cranky-ConditionalLockBufferForCleanup.patch
text/x-patch
Filename: cranky-ConditionalLockBufferForCleanup.patch
Type: text/x-patch
Part: 0
Patch
Format: unified
| File | + | − |
|---|---|---|
| src/backend/storage/buffer/bufmgr.c | 1 | 0 |
| src/test/regress/expected/create_index.out | 26 | 0 |
| src/test/regress/sql/create_index.sql | 11 | 0 |
diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c
index f0f8d4259c..d60c117378 100644
--- a/src/backend/storage/buffer/bufmgr.c
+++ b/src/backend/storage/buffer/bufmgr.c
@@ -5041,6 +5041,7 @@ ConditionalLockBufferForCleanup(Buffer buffer)
Assert(BufferIsValid(buffer));
+if (rand() % 10 == 0) return false;
if (BufferIsLocal(buffer))
{
refcount = LocalRefCount[-buffer - 1];
diff --git a/src/test/regress/expected/create_index.out b/src/test/regress/expected/create_index.out
index 70ab47a92f..93c1f4f08d 100644
--- a/src/test/regress/expected/create_index.out
+++ b/src/test/regress/expected/create_index.out
@@ -1932,6 +1932,32 @@ ORDER BY unique1;
42
(3 rows)
+explain (verbose)
+SELECT thousand, tenthous FROM tenk1
+WHERE thousand < 2 AND tenthous IN (1001,3000)
+ORDER BY thousand;
+ QUERY PLAN
+----------------------------------------------------------------------------------------------
+ Index Only Scan using tenk1_thous_tenthous on public.tenk1 (cost=0.29..4.71 rows=1 width=8)
+ Output: thousand, tenthous
+ Index Cond: (tenk1.thousand < 2)
+ Filter: (tenk1.tenthous = ANY ('{1001,3000}'::integer[]))
+(4 rows)
+
+select c.relname,c.relpages,c.reltuples,c.relallvisible,i.indisvalid,s.autovacuum_count,s.autoanalyze_count
+from pg_class c
+left join pg_stat_all_tables s on c.oid = s.relid
+left join pg_index i on c.oid = i.indexrelid
+where c.relname like 'tenk1%' order by c.relname;
+ relname | relpages | reltuples | relallvisible | indisvalid | autovacuum_count | autoanalyze_count
+----------------------+----------+-----------+---------------+------------+------------------+-------------------
+ tenk1 | 345 | 10000 | 345 | | 0 | 0
+ tenk1_hundred | 11 | 10000 | 0 | t | |
+ tenk1_thous_tenthous | 30 | 10000 | 0 | t | |
+ tenk1_unique1 | 30 | 10000 | 0 | t | |
+ tenk1_unique2 | 30 | 10000 | 0 | t | |
+(5 rows)
+
explain (costs off)
SELECT thousand, tenthous FROM tenk1
WHERE thousand < 2 AND tenthous IN (1001,3000)
diff --git a/src/test/regress/sql/create_index.sql b/src/test/regress/sql/create_index.sql
index d49ce9f300..732b54fb35 100644
--- a/src/test/regress/sql/create_index.sql
+++ b/src/test/regress/sql/create_index.sql
@@ -765,6 +765,17 @@ SELECT unique1 FROM tenk1
WHERE unique1 IN (1,42,7)
ORDER BY unique1;
+explain (verbose)
+SELECT thousand, tenthous FROM tenk1
+WHERE thousand < 2 AND tenthous IN (1001,3000)
+ORDER BY thousand;
+
+select c.relname,c.relpages,c.reltuples,c.relallvisible,i.indisvalid,s.autovacuum_count,s.autoanalyze_count
+from pg_class c
+left join pg_stat_all_tables s on c.oid = s.relid
+left join pg_index i on c.oid = i.indexrelid
+where c.relname like 'tenk1%' order by c.relname;
+
explain (costs off)
SELECT thousand, tenthous FROM tenk1
WHERE thousand < 2 AND tenthous IN (1001,3000)