sortas="PL/Python">in PL/Python>
- When a function is used in a trigger, the dictionary
+ When a function is used as a trigger, the dictionary
TD contains trigger-related values. The trigger
rows are in TD["new"]> and/or TD["old"]>
depending on the trigger event. TD["event"]> contains
STATEMENT>, and UNKNOWN>.
TD["name"]> contains the trigger name, and
TD["relid"]> contains the OID of the table on
- which the trigger occurred. If the trigger was called with
- arguments they are available in TD["args"][0]> to
- TD["args"][(n-1)]>.
+ which the trigger occurred. If the CREATE TRIGGER> command
+ included arguments, they are available in TD["args"][0]> to
+ TD["args"][(n>-1)]>.
this module are available to you in the Python code as
plpy.foo. At present
plpy implements the functions
- plpy.debug("msg"),
- plpy.log("msg"),
- plpy.info("msg"),
- plpy.notice("msg"),
- plpy.warning("msg"),
- plpy.error("msg"), and
- plpy.fatal("msg"). They are mostly equivalent
- to calling elog(LEVEL>, "msg")
+ plpy.debug(msg>),
+ plpy.log(msg>),
+ plpy.info(msg>),
+ plpy.notice(msg>),
+ plpy.warning(msg>),
+ plpy.error(msg>), and
+ plpy.fatal(msg>).
+ These are mostly equivalent to calling
+ elog(level>, msg>)
PL/Python> plpy.error and
plpy.fatal actually raise a Python exception
which, if uncaught, causes the PL/Python module to call
elog(ERROR, msg) when the function handler
- returns from the Python interpreter. Long-jumping out of the
- Python interpreter is probably not good. raise
- plpy.ERROR("msg") and raise
- plpy.FATAL("msg") are equivalent to calling
+ returns from the Python interpreter. raise
+ plpy.ERROR(msg>) and raise
+ plpy.FATAL(msg>) are equivalent to calling
plpy.error and
plpy.fatal, respectively.
The third argument is the limit and is optional.
- In the current version, any database error encountered while
- running a
PL/Python function will result
- in the immediate termination of that function by the server; it is
- not possible to trap error conditions using Python try
- ... catch constructs. For example, a syntax error in an
- SQL statement passed to the plpy.execute call
- will terminate the function. This behavior may be changed in a
- future release.
-
-
When you prepare a plan using the PL/Python module it is
automatically saved. Read the SPI documentation (
* MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.57 2004/09/19 23:38:21 tgl Exp $
+ * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.58 2004/12/17 02:14:48 tgl Exp $
*
*********************************************************************
*/
static PyObject *PLy_result_new(void);
static void PLy_result_dealloc(PyObject *);
static PyObject *PLy_result_getattr(PyObject *, char *);
-
-#ifdef NOT_USED
-/* Appear to be unused */
-static PyObject *PLy_result_fetch(PyObject *, PyObject *);
static PyObject *PLy_result_nrows(PyObject *, PyObject *);
static PyObject *PLy_result_status(PyObject *, PyObject *);
-#endif
static int PLy_result_length(PyObject *);
static PyObject *PLy_result_item(PyObject *, int);
static PyObject *PLy_result_slice(PyObject *, int, int);
};
static PyMethodDef PLy_plan_methods[] = {
- {"status", (PyCFunction) PLy_plan_status, METH_VARARGS, NULL},
+ {"status", PLy_plan_status, METH_VARARGS, NULL},
{NULL, NULL, 0, NULL}
};
PLy_result_doc, /* tp_doc */
};
-#ifdef NOT_USED
-/* Appear to be unused */
static PyMethodDef PLy_result_methods[] = {
- {"fetch", (PyCFunction) PLy_result_fetch, METH_VARARGS, NULL,},
- {"nrows", (PyCFunction) PLy_result_nrows, METH_VARARGS, NULL},
- {"status", (PyCFunction) PLy_result_status, METH_VARARGS, NULL},
+ {"nrows", PLy_result_nrows, METH_VARARGS, NULL},
+ {"status", PLy_result_status, METH_VARARGS, NULL},
{NULL, NULL, 0, NULL}
};
-#endif
static PyMethodDef PLy_methods[] = {
/*
}
static PyObject *
-PLy_result_getattr(PyObject * self, char *attr)
+PLy_result_getattr(PyObject * self, char *name)
{
- return NULL;
-}
-
-#ifdef NOT_USED
-/* Appear to be unused */
-static PyObject *
-PLy_result_fetch(PyObject * self, PyObject * args)
-{
- return NULL;
+ return Py_FindMethod(PLy_result_methods, self, name);
}
static PyObject *
Py_INCREF(ob->status);
return ob->status;
}
-#endif
static int
PLy_result_length(PyObject * arg)