SELECT invalid_type_uncaught('rick');
-WARNING: plpython: in function __plpython_procedure_invalid_type_uncaught_49801:
-plpy.SPIError: Cache lookup for type `test' failed.
+WARNING: plpython: in function invalid_type_uncaught:
+plpy.SPIError: Unknown error in PLy_spi_prepare.
+ERROR: Type "test" does not exist
SELECT invalid_type_caught('rick');
-WARNING: plpython: in function __plpython_procedure_invalid_type_caught_49802:
-plpy.SPIError: Cache lookup for type `test' failed.
+WARNING: plpython: in function invalid_type_caught:
+plpy.SPIError: Unknown error in PLy_spi_prepare.
+ERROR: Type "test" does not exist
SELECT invalid_type_reraised('rick');
-WARNING: plpython: in function __plpython_procedure_invalid_type_reraised_49803:
-plpy.SPIError: Cache lookup for type `test' failed.
+WARNING: plpython: in function invalid_type_reraised:
+plpy.SPIError: Unknown error in PLy_spi_prepare.
+ERROR: Type "test" does not exist
SELECT valid_type('rick');
valid_type
------------
(1 row)
SELECT read_file('/etc/passwd');
-ERROR: plpython: Call of function `__plpython_procedure_read_file_49809' failed.
+ERROR: plpython: Call of function `read_file' failed.
exceptions.IOError: can't open files in restricted mode
SELECT write_file('/tmp/plpython','This is very bad');
-ERROR: plpython: Call of function `__plpython_procedure_write_file_49810' failed.
+ERROR: plpython: Call of function `write_file' failed.
exceptions.IOError: can't open files in restricted mode
SELECT getpid();
-ERROR: plpython: Call of function `__plpython_procedure_getpid_49811' failed.
-exceptions.AttributeError: getpid
+ERROR: plpython: Call of function `getpid' failed.
+exceptions.AttributeError: 'module' object has no attribute 'getpid'
SELECT uname();
-ERROR: plpython: Call of function `__plpython_procedure_uname_49812' failed.
-exceptions.AttributeError: uname
+ERROR: plpython: Call of function `uname' failed.
+exceptions.AttributeError: 'module' object has no attribute 'uname'
SELECT sys_exit();
-ERROR: plpython: Call of function `__plpython_procedure_sys_exit_49813' failed.
-exceptions.AttributeError: exit
+ERROR: plpython: Call of function `sys_exit' failed.
+exceptions.AttributeError: 'module' object has no attribute 'exit'
SELECT sys_argv();
sys_argv
----------------
* MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.27 2002/11/22 16:25:30 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.28 2003/01/31 22:25:13 tgl Exp $
*
*********************************************************************
*/
*/
typedef struct PLyProcedure
{
- char *proname;
+ char *proname; /* SQL name of procedure */
+ char *pyname; /* Python name of procedure */
TransactionId fn_xmin;
CommandId fn_cmin;
PLyTypeInfo result; /* also used to store info for trigger
PLy_procedure_create(FunctionCallInfo fcinfo, bool is_trigger,
HeapTuple procTup, char *key)
{
- char procName[256];
+ char procName[NAMEDATALEN+256];
DECLARE_EXC();
Form_pg_proc procStruct;
elog(FATAL, "plpython: Procedure name would overrun buffer");
proc = PLy_malloc(sizeof(PLyProcedure));
- proc->proname = PLy_malloc(strlen(procName) + 1);
- strcpy(proc->proname, procName);
+ proc->proname = PLy_malloc(strlen(NameStr(procStruct->proname)) + 1);
+ strcpy(proc->proname, NameStr(procStruct->proname));
+ proc->pyname = PLy_malloc(strlen(procName) + 1);
+ strcpy(proc->pyname, procName);
proc->fn_xmin = HeapTupleHeaderGetXmin(procTup->t_data);
proc->fn_cmin = HeapTupleHeaderGetCmin(procTup->t_data);
PLy_typeinfo_init(&proc->result);
/*
* insert the function code into the interpreter
*/
- msrc = PLy_procedure_munge_source(proc->proname, src);
+ msrc = PLy_procedure_munge_source(proc->pyname, src);
crv = PyObject_CallMethod(proc->interp, "r_exec", "s", msrc);
free(msrc);
if ((crv != NULL) && (!PyErr_Occurred()))
{
int clen;
- char call[256];
+ char call[NAMEDATALEN+256];
Py_DECREF(crv);
/*
* compile a call to the function
*/
- clen = snprintf(call, sizeof(call), "%s()", proc->proname);
+ clen = snprintf(call, sizeof(call), "%s()", proc->pyname);
if ((clen < 0) || (clen >= sizeof(call)))
elog(ERROR, "plpython: string would overflow buffer.");
proc->code = Py_CompileString(call, "<string>", Py_eval_input);
Py_XDECREF(proc->me);
if (proc->proname)
PLy_free(proc->proname);
+ if (proc->pyname)
+ PLy_free(proc->pyname);
for (i = 0; i < proc->nargs; i++)
if (proc->args[i].is_rel == 1)
{
}
-/* Get the last procedure name called by the backend ( the innermost,
+/*
+ * Get the last procedure name called by the backend ( the innermost,
* If a plpython procedure call calls the backend and the backend calls
* another plpython procedure )
+ *
+ * NB: this returns SQL name, not the internal Python procedure name
*/
char *
psql -q -e $DBNAME < plpython_error.sql > error.output 2>&1
echo " Done. ***"
-echo -n "*** Checking the results of the feature tests"
-if diff -u feature.expected feature.output > feature.diff 2>&1 ; then
+echo -n "*** Checking the results of the feature tests."
+if diff -c feature.expected feature.output > feature.diff 2>&1 ; then
echo -n " passed!"
else
echo -n " failed! Please examine feature.diff."
echo " Done. ***"
echo -n "*** Checking the results of the error handling tests."
-diff -u error.expected error.output > error.diff 2>&1
+if diff -c error.expected error.output > error.diff 2>&1 ; then
+ echo -n " passed!"
+else
+ echo -n " failed! Please examine error.diff."
+fi
echo " Done. ***"
-echo "*** You need to check the file error.diff and make sure that"
-echo " any differences are due only to the oid encoded in the "
-echo " python function name. ***"
-
-# or write a fancier error checker...