Fixed type lookup in spi_prepare for possible qualified
authorJan Wieck
Mon, 29 Sep 2003 19:24:06 +0000 (19:24 +0000)
committerJan Wieck
Mon, 29 Sep 2003 19:24:06 +0000 (19:24 +0000)
type name specification.

Jan

src/pl/tcl/pltcl.c

index d4b0a70a4a712b03d4e857d49599555c2c1da018..c29b4403293acbe216f50c4c0218ac86d2f191dc 100644 (file)
@@ -31,7 +31,7 @@
  *   ENHANCEMENTS, OR MODIFICATIONS.
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.78 2003/09/14 17:25:54 tgl Exp $
+ *   $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.79 2003/09/29 19:24:06 wieck Exp $
  *
  **********************************************************************/
 
@@ -1818,13 +1818,33 @@ pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp,
     ************************************************************/
    for (i = 0; i < nargs; i++)
    {
-       /* XXX should extend this to allow qualified type names */
-       typeTup = typenameType(makeTypeName((char *) args[i]));
+       char           *argcopy;
+       List           *names = NIL;
+       List           *lp;
+       TypeName       *typename;
+
+       /************************************************************
+        * Use SplitIdentifierString() on a copy of the type name,
+        * turn the resulting pointer list into a TypeName node
+        * and call typenameType() to get the pg_type tuple.
+        ************************************************************/
+       argcopy  = pstrdup(args[i]);
+       SplitIdentifierString(argcopy, '.', &names);
+       typename = makeNode(TypeName);
+       foreach (lp, names)
+           typename->names = lappend(typename->names, makeString(lfirst(lp)));
+
+       typeTup = typenameType(typename);
        qdesc->argtypes[i] = HeapTupleGetOid(typeTup);
        perm_fmgr_info(((Form_pg_type) GETSTRUCT(typeTup))->typinput,
                       &(qdesc->arginfuncs[i]));
        qdesc->argtypelems[i] = ((Form_pg_type) GETSTRUCT(typeTup))->typelem;
        ReleaseSysCache(typeTup);
+
+       freeList(typename->names);
+       pfree(typename);
+       freeList(names);
+       pfree(argcopy);
    }
 
    /************************************************************