From f15668cb7df09ce39608e359abb6ed62aa12893e Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Fri, 22 May 2020 02:35:37 +0000 Subject: [PATCH 01/16] [non-jira]change tsdb tag mechanism --- src/common/inc/tdataformat.h | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/common/inc/tdataformat.h b/src/common/inc/tdataformat.h index 51a5dad486..eef2e51cc2 100644 --- a/src/common/inc/tdataformat.h +++ b/src/common/inc/tdataformat.h @@ -198,6 +198,44 @@ void tdPopDataColsPoints(SDataCols *pCols, int pointsToPop); //!!!! int tdMergeDataCols(SDataCols *target, SDataCols *src, int rowsToMerge); void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, SDataCols *src2, int *iter2, int tRows); + +// ----------------- Tag row structure + +/* A tag row, the format is like below: ++----------+-------------------------------------------------------------+---------------------------------+ +| int16 | int16 | int64 | int16 | int64 | ...| int16 | int64 | char | ++----------+-------------------------------------------------------------+---------------------------------+ +| ncols | colId1 | offset1 | colId2 | offset2 | ...| colIdN | offsetN | values | ++----------+-------------------------------------------------------------+---------------------------------+ + */ +typedef void *STagRowRaw; + +#define TD_TAG_ROW_HEAD_SIZE sizeof(int16_t) + +#define tagRowNum(r) (*(int16_t *)(r)) +#define tagRowArray(r) POINTER_SHIFT(r, TD_TAG_ROW_HEAD_SIZE) +//#define dataRowKey(r) (*(TSKEY *)(dataRowTuple(r))) +//#define dataRowSetLen(r, l) (dataRowLen(r) = (l)) +//#define dataRowCpy(dst, r) memcpy((dst), (r), dataRowLen(r)) +//#define dataRowMaxBytesFromSchema(s) (schemaTLen(s) + TD_DATA_ROW_HEAD_SIZE) + +typedef struct { + int16_t colId; // column ID + union{ + int64_t tagOffset; + int64_t tagValue; + }; +} STagCol; + +typedef struct { + int16_t nCols; // Total columns allocated + STagCol tagCols[]; +} STagRow; + + + + + #ifdef __cplusplus } #endif From 0f43e08f591d65812d38df9eeca994a41e751794 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Sat, 23 May 2020 03:37:07 +0000 Subject: [PATCH 02/16] [TD-90]Tag Schema --- src/common/inc/tdataformat.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/common/inc/tdataformat.h b/src/common/inc/tdataformat.h index eef2e51cc2..30fb18bb95 100644 --- a/src/common/inc/tdataformat.h +++ b/src/common/inc/tdataformat.h @@ -208,7 +208,7 @@ void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, SD | ncols | colId1 | offset1 | colId2 | offset2 | ...| colIdN | offsetN | values | +----------+-------------------------------------------------------------+---------------------------------+ */ -typedef void *STagRowRaw; + #define TD_TAG_ROW_HEAD_SIZE sizeof(int16_t) @@ -221,20 +221,20 @@ typedef void *STagRowRaw; typedef struct { int16_t colId; // column ID - union{ - int64_t tagOffset; - int64_t tagValue; - }; + int16_t colLen; // if col type is binary/Nchar, this is the length of binary/Nchar + int64_t valueOrOffset; //to store value for numeric col or offset for binary/Nchar } STagCol; typedef struct { - int16_t nCols; // Total columns allocated - STagCol tagCols[]; + int32_t len; + void * pBinaryData; // Space to store the binary and Nchar value + int16_t ncols; // Total columns allocated + STagCol tagCols[]; } STagRow; - - - +int tdInsertTagCol(SDataRow *row, void *value, int32_t bytes, int16_t colId); +int tdQuerTagByID(SDataRow row, void *value, int16_t colId); +SDataRow tdNewTagRowFromSchema(STSchema *pSchema); #ifdef __cplusplus } From df01a390d4fbd2f7832bf0e57183e95fd5623efe Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Sat, 23 May 2020 09:40:46 +0000 Subject: [PATCH 03/16] [TD-90] developing --- src/common/inc/tdataformat.h | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/common/inc/tdataformat.h b/src/common/inc/tdataformat.h index 30fb18bb95..4c3e578a9a 100644 --- a/src/common/inc/tdataformat.h +++ b/src/common/inc/tdataformat.h @@ -221,20 +221,28 @@ void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, SD typedef struct { int16_t colId; // column ID - int16_t colLen; // if col type is binary/Nchar, this is the length of binary/Nchar - int64_t valueOrOffset; //to store value for numeric col or offset for binary/Nchar + int8_t colType; + int8_t colLen; // if col type is binary/Nchar, this is the length of binary/Nchar + int16_t offset; //to store value for numeric col or offset for binary/Nchar } STagCol; typedef struct { int32_t len; - void * pBinaryData; // Space to store the binary and Nchar value + void * pData; // Space to store the tag value int16_t ncols; // Total columns allocated STagCol tagCols[]; } STagRow; -int tdInsertTagCol(SDataRow *row, void *value, int32_t bytes, int16_t colId); -int tdQuerTagByID(SDataRow row, void *value, int16_t colId); + +#define tagColSize(r) (sizeof(STagCol) + r.colLen) + +int tdInsertTagCol(SDataRow row, void *value, int16_t len, int8_t type, int16_t colId); //insert tag value and update all the information +int tdDeleteTagCol(SDataRow row, int16_t colId); // delete tag value and update all the information +int tdQuerTagByID(SDataRow row, int16_t colId, void *value); //if find tag, return value length, else return -1; +int tdAppendTagColVal(SDataRow row, void *value, int8_t type, int32_t bytes); + SDataRow tdNewTagRowFromSchema(STSchema *pSchema); +STSchema *tdGetSchemaFromData(SDataRow *row); #ifdef __cplusplus } From eb6b6e0c746c2968a77cfe8243f315e1f2dc2315 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Sun, 24 May 2020 08:48:51 +0000 Subject: [PATCH 04/16] [TD-90] alter tag function develop --- src/common/inc/tdataformat.h | 20 ++++++++++-------- src/common/src/tdataformat.c | 39 ++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 8 deletions(-) diff --git a/src/common/inc/tdataformat.h b/src/common/inc/tdataformat.h index 4c3e578a9a..0aec948015 100644 --- a/src/common/inc/tdataformat.h +++ b/src/common/inc/tdataformat.h @@ -202,11 +202,15 @@ void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, SD // ----------------- Tag row structure /* A tag row, the format is like below: -+----------+-------------------------------------------------------------+---------------------------------+ -| int16 | int16 | int64 | int16 | int64 | ...| int16 | int64 | char | -+----------+-------------------------------------------------------------+---------------------------------+ -| ncols | colId1 | offset1 | colId2 | offset2 | ...| colIdN | offsetN | values | -+----------+-------------------------------------------------------------+---------------------------------+ ++----------+----------------------------------------------------------------+ +| STagRow | STagCol | STagCol | STagCol | STagCol | ...| STagCol | STagCol | ++----------+----------------------------------------------------------------+ + +pData ++----------+----------------------------------------------------------------+ +| value 1 | value 2 | value 3 | value 4 | ....|value n | ++----------+----------------------------------------------------------------+ + */ @@ -221,8 +225,8 @@ void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, SD typedef struct { int16_t colId; // column ID - int8_t colType; - int8_t colLen; // if col type is binary/Nchar, this is the length of binary/Nchar + int16_t colType; + int16_t colLen; // if col type is binary/Nchar, this is the length of binary/Nchar int16_t offset; //to store value for numeric col or offset for binary/Nchar } STagCol; @@ -238,7 +242,7 @@ typedef struct { int tdInsertTagCol(SDataRow row, void *value, int16_t len, int8_t type, int16_t colId); //insert tag value and update all the information int tdDeleteTagCol(SDataRow row, int16_t colId); // delete tag value and update all the information -int tdQuerTagByID(SDataRow row, int16_t colId, void *value); //if find tag, return value length, else return -1; +int tdQuerTagByID(SDataRow row, int16_t colId, void *value, int16_t *type, int16_t *len); //if find tag, 0, else return -1; int tdAppendTagColVal(SDataRow row, void *value, int8_t type, int32_t bytes); SDataRow tdNewTagRowFromSchema(STSchema *pSchema); diff --git a/src/common/src/tdataformat.c b/src/common/src/tdataformat.c index 9d81cd07af..3df94452d8 100644 --- a/src/common/src/tdataformat.c +++ b/src/common/src/tdataformat.c @@ -151,6 +151,26 @@ SDataRow tdNewDataRowFromSchema(STSchema *pSchema) { return row; } +int tdInsertTagCol(SDataRow row, void *value, int16_t len, int8_t type, int16_t colId){ //insert tag value and update all the information + return 0; +}; + +int tdDeleteTagCol(SDataRow row, int16_t colId){ // delete tag value and update all the information + return o; +}; + +int tdQuerTagByID(SDataRow row, int16_t colId, void *value, int16_t *type, int16_t *len){ //if find tag, 0, else return -1; + return 0; +}; + +int tdAppendTagColVal(SDataRow row, void *value, int8_t type, int32_t bytes){ + return 0; +}; + +SDataRow tdNewTagRowFromSchema(STSchema *pSchema) { + //todo +} + /** * Free the SDataRow object */ @@ -183,6 +203,25 @@ int tdAppendColVal(SDataRow row, void *value, int8_t type, int32_t bytes, int32_ return 0; } +int tdAppendColVal(SDataRow row, void *value, int8_t type, int32_t bytes, int32_t offset) { + ASSERT(value != NULL); + int32_t toffset = offset + TD_DATA_ROW_HEAD_SIZE; + char * ptr = POINTER_SHIFT(row, dataRowLen(row)); + + switch (type) { + case TSDB_DATA_TYPE_BINARY: + case TSDB_DATA_TYPE_NCHAR: + *(VarDataOffsetT *)POINTER_SHIFT(row, toffset) = dataRowLen(row); + memcpy(ptr, value, varDataTLen(value)); + dataRowLen(row) += varDataTLen(value); + break; + default: + memcpy(POINTER_SHIFT(row, toffset), value, TYPE_BYTES[type]); + break; + } + + return 0; +} SDataRow tdDataRowDup(SDataRow row) { SDataRow trow = malloc(dataRowLen(row)); From c1bc7ef982d1021579a141b119762fb3c36ca4b1 Mon Sep 17 00:00:00 2001 From: Bomin Zhang Date: Tue, 26 May 2020 16:51:26 +0800 Subject: [PATCH 05/16] shell suport multiple commands in single statement --- src/kit/shell/src/shellDarwin.c | 9 +- src/kit/shell/src/shellEngine.c | 201 +++++++++++++++++-------------- src/kit/shell/src/shellLinux.c | 10 +- src/kit/shell/src/shellWindows.c | 7 +- 4 files changed, 116 insertions(+), 111 deletions(-) diff --git a/src/kit/shell/src/shellDarwin.c b/src/kit/shell/src/shellDarwin.c index e4ef06c403..987087d71f 100644 --- a/src/kit/shell/src/shellDarwin.c +++ b/src/kit/shell/src/shellDarwin.c @@ -335,17 +335,14 @@ void *shellLoopQuery(void *arg) { tscError("failed to malloc command"); return NULL; } - while (1) { - // Read command from shell. + do { + // Read command from shell. memset(command, 0, MAX_COMMAND_SIZE); set_terminal_mode(); shellReadCommand(con, command); reset_terminal_mode(); - - // Run the command - shellRunCommand(con, command); - } + } while (shellRunCommand(con, command) == 0); pthread_cleanup_pop(1); diff --git a/src/kit/shell/src/shellEngine.c b/src/kit/shell/src/shellEngine.c index 93818d7d73..4ef51eaa5a 100644 --- a/src/kit/shell/src/shellEngine.c +++ b/src/kit/shell/src/shellEngine.c @@ -82,20 +82,15 @@ TAOS *shellInit(SShellArguments *args) { // Check if it is temperory run if (args->commands != NULL || args->file[0] != 0) { if (args->commands != NULL) { - char *token; - token = strtok(args->commands, ";"); - while (token != NULL) { - printf("%s%s\n", PROMPT_HEADER, token); - shellRunCommand(con, token); - token = strtok(NULL, ";"); - } + printf("%s%s\n", PROMPT_HEADER, args->commands); + shellRunCommand(con, args->commands); } if (args->file[0] != 0) { source_file(con, args->file); } - taos_close(con); + taos_close(con); write_history(); exit(EXIT_SUCCESS); } @@ -111,67 +106,66 @@ TAOS *shellInit(SShellArguments *args) { return con; } -void shellReplaceCtrlChar(char *str) { - _Bool ctrlOn = false; - char *pstr = NULL; - char quote = 0; - for (pstr = str; *str != '\0'; ++str) { - if (ctrlOn) { - switch (*str) { - case 'n': - *pstr = '\n'; - pstr++; - break; - case 'r': - *pstr = '\r'; - pstr++; - break; - case 't': - *pstr = '\t'; - pstr++; - break; - case 'G': - *pstr++ = '\\'; - *pstr++ = *str; - break; - case '\\': - *pstr = '\\'; - pstr++; - break; - case '\'': - case '"': - if (quote) { - *pstr++ = '\\'; - *pstr++ = *str; - } - break; - default: - *pstr = *str; - pstr++; - break; - } - ctrlOn = false; - } else { - if (*str == '\\') { - ctrlOn = true; - } else { - if (quote == *str) { - quote = 0; - } else if (*str == '\'' || *str == '"') { - quote = *str; - } - *pstr = *str; - pstr++; - } +static bool isEmptyCommand(const char* cmd) { + for (char c = *cmd++; c != 0; c = *cmd++) { + if (c != ' ' && c != '\t' && c != ';') { + return false; } } - *pstr = '\0'; + return true; } -int32_t shellRunCommand(TAOS *con, char *command) { + +static int32_t shellRunSingleCommand(TAOS *con, char *command) { /* If command is empty just return */ - if (regex_match(command, "^[ \t;]*$", REG_EXTENDED)) { + if (isEmptyCommand(command)) { + return 0; + } + + // Analyse the command. + if (regex_match(command, "^[ \t]*(quit|q|exit)[ \t;]*$", REG_EXTENDED | REG_ICASE)) { + taos_close(con); + write_history(); + return -1; + } + + if (regex_match(command, "^[\t ]*clear[ \t;]*$", REG_EXTENDED | REG_ICASE)) { + // If clear the screen. + system("clear"); + return 0; + } + + if (regex_match(command, "^[\t ]*set[ \t]+max_binary_display_width[ \t]+(default|[1-9][0-9]*)[ \t;]*$", REG_EXTENDED | REG_ICASE)) { + strtok(command, " \t"); + strtok(NULL, " \t"); + char* p = strtok(NULL, " \t"); + if (strcasecmp(p, "default") == 0) { + tsMaxBinaryDisplayWidth = DEFAULT_MAX_BINARY_DISPLAY_WIDTH; + } else { + tsMaxBinaryDisplayWidth = atoi(p); + } + return 0; + } + + if (regex_match(command, "^[ \t]*source[\t ]+[^ ]+[ \t;]*$", REG_EXTENDED | REG_ICASE)) { + /* If source file. */ + char *c_ptr = strtok(command, " ;"); + assert(c_ptr != NULL); + c_ptr = strtok(NULL, " ;"); + assert(c_ptr != NULL); + source_file(con, c_ptr); + return 0; + } + + shellRunCommandOnServer(con, command); + return 0; +} + + +int32_t shellRunCommand(TAOS* con, char* command) { + /* If command is empty just return */ + if (isEmptyCommand(command)) { return 0; } @@ -190,40 +184,63 @@ int32_t shellRunCommand(TAOS *con, char *command) { } } - shellReplaceCtrlChar(command); - - // Analyse the command. - if (regex_match(command, "^[ \t]*(quit|q|exit)[ \t;]*$", REG_EXTENDED | REG_ICASE)) { - taos_close(con); - write_history(); - return -1; - } else if (regex_match(command, "^[\t ]*clear[ \t;]*$", REG_EXTENDED | REG_ICASE)) { - // If clear the screen. - system("clear"); - } else if (regex_match(command, "^[\t ]*set[ \t]+max_binary_display_width[ \t]+(default|[1-9][0-9]*)[ \t;]*$", REG_EXTENDED | REG_ICASE)) { - strtok(command, " \t"); - strtok(NULL, " \t"); - char* p = strtok(NULL, " \t"); - if (strcasecmp(p, "default") == 0) { - tsMaxBinaryDisplayWidth = DEFAULT_MAX_BINARY_DISPLAY_WIDTH; - } else { - tsMaxBinaryDisplayWidth = atoi(p); + bool esc = false; + char quote = 0, *cmd = command, *p = command; + for (char c = *command++; c != 0; c = *command++) { + if (esc) { + switch (c) { + case 'n': + c = '\n'; + break; + case 'r': + c = '\r'; + break; + case 't': + c = '\t'; + break; + case 'G': + *p++ = '\\'; + break; + case '\'': + case '"': + if (quote) { + *p++ = '\\'; + } + break; + } + *p++ = c; + esc = false; + continue; + } + + if (c == '\\') { + esc = true; + continue; } - } else if (regex_match(command, "^[ \t]*source[\t ]+[^ ]+[ \t;]*$", REG_EXTENDED | REG_ICASE)) { - /* If source file. */ - char *c_ptr = strtok(command, " ;"); - assert(c_ptr != NULL); - c_ptr = strtok(NULL, " ;"); - assert(c_ptr != NULL); - source_file(con, c_ptr); - } else { - shellRunCommandOnServer(con, command); + if (quote == c) { + quote = 0; + } else if (c == '\'' || c == '"') { + quote = c; + } + + *p++ = c; + if (c == ';') { + c = *p; + *p = 0; + if (shellRunSingleCommand(con, cmd) < 0) { + return -1; + } + *p = c; + p = cmd; + } } - - return 0; + + *p = 0; + return shellRunSingleCommand(con, cmd); } + void shellRunCommandOnServer(TAOS *con, char command[]) { int64_t st, et; wordexp_t full_path; diff --git a/src/kit/shell/src/shellLinux.c b/src/kit/shell/src/shellLinux.c index 856e011a78..d8b3e9bb4d 100644 --- a/src/kit/shell/src/shellLinux.c +++ b/src/kit/shell/src/shellLinux.c @@ -307,19 +307,13 @@ void *shellLoopQuery(void *arg) { return NULL; } - while (1) { + do { // Read command from shell. - memset(command, 0, MAX_COMMAND_SIZE); set_terminal_mode(); shellReadCommand(con, command); reset_terminal_mode(); - - // Run the command - if (shellRunCommand(con, command) != 0) { - break; - } - } + } while (shellRunCommand(con, command) == 0); tfree(command); exitShell(); diff --git a/src/kit/shell/src/shellWindows.c b/src/kit/shell/src/shellWindows.c index c446677276..440aa508ab 100644 --- a/src/kit/shell/src/shellWindows.c +++ b/src/kit/shell/src/shellWindows.c @@ -203,16 +203,13 @@ void *shellLoopQuery(void *arg) { char *command = malloc(MAX_COMMAND_SIZE); if (command == NULL) return NULL; - while (1) { + do { memset(command, 0, MAX_COMMAND_SIZE); shellPrintPrompt(); // Read command from shell. shellReadCommand(con, command); - - // Run the command - shellRunCommand(con, command); - } + } while (shellRunCommand(con, command) == 0); return NULL; } From fbc50a3da38563a032abf3b9ffa83935c698c453 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Tue, 26 May 2020 11:02:05 +0000 Subject: [PATCH 06/16] [TD-90] tag schema develop --- src/common/inc/tdataformat.h | 17 ++-- src/common/src/tdataformat.c | 151 ++++++++++++++++++++++++++++------- src/tsdb/src/tsdbMeta.c | 28 ++++--- src/tsdb/src/tsdbRead.c | 16 ++-- src/vnode/src/vnodeWrite.c | 6 +- 5 files changed, 162 insertions(+), 56 deletions(-) diff --git a/src/common/inc/tdataformat.h b/src/common/inc/tdataformat.h index 0aec948015..b1dda88d50 100644 --- a/src/common/inc/tdataformat.h +++ b/src/common/inc/tdataformat.h @@ -226,13 +226,13 @@ pData typedef struct { int16_t colId; // column ID int16_t colType; - int16_t colLen; // if col type is binary/Nchar, this is the length of binary/Nchar - int16_t offset; //to store value for numeric col or offset for binary/Nchar + uint16_t offset; //to store value for numeric col or offset for binary/Nchar } STagCol; typedef struct { - int32_t len; + int32_t len; void * pData; // Space to store the tag value + uint16_t dataLen; int16_t ncols; // Total columns allocated STagCol tagCols[]; } STagRow; @@ -242,10 +242,13 @@ typedef struct { int tdInsertTagCol(SDataRow row, void *value, int16_t len, int8_t type, int16_t colId); //insert tag value and update all the information int tdDeleteTagCol(SDataRow row, int16_t colId); // delete tag value and update all the information -int tdQuerTagByID(SDataRow row, int16_t colId, void *value, int16_t *type, int16_t *len); //if find tag, 0, else return -1; -int tdAppendTagColVal(SDataRow row, void *value, int8_t type, int32_t bytes); - -SDataRow tdNewTagRowFromSchema(STSchema *pSchema); +void * tdQueryTagByID(SDataRow row, int16_t colId, int16_t *type); //if find tag, 0, else return -1; +int tdAppendTagColVal(SDataRow row, void *value, int8_t type, int32_t bytes, int16_t colId); +SDataRow tdTagRowDup(SDataRow row); +void tdFreeTagRow(SDataRow row); +SDataRow tdTagRowDecode(SDataRow row); +int tdTagRowCpy(SDataRow dst, SDataRow src); +void * tdNewTagRowFromSchema(STSchema *pSchema, int16_t numofTags); STSchema *tdGetSchemaFromData(SDataRow *row); #ifdef __cplusplus diff --git a/src/common/src/tdataformat.c b/src/common/src/tdataformat.c index 3df94452d8..822a92322a 100644 --- a/src/common/src/tdataformat.c +++ b/src/common/src/tdataformat.c @@ -14,6 +14,7 @@ */ #include "tdataformat.h" #include "wchar.h" +#include "talgo.h" /** * Create a SSchema object with nCols columns @@ -152,25 +153,136 @@ SDataRow tdNewDataRowFromSchema(STSchema *pSchema) { } int tdInsertTagCol(SDataRow row, void *value, int16_t len, int8_t type, int16_t colId){ //insert tag value and update all the information + //todo return 0; }; int tdDeleteTagCol(SDataRow row, int16_t colId){ // delete tag value and update all the information - return o; -}; - -int tdQuerTagByID(SDataRow row, int16_t colId, void *value, int16_t *type, int16_t *len){ //if find tag, 0, else return -1; - return 0; -}; - -int tdAppendTagColVal(SDataRow row, void *value, int8_t type, int32_t bytes){ + //todo return 0; }; -SDataRow tdNewTagRowFromSchema(STSchema *pSchema) { - //todo +static int compTagVal(const void *key1, const void *key2) { + if (*(int16_t *)key1 > *(int16_t *)key2) { + return 1; + } else if (*(int16_t *)key1 == *(int16_t *)key2) { + return 0; + } else { + return -1; + } } +void * tdQueryTagByID(SDataRow row, int16_t colId, int16_t *type) { //if find tag, 0, else return -1; + //todo + ASSERT(((STagRow *)row)->pData != NULL); + + STagCol *pBase = ((STagRow *)row)->tagCols; + int16_t nCols = ((STagRow *)row)->ncols; + + STagCol * stCol = taosbsearch(&colId, pBase, nCols, sizeof(STagCol), compTagVal, TD_EQ); + if (NULL == stCol) { + return NULL; + } + + void * pData = ((STagRow *)row)->pData; + *type = stCol->colType; + + return pData + stCol->offset; +}; + +int tdAppendTagColVal(SDataRow row, void *value, int8_t type, int32_t bytes, int16_t colId){ + ASSERT(value != NULL); + //ASSERT(bytes-2 == varDataTLen(value)); + ASSERT(row != NULL); + STagRow *pTagrow = row; + + pTagrow->tagCols[pTagrow->ncols].colId = colId; + pTagrow->tagCols[pTagrow->ncols].colType = type; + pTagrow->tagCols[pTagrow->ncols].offset = pTagrow->dataLen; + + switch (type) { + case TSDB_DATA_TYPE_BINARY: + case TSDB_DATA_TYPE_NCHAR: + memcpy((char *)pTagrow->pData + pTagrow->dataLen, value, varDataTLen(value)); + pTagrow->dataLen += varDataTLen(value); + break; + default: + memcpy((char *)pTagrow->pData + pTagrow->dataLen, value, TYPE_BYTES[type]); + pTagrow->dataLen += TYPE_BYTES[type]; + break; + } + + pTagrow->ncols++; + + return 0; +}; + +void * tdNewTagRowFromSchema(STSchema *pSchema, int16_t numofTags) { + int32_t size = sizeof(STagRow) + numofTags * sizeof(STagCol); + + STagRow *row = malloc(size); + if (row == NULL) return NULL; + + int32_t datasize = pSchema->tlen - pSchema->flen; + row->pData = malloc(datasize); + if (NULL == row->pData) { + free(row); + return NULL; + } + + row->len = size; + row->dataLen = 0; + row->ncols = 0; + return row; +} +/** + * free tag row + */ + +void tdFreeTagRow(SDataRow row) { + if (row) { + free(((STagRow *)row)->pData); + free(row); + } +} + +SDataRow tdTagRowDup(SDataRow row) { + STagRow *trow = malloc(dataRowLen(row)); + if (trow == NULL) return NULL; + + dataRowCpy(trow, row); + trow->pData = malloc(trow->dataLen); + if (NULL == trow->pData) { + free(trow); + return NULL; + } + memcpy(trow->pData, ((STagRow *)row)->pData, trow->dataLen); + return trow; +} + +SDataRow tdTagRowDecode(SDataRow row) { + STagRow *trow = malloc(dataRowLen(row)); + if (trow == NULL) return NULL; + + dataRowCpy(trow, row); + trow->pData = malloc(trow->dataLen); + if (NULL == trow->pData) { + free(trow); + return NULL; + } + char * pData = (char *)row + dataRowLen(row) + sizeof(int32_t); + memcpy(trow->pData, pData, trow->dataLen); + return trow; +} + +int tdTagRowCpy(SDataRow dst, SDataRow src) { + if (src == NULL) return -1; + + dataRowCpy(dst, src); + void * pData = dst + dataRowLen(src); + memcpy(pData, ((STagRow *)src)->pData, ((STagRow *)src)->dataLen); + return 0; +} /** * Free the SDataRow object */ @@ -203,25 +315,6 @@ int tdAppendColVal(SDataRow row, void *value, int8_t type, int32_t bytes, int32_ return 0; } -int tdAppendColVal(SDataRow row, void *value, int8_t type, int32_t bytes, int32_t offset) { - ASSERT(value != NULL); - int32_t toffset = offset + TD_DATA_ROW_HEAD_SIZE; - char * ptr = POINTER_SHIFT(row, dataRowLen(row)); - - switch (type) { - case TSDB_DATA_TYPE_BINARY: - case TSDB_DATA_TYPE_NCHAR: - *(VarDataOffsetT *)POINTER_SHIFT(row, toffset) = dataRowLen(row); - memcpy(ptr, value, varDataTLen(value)); - dataRowLen(row) += varDataTLen(value); - break; - default: - memcpy(POINTER_SHIFT(row, toffset), value, TYPE_BYTES[type]); - break; - } - - return 0; -} SDataRow tdDataRowDup(SDataRow row) { SDataRow trow = malloc(dataRowLen(row)); diff --git a/src/tsdb/src/tsdbMeta.c b/src/tsdb/src/tsdbMeta.c index 356e9c77f1..c16bb74df8 100644 --- a/src/tsdb/src/tsdbMeta.c +++ b/src/tsdb/src/tsdbMeta.c @@ -54,7 +54,7 @@ void *tsdbEncodeTable(STable *pTable, int *contLen) { ptr = tdEncodeSchema(ptr, pTable->schema); ptr = tdEncodeSchema(ptr, pTable->tagSchema); } else if (pTable->type == TSDB_CHILD_TABLE) { - dataRowCpy(ptr, pTable->tagVal); + tdTagRowCpy(ptr, pTable->tagVal); } else { ptr = tdEncodeSchema(ptr, pTable->schema); } @@ -96,7 +96,7 @@ STable *tsdbDecodeTable(void *cont, int contLen) { pTable->schema = tdDecodeSchema(&ptr); pTable->tagSchema = tdDecodeSchema(&ptr); } else if (pTable->type == TSDB_CHILD_TABLE) { - pTable->tagVal = tdDataRowDup(ptr); + pTable->tagVal = tdTagRowDecode(ptr); } else { pTable->schema = tdDecodeSchema(&ptr); } @@ -114,8 +114,10 @@ static char* getTagIndexKey(const void* pData) { SDataRow row = elem->pTable->tagVal; STSchema* pSchema = tsdbGetTableTagSchema(elem->pMeta, elem->pTable); STColumn* pCol = &pSchema->columns[DEFAULT_TAG_INDEX_COLUMN]; - - return tdGetRowDataOfCol(row, pCol->type, TD_DATA_ROW_HEAD_SIZE + pCol->offset); + int16_t type = 0; + void * res = tdQueryTagByID(row, pCol->colId,&type); + ASSERT(type == pCol->type); + return res; } int tsdbRestoreTable(void *pHandle, void *cont, int contLen) { @@ -255,8 +257,9 @@ int32_t tsdbGetTableTagVal(TsdbRepoT* repo, STableId* id, int32_t colId, int16_t } SDataRow row = (SDataRow)pTable->tagVal; - char* d = tdGetRowDataOfCol(row, pCol->type, TD_DATA_ROW_HEAD_SIZE + pCol->offset); - + int16_t tagtype = 0; + char* d = tdQueryTagByID(row, pCol->colId, &tagtype); + //ASSERT((int8_t)tagtype == pCol->type) *val = d; *type = pCol->type; *bytes = pCol->bytes; @@ -321,7 +324,7 @@ int tsdbCreateTable(TsdbRepoT *repo, STableCfg *pCfg) { if (super->pIndex == NULL) { tdFreeSchema(super->schema); tdFreeSchema(super->tagSchema); - tdFreeDataRow(super->tagVal); + tdFreeTagRow(super->tagVal); free(super); return -1; } @@ -346,7 +349,7 @@ int tsdbCreateTable(TsdbRepoT *repo, STableCfg *pCfg) { if (IS_CREATE_STABLE(pCfg)) { // TSDB_CHILD_TABLE table->type = TSDB_CHILD_TABLE; table->superUid = pCfg->superUid; - table->tagVal = tdDataRowDup(pCfg->tagValues); + table->tagVal = tdTagRowDup(pCfg->tagValues); } else { // TSDB_NORMAL_TABLE table->type = TSDB_NORMAL_TABLE; table->superUid = -1; @@ -433,7 +436,7 @@ static void tsdbFreeMemTable(SMemTable *pMemTable) { static int tsdbFreeTable(STable *pTable) { // TODO: finish this function if (pTable->type == TSDB_CHILD_TABLE) { - tdFreeDataRow(pTable->tagVal); + tdFreeTagRow(pTable->tagVal); } else { tdFreeSchema(pTable->schema); } @@ -571,7 +574,9 @@ static int tsdbRemoveTableFromIndex(STsdbMeta *pMeta, STable *pTable) { STSchema* pSchema = tsdbGetTableTagSchema(pMeta, pTable); STColumn* pCol = &pSchema->columns[DEFAULT_TAG_INDEX_COLUMN]; - char* key = tdGetRowDataOfCol(pTable->tagVal, pCol->type, TD_DATA_ROW_HEAD_SIZE + pCol->offset); + int16_t tagtype = 0; + char* key = tdQueryTagByID(pTable->tagVal, pCol->colId, &tagtype); + ASSERT(pCol->type == tagtype); SArray* res = tSkipListGet(pSTable->pIndex, key); size_t size = taosArrayGetSize(res); @@ -602,7 +607,8 @@ static int tsdbEstimateTableEncodeSize(STable *pTable) { size += tdGetSchemaEncodeSize(pTable->schema); size += tdGetSchemaEncodeSize(pTable->tagSchema); } else if (pTable->type == TSDB_CHILD_TABLE) { - size += dataRowLen(pTable->tagVal); + STagRow *pTagRow = (STagRow *)(pTable->tagVal); + size += dataRowLen(pTable->tagVal) + pTagRow->dataLen; } else { size += tdGetSchemaEncodeSize(pTable->schema); } diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index ad3da226f6..4912f6f2e8 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -1746,9 +1746,9 @@ int32_t tableGroupComparFn(const void *p1, const void *p2, const void *param) { STColumn* pCol = schemaColAt(pTableGroupSupp->pTagSchema, colIndex); bytes = pCol->bytes; type = pCol->type; - - f1 = tdGetRowDataOfCol(pTable1->tagVal, pCol->type, TD_DATA_ROW_HEAD_SIZE + pCol->offset); - f2 = tdGetRowDataOfCol(pTable2->tagVal, pCol->type, TD_DATA_ROW_HEAD_SIZE + pCol->offset); + int16_t tgtype1, tgtype2 = 0; + f1 = tdQueryTagByID(pTable1->tagVal, pCol->colId, &tgtype1); + f2 = tdQueryTagByID(pTable2->tagVal, pCol->colId, &tgtype2); } int32_t ret = doCompare(f1, f2, type, bytes); @@ -1836,10 +1836,12 @@ bool indexedNodeFilterFp(const void* pNode, void* param) { val = (char*) elem->pTable->name; type = TSDB_DATA_TYPE_BINARY; } else { - STSchema* pTSchema = (STSchema*) pInfo->param; // todo table schema is identical to stable schema?? - - int32_t offset = pTSchema->columns[pInfo->colIndex].offset; - val = tdGetRowDataOfCol(elem->pTable->tagVal, pInfo->sch.type, TD_DATA_ROW_HEAD_SIZE + offset); +// STSchema* pTSchema = (STSchema*) pInfo->param; // todo table schema is identical to stable schema?? + int16_t type; + // int32_t offset = pTSchema->columns[pInfo->colIndex].offset; + // val = tdGetRowDataOfCol(elem->pTable->tagVal, pInfo->sch.type, TD_DATA_ROW_HEAD_SIZE + offset); + val = tdQueryTagByID(elem->pTable->tagVal, pInfo->colIndex, &type); + // ASSERT(pInfo->sch.type == type); } int32_t ret = 0; diff --git a/src/vnode/src/vnodeWrite.c b/src/vnode/src/vnodeWrite.c index 9c415d6af7..96ca19e129 100644 --- a/src/vnode/src/vnodeWrite.c +++ b/src/vnode/src/vnodeWrite.c @@ -139,11 +139,13 @@ static int32_t vnodeProcessCreateTableMsg(SVnodeObj *pVnode, void *pCont, SRspRe char *pTagData = pTable->data + totalCols * sizeof(SSchema); int accumBytes = 0; - dataRow = tdNewDataRowFromSchema(pDestTagSchema); + //dataRow = tdNewDataRowFromSchema(pDestTagSchema); + dataRow = tdNewTagRowFromSchema(pDestTagSchema, numOfTags); for (int i = 0; i < numOfTags; i++) { STColumn *pTCol = schemaColAt(pDestTagSchema, i); - tdAppendColVal(dataRow, pTagData + accumBytes, pTCol->type, pTCol->bytes, pTCol->offset); +// tdAppendColVal(dataRow, pTagData + accumBytes, pTCol->type, pTCol->bytes, pTCol->offset); + tdAppendTagColVal(dataRow, pTagData + accumBytes, pTCol->type, pTCol->bytes, pTCol->colId); accumBytes += htons(pSchema[i + numOfColumns].bytes); } tsdbTableSetTagValue(&tCfg, dataRow, false); From da266b1c1b9f79ba439a53924e8a962ef911f087 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Tue, 26 May 2020 19:32:16 +0800 Subject: [PATCH 07/16] fix tests/test/c/importPerTabe.c typo [TD-429] --- tests/test/c/CMakeLists.txt | 4 ++-- tests/test/c/{importPerTabe.c => importPerTable.c} | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename tests/test/c/{importPerTabe.c => importPerTable.c} (100%) diff --git a/tests/test/c/CMakeLists.txt b/tests/test/c/CMakeLists.txt index 893abb8e82..d40db5ee40 100644 --- a/tests/test/c/CMakeLists.txt +++ b/tests/test/c/CMakeLists.txt @@ -16,6 +16,6 @@ IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM)) add_executable(importOneRow importOneRow.c) target_link_libraries(importOneRow taos_static pthread) - add_executable(importPerTabe importPerTabe.c) - target_link_libraries(importPerTabe taos_static pthread) + add_executable(importPerTable importPerTable.c) + target_link_libraries(importPerTable taos_static pthread) ENDIF() diff --git a/tests/test/c/importPerTabe.c b/tests/test/c/importPerTable.c similarity index 100% rename from tests/test/c/importPerTabe.c rename to tests/test/c/importPerTable.c From 3882d0fa2d4f455f08e9a2a37518234096ecb778 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Tue, 26 May 2020 13:46:50 +0000 Subject: [PATCH 08/16] [TD-90]tagschema develop --- src/common/src/tdataformat.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/common/src/tdataformat.c b/src/common/src/tdataformat.c index 38d82f628b..5359d98535 100644 --- a/src/common/src/tdataformat.c +++ b/src/common/src/tdataformat.c @@ -162,10 +162,10 @@ int tdDeleteTagCol(SDataRow row, int16_t colId){ // delete tag value and updat return 0; }; -static int compTagVal(const void *key1, const void *key2) { - if (*(int16_t *)key1 > *(int16_t *)key2) { +static int compTagId(const void *key1, const void *key2) { + if (((STagCol *)key1)->colId > ((STagCol *)key2)->colId) { return 1; - } else if (*(int16_t *)key1 == *(int16_t *)key2) { + } else if (((STagCol *)key1)->colId == ((STagCol *)key2)->colId) { return 0; } else { return -1; @@ -178,8 +178,9 @@ void * tdQueryTagByID(SDataRow row, int16_t colId, int16_t *type) { //if find t STagCol *pBase = ((STagRow *)row)->tagCols; int16_t nCols = ((STagRow *)row)->ncols; + STagCol key = {colId,0,0}; - STagCol * stCol = taosbsearch(&colId, pBase, nCols, sizeof(STagCol), compTagVal, TD_EQ); + STagCol * stCol = taosbsearch(&key, pBase, nCols, sizeof(STagCol), compTagId, TD_EQ); if (NULL == stCol) { return NULL; } @@ -270,7 +271,7 @@ SDataRow tdTagRowDecode(SDataRow row) { free(trow); return NULL; } - char * pData = (char *)row + dataRowLen(row) + sizeof(int32_t); + char * pData = (char *)row + dataRowLen(row); memcpy(trow->pData, pData, trow->dataLen); return trow; } From 1dc32106052ca9228895de39db9c1965accc7103 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 26 May 2020 15:14:50 +0000 Subject: [PATCH 09/16] TD-423 --- src/tsdb/src/tsdbMain.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/tsdb/src/tsdbMain.c b/src/tsdb/src/tsdbMain.c index 55342ffd38..27473e805c 100644 --- a/src/tsdb/src/tsdbMain.c +++ b/src/tsdb/src/tsdbMain.c @@ -936,7 +936,7 @@ static SSkipListIterator **tsdbCreateTableIters(STsdbMeta *pMeta, int maxTables) for (int tid = 1; tid < maxTables; tid++) { STable *pTable = pMeta->tables[tid]; - if (pTable == NULL || pTable->imem == NULL) continue; + if (pTable == NULL || pTable->imem == NULL || pTable->imem->numOfRows == 0) continue; iters[tid] = tSkipListCreateIter(pTable->imem->pData); if (iters[tid] == NULL) goto _err; @@ -968,12 +968,12 @@ static void *tsdbCommitData(void *arg) { SRWHelper whelper = {{0}}; if (pCache->imem == NULL) return NULL; - tsdbPrint("vgId: %d, starting to commit....", pRepo->config.tsdbId); + tsdbPrint("vgId:%d, starting to commit....", pRepo->config.tsdbId); // Create the iterator to read from cache SSkipListIterator **iters = tsdbCreateTableIters(pMeta, pCfg->maxTables); if (iters == NULL) { - // TODO: deal with the error + ASSERT(0); return NULL; } @@ -1015,6 +1015,7 @@ _exit: } } tsdbUnLockRepo(arg); + tsdbPrint("vgId:%d, commit over....", pRepo->config.tsdbId); return NULL; } From 36daff8edca00c168c7867d67dc271ee77fc05f2 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Wed, 27 May 2020 02:47:00 +0000 Subject: [PATCH 10/16] [TD-90] tagschema develop --- src/common/src/tdataformat.c | 4 ---- src/tsdb/src/tsdbRead.c | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/common/src/tdataformat.c b/src/common/src/tdataformat.c index 5359d98535..6a567c6e6c 100644 --- a/src/common/src/tdataformat.c +++ b/src/common/src/tdataformat.c @@ -173,13 +173,10 @@ static int compTagId(const void *key1, const void *key2) { } void * tdQueryTagByID(SDataRow row, int16_t colId, int16_t *type) { //if find tag, 0, else return -1; - //todo ASSERT(((STagRow *)row)->pData != NULL); - STagCol *pBase = ((STagRow *)row)->tagCols; int16_t nCols = ((STagRow *)row)->ncols; STagCol key = {colId,0,0}; - STagCol * stCol = taosbsearch(&key, pBase, nCols, sizeof(STagCol), compTagId, TD_EQ); if (NULL == stCol) { return NULL; @@ -196,7 +193,6 @@ int tdAppendTagColVal(SDataRow row, void *value, int8_t type, int32_t bytes, int //ASSERT(bytes-2 == varDataTLen(value)); ASSERT(row != NULL); STagRow *pTagrow = row; - pTagrow->tagCols[pTagrow->ncols].colId = colId; pTagrow->tagCols[pTagrow->ncols].colType = type; pTagrow->tagCols[pTagrow->ncols].offset = pTagrow->dataLen; diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index 720479130b..2220ebfd88 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -1847,10 +1847,10 @@ bool indexedNodeFilterFp(const void* pNode, void* param) { int16_t type; // int32_t offset = pTSchema->columns[pInfo->colIndex].offset; // val = tdGetRowDataOfCol(elem->pTable->tagVal, pInfo->sch.type, TD_DATA_ROW_HEAD_SIZE + offset); - val = tdQueryTagByID(elem->pTable->tagVal, pInfo->colIndex, &type); + val = tdQueryTagByID(elem->pTable->tagVal, pInfo->sch.colId, &type); // ASSERT(pInfo->sch.type == type); } - + //todo :the val is possible to be null, so check it out carefully int32_t ret = 0; if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) { if (pInfo->optr == TSDB_RELATION_IN) { From a46e41f0e51568931d42ab22d5e14caee2e56845 Mon Sep 17 00:00:00 2001 From: Jeff Tao Date: Wed, 27 May 2020 02:48:00 +0000 Subject: [PATCH 11/16] security flag shall be reset if a newlink from client --- src/rpc/src/rpcMain.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index a8bb2fd65b..297ff31ed9 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -594,7 +594,10 @@ static SRpcConn *rpcAllocateServerConn(SRpcInfo *pRpc, SRecvInfo *pRecv) { // check if it is already allocated SRpcConn **ppConn = (SRpcConn **)(taosHashGet(pRpc->hash, hashstr, size)); if (ppConn) pConn = *ppConn; - if (pConn) return pConn; + if (pConn) { + pConn->secured = 0; + return pConn; + } int sid = taosAllocateId(pRpc->idPool); if (sid <= 0) { From 5270b1e331ec924c9fa5548a898c8a85dae4a6d3 Mon Sep 17 00:00:00 2001 From: Bomin Zhang Date: Wed, 27 May 2020 10:51:46 +0800 Subject: [PATCH 12/16] define error in hex --- src/inc/taoserror.h | 223 ++++++++++++++++++++++---------------------- 1 file changed, 111 insertions(+), 112 deletions(-) diff --git a/src/inc/taoserror.h b/src/inc/taoserror.h index ae30efd93e..ca520ff803 100644 --- a/src/inc/taoserror.h +++ b/src/inc/taoserror.h @@ -46,145 +46,144 @@ static STaosError errors[] = { #endif // rpc -TAOS_DEFINE_ERROR(TSDB_CODE_ACTION_IN_PROGRESS, 0, 1, "action in progress") -TAOS_DEFINE_ERROR(TSDB_CODE_ACTION_NEED_REPROCESSED, 0, 3, "action need to be reprocessed") -TAOS_DEFINE_ERROR(TSDB_CODE_MSG_NOT_PROCESSED, 0, 4, "message not processed") -TAOS_DEFINE_ERROR(TSDB_CODE_ALREADY_PROCESSED, 0, 5, "message already processed") -TAOS_DEFINE_ERROR(TSDB_CODE_REDIRECT, 0, 6, "redirect") -TAOS_DEFINE_ERROR(TSDB_CODE_LAST_SESSION_NOT_FINISHED, 0, 7, "last session not finished") -TAOS_DEFINE_ERROR(TSDB_CODE_MAX_SESSIONS, 0, 8, "max sessions") // too many sessions -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_SESSION_ID, 0, 9, "invalid session id") -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_TRAN_ID, 0, 10, "invalid transaction id") -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_MSG_TYPE, 0, 11, "invalid message type") -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_MSG_LEN, 0, 12, "invalid message length") -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_MSG_CONTENT, 0, 13, "invalid message content") -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_MSG_VERSION, 0, 14, "invalid message version") -TAOS_DEFINE_ERROR(TSDB_CODE_UNEXPECTED_RESPONSE, 0, 15, "unexpected response") -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_RESPONSE_TYPE, 0, 16, "invalid response type") -TAOS_DEFINE_ERROR(TSDB_CODE_MISMATCHED_METER_ID, 0, 17, "mismatched meter id") -TAOS_DEFINE_ERROR(TSDB_CODE_DISCONNECTED, 0, 18, "disconnected") -TAOS_DEFINE_ERROR(TSDB_CODE_NOT_READY, 0, 19, "not ready") // peer is not ready to process data -TAOS_DEFINE_ERROR(TSDB_CODE_TOO_SLOW, 0, 20, "too slow") -TAOS_DEFINE_ERROR(TSDB_CODE_OTHERS, 0, 21, "others") -TAOS_DEFINE_ERROR(TSDB_CODE_APP_ERROR, 0, 22, "app error") -TAOS_DEFINE_ERROR(TSDB_CODE_ALREADY_THERE, 0, 23, "already there") -TAOS_DEFINE_ERROR(TSDB_CODE_NO_RESOURCE, 0, 14, "no resource") -TAOS_DEFINE_ERROR(TSDB_CODE_OPS_NOT_SUPPORT, 0, 25, "operations not support") -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_OPTION, 0, 26, "invalid option") -TAOS_DEFINE_ERROR(TSDB_CODE_NOT_CONFIGURED, 0, 27, "not configured") -TAOS_DEFINE_ERROR(TSDB_CODE_NODE_OFFLINE, 0, 28, "node offline") -TAOS_DEFINE_ERROR(TSDB_CODE_NETWORK_UNAVAIL, 0, 29, "network unavailable") -TAOS_DEFINE_ERROR(TSDB_CODE_AUTH_REQUIRED, 0, 30, "auth required") +TAOS_DEFINE_ERROR(TSDB_CODE_ACTION_IN_PROGRESS, 0, 0x0001, "action in progress") +TAOS_DEFINE_ERROR(TSDB_CODE_ACTION_NEED_REPROCESSED, 0, 0x0003, "action need to be reprocessed") +TAOS_DEFINE_ERROR(TSDB_CODE_MSG_NOT_PROCESSED, 0, 0x0004, "message not processed") +TAOS_DEFINE_ERROR(TSDB_CODE_ALREADY_PROCESSED, 0, 0x0005, "message already processed") +TAOS_DEFINE_ERROR(TSDB_CODE_REDIRECT, 0, 0x0006, "redirect") +TAOS_DEFINE_ERROR(TSDB_CODE_LAST_SESSION_NOT_FINISHED, 0, 0x0007, "last session not finished") +TAOS_DEFINE_ERROR(TSDB_CODE_MAX_SESSIONS, 0, 0x0008, "max sessions") // too many sessions +TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_SESSION_ID, 0, 0x0009, "invalid session id") +TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_TRAN_ID, 0, 0x000A, "invalid transaction id") +TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_MSG_TYPE, 0, 0x000B, "invalid message type") +TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_MSG_LEN, 0, 0x000C, "invalid message length") +TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_MSG_CONTENT, 0, 0x000D, "invalid message content") +TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_MSG_VERSION, 0, 0x000E, "invalid message version") +TAOS_DEFINE_ERROR(TSDB_CODE_UNEXPECTED_RESPONSE, 0, 0x000F, "unexpected response") +TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_RESPONSE_TYPE, 0, 0x0010, "invalid response type") +TAOS_DEFINE_ERROR(TSDB_CODE_MISMATCHED_METER_ID, 0, 0x0011, "mismatched meter id") +TAOS_DEFINE_ERROR(TSDB_CODE_DISCONNECTED, 0, 0x0012, "disconnected") +TAOS_DEFINE_ERROR(TSDB_CODE_NOT_READY, 0, 0x0013, "not ready") // peer is not ready to process data +TAOS_DEFINE_ERROR(TSDB_CODE_TOO_SLOW, 0, 0x0014, "too slow") +TAOS_DEFINE_ERROR(TSDB_CODE_OTHERS, 0, 0x0015, "others") +TAOS_DEFINE_ERROR(TSDB_CODE_APP_ERROR, 0, 0x0016, "app error") +TAOS_DEFINE_ERROR(TSDB_CODE_ALREADY_THERE, 0, 0x0017, "already there") +TAOS_DEFINE_ERROR(TSDB_CODE_NO_RESOURCE, 0, 0x0018, "no resource") +TAOS_DEFINE_ERROR(TSDB_CODE_OPS_NOT_SUPPORT, 0, 0x0019, "operations not support") +TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_OPTION, 0, 0x001A, "invalid option") +TAOS_DEFINE_ERROR(TSDB_CODE_NOT_CONFIGURED, 0, 0x001B, "not configured") +TAOS_DEFINE_ERROR(TSDB_CODE_NODE_OFFLINE, 0, 0x001C, "node offline") +TAOS_DEFINE_ERROR(TSDB_CODE_NETWORK_UNAVAIL, 0, 0x001D, "network unavailable") +TAOS_DEFINE_ERROR(TSDB_CODE_AUTH_REQUIRED, 0, 0x001E, "auth required") // db -TAOS_DEFINE_ERROR(TSDB_CODE_DB_NOT_SELECTED, 0, 100, "db not selected") -TAOS_DEFINE_ERROR(TSDB_CODE_DB_ALREADY_EXIST, 0, 101, "database aleady exist") -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_DB, 0, 102, "invalid database") -TAOS_DEFINE_ERROR(TSDB_CODE_MONITOR_DB_FORBIDDEN, 0, 103, "monitor db forbidden") +TAOS_DEFINE_ERROR(TSDB_CODE_DB_NOT_SELECTED, 0, 0x0100, "db not selected") +TAOS_DEFINE_ERROR(TSDB_CODE_DB_ALREADY_EXIST, 0, 0x0101, "database aleady exist") +TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_DB, 0, 0x0102, "invalid database") +TAOS_DEFINE_ERROR(TSDB_CODE_MONITOR_DB_FORBIDDEN, 0, 0x0103, "monitor db forbidden") // user -TAOS_DEFINE_ERROR(TSDB_CODE_USER_ALREADY_EXIST, 0, 150, "user already exist") -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_USER, 0, 151, "invalid user") -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_PASS, 0, 152, "invalid password") -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_USER_FORMAT, 0, 153, "invalid user format") -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_PASS_FORMAT, 0, 154, "invalid password format") -TAOS_DEFINE_ERROR(TSDB_CODE_NO_USER_FROM_CONN, 0, 155, "can not get user from conn") +TAOS_DEFINE_ERROR(TSDB_CODE_USER_ALREADY_EXIST, 0, 0x0180, "user already exist") +TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_USER, 0, 0x0181, "invalid user") +TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_PASS, 0, 0x0182, "invalid password") +TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_USER_FORMAT, 0, 0x0183, "invalid user format") +TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_PASS_FORMAT, 0, 0x0184, "invalid password format") +TAOS_DEFINE_ERROR(TSDB_CODE_NO_USER_FROM_CONN, 0, 0x0185, "can not get user from conn") // table -TAOS_DEFINE_ERROR(TSDB_CODE_TABLE_ALREADY_EXIST, 0, 200, "table already exist") -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_TABLE_ID, 0, 201, "invalid table id") -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_TABLE_TYPE, 0, 202, "invalid table typee") -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_TABLE, 0, 203, "invalid table name") -TAOS_DEFINE_ERROR(TSDB_CODE_NOT_SUPER_TABLE, 0, 204, "no super table") // operation only available for super table -TAOS_DEFINE_ERROR(TSDB_CODE_NOT_ACTIVE_TABLE, 0, 205, "not active table") -TAOS_DEFINE_ERROR(TSDB_CODE_TABLE_ID_MISMATCH, 0, 206, "table id mismatch") -TAOS_DEFINE_ERROR(TSDB_CODE_TAG_ALREAY_EXIST, 0, 207, "tag already exist") -TAOS_DEFINE_ERROR(TSDB_CODE_TAG_NOT_EXIST, 0, 208, "tag not exist") -TAOS_DEFINE_ERROR(TSDB_CODE_FIELD_ALREAY_EXIST, 0, 209, "field already exist") -TAOS_DEFINE_ERROR(TSDB_CODE_FIELD_NOT_EXIST, 0, 210, "field not exist") -TAOS_DEFINE_ERROR(TSDB_CODE_COL_NAME_TOO_LONG, 0, 211, "column name too long") -TAOS_DEFINE_ERROR(TSDB_CODE_TOO_MANY_TAGS, 0, 211, "too many tags") +TAOS_DEFINE_ERROR(TSDB_CODE_TABLE_ALREADY_EXIST, 0, 0x0200, "table already exist") +TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_TABLE_ID, 0, 0x0201, "invalid table id") +TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_TABLE_TYPE, 0, 0x0202, "invalid table typee") +TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_TABLE, 0, 0x0203, "invalid table name") +TAOS_DEFINE_ERROR(TSDB_CODE_NOT_SUPER_TABLE, 0, 0x0204, "no super table") // operation only available for super table +TAOS_DEFINE_ERROR(TSDB_CODE_NOT_ACTIVE_TABLE, 0, 0x0205, "not active table") +TAOS_DEFINE_ERROR(TSDB_CODE_TABLE_ID_MISMATCH, 0, 0x0206, "table id mismatch") +TAOS_DEFINE_ERROR(TSDB_CODE_TAG_ALREAY_EXIST, 0, 0x0207, "tag already exist") +TAOS_DEFINE_ERROR(TSDB_CODE_TAG_NOT_EXIST, 0, 0x0208, "tag not exist") +TAOS_DEFINE_ERROR(TSDB_CODE_FIELD_ALREAY_EXIST, 0, 0x0209, "field already exist") +TAOS_DEFINE_ERROR(TSDB_CODE_FIELD_NOT_EXIST, 0, 0x020A, "field not exist") +TAOS_DEFINE_ERROR(TSDB_CODE_COL_NAME_TOO_LONG, 0, 0x020B, "column name too long") +TAOS_DEFINE_ERROR(TSDB_CODE_TOO_MANY_TAGS, 0, 0x020C, "too many tags") // dnode & mnode -TAOS_DEFINE_ERROR(TSDB_CODE_NO_ENOUGH_DNODES, 0, 250, "no enough dnodes") -TAOS_DEFINE_ERROR(TSDB_CODE_DNODE_ALREADY_EXIST, 0, 251, "dnode already exist") -TAOS_DEFINE_ERROR(TSDB_CODE_DNODE_NOT_EXIST, 0, 252, "dnode not exist") -TAOS_DEFINE_ERROR(TSDB_CODE_NO_MASTER, 0, 253, "no master") -TAOS_DEFINE_ERROR(TSDB_CODE_NO_REMOVE_MASTER, 0, 254, "no remove master") -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_QUERY_ID, 0, 255, "invalid query id") -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_STREAM_ID, 0, 256, "invalid stream id") -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_CONNECTION, 0, 257, "invalid connection") -TAOS_DEFINE_ERROR(TSDB_CODE_SDB_ERROR, 0, 258, "sdb error") -TAOS_DEFINE_ERROR(TSDB_CODE_TIMESTAMP_OUT_OF_RANGE, 0, 259, "timestamp is out of range") +TAOS_DEFINE_ERROR(TSDB_CODE_NO_ENOUGH_DNODES, 0, 0x0280, "no enough dnodes") +TAOS_DEFINE_ERROR(TSDB_CODE_DNODE_ALREADY_EXIST, 0, 0x0281, "dnode already exist") +TAOS_DEFINE_ERROR(TSDB_CODE_DNODE_NOT_EXIST, 0, 0x0282, "dnode not exist") +TAOS_DEFINE_ERROR(TSDB_CODE_NO_MASTER, 0, 0x0283, "no master") +TAOS_DEFINE_ERROR(TSDB_CODE_NO_REMOVE_MASTER, 0, 0x0284, "no remove master") +TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_QUERY_ID, 0, 0x0285, "invalid query id") +TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_STREAM_ID, 0, 0x0286, "invalid stream id") +TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_CONNECTION, 0, 0x0287, "invalid connection") +TAOS_DEFINE_ERROR(TSDB_CODE_SDB_ERROR, 0, 0x0288, "sdb error") +TAOS_DEFINE_ERROR(TSDB_CODE_TIMESTAMP_OUT_OF_RANGE, 0, 0x0289, "timestamp is out of range") // acct -TAOS_DEFINE_ERROR(TSDB_CODE_ACCT_ALREADY_EXIST, 0, 300, "accounts already exist") -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_ACCT, 0, 301, "invalid account") -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_ACCT_PARAMETER, 0, 302, "invalid account parameter") -TAOS_DEFINE_ERROR(TSDB_CODE_TOO_MANY_ACCTS, 0, 303, "too many accounts") -TAOS_DEFINE_ERROR(TSDB_CODE_TOO_MANY_USERS, 0, 304, "too many users") -TAOS_DEFINE_ERROR(TSDB_CODE_TOO_MANY_TABLES, 0, 305, "too many tables") -TAOS_DEFINE_ERROR(TSDB_CODE_TOO_MANY_DATABASES, 0, 306, "too many databases") -TAOS_DEFINE_ERROR(TSDB_CODE_TOO_MANY_TIME_SERIES, 0, 307, "not enough time series") +TAOS_DEFINE_ERROR(TSDB_CODE_ACCT_ALREADY_EXIST, 0, 0x0300, "accounts already exist") +TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_ACCT, 0, 0x0301, "invalid account") +TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_ACCT_PARAMETER, 0, 0x0302, "invalid account parameter") +TAOS_DEFINE_ERROR(TSDB_CODE_TOO_MANY_ACCTS, 0, 0x0303, "too many accounts") +TAOS_DEFINE_ERROR(TSDB_CODE_TOO_MANY_USERS, 0, 0x0304, "too many users") +TAOS_DEFINE_ERROR(TSDB_CODE_TOO_MANY_TABLES, 0, 0x0305, "too many tables") +TAOS_DEFINE_ERROR(TSDB_CODE_TOO_MANY_DATABASES, 0, 0x0306, "too many databases") +TAOS_DEFINE_ERROR(TSDB_CODE_TOO_MANY_TIME_SERIES, 0, 0x0307, "not enough time series") // grant -TAOS_DEFINE_ERROR(TSDB_CODE_AUTH_FAILURE, 0, 350, "auth failure") -TAOS_DEFINE_ERROR(TSDB_CODE_NO_RIGHTS, 0, 351, "no rights") -TAOS_DEFINE_ERROR(TSDB_CODE_NO_WRITE_ACCESS, 0, 352, "no write access") -TAOS_DEFINE_ERROR(TSDB_CODE_NO_READ_ACCESS, 0, 353, "no read access") -TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_EXPIRED, 0, 354, "grant expired") -TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_DNODE_LIMITED, 0, 355, "grant dnode limited") -TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_ACCT_LIMITED, 0, 356, "grant account limited") -TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_TIMESERIES_LIMITED, 0, 357, "grant timeseries limited") -TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_DB_LIMITED, 0, 358, "grant db limited") -TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_USER_LIMITED, 0, 359, "grant user limited") -TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_CONN_LIMITED, 0, 360, "grant conn limited") -TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_STREAM_LIMITED, 0, 361, "grant stream limited") -TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_SPEED_LIMITED, 0, 362, "grant speed limited") -TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_STORAGE_LIMITED, 0, 363, "grant storage limited") -TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_QUERYTIME_LIMITED, 0, 364, "grant query time limited") -TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_CPU_LIMITED, 0, 365, "grant cpu limited") +TAOS_DEFINE_ERROR(TSDB_CODE_AUTH_FAILURE, 0, 0x0380, "auth failure") +TAOS_DEFINE_ERROR(TSDB_CODE_NO_RIGHTS, 0, 0x0381, "no rights") +TAOS_DEFINE_ERROR(TSDB_CODE_NO_WRITE_ACCESS, 0, 0x0382, "no write access") +TAOS_DEFINE_ERROR(TSDB_CODE_NO_READ_ACCESS, 0, 0x0383, "no read access") +TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_EXPIRED, 0, 0x0384, "grant expired") +TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_DNODE_LIMITED, 0, 0x0385, "grant dnode limited") +TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_ACCT_LIMITED, 0, 0x0386, "grant account limited") +TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_TIMESERIES_LIMITED, 0, 0x0387, "grant timeseries limited") +TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_DB_LIMITED, 0, 0x0388, "grant db limited") +TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_USER_LIMITED, 0, 0x0389, "grant user limited") +TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_CONN_LIMITED, 0, 0x038A, "grant conn limited") +TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_STREAM_LIMITED, 0, 0x038B, "grant stream limited") +TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_SPEED_LIMITED, 0, 0x038C, "grant speed limited") +TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_STORAGE_LIMITED, 0, 0x038D, "grant storage limited") +TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_QUERYTIME_LIMITED, 0, 0x038E, "grant query time limited") +TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_CPU_LIMITED, 0, 0x038F, "grant cpu limited") // server -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_VGROUP_ID, 0, 400, "invalid vgroup id") -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_VNODE_ID, 0, 401, "invalid vnode id") -TAOS_DEFINE_ERROR(TSDB_CODE_NOT_ACTIVE_VNODE, 0, 402, "not active vnode") -TAOS_DEFINE_ERROR(TSDB_CODE_VG_INIT_FAILED, 0, 403, "vg init failed") -TAOS_DEFINE_ERROR(TSDB_CODE_SERV_NO_DISKSPACE, 0, 404, "server no diskspace") -TAOS_DEFINE_ERROR(TSDB_CODE_SERV_OUT_OF_MEMORY, 0, 405, "server out of memory") -TAOS_DEFINE_ERROR(TSDB_CODE_NO_DISK_PERMISSIONS, 0, 406, "no disk permissions") -TAOS_DEFINE_ERROR(TSDB_CODE_FILE_CORRUPTED, 0, 407, "file corrupted") -TAOS_DEFINE_ERROR(TSDB_CODE_MEMORY_CORRUPTED, 0, 408, "memory corrupted") -TAOS_DEFINE_ERROR(TSDB_CODE_NOT_SUCH_FILE_OR_DIR, 0, 409, "no such file or directory") +TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_VGROUP_ID, 0, 0x0400, "invalid vgroup id") +TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_VNODE_ID, 0, 0x0401, "invalid vnode id") +TAOS_DEFINE_ERROR(TSDB_CODE_NOT_ACTIVE_VNODE, 0, 0x0402, "not active vnode") +TAOS_DEFINE_ERROR(TSDB_CODE_VG_INIT_FAILED, 0, 0x0403, "vg init failed") +TAOS_DEFINE_ERROR(TSDB_CODE_SERV_NO_DISKSPACE, 0, 0x0404, "server no diskspace") +TAOS_DEFINE_ERROR(TSDB_CODE_SERV_OUT_OF_MEMORY, 0, 0x0405, "server out of memory") +TAOS_DEFINE_ERROR(TSDB_CODE_NO_DISK_PERMISSIONS, 0, 0x0406, "no disk permissions") +TAOS_DEFINE_ERROR(TSDB_CODE_FILE_CORRUPTED, 0, 0x0407, "file corrupted") +TAOS_DEFINE_ERROR(TSDB_CODE_MEMORY_CORRUPTED, 0, 0x0408, "memory corrupted") +TAOS_DEFINE_ERROR(TSDB_CODE_NOT_SUCH_FILE_OR_DIR, 0, 0x0409, "no such file or directory") // client -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_CLIENT_VERSION, 0, 451, "invalid client version") -TAOS_DEFINE_ERROR(TSDB_CODE_CLI_OUT_OF_MEMORY, 0, 452, "client out of memory") -TAOS_DEFINE_ERROR(TSDB_CODE_CLI_NO_DISKSPACE, 0, 453, "client no disk space") -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_TIME_STAMP, 0, 454, "invalid timestamp") -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_SQL, 0, 455, "invalid sql") -TAOS_DEFINE_ERROR(TSDB_CODE_QUERY_CACHE_ERASED, 0, 456, "query cache erased") -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_QUERY_MSG, 0, 457, "invalid query message") // failed to validate the sql expression msg by vnode -TAOS_DEFINE_ERROR(TSDB_CODE_SORTED_RES_TOO_MANY, 0, 458, "sorted res too many") // too many result for ordered super table projection query -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_QHANDLE, 0, 459, "invalid handle") -TAOS_DEFINE_ERROR(TSDB_CODE_QUERY_CANCELLED, 0, 460, "query cancelled") -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_IE, 0, 461, "invalid ie") -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_VALUE, 0, 462, "invalid value") -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_FQDN, 0, 463, "invalid FQDN") +TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_CLIENT_VERSION, 0, 0x0481, "invalid client version") +TAOS_DEFINE_ERROR(TSDB_CODE_CLI_OUT_OF_MEMORY, 0, 0x0482, "client out of memory") +TAOS_DEFINE_ERROR(TSDB_CODE_CLI_NO_DISKSPACE, 0, 0x0483, "client no disk space") +TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_TIME_STAMP, 0, 0x0484, "invalid timestamp") +TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_SQL, 0, 0x0485, "invalid sql") +TAOS_DEFINE_ERROR(TSDB_CODE_QUERY_CACHE_ERASED, 0, 0x0486, "query cache erased") +TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_QUERY_MSG, 0, 0x0487, "invalid query message") // failed to validate the sql expression msg by vnode +TAOS_DEFINE_ERROR(TSDB_CODE_SORTED_RES_TOO_MANY, 0, 0x0488, "sorted res too many") // too many result for ordered super table projection query +TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_QHANDLE, 0, 0x0489, "invalid handle") +TAOS_DEFINE_ERROR(TSDB_CODE_QUERY_CANCELLED, 0, 0x048A, "query cancelled") +TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_IE, 0, 0x048B, "invalid ie") +TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_VALUE, 0, 0x048C, "invalid value") +TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_FQDN, 0, 0x048D, "invalid FQDN") // others -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_FILE_FORMAT, 0, 500, "invalid file format") +TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_FILE_FORMAT, 0, 0x0500, "invalid file format") // TSDB -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_CONFIG, 0, 550, "invalid TSDB configuration") +TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_CONFIG, 0, 0x0580, "invalid TSDB configuration") #ifdef TAOS_ERROR_C }; #endif -#define TSDB_CODE_MAX_ERROR_CODE 120 #ifdef __cplusplus } From c27edd47b7f9aad15c4224d40c1005b8779b583e Mon Sep 17 00:00:00 2001 From: Bomin Zhang Date: Wed, 27 May 2020 10:22:32 +0800 Subject: [PATCH 13/16] update connector document --- documentation/webdocs/markdowndocs/Connector.md | 2 ++ documentation/webdocs/markdowndocs/connector-ch.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/documentation/webdocs/markdowndocs/Connector.md b/documentation/webdocs/markdowndocs/Connector.md index a0433d1f09..563d306128 100644 --- a/documentation/webdocs/markdowndocs/Connector.md +++ b/documentation/webdocs/markdowndocs/Connector.md @@ -2,6 +2,8 @@ TDengine provides many connectors for development, including C/C++, JAVA, Python, RESTful, Go, Node.JS, etc. +NOTE: All APIs which require a SQL string as parameter, including but not limit to `taos_query`, `taos_query_a`, `taos_subscribe` in the C/C++ Connector and their counterparts in other connectors, can ONLY process one SQL statement at a time. If more than one SQL statements are provided, their behaviors are undefined. + ## C/C++ API C/C++ APIs are similar to the MySQL APIs. Applications should include TDengine head file _taos.h_ to use C/C++ APIs by adding the following line in code: diff --git a/documentation/webdocs/markdowndocs/connector-ch.md b/documentation/webdocs/markdowndocs/connector-ch.md index b5d8fb5afb..47c8381f69 100644 --- a/documentation/webdocs/markdowndocs/connector-ch.md +++ b/documentation/webdocs/markdowndocs/connector-ch.md @@ -2,6 +2,8 @@ TDengine提供了丰富的应用程序开发接口,其中包括C/C++、JAVA、Python、RESTful、Go等,便于用户快速开发应用。 +注意:所以执行 SQL 语句的 API,例如 C/C++ Connector 中的 `tao_query`、`taos_query_a`、`taos_subscribe` 等,以及其它语言中与它们对应的API,每次都只能执行一条 SQL 语句,如果实际参数中包含了多条语句,它们的行为是未定义的。 + ## C/C++ Connector C/C++的API类似于MySQL的C API。应用程序使用时,需要包含TDengine头文件 _taos.h_(安装后,位于 _/usr/local/taos/include_): From 89da3e1479974f3fc72f0d586c2e8db2adf26e49 Mon Sep 17 00:00:00 2001 From: freemine Date: Wed, 27 May 2020 11:53:57 +0800 Subject: [PATCH 14/16] bugfix: alloc space for holding null-terminator --- src/query/src/qExecutor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 47ad633e34..72d018d315 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -5298,7 +5298,7 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList, if (pColFilter->filterstr) { pColFilter->len = htobe64(pFilterMsg->len); - pColFilter->pz = (int64_t) calloc(1, pColFilter->len); + pColFilter->pz = (int64_t) calloc(1, pColFilter->len + 1 * TSDB_NCHAR_SIZE); // note: null-terminator memcpy((void *)pColFilter->pz, pMsg, pColFilter->len); pMsg += (pColFilter->len + 1); } else { From 6390536449ff7d3a42ae5e48a98150a5c19c0693 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Wed, 27 May 2020 04:01:34 +0000 Subject: [PATCH 15/16] [TD-90] add insert and modify tag schema --- src/common/inc/tdataformat.h | 2 +- src/common/src/tdataformat.c | 23 ++++++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/common/inc/tdataformat.h b/src/common/inc/tdataformat.h index 497279fb27..528e9b2825 100644 --- a/src/common/inc/tdataformat.h +++ b/src/common/inc/tdataformat.h @@ -259,7 +259,7 @@ typedef struct { #define tagColSize(r) (sizeof(STagCol) + r.colLen) -int tdInsertTagCol(SDataRow row, void *value, int16_t len, int8_t type, int16_t colId); //insert tag value and update all the information +int tdSetTagCol(SDataRow row, void *value, int16_t len, int8_t type, int16_t colId); //insert tag value and update all the information int tdDeleteTagCol(SDataRow row, int16_t colId); // delete tag value and update all the information void * tdQueryTagByID(SDataRow row, int16_t colId, int16_t *type); //if find tag, 0, else return -1; int tdAppendTagColVal(SDataRow row, void *value, int8_t type, int32_t bytes, int16_t colId); diff --git a/src/common/src/tdataformat.c b/src/common/src/tdataformat.c index 6a567c6e6c..8c6e26d5e1 100644 --- a/src/common/src/tdataformat.c +++ b/src/common/src/tdataformat.c @@ -152,8 +152,10 @@ SDataRow tdNewDataRowFromSchema(STSchema *pSchema) { return row; } -int tdInsertTagCol(SDataRow row, void *value, int16_t len, int8_t type, int16_t colId){ //insert tag value and update all the information - //todo +int tdSetTagCol(SDataRow row, void *value, int16_t len, int8_t type, int16_t colId){ //insert/update tag value and update all the information + ASSERT(((STagRow *)row)->pData != NULL); + //STagCol * stCol = tdQueryTagColByID() + return 0; }; @@ -172,7 +174,22 @@ static int compTagId(const void *key1, const void *key2) { } } -void * tdQueryTagByID(SDataRow row, int16_t colId, int16_t *type) { //if find tag, 0, else return -1; +/** + * Find tag structure by colId, if find, return tag structure, else return NULL; + */ +STagCol * tdQueryTagColByID(SDataRow row, int16_t colId, int flags) { //if find tag, 0, else return -1; + ASSERT(((STagRow *)row)->pData != NULL); + STagCol *pBase = ((STagRow *)row)->tagCols; + int16_t nCols = ((STagRow *)row)->ncols; + STagCol key = {colId,0,0}; + STagCol * stCol = taosbsearch(&key, pBase, nCols, sizeof(STagCol), compTagId, flags); + return stCol; +}; + +/** +* Find tag value by colId, if find, return tag value, else return NULL; +*/ +void * tdQueryTagByID(SDataRow row, int16_t colId, int16_t *type) { ASSERT(((STagRow *)row)->pData != NULL); STagCol *pBase = ((STagRow *)row)->tagCols; int16_t nCols = ((STagRow *)row)->ncols; From 056b24c724690bd4b1a50bf8aaf83aa108f98d65 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Wed, 27 May 2020 09:06:13 +0000 Subject: [PATCH 16/16] [TD-90] fix invalid read --- src/common/src/tdataformat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/src/tdataformat.c b/src/common/src/tdataformat.c index 8c6e26d5e1..922c8bdea0 100644 --- a/src/common/src/tdataformat.c +++ b/src/common/src/tdataformat.c @@ -237,7 +237,7 @@ void * tdNewTagRowFromSchema(STSchema *pSchema, int16_t numofTags) { STagRow *row = malloc(size); if (row == NULL) return NULL; - int32_t datasize = pSchema->tlen - pSchema->flen; + int32_t datasize = pSchema->tlen; row->pData = malloc(datasize); if (NULL == row->pData) { free(row);