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

Commit45c6d75

Browse files
committed
Clarify handling of special-case values in bootstrap catalog data.
I (tgl) originally coded the special case for pg_proc.pronargs asthough it were a kind of default value. It seems better though totreat computable columns as an independent concern: this makes thecode clearer, and probably a bit faster too since we needn't dowork inside the per-column loop.Improve related comments, as well, in the expectation that theremight be more cases like this in future.John Naylor, some additional comment-hacking by meDiscussion:https://postgr.es/m/CAJVSVGW-D7OobzU=dybVT2JqZAx-4X1yvBJdavBmqQL05Q6CLw@mail.gmail.com
1 parentf2bb32d commit45c6d75

File tree

3 files changed

+28
-17
lines changed

3 files changed

+28
-17
lines changed

‎src/backend/catalog/Catalog.pm

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,21 @@ sub AddDefaultValues
292292
my ($row,$schema,$catname) =@_;
293293
my@missing_fields;
294294

295+
# Compute special-case column values.
296+
# Note: If you add new cases here, you must also teach
297+
# strip_default_values() in include/catalog/reformat_dat_file.pl
298+
# to delete them.
299+
if ($catnameeq'pg_proc')
300+
{
301+
# pg_proc.pronargs can be derived from proargtypes.
302+
if (defined$row->{proargtypes})
303+
{
304+
my@proargtypes =split /\s+/,$row->{proargtypes};
305+
$row->{pronargs} =scalar(@proargtypes);
306+
}
307+
}
308+
309+
# Now fill in defaults, and note any columns that remain undefined.
295310
foreachmy$column (@$schema)
296311
{
297312
my$attname =$column->{name};
@@ -305,21 +320,14 @@ sub AddDefaultValues
305320
{
306321
$row->{$attname} =$column->{default};
307322
}
308-
elsif ($catnameeq'pg_proc'
309-
&&$attnameeq'pronargs'
310-
&&defined($row->{proargtypes}))
311-
{
312-
# pg_proc.pronargs can be derived from proargtypes.
313-
my@proargtypes =split /\s+/,$row->{proargtypes};
314-
$row->{$attname} =scalar(@proargtypes);
315-
}
316323
else
317324
{
318325
# Failed to find a value.
319326
push@missing_fields,$attname;
320327
}
321328
}
322329

330+
# Failure to provide all columns is a hard error.
323331
if (@missing_fields)
324332
{
325333
diesprintf"missing values for field(s)%s in%s.dat line%s\n",

‎src/include/catalog/pg_proc.dat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
# "convert srctypename to desttypename" for cast functions
3131
# "less-equal-greater" for B-tree comparison functions
3232

33+
# Note: pronargs is computed when this file is read, so it does not need
34+
# to be specified in entries here. See AddDefaultValues() in Catalog.pm.
35+
3336
# Once upon a time these entries were ordered by OID. Lately it's often
3437
# been the custom to insert new entries adjacent to related older entries.
3538
# Try to do one or the other though, don't just insert entries at random.

‎src/include/catalog/reformat_dat_file.pl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -177,31 +177,31 @@
177177
close$dat;
178178
}
179179

180-
# Leave values out if there is a matching default.
180+
# Remove column values for which there is a matching default,
181+
# or if the value can be computed from other columns.
181182
substrip_default_values
182183
{
183184
my ($row,$schema,$catname) =@_;
184185

186+
# Delete values that match defaults.
185187
foreachmy$column (@$schema)
186188
{
187189
my$attname =$column->{name};
188190
die"strip_default_values:$catname.$attname undefined\n"
189191
if !defined$row->{$attname};
190192

191-
# Delete values that match defaults.
192193
if (defined$column->{default}
193194
and ($row->{$attname}eq$column->{default}))
194195
{
195196
delete$row->{$attname};
196197
}
198+
}
197199

198-
# Also delete pg_proc.pronargs, since that can be recomputed.
199-
if ($catnameeq'pg_proc'
200-
&&$attnameeq'pronargs'
201-
&&defined($row->{proargtypes}))
202-
{
203-
delete$row->{$attname};
204-
}
200+
# Delete computed values. See AddDefaultValues() in Catalog.pm.
201+
# Note: This must be done after deleting values matching defaults.
202+
if ($catnameeq'pg_proc')
203+
{
204+
delete$row->{pronargs}ifdefined$row->{proargtypes};
205205
}
206206
}
207207

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp