Skip to content

fix(plpgsql): locate syntax errors with plpgsql_check instead of flagging the whole body - #862

Merged
psteinroe merged 1 commit into
mainfrom
fix/plpgsql-syntax-with-check
Oct 18, 2026
Merged

psteinroe merged 1 commit into
mainfrom
fix/plpgsql-syntax-with-check

Conversation

@psteinroe

Copy link
Copy Markdown
Collaborator

With plpgsql_check installed, editing a PL/pgSQL function no longer underlines the entire function body.

Located compile errors

Errors that stop the function from compiling, like a misspelled DECLARE, a missing END IF or an unknown variable, come from plpgsql_check without a statement. They only have the body and a character position, so we fell back to the whole body. They now point at the token at that position, or at the delimiter in syntax error at or near ";". Errors at end of input still span the body.

Whole-body libpg_query error

libpg_query's PL/pgSQL syntax error has no usable location: cursorpos is always 0, and its "near line N" is the last parsed statement, not the error. It is now dropped for every function that plpgsql_check actually checked. It is still reported when plpgsql_check can't check the function: no database, extension missing or disabled, the function fails to create, or no trigger uses a trigger function.

#860 (draft) also touches database_diagnostics; whichever merges second needs a small rebase.

Refs #179

@psteinroe
psteinroe force-pushed the fix/plpgsql-syntax-with-check branch from 86a7ff6 to ec163ef Compare October 18, 2026 17:57
@psteinroe
psteinroe merged commit 2658b41 into main Oct 18, 2026
9 checks passed
@psteinroe
psteinroe deleted the fix/plpgsql-syntax-with-check branch October 18, 2026 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant