From: Teodor Sigaev Date: Fri, 13 Sep 2024 07:36:39 +0000 (+0300) Subject: Add static decoration to avoid error: "no X-Git-Url: http://www.sigaev.ru/git/gitweb.cgi?p=plantuner.git;a=commitdiff_plain;h=HEAD;hp=800d81bc85da64ff3ef66e12aed1d4e1e54fc006 Add static decoration to avoid error: "no previous extern declaration for non-static variable [-Wmissing-variable-declarations]" in clang-17 build. Anton A. Melnikov --- diff --git a/.gitignore b/.gitignore index 46eea3c..b09edda 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ temp diffs etc results +log/ diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..40324a1 --- /dev/null +++ b/meson.build @@ -0,0 +1,32 @@ +# Copyright (c) 2023, Postgres Professional + +plantuner_sources = files( + 'plantuner.c' +) + +if host_system == 'windows' + plantuner_sources += rc_lib_gen.process(win32ver_rc, extra_args: [ + '--NAME', 'plantuner', + '--FILEDESC', 'plantuner - provides hints for the planner that can disable or enable indexes for query execution',]) +endif + +plantuner = shared_module('plantuner', + plantuner_sources, + kwargs: contrib_mod_args, +) +contrib_targets += plantuner + +install_data( + kwargs: contrib_data_args, +) + +tests += { + 'name': 'plantuner', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'regress': { + 'sql': [ + 'plantuner', + ], + }, +} diff --git a/plantuner.c b/plantuner.c index f87dcea..0148a75 100644 --- a/plantuner.c +++ b/plantuner.c @@ -35,6 +35,9 @@ #include #include #include +#if PG_VERSION_NUM >= 160000 +#include +#endif #include #include #include @@ -66,7 +69,7 @@ static int nOnlyIndexes = 0; static Oid *onlyIndexes = NULL; static char *onlyIndexesOutStr = ""; -get_relation_info_hook_type prevHook = NULL; +static get_relation_info_hook_type prevHook = NULL; static bool fix_empty_table = false; static bool plantuner_enable_inited = false; @@ -99,7 +102,12 @@ indexesAssign(const char * newval, bool doit, GucSource source, * follow work could be done only in normal processing because of * accsess to system catalog */ - if (MyBackendId == InvalidBackendId || !IsUnderPostmaster || +#if PG_VERSION_NUM >= 170000 + if (MyProcNumber == INVALID_PROC_NUMBER || +#else + if (MyBackendId == InvalidBackendId || +#endif + !IsUnderPostmaster || !IsTransactionState()) { /* reset init state */ @@ -149,9 +157,23 @@ indexesAssign(const char * newval, bool doit, GucSource source, { char *curname = (char *) lfirst(l); #if PG_VERSION_NUM >= 90200 - Oid indexOid = RangeVarGetRelid( - makeRangeVarFromNameList(stringToQualifiedNameList(curname)), - NoLock, true); + List *cur_namelist; + Oid indexOid; + +#if PG_VERSION_NUM >= 160000 + ErrorSaveContext escontext = {T_ErrorSaveContext}; + + cur_namelist = stringToQualifiedNameList(curname, (Node *) &escontext); + + /* bad name list syntax */ + if (cur_namelist == NIL) + continue; +#else + cur_namelist = stringToQualifiedNameList(curname); +#endif + + indexOid = RangeVarGetRelid(makeRangeVarFromNameList(cur_namelist), + NoLock, true); #else Oid indexOid = RangeVarGetRelid( makeRangeVarFromNameList(stringToQualifiedNameList(curname)),