8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.290 2007/12/03 00:03:05 tgl Exp $
11
+ * $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.291 2007/12/27 16:45:22 tgl Exp $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
@@ -3094,13 +3094,7 @@ CopyAttributeOutText(CopyState cstate, char *string)
3094
3094
start = ptr ;
3095
3095
while ((c = * ptr ) != '\0' )
3096
3096
{
3097
- if (c == '\\' || c == delimc )
3098
- {
3099
- DUMPSOFAR ();
3100
- CopySendChar (cstate , '\\' );
3101
- start = ptr ++ ; /* we include char in next run */
3102
- }
3103
- else if ((unsigned char ) c < (unsigned char ) 0x20 )
3097
+ if ((unsigned char ) c < (unsigned char ) 0x20 )
3104
3098
{
3105
3099
/*
3106
3100
* \r and \n must be escaped, the others are traditional.
@@ -3130,6 +3124,9 @@ CopyAttributeOutText(CopyState cstate, char *string)
3130
3124
c = 'v' ;
3131
3125
break ;
3132
3126
default :
3127
+ /* If it's the delimiter, must backslash it */
3128
+ if (c == delimc )
3129
+ break ;
3133
3130
/* All ASCII control chars are length 1 */
3134
3131
ptr ++ ;
3135
3132
continue ; /* fall to end of loop */
@@ -3140,6 +3137,12 @@ CopyAttributeOutText(CopyState cstate, char *string)
3140
3137
CopySendChar (cstate , c );
3141
3138
start = ++ ptr ; /* do not include char in next run */
3142
3139
}
3140
+ else if (c == '\\' || c == delimc )
3141
+ {
3142
+ DUMPSOFAR ();
3143
+ CopySendChar (cstate , '\\' );
3144
+ start = ptr ++ ; /* we include char in next run */
3145
+ }
3143
3146
else if (IS_HIGHBIT_SET (c ))
3144
3147
ptr += pg_encoding_mblen (cstate -> client_encoding , ptr );
3145
3148
else
@@ -3151,13 +3154,7 @@ CopyAttributeOutText(CopyState cstate, char *string)
3151
3154
start = ptr ;
3152
3155
while ((c = * ptr ) != '\0' )
3153
3156
{
3154
- if (c == '\\' || c == delimc )
3155
- {
3156
- DUMPSOFAR ();
3157
- CopySendChar (cstate , '\\' );
3158
- start = ptr ++ ; /* we include char in next run */
3159
- }
3160
- else if ((unsigned char ) c < (unsigned char ) 0x20 )
3157
+ if ((unsigned char ) c < (unsigned char ) 0x20 )
3161
3158
{
3162
3159
/*
3163
3160
* \r and \n must be escaped, the others are traditional.
@@ -3187,6 +3184,9 @@ CopyAttributeOutText(CopyState cstate, char *string)
3187
3184
c = 'v' ;
3188
3185
break ;
3189
3186
default :
3187
+ /* If it's the delimiter, must backslash it */
3188
+ if (c == delimc )
3189
+ break ;
3190
3190
/* All ASCII control chars are length 1 */
3191
3191
ptr ++ ;
3192
3192
continue ; /* fall to end of loop */
@@ -3197,6 +3197,12 @@ CopyAttributeOutText(CopyState cstate, char *string)
3197
3197
CopySendChar (cstate , c );
3198
3198
start = ++ ptr ; /* do not include char in next run */
3199
3199
}
3200
+ else if (c == '\\' || c == delimc )
3201
+ {
3202
+ DUMPSOFAR ();
3203
+ CopySendChar (cstate , '\\' );
3204
+ start = ptr ++ ; /* we include char in next run */
3205
+ }
3200
3206
else
3201
3207
ptr ++ ;
3202
3208
}
0 commit comments