Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hash functions correctly depend on _eq functions #637

Merged
merged 1 commit into from
Aug 18, 2022
Merged

Hash functions correctly depend on _eq functions #637

merged 1 commit into from
Aug 18, 2022

Conversation

willmurnane
Copy link
Contributor

When a function is marked with #[derive(PostgresHash, ...)] SQL code like the following is generated:

CREATE OPERATOR FAMILY Foo_hash_ops USING hash;
CREATE OPERATOR CLASS Foo_hash_ops DEFAULT FOR TYPE Foo USING hash FAMILY Foo_hash_ops AS
	OPERATOR    1   =  (Foo, Foo),
	FUNCTION    1   foo_hash(Foo);

However, in the pgx schema DAG, there is no dependency currently emitted between the OPERATOR CLASS and the foo_eq function (or the OPERATOR = associated with it). This means about half the time, the hash stuff is generated before the definition of equals, which means the extension will fail to install.

This merge request adds a dependency to the DAG, causing the equals function to always be emitted before the hash function. Closes #611 .

Copy link
Contributor

@Hoverbear Hoverbear left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rest looks good!

@workingjubilee
Copy link
Member

This looks lovely! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants