X-Git-Url: http://sigaev.ru/git/gitweb.cgi?p=plantuner.git;a=blobdiff_plain;f=plantuner.c;h=b22ef9cf00a6a80f84d2cefa23e96b91337ce2d5;hp=1973d0176a36ee29260c0521e8968bb50bc12a8a;hb=HEAD;hpb=ecc61f2bf65d40d144e394dc228e9f93d865776e diff --git a/plantuner.c b/plantuner.c index 1973d01..e454698 100644 --- a/plantuner.c +++ b/plantuner.c @@ -35,6 +35,9 @@ #include #include #include +#if PG_VERSION_NUM >= 160000 +#include +#endif #include #include #include @@ -49,6 +52,11 @@ 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 = ""; @@ -94,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 */ @@ -144,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)), @@ -326,6 +353,7 @@ indexFilter(PlannerInfo *root, Oid relationObjectId, bool inhparent, { ListCell *l; +restart1: foreach(l, rel->indexlist) { IndexOptInfo *info = (IndexOptInfo*)lfirst(l); @@ -336,7 +364,10 @@ indexFilter(PlannerInfo *root, Oid relationObjectId, bool inhparent, remove = false; if (remove) + { rel->indexlist = list_delete_ptr(rel->indexlist, info); + goto restart1; + } } return;