@@ -7496,8 +7496,10 @@ isSimpleNode(Node *node, Node *parentNode, int prettyFlags)
7496
7496
CoercionForm type = ((FuncExpr * ) parentNode )-> funcformat ;
7497
7497
7498
7498
if (type == COERCE_EXPLICIT_CAST ||
7499
- type == COERCE_IMPLICIT_CAST )
7499
+ type == COERCE_IMPLICIT_CAST ||
7500
+ type == COERCE_INTERNAL_CAST )
7500
7501
return false;
7502
+
7501
7503
return true; /* own parentheses */
7502
7504
}
7503
7505
case T_BoolExpr : /* lower precedence */
@@ -7547,7 +7549,8 @@ isSimpleNode(Node *node, Node *parentNode, int prettyFlags)
7547
7549
CoercionForm type = ((FuncExpr * ) parentNode )-> funcformat ;
7548
7550
7549
7551
if (type == COERCE_EXPLICIT_CAST ||
7550
- type == COERCE_IMPLICIT_CAST )
7552
+ type == COERCE_IMPLICIT_CAST ||
7553
+ type == COERCE_INTERNAL_CAST )
7551
7554
return false;
7552
7555
return true; /* own parentheses */
7553
7556
}
@@ -7672,6 +7675,25 @@ get_rule_expr_paren(Node *node, deparse_context *context,
7672
7675
}
7673
7676
7674
7677
7678
+ /*
7679
+ * get_coercion - Parse back a coercion
7680
+ */
7681
+ static void
7682
+ get_coercion (Expr * arg , deparse_context * context , bool showimplicit ,
7683
+ Node * node , CoercionForm format , Oid typid , int32 typmod )
7684
+ {
7685
+ if (format == COERCE_INTERNAL_CAST ||
7686
+ (format == COERCE_IMPLICIT_CAST && !showimplicit ))
7687
+ {
7688
+ /* don't show the implicit cast */
7689
+ get_rule_expr_paren ((Node * ) arg , context , false, node );
7690
+ }
7691
+ else
7692
+ {
7693
+ get_coercion_expr ((Node * ) arg , context , typid , typmod , node );
7694
+ }
7695
+ }
7696
+
7675
7697
/* ----------
7676
7698
* get_rule_expr - Parse back an expression
7677
7699
*
@@ -8052,83 +8074,38 @@ get_rule_expr(Node *node, deparse_context *context,
8052
8074
case T_RelabelType :
8053
8075
{
8054
8076
RelabelType * relabel = (RelabelType * ) node ;
8055
- Node * arg = (Node * ) relabel -> arg ;
8056
8077
8057
- if (relabel -> relabelformat == COERCE_IMPLICIT_CAST &&
8058
- !showimplicit )
8059
- {
8060
- /* don't show the implicit cast */
8061
- get_rule_expr_paren (arg , context , false, node );
8062
- }
8063
- else
8064
- {
8065
- get_coercion_expr (arg , context ,
8066
- relabel -> resulttype ,
8067
- relabel -> resulttypmod ,
8068
- node );
8069
- }
8078
+ get_coercion (relabel -> arg , context , showimplicit , node ,
8079
+ relabel -> relabelformat , relabel -> resulttype ,
8080
+ relabel -> resulttypmod );
8070
8081
}
8071
8082
break ;
8072
8083
8073
8084
case T_CoerceViaIO :
8074
8085
{
8075
8086
CoerceViaIO * iocoerce = (CoerceViaIO * ) node ;
8076
- Node * arg = (Node * ) iocoerce -> arg ;
8077
8087
8078
- if (iocoerce -> coerceformat == COERCE_IMPLICIT_CAST &&
8079
- !showimplicit )
8080
- {
8081
- /* don't show the implicit cast */
8082
- get_rule_expr_paren (arg , context , false, node );
8083
- }
8084
- else
8085
- {
8086
- get_coercion_expr (arg , context ,
8087
- iocoerce -> resulttype ,
8088
- -1 ,
8089
- node );
8090
- }
8088
+ get_coercion (iocoerce -> arg , context , showimplicit , node ,
8089
+ iocoerce -> coerceformat , iocoerce -> resulttype , -1 );
8091
8090
}
8092
8091
break ;
8093
8092
8094
8093
case T_ArrayCoerceExpr :
8095
8094
{
8096
8095
ArrayCoerceExpr * acoerce = (ArrayCoerceExpr * ) node ;
8097
- Node * arg = (Node * ) acoerce -> arg ;
8098
8096
8099
- if (acoerce -> coerceformat == COERCE_IMPLICIT_CAST &&
8100
- !showimplicit )
8101
- {
8102
- /* don't show the implicit cast */
8103
- get_rule_expr_paren (arg , context , false, node );
8104
- }
8105
- else
8106
- {
8107
- get_coercion_expr (arg , context ,
8108
- acoerce -> resulttype ,
8109
- acoerce -> resulttypmod ,
8110
- node );
8111
- }
8097
+ get_coercion (acoerce -> arg , context , showimplicit , node ,
8098
+ acoerce -> coerceformat , acoerce -> resulttype ,
8099
+ acoerce -> resulttypmod );
8112
8100
}
8113
8101
break ;
8114
8102
8115
8103
case T_ConvertRowtypeExpr :
8116
8104
{
8117
8105
ConvertRowtypeExpr * convert = (ConvertRowtypeExpr * ) node ;
8118
- Node * arg = (Node * ) convert -> arg ;
8119
8106
8120
- if (convert -> convertformat == COERCE_IMPLICIT_CAST &&
8121
- !showimplicit )
8122
- {
8123
- /* don't show the implicit cast */
8124
- get_rule_expr_paren (arg , context , false, node );
8125
- }
8126
- else
8127
- {
8128
- get_coercion_expr (arg , context ,
8129
- convert -> resulttype , -1 ,
8130
- node );
8131
- }
8107
+ get_coercion (convert -> arg , context , showimplicit , node ,
8108
+ convert -> convertformat , convert -> resulttype , -1 );
8132
8109
}
8133
8110
break ;
8134
8111
@@ -8681,21 +8658,10 @@ get_rule_expr(Node *node, deparse_context *context,
8681
8658
case T_CoerceToDomain :
8682
8659
{
8683
8660
CoerceToDomain * ctest = (CoerceToDomain * ) node ;
8684
- Node * arg = (Node * ) ctest -> arg ;
8685
8661
8686
- if (ctest -> coercionformat == COERCE_IMPLICIT_CAST &&
8687
- !showimplicit )
8688
- {
8689
- /* don't show the implicit cast */
8690
- get_rule_expr (arg , context , false);
8691
- }
8692
- else
8693
- {
8694
- get_coercion_expr (arg , context ,
8695
- ctest -> resulttype ,
8696
- ctest -> resulttypmod ,
8697
- node );
8698
- }
8662
+ get_coercion (ctest -> arg , context , showimplicit , node ,
8663
+ ctest -> coercionformat , ctest -> resulttype ,
8664
+ ctest -> resulttypmod );
8699
8665
}
8700
8666
break ;
8701
8667
@@ -9027,7 +8993,8 @@ get_func_expr(FuncExpr *expr, deparse_context *context,
9027
8993
* If the function call came from an implicit coercion, then just show the
9028
8994
* first argument --- unless caller wants to see implicit coercions.
9029
8995
*/
9030
- if (expr -> funcformat == COERCE_IMPLICIT_CAST && !showimplicit )
8996
+ if (expr -> funcformat == COERCE_INTERNAL_CAST ||
8997
+ (expr -> funcformat == COERCE_IMPLICIT_CAST && !showimplicit ))
9031
8998
{
9032
8999
get_rule_expr_paren ((Node * ) linitial (expr -> args ), context ,
9033
9000
false, (Node * ) expr );
0 commit comments