tblinfo = getTables(fout, &numTables);
tblinfoindex = buildIndexArray(tblinfo, numTables, sizeof(TableInfo));
+ /* Do this after we've built tblinfoindex */
+ getOwnedSeqs(fout, tblinfo, numTables);
+
if (g_verbose)
write_msg(NULL, "reading extensions\n");
extinfo = getExtensions(fout, &numExtensions);
PQclear(res);
+ destroyPQExpBuffer(query);
+
+ return tblinfo;
+}
+
+/*
+ * getOwnedSeqs
+ * identify owned sequences and mark them as dumpable if owning table is
+ *
+ * We used to do this in getTables(), but it's better to do it after the
+ * index used by findTableByOid() has been set up.
+ */
+void
+getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables)
+{
+ int i;
+
/*
* Force sequences that are "owned" by table columns to be dumped whenever
* their owning table is being dumped.
*/
- for (i = 0; i < ntups; i++)
+ for (i = 0; i < numTables; i++)
{
TableInfo *seqinfo = &tblinfo[i];
- int j;
+ TableInfo *owning_tab;
if (!OidIsValid(seqinfo->owning_tab))
continue; /* not an owned sequence */
if (seqinfo->dobj.dump)
continue; /* no need to search */
-
- /* can't use findTableByOid yet, unfortunately */
- for (j = 0; j < ntups; j++)
+ owning_tab = findTableByOid(seqinfo->owning_tab);
+ if (owning_tab && owning_tab->dobj.dump)
{
- if (tblinfo[j].dobj.catId.oid == seqinfo->owning_tab)
- {
- if (tblinfo[j].dobj.dump)
- {
- seqinfo->interesting = true;
- seqinfo->dobj.dump = true;
- }
- break;
- }
+ seqinfo->interesting = true;
+ seqinfo->dobj.dump = true;
}
}
-
- destroyPQExpBuffer(query);
-
- return tblinfo;
}
/*
extern CollInfo *getCollations(Archive *fout, int *numCollations);
extern ConvInfo *getConversions(Archive *fout, int *numConversions);
extern TableInfo *getTables(Archive *fout, int *numTables);
+extern void getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables);
extern InhInfo *getInherits(Archive *fout, int *numInherits);
extern void getIndexes(Archive *fout, TableInfo tblinfo[], int numTables);
extern void getConstraints(Archive *fout, TableInfo tblinfo[], int numTables);