aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/nodes/nodeFuncs.c59
-rw-r--r--src/backend/optimizer/util/clauses.c56
-rw-r--r--src/backend/parser/parse_clause.c1
-rw-r--r--src/backend/parser/parse_relation.c1
-rw-r--r--src/backend/rewrite/rewriteHandler.c1
-rw-r--r--src/backend/utils/adt/ruleutils.c1
-rw-r--r--src/include/nodes/nodeFuncs.h1
-rw-r--r--src/include/optimizer/clauses.h2
8 files changed, 60 insertions, 62 deletions
diff --git a/src/backend/nodes/nodeFuncs.c b/src/backend/nodes/nodeFuncs.c
index a896d763b8f..908f397d501 100644
--- a/src/backend/nodes/nodeFuncs.c
+++ b/src/backend/nodes/nodeFuncs.c
@@ -572,6 +572,65 @@ relabel_to_typmod(Node *expr, int32 typmod)
}
/*
+ * strip_implicit_coercions: remove implicit coercions at top level of tree
+ *
+ * This doesn't modify or copy the input expression tree, just return a
+ * pointer to a suitable place within it.
+ *
+ * Note: there isn't any useful thing we can do with a RowExpr here, so
+ * just return it unchanged, even if it's marked as an implicit coercion.
+ */
+Node *
+strip_implicit_coercions(Node *node)
+{
+ if (node == NULL)
+ return NULL;
+ if (IsA(node, FuncExpr))
+ {
+ FuncExpr *f = (FuncExpr *) node;
+
+ if (f->funcformat == COERCE_IMPLICIT_CAST)
+ return strip_implicit_coercions(linitial(f->args));
+ }
+ else if (IsA(node, RelabelType))
+ {
+ RelabelType *r = (RelabelType *) node;
+
+ if (r->relabelformat == COERCE_IMPLICIT_CAST)
+ return strip_implicit_coercions((Node *) r->arg);
+ }
+ else if (IsA(node, CoerceViaIO))
+ {
+ CoerceViaIO *c = (CoerceViaIO *) node;
+
+ if (c->coerceformat == COERCE_IMPLICIT_CAST)
+ return strip_implicit_coercions((Node *) c->arg);
+ }
+ else if (IsA(node, ArrayCoerceExpr))
+ {
+ ArrayCoerceExpr *c = (ArrayCoerceExpr *) node;
+
+ if (c->coerceformat == COERCE_IMPLICIT_CAST)
+ return strip_implicit_coercions((Node *) c->arg);
+ }
+ else if (IsA(node, ConvertRowtypeExpr))
+ {
+ ConvertRowtypeExpr *c = (ConvertRowtypeExpr *) node;
+
+ if (c->convertformat == COERCE_IMPLICIT_CAST)
+ return strip_implicit_coercions((Node *) c->arg);
+ }
+ else if (IsA(node, CoerceToDomain))
+ {
+ CoerceToDomain *c = (CoerceToDomain *) node;
+
+ if (c->coercionformat == COERCE_IMPLICIT_CAST)
+ return strip_implicit_coercions((Node *) c->arg);
+ }
+ return node;
+}
+
+/*
* expression_returns_set
* Test whether an expression returns a set result.
*
diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c
index 7ec6b0b30ba..506e9d49fc3 100644
--- a/src/backend/optimizer/util/clauses.c
+++ b/src/backend/optimizer/util/clauses.c
@@ -2071,62 +2071,6 @@ CommuteRowCompareExpr(RowCompareExpr *clause)
}
/*
- * strip_implicit_coercions: remove implicit coercions at top level of tree
- *
- * Note: there isn't any useful thing we can do with a RowExpr here, so
- * just return it unchanged, even if it's marked as an implicit coercion.
- */
-Node *
-strip_implicit_coercions(Node *node)
-{
- if (node == NULL)
- return NULL;
- if (IsA(node, FuncExpr))
- {
- FuncExpr *f = (FuncExpr *) node;
-
- if (f->funcformat == COERCE_IMPLICIT_CAST)
- return strip_implicit_coercions(linitial(f->args));
- }
- else if (IsA(node, RelabelType))
- {
- RelabelType *r = (RelabelType *) node;
-
- if (r->relabelformat == COERCE_IMPLICIT_CAST)
- return strip_implicit_coercions((Node *) r->arg);
- }
- else if (IsA(node, CoerceViaIO))
- {
- CoerceViaIO *c = (CoerceViaIO *) node;
-
- if (c->coerceformat == COERCE_IMPLICIT_CAST)
- return strip_implicit_coercions((Node *) c->arg);
- }
- else if (IsA(node, ArrayCoerceExpr))
- {
- ArrayCoerceExpr *c = (ArrayCoerceExpr *) node;
-
- if (c->coerceformat == COERCE_IMPLICIT_CAST)
- return strip_implicit_coercions((Node *) c->arg);
- }
- else if (IsA(node, ConvertRowtypeExpr))
- {
- ConvertRowtypeExpr *c = (ConvertRowtypeExpr *) node;
-
- if (c->convertformat == COERCE_IMPLICIT_CAST)
- return strip_implicit_coercions((Node *) c->arg);
- }
- else if (IsA(node, CoerceToDomain))
- {
- CoerceToDomain *c = (CoerceToDomain *) node;
-
- if (c->coercionformat == COERCE_IMPLICIT_CAST)
- return strip_implicit_coercions((Node *) c->arg);
- }
- return node;
-}
-
-/*
* Helper for eval_const_expressions: check that datatype of an attribute
* is still what it was when the expression was parsed. This is needed to
* guard against improper simplification after ALTER COLUMN TYPE. (XXX we
diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c
index cbfb43188c1..ea90e58f710 100644
--- a/src/backend/parser/parse_clause.c
+++ b/src/backend/parser/parse_clause.c
@@ -21,7 +21,6 @@
#include "commands/defrem.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
-#include "optimizer/clauses.h"
#include "optimizer/tlist.h"
#include "parser/analyze.h"
#include "parser/parsetree.h"
diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c
index 42de89f5101..b2b88fc6a97 100644
--- a/src/backend/parser/parse_relation.c
+++ b/src/backend/parser/parse_relation.c
@@ -24,7 +24,6 @@
#include "funcapi.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
-#include "optimizer/clauses.h"
#include "parser/parsetree.h"
#include "parser/parse_relation.h"
#include "parser/parse_type.h"
diff --git a/src/backend/rewrite/rewriteHandler.c b/src/backend/rewrite/rewriteHandler.c
index 3c7974adc72..5c6763e17b4 100644
--- a/src/backend/rewrite/rewriteHandler.c
+++ b/src/backend/rewrite/rewriteHandler.c
@@ -19,7 +19,6 @@
#include "foreign/fdwapi.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
-#include "optimizer/clauses.h"
#include "parser/analyze.h"
#include "parser/parse_coerce.h"
#include "parser/parsetree.h"
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 762be4e846b..e6a20e3821c 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -38,7 +38,6 @@
#include "funcapi.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
-#include "optimizer/clauses.h"
#include "optimizer/tlist.h"
#include "parser/keywords.h"
#include "parser/parse_func.h"
diff --git a/src/include/nodes/nodeFuncs.h b/src/include/nodes/nodeFuncs.h
index d4901caefa6..fe7cfd38807 100644
--- a/src/include/nodes/nodeFuncs.h
+++ b/src/include/nodes/nodeFuncs.h
@@ -30,6 +30,7 @@ extern Oid exprType(const Node *expr);
extern int32 exprTypmod(const Node *expr);
extern bool exprIsLengthCoercion(const Node *expr, int32 *coercedTypmod);
extern Node *relabel_to_typmod(Node *expr, int32 typmod);
+extern Node *strip_implicit_coercions(Node *node);
extern bool expression_returns_set(Node *clause);
extern Oid exprCollation(const Node *expr);
diff --git a/src/include/optimizer/clauses.h b/src/include/optimizer/clauses.h
index 586f8c8881e..a08799957a0 100644
--- a/src/include/optimizer/clauses.h
+++ b/src/include/optimizer/clauses.h
@@ -77,8 +77,6 @@ extern int NumRelids(Node *clause);
extern void CommuteOpExpr(OpExpr *clause);
extern void CommuteRowCompareExpr(RowCompareExpr *clause);
-extern Node *strip_implicit_coercions(Node *node);
-
extern Node *eval_const_expressions(PlannerInfo *root, Node *node);
extern Node *estimate_expression_value(PlannerInfo *root, Node *node);