2009-06-12 02:30:03 +08:00
|
|
|
/* $PostgreSQL: pgsql/contrib/hstore/hstore.sql.in,v 1.11 2009/06/11 18:30:03 tgl Exp $ */
|
2007-11-13 12:24:29 +08:00
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
-- Adjust this setting to control where the objects get created.
|
2006-09-06 02:00:58 +08:00
|
|
|
SET search_path = public;
|
|
|
|
|
2007-08-27 07:36:32 +08:00
|
|
|
CREATE TYPE hstore;
|
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION hstore_in(cstring)
|
2006-09-06 02:00:58 +08:00
|
|
|
RETURNS hstore
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-08-27 07:36:32 +08:00
|
|
|
LANGUAGE C STRICT;
|
2006-09-06 02:00:58 +08:00
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION hstore_out(hstore)
|
2006-09-06 02:00:58 +08:00
|
|
|
RETURNS cstring
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-08-27 07:36:32 +08:00
|
|
|
LANGUAGE C STRICT;
|
2006-09-06 02:00:58 +08:00
|
|
|
|
|
|
|
CREATE TYPE hstore (
|
|
|
|
INTERNALLENGTH = -1,
|
|
|
|
INPUT = hstore_in,
|
|
|
|
OUTPUT = hstore_out,
|
|
|
|
STORAGE = extended
|
|
|
|
);
|
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION fetchval(hstore,text)
|
2006-09-06 02:00:58 +08:00
|
|
|
RETURNS text
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-08-27 07:36:32 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE;
|
2006-09-06 02:00:58 +08:00
|
|
|
|
|
|
|
CREATE OPERATOR -> (
|
|
|
|
LEFTARG = hstore,
|
|
|
|
RIGHTARG = text,
|
|
|
|
PROCEDURE = fetchval
|
|
|
|
);
|
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION isexists(hstore,text)
|
2006-09-06 02:00:58 +08:00
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME','exists'
|
2007-08-27 07:36:32 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE;
|
2006-09-06 02:00:58 +08:00
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION exist(hstore,text)
|
2006-10-12 00:42:51 +08:00
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME','exists'
|
2007-08-27 07:36:32 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE;
|
2006-10-12 00:42:51 +08:00
|
|
|
|
2007-03-14 22:21:53 +08:00
|
|
|
CREATE OPERATOR ? (
|
|
|
|
LEFTARG = hstore,
|
|
|
|
RIGHTARG = text,
|
|
|
|
PROCEDURE = exist,
|
|
|
|
RESTRICT = contsel,
|
|
|
|
JOIN = contjoinsel
|
|
|
|
);
|
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION isdefined(hstore,text)
|
2006-09-06 02:00:58 +08:00
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME','defined'
|
2007-08-27 07:36:32 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE;
|
2006-09-06 02:00:58 +08:00
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION defined(hstore,text)
|
2006-10-12 00:42:51 +08:00
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME','defined'
|
2007-08-27 07:36:32 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE;
|
2006-10-12 00:42:51 +08:00
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION delete(hstore,text)
|
2006-09-06 02:00:58 +08:00
|
|
|
RETURNS hstore
|
|
|
|
AS 'MODULE_PATHNAME','delete'
|
2007-08-27 07:36:32 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE;
|
2006-09-06 02:00:58 +08:00
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION hs_concat(hstore,hstore)
|
2006-09-06 02:00:58 +08:00
|
|
|
RETURNS hstore
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-08-27 07:36:32 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE;
|
2006-09-06 02:00:58 +08:00
|
|
|
|
|
|
|
CREATE OPERATOR || (
|
|
|
|
LEFTARG = hstore,
|
|
|
|
RIGHTARG = hstore,
|
|
|
|
PROCEDURE = hs_concat
|
|
|
|
);
|
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION hs_contains(hstore,hstore)
|
2006-09-06 02:00:58 +08:00
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-08-27 07:36:32 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE;
|
2006-09-06 02:00:58 +08:00
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION hs_contained(hstore,hstore)
|
2006-09-11 01:36:52 +08:00
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-08-27 07:36:32 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE;
|
2006-09-11 01:36:52 +08:00
|
|
|
|
|
|
|
CREATE OPERATOR @> (
|
|
|
|
LEFTARG = hstore,
|
|
|
|
RIGHTARG = hstore,
|
|
|
|
PROCEDURE = hs_contains,
|
|
|
|
COMMUTATOR = '<@',
|
|
|
|
RESTRICT = contsel,
|
|
|
|
JOIN = contjoinsel
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE OPERATOR <@ (
|
|
|
|
LEFTARG = hstore,
|
|
|
|
RIGHTARG = hstore,
|
|
|
|
PROCEDURE = hs_contained,
|
|
|
|
COMMUTATOR = '@>',
|
|
|
|
RESTRICT = contsel,
|
|
|
|
JOIN = contjoinsel
|
|
|
|
);
|
|
|
|
|
|
|
|
-- obsolete:
|
2006-09-06 02:00:58 +08:00
|
|
|
CREATE OPERATOR @ (
|
|
|
|
LEFTARG = hstore,
|
|
|
|
RIGHTARG = hstore,
|
|
|
|
PROCEDURE = hs_contains,
|
|
|
|
COMMUTATOR = '~',
|
|
|
|
RESTRICT = contsel,
|
|
|
|
JOIN = contjoinsel
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE OPERATOR ~ (
|
|
|
|
LEFTARG = hstore,
|
|
|
|
RIGHTARG = hstore,
|
|
|
|
PROCEDURE = hs_contained,
|
|
|
|
COMMUTATOR = '@',
|
|
|
|
RESTRICT = contsel,
|
|
|
|
JOIN = contjoinsel
|
|
|
|
);
|
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION tconvert(text,text)
|
2006-09-06 02:00:58 +08:00
|
|
|
RETURNS hstore
|
|
|
|
AS 'MODULE_PATHNAME'
|
2009-06-12 02:30:03 +08:00
|
|
|
LANGUAGE C IMMUTABLE; -- not STRICT
|
2006-09-06 02:00:58 +08:00
|
|
|
|
|
|
|
CREATE OPERATOR => (
|
|
|
|
LEFTARG = text,
|
|
|
|
RIGHTARG = text,
|
|
|
|
PROCEDURE = tconvert
|
|
|
|
);
|
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION akeys(hstore)
|
2006-09-06 02:00:58 +08:00
|
|
|
RETURNS _text
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-08-27 07:36:32 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE;
|
2006-09-06 02:00:58 +08:00
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION avals(hstore)
|
2006-09-06 02:00:58 +08:00
|
|
|
RETURNS _text
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-08-27 07:36:32 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE;
|
2006-09-06 02:00:58 +08:00
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION skeys(hstore)
|
2006-09-06 02:00:58 +08:00
|
|
|
RETURNS setof text
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-08-27 07:36:32 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE;
|
2006-09-06 02:00:58 +08:00
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION svals(hstore)
|
2006-09-06 02:00:58 +08:00
|
|
|
RETURNS setof text
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-08-27 07:36:32 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE;
|
2006-09-06 02:00:58 +08:00
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION each(IN hs hstore,
|
2007-08-27 07:36:32 +08:00
|
|
|
OUT key text,
|
|
|
|
OUT value text)
|
|
|
|
RETURNS SETOF record
|
2006-09-06 02:00:58 +08:00
|
|
|
AS 'MODULE_PATHNAME'
|
2007-08-27 07:36:32 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE;
|
2006-09-06 02:00:58 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- define the GiST support methods
|
|
|
|
|
2007-08-27 07:36:32 +08:00
|
|
|
CREATE TYPE ghstore;
|
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION ghstore_in(cstring)
|
2006-09-06 02:00:58 +08:00
|
|
|
RETURNS ghstore
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-08-27 07:36:32 +08:00
|
|
|
LANGUAGE C STRICT;
|
2006-09-06 02:00:58 +08:00
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION ghstore_out(ghstore)
|
2006-09-06 02:00:58 +08:00
|
|
|
RETURNS cstring
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-08-27 07:36:32 +08:00
|
|
|
LANGUAGE C STRICT;
|
2006-09-06 02:00:58 +08:00
|
|
|
|
|
|
|
CREATE TYPE ghstore (
|
|
|
|
INTERNALLENGTH = -1,
|
|
|
|
INPUT = ghstore_in,
|
|
|
|
OUTPUT = ghstore_out
|
|
|
|
);
|
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION ghstore_compress(internal)
|
2006-09-06 02:00:58 +08:00
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
2009-06-12 02:30:03 +08:00
|
|
|
LANGUAGE C IMMUTABLE STRICT;
|
2006-09-06 02:00:58 +08:00
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION ghstore_decompress(internal)
|
2006-09-06 02:00:58 +08:00
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
2009-06-12 02:30:03 +08:00
|
|
|
LANGUAGE C IMMUTABLE STRICT;
|
2006-09-06 02:00:58 +08:00
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION ghstore_penalty(internal,internal,internal)
|
2006-09-06 02:00:58 +08:00
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 07:43:18 +08:00
|
|
|
LANGUAGE C IMMUTABLE STRICT;
|
2006-09-06 02:00:58 +08:00
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION ghstore_picksplit(internal, internal)
|
2006-09-06 02:00:58 +08:00
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
2009-06-12 02:30:03 +08:00
|
|
|
LANGUAGE C IMMUTABLE STRICT;
|
2006-09-06 02:00:58 +08:00
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION ghstore_union(internal, internal)
|
2006-09-06 02:00:58 +08:00
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
2009-06-12 02:30:03 +08:00
|
|
|
LANGUAGE C IMMUTABLE STRICT;
|
2006-09-06 02:00:58 +08:00
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION ghstore_same(internal, internal, internal)
|
2006-09-06 02:00:58 +08:00
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
2009-06-12 02:30:03 +08:00
|
|
|
LANGUAGE C IMMUTABLE STRICT;
|
2006-09-06 02:00:58 +08:00
|
|
|
|
2008-04-15 01:05:34 +08:00
|
|
|
CREATE OR REPLACE FUNCTION ghstore_consistent(internal,internal,int,oid,internal)
|
2006-09-06 02:00:58 +08:00
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
2009-06-12 02:30:03 +08:00
|
|
|
LANGUAGE C IMMUTABLE STRICT;
|
2006-09-06 02:00:58 +08:00
|
|
|
|
|
|
|
-- register the opclass for indexing (not as default)
|
|
|
|
CREATE OPERATOR CLASS gist_hstore_ops
|
|
|
|
DEFAULT FOR TYPE hstore USING gist
|
|
|
|
AS
|
2008-04-15 01:05:34 +08:00
|
|
|
OPERATOR 7 @> ,
|
|
|
|
OPERATOR 9 ?(hstore,text) ,
|
|
|
|
--OPERATOR 8 <@ ,
|
|
|
|
OPERATOR 13 @ ,
|
|
|
|
--OPERATOR 14 ~ ,
|
|
|
|
FUNCTION 1 ghstore_consistent (internal, internal, int, oid, internal),
|
2006-09-06 02:00:58 +08:00
|
|
|
FUNCTION 2 ghstore_union (internal, internal),
|
|
|
|
FUNCTION 3 ghstore_compress (internal),
|
|
|
|
FUNCTION 4 ghstore_decompress (internal),
|
|
|
|
FUNCTION 5 ghstore_penalty (internal, internal, internal),
|
|
|
|
FUNCTION 6 ghstore_picksplit (internal, internal),
|
|
|
|
FUNCTION 7 ghstore_same (internal, internal, internal),
|
|
|
|
STORAGE ghstore;
|
|
|
|
|
2007-03-14 22:21:53 +08:00
|
|
|
-- define the GIN support methods
|
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION gin_extract_hstore(internal, internal)
|
2007-03-14 22:21:53 +08:00
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
2009-06-12 02:30:03 +08:00
|
|
|
LANGUAGE C IMMUTABLE STRICT;
|
2007-03-14 22:21:53 +08:00
|
|
|
|
2009-03-26 06:19:02 +08:00
|
|
|
CREATE OR REPLACE FUNCTION gin_extract_hstore_query(internal, internal, int2, internal, internal)
|
2007-03-14 22:21:53 +08:00
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
2009-06-12 02:30:03 +08:00
|
|
|
LANGUAGE C IMMUTABLE STRICT;
|
2007-03-14 22:21:53 +08:00
|
|
|
|
2009-03-26 06:19:02 +08:00
|
|
|
CREATE OR REPLACE FUNCTION gin_consistent_hstore(internal, int2, internal, int4, internal, internal)
|
2008-04-15 01:05:34 +08:00
|
|
|
RETURNS bool
|
2007-03-14 22:21:53 +08:00
|
|
|
AS 'MODULE_PATHNAME'
|
2009-06-12 02:30:03 +08:00
|
|
|
LANGUAGE C IMMUTABLE STRICT;
|
2007-03-14 22:21:53 +08:00
|
|
|
|
|
|
|
CREATE OPERATOR CLASS gin_hstore_ops
|
|
|
|
DEFAULT FOR TYPE hstore USING gin
|
|
|
|
AS
|
2008-04-15 01:05:34 +08:00
|
|
|
OPERATOR 7 @> ,
|
2007-09-30 07:43:18 +08:00
|
|
|
OPERATOR 9 ?(hstore,text),
|
2007-03-14 22:21:53 +08:00
|
|
|
FUNCTION 1 bttextcmp(text,text),
|
|
|
|
FUNCTION 2 gin_extract_hstore(internal, internal),
|
2009-03-26 06:19:02 +08:00
|
|
|
FUNCTION 3 gin_extract_hstore_query(internal, internal, int2, internal, internal),
|
|
|
|
FUNCTION 4 gin_consistent_hstore(internal, int2, internal, int4, internal, internal),
|
2007-03-14 22:21:53 +08:00
|
|
|
STORAGE text;
|