| PostgreSQL 9.2.4 Documentation | ||||
|---|---|---|---|---|
| Prev | Up | Chapter 42. PL/Python - Python Procedural Language | Next | |
The plpy module also provides the
functions plpy.debug(msg), plpy.log(msg),
plpy.info(msg), plpy.notice(msg),
plpy.warning(msg), plpy.error(msg),
and plpy.fatal(msg). plpy.error and plpy.fatal actually raise a Python exception
which, if uncaught, propagates out to the calling query, causing
the current transaction or subtransaction to be aborted.
raise plpy.Error(msg) and raise
plpy.Fatal(msg) are
equivalent to calling plpy.error
and plpy.fatal, respectively. The
other functions only generate messages of different priority
levels. Whether messages of a particular priority are reported to
the client, written to the server log, or both is controlled by
the log_min_messages
and client_min_messages
configuration variables. See Chapter 18 for more information.
Another set of utility functions are plpy.quote_literal(string), plpy.quote_nullable(string), and plpy.quote_ident(string). They are equivalent to the built-in quoting functions described in Section 9.4. They are useful when constructing ad-hoc queries. A PL/Python equivalent of dynamic SQL from Example 39-1 would be:
plpy.execute("UPDATE tbl SET %s = %s WHERE key = %s" % (
plpy.quote_ident(colname),
plpy.quote_nullable(newvalue),
plpy.quote_literal(keyvalue)))
Please use this form to add your own comments regarding your experience with particular features of PostgreSQL, clarifications of the documentation, or hints for other users. Please note, this is not a support forum, and your IP address will be logged. If you have a question or need help, please see the faq, try a mailing list, or join us on IRC. Note that submissions containing URLs or other keywords commonly found in 'spam' comments may be silently discarded. Please contact the webmaster if you think this is happening to you in error.
Proceed to the comment form.