system sh/stop_dnodes.sh

system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 0
system sh/cfg.sh -n dnode1 -c tableMetaKeepTimer -v 3
system sh/exec.sh -n dnode1 -s start
sleep 500
sql connect

print ========== alter_stable.sim

$db = demodb
sql drop database if exists $db
sql create database $db
sql use $db

##### alter stable test : change tag name
# case-1  change tag name: new name inclue old name
sql create table mt1 (ts timestamp, c1 int) tags (a int)
sql alter table mt1 change tag a abcd
sql alter table mt1 change tag abcd a
sql_error alter table mt1 change tag a 1

sql_error create table mtx1 (ts timestamp, c1 int) tags (123 int)

sql create table mt2 (ts timestamp, c1 int) tags (abc012345678901234567890123456789012345678901234567890123456789def int)
sql create table mt3 (ts timestamp, c1 int) tags (abc012345678901234567890123456789012345678901234567890123456789 int)
sql_error alter table mt3 change tag abc012345678901234567890123456789012345678901234567890123456789 abcdefg012345678901234567890123456789012345678901234567890123456789
sql alter table mt3 change tag abc012345678901234567890123456789012345678901234567890123456789 abcdefg0123456789012345678901234567890123456789

# case-2 set tag value
sql create table mt4 (ts timestamp, c1 int) tags (name binary(16), len int)
sql create table tb1 using mt4 tags ("beijing", 100)
sql alter table tb1 set tag name = "shanghai"
sql alter table tb1 set tag name = ""
sql alter table tb1 set tag name = "shenzhen"
sql alter table tb1 set tag len = 379

# test end   
sql drop database $db

system sh/exec.sh -n dnode1 -s stop -x SIGINT