From b03fd545170e1dee7e0019f5faa28ab796b52480 Mon Sep 17 00:00:00 2001 From: Tim Chang Date: Thu, 25 Jan 2024 16:22:17 -0500 Subject: [PATCH] Add tests for toast in ENR change (#2291) Adding toasts to ENR for temp tables. This was originally introduced as part of #2259 . Signed-off-by: Tim Chang --- test/JDBC/expected/BABEL-4554-vu-cleanup.out | 2 + test/JDBC/expected/BABEL-4554-vu-prepare.out | 64 ++++++++++++++++++++ test/JDBC/expected/BABEL-4554-vu-verify.out | 25 ++++++++ test/JDBC/input/BABEL-4554-vu-cleanup.sql | 2 + test/JDBC/input/BABEL-4554-vu-prepare.sql | 44 ++++++++++++++ test/JDBC/input/BABEL-4554-vu-verify.sql | 21 +++++++ 6 files changed, 158 insertions(+) create mode 100644 test/JDBC/expected/BABEL-4554-vu-cleanup.out create mode 100644 test/JDBC/expected/BABEL-4554-vu-prepare.out create mode 100644 test/JDBC/expected/BABEL-4554-vu-verify.out create mode 100644 test/JDBC/input/BABEL-4554-vu-cleanup.sql create mode 100644 test/JDBC/input/BABEL-4554-vu-prepare.sql create mode 100644 test/JDBC/input/BABEL-4554-vu-verify.sql diff --git a/test/JDBC/expected/BABEL-4554-vu-cleanup.out b/test/JDBC/expected/BABEL-4554-vu-cleanup.out new file mode 100644 index 0000000000..fcb11b3f99 --- /dev/null +++ b/test/JDBC/expected/BABEL-4554-vu-cleanup.out @@ -0,0 +1,2 @@ +DROP TYPE babel_4554_type +GO diff --git a/test/JDBC/expected/BABEL-4554-vu-prepare.out b/test/JDBC/expected/BABEL-4554-vu-prepare.out new file mode 100644 index 0000000000..1e6573b1cd --- /dev/null +++ b/test/JDBC/expected/BABEL-4554-vu-prepare.out @@ -0,0 +1,64 @@ + +-- Verify that newly created temp tables have toasts in ENR. +CREATE TABLE #babel_4554_temp_table(a varchar(4000), b nvarchar(MAX), c sysname) +GO + +-- 3: table, toast, index on toast +SELECT COUNT(*) FROM sys.babelfish_get_enr_list() +GO +~~START~~ +int +3 +~~END~~ + + +DROP TABLE #babel_4554_temp_table +GO + +-- 4: table, toast, index on toast, pkey +CREATE TABLE #babel_4554_temp_table_2(a sysname primary key, b nvarchar(MAX)) +GO + +SELECT COUNT(*) FROM sys.babelfish_get_enr_list() +GO +~~START~~ +int +4 +~~END~~ + + +-- 1: index +CREATE INDEX #babel_4554_idx1 ON #babel_4554_temp_table_2(b) +GO + +SELECT COUNT(*) FROM sys.babelfish_get_enr_list() +GO +~~START~~ +int +5 +~~END~~ + + +DROP INDEX #babel_4554_idx1 ON #babel_4554_temp_table_2 +GO + +DROP TABLE #babel_4554_temp_table_2 +GO + +-- Verify that non-ENR tables don't put their toasts in ENR. +CREATE TYPE babel_4554_type FROM INT +GO + +CREATE TABLE #babel_4554_temp_table_not_enr(a babel_4554_type, b nvarchar(MAX)) +GO + +SELECT COUNT(*) FROM sys.babelfish_get_enr_list() +GO +~~START~~ +int +0 +~~END~~ + + +DROP TABLE #babel_4554_temp_table_not_enr +GO diff --git a/test/JDBC/expected/BABEL-4554-vu-verify.out b/test/JDBC/expected/BABEL-4554-vu-verify.out new file mode 100644 index 0000000000..5d6edf026a --- /dev/null +++ b/test/JDBC/expected/BABEL-4554-vu-verify.out @@ -0,0 +1,25 @@ + +-- We should have no dangling entries here (taken from BABEL-4554 DA) +select * +from pg_class where relname in +( + select relname + from pg_class c + where not exists + ( + SELECT * from pg_class d + WHERE c.oid = d.reltoastrelid + ) + AND relname in + ( + select s.relname from pg_stat_all_tables s where s.relname LIKE 'pg_toast_%' + ) + AND pg_table_size(c.oid) = 0 + AND c.relkind = 't' + AND c.relpersistence = 't' +) +GO +~~START~~ +int#!#varchar#!#int#!#int#!#int#!#int#!#int#!#int#!#int#!#int#!#real#!#int#!#int#!#bit#!#bit#!#varchar#!#varchar#!#smallint#!#smallint#!#bit#!#bit#!#bit#!#bit#!#bit#!#bit#!#varchar#!#bit#!#int#!#int#!#int#!#varchar#!#varchar#!#varchar +~~END~~ + diff --git a/test/JDBC/input/BABEL-4554-vu-cleanup.sql b/test/JDBC/input/BABEL-4554-vu-cleanup.sql new file mode 100644 index 0000000000..5983643d80 --- /dev/null +++ b/test/JDBC/input/BABEL-4554-vu-cleanup.sql @@ -0,0 +1,2 @@ +DROP TYPE babel_4554_type +GO \ No newline at end of file diff --git a/test/JDBC/input/BABEL-4554-vu-prepare.sql b/test/JDBC/input/BABEL-4554-vu-prepare.sql new file mode 100644 index 0000000000..7d4ceb9e9a --- /dev/null +++ b/test/JDBC/input/BABEL-4554-vu-prepare.sql @@ -0,0 +1,44 @@ +-- Verify that newly created temp tables have toasts in ENR. + +CREATE TABLE #babel_4554_temp_table(a varchar(4000), b nvarchar(MAX), c sysname) +GO + +-- 3: table, toast, index on toast +SELECT COUNT(*) FROM sys.babelfish_get_enr_list() +GO + +DROP TABLE #babel_4554_temp_table +GO + +-- 4: table, toast, index on toast, pkey +CREATE TABLE #babel_4554_temp_table_2(a sysname primary key, b nvarchar(MAX)) +GO + +SELECT COUNT(*) FROM sys.babelfish_get_enr_list() +GO + +-- 1: index +CREATE INDEX #babel_4554_idx1 ON #babel_4554_temp_table_2(b) +GO + +SELECT COUNT(*) FROM sys.babelfish_get_enr_list() +GO + +DROP INDEX #babel_4554_idx1 ON #babel_4554_temp_table_2 +GO + +DROP TABLE #babel_4554_temp_table_2 +GO + +-- Verify that non-ENR tables don't put their toasts in ENR. +CREATE TYPE babel_4554_type FROM INT +GO + +CREATE TABLE #babel_4554_temp_table_not_enr(a babel_4554_type, b nvarchar(MAX)) +GO + +SELECT COUNT(*) FROM sys.babelfish_get_enr_list() +GO + +DROP TABLE #babel_4554_temp_table_not_enr +GO diff --git a/test/JDBC/input/BABEL-4554-vu-verify.sql b/test/JDBC/input/BABEL-4554-vu-verify.sql new file mode 100644 index 0000000000..96c92b932f --- /dev/null +++ b/test/JDBC/input/BABEL-4554-vu-verify.sql @@ -0,0 +1,21 @@ +-- We should have no dangling entries here (taken from BABEL-4554 DA) + +select * +from pg_class where relname in +( + select relname + from pg_class c + where not exists + ( + SELECT * from pg_class d + WHERE c.oid = d.reltoastrelid + ) + AND relname in + ( + select s.relname from pg_stat_all_tables s where s.relname LIKE 'pg_toast_%' + ) + AND pg_table_size(c.oid) = 0 + AND c.relkind = 't' + AND c.relpersistence = 't' +) +GO \ No newline at end of file