Repository navigation
Conversation
…odies by token Function bodies written as escape strings are unescaped like Postgres' lexer does, with a map of where each escape is, so their statements get tokens, hover, hints and diagnostics at the right place. The offset map now handles escapes of any length. The PL/pgSQL syntax check found the body with a substring search, which failed for bodies with doubled quotes (skipping the check) and could match an earlier occurrence. It now uses the string constant after AS, and reports on the whole statement if the body can't be found.
This was referenced Oct 24, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #918.
Two cases #918 left out: function bodies written as escape strings, and the PL/pgSQL body range, which still used
content.find.What changed
StatementOffsets(pgls_analyser) maps escapes of any length instead of only'': each escape records the bytes it stands for in the statement and its bytes in the document. Offsets inside an escape map to its start in both directions.sql_function::string_bodyunescapes'...'andE'...'constants afterAS, following thexerules of Postgres' lexer (scan.l#L262at REL_18_6):\b \f \n \r \t \v, octal,\xhex,\u/\U,'', and\before any other character. A value that isn't valid UTF-8 (e.g.\xff), a\uwithout four digits, a surrogate pair, or a constant continued on a new line is not matched, and the body gets no statements like before.U&'...'bodies are still not supported.PgQueryStore::get_or_cache_plpgsql_parseusesstring_bodyfor the range of PL/pgSQL syntax errors. If the body can't be located, the error now covers the whole statement instead of the check being skipped.Tests
unescapeunit tests: every escape kind, multi-byte UTF-8 from\xpairs, and the cases that aren't matched.StatementOffsets: an escape that is longer than the bytes it stands for.sql_function: anE'...'body with'',\',\\,\nandé, mapped back to the document.pg_query: PL/pgSQL syntax error spans for a body with''and for a body whose text also appears earlier, in a parameter default.unknownColumndiagnostic in anE'...'body.Not covered
U&'...'bodies; PL/pgSQL bodies still get no editor features (only the syntax check).