ClickHouse/tests/queries/0_stateless/02711_server_uuid_macro.sql

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

16 lines
894 B
MySQL
Raw Normal View History

2023-04-09 01:25:38 +00:00
DROP TABLE IF EXISTS test;
-- You can create a table with the {server_uuid} substituted.
CREATE TABLE test (x UInt8) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{database}/test', 'replica-{server_uuid}') ORDER BY x;
2023-04-09 01:25:38 +00:00
-- The server UUID is correctly substituted.
SELECT engine_full LIKE ('%replica-' || serverUUID()::String || '%') FROM system.tables WHERE database = currentDatabase() AND name = 'test';
-- An attempt to create a second table with the same UUID results in error.
CREATE TABLE test2 (x UInt8) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{database}/test', 'replica-{server_uuid}') ORDER BY x; -- { serverError REPLICA_ALREADY_EXISTS }
2023-04-09 01:25:38 +00:00
-- The macro {server_uuid} is special, not a configuration-type macro. It's normal that it is inaccessible with the getMacro function.
SELECT getMacro('server_uuid'); -- { serverError NO_ELEMENTS_IN_CONFIG }
2023-05-03 18:06:46 +00:00
DROP TABLE test SYNC;