ossc-db / pg_hint_plan

Extension adding support for optimizer hints in PostgreSQL
Other
696 stars 103 forks source link

pg_hint_plan-{1.4.1,1.5.0} fail to compile #134

Closed patricklauer closed 1 year ago

patricklauer commented 1 year ago

1.3.8 builds without issue, both 1.4.1 and 1.5.0 fail with the same error:

x86_64-pc-linux-gnu-gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -O2 -pipe -fPIC -I. -I./ -I/usr/include/postgresql-13/server -I/usr/include/postgresql-13/internal  -D_GNU_SOURCE   -c -o pg_hint_plan.o pg_hint_plan.c
In file included from pg_hint_plan.c:57:
normalize_query.h:15:27: error: unknown type name ‘JumbleState’
   15 | generate_normalized_query(JumbleState *jstate, const char *query,
      |                           ^~~~~~~~~~~
pg_hint_plan.c:424:89: error: unknown type name ‘JumbleState’
  424 |                                                                                         JumbleState *jstate);
      |                                                                                         ^~~~~~~~~~~
pg_hint_plan.c: In function ‘_PG_init’:
pg_hint_plan.c:726:35: error: ‘pg_hint_plan_post_parse_analyze’ undeclared (first use in this function)
  726 |         post_parse_analyze_hook = pg_hint_plan_post_parse_analyze;
      |                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pg_hint_plan.c:726:35: note: each undeclared identifier is reported only once for each function it appears in
pg_hint_plan.c: In function ‘enable_hint_table_check’:
pg_hint_plan.c:765:17: warning: implicit declaration of function ‘EnableQueryId’ [-Wimplicit-function-declaration]
  765 |                 EnableQueryId();
      |                 ^~~~~~~~~~~~~
pg_hint_plan.c:767:22: warning: implicit declaration of function ‘IsQueryIdEnabled’ [-Wimplicit-function-declaration]
  767 |                 if (!IsQueryIdEnabled())
      |                      ^~~~~~~~~~~~~~~~
pg_hint_plan.c: In function ‘get_current_join_mask’:
pg_hint_plan.c:2548:13: error: ‘enable_memoize’ undeclared (first use in this function); did you mean ‘enable_geqo’?
 2548 |         if (enable_memoize)
      |             ^~~~~~~~~~~~~~
      |             enable_geqo
pg_hint_plan.c: At top level:
pg_hint_plan.c:2823:49: error: unknown type name ‘JumbleState’
 2823 |                                                 JumbleState *jstate)
      |                                                 ^~~~~~~~~~~
pg_hint_plan.c:2976:65: error: unknown type name ‘JumbleState’
 2976 |                                                                 JumbleState *jstate)
      |                                                                 ^~~~~~~~~~~
pg_hint_plan.c: In function ‘pg_hint_plan_planner’:
pg_hint_plan.c:3042:17: warning: implicit declaration of function ‘get_current_hint_string’ [-Wimplicit-function-declaration]
 3042 |                 get_current_hint_string(parse, query_string, NULL);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~
In file included from pg_hint_plan.c:4930:
core.c: In function ‘try_partitionwise_join’:
core.c:1376:32: error: ‘RelOptInfo’ has no member named ‘live_parts’
 1376 |                         joinrel->live_parts = bms_add_member(joinrel->live_parts, cnt_parts);
      |                                ^~
core.c:1376:69: error: ‘RelOptInfo’ has no member named ‘live_parts’
 1376 |                         joinrel->live_parts = bms_add_member(joinrel->live_parts, cnt_parts);
      |                                                                     ^~
In file included from pg_hint_plan.c:4937:
pg_stat_statements.c: At top level:
pg_stat_statements.c:15:40: error: unknown type name ‘JumbleState’
   15 | static char *generate_normalized_query(JumbleState *jstate, const char *query,
      |                                        ^~~~~~~~~~~
pg_stat_statements.c:17:38: error: unknown type name ‘JumbleState’
   17 | static void fill_in_constant_lengths(JumbleState *jstate, const char *query,
      |                                      ^~~~~~~~~~~
pg_stat_statements.c:43:27: error: unknown type name ‘JumbleState’
   43 | generate_normalized_query(JumbleState *jstate, const char *query,
      |                           ^~~~~~~~~~~
pg_stat_statements.c:152:26: error: unknown type name ‘JumbleState’
  152 | fill_in_constant_lengths(JumbleState *jstate, const char *query,
      |                          ^~~~~~~~~~~
pg_stat_statements.c: In function ‘comp_location’:
pg_stat_statements.c:254:45: error: unknown type name ‘LocationLen’
  254 |         int                     l = ((const LocationLen *) a)->location;
      |                                             ^~~~~~~~~~~
pg_stat_statements.c:255:45: error: unknown type name ‘LocationLen’
  255 |         int                     r = ((const LocationLen *) b)->location;
      |                                             ^~~~~~~~~~~
pg_stat_statements.c: At top level:
pg_stat_statements.c:252:1: warning: ‘comp_location’ defined but not used [-Wunused-function]
  252 | comp_location(const void *a, const void *b)
      | ^~~~~~~~~~~~~
pg_hint_plan.c:1894:1: warning: ‘get_hints_from_comment’ defined but not used [-Wunused-function]
 1894 | get_hints_from_comment(const char *p)
      | ^~~~~~~~~~~~~~~~~~~~~~
pg_hint_plan.c:1810:1: warning: ‘get_hints_from_table’ defined but not used [-Wunused-function]
 1810 | get_hints_from_table(const char *client_query, const char *client_application)
      | ^~~~~~~~~~~~~~~~~~~~
make: *** [<builtin>: pg_hint_plan.o] Error 1

The root cause appears to be a change coming from 454f72a07c2bfa37816be9b223de17e01bdb23c8 which leaves JumbleState now undefined.

patricklauer commented 1 year ago

Ah, what a silly thing: Makefile setting "PG_CONFIG=pg_config" randomizes which pg_config will be used if multiple postgresen are installed.

I've fixed it locally by forcing the specific per-version pg_config, now builds as expected.