@@ -41,8 +41,8 @@ CREATE OPERATOR @>> (
4141 RIGHTARG = agtype,
4242 FUNCTION = ag_catalog .agtype_contains_top_level ,
4343 COMMUTATOR = ' <<@' ,
44- RESTRICT = contsel ,
45- JOIN = contjoinsel
44+ RESTRICT = matchingsel ,
45+ JOIN = matchingjoinsel
4646);
4747
4848CREATE FUNCTION ag_catalog .agtype_contained_by_top_level(agtype, agtype)
@@ -58,17 +58,114 @@ CREATE OPERATOR <<@ (
5858 RIGHTARG = agtype,
5959 FUNCTION = ag_catalog .agtype_contained_by_top_level ,
6060 COMMUTATOR = ' @>>' ,
61- RESTRICT = contsel ,
62- JOIN = contjoinsel
61+ RESTRICT = matchingsel ,
62+ JOIN = matchingjoinsel
6363);
6464
65+ /*
66+ * We have to drop and recreate the operators, because
67+ * commutator is not modifiable using ALTER OPERATOR.
68+ */
69+ ALTER EXTENSION age
70+ DROP OPERATOR ? (agtype, agtype);
71+ ALTER EXTENSION age
72+ DROP OPERATOR ? (agtype, text );
73+ ALTER EXTENSION age
74+ DROP OPERATOR ?| (agtype, agtype);
75+ ALTER EXTENSION age
76+ DROP OPERATOR ?| (agtype, text []);
77+ ALTER EXTENSION age
78+ DROP OPERATOR ?& (agtype, agtype[]);
79+ ALTER EXTENSION age
80+ DROP OPERATOR ?& (agtype, text );
81+
82+ DROP OPERATOR ? (agtype, agtype), ? (agtype, text ),
83+ ?| (agtype, agtype), ?| (agtype, text []),
84+ ?& (agtype, agtype[]), ?& (agtype, text );
85+
86+ CREATE OPERATOR ? (
87+ LEFTARG = agtype,
88+ RIGHTARG = agtype,
89+ FUNCTION = ag_catalog .agtype_exists_agtype ,
90+ RESTRICT = matchingsel,
91+ JOIN = matchingjoinsel
92+ );
93+
94+ CREATE OPERATOR ? (
95+ LEFTARG = agtype,
96+ RIGHTARG = text ,
97+ FUNCTION = ag_catalog .agtype_exists ,
98+ RESTRICT = matchingsel,
99+ JOIN = matchingjoinsel
100+ );
101+
102+ CREATE OPERATOR ?| (
103+ LEFTARG = agtype,
104+ RIGHTARG = agtype,
105+ FUNCTION = ag_catalog .agtype_exists_any_agtype ,
106+ RESTRICT = matchingsel,
107+ JOIN = matchingjoinsel
108+ );
109+
110+ CREATE OPERATOR ?| (
111+ LEFTARG = agtype,
112+ RIGHTARG = text [],
113+ FUNCTION = ag_catalog .agtype_exists_any ,
114+ RESTRICT = matchingsel,
115+ JOIN = matchingjoinsel
116+ );
117+
118+ CREATE OPERATOR ?& (
119+ LEFTARG = agtype,
120+ RIGHTARG = agtype,
121+ FUNCTION = ag_catalog .agtype_exists_all_agtype ,
122+ RESTRICT = matchingsel,
123+ JOIN = matchingjoinsel
124+ );
125+
126+ CREATE OPERATOR ?& (
127+ LEFTARG = agtype,
128+ RIGHTARG = text [],
129+ FUNCTION = ag_catalog .agtype_exists_all ,
130+ RESTRICT = matchingsel,
131+ JOIN = matchingjoinsel
132+ );
133+
134+ ALTER EXTENSION age
135+ ADD OPERATOR ? (agtype, agtype);
136+ ALTER EXTENSION age
137+ ADD OPERATOR ? (agtype, text );
138+ ALTER EXTENSION age
139+ ADD OPERATOR ?| (agtype, agtype);
140+ ALTER EXTENSION age
141+ ADD OPERATOR ?| (agtype, text []);
142+ ALTER EXTENSION age
143+ ADD OPERATOR ?& (agtype, agtype[]);
144+ ALTER EXTENSION age
145+ ADD OPERATOR ?& (agtype, text );
146+
147+ ALTER OPERATOR @> (agtype, agtype)
148+ SET (RESTRICT = matchingsel, JOIN = matchingjoinsel);
149+
150+ ALTER OPERATOR @> (agtype, agtype)
151+ SET (RESTRICT = matchingsel, JOIN = matchingjoinsel);
152+
153+ ALTER OPERATOR < @ (agtype, agtype)
154+ SET (RESTRICT = matchingsel, JOIN = matchingjoinsel);
155+
156+ ALTER OPERATOR < @ (agtype, agtype)
157+ SET (RESTRICT = matchingsel, JOIN = matchingjoinsel);
158+
65159/*
66160 * Since there is no option to add or drop operator from class,
67161 * we have to drop and recreate the whole operator class.
68162 * Reference: https://www.postgresql.org/docs/current/sql-alteropclass.html
69163 */
70164
71- DROP OPERATOR CLASS ag_catalog .gin_agtype_ops ;
165+ ALTER EXTENSION age
166+ DROP OPERATOR CLASS ag_catalog .gin_agtype_ops USING gin;
167+
168+ DROP OPERATOR CLASS ag_catalog .gin_agtype_ops USING gin;
72169
73170CREATE OPERATOR CLASS ag_catalog .gin_agtype_ops
74171DEFAULT FOR TYPE agtype USING gin AS
@@ -89,6 +186,9 @@ DEFAULT FOR TYPE agtype USING gin AS
89186 internal, internal, internal),
90187STORAGE text ;
91188
189+ ALTER EXTENSION age
190+ ADD OPERATOR CLASS ag_catalog .gin_agtype_ops USING gin;
191+
92192-- this function went from variadic "any" to just "any" type
93193CREATE OR REPLACE FUNCTION ag_catalog .age_tostring(" any" )
94194 RETURNS agtype
@@ -148,4 +248,10 @@ PARALLEL SAFE
148248AS ' MODULE_PATHNAME' ;
149249
150250CREATE CAST (agtype[] AS agtype)
151- WITH FUNCTION ag_catalog .agtype_array_to_agtype (agtype[]);
251+ WITH FUNCTION ag_catalog .agtype_array_to_agtype (agtype[]);
252+
253+ CREATE OPERATOR = ~ (
254+ LEFTARG = agtype,
255+ RIGHTARG = agtype,
256+ FUNCTION = ag_catalog .age_eq_tilde
257+ );
0 commit comments