Skip to content

Commit 1afd9fb

Browse files
Fix upgrade script for 1.5.0 to 1.6.0 (#2210)
- Since there are modifications to agtype gin operators, users will have to drop the gin indexes before running this script and recreate them.
1 parent 4cc02ad commit 1afd9fb

File tree

1 file changed

+25
-29
lines changed

1 file changed

+25
-29
lines changed

age--1.5.0--1.6.0.sql

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,18 @@ ALTER EXTENSION age
7878
ALTER EXTENSION age
7979
DROP OPERATOR ?| (agtype, text[]);
8080
ALTER EXTENSION age
81-
DROP OPERATOR ?& (agtype, agtype[]);
81+
DROP OPERATOR ?& (agtype, agtype);
8282
ALTER EXTENSION age
83-
DROP OPERATOR ?& (agtype, text);
83+
DROP OPERATOR ?& (agtype, text[]);
84+
ALTER EXTENSION age
85+
DROP OPERATOR @> (agtype, agtype);
86+
ALTER EXTENSION age
87+
DROP OPERATOR <@ (agtype, agtype);
8488

8589
DROP OPERATOR ? (agtype, agtype), ? (agtype, text),
8690
?| (agtype, agtype), ?| (agtype, text[]),
87-
?& (agtype, agtype[]), ?& (agtype, text);
91+
?& (agtype, agtype), ?& (agtype, text[]),
92+
@> (agtype, agtype), <@ (agtype, agtype);
8893

8994
CREATE OPERATOR ? (
9095
LEFTARG = agtype,
@@ -134,30 +139,23 @@ CREATE OPERATOR ?& (
134139
JOIN = matchingjoinsel
135140
);
136141

137-
ALTER EXTENSION age
138-
ADD OPERATOR ? (agtype, agtype);
139-
ALTER EXTENSION age
140-
ADD OPERATOR ? (agtype, text);
141-
ALTER EXTENSION age
142-
ADD OPERATOR ?| (agtype, agtype);
143-
ALTER EXTENSION age
144-
ADD OPERATOR ?| (agtype, text[]);
145-
ALTER EXTENSION age
146-
ADD OPERATOR ?& (agtype, agtype[]);
147-
ALTER EXTENSION age
148-
ADD OPERATOR ?& (agtype, text);
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);
142+
CREATE OPERATOR @> (
143+
LEFTARG = agtype,
144+
RIGHTARG = agtype,
145+
FUNCTION = ag_catalog.agtype_contains,
146+
COMMUTATOR = '<@',
147+
RESTRICT = matchingsel,
148+
JOIN = matchingjoinsel
149+
);
158150

159-
ALTER OPERATOR <@ (agtype, agtype)
160-
SET (RESTRICT = matchingsel, JOIN = matchingjoinsel);
151+
CREATE OPERATOR <@ (
152+
LEFTARG = agtype,
153+
RIGHTARG = agtype,
154+
FUNCTION = ag_catalog.agtype_contained_by,
155+
COMMUTATOR = '@>',
156+
RESTRICT = matchingsel,
157+
JOIN = matchingjoinsel
158+
);
161159

162160
/*
163161
* Since there is no option to add or drop operator from class,
@@ -169,6 +167,7 @@ ALTER EXTENSION age
169167
DROP OPERATOR CLASS ag_catalog.gin_agtype_ops USING gin;
170168

171169
DROP OPERATOR CLASS ag_catalog.gin_agtype_ops USING gin;
170+
DROP OPERATOR FAMILY ag_catalog.gin_agtype_ops USING gin;
172171

173172
CREATE OPERATOR CLASS ag_catalog.gin_agtype_ops
174173
DEFAULT FOR TYPE agtype USING gin AS
@@ -189,9 +188,6 @@ DEFAULT FOR TYPE agtype USING gin AS
189188
internal, internal, internal),
190189
STORAGE text;
191190

192-
ALTER EXTENSION age
193-
ADD OPERATOR CLASS ag_catalog.gin_agtype_ops USING gin;
194-
195191
-- this function went from variadic "any" to just "any" type
196192
CREATE OR REPLACE FUNCTION ag_catalog.age_tostring("any")
197193
RETURNS agtype

0 commit comments

Comments
 (0)