From d705aa813670d0dfab7b6f444609c5629cc4b008 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Fri, 20 Mar 1998 03:44:19 +0000 Subject: [PATCH] > > 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 --- src/backend/utils/adt/arrayfuncs.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c index 50c42c1120..6844c58412 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