|
3 | 3 | *back to source text
|
4 | 4 | *
|
5 | 5 | * IDENTIFICATION
|
6 |
| - * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.202 2005/06/28 05:09:01 tgl Exp $ |
| 6 | + * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.203 2005/07/02 17:01:50 momjian Exp $ |
7 | 7 | *
|
8 | 8 | * This software is copyrighted by Jan Wieck - Hamburg.
|
9 | 9 | *
|
@@ -564,12 +564,14 @@ pg_get_triggerdef(PG_FUNCTION_ARGS)
|
564 | 564 | {
|
565 | 565 | if (i>0)
|
566 | 566 | appendStringInfo(&buf,", ");
|
| 567 | +if (strchr(p,'\\')!=NULL) |
| 568 | +appendStringInfoChar(&buf,ESCAPE_STRING_SYNTAX); |
567 | 569 | appendStringInfoChar(&buf,'\'');
|
| 570 | + |
568 | 571 | while (*p)
|
569 | 572 | {
|
570 |
| -/* escape quotes and backslashes */ |
571 |
| -if (*p=='\''||*p=='\\') |
572 |
| -appendStringInfoChar(&buf,'\\'); |
| 573 | +if (SQL_STR_DOUBLE(*p)) |
| 574 | +appendStringInfoChar(&buf,*p); |
573 | 575 | appendStringInfoChar(&buf,*p++);
|
574 | 576 | }
|
575 | 577 | p++;
|
@@ -3869,22 +3871,29 @@ get_const_expr(Const *constval, deparse_context *context)
|
3869 | 3871 | break;
|
3870 | 3872 |
|
3871 | 3873 | default:
|
3872 |
| - |
3873 | 3874 | /*
|
3874 | 3875 | * We must quote any funny characters in the constant's
|
3875 | 3876 | * representation. XXX Any MULTIBYTE considerations here?
|
3876 | 3877 | */
|
| 3878 | +for (valptr=extval;*valptr;valptr++) |
| 3879 | +if (*valptr=='\\'|| |
| 3880 | +(unsignedchar)*valptr< (unsignedchar)' ') |
| 3881 | +{ |
| 3882 | +appendStringInfoChar(buf,ESCAPE_STRING_SYNTAX); |
| 3883 | +break; |
| 3884 | +} |
| 3885 | + |
3877 | 3886 | appendStringInfoChar(buf,'\'');
|
3878 | 3887 | for (valptr=extval;*valptr;valptr++)
|
3879 | 3888 | {
|
3880 | 3889 | charch=*valptr;
|
3881 | 3890 |
|
3882 |
| -if (ch=='\''||ch=='\\') |
| 3891 | +if (SQL_STR_DOUBLE(ch)) |
3883 | 3892 | {
|
3884 |
| -appendStringInfoChar(buf,'\\'); |
| 3893 | +appendStringInfoChar(buf,ch); |
3885 | 3894 | appendStringInfoChar(buf,ch);
|
3886 | 3895 | }
|
3887 |
| -elseif (((unsignedchar)ch)< ((unsignedchar)' ')) |
| 3896 | +elseif ((unsignedchar)ch< (unsignedchar)' ') |
3888 | 3897 | appendStringInfo(buf,"\\%03o", (int)ch);
|
3889 | 3898 | else
|
3890 | 3899 | appendStringInfoChar(buf,ch);
|
|