mirror of
https://github.com/postgres/postgres.git
synced 2025-07-18 17:42:25 +03:00
Fix bogus test for hypothetical indexes in get_actual_variable_range().
That function was supposing that indexoid == 0 for a hypothetical index, but that is not likely to be true in any non-toy implementation of an index adviser, since assigning a fake OID is the only way to know at EXPLAIN time which hypothetical index got selected. Fix by adding a flag to IndexOptInfo to mark hypothetical indexes. Back-patch to 9.0 where get_actual_variable_range() was added. Gurjeet Singh
This commit is contained in:
@ -1611,10 +1611,12 @@ _outIndexOptInfo(StringInfo str, IndexOptInfo *node)
|
|||||||
WRITE_UINT_FIELD(pages);
|
WRITE_UINT_FIELD(pages);
|
||||||
WRITE_FLOAT_FIELD(tuples, "%.0f");
|
WRITE_FLOAT_FIELD(tuples, "%.0f");
|
||||||
WRITE_INT_FIELD(ncolumns);
|
WRITE_INT_FIELD(ncolumns);
|
||||||
|
WRITE_OID_FIELD(relam);
|
||||||
WRITE_NODE_FIELD(indexprs);
|
WRITE_NODE_FIELD(indexprs);
|
||||||
WRITE_NODE_FIELD(indpred);
|
WRITE_NODE_FIELD(indpred);
|
||||||
WRITE_BOOL_FIELD(predOK);
|
WRITE_BOOL_FIELD(predOK);
|
||||||
WRITE_BOOL_FIELD(unique);
|
WRITE_BOOL_FIELD(unique);
|
||||||
|
WRITE_BOOL_FIELD(hypothetical);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -275,6 +275,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
|
|||||||
ChangeVarNodes((Node *) info->indpred, 1, varno, 0);
|
ChangeVarNodes((Node *) info->indpred, 1, varno, 0);
|
||||||
info->predOK = false; /* set later in indxpath.c */
|
info->predOK = false; /* set later in indxpath.c */
|
||||||
info->unique = index->indisunique;
|
info->unique = index->indisunique;
|
||||||
|
info->hypothetical = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Estimate the index size. If it's not a partial index, we lock
|
* Estimate the index size. If it's not a partial index, we lock
|
||||||
|
@ -4555,10 +4555,10 @@ get_actual_variable_range(PlannerInfo *root, VariableStatData *vardata,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The index list might include fictitious indexes inserted by a
|
* The index list might include hypothetical indexes inserted by a
|
||||||
* get_relation_info hook --- don't try to access them.
|
* get_relation_info hook --- don't try to access them.
|
||||||
*/
|
*/
|
||||||
if (!OidIsValid(index->indexoid))
|
if (index->hypothetical)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -471,6 +471,8 @@ typedef struct IndexOptInfo
|
|||||||
bool amsearchnulls; /* can AM search for NULL/NOT NULL entries? */
|
bool amsearchnulls; /* can AM search for NULL/NOT NULL entries? */
|
||||||
bool amhasgettuple; /* does AM have amgettuple interface? */
|
bool amhasgettuple; /* does AM have amgettuple interface? */
|
||||||
bool amhasgetbitmap; /* does AM have amgetbitmap interface? */
|
bool amhasgetbitmap; /* does AM have amgetbitmap interface? */
|
||||||
|
/* added in 9.0.4: */
|
||||||
|
bool hypothetical; /* true if index doesn't really exist */
|
||||||
} IndexOptInfo;
|
} IndexOptInfo;
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user