Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/backend/parser/cypher_clause.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
20 changes: 15 additions & 5 deletions src/backend/utils/adt/agtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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);
Expand All @@ -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 */
Expand Down