From ff25ab6b14ce5535219438e3a985aa101f7a9a9f Mon Sep 17 00:00:00 2001 From: Bomin Zhang Date: Wed, 17 Jun 2020 11:54:18 +0800 Subject: [PATCH] fix TD-645, TD-660 --- src/cq/src/cqMain.c | 21 ++++++++++++++++++++- src/inc/taos.h | 2 +- tests/script/general/parser/alter.sim | 14 +++++++------- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/cq/src/cqMain.c b/src/cq/src/cqMain.c index 13f3c0a2b0..769dfea774 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 bf6942be8b..9ac97a24e1 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 44c12fa968..c30cc171bc 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 -- GitLab