diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2011-02-22 23:33:44 +0200 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2011-02-22 23:41:23 +0200 |
commit | 1c51c7d5ffd407426f314b2cd317ef77f14efb1f (patch) | |
tree | 86ff75cfeb5801164eb4b3d4f5ce5dba20d8acad /doc/src | |
parent | 3e6b305d9e2a4616bf69e31b0b21ebbb844ba50e (diff) | |
download | postgresql-1c51c7d5ffd407426f314b2cd317ef77f14efb1f.tar.gz postgresql-1c51c7d5ffd407426f314b2cd317ef77f14efb1f.zip |
Add PL/Python functions for quoting strings
Add functions plpy.quote_ident, plpy.quote_literal,
plpy.quote_nullable, which wrap the equivalent SQL functions.
To be able to propagate char * constness properly, make the argument
of quote_literal_cstr() const char *. This also makes it more
consistent with quote_identifier().
Jan UrbaĆski, reviewed by Hitoshi Harada, some refinements by Peter
Eisentraut
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/plpython.sgml | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/doc/src/sgml/plpython.sgml b/doc/src/sgml/plpython.sgml index e05c2937b1f..7c869a8719f 100644 --- a/doc/src/sgml/plpython.sgml +++ b/doc/src/sgml/plpython.sgml @@ -997,6 +997,23 @@ $$ LANGUAGE plpythonu; <xref linkend="guc-client-min-messages"> configuration variables. See <xref linkend="runtime-config"> for more information. </para> + + <para> + Another set of utility functions are + <literal>plpy.quote_literal(<replaceable>string</>)</literal>, + <literal>plpy.quote_nullable(<replaceable>string</>)</literal>, and + <literal>plpy.quote_ident(<replaceable>string</>)</literal>. They + are equivalent to the built-in quoting functions described in <xref + linkend="functions-string">. They are useful when constructing + ad-hoc queries. A PL/Python equivalent of dynamic SQL from <xref + linkend="plpgsql-quote-literal-example"> would be: +<programlisting> +plpy.execute("UPDATE tbl SET %s = %s where key = %s" % ( + plpy.quote_ident(colname), + plpy.quote_nullable(newvalue), + plpy.quote_literal(keyvalue))) +</programlisting> + </para> </sect1> <sect1 id="plpython-envar"> |