ClickHouse/tests/queries/0_stateless/01109_exchange_tables.sql

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

68 lines
2.5 KiB
MySQL
Raw Normal View History

2021-09-12 12:35:27 +00:00
-- Tags: no-parallel
2024-02-21 22:26:30 +00:00
SET send_logs_level = 'fatal';
2021-09-12 12:35:27 +00:00
2020-03-31 20:38:05 +00:00
DROP DATABASE IF EXISTS test_01109;
CREATE DATABASE test_01109 ENGINE=Atomic;
USE test_01109;
2020-04-10 23:02:15 +00:00
CREATE TABLE t0 ENGINE=MergeTree() ORDER BY tuple() AS SELECT rowNumberInAllBlocks(), * FROM (SELECT toLowCardinality(arrayJoin(['exchange', 'tables'])));
-- NOTE: database = currentDatabase() is not mandatory
2020-04-10 23:02:15 +00:00
CREATE TABLE t1 ENGINE=Log() AS SELECT * FROM system.tables AS t JOIN system.databases AS d ON t.database=d.name;
CREATE TABLE t2 ENGINE=MergeTree() ORDER BY tuple() AS SELECT rowNumberInAllBlocks() + (SELECT count() FROM t0), * FROM (SELECT arrayJoin(['hello', 'world']));
2020-03-31 20:38:05 +00:00
EXCHANGE TABLES t1 AND t3; -- { serverError 60 }
EXCHANGE TABLES t4 AND t2; -- { serverError 60 }
2020-04-10 23:02:15 +00:00
RENAME TABLE t0 TO t1; -- { serverError 57 }
DROP TABLE t1;
RENAME TABLE t0 TO t1;
2020-03-31 20:38:05 +00:00
SELECT * FROM t1;
SELECT * FROM t2;
EXCHANGE TABLES t1 AND t2;
2020-03-31 20:38:05 +00:00
SELECT * FROM t1;
SELECT * FROM t2;
RENAME TABLE t1 TO t1tmp, t2 TO t2tmp;
RENAME TABLE t1tmp TO t2, t2tmp TO t1;
2020-03-31 20:38:05 +00:00
SELECT * FROM t1;
SELECT * FROM t2;
DROP DATABASE IF EXISTS test_01109_other_atomic;
DROP DATABASE IF EXISTS test_01109_ordinary;
CREATE DATABASE test_01109_other_atomic;
2022-06-23 10:58:34 +00:00
set allow_deprecated_database_ordinary=1;
2024-02-21 17:55:30 +00:00
-- Creation of a database with Ordinary engine emits a warning.
2022-06-23 07:59:13 +00:00
CREATE DATABASE test_01109_ordinary ENGINE=Ordinary;
2020-03-31 20:38:05 +00:00
CREATE TABLE test_01109_other_atomic.t3 ENGINE=MergeTree() ORDER BY tuple()
AS SELECT rowNumberInAllBlocks() + (SELECT max((*,*).1.1) + 1 FROM (SELECT (*,) FROM t1 UNION ALL SELECT (*,) FROM t2)), *
FROM (SELECT arrayJoin(['another', 'db']));
CREATE TABLE test_01109_ordinary.t4 AS t1;
EXCHANGE TABLES test_01109_other_atomic.t3 AND test_01109_ordinary.t4; -- { serverError 48 }
EXCHANGE TABLES test_01109_ordinary.t4 AND test_01109_other_atomic.t3; -- { serverError 48 }
EXCHANGE TABLES test_01109_ordinary.t4 AND test_01109_ordinary.t4; -- { serverError 48 }
EXCHANGE TABLES t1 AND test_01109_other_atomic.t3;
EXCHANGE TABLES t2 AND t2;
2020-03-31 20:38:05 +00:00
SELECT * FROM t1;
SELECT * FROM t2;
SELECT * FROM test_01109_other_atomic.t3;
SELECT * FROM test_01109_ordinary.t4;
DROP DATABASE IF EXISTS test_01109_rename_exists;
CREATE DATABASE test_01109_rename_exists ENGINE=Atomic;
USE test_01109_rename_exists;
CREATE TABLE t0 ENGINE=Log() AS SELECT * FROM system.numbers limit 2;
RENAME TABLE t0_tmp TO t1; -- { serverError 60 }
RENAME TABLE if exists t0_tmp TO t1;
RENAME TABLE if exists t0 TO t1;
SELECT * FROM t1;
2020-03-31 20:38:05 +00:00
DROP DATABASE test_01109;
DROP DATABASE test_01109_other_atomic;
DROP DATABASE test_01109_ordinary;
DROP DATABASE test_01109_rename_exists;