column_add.sim 5.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect

print ========== prepare stb and ctb
sql create database db vgroups 1
sql create table db.stb (ts timestamp, c1 int, c2 binary(4)) tags(t1 int, t2 float, t3 binary(16)) comment "abd"
sql create table db.ctb using db.stb tags(101, 102, "103")
sql insert into db.ctb values(now, 1, "2")

X
Xiaoyu Wang 已提交
12
sql select * from information_schema.ins_stables where db_name = 'db'
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
if $rows != 1 then
  return -1
endi
if $data[0][0] != stb then
  return -1
endi
if $data[0][1] != db then
  return -1
endi
if $data[0][3] != 3 then
  return -1
endi
if $data[0][4] != 3 then
  return -1
endi
if $data[0][6] != abd then
  return -1
endi

X
Xiaoyu Wang 已提交
32
sql select * from information_schema.ins_tables where db_name = 'db'
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
if $rows != 1 then
  return -1
endi
if $data[0][0] != ctb then
  return -1
endi
if $data[0][1] != db then
  return -1
endi
if $data[0][3] != 3 then
  return -1
endi
if $data[0][4] != stb then
  return -1
endi
if $data[0][6] != 2 then
  return -1
endi
if $data[0][9] != CHILD_TABLE then
  return -1
endi

sql select * from db.stb
if $rows != 1 then
  return -1
endi
if $data[0][1] != 1 then
  return -1
endi
if $data[0][2] != 2 then
  return -1
endi
if $data[0][3] != 101 then
  return -1
endi

sql_error alter table db.stb add column ts int
sql_error alter table db.stb add column t1 int
sql_error alter table db.stb add column t2 int
sql_error alter table db.stb add column t3 int
sql_error alter table db.stb add column c1 int

print ========== step1 add column c3
sql alter table db.stb add column c3 int
X
Xiaoyu Wang 已提交
77
sql select * from information_schema.ins_stables where db_name = 'db'
78 79 80 81
if $data[0][3] != 4 then
  return -1
endi

X
Xiaoyu Wang 已提交
82
sql select * from information_schema.ins_tables where db_name = 'db'
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
if $data[0][3] != 4 then
  return -1
endi

sql select * from db.stb
sql select * from db.stb
print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6]
if $rows != 1 then
  return -1
endi
if $data[0][1] != 1 then
  return -1
endi
if $data[0][2] != 2 then
  return -1
endi
if $data[0][3] != NULL then
  return -1
endi
if $data[0][4] != 101 then
  return -1
endi

sql insert into db.ctb values(now+1s, 1, 2, 3)
sql select * from db.stb
print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6]
print $data[1][0] $data[1][1] $data[1][2] $data[1][3] $data[1][4] $data[1][5] $data[1][6]

if $rows != 2 then
  return -1
endi
if $data[0][1] != 1 then
  return -1
endi
if $data[0][2] != 2 then
  return -1
G
Ganlin Zhao 已提交
119
endi
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
if $data[0][3] != NULL then
  return -1
endi
if $data[0][4] != 101 then
  return -1
endi
if $data[1][1] != 1 then
  return -1
endi
if $data[1][2] != 2 then
  return -1
endi
if $data[1][3] != 3 then
  return -1
endi
if $data[1][4] != 101 then
  return -1
endi

print ========== step2 add column c4
sql alter table db.stb add column c4 bigint
sql select * from db.stb
sql insert into db.ctb values(now+2s, 1, 2, 3, 4)
sql select * from db.stb
print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6]
print $data[1][0] $data[1][1] $data[1][2] $data[1][3] $data[1][4] $data[1][5] $data[1][6]
146
print $data[2][0] $data[2][1] $data[2][2] $data[2][3] $data[2][4] $data[2][5] $data[2][6]
147 148 149 150 151 152 153 154 155

if $rows != 3 then
  return -1
endi
if $data[0][1] != 1 then
  return -1
endi
if $data[0][2] != 2 then
  return -1
G
Ganlin Zhao 已提交
156
endi
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301
if $data[0][3] != NULL then
  return -1
endi
if $data[0][4] != NULL then
  return -1
endi
if $data[0][5] != 101 then
  return -1
endi
if $data[1][1] != 1 then
  return -1
endi
if $data[1][2] != 2 then
  return -1
endi
if $data[1][3] != 3 then
  return -1
endi
if $data[1][4] != NULL then
  return -1
endi
if $data[1][5] != 101 then
  return -1
endi
if $data[2][1] != 1 then
  return -1
endi
if $data[2][2] != 2 then
  return -1
endi
if $data[2][3] != 3 then
  return -1
endi
if $data[2][4] != 4 then
  return -1
endi
if $data[2][5] != 101 then
  return -1
endi

print ========== step3 add column c5
sql alter table db.stb add column c5 int
sql insert into db.ctb values(now+3s, 1, 2, 3, 4, 5)
sql select * from db.stb
print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6]
print $data[1][0] $data[1][1] $data[1][2] $data[1][3] $data[1][4] $data[1][5] $data[1][6]
print $data[2][0] $data[2][1] $data[2][2] $data[2][3] $data[2][4] $data[2][5] $data[2][6]

if $rows != 4 then
  return -1
endi
if $data[2][1] != 1 then
  return -1
endi
if $data[2][2] != 2 then
  return -1
endi
if $data[2][3] != 3 then
  return -1
endi
if $data[2][4] != 4 then
  return -1
endi
if $data[2][5] != NULL then
  return -1
endi
if $data[2][6] != 101 then
  return -1
endi
if $data[3][1] != 1 then
  return -1
endi
if $data[3][2] != 2 then
  return -1
endi
if $data[3][3] != 3 then
  return -1
endi
if $data[3][4] != 4 then
  return -1
endi
if $data[3][5] != 5 then
  return -1
endi
if $data[3][6] != 101 then
  return -1
endi

print ========== step4 add column c6
sql alter table db.stb add column c6 int
sql insert into db.ctb values(now+4s, 1, 2, 3, 4, 5, 6)
sql select * from db.stb

if $rows != 5 then
  return -1
endi
if $data[3][1] != 1 then
  return -1
endi
if $data[3][2] != 2 then
  return -1
endi
if $data[3][3] != 3 then
  return -1
endi
if $data[3][4] != 4 then
  return -1
endi
if $data[3][5] != 5 then
  return -1
endi
if $data[3][6] != NULL then
  return -1
endi
if $data[3][7] != 101 then
  return -1
endi
if $data[4][1] != 1 then
  return -1
endi
if $data[4][2] != 2 then
  return -1
endi
if $data[4][3] != 3 then
  return -1
endi
if $data[4][4] != 4 then
  return -1
endi
if $data[4][5] != 5 then
  return -1
endi
if $data[4][6] != 6 then
  return -1
endi
if $data[4][7] != 101 then
  return -1
endi

print ========== step5 describe
sql describe db.ctb
if $rows != 10 then
  return -1
endi

G
Ganlin Zhao 已提交
302
system sh/exec.sh -n dnode1 -s stop -x SIGINT