未验证 提交 75bc8d4c 编写于 作者: S Shengliang Guan 提交者: GitHub

Merge pull request #2327 from taosdata/feature/pyconn

Feature/pyconn: fix describe tables bugs which will cause the wrong length info of binary/nchar
...@@ -183,8 +183,12 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) { ...@@ -183,8 +183,12 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
// type length // type length
int32_t bytes = pSchema[i].bytes; int32_t bytes = pSchema[i].bytes;
pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, 2); pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, 2);
if (pSchema[i].type == TSDB_DATA_TYPE_NCHAR) { if (pSchema[i].type == TSDB_DATA_TYPE_BINARY || pSchema[i].type == TSDB_DATA_TYPE_NCHAR) {
bytes = bytes / TSDB_NCHAR_SIZE; 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; *(int32_t *)(pRes->data + tscFieldInfoGetOffset(pQueryInfo, 2) * totalNumOfRows + pField->bytes * i) = bytes;
......
...@@ -17,6 +17,7 @@ from util.log import * ...@@ -17,6 +17,7 @@ from util.log import *
from util.cases import * from util.cases import *
from util.sql import * from util.sql import *
from util.dnodes import * from util.dnodes import *
import codecs
class Test: class Test:
...@@ -93,14 +94,13 @@ class Test: ...@@ -93,14 +94,13 @@ class Test:
self.last_stb = current_stb self.last_stb = current_stb
current_tb = "tb%d" % int(round(time.time() * 1000)) current_tb = "tb%d" % int(round(time.time() * 1000))
tdSql.execute( sqlcmd = "create table %s using %s tags (1, 'test')" %(current_tb, self.last_stb)
"create table %s using %s tags (1, '表1')" % tdSql.execute(sqlcmd)
(current_tb, self.last_stb))
self.last_tb = current_tb self.last_tb = current_tb
self.written = 0 self.written = 0
tdSql.execute( tdSql.execute(
"insert into %s values (now, 27, '我是nchar字符串')" % "insert into %s values (now, 27, 'wsnchar')" %
self.last_tb) self.last_tb)
self.written = self.written + 1 self.written = self.written + 1
......
...@@ -40,10 +40,18 @@ class TDSql: ...@@ -40,10 +40,18 @@ class TDSql:
def prepare(self): def prepare(self):
tdLog.info("prepare database:db") tdLog.info("prepare database:db")
self.cursor.execute('reset query cache') s = 'reset query cache'
self.cursor.execute('drop database if exists db') print(s)
self.cursor.execute('create database db') self.cursor.execute(s)
self.cursor.execute('use db') 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): def error(self, sql):
expectErrNotOccured = True expectErrNotOccured = True
...@@ -66,6 +74,7 @@ class TDSql: ...@@ -66,6 +74,7 @@ class TDSql:
def query(self, sql): def query(self, sql):
self.sql = sql self.sql = sql
print(sql)
self.cursor.execute(sql) self.cursor.execute(sql)
self.queryResult = self.cursor.fetchall() self.queryResult = self.cursor.fetchall()
self.queryRows = len(self.queryResult) self.queryRows = len(self.queryResult)
...@@ -182,6 +191,7 @@ class TDSql: ...@@ -182,6 +191,7 @@ class TDSql:
def execute(self, sql): def execute(self, sql):
self.sql = sql self.sql = sql
print(sql)
self.affectedRows = self.cursor.execute(sql) self.affectedRows = self.cursor.execute(sql)
return self.affectedRows return self.affectedRows
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册