Example #1
0
/*
 * Extract the label datums of the nodes within innerTuple
 *
 * Returns NULL if label datums are NULLs
 */
Datum *
spgExtractNodeLabels(SpGistState *state, SpGistInnerTuple innerTuple)
{
	Datum	   *nodeLabels;
	int			nullcount = 0;
	int			i;
	SpGistNodeTuple node;

	nodeLabels = (Datum *) palloc(sizeof(Datum) * innerTuple->nNodes);
	SGITITERATE(innerTuple, i, node)
	{
		if (IndexTupleHasNulls(node))
			nullcount++;
		else
			nodeLabels[i] = SGNTDATUM(node, state);
	}
	if (nullcount == innerTuple->nNodes)
	{
		/* They're all null, so just return NULL */
		pfree(nodeLabels);
		return NULL;
	}
	if (nullcount != 0)
		elog(ERROR, "some but not all node labels are null in SPGiST inner tuple");
	return nodeLabels;
}
Example #2
0
		SGITITERATE(innerTuple, i, node)
		{
			if (IndexTupleHasNulls(node))
				elog(ERROR, "some but not all node labels are null in SPGiST inner tuple");
			nodeLabels[i] = SGNTDATUM(node, state);
		}