diff mbox series

[OSSTEST,5/7] mg-schema-test-database: posgtres compat: Sequences

Message ID 20210427180033.9439-6-iwj@xenproject.org (mailing list archive)
State New, archived
Headers show
Series Fixes for postgresql etc. upgrade | expand

Commit Message

Ian Jackson April 27, 2021, 6 p.m. UTC
Now (postgresql 11) start_value is in a different table.  We don't
really care about it very much and mostly care about the last value,
so we fix that (and launder the for-db comparison dumps).

Signed-off-by: Ian Jackson <iwj@xenproject.org>
---
 mg-schema-test-database | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/mg-schema-test-database b/mg-schema-test-database
index 26e35c5b..eab0746e 100755
--- a/mg-schema-test-database
+++ b/mg-schema-test-database
@@ -425,16 +425,16 @@  END
         seq_alters=""
         for seq in $sequences; do
         	orgseqval=$(psql_query <<END
-			SELECT start_value || ' ' || last_value FROM $seq
+			SELECT s.last_value FROM $seq s
 END
                 )
-                read orgstart orglast <<END
+                read orglast <<END
 $orgseqval
 END
 		newlast=$(( 10000 * (2 + $orglast / 10000) ))
                 seq_alters+="
 			ALTER SEQUENCE $seq
-				START WITH $orgstart
+				START WITH $newlast
 				RESTART WITH $newlast;
 "
         done
@@ -447,7 +447,15 @@  END
 
 	# Schema should now be identical to main DB
 	$(withtest get_pgdump_cmd) -s -O -x >$t.schema.created
-	diff -u $t.schema.orig $t.schema.created
+
+	for wh in orig created; do
+		perl -pe '
+			next unless m{^CREATE SEQUENCE }..m{^\)};
+			$_ = "" if m/^\s*START WITH \d+$/;
+		' <$t.schema.$wh >$t.schema.$wh-laund
+	done
+
+	diff -u $t.schema.orig-laund $t.schema.created-laund
 
 	#---------- mark resources that we are going to borrow ----------