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

Commit23d8624

Browse files
committed
Use named captures in Catalog::ParseHeader()
Using at least perl 5.14 is required since4c15327, meaning that it ispossible to use named captures and the %+ hash instead of having tocount parenthesis groups manually.While on it, CATALOG is made more flexible in its handling ofwhitespaces for parameter lists (see the addition of \s* in thiscase). The generated postgres.bki remains exactly the same before andafter this commit.Author: Dagfinn Ilmari MannsåkerReviewed-by: John NaylorDiscussion:https://postgr.es/m/87y1l3s7o9.fsf@wibble.ilmari.org
1 parent5bcc7e6 commit23d8624

File tree

1 file changed

+50
-35
lines changed

1 file changed

+50
-35
lines changed

‎src/backend/catalog/Catalog.pm

Lines changed: 50 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -91,73 +91,88 @@ sub ParseHeader
9191
# Push the data into the appropriate data structure.
9292
# Caution: when adding new recognized OID-defining macros,
9393
# also update src/include/catalog/renumber_oids.pl.
94-
if (/^DECLARE_TOAST\(\s*(\w+),\s*(\d+),\s*(\d+)\)/)
94+
if (/^DECLARE_TOAST\(\s*
95+
(?<parent_table>\w+),\s*
96+
(?<toast_oid>\d+),\s*
97+
(?<toast_index_oid>\d+)\s*
98+
\)/x
99+
)
95100
{
96-
push @{$catalog{toasting} },
97-
{parent_table=>$1,toast_oid=>$2,toast_index_oid=>$3 };
101+
push @{$catalog{toasting} }, {%+};
98102
}
99103
elsif (
100-
/^DECLARE_TOAST_WITH_MACRO\(\s*(\w+),\s*(\d+),\s*(\d+),\s*(\w+),\s*(\w+)\)/
104+
/^DECLARE_TOAST_WITH_MACRO\(\s*
105+
(?<parent_table>\w+),\s*
106+
(?<toast_oid>\d+),\s*
107+
(?<toast_index_oid>\d+),\s*
108+
(?<toast_oid_macro>\w+),\s*
109+
(?<toast_index_oid_macro>\w+)\s*
110+
\)/x
101111
)
102112
{
103-
push @{$catalog{toasting} },
104-
{
105-
parent_table=>$1,
106-
toast_oid=>$2,
107-
toast_index_oid=>$3,
108-
toast_oid_macro=>$4,
109-
toast_index_oid_macro=>$5
110-
};
113+
push @{$catalog{toasting} }, {%+};
111114
}
112115
elsif (
113-
/^DECLARE_(UNIQUE_)?INDEX(_PKEY)?\(\s*(\w+),\s*(\d+),\s*(\w+),\s*(.+)\)/
116+
/^DECLARE_(UNIQUE_)?INDEX(_PKEY)?\(\s*
117+
(?<index_name>\w+),\s*
118+
(?<index_oid>\d+),\s*
119+
(?<index_oid_macro>\w+),\s*
120+
(?<index_decl>.+)\s*
121+
\)/x
114122
)
115123
{
116124
push @{$catalog{indexing} },
117125
{
118126
is_unique=>$1 ? 1 : 0,
119127
is_pkey=>$2 ? 1 : 0,
120-
index_name=>$3,
121-
index_oid=>$4,
122-
index_oid_macro=>$5,
123-
index_decl=>$6
128+
%+,
124129
};
125130
}
126-
elsif (/^DECLARE_OID_DEFINING_MACRO\(\s*(\w+),\s*(\d+)\)/)
131+
elsif (
132+
/^DECLARE_OID_DEFINING_MACRO\(\s*
133+
(?<other_name>\w+),\s*
134+
(?<other_oid>\d+)\s*
135+
\)/x
136+
)
127137
{
128-
push @{$catalog{other_oids} },
129-
{
130-
other_name=>$1,
131-
other_oid=>$2
132-
};
138+
push @{$catalog{other_oids} }, {%+};
133139
}
134140
elsif (
135-
/^DECLARE_(ARRAY_)?FOREIGN_KEY(_OPT)?\(\s*\(([^)]+)\),\s*(\w+),\s*\(([^)]+)\)\)/
141+
/^DECLARE_(ARRAY_)?FOREIGN_KEY(_OPT)?\(\s*
142+
\((?<fk_cols>[^)]+)\),\s*
143+
(?<pk_table>\w+),\s*
144+
\((?<pk_cols>[^)]+)\)\s*
145+
\)/x
136146
)
137147
{
138148
push @{$catalog{foreign_keys} },
139149
{
140150
is_array=>$1 ? 1 : 0,
141151
is_opt=>$2 ? 1 : 0,
142-
fk_cols=>$3,
143-
pk_table=>$4,
144-
pk_cols=>$5
152+
%+,
145153
};
146154
}
147-
elsif (/^CATALOG\((\w+),(\d+),(\w+)\)/)
155+
elsif (
156+
/^CATALOG\(\s*
157+
(?<catname>\w+),\s*
158+
(?<relation_oid>\d+),\s*
159+
(?<relation_oid_macro>\w+)\s*
160+
\)/x
161+
)
148162
{
149-
$catalog{catname} =$1;
150-
$catalog{relation_oid} =$2;
151-
$catalog{relation_oid_macro} =$3;
163+
@catalog{keys %+ } =values %+;
152164

153165
$catalog{bootstrap} = /BKI_BOOTSTRAP/ ?' bootstrap' :'';
154166
$catalog{shared_relation} =
155167
/BKI_SHARED_RELATION/ ?' shared_relation' :'';
156-
if (/BKI_ROWTYPE_OID\((\d+),(\w+)\)/)
168+
if (/BKI_ROWTYPE_OID\(\s*
169+
(?<rowtype_oid>\d+),\s*
170+
(?<rowtype_oid_macro>\w+)\s*
171+
\)/x
172+
)
157173
{
158-
$catalog{rowtype_oid} =$1;
159-
$catalog{rowtype_oid_clause} =" rowtype_oid$1";
160-
$catalog{rowtype_oid_macro} =$2;
174+
@catalog{keys %+ } =values %+;
175+
$catalog{rowtype_oid_clause} =" rowtype_oid$+{rowtype_oid}";
161176
}
162177
else
163178
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp