blob: c1b4a60a93824b420c5008906c6630e5e60ca622 [file] [log] [blame]
-- Test that dropping a database will drop pages in the shared buffer cache.
CREATE OR REPLACE FUNCTION check_shared_buffer_cache_for_dboid(Oid) RETURNS BOOL
AS '@abs_srcdir@/regress.so', 'check_shared_buffer_cache_for_dboid'
LANGUAGE C;
-- Create a new database and a table. This should create entries in the shared
-- buffer cache with the database Oid in the entries' buffer tag.
CREATE DATABASE dropdb_check_shared_buffer_cache;
\c dropdb_check_shared_buffer_cache
CREATE TABLE dropdb_check_shared_buffer_cache_table (a int);
\c regression
-- Store the new database's Oid for later use
-- start_ignore
SELECT oid AS dropdb_check_shared_buffer_cache_dboid
FROM pg_database WHERE datname = 'dropdb_check_shared_buffer_cache';
-- end_ignore
\gset
-- We expect 'true' that the shared buffer cache contains pages related to our
-- newly created database.
SELECT check_shared_buffer_cache_for_dboid(:dropdb_check_shared_buffer_cache_dboid);
-- Now drop our database. This should trigger dropping of pages for this
-- database that are in the shared buffer cache.
DROP DATABASE dropdb_check_shared_buffer_cache;
-- We expect 'false' that the shared buffer cache contains pages related to our
-- dropped database.
SELECT check_shared_buffer_cache_for_dboid(:dropdb_check_shared_buffer_cache_dboid);