blob: e77930988a0adb91392a15c6a8e9069cdd055d9d [file]
-- Test that dropping a database will drop pages in the shared buffer cache.
\getenv abs_srcdir PG_ABS_SRCDIR
\set regress_dll :abs_srcdir '/regress.so'
CREATE OR REPLACE FUNCTION check_shared_buffer_cache_for_dboid(Oid) RETURNS BOOL
AS :'regress_dll', '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);