Movatterモバイル変換


[0]ホーム

URL:



Facebook
Postgres Pro
Facebook
Downloads
43.9. Utility Functions
Prev UpChapter 43. PL/Python - Python Procedural LanguageHome Next

43.9. Utility Functions

Theplpy module also provides the functionsplpy.debug(msg),plpy.log(msg),plpy.info(msg),plpy.notice(msg),plpy.warning(msg),plpy.error(msg), andplpy.fatal(msg).plpy.error andplpy.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) andraise plpy.Fatal(msg) are equivalent to callingplpy.error andplpy.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 thelog_min_messages andclient_min_messages configuration variables. SeeChapter 18 for more information.

Another set of utility functions areplpy.quote_literal(string),plpy.quote_nullable(string), andplpy.quote_ident(string). They are equivalent to the built-in quoting functions described inSection 9.4. They are useful when constructing ad-hoc queries. A PL/Python equivalent of dynamic SQL fromExample 40.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)))


Prev Up Next
43.8. Explicit Subtransactions Home 43.10. Environment Variables
epubpdf
Go to PostgreSQL 9.5
By continuing to browse this website, you agree to the use of cookies. Go toPrivacy Policy.

[8]ページ先頭

©2009-2025 Movatter.jp