struct, which the function must fill with result data.
<programlisting>
typedef struct spgConfigIn
{
Oid attType; /* Data type to be indexed */
} spgConfigIn;
typedef struct spgConfigOut
{
Oid prefixType; /* Data type of inner-tuple prefixes */
Oid labelType; /* Data type of inner-tuple node labels */
Oid leafType; /* Data type of leaf-tuple values */
bool canReturnData; /* Opclass can reconstruct original data */
bool longValuesOK; /* Opclass can cope with values > 1 page */
} spgConfigOut;
</programlisting>
<structfield>attType</structfield> is passed in order to support polymorphic
index operator classes; for ordinary fixed-data-type operator classes, it
will always have the same value and so can be ignored.
</para>
<para>
For operator classes that do not use prefixes,
<structfield>prefixType</structfield> can be set to <literal>VOIDOID</literal>.
Likewise, for operator classes that do not use node labels,
<structfield>labelType</structfield> can be set to <literal>VOIDOID</literal>.
<structfield>canReturnData</structfield> should be set true if the operator class
is capable of reconstructing the originally-supplied index value.
<structfield>longValuesOK</structfield> should be set true only when the
<structfield>attType</structfield> is of variable length and the operator
class is capable of segmenting long values by repeated suffixing
(see <xref linkend="spgist-limits"/>).
</para>
<para>
<structfield>leafType</structfield> should match the index storage type
defined by the operator class's <structfield>opckeytype</structfield>
catalog entry.
(Note that <structfield>opckeytype</structfield> can be zero,
implying the storage type is the same as the operator class's input
type, which is the most common situation.)
For reasons of backward compatibility, the <function>config</function>
method can set <structfield>leafType</structfield> to some other value,
and that value will be used; but this is deprecated since the index
contents are then incorrectly identified in the catalogs.
Also, it's permissible to
leave <structfield>leafType</structfield> uninitialized (zero);
that is interpreted as meaning the index storage type derived from
<structfield>opckeytype</structfield>.
</para>
<para>
When <structfield>attType</structfield>
and <structfield>leafType</structfield> are different, the optional
method <function>compress</function> must be provided.
Method <function>compress</function> is responsible
for transformation of datums to be indexed from <structfield>attType</structfield>
to <structfield>leafType</structfield>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><function>choose</function></term>
<listitem>
<para>
Chooses a method for inserting a new value into an inner tuple.
</para>
<para>
The <acronym>SQL</acronym> declaration of the function must look like this:
<programlisting>
CREATE FUNCTION my_choose(internal, internal) RETURNS void ...
</programlisting>
The first argument is a pointer to a <structname>spgChooseIn</structname>
C struct, containing input data for the function.
The second argument is a pointer to a <structname>spgChooseOut</structname>
C struct, which the function must fill with result data.
<programlisting>
typedef struct spgChooseIn
{
Datum datum; /* original datum to be indexed */
Datum leafDatum; /* current datum to be stored at leaf */
int level; /* current level (counting from zero) */
/* Data from current inner tuple */
bool allTheSame; /* tuple is marked all-the-same? */
bool hasPrefix;