microsoft / microsoft/vscode-pgsql

Disable autocommit

Open
#21 4 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
No language data
Stars
395
Forks
33
Avg merge
1h 46m
Merged PRs (30d)
3

Description

Dear devs,

I like the new Postgres extension much better in general, but there's still an issue that makes me hesitant to actually use it in production: there's no apparent way to disable autocommit.

When in read-write mode, I often want to run a destructive query, check how many rows were modified, maybe sanity-check by running another select and verifying that the table contents look good, and only then issue commit. However, vscode-pgsql commits everything immediately, so when the table contents look bad in that select, it's already too late.

One other scenario where disabling autocommit is necessary is when developing a long migration or routine. When I run a 2000-line SQL file and there's an error on line 1100, I want to be able to fix the error and run the migration again. However, vscode-pgsql will have already committed everything up to line 1100, potentially leaving the database in a broken and inconsistent state, and also preventing the migration from being re-run, as obviously not all operations are idempotent. Sometimes, this can be worked around by just selecting everything from line 1100 downward and running that as a command selectively, but if line 1100 is actually correct, and the error is e.g. an aftereffect of something that was subtly wrong in line 500, there's no way to fix that now, because line 500 has already been committed!

Autocommit is certainly fine as a default, as it is what many people expect. (It also prevents a simple select * from foo from keeping row locks forever and hanging other sessions, which is important when connected to shared databases.) However, manual transaction management is vital for anything more complicated than a one-off query against a dev database.

For the meantime, I'll keep using other tools to develop and debug SQL. It would be lovely though to be able to finally ditch them and do all development from within VSCode!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files, tests, or entry points are named in the issue. Start by locating the extension's PostgreSQL command execution and transaction-handling paths, then trace how autocommit is applied. Done means users can choose manual transaction management, inspect results, and commit only when ready without breaking the existing default behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql
Domain
databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.