--- /dev/null
+# 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',
+ ],
+ },
+}
#include <access/xact.h>
#include <catalog/namespace.h>
#include <catalog/pg_class.h>
+#if PG_VERSION_NUM >= 160000
+#include <nodes/miscnodes.h>
+#endif
#include <nodes/pg_list.h>
#include <optimizer/plancat.h>
#include <storage/bufmgr.h>
PG_MODULE_MAGIC;
+#if PG_VERSION_NUM >= 130000
+#define heap_open(r, l) table_open(r, l)
+#define heap_close(r, l) table_close(r, l)
+#endif
+
static int nDisabledIndexes = 0;
static Oid *disabledIndexes = NULL;
static char *disableIndexesOutStr = "";
* 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 */
{
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)),
{
ListCell *l;
+restart1:
foreach(l, rel->indexlist)
{
IndexOptInfo *info = (IndexOptInfo*)lfirst(l);
remove = false;
if (remove)
+ {
rel->indexlist = list_delete_ptr(rel->indexlist, info);
+ goto restart1;
+ }
}
return;