diff --git a/src/client/jni/com_taosdata_jdbc_TSDBJNIConnector.h b/src/client/jni/com_taosdata_jdbc_TSDBJNIConnector.h index 582bd6bac03ce0049c7c22fe58fa4fa6eb8c69fb..b3060e2c820d7bbb405bf6e96a4bf8af8ed0ec55 100644 --- a/src/client/jni/com_taosdata_jdbc_TSDBJNIConnector.h +++ b/src/client/jni/com_taosdata_jdbc_TSDBJNIConnector.h @@ -49,6 +49,14 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setOptions JNIEXPORT jstring JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_getTsCharset (JNIEnv *, jclass); +/* + * Class: com_taosdata_jdbc_TSDBJNIConnector + * Method: getResultTimePrecision + * Signature: (J)J + */ +JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TDDBJNIConnector_getResultTimePrecision + (JNIEnv *, jobject, jlong, jlong); + /* * Class: com_taosdata_jdbc_TSDBJNIConnector * Method: connectImp diff --git a/src/client/src/TSDBJNIConnector.c b/src/client/src/TSDBJNIConnector.c index 56e155311e60dd0a30d3f6b5dce99c9d4c76ec7f..7447e36ac9cf1074db0c62077be07b6a41a99256 100644 --- a/src/client/src/TSDBJNIConnector.c +++ b/src/client/src/TSDBJNIConnector.c @@ -671,3 +671,20 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_validateCreateTab JNIEXPORT jstring JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_getTsCharset(JNIEnv *env, jobject jobj) { return (*env)->NewStringUTF(env, (const char *)tsCharset); } + +JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TDDBJNIConnector_getResultTimePrecision(JNIEnv *env, jobject jobj, jlong con, + jlong res) { + TAOS *tscon = (TAOS *)con; + if (tscon == NULL) { + jniError("jobj:%p, connection is closed", jobj); + return JNI_CONNECTION_NULL; + } + + TAOS_RES *result = (TAOS_RES *)res; + if (result == NULL) { + jniError("jobj:%p, conn:%p, resultset is null", jobj, tscon); + return JNI_RESULT_SET_NULL; + } + + return taos_result_precision(result); +} \ No newline at end of file diff --git a/src/common/src/tvariant.c b/src/common/src/tvariant.c index 7009c4d5c3d8516f17dd4caf89b37e9c28f93274..7798deaa60db0fb0616a5558d7e7419b697f3082 100644 --- a/src/common/src/tvariant.c +++ b/src/common/src/tvariant.c @@ -48,8 +48,12 @@ void tVariantCreate(tVariant *pVar, SStrToken *token) { case TSDB_DATA_TYPE_INT:{ ret = tStrToInteger(token->z, token->type, token->n, &pVar->i64, true); if (ret != 0) { - pVar->nType = -1; // -1 means error type - return; + // data overflow, try unsigned parse the input number + ret = tStrToInteger(token->z, token->type, token->n, &pVar->i64, false); + if (ret != 0) { + pVar->nType = -1; // -1 means error type + return; + } } break; @@ -525,6 +529,8 @@ static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result } bool code = false; + + uint64_t ui = 0; switch(type) { case TSDB_DATA_TYPE_TINYINT: code = IS_VALID_TINYINT(*result); break; @@ -535,13 +541,17 @@ static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result case TSDB_DATA_TYPE_BIGINT: code = IS_VALID_BIGINT(*result); break; case TSDB_DATA_TYPE_UTINYINT: - code = IS_VALID_UTINYINT(*result); break; + ui = *result; + code = IS_VALID_UTINYINT(ui); break; case TSDB_DATA_TYPE_USMALLINT: - code = IS_VALID_USMALLINT(*result); break; + ui = *result; + code = IS_VALID_USMALLINT(ui); break; case TSDB_DATA_TYPE_UINT: - code = IS_VALID_UINT(*result); break; + ui = *result; + code = IS_VALID_UINT(ui); break; case TSDB_DATA_TYPE_UBIGINT: - code = IS_VALID_UBIGINT(*result); break; + ui = *result; + code = IS_VALID_UBIGINT(ui); break; } return code? 0:-1; diff --git a/src/query/src/qExtbuffer.c b/src/query/src/qExtbuffer.c index 73b5b81e52628a4bd151869487150d97a09b8155..90734e2e0ee70d0f41ecd4620e23f606e16f7d3e 100644 --- a/src/query/src/qExtbuffer.c +++ b/src/query/src/qExtbuffer.c @@ -354,45 +354,14 @@ static FORCE_INLINE int32_t primaryKeyComparator(int64_t f1, int64_t f2, int32_t static FORCE_INLINE int32_t columnValueAscendingComparator(char *f1, char *f2, int32_t type, int32_t bytes) { switch (type) { - case TSDB_DATA_TYPE_INT: { - int32_t first = *(int32_t *) f1; - int32_t second = *(int32_t *) f2; - if (first == second) { - return 0; - } - return (first < second) ? -1 : 1; - }; - case TSDB_DATA_TYPE_DOUBLE: { - DEFAULT_DOUBLE_COMP(GET_DOUBLE_VAL(f1), GET_DOUBLE_VAL(f2)); - }; - case TSDB_DATA_TYPE_FLOAT: { - DEFAULT_FLOAT_COMP(GET_FLOAT_VAL(f1), GET_FLOAT_VAL(f2)); - }; - case TSDB_DATA_TYPE_BIGINT: { - int64_t first = *(int64_t *)f1; - int64_t second = *(int64_t *)f2; - if (first == second) { - return 0; - } - return (first < second) ? -1 : 1; - }; - case TSDB_DATA_TYPE_SMALLINT: { - int16_t first = *(int16_t *)f1; - int16_t second = *(int16_t *)f2; - if (first == second) { - return 0; - } - return (first < second) ? -1 : 1; - }; + case TSDB_DATA_TYPE_INT: DEFAULT_COMP(GET_INT32_VAL(f1), GET_INT32_VAL(f2)); + case TSDB_DATA_TYPE_DOUBLE: DEFAULT_DOUBLE_COMP(GET_DOUBLE_VAL(f1), GET_DOUBLE_VAL(f2)); + case TSDB_DATA_TYPE_FLOAT: DEFAULT_FLOAT_COMP(GET_FLOAT_VAL(f1), GET_FLOAT_VAL(f2)); + case TSDB_DATA_TYPE_BIGINT: DEFAULT_COMP(GET_INT64_VAL(f1), GET_INT64_VAL(f2)); + case TSDB_DATA_TYPE_SMALLINT:DEFAULT_COMP(GET_INT16_VAL(f1), GET_INT16_VAL(f2)); case TSDB_DATA_TYPE_BOOL: - case TSDB_DATA_TYPE_TINYINT: { - int8_t first = *(int8_t *)f1; - int8_t second = *(int8_t *)f2; - if (first == second) { - return 0; - } - return (first < second) ? -1 : 1; - }; + case TSDB_DATA_TYPE_TINYINT: DEFAULT_COMP(GET_INT8_VAL(f1), GET_INT8_VAL(f2)); + case TSDB_DATA_TYPE_BINARY: { int32_t len1 = varDataLen(f1); int32_t len2 = varDataLen(f2); @@ -415,6 +384,10 @@ static FORCE_INLINE int32_t columnValueAscendingComparator(char *f1, char *f2, i } return (ret < 0) ? -1 : 1; }; + case TSDB_DATA_TYPE_UTINYINT: DEFAULT_COMP(GET_UINT8_VAL(f1), GET_UINT8_VAL(f2)); + case TSDB_DATA_TYPE_USMALLINT: DEFAULT_COMP(GET_UINT16_VAL(f1), GET_UINT16_VAL(f2)); + case TSDB_DATA_TYPE_UINT: DEFAULT_COMP(GET_UINT32_VAL(f1), GET_UINT32_VAL(f2)); + case TSDB_DATA_TYPE_UBIGINT: DEFAULT_COMP(GET_UINT64_VAL(f1), GET_UINT64_VAL(f2)); } return 0; diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index c71af0b5dd056c27c5ac302b1818a89be963040b..e22a6bf6f146b1edaf0133be74a03879cdf44eb2 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -3210,9 +3210,10 @@ int32_t tsdbQuerySTableByTagCond(STsdbRepo* tsdb, uint64_t uid, TSKEY skey, cons pGroupInfo->numOfTables = (uint32_t) taosArrayGetSize(res); pGroupInfo->pGroupList = createTableGroup(res, pTagSchema, pColIndex, numOfCols, skey); - tsdbDebug("%p no table name/tag condition, all tables belong to one group, numOfTables:%u", tsdb, pGroupInfo->numOfTables); - taosArrayDestroy(res); + tsdbDebug("%p no table name/tag condition, all tables qualified, numOfTables:%u, group:%zu", tsdb, + pGroupInfo->numOfTables, taosArrayGetSize(pGroupInfo->pGroupList)); + taosArrayDestroy(res); if (tsdbUnlockRepoMeta(tsdb) < 0) goto _error; return ret; } diff --git a/src/util/src/tcompare.c b/src/util/src/tcompare.c index 4d18ef14e2a1985259b11ff65391616c9d4706b2..354e7899c27d9af12f107964b067311fce10c84f 100644 --- a/src/util/src/tcompare.c +++ b/src/util/src/tcompare.c @@ -398,6 +398,10 @@ int32_t doCompare(const char* f1, const char* f2, int32_t type, size_t size) { case TSDB_DATA_TYPE_SMALLINT: DEFAULT_COMP(GET_INT16_VAL(f1), GET_INT16_VAL(f2)); case TSDB_DATA_TYPE_TINYINT: case TSDB_DATA_TYPE_BOOL: DEFAULT_COMP(GET_INT8_VAL(f1), GET_INT8_VAL(f2)); + case TSDB_DATA_TYPE_UTINYINT: DEFAULT_COMP(GET_UINT8_VAL(f1), GET_UINT8_VAL(f2)); + case TSDB_DATA_TYPE_USMALLINT: DEFAULT_COMP(GET_UINT16_VAL(f1), GET_UINT16_VAL(f2)); + case TSDB_DATA_TYPE_UINT: DEFAULT_COMP(GET_UINT32_VAL(f1), GET_UINT32_VAL(f2)); + case TSDB_DATA_TYPE_UBIGINT: DEFAULT_COMP(GET_UINT64_VAL(f1), GET_UINT64_VAL(f2)); case TSDB_DATA_TYPE_NCHAR: { tstr* t1 = (tstr*) f1; tstr* t2 = (tstr*) f2; diff --git a/tests/script/general/parser/first_last_query.sim b/tests/script/general/parser/first_last_query.sim index 2d08759f3fb0bdd78a3163e335334a49504ec861..2dff1dd51b4fe7d3646a013302b084f66b31669d 100644 --- a/tests/script/general/parser/first_last_query.sim +++ b/tests/script/general/parser/first_last_query.sim @@ -269,4 +269,50 @@ if $data14 != @test2@ then return -1 endi -sql drop table stest \ No newline at end of file +sql drop table stest + +print ===================>td-3779 +sql create table m1(ts timestamp, k int) tags(a int); +sql create table tm0 using m1 tags(1); +sql create table tm1 using m1 tags(2); +sql insert into tm0 values('2020-3-1 1:1:1', 112); +sql insert into tm1 values('2020-1-1 1:1:1', 1)('2020-3-1 0:1:1', 421); +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 1000 + +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed +sleep 1000 +sql connect +sql use first_db0; + +sql select last(*) from m1 group by tbname; +if $rows != 2 then + return -1 +endi + +if $data00 != @20-03-01 01:01:01.000@ then + return -1 +endi + +if $data01 != 112 then + return -1 +endi + +if $data02 != @tm0@ then + return -1 +endi + +if $data10 != @20-03-01 00:01:01.000@ then + return -1 +endi + +if $data11 != 421 then + return -1 +endi + +if $data12 != @tm1@ then + return -1 +endi + +sql drop table m1 \ No newline at end of file diff --git a/tests/script/general/parser/select_with_tags.sim b/tests/script/general/parser/select_with_tags.sim index da8e8765773bc6cf8a4ae2b1b0b1a6bb38a1194a..9f445649e1bbbec6ff6ff2e3d6fe836be9c68a3e 100644 --- a/tests/script/general/parser/select_with_tags.sim +++ b/tests/script/general/parser/select_with_tags.sim @@ -160,7 +160,7 @@ if $data03 != @abc15@ then endi sql select top(c6, 3) from select_tags_mt0 interval(10a) -sql select top(c3,10) from select_tags_mt0 interval(10a) group by tbname +sql select top(c3,10) from select_tags_mt0 interval(10a) group by tbname,t1,t2 sql select top(c6, 3) from select_tags_mt0 interval(10a) group by tbname; sql select top(c6, 10) from select_tags_mt0 interval(10a); diff --git a/tests/tsim/src/simSystem.c b/tests/tsim/src/simSystem.c index d2494eddbbbb1756e4daf63e7532fdb466a4824e..dda1e133de60d906232116f436a6b35908f1f25b 100644 --- a/tests/tsim/src/simSystem.c +++ b/tests/tsim/src/simSystem.c @@ -164,7 +164,6 @@ void *simExecuteScript(void *inputScript) { } if (script->killed || script->linePos >= script->numOfLines) { - printf("killed ---------------------->\n"); script = simProcessCallOver(script); if (script == NULL) { printf("abort now!\n");