aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_dump/pg_dump_sort.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/bin/pg_dump/pg_dump_sort.c b/src/bin/pg_dump/pg_dump_sort.c
index 410d1790ee1..5399ec1cd9f 100644
--- a/src/bin/pg_dump/pg_dump_sort.c
+++ b/src/bin/pg_dump/pg_dump_sort.c
@@ -34,6 +34,15 @@
* restore state). If you think to change this, see also the RestorePass
* mechanism in pg_backup_archiver.c.
*
+ * On the other hand, casts are intentionally sorted earlier than you might
+ * expect; logically they should come after functions, since they usually
+ * depend on those. This works around the backend's habit of recording
+ * views that use casts as dependent on the cast's underlying function.
+ * We initially sort casts first, and then any functions used by casts
+ * will be hoisted above the casts, and in turn views that those functions
+ * depend on will be hoisted above the functions. But views not used that
+ * way won't be hoisted.
+ *
* NOTE: object-type priorities must match the section assignments made in
* pg_dump.c; that is, PRE_DATA objects must sort before DO_PRE_DATA_BOUNDARY,
* POST_DATA objects must sort after DO_POST_DATA_BOUNDARY, and DATA objects
@@ -49,12 +58,12 @@ enum dbObjectTypePriorities
PRIO_TRANSFORM,
PRIO_EXTENSION,
PRIO_TYPE, /* used for DO_TYPE and DO_SHELL_TYPE */
+ PRIO_CAST,
PRIO_FUNC,
PRIO_AGG,
PRIO_ACCESS_METHOD,
PRIO_OPERATOR,
PRIO_OPFAMILY, /* used for DO_OPFAMILY and DO_OPCLASS */
- PRIO_CAST,
PRIO_CONVERSION,
PRIO_TSPARSER,
PRIO_TSTEMPLATE,