From 36f15ddecd82f949496a3541c2208857f10104e4 Mon Sep 17 00:00:00 2001 From: Jan Wieck Date: Mon, 29 Sep 2003 19:24:06 +0000 Subject: [PATCH] Fixed type lookup in spi_prepare for possible qualified type name specification. Jan --- src/pl/tcl/pltcl.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c index d4b0a70a4a..c29b440329 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.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); } /************************************************************ -- 2.40.0