Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
15f028f8
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看板
未验证
提交
15f028f8
编写于
3月 22, 2022
作者:
X
Xiaoyu Wang
提交者:
GitHub
3月 22, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #10890 from taosdata/feature/3.0_wxy
TD-13757 bugfix
上级
ac282bdb
a73a79e7
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
49 addition
and
33 deletion
+49
-33
source/libs/parser/src/parInsert.c
source/libs/parser/src/parInsert.c
+10
-3
source/libs/parser/src/parTokenizer.c
source/libs/parser/src/parTokenizer.c
+2
-2
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+11
-1
tests/script/tsim/insert/basic0.sim
tests/script/tsim/insert/basic0.sim
+26
-27
未找到文件。
source/libs/parser/src/parInsert.c
浏览文件 @
15f028f8
...
...
@@ -28,6 +28,13 @@
pSql += index; \
} while (0)
#define NEXT_TOKEN_WITH_PREV(pSql, sToken) \
do { \
int32_t index = 0; \
sToken = tStrGetToken(pSql, &index, true); \
pSql += index; \
} while (0)
#define NEXT_TOKEN_KEEP_SQL(pSql, sToken, index) \
do { \
sToken = tStrGetToken(pSql, &index, false); \
...
...
@@ -352,7 +359,7 @@ static int parseTime(char **end, SToken *pToken, int16_t timePrec, int64_t *time
sToken
=
tStrGetToken
(
pTokenEnd
,
&
index
,
false
);
pTokenEnd
+=
index
;
if
(
sToken
.
type
==
TK_MINUS
||
sToken
.
type
==
TK_NK_PLUS
)
{
if
(
sToken
.
type
==
TK_
NK_
MINUS
||
sToken
.
type
==
TK_NK_PLUS
)
{
index
=
0
;
valueToken
=
tStrGetToken
(
pTokenEnd
,
&
index
,
false
);
pTokenEnd
+=
index
;
...
...
@@ -748,7 +755,7 @@ static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pTagsSchema,
SToken
sToken
;
char
tmpTokenBuf
[
TSDB_MAX_BYTES_PER_ROW
]
=
{
0
};
// used for deleting Escape character: \\, \', \"
for
(
int
i
=
0
;
i
<
pCxt
->
tags
.
numOfBound
;
++
i
)
{
NEXT_TOKEN
(
pCxt
->
pSql
,
sToken
);
NEXT_TOKEN
_WITH_PREV
(
pCxt
->
pSql
,
sToken
);
SSchema
*
pSchema
=
&
pTagsSchema
[
pCxt
->
tags
.
boundedColumns
[
i
]];
param
.
schema
=
pSchema
;
CHECK_CODE
(
parseValueToken
(
&
pCxt
->
pSql
,
&
sToken
,
pSchema
,
precision
,
tmpTokenBuf
,
KvRowAppend
,
&
param
,
&
pCxt
->
msg
));
...
...
@@ -814,7 +821,7 @@ static int parseOneRow(SInsertParseContext* pCxt, STableDataBlocks* pDataBlocks,
SToken
sToken
=
{
0
};
// 1. set the parsed value from sql string
for
(
int
i
=
0
;
i
<
spd
->
numOfBound
;
++
i
)
{
NEXT_TOKEN
(
pCxt
->
pSql
,
sToken
);
NEXT_TOKEN
_WITH_PREV
(
pCxt
->
pSql
,
sToken
);
SSchema
*
pSchema
=
&
schema
[
spd
->
boundedColumns
[
i
]
-
1
];
param
.
schema
=
pSchema
;
getMemRowAppendInfo
(
schema
,
pBuilder
->
rowType
,
spd
,
i
,
&
param
.
toffset
,
&
param
.
colIdx
);
...
...
source/libs/parser/src/parTokenizer.c
浏览文件 @
15f028f8
...
...
@@ -320,7 +320,7 @@ uint32_t tGetToken(const char* z, uint32_t* tokenId) {
*
tokenId
=
TK_NK_COMMENT
;
return
i
;
}
*
tokenId
=
TK_MINUS
;
*
tokenId
=
TK_
NK_
MINUS
;
return
1
;
}
case
'('
:
{
...
...
@@ -674,7 +674,7 @@ SToken tStrGetToken(const char* str, int32_t* i, bool isPrevOptr) {
}
else
{
// support parse the -/+number format
if
((
isPrevOptr
)
&&
(
t0
.
type
==
TK_MINUS
||
t0
.
type
==
TK_NK_PLUS
))
{
if
((
isPrevOptr
)
&&
(
t0
.
type
==
TK_
NK_
MINUS
||
t0
.
type
==
TK_NK_PLUS
))
{
len
=
tGetToken
(
&
str
[
*
i
+
t0
.
n
],
&
type
);
if
(
type
==
TK_NK_INTEGER
||
type
==
TK_NK_FLOAT
)
{
t0
.
type
=
type
;
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
15f028f8
...
...
@@ -873,12 +873,22 @@ static int32_t translateAlterDatabase(STranslateContext* pCxt, SAlterDatabaseStm
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
calcTypeBytes
(
SDataType
dt
)
{
if
(
TSDB_DATA_TYPE_BINARY
==
dt
.
type
)
{
return
dt
.
bytes
+
VARSTR_HEADER_SIZE
;
}
else
if
(
TSDB_DATA_TYPE_NCHAR
==
dt
.
type
)
{
return
dt
.
bytes
*
TSDB_NCHAR_SIZE
+
VARSTR_HEADER_SIZE
;
}
else
{
return
dt
.
bytes
;
}
}
static
int32_t
columnNodeToField
(
SNodeList
*
pList
,
SArray
**
pArray
)
{
*
pArray
=
taosArrayInit
(
LIST_LENGTH
(
pList
),
sizeof
(
SField
));
SNode
*
pNode
;
FOREACH
(
pNode
,
pList
)
{
SColumnDefNode
*
pCol
=
(
SColumnDefNode
*
)
pNode
;
SField
field
=
{
.
type
=
pCol
->
dataType
.
type
,
.
bytes
=
pCol
->
dataType
.
bytes
};
SField
field
=
{
.
type
=
pCol
->
dataType
.
type
,
.
bytes
=
calcTypeBytes
(
pCol
->
dataType
)
};
strcpy
(
field
.
name
,
pCol
->
colName
);
taosArrayPush
(
*
pArray
,
&
field
);
}
...
...
tests/script/tsim/insert/basic0.sim
浏览文件 @
15f028f8
...
...
@@ -42,9 +42,8 @@ sql insert into ct1 values(now+0s, 10, 2.0, 3.0)
sql insert into ct1 values(now+1s, 11, 2.1, 3.1)(now+2s, 12, 2.2, 3.2)(now+3s, 13, 2.3, 3.3)
sql insert into ct2 values(now+0s, 10, 2.0, 3.0)
sql insert into ct2 values(now+1s, 11, 2.1, 3.1)(now+2s, 12, 2.2, 3.2)(now+3s, 13, 2.3, 3.3)
# after fix bug, modify sql_error to sql
sql_error insert into ct1 values(now+4s, -14, -2.4, -3.4) ct2 values(now+4s, -14, -2.4, -3.4)
sql_error insert into ct1 values(now+5s, -15, -2.5, -3.5)(now+6s, -16, -2.6, -3.6) ct2 values(now+5s, -15, -2.5, -3.5)(now+6s, -16, -2.6, -3.6)
sql insert into ct1 values(now+4s, -14, -2.4, -3.4) ct2 values(now+4s, -14, -2.4, -3.4)
sql insert into ct1 values(now+5s, -15, -2.5, -3.5)(now+6s, -16, -2.6, -3.6) ct2 values(now+5s, -15, -2.5, -3.5)(now+6s, -16, -2.6, -3.6)
sql insert into ct3 values('2021-01-01 00:00:00.000', 10, 2.0, 3.0)
...
...
@@ -52,7 +51,7 @@ sql insert into ct3 values('2021-01-01 00:00:00.000', 10, 2.0, 3.0)
#===================================================================
print =============== query data from child table
sql select * from ct1
if $rows !=
4 then # after fix bug, modify 4 to 7
if $rows !=
7 then
return -1
endi
if $data01 != 10 then
...
...
@@ -82,23 +81,23 @@ if $rows != 1 then
endi
print $data00 $data01 $data02
if $data00 !=
4
then
if $data00 !=
7
then
return -1
endi
print =============== select count(column) from child table
sql select count(ts), count(c1), count(c2), count(c3) from ct1
print $data00 $data01 $data02 $data03
if $data00 !=
4
then
if $data00 !=
7
then
return -1
endi
if $data01 !=
4
then
if $data01 !=
7
then
return -1
endi
if $data02 !=
4
then
if $data02 !=
7
then
return -1
endi
if $data03 !=
4
then
if $data03 !=
7
then
return -1
endi
...
...
@@ -112,13 +111,13 @@ print $data00 $data01 $data02 $data03
if $rows != 1 then
return -1
endi
if $data00 !=
10
then
if $data00 !=
-16
then
return -1
endi
if $data01 !=
2.0
0000 then
if $data01 !=
-2.6
0000 then
return -1
endi
if $data02 !=
3.0
00000000 then
if $data02 !=
-3.6
00000000 then
return -1
endi
...
...
@@ -144,13 +143,13 @@ print $data00 $data01 $data02 $data03
if $rows != 1 then
return -1
endi
if $data00 !=
46
then
if $data00 !=
1
then
return -1
endi
if $data01 !=
8.5
99999905 then
if $data01 !=
1.0
99999905 then
return -1
endi
if $data02 !=
12.6
00000000 then
if $data02 !=
2.1
00000000 then
return -1
endi
...
...
@@ -232,7 +231,7 @@ system sh/exec.sh -n dnode1 -s start
sleep 2000
sql select * from ct1
if $rows !=
4 then # after fix bug, modify 4 to 7
if $rows !=
7 then
return -1
endi
if $data01 != 10 then
...
...
@@ -262,23 +261,23 @@ if $rows != 1 then
endi
print $data00 $data01 $data02
if $data00 !=
4
then
if $data00 !=
7
then
return -1
endi
print =============== select count(column) from child table
sql select count(ts), count(c1), count(c2), count(c3) from ct1
print $data00 $data01 $data02 $data03
if $data00 !=
4
then
if $data00 !=
7
then
return -1
endi
if $data01 !=
4
then
if $data01 !=
7
then
return -1
endi
if $data02 !=
4
then
if $data02 !=
7
then
return -1
endi
if $data03 !=
4
then
if $data03 !=
7
then
return -1
endi
...
...
@@ -292,13 +291,13 @@ print $data00 $data01 $data02 $data03
if $rows != 1 then
return -1
endi
if $data00 !=
10
then
if $data00 !=
-16
then
return -1
endi
if $data01 !=
2.0
0000 then
if $data01 !=
-2.6
0000 then
return -1
endi
if $data02 !=
3.0
00000000 then
if $data02 !=
-3.6
00000000 then
return -1
endi
...
...
@@ -324,13 +323,13 @@ print $data00 $data01 $data02 $data03
if $rows != 1 then
return -1
endi
if $data00 !=
46
then
if $data00 !=
1
then
return -1
endi
if $data01 !=
8.5
99999905 then
if $data01 !=
1.0
99999905 then
return -1
endi
if $data02 !=
12.6
00000000 then
if $data02 !=
2.1
00000000 then
return -1
endi
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录