Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_44632607
TDengine
提交
6c2cf346
T
TDengine
项目概览
weixin_44632607
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6c2cf346
编写于
11月 25, 2019
作者:
H
hjxilinx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor some codes.
上级
553df7ff
变更
27
展开全部
隐藏空白更改
内联
并排
Showing
27 changed file
with
382 addition
and
379 deletion
+382
-379
src/client/inc/tscSQLParser.h
src/client/inc/tscSQLParser.h
+3
-19
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+1
-1
src/client/src/sql.c
src/client/src/sql.c
+3
-3
src/client/src/tscAst.c
src/client/src/tscAst.c
+7
-3
src/client/src/tscAsync.c
src/client/src/tscAsync.c
+1
-1
src/client/src/tscPrepare.c
src/client/src/tscPrepare.c
+1
-1
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+214
-100
src/client/src/tscSQLParserImpl.c
src/client/src/tscSQLParserImpl.c
+25
-4
src/client/src/tscSecondaryMerge.c
src/client/src/tscSecondaryMerge.c
+0
-1
src/client/src/tscServer.c
src/client/src/tscServer.c
+1
-1
src/client/src/tscSql.c
src/client/src/tscSql.c
+1
-1
src/client/src/tscStream.c
src/client/src/tscStream.c
+1
-1
src/client/src/tscSyntaxtreefunction.c
src/client/src/tscSyntaxtreefunction.c
+1
-1
src/inc/sql.y
src/inc/sql.y
+4
-3
src/inc/tast.h
src/inc/tast.h
+2
-2
src/inc/tsdb.h
src/inc/tsdb.h
+7
-5
src/inc/tsqlfunction.h
src/inc/tsqlfunction.h
+0
-1
src/inc/tstoken.h
src/inc/tstoken.h
+12
-4
src/system/detail/inc/mgmtUtil.h
src/system/detail/inc/mgmtUtil.h
+1
-0
src/system/detail/src/mgmtDb.c
src/system/detail/src/mgmtDb.c
+14
-73
src/system/detail/src/mgmtUtil.c
src/system/detail/src/mgmtUtil.c
+73
-0
src/system/detail/src/vnodeQueryProcess.c
src/system/detail/src/vnodeQueryProcess.c
+1
-1
src/util/src/textbuffer.c
src/util/src/textbuffer.c
+0
-1
src/util/src/tglobalcfg.c
src/util/src/tglobalcfg.c
+4
-4
src/util/src/tstoken.c
src/util/src/tstoken.c
+0
-142
src/util/src/ttokenizer.c
src/util/src/ttokenizer.c
+3
-5
src/util/src/ttypes.c
src/util/src/ttypes.c
+2
-1
未找到文件。
src/
inc/tsql
.h
→
src/
client/inc/tscSQLParser
.h
浏览文件 @
6c2cf346
...
...
@@ -23,24 +23,10 @@ extern "C" {
#include "taos.h"
#include "tsqldef.h"
#include "ttypes.h"
#define TK_SPACE 200
#define TK_COMMENT 201
#define TK_ILLEGAL 202
#define TK_HEX 203 // hex number 0x123
#define TK_OCT 204 // oct number
#define TK_BIN 205 // bin format data 0b111
#define TK_FILE 206
#define TK_QUESTION 207 // denoting the placeholder of "?",when invoking statement bind query
#define TSQL_SO_ASC 1
#define TSQL_SO_DESC 0
#include "taosmsg.h"
#define MAX_TOKEN_LEN 30
#define TSQL_TBNAME "TBNAME"
#define TSQL_TBNAME_L "tbname"
// token type
enum
{
TSQL_NODE_TYPE_EXPR
=
0x1
,
...
...
@@ -278,8 +264,7 @@ typedef struct tSQLExpr {
uint32_t
nSQLOptr
;
// TK_FUNCTION: sql function, TK_LE: less than(binary expr)
// 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
SSQLToken
operand
;
struct
tSQLExprList
*
pParam
;
// function parameters
...
...
@@ -346,8 +331,6 @@ tSQLExprList *tSQLExprListAppend(tSQLExprList *pList, tSQLExpr *pNode, SSQLToken
void
tSQLExprListDestroy
(
tSQLExprList
*
pList
);
int32_t
tSQLSyntaxNodeToString
(
tSQLExpr
*
pNode
,
char
*
dst
);
SQuerySQL
*
tSetQuerySQLElems
(
SSQLToken
*
pSelectToken
,
tSQLExprList
*
pSelection
,
tVariantList
*
pFrom
,
tSQLExpr
*
pWhere
,
tVariantList
*
pGroupby
,
tVariantList
*
pSortOrder
,
SSQLToken
*
pInterval
,
SSQLToken
*
pSliding
,
tVariantList
*
pFill
,
SLimitVal
*
pLimit
,
SLimitVal
*
pGLimit
);
...
...
@@ -379,6 +362,7 @@ tDCLSQL *tTokenListAppend(tDCLSQL *pTokenList, SSQLToken *pToken);
void
setCreateDBSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SSQLToken
*
pToken
,
SCreateDBInfo
*
pDB
,
SSQLToken
*
pIgExists
);
void
setCreateAcctSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SSQLToken
*
pName
,
SSQLToken
*
pPwd
,
SCreateAcctSQL
*
pAcctInfo
);
void
setDefaultCreateDbOption
(
SCreateDBInfo
*
pDBInfo
);
// prefix show db.tables;
void
setDBName
(
SSQLToken
*
pCpxName
,
SSQLToken
*
pDB
);
...
...
src/client/inc/tsclient.h
浏览文件 @
6c2cf346
...
...
@@ -35,7 +35,7 @@ extern "C" {
#include "tlog.h"
#include "tscCache.h"
#include "tsdb.h"
#include "ts
ql
.h"
#include "ts
cSQLParser
.h"
#include "tsqlfunction.h"
#include "tutil.h"
...
...
src/
util
/src/sql.c
→
src/
client
/src/sql.c
浏览文件 @
6c2cf346
...
...
@@ -30,7 +30,7 @@
#include <string.h>
#include <assert.h>
#include <stdbool.h>
#include "ts
ql
.h"
#include "ts
cSQLParser
.h"
#include "tutil.h"
/**************** End of %include directives **********************************/
/* These constants specify the various numeric values for terminal symbols
...
...
@@ -2146,7 +2146,7 @@ static void yy_reduce(
{
yymsp
[
-
1
].
minor
.
yy0
=
yymsp
[
0
].
minor
.
yy0
;
}
break
;
case
79
:
/* db_optr ::= */
{
memset
(
&
yymsp
[
1
].
minor
.
yy398
,
0
,
sizeof
(
SCreateDBInfo
)
);}
{
setDefaultCreateDbOption
(
&
yymsp
[
1
].
minor
.
yy398
);}
break
;
case
80
:
/* db_optr ::= db_optr tables */
case
94
:
/* alter_db_optr ::= alter_db_optr tables */
yytestcase
(
yyruleno
==
94
);
...
...
@@ -2199,7 +2199,7 @@ static void yy_reduce(
yymsp
[
-
1
].
minor
.
yy398
=
yylhsminor
.
yy398
;
break
;
case
92
:
/* alter_db_optr ::= */
{
memset
(
&
yymsp
[
1
].
minor
.
yy398
,
0
,
sizeof
(
SCreateDBInfo
)
);}
{
setDefaultCreateDbOption
(
&
yymsp
[
1
].
minor
.
yy398
);}
break
;
case
95
:
/* typename ::= ids */
{
tSQLSetColumnType
(
&
yylhsminor
.
yy223
,
&
yymsp
[
0
].
minor
.
yy0
);
}
...
...
src/client/src/tscAst.c
浏览文件 @
6c2cf346
...
...
@@ -21,8 +21,12 @@
#include "tschemautil.h"
#include "tsdb.h"
#include "tskiplist.h"
#include "tsqldef.h"
#include "tsqlfunction.h"
#include "tstoken.h"
#include "ttypes.h"
#include "tutil.h"
#include "tscSQLParser.h"
/*
*
...
...
@@ -37,10 +41,10 @@
*/
static
tSQLSyntaxNode
*
tSQLSyntaxNodeCreate
(
SSchema
*
pSchema
,
int32_t
numOfCols
,
SSQLToken
*
pToken
);
static
void
tSQLSyntaxNodeDestroy
(
tSQLSyntaxNode
*
pNode
,
void
(
*
fp
)(
void
*
));
static
void
tSQLSyntaxNodeDestroy
(
tSQLSyntaxNode
*
pNode
,
void
(
*
fp
)(
void
*
));
static
tSQLSyntaxNode
*
createSyntaxTree
(
SSchema
*
pSchema
,
int32_t
numOfCols
,
char
*
str
,
int32_t
*
i
);
static
void
destroySyntaxTree
(
tSQLSyntaxNode
*
);
static
void
destroySyntaxTree
(
tSQLSyntaxNode
*
);
static
uint8_t
isQueryOnPrimaryKey
(
const
char
*
primaryColumnName
,
const
tSQLSyntaxNode
*
pLeft
,
const
tSQLSyntaxNode
*
pRight
);
...
...
@@ -255,7 +259,7 @@ static tSQLSyntaxNode *createSyntaxTree(SSchema *pSchema, int32_t numOfCols, cha
t0
=
tStrGetToken
(
str
,
i
,
false
,
0
,
NULL
);
if
(
t0
.
n
==
0
||
t0
.
type
==
TK_RP
)
{
if
(
pLeft
->
nodeType
!=
TSQL_NODE_EXPR
)
{
// if left is not the expr, it is not a legal expr
if
(
pLeft
->
nodeType
!=
TSQL_NODE_EXPR
)
{
// if left is not the expr, it is not a legal expr
tSQLSyntaxNodeDestroy
(
pLeft
,
NULL
);
return
NULL
;
}
...
...
src/client/src/tscAsync.c
浏览文件 @
6c2cf346
...
...
@@ -22,7 +22,7 @@
#include "tscUtil.h"
#include "tsclient.h"
#include "tsocket.h"
#include "ts
ql
.h"
#include "ts
cSQLParser
.h"
#include "tutil.h"
#include "tnote.h"
...
...
src/client/src/tscPrepare.c
浏览文件 @
6c2cf346
...
...
@@ -15,7 +15,7 @@
#include "taos.h"
#include "tsclient.h"
#include "ts
ql
.h"
#include "ts
cSQLParser
.h"
#include "tscUtil.h"
#include "ttimer.h"
#include "taosmsg.h"
...
...
src/client/src/tscSQLParser.c
浏览文件 @
6c2cf346
此差异已折叠。
点击以展开。
src/client/src/tscSQLParserImpl.c
浏览文件 @
6c2cf346
...
...
@@ -14,8 +14,10 @@
*/
#include "os.h"
#include "taosmsg.h"
#include "tglobalcfg.h"
#include "tsql.h"
#include "tlog.h"
#include "tscSQLParser.h"
#include "tstoken.h"
#include "ttime.h"
#include "tutil.h"
...
...
@@ -515,7 +517,7 @@ SQuerySQL *tSetQuerySQLElems(SSQLToken *pSelectToken, tSQLExprList *pSelection,
if
(
pLimit
!=
NULL
)
{
pQuery
->
limit
=
*
pLimit
;
}
if
(
pGLimit
!=
NULL
)
{
pQuery
->
slimit
=
*
pGLimit
;
}
...
...
@@ -523,11 +525,11 @@ SQuerySQL *tSetQuerySQLElems(SSQLToken *pSelectToken, tSQLExprList *pSelection,
if
(
pInterval
!=
NULL
)
{
pQuery
->
interval
=
*
pInterval
;
}
if
(
pSliding
!=
NULL
)
{
pQuery
->
sliding
=
*
pSliding
;
}
pQuery
->
fillType
=
pFill
;
return
pQuery
;
}
...
...
@@ -742,3 +744,22 @@ void setCreateAcctSQL(SSqlInfo *pInfo, int32_t type, SSQLToken *pName, SSQLToken
tTokenListAppend
(
pInfo
->
pDCLInfo
,
pPwd
);
}
}
void
setDefaultCreateDbOption
(
SCreateDBInfo
*
pDBInfo
)
{
pDBInfo
->
numOfBlocksPerTable
=
-
1
;
pDBInfo
->
compressionLevel
=
-
1
;
pDBInfo
->
commitLog
=
-
1
;
pDBInfo
->
commitTime
=
-
1
;
pDBInfo
->
tablesPerVnode
=
-
1
;
pDBInfo
->
numOfAvgCacheBlocks
=
-
1
;
pDBInfo
->
cacheBlockSize
=
-
1
;
pDBInfo
->
rowPerFileBlock
=
-
1
;
pDBInfo
->
daysPerFile
=
-
1
;
pDBInfo
->
replica
=
-
1
;
pDBInfo
->
keep
=
NULL
;
memset
(
&
pDBInfo
->
precision
,
0
,
sizeof
(
SSQLToken
));
}
src/client/src/tscSecondaryMerge.c
浏览文件 @
6c2cf346
...
...
@@ -13,7 +13,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "os.h"
#include "tlosertree.h"
#include "tscSecondaryMerge.h"
...
...
src/client/src/tscServer.c
浏览文件 @
6c2cf346
...
...
@@ -24,7 +24,7 @@
#include "tsclient.h"
#include "tscompression.h"
#include "tsocket.h"
#include "ts
ql
.h"
#include "ts
cSQLParser
.h"
#include "ttime.h"
#include "ttimer.h"
#include "tutil.h"
...
...
src/client/src/tscSql.c
浏览文件 @
6c2cf346
...
...
@@ -24,7 +24,7 @@
#include "tsclient.h"
#include "tscompression.h"
#include "tsocket.h"
#include "ts
ql
.h"
#include "ts
cSQLParser
.h"
#include "ttimer.h"
#include "tutil.h"
#include "tnote.h"
...
...
src/client/src/tscStream.c
浏览文件 @
6c2cf346
...
...
@@ -15,7 +15,7 @@
#include "os.h"
#include "tlog.h"
#include "ts
ql
.h"
#include "ts
cSQLParser
.h"
#include "ttime.h"
#include "ttimer.h"
#include "tutil.h"
...
...
src/client/src/tscSyntaxtreefunction.c
浏览文件 @
6c2cf346
...
...
@@ -16,7 +16,7 @@
#include "os.h"
#include "tscSyntaxtreefunction.h"
#include "ts
ql
.h"
#include "ts
cSQLParser
.h"
#include "ttypes.h"
#include "tutil.h"
...
...
src/inc/sql.y
浏览文件 @
6c2cf346
...
...
@@ -26,7 +26,7 @@
#include <string.h>
#include <assert.h>
#include <stdbool.h>
#include "ts
ql
.h"
#include "ts
cSQLParser
.h"
#include "tutil.h"
}
...
...
@@ -218,7 +218,8 @@ comp(Y) ::= COMP INTEGER(X). { Y = X; }
prec(Y) ::= PRECISION STRING(X). { Y = X; }
%type db_optr {SCreateDBInfo}
db_optr(Y) ::= . {memset(&Y, 0, sizeof(SCreateDBInfo));}
db_optr(Y) ::= . {setDefaultCreateDbOption(&Y);}
db_optr(Y) ::= db_optr(Z) tables(X). { Y = Z; Y.tablesPerVnode = strtol(X.z, NULL, 10); }
db_optr(Y) ::= db_optr(Z) cache(X). { Y = Z; Y.cacheBlockSize = strtol(X.z, NULL, 10); }
db_optr(Y) ::= db_optr(Z) replica(X). { Y = Z; Y.replica = strtol(X.z, NULL, 10); }
...
...
@@ -233,7 +234,7 @@ db_optr(Y) ::= db_optr(Z) prec(X). { Y = Z; Y.precision = X; }
db_optr(Y) ::= db_optr(Z) keep(X). { Y = Z; Y.keep = X; }
%type alter_db_optr {SCreateDBInfo}
alter_db_optr(Y) ::= . {
memset(&Y, 0, sizeof(SCreateDBInfo)
);}
alter_db_optr(Y) ::= . {
setDefaultCreateDbOption(&Y
);}
alter_db_optr(Y) ::= alter_db_optr(Z) replica(X). { Y = Z; Y.replica = strtol(X.z, NULL, 10); }
alter_db_optr(Y) ::= alter_db_optr(Z) tables(X). { Y = Z; Y.tablesPerVnode = strtol(X.z, NULL, 10); }
...
...
src/inc/tast.h
浏览文件 @
6c2cf346
...
...
@@ -25,7 +25,7 @@ extern "C" {
#include <stdlib.h>
#include "taosmsg.h"
#include "t
sql
.h"
#include "t
types
.h"
struct
tSQLBinaryExpr
;
struct
SSchema
;
...
...
@@ -49,7 +49,7 @@ typedef struct tQueryInfo {
int32_t
offset
;
// offset value in tags
int32_t
colIdx
;
// index of column in schema
uint8_t
optr
;
// expression operator
SSchema
sch
;
// schema of tags
SSchema
sch
;
// schema of tags
tVariant
q
;
// query condition value on the specific schema, filter expression
__compar_fn_t
compare
;
// filter function
}
tQueryInfo
;
...
...
src/inc/tsdb.h
浏览文件 @
6c2cf346
...
...
@@ -146,8 +146,8 @@ extern "C" {
#define TSDB_MAX_MPEERS 5
#define TSDB_MAX_MGMT_IPS (TSDB_MAX_MPEERS+1)
//#define TSDB_REPLICA_MAX_NUM 3
#define TSDB_REPLICA_MIN_NUM 1
#define TSDB_REPLICA_MAX_NUM 3
#define TSDB_TBNAME_COLUMN_INDEX (-1)
#define TSDB_MULTI_METERMETA_MAX_NUM 100000 // maximum batch size allowed to load metermeta
...
...
@@ -162,9 +162,6 @@ extern "C" {
#define TSDB_MIN_COMPRESSION_LEVEL 0
#define TSDB_MAX_COMPRESSION_LEVEL 2
#define TSDB_MIN_CACHE_BLOCKS_PER_METER 32
#define TSDB_MAX_CACHE_BLOCKS_PER_METER 40960
#define TSDB_MIN_COMMIT_TIME_INTERVAL 30
#define TSDB_MAX_COMMIT_TIME_INTERVAL 40960
...
...
@@ -177,7 +174,9 @@ extern "C" {
#define TSDB_MIN_CACHE_BLOCKS 100
#define TSDB_MAX_CACHE_BLOCKS 409600
#define TSDB_MIN_AVG_BLOCKS 2
#define TSDB_MAX_AVG_BLOCKS 2048
#define TSDB_DEFAULT_AVG_BLOCKS 4
#define TSDB_MIN_TABLES_PER_VNODE 1
#define TSDB_MAX_TABLES_PER_VNODE 220000
...
...
@@ -204,7 +203,7 @@ extern "C" {
#define TSDB_MAX_RPC_THREADS 5
#define TSDB_QUERY_TYPE_QUERY
0
// normal query
#define TSDB_QUERY_TYPE_QUERY
0
// normal query
#define TSDB_QUERY_TYPE_FREE_RESOURCE 0x01U // free qhandle at vnode
/*
...
...
@@ -220,6 +219,9 @@ extern "C" {
#define TSDB_QUERY_TYPE_PROJECTION_QUERY 0x40U // select *,columns... query
#define TSDB_QUERY_TYPE_JOIN_SEC_STAGE 0x80U // join sub query at the second stage
#define TSQL_SO_ASC 1
#define TSQL_SO_DESC 0
#ifdef __cplusplus
}
#endif
...
...
src/inc/tsqlfunction.h
浏览文件 @
6c2cf346
...
...
@@ -24,7 +24,6 @@ extern "C" {
#include <stdint.h>
#include "trpc.h"
#include "tsql.h"
#include "ttypes.h"
#define TSDB_FUNC_INVALID_ID -1
...
...
src/inc/tstoken.h
浏览文件 @
6c2cf346
...
...
@@ -22,6 +22,18 @@ extern "C" {
#include <stdbool.h>
#define TK_SPACE 200
#define TK_COMMENT 201
#define TK_ILLEGAL 202
#define TK_HEX 203 // hex number 0x123
#define TK_OCT 204 // oct number
#define TK_BIN 205 // bin format data 0b111
#define TK_FILE 206
#define TK_QUESTION 207 // denoting the placeholder of "?",when invoking statement bind query
#define TSQL_TBNAME "TBNAME"
#define TSQL_TBNAME_L "tbname"
// used to denote the minimum unite in sql parsing
typedef
struct
SSQLToken
{
uint32_t
n
;
...
...
@@ -29,10 +41,6 @@ typedef struct SSQLToken {
char
*
z
;
}
SSQLToken
;
#if 0
char *tscGetToken(char *string, char **token, int *tokenLen);
#endif
/**
* tokenizer for sql string
* @param z
...
...
src/system/detail/inc/mgmtUtil.h
浏览文件 @
6c2cf346
...
...
@@ -31,6 +31,7 @@ int32_t mgmtFindTagCol(STabObj * pMetric, const char * tagName);
int32_t
mgmtGetTagsLength
(
STabObj
*
pMetric
,
int32_t
col
);
bool
mgmtCheckIsMonitorDB
(
char
*
db
,
char
*
monitordb
);
int32_t
mgmtCheckDBParams
(
SCreateDbMsg
*
pCreate
);
int32_t
mgmtRetrieveMetersFromMetric
(
SMetricMetaMsg
*
pInfo
,
int32_t
tableIndex
,
tQueryResultset
*
pRes
);
int32_t
mgmtDoJoin
(
SMetricMetaMsg
*
pMetricMetaMsg
,
tQueryResultset
*
pRes
);
...
...
src/system/detail/src/mgmtDb.c
浏览文件 @
6c2cf346
...
...
@@ -140,90 +140,31 @@ int mgmtCheckDbParams(SCreateDbMsg *pCreate) {
if
(
pCreate
->
replications
<
0
)
pCreate
->
replications
=
tsReplications
;
//
if
(
pCreate
->
rowsInFileBlock
<
0
)
pCreate
->
rowsInFileBlock
=
tsRowsInFileBlock
;
//
if
(
pCreate
->
cacheNumOfBlocks
.
fraction
<
0
)
pCreate
->
cacheNumOfBlocks
.
fraction
=
tsAverageCacheBlocks
;
//
//-1 for balance
if
(
pCreate
->
replications
<
0
||
pCreate
->
replications
>
TSDB_REPLICA_MAX_NUM
)
{
mTrace
(
"invalid db option replications: %d"
,
pCreate
->
replications
);
return
TSDB_CODE_INVALID_OPTION
;
}
if
(
pCreate
->
commitLog
<
0
||
pCreate
->
commitLog
>
1
)
{
mTrace
(
"invalid db option commitLog: %d"
,
pCreate
->
commitLog
);
return
TSDB_CODE_INVALID_OPTION
;
}
if
(
pCreate
->
replications
<
TSDB_REPLICA_MIN_NUM
||
pCreate
->
replications
>
TSDB_REPLICA_MAX_NUM
)
{
mTrace
(
"invalid db option replications: %d"
,
pCreate
->
replications
);
return
TSDB_CODE_INVALID_OPTION
;
}
if
(
pCreate
->
daysPerFile
<
TSDB_FILE_MIN_PARTITION_RANGE
||
pCreate
->
daysPerFile
>
TSDB_FILE_MAX_PARTITION_RANGE
)
{
mTrace
(
"invalid db option daysPerFile: %d valid range: %d--%d"
,
pCreate
->
daysPerFile
,
TSDB_FILE_MIN_PARTITION_RANGE
,
TSDB_FILE_MAX_PARTITION_RANGE
);
return
TSDB_CODE_INVALID_OPTION
;
}
if
(
pCreate
->
daysToKeep1
>
pCreate
->
daysToKeep2
||
pCreate
->
daysToKeep2
>
pCreate
->
daysToKeep
)
{
mTrace
(
"invalid db option daystokeep1: %d, daystokeep2: %d, daystokeep: %d"
,
pCreate
->
daysToKeep1
,
pCreate
->
daysToKeep2
,
pCreate
->
daysToKeep
);
return
TSDB_CODE_INVALID_OPTION
;
}
if
(
pCreate
->
daysToKeep1
<
TSDB_FILE_MIN_PARTITION_RANGE
||
pCreate
->
daysToKeep1
<
pCreate
->
daysPerFile
)
{
mTrace
(
"invalid db option daystokeep: %d"
,
pCreate
->
daysToKeep
);
return
TSDB_CODE_INVALID_OPTION
;
}
if
(
pCreate
->
rowsInFileBlock
<
TSDB_MIN_ROWS_IN_FILEBLOCK
||
pCreate
->
rowsInFileBlock
>
TSDB_MAX_ROWS_IN_FILEBLOCK
)
{
mTrace
(
"invalid db option rowsInFileBlock: %d valid range: %d--%d"
,
pCreate
->
rowsInFileBlock
,
TSDB_MIN_ROWS_IN_FILEBLOCK
,
TSDB_MAX_ROWS_IN_FILEBLOCK
);
return
TSDB_CODE_INVALID_OPTION
;
}
if
(
pCreate
->
cacheBlockSize
<
TSDB_MIN_CACHE_BLOCK_SIZE
||
pCreate
->
cacheBlockSize
>
TSDB_MAX_CACHE_BLOCK_SIZE
)
{
mTrace
(
"invalid db option cacheBlockSize: %d valid range: %d--%d"
,
pCreate
->
cacheBlockSize
,
TSDB_MIN_CACHE_BLOCK_SIZE
,
TSDB_MAX_CACHE_BLOCK_SIZE
);
if
(
mgmtCheckDBParams
(
pCreate
)
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_INVALID_OPTION
;
}
if
(
pCreate
->
maxSessions
<
TSDB_MIN_TABLES_PER_VNODE
||
pCreate
->
maxSessions
>
TSDB_MAX_TABLES_PER_VNODE
)
{
mTrace
(
"invalid db option maxSessions: %d valid range: %d--%d"
,
pCreate
->
maxSessions
,
TSDB_MIN_TABLES_PER_VNODE
,
TSDB_MAX_TABLES_PER_VNODE
);
return
TSDB_CODE_INVALID_OPTION
;
}
if
(
pCreate
->
precision
!=
TSDB_TIME_PRECISION_MILLI
&&
pCreate
->
precision
!=
TSDB_TIME_PRECISION_MICRO
)
{
mTrace
(
"invalid db option timePrecision: %d valid value: %d,%d"
,
pCreate
->
precision
,
TSDB_TIME_PRECISION_MILLI
,
TSDB_TIME_PRECISION_MICRO
);
return
TSDB_CODE_INVALID_OPTION
;
}
if
(
pCreate
->
cacheNumOfBlocks
.
fraction
<
0
||
pCreate
->
cacheNumOfBlocks
.
fraction
>
TSDB_MAX_AVG_BLOCKS
)
{
mTrace
(
"invalid db option ablocks: %d valid value: %d,%d"
,
pCreate
->
precision
,
0
,
TSDB_MAX_AVG_BLOCKS
);
return
TSDB_CODE_INVALID_OPTION
;
}
else
{
pCreate
->
cacheNumOfBlocks
.
totalBlocks
=
(
int32_t
)(
pCreate
->
cacheNumOfBlocks
.
fraction
*
pCreate
->
maxSessions
);
}
pCreate
->
cacheNumOfBlocks
.
totalBlocks
=
(
int32_t
)(
pCreate
->
cacheNumOfBlocks
.
fraction
*
pCreate
->
maxSessions
);
if
(
pCreate
->
cacheNumOfBlocks
.
totalBlocks
>
TSDB_MAX_CACHE_BLOCKS
)
{
mTrace
(
"invalid db option cacheNumOfBlocks: %d valid range:
%d
"
,
pCreate
->
cacheNumOfBlocks
.
totalBlocks
,
TSDB_MAX_CACHE_BLOCKS
);
mTrace
(
"invalid db option cacheNumOfBlocks: %d valid range:
[%d, %d]
"
,
pCreate
->
cacheNumOfBlocks
.
totalBlocks
,
TSDB_M
IN_CACHE_BLOCKS
,
TSDB_M
AX_CACHE_BLOCKS
);
return
TSDB_CODE_INVALID_OPTION
;
}
if
(
pCreate
->
commitTime
<
TSDB_MIN_COMMIT_TIME_INTERVAL
||
pCreate
->
commitTime
>
TSDB_MAX_COMMIT_TIME_INTERVAL
)
{
mTrace
(
"invalid db option commitTime: %d valid range: %d-%d"
,
pCreate
->
commitTime
,
TSDB_MIN_COMMIT_TIME_INTERVAL
,
TSDB_MAX_COMMIT_TIME_INTERVAL
);
return
TSDB_CODE_INVALID_OPTION
;
}
if
(
pCreate
->
compression
>
TSDB_MAX_COMPRESSION_LEVEL
)
{
mTrace
(
"invalid db option compression: %d"
,
pCreate
->
compression
,
TSDB_MIN_COMMIT_TIME_INTERVAL
,
TSDB_MAX_COMMIT_TIME_INTERVAL
);
return
TSDB_CODE_INVALID_OPTION
;
// calculate the blocks per table
if
(
pCreate
->
blocksPerMeter
<
0
)
{
pCreate
->
blocksPerMeter
=
pCreate
->
cacheNumOfBlocks
.
totalBlocks
/
4
;
}
if
(
pCreate
->
blocksPerMeter
<
0
)
pCreate
->
blocksPerMeter
=
pCreate
->
cacheNumOfBlocks
.
totalBlocks
/
4
;
if
(
pCreate
->
blocksPerMeter
>
pCreate
->
cacheNumOfBlocks
.
totalBlocks
*
3
/
4
)
{
pCreate
->
blocksPerMeter
=
pCreate
->
cacheNumOfBlocks
.
totalBlocks
*
3
/
4
;
}
if
(
pCreate
->
blocksPerMeter
<
4
)
pCreate
->
blocksPerMeter
=
4
;
if
(
pCreate
->
blocksPerMeter
<
TSDB_MIN_AVG_BLOCKS
)
{
pCreate
->
blocksPerMeter
=
TSDB_MIN_AVG_BLOCKS
;
}
pCreate
->
maxSessions
++
;
...
...
src/system/detail/src/mgmtUtil.c
浏览文件 @
6c2cf346
...
...
@@ -92,3 +92,76 @@ bool mgmtCheckIsMonitorDB(char *db, char *monitordb) {
size_t
len
=
strlen
(
dbName
);
return
(
strncasecmp
(
dbName
,
monitordb
,
len
)
==
0
&&
len
==
strlen
(
monitordb
));
}
int32_t
mgmtCheckDBParams
(
SCreateDbMsg
*
pCreate
)
{
if
(
pCreate
->
commitLog
<
0
||
pCreate
->
commitLog
>
1
)
{
mError
(
"invalid db option commitLog: %d, only 0 or 1 allowed"
,
pCreate
->
commitLog
);
return
TSDB_CODE_INVALID_OPTION
;
}
if
(
pCreate
->
replications
<
TSDB_REPLICA_MIN_NUM
||
pCreate
->
replications
>
TSDB_REPLICA_MAX_NUM
)
{
mError
(
"invalid db option replications: %d valid range: [%d, %d]"
,
pCreate
->
replications
,
TSDB_REPLICA_MIN_NUM
,
TSDB_REPLICA_MAX_NUM
);
return
TSDB_CODE_INVALID_OPTION
;
}
if
(
pCreate
->
daysPerFile
<
TSDB_FILE_MIN_PARTITION_RANGE
||
pCreate
->
daysPerFile
>
TSDB_FILE_MAX_PARTITION_RANGE
)
{
mError
(
"invalid db option daysPerFile: %d valid range: [%d, %d]"
,
pCreate
->
daysPerFile
,
TSDB_FILE_MIN_PARTITION_RANGE
,
TSDB_FILE_MAX_PARTITION_RANGE
);
return
TSDB_CODE_INVALID_OPTION
;
}
if
(
pCreate
->
daysToKeep1
>
pCreate
->
daysToKeep2
||
pCreate
->
daysToKeep2
>
pCreate
->
daysToKeep
)
{
mError
(
"invalid db option daystokeep1: %d, daystokeep2: %d, daystokeep: %d"
,
pCreate
->
daysToKeep1
,
pCreate
->
daysToKeep2
,
pCreate
->
daysToKeep
);
return
TSDB_CODE_INVALID_OPTION
;
}
if
(
pCreate
->
daysToKeep1
<
TSDB_FILE_MIN_PARTITION_RANGE
||
pCreate
->
daysToKeep1
<
pCreate
->
daysPerFile
)
{
mError
(
"invalid db option daystokeep: %d"
,
pCreate
->
daysToKeep
);
return
TSDB_CODE_INVALID_OPTION
;
}
if
(
pCreate
->
rowsInFileBlock
<
TSDB_MIN_ROWS_IN_FILEBLOCK
||
pCreate
->
rowsInFileBlock
>
TSDB_MAX_ROWS_IN_FILEBLOCK
)
{
mError
(
"invalid db option rowsInFileBlock: %d valid range: [%d, %d]"
,
pCreate
->
rowsInFileBlock
,
TSDB_MIN_ROWS_IN_FILEBLOCK
,
TSDB_MAX_ROWS_IN_FILEBLOCK
);
return
TSDB_CODE_INVALID_OPTION
;
}
if
(
pCreate
->
cacheBlockSize
<
TSDB_MIN_CACHE_BLOCK_SIZE
||
pCreate
->
cacheBlockSize
>
TSDB_MAX_CACHE_BLOCK_SIZE
)
{
mError
(
"invalid db option cacheBlockSize: %d valid range: [%d, %d]"
,
pCreate
->
cacheBlockSize
,
TSDB_MIN_CACHE_BLOCK_SIZE
,
TSDB_MAX_CACHE_BLOCK_SIZE
);
return
TSDB_CODE_INVALID_OPTION
;
}
if
(
pCreate
->
maxSessions
<
TSDB_MIN_TABLES_PER_VNODE
||
pCreate
->
maxSessions
>
TSDB_MAX_TABLES_PER_VNODE
)
{
mError
(
"invalid db option maxSessions: %d valid range: [%d, %d]"
,
pCreate
->
maxSessions
,
TSDB_MIN_TABLES_PER_VNODE
,
TSDB_MAX_TABLES_PER_VNODE
);
return
TSDB_CODE_INVALID_OPTION
;
}
if
(
pCreate
->
precision
!=
TSDB_TIME_PRECISION_MILLI
&&
pCreate
->
precision
!=
TSDB_TIME_PRECISION_MICRO
)
{
mError
(
"invalid db option timePrecision: %d valid value: [%d, %d]"
,
pCreate
->
precision
,
TSDB_TIME_PRECISION_MILLI
,
TSDB_TIME_PRECISION_MICRO
);
return
TSDB_CODE_INVALID_OPTION
;
}
if
(
pCreate
->
cacheNumOfBlocks
.
fraction
<
TSDB_MIN_AVG_BLOCKS
||
pCreate
->
cacheNumOfBlocks
.
fraction
>
TSDB_MAX_AVG_BLOCKS
)
{
mError
(
"invalid db option ablocks: %f valid value: [%d, %d]"
,
pCreate
->
cacheNumOfBlocks
.
fraction
,
0
,
TSDB_MAX_AVG_BLOCKS
);
return
TSDB_CODE_INVALID_OPTION
;
}
if
(
pCreate
->
commitTime
<
TSDB_MIN_COMMIT_TIME_INTERVAL
||
pCreate
->
commitTime
>
TSDB_MAX_COMMIT_TIME_INTERVAL
)
{
mError
(
"invalid db option commitTime: %d valid range: [%d, %d]"
,
pCreate
->
commitTime
,
TSDB_MIN_COMMIT_TIME_INTERVAL
,
TSDB_MAX_COMMIT_TIME_INTERVAL
);
return
TSDB_CODE_INVALID_OPTION
;
}
if
(
pCreate
->
compression
<
TSDB_MIN_COMPRESSION_LEVEL
||
pCreate
->
compression
>
TSDB_MAX_COMPRESSION_LEVEL
)
{
mError
(
"invalid db option compression: %d valid range: [%d, %d]"
,
pCreate
->
compression
,
TSDB_MIN_COMPRESSION_LEVEL
,
TSDB_MAX_COMPRESSION_LEVEL
);
return
TSDB_CODE_INVALID_OPTION
;
}
return
TSDB_CODE_SUCCESS
;
}
src/system/detail/src/vnodeQueryProcess.c
浏览文件 @
6c2cf346
...
...
@@ -27,7 +27,7 @@
#include "vnodeQueryImpl.h"
#define ALL_CACHE_BLOCKS_CHECKED(q) \
((
q)->slot == (q)->currentSlot && QUERY_IS_ASC_QUERY(q) || (q)->slot == (q)->firstSlot && (!QUERY_IS_ASC_QUERY(q
)))
((
(q)->slot == (q)->currentSlot && QUERY_IS_ASC_QUERY(q)) || ((q)->slot == (q)->firstSlot && (!QUERY_IS_ASC_QUERY(q)
)))
#define FORWARD_CACHE_BLOCK_CHECK_SLOT(slot, step, maxblocks) (slot) = ((slot) + (step) + (maxblocks)) % (maxblocks);
...
...
src/util/src/textbuffer.c
浏览文件 @
6c2cf346
...
...
@@ -18,7 +18,6 @@
#include "taosmsg.h"
#include "textbuffer.h"
#include "tlog.h"
#include "tsql.h"
#include "tsqlfunction.h"
#include "ttime.h"
#include "ttypes.h"
...
...
src/util/src/tglobalcfg.c
浏览文件 @
6c2cf346
...
...
@@ -84,7 +84,7 @@ short tsCheckHeaderFile = 0;
int
tsSessionsPerVnode
=
1000
;
int
tsCacheBlockSize
=
16384
;
// 256 columns
int
tsAverageCacheBlocks
=
4
;
int
tsAverageCacheBlocks
=
TSDB_DEFAULT_AVG_BLOCKS
;
int
tsRowsInFileBlock
=
4096
;
float
tsFileBlockMinPercent
=
0
.
05
;
...
...
@@ -92,10 +92,10 @@ float tsFileBlockMinPercent = 0.05;
short
tsNumOfBlocksPerMeter
=
100
;
short
tsCommitTime
=
3600
;
// seconds
short
tsCommitLog
=
1
;
short
tsCompression
=
2
;
short
tsCompression
=
TSDB_MAX_COMPRESSION_LEVEL
;
short
tsDaysPerFile
=
10
;
int
tsDaysToKeep
=
3650
;
int
tsReplications
=
1
;
int
tsReplications
=
TSDB_REPLICA_MIN_NUM
;
int
tsNumOfMPeers
=
3
;
int
tsMaxShellConns
=
2000
;
...
...
@@ -522,7 +522,7 @@ static void doInitGlobalConfig() {
0
,
1
.
0
,
0
,
TSDB_CFG_UTYPE_NONE
);
tsInitConfigOption
(
cfg
++
,
"ablocks"
,
&
tsAverageCacheBlocks
,
TSDB_CFG_VTYPE_INT
,
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
,
2
,
128
,
0
,
TSDB_CFG_UTYPE_NONE
);
TSDB_MIN_AVG_BLOCKS
,
TSDB_MAX_AVG_BLOCKS
,
0
,
TSDB_CFG_UTYPE_NONE
);
tsInitConfigOption
(
cfg
++
,
"tblocks"
,
&
tsNumOfBlocksPerMeter
,
TSDB_CFG_VTYPE_SHORT
,
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
,
32
,
4096
,
0
,
TSDB_CFG_UTYPE_NONE
);
...
...
src/util/src/tstoken.c
已删除
100644 → 0
浏览文件 @
553df7ff
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <ctype.h>
#include <pthread.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include "os.h"
#include "shash.h"
#include "tstoken.h"
void
shiftStr
(
char
*
dst
,
char
*
src
);
static
char
operator
[]
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
'$'
,
'%'
,
'&'
,
0
,
'('
,
')'
,
'*'
,
'+'
,
0
,
'-'
,
0
,
'/'
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
'<'
,
'='
,
'>'
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
'['
,
0
,
']'
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
'|'
,
0
,
0
,
0
};
static
char
delimiter
[]
=
{
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
','
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
';'
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
};
bool
isCharInDelimiter
(
char
c
,
char
*
delimiter
)
{
for
(
int
i
=
0
;
i
<
strlen
(
delimiter
);
i
++
)
{
if
(
delimiter
[
i
]
==
c
)
return
true
;
}
return
false
;
}
char
*
tscGetTokenDelimiter
(
char
*
string
,
char
**
token
,
int
*
tokenLen
,
char
*
delimiters
)
{
while
(
*
string
!=
0
)
{
if
(
isCharInDelimiter
(
*
string
,
delimiters
))
{
++
string
;
}
else
{
break
;
}
}
*
token
=
string
;
char
*
str
=
string
;
*
tokenLen
=
0
;
while
(
*
str
!=
0
)
{
if
(
!
isCharInDelimiter
(
*
str
,
delimiters
))
{
*
tokenLen
=
*
tokenLen
+
1
;
str
++
;
}
else
{
break
;
}
}
return
string
;
}
char
*
tscGetToken
(
char
*
string
,
char
**
token
,
int
*
tokenLen
)
{
char
quote
=
0
;
while
(
*
string
!=
0
)
{
if
(
delimiter
[
*
string
])
{
++
string
;
}
else
{
break
;
}
}
char
quotaChar
=
0
;
if
(
*
string
==
'\''
||
*
string
==
'\"'
)
{
quote
=
1
;
quotaChar
=
*
string
;
string
++
;
}
*
token
=
string
;
/* not in string, return token */
if
(
*
string
>
0
&&
operator
[
*
string
]
&&
quote
==
0
)
{
string
++
;
/* handle the case: insert into tabx using stable1 tags(-1)/tags(+1)
* values(....) */
if
(
operator
[
*
string
]
&&
(
*
string
!=
'('
&&
*
string
!=
')'
&&
*
string
!=
'-'
&&
*
string
!=
'+'
))
*
tokenLen
=
2
;
else
*
tokenLen
=
1
;
return
*
token
+
*
tokenLen
;
}
while
(
*
string
!=
0
)
{
if
(
quote
)
{
// handle escape situation: '\"', the " should not be eliminated
if
(
*
string
==
quotaChar
)
{
if
(
*
(
string
-
1
)
!=
'\\'
)
{
break
;
}
else
{
shiftStr
(
string
-
1
,
string
);
}
}
else
{
++
string
;
}
}
else
{
if
(
delimiter
[
*
string
])
break
;
if
(
operator
[
*
string
])
break
;
++
string
;
}
}
*
tokenLen
=
(
int
)(
string
-
*
token
);
if
(
quotaChar
!=
0
&&
*
string
!=
0
&&
*
(
string
+
1
)
!=
0
)
{
return
string
+
1
;
}
else
{
return
string
;
}
}
void
shiftStr
(
char
*
dst
,
char
*
src
)
{
int32_t
i
=
0
;
do
{
dst
[
i
]
=
src
[
i
];
i
++
;
}
while
(
delimiter
[
src
[
i
]]
==
0
);
src
[
i
-
1
]
=
' '
;
}
src/util/src/ttokenizer.c
浏览文件 @
6c2cf346
...
...
@@ -13,14 +13,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <ctype.h>
#include <pthread.h>
#include <string.h>
#include "os.h"
#include "shash.h"
#include "tsql.h"
#include "tutil.h"
#include "tsqldef.h"
#include "tstoken.h"
#include "ttypes.h"
// All the keywords of the SQL language are stored in a hash table
typedef
struct
SKeyword
{
...
...
src/util/src/ttypes.c
浏览文件 @
6c2cf346
...
...
@@ -16,7 +16,6 @@
#include "os.h"
#include "taos.h"
#include "tsdb.h"
#include "tsql.h"
#include "tsqldef.h"
#include "ttypes.h"
#include "tutil.h"
...
...
@@ -67,6 +66,8 @@ bool isValidDataType(int32_t type, int32_t length) {
void
tVariantCreate
(
tVariant
*
pVar
,
SSQLToken
*
token
)
{
tVariantCreateFromString
(
pVar
,
token
->
z
,
token
->
n
,
token
->
type
);
}
void
tVariantCreateFromString
(
tVariant
*
pVar
,
char
*
pz
,
uint32_t
len
,
uint32_t
type
)
{
memset
(
pVar
,
0
,
sizeof
(
tVariant
));
switch
(
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
{
int32_t
k
=
strncasecmp
(
pz
,
"true"
,
4
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录