system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2
system sh/exec.sh -n dnode1 -s start

sleep 100
sql connect
print ======================== dnode1 start

$db = testdb

sql create database $db
sql use $db

sql create stable st2 (ts timestamp, f1 int) tags (id int, t1 int, t2 nchar(4), t3 double)


sql insert into tb1 using st2 (id, t1) tags(1,2) values (now, 1)

sql select id,t1,t2,t3 from tb1

if $rows != 1 then
  return -1
endi

if $data00 != 1 then 
  return -1
endi
if $data01 != 2 then 
  return -1
endi
if $data02 != NULL then 
  return -1
endi
if $data03 != NULL then 
  return -1
endi

sql create table tb2 using st2 (t2,t3) tags ("12",22.0)

sql select id,t1,t2,t3 from tb2;

if $rows != 1 then
  return -1
endi

if $data00 != NULL then 
  return -1
endi
if $data01 != NULL then 
  return -1
endi
if $data02 != 12 then 
  return -1
endi
if $data03 != 22.000000000 then 
  return -1
endi


sql create table tb3 using st2 tags (1,2,"3",33.0);

sql select id,t1,t2,t3 from tb3;


if $rows != 1 then
  return -1
endi

if $data00 != 1 then 
  return -1
endi
if $data01 != 2 then 
  return -1
endi
if $data02 != 3 then 
  return -1
endi
if $data03 != 33.000000000 then 
  return -1
endi

sql insert into tb4 using st2 tags(1,2,"33",44.0) values (now, 1);

sql select id,t1,t2,t3 from tb4;

if $rows != 1 then
  return -1
endi

if $data00 != 1 then 
  return -1
endi
if $data01 != 2 then 
  return -1
endi
if $data02 != 33 then 
  return -1
endi
if $data03 != 44.000000000 then 
  return -1
endi

sql_error create table tb5 using st2() tags (3,3,"3",33.0);

sql_error create table tb6 using st2 (id,t1) tags (3,3,"3",33.0);

sql_error create table tb7 using st2 (id,t1) tags (3);

sql_error create table tb8 using st2 (ide) tags (3);

sql_error create table tb9 using st2 (id);

sql_error create table tb10 using st2 (id t1) tags (1,1);

sql_error create table tb10 using st2 (id,,t1) tags (1,1,1);

sql_error create table tb11 using st2 (id,t1,) tags (1,1,1);

sql create table tb12 using st2 (t1,id) tags (2,1);

sql select id,t1,t2,t3 from tb12;
if $rows != 1 then
  return -1
endi

if $data00 != 1 then 
  return -1
endi
if $data01 != 2 then 
  return -1
endi
if $data02 != NULL then 
  return -1
endi
if $data03 != NULL then 
  return -1
endi

sql create table tb13 using st2 ("t1",'id') tags (2,1);

sql select id,t1,t2,t3 from tb13;

if $rows != 1 then
  return -1
endi

if $data00 != 1 then 
  return -1
endi
if $data01 != 2 then 
  return -1
endi
if $data02 != NULL then 
  return -1
endi
if $data03 != NULL then 
  return -1
endi

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