On 12/6/25 12:53 PM, Kirill Reshke wrote:
I did find a misleading comment in amcheck's regression test suite,
during un-related hacking in Cloudberry[0]. There is a comment which
says `-- Check that sequences are rejected` but those are supported
starting c3b011d
Lets make things not misleading.
I think we should change a bit more to make it more like the tests for
heap tables. What do you think?
Andreas
From 610d966d639d4bd046b394979880e9227e4bc4df Mon Sep 17 00:00:00 2001
From: Andreas Karlsson <[email protected]>
Date: Wed, 14 Jan 2026 07:02:44 +0100
Subject: [PATCH] Improve amcheck heap tests for sequences
The test for sequences claims that it will reject sequences but it
actually does not do so. While fixing this we also make the test more
like the tests for heap tables and make sure we drop all objects we
create.
---
contrib/amcheck/expected/check_heap.out | 28 +++++++++++++++++++++----
contrib/amcheck/sql/check_heap.sql | 13 ++++++++----
2 files changed, 33 insertions(+), 8 deletions(-)
diff --git a/contrib/amcheck/expected/check_heap.out b/contrib/amcheck/expected/check_heap.out
index 979e5e84e72..bc0c6966b5a 100644
--- a/contrib/amcheck/expected/check_heap.out
+++ b/contrib/amcheck/expected/check_heap.out
@@ -213,11 +213,25 @@ SELECT * FROM verify_heapam('test_view',
endblock := NULL);
ERROR: cannot check relation "test_view"
DETAIL: This operation is not supported for views.
--- Check that sequences are rejected
+-- Check that valid options are not rejected nor corruption reported
+-- for a sequence
CREATE SEQUENCE test_sequence;
-SELECT * FROM verify_heapam('test_sequence',
- startblock := NULL,
- endblock := NULL);
+SELECT * FROM verify_heapam(relation := 'test_sequence', skip := 'none');
+ blkno | offnum | attnum | msg
+-------+--------+--------+-----
+(0 rows)
+
+SELECT * FROM verify_heapam(relation := 'test_sequence', skip := 'all-frozen');
+ blkno | offnum | attnum | msg
+-------+--------+--------+-----
+(0 rows)
+
+SELECT * FROM verify_heapam(relation := 'test_sequence', skip := 'all-visible');
+ blkno | offnum | attnum | msg
+-------+--------+--------+-----
+(0 rows)
+
+SELECT * FROM verify_heapam(relation := 'test_sequence', startblock := 0, endblock := 0);
blkno | offnum | attnum | msg
-------+--------+--------+-----
(0 rows)
@@ -232,6 +246,12 @@ SELECT * FROM verify_heapam('test_foreign_table',
ERROR: cannot check relation "test_foreign_table"
DETAIL: This operation is not supported for foreign tables.
-- cleanup
+DROP FOREIGN DATA WRAPPER dummy CASCADE;
+NOTICE: drop cascades to 2 other objects
+DETAIL: drop cascades to server dummy_server
+drop cascades to foreign table test_foreign_table
+DROP VIEW test_view;
+DROP SEQUENCE test_sequence;
DROP TABLE heaptest;
DROP TABLESPACE regress_test_stats_tblspc;
DROP TABLE test_partition;
diff --git a/contrib/amcheck/sql/check_heap.sql b/contrib/amcheck/sql/check_heap.sql
index 1745bae634e..7fbdc5abc76 100644
--- a/contrib/amcheck/sql/check_heap.sql
+++ b/contrib/amcheck/sql/check_heap.sql
@@ -124,11 +124,13 @@ SELECT * FROM verify_heapam('test_view',
startblock := NULL,
endblock := NULL);
--- Check that sequences are rejected
+-- Check that valid options are not rejected nor corruption reported
+-- for a sequence
CREATE SEQUENCE test_sequence;
-SELECT * FROM verify_heapam('test_sequence',
- startblock := NULL,
- endblock := NULL);
+SELECT * FROM verify_heapam(relation := 'test_sequence', skip := 'none');
+SELECT * FROM verify_heapam(relation := 'test_sequence', skip := 'all-frozen');
+SELECT * FROM verify_heapam(relation := 'test_sequence', skip := 'all-visible');
+SELECT * FROM verify_heapam(relation := 'test_sequence', startblock := 0, endblock := 0);
-- Check that foreign tables are rejected
CREATE FOREIGN DATA WRAPPER dummy;
@@ -139,6 +141,9 @@ SELECT * FROM verify_heapam('test_foreign_table',
endblock := NULL);
-- cleanup
+DROP FOREIGN DATA WRAPPER dummy CASCADE;
+DROP VIEW test_view;
+DROP SEQUENCE test_sequence;
DROP TABLE heaptest;
DROP TABLESPACE regress_test_stats_tblspc;
DROP TABLE test_partition;
--
2.47.3