Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e71466fd
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看板
提交
e71466fd
编写于
5月 08, 2020
作者:
H
hjxilinx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225] fix bugs for data bind insert
上级
3189c3dd
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
43 addition
and
37 deletion
+43
-37
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+19
-16
src/client/src/tscServer.c
src/client/src/tscServer.c
+1
-1
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+0
-1
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+1
-0
src/common/inc/tdataformat.h
src/common/inc/tdataformat.h
+4
-4
src/inc/taosdef.h
src/inc/taosdef.h
+2
-1
src/query/src/qtokenizer.c
src/query/src/qtokenizer.c
+4
-2
tests/script/general/parser/create_mt.sim
tests/script/general/parser/create_mt.sim
+11
-11
tests/script/general/parser/create_tb.sim
tests/script/general/parser/create_tb.sim
+1
-1
未找到文件。
src/client/src/tscParseInsert.c
浏览文件 @
e71466fd
...
@@ -305,10 +305,8 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SSQLToken *pToken, char *payload,
...
@@ -305,10 +305,8 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SSQLToken *pToken, char *payload,
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_BINARY
:
// binary data cannot be null-terminated char string, otherwise the last char of the string is lost
// binary data cannot be null-terminated char string, otherwise the last char of the string is lost
if
(
pToken
->
type
==
TK_NULL
)
{
if
(
pToken
->
type
==
TK_NULL
)
{
*
(
int16_t
*
)
payload
=
sizeof
(
int8_t
);
varDataSetLen
(
payload
,
sizeof
(
int8_t
));
payload
+=
VARSTR_HEADER_SIZE
;
*
(
uint8_t
*
)
varDataVal
(
payload
)
=
TSDB_DATA_BINARY_NULL
;
*
payload
=
TSDB_DATA_BINARY_NULL
;
}
else
{
// too long values will return invalid sql, not be truncated automatically
}
else
{
// too long values will return invalid sql, not be truncated automatically
if
(
pToken
->
n
+
VARSTR_HEADER_SIZE
>
pSchema
->
bytes
)
{
//todo refactor
if
(
pToken
->
n
+
VARSTR_HEADER_SIZE
>
pSchema
->
bytes
)
{
//todo refactor
return
tscInvalidSQLErrMsg
(
msg
,
"string data overflow"
,
pToken
->
z
);
return
tscInvalidSQLErrMsg
(
msg
,
"string data overflow"
,
pToken
->
z
);
...
@@ -321,22 +319,18 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SSQLToken *pToken, char *payload,
...
@@ -321,22 +319,18 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SSQLToken *pToken, char *payload,
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_NCHAR
:
if
(
pToken
->
type
==
TK_NULL
)
{
if
(
pToken
->
type
==
TK_NULL
)
{
*
(
int16_t
*
)
payload
=
sizeof
(
int32_t
);
varDataSetLen
(
payload
,
sizeof
(
int32_t
));
payload
+=
VARSTR_HEADER_SIZE
;
*
(
uint32_t
*
)
varDataVal
(
payload
)
=
TSDB_DATA_NCHAR_NULL
;
*
(
uint32_t
*
)
payload
=
TSDB_DATA_NCHAR_NULL
;
}
else
{
}
else
{
// if the converted output len is over than pColumnModel->bytes, return error: 'Argument list too long'
// if the converted output len is over than pColumnModel->bytes, return error: 'Argument list too long'
size_t
wcharLength
=
0
;
size_t
output
=
0
;
if
(
!
taosMbsToUcs4
(
pToken
->
z
,
pToken
->
n
,
payload
+
VARSTR_HEADER_SIZE
,
pSchema
->
bytes
-
VARSTR_HEADER_SIZE
,
if
(
!
taosMbsToUcs4
(
pToken
->
z
,
pToken
->
n
,
varDataVal
(
payload
),
pSchema
->
bytes
-
VARSTR_HEADER_SIZE
,
&
output
))
{
&
wcharLength
))
{
char
buf
[
512
]
=
{
0
};
char
buf
[
512
]
=
{
0
};
snprintf
(
buf
,
tListLen
(
buf
),
"%s"
,
strerror
(
errno
));
snprintf
(
buf
,
tListLen
(
buf
),
"%s"
,
strerror
(
errno
));
return
tscInvalidSQLErrMsg
(
msg
,
buf
,
pToken
->
z
);
return
tscInvalidSQLErrMsg
(
msg
,
buf
,
pToken
->
z
);
}
}
*
(
uint16_t
*
)
payload
=
(
uint16_t
)
(
wcharLength
);
varDataSetLen
(
payload
,
output
);
}
}
break
;
break
;
...
@@ -480,10 +474,19 @@ int tsParseOneRowData(char **str, STableDataBlocks *pDataBlocks, SSchema schema[
...
@@ -480,10 +474,19 @@ int tsParseOneRowData(char **str, STableDataBlocks *pDataBlocks, SSchema schema[
char
*
ptr
=
payload
;
char
*
ptr
=
payload
;
for
(
int32_t
i
=
0
;
i
<
spd
->
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
spd
->
numOfCols
;
++
i
)
{
if
(
!
spd
->
hasVal
[
i
])
{
// current column do not have any value to insert, set it to null
if
(
!
spd
->
hasVal
[
i
])
{
// current column do not have any value to insert, set it to null
setNull
(
ptr
,
schema
[
i
].
type
,
schema
[
i
].
bytes
);
if
(
schema
[
i
].
type
==
TSDB_DATA_TYPE_BINARY
)
{
varDataSetLen
(
ptr
,
sizeof
(
int8_t
));
*
(
uint8_t
*
)
varDataVal
(
ptr
)
=
TSDB_DATA_BINARY_NULL
;
}
else
if
(
schema
[
i
].
type
==
TSDB_DATA_TYPE_NCHAR
)
{
varDataSetLen
(
ptr
,
sizeof
(
int32_t
));
*
(
uint32_t
*
)
varDataVal
(
ptr
)
=
TSDB_DATA_NCHAR_NULL
;
}
else
{
setNull
(
ptr
,
schema
[
i
].
type
,
schema
[
i
].
bytes
);
}
}
}
ptr
+=
schema
[
i
].
bytes
;
ptr
+=
schema
[
i
].
bytes
;
}
}
...
@@ -1288,6 +1291,7 @@ int tsParseInsertSql(SSqlObj *pSql) {
...
@@ -1288,6 +1291,7 @@ int tsParseInsertSql(SSqlObj *pSql) {
pCmd
->
count
=
0
;
pCmd
->
count
=
0
;
pCmd
->
command
=
TSDB_SQL_INSERT
;
pCmd
->
command
=
TSDB_SQL_INSERT
;
pSql
->
res
.
numOfRows
=
0
;
SQueryInfo
*
pQueryInfo
=
NULL
;
SQueryInfo
*
pQueryInfo
=
NULL
;
tscGetQueryInfoDetailSafely
(
pCmd
,
pCmd
->
clauseIndex
,
&
pQueryInfo
);
tscGetQueryInfoDetailSafely
(
pCmd
,
pCmd
->
clauseIndex
,
&
pQueryInfo
);
...
@@ -1300,7 +1304,6 @@ int tsParseInsertSql(SSqlObj *pSql) {
...
@@ -1300,7 +1304,6 @@ int tsParseInsertSql(SSqlObj *pSql) {
return
tscInvalidSQLErrMsg
(
pCmd
->
payload
,
"keyword INTO is expected"
,
sToken
.
z
);
return
tscInvalidSQLErrMsg
(
pCmd
->
payload
,
"keyword INTO is expected"
,
sToken
.
z
);
}
}
pSql
->
res
.
numOfRows
=
0
;
return
doParseInsertSql
(
pSql
,
pSql
->
sqlstr
+
index
);
return
doParseInsertSql
(
pSql
,
pSql
->
sqlstr
+
index
);
}
}
...
...
src/client/src/tscServer.c
浏览文件 @
e71466fd
...
@@ -2419,7 +2419,7 @@ static int32_t getTableMetaFromMgmt(SSqlObj *pSql, STableMetaInfo *pTableMetaInf
...
@@ -2419,7 +2419,7 @@ static int32_t getTableMetaFromMgmt(SSqlObj *pSql, STableMetaInfo *pTableMetaInf
strncpy
(
pNewMeterMetaInfo
->
name
,
pTableMetaInfo
->
name
,
tListLen
(
pNewMeterMetaInfo
->
name
));
strncpy
(
pNewMeterMetaInfo
->
name
,
pTableMetaInfo
->
name
,
tListLen
(
pNewMeterMetaInfo
->
name
));
memcpy
(
pNew
->
cmd
.
payload
,
pSql
->
cmd
.
payload
,
TSDB_DEFAULT_PAYLOAD_SIZE
);
// tag information if table does not exists.
memcpy
(
pNew
->
cmd
.
payload
,
pSql
->
cmd
.
payload
,
TSDB_DEFAULT_PAYLOAD_SIZE
);
// tag information if table does not exists.
tscTrace
(
"%p new pSqlObj:%p to get tableMeta
"
,
pSql
,
pNew
);
tscTrace
(
"%p new pSqlObj:%p to get tableMeta
, auto create:%d"
,
pSql
,
pNew
,
pNew
->
cmd
.
autoCreated
);
pNew
->
fp
=
tscTableMetaCallBack
;
pNew
->
fp
=
tscTableMetaCallBack
;
pNew
->
param
=
pSql
;
pNew
->
param
=
pSql
;
...
...
src/client/src/tscSubquery.c
浏览文件 @
e71466fd
...
@@ -2024,7 +2024,6 @@ void **doSetResultRowData(SSqlObj *pSql, bool finalResult) {
...
@@ -2024,7 +2024,6 @@ void **doSetResultRowData(SSqlObj *pSql, bool finalResult) {
tExprTreeCalcTraverse
(
pRes
->
pArithSup
->
pArithExpr
->
pExpr
,
1
,
pRes
->
buffer
[
i
],
pRes
->
pArithSup
,
tExprTreeCalcTraverse
(
pRes
->
pArithSup
->
pArithExpr
->
pExpr
,
1
,
pRes
->
buffer
[
i
],
pRes
->
pArithSup
,
TSDB_ORDER_ASC
,
getArithemicInputSrc
);
TSDB_ORDER_ASC
,
getArithemicInputSrc
);
pRes
->
tsrow
[
i
]
=
pRes
->
buffer
[
i
];
pRes
->
tsrow
[
i
]
=
pRes
->
buffer
[
i
];
// free(sas); //todo optimization
}
}
}
}
...
...
src/client/src/tscUtil.c
浏览文件 @
e71466fd
...
@@ -357,6 +357,7 @@ void tscResetSqlCmdObj(SSqlCmd* pCmd) {
...
@@ -357,6 +357,7 @@ void tscResetSqlCmdObj(SSqlCmd* pCmd) {
pCmd
->
curSql
=
NULL
;
pCmd
->
curSql
=
NULL
;
pCmd
->
msgType
=
0
;
pCmd
->
msgType
=
0
;
pCmd
->
parseFinished
=
0
;
pCmd
->
parseFinished
=
0
;
pCmd
->
autoCreated
=
0
;
taosHashCleanup
(
pCmd
->
pTableList
);
taosHashCleanup
(
pCmd
->
pTableList
);
pCmd
->
pTableList
=
NULL
;
pCmd
->
pTableList
=
NULL
;
...
...
src/common/inc/tdataformat.h
浏览文件 @
e71466fd
...
@@ -28,16 +28,16 @@ extern "C" {
...
@@ -28,16 +28,16 @@ extern "C" {
#define STR_TO_VARSTR(x, str) do {VarDataLenT __len = strlen(str); \
#define STR_TO_VARSTR(x, str) do {VarDataLenT __len = strlen(str); \
*(VarDataLenT*)(x) = __len; \
*(VarDataLenT*)(x) = __len; \
strncpy(
(char*)(x) + VARSTR_HEADER_SIZE
, (str), __len);} while(0);
strncpy(
varDataVal(x)
, (str), __len);} while(0);
#define STR_WITH_MAXSIZE_TO_VARSTR(x, str, _maxs) do {\
#define STR_WITH_MAXSIZE_TO_VARSTR(x, str, _maxs) do {\
char* _e = stpncpy(
(char*)(x) + VARSTR_HEADER_SIZE
, (str), (_maxs));\
char* _e = stpncpy(
varDataVal(x)
, (str), (_maxs));\
*(VarDataLenT*)(x) = (_e - (x) - VARSTR_HEADER_SIZE
);\
varDataSetLen(x, (_e - (x) - VARSTR_HEADER_SIZE)
);\
} while(0)
} while(0)
#define STR_WITH_SIZE_TO_VARSTR(x, str, _size) do {\
#define STR_WITH_SIZE_TO_VARSTR(x, str, _size) do {\
*(VarDataLenT*)(x) = (_size); \
*(VarDataLenT*)(x) = (_size); \
strncpy(
(char*)(x) + VARSTR_HEADER_SIZE
, (str), (_size));\
strncpy(
varDataVal(x)
, (str), (_size));\
} while(0);
} while(0);
// ----------------- TSDB COLUMN DEFINITION
// ----------------- TSDB COLUMN DEFINITION
...
...
src/inc/taosdef.h
浏览文件 @
e71466fd
...
@@ -40,9 +40,10 @@ typedef int16_t VarDataLenT;
...
@@ -40,9 +40,10 @@ typedef int16_t VarDataLenT;
#define varDataLen(v) ((VarDataLenT *)(v))[0]
#define varDataLen(v) ((VarDataLenT *)(v))[0]
#define varDataTLen(v) (sizeof(VarDataLenT) + varDataLen(v))
#define varDataTLen(v) (sizeof(VarDataLenT) + varDataLen(v))
#define varDataVal(v) ((void *)((char *)v +
sizeof(VarDataLenT)
))
#define varDataVal(v) ((void *)((char *)v +
VARSTR_HEADER_SIZE
))
#define varDataCopy(dst, v) memcpy((dst), (void*) (v), varDataTLen(v))
#define varDataCopy(dst, v) memcpy((dst), (void*) (v), varDataTLen(v))
#define varDataLenByData(v) (*(VarDataLenT *)(((char*)(v)) - VARSTR_HEADER_SIZE))
#define varDataLenByData(v) (*(VarDataLenT *)(((char*)(v)) - VARSTR_HEADER_SIZE))
#define varDataSetLen(v, _len) (((VarDataLenT *)(v))[0] = (VarDataLenT) (_len))
// this data type is internally used only in 'in' query to hold the values
// 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 TSDB_DATA_TYPE_ARRAY (TSDB_DATA_TYPE_NCHAR + 1)
...
...
src/query/src/qtokenizer.c
浏览文件 @
e71466fd
...
@@ -268,11 +268,13 @@ int tSQLKeywordCode(const char* z, int n) {
...
@@ -268,11 +268,13 @@ int tSQLKeywordCode(const char* z, int n) {
pthread_once
(
&
keywordsHashTableInit
,
doInitKeywordsTable
);
pthread_once
(
&
keywordsHashTableInit
,
doInitKeywordsTable
);
char
key
[
512
]
=
{
0
};
char
key
[
512
]
=
{
0
};
assert
(
tListLen
(
key
)
>=
n
);
if
(
n
>
tListLen
(
key
))
{
// too long token, can not be any other token type
return
TK_ID
;
}
for
(
int32_t
j
=
0
;
j
<
n
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
n
;
++
j
)
{
if
(
z
[
j
]
>=
'a'
&&
z
[
j
]
<=
'z'
)
{
if
(
z
[
j
]
>=
'a'
&&
z
[
j
]
<=
'z'
)
{
key
[
j
]
=
(
char
)(
z
[
j
]
&
0xDF
);
// touppercase and set the null-terminated
key
[
j
]
=
(
char
)(
z
[
j
]
&
0xDF
);
// to
uppercase and set the null-terminated
}
else
{
}
else
{
key
[
j
]
=
z
[
j
];
key
[
j
]
=
z
[
j
];
}
}
...
...
tests/script/general/parser/create_mt.sim
浏览文件 @
e71466fd
...
@@ -172,8 +172,8 @@ sql create table $tb using $mt tags (-1)
...
@@ -172,8 +172,8 @@ sql create table $tb using $mt tags (-1)
# -x ng_tag_v
# -x ng_tag_v
# return -1
# return -1
#ng_tag_v:
#ng_tag_v:
sql
describe
$tb
sql
select tg from
$tb
if $data
23 != -1 then
if $data
00 != -1 then
return -1
return -1
endi
endi
sql drop table $tb
sql drop table $tb
...
@@ -182,9 +182,9 @@ sql drop table $tb
...
@@ -182,9 +182,9 @@ sql drop table $tb
print create_mt.sim unmatched_tag_types
print create_mt.sim unmatched_tag_types
sql reset query cache
sql reset query cache
sql create table $tb using $mt tags ('123')
sql create table $tb using $mt tags ('123')
sql
describe
$tb
sql
select tg from
$tb
#print data23 = $data23
print data00 = $data00
if $data
23
!= 123 then
if $data
00
!= 123 then
return -1
return -1
endi
endi
sql drop table $tb
sql drop table $tb
...
@@ -194,14 +194,14 @@ sql_error create table $tb using $mt tags ('abc')
...
@@ -194,14 +194,14 @@ sql_error create table $tb using $mt tags ('abc')
sql drop table if exists $tb
sql drop table if exists $tb
sql reset query cache
sql reset query cache
sql create table $tb using $mt tags (1e1)
sql create table $tb using $mt tags (1e1)
sql
describe
$tb
sql
select tg from
$tb
if $data
23
!= 10 then
if $data
00
!= 10 then
return -1
return -1
endi
endi
sql drop table $tb
sql drop table $tb
sql create table $tb using $mt tags ('1e1')
sql create table $tb using $mt tags ('1e1')
sql
describe
$tb
sql
select tg from
$tb
if $data
23
!= 10 then
if $data
00
!= 10 then
return -1
return -1
endi
endi
sql_error create table $tb using $mt tags (2147483649)
sql_error create table $tb using $mt tags (2147483649)
...
@@ -234,13 +234,13 @@ $mt2 = mt2
...
@@ -234,13 +234,13 @@ $mt2 = mt2
#if $data20 != $mt2 then
#if $data20 != $mt2 then
# return -1
# return -1
#endi
#endi
#sql
describe
$mt1
#sql
select tg from
$mt1
##print expected $CN_char
##print expected $CN_char
##print returned $data10
##print returned $data10
#if $data10 != $CN_char then
#if $data10 != $CN_char then
# return -1
# return -1
#endi
#endi
#sql
describe
$mt2
#sql
select tg from
$mt2
##print expected: $CN_char
##print expected: $CN_char
##print returned: $data20
##print returned: $data20
#if $data20 != $CN_char then
#if $data20 != $CN_char then
...
...
tests/script/general/parser/create_tb.sim
浏览文件 @
e71466fd
...
@@ -172,7 +172,7 @@ print ========== create_tb.sim case7: table_name_length_exceeds_limit
...
@@ -172,7 +172,7 @@ print ========== create_tb.sim case7: table_name_length_exceeds_limit
$tbname32 = _32_aaaabbbbccccddddaaaabbbbcccc
$tbname32 = _32_aaaabbbbccccddddaaaabbbbcccc
$tbname64 = _64_aaaabbbbccccddddaaaabbbbccccddddaaaabbbbccccddddaaaabbbbcccc
$tbname64 = _64_aaaabbbbccccddddaaaabbbbccccddddaaaabbbbccccddddaaaabbbbcccc
$tbname63 = _63_aaaabbbbccccddddaaaabbbbccccddddaaaabbbbccccddddaaaabbbbccc
$tbname63 = _63_aaaabbbbccccddddaaaabbbbccccddddaaaabbbbccccddddaaaabbbbccc
$tbname65 = _65_aaaabbbbccccddddaaaabbbbccccddddaaaabbbbccccddddaaaabbbbcccca
$tbname65 = _65_aaaabbbbccccddddaaaabbbbccccddddaaaabbbbccccddddaaaabbbbcccca
1111111111111111111111111111111111aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
sql create table $tbname32 (ts timestamp, col int)
sql create table $tbname32 (ts timestamp, col int)
sql insert into $tbname32 values (now, 1)
sql insert into $tbname32 values (now, 1)
sql create table $tbname64 (ts timestamp, col int)
sql create table $tbname64 (ts timestamp, col int)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录