@@ -181,7 +181,7 @@ typedef struct IndexAmRoutine
181
181
implications. The requirements of <structfield>amcanunique</structfield>
182
182
are discussed in <xref linkend="index-unique-checks"/>.
183
183
The <structfield>amcanmulticol</structfield> flag asserts that the
184
- access method supports multicolumn indexes, while
184
+ access method supports multi-key-column indexes, while
185
185
<structfield>amoptionalkey</structfield> asserts that it allows scans
186
186
where no indexable restriction clause is given for the first index column.
187
187
When <structfield>amcanmulticol</structfield> is false,
@@ -217,6 +217,19 @@ typedef struct IndexAmRoutine
217
217
conditions.
218
218
</para>
219
219
220
+ <para>
221
+ The <structfield>amcaninclude</structfield> flag indicates whether the
222
+ access method supports <quote>included</quote> columns, that is it can
223
+ store (without processing) additional columns beyond the key column(s).
224
+ The requirements of the preceding paragraph apply only to the key
225
+ columns. In particular, the combination
226
+ of <structfield>amcanmulticol</structfield>=<literal>false</literal>
227
+ and <structfield>amcaninclude</structfield>=<literal>true</literal> is
228
+ sensible: it means that there can only be one key column, but there can
229
+ also be included column(s). Also, included columns must be allowed to be
230
+ null, independently of <structfield>amoptionalkey</structfield>.
231
+ </para>
232
+
220
233
</sect1>
221
234
222
235
<sect1 id="index-functions">
@@ -368,10 +381,13 @@ amcanreturn (Relation indexRelation, int attno);
368
381
</programlisting>
369
382
Check whether the index can support <link
370
383
linkend="indexes-index-only-scans"><firstterm>index-only scans</firstterm></link> on
371
- the given column, by returning the indexed column values for an index entry
372
- in the form of an <structname>IndexTuple</structname>. The attribute number
373
- is 1-based, i.e., the first column's attno is 1. Returns true if supported,
374
- else false. If the access method does not support index-only scans at all,
384
+ the given column, by returning the column's original indexed value.
385
+ The attribute number is 1-based, i.e., the first column's attno is 1.
386
+ Returns true if supported, else false.
387
+ This function should always return true for included columns
388
+ (if those are supported), since there's little point in an included
389
+ column that can't be retrieved.
390
+ If the access method does not support index-only scans at all,
375
391
the <structfield>amcanreturn</structfield> field in its <structname>IndexAmRoutine</structname>
376
392
struct can be set to NULL.
377
393
</para>
@@ -461,7 +477,7 @@ amproperty (Oid index_oid, int attno,
461
477
core code does not know how to do that and will return NULL. It may
462
478
also be advantageous to implement <literal>AMPROP_RETURNABLE</literal> testing,
463
479
if that can be done more cheaply than by opening the index and calling
464
- <structfield >amcanreturn</structfield >, which is the core code's default behavior.
480
+ <function >amcanreturn</function >, which is the core code's default behavior.
465
481
The default behavior should be satisfactory for all other standard
466
482
properties.
467
483
</para>
@@ -553,10 +569,13 @@ amgettuple (IndexScanDesc scan,
553
569
554
570
<para>
555
571
If the index supports <link linkend="indexes-index-only-scans">index-only
556
- scans</link> (i.e., <function>amcanreturn</function> returns true for it),
572
+ scans</link> (i.e., <function>amcanreturn</function> returns true for any
573
+ of its columns),
557
574
then on success the AM must also check <literal>scan->xs_want_itup</literal>,
558
575
and if that is true it must return the originally indexed data for the
559
- index entry. The data can be returned in the form of an
576
+ index entry. Columns for which <function>amcanreturn</function> returns
577
+ false can be returned as nulls.
578
+ The data can be returned in the form of an
560
579
<structname>IndexTuple</structname> pointer stored at <literal>scan->xs_itup</literal>,
561
580
with tuple descriptor <literal>scan->xs_itupdesc</literal>; or in the form of
562
581
a <structname>HeapTuple</structname> pointer stored at <literal>scan->xs_hitup</literal>,
0 commit comments