diff --git a/documentation/webdocs/markdowndocs/TAOS SQL-ch.md b/documentation/webdocs/markdowndocs/TAOS SQL-ch.md index 81fc3ffcc428d20e92506f25521026fb70a643ef..7fe396e9e5e156c5528267e69beffd29f06a2f18 100644 --- a/documentation/webdocs/markdowndocs/TAOS SQL-ch.md +++ b/documentation/webdocs/markdowndocs/TAOS SQL-ch.md @@ -63,11 +63,11 @@ TDengine缺省的时间戳是毫秒精度,但通过修改配置参数enableMic | 3 | BIGINT | 8 | 长整型,范围 [-2^63+1, 2^63-1], -2^63用于NULL | | 4 | FLOAT | 4 | 浮点型,有效位数6-7,范围 [-3.4E38, 3.4E38] | | 5 | DOUBLE | 8 | 双精度浮点型,有效位数15-16,范围 [-1.7E308, 1.7E308] | -| 6 | BINARY | 自定义 | 用于记录字符串,理论上,最长可以有65526字节,但由于每行数据最多64K字节,实际上限一般小于理论值。 binary仅支持字符串输入,字符串两端使用单引号引用,否则英文全部自动转化为小写。使用时须指定大小,如binary(20)定义了最长为20个字符的字符串,每个字符占1byte的存储空间。如果用户字符串超出20字节,将被自动截断。对于字符串内的单引号,可以用转义字符反斜线加单引号来表示, 即 **\’**。 | +| 6 | BINARY | 自定义 | 用于记录字符串,理论上,最长可以有65526字节,但由于每行数据最多64K字节,实际上限一般小于理论值。 binary仅支持字符串输入,字符串两端使用单引号引用,否则英文全部自动转化为小写。使用时须指定大小,如binary(20)定义了最长为20个字符的字符串,每个字符占1byte的存储空间。如果用户字符串超出20字节将会报错。对于字符串内的单引号,可以用转义字符反斜线加单引号来表示, 即 **\’**。 | | 7 | SMALLINT | 2 | 短整型, 范围 [-32767, 32767], -32768用于NULL | | 8 | TINYINT | 1 | 单字节整型,范围 [-127, 127], -128用于NULL | | 9 | BOOL | 1 | 布尔型,{true, false} | -| 10 | NCHAR | 自定义 | 用于记录非ASCII字符串,如中文字符。每个nchar字符占用4bytes的存储空间。字符串两端使用单引号引用,字符串内的单引号需用转义字符 **\’**。nchar使用时须指定字符串大小,类型为nchar(10)的列表示此列的字符串最多存储10个nchar字符,会固定占用40bytes的空间。如用户字符串长度超出声明长度,则将被自动截断。 | +| 10 | NCHAR | 自定义 | 用于记录非ASCII字符串,如中文字符。每个nchar字符占用4bytes的存储空间。字符串两端使用单引号引用,字符串内的单引号需用转义字符 **\’**。nchar使用时须指定字符串大小,类型为nchar(10)的列表示此列的字符串最多存储10个nchar字符,会固定占用40bytes的空间。如用户字符串长度超出声明长度,则将会报错。 | **Tips**: TDengine对SQL语句中的英文字符不区分大小写,自动转化为小写执行。因此用户大小写敏感的字符串及密码,需要使用单引号将字符串引起来。 diff --git a/documentation/webdocs/markdowndocs/TAOS SQL.md b/documentation/webdocs/markdowndocs/TAOS SQL.md index 2b9960b860f5452b1b233355984a411b2c4a90a4..6c7f25b8f7c342d8e38ebdcd5f674534c340f6be 100644 --- a/documentation/webdocs/markdowndocs/TAOS SQL.md +++ b/documentation/webdocs/markdowndocs/TAOS SQL.md @@ -39,8 +39,8 @@ The full list of data types is listed below. For string types of data, we will | 6 | DOUBLE | 8 | A standard nullable double float type with 15-16 significant digits and a range of [-1.7E308, 1.7E308]​ | | 7 | BOOL | 1 | A nullable boolean type, [**`true`**, **`false`**] | | 8 | TIMESTAMP | 8 | A nullable timestamp type with the same usage as the primary column timestamp | -| 9 | BINARY(*M*) | *M* | A nullable string type whose length is *M*, any exceeded chars will be automatically truncated, the maximum length of *M* is 65526, but as maximum row size is 64K bytes, the actual upper limit will generally less than 65526. This type of string only supports ASCii encoded chars. | -| 10 | NCHAR(*M*) | 4 * *M* | A nullable string type whose length is *M*, any exceeded chars will be truncated. The **`NCHAR`** type supports Unicode encoded chars. | +| 9 | BINARY(*M*) | *M* | A nullable string type whose length is *M*, error should be threw with exceeded chars, the maximum length of *M* is 65526, but as maximum row size is 64K bytes, the actual upper limit will generally less than 65526. This type of string only supports ASCii encoded chars. | +| 10 | NCHAR(*M*) | 4 * *M* | A nullable string type whose length is *M*, error should be threw with exceeded chars. The **`NCHAR`** type supports Unicode encoded chars. | All the keywords in a SQL statement are case-insensitive, but strings values are case-sensitive and must be quoted by a pair of `'` or `"`. To quote a `'` or a `"` , you can use the escape character `\`. diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h index d0b42e58776009a70c042a2ff42a67b51b530c78..39144c3083803b99997d19cf63b389f5f1c21aa5 100644 --- a/src/common/inc/tglobal.h +++ b/src/common/inc/tglobal.h @@ -49,7 +49,7 @@ extern int32_t tsTotalMemoryMB; extern int32_t tsVersion; extern int32_t tscEmbedded; -extern int64_t tsMsPerDay[2]; +extern int64_t tsMsPerDay[3]; extern char tsFirst[]; extern char tsSecond[]; diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index 0f008111c04042b996cb3fcdee35178076352001..673ba2a6f5fe7b8caddcb62143cab447b971beb0 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -55,11 +55,12 @@ int32_t tsEnableCoreFile = 0; int32_t tscEmbedded = 0; /* - * minmum scale for whole system, millisecond by default + * minimum scale for whole system, millisecond by default * for TSDB_TIME_PRECISION_MILLI: 86400000L * TSDB_TIME_PRECISION_MICRO: 86400000000L + * TSDB_TIME_PRECISION_NANO: 86400000000000L */ -int64_t tsMsPerDay[] = {86400000L, 86400000000L}; +int64_t tsMsPerDay[] = {86400000L, 86400000000L, 86400000000000L}; char tsFirst[TSDB_EP_LEN] = {0}; char tsSecond[TSDB_EP_LEN] = {0}; diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h index f48f6bbde29b3bc3480929882cf20efc59c0807a..2aca057ba73666f3b3c4bbf4c56ddce27ce066fe 100644 --- a/src/inc/taosdef.h +++ b/src/inc/taosdef.h @@ -92,6 +92,7 @@ extern const int32_t TYPE_BYTES[11]; #define TSDB_TIME_PRECISION_MILLI 0 #define TSDB_TIME_PRECISION_MICRO 1 +#define TSDB_TIME_PRECISION_NANO 2 #define TSDB_TIME_PRECISION_MILLI_STR "ms" #define TSDB_TIME_PRECISION_MICRO_STR "us" @@ -286,9 +287,9 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size); #define TSDB_MAX_COMMIT_TIME 40960 #define TSDB_DEFAULT_COMMIT_TIME 3600 -#define TSDB_MIN_PRECISION TSDB_PRECISION_MILLI -#define TSDB_MAX_PRECISION TSDB_PRECISION_NANO -#define TSDB_DEFAULT_PRECISION TSDB_PRECISION_MILLI +#define TSDB_MIN_PRECISION TSDB_TIME_PRECISION_MILLI +#define TSDB_MAX_PRECISION TSDB_TIME_PRECISION_NANO +#define TSDB_DEFAULT_PRECISION TSDB_TIME_PRECISION_MILLI #define TSDB_MIN_COMP_LEVEL 0 #define TSDB_MAX_COMP_LEVEL 2 @@ -357,12 +358,6 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size); #define TAOS_QTYPE_WAL 2 #define TAOS_QTYPE_CQ 3 -typedef enum { - TSDB_PRECISION_MILLI, - TSDB_PRECISION_MICRO, - TSDB_PRECISION_NANO -} EPrecisionType; - typedef enum { TSDB_SUPER_TABLE = 0, // super table TSDB_CHILD_TABLE = 1, // table created from super table diff --git a/src/inc/tsdb.h b/src/inc/tsdb.h index 4a954f7ea35576f8b1c7c33883f4eafd6596b5aa..3680a46d854ceab325f40c3ec845d089f6464893 100644 --- a/src/inc/tsdb.h +++ b/src/inc/tsdb.h @@ -64,13 +64,14 @@ typedef struct { int8_t compression; } STsdbCfg; +typedef void TsdbRepoT; // use void to hide implementation details from outside + void tsdbSetDefaultCfg(STsdbCfg *pCfg); STsdbCfg *tsdbCreateDefaultCfg(); void tsdbFreeCfg(STsdbCfg *pCfg); +STsdbCfg *tsdbGetCfg(const TsdbRepoT *repo); // --------- TSDB REPOSITORY DEFINITION -typedef void TsdbRepoT; // use void to hide implementation details from outside - int tsdbCreateRepo(char *rootDir, STsdbCfg *pCfg, void *limiter); int32_t tsdbDropRepo(TsdbRepoT *repo); TsdbRepoT *tsdbOpenRepo(char *rootDir, STsdbAppH *pAppH); diff --git a/src/plugins/mqtt/src/mqttSystem.c b/src/plugins/mqtt/src/mqttSystem.c index 1f4e1e8a790d1a64dd899fb7826f57ff75b71e68..3266579e337c5b63032e8bcf253f87cf66252b6a 100644 --- a/src/plugins/mqtt/src/mqttSystem.c +++ b/src/plugins/mqtt/src/mqttSystem.c @@ -50,7 +50,7 @@ int32_t mqttInitSystem() { recntStatus.password = strstr(url, "@") != NULL ? strbetween(strstr(url, recntStatus.user_name), ":", "@") : NULL; if (strlen(url) == 0) { - mqttError("failed to initialize mqtt module, reason: url is null"); + mqttTrace("mqtt module not init, url is null"); return rc; } diff --git a/src/query/inc/qExecutor.h b/src/query/inc/qExecutor.h index 09ac1b6cd7842ee1c0fb82a93a7a790df8a535fd..722a625526ab8ac20a0570f3db5338fc28cf3ca3 100644 --- a/src/query/inc/qExecutor.h +++ b/src/query/inc/qExecutor.h @@ -136,7 +136,7 @@ typedef struct SQuery { int64_t intervalTime; int64_t slidingTime; // sliding time for sliding window query char slidingTimeUnit; // interval data type, used for daytime revise - int8_t precision; + int16_t precision; int16_t numOfOutput; int16_t fillType; int16_t checkBuffer; // check if the buffer is full during scan each block diff --git a/src/query/inc/qpercentile.h b/src/query/inc/qpercentile.h index f8f09357c635afd096cab622daab186eb2fbc512..c1227dad77d278d9534df229b8a68c2b4f305a54 100644 --- a/src/query/inc/qpercentile.h +++ b/src/query/inc/qpercentile.h @@ -49,7 +49,7 @@ typedef struct tMemBucket { int32_t nTotalBufferSize; int32_t maxElemsCapacity; - int16_t pageSize; + int32_t pageSize; int16_t numOfTotalPages; int16_t numOfAvailPages; /* remain available buffer pages */ diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index b487c790a9cbbeeaf2584d2962e9333cfc2c07ff..51d166ccb438f72a276e89c544a5db64afc33f06 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -3964,10 +3964,12 @@ static SFillColInfo* taosCreateFillColInfo(SQuery* pQuery) { } int32_t doInitQInfo(SQInfo *pQInfo, void *param, void *tsdb, int32_t vgId, bool isSTableQuery) { + int32_t code = TSDB_CODE_SUCCESS; + SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv; SQuery *pQuery = pQInfo->runtimeEnv.pQuery; - int32_t code = TSDB_CODE_SUCCESS; + pQuery->precision = tsdbGetCfg(tsdb)->precision; setScanLimitationByResultBuffer(pQuery); changeExecuteScanOrder(pQuery, false); @@ -5422,7 +5424,7 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList, pQuery->slidingTimeUnit = pQueryMsg->slidingTimeUnit; pQuery->fillType = pQueryMsg->fillType; pQuery->numOfTags = pQueryMsg->numOfTags; - + // todo do not allocate ?? pQuery->colList = calloc(numOfCols, sizeof(SSingleColumnFilterInfo)); if (pQuery->colList == NULL) { @@ -5491,7 +5493,7 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList, int tableIndex = 0; STimeWindow window = pQueryMsg->window; - taosArraySort( pTableIdList, compareTableIdInfo ); + taosArraySort(pTableIdList, compareTableIdInfo); for(int32_t i = 0; i < numOfGroups; ++i) { SArray* pa = taosArrayGetP(groupInfo->pGroupList, i); size_t s = taosArrayGetSize(pa); @@ -5960,7 +5962,8 @@ int32_t qDumpRetrieveResult(qinfo_t qinfo, SRetrieveTableRsp **pRsp, int32_t *co (*pRsp)->offset = 0; (*pRsp)->useconds = 0; } - + + (*pRsp)->precision = htons(pQuery->precision); if (pQuery->rec.rows > 0 && code == TSDB_CODE_SUCCESS) { code = doDumpQueryResult(pQInfo, (*pRsp)->data); } else { diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index 405f796a5e2e281ee5a63bf3fed7c14426ac30b4..bdf19bb4a085159a9ee07ab7691b36dc64e257bc 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -680,13 +680,13 @@ static SRpcConn *rpcSetupConnToServer(SRpcReqContext *pContext) { } if (pConn) { + pConn->tretry = 0; pConn->ahandle = pContext->ahandle; sprintf(pConn->info, "%s %p %p", pRpc->label, pConn, pConn->ahandle); } else { tError("%s %p, failed to set up connection(%s)", pRpc->label, pContext->ahandle, tstrerror(terrno)); } - pConn->tretry = 0; return pConn; } diff --git a/src/tsdb/src/tsdbMain.c b/src/tsdb/src/tsdbMain.c index af4b9608b6074a2d57274a6cc4e9e5d909eb6b76..e79873d1b91a53eb9d0857699e577c8c5728a56a 100644 --- a/src/tsdb/src/tsdbMain.c +++ b/src/tsdb/src/tsdbMain.c @@ -9,8 +9,7 @@ #include "ttime.h" #include -#define TSDB_DEFAULT_PRECISION TSDB_PRECISION_MILLI // default precision -#define IS_VALID_PRECISION(precision) (((precision) >= TSDB_PRECISION_MILLI) && ((precision) <= TSDB_PRECISION_NANO)) +#define IS_VALID_PRECISION(precision) (((precision) >= TSDB_TIME_PRECISION_MILLI) && ((precision) <= TSDB_TIME_PRECISION_NANO)) #define TSDB_DEFAULT_COMPRESSION TWO_STAGE_COMP #define IS_VALID_COMPRESSION(compression) (((compression) >= NO_COMPRESSION) && ((compression) <= TWO_STAGE_COMP)) #define TSDB_MIN_ID 0 @@ -79,6 +78,11 @@ void tsdbFreeCfg(STsdbCfg *pCfg) { if (pCfg != NULL) free(pCfg); } +STsdbCfg *tsdbGetCfg(const TsdbRepoT *repo) { + assert(repo != NULL); + return &((STsdbRepo*)repo)->config; +} + /** * Create a new TSDB repository * @param rootDir the TSDB repository root directory diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index eda9714d98eb41af6f991700a08a4c7a6239783f..46cc897eac8914bb6cb89f20e73762b00b148b66 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -364,12 +364,13 @@ static bool hasMoreDataInCache(STsdbQueryHandle* pHandle) { return true; } -static int32_t getFileIdFromKey(TSKEY key, int32_t daysPerFile) { +static int32_t getFileIdFromKey(TSKEY key, int32_t daysPerFile, int32_t precision) { + assert(precision >= TSDB_TIME_PRECISION_MICRO || precision <= TSDB_TIME_PRECISION_NANO); if (key == TSKEY_INITIAL_VAL) { return INT32_MIN; } - int64_t fid = (int64_t)(key / (daysPerFile * tsMsPerDay[0])); // set the starting fileId + int64_t fid = (int64_t)(key / (daysPerFile * tsMsPerDay[precision])); // set the starting fileId if (fid < 0L && llabs(fid) > INT32_MAX) { // data value overflow for INT32 fid = INT32_MIN; } @@ -1297,7 +1298,8 @@ static bool getDataBlocksInFiles(STsdbQueryHandle* pQueryHandle) { // find the start data block in file if (!pQueryHandle->locateStart) { pQueryHandle->locateStart = true; - int32_t fid = getFileIdFromKey(pQueryHandle->window.skey, pQueryHandle->pTsdb->config.daysPerFile); + STsdbCfg* pCfg = &pQueryHandle->pTsdb->config; + int32_t fid = getFileIdFromKey(pQueryHandle->window.skey, pCfg->daysPerFile, pCfg->precision); tsdbInitFileGroupIter(pFileHandle, &pQueryHandle->fileIter, pQueryHandle->order); tsdbSeekFileGroupIter(&pQueryHandle->fileIter, fid); diff --git a/src/util/src/ttimer.c b/src/util/src/ttimer.c index 55e7da3258c403934b7609fc71b05010070b41f4..68db574d82f3e668ced4b8895c3427640641079e 100644 --- a/src/util/src/ttimer.c +++ b/src/util/src/ttimer.c @@ -342,7 +342,6 @@ static void taosTimerLoopFunc(int signo) { int64_t now = taosGetTimestampMs(); for (int i = 0; i < tListLen(wheels); i++) { - tmrTrace("begin processing wheel %d", i); // `expried` is a temporary expire list. // expired timers are first add to this list, then move // to expired queue as a batch to improve performance. @@ -390,7 +389,6 @@ static void taosTimerLoopFunc(int signo) { } addToExpired(expired); - tmrTrace("end processing wheel %d", i); } } diff --git a/tests/script/general/http/restful_full.sim b/tests/script/general/http/restful_full.sim index a5defb5914d733147a88ca6024b61e8d183f0e03..0ae687350342242d320a094e42a736aee10ba15a 100644 --- a/tests/script/general/http/restful_full.sim +++ b/tests/script/general/http/restful_full.sim @@ -147,7 +147,7 @@ print =============== step3 - db system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' select * from d1.t1;' 127.0.0.1:6020/rest/sql print 21-> $system_content -if $system_content != @{"status":"error","code":1000,"desc":"invalid table name"}@ then +if $system_content != @{"status":"error","code":1000,"desc":"invalid table id"}@ then return -1 endi diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index b2416611cf70c44dbe17c97cec1912ee6e9cb203..1a22c3e789fc27cf8de54aaf050aa32c93f8c1f2 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -59,7 +59,6 @@ cd ../../../debug; make ./test.sh -f general/db/delete_writing1.sim ./test.sh -f general/db/delete_writing2.sim ./test.sh -f general/db/delete.sim -#not test ./test.sh -f general/db/dropdnodes.sim ./test.sh -f general/db/len.sim ./test.sh -f general/db/repeat.sim ./test.sh -f general/db/tables.sim @@ -121,7 +120,7 @@ cd ../../../debug; make # ./test.sh -f general/parser/import_file.sim ./test.sh -f general/parser/lastrow.sim ./test.sh -f general/parser/nchar.sim -./test.sh -f general/parser/null_char.sim +#unsupport ./test.sh -f general/parser/null_char.sim ./test.sh -f general/parser/single_row_in_tb.sim ./test.sh -f general/parser/select_from_cache_disk.sim ./test.sh -f general/parser/limit.sim @@ -214,7 +213,6 @@ cd ../../../debug; make ./test.sh -f general/tag/tinyint.sim ./test.sh -f general/user/authority.sim -./test.sh -f general/user/basic1.sim ./test.sh -f general/user/monitor.sim ./test.sh -f general/user/pass_alter.sim ./test.sh -f general/user/pass_len.sim diff --git a/tests/script/jenkins/general.txt b/tests/script/jenkins/general.txt new file mode 100644 index 0000000000000000000000000000000000000000..0c14e1c7a0ffd9bf01b11312e93320dbd883380d --- /dev/null +++ b/tests/script/jenkins/general.txt @@ -0,0 +1,5 @@ +cd ../../debug; cmake .. +cd ../../debug; make + +./test.sh -f general/db/dropdnodes.sim +./test.sh -f general/user/basic1.sim diff --git a/tests/script/jenkins/sync.txt b/tests/script/jenkins/unique.txt similarity index 100% rename from tests/script/jenkins/sync.txt rename to tests/script/jenkins/unique.txt