Skip to content

Parser hangs on certain input - some signed literals, some parentheticals #36

Description

@jessestimpson

Hi, thanks for the library. I've been making continued use of it in my FDB SQL layer, and it's great.

We've found a couple inputs that cause the parser to hang.

Version: commit da69080 (current main), Elixir 1.19.4, OTP 28

sql = "select id from t where a = -5"
{:ok, ctx, tokens} = SQL.Lexer.lex(sql)
task = Task.async(fn -> SQL.Parser.parse(tokens, ctx) end)
Task.yield(task, 5_000) || Task.shutdown(task, :brutal_kill)
#=> nil  (parse never completes)

These examples all display the hang:

select id from t where a = -5
select id from t where a > -5
select id from t where a = +5
select id from t where a = 1 and (b > 2)
select id from t where a = 1 or (b > 2)
select id from t where a = 1 for update

Comparatively, these examples parse fine, no issues:

select id from t where a in (-1, 2)
select id from t where (a > 1 or b < 0)
select -1

For the record, I don't have any use case for for update but found that it also hangs, so provided here for completeness.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions