未验证 提交 70c5191b 编写于 作者: Y Yang Zhao 提交者: GitHub

[TS-352]<fix>taosdemo support unsigned data master branch (#8017)

上级 16ad42e2
...@@ -79,10 +79,10 @@ extern char configDir[]; ...@@ -79,10 +79,10 @@ extern char configDir[];
#define DEFAULT_START_TIME 1500000000000 #define DEFAULT_START_TIME 1500000000000
#define MAX_PREPARED_RAND 1000000 #define MAX_PREPARED_RAND 1000000
#define INT_BUFF_LEN 11 #define INT_BUFF_LEN 12
#define BIGINT_BUFF_LEN 21 #define BIGINT_BUFF_LEN 21
#define SMALLINT_BUFF_LEN 6 #define SMALLINT_BUFF_LEN 7
#define TINYINT_BUFF_LEN 4 #define TINYINT_BUFF_LEN 5
#define BOOL_BUFF_LEN 6 #define BOOL_BUFF_LEN 6
#define FLOAT_BUFF_LEN 22 #define FLOAT_BUFF_LEN 22
#define DOUBLE_BUFF_LEN 42 #define DOUBLE_BUFF_LEN 42
...@@ -590,16 +590,22 @@ static void init_rand_data(); ...@@ -590,16 +590,22 @@ static void init_rand_data();
/* ************ Global variables ************ */ /* ************ Global variables ************ */
int32_t g_randint[MAX_PREPARED_RAND]; int32_t g_randint[MAX_PREPARED_RAND];
uint32_t g_randuint[MAX_PREPARED_RAND];
int64_t g_randbigint[MAX_PREPARED_RAND]; int64_t g_randbigint[MAX_PREPARED_RAND];
uint64_t g_randubigint[MAX_PREPARED_RAND];
float g_randfloat[MAX_PREPARED_RAND]; float g_randfloat[MAX_PREPARED_RAND];
double g_randdouble[MAX_PREPARED_RAND]; double g_randdouble[MAX_PREPARED_RAND];
char *g_randbool_buff = NULL; char *g_randbool_buff = NULL;
char *g_randint_buff = NULL; char *g_randint_buff = NULL;
char *g_randuint_buff = NULL;
char *g_rand_voltage_buff = NULL; char *g_rand_voltage_buff = NULL;
char *g_randbigint_buff = NULL; char *g_randbigint_buff = NULL;
char *g_randubigint_buff = NULL;
char *g_randsmallint_buff = NULL; char *g_randsmallint_buff = NULL;
char *g_randusmallint_buff = NULL;
char *g_randtinyint_buff = NULL; char *g_randtinyint_buff = NULL;
char *g_randutinyint_buff = NULL;
char *g_randfloat_buff = NULL; char *g_randfloat_buff = NULL;
char *g_rand_current_buff = NULL; char *g_rand_current_buff = NULL;
char *g_rand_phase_buff = NULL; char *g_rand_phase_buff = NULL;
...@@ -1575,7 +1581,11 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { ...@@ -1575,7 +1581,11 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
&& strcasecmp(dataType, "DOUBLE") && strcasecmp(dataType, "DOUBLE")
&& strcasecmp(dataType, "BINARY") && strcasecmp(dataType, "BINARY")
&& strcasecmp(dataType, "TIMESTAMP") && strcasecmp(dataType, "TIMESTAMP")
&& strcasecmp(dataType, "NCHAR")) { && strcasecmp(dataType, "NCHAR")
&& strcasecmp(dataType, "UTINYINT")
&& strcasecmp(dataType, "USMALLINT")
&& strcasecmp(dataType, "UINT")
&& strcasecmp(dataType, "UBIGINT")) {
printHelp(); printHelp();
errorPrint("%s", "-b: Invalid data_type!\n"); errorPrint("%s", "-b: Invalid data_type!\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
...@@ -1601,6 +1611,14 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { ...@@ -1601,6 +1611,14 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
arguments->data_type[0] = TSDB_DATA_TYPE_BOOL; arguments->data_type[0] = TSDB_DATA_TYPE_BOOL;
} else if (0 == strcasecmp(dataType, "TIMESTAMP")) { } else if (0 == strcasecmp(dataType, "TIMESTAMP")) {
arguments->data_type[0] = TSDB_DATA_TYPE_TIMESTAMP; arguments->data_type[0] = TSDB_DATA_TYPE_TIMESTAMP;
} else if (0 == strcasecmp(dataType, "UTINYINT")) {
arguments->data_type[0] = TSDB_DATA_TYPE_UTINYINT;
} else if (0 == strcasecmp(dataType, "USMALLINT")) {
arguments->data_type[0] = TSDB_DATA_TYPE_USMALLINT;
} else if (0 == strcasecmp(dataType, "UINT")) {
arguments->data_type[0] = TSDB_DATA_TYPE_UINT;
} else if (0 == strcasecmp(dataType, "UBIGINT")) {
arguments->data_type[0] = TSDB_DATA_TYPE_UBIGINT;
} else { } else {
arguments->data_type[0] = TSDB_DATA_TYPE_NULL; arguments->data_type[0] = TSDB_DATA_TYPE_NULL;
} }
...@@ -1622,7 +1640,11 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { ...@@ -1622,7 +1640,11 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
&& strcasecmp(token, "DOUBLE") && strcasecmp(token, "DOUBLE")
&& strcasecmp(token, "BINARY") && strcasecmp(token, "BINARY")
&& strcasecmp(token, "TIMESTAMP") && strcasecmp(token, "TIMESTAMP")
&& strcasecmp(token, "NCHAR")) { && strcasecmp(token, "NCHAR")
&& strcasecmp(token, "UTINYINT")
&& strcasecmp(token, "USMALLINT")
&& strcasecmp(token, "UINT")
&& strcasecmp(token, "UBIGINT")) {
printHelp(); printHelp();
free(g_dupstr); free(g_dupstr);
errorPrint("%s", "-b: Invalid data_type!\n"); errorPrint("%s", "-b: Invalid data_type!\n");
...@@ -1638,7 +1660,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { ...@@ -1638,7 +1660,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
} else if (0 == strcasecmp(token, "BIGINT")) { } else if (0 == strcasecmp(token, "BIGINT")) {
arguments->data_type[index] = TSDB_DATA_TYPE_BIGINT; arguments->data_type[index] = TSDB_DATA_TYPE_BIGINT;
} else if (0 == strcasecmp(token, "DOUBLE")) { } else if (0 == strcasecmp(token, "DOUBLE")) {
arguments->data_type[index] = TSDB_DATA_TYPE_FLOAT; arguments->data_type[index] = TSDB_DATA_TYPE_DOUBLE;
} else if (0 == strcasecmp(token, "TINYINT")) { } else if (0 == strcasecmp(token, "TINYINT")) {
arguments->data_type[index] = TSDB_DATA_TYPE_TINYINT; arguments->data_type[index] = TSDB_DATA_TYPE_TINYINT;
} else if (0 == strcasecmp(token, "BINARY")) { } else if (0 == strcasecmp(token, "BINARY")) {
...@@ -1649,6 +1671,14 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { ...@@ -1649,6 +1671,14 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
arguments->data_type[index] = TSDB_DATA_TYPE_BOOL; arguments->data_type[index] = TSDB_DATA_TYPE_BOOL;
} else if (0 == strcasecmp(token, "TIMESTAMP")) { } else if (0 == strcasecmp(token, "TIMESTAMP")) {
arguments->data_type[index] = TSDB_DATA_TYPE_TIMESTAMP; arguments->data_type[index] = TSDB_DATA_TYPE_TIMESTAMP;
} else if (0 == strcasecmp(token, "UTINYINT")) {
arguments->data_type[index] = TSDB_DATA_TYPE_UTINYINT;
} else if (0 == strcasecmp(token, "USMALLINT")) {
arguments->data_type[index] = TSDB_DATA_TYPE_USMALLINT;
} else if (0 == strcasecmp(token, "UINT")) {
arguments->data_type[index] = TSDB_DATA_TYPE_UINT;
} else if (0 == strcasecmp(token, "UBIGINT")) {
arguments->data_type[index] = TSDB_DATA_TYPE_UBIGINT;
} else { } else {
arguments->data_type[index] = TSDB_DATA_TYPE_NULL; arguments->data_type[index] = TSDB_DATA_TYPE_NULL;
} }
...@@ -1952,18 +1982,22 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { ...@@ -1952,18 +1982,22 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
break; break;
case TSDB_DATA_TYPE_INT: case TSDB_DATA_TYPE_INT:
case TSDB_DATA_TYPE_UINT:
g_args.lenOfOneRow += INT_BUFF_LEN; g_args.lenOfOneRow += INT_BUFF_LEN;
break; break;
case TSDB_DATA_TYPE_BIGINT: case TSDB_DATA_TYPE_BIGINT:
case TSDB_DATA_TYPE_UBIGINT:
g_args.lenOfOneRow += BIGINT_BUFF_LEN; g_args.lenOfOneRow += BIGINT_BUFF_LEN;
break; break;
case TSDB_DATA_TYPE_SMALLINT: case TSDB_DATA_TYPE_SMALLINT:
case TSDB_DATA_TYPE_USMALLINT:
g_args.lenOfOneRow += SMALLINT_BUFF_LEN; g_args.lenOfOneRow += SMALLINT_BUFF_LEN;
break; break;
case TSDB_DATA_TYPE_TINYINT: case TSDB_DATA_TYPE_TINYINT:
case TSDB_DATA_TYPE_UTINYINT:
g_args.lenOfOneRow += TINYINT_BUFF_LEN; g_args.lenOfOneRow += TINYINT_BUFF_LEN;
break; break;
...@@ -2195,6 +2229,23 @@ static int32_t rand_tinyint() ...@@ -2195,6 +2229,23 @@ static int32_t rand_tinyint()
return g_randint[cursor % MAX_PREPARED_RAND] % 128; return g_randint[cursor % MAX_PREPARED_RAND] % 128;
} }
static char *rand_utinyint_str()
{
static int cursor;
cursor++;
if (cursor > (MAX_PREPARED_RAND - 1)) cursor = 0;
return g_randutinyint_buff +
((cursor % MAX_PREPARED_RAND) * TINYINT_BUFF_LEN);
}
static int32_t rand_utinyint()
{
static int cursor;
cursor++;
if (cursor > (MAX_PREPARED_RAND - 1)) cursor = 0;
return g_randuint[cursor % MAX_PREPARED_RAND] % 255;
}
static char *rand_smallint_str() static char *rand_smallint_str()
{ {
static int cursor; static int cursor;
...@@ -2209,7 +2260,24 @@ static int32_t rand_smallint() ...@@ -2209,7 +2260,24 @@ static int32_t rand_smallint()
static int cursor; static int cursor;
cursor++; cursor++;
if (cursor > (MAX_PREPARED_RAND - 1)) cursor = 0; if (cursor > (MAX_PREPARED_RAND - 1)) cursor = 0;
return g_randint[cursor % MAX_PREPARED_RAND] % 32767; return g_randint[cursor % MAX_PREPARED_RAND] % 32768;
}
static char *rand_usmallint_str()
{
static int cursor;
cursor++;
if (cursor > (MAX_PREPARED_RAND - 1)) cursor = 0;
return g_randusmallint_buff +
((cursor % MAX_PREPARED_RAND) * SMALLINT_BUFF_LEN);
}
static int32_t rand_usmallint()
{
static int cursor;
cursor++;
if (cursor > (MAX_PREPARED_RAND - 1)) cursor = 0;
return g_randuint[cursor % MAX_PREPARED_RAND] % 65535;
} }
static char *rand_int_str() static char *rand_int_str()
...@@ -2228,6 +2296,22 @@ static int32_t rand_int() ...@@ -2228,6 +2296,22 @@ static int32_t rand_int()
return g_randint[cursor % MAX_PREPARED_RAND]; return g_randint[cursor % MAX_PREPARED_RAND];
} }
static char *rand_uint_str()
{
static int cursor;
cursor++;
if (cursor > (MAX_PREPARED_RAND - 1)) cursor = 0;
return g_randuint_buff + ((cursor % MAX_PREPARED_RAND) * INT_BUFF_LEN);
}
static int32_t rand_uint()
{
static int cursor;
cursor++;
if (cursor > (MAX_PREPARED_RAND - 1)) cursor = 0;
return g_randuint[cursor % MAX_PREPARED_RAND];
}
static char *rand_bigint_str() static char *rand_bigint_str()
{ {
static int cursor; static int cursor;
...@@ -2245,6 +2329,23 @@ static int64_t rand_bigint() ...@@ -2245,6 +2329,23 @@ static int64_t rand_bigint()
return g_randbigint[cursor % MAX_PREPARED_RAND]; return g_randbigint[cursor % MAX_PREPARED_RAND];
} }
static char *rand_ubigint_str()
{
static int cursor;
cursor++;
if (cursor > (MAX_PREPARED_RAND - 1)) cursor = 0;
return g_randubigint_buff +
((cursor % MAX_PREPARED_RAND) * BIGINT_BUFF_LEN);
}
static int64_t rand_ubigint()
{
static int cursor;
cursor++;
if (cursor > (MAX_PREPARED_RAND - 1)) cursor = 0;
return g_randubigint[cursor % MAX_PREPARED_RAND];
}
static char *rand_float_str() static char *rand_float_str()
{ {
static int cursor; static int cursor;
...@@ -2382,9 +2483,18 @@ static void init_rand_data() { ...@@ -2382,9 +2483,18 @@ static void init_rand_data() {
assert(g_rand_phase_buff); assert(g_rand_phase_buff);
g_randdouble_buff = calloc(1, DOUBLE_BUFF_LEN * MAX_PREPARED_RAND); g_randdouble_buff = calloc(1, DOUBLE_BUFF_LEN * MAX_PREPARED_RAND);
assert(g_randdouble_buff); assert(g_randdouble_buff);
g_randuint_buff = calloc(1, INT_BUFF_LEN * MAX_PREPARED_RAND);
assert(g_randuint_buff);
g_randutinyint_buff = calloc(1, TINYINT_BUFF_LEN * MAX_PREPARED_RAND);
assert(g_randutinyint_buff);
g_randusmallint_buff = calloc(1, SMALLINT_BUFF_LEN * MAX_PREPARED_RAND);
assert(g_randusmallint_buff);
g_randubigint_buff = calloc(1, BIGINT_BUFF_LEN * MAX_PREPARED_RAND);
assert(g_randubigint_buff);
for (int i = 0; i < MAX_PREPARED_RAND; i++) { for (int i = 0; i < MAX_PREPARED_RAND; i++) {
g_randint[i] = (int)(taosRandom() % 65535); g_randint[i] = (int)(taosRandom() % RAND_MAX - (RAND_MAX >> 1));
g_randuint[i] = (int)(taosRandom());
sprintf(g_randint_buff + i * INT_BUFF_LEN, "%d", sprintf(g_randint_buff + i * INT_BUFF_LEN, "%d",
g_randint[i]); g_randint[i]);
sprintf(g_rand_voltage_buff + i * INT_BUFF_LEN, "%d", sprintf(g_rand_voltage_buff + i * INT_BUFF_LEN, "%d",
...@@ -2393,15 +2503,24 @@ static void init_rand_data() { ...@@ -2393,15 +2503,24 @@ static void init_rand_data() {
sprintf(g_randbool_buff + i * BOOL_BUFF_LEN, "%s", sprintf(g_randbool_buff + i * BOOL_BUFF_LEN, "%s",
((g_randint[i] % 2) & 1)?"true":"false"); ((g_randint[i] % 2) & 1)?"true":"false");
sprintf(g_randsmallint_buff + i * SMALLINT_BUFF_LEN, "%d", sprintf(g_randsmallint_buff + i * SMALLINT_BUFF_LEN, "%d",
g_randint[i] % 32767); g_randint[i] % 32768);
sprintf(g_randtinyint_buff + i * TINYINT_BUFF_LEN, "%d", sprintf(g_randtinyint_buff + i * TINYINT_BUFF_LEN, "%d",
g_randint[i] % 128); g_randint[i] % 128);
sprintf(g_randuint_buff + i * INT_BUFF_LEN, "%d",
g_randbigint[i] = (int64_t)(taosRandom() % 2147483648); g_randuint[i]);
sprintf(g_randusmallint_buff + i * SMALLINT_BUFF_LEN, "%d",
g_randuint[i] % 65535);
sprintf(g_randutinyint_buff + i * TINYINT_BUFF_LEN, "%d",
g_randuint[i] % 255);
g_randbigint[i] = (int64_t)(taosRandom() % RAND_MAX - (RAND_MAX >> 1));
g_randubigint[i] = (uint64_t)(taosRandom());
sprintf(g_randbigint_buff + i * BIGINT_BUFF_LEN, "%"PRId64"", sprintf(g_randbigint_buff + i * BIGINT_BUFF_LEN, "%"PRId64"",
g_randbigint[i]); g_randbigint[i]);
sprintf(g_randubigint_buff + i * BIGINT_BUFF_LEN, "%"PRId64"",
g_randubigint[i]);
g_randfloat[i] = (float)(taosRandom() / 1000.0); g_randfloat[i] = (float)(taosRandom() / 1000.0) * (taosRandom() % 2 > 0.5 ? 1 : -1);
sprintf(g_randfloat_buff + i * FLOAT_BUFF_LEN, "%f", sprintf(g_randfloat_buff + i * FLOAT_BUFF_LEN, "%f",
g_randfloat[i]); g_randfloat[i]);
sprintf(g_rand_current_buff + i * FLOAT_BUFF_LEN, "%f", sprintf(g_rand_current_buff + i * FLOAT_BUFF_LEN, "%f",
...@@ -2411,7 +2530,7 @@ static void init_rand_data() { ...@@ -2411,7 +2530,7 @@ static void init_rand_data() {
(float)((115 + g_randint[i] % 10 (float)((115 + g_randint[i] % 10
+ g_randfloat[i]/1000000000)/360)); + g_randfloat[i]/1000000000)/360));
g_randdouble[i] = (double)(taosRandom() / 1000000.0); g_randdouble[i] = (double)(taosRandom() / 1000000.0) * (taosRandom() % 2 > 0.5 ? 1 : -1);
sprintf(g_randdouble_buff + i * DOUBLE_BUFF_LEN, "%f", sprintf(g_randdouble_buff + i * DOUBLE_BUFF_LEN, "%f",
g_randdouble[i]); g_randdouble[i]);
} }
...@@ -2974,18 +3093,34 @@ static void xDumpFieldToFile(FILE* fp, const char* val, ...@@ -2974,18 +3093,34 @@ static void xDumpFieldToFile(FILE* fp, const char* val,
fprintf(fp, "%d", *((int8_t *)val)); fprintf(fp, "%d", *((int8_t *)val));
break; break;
case TSDB_DATA_TYPE_UTINYINT:
fprintf(fp, "%d", *((uint8_t *)val));
break;
case TSDB_DATA_TYPE_SMALLINT: case TSDB_DATA_TYPE_SMALLINT:
fprintf(fp, "%d", *((int16_t *)val)); fprintf(fp, "%d", *((int16_t *)val));
break; break;
case TSDB_DATA_TYPE_USMALLINT:
fprintf(fp, "%d", *((uint16_t *)val));
break;
case TSDB_DATA_TYPE_INT: case TSDB_DATA_TYPE_INT:
fprintf(fp, "%d", *((int32_t *)val)); fprintf(fp, "%d", *((int32_t *)val));
break; break;
case TSDB_DATA_TYPE_UINT:
fprintf(fp, "%d", *((uint32_t *)val));
break;
case TSDB_DATA_TYPE_BIGINT: case TSDB_DATA_TYPE_BIGINT:
fprintf(fp, "%"PRId64"", *((int64_t *)val)); fprintf(fp, "%"PRId64"", *((int64_t *)val));
break; break;
case TSDB_DATA_TYPE_UBIGINT:
fprintf(fp, "%"PRId64"", *((uint64_t *)val));
break;
case TSDB_DATA_TYPE_FLOAT: case TSDB_DATA_TYPE_FLOAT:
fprintf(fp, "%.5f", GET_FLOAT_VAL(val)); fprintf(fp, "%.5f", GET_FLOAT_VAL(val));
break; break;
...@@ -3472,7 +3607,23 @@ static char* generateTagValuesForStb(SSuperTable* stbInfo, int64_t tableSeq) { ...@@ -3472,7 +3607,23 @@ static char* generateTagValuesForStb(SSuperTable* stbInfo, int64_t tableSeq) {
} else if (0 == strncasecmp(stbInfo->tags[i].dataType, } else if (0 == strncasecmp(stbInfo->tags[i].dataType,
"timestamp", strlen("timestamp"))) { "timestamp", strlen("timestamp"))) {
dataLen += snprintf(dataBuf + dataLen, TSDB_MAX_SQL_LEN - dataLen, dataLen += snprintf(dataBuf + dataLen, TSDB_MAX_SQL_LEN - dataLen,
"%"PRId64",", rand_bigint()); "%"PRId64",", rand_ubigint());
} else if (0 == strncasecmp(stbInfo->tags[i].dataType,
"utinyint", strlen("utinyint"))) {
dataLen += snprintf(dataBuf + dataLen, TSDB_MAX_SQL_LEN - dataLen,
"%d,", rand_utinyint());
} else if (0 == strncasecmp(stbInfo->tags[i].dataType,
"usmallint", strlen("usmallint"))) {
dataLen += snprintf(dataBuf + dataLen, TSDB_MAX_SQL_LEN - dataLen,
"%d,", rand_usmallint());
} else if (0 == strncasecmp(stbInfo->tags[i].dataType,
"uint", strlen("uint"))) {
dataLen += snprintf(dataBuf + dataLen, TSDB_MAX_SQL_LEN - dataLen,
"%d,", rand_uint());
} else if (0 == strncasecmp(stbInfo->tags[i].dataType,
"ubigint", strlen("ubigint"))) {
dataLen += snprintf(dataBuf + dataLen, TSDB_MAX_SQL_LEN - dataLen,
"%"PRId64",", rand_ubigint());
} else { } else {
errorPrint2("No support data type: %s\n", stbInfo->tags[i].dataType); errorPrint2("No support data type: %s\n", stbInfo->tags[i].dataType);
tmfree(dataBuf); tmfree(dataBuf);
...@@ -3502,18 +3653,22 @@ static int calcRowLen(SSuperTable* superTbls) { ...@@ -3502,18 +3653,22 @@ static int calcRowLen(SSuperTable* superTbls) {
break; break;
case TSDB_DATA_TYPE_INT: case TSDB_DATA_TYPE_INT:
case TSDB_DATA_TYPE_UINT:
lenOfOneRow += INT_BUFF_LEN; lenOfOneRow += INT_BUFF_LEN;
break; break;
case TSDB_DATA_TYPE_BIGINT: case TSDB_DATA_TYPE_BIGINT:
case TSDB_DATA_TYPE_UBIGINT:
lenOfOneRow += BIGINT_BUFF_LEN; lenOfOneRow += BIGINT_BUFF_LEN;
break; break;
case TSDB_DATA_TYPE_SMALLINT: case TSDB_DATA_TYPE_SMALLINT:
case TSDB_DATA_TYPE_USMALLINT:
lenOfOneRow += SMALLINT_BUFF_LEN; lenOfOneRow += SMALLINT_BUFF_LEN;
break; break;
case TSDB_DATA_TYPE_TINYINT: case TSDB_DATA_TYPE_TINYINT:
case TSDB_DATA_TYPE_UTINYINT:
lenOfOneRow += TINYINT_BUFF_LEN; lenOfOneRow += TINYINT_BUFF_LEN;
break; break;
...@@ -3544,27 +3699,41 @@ static int calcRowLen(SSuperTable* superTbls) { ...@@ -3544,27 +3699,41 @@ static int calcRowLen(SSuperTable* superTbls) {
int tagIndex; int tagIndex;
int lenOfTagOfOneRow = 0; int lenOfTagOfOneRow = 0;
for (tagIndex = 0; tagIndex < superTbls->tagCount; tagIndex++) { for (tagIndex = 0; tagIndex < superTbls->tagCount; tagIndex++) {
char* dataType = superTbls->tags[tagIndex].dataType; char * dataType = superTbls->tags[tagIndex].dataType;
switch (superTbls->tags[tagIndex].data_type)
if (strcasecmp(dataType, "BINARY") == 0) { {
case TSDB_DATA_TYPE_BINARY:
lenOfTagOfOneRow += superTbls->tags[tagIndex].dataLen + 3; lenOfTagOfOneRow += superTbls->tags[tagIndex].dataLen + 3;
} else if (strcasecmp(dataType, "NCHAR") == 0) { break;
case TSDB_DATA_TYPE_NCHAR:
lenOfTagOfOneRow += superTbls->tags[tagIndex].dataLen + 3; lenOfTagOfOneRow += superTbls->tags[tagIndex].dataLen + 3;
} else if (strcasecmp(dataType, "INT") == 0) { break;
case TSDB_DATA_TYPE_INT:
case TSDB_DATA_TYPE_UINT:
lenOfTagOfOneRow += superTbls->tags[tagIndex].dataLen + INT_BUFF_LEN; lenOfTagOfOneRow += superTbls->tags[tagIndex].dataLen + INT_BUFF_LEN;
} else if (strcasecmp(dataType, "BIGINT") == 0) { break;
case TSDB_DATA_TYPE_BIGINT:
case TSDB_DATA_TYPE_UBIGINT:
lenOfTagOfOneRow += superTbls->tags[tagIndex].dataLen + BIGINT_BUFF_LEN; lenOfTagOfOneRow += superTbls->tags[tagIndex].dataLen + BIGINT_BUFF_LEN;
} else if (strcasecmp(dataType, "SMALLINT") == 0) { break;
case TSDB_DATA_TYPE_SMALLINT:
case TSDB_DATA_TYPE_USMALLINT:
lenOfTagOfOneRow += superTbls->tags[tagIndex].dataLen + SMALLINT_BUFF_LEN; lenOfTagOfOneRow += superTbls->tags[tagIndex].dataLen + SMALLINT_BUFF_LEN;
} else if (strcasecmp(dataType, "TINYINT") == 0) { break;
case TSDB_DATA_TYPE_TINYINT:
case TSDB_DATA_TYPE_UTINYINT:
lenOfTagOfOneRow += superTbls->tags[tagIndex].dataLen + TINYINT_BUFF_LEN; lenOfTagOfOneRow += superTbls->tags[tagIndex].dataLen + TINYINT_BUFF_LEN;
} else if (strcasecmp(dataType, "BOOL") == 0) { break;
case TSDB_DATA_TYPE_BOOL:
lenOfTagOfOneRow += superTbls->tags[tagIndex].dataLen + BOOL_BUFF_LEN; lenOfTagOfOneRow += superTbls->tags[tagIndex].dataLen + BOOL_BUFF_LEN;
} else if (strcasecmp(dataType, "FLOAT") == 0) { break;
case TSDB_DATA_TYPE_FLOAT:
lenOfTagOfOneRow += superTbls->tags[tagIndex].dataLen + FLOAT_BUFF_LEN; lenOfTagOfOneRow += superTbls->tags[tagIndex].dataLen + FLOAT_BUFF_LEN;
} else if (strcasecmp(dataType, "DOUBLE") == 0) { break;
case TSDB_DATA_TYPE_DOUBLE:
lenOfTagOfOneRow += superTbls->tags[tagIndex].dataLen + DOUBLE_BUFF_LEN; lenOfTagOfOneRow += superTbls->tags[tagIndex].dataLen + DOUBLE_BUFF_LEN;
} else { break;
default:
errorPrint2("get error tag type : %s\n", dataType); errorPrint2("get error tag type : %s\n", dataType);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
...@@ -3697,40 +3866,60 @@ static int getSuperTableFromServer(TAOS * taos, char* dbName, ...@@ -3697,40 +3866,60 @@ static int getSuperTableFromServer(TAOS * taos, char* dbName,
tstrncpy(superTbls->tags[tagIndex].field, tstrncpy(superTbls->tags[tagIndex].field,
(char *)row[TSDB_DESCRIBE_METRIC_FIELD_INDEX], (char *)row[TSDB_DESCRIBE_METRIC_FIELD_INDEX],
fields[TSDB_DESCRIBE_METRIC_FIELD_INDEX].bytes); fields[TSDB_DESCRIBE_METRIC_FIELD_INDEX].bytes);
tstrncpy(superTbls->tags[tagIndex].dataType, if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
(char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
min(DATATYPE_BUFF_LEN,
fields[TSDB_DESCRIBE_METRIC_TYPE_INDEX].bytes) + 1);
if (0 == strncasecmp(superTbls->tags[tagIndex].dataType,
"INT", strlen("INT"))) { "INT", strlen("INT"))) {
superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_INT; superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_INT;
} else if (0 == strncasecmp(superTbls->tags[tagIndex].dataType, } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
"TINYINT", strlen("TINYINT"))) { "TINYINT", strlen("TINYINT"))) {
superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_TINYINT; superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_TINYINT;
} else if (0 == strncasecmp(superTbls->tags[tagIndex].dataType, } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
"SMALLINT", strlen("SMALLINT"))) { "SMALLINT", strlen("SMALLINT"))) {
superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_SMALLINT; superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_SMALLINT;
} else if (0 == strncasecmp(superTbls->tags[tagIndex].dataType, } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
"BIGINT", strlen("BIGINT"))) { "BIGINT", strlen("BIGINT"))) {
superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_BIGINT; superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_BIGINT;
} else if (0 == strncasecmp(superTbls->tags[tagIndex].dataType, } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
"FLOAT", strlen("FLOAT"))) { "FLOAT", strlen("FLOAT"))) {
superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_FLOAT; superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_FLOAT;
} else if (0 == strncasecmp(superTbls->tags[tagIndex].dataType, } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
"DOUBLE", strlen("DOUBLE"))) { "DOUBLE", strlen("DOUBLE"))) {
superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_DOUBLE; superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_DOUBLE;
} else if (0 == strncasecmp(superTbls->tags[tagIndex].dataType, } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
"BINARY", strlen("BINARY"))) { "BINARY", strlen("BINARY"))) {
superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_BINARY; superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_BINARY;
} else if (0 == strncasecmp(superTbls->tags[tagIndex].dataType, } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
"NCHAR", strlen("NCHAR"))) { "NCHAR", strlen("NCHAR"))) {
superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_NCHAR; superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_NCHAR;
} else if (0 == strncasecmp(superTbls->tags[tagIndex].dataType, } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
"BOOL", strlen("BOOL"))) { "BOOL", strlen("BOOL"))) {
superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_BOOL; superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_BOOL;
} else if (0 == strncasecmp(superTbls->tags[tagIndex].dataType, } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
"TIMESTAMP", strlen("TIMESTAMP"))) { "TIMESTAMP", strlen("TIMESTAMP"))) {
superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_TIMESTAMP; superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_TIMESTAMP;
} else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
"TINYINT UNSIGNED", strlen("TINYINT UNSIGNED"))) {
superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_UTINYINT;
tstrncpy(superTbls->tags[tagIndex].dataType,"UTINYINT",
min(DATATYPE_BUFF_LEN,
fields[TSDB_DESCRIBE_METRIC_TYPE_INDEX].bytes) + 1);
} else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
"SMALLINT UNSIGNED", strlen("SMALLINT UNSIGNED"))) {
superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_USMALLINT;
tstrncpy(superTbls->tags[tagIndex].dataType,"USMALLINT",
min(DATATYPE_BUFF_LEN,
fields[TSDB_DESCRIBE_METRIC_TYPE_INDEX].bytes) + 1);
} else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
"INT UNSIGNED", strlen("INT UNSIGNED"))) {
superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_UINT;
tstrncpy(superTbls->tags[tagIndex].dataType,"UINT",
min(DATATYPE_BUFF_LEN,
fields[TSDB_DESCRIBE_METRIC_TYPE_INDEX].bytes) + 1);
}else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
"BIGINT UNSIGNED", strlen("BIGINT UNSIGNED"))) {
superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_UBIGINT;
tstrncpy(superTbls->tags[tagIndex].dataType,"UBIGINT",
min(DATATYPE_BUFF_LEN,
fields[TSDB_DESCRIBE_METRIC_TYPE_INDEX].bytes) + 1);
} else { } else {
superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_NULL; superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_NULL;
} }
...@@ -3740,46 +3929,78 @@ static int getSuperTableFromServer(TAOS * taos, char* dbName, ...@@ -3740,46 +3929,78 @@ static int getSuperTableFromServer(TAOS * taos, char* dbName,
(char *)row[TSDB_DESCRIBE_METRIC_NOTE_INDEX], (char *)row[TSDB_DESCRIBE_METRIC_NOTE_INDEX],
min(NOTE_BUFF_LEN, min(NOTE_BUFF_LEN,
fields[TSDB_DESCRIBE_METRIC_NOTE_INDEX].bytes) + 1); fields[TSDB_DESCRIBE_METRIC_NOTE_INDEX].bytes) + 1);
if (strstr((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], "UNSIGNED") == NULL)
{
tstrncpy(superTbls->tags[tagIndex].dataType,
(char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
min(DATATYPE_BUFF_LEN,
fields[TSDB_DESCRIBE_METRIC_TYPE_INDEX].bytes) + 1);
}
tagIndex++; tagIndex++;
} else { } else {
tstrncpy(superTbls->columns[columnIndex].field, tstrncpy(superTbls->columns[columnIndex].field,
(char *)row[TSDB_DESCRIBE_METRIC_FIELD_INDEX], (char *)row[TSDB_DESCRIBE_METRIC_FIELD_INDEX],
fields[TSDB_DESCRIBE_METRIC_FIELD_INDEX].bytes); fields[TSDB_DESCRIBE_METRIC_FIELD_INDEX].bytes);
tstrncpy(superTbls->columns[columnIndex].dataType,
(char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
min(DATATYPE_BUFF_LEN, "INT", strlen("INT")) &&
fields[TSDB_DESCRIBE_METRIC_TYPE_INDEX].bytes) + 1); strstr((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], "UNSIGNED") == NULL) {
if (0 == strncasecmp(superTbls->columns[columnIndex].dataType,
"INT", strlen("INT"))) {
superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_INT; superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_INT;
} else if (0 == strncasecmp(superTbls->columns[columnIndex].dataType, } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
"TINYINT", strlen("TINYINT"))) { "TINYINT", strlen("TINYINT")) &&
strstr((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], "UNSIGNED") == NULL) {
superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_TINYINT; superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_TINYINT;
} else if (0 == strncasecmp(superTbls->columns[columnIndex].dataType, } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
"SMALLINT", strlen("SMALLINT"))) { "SMALLINT", strlen("SMALLINT")) &&
strstr((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], "UNSIGNED") == NULL) {
superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_SMALLINT; superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_SMALLINT;
} else if (0 == strncasecmp(superTbls->columns[columnIndex].dataType, } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
"BIGINT", strlen("BIGINT"))) { "BIGINT", strlen("BIGINT")) &&
strstr((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], "UNSIGNED") == NULL) {
superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_BIGINT; superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_BIGINT;
} else if (0 == strncasecmp(superTbls->columns[columnIndex].dataType, } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
"FLOAT", strlen("FLOAT"))) { "FLOAT", strlen("FLOAT"))) {
superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_FLOAT; superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_FLOAT;
} else if (0 == strncasecmp(superTbls->columns[columnIndex].dataType, } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
"DOUBLE", strlen("DOUBLE"))) { "DOUBLE", strlen("DOUBLE"))) {
superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_DOUBLE; superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_DOUBLE;
} else if (0 == strncasecmp(superTbls->columns[columnIndex].dataType, } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
"BINARY", strlen("BINARY"))) { "BINARY", strlen("BINARY"))) {
superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_BINARY; superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_BINARY;
} else if (0 == strncasecmp(superTbls->columns[columnIndex].dataType, } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
"NCHAR", strlen("NCHAR"))) { "NCHAR", strlen("NCHAR"))) {
superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_NCHAR; superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_NCHAR;
} else if (0 == strncasecmp(superTbls->columns[columnIndex].dataType, } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
"BOOL", strlen("BOOL"))) { "BOOL", strlen("BOOL"))) {
superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_BOOL; superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_BOOL;
} else if (0 == strncasecmp(superTbls->columns[columnIndex].dataType, } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
"TIMESTAMP", strlen("TIMESTAMP"))) { "TIMESTAMP", strlen("TIMESTAMP"))) {
superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_TIMESTAMP; superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_TIMESTAMP;
} else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
"TINYINT UNSIGNED", strlen("TINYINT UNSIGNED"))) {
superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_UTINYINT;
tstrncpy(superTbls->columns[columnIndex].dataType,"UTINYINT",
min(DATATYPE_BUFF_LEN,
fields[TSDB_DESCRIBE_METRIC_TYPE_INDEX].bytes) + 1);
} else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
"SMALLINT UNSIGNED", strlen("SMALLINT UNSIGNED"))) {
superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_USMALLINT;
tstrncpy(superTbls->columns[columnIndex].dataType,"USMALLINT",
min(DATATYPE_BUFF_LEN,
fields[TSDB_DESCRIBE_METRIC_TYPE_INDEX].bytes) + 1);
} else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
"INT UNSIGNED", strlen("INT UNSIGNED"))) {
superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_UINT;
tstrncpy(superTbls->columns[columnIndex].dataType,"UINT",
min(DATATYPE_BUFF_LEN,
fields[TSDB_DESCRIBE_METRIC_TYPE_INDEX].bytes) + 1);
} else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
"BIGINT UNSIGNED", strlen("BIGINT UNSIGNED"))) {
superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_UBIGINT;
tstrncpy(superTbls->columns[columnIndex].dataType,"UBIGINT",
min(DATATYPE_BUFF_LEN,
fields[TSDB_DESCRIBE_METRIC_TYPE_INDEX].bytes) + 1);
} else { } else {
superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_NULL; superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_NULL;
} }
...@@ -3789,6 +4010,13 @@ static int getSuperTableFromServer(TAOS * taos, char* dbName, ...@@ -3789,6 +4010,13 @@ static int getSuperTableFromServer(TAOS * taos, char* dbName,
(char *)row[TSDB_DESCRIBE_METRIC_NOTE_INDEX], (char *)row[TSDB_DESCRIBE_METRIC_NOTE_INDEX],
min(NOTE_BUFF_LEN, min(NOTE_BUFF_LEN,
fields[TSDB_DESCRIBE_METRIC_NOTE_INDEX].bytes) + 1); fields[TSDB_DESCRIBE_METRIC_NOTE_INDEX].bytes) + 1);
if (strstr((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], "UNSIGNED") == NULL) {
tstrncpy(superTbls->columns[columnIndex].dataType,
(char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
min(DATATYPE_BUFF_LEN,
fields[TSDB_DESCRIBE_METRIC_TYPE_INDEX].bytes) + 1);
}
columnIndex++; columnIndex++;
} }
...@@ -3913,6 +4141,30 @@ static int createSuperTable( ...@@ -3913,6 +4141,30 @@ static int createSuperTable(
lenOfOneRow += TIMESTAMP_BUFF_LEN; lenOfOneRow += TIMESTAMP_BUFF_LEN;
break; break;
case TSDB_DATA_TYPE_UTINYINT:
len += snprintf(cols + len, COL_BUFFER_LEN - len, ",C%d %s",
colIndex, "TINYINT UNSIGNED");
lenOfOneRow += TINYINT_BUFF_LEN;
break;
case TSDB_DATA_TYPE_USMALLINT:
len += snprintf(cols + len, COL_BUFFER_LEN - len, ",C%d %s",
colIndex, "SMALLINT UNSIGNED");
lenOfOneRow += SMALLINT_BUFF_LEN;
break;
case TSDB_DATA_TYPE_UINT:
len += snprintf(cols + len, COL_BUFFER_LEN - len, ",C%d %s",
colIndex, "INT UNSIGNED");
lenOfOneRow += INT_BUFF_LEN;
break;
case TSDB_DATA_TYPE_UBIGINT:
len += snprintf(cols + len, COL_BUFFER_LEN - len, ",C%d %s",
colIndex, "BIGINT UNSIGNED");
lenOfOneRow += BIGINT_BUFF_LEN;
break;
default: default:
taos_close(taos); taos_close(taos);
free(command); free(command);
...@@ -4003,6 +4255,22 @@ static int createSuperTable( ...@@ -4003,6 +4255,22 @@ static int createSuperTable(
len += snprintf(tags + len, TSDB_MAX_TAGS_LEN - len, len += snprintf(tags + len, TSDB_MAX_TAGS_LEN - len,
"T%d %s,", tagIndex, "DOUBLE"); "T%d %s,", tagIndex, "DOUBLE");
lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + DOUBLE_BUFF_LEN; lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + DOUBLE_BUFF_LEN;
} else if (strcasecmp(dataType, "UTINYINT") == 0) {
len += snprintf(tags + len, TSDB_MAX_TAGS_LEN - len,
"T%d %s,", tagIndex, "TINYINT UNSIGNED");
lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + TINYINT_BUFF_LEN;
} else if (strcasecmp(dataType, "USMALLINT") == 0) {
len += snprintf(tags + len, TSDB_MAX_TAGS_LEN - len,
"T%d %s,", tagIndex, "SMALLINT UNSIGNED");
lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + SMALLINT_BUFF_LEN;
} else if (strcasecmp(dataType, "UINT") == 0) {
len += snprintf(tags + len, TSDB_MAX_TAGS_LEN - len,
"T%d %s,", tagIndex, "INT UNSIGNED");
lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + INT_BUFF_LEN;
} else if (strcasecmp(dataType, "UBIGINT") == 0) {
len += snprintf(tags + len, TSDB_MAX_TAGS_LEN - len,
"T%d %s,", tagIndex, "BIGINT UNSIGNED");
lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + BIGINT_BUFF_LEN;
} else { } else {
taos_close(taos); taos_close(taos);
free(command); free(command);
...@@ -4158,19 +4426,17 @@ int createDatabasesAndStables(char *command) { ...@@ -4158,19 +4426,17 @@ int createDatabasesAndStables(char *command) {
errorPrint("create super table %"PRIu64" failed!\n\n", j); errorPrint("create super table %"PRIu64" failed!\n\n", j);
continue; continue;
} }
} } else {
ret = getSuperTableFromServer(taos, g_Dbs.db[i].dbName,
ret = getSuperTableFromServer(taos, g_Dbs.db[i].dbName,
&g_Dbs.db[i].superTbls[j]); &g_Dbs.db[i].superTbls[j]);
if (0 != ret) { if (0 != ret) {
errorPrint2("\nget super table %s.%s info failed!\n\n", errorPrint2("\nget super table %s.%s info failed!\n\n",
g_Dbs.db[i].dbName, g_Dbs.db[i].superTbls[j].stbName); g_Dbs.db[i].dbName, g_Dbs.db[i].superTbls[j].stbName);
continue; continue;
}
} }
validStbCount ++; validStbCount ++;
} }
g_Dbs.db[i].superTblCount = validStbCount; g_Dbs.db[i].superTblCount = validStbCount;
} }
...@@ -4663,6 +4929,18 @@ static bool getColumnAndTagTypeFromInsertJsonFile( ...@@ -4663,6 +4929,18 @@ static bool getColumnAndTagTypeFromInsertJsonFile(
} else if (0 == strncasecmp(superTbls->columns[c].dataType, } else if (0 == strncasecmp(superTbls->columns[c].dataType,
"TIMESTAMP", strlen("TIMESTAMP"))) { "TIMESTAMP", strlen("TIMESTAMP"))) {
superTbls->columns[c].data_type = TSDB_DATA_TYPE_TIMESTAMP; superTbls->columns[c].data_type = TSDB_DATA_TYPE_TIMESTAMP;
} else if (0 == strncasecmp(superTbls->columns[c].dataType,
"UTINYINT", strlen("UTINYINT"))) {
superTbls->columns[c].data_type = TSDB_DATA_TYPE_UTINYINT;
} else if (0 == strncasecmp(superTbls->columns[c].dataType,
"USMALLINT", strlen("USMALLINT"))) {
superTbls->columns[c].data_type = TSDB_DATA_TYPE_USMALLINT;
} else if (0 == strncasecmp(superTbls->columns[c].dataType,
"UINT", strlen("UINT"))) {
superTbls->columns[c].data_type = TSDB_DATA_TYPE_UINT;
} else if (0 == strncasecmp(superTbls->columns[c].dataType,
"UBIGINT", strlen("UBIGINT"))) {
superTbls->columns[c].data_type = TSDB_DATA_TYPE_UBIGINT;
} else { } else {
superTbls->columns[c].data_type = TSDB_DATA_TYPE_NULL; superTbls->columns[c].data_type = TSDB_DATA_TYPE_NULL;
} }
...@@ -4768,6 +5046,18 @@ static bool getColumnAndTagTypeFromInsertJsonFile( ...@@ -4768,6 +5046,18 @@ static bool getColumnAndTagTypeFromInsertJsonFile(
} else if (0 == strncasecmp(superTbls->tags[t].dataType, } else if (0 == strncasecmp(superTbls->tags[t].dataType,
"TIMESTAMP", strlen("TIMESTAMP"))) { "TIMESTAMP", strlen("TIMESTAMP"))) {
superTbls->tags[t].data_type = TSDB_DATA_TYPE_TIMESTAMP; superTbls->tags[t].data_type = TSDB_DATA_TYPE_TIMESTAMP;
} else if (0 == strncasecmp(superTbls->tags[t].dataType,
"UTINYINT", strlen("UTINYINT"))) {
superTbls->tags[t].data_type = TSDB_DATA_TYPE_UTINYINT;
} else if (0 == strncasecmp(superTbls->tags[t].dataType,
"USMALLINT", strlen("USMALLINT"))) {
superTbls->tags[t].data_type = TSDB_DATA_TYPE_USMALLINT;
} else if (0 == strncasecmp(superTbls->tags[t].dataType,
"UINT", strlen("UINT"))) {
superTbls->tags[t].data_type = TSDB_DATA_TYPE_UINT;
} else if (0 == strncasecmp(superTbls->tags[t].dataType,
"UBIGINT", strlen("UBIGINT"))) {
superTbls->tags[t].data_type = TSDB_DATA_TYPE_UBIGINT;
} else { } else {
superTbls->tags[t].data_type = TSDB_DATA_TYPE_NULL; superTbls->tags[t].data_type = TSDB_DATA_TYPE_NULL;
} }
...@@ -6185,9 +6475,22 @@ static int64_t generateStbRowData( ...@@ -6185,9 +6475,22 @@ static int64_t generateStbRowData(
tstrncpy(pstr + dataLen, tmp, min(tmpLen + 1, INT_BUFF_LEN)); tstrncpy(pstr + dataLen, tmp, min(tmpLen + 1, INT_BUFF_LEN));
break; break;
case TSDB_DATA_TYPE_UINT:
tmp = rand_uint_str();
tmpLen = strlen(tmp);
tstrncpy(pstr + dataLen, tmp, min(tmpLen + 1, INT_BUFF_LEN));
break;
case TSDB_DATA_TYPE_BIGINT: case TSDB_DATA_TYPE_BIGINT:
tmp = rand_bigint_str(); tmp = rand_bigint_str();
tstrncpy(pstr + dataLen, tmp, BIGINT_BUFF_LEN); tmpLen = strlen(tmp);
tstrncpy(pstr + dataLen, tmp, min(tmpLen + 1, BIGINT_BUFF_LEN));
break;
case TSDB_DATA_TYPE_UBIGINT:
tmp = rand_ubigint_str();
tmpLen = strlen(tmp);
tstrncpy(pstr + dataLen, tmp, min(tmpLen + 1, BIGINT_BUFF_LEN));
break; break;
case TSDB_DATA_TYPE_FLOAT: case TSDB_DATA_TYPE_FLOAT:
...@@ -6201,38 +6504,49 @@ static int64_t generateStbRowData( ...@@ -6201,38 +6504,49 @@ static int64_t generateStbRowData(
tmp = rand_float_str(); tmp = rand_float_str();
} }
tmpLen = strlen(tmp); tmpLen = strlen(tmp);
tstrncpy(pstr + dataLen, tmp, min(tmpLen +1, FLOAT_BUFF_LEN)); tstrncpy(pstr + dataLen, tmp, min(tmpLen + 1, FLOAT_BUFF_LEN));
break; break;
case TSDB_DATA_TYPE_DOUBLE: case TSDB_DATA_TYPE_DOUBLE:
tmp = rand_double_str(); tmp = rand_double_str();
tmpLen = strlen(tmp); tmpLen = strlen(tmp);
tstrncpy(pstr + dataLen, tmp, min(tmpLen +1, DOUBLE_BUFF_LEN)); tstrncpy(pstr + dataLen, tmp, min(tmpLen + 1, DOUBLE_BUFF_LEN));
break; break;
case TSDB_DATA_TYPE_SMALLINT: case TSDB_DATA_TYPE_SMALLINT:
tmp = rand_smallint_str(); tmp = rand_smallint_str();
tmpLen = strlen(tmp); tmpLen = strlen(tmp);
tstrncpy(pstr + dataLen, tmp, tstrncpy(pstr + dataLen, tmp, min(tmpLen + 1, SMALLINT_BUFF_LEN));
min(tmpLen + 1, SMALLINT_BUFF_LEN)); break;
case TSDB_DATA_TYPE_USMALLINT:
tmp = rand_usmallint_str();
tmpLen = strlen(tmp);
tstrncpy(pstr + dataLen, tmp, min(tmpLen + 1, SMALLINT_BUFF_LEN));
break; break;
case TSDB_DATA_TYPE_TINYINT: case TSDB_DATA_TYPE_TINYINT:
tmp = rand_tinyint_str(); tmp = rand_tinyint_str();
tmpLen = strlen(tmp); tmpLen = strlen(tmp);
tstrncpy(pstr + dataLen, tmp, min(tmpLen +1, TINYINT_BUFF_LEN)); tstrncpy(pstr + dataLen, tmp, min(tmpLen + 1, TINYINT_BUFF_LEN));
break;
case TSDB_DATA_TYPE_UTINYINT:
tmp = rand_utinyint_str();
tmpLen = strlen(tmp);
tstrncpy(pstr + dataLen, tmp, min(tmpLen + 1, TINYINT_BUFF_LEN));
break; break;
case TSDB_DATA_TYPE_BOOL: case TSDB_DATA_TYPE_BOOL:
tmp = rand_bool_str(); tmp = rand_bool_str();
tmpLen = strlen(tmp); tmpLen = strlen(tmp);
tstrncpy(pstr + dataLen, tmp, min(tmpLen +1, BOOL_BUFF_LEN)); tstrncpy(pstr + dataLen, tmp, min(tmpLen + 1, BOOL_BUFF_LEN));
break; break;
case TSDB_DATA_TYPE_TIMESTAMP: case TSDB_DATA_TYPE_TIMESTAMP:
tmp = rand_bigint_str(); tmp = rand_bigint_str();
tmpLen = strlen(tmp); tmpLen = strlen(tmp);
tstrncpy(pstr + dataLen, tmp, min(tmpLen +1, BIGINT_BUFF_LEN)); tstrncpy(pstr + dataLen, tmp, min(tmpLen + 1, BIGINT_BUFF_LEN));
break; break;
case TSDB_DATA_TYPE_NULL: case TSDB_DATA_TYPE_NULL:
...@@ -6243,9 +6557,8 @@ static int64_t generateStbRowData( ...@@ -6243,9 +6557,8 @@ static int64_t generateStbRowData(
stbInfo->columns[i].dataType); stbInfo->columns[i].dataType);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (tmp) { if (tmp) {
dataLen += strlen(tmp); dataLen += tmpLen;
} }
} }
...@@ -6253,7 +6566,7 @@ static int64_t generateStbRowData( ...@@ -6253,7 +6566,7 @@ static int64_t generateStbRowData(
return 0; return 0;
} }
tstrncpy(pstr + dataLen, ")", 2); dataLen += snprintf(pstr + dataLen, 2, ")");
verbosePrint("%s() LN%d, dataLen:%"PRId64"\n", __func__, __LINE__, dataLen); verbosePrint("%s() LN%d, dataLen:%"PRId64"\n", __func__, __LINE__, dataLen);
verbosePrint("%s() LN%d, recBuf:\n\t%s\n", __func__, __LINE__, recBuf); verbosePrint("%s() LN%d, recBuf:\n\t%s\n", __func__, __LINE__, recBuf);
...@@ -6330,6 +6643,22 @@ static int64_t generateData(char *recBuf, char *data_type, ...@@ -6330,6 +6643,22 @@ static int64_t generateData(char *recBuf, char *data_type,
free(s); free(s);
break; break;
case TSDB_DATA_TYPE_UTINYINT:
pstr += sprintf(pstr, ",%d", rand_utinyint() );
break;
case TSDB_DATA_TYPE_USMALLINT:
pstr += sprintf(pstr, ",%d", rand_usmallint());
break;
case TSDB_DATA_TYPE_UINT:
pstr += sprintf(pstr, ",%d", rand_uint());
break;
case TSDB_DATA_TYPE_UBIGINT:
pstr += sprintf(pstr, ",%"PRId64"", rand_ubigint());
break;
case TSDB_DATA_TYPE_NULL: case TSDB_DATA_TYPE_NULL:
break; break;
...@@ -6401,10 +6730,18 @@ static int generateSampleFromRand( ...@@ -6401,10 +6730,18 @@ static int generateSampleFromRand(
pos += sprintf(buff + pos, "%s,", tmp); pos += sprintf(buff + pos, "%s,", tmp);
break; break;
case TSDB_DATA_TYPE_UINT:
pos += sprintf(buff + pos, "%s,", rand_uint_str());
break;
case TSDB_DATA_TYPE_BIGINT: case TSDB_DATA_TYPE_BIGINT:
pos += sprintf(buff + pos, "%s,", rand_bigint_str()); pos += sprintf(buff + pos, "%s,", rand_bigint_str());
break; break;
case TSDB_DATA_TYPE_UBIGINT:
pos += sprintf(buff + pos, "%s,", rand_ubigint_str());
break;
case TSDB_DATA_TYPE_FLOAT: case TSDB_DATA_TYPE_FLOAT:
if (g_args.demo_mode) { if (g_args.demo_mode) {
if (c == 0) { if (c == 0) {
...@@ -6426,10 +6763,18 @@ static int generateSampleFromRand( ...@@ -6426,10 +6763,18 @@ static int generateSampleFromRand(
pos += sprintf(buff + pos, "%s,", rand_smallint_str()); pos += sprintf(buff + pos, "%s,", rand_smallint_str());
break; break;
case TSDB_DATA_TYPE_USMALLINT:
pos += sprintf(buff + pos, "%s,", rand_usmallint_str());
break;
case TSDB_DATA_TYPE_TINYINT: case TSDB_DATA_TYPE_TINYINT:
pos += sprintf(buff + pos, "%s,", rand_tinyint_str()); pos += sprintf(buff + pos, "%s,", rand_tinyint_str());
break; break;
case TSDB_DATA_TYPE_UTINYINT:
pos += sprintf(buff + pos, "%s,", rand_utinyint_str());
break;
case TSDB_DATA_TYPE_BOOL: case TSDB_DATA_TYPE_BOOL:
pos += sprintf(buff + pos, "%s,", rand_bool_str()); pos += sprintf(buff + pos, "%s,", rand_bool_str());
break; break;
...@@ -6953,13 +7298,17 @@ static int32_t prepareStmtBindArrayByType( ...@@ -6953,13 +7298,17 @@ static int32_t prepareStmtBindArrayByType(
char *value) char *value)
{ {
int32_t *bind_int; int32_t *bind_int;
uint32_t *bind_uint;
int64_t *bind_bigint; int64_t *bind_bigint;
uint64_t *bind_ubigint;
float *bind_float; float *bind_float;
double *bind_double; double *bind_double;
int8_t *bind_bool; int8_t *bind_bool;
int64_t *bind_ts2; int64_t *bind_ts2;
int16_t *bind_smallint; int16_t *bind_smallint;
uint16_t *bind_usmallint;
int8_t *bind_tinyint; int8_t *bind_tinyint;
uint8_t *bind_utinyint;
switch(data_type) { switch(data_type) {
case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_BINARY:
...@@ -7024,6 +7373,22 @@ static int32_t prepareStmtBindArrayByType( ...@@ -7024,6 +7373,22 @@ static int32_t prepareStmtBindArrayByType(
bind->length = &bind->buffer_length; bind->length = &bind->buffer_length;
bind->is_null = NULL; bind->is_null = NULL;
break; break;
case TSDB_DATA_TYPE_UINT:
bind_uint = malloc(sizeof(uint32_t));
assert(bind_uint);
if (value) {
*bind_uint = atoi(value);
} else {
*bind_uint = rand_int();
}
bind->buffer_type = TSDB_DATA_TYPE_UINT;
bind->buffer_length = sizeof(uint32_t);
bind->buffer = bind_uint;
bind->length = &bind->buffer_length;
bind->is_null = NULL;
break;
case TSDB_DATA_TYPE_BIGINT: case TSDB_DATA_TYPE_BIGINT:
bind_bigint = malloc(sizeof(int64_t)); bind_bigint = malloc(sizeof(int64_t));
...@@ -7041,6 +7406,22 @@ static int32_t prepareStmtBindArrayByType( ...@@ -7041,6 +7406,22 @@ static int32_t prepareStmtBindArrayByType(
bind->is_null = NULL; bind->is_null = NULL;
break; break;
case TSDB_DATA_TYPE_UBIGINT:
bind_ubigint = malloc(sizeof(uint64_t));
assert(bind_ubigint);
if (value) {
*bind_ubigint = atoll(value);
} else {
*bind_ubigint = rand_bigint();
}
bind->buffer_type = TSDB_DATA_TYPE_UBIGINT;
bind->buffer_length = sizeof(uint64_t);
bind->buffer = bind_ubigint;
bind->length = &bind->buffer_length;
bind->is_null = NULL;
break;
case TSDB_DATA_TYPE_FLOAT: case TSDB_DATA_TYPE_FLOAT:
bind_float = malloc(sizeof(float)); bind_float = malloc(sizeof(float));
assert(bind_float); assert(bind_float);
...@@ -7089,6 +7470,22 @@ static int32_t prepareStmtBindArrayByType( ...@@ -7089,6 +7470,22 @@ static int32_t prepareStmtBindArrayByType(
bind->is_null = NULL; bind->is_null = NULL;
break; break;
case TSDB_DATA_TYPE_USMALLINT:
bind_usmallint = malloc(sizeof(uint16_t));
assert(bind_usmallint);
if (value) {
*bind_usmallint = (uint16_t)atoi(value);
} else {
*bind_usmallint = rand_smallint();
}
bind->buffer_type = TSDB_DATA_TYPE_SMALLINT;
bind->buffer_length = sizeof(uint16_t);
bind->buffer = bind_usmallint;
bind->length = &bind->buffer_length;
bind->is_null = NULL;
break;
case TSDB_DATA_TYPE_TINYINT: case TSDB_DATA_TYPE_TINYINT:
bind_tinyint = malloc(sizeof(int8_t)); bind_tinyint = malloc(sizeof(int8_t));
assert(bind_tinyint); assert(bind_tinyint);
...@@ -7105,6 +7502,22 @@ static int32_t prepareStmtBindArrayByType( ...@@ -7105,6 +7502,22 @@ static int32_t prepareStmtBindArrayByType(
bind->is_null = NULL; bind->is_null = NULL;
break; break;
case TSDB_DATA_TYPE_UTINYINT:
bind_utinyint = malloc(sizeof(uint8_t));
assert(bind_utinyint);
if (value) {
*bind_utinyint = (int8_t)atoi(value);
} else {
*bind_utinyint = rand_tinyint();
}
bind->buffer_type = TSDB_DATA_TYPE_UTINYINT;
bind->buffer_length = sizeof(uint8_t);
bind->buffer = bind_utinyint;
bind->length = &bind->buffer_length;
bind->is_null = NULL;
break;
case TSDB_DATA_TYPE_BOOL: case TSDB_DATA_TYPE_BOOL:
bind_bool = malloc(sizeof(int8_t)); bind_bool = malloc(sizeof(int8_t));
assert(bind_bool); assert(bind_bool);
...@@ -7179,11 +7592,15 @@ static int32_t prepareStmtBindArrayByTypeForRand( ...@@ -7179,11 +7592,15 @@ static int32_t prepareStmtBindArrayByTypeForRand(
char *value) char *value)
{ {
int32_t *bind_int; int32_t *bind_int;
uint32_t *bind_uint;
int64_t *bind_bigint; int64_t *bind_bigint;
uint64_t *bind_ubigint;
float *bind_float; float *bind_float;
double *bind_double; double *bind_double;
int16_t *bind_smallint; int16_t *bind_smallint;
uint16_t *bind_usmallint;
int8_t *bind_tinyint; int8_t *bind_tinyint;
uint8_t *bind_utinyint;
int8_t *bind_bool; int8_t *bind_bool;
int64_t *bind_ts2; int64_t *bind_ts2;
...@@ -7253,6 +7670,23 @@ static int32_t prepareStmtBindArrayByTypeForRand( ...@@ -7253,6 +7670,23 @@ static int32_t prepareStmtBindArrayByTypeForRand(
*ptr += bind->buffer_length; *ptr += bind->buffer_length;
break; break;
case TSDB_DATA_TYPE_UINT:
bind_uint = (uint32_t *)*ptr;
if (value) {
*bind_uint = atoi(value);
} else {
*bind_uint = rand_int();
}
bind->buffer_type = TSDB_DATA_TYPE_UINT;
bind->buffer_length = sizeof(uint32_t);
bind->buffer = bind_uint;
bind->length = &bind->buffer_length;
bind->is_null = NULL;
*ptr += bind->buffer_length;
break;
case TSDB_DATA_TYPE_BIGINT: case TSDB_DATA_TYPE_BIGINT:
bind_bigint = (int64_t *)*ptr; bind_bigint = (int64_t *)*ptr;
...@@ -7270,6 +7704,23 @@ static int32_t prepareStmtBindArrayByTypeForRand( ...@@ -7270,6 +7704,23 @@ static int32_t prepareStmtBindArrayByTypeForRand(
*ptr += bind->buffer_length; *ptr += bind->buffer_length;
break; break;
case TSDB_DATA_TYPE_UBIGINT:
bind_ubigint = (uint64_t *)*ptr;
if (value) {
*bind_ubigint = atoll(value);
} else {
*bind_ubigint = rand_bigint();
}
bind->buffer_type = TSDB_DATA_TYPE_UBIGINT;
bind->buffer_length = sizeof(uint64_t);
bind->buffer = bind_ubigint;
bind->length = &bind->buffer_length;
bind->is_null = NULL;
*ptr += bind->buffer_length;
break;
case TSDB_DATA_TYPE_FLOAT: case TSDB_DATA_TYPE_FLOAT:
bind_float = (float *)*ptr; bind_float = (float *)*ptr;
...@@ -7321,6 +7772,23 @@ static int32_t prepareStmtBindArrayByTypeForRand( ...@@ -7321,6 +7772,23 @@ static int32_t prepareStmtBindArrayByTypeForRand(
*ptr += bind->buffer_length; *ptr += bind->buffer_length;
break; break;
case TSDB_DATA_TYPE_USMALLINT:
bind_usmallint = (uint16_t *)*ptr;
if (value) {
*bind_usmallint = (uint16_t)atoi(value);
} else {
*bind_usmallint = rand_smallint();
}
bind->buffer_type = TSDB_DATA_TYPE_USMALLINT;
bind->buffer_length = sizeof(uint16_t);
bind->buffer = bind_usmallint;
bind->length = &bind->buffer_length;
bind->is_null = NULL;
*ptr += bind->buffer_length;
break;
case TSDB_DATA_TYPE_TINYINT: case TSDB_DATA_TYPE_TINYINT:
bind_tinyint = (int8_t *)*ptr; bind_tinyint = (int8_t *)*ptr;
...@@ -7338,6 +7806,23 @@ static int32_t prepareStmtBindArrayByTypeForRand( ...@@ -7338,6 +7806,23 @@ static int32_t prepareStmtBindArrayByTypeForRand(
*ptr += bind->buffer_length; *ptr += bind->buffer_length;
break; break;
case TSDB_DATA_TYPE_UTINYINT:
bind_utinyint = (uint8_t *)*ptr;
if (value) {
*bind_utinyint = (uint8_t)atoi(value);
} else {
*bind_utinyint = rand_tinyint();
}
bind->buffer_type = TSDB_DATA_TYPE_UTINYINT;
bind->buffer_length = sizeof(uint8_t);
bind->buffer = bind_utinyint;
bind->length = &bind->buffer_length;
bind->is_null = NULL;
*ptr += bind->buffer_length;
break;
case TSDB_DATA_TYPE_BOOL: case TSDB_DATA_TYPE_BOOL:
bind_bool = (int8_t *)*ptr; bind_bool = (int8_t *)*ptr;
...@@ -7745,6 +8230,7 @@ static int execStbBindParamBatch( ...@@ -7745,6 +8230,7 @@ static int execStbBindParamBatch(
break; break;
case TSDB_DATA_TYPE_INT: case TSDB_DATA_TYPE_INT:
case TSDB_DATA_TYPE_UINT:
param->buffer_length = sizeof(int32_t); param->buffer_length = sizeof(int32_t);
param->buffer = param->buffer =
(void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1)) (void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1))
...@@ -7752,6 +8238,7 @@ static int execStbBindParamBatch( ...@@ -7752,6 +8238,7 @@ static int execStbBindParamBatch(
break; break;
case TSDB_DATA_TYPE_TINYINT: case TSDB_DATA_TYPE_TINYINT:
case TSDB_DATA_TYPE_UTINYINT:
param->buffer_length = sizeof(int8_t); param->buffer_length = sizeof(int8_t);
param->buffer = param->buffer =
(void *)((uintptr_t)*(uintptr_t*)( (void *)((uintptr_t)*(uintptr_t*)(
...@@ -7761,6 +8248,7 @@ static int execStbBindParamBatch( ...@@ -7761,6 +8248,7 @@ static int execStbBindParamBatch(
break; break;
case TSDB_DATA_TYPE_SMALLINT: case TSDB_DATA_TYPE_SMALLINT:
case TSDB_DATA_TYPE_USMALLINT:
param->buffer_length = sizeof(int16_t); param->buffer_length = sizeof(int16_t);
param->buffer = param->buffer =
(void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1)) (void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1))
...@@ -7768,6 +8256,7 @@ static int execStbBindParamBatch( ...@@ -7768,6 +8256,7 @@ static int execStbBindParamBatch(
break; break;
case TSDB_DATA_TYPE_BIGINT: case TSDB_DATA_TYPE_BIGINT:
case TSDB_DATA_TYPE_UBIGINT:
param->buffer_length = sizeof(int64_t); param->buffer_length = sizeof(int64_t);
param->buffer = param->buffer =
(void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1)) (void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1))
...@@ -7904,24 +8393,28 @@ static int parseSamplefileToStmtBatch( ...@@ -7904,24 +8393,28 @@ static int parseSamplefileToStmtBatch(
switch(data_type) { switch(data_type) {
case TSDB_DATA_TYPE_INT: case TSDB_DATA_TYPE_INT:
case TSDB_DATA_TYPE_UINT:
tmpP = calloc(1, sizeof(int) * MAX_SAMPLES); tmpP = calloc(1, sizeof(int) * MAX_SAMPLES);
assert(tmpP); assert(tmpP);
*(uintptr_t*)(sampleBindBatchArray+ sizeof(uintptr_t*)*c) = (uintptr_t)tmpP; *(uintptr_t*)(sampleBindBatchArray+ sizeof(uintptr_t*)*c) = (uintptr_t)tmpP;
break; break;
case TSDB_DATA_TYPE_TINYINT: case TSDB_DATA_TYPE_TINYINT:
case TSDB_DATA_TYPE_UTINYINT:
tmpP = calloc(1, sizeof(int8_t) * MAX_SAMPLES); tmpP = calloc(1, sizeof(int8_t) * MAX_SAMPLES);
assert(tmpP); assert(tmpP);
*(uintptr_t*)(sampleBindBatchArray+ sizeof(uintptr_t*)*c) = (uintptr_t)tmpP; *(uintptr_t*)(sampleBindBatchArray+ sizeof(uintptr_t*)*c) = (uintptr_t)tmpP;
break; break;
case TSDB_DATA_TYPE_SMALLINT: case TSDB_DATA_TYPE_SMALLINT:
case TSDB_DATA_TYPE_USMALLINT:
tmpP = calloc(1, sizeof(int16_t) * MAX_SAMPLES); tmpP = calloc(1, sizeof(int16_t) * MAX_SAMPLES);
assert(tmpP); assert(tmpP);
*(uintptr_t*)(sampleBindBatchArray+ sizeof(uintptr_t*)*c) = (uintptr_t)tmpP; *(uintptr_t*)(sampleBindBatchArray+ sizeof(uintptr_t*)*c) = (uintptr_t)tmpP;
break; break;
case TSDB_DATA_TYPE_BIGINT: case TSDB_DATA_TYPE_BIGINT:
case TSDB_DATA_TYPE_UBIGINT:
tmpP = calloc(1, sizeof(int64_t) * MAX_SAMPLES); tmpP = calloc(1, sizeof(int64_t) * MAX_SAMPLES);
assert(tmpP); assert(tmpP);
*(uintptr_t*)(sampleBindBatchArray+ sizeof(uintptr_t*)*c) = (uintptr_t)tmpP; *(uintptr_t*)(sampleBindBatchArray+ sizeof(uintptr_t*)*c) = (uintptr_t)tmpP;
...@@ -8000,6 +8493,7 @@ static int parseSamplefileToStmtBatch( ...@@ -8000,6 +8493,7 @@ static int parseSamplefileToStmtBatch(
switch(data_type) { switch(data_type) {
case TSDB_DATA_TYPE_INT: case TSDB_DATA_TYPE_INT:
case TSDB_DATA_TYPE_UINT:
*((int32_t*)((uintptr_t)*(uintptr_t*)(sampleBindBatchArray *((int32_t*)((uintptr_t)*(uintptr_t*)(sampleBindBatchArray
+sizeof(char*)*c)+sizeof(int32_t)*i)) = +sizeof(char*)*c)+sizeof(int32_t)*i)) =
atoi(tmpStr); atoi(tmpStr);
...@@ -8018,18 +8512,21 @@ static int parseSamplefileToStmtBatch( ...@@ -8018,18 +8512,21 @@ static int parseSamplefileToStmtBatch(
break; break;
case TSDB_DATA_TYPE_TINYINT: case TSDB_DATA_TYPE_TINYINT:
case TSDB_DATA_TYPE_UTINYINT:
*((int8_t*)((uintptr_t)*(uintptr_t*)(sampleBindBatchArray *((int8_t*)((uintptr_t)*(uintptr_t*)(sampleBindBatchArray
+sizeof(char*)*c)+sizeof(int8_t)*i)) = +sizeof(char*)*c)+sizeof(int8_t)*i)) =
(int8_t)atoi(tmpStr); (int8_t)atoi(tmpStr);
break; break;
case TSDB_DATA_TYPE_SMALLINT: case TSDB_DATA_TYPE_SMALLINT:
case TSDB_DATA_TYPE_USMALLINT:
*((int16_t*)((uintptr_t)*(uintptr_t*)(sampleBindBatchArray *((int16_t*)((uintptr_t)*(uintptr_t*)(sampleBindBatchArray
+sizeof(char*)*c)+sizeof(int16_t)*i)) = +sizeof(char*)*c)+sizeof(int16_t)*i)) =
(int16_t)atoi(tmpStr); (int16_t)atoi(tmpStr);
break; break;
case TSDB_DATA_TYPE_BIGINT: case TSDB_DATA_TYPE_BIGINT:
case TSDB_DATA_TYPE_UBIGINT:
*((int64_t*)((uintptr_t)*(uintptr_t*)(sampleBindBatchArray *((int64_t*)((uintptr_t)*(uintptr_t*)(sampleBindBatchArray
+sizeof(char*)*c)+sizeof(int64_t)*i)) = +sizeof(char*)*c)+sizeof(int64_t)*i)) =
(int64_t)atol(tmpStr); (int64_t)atol(tmpStr);
...@@ -11565,5 +12062,4 @@ int main(int argc, char *argv[]) { ...@@ -11565,5 +12062,4 @@ int main(int argc, char *argv[]) {
} }
return 0; return 0;
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册