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
101 changes: 101 additions & 0 deletions regress/expected/agtype.out
Original file line number Diff line number Diff line change
Expand Up @@ -3776,9 +3776,110 @@ SELECT agtype_build_map('1', '1', 2, 2, 3.14, 3.14, 'e', 2.71);
{"1": "1", "2": 2, "e": 2.71::numeric, "3.14": 3.14::numeric}
(1 row)

--
-- Bug found from issue 2043 - Regression in string concatenation using the + operator
--
-- This bug impacted specific numeric cases too.
--
SELECT * FROM create_graph('issue_2243');
NOTICE: graph "issue_2243" has been created
create_graph
--------------

(1 row)

SELECT * FROM cypher('issue_2243', $$
CREATE (n30164502:Node {data_id: 30164502})
RETURN id(n30164502) + ':test_n' + n30164502.data_id
$$ ) as (result agtype);
result
----------------------------------
"844424930131969:test_n30164502"
(1 row)

-- concat / add
SELECT * FROM cypher('issue_2243', $$
RETURN 9223372036854775807::integer + ":test_n" + 9223372036854775807::integer
$$ ) as (result agtype);
result
-------------------------------------------------
"9223372036854775807:test_n9223372036854775807"
(1 row)

SELECT * FROM cypher('issue_2243', $$
RETURN 9223372036854775807::numeric + 9223372036854775807::integer
$$ ) as (result agtype);
result
-------------------------------
18446744073709551614::numeric
(1 row)

-- sub
SELECT * FROM cypher('issue_2243', $$
RETURN 9223372036854775807::numeric - 9223372036854775807::integer
$$ ) as (result agtype);
result
------------
0::numeric
(1 row)

-- mul
SELECT * FROM cypher('issue_2243', $$
RETURN 9223372036854775807::numeric * 9223372036854775807::integer
$$ ) as (result agtype);
result
-------------------------------------------------
85070591730234615847396907784232501249::numeric
(1 row)

-- div
SELECT * FROM cypher('issue_2243', $$
RETURN 9223372036854775807::numeric / 9223372036854775807::integer
$$ ) as (result agtype);
result
---------------------------------
1.00000000000000000000::numeric
(1 row)

SELECT * FROM cypher('issue_2243', $$
RETURN 9223372036854775807::integer / 9223372036854775807::numeric
$$ ) as (result agtype);
result
---------------------------------
1.00000000000000000000::numeric
(1 row)

-- mod
SELECT * FROM cypher('issue_2243', $$
RETURN 9223372036854775807::numeric % 9223372036854775807::integer
$$ ) as (result agtype);
result
------------
0::numeric
(1 row)

SELECT * FROM cypher('issue_2243', $$
RETURN 9223372036854775807::integer % 9223372036854775807::numeric
$$ ) as (result agtype);
result
------------
0::numeric
(1 row)

--
-- Cleanup
--
SELECT drop_graph('issue_2243', true);
NOTICE: drop cascades to 3 other objects
DETAIL: drop cascades to table issue_2243._ag_label_vertex
drop cascades to table issue_2243._ag_label_edge
drop cascades to table issue_2243."Node"
NOTICE: graph "issue_2243" has been dropped
drop_graph
------------

(1 row)

SELECT drop_graph('agtype_build_map', true);
NOTICE: drop cascades to 2 other objects
DETAIL: drop cascades to table agtype_build_map._ag_label_vertex
Expand Down
47 changes: 47 additions & 0 deletions regress/sql/agtype.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1075,9 +1075,56 @@ SELECT * FROM cypher('agtype_build_map', $$ RETURN ag_catalog.agtype_build_map('
$$) AS (results agtype);
SELECT agtype_build_map('1', '1', 2, 2, 3.14, 3.14, 'e', 2.71);

--
-- Bug found from issue 2043 - Regression in string concatenation using the + operator
--
-- This bug impacted specific numeric cases too.
--
SELECT * FROM create_graph('issue_2243');
SELECT * FROM cypher('issue_2243', $$
CREATE (n30164502:Node {data_id: 30164502})
RETURN id(n30164502) + ':test_n' + n30164502.data_id
$$ ) as (result agtype);

-- concat / add
SELECT * FROM cypher('issue_2243', $$
RETURN 9223372036854775807::integer + ":test_n" + 9223372036854775807::integer
$$ ) as (result agtype);

SELECT * FROM cypher('issue_2243', $$
RETURN 9223372036854775807::numeric + 9223372036854775807::integer
$$ ) as (result agtype);

-- sub
SELECT * FROM cypher('issue_2243', $$
RETURN 9223372036854775807::numeric - 9223372036854775807::integer
$$ ) as (result agtype);

-- mul
SELECT * FROM cypher('issue_2243', $$
RETURN 9223372036854775807::numeric * 9223372036854775807::integer
$$ ) as (result agtype);

-- div
SELECT * FROM cypher('issue_2243', $$
RETURN 9223372036854775807::numeric / 9223372036854775807::integer
$$ ) as (result agtype);
SELECT * FROM cypher('issue_2243', $$
RETURN 9223372036854775807::integer / 9223372036854775807::numeric
$$ ) as (result agtype);

-- mod
SELECT * FROM cypher('issue_2243', $$
RETURN 9223372036854775807::numeric % 9223372036854775807::integer
$$ ) as (result agtype);
SELECT * FROM cypher('issue_2243', $$
RETURN 9223372036854775807::integer % 9223372036854775807::numeric
$$ ) as (result agtype);

--
-- Cleanup
--
SELECT drop_graph('issue_2243', true);
SELECT drop_graph('agtype_build_map', true);

DROP TABLE agtype_table;
Expand Down
4 changes: 2 additions & 2 deletions src/backend/utils/adt/agtype_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static char *get_string_from_agtype_value(agtype_value *agtv, int *length)
{
case AGTV_INTEGER:
number = DirectFunctionCall1(int8out,
Int8GetDatum(agtv->val.int_value));
Int64GetDatum(agtv->val.int_value));
string = DatumGetCString(number);
*length = strlen(string);
return string;
Expand Down Expand Up @@ -115,7 +115,7 @@ Datum get_numeric_datum_from_agtype_value(agtype_value *agtv)
{
case AGTV_INTEGER:
return DirectFunctionCall1(int8_numeric,
Int8GetDatum(agtv->val.int_value));
Int64GetDatum(agtv->val.int_value));
case AGTV_FLOAT:
return DirectFunctionCall1(float8_numeric,
Float8GetDatum(agtv->val.float_value));
Expand Down