Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9affed2

Browse files
tglsfdcnmisch
authored andcommitted
pg_dump: provide a stable sort order for rules.
Previously, we sorted rules by schema name and then rule name;if that wasn't unique, we sorted by rule OID. This can beproblematic for comparing dumps from databases with differenthistories, especially since certain rule names like "_RETURN"are very common. Let's make the sort key schema name, rule name,table name, which should be unique. (This is the same behaviorwe've long used for triggers and RLS policies.)Andreas KarlssonThis back-patches v18 commit350e6b8 toall supported branches. The next commit will assert that pg_dumpprovides a stable sort order for all object types. That assertion wouldfail without stabilizing DO_RULE order as this commit did.Discussion:https://postgr.es/m/b4e468d8-0cd6-42e6-ac8a-1d6afa6e0cf1@proxel.seDiscussion:https://postgr.es/m/20250707192654.9e.nmisch@google.comBackpatch-through: 13-17
1 parentc1984be commit9affed2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

‎src/bin/pg_dump/pg_dump_sort.c‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,17 @@ DOTypeNameCompare(const void *p1, const void *p2)
291291
if (cmpval!=0)
292292
returncmpval;
293293
}
294+
elseif (obj1->objType==DO_RULE)
295+
{
296+
RuleInfo*robj1=*(RuleInfo*const*)p1;
297+
RuleInfo*robj2=*(RuleInfo*const*)p2;
298+
299+
/* Sort by table name (table namespace was considered already) */
300+
cmpval=strcmp(robj1->ruletable->dobj.name,
301+
robj2->ruletable->dobj.name);
302+
if (cmpval!=0)
303+
returncmpval;
304+
}
294305
elseif (obj1->objType==DO_TRIGGER)
295306
{
296307
TriggerInfo*tobj1=*(TriggerInfo*const*)p1;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp