diff options
| author | Tom Lane | 2002-08-22 00:01:51 +0000 |
|---|---|---|
| committer | Tom Lane | 2002-08-22 00:01:51 +0000 |
| commit | b663f3443ba096a06970214c3e83e79f6e570b84 (patch) | |
| tree | 049e26c1b02535c12bee6e60ba89cf1d42a41a72 /src/pl/tcl | |
| parent | 606c9b9d4fafe9300d039c044edc9727c0ed43c9 (diff) | |
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 ...
Diffstat (limited to 'src/pl/tcl')
| -rw-r--r-- | src/pl/tcl/pltcl.c | 49 | ||||
| -rw-r--r-- | src/pl/tcl/test/test_setup.sql | 8 |
2 files changed, 41 insertions, 16 deletions
diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c index 6f2080b1a43..477dd52d1fd 100644 --- a/src/pl/tcl/pltcl.c +++ b/src/pl/tcl/pltcl.c @@ -31,7 +31,7 @@ * ENHANCEMENTS, OR MODIFICATIONS. * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.59 2002/07/20 05:16:59 momjian Exp $ + * $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.60 2002/08/22 00:01:50 tgl Exp $ * **********************************************************************/ @@ -1051,15 +1051,34 @@ compile_pltcl_function(Oid fn_oid, bool is_trigger) { free(prodesc->proname); free(prodesc); - if (!OidIsValid(procStruct->prorettype)) - elog(ERROR, "pltcl functions cannot return type \"opaque\"" - "\n\texcept when used as triggers"); - else - elog(ERROR, "pltcl: cache lookup for return type %u failed", - procStruct->prorettype); + elog(ERROR, "pltcl: cache lookup for return type %u failed", + procStruct->prorettype); } typeStruct = (Form_pg_type) GETSTRUCT(typeTup); + /* Disallow pseudotype result, except VOID */ + if (typeStruct->typtype == 'p') + { + if (procStruct->prorettype == VOIDOID) + /* okay */; + else if (procStruct->prorettype == TRIGGEROID || + procStruct->prorettype == OPAQUEOID) + { + free(prodesc->proname); + free(prodesc); + elog(ERROR, "pltcl functions cannot return type %s" + "\n\texcept when used as triggers", + format_type_be(procStruct->prorettype)); + } + else + { + free(prodesc->proname); + free(prodesc); + elog(ERROR, "pltcl functions cannot return type %s", + format_type_be(procStruct->prorettype)); + } + } + if (typeStruct->typrelid != InvalidOid) { free(prodesc->proname); @@ -1090,14 +1109,20 @@ compile_pltcl_function(Oid fn_oid, bool is_trigger) { free(prodesc->proname); free(prodesc); - if (!OidIsValid(procStruct->proargtypes[i])) - elog(ERROR, "pltcl functions cannot take type \"opaque\""); - else - elog(ERROR, "pltcl: cache lookup for argument type %u failed", - procStruct->proargtypes[i]); + elog(ERROR, "pltcl: cache lookup for argument type %u failed", + procStruct->proargtypes[i]); } typeStruct = (Form_pg_type) GETSTRUCT(typeTup); + /* Disallow pseudotype argument */ + if (typeStruct->typtype == 'p') + { + free(prodesc->proname); + free(prodesc); + elog(ERROR, "pltcl functions cannot take type %s", + format_type_be(procStruct->proargtypes[i])); + } + if (typeStruct->typrelid != InvalidOid) { prodesc->arg_is_rel[i] = 1; diff --git a/src/pl/tcl/test/test_setup.sql b/src/pl/tcl/test/test_setup.sql index 918e2212696..c7902386f40 100644 --- a/src/pl/tcl/test/test_setup.sql +++ b/src/pl/tcl/test/test_setup.sql @@ -58,7 +58,7 @@ create function check_pkey1_exists(int4, bpchar) returns bool as ' -- -- Trigger function on every change to T_pkey1 -- -create function trig_pkey1_before() returns opaque as ' +create function trig_pkey1_before() returns trigger as ' # # Create prepared plans on the first call # @@ -152,7 +152,7 @@ create trigger pkey1_before before insert or update or delete on T_pkey1 -- Trigger function to check for duplicate keys in T_pkey2 -- and to force key2 to be upper case only without leading whitespaces -- -create function trig_pkey2_before() returns opaque as ' +create function trig_pkey2_before() returns trigger as ' # # Prepare plan on first call # @@ -195,7 +195,7 @@ create trigger pkey2_before before insert or update on T_pkey2 -- in T_pkey2 are done so the trigger for primkey check on T_dta2 -- fired on our updates will see the new key values in T_pkey2. -- -create function trig_pkey2_after() returns opaque as ' +create function trig_pkey2_after() returns trigger as ' # # Prepare plans on first call # @@ -282,7 +282,7 @@ create trigger pkey2_after after update or delete on T_pkey2 -- -- Generic trigger function to check references in T_dta1 and T_dta2 -- -create function check_primkey() returns opaque as ' +create function check_primkey() returns trigger as ' # # For every trigger/relation pair we create # a saved plan and hold them in GD |
