Merge pull request #26676 from taosdata/feat/TD-30991-3.0
feat: (errcode) ttime.c geomFunc.c geosWrapper.c
This commit is contained in:
commit
3f79e5b7e3
|
@ -86,11 +86,11 @@ void deltaToUtcInitOnce();
|
||||||
char getPrecisionUnit(int32_t precision);
|
char getPrecisionUnit(int32_t precision);
|
||||||
|
|
||||||
int64_t convertTimePrecision(int64_t ts, int32_t fromPrecision, int32_t toPrecision);
|
int64_t convertTimePrecision(int64_t ts, int32_t fromPrecision, int32_t toPrecision);
|
||||||
int64_t convertTimeFromPrecisionToUnit(int64_t ts, int32_t fromPrecision, char toUnit);
|
int32_t convertTimeFromPrecisionToUnit(int64_t time, int32_t fromPrecision, char toUnit, int64_t* pRes);
|
||||||
int32_t convertStringToTimestamp(int16_t type, char* inputData, int64_t timePrec, int64_t* timeVal);
|
int32_t convertStringToTimestamp(int16_t type, char* inputData, int64_t timePrec, int64_t* timeVal);
|
||||||
int32_t getDuration(int64_t val, char unit, int64_t* result, int32_t timePrecision);
|
int32_t getDuration(int64_t val, char unit, int64_t* result, int32_t timePrecision);
|
||||||
|
|
||||||
void taosFormatUtcTime(char* buf, int32_t bufLen, int64_t ts, int32_t precision);
|
int32_t taosFormatUtcTime(char* buf, int32_t bufLen, int64_t ts, int32_t precision);
|
||||||
|
|
||||||
struct STm {
|
struct STm {
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
|
|
|
@ -35,7 +35,7 @@ void deltaToUtcInitOnce() {
|
||||||
// printf("====delta:%lld\n\n", seconds);
|
// printf("====delta:%lld\n\n", seconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t parseFraction(char* str, char** end, int32_t timePrec);
|
static int32_t parseFraction(char* str, char** end, int32_t timePrec, int64_t* pFraction);
|
||||||
static int32_t parseTimeWithTz(const char* timestr, int64_t* time, int32_t timePrec, char delim);
|
static int32_t parseTimeWithTz(const char* timestr, int64_t* time, int32_t timePrec, char delim);
|
||||||
static int32_t parseLocaltime(char* timestr, int32_t len, int64_t* utime, int32_t timePrec, char delim);
|
static int32_t parseLocaltime(char* timestr, int32_t len, int64_t* utime, int32_t timePrec, char delim);
|
||||||
static int32_t parseLocaltimeDst(char* timestr, int32_t len, int64_t* utime, int32_t timePrec, char delim);
|
static int32_t parseLocaltimeDst(char* timestr, int32_t len, int64_t* utime, int32_t timePrec, char delim);
|
||||||
|
@ -95,7 +95,9 @@ char* forwardToTimeStringEnd(char* str) {
|
||||||
return &str[i];
|
return &str[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t parseFraction(char* str, char** end, int32_t timePrec) {
|
int32_t parseFraction(char* str, char** end, int32_t timePrec, int64_t* pFraction) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
int64_t fraction = 0;
|
int64_t fraction = 0;
|
||||||
|
|
||||||
|
@ -112,7 +114,7 @@ int64_t parseFraction(char* str, char** end, int32_t timePrec) {
|
||||||
|
|
||||||
int32_t totalLen = i;
|
int32_t totalLen = i;
|
||||||
if (totalLen <= 0) {
|
if (totalLen <= 0) {
|
||||||
return -1;
|
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* parse the fraction */
|
/* parse the fraction */
|
||||||
|
@ -134,21 +136,24 @@ int64_t parseFraction(char* str, char** end, int32_t timePrec) {
|
||||||
}
|
}
|
||||||
times = NANO_SEC_FRACTION_LEN - i;
|
times = NANO_SEC_FRACTION_LEN - i;
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||||
}
|
}
|
||||||
|
|
||||||
fraction = strnatoi(str, i) * factor[times];
|
fraction = strnatoi(str, i) * factor[times];
|
||||||
*end = str + totalLen;
|
*end = str + totalLen;
|
||||||
|
*pFraction = fraction;
|
||||||
|
|
||||||
return fraction;
|
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t parseTimezone(char* str, int64_t* tzOffset) {
|
int32_t parseTimezone(char* str, int64_t* tzOffset) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
int64_t hour = 0;
|
int64_t hour = 0;
|
||||||
|
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
if (str[i] != '+' && str[i] != '-') {
|
if (str[i] != '+' && str[i] != '-') {
|
||||||
return -1;
|
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
|
@ -160,7 +165,7 @@ int32_t parseTimezone(char* str, int64_t* tzOffset) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* sep = strchr(&str[i], ':');
|
char* sep = strchr(&str[i], ':');
|
||||||
|
@ -175,18 +180,18 @@ int32_t parseTimezone(char* str, int64_t* tzOffset) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hour > 12 || hour < 0) {
|
if (hour > 12 || hour < 0) {
|
||||||
return -1;
|
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||||
}
|
}
|
||||||
|
|
||||||
// return error if there're illegal charaters after min(2 Digits)
|
// return error if there're illegal charaters after min(2 Digits)
|
||||||
char* minStr = &str[i];
|
char* minStr = &str[i];
|
||||||
if (minStr[1] != '\0' && minStr[2] != '\0') {
|
if (minStr[1] != '\0' && minStr[2] != '\0') {
|
||||||
return -1;
|
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t minute = strnatoi(&str[i], 2);
|
int64_t minute = strnatoi(&str[i], 2);
|
||||||
if (minute > 59 || (hour == 12 && minute > 0)) {
|
if (minute > 59 || (hour == 12 && minute > 0)) {
|
||||||
return -1;
|
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (str[0] == '+') {
|
if (str[0] == '+') {
|
||||||
|
@ -195,13 +200,13 @@ int32_t parseTimezone(char* str, int64_t* tzOffset) {
|
||||||
*tzOffset = hour * 3600 + minute * 60;
|
*tzOffset = hour * 3600 + minute * 60;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t offsetOfTimezone(char* tzStr, int64_t* offset) {
|
int32_t offsetOfTimezone(char* tzStr, int64_t* offset) {
|
||||||
if (tzStr && (tzStr[0] == 'z' || tzStr[0] == 'Z')) {
|
if (tzStr && (tzStr[0] == 'z' || tzStr[0] == 'Z')) {
|
||||||
*offset = 0;
|
*offset = 0;
|
||||||
return 0;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
return parseTimezone(tzStr, offset);
|
return parseTimezone(tzStr, offset);
|
||||||
}
|
}
|
||||||
|
@ -219,6 +224,8 @@ int32_t offsetOfTimezone(char* tzStr, int64_t* offset) {
|
||||||
* 2013-04-12T15:52:01.123+0800
|
* 2013-04-12T15:52:01.123+0800
|
||||||
*/
|
*/
|
||||||
int32_t parseTimeWithTz(const char* timestr, int64_t* time, int32_t timePrec, char delim) {
|
int32_t parseTimeWithTz(const char* timestr, int64_t* time, int32_t timePrec, char delim) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
int64_t factor = TSDB_TICK_PER_SECOND(timePrec);
|
int64_t factor = TSDB_TICK_PER_SECOND(timePrec);
|
||||||
int64_t tzOffset = 0;
|
int64_t tzOffset = 0;
|
||||||
|
|
||||||
|
@ -234,7 +241,7 @@ int32_t parseTimeWithTz(const char* timestr, int64_t* time, int32_t timePrec, ch
|
||||||
}
|
}
|
||||||
|
|
||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
return -1;
|
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* mktime will be affected by TZ, set by using taos_options */
|
/* mktime will be affected by TZ, set by using taos_options */
|
||||||
|
@ -253,22 +260,18 @@ int32_t parseTimeWithTz(const char* timestr, int64_t* time, int32_t timePrec, ch
|
||||||
*time = seconds * factor;
|
*time = seconds * factor;
|
||||||
} else if (str[0] == '.') {
|
} else if (str[0] == '.') {
|
||||||
str += 1;
|
str += 1;
|
||||||
if ((fraction = parseFraction(str, &str, timePrec)) < 0) {
|
TAOS_CHECK_RETURN(parseFraction(str, &str, timePrec, &fraction));
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
*time = seconds * factor + fraction;
|
*time = seconds * factor + fraction;
|
||||||
|
|
||||||
char seg = str[0];
|
char seg = str[0];
|
||||||
if (seg != 'Z' && seg != 'z' && seg != '+' && seg != '-') {
|
if (seg != 'Z' && seg != 'z' && seg != '+' && seg != '-') {
|
||||||
return -1;
|
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||||
} else if ((seg == 'Z' || seg == 'z') && str[1] != '\0') {
|
} else if ((seg == 'Z' || seg == 'z') && str[1] != '\0') {
|
||||||
return -1;
|
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||||
} else if (seg == '+' || seg == '-') {
|
} else if (seg == '+' || seg == '-') {
|
||||||
// parse the timezone
|
// parse the timezone
|
||||||
if (parseTimezone(str, &tzOffset) == -1) {
|
TAOS_CHECK_RETURN(parseTimezone(str, &tzOffset));
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
*time += tzOffset * factor;
|
*time += tzOffset * factor;
|
||||||
}
|
}
|
||||||
|
@ -277,16 +280,14 @@ int32_t parseTimeWithTz(const char* timestr, int64_t* time, int32_t timePrec, ch
|
||||||
*time = seconds * factor + fraction;
|
*time = seconds * factor + fraction;
|
||||||
|
|
||||||
// parse the timezone
|
// parse the timezone
|
||||||
if (parseTimezone(str, &tzOffset) == -1) {
|
TAOS_CHECK_RETURN(parseTimezone(str, &tzOffset));
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
*time += tzOffset * factor;
|
*time += tzOffset * factor;
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE bool validateTm(struct tm* pTm) {
|
static FORCE_INLINE bool validateTm(struct tm* pTm) {
|
||||||
|
@ -314,6 +315,8 @@ static FORCE_INLINE bool validateTm(struct tm* pTm) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t parseLocaltime(char* timestr, int32_t len, int64_t* utime, int32_t timePrec, char delim) {
|
int32_t parseLocaltime(char* timestr, int32_t len, int64_t* utime, int32_t timePrec, char delim) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
*utime = 0;
|
*utime = 0;
|
||||||
struct tm tm = {0};
|
struct tm tm = {0};
|
||||||
|
|
||||||
|
@ -330,7 +333,7 @@ int32_t parseLocaltime(char* timestr, int32_t len, int64_t* utime, int32_t timeP
|
||||||
// if parse failed, try "%Y-%m-%d" format
|
// if parse failed, try "%Y-%m-%d" format
|
||||||
str = taosStrpTime(timestr, "%Y-%m-%d", &tm);
|
str = taosStrpTime(timestr, "%Y-%m-%d", &tm);
|
||||||
if (str == NULL || (((str - timestr) < len) && (*str != '.')) || !validateTm(&tm)) {
|
if (str == NULL || (((str - timestr) < len) && (*str != '.')) || !validateTm(&tm)) {
|
||||||
return -1;
|
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,16 +350,16 @@ int32_t parseLocaltime(char* timestr, int32_t len, int64_t* utime, int32_t timeP
|
||||||
|
|
||||||
if (*str == '.') {
|
if (*str == '.') {
|
||||||
/* parse the second fraction part */
|
/* parse the second fraction part */
|
||||||
if ((fraction = parseFraction(str + 1, &str, timePrec)) < 0) {
|
TAOS_CHECK_RETURN(parseFraction(str + 1, &str, timePrec, &fraction));
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*utime = TSDB_TICK_PER_SECOND(timePrec) * seconds + fraction;
|
*utime = TSDB_TICK_PER_SECOND(timePrec) * seconds + fraction;
|
||||||
return 0;
|
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t parseLocaltimeDst(char* timestr, int32_t len, int64_t* utime, int32_t timePrec, char delim) {
|
int32_t parseLocaltimeDst(char* timestr, int32_t len, int64_t* utime, int32_t timePrec, char delim) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
*utime = 0;
|
*utime = 0;
|
||||||
struct tm tm = {0};
|
struct tm tm = {0};
|
||||||
tm.tm_isdst = -1;
|
tm.tm_isdst = -1;
|
||||||
|
@ -374,7 +377,7 @@ int32_t parseLocaltimeDst(char* timestr, int32_t len, int64_t* utime, int32_t ti
|
||||||
// if parse failed, try "%Y-%m-%d" format
|
// if parse failed, try "%Y-%m-%d" format
|
||||||
str = taosStrpTime(timestr, "%Y-%m-%d", &tm);
|
str = taosStrpTime(timestr, "%Y-%m-%d", &tm);
|
||||||
if (str == NULL || (((str - timestr) < len) && (*str != '.')) || !validateTm(&tm)) {
|
if (str == NULL || (((str - timestr) < len) && (*str != '.')) || !validateTm(&tm)) {
|
||||||
return -1;
|
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,13 +387,11 @@ int32_t parseLocaltimeDst(char* timestr, int32_t len, int64_t* utime, int32_t ti
|
||||||
int64_t fraction = 0;
|
int64_t fraction = 0;
|
||||||
if (*str == '.') {
|
if (*str == '.') {
|
||||||
/* parse the second fraction part */
|
/* parse the second fraction part */
|
||||||
if ((fraction = parseFraction(str + 1, &str, timePrec)) < 0) {
|
TAOS_CHECK_RETURN(parseFraction(str + 1, &str, timePrec, &fraction));
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*utime = TSDB_TICK_PER_SECOND(timePrec) * seconds + fraction;
|
*utime = TSDB_TICK_PER_SECOND(timePrec) * seconds + fraction;
|
||||||
return 0;
|
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
char getPrecisionUnit(int32_t precision) {
|
char getPrecisionUnit(int32_t precision) {
|
||||||
|
@ -482,10 +483,12 @@ int64_t convertTimePrecision(int64_t utime, int32_t fromPrecision, int32_t toPre
|
||||||
|
|
||||||
// !!!!notice: double lose precison if time is too large, for example: 1626006833631000000*1.0 = double =
|
// !!!!notice: double lose precison if time is too large, for example: 1626006833631000000*1.0 = double =
|
||||||
// 1626006833631000064
|
// 1626006833631000064
|
||||||
int64_t convertTimeFromPrecisionToUnit(int64_t time, int32_t fromPrecision, char toUnit) {
|
int32_t convertTimeFromPrecisionToUnit(int64_t time, int32_t fromPrecision, char toUnit, int64_t* pRes) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
if (fromPrecision != TSDB_TIME_PRECISION_MILLI && fromPrecision != TSDB_TIME_PRECISION_MICRO &&
|
if (fromPrecision != TSDB_TIME_PRECISION_MILLI && fromPrecision != TSDB_TIME_PRECISION_MICRO &&
|
||||||
fromPrecision != TSDB_TIME_PRECISION_NANO) {
|
fromPrecision != TSDB_TIME_PRECISION_NANO) {
|
||||||
return -1;
|
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t factors[3] = {NANOSECOND_PER_MSEC, NANOSECOND_PER_USEC, 1};
|
int64_t factors[3] = {NANOSECOND_PER_MSEC, NANOSECOND_PER_USEC, 1};
|
||||||
|
@ -541,15 +544,23 @@ int64_t convertTimeFromPrecisionToUnit(int64_t time, int32_t fromPrecision, char
|
||||||
time *= factors[fromPrecision];
|
time *= factors[fromPrecision];
|
||||||
break;
|
break;
|
||||||
default: {
|
default: {
|
||||||
return -1;
|
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tmp >= (double)INT64_MAX) return INT64_MAX;
|
if (tmp >= (double)INT64_MAX) {
|
||||||
if (tmp <= (double)INT64_MIN) return INT64_MIN;
|
*pRes = INT64_MAX;
|
||||||
return time;
|
} else if (tmp <= (double)INT64_MIN) {
|
||||||
|
*pRes = INT64_MIN;
|
||||||
|
} else {
|
||||||
|
*pRes = time;
|
||||||
|
}
|
||||||
|
|
||||||
|
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t convertStringToTimestamp(int16_t type, char* inputData, int64_t timePrec, int64_t* timeVal) {
|
int32_t convertStringToTimestamp(int16_t type, char* inputData, int64_t timePrec, int64_t* timeVal) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
int32_t charLen = varDataLen(inputData);
|
int32_t charLen = varDataLen(inputData);
|
||||||
char* newColData;
|
char* newColData;
|
||||||
if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_VARBINARY) {
|
if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_VARBINARY) {
|
||||||
|
@ -558,7 +569,7 @@ int32_t convertStringToTimestamp(int16_t type, char* inputData, int64_t timePrec
|
||||||
int32_t ret = taosParseTime(newColData, timeVal, charLen, (int32_t)timePrec, tsDaylight);
|
int32_t ret = taosParseTime(newColData, timeVal, charLen, (int32_t)timePrec, tsDaylight);
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
taosMemoryFree(newColData);
|
taosMemoryFree(newColData);
|
||||||
return TSDB_CODE_INVALID_TIMESTAMP;
|
TAOS_RETURN(TSDB_CODE_INVALID_TIMESTAMP);
|
||||||
}
|
}
|
||||||
taosMemoryFree(newColData);
|
taosMemoryFree(newColData);
|
||||||
} else if (type == TSDB_DATA_TYPE_NCHAR) {
|
} else if (type == TSDB_DATA_TYPE_NCHAR) {
|
||||||
|
@ -566,50 +577,52 @@ int32_t convertStringToTimestamp(int16_t type, char* inputData, int64_t timePrec
|
||||||
int len = taosUcs4ToMbs((TdUcs4*)varDataVal(inputData), charLen, newColData);
|
int len = taosUcs4ToMbs((TdUcs4*)varDataVal(inputData), charLen, newColData);
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
taosMemoryFree(newColData);
|
taosMemoryFree(newColData);
|
||||||
return TSDB_CODE_FAILED;
|
TAOS_RETURN(TSDB_CODE_FAILED);
|
||||||
}
|
}
|
||||||
newColData[len] = 0;
|
newColData[len] = 0;
|
||||||
int32_t ret = taosParseTime(newColData, timeVal, len, (int32_t)timePrec, tsDaylight);
|
int32_t ret = taosParseTime(newColData, timeVal, len, (int32_t)timePrec, tsDaylight);
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
taosMemoryFree(newColData);
|
taosMemoryFree(newColData);
|
||||||
return ret;
|
TAOS_RETURN(ret);
|
||||||
}
|
}
|
||||||
taosMemoryFree(newColData);
|
taosMemoryFree(newColData);
|
||||||
} else {
|
} else {
|
||||||
return TSDB_CODE_FAILED;
|
TAOS_RETURN(TSDB_CODE_FAILED);
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t getDuration(int64_t val, char unit, int64_t* result, int32_t timePrecision) {
|
int32_t getDuration(int64_t val, char unit, int64_t* result, int32_t timePrecision) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
switch (unit) {
|
switch (unit) {
|
||||||
case 's':
|
case 's':
|
||||||
if (val > INT64_MAX / MILLISECOND_PER_SECOND) {
|
if (val > INT64_MAX / MILLISECOND_PER_SECOND) {
|
||||||
return -1;
|
TAOS_RETURN(TSDB_CODE_OUT_OF_RANGE);
|
||||||
}
|
}
|
||||||
(*result) = convertTimePrecision(val * MILLISECOND_PER_SECOND, TSDB_TIME_PRECISION_MILLI, timePrecision);
|
(*result) = convertTimePrecision(val * MILLISECOND_PER_SECOND, TSDB_TIME_PRECISION_MILLI, timePrecision);
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
if (val > INT64_MAX / MILLISECOND_PER_MINUTE) {
|
if (val > INT64_MAX / MILLISECOND_PER_MINUTE) {
|
||||||
return -1;
|
TAOS_RETURN(TSDB_CODE_OUT_OF_RANGE);
|
||||||
}
|
}
|
||||||
(*result) = convertTimePrecision(val * MILLISECOND_PER_MINUTE, TSDB_TIME_PRECISION_MILLI, timePrecision);
|
(*result) = convertTimePrecision(val * MILLISECOND_PER_MINUTE, TSDB_TIME_PRECISION_MILLI, timePrecision);
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
if (val > INT64_MAX / MILLISECOND_PER_MINUTE) {
|
if (val > INT64_MAX / MILLISECOND_PER_MINUTE) {
|
||||||
return -1;
|
TAOS_RETURN(TSDB_CODE_OUT_OF_RANGE);
|
||||||
}
|
}
|
||||||
(*result) = convertTimePrecision(val * MILLISECOND_PER_HOUR, TSDB_TIME_PRECISION_MILLI, timePrecision);
|
(*result) = convertTimePrecision(val * MILLISECOND_PER_HOUR, TSDB_TIME_PRECISION_MILLI, timePrecision);
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
if (val > INT64_MAX / MILLISECOND_PER_DAY) {
|
if (val > INT64_MAX / MILLISECOND_PER_DAY) {
|
||||||
return -1;
|
TAOS_RETURN(TSDB_CODE_OUT_OF_RANGE);
|
||||||
}
|
}
|
||||||
(*result) = convertTimePrecision(val * MILLISECOND_PER_DAY, TSDB_TIME_PRECISION_MILLI, timePrecision);
|
(*result) = convertTimePrecision(val * MILLISECOND_PER_DAY, TSDB_TIME_PRECISION_MILLI, timePrecision);
|
||||||
break;
|
break;
|
||||||
case 'w':
|
case 'w':
|
||||||
if (val > INT64_MAX / MILLISECOND_PER_WEEK) {
|
if (val > INT64_MAX / MILLISECOND_PER_WEEK) {
|
||||||
return -1;
|
TAOS_RETURN(TSDB_CODE_OUT_OF_RANGE);
|
||||||
}
|
}
|
||||||
(*result) = convertTimePrecision(val * MILLISECOND_PER_WEEK, TSDB_TIME_PRECISION_MILLI, timePrecision);
|
(*result) = convertTimePrecision(val * MILLISECOND_PER_WEEK, TSDB_TIME_PRECISION_MILLI, timePrecision);
|
||||||
break;
|
break;
|
||||||
|
@ -623,10 +636,10 @@ int32_t getDuration(int64_t val, char unit, int64_t* result, int32_t timePrecisi
|
||||||
(*result) = convertTimePrecision(val, TSDB_TIME_PRECISION_NANO, timePrecision);
|
(*result) = convertTimePrecision(val, TSDB_TIME_PRECISION_NANO, timePrecision);
|
||||||
break;
|
break;
|
||||||
default: {
|
default: {
|
||||||
return -1;
|
TAOS_RETURN(TSDB_CODE_OUT_OF_RANGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -645,47 +658,50 @@ int32_t getDuration(int64_t val, char unit, int64_t* result, int32_t timePrecisi
|
||||||
*/
|
*/
|
||||||
int32_t parseAbsoluteDuration(const char* token, int32_t tokenlen, int64_t* duration, char* unit,
|
int32_t parseAbsoluteDuration(const char* token, int32_t tokenlen, int64_t* duration, char* unit,
|
||||||
int32_t timePrecision) {
|
int32_t timePrecision) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
char* endPtr = NULL;
|
char* endPtr = NULL;
|
||||||
|
|
||||||
/* get the basic numeric value */
|
/* get the basic numeric value */
|
||||||
int64_t timestamp = taosStr2Int64(token, &endPtr, 10);
|
int64_t timestamp = taosStr2Int64(token, &endPtr, 10);
|
||||||
if ((timestamp == 0 && token[0] != '0') || errno != 0) {
|
if ((timestamp == 0 && token[0] != '0') || errno != 0) {
|
||||||
return -1;
|
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* natual month/year are not allowed in absolute duration */
|
/* natual month/year are not allowed in absolute duration */
|
||||||
*unit = token[tokenlen - 1];
|
*unit = token[tokenlen - 1];
|
||||||
if (*unit == 'n' || *unit == 'y') {
|
if (*unit == 'n' || *unit == 'y') {
|
||||||
return -1;
|
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||||
}
|
}
|
||||||
|
|
||||||
return getDuration(timestamp, *unit, duration, timePrecision);
|
return getDuration(timestamp, *unit, duration, timePrecision);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t parseNatualDuration(const char* token, int32_t tokenLen, int64_t* duration, char* unit, int32_t timePrecision, bool negativeAllow) {
|
int32_t parseNatualDuration(const char* token, int32_t tokenLen, int64_t* duration, char* unit, int32_t timePrecision,
|
||||||
|
bool negativeAllow) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
||||||
/* get the basic numeric value */
|
/* get the basic numeric value */
|
||||||
*duration = taosStr2Int64(token, NULL, 10);
|
*duration = taosStr2Int64(token, NULL, 10);
|
||||||
if ((*duration < 0 && !negativeAllow) || errno != 0) {
|
if ((*duration < 0 && !negativeAllow) || errno != 0) {
|
||||||
return -1;
|
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
*unit = token[tokenLen - 1];
|
*unit = token[tokenLen - 1];
|
||||||
if (*unit == 'n' || *unit == 'y') {
|
if (*unit == 'n' || *unit == 'y') {
|
||||||
return 0;
|
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||||
}
|
}
|
||||||
if(isdigit(*unit)) {
|
if (isdigit(*unit)) {
|
||||||
*unit = getPrecisionUnit(timePrecision);
|
*unit = getPrecisionUnit(timePrecision);
|
||||||
}
|
}
|
||||||
|
|
||||||
return getDuration(*duration, *unit, duration, timePrecision);
|
return getDuration(*duration, *unit, duration, timePrecision);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool taosIsLeapYear(int32_t year) {
|
static bool taosIsLeapYear(int32_t year) { return (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); }
|
||||||
return (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision) {
|
int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision) {
|
||||||
if (duration == 0) {
|
if (duration == 0) {
|
||||||
|
@ -900,7 +916,8 @@ int64_t taosTimeTruncate(int64_t ts, const SInterval* pInterval) {
|
||||||
// used together with taosTimeTruncate. when offset is great than zero, slide-start/slide-end is the anchor point
|
// used together with taosTimeTruncate. when offset is great than zero, slide-start/slide-end is the anchor point
|
||||||
int64_t taosTimeGetIntervalEnd(int64_t intervalStart, const SInterval* pInterval) {
|
int64_t taosTimeGetIntervalEnd(int64_t intervalStart, const SInterval* pInterval) {
|
||||||
if (pInterval->offset > 0) {
|
if (pInterval->offset > 0) {
|
||||||
int64_t slideStart = taosTimeAdd(intervalStart, -1 * pInterval->offset, pInterval->offsetUnit, pInterval->precision);
|
int64_t slideStart =
|
||||||
|
taosTimeAdd(intervalStart, -1 * pInterval->offset, pInterval->offsetUnit, pInterval->precision);
|
||||||
int64_t slideEnd = taosTimeAdd(slideStart, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1;
|
int64_t slideEnd = taosTimeAdd(slideStart, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1;
|
||||||
int64_t result = taosTimeAdd(slideEnd, pInterval->offset, pInterval->offsetUnit, pInterval->precision);
|
int64_t result = taosTimeAdd(slideEnd, pInterval->offset, pInterval->offsetUnit, pInterval->precision);
|
||||||
return result;
|
return result;
|
||||||
|
@ -960,7 +977,9 @@ const char* fmtts(int64_t ts) {
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
void taosFormatUtcTime(char* buf, int32_t bufLen, int64_t t, int32_t precision) {
|
int32_t taosFormatUtcTime(char* buf, int32_t bufLen, int64_t t, int32_t precision) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
char ts[40] = {0};
|
char ts[40] = {0};
|
||||||
struct tm ptm;
|
struct tm ptm;
|
||||||
|
|
||||||
|
@ -996,17 +1015,18 @@ void taosFormatUtcTime(char* buf, int32_t bufLen, int64_t t, int32_t precision)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fractionLen = 0;
|
fractionLen = 0;
|
||||||
return;
|
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosLocalTime(", &ptm, buf) == NULL) {
|
if (taosLocalTime(", &ptm, buf) == NULL) {
|
||||||
return;
|
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||||
}
|
}
|
||||||
int32_t length = (int32_t)strftime(ts, 40, "%Y-%m-%dT%H:%M:%S", &ptm);
|
int32_t length = (int32_t)strftime(ts, 40, "%Y-%m-%dT%H:%M:%S", &ptm);
|
||||||
length += snprintf(ts + length, fractionLen, format, mod);
|
length += snprintf(ts + length, fractionLen, format, mod);
|
||||||
length += (int32_t)strftime(ts + length, 40 - length, "%z", &ptm);
|
length += (int32_t)strftime(ts + length, 40 - length, "%z", &ptm);
|
||||||
|
|
||||||
tstrncpy(buf, ts, bufLen);
|
tstrncpy(buf, ts, bufLen);
|
||||||
|
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t taosTs2Tm(int64_t ts, int32_t precision, struct STm* tm) {
|
int32_t taosTs2Tm(int64_t ts, int32_t precision, struct STm* tm) {
|
||||||
|
@ -1055,7 +1075,7 @@ typedef enum {
|
||||||
TSFKW_Mon,
|
TSFKW_Mon,
|
||||||
TSFKW_MS,
|
TSFKW_MS,
|
||||||
TSFKW_NS,
|
TSFKW_NS,
|
||||||
//TSFKW_OF,
|
// TSFKW_OF,
|
||||||
TSFKW_PM,
|
TSFKW_PM,
|
||||||
TSFKW_P_M,
|
TSFKW_P_M,
|
||||||
TSFKW_SS,
|
TSFKW_SS,
|
||||||
|
@ -1076,7 +1096,7 @@ typedef enum {
|
||||||
TSFKW_day,
|
TSFKW_day,
|
||||||
TSFKW_ddd,
|
TSFKW_ddd,
|
||||||
TSFKW_dd,
|
TSFKW_dd,
|
||||||
TSFKW_dy, // mon, tue
|
TSFKW_dy, // mon, tue
|
||||||
TSFKW_d,
|
TSFKW_d,
|
||||||
TSFKW_hh24,
|
TSFKW_hh24,
|
||||||
TSFKW_hh12,
|
TSFKW_hh12,
|
||||||
|
@ -1268,7 +1288,7 @@ static void parseTsFormat(const char* formatStr, SArray* formats) {
|
||||||
}
|
}
|
||||||
if (*formatStr == '\\' && *(formatStr + 1)) {
|
if (*formatStr == '\\' && *(formatStr + 1)) {
|
||||||
formatStr++;
|
formatStr++;
|
||||||
last = NULL; // stop expanding last format, create new format
|
last = NULL; // stop expanding last format, create new format
|
||||||
}
|
}
|
||||||
if (last) {
|
if (last) {
|
||||||
// expand
|
// expand
|
||||||
|
@ -1289,7 +1309,7 @@ static void parseTsFormat(const char* formatStr, SArray* formats) {
|
||||||
// for other strings
|
// for other strings
|
||||||
if (*formatStr == '\\' && *(formatStr + 1)) {
|
if (*formatStr == '\\' && *(formatStr + 1)) {
|
||||||
formatStr++;
|
formatStr++;
|
||||||
lastOtherFormat = NULL; // stop expanding
|
lastOtherFormat = NULL; // stop expanding
|
||||||
} else {
|
} else {
|
||||||
if (lastOtherFormat && !isSeperatorChar(*formatStr)) {
|
if (lastOtherFormat && !isSeperatorChar(*formatStr)) {
|
||||||
// expanding
|
// expanding
|
||||||
|
@ -1304,8 +1324,8 @@ static void parseTsFormat(const char* formatStr, SArray* formats) {
|
||||||
formatStr++;
|
formatStr++;
|
||||||
} else {
|
} else {
|
||||||
TSFormatNode format = {
|
TSFormatNode format = {
|
||||||
.type = isSeperatorChar(*formatStr) ? TS_FORMAT_NODE_TYPE_SEPARATOR : TS_FORMAT_NODE_TYPE_CHAR,
|
.type = isSeperatorChar(*formatStr) ? TS_FORMAT_NODE_TYPE_SEPARATOR : TS_FORMAT_NODE_TYPE_CHAR,
|
||||||
.key = NULL};
|
.key = NULL};
|
||||||
format.c = formatStr;
|
format.c = formatStr;
|
||||||
format.len = 1;
|
format.len = 1;
|
||||||
taosArrayPush(formats, &format);
|
taosArrayPush(formats, &format);
|
||||||
|
@ -1318,7 +1338,7 @@ static void parseTsFormat(const char* formatStr, SArray* formats) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tm2char(const SArray* formats, const struct STm* tm, char* s, int32_t outLen) {
|
static int32_t tm2char(const SArray* formats, const struct STm* tm, char* s, int32_t outLen) {
|
||||||
int32_t size = taosArrayGetSize(formats);
|
int32_t size = taosArrayGetSize(formats);
|
||||||
const char* start = s;
|
const char* start = s;
|
||||||
for (int32_t i = 0; i < size; ++i) {
|
for (int32_t i = 0; i < size; ++i) {
|
||||||
TSFormatNode* format = taosArrayGet(formats, i);
|
TSFormatNode* format = taosArrayGet(formats, i);
|
||||||
|
@ -1923,8 +1943,8 @@ int32_t taosTs2Char(const char* format, SArray** formats, int64_t ts, int32_t pr
|
||||||
return tm2char(*formats, &tm, out, outLen);
|
return tm2char(*formats, &tm, out, outLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t taosChar2Ts(const char* format, SArray** formats, const char* tsStr, int64_t* ts, int32_t precision, char* errMsg,
|
int32_t taosChar2Ts(const char* format, SArray** formats, const char* tsStr, int64_t* ts, int32_t precision,
|
||||||
int32_t errMsgLen) {
|
char* errMsg, int32_t errMsgLen) {
|
||||||
const char* sErrPos;
|
const char* sErrPos;
|
||||||
int32_t fErrIdx;
|
int32_t fErrIdx;
|
||||||
if (!*formats) {
|
if (!*formats) {
|
||||||
|
@ -1977,26 +1997,27 @@ static int8_t UNIT_INDEX[26] = {/*a*/ 2, 0, -1, 6, -1, -1, -1,
|
||||||
|
|
||||||
#define GET_UNIT_INDEX(idx) UNIT_INDEX[(idx) - 97]
|
#define GET_UNIT_INDEX(idx) UNIT_INDEX[(idx) - 97]
|
||||||
|
|
||||||
static int64_t UNIT_MATRIX[10][11] = { /* ns, us, ms, s, min, h, d, w, month, y*/
|
static int64_t UNIT_MATRIX[10][11] = {/* ns, us, ms, s, min, h, d, w, month, y*/
|
||||||
/*ns*/ { 1, 1000, 0},
|
/*ns*/ {1, 1000, 0},
|
||||||
/*us*/ {1000, 1, 1000, 0},
|
/*us*/ {1000, 1, 1000, 0},
|
||||||
/*ms*/ { 0, 1000, 1, 1000, 0},
|
/*ms*/ {0, 1000, 1, 1000, 0},
|
||||||
/*s*/ { 0, 0, 1000, 1, 60, 0},
|
/*s*/ {0, 0, 1000, 1, 60, 0},
|
||||||
/*min*/ { 0, 0, 0, 60, 1, 60, 0},
|
/*min*/ {0, 0, 0, 60, 1, 60, 0},
|
||||||
/*h*/ { 0, 0, 0, 0, 60, 1, 1, 0},
|
/*h*/ {0, 0, 0, 0, 60, 1, 1, 0},
|
||||||
/*d*/ { 0, 0, 0, 0, 0, 24, 1, 7, 1, 0},
|
/*d*/ {0, 0, 0, 0, 0, 24, 1, 7, 1, 0},
|
||||||
/*w*/ { 0, 0, 0, 0, 0, 0, 7, 1, -1, 0},
|
/*w*/ {0, 0, 0, 0, 0, 0, 7, 1, -1, 0},
|
||||||
/*mon*/ { 0, 0, 0, 0, 0, 0, 0, 0, 1, 12, 0},
|
/*mon*/ {0, 0, 0, 0, 0, 0, 0, 0, 1, 12, 0},
|
||||||
/*y*/ { 0, 0, 0, 0, 0, 0, 0, 0, 12, 1, 0}};
|
/*y*/ {0, 0, 0, 0, 0, 0, 0, 0, 12, 1, 0}};
|
||||||
|
|
||||||
static bool recursiveTsmaCheckRecursive(int64_t baseInterval, int8_t baseIdx, int64_t interval, int8_t idx, bool checkEq) {
|
static bool recursiveTsmaCheckRecursive(int64_t baseInterval, int8_t baseIdx, int64_t interval, int8_t idx,
|
||||||
|
bool checkEq) {
|
||||||
if (UNIT_MATRIX[baseIdx][idx] == -1) return false;
|
if (UNIT_MATRIX[baseIdx][idx] == -1) return false;
|
||||||
if (baseIdx == idx) {
|
if (baseIdx == idx) {
|
||||||
if (interval < baseInterval) return false;
|
if (interval < baseInterval) return false;
|
||||||
if (checkEq && interval == baseInterval) return false;
|
if (checkEq && interval == baseInterval) return false;
|
||||||
return interval % baseInterval == 0;
|
return interval % baseInterval == 0;
|
||||||
}
|
}
|
||||||
int8_t next = baseIdx + 1;
|
int8_t next = baseIdx + 1;
|
||||||
int64_t val = UNIT_MATRIX[baseIdx][next];
|
int64_t val = UNIT_MATRIX[baseIdx][next];
|
||||||
while (val != 0 && next <= idx) {
|
while (val != 0 && next <= idx) {
|
||||||
if (val == -1) {
|
if (val == -1) {
|
||||||
|
@ -2006,7 +2027,7 @@ static bool recursiveTsmaCheckRecursive(int64_t baseInterval, int8_t baseIdx, in
|
||||||
}
|
}
|
||||||
if (val % baseInterval == 0 || baseInterval % val == 0) {
|
if (val % baseInterval == 0 || baseInterval % val == 0) {
|
||||||
int8_t extra = baseInterval >= val ? 0 : 1;
|
int8_t extra = baseInterval >= val ? 0 : 1;
|
||||||
bool needCheckEq = baseInterval >= val && !(baseIdx < next && val == 1);
|
bool needCheckEq = baseInterval >= val && !(baseIdx < next && val == 1);
|
||||||
if (!recursiveTsmaCheckRecursive(baseInterval / val + extra, next, interval, idx, needCheckEq && checkEq)) {
|
if (!recursiveTsmaCheckRecursive(baseInterval / val + extra, next, interval, idx, needCheckEq && checkEq)) {
|
||||||
next++;
|
next++;
|
||||||
val = UNIT_MATRIX[baseIdx][next];
|
val = UNIT_MATRIX[baseIdx][next];
|
||||||
|
@ -2021,7 +2042,8 @@ static bool recursiveTsmaCheckRecursive(int64_t baseInterval, int8_t baseIdx, in
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool recursiveTsmaCheckRecursiveReverse(int64_t baseInterval, int8_t baseIdx, int64_t interval, int8_t idx, bool checkEq) {
|
static bool recursiveTsmaCheckRecursiveReverse(int64_t baseInterval, int8_t baseIdx, int64_t interval, int8_t idx,
|
||||||
|
bool checkEq) {
|
||||||
if (UNIT_MATRIX[baseIdx][idx] == -1) return false;
|
if (UNIT_MATRIX[baseIdx][idx] == -1) return false;
|
||||||
|
|
||||||
if (baseIdx == idx) {
|
if (baseIdx == idx) {
|
||||||
|
@ -2030,7 +2052,7 @@ static bool recursiveTsmaCheckRecursiveReverse(int64_t baseInterval, int8_t base
|
||||||
return interval % baseInterval == 0;
|
return interval % baseInterval == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t next = baseIdx - 1;
|
int8_t next = baseIdx - 1;
|
||||||
int64_t val = UNIT_MATRIX[baseIdx][next];
|
int64_t val = UNIT_MATRIX[baseIdx][next];
|
||||||
while (val != 0 && next >= 0) {
|
while (val != 0 && next >= 0) {
|
||||||
return recursiveTsmaCheckRecursiveReverse(baseInterval * val, next, interval, idx, checkEq);
|
return recursiveTsmaCheckRecursiveReverse(baseInterval * val, next, interval, idx, checkEq);
|
||||||
|
@ -2041,18 +2063,27 @@ static bool recursiveTsmaCheckRecursiveReverse(int64_t baseInterval, int8_t base
|
||||||
/*
|
/*
|
||||||
* @breif check if tsma with param [interval], [unit] can create based on base tsma with baseInterval and baseUnit
|
* @breif check if tsma with param [interval], [unit] can create based on base tsma with baseInterval and baseUnit
|
||||||
* @param baseInterval, baseUnit, interval/unit of base tsma
|
* @param baseInterval, baseUnit, interval/unit of base tsma
|
||||||
* @param interval the tsma interval going to create. Not that if unit is not calander unit, then interval has already been
|
* @param interval the tsma interval going to create. Not that if unit is not calander unit, then interval has already
|
||||||
* translated to TICKS of [precision]
|
* been translated to TICKS of [precision]
|
||||||
* @param unit the tsma unit going to create
|
* @param unit the tsma unit going to create
|
||||||
* @param precision the precision of this db
|
* @param precision the precision of this db
|
||||||
* @param checkEq pass true if same interval is not acceptable, false if acceptable.
|
* @param checkEq pass true if same interval is not acceptable, false if acceptable.
|
||||||
* @ret true the tsma can be created, else cannot
|
* @ret true the tsma can be created, else cannot
|
||||||
* */
|
* */
|
||||||
bool checkRecursiveTsmaInterval(int64_t baseInterval, int8_t baseUnit, int64_t interval, int8_t unit, int8_t precision, bool checkEq) {
|
bool checkRecursiveTsmaInterval(int64_t baseInterval, int8_t baseUnit, int64_t interval, int8_t unit, int8_t precision,
|
||||||
|
bool checkEq) {
|
||||||
bool baseIsCalendarDuration = IS_CALENDAR_TIME_DURATION(baseUnit);
|
bool baseIsCalendarDuration = IS_CALENDAR_TIME_DURATION(baseUnit);
|
||||||
if (!baseIsCalendarDuration) baseInterval = convertTimeFromPrecisionToUnit(baseInterval, precision, baseUnit);
|
if (!baseIsCalendarDuration) {
|
||||||
|
if (TSDB_CODE_SUCCESS != convertTimeFromPrecisionToUnit(baseInterval, precision, baseUnit, &baseInterval)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
bool isCalendarDuration = IS_CALENDAR_TIME_DURATION(unit);
|
bool isCalendarDuration = IS_CALENDAR_TIME_DURATION(unit);
|
||||||
if (!isCalendarDuration) interval = convertTimeFromPrecisionToUnit(interval, precision, unit);
|
if (!isCalendarDuration) {
|
||||||
|
if (TSDB_CODE_SUCCESS != convertTimeFromPrecisionToUnit(interval, precision, unit, &interval)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool needCheckEq = baseIsCalendarDuration == isCalendarDuration && checkEq;
|
bool needCheckEq = baseIsCalendarDuration == isCalendarDuration && checkEq;
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ int32_t mndInitSma(SMnode *pMnode) {
|
||||||
|
|
||||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_INDEX, mndRetrieveIdx);
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_INDEX, mndRetrieveIdx);
|
||||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_INDEX, mndCancelRetrieveIdx);
|
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_INDEX, mndCancelRetrieveIdx);
|
||||||
|
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_TSMA, mndProcessCreateTSMAReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_TSMA, mndProcessCreateTSMAReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_DROP_TSMA, mndProcessDropTSMAReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_DROP_TSMA, mndProcessDropTSMAReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_GET_TABLE_TSMA, mndProcessGetTbTSMAReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_GET_TABLE_TSMA, mndProcessGetTbTSMAReq);
|
||||||
|
@ -616,7 +616,12 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
|
||||||
|
|
||||||
// check the maxDelay
|
// check the maxDelay
|
||||||
if (streamObj.conf.triggerParam < TSDB_MIN_ROLLUP_MAX_DELAY) {
|
if (streamObj.conf.triggerParam < TSDB_MIN_ROLLUP_MAX_DELAY) {
|
||||||
int64_t msInterval = convertTimeFromPrecisionToUnit(pCreate->interval, pDb->cfg.precision, TIME_UNIT_MILLISECOND);
|
int64_t msInterval = -1;
|
||||||
|
int32_t code = convertTimeFromPrecisionToUnit(pCreate->interval, pDb->cfg.precision, TIME_UNIT_MILLISECOND, &msInterval);
|
||||||
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
mError("sma:%s, failed to create since convert time failed: %s", smaObj.name, tstrerror(code));
|
||||||
|
return code;
|
||||||
|
}
|
||||||
streamObj.conf.triggerParam = msInterval > TSDB_MIN_ROLLUP_MAX_DELAY ? msInterval : TSDB_MIN_ROLLUP_MAX_DELAY;
|
streamObj.conf.triggerParam = msInterval > TSDB_MIN_ROLLUP_MAX_DELAY ? msInterval : TSDB_MIN_ROLLUP_MAX_DELAY;
|
||||||
}
|
}
|
||||||
if (streamObj.conf.triggerParam > TSDB_MAX_ROLLUP_MAX_DELAY) {
|
if (streamObj.conf.triggerParam > TSDB_MAX_ROLLUP_MAX_DELAY) {
|
||||||
|
|
|
@ -23,7 +23,9 @@ static int32_t rsmaRestore(SSma *pSma);
|
||||||
#define SMA_SET_KEEP_CFG(v, l) \
|
#define SMA_SET_KEEP_CFG(v, l) \
|
||||||
do { \
|
do { \
|
||||||
SRetention *r = &pCfg->retentions[l]; \
|
SRetention *r = &pCfg->retentions[l]; \
|
||||||
pKeepCfg->keep2 = convertTimeFromPrecisionToUnit(r->keep, pCfg->precision, TIME_UNIT_MINUTE); \
|
int64_t keep = -1; \
|
||||||
|
convertTimeFromPrecisionToUnit(r->keep, pCfg->precision, TIME_UNIT_MINUTE, &keep); \
|
||||||
|
pKeepCfg->keep2 = (int32_t)keep; \
|
||||||
pKeepCfg->keep0 = pKeepCfg->keep2; \
|
pKeepCfg->keep0 = pKeepCfg->keep2; \
|
||||||
pKeepCfg->keep1 = pKeepCfg->keep2; \
|
pKeepCfg->keep1 = pKeepCfg->keep2; \
|
||||||
pKeepCfg->days = smaEvalDays(v, pCfg->retentions, l, pCfg->precision, pCfg->days); \
|
pKeepCfg->days = smaEvalDays(v, pCfg->retentions, l, pCfg->precision, pCfg->days); \
|
||||||
|
@ -60,8 +62,12 @@ static int32_t rsmaRestore(SSma *pSma);
|
||||||
* @return int32_t
|
* @return int32_t
|
||||||
*/
|
*/
|
||||||
static int32_t smaEvalDays(SVnode *pVnode, SRetention *r, int8_t level, int8_t precision, int32_t duration) {
|
static int32_t smaEvalDays(SVnode *pVnode, SRetention *r, int8_t level, int8_t precision, int32_t duration) {
|
||||||
int32_t freqDuration = convertTimeFromPrecisionToUnit((r + TSDB_RETENTION_L0)->freq, precision, TIME_UNIT_MINUTE);
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
int32_t keepDuration = convertTimeFromPrecisionToUnit((r + TSDB_RETENTION_L0)->keep, precision, TIME_UNIT_MINUTE);
|
|
||||||
|
int64_t freqDuration = -1;
|
||||||
|
int64_t keepDuration = -1;
|
||||||
|
code = convertTimeFromPrecisionToUnit((r + TSDB_RETENTION_L0)->freq, precision, TIME_UNIT_MINUTE, &freqDuration);
|
||||||
|
code = convertTimeFromPrecisionToUnit((r + TSDB_RETENTION_L0)->keep, precision, TIME_UNIT_MINUTE, &keepDuration);
|
||||||
int32_t days = duration; // min
|
int32_t days = duration; // min
|
||||||
|
|
||||||
if (days < freqDuration) {
|
if (days < freqDuration) {
|
||||||
|
@ -76,8 +82,8 @@ static int32_t smaEvalDays(SVnode *pVnode, SRetention *r, int8_t level, int8_t p
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
freqDuration = convertTimeFromPrecisionToUnit((r + level)->freq, precision, TIME_UNIT_MINUTE);
|
code = convertTimeFromPrecisionToUnit((r + level)->freq, precision, TIME_UNIT_MINUTE, &freqDuration);
|
||||||
keepDuration = convertTimeFromPrecisionToUnit((r + level)->keep, precision, TIME_UNIT_MINUTE);
|
code = convertTimeFromPrecisionToUnit((r + level)->keep, precision, TIME_UNIT_MINUTE, &keepDuration);
|
||||||
|
|
||||||
int32_t nFreqTimes = (r + level)->freq / (60 * 1000); // use 60s for freq of 1st level
|
int32_t nFreqTimes = (r + level)->freq / (60 * 1000); // use 60s for freq of 1st level
|
||||||
days *= (nFreqTimes > 1 ? nFreqTimes : 1);
|
days *= (nFreqTimes > 1 ? nFreqTimes : 1);
|
||||||
|
|
|
@ -335,8 +335,9 @@ static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat
|
||||||
}
|
}
|
||||||
|
|
||||||
if (param->maxdelay[idx] < TSDB_MIN_ROLLUP_MAX_DELAY) {
|
if (param->maxdelay[idx] < TSDB_MIN_ROLLUP_MAX_DELAY) {
|
||||||
int64_t msInterval =
|
int64_t msInterval = -1;
|
||||||
convertTimeFromPrecisionToUnit(pRetention[idx + 1].freq, pTsdbCfg->precision, TIME_UNIT_MILLISECOND);
|
TAOS_CHECK_RETURN(convertTimeFromPrecisionToUnit(pRetention[idx + 1].freq, pTsdbCfg->precision,
|
||||||
|
TIME_UNIT_MILLISECOND, &msInterval));
|
||||||
pItem->maxDelay = (int32_t)msInterval;
|
pItem->maxDelay = (int32_t)msInterval;
|
||||||
} else {
|
} else {
|
||||||
pItem->maxDelay = (int32_t)param->maxdelay[idx];
|
pItem->maxDelay = (int32_t)param->maxdelay[idx];
|
||||||
|
|
|
@ -69,8 +69,9 @@ static int32_t tdProcessTSmaGetDaysImpl(SVnodeCfg *pCfg, void *pCont, uint32_t c
|
||||||
}
|
}
|
||||||
|
|
||||||
STsdbCfg *pTsdbCfg = &pCfg->tsdbCfg;
|
STsdbCfg *pTsdbCfg = &pCfg->tsdbCfg;
|
||||||
int64_t sInterval = convertTimeFromPrecisionToUnit(tsma.interval, pTsdbCfg->precision, TIME_UNIT_SECOND);
|
int64_t sInterval = -1;
|
||||||
if (sInterval <= 0) {
|
code = convertTimeFromPrecisionToUnit(tsma.interval, pTsdbCfg->precision, TIME_UNIT_SECOND, &sInterval);
|
||||||
|
if (TSDB_CODE_SUCCESS != code || 0 == sInterval) {
|
||||||
*days = pTsdbCfg->days;
|
*days = pTsdbCfg->days;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
@ -78,7 +79,11 @@ static int32_t tdProcessTSmaGetDaysImpl(SVnodeCfg *pCfg, void *pCont, uint32_t c
|
||||||
if (records >= SMA_STORAGE_SPLIT_FACTOR) {
|
if (records >= SMA_STORAGE_SPLIT_FACTOR) {
|
||||||
*days = pTsdbCfg->days;
|
*days = pTsdbCfg->days;
|
||||||
} else {
|
} else {
|
||||||
int64_t mInterval = convertTimeFromPrecisionToUnit(tsma.interval, pTsdbCfg->precision, TIME_UNIT_MINUTE);
|
int64_t mInterval = -1;
|
||||||
|
code = convertTimeFromPrecisionToUnit(tsma.interval, pTsdbCfg->precision, TIME_UNIT_MINUTE, &mInterval);
|
||||||
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
int64_t daysPerFile = mInterval * SMA_STORAGE_MINUTES_DAY * 2;
|
int64_t daysPerFile = mInterval * SMA_STORAGE_MINUTES_DAY * 2;
|
||||||
|
|
||||||
if (daysPerFile > SMA_STORAGE_MINUTES_MAX) {
|
if (daysPerFile > SMA_STORAGE_MINUTES_MAX) {
|
||||||
|
|
|
@ -176,7 +176,14 @@ typedef struct SExplainCtx {
|
||||||
#define EXPLAIN_JOIN_STRING(_type) ((JOIN_TYPE_INNER == _type) ? "Inner join" : "Join")
|
#define EXPLAIN_JOIN_STRING(_type) ((JOIN_TYPE_INNER == _type) ? "Inner join" : "Join")
|
||||||
#define EXPLAIN_MERGE_MODE_STRING(_mode) ((_mode) == MERGE_TYPE_SORT ? "sort" : ((_mode) == MERGE_TYPE_NON_SORT ? "merge" : "column"))
|
#define EXPLAIN_MERGE_MODE_STRING(_mode) ((_mode) == MERGE_TYPE_SORT ? "sort" : ((_mode) == MERGE_TYPE_NON_SORT ? "merge" : "column"))
|
||||||
|
|
||||||
#define INVERAL_TIME_FROM_PRECISION_TO_UNIT(_t, _u, _p) (((_u) == 'n' || (_u) == 'y') ? (_t) : (convertTimeFromPrecisionToUnit(_t, _p, _u)))
|
#define INVERAL_TIME_FROM_PRECISION_TO_UNIT(_t, _u, _p, _r) \
|
||||||
|
do { \
|
||||||
|
if ((_u) == 'n' || (_u) == 'y') { \
|
||||||
|
_r = (_t); \
|
||||||
|
} else { \
|
||||||
|
code = convertTimeFromPrecisionToUnit(_t, _p, _u, &_r); \
|
||||||
|
} \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
#define EXPLAIN_ROW_NEW(level, ...) \
|
#define EXPLAIN_ROW_NEW(level, ...) \
|
||||||
do { \
|
do { \
|
||||||
|
|
|
@ -55,7 +55,7 @@ char* qExplainGetAsofOpStr(int32_t opType) {
|
||||||
case OP_TYPE_LOWER_EQUAL:
|
case OP_TYPE_LOWER_EQUAL:
|
||||||
return "<=";
|
return "<=";
|
||||||
case OP_TYPE_EQUAL:
|
case OP_TYPE_EQUAL:
|
||||||
return "=";
|
return "=";
|
||||||
default:
|
default:
|
||||||
return "UNKNOWN";
|
return "UNKNOWN";
|
||||||
}
|
}
|
||||||
|
@ -192,13 +192,13 @@ int32_t qExplainGenerateResNodeExecInfo(SPhysiNode *pNode, SArray **pExecInfo, S
|
||||||
if (0 == group->physiPlanExecIdx) {
|
if (0 == group->physiPlanExecIdx) {
|
||||||
group->nodeIdx = 0;
|
group->nodeIdx = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
rsp = taosArrayGet(group->nodeExecInfo, group->nodeIdx++);
|
rsp = taosArrayGet(group->nodeExecInfo, group->nodeIdx++);
|
||||||
if (group->physiPlanExecIdx >= rsp->numOfPlans) {
|
if (group->physiPlanExecIdx >= rsp->numOfPlans) {
|
||||||
qError("physiPlanIdx %d exceed plan num %d", group->physiPlanExecIdx, rsp->numOfPlans);
|
qError("physiPlanIdx %d exceed plan num %d", group->physiPlanExecIdx, rsp->numOfPlans);
|
||||||
return TSDB_CODE_APP_ERROR;
|
return TSDB_CODE_APP_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(taosArrayPush(*pExecInfo, rsp->subplanInfo + group->physiPlanExecIdx) == NULL) return terrno;
|
if(taosArrayPush(*pExecInfo, rsp->subplanInfo + group->physiPlanExecIdx) == NULL) return terrno;
|
||||||
} else {
|
} else {
|
||||||
for (int32_t i = 0; i < group->nodeNum; ++i) {
|
for (int32_t i = 0; i < group->nodeNum; ++i) {
|
||||||
|
@ -338,7 +338,7 @@ static char* qExplainGetScanMode(STableScanPhysiNode* pScan) {
|
||||||
isGroupByTag = (NULL != pScan->pGroupTags) && !isGroupByTbname;
|
isGroupByTag = (NULL != pScan->pGroupTags) && !isGroupByTbname;
|
||||||
if ((((!isGroupByTag) || isGroupByTbname) && pScan->groupSort) || (isGroupByTag && (pScan->groupSort || pScan->scan.groupOrderScan))) {
|
if ((((!isGroupByTag) || isGroupByTbname) && pScan->groupSort) || (isGroupByTag && (pScan->groupSort || pScan->scan.groupOrderScan))) {
|
||||||
return "seq_grp_order";
|
return "seq_grp_order";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((isGroupByTbname && (pScan->groupSort || pScan->scan.groupOrderScan)) || (isGroupByTag && (pScan->groupSort || pScan->scan.groupOrderScan))) {
|
if ((isGroupByTbname && (pScan->groupSort || pScan->scan.groupOrderScan)) || (isGroupByTag && (pScan->groupSort || pScan->scan.groupOrderScan))) {
|
||||||
return "grp_order";
|
return "grp_order";
|
||||||
|
@ -416,7 +416,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -581,7 +581,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -621,7 +621,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
|
|
||||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_MERGEBLOCKS_FORMAT, pPrjNode->mergeDataBlock? "True":"False");
|
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_MERGEBLOCKS_FORMAT, pPrjNode->mergeDataBlock? "True":"False");
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
|
|
||||||
if (pPrjNode->node.pConditions) {
|
if (pPrjNode->node.pConditions) {
|
||||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT);
|
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT);
|
||||||
|
@ -629,7 +629,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -689,7 +689,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_GRP_JOIN_FORMAT, pJoinNode->grpJoin);
|
EXPLAIN_ROW_APPEND(EXPLAIN_GRP_JOIN_FORMAT, pJoinNode->grpJoin);
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT);
|
EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT);
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
|
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -705,7 +705,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_PRIM_CONDITIONS_FORMAT);
|
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_PRIM_CONDITIONS_FORMAT);
|
||||||
QRY_ERR_RET(nodesNodeToSQL(pJoinNode->pPrimKeyCond, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
QRY_ERR_RET(nodesNodeToSQL(pJoinNode->pPrimKeyCond, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL != pJoinNode->pEqLeft && pJoinNode->pEqLeft->length > 0) {
|
if (NULL != pJoinNode->pEqLeft && pJoinNode->pEqLeft->length > 0) {
|
||||||
|
@ -733,7 +733,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
QRY_ERR_RET(
|
QRY_ERR_RET(
|
||||||
nodesNodeToSQL(pJoinNode->pFullOnCond, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
nodesNodeToSQL(pJoinNode->pFullOnCond, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL != pJoinNode->pColOnCond) {
|
if (NULL != pJoinNode->pColOnCond) {
|
||||||
|
@ -741,7 +741,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
QRY_ERR_RET(
|
QRY_ERR_RET(
|
||||||
nodesNodeToSQL(pJoinNode->pColOnCond, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
nodesNodeToSQL(pJoinNode->pColOnCond, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -831,7 +831,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -844,7 +844,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
qError("exchange src group %d not in groupHash", pExchNode->srcStartGroupId);
|
qError("exchange src group %d not in groupHash", pExchNode->srcStartGroupId);
|
||||||
QRY_ERR_RET(TSDB_CODE_APP_ERROR);
|
QRY_ERR_RET(TSDB_CODE_APP_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeNum += group->nodeNum;
|
nodeNum += group->nodeNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -876,7 +876,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = pExchNode->srcStartGroupId; i <= pExchNode->srcEndGroupId; ++i) {
|
for (int32_t i = pExchNode->srcStartGroupId; i <= pExchNode->srcEndGroupId; ++i) {
|
||||||
|
@ -956,7 +956,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -991,10 +991,17 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
uint8_t precision = qExplainGetIntervalPrecision(pIntNode);
|
uint8_t precision = qExplainGetIntervalPrecision(pIntNode);
|
||||||
|
int64_t time1 = -1;
|
||||||
|
int64_t time2 = -1;
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
INVERAL_TIME_FROM_PRECISION_TO_UNIT(pIntNode->interval, pIntNode->intervalUnit, precision, time1);
|
||||||
|
QRY_ERR_RET(code);
|
||||||
|
INVERAL_TIME_FROM_PRECISION_TO_UNIT(pIntNode->sliding, pIntNode->slidingUnit, precision, time2);
|
||||||
|
QRY_ERR_RET(code);
|
||||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_TIME_WINDOWS_FORMAT,
|
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_TIME_WINDOWS_FORMAT,
|
||||||
INVERAL_TIME_FROM_PRECISION_TO_UNIT(pIntNode->interval, pIntNode->intervalUnit, precision),
|
time1,
|
||||||
pIntNode->intervalUnit, pIntNode->offset, getPrecisionUnit(precision),
|
pIntNode->intervalUnit, pIntNode->offset, getPrecisionUnit(precision),
|
||||||
INVERAL_TIME_FROM_PRECISION_TO_UNIT(pIntNode->sliding, pIntNode->slidingUnit, precision),
|
time2,
|
||||||
pIntNode->slidingUnit);
|
pIntNode->slidingUnit);
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
|
@ -1043,10 +1050,17 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
uint8_t precision = qExplainGetIntervalPrecision(pIntNode);
|
uint8_t precision = qExplainGetIntervalPrecision(pIntNode);
|
||||||
|
int64_t time1 = -1;
|
||||||
|
int64_t time2 = -1;
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
INVERAL_TIME_FROM_PRECISION_TO_UNIT(pIntNode->interval, pIntNode->intervalUnit, precision, time1);
|
||||||
|
QRY_ERR_RET(code);
|
||||||
|
INVERAL_TIME_FROM_PRECISION_TO_UNIT(pIntNode->sliding, pIntNode->slidingUnit, precision, time2);
|
||||||
|
QRY_ERR_RET(code);
|
||||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_TIME_WINDOWS_FORMAT,
|
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_TIME_WINDOWS_FORMAT,
|
||||||
INVERAL_TIME_FROM_PRECISION_TO_UNIT(pIntNode->interval, pIntNode->intervalUnit, precision),
|
time1,
|
||||||
pIntNode->intervalUnit, pIntNode->offset, getPrecisionUnit(precision),
|
pIntNode->intervalUnit, pIntNode->offset, getPrecisionUnit(precision),
|
||||||
INVERAL_TIME_FROM_PRECISION_TO_UNIT(pIntNode->sliding, pIntNode->slidingUnit, precision),
|
time2,
|
||||||
pIntNode->slidingUnit);
|
pIntNode->slidingUnit);
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
|
@ -1123,7 +1137,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1163,7 +1177,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1205,7 +1219,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1247,7 +1261,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1340,7 +1354,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1381,7 +1395,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1422,7 +1436,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1464,7 +1478,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1535,7 +1549,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1563,10 +1577,17 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
uint8_t precision = qExplainGetIntervalPrecision(pIntNode);
|
uint8_t precision = qExplainGetIntervalPrecision(pIntNode);
|
||||||
|
int64_t time1 = -1;
|
||||||
|
int64_t time2 = -1;
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
INVERAL_TIME_FROM_PRECISION_TO_UNIT(pIntNode->interval, pIntNode->intervalUnit, precision, time1);
|
||||||
|
QRY_ERR_RET(code);
|
||||||
|
INVERAL_TIME_FROM_PRECISION_TO_UNIT(pIntNode->sliding, pIntNode->slidingUnit, precision, time2);
|
||||||
|
QRY_ERR_RET(code);
|
||||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_TIME_WINDOWS_FORMAT,
|
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_TIME_WINDOWS_FORMAT,
|
||||||
INVERAL_TIME_FROM_PRECISION_TO_UNIT(pIntNode->interval, pIntNode->intervalUnit, precision),
|
time1,
|
||||||
pIntNode->intervalUnit, pIntNode->offset, getPrecisionUnit(precision),
|
pIntNode->intervalUnit, pIntNode->offset, getPrecisionUnit(precision),
|
||||||
INVERAL_TIME_FROM_PRECISION_TO_UNIT(pIntNode->sliding, pIntNode->slidingUnit, precision),
|
time2,
|
||||||
pIntNode->slidingUnit);
|
pIntNode->slidingUnit);
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
|
@ -1577,7 +1598,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1644,7 +1665,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1669,7 +1690,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
|
|
||||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_EVENT_END_FORMAT);
|
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_EVENT_END_FORMAT);
|
||||||
QRY_ERR_RET(nodesNodeToSQL(pEventNode->pEndCond, tbuf + VARSTR_HEADER_SIZE,
|
QRY_ERR_RET(nodesNodeToSQL(pEventNode->pEndCond, tbuf + VARSTR_HEADER_SIZE,
|
||||||
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
||||||
|
@ -1722,7 +1743,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
if (pJoinNode->pPrimKeyCond) {
|
if (pJoinNode->pPrimKeyCond) {
|
||||||
QRY_ERR_RET(
|
QRY_ERR_RET(
|
||||||
nodesNodeToSQL(pJoinNode->pPrimKeyCond, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
nodesNodeToSQL(pJoinNode->pPrimKeyCond, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
||||||
conditionsGot = true;
|
conditionsGot = true;
|
||||||
}
|
}
|
||||||
if (pJoinNode->pColEqCond) {
|
if (pJoinNode->pColEqCond) {
|
||||||
if (conditionsGot) {
|
if (conditionsGot) {
|
||||||
|
@ -1730,7 +1751,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
}
|
}
|
||||||
QRY_ERR_RET(
|
QRY_ERR_RET(
|
||||||
nodesNodeToSQL(pJoinNode->pColEqCond, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
nodesNodeToSQL(pJoinNode->pColEqCond, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
||||||
conditionsGot = true;
|
conditionsGot = true;
|
||||||
}
|
}
|
||||||
if (pJoinNode->pTagEqCond) {
|
if (pJoinNode->pTagEqCond) {
|
||||||
if (conditionsGot) {
|
if (conditionsGot) {
|
||||||
|
@ -1738,7 +1759,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
}
|
}
|
||||||
QRY_ERR_RET(
|
QRY_ERR_RET(
|
||||||
nodesNodeToSQL(pJoinNode->pTagEqCond, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
nodesNodeToSQL(pJoinNode->pTagEqCond, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
||||||
conditionsGot = true;
|
conditionsGot = true;
|
||||||
}
|
}
|
||||||
if (pJoinNode->pFullOnCond) {
|
if (pJoinNode->pFullOnCond) {
|
||||||
if (conditionsGot) {
|
if (conditionsGot) {
|
||||||
|
@ -1746,14 +1767,14 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
}
|
}
|
||||||
QRY_ERR_RET(nodesNodeToSQL(pJoinNode->pFullOnCond, tbuf + VARSTR_HEADER_SIZE,
|
QRY_ERR_RET(nodesNodeToSQL(pJoinNode->pFullOnCond, tbuf + VARSTR_HEADER_SIZE,
|
||||||
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
||||||
}
|
}
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
|
|
||||||
if (pJoinNode->timeRangeTarget) {
|
if (pJoinNode->timeRangeTarget) {
|
||||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_TABLE_TIMERANGE_FORMAT, qExplainGetTimerangeTargetStr(pJoinNode->timeRangeTarget), pJoinNode->timeRange.skey, pJoinNode->timeRange.ekey);
|
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_TABLE_TIMERANGE_FORMAT, qExplainGetTimerangeTargetStr(pJoinNode->timeRangeTarget), pJoinNode->timeRange.skey, pJoinNode->timeRange.ekey);
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2124,7 +2145,7 @@ int32_t qExplainUpdateExecInfo(SExplainCtx *pCtx, SExplainRsp *pRspMsg, int32_t
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
TAOS_CHECK_ERRNO(code);
|
TAOS_CHECK_ERRNO(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
groupDone = (taosArrayGetSize(group->nodeExecInfo) >= group->nodeNum);
|
groupDone = (taosArrayGetSize(group->nodeExecInfo) >= group->nodeNum);
|
||||||
|
|
||||||
taosWUnLockLatch(&group->lock);
|
taosWUnLockLatch(&group->lock);
|
||||||
|
|
|
@ -180,7 +180,7 @@ int32_t executeGeomFromTextFunc(SColumnInfoData *pInputData, int32_t i, SColumnI
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
colDataSetVal(pOutputData, i, output, (output == NULL));
|
code = colDataSetVal(pOutputData, i, output, (output == NULL));
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (output) {
|
if (output) {
|
||||||
|
@ -200,7 +200,7 @@ int32_t executeAsTextFunc(SColumnInfoData *pInputData, int32_t i, SColumnInfoDat
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
colDataSetVal(pOutputData, i, output, (output == NULL));
|
code = colDataSetVal(pOutputData, i, output, (output == NULL));
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (output) {
|
if (output) {
|
||||||
|
@ -228,7 +228,7 @@ int32_t executeRelationFunc(const GEOSGeometry *geom1, const GEOSPreparedGeometr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
colDataSetVal(pOutputData, i, &res, (res==-1));
|
code = colDataSetVal(pOutputData, i, &res, (res==-1));
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,9 +86,9 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int initWktRegex(pcre2_code **ppRegex, pcre2_match_data **ppMatchData) {
|
static int32_t initWktRegex(pcre2_code **ppRegex, pcre2_match_data **ppMatchData) {
|
||||||
int ret = 0;
|
int32_t code = 0;
|
||||||
char *wktPatternWithSpace = taosMemoryCalloc(4, 1024);
|
char *wktPatternWithSpace = taosMemoryCalloc(4, 1024);
|
||||||
sprintf(
|
sprintf(
|
||||||
wktPatternWithSpace,
|
wktPatternWithSpace,
|
||||||
"^( *)point( *)z?m?( *)((empty)|(\\(( *)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?(( "
|
"^( *)point( *)z?m?( *)((empty)|(\\(( *)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?(( "
|
||||||
|
@ -142,9 +142,9 @@ static int initWktRegex(pcre2_code **ppRegex, pcre2_match_data **ppMatchData) {
|
||||||
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?){1,3}( *))*( *)\\)))( *))*( *)\\)))( *))*( "
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?){1,3}( *))*( *)\\)))( *))*( *)\\)))( *))*( "
|
||||||
"*)\\)))|(GEOCOLLECTION\\((?R)(( *)(,)( *)(?R))*( *)\\))( *)$");
|
"*)\\)))|(GEOCOLLECTION\\((?R)(( *)(,)( *)(?R))*( *)\\))( *)$");
|
||||||
|
|
||||||
ret = doRegComp(ppRegex, ppMatchData, wktPatternWithSpace);
|
code = doRegComp(ppRegex, ppMatchData, wktPatternWithSpace);
|
||||||
taosMemoryFree(wktPatternWithSpace);
|
taosMemoryFree(wktPatternWithSpace);
|
||||||
return ret;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t initCtxGeomFromText() {
|
int32_t initCtxGeomFromText() {
|
||||||
|
|
|
@ -1523,7 +1523,7 @@ static int32_t biMakeTbnameProjectAstNode(char* funcName, char* tableAlias, SNod
|
||||||
if (!multiResFunc) {
|
if (!multiResFunc) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
tstrncpy(multiResFunc->functionName, funcName, TSDB_FUNC_NAME_LEN);
|
tstrncpy(multiResFunc->functionName, funcName, TSDB_FUNC_NAME_LEN);
|
||||||
code = nodesListMakeStrictAppend(&multiResFunc->pParameterList, (SNode*)tbNameFunc);
|
code = nodesListMakeStrictAppend(&multiResFunc->pParameterList, (SNode*)tbNameFunc);
|
||||||
|
@ -5233,7 +5233,8 @@ static int32_t translateFill(STranslateContext* pCxt, SSelectStmt* pSelect, SInt
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t getMonthsFromTimeVal(int64_t val, int32_t fromPrecision, char unit) {
|
static int64_t getMonthsFromTimeVal(int64_t val, int32_t fromPrecision, char unit) {
|
||||||
int64_t days = convertTimeFromPrecisionToUnit(val, fromPrecision, 'd');
|
int64_t days = -1;
|
||||||
|
convertTimeFromPrecisionToUnit(val, fromPrecision, 'd', &days);
|
||||||
switch (unit) {
|
switch (unit) {
|
||||||
case 'b':
|
case 'b':
|
||||||
case 'u':
|
case 'u':
|
||||||
|
@ -8232,7 +8233,8 @@ static SNode* makeIntervalVal(SRetention* pRetension, int8_t precision) {
|
||||||
if (NULL == pVal) {
|
if (NULL == pVal) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
int64_t timeVal = convertTimeFromPrecisionToUnit(pRetension->freq, precision, pRetension->freqUnit);
|
int64_t timeVal = -1;
|
||||||
|
convertTimeFromPrecisionToUnit(pRetension->freq, precision, pRetension->freqUnit, &timeVal);
|
||||||
char buf[20] = {0};
|
char buf[20] = {0};
|
||||||
int32_t len = snprintf(buf, sizeof(buf), "%" PRId64 "%c", timeVal, pRetension->freqUnit);
|
int32_t len = snprintf(buf, sizeof(buf), "%" PRId64 "%c", timeVal, pRetension->freqUnit);
|
||||||
pVal->literal = strndup(buf, len);
|
pVal->literal = strndup(buf, len);
|
||||||
|
@ -8781,7 +8783,7 @@ static int32_t translateUseDatabase(STranslateContext* pCxt, SUseDatabaseStmt* p
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tNameExtractFullName(&name, usedbReq.db);
|
code = tNameExtractFullName(&name, usedbReq.db);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code)
|
if (TSDB_CODE_SUCCESS == code)
|
||||||
code = getDBVgVersion(pCxt, usedbReq.db, &usedbReq.vgVersion, &usedbReq.dbId, &usedbReq.numOfTable, &usedbReq.stateTs);
|
code = getDBVgVersion(pCxt, usedbReq.db, &usedbReq.vgVersion, &usedbReq.dbId, &usedbReq.numOfTable, &usedbReq.stateTs);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = buildCmdMsg(pCxt, TDMT_MND_USE_DB, (FSerializeFunc)tSerializeSUseDbReq, &usedbReq);
|
code = buildCmdMsg(pCxt, TDMT_MND_USE_DB, (FSerializeFunc)tSerializeSUseDbReq, &usedbReq);
|
||||||
|
|
|
@ -33,7 +33,7 @@ class TDTestCase:
|
||||||
self.testcasePath = os.path.split(__file__)[0]
|
self.testcasePath = os.path.split(__file__)[0]
|
||||||
self.testcaseFilename = os.path.split(__file__)[-1]
|
self.testcaseFilename = os.path.split(__file__)[-1]
|
||||||
os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename))
|
os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename))
|
||||||
|
|
||||||
self.db = "sel_null"
|
self.db = "sel_null"
|
||||||
|
|
||||||
def insert_data(self,database,vgroups):
|
def insert_data(self,database,vgroups):
|
||||||
|
@ -46,10 +46,10 @@ class TDTestCase:
|
||||||
|
|
||||||
for i in range(5):
|
for i in range(5):
|
||||||
tdSql.execute('''create table %s.stb0_%d using %s.stb0 tags(%d,'varchar%d',%d,%d, %d, %d,%d,'binary%d','nchar%d',%d,%d,%d ) ;'''%(database,i,database,i,i,i,i,i,i,i,i,i,i,i,i))
|
tdSql.execute('''create table %s.stb0_%d using %s.stb0 tags(%d,'varchar%d',%d,%d, %d, %d,%d,'binary%d','nchar%d',%d,%d,%d ) ;'''%(database,i,database,i,i,i,i,i,i,i,i,i,i,i,i))
|
||||||
|
|
||||||
# insert data
|
# insert data
|
||||||
for i in range(num_random):
|
for i in range(num_random):
|
||||||
for j in range(50):
|
for j in range(50):
|
||||||
tdSql.execute('''insert into %s.stb0_0 (ts , c1 , c0) values(now, %d, %d) ;''' % (database,j,j))
|
tdSql.execute('''insert into %s.stb0_0 (ts , c1 , c0) values(now, %d, %d) ;''' % (database,j,j))
|
||||||
tdSql.execute('''insert into %s.stb0_1 (ts , c1 , c0) values(now, %d, %d) ;''' % (database,j,j))
|
tdSql.execute('''insert into %s.stb0_1 (ts , c1 , c0) values(now, %d, %d) ;''' % (database,j,j))
|
||||||
tdSql.execute('''insert into %s.stb0_2 (ts , c1 , c0) values(now, %d, %d) ;''' % (database,j,j))
|
tdSql.execute('''insert into %s.stb0_2 (ts , c1 , c0) values(now, %d, %d) ;''' % (database,j,j))
|
||||||
|
@ -60,378 +60,378 @@ class TDTestCase:
|
||||||
tdSql.checkData(0,0,5*num_random*50)
|
tdSql.checkData(0,0,5*num_random*50)
|
||||||
tdSql.query("select count(*) from %s.stb0_0;"%database)
|
tdSql.query("select count(*) from %s.stb0_0;"%database)
|
||||||
tdSql.checkData(0,0,num_random*50)
|
tdSql.checkData(0,0,num_random*50)
|
||||||
|
|
||||||
def ts_3085(self,database):
|
def ts_3085(self,database):
|
||||||
sql = "select count(c0null) from(select * from %s.stb0 limit 20,4) "%(database)
|
sql = "select count(c0null) from(select * from %s.stb0 limit 20,4) "%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,0)
|
tdSql.checkData(0,0,0)
|
||||||
|
|
||||||
offset = random.randint(10,100)
|
offset = random.randint(10,100)
|
||||||
for i in range(offset):
|
for i in range(offset):
|
||||||
sql = "select count(c0null) from(select * from %s.stb0 limit %d,%d) "%(database,offset,i)
|
sql = "select count(c0null) from(select * from %s.stb0 limit %d,%d) "%(database,offset,i)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,0)
|
tdSql.checkData(0,0,0)
|
||||||
sql = "select count(c1null) from(select * from %s.stb0 limit %d,%d) "%(database,offset,i)
|
sql = "select count(c1null) from(select * from %s.stb0 limit %d,%d) "%(database,offset,i)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,0)
|
tdSql.checkData(0,0,0)
|
||||||
sql = "select count(c0) from(select * from %s.stb0 limit %d,%d) "%(database,offset,i)
|
sql = "select count(c0) from(select * from %s.stb0 limit %d,%d) "%(database,offset,i)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,i)
|
tdSql.checkData(0,0,i)
|
||||||
sql = "select count(c1) from(select * from %s.stb0 limit %d,%d) "%(database,offset,i)
|
sql = "select count(c1) from(select * from %s.stb0 limit %d,%d) "%(database,offset,i)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,i)
|
tdSql.checkData(0,0,i)
|
||||||
sql = "select count(t0) from(select * from %s.stb0 limit %d,%d) "%(database,offset,i)
|
sql = "select count(t0) from(select * from %s.stb0 limit %d,%d) "%(database,offset,i)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,i)
|
tdSql.checkData(0,0,i)
|
||||||
sql = "select count(t1) from(select * from %s.stb0 limit %d,%d) "%(database,offset,i)
|
sql = "select count(t1) from(select * from %s.stb0 limit %d,%d) "%(database,offset,i)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,i)
|
tdSql.checkData(0,0,i)
|
||||||
|
|
||||||
|
|
||||||
def ts_2974_max(self,database):
|
def ts_2974_max(self,database):
|
||||||
sql = "select max(c0) from %s.stb0 where ts<now;"%(database)
|
sql = "select max(c0) from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,49)
|
tdSql.checkData(0,0,49)
|
||||||
sql = "select max(c0),ts from %s.stb0 where ts<now;"%(database)
|
sql = "select max(c0),ts from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,49)
|
tdSql.checkData(0,0,49)
|
||||||
sql = "select max(c1) from %s.stb0 where ts<now;"%(database)
|
sql = "select max(c1) from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,49)
|
tdSql.checkData(0,0,49)
|
||||||
sql = "select max(c1),ts from %s.stb0 where ts<now;"%(database)
|
sql = "select max(c1),ts from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,49)
|
tdSql.checkData(0,0,49)
|
||||||
|
|
||||||
sql = "select max(c0null) from %s.stb0 where ts<now;"%(database)
|
sql = "select max(c0null) from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,"None")
|
tdSql.checkData(0,0,"None")
|
||||||
sql = "select max(c0null),ts from %s.stb0 where ts<now;"%(database)
|
sql = "select max(c0null),ts from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,"None")
|
tdSql.checkData(0,0,"None")
|
||||||
sql = "select max(c1null) from %s.stb0 where ts<now;"%(database)
|
sql = "select max(c1null) from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,"None")
|
tdSql.checkData(0,0,"None")
|
||||||
sql = "select max(c1null),ts from %s.stb0 where ts<now;"%(database)
|
sql = "select max(c1null),ts from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,"None")
|
tdSql.checkData(0,0,"None")
|
||||||
|
|
||||||
sql = "select max(t0) from %s.stb0 where ts<now;"%(database)
|
sql = "select max(t0) from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,4)
|
tdSql.checkData(0,0,4)
|
||||||
sql = "select max(t0),ts from %s.stb0 where ts<now;"%(database)
|
sql = "select max(t0),ts from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,4)
|
tdSql.checkData(0,0,4)
|
||||||
sql = "select max(t1) from %s.stb0 where ts<now;"%(database)
|
sql = "select max(t1) from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.error(sql)
|
tdSql.error(sql)
|
||||||
sql = "select max(t1),ts from %s.stb0 where ts<now;"%(database)
|
sql = "select max(t1),ts from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.error(sql)
|
tdSql.error(sql)
|
||||||
sql = "select max(t_bool) from %s.stb0 where ts<now;"%(database)
|
sql = "select max(t_bool) from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.error(sql)
|
tdSql.error(sql)
|
||||||
sql = "select max(t_bool),ts from %s.stb0 where ts<now;"%(database)
|
sql = "select max(t_bool),ts from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.error(sql)
|
tdSql.error(sql)
|
||||||
sql = "select max(t_binary) from %s.stb0 where ts<now;"%(database)
|
sql = "select max(t_binary) from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.error(sql)
|
tdSql.error(sql)
|
||||||
sql = "select max(t_binary),ts from %s.stb0 where ts<now;"%(database)
|
sql = "select max(t_binary),ts from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.error(sql)
|
tdSql.error(sql)
|
||||||
sql = "select max(t_nchar) from %s.stb0 where ts<now;"%(database)
|
sql = "select max(t_nchar) from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.error(sql)
|
tdSql.error(sql)
|
||||||
sql = "select max(t_nchar),ts from %s.stb0 where ts<now;"%(database)
|
sql = "select max(t_nchar),ts from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.error(sql)
|
tdSql.error(sql)
|
||||||
sql = "select max(t_int) from %s.stb0 where ts<now;"%(database)
|
sql = "select max(t_int) from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,4)
|
tdSql.checkData(0,0,4)
|
||||||
sql = "select max(t_int),ts from %s.stb0 where ts<now;"%(database)
|
sql = "select max(t_int),ts from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,4)
|
tdSql.checkData(0,0,4)
|
||||||
sql = "select max(t_int) from %s.stb0 where ts<now;"%(database)
|
sql = "select max(t_int) from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,4)
|
tdSql.checkData(0,0,4)
|
||||||
sql = "select max(t_int),ts from %s.stb0 where ts<now;"%(database)
|
sql = "select max(t_int),ts from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,4)
|
tdSql.checkData(0,0,4)
|
||||||
sql = "select max(t_int) from %s.stb0 where ts<now;"%(database)
|
sql = "select max(t_int) from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,4)
|
tdSql.checkData(0,0,4)
|
||||||
sql = "select max(t_int),ts from %s.stb0 where ts<now;"%(database)
|
sql = "select max(t_int),ts from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,4)
|
tdSql.checkData(0,0,4)
|
||||||
sql = "select max(t_bigint) from %s.stb0 where ts<now;"%(database)
|
sql = "select max(t_bigint) from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,4)
|
tdSql.checkData(0,0,4)
|
||||||
sql = "select max(t_bigint),ts from %s.stb0 where ts<now;"%(database)
|
sql = "select max(t_bigint),ts from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,4)
|
tdSql.checkData(0,0,4)
|
||||||
sql = "select max(t_smallint) from %s.stb0 where ts<now;"%(database)
|
sql = "select max(t_smallint) from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,4)
|
tdSql.checkData(0,0,4)
|
||||||
sql = "select max(t_smallint),ts from %s.stb0 where ts<now;"%(database)
|
sql = "select max(t_smallint),ts from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,4)
|
tdSql.checkData(0,0,4)
|
||||||
sql = "select max(t_tinyint) from %s.stb0 where ts<now;"%(database)
|
sql = "select max(t_tinyint) from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,4)
|
tdSql.checkData(0,0,4)
|
||||||
sql = "select max(t_tinyint),ts from %s.stb0 where ts<now;"%(database)
|
sql = "select max(t_tinyint),ts from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,4)
|
tdSql.checkData(0,0,4)
|
||||||
sql = "select max(t_float) from %s.stb0 where ts<now;"%(database)
|
sql = "select max(t_float) from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,4)
|
tdSql.checkData(0,0,4)
|
||||||
sql = "select max(t_float),ts from %s.stb0 where ts<now;"%(database)
|
sql = "select max(t_float),ts from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,4)
|
tdSql.checkData(0,0,4)
|
||||||
sql = "select max(t_double) from %s.stb0 where ts<now;"%(database)
|
sql = "select max(t_double) from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,4)
|
tdSql.checkData(0,0,4)
|
||||||
sql = "select max(t_double),ts from %s.stb0 where ts<now;"%(database)
|
sql = "select max(t_double),ts from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,4)
|
tdSql.checkData(0,0,4)
|
||||||
|
|
||||||
def ts_2974_min(self,database):
|
def ts_2974_min(self,database):
|
||||||
sql = "select min(c0) from %s.stb0 where ts<now;"%(database)
|
sql = "select min(c0) from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,0)
|
tdSql.checkData(0,0,0)
|
||||||
sql = "select min(c0),ts from %s.stb0 where ts<now;"%(database)
|
sql = "select min(c0),ts from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,0)
|
tdSql.checkData(0,0,0)
|
||||||
sql = "select min(c1) from %s.stb0 where ts<now;"%(database)
|
sql = "select min(c1) from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,0)
|
tdSql.checkData(0,0,0)
|
||||||
sql = "select min(c1),ts from %s.stb0 where ts<now;"%(database)
|
sql = "select min(c1),ts from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,0)
|
tdSql.checkData(0,0,0)
|
||||||
|
|
||||||
sql = "select min(c0null) from %s.stb0 where ts<now;"%(database)
|
sql = "select min(c0null) from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,"None")
|
tdSql.checkData(0,0,"None")
|
||||||
sql = "select min(c0null),ts from %s.stb0 where ts<now;"%(database)
|
sql = "select min(c0null),ts from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,"None")
|
tdSql.checkData(0,0,"None")
|
||||||
sql = "select min(c1null) from %s.stb0 where ts<now;"%(database)
|
sql = "select min(c1null) from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,"None")
|
tdSql.checkData(0,0,"None")
|
||||||
sql = "select min(c1null),ts from %s.stb0 where ts<now;"%(database)
|
sql = "select min(c1null),ts from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,"None")
|
tdSql.checkData(0,0,"None")
|
||||||
|
|
||||||
sql = "select min(t0) from %s.stb0 where ts<now;"%(database)
|
sql = "select min(t0) from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,0)
|
tdSql.checkData(0,0,0)
|
||||||
sql = "select min(t0),ts from %s.stb0 where ts<now;"%(database)
|
sql = "select min(t0),ts from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,0)
|
tdSql.checkData(0,0,0)
|
||||||
sql = "select min(t1) from %s.stb0 where ts<now;"%(database)
|
sql = "select min(t1) from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.error(sql)
|
tdSql.error(sql)
|
||||||
sql = "select min(t1),ts from %s.stb0 where ts<now;"%(database)
|
sql = "select min(t1),ts from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.error(sql)
|
tdSql.error(sql)
|
||||||
sql = "select min(t_bool) from %s.stb0 where ts<now;"%(database)
|
sql = "select min(t_bool) from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.error(sql)
|
tdSql.error(sql)
|
||||||
sql = "select min(t_bool),ts from %s.stb0 where ts<now;"%(database)
|
sql = "select min(t_bool),ts from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.error(sql)
|
tdSql.error(sql)
|
||||||
sql = "select min(t_binary) from %s.stb0 where ts<now;"%(database)
|
sql = "select min(t_binary) from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.error(sql)
|
tdSql.error(sql)
|
||||||
sql = "select min(t_binary),ts from %s.stb0 where ts<now;"%(database)
|
sql = "select min(t_binary),ts from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.error(sql)
|
tdSql.error(sql)
|
||||||
sql = "select min(t_nchar) from %s.stb0 where ts<now;"%(database)
|
sql = "select min(t_nchar) from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.error(sql)
|
tdSql.error(sql)
|
||||||
sql = "select min(t_nchar),ts from %s.stb0 where ts<now;"%(database)
|
sql = "select min(t_nchar),ts from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.error(sql)
|
tdSql.error(sql)
|
||||||
sql = "select min(t_int) from %s.stb0 where ts<now;"%(database)
|
sql = "select min(t_int) from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,0)
|
tdSql.checkData(0,0,0)
|
||||||
sql = "select min(t_int),ts from %s.stb0 where ts<now;"%(database)
|
sql = "select min(t_int),ts from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,0)
|
tdSql.checkData(0,0,0)
|
||||||
sql = "select min(t_int) from %s.stb0 where ts<now;"%(database)
|
sql = "select min(t_int) from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,0)
|
tdSql.checkData(0,0,0)
|
||||||
sql = "select min(t_int),ts from %s.stb0 where ts<now;"%(database)
|
sql = "select min(t_int),ts from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,0)
|
tdSql.checkData(0,0,0)
|
||||||
sql = "select min(t_int) from %s.stb0 where ts<now;"%(database)
|
sql = "select min(t_int) from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,0)
|
tdSql.checkData(0,0,0)
|
||||||
sql = "select min(t_int),ts from %s.stb0 where ts<now;"%(database)
|
sql = "select min(t_int),ts from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,0)
|
tdSql.checkData(0,0,0)
|
||||||
sql = "select min(t_bigint) from %s.stb0 where ts<now;"%(database)
|
sql = "select min(t_bigint) from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,0)
|
tdSql.checkData(0,0,0)
|
||||||
sql = "select min(t_bigint),ts from %s.stb0 where ts<now;"%(database)
|
sql = "select min(t_bigint),ts from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,0)
|
tdSql.checkData(0,0,0)
|
||||||
sql = "select min(t_smallint) from %s.stb0 where ts<now;"%(database)
|
sql = "select min(t_smallint) from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,0)
|
tdSql.checkData(0,0,0)
|
||||||
sql = "select min(t_smallint),ts from %s.stb0 where ts<now;"%(database)
|
sql = "select min(t_smallint),ts from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,0)
|
tdSql.checkData(0,0,0)
|
||||||
sql = "select min(t_tinyint) from %s.stb0 where ts<now;"%(database)
|
sql = "select min(t_tinyint) from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,0)
|
tdSql.checkData(0,0,0)
|
||||||
sql = "select min(t_tinyint),ts from %s.stb0 where ts<now;"%(database)
|
sql = "select min(t_tinyint),ts from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,0)
|
tdSql.checkData(0,0,0)
|
||||||
sql = "select min(t_float) from %s.stb0 where ts<now;"%(database)
|
sql = "select min(t_float) from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,0)
|
tdSql.checkData(0,0,0)
|
||||||
sql = "select min(t_float),ts from %s.stb0 where ts<now;"%(database)
|
sql = "select min(t_float),ts from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,0)
|
tdSql.checkData(0,0,0)
|
||||||
sql = "select min(t_double) from %s.stb0 where ts<now;"%(database)
|
sql = "select min(t_double) from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,0)
|
tdSql.checkData(0,0,0)
|
||||||
sql = "select min(t_double),ts from %s.stb0 where ts<now;"%(database)
|
sql = "select min(t_double),ts from %s.stb0 where ts<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,0)
|
tdSql.checkData(0,0,0)
|
||||||
|
|
||||||
def ts_2601(self,database):
|
def ts_2601(self,database):
|
||||||
|
|
||||||
tdSql.query("alter local 'keepcolumnname' '0';")
|
tdSql.query("alter local 'keepcolumnname' '0';")
|
||||||
sql = "select ts,c0 from (select last(*) from %s.stb0 where ts<now);"%(database)
|
sql = "select ts,c0 from (select last(*) from %s.stb0 where ts<now);"%(database)
|
||||||
tdSql.error(sql)
|
tdSql.error(sql)
|
||||||
sql = "select ts,c0 from (select last(*) from %s.stb0 where ts<now order by ts );"%(database)
|
sql = "select ts,c0 from (select last(*) from %s.stb0 where ts<now order by ts );"%(database)
|
||||||
tdSql.error(sql)
|
tdSql.error(sql)
|
||||||
|
|
||||||
tdSql.query("alter local 'keepcolumnname' '1';")
|
tdSql.query("alter local 'keepcolumnname' '1';")
|
||||||
sql = "select ts,c0 from (select last(*) from %s.stb0 where ts<now);"%(database)
|
sql = "select ts,c0 from (select last(*) from %s.stb0 where ts<now);"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
sql = "select ts,c0 from (select last(*) from %s.stb0 where ts<now order by ts );"%(database)
|
sql = "select ts,c0 from (select last(*) from %s.stb0 where ts<now order by ts );"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
|
|
||||||
def ts_3108(self,database):
|
def ts_3108(self,database):
|
||||||
|
|
||||||
sql = "select count(*) from %s.stb0 where to_unixtimestamp('2023-01-01 00:00:00.000')<now;"%(database)
|
sql = "select count(*) from %s.stb0 where to_unixtimestamp('2023-01-01 00:00:00.000')<now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,2500)
|
tdSql.checkData(0,0,2500)
|
||||||
sql = "select count(*) from %s.stb0 where to_unixtimestamp('2023-01-01 00:00:00.000')>now;"%(database)
|
sql = "select count(*) from %s.stb0 where to_unixtimestamp('2023-01-01 00:00:00.000')>now;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
sql = "select count(*) from %s.stb0 where to_unixtimestamp('2024-01-01 00:00:00.000')<now+1y;"%(database)
|
sql = "select count(*) from %s.stb0 where to_unixtimestamp('2024-01-01 00:00:00.000')<now+1y;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkData(0,0,2500)
|
tdSql.checkData(0,0,2500)
|
||||||
sql = "select count(*) from %s.stb0 where to_unixtimestamp('2024-01-01 00:00:00.000')>now+1y;"%(database)
|
sql = "select count(*) from %s.stb0 where to_unixtimestamp('2024-01-01 00:00:00.000')>now+1y;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
def ts_3110(self,database):
|
def ts_3110(self,database):
|
||||||
|
|
||||||
sql1 = "select * from %s.stb0 order by ts desc limit 2;"%(database)
|
sql1 = "select * from %s.stb0 order by ts desc limit 2;"%(database)
|
||||||
tdSql.query(sql1)
|
tdSql.query(sql1)
|
||||||
data1_0_0 = tdSql.getData(0,0)
|
data1_0_0 = tdSql.getData(0,0)
|
||||||
data1_1_0 = tdSql.getData(1,0)
|
data1_1_0 = tdSql.getData(1,0)
|
||||||
|
|
||||||
sql2 = "select * from (select * from %s.stb0 order by ts desc limit 2) order by ts;"%(database)
|
sql2 = "select * from (select * from %s.stb0 order by ts desc limit 2) order by ts;"%(database)
|
||||||
tdSql.query(sql2)
|
tdSql.query(sql2)
|
||||||
data2_0_0 = tdSql.getData(0,0)
|
data2_0_0 = tdSql.getData(0,0)
|
||||||
data2_1_0 = tdSql.getData(1,0)
|
data2_1_0 = tdSql.getData(1,0)
|
||||||
|
|
||||||
if (data1_0_0 == data2_1_0) and (data1_1_0 == data2_0_0):
|
if (data1_0_0 == data2_1_0) and (data1_1_0 == data2_0_0):
|
||||||
tdLog.info("ts_3110: success")
|
tdLog.info("ts_3110: success")
|
||||||
else:
|
else:
|
||||||
tdLog.exit("ts_3110: sql1 result:'%s' not equal sql2 result:'%s'" % (sql1,sql2))
|
tdLog.exit("ts_3110: sql1 result:'%s' not equal sql2 result:'%s'" % (sql1,sql2))
|
||||||
|
|
||||||
def ts_3036(self,database):
|
def ts_3036(self,database):
|
||||||
|
|
||||||
sql1 = "select ts , c0 , c1 , c0null , c1null from (select ts , c0 , c1 , c0null , c1null from %s.stb0_0 where ts between now -1d and now +1d \
|
sql1 = "select ts , c0 , c1 , c0null , c1null from (select ts , c0 , c1 , c0null , c1null from %s.stb0_0 where ts between now -1d and now +1d \
|
||||||
union all select ts , c0 , c1 , c0null , c1null from %s.stb0_1 where ts between now -1d and now +1d \
|
union all select ts , c0 , c1 , c0null , c1null from %s.stb0_1 where ts between now -1d and now +1d \
|
||||||
union all select ts , c0 , c1 , c0null , c1null from %s.stb0_2 where ts between now -1d and now +1d ) tt \
|
union all select ts , c0 , c1 , c0null , c1null from %s.stb0_2 where ts between now -1d and now +1d ) tt \
|
||||||
where ts < now order by tt.ts desc limit 2;"%(database,database,database)
|
where ts < now order by tt.ts desc limit 2;"%(database,database,database)
|
||||||
tdSql.query(sql1)
|
tdSql.query(sql1)
|
||||||
data1_0_0 = tdSql.getData(0,0)
|
data1_0_0 = tdSql.getData(0,0)
|
||||||
data1_1_0 = tdSql.getData(1,0)
|
data1_1_0 = tdSql.getData(1,0)
|
||||||
|
|
||||||
sql2 = "select ts , c0 , c1 , c0null , c1null from (select tbname as tb, ts , c0 , c1 , c0null , c1null from %s.stb0 where ts > now \
|
sql2 = "select ts , c0 , c1 , c0null , c1null from (select tbname as tb, ts , c0 , c1 , c0null , c1null from %s.stb0 where ts > now \
|
||||||
union all select tbname as tb, ts , c0 , c1 , c0null , c1null from %s.stb0 where ts = now \
|
union all select tbname as tb, ts , c0 , c1 , c0null , c1null from %s.stb0 where ts = now \
|
||||||
union all select tbname as tb, ts , c0 , c1 , c0null , c1null from %s.stb0 where ts < now ) tt \
|
union all select tbname as tb, ts , c0 , c1 , c0null , c1null from %s.stb0 where ts < now ) tt \
|
||||||
where tt.ts between now -1d and now +1d and tt.tb in ('stb0_0','stb0_1','stb0_2') order by tt.ts desc limit 2;"%(database,database,database)
|
where tt.ts between now -1d and now +1d and tt.tb in ('stb0_0','stb0_1','stb0_2') order by tt.ts desc limit 2;"%(database,database,database)
|
||||||
tdSql.query(sql2)
|
tdSql.query(sql2)
|
||||||
data2_0_0 = tdSql.getData(0,0)
|
data2_0_0 = tdSql.getData(0,0)
|
||||||
data2_1_0 = tdSql.getData(1,0)
|
data2_1_0 = tdSql.getData(1,0)
|
||||||
|
|
||||||
sql3 = "select ts , c0 , c1 , c0null , c1null from %s.stb0 \
|
sql3 = "select ts , c0 , c1 , c0null , c1null from %s.stb0 \
|
||||||
where ts between now -1d and now +1d and tbname in ('stb0_0','stb0_1','stb0_2') order by ts desc limit 2;"%(database)
|
where ts between now -1d and now +1d and tbname in ('stb0_0','stb0_1','stb0_2') order by ts desc limit 2;"%(database)
|
||||||
tdSql.query(sql3)
|
tdSql.query(sql3)
|
||||||
data3_0_0 = tdSql.getData(0,0)
|
data3_0_0 = tdSql.getData(0,0)
|
||||||
data3_1_0 = tdSql.getData(1,0)
|
data3_1_0 = tdSql.getData(1,0)
|
||||||
|
|
||||||
if (data1_0_0 == data2_0_0 == data3_0_0) and (data1_1_0 == data2_1_0 == data3_1_0):
|
if (data1_0_0 == data2_0_0 == data3_0_0) and (data1_1_0 == data2_1_0 == data3_1_0):
|
||||||
tdLog.info("ts_3036: success")
|
tdLog.info("ts_3036: success")
|
||||||
else:
|
else:
|
||||||
tdLog.exit("ts_3036: sql1 result:'%s' not equal sql2 result:'%s' or not equal sql3 result:'%s'" % (sql1,sql2,sql3))
|
tdLog.exit("ts_3036: sql1 result:'%s' not equal sql2 result:'%s' or not equal sql3 result:'%s'" % (sql1,sql2,sql3))
|
||||||
|
|
||||||
|
|
||||||
def ts_23569(self,database):
|
def ts_23569(self,database):
|
||||||
|
|
||||||
tdSql.query("alter local 'keepcolumnname' '0';")
|
tdSql.query("alter local 'keepcolumnname' '0';")
|
||||||
sql = "alter table %s.stb0 drop tag t10;"%(database)
|
sql = "alter table %s.stb0 drop tag t10;"%(database)
|
||||||
tdSql.error(sql)
|
tdSql.error(sql)
|
||||||
error_msg = tdSql.error(sql)
|
error_msg = tdSql.error(sql)
|
||||||
include_msg = 'Invalid tag name'
|
include_msg = 'Invalid tag name'
|
||||||
if include_msg in error_msg:
|
if include_msg in error_msg:
|
||||||
tdLog.info("ts_23569: success")
|
tdLog.info("ts_23569: success")
|
||||||
else:
|
else:
|
||||||
tdLog.exit("ts_23569: include_msg:'%s' not in error_msg:'%s'" % (include_msg,error_msg))
|
tdLog.exit("ts_23569: include_msg:'%s' not in error_msg:'%s'" % (include_msg,error_msg))
|
||||||
|
|
||||||
tdSql.query("alter local 'keepcolumnname' '1';")
|
tdSql.query("alter local 'keepcolumnname' '1';")
|
||||||
sql = "alter table %s.stb0 drop tag t10;"%(database)
|
sql = "alter table %s.stb0 drop tag t10;"%(database)
|
||||||
tdSql.error(sql)
|
tdSql.error(sql)
|
||||||
error_msg = tdSql.error(sql)
|
error_msg = tdSql.error(sql)
|
||||||
include_msg = 'Invalid tag name'
|
include_msg = 'Invalid tag name'
|
||||||
if include_msg in error_msg:
|
if include_msg in error_msg:
|
||||||
tdLog.info("ts_23569: success")
|
tdLog.info("ts_23569: success")
|
||||||
else:
|
else:
|
||||||
tdLog.exit("ts_23569: include_msg:'%s' not in error_msg:'%s'" % (include_msg,error_msg))
|
tdLog.exit("ts_23569: include_msg:'%s' not in error_msg:'%s'" % (include_msg,error_msg))
|
||||||
|
|
||||||
def ts_23505(self,database):
|
def ts_23505(self,database):
|
||||||
|
|
||||||
sql = "create table %s.`12345` (`567` timestamp,num int);"%(database)
|
sql = "create table %s.`12345` (`567` timestamp,num int);"%(database)
|
||||||
tdSql.execute(sql)
|
tdSql.execute(sql)
|
||||||
|
|
||||||
sql = "insert into %s.12345 values (now,1);"%(database)
|
|
||||||
tdSql.error(sql)
|
|
||||||
|
|
||||||
sql = "insert into %s.`12345` values (now,1);"%(database)
|
|
||||||
tdSql.execute(sql)
|
|
||||||
|
|
||||||
sql = "select * from %s.`12345` order by `567` desc limit 2;"%(database)
|
|
||||||
tdSql.query(sql)
|
|
||||||
tdSql.checkData(0,1,1)
|
|
||||||
|
|
||||||
sql = "drop table %s.`12345` ;"%(database)
|
|
||||||
tdSql.execute(sql)
|
|
||||||
sql = "select * from %s.`12345` order by `567` desc limit 2;"%(database)
|
|
||||||
tdSql.error(sql)
|
|
||||||
|
|
||||||
def td_27939(self,database):
|
sql = "insert into %s.12345 values (now,1);"%(database)
|
||||||
|
tdSql.error(sql)
|
||||||
|
|
||||||
|
sql = "insert into %s.`12345` values (now,1);"%(database)
|
||||||
|
tdSql.execute(sql)
|
||||||
|
|
||||||
|
sql = "select * from %s.`12345` order by `567` desc limit 2;"%(database)
|
||||||
|
tdSql.query(sql)
|
||||||
|
tdSql.checkData(0,1,1)
|
||||||
|
|
||||||
|
sql = "drop table %s.`12345` ;"%(database)
|
||||||
|
tdSql.execute(sql)
|
||||||
|
sql = "select * from %s.`12345` order by `567` desc limit 2;"%(database)
|
||||||
|
tdSql.error(sql)
|
||||||
|
|
||||||
|
def td_27939(self,database):
|
||||||
sql = "create table %s.`test1eq2` (`ts` timestamp, id int);"%(database)
|
sql = "create table %s.`test1eq2` (`ts` timestamp, id int);"%(database)
|
||||||
tdSql.execute(sql)
|
tdSql.execute(sql)
|
||||||
|
|
||||||
sql = "insert into %s.test1eq2 values (now,1);"%(database)
|
sql = "insert into %s.test1eq2 values (now,1);"%(database)
|
||||||
tdSql.execute(sql)
|
tdSql.execute(sql)
|
||||||
|
|
||||||
sql = "insert into %s.`test1eq2` values (now,2);"%(database)
|
sql = "insert into %s.`test1eq2` values (now,2);"%(database)
|
||||||
tdSql.execute(sql)
|
tdSql.execute(sql)
|
||||||
|
|
||||||
sql = "select * from %s.`test1eq2` where 1=2;"%(database)
|
sql = "select * from %s.`test1eq2` where 1=2;"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
sql = "select * from (select * from %s.`test1eq2` where 1=2);"%(database)
|
sql = "select * from (select * from %s.`test1eq2` where 1=2);"%(database)
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
sql = "drop table %s.`test1eq2` ;"%(database)
|
sql = "drop table %s.`test1eq2` ;"%(database)
|
||||||
tdSql.execute(sql)
|
tdSql.execute(sql)
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
startTime = time.time()
|
startTime = time.time()
|
||||||
|
|
||||||
os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename))
|
os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename))
|
||||||
|
|
||||||
self.insert_data("%s" %self.db,2)
|
self.insert_data("%s" %self.db,2)
|
||||||
|
|
||||||
self.ts_3085("%s" %self.db)
|
self.ts_3085("%s" %self.db)
|
||||||
self.ts_2974_max("%s" %self.db)
|
self.ts_2974_max("%s" %self.db)
|
||||||
self.ts_2974_min("%s" %self.db)
|
self.ts_2974_min("%s" %self.db)
|
||||||
|
@ -443,9 +443,9 @@ class TDTestCase:
|
||||||
self.ts_3036("%s" %self.db)
|
self.ts_3036("%s" %self.db)
|
||||||
|
|
||||||
self.td_27939("%s" %self.db)
|
self.td_27939("%s" %self.db)
|
||||||
|
|
||||||
tdSql.query("flush database %s" %self.db)
|
tdSql.query("flush database %s" %self.db)
|
||||||
|
|
||||||
self.ts_2974_max("%s" %self.db)
|
self.ts_2974_max("%s" %self.db)
|
||||||
self.ts_2974_min("%s" %self.db)
|
self.ts_2974_min("%s" %self.db)
|
||||||
self.ts_3085("%s" %self.db)
|
self.ts_3085("%s" %self.db)
|
||||||
|
@ -461,7 +461,7 @@ class TDTestCase:
|
||||||
self.test_select_as_chinese_characters();
|
self.test_select_as_chinese_characters();
|
||||||
endTime = time.time()
|
endTime = time.time()
|
||||||
print("total time %ds" % (endTime - startTime))
|
print("total time %ds" % (endTime - startTime))
|
||||||
|
|
||||||
def test_select_as_chinese_characters(self):
|
def test_select_as_chinese_characters(self):
|
||||||
tdSql.execute("use sel_null")
|
tdSql.execute("use sel_null")
|
||||||
tdSql.query("select ts as 时间戳, c0 as c第一列, t0 标签1 from sel_null.stb0_0 limit 10", queryTimes=1)
|
tdSql.query("select ts as 时间戳, c0 as c第一列, t0 标签1 from sel_null.stb0_0 limit 10", queryTimes=1)
|
||||||
|
|
Loading…
Reference in New Issue