From 1f8db153985a3e22738f7406477f80970f5c7091 Mon Sep 17 00:00:00 2001 From: Vignesh C Date: Mon, 15 Dec 2025 23:27:40 +0530 Subject: [PATCH] Fix pg_dump crash for DO_SUBSCRIPTION_REL sorting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pg_dump did not fully order DO_SUBSCRIPTION_REL objects. When multiple subscription–relation entries belonged to the same subscription, the comparison fell through to the assertion path and crashed. Fix this by extending the comparison to order such entries by the referenced table's schema name and table name. --- src/bin/pg_dump/pg_dump_sort.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/bin/pg_dump/pg_dump_sort.c b/src/bin/pg_dump/pg_dump_sort.c index 164c76e0864..4a02e1da8b0 100644 --- a/src/bin/pg_dump/pg_dump_sort.c +++ b/src/bin/pg_dump/pg_dump_sort.c @@ -454,6 +454,20 @@ DOTypeNameCompare(const void *p1, const void *p2) if (cmpval != 0) return cmpval; } + else if (obj1->objType == DO_SUBSCRIPTION_REL) + { + SubRelInfo *srobj1 = *(SubRelInfo *const *) p1; + SubRelInfo *srobj2 = *(SubRelInfo *const *) p2; + + /* Sort by schema name (subscription name was already considered) */ + cmpval = strcmp(srobj1->tblinfo->dobj.namespace->dobj.name, + srobj2->tblinfo->dobj.namespace->dobj.name); + if (cmpval != 0) + return cmpval; + + /* Sort by table name */ + return strcmp(srobj1->tblinfo->dobj.name, srobj2->tblinfo->dobj.name); + } /* * Shouldn't get here except after catalog corruption, but if we do, sort -- 2.43.0