Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
dac0a985
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
dac0a985
编写于
8月 24, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-1213]
上级
5b5edf00
变更
22
展开全部
显示空白变更内容
内联
并排
Showing
22 changed file
with
239 addition
and
230 deletion
+239
-230
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+2
-2
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+14
-14
src/client/src/tscPrepare.c
src/client/src/tscPrepare.c
+1
-1
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+70
-69
src/client/src/tscServer.c
src/client/src/tscServer.c
+4
-4
src/client/src/tscSql.c
src/client/src/tscSql.c
+1
-1
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+3
-3
src/common/inc/tname.h
src/common/inc/tname.h
+2
-2
src/common/inc/tvariant.h
src/common/inc/tvariant.h
+1
-1
src/common/src/tname.c
src/common/src/tname.c
+4
-4
src/common/src/tvariant.c
src/common/src/tvariant.c
+7
-7
src/query/inc/qAst.h
src/query/inc/qAst.h
+1
-1
src/query/inc/qSqlparser.h
src/query/inc/qSqlparser.h
+42
-42
src/query/inc/sql.y
src/query/inc/sql.y
+15
-15
src/query/src/qAst.c
src/query/src/qAst.c
+5
-5
src/query/src/qParserImpl.c
src/query/src/qParserImpl.c
+51
-43
src/query/src/qTokenizer.c
src/query/src/qTokenizer.c
+2
-2
src/query/src/sql.c
src/query/src/sql.c
+5
-5
src/query/tests/unitTest.cpp
src/query/tests/unitTest.cpp
+4
-4
src/util/inc/tstoken.h
src/util/inc/tstoken.h
+4
-4
tests/script/general/parser/constCol.sim
tests/script/general/parser/constCol.sim
+0
-0
tests/script/general/parser/testSuite.sim
tests/script/general/parser/testSuite.sim
+1
-1
未找到文件。
src/client/inc/tscUtil.h
浏览文件 @
dac0a985
...
@@ -141,7 +141,7 @@ bool tscQueryTags(SQueryInfo* pQueryInfo);
...
@@ -141,7 +141,7 @@ bool tscQueryTags(SQueryInfo* pQueryInfo);
SSqlExpr
*
tscAddSpecialColumnForSelect
(
SQueryInfo
*
pQueryInfo
,
int32_t
outputColIndex
,
int16_t
functionId
,
SSqlExpr
*
tscAddSpecialColumnForSelect
(
SQueryInfo
*
pQueryInfo
,
int32_t
outputColIndex
,
int16_t
functionId
,
SColumnIndex
*
pIndex
,
SSchema
*
pColSchema
,
int16_t
colType
);
SColumnIndex
*
pIndex
,
SSchema
*
pColSchema
,
int16_t
colType
);
int32_t
tscSetTableFullName
(
STableMetaInfo
*
pTableMetaInfo
,
SS
QL
Token
*
pzTableName
,
SSqlObj
*
pSql
);
int32_t
tscSetTableFullName
(
STableMetaInfo
*
pTableMetaInfo
,
SS
tr
Token
*
pzTableName
,
SSqlObj
*
pSql
);
void
tscClearInterpInfo
(
SQueryInfo
*
pQueryInfo
);
void
tscClearInterpInfo
(
SQueryInfo
*
pQueryInfo
);
bool
tscIsInsertData
(
char
*
sqlstr
);
bool
tscIsInsertData
(
char
*
sqlstr
);
...
@@ -194,7 +194,7 @@ SColumn* tscColumnListInsert(SArray* pColList, SColumnIndex* colIndex);
...
@@ -194,7 +194,7 @@ SColumn* tscColumnListInsert(SArray* pColList, SColumnIndex* colIndex);
SArray
*
tscColumnListClone
(
const
SArray
*
src
,
int16_t
tableIndex
);
SArray
*
tscColumnListClone
(
const
SArray
*
src
,
int16_t
tableIndex
);
void
tscColumnListDestroy
(
SArray
*
pColList
);
void
tscColumnListDestroy
(
SArray
*
pColList
);
int32_t
tscValidateName
(
SS
QL
Token
*
pToken
);
int32_t
tscValidateName
(
SS
tr
Token
*
pToken
);
void
tscIncStreamExecutionCount
(
void
*
pStream
);
void
tscIncStreamExecutionCount
(
void
*
pStream
);
...
...
src/client/src/tscParseInsert.c
浏览文件 @
dac0a985
...
@@ -40,7 +40,7 @@ enum {
...
@@ -40,7 +40,7 @@ enum {
static
int32_t
tscAllocateMemIfNeed
(
STableDataBlocks
*
pDataBlock
,
int32_t
rowSize
,
int32_t
*
numOfRows
);
static
int32_t
tscAllocateMemIfNeed
(
STableDataBlocks
*
pDataBlock
,
int32_t
rowSize
,
int32_t
*
numOfRows
);
static
int32_t
tscToInteger
(
SS
QL
Token
*
pToken
,
int64_t
*
value
,
char
**
endPtr
)
{
static
int32_t
tscToInteger
(
SS
tr
Token
*
pToken
,
int64_t
*
value
,
char
**
endPtr
)
{
if
(
pToken
->
n
==
0
)
{
if
(
pToken
->
n
==
0
)
{
return
TK_ILLEGAL
;
return
TK_ILLEGAL
;
}
}
...
@@ -73,7 +73,7 @@ static int32_t tscToInteger(SSQLToken *pToken, int64_t *value, char **endPtr) {
...
@@ -73,7 +73,7 @@ static int32_t tscToInteger(SSQLToken *pToken, int64_t *value, char **endPtr) {
return
pToken
->
type
;
return
pToken
->
type
;
}
}
static
int32_t
tscToDouble
(
SS
QL
Token
*
pToken
,
double
*
value
,
char
**
endPtr
)
{
static
int32_t
tscToDouble
(
SS
tr
Token
*
pToken
,
double
*
value
,
char
**
endPtr
)
{
if
(
pToken
->
n
==
0
)
{
if
(
pToken
->
n
==
0
)
{
return
TK_ILLEGAL
;
return
TK_ILLEGAL
;
}
}
...
@@ -89,9 +89,9 @@ static int32_t tscToDouble(SSQLToken *pToken, double *value, char **endPtr) {
...
@@ -89,9 +89,9 @@ static int32_t tscToDouble(SSQLToken *pToken, double *value, char **endPtr) {
return
pToken
->
type
;
return
pToken
->
type
;
}
}
int
tsParseTime
(
SS
QL
Token
*
pToken
,
int64_t
*
time
,
char
**
next
,
char
*
error
,
int16_t
timePrec
)
{
int
tsParseTime
(
SS
tr
Token
*
pToken
,
int64_t
*
time
,
char
**
next
,
char
*
error
,
int16_t
timePrec
)
{
int32_t
index
=
0
;
int32_t
index
=
0
;
SS
QL
Token
sToken
;
SS
tr
Token
sToken
;
int64_t
interval
;
int64_t
interval
;
int64_t
useconds
=
0
;
int64_t
useconds
=
0
;
char
*
pTokenEnd
=
*
next
;
char
*
pTokenEnd
=
*
next
;
...
@@ -128,7 +128,7 @@ int tsParseTime(SSQLToken *pToken, int64_t *time, char **next, char *error, int1
...
@@ -128,7 +128,7 @@ int tsParseTime(SSQLToken *pToken, int64_t *time, char **next, char *error, int1
* time expression:
* time expression:
* e.g., now+12a, now-5h
* e.g., now+12a, now-5h
*/
*/
SS
QL
Token
valueToken
;
SS
tr
Token
valueToken
;
index
=
0
;
index
=
0
;
sToken
=
tStrGetToken
(
pTokenEnd
,
&
index
,
false
,
0
,
NULL
);
sToken
=
tStrGetToken
(
pTokenEnd
,
&
index
,
false
,
0
,
NULL
);
pTokenEnd
+=
index
;
pTokenEnd
+=
index
;
...
@@ -163,7 +163,7 @@ int tsParseTime(SSQLToken *pToken, int64_t *time, char **next, char *error, int1
...
@@ -163,7 +163,7 @@ int tsParseTime(SSQLToken *pToken, int64_t *time, char **next, char *error, int1
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
tsParseOneColumnData
(
SSchema
*
pSchema
,
SS
QL
Token
*
pToken
,
char
*
payload
,
char
*
msg
,
char
**
str
,
bool
primaryKey
,
int32_t
tsParseOneColumnData
(
SSchema
*
pSchema
,
SS
tr
Token
*
pToken
,
char
*
payload
,
char
*
msg
,
char
**
str
,
bool
primaryKey
,
int16_t
timePrec
)
{
int16_t
timePrec
)
{
int64_t
iv
;
int64_t
iv
;
int32_t
numType
;
int32_t
numType
;
...
@@ -409,7 +409,7 @@ static int32_t tsCheckTimestamp(STableDataBlocks *pDataBlocks, const char *start
...
@@ -409,7 +409,7 @@ static int32_t tsCheckTimestamp(STableDataBlocks *pDataBlocks, const char *start
int
tsParseOneRowData
(
char
**
str
,
STableDataBlocks
*
pDataBlocks
,
SSchema
schema
[],
SParsedDataColInfo
*
spd
,
char
*
error
,
int
tsParseOneRowData
(
char
**
str
,
STableDataBlocks
*
pDataBlocks
,
SSchema
schema
[],
SParsedDataColInfo
*
spd
,
char
*
error
,
int16_t
timePrec
,
int32_t
*
code
,
char
*
tmpTokenBuf
)
{
int16_t
timePrec
,
int32_t
*
code
,
char
*
tmpTokenBuf
)
{
int32_t
index
=
0
;
int32_t
index
=
0
;
SS
QL
Token
sToken
=
{
0
};
SS
tr
Token
sToken
=
{
0
};
char
*
payload
=
pDataBlocks
->
pData
+
pDataBlocks
->
size
;
char
*
payload
=
pDataBlocks
->
pData
+
pDataBlocks
->
size
;
// 1. set the parsed value from sql string
// 1. set the parsed value from sql string
...
@@ -524,7 +524,7 @@ static int32_t rowDataCompar(const void *lhs, const void *rhs) {
...
@@ -524,7 +524,7 @@ static int32_t rowDataCompar(const void *lhs, const void *rhs) {
int
tsParseValues
(
char
**
str
,
STableDataBlocks
*
pDataBlock
,
STableMeta
*
pTableMeta
,
int
maxRows
,
int
tsParseValues
(
char
**
str
,
STableDataBlocks
*
pDataBlock
,
STableMeta
*
pTableMeta
,
int
maxRows
,
SParsedDataColInfo
*
spd
,
char
*
error
,
int32_t
*
code
,
char
*
tmpTokenBuf
)
{
SParsedDataColInfo
*
spd
,
char
*
error
,
int32_t
*
code
,
char
*
tmpTokenBuf
)
{
int32_t
index
=
0
;
int32_t
index
=
0
;
SS
QL
Token
sToken
;
SS
tr
Token
sToken
;
int16_t
numOfRows
=
0
;
int16_t
numOfRows
=
0
;
...
@@ -734,8 +734,8 @@ static int32_t doParseInsertStatement(SSqlObj *pSql, void *pTableList, char **st
...
@@ -734,8 +734,8 @@ static int32_t doParseInsertStatement(SSqlObj *pSql, void *pTableList, char **st
static
int32_t
tscCheckIfCreateTable
(
char
**
sqlstr
,
SSqlObj
*
pSql
)
{
static
int32_t
tscCheckIfCreateTable
(
char
**
sqlstr
,
SSqlObj
*
pSql
)
{
int32_t
index
=
0
;
int32_t
index
=
0
;
SS
QL
Token
sToken
=
{
0
};
SS
tr
Token
sToken
=
{
0
};
SS
QL
Token
tableToken
=
{
0
};
SS
tr
Token
tableToken
=
{
0
};
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
const
int32_t
TABLE_INDEX
=
0
;
const
int32_t
TABLE_INDEX
=
0
;
...
@@ -993,7 +993,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
...
@@ -993,7 +993,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
return
code
;
return
code
;
}
}
int
validateTableName
(
char
*
tblName
,
int
len
,
SS
QL
Token
*
psTblToken
)
{
int
validateTableName
(
char
*
tblName
,
int
len
,
SS
tr
Token
*
psTblToken
)
{
tstrncpy
(
psTblToken
->
z
,
tblName
,
TSDB_TABLE_FNAME_LEN
);
tstrncpy
(
psTblToken
->
z
,
tblName
,
TSDB_TABLE_FNAME_LEN
);
psTblToken
->
n
=
len
;
psTblToken
->
n
=
len
;
...
@@ -1057,7 +1057,7 @@ int tsParseInsertSql(SSqlObj *pSql) {
...
@@ -1057,7 +1057,7 @@ int tsParseInsertSql(SSqlObj *pSql) {
while
(
1
)
{
while
(
1
)
{
int32_t
index
=
0
;
int32_t
index
=
0
;
SS
QL
Token
sToken
=
tStrGetToken
(
str
,
&
index
,
false
,
0
,
NULL
);
SS
tr
Token
sToken
=
tStrGetToken
(
str
,
&
index
,
false
,
0
,
NULL
);
// no data in the sql string anymore.
// no data in the sql string anymore.
if
(
sToken
.
n
==
0
)
{
if
(
sToken
.
n
==
0
)
{
...
@@ -1083,7 +1083,7 @@ int tsParseInsertSql(SSqlObj *pSql) {
...
@@ -1083,7 +1083,7 @@ int tsParseInsertSql(SSqlObj *pSql) {
pCmd
->
curSql
=
sToken
.
z
;
pCmd
->
curSql
=
sToken
.
z
;
char
buf
[
TSDB_TABLE_FNAME_LEN
];
char
buf
[
TSDB_TABLE_FNAME_LEN
];
SS
QL
Token
sTblToken
;
SS
tr
Token
sTblToken
;
sTblToken
.
z
=
buf
;
sTblToken
.
z
=
buf
;
// Check if the table name available or not
// Check if the table name available or not
if
(
validateTableName
(
sToken
.
z
,
sToken
.
n
,
&
sTblToken
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
validateTableName
(
sToken
.
z
,
sToken
.
n
,
&
sTblToken
)
!=
TSDB_CODE_SUCCESS
)
{
...
@@ -1285,7 +1285,7 @@ int tsInsertInitialCheck(SSqlObj *pSql) {
...
@@ -1285,7 +1285,7 @@ int tsInsertInitialCheck(SSqlObj *pSql) {
int32_t
index
=
0
;
int32_t
index
=
0
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SS
QL
Token
sToken
=
tStrGetToken
(
pSql
->
sqlstr
,
&
index
,
false
,
0
,
NULL
);
SS
tr
Token
sToken
=
tStrGetToken
(
pSql
->
sqlstr
,
&
index
,
false
,
0
,
NULL
);
assert
(
sToken
.
type
==
TK_INSERT
||
sToken
.
type
==
TK_IMPORT
);
assert
(
sToken
.
type
==
TK_INSERT
||
sToken
.
type
==
TK_IMPORT
);
pCmd
->
count
=
0
;
pCmd
->
count
=
0
;
...
...
src/client/src/tscPrepare.c
浏览文件 @
dac0a985
...
@@ -155,7 +155,7 @@ static int normalStmtPrepare(STscStmt* stmt) {
...
@@ -155,7 +155,7 @@ static int normalStmtPrepare(STscStmt* stmt) {
uint32_t
i
=
0
,
start
=
0
;
uint32_t
i
=
0
,
start
=
0
;
while
(
sql
[
i
]
!=
0
)
{
while
(
sql
[
i
]
!=
0
)
{
SS
QL
Token
token
=
{
0
};
SS
tr
Token
token
=
{
0
};
token
.
n
=
tSQLGetToken
(
sql
+
i
,
&
token
.
type
);
token
.
n
=
tSQLGetToken
(
sql
+
i
,
&
token
.
type
);
if
(
token
.
type
==
TK_QUESTION
)
{
if
(
token
.
type
==
TK_QUESTION
)
{
...
...
src/client/src/tscSQLParser.c
浏览文件 @
dac0a985
此差异已折叠。
点击以展开。
src/client/src/tscServer.c
浏览文件 @
dac0a985
...
@@ -931,8 +931,8 @@ int32_t tscBuildAcctMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -931,8 +931,8 @@ int32_t tscBuildAcctMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
SCMCreateAcctMsg
*
pAlterMsg
=
(
SCMCreateAcctMsg
*
)
pCmd
->
payload
;
SCMCreateAcctMsg
*
pAlterMsg
=
(
SCMCreateAcctMsg
*
)
pCmd
->
payload
;
SS
QL
Token
*
pName
=
&
pInfo
->
pDCLInfo
->
user
.
user
;
SS
tr
Token
*
pName
=
&
pInfo
->
pDCLInfo
->
user
.
user
;
SS
QL
Token
*
pPwd
=
&
pInfo
->
pDCLInfo
->
user
.
passwd
;
SS
tr
Token
*
pPwd
=
&
pInfo
->
pDCLInfo
->
user
.
passwd
;
strncpy
(
pAlterMsg
->
user
,
pName
->
z
,
pName
->
n
);
strncpy
(
pAlterMsg
->
user
,
pName
->
z
,
pName
->
n
);
strncpy
(
pAlterMsg
->
pass
,
pPwd
->
z
,
pPwd
->
n
);
strncpy
(
pAlterMsg
->
pass
,
pPwd
->
z
,
pPwd
->
n
);
...
@@ -1134,13 +1134,13 @@ int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1134,13 +1134,13 @@ int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pShowMsg
->
type
=
pShowInfo
->
showType
;
pShowMsg
->
type
=
pShowInfo
->
showType
;
if
(
pShowInfo
->
showType
!=
TSDB_MGMT_TABLE_VNODES
)
{
if
(
pShowInfo
->
showType
!=
TSDB_MGMT_TABLE_VNODES
)
{
SS
QL
Token
*
pPattern
=
&
pShowInfo
->
pattern
;
SS
tr
Token
*
pPattern
=
&
pShowInfo
->
pattern
;
if
(
pPattern
->
type
>
0
)
{
// only show tables support wildcard query
if
(
pPattern
->
type
>
0
)
{
// only show tables support wildcard query
strncpy
(
pShowMsg
->
payload
,
pPattern
->
z
,
pPattern
->
n
);
strncpy
(
pShowMsg
->
payload
,
pPattern
->
z
,
pPattern
->
n
);
pShowMsg
->
payloadLen
=
htons
(
pPattern
->
n
);
pShowMsg
->
payloadLen
=
htons
(
pPattern
->
n
);
}
}
}
else
{
}
else
{
SS
QL
Token
*
pEpAddr
=
&
pShowInfo
->
prefix
;
SS
tr
Token
*
pEpAddr
=
&
pShowInfo
->
prefix
;
assert
(
pEpAddr
->
n
>
0
&&
pEpAddr
->
type
>
0
);
assert
(
pEpAddr
->
n
>
0
&&
pEpAddr
->
type
>
0
);
strncpy
(
pShowMsg
->
payload
,
pEpAddr
->
z
,
pEpAddr
->
n
);
strncpy
(
pShowMsg
->
payload
,
pEpAddr
->
z
,
pEpAddr
->
n
);
...
...
src/client/src/tscSql.c
浏览文件 @
dac0a985
...
@@ -855,7 +855,7 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t
...
@@ -855,7 +855,7 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t
str
=
nextStr
+
1
;
str
=
nextStr
+
1
;
len
=
(
int32_t
)
strtrim
(
tblName
);
len
=
(
int32_t
)
strtrim
(
tblName
);
SS
QL
Token
sToken
=
{.
n
=
len
,
.
type
=
TK_ID
,
.
z
=
tblName
};
SS
tr
Token
sToken
=
{.
n
=
len
,
.
type
=
TK_ID
,
.
z
=
tblName
};
tSQLGetToken
(
tblName
,
&
sToken
.
type
);
tSQLGetToken
(
tblName
,
&
sToken
.
type
);
// Check if the table name available or not
// Check if the table name available or not
...
...
src/client/src/tscUtil.c
浏览文件 @
dac0a985
...
@@ -744,7 +744,7 @@ bool tscIsInsertData(char* sqlstr) {
...
@@ -744,7 +744,7 @@ bool tscIsInsertData(char* sqlstr) {
int32_t
index
=
0
;
int32_t
index
=
0
;
do
{
do
{
SS
QL
Token
t0
=
tStrGetToken
(
sqlstr
,
&
index
,
false
,
0
,
NULL
);
SS
tr
Token
t0
=
tStrGetToken
(
sqlstr
,
&
index
,
false
,
0
,
NULL
);
if
(
t0
.
type
!=
TK_LP
)
{
if
(
t0
.
type
!=
TK_LP
)
{
return
t0
.
type
==
TK_INSERT
||
t0
.
type
==
TK_IMPORT
;
return
t0
.
type
==
TK_INSERT
||
t0
.
type
==
TK_IMPORT
;
}
}
...
@@ -1187,7 +1187,7 @@ void tscColumnListDestroy(SArray* pColumnList) {
...
@@ -1187,7 +1187,7 @@ void tscColumnListDestroy(SArray* pColumnList) {
* 'first_part.second_part'
* 'first_part.second_part'
*
*
*/
*/
static
int32_t
validateQuoteToken
(
SS
QL
Token
*
pToken
)
{
static
int32_t
validateQuoteToken
(
SS
tr
Token
*
pToken
)
{
strdequote
(
pToken
->
z
);
strdequote
(
pToken
->
z
);
pToken
->
n
=
(
uint32_t
)
strtrim
(
pToken
->
z
);
pToken
->
n
=
(
uint32_t
)
strtrim
(
pToken
->
z
);
...
@@ -1203,7 +1203,7 @@ static int32_t validateQuoteToken(SSQLToken* pToken) {
...
@@ -1203,7 +1203,7 @@ static int32_t validateQuoteToken(SSQLToken* pToken) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
tscValidateName
(
SS
QL
Token
*
pToken
)
{
int32_t
tscValidateName
(
SS
tr
Token
*
pToken
)
{
if
(
pToken
->
type
!=
TK_STRING
&&
pToken
->
type
!=
TK_ID
)
{
if
(
pToken
->
type
!=
TK_STRING
&&
pToken
->
type
!=
TK_ID
)
{
return
TSDB_CODE_TSC_INVALID_SQL
;
return
TSDB_CODE_TSC_INVALID_SQL
;
}
}
...
...
src/common/inc/tname.h
浏览文件 @
dac0a985
...
@@ -25,11 +25,11 @@ void extractTableName(const char *tableId, char *name);
...
@@ -25,11 +25,11 @@ void extractTableName(const char *tableId, char *name);
char
*
extractDBName
(
const
char
*
tableId
,
char
*
name
);
char
*
extractDBName
(
const
char
*
tableId
,
char
*
name
);
void
extractTableNameFromToken
(
SS
QLToken
*
pToken
,
SSQL
Token
*
pTable
);
void
extractTableNameFromToken
(
SS
trToken
*
pToken
,
SStr
Token
*
pTable
);
SSchema
tGetTableNameColumnSchema
();
SSchema
tGetTableNameColumnSchema
();
SSchema
tGetUserSpecifiedColumnSchema
(
tVariant
*
pVal
,
const
char
*
name
);
SSchema
tGetUserSpecifiedColumnSchema
(
tVariant
*
pVal
,
SStrToken
*
exprStr
,
const
char
*
name
);
bool
tscValidateTableNameLength
(
size_t
len
);
bool
tscValidateTableNameLength
(
size_t
len
);
...
...
src/common/inc/tvariant.h
浏览文件 @
dac0a985
...
@@ -36,7 +36,7 @@ typedef struct tVariant {
...
@@ -36,7 +36,7 @@ typedef struct tVariant {
};
};
}
tVariant
;
}
tVariant
;
void
tVariantCreate
(
tVariant
*
pVar
,
SS
QL
Token
*
token
);
void
tVariantCreate
(
tVariant
*
pVar
,
SS
tr
Token
*
token
);
void
tVariantCreateFromString
(
tVariant
*
pVar
,
char
*
pz
,
uint32_t
len
,
uint32_t
type
);
void
tVariantCreateFromString
(
tVariant
*
pVar
,
char
*
pz
,
uint32_t
len
,
uint32_t
type
);
...
...
src/common/src/tname.c
浏览文件 @
dac0a985
...
@@ -48,7 +48,7 @@ SSchema tGetTableNameColumnSchema() {
...
@@ -48,7 +48,7 @@ SSchema tGetTableNameColumnSchema() {
return
s
;
return
s
;
}
}
SSchema
tGetUserSpecifiedColumnSchema
(
tVariant
*
pVal
,
const
char
*
name
)
{
SSchema
tGetUserSpecifiedColumnSchema
(
tVariant
*
pVal
,
SStrToken
*
exprStr
,
const
char
*
name
)
{
SSchema
s
=
{
0
};
SSchema
s
=
{
0
};
s
.
type
=
pVal
->
nType
;
s
.
type
=
pVal
->
nType
;
...
@@ -62,8 +62,8 @@ SSchema tGetUserSpecifiedColumnSchema(tVariant* pVal, const char* name) {
...
@@ -62,8 +62,8 @@ SSchema tGetUserSpecifiedColumnSchema(tVariant* pVal, const char* name) {
if
(
name
!=
NULL
)
{
if
(
name
!=
NULL
)
{
tstrncpy
(
s
.
name
,
name
,
sizeof
(
s
.
name
));
tstrncpy
(
s
.
name
,
name
,
sizeof
(
s
.
name
));
}
else
{
}
else
{
tVariantToString
(
pVal
,
s
.
name
);
size_t
len
=
MIN
(
sizeof
(
s
.
name
),
exprStr
->
n
+
1
);
strdequote
(
s
.
name
);
tstrncpy
(
s
.
name
,
exprStr
->
z
,
len
);
}
}
return
s
;
return
s
;
...
@@ -132,7 +132,7 @@ int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t slidingTime, in
...
@@ -132,7 +132,7 @@ int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t slidingTime, in
* tablePrefix.columnName
* tablePrefix.columnName
* extract table name and save it in pTable, with only column name in pToken
* extract table name and save it in pTable, with only column name in pToken
*/
*/
void
extractTableNameFromToken
(
SS
QLToken
*
pToken
,
SSQL
Token
*
pTable
)
{
void
extractTableNameFromToken
(
SS
trToken
*
pToken
,
SStr
Token
*
pTable
)
{
const
char
sep
=
TS_PATH_DELIMITER
[
0
];
const
char
sep
=
TS_PATH_DELIMITER
[
0
];
if
(
pToken
==
pTable
||
pToken
==
NULL
||
pTable
==
NULL
)
{
if
(
pToken
==
pTable
||
pToken
==
NULL
||
pTable
==
NULL
)
{
...
...
src/common/src/tvariant.c
浏览文件 @
dac0a985
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
#include "tutil.h"
#include "tutil.h"
// todo support scientific expression number and oct number
// todo support scientific expression number and oct number
void
tVariantCreate
(
tVariant
*
pVar
,
SS
QL
Token
*
token
)
{
tVariantCreateFromString
(
pVar
,
token
->
z
,
token
->
n
,
token
->
type
);
}
void
tVariantCreate
(
tVariant
*
pVar
,
SS
tr
Token
*
token
)
{
tVariantCreateFromString
(
pVar
,
token
->
z
,
token
->
n
,
token
->
type
);
}
void
tVariantCreateFromString
(
tVariant
*
pVar
,
char
*
pz
,
uint32_t
len
,
uint32_t
type
)
{
void
tVariantCreateFromString
(
tVariant
*
pVar
,
char
*
pz
,
uint32_t
len
,
uint32_t
type
)
{
memset
(
pVar
,
0
,
sizeof
(
tVariant
));
memset
(
pVar
,
0
,
sizeof
(
tVariant
));
...
@@ -270,7 +270,7 @@ static int32_t doConvertToInteger(tVariant *pVariant, char *pDest, int32_t type,
...
@@ -270,7 +270,7 @@ static int32_t doConvertToInteger(tVariant *pVariant, char *pDest, int32_t type,
errno = 0;
errno = 0;
char *endPtr = NULL;
char *endPtr = NULL;
SS
QL
Token token = {0};
SS
tr
Token token = {0};
token.n = tSQLGetToken(pVariant->pz, &token.type);
token.n = tSQLGetToken(pVariant->pz, &token.type);
if (token.type == TK_MINUS || token.type == TK_PLUS) {
if (token.type == TK_MINUS || token.type == TK_PLUS) {
...
@@ -319,7 +319,7 @@ static int32_t doConvertToInteger(tVariant *pVariant, char *pDest, int32_t type,
...
@@ -319,7 +319,7 @@ static int32_t doConvertToInteger(tVariant *pVariant, char *pDest, int32_t type,
errno = 0;
errno = 0;
wchar_t *endPtr = NULL;
wchar_t *endPtr = NULL;
SS
QL
Token token = {0};
SS
tr
Token token = {0};
token.n = tSQLGetToken(pVariant->pz, &token.type);
token.n = tSQLGetToken(pVariant->pz, &token.type);
if (token.type == TK_MINUS || token.type == TK_PLUS) {
if (token.type == TK_MINUS || token.type == TK_PLUS) {
...
@@ -478,7 +478,7 @@ static int32_t toNchar(tVariant *pVariant, char **pDest, int32_t *pDestSize) {
...
@@ -478,7 +478,7 @@ static int32_t toNchar(tVariant *pVariant, char **pDest, int32_t *pDestSize) {
}
}
static
FORCE_INLINE
int32_t
convertToDouble
(
char
*
pStr
,
int32_t
len
,
double
*
value
)
{
static
FORCE_INLINE
int32_t
convertToDouble
(
char
*
pStr
,
int32_t
len
,
double
*
value
)
{
SS
QL
Token
stoken
=
{.
z
=
pStr
,
.
n
=
len
};
SS
tr
Token
stoken
=
{.
z
=
pStr
,
.
n
=
len
};
if
(
TK_ILLEGAL
==
isValidNumber
(
&
stoken
))
{
if
(
TK_ILLEGAL
==
isValidNumber
(
&
stoken
))
{
return
-
1
;
return
-
1
;
...
@@ -504,7 +504,7 @@ static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result
...
@@ -504,7 +504,7 @@ static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result
errno
=
0
;
errno
=
0
;
char
*
endPtr
=
NULL
;
char
*
endPtr
=
NULL
;
SS
QL
Token
token
=
{
0
};
SS
tr
Token
token
=
{
0
};
token
.
n
=
tSQLGetToken
(
pVariant
->
pz
,
&
token
.
type
);
token
.
n
=
tSQLGetToken
(
pVariant
->
pz
,
&
token
.
type
);
if
(
token
.
type
==
TK_MINUS
||
token
.
type
==
TK_PLUS
)
{
if
(
token
.
type
==
TK_MINUS
||
token
.
type
==
TK_PLUS
)
{
...
@@ -521,7 +521,7 @@ static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result
...
@@ -521,7 +521,7 @@ static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result
return
0
;
return
0
;
}
}
SS
QL
Token
sToken
=
{.
z
=
pVariant
->
pz
,
.
n
=
pVariant
->
nLen
};
SS
tr
Token
sToken
=
{.
z
=
pVariant
->
pz
,
.
n
=
pVariant
->
nLen
};
if
(
TK_ILLEGAL
==
isValidNumber
(
&
sToken
))
{
if
(
TK_ILLEGAL
==
isValidNumber
(
&
sToken
))
{
return
-
1
;
return
-
1
;
}
}
...
@@ -557,7 +557,7 @@ static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result
...
@@ -557,7 +557,7 @@ static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result
errno
=
0
;
errno
=
0
;
wchar_t
*
endPtr
=
NULL
;
wchar_t
*
endPtr
=
NULL
;
SS
QL
Token
token
=
{
0
};
SS
tr
Token
token
=
{
0
};
token
.
n
=
tSQLGetToken
(
pVariant
->
pz
,
&
token
.
type
);
token
.
n
=
tSQLGetToken
(
pVariant
->
pz
,
&
token
.
type
);
if
(
token
.
type
==
TK_MINUS
||
token
.
type
==
TK_PLUS
)
{
if
(
token
.
type
==
TK_MINUS
||
token
.
type
==
TK_PLUS
)
{
...
...
src/query/inc/qAst.h
浏览文件 @
dac0a985
...
@@ -80,7 +80,7 @@ void tExprTreeTraverse(tExprNode *pExpr, SSkipList *pSkipList, SArray *result, S
...
@@ -80,7 +80,7 @@ void tExprTreeTraverse(tExprNode *pExpr, SSkipList *pSkipList, SArray *result, S
void
tExprTreeCalcTraverse
(
tExprNode
*
pExprs
,
int32_t
numOfRows
,
char
*
pOutput
,
void
*
param
,
int32_t
order
,
void
tExprTreeCalcTraverse
(
tExprNode
*
pExprs
,
int32_t
numOfRows
,
char
*
pOutput
,
void
*
param
,
int32_t
order
,
char
*
(
*
cb
)(
void
*
,
const
char
*
,
int32_t
));
char
*
(
*
cb
)(
void
*
,
const
char
*
,
int32_t
));
uint8_t
getBinaryExprOptr
(
SS
QL
Token
*
pToken
);
uint8_t
getBinaryExprOptr
(
SS
tr
Token
*
pToken
);
void
tExprNodeDestroy
(
tExprNode
*
pNode
,
void
(
*
fp
)(
void
*
));
void
tExprNodeDestroy
(
tExprNode
*
pNode
,
void
(
*
fp
)(
void
*
));
void
exprTreeToBinary
(
SBufferWriter
*
bw
,
tExprNode
*
pExprTree
);
void
exprTreeToBinary
(
SBufferWriter
*
bw
,
tExprNode
*
pExprTree
);
...
...
src/query/inc/qSqlparser.h
浏览文件 @
dac0a985
...
@@ -26,7 +26,7 @@ extern "C" {
...
@@ -26,7 +26,7 @@ extern "C" {
#include "tstoken.h"
#include "tstoken.h"
#include "tvariant.h"
#include "tvariant.h"
#define ParseTOKENTYPE SS
QL
Token
#define ParseTOKENTYPE SS
tr
Token
extern
char
tTokenTypeSwitcher
[
13
];
extern
char
tTokenTypeSwitcher
[
13
];
#define toTSDBType(x) \
#define toTSDBType(x) \
...
@@ -71,16 +71,16 @@ typedef struct SQuerySQL {
...
@@ -71,16 +71,16 @@ typedef struct SQuerySQL {
struct
tSQLExpr
*
pWhere
;
// where clause [optional]
struct
tSQLExpr
*
pWhere
;
// where clause [optional]
tVariantList
*
pGroupby
;
// groupby clause, only for tags[optional]
tVariantList
*
pGroupby
;
// groupby clause, only for tags[optional]
tVariantList
*
pSortOrder
;
// orderby [optional]
tVariantList
*
pSortOrder
;
// orderby [optional]
SS
QL
Token
interval
;
// interval [optional]
SS
tr
Token
interval
;
// interval [optional]
SS
QL
Token
sliding
;
// sliding window [optional]
SS
tr
Token
sliding
;
// sliding window [optional]
SLimitVal
limit
;
// limit offset [optional]
SLimitVal
limit
;
// limit offset [optional]
SLimitVal
slimit
;
// group limit offset [optional]
SLimitVal
slimit
;
// group limit offset [optional]
tVariantList
*
fillType
;
// fill type[optional]
tVariantList
*
fillType
;
// fill type[optional]
SS
QL
Token
selectToken
;
// sql string
SS
tr
Token
selectToken
;
// sql string
}
SQuerySQL
;
}
SQuerySQL
;
typedef
struct
SCreateTableSQL
{
typedef
struct
SCreateTableSQL
{
struct
SS
QL
Token
name
;
// meter name, create table [meterName] xxx
struct
SS
tr
Token
name
;
// meter name, create table [meterName] xxx
bool
existCheck
;
bool
existCheck
;
int8_t
type
;
// create normal table/from super table/ stream
int8_t
type
;
// create normal table/from super table/ stream
...
@@ -90,7 +90,7 @@ typedef struct SCreateTableSQL {
...
@@ -90,7 +90,7 @@ typedef struct SCreateTableSQL {
}
colInfo
;
}
colInfo
;
struct
{
struct
{
SS
QL
Token
stableName
;
// super table name, for using clause
SS
tr
Token
stableName
;
// super table name, for using clause
tVariantList
*
pTagVals
;
// create by using metric, tag value
tVariantList
*
pTagVals
;
// create by using metric, tag value
STagData
tagdata
;
STagData
tagdata
;
}
usingInfo
;
}
usingInfo
;
...
@@ -99,7 +99,7 @@ typedef struct SCreateTableSQL {
...
@@ -99,7 +99,7 @@ typedef struct SCreateTableSQL {
}
SCreateTableSQL
;
}
SCreateTableSQL
;
typedef
struct
SAlterTableSQL
{
typedef
struct
SAlterTableSQL
{
SS
QL
Token
name
;
SS
tr
Token
name
;
int16_t
type
;
int16_t
type
;
STagData
tagData
;
STagData
tagData
;
...
@@ -108,7 +108,7 @@ typedef struct SAlterTableSQL {
...
@@ -108,7 +108,7 @@ typedef struct SAlterTableSQL {
}
SAlterTableSQL
;
}
SAlterTableSQL
;
typedef
struct
SCreateDBInfo
{
typedef
struct
SCreateDBInfo
{
SS
QL
Token
dbname
;
SS
tr
Token
dbname
;
int32_t
replica
;
int32_t
replica
;
int32_t
cacheBlockSize
;
int32_t
cacheBlockSize
;
int32_t
maxTablesPerVnode
;
int32_t
maxTablesPerVnode
;
...
@@ -121,7 +121,7 @@ typedef struct SCreateDBInfo {
...
@@ -121,7 +121,7 @@ typedef struct SCreateDBInfo {
int32_t
walLevel
;
int32_t
walLevel
;
int32_t
quorum
;
int32_t
quorum
;
int32_t
compressionLevel
;
int32_t
compressionLevel
;
SS
QL
Token
precision
;
SS
tr
Token
precision
;
bool
ignoreExists
;
bool
ignoreExists
;
tVariantList
*
keep
;
tVariantList
*
keep
;
...
@@ -136,33 +136,33 @@ typedef struct SCreateAcctSQL {
...
@@ -136,33 +136,33 @@ typedef struct SCreateAcctSQL {
int64_t
maxStorage
;
int64_t
maxStorage
;
int64_t
maxQueryTime
;
int64_t
maxQueryTime
;
int32_t
maxConnections
;
int32_t
maxConnections
;
SS
QL
Token
stat
;
SS
tr
Token
stat
;
}
SCreateAcctSQL
;
}
SCreateAcctSQL
;
typedef
struct
SShowInfo
{
typedef
struct
SShowInfo
{
uint8_t
showType
;
uint8_t
showType
;
SS
QL
Token
prefix
;
SS
tr
Token
prefix
;
SS
QL
Token
pattern
;
SS
tr
Token
pattern
;
}
SShowInfo
;
}
SShowInfo
;
typedef
struct
SUserInfo
{
typedef
struct
SUserInfo
{
SS
QL
Token
user
;
SS
tr
Token
user
;
SS
QL
Token
passwd
;
SS
tr
Token
passwd
;
SS
QL
Token
privilege
;
SS
tr
Token
privilege
;
int16_t
type
;
int16_t
type
;
}
SUserInfo
;
}
SUserInfo
;
typedef
struct
tDCLSQL
{
typedef
struct
tDCLSQL
{
int32_t
nTokens
;
/* Number of expressions on the list */
int32_t
nTokens
;
/* Number of expressions on the list */
int32_t
nAlloc
;
/* Number of entries allocated below */
int32_t
nAlloc
;
/* Number of entries allocated below */
SS
QL
Token
*
a
;
/* one entry for element */
SS
tr
Token
*
a
;
/* one entry for element */
bool
existsCheck
;
bool
existsCheck
;
union
{
union
{
SCreateDBInfo
dbOpt
;
SCreateDBInfo
dbOpt
;
SCreateAcctSQL
acctOpt
;
SCreateAcctSQL
acctOpt
;
SShowInfo
showOpt
;
SShowInfo
showOpt
;
SS
QL
Token
ip
;
SS
tr
Token
ip
;
};
};
SUserInfo
user
;
SUserInfo
user
;
...
@@ -194,14 +194,14 @@ typedef struct tSQLExpr {
...
@@ -194,14 +194,14 @@ typedef struct tSQLExpr {
// the full sql string of function(col, param), which is actually the raw
// the full sql string of function(col, param), which is actually the raw
// field name, since the function name is kept in nSQLOptr already
// field name, since the function name is kept in nSQLOptr already
SS
QL
Token
operand
;
SS
tr
Token
operand
;
SS
QL
Token
colInfo
;
// field id
SS
tr
Token
colInfo
;
// field id
tVariant
val
;
// value only for string, float, int
tVariant
val
;
// value only for string, float, int
struct
tSQLExpr
*
pLeft
;
// left child
struct
tSQLExpr
*
pLeft
;
// left child
struct
tSQLExpr
*
pRight
;
// right child
struct
tSQLExpr
*
pRight
;
// right child
struct
tSQLExprList
*
pParam
;
// function parameters
struct
tSQLExprList
*
pParam
;
// function parameters
SStrToken
token
;
// original sql expr string
}
tSQLExpr
;
}
tSQLExpr
;
// used in select clause. select <tSQLExprList> from xxx
// used in select clause. select <tSQLExprList> from xxx
...
@@ -243,7 +243,7 @@ tVariantList *tVariantListAppend(tVariantList *pList, tVariant *pVar, uint8_t so
...
@@ -243,7 +243,7 @@ tVariantList *tVariantListAppend(tVariantList *pList, tVariant *pVar, uint8_t so
tVariantList
*
tVariantListInsert
(
tVariantList
*
pList
,
tVariant
*
pVar
,
uint8_t
sortOrder
,
int32_t
index
);
tVariantList
*
tVariantListInsert
(
tVariantList
*
pList
,
tVariant
*
pVar
,
uint8_t
sortOrder
,
int32_t
index
);
tVariantList
*
tVariantListAppendToken
(
tVariantList
*
pList
,
SS
QL
Token
*
pAliasToken
,
uint8_t
sortOrder
);
tVariantList
*
tVariantListAppendToken
(
tVariantList
*
pList
,
SS
tr
Token
*
pAliasToken
,
uint8_t
sortOrder
);
void
tVariantListDestroy
(
tVariantList
*
pList
);
void
tVariantListDestroy
(
tVariantList
*
pList
);
tFieldList
*
tFieldListAppend
(
tFieldList
*
pList
,
TAOS_FIELD
*
pField
);
tFieldList
*
tFieldListAppend
(
tFieldList
*
pList
,
TAOS_FIELD
*
pField
);
...
@@ -254,61 +254,61 @@ tSQLExpr *tSQLExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optType);
...
@@ -254,61 +254,61 @@ tSQLExpr *tSQLExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optType);
void
tSQLExprDestroy
(
tSQLExpr
*
);
void
tSQLExprDestroy
(
tSQLExpr
*
);
tSQLExprList
*
tSQLExprListAppend
(
tSQLExprList
*
pList
,
tSQLExpr
*
pNode
,
SS
QL
Token
*
pToken
);
tSQLExprList
*
tSQLExprListAppend
(
tSQLExprList
*
pList
,
tSQLExpr
*
pNode
,
SS
tr
Token
*
pToken
);
void
tSQLExprListDestroy
(
tSQLExprList
*
pList
);
void
tSQLExprListDestroy
(
tSQLExprList
*
pList
);
SQuerySQL
*
tSetQuerySQLElems
(
SS
QL
Token
*
pSelectToken
,
tSQLExprList
*
pSelection
,
tVariantList
*
pFrom
,
tSQLExpr
*
pWhere
,
SQuerySQL
*
tSetQuerySQLElems
(
SS
tr
Token
*
pSelectToken
,
tSQLExprList
*
pSelection
,
tVariantList
*
pFrom
,
tSQLExpr
*
pWhere
,
tVariantList
*
pGroupby
,
tVariantList
*
pSortOrder
,
SS
QL
Token
*
pInterval
,
tVariantList
*
pGroupby
,
tVariantList
*
pSortOrder
,
SS
tr
Token
*
pInterval
,
SS
QL
Token
*
pSliding
,
tVariantList
*
pFill
,
SLimitVal
*
pLimit
,
SLimitVal
*
pGLimit
);
SS
tr
Token
*
pSliding
,
tVariantList
*
pFill
,
SLimitVal
*
pLimit
,
SLimitVal
*
pGLimit
);
SCreateTableSQL
*
tSetCreateSQLElems
(
tFieldList
*
pCols
,
tFieldList
*
pTags
,
SS
QL
Token
*
pMetricName
,
SCreateTableSQL
*
tSetCreateSQLElems
(
tFieldList
*
pCols
,
tFieldList
*
pTags
,
SS
tr
Token
*
pMetricName
,
tVariantList
*
pTagVals
,
SQuerySQL
*
pSelect
,
int32_t
type
);
tVariantList
*
pTagVals
,
SQuerySQL
*
pSelect
,
int32_t
type
);
void
tSQLExprNodeDestroy
(
tSQLExpr
*
pExpr
);
void
tSQLExprNodeDestroy
(
tSQLExpr
*
pExpr
);
tSQLExpr
*
tSQLExprNodeClone
(
tSQLExpr
*
pExpr
);
tSQLExpr
*
tSQLExprNodeClone
(
tSQLExpr
*
pExpr
);
SAlterTableSQL
*
tAlterTableSQLElems
(
SS
QL
Token
*
pMeterName
,
tFieldList
*
pCols
,
tVariantList
*
pVals
,
int32_t
type
);
SAlterTableSQL
*
tAlterTableSQLElems
(
SS
tr
Token
*
pMeterName
,
tFieldList
*
pCols
,
tVariantList
*
pVals
,
int32_t
type
);
tSQLExprListList
*
tSQLListListAppend
(
tSQLExprListList
*
pList
,
tSQLExprList
*
pExprList
);
tSQLExprListList
*
tSQLListListAppend
(
tSQLExprListList
*
pList
,
tSQLExprList
*
pExprList
);
void
destroyAllSelectClause
(
SSubclauseInfo
*
pSql
);
void
destroyAllSelectClause
(
SSubclauseInfo
*
pSql
);
void
doDestroyQuerySql
(
SQuerySQL
*
pSql
);
void
doDestroyQuerySql
(
SQuerySQL
*
pSql
);
SSqlInfo
*
setSQLInfo
(
SSqlInfo
*
pInfo
,
void
*
pSqlExprInfo
,
SS
QL
Token
*
pMeterName
,
int32_t
type
);
SSqlInfo
*
setSQLInfo
(
SSqlInfo
*
pInfo
,
void
*
pSqlExprInfo
,
SS
tr
Token
*
pMeterName
,
int32_t
type
);
SSubclauseInfo
*
setSubclause
(
SSubclauseInfo
*
pClause
,
void
*
pSqlExprInfo
);
SSubclauseInfo
*
setSubclause
(
SSubclauseInfo
*
pClause
,
void
*
pSqlExprInfo
);
SSubclauseInfo
*
appendSelectClause
(
SSubclauseInfo
*
pInfo
,
void
*
pSubclause
);
SSubclauseInfo
*
appendSelectClause
(
SSubclauseInfo
*
pInfo
,
void
*
pSubclause
);
void
setCreatedTableName
(
SSqlInfo
*
pInfo
,
SS
QLToken
*
pMeterName
,
SSQL
Token
*
pIfNotExists
);
void
setCreatedTableName
(
SSqlInfo
*
pInfo
,
SS
trToken
*
pMeterName
,
SStr
Token
*
pIfNotExists
);
void
SQLInfoDestroy
(
SSqlInfo
*
pInfo
);
void
SQLInfoDestroy
(
SSqlInfo
*
pInfo
);
void
setDCLSQLElems
(
SSqlInfo
*
pInfo
,
int32_t
type
,
int32_t
nParams
,
...);
void
setDCLSQLElems
(
SSqlInfo
*
pInfo
,
int32_t
type
,
int32_t
nParams
,
...);
void
setDropDBTableInfo
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
QLToken
*
pToken
,
SSQL
Token
*
existsCheck
);
void
setDropDBTableInfo
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
trToken
*
pToken
,
SStr
Token
*
existsCheck
);
void
setShowOptions
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
QLToken
*
prefix
,
SSQL
Token
*
pPatterns
);
void
setShowOptions
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
trToken
*
prefix
,
SStr
Token
*
pPatterns
);
tDCLSQL
*
tTokenListAppend
(
tDCLSQL
*
pTokenList
,
SS
QL
Token
*
pToken
);
tDCLSQL
*
tTokenListAppend
(
tDCLSQL
*
pTokenList
,
SS
tr
Token
*
pToken
);
void
setCreateDBSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
QLToken
*
pToken
,
SCreateDBInfo
*
pDB
,
SSQL
Token
*
pIgExists
);
void
setCreateDBSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
trToken
*
pToken
,
SCreateDBInfo
*
pDB
,
SStr
Token
*
pIgExists
);
void
setCreateAcctSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
QLToken
*
pName
,
SSQL
Token
*
pPwd
,
SCreateAcctSQL
*
pAcctInfo
);
void
setCreateAcctSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
trToken
*
pName
,
SStr
Token
*
pPwd
,
SCreateAcctSQL
*
pAcctInfo
);
void
setCreateUserSQL
(
SSqlInfo
*
pInfo
,
SS
QLToken
*
pName
,
SSQL
Token
*
pPasswd
);
void
setCreateUserSQL
(
SSqlInfo
*
pInfo
,
SS
trToken
*
pName
,
SStr
Token
*
pPasswd
);
void
setKillSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
QL
Token
*
ip
);
void
setKillSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
tr
Token
*
ip
);
void
setAlterUserSQL
(
SSqlInfo
*
pInfo
,
int16_t
type
,
SS
QLToken
*
pName
,
SSQLToken
*
pPwd
,
SSQL
Token
*
pPrivilege
);
void
setAlterUserSQL
(
SSqlInfo
*
pInfo
,
int16_t
type
,
SS
trToken
*
pName
,
SStrToken
*
pPwd
,
SStr
Token
*
pPrivilege
);
void
setDefaultCreateDbOption
(
SCreateDBInfo
*
pDBInfo
);
void
setDefaultCreateDbOption
(
SCreateDBInfo
*
pDBInfo
);
// prefix show db.tables;
// prefix show db.tables;
void
setDBName
(
SS
QLToken
*
pCpxName
,
SSQL
Token
*
pDB
);
void
setDBName
(
SS
trToken
*
pCpxName
,
SStr
Token
*
pDB
);
tSQLExpr
*
tSQLExprIdValueCreate
(
SS
QL
Token
*
pToken
,
int32_t
optType
);
tSQLExpr
*
tSQLExprIdValueCreate
(
SS
tr
Token
*
pToken
,
int32_t
optType
);
tSQLExpr
*
tSQLExprCreateFunction
(
tSQLExprList
*
pList
,
SS
QLToken
*
pFuncToken
,
SSQL
Token
*
endToken
,
int32_t
optType
);
tSQLExpr
*
tSQLExprCreateFunction
(
tSQLExprList
*
pList
,
SS
trToken
*
pFuncToken
,
SStr
Token
*
endToken
,
int32_t
optType
);
void
tSQLSetColumnInfo
(
TAOS_FIELD
*
pField
,
SS
QL
Token
*
pName
,
TAOS_FIELD
*
pType
);
void
tSQLSetColumnInfo
(
TAOS_FIELD
*
pField
,
SS
tr
Token
*
pName
,
TAOS_FIELD
*
pType
);
void
tSQLSetColumnType
(
TAOS_FIELD
*
pField
,
SS
QL
Token
*
pToken
);
void
tSQLSetColumnType
(
TAOS_FIELD
*
pField
,
SS
tr
Token
*
pToken
);
void
*
ParseAlloc
(
void
*
(
*
mallocProc
)(
size_t
));
void
*
ParseAlloc
(
void
*
(
*
mallocProc
)(
size_t
));
...
...
src/query/inc/sql.y
浏览文件 @
dac0a985
...
@@ -2,8 +2,8 @@
...
@@ -2,8 +2,8 @@
//usage: lemon sql.y
//usage: lemon sql.y
%token_prefix TK_
%token_prefix TK_
%token_type {SS
QL
Token}
%token_type {SS
tr
Token}
%default_type {SS
QL
Token}
%default_type {SS
tr
Token}
%extra_argument {SSqlInfo* pInfo}
%extra_argument {SSqlInfo* pInfo}
%fallback ID BOOL TINYINT SMALLINT INTEGER BIGINT FLOAT DOUBLE STRING TIMESTAMP BINARY NCHAR.
%fallback ID BOOL TINYINT SMALLINT INTEGER BIGINT FLOAT DOUBLE STRING TIMESTAMP BINARY NCHAR.
...
@@ -80,11 +80,11 @@ cmd ::= SHOW GRANTS. { setShowOptions(pInfo, TSDB_MGMT_TABLE_GRANTS, 0, 0);
...
@@ -80,11 +80,11 @@ cmd ::= SHOW GRANTS. { setShowOptions(pInfo, TSDB_MGMT_TABLE_GRANTS, 0, 0);
cmd ::= SHOW VNODES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_VNODES, 0, 0); }
cmd ::= SHOW VNODES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_VNODES, 0, 0); }
cmd ::= SHOW VNODES IPTOKEN(X). { setShowOptions(pInfo, TSDB_MGMT_TABLE_VNODES, &X, 0); }
cmd ::= SHOW VNODES IPTOKEN(X). { setShowOptions(pInfo, TSDB_MGMT_TABLE_VNODES, &X, 0); }
%type dbPrefix {SS
QL
Token}
%type dbPrefix {SS
tr
Token}
dbPrefix(A) ::=. {A.n = 0; A.type = 0;}
dbPrefix(A) ::=. {A.n = 0; A.type = 0;}
dbPrefix(A) ::= ids(X) DOT. {A = X; }
dbPrefix(A) ::= ids(X) DOT. {A = X; }
%type cpxName {SS
QL
Token}
%type cpxName {SS
tr
Token}
cpxName(A) ::= . {A.n = 0; }
cpxName(A) ::= . {A.n = 0; }
cpxName(A) ::= DOT ids(Y). {A = Y; A.n += 1; }
cpxName(A) ::= DOT ids(Y). {A = Y; A.n += 1; }
...
@@ -101,19 +101,19 @@ cmd ::= SHOW dbPrefix(X) STABLES. {
...
@@ -101,19 +101,19 @@ cmd ::= SHOW dbPrefix(X) STABLES. {
}
}
cmd ::= SHOW dbPrefix(X) STABLES LIKE ids(Y). {
cmd ::= SHOW dbPrefix(X) STABLES LIKE ids(Y). {
SS
QL
Token token;
SS
tr
Token token;
setDBName(&token, &X);
setDBName(&token, &X);
setShowOptions(pInfo, TSDB_MGMT_TABLE_METRIC, &token, &Y);
setShowOptions(pInfo, TSDB_MGMT_TABLE_METRIC, &token, &Y);
}
}
cmd ::= SHOW dbPrefix(X) VGROUPS. {
cmd ::= SHOW dbPrefix(X) VGROUPS. {
SS
QL
Token token;
SS
tr
Token token;
setDBName(&token, &X);
setDBName(&token, &X);
setShowOptions(pInfo, TSDB_MGMT_TABLE_VGROUP, &token, 0);
setShowOptions(pInfo, TSDB_MGMT_TABLE_VGROUP, &token, 0);
}
}
cmd ::= SHOW dbPrefix(X) VGROUPS ids(Y). {
cmd ::= SHOW dbPrefix(X) VGROUPS ids(Y). {
SS
QL
Token token;
SS
tr
Token token;
setDBName(&token, &X);
setDBName(&token, &X);
setShowOptions(pInfo, TSDB_MGMT_TABLE_VGROUP, &token, &Y);
setShowOptions(pInfo, TSDB_MGMT_TABLE_VGROUP, &token, &Y);
}
}
...
@@ -145,7 +145,7 @@ cmd ::= ALTER DNODE ids(X) ids(Y). { setDCLSQLElems(pInfo, TSDB_SQL
...
@@ -145,7 +145,7 @@ cmd ::= ALTER DNODE ids(X) ids(Y). { setDCLSQLElems(pInfo, TSDB_SQL
cmd ::= ALTER DNODE ids(X) ids(Y) ids(Z). { setDCLSQLElems(pInfo, TSDB_SQL_CFG_DNODE, 3, &X, &Y, &Z); }
cmd ::= ALTER DNODE ids(X) ids(Y) ids(Z). { setDCLSQLElems(pInfo, TSDB_SQL_CFG_DNODE, 3, &X, &Y, &Z); }
cmd ::= ALTER LOCAL ids(X). { setDCLSQLElems(pInfo, TSDB_SQL_CFG_LOCAL, 1, &X); }
cmd ::= ALTER LOCAL ids(X). { setDCLSQLElems(pInfo, TSDB_SQL_CFG_LOCAL, 1, &X); }
cmd ::= ALTER LOCAL ids(X) ids(Y). { setDCLSQLElems(pInfo, TSDB_SQL_CFG_LOCAL, 2, &X, &Y); }
cmd ::= ALTER LOCAL ids(X) ids(Y). { setDCLSQLElems(pInfo, TSDB_SQL_CFG_LOCAL, 2, &X, &Y); }
cmd ::= ALTER DATABASE ids(X) alter_db_optr(Y). { SS
QL
Token t = {0}; setCreateDBSQL(pInfo, TSDB_SQL_ALTER_DB, &X, &Y, &t);}
cmd ::= ALTER DATABASE ids(X) alter_db_optr(Y). { SS
tr
Token t = {0}; setCreateDBSQL(pInfo, TSDB_SQL_ALTER_DB, &X, &Y, &t);}
cmd ::= ALTER ACCOUNT ids(X) acct_optr(Z). { setCreateAcctSQL(pInfo, TSDB_SQL_ALTER_ACCT, &X, NULL, &Z);}
cmd ::= ALTER ACCOUNT ids(X) acct_optr(Z). { setCreateAcctSQL(pInfo, TSDB_SQL_ALTER_ACCT, &X, NULL, &Z);}
cmd ::= ALTER ACCOUNT ids(X) PASS ids(Y) acct_optr(Z). { setCreateAcctSQL(pInfo, TSDB_SQL_ALTER_ACCT, &X, &Y, &Z);}
cmd ::= ALTER ACCOUNT ids(X) PASS ids(Y) acct_optr(Z). { setCreateAcctSQL(pInfo, TSDB_SQL_ALTER_ACCT, &X, &Y, &Z);}
...
@@ -153,15 +153,15 @@ cmd ::= ALTER ACCOUNT ids(X) PASS ids(Y) acct_optr(Z). { setCreateAcctSQL(p
...
@@ -153,15 +153,15 @@ cmd ::= ALTER ACCOUNT ids(X) PASS ids(Y) acct_optr(Z). { setCreateAcctSQL(p
// An IDENTIFIER can be a generic identifier, or one of several keywords.
// An IDENTIFIER can be a generic identifier, or one of several keywords.
// Any non-standard keyword can also be an identifier.
// Any non-standard keyword can also be an identifier.
// And "ids" is an identifer-or-string.
// And "ids" is an identifer-or-string.
%type ids {SS
QL
Token}
%type ids {SS
tr
Token}
ids(A) ::= ID(X). {A = X; }
ids(A) ::= ID(X). {A = X; }
ids(A) ::= STRING(X). {A = X; }
ids(A) ::= STRING(X). {A = X; }
%type ifexists {SS
QL
Token}
%type ifexists {SS
tr
Token}
ifexists(X) ::= IF EXISTS. {X.n = 1;}
ifexists(X) ::= IF EXISTS. {X.n = 1;}
ifexists(X) ::= . {X.n = 0;}
ifexists(X) ::= . {X.n = 0;}
%type ifnotexists {SS
QL
Token}
%type ifnotexists {SS
tr
Token}
ifnotexists(X) ::= IF NOT EXISTS. {X.n = 1;}
ifnotexists(X) ::= IF NOT EXISTS. {X.n = 1;}
ifnotexists(X) ::= . {X.n = 0;}
ifnotexists(X) ::= . {X.n = 0;}
...
@@ -416,7 +416,7 @@ selcollist(A) ::= sclp(P) STAR. {
...
@@ -416,7 +416,7 @@ selcollist(A) ::= sclp(P) STAR. {
// An option "AS <id>" phrase that can follow one of the expressions that
// An option "AS <id>" phrase that can follow one of the expressions that
// define the result set, or one of the tables in the FROM clause.
// define the result set, or one of the tables in the FROM clause.
//
//
%type as {SS
QL
Token}
%type as {SS
tr
Token}
as(X) ::= AS ids(Y). { X = Y; }
as(X) ::= AS ids(Y). { X = Y; }
as(X) ::= ids(Y). { X = Y; }
as(X) ::= ids(Y). { X = Y; }
as(X) ::= . { X.n = 0; }
as(X) ::= . { X.n = 0; }
...
@@ -458,10 +458,10 @@ tablelist(A) ::= tablelist(Y) COMMA ids(X) cpxName(Z) ids(F). {
...
@@ -458,10 +458,10 @@ tablelist(A) ::= tablelist(Y) COMMA ids(X) cpxName(Z) ids(F). {
}
}
// The value of interval should be the form of "number+[a,s,m,h,d,n,y]" or "now"
// The value of interval should be the form of "number+[a,s,m,h,d,n,y]" or "now"
%type tmvar {SS
QL
Token}
%type tmvar {SS
tr
Token}
tmvar(A) ::= VARIABLE(X). {A = X;}
tmvar(A) ::= VARIABLE(X). {A = X;}
%type interval_opt {SS
QL
Token}
%type interval_opt {SS
tr
Token}
interval_opt(N) ::= INTERVAL LP tmvar(E) RP. {N = E; }
interval_opt(N) ::= INTERVAL LP tmvar(E) RP. {N = E; }
interval_opt(N) ::= . {N.n = 0; N.z = NULL; N.type = 0; }
interval_opt(N) ::= . {N.n = 0; N.z = NULL; N.type = 0; }
...
@@ -482,7 +482,7 @@ fill_opt(N) ::= FILL LP ID(Y) RP. {
...
@@ -482,7 +482,7 @@ fill_opt(N) ::= FILL LP ID(Y) RP. {
N = tVariantListAppendToken(NULL, &Y, -1);
N = tVariantListAppendToken(NULL, &Y, -1);
}
}
%type sliding_opt {SS
QL
Token}
%type sliding_opt {SS
tr
Token}
sliding_opt(K) ::= SLIDING LP tmvar(E) RP. {K = E; }
sliding_opt(K) ::= SLIDING LP tmvar(E) RP. {K = E; }
sliding_opt(K) ::= . {K.n = 0; K.z = NULL; K.type = 0; }
sliding_opt(K) ::= . {K.n = 0; K.z = NULL; K.type = 0; }
...
...
src/query/src/qAst.c
浏览文件 @
dac0a985
...
@@ -44,7 +44,7 @@
...
@@ -44,7 +44,7 @@
* ver 0.3, pipeline filter in the form of: (a+2)/9 > 14
* ver 0.3, pipeline filter in the form of: (a+2)/9 > 14
*
*
*/
*/
static
tExprNode
*
tExprNodeCreate
(
SSchema
*
pSchema
,
int32_t
numOfCols
,
SS
QL
Token
*
pToken
);
static
tExprNode
*
tExprNodeCreate
(
SSchema
*
pSchema
,
int32_t
numOfCols
,
SS
tr
Token
*
pToken
);
static
tExprNode
*
createSyntaxTree
(
SSchema
*
pSchema
,
int32_t
numOfCols
,
char
*
str
,
int32_t
*
i
);
static
tExprNode
*
createSyntaxTree
(
SSchema
*
pSchema
,
int32_t
numOfCols
,
char
*
str
,
int32_t
*
i
);
static
void
destroySyntaxTree
(
tExprNode
*
);
static
void
destroySyntaxTree
(
tExprNode
*
);
...
@@ -103,7 +103,7 @@ static void reviseBinaryExprIfNecessary(tExprNode **pLeft, tExprNode **pRight, u
...
@@ -103,7 +103,7 @@ static void reviseBinaryExprIfNecessary(tExprNode **pLeft, tExprNode **pRight, u
}
}
}
}
static
tExprNode
*
tExprNodeCreate
(
SSchema
*
pSchema
,
int32_t
numOfCols
,
SS
QL
Token
*
pToken
)
{
static
tExprNode
*
tExprNodeCreate
(
SSchema
*
pSchema
,
int32_t
numOfCols
,
SS
tr
Token
*
pToken
)
{
/* if the token is not a value, return false */
/* if the token is not a value, return false */
if
(
pToken
->
type
==
TK_RP
||
(
pToken
->
type
!=
TK_INTEGER
&&
pToken
->
type
!=
TK_FLOAT
&&
pToken
->
type
!=
TK_ID
&&
if
(
pToken
->
type
==
TK_RP
||
(
pToken
->
type
!=
TK_INTEGER
&&
pToken
->
type
!=
TK_FLOAT
&&
pToken
->
type
!=
TK_ID
&&
pToken
->
type
!=
TK_TBNAME
&&
pToken
->
type
!=
TK_STRING
&&
pToken
->
type
!=
TK_BOOL
))
{
pToken
->
type
!=
TK_TBNAME
&&
pToken
->
type
!=
TK_STRING
&&
pToken
->
type
!=
TK_BOOL
))
{
...
@@ -117,7 +117,7 @@ static tExprNode *tExprNodeCreate(SSchema *pSchema, int32_t numOfCols, SSQLToken
...
@@ -117,7 +117,7 @@ static tExprNode *tExprNodeCreate(SSchema *pSchema, int32_t numOfCols, SSQLToken
int32_t
i
=
0
;
int32_t
i
=
0
;
if
(
pToken
->
type
==
TK_ID
)
{
if
(
pToken
->
type
==
TK_ID
)
{
do
{
do
{
SS
QL
Token
tableToken
=
{
0
};
SS
tr
Token
tableToken
=
{
0
};
extractTableNameFromToken
(
pToken
,
&
tableToken
);
extractTableNameFromToken
(
pToken
,
&
tableToken
);
size_t
len
=
strlen
(
pSchema
[
i
].
name
);
size_t
len
=
strlen
(
pSchema
[
i
].
name
);
...
@@ -157,7 +157,7 @@ static tExprNode *tExprNodeCreate(SSchema *pSchema, int32_t numOfCols, SSQLToken
...
@@ -157,7 +157,7 @@ static tExprNode *tExprNodeCreate(SSchema *pSchema, int32_t numOfCols, SSQLToken
return
pNode
;
return
pNode
;
}
}
uint8_t
getBinaryExprOptr
(
SS
QL
Token
*
pToken
)
{
uint8_t
getBinaryExprOptr
(
SS
tr
Token
*
pToken
)
{
switch
(
pToken
->
type
)
{
switch
(
pToken
->
type
)
{
case
TK_LT
:
case
TK_LT
:
return
TSDB_RELATION_LESS
;
return
TSDB_RELATION_LESS
;
...
@@ -234,7 +234,7 @@ uint8_t isQueryOnPrimaryKey(const char *primaryColumnName, const tExprNode *pLef
...
@@ -234,7 +234,7 @@ uint8_t isQueryOnPrimaryKey(const char *primaryColumnName, const tExprNode *pLef
}
}
static
tExprNode
*
createSyntaxTree
(
SSchema
*
pSchema
,
int32_t
numOfCols
,
char
*
str
,
int32_t
*
i
)
{
static
tExprNode
*
createSyntaxTree
(
SSchema
*
pSchema
,
int32_t
numOfCols
,
char
*
str
,
int32_t
*
i
)
{
SS
QL
Token
t0
=
tStrGetToken
(
str
,
i
,
false
,
0
,
NULL
);
SS
tr
Token
t0
=
tStrGetToken
(
str
,
i
,
false
,
0
,
NULL
);
if
(
t0
.
n
==
0
)
{
if
(
t0
.
n
==
0
)
{
return
NULL
;
return
NULL
;
}
}
...
...
src/query/src/qParserImpl.c
浏览文件 @
dac0a985
...
@@ -33,7 +33,7 @@ SSqlInfo qSQLParse(const char *pStr) {
...
@@ -33,7 +33,7 @@ SSqlInfo qSQLParse(const char *pStr) {
int32_t
i
=
0
;
int32_t
i
=
0
;
while
(
1
)
{
while
(
1
)
{
SS
QL
Token
t0
=
{
0
};
SS
tr
Token
t0
=
{
0
};
if
(
pStr
[
i
]
==
0
)
{
if
(
pStr
[
i
]
==
0
)
{
Parse
(
pParser
,
0
,
t0
,
&
sqlInfo
);
Parse
(
pParser
,
0
,
t0
,
&
sqlInfo
);
...
@@ -73,7 +73,7 @@ abort_parse:
...
@@ -73,7 +73,7 @@ abort_parse:
return
sqlInfo
;
return
sqlInfo
;
}
}
tSQLExprList
*
tSQLExprListAppend
(
tSQLExprList
*
pList
,
tSQLExpr
*
pNode
,
SS
QL
Token
*
pToken
)
{
tSQLExprList
*
tSQLExprListAppend
(
tSQLExprList
*
pList
,
tSQLExpr
*
pNode
,
SS
tr
Token
*
pToken
)
{
if
(
pList
==
NULL
)
{
if
(
pList
==
NULL
)
{
pList
=
calloc
(
1
,
sizeof
(
tSQLExprList
));
pList
=
calloc
(
1
,
sizeof
(
tSQLExprList
));
}
}
...
@@ -117,41 +117,45 @@ void tSQLExprListDestroy(tSQLExprList *pList) {
...
@@ -117,41 +117,45 @@ void tSQLExprListDestroy(tSQLExprList *pList) {
free
(
pList
);
free
(
pList
);
}
}
tSQLExpr
*
tSQLExprIdValueCreate
(
SSQLToken
*
pAliasToken
,
int32_t
optrType
)
{
tSQLExpr
*
tSQLExprIdValueCreate
(
SStrToken
*
pToken
,
int32_t
optrType
)
{
tSQLExpr
*
nodePtr
=
calloc
(
1
,
sizeof
(
tSQLExpr
));
tSQLExpr
*
pSQLExpr
=
calloc
(
1
,
sizeof
(
tSQLExpr
));
if
(
pToken
!=
NULL
)
{
pSQLExpr
->
token
=
*
pToken
;
}
if
(
optrType
==
TK_INTEGER
||
optrType
==
TK_STRING
||
optrType
==
TK_FLOAT
||
optrType
==
TK_BOOL
)
{
if
(
optrType
==
TK_INTEGER
||
optrType
==
TK_STRING
||
optrType
==
TK_FLOAT
||
optrType
==
TK_BOOL
)
{
toTSDBType
(
p
Alias
Token
->
type
);
toTSDBType
(
pToken
->
type
);
tVariantCreate
(
&
nodePtr
->
val
,
pAlias
Token
);
tVariantCreate
(
&
pSQLExpr
->
val
,
p
Token
);
nodePt
r
->
nSQLOptr
=
optrType
;
pSQLExp
r
->
nSQLOptr
=
optrType
;
}
else
if
(
optrType
==
TK_NOW
)
{
}
else
if
(
optrType
==
TK_NOW
)
{
// default use microsecond
// default use microsecond
nodePt
r
->
val
.
i64Key
=
taosGetTimestamp
(
TSDB_TIME_PRECISION_MICRO
);
pSQLExp
r
->
val
.
i64Key
=
taosGetTimestamp
(
TSDB_TIME_PRECISION_MICRO
);
nodePt
r
->
val
.
nType
=
TSDB_DATA_TYPE_BIGINT
;
pSQLExp
r
->
val
.
nType
=
TSDB_DATA_TYPE_BIGINT
;
nodePt
r
->
nSQLOptr
=
TK_TIMESTAMP
;
// TK_TIMESTAMP used to denote the time value is in microsecond
pSQLExp
r
->
nSQLOptr
=
TK_TIMESTAMP
;
// TK_TIMESTAMP used to denote the time value is in microsecond
}
else
if
(
optrType
==
TK_VARIABLE
)
{
}
else
if
(
optrType
==
TK_VARIABLE
)
{
int32_t
ret
=
getTimestampInUsFromStr
(
p
AliasToken
->
z
,
pAliasToken
->
n
,
&
nodePt
r
->
val
.
i64Key
);
int32_t
ret
=
getTimestampInUsFromStr
(
p
Token
->
z
,
pToken
->
n
,
&
pSQLExp
r
->
val
.
i64Key
);
UNUSED
(
ret
);
UNUSED
(
ret
);
nodePt
r
->
val
.
nType
=
TSDB_DATA_TYPE_BIGINT
;
pSQLExp
r
->
val
.
nType
=
TSDB_DATA_TYPE_BIGINT
;
nodePt
r
->
nSQLOptr
=
TK_TIMESTAMP
;
pSQLExp
r
->
nSQLOptr
=
TK_TIMESTAMP
;
}
else
{
// it must be the column name (tk_id) if it is not the number
}
else
{
// it must be the column name (tk_id) if it is not the number
assert
(
optrType
==
TK_ID
||
optrType
==
TK_ALL
);
assert
(
optrType
==
TK_ID
||
optrType
==
TK_ALL
);
if
(
p
Alias
Token
!=
NULL
)
{
if
(
pToken
!=
NULL
)
{
nodePtr
->
colInfo
=
*
pAlias
Token
;
pSQLExpr
->
colInfo
=
*
p
Token
;
}
}
nodePt
r
->
nSQLOptr
=
optrType
;
pSQLExp
r
->
nSQLOptr
=
optrType
;
}
}
return
nodePt
r
;
return
pSQLExp
r
;
}
}
/*
/*
* pList is the parameters for function with id(optType)
* pList is the parameters for function with id(optType)
* function name is denoted by pFunctionToken
* function name is denoted by pFunctionToken
*/
*/
tSQLExpr
*
tSQLExprCreateFunction
(
tSQLExprList
*
pList
,
SS
QLToken
*
pFuncToken
,
SSQL
Token
*
endToken
,
int32_t
optType
)
{
tSQLExpr
*
tSQLExprCreateFunction
(
tSQLExprList
*
pList
,
SS
trToken
*
pFuncToken
,
SStr
Token
*
endToken
,
int32_t
optType
)
{
if
(
pFuncToken
==
NULL
)
return
NULL
;
if
(
pFuncToken
==
NULL
)
return
NULL
;
tSQLExpr
*
pExpr
=
calloc
(
1
,
sizeof
(
tSQLExpr
));
tSQLExpr
*
pExpr
=
calloc
(
1
,
sizeof
(
tSQLExpr
));
...
@@ -173,8 +177,12 @@ tSQLExpr *tSQLExprCreateFunction(tSQLExprList *pList, SSQLToken *pFuncToken, SSQ
...
@@ -173,8 +177,12 @@ tSQLExpr *tSQLExprCreateFunction(tSQLExprList *pList, SSQLToken *pFuncToken, SSQ
tSQLExpr
*
tSQLExprCreate
(
tSQLExpr
*
pLeft
,
tSQLExpr
*
pRight
,
int32_t
optrType
)
{
tSQLExpr
*
tSQLExprCreate
(
tSQLExpr
*
pLeft
,
tSQLExpr
*
pRight
,
int32_t
optrType
)
{
tSQLExpr
*
pExpr
=
calloc
(
1
,
sizeof
(
tSQLExpr
));
tSQLExpr
*
pExpr
=
calloc
(
1
,
sizeof
(
tSQLExpr
));
if
(
optrType
==
TK_PLUS
||
optrType
==
TK_MINUS
||
optrType
==
TK_STAR
||
optrType
==
TK_DIVIDE
||
char
*
endPos
=
pRight
->
token
.
z
+
pRight
->
token
.
n
;
optrType
==
TK_REM
)
{
pExpr
->
token
.
z
=
pLeft
->
token
.
z
;
pExpr
->
token
.
n
=
endPos
-
pExpr
->
token
.
z
;
pExpr
->
token
.
type
=
pLeft
->
token
.
type
;
if
(
optrType
==
TK_PLUS
||
optrType
==
TK_MINUS
||
optrType
==
TK_STAR
||
optrType
==
TK_DIVIDE
||
optrType
==
TK_REM
)
{
/*
/*
* if a token is noted as the TK_TIMESTAMP, the time precision is microsecond
* if a token is noted as the TK_TIMESTAMP, the time precision is microsecond
* Otherwise, the time precision is adaptive, determined by the time precision from databases.
* Otherwise, the time precision is adaptive, determined by the time precision from databases.
...
@@ -373,7 +381,7 @@ void tVariantListDestroy(tVariantList *pList) {
...
@@ -373,7 +381,7 @@ void tVariantListDestroy(tVariantList *pList) {
free
(
pList
);
free
(
pList
);
}
}
tVariantList
*
tVariantListAppendToken
(
tVariantList
*
pList
,
SS
QLToken
*
pAlias
Token
,
uint8_t
sortOrder
)
{
tVariantList
*
tVariantListAppendToken
(
tVariantList
*
pList
,
SS
trToken
*
p
Token
,
uint8_t
sortOrder
)
{
if
(
pList
==
NULL
)
{
if
(
pList
==
NULL
)
{
pList
=
calloc
(
1
,
sizeof
(
tVariantList
));
pList
=
calloc
(
1
,
sizeof
(
tVariantList
));
}
}
...
@@ -382,9 +390,9 @@ tVariantList *tVariantListAppendToken(tVariantList *pList, SSQLToken *pAliasToke
...
@@ -382,9 +390,9 @@ tVariantList *tVariantListAppendToken(tVariantList *pList, SSQLToken *pAliasToke
return
pList
;
return
pList
;
}
}
if
(
p
Alias
Token
)
{
if
(
pToken
)
{
tVariant
t
=
{
0
};
tVariant
t
=
{
0
};
tVariantCreate
(
&
t
,
p
Alias
Token
);
tVariantCreate
(
&
t
,
pToken
);
tVariantListItem
*
pItem
=
&
pList
->
a
[
pList
->
nExpr
++
];
tVariantListItem
*
pItem
=
&
pList
->
a
[
pList
->
nExpr
++
];
memcpy
(
pItem
,
&
t
,
sizeof
(
tVariant
));
memcpy
(
pItem
,
&
t
,
sizeof
(
tVariant
));
...
@@ -420,7 +428,7 @@ void tFieldListDestroy(tFieldList *pList) {
...
@@ -420,7 +428,7 @@ void tFieldListDestroy(tFieldList *pList) {
free
(
pList
);
free
(
pList
);
}
}
void
setDBName
(
SS
QLToken
*
pCpxName
,
SSQL
Token
*
pDB
)
{
void
setDBName
(
SS
trToken
*
pCpxName
,
SStr
Token
*
pDB
)
{
pCpxName
->
type
=
pDB
->
type
;
pCpxName
->
type
=
pDB
->
type
;
pCpxName
->
z
=
pDB
->
z
;
pCpxName
->
z
=
pDB
->
z
;
pCpxName
->
n
=
pDB
->
n
;
pCpxName
->
n
=
pDB
->
n
;
...
@@ -464,7 +472,7 @@ int32_t getTimestampInUsFromStrImpl(int64_t val, char unit, int64_t *result) {
...
@@ -464,7 +472,7 @@ int32_t getTimestampInUsFromStrImpl(int64_t val, char unit, int64_t *result) {
return
0
;
return
0
;
}
}
void
tSQLSetColumnInfo
(
TAOS_FIELD
*
pField
,
SS
QL
Token
*
pName
,
TAOS_FIELD
*
pType
)
{
void
tSQLSetColumnInfo
(
TAOS_FIELD
*
pField
,
SS
tr
Token
*
pName
,
TAOS_FIELD
*
pType
)
{
int32_t
maxLen
=
sizeof
(
pField
->
name
)
/
sizeof
(
pField
->
name
[
0
]);
int32_t
maxLen
=
sizeof
(
pField
->
name
)
/
sizeof
(
pField
->
name
[
0
]);
// truncate the column name
// truncate the column name
...
@@ -479,7 +487,7 @@ void tSQLSetColumnInfo(TAOS_FIELD *pField, SSQLToken *pName, TAOS_FIELD *pType)
...
@@ -479,7 +487,7 @@ void tSQLSetColumnInfo(TAOS_FIELD *pField, SSQLToken *pName, TAOS_FIELD *pType)
pField
->
bytes
=
pType
->
bytes
;
pField
->
bytes
=
pType
->
bytes
;
}
}
void
tSQLSetColumnType
(
TAOS_FIELD
*
pField
,
SS
QL
Token
*
type
)
{
void
tSQLSetColumnType
(
TAOS_FIELD
*
pField
,
SS
tr
Token
*
type
)
{
pField
->
type
=
-
1
;
pField
->
type
=
-
1
;
int32_t
LENGTH_SIZE_OF_STR
=
2
;
// in case of nchar and binary, there two bytes to keep the length of binary|nchar.
int32_t
LENGTH_SIZE_OF_STR
=
2
;
// in case of nchar and binary, there two bytes to keep the length of binary|nchar.
...
@@ -517,9 +525,9 @@ void tSQLSetColumnType(TAOS_FIELD *pField, SSQLToken *type) {
...
@@ -517,9 +525,9 @@ void tSQLSetColumnType(TAOS_FIELD *pField, SSQLToken *type) {
/*
/*
* extract the select info out of sql string
* extract the select info out of sql string
*/
*/
SQuerySQL
*
tSetQuerySQLElems
(
SS
QL
Token
*
pSelectToken
,
tSQLExprList
*
pSelection
,
tVariantList
*
pFrom
,
tSQLExpr
*
pWhere
,
SQuerySQL
*
tSetQuerySQLElems
(
SS
tr
Token
*
pSelectToken
,
tSQLExprList
*
pSelection
,
tVariantList
*
pFrom
,
tSQLExpr
*
pWhere
,
tVariantList
*
pGroupby
,
tVariantList
*
pSortOrder
,
SS
QL
Token
*
pInterval
,
tVariantList
*
pGroupby
,
tVariantList
*
pSortOrder
,
SS
tr
Token
*
pInterval
,
SS
QL
Token
*
pSliding
,
tVariantList
*
pFill
,
SLimitVal
*
pLimit
,
SLimitVal
*
pGLimit
)
{
SS
tr
Token
*
pSliding
,
tVariantList
*
pFill
,
SLimitVal
*
pLimit
,
SLimitVal
*
pGLimit
)
{
assert
(
pSelection
!=
NULL
);
assert
(
pSelection
!=
NULL
);
SQuerySQL
*
pQuery
=
calloc
(
1
,
sizeof
(
SQuerySQL
));
SQuerySQL
*
pQuery
=
calloc
(
1
,
sizeof
(
SQuerySQL
));
...
@@ -611,7 +619,7 @@ void destroyAllSelectClause(SSubclauseInfo *pClause) {
...
@@ -611,7 +619,7 @@ void destroyAllSelectClause(SSubclauseInfo *pClause) {
taosTFree
(
pClause
->
pClause
);
taosTFree
(
pClause
->
pClause
);
}
}
SCreateTableSQL
*
tSetCreateSQLElems
(
tFieldList
*
pCols
,
tFieldList
*
pTags
,
SS
QL
Token
*
pStableName
,
SCreateTableSQL
*
tSetCreateSQLElems
(
tFieldList
*
pCols
,
tFieldList
*
pTags
,
SS
tr
Token
*
pStableName
,
tVariantList
*
pTagVals
,
SQuerySQL
*
pSelect
,
int32_t
type
)
{
tVariantList
*
pTagVals
,
SQuerySQL
*
pSelect
,
int32_t
type
)
{
SCreateTableSQL
*
pCreate
=
calloc
(
1
,
sizeof
(
SCreateTableSQL
));
SCreateTableSQL
*
pCreate
=
calloc
(
1
,
sizeof
(
SCreateTableSQL
));
...
@@ -644,7 +652,7 @@ SCreateTableSQL *tSetCreateSQLElems(tFieldList *pCols, tFieldList *pTags, SSQLTo
...
@@ -644,7 +652,7 @@ SCreateTableSQL *tSetCreateSQLElems(tFieldList *pCols, tFieldList *pTags, SSQLTo
return
pCreate
;
return
pCreate
;
}
}
SAlterTableSQL
*
tAlterTableSQLElems
(
SS
QL
Token
*
pMeterName
,
tFieldList
*
pCols
,
tVariantList
*
pVals
,
int32_t
type
)
{
SAlterTableSQL
*
tAlterTableSQLElems
(
SS
tr
Token
*
pMeterName
,
tFieldList
*
pCols
,
tVariantList
*
pVals
,
int32_t
type
)
{
SAlterTableSQL
*
pAlterTable
=
calloc
(
1
,
sizeof
(
SAlterTableSQL
));
SAlterTableSQL
*
pAlterTable
=
calloc
(
1
,
sizeof
(
SAlterTableSQL
));
pAlterTable
->
name
=
*
pMeterName
;
pAlterTable
->
name
=
*
pMeterName
;
...
@@ -716,7 +724,7 @@ SSubclauseInfo* setSubclause(SSubclauseInfo* pSubclause, void *pSqlExprInfo) {
...
@@ -716,7 +724,7 @@ SSubclauseInfo* setSubclause(SSubclauseInfo* pSubclause, void *pSqlExprInfo) {
return
pSubclause
;
return
pSubclause
;
}
}
SSqlInfo
*
setSQLInfo
(
SSqlInfo
*
pInfo
,
void
*
pSqlExprInfo
,
SS
QL
Token
*
pMeterName
,
int32_t
type
)
{
SSqlInfo
*
setSQLInfo
(
SSqlInfo
*
pInfo
,
void
*
pSqlExprInfo
,
SS
tr
Token
*
pMeterName
,
int32_t
type
)
{
pInfo
->
type
=
type
;
pInfo
->
type
=
type
;
if
(
type
==
TSDB_SQL_SELECT
)
{
if
(
type
==
TSDB_SQL_SELECT
)
{
...
@@ -745,7 +753,7 @@ SSubclauseInfo* appendSelectClause(SSubclauseInfo *pQueryInfo, void *pSubclause)
...
@@ -745,7 +753,7 @@ SSubclauseInfo* appendSelectClause(SSubclauseInfo *pQueryInfo, void *pSubclause)
return
pQueryInfo
;
return
pQueryInfo
;
}
}
void
setCreatedTableName
(
SSqlInfo
*
pInfo
,
SS
QLToken
*
pMeterName
,
SSQL
Token
*
pIfNotExists
)
{
void
setCreatedTableName
(
SSqlInfo
*
pInfo
,
SS
trToken
*
pMeterName
,
SStr
Token
*
pIfNotExists
)
{
pInfo
->
pCreateTableInfo
->
name
=
*
pMeterName
;
pInfo
->
pCreateTableInfo
->
name
=
*
pMeterName
;
pInfo
->
pCreateTableInfo
->
existCheck
=
(
pIfNotExists
->
n
!=
0
);
pInfo
->
pCreateTableInfo
->
existCheck
=
(
pIfNotExists
->
n
!=
0
);
}
}
...
@@ -760,7 +768,7 @@ void tTokenListBuyMoreSpace(tDCLSQL *pTokenList) {
...
@@ -760,7 +768,7 @@ void tTokenListBuyMoreSpace(tDCLSQL *pTokenList) {
}
}
}
}
tDCLSQL
*
tTokenListAppend
(
tDCLSQL
*
pTokenList
,
SS
QL
Token
*
pToken
)
{
tDCLSQL
*
tTokenListAppend
(
tDCLSQL
*
pTokenList
,
SS
tr
Token
*
pToken
)
{
if
(
pToken
==
NULL
)
return
NULL
;
if
(
pToken
==
NULL
)
return
NULL
;
if
(
pTokenList
==
NULL
)
pTokenList
=
calloc
(
1
,
sizeof
(
tDCLSQL
));
if
(
pTokenList
==
NULL
)
pTokenList
=
calloc
(
1
,
sizeof
(
tDCLSQL
));
...
@@ -781,19 +789,19 @@ void setDCLSQLElems(SSqlInfo *pInfo, int32_t type, int32_t nParam, ...) {
...
@@ -781,19 +789,19 @@ void setDCLSQLElems(SSqlInfo *pInfo, int32_t type, int32_t nParam, ...) {
va_start
(
va
,
nParam
);
va_start
(
va
,
nParam
);
while
(
nParam
--
>
0
)
{
while
(
nParam
--
>
0
)
{
SS
QLToken
*
pToken
=
va_arg
(
va
,
SSQL
Token
*
);
SS
trToken
*
pToken
=
va_arg
(
va
,
SStr
Token
*
);
pInfo
->
pDCLInfo
=
tTokenListAppend
(
pInfo
->
pDCLInfo
,
pToken
);
pInfo
->
pDCLInfo
=
tTokenListAppend
(
pInfo
->
pDCLInfo
,
pToken
);
}
}
va_end
(
va
);
va_end
(
va
);
}
}
void
setDropDBTableInfo
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
QLToken
*
pToken
,
SSQL
Token
*
existsCheck
)
{
void
setDropDBTableInfo
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
trToken
*
pToken
,
SStr
Token
*
existsCheck
)
{
pInfo
->
type
=
type
;
pInfo
->
type
=
type
;
pInfo
->
pDCLInfo
=
tTokenListAppend
(
pInfo
->
pDCLInfo
,
pToken
);
pInfo
->
pDCLInfo
=
tTokenListAppend
(
pInfo
->
pDCLInfo
,
pToken
);
pInfo
->
pDCLInfo
->
existsCheck
=
(
existsCheck
->
n
==
1
);
pInfo
->
pDCLInfo
->
existsCheck
=
(
existsCheck
->
n
==
1
);
}
}
void
setShowOptions
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
QLToken
*
prefix
,
SSQL
Token
*
pPatterns
)
{
void
setShowOptions
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
trToken
*
prefix
,
SStr
Token
*
pPatterns
)
{
if
(
pInfo
->
pDCLInfo
==
NULL
)
{
if
(
pInfo
->
pDCLInfo
==
NULL
)
{
pInfo
->
pDCLInfo
=
calloc
(
1
,
sizeof
(
tDCLSQL
));
pInfo
->
pDCLInfo
=
calloc
(
1
,
sizeof
(
tDCLSQL
));
}
}
...
@@ -816,7 +824,7 @@ void setShowOptions(SSqlInfo *pInfo, int32_t type, SSQLToken* prefix, SSQLToken*
...
@@ -816,7 +824,7 @@ void setShowOptions(SSqlInfo *pInfo, int32_t type, SSQLToken* prefix, SSQLToken*
}
}
}
}
void
setCreateDBSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
QLToken
*
pToken
,
SCreateDBInfo
*
pDB
,
SSQL
Token
*
pIgExists
)
{
void
setCreateDBSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
trToken
*
pToken
,
SCreateDBInfo
*
pDB
,
SStr
Token
*
pIgExists
)
{
pInfo
->
type
=
type
;
pInfo
->
type
=
type
;
if
(
pInfo
->
pDCLInfo
==
NULL
)
{
if
(
pInfo
->
pDCLInfo
==
NULL
)
{
pInfo
->
pDCLInfo
=
calloc
(
1
,
sizeof
(
tDCLSQL
));
pInfo
->
pDCLInfo
=
calloc
(
1
,
sizeof
(
tDCLSQL
));
...
@@ -827,7 +835,7 @@ void setCreateDBSQL(SSqlInfo *pInfo, int32_t type, SSQLToken *pToken, SCreateDBI
...
@@ -827,7 +835,7 @@ void setCreateDBSQL(SSqlInfo *pInfo, int32_t type, SSQLToken *pToken, SCreateDBI
pInfo
->
pDCLInfo
->
dbOpt
.
ignoreExists
=
pIgExists
->
n
;
// sql.y has: ifnotexists(X) ::= IF NOT EXISTS. {X.n = 1;}
pInfo
->
pDCLInfo
->
dbOpt
.
ignoreExists
=
pIgExists
->
n
;
// sql.y has: ifnotexists(X) ::= IF NOT EXISTS. {X.n = 1;}
}
}
void
setCreateAcctSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
QLToken
*
pName
,
SSQL
Token
*
pPwd
,
SCreateAcctSQL
*
pAcctInfo
)
{
void
setCreateAcctSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
trToken
*
pName
,
SStr
Token
*
pPwd
,
SCreateAcctSQL
*
pAcctInfo
)
{
pInfo
->
type
=
type
;
pInfo
->
type
=
type
;
if
(
pInfo
->
pDCLInfo
==
NULL
)
{
if
(
pInfo
->
pDCLInfo
==
NULL
)
{
pInfo
->
pDCLInfo
=
calloc
(
1
,
sizeof
(
tDCLSQL
));
pInfo
->
pDCLInfo
=
calloc
(
1
,
sizeof
(
tDCLSQL
));
...
@@ -843,7 +851,7 @@ void setCreateAcctSQL(SSqlInfo *pInfo, int32_t type, SSQLToken *pName, SSQLToken
...
@@ -843,7 +851,7 @@ void setCreateAcctSQL(SSqlInfo *pInfo, int32_t type, SSQLToken *pName, SSQLToken
}
}
}
}
void
setCreateUserSQL
(
SSqlInfo
*
pInfo
,
SS
QLToken
*
pName
,
SSQL
Token
*
pPasswd
)
{
void
setCreateUserSQL
(
SSqlInfo
*
pInfo
,
SS
trToken
*
pName
,
SStr
Token
*
pPasswd
)
{
pInfo
->
type
=
TSDB_SQL_CREATE_USER
;
pInfo
->
type
=
TSDB_SQL_CREATE_USER
;
if
(
pInfo
->
pDCLInfo
==
NULL
)
{
if
(
pInfo
->
pDCLInfo
==
NULL
)
{
pInfo
->
pDCLInfo
=
calloc
(
1
,
sizeof
(
tDCLSQL
));
pInfo
->
pDCLInfo
=
calloc
(
1
,
sizeof
(
tDCLSQL
));
...
@@ -855,7 +863,7 @@ void setCreateUserSQL(SSqlInfo *pInfo, SSQLToken *pName, SSQLToken *pPasswd) {
...
@@ -855,7 +863,7 @@ void setCreateUserSQL(SSqlInfo *pInfo, SSQLToken *pName, SSQLToken *pPasswd) {
pInfo
->
pDCLInfo
->
user
.
passwd
=
*
pPasswd
;
pInfo
->
pDCLInfo
->
user
.
passwd
=
*
pPasswd
;
}
}
void
setAlterUserSQL
(
SSqlInfo
*
pInfo
,
int16_t
type
,
SS
QLToken
*
pName
,
SSQLToken
*
pPwd
,
SSQL
Token
*
pPrivilege
)
{
void
setAlterUserSQL
(
SSqlInfo
*
pInfo
,
int16_t
type
,
SS
trToken
*
pName
,
SStrToken
*
pPwd
,
SStr
Token
*
pPrivilege
)
{
pInfo
->
type
=
TSDB_SQL_ALTER_USER
;
pInfo
->
type
=
TSDB_SQL_ALTER_USER
;
if
(
pInfo
->
pDCLInfo
==
NULL
)
{
if
(
pInfo
->
pDCLInfo
==
NULL
)
{
pInfo
->
pDCLInfo
=
calloc
(
1
,
sizeof
(
tDCLSQL
));
pInfo
->
pDCLInfo
=
calloc
(
1
,
sizeof
(
tDCLSQL
));
...
@@ -880,7 +888,7 @@ void setAlterUserSQL(SSqlInfo *pInfo, int16_t type, SSQLToken *pName, SSQLToken*
...
@@ -880,7 +888,7 @@ void setAlterUserSQL(SSqlInfo *pInfo, int16_t type, SSQLToken *pName, SSQLToken*
}
}
}
}
void
setKillSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
QL
Token
*
ip
)
{
void
setKillSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
tr
Token
*
ip
)
{
pInfo
->
type
=
type
;
pInfo
->
type
=
type
;
if
(
pInfo
->
pDCLInfo
==
NULL
)
{
if
(
pInfo
->
pDCLInfo
==
NULL
)
{
pInfo
->
pDCLInfo
=
calloc
(
1
,
sizeof
(
tDCLSQL
));
pInfo
->
pDCLInfo
=
calloc
(
1
,
sizeof
(
tDCLSQL
));
...
@@ -909,5 +917,5 @@ void setDefaultCreateDbOption(SCreateDBInfo *pDBInfo) {
...
@@ -909,5 +917,5 @@ void setDefaultCreateDbOption(SCreateDBInfo *pDBInfo) {
pDBInfo
->
quorum
=
-
1
;
pDBInfo
->
quorum
=
-
1
;
pDBInfo
->
keep
=
NULL
;
pDBInfo
->
keep
=
NULL
;
memset
(
&
pDBInfo
->
precision
,
0
,
sizeof
(
SS
QL
Token
));
memset
(
&
pDBInfo
->
precision
,
0
,
sizeof
(
SS
tr
Token
));
}
}
src/query/src/qTokenizer.c
浏览文件 @
dac0a985
...
@@ -580,8 +580,8 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
...
@@ -580,8 +580,8 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
return
0
;
return
0
;
}
}
SS
QL
Token
tStrGetToken
(
char
*
str
,
int32_t
*
i
,
bool
isPrevOptr
,
uint32_t
numOfIgnoreToken
,
uint32_t
*
ignoreTokenTypes
)
{
SS
tr
Token
tStrGetToken
(
char
*
str
,
int32_t
*
i
,
bool
isPrevOptr
,
uint32_t
numOfIgnoreToken
,
uint32_t
*
ignoreTokenTypes
)
{
SS
QL
Token
t0
=
{
0
};
SS
tr
Token
t0
=
{
0
};
// here we reach the end of sql string, null-terminated string
// here we reach the end of sql string, null-terminated string
if
(
str
[
*
i
]
==
0
)
{
if
(
str
[
*
i
]
==
0
)
{
...
...
src/query/src/sql.c
浏览文件 @
dac0a985
...
@@ -99,7 +99,7 @@
...
@@ -99,7 +99,7 @@
#define YYCODETYPE unsigned short int
#define YYCODETYPE unsigned short int
#define YYNOCODE 274
#define YYNOCODE 274
#define YYACTIONTYPE unsigned short int
#define YYACTIONTYPE unsigned short int
#define ParseTOKENTYPE SS
QL
Token
#define ParseTOKENTYPE SS
tr
Token
typedef
union
{
typedef
union
{
int
yyinit
;
int
yyinit
;
ParseTOKENTYPE
yy0
;
ParseTOKENTYPE
yy0
;
...
@@ -2074,21 +2074,21 @@ static void yy_reduce(
...
@@ -2074,21 +2074,21 @@ static void yy_reduce(
break
;
break
;
case
22
:
/* cmd ::= SHOW dbPrefix STABLES LIKE ids */
case
22
:
/* cmd ::= SHOW dbPrefix STABLES LIKE ids */
{
{
SS
QL
Token
token
;
SS
tr
Token
token
;
setDBName
(
&
token
,
&
yymsp
[
-
3
].
minor
.
yy0
);
setDBName
(
&
token
,
&
yymsp
[
-
3
].
minor
.
yy0
);
setShowOptions
(
pInfo
,
TSDB_MGMT_TABLE_METRIC
,
&
token
,
&
yymsp
[
0
].
minor
.
yy0
);
setShowOptions
(
pInfo
,
TSDB_MGMT_TABLE_METRIC
,
&
token
,
&
yymsp
[
0
].
minor
.
yy0
);
}
}
break
;
break
;
case
23
:
/* cmd ::= SHOW dbPrefix VGROUPS */
case
23
:
/* cmd ::= SHOW dbPrefix VGROUPS */
{
{
SS
QL
Token
token
;
SS
tr
Token
token
;
setDBName
(
&
token
,
&
yymsp
[
-
1
].
minor
.
yy0
);
setDBName
(
&
token
,
&
yymsp
[
-
1
].
minor
.
yy0
);
setShowOptions
(
pInfo
,
TSDB_MGMT_TABLE_VGROUP
,
&
token
,
0
);
setShowOptions
(
pInfo
,
TSDB_MGMT_TABLE_VGROUP
,
&
token
,
0
);
}
}
break
;
break
;
case
24
:
/* cmd ::= SHOW dbPrefix VGROUPS ids */
case
24
:
/* cmd ::= SHOW dbPrefix VGROUPS ids */
{
{
SS
QL
Token
token
;
SS
tr
Token
token
;
setDBName
(
&
token
,
&
yymsp
[
-
2
].
minor
.
yy0
);
setDBName
(
&
token
,
&
yymsp
[
-
2
].
minor
.
yy0
);
setShowOptions
(
pInfo
,
TSDB_MGMT_TABLE_VGROUP
,
&
token
,
&
yymsp
[
0
].
minor
.
yy0
);
setShowOptions
(
pInfo
,
TSDB_MGMT_TABLE_VGROUP
,
&
token
,
&
yymsp
[
0
].
minor
.
yy0
);
}
}
...
@@ -2139,7 +2139,7 @@ static void yy_reduce(
...
@@ -2139,7 +2139,7 @@ static void yy_reduce(
{
setDCLSQLElems
(
pInfo
,
TSDB_SQL_CFG_LOCAL
,
2
,
&
yymsp
[
-
1
].
minor
.
yy0
,
&
yymsp
[
0
].
minor
.
yy0
);
}
{
setDCLSQLElems
(
pInfo
,
TSDB_SQL_CFG_LOCAL
,
2
,
&
yymsp
[
-
1
].
minor
.
yy0
,
&
yymsp
[
0
].
minor
.
yy0
);
}
break
;
break
;
case
38
:
/* cmd ::= ALTER DATABASE ids alter_db_optr */
case
38
:
/* cmd ::= ALTER DATABASE ids alter_db_optr */
{
SS
QL
Token
t
=
{
0
};
setCreateDBSQL
(
pInfo
,
TSDB_SQL_ALTER_DB
,
&
yymsp
[
-
1
].
minor
.
yy0
,
&
yymsp
[
0
].
minor
.
yy268
,
&
t
);}
{
SS
tr
Token
t
=
{
0
};
setCreateDBSQL
(
pInfo
,
TSDB_SQL_ALTER_DB
,
&
yymsp
[
-
1
].
minor
.
yy0
,
&
yymsp
[
0
].
minor
.
yy268
,
&
t
);}
break
;
break
;
case
39
:
/* cmd ::= ALTER ACCOUNT ids acct_optr */
case
39
:
/* cmd ::= ALTER ACCOUNT ids acct_optr */
{
setCreateAcctSQL
(
pInfo
,
TSDB_SQL_ALTER_ACCT
,
&
yymsp
[
-
1
].
minor
.
yy0
,
NULL
,
&
yymsp
[
0
].
minor
.
yy149
);}
{
setCreateAcctSQL
(
pInfo
,
TSDB_SQL_ALTER_ACCT
,
&
yymsp
[
-
1
].
minor
.
yy0
,
NULL
,
&
yymsp
[
0
].
minor
.
yy149
);}
...
...
src/query/tests/unitTest.cpp
浏览文件 @
dac0a985
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
namespace
{
namespace
{
int32_t
testValidateName
(
char
*
name
)
{
int32_t
testValidateName
(
char
*
name
)
{
SS
QL
Token
token
=
{
0
};
SS
tr
Token
token
=
{
0
};
token
.
z
=
name
;
token
.
z
=
name
;
token
.
n
=
strlen
(
name
);
token
.
n
=
strlen
(
name
);
token
.
type
=
0
;
token
.
type
=
0
;
...
@@ -720,8 +720,8 @@ TEST(testCase, tGetToken_Test) {
...
@@ -720,8 +720,8 @@ TEST(testCase, tGetToken_Test) {
EXPECT_FALSE
(
type
==
TK_HEX
);
EXPECT_FALSE
(
type
==
TK_HEX
);
}
}
static
SS
QL
Token
createStrToken
(
char
*
s
)
{
static
SS
tr
Token
createStrToken
(
char
*
s
)
{
SS
QL
Token
t
=
{
0
};
//.type = TK_STRING, .z = s, .n = strlen(s)};
SS
tr
Token
t
=
{
0
};
//.type = TK_STRING, .z = s, .n = strlen(s)};
t
.
type
=
TK_STRING
;
t
.
type
=
TK_STRING
;
t
.
z
=
s
;
t
.
z
=
s
;
t
.
n
=
strlen
(
s
);
t
.
n
=
strlen
(
s
);
...
@@ -730,7 +730,7 @@ static SSQLToken createStrToken(char* s) {
...
@@ -730,7 +730,7 @@ static SSQLToken createStrToken(char* s) {
}
}
TEST
(
testCase
,
isValidNumber_test
)
{
TEST
(
testCase
,
isValidNumber_test
)
{
SS
QL
Token
t1
=
createStrToken
(
"123abc"
);
SS
tr
Token
t1
=
createStrToken
(
"123abc"
);
EXPECT_EQ
(
isValidNumber
(
&
t1
),
TK_ILLEGAL
);
EXPECT_EQ
(
isValidNumber
(
&
t1
),
TK_ILLEGAL
);
...
...
src/util/inc/tstoken.h
浏览文件 @
dac0a985
...
@@ -28,11 +28,11 @@ extern "C" {
...
@@ -28,11 +28,11 @@ extern "C" {
#define TSQL_TBNAME_L "tbname"
#define TSQL_TBNAME_L "tbname"
// used to denote the minimum unite in sql parsing
// used to denote the minimum unite in sql parsing
typedef
struct
SS
QL
Token
{
typedef
struct
SS
tr
Token
{
uint32_t
n
;
uint32_t
n
;
uint32_t
type
;
uint32_t
type
;
char
*
z
;
char
*
z
;
}
SS
QL
Token
;
}
SS
tr
Token
;
/**
/**
* tokenizer for sql string
* tokenizer for sql string
...
@@ -52,7 +52,7 @@ uint32_t tSQLGetToken(char *z, uint32_t *tokenType);
...
@@ -52,7 +52,7 @@ uint32_t tSQLGetToken(char *z, uint32_t *tokenType);
* @param ignoreTokenTypes
* @param ignoreTokenTypes
* @return
* @return
*/
*/
SS
QL
Token
tStrGetToken
(
char
*
str
,
int32_t
*
i
,
bool
isPrevOptr
,
uint32_t
numOfIgnoreToken
,
uint32_t
*
ignoreTokenTypes
);
SS
tr
Token
tStrGetToken
(
char
*
str
,
int32_t
*
i
,
bool
isPrevOptr
,
uint32_t
numOfIgnoreToken
,
uint32_t
*
ignoreTokenTypes
);
/**
/**
* check if it is a keyword or not
* check if it is a keyword or not
...
@@ -76,7 +76,7 @@ bool isKeyWord(const char *z, int32_t len);
...
@@ -76,7 +76,7 @@ bool isKeyWord(const char *z, int32_t len);
* @param pToken
* @param pToken
* @return token type, if it is not a number, TK_ILLEGAL will return
* @return token type, if it is not a number, TK_ILLEGAL will return
*/
*/
static
FORCE_INLINE
int32_t
isValidNumber
(
const
SS
QL
Token
*
pToken
)
{
static
FORCE_INLINE
int32_t
isValidNumber
(
const
SS
tr
Token
*
pToken
)
{
const
char
*
z
=
pToken
->
z
;
const
char
*
z
=
pToken
->
z
;
int32_t
type
=
TK_ILLEGAL
;
int32_t
type
=
TK_ILLEGAL
;
...
...
tests/script/general/parser/
bug
.sim
→
tests/script/general/parser/
constCol
.sim
浏览文件 @
dac0a985
文件已移动
tests/script/general/parser/testSuite.sim
浏览文件 @
dac0a985
...
@@ -97,7 +97,7 @@ run general/parser/topbot.sim
...
@@ -97,7 +97,7 @@ run general/parser/topbot.sim
sleep 2000
sleep 2000
run general/parser/union.sim
run general/parser/union.sim
sleep 2000
sleep 2000
run general/parser/
bug
.sim
run general/parser/
constCol
.sim
sleep 2000
sleep 2000
run general/parser/sliding.sim
run general/parser/sliding.sim
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录