@@ -261,8 +261,8 @@ static void binary_upgrade_extension_member(PQExpBuffer upgrade_buffer,
261
261
static const char *getAttrName(int attrnum, TableInfo *tblInfo);
262
262
static const char *fmtCopyColumnList(const TableInfo *ti, PQExpBuffer buffer);
263
263
static bool nonemptyReloptions(const char *reloptions);
264
- static void fmtReloptionsArray(Archive *fout, PQExpBuffer buffer ,
265
- const char *reloptions, const char *prefix );
264
+ static void appendReloptionsArrayAH(PQExpBuffer buffer, const char *reloptions ,
265
+ const char *prefix, Archive *fout );
266
266
static char *get_synchronized_snapshot(Archive *fout);
267
267
static PGresult *ExecuteSqlQueryForSingleRow(Archive *fout, char *query);
268
268
static void setupDumpWorker(Archive *AHX);
@@ -15046,7 +15046,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
15046
15046
if (nonemptyReloptions(tbinfo->reloptions))
15047
15047
{
15048
15048
appendPQExpBufferStr(q, " WITH (");
15049
- fmtReloptionsArray(fout, q, tbinfo->reloptions, "");
15049
+ appendReloptionsArrayAH( q, tbinfo->reloptions, "", fout );
15050
15050
appendPQExpBufferChar(q, ')');
15051
15051
}
15052
15052
result = createViewAsClause(fout, tbinfo);
@@ -15301,13 +15301,14 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
15301
15301
if (nonemptyReloptions(tbinfo->reloptions))
15302
15302
{
15303
15303
addcomma = true;
15304
- fmtReloptionsArray(fout, q, tbinfo->reloptions, "");
15304
+ appendReloptionsArrayAH( q, tbinfo->reloptions, "", fout );
15305
15305
}
15306
15306
if (nonemptyReloptions(tbinfo->toast_reloptions))
15307
15307
{
15308
15308
if (addcomma)
15309
15309
appendPQExpBufferStr(q, ", ");
15310
- fmtReloptionsArray(fout, q, tbinfo->toast_reloptions, "toast.");
15310
+ appendReloptionsArrayAH(q, tbinfo->toast_reloptions, "toast.",
15311
+ fout);
15311
15312
}
15312
15313
appendPQExpBufferChar(q, ')');
15313
15314
}
@@ -15908,7 +15909,7 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
15908
15909
if (nonemptyReloptions(indxinfo->indreloptions))
15909
15910
{
15910
15911
appendPQExpBufferStr(q, " WITH (");
15911
- fmtReloptionsArray(fout, q, indxinfo->indreloptions, "");
15912
+ appendReloptionsArrayAH( q, indxinfo->indreloptions, "", fout );
15912
15913
appendPQExpBufferChar(q, ')');
15913
15914
}
15914
15915
@@ -16809,7 +16810,7 @@ dumpRule(Archive *fout, RuleInfo *rinfo)
16809
16810
{
16810
16811
appendPQExpBuffer(cmd, "ALTER VIEW %s SET (",
16811
16812
fmtId(tbinfo->dobj.name));
16812
- fmtReloptionsArray(fout, cmd, rinfo->reloptions, "");
16813
+ appendReloptionsArrayAH( cmd, rinfo->reloptions, "", fout );
16813
16814
appendPQExpBufferStr(cmd, ");\n");
16814
16815
}
16815
16816
@@ -17707,67 +17708,17 @@ nonemptyReloptions(const char *reloptions)
17707
17708
* Format a reloptions array and append it to the given buffer.
17708
17709
*
17709
17710
* "prefix" is prepended to the option names; typically it's "" or "toast.".
17710
- *
17711
- * Note: this logic should generally match the backend's flatten_reloptions()
17712
- * (in adt/ruleutils.c).
17713
17711
*/
17714
17712
static void
17715
- fmtReloptionsArray(Archive *fout, PQExpBuffer buffer, const char *reloptions,
17716
- const char *prefix)
17713
+ appendReloptionsArrayAH( PQExpBuffer buffer, const char *reloptions,
17714
+ const char *prefix, Archive *fout )
17717
17715
{
17718
- char **options;
17719
- int noptions;
17720
- int i;
17716
+ bool res;
17721
17717
17722
- if (!parsePGArray(reloptions, &options, &noptions))
17723
- {
17718
+ res = appendReloptionsArray(buffer, reloptions, prefix, fout->encoding,
17719
+ fout->std_strings);
17720
+ if (!res)
17724
17721
write_msg(NULL, "WARNING: could not parse reloptions array\n");
17725
- if (options)
17726
- free(options);
17727
- return;
17728
- }
17729
-
17730
- for (i = 0; i < noptions; i++)
17731
- {
17732
- char *option = options[i];
17733
- char *name;
17734
- char *separator;
17735
- char *value;
17736
-
17737
- /*
17738
- * Each array element should have the form name=value. If the "=" is
17739
- * missing for some reason, treat it like an empty value.
17740
- */
17741
- name = option;
17742
- separator = strchr(option, '=');
17743
- if (separator)
17744
- {
17745
- *separator = '\0';
17746
- value = separator + 1;
17747
- }
17748
- else
17749
- value = "";
17750
-
17751
- if (i > 0)
17752
- appendPQExpBufferStr(buffer, ", ");
17753
- appendPQExpBuffer(buffer, "%s%s=", prefix, fmtId(name));
17754
-
17755
- /*
17756
- * In general we need to quote the value; but to avoid unnecessary
17757
- * clutter, do not quote if it is an identifier that would not need
17758
- * quoting. (We could also allow numbers, but that is a bit trickier
17759
- * than it looks --- for example, are leading zeroes significant? We
17760
- * don't want to assume very much here about what custom reloptions
17761
- * might mean.)
17762
- */
17763
- if (strcmp(fmtId(value), value) == 0)
17764
- appendPQExpBufferStr(buffer, value);
17765
- else
17766
- appendStringLiteralAH(buffer, value, fout);
17767
- }
17768
-
17769
- if (options)
17770
- free(options);
17771
17722
}
17772
17723
17773
17724
/*
0 commit comments