From 10e7ea2da2b49d46fb8479deab92fc9296eb8d0f Mon Sep 17 00:00:00 2001 From: Julien Rouhaud Date: Mon, 16 Mar 2015 00:11:24 +0100 Subject: [PATCH] Fix forgotten hardcoded 1st attribute, and some other minor changes --- pg_hypo.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pg_hypo.c b/pg_hypo.c index 3031af6..6c0068d 100644 --- a/pg_hypo.c +++ b/pg_hypo.c @@ -507,7 +507,7 @@ addHypotheticalIndex(PlannerInfo *root, Oid relationObjectId, bool inhparent, Re for (i = 0; i < ncolumns; i++) { - index->indexkeys[i] = 1; // 1st col, WIP + index->indexkeys[i] = entry.indexkeys; switch (index->relam) { case BTREE_AM_OID: @@ -519,6 +519,8 @@ addHypotheticalIndex(PlannerInfo *root, Oid relationObjectId, bool inhparent, Re } } + index->unique = false; /* no hypothetical unique index */ + if (index->relam == BTREE_AM_OID) { index->canreturn = true; @@ -528,7 +530,6 @@ addHypotheticalIndex(PlannerInfo *root, Oid relationObjectId, bool inhparent, Re index->amsearchnulls = true; index->amhasgettuple = true; index->amhasgetbitmap = true; - index->unique = false; index->immediate = true; index->amcostestimate = (RegProcedure) 1268; // btcostestimate index->sortopfamily = index->opfamily; @@ -545,13 +546,14 @@ addHypotheticalIndex(PlannerInfo *root, Oid relationObjectId, bool inhparent, Re } index->indexprs = NIL; // not handled for now, WIP - index->indpred = NIL; // not handled for now, WIP + index->indpred = NIL; // no partial index handled for now, WIP + /* Build targetlist using the completed indexprs data, stolen from PostgreSQL */ index->indextlist = build_index_tlist(root, index, relation); if (index->indpred == NIL) { - index->pages = rel->tuples / 10; // Should compute if col width and other stuff, WIP + index->pages = rel->tuples / 10; // Should compute with col width and other stuff, WIP index->tuples = rel->tuples; // Same }