- fix "function declaration isn’t a prototype" master
authorTeodor Sigaev <teodor@sigaev.ru>
Wed, 8 Jul 2026 10:03:38 +0000 (13:03 +0300)
committerTeodor Sigaev <teodor@sigaev.ru>
Wed, 8 Jul 2026 10:03:38 +0000 (13:03 +0300)
- use build_simple_rel_hook instead of get_relation_info_hook for PG 19

Marina Polyakova

plantuner.c

index 0148a75..d31dbbb 100644 (file)
@@ -39,6 +39,9 @@
 #include <nodes/miscnodes.h>
 #endif
 #include <nodes/pg_list.h>
+#if PG_VERSION_NUM >= 190000
+#include <optimizer/pathnode.h>
+#endif
 #include <optimizer/plancat.h>
 #include <storage/bufmgr.h>
 #include <utils/builtins.h>
@@ -69,7 +72,12 @@ static int   nOnlyIndexes = 0;
 static Oid     *onlyIndexes = NULL;
 static char *onlyIndexesOutStr = "";
 
+#if PG_VERSION_NUM >= 190000
+static build_simple_rel_hook_type      prevHook = NULL;
+#else
 static get_relation_info_hook_type     prevHook = NULL;
+#endif
+
 static bool    fix_empty_table = false;
 
 static bool    plantuner_enable_inited = false;
@@ -261,7 +269,7 @@ assignOnlyIndexes(const char * newval, bool doit, GucSource source)
 }
 
 static void
-lateInit()
+lateInit(void)
 {
        if (!plantuner_only_inited)
                indexesAssign(onlyIndexesOutStr, true, PGC_S_USER, OnlyKind);
@@ -399,9 +407,16 @@ restart1:
 }
 
 static void
+#if PG_VERSION_NUM >= 190000
+execPlantuner(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
+{
+       Oid                     relationObjectId = rte->relid;
+       bool            inhparent = rte->inh;
+#else
 execPlantuner(PlannerInfo *root, Oid relationObjectId, bool inhparent,
                          RelOptInfo *rel)
 {
+#endif
        Relation        relation;
 
        relation = heap_open(relationObjectId, NoLock);
@@ -425,7 +440,11 @@ execPlantuner(PlannerInfo *root, Oid relationObjectId, bool inhparent,
         * Call next hook if it exists
         */
        if (prevHook)
+#if PG_VERSION_NUM >= 190000
+               prevHook(root, rel, rte);
+#else
                prevHook(root, relationObjectId, inhparent, rel);
+#endif
 }
 
 static const char*
@@ -568,9 +587,17 @@ _PG_init(void)
                NULL
        );
 
+#if PG_VERSION_NUM >= 190000
+       if (build_simple_rel_hook != execPlantuner )
+       {
+               prevHook = build_simple_rel_hook;
+               build_simple_rel_hook = execPlantuner;
+       }
+#else
        if (get_relation_info_hook != execPlantuner )
        {
                prevHook = get_relation_info_hook;
                get_relation_info_hook = execPlantuner;
        }
+#endif
 }