Merge pull request #23816 from taosdata/enh/xsren/TD-27474/timezone3.0
fix timezone range
This commit is contained in:
commit
24a2e857c3
|
@ -174,6 +174,10 @@ int32_t parseTimezone(char* str, int64_t* tzOffset) {
|
|||
i += 2;
|
||||
}
|
||||
|
||||
if (hour > 12 || hour < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// return error if there're illegal charaters after min(2 Digits)
|
||||
char* minStr = &str[i];
|
||||
if (minStr[1] != '\0' && minStr[2] != '\0') {
|
||||
|
@ -181,7 +185,7 @@ int32_t parseTimezone(char* str, int64_t* tzOffset) {
|
|||
}
|
||||
|
||||
int64_t minute = strnatoi(&str[i], 2);
|
||||
if (minute > 59) {
|
||||
if (minute > 59 || (hour == 12 && minute > 0)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -348,15 +348,15 @@ HANDLE taosOpenFileNotStream(const char *path, int32_t tdFileOptions) {
|
|||
if (h != INVALID_HANDLE_VALUE && (tdFileOptions & TD_FILE_APPEND) && (tdFileOptions & TD_FILE_WRITE)) {
|
||||
SetFilePointer(h, 0, NULL, FILE_END);
|
||||
}
|
||||
if (h == INVALID_HANDLE_VALUE) {
|
||||
DWORD dwError = GetLastError();
|
||||
LPVOID lpMsgBuf;
|
||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwError,
|
||||
0,
|
||||
(LPTSTR)&lpMsgBuf, 0, NULL);
|
||||
printf("CreateFile failed with error %d: %s", dwError, (char*)lpMsgBuf);
|
||||
LocalFree(lpMsgBuf);
|
||||
}
|
||||
// if (h == INVALID_HANDLE_VALUE) {
|
||||
// DWORD dwError = GetLastError();
|
||||
// LPVOID lpMsgBuf;
|
||||
// FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwError,
|
||||
// 0,
|
||||
// (LPTSTR)&lpMsgBuf, 0, NULL);
|
||||
// printf("CreateFile failed with error %d: %s", dwError, (char*)lpMsgBuf);
|
||||
// LocalFree(lpMsgBuf);
|
||||
// }
|
||||
return h;
|
||||
}
|
||||
|
||||
|
|
|
@ -343,6 +343,6 @@ TEST(osTest, osFilePerformance) {
|
|||
printf("Test OpenForRead & Close file %d times, cost: %" PRId64 "us\n", TESTTIMES, OpenForReadCloseFileCost);
|
||||
}
|
||||
|
||||
#endif OSFILE_PERFORMANCE_TEST
|
||||
#endif // OSFILE_PERFORMANCE_TEST
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
|
|
@ -112,10 +112,59 @@ class TDTestCase:
|
|||
self.data_check(timezone,self.stbname,'stable')
|
||||
for i in range(self.tbnum):
|
||||
self.data_check(timezone,f'{self.stbname}_{i}','child_table')
|
||||
tdSql.execute(f'drop database {self.dbname}')
|
||||
|
||||
def timezone_format_test(self):
|
||||
tdSql.execute(f'create database {self.dbname}')
|
||||
tdSql.execute(self.setsql.set_create_stable_sql(f'{self.dbname}.stb', {'ts':'timestamp','id':'int'}, {'status':'int'}))
|
||||
|
||||
tdSql.execute(f"insert into {self.dbname}.d0 using {self.dbname}.stb tags (1) values ('2021-07-01 00:00:00.000',0);")
|
||||
tdSql.query(f"select ts from {self.dbname}.d0;")
|
||||
tdSql.checkData(0, 0, "2021-07-01 00:00:00.000")
|
||||
|
||||
tdSql.execute(f"insert into {self.dbname}.d1 using {self.dbname}.stb tags (1) values ('2021-07-01T00:00:00.000+07:50',1)")
|
||||
tdSql.query(f"select ts from {self.dbname}.d1")
|
||||
tdSql.checkData(0, 0, "2021-07-01 00:10:00.000")
|
||||
|
||||
tdSql.execute(f"insert into {self.dbname}.d2 using {self.dbname}.stb tags (1) values ('2021-07-01T00:00:00.000+12:00',1)")
|
||||
tdSql.query(f"select ts from {self.dbname}.d2")
|
||||
tdSql.checkData(0, 0, "2021-06-30 20:00:00.000")
|
||||
|
||||
tdSql.execute(f"insert into {self.dbname}.d3 using {self.dbname}.stb tags (1) values ('2021-07-01T00:00:00.000-00:10',1)")
|
||||
tdSql.query(f"select ts from {self.dbname}.d3")
|
||||
tdSql.checkData(0, 0, "2021-07-01 08:10:00.000")
|
||||
|
||||
tdSql.execute(f"insert into {self.dbname}.d4 using {self.dbname}.stb tags (1) values ('2021-07-01T00:00:00.000-12:00',1)")
|
||||
tdSql.query(f"select ts from {self.dbname}.d4")
|
||||
tdSql.checkData(0, 0, "2021-07-01 20:00:00.000")
|
||||
|
||||
tdSql.execute(f"insert into {self.dbname}.d5 using {self.dbname}.stb tags (1) values ('2021-07-01T00:00:00.000-1200',1)")
|
||||
tdSql.query(f"select ts from {self.dbname}.d5")
|
||||
tdSql.checkData(0, 0, "2021-07-01 20:00:00.000")
|
||||
|
||||
tdSql.execute(f"insert into {self.dbname}.d6 using {self.dbname}.stb tags (1) values ('2021-07-01T00:00:00.000-115',1)")
|
||||
tdSql.query(f"select ts from {self.dbname}.d6")
|
||||
tdSql.checkData(0, 0, "2021-07-01 19:05:00.000")
|
||||
|
||||
tdSql.execute(f"insert into {self.dbname}.d7 using {self.dbname}.stb tags (1) values ('2021-07-01T00:00:00.000-1105',1)")
|
||||
tdSql.query(f"select ts from {self.dbname}.d7")
|
||||
tdSql.checkData(0, 0, "2021-07-01 19:05:00.000")
|
||||
|
||||
tdSql.error(f"insert into {self.dbname}.d21 using {self.dbname}.stb tags (1) values ('2021-07-01T00:00:00.000+12:10',1)")
|
||||
tdSql.error(f"insert into {self.dbname}.d22 using {self.dbname}.stb tags (1) values ('2021-07-01T00:00:00.000-24:10',1)")
|
||||
tdSql.error(f"insert into {self.dbname}.d23 using {self.dbname}.stb tags (1) values ('2021-07-01T00:00:00.000+12:10',1)")
|
||||
tdSql.error(f"insert into {self.dbname}.d24 using {self.dbname}.stb tags (1) values ('2021-07-01T00:00:00.000-24:10',1)")
|
||||
tdSql.error(f"insert into {self.dbname}.d24 using {self.dbname}.stb tags (1) values ('2021-07-01T00:00:00.000-24100',1)")
|
||||
tdSql.error(f"insert into {self.dbname}.d24 using {self.dbname}.stb tags (1) values ('2021-07-01T00:00:00.000-1210',1)")
|
||||
|
||||
tdSql.execute(f'drop database {self.dbname}')
|
||||
|
||||
|
||||
def run(self): # sourcery skip: extract-duplicate-method
|
||||
timezone = self.get_system_timezone()
|
||||
self.timezone_check_ntb(timezone)
|
||||
self.timezone_check_stb(timezone)
|
||||
self.timezone_format_test()
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
|
|
Loading…
Reference in New Issue