@@ -196,7 +196,7 @@ typedef struct IndexAmRoutine
196
196
implications. The requirements of <structfield>amcanunique</structfield>
197
197
are discussed in <xref linkend="index-unique-checks"/>.
198
198
The <structfield>amcanmulticol</structfield> flag asserts that the
199
- access method supports multicolumn indexes, while
199
+ access method supports multi-key-column indexes, while
200
200
<structfield>amoptionalkey</structfield> asserts that it allows scans
201
201
where no indexable restriction clause is given for the first index column.
202
202
When <structfield>amcanmulticol</structfield> is false,
@@ -232,6 +232,19 @@ typedef struct IndexAmRoutine
232
232
conditions.
233
233
</para>
234
234
235
+ <para>
236
+ The <structfield>amcaninclude</structfield> flag indicates whether the
237
+ access method supports <quote>included</quote> columns, that is it can
238
+ store (without processing) additional columns beyond the key column(s).
239
+ The requirements of the preceding paragraph apply only to the key
240
+ columns. In particular, the combination
241
+ of <structfield>amcanmulticol</structfield>=<literal>false</literal>
242
+ and <structfield>amcaninclude</structfield>=<literal>true</literal> is
243
+ sensible: it means that there can only be one key column, but there can
244
+ also be included column(s). Also, included columns must be allowed to be
245
+ null, independently of <structfield>amoptionalkey</structfield>.
246
+ </para>
247
+
235
248
</sect1>
236
249
237
250
<sect1 id="index-functions">
@@ -383,10 +396,13 @@ amcanreturn (Relation indexRelation, int attno);
383
396
</programlisting>
384
397
Check whether the index can support <link
385
398
linkend="indexes-index-only-scans"><firstterm>index-only scans</firstterm></link> on
386
- the given column, by returning the indexed column values for an index entry
387
- in the form of an <structname>IndexTuple</structname>. The attribute number
388
- is 1-based, i.e., the first column's attno is 1. Returns true if supported,
389
- else false. If the access method does not support index-only scans at all,
399
+ the given column, by returning the column's original indexed value.
400
+ The attribute number is 1-based, i.e., the first column's attno is 1.
401
+ Returns true if supported, else false.
402
+ This function should always return true for included columns
403
+ (if those are supported), since there's little point in an included
404
+ column that can't be retrieved.
405
+ If the access method does not support index-only scans at all,
390
406
the <structfield>amcanreturn</structfield> field in its <structname>IndexAmRoutine</structname>
391
407
struct can be set to NULL.
392
408
</para>
@@ -476,7 +492,7 @@ amproperty (Oid index_oid, int attno,
476
492
core code does not know how to do that and will return NULL. It may
477
493
also be advantageous to implement <literal>AMPROP_RETURNABLE</literal> testing,
478
494
if that can be done more cheaply than by opening the index and calling
479
- <structfield >amcanreturn</structfield >, which is the core code's default behavior.
495
+ <function >amcanreturn</function >, which is the core code's default behavior.
480
496
The default behavior should be satisfactory for all other standard
481
497
properties.
482
498
</para>
@@ -580,10 +596,13 @@ amgettuple (IndexScanDesc scan,
580
596
581
597
<para>
582
598
If the index supports <link linkend="indexes-index-only-scans">index-only
583
- scans</link> (i.e., <function>amcanreturn</function> returns true for it),
599
+ scans</link> (i.e., <function>amcanreturn</function> returns true for any
600
+ of its columns),
584
601
then on success the AM must also check <literal>scan->xs_want_itup</literal>,
585
602
and if that is true it must return the originally indexed data for the
586
- index entry. The data can be returned in the form of an
603
+ index entry. Columns for which <function>amcanreturn</function> returns
604
+ false can be returned as nulls.
605
+ The data can be returned in the form of an
587
606
<structname>IndexTuple</structname> pointer stored at <literal>scan->xs_itup</literal>,
588
607
with tuple descriptor <literal>scan->xs_itupdesc</literal>; or in the form of
589
608
a <structname>HeapTuple</structname> pointer stored at <literal>scan->xs_hitup</literal>,
0 commit comments