aboutsummaryrefslogtreecommitdiff
path: root/src/pl/plpython/plpython.c
diff options
context:
space:
mode:
authorAndrew Dunstan <andrew@dunslane.net>2007-02-21 03:27:32 +0000
committerAndrew Dunstan <andrew@dunslane.net>2007-02-21 03:27:32 +0000
commitafc7e0d848a756679813c88444ecf9cd5f5f92d4 (patch)
tree466fa3dbacd32d2b8cee19d9b0f3bb0386ef30bd /src/pl/plpython/plpython.c
parent80ab3e0d34dd8918a30a222e909b96b03bd3adeb (diff)
downloadpostgresql-afc7e0d848a756679813c88444ecf9cd5f5f92d4.tar.gz
postgresql-afc7e0d848a756679813c88444ecf9cd5f5f92d4.zip
Allow pltcl args to spi_prepare and plpython args to plpy.prepare to be standard type aliases as well as those known in pg_type. Similar to recent change in plperl.
Diffstat (limited to 'src/pl/plpython/plpython.c')
-rw-r--r--src/pl/plpython/plpython.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/pl/plpython/plpython.c b/src/pl/plpython/plpython.c
index 90a3f87b150..78c9f6c66e0 100644
--- a/src/pl/plpython/plpython.c
+++ b/src/pl/plpython/plpython.c
@@ -1,7 +1,7 @@
/**********************************************************************
* plpython.c - python as a procedural language for PostgreSQL
*
- * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.95 2007/02/09 03:35:35 tgl Exp $
+ * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.96 2007/02/21 03:27:32 adunstan Exp $
*
*********************************************************************
*/
@@ -2309,27 +2309,34 @@ PLy_spi_prepare(PyObject * self, PyObject * args)
for (i = 0; i < nargs; i++)
{
char *sptr;
- List *names;
HeapTuple typeTup;
+ Oid typeId;
+ int32 typmod;
Form_pg_type typeStruct;
optr = PySequence_GetItem(list, i);
if (!PyString_Check(optr))
elog(ERROR, "Type names must be strings.");
sptr = PyString_AsString(optr);
+
+ /********************************************************
+ * Resolve argument type names and then look them up by
+ * oid in the system cache, and remember the required
+ *information for input conversion.
+ ********************************************************/
+
+ parseTypeString(sptr, &typeId, &typmod);
+
+ typeTup = SearchSysCache(TYPEOID,
+ ObjectIdGetDatum(typeId),
+ 0,0,0);
+ if (!HeapTupleIsValid(typeTup))
+ elog(ERROR, "cache lookup failed for type %u", typeId);
- /*
- * Parse possibly-qualified type name and look it up in
- * pg_type
- */
- names = stringToQualifiedNameList(sptr,
- "PLy_spi_prepare");
- typeTup = typenameType(NULL,
- makeTypeNameFromNameList(names));
Py_DECREF(optr);
optr = NULL; /* this is important */
- plan->types[i] = HeapTupleGetOid(typeTup);
+ plan->types[i] = typeId;
typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
if (typeStruct->typtype != 'c')
PLy_output_datum_func(&plan->args[i], typeTup);