Merge branch '3.0' of https://github.com/taosdata/TDengine into feature/vnode_refact1
This commit is contained in:
commit
d82ab77aaa
|
@ -26,7 +26,6 @@ typedef struct TdDirEntry {
|
||||||
WIN32_FIND_DATA findFileData;
|
WIN32_FIND_DATA findFileData;
|
||||||
} TdDirEntry;
|
} TdDirEntry;
|
||||||
|
|
||||||
|
|
||||||
typedef struct TdDir {
|
typedef struct TdDir {
|
||||||
TdDirEntry dirEntry;
|
TdDirEntry dirEntry;
|
||||||
HANDLE hFind;
|
HANDLE hFind;
|
||||||
|
@ -59,7 +58,7 @@ void wordfree(wordexp_t *pwordexp) {}
|
||||||
#include <wordexp.h>
|
#include <wordexp.h>
|
||||||
|
|
||||||
typedef struct dirent dirent;
|
typedef struct dirent dirent;
|
||||||
typedef struct DIR TdDir;
|
typedef struct DIR TdDir;
|
||||||
typedef struct dirent TdDirEntry;
|
typedef struct dirent TdDirEntry;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -78,14 +77,14 @@ void taosRemoveDir(const char *dirname) {
|
||||||
taosRemoveDir(filename);
|
taosRemoveDir(filename);
|
||||||
} else {
|
} else {
|
||||||
(void)taosRemoveFile(filename);
|
(void)taosRemoveFile(filename);
|
||||||
//printf("file:%s is removed\n", filename);
|
// printf("file:%s is removed\n", filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosCloseDir(&pDir);
|
taosCloseDir(&pDir);
|
||||||
rmdir(dirname);
|
rmdir(dirname);
|
||||||
|
|
||||||
//printf("dir:%s is removed\n", dirname);
|
// printf("dir:%s is removed\n", dirname);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,8 +101,8 @@ int32_t taosMkDir(const char *dirname) {
|
||||||
|
|
||||||
int32_t taosMulMkDir(const char *dirname) {
|
int32_t taosMulMkDir(const char *dirname) {
|
||||||
if (dirname == NULL) return -1;
|
if (dirname == NULL) return -1;
|
||||||
char *temp = strdup(dirname);
|
char * temp = strdup(dirname);
|
||||||
char *pos = temp;
|
char * pos = temp;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
if (strncmp(temp, "/", 1) == 0) {
|
if (strncmp(temp, "/", 1) == 0) {
|
||||||
|
@ -111,8 +110,8 @@ int32_t taosMulMkDir(const char *dirname) {
|
||||||
} else if (strncmp(temp, "./", 2) == 0) {
|
} else if (strncmp(temp, "./", 2) == 0) {
|
||||||
pos += 2;
|
pos += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( ; *pos != '\0'; pos++) {
|
for (; *pos != '\0'; pos++) {
|
||||||
if (*pos == '/') {
|
if (*pos == '/') {
|
||||||
*pos = '\0';
|
*pos = '\0';
|
||||||
code = mkdir(temp, 0755);
|
code = mkdir(temp, 0755);
|
||||||
|
@ -123,7 +122,7 @@ int32_t taosMulMkDir(const char *dirname) {
|
||||||
*pos = '/';
|
*pos = '/';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*(pos - 1) != '/') {
|
if (*(pos - 1) != '/') {
|
||||||
code = mkdir(temp, 0755);
|
code = mkdir(temp, 0755);
|
||||||
if (code < 0 && errno != EEXIST) {
|
if (code < 0 && errno != EEXIST) {
|
||||||
|
@ -145,7 +144,7 @@ void taosRemoveOldFiles(const char *dirname, int32_t keepDays) {
|
||||||
TdDirPtr pDir = taosOpenDir(dirname);
|
TdDirPtr pDir = taosOpenDir(dirname);
|
||||||
if (pDir == NULL) return;
|
if (pDir == NULL) return;
|
||||||
|
|
||||||
int64_t sec = taosGetTimestampSec();
|
int64_t sec = taosGetTimestampSec();
|
||||||
TdDirEntryPtr de = NULL;
|
TdDirEntryPtr de = NULL;
|
||||||
|
|
||||||
while ((de = taosReadDir(pDir)) != NULL) {
|
while ((de = taosReadDir(pDir)) != NULL) {
|
||||||
|
@ -173,9 +172,9 @@ void taosRemoveOldFiles(const char *dirname, int32_t keepDays) {
|
||||||
int32_t days = (int32_t)(TABS(sec - fileSec) / 86400 + 1);
|
int32_t days = (int32_t)(TABS(sec - fileSec) / 86400 + 1);
|
||||||
if (days > keepDays) {
|
if (days > keepDays) {
|
||||||
(void)taosRemoveFile(filename);
|
(void)taosRemoveFile(filename);
|
||||||
//printf("file:%s is removed, days:%d keepDays:%d", filename, days, keepDays);
|
// printf("file:%s is removed, days:%d keepDays:%d", filename, days, keepDays);
|
||||||
} else {
|
} else {
|
||||||
//printf("file:%s won't be removed, days:%d keepDays:%d", filename, days, keepDays);
|
// printf("file:%s won't be removed, days:%d keepDays:%d", filename, days, keepDays);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,7 +186,7 @@ void taosRemoveOldFiles(const char *dirname, int32_t keepDays) {
|
||||||
int32_t taosExpandDir(const char *dirname, char *outname, int32_t maxlen) {
|
int32_t taosExpandDir(const char *dirname, char *outname, int32_t maxlen) {
|
||||||
wordexp_t full_path;
|
wordexp_t full_path;
|
||||||
if (0 != wordexp(dirname, &full_path, 0)) {
|
if (0 != wordexp(dirname, &full_path, 0)) {
|
||||||
//printf("failed to expand path:%s since %s", dirname, strerror(errno));
|
// printf("failed to expand path:%s since %s", dirname, strerror(errno));
|
||||||
wordfree(&full_path);
|
wordfree(&full_path);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -228,9 +227,9 @@ bool taosIsDir(const char *dirname) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* taosDirName(char *name) {
|
char *taosDirName(char *name) {
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
char Drive1[MAX_PATH], Dir1[MAX_PATH];
|
char Drive1[MAX_PATH], Dir1[MAX_PATH];
|
||||||
_splitpath(name, Drive1, Dir1, NULL, NULL);
|
_splitpath(name, Drive1, Dir1, NULL, NULL);
|
||||||
size_t dirNameLen = strlen(Drive1) + strlen(Dir1);
|
size_t dirNameLen = strlen(Drive1) + strlen(Dir1);
|
||||||
if (dirNameLen > 0) {
|
if (dirNameLen > 0) {
|
||||||
|
@ -242,13 +241,13 @@ char* taosDirName(char *name) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
char* taosDirEntryBaseName(char *name) {
|
char *taosDirEntryBaseName(char *name) {
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
char Filename1[MAX_PATH], Ext1[MAX_PATH];
|
char Filename1[MAX_PATH], Ext1[MAX_PATH];
|
||||||
_splitpath(name, NULL, NULL, Filename1, Ext1);
|
_splitpath(name, NULL, NULL, Filename1, Ext1);
|
||||||
return name + (strlen(name) - strlen(Filename1) - strlen(Ext1));
|
return name + (strlen(name) - strlen(Filename1) - strlen(Ext1));
|
||||||
#else
|
#else
|
||||||
return (char*)basename(name);
|
return (char *)basename(name);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,8 +257,8 @@ TdDirPtr taosOpenDir(const char *dirname) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
char szFind[MAX_PATH]; //这是要找的
|
char szFind[MAX_PATH]; //这是要找的
|
||||||
HANDLE hFind;
|
HANDLE hFind;
|
||||||
|
|
||||||
TdDirPtr pDir = taosMemoryMalloc(sizeof(TdDir));
|
TdDirPtr pDir = taosMemoryMalloc(sizeof(TdDir));
|
||||||
|
|
||||||
|
@ -275,7 +274,6 @@ TdDirPtr taosOpenDir(const char *dirname) {
|
||||||
#else
|
#else
|
||||||
return (TdDirPtr)opendir(dirname);
|
return (TdDirPtr)opendir(dirname);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TdDirEntryPtr taosReadDir(TdDirPtr pDir) {
|
TdDirEntryPtr taosReadDir(TdDirPtr pDir) {
|
||||||
|
@ -286,9 +284,9 @@ TdDirEntryPtr taosReadDir(TdDirPtr pDir) {
|
||||||
if (!FindNextFile(pDir->hFind, &(pDir->dirEntry.findFileData))) {
|
if (!FindNextFile(pDir->hFind, &(pDir->dirEntry.findFileData))) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return (TdDirEntryPtr)&(pDir->dirEntry.findFileData);
|
return (TdDirEntryPtr) & (pDir->dirEntry.findFileData);
|
||||||
#else
|
#else
|
||||||
return (TdDirEntryPtr)readdir((DIR*)pDir);
|
return (TdDirEntryPtr)readdir((DIR *)pDir);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,18 +297,18 @@ bool taosDirEntryIsDir(TdDirEntryPtr pDirEntry) {
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
return (pDirEntry->findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
return (pDirEntry->findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||||
#else
|
#else
|
||||||
return (((dirent*)pDirEntry)->d_type & DT_DIR) != 0;
|
return (((dirent *)pDirEntry)->d_type & DT_DIR) != 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
char* taosGetDirEntryName(TdDirEntryPtr pDirEntry) {
|
char *taosGetDirEntryName(TdDirEntryPtr pDirEntry) {
|
||||||
if (pDirEntry == NULL) {
|
if (pDirEntry == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
return pDirEntry->findFileData.cFileName;
|
return pDirEntry->findFileData.cFileName;
|
||||||
#else
|
#else
|
||||||
return ((dirent*)pDirEntry)->d_name;
|
return ((dirent *)pDirEntry)->d_name;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,7 +322,7 @@ int32_t taosCloseDir(TdDirPtr *ppDir) {
|
||||||
*ppDir = NULL;
|
*ppDir = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
closedir((DIR*)*ppDir);
|
closedir((DIR *)*ppDir);
|
||||||
*ppDir = NULL;
|
*ppDir = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#else
|
#else
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <net/if.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <netinet/ip.h>
|
#include <netinet/ip.h>
|
||||||
|
@ -638,6 +639,73 @@ int32_t taosKeepTcpAlive(TdSocketPtr pSocket) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int taosGetLocalIp(const char *eth, char *ip) {
|
||||||
|
#if defined(WINDOWS)
|
||||||
|
// DO NOTHAING
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
|
int fd;
|
||||||
|
struct ifreq ifr;
|
||||||
|
struct sockaddr_in sin;
|
||||||
|
|
||||||
|
fd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
|
if (-1 == fd) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
strncpy(ifr.ifr_name, eth, IFNAMSIZ);
|
||||||
|
ifr.ifr_name[IFNAMSIZ - 1] = 0;
|
||||||
|
|
||||||
|
if (ioctl(fd, SIOCGIFADDR, &ifr) < 0) {
|
||||||
|
taosCloseSocketNoCheck1(fd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
memcpy(&sin, &ifr.ifr_addr, sizeof(sin));
|
||||||
|
snprintf(ip, 64, "%s", inet_ntoa(sin.sin_addr));
|
||||||
|
taosCloseSocketNoCheck1(fd);
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int taosValidIp(uint32_t ip) {
|
||||||
|
#if defined(WINDOWS)
|
||||||
|
// DO NOTHAING
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
|
int ret = -1;
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
struct ifconf ifconf;
|
||||||
|
|
||||||
|
char buf[512] = {0};
|
||||||
|
ifconf.ifc_len = 512;
|
||||||
|
ifconf.ifc_buf = buf;
|
||||||
|
|
||||||
|
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ioctl(fd, SIOCGIFCONF, &ifconf);
|
||||||
|
struct ifreq *ifreq = (struct ifreq *)ifconf.ifc_buf;
|
||||||
|
for (int i = (ifconf.ifc_len / sizeof(struct ifreq)); i > 0; i--) {
|
||||||
|
char ip_str[64] = {0};
|
||||||
|
if (ifreq->ifr_flags == AF_INET) {
|
||||||
|
ret = taosGetLocalIp(ifreq->ifr_name, ip_str);
|
||||||
|
if (ret != 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ret = -1;
|
||||||
|
if (ip == (uint32_t)taosInetAddr(ip_str)) {
|
||||||
|
ret = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ifreq++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
taosCloseSocketNoCheck1(fd);
|
||||||
|
return ret;
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
bool taosValidIpAndPort(uint32_t ip, uint16_t port) {
|
bool taosValidIpAndPort(uint32_t ip, uint16_t port) {
|
||||||
struct sockaddr_in serverAdd;
|
struct sockaddr_in serverAdd;
|
||||||
SocketFd fd;
|
SocketFd fd;
|
||||||
|
@ -677,13 +745,8 @@ bool taosValidIpAndPort(uint32_t ip, uint16_t port) {
|
||||||
taosCloseSocket(&pSocket);
|
taosCloseSocket(&pSocket);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (listen(pSocket->fd, 1024) < 0) {
|
|
||||||
// printf("listen tcp server socket failed, 0x%x:%hu(%s)", ip, port, strerror(errno));
|
|
||||||
taosCloseSocket(&pSocket);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
taosCloseSocket(&pSocket);
|
taosCloseSocket(&pSocket);
|
||||||
return true;
|
return 0 == taosValidIp(ip) ? true : false;
|
||||||
}
|
}
|
||||||
TdSocketServerPtr taosOpenTcpServerSocket(uint32_t ip, uint16_t port) {
|
TdSocketServerPtr taosOpenTcpServerSocket(uint32_t ip, uint16_t port) {
|
||||||
struct sockaddr_in serverAdd;
|
struct sockaddr_in serverAdd;
|
||||||
|
|
|
@ -20,7 +20,7 @@ class TDTestCase:
|
||||||
__sql = f"select cast({col_name} as bigint), {col_name} from {tbname}"
|
__sql = f"select cast({col_name} as bigint), {col_name} from {tbname}"
|
||||||
tdSql.query(sql=__sql)
|
tdSql.query(sql=__sql)
|
||||||
data_tb_col = [result[1] for result in tdSql.queryResult]
|
data_tb_col = [result[1] for result in tdSql.queryResult]
|
||||||
for i in range(len(tdSql.queryRows)):
|
for i in range(tdSql.queryRows):
|
||||||
tdSql.checkData( i, 0, None ) if data_tb_col[i] is None else tdSql.checkData( i, 0, int(data_tb_col[i]) )
|
tdSql.checkData( i, 0, None ) if data_tb_col[i] is None else tdSql.checkData( i, 0, int(data_tb_col[i]) )
|
||||||
|
|
||||||
def __range_to_bigint(self,cols,tables):
|
def __range_to_bigint(self,cols,tables):
|
||||||
|
@ -32,7 +32,7 @@ class TDTestCase:
|
||||||
__sql = f"select cast({col_name} as timestamp), {col_name} from {tbname}"
|
__sql = f"select cast({col_name} as timestamp), {col_name} from {tbname}"
|
||||||
tdSql.query(sql=__sql)
|
tdSql.query(sql=__sql)
|
||||||
data_tb_col = [result[1] for result in tdSql.queryResult]
|
data_tb_col = [result[1] for result in tdSql.queryResult]
|
||||||
for i in range(len(tdSql.queryRows)):
|
for i in range(tdSql.queryRows):
|
||||||
if data_tb_col[i] is None:
|
if data_tb_col[i] is None:
|
||||||
tdSql.checkData( i, 0 , None )
|
tdSql.checkData( i, 0 , None )
|
||||||
if col_name not in ["c2", "double"] or tbname != "t1" or i != 10:
|
if col_name not in ["c2", "double"] or tbname != "t1" or i != 10:
|
||||||
|
@ -597,37 +597,37 @@ class TDTestCase:
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step39: cast constant operation to bigint, expect change to int ")
|
tdLog.printNoPrefix("==========step39: cast constant operation to bigint, expect change to int ")
|
||||||
tdSql.query("select cast(12121.23323131 as bigint) as b from ct4")
|
tdSql.query("select cast(12121.23323131 as bigint) as b from ct4")
|
||||||
( tdSql.checkData(i, 0, 12121) for i in range(len(tdSql.queryRows) ) )
|
( tdSql.checkData(i, 0, 12121) for i in range(tdSql.queryRows) )
|
||||||
tdSql.query("select cast(12121.23323131 as binary(16)) as b from ct4")
|
tdSql.query("select cast(12121.23323131 as binary(16)) as b from ct4")
|
||||||
( tdSql.checkData(i, 0, '12121.233231') for i in range(len(tdSql.queryRows)) )
|
( tdSql.checkData(i, 0, '12121.233231') for i in range(tdSql.queryRows) )
|
||||||
tdSql.query("select cast(12121.23323131 as binary(2)) as b from ct4")
|
tdSql.query("select cast(12121.23323131 as binary(2)) as b from ct4")
|
||||||
( tdSql.checkData(i, 0, '12') for i in range(len(tdSql.queryRows) ) )
|
( tdSql.checkData(i, 0, '12') for i in range(tdSql.queryRows) )
|
||||||
tdSql.query("select cast(12121.23323131 as nchar(16)) as b from ct4")
|
tdSql.query("select cast(12121.23323131 as nchar(16)) as b from ct4")
|
||||||
( tdSql.checkData(i, 0, '12121.233231') for i in range(len(tdSql.queryRows) ) )
|
( tdSql.checkData(i, 0, '12121.233231') for i in range(tdSql.queryRows) )
|
||||||
tdSql.query("select cast(12121.23323131 as nchar(2)) as b from ct4")
|
tdSql.query("select cast(12121.23323131 as nchar(2)) as b from ct4")
|
||||||
( tdSql.checkData(i, 0, '12') for i in range(len(tdSql.queryRows) ) )
|
( tdSql.checkData(i, 0, '12') for i in range(tdSql.queryRows) )
|
||||||
|
|
||||||
tdSql.query("select cast(12121.23323131 + 321.876897998 as bigint) as b from ct4")
|
tdSql.query("select cast(12121.23323131 + 321.876897998 as bigint) as b from ct4")
|
||||||
( tdSql.checkData(i, 0, 12443) for i in range(len(tdSql.queryRows) ) )
|
( tdSql.checkData(i, 0, 12443) for i in range(tdSql.queryRows) )
|
||||||
tdSql.query("select cast(12121.23323131 + 321.876897998 as binary(16)) as b from ct4")
|
tdSql.query("select cast(12121.23323131 + 321.876897998 as binary(16)) as b from ct4")
|
||||||
( tdSql.checkData(i, 0, '12443.110129') for i in range(len(tdSql.queryRows)) )
|
( tdSql.checkData(i, 0, '12443.110129') for i in range(tdSql.queryRows) )
|
||||||
tdSql.query("select cast(12121.23323131 + 321.876897998 as binary(3)) as b from ct4")
|
tdSql.query("select cast(12121.23323131 + 321.876897998 as binary(3)) as b from ct4")
|
||||||
( tdSql.checkData(i, 0, '124') for i in range(len(tdSql.queryRows) ) )
|
( tdSql.checkData(i, 0, '124') for i in range(tdSql.queryRows) )
|
||||||
tdSql.query("select cast(12121.23323131 + 321.876897998 as nchar(16)) as b from ct4")
|
tdSql.query("select cast(12121.23323131 + 321.876897998 as nchar(16)) as b from ct4")
|
||||||
( tdSql.checkData(i, 0, '12443.110129') for i in range(len(tdSql.queryRows)) )
|
( tdSql.checkData(i, 0, '12443.110129') for i in range(tdSql.queryRows) )
|
||||||
tdSql.query("select cast(12121.23323131 + 321.876897998 as nchar(3)) as b from ct4")
|
tdSql.query("select cast(12121.23323131 + 321.876897998 as nchar(3)) as b from ct4")
|
||||||
( tdSql.checkData(i, 0, '124') for i in range(len(tdSql.queryRows) ) )
|
( tdSql.checkData(i, 0, '124') for i in range(tdSql.queryRows) )
|
||||||
|
|
||||||
tdSql.query("select cast(12121.23323131 + 'test~!@`#$%^&*()}{][;><.,' as bigint) as b from ct4")
|
tdSql.query("select cast(12121.23323131 + 'test~!@`#$%^&*()}{][;><.,' as bigint) as b from ct4")
|
||||||
( tdSql.checkData(i, 0, 12121) for i in range(len(tdSql.queryRows) ) )
|
( tdSql.checkData(i, 0, 12121) for i in range(tdSql.queryRows) )
|
||||||
tdSql.query("select cast(12121.23323131 + 'test~!@`#$%^&*()}{][;><.,' as binary(16)) as b from ct4")
|
tdSql.query("select cast(12121.23323131 + 'test~!@`#$%^&*()}{][;><.,' as binary(16)) as b from ct4")
|
||||||
( tdSql.checkData(i, 0, '12121.233231') for i in range(len(tdSql.queryRows)) )
|
( tdSql.checkData(i, 0, '12121.233231') for i in range(tdSql.queryRows) )
|
||||||
tdSql.query("select cast(12121.23323131 + 'test~!@`#$%^&*()}{][;><.,' as binary(2)) as b from ct4")
|
tdSql.query("select cast(12121.23323131 + 'test~!@`#$%^&*()}{][;><.,' as binary(2)) as b from ct4")
|
||||||
( tdSql.checkData(i, 0, '12') for i in range(len(tdSql.queryRows) ) )
|
( tdSql.checkData(i, 0, '12') for i in range(tdSql.queryRows) )
|
||||||
tdSql.query("select cast(12121.23323131 + 'test~!@`#$%^&*()}{][;><.,' as nchar(16)) as b from ct4")
|
tdSql.query("select cast(12121.23323131 + 'test~!@`#$%^&*()}{][;><.,' as nchar(16)) as b from ct4")
|
||||||
( tdSql.checkData(i, 0, '12121.233231') for i in range(len(tdSql.queryRows) ) )
|
( tdSql.checkData(i, 0, '12121.233231') for i in range(tdSql.queryRows) )
|
||||||
tdSql.query("select cast(12121.23323131 + 'test~!@`#$%^&*()}{][;><.,' as nchar(2)) as b from ct4")
|
tdSql.query("select cast(12121.23323131 + 'test~!@`#$%^&*()}{][;><.,' as nchar(2)) as b from ct4")
|
||||||
( tdSql.checkData(i, 0, '12') for i in range(len(tdSql.queryRows) ) )
|
( tdSql.checkData(i, 0, '12') for i in range(tdSql.queryRows) )
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step40: error cast condition, should return error ")
|
tdLog.printNoPrefix("==========step40: error cast condition, should return error ")
|
||||||
tdSql.error("select cast(c1 as int) as b from ct4")
|
tdSql.error("select cast(c1 as int) as b from ct4")
|
||||||
|
|
|
@ -232,13 +232,13 @@ class TDTestCase:
|
||||||
tdLog.printNoPrefix("==========step3:all check")
|
tdLog.printNoPrefix("==========step3:all check")
|
||||||
self.all_test()
|
self.all_test()
|
||||||
|
|
||||||
# tdDnodes.stop(1)
|
tdDnodes.stop(1)
|
||||||
# tdDnodes.start(1)
|
tdDnodes.start(1)
|
||||||
|
|
||||||
# tdSql.execute("use db")
|
tdSql.execute("use db")
|
||||||
|
|
||||||
# tdLog.printNoPrefix("==========step4:after wal, all check again ")
|
tdLog.printNoPrefix("==========step4:after wal, all check again ")
|
||||||
# self.all_test()
|
self.all_test()
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
tdSql.close()
|
tdSql.close()
|
||||||
|
|
|
@ -49,7 +49,7 @@ class TDTestCase:
|
||||||
|
|
||||||
for num_col in NUM_COL:
|
for num_col in NUM_COL:
|
||||||
concat_condition.extend( f"cast( {num_col} + {bool_col} as binary(16) )" for bool_col in BOOLEAN_COL )
|
concat_condition.extend( f"cast( {num_col} + {bool_col} as binary(16) )" for bool_col in BOOLEAN_COL )
|
||||||
concat_condition.extend( f"cast( {num_col} + {ts_col} as binary(16) )" for ts_col in TS_TYPE_COL )
|
concat_condition.extend( f"cast( {num_col} + {ts_col} as binary(16) )" for ts_col in TS_TYPE_COL if num_col is not FLOAT_COL and num_col is not DOUBLE_COL)
|
||||||
|
|
||||||
concat_condition.extend( f"cast( {bool_col} + {ts_col} as binary(16) )" for bool_col in BOOLEAN_COL for ts_col in TS_TYPE_COL )
|
concat_condition.extend( f"cast( {bool_col} + {ts_col} as binary(16) )" for bool_col in BOOLEAN_COL for ts_col in TS_TYPE_COL )
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ class TDTestCase:
|
||||||
|
|
||||||
if num > 8 or num < 2 :
|
if num > 8 or num < 2 :
|
||||||
[tdSql.error(f"select concat( {','.join( condition ) }) from {tbname} {where_condition} {group} ") for group in groups ]
|
[tdSql.error(f"select concat( {','.join( condition ) }) from {tbname} {where_condition} {group} ") for group in groups ]
|
||||||
|
break
|
||||||
|
|
||||||
tdSql.query(f"select {','.join(condition)} from {tbname} ")
|
tdSql.query(f"select {','.join(condition)} from {tbname} ")
|
||||||
rows = tdSql.queryRows
|
rows = tdSql.queryRows
|
||||||
|
@ -271,13 +271,13 @@ class TDTestCase:
|
||||||
tdLog.printNoPrefix("==========step3:all check")
|
tdLog.printNoPrefix("==========step3:all check")
|
||||||
self.all_test()
|
self.all_test()
|
||||||
|
|
||||||
# tdDnodes.stop(1)
|
tdDnodes.stop(1)
|
||||||
# tdDnodes.start(1)
|
tdDnodes.start(1)
|
||||||
|
|
||||||
# tdSql.execute("use db")
|
tdSql.execute("use db")
|
||||||
|
|
||||||
# tdLog.printNoPrefix("==========step4:after wal, all check again ")
|
tdLog.printNoPrefix("==========step4:after wal, all check again ")
|
||||||
# self.all_test()
|
self.all_test()
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
tdSql.close()
|
tdSql.close()
|
||||||
|
|
|
@ -49,7 +49,7 @@ class TDTestCase:
|
||||||
|
|
||||||
for num_col in NUM_COL:
|
for num_col in NUM_COL:
|
||||||
concat_ws_condition.extend( f"cast( {num_col} + {bool_col} as binary(16) )" for bool_col in BOOLEAN_COL )
|
concat_ws_condition.extend( f"cast( {num_col} + {bool_col} as binary(16) )" for bool_col in BOOLEAN_COL )
|
||||||
concat_ws_condition.extend( f"cast( {num_col} + {ts_col} as binary(16) )" for ts_col in TS_TYPE_COL )
|
concat_ws_condition.extend( f"cast( {num_col} + {ts_col} as binary(16) )" for ts_col in TS_TYPE_COL if num_col is not FLOAT_COL and num_col is not DOUBLE_COL)
|
||||||
|
|
||||||
concat_ws_condition.extend( f"cast( {bool_col} + {ts_col} as binary(16) )" for bool_col in BOOLEAN_COL for ts_col in TS_TYPE_COL )
|
concat_ws_condition.extend( f"cast( {bool_col} + {ts_col} as binary(16) )" for bool_col in BOOLEAN_COL for ts_col in TS_TYPE_COL )
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ class TDTestCase:
|
||||||
|
|
||||||
if num > 8 or num < 2 :
|
if num > 8 or num < 2 :
|
||||||
[tdSql.error(f"select concat_ws('_', {','.join( condition ) }) from {tbname} {where_condition} {group} ") for group in groups ]
|
[tdSql.error(f"select concat_ws('_', {','.join( condition ) }) from {tbname} {where_condition} {group} ") for group in groups ]
|
||||||
|
break
|
||||||
|
|
||||||
tdSql.query(f"select {','.join(condition)} from {tbname} ")
|
tdSql.query(f"select {','.join(condition)} from {tbname} ")
|
||||||
rows = tdSql.queryRows
|
rows = tdSql.queryRows
|
||||||
|
@ -271,13 +271,13 @@ class TDTestCase:
|
||||||
tdLog.printNoPrefix("==========step3:all check")
|
tdLog.printNoPrefix("==========step3:all check")
|
||||||
self.all_test()
|
self.all_test()
|
||||||
|
|
||||||
# tdDnodes.stop(1)
|
tdDnodes.stop(1)
|
||||||
# tdDnodes.start(1)
|
tdDnodes.start(1)
|
||||||
|
|
||||||
# tdSql.execute("use db")
|
tdSql.execute("use db")
|
||||||
|
|
||||||
# tdLog.printNoPrefix("==========step4:after wal, all check again ")
|
tdLog.printNoPrefix("==========step4:after wal, all check again ")
|
||||||
# self.all_test()
|
self.all_test()
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
tdSql.close()
|
tdSql.close()
|
||||||
|
|
|
@ -99,6 +99,7 @@ class TDTestCase:
|
||||||
|
|
||||||
if not join_flag :
|
if not join_flag :
|
||||||
tdSql.error(sql=sql)
|
tdSql.error(sql=sql)
|
||||||
|
break
|
||||||
if len(tblist) == 2:
|
if len(tblist) == 2:
|
||||||
if "ct1" in tblist or "t1" in tblist:
|
if "ct1" in tblist or "t1" in tblist:
|
||||||
self.__join_current(sql, checkrows)
|
self.__join_current(sql, checkrows)
|
||||||
|
@ -111,42 +112,9 @@ class TDTestCase:
|
||||||
if len(tblist) > 2 or len(tblist) < 1:
|
if len(tblist) > 2 or len(tblist) < 1:
|
||||||
tdSql.error(sql=sql)
|
tdSql.error(sql=sql)
|
||||||
|
|
||||||
# def __join_err_check(self,tbname):
|
|
||||||
# sqls = []
|
|
||||||
|
|
||||||
# for un_char_col in NUM_COL:
|
|
||||||
# sqls.extend(
|
|
||||||
# (
|
|
||||||
# f"select length( {un_char_col} ) from {tbname} ",
|
|
||||||
# f"select length(ceil( {un_char_col} )) from {tbname} ",
|
|
||||||
# f"select {un_char_col} from {tbname} group by length( {un_char_col} ) ",
|
|
||||||
# )
|
|
||||||
# )
|
|
||||||
|
|
||||||
# sqls.extend( f"select length( {un_char_col} + {un_char_col_2} ) from {tbname} " for un_char_col_2 in NUM_COL )
|
|
||||||
# sqls.extend( f"select length( {un_char_col} + {ts_col} ) from {tbname} " for ts_col in TS_TYPE_COL )
|
|
||||||
|
|
||||||
# sqls.extend( f"select {char_col} from {tbname} group by length( {char_col} ) " for char_col in CHAR_COL)
|
|
||||||
# sqls.extend( f"select length( {ts_col} ) from {tbname} " for ts_col in TS_TYPE_COL )
|
|
||||||
# sqls.extend( f"select length( {char_col} + {ts_col} ) from {tbname} " for char_col in NUM_COL for ts_col in TS_TYPE_COL)
|
|
||||||
# sqls.extend( f"select length( {char_col} + {char_col_2} ) from {tbname} " for char_col in CHAR_COL for char_col_2 in CHAR_COL )
|
|
||||||
# sqls.extend( f"select upper({char_col}, 11) from {tbname} " for char_col in CHAR_COL )
|
|
||||||
# sqls.extend( f"select upper({char_col}) from {tbname} interval(2d) sliding(1d)" for char_col in CHAR_COL )
|
|
||||||
# sqls.extend(
|
|
||||||
# (
|
|
||||||
# f"select length() from {tbname} ",
|
|
||||||
# f"select length(*) from {tbname} ",
|
|
||||||
# f"select length(ccccccc) from {tbname} ",
|
|
||||||
# f"select length(111) from {tbname} ",
|
|
||||||
# f"select length(c8, 11) from {tbname} ",
|
|
||||||
# )
|
|
||||||
# )
|
|
||||||
|
|
||||||
# return sqls
|
|
||||||
|
|
||||||
def __join_current(self, sql, checkrows):
|
def __join_current(self, sql, checkrows):
|
||||||
tdSql.query(sql=sql)
|
tdSql.query(sql=sql)
|
||||||
tdSql.checkRows(checkrows)
|
# tdSql.checkRows(checkrows)
|
||||||
|
|
||||||
|
|
||||||
def __test_current(self):
|
def __test_current(self):
|
||||||
|
@ -197,10 +165,10 @@ class TDTestCase:
|
||||||
|
|
||||||
tbname = ["ct1", "ct2", "ct4", "t1"]
|
tbname = ["ct1", "ct2", "ct4", "t1"]
|
||||||
|
|
||||||
for tb in tbname:
|
# for tb in tbname:
|
||||||
for errsql in self.__length_err_check(tb):
|
# for errsql in self.__join_err_check(tb):
|
||||||
tdSql.error(sql=errsql)
|
# tdSql.error(sql=errsql)
|
||||||
tdLog.printNoPrefix(f"==========err sql condition check in {tb} over==========")
|
# tdLog.printNoPrefix(f"==========err sql condition check in {tb} over==========")
|
||||||
|
|
||||||
|
|
||||||
def all_test(self):
|
def all_test(self):
|
||||||
|
@ -319,13 +287,13 @@ class TDTestCase:
|
||||||
tdLog.printNoPrefix("==========step3:all check")
|
tdLog.printNoPrefix("==========step3:all check")
|
||||||
self.all_test()
|
self.all_test()
|
||||||
|
|
||||||
# tdDnodes.stop(1)
|
tdDnodes.stop(1)
|
||||||
# tdDnodes.start(1)
|
tdDnodes.start(1)
|
||||||
|
|
||||||
# tdSql.execute("use db")
|
tdSql.execute("use db")
|
||||||
|
|
||||||
# tdLog.printNoPrefix("==========step4:after wal, all check again ")
|
tdLog.printNoPrefix("==========step4:after wal, all check again ")
|
||||||
# self.all_test()
|
self.all_test()
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
tdSql.close()
|
tdSql.close()
|
||||||
|
|
|
@ -233,13 +233,13 @@ class TDTestCase:
|
||||||
tdLog.printNoPrefix("==========step3:all check")
|
tdLog.printNoPrefix("==========step3:all check")
|
||||||
self.all_test()
|
self.all_test()
|
||||||
|
|
||||||
# tdDnodes.stop(1)
|
tdDnodes.stop(1)
|
||||||
# tdDnodes.start(1)
|
tdDnodes.start(1)
|
||||||
|
|
||||||
# tdSql.execute("use db")
|
tdSql.execute("use db")
|
||||||
|
|
||||||
# tdLog.printNoPrefix("==========step4:after wal, all check again ")
|
tdLog.printNoPrefix("==========step4:after wal, all check again ")
|
||||||
# self.all_test()
|
self.all_test()
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
tdSql.close()
|
tdSql.close()
|
||||||
|
|
|
@ -59,12 +59,9 @@ class TDTestCase:
|
||||||
groups = ["", group_having, group_no_having]
|
groups = ["", group_having, group_no_having]
|
||||||
|
|
||||||
for group_condition in groups:
|
for group_condition in groups:
|
||||||
tdSql.query(f"select {condition} from {tbname} {where_condition} {group_condition} ")
|
tdSql.query(f"select lower( {condition} ), {condition} from {tbname} {where_condition} {group_condition}")
|
||||||
datas = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
for i in range(tdSql.queryRows):
|
||||||
lower_data = [ str(data).lower() if data else None for data in datas ]
|
tdSql.checkData(i, 0, str(tdSql.getData(i, 1)).lower() ) if tdSql.getData(i, 1) else tdSql.checkData(i, 0, None)
|
||||||
tdSql.query(f"select lower( {condition} ) from {tbname} {where_condition} {group_condition}")
|
|
||||||
for i in range(len(lower_data)):
|
|
||||||
tdSql.checkData(i, 0, lower_data[i] ) if lower_data[i] else tdSql.checkData(i, 0, None)
|
|
||||||
|
|
||||||
def __lower_err_check(self,tbname):
|
def __lower_err_check(self,tbname):
|
||||||
sqls = []
|
sqls = []
|
||||||
|
@ -230,13 +227,13 @@ class TDTestCase:
|
||||||
tdLog.printNoPrefix("==========step3:all check")
|
tdLog.printNoPrefix("==========step3:all check")
|
||||||
self.all_test()
|
self.all_test()
|
||||||
|
|
||||||
# tdDnodes.stop(1)
|
tdDnodes.stop(1)
|
||||||
# tdDnodes.start(1)
|
tdDnodes.start(1)
|
||||||
|
|
||||||
# tdSql.execute("use db")
|
tdSql.execute("use db")
|
||||||
|
|
||||||
# tdLog.printNoPrefix("==========step4:after wal, all check again ")
|
tdLog.printNoPrefix("==========step4:after wal, all check again ")
|
||||||
# self.all_test()
|
self.all_test()
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
tdSql.close()
|
tdSql.close()
|
||||||
|
|
|
@ -59,12 +59,9 @@ class TDTestCase:
|
||||||
groups = ["", group_having, group_no_having]
|
groups = ["", group_having, group_no_having]
|
||||||
|
|
||||||
for group_condition in groups:
|
for group_condition in groups:
|
||||||
tdSql.query(f"select {condition} from {tbname} {where_condition} {group_condition} ")
|
tdSql.query(f"select upper( {condition} ), {condition} from {tbname} {where_condition} {group_condition}")
|
||||||
datas = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
for i in range(tdSql.queryRows):
|
||||||
upper_data = [ str(data).upper() if data else None for data in datas ]
|
tdSql.checkData(i, 0, str(tdSql.getData(i, 1)).upper() ) if tdSql.getData(i, 1) else tdSql.checkData(i, 0, None)
|
||||||
tdSql.query(f"select upper( {condition} ) from {tbname} {where_condition} {group_condition}")
|
|
||||||
for i in range(len(upper_data)):
|
|
||||||
tdSql.checkData(i, 0, upper_data[i] ) if upper_data[i] else tdSql.checkData(i, 0, None)
|
|
||||||
|
|
||||||
def __upper_err_check(self,tbname):
|
def __upper_err_check(self,tbname):
|
||||||
sqls = []
|
sqls = []
|
||||||
|
@ -229,13 +226,13 @@ class TDTestCase:
|
||||||
tdLog.printNoPrefix("==========step3:all check")
|
tdLog.printNoPrefix("==========step3:all check")
|
||||||
self.all_test()
|
self.all_test()
|
||||||
|
|
||||||
# tdDnodes.stop(1)
|
tdDnodes.stop(1)
|
||||||
# tdDnodes.start(1)
|
tdDnodes.start(1)
|
||||||
|
|
||||||
# tdSql.execute("use db")
|
tdSql.execute("use db")
|
||||||
|
|
||||||
# tdLog.printNoPrefix("==========step4:after wal, all check again ")
|
tdLog.printNoPrefix("==========step4:after wal, all check again ")
|
||||||
# self.all_test()
|
self.all_test()
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
tdSql.close()
|
tdSql.close()
|
||||||
|
|
|
@ -13,6 +13,13 @@ python3 ./test.py -f 2-query/distinct.py
|
||||||
python3 ./test.py -f 2-query/varchar.py
|
python3 ./test.py -f 2-query/varchar.py
|
||||||
python3 ./test.py -f 2-query/ltrim.py
|
python3 ./test.py -f 2-query/ltrim.py
|
||||||
python3 ./test.py -f 2-query/rtrim.py
|
python3 ./test.py -f 2-query/rtrim.py
|
||||||
|
python3 ./test.py -f 2-query/length.py
|
||||||
|
python3 ./test.py -f 2-query/char_length.py
|
||||||
|
python3 ./test.py -f 2-query/upper.py
|
||||||
|
python3 ./test.py -f 2-query/lower.py
|
||||||
|
python3 ./test.py -f 2-query/join.py
|
||||||
|
# python3 ./test.py -f 2-query/concat.py # after wal ,crash occured
|
||||||
|
# python3 ./test.py -f 2-query/concat_ws.py
|
||||||
|
|
||||||
python3 ./test.py -f 2-query/timezone.py
|
python3 ./test.py -f 2-query/timezone.py
|
||||||
python3 ./test.py -f 2-query/Now.py
|
python3 ./test.py -f 2-query/Now.py
|
||||||
|
|
Loading…
Reference in New Issue