Add quote_literal(anyelement) to preserve (and, in fact, extend) a
authorTom Lane
Tue, 27 Nov 2007 18:29:11 +0000 (18:29 +0000)
committerTom Lane
Tue, 27 Nov 2007 18:29:11 +0000 (18:29 +0000)
useful consequence of the former liberal implicit casting to text;
namely that you can feed non-string values to quote_literal() and get
unsurprising results.  Per discussion.

doc/src/sgml/func.sgml
src/include/catalog/catversion.h
src/include/catalog/pg_proc.h

index 24b1931caea5bbf6ae397dcc2e6763fc602d1d08..a3baee14489cb9f775e9d7a09d33ecd2bcaff78b 100644 (file)
@@ -1,4 +1,4 @@
-
+
 
  
   Functions and Operators
       
 
       
-       quote_ident(string)
+       quote_ident(string text)
        text
        
         Return the given string suitably quoted to be used as an identifier
       
 
       
-       quote_literal(string)
+       quote_literal(string text)
        text
        
         Return the given string suitably quoted to be used as a string literal
        'O''Reilly'
       
 
+      
+       quote_literal(value anyelement)
+       text
+       
+        Coerce the given value to text and then quote it as a literal.
+        Embedded single-quotes and backslashes are properly doubled.
+       
+       quote_literal(42.5)
+       '42.5'
+      
+
       
        regexp_matches(string textpattern text [, flags text])
        setof text[]
index 036d004b555b3e1d3e4ff408befe8dee81def040..345ce3bced4d13962b9fe28ecb12d61f1666dfb5 100644 (file)
@@ -37,7 +37,7 @@
  * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.438 2007/11/27 12:21:05 petere Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.439 2007/11/27 18:29:11 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -53,6 +53,6 @@
  */
 
 /*                         yyyymmddN */
-#define CATALOG_VERSION_NO 200711271
+#define CATALOG_VERSION_NO 200711272
 
 #endif
index 1472437f715fd934b5a76dbf7c7cbf44ede84581..424a8bd2a8e1f6edc9ea4a99935a3bc5a5837f3a 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.479 2007/11/27 12:21:05 petere Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.480 2007/11/27 18:29:11 tgl Exp $
  *
  * NOTES
  *   The script catalog/genbki.sh reads this file and generates .bki
@@ -2631,6 +2631,8 @@ DATA(insert OID =  1282 ( quote_ident    PGNSP PGUID 12 1 0 f f t f i 1 25 "25"
 DESCR("quote an identifier for usage in a querystring");
 DATA(insert OID =  1283 ( quote_literal    PGNSP PGUID 12 1 0 f f t f i 1 25 "25" _null_ _null_ _null_ quote_literal - _null_ _null_ ));
 DESCR("quote a literal for usage in a querystring");
+DATA(insert OID =  1285 ( quote_literal    PGNSP PGUID 14 1 0 f f t f v 1 25 "2283" _null_ _null_ _null_ "select pg_catalog.quote_literal($1::pg_catalog.text)" - _null_ _null_ ));
+DESCR("quote a data value for usage in a querystring");
 
 DATA(insert OID = 1798 (  oidin               PGNSP PGUID 12 1 0 f f t f i 1 26 "2275" _null_ _null_ _null_ oidin - _null_ _null_ ));
 DESCR("I/O");