Change \' to '', for SQL standards compliance. Backpatch to 7.3, 7.4,

and 8.0.  Later releases already patched.
This commit is contained in:
Bruce Momjian 2006-05-21 19:56:41 +00:00
parent 506747337b
commit 583a472f7b
14 changed files with 55 additions and 55 deletions

View File

@ -33,7 +33,7 @@
#
#
##############################################################################
# $Id: DBMirror.pl,v 1.3.2.2 2002/12/05 21:04:14 momjian Exp $
# $Id: DBMirror.pl,v 1.3.2.3 2006/05/21 19:56:40 momjian Exp $
#
##############################################################################
@ -412,7 +412,7 @@ sub mirrorInsert($$$$$) {
if(defined $recordValues{$column}) {
my $quotedValue = $recordValues{$column};
$quotedValue =~ s/\\/\\\\/g;
$quotedValue =~ s/'/\\'/g;
$quotedValue =~ s/'/''/g;
$valuesQuery .= "'$quotedValue'";
}
else {
@ -595,7 +595,7 @@ sub mirrorUpdate($$$$$) {
if(defined $currentValue ) {
$quotedValue = $currentValue;
$quotedValue =~ s/\\/\\\\/g;
$quotedValue =~ s/'/\\'/g;
$quotedValue =~ s/'/''/g;
$updateQuery .= "'$quotedValue'";
}
else {
@ -617,7 +617,7 @@ sub mirrorUpdate($$$$$) {
if(defined $currentValue) {
$quotedValue = $currentValue;
$quotedValue =~ s/\\/\\\\/g;
$quotedValue =~ s/'/\\'/g;
$quotedValue =~ s/'/''/g;
$updateQuery .= "'$quotedValue'";
}
else {

View File

@ -1,6 +1,6 @@
/****************************************************************************
* pending.c
* $Id: pending.c,v 1.6.2.5 2003/03/20 03:58:48 momjian Exp $
* $Id: pending.c,v 1.6.2.6 2006/05/21 19:56:40 momjian Exp $
*
* This file contains a trigger for Postgresql-7.x to record changes to tables
* to a pending table for mirroring.
@ -478,7 +478,7 @@ packageData(HeapTuple tTupleData, TupleDesc tTupleDesc,
}
if (*cpUnFormatedPtr == '\\' || *cpUnFormatedPtr == '\'')
{
*cpFormatedPtr = '\\';
*cpFormatedPtr = *cpUnFormatedPtr;
cpFormatedPtr++;
iUsedDataBlock++;
}

View File

@ -42,31 +42,31 @@ SELECT '1 2'::txtidx;
'1' '2'
(1 row)
SELECT '\'1 2\''::txtidx;
SELECT '''1 2'''::txtidx;
txtidx
--------
'1 2'
(1 row)
SELECT '\'1 \\\'2\''::txtidx;
SELECT '''1 \\''2'''::txtidx;
txtidx
---------
'1 \'2'
(1 row)
SELECT '\'1 \\\'2\'3'::txtidx;
SELECT '''1 \\''2''3'::txtidx;
txtidx
-------------
'3' '1 \'2'
(1 row)
SELECT '\'1 \\\'2\' 3'::txtidx;
SELECT '''1 \\''2'' 3'::txtidx;
txtidx
-------------
'3' '1 \'2'
(1 row)
SELECT '\'1 \\\'2\' \' 3\' 4 '::txtidx;
SELECT '''1 \\''2'' '' 3'' 4 '::txtidx;
txtidx
------------------
'4' ' 3' '1 \'2'
@ -97,13 +97,13 @@ SELECT ' 1 '::query_txt;
'1'
(1 row)
SELECT '\'1 2\''::query_txt;
SELECT '''1 2'''::query_txt;
query_txt
-----------
'1 2'
(1 row)
SELECT '\'1 \\\'2\''::query_txt;
SELECT '''1 \\''2'''::query_txt;
query_txt
-----------
'1 \'2'
@ -301,7 +301,7 @@ SELECT '1&(2&(4&(5|!6)))'::query_txt;
'1' & '2' & '4' & ( '5' | !'6' )
(1 row)
SELECT '1&(\'2\'&(\' 4\'&(\\|5 | \'6 \\\' !|&\')))'::query_txt;
SELECT '1&(''2''&('' 4''&(\\|5 | ''6 \\'' !|&'')))'::query_txt;
query_txt
------------------------------------------
'1' & '2' & ' 4' & ( '|5' | '6 \' !|&' )
@ -331,13 +331,13 @@ SELECT ' 1 '::mquery_txt;
'1'
(1 row)
SELECT '\'1 2\''::mquery_txt;
SELECT '''1 2'''::mquery_txt;
mquery_txt
------------
'1' & '2'
(1 row)
SELECT '\'1 \\\'2\''::mquery_txt;
SELECT '''1 \\''2'''::mquery_txt;
mquery_txt
------------
'1' & '2'
@ -535,7 +535,7 @@ SELECT '1&(2&(4&(5|!6)))'::mquery_txt;
'1' & '2' & '4' & ( '5' | !'6' )
(1 row)
SELECT '1&(\'2\'&(\' 4\'&(\\|5 | \'6 \\\' !|&\')))'::mquery_txt;
SELECT '1&(''2''&('' 4''&(\\|5 | ''6 \\'' !|&'')))'::mquery_txt;
mquery_txt
---------------------------------
'1' & '2' & '4' & ( '5' | '6' )
@ -694,7 +694,7 @@ SELECT count(*) FROM test_txtidx WHERE a ## '(eq|yt)&(wR|qh)';
11
(1 row)
SELECT txt2txtidx('345 qwe@efd.r \' http://www.com/ http://aew.werc.ewr/?ad=qwe&dw 1aew.werc.ewr/?ad=qwe&dw 2aew.werc.ewr http://3aew.werc.ewr/?ad=qwe&dw http://4aew.werc.ewr http://5aew.werc.ewr:8100/? ad=qwe&dw 6aew.werc.ewr:8100/?ad=qwe&dw 7aew.werc.ewr:8100/?ad=qwe&dw=%20%32 +4.0e-10 qwe qwe qwqwe 234.435 455 5.005 teodor@stack.net qwe-wer asdf <fr>qwer jf sdjk<we hjwer <werrwe> ewr1> ewri2 <a href="qwe<qwe>">
SELECT txt2txtidx('345 qwe@efd.r '' http://www.com/ http://aew.werc.ewr/?ad=qwe&dw 1aew.werc.ewr/?ad=qwe&dw 2aew.werc.ewr http://3aew.werc.ewr/?ad=qwe&dw http://4aew.werc.ewr http://5aew.werc.ewr:8100/? ad=qwe&dw 6aew.werc.ewr:8100/?ad=qwe&dw 7aew.werc.ewr:8100/?ad=qwe&dw=%20%32 +4.0e-10 qwe qwe qwqwe 234.435 455 5.005 teodor@stack.net qwe-wer asdf <fr>qwer jf sdjk<we hjwer <werrwe> ewr1> ewri2 <a href="qwe<qwe>">
/usr/local/fff /awdf/dwqe/4325 rewt/ewr wefjn /wqe-324/ewr gist.h gist.h.c gist.c. readline 4.2 4.2. 4.2, readline-4.2 readline-4.2. 234
<i <b> wow < jqw <> qwerty');
txt2txtidx
@ -708,7 +708,7 @@ SELECT txtidxsize(txt2txtidx('345 qw'));
2
(1 row)
SELECT txtidxsize(txt2txtidx('345 qwe@efd.r \' http://www.com/ http://aew.werc.ewr/?ad=qwe&dw 1aew.werc.ewr/?ad=qwe&dw 2aew.werc.ewr http://3aew.werc.ewr/?ad=qwe&dw http://4aew.werc.ewr http://5aew.werc.ewr:8100/? ad=qwe&dw 6aew.werc.ewr:8100/?ad=qwe&dw 7aew.werc.ewr:8100/?ad=qwe&dw=%20%32 +4.0e-10 qwe qwe qwqwe 234.435 455 5.005 teodor@stack.net qwe-wer asdf <fr>qwer jf sdjk<we hjwer <werrwe> ewr1> ewri2 <a href="qwe<qwe>">
SELECT txtidxsize(txt2txtidx('345 qwe@efd.r '' http://www.com/ http://aew.werc.ewr/?ad=qwe&dw 1aew.werc.ewr/?ad=qwe&dw 2aew.werc.ewr http://3aew.werc.ewr/?ad=qwe&dw http://4aew.werc.ewr http://5aew.werc.ewr:8100/? ad=qwe&dw 6aew.werc.ewr:8100/?ad=qwe&dw 7aew.werc.ewr:8100/?ad=qwe&dw=%20%32 +4.0e-10 qwe qwe qwqwe 234.435 455 5.005 teodor@stack.net qwe-wer asdf <fr>qwer jf sdjk<we hjwer <werrwe> ewr1> ewri2 <a href="qwe<qwe>">
/usr/local/fff /awdf/dwqe/4325 rewt/ewr wefjn /wqe-324/ewr gist.h gist.h.c gist.c. readline 4.2 4.2. 4.2, readline-4.2 readline-4.2. 234
<i <b> wow < jqw <> qwerty'));
txtidxsize

View File

@ -12,19 +12,19 @@ SELECT '1 '::txtidx;
SELECT ' 1'::txtidx;
SELECT ' 1 '::txtidx;
SELECT '1 2'::txtidx;
SELECT '\'1 2\''::txtidx;
SELECT '\'1 \\\'2\''::txtidx;
SELECT '\'1 \\\'2\'3'::txtidx;
SELECT '\'1 \\\'2\' 3'::txtidx;
SELECT '\'1 \\\'2\' \' 3\' 4 '::txtidx;
SELECT '''1 2'''::txtidx;
SELECT '''1 \\''2'''::txtidx;
SELECT '''1 \\''2''3'::txtidx;
SELECT '''1 \\''2'' 3'::txtidx;
SELECT '''1 \\''2'' '' 3'' 4 '::txtidx;
--query_txt
SELECT '1'::query_txt;
SELECT '1 '::query_txt;
SELECT ' 1'::query_txt;
SELECT ' 1 '::query_txt;
SELECT '\'1 2\''::query_txt;
SELECT '\'1 \\\'2\''::query_txt;
SELECT '''1 2'''::query_txt;
SELECT '''1 \\''2'''::query_txt;
SELECT '!1'::query_txt;
SELECT '1|2'::query_txt;
SELECT '1|!2'::query_txt;
@ -57,13 +57,13 @@ SELECT '1&(2&(4&(5&6)))'::query_txt;
SELECT '1&2&4&5&6'::query_txt;
SELECT '1&(2&(4&(5|6)))'::query_txt;
SELECT '1&(2&(4&(5|!6)))'::query_txt;
SELECT '1&(\'2\'&(\' 4\'&(\\|5 | \'6 \\\' !|&\')))'::query_txt;
SELECT '1&(''2''&('' 4''&(\\|5 | ''6 \\'' !|&'')))'::query_txt;
SELECT '1'::mquery_txt;
SELECT '1 '::mquery_txt;
SELECT ' 1'::mquery_txt;
SELECT ' 1 '::mquery_txt;
SELECT '\'1 2\''::mquery_txt;
SELECT '\'1 \\\'2\''::mquery_txt;
SELECT '''1 2'''::mquery_txt;
SELECT '''1 \\''2'''::mquery_txt;
SELECT '!1'::mquery_txt;
SELECT '1|2'::mquery_txt;
SELECT '1|!2'::mquery_txt;
@ -96,7 +96,7 @@ SELECT '1&(2&(4&(5&6)))'::mquery_txt;
SELECT '1&2&4&5&6'::mquery_txt;
SELECT '1&(2&(4&(5|6)))'::mquery_txt;
SELECT '1&(2&(4&(5|!6)))'::mquery_txt;
SELECT '1&(\'2\'&(\' 4\'&(\\|5 | \'6 \\\' !|&\')))'::mquery_txt;
SELECT '1&(''2''&('' 4''&(\\|5 | ''6 \\'' !|&'')))'::mquery_txt;
SELECT 'querty-fgries | http://www.google.com/index.html | www.rambler.ru/index.shtml'::mquery_txt;
CREATE TABLE test_txtidx( t text, a txtidx );
@ -133,13 +133,13 @@ SELECT count(*) FROM test_txtidx WHERE a ## 'eq|yt';
SELECT count(*) FROM test_txtidx WHERE a ## '(eq&yt)|(wR&qh)';
SELECT count(*) FROM test_txtidx WHERE a ## '(eq|yt)&(wR|qh)';
SELECT txt2txtidx('345 qwe@efd.r \' http://www.com/ http://aew.werc.ewr/?ad=qwe&dw 1aew.werc.ewr/?ad=qwe&dw 2aew.werc.ewr http://3aew.werc.ewr/?ad=qwe&dw http://4aew.werc.ewr http://5aew.werc.ewr:8100/? ad=qwe&dw 6aew.werc.ewr:8100/?ad=qwe&dw 7aew.werc.ewr:8100/?ad=qwe&dw=%20%32 +4.0e-10 qwe qwe qwqwe 234.435 455 5.005 teodor@stack.net qwe-wer asdf <fr>qwer jf sdjk<we hjwer <werrwe> ewr1> ewri2 <a href="qwe<qwe>">
SELECT txt2txtidx('345 qwe@efd.r '' http://www.com/ http://aew.werc.ewr/?ad=qwe&dw 1aew.werc.ewr/?ad=qwe&dw 2aew.werc.ewr http://3aew.werc.ewr/?ad=qwe&dw http://4aew.werc.ewr http://5aew.werc.ewr:8100/? ad=qwe&dw 6aew.werc.ewr:8100/?ad=qwe&dw 7aew.werc.ewr:8100/?ad=qwe&dw=%20%32 +4.0e-10 qwe qwe qwqwe 234.435 455 5.005 teodor@stack.net qwe-wer asdf <fr>qwer jf sdjk<we hjwer <werrwe> ewr1> ewri2 <a href="qwe<qwe>">
/usr/local/fff /awdf/dwqe/4325 rewt/ewr wefjn /wqe-324/ewr gist.h gist.h.c gist.c. readline 4.2 4.2. 4.2, readline-4.2 readline-4.2. 234
<i <b> wow < jqw <> qwerty');
SELECT txtidxsize(txt2txtidx('345 qw'));
SELECT txtidxsize(txt2txtidx('345 qwe@efd.r \' http://www.com/ http://aew.werc.ewr/?ad=qwe&dw 1aew.werc.ewr/?ad=qwe&dw 2aew.werc.ewr http://3aew.werc.ewr/?ad=qwe&dw http://4aew.werc.ewr http://5aew.werc.ewr:8100/? ad=qwe&dw 6aew.werc.ewr:8100/?ad=qwe&dw 7aew.werc.ewr:8100/?ad=qwe&dw=%20%32 +4.0e-10 qwe qwe qwqwe 234.435 455 5.005 teodor@stack.net qwe-wer asdf <fr>qwer jf sdjk<we hjwer <werrwe> ewr1> ewri2 <a href="qwe<qwe>">
SELECT txtidxsize(txt2txtidx('345 qwe@efd.r '' http://www.com/ http://aew.werc.ewr/?ad=qwe&dw 1aew.werc.ewr/?ad=qwe&dw 2aew.werc.ewr http://3aew.werc.ewr/?ad=qwe&dw http://4aew.werc.ewr http://5aew.werc.ewr:8100/? ad=qwe&dw 6aew.werc.ewr:8100/?ad=qwe&dw 7aew.werc.ewr:8100/?ad=qwe&dw=%20%32 +4.0e-10 qwe qwe qwqwe 234.435 455 5.005 teodor@stack.net qwe-wer asdf <fr>qwer jf sdjk<we hjwer <werrwe> ewr1> ewri2 <a href="qwe<qwe>">
/usr/local/fff /awdf/dwqe/4325 rewt/ewr wefjn /wqe-324/ewr gist.h gist.h.c gist.c. readline 4.2 4.2. 4.2, readline-4.2 readline-4.2. 234
<i <b> wow < jqw <> qwerty'));

View File

@ -3,7 +3,7 @@
* back to source text
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.124.2.2 2003/10/02 22:25:08 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.124.2.3 2006/05/21 19:56:40 momjian Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
@ -2563,7 +2563,7 @@ get_const_expr(Const *constval, deparse_context *context)
if (ch == '\'' || ch == '\\')
{
appendStringInfoChar(buf, '\\');
appendStringInfoChar(buf, ch);
appendStringInfoChar(buf, ch);
}
else if (((unsigned char) ch) < ((unsigned char) ' '))

View File

@ -22,7 +22,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.305.2.12 2006/01/09 21:16:57 tgl Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.305.2.13 2006/05/21 19:56:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -6410,7 +6410,7 @@ dumpTriggers(Archive *fout, TableInfo *tblinfo, int numTables)
for (s = tgargs; s < p;)
{
if (*s == '\'')
appendPQExpBufferChar(query, '\\');
appendPQExpBufferChar(query, *s);
appendPQExpBufferChar(query, *s++);
}
appendPQExpBufferChar(query, '\'');

View File

@ -3,7 +3,7 @@
*
* Copyright 2000-2002 by PostgreSQL Global Development Group
*
* $Header: /cvsroot/pgsql/src/bin/psql/large_obj.c,v 1.23 2002/10/15 02:24:16 tgl Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/large_obj.c,v 1.23.2.1 2006/05/21 19:56:40 momjian Exp $
*/
#include "postgres_fe.h"
#include "large_obj.h"
@ -217,7 +217,7 @@ do_lo_import(const char *filename_arg, const char *comment_arg)
for (i = 0; i < slen; i++)
{
if (comment_arg[i] == '\'' || comment_arg[i] == '\\')
*bufptr++ = '\\';
*bufptr++ = comment_arg[i];
*bufptr++ = comment_arg[i];
}
strcpy(bufptr, "')");

View File

@ -12,7 +12,7 @@
#
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createdb,v 1.28 2002/10/18 22:05:36 petere Exp $
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createdb,v 1.28.2.1 2006/05/21 19:56:41 momjian Exp $
#
#-------------------------------------------------------------------------
@ -181,7 +181,7 @@ fi
# escape the quotes
dbpath=`echo "$dbpath" | sed "s/'/\\\\\'/g"`
dbpath=`echo "$dbpath" | sed "s/'/\'\'/g"`
dbname=`echo "$dbname" | sed 's/\"/\\\"/g'`
TEMPLATE=`echo "$TEMPLATE" | sed 's/\"/\"\"/g'`
@ -201,7 +201,7 @@ fi
# Insert comment as well, if requested
[ -z "$dbcomment" ] && exit 0
dbcomment=`echo "$dbcomment" | sed "s/'/\\\\\'/g"`
dbcomment=`echo "$dbcomment" | sed "s/'/\'\'/g"`
${PATHNAME}psql $PSQLOPT -d "$dbname" -c "SET autocommit TO 'on';COMMENT ON DATABASE \"$dbname\" IS '$dbcomment'"
if [ "$?" -ne 0 ]; then

View File

@ -83,7 +83,7 @@ exec sql end declare section;
exec sql execute immediate :command;
printf("New tuple got OID = %ld\n", sqlca.sqlerrd[1]);
sprintf(command, "insert into \"Test\" (name, amount, letter) values ('db: \\\'mm\\\'', 2, 't')");
sprintf(command, "insert into \"Test\" (name, amount, letter) values ('db: ''mm''', 2, 't')");
exec sql execute immediate :command;
strcpy(msg, "execute insert 2");

View File

@ -8,7 +8,7 @@ import java.util.Vector;
import org.postgresql.largeobject.*;
import org.postgresql.util.*;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.12.2.7 2003/08/07 17:56:27 barry Exp $
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.12.2.8 2006/05/21 19:56:41 momjian Exp $
* This class defines methods of the jdbc1 specification. This class is
* extended by org.postgresql.jdbc2.AbstractJdbc2Statement which adds the jdbc2
* methods. The real Statement class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Statement
@ -936,7 +936,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
{
case '\\':
case '\'':
p_output.append('\\');
p_output.append(c);
p_output.append(c);
break;
case '\0':

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.122.2.1 2003/11/30 20:52:37 joe Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.122.2.2 2006/05/21 19:56:41 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -161,7 +161,7 @@ PQescapeBytea(unsigned char *bintext, size_t binlen, size_t *bytealen)
}
else if (*vp == '\'')
{
rp[0] = '\\';
rp[0] = '\'';
rp[1] = '\'';
rp += 2;
}

View File

@ -120,16 +120,16 @@ def comp_func(pgcnx):
print "-- same order as the columns of EMP."
print
print "CREATE FUNCTION new_emp() RETURNS EMP"
print " AS 'SELECT \'None\'::text AS name,"
print " AS 'SELECT ''None''::text AS name,"
print " 1000 AS salary,"
print " 25 AS age,"
print " \'none\'::varchar(16) AS dept'"
print " ''none''::varchar(16) AS dept'"
print " LANGUAGE 'sql'"
pgcnx.query("""CREATE FUNCTION new_emp() RETURNS EMP
AS 'SELECT \\\'None\\\'::text AS name,
AS 'SELECT ''None''::text AS name,
1000 AS salary,
25 AS age,
\\\'none\\\'::varchar(16) AS dept'
''none''::varchar(16) AS dept'
LANGUAGE 'sql'""")
wait_key()
print

View File

@ -4,7 +4,7 @@
* procedural language
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/gram.y,v 1.39.2.2 2005/02/08 18:22:45 tgl Exp $
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/gram.y,v 1.39.2.3 2006/05/21 19:56:41 momjian Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
@ -387,7 +387,7 @@ decl_statement : decl_varname decl_const decl_datatype decl_notnull decl_defval
while (*cp1 != '\0')
{
if (*cp1 == '\\' || *cp1 == '\'')
*cp2++ = '\\';
*cp2++ = *cp1;
*cp2++ = *cp1++;
}
strcpy(cp2, "'::refcursor");

View File

@ -6,7 +6,7 @@
--
-- Copyright (c) 1994-5, Regents of the University of California
--
-- $Id: funcs.source,v 1.5 2001/10/26 20:45:33 tgl Exp $
-- $Id: funcs.source,v 1.5.4.1 2006/05/21 19:56:41 momjian Exp $
--
---------------------------------------------------------------------------
@ -76,10 +76,10 @@ WHERE EMP.cubicle ~= '(2,1)'::point;
-- columns of EMP.
CREATE FUNCTION new_emp() RETURNS EMP
AS 'SELECT \'None\'::text AS name,
AS 'SELECT ''None''::text AS name,
1000 AS salary,
25 AS age,
\'(2,2)\'::point AS cubicle'
''(2,2)''::point AS cubicle'
LANGUAGE 'sql';
-- you can then project a column out of resulting the tuple by using the