BEGIN;
+CREATE TYPE hstore;
+
CREATE FUNCTION hstore_in(cstring)
RETURNS hstore
AS 'MODULE_PATHNAME'
-LANGUAGE 'C' with (isstrict);
+LANGUAGE C STRICT;
CREATE FUNCTION hstore_out(hstore)
RETURNS cstring
AS 'MODULE_PATHNAME'
-LANGUAGE 'C' with (isstrict);
+LANGUAGE C STRICT;
CREATE TYPE hstore (
INTERNALLENGTH = -1,
CREATE FUNCTION fetchval(hstore,text)
RETURNS text
AS 'MODULE_PATHNAME'
-LANGUAGE 'C' with (isstrict,iscachable);
+LANGUAGE C STRICT IMMUTABLE;
CREATE OPERATOR -> (
LEFTARG = hstore,
CREATE FUNCTION isexists(hstore,text)
RETURNS bool
AS 'MODULE_PATHNAME','exists'
-LANGUAGE 'C' with (isstrict,iscachable);
+LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION exist(hstore,text)
RETURNS bool
AS 'MODULE_PATHNAME','exists'
-LANGUAGE 'C' with (isstrict,iscachable);
+LANGUAGE C STRICT IMMUTABLE;
CREATE OPERATOR ? (
LEFTARG = hstore,
CREATE FUNCTION isdefined(hstore,text)
RETURNS bool
AS 'MODULE_PATHNAME','defined'
-LANGUAGE 'C' with (isstrict,iscachable);
+LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION defined(hstore,text)
RETURNS bool
AS 'MODULE_PATHNAME','defined'
-LANGUAGE 'C' with (isstrict,iscachable);
+LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION delete(hstore,text)
RETURNS hstore
AS 'MODULE_PATHNAME','delete'
-LANGUAGE 'C' with (isstrict,iscachable);
+LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION hs_concat(hstore,hstore)
RETURNS hstore
AS 'MODULE_PATHNAME'
-LANGUAGE 'C' with (isstrict,iscachable);
+LANGUAGE C STRICT IMMUTABLE;
CREATE OPERATOR || (
LEFTARG = hstore,
CREATE FUNCTION hs_contains(hstore,hstore)
RETURNS bool
AS 'MODULE_PATHNAME'
-LANGUAGE 'C' with (isstrict,iscachable);
+LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION hs_contained(hstore,hstore)
RETURNS bool
AS 'MODULE_PATHNAME'
-LANGUAGE 'C' with (isstrict,iscachable);
+LANGUAGE C STRICT IMMUTABLE;
CREATE OPERATOR @> (
LEFTARG = hstore,
CREATE FUNCTION tconvert(text,text)
RETURNS hstore
AS 'MODULE_PATHNAME'
-LANGUAGE 'C' with (iscachable);
+LANGUAGE C IMMUTABLE;
CREATE OPERATOR => (
LEFTARG = text,
CREATE FUNCTION akeys(hstore)
RETURNS _text
AS 'MODULE_PATHNAME'
-LANGUAGE 'C' with (isstrict,iscachable);
+LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION avals(hstore)
RETURNS _text
AS 'MODULE_PATHNAME'
-LANGUAGE 'C' with (isstrict,iscachable);
+LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION skeys(hstore)
RETURNS setof text
AS 'MODULE_PATHNAME'
-LANGUAGE 'C' with (isstrict,iscachable);
+LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION svals(hstore)
RETURNS setof text
AS 'MODULE_PATHNAME'
-LANGUAGE 'C' with (isstrict,iscachable);
-
-create type hs_each as (key text, value text);
+LANGUAGE C STRICT IMMUTABLE;
-CREATE FUNCTION each(hstore)
-RETURNS setof hs_each
+CREATE FUNCTION each(IN hs hstore,
+ OUT key text,
+ OUT value text)
+RETURNS SETOF record
AS 'MODULE_PATHNAME'
-LANGUAGE 'C' with (isstrict,iscachable);
+LANGUAGE C STRICT IMMUTABLE;
-- define the GiST support methods
+CREATE TYPE ghstore;
+
CREATE FUNCTION ghstore_in(cstring)
RETURNS ghstore
AS 'MODULE_PATHNAME'
-LANGUAGE 'C' with (isstrict);
+LANGUAGE C STRICT;
CREATE FUNCTION ghstore_out(ghstore)
RETURNS cstring
AS 'MODULE_PATHNAME'
-LANGUAGE 'C' with (isstrict);
+LANGUAGE C STRICT;
CREATE TYPE ghstore (
INTERNALLENGTH = -1,
CREATE FUNCTION ghstore_compress(internal)
RETURNS internal
AS 'MODULE_PATHNAME'
-LANGUAGE 'C';
+LANGUAGE C;
CREATE FUNCTION ghstore_decompress(internal)
RETURNS internal
AS 'MODULE_PATHNAME'
-LANGUAGE 'C';
+LANGUAGE C;
CREATE FUNCTION ghstore_penalty(internal,internal,internal)
RETURNS internal
AS 'MODULE_PATHNAME'
-LANGUAGE 'C' WITH (isstrict);
+LANGUAGE C STRICT;
CREATE FUNCTION ghstore_picksplit(internal, internal)
RETURNS internal
AS 'MODULE_PATHNAME'
-LANGUAGE 'C';
+LANGUAGE C;
CREATE FUNCTION ghstore_union(internal, internal)
RETURNS internal
AS 'MODULE_PATHNAME'
-LANGUAGE 'C';
+LANGUAGE C;
CREATE FUNCTION ghstore_same(internal, internal, internal)
RETURNS internal
AS 'MODULE_PATHNAME'
-LANGUAGE 'C';
+LANGUAGE C;
CREATE FUNCTION ghstore_consistent(internal,internal,int4)
RETURNS bool
AS 'MODULE_PATHNAME'
-LANGUAGE 'C';
+LANGUAGE C;
-- register the opclass for indexing (not as default)
CREATE OPERATOR CLASS gist_hstore_ops
memcpy(st->hs, hs, VARSIZE(hs));
funcctx->user_fctx = (void *) st;
- tupdesc = RelationNameGetTupleDesc("hs_each");
- funcctx->slot = TupleDescGetSlot(tupdesc);
+ /* Build a tuple descriptor for our result type */
+ if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
+ elog(ERROR, "return type must be a row type");
+
funcctx->attinmeta = TupleDescGetAttInMetadata(tupdesc);
MemoryContextSwitchTo(oldcontext);
st->i++;
tuple = heap_formtuple(funcctx->attinmeta->tupdesc, dvalues, nulls);
- res = TupleGetDatum(funcctx->slot, tuple);
+ res = HeapTupleGetDatum(tuple);
pfree(DatumGetPointer(dvalues[0]));
if (nulls[1] != 'n')