Обсуждение: PGAdmin Auto-commits?

Поиск
Список
Период
Сортировка

PGAdmin Auto-commits?

От
"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?
 
Thanks,
Ryan
 

Re: PGAdmin Auto-commits?

От
"Dave Page"
Дата:
On Thu, Oct 2, 2008 at 1:58 PM, Ryan Daniels <ryan.daniels@gmail.com> wrote:
>
> 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


Re: PGAdmin Auto-commits?

От
"Dave Page"
Дата:
On Thu, Oct 2, 2008 at 2:12 PM, Michael Shapiro <mshapiro51@gmail.com> wrote:
> 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