@@ -190,7 +190,7 @@ typedef struct IndexAmRoutine
190
190
implications. The requirements of <structfield>amcanunique</structfield>
191
191
are discussed in <xref linkend="index-unique-checks"/>.
192
192
The <structfield>amcanmulticol</structfield> flag asserts that the
193
- access method supports multicolumn indexes, while
193
+ access method supports multi-key-column indexes, while
194
194
<structfield>amoptionalkey</structfield> asserts that it allows scans
195
195
where no indexable restriction clause is given for the first index column.
196
196
When <structfield>amcanmulticol</structfield> is false,
@@ -226,6 +226,19 @@ typedef struct IndexAmRoutine
226
226
conditions.
227
227
</para>
228
228
229
+ <para>
230
+ The <structfield>amcaninclude</structfield> flag indicates whether the
231
+ access method supports <quote>included</quote> columns, that is it can
232
+ store (without processing) additional columns beyond the key column(s).
233
+ The requirements of the preceding paragraph apply only to the key
234
+ columns. In particular, the combination
235
+ of <structfield>amcanmulticol</structfield>=<literal>false</literal>
236
+ and <structfield>amcaninclude</structfield>=<literal>true</literal> is
237
+ sensible: it means that there can only be one key column, but there can
238
+ also be included column(s). Also, included columns must be allowed to be
239
+ null, independently of <structfield>amoptionalkey</structfield>.
240
+ </para>
241
+
229
242
</sect1>
230
243
231
244
<sect1 id="index-functions">
@@ -377,10 +390,13 @@ amcanreturn (Relation indexRelation, int attno);
377
390
</programlisting>
378
391
Check whether the index can support <link
379
392
linkend="indexes-index-only-scans"><firstterm>index-only scans</firstterm></link> on
380
- the given column, by returning the indexed column values for an index entry
381
- in the form of an <structname>IndexTuple</structname>. The attribute number
382
- is 1-based, i.e., the first column's attno is 1. Returns true if supported,
383
- else false. If the access method does not support index-only scans at all,
393
+ the given column, by returning the column's original indexed value.
394
+ The attribute number is 1-based, i.e., the first column's attno is 1.
395
+ Returns true if supported, else false.
396
+ This function should always return true for included columns
397
+ (if those are supported), since there's little point in an included
398
+ column that can't be retrieved.
399
+ If the access method does not support index-only scans at all,
384
400
the <structfield>amcanreturn</structfield> field in its <structname>IndexAmRoutine</structname>
385
401
struct can be set to NULL.
386
402
</para>
@@ -470,7 +486,7 @@ amproperty (Oid index_oid, int attno,
470
486
core code does not know how to do that and will return NULL. It may
471
487
also be advantageous to implement <literal>AMPROP_RETURNABLE</literal> testing,
472
488
if that can be done more cheaply than by opening the index and calling
473
- <structfield >amcanreturn</structfield >, which is the core code's default behavior.
489
+ <function >amcanreturn</function >, which is the core code's default behavior.
474
490
The default behavior should be satisfactory for all other standard
475
491
properties.
476
492
</para>
@@ -574,10 +590,13 @@ amgettuple (IndexScanDesc scan,
574
590
575
591
<para>
576
592
If the index supports <link linkend="indexes-index-only-scans">index-only
577
- scans</link> (i.e., <function>amcanreturn</function> returns true for it),
593
+ scans</link> (i.e., <function>amcanreturn</function> returns true for any
594
+ of its columns),
578
595
then on success the AM must also check <literal>scan->xs_want_itup</literal>,
579
596
and if that is true it must return the originally indexed data for the
580
- index entry. The data can be returned in the form of an
597
+ index entry. Columns for which <function>amcanreturn</function> returns
598
+ false can be returned as nulls.
599
+ The data can be returned in the form of an
581
600
<structname>IndexTuple</structname> pointer stored at <literal>scan->xs_itup</literal>,
582
601
with tuple descriptor <literal>scan->xs_itupdesc</literal>; or in the form of
583
602
a <structname>HeapTuple</structname> pointer stored at <literal>scan->xs_hitup</literal>,
0 commit comments