Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f6067e1b
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f6067e1b
编写于
5月 05, 2020
作者:
H
hjxilinx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-168] fix bug in var string handling
上级
64a2c841
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
54 addition
and
26 deletion
+54
-26
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+2
-1
src/client/src/tscAsync.c
src/client/src/tscAsync.c
+1
-1
src/client/src/tscSql.c
src/client/src/tscSql.c
+11
-2
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+2
-1
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+22
-13
src/common/inc/tdataformat.h
src/common/inc/tdataformat.h
+1
-1
src/dnode/src/dnodeWrite.c
src/dnode/src/dnodeWrite.c
+1
-1
src/inc/taos.h
src/inc/taos.h
+5
-3
src/inc/taosdef.h
src/inc/taosdef.h
+4
-1
src/kit/shell/src/shellEngine.c
src/kit/shell/src/shellEngine.c
+5
-2
未找到文件。
src/client/inc/tsclient.h
浏览文件 @
f6067e1b
...
...
@@ -280,6 +280,7 @@ typedef struct {
SResRec
*
pGroupRec
;
char
*
data
;
void
**
tsrow
;
int32_t
*
length
;
// length for each field for current row
char
**
buffer
;
// Buffer used to put multibytes encoded using unicode (wchar_t)
SColumnIndex
*
pColumnIndex
;
struct
SLocalReducer
*
pLocalReducer
;
...
...
@@ -421,7 +422,7 @@ int32_t tscInvalidSQLErrMsg(char *msg, const char *additionalInfo, const char *s
void
tscQueueAsyncFreeResult
(
SSqlObj
*
pSql
);
int32_t
tscToSQLCmd
(
SSqlObj
*
pSql
,
struct
SSqlInfo
*
pInfo
);
char
*
tscGetResultColumnChr
(
SSqlRes
*
pRes
,
SQueryInfo
*
pQueryInfo
,
int32_t
column
,
int16_t
bytes
);
void
tscGetResultColumnChr
(
SSqlRes
*
pRes
,
SFieldInfo
*
pFieldInfo
,
int32_t
column
);
extern
void
*
pVnodeConn
;
extern
void
*
tscCacheHandle
;
...
...
src/client/src/tscAsync.c
浏览文件 @
f6067e1b
...
...
@@ -317,7 +317,7 @@ void tscProcessFetchRow(SSchedMsg *pMsg) {
SFieldSupInfo
*
pSup
=
taosArrayGet
(
pQueryInfo
->
fieldsInfo
.
pSupportInfo
,
i
);
if
(
pSup
->
pSqlExpr
!=
NULL
)
{
pRes
->
tsrow
[
i
]
=
tscGetResultColumnChr
(
pRes
,
pQueryInfo
,
i
,
pSup
->
pSqlExpr
->
resBytes
);
tscGetResultColumnChr
(
pRes
,
&
pQueryInfo
->
fieldsInfo
,
i
);
}
else
{
// todo add
}
...
...
src/client/src/tscSql.c
浏览文件 @
f6067e1b
...
...
@@ -425,7 +425,7 @@ int taos_fetch_block_impl(TAOS_RES *res, TAOS_ROW *rows) {
assert
(
0
);
for
(
int
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
;
++
i
)
{
pRes
->
tsrow
[
i
]
=
tscGetResultColumnChr
(
pRes
,
pQueryInfo
,
i
,
0
);
tscGetResultColumnChr
(
pRes
,
&
pQueryInfo
->
fieldsInfo
,
i
);
}
*
rows
=
pRes
->
tsrow
;
...
...
@@ -725,6 +725,15 @@ char *taos_get_server_info(TAOS *taos) {
return
pObj
->
sversion
;
}
int
*
taos_fetch_lengths
(
TAOS_RES
*
res
)
{
SSqlObj
*
pSql
=
(
SSqlObj
*
)
res
;
if
(
pSql
==
NULL
||
pSql
->
signature
!=
pSql
)
{
return
NULL
;
}
return
pSql
->
res
.
length
;
}
char
*
taos_get_client_info
()
{
return
version
;
}
void
taos_stop_query
(
TAOS_RES
*
res
)
{
...
...
@@ -796,7 +805,7 @@ int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields)
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_NCHAR
:
{
size_t
xlen
=
0
;
for
(
xlen
=
0
;
xlen
<
=
fields
[
i
].
bytes
;
xlen
++
)
{
for
(
xlen
=
0
;
xlen
<
fields
[
i
].
bytes
-
VARSTR_HEADER_SIZE
;
xlen
++
)
{
char
c
=
((
char
*
)
row
[
i
])[
xlen
];
if
(
c
==
0
)
break
;
str
[
len
++
]
=
c
;
...
...
src/client/src/tscSubquery.c
浏览文件 @
f6067e1b
...
...
@@ -1849,6 +1849,7 @@ void tscBuildResFromSubqueries(SSqlObj *pSql) {
if
(
pRes
->
tsrow
==
NULL
)
{
pRes
->
tsrow
=
calloc
(
numOfExprs
,
POINTER_BYTES
);
pRes
->
length
=
calloc
(
numOfExprs
,
sizeof
(
int32_t
));
}
bool
success
=
false
;
...
...
@@ -1967,7 +1968,7 @@ void **doSetResultRowData(SSqlObj *pSql, bool finalResult) {
for
(
int
i
=
0
;
i
<
tscNumOfFields
(
pQueryInfo
);
++
i
)
{
SFieldSupInfo
*
pSup
=
tscFieldInfoGetSupp
(
&
pQueryInfo
->
fieldsInfo
,
i
);
if
(
pSup
->
pSqlExpr
!=
NULL
)
{
pRes
->
tsrow
[
i
]
=
tscGetResultColumnChr
(
pRes
,
pQueryInfo
,
i
,
pSup
->
pSqlExpr
->
resBytes
);
tscGetResultColumnChr
(
pRes
,
&
pQueryInfo
->
fieldsInfo
,
i
);
}
// primary key column cannot be null in interval query, no need to check
...
...
src/client/src/tscUtil.c
浏览文件 @
f6067e1b
...
...
@@ -210,7 +210,7 @@ bool tscNonOrderedProjectionQueryOnSTable(SQueryInfo* pQueryInfo, int32_t tableI
return
false
;
}
// order by column exists, not a non-ordered projection query
// order by column
Index
exists, not a non-ordered projection query
return
pQueryInfo
->
order
.
orderColId
<
0
;
}
...
...
@@ -219,7 +219,7 @@ bool tscOrderedProjectionQueryOnSTable(SQueryInfo* pQueryInfo, int32_t tableInde
return
false
;
}
// order by column exists, a non-ordered projection query
// order by column
Index
exists, a non-ordered projection query
return
pQueryInfo
->
order
.
orderColId
>=
0
;
}
...
...
@@ -286,13 +286,15 @@ int32_t tscCreateResPointerInfo(SSqlRes* pRes, SQueryInfo* pQueryInfo) {
int32_t
numOfOutput
=
pQueryInfo
->
fieldsInfo
.
numOfOutput
;
pRes
->
numOfCols
=
numOfOutput
;
pRes
->
tsrow
=
calloc
(
POINTER_BYTES
,
numOfOutput
);
pRes
->
buffer
=
calloc
(
POINTER_BYTES
,
numOfOutput
);
pRes
->
tsrow
=
calloc
(
numOfOutput
,
POINTER_BYTES
);
pRes
->
length
=
calloc
(
numOfOutput
,
sizeof
(
int32_t
));
// todo refactor
pRes
->
buffer
=
calloc
(
numOfOutput
,
POINTER_BYTES
);
// not enough memory
if
(
pRes
->
tsrow
==
NULL
||
(
pRes
->
buffer
==
NULL
&&
pRes
->
numOfCols
>
0
))
{
tfree
(
pRes
->
tsrow
);
tfree
(
pRes
->
buffer
);
tfree
(
pRes
->
length
);
pRes
->
code
=
TSDB_CODE_CLI_OUT_OF_MEMORY
;
return
pRes
->
code
;
...
...
@@ -312,6 +314,7 @@ void tscDestroyResPointerInfo(SSqlRes* pRes) {
tfree
(
pRes
->
pRsp
);
tfree
(
pRes
->
tsrow
);
tfree
(
pRes
->
length
);
tfree
(
pRes
->
pGroupRec
);
tfree
(
pRes
->
pColumnIndex
);
...
...
@@ -592,7 +595,7 @@ int32_t tscGetDataBlockFromList(void* pHashList, SDataBlockList* pDataBlockList,
}
static
int
trimDataBlock
(
void
*
pDataBlock
,
STableDataBlocks
*
pTableDataBlock
)
{
// TODO: optimize this function
// TODO: optimize this function
, handle the case while binary is not presented
int
len
=
0
;
STableMeta
*
pTableMeta
=
pTableDataBlock
->
pTableMeta
;
...
...
@@ -924,7 +927,7 @@ static SSqlExpr* doBuildSqlExpr(SQueryInfo* pQueryInfo, int16_t functionId, SCol
SSqlExpr
*
pExpr
=
calloc
(
1
,
sizeof
(
SSqlExpr
));
pExpr
->
functionId
=
functionId
;
// set the correct column index
// set the correct column
Index
index
if
(
pColIndex
->
columnIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
pExpr
->
colInfo
.
colId
=
TSDB_TBNAME_COLUMN_INDEX
;
}
else
{
...
...
@@ -1063,7 +1066,7 @@ void tscSqlExprCopy(SArray* dst, const SArray* src, uint64_t uid, bool deepcopy)
}
SColumn
*
tscColumnListInsert
(
SArray
*
pColumnList
,
SColumnIndex
*
pColIndex
)
{
// ignore the tbname column to be inserted into source list
// ignore the tbname column
Index
to be inserted into source list
if
(
pColIndex
->
columnIndex
<
0
)
{
return
NULL
;
}
...
...
@@ -2124,11 +2127,13 @@ void tscTryQueryNextClause(SSqlObj* pSql, void (*queryFp)()) {
}
}
char
*
tscGetResultColumnChr
(
SSqlRes
*
pRes
,
SQueryInfo
*
pQueryInfo
,
int32_t
column
,
int16_t
bytes
)
{
SField
Info
*
pFieldInfo
=
&
pQueryInfo
->
fieldsInfo
;
SFieldSupInfo
*
pInfo
=
tscFieldInfoGetSupp
(
pFieldInfo
,
column
);
void
tscGetResultColumnChr
(
SSqlRes
*
pRes
,
SFieldInfo
*
pFieldInfo
,
int32_t
columnIndex
)
{
SField
SupInfo
*
pInfo
=
tscFieldInfoGetSupp
(
pFieldInfo
,
columnIndex
)
;
assert
(
pInfo
->
pSqlExpr
!=
NULL
);
int32_t
type
=
pInfo
->
pSqlExpr
->
resType
;
int32_t
bytes
=
pInfo
->
pSqlExpr
->
resBytes
;
char
*
pData
=
((
char
*
)
pRes
->
data
)
+
pInfo
->
pSqlExpr
->
offset
*
pRes
->
numOfRows
+
bytes
*
pRes
->
row
;
if
(
type
==
TSDB_DATA_TYPE_NCHAR
||
type
==
TSDB_DATA_TYPE_BINARY
)
{
...
...
@@ -2137,9 +2142,13 @@ char* tscGetResultColumnChr(SSqlRes* pRes, SQueryInfo* pQueryInfo, int32_t colum
*
(
char
*
)
(
pData
+
realLen
+
VARSTR_HEADER_SIZE
)
=
0
;
}
return
pData
+
VARSTR_HEADER_SIZE
;
// head is the length of binary/nchar data
pRes
->
tsrow
[
columnIndex
]
=
pData
+
VARSTR_HEADER_SIZE
;
pRes
->
length
[
columnIndex
]
=
realLen
;
}
else
{
return
pData
;
assert
(
bytes
==
tDataTypeDesc
[
type
].
nSize
);
pRes
->
tsrow
[
columnIndex
]
=
pData
;
pRes
->
length
[
columnIndex
]
=
bytes
;
}
}
src/common/inc/tdataformat.h
浏览文件 @
f6067e1b
...
...
@@ -32,7 +32,7 @@ extern "C" {
#define STR_WITH_MAXSIZE_TO_VARSTR(x, str, _maxs) do {\
char* _e = stpncpy((char*)(x) + VARSTR_HEADER_SIZE, (str), (_maxs));\
*(VarDataLenT*)(x) =
_e - (x
);\
*(VarDataLenT*)(x) =
(_e - (x) - VARSTR_HEADER_SIZE
);\
} while(0)
#define STR_WITH_SIZE_TO_VARSTR(x, str, _size) do {\
...
...
src/dnode/src/dnodeWrite.c
浏览文件 @
f6067e1b
...
...
@@ -228,7 +228,7 @@ static void dnodeHandleIdleWorker(SWriteWorker *pWorker) {
int32_t
num
=
taosGetQueueNumber
(
pWorker
->
qset
);
if
(
num
>
0
)
{
usleep
(
30
);
usleep
(
30
000
);
sched_yield
();
}
else
{
taosFreeQall
(
pWorker
->
qall
);
...
...
src/inc/taos.h
浏览文件 @
f6067e1b
...
...
@@ -53,9 +53,9 @@ typedef enum {
}
TSDB_OPTION
;
typedef
struct
taosField
{
char
name
[
64
];
short
bytes
;
char
type
;
char
name
[
64
];
short
bytes
;
uint8_t
type
;
}
TAOS_FIELD
;
#ifdef _TD_GO_DLL_
...
...
@@ -104,6 +104,8 @@ DLL_EXPORT void taos_stop_query(TAOS_RES *res);
int
taos_fetch_block
(
TAOS_RES
*
res
,
TAOS_ROW
*
rows
);
int
taos_validate_sql
(
TAOS
*
taos
,
const
char
*
sql
);
int
*
taos_fetch_lengths
(
TAOS_RES
*
res
);
// TAOS_RES *taos_list_tables(TAOS *mysql, const char *wild);
// TAOS_RES *taos_list_dbs(TAOS *mysql, const char *wild);
...
...
src/inc/taosdef.h
浏览文件 @
f6067e1b
...
...
@@ -36,14 +36,17 @@ extern "C" {
typedef
int32_t
VarDataOffsetT
;
typedef
int16_t
VarDataLenT
;
#define VARSTR_HEADER_SIZE sizeof(VarDataLenT)
#define varDataLen(v) ((VarDataLenT *)(v))[0]
#define varDataTLen(v) (sizeof(VarDataLenT) + varDataLen(v))
#define varDataVal(v) ((void *)((char *)v + sizeof(VarDataLenT)))
#define varDataCopy(dst, v) memcpy((dst), (void*) (v), varDataTLen(v))
#define varDataLenByData(v) (*(VarDataLenT *)(((char*)(v)) - VARSTR_HEADER_SIZE))
// this data type is internally used only in 'in' query to hold the values
#define TSDB_DATA_TYPE_ARRAY (TSDB_DATA_TYPE_NCHAR + 1)
#define VARSTR_HEADER_SIZE sizeof(VarDataLenT)
// Bytes for each type.
extern
const
int32_t
TYPE_BYTES
[
11
];
...
...
src/kit/shell/src/shellEngine.c
浏览文件 @
f6067e1b
...
...
@@ -350,6 +350,8 @@ int shellDumpResult(TAOS *con, char *fname, int *error_no, bool printMode) {
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
result
);
row
=
taos_fetch_row
(
result
);
int32_t
*
length
=
taos_fetch_lengths
(
result
);
char
t_str
[
TSDB_MAX_BYTES_PER_ROW
]
=
"
\0
"
;
int
l
[
TSDB_MAX_COLUMNS
]
=
{
0
};
int
maxLenColumnName
=
0
;
...
...
@@ -457,7 +459,7 @@ int shellDumpResult(TAOS *con, char *fname, int *error_no, bool printMode) {
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_NCHAR
:
memset
(
t_str
,
0
,
TSDB_MAX_BYTES_PER_ROW
);
memcpy
(
t_str
,
row
[
i
],
fields
[
i
].
bytes
);
memcpy
(
t_str
,
row
[
i
],
length
[
i
]
);
/* printf("%-*s|",max(fields[i].bytes, strlen(fields[i].name)),
* t_str); */
/* printf("%-*s|", l[i], t_str); */
...
...
@@ -532,7 +534,8 @@ int shellDumpResult(TAOS *con, char *fname, int *error_no, bool printMode) {
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_NCHAR
:
memset
(
t_str
,
0
,
TSDB_MAX_BYTES_PER_ROW
);
memcpy
(
t_str
,
row
[
i
],
fields
[
i
].
bytes
);
memcpy
(
t_str
,
row
[
i
],
length
[
i
]);
l
[
i
]
=
MAX
(
fields
[
i
].
bytes
,
strlen
(
fields
[
i
].
name
));
shellPrintNChar
(
t_str
,
l
[
i
],
printMode
);
break
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录