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
2 changes: 1 addition & 1 deletion docker/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#


FROM postgres:14-buster
FROM postgres:14

RUN apt-get update
RUN apt-get install --assume-yes --no-install-recommends --no-install-suggests \
Expand Down
8 changes: 8 additions & 0 deletions src/backend/parser/cypher_analyze.c
Original file line number Diff line number Diff line change
Expand Up @@ -756,8 +756,16 @@ static Query *analyze_cypher_and_coerce(List *stmt, RangeTblFunction *rtfunc,

pnsi = addRangeTableEntryForSubquery(pstate, subquery, makeAlias("_", NIL),
lateral, true);

rtindex = list_length(pstate->p_rtable);
Assert(rtindex == 1); // rte is the only RangeTblEntry in pstate
if (rtindex !=1 )
{
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("invalid value for rtindex")));
}


addNSItemToQuery(pstate, pnsi, true, true, true);
query->targetList = expandNSItemAttrs(pstate, pnsi, 0, -1);
Expand Down
18 changes: 18 additions & 0 deletions src/backend/parser/cypher_clause.c
Original file line number Diff line number Diff line change
Expand Up @@ -2311,6 +2311,12 @@ static Query *transform_cypher_clause_with_where(cypher_parsestate *cpstate,
Assert(pnsi != NULL);
rtindex = list_length(pstate->p_rtable);
Assert(rtindex == 1); // rte is the only RangeTblEntry in pstate
if (rtindex != 1)
{
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("invalid value for rtindex")));
}

/*
* add all the target entries in pnsi to the current target list to pass
Expand Down Expand Up @@ -2585,6 +2591,12 @@ static Query *transform_cypher_match_pattern(cypher_parsestate *cpstate,
rte = pnsi->p_rte;
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")));
}

/*
* add all the target entries in rte to the current target list to pass
Expand Down Expand Up @@ -6775,6 +6787,12 @@ static void handle_prev_clause(cypher_parsestate *cpstate, Query *query,
if (first_rte)
{
Assert(rtindex == 1);
if (rtindex != 1)
{
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("invalid value for rtindex")));
}
}

// add all the rte's attributes to the current queries targetlist
Expand Down
57 changes: 47 additions & 10 deletions src/backend/utils/adt/agtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ static int extract_variadic_args_min(FunctionCallInfo fcinfo,
int variadic_start, bool convert_unknown,
Datum **args, Oid **types, bool **nulls,
int min_num_args);
static agtype_value* agtype_build_map_as_agtype_value(FunctionCallInfo fcinfo);
static agtype_value *agtype_build_map_as_agtype_value(FunctionCallInfo fcinfo);
agtype_value *agtype_composite_to_agtype_value_binary(agtype *a);

/* global storage of OID for agtype and _agtype */
Expand Down Expand Up @@ -2364,7 +2364,7 @@ Datum make_edge(Datum id, Datum startid, Datum endid, Datum label,
properties);
}

static agtype_value* agtype_build_map_as_agtype_value(FunctionCallInfo fcinfo)
static agtype_value *agtype_build_map_as_agtype_value(FunctionCallInfo fcinfo)
{
int nargs;
int i;
Expand All @@ -2377,7 +2377,9 @@ static agtype_value* agtype_build_map_as_agtype_value(FunctionCallInfo fcinfo)
nargs = extract_variadic_args(fcinfo, 0, true, &args, &types, &nulls);

if (nargs < 0)
PG_RETURN_NULL();
{
return NULL;
}

if (nargs % 2 != 0)
{
Expand Down Expand Up @@ -2420,7 +2422,14 @@ PG_FUNCTION_INFO_V1(agtype_build_map);
*/
Datum agtype_build_map(PG_FUNCTION_ARGS)
{
agtype_value *result= agtype_build_map_as_agtype_value(fcinfo);
agtype_value *result = NULL;

result = agtype_build_map_as_agtype_value(fcinfo);
if (result == NULL)
{
PG_RETURN_NULL();
}

PG_RETURN_POINTER(agtype_value_to_agtype(result));
}

Expand Down Expand Up @@ -2448,8 +2457,16 @@ PG_FUNCTION_INFO_V1(agtype_build_map_nonull);
*/
Datum agtype_build_map_nonull(PG_FUNCTION_ARGS)
{
agtype_value *result= agtype_build_map_as_agtype_value(fcinfo);
agtype_value *result = NULL;

result = agtype_build_map_as_agtype_value(fcinfo);
if (result == NULL)
{
PG_RETURN_NULL();
}

remove_null_from_agtype_object(result);

PG_RETURN_POINTER(agtype_value_to_agtype(result));
}

Expand Down Expand Up @@ -5446,18 +5463,26 @@ Datum age_tointeger(PG_FUNCTION_ARGS)
if (type != AGTYPEOID)
{
if (type == INT2OID)
{
result = (int64) DatumGetInt16(arg);
}
else if (type == INT4OID)
{
result = (int64) DatumGetInt32(arg);
}
else if (type == INT8OID)
{
result = (int64) DatumGetInt64(arg);
}
else if (type == FLOAT4OID)
{
float4 f = DatumGetFloat4(arg);

if (isnan(f) || isinf(f) ||
f < PG_INT64_MIN || f > PG_INT64_MAX)
f < (float4)PG_INT64_MIN || f > (float4)PG_INT64_MAX)
{
PG_RETURN_NULL();
}

result = (int64) f;
}
Expand All @@ -5466,8 +5491,10 @@ Datum age_tointeger(PG_FUNCTION_ARGS)
float8 f = DatumGetFloat8(arg);

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 @@ -5479,17 +5506,23 @@ Datum age_tointeger(PG_FUNCTION_ARGS)
numeric_float8_no_overflow, arg));

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;
}
else if (type == CSTRINGOID || type == TEXTOID)
{
if (type == CSTRINGOID)
{
string = DatumGetCString(arg);
}
else
{
string = text_to_cstring(DatumGetTextPP(arg));
}

/* convert it if it is a regular integer string */
is_valid = scanint8(string, true, &result);
Expand All @@ -5499,7 +5532,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 @@ -5508,16 +5541,20 @@ 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
{
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("toInteger() unsupported argument type %d",
type)));
}
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/backend/utils/graph_generation.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Datum create_complete_graph(PG_FUNCTION_ARGS)
int64 no_vertices;
int64 i,j,vid = 1, eid, start_vid, end_vid;

Name vtx_label_name;
Name vtx_label_name = NULL;
Name edge_label_name;
int32 vtx_label_id;
int32 edge_label_id;
Expand Down