> > I'm using text[] arrays. Some of my array elements have '"'

> > characters in them.  Dumping and reloading using pg_dumpall >
> doesn't work with this and dumping the entire array and > > then
trying to parse it is hopeless.

Doug Gibson
This commit is contained in:
Bruce Momjian 1998-03-20 03:44:19 +00:00
parent 80f7c41388
commit d705aa8136
1 changed files with 14 additions and 4 deletions

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.27 1998/02/26 04:36:50 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.28 1998/03/20 03:44:19 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -624,7 +624,7 @@ array_out(ArrayType *v, Oid element_type)
FmgrInfo outputproc; FmgrInfo outputproc;
char typalign; char typalign;
char *p, char *p, *tmp,
*retval, *retval,
**values, **values,
delim[2]; delim[2];
@ -633,6 +633,7 @@ array_out(ArrayType *v, Oid element_type)
i, i,
j, j,
k, k,
l,
indx[MAXDIM]; indx[MAXDIM];
bool dummy_bool; bool dummy_bool;
int ndim, int ndim,
@ -713,7 +714,11 @@ array_out(ArrayType *v, Oid element_type)
*/ */
overall_length += 2; overall_length += 2;
} }
overall_length += (strlen(values[i]) + 1); for (tmp=values[i];*tmp;tmp++) {
overall_length += 1;
if (*tmp=='"') overall_length += 1;
}
overall_length += 1;
} }
/* /*
@ -740,7 +745,12 @@ array_out(ArrayType *v, Oid element_type)
if (!typbyval) if (!typbyval)
{ {
strcat(p, "\""); strcat(p, "\"");
strcat(p, values[k]); l=strlen(p);
for (tmp=values[k];*tmp;tmp++) {
if (*tmp=='"') p[l++]='\\';
p[l++]=*tmp;
}
p[l]='\0';
strcat(p, "\""); strcat(p, "\"");
} }
else else