feat:[TD-32642] add timezone support in windows
This commit is contained in:
parent
b179c14b6d
commit
77b9871c0e
|
@ -65,22 +65,14 @@ typedef enum {
|
||||||
} TSDB_OPTION;
|
} TSDB_OPTION;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TSDB_OPTION_CONNECTION_CLEAR = -1, // clear all option in this connection
|
TSDB_OPTION_CONNECTION_CLEAR = -1, // means clear all option in this connection
|
||||||
TSDB_OPTION_CONNECTION_CHARSET, // charset, Same as the scope supported by the system
|
TSDB_OPTION_CONNECTION_CHARSET, // charset, Same as the scope supported by the system
|
||||||
TSDB_OPTION_CONNECTION_TIMEZONE, // timezone, Same as the scope supported by the system
|
TSDB_OPTION_CONNECTION_TIMEZONE, // timezone, Same as the scope supported by the system
|
||||||
TSDB_OPTION_CONNECTION_USER_IP, // user ip
|
TSDB_OPTION_CONNECTION_USER_IP, // user ip
|
||||||
TSDB_OPTION_CONNECTION_USER_APP, // user app
|
TSDB_OPTION_CONNECTION_USER_APP, // user app, max lengthe is 23, truncated if longer than 23
|
||||||
TSDB_MAX_OPTIONS_CONNECTION
|
TSDB_MAX_OPTIONS_CONNECTION
|
||||||
} TSDB_OPTION_CONNECTION;
|
} TSDB_OPTION_CONNECTION;
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
TSDB_OPTION_CONNECT_CHARSET,
|
|
||||||
TSDB_OPTION_CONNECT_TIMEZONE,
|
|
||||||
TSDB_OPTION_CONNECT_IP,
|
|
||||||
TSDB_OPTION_CONNECT_APP_NAME,
|
|
||||||
TSDB_MAX_CONNECT_OPTIONS
|
|
||||||
} TSDB_OPTION_CONNECT;
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TSDB_SML_UNKNOWN_PROTOCOL = 0,
|
TSDB_SML_UNKNOWN_PROTOCOL = 0,
|
||||||
TSDB_SML_LINE_PROTOCOL = 1,
|
TSDB_SML_LINE_PROTOCOL = 1,
|
||||||
|
@ -189,9 +181,26 @@ typedef struct TAOS_STMT_OPTIONS {
|
||||||
bool singleTableBindOnce;
|
bool singleTableBindOnce;
|
||||||
} TAOS_STMT_OPTIONS;
|
} TAOS_STMT_OPTIONS;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
description:
|
||||||
|
taos_options_connection use to set extra connect options and affect behavior for a connection.
|
||||||
|
This function may be called multiple times to set several options.
|
||||||
|
Call taos_options_connection() after taos_connect() or taos_connect_auth().
|
||||||
|
The option argument is the option that you want to set; the arg argument is the value for the option.
|
||||||
|
If you want to reset the option, set arg to NULL.
|
||||||
|
input:
|
||||||
|
taos: returned by taos_connect
|
||||||
|
option: option name
|
||||||
|
arg: option value(string)
|
||||||
|
output:
|
||||||
|
0: success
|
||||||
|
others: fail, error msg can be got by taos_errstr(NULL)
|
||||||
|
*/
|
||||||
|
DLL_EXPORT int taos_options_connection(TAOS *taos, TSDB_OPTION_CONNECTION option, const void *arg, ...);
|
||||||
|
|
||||||
DLL_EXPORT void taos_cleanup(void);
|
DLL_EXPORT void taos_cleanup(void);
|
||||||
DLL_EXPORT int taos_options(TSDB_OPTION option, const void *arg, ...);
|
DLL_EXPORT int taos_options(TSDB_OPTION option, const void *arg, ...);
|
||||||
DLL_EXPORT int taos_options_connection(TAOS *taos, TSDB_OPTION_CONNECTION option, const void *arg, ...);
|
|
||||||
DLL_EXPORT setConfRet taos_set_config(const char *config);
|
DLL_EXPORT setConfRet taos_set_config(const char *config);
|
||||||
DLL_EXPORT int taos_init(void);
|
DLL_EXPORT int taos_init(void);
|
||||||
DLL_EXPORT TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port);
|
DLL_EXPORT TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port);
|
||||||
|
|
|
@ -3420,7 +3420,6 @@ typedef struct {
|
||||||
SAppHbReq app;
|
SAppHbReq app;
|
||||||
SQueryHbReqBasic* query;
|
SQueryHbReqBasic* query;
|
||||||
SHashObj* info; // hash<Skv.key, Skv>
|
SHashObj* info; // hash<Skv.key, Skv>
|
||||||
char name[TSDB_APP_NAME_LEN];
|
|
||||||
char userApp[TSDB_APP_NAME_LEN];
|
char userApp[TSDB_APP_NAME_LEN];
|
||||||
uint32_t userIp;
|
uint32_t userIp;
|
||||||
} SClientHbReq;
|
} SClientHbReq;
|
||||||
|
|
|
@ -413,7 +413,9 @@ static FORCE_INLINE int32_t tDecodeBinary(SDecoder* pCoder, uint8_t** val, uint3
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tDecodeCStrAndLen(SDecoder* pCoder, char** val, uint32_t* len) {
|
static FORCE_INLINE int32_t tDecodeCStrAndLen(SDecoder* pCoder, char** val, uint32_t* len) {
|
||||||
TAOS_CHECK_RETURN(tDecodeBinary(pCoder, (uint8_t**)val, len));
|
TAOS_CHECK_RETURN(tDecodeBinary(pCoder, (uint8_t**)val, len));
|
||||||
(*len) -= 1;
|
if (*len > 0) {
|
||||||
|
(*len) -= 1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -427,7 +429,10 @@ static int32_t tDecodeCStrTo(SDecoder* pCoder, char* val) {
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
TAOS_CHECK_RETURN(tDecodeCStrAndLen(pCoder, &pStr, &len));
|
TAOS_CHECK_RETURN(tDecodeCStrAndLen(pCoder, &pStr, &len));
|
||||||
|
|
||||||
TAOS_MEMCPY(val, pStr, len + 1);
|
if (pCoder->pos + 1 < pCoder->size) {
|
||||||
|
TAOS_MEMCPY(val, pStr, len + 1);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,6 @@ static timezone_t setConnnectionTz(const char* val){
|
||||||
if (pTimezoneMap == NULL){
|
if (pTimezoneMap == NULL){
|
||||||
pTimezoneMap = taosHashInit(0, MurmurHash3_32, false, HASH_ENTRY_LOCK);
|
pTimezoneMap = taosHashInit(0, MurmurHash3_32, false, HASH_ENTRY_LOCK);
|
||||||
if (pTimezoneMap == NULL) {
|
if (pTimezoneMap == NULL) {
|
||||||
atomic_store_32(&lock_c, 0);
|
|
||||||
goto END;
|
goto END;
|
||||||
}
|
}
|
||||||
taosHashSetFreeFp(pTimezoneMap, freeTz);
|
taosHashSetFreeFp(pTimezoneMap, freeTz);
|
||||||
|
@ -85,7 +84,6 @@ static timezone_t setConnnectionTz(const char* val){
|
||||||
if (pTimezoneNameMap == NULL){
|
if (pTimezoneNameMap == NULL){
|
||||||
pTimezoneNameMap = taosHashInit(0, taosIntHash_64, false, HASH_ENTRY_LOCK);
|
pTimezoneNameMap = taosHashInit(0, taosIntHash_64, false, HASH_ENTRY_LOCK);
|
||||||
if (pTimezoneNameMap == NULL) {
|
if (pTimezoneNameMap == NULL) {
|
||||||
atomic_store_32(&lock_c, 0);
|
|
||||||
goto END;
|
goto END;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -474,6 +474,8 @@ TEST(charsetCase, alter_charset_Test) {
|
||||||
|
|
||||||
execQueryFail(pConn, "alter dnode 1 'charset gbk'");
|
execQueryFail(pConn, "alter dnode 1 'charset gbk'");
|
||||||
execQueryFail(pConn, "local 'charset gbk'");
|
execQueryFail(pConn, "local 'charset gbk'");
|
||||||
|
|
||||||
|
taos_close(pConn);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef WINDOWS
|
#ifndef WINDOWS
|
||||||
|
@ -493,6 +495,8 @@ TEST(timezoneCase, alter_timezone_Test) {
|
||||||
check_timezone(pConn, "show local variables", "Asia/Shanghai");
|
check_timezone(pConn, "show local variables", "Asia/Shanghai");
|
||||||
|
|
||||||
execQueryFail(pConn, "alter dnode 1 'timezone Asia/Kolkata'");
|
execQueryFail(pConn, "alter dnode 1 'timezone Asia/Kolkata'");
|
||||||
|
|
||||||
|
taos_close(pConn);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *tz_test[] = {
|
char *tz_test[] = {
|
||||||
|
|
|
@ -584,7 +584,7 @@ static bool isCharStart(char c) {
|
||||||
static int32_t trimHelper(char *orgStr, char* remStr, int32_t orgLen, int32_t remLen, bool trimLeft, bool isNchar) {
|
static int32_t trimHelper(char *orgStr, char* remStr, int32_t orgLen, int32_t remLen, bool trimLeft, bool isNchar) {
|
||||||
if (trimLeft) {
|
if (trimLeft) {
|
||||||
int32_t pos = 0;
|
int32_t pos = 0;
|
||||||
for (int32_t i = 0; i < orgLen; i += remLen) {
|
for (int32_t i = 0; i < orgLen - remLen; i += remLen) {
|
||||||
if (memcmp(orgStr + i, remStr, remLen) == 0) {
|
if (memcmp(orgStr + i, remStr, remLen) == 0) {
|
||||||
if (isCharStart(orgStr[i + remLen]) || isNchar) {
|
if (isCharStart(orgStr[i + remLen]) || isNchar) {
|
||||||
pos = i + remLen;
|
pos = i + remLen;
|
||||||
|
|
Loading…
Reference in New Issue