From: | "Daniel Verite" <daniel(at)manitou-mail(dot)org> |
---|---|
To: | "Bryn Llewellyn" <bryn(at)yugabyte(dot)com> |
Cc: | Christophe Pettus <xof(at)thebuild(dot)com>, David G(dot) Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>, rjuju123(at)gmail(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 21:01:13 |
Message-ID: | b1069196-5574-4192-9619-3115e4fb2ba3@manitou-mail.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Bryn Llewellyn wrote:
> 2023-02-20 12:42:44.993 PST [2540504] d0$u0(at)d0 LOG: 00000: statement:
> insert into s.t(v) values(17); insert into s.t(v) values(42);
> 2023-02-20 12:42:44.993 PST [2540504] d0$u0(at)d0 LOCATION: exec_simple_query,
> postgres.c:971
>
> It seems a bit odd that psql has no syntax to ask for this in its
> interactive mode.
Backslash-semicolon is the syntax. Quoted from the doc:
<quote>
\;
Backslash-semicolon is not a meta-command in the same way as the
preceding commands; rather, it simply causes a semicolon to be added to the
query buffer without any further processing.
Normally, psql will dispatch an SQL command to the server as soon as it
reaches the command-ending semicolon, even if more input remains on the
current line. Thus for example entering
select 1; select 2; select 3;
will result in the three SQL commands being individually sent to the
server, with each one's results being displayed before continuing to the next
command. However, a semicolon entered as \; will not trigger command
processing, so that the command before it and the one after are effectively
combined and sent to the server in one request. So for example
select 1\; select 2\; select 3;
results in sending the three SQL commands to the server in a single
request, when the non-backslashed semicolon is reached. The server executes
such a request as a single transaction, unless there are explicit
BEGIN/COMMIT commands included in the string to divide it into multiple
transactions. (See Section 55.2.2.1 for more details about how the server
handles multi-query strings.)
</quote>
Best regards,
--
Daniel Vérité
https://postgresql.verite.pro/
Twitter: @DanielVerite
From | Date | Subject | |
---|---|---|---|
Next Message | Adrian Klaver | 2023-02-20 23:24:23 | Re: pg_dump'ed file contains "DROP DATABASE" |
Previous Message | Bryn Llewellyn | 2023-02-20 20:50:28 | Re: Thanks! Re: Who adds the "start transaction" and "commit" to the intended SQL statement in "autocommit" mode? |