Re: Thanks! Re: Who adds the "start transaction" and "commit" to the intended SQL statement in "autocommit" mode?

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Bryn Llewellyn <bryn(at)yugabyte(dot)com>
Cc: rjuju123(at)gmail(dot)com, xof(at)thebuild(dot)com, pgsql-general list <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Thanks! Re: Who adds the "start transaction" and "commit" to the intended SQL statement in "autocommit" mode?
Date: 2023-02-20 20:10:42
Message-ID: CAKFQuwYKYk5E=LBjhxmWBwAZSFuJsZyoLLyf0catEySdQHghJg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Feb 20, 2023 at 12:57 PM Bryn Llewellyn <bryn(at)yugabyte(dot)com> wrote:

> 3. Chapter 55 also has a section "Multiple Statements In A Simple Query".
> But this feature seems to do no more semantically beyond implicitly
> achieving what I could do by surrounding several statements explicitly with
> "begin; ... commit;". There is, though, the non-semantic aspect of
> round-trip reduction. It seems that psql doesn't expose doing many
> statements in a simple query. (At least, that's what I see in the server
> log when I put several statements on a single line (with psql's autocommit
> on).
>

IIRC psql -c 'insert into tbl values (1); select * from tbl;' uses the
simply query protocol with multiple statements.

Then, 55.2.2.1:

> When a simple Query message contains more than one SQL statement
(separated by semicolons), those statements are executed as a single
transaction

So in effect bundling within the Simple Query Protocol has a similar effect
to wrapping all statements in a begin/commit pair.

David J.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Marc Millas 2023-02-20 20:36:53 Re: pg_reload_conf()
Previous Message Christophe Pettus 2023-02-20 20:05:21 Re: Thanks! Re: Who adds the "start transaction" and "commit" to the intended SQL statement in "autocommit" mode?