Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit10a509d

Browse files
committed
Move strip_implicit_coercions() from optimizer to nodeFuncs.c.
Use of this function has spread into the parser and rewriter, so it seemslike time to pull it out of the optimizer and put it into the more centralnodeFuncs module. This eliminates the need to #include optimizer/clauses.hin most of the calling files, demonstrating that this function was indeed abit outside the normal code reference patterns.
1 parentef65566 commit10a509d

File tree

8 files changed

+60
-62
lines changed

8 files changed

+60
-62
lines changed

‎src/backend/nodes/nodeFuncs.c

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,65 @@ relabel_to_typmod(Node *expr, int32 typmod)
571571
COERCE_EXPLICIT_CAST);
572572
}
573573

574+
/*
575+
* strip_implicit_coercions: remove implicit coercions at top level of tree
576+
*
577+
* This doesn't modify or copy the input expression tree, just return a
578+
* pointer to a suitable place within it.
579+
*
580+
* Note: there isn't any useful thing we can do with a RowExpr here, so
581+
* just return it unchanged, even if it's marked as an implicit coercion.
582+
*/
583+
Node*
584+
strip_implicit_coercions(Node*node)
585+
{
586+
if (node==NULL)
587+
returnNULL;
588+
if (IsA(node,FuncExpr))
589+
{
590+
FuncExpr*f= (FuncExpr*)node;
591+
592+
if (f->funcformat==COERCE_IMPLICIT_CAST)
593+
returnstrip_implicit_coercions(linitial(f->args));
594+
}
595+
elseif (IsA(node,RelabelType))
596+
{
597+
RelabelType*r= (RelabelType*)node;
598+
599+
if (r->relabelformat==COERCE_IMPLICIT_CAST)
600+
returnstrip_implicit_coercions((Node*)r->arg);
601+
}
602+
elseif (IsA(node,CoerceViaIO))
603+
{
604+
CoerceViaIO*c= (CoerceViaIO*)node;
605+
606+
if (c->coerceformat==COERCE_IMPLICIT_CAST)
607+
returnstrip_implicit_coercions((Node*)c->arg);
608+
}
609+
elseif (IsA(node,ArrayCoerceExpr))
610+
{
611+
ArrayCoerceExpr*c= (ArrayCoerceExpr*)node;
612+
613+
if (c->coerceformat==COERCE_IMPLICIT_CAST)
614+
returnstrip_implicit_coercions((Node*)c->arg);
615+
}
616+
elseif (IsA(node,ConvertRowtypeExpr))
617+
{
618+
ConvertRowtypeExpr*c= (ConvertRowtypeExpr*)node;
619+
620+
if (c->convertformat==COERCE_IMPLICIT_CAST)
621+
returnstrip_implicit_coercions((Node*)c->arg);
622+
}
623+
elseif (IsA(node,CoerceToDomain))
624+
{
625+
CoerceToDomain*c= (CoerceToDomain*)node;
626+
627+
if (c->coercionformat==COERCE_IMPLICIT_CAST)
628+
returnstrip_implicit_coercions((Node*)c->arg);
629+
}
630+
returnnode;
631+
}
632+
574633
/*
575634
* expression_returns_set
576635
* Test whether an expression returns a set result.

‎src/backend/optimizer/util/clauses.c

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2070,62 +2070,6 @@ CommuteRowCompareExpr(RowCompareExpr *clause)
20702070
clause->rargs=temp;
20712071
}
20722072

2073-
/*
2074-
* strip_implicit_coercions: remove implicit coercions at top level of tree
2075-
*
2076-
* Note: there isn't any useful thing we can do with a RowExpr here, so
2077-
* just return it unchanged, even if it's marked as an implicit coercion.
2078-
*/
2079-
Node*
2080-
strip_implicit_coercions(Node*node)
2081-
{
2082-
if (node==NULL)
2083-
returnNULL;
2084-
if (IsA(node,FuncExpr))
2085-
{
2086-
FuncExpr*f= (FuncExpr*)node;
2087-
2088-
if (f->funcformat==COERCE_IMPLICIT_CAST)
2089-
returnstrip_implicit_coercions(linitial(f->args));
2090-
}
2091-
elseif (IsA(node,RelabelType))
2092-
{
2093-
RelabelType*r= (RelabelType*)node;
2094-
2095-
if (r->relabelformat==COERCE_IMPLICIT_CAST)
2096-
returnstrip_implicit_coercions((Node*)r->arg);
2097-
}
2098-
elseif (IsA(node,CoerceViaIO))
2099-
{
2100-
CoerceViaIO*c= (CoerceViaIO*)node;
2101-
2102-
if (c->coerceformat==COERCE_IMPLICIT_CAST)
2103-
returnstrip_implicit_coercions((Node*)c->arg);
2104-
}
2105-
elseif (IsA(node,ArrayCoerceExpr))
2106-
{
2107-
ArrayCoerceExpr*c= (ArrayCoerceExpr*)node;
2108-
2109-
if (c->coerceformat==COERCE_IMPLICIT_CAST)
2110-
returnstrip_implicit_coercions((Node*)c->arg);
2111-
}
2112-
elseif (IsA(node,ConvertRowtypeExpr))
2113-
{
2114-
ConvertRowtypeExpr*c= (ConvertRowtypeExpr*)node;
2115-
2116-
if (c->convertformat==COERCE_IMPLICIT_CAST)
2117-
returnstrip_implicit_coercions((Node*)c->arg);
2118-
}
2119-
elseif (IsA(node,CoerceToDomain))
2120-
{
2121-
CoerceToDomain*c= (CoerceToDomain*)node;
2122-
2123-
if (c->coercionformat==COERCE_IMPLICIT_CAST)
2124-
returnstrip_implicit_coercions((Node*)c->arg);
2125-
}
2126-
returnnode;
2127-
}
2128-
21292073
/*
21302074
* Helper for eval_const_expressions: check that datatype of an attribute
21312075
* is still what it was when the expression was parsed. This is needed to

‎src/backend/parser/parse_clause.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include"commands/defrem.h"
2222
#include"nodes/makefuncs.h"
2323
#include"nodes/nodeFuncs.h"
24-
#include"optimizer/clauses.h"
2524
#include"optimizer/tlist.h"
2625
#include"parser/analyze.h"
2726
#include"parser/parsetree.h"

‎src/backend/parser/parse_relation.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include"funcapi.h"
2525
#include"nodes/makefuncs.h"
2626
#include"nodes/nodeFuncs.h"
27-
#include"optimizer/clauses.h"
2827
#include"parser/parsetree.h"
2928
#include"parser/parse_relation.h"
3029
#include"parser/parse_type.h"

‎src/backend/rewrite/rewriteHandler.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include"foreign/fdwapi.h"
2020
#include"nodes/makefuncs.h"
2121
#include"nodes/nodeFuncs.h"
22-
#include"optimizer/clauses.h"
2322
#include"parser/analyze.h"
2423
#include"parser/parse_coerce.h"
2524
#include"parser/parsetree.h"

‎src/backend/utils/adt/ruleutils.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
#include"funcapi.h"
3939
#include"nodes/makefuncs.h"
4040
#include"nodes/nodeFuncs.h"
41-
#include"optimizer/clauses.h"
4241
#include"optimizer/tlist.h"
4342
#include"parser/keywords.h"
4443
#include"parser/parse_func.h"

‎src/include/nodes/nodeFuncs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ extern OidexprType(const Node *expr);
3030
externint32exprTypmod(constNode*expr);
3131
externboolexprIsLengthCoercion(constNode*expr,int32*coercedTypmod);
3232
externNode*relabel_to_typmod(Node*expr,int32typmod);
33+
externNode*strip_implicit_coercions(Node*node);
3334
externboolexpression_returns_set(Node*clause);
3435

3536
externOidexprCollation(constNode*expr);

‎src/include/optimizer/clauses.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ extern intNumRelids(Node *clause);
7777
externvoidCommuteOpExpr(OpExpr*clause);
7878
externvoidCommuteRowCompareExpr(RowCompareExpr*clause);
7979

80-
externNode*strip_implicit_coercions(Node*node);
81-
8280
externNode*eval_const_expressions(PlannerInfo*root,Node*node);
8381

8482
externNode*estimate_expression_value(PlannerInfo*root,Node*node);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp