mirror of
https://github.com/postgres/postgres.git
synced 2025-06-17 17:02:08 +03:00
Remove support for postfix (right-unary) operators.
This feature has been a thorn in our sides for a long time, causing many grammatical ambiguity problems. It doesn't seem worth the pain to continue to support it, so remove it. There are some follow-on improvements we can make in the grammar, but this commit only removes the bare minimum number of productions, plus assorted backend support code. Note that pg_dump and psql continue to have full support, since they may be used against older servers. However, pg_dump warns about postfix operators. There is also a check in pg_upgrade. Documentation-wise, I (tgl) largely removed the "left unary" terminology in favor of saying "prefix operator", which is a more standard and IMO less confusing term. I included a catversion bump, although no initial catalog data changes here, to mark the boundary at which oprkind = 'r' stopped being valid in pg_operator. Mark Dilger, based on work by myself and Robert Haas; review by John Naylor Discussion: https://postgr.es/m/38ca86db-42ab-9b48-2902-337a0d6b8311@2ndquadrant.com
This commit is contained in:
@ -57,7 +57,7 @@ bool Transform_null_equals = false;
|
||||
#define PREC_GROUP_NOT_LIKE 9 /* NOT LIKE/ILIKE/SIMILAR */
|
||||
#define PREC_GROUP_NOT_BETWEEN 10 /* NOT BETWEEN */
|
||||
#define PREC_GROUP_NOT_IN 11 /* NOT IN */
|
||||
#define PREC_GROUP_POSTFIX_OP 12 /* generic postfix operators */
|
||||
#define PREC_GROUP_ANY_ALL 12 /* ANY/ALL */
|
||||
#define PREC_GROUP_INFIX_OP 13 /* generic infix operators */
|
||||
#define PREC_GROUP_PREFIX_OP 14 /* generic prefix operators */
|
||||
|
||||
@ -71,7 +71,7 @@ bool Transform_null_equals = false;
|
||||
* 4. LIKE ILIKE SIMILAR
|
||||
* 5. BETWEEN
|
||||
* 6. IN
|
||||
* 7. generic postfix Op
|
||||
* 7. ANY ALL
|
||||
* 8. generic Op, including <= => <>
|
||||
* 9. generic prefix Op
|
||||
* 10. IS tests (NullTest, BooleanTest, etc)
|
||||
@ -1031,7 +1031,7 @@ transformAExprOpAny(ParseState *pstate, A_Expr *a)
|
||||
Node *rexpr = a->rexpr;
|
||||
|
||||
if (operator_precedence_warning)
|
||||
emit_precedence_warnings(pstate, PREC_GROUP_POSTFIX_OP,
|
||||
emit_precedence_warnings(pstate, PREC_GROUP_ANY_ALL,
|
||||
strVal(llast(a->name)),
|
||||
lexpr, NULL,
|
||||
a->location);
|
||||
@ -1054,7 +1054,7 @@ transformAExprOpAll(ParseState *pstate, A_Expr *a)
|
||||
Node *rexpr = a->rexpr;
|
||||
|
||||
if (operator_precedence_warning)
|
||||
emit_precedence_warnings(pstate, PREC_GROUP_POSTFIX_OP,
|
||||
emit_precedence_warnings(pstate, PREC_GROUP_ANY_ALL,
|
||||
strVal(llast(a->name)),
|
||||
lexpr, NULL,
|
||||
a->location);
|
||||
@ -2019,7 +2019,7 @@ transformSubLink(ParseState *pstate, SubLink *sublink)
|
||||
sublink->testexpr, NULL,
|
||||
sublink->location);
|
||||
else
|
||||
emit_precedence_warnings(pstate, PREC_GROUP_POSTFIX_OP,
|
||||
emit_precedence_warnings(pstate, PREC_GROUP_ANY_ALL,
|
||||
strVal(llast(sublink->operName)),
|
||||
sublink->testexpr, NULL,
|
||||
sublink->location);
|
||||
@ -3244,28 +3244,11 @@ operator_precedence_group(Node *node, const char **nodename)
|
||||
group = PREC_GROUP_PREFIX_OP;
|
||||
}
|
||||
}
|
||||
else if (aexpr->kind == AEXPR_OP &&
|
||||
aexpr->lexpr != NULL &&
|
||||
aexpr->rexpr == NULL)
|
||||
{
|
||||
/* postfix operator */
|
||||
if (list_length(aexpr->name) == 1)
|
||||
{
|
||||
*nodename = strVal(linitial(aexpr->name));
|
||||
group = PREC_GROUP_POSTFIX_OP;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* schema-qualified operator syntax */
|
||||
*nodename = "OPERATOR()";
|
||||
group = PREC_GROUP_POSTFIX_OP;
|
||||
}
|
||||
}
|
||||
else if (aexpr->kind == AEXPR_OP_ANY ||
|
||||
aexpr->kind == AEXPR_OP_ALL)
|
||||
{
|
||||
*nodename = strVal(llast(aexpr->name));
|
||||
group = PREC_GROUP_POSTFIX_OP;
|
||||
group = PREC_GROUP_ANY_ALL;
|
||||
}
|
||||
else if (aexpr->kind == AEXPR_DISTINCT ||
|
||||
aexpr->kind == AEXPR_NOT_DISTINCT)
|
||||
@ -3356,7 +3339,7 @@ operator_precedence_group(Node *node, const char **nodename)
|
||||
else
|
||||
{
|
||||
*nodename = strVal(llast(s->operName));
|
||||
group = PREC_GROUP_POSTFIX_OP;
|
||||
group = PREC_GROUP_ANY_ALL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3432,9 +3415,8 @@ emit_precedence_warnings(ParseState *pstate,
|
||||
* Complain if left child, which should be same or higher precedence
|
||||
* according to current rules, used to be lower precedence.
|
||||
*
|
||||
* Exception to precedence rules: if left child is IN or NOT IN or a
|
||||
* postfix operator, the grouping is syntactically forced regardless of
|
||||
* precedence.
|
||||
* Exception to precedence rules: if left child is IN or NOT IN the
|
||||
* grouping is syntactically forced regardless of precedence.
|
||||
*/
|
||||
cgroup = operator_precedence_group(lchild, &copname);
|
||||
if (cgroup > 0)
|
||||
@ -3442,7 +3424,7 @@ emit_precedence_warnings(ParseState *pstate,
|
||||
if (oldprecedence_l[cgroup] < oldprecedence_r[opgroup] &&
|
||||
cgroup != PREC_GROUP_IN &&
|
||||
cgroup != PREC_GROUP_NOT_IN &&
|
||||
cgroup != PREC_GROUP_POSTFIX_OP &&
|
||||
cgroup != PREC_GROUP_ANY_ALL &&
|
||||
cgroup != PREC_GROUP_POSTFIX_IS)
|
||||
ereport(WARNING,
|
||||
(errmsg("operator precedence change: %s is now lower precedence than %s",
|
||||
|
Reference in New Issue
Block a user