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