diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2015-02-23 12:46:46 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2015-02-23 12:46:50 -0500 |
commit | 56be925e4b8f5b1c0e6716ca5cbe0360d1229f50 (patch) | |
tree | 1b00fd91c5044e62ee515a2e90862a8855d727a2 /src/backend/parser/parse_expr.c | |
parent | 296f3a6053844089bc533630fffafaba8f016384 (diff) | |
download | postgresql-56be925e4b8f5b1c0e6716ca5cbe0360d1229f50.tar.gz postgresql-56be925e4b8f5b1c0e6716ca5cbe0360d1229f50.zip |
Further tweaking of raw grammar output to distinguish different inputs.
Use a different A_Expr_Kind for LIKE/ILIKE/SIMILAR TO constructs, so that
they can be distinguished from direct invocation of the underlying
operators. Also, postpone selection of the operator name when transforming
"x IN (select)" to "x = ANY (select)", so that those syntaxes can be told
apart at parse analysis time.
I had originally thought I'd also have to do something special for the
syntaxes IS NOT DISTINCT FROM, IS NOT DOCUMENT, and x NOT IN (SELECT...),
which the grammar translates as though they were NOT (construct).
On reflection though, we can distinguish those cases reliably by noting
whether the parse location shown for the NOT is the same as for its child
node. This only requires tweaking the parse locations for NOT IN, which
I've done here.
These changes should have no effect outside the parser; they're just in
support of being able to give accurate warnings for planned operator
precedence changes.
Diffstat (limited to 'src/backend/parser/parse_expr.c')
-rw-r--r-- | src/backend/parser/parse_expr.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c index f314745818b..7829bcbac16 100644 --- a/src/backend/parser/parse_expr.c +++ b/src/backend/parser/parse_expr.c @@ -182,6 +182,12 @@ transformExprRecurse(ParseState *pstate, Node *expr) case AEXPR_IN: result = transformAExprIn(pstate, a); break; + case AEXPR_LIKE: + case AEXPR_ILIKE: + case AEXPR_SIMILAR: + /* we can transform these just like AEXPR_OP */ + result = transformAExprOp(pstate, a); + break; case AEXPR_BETWEEN: case AEXPR_NOT_BETWEEN: case AEXPR_BETWEEN_SYM: @@ -1649,6 +1655,12 @@ transformSubLink(ParseState *pstate, SubLink *sublink) ListCell *l; /* + * If the source was "x IN (select)", convert to "x = ANY (select)". + */ + if (sublink->operName == NIL) + sublink->operName = list_make1(makeString("=")); + + /* * Transform lefthand expression, and convert to a list */ lefthand = transformExprRecurse(pstate, sublink->testexpr); |