mirror of https://github.com/citusdata/citus.git
Do clean-up before columnar_create to make it runnable multiple times
So that flaky test detector can run columnar_create.sql multiple times.pull/6624/head
parent
1c51ddae49
commit
594684bb33
|
@ -1,24 +1,50 @@
|
||||||
--
|
--
|
||||||
-- Test the CREATE statements related to columnar.
|
-- Test the CREATE statements related to columnar.
|
||||||
--
|
--
|
||||||
|
-- We cannot create below tables within columnar_create because columnar_create
|
||||||
|
-- is dropped at the end of this test but unfortunately some other tests depend
|
||||||
|
-- those tables too.
|
||||||
|
--
|
||||||
|
-- However, this file has to be runnable multiple times for flaky test detection;
|
||||||
|
-- so we create them below --outside columnar_create-- idempotantly.
|
||||||
|
DO
|
||||||
|
$$
|
||||||
|
BEGIN
|
||||||
|
IF NOT EXISTS (
|
||||||
|
SELECT 1 FROM pg_class
|
||||||
|
WHERE relname = 'contestant' AND
|
||||||
|
relnamespace = (
|
||||||
|
SELECT oid FROM pg_namespace WHERE nspname = 'public'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
THEN
|
||||||
-- Create uncompressed table
|
-- Create uncompressed table
|
||||||
CREATE TABLE contestant (handle TEXT, birthdate DATE, rating INT,
|
CREATE TABLE contestant (handle TEXT, birthdate DATE, rating INT,
|
||||||
percentile FLOAT, country CHAR(3), achievements TEXT[])
|
percentile FLOAT, country CHAR(3), achievements TEXT[])
|
||||||
USING columnar;
|
USING columnar;
|
||||||
ALTER TABLE contestant SET (columnar.compression = none);
|
ALTER TABLE contestant SET (columnar.compression = none);
|
||||||
|
|
||||||
CREATE INDEX contestant_idx on contestant(handle);
|
CREATE INDEX contestant_idx on contestant(handle);
|
||||||
|
|
||||||
-- Create zstd compressed table
|
-- Create zstd compressed table
|
||||||
CREATE TABLE contestant_compressed (handle TEXT, birthdate DATE, rating INT,
|
CREATE TABLE contestant_compressed (handle TEXT, birthdate DATE, rating INT,
|
||||||
percentile FLOAT, country CHAR(3), achievements TEXT[])
|
percentile FLOAT, country CHAR(3), achievements TEXT[])
|
||||||
USING columnar;
|
USING columnar;
|
||||||
|
|
||||||
-- Test that querying an empty table works
|
-- Test that querying an empty table works
|
||||||
ANALYZE contestant;
|
ANALYZE contestant;
|
||||||
|
END IF;
|
||||||
|
END
|
||||||
|
$$
|
||||||
|
LANGUAGE plpgsql;
|
||||||
SELECT count(*) FROM contestant;
|
SELECT count(*) FROM contestant;
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
0
|
0
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
CREATE SCHEMA columnar_create;
|
||||||
|
SET search_path TO columnar_create;
|
||||||
-- Should fail: unlogged tables not supported
|
-- Should fail: unlogged tables not supported
|
||||||
CREATE UNLOGGED TABLE columnar_unlogged(i int) USING columnar;
|
CREATE UNLOGGED TABLE columnar_unlogged(i int) USING columnar;
|
||||||
ERROR: unlogged columnar tables are not supported
|
ERROR: unlogged columnar tables are not supported
|
||||||
|
@ -156,6 +182,7 @@ SELECT columnar.get_storage_id(oid) AS columnar_temp_storage_id
|
||||||
FROM pg_class WHERE relname='columnar_temp' \gset
|
FROM pg_class WHERE relname='columnar_temp' \gset
|
||||||
SELECT pg_backend_pid() AS val INTO old_backend_pid;
|
SELECT pg_backend_pid() AS val INTO old_backend_pid;
|
||||||
\c - - - :master_port
|
\c - - - :master_port
|
||||||
|
SET search_path TO columnar_create;
|
||||||
-- wait until old backend to expire to make sure that temp table cleanup is complete
|
-- wait until old backend to expire to make sure that temp table cleanup is complete
|
||||||
SELECT columnar_test_helpers.pg_waitpid(val) FROM old_backend_pid;
|
SELECT columnar_test_helpers.pg_waitpid(val) FROM old_backend_pid;
|
||||||
pg_waitpid
|
pg_waitpid
|
||||||
|
@ -265,3 +292,5 @@ SELECT columnar_test_helpers.columnar_metadata_has_storage_id(:columnar_temp_sto
|
||||||
|
|
||||||
-- make sure citus_columnar can be loaded
|
-- make sure citus_columnar can be loaded
|
||||||
LOAD 'citus_columnar';
|
LOAD 'citus_columnar';
|
||||||
|
SET client_min_messages TO WARNING;
|
||||||
|
DROP SCHEMA columnar_create CASCADE;
|
||||||
|
|
|
@ -2,7 +2,23 @@
|
||||||
-- Test the CREATE statements related to columnar.
|
-- Test the CREATE statements related to columnar.
|
||||||
--
|
--
|
||||||
|
|
||||||
|
-- We cannot create below tables within columnar_create because columnar_create
|
||||||
|
-- is dropped at the end of this test but unfortunately some other tests depend
|
||||||
|
-- those tables too.
|
||||||
|
--
|
||||||
|
-- However, this file has to be runnable multiple times for flaky test detection;
|
||||||
|
-- so we create them below --outside columnar_create-- idempotantly.
|
||||||
|
DO
|
||||||
|
$$
|
||||||
|
BEGIN
|
||||||
|
IF NOT EXISTS (
|
||||||
|
SELECT 1 FROM pg_class
|
||||||
|
WHERE relname = 'contestant' AND
|
||||||
|
relnamespace = (
|
||||||
|
SELECT oid FROM pg_namespace WHERE nspname = 'public'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
THEN
|
||||||
-- Create uncompressed table
|
-- Create uncompressed table
|
||||||
CREATE TABLE contestant (handle TEXT, birthdate DATE, rating INT,
|
CREATE TABLE contestant (handle TEXT, birthdate DATE, rating INT,
|
||||||
percentile FLOAT, country CHAR(3), achievements TEXT[])
|
percentile FLOAT, country CHAR(3), achievements TEXT[])
|
||||||
|
@ -18,8 +34,16 @@ CREATE TABLE contestant_compressed (handle TEXT, birthdate DATE, rating INT,
|
||||||
|
|
||||||
-- Test that querying an empty table works
|
-- Test that querying an empty table works
|
||||||
ANALYZE contestant;
|
ANALYZE contestant;
|
||||||
|
END IF;
|
||||||
|
END
|
||||||
|
$$
|
||||||
|
LANGUAGE plpgsql;
|
||||||
|
|
||||||
SELECT count(*) FROM contestant;
|
SELECT count(*) FROM contestant;
|
||||||
|
|
||||||
|
CREATE SCHEMA columnar_create;
|
||||||
|
SET search_path TO columnar_create;
|
||||||
|
|
||||||
-- Should fail: unlogged tables not supported
|
-- Should fail: unlogged tables not supported
|
||||||
CREATE UNLOGGED TABLE columnar_unlogged(i int) USING columnar;
|
CREATE UNLOGGED TABLE columnar_unlogged(i int) USING columnar;
|
||||||
|
|
||||||
|
@ -118,6 +142,7 @@ FROM pg_class WHERE relname='columnar_temp' \gset
|
||||||
SELECT pg_backend_pid() AS val INTO old_backend_pid;
|
SELECT pg_backend_pid() AS val INTO old_backend_pid;
|
||||||
|
|
||||||
\c - - - :master_port
|
\c - - - :master_port
|
||||||
|
SET search_path TO columnar_create;
|
||||||
|
|
||||||
-- wait until old backend to expire to make sure that temp table cleanup is complete
|
-- wait until old backend to expire to make sure that temp table cleanup is complete
|
||||||
SELECT columnar_test_helpers.pg_waitpid(val) FROM old_backend_pid;
|
SELECT columnar_test_helpers.pg_waitpid(val) FROM old_backend_pid;
|
||||||
|
@ -184,3 +209,6 @@ SELECT columnar_test_helpers.columnar_metadata_has_storage_id(:columnar_temp_sto
|
||||||
|
|
||||||
-- make sure citus_columnar can be loaded
|
-- make sure citus_columnar can be loaded
|
||||||
LOAD 'citus_columnar';
|
LOAD 'citus_columnar';
|
||||||
|
|
||||||
|
SET client_min_messages TO WARNING;
|
||||||
|
DROP SCHEMA columnar_create CASCADE;
|
||||||
|
|
Loading…
Reference in New Issue