Commit b663f344 authored by Tom Lane's avatar Tom Lane

Add a bunch of pseudo-types to replace the behavior formerly associated

with OPAQUE, as per recent pghackers discussion.  I still want to do some
more work on the 'cstring' pseudo-type, but I'm going to commit the bulk
of the changes now before the tree starts shifting under me ...
parent 606c9b9d
...@@ -4,13 +4,13 @@ begin transaction; ...@@ -4,13 +4,13 @@ begin transaction;
SET search_path = public; SET search_path = public;
-- create type of int4 key -- create type of int4 key
CREATE FUNCTION int4key_in(opaque) CREATE FUNCTION int4key_in(cstring)
RETURNS opaque RETURNS int4key
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'c' with (isstrict);
CREATE FUNCTION int4key_out(opaque) CREATE FUNCTION int4key_out(int4key)
RETURNS opaque RETURNS cstring
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'c' with (isstrict);
...@@ -29,19 +29,19 @@ output = int4key_out ...@@ -29,19 +29,19 @@ output = int4key_out
-- --
-- --
-- define the GiST support methods -- define the GiST support methods
create function gint4_consistent(opaque,int4,int2) returns bool as 'MODULE_PATHNAME' language 'C'; create function gint4_consistent(internal,int4,int2) returns bool as 'MODULE_PATHNAME' language 'C';
create function gint4_compress(opaque) returns opaque as 'MODULE_PATHNAME' language 'C'; create function gint4_compress(internal) returns internal as 'MODULE_PATHNAME' language 'C';
create function btree_decompress(opaque) returns opaque as 'MODULE_PATHNAME' language 'C'; create function btree_decompress(internal) returns internal as 'MODULE_PATHNAME' language 'C';
create function gint4_penalty(opaque,opaque,opaque) returns opaque as 'MODULE_PATHNAME' language 'C' with(isstrict); create function gint4_penalty(internal,internal,internal) returns internal as 'MODULE_PATHNAME' language 'C' with(isstrict);
create function gint4_picksplit(opaque, opaque) returns opaque as 'MODULE_PATHNAME' language 'C'; create function gint4_picksplit(internal, internal) returns internal as 'MODULE_PATHNAME' language 'C';
create function gint4_union(bytea, opaque) returns int4 as 'MODULE_PATHNAME' language 'C'; create function gint4_union(bytea, internal) returns int4 as 'MODULE_PATHNAME' language 'C';
create function gint4_same(opaque, opaque, opaque) returns opaque as 'MODULE_PATHNAME' language 'C'; create function gint4_same(internal, internal, internal) returns internal as 'MODULE_PATHNAME' language 'C';
-- Create the operator class -- Create the operator class
CREATE OPERATOR CLASS gist_int4_ops CREATE OPERATOR CLASS gist_int4_ops
...@@ -51,13 +51,13 @@ CREATE OPERATOR CLASS gist_int4_ops ...@@ -51,13 +51,13 @@ CREATE OPERATOR CLASS gist_int4_ops
OPERATOR 3 = , OPERATOR 3 = ,
OPERATOR 4 >= , OPERATOR 4 >= ,
OPERATOR 5 > , OPERATOR 5 > ,
FUNCTION 1 gint4_consistent (opaque, int4, int2), FUNCTION 1 gint4_consistent (internal, int4, int2),
FUNCTION 2 gint4_union (bytea, opaque), FUNCTION 2 gint4_union (bytea, internal),
FUNCTION 3 gint4_compress (opaque), FUNCTION 3 gint4_compress (internal),
FUNCTION 4 btree_decompress (opaque), FUNCTION 4 btree_decompress (internal),
FUNCTION 5 gint4_penalty (opaque, opaque, opaque), FUNCTION 5 gint4_penalty (internal, internal, internal),
FUNCTION 6 gint4_picksplit (opaque, opaque), FUNCTION 6 gint4_picksplit (internal, internal),
FUNCTION 7 gint4_same (opaque, opaque, opaque), FUNCTION 7 gint4_same (internal, internal, internal),
STORAGE int4key; STORAGE int4key;
...@@ -70,13 +70,13 @@ CREATE OPERATOR CLASS gist_int4_ops ...@@ -70,13 +70,13 @@ CREATE OPERATOR CLASS gist_int4_ops
-- --
-- create type of timestamp key -- create type of timestamp key
CREATE FUNCTION tskey_in(opaque) CREATE FUNCTION tskey_in(cstring)
RETURNS opaque RETURNS tskey
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'c' with (isstrict);
CREATE FUNCTION tskey_out(opaque) CREATE FUNCTION tskey_out(tskey)
RETURNS opaque RETURNS cstring
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'c' with (isstrict);
...@@ -86,17 +86,17 @@ input = tskey_in, ...@@ -86,17 +86,17 @@ input = tskey_in,
output = tskey_out output = tskey_out
); );
create function gts_consistent(opaque,timestamp,int2) returns bool as 'MODULE_PATHNAME' language 'C'; create function gts_consistent(internal,timestamp,int2) returns bool as 'MODULE_PATHNAME' language 'C';
create function gts_compress(opaque) returns opaque as 'MODULE_PATHNAME' language 'C'; create function gts_compress(internal) returns internal as 'MODULE_PATHNAME' language 'C';
create function gts_penalty(opaque,opaque,opaque) returns opaque as 'MODULE_PATHNAME' language 'C' with(isstrict); create function gts_penalty(internal,internal,internal) returns internal as 'MODULE_PATHNAME' language 'C' with(isstrict);
create function gts_picksplit(opaque, opaque) returns opaque as 'MODULE_PATHNAME' language 'C'; create function gts_picksplit(internal, internal) returns internal as 'MODULE_PATHNAME' language 'C';
create function gts_union(bytea, opaque) returns int4 as 'MODULE_PATHNAME' language 'C'; create function gts_union(bytea, internal) returns int4 as 'MODULE_PATHNAME' language 'C';
create function gts_same(opaque, opaque, opaque) returns opaque as 'MODULE_PATHNAME' language 'C'; create function gts_same(internal, internal, internal) returns internal as 'MODULE_PATHNAME' language 'C';
-- Create the operator class -- Create the operator class
CREATE OPERATOR CLASS gist_timestamp_ops CREATE OPERATOR CLASS gist_timestamp_ops
...@@ -106,13 +106,13 @@ CREATE OPERATOR CLASS gist_timestamp_ops ...@@ -106,13 +106,13 @@ CREATE OPERATOR CLASS gist_timestamp_ops
OPERATOR 3 = , OPERATOR 3 = ,
OPERATOR 4 >= , OPERATOR 4 >= ,
OPERATOR 5 > , OPERATOR 5 > ,
FUNCTION 1 gts_consistent (opaque, timestamp, int2), FUNCTION 1 gts_consistent (internal, timestamp, int2),
FUNCTION 2 gts_union (bytea, opaque), FUNCTION 2 gts_union (bytea, internal),
FUNCTION 3 gts_compress (opaque), FUNCTION 3 gts_compress (internal),
FUNCTION 4 btree_decompress (opaque), FUNCTION 4 btree_decompress (internal),
FUNCTION 5 gts_penalty (opaque, opaque, opaque), FUNCTION 5 gts_penalty (internal, internal, internal),
FUNCTION 6 gts_picksplit (opaque, opaque), FUNCTION 6 gts_picksplit (internal, internal),
FUNCTION 7 gts_same (opaque, opaque, opaque), FUNCTION 7 gts_same (internal, internal, internal),
STORAGE tskey; STORAGE tskey;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
-- darcy@druid.net -- darcy@druid.net
-- http://www.druid.net/darcy/ -- http://www.druid.net/darcy/
-- --
-- $Header: /cvsroot/pgsql/contrib/chkpass/chkpass.sql.in,v 1.1 2001/08/23 16:50:33 tgl Exp $ -- $Header: /cvsroot/pgsql/contrib/chkpass/chkpass.sql.in,v 1.2 2002/08/22 00:01:38 tgl Exp $
-- --
-- best viewed with tabs set to 4 -- best viewed with tabs set to 4
-- --
...@@ -13,13 +13,13 @@ ...@@ -13,13 +13,13 @@
-- Input and output functions and the type itself: -- Input and output functions and the type itself:
-- --
create function chkpass_in(opaque) create function chkpass_in(cstring)
returns opaque returns chkpass
as 'MODULE_PATHNAME' as 'MODULE_PATHNAME'
language 'c'; language 'c';
create function chkpass_out(opaque) create function chkpass_out(chkpass)
returns opaque returns cstring
as 'MODULE_PATHNAME' as 'MODULE_PATHNAME'
language 'c'; language 'c';
......
...@@ -99,14 +99,6 @@ cube_in(char *str) ...@@ -99,14 +99,6 @@ cube_in(char *str)
return ((NDBOX *) result); return ((NDBOX *) result);
} }
/*
* You might have noticed a slight inconsistency between the following
* declaration and the SQL definition:
* CREATE FUNCTION cube_out(opaque) RETURNS opaque ...
* The reason is that the argument pass into cube_out is really just a
* pointer. POSTGRES thinks all output functions are:
* char *out_func(char *);
*/
char * char *
cube_out(NDBOX *cube) cube_out(NDBOX *cube)
{ {
......
...@@ -5,13 +5,13 @@ BEGIN TRANSACTION; ...@@ -5,13 +5,13 @@ BEGIN TRANSACTION;
-- Adjust this setting to control where the objects get created. -- Adjust this setting to control where the objects get created.
SET search_path = public; SET search_path = public;
CREATE FUNCTION cube_in(opaque) CREATE FUNCTION cube_in(cstring)
RETURNS opaque RETURNS cube
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' WITH (isStrict); LANGUAGE 'c' WITH (isStrict);
CREATE FUNCTION cube_out(opaque) CREATE FUNCTION cube_out(cube)
RETURNS opaque RETURNS cstring
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' WITH (isStrict); LANGUAGE 'c' WITH (isStrict);
...@@ -192,25 +192,25 @@ CREATE OPERATOR ~ ( ...@@ -192,25 +192,25 @@ CREATE OPERATOR ~ (
-- define the GiST support methods -- define the GiST support methods
CREATE FUNCTION g_cube_consistent(opaque,cube,int4) RETURNS bool CREATE FUNCTION g_cube_consistent(internal,cube,int4) RETURNS bool
AS 'MODULE_PATHNAME' LANGUAGE 'c'; AS 'MODULE_PATHNAME' LANGUAGE 'c';
CREATE FUNCTION g_cube_compress(opaque) RETURNS opaque CREATE FUNCTION g_cube_compress(internal) RETURNS internal
AS 'MODULE_PATHNAME' LANGUAGE 'c'; AS 'MODULE_PATHNAME' LANGUAGE 'c';
CREATE FUNCTION g_cube_decompress(opaque) RETURNS opaque CREATE FUNCTION g_cube_decompress(internal) RETURNS internal
AS 'MODULE_PATHNAME' LANGUAGE 'c'; AS 'MODULE_PATHNAME' LANGUAGE 'c';
CREATE FUNCTION g_cube_penalty(opaque,opaque,opaque) RETURNS opaque CREATE FUNCTION g_cube_penalty(internal,internal,internal) RETURNS internal
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
CREATE FUNCTION g_cube_picksplit(opaque, opaque) RETURNS opaque CREATE FUNCTION g_cube_picksplit(internal, internal) RETURNS internal
AS 'MODULE_PATHNAME' LANGUAGE 'c'; AS 'MODULE_PATHNAME' LANGUAGE 'c';
CREATE FUNCTION g_cube_union(bytea, opaque) RETURNS cube CREATE FUNCTION g_cube_union(bytea, internal) RETURNS cube
AS 'MODULE_PATHNAME' LANGUAGE 'c'; AS 'MODULE_PATHNAME' LANGUAGE 'c';
CREATE FUNCTION g_cube_same(cube, cube, opaque) RETURNS opaque CREATE FUNCTION g_cube_same(cube, cube, internal) RETURNS internal
AS 'MODULE_PATHNAME' LANGUAGE 'c'; AS 'MODULE_PATHNAME' LANGUAGE 'c';
...@@ -226,13 +226,13 @@ CREATE OPERATOR CLASS gist_cube_ops ...@@ -226,13 +226,13 @@ CREATE OPERATOR CLASS gist_cube_ops
OPERATOR 6 = , OPERATOR 6 = ,
OPERATOR 7 @ , OPERATOR 7 @ ,
OPERATOR 8 ~ , OPERATOR 8 ~ ,
FUNCTION 1 g_cube_consistent (opaque, cube, int4), FUNCTION 1 g_cube_consistent (internal, cube, int4),
FUNCTION 2 g_cube_union (bytea, opaque), FUNCTION 2 g_cube_union (bytea, internal),
FUNCTION 3 g_cube_compress (opaque), FUNCTION 3 g_cube_compress (internal),
FUNCTION 4 g_cube_decompress (opaque), FUNCTION 4 g_cube_decompress (internal),
FUNCTION 5 g_cube_penalty (opaque, opaque, opaque), FUNCTION 5 g_cube_penalty (internal, internal, internal),
FUNCTION 6 g_cube_picksplit (opaque, opaque), FUNCTION 6 g_cube_picksplit (internal, internal),
FUNCTION 7 g_cube_same (cube, cube, opaque); FUNCTION 7 g_cube_same (cube, cube, internal);
END TRANSACTION; END TRANSACTION;
CREATE FUNCTION "recordchange" () RETURNS opaque AS CREATE FUNCTION "recordchange" () RETURNS trigger AS
'/usr/local/pgsql/lib/pending.so', 'recordchange' LANGUAGE 'C'; '/usr/local/pgsql/lib/pending.so', 'recordchange' LANGUAGE 'C';
CREATE TABLE "MirrorHost" ( CREATE TABLE "MirrorHost" (
......
...@@ -58,7 +58,7 @@ sub-string will fit. ...@@ -58,7 +58,7 @@ sub-string will fit.
The create the function that contains the trigger:: The create the function that contains the trigger::
create function fti() returns opaque as create function fti() returns trigger as
'/path/to/fti.so' language 'C'; '/path/to/fti.so' language 'C';
And finally define the trigger on the 'cds' table: And finally define the trigger on the 'cds' table:
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
* Example: * Example:
* *
* -- Create the SQL function based on the compiled shared object * -- Create the SQL function based on the compiled shared object
* create function fti() returns opaque as * create function fti() returns trigger as
* '/usr/local/pgsql/lib/contrib/fti.so' language 'C'; * '/usr/local/pgsql/lib/contrib/fti.so' language 'C';
* *
* -- Create the FTI table * -- Create the FTI table
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
# #
# create index fti_idx on my_fti_table (string,id); # create index fti_idx on my_fti_table (string,id);
# #
# create function fti() returns opaque as # create function fti() returns trigger as
# '/path/to/fti/file/fti.so' # '/path/to/fti/file/fti.so'
# language 'C'; # language 'C';
# #
......
create function fti() returns opaque as create function fti() returns trigger as
'MODULE_PATHNAME' 'MODULE_PATHNAME'
language 'C'; language 'C';
\ No newline at end of file
...@@ -7,13 +7,13 @@ BEGIN TRANSACTION; ...@@ -7,13 +7,13 @@ BEGIN TRANSACTION;
SET search_path = public; SET search_path = public;
-- Query type -- Query type
CREATE FUNCTION bqarr_in(opaque) CREATE FUNCTION bqarr_in(cstring)
RETURNS opaque RETURNS query_int
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'c' with (isstrict);
CREATE FUNCTION bqarr_out(opaque) CREATE FUNCTION bqarr_out(query_int)
RETURNS opaque RETURNS cstring
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'c' with (isstrict);
...@@ -200,25 +200,25 @@ CREATE OPERATOR & ( ...@@ -200,25 +200,25 @@ CREATE OPERATOR & (
-------------- --------------
-- define the GiST support methods -- define the GiST support methods
CREATE FUNCTION g_int_consistent(opaque,_int4,int4) RETURNS bool CREATE FUNCTION g_int_consistent(internal,_int4,int4) RETURNS bool
AS 'MODULE_PATHNAME' LANGUAGE 'c'; AS 'MODULE_PATHNAME' LANGUAGE 'c';
CREATE FUNCTION g_int_compress(opaque) RETURNS opaque CREATE FUNCTION g_int_compress(internal) RETURNS internal
AS 'MODULE_PATHNAME' LANGUAGE 'c'; AS 'MODULE_PATHNAME' LANGUAGE 'c';
CREATE FUNCTION g_int_decompress(opaque) RETURNS opaque CREATE FUNCTION g_int_decompress(internal) RETURNS internal
AS 'MODULE_PATHNAME' LANGUAGE 'c'; AS 'MODULE_PATHNAME' LANGUAGE 'c';
CREATE FUNCTION g_int_penalty(opaque,opaque,opaque) RETURNS opaque CREATE FUNCTION g_int_penalty(internal,internal,internal) RETURNS internal
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
CREATE FUNCTION g_int_picksplit(opaque, opaque) RETURNS opaque CREATE FUNCTION g_int_picksplit(internal, internal) RETURNS internal
AS 'MODULE_PATHNAME' LANGUAGE 'c'; AS 'MODULE_PATHNAME' LANGUAGE 'c';
CREATE FUNCTION g_int_union(bytea, opaque) RETURNS _int4 CREATE FUNCTION g_int_union(bytea, internal) RETURNS _int4
AS 'MODULE_PATHNAME' LANGUAGE 'c'; AS 'MODULE_PATHNAME' LANGUAGE 'c';
CREATE FUNCTION g_int_same(_int4, _int4, opaque) RETURNS opaque CREATE FUNCTION g_int_same(_int4, _int4, internal) RETURNS internal
AS 'MODULE_PATHNAME' LANGUAGE 'c'; AS 'MODULE_PATHNAME' LANGUAGE 'c';
...@@ -231,38 +231,38 @@ CREATE OPERATOR CLASS gist__int_ops ...@@ -231,38 +231,38 @@ CREATE OPERATOR CLASS gist__int_ops
OPERATOR 7 @, OPERATOR 7 @,
OPERATOR 8 ~, OPERATOR 8 ~,
OPERATOR 20 @@ (_int4, query_int), OPERATOR 20 @@ (_int4, query_int),
FUNCTION 1 g_int_consistent (opaque, _int4, int4), FUNCTION 1 g_int_consistent (internal, _int4, int4),
FUNCTION 2 g_int_union (bytea, opaque), FUNCTION 2 g_int_union (bytea, internal),
FUNCTION 3 g_int_compress (opaque), FUNCTION 3 g_int_compress (internal),
FUNCTION 4 g_int_decompress (opaque), FUNCTION 4 g_int_decompress (internal),
FUNCTION 5 g_int_penalty (opaque, opaque, opaque), FUNCTION 5 g_int_penalty (internal, internal, internal),
FUNCTION 6 g_int_picksplit (opaque, opaque), FUNCTION 6 g_int_picksplit (internal, internal),
FUNCTION 7 g_int_same (_int4, _int4, opaque); FUNCTION 7 g_int_same (_int4, _int4, internal);
--------------------------------------------- ---------------------------------------------
-- intbig -- intbig
--------------------------------------------- ---------------------------------------------
-- define the GiST support methods -- define the GiST support methods
CREATE FUNCTION g_intbig_consistent(opaque,_int4,int4) RETURNS bool CREATE FUNCTION g_intbig_consistent(internal,_int4,int4) RETURNS bool
AS 'MODULE_PATHNAME' LANGUAGE 'c'; AS 'MODULE_PATHNAME' LANGUAGE 'c';
CREATE FUNCTION g_intbig_compress(opaque) RETURNS opaque CREATE FUNCTION g_intbig_compress(internal) RETURNS internal
AS 'MODULE_PATHNAME' LANGUAGE 'c'; AS 'MODULE_PATHNAME' LANGUAGE 'c';
CREATE FUNCTION g_intbig_decompress(opaque) RETURNS opaque CREATE FUNCTION g_intbig_decompress(internal) RETURNS internal
AS 'MODULE_PATHNAME' LANGUAGE 'c'; AS 'MODULE_PATHNAME' LANGUAGE 'c';
CREATE FUNCTION g_intbig_penalty(opaque,opaque,opaque) RETURNS opaque CREATE FUNCTION g_intbig_penalty(internal,internal,internal) RETURNS internal
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
CREATE FUNCTION g_intbig_picksplit(opaque, opaque) RETURNS opaque CREATE FUNCTION g_intbig_picksplit(internal, internal) RETURNS internal
AS 'MODULE_PATHNAME' LANGUAGE 'c'; AS 'MODULE_PATHNAME' LANGUAGE 'c';
CREATE FUNCTION g_intbig_union(bytea, opaque) RETURNS _int4 CREATE FUNCTION g_intbig_union(bytea, internal) RETURNS _int4
AS 'MODULE_PATHNAME' LANGUAGE 'c'; AS 'MODULE_PATHNAME' LANGUAGE 'c';
CREATE FUNCTION g_intbig_same(_int4, _int4, opaque) RETURNS opaque CREATE FUNCTION g_intbig_same(_int4, _int4, internal) RETURNS internal
AS 'MODULE_PATHNAME' LANGUAGE 'c'; AS 'MODULE_PATHNAME' LANGUAGE 'c';
-- register the opclass for indexing (not as default) -- register the opclass for indexing (not as default)
...@@ -274,12 +274,12 @@ CREATE OPERATOR CLASS gist__intbig_ops ...@@ -274,12 +274,12 @@ CREATE OPERATOR CLASS gist__intbig_ops
OPERATOR 7 @ RECHECK, OPERATOR 7 @ RECHECK,
OPERATOR 8 ~ RECHECK, OPERATOR 8 ~ RECHECK,
OPERATOR 20 @@ (_int4, query_int) RECHECK, OPERATOR 20 @@ (_int4, query_int) RECHECK,
FUNCTION 1 g_intbig_consistent (opaque, _int4, int4), FUNCTION 1 g_intbig_consistent (internal, _int4, int4),
FUNCTION 2 g_intbig_union (bytea, opaque), FUNCTION 2 g_intbig_union (bytea, internal),
FUNCTION 3 g_intbig_compress (opaque), FUNCTION 3 g_intbig_compress (internal),
FUNCTION 4 g_intbig_decompress (opaque), FUNCTION 4 g_intbig_decompress (internal),
FUNCTION 5 g_intbig_penalty (opaque, opaque, opaque), FUNCTION 5 g_intbig_penalty (internal, internal, internal),
FUNCTION 6 g_intbig_picksplit (opaque, opaque), FUNCTION 6 g_intbig_picksplit (internal, internal),
FUNCTION 7 g_intbig_same (_int4, _int4, opaque); FUNCTION 7 g_intbig_same (_int4, _int4, internal);
END TRANSACTION; END TRANSACTION;
-- --
-- PostgreSQL code for ISSNs. -- PostgreSQL code for ISSNs.
-- --
-- $Id: isbn_issn.sql.in,v 1.5 2002/07/30 17:34:37 tgl Exp $ -- $Id: isbn_issn.sql.in,v 1.6 2002/08/22 00:01:39 tgl Exp $
-- --
-- Adjust this setting to control where the objects get created. -- Adjust this setting to control where the objects get created.
...@@ -12,13 +12,13 @@ SET search_path = public; ...@@ -12,13 +12,13 @@ SET search_path = public;
-- Input and output functions and the type itself: -- Input and output functions and the type itself:
-- --
create function issn_in(opaque) create function issn_in(cstring)
returns opaque returns issn
as 'MODULE_PATHNAME' as 'MODULE_PATHNAME'
language 'c'; language 'c';
create function issn_out(opaque) create function issn_out(issn)
returns opaque returns cstring
as 'MODULE_PATHNAME' as 'MODULE_PATHNAME'
language 'c'; language 'c';
...@@ -123,19 +123,19 @@ create operator <> ( ...@@ -123,19 +123,19 @@ create operator <> (
-- --
-- PostgreSQL code for ISBNs. -- PostgreSQL code for ISBNs.
-- --
-- $Id: isbn_issn.sql.in,v 1.5 2002/07/30 17:34:37 tgl Exp $ -- $Id: isbn_issn.sql.in,v 1.6 2002/08/22 00:01:39 tgl Exp $
-- --
-- --
-- Input and output functions and the type itself: -- Input and output functions and the type itself:
-- --
create function isbn_in(opaque) create function isbn_in(cstring)
returns opaque returns isbn
as 'MODULE_PATHNAME' as 'MODULE_PATHNAME'
language 'c'; language 'c';
create function isbn_out(opaque) create function isbn_out(isbn)
returns opaque returns cstring
as 'MODULE_PATHNAME' as 'MODULE_PATHNAME'
language 'c'; language 'c';
......
-- --
-- PostgreSQL code for LargeObjects -- PostgreSQL code for LargeObjects
-- --
-- $Id: lo.sql.in,v 1.6 2000/11/21 21:51:58 tgl Exp $ -- $Id: lo.sql.in,v 1.7 2002/08/22 00:01:39 tgl Exp $
-- --
-- --
-- Create the data type -- Create the data type
-- --
-- used by the lo type, it takes an oid and returns an lo object -- used by the lo type, it takes an oid and returns an lo object
create function lo_in(opaque) create function lo_in(cstring)
returns opaque returns lo
as 'MODULE_PATHNAME' as 'MODULE_PATHNAME'
language 'c'; language 'c';
-- used by the lo type, it returns the oid of the object -- used by the lo type, it returns the oid of the object
create function lo_out(opaque) create function lo_out(lo)
returns opaque returns cstring
as 'MODULE_PATHNAME' as 'MODULE_PATHNAME'
language 'c'; language 'c';
...@@ -51,6 +51,6 @@ create function lo(oid) ...@@ -51,6 +51,6 @@ create function lo(oid)
-- This is used in triggers -- This is used in triggers
create function lo_manage() create function lo_manage()
returns opaque returns trigger
as 'MODULE_PATHNAME' as 'MODULE_PATHNAME'
language 'c'; language 'c';
...@@ -6,16 +6,10 @@ ...@@ -6,16 +6,10 @@
-- remove our test table -- remove our test table
drop table a; drop table a;
-- now drop any sql based functions associated with the lo type -- now drop the type and associated C functions
drop function oid(lo); drop type lo CASCADE;
-- now drop the type -- the trigger function has no dependency on the type, so drop separately
drop type lo;
-- as the type is gone, remove the C based functions
drop function lo_in(opaque);
drop function lo_out(opaque);
drop function lo(oid);
drop function lo_manage(); drop function lo_manage();
-- the lo stuff is now removed from the system -- the lo stuff is now removed from the system
...@@ -3,13 +3,13 @@ BEGIN; ...@@ -3,13 +3,13 @@ BEGIN;
-- Adjust this setting to control where the objects get created. -- Adjust this setting to control where the objects get created.
SET search_path = public; SET search_path = public;
CREATE FUNCTION ltree_in(opaque) CREATE FUNCTION ltree_in(cstring)
RETURNS opaque RETURNS ltree
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'c' with (isstrict);
CREATE FUNCTION ltree_out(opaque) CREATE FUNCTION ltree_out(ltree)
RETURNS opaque RETURNS cstring
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'c' with (isstrict);
...@@ -232,13 +232,13 @@ CREATE OPERATOR CLASS ltree_ops ...@@ -232,13 +232,13 @@ CREATE OPERATOR CLASS ltree_ops
--lquery type --lquery type
CREATE FUNCTION lquery_in(opaque) CREATE FUNCTION lquery_in(cstring)
RETURNS opaque RETURNS lquery
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'c' with (isstrict);
CREATE FUNCTION lquery_out(opaque) CREATE FUNCTION lquery_out(lquery)
RETURNS opaque RETURNS cstring
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'c' with (isstrict);
...@@ -284,13 +284,13 @@ CREATE OPERATOR ^~ ( ...@@ -284,13 +284,13 @@ CREATE OPERATOR ^~ (
RESTRICT = contsel, JOIN = contjoinsel RESTRICT = contsel, JOIN = contjoinsel
); );
CREATE FUNCTION ltxtq_in(opaque) CREATE FUNCTION ltxtq_in(cstring)
RETURNS opaque RETURNS ltxtquery
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'c' with (isstrict);
CREATE FUNCTION ltxtq_out(opaque) CREATE FUNCTION ltxtq_out(ltxtquery)
RETURNS opaque RETURNS cstring
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'c' with (isstrict);
...@@ -339,13 +339,13 @@ CREATE OPERATOR ^@ ( ...@@ -339,13 +339,13 @@ CREATE OPERATOR ^@ (
); );
--GiST support for ltree --GiST support for ltree
CREATE FUNCTION ltree_gist_in(opaque) CREATE FUNCTION ltree_gist_in(cstring)
RETURNS opaque RETURNS ltree_gist
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'c' with (isstrict);
CREATE FUNCTION ltree_gist_out(opaque) CREATE FUNCTION ltree_gist_out(ltree_gist)
RETURNS opaque RETURNS cstring
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'c' with (isstrict);
...@@ -357,13 +357,13 @@ CREATE TYPE ltree_gist ( ...@@ -357,13 +357,13 @@ CREATE TYPE ltree_gist (
); );
create function ltree_consistent(opaque,opaque,int2) returns bool as 'MODULE_PATHNAME' language 'C'; create function ltree_consistent(internal,internal,int2) returns bool as 'MODULE_PATHNAME' language 'C';
create function ltree_compress(opaque) returns opaque as 'MODULE_PATHNAME' language 'C'; create function ltree_compress(internal) returns internal as 'MODULE_PATHNAME' language 'C';
create function ltree_decompress(opaque) returns opaque as 'MODULE_PATHNAME' language 'C'; create function ltree_decompress(internal) returns internal as 'MODULE_PATHNAME' language 'C';
create function ltree_penalty(opaque,opaque,opaque) returns opaque as 'MODULE_PATHNAME' language 'C' with(isstrict); create function ltree_penalty(internal,internal,internal) returns internal as 'MODULE_PATHNAME' language 'C' with(isstrict);
create function ltree_picksplit(opaque, opaque) returns opaque as 'MODULE_PATHNAME' language 'C'; create function ltree_picksplit(internal, internal) returns internal as 'MODULE_PATHNAME' language 'C';
create function ltree_union(bytea, opaque) returns int4 as 'MODULE_PATHNAME' language 'C'; create function ltree_union(bytea, internal) returns int4 as 'MODULE_PATHNAME' language 'C';
create function ltree_same(opaque, opaque, opaque) returns opaque as 'MODULE_PATHNAME' language 'C'; create function ltree_same(internal, internal, internal) returns internal as 'MODULE_PATHNAME' language 'C';
CREATE OPERATOR CLASS gist_ltree_ops CREATE OPERATOR CLASS gist_ltree_ops
DEFAULT FOR TYPE ltree USING gist AS DEFAULT FOR TYPE ltree USING gist AS
...@@ -378,13 +378,13 @@ CREATE OPERATOR CLASS gist_ltree_ops ...@@ -378,13 +378,13 @@ CREATE OPERATOR CLASS gist_ltree_ops
OPERATOR 13 ~ (lquery, ltree) , OPERATOR 13 ~ (lquery, ltree) ,
OPERATOR 14 @ (ltree, ltxtquery) , OPERATOR 14 @ (ltree, ltxtquery) ,
OPERATOR 15 @ (ltxtquery, ltree) , OPERATOR 15 @ (ltxtquery, ltree) ,
FUNCTION 1 ltree_consistent (opaque, opaque, int2), FUNCTION 1 ltree_consistent (internal, internal, int2),
FUNCTION 2 ltree_union (bytea, opaque), FUNCTION 2 ltree_union (bytea, internal),
FUNCTION 3 ltree_compress (opaque), FUNCTION 3 ltree_compress (internal),
FUNCTION 4 ltree_decompress (opaque), FUNCTION 4 ltree_decompress (internal),
FUNCTION 5 ltree_penalty (opaque, opaque, opaque), FUNCTION 5 ltree_penalty (internal, internal, internal),
FUNCTION 6 ltree_picksplit (opaque, opaque), FUNCTION 6 ltree_picksplit (internal, internal),
FUNCTION 7 ltree_same (opaque, opaque, opaque), FUNCTION 7 ltree_same (internal, internal, internal),
STORAGE ltree_gist; STORAGE ltree_gist;
...@@ -566,12 +566,12 @@ CREATE OPERATOR ?@ ( ...@@ -566,12 +566,12 @@ CREATE OPERATOR ?@ (
); );
--GiST support for ltree[] --GiST support for ltree[]
create function _ltree_consistent(opaque,opaque,int2) returns bool as 'MODULE_PATHNAME' language 'C'; create function _ltree_consistent(internal,internal,int2) returns bool as 'MODULE_PATHNAME' language 'C';
create function _ltree_compress(opaque) returns opaque as 'MODULE_PATHNAME' language 'C'; create function _ltree_compress(internal) returns internal as 'MODULE_PATHNAME' language 'C';
create function _ltree_penalty(opaque,opaque,opaque) returns opaque as 'MODULE_PATHNAME' language 'C' with(isstrict); create function _ltree_penalty(internal,internal,internal) returns internal as 'MODULE_PATHNAME' language 'C' with(isstrict);
create function _ltree_picksplit(opaque, opaque) returns opaque as 'MODULE_PATHNAME' language 'C'; create function _ltree_picksplit(internal, internal) returns internal as 'MODULE_PATHNAME' language 'C';
create function _ltree_union(bytea, opaque) returns int4 as 'MODULE_PATHNAME' language 'C'; create function _ltree_union(bytea, internal) returns int4 as 'MODULE_PATHNAME' language 'C';
create function _ltree_same(opaque, opaque, opaque) returns opaque as 'MODULE_PATHNAME' language 'C'; create function _ltree_same(internal, internal, internal) returns internal as 'MODULE_PATHNAME' language 'C';
CREATE OPERATOR CLASS gist__ltree_ops CREATE OPERATOR CLASS gist__ltree_ops
DEFAULT FOR TYPE _ltree USING gist AS DEFAULT FOR TYPE _ltree USING gist AS
...@@ -581,13 +581,13 @@ CREATE OPERATOR CLASS gist__ltree_ops ...@@ -581,13 +581,13 @@ CREATE OPERATOR CLASS gist__ltree_ops
OPERATOR 13 ~ (lquery, _ltree) RECHECK , OPERATOR 13 ~ (lquery, _ltree) RECHECK ,
OPERATOR 14 @ (_ltree, ltxtquery) RECHECK , OPERATOR 14 @ (_ltree, ltxtquery) RECHECK ,
OPERATOR 15 @ (ltxtquery, _ltree) RECHECK , OPERATOR 15 @ (ltxtquery, _ltree) RECHECK ,
FUNCTION 1 _ltree_consistent (opaque, opaque, int2), FUNCTION 1 _ltree_consistent (internal, internal, int2),
FUNCTION 2 _ltree_union (bytea, opaque), FUNCTION 2 _ltree_union (bytea, internal),
FUNCTION 3 _ltree_compress (opaque), FUNCTION 3 _ltree_compress (internal),
FUNCTION 4 ltree_decompress (opaque), FUNCTION 4 ltree_decompress (internal),
FUNCTION 5 _ltree_penalty (opaque, opaque, opaque), FUNCTION 5 _ltree_penalty (internal, internal, internal),
FUNCTION 6 _ltree_picksplit (opaque, opaque), FUNCTION 6 _ltree_picksplit (internal, internal),
FUNCTION 7 _ltree_same (opaque, opaque, opaque), FUNCTION 7 _ltree_same (internal, internal, internal),
STORAGE ltree_gist; STORAGE ltree_gist;
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
# SUCH DAMAGE. # SUCH DAMAGE.
# #
# $My2pg: my2pg.pl,v 1.24 2001/12/06 19:32:20 fonin Exp $ # $My2pg: my2pg.pl,v 1.24 2001/12/06 19:32:20 fonin Exp $
# $Id: my2pg.pl,v 1.8 2002/04/24 01:42:29 momjian Exp $ # $Id: my2pg.pl,v 1.9 2002/08/22 00:01:39 tgl Exp $
# TODO: # TODO:
# + Handle SETs # + Handle SETs
...@@ -47,6 +47,12 @@ ...@@ -47,6 +47,12 @@
# #
# $Log: my2pg.pl,v $ # $Log: my2pg.pl,v $
# Revision 1.9 2002/08/22 00:01:39 tgl
# Add a bunch of pseudo-types to replace the behavior formerly associated
# with OPAQUE, as per recent pghackers discussion. I still want to do some
# more work on the 'cstring' pseudo-type, but I'm going to commit the bulk
# of the changes now before the tree starts shifting under me ...
#
# Revision 1.8 2002/04/24 01:42:29 momjian # Revision 1.8 2002/04/24 01:42:29 momjian
# Update to my2pg 1.24. # Update to my2pg 1.24.
# #
...@@ -193,7 +199,7 @@ $libtypename.='/libtypes.so'; ...@@ -193,7 +199,7 @@ $libtypename.='/libtypes.so';
# push header to libtypes.c # push header to libtypes.c
open(LIBTYPES,">$libtypesource"); open(LIBTYPES,">$libtypesource");
print LIBTYPES "/******************************************************"; print LIBTYPES "/******************************************************";
print LIBTYPES "\n * My2Pg \$Revision: 1.8 $ \translated dump"; print LIBTYPES "\n * My2Pg \$Revision: 1.9 $ \translated dump";
print LIBTYPES "\n * User types definitions"; print LIBTYPES "\n * User types definitions";
print LIBTYPES "\n ******************************************************/"; print LIBTYPES "\n ******************************************************/";
print LIBTYPES "\n\n#include <postgres.h>\n"; print LIBTYPES "\n\n#include <postgres.h>\n";
...@@ -308,11 +314,11 @@ int2* $typename"."_in (char *str) { ...@@ -308,11 +314,11 @@ int2* $typename"."_in (char *str) {
print LIBTYPES "\n * Types for table ".uc($table_name); print LIBTYPES "\n * Types for table ".uc($table_name);
print LIBTYPES "\n */\n"; print LIBTYPES "\n */\n";
$types.="\nCREATE FUNCTION $typename"."_in (opaque) $types.="\nCREATE FUNCTION $typename"."_in (cstring)
RETURNS $typename RETURNS $typename
AS '$libtypename' AS '$libtypename'
LANGUAGE 'c' LANGUAGE 'c'
WITH (ISCACHABLE);\n"; WITH (ISSTRICT, ISCACHABLE);\n";
# creating output function # creating output function
my $func_out=" my $func_out="
...@@ -362,11 +368,11 @@ bool $typename"."_ge(int2* a, int2* b) { ...@@ -362,11 +368,11 @@ bool $typename"."_ge(int2* a, int2* b) {
return (*a>=*b); return (*a>=*b);
}\n"; }\n";
$types.="\nCREATE FUNCTION $typename"."_out (opaque) $types.="\nCREATE FUNCTION $typename"."_out ($typename)
RETURNS opaque RETURNS cstring
AS '$libtypename' AS '$libtypename'
LANGUAGE 'c' LANGUAGE 'c'
WITH (ISCACHABLE);\n"; WITH (ISSTRICT, ISCACHABLE);\n";
$types.="\nCREATE TYPE $typename ( $types.="\nCREATE TYPE $typename (
internallength = 2, internallength = 2,
...@@ -509,7 +515,7 @@ $typesize* $typename"."_in (char *str) { ...@@ -509,7 +515,7 @@ $typesize* $typename"."_in (char *str) {
print LIBTYPES "\n * Types for table ".uc($table_name); print LIBTYPES "\n * Types for table ".uc($table_name);
print LIBTYPES "\n */\n"; print LIBTYPES "\n */\n";
$types.="\nCREATE FUNCTION $typename"."_in (opaque) $types.="\nCREATE FUNCTION $typename"."_in (cstring)
RETURNS $typename RETURNS $typename
AS '$libtypename' AS '$libtypename'
LANGUAGE 'c';\n"; LANGUAGE 'c';\n";
...@@ -561,8 +567,8 @@ $typesize find_in_set($typesize *a, $typesize *b) { ...@@ -561,8 +567,8 @@ $typesize find_in_set($typesize *a, $typesize *b) {
\n"; \n";
$types.="\nCREATE FUNCTION $typename"."_out (opaque) $types.="\nCREATE FUNCTION $typename"."_out ($typename)
RETURNS opaque RETURNS cstring
AS '$libtypename' AS '$libtypename'
LANGUAGE 'c';\n"; LANGUAGE 'c';\n";
...@@ -725,7 +731,7 @@ close(LIBTYPES); ...@@ -725,7 +731,7 @@ close(LIBTYPES);
open(MAKE,">Makefile"); open(MAKE,">Makefile");
print MAKE "# print MAKE "#
# My2Pg \$Revision: 1.8 $ \translated dump # My2Pg \$Revision: 1.9 $ \translated dump
# Makefile # Makefile
# #
......
DROP FUNCTION noup (); DROP FUNCTION noup ();
CREATE FUNCTION noup () CREATE FUNCTION noup ()
RETURNS opaque RETURNS trigger
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C'; LANGUAGE 'C';
...@@ -854,7 +854,7 @@ print STDERR "Add triggers definition...\n" if ($self->{debug}); ...@@ -854,7 +854,7 @@ print STDERR "Add triggers definition...\n" if ($self->{debug});
# Escaping Single Quotes # Escaping Single Quotes
#$trig->[4] =~ s/'/''/sg; #$trig->[4] =~ s/'/''/sg;
$sql_output .= "CREATE FUNCTION pg_fct_\L$trig->[0]\E () RETURNS OPAQUE AS '\n$trig->[4]\n' LANGUAGE 'plpgsql'\n\n"; $sql_output .= "CREATE FUNCTION pg_fct_\L$trig->[0]\E () RETURNS TRIGGER AS '\n$trig->[4]\n' LANGUAGE 'plpgsql'\n\n";
$sql_output .= "CREATE TRIGGER \L$trig->[0]\E\n\t$trig->[1] $trig->[2] ON \L$trig->[3]\E FOR EACH ROW\n\tEXECUTE PROCEDURE pg_fct_\L$trig->[0]\E();\n\n"; $sql_output .= "CREATE TRIGGER \L$trig->[0]\E\n\t$trig->[1] $trig->[2] ON \L$trig->[3]\E FOR EACH ROW\n\tEXECUTE PROCEDURE pg_fct_\L$trig->[0]\E();\n\n";
} }
} }
......
...@@ -89,7 +89,7 @@ RollbackAndQuit($conn) if ($result->resultStatus ne PGRES_COMMAND_OK); ...@@ -89,7 +89,7 @@ RollbackAndQuit($conn) if ($result->resultStatus ne PGRES_COMMAND_OK);
$result = $conn->exec("create sequence _rserv_sync_seq_"); $result = $conn->exec("create sequence _rserv_sync_seq_");
RollbackAndQuit($conn) if ($result->resultStatus ne PGRES_COMMAND_OK); RollbackAndQuit($conn) if ($result->resultStatus ne PGRES_COMMAND_OK);
$result = $conn->exec("CREATE FUNCTION _rserv_log_() RETURNS opaque" . $result = $conn->exec("CREATE FUNCTION _rserv_log_() RETURNS trigger" .
" AS '@MODULE_FILENAME@' LANGUAGE 'c'"); " AS '@MODULE_FILENAME@' LANGUAGE 'c'");
RollbackAndQuit($conn) if ($result->resultStatus ne PGRES_COMMAND_OK); RollbackAndQuit($conn) if ($result->resultStatus ne PGRES_COMMAND_OK);
......
...@@ -79,7 +79,7 @@ create sequence _rserv_sync_seq_; ...@@ -79,7 +79,7 @@ create sequence _rserv_sync_seq_;
drop function _rserv_log_(); drop function _rserv_log_();
CREATE FUNCTION _rserv_log_() CREATE FUNCTION _rserv_log_()
RETURNS opaque RETURNS trigger
AS '@MODULE_FILENAME@' AS '@MODULE_FILENAME@'
LANGUAGE 'c' LANGUAGE 'c'
; ;
......
...@@ -11,19 +11,19 @@ SET search_path = public; ...@@ -11,19 +11,19 @@ SET search_path = public;
-- --
-- --
-- define the GiST support methods -- define the GiST support methods
create function gbox_consistent(opaque,box,int4) returns bool as 'MODULE_PATHNAME' language 'C'; create function gbox_consistent(internal,box,int4) returns bool as 'MODULE_PATHNAME' language 'C';
create function gbox_compress(opaque) returns opaque as 'MODULE_PATHNAME' language 'C'; create function gbox_compress(internal) returns internal as 'MODULE_PATHNAME' language 'C';
create function rtree_decompress(opaque) returns opaque as 'MODULE_PATHNAME' language 'C'; create function rtree_decompress(internal) returns internal as 'MODULE_PATHNAME' language 'C';
create function gbox_penalty(opaque,opaque,opaque) returns opaque as 'MODULE_PATHNAME' language 'C' with (isstrict); create function gbox_penalty(internal,internal,internal) returns internal as 'MODULE_PATHNAME' language 'C' with (isstrict);
create function gbox_picksplit(opaque, opaque) returns opaque as 'MODULE_PATHNAME' language 'C'; create function gbox_picksplit(internal, internal) returns internal as 'MODULE_PATHNAME' language 'C';
create function gbox_union(bytea, opaque) returns box as 'MODULE_PATHNAME' language 'C'; create function gbox_union(bytea, internal) returns box as 'MODULE_PATHNAME' language 'C';
create function gbox_same(box, box, opaque) returns opaque as 'MODULE_PATHNAME' language 'C'; create function gbox_same(box, box, internal) returns internal as 'MODULE_PATHNAME' language 'C';
-- create the operator class -- create the operator class
CREATE OPERATOR CLASS gist_box_ops CREATE OPERATOR CLASS gist_box_ops
...@@ -36,13 +36,13 @@ CREATE OPERATOR CLASS gist_box_ops ...@@ -36,13 +36,13 @@ CREATE OPERATOR CLASS gist_box_ops
OPERATOR 6 ~= , OPERATOR 6 ~= ,
OPERATOR 7 ~ , OPERATOR 7 ~ ,
OPERATOR 8 @ , OPERATOR 8 @ ,
FUNCTION 1 gbox_consistent (opaque, box, int4), FUNCTION 1 gbox_consistent (internal, box, int4),
FUNCTION 2 gbox_union (bytea, opaque), FUNCTION 2 gbox_union (bytea, internal),
FUNCTION 3 gbox_compress (opaque), FUNCTION 3 gbox_compress (internal),
FUNCTION 4 rtree_decompress (opaque), FUNCTION 4 rtree_decompress (internal),
FUNCTION 5 gbox_penalty (opaque, opaque, opaque), FUNCTION 5 gbox_penalty (internal, internal, internal),
FUNCTION 6 gbox_picksplit (opaque, opaque), FUNCTION 6 gbox_picksplit (internal, internal),
FUNCTION 7 gbox_same (box, box, opaque); FUNCTION 7 gbox_same (box, box, internal);
-- --
...@@ -53,9 +53,9 @@ CREATE OPERATOR CLASS gist_box_ops ...@@ -53,9 +53,9 @@ CREATE OPERATOR CLASS gist_box_ops
-- --
-- --
-- define the GiST support methods -- define the GiST support methods
create function gpoly_consistent(opaque,polygon,int4) returns bool as 'MODULE_PATHNAME' language 'C'; create function gpoly_consistent(internal,polygon,int4) returns bool as 'MODULE_PATHNAME' language 'C';
create function gpoly_compress(opaque) returns opaque as 'MODULE_PATHNAME' language 'C'; create function gpoly_compress(internal) returns internal as 'MODULE_PATHNAME' language 'C';
-- create the operator class -- create the operator class
CREATE OPERATOR CLASS gist_poly_ops CREATE OPERATOR CLASS gist_poly_ops
...@@ -68,13 +68,13 @@ CREATE OPERATOR CLASS gist_poly_ops ...@@ -68,13 +68,13 @@ CREATE OPERATOR CLASS gist_poly_ops
OPERATOR 6 ~= RECHECK , OPERATOR 6 ~= RECHECK ,
OPERATOR 7 ~ RECHECK , OPERATOR 7 ~ RECHECK ,
OPERATOR 8 @ RECHECK , OPERATOR 8 @ RECHECK ,
FUNCTION 1 gpoly_consistent (opaque, polygon, int4), FUNCTION 1 gpoly_consistent (internal, polygon, int4),
FUNCTION 2 gbox_union (bytea, opaque), FUNCTION 2 gbox_union (bytea, internal),
FUNCTION 3 gpoly_compress (opaque), FUNCTION 3 gpoly_compress (internal),
FUNCTION 4 rtree_decompress (opaque), FUNCTION 4 rtree_decompress (internal),
FUNCTION 5 gbox_penalty (opaque, opaque, opaque), FUNCTION 5 gbox_penalty (internal, internal, internal),
FUNCTION 6 gbox_picksplit (opaque, opaque), FUNCTION 6 gbox_picksplit (internal, internal),
FUNCTION 7 gbox_same (box, box, opaque), FUNCTION 7 gbox_same (box, box, internal),
STORAGE box; STORAGE box;
......
...@@ -114,14 +114,6 @@ seg_in(char *str) ...@@ -114,14 +114,6 @@ seg_in(char *str)
return (result); return (result);
} }
/*
* You might have noticed a slight inconsistency between the following
* declaration and the SQL definition:
* CREATE FUNCTION seg_out(opaque) RETURNS opaque ...
* The reason is that the argument passed into seg_out is really just a
* pointer. POSTGRES thinks all output functions are:
* char *out_func(char *);
*/
char * char *
seg_out(SEG * seg) seg_out(SEG * seg)
{ {
......
...@@ -5,13 +5,13 @@ BEGIN TRANSACTION; ...@@ -5,13 +5,13 @@ BEGIN TRANSACTION;
-- Adjust this setting to control where the objects get created. -- Adjust this setting to control where the objects get created.
SET search_path = public; SET search_path = public;
CREATE FUNCTION seg_in(opaque) CREATE FUNCTION seg_in(cstring)
RETURNS opaque RETURNS seg
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c'; LANGUAGE 'c';
CREATE FUNCTION seg_out(opaque) CREATE FUNCTION seg_out(seg)
RETURNS opaque RETURNS cstring
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c'; LANGUAGE 'c';
...@@ -216,25 +216,25 @@ CREATE OPERATOR ~ ( ...@@ -216,25 +216,25 @@ CREATE OPERATOR ~ (
-- define the GiST support methods -- define the GiST support methods
CREATE FUNCTION gseg_consistent(opaque,seg,int4) RETURNS bool CREATE FUNCTION gseg_consistent(internal,seg,int4) RETURNS bool
AS 'MODULE_PATHNAME' LANGUAGE 'c'; AS 'MODULE_PATHNAME' LANGUAGE 'c';
CREATE FUNCTION gseg_compress(opaque) RETURNS opaque CREATE FUNCTION gseg_compress(internal) RETURNS internal
AS 'MODULE_PATHNAME' LANGUAGE 'c'; AS 'MODULE_PATHNAME' LANGUAGE 'c';
CREATE FUNCTION gseg_decompress(opaque) RETURNS opaque CREATE FUNCTION gseg_decompress(internal) RETURNS internal
AS 'MODULE_PATHNAME' LANGUAGE 'c'; AS 'MODULE_PATHNAME' LANGUAGE 'c';
CREATE FUNCTION gseg_penalty(opaque,opaque,opaque) RETURNS opaque CREATE FUNCTION gseg_penalty(internal,internal,internal) RETURNS internal
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
CREATE FUNCTION gseg_picksplit(opaque, opaque) RETURNS opaque CREATE FUNCTION gseg_picksplit(internal, internal) RETURNS internal
AS 'MODULE_PATHNAME' LANGUAGE 'c'; AS 'MODULE_PATHNAME' LANGUAGE 'c';
CREATE FUNCTION gseg_union(bytea, opaque) RETURNS seg CREATE FUNCTION gseg_union(bytea, internal) RETURNS seg
AS 'MODULE_PATHNAME' LANGUAGE 'c'; AS 'MODULE_PATHNAME' LANGUAGE 'c';
CREATE FUNCTION gseg_same(seg, seg, opaque) RETURNS opaque CREATE FUNCTION gseg_same(seg, seg, internal) RETURNS internal
AS 'MODULE_PATHNAME' LANGUAGE 'c'; AS 'MODULE_PATHNAME' LANGUAGE 'c';
...@@ -250,13 +250,13 @@ CREATE OPERATOR CLASS gist_seg_ops ...@@ -250,13 +250,13 @@ CREATE OPERATOR CLASS gist_seg_ops
OPERATOR 6 = , OPERATOR 6 = ,
OPERATOR 7 @ , OPERATOR 7 @ ,
OPERATOR 8 ~ , OPERATOR 8 ~ ,
FUNCTION 1 gseg_consistent (opaque, seg, int4), FUNCTION 1 gseg_consistent (internal, seg, int4),
FUNCTION 2 gseg_union (bytea, opaque), FUNCTION 2 gseg_union (bytea, internal),
FUNCTION 3 gseg_compress (opaque), FUNCTION 3 gseg_compress (internal),
FUNCTION 4 gseg_decompress (opaque), FUNCTION 4 gseg_decompress (internal),
FUNCTION 5 gseg_penalty (opaque, opaque, opaque), FUNCTION 5 gseg_penalty (internal, internal, internal),
FUNCTION 6 gseg_picksplit (opaque, opaque), FUNCTION 6 gseg_picksplit (internal, internal),
FUNCTION 7 gseg_same (seg, seg, opaque); FUNCTION 7 gseg_same (seg, seg, internal);
END TRANSACTION; END TRANSACTION;
DROP FUNCTION autoinc(); DROP FUNCTION autoinc();
CREATE FUNCTION autoinc() CREATE FUNCTION autoinc()
RETURNS opaque RETURNS trigger
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C'; LANGUAGE 'C';
DROP FUNCTION insert_username(); DROP FUNCTION insert_username();
CREATE FUNCTION insert_username() CREATE FUNCTION insert_username()
RETURNS opaque RETURNS trigger
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C'; LANGUAGE 'C';
DROP FUNCTION moddatetime(); DROP FUNCTION moddatetime();
CREATE FUNCTION moddatetime() CREATE FUNCTION moddatetime()
RETURNS opaque RETURNS trigger
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C'; LANGUAGE 'C';
...@@ -2,11 +2,11 @@ DROP FUNCTION check_primary_key (); ...@@ -2,11 +2,11 @@ DROP FUNCTION check_primary_key ();
DROP FUNCTION check_foreign_key (); DROP FUNCTION check_foreign_key ();
CREATE FUNCTION check_primary_key () CREATE FUNCTION check_primary_key ()
RETURNS opaque RETURNS trigger
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C'; LANGUAGE 'C';
CREATE FUNCTION check_foreign_key () CREATE FUNCTION check_foreign_key ()
RETURNS opaque RETURNS trigger
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C'; LANGUAGE 'C';
...@@ -2,7 +2,7 @@ DROP FUNCTION timetravel(); ...@@ -2,7 +2,7 @@ DROP FUNCTION timetravel();
DROP FUNCTION set_timetravel(name, int4); DROP FUNCTION set_timetravel(name, int4);
CREATE FUNCTION timetravel() CREATE FUNCTION timetravel()
RETURNS opaque RETURNS trigger
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C'; LANGUAGE 'C';
......
...@@ -9,21 +9,21 @@ ...@@ -9,21 +9,21 @@
-- Define the new output functions. -- Define the new output functions.
-- --
create function c_charout(opaque) returns int4 create function c_charout(bpchar) returns cstring
as 'MODULE_PATHNAME' as 'MODULE_PATHNAME'
language 'c'; language 'c';
create function c_textout(opaque) returns int4 create function c_textout(text) returns cstring
as 'MODULE_PATHNAME' as 'MODULE_PATHNAME'
language 'c'; language 'c';
create function c_varcharout(opaque) returns int4 create function c_varcharout(varchar) returns cstring
as 'MODULE_PATHNAME' as 'MODULE_PATHNAME'
language 'c'; language 'c';
-- This is not needed because escapes are handled by the parser -- This is not needed because escapes are handled by the parser
-- --
-- create function c_textin(opaque) -- create function c_textin(cstring)
-- returns text -- returns text
-- as 'MODULE_PATHNAME' -- as 'MODULE_PATHNAME'
-- language 'c'; -- language 'c';
......
...@@ -5,13 +5,13 @@ SET search_path = public; ...@@ -5,13 +5,13 @@ SET search_path = public;
-- TXTIDX type -- TXTIDX type
CREATE FUNCTION txtidx_in(opaque) CREATE FUNCTION txtidx_in(cstring)
RETURNS opaque RETURNS txtidx
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'c' with (isstrict);
CREATE FUNCTION txtidx_out(opaque) CREATE FUNCTION txtidx_out(txtidx)
RETURNS opaque RETURNS cstring
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'c' with (isstrict);
...@@ -34,13 +34,13 @@ LANGUAGE 'c' with (isstrict); ...@@ -34,13 +34,13 @@ LANGUAGE 'c' with (isstrict);
--QUERYTYPES --QUERYTYPES
--without morphology --without morphology
CREATE FUNCTION qtxt_in(opaque) CREATE FUNCTION qtxt_in(cstring)
RETURNS opaque RETURNS query_txt
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'c' with (isstrict);
CREATE FUNCTION qtxt_out(opaque) CREATE FUNCTION qtxt_out(query_txt)
RETURNS opaque RETURNS cstring
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'c' with (isstrict);
...@@ -51,15 +51,21 @@ output = qtxt_out ...@@ -51,15 +51,21 @@ output = qtxt_out
); );
--with morphology --with morphology
CREATE FUNCTION mqtxt_in(opaque) CREATE FUNCTION mqtxt_in(cstring)
RETURNS opaque RETURNS mquery_txt
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'c' with (isstrict);
--same C output function as for query_txt
CREATE FUNCTION mqtxt_out(mquery_txt)
RETURNS cstring
AS 'MODULE_PATHNAME', 'qtxt_out'
LANGUAGE 'c' with (isstrict);
CREATE TYPE mquery_txt ( CREATE TYPE mquery_txt (
internallength = -1, internallength = -1,
input = mqtxt_in, input = mqtxt_in,
output = qtxt_out output = mqtxt_out
); );
--only for debug --only for debug
...@@ -115,19 +121,19 @@ CREATE OPERATOR ~# ( ...@@ -115,19 +121,19 @@ CREATE OPERATOR ~# (
); );
--Trigger --Trigger
create function tsearch() returns opaque as create function tsearch() returns trigger as
'MODULE_PATHNAME' 'MODULE_PATHNAME'
language 'C'; language 'C';
--GiST --GiST
--GiST key type --GiST key type
CREATE FUNCTION gtxtidx_in(opaque) CREATE FUNCTION gtxtidx_in(cstring)
RETURNS opaque RETURNS gtxtidx
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'c' with (isstrict);
CREATE FUNCTION gtxtidx_out(opaque) CREATE FUNCTION gtxtidx_out(gtxtidx)
RETURNS opaque RETURNS cstring
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'c' with (isstrict);
...@@ -138,25 +144,25 @@ output = gtxtidx_out ...@@ -138,25 +144,25 @@ output = gtxtidx_out
); );
-- support functions -- support functions
CREATE FUNCTION gtxtidx_consistent(gtxtidx,opaque,int4) RETURNS bool CREATE FUNCTION gtxtidx_consistent(gtxtidx,internal,int4) RETURNS bool
AS 'MODULE_PATHNAME' LANGUAGE 'c'; AS 'MODULE_PATHNAME' LANGUAGE 'c';
CREATE FUNCTION gtxtidx_compress(opaque) RETURNS opaque CREATE FUNCTION gtxtidx_compress(internal) RETURNS internal
AS 'MODULE_PATHNAME' LANGUAGE 'c'; AS 'MODULE_PATHNAME' LANGUAGE 'c';
CREATE FUNCTION gtxtidx_decompress(opaque) RETURNS opaque CREATE FUNCTION gtxtidx_decompress(internal) RETURNS internal
AS 'MODULE_PATHNAME' LANGUAGE 'c'; AS 'MODULE_PATHNAME' LANGUAGE 'c';
CREATE FUNCTION gtxtidx_penalty(opaque,opaque,opaque) RETURNS opaque CREATE FUNCTION gtxtidx_penalty(internal,internal,internal) RETURNS internal
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
CREATE FUNCTION gtxtidx_picksplit(opaque, opaque) RETURNS opaque CREATE FUNCTION gtxtidx_picksplit(internal, internal) RETURNS internal
AS 'MODULE_PATHNAME' LANGUAGE 'c'; AS 'MODULE_PATHNAME' LANGUAGE 'c';
CREATE FUNCTION gtxtidx_union(bytea, opaque) RETURNS _int4 CREATE FUNCTION gtxtidx_union(bytea, internal) RETURNS _int4
AS 'MODULE_PATHNAME' LANGUAGE 'c'; AS 'MODULE_PATHNAME' LANGUAGE 'c';
CREATE FUNCTION gtxtidx_same(gtxtidx, gtxtidx, opaque) RETURNS opaque CREATE FUNCTION gtxtidx_same(gtxtidx, gtxtidx, internal) RETURNS internal
AS 'MODULE_PATHNAME' LANGUAGE 'c'; AS 'MODULE_PATHNAME' LANGUAGE 'c';
-- create the operator class -- create the operator class
...@@ -164,13 +170,13 @@ CREATE OPERATOR CLASS gist_txtidx_ops ...@@ -164,13 +170,13 @@ CREATE OPERATOR CLASS gist_txtidx_ops
DEFAULT FOR TYPE txtidx USING gist AS DEFAULT FOR TYPE txtidx USING gist AS
OPERATOR 1 @@ (txtidx, query_txt) RECHECK , OPERATOR 1 @@ (txtidx, query_txt) RECHECK ,
OPERATOR 2 ## (txtidx, mquery_txt) RECHECK , OPERATOR 2 ## (txtidx, mquery_txt) RECHECK ,
FUNCTION 1 gtxtidx_consistent (gtxtidx, opaque, int4), FUNCTION 1 gtxtidx_consistent (gtxtidx, internal, int4),
FUNCTION 2 gtxtidx_union (bytea, opaque), FUNCTION 2 gtxtidx_union (bytea, internal),
FUNCTION 3 gtxtidx_compress (opaque), FUNCTION 3 gtxtidx_compress (internal),
FUNCTION 4 gtxtidx_decompress (opaque), FUNCTION 4 gtxtidx_decompress (internal),
FUNCTION 5 gtxtidx_penalty (opaque, opaque, opaque), FUNCTION 5 gtxtidx_penalty (internal, internal, internal),
FUNCTION 6 gtxtidx_picksplit (opaque, opaque), FUNCTION 6 gtxtidx_picksplit (internal, internal),
FUNCTION 7 gtxtidx_same (gtxtidx, gtxtidx, opaque), FUNCTION 7 gtxtidx_same (gtxtidx, gtxtidx, internal),
STORAGE gtxtidx; STORAGE gtxtidx;
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.99 2002/08/19 19:33:33 tgl Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.100 2002/08/22 00:01:40 tgl Exp $
--> -->
<chapter id="datatype"> <chapter id="datatype">
...@@ -3099,6 +3099,146 @@ SELECT SUBSTRING(b FROM 1 FOR 2) FROM test; ...@@ -3099,6 +3099,146 @@ SELECT SUBSTRING(b FROM 1 FOR 2) FROM test;
</sect1> </sect1>
<sect1 id="datatype-pseudo">
<title>Pseudo-Types</title>
<indexterm zone="datatype-pseudo">
<primary>record</primary>
</indexterm>
<indexterm zone="datatype-pseudo">
<primary>any</primary>
</indexterm>
<indexterm zone="datatype-pseudo">
<primary>anyarray</primary>
</indexterm>
<indexterm zone="datatype-pseudo">
<primary>void</primary>
</indexterm>
<indexterm zone="datatype-pseudo">
<primary>trigger</primary>
</indexterm>
<indexterm zone="datatype-pseudo">
<primary>language_handler</primary>
</indexterm>
<indexterm zone="datatype-pseudo">
<primary>cstring</primary>
</indexterm>
<indexterm zone="datatype-pseudo">
<primary>internal</primary>
</indexterm>
<indexterm zone="datatype-pseudo">
<primary>opaque</primary>
</indexterm>
<para>
The <productname>PostgreSQL</productname> type system contains a number
of special-purpose entries that are collectively called
<firstterm>pseudo-types</>. A pseudo-type cannot be used as a column
datatype, but it can be used to declare a function's argument or result
type. Each of the available pseudo-types is useful in situations where
a function's behavior does not correspond to simply taking or returning
a value of a specific SQL datatype.
</para>
<para>
<table tocentry="1">
<title>Pseudo-Types</title>
<tgroup cols="2">
<thead>
<row>
<entry>Type name</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry><type>record</></entry>
<entry>Identifies a function returning an unspecified tuple type</entry>
</row>
<row>
<entry><type>any</></entry>
<entry>Indicates that a function accepts any input datatype whatever</entry>
</row>
<row>
<entry><type>anyarray</></entry>
<entry>Indicates that a function accepts any array datatype</entry>
</row>
<row>
<entry><type>void</></entry>
<entry>Indicates that a function returns no value</entry>
</row>
<row>
<entry><type>trigger</></entry>
<entry>A trigger function is declared to return <type>trigger</></entry>
</row>
<row>
<entry><type>language_handler</></entry>
<entry>A procedural language call handler is declared to return <type>language_handler</></entry>
</row>
<row>
<entry><type>cstring</></entry>
<entry>Indicates a function takes or returns a null-terminated C string</entry>
</row>
<row>
<entry><type>internal</></entry>
<entry>Indicates that a function accepts or returns a server-internal
data type</entry>
</row>
<row>
<entry><type>opaque</></entry>
<entry>An obsolete type name that formerly served all the above purposes</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<para>
Functions coded in C (whether built-in or dynamically loaded) may be
declared to take or return any of these pseudo datatypes. It is up to
the function author to ensure that the function will behave safely
when a pseudo-type is used as an argument type.
</para>
<para>
Functions coded in procedural languages may use pseudo-types only as
allowed by their implementation languages. At present the procedural
languages all forbid use of a pseudo-type as argument type, and allow
only <type>void</> as a result type (plus <type>trigger</> when the
function is used as a trigger).
</para>
<para>
The <type>internal</> pseudo-type is used to declare functions that are
meant only to be called internally by the database system, and not by
direct invocation in a SQL query. If a function has at least one
<type>internal</>-type argument then it cannot be called from SQL.
To preserve the type safety of this restriction it is important to
follow this coding rule: do not create any function that is declared
to return <type>internal</> unless it has at least one <type>internal</>
argument.
</para>
</sect1>
&array; &array;
</chapter> </chapter>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/indexcost.sgml,v 2.11 2002/03/22 19:20:10 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/Attic/indexcost.sgml,v 2.12 2002/08/22 00:01:40 tgl Exp $
--> -->
<chapter id="indexcost"> <chapter id="indexcost">
...@@ -261,15 +261,8 @@ amcostestimate (Query *root, ...@@ -261,15 +261,8 @@ amcostestimate (Query *root,
<para> <para>
By convention, the <literal>pg_proc</literal> entry for an By convention, the <literal>pg_proc</literal> entry for an
<literal>amcostestimate</literal> function should show <literal>amcostestimate</literal> function should show
eight arguments all declared as <type>internal</> (since none of them have
<programlisting> types that are known to SQL), and the return type is <type>void</>.
prorettype = 0
pronargs = 8
proargtypes = 0 0 0 0 0 0 0 0
</programlisting>
We use zero ("opaque") for all the arguments since none of them have types
that are known in pg_type.
</para> </para>
</chapter> </chapter>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/plpgsql.sgml,v 1.2 2002/08/20 05:28:23 momjian Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/plpgsql.sgml,v 1.3 2002/08/22 00:01:40 tgl Exp $
--> -->
<chapter id="plpgsql"> <chapter id="plpgsql">
...@@ -1865,7 +1865,7 @@ RAISE EXCEPTION ''Inexistent ID --> %'',user_id; ...@@ -1865,7 +1865,7 @@ RAISE EXCEPTION ''Inexistent ID --> %'',user_id;
<application>PL/pgSQL</application> can be used to define trigger <application>PL/pgSQL</application> can be used to define trigger
procedures. A trigger procedure is created with the <command>CREATE procedures. A trigger procedure is created with the <command>CREATE
FUNCTION</command> command as a function with no arguments and a return FUNCTION</command> command as a function with no arguments and a return
type of <type>OPAQUE</type>. Note that the function must be declared type of <type>TRIGGER</type>. Note that the function must be declared
with no arguments even if it expects to receive arguments specified with no arguments even if it expects to receive arguments specified
in <command>CREATE TRIGGER</> --- trigger arguments are passed via in <command>CREATE TRIGGER</> --- trigger arguments are passed via
<varname>TG_ARGV</>, as described below. <varname>TG_ARGV</>, as described below.
...@@ -2022,7 +2022,7 @@ CREATE TABLE emp ( ...@@ -2022,7 +2022,7 @@ CREATE TABLE emp (
last_user text last_user text
); );
CREATE FUNCTION emp_stamp () RETURNS OPAQUE AS ' CREATE FUNCTION emp_stamp () RETURNS TRIGGER AS '
BEGIN BEGIN
-- Check that empname and salary are given -- Check that empname and salary are given
IF NEW.empname ISNULL THEN IF NEW.empname ISNULL THEN
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/pltcl.sgml,v 2.20 2002/03/22 19:20:21 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/pltcl.sgml,v 2.21 2002/08/22 00:01:40 tgl Exp $
--> -->
<chapter id="pltcl"> <chapter id="pltcl">
...@@ -472,7 +472,7 @@ SELECT 'doesn''t' AS ret ...@@ -472,7 +472,7 @@ SELECT 'doesn''t' AS ret
Trigger procedures can be written in PL/Tcl. As is customary in Trigger procedures can be written in PL/Tcl. As is customary in
<productname>PostgreSQL</productname>, a procedure that's to be called <productname>PostgreSQL</productname>, a procedure that's to be called
as a trigger must be declared as a function with no arguments as a trigger must be declared as a function with no arguments
and a return type of <literal>opaque</>. and a return type of <literal>trigger</>.
</para> </para>
<para> <para>
The information from the trigger manager is passed to the procedure body The information from the trigger manager is passed to the procedure body
...@@ -597,7 +597,7 @@ SELECT 'doesn''t' AS ret ...@@ -597,7 +597,7 @@ SELECT 'doesn''t' AS ret
incremented on every update operation: incremented on every update operation:
<programlisting> <programlisting>
CREATE FUNCTION trigfunc_modcount() RETURNS OPAQUE AS ' CREATE FUNCTION trigfunc_modcount() RETURNS TRIGGER AS '
switch $TG_op { switch $TG_op {
INSERT { INSERT {
set NEW($1) 0 set NEW($1) 0
......
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_conversion.sgml,v 1.2 2002/07/22 13:00:00 ishii Exp $ --> <!-- $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_conversion.sgml,v 1.3 2002/08/22 00:01:40 tgl Exp $ -->
<refentry id="SQL-CREATECONVERSION"> <refentry id="SQL-CREATECONVERSION">
<refmeta> <refmeta>
...@@ -108,10 +108,10 @@ CREATE [DEFAULT] CONVERSION <replaceable>conversion_name</replaceable> ...@@ -108,10 +108,10 @@ CREATE [DEFAULT] CONVERSION <replaceable>conversion_name</replaceable>
conv_proc( conv_proc(
INTEGER, -- source encoding id INTEGER, -- source encoding id
INTEGER, -- destination encoding id INTEGER, -- destination encoding id
OPAQUE, -- source string (null terminated C string) CSTRING, -- source string (null terminated C string)
OPAQUE, -- destination string (null terminated C string) CSTRING, -- destination string (null terminated C string)
INTEGER -- source string length INTEGER -- source string length
) returns INTEGER; -- dummy. returns nothing, actually. ) returns VOID;
</programlisting> </programlisting>
</para> </para>
</listitem> </listitem>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_function.sgml,v 1.41 2002/07/24 19:11:07 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_function.sgml,v 1.42 2002/08/22 00:01:40 tgl Exp $
--> -->
<refentry id="SQL-CREATEFUNCTION"> <refentry id="SQL-CREATEFUNCTION">
...@@ -67,16 +67,17 @@ CREATE [ OR REPLACE ] FUNCTION <replaceable class="parameter">name</replaceable> ...@@ -67,16 +67,17 @@ CREATE [ OR REPLACE ] FUNCTION <replaceable class="parameter">name</replaceable>
<listitem> <listitem>
<para> <para>
The data type(s) of the function's arguments, if any. The The data type(s) of the function's arguments, if any. The
input types may be base or complex types, input types may be base, complex, or domain types,
<literal>opaque</literal>, or the same as the type of an or the same as the type of an existing column.
existing column. <literal>Opaque</literal> indicates The type of a column is referenced by writing <replaceable
that the function accepts arguments of a non-SQL type such as
<type>char *</type>.
The type of a column is indicated using <replaceable
class="parameter">tablename</replaceable>.<replaceable class="parameter">tablename</replaceable>.<replaceable
class="parameter">columnname</replaceable><literal>%TYPE</literal>; class="parameter">columnname</replaceable><literal>%TYPE</literal>;
using this can sometimes help make a function independent from using this can sometimes help make a function independent from
changes to the definition of a table. changes to the definition of a table.
Depending on the implementation language it may also be allowed
to specify <quote>pseudo-types</> such as <type>cstring</>.
Pseudo-types indicate that the actual argument type is either
incompletely specified, or outside the set of ordinary SQL datatypes.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -87,15 +88,13 @@ CREATE [ OR REPLACE ] FUNCTION <replaceable class="parameter">name</replaceable> ...@@ -87,15 +88,13 @@ CREATE [ OR REPLACE ] FUNCTION <replaceable class="parameter">name</replaceable>
<listitem> <listitem>
<para> <para>
The return data type. The return type may be specified as a The return data type. The return type may be specified as a
base type, complex type, <literal>setof</literal> type, base, complex, or domain type, or the same as the type of an
<literal>opaque</literal>, or the same as the type of an
existing column. existing column.
Depending on the implementation language it may also be allowed
to specify <quote>pseudo-types</> such as <type>cstring</>.
The <literal>setof</literal> The <literal>setof</literal>
modifier indicates that the function will return a set of modifier indicates that the function will return a set of
items, rather than a single item. Functions with a declared items, rather than a single item.
return type of <literal>opaque</literal> do not return a value.
These cannot be called directly; trigger functions make use of
this feature.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_language.sgml,v 1.26 2002/07/24 19:11:07 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_language.sgml,v 1.27 2002/08/22 00:01:40 tgl Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -108,8 +108,8 @@ CREATE [ TRUSTED ] [ PROCEDURAL ] LANGUAGE <replaceable class="parameter">langna ...@@ -108,8 +108,8 @@ CREATE [ TRUSTED ] [ PROCEDURAL ] LANGUAGE <replaceable class="parameter">langna
language such as C with version 1 call convention and language such as C with version 1 call convention and
registered with <productname>PostgreSQL</productname> as a registered with <productname>PostgreSQL</productname> as a
function taking no arguments and returning the function taking no arguments and returning the
<type>opaque</type> type, a placeholder for unspecified or <type>language_handler</type> type, a placeholder type that is
undefined types. simply used to identify the function as a call handler.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -122,11 +122,13 @@ CREATE [ TRUSTED ] [ PROCEDURAL ] LANGUAGE <replaceable class="parameter">langna ...@@ -122,11 +122,13 @@ CREATE [ TRUSTED ] [ PROCEDURAL ] LANGUAGE <replaceable class="parameter">langna
<replaceable class="parameter">valfunction</replaceable> is the <replaceable class="parameter">valfunction</replaceable> is the
name of a previously registered function that will be called name of a previously registered function that will be called
when a new function in the language is created, to validate the when a new function in the language is created, to validate the
new function. The validator function must take one argument of new function.
type <type>oid</type>, which will be the OID of the If no
to-be-created function, and can have any return type. If no
validator function is specified, then a new function will not validator function is specified, then a new function will not
be checked when it is created. be checked when it is created.
The validator function must take one argument of
type <type>oid</type>, which will be the OID of the
to-be-created function, and will typically return <type>void</>.
</para> </para>
<para> <para>
...@@ -251,7 +253,7 @@ ERROR: PL handler function <replaceable class="parameter">funcname</replaceable ...@@ -251,7 +253,7 @@ ERROR: PL handler function <replaceable class="parameter">funcname</replaceable
The following two commands executed in sequence will register a new The following two commands executed in sequence will register a new
procedural language and the associated call handler. procedural language and the associated call handler.
<programlisting> <programlisting>
CREATE FUNCTION plsample_call_handler () RETURNS opaque CREATE FUNCTION plsample_call_handler () RETURNS language_handler
AS '$libdir/plsample' AS '$libdir/plsample'
LANGUAGE C; LANGUAGE C;
CREATE LANGUAGE plsample CREATE LANGUAGE plsample
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_opclass.sgml,v 1.1 2002/07/29 22:14:10 tgl Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_opclass.sgml,v 1.2 2002/08/22 00:01:40 tgl Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -260,13 +260,13 @@ CREATE OPERATOR CLASS gist__int_ops ...@@ -260,13 +260,13 @@ CREATE OPERATOR CLASS gist__int_ops
OPERATOR 7 @, OPERATOR 7 @,
OPERATOR 8 ~, OPERATOR 8 ~,
OPERATOR 20 @@ (_int4, query_int), OPERATOR 20 @@ (_int4, query_int),
FUNCTION 1 g_int_consistent (opaque, _int4, int4), FUNCTION 1 g_int_consistent (internal, _int4, int4),
FUNCTION 2 g_int_union (bytea, opaque), FUNCTION 2 g_int_union (bytea, internal),
FUNCTION 3 g_int_compress (opaque), FUNCTION 3 g_int_compress (internal),
FUNCTION 4 g_int_decompress (opaque), FUNCTION 4 g_int_decompress (internal),
FUNCTION 5 g_int_penalty (opaque, opaque, opaque), FUNCTION 5 g_int_penalty (internal, internal, internal),
FUNCTION 6 g_int_picksplit (opaque, opaque), FUNCTION 6 g_int_picksplit (internal, internal),
FUNCTION 7 g_int_same (_int4, _int4, opaque); FUNCTION 7 g_int_same (_int4, _int4, internal);
</programlisting> </programlisting>
<para> <para>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_trigger.sgml,v 1.26 2002/05/18 15:44:47 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_trigger.sgml,v 1.27 2002/08/22 00:01:40 tgl Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -66,7 +66,7 @@ CREATE TRIGGER <replaceable class="PARAMETER">name</replaceable> { BEFORE | AFTE ...@@ -66,7 +66,7 @@ CREATE TRIGGER <replaceable class="PARAMETER">name</replaceable> { BEFORE | AFTE
<listitem> <listitem>
<para> <para>
A user-supplied function that is declared as taking no arguments A user-supplied function that is declared as taking no arguments
and returning type <literal>opaque</>. and returning type <literal>trigger</>.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -167,6 +167,14 @@ CREATE TRIGGER ...@@ -167,6 +167,14 @@ CREATE TRIGGER
<literal>TRIGGER</literal> privilege on the table. <literal>TRIGGER</literal> privilege on the table.
</para> </para>
<para>
In <productname>PostgreSQL</productname> versions before 7.3, it was
necessary to declare trigger functions as returning the placeholder
type <type>opaque</>, rather than <type>trigger</>. This is still
supported, but is deprecated because it is obscure and causes loss of
type safety.
</para>
<para> <para>
As of the current release, <literal>STATEMENT</literal> triggers are not implemented. As of the current release, <literal>STATEMENT</literal> triggers are not implemented.
</para> </para>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_type.sgml,v 1.31 2002/08/15 16:36:00 momjian Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_type.sgml,v 1.32 2002/08/22 00:01:40 tgl Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -226,22 +226,47 @@ CREATE TYPE ...@@ -226,22 +226,47 @@ CREATE TYPE
operators and functions defined for the type. Naturally, operators and functions defined for the type. Naturally,
<replaceable class="parameter">output_function</replaceable> <replaceable class="parameter">output_function</replaceable>
performs the reverse transformation. The input function may be performs the reverse transformation. The input function may be
declared as taking one argument of type <type>opaque</type>, declared as taking one argument of type <type>cstring</type>,
or as taking three arguments of types or as taking three arguments of types
<type>opaque</type>, <type>OID</type>, <type>int4</type>. <type>cstring</type>, <type>OID</type>, <type>int4</type>.
(The first argument is the input text as a C string, the second (The first argument is the input text as a C string, the second
argument is the element type in case this is an array type, argument is the element type in case this is an array type,
and the third is the typmod of the destination column, if known.) and the third is the typmod of the destination column, if known.)
It should return a value of the datatype itself.
The output function may be The output function may be
declared as taking one argument of type <type>opaque</type>, declared as taking one argument of the new datatype, or as taking
or as taking two arguments of types two arguments of which the second is type <type>OID</type>.
<type>opaque</type>, <type>OID</type>. (The second argument is again the array element type for array types.)
(The first argument is actually of the data type itself, but since the The output function should return type <type>cstring</type>.
output function must be declared first, it's easier to declare it as
accepting type <type>opaque</type>. The second argument is again
the array element type for array types.)
</para> </para>
<para>
You should at this point be wondering how the input and output functions
can be declared to have results or inputs of the new type, when they have
to be created before the new type can be created. The answer is that the
input function must be created first, then the output function, then the
datatype.
<productname>PostgreSQL</productname> will first see the name of the new
datatype as the return type of the input function. It will create a
<quote>shell</> type, which is simply a placeholder entry in
<literal>pg_type</>, and link the input function definition to the shell
type. Similarly the output function will be linked to the (now already
existing) shell type. Finally, <command>CREATE TYPE</> replaces the
shell entry with a complete type definition, and the new type can be used.
</para>
<note>
<para>
In <productname>PostgreSQL</productname> versions before 7.3, it was
customary to avoid creating a shell type by replacing the functions'
forward references to the type name with the placeholder pseudo-type
<type>OPAQUE</>. The <type>cstring</> inputs and
results also had to be declared as <type>OPAQUE</> before 7.3.
Use of <type>OPAQUE</> for this purpose is still supported, but it is
deprecated because it causes loss of type safety.
</para>
</note>
<para> <para>
New base data types can be fixed length, in which case New base data types can be fixed length, in which case
<replaceable class="parameter">internallength</replaceable> is a <replaceable class="parameter">internallength</replaceable> is a
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.149 2002/08/20 17:54:44 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.150 2002/08/22 00:01:40 tgl Exp $
--> -->
<appendix id="release"> <appendix id="release">
...@@ -24,6 +24,7 @@ CDATA means the content is "SGML-free", so you can write without ...@@ -24,6 +24,7 @@ CDATA means the content is "SGML-free", so you can write without
worries about funny characters. worries about funny characters.
--> -->
<literallayout><![CDATA[ <literallayout><![CDATA[
Type OPAQUE is now deprecated in favor of pseudo-types cstring, trigger, etc
Files larger than 2 GB are now supported (if supported by the operating system) Files larger than 2 GB are now supported (if supported by the operating system)
SERIAL no longer implies UNIQUE; specify explicitly if index is wanted SERIAL no longer implies UNIQUE; specify explicitly if index is wanted
pg_dump -n and -N options have been removed. The new behavior is like -n but knows about key words. pg_dump -n and -N options have been removed. The new behavior is like -n but knows about key words.
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/trigger.sgml,v 1.23 2002/04/19 16:36:08 tgl Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/trigger.sgml,v 1.24 2002/08/22 00:01:40 tgl Exp $
--> -->
<chapter id="triggers"> <chapter id="triggers">
...@@ -26,7 +26,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/trigger.sgml,v 1.23 2002/04/19 16:36:08 tgl ...@@ -26,7 +26,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/trigger.sgml,v 1.23 2002/04/19 16:36:08 tgl
<para> <para>
The trigger function must be defined before the trigger itself can be The trigger function must be defined before the trigger itself can be
created. The trigger function must be declared as a created. The trigger function must be declared as a
function taking no arguments and returning type <literal>opaque</>. function taking no arguments and returning type <literal>trigger</>.
(The trigger function receives its input through a TriggerData (The trigger function receives its input through a TriggerData
structure, not in the form of ordinary function arguments.) structure, not in the form of ordinary function arguments.)
If the function is written in C, it must use the <quote>version 1</> If the function is written in C, it must use the <quote>version 1</>
...@@ -536,7 +536,7 @@ trigf(PG_FUNCTION_ARGS) ...@@ -536,7 +536,7 @@ trigf(PG_FUNCTION_ARGS)
Now, compile and create the trigger function: Now, compile and create the trigger function:
<programlisting> <programlisting>
CREATE FUNCTION trigf () RETURNS OPAQUE AS CREATE FUNCTION trigf () RETURNS TRIGGER AS
'...path_to_so' LANGUAGE 'C'; '...path_to_so' LANGUAGE 'C';
CREATE TABLE ttest (x int4); CREATE TABLE ttest (x int4);
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/xfunc.sgml,v 1.54 2002/07/30 16:20:03 momjian Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/xfunc.sgml,v 1.55 2002/08/22 00:01:40 tgl Exp $
--> -->
<chapter id="xfunc"> <chapter id="xfunc">
...@@ -2071,12 +2071,9 @@ SELECT * FROM vw_getfoo; ...@@ -2071,12 +2071,9 @@ SELECT * FROM vw_getfoo;
<quote>normal</quote> function, which must be written in a <quote>normal</quote> function, which must be written in a
compiled language such as C and registered with compiled language such as C and registered with
<productname>PostgreSQL</productname> as taking no arguments and <productname>PostgreSQL</productname> as taking no arguments and
returning the <type>opaque</type> type, a placeholder for returning the <type>language_handler</type> type.
unspecified or undefined types. This prevents the call handler This special pseudo-type identifies the handler as a call handler
from being called directly as a function from queries. (However, and prevents it from being called directly in queries.
arguments may be supplied in the actual call to the handler when a
function in the language offered by the handler is to be
executed.)
</para> </para>
<note> <note>
...@@ -2203,7 +2200,7 @@ plsample_call_handler(PG_FUNCTION_ARGS) ...@@ -2203,7 +2200,7 @@ plsample_call_handler(PG_FUNCTION_ARGS)
The following commands then register the sample procedural The following commands then register the sample procedural
language: language:
<programlisting> <programlisting>
CREATE FUNCTION plsample_call_handler () RETURNS opaque CREATE FUNCTION plsample_call_handler () RETURNS language_handler
AS '/usr/local/pgsql/lib/plsample' AS '/usr/local/pgsql/lib/plsample'
LANGUAGE C; LANGUAGE C;
CREATE LANGUAGE plsample CREATE LANGUAGE plsample
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/xplang.sgml,v 1.17 2002/01/07 02:29:14 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/xplang.sgml,v 1.18 2002/08/22 00:01:40 tgl Exp $
--> -->
<chapter id="xplang"> <chapter id="xplang">
...@@ -82,10 +82,10 @@ createlang plpgsql template1 ...@@ -82,10 +82,10 @@ createlang plpgsql template1
The handler must be declared with the command The handler must be declared with the command
<synopsis> <synopsis>
CREATE FUNCTION <replaceable>handler_function_name</replaceable> () CREATE FUNCTION <replaceable>handler_function_name</replaceable> ()
RETURNS OPAQUE AS RETURNS LANGUAGE_HANDLER AS
'<replaceable>path-to-shared-object</replaceable>' LANGUAGE C; '<replaceable>path-to-shared-object</replaceable>' LANGUAGE C;
</synopsis> </synopsis>
The special return type of <type>OPAQUE</type> tells The special return type of <type>LANGUAGE_HANDLER</type> tells
the database that this function does not return one of the database that this function does not return one of
the defined <acronym>SQL</acronym> data types and is not directly usable the defined <acronym>SQL</acronym> data types and is not directly usable
in <acronym>SQL</acronym> statements. in <acronym>SQL</acronym> statements.
...@@ -140,7 +140,7 @@ CREATE <optional>TRUSTED</optional> <optional>PROCEDURAL</optional> LANGUAGE <re ...@@ -140,7 +140,7 @@ CREATE <optional>TRUSTED</optional> <optional>PROCEDURAL</optional> LANGUAGE <re
shared object for the <application>PL/pgSQL</application> language's call handler function. shared object for the <application>PL/pgSQL</application> language's call handler function.
<programlisting> <programlisting>
CREATE FUNCTION plpgsql_call_handler () RETURNS OPAQUE AS CREATE FUNCTION plpgsql_call_handler () RETURNS LANGUAGE_HANDLER AS
'$libdir/plpgsql' LANGUAGE C; '$libdir/plpgsql' LANGUAGE C;
</programlisting> </programlisting>
</para> </para>
......
...@@ -128,13 +128,13 @@ complex_out(Complex *complex) ...@@ -128,13 +128,13 @@ complex_out(Complex *complex)
<function>complex_out</function> before creating the type: <function>complex_out</function> before creating the type:
<programlisting> <programlisting>
CREATE FUNCTION complex_in(opaque) CREATE FUNCTION complex_in(cstring)
RETURNS complex RETURNS complex
AS '<replaceable>PGROOT</replaceable>/tutorial/complex' AS '<replaceable>PGROOT</replaceable>/tutorial/complex'
LANGUAGE C; LANGUAGE C;
CREATE FUNCTION complex_out(opaque) CREATE FUNCTION complex_out(complex)
RETURNS opaque RETURNS cstring
AS '<replaceable>PGROOT</replaceable>/tutorial/complex' AS '<replaceable>PGROOT</replaceable>/tutorial/complex'
LANGUAGE C; LANGUAGE C;
</programlisting> </programlisting>
...@@ -149,6 +149,10 @@ CREATE TYPE complex ( ...@@ -149,6 +149,10 @@ CREATE TYPE complex (
output = complex_out output = complex_out
); );
</programlisting> </programlisting>
Notice that the declarations of the input and output functions must
reference the not-yet-defined type. This is allowed, but will draw
warning messages that may be ignored.
</para> </para>
<para> <para>
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.62 2002/06/20 20:29:24 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.63 2002/08/22 00:01:41 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -17,10 +17,10 @@ ...@@ -17,10 +17,10 @@
#include "access/heapam.h" #include "access/heapam.h"
#include "access/printtup.h" #include "access/printtup.h"
#include "catalog/pg_type.h"
#include "libpq/libpq.h" #include "libpq/libpq.h"
#include "libpq/pqformat.h" #include "libpq/pqformat.h"
#include "utils/syscache.h" #include "utils/lsyscache.h"
static void printtup_setup(DestReceiver *self, int operation, static void printtup_setup(DestReceiver *self, int operation,
const char *portalName, TupleDesc typeinfo); const char *portalName, TupleDesc typeinfo);
...@@ -33,31 +33,6 @@ static void printtup_cleanup(DestReceiver *self); ...@@ -33,31 +33,6 @@ static void printtup_cleanup(DestReceiver *self);
* ---------------------------------------------------------------- * ----------------------------------------------------------------
*/ */
/* ----------------
* getTypeOutputInfo -- get info needed for printing values of a type
* ----------------
*/
bool
getTypeOutputInfo(Oid type, Oid *typOutput, Oid *typElem,
bool *typIsVarlena)
{
HeapTuple typeTuple;
Form_pg_type pt;
typeTuple = SearchSysCache(TYPEOID,
ObjectIdGetDatum(type),
0, 0, 0);
if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "getTypeOutputInfo: Cache lookup of type %u failed", type);
pt = (Form_pg_type) GETSTRUCT(typeTuple);
*typOutput = pt->typoutput;
*typElem = pt->typelem;
*typIsVarlena = (!pt->typbyval) && (pt->typlen == -1);
ReleaseSysCache(typeTuple);
return OidIsValid(*typOutput);
}
/* ---------------- /* ----------------
* Private state for a printtup destination object * Private state for a printtup destination object
* ---------------- * ----------------
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.74 2002/08/07 21:45:01 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.75 2002/08/22 00:01:41 tgl Exp $
* *
* NOTES * NOTES
* See acl.h. * See acl.h.
...@@ -376,7 +376,7 @@ ExecuteGrantStmt_Function(GrantStmt *stmt) ...@@ -376,7 +376,7 @@ ExecuteGrantStmt_Function(GrantStmt *stmt)
char replaces[Natts_pg_proc]; char replaces[Natts_pg_proc];
oid = LookupFuncNameTypeNames(func->funcname, func->funcargs, oid = LookupFuncNameTypeNames(func->funcname, func->funcargs,
true, stmt->is_grant ? "GRANT" : "REVOKE"); stmt->is_grant ? "GRANT" : "REVOKE");
relation = heap_openr(ProcedureRelationName, RowExclusiveLock); relation = heap_openr(ProcedureRelationName, RowExclusiveLock);
tuple = SearchSysCache(PROCOID, tuple = SearchSysCache(PROCOID,
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.53 2002/08/05 03:29:16 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.54 2002/08/22 00:01:41 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -67,13 +67,13 @@ AggregateCreate(const char *aggName, ...@@ -67,13 +67,13 @@ AggregateCreate(const char *aggName,
/* handle transfn */ /* handle transfn */
MemSet(fnArgs, 0, FUNC_MAX_ARGS * sizeof(Oid)); MemSet(fnArgs, 0, FUNC_MAX_ARGS * sizeof(Oid));
fnArgs[0] = aggTransType; fnArgs[0] = aggTransType;
if (OidIsValid(aggBaseType)) if (aggBaseType == ANYOID)
nargs = 1;
else
{ {
fnArgs[1] = aggBaseType; fnArgs[1] = aggBaseType;
nargs = 2; nargs = 2;
} }
else
nargs = 1;
transfn = LookupFuncName(aggtransfnName, nargs, fnArgs); transfn = LookupFuncName(aggtransfnName, nargs, fnArgs);
if (!OidIsValid(transfn)) if (!OidIsValid(transfn))
func_error("AggregateCreate", aggtransfnName, nargs, fnArgs, NULL); func_error("AggregateCreate", aggtransfnName, nargs, fnArgs, NULL);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.75 2002/08/05 03:29:16 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.76 2002/08/22 00:01:41 tgl Exp $
* *
* NOTES * NOTES
* these routines moved here from commands/define.c and somewhat cleaned up. * these routines moved here from commands/define.c and somewhat cleaned up.
...@@ -464,9 +464,9 @@ OperatorCreate(const char *operatorName, ...@@ -464,9 +464,9 @@ OperatorCreate(const char *operatorName,
if (restrictionName) if (restrictionName)
{ {
MemSet(typeId, 0, FUNC_MAX_ARGS * sizeof(Oid)); MemSet(typeId, 0, FUNC_MAX_ARGS * sizeof(Oid));
typeId[0] = 0; /* Query (opaque type) */ typeId[0] = INTERNALOID; /* Query */
typeId[1] = OIDOID; /* operator OID */ typeId[1] = OIDOID; /* operator OID */
typeId[2] = 0; /* args list (opaque type) */ typeId[2] = INTERNALOID; /* args list */
typeId[3] = INT4OID; /* varRelid */ typeId[3] = INT4OID; /* varRelid */
restOid = LookupFuncName(restrictionName, 4, typeId); restOid = LookupFuncName(restrictionName, 4, typeId);
...@@ -482,9 +482,9 @@ OperatorCreate(const char *operatorName, ...@@ -482,9 +482,9 @@ OperatorCreate(const char *operatorName,
if (joinName) if (joinName)
{ {
MemSet(typeId, 0, FUNC_MAX_ARGS * sizeof(Oid)); MemSet(typeId, 0, FUNC_MAX_ARGS * sizeof(Oid));
typeId[0] = 0; /* Query (opaque type) */ typeId[0] = INTERNALOID; /* Query */
typeId[1] = OIDOID; /* operator OID */ typeId[1] = OIDOID; /* operator OID */
typeId[2] = 0; /* args list (opaque type) */ typeId[2] = INTERNALOID; /* args list */
joinOid = LookupFuncName(joinName, 3, typeId); joinOid = LookupFuncName(joinName, 3, typeId);
if (!OidIsValid(joinOid)) if (!OidIsValid(joinOid))
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.88 2002/08/05 03:29:16 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.89 2002/08/22 00:01:41 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -502,7 +502,8 @@ fmgr_internal_validator(PG_FUNCTION_ARGS) ...@@ -502,7 +502,8 @@ fmgr_internal_validator(PG_FUNCTION_ARGS)
elog(ERROR, "there is no built-in function named \"%s\"", prosrc); elog(ERROR, "there is no built-in function named \"%s\"", prosrc);
ReleaseSysCache(tuple); ReleaseSysCache(tuple);
PG_RETURN_BOOL(true);
PG_RETURN_VOID();
} }
...@@ -545,9 +546,9 @@ fmgr_c_validator(PG_FUNCTION_ARGS) ...@@ -545,9 +546,9 @@ fmgr_c_validator(PG_FUNCTION_ARGS)
(void) fetch_finfo_record(libraryhandle, prosrc); (void) fetch_finfo_record(libraryhandle, prosrc);
ReleaseSysCache(tuple); ReleaseSysCache(tuple);
PG_RETURN_BOOL(true);
}
PG_RETURN_VOID();
}
/* /*
...@@ -567,6 +568,7 @@ fmgr_sql_validator(PG_FUNCTION_ARGS) ...@@ -567,6 +568,7 @@ fmgr_sql_validator(PG_FUNCTION_ARGS)
Datum tmp; Datum tmp;
char *prosrc; char *prosrc;
char functyptype; char functyptype;
int i;
tuple = SearchSysCache(PROCOID, funcoid, 0, 0, 0); tuple = SearchSysCache(PROCOID, funcoid, 0, 0, 0);
if (!HeapTupleIsValid(tuple)) if (!HeapTupleIsValid(tuple))
...@@ -574,8 +576,19 @@ fmgr_sql_validator(PG_FUNCTION_ARGS) ...@@ -574,8 +576,19 @@ fmgr_sql_validator(PG_FUNCTION_ARGS)
proc = (Form_pg_proc) GETSTRUCT(tuple); proc = (Form_pg_proc) GETSTRUCT(tuple);
if (!OidIsValid(proc->prorettype)) /* Disallow pseudotypes in arguments and result */
elog(ERROR, "SQL functions cannot return type \"opaque\""); /* except that return type can be RECORD */
if (get_typtype(proc->prorettype) == 'p' &&
proc->prorettype != RECORDOID)
elog(ERROR, "SQL functions cannot return type %s",
format_type_be(proc->prorettype));
for (i = 0; i < proc->pronargs; i++)
{
if (get_typtype(proc->proargtypes[i]) == 'p')
elog(ERROR, "SQL functions cannot have arguments of type %s",
format_type_be(proc->proargtypes[i]));
}
tmp = SysCacheGetAttr(PROCOID, tuple, Anum_pg_proc_prosrc, &isnull); tmp = SysCacheGetAttr(PROCOID, tuple, Anum_pg_proc_prosrc, &isnull);
if (isnull) if (isnull)
...@@ -590,5 +603,6 @@ fmgr_sql_validator(PG_FUNCTION_ARGS) ...@@ -590,5 +603,6 @@ fmgr_sql_validator(PG_FUNCTION_ARGS)
checkretval(proc->prorettype, functyptype, querytree_list); checkretval(proc->prorettype, functyptype, querytree_list);
ReleaseSysCache(tuple); ReleaseSysCache(tuple);
PG_RETURN_BOOL(true);
PG_RETURN_VOID();
} }
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/aggregatecmds.c,v 1.3 2002/07/12 18:43:15 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/aggregatecmds.c,v 1.4 2002/08/22 00:01:41 tgl Exp $
* *
* DESCRIPTION * DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the * The "DefineFoo" routines take the parse tree and pick out the
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "catalog/namespace.h" #include "catalog/namespace.h"
#include "catalog/pg_aggregate.h" #include "catalog/pg_aggregate.h"
#include "catalog/pg_proc.h" #include "catalog/pg_proc.h"
#include "catalog/pg_type.h"
#include "commands/defrem.h" #include "commands/defrem.h"
#include "miscadmin.h" #include "miscadmin.h"
#include "parser/parse_func.h" #include "parser/parse_func.h"
...@@ -104,29 +105,23 @@ DefineAggregate(List *names, List *parameters) ...@@ -104,29 +105,23 @@ DefineAggregate(List *names, List *parameters)
elog(ERROR, "Define: \"sfunc\" unspecified"); elog(ERROR, "Define: \"sfunc\" unspecified");
/* /*
* Handle the aggregate's base type (input data type). This can be * look up the aggregate's base type (input datatype) and transtype.
* specified as 'ANY' for a data-independent transition function, such *
* as COUNT(*). * We have historically allowed the command to look like basetype = 'ANY'
* so we must do a case-insensitive comparison for the name ANY. Ugh.
*
* basetype can be a pseudo-type, but transtype can't, since we need
* to be able to store values of the transtype.
*/ */
baseTypeId = LookupTypeName(baseType); if (strcasecmp(TypeNameToString(baseType), "ANY") == 0)
if (OidIsValid(baseTypeId)) baseTypeId = ANYOID;
{
/* no need to allow aggregates on as-yet-undefined types */
if (!get_typisdefined(baseTypeId))
elog(ERROR, "Type \"%s\" is only a shell",
TypeNameToString(baseType));
}
else else
{ baseTypeId = typenameTypeId(baseType);
char *typnam = TypeNameToString(baseType);
if (strcasecmp(typnam, "ANY") != 0)
elog(ERROR, "Type \"%s\" does not exist", typnam);
baseTypeId = InvalidOid;
}
/* handle transtype --- no special cases here */
transTypeId = typenameTypeId(transType); transTypeId = typenameTypeId(transType);
if (get_typtype(transTypeId) == 'p')
elog(ERROR, "Aggregate transition datatype cannot be %s",
format_type_be(transTypeId));
/* /*
* Most of the argument-checking is done inside of AggregateCreate * Most of the argument-checking is done inside of AggregateCreate
...@@ -159,14 +154,13 @@ RemoveAggregate(RemoveAggrStmt *stmt) ...@@ -159,14 +154,13 @@ RemoveAggregate(RemoveAggrStmt *stmt)
* if a basetype is passed in, then attempt to find an aggregate for * if a basetype is passed in, then attempt to find an aggregate for
* that specific type. * that specific type.
* *
* else if the basetype is blank, then attempt to find an aggregate with * else attempt to find an aggregate with a basetype of ANYOID.
* a basetype of zero. This is valid. It means that the aggregate is * This means that the aggregate is to apply to all basetypes (eg, COUNT).
* to apply to all basetypes (eg, COUNT).
*/ */
if (aggType) if (aggType)
basetypeID = typenameTypeId(aggType); basetypeID = typenameTypeId(aggType);
else else
basetypeID = InvalidOid; basetypeID = ANYOID;
procOid = find_aggregate_func("RemoveAggregate", aggName, basetypeID); procOid = find_aggregate_func("RemoveAggregate", aggName, basetypeID);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Copyright (c) 1996-2001, PostgreSQL Global Development Group * Copyright (c) 1996-2001, PostgreSQL Global Development Group
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/comment.c,v 1.56 2002/08/09 16:45:14 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/comment.c,v 1.57 2002/08/22 00:01:41 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "catalog/pg_operator.h" #include "catalog/pg_operator.h"
#include "catalog/pg_rewrite.h" #include "catalog/pg_rewrite.h"
#include "catalog/pg_trigger.h" #include "catalog/pg_trigger.h"
#include "catalog/pg_type.h"
#include "commands/comment.h" #include "commands/comment.h"
#include "commands/dbcommands.h" #include "commands/dbcommands.h"
#include "miscadmin.h" #include "miscadmin.h"
...@@ -628,7 +629,7 @@ CommentAggregate(List *aggregate, List *arguments, char *comment) ...@@ -628,7 +629,7 @@ CommentAggregate(List *aggregate, List *arguments, char *comment)
if (aggtype) if (aggtype)
baseoid = typenameTypeId(aggtype); baseoid = typenameTypeId(aggtype);
else else
baseoid = InvalidOid; baseoid = ANYOID;
/* Now, attempt to find the actual tuple in pg_proc */ /* Now, attempt to find the actual tuple in pg_proc */
...@@ -661,7 +662,7 @@ CommentProc(List *function, List *arguments, char *comment) ...@@ -661,7 +662,7 @@ CommentProc(List *function, List *arguments, char *comment)
/* Look up the procedure */ /* Look up the procedure */
oid = LookupFuncNameTypeNames(function, arguments, oid = LookupFuncNameTypeNames(function, arguments,
true, "CommentProc"); "CommentProc");
/* Now, validate the user's ability to comment on this function */ /* Now, validate the user's ability to comment on this function */
......
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* *
* conversionmacmds.c * conversioncmds.c
* conversion creation command support code * conversion creation command support code
* *
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/conversioncmds.c,v 1.2 2002/07/25 10:07:11 ishii Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/conversioncmds.c,v 1.3 2002/08/22 00:01:42 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -45,7 +45,7 @@ CreateConversionCommand(CreateConversionStmt *stmt) ...@@ -45,7 +45,7 @@ CreateConversionCommand(CreateConversionStmt *stmt)
const char *to_encoding_name = stmt->to_encoding_name; const char *to_encoding_name = stmt->to_encoding_name;
List *func_name = stmt->func_name; List *func_name = stmt->func_name;
static Oid funcargs[] = {INT4OID, INT4OID, 0, 0, INT4OID}; static Oid funcargs[] = {INT4OID, INT4OID, CSTRINGOID, CSTRINGOID, INT4OID};
/* Convert list of names to a name and namespace */ /* Convert list of names to a name and namespace */
namespaceId = QualifiedNameGetCreationNamespace(stmt->conversion_name, &conversion_name); namespaceId = QualifiedNameGetCreationNamespace(stmt->conversion_name, &conversion_name);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.165 2002/08/19 15:08:46 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.166 2002/08/22 00:01:42 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "utils/acl.h" #include "utils/acl.h"
#include "utils/builtins.h" #include "utils/builtins.h"
#include "utils/relcache.h" #include "utils/relcache.h"
#include "utils/lsyscache.h"
#include "utils/syscache.h" #include "utils/syscache.h"
#ifdef MULTIBYTE #ifdef MULTIBYTE
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/functioncmds.c,v 1.17 2002/08/11 17:44:12 petere Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/functioncmds.c,v 1.18 2002/08/22 00:01:42 tgl Exp $
* *
* DESCRIPTION * DESCRIPTION
* These routines take the parse tree and pick out the * These routines take the parse tree and pick out the
...@@ -61,7 +61,9 @@ ...@@ -61,7 +61,9 @@
* allow a shell type to be used, or even created if the specified return type * allow a shell type to be used, or even created if the specified return type
* doesn't exist yet. (Without this, there's no way to define the I/O procs * doesn't exist yet. (Without this, there's no way to define the I/O procs
* for a new type.) But SQL function creation won't cope, so error out if * for a new type.) But SQL function creation won't cope, so error out if
* the target language is SQL. * the target language is SQL. (We do this here, not in the SQL-function
* validator, so as not to produce a WARNING and then an ERROR for the same
* condition.)
*/ */
static void static void
compute_return_type(TypeName *returnType, Oid languageOid, compute_return_type(TypeName *returnType, Oid languageOid,
...@@ -76,7 +78,8 @@ compute_return_type(TypeName *returnType, Oid languageOid, ...@@ -76,7 +78,8 @@ compute_return_type(TypeName *returnType, Oid languageOid,
if (!get_typisdefined(rettype)) if (!get_typisdefined(rettype))
{ {
if (languageOid == SQLlanguageId) if (languageOid == SQLlanguageId)
elog(ERROR, "SQL functions cannot return shell types"); elog(ERROR, "SQL function cannot return shell type \"%s\"",
TypeNameToString(returnType));
else else
elog(WARNING, "Return type \"%s\" is only a shell", elog(WARNING, "Return type \"%s\" is only a shell",
TypeNameToString(returnType)); TypeNameToString(returnType));
...@@ -85,29 +88,32 @@ compute_return_type(TypeName *returnType, Oid languageOid, ...@@ -85,29 +88,32 @@ compute_return_type(TypeName *returnType, Oid languageOid,
else else
{ {
char *typnam = TypeNameToString(returnType); char *typnam = TypeNameToString(returnType);
Oid namespaceId;
AclResult aclresult;
char *typname;
if (strcmp(typnam, "opaque") == 0) /*
rettype = InvalidOid; * Only C-coded functions can be I/O functions. We enforce this
else * restriction here mainly to prevent littering the catalogs with
{ * shell types due to simple typos in user-defined function
Oid namespaceId; * definitions.
AclResult aclresult; */
char *typname; if (languageOid != INTERNALlanguageId &&
languageOid != ClanguageId)
if (languageOid == SQLlanguageId) elog(ERROR, "Type \"%s\" does not exist", typnam);
elog(ERROR, "Type \"%s\" does not exist", typnam);
elog(WARNING, "ProcedureCreate: type %s is not yet defined", /* Otherwise, go ahead and make a shell type */
typnam); elog(WARNING, "ProcedureCreate: type %s is not yet defined",
namespaceId = QualifiedNameGetCreationNamespace(returnType->names, typnam);
&typname); namespaceId = QualifiedNameGetCreationNamespace(returnType->names,
aclresult = pg_namespace_aclcheck(namespaceId, GetUserId(), &typname);
ACL_CREATE); aclresult = pg_namespace_aclcheck(namespaceId, GetUserId(),
if (aclresult != ACLCHECK_OK) ACL_CREATE);
aclcheck_error(aclresult, get_namespace_name(namespaceId)); if (aclresult != ACLCHECK_OK)
rettype = TypeShellMake(typname, namespaceId); aclcheck_error(aclresult, get_namespace_name(namespaceId));
if (!OidIsValid(rettype)) rettype = TypeShellMake(typname, namespaceId);
elog(ERROR, "could not create type %s", typnam); if (!OidIsValid(rettype))
} elog(ERROR, "could not create type %s", typnam);
} }
*prorettype_p = rettype; *prorettype_p = rettype;
...@@ -138,25 +144,24 @@ compute_parameter_types(List *argTypes, Oid languageOid, ...@@ -138,25 +144,24 @@ compute_parameter_types(List *argTypes, Oid languageOid,
if (OidIsValid(toid)) if (OidIsValid(toid))
{ {
if (!get_typisdefined(toid)) if (!get_typisdefined(toid))
elog(WARNING, "Argument type \"%s\" is only a shell",
TypeNameToString(t));
}
else
{
char *typnam = TypeNameToString(t);
if (strcmp(typnam, "opaque") == 0)
{ {
/* As above, hard error if language is SQL */
if (languageOid == SQLlanguageId) if (languageOid == SQLlanguageId)
elog(ERROR, "SQL functions cannot have arguments of type \"opaque\""); elog(ERROR, "SQL function cannot accept shell type \"%s\"",
toid = InvalidOid; TypeNameToString(t));
else
elog(WARNING, "Argument type \"%s\" is only a shell",
TypeNameToString(t));
} }
else }
elog(ERROR, "Type \"%s\" does not exist", typnam); else
{
elog(ERROR, "Type \"%s\" does not exist",
TypeNameToString(t));
} }
if (t->setof) if (t->setof)
elog(ERROR, "functions cannot accept set arguments"); elog(ERROR, "Functions cannot accept set arguments");
parameterTypes[parameterCount++] = toid; parameterTypes[parameterCount++] = toid;
} }
...@@ -492,7 +497,7 @@ RemoveFunction(RemoveFuncStmt *stmt) ...@@ -492,7 +497,7 @@ RemoveFunction(RemoveFuncStmt *stmt)
* Find the function, do permissions and validity checks * Find the function, do permissions and validity checks
*/ */
funcOid = LookupFuncNameTypeNames(functionName, argTypes, funcOid = LookupFuncNameTypeNames(functionName, argTypes,
true, "RemoveFunction"); "RemoveFunction");
tup = SearchSysCache(PROCOID, tup = SearchSysCache(PROCOID,
ObjectIdGetDatum(funcOid), ObjectIdGetDatum(funcOid),
...@@ -621,6 +626,23 @@ CreateCast(CreateCastStmt *stmt) ...@@ -621,6 +626,23 @@ CreateCast(CreateCastStmt *stmt)
if (sourcetypeid == targettypeid) if (sourcetypeid == targettypeid)
elog(ERROR, "source data type and target data type are the same"); elog(ERROR, "source data type and target data type are the same");
/* No shells, no pseudo-types allowed */
if (!get_typisdefined(sourcetypeid))
elog(ERROR, "source data type %s is only a shell",
TypeNameToString(stmt->sourcetype));
if (!get_typisdefined(targettypeid))
elog(ERROR, "target data type %s is only a shell",
TypeNameToString(stmt->targettype));
if (get_typtype(sourcetypeid) == 'p')
elog(ERROR, "source data type %s is a pseudo-type",
TypeNameToString(stmt->sourcetype));
if (get_typtype(targettypeid) == 'p')
elog(ERROR, "target data type %s is a pseudo-type",
TypeNameToString(stmt->targettype));
if (!pg_type_ownercheck(sourcetypeid, GetUserId()) if (!pg_type_ownercheck(sourcetypeid, GetUserId())
&& !pg_type_ownercheck(targettypeid, GetUserId())) && !pg_type_ownercheck(targettypeid, GetUserId()))
elog(ERROR, "must be owner of type %s or type %s", elog(ERROR, "must be owner of type %s or type %s",
...@@ -642,7 +664,6 @@ CreateCast(CreateCastStmt *stmt) ...@@ -642,7 +664,6 @@ CreateCast(CreateCastStmt *stmt)
{ {
funcid = LookupFuncNameTypeNames(stmt->func->funcname, funcid = LookupFuncNameTypeNames(stmt->func->funcname,
stmt->func->funcargs, stmt->func->funcargs,
false,
"CreateCast"); "CreateCast");
tuple = SearchSysCache(PROCOID, ObjectIdGetDatum(funcid), 0, 0, 0); tuple = SearchSysCache(PROCOID, ObjectIdGetDatum(funcid), 0, 0, 0);
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/opclasscmds.c,v 1.3 2002/08/05 03:29:16 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/opclasscmds.c,v 1.4 2002/08/22 00:01:42 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -177,7 +177,7 @@ DefineOpClass(CreateOpClassStmt *stmt) ...@@ -177,7 +177,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
elog(ERROR, "DefineOpClass: procedure number %d appears more than once", elog(ERROR, "DefineOpClass: procedure number %d appears more than once",
item->number); item->number);
funcOid = LookupFuncNameTypeNames(item->name, item->args, funcOid = LookupFuncNameTypeNames(item->name, item->args,
true, "DefineOpClass"); "DefineOpClass");
/* Caller must have execute permission on functions */ /* Caller must have execute permission on functions */
aclresult = pg_proc_aclcheck(funcOid, GetUserId(), aclresult = pg_proc_aclcheck(funcOid, GetUserId(),
ACL_EXECUTE); ACL_EXECUTE);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/proclang.c,v 1.40 2002/08/13 17:22:08 petere Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/proclang.c,v 1.41 2002/08/22 00:01:42 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -71,17 +71,18 @@ CreateProceduralLanguage(CreatePLangStmt *stmt) ...@@ -71,17 +71,18 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
elog(ERROR, "Language %s already exists", languageName); elog(ERROR, "Language %s already exists", languageName);
/* /*
* Lookup the PL handler function and check that it is of return type * Lookup the PL handler function and check that it is of the expected
* Opaque * return type
*/ */
MemSet(typev, 0, sizeof(typev)); MemSet(typev, 0, sizeof(typev));
procOid = LookupFuncName(stmt->plhandler, 0, typev); procOid = LookupFuncName(stmt->plhandler, 0, typev);
if (!OidIsValid(procOid)) if (!OidIsValid(procOid))
elog(ERROR, "function %s() doesn't exist", elog(ERROR, "function %s() doesn't exist",
NameListToString(stmt->plhandler)); NameListToString(stmt->plhandler));
if (get_func_rettype(procOid) != InvalidOid) if (get_func_rettype(procOid) != LANGUAGE_HANDLEROID)
elog(ERROR, "function %s() does not return type \"opaque\"", elog(ERROR, "function %s() does not return type %s",
NameListToString(stmt->plhandler)); NameListToString(stmt->plhandler),
format_type_be(LANGUAGE_HANDLEROID));
/* validate the validator function */ /* validate the validator function */
if (stmt->plvalidator) if (stmt->plvalidator)
...@@ -91,6 +92,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt) ...@@ -91,6 +92,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
if (!OidIsValid(valProcOid)) if (!OidIsValid(valProcOid))
elog(ERROR, "function %s(oid) doesn't exist", elog(ERROR, "function %s(oid) doesn't exist",
NameListToString(stmt->plvalidator)); NameListToString(stmt->plvalidator));
/* return value is ignored, so we don't check the type */
} }
else else
valProcOid = InvalidOid; valProcOid = InvalidOid;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.127 2002/08/18 11:20:05 petere Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.128 2002/08/22 00:01:42 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "catalog/pg_language.h" #include "catalog/pg_language.h"
#include "catalog/pg_proc.h" #include "catalog/pg_proc.h"
#include "catalog/pg_trigger.h" #include "catalog/pg_trigger.h"
#include "catalog/pg_type.h"
#include "commands/trigger.h" #include "commands/trigger.h"
#include "executor/executor.h" #include "executor/executor.h"
#include "miscadmin.h" #include "miscadmin.h"
...@@ -222,9 +223,15 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint) ...@@ -222,9 +223,15 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint)
if (!HeapTupleIsValid(tuple)) if (!HeapTupleIsValid(tuple))
elog(ERROR, "CreateTrigger: function %s() does not exist", elog(ERROR, "CreateTrigger: function %s() does not exist",
NameListToString(stmt->funcname)); NameListToString(stmt->funcname));
if (((Form_pg_proc) GETSTRUCT(tuple))->prorettype != 0) if (((Form_pg_proc) GETSTRUCT(tuple))->prorettype != TRIGGEROID)
elog(ERROR, "CreateTrigger: function %s() must return OPAQUE", {
NameListToString(stmt->funcname)); /* OPAQUE is deprecated, but allowed for backwards compatibility */
if (((Form_pg_proc) GETSTRUCT(tuple))->prorettype == OPAQUEOID)
elog(NOTICE, "CreateTrigger: OPAQUE is deprecated, use type TRIGGER instead to define trigger functions");
else
elog(ERROR, "CreateTrigger: function %s() must return TRIGGER",
NameListToString(stmt->funcname));
}
ReleaseSysCache(tuple); ReleaseSysCache(tuple);
/* /*
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/typecmds.c,v 1.9 2002/08/15 16:36:02 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/typecmds.c,v 1.10 2002/08/22 00:01:42 tgl Exp $
* *
* DESCRIPTION * DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the * The "DefineFoo" routines take the parse tree and pick out the
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
#include "utils/syscache.h" #include "utils/syscache.h"
static Oid findTypeIOFunction(List *procname, bool isOutput); static Oid findTypeIOFunction(List *procname, Oid typeOid, bool isOutput);
/* /*
* DefineType * DefineType
...@@ -75,6 +75,7 @@ DefineType(List *names, List *parameters) ...@@ -75,6 +75,7 @@ DefineType(List *names, List *parameters)
char *shadow_type; char *shadow_type;
List *pl; List *pl;
Oid typoid; Oid typoid;
Oid resulttype;
/* Convert list of names to a name and namespace */ /* Convert list of names to a name and namespace */
typeNamespace = QualifiedNameGetCreationNamespace(names, &typeName); typeNamespace = QualifiedNameGetCreationNamespace(names, &typeName);
...@@ -116,7 +117,13 @@ DefineType(List *names, List *parameters) ...@@ -116,7 +117,13 @@ DefineType(List *names, List *parameters)
delimiter = p[0]; delimiter = p[0];
} }
else if (strcasecmp(defel->defname, "element") == 0) else if (strcasecmp(defel->defname, "element") == 0)
{
elemType = typenameTypeId(defGetTypeName(defel)); elemType = typenameTypeId(defGetTypeName(defel));
/* disallow arrays of pseudotypes */
if (get_typtype(elemType) == 'p')
elog(ERROR, "Array element type cannot be %s",
format_type_be(elemType));
}
else if (strcasecmp(defel->defname, "default") == 0) else if (strcasecmp(defel->defname, "default") == 0)
defaultValue = defGetString(defel); defaultValue = defGetString(defel);
else if (strcasecmp(defel->defname, "passedbyvalue") == 0) else if (strcasecmp(defel->defname, "passedbyvalue") == 0)
...@@ -179,9 +186,36 @@ DefineType(List *names, List *parameters) ...@@ -179,9 +186,36 @@ DefineType(List *names, List *parameters)
if (outputName == NIL) if (outputName == NIL)
elog(ERROR, "Define: \"output\" unspecified"); elog(ERROR, "Define: \"output\" unspecified");
/* Convert I/O proc names to OIDs */ /*
inputOid = findTypeIOFunction(inputName, false); * Look to see if type already exists (presumably as a shell; if not,
outputOid = findTypeIOFunction(outputName, true); * TypeCreate will complain). If it does then the declarations of the
* I/O functions might use it.
*/
typoid = GetSysCacheOid(TYPENAMENSP,
CStringGetDatum(typeName),
ObjectIdGetDatum(typeNamespace),
0, 0);
/*
* Convert I/O proc names to OIDs
*/
inputOid = findTypeIOFunction(inputName, typoid, false);
outputOid = findTypeIOFunction(outputName, typoid, true);
/*
* Verify that I/O procs return the expected thing. OPAQUE is an allowed
* (but deprecated) alternative to the fully type-safe choices.
*/
resulttype = get_func_rettype(inputOid);
if (!((OidIsValid(typoid) && resulttype == typoid) ||
resulttype == OPAQUEOID))
elog(ERROR, "Type input function %s must return %s or OPAQUE",
NameListToString(inputName), typeName);
resulttype = get_func_rettype(outputOid);
if (!(resulttype == CSTRINGOID ||
resulttype == OPAQUEOID))
elog(ERROR, "Type output function %s must return CSTRING or OPAQUE",
NameListToString(outputName));
/* /*
* now have TypeCreate do all the real work. * now have TypeCreate do all the real work.
...@@ -377,10 +411,9 @@ DefineDomain(CreateDomainStmt *stmt) ...@@ -377,10 +411,9 @@ DefineDomain(CreateDomainStmt *stmt)
basetypeoid = HeapTupleGetOid(typeTup); basetypeoid = HeapTupleGetOid(typeTup);
/* /*
* What we really don't want is domains of domains. This could cause all sorts * Base type must be a plain base type. Domains over pseudo types would
* of neat issues if we allow that. * create a security hole. Domains of domains might be made to work in
* * the future, but not today. Ditto for domains over complex types.
* With testing, we may determine complex types should be allowed
*/ */
typtype = baseType->typtype; typtype = baseType->typtype;
if (typtype != 'b') if (typtype != 'b')
...@@ -621,52 +654,109 @@ RemoveDomain(List *names, DropBehavior behavior) ...@@ -621,52 +654,109 @@ RemoveDomain(List *names, DropBehavior behavior)
/* /*
* Find a suitable I/O function for a type. * Find a suitable I/O function for a type.
*
* typeOid is the type's OID, if it already exists as a shell type,
* otherwise InvalidOid.
*/ */
static Oid static Oid
findTypeIOFunction(List *procname, bool isOutput) findTypeIOFunction(List *procname, Oid typeOid, bool isOutput)
{ {
Oid argList[FUNC_MAX_ARGS]; Oid argList[FUNC_MAX_ARGS];
int nargs;
Oid procOid; Oid procOid;
/* if (isOutput)
* First look for a 1-argument func with all argtypes 0. This is
* valid for all kinds of procedure.
*/
MemSet(argList, 0, FUNC_MAX_ARGS * sizeof(Oid));
procOid = LookupFuncName(procname, 1, argList);
if (!OidIsValid(procOid))
{ {
/* /*
* Alternatively, input procedures may take 3 args (data * Output functions can take a single argument of the type,
* value, element OID, atttypmod); the pg_proc argtype * or two arguments (data value, element OID). The signature
* signature is 0,OIDOID,INT4OID. Output procedures may * may use OPAQUE in place of the actual type name; this is the
* take 2 args (data value, element OID). * only possibility if the type doesn't yet exist as a shell.
*/ */
if (isOutput) if (OidIsValid(typeOid))
{
/* output proc */
nargs = 2;
argList[1] = OIDOID;
}
else
{ {
/* input proc */ MemSet(argList, 0, FUNC_MAX_ARGS * sizeof(Oid));
nargs = 3;
argList[0] = typeOid;
procOid = LookupFuncName(procname, 1, argList);
if (OidIsValid(procOid))
return procOid;
argList[1] = OIDOID; argList[1] = OIDOID;
argList[2] = INT4OID;
procOid = LookupFuncName(procname, 2, argList);
if (OidIsValid(procOid))
return procOid;
} }
procOid = LookupFuncName(procname, nargs, argList);
if (!OidIsValid(procOid)) MemSet(argList, 0, FUNC_MAX_ARGS * sizeof(Oid));
func_error("TypeCreate", procname, 1, argList, NULL);
argList[0] = OPAQUEOID;
procOid = LookupFuncName(procname, 1, argList);
if (OidIsValid(procOid))
return procOid;
argList[1] = OIDOID;
procOid = LookupFuncName(procname, 2, argList);
if (OidIsValid(procOid))
return procOid;
/* Prefer type name over OPAQUE in the failure message. */
if (OidIsValid(typeOid))
argList[0] = typeOid;
func_error("TypeCreate", procname, 1, argList, NULL);
} }
else
{
/*
* Input functions can take a single argument of type CSTRING,
* or three arguments (string, element OID, typmod). The signature
* may use OPAQUE in place of CSTRING.
*/
MemSet(argList, 0, FUNC_MAX_ARGS * sizeof(Oid));
argList[0] = CSTRINGOID;
procOid = LookupFuncName(procname, 1, argList);
if (OidIsValid(procOid))
return procOid;
return procOid; argList[1] = OIDOID;
argList[2] = INT4OID;
procOid = LookupFuncName(procname, 3, argList);
if (OidIsValid(procOid))
return procOid;
MemSet(argList, 0, FUNC_MAX_ARGS * sizeof(Oid));
argList[0] = OPAQUEOID;
procOid = LookupFuncName(procname, 1, argList);
if (OidIsValid(procOid))
return procOid;
argList[1] = OIDOID;
argList[2] = INT4OID;
procOid = LookupFuncName(procname, 3, argList);
if (OidIsValid(procOid))
return procOid;
/* Use CSTRING (preferred) in the error message */
argList[0] = CSTRINGOID;
func_error("TypeCreate", procname, 1, argList, NULL);
}
return InvalidOid; /* keep compiler quiet */
} }
/*------------------------------------------------------------------- /*-------------------------------------------------------------------
* DefineCompositeType * DefineCompositeType
* *
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.79 2002/07/20 05:29:01 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.80 2002/08/22 00:01:42 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -47,7 +47,6 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, ...@@ -47,7 +47,6 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId,
Node *result; Node *result;
if (targetTypeId == inputTypeId || if (targetTypeId == inputTypeId ||
targetTypeId == InvalidOid ||
node == NULL) node == NULL)
{ {
/* no conversion needed, but constraints may need to be applied */ /* no conversion needed, but constraints may need to be applied */
...@@ -97,6 +96,12 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, ...@@ -97,6 +96,12 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId,
if (targetTypeId != baseTypeId) if (targetTypeId != baseTypeId)
result = (Node *) TypeConstraints(result, targetTypeId); result = (Node *) TypeConstraints(result, targetTypeId);
} }
else if (targetTypeId == ANYOID ||
targetTypeId == ANYARRAYOID)
{
/* assume can_coerce_type verified that implicit coercion is okay */
result = node;
}
else if (IsBinaryCompatible(inputTypeId, targetTypeId)) else if (IsBinaryCompatible(inputTypeId, targetTypeId))
{ {
/* /*
...@@ -213,18 +218,10 @@ can_coerce_type(int nargs, Oid *input_typeids, Oid *func_typeids, ...@@ -213,18 +218,10 @@ can_coerce_type(int nargs, Oid *input_typeids, Oid *func_typeids,
if (inputTypeId == targetTypeId) if (inputTypeId == targetTypeId)
continue; continue;
/* /* don't choke on references to no-longer-existing types */
* one of the known-good transparent conversions? then drop if (!typeidIsValid(inputTypeId))
* through...
*/
if (IsBinaryCompatible(inputTypeId, targetTypeId))
continue;
/* don't know what to do for the output type? then quit... */
if (targetTypeId == InvalidOid)
return false; return false;
/* don't know what to do for the input type? then quit... */ if (!typeidIsValid(targetTypeId))
if (inputTypeId == InvalidOid)
return false; return false;
/* /*
...@@ -238,18 +235,44 @@ can_coerce_type(int nargs, Oid *input_typeids, Oid *func_typeids, ...@@ -238,18 +235,44 @@ can_coerce_type(int nargs, Oid *input_typeids, Oid *func_typeids,
continue; continue;
} }
/* accept if target is ANY */
if (targetTypeId == ANYOID)
continue;
/* if target is ANYARRAY and source is a varlena array type, accept */
if (targetTypeId == ANYARRAYOID)
{
Oid typOutput;
Oid typElem;
bool typIsVarlena;
if (getTypeOutputInfo(inputTypeId, &typOutput, &typElem,
&typIsVarlena))
{
if (OidIsValid(typElem) && typIsVarlena)
continue;
}
/*
* Otherwise reject; this assumes there are no explicit coercions
* to ANYARRAY. If we don't reject then parse_coerce would have
* to repeat the above test.
*/
return false;
}
/*
* one of the known-good transparent conversions? then drop
* through...
*/
if (IsBinaryCompatible(inputTypeId, targetTypeId))
continue;
/* /*
* If input is a class type that inherits from target, no problem * If input is a class type that inherits from target, no problem
*/ */
if (typeInheritsFrom(inputTypeId, targetTypeId)) if (typeInheritsFrom(inputTypeId, targetTypeId))
continue; continue;
/* don't choke on references to no-longer-existing types */
if (!typeidIsValid(inputTypeId))
return false;
if (!typeidIsValid(targetTypeId))
return false;
/* /*
* Else, try for run-time conversion using functions: look for a * Else, try for run-time conversion using functions: look for a
* single-argument function named with the target type name and * single-argument function named with the target type name and
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.134 2002/08/08 01:44:30 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.135 2002/08/22 00:01:42 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1264,10 +1264,7 @@ func_error(const char *caller, List *funcname, ...@@ -1264,10 +1264,7 @@ func_error(const char *caller, List *funcname,
{ {
if (i) if (i)
appendStringInfo(&argbuf, ", "); appendStringInfo(&argbuf, ", ");
if (OidIsValid(argtypes[i])) appendStringInfo(&argbuf, format_type_be(argtypes[i]));
appendStringInfo(&argbuf, format_type_be(argtypes[i]));
else
appendStringInfo(&argbuf, "opaque");
} }
if (caller == NULL) if (caller == NULL)
...@@ -1289,7 +1286,7 @@ func_error(const char *caller, List *funcname, ...@@ -1289,7 +1286,7 @@ func_error(const char *caller, List *funcname,
* Convenience routine to check that a function exists and is an * Convenience routine to check that a function exists and is an
* aggregate. * aggregate.
* *
* Note: basetype is InvalidOid if we are looking for an aggregate on * Note: basetype is ANYOID if we are looking for an aggregate on
* all types. * all types.
*/ */
Oid Oid
...@@ -1303,7 +1300,7 @@ find_aggregate_func(const char *caller, List *aggname, Oid basetype) ...@@ -1303,7 +1300,7 @@ find_aggregate_func(const char *caller, List *aggname, Oid basetype)
if (!OidIsValid(oid)) if (!OidIsValid(oid))
{ {
if (basetype == InvalidOid) if (basetype == ANYOID)
elog(ERROR, "%s: aggregate %s(*) does not exist", elog(ERROR, "%s: aggregate %s(*) does not exist",
caller, NameListToString(aggname)); caller, NameListToString(aggname));
else else
...@@ -1322,7 +1319,7 @@ find_aggregate_func(const char *caller, List *aggname, Oid basetype) ...@@ -1322,7 +1319,7 @@ find_aggregate_func(const char *caller, List *aggname, Oid basetype)
if (!pform->proisagg) if (!pform->proisagg)
{ {
if (basetype == InvalidOid) if (basetype == ANYOID)
elog(ERROR, "%s: function %s(*) is not an aggregate", elog(ERROR, "%s: function %s(*) is not an aggregate",
caller, NameListToString(aggname)); caller, NameListToString(aggname));
else else
...@@ -1366,12 +1363,9 @@ LookupFuncName(List *funcname, int nargs, const Oid *argtypes) ...@@ -1366,12 +1363,9 @@ LookupFuncName(List *funcname, int nargs, const Oid *argtypes)
* Like LookupFuncName, but the argument types are specified by a * Like LookupFuncName, but the argument types are specified by a
* list of TypeName nodes. Also, if we fail to find the function * list of TypeName nodes. Also, if we fail to find the function
* and caller is not NULL, then an error is reported via func_error. * and caller is not NULL, then an error is reported via func_error.
*
* "opaque" is accepted as a typename only if opaqueOK is true.
*/ */
Oid Oid
LookupFuncNameTypeNames(List *funcname, List *argtypes, bool opaqueOK, LookupFuncNameTypeNames(List *funcname, List *argtypes, const char *caller)
const char *caller)
{ {
Oid funcoid; Oid funcoid;
Oid argoids[FUNC_MAX_ARGS]; Oid argoids[FUNC_MAX_ARGS];
...@@ -1389,15 +1383,10 @@ LookupFuncNameTypeNames(List *funcname, List *argtypes, bool opaqueOK, ...@@ -1389,15 +1383,10 @@ LookupFuncNameTypeNames(List *funcname, List *argtypes, bool opaqueOK,
TypeName *t = (TypeName *) lfirst(argtypes); TypeName *t = (TypeName *) lfirst(argtypes);
argoids[i] = LookupTypeName(t); argoids[i] = LookupTypeName(t);
if (!OidIsValid(argoids[i]))
{
char *typnam = TypeNameToString(t);
if (opaqueOK && strcmp(typnam, "opaque") == 0) if (!OidIsValid(argoids[i]))
argoids[i] = InvalidOid; elog(ERROR, "Type \"%s\" does not exist",
else TypeNameToString(t));
elog(ERROR, "Type \"%s\" does not exist", typnam);
}
argtypes = lnext(argtypes); argtypes = lnext(argtypes);
} }
......
# #
# Makefile for utils/adt # Makefile for utils/adt
# #
# $Header: /cvsroot/pgsql/src/backend/utils/adt/Makefile,v 1.52 2002/08/17 13:04:15 momjian Exp $ # $Header: /cvsroot/pgsql/src/backend/utils/adt/Makefile,v 1.53 2002/08/22 00:01:43 tgl Exp $
# #
subdir = src/backend/utils/adt subdir = src/backend/utils/adt
...@@ -19,7 +19,7 @@ OBJS = acl.o arrayfuncs.o arrayutils.o bool.o cash.o char.o \ ...@@ -19,7 +19,7 @@ OBJS = acl.o arrayfuncs.o arrayutils.o bool.o cash.o char.o \
date.o datetime.o datum.o float.o format_type.o \ date.o datetime.o datum.o float.o format_type.o \
geo_ops.o geo_selfuncs.o int.o int8.o like.o lockfuncs.o \ geo_ops.o geo_selfuncs.o int.o int8.o like.o lockfuncs.o \
misc.o nabstime.o name.o not_in.o numeric.o numutils.o \ misc.o nabstime.o name.o not_in.o numeric.o numutils.o \
oid.o oracle_compat.o \ oid.o oracle_compat.o pseudotypes.o \
regexp.o regproc.o ruleutils.o selfuncs.o sets.o \ regexp.o regproc.o ruleutils.o selfuncs.o sets.o \
tid.o timestamp.o varbit.o varchar.o varlena.o version.o \ tid.o timestamp.o varbit.o varchar.o varlena.o version.o \
network.o mac.o inet_net_ntop.o inet_net_pton.o \ network.o mac.o inet_net_ntop.o inet_net_pton.o \
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/int.c,v 1.51 2002/06/20 20:29:37 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/int.c,v 1.52 2002/08/22 00:01:43 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -144,59 +144,6 @@ int2vectoreq(PG_FUNCTION_ARGS) ...@@ -144,59 +144,6 @@ int2vectoreq(PG_FUNCTION_ARGS)
PG_RETURN_BOOL(memcmp(arg1, arg2, INDEX_MAX_KEYS * sizeof(int16)) == 0); PG_RETURN_BOOL(memcmp(arg1, arg2, INDEX_MAX_KEYS * sizeof(int16)) == 0);
} }
/*
* Type int44 has no real-world use, but the regression tests use it.
* It's a four-element vector of int4's.
*/
/*
* int44in - converts "num num ..." to internal form
*
* Note: Fills any missing positions with zeroes.
*/
Datum
int44in(PG_FUNCTION_ARGS)
{
char *input_string = PG_GETARG_CSTRING(0);
int32 *result = (int32 *) palloc(4 * sizeof(int32));
int i;
i = sscanf(input_string,
"%d, %d, %d, %d",
&result[0],
&result[1],
&result[2],
&result[3]);
while (i < 4)
result[i++] = 0;
PG_RETURN_POINTER(result);
}
/*
* int44out - converts internal form to "num num ..."
*/
Datum
int44out(PG_FUNCTION_ARGS)
{
int32 *an_array = (int32 *) PG_GETARG_POINTER(0);
char *result = (char *) palloc(16 * 4); /* Allow 14 digits +
* sign */
int i;
char *walk;
walk = result;
for (i = 0; i < 4; i++)
{
pg_ltoa(an_array[i], walk);
while (*++walk != '\0')
;
*walk++ = ' ';
}
*--walk = '\0';
PG_RETURN_CSTRING(result);
}
/***************************************************************************** /*****************************************************************************
* PUBLIC ROUTINES * * PUBLIC ROUTINES *
......
/*-------------------------------------------------------------------------
*
* pseudotypes.c
* Functions for the system pseudo-types.
*
* A pseudo-type isn't really a type and never has any operations, but
* we do need to supply input and output functions to satisfy the links
* in the pseudo-type's entry in pg_type. In most cases the functions
* just throw an error if invoked. (XXX the error messages here cover
* the most common case, but might be confusing in some contexts. Can
* we do better?)
*
*
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/pseudotypes.c,v 1.1 2002/08/22 00:01:43 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "utils/builtins.h"
/*
* record_in - input routine for pseudo-type RECORD.
*/
Datum
record_in(PG_FUNCTION_ARGS)
{
elog(ERROR, "Cannot accept a constant of type %s", "RECORD");
PG_RETURN_VOID(); /* keep compiler quiet */
}
/*
* record_out - output routine for pseudo-type RECORD.
*/
Datum
record_out(PG_FUNCTION_ARGS)
{
elog(ERROR, "Cannot display a value of type %s", "RECORD");
PG_RETURN_VOID(); /* keep compiler quiet */
}
/*
* cstring_in - input routine for pseudo-type CSTRING.
*/
Datum
cstring_in(PG_FUNCTION_ARGS)
{
elog(ERROR, "Cannot accept a constant of type %s", "CSTRING");
PG_RETURN_VOID(); /* keep compiler quiet */
}
/*
* cstring_out - output routine for pseudo-type CSTRING.
*/
Datum
cstring_out(PG_FUNCTION_ARGS)
{
elog(ERROR, "Cannot display a value of type %s", "CSTRING");
PG_RETURN_VOID(); /* keep compiler quiet */
}
/*
* any_in - input routine for pseudo-type ANY.
*/
Datum
any_in(PG_FUNCTION_ARGS)
{
elog(ERROR, "Cannot accept a constant of type %s", "ANY");
PG_RETURN_VOID(); /* keep compiler quiet */
}
/*
* any_out - output routine for pseudo-type ANY.
*/
Datum
any_out(PG_FUNCTION_ARGS)
{
elog(ERROR, "Cannot display a value of type %s", "ANY");
PG_RETURN_VOID(); /* keep compiler quiet */
}
/*
* anyarray_in - input routine for pseudo-type ANYARRAY.
*/
Datum
anyarray_in(PG_FUNCTION_ARGS)
{
elog(ERROR, "Cannot accept a constant of type %s", "ANYARRAY");
PG_RETURN_VOID(); /* keep compiler quiet */
}
/*
* anyarray_out - output routine for pseudo-type ANYARRAY.
*/
Datum
anyarray_out(PG_FUNCTION_ARGS)
{
elog(ERROR, "Cannot display a value of type %s", "ANYARRAY");
PG_RETURN_VOID(); /* keep compiler quiet */
}
/*
* void_in - input routine for pseudo-type VOID.
*
* We allow this so that PL functions can return VOID without any special
* hack in the PL handler. Whatever value the PL thinks it's returning
* will just be ignored.
*/
Datum
void_in(PG_FUNCTION_ARGS)
{
PG_RETURN_VOID(); /* you were expecting something different? */
}
/*
* void_out - output routine for pseudo-type VOID.
*
* We allow this so that "SELECT function_returning_void(...)" works.
*/
Datum
void_out(PG_FUNCTION_ARGS)
{
PG_RETURN_CSTRING(pstrdup(""));
}
/*
* trigger_in - input routine for pseudo-type TRIGGER.
*/
Datum
trigger_in(PG_FUNCTION_ARGS)
{
elog(ERROR, "Cannot accept a constant of type %s", "TRIGGER");
PG_RETURN_VOID(); /* keep compiler quiet */
}
/*
* trigger_out - output routine for pseudo-type TRIGGER.
*/
Datum
trigger_out(PG_FUNCTION_ARGS)
{
elog(ERROR, "Cannot display a value of type %s", "TRIGGER");
PG_RETURN_VOID(); /* keep compiler quiet */
}
/*
* language_handler_in - input routine for pseudo-type LANGUAGE_HANDLER.
*/
Datum
language_handler_in(PG_FUNCTION_ARGS)
{
elog(ERROR, "Cannot accept a constant of type %s", "LANGUAGE_HANDLER");
PG_RETURN_VOID(); /* keep compiler quiet */
}
/*
* language_handler_out - output routine for pseudo-type LANGUAGE_HANDLER.
*/
Datum
language_handler_out(PG_FUNCTION_ARGS)
{
elog(ERROR, "Cannot display a value of type %s", "LANGUAGE_HANDLER");
PG_RETURN_VOID(); /* keep compiler quiet */
}
/*
* internal_in - input routine for pseudo-type INTERNAL.
*/
Datum
internal_in(PG_FUNCTION_ARGS)
{
elog(ERROR, "Cannot accept a constant of type %s", "INTERNAL");
PG_RETURN_VOID(); /* keep compiler quiet */
}
/*
* internal_out - output routine for pseudo-type INTERNAL.
*/
Datum
internal_out(PG_FUNCTION_ARGS)
{
elog(ERROR, "Cannot display a value of type %s", "INTERNAL");
PG_RETURN_VOID(); /* keep compiler quiet */
}
/*
* opaque_in - input routine for pseudo-type OPAQUE.
*/
Datum
opaque_in(PG_FUNCTION_ARGS)
{
elog(ERROR, "Cannot accept a constant of type %s", "OPAQUE");
PG_RETURN_VOID(); /* keep compiler quiet */
}
/*
* opaque_out - output routine for pseudo-type OPAQUE.
*/
Datum
opaque_out(PG_FUNCTION_ARGS)
{
elog(ERROR, "Cannot display a value of type %s", "OPAQUE");
PG_RETURN_VOID(); /* keep compiler quiet */
}
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.72 2002/07/29 22:14:11 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.73 2002/08/22 00:01:43 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
#include "utils/syscache.h" #include "utils/syscache.h"
static void parseNameAndArgTypes(const char *string, const char *caller, static void parseNameAndArgTypes(const char *string, const char *caller,
const char *type0_spelling, bool allowNone,
List **names, int *nargs, Oid *argtypes); List **names, int *nargs, Oid *argtypes);
...@@ -260,7 +260,7 @@ regprocedurein(PG_FUNCTION_ARGS) ...@@ -260,7 +260,7 @@ regprocedurein(PG_FUNCTION_ARGS)
* datatype cannot be used for any system column that needs to receive * datatype cannot be used for any system column that needs to receive
* data during bootstrap. * data during bootstrap.
*/ */
parseNameAndArgTypes(pro_name_or_oid, "regprocedurein", "opaque", parseNameAndArgTypes(pro_name_or_oid, "regprocedurein", false,
&names, &nargs, argtypes); &names, &nargs, argtypes);
clist = FuncnameGetCandidates(names, nargs); clist = FuncnameGetCandidates(names, nargs);
...@@ -325,10 +325,7 @@ format_procedure(Oid procedure_oid) ...@@ -325,10 +325,7 @@ format_procedure(Oid procedure_oid)
if (i > 0) if (i > 0)
appendStringInfoChar(&buf, ','); appendStringInfoChar(&buf, ',');
if (OidIsValid(thisargtype)) appendStringInfo(&buf, "%s", format_type_be(thisargtype));
appendStringInfo(&buf, "%s", format_type_be(thisargtype));
else
appendStringInfo(&buf, "opaque");
} }
appendStringInfoChar(&buf, ')'); appendStringInfoChar(&buf, ')');
...@@ -584,7 +581,7 @@ regoperatorin(PG_FUNCTION_ARGS) ...@@ -584,7 +581,7 @@ regoperatorin(PG_FUNCTION_ARGS)
* datatype cannot be used for any system column that needs to receive * datatype cannot be used for any system column that needs to receive
* data during bootstrap. * data during bootstrap.
*/ */
parseNameAndArgTypes(opr_name_or_oid, "regoperatorin", "none", parseNameAndArgTypes(opr_name_or_oid, "regoperatorin", true,
&names, &nargs, argtypes); &names, &nargs, argtypes);
if (nargs == 1) if (nargs == 1)
elog(ERROR, "regoperatorin: use NONE to denote the missing argument of a unary operator"); elog(ERROR, "regoperatorin: use NONE to denote the missing argument of a unary operator");
...@@ -1036,12 +1033,12 @@ stringToQualifiedNameList(const char *string, const char *caller) ...@@ -1036,12 +1033,12 @@ stringToQualifiedNameList(const char *string, const char *caller)
* the argtypes array should be of size FUNC_MAX_ARGS). The function or * the argtypes array should be of size FUNC_MAX_ARGS). The function or
* operator name is returned to *names as a List of Strings. * operator name is returned to *names as a List of Strings.
* *
* If type0_spelling is not NULL, it is a name to be accepted as a * If allowNone is TRUE, accept "NONE" and return it as InvalidOid (this is
* placeholder for OID 0. * for unary operators).
*/ */
static void static void
parseNameAndArgTypes(const char *string, const char *caller, parseNameAndArgTypes(const char *string, const char *caller,
const char *type0_spelling, bool allowNone,
List **names, int *nargs, Oid *argtypes) List **names, int *nargs, Oid *argtypes)
{ {
char *rawname; char *rawname;
...@@ -1147,9 +1144,9 @@ parseNameAndArgTypes(const char *string, const char *caller, ...@@ -1147,9 +1144,9 @@ parseNameAndArgTypes(const char *string, const char *caller,
*ptr2 = '\0'; *ptr2 = '\0';
} }
if (type0_spelling && strcasecmp(typename, type0_spelling) == 0) if (allowNone && strcasecmp(typename, "none") == 0)
{ {
/* Special case for OPAQUE or NONE */ /* Special case for NONE */
typeid = InvalidOid; typeid = InvalidOid;
typmod = -1; typmod = -1;
} }
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.112 2002/06/20 20:29:38 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.113 2002/08/22 00:01:44 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
* *
* This is represented at the SQL level (in pg_proc) as * This is represented at the SQL level (in pg_proc) as
* *
* float8 oprrest (opaque, oid, opaque, int4); * float8 oprrest (internal, oid, internal, int4);
* *
* The call convention for a join estimator (oprjoin function) is similar * The call convention for a join estimator (oprjoin function) is similar
* except that varRelid is not needed: * except that varRelid is not needed:
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
* Oid operator, * Oid operator,
* List *args); * List *args);
* *
* float8 oprjoin (opaque, oid, opaque); * float8 oprjoin (internal, oid, internal);
*---------- *----------
*/ */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.78 2002/08/05 02:30:50 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.79 2002/08/22 00:01:44 tgl Exp $
* *
* NOTES * NOTES
* Eventually, the index information should go through here, too. * Eventually, the index information should go through here, too.
...@@ -1166,6 +1166,34 @@ get_typtype(Oid typid) ...@@ -1166,6 +1166,34 @@ get_typtype(Oid typid)
return '\0'; return '\0';
} }
/*
* getTypeOutputInfo
*
* Get info needed for printing values of a type
*
* Returns true if data valid (a false result probably means it's a shell type)
*/
bool
getTypeOutputInfo(Oid type, Oid *typOutput, Oid *typElem,
bool *typIsVarlena)
{
HeapTuple typeTuple;
Form_pg_type pt;
typeTuple = SearchSysCache(TYPEOID,
ObjectIdGetDatum(type),
0, 0, 0);
if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "getTypeOutputInfo: Cache lookup of type %u failed", type);
pt = (Form_pg_type) GETSTRUCT(typeTuple);
*typOutput = pt->typoutput;
*typElem = pt->typelem;
*typIsVarlena = (!pt->typbyval) && (pt->typlen == -1);
ReleaseSysCache(typeTuple);
return OidIsValid(*typOutput);
}
/* ---------- STATISTICS CACHE ---------- */ /* ---------- STATISTICS CACHE ---------- */
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# Makefile for utils/mb/conversion_procs # Makefile for utils/mb/conversion_procs
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/Makefile,v 1.4 2002/08/14 02:45:10 ishii Exp $ # $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/Makefile,v 1.5 2002/08/22 00:01:44 tgl Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -153,7 +153,7 @@ $(SQLSCRIPT): Makefile ...@@ -153,7 +153,7 @@ $(SQLSCRIPT): Makefile
func=$$1; shift; \ func=$$1; shift; \
obj=$$1; shift; \ obj=$$1; shift; \
echo "-- $$se --> $$de"; \ echo "-- $$se --> $$de"; \
echo "CREATE OR REPLACE FUNCTION $$func (INTEGER, INTEGER, OPAQUE, OPAQUE, INTEGER) RETURNS INTEGER AS '$$"libdir"/$$obj', '$$func' LANGUAGE 'c';"; \ echo "CREATE OR REPLACE FUNCTION $$func (INTEGER, INTEGER, CSTRING, CSTRING, INTEGER) RETURNS VOID AS '$$"libdir"/$$obj', '$$func' LANGUAGE 'c';"; \
echo "DROP CONVERSION pg_catalog.$$name;"; \ echo "DROP CONVERSION pg_catalog.$$name;"; \
echo "CREATE DEFAULT CONVERSION pg_catalog.$$name FOR '$$se' TO '$$de' FROM $$func;"; \ echo "CREATE DEFAULT CONVERSION pg_catalog.$$name FOR '$$se' TO '$$de' FROM $$func;"; \
done > $@ done > $@
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/ascii_and_mic/ascii_and_mic.c,v 1.1 2002/08/14 02:45:10 ishii Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/ascii_and_mic/ascii_and_mic.c,v 1.2 2002/08/22 00:01:44 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -25,10 +25,10 @@ extern Datum mic_to_ascii(PG_FUNCTION_ARGS); ...@@ -25,10 +25,10 @@ extern Datum mic_to_ascii(PG_FUNCTION_ARGS);
* conv_proc( * conv_proc(
* INTEGER, -- source encoding id * INTEGER, -- source encoding id
* INTEGER, -- destination encoding id * INTEGER, -- destination encoding id
* OPAQUE, -- source string (null terminated C string) * CSTRING, -- source string (null terminated C string)
* OPAQUE, -- destination string (null terminated C string) * CSTRING, -- destination string (null terminated C string)
* INTEGER -- source string length * INTEGER -- source string length
* ) returns INTEGER; -- dummy. returns nothing, actually. * ) returns VOID;
* ---------- * ----------
*/ */
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c,v 1.1 2002/08/14 02:45:10 ishii Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c,v 1.2 2002/08/22 00:01:44 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -63,10 +63,10 @@ extern Datum alt_to_iso(PG_FUNCTION_ARGS); ...@@ -63,10 +63,10 @@ extern Datum alt_to_iso(PG_FUNCTION_ARGS);
* conv_proc( * conv_proc(
* INTEGER, -- source encoding id * INTEGER, -- source encoding id
* INTEGER, -- destination encoding id * INTEGER, -- destination encoding id
* OPAQUE, -- source string (null terminated C string) * CSTRING, -- source string (null terminated C string)
* OPAQUE, -- destination string (null terminated C string) * CSTRING, -- destination string (null terminated C string)
* INTEGER -- source string length * INTEGER -- source string length
* ) returns INTEGER; -- dummy. returns nothing, actually. * ) returns VOID;
* ---------- * ----------
*/ */
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_cn_and_mic/euc_cn_and_mic.c,v 1.1 2002/08/14 02:45:10 ishii Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_cn_and_mic/euc_cn_and_mic.c,v 1.2 2002/08/22 00:01:44 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -25,10 +25,10 @@ extern Datum mic_to_euc_cn(PG_FUNCTION_ARGS); ...@@ -25,10 +25,10 @@ extern Datum mic_to_euc_cn(PG_FUNCTION_ARGS);
* conv_proc( * conv_proc(
* INTEGER, -- source encoding id * INTEGER, -- source encoding id
* INTEGER, -- destination encoding id * INTEGER, -- destination encoding id
* OPAQUE, -- source string (null terminated C string) * CSTRING, -- source string (null terminated C string)
* OPAQUE, -- destination string (null terminated C string) * CSTRING, -- destination string (null terminated C string)
* INTEGER -- source string length * INTEGER -- source string length
* ) returns INTEGER; -- dummy. returns nothing, actually. * ) returns VOID;
* ---------- * ----------
*/ */
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c,v 1.1 2002/07/16 09:25:05 ishii Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c,v 1.2 2002/08/22 00:01:44 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -47,10 +47,10 @@ extern Datum mic_to_sjis(PG_FUNCTION_ARGS); ...@@ -47,10 +47,10 @@ extern Datum mic_to_sjis(PG_FUNCTION_ARGS);
* conv_proc( * conv_proc(
* INTEGER, -- source encoding id * INTEGER, -- source encoding id
* INTEGER, -- destination encoding id * INTEGER, -- destination encoding id
* OPAQUE, -- source string (null terminated C string) * CSTRING, -- source string (null terminated C string)
* OPAQUE, -- destination string (null terminated C string) * CSTRING, -- destination string (null terminated C string)
* INTEGER -- source string length * INTEGER -- source string length
* ) returns INTEGER; -- dummy. returns nothing, actually. * ) returns VOID;
* ---------- * ----------
*/ */
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_kr_and_mic/euc_kr_and_mic.c,v 1.1 2002/08/14 02:45:10 ishii Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_kr_and_mic/euc_kr_and_mic.c,v 1.2 2002/08/22 00:01:44 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -25,10 +25,10 @@ extern Datum mic_to_euc_kr(PG_FUNCTION_ARGS); ...@@ -25,10 +25,10 @@ extern Datum mic_to_euc_kr(PG_FUNCTION_ARGS);
* conv_proc( * conv_proc(
* INTEGER, -- source encoding id * INTEGER, -- source encoding id
* INTEGER, -- destination encoding id * INTEGER, -- destination encoding id
* OPAQUE, -- source string (null terminated C string) * CSTRING, -- source string (null terminated C string)
* OPAQUE, -- destination string (null terminated C string) * CSTRING, -- destination string (null terminated C string)
* INTEGER -- source string length * INTEGER -- source string length
* ) returns INTEGER; -- dummy. returns nothing, actually. * ) returns VOID;
* ---------- * ----------
*/ */
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c,v 1.1 2002/07/16 09:25:05 ishii Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c,v 1.2 2002/08/22 00:01:44 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -35,10 +35,10 @@ extern Datum mic_to_big5(PG_FUNCTION_ARGS); ...@@ -35,10 +35,10 @@ extern Datum mic_to_big5(PG_FUNCTION_ARGS);
* conv_proc( * conv_proc(
* INTEGER, -- source encoding id * INTEGER, -- source encoding id
* INTEGER, -- destination encoding id * INTEGER, -- destination encoding id
* OPAQUE, -- source string (null terminated C string) * CSTRING, -- source string (null terminated C string)
* OPAQUE, -- destination string (null terminated C string) * CSTRING, -- destination string (null terminated C string)
* INTEGER -- source string length * INTEGER -- source string length
* ) returns INTEGER; -- dummy. returns nothing, actually. * ) returns VOID;
* ---------- * ----------
*/ */
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/latin2_and_win1250/latin2_and_win1250.c,v 1.1 2002/08/14 02:45:10 ishii Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/latin2_and_win1250/latin2_and_win1250.c,v 1.2 2002/08/22 00:01:44 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -35,10 +35,10 @@ extern Datum win1250_to_latin2(PG_FUNCTION_ARGS); ...@@ -35,10 +35,10 @@ extern Datum win1250_to_latin2(PG_FUNCTION_ARGS);
* conv_proc( * conv_proc(
* INTEGER, -- source encoding id * INTEGER, -- source encoding id
* INTEGER, -- destination encoding id * INTEGER, -- destination encoding id
* OPAQUE, -- source string (null terminated C string) * CSTRING, -- source string (null terminated C string)
* OPAQUE, -- destination string (null terminated C string) * CSTRING, -- destination string (null terminated C string)
* INTEGER -- source string length * INTEGER -- source string length
* ) returns INTEGER; -- dummy. returns nothing, actually. * ) returns VOID;
* ---------- * ----------
*/ */
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/latin_and_mic/latin_and_mic.c,v 1.1 2002/08/14 02:45:10 ishii Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/latin_and_mic/latin_and_mic.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -33,10 +33,10 @@ extern Datum mic_to_latin4(PG_FUNCTION_ARGS); ...@@ -33,10 +33,10 @@ extern Datum mic_to_latin4(PG_FUNCTION_ARGS);
* conv_proc( * conv_proc(
* INTEGER, -- source encoding id * INTEGER, -- source encoding id
* INTEGER, -- destination encoding id * INTEGER, -- destination encoding id
* OPAQUE, -- source string (null terminated C string) * CSTRING, -- source string (null terminated C string)
* OPAQUE, -- destination string (null terminated C string) * CSTRING, -- destination string (null terminated C string)
* INTEGER -- source string length * INTEGER -- source string length
* ) returns INTEGER; -- dummy. returns nothing, actually. * ) returns VOID;
* ---------- * ----------
*/ */
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_ascii/utf8_and_ascii.c,v 1.1 2002/07/16 09:25:05 ishii Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_ascii/utf8_and_ascii.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -25,10 +25,10 @@ extern Datum utf8_to_ascii(PG_FUNCTION_ARGS); ...@@ -25,10 +25,10 @@ extern Datum utf8_to_ascii(PG_FUNCTION_ARGS);
* conv_proc( * conv_proc(
* INTEGER, -- source encoding id * INTEGER, -- source encoding id
* INTEGER, -- destination encoding id * INTEGER, -- destination encoding id
* OPAQUE, -- source string (null terminated C string) * CSTRING, -- source string (null terminated C string)
* OPAQUE, -- destination string (null terminated C string) * CSTRING, -- destination string (null terminated C string)
* INTEGER -- source string length * INTEGER -- source string length
* ) returns INTEGER; -- dummy. returns nothing, actually. * ) returns VOID;
* ---------- * ----------
*/ */
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_big5/utf8_and_big5.c,v 1.1 2002/07/16 09:25:05 ishii Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_big5/utf8_and_big5.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -27,10 +27,10 @@ extern Datum utf8_to_big5(PG_FUNCTION_ARGS); ...@@ -27,10 +27,10 @@ extern Datum utf8_to_big5(PG_FUNCTION_ARGS);
* conv_proc( * conv_proc(
* INTEGER, -- source encoding id * INTEGER, -- source encoding id
* INTEGER, -- destination encoding id * INTEGER, -- destination encoding id
* OPAQUE, -- source string (null terminated C string) * CSTRING, -- source string (null terminated C string)
* OPAQUE, -- destination string (null terminated C string) * CSTRING, -- destination string (null terminated C string)
* INTEGER -- source string length * INTEGER -- source string length
* ) returns INTEGER; -- dummy. returns nothing, actually. * ) returns VOID;
* ---------- * ----------
*/ */
Datum Datum
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c,v 1.1 2002/08/14 02:45:10 ishii Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -39,10 +39,10 @@ extern Datum alt_to_utf8(PG_FUNCTION_ARGS); ...@@ -39,10 +39,10 @@ extern Datum alt_to_utf8(PG_FUNCTION_ARGS);
* conv_proc( * conv_proc(
* INTEGER, -- source encoding id * INTEGER, -- source encoding id
* INTEGER, -- destination encoding id * INTEGER, -- destination encoding id
* OPAQUE, -- source string (null terminated C string) * CSTRING, -- source string (null terminated C string)
* OPAQUE, -- destination string (null terminated C string) * CSTRING, -- destination string (null terminated C string)
* INTEGER -- source string length * INTEGER -- source string length
* ) returns INTEGER; -- dummy. returns nothing, actually. * ) returns VOID;
* ---------- * ----------
*/ */
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c,v 1.1 2002/07/16 09:25:05 ishii Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -27,10 +27,10 @@ extern Datum utf8_to_euc_cn(PG_FUNCTION_ARGS); ...@@ -27,10 +27,10 @@ extern Datum utf8_to_euc_cn(PG_FUNCTION_ARGS);
* conv_proc( * conv_proc(
* INTEGER, -- source encoding id * INTEGER, -- source encoding id
* INTEGER, -- destination encoding id * INTEGER, -- destination encoding id
* OPAQUE, -- source string (null terminated C string) * CSTRING, -- source string (null terminated C string)
* OPAQUE, -- destination string (null terminated C string) * CSTRING, -- destination string (null terminated C string)
* INTEGER -- source string length * INTEGER -- source string length
* ) returns INTEGER; -- dummy. returns nothing, actually. * ) returns VOID;
* ---------- * ----------
*/ */
Datum Datum
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c,v 1.1 2002/07/16 09:25:05 ishii Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -27,10 +27,10 @@ extern Datum utf8_to_euc_jp(PG_FUNCTION_ARGS); ...@@ -27,10 +27,10 @@ extern Datum utf8_to_euc_jp(PG_FUNCTION_ARGS);
* conv_proc( * conv_proc(
* INTEGER, -- source encoding id * INTEGER, -- source encoding id
* INTEGER, -- destination encoding id * INTEGER, -- destination encoding id
* OPAQUE, -- source string (null terminated C string) * CSTRING, -- source string (null terminated C string)
* OPAQUE, -- destination string (null terminated C string) * CSTRING, -- destination string (null terminated C string)
* INTEGER -- source string length * INTEGER -- source string length
* ) returns INTEGER; -- dummy. returns nothing, actually. * ) returns VOID;
* ---------- * ----------
*/ */
Datum Datum
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c,v 1.1 2002/07/16 09:25:05 ishii Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -27,10 +27,10 @@ extern Datum utf8_to_euc_kr(PG_FUNCTION_ARGS); ...@@ -27,10 +27,10 @@ extern Datum utf8_to_euc_kr(PG_FUNCTION_ARGS);
* conv_proc( * conv_proc(
* INTEGER, -- source encoding id * INTEGER, -- source encoding id
* INTEGER, -- destination encoding id * INTEGER, -- destination encoding id
* OPAQUE, -- source string (null terminated C string) * CSTRING, -- source string (null terminated C string)
* OPAQUE, -- destination string (null terminated C string) * CSTRING, -- destination string (null terminated C string)
* INTEGER -- source string length * INTEGER -- source string length
* ) returns INTEGER; -- dummy. returns nothing, actually. * ) returns VOID;
* ---------- * ----------
*/ */
Datum Datum
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c,v 1.1 2002/07/16 09:25:05 ishii Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -27,10 +27,10 @@ extern Datum utf8_to_euc_tw(PG_FUNCTION_ARGS); ...@@ -27,10 +27,10 @@ extern Datum utf8_to_euc_tw(PG_FUNCTION_ARGS);
* conv_proc( * conv_proc(
* INTEGER, -- source encoding id * INTEGER, -- source encoding id
* INTEGER, -- destination encoding id * INTEGER, -- destination encoding id
* OPAQUE, -- source string (null terminated C string) * CSTRING, -- source string (null terminated C string)
* OPAQUE, -- destination string (null terminated C string) * CSTRING, -- destination string (null terminated C string)
* INTEGER -- source string length * INTEGER -- source string length
* ) returns INTEGER; -- dummy. returns nothing, actually. * ) returns VOID;
* ---------- * ----------
*/ */
Datum Datum
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c,v 1.1 2002/07/16 09:25:05 ishii Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -27,10 +27,10 @@ extern Datum utf8_to_gb18030(PG_FUNCTION_ARGS); ...@@ -27,10 +27,10 @@ extern Datum utf8_to_gb18030(PG_FUNCTION_ARGS);
* conv_proc( * conv_proc(
* INTEGER, -- source encoding id * INTEGER, -- source encoding id
* INTEGER, -- destination encoding id * INTEGER, -- destination encoding id
* OPAQUE, -- source string (null terminated C string) * CSTRING, -- source string (null terminated C string)
* OPAQUE, -- destination string (null terminated C string) * CSTRING, -- destination string (null terminated C string)
* INTEGER -- source string length * INTEGER -- source string length
* ) returns INTEGER; -- dummy. returns nothing, actually. * ) returns VOID;
* ---------- * ----------
*/ */
Datum Datum
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_gbk/utf8_and_gbk.c,v 1.1 2002/07/16 09:25:05 ishii Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_gbk/utf8_and_gbk.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -27,10 +27,10 @@ extern Datum utf8_to_gbk(PG_FUNCTION_ARGS); ...@@ -27,10 +27,10 @@ extern Datum utf8_to_gbk(PG_FUNCTION_ARGS);
* conv_proc( * conv_proc(
* INTEGER, -- source encoding id * INTEGER, -- source encoding id
* INTEGER, -- destination encoding id * INTEGER, -- destination encoding id
* OPAQUE, -- source string (null terminated C string) * CSTRING, -- source string (null terminated C string)
* OPAQUE, -- destination string (null terminated C string) * CSTRING, -- destination string (null terminated C string)
* INTEGER -- source string length * INTEGER -- source string length
* ) returns INTEGER; -- dummy. returns nothing, actually. * ) returns VOID;
* ---------- * ----------
*/ */
Datum Datum
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c,v 1.1 2002/07/16 09:25:05 ishii Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -51,10 +51,10 @@ extern Datum utf8_to_iso8859(PG_FUNCTION_ARGS); ...@@ -51,10 +51,10 @@ extern Datum utf8_to_iso8859(PG_FUNCTION_ARGS);
* conv_proc( * conv_proc(
* INTEGER, -- source encoding id * INTEGER, -- source encoding id
* INTEGER, -- destination encoding id * INTEGER, -- destination encoding id
* OPAQUE, -- source string (null terminated C string) * CSTRING, -- source string (null terminated C string)
* OPAQUE, -- destination string (null terminated C string) * CSTRING, -- destination string (null terminated C string)
* INTEGER -- source string length * INTEGER -- source string length
* ) returns INTEGER; -- dummy. returns nothing, actually. * ) returns VOID;
* ---------- * ----------
*/ */
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859_1/utf8_and_iso8859_1.c,v 1.1 2002/07/16 09:25:05 ishii Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859_1/utf8_and_iso8859_1.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -25,10 +25,10 @@ extern Datum utf8_to_iso8859_1(PG_FUNCTION_ARGS); ...@@ -25,10 +25,10 @@ extern Datum utf8_to_iso8859_1(PG_FUNCTION_ARGS);
* conv_proc( * conv_proc(
* INTEGER, -- source encoding id * INTEGER, -- source encoding id
* INTEGER, -- destination encoding id * INTEGER, -- destination encoding id
* OPAQUE, -- source string (null terminated C string) * CSTRING, -- source string (null terminated C string)
* OPAQUE, -- destination string (null terminated C string) * CSTRING, -- destination string (null terminated C string)
* INTEGER -- source string length * INTEGER -- source string length
* ) returns INTEGER; -- dummy. returns nothing, actually. * ) returns VOID;
* ---------- * ----------
*/ */
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c,v 1.1 2002/07/16 09:25:06 ishii Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -27,10 +27,10 @@ extern Datum utf8_to_johab(PG_FUNCTION_ARGS); ...@@ -27,10 +27,10 @@ extern Datum utf8_to_johab(PG_FUNCTION_ARGS);
* conv_proc( * conv_proc(
* INTEGER, -- source encoding id * INTEGER, -- source encoding id
* INTEGER, -- destination encoding id * INTEGER, -- destination encoding id
* OPAQUE, -- source string (null terminated C string) * CSTRING, -- source string (null terminated C string)
* OPAQUE, -- destination string (null terminated C string) * CSTRING, -- destination string (null terminated C string)
* INTEGER -- source string length * INTEGER -- source string length
* ) returns INTEGER; -- dummy. returns nothing, actually. * ) returns VOID;
* ---------- * ----------
*/ */
Datum Datum
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_sjis/utf8_and_sjis.c,v 1.1 2002/07/16 09:25:06 ishii Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_sjis/utf8_and_sjis.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -27,10 +27,10 @@ extern Datum utf8_to_sjis(PG_FUNCTION_ARGS); ...@@ -27,10 +27,10 @@ extern Datum utf8_to_sjis(PG_FUNCTION_ARGS);
* conv_proc( * conv_proc(
* INTEGER, -- source encoding id * INTEGER, -- source encoding id
* INTEGER, -- destination encoding id * INTEGER, -- destination encoding id
* OPAQUE, -- source string (null terminated C string) * CSTRING, -- source string (null terminated C string)
* OPAQUE, -- destination string (null terminated C string) * CSTRING, -- destination string (null terminated C string)
* INTEGER -- source string length * INTEGER -- source string length
* ) returns INTEGER; -- dummy. returns nothing, actually. * ) returns VOID;
* ---------- * ----------
*/ */
Datum Datum
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_tcvn/Attic/utf8_and_tcvn.c,v 1.1 2002/07/16 09:25:06 ishii Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_tcvn/Attic/utf8_and_tcvn.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -27,10 +27,10 @@ extern Datum utf8_to_tcvn(PG_FUNCTION_ARGS); ...@@ -27,10 +27,10 @@ extern Datum utf8_to_tcvn(PG_FUNCTION_ARGS);
* conv_proc( * conv_proc(
* INTEGER, -- source encoding id * INTEGER, -- source encoding id
* INTEGER, -- destination encoding id * INTEGER, -- destination encoding id
* OPAQUE, -- source string (null terminated C string) * CSTRING, -- source string (null terminated C string)
* OPAQUE, -- destination string (null terminated C string) * CSTRING, -- destination string (null terminated C string)
* INTEGER -- source string length * INTEGER -- source string length
* ) returns INTEGER; -- dummy. returns nothing, actually. * ) returns VOID;
* ---------- * ----------
*/ */
Datum Datum
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_uhc/utf8_and_uhc.c,v 1.1 2002/07/16 09:25:06 ishii Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_uhc/utf8_and_uhc.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -27,10 +27,10 @@ extern Datum utf8_to_uhc(PG_FUNCTION_ARGS); ...@@ -27,10 +27,10 @@ extern Datum utf8_to_uhc(PG_FUNCTION_ARGS);
* conv_proc( * conv_proc(
* INTEGER, -- source encoding id * INTEGER, -- source encoding id
* INTEGER, -- destination encoding id * INTEGER, -- destination encoding id
* OPAQUE, -- source string (null terminated C string) * CSTRING, -- source string (null terminated C string)
* OPAQUE, -- destination string (null terminated C string) * CSTRING, -- destination string (null terminated C string)
* INTEGER -- source string length * INTEGER -- source string length
* ) returns INTEGER; -- dummy. returns nothing, actually. * ) returns VOID;
* ---------- * ----------
*/ */
Datum Datum
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win1250/Attic/utf8_and_win1250.c,v 1.1 2002/08/14 02:45:10 ishii Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win1250/Attic/utf8_and_win1250.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -27,10 +27,10 @@ extern Datum win1250_to_utf(PG_FUNCTION_ARGS); ...@@ -27,10 +27,10 @@ extern Datum win1250_to_utf(PG_FUNCTION_ARGS);
* conv_proc( * conv_proc(
* INTEGER, -- source encoding id * INTEGER, -- source encoding id
* INTEGER, -- destination encoding id * INTEGER, -- destination encoding id
* OPAQUE, -- source string (null terminated C string) * CSTRING, -- source string (null terminated C string)
* OPAQUE, -- destination string (null terminated C string) * CSTRING, -- destination string (null terminated C string)
* INTEGER -- source string length * INTEGER -- source string length
* ) returns INTEGER; -- dummy. returns nothing, actually. * ) returns VOID;
* ---------- * ----------
*/ */
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win1256/Attic/utf8_and_win1256.c,v 1.1 2002/08/14 02:45:10 ishii Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win1256/Attic/utf8_and_win1256.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -27,10 +27,10 @@ extern Datum win1256_to_utf(PG_FUNCTION_ARGS); ...@@ -27,10 +27,10 @@ extern Datum win1256_to_utf(PG_FUNCTION_ARGS);
* conv_proc( * conv_proc(
* INTEGER, -- source encoding id * INTEGER, -- source encoding id
* INTEGER, -- destination encoding id * INTEGER, -- destination encoding id
* OPAQUE, -- source string (null terminated C string) * CSTRING, -- source string (null terminated C string)
* OPAQUE, -- destination string (null terminated C string) * CSTRING, -- destination string (null terminated C string)
* INTEGER -- source string length * INTEGER -- source string length
* ) returns INTEGER; -- dummy. returns nothing, actually. * ) returns VOID;
* ---------- * ----------
*/ */
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win874/Attic/utf8_and_win874.c,v 1.1 2002/08/14 02:45:10 ishii Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win874/Attic/utf8_and_win874.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -27,10 +27,10 @@ extern Datum win874_to_utf(PG_FUNCTION_ARGS); ...@@ -27,10 +27,10 @@ extern Datum win874_to_utf(PG_FUNCTION_ARGS);
* conv_proc( * conv_proc(
* INTEGER, -- source encoding id * INTEGER, -- source encoding id
* INTEGER, -- destination encoding id * INTEGER, -- destination encoding id
* OPAQUE, -- source string (null terminated C string) * CSTRING, -- source string (null terminated C string)
* OPAQUE, -- destination string (null terminated C string) * CSTRING, -- destination string (null terminated C string)
* INTEGER -- source string length * INTEGER -- source string length
* ) returns INTEGER; -- dummy. returns nothing, actually. * ) returns VOID;
* ---------- * ----------
*/ */
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.288 2002/08/20 17:54:44 petere Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.289 2002/08/22 00:01:45 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1899,6 +1899,7 @@ getAggregates(int *numAggs) ...@@ -1899,6 +1899,7 @@ getAggregates(int *numAggs)
write_msg(NULL, "WARNING: owner of aggregate function \"%s\" appears to be invalid\n", write_msg(NULL, "WARNING: owner of aggregate function \"%s\" appears to be invalid\n",
agginfo[i].aggname); agginfo[i].aggname);
agginfo[i].aggacl = strdup(PQgetvalue(res, i, i_aggacl)); agginfo[i].aggacl = strdup(PQgetvalue(res, i, i_aggacl));
agginfo[i].anybasetype = false; /* computed when it's dumped */
agginfo[i].fmtbasetype = NULL; /* computed when it's dumped */ agginfo[i].fmtbasetype = NULL; /* computed when it's dumped */
} }
...@@ -3044,7 +3045,7 @@ dumpOneBaseType(Archive *fout, TypeInfo *tinfo, ...@@ -3044,7 +3045,7 @@ dumpOneBaseType(Archive *fout, TypeInfo *tinfo,
/* DROP must be fully qualified in case same name appears in pg_catalog */ /* DROP must be fully qualified in case same name appears in pg_catalog */
appendPQExpBuffer(delq, "DROP TYPE %s.", appendPQExpBuffer(delq, "DROP TYPE %s.",
fmtId(tinfo->typnamespace->nspname)); fmtId(tinfo->typnamespace->nspname));
appendPQExpBuffer(delq, "%s;\n", appendPQExpBuffer(delq, "%s CASCADE;\n",
fmtId(tinfo->typname)); fmtId(tinfo->typname));
appendPQExpBuffer(q, appendPQExpBuffer(q,
...@@ -4502,7 +4503,6 @@ static char * ...@@ -4502,7 +4503,6 @@ static char *
format_aggregate_signature(AggInfo *agginfo, Archive *fout, bool honor_quotes) format_aggregate_signature(AggInfo *agginfo, Archive *fout, bool honor_quotes)
{ {
PQExpBufferData buf; PQExpBufferData buf;
bool anybasetype;
initPQExpBuffer(&buf); initPQExpBuffer(&buf);
if (honor_quotes) if (honor_quotes)
...@@ -4511,19 +4511,17 @@ format_aggregate_signature(AggInfo *agginfo, Archive *fout, bool honor_quotes) ...@@ -4511,19 +4511,17 @@ format_aggregate_signature(AggInfo *agginfo, Archive *fout, bool honor_quotes)
else else
appendPQExpBuffer(&buf, "%s", agginfo->aggname); appendPQExpBuffer(&buf, "%s", agginfo->aggname);
anybasetype = (strcmp(agginfo->aggbasetype, "0") == 0);
/* If using regtype or format_type, fmtbasetype is already quoted */ /* If using regtype or format_type, fmtbasetype is already quoted */
if (fout->remoteVersion >= 70100) if (fout->remoteVersion >= 70100)
{ {
if (anybasetype) if (agginfo->anybasetype)
appendPQExpBuffer(&buf, "(*)"); appendPQExpBuffer(&buf, "(*)");
else else
appendPQExpBuffer(&buf, "(%s)", agginfo->fmtbasetype); appendPQExpBuffer(&buf, "(%s)", agginfo->fmtbasetype);
} }
else else
{ {
if (anybasetype) if (agginfo->anybasetype)
appendPQExpBuffer(&buf, "(*)"); appendPQExpBuffer(&buf, "(*)");
else else
appendPQExpBuffer(&buf, "(%s)", appendPQExpBuffer(&buf, "(%s)",
...@@ -4568,6 +4566,7 @@ dumpOneAgg(Archive *fout, AggInfo *agginfo) ...@@ -4568,6 +4566,7 @@ dumpOneAgg(Archive *fout, AggInfo *agginfo)
int i_aggfinalfn; int i_aggfinalfn;
int i_aggtranstype; int i_aggtranstype;
int i_agginitval; int i_agginitval;
int i_anybasetype;
int i_fmtbasetype; int i_fmtbasetype;
int i_convertok; int i_convertok;
const char *aggtransfn; const char *aggtransfn;
...@@ -4575,7 +4574,6 @@ dumpOneAgg(Archive *fout, AggInfo *agginfo) ...@@ -4575,7 +4574,6 @@ dumpOneAgg(Archive *fout, AggInfo *agginfo)
const char *aggtranstype; const char *aggtranstype;
const char *agginitval; const char *agginitval;
bool convertok; bool convertok;
bool anybasetype;
/* Make sure we are in proper schema */ /* Make sure we are in proper schema */
selectSourceSchema(agginfo->aggnamespace->nspname); selectSourceSchema(agginfo->aggnamespace->nspname);
...@@ -4586,6 +4584,7 @@ dumpOneAgg(Archive *fout, AggInfo *agginfo) ...@@ -4586,6 +4584,7 @@ dumpOneAgg(Archive *fout, AggInfo *agginfo)
appendPQExpBuffer(query, "SELECT aggtransfn, " appendPQExpBuffer(query, "SELECT aggtransfn, "
"aggfinalfn, aggtranstype::pg_catalog.regtype, " "aggfinalfn, aggtranstype::pg_catalog.regtype, "
"agginitval, " "agginitval, "
"proargtypes[0] = 'pg_catalog.\"any\"'::pg_catalog.regtype as anybasetype, "
"proargtypes[0]::pg_catalog.regtype as fmtbasetype, " "proargtypes[0]::pg_catalog.regtype as fmtbasetype, "
"'t'::boolean as convertok " "'t'::boolean as convertok "
"from pg_catalog.pg_aggregate a, pg_catalog.pg_proc p " "from pg_catalog.pg_aggregate a, pg_catalog.pg_proc p "
...@@ -4598,6 +4597,7 @@ dumpOneAgg(Archive *fout, AggInfo *agginfo) ...@@ -4598,6 +4597,7 @@ dumpOneAgg(Archive *fout, AggInfo *agginfo)
appendPQExpBuffer(query, "SELECT aggtransfn, aggfinalfn, " appendPQExpBuffer(query, "SELECT aggtransfn, aggfinalfn, "
"format_type(aggtranstype, NULL) as aggtranstype, " "format_type(aggtranstype, NULL) as aggtranstype, "
"agginitval, " "agginitval, "
"aggbasetype = 0 as anybasetype, "
"CASE WHEN aggbasetype = 0 THEN '-' " "CASE WHEN aggbasetype = 0 THEN '-' "
"ELSE format_type(aggbasetype, NULL) END as fmtbasetype, " "ELSE format_type(aggbasetype, NULL) END as fmtbasetype, "
"'t'::boolean as convertok " "'t'::boolean as convertok "
...@@ -4611,6 +4611,7 @@ dumpOneAgg(Archive *fout, AggInfo *agginfo) ...@@ -4611,6 +4611,7 @@ dumpOneAgg(Archive *fout, AggInfo *agginfo)
"aggfinalfn, " "aggfinalfn, "
"(select typname from pg_type where oid = aggtranstype1) as aggtranstype, " "(select typname from pg_type where oid = aggtranstype1) as aggtranstype, "
"agginitval1 as agginitval, " "agginitval1 as agginitval, "
"aggbasetype = 0 as anybasetype, "
"(select typname from pg_type where oid = aggbasetype) as fmtbasetype, " "(select typname from pg_type where oid = aggbasetype) as fmtbasetype, "
"(aggtransfn2 = 0 and aggtranstype2 = 0 and agginitval2 is null) as convertok " "(aggtransfn2 = 0 and aggtranstype2 = 0 and agginitval2 is null) as convertok "
"from pg_aggregate " "from pg_aggregate "
...@@ -4640,6 +4641,7 @@ dumpOneAgg(Archive *fout, AggInfo *agginfo) ...@@ -4640,6 +4641,7 @@ dumpOneAgg(Archive *fout, AggInfo *agginfo)
i_aggfinalfn = PQfnumber(res, "aggfinalfn"); i_aggfinalfn = PQfnumber(res, "aggfinalfn");
i_aggtranstype = PQfnumber(res, "aggtranstype"); i_aggtranstype = PQfnumber(res, "aggtranstype");
i_agginitval = PQfnumber(res, "agginitval"); i_agginitval = PQfnumber(res, "agginitval");
i_anybasetype = PQfnumber(res, "anybasetype");
i_fmtbasetype = PQfnumber(res, "fmtbasetype"); i_fmtbasetype = PQfnumber(res, "fmtbasetype");
i_convertok = PQfnumber(res, "convertok"); i_convertok = PQfnumber(res, "convertok");
...@@ -4647,6 +4649,8 @@ dumpOneAgg(Archive *fout, AggInfo *agginfo) ...@@ -4647,6 +4649,8 @@ dumpOneAgg(Archive *fout, AggInfo *agginfo)
aggfinalfn = PQgetvalue(res, 0, i_aggfinalfn); aggfinalfn = PQgetvalue(res, 0, i_aggfinalfn);
aggtranstype = PQgetvalue(res, 0, i_aggtranstype); aggtranstype = PQgetvalue(res, 0, i_aggtranstype);
agginitval = PQgetvalue(res, 0, i_agginitval); agginitval = PQgetvalue(res, 0, i_agginitval);
/* we save anybasetype so that dumpAggACL can use it later */
agginfo->anybasetype = (PQgetvalue(res, 0, i_anybasetype)[0] == 't');
/* we save fmtbasetype so that dumpAggACL can use it later */ /* we save fmtbasetype so that dumpAggACL can use it later */
agginfo->fmtbasetype = strdup(PQgetvalue(res, 0, i_fmtbasetype)); agginfo->fmtbasetype = strdup(PQgetvalue(res, 0, i_fmtbasetype));
convertok = (PQgetvalue(res, 0, i_convertok)[0] == 't'); convertok = (PQgetvalue(res, 0, i_convertok)[0] == 't');
...@@ -4669,13 +4673,12 @@ dumpOneAgg(Archive *fout, AggInfo *agginfo) ...@@ -4669,13 +4673,12 @@ dumpOneAgg(Archive *fout, AggInfo *agginfo)
return; return;
} }
anybasetype = (strcmp(agginfo->aggbasetype, "0") == 0);
if (g_fout->remoteVersion >= 70300) if (g_fout->remoteVersion >= 70300)
{ {
/* If using 7.3's regproc or regtype, data is already quoted */ /* If using 7.3's regproc or regtype, data is already quoted */
appendPQExpBuffer(details, " BASETYPE = %s,\n SFUNC = %s,\n STYPE = %s", appendPQExpBuffer(details, " BASETYPE = %s,\n SFUNC = %s,\n STYPE = %s",
anybasetype ? "'any'" : agginfo->fmtbasetype, agginfo->anybasetype ? "'any'" :
agginfo->fmtbasetype,
aggtransfn, aggtransfn,
aggtranstype); aggtranstype);
} }
...@@ -4683,7 +4686,8 @@ dumpOneAgg(Archive *fout, AggInfo *agginfo) ...@@ -4683,7 +4686,8 @@ dumpOneAgg(Archive *fout, AggInfo *agginfo)
{ {
/* format_type quotes, regproc does not */ /* format_type quotes, regproc does not */
appendPQExpBuffer(details, " BASETYPE = %s,\n SFUNC = %s,\n STYPE = %s", appendPQExpBuffer(details, " BASETYPE = %s,\n SFUNC = %s,\n STYPE = %s",
anybasetype ? "'any'" : agginfo->fmtbasetype, agginfo->anybasetype ? "'any'" :
agginfo->fmtbasetype,
fmtId(aggtransfn), fmtId(aggtransfn),
aggtranstype); aggtranstype);
} }
...@@ -4691,7 +4695,7 @@ dumpOneAgg(Archive *fout, AggInfo *agginfo) ...@@ -4691,7 +4695,7 @@ dumpOneAgg(Archive *fout, AggInfo *agginfo)
{ {
/* need quotes all around */ /* need quotes all around */
appendPQExpBuffer(details, " BASETYPE = %s,\n", appendPQExpBuffer(details, " BASETYPE = %s,\n",
anybasetype ? "'any'" : agginfo->anybasetype ? "'any'" :
fmtId(agginfo->fmtbasetype)); fmtId(agginfo->fmtbasetype));
appendPQExpBuffer(details, " SFUNC = %s,\n", appendPQExpBuffer(details, " SFUNC = %s,\n",
fmtId(aggtransfn)); fmtId(aggtransfn));
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: pg_dump.h,v 1.97 2002/08/19 19:33:35 tgl Exp $ * $Id: pg_dump.h,v 1.98 2002/08/22 00:01:46 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -74,6 +74,7 @@ typedef struct _aggInfo ...@@ -74,6 +74,7 @@ typedef struct _aggInfo
NamespaceInfo *aggnamespace; /* link to containing namespace */ NamespaceInfo *aggnamespace; /* link to containing namespace */
char *usename; char *usename;
char *aggacl; char *aggacl;
bool anybasetype; /* is the basetype "any"? */
char *fmtbasetype; /* formatted type name */ char *fmtbasetype; /* formatted type name */
} AggInfo; } AggInfo;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright 2000-2002 by PostgreSQL Global Development Group * Copyright 2000-2002 by PostgreSQL Global Development Group
* *
* $Header: /cvsroot/pgsql/src/bin/psql/describe.c,v 1.62 2002/08/16 23:01:19 tgl Exp $ * $Header: /cvsroot/pgsql/src/bin/psql/describe.c,v 1.63 2002/08/22 00:01:47 tgl Exp $
*/ */
#include "postgres_fe.h" #include "postgres_fe.h"
#include "describe.h" #include "describe.h"
...@@ -68,13 +68,14 @@ describeAggregates(const char *pattern, bool verbose) ...@@ -68,13 +68,14 @@ describeAggregates(const char *pattern, bool verbose)
/* /*
* There are two kinds of aggregates: ones that work on particular * There are two kinds of aggregates: ones that work on particular
* types and ones that work on all (denoted by input type = 0) * types and ones that work on all (denoted by input type = "any")
*/ */
printfPQExpBuffer(&buf, printfPQExpBuffer(&buf,
"SELECT n.nspname as \"%s\",\n" "SELECT n.nspname as \"%s\",\n"
" p.proname AS \"%s\",\n" " p.proname AS \"%s\",\n"
" CASE p.proargtypes[0]\n" " CASE p.proargtypes[0]\n"
" WHEN 0 THEN CAST('%s' AS pg_catalog.text)\n" " WHEN 'pg_catalog.\"any\"'::pg_catalog.regtype\n"
" THEN CAST('%s' AS pg_catalog.text)\n"
" ELSE pg_catalog.format_type(p.proargtypes[0], NULL)\n" " ELSE pg_catalog.format_type(p.proargtypes[0], NULL)\n"
" END AS \"%s\",\n" " END AS \"%s\",\n"
" pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n"
...@@ -146,12 +147,11 @@ describeFunctions(const char *pattern, bool verbose) ...@@ -146,12 +147,11 @@ describeFunctions(const char *pattern, bool verbose)
"\n LEFT JOIN pg_catalog.pg_user u ON u.usesysid = p.proowner\n"); "\n LEFT JOIN pg_catalog.pg_user u ON u.usesysid = p.proowner\n");
/* /*
* we skip in/out funcs by excluding functions that take some * we skip in/out funcs by excluding functions that take or return cstring
* arguments, but have no types defined for those arguments
*/ */
appendPQExpBuffer(&buf, appendPQExpBuffer(&buf,
"WHERE p.prorettype <> 0\n" "WHERE p.prorettype <> 'pg_catalog.cstring'::pg_catalog.regtype\n"
" AND (p.pronargs = 0 OR pg_catalog.oidvectortypes(p.proargtypes) <> '')\n" " AND p.proargtypes[0] <> 'pg_catalog.cstring'::pg_catalog.regtype\n"
" AND NOT p.proisagg\n"); " AND NOT p.proisagg\n");
processNamePattern(&buf, pattern, true, false, processNamePattern(&buf, pattern, true, false,
...@@ -436,7 +436,10 @@ objectDescription(const char *pattern) ...@@ -436,7 +436,10 @@ objectDescription(const char *pattern)
" CAST('%s' AS pg_catalog.text) as object\n" " CAST('%s' AS pg_catalog.text) as object\n"
" FROM pg_catalog.pg_proc p\n" " FROM pg_catalog.pg_proc p\n"
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n"
" WHERE (p.pronargs = 0 or pg_catalog.oidvectortypes(p.proargtypes) <> '') AND NOT p.proisagg\n",
" WHERE p.prorettype <> 'pg_catalog.cstring'::pg_catalog.regtype\n"
" AND p.proargtypes[0] <> 'pg_catalog.cstring'::pg_catalog.regtype\n"
" AND NOT p.proisagg\n",
_("function")); _("function"));
processNamePattern(&buf, pattern, true, false, processNamePattern(&buf, pattern, true, false,
"n.nspname", "p.proname", NULL, "n.nspname", "p.proname", NULL,
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
# Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group # Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California # Portions Copyright (c) 1994, Regents of the University of California
# #
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createlang.sh,v 1.37 2002/08/10 16:57:32 petere Exp $ # $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createlang.sh,v 1.38 2002/08/22 00:01:47 tgl Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -270,7 +270,7 @@ fi ...@@ -270,7 +270,7 @@ fi
# Create the call handler and the language # Create the call handler and the language
# ---------- # ----------
if [ "$handlerexists" = no ]; then if [ "$handlerexists" = no ]; then
sqlcmd="CREATE FUNCTION \"$handler\" () RETURNS OPAQUE AS '$PGLIB/${object}' LANGUAGE C;" sqlcmd="CREATE FUNCTION \"$handler\" () RETURNS LANGUAGE_HANDLER AS '$PGLIB/${object}' LANGUAGE C;"
if [ "$showsql" = yes ]; then if [ "$showsql" = yes ]; then
echo "$sqlcmd" echo "$sqlcmd"
fi fi
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: printtup.h,v 1.20 2002/06/20 20:29:43 momjian Exp $ * $Id: printtup.h,v 1.21 2002/08/22 00:01:47 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -27,7 +27,4 @@ extern void debugtup(HeapTuple tuple, TupleDesc typeinfo, ...@@ -27,7 +27,4 @@ extern void debugtup(HeapTuple tuple, TupleDesc typeinfo,
extern void spi_printtup(HeapTuple tuple, TupleDesc tupdesc, extern void spi_printtup(HeapTuple tuple, TupleDesc tupdesc,
DestReceiver *self); DestReceiver *self);
extern bool getTypeOutputInfo(Oid type, Oid *typOutput, Oid *typElem,
bool *typIsVarlena);
#endif /* PRINTTUP_H */ #endif /* PRINTTUP_H */
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: catversion.h,v 1.150 2002/08/17 13:04:15 momjian Exp $ * $Id: catversion.h,v 1.151 2002/08/22 00:01:47 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -53,6 +53,6 @@ ...@@ -53,6 +53,6 @@
*/ */
/* yyyymmddN */ /* yyyymmddN */
#define CATALOG_VERSION_NO 200208171 #define CATALOG_VERSION_NO 200208201
#endif #endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment