This is an automated email from the ASF dual-hosted git repository.
jgemignani pushed a commit to branch PG13
in repository https://gitbox.apache.org/repos/asf/age.git
The following commit(s) were added to refs/heads/PG13 by this push:
new e569bf0d Copy PGs verify_common_type function to AGE (#1609)
e569bf0d is described below
commit e569bf0d57c42c7e8d39ff5c076e9d02ed990160
Author: Zainab Saad <[email protected]>
AuthorDate: Thu Feb 15 22:34:10 2024 +0500
Copy PGs verify_common_type function to AGE (#1609)
- The function verify_common_type does not exist for few lower versions
of PG13 and transform_AEXPR_IN uses this function due to which build
failed, this PR copies above function to AGE
---
src/backend/parser/cypher_expr.c | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/src/backend/parser/cypher_expr.c b/src/backend/parser/cypher_expr.c
index 490386f4..07e95f00 100644
--- a/src/backend/parser/cypher_expr.c
+++ b/src/backend/parser/cypher_expr.c
@@ -91,6 +91,7 @@ static Node *transform_WholeRowRef(ParseState *pstate,
ParseNamespaceItem *pnsi,
static ArrayExpr *make_agtype_array_expr(List *args);
static Node *transform_column_ref_for_indirection(cypher_parsestate *cpstate,
ColumnRef *cr);
+static bool verify_common_type_coercion(Oid common_type, List *exprs);
/* transform a cypher expression */
Node *transform_cypher_expr(cypher_parsestate *cpstate, Node *expr,
@@ -493,6 +494,29 @@ static Node
*transform_cypher_comparison_aexpr_OP(cypher_parsestate *cpstate,
return (Node *)transform_AEXPR_OP(cpstate, n);
}
+/*
+ * Copied from PGs verify_common_type -
+ * Verify that all input types can be coerced to a proposed common type.
+ * Return true if so, false if not all coercions are possible.
+ */
+static bool verify_common_type_coercion(Oid common_type, List *exprs)
+{
+ ListCell *lc;
+
+ foreach(lc, exprs)
+ {
+ Node *nexpr = (Node *) lfirst(lc);
+ Oid ntype = exprType(nexpr);
+
+ if (!can_coerce_type(1, &ntype, &common_type, COERCION_IMPLICIT))
+ {
+ return false;
+ }
+ }
+
+ return true;
+}
+
static Node *transform_AEXPR_IN(cypher_parsestate *cpstate, A_Expr *a)
{
ParseState *pstate = (ParseState *)cpstate;
@@ -578,7 +602,7 @@ static Node *transform_AEXPR_IN(cypher_parsestate *cpstate,
A_Expr *a)
scalar_type = AGTYPEOID;
- if (verify_common_type(scalar_type, allexprs) != true)
+ if (verify_common_type_coercion(scalar_type, allexprs) != true)
{
ereport(ERROR,
(errcode(ERRCODE_CANNOT_COERCE),