Skip to content

Commit a030113

Browse files
committed
Tweak fmgrtab generation so that the F_XXX macros that give OIDs for
built-in procedures are named after the prosrc field of pg_proc (ie, the actual C function name), not the proname field. This did not use to make a difference back when the two were always the same, but in the presence of overloaded proname values we'd best try to use the C name instead. AFAICT this change affects no existing code, but it is necessary to be able to get at some built-in functions that no macro was being generated for before.
1 parent 22a517a commit a030113

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/backend/utils/Gen_fmgrtab.sh.in

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#
1010
#
1111
# IDENTIFICATION
12-
# $Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh.in,v 1.22 2000/05/28 17:56:05 tgl Exp $
12+
# $Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh.in,v 1.23 2000/05/29 20:18:30 tgl Exp $
1313
#
1414
# NOTES
1515
# Passes any -D options on to cpp prior to generating the list
@@ -41,7 +41,7 @@ TABLEFILE=fmgrtab.c
4141

4242
#
4343
# Generate the file containing raw pg_proc tuple data
44-
# (but only for "internal" language procedures...).
44+
# (but only for "internal" and "newinternal" language procedures...).
4545
#
4646
# Unlike genbki.sh, which can run through cpp last, we have to
4747
# deal with preprocessor statements first (before we sort the
@@ -82,7 +82,7 @@ cat > $OIDSFILE <<FuNkYfMgRsTuFf
8282
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
8383
* Portions Copyright (c) 1994, Regents of the University of California
8484
*
85-
* $Id: Gen_fmgrtab.sh.in,v 1.22 2000/05/28 17:56:05 tgl Exp $
85+
* $Id: Gen_fmgrtab.sh.in,v 1.23 2000/05/29 20:18:30 tgl Exp $
8686
*
8787
* NOTES
8888
* ******************************
@@ -99,16 +99,21 @@ cat > $OIDSFILE <<FuNkYfMgRsTuFf
9999
100100
/*
101101
* Constant macros for the OIDs of entries in pg_proc.
102-
* NOTE: if the same "proname" is used for more than one
103-
* internal-function entry in pg_proc, the equivalent macro
104-
* will be defined with the lowest OID among those entries.
102+
*
103+
* NOTE: macros are named after the prosrc value, ie the actual C name
104+
* of the implementing function, not the proname which may be overloaded.
105+
* For example, we want to be able to assign different macro names to both
106+
* char_text() and int4_text() even though these both appear with proname
107+
* 'text'. If the same C function appears in more than one pg_proc entry,
108+
* its equivalent macro will be defined with the OID of the entry appearing
109+
* first in pg_proc.h.
105110
*/
106111
FuNkYfMgRsTuFf
107112

108113
tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' < $RAWFILE | \
109114
awk '
110115
BEGIN { OFS = ""; }
111-
{ if (seenit[$2]++ == 0) print "#define F_", $2, " ", $1; }' >> $OIDSFILE
116+
{ if (seenit[$(NF-1)]++ == 0) print "#define F_", $(NF-1), " ", $1; }' >> $OIDSFILE
112117

113118
cat >> $OIDSFILE <<FuNkYfMgRsTuFf
114119
@@ -134,7 +139,7 @@ cat > $TABLEFILE <<FuNkYfMgRtAbStUfF
134139
* Portions Copyright (c) 1994, Regents of the University of California
135140
*
136141
* IDENTIFICATION
137-
* $Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh.in,v 1.22 2000/05/28 17:56:05 tgl Exp $
142+
* $Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh.in,v 1.23 2000/05/29 20:18:30 tgl Exp $
138143
*
139144
* NOTES
140145
*

0 commit comments

Comments
 (0)