aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/ruleutils.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2020-09-17 19:38:05 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2020-09-17 19:38:05 -0400
commit1ed6b895634ce0dc5fd4bd040e87252b32182cba (patch)
treed0f22d227e7df8ca5139baf4eba578de052f6a82 /src/backend/utils/adt/ruleutils.c
parent76f412ab310554acb970a0b73c8d1f37f35548c6 (diff)
downloadpostgresql-1ed6b895634ce0dc5fd4bd040e87252b32182cba.tar.gz
postgresql-1ed6b895634ce0dc5fd4bd040e87252b32182cba.zip
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
Diffstat (limited to 'src/backend/utils/adt/ruleutils.c')
-rw-r--r--src/backend/utils/adt/ruleutils.c39
1 files changed, 7 insertions, 32 deletions
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 60dd80c23c8..15877e37a60 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -9198,35 +9198,14 @@ get_oper_expr(OpExpr *expr, deparse_context *context)
}
else
{
- /* unary operator --- but which side? */
+ /* prefix operator */
Node *arg = (Node *) linitial(args);
- HeapTuple tp;
- Form_pg_operator optup;
-
- tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
- if (!HeapTupleIsValid(tp))
- elog(ERROR, "cache lookup failed for operator %u", opno);
- optup = (Form_pg_operator) GETSTRUCT(tp);
- switch (optup->oprkind)
- {
- case 'l':
- appendStringInfo(buf, "%s ",
- generate_operator_name(opno,
- InvalidOid,
- exprType(arg)));
- get_rule_expr_paren(arg, context, true, (Node *) expr);
- break;
- case 'r':
- get_rule_expr_paren(arg, context, true, (Node *) expr);
- appendStringInfo(buf, " %s",
- generate_operator_name(opno,
- exprType(arg),
- InvalidOid));
- break;
- default:
- elog(ERROR, "bogus oprkind: %d", optup->oprkind);
- }
- ReleaseSysCache(tp);
+
+ appendStringInfo(buf, "%s ",
+ generate_operator_name(opno,
+ InvalidOid,
+ exprType(arg)));
+ get_rule_expr_paren(arg, context, true, (Node *) expr);
}
if (!PRETTY_PAREN(context))
appendStringInfoChar(buf, ')');
@@ -11087,10 +11066,6 @@ generate_operator_name(Oid operid, Oid arg1, Oid arg2)
p_result = left_oper(NULL, list_make1(makeString(oprname)), arg2,
true, -1);
break;
- case 'r':
- p_result = right_oper(NULL, list_make1(makeString(oprname)), arg1,
- true, -1);
- break;
default:
elog(ERROR, "unrecognized oprkind: %d", operform->oprkind);
p_result = NULL; /* keep compiler quiet */