Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PG15] Changed duplicated IF-STATEMENT INT4OID to INT2OID #1184

Merged
merged 1 commit into from
Aug 23, 2023
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
24 changes: 24 additions & 0 deletions regress/expected/agtype.out
Original file line number Diff line number Diff line change
Expand Up @@ -3192,6 +3192,30 @@ SELECT agtype_btree_cmp(
-1
(1 row)

--Int2 to Agtype in agtype_volatile_wrapper
SELECT ag_catalog.agtype_volatile_wrapper(1::int2);
agtype_volatile_wrapper
-------------------------
1
(1 row)

SELECT ag_catalog.agtype_volatile_wrapper(32767::int2);
agtype_volatile_wrapper
-------------------------
32767
(1 row)

SELECT ag_catalog.agtype_volatile_wrapper(-32767::int2);
agtype_volatile_wrapper
-------------------------
-32767
(1 row)

-- These should fail
SELECT ag_catalog.agtype_volatile_wrapper(32768::int2);
ERROR: smallint out of range
SELECT ag_catalog.agtype_volatile_wrapper(-32768::int2);
ERROR: smallint out of range
--
-- Cleanup
--
Expand Down
9 changes: 9 additions & 0 deletions regress/sql/agtype.sql
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,15 @@ SELECT agtype_btree_cmp(
'[{"id":1, "label":"test", "properties":{"id":100}}::vertex,
{"id":2, "start_id":1, "end_id": 3, "label":"elabel", "properties":{}}::edge,
{"id":4, "label":"vlabel", "properties":{}}::vertex]::path'::agtype);

--Int2 to Agtype in agtype_volatile_wrapper
SELECT ag_catalog.agtype_volatile_wrapper(1::int2);
SELECT ag_catalog.agtype_volatile_wrapper(32767::int2);
SELECT ag_catalog.agtype_volatile_wrapper(-32767::int2);

-- These should fail
SELECT ag_catalog.agtype_volatile_wrapper(32768::int2);
SELECT ag_catalog.agtype_volatile_wrapper(-32768::int2);
--
-- Cleanup
--
Expand Down
2 changes: 1 addition & 1 deletion src/backend/utils/adt/agtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -10784,7 +10784,7 @@ Datum agtype_volatile_wrapper(PG_FUNCTION_ARGS)
{
agtv_result.val.int_value = (int64) DatumGetInt32(arg);
}
else if (type == INT4OID)
else if (type == INT2OID)
{
agtv_result.val.int_value = (int64) DatumGetInt16(arg);
}
Expand Down