From: Ian Jackson <iwj@xenproject.org>
To: xen-devel@lists.xenproject.org
Cc: Ian Jackson <iwj@xenproject.org>
Subject: [OSSTEST PATCH 1/7] mg-schema-test-database: posgtres compat: psql transactions
Date: Tue, 27 Apr 2021 19:00:27 +0100 [thread overview]
Message-ID: <20210427180033.9439-2-iwj@xenproject.org> (raw)
In-Reply-To: <20210427180033.9439-1-iwj@xenproject.org>
Now (postgresql 11):
* psql transaction behaviour has changed so that now we want to
use the -1 option. This obviates a few BEGIN and COMMITs.
* SET implicitly starts a transaction and DROP and CREATE DATABASE
aren't transactional and now complain if they are run in a
transaction. So we must add COMMIT after SET.
Signed-off-by: Ian Jackson <iwj@xenproject.org>
---
mg-schema-create | 2 +-
mg-schema-test-database | 12 +++++-------
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/mg-schema-create b/mg-schema-create
index 9bb3040a..3a344db4 100755
--- a/mg-schema-create
+++ b/mg-schema-create
@@ -89,7 +89,7 @@ fi
$progress "Populating database..."
-$(get_psql_cmd) $quietopt -f schema/initial.sql
+$(get_psql_cmd) $quietopt -1 -f schema/initial.sql
if $do_updates; then
./mg-schema-update $quietopt apply-all "${updates[@]}"
diff --git a/mg-schema-test-database b/mg-schema-test-database
index dab536c5..e69b9881 100755
--- a/mg-schema-test-database
+++ b/mg-schema-test-database
@@ -132,7 +132,7 @@ psql_query () {
}
psql_do_cmd () {
- echo "$(get_psql_cmd) ${OSSTEST_DEBUG:+-e -a}"
+ echo "$(get_psql_cmd) ${OSSTEST_DEBUG:+-e -a}" -1
}
psql_do () {
@@ -411,7 +411,9 @@ END
#---------- create test db ----------
psql_do <<END
+ COMMIT;
CREATE DATABASE $dbname;
+ BEGIN;
END
withtest ./mg-schema-create -q --no-updates
@@ -449,12 +451,10 @@ END
for task in $tasks; do
psql_do <<END
- BEGIN;
$(make_xdbref_task $dbname 'borrowed for test db' \
$task "$username@$nodename")
UPDATE resources SET owntaskid = $(borrowtaskid $task)
WHERE owntaskid=$task;
- COMMIT;
END
done
@@ -466,7 +466,6 @@ END
cat >>$t.import <<END
\o $t.import-output
- BEGIN;
SET CONSTRAINTS ALL DEFERRED;
END
@@ -500,7 +499,6 @@ END
WHERE owntaskid != $(borrowtaskid $task)
AND owntaskid != $(taskid magic shared)
AND owntaskid != $(taskid magic preparing);
- COMMIT;
END
printf "Copy..."
@@ -519,11 +517,9 @@ END
for task in $tasks; do
(withtest psql_do <<END
- BEGIN;
UPDATE resources
SET owntaskid = $(taskid magic idle)
WHERE owntaskid = $(borrowtaskid $task);
- COMMIT;
END
)
done
@@ -551,7 +547,9 @@ drop)
psql_do <<END
SET client_min_messages = WARNING;
+ COMMIT;
DROP DATABASE IF EXISTS $dbname;
+ BEGIN;
UPDATE resources
SET owntaskid = CAST(tasks.refinfo AS INTEGER)
FROM tasks
--
2.20.1
next prev parent reply other threads:[~2021-04-27 18:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-27 18:00 [OSSTEST PATCH 0/7] Fixes for postgresql etc. upgrade Ian Jackson
2021-04-27 18:00 ` Ian Jackson [this message]
2021-04-27 18:00 ` [OSSTEST PATCH 2/7] mg-schema-test-database: Be slightly more defensive Ian Jackson
2021-04-27 18:00 ` [OSSTEST PATCH 3/7] mg-schema-test-database: posgtres compat: Cope with schema name Ian Jackson
2021-04-27 18:00 ` [OSSTEST PATCH 4/7] mg-schema-test-database: GetOpt compat: work around arg bundling bug Ian Jackson
2021-04-27 18:00 ` [OSSTEST PATCH 5/7] mg-schema-test-database: posgtres compat: Sequences Ian Jackson
2021-04-27 18:00 ` [OSSTEST PATCH 6/7] mg-schema-test-database: Fix following host_lifecycle Ian Jackson
2021-04-27 18:00 ` [OSSTEST PATCH 7/7] mg-schema-test-database: posgtres compat: tidy messages Ian Jackson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210427180033.9439-2-iwj@xenproject.org \
--to=iwj@xenproject.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).