|
1 | 1 | /**********************************************************************
|
2 | 2 | * plpython.c - python as a procedural language for PostgreSQL
|
3 | 3 | *
|
4 |
| - * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.95 2007/02/09 03:35:35 tgl Exp $ |
| 4 | + * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.96 2007/02/21 03:27:32 adunstan Exp $ |
5 | 5 | *
|
6 | 6 | *********************************************************************
|
7 | 7 | */
|
@@ -2309,27 +2309,34 @@ PLy_spi_prepare(PyObject * self, PyObject * args)
|
2309 | 2309 | for (i = 0; i < nargs; i++)
|
2310 | 2310 | {
|
2311 | 2311 | char *sptr;
|
2312 |
| - List *names; |
2313 | 2312 | HeapTuple typeTup;
|
| 2313 | + Oid typeId; |
| 2314 | + int32 typmod; |
2314 | 2315 | Form_pg_type typeStruct;
|
2315 | 2316 |
|
2316 | 2317 | optr = PySequence_GetItem(list, i);
|
2317 | 2318 | if (!PyString_Check(optr))
|
2318 | 2319 | elog(ERROR, "Type names must be strings.");
|
2319 | 2320 | sptr = PyString_AsString(optr);
|
| 2321 | + |
| 2322 | + /******************************************************** |
| 2323 | + * Resolve argument type names and then look them up by |
| 2324 | + * oid in the system cache, and remember the required |
| 2325 | + *information for input conversion. |
| 2326 | + ********************************************************/ |
| 2327 | + |
| 2328 | + parseTypeString(sptr, &typeId, &typmod); |
| 2329 | + |
| 2330 | + typeTup = SearchSysCache(TYPEOID, |
| 2331 | + ObjectIdGetDatum(typeId), |
| 2332 | + 0,0,0); |
| 2333 | + if (!HeapTupleIsValid(typeTup)) |
| 2334 | + elog(ERROR, "cache lookup failed for type %u", typeId); |
2320 | 2335 |
|
2321 |
| - /* |
2322 |
| - * Parse possibly-qualified type name and look it up in |
2323 |
| - * pg_type |
2324 |
| - */ |
2325 |
| - names = stringToQualifiedNameList(sptr, |
2326 |
| - "PLy_spi_prepare"); |
2327 |
| - typeTup = typenameType(NULL, |
2328 |
| - makeTypeNameFromNameList(names)); |
2329 | 2336 | Py_DECREF(optr);
|
2330 | 2337 | optr = NULL; /* this is important */
|
2331 | 2338 |
|
2332 |
| - plan->types[i] = HeapTupleGetOid(typeTup); |
| 2339 | + plan->types[i] = typeId; |
2333 | 2340 | typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
|
2334 | 2341 | if (typeStruct->typtype != 'c')
|
2335 | 2342 | PLy_output_datum_func(&plan->args[i], typeTup);
|
|
0 commit comments