MCPcopy Create free account
hub / github.com/apache/cloudberry / ginint4_queryextract

Function ginint4_queryextract

contrib/intarray/_int_gin.c:12–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10PG_FUNCTION_INFO_V1(ginint4_queryextract);
11
12Datum
13ginint4_queryextract(PG_FUNCTION_ARGS)
14{
15 int32 *nentries = (int32 *) PG_GETARG_POINTER(1);
16 StrategyNumber strategy = PG_GETARG_UINT16(2);
17 int32 *searchMode = (int32 *) PG_GETARG_POINTER(6);
18 Datum *res = NULL;
19
20 *nentries = 0;
21
22 if (strategy == BooleanSearchStrategy)
23 {
24 QUERYTYPE *query = PG_GETARG_QUERYTYPE_P(0);
25 ITEM *items = GETQUERY(query);
26 int i;
27
28 /* empty query must fail */
29 if (query->size <= 0)
30 PG_RETURN_POINTER(NULL);
31
32 /*
33 * If the query doesn't have any required primitive values (for
34 * instance, it's something like '! 42'), we have to do a full index
35 * scan.
36 */
37 if (query_has_required_values(query))
38 *searchMode = GIN_SEARCH_MODE_DEFAULT;
39 else
40 *searchMode = GIN_SEARCH_MODE_ALL;
41
42 /*
43 * Extract all the VAL items as things we want GIN to check for.
44 */
45 res = (Datum *) palloc(sizeof(Datum) * query->size);
46 *nentries = 0;
47
48 for (i = 0; i < query->size; i++)
49 {
50 if (items[i].type == VAL)
51 {
52 res[*nentries] = Int32GetDatum(items[i].val);
53 (*nentries)++;
54 }
55 }
56 }
57 else
58 {
59 ArrayType *query = PG_GETARG_ARRAYTYPE_P(0);
60
61 CHECKARRVALID(query);
62 *nentries = ARRNELEMS(query);
63 if (*nentries > 0)
64 {
65 int32 *arr;
66 int32 i;
67
68 res = (Datum *) palloc(sizeof(Datum) * (*nentries));
69

Callers

nothing calls this directly

Calls 3

Int32GetDatumFunction · 0.85
pallocFunction · 0.50

Tested by

no test coverage detected