int nkeys; /* length of array */
Datum reconstructedValue; /* value reconstructed at parent */
+ void *traversalValue; /* opclass-specific traverse value */
+ MemoryContext traversalMemoryContext;
int level; /* current level (counting from zero) */
bool returnData; /* original data must be returned? */
int *nodeNumbers; /* their indexes in the node array */
int *levelAdds; /* increment level by this much for each */
Datum *reconstructedValues; /* associated reconstructed values */
+ void **traversalValues; /* opclass-specific traverse values */
+
} spgInnerConsistentOut;
</programlisting>
inner tuple, and
<structfield>nodeLabels</> is an array of their label values, or
NULL if the nodes do not have labels.
+ <structfield>traversalValue</> is a pointer to data that
+ <function>inner_consistent</> gets when called on child nodes from an
+ outer call of <function>inner_consistent</> on parent nodes.
</para>
<para>
responsible for palloc'ing the
<structfield>nodeNumbers</>, <structfield>levelAdds</> and
<structfield>reconstructedValues</> arrays.
+ Sometimes accumulating some information is needed, while
+ descending from parent to child node was happened. In this case
+ <structfield>traversalValues</> array keeps pointers to
+ specific data you need to accumulate for every child node.
+ Memory for <structfield>traversalValues</> should be allocated in
+ the default context, but each element of it should be allocated in
+ <structfield>traversalMemoryContext</>.
</para>
</listitem>
</varlistentry>
ScanKey scankeys; /* array of operators and comparison values */
int nkeys; /* length of array */
+ void *traversalValue; /* opclass-specific traverse value */
Datum reconstructedValue; /* value reconstructed at parent */
int level; /* current level (counting from zero) */
bool returnData; /* original data must be returned? */
typedef struct ScanStackEntry
{
Datum reconstructedValue; /* value reconstructed from parent */
+ void *traversalValue; /* opclass-specific traverse value */
int level; /* level of items on this page */
ItemPointerData ptr; /* block and offset to scan from */
} ScanStackEntry;
if (!so->state.attType.attbyval &&
DatumGetPointer(stackEntry->reconstructedValue) != NULL)
pfree(DatumGetPointer(stackEntry->reconstructedValue));
+ if (stackEntry->traversalValue)
+ pfree(stackEntry->traversalValue);
+
pfree(stackEntry);
}
spgLeafTest(Relation index, SpGistScanOpaque so,
SpGistLeafTuple leafTuple, bool isnull,
int level, Datum reconstructedValue,
+ void *traversalValue,
Datum *leafValue, bool *recheck)
{
bool result;
in.scankeys = so->keyData;
in.nkeys = so->numberOfKeys;
in.reconstructedValue = reconstructedValue;
+ in.traversalValue = traversalValue;
in.level = level;
in.returnData = so->want_itup;
in.leafDatum = leafDatum;
leafTuple, isnull,
stackEntry->level,
stackEntry->reconstructedValue,
+ stackEntry->traversalValue,
&leafValue,
&recheck))
{
leafTuple, isnull,
stackEntry->level,
stackEntry->reconstructedValue,
+ stackEntry->traversalValue,
&leafValue,
&recheck))
{
in.scankeys = so->keyData;
in.nkeys = so->numberOfKeys;
in.reconstructedValue = stackEntry->reconstructedValue;
+ in.traversalMemoryContext = oldCtx;
+ in.traversalValue = stackEntry->traversalValue;
in.level = stackEntry->level;
in.returnData = so->want_itup;
in.allTheSame = innerTuple->allTheSame;
else
newEntry->reconstructedValue = (Datum) 0;
+ /*
+ * Elements of out.traversalValues should be allocated in
+ * in.traversalMemoryContext, which is actually a long
+ * lived context of index scan.
+ */
+ newEntry->traversalValue = (out.traversalValues) ?
+ out.traversalValues[i] : NULL;
+
so->scanStack = lcons(newEntry, so->scanStack);
}
}
int nkeys; /* length of array */
Datum reconstructedValue; /* value reconstructed at parent */
+ void *traversalValue; /* opclass-specific traverse value */
+ MemoryContext traversalMemoryContext;
int level; /* current level (counting from zero) */
bool returnData; /* original data must be returned? */
int *nodeNumbers; /* their indexes in the node array */
int *levelAdds; /* increment level by this much for each */
Datum *reconstructedValues; /* associated reconstructed values */
+ void **traversalValues; /* opclass-specific traverse values */
} spgInnerConsistentOut;
/*
ScanKey scankeys; /* array of operators and comparison values */
int nkeys; /* length of array */
+ void *traversalValue; /* opclass-specific traverse value */
Datum reconstructedValue; /* value reconstructed at parent */
int level; /* current level (counting from zero) */
bool returnData; /* original data must be returned? */