Just some fixups to a couple contrib directories I was trying out.

. replace CREATE OR REPLACE AGGREGATE with a separate DROP and CREATE
. add DROP for all CREATE OPERATORs
. use IMMUTABLE and STRICT instead of WITH (isStrict)
. add IMMUTABLE and STRICT to int_array_aggregate's accumulator function

Gregory Stark
This commit is contained in:
Bruce Momjian 2003-03-20 04:39:27 +00:00
parent 900fa3d0f5
commit ee303739d3
2 changed files with 65 additions and 34 deletions

View File

@ -11,41 +11,45 @@ SET autocommit TO 'on';
CREATE OR REPLACE FUNCTION array_texteq(_text, text) CREATE OR REPLACE FUNCTION array_texteq(_text, text)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict); LANGUAGE 'C' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION array_all_texteq(_text, text) CREATE OR REPLACE FUNCTION array_all_texteq(_text, text)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict); LANGUAGE 'C' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION array_textregexeq(_text, text) CREATE OR REPLACE FUNCTION array_textregexeq(_text, text)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict); LANGUAGE 'C' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION array_all_textregexeq(_text, text) CREATE OR REPLACE FUNCTION array_all_textregexeq(_text, text)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict); LANGUAGE 'C' IMMUTABLE STRICT;
DROP OPERATOR *=(_text,text);
CREATE OPERATOR *= ( CREATE OPERATOR *= (
LEFTARG=_text, LEFTARG=_text,
RIGHTARG=text, RIGHTARG=text,
PROCEDURE=array_texteq PROCEDURE=array_texteq
); );
DROP OPERATOR **=(_text,text);
CREATE OPERATOR **= ( CREATE OPERATOR **= (
LEFTARG=_text, LEFTARG=_text,
RIGHTARG=text, RIGHTARG=text,
PROCEDURE=array_all_texteq PROCEDURE=array_all_texteq
); );
DROP OPERATOR *~(_text,text);
CREATE OPERATOR *~ ( CREATE OPERATOR *~ (
LEFTARG=_text, LEFTARG=_text,
RIGHTARG=text, RIGHTARG=text,
PROCEDURE=array_textregexeq PROCEDURE=array_textregexeq
); );
DROP OPERATOR **~(_text,text);
CREATE OPERATOR **~ ( CREATE OPERATOR **~ (
LEFTARG=_text, LEFTARG=_text,
RIGHTARG=text, RIGHTARG=text,
@ -60,41 +64,45 @@ CREATE OPERATOR **~ (
CREATE OR REPLACE FUNCTION array_varchareq(_varchar, varchar) CREATE OR REPLACE FUNCTION array_varchareq(_varchar, varchar)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict); LANGUAGE 'C' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION array_all_varchareq(_varchar, varchar) CREATE OR REPLACE FUNCTION array_all_varchareq(_varchar, varchar)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict); LANGUAGE 'C' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION array_varcharregexeq(_varchar, varchar) CREATE OR REPLACE FUNCTION array_varcharregexeq(_varchar, varchar)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict); LANGUAGE 'C' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION array_all_varcharregexeq(_varchar, varchar) CREATE OR REPLACE FUNCTION array_all_varcharregexeq(_varchar, varchar)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict); LANGUAGE 'C' IMMUTABLE STRICT;
DROP OPERATOR *=(_varchar,"varchar");
CREATE OPERATOR *= ( CREATE OPERATOR *= (
LEFTARG=_varchar, LEFTARG=_varchar,
RIGHTARG="varchar", RIGHTARG="varchar",
PROCEDURE=array_varchareq PROCEDURE=array_varchareq
); );
DROP OPERATOR **=(_varchar,"varchar");
CREATE OPERATOR **= ( CREATE OPERATOR **= (
LEFTARG=_varchar, LEFTARG=_varchar,
RIGHTARG="varchar", RIGHTARG="varchar",
PROCEDURE=array_all_varchareq PROCEDURE=array_all_varchareq
); );
DROP OPERATOR *~(_varchar,"varchar");
CREATE OPERATOR *~ ( CREATE OPERATOR *~ (
LEFTARG=_varchar, LEFTARG=_varchar,
RIGHTARG="varchar", RIGHTARG="varchar",
PROCEDURE=array_varcharregexeq PROCEDURE=array_varcharregexeq
); );
DROP OPERATOR **~(_varchar,"varchar");
CREATE OPERATOR **~ ( CREATE OPERATOR **~ (
LEFTARG=_varchar, LEFTARG=_varchar,
RIGHTARG="varchar", RIGHTARG="varchar",
@ -107,41 +115,45 @@ CREATE OPERATOR **~ (
CREATE OR REPLACE FUNCTION array_bpchareq(_bpchar, bpchar) CREATE OR REPLACE FUNCTION array_bpchareq(_bpchar, bpchar)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict); LANGUAGE 'C' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION array_all_bpchareq(_bpchar, bpchar) CREATE OR REPLACE FUNCTION array_all_bpchareq(_bpchar, bpchar)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict); LANGUAGE 'C' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION array_bpcharregexeq(_bpchar, bpchar) CREATE OR REPLACE FUNCTION array_bpcharregexeq(_bpchar, bpchar)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict); LANGUAGE 'C' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION array_all_bpcharregexeq(_bpchar, bpchar) CREATE OR REPLACE FUNCTION array_all_bpcharregexeq(_bpchar, bpchar)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict); LANGUAGE 'C' IMMUTABLE STRICT;
DROP OPERATOR *=(_bpchar,bpchar);
CREATE OPERATOR *= ( CREATE OPERATOR *= (
LEFTARG=_bpchar, LEFTARG=_bpchar,
RIGHTARG=bpchar, RIGHTARG=bpchar,
PROCEDURE=array_bpchareq PROCEDURE=array_bpchareq
); );
DROP OPERATOR **=(_bpchar,bpchar);
CREATE OPERATOR **= ( CREATE OPERATOR **= (
LEFTARG=_bpchar, LEFTARG=_bpchar,
RIGHTARG=bpchar, RIGHTARG=bpchar,
PROCEDURE=array_all_bpchareq PROCEDURE=array_all_bpchareq
); );
DROP OPERATOR *~(_bpchar,bpchar);
CREATE OPERATOR *~ ( CREATE OPERATOR *~ (
LEFTARG=_bpchar, LEFTARG=_bpchar,
RIGHTARG=bpchar, RIGHTARG=bpchar,
PROCEDURE=array_bpcharregexeq PROCEDURE=array_bpcharregexeq
); );
DROP OPERATOR **~(_bpchar,bpchar);
CREATE OPERATOR **~ ( CREATE OPERATOR **~ (
LEFTARG=_bpchar, LEFTARG=_bpchar,
RIGHTARG=bpchar, RIGHTARG=bpchar,
@ -154,129 +166,141 @@ CREATE OPERATOR **~ (
CREATE OR REPLACE FUNCTION array_int4eq(_int4, int4) CREATE OR REPLACE FUNCTION array_int4eq(_int4, int4)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict); LANGUAGE 'C' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION array_all_int4eq(_int4, int4) CREATE OR REPLACE FUNCTION array_all_int4eq(_int4, int4)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict); LANGUAGE 'C' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION array_int4ne(_int4, int4) CREATE OR REPLACE FUNCTION array_int4ne(_int4, int4)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict); LANGUAGE 'C' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION array_all_int4ne(_int4, int4) CREATE OR REPLACE FUNCTION array_all_int4ne(_int4, int4)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict); LANGUAGE 'C' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION array_int4gt(_int4, int4) CREATE OR REPLACE FUNCTION array_int4gt(_int4, int4)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict); LANGUAGE 'C' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION array_all_int4gt(_int4, int4) CREATE OR REPLACE FUNCTION array_all_int4gt(_int4, int4)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict); LANGUAGE 'C' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION array_int4ge(_int4, int4) CREATE OR REPLACE FUNCTION array_int4ge(_int4, int4)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict); LANGUAGE 'C' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION array_all_int4ge(_int4, int4) CREATE OR REPLACE FUNCTION array_all_int4ge(_int4, int4)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict); LANGUAGE 'C' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION array_int4lt(_int4, int4) CREATE OR REPLACE FUNCTION array_int4lt(_int4, int4)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict); LANGUAGE 'C' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION array_all_int4lt(_int4, int4) CREATE OR REPLACE FUNCTION array_all_int4lt(_int4, int4)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict); LANGUAGE 'C' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION array_int4le(_int4, int4) CREATE OR REPLACE FUNCTION array_int4le(_int4, int4)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict); LANGUAGE 'C' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION array_all_int4le(_int4, int4) CREATE OR REPLACE FUNCTION array_all_int4le(_int4, int4)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict); LANGUAGE 'C' IMMUTABLE STRICT;
DROP OPERATOR *=(_int4,int4);
CREATE OPERATOR *= ( CREATE OPERATOR *= (
LEFTARG=_int4, LEFTARG=_int4,
RIGHTARG=int4, RIGHTARG=int4,
PROCEDURE=array_int4eq PROCEDURE=array_int4eq
); );
DROP OPERATOR **=(_int4,int4);
CREATE OPERATOR **= ( CREATE OPERATOR **= (
LEFTARG=_int4, LEFTARG=_int4,
RIGHTARG=int4, RIGHTARG=int4,
PROCEDURE=array_all_int4eq PROCEDURE=array_all_int4eq
); );
DROP OPERATOR *<>(_int4,int4);
CREATE OPERATOR *<> ( CREATE OPERATOR *<> (
LEFTARG=_int4, LEFTARG=_int4,
RIGHTARG=int4, RIGHTARG=int4,
PROCEDURE=array_int4ne PROCEDURE=array_int4ne
); );
DROP OPERATOR **<>(_int4,int4);
CREATE OPERATOR **<> ( CREATE OPERATOR **<> (
LEFTARG=_int4, LEFTARG=_int4,
RIGHTARG=int4, RIGHTARG=int4,
PROCEDURE=array_all_int4ne PROCEDURE=array_all_int4ne
); );
DROP OPERATOR *>(_int4,int4);
CREATE OPERATOR *> ( CREATE OPERATOR *> (
LEFTARG=_int4, LEFTARG=_int4,
RIGHTARG=int4, RIGHTARG=int4,
PROCEDURE=array_int4gt PROCEDURE=array_int4gt
); );
DROP OPERATOR **>(_int4,int4);
CREATE OPERATOR **> ( CREATE OPERATOR **> (
LEFTARG=_int4, LEFTARG=_int4,
RIGHTARG=int4, RIGHTARG=int4,
PROCEDURE=array_all_int4gt PROCEDURE=array_all_int4gt
); );
DROP OPERATOR *>=(_int4,int4);
CREATE OPERATOR *>= ( CREATE OPERATOR *>= (
LEFTARG=_int4, LEFTARG=_int4,
RIGHTARG=int4, RIGHTARG=int4,
PROCEDURE=array_int4ge PROCEDURE=array_int4ge
); );
DROP OPERATOR **>=(_int4,int4);
CREATE OPERATOR **>= ( CREATE OPERATOR **>= (
LEFTARG=_int4, LEFTARG=_int4,
RIGHTARG=int4, RIGHTARG=int4,
PROCEDURE=array_all_int4ge PROCEDURE=array_all_int4ge
); );
DROP OPERATOR *<(_int4,int4);
CREATE OPERATOR *< ( CREATE OPERATOR *< (
LEFTARG=_int4, LEFTARG=_int4,
RIGHTARG=int4, RIGHTARG=int4,
PROCEDURE=array_int4lt PROCEDURE=array_int4lt
); );
DROP OPERATOR **<(_int4,int4);
CREATE OPERATOR **< ( CREATE OPERATOR **< (
LEFTARG=_int4, LEFTARG=_int4,
RIGHTARG=int4, RIGHTARG=int4,
PROCEDURE=array_all_int4lt PROCEDURE=array_all_int4lt
); );
DROP OPERATOR *<=(_int4,int4);
CREATE OPERATOR *<= ( CREATE OPERATOR *<= (
LEFTARG=_int4, LEFTARG=_int4,
RIGHTARG=int4, RIGHTARG=int4,
PROCEDURE=array_int4le PROCEDURE=array_int4le
); );
DROP OPERATOR **<=(_int4,int4);
CREATE OPERATOR **<= ( CREATE OPERATOR **<= (
LEFTARG=_int4, LEFTARG=_int4,
RIGHTARG=int4, RIGHTARG=int4,
@ -288,19 +312,21 @@ CREATE OPERATOR **<= (
CREATE OR REPLACE FUNCTION array_oideq(_oid, oid) CREATE OR REPLACE FUNCTION array_oideq(_oid, oid)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict); LANGUAGE 'C' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION array_all_oidne(_oid, oid) CREATE OR REPLACE FUNCTION array_all_oidne(_oid, oid)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict); LANGUAGE 'C' IMMUTABLE STRICT;
DROP OPERATOR *=(_oid,oid);
CREATE OPERATOR *= ( CREATE OPERATOR *= (
LEFTARG=_oid, LEFTARG=_oid,
RIGHTARG=oid, RIGHTARG=oid,
PROCEDURE=array_oideq PROCEDURE=array_oideq
); );
DROP OPERATOR **<>(_oid,oid);
CREATE OPERATOR **<> ( CREATE OPERATOR **<> (
LEFTARG=_oid, LEFTARG=_oid,
RIGHTARG=oid, RIGHTARG=oid,
@ -312,41 +338,45 @@ CREATE OPERATOR **<> (
CREATE OR REPLACE FUNCTION array_ineteq(_inet, inet) CREATE OR REPLACE FUNCTION array_ineteq(_inet, inet)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict); LANGUAGE 'C' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION array_all_ineteq(_inet, inet) CREATE OR REPLACE FUNCTION array_all_ineteq(_inet, inet)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict); LANGUAGE 'C' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION array_inetne(_inet, inet) CREATE OR REPLACE FUNCTION array_inetne(_inet, inet)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict); LANGUAGE 'C' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION array_all_inetne(_inet, inet) CREATE OR REPLACE FUNCTION array_all_inetne(_inet, inet)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict); LANGUAGE 'C' IMMUTABLE STRICT;
DROP OPERATOR *=(_inet,inet);
CREATE OPERATOR *= ( CREATE OPERATOR *= (
LEFTARG=_inet, LEFTARG=_inet,
RIGHTARG=inet, RIGHTARG=inet,
PROCEDURE=array_ineteq PROCEDURE=array_ineteq
); );
DROP OPERATOR **=(_inet,inet);
CREATE OPERATOR **= ( CREATE OPERATOR **= (
LEFTARG=_inet, LEFTARG=_inet,
RIGHTARG=inet, RIGHTARG=inet,
PROCEDURE=array_all_ineteq PROCEDURE=array_all_ineteq
); );
DROP OPERATOR *<>(_inet,inet);
CREATE OPERATOR *<> ( CREATE OPERATOR *<> (
LEFTARG=_inet, LEFTARG=_inet,
RIGHTARG=inet, RIGHTARG=inet,
PROCEDURE=array_inetne PROCEDURE=array_inetne
); );
DROP OPERATOR **<>(_inet,inet);
CREATE OPERATOR **<> ( CREATE OPERATOR **<> (
LEFTARG=_inet, LEFTARG=_inet,
RIGHTARG=inet, RIGHTARG=inet,

View File

@ -8,18 +8,19 @@ SET autocommit TO 'on';
CREATE OR REPLACE FUNCTION int_agg_state (int4, int4) CREATE OR REPLACE FUNCTION int_agg_state (int4, int4)
RETURNS int4 RETURNS int4
AS 'MODULE_PATHNAME','int_agg_state' AS 'MODULE_PATHNAME','int_agg_state'
LANGUAGE 'C'; LANGUAGE 'C' IMMUTABLE STRICT;
-- Internal function for the aggregate -- Internal function for the aggregate
-- Is called at the end of the aggregation, and returns an array. -- Is called at the end of the aggregation, and returns an array.
CREATE OR REPLACE FUNCTION int_agg_final_array (int4) CREATE OR REPLACE FUNCTION int_agg_final_array (int4)
RETURNS int4[] RETURNS int4[]
AS 'MODULE_PATHNAME','int_agg_final_array' AS 'MODULE_PATHNAME','int_agg_final_array'
LANGUAGE 'C'; LANGUAGE 'C' IMMUTABLE STRICT;
-- The aggration funcion. -- The aggration funcion.
-- uses the above functions to create an array of integers from an aggregation. -- uses the above functions to create an array of integers from an aggregation.
CREATE OR REPLACE AGGREGATE int_array_aggregate ( DROP AGGREGATE int_array_aggregate(int4);
CREATE AGGREGATE int_array_aggregate (
BASETYPE = int4, BASETYPE = int4,
SFUNC = int_agg_state, SFUNC = int_agg_state,
STYPE = int4, STYPE = int4,
@ -33,4 +34,4 @@ CREATE OR REPLACE AGGREGATE int_array_aggregate (
CREATE OR REPLACE FUNCTION int_array_enum(int4[]) CREATE OR REPLACE FUNCTION int_array_enum(int4[])
RETURNS setof integer RETURNS setof integer
AS 'MODULE_PATHNAME','int_enum' AS 'MODULE_PATHNAME','int_enum'
LANGUAGE 'C'; LANGUAGE 'C' IMMUTABLE STRICT;