xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Jackson <ian.jackson@eu.citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Subject: [OSSTEST PATCH 1/9] mg-schema-test-database: Revamp sequence handling
Date: Tue, 20 Dec 2016 18:37:54 +0000	[thread overview]
Message-ID: <1482259082-30767-2-git-send-email-ian.jackson@eu.citrix.com> (raw)
In-Reply-To: <1482259082-30767-1-git-send-email-ian.jackson@eu.citrix.com>

The initial value (at creation time) of a sequence appears in the
schema, but is not of any consequence.  To avoid the schema diff check
failing in databases created in a slightly different way, it is
necessary to copy the actual original initial sequence value for each
sequence.

Replace the sequence handling code with a setup which, for each
sequence, copies the START WITH and calculates a fresh RESTART WITH.

This replaces both the unconditional copy (done with pgdump) and the
special calculation of the next flight number.  Now all sequences have
the "bump the number somewhat" treatment, which seems nice.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 mg-schema-test-database | 43 ++++++++++++++++++++++---------------------
 1 file changed, 22 insertions(+), 21 deletions(-)

diff --git a/mg-schema-test-database b/mg-schema-test-database
index 5ebba39..a82c044 100755
--- a/mg-schema-test-database
+++ b/mg-schema-test-database
@@ -413,6 +413,28 @@ END
 
 	withtest ./mg-schema-update -q apply $wantupdates
 
+        printf " (seqs)"
+        seq_alters=""
+        for seq in $sequences; do
+        	orgseqval=$(psql_query <<END
+			SELECT start_value || ' ' || last_value FROM $seq
+END
+                )
+                read orgstart orglast <<END
+$orgseqval
+END
+		newlast=$(( 10000 * (2 + $orglast / 10000) ))
+                seq_alters+="
+			ALTER SEQUENCE $seq
+				START WITH $orgstart
+				RESTART WITH $newlast;
+"
+        done
+	(withtest psql_do <<END
+$seq_alters
+END
+        )
+
 	printf ".\n"
 
 	# Schema should now be identical to main DB
@@ -444,14 +466,6 @@ END
 		SET CONSTRAINTS ALL DEFERRED;
 END
 
-	$(get_pgdump_cmd) -a -O -x ${sequences// / -t } >$t.sequences-import
-	perl <$t.sequences-import >>$t.import -ne '
-		next if m/^--/;
-		next if m/^SET /;
-		next unless m/\S/;
-		print or die $!;
-	'
-
 	for table in $tables; do
 		case " $ftables " in
 		*" $table "*)	condition="flight >= $minflight" ;;
@@ -490,19 +504,6 @@ END
 
 	rm -f $t.tabledata.*
 
-	printf "flightseq..."
-
-	lastflight=$(psql_query <<END
-		SELECT last_value FROM flights_flight_seq
-END
-		)
-	newlastflight=$(( 10000 * (2 + $lastflight / 10000) ))
-
-	withtest psql_do <<END
-		ALTER SEQUENCE flights_flight_seq
-			RESTART WITH $newlastflight;
-END
-
 	#---------- actually borrow resources ----------
 
 	printf "borrow..."
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2016-12-20 18:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-20 18:37 [OSSTEST PATCH 0/9] db retry: fixes and workarounds Ian Jackson
2016-12-20 18:37 ` Ian Jackson [this message]
2016-12-20 18:37 ` [OSSTEST PATCH 2/9] mg-schema-test-database: Wrap some withtest psql_do in subshells Ian Jackson
2016-12-20 18:37 ` [OSSTEST PATCH 3/9] cs-bisection-step: Do not acquire the repo lock Ian Jackson
2016-12-20 18:37 ` [OSSTEST PATCH 4/9] db retry, bisection: Reset %jobs_created on db retry Ian Jackson
2016-12-20 18:37 ` [OSSTEST PATCH 5/9] db retry, bisect: Cache build reuse investigations Ian Jackson
2016-12-20 18:37 ` [OSSTEST PATCH 6/9] db retry: Document $@ as an implicit parameter to need_retry Ian Jackson
2016-12-20 18:38 ` [OSSTEST PATCH 7/9] db retry: Break out Osstest::Executive::JobDB::_need_retry Ian Jackson
2016-12-20 18:38 ` [OSSTEST PATCH 8/9] db retry: Use HandleError and exceptions to detect when to retry Ian Jackson
2016-12-20 18:38 ` [OSSTEST PATCH 9/9] db retry: Retry on $dbh->state eq '' 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=1482259082-30767-2-git-send-email-ian.jackson@eu.citrix.com \
    --to=ian.jackson@eu.citrix.com \
    --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).