diff --git a/src/backend/parser/cypher_clause.c b/src/backend/parser/cypher_clause.c index df1a4348c..299f12030 100644 --- a/src/backend/parser/cypher_clause.c +++ b/src/backend/parser/cypher_clause.c @@ -1334,6 +1334,13 @@ static Query *transform_cypher_unwind(cypher_parsestate *cpstate, pnsi = transform_prev_cypher_clause(cpstate, clause->prev, true); rtindex = list_length(pstate->p_rtable); Assert(rtindex == 1); // rte is the first RangeTblEntry in pstate + if (rtindex != 1) + { + ereport(ERROR, + (errcode(ERRCODE_DATATYPE_MISMATCH), + errmsg("invalid value for rtindex"))); + } + query->targetList = expandNSItemAttrs(pstate, pnsi, 0, -1); } diff --git a/src/backend/utils/adt/agtype.c b/src/backend/utils/adt/agtype.c index f60f85ee4..c95419225 100644 --- a/src/backend/utils/adt/agtype.c +++ b/src/backend/utils/adt/agtype.c @@ -5574,11 +5574,13 @@ Datum age_tointeger(PG_FUNCTION_ARGS) result = agtv_value->val.int_value; else if (agtv_value->type == AGTV_FLOAT) { - float f = agtv_value->val.float_value; + float8 f = agtv_value->val.float_value; if (isnan(f) || isinf(f) || - f < PG_INT64_MIN || f > PG_INT64_MAX) + f < (float8)PG_INT64_MIN || f > (float8)PG_INT64_MAX) + { PG_RETURN_NULL(); + } result = (int64) f; } @@ -5591,8 +5593,10 @@ Datum age_tointeger(PG_FUNCTION_ARGS) numeric_float8_no_overflow, num)); if (isnan(f) || isinf(f) || - f < PG_INT64_MIN || f > PG_INT64_MAX) + f < (float8)PG_INT64_MIN || f > (float8)PG_INT64_MAX) + { PG_RETURN_NULL(); + } result = (int64) f; } @@ -5609,7 +5613,7 @@ Datum age_tointeger(PG_FUNCTION_ARGS) */ if (!is_valid) { - float f; + float8 f; f = float8in_internal_null(string, NULL, "double precision", string, &is_valid); @@ -5619,18 +5623,24 @@ Datum age_tointeger(PG_FUNCTION_ARGS) * return null. */ if (!is_valid || isnan(f) || isinf(f) || - f < PG_INT64_MIN || f > PG_INT64_MAX) + f < (float8)PG_INT64_MIN || f > (float8)PG_INT64_MAX) + { PG_RETURN_NULL(); + } result = (int64) f; } else + { free(string); + } } else + { ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("toInteger() unsupported argument agtype %d", agtv_value->type))); + } } /* build the result */