* GPDB: For a few built-in equality operators, we have a specialized fast-path * version to evaluate a ScalarArrayOpExpr. In the fast path, the array * argument must be a constant. It is decomposed into a C array here for faster * evaluation at runtime. */
| 3363 | * evaluation at runtime. |
| 3364 | */ |
| 3365 | static bool |
| 3366 | ExecInitScalarArrayOpFastPath(ExprEvalStep *scratch, |
| 3367 | ScalarArrayOpExpr *opexpr, |
| 3368 | ExprState *state, Datum *resv, bool *resnull) |
| 3369 | { |
| 3370 | Oid opfuncid = opexpr->opfuncid; |
| 3371 | Oid collid = opexpr->inputcollid; |
| 3372 | Expr *scalararg; |
| 3373 | Expr *arrayarg; |
| 3374 | Const *arrayconst; |
| 3375 | ArrayType *arr; |
| 3376 | int16 typlen; |
| 3377 | bool typbyval; |
| 3378 | char typalign; |
| 3379 | char *s; |
| 3380 | bits8 *bitmap; |
| 3381 | int bitmask; |
| 3382 | int nelems; |
| 3383 | int *fp_len; |
| 3384 | Datum *fp_datum; |
| 3385 | |
| 3386 | Assert(list_length(opexpr->args) == 2); |
| 3387 | scalararg = (Expr *) linitial(opexpr->args); |
| 3388 | arrayarg = (Expr *) lsecond(opexpr->args); |
| 3389 | |
| 3390 | /* IN will be evaluated as OR */ |
| 3391 | if (!opexpr->useOr) |
| 3392 | return false; |
| 3393 | |
| 3394 | /* only if the array arg is const */ |
| 3395 | if (!IsA(arrayarg, Const)) |
| 3396 | return false; |
| 3397 | arrayconst = (Const *) arrayarg; |
| 3398 | |
| 3399 | /* We do not handle null */ |
| 3400 | if (arrayconst->constisnull) |
| 3401 | return false; |
| 3402 | |
| 3403 | arr = DatumGetArrayTypeP(arrayconst->constvalue); |
| 3404 | nelems = ArrayGetNItems(ARR_NDIM(arr), ARR_DIMS(arr)); |
| 3405 | |
| 3406 | /* We do not handle this case */ |
| 3407 | if (nelems <= 0) |
| 3408 | return false; |
| 3409 | |
| 3410 | if (opfuncid == F_INT2EQ || opfuncid == F_INT4EQ || opexpr->opfuncid == F_INT8EQ || |
| 3411 | opfuncid == F_DATE_EQ) |
| 3412 | { |
| 3413 | /* ok */ |
| 3414 | } |
| 3415 | else if (opfuncid == F_TEXTEQ || opfuncid == F_BPCHAREQ) |
| 3416 | { |
| 3417 | /* |
| 3418 | * Since we're not calling texteq(), sanity check here that collation was |
| 3419 | * reosolved. This is the same as check_collation_set(collid). |
| 3420 | */ |
| 3421 | if (!OidIsValid(collid)) |
| 3422 | { |
no test coverage detected