Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita2095f7

Browse files
committed
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 indexadviser, since assigning a fake OID is the only way to know at EXPLAIN timewhich hypothetical index got selected. Fix by adding a flag toIndexOptInfo to mark hypothetical indexes. Back-patch to 9.0 whereget_actual_variable_range() was added.Gurjeet Singh
1 parent6595dd0 commita2095f7

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

‎src/backend/nodes/outfuncs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,10 +1700,12 @@ _outIndexOptInfo(StringInfo str, IndexOptInfo *node)
17001700
WRITE_UINT_FIELD(pages);
17011701
WRITE_FLOAT_FIELD(tuples,"%.0f");
17021702
WRITE_INT_FIELD(ncolumns);
1703+
WRITE_OID_FIELD(relam);
17031704
WRITE_NODE_FIELD(indexprs);
17041705
WRITE_NODE_FIELD(indpred);
17051706
WRITE_BOOL_FIELD(predOK);
17061707
WRITE_BOOL_FIELD(unique);
1708+
WRITE_BOOL_FIELD(hypothetical);
17071709
}
17081710

17091711
staticvoid

‎src/backend/optimizer/util/plancat.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
316316
ChangeVarNodes((Node*)info->indpred,1,varno,0);
317317
info->predOK= false;/* set later in indxpath.c */
318318
info->unique=index->indisunique;
319+
info->hypothetical= false;
319320

320321
/*
321322
* Estimate the index size. If it's not a partial index, we lock

‎src/backend/utils/adt/selfuncs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4562,10 +4562,10 @@ get_actual_variable_range(PlannerInfo *root, VariableStatData *vardata,
45624562
continue;
45634563

45644564
/*
4565-
* The index list might includefictitious indexes inserted by a
4565+
* The index list might includehypothetical indexes inserted by a
45664566
* get_relation_info hook --- don't try to access them.
45674567
*/
4568-
if (!OidIsValid(index->indexoid))
4568+
if (index->hypothetical)
45694569
continue;
45704570

45714571
/*

‎src/include/nodes/relation.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ typedef struct IndexOptInfo
455455
intncolumns;/* number of columns in index */
456456
Oid*opfamily;/* OIDs of operator families for columns */
457457
int*indexkeys;/* column numbers of index's keys, or 0 */
458-
Oid*indexcollations;/* OIDs ofthecollations of the index columns */
458+
Oid*indexcollations;/* OIDs of collations of index columns */
459459
Oid*opcintype;/* OIDs of opclass declared input data types */
460460
Oid*sortopfamily;/* OIDs of btree opfamilies, if orderable */
461461
bool*reverse_sort;/* is sort order descending? */
@@ -469,6 +469,7 @@ typedef struct IndexOptInfo
469469

470470
boolpredOK;/* true if predicate matches query */
471471
boolunique;/* true if a unique index */
472+
boolhypothetical;/* true if index doesn't really exist */
472473
boolamcanorderbyop;/* does AM support order by operator result? */
473474
boolamoptionalkey;/* can query omit key for the first column? */
474475
boolamsearchnulls;/* can AM search for NULL/NOT NULL entries? */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp