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

Function transformAExprOp

src/backend/parser/parse_expr.c:895–974  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

893}
894
895static Node *
896transformAExprOp(ParseState *pstate, A_Expr *a)
897{
898 Node *lexpr = a->lexpr;
899 Node *rexpr = a->rexpr;
900 Node *result;
901
902 /*
903 * Special-case "foo = NULL" and "NULL = foo" for compatibility with
904 * standards-broken products (like Microsoft's). Turn these into IS NULL
905 * exprs. (If either side is a CaseTestExpr, then the expression was
906 * generated internally from a CASE-WHEN expression, and
907 * transform_null_equals does not apply.)
908 */
909 if (Transform_null_equals &&
910 list_length(a->name) == 1 &&
911 strcmp(strVal(linitial(a->name)), "=") == 0 &&
912 (exprIsNullConstant(lexpr) || exprIsNullConstant(rexpr)) &&
913 (!IsA(lexpr, CaseTestExpr) && !IsA(rexpr, CaseTestExpr)))
914 {
915 NullTest *n = makeNode(NullTest);
916
917 n->nulltesttype = IS_NULL;
918 n->location = a->location;
919
920 if (exprIsNullConstant(lexpr))
921 n->arg = (Expr *) rexpr;
922 else
923 n->arg = (Expr *) lexpr;
924
925 result = transformExprRecurse(pstate, (Node *) n);
926 }
927 else if (lexpr && IsA(lexpr, RowExpr) &&
928 rexpr && IsA(rexpr, SubLink) &&
929 ((SubLink *) rexpr)->subLinkType == EXPR_SUBLINK)
930 {
931 /*
932 * Convert "row op subselect" into a ROWCOMPARE sublink. Formerly the
933 * grammar did this, but now that a row construct is allowed anywhere
934 * in expressions, it's easier to do it here.
935 */
936 SubLink *s = (SubLink *) rexpr;
937
938 s->subLinkType = ROWCOMPARE_SUBLINK;
939 s->testexpr = lexpr;
940 s->operName = a->name;
941 s->location = a->location;
942 result = transformExprRecurse(pstate, (Node *) s);
943 }
944 else if (lexpr && IsA(lexpr, RowExpr) &&
945 rexpr && IsA(rexpr, RowExpr))
946 {
947 /* ROW() op ROW() is handled specially */
948 lexpr = transformExprRecurse(pstate, lexpr);
949 rexpr = transformExprRecurse(pstate, rexpr);
950
951 result = make_row_comparison_op(pstate,
952 a->name,

Callers 1

transformExprRecurseFunction · 0.85

Calls 5

list_lengthFunction · 0.85
exprIsNullConstantFunction · 0.85
transformExprRecurseFunction · 0.85
make_row_comparison_opFunction · 0.85
make_opFunction · 0.85

Tested by

no test coverage detected