From: Rory Campbell-Lange <rory@campbell-lange.net>
To: pgsql-general@lists.postgresql.org
Subject: "set autocommit on" in golang client query
Date: Mon, 1 Aug 2022 14:10:00 +0100
Message-ID: <YufQqOrQfuLALtMC@campbell-lange.net> (raw)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: rory@campbell-lange.net
Subject: Re: "set autocommit on" in golang client query
In-Reply-To: <YufQqOrQfuLALtMC@campbell-lange.net>
References: <YufQqOrQfuLALtMC@campbell-lange.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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