Commit a676386b authored by Tom Lane's avatar Tom Lane

Remove operator_precedence_warning.

This GUC was always intended as a temporary solution to help with
finding 9.4-to-9.5 migration issues.  Now that all pre-9.5 branches
are out of support, and 9.5 will be too before v14 is released,
it seems like it's okay to drop it.  Doing so allows removal of
several hundred lines of poorly-tested code in parse_expr.c,
which have been a fertile source of bugs when people did use this.

Discussion: https://postgr.es/m/2234320.1607117945@sss.pgh.pa.us
parent 4f5760d4
...@@ -9389,29 +9389,6 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir' ...@@ -9389,29 +9389,6 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry id="guc-operator-precedence-warning" xreflabel="operator_precedence_warning">
<term><varname>operator_precedence_warning</varname> (<type>boolean</type>)
<indexterm>
<primary><varname>operator_precedence_warning</varname> configuration parameter</primary>
</indexterm>
</term>
<listitem>
<para>
When on, the parser will emit a warning for any construct that might
have changed meanings since <productname>PostgreSQL</productname> 9.4 as a result
of changes in operator precedence. This is useful for auditing
applications to see if precedence changes have broken anything; but it
is not meant to be kept turned on in production, since it will warn
about some perfectly valid, standard-compliant SQL code.
The default is <literal>off</literal>.
</para>
<para>
See <xref linkend="sql-precedence"/> for more information.
</para>
</listitem>
</varlistentry>
<varlistentry id="guc-quote-all-identifiers" xreflabel="quote-all-identifiers"> <varlistentry id="guc-quote-all-identifiers" xreflabel="quote-all-identifiers">
<term><varname>quote_all_identifiers</varname> (<type>boolean</type>) <term><varname>quote_all_identifiers</varname> (<type>boolean</type>)
<indexterm> <indexterm>
......
...@@ -1121,11 +1121,7 @@ SELECT 3 OPERATOR(pg_catalog.+) 4; ...@@ -1121,11 +1121,7 @@ SELECT 3 OPERATOR(pg_catalog.+) 4;
cases, these changes will result in no behavioral change, or perhaps cases, these changes will result in no behavioral change, or perhaps
in <quote>no such operator</quote> failures which can be resolved by adding in <quote>no such operator</quote> failures which can be resolved by adding
parentheses. However there are corner cases in which a query might parentheses. However there are corner cases in which a query might
change behavior without any parsing error being reported. If you are change behavior without any parsing error being reported.
concerned about whether these changes have silently broken something,
you can test your application with the configuration
parameter <xref linkend="guc-operator-precedence-warning"/> turned on
to see if any warnings are logged.
</para> </para>
</note> </note>
</sect2> </sect2>
......
...@@ -3264,9 +3264,6 @@ _outAExpr(StringInfo str, const A_Expr *node) ...@@ -3264,9 +3264,6 @@ _outAExpr(StringInfo str, const A_Expr *node)
appendStringInfoString(str, " NOT_BETWEEN_SYM "); appendStringInfoString(str, " NOT_BETWEEN_SYM ");
WRITE_NODE_FIELD(name); WRITE_NODE_FIELD(name);
break; break;
case AEXPR_PAREN:
appendStringInfoString(str, " PAREN");
break;
default: default:
appendStringInfoString(str, " ??"); appendStringInfoString(str, " ??");
break; break;
......
...@@ -59,7 +59,6 @@ ...@@ -59,7 +59,6 @@
#include "nodes/nodeFuncs.h" #include "nodes/nodeFuncs.h"
#include "parser/gramparse.h" #include "parser/gramparse.h"
#include "parser/parser.h" #include "parser/parser.h"
#include "parser/parse_expr.h"
#include "storage/lmgr.h" #include "storage/lmgr.h"
#include "utils/date.h" #include "utils/date.h"
#include "utils/datetime.h" #include "utils/datetime.h"
...@@ -13461,28 +13460,6 @@ c_expr: columnref { $$ = $1; } ...@@ -13461,28 +13460,6 @@ c_expr: columnref { $$ = $1; }
n->indirection = check_indirection($4, yyscanner); n->indirection = check_indirection($4, yyscanner);
$$ = (Node *)n; $$ = (Node *)n;
} }
else if (operator_precedence_warning)
{
/*
* If precedence warnings are enabled, insert
* AEXPR_PAREN nodes wrapping all explicitly
* parenthesized subexpressions; this prevents bogus
* warnings from being issued when the ordering has
* been forced by parentheses. Take care that an
* AEXPR_PAREN node has the same exprLocation as its
* child, so as not to cause surprising changes in
* error cursor positioning.
*
* In principle we should not be relying on a GUC to
* decide whether to insert AEXPR_PAREN nodes.
* However, since they have no effect except to
* suppress warnings, it's probably safe enough; and
* we'd just as soon not waste cycles on dummy parse
* nodes if we don't have to.
*/
$$ = (Node *) makeA_Expr(AEXPR_PAREN, NIL, $2, NULL,
exprLocation($2));
}
else else
$$ = $2; $$ = $2;
} }
...@@ -16516,16 +16493,10 @@ doNegateFloat(Value *v) ...@@ -16516,16 +16493,10 @@ doNegateFloat(Value *v)
static Node * static Node *
makeAndExpr(Node *lexpr, Node *rexpr, int location) makeAndExpr(Node *lexpr, Node *rexpr, int location)
{ {
Node *lexp = lexpr;
/* Look through AEXPR_PAREN nodes so they don't affect flattening */
while (IsA(lexp, A_Expr) &&
((A_Expr *) lexp)->kind == AEXPR_PAREN)
lexp = ((A_Expr *) lexp)->lexpr;
/* Flatten "a AND b AND c ..." to a single BoolExpr on sight */ /* Flatten "a AND b AND c ..." to a single BoolExpr on sight */
if (IsA(lexp, BoolExpr)) if (IsA(lexpr, BoolExpr))
{ {
BoolExpr *blexpr = (BoolExpr *) lexp; BoolExpr *blexpr = (BoolExpr *) lexpr;
if (blexpr->boolop == AND_EXPR) if (blexpr->boolop == AND_EXPR)
{ {
...@@ -16539,16 +16510,10 @@ makeAndExpr(Node *lexpr, Node *rexpr, int location) ...@@ -16539,16 +16510,10 @@ makeAndExpr(Node *lexpr, Node *rexpr, int location)
static Node * static Node *
makeOrExpr(Node *lexpr, Node *rexpr, int location) makeOrExpr(Node *lexpr, Node *rexpr, int location)
{ {
Node *lexp = lexpr;
/* Look through AEXPR_PAREN nodes so they don't affect flattening */
while (IsA(lexp, A_Expr) &&
((A_Expr *) lexp)->kind == AEXPR_PAREN)
lexp = ((A_Expr *) lexp)->lexpr;
/* Flatten "a OR b OR c ..." to a single BoolExpr on sight */ /* Flatten "a OR b OR c ..." to a single BoolExpr on sight */
if (IsA(lexp, BoolExpr)) if (IsA(lexpr, BoolExpr))
{ {
BoolExpr *blexpr = (BoolExpr *) lexp; BoolExpr *blexpr = (BoolExpr *) lexpr;
if (blexpr->boolop == OR_EXPR) if (blexpr->boolop == OR_EXPR)
{ {
......
This diff is collapsed.
...@@ -1755,11 +1755,6 @@ FigureColnameInternal(Node *node, char **name) ...@@ -1755,11 +1755,6 @@ FigureColnameInternal(Node *node, char **name)
*name = "nullif"; *name = "nullif";
return 2; return 2;
} }
if (((A_Expr *) node)->kind == AEXPR_PAREN)
{
/* look through dummy parenthesis node */
return FigureColnameInternal(((A_Expr *) node)->lexpr, name);
}
break; break;
case T_TypeCast: case T_TypeCast:
strength = FigureColnameInternal(((TypeCast *) node)->arg, strength = FigureColnameInternal(((TypeCast *) node)->arg,
......
...@@ -1878,16 +1878,6 @@ static struct config_bool ConfigureNamesBool[] = ...@@ -1878,16 +1878,6 @@ static struct config_bool ConfigureNamesBool[] =
NULL, NULL, NULL NULL, NULL, NULL
}, },
{
{"operator_precedence_warning", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
gettext_noop("Emit a warning for constructs that changed meaning since PostgreSQL 9.4."),
NULL,
},
&operator_precedence_warning,
false,
NULL, NULL, NULL
},
{ {
{"quote_all_identifiers", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS, {"quote_all_identifiers", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
gettext_noop("When generating SQL fragments, quote all identifiers."), gettext_noop("When generating SQL fragments, quote all identifiers."),
......
...@@ -740,7 +740,6 @@ ...@@ -740,7 +740,6 @@
#backslash_quote = safe_encoding # on, off, or safe_encoding #backslash_quote = safe_encoding # on, off, or safe_encoding
#escape_string_warning = on #escape_string_warning = on
#lo_compat_privileges = off #lo_compat_privileges = off
#operator_precedence_warning = off
#quote_all_identifiers = off #quote_all_identifiers = off
#standard_conforming_strings = on #standard_conforming_strings = on
#synchronize_seqscans = on #synchronize_seqscans = on
......
...@@ -265,8 +265,7 @@ typedef enum A_Expr_Kind ...@@ -265,8 +265,7 @@ typedef enum A_Expr_Kind
AEXPR_BETWEEN, /* name must be "BETWEEN" */ AEXPR_BETWEEN, /* name must be "BETWEEN" */
AEXPR_NOT_BETWEEN, /* name must be "NOT BETWEEN" */ AEXPR_NOT_BETWEEN, /* name must be "NOT BETWEEN" */
AEXPR_BETWEEN_SYM, /* name must be "BETWEEN SYMMETRIC" */ AEXPR_BETWEEN_SYM, /* name must be "BETWEEN SYMMETRIC" */
AEXPR_NOT_BETWEEN_SYM, /* name must be "NOT BETWEEN SYMMETRIC" */ AEXPR_NOT_BETWEEN_SYM /* name must be "NOT BETWEEN SYMMETRIC" */
AEXPR_PAREN /* nameless dummy node for parentheses */
} A_Expr_Kind; } A_Expr_Kind;
typedef struct A_Expr typedef struct A_Expr
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "parser/parse_node.h" #include "parser/parse_node.h"
/* GUC parameters */ /* GUC parameters */
extern bool operator_precedence_warning;
extern bool Transform_null_equals; extern bool Transform_null_equals;
extern Node *transformExpr(ParseState *pstate, Node *expr, ParseExprKind exprKind); extern Node *transformExpr(ParseState *pstate, Node *expr, ParseExprKind exprKind);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment