@@ -7567,8 +7567,10 @@ isSimpleNode(Node *node, Node *parentNode, int prettyFlags)
7567
7567
CoercionForm type = ((FuncExpr * ) parentNode )-> funcformat ;
7568
7568
7569
7569
if (type == COERCE_EXPLICIT_CAST ||
7570
- type == COERCE_IMPLICIT_CAST )
7570
+ type == COERCE_IMPLICIT_CAST ||
7571
+ type == COERCE_INTERNAL_CAST )
7571
7572
return false;
7573
+
7572
7574
return true; /* own parentheses */
7573
7575
}
7574
7576
case T_BoolExpr : /* lower precedence */
@@ -7618,7 +7620,8 @@ isSimpleNode(Node *node, Node *parentNode, int prettyFlags)
7618
7620
CoercionForm type = ((FuncExpr * ) parentNode )-> funcformat ;
7619
7621
7620
7622
if (type == COERCE_EXPLICIT_CAST ||
7621
- type == COERCE_IMPLICIT_CAST )
7623
+ type == COERCE_IMPLICIT_CAST ||
7624
+ type == COERCE_INTERNAL_CAST )
7622
7625
return false;
7623
7626
return true; /* own parentheses */
7624
7627
}
@@ -7743,6 +7746,25 @@ get_rule_expr_paren(Node *node, deparse_context *context,
7743
7746
}
7744
7747
7745
7748
7749
+ /*
7750
+ * get_coercion - Parse back a coercion
7751
+ */
7752
+ static void
7753
+ get_coercion (Expr * arg , deparse_context * context , bool showimplicit ,
7754
+ Node * node , CoercionForm format , Oid typid , int32 typmod )
7755
+ {
7756
+ if (format == COERCE_INTERNAL_CAST ||
7757
+ (format == COERCE_IMPLICIT_CAST && !showimplicit ))
7758
+ {
7759
+ /* don't show the implicit cast */
7760
+ get_rule_expr_paren ((Node * ) arg , context , false, node );
7761
+ }
7762
+ else
7763
+ {
7764
+ get_coercion_expr ((Node * ) arg , context , typid , typmod , node );
7765
+ }
7766
+ }
7767
+
7746
7768
/* ----------
7747
7769
* get_rule_expr - Parse back an expression
7748
7770
*
@@ -8123,83 +8145,38 @@ get_rule_expr(Node *node, deparse_context *context,
8123
8145
case T_RelabelType :
8124
8146
{
8125
8147
RelabelType * relabel = (RelabelType * ) node ;
8126
- Node * arg = (Node * ) relabel -> arg ;
8127
8148
8128
- if (relabel -> relabelformat == COERCE_IMPLICIT_CAST &&
8129
- !showimplicit )
8130
- {
8131
- /* don't show the implicit cast */
8132
- get_rule_expr_paren (arg , context , false, node );
8133
- }
8134
- else
8135
- {
8136
- get_coercion_expr (arg , context ,
8137
- relabel -> resulttype ,
8138
- relabel -> resulttypmod ,
8139
- node );
8140
- }
8149
+ get_coercion (relabel -> arg , context , showimplicit , node ,
8150
+ relabel -> relabelformat , relabel -> resulttype ,
8151
+ relabel -> resulttypmod );
8141
8152
}
8142
8153
break ;
8143
8154
8144
8155
case T_CoerceViaIO :
8145
8156
{
8146
8157
CoerceViaIO * iocoerce = (CoerceViaIO * ) node ;
8147
- Node * arg = (Node * ) iocoerce -> arg ;
8148
8158
8149
- if (iocoerce -> coerceformat == COERCE_IMPLICIT_CAST &&
8150
- !showimplicit )
8151
- {
8152
- /* don't show the implicit cast */
8153
- get_rule_expr_paren (arg , context , false, node );
8154
- }
8155
- else
8156
- {
8157
- get_coercion_expr (arg , context ,
8158
- iocoerce -> resulttype ,
8159
- -1 ,
8160
- node );
8161
- }
8159
+ get_coercion (iocoerce -> arg , context , showimplicit , node ,
8160
+ iocoerce -> coerceformat , iocoerce -> resulttype , -1 );
8162
8161
}
8163
8162
break ;
8164
8163
8165
8164
case T_ArrayCoerceExpr :
8166
8165
{
8167
8166
ArrayCoerceExpr * acoerce = (ArrayCoerceExpr * ) node ;
8168
- Node * arg = (Node * ) acoerce -> arg ;
8169
8167
8170
- if (acoerce -> coerceformat == COERCE_IMPLICIT_CAST &&
8171
- !showimplicit )
8172
- {
8173
- /* don't show the implicit cast */
8174
- get_rule_expr_paren (arg , context , false, node );
8175
- }
8176
- else
8177
- {
8178
- get_coercion_expr (arg , context ,
8179
- acoerce -> resulttype ,
8180
- acoerce -> resulttypmod ,
8181
- node );
8182
- }
8168
+ get_coercion (acoerce -> arg , context , showimplicit , node ,
8169
+ acoerce -> coerceformat , acoerce -> resulttype ,
8170
+ acoerce -> resulttypmod );
8183
8171
}
8184
8172
break ;
8185
8173
8186
8174
case T_ConvertRowtypeExpr :
8187
8175
{
8188
8176
ConvertRowtypeExpr * convert = (ConvertRowtypeExpr * ) node ;
8189
- Node * arg = (Node * ) convert -> arg ;
8190
8177
8191
- if (convert -> convertformat == COERCE_IMPLICIT_CAST &&
8192
- !showimplicit )
8193
- {
8194
- /* don't show the implicit cast */
8195
- get_rule_expr_paren (arg , context , false, node );
8196
- }
8197
- else
8198
- {
8199
- get_coercion_expr (arg , context ,
8200
- convert -> resulttype , -1 ,
8201
- node );
8202
- }
8178
+ get_coercion (convert -> arg , context , showimplicit , node ,
8179
+ convert -> convertformat , convert -> resulttype , -1 );
8203
8180
}
8204
8181
break ;
8205
8182
@@ -8752,21 +8729,10 @@ get_rule_expr(Node *node, deparse_context *context,
8752
8729
case T_CoerceToDomain :
8753
8730
{
8754
8731
CoerceToDomain * ctest = (CoerceToDomain * ) node ;
8755
- Node * arg = (Node * ) ctest -> arg ;
8756
8732
8757
- if (ctest -> coercionformat == COERCE_IMPLICIT_CAST &&
8758
- !showimplicit )
8759
- {
8760
- /* don't show the implicit cast */
8761
- get_rule_expr (arg , context , false);
8762
- }
8763
- else
8764
- {
8765
- get_coercion_expr (arg , context ,
8766
- ctest -> resulttype ,
8767
- ctest -> resulttypmod ,
8768
- node );
8769
- }
8733
+ get_coercion (ctest -> arg , context , showimplicit , node ,
8734
+ ctest -> coercionformat , ctest -> resulttype ,
8735
+ ctest -> resulttypmod );
8770
8736
}
8771
8737
break ;
8772
8738
@@ -9098,7 +9064,8 @@ get_func_expr(FuncExpr *expr, deparse_context *context,
9098
9064
* If the function call came from an implicit coercion, then just show the
9099
9065
* first argument --- unless caller wants to see implicit coercions.
9100
9066
*/
9101
- if (expr -> funcformat == COERCE_IMPLICIT_CAST && !showimplicit )
9067
+ if (expr -> funcformat == COERCE_INTERNAL_CAST ||
9068
+ (expr -> funcformat == COERCE_IMPLICIT_CAST && !showimplicit ))
9102
9069
{
9103
9070
get_rule_expr_paren ((Node * ) linitial (expr -> args ), context ,
9104
9071
false, (Node * ) expr );
0 commit comments