Discussion:
PGAdmin Auto-commits?
Ryan Daniels
2008-10-02 12:58:47 UTC
Permalink
When I run insert statements from the SQL window, the data seems to be
commited automatically. Is this the case? I looked through the buttons and
menu options of the window, but did not find any choices for commit and
rollback. Is there an option somewhere that turns off auto-commit?

If it is the case that auto-commit occurs, and there are no toolbar buttons
to do this, can commit and rollback buttons be added in an upcomming
version?

Thanks,
Ryan
Dave Page
2008-10-02 13:04:34 UTC
Permalink
Post by Ryan Daniels
When I run insert statements from the SQL window, the data seems to be
commited automatically. Is this the case? I looked through the buttons and
menu options of the window, but did not find any choices for commit and
rollback. Is there an option somewhere that turns off auto-commit?
If it is the case that auto-commit occurs, and there are no toolbar buttons
to do this, can commit and rollback buttons be added in an upcomming
version?
It follows the normal PostgreSQL behaviour. If you don't want to
commit immediately, issue a BEGIN first.
--
Dave Page
EnterpriseDB UK: http://www.enterprisedb.com
--
Sent via pgadmin-support mailing list (pgadmin-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-support
Dave Page
2008-10-02 13:33:59 UTC
Permalink
Does the SQL window explicitly start a transaction so that all the stmts in
it are committed (or rolled back) if one of the fails?
Or does each stmt execute in its own transaction? Or does it just submit the
entire text as a single query and let Postgres decide how to wrap it in a
transaction?
The latter.
This is really a question of how PgAmin executes the queries in a given
window.
As for how Postgres handles multiple stmts, this list (or you) may not be
the place for that question, but I don't think BEGIN/END does anyting
explicitly wrt to transactions, other than perhaps treat the stmts between
BEGIN/END as a single stmt, but I'm really not sure of this.
If a connection has an explicitly opened transaction on it, no further
statements (multi statement queries or single) will be committed
unless a commit is executed. If no transaction is started by the user,
each query (multi or single statement) will commit immediated.

So:

UPDATE foo SET a = b;
<F5>

will commit immediately.

BEGIN;
UPDATE foo SET a = b;
<F5>

will not commit until you do:

COMMIT;
<F5>
--
Dave Page
EnterpriseDB UK: http://www.enterprisedb.com
--
Sent via pgadmin-support mailing list (pgadmin-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-support
Loading...