Skip to content

feat: show the result of executed statements in a panel - #79

Open
psteinroe wants to merge 1 commit into
mainfrom
feat/render-statement-results
Open

psteinroe wants to merge 1 commit into
mainfrom
feat/render-statement-results

Conversation

@psteinroe

@psteinroe psteinroe commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Since supabase-community/postgres-language-server#879, pgls.executeStatement returns the result of the statement instead of null: the columns and up to 100 rows (values in their Postgres text form, null for SQL NULL), a truncated flag, rowsAffected for statements that return no rows, and, since supabase-community/postgres-language-server#903, the Postgres error with SQLSTATE, detail, hint and its position in the document. The extension ignored that value, so the only feedback was the server's one-line showMessage.

This adds a Statement Result webview beside the editor. A middleware on workspace/executeCommand lets every command through unchanged and, for pgls.executeStatement, renders what the server returned:

  • the SQL of the executed statement (taken from the command's first argument) and how long the request took,
  • for a query, the rows as a table with a row number column, NULL shown as NULL, and a note when the result was truncated,
  • for any other statement, the server's summary with the affected row count,
  • for a Postgres error, the message, SQLSTATE, detail and hint. The position is a link that selects it in the document,
  • if the request itself fails (e.g. invalid arguments or no connection), the error message.

The panel is created on the first execution and reused, and it doesn't take focus. It runs one small script, behind a nonce-based CSP, that only posts the "reveal" message for the error link. Older servers return null, which is ignored, so nothing changes for them. truncatedValues, which the guard in supabase-community/postgres-language-server#920 adds, is shown as a note when present. The notices that the server collects with that change end up in the summary message, so they show up without extra handling.

The README gets a section on executing statements.

How I tested it: npm run compile, npm run lint and npm run package pass. I ran the extension in VS Code 1.140 (under Xvfb) against a server built from main and a local Postgres, with a script in the extension host that runs the "Execute Statement" code action:

  • select ... from generate_series(1, 150) shows 100 rows, the NULLs and the truncation note,
  • select 'ä' as a, missing_column from pg_class on line 4 shows 42703 at "Line 4, column 18", and clicking the link puts the cursor there,
  • create temp table ... shows "Rows affected: 0",
  • pgls.executeStatement without arguments shows the InvalidParams message from the server.

The server returns the rows, the affected row count, or the Postgres error
of pgls.executeStatement. A middleware on workspace/executeCommand renders
it in a webview beside the editor, including truncation and a link to the
error position in the document.
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