mirror of
https://github.com/postgres/postgres.git
synced 2025-08-28 18:48:04 +03:00
Allow index AMs to return either HeapTuple or IndexTuple format during IOS.
Previously, only IndexTuple format was supported for the output data of an index-only scan. This is fine for btree, which is just returning a verbatim index tuple anyway. It's not so fine for SP-GiST, which can return reconstructed data that's much larger than a page. To fix, extend the index AM API so that index-only scan data can be returned in either HeapTuple or IndexTuple format. There's other ways we could have done it, but this way avoids an API break for index AMs that aren't concerned with the issue, and it costs little except a couple more fields in IndexScanDescs. I changed both GiST and SP-GiST to use the HeapTuple method. I'm not very clear on whether GiST can reconstruct data that's too large for an IndexTuple, but that seems possible, and it's not much of a code change to fix. Per a complaint from Vik Fearing. Reviewed by Jason Li. Discussion: https://postgr.es/m/49527f79-530d-0bfe-3dad-d183596afa92@2ndquadrant.fr
This commit is contained in:
@@ -119,6 +119,8 @@ RelationGetIndexScan(Relation indexRelation, int nkeys, int norderbys)
|
||||
|
||||
scan->xs_itup = NULL;
|
||||
scan->xs_itupdesc = NULL;
|
||||
scan->xs_hitup = NULL;
|
||||
scan->xs_hitupdesc = NULL;
|
||||
|
||||
ItemPointerSetInvalid(&scan->xs_ctup.t_self);
|
||||
scan->xs_ctup.t_data = NULL;
|
||||
|
@@ -535,8 +535,8 @@ index_getnext_tid(IndexScanDesc scan, ScanDirection direction)
|
||||
/*
|
||||
* The AM's amgettuple proc finds the next index entry matching the scan
|
||||
* keys, and puts the TID into scan->xs_ctup.t_self. It should also set
|
||||
* scan->xs_recheck and possibly scan->xs_itup, though we pay no attention
|
||||
* to those fields here.
|
||||
* scan->xs_recheck and possibly scan->xs_itup/scan->xs_hitup, though we
|
||||
* pay no attention to those fields here.
|
||||
*/
|
||||
found = scan->indexRelation->rd_amroutine->amgettuple(scan, direction);
|
||||
|
||||
|
Reference in New Issue
Block a user