TDengine/tests/script/general/parser/alter1.sim

137 lines
2.4 KiB
Text
Raw Normal View History

2020-04-19 15:28:22 +00:00
system sh/stop_dnodes.sh
2020-04-29 09:30:03 +00:00
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
2020-04-19 15:28:22 +00:00
system sh/exec.sh -n dnode1 -s start
2021-01-09 06:25:54 +00:00
sleep 100
2020-04-19 15:28:22 +00:00
sql connect
sql reset query cache
$dbPrefix = alt1_db
print ========== alter1.sim
$db = $dbPrefix
sql drop database if exists $db
sql create database $db
sql use $db
sql create table stb (ts timestamp, speed double, mileage double) tags(carId int, carModel int)
sql create table car1 using stb tags (1, 1)
sql create table car2 using stb tags (2, 1)
sql create table car3 using stb tags (3, 2)
sql insert into car1 values (now-1s, 100, 10000)
sql insert into car2 values (now, 100, 10000)
sql insert into car3 values (now, 100, 10000)
sql insert into car1 values (now, 120, 11000)
print ================== add a column
sql alter table stb add column c1 int
sql describe stb
if $rows != 6 then
return -1
endi
sql select * from stb
print rows = $rows
if $rows != 4 then
return -1
endi
if $data03 != NULL then
2020-04-19 15:28:22 +00:00
return -1
endi
if $data13 != NULL then
2020-04-19 15:28:22 +00:00
return -1
endi
if $data23 != NULL then
2020-04-19 15:28:22 +00:00
return -1
endi
if $data33 != NULL then
2020-04-19 15:28:22 +00:00
return -1
endi
sql select c1 from stb
if $rows != 4 then
return -1
endi
if $data00 != NULL then
2020-04-19 15:28:22 +00:00
return -1
endi
if $data30 != NULL then
2020-04-19 15:28:22 +00:00
return -1
endi
sql select c1+speed from stb
if $rows != 4 then
return -1
endi
sql select c1+speed from car1
if $rows != 2 then
return -1
endi
if $data00 != NULL then
2020-04-19 15:28:22 +00:00
return -1
endi
if $data10 != NULL then
2020-04-19 15:28:22 +00:00
return -1
endi
sql select * from car1
if $rows != 2 then
return -1
endi
if $data03 != NULL then
2020-04-19 15:28:22 +00:00
return -1
endi
if $data13 != NULL then
2020-04-19 15:28:22 +00:00
return -1
endi
2021-01-09 06:25:54 +00:00
sleep 100
2020-04-19 15:28:22 +00:00
print ================== insert values into table
sql insert into car1 values (now, 1, 1,1 ) (now +1s, 2,2,2,) car2 values (now, 1,3,3)
sql select c1+speed from stb where c1 > 0
if $rows != 3 then
return -1
endi
print ================== add a tag
sql alter table stb add tag t1 int
sql describe stb
if $rows != 7 then
return -1
endi
if $data60 != t1 then
return -1
endi
print ================== change a tag value
sql alter table car1 set tag carid=10
2020-06-17 10:04:56 +00:00
sql select carId, carmodel from car1
if $rows != 1 then
2020-04-19 15:28:22 +00:00
return -1
endi
2020-06-17 10:04:56 +00:00
if $data00 != 10 then
2020-04-19 15:28:22 +00:00
return -1
endi
sql select * from stb where carid = 10
if $rows != 4 then
return -1
endi
sql alter table car2 set tag carmodel = 2
sql select * from stb where carmodel = 2
print $rows
if $rows != 3 then
return -1
endi
2021-04-25 03:04:46 +00:00
#sql drop database $db
#sql show databases
#if $rows != 0 then
# return -1
#endi