Skip to content

Commit 27d2c12

Browse files
committed
pg_dump: Separate table and sequence data object types
Instead of handling both sequence data and table data internally as "table data", handle sequences separately under a "sequence set" type. We already handled materialized view data differently, so it makes the code somewhat cleaner to handle each relation kind separately at the top level. This does not change the output format, since there already was a separate "SEQUENCE SET" archive entry type. A noticeable difference is that SEQUENCE SET entries now always appear after TABLE DATA entries. And in parallel mode there is less sorting to do, because the sequence data entries are no longer considered table data. Reviewed-by: Anastasia Lubennikova <[email protected]> Reviewed-by: Michael Paquier <[email protected]>
1 parent d5d8a0b commit 27d2c12

File tree

3 files changed

+25
-15
lines changed

3 files changed

+25
-15
lines changed

src/bin/pg_dump/pg_dump.c

+7-4
Original file line numberDiff line numberDiff line change
@@ -2090,6 +2090,8 @@ makeTableDataInfo(DumpOptions *dopt, TableInfo *tbinfo, bool oids)
20902090

20912091
if (tbinfo->relkind == RELKIND_MATVIEW)
20922092
tdinfo->dobj.objType = DO_REFRESH_MATVIEW;
2093+
else if (tbinfo->relkind == RELKIND_SEQUENCE)
2094+
tdinfo->dobj.objType = DO_SEQUENCE_SET;
20932095
else
20942096
tdinfo->dobj.objType = DO_TABLE_DATA;
20952097

@@ -8498,11 +8500,11 @@ dumpDumpableObject(Archive *fout, DumpableObject *dobj)
84988500
case DO_TRANSFORM:
84998501
dumpTransform(fout, (TransformInfo *) dobj);
85008502
break;
8503+
case DO_SEQUENCE_SET:
8504+
dumpSequenceData(fout, (TableDataInfo *) dobj);
8505+
break;
85018506
case DO_TABLE_DATA:
8502-
if (((TableDataInfo *) dobj)->tdtable->relkind == RELKIND_SEQUENCE)
8503-
dumpSequenceData(fout, (TableDataInfo *) dobj);
8504-
else
8505-
dumpTableData(fout, (TableDataInfo *) dobj);
8507+
dumpTableData(fout, (TableDataInfo *) dobj);
85068508
break;
85078509
case DO_DUMMY_TYPE:
85088510
/* table rowtypes and array types are never dumped separately */
@@ -16226,6 +16228,7 @@ addBoundaryDependencies(DumpableObject **dobjs, int numObjs,
1622616228
addObjectDependency(preDataBound, dobj->dumpId);
1622716229
break;
1622816230
case DO_TABLE_DATA:
16231+
case DO_SEQUENCE_SET:
1622916232
case DO_BLOB_DATA:
1623016233
/* Data objects: must come between the boundaries */
1623116234
addObjectDependency(dobj, preDataBound->dumpId);

src/bin/pg_dump/pg_dump.h

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ typedef enum
6363
DO_PROCLANG,
6464
DO_CAST,
6565
DO_TABLE_DATA,
66+
DO_SEQUENCE_SET,
6667
DO_DUMMY_TYPE,
6768
DO_TSPARSER,
6869
DO_TSDICT,

src/bin/pg_dump/pg_dump_sort.c

+17-11
Original file line numberDiff line numberDiff line change
@@ -47,30 +47,31 @@ static const int dbObjectTypePriority[] =
4747
11, /* DO_CONVERSION */
4848
18, /* DO_TABLE */
4949
20, /* DO_ATTRDEF */
50-
27, /* DO_INDEX */
51-
28, /* DO_RULE */
52-
29, /* DO_TRIGGER */
53-
26, /* DO_CONSTRAINT */
54-
30, /* DO_FK_CONSTRAINT */
50+
28, /* DO_INDEX */
51+
29, /* DO_RULE */
52+
30, /* DO_TRIGGER */
53+
27, /* DO_CONSTRAINT */
54+
31, /* DO_FK_CONSTRAINT */
5555
2, /* DO_PROCLANG */
5656
10, /* DO_CAST */
5757
23, /* DO_TABLE_DATA */
58+
24, /* DO_SEQUENCE_SET */
5859
19, /* DO_DUMMY_TYPE */
5960
12, /* DO_TSPARSER */
6061
14, /* DO_TSDICT */
6162
13, /* DO_TSTEMPLATE */
6263
15, /* DO_TSCONFIG */
6364
16, /* DO_FDW */
6465
17, /* DO_FOREIGN_SERVER */
65-
31, /* DO_DEFAULT_ACL */
66+
32, /* DO_DEFAULT_ACL */
6667
3, /* DO_TRANSFORM */
6768
21, /* DO_BLOB */
68-
24, /* DO_BLOB_DATA */
69+
25, /* DO_BLOB_DATA */
6970
22, /* DO_PRE_DATA_BOUNDARY */
70-
25, /* DO_POST_DATA_BOUNDARY */
71-
32, /* DO_EVENT_TRIGGER */
72-
33, /* DO_REFRESH_MATVIEW */
73-
34 /* DO_POLICY */
71+
26, /* DO_POST_DATA_BOUNDARY */
72+
33, /* DO_EVENT_TRIGGER */
73+
34, /* DO_REFRESH_MATVIEW */
74+
35 /* DO_POLICY */
7475
};
7576

7677
static DumpId preDataBoundId;
@@ -1345,6 +1346,11 @@ describeDumpableObject(DumpableObject *obj, char *buf, int bufsize)
13451346
"TABLE DATA %s (ID %d OID %u)",
13461347
obj->name, obj->dumpId, obj->catId.oid);
13471348
return;
1349+
case DO_SEQUENCE_SET:
1350+
snprintf(buf, bufsize,
1351+
"SEQUENCE SET %s (ID %d OID %u)",
1352+
obj->name, obj->dumpId, obj->catId.oid);
1353+
return;
13481354
case DO_DUMMY_TYPE:
13491355
snprintf(buf, bufsize,
13501356
"DUMMY TYPE %s (ID %d OID %u)",

0 commit comments

Comments
 (0)