We maintain a separate test output file sequence_1.out because the
log_cnt value can vary if there is a checkpoint happening at the right
time. So we have to maintain two files because of a one character
difference. I propose the attached patch to restructure the test a bit
to avoid this, without loss of test coverage.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
>From 3d28ea1b6684fb00591526a79dfaeafbff459a44 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut
Date: Tue, 24 Jan 2017 09:44:40 -0500
Subject: [PATCH] Simplify sequence test
We maintained two separate expected files because log_cnt could be one
of two values. Rewrite the test so that we only need one file.
---
src/test/regress/expected/sequence.out | 10 +-
src/test/regress/expected/sequence_1.out | 559 ---
src/test/regress/sql/sequence.sql| 4 +-
3 files changed, 9 insertions(+), 564 deletions(-)
delete mode 100644 src/test/regress/expected/sequence_1.out
diff --git a/src/test/regress/expected/sequence.out b/src/test/regress/expected/sequence.out
index a2bdd3002b..ad03a31a4e 100644
--- a/src/test/regress/expected/sequence.out
+++ b/src/test/regress/expected/sequence.out
@@ -190,10 +190,12 @@ SELECT nextval('foo_seq_new');
2
(1 row)
-SELECT * FROM foo_seq_new;
- last_value | log_cnt | is_called
-+-+---
- 2 | 31 | t
+-- log_cnt can be higher if there is a checkpoint just at the right
+-- time, so just test for the expected range
+SELECT last_value, log_cnt IN (31, 32) AS log_cnt_ok, is_called FROM foo_seq_new;
+ last_value | log_cnt_ok | is_called
+++---
+ 2 | t | t
(1 row)
DROP SEQUENCE foo_seq_new;
diff --git a/src/test/regress/expected/sequence_1.out b/src/test/regress/expected/sequence_1.out
deleted file mode 100644
index 5d7ab72944..00
--- a/src/test/regress/expected/sequence_1.out
+++ /dev/null
@@ -1,559 +0,0 @@
test creation of SERIAL column
-CREATE TABLE serialTest (f1 text, f2 serial);
-INSERT INTO serialTest VALUES ('foo');
-INSERT INTO serialTest VALUES ('bar');
-INSERT INTO serialTest VALUES ('force', 100);
-INSERT INTO serialTest VALUES ('wrong', NULL);
-ERROR: null value in column "f2" violates not-null constraint
-DETAIL: Failing row contains (wrong, null).
-SELECT * FROM serialTest;
- f1 | f2
+-
- foo | 1
- bar | 2
- force | 100
-(3 rows)
-
--- test smallserial / bigserial
-CREATE TABLE serialTest2 (f1 text, f2 serial, f3 smallserial, f4 serial2,
- f5 bigserial, f6 serial8);
-INSERT INTO serialTest2 (f1)
- VALUES ('test_defaults');
-INSERT INTO serialTest2 (f1, f2, f3, f4, f5, f6)
- VALUES ('test_max_vals', 2147483647, 32767, 32767, 9223372036854775807,
- 9223372036854775807),
- ('test_min_vals', -2147483648, -32768, -32768, -9223372036854775808,
- -9223372036854775808);
--- All these INSERTs should fail:
-INSERT INTO serialTest2 (f1, f3)
- VALUES ('bogus', -32769);
-ERROR: smallint out of range
-INSERT INTO serialTest2 (f1, f4)
- VALUES ('bogus', -32769);
-ERROR: smallint out of range
-INSERT INTO serialTest2 (f1, f3)
- VALUES ('bogus', 32768);
-ERROR: smallint out of range
-INSERT INTO serialTest2 (f1, f4)
- VALUES ('bogus', 32768);
-ERROR: smallint out of range
-INSERT INTO serialTest2 (f1, f5)
- VALUES ('bogus', -9223372036854775809);
-ERROR: bigint out of range
-INSERT INTO serialTest2 (f1, f6)
- VALUES ('bogus', -9223372036854775809);
-ERROR: bigint out of range
-INSERT INTO serialTest2 (f1, f5)
- VALUES ('bogus', 9223372036854775808);
-ERROR: bigint out of range
-INSERT INTO serialTest2 (f1, f6)
- VALUES ('bogus', 9223372036854775808);
-ERROR: bigint out of range
-SELECT * FROM serialTest2 ORDER BY f2 ASC;
- f1 | f2 | f3 | f4 | f5 | f6
+-+++--+--
- test_min_vals | -2147483648 | -32768 | -32768 | -9223372036854775808 | -9223372036854775808
- test_defaults | 1 | 1 | 1 |1 |1
- test_max_vals | 2147483647 | 32767 | 32767 | 9223372036854775807 | 9223372036854775807
-(3 rows)
-
-SELECT nextval('serialTest2_f2_seq');
- nextval
--
- 2
-(1 row)
-
-SELECT nextval('serialTest2_f3_seq');
- nextval
--
- 2
-(1 row)
-
-SELECT nextval('serialTest2_f4_seq');
- nextval
--
- 2
-(1 row)
-
-SELECT nextval('serialTest2_f5_seq');
- nextval
--
- 2
-(1 row)
-
-SELECT nextval('serialTest2_f6_seq');
- nextval
--
- 2
-(1 row)
-
--- basic sequence operations using both text and oid references
-CREATE SEQUENCE sequence_test;
-CREATE SEQUENCE IF NOT EXISTS sequence_test;
-NOTICE: relation "sequence_test" already exists,