Skip to content

Naming CTE expression to keywords like source/target causes splitter::advance panic #476

@SichangHe

Description

@SichangHe

Edit: Not only source, but target also does not work, so I presume more keywords have this problem.

with source as (select b from c) select * from source;

Opening the above SQL file and enabling postgres_lsp in Nvim causes:

[ERROR] ...p/_transport.lua:36 "rpc" "postgrestools" "stderr" "Encountered an unexpected error\n\nThis is a bug in Postgres Tools, not an error in your code, and we would appreciate it if you could report it along with the following information to help us fixing the issue:\n\nSource Location: crates/pgt_statement_splitter/src/splitter.rs:115:14\nThread Name: tokio-runtime-worker\nMessage: lexed should have non-trivia eof token\n\n"

And, the language server does not display any diagnostics like relation 'c' does not exist, probably because it stops analyzing the file after the thread panicked.

Renaming source to d resolves this issue, so the error is misleading.

Suggestion

Handle the error in advance and tell people not to use certain words as CTE names in the error message.


I think this should be enough information. If not, please feel free to ask.

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