Skip to content

Conversation

@LucaCappelletti94
Copy link
Contributor

Adds support for CREATE OPERATOR, CREATE OPERATOR FAMILY, and CREATE OPERATOR CLASS statements.

Examples

-- CREATE OPERATOR with all parameters
CREATE OPERATOR < (
    PROCEDURE = cas_lt,
    LEFTARG = CAS,
    RIGHTARG = CAS,
    COMMUTATOR = >,
    NEGATOR = >=,
    RESTRICT = scalarltsel,
    JOIN = scalarltjoinsel
);

-- CREATE OPERATOR FAMILY
CREATE OPERATOR FAMILY integer_ops USING btree;

-- CREATE OPERATOR CLASS
CREATE OPERATOR CLASS int4_ops
    DEFAULT FOR TYPE int4 USING btree FAMILY integer_ops AS
    OPERATOR 1 <,
    OPERATOR 2 <=,
    FUNCTION 1 btint4cmp(int4, int4),
    STORAGE int4;

Copy link
Contributor

@iffyio iffyio left a comment

Choose a reason for hiding this comment

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

Left some comments, a bit worried that its a lot of code and seems to be lacking test coverage, I tried to point out a few of them but would be good that we do a full pass to ensure code coverage in the PR


/// Helper function to parse an operator name (which can contain special characters)
/// Operator names can be schema-qualified (e.g., schema.operator)
fn parse_operator_name(&mut self) -> Result<ObjectName, ParserError> {
Copy link
Contributor

Choose a reason for hiding this comment

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

does this differ from parse_object_name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Basically, the other function does not support correctly the cases where the operator name is + or schema_name.@ etc etc

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.

2 participants