Skip to content

Commit 352a24a

Browse files
committed
Generate fmgr prototypes automatically
Gen_fmgrtab.pl creates a new file fmgrprotos.h, which contains prototypes for all functions registered in pg_proc.h. This avoids having to manually maintain these prototypes across a random variety of header files. It also automatically enforces a correct function signature, and since there are warnings about missing prototypes, it will detect functions that are defined but not registered in pg_proc.h (or otherwise used). Reviewed-by: Pavel Stehule <pavel.stehule@gmail.com>
1 parent 323b96a commit 352a24a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+125
-2899
lines changed

contrib/btree_gist/btree_bit.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include "btree_gist.h"
77
#include "btree_utils_var.h"
8+
#include "utils/builtins.h"
89
#include "utils/bytea.h"
910
#include "utils/varbit.h"
1011

contrib/btree_gist/btree_bytea.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include "btree_gist.h"
77
#include "btree_utils_var.h"
8+
#include "utils/builtins.h"
89
#include "utils/bytea.h"
910

1011

contrib/btree_gist/btree_date.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include "btree_gist.h"
77
#include "btree_utils_num.h"
8+
#include "utils/builtins.h"
89
#include "utils/date.h"
910

1011
typedef struct

contrib/btree_gist/btree_interval.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include "btree_gist.h"
77
#include "btree_utils_num.h"
8+
#include "utils/builtins.h"
89
#include "utils/timestamp.h"
910

1011
typedef struct

contrib/btree_gist/btree_time.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include "btree_gist.h"
77
#include "btree_utils_num.h"
8+
#include "utils/builtins.h"
89
#include "utils/date.h"
910
#include "utils/timestamp.h"
1011

contrib/intarray/_int_selfuncs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "catalog/pg_operator.h"
2020
#include "catalog/pg_statistic.h"
2121
#include "catalog/pg_type.h"
22+
#include "utils/builtins.h"
2223
#include "utils/selfuncs.h"
2324
#include "utils/syscache.h"
2425
#include "utils/lsyscache.h"

contrib/lo/lo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#include "commands/trigger.h"
1111
#include "executor/spi.h"
12-
#include "libpq/be-fsstubs.h"
12+
#include "utils/builtins.h"
1313
#include "utils/rel.h"
1414

1515
PG_MODULE_MAGIC;

contrib/spi/moddatetime.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ OH, me, I'm Terry Mackintosh <terry@terrym.com>
1919
#include "catalog/pg_type.h"
2020
#include "executor/spi.h"
2121
#include "commands/trigger.h"
22+
#include "utils/builtins.h"
2223
#include "utils/rel.h"
23-
#include "utils/timestamp.h"
2424

2525
PG_MODULE_MAGIC;
2626

src/backend/Makefile

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ storage/lmgr/lwlocknames.h: storage/lmgr/generate-lwlocknames.pl storage/lmgr/lw
139139
utils/errcodes.h: utils/generate-errcodes.pl utils/errcodes.txt
140140
$(MAKE) -C utils errcodes.h
141141

142-
utils/fmgroids.h: utils/Gen_fmgrtab.pl catalog/Catalog.pm $(top_srcdir)/src/include/catalog/pg_proc.h
143-
$(MAKE) -C utils fmgroids.h
142+
utils/fmgroids.h utils/fmgrprotos.h: utils/Gen_fmgrtab.pl catalog/Catalog.pm $(top_srcdir)/src/include/catalog/pg_proc.h
143+
$(MAKE) -C utils $(notdir $@)
144144

145145
utils/probes.h: utils/probes.d
146146
$(MAKE) -C utils probes.h
@@ -166,7 +166,7 @@ submake-schemapg:
166166

167167
.PHONY: generated-headers
168168

169-
generated-headers: $(top_builddir)/src/include/parser/gram.h $(top_builddir)/src/include/catalog/schemapg.h $(top_builddir)/src/include/storage/lwlocknames.h $(top_builddir)/src/include/utils/errcodes.h $(top_builddir)/src/include/utils/fmgroids.h $(top_builddir)/src/include/utils/probes.h
169+
generated-headers: $(top_builddir)/src/include/parser/gram.h $(top_builddir)/src/include/catalog/schemapg.h $(top_builddir)/src/include/storage/lwlocknames.h $(top_builddir)/src/include/utils/errcodes.h $(top_builddir)/src/include/utils/fmgroids.h $(top_builddir)/src/include/utils/fmgrprotos.h $(top_builddir)/src/include/utils/probes.h
170170

171171
$(top_builddir)/src/include/parser/gram.h: parser/gram.h
172172
prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
@@ -193,6 +193,11 @@ $(top_builddir)/src/include/utils/fmgroids.h: utils/fmgroids.h
193193
cd '$(dir $@)' && rm -f $(notdir $@) && \
194194
$(LN_S) "$$prereqdir/$(notdir $<)" .
195195

196+
$(top_builddir)/src/include/utils/fmgrprotos.h: utils/fmgrprotos.h
197+
prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
198+
cd '$(dir $@)' && rm -f $(notdir $@) && \
199+
$(LN_S) "$$prereqdir/$(notdir $<)" .
200+
196201
$(top_builddir)/src/include/utils/probes.h: utils/probes.h
197202
cd '$(dir $@)' && rm -f $(notdir $@) && \
198203
$(LN_S) "../../../$(subdir)/utils/probes.h" .
@@ -211,7 +216,7 @@ distprep:
211216
$(MAKE) -C catalog schemapg.h postgres.bki postgres.description postgres.shdescription
212217
$(MAKE) -C replication repl_gram.c repl_scanner.c syncrep_gram.c syncrep_scanner.c
213218
$(MAKE) -C storage/lmgr lwlocknames.h
214-
$(MAKE) -C utils fmgrtab.c fmgroids.h errcodes.h
219+
$(MAKE) -C utils fmgrtab.c fmgroids.h fmgrprotos.h errcodes.h
215220
$(MAKE) -C utils/misc guc-file.c
216221
$(MAKE) -C utils/sort qsort_tuple.c
217222

@@ -303,6 +308,7 @@ clean:
303308
$(top_builddir)/src/include/catalog/schemapg.h \
304309
$(top_builddir)/src/include/storage/lwlocknames.h \
305310
$(top_builddir)/src/include/utils/fmgroids.h \
311+
$(top_builddir)/src/include/utils/fmgrprotos.h \
306312
$(top_builddir)/src/include/utils/probes.h
307313
ifeq ($(PORTNAME), cygwin)
308314
rm -f postgres.dll libpostgres.a
@@ -331,6 +337,7 @@ maintainer-clean: distclean
331337
storage/lmgr/lwlocknames.c \
332338
storage/lmgr/lwlocknames.h \
333339
utils/fmgroids.h \
340+
utils/fmgrprotos.h \
334341
utils/fmgrtab.c \
335342
utils/errcodes.h \
336343
utils/misc/guc-file.c \

src/backend/access/brin/brin.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "pgstat.h"
2929
#include "storage/bufmgr.h"
3030
#include "storage/freespace.h"
31+
#include "utils/builtins.h"
3132
#include "utils/index_selfuncs.h"
3233
#include "utils/memutils.h"
3334
#include "utils/rel.h"

src/backend/access/brin/brin_inclusion.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "access/skey.h"
3131
#include "catalog/pg_amop.h"
3232
#include "catalog/pg_type.h"
33+
#include "utils/builtins.h"
3334
#include "utils/datum.h"
3435
#include "utils/lsyscache.h"
3536
#include "utils/rel.h"
@@ -76,10 +77,6 @@ typedef struct InclusionOpaque
7677
FmgrInfo strategy_procinfos[RTMaxStrategyNumber];
7778
} InclusionOpaque;
7879

79-
Datum brin_inclusion_opcinfo(PG_FUNCTION_ARGS);
80-
Datum brin_inclusion_add_value(PG_FUNCTION_ARGS);
81-
Datum brin_inclusion_consistent(PG_FUNCTION_ARGS);
82-
Datum brin_inclusion_union(PG_FUNCTION_ARGS);
8380
static FmgrInfo *inclusion_get_procinfo(BrinDesc *bdesc, uint16 attno,
8481
uint16 procnum);
8582
static FmgrInfo *inclusion_get_strategy_procinfo(BrinDesc *bdesc, uint16 attno,

src/backend/access/brin/brin_minmax.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "access/stratnum.h"
1717
#include "catalog/pg_type.h"
1818
#include "catalog/pg_amop.h"
19+
#include "utils/builtins.h"
1920
#include "utils/datum.h"
2021
#include "utils/lsyscache.h"
2122
#include "utils/rel.h"
@@ -28,10 +29,6 @@ typedef struct MinmaxOpaque
2829
FmgrInfo strategy_procinfos[BTMaxStrategyNumber];
2930
} MinmaxOpaque;
3031

31-
Datum brin_minmax_opcinfo(PG_FUNCTION_ARGS);
32-
Datum brin_minmax_add_value(PG_FUNCTION_ARGS);
33-
Datum brin_minmax_consistent(PG_FUNCTION_ARGS);
34-
Datum brin_minmax_union(PG_FUNCTION_ARGS);
3532
static FmgrInfo *minmax_get_strategy_procinfo(BrinDesc *bdesc, uint16 attno,
3633
Oid subtype, uint16 strategynum);
3734

src/backend/access/gin/ginfast.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "postmaster/autovacuum.h"
3131
#include "storage/indexfsm.h"
3232
#include "storage/lmgr.h"
33+
#include "utils/builtins.h"
3334

3435
/* GUC parameter */
3536
int gin_pending_list_limit = 0;

src/backend/access/gist/gist.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "access/gistscan.h"
1919
#include "catalog/pg_collation.h"
2020
#include "miscadmin.h"
21+
#include "utils/builtins.h"
2122
#include "utils/index_selfuncs.h"
2223
#include "utils/memutils.h"
2324
#include "utils/rel.h"

src/backend/access/hash/hash.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "commands/vacuum.h"
2626
#include "miscadmin.h"
2727
#include "optimizer/plancat.h"
28+
#include "utils/builtins.h"
2829
#include "utils/index_selfuncs.h"
2930
#include "utils/rel.h"
3031

src/backend/access/hash/hashfunc.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,17 @@
2727
#include "postgres.h"
2828

2929
#include "access/hash.h"
30+
#include "utils/builtins.h"
3031

32+
/*
33+
* Datatype-specific hash functions.
34+
*
35+
* These support both hash indexes and hash joins.
36+
*
37+
* NOTE: some of these are also used by catcache operations, without
38+
* any direct connection to hash indexes. Also, the common hash_any
39+
* routine is also used by dynahash tables.
40+
*/
3141

3242
/* Note: this is used for both "char" and boolean datatypes */
3343
Datum

src/backend/access/index/amapi.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "access/htup_details.h"
1818
#include "catalog/pg_am.h"
1919
#include "catalog/pg_opclass.h"
20+
#include "utils/builtins.h"
2021
#include "utils/syscache.h"
2122

2223

src/backend/access/nbtree/nbtree.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "storage/lmgr.h"
2929
#include "storage/smgr.h"
3030
#include "tcop/tcopprot.h" /* pgrminclude ignore */
31+
#include "utils/builtins.h"
3132
#include "utils/index_selfuncs.h"
3233
#include "utils/memutils.h"
3334

src/backend/access/spgist/spgutils.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "storage/bufmgr.h"
2323
#include "storage/indexfsm.h"
2424
#include "storage/lmgr.h"
25+
#include "utils/builtins.h"
2526
#include "utils/index_selfuncs.h"
2627
#include "utils/lsyscache.h"
2728

src/backend/access/transam/xlogfuncs.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
#include "access/htup_details.h"
2020
#include "access/xlog.h"
21-
#include "access/xlog_fn.h"
2221
#include "access/xlog_internal.h"
2322
#include "access/xlogutils.h"
2423
#include "catalog/catalog.h"

src/backend/catalog/namespace.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -198,22 +198,6 @@ static void NamespaceCallback(Datum arg, int cacheid, uint32 hashvalue);
198198
static bool MatchNamedCall(HeapTuple proctup, int nargs, List *argnames,
199199
int **argnumbers);
200200

201-
/* These don't really need to appear in any header file */
202-
Datum pg_table_is_visible(PG_FUNCTION_ARGS);
203-
Datum pg_type_is_visible(PG_FUNCTION_ARGS);
204-
Datum pg_function_is_visible(PG_FUNCTION_ARGS);
205-
Datum pg_operator_is_visible(PG_FUNCTION_ARGS);
206-
Datum pg_opclass_is_visible(PG_FUNCTION_ARGS);
207-
Datum pg_opfamily_is_visible(PG_FUNCTION_ARGS);
208-
Datum pg_collation_is_visible(PG_FUNCTION_ARGS);
209-
Datum pg_conversion_is_visible(PG_FUNCTION_ARGS);
210-
Datum pg_ts_parser_is_visible(PG_FUNCTION_ARGS);
211-
Datum pg_ts_dict_is_visible(PG_FUNCTION_ARGS);
212-
Datum pg_ts_template_is_visible(PG_FUNCTION_ARGS);
213-
Datum pg_ts_config_is_visible(PG_FUNCTION_ARGS);
214-
Datum pg_my_temp_schema(PG_FUNCTION_ARGS);
215-
Datum pg_is_other_temp_schema(PG_FUNCTION_ARGS);
216-
217201

218202
/*
219203
* RangeVarGetRelid

src/backend/catalog/pg_proc.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@
4141
#include "utils/syscache.h"
4242

4343

44-
Datum fmgr_internal_validator(PG_FUNCTION_ARGS);
45-
Datum fmgr_c_validator(PG_FUNCTION_ARGS);
46-
Datum fmgr_sql_validator(PG_FUNCTION_ARGS);
47-
4844
typedef struct
4945
{
5046
char *proname;

src/backend/commands/define.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#include "nodes/makefuncs.h"
4141
#include "parser/parse_type.h"
4242
#include "parser/scansup.h"
43-
#include "utils/int8.h"
43+
#include "utils/builtins.h"
4444

4545
/*
4646
* Extract a string value (otherwise uninterpreted) from a DefElem.

src/backend/executor/nodeSamplescan.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "miscadmin.h"
2323
#include "pgstat.h"
2424
#include "storage/predicate.h"
25+
#include "utils/builtins.h"
2526
#include "utils/rel.h"
2627
#include "utils/tqual.h"
2728

src/backend/foreign/foreign.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@
2828
#include "utils/syscache.h"
2929

3030

31-
extern Datum pg_options_to_table(PG_FUNCTION_ARGS);
32-
extern Datum postgresql_fdw_validator(PG_FUNCTION_ARGS);
33-
34-
3531
/*
3632
* GetForeignDataWrapper - look up the foreign-data wrapper by OID.
3733
*/

src/backend/storage/smgr/smgrtype.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "postgres.h"
1616

1717
#include "storage/smgr.h"
18+
#include "utils/builtins.h"
1819

1920

2021
typedef struct smgrid

src/backend/tsearch/dict_ispell.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "tsearch/dicts/spell.h"
1818
#include "tsearch/ts_locale.h"
1919
#include "tsearch/ts_utils.h"
20+
#include "utils/builtins.h"
2021

2122

2223
typedef struct

src/backend/tsearch/dict_simple.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "commands/defrem.h"
1717
#include "tsearch/ts_locale.h"
1818
#include "tsearch/ts_utils.h"
19+
#include "utils/builtins.h"
1920

2021

2122
typedef struct

src/backend/tsearch/dict_synonym.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "commands/defrem.h"
1717
#include "tsearch/ts_locale.h"
1818
#include "tsearch/ts_utils.h"
19+
#include "utils/builtins.h"
1920

2021
typedef struct
2122
{

src/backend/tsearch/ts_selfuncs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "miscadmin.h"
2020
#include "nodes/nodes.h"
2121
#include "tsearch/ts_type.h"
22+
#include "utils/builtins.h"
2223
#include "utils/lsyscache.h"
2324
#include "utils/selfuncs.h"
2425
#include "utils/syscache.h"

src/backend/utils/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/fmgrtab.c
22
/fmgroids.h
3+
/fmgrprotos.h
34
/probes.h
45
/errcodes.h

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy