pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feed"set autocommit on" in golang client query
2+ messages / 2 participants
[nested] [flat]
* "set autocommit on" in golang client query
@ 2022-08-01 13:10 Rory Campbell-Lange <rory@campbell-lange.net>
0 siblings, 1 reply; 2+ messages in thread
From: Rory Campbell-Lange @ 2022-08-01 13:10 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Apologies for the rather naive question.
I have a psql migration script to call a looping procedure which commits
batches of data along the following lines:
set search_path = a, b c;
\set AUTOCOMMIT on
-- call procedure with nested transactions
CALL c.pr_my_procedure(debug=>true);
I'm trying to migrate this to a programme using the golang pgx module to exec
this code on a large number of databases in parallel. There doesn't seem an
obvious way of setting autocommit outside of psql, so the equivalent of
conn.Exec(context.Background(),
"set search_path = a, b c; set AUTOCOMMIT on; CALL c.pr_my_procedure(debug=>true);")
fails with
ERROR: syntax error at or near "ON"
while
conn.Exec(context.Background(),
"set search_path = a, b c; CALL c.pr_my_procedure(debug=>true);")
fails with
ERROR: invalid transaction termination
How should I set autocommit on? The "Create Procedure" docs at
https://www.postgresql.org/docs/current/sql-createprocedure.html don't seem to
mention autocommit.
Rory
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: "set autocommit on" in golang client query
@ 2022-08-01 13:18 Guillaume Lelarge <guillaume@lelarge.info>
parent: Rory Campbell-Lange <rory@campbell-lange.net>
0 siblings, 0 replies; 2+ messages in thread
From: Guillaume Lelarge @ 2022-08-01 13:18 UTC (permalink / raw)
To: Rory Campbell-Lange <rory@campbell-lange.net>; +Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Hi,
Le lun. 1 août 2022 à 15:10, Rory Campbell-Lange <rory@campbell-lange.net>
a écrit :
> Apologies for the rather naive question.
>
> I have a psql migration script to call a looping procedure which commits
> batches of data along the following lines:
>
> set search_path = a, b c;
> \set AUTOCOMMIT on
> -- call procedure with nested transactions
> CALL c.pr_my_procedure(debug=>true);
>
> I'm trying to migrate this to a programme using the golang pgx module to
> exec
> this code on a large number of databases in parallel. There doesn't seem an
> obvious way of setting autocommit outside of psql, so the equivalent of
>
> conn.Exec(context.Background(),
> "set search_path = a, b c; set AUTOCOMMIT on; CALL
> c.pr_my_procedure(debug=>true);")
>
> fails with
>
> ERROR: syntax error at or near "ON"
>
> while
>
> conn.Exec(context.Background(),
> "set search_path = a, b c; CALL
> c.pr_my_procedure(debug=>true);")
>
> fails with
>
> ERROR: invalid transaction termination
>
> How should I set autocommit on? The "Create Procedure" docs at
> https://www.postgresql.org/docs/current/sql-createprocedure.html don't
> seem to
> mention autocommit.
>
>
That's because it doesn't exist on the PostgreSQL server. You can use it
with psql but that's a psql feature, not the server's.
--
Guillaume.
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2022-08-01 13:18 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-08-01 13:10 "set autocommit on" in golang client query Rory Campbell-Lange <rory@campbell-lange.net>
2022-08-01 13:18 ` Guillaume Lelarge <guillaume@lelarge.info>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox