1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

Replace simple constant pg_am.amcanreturn with an AM support function.

The need for this was debated when we put in the index-only-scan feature,
but at the time we had no near-term expectation of having AMs that could
support such scans for only some indexes; so we kept it simple.  However,
the SP-GiST AM forces the issue, so let's fix it.

This patch only installs the new API; no behavior actually changes.
This commit is contained in:
Tom Lane
2011-12-18 15:49:00 -05:00
parent 19d2231718
commit 3695a55513
15 changed files with 103 additions and 46 deletions

View File

@ -481,13 +481,6 @@
<entry>Does the access method support multicolumn indexes?</entry>
</row>
<row>
<entry><structfield>amcanreturn</structfield></entry>
<entry><type>bool</type></entry>
<entry></entry>
<entry>Can the access method return the contents of index entries?</entry>
</row>
<row>
<entry><structfield>amoptionalkey</structfield></entry>
<entry><type>bool</type></entry>
@ -622,6 +615,14 @@
<entry>Post-<command>VACUUM</command> cleanup function</entry>
</row>
<row>
<entry><structfield>amcanreturn</structfield></entry>
<entry><type>regproc</type></entry>
<entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
<entry>Function to check whether index supports index-only scans,
or zero if none</entry>
</row>
<row>
<entry><structfield>amcostestimate</structfield></entry>
<entry><type>regproc</type></entry>

View File

@ -134,11 +134,6 @@
<structfield>amsearchnulls</structfield>, indicating that it supports
<literal>IS NULL</> and <literal>IS NOT NULL</> clauses as search
conditions.
An index method can also set <structfield>amcanreturn</structfield>,
indicating that it can support <firstterm>index-only scans</> by returning
the indexed column values for an index entry in the form of an IndexTuple.
(An example of an index AM that cannot do this is hash, which stores only
the hash values not the original data.)
</para>
</sect1>
@ -278,6 +273,19 @@ amvacuumcleanup (IndexVacuumInfo *info,
<para>
<programlisting>
bool
amcanreturn (Relation indexRelation);
</programlisting>
Check whether the index can support <firstterm>index-only scans</> by
returning the indexed column values for an index entry in the form of an
IndexTuple. Return TRUE if so, else FALSE. If the index AM can never
support index-only scans (an example is hash, which stores only
the hash values not the original data), it is sufficient to set its
<structfield>amcanreturn</> field to zero in <structname>pg_am</>.
</para>
<para>
<programlisting>
void
amcostestimate (PlannerInfo *root,
IndexOptInfo *index,
@ -391,9 +399,9 @@ amgettuple (IndexScanDesc scan,
</para>
<para>
If the access method supports index-only scans (i.e.,
<structfield>amcanreturn</structfield> is TRUE in its <structname>pg_am</>
row), then on success it must also check
If the index supports index-only scans (i.e.,
<function>amcanreturn</function> returns TRUE for it),
then on success the AM must also check
<literal>scan-&gt;xs_want_itup</>, and if that is true it must return
the original indexed data for the index entry, in the form of an
<structname>IndexTuple</> pointer stored at <literal>scan-&gt;xs_itup</>,