aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2011-02-16 19:24:45 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2011-02-16 19:24:45 -0500
commita2095f7fb5a57ea1794f25d029756d9a140fd429 (patch)
tree88d2127208f79e35b3b4237b00b54f41f9ae9164 /src/backend
parent6595dd04d136d5c97ae05fc580572c8f00042143 (diff)
downloadpostgresql-a2095f7fb5a57ea1794f25d029756d9a140fd429.tar.gz
postgresql-a2095f7fb5a57ea1794f25d029756d9a140fd429.zip
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
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/nodes/outfuncs.c2
-rw-r--r--src/backend/optimizer/util/plancat.c1
-rw-r--r--src/backend/utils/adt/selfuncs.c4
3 files changed, 5 insertions, 2 deletions
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index 5c943bc2543..192c0422913 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -1700,10 +1700,12 @@ _outIndexOptInfo(StringInfo str, IndexOptInfo *node)
WRITE_UINT_FIELD(pages);
WRITE_FLOAT_FIELD(tuples, "%.0f");
WRITE_INT_FIELD(ncolumns);
+ WRITE_OID_FIELD(relam);
WRITE_NODE_FIELD(indexprs);
WRITE_NODE_FIELD(indpred);
WRITE_BOOL_FIELD(predOK);
WRITE_BOOL_FIELD(unique);
+ WRITE_BOOL_FIELD(hypothetical);
}
static void
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index 1f79ba24fb3..40df626b62f 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -316,6 +316,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
ChangeVarNodes((Node *) info->indpred, 1, varno, 0);
info->predOK = false; /* set later in indxpath.c */
info->unique = index->indisunique;
+ info->hypothetical = false;
/*
* Estimate the index size. If it's not a partial index, we lock
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
index b3299b56d83..f10110b1b7e 100644
--- a/src/backend/utils/adt/selfuncs.c
+++ b/src/backend/utils/adt/selfuncs.c
@@ -4562,10 +4562,10 @@ get_actual_variable_range(PlannerInfo *root, VariableStatData *vardata,
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.
*/
- if (!OidIsValid(index->indexoid))
+ if (index->hypothetical)
continue;
/*