From d395aecffad7cc6bd043e2d81a1bed5b3fe2f5fa Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 26 Jun 2005 19:16:07 +0000 Subject: Code review for escape-strings patch. Sync psql and plpgsql lexers with main, avoid using a SQL-defined SQLSTATE for what is most definitely not a SQL-compatible error condition, fix documentation omissions, adhere to message style guidelines, don't use two GUC_REPORT variables when one is sufficient. Nothing done about pg_dump issues. --- doc/src/sgml/errcodes.sgml | 7 ++++++- doc/src/sgml/libpq.sgml | 21 ++++++++++++++++----- doc/src/sgml/protocol.sgml | 11 +++++++---- doc/src/sgml/runtime.sgml | 41 +++++++++++++++-------------------------- doc/src/sgml/syntax.sgml | 8 ++++---- 5 files changed, 48 insertions(+), 40 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/errcodes.sgml b/doc/src/sgml/errcodes.sgml index ad556d01516..71b4a8cd406 100644 --- a/doc/src/sgml/errcodes.sgml +++ b/doc/src/sgml/errcodes.sgml @@ -1,4 +1,4 @@ - + <productname>PostgreSQL</productname> Error Codes @@ -370,6 +370,11 @@ INVALID ESCAPE SEQUENCE + +22P06 +NONSTANDARD USE OF ESCAPE CHARACTER + + 22010 INVALID INDICATOR PARAMETER VALUE diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml index 9c1b94e2be7..a5bde7fc76e 100644 --- a/doc/src/sgml/libpq.sgml +++ b/doc/src/sgml/libpq.sgml @@ -1,5 +1,5 @@ @@ -286,7 +286,7 @@ PGconn *PQconnectdb(const char *conninfo); Kerberos service name to use when authenticating with Kerberos 4 or 5. This must match the service name specified in the server configuration for Kerberos authentication to succeed. (See also - .) + .) @@ -888,10 +888,13 @@ Parameters reported as of the current release include is_superuser, session_authorization, DateStyle, -TimeZone, and -integer_datetimes. +TimeZone, +integer_datetimes, and +standard_compliant_strings. (server_encoding, TimeZone, and -integer_datetimes were not reported by releases before 8.0.) +integer_datetimes were not reported by releases before 8.0; +standard_compliant_strings was not reported by releases +before 8.1.) Note that server_version, server_encoding and @@ -913,6 +916,14 @@ see also PQserverVersion, which returns the information in a numeric form that is much easier to compare against. + +If no value for standard_compliant_strings is reported, +applications may assume it is false, that is, backslashes +are treated as escapes in string literals. Also, the presence of this +parameter may be taken as an indication that the escape string syntax +(E'...') is accepted. + + Although the returned pointer is declared const, it in fact points to mutable storage associated with the PGconn structure. diff --git a/doc/src/sgml/protocol.sgml b/doc/src/sgml/protocol.sgml index cd6fa0e94f0..7ebcfc63a34 100644 --- a/doc/src/sgml/protocol.sgml +++ b/doc/src/sgml/protocol.sgml @@ -1,4 +1,4 @@ - + Frontend/Backend Protocol @@ -1072,10 +1072,13 @@ is_superuser, session_authorization, DateStyle, - TimeZone, and - integer_datetimes. + TimeZone, + integer_datetimes, and + standard_compliant_strings. (server_encoding, TimeZone, and - integer_datetimes were not reported by releases before 8.0.) + integer_datetimes were not reported by releases before 8.0; + standard_compliant_strings was not reported by releases + before 8.1.) Note that server_version, server_encoding and diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml index 3841b0dee2d..c0b3e65ba78 100644 --- a/doc/src/sgml/runtime.sgml +++ b/doc/src/sgml/runtime.sgml @@ -1,5 +1,5 @@ @@ -3766,13 +3766,11 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir' When on, a warning is issued if a backslash - (\) appears in a ordinary, non-escape syntax - ('') string. To log the statement that generated the - warning, set log_min_error_statement to - error. The default is off. + (\) appears in an ordinary string literal + ('...' syntax). The default is off. - Escape string syntax (E'') should be used for + Escape string syntax (E'...') should be used for escapes, because in future versions of PostgreSQL ordinary strings will have the standard-compliant behavior of treating backslashes @@ -3988,22 +3986,7 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir' - - escape_string_syntax (boolean) - stringsescape - - escape_string_syntax configuration parameter - - - - Reports whether escape string syntax (E'') is - supported. This variable is used by applications that need to - determine if escape string syntax can be used in their code. - - - - - + standard_compliant_strings (boolean) stringsescape @@ -4011,10 +3994,16 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir' - Reports whether ordinary, non-escape syntax strings - ('') treat backslashes literally, as specified in - the SQL standard. This variable is used by applications that - need to know how ordinary strings are processed`. + Reports whether ordinary string literals + ('...') treat backslashes literally, as specified in + the SQL standard. The value is currently always false, + indicating that backslashes are treated as escapes. It is planned + that this will change to true in a future + PostgreSQL release when string literal + syntax changes to meet the standard. Applications may check this + parameter to determine how string literals will be processed. + The presence of this parameter can also be taken as an indication + that the escape string syntax (E'...') is supported. diff --git a/doc/src/sgml/syntax.sgml b/doc/src/sgml/syntax.sgml index 3d8d457c561..0d3d7f19f18 100644 --- a/doc/src/sgml/syntax.sgml +++ b/doc/src/sgml/syntax.sgml @@ -1,5 +1,5 @@ @@ -249,7 +249,7 @@ UPDATE "my_table" SET "a" = 5; PostgreSQL also allows single quotes to be escaped with a backslash (\'). However, future versions of PostgreSQL will not - support this so applications using this should convert to the + allow this, so applications using backslashes should convert to the standard-compliant method outlined above. @@ -276,8 +276,8 @@ UPDATE "my_table" SET "a" = 5; eventually treat backslashes as literal characters to be standard-compliant. The proper way to specify escape processing is to use the escape string syntax to indicate that escape - processing is desired. Escape string syntax is specified by placing - the the letter E (upper or lower case) before + processing is desired. Escape string syntax is specified by writing + the letter E (upper or lower case) just before the string, e.g. E'\041'. This method will work in all future versions of PostgreSQL. -- cgit v1.2.3