From: Bruce Momjian Date: Fri, 20 Mar 1998 03:44:19 +0000 (+0000) Subject: > > I'm using text[] arrays. Some of my array elements have '"' X-Git-Tag: REL6_3_2~126 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d705aa813670d0dfab7b6f444609c5629cc4b008;p=thirdparty%2Fpostgresql.git > > 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 --- diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c index 50c42c11207..6844c584124 100644 --- a/src/backend/utils/adt/arrayfuncs.c +++ b/src/backend/utils/adt/arrayfuncs.c @@ -7,7 +7,7 @@ * * * 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; char typalign; - char *p, + char *p, *tmp, *retval, **values, delim[2]; @@ -633,6 +633,7 @@ array_out(ArrayType *v, Oid element_type) i, j, k, + l, indx[MAXDIM]; bool dummy_bool; int ndim, @@ -713,7 +714,11 @@ array_out(ArrayType *v, Oid element_type) */ 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) { 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, "\""); } else