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

Commit15df037

Browse files
committed
pg_dump: Dump operators with the same name ordered by arity
pg_dump sorts operators by name, but operators with the same name comeout in random order. Now operators with the same name are dumped inthe order prefix, postfix, infix. (This is consistent with functions,which are dumped in increasing number of argument order.)
1 parent104e7da commit15df037

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

‎src/bin/pg_dump/pg_dump.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3138,6 +3138,7 @@ getOperators(int *numOprs)
31383138
inti_oprname;
31393139
inti_oprnamespace;
31403140
inti_rolname;
3141+
inti_oprkind;
31413142
inti_oprcode;
31423143

31433144
/*
@@ -3153,6 +3154,7 @@ getOperators(int *numOprs)
31533154
appendPQExpBuffer(query,"SELECT tableoid, oid, oprname, "
31543155
"oprnamespace, "
31553156
"(%s oprowner) AS rolname, "
3157+
"oprkind, "
31563158
"oprcode::oid AS oprcode "
31573159
"FROM pg_operator",
31583160
username_subquery);
@@ -3162,6 +3164,7 @@ getOperators(int *numOprs)
31623164
appendPQExpBuffer(query,"SELECT tableoid, oid, oprname, "
31633165
"0::oid AS oprnamespace, "
31643166
"(%s oprowner) AS rolname, "
3167+
"oprkind, "
31653168
"oprcode::oid AS oprcode "
31663169
"FROM pg_operator",
31673170
username_subquery);
@@ -3173,6 +3176,7 @@ getOperators(int *numOprs)
31733176
"oid, oprname, "
31743177
"0::oid AS oprnamespace, "
31753178
"(%s oprowner) AS rolname, "
3179+
"oprkind, "
31763180
"oprcode::oid AS oprcode "
31773181
"FROM pg_operator",
31783182
username_subquery);
@@ -3191,6 +3195,7 @@ getOperators(int *numOprs)
31913195
i_oprname=PQfnumber(res,"oprname");
31923196
i_oprnamespace=PQfnumber(res,"oprnamespace");
31933197
i_rolname=PQfnumber(res,"rolname");
3198+
i_oprkind=PQfnumber(res,"oprkind");
31943199
i_oprcode=PQfnumber(res,"oprcode");
31953200

31963201
for (i=0;i<ntups;i++)
@@ -3203,6 +3208,7 @@ getOperators(int *numOprs)
32033208
oprinfo[i].dobj.namespace=findNamespace(atooid(PQgetvalue(res,i,i_oprnamespace)),
32043209
oprinfo[i].dobj.catId.oid);
32053210
oprinfo[i].rolname=pg_strdup(PQgetvalue(res,i,i_rolname));
3211+
oprinfo[i].oprkind= (PQgetvalue(res,i,i_oprkind))[0];
32063212
oprinfo[i].oprcode=atooid(PQgetvalue(res,i,i_oprcode));
32073213

32083214
/* Decide whether we want to dump it */

‎src/bin/pg_dump/pg_dump.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ typedef struct _oprInfo
204204
{
205205
DumpableObjectdobj;
206206
char*rolname;
207+
charoprkind;
207208
Oidoprcode;
208209
}OprInfo;
209210

‎src/bin/pg_dump/pg_dump_sort.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,16 @@ DOTypeNameCompare(const void *p1, const void *p2)
178178
if (cmpval!=0)
179179
returncmpval;
180180
}
181+
elseif (obj1->objType==DO_OPERATOR)
182+
{
183+
OprInfo*oobj1=*(OprInfo*const*)p1;
184+
OprInfo*oobj2=*(OprInfo*const*)p2;
185+
186+
/* oprkind is 'l', 'r', or 'b'; this sorts prefix, postfix, infix */
187+
cmpval= (oobj2->oprkind-oobj1->oprkind);
188+
if (cmpval!=0)
189+
returncmpval;
190+
}
181191

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp