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

Appearance settings

Commit 6402afd

Browse filesBrowse files
committed
Properly check index mark/restore in ExecSupportsMarkRestore.
Previously this code assumed that all IndexScan nodes supported mark/restore, which is not true since it depends on optional index AM support functions. This could lead to errors about missing support functions in rare edge cases of mergejoins with no sort keys, where an unordered non-btree index scan was placed on the inner path without a protecting Materialize node. (Normally, the fact that merge join requires ordered input would avoid this error.) Backpatch all the way since this bug is ancient. Per report from Eugen Konkov on irc. Discussion: https://postgr.es/m/87o8jn50be.fsf@news-spur.riddles.org.uk
1 parent 02a2dbe commit 6402afd
Copy full SHA for 6402afd

File tree

Expand file treeCollapse file tree

3 files changed

+8
-0
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+8
-0
lines changed

‎src/backend/executor/execAmi.c

Copy file name to clipboardExpand all lines: src/backend/executor/execAmi.c
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,11 @@ ExecSupportsMarkRestore(Path *pathnode)
394394
{
395395
case T_IndexScan:
396396
case T_IndexOnlyScan:
397+
/*
398+
* Not all index types support mark/restore.
399+
*/
400+
return castNode(IndexPath, pathnode)->indexinfo->amcanmarkpos;
401+
397402
case T_Material:
398403
case T_Sort:
399404
return true;

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

Copy file name to clipboardExpand all lines: src/backend/optimizer/util/plancat.c
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
242242
info->amsearchnulls = amroutine->amsearchnulls;
243243
info->amhasgettuple = (amroutine->amgettuple != NULL);
244244
info->amhasgetbitmap = (amroutine->amgetbitmap != NULL);
245+
info->amcanmarkpos = (amroutine->ammarkpos != NULL &&
246+
amroutine->amrestrpos != NULL);
245247
info->amcostestimate = amroutine->amcostestimate;
246248
Assert(info->amcostestimate != NULL);
247249

‎src/include/nodes/relation.h

Copy file name to clipboardExpand all lines: src/include/nodes/relation.h
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,7 @@ typedef struct IndexOptInfo
620620
bool amsearchnulls; /* can AM search for NULL/NOT NULL entries? */
621621
bool amhasgettuple; /* does AM have amgettuple interface? */
622622
bool amhasgetbitmap; /* does AM have amgetbitmap interface? */
623+
bool amcanmarkpos; /* does AM support mark/restore? */
623624
/* Rather than include amapi.h here, we declare amcostestimate like this */
624625
void (*amcostestimate) (); /* AM's cost estimator */
625626
} IndexOptInfo;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.