/* *extractValuesupportfunction
*/
Datum
ginarrayextract(PG_FUNCTION_ARGS)
{ /* Make copy of array input to ensure it doesn't disappear while in use */
ArrayType *array = PG_GETARG_ARRAYTYPE_P_COPY(0);
int32 *nkeys = (int32 *) PG_GETARG_POINTER(1); bool **nullFlags = (bool **) PG_GETARG_POINTER(2);
int16 elmlen; bool elmbyval; char elmalign;
Datum *elems; bool *nulls; int nelems;
/* we should not free array, elems[i] points into it */
PG_RETURN_POINTER(elems);
}
/* *Formerly,ginarrayextracthadonlytwoarguments.Nowithasthree, *butwestillneedapg_procentrywithtwoargstosupportreloading *pre-9.1contrib/intarrayopclassdeclarations.Thiscompatibility *functionshouldgoawayeventually.
*/
Datum
ginarrayextract_2args(PG_FUNCTION_ARGS)
{ if (PG_NARGS() < 3) /* should not happen */
elog(ERROR, "ginarrayextract requires three arguments"); return ginarrayextract(fcinfo);
}
/* *extractQuerysupportfunction
*/
Datum
ginqueryarrayextract(PG_FUNCTION_ARGS)
{ /* Make copy of array input to ensure it doesn't disappear while in use */
ArrayType *array = PG_GETARG_ARRAYTYPE_P_COPY(0);
int32 *nkeys = (int32 *) PG_GETARG_POINTER(1);
StrategyNumber strategy = PG_GETARG_UINT16(2);
switch (strategy)
{ case GinOverlapStrategy: /* result is not lossy */
*recheck = false; /* must have a match for at least one non-null element */
res = false; for (i = 0; i < nkeys; i++)
{ if (check[i] && !nullFlags[i])
{
res = true; break;
}
} break; case GinContainsStrategy: /* result is not lossy */
*recheck = false; /* must have all elements in check[] true, and no nulls */
res = true; for (i = 0; i < nkeys; i++)
{ if (!check[i] || nullFlags[i])
{
res = false; break;
}
} break; case GinContainedStrategy: /* we will need recheck */
*recheck = true; /* can't do anything else useful here */
res = true; break; case GinEqualStrategy: /* we will need recheck */
*recheck = true;
/* *Musthaveallelementsincheck[]true;nodiscrimination *againstnullshere.Thisisbecausearray_contain_compareand *array_eqhandlenullsdifferently...
*/
res = true; for (i = 0; i < nkeys; i++)
{ if (!check[i])
{
res = false; break;
}
} break; default:
elog(ERROR, "ginarrayconsistent: unknown strategy number: %d",
strategy);
res = false;
}
switch (strategy)
{ case GinOverlapStrategy: /* must have a match for at least one non-null element */
res = GIN_FALSE; for (i = 0; i < nkeys; i++)
{ if (!nullFlags[i])
{ if (check[i] == GIN_TRUE)
{
res = GIN_TRUE; break;
} elseif (check[i] == GIN_MAYBE && res == GIN_FALSE)
{
res = GIN_MAYBE;
}
}
} break; case GinContainsStrategy: /* must have all elements in check[] true, and no nulls */
res = GIN_TRUE; for (i = 0; i < nkeys; i++)
{ if (check[i] == GIN_FALSE || nullFlags[i])
{
res = GIN_FALSE; break;
} if (check[i] == GIN_MAYBE)
{
res = GIN_MAYBE;
}
} break; case GinContainedStrategy: /* can't do anything else useful here */
res = GIN_MAYBE; break; case GinEqualStrategy:
/* *Musthaveallelementsincheck[]true;nodiscrimination *againstnullshere.Thisisbecausearray_contain_compareand *array_eqhandlenullsdifferently...
*/
res = GIN_MAYBE; for (i = 0; i < nkeys; i++)
{ if (check[i] == GIN_FALSE)
{
res = GIN_FALSE; break;
}
} break; default:
elog(ERROR, "ginarrayconsistent: unknown strategy number: %d",
strategy);
res = false;
}
PG_RETURN_GIN_TERNARY_VALUE(res);
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.32 Sekunden
(vorverarbeitet am 2026-08-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.