diff options
author | Tom Lane | 2020-11-04 16:25:56 +0000 |
---|---|---|
committer | Tom Lane | 2020-11-04 16:25:56 +0000 |
commit | f21636e5d5b8394ed076e18ddc5f4ba710c69c99 (patch) | |
tree | 4940bc380da996857fc4a95e2e9d43006d6d7677 /src/backend/utils | |
parent | 113d3591b859fb8dc191bc0599d1ad62d91f1aa4 (diff) |
Remove useless entries for aggregate functions from fmgrtab.c.
Gen_fmgrtab.pl treated aggregate functions the same as other built-in
functions, which is wasteful because there is no real need to have
entries for them in the fmgr_builtins[] table. Suppressing those
entries saves about 3KB in the compiled table on my machine; which
is not a lot but it's not nothing either, considering that that
table is pretty "hot". The only outside code change needed is
that ExecInitWindowAgg() can't be allowed to call fmgr_info_cxt()
on a plain aggregate function. But that saves a few cycles anyway.
Having done that, the aggregate_dummy() function is unreferenced
and might as well be dropped. Using "aggregate_dummy" as the prosrc
value for an aggregate is now just a documentation convention not
something that matters. There was some discussion of using NULL
instead to save a few bytes in pg_proc, but we'd have to remove
prosrc's BKI_FORCE_NOT_NULL marking which doesn't seem a great idea.
Anyway, it's possible there's client-side code that expects to
see "aggregate_dummy" there, so I'm loath to change it without a
strong reason.
Discussion: https://postgr.es/m/533989.1604263665@sss.pgh.pa.us
Diffstat (limited to 'src/backend/utils')
-rw-r--r-- | src/backend/utils/Gen_fmgrtab.pl | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/backend/utils/Gen_fmgrtab.pl b/src/backend/utils/Gen_fmgrtab.pl index 8228ad6db60..ae8cf5bb64c 100644 --- a/src/backend/utils/Gen_fmgrtab.pl +++ b/src/backend/utils/Gen_fmgrtab.pl @@ -75,6 +75,7 @@ foreach my $row (@{ $catalog_data{pg_proc} }) oid => $bki_values{oid}, name => $bki_values{proname}, lang => $bki_values{prolang}, + kind => $bki_values{prokind}, strict => $bki_values{proisstrict}, retset => $bki_values{proretset}, nargs => $bki_values{pronargs}, @@ -195,8 +196,10 @@ foreach my $s (sort { $a->{oid} <=> $b->{oid} } @fmgr) $sqlname .= "_" . $s->{args} if ($proname_counts{ $s->{name} } > 1); $sqlname =~ s/\s+/_/g; print $ofh "#define F_" . uc $sqlname . " $s->{oid}\n"; - # We want only one extern per internal-language function - if ($s->{lang} eq 'internal' && !$seenit{ $s->{prosrc} }) + # We want only one extern per internal-language, non-aggregate function + if ( $s->{lang} eq 'internal' + && $s->{kind} ne 'a' + && !$seenit{ $s->{prosrc} }) { $seenit{ $s->{prosrc} } = 1; print $pfh "extern Datum $s->{prosrc}(PG_FUNCTION_ARGS);\n"; @@ -214,6 +217,8 @@ my $fmgr_count = 0; foreach my $s (sort { $a->{oid} <=> $b->{oid} } @fmgr) { next if $s->{lang} ne 'internal'; + # We do not need entries for aggregate functions + next if $s->{kind} eq 'a'; print $tfh ",\n" if ($fmgr_count > 0); print $tfh |