From 6619d9074dde248e578486fc8d80cfa4fd445015 Mon Sep 17 00:00:00 2001 From: Andrew Werner Date: Fri, 27 Jan 2023 18:30:38 +0000 Subject: [PATCH] logictest: extent temp_table test to exercise discard + drop We had bugs with this in earlier releases. This is a forward-port of a test introduced in #96102. It never failed master, but no reason to ever let this regress. Epic: none Release note: None --- .../logictest/testdata/logic_test/temp_table | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/pkg/sql/logictest/testdata/logic_test/temp_table b/pkg/sql/logictest/testdata/logic_test/temp_table index 11b103d55dae..762d099916d8 100644 --- a/pkg/sql/logictest/testdata/logic_test/temp_table +++ b/pkg/sql/logictest/testdata/logic_test/temp_table @@ -356,4 +356,44 @@ to_drop.pg_temp.testuser_tmp to_drop.pg_temp.tempuser_view to_drop.pg_temp.root_temp +subtest create_after_discard_and_drop_database + +statement ok +ALTER ROLE testuser WITH CREATEDB; + user testuser + +statement ok +CREATE DATABASE to_drop + +statement ok +USE to_drop + +statement ok +CREATE TEMPORARY TABLE t (i INT PRIMARY KEY); + +statement ok +SELECT * FROM pg_temp.t + +statement ok +DISCARD TEMP + +statement error pgcode 42P01 relation "pg_temp.t" does not exist +SELECT * FROM pg_temp.t + +statement ok +USE defaultdb; +DROP DATABASE to_drop CASCADE; + +statement ok +CREATE DATABASE to_drop + +statement ok +CREATE TEMPORARY TABLE t (i INT PRIMARY KEY); + +statement ok +SELECT * FROM pg_temp.t + +statement ok +USE defaultdb; +DROP DATABASE to_drop CASCADE;