Add E'' to internally created SQL strings that contain backslashes.
Improve code clarity by using macros for E'' processing.
This commit is contained in:
parent
654efe6aaa
commit
74b49a8129
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/quote.c,v 1.15 2005/03/21 16:29:20 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/quote.c,v 1.16 2005/07/02 17:01:50 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -60,19 +60,25 @@ quote_literal(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
len = VARSIZE(t) - VARHDRSZ;
|
len = VARSIZE(t) - VARHDRSZ;
|
||||||
/* We make a worst-case result area; wasting a little space is OK */
|
/* We make a worst-case result area; wasting a little space is OK */
|
||||||
result = (text *) palloc(len * 2 + 2 + VARHDRSZ);
|
result = (text *) palloc(len * 2 + 3 + VARHDRSZ);
|
||||||
|
|
||||||
cp1 = VARDATA(t);
|
cp1 = VARDATA(t);
|
||||||
cp2 = VARDATA(result);
|
cp2 = VARDATA(result);
|
||||||
|
|
||||||
|
for(; len-- > 0; cp1++)
|
||||||
|
if (*cp1 == '\\')
|
||||||
|
{
|
||||||
|
*cp2++ = ESCAPE_STRING_SYNTAX;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
len = VARSIZE(t) - VARHDRSZ;
|
||||||
|
cp1 = VARDATA(t);
|
||||||
*cp2++ = '\'';
|
*cp2++ = '\'';
|
||||||
while (len-- > 0)
|
while (len-- > 0)
|
||||||
{
|
{
|
||||||
if (*cp1 == '\'')
|
if (SQL_STR_DOUBLE(*cp1))
|
||||||
*cp2++ = '\'';
|
*cp2++ = *cp1;
|
||||||
else if (*cp1 == '\\')
|
|
||||||
*cp2++ = '\\';
|
|
||||||
|
|
||||||
*cp2++ = *cp1++;
|
*cp2++ = *cp1++;
|
||||||
}
|
}
|
||||||
*cp2++ = '\'';
|
*cp2++ = '\'';
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* back to source text
|
* back to source text
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.202 2005/06/28 05:09:01 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.203 2005/07/02 17:01:50 momjian Exp $
|
||||||
*
|
*
|
||||||
* This software is copyrighted by Jan Wieck - Hamburg.
|
* This software is copyrighted by Jan Wieck - Hamburg.
|
||||||
*
|
*
|
||||||
@ -564,12 +564,14 @@ pg_get_triggerdef(PG_FUNCTION_ARGS)
|
|||||||
{
|
{
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
appendStringInfo(&buf, ", ");
|
appendStringInfo(&buf, ", ");
|
||||||
|
if (strchr(p, '\\') != NULL)
|
||||||
|
appendStringInfoChar(&buf, ESCAPE_STRING_SYNTAX);
|
||||||
appendStringInfoChar(&buf, '\'');
|
appendStringInfoChar(&buf, '\'');
|
||||||
|
|
||||||
while (*p)
|
while (*p)
|
||||||
{
|
{
|
||||||
/* escape quotes and backslashes */
|
if (SQL_STR_DOUBLE(*p))
|
||||||
if (*p == '\'' || *p == '\\')
|
appendStringInfoChar(&buf, *p);
|
||||||
appendStringInfoChar(&buf, '\\');
|
|
||||||
appendStringInfoChar(&buf, *p++);
|
appendStringInfoChar(&buf, *p++);
|
||||||
}
|
}
|
||||||
p++;
|
p++;
|
||||||
@ -3869,22 +3871,29 @@ get_const_expr(Const *constval, deparse_context *context)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We must quote any funny characters in the constant's
|
* We must quote any funny characters in the constant's
|
||||||
* representation. XXX Any MULTIBYTE considerations here?
|
* representation. XXX Any MULTIBYTE considerations here?
|
||||||
*/
|
*/
|
||||||
|
for (valptr = extval; *valptr; valptr++)
|
||||||
|
if (*valptr == '\\' ||
|
||||||
|
(unsigned char)*valptr < (unsigned char)' ')
|
||||||
|
{
|
||||||
|
appendStringInfoChar(buf, ESCAPE_STRING_SYNTAX);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
appendStringInfoChar(buf, '\'');
|
appendStringInfoChar(buf, '\'');
|
||||||
for (valptr = extval; *valptr; valptr++)
|
for (valptr = extval; *valptr; valptr++)
|
||||||
{
|
{
|
||||||
char ch = *valptr;
|
char ch = *valptr;
|
||||||
|
|
||||||
if (ch == '\'' || ch == '\\')
|
if (SQL_STR_DOUBLE(ch))
|
||||||
{
|
{
|
||||||
appendStringInfoChar(buf, '\\');
|
appendStringInfoChar(buf, ch);
|
||||||
appendStringInfoChar(buf, ch);
|
appendStringInfoChar(buf, ch);
|
||||||
}
|
}
|
||||||
else if (((unsigned char) ch) < ((unsigned char) ' '))
|
else if ((unsigned char)ch < (unsigned char)' ')
|
||||||
appendStringInfo(buf, "\\%03o", (int) ch);
|
appendStringInfo(buf, "\\%03o", (int) ch);
|
||||||
else
|
else
|
||||||
appendStringInfoChar(buf, ch);
|
appendStringInfoChar(buf, ch);
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
* Portions taken from FreeBSD.
|
* Portions taken from FreeBSD.
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.89 2005/07/01 17:40:28 momjian Exp $
|
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.90 2005/07/02 17:01:50 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1986,8 +1986,8 @@ escape_quotes(const char *src)
|
|||||||
|
|
||||||
for (i = 0, j = 0; i < len; i++)
|
for (i = 0, j = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
if (src[i] == '\\' || src[i] == '\'')
|
if (SQL_STR_DOUBLE(src[i]))
|
||||||
result[j++] = src[i]; /* double these */
|
result[j++] = src[i];
|
||||||
result[j++] = src[i];
|
result[j++] = src[i];
|
||||||
}
|
}
|
||||||
result[j] = '\0';
|
result[j] = '\0';
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/bin/pg_dump/dumputils.c,v 1.18 2005/07/01 21:03:25 momjian Exp $
|
* $PostgreSQL: pgsql/src/bin/pg_dump/dumputils.c,v 1.19 2005/07/02 17:01:51 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -111,35 +111,30 @@ fmtId(const char *rawid)
|
|||||||
void
|
void
|
||||||
appendStringLiteral(PQExpBuffer buf, const char *str, bool escapeAll)
|
appendStringLiteral(PQExpBuffer buf, const char *str, bool escapeAll)
|
||||||
{
|
{
|
||||||
bool has_escapes = false;
|
char ch;
|
||||||
const char *str2 = str;
|
const char *p;
|
||||||
|
|
||||||
while (*str2)
|
for (p = str; *p; p++)
|
||||||
{
|
{
|
||||||
char ch = *str2++;
|
ch = *p;
|
||||||
|
|
||||||
if (ch == '\\' ||
|
if (ch == '\\' ||
|
||||||
((unsigned char)ch < (unsigned char)' ' &&
|
((unsigned char)ch < (unsigned char)' ' &&
|
||||||
(escapeAll ||
|
(escapeAll ||
|
||||||
(ch != '\t' && ch != '\n' && ch != '\v' &&
|
(ch != '\t' && ch != '\n' && ch != '\v' &&
|
||||||
ch != '\f' && ch != '\r'))))
|
ch != '\f' && ch != '\r'))))
|
||||||
{
|
{
|
||||||
has_escapes = true;
|
appendPQExpBufferChar(buf, ESCAPE_STRING_SYNTAX);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_escapes)
|
|
||||||
appendPQExpBufferChar(buf, 'E');
|
|
||||||
|
|
||||||
appendPQExpBufferChar(buf, '\'');
|
appendPQExpBufferChar(buf, '\'');
|
||||||
while (*str)
|
for (p = str; *p; p++)
|
||||||
{
|
{
|
||||||
char ch = *str++;
|
ch = *p;
|
||||||
|
if (SQL_STR_DOUBLE(ch))
|
||||||
if (ch == '\\' || ch == '\'')
|
|
||||||
{
|
{
|
||||||
appendPQExpBufferChar(buf, ch); /* double these */
|
appendPQExpBufferChar(buf, ch);
|
||||||
appendPQExpBufferChar(buf, ch);
|
appendPQExpBufferChar(buf, ch);
|
||||||
}
|
}
|
||||||
else if ((unsigned char)ch < (unsigned char)' ' &&
|
else if ((unsigned char)ch < (unsigned char)' ' &&
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
* by PostgreSQL
|
* by PostgreSQL
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.412 2005/07/01 21:03:25 momjian Exp $
|
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.413 2005/07/02 17:01:51 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -7792,18 +7792,17 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo)
|
|||||||
}
|
}
|
||||||
p--;
|
p--;
|
||||||
|
|
||||||
/* do we need E''? */
|
|
||||||
while (s2 < p)
|
while (s2 < p)
|
||||||
if (*s2++ == '\\')
|
if (*s2++ == '\\')
|
||||||
{
|
{
|
||||||
appendPQExpBufferChar(query, 'E');
|
appendPQExpBufferChar(query, ESCAPE_STRING_SYNTAX);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
appendPQExpBufferChar(query, '\'');
|
appendPQExpBufferChar(query, '\'');
|
||||||
while (s < p)
|
while (s < p)
|
||||||
{
|
{
|
||||||
if (*s == '\'')
|
if (*s == '\'') /* bytea already doubles backslashes */
|
||||||
appendPQExpBufferChar(query, '\'');
|
appendPQExpBufferChar(query, '\'');
|
||||||
appendPQExpBufferChar(query, *s++);
|
appendPQExpBufferChar(query, *s++);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
|
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.119 2005/07/01 17:40:28 momjian Exp $
|
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.120 2005/07/02 17:01:52 momjian Exp $
|
||||||
*/
|
*/
|
||||||
#include "postgres_fe.h"
|
#include "postgres_fe.h"
|
||||||
#include "describe.h"
|
#include "describe.h"
|
||||||
@ -1898,8 +1898,8 @@ processNamePattern(PQExpBuffer buf, const char *pattern,
|
|||||||
appendPQExpBuffer(&namebuf, "\\\\");
|
appendPQExpBuffer(&namebuf, "\\\\");
|
||||||
|
|
||||||
/* Ensure chars special to string literals are passed properly */
|
/* Ensure chars special to string literals are passed properly */
|
||||||
if (*cp == '\'' || *cp == '\\')
|
if (SQL_STR_DOUBLE(*cp))
|
||||||
appendPQExpBufferChar(&namebuf, *cp); /* double these */
|
appendPQExpBufferChar(&namebuf, *cp);
|
||||||
|
|
||||||
i = PQmblen(cp, pset.encoding);
|
i = PQmblen(cp, pset.encoding);
|
||||||
while (i--)
|
while (i--)
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
|
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/bin/psql/large_obj.c,v 1.38 2005/07/01 17:40:28 momjian Exp $
|
* $PostgreSQL: pgsql/src/bin/psql/large_obj.c,v 1.39 2005/07/02 17:01:52 momjian Exp $
|
||||||
*/
|
*/
|
||||||
#include "postgres_fe.h"
|
#include "postgres_fe.h"
|
||||||
#include "large_obj.h"
|
#include "large_obj.h"
|
||||||
@ -172,13 +172,17 @@ do_lo_import(const char *filename_arg, const char *comment_arg)
|
|||||||
if (!cmdbuf)
|
if (!cmdbuf)
|
||||||
return fail_lo_xact("\\lo_import", own_transaction);
|
return fail_lo_xact("\\lo_import", own_transaction);
|
||||||
sprintf(cmdbuf,
|
sprintf(cmdbuf,
|
||||||
"COMMENT ON LARGE OBJECT %u IS '",
|
"COMMENT ON LARGE OBJECT %u IS ",
|
||||||
loid);
|
loid);
|
||||||
bufptr = cmdbuf + strlen(cmdbuf);
|
bufptr = cmdbuf + strlen(cmdbuf);
|
||||||
|
|
||||||
|
if (strchr(comment_arg, '\\') != NULL)
|
||||||
|
*bufptr++ = ESCAPE_STRING_SYNTAX;
|
||||||
|
*bufptr++ = '\'';
|
||||||
for (i = 0; i < slen; i++)
|
for (i = 0; i < slen; i++)
|
||||||
{
|
{
|
||||||
if (comment_arg[i] == '\'' || comment_arg[i] == '\\')
|
if (SQL_STR_DOUBLE(comment_arg[i]))
|
||||||
*bufptr++ = comment_arg[i]; /* double these */
|
*bufptr++ = comment_arg[i];
|
||||||
*bufptr++ = comment_arg[i];
|
*bufptr++ = comment_arg[i];
|
||||||
}
|
}
|
||||||
strcpy(bufptr, "'");
|
strcpy(bufptr, "'");
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/include/c.h,v 1.186 2005/06/28 05:09:04 tgl Exp $
|
* $PostgreSQL: pgsql/src/include/c.h,v 1.187 2005/07/02 17:01:52 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -479,6 +479,8 @@ typedef NameData *Name;
|
|||||||
|
|
||||||
#define NameStr(name) ((name).data)
|
#define NameStr(name) ((name).data)
|
||||||
|
|
||||||
|
#define SQL_STR_DOUBLE(ch) ((ch) == '\'' || (ch) == '\\')
|
||||||
|
#define ESCAPE_STRING_SYNTAX 'E'
|
||||||
|
|
||||||
/* ----------------------------------------------------------------
|
/* ----------------------------------------------------------------
|
||||||
* Section 4: IsValid macros for system types
|
* Section 4: IsValid macros for system types
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.40 2005/06/02 12:35:11 meskes Exp $ */
|
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.41 2005/07/02 17:01:53 momjian Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The aim is to get a simpler inteface to the database routines.
|
* The aim is to get a simpler inteface to the database routines.
|
||||||
@ -45,21 +45,14 @@ quote_postgres(char *arg, int lineno)
|
|||||||
if (!res)
|
if (!res)
|
||||||
return (res);
|
return (res);
|
||||||
|
|
||||||
|
if (strchr(arg, '\\') != NULL)
|
||||||
|
res[ri++] = ESCAPE_STRING_SYNTAX;
|
||||||
res[ri++] = '\'';
|
res[ri++] = '\'';
|
||||||
|
|
||||||
for (i = 0; arg[i]; i++, ri++)
|
for (i = 0; arg[i]; i++, ri++)
|
||||||
{
|
{
|
||||||
switch (arg[i])
|
if (SQL_STR_DOUBLE(arg[i]))
|
||||||
{
|
res[ri++] = arg[i];
|
||||||
case '\'':
|
|
||||||
res[ri++] = '\'';
|
|
||||||
break;
|
|
||||||
case '\\':
|
|
||||||
res[ri++] = '\\';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
;
|
|
||||||
}
|
|
||||||
res[ri] = arg[i];
|
res[ri] = arg[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.307 2005/02/10 08:06:35 meskes Exp $ */
|
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.308 2005/07/02 17:01:53 momjian Exp $ */
|
||||||
|
|
||||||
/* Copyright comment */
|
/* Copyright comment */
|
||||||
%{
|
%{
|
||||||
@ -4216,11 +4216,16 @@ Bconst: BCONST { $$ = make_name();};
|
|||||||
Xconst: XCONST { $$ = make_name();};
|
Xconst: XCONST { $$ = make_name();};
|
||||||
Sconst: SCONST
|
Sconst: SCONST
|
||||||
{
|
{
|
||||||
$$ = (char *)mm_alloc(strlen($1) + 3);
|
char *ret;
|
||||||
$$[0]='\'';
|
|
||||||
strcpy($$+1, $1);
|
$$ = ret = (char *)mm_alloc(strlen($1) + 4);
|
||||||
$$[strlen($1)+2]='\0';
|
if (strchr($1, '\\') != NULL)
|
||||||
$$[strlen($1)+1]='\'';
|
*ret++ = ESCAPE_STRING_SYNTAX;
|
||||||
|
*ret++ = '\'';
|
||||||
|
strcpy(ret, $1);
|
||||||
|
ret += strlen($1);
|
||||||
|
*ret++ = '\'';
|
||||||
|
*ret++ = '\0';
|
||||||
free($1);
|
free($1);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.169 2005/06/12 00:00:21 neilc Exp $
|
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.170 2005/07/02 17:01:54 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -2368,23 +2368,9 @@ PQescapeString(char *to, const char *from, size_t length)
|
|||||||
|
|
||||||
while (remaining > 0 && *source != '\0')
|
while (remaining > 0 && *source != '\0')
|
||||||
{
|
{
|
||||||
switch (*source)
|
if (SQL_STR_DOUBLE(*source))
|
||||||
{
|
|
||||||
case '\\':
|
|
||||||
*target++ = '\\';
|
|
||||||
*target++ = '\\';
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '\'':
|
|
||||||
*target++ = '\'';
|
|
||||||
*target++ = '\'';
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
*target++ = *source;
|
*target++ = *source;
|
||||||
break;
|
*target++ = *source++;
|
||||||
}
|
|
||||||
source++;
|
|
||||||
remaining--;
|
remaining--;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2449,7 +2435,7 @@ PQescapeBytea(const unsigned char *bintext, size_t binlen, size_t *bytealen)
|
|||||||
}
|
}
|
||||||
else if (*vp == '\'')
|
else if (*vp == '\'')
|
||||||
{
|
{
|
||||||
rp[0] = '\\';
|
rp[0] = '\'';
|
||||||
rp[1] = '\'';
|
rp[1] = '\'';
|
||||||
rp += 2;
|
rp += 2;
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* procedural language
|
* procedural language
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.79 2005/07/02 08:59:47 neilc Exp $
|
* $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.80 2005/07/02 17:01:59 momjian Exp $
|
||||||
*
|
*
|
||||||
* This software is copyrighted by Jan Wieck - Hamburg.
|
* This software is copyrighted by Jan Wieck - Hamburg.
|
||||||
*
|
*
|
||||||
@ -389,13 +389,16 @@ decl_statement : decl_varname decl_const decl_datatype decl_notnull decl_defval
|
|||||||
curname_def = palloc0(sizeof(PLpgSQL_expr));
|
curname_def = palloc0(sizeof(PLpgSQL_expr));
|
||||||
|
|
||||||
curname_def->dtype = PLPGSQL_DTYPE_EXPR;
|
curname_def->dtype = PLPGSQL_DTYPE_EXPR;
|
||||||
strcpy(buf, "SELECT '");
|
strcpy(buf, "SELECT ");
|
||||||
cp1 = new->refname;
|
cp1 = new->refname;
|
||||||
cp2 = buf + strlen(buf);
|
cp2 = buf + strlen(buf);
|
||||||
while (*cp1 != '\0')
|
if (strchr(cp1, '\\') != NULL)
|
||||||
|
*cp2++ = ESCAPE_STRING_SYNTAX;
|
||||||
|
*cp2++ = '\'';
|
||||||
|
while (*cp1)
|
||||||
{
|
{
|
||||||
if (*cp1 == '\\' || *cp1 == '\'')
|
if (SQL_STR_DOUBLE(*cp1))
|
||||||
*cp2++ = *cp1; /* double these */
|
*cp2++ = *cp1;
|
||||||
*cp2++ = *cp1++;
|
*cp2++ = *cp1++;
|
||||||
}
|
}
|
||||||
strcpy(cp2, "'::refcursor");
|
strcpy(cp2, "'::refcursor");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user