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

Function DecodeTextArrayToBitmapset

src/backend/utils/cache/evtcache.c:220–245  ·  view source on GitHub ↗

* Decode text[] to a Bitmapset of CommandTags. * * We could avoid a bit of overhead here if we were willing to duplicate some * of the logic from deconstruct_array, but it doesn't seem worth the code * complexity. */

Source from the content-addressed store, hash-verified

218 * complexity.
219 */
220static Bitmapset *
221DecodeTextArrayToBitmapset(Datum array)
222{
223 ArrayType *arr = DatumGetArrayTypeP(array);
224 Datum *elems;
225 Bitmapset *bms;
226 int i;
227 int nelems;
228
229 if (ARR_NDIM(arr) != 1 || ARR_HASNULL(arr) || ARR_ELEMTYPE(arr) != TEXTOID)
230 elog(ERROR, "expected 1-D text array");
231 deconstruct_array(arr, TEXTOID, -1, false, TYPALIGN_INT,
232 &elems, NULL, &nelems);
233
234 for (bms = NULL, i = 0; i < nelems; ++i)
235 {
236 char *str = TextDatumGetCString(elems[i]);
237
238 bms = bms_add_member(bms, GetCommandTagEnum(str));
239 pfree(str);
240 }
241
242 pfree(elems);
243
244 return bms;
245}
246
247/*
248 * Flush all cache entries when pg_event_trigger is updated.

Callers 1

BuildEventTriggerCacheFunction · 0.85

Calls 4

deconstruct_arrayFunction · 0.85
bms_add_memberFunction · 0.85
GetCommandTagEnumFunction · 0.85
pfreeFunction · 0.50

Tested by

no test coverage detected