Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
115160bb
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看板
提交
115160bb
编写于
2月 05, 2023
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: insert syntax error
上级
2a7732b1
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
40 addition
and
25 deletion
+40
-25
source/libs/parser/inc/parInsertUtil.h
source/libs/parser/inc/parInsertUtil.h
+5
-5
source/libs/parser/inc/parToken.h
source/libs/parser/inc/parToken.h
+1
-1
source/libs/parser/src/parInsertSql.c
source/libs/parser/src/parInsertSql.c
+27
-16
source/libs/parser/src/parTokenizer.c
source/libs/parser/src/parTokenizer.c
+5
-1
source/libs/parser/src/parser.c
source/libs/parser/src/parser.c
+2
-2
未找到文件。
source/libs/parser/inc/parInsertUtil.h
浏览文件 @
115160bb
...
...
@@ -22,11 +22,11 @@ struct SToken;
#define IS_DATA_COL_ORDERED(spd) ((spd->orderStatus) == (int8_t)ORDER_STATUS_ORDERED)
#define NEXT_TOKEN(pSql, sToken) \
do { \
int32_t index = 0; \
sToken = tStrGetToken(pSql, &index, false); \
pSql += index; \
#define NEXT_TOKEN(pSql, sToken)
\
do {
\
int32_t index = 0;
\
sToken = tStrGetToken(pSql, &index, false
, NULL
); \
pSql += index;
\
} while (0)
#define CHECK_CODE(expr) \
...
...
source/libs/parser/inc/parToken.h
浏览文件 @
115160bb
...
...
@@ -55,7 +55,7 @@ uint32_t tGetToken(const char *z, uint32_t *tokenType);
* @param isPrevOptr
* @return
*/
SToken
tStrGetToken
(
const
char
*
str
,
int32_t
*
i
,
bool
isPrevOptr
);
SToken
tStrGetToken
(
const
char
*
str
,
int32_t
*
i
,
bool
isPrevOptr
,
bool
*
pIgnoreComma
);
/**
* check if it is a keyword or not
...
...
source/libs/parser/src/parInsertSql.c
浏览文件 @
115160bb
...
...
@@ -18,16 +18,23 @@
#include "tglobal.h"
#include "ttime.h"
#define NEXT_TOKEN_WITH_PREV(pSql, token) \
do { \
int32_t index = 0; \
token = tStrGetToken(pSql, &index, true); \
pSql += index; \
#define NEXT_TOKEN_WITH_PREV(pSql, token)
\
do {
\
int32_t index = 0;
\
token = tStrGetToken(pSql, &index, true
, NULL
); \
pSql += index;
\
} while (0)
#define NEXT_TOKEN_KEEP_SQL(pSql, token, index) \
do { \
token = tStrGetToken(pSql, &index, false); \
#define NEXT_TOKEN_WITH_PREV_EXT(pSql, token, pIgnoreComma) \
do { \
int32_t index = 0; \
token = tStrGetToken(pSql, &index, true, pIgnoreComma); \
pSql += index; \
} while (0)
#define NEXT_TOKEN_KEEP_SQL(pSql, token, index) \
do { \
token = tStrGetToken(pSql, &index, false, NULL); \
} while (0)
#define NEXT_VALID_TOKEN(pSql, token) \
...
...
@@ -302,12 +309,12 @@ static int parseTime(const char** end, SToken* pToken, int16_t timePrec, int64_t
* e.g., now+12a, now-5h
*/
index
=
0
;
SToken
token
=
tStrGetToken
(
pTokenEnd
,
&
index
,
false
);
SToken
token
=
tStrGetToken
(
pTokenEnd
,
&
index
,
false
,
NULL
);
pTokenEnd
+=
index
;
if
(
token
.
type
==
TK_NK_MINUS
||
token
.
type
==
TK_NK_PLUS
)
{
index
=
0
;
SToken
valueToken
=
tStrGetToken
(
pTokenEnd
,
&
index
,
false
);
SToken
valueToken
=
tStrGetToken
(
pTokenEnd
,
&
index
,
false
,
NULL
);
pTokenEnd
+=
index
;
if
(
valueToken
.
n
<
2
)
{
...
...
@@ -1240,10 +1247,14 @@ static int parseOneRow(SInsertParseContext* pCxt, const char** pSql, STableDataB
int32_t
code
=
tdSRowResetBuf
(
pBuilder
,
row
);
// 1. set the parsed value from sql string
for
(
int
i
=
0
;
i
<
pCols
->
numOfBound
&&
TSDB_CODE_SUCCESS
==
code
;
++
i
)
{
NEXT_TOKEN_WITH_PREV
(
*
pSql
,
*
pToken
);
SSchema
*
pSchema
=
&
pSchemas
[
pCols
->
boundColumns
[
i
]];
const
char
*
pOrigSql
=
*
pSql
;
bool
ignoreComma
=
false
;
NEXT_TOKEN_WITH_PREV_EXT
(
*
pSql
,
*
pToken
,
&
ignoreComma
);
if
(
ignoreComma
)
{
code
=
buildSyntaxErrMsg
(
&
pCxt
->
msg
,
"invalid data or symbol"
,
pOrigSql
);
}
if
(
pToken
->
type
==
TK_NK_QUESTION
)
{
if
(
TSDB_CODE_SUCCESS
==
code
&&
pToken
->
type
==
TK_NK_QUESTION
)
{
isParseBindParam
=
true
;
if
(
NULL
==
pCxt
->
pComCxt
->
pStmtCb
)
{
code
=
buildSyntaxErrMsg
(
&
pCxt
->
msg
,
"? only used in stmt"
,
pToken
->
z
);
...
...
@@ -1260,10 +1271,10 @@ static int parseOneRow(SInsertParseContext* pCxt, const char** pSql, STableDataB
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
param
.
schema
=
pSchema
;
param
.
schema
=
&
pSchemas
[
pCols
->
boundColumns
[
i
]]
;
insGetSTSRowAppendInfo
(
pBuilder
->
rowType
,
pCols
,
i
,
&
param
.
toffset
,
&
param
.
colIdx
);
code
=
parseValueToken
(
pCxt
,
pSql
,
pToken
,
p
Schema
,
getTableInfo
(
pDataBuf
->
pTableMeta
).
precision
,
insMemRowAppend
,
&
param
);
code
=
parseValueToken
(
pCxt
,
pSql
,
pToken
,
p
aram
.
schema
,
getTableInfo
(
pDataBuf
->
pTableMeta
).
precision
,
insMemRowAppend
,
&
param
);
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
i
<
pCols
->
numOfBound
-
1
)
{
...
...
source/libs/parser/src/parTokenizer.c
浏览文件 @
115160bb
...
...
@@ -620,7 +620,7 @@ uint32_t tGetToken(const char* z, uint32_t* tokenId) {
return
0
;
}
SToken
tStrGetToken
(
const
char
*
str
,
int32_t
*
i
,
bool
isPrevOptr
)
{
SToken
tStrGetToken
(
const
char
*
str
,
int32_t
*
i
,
bool
isPrevOptr
,
bool
*
pIgnoreComma
)
{
SToken
t0
=
{
0
};
// here we reach the end of sql string, null-terminated string
...
...
@@ -641,6 +641,10 @@ SToken tStrGetToken(const char* str, int32_t* i, bool isPrevOptr) {
return
t0
;
}
if
(
NULL
!=
pIgnoreComma
&&
t
==
','
)
{
*
pIgnoreComma
=
true
;
}
t
=
str
[
++
(
*
i
)];
}
...
...
source/libs/parser/src/parser.c
浏览文件 @
115160bb
...
...
@@ -27,7 +27,7 @@ bool qIsInsertValuesSql(const char* pStr, size_t length) {
const
char
*
pSql
=
pStr
;
int32_t
index
=
0
;
SToken
t
=
tStrGetToken
((
char
*
)
pStr
,
&
index
,
false
);
SToken
t
=
tStrGetToken
((
char
*
)
pStr
,
&
index
,
false
,
NULL
);
if
(
TK_INSERT
!=
t
.
type
&&
TK_IMPORT
!=
t
.
type
)
{
return
false
;
}
...
...
@@ -35,7 +35,7 @@ bool qIsInsertValuesSql(const char* pStr, size_t length) {
do
{
pStr
+=
index
;
index
=
0
;
t
=
tStrGetToken
((
char
*
)
pStr
,
&
index
,
false
);
t
=
tStrGetToken
((
char
*
)
pStr
,
&
index
,
false
,
NULL
);
if
(
TK_USING
==
t
.
type
||
TK_VALUES
==
t
.
type
||
TK_FILE
==
t
.
type
)
{
return
true
;
}
else
if
(
TK_SELECT
==
t
.
type
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录