-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]>
- Loading branch information
1 parent
ffd3b17
commit b03fd54
Showing
6 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
DROP TYPE babel_4554_type | ||
GO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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~~ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
DROP TYPE babel_4554_type | ||
GO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |