Skip to content

left() function fails to handle large negative integers correctly #2205

@Phasheng

Description

@Phasheng

Describe the bug
I discovered that left() function incorrectly processes large negative integers below INT_MIN instead of throwing error.

How are you accessing AGE (Command line, driver, etc.)?

  • Command line

What is the command that caused the error?
When a negative integer bigger than INT_MIN is used as the length of left() function, an error will be caused:

SELECT * FROM cypher('test_graph', $$
RETURN LEFT('abcdef', -2147483648) AS ref0
$$) AS (ref0 agtype);
ERROR:  left() negative values are not supported for length

However, when executing query with large negative integer below -2147483648, the original text will be returned:

SELECT * FROM cypher('test_graph', $$
RETURN LEFT('abcdef', -2147483649) AS ref0, -2147483649 < 0 as ref1
$$) AS (ref0 agtype, ref1 agtype);
   ref0   | ref1 
----------+------
 "abcdef" | true

Expected behavior
Both queries above should fail with an error.

Environment:

  • Latest in Docker hub

Additional context
I also found this bug in neo4j. Here is the link: neo4j/neo4j#13671

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions