46.9. Utility Functions
The plpy
module also provides the functions
|
|
|
|
|
|
|
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(
msg
)
and plpy.fatal(
msg
)
, respectively but the raise
form does not allow passing keyword arguments. 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 20 for more information.
The msg
argument is given as a positional argument. For backward compatibility, more than one positional argument can be given. In that case, the string representation of the tuple of positional arguments becomes the message reported to the client.
The following keyword-only arguments are accepted:
|
|
|
|
|
|
|
|
The string representation of the objects passed as keyword-only arguments is used to enrich the messages reported to the client. For example:
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 43.1 would be:
Last updated