2020-02-17 13:20:09 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
2020-08-01 00:51:12 +00:00
|
|
|
. "$CURDIR"/../shell_config.sh
|
2020-02-17 13:20:09 +00:00
|
|
|
|
|
|
|
$CLICKHOUSE_CLIENT --query "DROP TABLE IF EXISTS table_for_bad_alters";
|
|
|
|
|
2020-05-12 03:41:35 +00:00
|
|
|
$CLICKHOUSE_CLIENT -n --query "CREATE TABLE table_for_bad_alters (
|
|
|
|
key UInt64,
|
|
|
|
value1 UInt8,
|
|
|
|
value2 String
|
2020-08-26 17:45:20 +00:00
|
|
|
) ENGINE = ReplicatedMergeTree('/clickhouse/tables/test_01079/table_for_bad_alters', '1')
|
2020-02-17 13:20:09 +00:00
|
|
|
ORDER BY key;"
|
|
|
|
|
|
|
|
$CLICKHOUSE_CLIENT --query "INSERT INTO table_for_bad_alters VALUES(1, 1, 'Hello');"
|
|
|
|
$CLICKHOUSE_CLIENT --query "ALTER TABLE table_for_bad_alters MODIFY COLUMN value1 UInt32, DROP COLUMN non_existing_column" 2>&1 | grep -o "Wrong column name." | uniq
|
|
|
|
$CLICKHOUSE_CLIENT --query "SHOW CREATE TABLE table_for_bad_alters;" # nothing changed
|
|
|
|
|
|
|
|
$CLICKHOUSE_CLIENT --query "ALTER TABLE table_for_bad_alters MODIFY COLUMN value2 UInt32 SETTINGS replication_alter_partitions_sync=0;"
|
|
|
|
|
|
|
|
sleep 2
|
|
|
|
|
|
|
|
while [[ $($CLICKHOUSE_CLIENT --query "KILL MUTATION WHERE mutation_id='0000000000'" 2>&1) ]]; do
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|
|
|
|
$CLICKHOUSE_CLIENT --query "SHOW CREATE TABLE table_for_bad_alters;" # Type changed, but we can revert back
|
|
|
|
|
|
|
|
$CLICKHOUSE_CLIENT --query "INSERT INTO table_for_bad_alters VALUES(2, 2, 7)"
|
|
|
|
|
|
|
|
$CLICKHOUSE_CLIENT --query "SELECT distinct(value2) FROM table_for_bad_alters" 2>&1 | grep -o 'syntax error at begin of string.' | uniq
|
|
|
|
|
|
|
|
$CLICKHOUSE_CLIENT --query "ALTER TABLE table_for_bad_alters MODIFY COLUMN value2 String SETTINGS replication_alter_partitions_sync=2"
|
|
|
|
|
|
|
|
$CLICKHOUSE_CLIENT --query "INSERT INTO table_for_bad_alters VALUES(3, 3, 'World')"
|
|
|
|
|
|
|
|
$CLICKHOUSE_CLIENT --query "SELECT value2 FROM table_for_bad_alters ORDER BY value2"
|
|
|
|
|
|
|
|
$CLICKHOUSE_CLIENT --query "ALTER TABLE table_for_bad_alters DROP INDEX idx2" 2>&1 | grep -o 'Wrong index name.' | uniq
|
|
|
|
|
|
|
|
$CLICKHOUSE_CLIENT --query "DROP TABLE IF EXISTS table_for_bad_alters"
|