@@ -7414,8 +7414,10 @@ isSimpleNode(Node *node, Node *parentNode, int prettyFlags)
7414
7414
CoercionForm type = ((FuncExpr * ) parentNode )-> funcformat ;
7415
7415
7416
7416
if (type == COERCE_EXPLICIT_CAST ||
7417
- type == COERCE_IMPLICIT_CAST )
7417
+ type == COERCE_IMPLICIT_CAST ||
7418
+ type == COERCE_INTERNAL_CAST )
7418
7419
return false;
7420
+
7419
7421
return true; /* own parentheses */
7420
7422
}
7421
7423
case T_BoolExpr : /* lower precedence */
@@ -7465,7 +7467,8 @@ isSimpleNode(Node *node, Node *parentNode, int prettyFlags)
7465
7467
CoercionForm type = ((FuncExpr * ) parentNode )-> funcformat ;
7466
7468
7467
7469
if (type == COERCE_EXPLICIT_CAST ||
7468
- type == COERCE_IMPLICIT_CAST )
7470
+ type == COERCE_IMPLICIT_CAST ||
7471
+ type == COERCE_INTERNAL_CAST )
7469
7472
return false;
7470
7473
return true; /* own parentheses */
7471
7474
}
@@ -7590,6 +7593,25 @@ get_rule_expr_paren(Node *node, deparse_context *context,
7590
7593
}
7591
7594
7592
7595
7596
+ /*
7597
+ * get_coercion - Parse back a coercion
7598
+ */
7599
+ static void
7600
+ get_coercion (Expr * arg , deparse_context * context , bool showimplicit ,
7601
+ Node * node , CoercionForm format , Oid typid , int32 typmod )
7602
+ {
7603
+ if (format == COERCE_INTERNAL_CAST ||
7604
+ (format == COERCE_IMPLICIT_CAST && !showimplicit ))
7605
+ {
7606
+ /* don't show the implicit cast */
7607
+ get_rule_expr_paren ((Node * ) arg , context , false, node );
7608
+ }
7609
+ else
7610
+ {
7611
+ get_coercion_expr ((Node * ) arg , context , typid , typmod , node );
7612
+ }
7613
+ }
7614
+
7593
7615
/* ----------
7594
7616
* get_rule_expr - Parse back an expression
7595
7617
*
@@ -7970,83 +7992,38 @@ get_rule_expr(Node *node, deparse_context *context,
7970
7992
case T_RelabelType :
7971
7993
{
7972
7994
RelabelType * relabel = (RelabelType * ) node ;
7973
- Node * arg = (Node * ) relabel -> arg ;
7974
7995
7975
- if (relabel -> relabelformat == COERCE_IMPLICIT_CAST &&
7976
- !showimplicit )
7977
- {
7978
- /* don't show the implicit cast */
7979
- get_rule_expr_paren (arg , context , false, node );
7980
- }
7981
- else
7982
- {
7983
- get_coercion_expr (arg , context ,
7984
- relabel -> resulttype ,
7985
- relabel -> resulttypmod ,
7986
- node );
7987
- }
7996
+ get_coercion (relabel -> arg , context , showimplicit , node ,
7997
+ relabel -> relabelformat , relabel -> resulttype ,
7998
+ relabel -> resulttypmod );
7988
7999
}
7989
8000
break ;
7990
8001
7991
8002
case T_CoerceViaIO :
7992
8003
{
7993
8004
CoerceViaIO * iocoerce = (CoerceViaIO * ) node ;
7994
- Node * arg = (Node * ) iocoerce -> arg ;
7995
8005
7996
- if (iocoerce -> coerceformat == COERCE_IMPLICIT_CAST &&
7997
- !showimplicit )
7998
- {
7999
- /* don't show the implicit cast */
8000
- get_rule_expr_paren (arg , context , false, node );
8001
- }
8002
- else
8003
- {
8004
- get_coercion_expr (arg , context ,
8005
- iocoerce -> resulttype ,
8006
- -1 ,
8007
- node );
8008
- }
8006
+ get_coercion (iocoerce -> arg , context , showimplicit , node ,
8007
+ iocoerce -> coerceformat , iocoerce -> resulttype , -1 );
8009
8008
}
8010
8009
break ;
8011
8010
8012
8011
case T_ArrayCoerceExpr :
8013
8012
{
8014
8013
ArrayCoerceExpr * acoerce = (ArrayCoerceExpr * ) node ;
8015
- Node * arg = (Node * ) acoerce -> arg ;
8016
8014
8017
- if (acoerce -> coerceformat == COERCE_IMPLICIT_CAST &&
8018
- !showimplicit )
8019
- {
8020
- /* don't show the implicit cast */
8021
- get_rule_expr_paren (arg , context , false, node );
8022
- }
8023
- else
8024
- {
8025
- get_coercion_expr (arg , context ,
8026
- acoerce -> resulttype ,
8027
- acoerce -> resulttypmod ,
8028
- node );
8029
- }
8015
+ get_coercion (acoerce -> arg , context , showimplicit , node ,
8016
+ acoerce -> coerceformat , acoerce -> resulttype ,
8017
+ acoerce -> resulttypmod );
8030
8018
}
8031
8019
break ;
8032
8020
8033
8021
case T_ConvertRowtypeExpr :
8034
8022
{
8035
8023
ConvertRowtypeExpr * convert = (ConvertRowtypeExpr * ) node ;
8036
- Node * arg = (Node * ) convert -> arg ;
8037
8024
8038
- if (convert -> convertformat == COERCE_IMPLICIT_CAST &&
8039
- !showimplicit )
8040
- {
8041
- /* don't show the implicit cast */
8042
- get_rule_expr_paren (arg , context , false, node );
8043
- }
8044
- else
8045
- {
8046
- get_coercion_expr (arg , context ,
8047
- convert -> resulttype , -1 ,
8048
- node );
8049
- }
8025
+ get_coercion (convert -> arg , context , showimplicit , node ,
8026
+ convert -> convertformat , convert -> resulttype , -1 );
8050
8027
}
8051
8028
break ;
8052
8029
@@ -8599,21 +8576,10 @@ get_rule_expr(Node *node, deparse_context *context,
8599
8576
case T_CoerceToDomain :
8600
8577
{
8601
8578
CoerceToDomain * ctest = (CoerceToDomain * ) node ;
8602
- Node * arg = (Node * ) ctest -> arg ;
8603
8579
8604
- if (ctest -> coercionformat == COERCE_IMPLICIT_CAST &&
8605
- !showimplicit )
8606
- {
8607
- /* don't show the implicit cast */
8608
- get_rule_expr (arg , context , false);
8609
- }
8610
- else
8611
- {
8612
- get_coercion_expr (arg , context ,
8613
- ctest -> resulttype ,
8614
- ctest -> resulttypmod ,
8615
- node );
8616
- }
8580
+ get_coercion (ctest -> arg , context , showimplicit , node ,
8581
+ ctest -> coercionformat , ctest -> resulttype ,
8582
+ ctest -> resulttypmod );
8617
8583
}
8618
8584
break ;
8619
8585
@@ -8945,7 +8911,8 @@ get_func_expr(FuncExpr *expr, deparse_context *context,
8945
8911
* If the function call came from an implicit coercion, then just show the
8946
8912
* first argument --- unless caller wants to see implicit coercions.
8947
8913
*/
8948
- if (expr -> funcformat == COERCE_IMPLICIT_CAST && !showimplicit )
8914
+ if (expr -> funcformat == COERCE_INTERNAL_CAST ||
8915
+ (expr -> funcformat == COERCE_IMPLICIT_CAST && !showimplicit ))
8949
8916
{
8950
8917
get_rule_expr_paren ((Node * ) linitial (expr -> args ), context ,
8951
8918
false, (Node * ) expr );
0 commit comments