Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
20c31144
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看板
未验证
提交
20c31144
编写于
9月 02, 2020
作者:
S
Shengliang Guan
提交者:
GitHub
9月 02, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3350 from taosdata/feature/TD-934
TD-934
上级
a72318c5
baddf0ce
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
50 addition
and
18 deletion
+50
-18
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+1
-0
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+8
-8
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+1
-1
src/client/src/tscSql.c
src/client/src/tscSql.c
+7
-4
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+30
-3
src/inc/taoserror.h
src/inc/taoserror.h
+1
-0
tests/script/general/http/restful_full.sim
tests/script/general/http/restful_full.sim
+2
-2
未找到文件。
src/client/inc/tsclient.h
浏览文件 @
20c31144
...
...
@@ -458,6 +458,7 @@ bool tscResultsetFetchCompleted(TAOS_RES *result);
char
*
tscGetErrorMsgPayload
(
SSqlCmd
*
pCmd
);
int32_t
tscInvalidSQLErrMsg
(
char
*
msg
,
const
char
*
additionalInfo
,
const
char
*
sql
);
int32_t
tscSQLSyntaxErrMsg
(
char
*
msg
,
const
char
*
additionalInfo
,
const
char
*
sql
);
int32_t
tscToSQLCmd
(
SSqlObj
*
pSql
,
struct
SSqlInfo
*
pInfo
);
...
...
src/client/src/tscParseInsert.c
浏览文件 @
20c31144
...
...
@@ -180,7 +180,7 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SStrToken *pToken, char *payload,
}
else
if
(
strncasecmp
(
TSDB_DATA_NULL_STR_L
,
pToken
->
z
,
pToken
->
n
)
==
0
)
{
*
(
uint8_t
*
)
payload
=
TSDB_DATA_BOOL_NULL
;
}
else
{
return
tsc
InvalidSQL
ErrMsg
(
msg
,
"invalid bool data"
,
pToken
->
z
);
return
tsc
SQLSyntax
ErrMsg
(
msg
,
"invalid bool data"
,
pToken
->
z
);
}
}
else
if
(
pToken
->
type
==
TK_INTEGER
)
{
iv
=
strtoll
(
pToken
->
z
,
NULL
,
10
);
...
...
@@ -439,8 +439,8 @@ int tsParseOneRowData(char **str, STableDataBlocks *pDataBlocks, SSchema schema[
int16_t
type
=
sToken
.
type
;
if
((
type
!=
TK_NOW
&&
type
!=
TK_INTEGER
&&
type
!=
TK_STRING
&&
type
!=
TK_FLOAT
&&
type
!=
TK_BOOL
&&
type
!=
TK_NULL
&&
type
!=
TK_HEX
&&
type
!=
TK_OCT
&&
type
!=
TK_BIN
)
||
(
sToken
.
n
==
0
)
||
(
type
==
TK_RP
))
{
tsc
InvalidSQL
ErrMsg
(
error
,
"invalid data or symbol"
,
sToken
.
z
);
*
code
=
TSDB_CODE_TSC_
INVALID_SQL
;
tsc
SQLSyntax
ErrMsg
(
error
,
"invalid data or symbol"
,
sToken
.
z
);
*
code
=
TSDB_CODE_TSC_
SQL_SYNTAX_ERROR
;
return
-
1
;
}
...
...
@@ -472,7 +472,7 @@ int tsParseOneRowData(char **str, STableDataBlocks *pDataBlocks, SSchema schema[
bool
isPrimaryKey
=
(
colIndex
==
PRIMARYKEY_TIMESTAMP_COL_INDEX
);
int32_t
ret
=
tsParseOneColumnData
(
pSchema
,
&
sToken
,
start
,
error
,
str
,
isPrimaryKey
,
timePrec
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
*
code
=
TSDB_CODE_TSC_
INVALID_SQL
;
*
code
=
TSDB_CODE_TSC_
SQL_SYNTAX_ERROR
;
return
-
1
;
// NOTE: here 0 mean error!
}
...
...
@@ -568,8 +568,8 @@ int tsParseValues(char **str, STableDataBlocks *pDataBlock, STableMeta *pTableMe
sToken
=
tStrGetToken
(
*
str
,
&
index
,
false
,
0
,
NULL
);
*
str
+=
index
;
if
(
sToken
.
n
==
0
||
sToken
.
type
!=
TK_RP
)
{
tsc
InvalidSQL
ErrMsg
(
error
,
") expected"
,
*
str
);
*
code
=
TSDB_CODE_TSC_
INVALID_SQL
;
tsc
SQLSyntax
ErrMsg
(
error
,
") expected"
,
*
str
);
*
code
=
TSDB_CODE_TSC_
SQL_SYNTAX_ERROR
;
return
-
1
;
}
...
...
@@ -578,7 +578,7 @@ int tsParseValues(char **str, STableDataBlocks *pDataBlock, STableMeta *pTableMe
if
(
numOfRows
<=
0
)
{
strcpy
(
error
,
"no any data points"
);
*
code
=
TSDB_CODE_TSC_
INVALID_SQL
;
*
code
=
TSDB_CODE_TSC_
SQL_SYNTAX_ERROR
;
return
-
1
;
}
else
{
return
numOfRows
;
...
...
@@ -943,7 +943,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
sToken
=
tStrGetToken
(
sql
,
&
index
,
false
,
0
,
NULL
);
sql
+=
index
;
if
(
sToken
.
n
==
0
||
sToken
.
type
!=
TK_RP
)
{
return
tsc
InvalidSQL
ErrMsg
(
pCmd
->
payload
,
") expected"
,
sToken
.
z
);
return
tsc
SQLSyntax
ErrMsg
(
pCmd
->
payload
,
") expected"
,
sToken
.
z
);
}
pCmd
->
payloadLen
=
sizeof
(
pTag
->
name
)
+
sizeof
(
pTag
->
dataLen
)
+
pTag
->
dataLen
;
...
...
src/client/src/tscSQLParser.c
浏览文件 @
20c31144
...
...
@@ -190,7 +190,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
(
!
pInfo
->
valid
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
)
,
pInfo
->
pzErrMsg
);
return
tscSQLSyntaxErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
NULL
,
pInfo
->
pzErrMsg
);
}
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetailSafely
(
pCmd
,
pCmd
->
clauseIndex
);
...
...
src/client/src/tscSql.c
浏览文件 @
20c31144
...
...
@@ -597,11 +597,12 @@ int taos_errno(TAOS_RES *tres) {
}
/*
* In case of invalid sql error, additional information is attached to explain
* In case of invalid sql
/sql syntax
error, additional information is attached to explain
* why the sql is invalid
*/
static
bool
hasAdditionalErrorInfo
(
int32_t
code
,
SSqlCmd
*
pCmd
)
{
if
(
code
!=
TSDB_CODE_TSC_INVALID_SQL
)
{
if
(
code
!=
TSDB_CODE_TSC_INVALID_SQL
&&
code
!=
TSDB_CODE_TSC_SQL_SYNTAX_ERROR
)
{
return
false
;
}
...
...
@@ -609,9 +610,11 @@ static bool hasAdditionalErrorInfo(int32_t code, SSqlCmd *pCmd) {
char
*
z
=
NULL
;
if
(
len
>
0
)
{
z
=
strstr
(
pCmd
->
payload
,
"invalid SQL"
);
z
=
strstr
(
pCmd
->
payload
,
"invalid SQL"
);
if
(
z
==
NULL
)
{
z
=
strstr
(
pCmd
->
payload
,
"syntax error"
);
}
}
return
z
!=
NULL
;
}
...
...
src/client/src/tscUtil.c
浏览文件 @
20c31144
...
...
@@ -2029,10 +2029,37 @@ bool tscIsUpdateQuery(SSqlObj* pSql) {
return
((
pCmd
->
command
>=
TSDB_SQL_INSERT
&&
pCmd
->
command
<=
TSDB_SQL_DROP_DNODE
)
||
TSDB_SQL_USE_DB
==
pCmd
->
command
);
}
int32_t
tscSQLSyntaxErrMsg
(
char
*
msg
,
const
char
*
additionalInfo
,
const
char
*
sql
)
{
const
char
*
msgFormat1
=
"syntax error near
\'
%s
\'
"
;
const
char
*
msgFormat2
=
"syntax error near
\'
%s
\'
(%s)"
;
const
char
*
msgFormat3
=
"%s"
;
const
char
*
prefix
=
"syntax error"
;
const
int32_t
BACKWARD_CHAR_STEP
=
0
;
if
(
sql
==
NULL
)
{
assert
(
additionalInfo
!=
NULL
);
sprintf
(
msg
,
msgFormat1
,
additionalInfo
);
return
TSDB_CODE_TSC_SQL_SYNTAX_ERROR
;
}
char
buf
[
64
]
=
{
0
};
// only extract part of sql string
strncpy
(
buf
,
(
sql
-
BACKWARD_CHAR_STEP
),
tListLen
(
buf
)
-
1
);
if
(
additionalInfo
!=
NULL
)
{
sprintf
(
msg
,
msgFormat2
,
buf
,
additionalInfo
);
}
else
{
const
char
*
msgFormat
=
(
0
==
strncmp
(
sql
,
prefix
,
strlen
(
prefix
)))
?
msgFormat3
:
msgFormat1
;
sprintf
(
msg
,
msgFormat
,
buf
);
}
return
TSDB_CODE_TSC_SQL_SYNTAX_ERROR
;
}
int32_t
tscInvalidSQLErrMsg
(
char
*
msg
,
const
char
*
additionalInfo
,
const
char
*
sql
)
{
const
char
*
msgFormat1
=
"invalid SQL: %s"
;
const
char
*
msgFormat2
=
"invalid SQL:
syntax error near
\"
%s
\"
(%s)"
;
const
char
*
msgFormat3
=
"invalid SQL:
syntax error near
\"
%s
\"
"
;
const
char
*
msgFormat2
=
"invalid SQL:
\'
%s
\'
(%s)"
;
const
char
*
msgFormat3
=
"invalid SQL:
\'
%s
\'
"
;
const
int32_t
BACKWARD_CHAR_STEP
=
0
;
...
...
@@ -2258,4 +2285,4 @@ bool tscSetSqlOwner(SSqlObj* pSql) {
void
tscClearSqlOwner
(
SSqlObj
*
pSql
)
{
assert
(
taosCheckPthreadValid
(
pSql
->
owner
));
atomic_store_64
(
&
pSql
->
owner
,
0
);
}
\ No newline at end of file
}
src/inc/taoserror.h
浏览文件 @
20c31144
...
...
@@ -98,6 +98,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSC_ACTION_IN_PROGRESS, 0, 0x0212, "Action in
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_DISCONNECTED
,
0
,
0x0213
,
"Disconnected from service"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_NO_WRITE_AUTH
,
0
,
0x0214
,
"No write permission"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_CONN_KILLED
,
0
,
0x0215
,
"Connection killed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_SQL_SYNTAX_ERROR
,
0
,
0x0216
,
"Syntax errr in SQL"
)
// mnode
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_MSG_NOT_PROCESSED
,
0
,
0x0300
,
"Message not processed"
)
...
...
tests/script/general/http/restful_full.sim
浏览文件 @
20c31144
...
...
@@ -119,7 +119,7 @@ endi
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' used1' 127.0.0.1:7111/rest/sql
print 17-> $system_content
if $system_content != @{"status":"error","code":5
12,"desc":"invalid SQL: invalid SQL: syntax error near 'used1'
"}@ then
if $system_content != @{"status":"error","code":5
34,"desc":"Syntax errr in SQL
"}@ then
return -1
endi
...
...
@@ -230,4 +230,4 @@ if $system_content != @{"status":"succ","head":["ts","speed"],"data":[["2017-12-
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
system sh/exec.sh -n dnode1 -s stop -x SIGINT
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录