Replace the hard-wired type knowledge in TypeCategory() and IsPreferredType()
[PostgreSQL.git] / contrib / hstore / hstore.sql.in
blob0ccc71cab363bbd26c9c7a04cb976d23ecec7515
1 /* $PostgreSQL$ */
3 -- Adjust this setting to control where the objects get created.
4 SET search_path = public;
6 CREATE TYPE hstore;
8 CREATE OR REPLACE FUNCTION hstore_in(cstring)
9 RETURNS hstore
10 AS 'MODULE_PATHNAME'
11 LANGUAGE C STRICT;
13 CREATE OR REPLACE FUNCTION hstore_out(hstore)
14 RETURNS cstring
15 AS 'MODULE_PATHNAME'
16 LANGUAGE C STRICT;
18 CREATE TYPE hstore (
19 INTERNALLENGTH = -1,
20 INPUT = hstore_in,
21 OUTPUT = hstore_out,
22 STORAGE = extended
25 CREATE OR REPLACE FUNCTION fetchval(hstore,text)
26 RETURNS text
27 AS 'MODULE_PATHNAME'
28 LANGUAGE C STRICT IMMUTABLE;
30 CREATE OPERATOR -> (
31 LEFTARG = hstore,
32 RIGHTARG = text,
33 PROCEDURE = fetchval
36 CREATE OR REPLACE FUNCTION isexists(hstore,text)
37 RETURNS bool
38 AS 'MODULE_PATHNAME','exists'
39 LANGUAGE C STRICT IMMUTABLE;
41 CREATE OR REPLACE FUNCTION exist(hstore,text)
42 RETURNS bool
43 AS 'MODULE_PATHNAME','exists'
44 LANGUAGE C STRICT IMMUTABLE;
46 CREATE OPERATOR ? (
47 LEFTARG = hstore,
48 RIGHTARG = text,
49 PROCEDURE = exist,
50 RESTRICT = contsel,
51 JOIN = contjoinsel
54 CREATE OR REPLACE FUNCTION isdefined(hstore,text)
55 RETURNS bool
56 AS 'MODULE_PATHNAME','defined'
57 LANGUAGE C STRICT IMMUTABLE;
59 CREATE OR REPLACE FUNCTION defined(hstore,text)
60 RETURNS bool
61 AS 'MODULE_PATHNAME','defined'
62 LANGUAGE C STRICT IMMUTABLE;
64 CREATE OR REPLACE FUNCTION delete(hstore,text)
65 RETURNS hstore
66 AS 'MODULE_PATHNAME','delete'
67 LANGUAGE C STRICT IMMUTABLE;
69 CREATE OR REPLACE FUNCTION hs_concat(hstore,hstore)
70 RETURNS hstore
71 AS 'MODULE_PATHNAME'
72 LANGUAGE C STRICT IMMUTABLE;
74 CREATE OPERATOR || (
75 LEFTARG = hstore,
76 RIGHTARG = hstore,
77 PROCEDURE = hs_concat
80 CREATE OR REPLACE FUNCTION hs_contains(hstore,hstore)
81 RETURNS bool
82 AS 'MODULE_PATHNAME'
83 LANGUAGE C STRICT IMMUTABLE;
85 CREATE OR REPLACE FUNCTION hs_contained(hstore,hstore)
86 RETURNS bool
87 AS 'MODULE_PATHNAME'
88 LANGUAGE C STRICT IMMUTABLE;
90 CREATE OPERATOR @> (
91 LEFTARG = hstore,
92 RIGHTARG = hstore,
93 PROCEDURE = hs_contains,
94 COMMUTATOR = '<@',
95 RESTRICT = contsel,
96 JOIN = contjoinsel
99 CREATE OPERATOR <@ (
100 LEFTARG = hstore,
101 RIGHTARG = hstore,
102 PROCEDURE = hs_contained,
103 COMMUTATOR = '@>',
104 RESTRICT = contsel,
105 JOIN = contjoinsel
108 -- obsolete:
109 CREATE OPERATOR @ (
110 LEFTARG = hstore,
111 RIGHTARG = hstore,
112 PROCEDURE = hs_contains,
113 COMMUTATOR = '~',
114 RESTRICT = contsel,
115 JOIN = contjoinsel
118 CREATE OPERATOR ~ (
119 LEFTARG = hstore,
120 RIGHTARG = hstore,
121 PROCEDURE = hs_contained,
122 COMMUTATOR = '@',
123 RESTRICT = contsel,
124 JOIN = contjoinsel
127 CREATE OR REPLACE FUNCTION tconvert(text,text)
128 RETURNS hstore
129 AS 'MODULE_PATHNAME'
130 LANGUAGE C IMMUTABLE;
132 CREATE OPERATOR => (
133 LEFTARG = text,
134 RIGHTARG = text,
135 PROCEDURE = tconvert
138 CREATE OR REPLACE FUNCTION akeys(hstore)
139 RETURNS _text
140 AS 'MODULE_PATHNAME'
141 LANGUAGE C STRICT IMMUTABLE;
143 CREATE OR REPLACE FUNCTION avals(hstore)
144 RETURNS _text
145 AS 'MODULE_PATHNAME'
146 LANGUAGE C STRICT IMMUTABLE;
148 CREATE OR REPLACE FUNCTION skeys(hstore)
149 RETURNS setof text
150 AS 'MODULE_PATHNAME'
151 LANGUAGE C STRICT IMMUTABLE;
153 CREATE OR REPLACE FUNCTION svals(hstore)
154 RETURNS setof text
155 AS 'MODULE_PATHNAME'
156 LANGUAGE C STRICT IMMUTABLE;
158 CREATE OR REPLACE FUNCTION each(IN hs hstore,
159 OUT key text,
160 OUT value text)
161 RETURNS SETOF record
162 AS 'MODULE_PATHNAME'
163 LANGUAGE C STRICT IMMUTABLE;
167 -- define the GiST support methods
169 CREATE TYPE ghstore;
171 CREATE OR REPLACE FUNCTION ghstore_in(cstring)
172 RETURNS ghstore
173 AS 'MODULE_PATHNAME'
174 LANGUAGE C STRICT;
176 CREATE OR REPLACE FUNCTION ghstore_out(ghstore)
177 RETURNS cstring
178 AS 'MODULE_PATHNAME'
179 LANGUAGE C STRICT;
181 CREATE TYPE ghstore (
182 INTERNALLENGTH = -1,
183 INPUT = ghstore_in,
184 OUTPUT = ghstore_out
187 CREATE OR REPLACE FUNCTION ghstore_compress(internal)
188 RETURNS internal
189 AS 'MODULE_PATHNAME'
190 LANGUAGE C IMMUTABLE;
192 CREATE OR REPLACE FUNCTION ghstore_decompress(internal)
193 RETURNS internal
194 AS 'MODULE_PATHNAME'
195 LANGUAGE C IMMUTABLE;
197 CREATE OR REPLACE FUNCTION ghstore_penalty(internal,internal,internal)
198 RETURNS internal
199 AS 'MODULE_PATHNAME'
200 LANGUAGE C IMMUTABLE STRICT;
202 CREATE OR REPLACE FUNCTION ghstore_picksplit(internal, internal)
203 RETURNS internal
204 AS 'MODULE_PATHNAME'
205 LANGUAGE C IMMUTABLE;
207 CREATE OR REPLACE FUNCTION ghstore_union(internal, internal)
208 RETURNS internal
209 AS 'MODULE_PATHNAME'
210 LANGUAGE C IMMUTABLE;
212 CREATE OR REPLACE FUNCTION ghstore_same(internal, internal, internal)
213 RETURNS internal
214 AS 'MODULE_PATHNAME'
215 LANGUAGE C IMMUTABLE;
217 CREATE OR REPLACE FUNCTION ghstore_consistent(internal,internal,int,oid,internal)
218 RETURNS bool
219 AS 'MODULE_PATHNAME'
220 LANGUAGE C IMMUTABLE;
222 -- register the opclass for indexing (not as default)
223 CREATE OPERATOR CLASS gist_hstore_ops
224 DEFAULT FOR TYPE hstore USING gist
226 OPERATOR 7 @> ,
227 OPERATOR 9 ?(hstore,text) ,
228 --OPERATOR 8 <@ ,
229 OPERATOR 13 @ ,
230 --OPERATOR 14 ~ ,
231 FUNCTION 1 ghstore_consistent (internal, internal, int, oid, internal),
232 FUNCTION 2 ghstore_union (internal, internal),
233 FUNCTION 3 ghstore_compress (internal),
234 FUNCTION 4 ghstore_decompress (internal),
235 FUNCTION 5 ghstore_penalty (internal, internal, internal),
236 FUNCTION 6 ghstore_picksplit (internal, internal),
237 FUNCTION 7 ghstore_same (internal, internal, internal),
238 STORAGE ghstore;
240 -- define the GIN support methods
242 CREATE OR REPLACE FUNCTION gin_extract_hstore(internal, internal)
243 RETURNS internal
244 AS 'MODULE_PATHNAME'
245 LANGUAGE C IMMUTABLE;
247 CREATE OR REPLACE FUNCTION gin_extract_hstore_query(internal, internal, int2)
248 RETURNS internal
249 AS 'MODULE_PATHNAME'
250 LANGUAGE C IMMUTABLE;
252 CREATE OR REPLACE FUNCTION gin_consistent_hstore(internal, int2, internal, internal)
253 RETURNS bool
254 AS 'MODULE_PATHNAME'
255 LANGUAGE C IMMUTABLE;
257 CREATE OPERATOR CLASS gin_hstore_ops
258 DEFAULT FOR TYPE hstore USING gin
260 OPERATOR 7 @> ,
261 OPERATOR 9 ?(hstore,text),
262 FUNCTION 1 bttextcmp(text,text),
263 FUNCTION 2 gin_extract_hstore(internal, internal),
264 FUNCTION 3 gin_extract_hstore_query(internal, internal, int2),
265 FUNCTION 4 gin_consistent_hstore(internal, int2, internal, internal),
266 STORAGE text;