Another patch that was put into 2.x and not into 1.x
From Bruce...
This commit is contained in:
parent
2f9ee44f2b
commit
20d44ee41f
@ -6,7 +6,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.2.2.2 1996/08/26 06:53:03 scrappy Exp $
|
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.2.2.3 1996/10/28 22:09:30 scrappy Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -109,7 +109,7 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe, char *filena
|
|||||||
if (!pipe) {
|
if (!pipe) {
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}else if (!from && !binary) {
|
}else if (!from && !binary) {
|
||||||
fputs(".\n", fp);
|
fputs("\\.\n", fp);
|
||||||
if (IsUnderPostmaster) fflush(Pfout);
|
if (IsUnderPostmaster) fflush(Pfout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -176,6 +176,9 @@ CopyTo(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
|
|||||||
CopyAttributeOut(fp, string, delim);
|
CopyAttributeOut(fp, string, delim);
|
||||||
pfree(string);
|
pfree(string);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
fputs("\\N", fp); /* null indicator */
|
||||||
|
|
||||||
if (i == attr_count - 1) {
|
if (i == attr_count - 1) {
|
||||||
fputc('\n', fp);
|
fputc('\n', fp);
|
||||||
}else {
|
}else {
|
||||||
@ -731,40 +734,21 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim)
|
|||||||
int done = 0;
|
int done = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
if (feof(fp)) {
|
if (feof(fp))
|
||||||
*isnull = (bool) false;
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
|
||||||
|
|
||||||
while (!done) {
|
while (!done) {
|
||||||
c = getc(fp);
|
c = getc(fp);
|
||||||
|
|
||||||
if (feof(fp)) {
|
if (feof(fp))
|
||||||
*isnull = (bool) false;
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}else if (reading_from_input && i == 0 && c == '.') {
|
|
||||||
attribute[0] = c;
|
|
||||||
c = getc(fp);
|
|
||||||
if (c == '\n') {
|
|
||||||
*isnull = (bool) false;
|
|
||||||
return(NULL);
|
|
||||||
}else if (inString(c,delim)) {
|
|
||||||
attribute[1] = 0;
|
|
||||||
*isnull = (bool) false;
|
|
||||||
return(&attribute[0]);
|
|
||||||
}else {
|
|
||||||
attribute[1] = c;
|
|
||||||
i = 2;
|
|
||||||
}
|
|
||||||
}else if (c == '\\') {
|
}else if (c == '\\') {
|
||||||
c = getc(fp);
|
c = getc(fp);
|
||||||
#ifdef ESCAPE_PATCH
|
#ifdef ESCAPE_PATCH
|
||||||
#define ISOCTAL(c) (((c) >= '0') && ((c) <= '7'))
|
#define ISOCTAL(c) (((c) >= '0') && ((c) <= '7'))
|
||||||
#define VALUE(c) ((c) - '0')
|
#define VALUE(c) ((c) - '0')
|
||||||
if (feof(fp)) {
|
if (feof(fp))
|
||||||
*isnull = (bool) false;
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '0':
|
case '0':
|
||||||
case '1':
|
case '1':
|
||||||
@ -783,21 +767,17 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim)
|
|||||||
if (ISOCTAL(c)) {
|
if (ISOCTAL(c)) {
|
||||||
val = (val<<3) + VALUE(c);
|
val = (val<<3) + VALUE(c);
|
||||||
} else {
|
} else {
|
||||||
if (feof(fp)) {
|
if (feof(fp))
|
||||||
*isnull = (bool) false;
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
|
||||||
ungetc(c, fp);
|
ungetc(c, fp);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (feof(fp)) {
|
if (feof(fp))
|
||||||
*isnull = (bool) false;
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
|
||||||
ungetc(c, fp);
|
ungetc(c, fp);
|
||||||
}
|
}
|
||||||
c = val & 0377;
|
c = val & 0377;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
c = '\b';
|
c = '\b';
|
||||||
@ -817,6 +797,16 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim)
|
|||||||
case 'v':
|
case 'v':
|
||||||
c = '\v';
|
c = '\v';
|
||||||
break;
|
break;
|
||||||
|
case 'N':
|
||||||
|
attribute[0] = '\0'; /* just to be safe */
|
||||||
|
*isnull = (bool) true;
|
||||||
|
break;
|
||||||
|
case '.':
|
||||||
|
c = getc(fp);
|
||||||
|
if (c != '\n')
|
||||||
|
elog(WARN, "CopyReadAttribute - end of record marker corrupted");
|
||||||
|
return(NULL);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}else if (inString(c,delim) || c == '\n') {
|
}else if (inString(c,delim) || c == '\n') {
|
||||||
@ -827,13 +817,7 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim)
|
|||||||
elog(WARN, "CopyReadAttribute - attribute length too long");
|
elog(WARN, "CopyReadAttribute - attribute length too long");
|
||||||
}
|
}
|
||||||
attribute[i] = '\0';
|
attribute[i] = '\0';
|
||||||
if (i == 0) {
|
return(&attribute[0]);
|
||||||
*isnull = (bool) true;
|
|
||||||
return(NULL);
|
|
||||||
}else {
|
|
||||||
*isnull = (bool) false;
|
|
||||||
return(&attribute[0]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ESCAPE_PATCH
|
#ifdef ESCAPE_PATCH
|
||||||
@ -845,26 +829,26 @@ CopyAttributeOut(FILE *fp, char *string, char *delim)
|
|||||||
int len = strlen(string);
|
int len = strlen(string);
|
||||||
|
|
||||||
/* XXX - This is a kludge, we should check the data type */
|
/* XXX - This is a kludge, we should check the data type */
|
||||||
if (len && (string[0] == '{') && (string[len-1] == '}')) {
|
if (len && (string[0] == '{') && (string[len-1] == '}'))
|
||||||
is_array = true;
|
is_array = true;
|
||||||
}
|
|
||||||
|
|
||||||
for ( ; c = *string; string++) {
|
for ( ; c = *string; string++) {
|
||||||
if ((c == delim[0]) || (c == '\n')) {
|
if (c == delim[0] || c == '\n' ||
|
||||||
|
(c == '\\' && !is_array))
|
||||||
fputc('\\', fp);
|
fputc('\\', fp);
|
||||||
} else if ((c == '\\') && is_array) {
|
else
|
||||||
if (*(string+1) == '\\') {
|
if (c == '\\' && is_array)
|
||||||
/* translate \\ to \\\\ */
|
if (*(string+1) == '\\') {
|
||||||
fputc('\\', fp);
|
/* translate \\ to \\\\ */
|
||||||
fputc('\\', fp);
|
fputc('\\', fp);
|
||||||
fputc('\\', fp);
|
fputc('\\', fp);
|
||||||
string++;
|
fputc('\\', fp);
|
||||||
} else if (*(string+1) == '"') {
|
string++;
|
||||||
/* translate \" to \\\" */
|
} else if (*(string+1) == '"') {
|
||||||
fputc('\\', fp);
|
/* translate \" to \\\" */
|
||||||
fputc('\\', fp);
|
fputc('\\', fp);
|
||||||
}
|
fputc('\\', fp);
|
||||||
}
|
}
|
||||||
fputc(*string, fp);
|
fputc(*string, fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.5.2.2 1996/10/02 21:39:29 scrappy Exp $
|
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.5.2.3 1996/10/28 22:09:39 scrappy Exp $
|
||||||
*
|
*
|
||||||
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
|
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
|
||||||
*
|
*
|
||||||
@ -1405,7 +1405,9 @@ dumpClasses(TableInfo *tblinfo, int numTables, FILE *fout, char *onlytable, int
|
|||||||
while (!copydone) {
|
while (!copydone) {
|
||||||
ret = PQgetline(res->conn, copybuf, COPYBUFSIZ);
|
ret = PQgetline(res->conn, copybuf, COPYBUFSIZ);
|
||||||
|
|
||||||
if (copybuf[0] == '.' && copybuf[1] =='\0') {
|
if (copybuf[0] == '\\' &&
|
||||||
|
copybuf[1] == '.' &&
|
||||||
|
copybuf[2] == '\0') {
|
||||||
copydone = true; /* don't print this... */
|
copydone = true; /* don't print this... */
|
||||||
} else {
|
} else {
|
||||||
fputs(copybuf, fout);
|
fputs(copybuf, fout);
|
||||||
@ -1421,7 +1423,7 @@ dumpClasses(TableInfo *tblinfo, int numTables, FILE *fout, char *onlytable, int
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fprintf(fout, ".\n");
|
fprintf(fout, "\\.\n");
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
PQendcopy(res->conn);
|
PQendcopy(res->conn);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user