From e4fb8ff06a8aa1b4c073c46f63b7effd5885e327 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 17 Oct 2008 22:10:30 +0000 Subject: Add a new column to pg_am to specify whether an index AM supports backward scanning; GiST and GIN do not, and it seems like too much trouble to make them do so. By teaching ExecSupportsBackwardScan() about this restriction, we ensure that the planner will protect a scroll cursor from the problem by adding a Materialize node. In passing, fix another longstanding bug in the same area: backwards scan of a plan with set-returning functions in the targetlist did not work either, since the TupFromTlist expansion code pays no attention to direction (and has no way to run a SRF backwards anyway). Again the fix is to make ExecSupportsBackwardScan check this restriction. Also adjust the index AM API specification to note that mark/restore support is unnecessary if the AM can't produce ordered output. --- doc/src/sgml/catalogs.sgml | 9 ++++++++- doc/src/sgml/indexam.sgml | 19 ++++++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml index ae6dfbd8a55..a68799334ad 100644 --- a/doc/src/sgml/catalogs.sgml +++ b/doc/src/sgml/catalogs.sgml @@ -1,4 +1,4 @@ - + @@ -401,6 +401,13 @@ Does the access method support ordered scans? + + amcanbackward + bool + + Does the access method support backward scanning? + + amcanunique bool diff --git a/doc/src/sgml/indexam.sgml b/doc/src/sgml/indexam.sgml index 393ccfa2dd1..db16c1d4ee5 100644 --- a/doc/src/sgml/indexam.sgml +++ b/doc/src/sgml/indexam.sgml @@ -1,4 +1,4 @@ - + Index Access Method Interface Definition @@ -474,15 +474,20 @@ amrestrpos (IndexScanDesc scan); normally would. (This will only occur for access methods that advertise they support ordered scans.) After the first call, amgettuple must be prepared to advance the scan in - either direction from the most recently returned entry. + either direction from the most recently returned entry. (But if + pg_am.amcanbackward is false, all subsequent + calls will have the same direction as the first one.) - The access method must support marking a position in a scan - and later returning to the marked position. The same position might be - restored multiple times. However, only one position need be remembered - per scan; a new ammarkpos call overrides the previously - marked position. + Access methods that support ordered scans must support marking a + position in a scan and later returning to the marked position. The same + position might be restored multiple times. However, only one position need + be remembered per scan; a new ammarkpos call overrides the + previously marked position. An access method that does not support + ordered scans should still provide mark and restore functions in + pg_am, but it is sufficient to have them throw errors if + called. -- cgit v1.2.3