projects
/
plantuner.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e254f0c
)
fix support of predefined GUC variables (in postgresql.conf)
author
Teodor Sigaev
<teodor@sigaev.ru>
Thu, 14 Feb 2019 12:45:55 +0000
(15:45 +0300)
committer
Teodor Sigaev
<teodor@sigaev.ru>
Thu, 14 Feb 2019 12:45:55 +0000
(15:45 +0300)
plantuner.c
patch
|
blob
|
history
diff --git
a/plantuner.c
b/plantuner.c
index
5a1d480
..
050e3b7
100644
(file)
--- a/
plantuner.c
+++ b/
plantuner.c
@@
-30,6
+30,7
@@
#include <postgres.h>
#include <fmgr.h>
#include <postgres.h>
#include <fmgr.h>
+#include <miscadmin.h>
#include <access/heapam.h>
#include <catalog/namespace.h>
#include <catalog/pg_class.h>
#include <access/heapam.h>
#include <catalog/namespace.h>
#include <catalog/pg_class.h>
@@
-58,6
+59,8
@@
static char *enableIndexesOutStr = "";
get_relation_info_hook_type prevHook = NULL;
static bool fix_empty_table = false;
get_relation_info_hook_type prevHook = NULL;
static bool fix_empty_table = false;
+static bool plantuner_enable_inited = false;
+static bool plantuner_disable_inited = false;
static const char *
indexesAssign(const char * newval, bool doit, GucSource source, bool isDisable)
static const char *
indexesAssign(const char * newval, bool doit, GucSource source, bool isDisable)
@@
-83,6
+86,19
@@
indexesAssign(const char * newval, bool doit, GucSource source, bool isDisable)
(int)(sizeof(Oid) * (nOids+1)));
}
(int)(sizeof(Oid) * (nOids+1)));
}
+ /*
+ * follow work could be done only in normal processing because of
+ * accsess to system catalog
+ */
+ if (MyBackendId == InvalidBackendId || !IsUnderPostmaster ||
+ !IsNormalProcessingMode() || MyAuxProcType != NotAnAuxProcess)
+ return newval;
+
+ if (isDisable)
+ plantuner_disable_inited = true;
+ else
+ plantuner_enable_inited = true;
+
foreach(l, namelist)
{
char *curname = (char *) lfirst(l);
foreach(l, namelist)
{
char *curname = (char *) lfirst(l);
@@
-161,6
+177,15
@@
assignEnabledIndexes(const char * newval, bool doit, GucSource source)
return indexesAssign(newval, doit, source, false);
}
return indexesAssign(newval, doit, source, false);
}
+static void
+lateInit()
+{
+ if (!plantuner_enable_inited)
+ indexesAssign(enableIndexesOutStr, true, PGC_S_USER, false);
+ if (!plantuner_disable_inited)
+ indexesAssign(disableIndexesOutStr, true, PGC_S_USER, true);
+}
+
#if PG_VERSION_NUM >= 90100
static bool
#if PG_VERSION_NUM >= 90100
static bool
@@
-215,6
+240,8
@@
indexFilter(PlannerInfo *root, Oid relationObjectId, bool inhparent,
{
int i;
{
int i;
+ lateInit();
+
for(i=0;i<nDisabledIndexes;i++)
{
ListCell *l;
for(i=0;i<nDisabledIndexes;i++)
{
ListCell *l;
@@
-277,6
+304,8
@@
IndexFilterShow(Oid* indexes, int nIndexes)
int i,
len;
int i,
len;
+ lateInit();
+
len = 1 /* \0 */ + nIndexes * (2 * NAMEDATALEN + 2 /* ', ' */ + 1 /* . */);
ptr = val = palloc(len);
len = 1 /* \0 */ + nIndexes * (2 * NAMEDATALEN + 2 /* ', ' */ + 1 /* . */);
ptr = val = palloc(len);