* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY CONTRIBUTORS ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
PG_MODULE_MAGIC;
-static int nDisabledIndexes = 0;
+static int nDisabledIndexes = 0;
static Oid *disabledIndexes = NULL;
static char *disableIndexesOutStr = "";
-static int nEnabledIndexes = 0;
+static int nEnabledIndexes = 0;
static Oid *enabledIndexes = NULL;
static char *enableIndexesOutStr = "";
static const char *
-indexesAssign(const char * newval, bool doit, GucSource source, bool isDisable)
+indexesAssign(const char * newval, bool doit, GucSource source, bool isDisable)
{
- char *rawname;
- List *namelist;
- ListCell *l;
+ char *rawname;
+ List *namelist;
+ ListCell *l;
Oid *newOids = NULL;
int nOids = 0,
i = 0;
if (!SplitIdentifierString(rawname, ',', &namelist))
goto cleanup;
- if (doit)
+ if (doit)
{
nOids = list_length(namelist);
newOids = malloc(sizeof(Oid) * (nOids+1));
if (!newOids)
- elog(ERROR,"could not allocate %d bytes", (int)(sizeof(Oid) * (nOids+1)));
+ elog(ERROR,"could not allocate %d bytes",
+ (int)(sizeof(Oid) * (nOids+1)));
}
foreach(l, namelist)
{
- char *curname = (char *) lfirst(l);
+ char *curname = (char *) lfirst(l);
#if PG_VERSION_NUM >= 90200
- Oid indexOid = RangeVarGetRelid(makeRangeVarFromNameList(stringToQualifiedNameList(curname)),
- NoLock, true);
+ Oid indexOid = RangeVarGetRelid(
+ makeRangeVarFromNameList(stringToQualifiedNameList(curname)),
+ NoLock, true);
#else
- Oid indexOid = RangeVarGetRelid(makeRangeVarFromNameList(stringToQualifiedNameList(curname)),
- true);
+ Oid indexOid = RangeVarGetRelid(
+ makeRangeVarFromNameList(stringToQualifiedNameList(curname)),
+ true);
#endif
if (indexOid == InvalidOid)
}
}
- if (doit)
+ if (doit)
{
if (isDisable)
{
static const char *
assignDisabledIndexes(const char * newval, bool doit, GucSource source)
{
- return indexesAssign(newval, doit, source, true);
+ return indexesAssign(newval, doit, source, true);
}
static const char *
assignEnabledIndexes(const char * newval, bool doit, GucSource source)
{
- return indexesAssign(newval, doit, source, false);
+ return indexesAssign(newval, doit, source, false);
}
#if PG_VERSION_NUM >= 90100
#endif
static void
-indexFilter(PlannerInfo *root, Oid relationObjectId, bool inhparent, RelOptInfo *rel) {
+indexFilter(PlannerInfo *root, Oid relationObjectId, bool inhparent,
+ RelOptInfo *rel)
+{
int i;
for(i=0;i<nDisabledIndexes;i++)
}
static void
-execPlantuner(PlannerInfo *root, Oid relationObjectId, bool inhparent, RelOptInfo *rel) {
- Relation relation;
+execPlantuner(PlannerInfo *root, Oid relationObjectId, bool inhparent,
+ RelOptInfo *rel)
+{
+ Relation relation;
relation = heap_open(relationObjectId, NoLock);
if (relation->rd_rel->relkind == RELKIND_RELATION)
heap_close(relation, NoLock);
/*
- * Call next hook if it exists
+ * Call next hook if it exists
*/
if (prevHook)
prevHook(root, relationObjectId, inhparent, rel);
}
static const char*
-IndexFilterShow(Oid* indexes, int nIndexes)
+IndexFilterShow(Oid* indexes, int nIndexes)
{
- char *val, *ptr;
- int i,
+ char *val, *ptr;
+ int i,
len;
len = 1 /* \0 */ + nIndexes * (2 * NAMEDATALEN + 2 /* ', ' */ + 1 /* . */);
*ptr =(char)'\0';
for(i=0; i<nIndexes; i++)
{
- char *relname = get_rel_name(indexes[i]);
- Oid nspOid = get_rel_namespace(indexes[i]);
- char *nspname = get_namespace_name(nspOid);
+ char *relname = get_rel_name(indexes[i]);
+ Oid nspOid = get_rel_namespace(indexes[i]);
+ char *nspname = get_namespace_name(nspOid);
if ( relname == NULL || nspOid == InvalidOid || nspname == NULL )
continue;
void _PG_init(void);
void
-_PG_init(void)
+_PG_init(void)
{
- DefineCustomStringVariable(
+ DefineCustomStringVariable(
"plantuner.forbid_index",
"List of forbidden indexes (deprecated)",
"Listed indexes will not be used in queries (deprecated, use plantuner.disable_index)",
disabledIndexFilterShow
);
- DefineCustomStringVariable(
+ DefineCustomStringVariable(
"plantuner.disable_index",
"List of disabled indexes",
"Listed indexes will not be used in queries",
disabledIndexFilterShow
);
- DefineCustomStringVariable(
+ DefineCustomStringVariable(
"plantuner.enable_index",
"List of enabled indexes (overload plantuner.disable_index)",
"Listed indexes which could be used in queries even they are listed in plantuner.disable_index",
enabledIndexFilterShow
);
- DefineCustomBoolVariable(
+ DefineCustomBoolVariable(
"plantuner.fix_empty_table",
"Sets to zero estimations for empty tables",
"Sets to zero estimations for empty or newly created tables",