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

Commit078f5bc

Browse files
committed
Stabilize pg_dump output order for similarly-named triggers and policies.
The code only compared two triggers' names and namespaces (the latterbeing the owning table's schema). This could result in falling backto an OID-based sort of similarly-named triggers on different tables.We prefer to avoid that, so add a comparison of the table names too.(The sort order is thus table namespace, trigger name, table name,which is a bit odd, but it doesn't seem worth contorting the codeto work around that.)Likewise for policy objects, in 9.5 and up.Complaint and fix by Benjie Gillam. Back-patch to all supportedbranches.Discussion:https://postgr.es/m/CAMThMzEEt2mvBbPgCaZ1Ap1N-moGn=Edxmadddjq89WG4NpPtQ@mail.gmail.com
1 parent0782050 commit078f5bc

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

‎src/bin/pg_dump/pg_dump_sort.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ DOTypeNameCompare(const void *p1, const void *p2)
262262
FuncInfo*fobj2=*(FuncInfo*const*)p2;
263263
inti;
264264

265+
/* Sort by number of arguments, then argument type names */
265266
cmpval=fobj1->nargs-fobj2->nargs;
266267
if (cmpval!=0)
267268
returncmpval;
@@ -300,10 +301,33 @@ DOTypeNameCompare(const void *p1, const void *p2)
300301
AttrDefInfo*adobj1=*(AttrDefInfo*const*)p1;
301302
AttrDefInfo*adobj2=*(AttrDefInfo*const*)p2;
302303

304+
/* Sort by attribute number */
303305
cmpval= (adobj1->adnum-adobj2->adnum);
304306
if (cmpval!=0)
305307
returncmpval;
306308
}
309+
elseif (obj1->objType==DO_POLICY)
310+
{
311+
PolicyInfo*pobj1=*(PolicyInfo*const*)p1;
312+
PolicyInfo*pobj2=*(PolicyInfo*const*)p2;
313+
314+
/* Sort by table name (table namespace was considered already) */
315+
cmpval=strcmp(pobj1->poltable->dobj.name,
316+
pobj2->poltable->dobj.name);
317+
if (cmpval!=0)
318+
returncmpval;
319+
}
320+
elseif (obj1->objType==DO_TRIGGER)
321+
{
322+
TriggerInfo*tobj1=*(TriggerInfo*const*)p1;
323+
TriggerInfo*tobj2=*(TriggerInfo*const*)p2;
324+
325+
/* Sort by table name (table namespace was considered already) */
326+
cmpval=strcmp(tobj1->tgtable->dobj.name,
327+
tobj2->tgtable->dobj.name);
328+
if (cmpval!=0)
329+
returncmpval;
330+
}
307331

308332
/* Usually shouldn't get here, but if we do, sort by OID */
309333
returnoidcmp(obj1->catId.oid,obj2->catId.oid);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp