提交 da48c584 编写于 作者: wmmhello's avatar wmmhello

TD-6129<feature> add json tag support

上级 1a1f8ee5
......@@ -389,7 +389,16 @@ int32_t tsParseOneColumn(SSchema *pSchema, SStrToken *pToken, char *payload, cha
break;
case TSDB_DATA_TYPE_JSON:
*((int8_t *)payload) = -1;
if (pToken->n > TSDB_MAX_TAGS_LEN) {
return tscInvalidOperationMsg(msg, "json tag length too long");
}
if (pToken->type == TK_NULL) {
*(int8_t *)payload = TSDB_DATA_TINYINT_NULL;
} else if (pToken->type != TK_STRING){
tscInvalidOperationMsg(msg, "invalid json data", pToken->z);
} else{
*((int8_t *)payload) = TSDB_DATA_BINARY_PLACEHOLDER;
}
break;
case TSDB_DATA_TYPE_TIMESTAMP: {
......@@ -1097,7 +1106,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
}
char tagVal[TSDB_MAX_TAGS_LEN];
int32_t output = 0;
if (!taosMbsToUcs4(item->string, strlen(item->string), varDataVal(tagVal), pSchema->bytes - VARSTR_HEADER_SIZE, &output)) {
if (!taosMbsToUcs4(item->string, strlen(item->string), varDataVal(tagVal), TSDB_MAX_TAGS_LEN - VARSTR_HEADER_SIZE, &output)) {
tscError("json string error:%s|%s", strerror(errno), item->string);
tdDestroyKVRowBuilder(&kvRowBuilder);
tscDestroyBoundColumnInfo(&spd);
......@@ -1109,7 +1118,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
if(item->type == cJSON_String){
output = 0;
if (!taosMbsToUcs4(item->valuestring, strlen(item->valuestring), varDataVal(tagVal), pSchema->bytes - VARSTR_HEADER_SIZE, &output)) {
if (!taosMbsToUcs4(item->valuestring, strlen(item->valuestring), varDataVal(tagVal), TSDB_MAX_TAGS_LEN - VARSTR_HEADER_SIZE, &output)) {
tscError("json string error:%s|%s", strerror(errno), item->string);
tdDestroyKVRowBuilder(&kvRowBuilder);
tscDestroyBoundColumnInfo(&spd);
......@@ -1117,7 +1126,6 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
}
varDataSetLen(tagVal, output);
tdAddColToKVRow(&kvRowBuilder, jsonIndex++, TSDB_DATA_TYPE_NCHAR, tagVal);
}else if(item->type == cJSON_Number){
*((double *)tagVal) = item->valuedouble;
......@@ -1671,7 +1679,7 @@ int tsParseSql(SSqlObj *pSql, bool initial) {
} else {
SSqlInfo sqlInfo = qSqlParse(pSql->sqlstr);
ret = tscValidateSqlInfo(pSql, &sqlInfo);
if (ret == TSDB_CODE_TSC_INVALID_OPERATION && pSql->parseRetry < 1 && sqlInfo.type == TSDB_SQL_SELECT) {
if (ret == TSDB_CODE_TSC_INVALID_OPERATION && pSql1>parseRetry < 1 && sqlInfo.type == TSDB_SQL_SELECT) {
tscDebug("0x%"PRIx64 " parse query sql statement failed, code:%s, clear meta cache and retry ", pSql->self, tstrerror(ret));
tscResetSqlCmd(pCmd, true, pSql->self);
......
......@@ -1485,27 +1485,31 @@ static bool validataTagJson(char *json){
return false;
}
bool returnVal = true;
int size = cJSON_GetArraySize(root);
if(!cJSON_IsObject(root) || size == 0)
if(!cJSON_IsObject(root) || size == 0){
tscError("json error invalide value");
}
for(int i = 0; i < size; i++) {
cJSON* item = cJSON_GetArrayItem(root, i);
if (!item) {
item->string,
tscError("json inner error:%d", i);
returnVal = false;
goto end;
}
if(item->type != cJSON_String && item->type != cJSON_Number){
tscError("json value unsupport:%d", item->type);
returnVal = false;
goto end;
}
}
end:
cJSON_Delete(root);
return returnVal;
}
if (numOfTags == 1) {
TAOS_FIELD* p = taosArrayGet(pTagsList, 0);
if (p->type == TSDB_DATA_TYPE_JSON && validataTagJson(p->)) {
invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg5);
return false;
}
}
static bool validateTagParams(SArray* pTagsList, SArray* pFieldList, SSqlCmd* pCmd) {
assert(pTagsList != NULL);
......@@ -1527,7 +1531,7 @@ static bool validateTagParams(SArray* pTagsList, SArray* pFieldList, SSqlCmd* pC
for (int32_t i = 0; i < numOfTags; ++i) {
TAOS_FIELD* p = taosArrayGet(pTagsList, i);
if (!isValidDataType(p->type)) {
if (!isValidDataType(p->type) && p->type != TSDB_DATA_TYPE_JSON) {
invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg5);
return false;
}
......@@ -1579,6 +1583,8 @@ static bool validateTagParams(SArray* pTagsList, SArray* pFieldList, SSqlCmd* pC
invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3);
return false;
}
if (p->type == TSDB_DATA_TYPE_JSON && validataTagJson
}
return true;
......@@ -7734,6 +7740,8 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
const char* msg3 = "tag value too long";
const char* msg4 = "illegal value or data overflow";
const char* msg5 = "tags number not matched";
const char* msg6 = "tags json invalidate";
const char* msg7 = "serizelize json error";
SSqlCmd* pCmd = &pSql->cmd;
......@@ -7837,6 +7845,11 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
} else if (pItem->pVar.nType == TSDB_DATA_TYPE_TIMESTAMP) {
pItem->pVar.i64 = convertTimePrecision(pItem->pVar.i64, TSDB_TIME_PRECISION_NANO, tinfo.precision);
}
} else if (pSchema->type == TSDB_DATA_TYPE_JSON) {
if (pItem->pVar.nLen > TSDB_MAX_TAGS_LEN) {
tdDestroyKVRowBuilder(&kvRowBuilder);
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3);
}
}
ret = tVariantDump(&(pItem->pVar), tagVal, pSchema->type, true);
......@@ -7892,9 +7905,13 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
} else if (pItem->pVar.nType == TSDB_DATA_TYPE_TIMESTAMP) {
pItem->pVar.i64 = convertTimePrecision(pItem->pVar.i64, TSDB_TIME_PRECISION_NANO, tinfo.precision);
}
} else if (pSchema->type == TSDB_DATA_TYPE_JSON) {
if (pItem->pVar.nLen > TSDB_MAX_TAGS_LEN) {
tdDestroyKVRowBuilder(&kvRowBuilder);
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3);
}
}
ret = tVariantDump(&(pItem->pVar), tagVal, pSchema->type, true);
// check again after the convert since it may be converted from binary to nchar.
......@@ -7915,6 +7932,66 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
}
}
// encode json tag string
if(schemaSize == 1 && pTagSchema[0].type == TSDB_DATA_TYPE_JSON){
if (valSize != schemaSize) {
tdDestroyKVRowBuilder(&kvRowBuilder);
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg5);
}
tVariantListItem* pItem = taosArrayGet(pValList, 0);
cJSON *root = cJSON_Parse(pItem->pVar.pz);
if (root == NULL){
tscError("json parse error");
tdDestroyKVRowBuilder(&kvRowBuilder);
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg6);
}
int size = cJSON_GetArraySize(root);
if(!cJSON_IsObject(root) || size == 0){
tscError("json error invalide value");
tdDestroyKVRowBuilder(&kvRowBuilder);
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg6);
}
int jsonIndex = 0;
for(int i = 0; i < size; i++) {
cJSON* item = cJSON_GetArrayItem(root, i);
if (!item) {
tscError("json inner error:%d", i);
continue;
}
char tagVal[TSDB_MAX_TAGS_LEN];
int32_t output = 0;
if (!taosMbsToUcs4(item->string, strlen(item->string), varDataVal(tagVal), TSDB_MAX_TAGS_LEN - VARSTR_HEADER_SIZE, &output)) {
tscError("json string error:%s|%s", strerror(errno), item->string);
tdDestroyKVRowBuilder(&kvRowBuilder);
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg7);
}
varDataSetLen(tagVal, output);
tdAddColToKVRow(&kvRowBuilder, jsonIndex++, TSDB_DATA_TYPE_NCHAR, tagVal);
if(item->type == cJSON_String){
output = 0;
if (!taosMbsToUcs4(item->valuestring, strlen(item->valuestring), varDataVal(tagVal), TSDB_MAX_TAGS_LEN - VARSTR_HEADER_SIZE, &output)) {
tscError("json string error:%s|%s", strerror(errno), item->string);
tdDestroyKVRowBuilder(&kvRowBuilder);
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg7);
}
varDataSetLen(tagVal, output);
tdAddColToKVRow(&kvRowBuilder, jsonIndex++, TSDB_DATA_TYPE_NCHAR, tagVal);
}else if(item->type == cJSON_Number){
*((double *)tagVal) = item->valuedouble;
tdAddColToKVRow(&kvRowBuilder, jsonIndex++, TSDB_DATA_TYPE_BIGINT, tagVal);
}else{
tdDestroyKVRowBuilder(&kvRowBuilder);
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg6);}
}
cJSON_Delete(root);
}
SKVRow row = tdGetKVRowFromBuilder(&kvRowBuilder);
tdDestroyKVRowBuilder(&kvRowBuilder);
if (row == NULL) {
......
......@@ -189,8 +189,11 @@ static bool doValidateSchema(SSchema* pSchema, int32_t numOfCols, int32_t maxLen
int32_t rowLen = 0;
for (int32_t i = 0; i < numOfCols; ++i) {
if (pSchema[i].type == TSDB_DATA_TYPE_JSON && numOfCols != 1){
return false;
}
// 1. valid types
if (!isValidDataType(pSchema[i].type)) {
if (!isValidDataType(pSchema[i].type) && pSchema[i].type != TSDB_DATA_TYPE_JSON) {
return false;
}
......
......@@ -34,7 +34,7 @@ const int32_t TYPE_BYTES[16] = {
sizeof(uint16_t), // TSDB_DATA_TYPE_USMALLINT
sizeof(uint32_t), // TSDB_DATA_TYPE_UINT
sizeof(uint64_t), // TSDB_DATA_TYPE_UBIGINT
sizeof(VarDataOffsetT), // TSDB_DATA_TYPE_JSON
sizeof(int8_t), // TSDB_DATA_TYPE_JSON
};
#define DO_STATICS(__sum, __min, __max, __minIndex, __maxIndex, _list, _index) \
......@@ -430,7 +430,7 @@ FORCE_INLINE void* getDataMax(int32_t type) {
bool isValidDataType(int32_t type) {
return type >= TSDB_DATA_TYPE_NULL && type <= TSDB_DATA_TYPE_JSON;
return type >= TSDB_DATA_TYPE_NULL && type <= TSDB_DATA_TYPE_UBIGINT;
}
void setVardataNull(void* val, int32_t type) {
......
......@@ -888,6 +888,16 @@ int32_t tVariantDumpEx(tVariant *pVariant, char *payload, int16_t type, bool inc
break;
}
case TSDB_DATA_TYPE_JSON: {
if (pVariant->nType == TSDB_DATA_TYPE_NULL) {
*(int8_t *)payload = TSDB_DATA_TINYINT_NULL;
} else if (pVariant->nType != TSDB_DATA_TYPE_BINARY){
return -1;
} else {
*((int8_t *)payload) = TSDB_DATA_BINARY_PLACEHOLDER;
}
break;
}
}
return 0;
......
......@@ -70,6 +70,7 @@ extern const int32_t TYPE_BYTES[16];
#define TSDB_DATA_DOUBLE_NULL 0x7FFFFF0000000000L // an NAN
#define TSDB_DATA_NCHAR_NULL 0xFFFFFFFF
#define TSDB_DATA_BINARY_NULL 0xFF
#define TSDB_DATA_BINARY_PLACEHOLDER 0x7F
#define TSDB_DATA_UTINYINT_NULL 0xFF
#define TSDB_DATA_USMALLINT_NULL 0xFFFF
......
......@@ -28,191 +28,192 @@
#define TK_TIMESTAMP 10
#define TK_BINARY 11
#define TK_NCHAR 12
#define TK_OR 13
#define TK_AND 14
#define TK_NOT 15
#define TK_EQ 16
#define TK_NE 17
#define TK_ISNULL 18
#define TK_NOTNULL 19
#define TK_IS 20
#define TK_LIKE 21
#define TK_MATCH 22
#define TK_GLOB 23
#define TK_BETWEEN 24
#define TK_IN 25
#define TK_GT 26
#define TK_GE 27
#define TK_LT 28
#define TK_LE 29
#define TK_BITAND 30
#define TK_BITOR 31
#define TK_LSHIFT 32
#define TK_RSHIFT 33
#define TK_PLUS 34
#define TK_MINUS 35
#define TK_DIVIDE 36
#define TK_TIMES 37
#define TK_STAR 38
#define TK_SLASH 39
#define TK_REM 40
#define TK_CONCAT 41
#define TK_UMINUS 42
#define TK_UPLUS 43
#define TK_BITNOT 44
#define TK_QUESTION 45
#define TK_ARROW 46
#define TK_SHOW 47
#define TK_DATABASES 48
#define TK_TOPICS 49
#define TK_FUNCTIONS 50
#define TK_MNODES 51
#define TK_DNODES 52
#define TK_ACCOUNTS 53
#define TK_USERS 54
#define TK_MODULES 55
#define TK_QUERIES 56
#define TK_CONNECTIONS 57
#define TK_STREAMS 58
#define TK_VARIABLES 59
#define TK_SCORES 60
#define TK_GRANTS 61
#define TK_VNODES 62
#define TK_DOT 63
#define TK_CREATE 64
#define TK_TABLE 65
#define TK_STABLE 66
#define TK_DATABASE 67
#define TK_TABLES 68
#define TK_STABLES 69
#define TK_VGROUPS 70
#define TK_DROP 71
#define TK_TOPIC 72
#define TK_FUNCTION 73
#define TK_DNODE 74
#define TK_USER 75
#define TK_ACCOUNT 76
#define TK_USE 77
#define TK_DESCRIBE 78
#define TK_DESC 79
#define TK_ALTER 80
#define TK_PASS 81
#define TK_PRIVILEGE 82
#define TK_LOCAL 83
#define TK_COMPACT 84
#define TK_LP 85
#define TK_RP 86
#define TK_IF 87
#define TK_EXISTS 88
#define TK_AS 89
#define TK_OUTPUTTYPE 90
#define TK_AGGREGATE 91
#define TK_BUFSIZE 92
#define TK_PPS 93
#define TK_TSERIES 94
#define TK_DBS 95
#define TK_STORAGE 96
#define TK_QTIME 97
#define TK_CONNS 98
#define TK_STATE 99
#define TK_COMMA 100
#define TK_KEEP 101
#define TK_CACHE 102
#define TK_REPLICA 103
#define TK_QUORUM 104
#define TK_DAYS 105
#define TK_MINROWS 106
#define TK_MAXROWS 107
#define TK_BLOCKS 108
#define TK_CTIME 109
#define TK_WAL 110
#define TK_FSYNC 111
#define TK_COMP 112
#define TK_PRECISION 113
#define TK_UPDATE 114
#define TK_CACHELAST 115
#define TK_PARTITIONS 116
#define TK_UNSIGNED 117
#define TK_TAGS 118
#define TK_USING 119
#define TK_NULL 120
#define TK_NOW 121
#define TK_SELECT 122
#define TK_UNION 123
#define TK_ALL 124
#define TK_DISTINCT 125
#define TK_FROM 126
#define TK_VARIABLE 127
#define TK_INTERVAL 128
#define TK_EVERY 129
#define TK_SESSION 130
#define TK_STATE_WINDOW 131
#define TK_FILL 132
#define TK_SLIDING 133
#define TK_ORDER 134
#define TK_BY 135
#define TK_ASC 136
#define TK_GROUP 137
#define TK_HAVING 138
#define TK_LIMIT 139
#define TK_OFFSET 140
#define TK_SLIMIT 141
#define TK_SOFFSET 142
#define TK_WHERE 143
#define TK_RESET 144
#define TK_QUERY 145
#define TK_SYNCDB 146
#define TK_ADD 147
#define TK_COLUMN 148
#define TK_MODIFY 149
#define TK_TAG 150
#define TK_CHANGE 151
#define TK_SET 152
#define TK_KILL 153
#define TK_CONNECTION 154
#define TK_STREAM 155
#define TK_COLON 156
#define TK_ABORT 157
#define TK_AFTER 158
#define TK_ATTACH 159
#define TK_BEFORE 160
#define TK_BEGIN 161
#define TK_CASCADE 162
#define TK_CLUSTER 163
#define TK_CONFLICT 164
#define TK_COPY 165
#define TK_DEFERRED 166
#define TK_DELIMITERS 167
#define TK_DETACH 168
#define TK_EACH 169
#define TK_END 170
#define TK_EXPLAIN 171
#define TK_FAIL 172
#define TK_FOR 173
#define TK_IGNORE 174
#define TK_IMMEDIATE 175
#define TK_INITIALLY 176
#define TK_INSTEAD 177
#define TK_KEY 178
#define TK_OF 179
#define TK_RAISE 180
#define TK_REPLACE 181
#define TK_RESTRICT 182
#define TK_ROW 183
#define TK_STATEMENT 184
#define TK_TRIGGER 185
#define TK_VIEW 186
#define TK_IPTOKEN 187
#define TK_SEMI 188
#define TK_NONE 189
#define TK_PREV 190
#define TK_LINEAR 191
#define TK_IMPORT 192
#define TK_TBNAME 193
#define TK_JOIN 194
#define TK_INSERT 195
#define TK_INTO 196
#define TK_VALUES 197
#define TK_JSON 13
#define TK_OR 14
#define TK_AND 15
#define TK_NOT 16
#define TK_EQ 17
#define TK_NE 18
#define TK_ISNULL 19
#define TK_NOTNULL 20
#define TK_IS 21
#define TK_LIKE 22
#define TK_MATCH 23
#define TK_GLOB 24
#define TK_BETWEEN 25
#define TK_IN 26
#define TK_GT 27
#define TK_GE 28
#define TK_LT 29
#define TK_LE 30
#define TK_BITAND 31
#define TK_BITOR 32
#define TK_LSHIFT 33
#define TK_RSHIFT 34
#define TK_PLUS 35
#define TK_MINUS 36
#define TK_DIVIDE 37
#define TK_TIMES 38
#define TK_STAR 39
#define TK_SLASH 40
#define TK_REM 41
#define TK_CONCAT 42
#define TK_UMINUS 43
#define TK_UPLUS 44
#define TK_BITNOT 45
#define TK_QUESTION 46
#define TK_ARROW 47
#define TK_SHOW 48
#define TK_DATABASES 49
#define TK_TOPICS 50
#define TK_FUNCTIONS 51
#define TK_MNODES 52
#define TK_DNODES 53
#define TK_ACCOUNTS 54
#define TK_USERS 55
#define TK_MODULES 56
#define TK_QUERIES 57
#define TK_CONNECTIONS 58
#define TK_STREAMS 59
#define TK_VARIABLES 60
#define TK_SCORES 61
#define TK_GRANTS 62
#define TK_VNODES 63
#define TK_DOT 64
#define TK_CREATE 65
#define TK_TABLE 66
#define TK_STABLE 67
#define TK_DATABASE 68
#define TK_TABLES 69
#define TK_STABLES 70
#define TK_VGROUPS 71
#define TK_DROP 72
#define TK_TOPIC 73
#define TK_FUNCTION 74
#define TK_DNODE 75
#define TK_USER 76
#define TK_ACCOUNT 77
#define TK_USE 78
#define TK_DESCRIBE 79
#define TK_DESC 80
#define TK_ALTER 81
#define TK_PASS 82
#define TK_PRIVILEGE 83
#define TK_LOCAL 84
#define TK_COMPACT 85
#define TK_LP 86
#define TK_RP 87
#define TK_IF 88
#define TK_EXISTS 89
#define TK_AS 90
#define TK_OUTPUTTYPE 91
#define TK_AGGREGATE 92
#define TK_BUFSIZE 93
#define TK_PPS 94
#define TK_TSERIES 95
#define TK_DBS 96
#define TK_STORAGE 97
#define TK_QTIME 98
#define TK_CONNS 99
#define TK_STATE 100
#define TK_COMMA 101
#define TK_KEEP 102
#define TK_CACHE 103
#define TK_REPLICA 104
#define TK_QUORUM 105
#define TK_DAYS 106
#define TK_MINROWS 107
#define TK_MAXROWS 108
#define TK_BLOCKS 109
#define TK_CTIME 110
#define TK_WAL 111
#define TK_FSYNC 112
#define TK_COMP 113
#define TK_PRECISION 114
#define TK_UPDATE 115
#define TK_CACHELAST 116
#define TK_PARTITIONS 117
#define TK_UNSIGNED 118
#define TK_TAGS 119
#define TK_USING 120
#define TK_NULL 121
#define TK_NOW 122
#define TK_SELECT 123
#define TK_UNION 124
#define TK_ALL 125
#define TK_DISTINCT 126
#define TK_FROM 127
#define TK_VARIABLE 128
#define TK_INTERVAL 129
#define TK_EVERY 130
#define TK_SESSION 131
#define TK_STATE_WINDOW 132
#define TK_FILL 133
#define TK_SLIDING 134
#define TK_ORDER 135
#define TK_BY 136
#define TK_ASC 137
#define TK_GROUP 138
#define TK_HAVING 139
#define TK_LIMIT 140
#define TK_OFFSET 141
#define TK_SLIMIT 142
#define TK_SOFFSET 143
#define TK_WHERE 144
#define TK_RESET 145
#define TK_QUERY 146
#define TK_SYNCDB 147
#define TK_ADD 148
#define TK_COLUMN 149
#define TK_MODIFY 150
#define TK_TAG 151
#define TK_CHANGE 152
#define TK_SET 153
#define TK_KILL 154
#define TK_CONNECTION 155
#define TK_STREAM 156
#define TK_COLON 157
#define TK_ABORT 158
#define TK_AFTER 159
#define TK_ATTACH 160
#define TK_BEFORE 161
#define TK_BEGIN 162
#define TK_CASCADE 163
#define TK_CLUSTER 164
#define TK_CONFLICT 165
#define TK_COPY 166
#define TK_DEFERRED 167
#define TK_DELIMITERS 168
#define TK_DETACH 169
#define TK_EACH 170
#define TK_END 171
#define TK_EXPLAIN 172
#define TK_FAIL 173
#define TK_FOR 174
#define TK_IGNORE 175
#define TK_IMMEDIATE 176
#define TK_INITIALLY 177
#define TK_INSTEAD 178
#define TK_KEY 179
#define TK_OF 180
#define TK_RAISE 181
#define TK_REPLACE 182
#define TK_RESTRICT 183
#define TK_ROW 184
#define TK_STATEMENT 185
#define TK_TRIGGER 186
#define TK_VIEW 187
#define TK_IPTOKEN 188
#define TK_SEMI 189
#define TK_NONE 190
#define TK_PREV 191
#define TK_LINEAR 192
#define TK_IMPORT 193
#define TK_TBNAME 194
#define TK_JOIN 195
#define TK_INSERT 196
#define TK_INTO 197
#define TK_VALUES 198
#define TK_SPACE 300
#define TK_COMMENT 301
......
......@@ -6,7 +6,7 @@
%default_type {SStrToken}
%extra_argument {SSqlInfo* pInfo}
%fallback ID BOOL TINYINT SMALLINT INTEGER BIGINT FLOAT DOUBLE STRING TIMESTAMP BINARY NCHAR.
%fallback ID BOOL TINYINT SMALLINT INTEGER BIGINT FLOAT DOUBLE STRING TIMESTAMP BINARY NCHAR JSON.
%left OR.
%left AND.
......
......@@ -55,191 +55,192 @@
#define TK_TIMESTAMP 10
#define TK_BINARY 11
#define TK_NCHAR 12
#define TK_OR 13
#define TK_AND 14
#define TK_NOT 15
#define TK_EQ 16
#define TK_NE 17
#define TK_ISNULL 18
#define TK_NOTNULL 19
#define TK_IS 20
#define TK_LIKE 21
#define TK_MATCH 22
#define TK_GLOB 23
#define TK_BETWEEN 24
#define TK_IN 25
#define TK_GT 26
#define TK_GE 27
#define TK_LT 28
#define TK_LE 29
#define TK_BITAND 30
#define TK_BITOR 31
#define TK_LSHIFT 32
#define TK_RSHIFT 33
#define TK_PLUS 34
#define TK_MINUS 35
#define TK_DIVIDE 36
#define TK_TIMES 37
#define TK_STAR 38
#define TK_SLASH 39
#define TK_REM 40
#define TK_CONCAT 41
#define TK_UMINUS 42
#define TK_UPLUS 43
#define TK_BITNOT 44
#define TK_QUESTION 45
#define TK_ARROW 46
#define TK_SHOW 47
#define TK_DATABASES 48
#define TK_TOPICS 49
#define TK_FUNCTIONS 50
#define TK_MNODES 51
#define TK_DNODES 52
#define TK_ACCOUNTS 53
#define TK_USERS 54
#define TK_MODULES 55
#define TK_QUERIES 56
#define TK_CONNECTIONS 57
#define TK_STREAMS 58
#define TK_VARIABLES 59
#define TK_SCORES 60
#define TK_GRANTS 61
#define TK_VNODES 62
#define TK_DOT 63
#define TK_CREATE 64
#define TK_TABLE 65
#define TK_STABLE 66
#define TK_DATABASE 67
#define TK_TABLES 68
#define TK_STABLES 69
#define TK_VGROUPS 70
#define TK_DROP 71
#define TK_TOPIC 72
#define TK_FUNCTION 73
#define TK_DNODE 74
#define TK_USER 75
#define TK_ACCOUNT 76
#define TK_USE 77
#define TK_DESCRIBE 78
#define TK_DESC 79
#define TK_ALTER 80
#define TK_PASS 81
#define TK_PRIVILEGE 82
#define TK_LOCAL 83
#define TK_COMPACT 84
#define TK_LP 85
#define TK_RP 86
#define TK_IF 87
#define TK_EXISTS 88
#define TK_AS 89
#define TK_OUTPUTTYPE 90
#define TK_AGGREGATE 91
#define TK_BUFSIZE 92
#define TK_PPS 93
#define TK_TSERIES 94
#define TK_DBS 95
#define TK_STORAGE 96
#define TK_QTIME 97
#define TK_CONNS 98
#define TK_STATE 99
#define TK_COMMA 100
#define TK_KEEP 101
#define TK_CACHE 102
#define TK_REPLICA 103
#define TK_QUORUM 104
#define TK_DAYS 105
#define TK_MINROWS 106
#define TK_MAXROWS 107
#define TK_BLOCKS 108
#define TK_CTIME 109
#define TK_WAL 110
#define TK_FSYNC 111
#define TK_COMP 112
#define TK_PRECISION 113
#define TK_UPDATE 114
#define TK_CACHELAST 115
#define TK_PARTITIONS 116
#define TK_UNSIGNED 117
#define TK_TAGS 118
#define TK_USING 119
#define TK_NULL 120
#define TK_NOW 121
#define TK_SELECT 122
#define TK_UNION 123
#define TK_ALL 124
#define TK_DISTINCT 125
#define TK_FROM 126
#define TK_VARIABLE 127
#define TK_INTERVAL 128
#define TK_EVERY 129
#define TK_SESSION 130
#define TK_STATE_WINDOW 131
#define TK_FILL 132
#define TK_SLIDING 133
#define TK_ORDER 134
#define TK_BY 135
#define TK_ASC 136
#define TK_GROUP 137
#define TK_HAVING 138
#define TK_LIMIT 139
#define TK_OFFSET 140
#define TK_SLIMIT 141
#define TK_SOFFSET 142
#define TK_WHERE 143
#define TK_RESET 144
#define TK_QUERY 145
#define TK_SYNCDB 146
#define TK_ADD 147
#define TK_COLUMN 148
#define TK_MODIFY 149
#define TK_TAG 150
#define TK_CHANGE 151
#define TK_SET 152
#define TK_KILL 153
#define TK_CONNECTION 154
#define TK_STREAM 155
#define TK_COLON 156
#define TK_ABORT 157
#define TK_AFTER 158
#define TK_ATTACH 159
#define TK_BEFORE 160
#define TK_BEGIN 161
#define TK_CASCADE 162
#define TK_CLUSTER 163
#define TK_CONFLICT 164
#define TK_COPY 165
#define TK_DEFERRED 166
#define TK_DELIMITERS 167
#define TK_DETACH 168
#define TK_EACH 169
#define TK_END 170
#define TK_EXPLAIN 171
#define TK_FAIL 172
#define TK_FOR 173
#define TK_IGNORE 174
#define TK_IMMEDIATE 175
#define TK_INITIALLY 176
#define TK_INSTEAD 177
#define TK_KEY 178
#define TK_OF 179
#define TK_RAISE 180
#define TK_REPLACE 181
#define TK_RESTRICT 182
#define TK_ROW 183
#define TK_STATEMENT 184
#define TK_TRIGGER 185
#define TK_VIEW 186
#define TK_IPTOKEN 187
#define TK_SEMI 188
#define TK_NONE 189
#define TK_PREV 190
#define TK_LINEAR 191
#define TK_IMPORT 192
#define TK_TBNAME 193
#define TK_JOIN 194
#define TK_INSERT 195
#define TK_INTO 196
#define TK_VALUES 197
#define TK_JSON 13
#define TK_OR 14
#define TK_AND 15
#define TK_NOT 16
#define TK_EQ 17
#define TK_NE 18
#define TK_ISNULL 19
#define TK_NOTNULL 20
#define TK_IS 21
#define TK_LIKE 22
#define TK_MATCH 23
#define TK_GLOB 24
#define TK_BETWEEN 25
#define TK_IN 26
#define TK_GT 27
#define TK_GE 28
#define TK_LT 29
#define TK_LE 30
#define TK_BITAND 31
#define TK_BITOR 32
#define TK_LSHIFT 33
#define TK_RSHIFT 34
#define TK_PLUS 35
#define TK_MINUS 36
#define TK_DIVIDE 37
#define TK_TIMES 38
#define TK_STAR 39
#define TK_SLASH 40
#define TK_REM 41
#define TK_CONCAT 42
#define TK_UMINUS 43
#define TK_UPLUS 44
#define TK_BITNOT 45
#define TK_QUESTION 46
#define TK_ARROW 47
#define TK_SHOW 48
#define TK_DATABASES 49
#define TK_TOPICS 50
#define TK_FUNCTIONS 51
#define TK_MNODES 52
#define TK_DNODES 53
#define TK_ACCOUNTS 54
#define TK_USERS 55
#define TK_MODULES 56
#define TK_QUERIES 57
#define TK_CONNECTIONS 58
#define TK_STREAMS 59
#define TK_VARIABLES 60
#define TK_SCORES 61
#define TK_GRANTS 62
#define TK_VNODES 63
#define TK_DOT 64
#define TK_CREATE 65
#define TK_TABLE 66
#define TK_STABLE 67
#define TK_DATABASE 68
#define TK_TABLES 69
#define TK_STABLES 70
#define TK_VGROUPS 71
#define TK_DROP 72
#define TK_TOPIC 73
#define TK_FUNCTION 74
#define TK_DNODE 75
#define TK_USER 76
#define TK_ACCOUNT 77
#define TK_USE 78
#define TK_DESCRIBE 79
#define TK_DESC 80
#define TK_ALTER 81
#define TK_PASS 82
#define TK_PRIVILEGE 83
#define TK_LOCAL 84
#define TK_COMPACT 85
#define TK_LP 86
#define TK_RP 87
#define TK_IF 88
#define TK_EXISTS 89
#define TK_AS 90
#define TK_OUTPUTTYPE 91
#define TK_AGGREGATE 92
#define TK_BUFSIZE 93
#define TK_PPS 94
#define TK_TSERIES 95
#define TK_DBS 96
#define TK_STORAGE 97
#define TK_QTIME 98
#define TK_CONNS 99
#define TK_STATE 100
#define TK_COMMA 101
#define TK_KEEP 102
#define TK_CACHE 103
#define TK_REPLICA 104
#define TK_QUORUM 105
#define TK_DAYS 106
#define TK_MINROWS 107
#define TK_MAXROWS 108
#define TK_BLOCKS 109
#define TK_CTIME 110
#define TK_WAL 111
#define TK_FSYNC 112
#define TK_COMP 113
#define TK_PRECISION 114
#define TK_UPDATE 115
#define TK_CACHELAST 116
#define TK_PARTITIONS 117
#define TK_UNSIGNED 118
#define TK_TAGS 119
#define TK_USING 120
#define TK_NULL 121
#define TK_NOW 122
#define TK_SELECT 123
#define TK_UNION 124
#define TK_ALL 125
#define TK_DISTINCT 126
#define TK_FROM 127
#define TK_VARIABLE 128
#define TK_INTERVAL 129
#define TK_EVERY 130
#define TK_SESSION 131
#define TK_STATE_WINDOW 132
#define TK_FILL 133
#define TK_SLIDING 134
#define TK_ORDER 135
#define TK_BY 136
#define TK_ASC 137
#define TK_GROUP 138
#define TK_HAVING 139
#define TK_LIMIT 140
#define TK_OFFSET 141
#define TK_SLIMIT 142
#define TK_SOFFSET 143
#define TK_WHERE 144
#define TK_RESET 145
#define TK_QUERY 146
#define TK_SYNCDB 147
#define TK_ADD 148
#define TK_COLUMN 149
#define TK_MODIFY 150
#define TK_TAG 151
#define TK_CHANGE 152
#define TK_SET 153
#define TK_KILL 154
#define TK_CONNECTION 155
#define TK_STREAM 156
#define TK_COLON 157
#define TK_ABORT 158
#define TK_AFTER 159
#define TK_ATTACH 160
#define TK_BEFORE 161
#define TK_BEGIN 162
#define TK_CASCADE 163
#define TK_CLUSTER 164
#define TK_CONFLICT 165
#define TK_COPY 166
#define TK_DEFERRED 167
#define TK_DELIMITERS 168
#define TK_DETACH 169
#define TK_EACH 170
#define TK_END 171
#define TK_EXPLAIN 172
#define TK_FAIL 173
#define TK_FOR 174
#define TK_IGNORE 175
#define TK_IMMEDIATE 176
#define TK_INITIALLY 177
#define TK_INSTEAD 178
#define TK_KEY 179
#define TK_OF 180
#define TK_RAISE 181
#define TK_REPLACE 182
#define TK_RESTRICT 183
#define TK_ROW 184
#define TK_STATEMENT 185
#define TK_TRIGGER 186
#define TK_VIEW 187
#define TK_IPTOKEN 188
#define TK_SEMI 189
#define TK_NONE 190
#define TK_PREV 191
#define TK_LINEAR 192
#define TK_IMPORT 193
#define TK_TBNAME 194
#define TK_JOIN 195
#define TK_INSERT 196
#define TK_INTO 197
#define TK_VALUES 198
#endif
/**************** End token definitions ***************************************/
......
......@@ -44,6 +44,7 @@ static SKeyword keywordTable[] = {
{"TIMESTAMP", TK_TIMESTAMP},
{"BINARY", TK_BINARY},
{"NCHAR", TK_NCHAR},
{"JSON", TK_JSON},
{"OR", TK_OR},
{"AND", TK_AND},
{"NOT", TK_NOT},
......@@ -257,7 +258,7 @@ static void doInitKeywordsTable(void) {
static pthread_once_t keywordsHashTableInit = PTHREAD_ONCE_INIT;
static int32_t tKeywordCode(const char* z, int n) {
static int32_t gtKeywordCode(const char* z, int n) {
pthread_once(&keywordsHashTableInit, doInitKeywordsTable);
char key[512] = {0};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册