Merge pull request #3258 from taosdata/mergetodevelop
Merge from master into develop
This commit is contained in:
commit
3d655a7932
|
@ -66,6 +66,8 @@ CMakeError.log
|
|||
/test/cfg
|
||||
/src/.vs
|
||||
*.o
|
||||
version.c
|
||||
taos.rc
|
||||
src/connector/jdbc/.settings/
|
||||
tests/comparisonTest/cassandra/cassandratest/.classpath
|
||||
tests/comparisonTest/cassandra/cassandratest/.project
|
||||
|
|
|
@ -28,6 +28,7 @@ INCLUDE(cmake/input.inc)
|
|||
INCLUDE(cmake/platform.inc)
|
||||
INCLUDE(cmake/define.inc)
|
||||
INCLUDE(cmake/env.inc)
|
||||
INCLUDE(cmake/version.inc)
|
||||
INCLUDE(cmake/install.inc)
|
||||
|
||||
ADD_SUBDIRECTORY(deps)
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
PROJECT(TDengine)
|
||||
|
||||
SET(TD_VER_1 "2")
|
||||
SET(TD_VER_2 "0")
|
||||
SET(TD_VER_3 "2")
|
||||
SET(TD_VER_4 "3")
|
||||
SET(TD_VER_GIT "d711657139620f6c50f362597020705b8ad26bd2")
|
||||
SET(TD_VER_GIT_INTERNAL "1d74ae24c541ffbb280e8630883c0236cd45f8c7")
|
||||
|
||||
SET(TD_VER_VERTYPE "stable")
|
||||
SET(TD_VER_CPUTYPE "x64")
|
||||
SET(TD_VER_OSTYPE "Linux")
|
||||
|
||||
SET(TD_VER_COMPATIBLE "2.0.0.0")
|
||||
STRING(TIMESTAMP TD_VER_DATE "%Y-%m-%d %H:%M:%S")
|
||||
|
||||
IF (TD_LINUX_64)
|
||||
SET(TD_VER_CPUTYPE "x64")
|
||||
ENDIF ()
|
||||
|
||||
IF (TD_LINUX_32)
|
||||
SET(TD_VER_CPUTYPE "x86")
|
||||
ENDIF ()
|
||||
|
||||
IF (TD_ARM_64)
|
||||
SET(TD_VER_CPUTYPE "aarch64")
|
||||
ENDIF ()
|
||||
|
||||
IF (TD_ARM_32)
|
||||
SET(TD_VER_CPUTYPE "aarch32")
|
||||
ENDIF ()
|
||||
|
||||
IF (TD_WINDOWS_64)
|
||||
SET(TD_VER_CPUTYPE "x64")
|
||||
ENDIF ()
|
||||
|
||||
IF (TD_WINDOWS_32)
|
||||
SET(TD_VER_CPUTYPE "x86")
|
||||
ENDIF ()
|
||||
|
||||
CONFIGURE_FILE("${TD_COMMUNITY_DIR}/src/util/src/version.c.in" "${TD_COMMUNITY_DIR}/src/util/src/version.c")
|
|
@ -4,5 +4,5 @@ PROJECT(TDengine)
|
|||
IF (TD_WINDOWS)
|
||||
INCLUDE_DIRECTORIES(include)
|
||||
AUX_SOURCE_DIRECTORY(src SRC)
|
||||
ADD_LIBRARY(MsvcLibXw64 ${SRC})
|
||||
ADD_LIBRARY(MsvcLibXw ${SRC})
|
||||
ENDIF ()
|
||||
|
|
|
@ -12,6 +12,6 @@ ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib"
|
|||
ENV LANG=en_US.UTF-8
|
||||
ENV LANGUAGE=en_US:en
|
||||
ENV LC_ALL=en_US.UTF-8
|
||||
EXPOSE 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041
|
||||
EXPOSE 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042
|
||||
CMD ["taosd"]
|
||||
VOLUME [ "/var/lib/taos", "/var/log/taos","/etc/taos/" ]
|
||||
|
|
|
@ -10,6 +10,7 @@ set -e
|
|||
# -o [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | Ningsi60 | Ningsi80 |...]
|
||||
# -V [stable | beta]
|
||||
# -l [full | lite]
|
||||
# -s [static | dynamic]
|
||||
# -n [2.0.0.3]
|
||||
|
||||
# set parameters by default value
|
||||
|
@ -18,9 +19,10 @@ verType=stable # [stable, beta]
|
|||
cpuType=x64 # [aarch32 | aarch64 | x64 | x86 | mips64 ...]
|
||||
osType=Linux # [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | Ningsi60 | Ningsi80 |...]
|
||||
pagMode=full # [full | lite]
|
||||
soMode=dynamic # [static | dynamic]
|
||||
verNumber=""
|
||||
|
||||
while getopts "hv:V:c:o:l:n:" arg
|
||||
while getopts "hv:V:c:o:l:s:n:" arg
|
||||
do
|
||||
case $arg in
|
||||
v)
|
||||
|
@ -39,6 +41,10 @@ do
|
|||
#echo "pagMode=$OPTARG"
|
||||
pagMode=$(echo $OPTARG)
|
||||
;;
|
||||
s)
|
||||
#echo "soMode=$OPTARG"
|
||||
soMode=$(echo $OPTARG)
|
||||
;;
|
||||
n)
|
||||
#echo "verNumber=$OPTARG"
|
||||
verNumber=$(echo $OPTARG)
|
||||
|
@ -53,6 +59,7 @@ do
|
|||
echo " -o [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | Ningsi60 | Ningsi80 |...] "
|
||||
echo " -V [stable | beta] "
|
||||
echo " -l [full | lite] "
|
||||
echo " -s [static | dynamic] "
|
||||
echo " -n [version number] "
|
||||
exit 0
|
||||
;;
|
||||
|
@ -63,7 +70,7 @@ do
|
|||
esac
|
||||
done
|
||||
|
||||
echo "verMode=${verMode} verType=${verType} cpuType=${cpuType} osType=${osType} pagMode=${pagMode} verNumber=${verNumber}"
|
||||
echo "verMode=${verMode} verType=${verType} cpuType=${cpuType} osType=${osType} pagMode=${pagMode} soMode=${soMode} verNumber=${verNumber}"
|
||||
|
||||
curr_dir=$(pwd)
|
||||
|
||||
|
@ -223,9 +230,9 @@ cd ${compile_dir}
|
|||
# check support cpu type
|
||||
if [[ "$cpuType" == "x64" ]] || [[ "$cpuType" == "aarch64" ]] || [[ "$cpuType" == "aarch32" ]] || [[ "$cpuType" == "mips64" ]] ; then
|
||||
if [ "$verMode" != "cluster" ]; then
|
||||
cmake ../ -DCPUTYPE=${cpuType} -DPAGMODE=${pagMode} -DOSTYPE=${osType}
|
||||
cmake ../ -DCPUTYPE=${cpuType} -DPAGMODE=${pagMode} -DOSTYPE=${osType} -DSOMODE=${soMode}
|
||||
else
|
||||
cmake ../../ -DCPUTYPE=${cpuType} -DOSTYPE=${osType}
|
||||
cmake ../../ -DCPUTYPE=${cpuType} -DOSTYPE=${osType} -DSOMODE=${soMode}
|
||||
fi
|
||||
else
|
||||
echo "input cpuType=${cpuType} error!!!"
|
||||
|
|
|
@ -35,12 +35,14 @@ IF (TD_LINUX)
|
|||
ELSEIF (TD_WINDOWS)
|
||||
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/jni/windows)
|
||||
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/jni/windows/win32)
|
||||
|
||||
|
||||
CONFIGURE_FILE("${TD_COMMUNITY_DIR}/src/client/src/taos.rc.in" "${TD_COMMUNITY_DIR}/src/client/src/taos.rc")
|
||||
|
||||
ADD_LIBRARY(taos_static STATIC ${SRC})
|
||||
TARGET_LINK_LIBRARIES(taos_static trpc tutil query)
|
||||
|
||||
# generate dynamic library (*.dll)
|
||||
ADD_LIBRARY(taos SHARED ${SRC})
|
||||
ADD_LIBRARY(taos SHARED ${SRC} ${TD_COMMUNITY_DIR}/src/client/src/taos.rc)
|
||||
IF (NOT TD_GODLL)
|
||||
SET_TARGET_PROPERTIES(taos PROPERTIES LINK_FLAGS /DEF:${TD_COMMUNITY_DIR}/src/client/src/taos.def)
|
||||
ENDIF ()
|
||||
|
|
|
@ -108,7 +108,7 @@ int32_t tscCreateDataBlock(size_t initialSize, int32_t rowSize, int32_t startOff
|
|||
void tscDestroyDataBlock(STableDataBlocks* pDataBlock);
|
||||
void tscSortRemoveDataBlockDupRows(STableDataBlocks* dataBuf);
|
||||
|
||||
SParamInfo* tscAddParamToDataBlock(STableDataBlocks* pDataBlock, char type, uint8_t timePrec, short bytes,
|
||||
SParamInfo* tscAddParamToDataBlock(STableDataBlocks* pDataBlock, char type, uint8_t timePrec, int16_t bytes,
|
||||
uint32_t offset);
|
||||
|
||||
void* tscDestroyBlockArrayList(SArray* pDataBlockList);
|
||||
|
|
|
@ -234,7 +234,7 @@ typedef struct {
|
|||
char * curSql; // current sql, resume position of sql after parsing paused
|
||||
int8_t parseFinished;
|
||||
|
||||
short numOfCols;
|
||||
int16_t numOfCols;
|
||||
uint32_t allocSize;
|
||||
char * payload;
|
||||
int32_t payloadLen;
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
1 VERSIONINFO
|
||||
FILEVERSION ${TD_VER_1}, ${TD_VER_2}, ${TD_VER_3}
|
||||
PRODUCTVERSION ${TD_VER_1}, ${TD_VER_2}, ${TD_VER_3}
|
||||
FILEFLAGSMASK 0x17L
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x4L
|
||||
FILETYPE 0x0L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "FileDescription", "Native C Driver for TDengine"
|
||||
VALUE "FileVersion", "${TD_VER_1}, ${TD_VER_2}, ${TD_VER_3}"
|
||||
VALUE "InternalName", "taos.dll(${TD_VER_CPUTYPE})"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2020 TAOS Data"
|
||||
VALUE "OriginalFilename", ""
|
||||
VALUE "ProductName", "taos.dll(${TD_VER_CPUTYPE})"
|
||||
VALUE "ProductVersion", "${TD_VER_1}.${TD_VER_2}.${TD_VER_3}.${TD_VER_4}"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
|
@ -201,7 +201,7 @@ TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass,
|
|||
}
|
||||
|
||||
TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port) {
|
||||
tscDebug("try to create a connection to %s:%u, user:%s db:%s", ip, port, user, db);
|
||||
tscDebug("try to create a connection to %s:%u, user:%s db:%s", ip, port != 0 ? port : tsServerPort , user, db);
|
||||
if (user == NULL) user = TSDB_DEFAULT_USER;
|
||||
if (pass == NULL) pass = TSDB_DEFAULT_PASS;
|
||||
|
||||
|
|
|
@ -404,7 +404,7 @@ void tscDestroyDataBlock(STableDataBlocks* pDataBlock) {
|
|||
taosTFree(pDataBlock);
|
||||
}
|
||||
|
||||
SParamInfo* tscAddParamToDataBlock(STableDataBlocks* pDataBlock, char type, uint8_t timePrec, short bytes,
|
||||
SParamInfo* tscAddParamToDataBlock(STableDataBlocks* pDataBlock, char type, uint8_t timePrec, int16_t bytes,
|
||||
uint32_t offset) {
|
||||
uint32_t needed = pDataBlock->numOfParams + 1;
|
||||
if (needed > pDataBlock->numOfAllocedParams) {
|
||||
|
|
|
@ -29,6 +29,7 @@ extern uint16_t tsServerPort;
|
|||
extern uint16_t tsDnodeShellPort;
|
||||
extern uint16_t tsDnodeDnodePort;
|
||||
extern uint16_t tsSyncPort;
|
||||
extern uint16_t tsArbitratorPort;
|
||||
extern int32_t tsStatusInterval;
|
||||
extern int32_t tsNumOfMnodes;
|
||||
extern int32_t tsEnableVnodeBak;
|
||||
|
|
|
@ -37,6 +37,7 @@ uint16_t tsServerPort = 6030;
|
|||
uint16_t tsDnodeShellPort = 6030; // udp[6035-6039] tcp[6035]
|
||||
uint16_t tsDnodeDnodePort = 6035; // udp/tcp
|
||||
uint16_t tsSyncPort = 6040;
|
||||
uint16_t tsArbitratorPort = 6042;
|
||||
int32_t tsStatusInterval = 1; // second
|
||||
int32_t tsNumOfMnodes = 3;
|
||||
int32_t tsEnableVnodeBak = 1;
|
||||
|
@ -1331,7 +1332,10 @@ int taosGetFqdnPortFromEp(const char *ep, char *fqdn, uint16_t *port) {
|
|||
*port = atoi(temp+1);
|
||||
}
|
||||
|
||||
if (*port == 0) *port = tsServerPort;
|
||||
if (*port == 0) {
|
||||
*port = tsServerPort;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ DLL_EXPORT int taos_result_precision(TAOS_RES *res); // get the time precision
|
|||
DLL_EXPORT void taos_free_result(TAOS_RES *res);
|
||||
DLL_EXPORT int taos_field_count(TAOS_RES *tres);
|
||||
DLL_EXPORT int taos_num_fields(TAOS_RES *res);
|
||||
DLL_EXPORT int taos_affected_rows(TAOS_RES *taos);
|
||||
DLL_EXPORT int taos_affected_rows(TAOS_RES *res);
|
||||
DLL_EXPORT TAOS_FIELD *taos_fetch_fields(TAOS_RES *res);
|
||||
DLL_EXPORT int taos_select_db(TAOS *taos, const char *db);
|
||||
DLL_EXPORT int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields);
|
||||
|
|
|
@ -63,7 +63,7 @@ typedef struct tstr {
|
|||
extern const int32_t TYPE_BYTES[11];
|
||||
// TODO: replace and remove code below
|
||||
#define CHAR_BYTES sizeof(char)
|
||||
#define SHORT_BYTES sizeof(short)
|
||||
#define SHORT_BYTES sizeof(int16_t)
|
||||
#define INT_BYTES sizeof(int)
|
||||
#define LONG_BYTES sizeof(int64_t)
|
||||
#define FLOAT_BYTES sizeof(float)
|
||||
|
|
|
@ -66,6 +66,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_RPC_INVALID_MSG_TYPE, 0, 0x0011, "Invalid me
|
|||
TAOS_DEFINE_ERROR(TSDB_CODE_RPC_INVALID_RESPONSE_TYPE, 0, 0x0012, "Invalid response type")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_RPC_INVALID_TIME_STAMP, 0, 0x0013, "Invalid timestamp")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_APP_NOT_READY, 0, 0x0014, "Database not ready")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_RPC_FQDN_ERROR, 0, 0x0015, "Unable to resolve FQDN")
|
||||
|
||||
//common & util
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_COM_OPS_NOT_SUPPORT, 0, 0x0100, "Operation not supported")
|
||||
|
|
|
@ -424,7 +424,10 @@ typedef struct SColumnInfo {
|
|||
int16_t type;
|
||||
int16_t bytes;
|
||||
int16_t numOfFilters;
|
||||
SColumnFilterInfo *filters;
|
||||
union{
|
||||
int64_t placeholder;
|
||||
SColumnFilterInfo *filters;
|
||||
};
|
||||
} SColumnInfo;
|
||||
|
||||
typedef struct STableIdInfo {
|
||||
|
|
|
@ -27,35 +27,46 @@
|
|||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <wordexp.h>
|
||||
|
||||
#define MAX_PKG_LEN (64*1000)
|
||||
#define BUFFER_SIZE (MAX_PKG_LEN + 1024)
|
||||
#define MAX_PKG_LEN (64*1000)
|
||||
#define BUFFER_SIZE (MAX_PKG_LEN + 1024)
|
||||
#define TEST_FQDN_LEN 128
|
||||
#define TEST_IPv4ADDR_LEN 16
|
||||
|
||||
typedef struct {
|
||||
int port;
|
||||
char *host;
|
||||
uint16_t port;
|
||||
uint32_t hostIp;
|
||||
char fqdn[TEST_FQDN_LEN];
|
||||
uint16_t pktLen;
|
||||
} info_s;
|
||||
|
||||
typedef struct Arguments {
|
||||
char * host;
|
||||
char host[TEST_IPv4ADDR_LEN];
|
||||
char fqdn[TEST_FQDN_LEN];
|
||||
uint16_t port;
|
||||
uint16_t max_port;
|
||||
uint16_t pktLen;
|
||||
} SArguments;
|
||||
|
||||
static struct argp_option options[] = {
|
||||
{0, 'h', "host", 0, "The host to connect to TDEngine. Default is localhost.", 0},
|
||||
{0, 'h', "host ip", 0, "The host ip to connect to TDEngine. Default is localhost.", 0},
|
||||
{0, 'p', "port", 0, "The TCP or UDP port number to use for the connection. Default is 6030.", 1},
|
||||
{0, 'm', "max port", 0, "The max TCP or UDP port number to use for the connection. Default is 6060.", 2},
|
||||
{0, 'm', "max port", 0, "The max TCP or UDP port number to use for the connection. Default is 6042.", 2},
|
||||
{0, 'f', "host fqdn", 0, "The host fqdn to connect to TDEngine.", 3},
|
||||
{0, 'l', "test pkg len", 0, "The len of pkg for test. Default is 1000 Bytes, max not greater than 64k Bytes.\nNotes: This parameter must be consistent between the client and the server.", 3}};
|
||||
|
||||
static error_t parse_opt(int key, char *arg, struct argp_state *state) {
|
||||
|
||||
wordexp_t full_path;
|
||||
SArguments *arguments = state->input;
|
||||
switch (key) {
|
||||
case 'h':
|
||||
arguments->host = arg;
|
||||
if (wordexp(arg, &full_path, 0) != 0) {
|
||||
fprintf(stderr, "Invalid host ip %s\n", arg);
|
||||
return -1;
|
||||
}
|
||||
strcpy(arguments->host, full_path.we_wordv[0]);
|
||||
wordfree(&full_path);
|
||||
break;
|
||||
case 'p':
|
||||
arguments->port = atoi(arg);
|
||||
|
@ -66,6 +77,14 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
|
|||
case 'l':
|
||||
arguments->pktLen = atoi(arg);
|
||||
break;
|
||||
case 'f':
|
||||
if (wordexp(arg, &full_path, 0) != 0) {
|
||||
fprintf(stderr, "Invalid host fqdn %s\n", arg);
|
||||
return -1;
|
||||
}
|
||||
strcpy(arguments->fqdn, full_path.we_wordv[0]);
|
||||
wordfree(&full_path);
|
||||
break;
|
||||
|
||||
default:
|
||||
return ARGP_ERR_UNKNOWN;
|
||||
|
@ -76,8 +95,6 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
|
|||
static struct argp argp = {options, parse_opt, 0, 0};
|
||||
|
||||
int checkTcpPort(info_s *info) {
|
||||
int port = info->port;
|
||||
char *host = info->host;
|
||||
int clientSocket;
|
||||
|
||||
struct sockaddr_in serverAddr;
|
||||
|
@ -88,21 +105,35 @@ int checkTcpPort(info_s *info) {
|
|||
printf("socket() fail: %s\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
serverAddr.sin_family = AF_INET;
|
||||
serverAddr.sin_port = htons(port);
|
||||
|
||||
serverAddr.sin_addr.s_addr = inet_addr(host);
|
||||
// set send and recv overtime
|
||||
struct timeval timeout;
|
||||
timeout.tv_sec = 2; //s
|
||||
timeout.tv_usec = 0; //us
|
||||
if (setsockopt(clientSocket, SOL_SOCKET,SO_SNDTIMEO, (char *)&timeout, sizeof(struct timeval)) == -1) {
|
||||
perror("setsockopt send timer failed:");
|
||||
}
|
||||
if (setsockopt(clientSocket, SOL_SOCKET,SO_RCVTIMEO, (char *)&timeout, sizeof(struct timeval)) == -1) {
|
||||
perror("setsockopt recv timer failed:");
|
||||
}
|
||||
|
||||
serverAddr.sin_family = AF_INET;
|
||||
serverAddr.sin_port = htons(info->port);
|
||||
|
||||
serverAddr.sin_addr.s_addr = info->hostIp;
|
||||
|
||||
//printf("=================================\n");
|
||||
if (connect(clientSocket, (struct sockaddr *)&serverAddr, sizeof(serverAddr)) < 0) {
|
||||
printf("connect() fail: %s\n", strerror(errno));
|
||||
printf("connect() fail: %s\t", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
//printf("Connect to: %s:%d...success\n", host, port);
|
||||
memset(sendbuf, 0, BUFFER_SIZE);
|
||||
memset(recvbuf, 0, BUFFER_SIZE);
|
||||
|
||||
sprintf(sendbuf, "client send tcp pkg to %s:%d, content: 1122334455", host, port);
|
||||
struct in_addr ipStr;
|
||||
memcpy(&ipStr, &info->hostIp, 4);
|
||||
sprintf(sendbuf, "client send tcp pkg to %s:%d, content: 1122334455", inet_ntoa(ipStr), info->port);
|
||||
sprintf(sendbuf + info->pktLen - 16, "1122334455667788");
|
||||
|
||||
send(clientSocket, sendbuf, info->pktLen, 0);
|
||||
|
@ -120,7 +151,7 @@ int checkTcpPort(info_s *info) {
|
|||
if (errno == EINTR) {
|
||||
continue;
|
||||
} else {
|
||||
printf("recv ack pkg from TCP port: %d fail:%s.\n", port, strerror(errno));
|
||||
printf("recv ack pkg from TCP port: %d fail:%s.\n", info->port, strerror(errno));
|
||||
close(clientSocket);
|
||||
return -1;
|
||||
}
|
||||
|
@ -132,7 +163,7 @@ int checkTcpPort(info_s *info) {
|
|||
}
|
||||
|
||||
if (iDataNum < info->pktLen) {
|
||||
printf("recv ack pkg len: %d, less than req pkg len: %d from tcp port: %d\n", iDataNum, info->pktLen, port);
|
||||
printf("recv ack pkg len: %d, less than req pkg len: %d from tcp port: %d\n", iDataNum, info->pktLen, info->port);
|
||||
return -1;
|
||||
}
|
||||
//printf("Read ack pkg len:%d from tcp port: %d, buffer: %s %s\n", info->pktLen, port, recvbuf, recvbuf+iDataNum-8);
|
||||
|
@ -142,8 +173,6 @@ int checkTcpPort(info_s *info) {
|
|||
}
|
||||
|
||||
int checkUdpPort(info_s *info) {
|
||||
int port = info->port;
|
||||
char *host = info->host;
|
||||
int clientSocket;
|
||||
|
||||
struct sockaddr_in serverAddr;
|
||||
|
@ -154,15 +183,28 @@ int checkUdpPort(info_s *info) {
|
|||
perror("socket");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// set overtime
|
||||
struct timeval timeout;
|
||||
timeout.tv_sec = 2; //s
|
||||
timeout.tv_usec = 0; //us
|
||||
if (setsockopt(clientSocket, SOL_SOCKET,SO_SNDTIMEO, (char *)&timeout, sizeof(struct timeval)) == -1) {
|
||||
perror("setsockopt send timer failed:");
|
||||
}
|
||||
if (setsockopt(clientSocket, SOL_SOCKET,SO_RCVTIMEO, (char *)&timeout, sizeof(struct timeval)) == -1) {
|
||||
perror("setsockopt recv timer failed:");
|
||||
}
|
||||
|
||||
serverAddr.sin_family = AF_INET;
|
||||
serverAddr.sin_port = htons(port);
|
||||
serverAddr.sin_addr.s_addr = inet_addr(host);
|
||||
serverAddr.sin_port = htons(info->port);
|
||||
serverAddr.sin_addr.s_addr = info->hostIp;
|
||||
|
||||
memset(sendbuf, 0, BUFFER_SIZE);
|
||||
memset(recvbuf, 0, BUFFER_SIZE);
|
||||
|
||||
sprintf(sendbuf, "client send udp pkg to %s:%d, content: 1122334455", host, port);
|
||||
struct in_addr ipStr;
|
||||
memcpy(&ipStr, &info->hostIp, 4);
|
||||
sprintf(sendbuf, "client send udp pkg to %s:%d, content: 1122334455", inet_ntoa(ipStr), info->port);
|
||||
sprintf(sendbuf + info->pktLen - 16, "1122334455667788");
|
||||
|
||||
socklen_t sin_size = sizeof(*(struct sockaddr *)&serverAddr);
|
||||
|
@ -176,7 +218,7 @@ int checkUdpPort(info_s *info) {
|
|||
iDataNum = recvfrom(clientSocket, recvbuf, BUFFER_SIZE, 0, (struct sockaddr *)&serverAddr, &sin_size);
|
||||
|
||||
if (iDataNum < info->pktLen) {
|
||||
printf("Read ack pkg len: %d, less than req pkg len: %d from udp port: %d\n", iDataNum, info->pktLen, port);
|
||||
printf("Read ack pkg len: %d, less than req pkg len: %d from udp port: %d\t\t", iDataNum, info->pktLen, info->port);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -185,10 +227,61 @@ int checkUdpPort(info_s *info) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
SArguments arguments = {"127.0.0.1", 6030, 6060, 1000};
|
||||
info_s info;
|
||||
int32_t getIpFromFqdn(const char *fqdn, uint32_t* ip) {
|
||||
struct addrinfo hints = {0};
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
|
||||
struct addrinfo *result = NULL;
|
||||
|
||||
int32_t ret = getaddrinfo(fqdn, NULL, &hints, &result);
|
||||
if (result) {
|
||||
struct sockaddr *sa = result->ai_addr;
|
||||
struct sockaddr_in *si = (struct sockaddr_in*)sa;
|
||||
struct in_addr ia = si->sin_addr;
|
||||
*ip = ia.s_addr;
|
||||
freeaddrinfo(result);
|
||||
return 0;
|
||||
} else {
|
||||
printf("Failed get the ip address from fqdn:%s, code:%d, reason:%s", fqdn, ret, gai_strerror(ret));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
void checkPort(uint32_t hostIp, uint16_t startPort, uint16_t maxPort, uint16_t pktLen) {
|
||||
int ret;
|
||||
info_s info;
|
||||
memset(&info, 0, sizeof(info_s));
|
||||
info.hostIp = hostIp;
|
||||
info.pktLen = pktLen;
|
||||
|
||||
for (uint16_t port = startPort; port <= maxPort; port++) {
|
||||
//printf("test: %s:%d\n", info.host, port);
|
||||
printf("\n");
|
||||
|
||||
info.port = port;
|
||||
ret = checkTcpPort(&info);
|
||||
if (ret != 0) {
|
||||
printf("tcp port:%d test fail.\t\n", port);
|
||||
} else {
|
||||
printf("tcp port:%d test ok.\t\t", port);
|
||||
}
|
||||
|
||||
ret = checkUdpPort(&info);
|
||||
if (ret != 0) {
|
||||
printf("udp port:%d test fail.\t\n", port);
|
||||
} else {
|
||||
printf("udp port:%d test ok.\t\t", port);
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
return ;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
SArguments arguments = {"127.0.0.1", "", 6030, 6042, 1000};
|
||||
int ret;
|
||||
|
||||
argp_parse(&argp, argc, argv, 0, 0, &arguments);
|
||||
if (arguments.pktLen > MAX_PKG_LEN) {
|
||||
|
@ -196,32 +289,25 @@ int main(int argc, char *argv[]) {
|
|||
exit(0);
|
||||
}
|
||||
|
||||
printf("host: %s\tport: %d\tmax_port: %d\tpkgLen: %d\n", arguments.host, arguments.port, arguments.max_port, arguments.pktLen);
|
||||
printf("host ip: %s\thost fqdn: %s\tport: %d\tmax_port: %d\tpkgLen: %d\n", arguments.host, arguments.fqdn, arguments.port, arguments.max_port, arguments.pktLen);
|
||||
|
||||
int port = arguments.port;
|
||||
|
||||
info.host = arguments.host;
|
||||
info.pktLen = arguments.pktLen;
|
||||
|
||||
for (; port <= arguments.max_port; port++) {
|
||||
//printf("test: %s:%d\n", info.host, port);
|
||||
if (arguments.host[0] != 0) {
|
||||
printf("\nstart connect to %s test:\n", arguments.host);
|
||||
checkPort(inet_addr(arguments.host), arguments.port, arguments.max_port, arguments.pktLen);
|
||||
printf("\n");
|
||||
|
||||
info.port = port;
|
||||
ret = checkTcpPort(&info);
|
||||
if (ret != 0) {
|
||||
printf("tcp port:%d test fail.\t\t", port);
|
||||
} else {
|
||||
printf("tcp port:%d test ok.\t\t", port);
|
||||
}
|
||||
|
||||
ret = checkUdpPort(&info);
|
||||
if (ret != 0) {
|
||||
printf("udp port:%d test fail.\t\t", port);
|
||||
} else {
|
||||
printf("udp port:%d test ok.\t\t", port);
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
if (arguments.fqdn[0] != 0) {
|
||||
uint32_t hostIp = 0;
|
||||
ret = getIpFromFqdn(arguments.fqdn, &hostIp);
|
||||
if (ret) {
|
||||
printf("\n");
|
||||
return 0;
|
||||
}
|
||||
printf("\nstart connetc to %s test:\n", arguments.fqdn);
|
||||
checkPort(hostIp, arguments.port, arguments.max_port, arguments.pktLen);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -142,9 +142,9 @@ static void *bindTcpPort(void *sarg) {
|
|||
printf("recv Client: %s pkg from TCP port: %d, pkg len: %d\n", inet_ntoa(clientAddr.sin_addr), port, iDataNum);
|
||||
if (iDataNum > 0) {
|
||||
send(client, buffer, iDataNum, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
close(serverSocket);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ static void *bindUdpPort(void *sarg) {
|
|||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
SArguments arguments = {"127.0.0.1", 6030, 6060, 1000};
|
||||
SArguments arguments = {"127.0.0.1", 6030, 6042, 1000};
|
||||
argp_parse(&argp, argc, argv, 0, 0, &arguments);
|
||||
if (arguments.pktLen > MAX_PKG_LEN) {
|
||||
printf("test pkg len overflow: %d, max len not greater than %d bytes\n", arguments.pktLen, MAX_PKG_LEN);
|
||||
|
|
|
@ -354,7 +354,7 @@ static int32_t mnodeCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate, SMnodeMsg
|
|||
mDebug("db:%s, already exist, ignore exist is set", pCreate->db);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
} else {
|
||||
mError("db:%s, is already exist, ignore exist not set", pCreate->db);
|
||||
mError("db:%s, already exist, ignore exist not set", pCreate->db);
|
||||
return TSDB_CODE_MND_DB_ALREADY_EXIST;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -518,7 +518,7 @@ static int32_t mnodeCreateDnode(char *ep, SMnodeMsg *pMsg) {
|
|||
SDnodeObj *pDnode = mnodeGetDnodeByEp(ep);
|
||||
if (pDnode != NULL) {
|
||||
mnodeDecDnodeRef(pDnode);
|
||||
mError("dnode:%d is already exist, %s:%d", pDnode->dnodeId, pDnode->dnodeFqdn, pDnode->dnodePort);
|
||||
mError("dnode:%d, already exist, %s:%d", pDnode->dnodeId, pDnode->dnodeFqdn, pDnode->dnodePort);
|
||||
return TSDB_CODE_MND_DNODE_ALREADY_EXIST;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,4 +4,4 @@ PROJECT(TDengine)
|
|||
AUX_SOURCE_DIRECTORY(. SRC)
|
||||
ADD_LIBRARY(os ${SRC})
|
||||
|
||||
TARGET_LINK_LIBRARIES(os winmm IPHLPAPI ws2_32 MsvcLibXw64)
|
||||
TARGET_LINK_LIBRARIES(os winmm IPHLPAPI ws2_32 MsvcLibXw)
|
||||
|
|
|
@ -563,7 +563,7 @@ static SRpcConn *rpcOpenConn(SRpcInfo *pRpc, char *peerFqdn, uint16_t peerPort,
|
|||
uint32_t peerIp = taosGetIpFromFqdn(peerFqdn);
|
||||
if (peerIp == 0xFFFFFFFF) {
|
||||
tError("%s, failed to resolve FQDN:%s", pRpc->label, peerFqdn);
|
||||
terrno = TSDB_CODE_RPC_APP_ERROR;
|
||||
terrno = TSDB_CODE_RPC_FQDN_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ typedef void* tthread_h;
|
|||
typedef struct {
|
||||
int numOfThreads;
|
||||
uint32_t serverIp;
|
||||
short port;
|
||||
int16_t port;
|
||||
int bufferSize;
|
||||
void (*processBrokenLink)(void *ahandle);
|
||||
int (*processIncomingMsg)(void *ahandle, void *buffer);
|
||||
|
|
|
@ -413,9 +413,11 @@ static void syncAddArbitrator(SSyncNode *pNode)
|
|||
|
||||
SNodeInfo nodeInfo;
|
||||
nodeInfo.nodeId = 0;
|
||||
taosGetFqdnPortFromEp(tsArbitrator, nodeInfo.nodeFqdn, &nodeInfo.nodePort);
|
||||
nodeInfo.nodePort += TSDB_PORT_SYNC;
|
||||
|
||||
int ret = taosGetFqdnPortFromEp(tsArbitrator, nodeInfo.nodeFqdn, &nodeInfo.nodePort);
|
||||
if (-1 == ret) {
|
||||
nodeInfo.nodePort = tsArbitratorPort;
|
||||
}
|
||||
|
||||
if (pPeer) {
|
||||
if ((strcmp(nodeInfo.nodeFqdn, pPeer->fqdn) == 0) && (nodeInfo.nodePort == pPeer->port)) {
|
||||
return;
|
||||
|
|
|
@ -40,13 +40,9 @@ typedef struct {
|
|||
void *pConn;
|
||||
} SNodeConn;
|
||||
|
||||
uint16_t tsArbitratorPort = 0;
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
char arbLogPath[TSDB_FILENAME_LEN + 16] = {0};
|
||||
|
||||
tsArbitratorPort = tsServerPort + TSDB_PORT_ARBITRATOR;
|
||||
|
||||
for (int i=1; i<argc; ++i) {
|
||||
if (strcmp(argv[i], "-p")==0 && i < argc-1) {
|
||||
tsArbitratorPort = atoi(argv[++i]);
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
char version[12] = "2.0.2.0";
|
||||
char compatible_version[12] = "2.0.0.0";
|
||||
char gitinfo[48] = "d711657139620f6c50f362597020705b8ad26bd2";
|
||||
char gitinfoOfInternal[48] = "1d74ae24c541ffbb280e8630883c0236cd45f8c7";
|
||||
char buildinfo[64] = "Built by root at 2020-08-24 16:31";
|
||||
|
||||
void libtaos_2_0_2_0_Linux_x64_beta() {};
|
|
@ -0,0 +1,7 @@
|
|||
char version[12] = "${TD_VER_1}.${TD_VER_2}.${TD_VER_3}.${TD_VER_4}";
|
||||
char compatible_version[12] = "${TD_VER_COMPATIBLE}";
|
||||
char gitinfo[48] = "${TD_VER_GIT}";
|
||||
char gitinfoOfInternal[48] = "${TD_VER_GIT_INTERNAL}";
|
||||
char buildinfo[64] = "Built at ${TD_VER_DATE}";
|
||||
|
||||
void libtaos_${TD_VER_1}_${TD_VER_2}_${TD_VER_3}_${TD_VER_4}_${TD_VER_OSTYPE}_${TD_VER_CPUTYPE}_${TD_VER_VERTYPE}() {};
|
|
@ -549,7 +549,7 @@ static int vnodeGetWalInfo(void *ahandle, char *name, uint32_t *index) {
|
|||
|
||||
static void vnodeNotifyRole(void *ahandle, int8_t role) {
|
||||
SVnodeObj *pVnode = ahandle;
|
||||
vInfo("vgId:%d, sync role changed from %d to %d", pVnode->vgId, pVnode->role, role);
|
||||
vInfo("vgId:%d, sync role changed from %s to %s", pVnode->vgId, syncRole[pVnode->role], syncRole[role]);
|
||||
pVnode->role = role;
|
||||
dnodeSendStatusMsgToMnode();
|
||||
|
||||
|
|
|
@ -20,16 +20,17 @@ using System.Runtime.InteropServices;
|
|||
namespace TDengineDriver
|
||||
{
|
||||
enum TDengineDataType {
|
||||
TSDB_DATA_TYPE_BOOL = 1,
|
||||
TSDB_DATA_TYPE_TINYINT = 2,
|
||||
TSDB_DATA_TYPE_SMALLINT = 3,
|
||||
TSDB_DATA_TYPE_INT = 4,
|
||||
TSDB_DATA_TYPE_BIGINT = 5,
|
||||
TSDB_DATA_TYPE_FLOAT = 6,
|
||||
TSDB_DATA_TYPE_DOUBLE = 7,
|
||||
TSDB_DATA_TYPE_BINARY = 8,
|
||||
TSDB_DATA_TYPE_TIMESTAMP = 9,
|
||||
TSDB_DATA_TYPE_NCHAR = 10
|
||||
TSDB_DATA_TYPE_NULL = 0, // 1 bytes
|
||||
TSDB_DATA_TYPE_BOOL = 1, // 1 bytes
|
||||
TSDB_DATA_TYPE_TINYINT = 2, // 1 bytes
|
||||
TSDB_DATA_TYPE_SMALLINT = 3, // 2 bytes
|
||||
TSDB_DATA_TYPE_INT = 4, // 4 bytes
|
||||
TSDB_DATA_TYPE_BIGINT = 5, // 8 bytes
|
||||
TSDB_DATA_TYPE_FLOAT = 6, // 4 bytes
|
||||
TSDB_DATA_TYPE_DOUBLE = 7, // 8 bytes
|
||||
TSDB_DATA_TYPE_BINARY = 8, // string
|
||||
TSDB_DATA_TYPE_TIMESTAMP = 9,// 8 bytes
|
||||
TSDB_DATA_TYPE_NCHAR = 10 // unicode string
|
||||
}
|
||||
|
||||
enum TDengineInitOption
|
||||
|
@ -79,54 +80,53 @@ namespace TDengineDriver
|
|||
class TDengine
|
||||
{
|
||||
public const int TSDB_CODE_SUCCESS = 0;
|
||||
|
||||
[DllImport("taos.dll", EntryPoint = "taos_init", CallingConvention = CallingConvention.StdCall)]
|
||||
|
||||
[DllImport("taos.dll", EntryPoint = "taos_init", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern public void Init();
|
||||
|
||||
[DllImport("taos.dll", EntryPoint = "taos_options", CallingConvention = CallingConvention.StdCall)]
|
||||
[DllImport("taos.dll", EntryPoint = "taos_cleanup", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern public void Cleanup();
|
||||
|
||||
[DllImport("taos.dll", EntryPoint = "taos_options", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern public void Options(int option, string value);
|
||||
|
||||
[DllImport("taos.dll", EntryPoint = "taos_connect", CallingConvention = CallingConvention.StdCall)]
|
||||
static extern public long Connect(string ip, string user, string password, string db, int port);
|
||||
[DllImport("taos.dll", EntryPoint = "taos_connect", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern public IntPtr Connect(string ip, string user, string password, string db, short port);
|
||||
|
||||
[DllImport("taos.dll", EntryPoint = "taos_errstr", CallingConvention = CallingConvention.StdCall)]
|
||||
static extern private IntPtr taos_errstr(long taos);
|
||||
static public string Error(long conn)
|
||||
[DllImport("taos.dll", EntryPoint = "taos_errstr", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern private IntPtr taos_errstr(IntPtr res);
|
||||
static public string Error(IntPtr res)
|
||||
{
|
||||
IntPtr errPtr = taos_errstr(conn);
|
||||
IntPtr errPtr = taos_errstr(res);
|
||||
return Marshal.PtrToStringAnsi(errPtr);
|
||||
}
|
||||
|
||||
[DllImport("taos.dll", EntryPoint = "taos_errno", CallingConvention = CallingConvention.StdCall)]
|
||||
static extern public int ErrorNo(long taos);
|
||||
[DllImport("taos.dll", EntryPoint = "taos_errno", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern public int ErrorNo(IntPtr res);
|
||||
|
||||
[DllImport("taos.dll", EntryPoint = "taos_query", CallingConvention = CallingConvention.StdCall)]
|
||||
static extern public int Query(long taos, string sqlstr);
|
||||
[DllImport("taos.dll", EntryPoint = "taos_query", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern public IntPtr Query(IntPtr conn, string sqlstr);
|
||||
|
||||
[DllImport("taos.dll", EntryPoint = "taos_affected_rows", CallingConvention = CallingConvention.StdCall)]
|
||||
static extern public int AffectRows(long taos);
|
||||
[DllImport("taos.dll", EntryPoint = "taos_affected_rows", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern public int AffectRows(IntPtr res);
|
||||
|
||||
[DllImport("taos.dll", EntryPoint = "taos_use_result", CallingConvention = CallingConvention.StdCall)]
|
||||
static extern public long UseResult(long taos);
|
||||
[DllImport("taos.dll", EntryPoint = "taos_field_count", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern public int FieldCount(IntPtr res);
|
||||
|
||||
[DllImport("taos.dll", EntryPoint = "taos_field_count", CallingConvention = CallingConvention.StdCall)]
|
||||
static extern public int FieldCount(long taos);
|
||||
|
||||
[DllImport("taos.dll", EntryPoint = "taos_fetch_fields", CallingConvention = CallingConvention.StdCall)]
|
||||
static extern private IntPtr taos_fetch_fields(long res);
|
||||
static public List<TDengineMeta> FetchFields(long taos)
|
||||
[DllImport("taos.dll", EntryPoint = "taos_fetch_fields", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern private IntPtr taos_fetch_fields(IntPtr res);
|
||||
static public List<TDengineMeta> FetchFields(IntPtr res)
|
||||
{
|
||||
const int fieldSize = 68;
|
||||
|
||||
List<TDengineMeta> metas = new List<TDengineMeta>();
|
||||
long result = TDengine.UseResult(taos);
|
||||
if (result == 0)
|
||||
if (res == IntPtr.Zero)
|
||||
{
|
||||
return metas;
|
||||
}
|
||||
|
||||
int fieldCount = FieldCount(taos);
|
||||
IntPtr fieldsPtr = taos_fetch_fields(result);
|
||||
int fieldCount = FieldCount(res);
|
||||
IntPtr fieldsPtr = taos_fetch_fields(res);
|
||||
|
||||
for (int i = 0; i < fieldCount; ++i)
|
||||
{
|
||||
|
@ -134,21 +134,21 @@ namespace TDengineDriver
|
|||
|
||||
TDengineMeta meta = new TDengineMeta();
|
||||
meta.name = Marshal.PtrToStringAnsi(fieldsPtr + offset);
|
||||
meta.size = Marshal.ReadInt16(fieldsPtr + offset + 64);
|
||||
meta.type = Marshal.ReadByte(fieldsPtr + offset + 66);
|
||||
meta.type = Marshal.ReadByte(fieldsPtr + offset + 65);
|
||||
meta.size = Marshal.ReadInt16(fieldsPtr + offset + 66);
|
||||
metas.Add(meta);
|
||||
}
|
||||
|
||||
return metas;
|
||||
}
|
||||
|
||||
[DllImport("taos.dll", EntryPoint = "taos_fetch_row", CallingConvention = CallingConvention.StdCall)]
|
||||
static extern public IntPtr FetchRows(long res);
|
||||
[DllImport("taos.dll", EntryPoint = "taos_fetch_row", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern public IntPtr FetchRows(IntPtr res);
|
||||
|
||||
[DllImport("taos.dll", EntryPoint = "taos_free_result", CallingConvention = CallingConvention.StdCall)]
|
||||
static extern public IntPtr FreeResult(long res);
|
||||
[DllImport("taos.dll", EntryPoint = "taos_free_result", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern public IntPtr FreeResult(IntPtr res);
|
||||
|
||||
[DllImport("taos.dll", EntryPoint = "taos_close", CallingConvention = CallingConvention.StdCall)]
|
||||
static extern public int Close(long taos);
|
||||
[DllImport("taos.dll", EntryPoint = "taos_close", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern public int Close(IntPtr taos);
|
||||
}
|
||||
}
|
|
@ -28,7 +28,7 @@ namespace TDengineDriver
|
|||
private string configDir;
|
||||
private string user;
|
||||
private string password;
|
||||
private int port = 0;
|
||||
private short port = 0;
|
||||
|
||||
//sql parameters
|
||||
private string dbName;
|
||||
|
@ -43,7 +43,7 @@ namespace TDengineDriver
|
|||
private long batchRows;
|
||||
private long beginTimestamp = 1551369600000L;
|
||||
|
||||
private long conn = 0;
|
||||
private IntPtr conn = IntPtr.Zero;
|
||||
private long rowsInserted = 0;
|
||||
|
||||
static void Main(string[] args)
|
||||
|
@ -191,7 +191,7 @@ namespace TDengineDriver
|
|||
{
|
||||
string db = "";
|
||||
this.conn = TDengine.Connect(this.host, this.user, this.password, db, this.port);
|
||||
if (this.conn == 0)
|
||||
if (this.conn == IntPtr.Zero)
|
||||
{
|
||||
Console.WriteLine("Connect to TDengine failed");
|
||||
ExitProgram();
|
||||
|
@ -211,58 +211,62 @@ namespace TDengineDriver
|
|||
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.Append("create database if not exists ").Append(this.dbName);
|
||||
int code = TDengine.Query(this.conn, sql.ToString());
|
||||
if (code == TDengine.TSDB_CODE_SUCCESS)
|
||||
IntPtr res = TDengine.Query(this.conn, sql.ToString());
|
||||
if (res != IntPtr.Zero)
|
||||
{
|
||||
Console.WriteLine(sql.ToString() + " success");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(conn));
|
||||
Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(res));
|
||||
ExitProgram();
|
||||
}
|
||||
TDengine.FreeResult(res);
|
||||
|
||||
sql.Clear();
|
||||
sql.Append("use ").Append(this.dbName);
|
||||
code = TDengine.Query(this.conn, sql.ToString());
|
||||
if (code == TDengine.TSDB_CODE_SUCCESS)
|
||||
res = TDengine.Query(this.conn, sql.ToString());
|
||||
if (res != IntPtr.Zero)
|
||||
{
|
||||
Console.WriteLine(sql.ToString() + " success");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(this.conn));
|
||||
Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(res));
|
||||
ExitProgram();
|
||||
}
|
||||
TDengine.FreeResult(res);
|
||||
|
||||
sql.Clear();
|
||||
sql.Append("create table if not exists ").Append(this.stableName).Append("(ts timestamp, v1 int) tags(t1 int)");
|
||||
code = TDengine.Query(this.conn, sql.ToString());
|
||||
if (code == TDengine.TSDB_CODE_SUCCESS)
|
||||
sql.Append("create table if not exists ").Append(this.stableName).Append("(ts timestamp, v1 bool, v2 tinyint, v3 smallint, v4 int, v5 bigint, v6 float, v7 double, v8 binary(10), v9 nchar(10)) tags(t1 int)");
|
||||
res = TDengine.Query(this.conn, sql.ToString());
|
||||
if (res != IntPtr.Zero)
|
||||
{
|
||||
Console.WriteLine(sql.ToString() + " success");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(this.conn));
|
||||
Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(res));
|
||||
ExitProgram();
|
||||
}
|
||||
TDengine.FreeResult(res);
|
||||
|
||||
for (int i = 0; i < this.tableCount; i++)
|
||||
{
|
||||
sql.Clear();
|
||||
sql = sql.Append("create table if not exists ").Append(this.tablePrefix).Append(i)
|
||||
.Append(" using ").Append(this.stableName).Append(" tags(").Append(i).Append(")");
|
||||
code = TDengine.Query(this.conn, sql.ToString());
|
||||
if (code == TDengine.TSDB_CODE_SUCCESS)
|
||||
res = TDengine.Query(this.conn, sql.ToString());
|
||||
if (res != IntPtr.Zero)
|
||||
{
|
||||
Console.WriteLine(sql.ToString() + " success");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(this.conn));
|
||||
Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(res));
|
||||
ExitProgram();
|
||||
}
|
||||
TDengine.FreeResult(res);
|
||||
}
|
||||
|
||||
Console.WriteLine("create db and table success");
|
||||
|
@ -287,16 +291,22 @@ namespace TDengineDriver
|
|||
for (int batch = 0; batch < this.batchRows; ++batch)
|
||||
{
|
||||
long rows = loop * this.batchRows + batch;
|
||||
sql.Append("(").Append(this.beginTimestamp + rows).Append(",").Append(rows).Append(")");
|
||||
sql.Append("(")
|
||||
.Append(this.beginTimestamp + rows)
|
||||
.Append(", 1, 2, 3,")
|
||||
.Append(rows)
|
||||
.Append(", 5, 6, 7, 'abc', 'def')");
|
||||
}
|
||||
int code = TDengine.Query(conn, sql.ToString());
|
||||
if (code != TDengine.TSDB_CODE_SUCCESS)
|
||||
IntPtr res = TDengine.Query(this.conn, sql.ToString());
|
||||
if (res == IntPtr.Zero)
|
||||
{
|
||||
Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(conn));
|
||||
Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(res));
|
||||
}
|
||||
|
||||
int affectRows = TDengine.AffectRows(conn);
|
||||
int affectRows = TDengine.AffectRows(res);
|
||||
this.rowsInserted += affectRows;
|
||||
|
||||
TDengine.FreeResult(res);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -316,51 +326,45 @@ namespace TDengineDriver
|
|||
|
||||
System.DateTime start = new System.DateTime();
|
||||
long queryRows = 0;
|
||||
|
||||
for (int i = 0; i < this.tableCount; ++i)
|
||||
|
||||
for (int i = 0; i < 1/*this.tableCount*/; ++i)
|
||||
{
|
||||
String sql = "select * from " + this.dbName + "." + tablePrefix + i;
|
||||
Console.WriteLine(sql);
|
||||
|
||||
int code = TDengine.Query(conn, sql);
|
||||
if (code != TDengine.TSDB_CODE_SUCCESS)
|
||||
IntPtr res = TDengine.Query(conn, sql);
|
||||
if (res == IntPtr.Zero)
|
||||
{
|
||||
Console.WriteLine(sql + " failure, reason: " + TDengine.Error(conn));
|
||||
Console.WriteLine(sql + " failure, reason: " + TDengine.Error(res));
|
||||
ExitProgram();
|
||||
}
|
||||
|
||||
int fieldCount = TDengine.FieldCount(conn);
|
||||
//Console.WriteLine("field count: " + fieldCount);
|
||||
int fieldCount = TDengine.FieldCount(res);
|
||||
Console.WriteLine("field count: " + fieldCount);
|
||||
|
||||
List<TDengineMeta> metas = TDengine.FetchFields(conn);
|
||||
List<TDengineMeta> metas = TDengine.FetchFields(res);
|
||||
for (int j = 0; j < metas.Count; j++)
|
||||
{
|
||||
TDengineMeta meta = (TDengineMeta)metas[j];
|
||||
//Console.WriteLine("index:" + j + ", type:" + meta.type + ", typename:" + meta.TypeName() + ", name:" + meta.name + ", size:" + meta.size);
|
||||
}
|
||||
|
||||
long result = TDengine.UseResult(conn);
|
||||
if (result == 0)
|
||||
{
|
||||
Console.WriteLine(sql + " result set is null");
|
||||
return;
|
||||
Console.WriteLine("index:" + j + ", type:" + meta.type + ", typename:" + meta.TypeName() + ", name:" + meta.name + ", size:" + meta.size);
|
||||
}
|
||||
|
||||
IntPtr rowdata;
|
||||
while ((rowdata = TDengine.FetchRows(result)) != IntPtr.Zero)
|
||||
StringBuilder builder = new StringBuilder();
|
||||
while ((rowdata = TDengine.FetchRows(res)) != IntPtr.Zero)
|
||||
{
|
||||
queryRows++;
|
||||
for (int fields = 0; fields < fieldCount; ++fields)
|
||||
{
|
||||
TDengineMeta meta = metas[fields];
|
||||
int offset = 8 * fields;
|
||||
int offset = IntPtr.Size * fields;
|
||||
IntPtr data = Marshal.ReadIntPtr(rowdata, offset);
|
||||
|
||||
//Console.Write("---");
|
||||
builder.Append("---");
|
||||
|
||||
if (data == IntPtr.Zero)
|
||||
{
|
||||
//Console.Write("NULL");
|
||||
builder.Append("NULL");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -368,55 +372,61 @@ namespace TDengineDriver
|
|||
{
|
||||
case TDengineDataType.TSDB_DATA_TYPE_BOOL:
|
||||
bool v1 = Marshal.ReadByte(data) == 0 ? false : true;
|
||||
//Console.Write(v1);
|
||||
builder.Append(v1);
|
||||
break;
|
||||
case TDengineDataType.TSDB_DATA_TYPE_TINYINT:
|
||||
byte v2 = Marshal.ReadByte(data);
|
||||
//Console.Write(v2);
|
||||
builder.Append(v2);
|
||||
break;
|
||||
case TDengineDataType.TSDB_DATA_TYPE_SMALLINT:
|
||||
short v3 = Marshal.ReadInt16(data);
|
||||
//Console.Write(v3);
|
||||
builder.Append(v3);
|
||||
break;
|
||||
case TDengineDataType.TSDB_DATA_TYPE_INT:
|
||||
int v4 = Marshal.ReadInt32(data);
|
||||
//Console.Write(v4);
|
||||
builder.Append(v4);
|
||||
break;
|
||||
case TDengineDataType.TSDB_DATA_TYPE_BIGINT:
|
||||
long v5 = Marshal.ReadInt64(data);
|
||||
//Console.Write(v5);
|
||||
builder.Append(v5);
|
||||
break;
|
||||
case TDengineDataType.TSDB_DATA_TYPE_FLOAT:
|
||||
float v6 = (float)Marshal.PtrToStructure(data, typeof(float));
|
||||
//Console.Write(v6);
|
||||
builder.Append(v6);
|
||||
break;
|
||||
case TDengineDataType.TSDB_DATA_TYPE_DOUBLE:
|
||||
double v7 = (double)Marshal.PtrToStructure(data, typeof(double));
|
||||
//Console.Write(v7);
|
||||
builder.Append(v7);
|
||||
break;
|
||||
case TDengineDataType.TSDB_DATA_TYPE_BINARY:
|
||||
string v8 = Marshal.PtrToStringAnsi(data);
|
||||
//Console.Write(v8);
|
||||
builder.Append(v8);
|
||||
break;
|
||||
case TDengineDataType.TSDB_DATA_TYPE_TIMESTAMP:
|
||||
long v9 = Marshal.ReadInt64(data);
|
||||
//Console.Write(v9);
|
||||
builder.Append(v9);
|
||||
break;
|
||||
case TDengineDataType.TSDB_DATA_TYPE_NCHAR:
|
||||
string v10 = Marshal.PtrToStringAnsi(data);
|
||||
//Console.Write(v10);
|
||||
builder.Append(v10);
|
||||
break;
|
||||
}
|
||||
}
|
||||
//Console.WriteLine("---");
|
||||
builder.Append("---");
|
||||
|
||||
if (queryRows <= 10)
|
||||
{
|
||||
Console.WriteLine(builder.ToString());
|
||||
}
|
||||
builder.Clear();
|
||||
}
|
||||
|
||||
if (TDengine.ErrorNo(conn) != 0)
|
||||
if (TDengine.ErrorNo(res) != 0)
|
||||
{
|
||||
Console.Write("Query is not complete, Error {0:G}", TDengine.ErrorNo(conn), TDengine.Error(conn));
|
||||
Console.Write("Query is not complete, Error {0:G}", TDengine.ErrorNo(res), TDengine.Error(res));
|
||||
}
|
||||
|
||||
TDengine.FreeResult(result);
|
||||
TDengine.FreeResult(res);
|
||||
}
|
||||
|
||||
System.DateTime end = new System.DateTime();
|
||||
|
@ -428,14 +438,15 @@ namespace TDengineDriver
|
|||
|
||||
public void CloseConnection()
|
||||
{
|
||||
if (conn != 0)
|
||||
if (this.conn != IntPtr.Zero)
|
||||
{
|
||||
TDengine.Close(conn);
|
||||
TDengine.Close(this.conn);
|
||||
}
|
||||
}
|
||||
|
||||
static void ExitProgram()
|
||||
{
|
||||
TDengine.Cleanup();
|
||||
System.Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,20 +96,20 @@ enum {
|
|||
|
||||
struct _script_t;
|
||||
typedef struct _cmd_t {
|
||||
short cmdno;
|
||||
short nlen;
|
||||
char name[MAX_SIM_CMD_NAME_LEN];
|
||||
bool (*parseCmd)(char *, struct _cmd_t *, int);
|
||||
bool (*executeCmd)(struct _script_t *script, char *option);
|
||||
int16_t cmdno;
|
||||
int16_t nlen;
|
||||
char name[MAX_SIM_CMD_NAME_LEN];
|
||||
bool (*parseCmd)(char *, struct _cmd_t *, int);
|
||||
bool (*executeCmd)(struct _script_t *script, char *option);
|
||||
struct _cmd_t *next;
|
||||
} SCommand;
|
||||
|
||||
typedef struct {
|
||||
short cmdno;
|
||||
short jump; // jump position
|
||||
short errorJump; // sql jump flag, while '-x' exist in sql cmd, this flag
|
||||
// will be SQL_JUMP_TRUE, otherwise is SQL_JUMP_FALSE */
|
||||
short lineNum; // correspodning line number in original file
|
||||
int16_t cmdno;
|
||||
int16_t jump; // jump position
|
||||
int16_t errorJump; // sql jump flag, while '-x' exist in sql cmd, this flag
|
||||
// will be SQL_JUMP_TRUE, otherwise is SQL_JUMP_FALSE */
|
||||
int16_t lineNum; // correspodning line number in original file
|
||||
int optionOffset; // relative option offset
|
||||
} SCmdLine;
|
||||
|
||||
|
@ -120,7 +120,7 @@ typedef struct _var_t {
|
|||
} SVariable;
|
||||
|
||||
typedef struct _script_t {
|
||||
int type;
|
||||
int type;
|
||||
bool killed;
|
||||
|
||||
void *taos;
|
||||
|
@ -130,10 +130,10 @@ typedef struct _script_t {
|
|||
char system_exit_code[12];
|
||||
char system_ret_content[MAX_SYSTEM_RESULT_LEN];
|
||||
|
||||
int varLen;
|
||||
int linePos; // current cmd position
|
||||
int numOfLines; // number of lines in the script
|
||||
int bgScriptLen;
|
||||
int varLen;
|
||||
int linePos; // current cmd position
|
||||
int numOfLines; // number of lines in the script
|
||||
int bgScriptLen;
|
||||
char fileName[MAX_FILE_NAME_LEN]; // script file name
|
||||
char error[MAX_ERROR_LEN];
|
||||
char *optionBuffer;
|
||||
|
|
|
@ -33,21 +33,21 @@ enum {
|
|||
|
||||
/* label stack */
|
||||
typedef struct {
|
||||
char top; /* number of labels */
|
||||
short pos[MAX_NUM_LABLES]; /* the position of the label */
|
||||
char label[MAX_NUM_LABLES][MAX_LABEL_LEN]; /* name of the label */
|
||||
char top; /* number of labels */
|
||||
int16_t pos[MAX_NUM_LABLES]; /* the position of the label */
|
||||
char label[MAX_NUM_LABLES][MAX_LABEL_LEN]; /* name of the label */
|
||||
} SLabel;
|
||||
|
||||
/* block definition */
|
||||
typedef struct {
|
||||
char top; /* the number of blocks stacked */
|
||||
char type[MAX_NUM_BLOCK]; /* the block type */
|
||||
short *pos[MAX_NUM_BLOCK]; /* position of the jump for if/elif/case */
|
||||
short back[MAX_NUM_BLOCK]; /* go back, endw and continue */
|
||||
char numJump[MAX_NUM_BLOCK];
|
||||
short *jump[MAX_NUM_BLOCK][MAX_NUM_JUMP]; /* break or elif */
|
||||
char sexp[MAX_NUM_BLOCK][40]; /*switch expression */
|
||||
char sexpLen[MAX_NUM_BLOCK]; /*switch expression length */
|
||||
char top; /* the number of blocks stacked */
|
||||
char type[MAX_NUM_BLOCK]; /* the block type */
|
||||
int16_t *pos[MAX_NUM_BLOCK]; /* position of the jump for if/elif/case */
|
||||
int16_t back[MAX_NUM_BLOCK]; /* go back, endw and continue */
|
||||
char numJump[MAX_NUM_BLOCK];
|
||||
int16_t *jump[MAX_NUM_BLOCK][MAX_NUM_JUMP]; /* break or elif */
|
||||
char sexp[MAX_NUM_BLOCK][40]; /*switch expression */
|
||||
char sexpLen[MAX_NUM_BLOCK]; /*switch expression length */
|
||||
} SBlock;
|
||||
|
||||
bool simParseExpression(char *token, int lineNum);
|
||||
|
|
Loading…
Reference in New Issue