From 654f5aad26ad8e0c76938e08a6fb232862343f3a Mon Sep 17 00:00:00 2001 From: liu0x54 Date: Tue, 16 Jun 2020 10:08:49 +0000 Subject: [PATCH 1/2] for pass pytest --- tests/pytest/random-test/random-test.py | 11 +++++------ tests/pytest/util/sql.py | 18 ++++++++++++++---- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/tests/pytest/random-test/random-test.py b/tests/pytest/random-test/random-test.py index 5eb356960a..1bb924507d 100644 --- a/tests/pytest/random-test/random-test.py +++ b/tests/pytest/random-test/random-test.py @@ -17,6 +17,7 @@ from util.log import * from util.cases import * from util.sql import * from util.dnodes import * +import codecs class Test: @@ -93,13 +94,11 @@ class Test: self.last_stb = current_stb current_tb = "tb%d" % int(round(time.time() * 1000)) - tdSql.execute( - "create table %s using %s tags (1, '表1')" % - (current_tb, self.last_stb)) + sqlcmd = "create table %s using %s tags (1, 'test')" %(current_tb, self.last_stb) + tdSql.execute(sqlcmd) self.last_tb = current_tb - tdSql.execute( - "insert into %s values (now, 27, '我是nchar字符串')" % - self.last_tb) + sqlcmd = "insert into %s values (now, 27, 'testnchar')" % self.last_tb + tdSql.execute(sqlcmd) self.written = self.written + 1 def drop_stable(self): diff --git a/tests/pytest/util/sql.py b/tests/pytest/util/sql.py index 367217cd49..1fb09b3601 100644 --- a/tests/pytest/util/sql.py +++ b/tests/pytest/util/sql.py @@ -40,10 +40,18 @@ class TDSql: def prepare(self): tdLog.info("prepare database:db") - self.cursor.execute('reset query cache') - self.cursor.execute('drop database if exists db') - self.cursor.execute('create database db') - self.cursor.execute('use db') + s = 'reset query cache' + print(s) + self.cursor.execute(s) + s = 'drop database if exists db' + print(s) + self.cursor.execute(s) + s = 'create database db' + print(s) + self.cursor.execute(s) + s = 'use db' + print(s) + self.cursor.execute(s) def error(self, sql): expectErrNotOccured = True @@ -66,6 +74,7 @@ class TDSql: def query(self, sql): self.sql = sql + print(sql) self.cursor.execute(sql) self.queryResult = self.cursor.fetchall() self.queryRows = len(self.queryResult) @@ -182,6 +191,7 @@ class TDSql: def execute(self, sql): self.sql = sql + print(sql) self.affectedRows = self.cursor.execute(sql) return self.affectedRows From b986843d7d7b84a816e05aac59361ac7f0da73ab Mon Sep 17 00:00:00 2001 From: liu0x54 Date: Wed, 17 Jun 2020 11:01:00 +0000 Subject: [PATCH 2/2] [TD-657] fix describe the table bugs --- src/client/src/tscLocal.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/client/src/tscLocal.c b/src/client/src/tscLocal.c index a880f4487e..b1a6e1595e 100644 --- a/src/client/src/tscLocal.c +++ b/src/client/src/tscLocal.c @@ -183,8 +183,12 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) { // type length int32_t bytes = pSchema[i].bytes; pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, 2); - if (pSchema[i].type == TSDB_DATA_TYPE_NCHAR) { - bytes = bytes / TSDB_NCHAR_SIZE; + if (pSchema[i].type == TSDB_DATA_TYPE_BINARY || pSchema[i].type == TSDB_DATA_TYPE_NCHAR) { + bytes -= VARSTR_HEADER_SIZE; + + if (pSchema[i].type == TSDB_DATA_TYPE_NCHAR) { + bytes = bytes / TSDB_NCHAR_SIZE; + } } *(int32_t *)(pRes->data + tscFieldInfoGetOffset(pQueryInfo, 2) * totalNumOfRows + pField->bytes * i) = bytes;