Hook up the plpython result-object nrows and status methods correctly.
authorTom Lane
Fri, 17 Dec 2004 02:14:48 +0000 (02:14 +0000)
committerTom Lane
Fri, 17 Dec 2004 02:14:48 +0000 (02:14 +0000)
Adjust documentation to match current reality.

doc/src/sgml/plpython.sgml
src/pl/plpython/plpython.c

index 6655219d3e68db1c8dc46e21e8fcde9251af6574..a3d64bd353e59a16884bb5cfeadee46b3bc71b91 100644 (file)
@@ -1,4 +1,4 @@
-
+
 
 
  PL/Python - Python Procedural Language
@@ -46,7 +46,8 @@
   PL/Python Functions
 
   
-   The Python code you write gets transformed into a Python function.  E.g.,
+   The Python code you write gets transformed into a Python function.
+   For example,
 
 CREATE FUNCTION myfunc(text) RETURNS text
     AS 'return args[0]'
@@ -60,13 +61,14 @@ def __plpython_procedure_myfunc_23456():
         return args[0]
 
 
-   assuming that 23456 is the OID of the function.
+   assuming that 23456 is the OID assigned to the function by
+   PostgreSQL.
   
 
   
    If you do not provide a return value, Python returns the default
-   NoneThe language module translates Python's
-   None into the SQL null
+   NonePL/Python translates
+   Python's None into the SQL null
    value.null value
    sortas="PL/Python">in PL/Python
   
@@ -108,7 +110,7 @@ def __plpython_procedure_myfunc_23456():
   
 
   
-   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
@@ -120,9 +122,9 @@ def __plpython_procedure_myfunc_23456():
    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)].
   
 
   
@@ -143,23 +145,23 @@ def __plpython_procedure_myfunc_23456():
    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)
    from C code.elogin
    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.
   
@@ -210,17 +212,6 @@ rv = plpy.execute(plan, [ "name" ], 5)
    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 (
index 5826ad48c620c10dda02b6d5a1a06b13eba6e61a..5f5b36b0a5062c0bf727da7b98e19a810a871f0c 100644 (file)
@@ -29,7 +29,7 @@
  * 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 $
  *
  *********************************************************************
  */
@@ -1531,13 +1531,8 @@ static PyObject *PLy_plan_status(PyObject *, PyObject *);
 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);
@@ -1582,7 +1577,7 @@ static PyTypeObject PLy_PlanType = {
 };
 
 static PyMethodDef PLy_plan_methods[] = {
-   {"status", (PyCFunction) PLy_plan_status, METH_VARARGS, NULL},
+   {"status", PLy_plan_status, METH_VARARGS, NULL},
    {NULL, NULL, 0, NULL}
 };
 
@@ -1626,15 +1621,11 @@ static PyTypeObject PLy_ResultType = {
    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[] = {
    /*
@@ -1758,17 +1749,9 @@ PLy_result_dealloc(PyObject * arg)
 }
 
 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 *
@@ -1788,7 +1771,6 @@ PLy_result_status(PyObject * self, PyObject * args)
    Py_INCREF(ob->status);
    return ob->status;
 }
-#endif
 
 static int
 PLy_result_length(PyObject * arg)