提交 b96fdff8 编写于 作者: S slguan

Merge branch 'develop' into feature/slguan

......@@ -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);
......
......@@ -35,7 +35,7 @@ extern "C" {
#include "tlog.h"
#include "tscCache.h"
#include "tsdb.h"
#include "tsql.h"
#include "tscSQLParser.h"
#include "tsqlfunction.h"
#include "tutil.h"
......
......@@ -30,7 +30,7 @@
#include <string.h>
#include <assert.h>
#include <stdbool.h>
#include "tsql.h"
#include "tscSQLParser.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); }
......
......@@ -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;
}
......
......@@ -22,7 +22,7 @@
#include "tscUtil.h"
#include "tsclient.h"
#include "tsocket.h"
#include "tsql.h"
#include "tscSQLParser.h"
#include "tutil.h"
#include "tnote.h"
......
......@@ -15,7 +15,7 @@
#include "taos.h"
#include "tsclient.h"
#include "tsql.h"
#include "tscSQLParser.h"
#include "tscUtil.h"
#include "ttimer.h"
#include "taosmsg.h"
......
此差异已折叠。
......@@ -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));
}
......@@ -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"
......
......@@ -24,7 +24,7 @@
#include "tsclient.h"
#include "tscompression.h"
#include "tsocket.h"
#include "tsql.h"
#include "tscSQLParser.h"
#include "ttime.h"
#include "ttimer.h"
#include "tutil.h"
......
......@@ -24,7 +24,7 @@
#include "tsclient.h"
#include "tscompression.h"
#include "tsocket.h"
#include "tsql.h"
#include "tscSQLParser.h"
#include "ttimer.h"
#include "tutil.h"
#include "tnote.h"
......
......@@ -15,7 +15,7 @@
#include "os.h"
#include "tlog.h"
#include "tsql.h"
#include "tscSQLParser.h"
#include "ttime.h"
#include "ttimer.h"
#include "tutil.h"
......
......@@ -16,7 +16,7 @@
#include "os.h"
#include "tscSyntaxtreefunction.h"
#include "tsql.h"
#include "tscSQLParser.h"
#include "ttypes.h"
#include "tutil.h"
......
......@@ -26,7 +26,7 @@
#include <string.h>
#include <assert.h>
#include <stdbool.h>
#include "tsql.h"
#include "tscSQLParser.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); }
......
......@@ -25,7 +25,7 @@ extern "C" {
#include <stdlib.h>
#include "taosmsg.h"
#include "tsql.h"
#include "ttypes.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;
......
......@@ -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
......
......@@ -24,7 +24,6 @@ extern "C" {
#include <stdint.h>
#include "trpc.h"
#include "tsql.h"
#include "ttypes.h"
#define TSDB_FUNC_INVALID_ID -1
......
......@@ -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
......
......@@ -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);
......
......@@ -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_MIN_CACHE_BLOCKS, TSDB_MAX_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++;
......
......@@ -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;
}
......@@ -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);
......
......@@ -283,6 +283,7 @@ SSqlFunctionExpr* vnodeCreateSqlFunctionExpr(SQueryMeterMsg* pQueryMsg, int32_t*
int32_t param = pExprs[i].pBase.arg[0].argValue.i64;
if (getResultDataInfo(type, bytes, pExprs[i].pBase.functionId, param, &pExprs[i].resType, &pExprs[i].resBytes,
&pExprs[i].interResBytes, 0, isSuperTable) != TSDB_CODE_SUCCESS) {
*code = TSDB_CODE_INVALID_QUERY_MSG;
return NULL;
}
......@@ -626,16 +627,16 @@ void vnodeUpdateQueryColumnIndex(SQuery* pQuery, SMeterObj* pMeterObj) {
return;
}
for(int32_t i = 0; i < pQuery->numOfOutputCols; ++i) {
SSqlFuncExprMsg* pSqlExprMsg = &pQuery->pSelectExpr[i].pBase;
for(int32_t k = 0; k < pQuery->numOfOutputCols; ++k) {
SSqlFuncExprMsg* pSqlExprMsg = &pQuery->pSelectExpr[k].pBase;
if (pSqlExprMsg->functionId == TSDB_FUNC_ARITHM || pSqlExprMsg->colInfo.flag == TSDB_COL_TAG) {
continue;
}
SColIndexEx* pColIndexEx = &pSqlExprMsg->colInfo;
for(int32_t j = 0; j < pQuery->numOfCols; ++j) {
if (pColIndexEx->colId == pQuery->colList[j].data.colId) {
pColIndexEx->colIdx = pQuery->colList[j].colIdx;
for(int32_t f = 0; f < pQuery->numOfCols; ++f) {
if (pColIndexEx->colId == pQuery->colList[f].data.colId) {
pColIndexEx->colIdx = pQuery->colList[f].colIdx;
break;
}
}
......
......@@ -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"
......
......@@ -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);
......
/*
* 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] = ' ';
}
......@@ -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 {
......
......@@ -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.
先完成此消息的编辑!
想要评论请 注册