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 660b899

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 b0727ae commit 660b899
Copy full SHA for 660b899

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
@@ -417,6 +417,11 @@ ExecSupportsMarkRestore(Path *pathnode)
417417
{
418418
case T_IndexScan:
419419
case T_IndexOnlyScan:
420+
/*
421+
* Not all index types support mark/restore.
422+
*/
423+
return castNode(IndexPath, pathnode)->indexinfo->amcanmarkpos;
424+
420425
case T_Material:
421426
case T_Sort:
422427
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
@@ -284,6 +284,8 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
284284
info->amhasgettuple = (amroutine->amgettuple != NULL);
285285
info->amhasgetbitmap = amroutine->amgetbitmap != NULL &&
286286
relation->rd_tableam->scan_bitmap_next_block != NULL;
287+
info->amcanmarkpos = (amroutine->ammarkpos != NULL &&
288+
amroutine->amrestrpos != NULL);
287289
info->amcostestimate = amroutine->amcostestimate;
288290
Assert(info->amcostestimate != NULL);
289291

‎src/include/nodes/pathnodes.h

Copy file name to clipboardExpand all lines: src/include/nodes/pathnodes.h
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,7 @@ struct IndexOptInfo
864864
bool amhasgettuple; /* does AM have amgettuple interface? */
865865
bool amhasgetbitmap; /* does AM have amgetbitmap interface? */
866866
bool amcanparallel; /* does AM support parallel scan? */
867+
bool amcanmarkpos; /* does AM support mark/restore? */
867868
/* Rather than include amapi.h here, we declare amcostestimate like this */
868869
void (*amcostestimate) (); /* AM's cost estimator */
869870
};

0 commit comments

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