*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup.h,v 1.24 2002/09/04 20:31:34 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup.h,v 1.25 2003/08/28 20:21:34 tgl Exp $
*
*-------------------------------------------------------------------------
*/
extern RestoreOptions *NewRestoreOptions(void);
/* Rearrange TOC entries */
-extern void MoveToStart(Archive *AH, char *oType);
-extern void MoveToEnd(Archive *AH, char *oType);
+extern void MoveToStart(Archive *AH, const char *oType);
+extern void MoveToEnd(Archive *AH, const char *oType);
+extern void SortTocByObjectType(Archive *AH);
extern void SortTocByOID(Archive *AH);
extern void SortTocByID(Archive *AH);
extern void SortTocFromFile(Archive *AH, RestoreOptions *ropt);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.74 2003/08/04 00:43:27 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.75 2003/08/28 20:21:34 tgl Exp $
*
*-------------------------------------------------------------------------
*/
/*
* Move TOC entries of the specified type to the START of the TOC.
+ *
+ * This is public, but if you use it anywhere but SortTocByObjectType,
+ * you are risking breaking things.
*/
-
-/* Public */
void
-MoveToStart(Archive *AHX, char *oType)
+MoveToStart(Archive *AHX, const char *oType)
{
ArchiveHandle *AH = (ArchiveHandle *) AHX;
TocEntry *te = AH->toc->next;
/*
* Move TOC entries of the specified type to the end of the TOC.
+ *
+ * This is public, but if you use it anywhere but SortTocByObjectType,
+ * you are risking breaking things.
*/
-/* Public */
void
-MoveToEnd(Archive *AHX, char *oType)
+MoveToEnd(Archive *AHX, const char *oType)
{
ArchiveHandle *AH = (ArchiveHandle *) AHX;
TocEntry *te = AH->toc->next;
}
/*
+ * Sort TOC by object type (items of same type keep same relative order)
+ *
+ * This is factored out to ensure that pg_dump and pg_restore stay in sync
+ * about the standard ordering.
+ */
+void
+SortTocByObjectType(Archive *AH)
+{
+ /*
+ * Procedural languages have to be declared just after database and
+ * schema creation, before they are used.
+ */
+ MoveToStart(AH, "ACL LANGUAGE");
+ MoveToStart(AH, "PROCEDURAL LANGUAGE");
+ MoveToStart(AH, "FUNC PROCEDURAL LANGUAGE");
+ MoveToStart(AH, "SCHEMA");
+ MoveToStart(AH, "<Init>");
+ /* Database entries *must* be at front (see also pg_restore.c) */
+ MoveToStart(AH, "DATABASE");
+
+ MoveToEnd(AH, "TABLE DATA");
+ MoveToEnd(AH, "BLOBS");
+ MoveToEnd(AH, "INDEX");
+ MoveToEnd(AH, "CONSTRAINT");
+ MoveToEnd(AH, "FK CONSTRAINT");
+ MoveToEnd(AH, "TRIGGER");
+ MoveToEnd(AH, "RULE");
+ MoveToEnd(AH, "SEQUENCE SET");
+
+ /*
+ * Moving all comments to end is annoying, but must do it for comments
+ * on stuff we just moved, and we don't seem to have quite enough
+ * dependency structure to get it really right...
+ */
+ MoveToEnd(AH, "COMMENT");
+}
+
+/*
* Sort TOC by OID
*/
/* Public */
* by PostgreSQL
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.345 2003/08/28 18:59:06 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.346 2003/08/28 20:21:34 tgl Exp $
*
*-------------------------------------------------------------------------
*/
dumpRules(g_fout, tblinfo, numTables);
}
- /* Now sort the output nicely */
+ /* Now sort the output nicely: by OID within object types */
SortTocByOID(g_fout);
-
- /*
- * Procedural languages have to be declared just after database and
- * schema creation, before they are used.
- */
- MoveToStart(g_fout, "ACL LANGUAGE");
- MoveToStart(g_fout, "PROCEDURAL LANGUAGE");
- MoveToStart(g_fout, "FUNC PROCEDURAL LANGUAGE");
- MoveToStart(g_fout, "SCHEMA");
- MoveToStart(g_fout, "DATABASE");
- MoveToEnd(g_fout, "TABLE DATA");
- MoveToEnd(g_fout, "BLOBS");
- MoveToEnd(g_fout, "INDEX");
- MoveToEnd(g_fout, "CONSTRAINT");
- MoveToEnd(g_fout, "FK CONSTRAINT");
- MoveToEnd(g_fout, "TRIGGER");
- MoveToEnd(g_fout, "RULE");
- MoveToEnd(g_fout, "SEQUENCE SET");
-
- /*
- * Moving all comments to end is annoying, but must do it for comments
- * on stuff we just moved, and we don't seem to have quite enough
- * dependency structure to get it really right...
- */
- MoveToEnd(g_fout, "COMMENT");
+ SortTocByObjectType(g_fout);
if (plainText)
{
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_restore.c,v 1.50 2003/08/07 21:11:58 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_restore.c,v 1.51 2003/08/28 20:21:34 tgl Exp $
*
*-------------------------------------------------------------------------
*/
SortTocByID(AH);
if (opts->rearrange)
+ SortTocByObjectType(AH);
+ else
{
- MoveToStart(AH, "<Init>");
- MoveToEnd(AH, "TABLE DATA");
- MoveToEnd(AH, "BLOBS");
- MoveToEnd(AH, "INDEX");
- MoveToEnd(AH, "TRIGGER");
- MoveToEnd(AH, "RULE");
- MoveToEnd(AH, "SEQUENCE SET");
+ /* Database MUST be at start (see also SortTocByObjectType) */
+ MoveToStart(AH, "DATABASE");
}
- /* Database MUST be at start */
- MoveToStart(AH, "DATABASE");
-
if (opts->tocSummary)
PrintTOCSummary(AH, opts);
else