OSDN Git Service

Improve error message for erroneous use of 'opaque' as plpgsql argument
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 8 Dec 2000 00:03:02 +0000 (00:03 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 8 Dec 2000 00:03:02 +0000 (00:03 +0000)
or return type.

src/pl/plpgsql/src/pl_comp.c

index c0fe596..299a31d 100644 (file)
@@ -3,7 +3,7 @@
  *                       procedural language
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.24 2000/11/16 22:30:50 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.25 2000/12/08 00:03:02 tgl Exp $
  *
  *       This software is copyrighted by Jan Wieck - Hamburg.
  *
@@ -181,8 +181,12 @@ plpgsql_compile(Oid fn_oid, int functype)
                        if (!HeapTupleIsValid(typeTup))
                        {
                                plpgsql_comperrinfo();
-                               elog(ERROR, "cache lookup for return type %u failed",
-                                        procStruct->prorettype);
+                               if (!OidIsValid(procStruct->prorettype))
+                                       elog(ERROR, "plpgsql functions cannot return type \"opaque\""
+                                                "\n\texcept when used as triggers");
+                               else
+                                       elog(ERROR, "cache lookup for return type %u failed",
+                                                procStruct->prorettype);
                        }
                        typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
                        if (typeStruct->typrelid != InvalidOid)
@@ -214,8 +218,11 @@ plpgsql_compile(Oid fn_oid, int functype)
                                if (!HeapTupleIsValid(typeTup))
                                {
                                        plpgsql_comperrinfo();
-                                       elog(ERROR, "cache lookup for argument type %u failed",
-                                                procStruct->proargtypes[i]);
+                                       if (!OidIsValid(procStruct->proargtypes[i]))
+                                               elog(ERROR, "plpgsql functions cannot take type \"opaque\"");
+                                       else
+                                               elog(ERROR, "cache lookup for argument type %u failed",
+                                                        procStruct->proargtypes[i]);
                                }
                                typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
 
@@ -232,7 +239,8 @@ plpgsql_compile(Oid fn_oid, int functype)
                                        if (plpgsql_parse_wordrowtype(buf) != T_ROW)
                                        {
                                                plpgsql_comperrinfo();
-                                               elog(ERROR, "cannot get tuple struct of argument %d", i + 1);
+                                               elog(ERROR, "cannot get tuple struct of argument %d",
+                                                        i + 1);
                                        }
 
                                        row = plpgsql_yylval.row;