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

Commit995e0fb

Browse files
committed
Un-break genbki.pl's error reporting capabilities.
This essentially reverts commit69eb643, which added a fast pathin Catalog::ParseData, but neglected to preserve the behavior ofadding a line_number field in each hash. That makes it impossiblefor genbki.pl to provide any localization of error reports, which isbad enough; but actually the affected error reports failed entirely,producing useless bleats like "use of undefined value in sprintf".69eb643 claimed to get a 15% speedup, but I'm not sure I believethat: the time to rebuild the bki files changes by less than 1% forme. In any case, making debugging of mistakes in .dat files moredifficult would not be justified by even an order of magnitudespeedup here; it's just not that big a chunk of the total build time.Per report from David Wheeler. Although it's also broken in v16,I don't think this is worth a back-patch, since we're very unlikelyto touch the v16 catalog data again.Discussion:https://postgr.es/m/19238.1710953049@sss.pgh.pa.us
1 parent1218ca9 commit995e0fb

File tree

1 file changed

+7
-21
lines changed

1 file changed

+7
-21
lines changed

‎src/backend/catalog/Catalog.pm

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -300,21 +300,21 @@ sub ParseHeader
300300

301301
# Parses a file containing Perl data structure literals, returning live data.
302302
#
303-
# The parameter $preserve_formatting needs to be set for callers that want
303+
# The parameter $preserve_comments needs to be set for callers that want
304304
# to work with non-data lines in the data files, such as comments and blank
305305
# lines. If a caller just wants to consume the data, leave it unset.
306+
# (When requested, non-data lines will be returned as array entries that
307+
# are strings not hashes, so extra code is needed to deal with that.)
306308
subParseData
307309
{
308-
my ($input_file,$schema,$preserve_formatting) =@_;
310+
my ($input_file,$schema,$preserve_comments) =@_;
309311

310312
open(my$ifd,'<',$input_file) ||die"$input_file:$!";
311313
$input_file =~/(\w+)\.dat$/
312314
ordie"Input file$input_file needs to be a .dat file.\n";
313315
my$catname =$1;
314316
my$data = [];
315317

316-
if ($preserve_formatting)
317-
{
318318
# Scan the input file.
319319
while (<$ifd>)
320320
{
@@ -369,31 +369,17 @@ sub ParseData
369369
# with --full-tuples to print autogenerated entries, which seems like
370370
# useful behavior for debugging.)
371371
#
372-
# Otherwise, we have a non-data string, which weneed tokeepin
373-
#order to preserve formatting.
372+
# Otherwise, we have a non-data string, which we keeponly if
373+
#the caller requested it.
374374
if (defined$hash_ref)
375375
{
376376
push@$data,$hash_refif !$hash_ref->{autogenerated};
377377
}
378378
else
379379
{
380-
push@$data,$_;
380+
push@$data,$_if$preserve_comments;
381381
}
382382
}
383-
}
384-
else
385-
{
386-
# When we only care about the contents, it's faster to read and eval
387-
# the whole file at once.
388-
local$/;
389-
my$full_file = <$ifd>;
390-
eval"\$data =$full_file"## no critic (ProhibitStringyEval)
391-
ordie"error parsing$input_file\n";
392-
foreachmy$hash_ref (@{$data})
393-
{
394-
AddDefaultValues($hash_ref,$schema,$catname);
395-
}
396-
}
397383

398384
close$ifd;
399385

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp