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

Commitd5ab79d

Browse files
committed
Make pg_dump's table of object-type priorities more maintainable.
Wedging a new object type into this table has historically requiredmanually renumbering a lot of existing entries. (Although it appearsthat some people got lazy and re-used the priority level of anexisting object type, even if it wasn't particularly related.)We can let the compiler do the counting by inventing an enum type thatlists the desired priority levels in order. Now, if you want to addor remove a priority level, that's a one-liner.This patch is not purely cosmetic, because I split apart the prioritiesof DO_COLLATION and DO_TRANSFORM, as well as those of DO_ACCESS_METHODand DO_OPERATOR, which look to me to have been merged out of expediencyrather than because it was a good idea. Shell types continue to besorted interchangeably with full types, and opclasses interchangeablywith opfamilies.
1 parentf315205 commitd5ab79d

File tree

1 file changed

+93
-44
lines changed

1 file changed

+93
-44
lines changed

‎src/bin/pg_dump/pg_dump_sort.c

Lines changed: 93 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -39,52 +39,101 @@
3939
* POST_DATA objects must sort after DO_POST_DATA_BOUNDARY, and DATA objects
4040
* must sort between them.
4141
*/
42+
43+
/* This enum lists the priority levels in order */
44+
enumdbObjectTypePriorities
45+
{
46+
PRIO_NAMESPACE=1,
47+
PRIO_PROCLANG,
48+
PRIO_COLLATION,
49+
PRIO_TRANSFORM,
50+
PRIO_EXTENSION,
51+
PRIO_TYPE,/* used for DO_TYPE and DO_SHELL_TYPE */
52+
PRIO_FUNC,
53+
PRIO_AGG,
54+
PRIO_ACCESS_METHOD,
55+
PRIO_OPERATOR,
56+
PRIO_OPFAMILY,/* used for DO_OPFAMILY and DO_OPCLASS */
57+
PRIO_CAST,
58+
PRIO_CONVERSION,
59+
PRIO_TSPARSER,
60+
PRIO_TSTEMPLATE,
61+
PRIO_TSDICT,
62+
PRIO_TSCONFIG,
63+
PRIO_FDW,
64+
PRIO_FOREIGN_SERVER,
65+
PRIO_TABLE,
66+
PRIO_DUMMY_TYPE,
67+
PRIO_ATTRDEF,
68+
PRIO_BLOB,
69+
PRIO_PRE_DATA_BOUNDARY,/* boundary! */
70+
PRIO_TABLE_DATA,
71+
PRIO_SEQUENCE_SET,
72+
PRIO_BLOB_DATA,
73+
PRIO_POST_DATA_BOUNDARY,/* boundary! */
74+
PRIO_CONSTRAINT,
75+
PRIO_INDEX,
76+
PRIO_INDEX_ATTACH,
77+
PRIO_STATSEXT,
78+
PRIO_RULE,
79+
PRIO_TRIGGER,
80+
PRIO_FK_CONSTRAINT,
81+
PRIO_POLICY,
82+
PRIO_PUBLICATION,
83+
PRIO_PUBLICATION_REL,
84+
PRIO_SUBSCRIPTION,
85+
PRIO_DEFAULT_ACL,/* done in ACL pass */
86+
PRIO_EVENT_TRIGGER,/* must be next to last! */
87+
PRIO_REFRESH_MATVIEW/* must be last! */
88+
};
89+
90+
/* This table is indexed by enum DumpableObjectType */
4291
staticconstintdbObjectTypePriority[]=
4392
{
44-
1,/* DO_NAMESPACE */
45-
4,/* DO_EXTENSION */
46-
5,/* DO_TYPE */
47-
5,/* DO_SHELL_TYPE */
48-
6,/* DO_FUNC */
49-
7,/* DO_AGG */
50-
8,/* DO_OPERATOR */
51-
8,/* DO_ACCESS_METHOD */
52-
9,/* DO_OPCLASS */
53-
9,/* DO_OPFAMILY */
54-
3,/* DO_COLLATION */
55-
11,/* DO_CONVERSION */
56-
18,/* DO_TABLE */
57-
20,/* DO_ATTRDEF */
58-
28,/* DO_INDEX */
59-
29,/* DO_INDEX_ATTACH */
60-
30,/* DO_STATSEXT */
61-
31,/* DO_RULE */
62-
32,/* DO_TRIGGER */
63-
27,/* DO_CONSTRAINT */
64-
33,/* DO_FK_CONSTRAINT */
65-
2,/* DO_PROCLANG */
66-
10,/* DO_CAST */
67-
23,/* DO_TABLE_DATA */
68-
24,/* DO_SEQUENCE_SET */
69-
19,/* DO_DUMMY_TYPE */
70-
12,/* DO_TSPARSER */
71-
14,/* DO_TSDICT */
72-
13,/* DO_TSTEMPLATE */
73-
15,/* DO_TSCONFIG */
74-
16,/* DO_FDW */
75-
17,/* DO_FOREIGN_SERVER */
76-
38,/* DO_DEFAULT_ACL --- done in ACL pass */
77-
3,/* DO_TRANSFORM */
78-
21,/* DO_BLOB */
79-
25,/* DO_BLOB_DATA */
80-
22,/* DO_PRE_DATA_BOUNDARY */
81-
26,/* DO_POST_DATA_BOUNDARY */
82-
39,/* DO_EVENT_TRIGGER --- next to last! */
83-
40,/* DO_REFRESH_MATVIEW --- last! */
84-
34,/* DO_POLICY */
85-
35,/* DO_PUBLICATION */
86-
36,/* DO_PUBLICATION_REL */
87-
37/* DO_SUBSCRIPTION */
93+
PRIO_NAMESPACE,/* DO_NAMESPACE */
94+
PRIO_EXTENSION,/* DO_EXTENSION */
95+
PRIO_TYPE,/* DO_TYPE */
96+
PRIO_TYPE,/* DO_SHELL_TYPE */
97+
PRIO_FUNC,/* DO_FUNC */
98+
PRIO_AGG,/* DO_AGG */
99+
PRIO_OPERATOR,/* DO_OPERATOR */
100+
PRIO_ACCESS_METHOD,/* DO_ACCESS_METHOD */
101+
PRIO_OPFAMILY,/* DO_OPCLASS */
102+
PRIO_OPFAMILY,/* DO_OPFAMILY */
103+
PRIO_COLLATION,/* DO_COLLATION */
104+
PRIO_CONVERSION,/* DO_CONVERSION */
105+
PRIO_TABLE,/* DO_TABLE */
106+
PRIO_ATTRDEF,/* DO_ATTRDEF */
107+
PRIO_INDEX,/* DO_INDEX */
108+
PRIO_INDEX_ATTACH,/* DO_INDEX_ATTACH */
109+
PRIO_STATSEXT,/* DO_STATSEXT */
110+
PRIO_RULE,/* DO_RULE */
111+
PRIO_TRIGGER,/* DO_TRIGGER */
112+
PRIO_CONSTRAINT,/* DO_CONSTRAINT */
113+
PRIO_FK_CONSTRAINT,/* DO_FK_CONSTRAINT */
114+
PRIO_PROCLANG,/* DO_PROCLANG */
115+
PRIO_CAST,/* DO_CAST */
116+
PRIO_TABLE_DATA,/* DO_TABLE_DATA */
117+
PRIO_SEQUENCE_SET,/* DO_SEQUENCE_SET */
118+
PRIO_DUMMY_TYPE,/* DO_DUMMY_TYPE */
119+
PRIO_TSPARSER,/* DO_TSPARSER */
120+
PRIO_TSDICT,/* DO_TSDICT */
121+
PRIO_TSTEMPLATE,/* DO_TSTEMPLATE */
122+
PRIO_TSCONFIG,/* DO_TSCONFIG */
123+
PRIO_FDW,/* DO_FDW */
124+
PRIO_FOREIGN_SERVER,/* DO_FOREIGN_SERVER */
125+
PRIO_DEFAULT_ACL,/* DO_DEFAULT_ACL */
126+
PRIO_TRANSFORM,/* DO_TRANSFORM */
127+
PRIO_BLOB,/* DO_BLOB */
128+
PRIO_BLOB_DATA,/* DO_BLOB_DATA */
129+
PRIO_PRE_DATA_BOUNDARY,/* DO_PRE_DATA_BOUNDARY */
130+
PRIO_POST_DATA_BOUNDARY,/* DO_POST_DATA_BOUNDARY */
131+
PRIO_EVENT_TRIGGER,/* DO_EVENT_TRIGGER */
132+
PRIO_REFRESH_MATVIEW,/* DO_REFRESH_MATVIEW */
133+
PRIO_POLICY,/* DO_POLICY */
134+
PRIO_PUBLICATION,/* DO_PUBLICATION */
135+
PRIO_PUBLICATION_REL,/* DO_PUBLICATION_REL */
136+
PRIO_SUBSCRIPTION/* DO_SUBSCRIPTION */
88137
};
89138

90139
StaticAssertDecl(lengthof(dbObjectTypePriority)== (DO_SUBSCRIPTION+1),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp