Repository: incubator-hawq Updated Branches: refs/heads/master dbcbe0fce -> faf50470b
HAWQ-908. Add feature test for goh_toast with new test framework Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/faf50470 Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/faf50470 Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/faf50470 Branch: refs/heads/master Commit: faf50470b73c3d646ff6edfd03a62fbf7931a5f7 Parents: dbcbe0f Author: ivan <[email protected]> Authored: Tue Jul 26 11:02:01 2016 +0800 Committer: ivan <[email protected]> Committed: Tue Jul 26 11:02:01 2016 +0800 ---------------------------------------------------------------------- src/test/feature/toast/TestToast.cpp | 19 +++++++++++ src/test/feature/toast/ans/goh_toast.ans | 49 +++++++++++++++++++++++++++ src/test/feature/toast/sql/goh_toast.sql | 32 +++++++++++++++++ 3 files changed, 100 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/faf50470/src/test/feature/toast/TestToast.cpp ---------------------------------------------------------------------- diff --git a/src/test/feature/toast/TestToast.cpp b/src/test/feature/toast/TestToast.cpp new file mode 100644 index 0000000..2cd826a --- /dev/null +++ b/src/test/feature/toast/TestToast.cpp @@ -0,0 +1,19 @@ +#include "gtest/gtest.h" + +#include "lib/sql_util.h" + +using std::string; + +class TestToast: public ::testing::Test +{ + public: + TestToast() { } + ~TestToast() {} +}; + +TEST_F(TestToast, BasicTest) +{ + hawq::test::SQLUtility util; + util.execSQLFile("toast/sql/goh_toast.sql", + "toast/ans/goh_toast.ans"); +} http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/faf50470/src/test/feature/toast/ans/goh_toast.ans ---------------------------------------------------------------------- diff --git a/src/test/feature/toast/ans/goh_toast.ans b/src/test/feature/toast/ans/goh_toast.ans new file mode 100644 index 0000000..42a6a3b --- /dev/null +++ b/src/test/feature/toast/ans/goh_toast.ans @@ -0,0 +1,49 @@ +-- start_ignore +SET SEARCH_PATH=TestToast_BasicTest; +SET +-- end_ignore +CREATE TABLE toastable_ao(a text, b varchar, c int) with(appendonly=true, compresslevel=1) distributed randomly; +CREATE TABLE +-- INSERT +-- uses the toast call to store the large tuples +INSERT INTO toastable_ao VALUES(repeat('a',100000), repeat('b',100001), 1); +INSERT 0 1 +INSERT INTO toastable_ao VALUES(repeat('A',100000), repeat('B',100001), 2); +INSERT 0 1 +-- Check that tuples were toasted and are detoasted correctly. we use +-- char_length() because it guarantees a detoast without showing tho whole result +SELECT char_length(a), char_length(b), c FROM toastable_ao ORDER BY c; + char_length | char_length | c +-------------+-------------+--- + 100000 | 100001 | 1 + 100000 | 100001 | 2 +(2 rows) + +-- ALTER +-- this will cause a full table rewrite. we make sure the tosted values and references +-- stay intact after all the oid switching business going on. +-- ALTER TABLE toastable_ao ADD COLUMN d int DEFAULT 10; +-- SELECT char_length(a), char_length(b), c, d FROM toastable_ao ORDER BY c; +SELECT char_length(a), char_length(b), c FROM toastable_ao ORDER BY c; + char_length | char_length | c +-------------+-------------+--- + 100000 | 100001 | 1 + 100000 | 100001 | 2 +(2 rows) + +-- TRUNCATE +-- remove reference to toast table and create a new one with different values +TRUNCATE toastable_ao; +TRUNCATE TABLE +INSERT INTO toastable_ao VALUES(repeat('a',100002), repeat('b',100003), 2); +INSERT 0 1 +SELECT char_length(a), char_length(b), c FROM toastable_ao; + char_length | char_length | c +-------------+-------------+--- + 100002 | 100003 | 2 +(1 row) + +-- TODO: figure out a way to verify that toasted data is removed after the truncate. +DROP TABLE toastable_ao; +DROP TABLE +-- TODO: figure out a way to verify that the toast tables are dropped http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/faf50470/src/test/feature/toast/sql/goh_toast.sql ---------------------------------------------------------------------- diff --git a/src/test/feature/toast/sql/goh_toast.sql b/src/test/feature/toast/sql/goh_toast.sql new file mode 100644 index 0000000..45d9305 --- /dev/null +++ b/src/test/feature/toast/sql/goh_toast.sql @@ -0,0 +1,32 @@ +CREATE TABLE toastable_ao(a text, b varchar, c int) with(appendonly=true, compresslevel=1) distributed randomly; + +-- INSERT +-- uses the toast call to store the large tuples +INSERT INTO toastable_ao VALUES(repeat('a',100000), repeat('b',100001), 1); +INSERT INTO toastable_ao VALUES(repeat('A',100000), repeat('B',100001), 2); + +-- Check that tuples were toasted and are detoasted correctly. we use +-- char_length() because it guarantees a detoast without showing tho whole result +SELECT char_length(a), char_length(b), c FROM toastable_ao ORDER BY c; + +-- ALTER +-- this will cause a full table rewrite. we make sure the tosted values and references +-- stay intact after all the oid switching business going on. +-- ALTER TABLE toastable_ao ADD COLUMN d int DEFAULT 10; + +-- SELECT char_length(a), char_length(b), c, d FROM toastable_ao ORDER BY c; +SELECT char_length(a), char_length(b), c FROM toastable_ao ORDER BY c; + +-- TRUNCATE +-- remove reference to toast table and create a new one with different values +TRUNCATE toastable_ao; + +INSERT INTO toastable_ao VALUES(repeat('a',100002), repeat('b',100003), 2); + +SELECT char_length(a), char_length(b), c FROM toastable_ao; + +-- TODO: figure out a way to verify that toasted data is removed after the truncate. + +DROP TABLE toastable_ao; + +-- TODO: figure out a way to verify that the toast tables are dropped
