fix-ext-sequence-config-dump.92.patch
text/x-patch
Filename: fix-ext-sequence-config-dump.92.patch
Type: text/x-patch
Part: 0
Message:
Re: [9.1] 2 bugs with extensions
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: context
| File | + | − |
|---|---|---|
| src/bin/pg_dump/pg_dump.c | 32 | 0 |
*** a/src/bin/pg_dump/pg_dump.c
--- b/src/bin/pg_dump/pg_dump.c
***************
*** 189,195 **** static void dumpTrigger(Archive *fout, TriggerInfo *tginfo);
static void dumpTable(Archive *fout, TableInfo *tbinfo);
static void dumpTableSchema(Archive *fout, TableInfo *tbinfo);
static void dumpAttrDef(Archive *fout, AttrDefInfo *adinfo);
! static void dumpSequence(Archive *fout, TableInfo *tbinfo);
static void dumpIndex(Archive *fout, IndxInfo *indxinfo);
static void dumpConstraint(Archive *fout, ConstraintInfo *coninfo);
static void dumpTableConstraintComment(Archive *fout, ConstraintInfo *coninfo);
--- 189,195 ----
static void dumpTable(Archive *fout, TableInfo *tbinfo);
static void dumpTableSchema(Archive *fout, TableInfo *tbinfo);
static void dumpAttrDef(Archive *fout, AttrDefInfo *adinfo);
! static void dumpSequence(Archive *fout, TableInfo *tbinfo, bool extMember);
static void dumpIndex(Archive *fout, IndxInfo *indxinfo);
static void dumpConstraint(Archive *fout, ConstraintInfo *coninfo);
static void dumpTableConstraintComment(Archive *fout, ConstraintInfo *coninfo);
***************
*** 1566,1571 **** dumpTableData(Archive *fout, TableDataInfo *tdinfo)
--- 1566,1577 ----
DataDumperPtr dumpFn;
char *copyStmt;
+ if (tbinfo->relkind == RELKIND_SEQUENCE)
+ {
+ dumpSequence(fout, tbinfo, true);
+ return;
+ }
+
if (!dump_inserts)
{
/* Dump/restore using COPY */
***************
*** 1638,1646 **** makeTableDataInfo(TableInfo *tbinfo, bool oids)
/* Skip VIEWs (no data to dump) */
if (tbinfo->relkind == RELKIND_VIEW)
return;
- /* Skip SEQUENCEs (handled elsewhere) */
- if (tbinfo->relkind == RELKIND_SEQUENCE)
- return;
/* Skip FOREIGN TABLEs (no data to dump) */
if (tbinfo->relkind == RELKIND_FOREIGN_TABLE)
return;
--- 1644,1649 ----
***************
*** 12102,12108 **** dumpTable(Archive *fout, TableInfo *tbinfo)
char *namecopy;
if (tbinfo->relkind == RELKIND_SEQUENCE)
! dumpSequence(fout, tbinfo);
else if (!dataOnly)
dumpTableSchema(fout, tbinfo);
--- 12105,12111 ----
char *namecopy;
if (tbinfo->relkind == RELKIND_SEQUENCE)
! dumpSequence(fout, tbinfo, false);
else if (!dataOnly)
dumpTableSchema(fout, tbinfo);
***************
*** 13219,13225 **** findLastBuiltinOid_V70(Archive *fout)
}
static void
! dumpSequence(Archive *fout, TableInfo *tbinfo)
{
PGresult *res;
char *startv,
--- 13222,13228 ----
}
static void
! dumpSequence(Archive *fout, TableInfo *tbinfo, bool extMember)
{
PGresult *res;
char *startv,
***************
*** 13319,13325 **** dumpSequence(Archive *fout, TableInfo *tbinfo)
*
* Add a 'SETVAL(seq, last_val, iscalled)' as part of a "data" dump.
*/
! if (!dataOnly)
{
/*
* DROP must be fully qualified in case same name appears in
--- 13322,13328 ----
*
* Add a 'SETVAL(seq, last_val, iscalled)' as part of a "data" dump.
*/
! if (!extMember && !dataOnly)
{
/*
* DROP must be fully qualified in case same name appears in
***************
*** 13440,13446 **** dumpSequence(Archive *fout, TableInfo *tbinfo)
tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId);
}
! if (!schemaOnly)
{
resetPQExpBuffer(query);
appendPQExpBuffer(query, "SELECT pg_catalog.setval(");
--- 13443,13449 ----
tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId);
}
! if (extMember || !schemaOnly)
{
resetPQExpBuffer(query);
appendPQExpBuffer(query, "SELECT pg_catalog.setval(");
***************
*** 13953,13963 **** getExtensionMembership(Archive *fout, ExtensionInfo extinfo[],
* the --oids setting. This is because row filtering
* conditions aren't compatible with dumping OIDs.
*/
! makeTableDataInfo(configtbl, false);
! if (configtbl->dataObj != NULL)
! {
! if (strlen(extconditionarray[j]) > 0)
! configtbl->dataObj->filtercond = pg_strdup(extconditionarray[j]);
}
}
}
--- 13956,13982 ----
* the --oids setting. This is because row filtering
* conditions aren't compatible with dumping OIDs.
*/
! switch (configtbl->relkind)
! {
! case RELKIND_SEQUENCE:
! makeTableDataInfo(configtbl, false);
! break;
!
! case RELKIND_RELATION:
! case RELKIND_VIEW:
! makeTableDataInfo(configtbl, false);
! if (configtbl->dataObj != NULL)
! configtbl->dataObj->filtercond =
! pg_strdup(extconditionarray[j]);
! break;
!
! case RELKIND_INDEX:
! case RELKIND_TOASTVALUE:
! case RELKIND_COMPOSITE_TYPE:
! case RELKIND_FOREIGN_TABLE:
! case RELKIND_UNCATALOGED:
! /* not supported as an extension config dump target */
! break;
}
}
}