diff --git a/src/cq/src/cqMain.c b/src/cq/src/cqMain.c index 13f3c0a2b0a0a75e07329a24f13ab0b9a274d3ac..769dfea774b86c9cd420edcd1b15d1020da3a67f 100644 --- a/src/cq/src/cqMain.c +++ b/src/cq/src/cqMain.c @@ -256,11 +256,30 @@ static void cqProcessStreamRes(void *param, TAOS_RES *tres, TAOS_ROW row) { SDataRow trow = (SDataRow)pBlk->data; tdInitDataRow(trow, pSchema); + union { + char buf[sizeof(int64_t)]; + tstr str; + } nullVal; + for (int32_t i = 0; i < pSchema->numOfCols; i++) { STColumn *c = pSchema->columns + i; char* val = (char*)row[i]; if (IS_VAR_DATA_TYPE(c->type)) { - val -= sizeof(VarDataLenT); + if (val == NULL) { + val = nullVal.buf; + if (c->type == TSDB_DATA_TYPE_BINARY) { + setNull(nullVal.str.data, TSDB_DATA_TYPE_BINARY, 1); + nullVal.str.len = 1; + } else { + setNull(nullVal.str.data, TSDB_DATA_TYPE_NCHAR, 4); + nullVal.str.len = 4; + } + } else { + val -= sizeof(VarDataLenT); + } + } else if (val == NULL) { + val = nullVal.buf; + setNull(val, c->type, c->bytes); } tdAppendColVal(trow, val, c->type, c->bytes, c->offset); } diff --git a/src/inc/taos.h b/src/inc/taos.h index bf6942be8b7ddff9ffff4af222fb5e938e63d096..9ac97a24e1d4bb695b4f1a30516b9799b6ad89eb 100644 --- a/src/inc/taos.h +++ b/src/inc/taos.h @@ -55,7 +55,7 @@ typedef enum { typedef struct taosField { char name[65]; uint8_t type; - short bytes; + uint16_t bytes; } TAOS_FIELD; #ifdef _TD_GO_DLL_ diff --git a/tests/script/general/parser/alter.sim b/tests/script/general/parser/alter.sim index 44c12fa968d52b7c6e3811d4997e549af3bba7bf..c30cc171bc519ef17928d2db722025149788a2f3 100644 --- a/tests/script/general/parser/alter.sim +++ b/tests/script/general/parser/alter.sim @@ -137,7 +137,7 @@ sleep 6000 sql insert into tb1 values (now, 2, 'taos') sleep 3000 sql select * from strm -if $rows != 1 then +if $rows != 2 then return -1 endi if $data04 != 1 then @@ -148,7 +148,7 @@ sleep 6000 sql insert into tb1 values (now, 3, 'taos', 3); sleep 3000 sql select * from strm -if $rows != 1 then +if $rows != 3 then return -1 endi if $data04 != 1 then @@ -188,9 +188,9 @@ sql create table tb using mt tags(1) sleep 3000 sql insert into tb values ('2018-11-01 16:30:00.000', 1, 'insert', 1) sql alter table mt drop column c3 -# the below query should be deleted after bug fix + sql insert into tb values ('2018-11-01 16:29:59.000', 1, 'insert') -sql_error import into tb values ('2018-11-01 16:29:59.000', 1, 'import') +sql import into tb values ('2018-11-01 16:29:59.000', 1, 'import') sql select * from tb order by ts desc if $data01 != 1 then return -1 @@ -203,13 +203,13 @@ sql select * from tb order by ts desc if $data03 != NULL then return -1 endi -# the query below should be deleted after bug fix + sql reset query cache sql insert into tb values ('2018-11-01 16:29:58.000', 2, 'import', 3) -sql_error import into tb values ('2018-11-01 16:29:58.000', 2, 'import', 3) +sql import into tb values ('2018-11-01 16:29:58.000', 2, 'import', 3) sql import into tb values ('2018-11-01 16:39:58.000', 2, 'import', 3) sql select * from tb order by ts desc -if $rows != 2 then +if $rows != 4 then return -1 endi if $data03 != 3 then