From 1c51c7d5ffd407426f314b2cd317ef77f14efb1f Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Tue, 22 Feb 2011 23:33:44 +0200 Subject: Add PL/Python functions for quoting strings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- doc/src/sgml/plpython.sgml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'doc/src') 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; configuration variables. See 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 . They are useful when constructing + ad-hoc queries. A PL/Python equivalent of dynamic SQL from would be: + +plpy.execute("UPDATE tbl SET %s = %s where key = %s" % ( + plpy.quote_ident(colname), + plpy.quote_nullable(newvalue), + plpy.quote_literal(keyvalue))) + + -- cgit v1.2.3