* 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. */
| 218 | * complexity. |
| 219 | */ |
| 220 | static Bitmapset * |
| 221 | DecodeTextArrayToBitmapset(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. |
no test coverage detected