diff options
author | Tom Lane | 2017-04-13 16:07:47 +0000 |
---|---|---|
committer | Tom Lane | 2017-04-13 16:07:57 +0000 |
commit | 5e39f06cfe65acbecedf42a660f577c3fca47bcc (patch) | |
tree | 0a4b820a1a40fec5c88d63524522f29c64aebe1f /src/backend/utils/Gen_fmgrtab.pl | |
parent | a9254e675bde7dc2d976d207450c559d914c0dd6 (diff) |
Move bootstrap-time lookup of regproc OIDs into genbki.pl.
Formerly, the bootstrap backend looked up the OIDs corresponding to
names in regproc catalog entries using brute-force searches of pg_proc.
It was somewhat remarkable that that worked at all, since it was used
while populating other pretty-fundamental catalogs like pg_operator.
And it was also quite slow, and getting slower as pg_proc gets bigger.
This patch moves the lookup work into genbki.pl, so that the values in
postgres.bki for regproc columns are always numeric OIDs, an option
that regprocin() already supported. Perl isn't the world's speediest
language, so this about doubles the time needed to run genbki.pl (from
0.3 to 0.6 sec on my machine). But we only do that at most once per
build. The time needed to run initdb drops significantly --- on my
machine, initdb --no-sync goes from 1.8 to 1.3 seconds. So this is
a small net win even for just one initdb per build, and it becomes
quite a nice win for test sequences requiring many initdb runs.
Strip out the now-dead code for brute-force catalog searching in
regprocin. We'd also cargo-culted similar logic into regoperin
and some (not all) of the other reg*in functions. That is all
dead code too since we currently have no need to load such values
during bootstrap. I removed it all, reasoning that if we ever
need such functionality it'd be much better to do it in a similar
way to this patch.
There might be some simplifications possible in the backend now that
regprocin doesn't require doing catalog reads so early in bootstrap.
I've not looked into that, though.
Andreas Karlsson, with some small adjustments by me
Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'src/backend/utils/Gen_fmgrtab.pl')
-rw-r--r-- | src/backend/utils/Gen_fmgrtab.pl | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/src/backend/utils/Gen_fmgrtab.pl b/src/backend/utils/Gen_fmgrtab.pl index 2af9b355e75..76bdf5ca0d7 100644 --- a/src/backend/utils/Gen_fmgrtab.pl +++ b/src/backend/utils/Gen_fmgrtab.pl @@ -58,30 +58,20 @@ foreach my $column (@{ $catalogs->{pg_proc}->{columns} }) my $data = $catalogs->{pg_proc}->{data}; foreach my $row (@$data) { - - # To construct fmgroids.h and fmgrtab.c, we need to inspect some - # of the individual data fields. Just splitting on whitespace - # won't work, because some quoted fields might contain internal - # whitespace. We handle this by folding them all to a simple - # "xxx". Fortunately, this script doesn't need to look at any - # fields that might need quoting, so this simple hack is - # sufficient. - $row->{bki_values} =~ s/"[^"]*"/"xxx"/g; - @{$row}{@attnames} = split /\s+/, $row->{bki_values}; + # Split line into tokens without interpreting their meaning. + my %bki_values; + @bki_values{@attnames} = Catalog::SplitDataLine($row->{bki_values}); # Select out just the rows for internal-language procedures. # Note assumption here that INTERNALlanguageId is 12. - next if $row->{prolang} ne '12'; + next if $bki_values{prolang} ne '12'; push @fmgr, { oid => $row->{oid}, - strict => $row->{proisstrict}, - retset => $row->{proretset}, - nargs => $row->{pronargs}, - prosrc => $row->{prosrc}, }; - - # Hack to work around memory leak in some versions of Perl - $row = undef; + strict => $bki_values{proisstrict}, + retset => $bki_values{proretset}, + nargs => $bki_values{pronargs}, + prosrc => $bki_values{prosrc}, }; } # Emit headers for both files |