diff --git a/cmake/taosadapter_CMakeLists.txt.in b/cmake/taosadapter_CMakeLists.txt.in index 13826a1a74..ef6ed4af1d 100644 --- a/cmake/taosadapter_CMakeLists.txt.in +++ b/cmake/taosadapter_CMakeLists.txt.in @@ -2,7 +2,7 @@ # taosadapter ExternalProject_Add(taosadapter GIT_REPOSITORY https://github.com/taosdata/taosadapter.git - GIT_TAG main + GIT_TAG 3.0 SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosadapter" BINARY_DIR "" #BUILD_IN_SOURCE TRUE diff --git a/include/common/systable.h b/include/common/systable.h index ea18338e9e..b44d8ce1d6 100644 --- a/include/common/systable.h +++ b/include/common/systable.h @@ -49,6 +49,7 @@ extern "C" { #define TSDB_INS_TABLE_STREAMS "ins_streams" #define TSDB_INS_TABLE_STREAM_TASKS "ins_stream_tasks" #define TSDB_INS_TABLE_USER_PRIVILEGES "ins_user_privileges" +#define TSDB_INS_TABLE_VIEWS "ins_views" #define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema" #define TSDB_PERFS_TABLE_SMAS "perf_smas" diff --git a/include/common/taosdef.h b/include/common/taosdef.h index d1ca446904..9e92e2f569 100644 --- a/include/common/taosdef.h +++ b/include/common/taosdef.h @@ -42,7 +42,8 @@ typedef enum { TSDB_TEMP_TABLE = 4, // temp table created by nest query TSDB_SYSTEM_TABLE = 5, TSDB_TSMA_TABLE = 6, // time-range-wise sma - TSDB_TABLE_MAX = 7 + TSDB_VIEW_TABLE = 7, + TSDB_TABLE_MAX = 8 } ETableType; typedef enum { diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 323772af95..57906c1695 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -107,6 +107,8 @@ enum { HEARTBEAT_KEY_DBINFO, HEARTBEAT_KEY_STBINFO, HEARTBEAT_KEY_TMQ, + HEARTBEAT_KEY_DYN_VIEW, + HEARTBEAT_KEY_VIEWINFO, }; typedef enum _mgmt_table { @@ -141,6 +143,7 @@ typedef enum _mgmt_table { TSDB_MGMT_TABLE_APPS, TSDB_MGMT_TABLE_STREAM_TASKS, TSDB_MGMT_TABLE_PRIVILEGES, + TSDB_MGMT_TABLE_VIEWS, TSDB_MGMT_TABLE_MAX, } EShowType; @@ -168,26 +171,12 @@ typedef enum _mgmt_table { #define TSDB_ALTER_USER_PASSWD 0x1 #define TSDB_ALTER_USER_SUPERUSER 0x2 -#define TSDB_ALTER_USER_ADD_READ_DB 0x3 -#define TSDB_ALTER_USER_REMOVE_READ_DB 0x4 -#define TSDB_ALTER_USER_ADD_WRITE_DB 0x5 -#define TSDB_ALTER_USER_REMOVE_WRITE_DB 0x6 -#define TSDB_ALTER_USER_ADD_ALL_DB 0x7 -#define TSDB_ALTER_USER_REMOVE_ALL_DB 0x8 -#define TSDB_ALTER_USER_ENABLE 0x9 -#define TSDB_ALTER_USER_SYSINFO 0xA -#define TSDB_ALTER_USER_ADD_SUBSCRIBE_TOPIC 0xB -#define TSDB_ALTER_USER_REMOVE_SUBSCRIBE_TOPIC 0xC -#define TSDB_ALTER_USER_ADD_READ_TABLE 0xD -#define TSDB_ALTER_USER_REMOVE_READ_TABLE 0xE -#define TSDB_ALTER_USER_ADD_WRITE_TABLE 0xF -#define TSDB_ALTER_USER_REMOVE_WRITE_TABLE 0x10 -#define TSDB_ALTER_USER_ADD_ALL_TABLE 0x11 -#define TSDB_ALTER_USER_REMOVE_ALL_TABLE 0x12 -#define TSDB_ALTER_USER_ADD_WHITE_LIST 0x13 -#define TSDB_ALTER_USER_DROP_WHITE_LIST 0x14 - -#define TSDB_ALTER_USER_PRIVILEGES 0x2 +#define TSDB_ALTER_USER_ENABLE 0x3 +#define TSDB_ALTER_USER_SYSINFO 0x4 +#define TSDB_ALTER_USER_ADD_PRIVILEGES 0x5 +#define TSDB_ALTER_USER_DEL_PRIVILEGES 0x6 +#define TSDB_ALTER_USER_ADD_WHITE_LIST 0x7 +#define TSDB_ALTER_USER_DROP_WHITE_LIST 0x8 #define TSDB_KILL_MSG_LEN 30 @@ -251,6 +240,7 @@ typedef enum ENodeType { QUERY_NODE_CASE_WHEN, QUERY_NODE_EVENT_WINDOW, QUERY_NODE_HINT, + QUERY_NODE_VIEW, // Statement nodes are used in parser and planner module. QUERY_NODE_SET_OPERATOR = 100, @@ -333,6 +323,8 @@ typedef enum ENodeType { QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT, QUERY_NODE_SHOW_VNODES_STMT, QUERY_NODE_SHOW_USER_PRIVILEGES_STMT, + QUERY_NODE_SHOW_VIEWS_STMT, + QUERY_NODE_SHOW_CREATE_VIEW_STMT, QUERY_NODE_SHOW_CREATE_DATABASE_STMT, QUERY_NODE_SHOW_CREATE_TABLE_STMT, QUERY_NODE_SHOW_CREATE_STABLE_STMT, @@ -354,7 +346,9 @@ typedef enum ENodeType { QUERY_NODE_RESTORE_MNODE_STMT, QUERY_NODE_RESTORE_VNODE_STMT, QUERY_NODE_PAUSE_STREAM_STMT, - QUERY_NODE_RESUME_STREAM_STMT, + QUERY_NODE_RESUME_STREAM_STMT, + QUERY_NODE_CREATE_VIEW_STMT, + QUERY_NODE_DROP_VIEW_STMT, // logic plan node QUERY_NODE_LOGIC_PLAN_SCAN = 1000, @@ -948,6 +942,7 @@ typedef struct { int8_t superUser; int8_t sysInfo; int8_t enable; + int8_t isView; char user[TSDB_USER_LEN]; char pass[TSDB_USET_PASSWORD_LEN]; char objname[TSDB_DB_FNAME_LEN]; // db or topic @@ -956,6 +951,7 @@ typedef struct { int32_t tagCondLen; int32_t numIpRanges; SIpV4Range* pIpRanges; + int64_t privileges; int32_t sqlLen; char* sql; } SAlterUserReq; @@ -984,6 +980,10 @@ typedef struct { SHashObj* writeDbs; SHashObj* readTbs; SHashObj* writeTbs; + SHashObj* alterTbs; + SHashObj* readViews; + SHashObj* writeViews; + SHashObj* alterViews; SHashObj* useDbs; int64_t whiteListVer; } SGetUserAuthRsp; @@ -1814,6 +1814,15 @@ int32_t tSerializeSSTbHbRsp(void* buf, int32_t bufLen, SSTbHbRsp* pRsp); int32_t tDeserializeSSTbHbRsp(void* buf, int32_t bufLen, SSTbHbRsp* pRsp); void tFreeSSTbHbRsp(SSTbHbRsp* pRsp); +typedef struct { + SArray* pViewRsp; // Array of SViewMetaRsp*; +} SViewHbRsp; + +int32_t tSerializeSViewHbRsp(void* buf, int32_t bufLen, SViewHbRsp* pRsp); +int32_t tDeserializeSViewHbRsp(void* buf, int32_t bufLen, SViewHbRsp* pRsp); +void tFreeSViewHbRsp(SViewHbRsp* pRsp); + + typedef struct { int32_t numOfTables; int32_t numOfVgroup; @@ -3886,6 +3895,58 @@ typedef struct { }; } SPackedData; +typedef struct { + char fullname[TSDB_VIEW_FNAME_LEN]; + char name[TSDB_VIEW_NAME_LEN]; + char dbFName[TSDB_DB_FNAME_LEN]; + char* querySql; + char* sql; + int8_t orReplace; + int8_t precision; + int32_t numOfCols; + SSchema* pSchema; +} SCMCreateViewReq; + +int32_t tSerializeSCMCreateViewReq(void* buf, int32_t bufLen, const SCMCreateViewReq* pReq); +int32_t tDeserializeSCMCreateViewReq(void* buf, int32_t bufLen, SCMCreateViewReq* pReq); +void tFreeSCMCreateViewReq(SCMCreateViewReq* pReq); + +typedef struct { + char fullname[TSDB_VIEW_FNAME_LEN]; + char name[TSDB_VIEW_NAME_LEN]; + char dbFName[TSDB_DB_FNAME_LEN]; + char* sql; + int8_t igNotExists; +} SCMDropViewReq; + +int32_t tSerializeSCMDropViewReq(void* buf, int32_t bufLen, const SCMDropViewReq* pReq); +int32_t tDeserializeSCMDropViewReq(void* buf, int32_t bufLen, SCMDropViewReq* pReq); +void tFreeSCMDropViewReq(SCMDropViewReq* pReq); + +typedef struct { + char fullname[TSDB_VIEW_FNAME_LEN]; +} SViewMetaReq; +int32_t tSerializeSViewMetaReq(void* buf, int32_t bufLen, const SViewMetaReq* pReq); +int32_t tDeserializeSViewMetaReq(void* buf, int32_t bufLen, SViewMetaReq* pReq); + +typedef struct { + char name[TSDB_VIEW_NAME_LEN]; + char dbFName[TSDB_DB_FNAME_LEN]; + char* user; + uint64_t dbId; + uint64_t viewId; + char* querySql; + int8_t precision; + int8_t type; + int32_t version; + int32_t numOfCols; + SSchema* pSchema; +} SViewMetaRsp; +int32_t tSerializeSViewMetaRsp(void* buf, int32_t bufLen, const SViewMetaRsp* pRsp); +int32_t tDeserializeSViewMetaRsp(void* buf, int32_t bufLen, SViewMetaRsp* pRsp); +void tFreeSViewMetaRsp(SViewMetaRsp* pRsp); + + #pragma pack(pop) #ifdef __cplusplus diff --git a/include/common/tmsgdef.h b/include/common/tmsgdef.h index b92bba831c..4eb8328caa 100644 --- a/include/common/tmsgdef.h +++ b/include/common/tmsgdef.h @@ -189,6 +189,9 @@ enum { // WARN: new msg should be appended to segment tail TD_DEF_MSG_TYPE(TDMT_MND_STREAM_NODECHANGE_CHECK, "stream-nodechange-check", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_MND_TRIM_DB_TIMER, "trim-db-tmr", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_MND_GRANT_NOTIFY, "grant-notify", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_MND_CREATE_VIEW, "create-view", SCMCreateViewReq, NULL) + TD_DEF_MSG_TYPE(TDMT_MND_DROP_VIEW, "drop-view", SCMDropViewReq, NULL) + TD_DEF_MSG_TYPE(TDMT_MND_VIEW_META, "view-meta", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_MND_MAX_MSG, "mnd-max", NULL, NULL) TD_NEW_MSG_SEG(TDMT_VND_MSG) diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index 72099aaaf2..cb080ab118 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -187,180 +187,183 @@ #define TK_SUBSCRIPTIONS 168 #define TK_VNODES 169 #define TK_ALIVE 170 -#define TK_NORMAL 171 -#define TK_CHILD 172 -#define TK_LIKE 173 -#define TK_TBNAME 174 -#define TK_QTAGS 175 -#define TK_AS 176 -#define TK_SYSTEM 177 -#define TK_INDEX 178 -#define TK_FUNCTION 179 -#define TK_INTERVAL 180 -#define TK_COUNT 181 -#define TK_LAST_ROW 182 -#define TK_META 183 -#define TK_ONLY 184 -#define TK_TOPIC 185 -#define TK_CONSUMER 186 -#define TK_GROUP 187 -#define TK_DESC 188 -#define TK_DESCRIBE 189 -#define TK_RESET 190 -#define TK_QUERY 191 -#define TK_CACHE 192 -#define TK_EXPLAIN 193 -#define TK_ANALYZE 194 -#define TK_VERBOSE 195 -#define TK_NK_BOOL 196 -#define TK_RATIO 197 -#define TK_NK_FLOAT 198 -#define TK_OUTPUTTYPE 199 -#define TK_AGGREGATE 200 -#define TK_BUFSIZE 201 -#define TK_LANGUAGE 202 -#define TK_REPLACE 203 -#define TK_STREAM 204 -#define TK_INTO 205 -#define TK_PAUSE 206 -#define TK_RESUME 207 -#define TK_TRIGGER 208 -#define TK_AT_ONCE 209 -#define TK_WINDOW_CLOSE 210 -#define TK_IGNORE 211 -#define TK_EXPIRED 212 -#define TK_FILL_HISTORY 213 -#define TK_UPDATE 214 -#define TK_SUBTABLE 215 -#define TK_UNTREATED 216 -#define TK_KILL 217 -#define TK_CONNECTION 218 -#define TK_TRANSACTION 219 -#define TK_BALANCE 220 -#define TK_VGROUP 221 -#define TK_LEADER 222 -#define TK_MERGE 223 -#define TK_REDISTRIBUTE 224 -#define TK_SPLIT 225 -#define TK_DELETE 226 -#define TK_INSERT 227 -#define TK_NULL 228 -#define TK_NK_QUESTION 229 -#define TK_NK_ALIAS 230 -#define TK_NK_ARROW 231 -#define TK_ROWTS 232 -#define TK_QSTART 233 -#define TK_QEND 234 -#define TK_QDURATION 235 -#define TK_WSTART 236 -#define TK_WEND 237 -#define TK_WDURATION 238 -#define TK_IROWTS 239 -#define TK_ISFILLED 240 -#define TK_CAST 241 -#define TK_NOW 242 -#define TK_TODAY 243 -#define TK_TIMEZONE 244 -#define TK_CLIENT_VERSION 245 -#define TK_SERVER_VERSION 246 -#define TK_SERVER_STATUS 247 -#define TK_CURRENT_USER 248 -#define TK_CASE 249 -#define TK_WHEN 250 -#define TK_THEN 251 -#define TK_ELSE 252 -#define TK_BETWEEN 253 -#define TK_IS 254 -#define TK_NK_LT 255 -#define TK_NK_GT 256 -#define TK_NK_LE 257 -#define TK_NK_GE 258 -#define TK_NK_NE 259 -#define TK_MATCH 260 -#define TK_NMATCH 261 -#define TK_CONTAINS 262 -#define TK_IN 263 -#define TK_JOIN 264 -#define TK_INNER 265 -#define TK_SELECT 266 -#define TK_NK_HINT 267 -#define TK_DISTINCT 268 -#define TK_WHERE 269 -#define TK_PARTITION 270 -#define TK_BY 271 -#define TK_SESSION 272 -#define TK_STATE_WINDOW 273 -#define TK_EVENT_WINDOW 274 -#define TK_SLIDING 275 -#define TK_FILL 276 -#define TK_VALUE 277 -#define TK_VALUE_F 278 -#define TK_NONE 279 -#define TK_PREV 280 -#define TK_NULL_F 281 -#define TK_LINEAR 282 -#define TK_NEXT 283 -#define TK_HAVING 284 -#define TK_RANGE 285 -#define TK_EVERY 286 -#define TK_ORDER 287 -#define TK_SLIMIT 288 -#define TK_SOFFSET 289 -#define TK_LIMIT 290 -#define TK_OFFSET 291 -#define TK_ASC 292 -#define TK_NULLS 293 -#define TK_ABORT 294 -#define TK_AFTER 295 -#define TK_ATTACH 296 -#define TK_BEFORE 297 -#define TK_BEGIN 298 -#define TK_BITAND 299 -#define TK_BITNOT 300 -#define TK_BITOR 301 -#define TK_BLOCKS 302 -#define TK_CHANGE 303 -#define TK_COMMA 304 -#define TK_CONCAT 305 -#define TK_CONFLICT 306 -#define TK_COPY 307 -#define TK_DEFERRED 308 -#define TK_DELIMITERS 309 -#define TK_DETACH 310 -#define TK_DIVIDE 311 -#define TK_DOT 312 -#define TK_EACH 313 -#define TK_FAIL 314 -#define TK_FILE 315 -#define TK_FOR 316 -#define TK_GLOB 317 -#define TK_ID 318 -#define TK_IMMEDIATE 319 -#define TK_IMPORT 320 -#define TK_INITIALLY 321 -#define TK_INSTEAD 322 -#define TK_ISNULL 323 -#define TK_KEY 324 -#define TK_MODULES 325 -#define TK_NK_BITNOT 326 -#define TK_NK_SEMI 327 -#define TK_NOTNULL 328 -#define TK_OF 329 -#define TK_PLUS 330 -#define TK_PRIVILEGE 331 -#define TK_RAISE 332 -#define TK_RESTRICT 333 -#define TK_ROW 334 -#define TK_SEMI 335 -#define TK_STAR 336 -#define TK_STATEMENT 337 -#define TK_STRICT 338 -#define TK_STRING 339 -#define TK_TIMES 340 -#define TK_VALUES 341 -#define TK_VARIABLE 342 -#define TK_VIEW 343 -#define TK_WAL 344 +#define TK_VIEWS 171 +#define TK_VIEW 172 +#define TK_NORMAL 173 +#define TK_CHILD 174 +#define TK_LIKE 175 +#define TK_TBNAME 176 +#define TK_QTAGS 177 +#define TK_AS 178 +#define TK_SYSTEM 179 +#define TK_INDEX 180 +#define TK_FUNCTION 181 +#define TK_INTERVAL 182 +#define TK_COUNT 183 +#define TK_LAST_ROW 184 +#define TK_META 185 +#define TK_ONLY 186 +#define TK_TOPIC 187 +#define TK_CONSUMER 188 +#define TK_GROUP 189 +#define TK_DESC 190 +#define TK_DESCRIBE 191 +#define TK_RESET 192 +#define TK_QUERY 193 +#define TK_CACHE 194 +#define TK_EXPLAIN 195 +#define TK_ANALYZE 196 +#define TK_VERBOSE 197 +#define TK_NK_BOOL 198 +#define TK_RATIO 199 +#define TK_NK_FLOAT 200 +#define TK_OUTPUTTYPE 201 +#define TK_AGGREGATE 202 +#define TK_BUFSIZE 203 +#define TK_LANGUAGE 204 +#define TK_REPLACE 205 +#define TK_STREAM 206 +#define TK_INTO 207 +#define TK_PAUSE 208 +#define TK_RESUME 209 +#define TK_TRIGGER 210 +#define TK_AT_ONCE 211 +#define TK_WINDOW_CLOSE 212 +#define TK_IGNORE 213 +#define TK_EXPIRED 214 +#define TK_FILL_HISTORY 215 +#define TK_UPDATE 216 +#define TK_SUBTABLE 217 +#define TK_UNTREATED 218 +#define TK_KILL 219 +#define TK_CONNECTION 220 +#define TK_TRANSACTION 221 +#define TK_BALANCE 222 +#define TK_VGROUP 223 +#define TK_LEADER 224 +#define TK_MERGE 225 +#define TK_REDISTRIBUTE 226 +#define TK_SPLIT 227 +#define TK_DELETE 228 +#define TK_INSERT 229 +#define TK_NULL 230 +#define TK_NK_QUESTION 231 +#define TK_NK_ALIAS 232 +#define TK_NK_ARROW 233 +#define TK_ROWTS 234 +#define TK_QSTART 235 +#define TK_QEND 236 +#define TK_QDURATION 237 +#define TK_WSTART 238 +#define TK_WEND 239 +#define TK_WDURATION 240 +#define TK_IROWTS 241 +#define TK_ISFILLED 242 +#define TK_CAST 243 +#define TK_NOW 244 +#define TK_TODAY 245 +#define TK_TIMEZONE 246 +#define TK_CLIENT_VERSION 247 +#define TK_SERVER_VERSION 248 +#define TK_SERVER_STATUS 249 +#define TK_CURRENT_USER 250 +#define TK_CASE 251 +#define TK_WHEN 252 +#define TK_THEN 253 +#define TK_ELSE 254 +#define TK_BETWEEN 255 +#define TK_IS 256 +#define TK_NK_LT 257 +#define TK_NK_GT 258 +#define TK_NK_LE 259 +#define TK_NK_GE 260 +#define TK_NK_NE 261 +#define TK_MATCH 262 +#define TK_NMATCH 263 +#define TK_CONTAINS 264 +#define TK_IN 265 +#define TK_JOIN 266 +#define TK_INNER 267 +#define TK_SELECT 268 +#define TK_NK_HINT 269 +#define TK_DISTINCT 270 +#define TK_WHERE 271 +#define TK_PARTITION 272 +#define TK_BY 273 +#define TK_SESSION 274 +#define TK_STATE_WINDOW 275 +#define TK_EVENT_WINDOW 276 +#define TK_SLIDING 277 +#define TK_FILL 278 +#define TK_VALUE 279 +#define TK_VALUE_F 280 +#define TK_NONE 281 +#define TK_PREV 282 +#define TK_NULL_F 283 +#define TK_LINEAR 284 +#define TK_NEXT 285 +#define TK_HAVING 286 +#define TK_RANGE 287 +#define TK_EVERY 288 +#define TK_ORDER 289 +#define TK_SLIMIT 290 +#define TK_SOFFSET 291 +#define TK_LIMIT 292 +#define TK_OFFSET 293 +#define TK_ASC 294 +#define TK_NULLS 295 +#define TK_ABORT 296 +#define TK_AFTER 297 +#define TK_ATTACH 298 +#define TK_BEFORE 299 +#define TK_BEGIN 300 +#define TK_BITAND 301 +#define TK_BITNOT 302 +#define TK_BITOR 303 +#define TK_BLOCKS 304 +#define TK_CHANGE 305 +#define TK_COMMA 306 +#define TK_CONCAT 307 +#define TK_CONFLICT 308 +#define TK_COPY 309 +#define TK_DEFERRED 310 +#define TK_DELIMITERS 311 +#define TK_DETACH 312 +#define TK_DIVIDE 313 +#define TK_DOT 314 +#define TK_EACH 315 +#define TK_FAIL 316 +#define TK_FILE 317 +#define TK_FOR 318 +#define TK_GLOB 319 +#define TK_ID 320 +#define TK_IMMEDIATE 321 +#define TK_IMPORT 322 +#define TK_INITIALLY 323 +#define TK_INSTEAD 324 +#define TK_ISNULL 325 +#define TK_KEY 326 +#define TK_MODULES 327 +#define TK_NK_BITNOT 328 +#define TK_NK_SEMI 329 +#define TK_NOTNULL 330 +#define TK_OF 331 +#define TK_PLUS 332 +#define TK_PRIVILEGE 333 +#define TK_RAISE 334 +#define TK_RESTRICT 335 +#define TK_ROW 336 +#define TK_SEMI 337 +#define TK_STAR 338 +#define TK_STATEMENT 339 +#define TK_STRICT 340 +#define TK_STRING 341 +#define TK_TIMES 342 +#define TK_VALUES 343 +#define TK_VARIABLE 344 +#define TK_WAL 345 + + diff --git a/include/libs/catalog/catalog.h b/include/libs/catalog/catalog.h index 7a7a13b285..b34b998d76 100644 --- a/include/libs/catalog/catalog.h +++ b/include/libs/catalog/catalog.h @@ -37,13 +37,16 @@ enum { CTG_DBG_DB_NUM = 1, CTG_DBG_META_NUM, CTG_DBG_STB_NUM, + CTG_DBG_VIEW_NUM, CTG_DBG_DB_RENT_NUM, CTG_DBG_STB_RENT_NUM, + CTG_DBG_VIEW_RENT_NUM, }; typedef enum { AUTH_TYPE_READ = 1, AUTH_TYPE_WRITE, + AUTH_TYPE_ALTER, AUTH_TYPE_OTHER, AUTH_TYPE_READ_OR_WRITE, } AUTH_TYPE; @@ -51,12 +54,19 @@ typedef enum { typedef struct SUserAuthInfo { char user[TSDB_USER_LEN]; SName tbName; + bool isView; AUTH_TYPE type; } SUserAuthInfo; +typedef enum { + AUTH_RES_BASIC = 0, + AUTH_RES_VIEW, + AUTH_RES_MAX_VALUE +} AUTH_RES_TYPE; + typedef struct SUserAuthRes { - bool pass; - SNode* pCond; + bool pass[AUTH_RES_MAX_VALUE]; + SNode* pCond[AUTH_RES_MAX_VALUE]; } SUserAuthRes; typedef struct SDbInfo { @@ -83,6 +93,7 @@ typedef struct SCatalogReq { SArray* pTableIndex; // element is SNAME SArray* pTableCfg; // element is SNAME SArray* pTableTag; // element is SNAME + SArray* pView; // element is STablesReq bool qNodeRequired; // valid qnode bool dNodeRequired; // valid dnode bool svrVerRequired; @@ -96,6 +107,7 @@ typedef struct SMetaRes { } SMetaRes; typedef struct SMetaData { + bool ctgFree; // need to freed by catalog module SArray* pDbVgroup; // pRes = SArray* SArray* pDbCfg; // pRes = SDbCfgInfo* SArray* pDbInfo; // pRes = SDbInfo* @@ -109,21 +121,24 @@ typedef struct SMetaData { SArray* pTableCfg; // pRes = STableCfg* SArray* pTableTag; // pRes = SArray* SArray* pDnodeList; // pRes = SArray* + SArray* pView; // pRes = SViewMeta* SMetaRes* pSvrVer; // pRes = char* } SMetaData; typedef struct SCatalogCfg { uint32_t maxTblCacheNum; + uint32_t maxViewCacheNum; uint32_t maxDBCacheNum; uint32_t maxUserCacheNum; uint32_t dbRentSec; uint32_t stbRentSec; + uint32_t viewRentSec; } SCatalogCfg; typedef struct SSTableVersion { char dbFName[TSDB_DB_FNAME_LEN]; char stbName[TSDB_TABLE_NAME_LEN]; - uint64_t dbId; + int64_t dbId; uint64_t suid; int32_t sversion; int32_t tversion; @@ -139,6 +154,20 @@ typedef struct SDbCacheInfo { int64_t stateTs; } SDbCacheInfo; +typedef struct SDynViewVersion { + int64_t svrBootTs; + uint64_t dynViewVer; +} SDynViewVersion; + +typedef struct SViewVersion { + char dbFName[TSDB_DB_FNAME_LEN]; + char viewName[TSDB_VIEW_NAME_LEN]; + int64_t dbId; + uint64_t viewId; + int32_t version; +} SViewVersion; + + typedef struct STbSVersion { char* tbFName; int32_t sver; @@ -307,6 +336,8 @@ int32_t catalogGetDnodeList(SCatalog* pCatalog, SRequestConnInfo* pConn, SArray* int32_t catalogGetExpiredSTables(SCatalog* pCatalog, SSTableVersion** stables, uint32_t* num); +int32_t catalogGetExpiredViews(SCatalog* pCtg, SViewVersion** views, uint32_t* num, SDynViewVersion** dynViewVersion); + int32_t catalogGetExpiredDBs(SCatalog* pCatalog, SDbCacheInfo** dbs, uint32_t* num); int32_t catalogGetExpiredUsers(SCatalog* pCtg, SUserAuthVersion** users, uint32_t* num); @@ -343,6 +374,16 @@ SMetaData* catalogCloneMetaData(SMetaData* pData); void catalogFreeMetaData(SMetaData* pData); +int32_t catalogRemoveViewMeta(SCatalog* pCtg, const char* dbFName, uint64_t dbId, const char* viewName, uint64_t viewId); + +int32_t catalogUpdateDynViewVer(SCatalog* pCtg, SDynViewVersion* pVer); + +int32_t catalogUpdateViewMeta(SCatalog* pCtg, SViewMetaRsp* pMsg); + +int32_t catalogAsyncUpdateViewMeta(SCatalog* pCtg, SViewMetaRsp* pMsg); + +int32_t catalogGetViewMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pViewName, STableMeta** pTableMeta); + int32_t ctgdEnableDebug(char* option, bool enable); int32_t ctgdHandleDbgCommand(char* command); diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index 2b824c07be..ac4f5bea0e 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -26,7 +26,7 @@ extern "C" { #define DESCRIBE_RESULT_COLS 4 #define DESCRIBE_RESULT_FIELD_LEN (TSDB_COL_NAME_LEN - 1 + VARSTR_HEADER_SIZE) #define DESCRIBE_RESULT_TYPE_LEN (20 + VARSTR_HEADER_SIZE) -#define DESCRIBE_RESULT_NOTE_LEN (8 + VARSTR_HEADER_SIZE) +#define DESCRIBE_RESULT_NOTE_LEN (16 + VARSTR_HEADER_SIZE) #define SHOW_CREATE_DB_RESULT_COLS 2 #define SHOW_CREATE_DB_RESULT_FIELD1_LEN (TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE) @@ -36,6 +36,11 @@ extern "C" { #define SHOW_CREATE_TB_RESULT_FIELD1_LEN (TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE) #define SHOW_CREATE_TB_RESULT_FIELD2_LEN (TSDB_MAX_ALLOWED_SQL_LEN * 3) +#define SHOW_CREATE_VIEW_RESULT_COLS 2 +#define SHOW_CREATE_VIEW_RESULT_FIELD1_LEN (TSDB_VIEW_FNAME_LEN + 4 + VARSTR_HEADER_SIZE) +#define SHOW_CREATE_VIEW_RESULT_FIELD2_LEN (TSDB_MAX_ALLOWED_SQL_LEN + VARSTR_HEADER_SIZE) + + #define SHOW_LOCAL_VARIABLES_RESULT_COLS 3 #define SHOW_LOCAL_VARIABLES_RESULT_FIELD1_LEN (TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE) #define SHOW_LOCAL_VARIABLES_RESULT_FIELD2_LEN (TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE) @@ -51,6 +56,7 @@ extern "C" { #define PRIVILEGE_TYPE_READ BIT_FLAG_MASK(1) #define PRIVILEGE_TYPE_WRITE BIT_FLAG_MASK(2) #define PRIVILEGE_TYPE_SUBSCRIBE BIT_FLAG_MASK(3) +#define PRIVILEGE_TYPE_ALTER BIT_FLAG_MASK(4) typedef struct SDatabaseOptions { ENodeType type; @@ -297,6 +303,13 @@ typedef struct SShowCreateTableStmt { void* pTableCfg; // STableCfg } SShowCreateTableStmt; +typedef struct SShowCreateViewStmt { + ENodeType type; + char dbName[TSDB_DB_NAME_LEN]; + char viewName[TSDB_VIEW_NAME_LEN]; + void* pViewMeta; +} SShowCreateViewStmt; + typedef struct SShowTableDistributedStmt { ENodeType type; char dbName[TSDB_DB_NAME_LEN]; @@ -490,6 +503,23 @@ typedef struct SDropFunctionStmt { bool ignoreNotExists; } SDropFunctionStmt; +typedef struct SCreateViewStmt { + ENodeType type; + char dbName[TSDB_DB_NAME_LEN]; + char viewName[TSDB_VIEW_NAME_LEN]; + char* pQuerySql; + bool orReplace; + SNode* pQuery; + SCMCreateViewReq createReq; +} SCreateViewStmt; + +typedef struct SDropViewStmt { + ENodeType type; + char dbName[TSDB_DB_NAME_LEN]; + char viewName[TSDB_VIEW_NAME_LEN]; + bool ignoreNotExists; +} SDropViewStmt; + typedef struct SGrantStmt { ENodeType type; char userName[TSDB_USER_LEN]; diff --git a/include/libs/nodes/querynodes.h b/include/libs/nodes/querynodes.h index 13f5aeb3fa..19dc8c9e4d 100644 --- a/include/libs/nodes/querynodes.h +++ b/include/libs/nodes/querynodes.h @@ -30,6 +30,11 @@ extern "C" { #define VGROUPS_INFO_SIZE(pInfo) \ (NULL == (pInfo) ? 0 : (sizeof(SVgroupsInfo) + (pInfo)->numOfVgroups * sizeof(SVgroupInfo))) +typedef struct SAssociationNode { + SNode** pPlace; + SNode* pAssociationNode; +} SAssociationNode; + typedef struct SRawExprNode { ENodeType nodeType; char* p; @@ -182,6 +187,16 @@ typedef struct STempTableNode { SNode* pSubquery; } STempTableNode; +typedef struct SViewNode { + STableNode table; // QUERY_NODE_REAL_TABLE + struct STableMeta* pMeta; + SVgroupsInfo* pVgroupList; + char qualDbName[TSDB_DB_NAME_LEN]; // SHOW qualDbName.TABLES + double ratio; + SArray* pSmaIndexes; + int8_t cacheLastMode; +} SViewNode; + typedef enum EJoinType { JOIN_TYPE_INNER = 1, JOIN_TYPE_LEFT, @@ -413,7 +428,8 @@ typedef struct SVgDataBlocks { typedef void (*FFreeTableBlockHash)(SHashObj*); typedef void (*FFreeVgourpBlockArray)(SArray*); - +struct SStbRowsDataContext; +typedef void (*FFreeStbRowsDataContext)(struct SStbRowsDataContext*); typedef struct SVnodeModifyOpStmt { ENodeType nodeType; ENodeType sqlNodeType; @@ -428,11 +444,11 @@ typedef struct SVnodeModifyOpStmt { struct STableMeta* pTableMeta; SNode* pTagCond; SArray* pTableTag; - SHashObj* pVgroupsHashObj; + SHashObj* pVgroupsHashObj; // SHashObj SHashObj* pTableBlockHashObj; // SHashObj - SHashObj* pSubTableHashObj; - SHashObj* pTableNameHashObj; - SHashObj* pDbFNameHashObj; + SHashObj* pSubTableHashObj; // SHashObj + SHashObj* pTableNameHashObj; // set of table names for refreshing meta, sync mode + SHashObj* pDbFNameHashObj; // set of db names for refreshing meta, sync mode SArray* pVgDataBlocks; // SArray SVCreateTbReq* pCreateTblReq; TdFilePtr fp; @@ -440,6 +456,10 @@ typedef struct SVnodeModifyOpStmt { FFreeVgourpBlockArray freeArrayFunc; bool usingTableProcessing; bool fileProcessing; + + bool stbSyntax; + struct SStbRowsDataContext* pStbRowsCxt; + FFreeStbRowsDataContext freeStbRowsCxtFunc; } SVnodeModifyOpStmt; typedef struct SExplainOptions { diff --git a/include/libs/parser/parser.h b/include/libs/parser/parser.h index 4b1af5cc26..177607b178 100644 --- a/include/libs/parser/parser.h +++ b/include/libs/parser/parser.h @@ -22,9 +22,7 @@ extern "C" { #include "query.h" #include "querynodes.h" - -struct SCatalogReq; -struct SMetaData; +#include "catalog.h" typedef struct SStmtCallback { TAOS_STMT* pStmt; @@ -33,6 +31,33 @@ typedef struct SStmtCallback { int32_t (*getExecInfoFn)(TAOS_STMT*, SHashObj**, SHashObj**); } SStmtCallback; +typedef enum { + PARSE_SQL_RES_QUERY = 1, + PARSE_SQL_RES_SCHEMA, +} SParseResType; + +typedef struct SParseSchemaRes { + int8_t precision; + int32_t numOfCols; + SSchema* pSchema; +} SParseSchemaRes; + +typedef struct SParseQueryRes { + SNode* pQuery; + SCatalogReq* pCatalogReq; + SMetaData meta; +} SParseQueryRes; + +typedef struct SParseSqlRes { + SParseResType resType; + union { + SParseSchemaRes schemaRes; + SParseQueryRes queryRes; + }; +} SParseSqlRes; + +typedef int32_t (*parseSqlFn)(void*, const char*, const char*, bool, const char*, SParseSqlRes*); + typedef struct SParseCsvCxt { TdFilePtr fp; // last parsed file int32_t tableNo; // last parsed table @@ -55,6 +80,8 @@ typedef struct SParseContext { struct SCatalog* pCatalog; SStmtCallback* pStmtCb; const char* pUser; + const char* pEffectiveUser; + bool parseOnly; bool isSuperUser; bool enableSysInfo; bool async; @@ -64,7 +91,10 @@ typedef struct SParseContext { SArray* pTableMetaPos; // sql table pos => catalog data pos SArray* pTableVgroupPos; // sql table pos => catalog data pos int64_t allocatorId; + parseSqlFn parseSqlFp; + void* parseSqlParam; int8_t biMode; + SArray* pSubMetaList; } SParseContext; int32_t qParseSql(SParseContext* pCxt, SQuery** pQuery); @@ -125,6 +155,8 @@ int rawBlockBindData(SQuery *query, STableMeta* pTableMeta, void* data, SVCr int32_t rewriteToVnodeModifyOpStmt(SQuery* pQuery, SArray* pBufArray); SArray* serializeVgroupsCreateTableBatch(SHashObj* pVgroupHashmap); SArray* serializeVgroupsDropTableBatch(SHashObj* pVgroupHashmap); +void destoryCatalogReq(SCatalogReq *pCatalogReq); + #ifdef __cplusplus } #endif diff --git a/include/libs/qcom/query.h b/include/libs/qcom/query.h index 71b8badb13..8b5bf1abb1 100644 --- a/include/libs/qcom/query.h +++ b/include/libs/qcom/query.h @@ -119,6 +119,17 @@ typedef struct STableMeta { } STableMeta; #pragma pack(pop) +typedef struct SViewMeta { + uint64_t viewId; + char* user; + char* querySql; + int8_t precision; + int8_t type; + int32_t version; + int32_t numOfCols; + SSchema* pSchema; +} SViewMeta; + typedef struct SDBVgInfo { int32_t vgVersion; int16_t hashPrefix; @@ -148,6 +159,15 @@ typedef struct STableMetaOutput { STableMeta* tbMeta; } STableMetaOutput; +typedef struct SViewMetaOutput { + char name[TSDB_VIEW_NAME_LEN]; + char dbFName[TSDB_DB_FNAME_LEN]; + char* querySql; + int8_t precision; + int32_t numOfCols; + SSchema* pSchema; +} SViewMetaOutput; + typedef struct SDataBuf { int32_t msgType; void* pData; @@ -300,9 +320,11 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t (NO_RET_REDIRECT_ERROR(_code) || SYNC_UNKNOWN_LEADER_REDIRECT_ERROR(_code) || \ SYNC_SELF_LEADER_REDIRECT_ERROR(_code) || SYNC_OTHER_LEADER_REDIRECT_ERROR(_code)) +#define IS_VIEW_REQUEST(_type) ((_type) == TDMT_MND_CREATE_VIEW || (_type) == TDMT_MND_DROP_VIEW) + #define NEED_CLIENT_RM_TBLMETA_REQ(_type) \ ((_type) == TDMT_VND_CREATE_TABLE || (_type) == TDMT_MND_CREATE_STB || (_type) == TDMT_VND_DROP_TABLE || \ - (_type) == TDMT_MND_DROP_STB) + (_type) == TDMT_MND_DROP_STB || (_type) == TDMT_MND_CREATE_VIEW || (_type) == TDMT_MND_DROP_VIEW) #define NEED_SCHEDULER_REDIRECT_ERROR(_code) \ (SYNC_UNKNOWN_LEADER_REDIRECT_ERROR(_code) || SYNC_SELF_LEADER_REDIRECT_ERROR(_code) || \ diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 8748ea99a2..6094dbf635 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -384,15 +384,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_MND_TOO_MANY_STREAMS TAOS_DEF_ERROR_CODE(0, 0x03F6) #define TSDB_CODE_MND_INVALID_TARGET_TABLE TAOS_DEF_ERROR_CODE(0, 0x03F7) -// mnode-sma -#define TSDB_CODE_MND_SMA_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0480) -#define TSDB_CODE_MND_SMA_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0481) -#define TSDB_CODE_MND_INVALID_SMA_OPTION TAOS_DEF_ERROR_CODE(0, 0x0482) -// mnode-tag-indxe - -#define TSDB_CODE_MND_TAG_INDEX_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0483) -#define TSDB_CODE_MND_TAG_INDEX_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0484) // dnode // #define TSDB_CODE_DND_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0400) // 2.x @@ -419,6 +411,22 @@ int32_t* taosGetErrno(); #define TSDB_CODE_MNODE_NO_NEED_RESTORE TAOS_DEF_ERROR_CODE(0, 0x0415) // internal #define TSDB_CODE_DNODE_ONLY_USE_WHEN_OFFLINE TAOS_DEF_ERROR_CODE(0, 0x0416) +// mnode-sma +#define TSDB_CODE_MND_SMA_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0480) +#define TSDB_CODE_MND_SMA_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0481) +#define TSDB_CODE_MND_INVALID_SMA_OPTION TAOS_DEF_ERROR_CODE(0, 0x0482) + +// mnode-tag-indxe + +#define TSDB_CODE_MND_TAG_INDEX_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0483) +#define TSDB_CODE_MND_TAG_INDEX_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0484) + + +// mnode-view +#define TSDB_CODE_MND_VIEW_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x04A0) +#define TSDB_CODE_MND_VIEW_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x04A1) + + // vnode // #define TSDB_CODE_VND_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0500) // 2.x // #define TSDB_CODE_VND_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0501) // 2.x @@ -726,6 +734,9 @@ int32_t* taosGetErrno(); #define TSDB_CODE_PAR_SYSTABLE_NOT_ALLOWED TAOS_DEF_ERROR_CODE(0, 0x2669) #define TSDB_CODE_PAR_INVALID_VARBINARY TAOS_DEF_ERROR_CODE(0, 0x266A) #define TSDB_CODE_PAR_INVALID_IP_RANGE TAOS_DEF_ERROR_CODE(0, 0x266B) +#define TSDB_CODE_PAR_INVALID_VIEW_QUERY TAOS_DEF_ERROR_CODE(0, 0x266C) +#define TSDB_CODE_PAR_COL_QUERY_MISMATCH TAOS_DEF_ERROR_CODE(0, 0x266D) +#define TSDB_CODE_PAR_VIEW_CONFLICT_WITH_TABLE TAOS_DEF_ERROR_CODE(0, 0x266E) #define TSDB_CODE_PAR_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x26FF) //planner diff --git a/include/util/tdef.h b/include/util/tdef.h index e891ac4a2a..1b56b5b623 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -240,6 +240,9 @@ typedef enum ELogicConditionType { #define TSDB_MAX_SQL_SHOW_LEN 1024 #define TSDB_MAX_ALLOWED_SQL_LEN (1 * 1024 * 1024u) // sql length should be less than 1mb +#define TSDB_VIEW_NAME_LEN 193 +#define TSDB_VIEW_FNAME_LEN (TSDB_DB_FNAME_LEN + TSDB_VIEW_NAME_LEN + TSDB_NAME_DELIMITER_LEN) + #define TSDB_APP_NAME_LEN TSDB_UNI_LEN #define TSDB_TB_COMMENT_LEN 1025 diff --git a/source/client/CMakeLists.txt b/source/client/CMakeLists.txt index e45ee9c932..f089247859 100644 --- a/source/client/CMakeLists.txt +++ b/source/client/CMakeLists.txt @@ -1,5 +1,9 @@ aux_source_directory(src CLIENT_SRC) +IF (TD_ENTERPRISE) + LIST(APPEND CLIENT_SRC ${TD_ENTERPRISE_DIR}/src/plugins/view/src/clientView.c) +ENDIF () + if(TD_WINDOWS) add_library(taos SHARED ${CLIENT_SRC} ${CMAKE_CURRENT_SOURCE_DIR}/src/taos.rc.in) else() diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index 9cf3716c19..75003d76d8 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -269,6 +269,7 @@ typedef struct SRequestObj { bool syncQuery; // todo refactor: async query object bool stableQuery; // todo refactor bool validateOnly; // todo refactor + bool parseOnly; bool killed; bool inRetry; bool isSubReq; @@ -279,6 +280,8 @@ typedef struct SRequestObj { void* pPostPlan; SReqRelInfo relation; void* pWrapper; + SMetaData parseMeta; + char* effectiveUser; } SRequestObj; typedef struct SSyncQueryParam { @@ -305,6 +308,8 @@ void taosAsyncQueryImpl(uint64_t connId, const char* sql, __taos_async_fn_t fp, void taosAsyncQueryImplWithReqid(uint64_t connId, const char* sql, __taos_async_fn_t fp, void* param, bool validateOnly, int64_t reqid); void taosAsyncFetchImpl(SRequestObj *pRequest, __taos_async_fn_t fp, void *param); +int32_t clientParseSql(void* param, const char* dbName, const char* sql, bool parseOnly, const char* effectiveUser, SParseSqlRes* pRes); +void syncQueryFn(void* param, void* res, int32_t code); int32_t getVersion1BlockMetaSize(const char* p, int32_t numOfCols); @@ -403,7 +408,7 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData* pResu int32_t refreshMeta(STscObj* pTscObj, SRequestObj* pRequest); int32_t updateQnodeList(SAppInstInfo* pInfo, SArray* pNodeList); void doAsyncQuery(SRequestObj* pRequest, bool forceUpdateMeta); -int32_t removeMeta(STscObj* pTscObj, SArray* tbList); +int32_t removeMeta(STscObj* pTscObj, SArray* tbList, bool isView); int32_t handleAlterTbExecRes(void* res, struct SCatalog* pCatalog); int32_t handleCreateTbExecRes(void* res, SCatalog* pCatalog); bool qnodeRequired(SRequestObj* pRequest); @@ -415,6 +420,11 @@ int32_t buildPreviousRequest(SRequestObj *pRequest, const char* sql, SRequestObj int32_t prepareAndParseSqlSyntax(SSqlCallbackWrapper **ppWrapper, SRequestObj *pRequest, bool updateMetaForce); void returnToUser(SRequestObj* pRequest); void stopAllQueries(SRequestObj *pRequest); +void freeQueryParam(SSyncQueryParam* param); + +#ifdef TD_ENTERPRISE +int32_t clientParseSqlImpl(void* param, const char* dbName, const char* sql, bool parseOnly, const char* effeciveUser, SParseSqlRes* pRes); +#endif #ifdef __cplusplus } diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index 98782f74aa..b36ef20b53 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -447,6 +447,7 @@ void doDestroyRequest(void *p) { qDestroyQuery(pRequest->pQuery); nodesDestroyAllocator(pRequest->allocatorRefId); + taosMemoryFreeClear(pRequest->effectiveUser); taosMemoryFreeClear(pRequest->sqlstr); taosMemoryFree(pRequest); tscTrace("end to destroy request %" PRIx64 " p:%p", reqId, pRequest); diff --git a/source/client/src/clientHb.c b/source/client/src/clientHb.c index dfcca2f36e..1de5941ac3 100644 --- a/source/client/src/clientHb.c +++ b/source/client/src/clientHb.c @@ -53,7 +53,7 @@ static int32_t hbProcessUserAuthInfoRsp(void *value, int32_t valueLen, struct SC int32_t numOfBatchs = taosArrayGetSize(batchRsp.pArray); for (int32_t i = 0; i < numOfBatchs; ++i) { SGetUserAuthRsp *rsp = taosArrayGet(batchRsp.pArray, i); - tscDebug("hb user auth rsp, user:%s, version:%d", rsp->user, rsp->version); + tscDebug("hb to update user auth, user:%s, version:%d", rsp->user, rsp->version); catalogUpdateUserAuthInfo(pCatalog, rsp); } @@ -205,6 +205,7 @@ static int32_t hbProcessDBInfoRsp(void *value, int32_t valueLen, struct SCatalog rsp->useDbRsp->db, rsp->useDbRsp->vgVersion, rsp->useDbRsp->stateTs, rsp->useDbRsp->uid); if (rsp->useDbRsp->vgVersion < 0) { + tscDebug("hb to remove db, db:%s", rsp->useDbRsp->db); code = catalogRemoveDB(pCatalog, rsp->useDbRsp->db, rsp->useDbRsp->uid); } else { SDBVgInfo *vgInfo = NULL; @@ -213,6 +214,8 @@ static int32_t hbProcessDBInfoRsp(void *value, int32_t valueLen, struct SCatalog goto _return; } + tscDebug("hb to update db vgInfo, db:%s", rsp->useDbRsp->db); + catalogUpdateDBVgInfo(pCatalog, rsp->useDbRsp->db, rsp->useDbRsp->uid, vgInfo); if (IS_SYS_DBNAME(rsp->useDbRsp->db)) { @@ -253,10 +256,10 @@ static int32_t hbProcessStbInfoRsp(void *value, int32_t valueLen, struct SCatalo STableMetaRsp *rsp = taosArrayGet(hbRsp.pMetaRsp, i); if (rsp->numOfColumns < 0) { - tscDebug("hb remove stb, db:%s, stb:%s", rsp->dbFName, rsp->stbName); + tscDebug("hb to remove stb, db:%s, stb:%s", rsp->dbFName, rsp->stbName); catalogRemoveStbMeta(pCatalog, rsp->dbFName, rsp->dbId, rsp->stbName, rsp->suid); } else { - tscDebug("hb update stb, db:%s, stb:%s", rsp->dbFName, rsp->stbName); + tscDebug("hb to update stb, db:%s, stb:%s", rsp->dbFName, rsp->stbName); if (rsp->pSchemas[0].colId != PRIMARYKEY_TIMESTAMP_COL_ID) { tscError("invalid colId[%" PRIi16 "] for the first column in table meta rsp msg", rsp->pSchemas[0].colId); tFreeSSTbHbRsp(&hbRsp); @@ -281,6 +284,108 @@ static int32_t hbProcessStbInfoRsp(void *value, int32_t valueLen, struct SCatalo return TSDB_CODE_SUCCESS; } + +static int32_t hbProcessDynViewRsp(void *value, int32_t valueLen, struct SCatalog *pCatalog) { + return catalogUpdateDynViewVer(pCatalog, (SDynViewVersion*)value); +} + +static void hbFreeSViewMetaInRsp(void* p) { + if (NULL == p || NULL == *(void**)p) { + return; + } + SViewMetaRsp *pRsp = *(SViewMetaRsp**)p; + tFreeSViewMetaRsp(pRsp); + taosMemoryFreeClear(pRsp); +} + +static int32_t hbProcessViewInfoRsp(void *value, int32_t valueLen, struct SCatalog *pCatalog) { + int32_t code = 0; + + SViewHbRsp hbRsp = {0}; + if (tDeserializeSViewHbRsp(value, valueLen, &hbRsp) != 0) { + taosArrayDestroyEx(hbRsp.pViewRsp, hbFreeSViewMetaInRsp); + terrno = TSDB_CODE_INVALID_MSG; + return -1; + } + + int32_t numOfMeta = taosArrayGetSize(hbRsp.pViewRsp); + for (int32_t i = 0; i < numOfMeta; ++i) { + SViewMetaRsp *rsp = taosArrayGetP(hbRsp.pViewRsp, i); + + if (rsp->numOfCols < 0) { + tscDebug("hb to remove view, db:%s, view:%s", rsp->dbFName, rsp->name); + catalogRemoveViewMeta(pCatalog, rsp->dbFName, rsp->dbId, rsp->name, rsp->viewId); + tFreeSViewMetaRsp(rsp); + taosMemoryFreeClear(rsp); + } else { + tscDebug("hb to update view, db:%s, view:%s", rsp->dbFName, rsp->name); + catalogUpdateViewMeta(pCatalog, rsp); + } + } + + taosArrayDestroy(hbRsp.pViewRsp); + return TSDB_CODE_SUCCESS; +} + + +static void hbProcessQueryRspKvs(int32_t kvNum, SArray* pKvs, struct SCatalog *pCatalog, SAppHbMgr *pAppHbMgr) { + for (int32_t i = 0; i < kvNum; ++i) { + SKv *kv = taosArrayGet(pKvs, i); + switch (kv->key) { + case HEARTBEAT_KEY_USER_AUTHINFO: { + if (kv->valueLen <= 0 || NULL == kv->value) { + tscError("invalid hb user auth info, len:%d, value:%p", kv->valueLen, kv->value); + break; + } + + hbProcessUserAuthInfoRsp(kv->value, kv->valueLen, pCatalog, pAppHbMgr); + break; + } + case HEARTBEAT_KEY_DBINFO: { + if (kv->valueLen <= 0 || NULL == kv->value) { + tscError("invalid hb db info, len:%d, value:%p", kv->valueLen, kv->value); + break; + } + + hbProcessDBInfoRsp(kv->value, kv->valueLen, pCatalog); + break; + } + case HEARTBEAT_KEY_STBINFO: { + if (kv->valueLen <= 0 || NULL == kv->value) { + tscError("invalid hb stb info, len:%d, value:%p", kv->valueLen, kv->value); + break; + } + + hbProcessStbInfoRsp(kv->value, kv->valueLen, pCatalog); + break; + } +#ifdef TD_ENTERPRISE + case HEARTBEAT_KEY_DYN_VIEW: { + if (kv->valueLen <= 0 || NULL == kv->value) { + tscError("invalid dyn view info, len:%d, value:%p", kv->valueLen, kv->value); + break; + } + + hbProcessDynViewRsp(kv->value, kv->valueLen, pCatalog); + break; + } + case HEARTBEAT_KEY_VIEWINFO: { + if (kv->valueLen <= 0 || NULL == kv->value) { + tscError("invalid view info, len:%d, value:%p", kv->valueLen, kv->value); + break; + } + + hbProcessViewInfoRsp(kv->value, kv->valueLen, pCatalog); + break; + } +#endif + default: + tscError("invalid hb key type:%d", kv->key); + break; + } + } +} + static int32_t hbQueryHbRspHandle(SAppHbMgr *pAppHbMgr, SClientHbRsp *pRsp) { SClientHbReq *pReq = taosHashAcquire(pAppHbMgr->activeInfo, &pRsp->connKey, sizeof(SClientHbKey)); if (NULL == pReq) { @@ -338,66 +443,16 @@ static int32_t hbQueryHbRspHandle(SAppHbMgr *pAppHbMgr, SClientHbRsp *pRsp) { tscDebug("hb got %d rsp kv", kvNum); - for (int32_t i = 0; i < kvNum; ++i) { - SKv *kv = taosArrayGet(pRsp->info, i); - switch (kv->key) { - case HEARTBEAT_KEY_USER_AUTHINFO: { - if (kv->valueLen <= 0 || NULL == kv->value) { - tscError("invalid hb user auth info, len:%d, value:%p", kv->valueLen, kv->value); - break; - } - - struct SCatalog *pCatalog = NULL; - - int32_t code = catalogGetHandle(pReq->clusterId, &pCatalog); - if (code != TSDB_CODE_SUCCESS) { - tscWarn("catalogGetHandle failed, clusterId:%" PRIx64 ", error:%s", pReq->clusterId, tstrerror(code)); - break; - } - - hbProcessUserAuthInfoRsp(kv->value, kv->valueLen, pCatalog, pAppHbMgr); - break; - } - case HEARTBEAT_KEY_DBINFO: { - if (kv->valueLen <= 0 || NULL == kv->value) { - tscError("invalid hb db info, len:%d, value:%p", kv->valueLen, kv->value); - break; - } - - struct SCatalog *pCatalog = NULL; - - int32_t code = catalogGetHandle(pReq->clusterId, &pCatalog); - if (code != TSDB_CODE_SUCCESS) { - tscWarn("catalogGetHandle failed, clusterId:%" PRIx64 ", error:%s", pReq->clusterId, tstrerror(code)); - break; - } - - hbProcessDBInfoRsp(kv->value, kv->valueLen, pCatalog); - break; - } - case HEARTBEAT_KEY_STBINFO: { - if (kv->valueLen <= 0 || NULL == kv->value) { - tscError("invalid hb stb info, len:%d, value:%p", kv->valueLen, kv->value); - break; - } - - struct SCatalog *pCatalog = NULL; - - int32_t code = catalogGetHandle(pReq->clusterId, &pCatalog); - if (code != TSDB_CODE_SUCCESS) { - tscWarn("catalogGetHandle failed, clusterId:%" PRIx64 ", error:%s", pReq->clusterId, tstrerror(code)); - break; - } - - hbProcessStbInfoRsp(kv->value, kv->valueLen, pCatalog); - break; - } - default: - tscError("invalid hb key type:%d", kv->key); - break; + if (kvNum > 0) { + struct SCatalog *pCatalog = NULL; + int32_t code = catalogGetHandle(pReq->clusterId, &pCatalog); + if (code != TSDB_CODE_SUCCESS) { + tscWarn("catalogGetHandle failed, clusterId:%" PRIx64 ", error:%s", pReq->clusterId, tstrerror(code)); + } else { + hbProcessQueryRspKvs(kvNum, pRsp->info, pCatalog, pAppHbMgr); } } - + taosHashRelease(pAppHbMgr->activeInfo, pReq); return TSDB_CODE_SUCCESS; @@ -740,8 +795,8 @@ int32_t hbGetExpiredStbInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, SC for (int32_t i = 0; i < stbNum; ++i) { SSTableVersion *stb = &stbs[i]; stb->suid = htobe64(stb->suid); - stb->sversion = htons(stb->sversion); - stb->tversion = htons(stb->tversion); + stb->sversion = htonl(stb->sversion); + stb->tversion = htonl(stb->tversion); stb->smaVer = htonl(stb->smaVer); } @@ -762,6 +817,56 @@ int32_t hbGetExpiredStbInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, SC return TSDB_CODE_SUCCESS; } +int32_t hbGetExpiredViewInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, SClientHbReq *req) { + SViewVersion *views = NULL; + uint32_t viewNum = 0; + int32_t code = 0; + SDynViewVersion *pDynViewVer = NULL; + + code = catalogGetExpiredViews(pCatalog, &views, &viewNum, &pDynViewVer); + if (TSDB_CODE_SUCCESS != code) { + taosMemoryFree(views); + taosMemoryFree(pDynViewVer); + return code; + } + + if (viewNum <= 0) { + taosMemoryFree(views); + taosMemoryFree(pDynViewVer); + return TSDB_CODE_SUCCESS; + } + + for (int32_t i = 0; i < viewNum; ++i) { + SViewVersion *view = &views[i]; + view->dbId = htobe64(view->dbId); + view->viewId = htobe64(view->viewId); + view->version = htonl(view->version); + } + + tscDebug("hb got %d expired view, valueLen:%lu", viewNum, sizeof(SViewVersion) * viewNum); + + if (NULL == req->info) { + req->info = taosHashInit(64, hbKeyHashFunc, 1, HASH_ENTRY_LOCK); + } + + SKv kv = { + .key = HEARTBEAT_KEY_DYN_VIEW, + .valueLen = sizeof(SDynViewVersion), + .value = pDynViewVer, + }; + + taosHashPut(req->info, &kv.key, sizeof(kv.key), &kv, sizeof(kv)); + + kv.key = HEARTBEAT_KEY_VIEWINFO; + kv.valueLen = sizeof(SViewVersion) * viewNum; + kv.value = views; + + taosHashPut(req->info, &kv.key, sizeof(kv.key), &kv, sizeof(kv)); + + return TSDB_CODE_SUCCESS; +} + + int32_t hbGetAppInfo(int64_t clusterId, SClientHbReq *req) { SAppHbReq *pApp = taosHashGet(clientHbMgr.appSummary, &clusterId, sizeof(clusterId)); if (NULL != pApp) { @@ -781,19 +886,17 @@ int32_t hbQueryHbReqHandle(SClientHbKey *connKey, void *param, SClientHbReq *req SHbParam *hbParam = (SHbParam *)param; SCatalog *pCatalog = NULL; + hbGetQueryBasicInfo(connKey, req); + if (hbParam->reqCnt == 0) { code = catalogGetHandle(hbParam->clusterId, &pCatalog); if (code != TSDB_CODE_SUCCESS) { tscWarn("catalogGetHandle failed, clusterId:%" PRIx64 ", error:%s", hbParam->clusterId, tstrerror(code)); return code; } - } - hbGetAppInfo(hbParam->clusterId, req); + hbGetAppInfo(hbParam->clusterId, req); - hbGetQueryBasicInfo(connKey, req); - - if (hbParam->reqCnt == 0) { if (!taosHashGet(clientHbMgr.appHbHash, &hbParam->clusterId, sizeof(hbParam->clusterId))) { code = hbGetExpiredUserInfo(connKey, pCatalog, req); if (TSDB_CODE_SUCCESS != code) { @@ -819,6 +922,15 @@ int32_t hbQueryHbReqHandle(SClientHbKey *connKey, void *param, SClientHbReq *req if (TSDB_CODE_SUCCESS != code) { return code; } + +#ifdef TD_ENTERPRISE + code = hbGetExpiredViewInfo(connKey, pCatalog, req); + if (TSDB_CODE_SUCCESS != code) { + return code; + } +#endif + } else { + req->app.appId = 0; } ++hbParam->reqCnt; // success to get catalog info diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 5684411646..395a396d89 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -1009,7 +1009,7 @@ void schedulerExecCb(SExecResult* pResult, void* param, int32_t code) { tscDebug("schedulerExecCb request type %s", TMSG_INFO(pRequest->type)); if (NEED_CLIENT_RM_TBLMETA_REQ(pRequest->type) && NULL == pRequest->body.resInfo.execRes.res) { - removeMeta(pTscObj, pRequest->targetTableList); + removeMeta(pTscObj, pRequest->targetTableList, IS_VIEW_REQUEST(pRequest->type)); } pRequest->metric.execCostUs = taosGetTimestampUs() - pRequest->metric.execStart; @@ -1097,7 +1097,7 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, bool keepQue } if (NEED_CLIENT_RM_TBLMETA_REQ(pRequest->type) && NULL == pRequest->body.resInfo.execRes.res) { - removeMeta(pRequest->pTscObj, pRequest->targetTableList); + removeMeta(pRequest->pTscObj, pRequest->targetTableList, IS_VIEW_REQUEST(pRequest->type)); } handleQueryExecRsp(pRequest); @@ -1116,31 +1116,34 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, bool keepQue static int32_t asyncExecSchQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData* pResultMeta, SSqlCallbackWrapper* pWrapper) { + int32_t code = TSDB_CODE_SUCCESS; pRequest->type = pQuery->msgType; - - SArray* pMnodeList = taosArrayInit(4, sizeof(SQueryNodeLoad)); - - SPlanContext cxt = {.queryId = pRequest->requestId, - .acctId = pRequest->pTscObj->acctId, - .mgmtEpSet = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp), - .pAstRoot = pQuery->pRoot, - .showRewrite = pQuery->showRewrite, - .pMsg = pRequest->msgBuf, - .msgLen = ERROR_MSG_BUF_DEFAULT_SIZE, - .pUser = pRequest->pTscObj->user, - .sysInfo = pRequest->pTscObj->sysInfo, - .allocatorId = pRequest->allocatorRefId}; - - SQueryPlan* pDag = NULL; - + SArray* pMnodeList = NULL; + SQueryPlan* pDag = NULL; int64_t st = taosGetTimestampUs(); - int32_t code = qCreateQueryPlan(&cxt, &pDag, pMnodeList); - if (code) { - tscError("0x%" PRIx64 " failed to create query plan, code:%s 0x%" PRIx64, pRequest->self, tstrerror(code), - pRequest->requestId); - } else { - pRequest->body.subplanNum = pDag->numOfSubplans; - TSWAP(pRequest->pPostPlan, pDag->pPostPlan); + + if (!pRequest->parseOnly) { + pMnodeList = taosArrayInit(4, sizeof(SQueryNodeLoad)); + + SPlanContext cxt = {.queryId = pRequest->requestId, + .acctId = pRequest->pTscObj->acctId, + .mgmtEpSet = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp), + .pAstRoot = pQuery->pRoot, + .showRewrite = pQuery->showRewrite, + .pMsg = pRequest->msgBuf, + .msgLen = ERROR_MSG_BUF_DEFAULT_SIZE, + .pUser = pRequest->pTscObj->user, + .sysInfo = pRequest->pTscObj->sysInfo, + .allocatorId = pRequest->allocatorRefId}; + + code = qCreateQueryPlan(&cxt, &pDag, pMnodeList); + if (code) { + tscError("0x%" PRIx64 " failed to create query plan, code:%s 0x%" PRIx64, pRequest->self, tstrerror(code), + pRequest->requestId); + } else { + pRequest->body.subplanNum = pDag->numOfSubplans; + TSWAP(pRequest->pPostPlan, pDag->pPostPlan); + } } pRequest->metric.execStart = taosGetTimestampUs(); @@ -1173,6 +1176,7 @@ static int32_t asyncExecSchQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaDat code = schedulerExecJob(&req, &pRequest->body.queryJob); taosArrayDestroy(pNodeList); } else { + qDestroyQueryPlan(pDag); tscDebug("0x%" PRIx64 " plan not executed, code:%s 0x%" PRIx64, pRequest->self, tstrerror(code), pRequest->requestId); destorySqlCallbackWrapper(pWrapper); @@ -1193,6 +1197,11 @@ static int32_t asyncExecSchQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaDat void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData* pResultMeta, SSqlCallbackWrapper* pWrapper) { int32_t code = 0; + if (pRequest->parseOnly) { + pRequest->body.queryFp(pRequest->body.param, pRequest, 0); + return; + } + pRequest->body.execMode = pQuery->execMode; if (QUERY_EXEC_MODE_SCHEDULE != pRequest->body.execMode) { destorySqlCallbackWrapper(pWrapper); @@ -1226,6 +1235,7 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData* pResultM pRequest->body.queryFp(pRequest->body.param, pRequest, 0); break; default: + tscError("0x%" PRIx64 " invalid execMode %d", pRequest->self, pQuery->execMode); pRequest->body.queryFp(pRequest->body.param, pRequest, -1); break; } @@ -1272,7 +1282,7 @@ int32_t refreshMeta(STscObj* pTscObj, SRequestObj* pRequest) { return code; } -int32_t removeMeta(STscObj* pTscObj, SArray* tbList) { +int32_t removeMeta(STscObj* pTscObj, SArray* tbList, bool isView) { SCatalog* pCatalog = NULL; int32_t tbNum = taosArrayGetSize(tbList); int32_t code = catalogGetHandle(pTscObj->pAppInfo->clusterId, &pCatalog); @@ -1280,9 +1290,18 @@ int32_t removeMeta(STscObj* pTscObj, SArray* tbList) { return code; } - for (int32_t i = 0; i < tbNum; ++i) { - SName* pTbName = taosArrayGet(tbList, i); - catalogRemoveTableMeta(pCatalog, pTbName); + if (isView) { + for (int32_t i = 0; i < tbNum; ++i) { + SName* pViewName = taosArrayGet(tbList, i); + char dbFName[TSDB_DB_FNAME_LEN]; + tNameGetFullDbName(pViewName, dbFName); + catalogRemoveViewMeta(pCatalog, dbFName, 0, pViewName->tname, 0); + } + } else { + for (int32_t i = 0; i < tbNum; ++i) { + SName* pTbName = taosArrayGet(tbList, i); + catalogRemoveTableMeta(pCatalog, pTbName); + } } return TSDB_CODE_SUCCESS; @@ -2604,3 +2623,13 @@ void taosAsyncFetchImpl(SRequestObj* pRequest, __taos_async_fn_t fp, void* param schedulerFetchRows(pRequest->body.queryJob, &req); } + +int32_t clientParseSql(void* param, const char* dbName, const char* sql, bool parseOnly, const char* effectiveUser, SParseSqlRes* pRes) { +#ifndef TD_ENTERPRISE + return TSDB_CODE_SUCCESS; +#else + return clientParseSqlImpl(param, dbName, sql, parseOnly, effectiveUser, pRes); +#endif +} + + diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index 5b8c54f1d6..2091bcf64f 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -32,7 +32,7 @@ #define TSC_VAR_RELEASED 0 static int32_t sentinel = TSC_VAR_NOT_RELEASE; -static int32_t createParseContext(const SRequestObj *pRequest, SParseContext **pCxt); +static int32_t createParseContext(const SRequestObj *pRequest, SParseContext **pCxt, SSqlCallbackWrapper *pWrapper); int taos_options(TSDB_OPTION option, const void *arg, ...) { static int32_t lock = 0; @@ -879,39 +879,12 @@ int taos_get_current_db(TAOS *taos, char *database, int len, int *required) { return code; } -static void destoryTablesReq(void *p) { - STablesReq *pRes = (STablesReq *)p; - taosArrayDestroy(pRes->pTables); -} - -static void destoryCatalogReq(SCatalogReq *pCatalogReq) { - if (NULL == pCatalogReq) { - return; - } - taosArrayDestroy(pCatalogReq->pDbVgroup); - taosArrayDestroy(pCatalogReq->pDbCfg); - taosArrayDestroy(pCatalogReq->pDbInfo); - if (pCatalogReq->cloned) { - taosArrayDestroy(pCatalogReq->pTableMeta); - taosArrayDestroy(pCatalogReq->pTableHash); - } else { - taosArrayDestroyEx(pCatalogReq->pTableMeta, destoryTablesReq); - taosArrayDestroyEx(pCatalogReq->pTableHash, destoryTablesReq); - } - taosArrayDestroy(pCatalogReq->pUdf); - taosArrayDestroy(pCatalogReq->pIndex); - taosArrayDestroy(pCatalogReq->pUser); - taosArrayDestroy(pCatalogReq->pTableIndex); - taosArrayDestroy(pCatalogReq->pTableCfg); - taosArrayDestroy(pCatalogReq->pTableTag); - taosMemoryFree(pCatalogReq); -} - void destorySqlCallbackWrapper(SSqlCallbackWrapper *pWrapper) { if (NULL == pWrapper) { return; } destoryCatalogReq(pWrapper->pCatalogReq); + taosMemoryFree(pWrapper->pCatalogReq); qDestroyParseContext(pWrapper->pParseCtx); taosMemoryFree(pWrapper); } @@ -933,6 +906,7 @@ static void doAsyncQueryFromAnalyse(SMetaData *pResultMeta, void *param, int32_t int64_t analyseStart = taosGetTimestampUs(); pRequest->metric.ctgCostUs = analyseStart - pRequest->metric.ctgStart; + pWrapper->pParseCtx->parseOnly = pRequest->parseOnly; if (TSDB_CODE_SUCCESS == code) { code = qAnalyseSqlSemantic(pWrapper->pParseCtx, pWrapper->pCatalogReq, pResultMeta, pQuery); @@ -940,6 +914,11 @@ static void doAsyncQueryFromAnalyse(SMetaData *pResultMeta, void *param, int32_t pRequest->metric.analyseCostUs += taosGetTimestampUs() - analyseStart; + if (pRequest->parseOnly) { + memcpy(&pRequest->parseMeta, pResultMeta, sizeof(*pResultMeta)); + memset(pResultMeta, 0, sizeof(*pResultMeta)); + } + handleQueryAnslyseRes(pWrapper, pResultMeta, code); } @@ -960,6 +939,7 @@ int32_t cloneCatalogReq(SCatalogReq **ppTarget, SCatalogReq *pSrc) { pTarget->pTableIndex = taosArrayDup(pSrc->pTableIndex, NULL); pTarget->pTableCfg = taosArrayDup(pSrc->pTableCfg, NULL); pTarget->pTableTag = taosArrayDup(pSrc->pTableTag, NULL); + pTarget->pView = taosArrayDup(pSrc->pView, NULL); pTarget->qNodeRequired = pSrc->qNodeRequired; pTarget->dNodeRequired = pSrc->dNodeRequired; pTarget->svrVerRequired = pSrc->svrVerRequired; @@ -1147,7 +1127,7 @@ void taos_query_a_with_reqid(TAOS *taos, const char *sql, __taos_async_fn_t fp, taosAsyncQueryImplWithReqid(connId, sql, fp, param, false, reqid); } -int32_t createParseContext(const SRequestObj *pRequest, SParseContext **pCxt) { +int32_t createParseContext(const SRequestObj *pRequest, SParseContext **pCxt, SSqlCallbackWrapper *pWrapper) { const STscObj *pTscObj = pRequest->pTscObj; *pCxt = taosMemoryCalloc(1, sizeof(SParseContext)); @@ -1167,12 +1147,15 @@ int32_t createParseContext(const SRequestObj *pRequest, SParseContext **pCxt) { .pTransporter = pTscObj->pAppInfo->pTransporter, .pStmtCb = NULL, .pUser = pTscObj->user, + .pEffectiveUser = pRequest->effectiveUser, .isSuperUser = (0 == strcmp(pTscObj->user, TSDB_DEFAULT_USER)), .enableSysInfo = pTscObj->sysInfo, .async = true, .svrVer = pTscObj->sVer, .nodeOffline = (pTscObj->pAppInfo->onlineDnodes < pTscObj->pAppInfo->totalDnodes), - .allocatorId = pRequest->allocatorRefId}; + .allocatorId = pRequest->allocatorRefId, + .parseSqlFp = clientParseSql, + .parseSqlParam = pWrapper}; int8_t biMode = atomic_load_8(&((STscObj *)pTscObj)->biMode); (*pCxt)->biMode = biMode; return TSDB_CODE_SUCCESS; @@ -1191,7 +1174,7 @@ int32_t prepareAndParseSqlSyntax(SSqlCallbackWrapper **ppWrapper, SRequestObj *p } if (TSDB_CODE_SUCCESS == code) { - code = createParseContext(pRequest, &pWrapper->pParseCtx); + code = createParseContext(pRequest, &pWrapper->pParseCtx, pWrapper); } if (TSDB_CODE_SUCCESS == code) { @@ -1570,7 +1553,7 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) { tsem_wait(&pParam->sem); _return: - taosArrayDestroyEx(catalogReq.pTableMeta, destoryTablesReq); + destoryCatalogReq(&catalogReq); destroyRequest(pRequest); return code; } @@ -1860,4 +1843,4 @@ int taos_set_conn_mode(TAOS* taos, int mode, int value) { return TSDB_CODE_INVALID_PARA; } return 0; -} \ No newline at end of file +} diff --git a/source/client/src/clientMsgHandler.c b/source/client/src/clientMsgHandler.c index 8027a61b8f..693efbc364 100644 --- a/source/client/src/clientMsgHandler.c +++ b/source/client/src/clientMsgHandler.c @@ -35,7 +35,7 @@ int32_t genericRspCallback(void* param, SDataBuf* pMsg, int32_t code) { setErrno(pRequest, code); if (NEED_CLIENT_RM_TBLMETA_REQ(pRequest->type)) { - removeMeta(pRequest->pTscObj, pRequest->targetTableList); + removeMeta(pRequest->pTscObj, pRequest->targetTableList, IS_VIEW_REQUEST(pRequest->type)); } taosMemoryFree(pMsg->pEpSet); diff --git a/source/client/src/clientRawBlockWrite.c b/source/client/src/clientRawBlockWrite.c index a12dc8d839..03cd19fa40 100644 --- a/source/client/src/clientRawBlockWrite.c +++ b/source/client/src/clientRawBlockWrite.c @@ -15,15 +15,14 @@ #include "cJSON.h" #include "clientInt.h" -#include "clientLog.h" #include "parser.h" #include "tdatablock.h" #include "tdef.h" #include "tglobal.h" #include "tmsgtype.h" -#include "tqueue.h" -#include "tref.h" -#include "ttimer.h" + +#define LOG_ID_TAG "connId:0x%"PRIx64",reqId:0x%"PRIx64 +#define LOG_ID_VALUE *(int64_t*)taos,pRequest->requestId static tb_uid_t processSuid(tb_uid_t suid, char* db) { return suid + MurmurHash3_32(db, strlen(db)); } @@ -32,6 +31,7 @@ static char* buildCreateTableJson(SSchemaWrapper* schemaRow, SSchemaWrapper* sch char* string = NULL; cJSON* json = cJSON_CreateObject(); if (json == NULL) { + uError("create json object failed") return NULL; } cJSON* type = cJSON_CreateString("create"); @@ -106,6 +106,7 @@ static char* buildAlterSTableJson(void* alterData, int32_t alterDataLen) { json = cJSON_CreateObject(); if (json == NULL) { + uError("create json object failed"); goto end; } cJSON* type = cJSON_CreateString("alter"); @@ -181,7 +182,7 @@ static char* buildAlterSTableJson(void* alterData, int32_t alterDataLen) { } string = cJSON_PrintUnformatted(json); -end: + end: cJSON_Delete(json); tFreeSMAltertbReq(&req); return string; @@ -192,7 +193,7 @@ static char* processCreateStb(SMqMetaRsp* metaRsp) { SDecoder coder; char* string = NULL; - uDebug("processCreateStb called"); + uDebug("create stable data:%p", metaRsp); // decode and process req void* data = POINTER_SHIFT(metaRsp->metaRsp, sizeof(SMsgHead)); int32_t len = metaRsp->metaRspLen - sizeof(SMsgHead); @@ -202,8 +203,8 @@ static char* processCreateStb(SMqMetaRsp* metaRsp) { goto _err; } string = buildCreateTableJson(&req.schemaRow, &req.schemaTag, req.name, req.suid, TSDB_SUPER_TABLE); - uDebug("processCreateStb %s", string); -_err: + _err: + uDebug("create stable return, sql json:%s", string); tDecoderClear(&coder); return string; } @@ -212,7 +213,7 @@ static char* processAlterStb(SMqMetaRsp* metaRsp) { SVCreateStbReq req = {0}; SDecoder coder; char* string = NULL; - uDebug("processAlterStb called"); + uDebug("alter stable data:%p", metaRsp); // decode and process req void* data = POINTER_SHIFT(metaRsp->metaRsp, sizeof(SMsgHead)); @@ -223,9 +224,8 @@ static char* processAlterStb(SMqMetaRsp* metaRsp) { goto _err; } string = buildAlterSTableJson(req.alterOriData, req.alterOriDataLen); - uDebug("processAlterStb %s", string); - -_err: + _err: + uDebug("alter stable return, sql json:%s", string); tDecoderClear(&coder); return string; } @@ -251,12 +251,14 @@ static void buildChildElement(cJSON* json, SVCreateTbReq* pCreateReq) { SArray* pTagVals = NULL; int32_t code = tTagToValArray(pTag, &pTagVals); if (code) { + uError("tTagToValArray failed code:%d", code); goto end; } if (tTagIsJson(pTag)) { STag* p = (STag*)pTag; if (p->nTag == 0) { + uError("p->nTag == 0"); goto end; } char* pJson = parseTagDatatoJson(pTag); @@ -313,7 +315,7 @@ static void buildChildElement(cJSON* json, SVCreateTbReq* pCreateReq) { cJSON_AddItemToArray(tags, tag); } -end: + end: cJSON_AddItemToObject(json, "tags", tags); taosArrayDestroy(pTagVals); } @@ -322,6 +324,7 @@ static char* buildCreateCTableJson(SVCreateTbReq* pCreateReq, int32_t nReqs) { char* string = NULL; cJSON* json = cJSON_CreateObject(); if (json == NULL) { + uError("create json object failed"); return NULL; } cJSON* type = cJSON_CreateString("create"); @@ -353,7 +356,7 @@ static char* processCreateTable(SMqMetaRsp* metaRsp) { SVCreateTbReq* pCreateReq; char* string = NULL; // decode - uDebug("processCreateTable called"); + uDebug("create table data:%p", metaRsp); void* data = POINTER_SHIFT(metaRsp->metaRsp, sizeof(SMsgHead)); int32_t len = metaRsp->metaRspLen - sizeof(SMsgHead); tDecoderInit(&decoder, data, len); @@ -370,10 +373,10 @@ static char* processCreateTable(SMqMetaRsp* metaRsp) { string = buildCreateTableJson(&pCreateReq->ntb.schemaRow, NULL, pCreateReq->name, pCreateReq->uid, TSDB_NORMAL_TABLE); } - uDebug("processCreateTable :%s", string); } -_exit: + _exit: + uDebug("create table return, sql json:%s", string); for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { pCreateReq = req.pReqs + iReq; taosMemoryFreeClear(pCreateReq->comment); @@ -387,9 +390,9 @@ _exit: } static char* processAutoCreateTable(STaosxRsp* rsp) { - uDebug("processAutoCreateTable called"); + uDebug("auto create table data:%p", rsp); if (rsp->createTableNum <= 0) { - uError("WriteRaw:processAutoCreateTable rsp->createTableNum <= 0"); + uError("processAutoCreateTable rsp->createTableNum <= 0"); goto _exit; } @@ -408,13 +411,13 @@ static char* processAutoCreateTable(STaosxRsp* rsp) { } if (pCreateReq[iReq].type != TSDB_CHILD_TABLE) { - uError("WriteRaw:processAutoCreateTable pCreateReq[iReq].type != TSDB_CHILD_TABLE"); + uError("processAutoCreateTable pCreateReq[iReq].type != TSDB_CHILD_TABLE"); goto _exit; } } string = buildCreateCTableJson(pCreateReq, rsp->createTableNum); - uDebug("processAutoCreateTable :%s", string); -_exit: + _exit: + uDebug("auto created table return, sql json:%s", string); for (int i = 0; i < rsp->createTableNum; i++) { tDecoderClear(&decoder[i]); taosMemoryFreeClear(pCreateReq[i].comment); @@ -433,17 +436,19 @@ static char* processAlterTable(SMqMetaRsp* metaRsp) { char* string = NULL; cJSON* json = NULL; - uDebug("processAlterTable called"); + uDebug("alter table data:%p", metaRsp); // decode void* data = POINTER_SHIFT(metaRsp->metaRsp, sizeof(SMsgHead)); int32_t len = metaRsp->metaRspLen - sizeof(SMsgHead); tDecoderInit(&decoder, data, len); if (tDecodeSVAlterTbReq(&decoder, &vAlterTbReq) < 0) { + uError("tDecodeSVAlterTbReq error"); goto _exit; } json = cJSON_CreateObject(); if (json == NULL) { + uError("create json object failed"); goto _exit; } cJSON* type = cJSON_CreateString("alter"); @@ -543,9 +548,9 @@ static char* processAlterTable(SMqMetaRsp* metaRsp) { break; } string = cJSON_PrintUnformatted(json); - uDebug("processAlterTable :%s", string); -_exit: + _exit: + uDebug("alter table return, sql json:%s", string); cJSON_Delete(json); tDecoderClear(&decoder); return string; @@ -556,18 +561,20 @@ static char* processDropSTable(SMqMetaRsp* metaRsp) { SVDropStbReq req = {0}; char* string = NULL; cJSON* json = NULL; - uDebug("processDropSTable called"); + uDebug("processDropSTable data:%p", metaRsp); // decode void* data = POINTER_SHIFT(metaRsp->metaRsp, sizeof(SMsgHead)); int32_t len = metaRsp->metaRspLen - sizeof(SMsgHead); tDecoderInit(&decoder, data, len); if (tDecodeSVDropStbReq(&decoder, &req) < 0) { + uError("tDecodeSVDropStbReq failed"); goto _exit; } json = cJSON_CreateObject(); if (json == NULL) { + uError("create json object failed"); goto _exit; } cJSON* type = cJSON_CreateString("drop"); @@ -578,8 +585,8 @@ static char* processDropSTable(SMqMetaRsp* metaRsp) { cJSON_AddItemToObject(json, "tableName", tableName); string = cJSON_PrintUnformatted(json); - uDebug("processDropSTable :%s", string); -_exit: + _exit: + uDebug("processDropSTable return, sql json:%s", string); cJSON_Delete(json); tDecoderClear(&decoder); return string; @@ -587,18 +594,17 @@ _exit: static char* processDeleteTable(SMqMetaRsp* metaRsp) { SDeleteRes req = {0}; SDecoder coder = {0}; - int32_t code = TSDB_CODE_SUCCESS; cJSON* json = NULL; char* string = NULL; - uDebug("processDeleteTable called"); + uDebug("processDeleteTable data:%p", metaRsp); // decode and process req void* data = POINTER_SHIFT(metaRsp->metaRsp, sizeof(SMsgHead)); int32_t len = metaRsp->metaRspLen - sizeof(SMsgHead); tDecoderInit(&coder, data, len); if (tDecodeDeleteRes(&coder, &req) < 0) { - code = TSDB_CODE_INVALID_PARA; + uError("tDecodeDeleteRes failed"); goto _exit; } @@ -606,10 +612,10 @@ static char* processDeleteTable(SMqMetaRsp* metaRsp) { char sql[256] = {0}; snprintf(sql, sizeof(sql), "delete from `%s` where `%s` >= %" PRId64 " and `%s` <= %" PRId64, req.tableFName, req.tsColName, req.skey, req.tsColName, req.ekey); - uDebug("delete sql:%s\n", sql); json = cJSON_CreateObject(); if (json == NULL) { + uError("creaet json object failed"); goto _exit; } cJSON* type = cJSON_CreateString("delete"); @@ -618,8 +624,8 @@ static char* processDeleteTable(SMqMetaRsp* metaRsp) { cJSON_AddItemToObject(json, "sql", sqlJson); string = cJSON_PrintUnformatted(json); - uDebug("processDeleteTable :%s", string); -_exit: + _exit: + uDebug("processDeleteTable return, sql json:%s", string); cJSON_Delete(json); tDecoderClear(&coder); return string; @@ -631,17 +637,19 @@ static char* processDropTable(SMqMetaRsp* metaRsp) { char* string = NULL; cJSON* json = NULL; - uDebug("processDropTable called"); + uDebug("processDropTable data:%p", metaRsp); // decode void* data = POINTER_SHIFT(metaRsp->metaRsp, sizeof(SMsgHead)); int32_t len = metaRsp->metaRspLen - sizeof(SMsgHead); tDecoderInit(&decoder, data, len); if (tDecodeSVDropTbBatchReq(&decoder, &req) < 0) { + uError("tDecodeSVDropTbBatchReq failed"); goto _exit; } json = cJSON_CreateObject(); if (json == NULL) { + uError("create json object failed"); goto _exit; } cJSON* type = cJSON_CreateString("drop"); @@ -661,26 +669,30 @@ static char* processDropTable(SMqMetaRsp* metaRsp) { cJSON_AddItemToObject(json, "tableNameList", tableNameList); string = cJSON_PrintUnformatted(json); - uDebug("processDropTable :%s", string); -_exit: + _exit: + uDebug("processDropTable return, json sql:%s", string); cJSON_Delete(json); tDecoderClear(&decoder); return string; } static int32_t taosCreateStb(TAOS* taos, void* meta, int32_t metaLen) { + if(taos == NULL || meta == NULL) { + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } SVCreateStbReq req = {0}; SDecoder coder; SMCreateStbReq pReq = {0}; int32_t code = TSDB_CODE_SUCCESS; SRequestObj* pRequest = NULL; - uDebug("taosCreateStb called"); code = buildRequest(*(int64_t*)taos, "", 0, NULL, false, &pRequest, 0); if (code != TSDB_CODE_SUCCESS) { - goto end; + terrno = code; + return code; } - + uDebug(LOG_ID_TAG" create stable, meta:%p, metaLen:%d", LOG_ID_VALUE, meta, metaLen); pRequest->syncQuery = true; if (!pRequest->pDb) { code = TSDB_CODE_PAR_DB_NOT_SPECIFIED; @@ -719,7 +731,8 @@ static int32_t taosCreateStb(TAOS* taos, void* meta, int32_t metaLen) { pReq.source = TD_REQ_FROM_TAOX; pReq.igExists = true; - uDebug("taosCreateStb name:%s suid:%" PRId64 " processSuid:%" PRId64, req.name, req.suid, pReq.suid); + uDebug(LOG_ID_TAG" create stable name:%s suid:%" PRId64 " processSuid:%" PRId64, + LOG_ID_VALUE, req.name, req.suid, pReq.suid); STscObj* pTscObj = pRequest->pTscObj; SName tableName; tNameExtractFullName(toName(pTscObj->acctId, pRequest->pDb, req.name, &tableName), pReq.name); @@ -752,26 +765,33 @@ static int32_t taosCreateStb(TAOS* taos, void* meta, int32_t metaLen) { code = pRequest->code; taosMemoryFree(pCmdMsg.pMsg); -end: + end: + uDebug(LOG_ID_TAG" create stable return, msg:%s", LOG_ID_VALUE, tstrerror(code)); destroyRequest(pRequest); tFreeSMCreateStbReq(&pReq); tDecoderClear(&coder); + terrno = code; return code; } static int32_t taosDropStb(TAOS* taos, void* meta, int32_t metaLen) { + if(taos == NULL || meta == NULL) { + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } SVDropStbReq req = {0}; SDecoder coder = {0}; SMDropStbReq pReq = {0}; int32_t code = TSDB_CODE_SUCCESS; SRequestObj* pRequest = NULL; - uDebug("taosDropStb called"); code = buildRequest(*(int64_t*)taos, "", 0, NULL, false, &pRequest, 0); if (code != TSDB_CODE_SUCCESS) { - goto end; + terrno = code; + return code; } + uDebug(LOG_ID_TAG" drop stable, meta:%p, metaLen:%d", LOG_ID_VALUE, meta, metaLen); pRequest->syncQuery = true; if (!pRequest->pDb) { code = TSDB_CODE_PAR_DB_NOT_SPECIFIED; @@ -792,9 +812,9 @@ static int32_t taosDropStb(TAOS* taos, void* meta, int32_t metaLen) { goto end; } SRequestConnInfo conn = {.pTrans = pRequest->pTscObj->pAppInfo->pTransporter, - .requestId = pRequest->requestId, - .requestObjRefId = pRequest->self, - .mgmtEps = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp)}; + .requestId = pRequest->requestId, + .requestObjRefId = pRequest->self, + .mgmtEps = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp)}; SName pName = {0}; toName(pRequest->pTscObj->acctId, pRequest->pDb, req.name, &pName); STableMeta* pTableMeta = NULL; @@ -805,7 +825,6 @@ static int32_t taosDropStb(TAOS* taos, void* meta, int32_t metaLen) { goto end; } if (code != TSDB_CODE_SUCCESS) { - uError("taosCreateTable:catalogGetTableMeta failed. table name: %s", req.name); goto end; } pReq.suid = pTableMeta->uid; @@ -816,7 +835,8 @@ static int32_t taosDropStb(TAOS* taos, void* meta, int32_t metaLen) { pReq.source = TD_REQ_FROM_TAOX; // pReq.suid = processSuid(req.suid, pRequest->pDb); - uDebug("taosDropStb name:%s suid:%" PRId64 " new suid:%" PRId64, req.name, req.suid, pReq.suid); + uDebug(LOG_ID_TAG" drop stable name:%s suid:%" PRId64 " new suid:%" PRId64, + LOG_ID_VALUE, req.name, req.suid, pReq.suid); STscObj* pTscObj = pRequest->pTscObj; SName tableName = {0}; tNameExtractFullName(toName(pTscObj->acctId, pRequest->pDb, req.name, &tableName), pReq.name); @@ -849,9 +869,11 @@ static int32_t taosDropStb(TAOS* taos, void* meta, int32_t metaLen) { code = pRequest->code; taosMemoryFree(pCmdMsg.pMsg); -end: + end: + uDebug(LOG_ID_TAG" drop stable return, msg:%s", LOG_ID_VALUE, tstrerror(code)); destroyRequest(pRequest); tDecoderClear(&coder); + terrno = code; return code; } @@ -867,6 +889,10 @@ static void destroyCreateTbReqBatch(void* data) { } static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) { + if(taos == NULL || meta == NULL) { + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } SVCreateTbBatchReq req = {0}; SDecoder coder = {0}; int32_t code = TSDB_CODE_SUCCESS; @@ -874,12 +900,14 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) { SQuery* pQuery = NULL; SHashObj* pVgroupHashmap = NULL; - uDebug("taosCreateTable called"); code = buildRequest(*(int64_t*)taos, "", 0, NULL, false, &pRequest, 0); if (code != TSDB_CODE_SUCCESS) { - goto end; + terrno = code; + return code; } + uDebug(LOG_ID_TAG " create table, meta:%p, metaLen:%d", LOG_ID_VALUE, meta, metaLen); + pRequest->syncQuery = true; if (!pRequest->pDb) { code = TSDB_CODE_PAR_DB_NOT_SPECIFIED; @@ -911,9 +939,9 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) { taosHashSetFreeFp(pVgroupHashmap, destroyCreateTbReqBatch); SRequestConnInfo conn = {.pTrans = pTscObj->pAppInfo->pTransporter, - .requestId = pRequest->requestId, - .requestObjRefId = pRequest->self, - .mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)}; + .requestId = pRequest->requestId, + .requestObjRefId = pRequest->self, + .mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)}; pRequest->tableList = taosArrayInit(req.nReqs, sizeof(SName)); // loop to create table @@ -939,12 +967,9 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) { toName(pTscObj->acctId, pRequest->pDb, pCreateReq->ctb.stbName, &sName); code = catalogGetTableMeta(pCatalog, &conn, &sName, &pTableMeta); if (code != TSDB_CODE_SUCCESS) { - uError("taosCreateTable:catalogGetTableMeta failed. table name: %s", pCreateReq->ctb.stbName); goto end; } pCreateReq->ctb.suid = pTableMeta->uid; - uDebug("taosCreateTable name:%s sname:%s suid:%" PRId64 " new suid:%" PRId64, pCreateReq->name, - pCreateReq->ctb.stbName, oldSuid, pCreateReq->ctb.suid); for (int32_t i = 0; i < taosArrayGetSize(pCreateReq->ctb.tagName); i++) { char* tName = taosArrayGet(pCreateReq->ctb.tagName, i); @@ -993,12 +1018,13 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) { launchQueryImpl(pRequest, pQuery, true, NULL); if (pRequest->code == TSDB_CODE_SUCCESS) { - removeMeta(pTscObj, pRequest->tableList); + removeMeta(pTscObj, pRequest->tableList, false); } code = pRequest->code; -end: + end: + uDebug(LOG_ID_TAG" create table return, msg:%s", LOG_ID_VALUE, tstrerror(code)); for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { pCreateReq = req.pReqs + iReq; taosMemoryFreeClear(pCreateReq->comment); @@ -1011,6 +1037,7 @@ end: destroyRequest(pRequest); tDecoderClear(&coder); qDestroyQuery(pQuery); + terrno = code; return code; } @@ -1026,6 +1053,10 @@ static void destroyDropTbReqBatch(void* data) { } static int32_t taosDropTable(TAOS* taos, void* meta, int32_t metaLen) { + if(taos == NULL || meta == NULL) { + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } SVDropTbBatchReq req = {0}; SDecoder coder = {0}; int32_t code = TSDB_CODE_SUCCESS; @@ -1033,11 +1064,13 @@ static int32_t taosDropTable(TAOS* taos, void* meta, int32_t metaLen) { SQuery* pQuery = NULL; SHashObj* pVgroupHashmap = NULL; - uDebug("taosDropTable called"); code = buildRequest(*(int64_t*)taos, "", 0, NULL, false, &pRequest, 0); if (code != TSDB_CODE_SUCCESS) { - goto end; + terrno = code; + return code; } + uDebug(LOG_ID_TAG " drop table, meta:%p, len:%d", LOG_ID_VALUE, meta, metaLen); + pRequest->syncQuery = true; if (!pRequest->pDb) { code = TSDB_CODE_PAR_DB_NOT_SPECIFIED; @@ -1069,9 +1102,9 @@ static int32_t taosDropTable(TAOS* taos, void* meta, int32_t metaLen) { taosHashSetFreeFp(pVgroupHashmap, destroyDropTbReqBatch); SRequestConnInfo conn = {.pTrans = pTscObj->pAppInfo->pTransporter, - .requestId = pRequest->requestId, - .requestObjRefId = pRequest->self, - .mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)}; + .requestId = pRequest->requestId, + .requestObjRefId = pRequest->self, + .mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)}; pRequest->tableList = taosArrayInit(req.nReqs, sizeof(SName)); // loop to create table for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { @@ -1095,13 +1128,12 @@ static int32_t taosDropTable(TAOS* taos, void* meta, int32_t metaLen) { continue; } if (code != TSDB_CODE_SUCCESS) { - uError("taosDropTable:catalogGetTableMeta failed. table name: %s", pDropReq->name); goto end; } tb_uid_t oldSuid = pDropReq->suid; pDropReq->suid = pTableMeta->suid; taosMemoryFreeClear(pTableMeta); - uDebug("taosDropTable name:%s suid:%" PRId64 " new suid:%" PRId64, pDropReq->name, oldSuid, pDropReq->suid); + uDebug(LOG_ID_TAG" drop table name:%s suid:%" PRId64 " new suid:%" PRId64, LOG_ID_VALUE, pDropReq->name, oldSuid, pDropReq->suid); taosArrayPush(pRequest->tableList, &pName); SVgroupDropTableBatch* pTableBatch = taosHashGet(pVgroupHashmap, &pInfo.vgId, sizeof(pInfo.vgId)); @@ -1139,15 +1171,17 @@ static int32_t taosDropTable(TAOS* taos, void* meta, int32_t metaLen) { launchQueryImpl(pRequest, pQuery, true, NULL); if (pRequest->code == TSDB_CODE_SUCCESS) { - removeMeta(pTscObj, pRequest->tableList); + removeMeta(pTscObj, pRequest->tableList, false); } code = pRequest->code; -end: + end: + uDebug(LOG_ID_TAG" drop table return, msg:%s", LOG_ID_VALUE, tstrerror(code)); taosHashCleanup(pVgroupHashmap); destroyRequest(pRequest); tDecoderClear(&coder); qDestroyQuery(pQuery); + terrno = code; return code; } @@ -1184,11 +1218,17 @@ end: //} static int32_t taosDeleteData(TAOS* taos, void* meta, int32_t metaLen) { - SDeleteRes req = {0}; - SDecoder coder = {0}; + if(taos == NULL || meta == NULL) { + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } + SDeleteRes req = {0}; + SDecoder coder = {0}; + char sql[256] = {0}; int32_t code = TSDB_CODE_SUCCESS; - uDebug("taosDeleteData called"); + uDebug("connId:0x%"PRIx64" delete data, meta:%p, len:%d", *(int64_t*)taos, meta, metaLen); + // decode and process req void* data = POINTER_SHIFT(meta, sizeof(SMsgHead)); int32_t len = metaLen - sizeof(SMsgHead); @@ -1199,10 +1239,8 @@ static int32_t taosDeleteData(TAOS* taos, void* meta, int32_t metaLen) { } // getTbName(req.tableFName); - char sql[256] = {0}; snprintf(sql, sizeof(sql), "delete from `%s` where `%s` >= %" PRId64 " and `%s` <= %" PRId64, req.tableFName, req.tsColName, req.skey, req.tsColName, req.ekey); - uDebug("delete sql:%s\n", sql); TAOS_RES* res = taos_query(taos, sql); SRequestObj* pRequest = (SRequestObj*)res; @@ -1212,12 +1250,18 @@ static int32_t taosDeleteData(TAOS* taos, void* meta, int32_t metaLen) { } taos_free_result(res); -end: + end: + uDebug("connId:0x%"PRIx64" delete data sql:%s, code:%s", *(int64_t*)taos, sql, tstrerror(code)); tDecoderClear(&coder); + terrno = code; return code; } static int32_t taosAlterTable(TAOS* taos, void* meta, int32_t metaLen) { + if(taos == NULL || meta == NULL) { + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } SVAlterTbReq req = {0}; SDecoder coder = {0}; int32_t code = TSDB_CODE_SUCCESS; @@ -1226,13 +1270,12 @@ static int32_t taosAlterTable(TAOS* taos, void* meta, int32_t metaLen) { SArray* pArray = NULL; SVgDataBlocks* pVgData = NULL; - uDebug("taosAlterTable called"); code = buildRequest(*(int64_t*)taos, "", 0, NULL, false, &pRequest, 0); - if (code != TSDB_CODE_SUCCESS) { - goto end; + terrno = code; + return code; } - + uDebug(LOG_ID_TAG " alter table, meta:%p, len:%d", LOG_ID_VALUE, meta, metaLen); pRequest->syncQuery = true; if (!pRequest->pDb) { code = TSDB_CODE_PAR_DB_NOT_SPECIFIED; @@ -1260,9 +1303,9 @@ static int32_t taosAlterTable(TAOS* taos, void* meta, int32_t metaLen) { } SRequestConnInfo conn = {.pTrans = pTscObj->pAppInfo->pTransporter, - .requestId = pRequest->requestId, - .requestObjRefId = pRequest->self, - .mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)}; + .requestId = pRequest->requestId, + .requestObjRefId = pRequest->self, + .mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)}; SVgroupInfo pInfo = {0}; SName pName = {0}; @@ -1272,7 +1315,6 @@ static int32_t taosAlterTable(TAOS* taos, void* meta, int32_t metaLen) { goto end; } - uDebug("taosAlterTable name:%s", req.tbName); pArray = taosArrayInit(1, sizeof(void*)); if (NULL == pArray) { code = TSDB_CODE_OUT_OF_MEMORY; @@ -1326,13 +1368,15 @@ static int32_t taosAlterTable(TAOS* taos, void* meta, int32_t metaLen) { code = handleAlterTbExecRes(pRes->res, pCatalog); } } -end: + end: + uDebug(LOG_ID_TAG " alter table return, meta:%p, len:%d, msg:%s", LOG_ID_VALUE, meta, metaLen, tstrerror(code)); taosArrayDestroy(pArray); if (pVgData) taosMemoryFreeClear(pVgData->pData); taosMemoryFreeClear(pVgData); destroyRequest(pRequest); tDecoderClear(&coder); qDestroyQuery(pQuery); + terrno = code; return code; } @@ -1344,24 +1388,24 @@ int taos_write_raw_block_with_fields(TAOS* taos, int rows, char* pData, const ch int taos_write_raw_block_with_fields_with_reqid(TAOS *taos, int rows, char *pData, const char *tbname, TAOS_FIELD *fields, int numFields, int64_t reqid){ if (!taos || !pData || !tbname) { - return TSDB_CODE_INVALID_PARA; + terrno = TSDB_CODE_INVALID_PARA; + return terrno; } int32_t code = TSDB_CODE_SUCCESS; STableMeta* pTableMeta = NULL; SQuery* pQuery = NULL; SHashObj* pVgHash = NULL; - uDebug("taos_write_raw_block_with_fields called"); SRequestObj* pRequest = (SRequestObj*)createRequest(*(int64_t*)taos, TSDB_SQL_INSERT, reqid); if (!pRequest) { - uError("WriteRaw:createRequest error request is null"); - code = terrno; - goto end; + return terrno; } + uDebug(LOG_ID_TAG " write raw block with field, rows:%d, pData:%p, tbname:%s, fields:%p, numFields:%d", + LOG_ID_VALUE, rows, pData, tbname, fields, numFields); + pRequest->syncQuery = true; if (!pRequest->pDb) { - uError("WriteRaw:not use db"); code = TSDB_CODE_PAR_DB_NOT_SPECIFIED; goto end; } @@ -1370,11 +1414,9 @@ int taos_write_raw_block_with_fields_with_reqid(TAOS *taos, int rows, char *pDat tstrncpy(pName.dbname, pRequest->pDb, sizeof(pName.dbname)); tstrncpy(pName.tname, tbname, sizeof(pName.tname)); - uDebug("taos_write_raw_block_with_fields name:%s", tbname); struct SCatalog* pCatalog = NULL; code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog); if (code != TSDB_CODE_SUCCESS) { - uError("WriteRaw: get gatlog error"); goto end; } @@ -1387,13 +1429,11 @@ int taos_write_raw_block_with_fields_with_reqid(TAOS *taos, int rows, char *pDat SVgroupInfo vgData = {0}; code = catalogGetTableHashVgroup(pCatalog, &conn, &pName, &vgData); if (code != TSDB_CODE_SUCCESS) { - uError("WriteRaw:catalogGetTableHashVgroup failed. table name: %s", tbname); goto end; } code = catalogGetTableMeta(pCatalog, &conn, &pName, &pTableMeta); if (code != TSDB_CODE_SUCCESS) { - uError("WriteRaw:catalogGetTableMeta failed. table name: %s", tbname); goto end; } // uError("td23101 0vgId:%d, vgId:%d, name:%s, uid:%"PRIu64, vgData.vgId, pTableMeta->vgId, tbname, pTableMeta->uid); @@ -1405,29 +1445,27 @@ int taos_write_raw_block_with_fields_with_reqid(TAOS *taos, int rows, char *pDat } pVgHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK); taosHashPut(pVgHash, (const char*)&vgData.vgId, sizeof(vgData.vgId), (char*)&vgData, sizeof(vgData)); - // uError("td23101 1vgId:%d, numEps:%d, name:%s, uid:%"PRIu64, vgData.vgId, vgData.epSet.numOfEps, tbname, - // pTableMeta->uid); code = rawBlockBindData(pQuery, pTableMeta, pData, NULL, fields, numFields, false); if (code != TSDB_CODE_SUCCESS) { - uError("WriteRaw:rawBlockBindData failed"); goto end; } code = smlBuildOutput(pQuery, pVgHash); if (code != TSDB_CODE_SUCCESS) { - uError("smlBuildOutput failed"); goto end; } launchQueryImpl(pRequest, pQuery, true, NULL); code = pRequest->code; -end: + end: + uDebug(LOG_ID_TAG " write raw block with field return, msg:%s", LOG_ID_VALUE, tstrerror(code)); taosMemoryFreeClear(pTableMeta); qDestroyQuery(pQuery); destroyRequest(pRequest); taosHashCleanup(pVgHash); + terrno = code; return code; } @@ -1437,24 +1475,23 @@ int taos_write_raw_block(TAOS* taos, int rows, char* pData, const char* tbname) int taos_write_raw_block_with_reqid(TAOS* taos, int rows, char* pData, const char* tbname, int64_t reqid) { if (!taos || !pData || !tbname) { - return TSDB_CODE_INVALID_PARA; + terrno = TSDB_CODE_INVALID_PARA; + return terrno; } int32_t code = TSDB_CODE_SUCCESS; STableMeta* pTableMeta = NULL; SQuery* pQuery = NULL; SHashObj* pVgHash = NULL; - uDebug("taos_write_raw_block called"); SRequestObj* pRequest = (SRequestObj*)createRequest(*(int64_t*)taos, TSDB_SQL_INSERT, reqid); if (!pRequest) { - uError("WriteRaw:createRequest error request is null"); - code = terrno; - goto end; + return terrno; } + uDebug(LOG_ID_TAG " write raw block, rows:%d, pData:%p, tbname:%s", LOG_ID_VALUE, rows, pData, tbname); + pRequest->syncQuery = true; if (!pRequest->pDb) { - uError("WriteRaw:not use db"); code = TSDB_CODE_PAR_DB_NOT_SPECIFIED; goto end; } @@ -1463,11 +1500,9 @@ int taos_write_raw_block_with_reqid(TAOS* taos, int rows, char* pData, const cha tstrncpy(pName.dbname, pRequest->pDb, sizeof(pName.dbname)); tstrncpy(pName.tname, tbname, sizeof(pName.tname)); - uDebug("taos_write_raw_block name:%s", tbname); struct SCatalog* pCatalog = NULL; code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog); if (code != TSDB_CODE_SUCCESS) { - uError("WriteRaw: get gatlog error"); goto end; } @@ -1480,13 +1515,11 @@ int taos_write_raw_block_with_reqid(TAOS* taos, int rows, char* pData, const cha SVgroupInfo vgData = {0}; code = catalogGetTableHashVgroup(pCatalog, &conn, &pName, &vgData); if (code != TSDB_CODE_SUCCESS) { - uError("WriteRaw:catalogGetTableHashVgroup failed. table name: %s", tbname); goto end; } code = catalogGetTableMeta(pCatalog, &conn, &pName, &pTableMeta); if (code != TSDB_CODE_SUCCESS) { - uError("WriteRaw:catalogGetTableMeta failed. table name: %s", tbname); goto end; } pQuery = smlInitHandle(); @@ -1499,43 +1532,46 @@ int taos_write_raw_block_with_reqid(TAOS* taos, int rows, char* pData, const cha code = rawBlockBindData(pQuery, pTableMeta, pData, NULL, NULL, 0, false); if (code != TSDB_CODE_SUCCESS) { - uError("WriteRaw:rawBlockBindData failed"); goto end; } code = smlBuildOutput(pQuery, pVgHash); if (code != TSDB_CODE_SUCCESS) { - uError("smlBuildOutput failed"); goto end; } launchQueryImpl(pRequest, pQuery, true, NULL); code = pRequest->code; -end: + end: + uDebug(LOG_ID_TAG " write raw block return, msg:%s", LOG_ID_VALUE, tstrerror(code)); taosMemoryFreeClear(pTableMeta); qDestroyQuery(pQuery); destroyRequest(pRequest); taosHashCleanup(pVgHash); + terrno = code; return code; } static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) { + if(taos == NULL || data == NULL){ + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } int32_t code = TSDB_CODE_SUCCESS; SHashObj* pVgHash = NULL; SQuery* pQuery = NULL; SMqRspObj rspObj = {0}; SDecoder decoder = {0}; STableMeta* pTableMeta = NULL; - uDebug("tmqWriteRawDataImpl called"); terrno = TSDB_CODE_SUCCESS; SRequestObj* pRequest = (SRequestObj*)createRequest(*(int64_t*)taos, TSDB_SQL_INSERT, 0); if (!pRequest) { - uError("WriteRaw:createRequest error request is null"); return terrno; } + uDebug(LOG_ID_TAG " write raw data, data:%p, dataLen:%d", LOG_ID_VALUE, data, dataLen); pRequest->syncQuery = true; rspObj.resIter = -1; rspObj.resType = RES_TYPE__TMQ; @@ -1543,13 +1579,11 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) { tDecoderInit(&decoder, data, dataLen); code = tDecodeMqDataRsp(&decoder, &rspObj.rsp); if (code != 0) { - uError("WriteRaw:decode smqDataRsp error"); code = TSDB_CODE_INVALID_MSG; goto end; } if (!pRequest->pDb) { - uError("WriteRaw:not use db"); code = TSDB_CODE_PAR_DB_NOT_SPECIFIED; goto end; } @@ -1557,7 +1591,6 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) { struct SCatalog* pCatalog = NULL; code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog); if (code != TSDB_CODE_SUCCESS) { - uError("WriteRaw: get gatlog error"); goto end; } @@ -1573,41 +1606,35 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) { goto end; } pVgHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK); - uDebug("tmqWriteRawDataImpl raw data block num:%d", rspObj.rsp.blockNum); while (++rspObj.resIter < rspObj.rsp.blockNum) { SRetrieveTableRsp* pRetrieve = (SRetrieveTableRsp*)taosArrayGetP(rspObj.rsp.blockData, rspObj.resIter); if (!rspObj.rsp.withSchema) { - uError("WriteRaw:no schema, iter:%d", rspObj.resIter); goto end; } const char* tbName = (const char*)taosArrayGetP(rspObj.rsp.blockTbName, rspObj.resIter); if (!tbName) { - uError("WriteRaw: tbname is null"); code = TSDB_CODE_TMQ_INVALID_MSG; goto end; } - uDebug("tmqWriteRawDataImpl raw data tbname:%s", tbName); SName pName = {TSDB_TABLE_NAME_T, pRequest->pTscObj->acctId, {0}, {0}}; strcpy(pName.dbname, pRequest->pDb); strcpy(pName.tname, tbName); code = catalogGetTableMeta(pCatalog, &conn, &pName, &pTableMeta); - if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST) { - uError("WriteRaw:catalogGetTableMeta table not exist. table name: %s", tbName); - code = TSDB_CODE_SUCCESS; - continue; - } +// if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST) { +// uError("WriteRaw:catalogGetTableMeta table not exist. table name: %s", tbName); +// code = TSDB_CODE_SUCCESS; +// continue; +// } if (code != TSDB_CODE_SUCCESS) { - uError("WriteRaw:catalogGetTableMeta failed. table name: %s", tbName); goto end; } SVgroupInfo vg; code = catalogGetTableHashVgroup(pCatalog, &conn, &pName, &vg); if (code != TSDB_CODE_SUCCESS) { - uError("WriteRaw:catalogGetTableHashVgroup failed. table name: %s", tbName); goto end; } @@ -1629,7 +1656,6 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) { code = rawBlockBindData(pQuery, pTableMeta, pRetrieve->data, NULL, fields, pSW->nCols, true); taosMemoryFree(fields); if (code != TSDB_CODE_SUCCESS) { - uError("WriteRaw:rawBlockBindData failed"); goto end; } taosMemoryFreeClear(pTableMeta); @@ -1637,24 +1663,29 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) { code = smlBuildOutput(pQuery, pVgHash); if (code != TSDB_CODE_SUCCESS) { - uError("smlBuildOutput failed"); goto end; } launchQueryImpl(pRequest, pQuery, true, NULL); code = pRequest->code; -end: + end: + uDebug(LOG_ID_TAG " write raw data return, msg:%s", LOG_ID_VALUE, tstrerror(code)); tDeleteMqDataRsp(&rspObj.rsp); tDecoderClear(&decoder); qDestroyQuery(pQuery); destroyRequest(pRequest); taosHashCleanup(pVgHash); taosMemoryFreeClear(pTableMeta); + terrno = code; return code; } static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen) { + if(taos == NULL || data == NULL){ + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } int32_t code = TSDB_CODE_SUCCESS; SHashObj* pVgHash = NULL; SQuery* pQuery = NULL; @@ -1662,15 +1693,13 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen) SDecoder decoder = {0}; STableMeta* pTableMeta = NULL; SVCreateTbReq* pCreateReqDst = NULL; - uDebug("tmqWriteRawMetaDataImpl called"); terrno = TSDB_CODE_SUCCESS; SRequestObj* pRequest = (SRequestObj*)createRequest(*(int64_t*)taos, TSDB_SQL_INSERT, 0); if (!pRequest) { - uError("WriteRaw:createRequest error request is null"); return terrno; } - + uDebug(LOG_ID_TAG " write raw metadata, data:%p, dataLen:%d", LOG_ID_VALUE, data, dataLen); pRequest->syncQuery = true; rspObj.resIter = -1; rspObj.resType = RES_TYPE__TMQ_METADATA; @@ -1678,13 +1707,11 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen) tDecoderInit(&decoder, data, dataLen); code = tDecodeSTaosxRsp(&decoder, &rspObj.rsp); if (code != 0) { - uError("WriteRaw:decode smqDataRsp error"); code = TSDB_CODE_INVALID_MSG; goto end; } if (!pRequest->pDb) { - uError("WriteRaw:not use db"); code = TSDB_CODE_PAR_DB_NOT_SPECIFIED; goto end; } @@ -1692,7 +1719,6 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen) struct SCatalog* pCatalog = NULL; code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog); if (code != TSDB_CODE_SUCCESS) { - uError("WriteRaw: get gatlog error"); goto end; } @@ -1709,22 +1735,20 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen) } pVgHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK); - uDebug("tmqWriteRawMetaDataImpl raw data block num:%d", rspObj.rsp.blockNum); + uDebug(LOG_ID_TAG" write raw metadata block num:%d", LOG_ID_VALUE, rspObj.rsp.blockNum); while (++rspObj.resIter < rspObj.rsp.blockNum) { SRetrieveTableRsp* pRetrieve = (SRetrieveTableRsp*)taosArrayGetP(rspObj.rsp.blockData, rspObj.resIter); if (!rspObj.rsp.withSchema) { - uError("WriteRaw:no schema, iter:%d", rspObj.resIter); goto end; } const char* tbName = (const char*)taosArrayGetP(rspObj.rsp.blockTbName, rspObj.resIter); if (!tbName) { - uError("WriteRaw: tbname is null"); code = TSDB_CODE_TMQ_INVALID_MSG; goto end; } - uDebug("tmqWriteRawMetaDataImpl raw data tbname:%s\n", tbName); + uDebug(LOG_ID_TAG" write raw metadata block tbname:%s", LOG_ID_VALUE, tbName); SName pName = {TSDB_TABLE_NAME_T, pRequest->pTscObj->acctId, {0}, {0}}; strcpy(pName.dbname, pRequest->pDb); strcpy(pName.tname, tbName); @@ -1740,13 +1764,11 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen) if (tDecodeSVCreateTbReq(&decoderTmp, &pCreateReq) < 0) { tDecoderClear(&decoderTmp); tDestroySVCreateTbReq(&pCreateReq, TSDB_MSG_FLG_DECODE); - uError("WriteRaw: tDecodeSVCreateTbReq error"); code = TSDB_CODE_TMQ_INVALID_MSG; goto end; } if (pCreateReq.type != TSDB_CHILD_TABLE) { - uError("WriteRaw:pCreateReq.type != TSDB_CHILD_TABLE. table name: %s", tbName); code = TSDB_CODE_TSC_INVALID_VALUE; tDecoderClear(&decoderTmp); tDestroySVCreateTbReq(&pCreateReq, TSDB_MSG_FLG_DECODE); @@ -1766,7 +1788,6 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen) SVgroupInfo vg; code = catalogGetTableHashVgroup(pCatalog, &conn, &pName, &vg); if (code != TSDB_CODE_SUCCESS) { - uError("WriteRaw:catalogGetTableHashVgroup failed. table name: %s", tbName); goto end; } @@ -1774,13 +1795,12 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen) strcpy(pName.tname, pCreateReqDst->ctb.stbName); } code = catalogGetTableMeta(pCatalog, &conn, &pName, &pTableMeta); - if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST) { - uError("WriteRaw:catalogGetTableMeta table not exist. table name: %s", tbName); - code = TSDB_CODE_SUCCESS; - continue; - } +// if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST) { +// uError("WriteRaw:catalogGetTableMeta table not exist. table name: %s", tbName); +// code = TSDB_CODE_SUCCESS; +// continue; +// } if (code != TSDB_CODE_SUCCESS) { - uError("WriteRaw:catalogGetTableMeta failed. table name: %s", tbName); goto end; } @@ -1807,7 +1827,6 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen) code = rawBlockBindData(pQuery, pTableMeta, pRetrieve->data, pCreateReqDst, fields, pSW->nCols, true); taosMemoryFree(fields); if (code != TSDB_CODE_SUCCESS) { - uError("WriteRaw:rawBlockBindData failed"); goto end; } pCreateReqDst = NULL; @@ -1816,14 +1835,14 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen) code = smlBuildOutput(pQuery, pVgHash); if (code != TSDB_CODE_SUCCESS) { - uError("smlBuildOutput failed"); goto end; } launchQueryImpl(pRequest, pQuery, true, NULL); code = pRequest->code; -end: + end: + uDebug(LOG_ID_TAG " write raw metadata return, msg:%s", LOG_ID_VALUE, tstrerror(code)); tDeleteSTaosxRsp(&rspObj.rsp); tDecoderClear(&decoder); qDestroyQuery(pQuery); @@ -1834,12 +1853,13 @@ end: tdDestroySVCreateTbReq(pCreateReqDst); taosMemoryFree(pCreateReqDst); } + terrno = code; return code; } char* tmq_get_json_meta(TAOS_RES* res) { if (res == NULL) return NULL; - uDebug("tmq_get_json_meta called"); + uDebug("tmq_get_json_meta res:%p", res); if (!TD_RES_TMQ_META(res) && !TD_RES_TMQ_METADATA(res)) { return NULL; } @@ -1874,16 +1894,16 @@ char* tmq_get_json_meta(TAOS_RES* res) { void tmq_free_json_meta(char* jsonMeta) { taosMemoryFreeClear(jsonMeta); } int32_t tmq_get_raw(TAOS_RES* res, tmq_raw_data* raw) { - uDebug("tmq_get_raw called"); if (!raw || !res) { - return TSDB_CODE_INVALID_PARA; + terrno = TSDB_CODE_INVALID_PARA; + return terrno; } if (TD_RES_TMQ_META(res)) { SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)res; raw->raw = pMetaRspObj->metaRsp.metaRsp; raw->raw_len = pMetaRspObj->metaRsp.metaRspLen; raw->raw_type = pMetaRspObj->metaRsp.resMsgType; - uDebug("tmq_get_raw meta"); + uDebug("tmq get raw type meta:%p", raw); } else if (TD_RES_TMQ(res)) { SMqRspObj* rspObj = ((SMqRspObj*)res); @@ -1903,7 +1923,7 @@ int32_t tmq_get_raw(TAOS_RES* res, tmq_raw_data* raw) { raw->raw = buf; raw->raw_len = len; raw->raw_type = RES_TYPE__TMQ; - uDebug("tmq_get_raw data"); + uDebug("tmq get raw type data:%p", raw); } else if (TD_RES_TMQ_METADATA(res)) { SMqTaosxRspObj* rspObj = ((SMqTaosxRspObj*)res); @@ -1923,25 +1943,25 @@ int32_t tmq_get_raw(TAOS_RES* res, tmq_raw_data* raw) { raw->raw = buf; raw->raw_len = len; raw->raw_type = RES_TYPE__TMQ_METADATA; - uDebug("tmq_get_raw meta data"); + uDebug("tmq get raw type metadata:%p", raw); } else { - uError("tmq_get_raw error:%d", *(int8_t*)res); - return TSDB_CODE_TMQ_INVALID_MSG; + uError("tmq get raw error type:%d", *(int8_t*)res); + terrno = TSDB_CODE_TMQ_INVALID_MSG; + return terrno; } return TSDB_CODE_SUCCESS; } void tmq_free_raw(tmq_raw_data raw) { - uDebug("tmq_free_raw raw_type:%d", raw.raw_type); + uDebug("tmq free raw data type:%d", raw.raw_type); if (raw.raw_type == RES_TYPE__TMQ || raw.raw_type == RES_TYPE__TMQ_METADATA) { taosMemoryFree(raw.raw); } } int32_t tmq_write_raw(TAOS* taos, tmq_raw_data raw) { - uDebug("tmq_write_raw called"); if (!taos) { - return TSDB_CODE_INVALID_PARA; + goto end; } if (raw.raw_type == TDMT_VND_CREATE_STB) { @@ -1963,5 +1983,8 @@ int32_t tmq_write_raw(TAOS* taos, tmq_raw_data raw) { } else if (raw.raw_type == RES_TYPE__TMQ_METADATA) { return tmqWriteRawMetaDataImpl(taos, raw.raw, raw.raw_len); } - return TSDB_CODE_INVALID_PARA; + + end: + terrno = TSDB_CODE_INVALID_PARA; + return terrno; } diff --git a/source/client/src/clientSml.c b/source/client/src/clientSml.c index 17645fbec5..6ab0bfc563 100644 --- a/source/client/src/clientSml.c +++ b/source/client/src/clientSml.c @@ -104,9 +104,9 @@ static int32_t smlCheckAuth(SSmlHandle *info, SRequestConnInfo* conn, const cha SUserAuthRes authRes = {0}; code = catalogChkAuth(info->pCatalog, conn, &pAuth, &authRes); - nodesDestroyNode(authRes.pCond); + nodesDestroyNode(authRes.pCond[AUTH_RES_BASIC]); - return (code == TSDB_CODE_SUCCESS) ? (authRes.pass ? TSDB_CODE_SUCCESS : TSDB_CODE_PAR_PERMISSION_DENIED) : code; + return (code == TSDB_CODE_SUCCESS) ? (authRes.pass[AUTH_RES_BASIC] ? TSDB_CODE_SUCCESS : TSDB_CODE_PAR_PERMISSION_DENIED) : code; } inline bool smlDoubleToInt64OverFlow(double num) { diff --git a/source/client/src/clientTmq.c b/source/client/src/clientTmq.c index 23b89286f6..6aebba7c02 100644 --- a/source/client/src/clientTmq.c +++ b/source/client/src/clientTmq.c @@ -1451,7 +1451,7 @@ static bool doUpdateLocalEp(tmq_t* tmq, int32_t epoch, const SMqAskEpRsp* pRsp) bool set = false; int32_t topicNumGet = taosArrayGetSize(pRsp->topics); - if (topicNumGet <= 0 && epoch <= tmq->epoch) { + if (epoch < tmq->epoch || (epoch == tmq->epoch && topicNumGet == 0)) { tscInfo("consumer:0x%" PRIx64 " no update ep epoch from %d to epoch %d, incoming topics:%d", tmq->consumerId, tmq->epoch, epoch, topicNumGet); return false; diff --git a/source/common/src/systable.c b/source/common/src/systable.c index dc584437bf..5f44d3e7fc 100644 --- a/source/common/src/systable.c +++ b/source/common/src/systable.c @@ -24,6 +24,7 @@ #define SYSTABLE_SCH_TABLE_NAME_LEN ((TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE) #define SYSTABLE_SCH_DB_NAME_LEN ((TSDB_DB_NAME_LEN - 1) + VARSTR_HEADER_SIZE) #define SYSTABLE_SCH_COL_NAME_LEN ((TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE) +#define SYSTABLE_SCH_VIEW_NAME_LEN ((TSDB_VIEW_NAME_LEN - 1) + VARSTR_HEADER_SIZE) // clang-format off static const SSysDbTableSchema dnodesSchema[] = { @@ -315,8 +316,23 @@ static const SSysDbTableSchema userUserPrivilegesSchema[] = { {.name = "db_name", .bytes = TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, {.name = "table_name", .bytes = TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, {.name = "condition", .bytes = TSDB_PRIVILEDGE_CONDITION_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, + {.name = "notes", .bytes = 64 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, }; +static const SSysDbTableSchema userViewsSchema[] = { + {.name = "view_name", .bytes = SYSTABLE_SCH_VIEW_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, + {.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, + {.name = "effective_user", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, + {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false}, + {.name = "type", .bytes = 128 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, + {.name = "query_sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, + {.name = "parameters", .bytes = 2048 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, + {.name = "default_values", .bytes = 2048 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, + {.name = "target_table", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, +// {.name = "column_list", .bytes = 2048 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, +}; + + static const SSysTableMeta infosMeta[] = { {TSDB_INS_TABLE_DNODES, dnodesSchema, tListLen(dnodesSchema), true}, {TSDB_INS_TABLE_MNODES, mnodesSchema, tListLen(mnodesSchema), true}, @@ -343,6 +359,7 @@ static const SSysTableMeta infosMeta[] = { {TSDB_INS_TABLE_STREAM_TASKS, streamTaskSchema, tListLen(streamTaskSchema), false}, {TSDB_INS_TABLE_VNODES, vnodesSchema, tListLen(vnodesSchema), true}, {TSDB_INS_TABLE_USER_PRIVILEGES, userUserPrivilegesSchema, tListLen(userUserPrivilegesSchema), true}, + {TSDB_INS_TABLE_VIEWS, userViewsSchema, tListLen(userViewsSchema), false}, }; static const SSysDbTableSchema connectionsSchema[] = { diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 137633ec13..34b789fef8 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -1677,6 +1677,7 @@ int32_t tSerializeSAlterUserReq(void *buf, int32_t bufLen, SAlterUserReq *pReq) if (tEncodeI8(&encoder, pReq->superUser) < 0) return -1; if (tEncodeI8(&encoder, pReq->sysInfo) < 0) return -1; if (tEncodeI8(&encoder, pReq->enable) < 0) return -1; + if (tEncodeI8(&encoder, pReq->isView) < 0) return -1; if (tEncodeCStr(&encoder, pReq->user) < 0) return -1; if (tEncodeCStr(&encoder, pReq->pass) < 0) return -1; if (tEncodeCStr(&encoder, pReq->objname) < 0) return -1; @@ -1691,6 +1692,7 @@ int32_t tSerializeSAlterUserReq(void *buf, int32_t bufLen, SAlterUserReq *pReq) if (tEncodeU32(&encoder, pReq->pIpRanges[i].ip) < 0) return -1; if (tEncodeU32(&encoder, pReq->pIpRanges[i].mask) < 0) return -1; } + if (tEncodeI64(&encoder, pReq->privileges) < 0) return -1; ENCODESQL(); tEndEncode(&encoder); @@ -1708,6 +1710,7 @@ int32_t tDeserializeSAlterUserReq(void *buf, int32_t bufLen, SAlterUserReq *pReq if (tDecodeI8(&decoder, &pReq->superUser) < 0) return -1; if (tDecodeI8(&decoder, &pReq->sysInfo) < 0) return -1; if (tDecodeI8(&decoder, &pReq->enable) < 0) return -1; + if (tDecodeI8(&decoder, &pReq->isView) < 0) return -1; if (tDecodeCStrTo(&decoder, pReq->user) < 0) return -1; if (tDecodeCStrTo(&decoder, pReq->pass) < 0) return -1; if (tDecodeCStrTo(&decoder, pReq->objname) < 0) return -1; @@ -1728,6 +1731,7 @@ int32_t tDeserializeSAlterUserReq(void *buf, int32_t bufLen, SAlterUserReq *pReq if (tDecodeU32(&decoder, &(pReq->pIpRanges[i].ip)) < 0) return -1; if (tDecodeU32(&decoder, &(pReq->pIpRanges[i].mask)) < 0) return -1; } + if (tDecodeI64(&decoder, &pReq->privileges) < 0) return -1; DECODESQL(); tEndDecode(&decoder); @@ -1802,10 +1806,18 @@ int32_t tSerializeSGetUserAuthRspImpl(SEncoder *pEncoder, SGetUserAuthRsp *pRsp) int32_t numOfReadTbs = taosHashGetSize(pRsp->readTbs); int32_t numOfWriteTbs = taosHashGetSize(pRsp->writeTbs); - int32_t numOfUseTbs = taosHashGetSize(pRsp->useDbs); + int32_t numOfAlterTbs = taosHashGetSize(pRsp->alterTbs); + int32_t numOfReadViews = taosHashGetSize(pRsp->readViews); + int32_t numOfWriteViews = taosHashGetSize(pRsp->writeViews); + int32_t numOfAlterViews = taosHashGetSize(pRsp->alterViews); + int32_t numOfUseDbs = taosHashGetSize(pRsp->useDbs); if (tEncodeI32(pEncoder, numOfReadTbs) < 0) return -1; if (tEncodeI32(pEncoder, numOfWriteTbs) < 0) return -1; - if (tEncodeI32(pEncoder, numOfUseTbs) < 0) return -1; + if (tEncodeI32(pEncoder, numOfAlterTbs) < 0) return -1; + if (tEncodeI32(pEncoder, numOfReadViews) < 0) return -1; + if (tEncodeI32(pEncoder, numOfWriteViews) < 0) return -1; + if (tEncodeI32(pEncoder, numOfAlterViews) < 0) return -1; + if (tEncodeI32(pEncoder, numOfUseDbs) < 0) return -1; char *tb = taosHashIterate(pRsp->readTbs, NULL); while (tb != NULL) { @@ -1837,6 +1849,66 @@ int32_t tSerializeSGetUserAuthRspImpl(SEncoder *pEncoder, SGetUserAuthRsp *pRsp) tb = taosHashIterate(pRsp->writeTbs, tb); } + tb = taosHashIterate(pRsp->alterTbs, NULL); + while (tb != NULL) { + size_t keyLen = 0; + void *key = taosHashGetKey(tb, &keyLen); + if (tEncodeI32(pEncoder, keyLen) < 0) return -1; + if (tEncodeCStr(pEncoder, key) < 0) return -1; + + size_t valueLen = 0; + valueLen = strlen(tb); + if (tEncodeI32(pEncoder, valueLen) < 0) return -1; + if (tEncodeCStr(pEncoder, tb) < 0) return -1; + + tb = taosHashIterate(pRsp->alterTbs, tb); + } + + tb = taosHashIterate(pRsp->readViews, NULL); + while (tb != NULL) { + size_t keyLen = 0; + void *key = taosHashGetKey(tb, &keyLen); + if (tEncodeI32(pEncoder, keyLen) < 0) return -1; + if (tEncodeCStr(pEncoder, key) < 0) return -1; + + size_t valueLen = 0; + valueLen = strlen(tb); + if (tEncodeI32(pEncoder, valueLen) < 0) return -1; + if (tEncodeCStr(pEncoder, tb) < 0) return -1; + + tb = taosHashIterate(pRsp->readViews, tb); + } + + tb = taosHashIterate(pRsp->writeViews, NULL); + while (tb != NULL) { + size_t keyLen = 0; + void *key = taosHashGetKey(tb, &keyLen); + if (tEncodeI32(pEncoder, keyLen) < 0) return -1; + if (tEncodeCStr(pEncoder, key) < 0) return -1; + + size_t valueLen = 0; + valueLen = strlen(tb); + if (tEncodeI32(pEncoder, valueLen) < 0) return -1; + if (tEncodeCStr(pEncoder, tb) < 0) return -1; + + tb = taosHashIterate(pRsp->writeViews, tb); + } + + tb = taosHashIterate(pRsp->alterViews, NULL); + while (tb != NULL) { + size_t keyLen = 0; + void *key = taosHashGetKey(tb, &keyLen); + if (tEncodeI32(pEncoder, keyLen) < 0) return -1; + if (tEncodeCStr(pEncoder, key) < 0) return -1; + + size_t valueLen = 0; + valueLen = strlen(tb); + if (tEncodeI32(pEncoder, valueLen) < 0) return -1; + if (tEncodeCStr(pEncoder, tb) < 0) return -1; + + tb = taosHashIterate(pRsp->alterViews, tb); + } + int32_t *useDb = taosHashIterate(pRsp->useDbs, NULL); while (useDb != NULL) { size_t keyLen = 0; @@ -1876,9 +1948,14 @@ int32_t tDeserializeSGetUserAuthRspImpl(SDecoder *pDecoder, SGetUserAuthRsp *pRs pRsp->writeDbs = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); pRsp->readTbs = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); pRsp->writeTbs = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); + pRsp->alterTbs = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); + pRsp->readViews = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); + pRsp->writeViews = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); + pRsp->alterViews = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); pRsp->useDbs = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); if (pRsp->createdDbs == NULL || pRsp->readDbs == NULL || pRsp->writeDbs == NULL || pRsp->readTbs == NULL || - pRsp->writeTbs == NULL || pRsp->useDbs == NULL) { + pRsp->writeTbs == NULL || pRsp->alterTbs == NULL || pRsp->readViews == NULL || + pRsp->writeViews == NULL || pRsp->alterViews == NULL ||pRsp->useDbs == NULL) { goto _err; } @@ -1900,29 +1977,37 @@ int32_t tDeserializeSGetUserAuthRspImpl(SDecoder *pDecoder, SGetUserAuthRsp *pRs char db[TSDB_DB_FNAME_LEN] = {0}; if (tDecodeCStrTo(pDecoder, db) < 0) goto _err; int32_t len = strlen(db); - taosHashPut(pRsp->createdDbs, db, len, db, len + 1); + taosHashPut(pRsp->createdDbs, db, len + 1, db, len + 1); } for (int32_t i = 0; i < numOfReadDbs; ++i) { char db[TSDB_DB_FNAME_LEN] = {0}; if (tDecodeCStrTo(pDecoder, db) < 0) goto _err; int32_t len = strlen(db); - taosHashPut(pRsp->readDbs, db, len, db, len + 1); + taosHashPut(pRsp->readDbs, db, len + 1, db, len + 1); } for (int32_t i = 0; i < numOfWriteDbs; ++i) { char db[TSDB_DB_FNAME_LEN] = {0}; if (tDecodeCStrTo(pDecoder, db) < 0) goto _err; int32_t len = strlen(db); - taosHashPut(pRsp->writeDbs, db, len, db, len + 1); + taosHashPut(pRsp->writeDbs, db, len + 1, db, len + 1); } if (!tDecodeIsEnd(pDecoder)) { int32_t numOfReadTbs = 0; int32_t numOfWriteTbs = 0; + int32_t numOfAlterTbs = 0; + int32_t numOfReadViews = 0; + int32_t numOfWriteViews = 0; + int32_t numOfAlterViews = 0; int32_t numOfUseDbs = 0; if (tDecodeI32(pDecoder, &numOfReadTbs) < 0) goto _err; if (tDecodeI32(pDecoder, &numOfWriteTbs) < 0) goto _err; + if (tDecodeI32(pDecoder, &numOfAlterTbs) < 0) goto _err; + if (tDecodeI32(pDecoder, &numOfReadViews) < 0) goto _err; + if (tDecodeI32(pDecoder, &numOfWriteViews) < 0) goto _err; + if (tDecodeI32(pDecoder, &numOfAlterViews) < 0) goto _err; if (tDecodeI32(pDecoder, &numOfUseDbs) < 0) goto _err; for (int32_t i = 0; i < numOfReadTbs; ++i) { @@ -1938,7 +2023,7 @@ int32_t tDeserializeSGetUserAuthRspImpl(SDecoder *pDecoder, SGetUserAuthRsp *pRs value = taosMemoryCalloc(valuelen + 1, sizeof(char)); if (tDecodeCStrTo(pDecoder, value) < 0) goto _err; - taosHashPut(pRsp->readTbs, key, strlen(key), value, valuelen + 1); + taosHashPut(pRsp->readTbs, key, keyLen, value, valuelen + 1); taosMemoryFreeClear(key); taosMemoryFreeClear(value); @@ -1957,7 +2042,83 @@ int32_t tDeserializeSGetUserAuthRspImpl(SDecoder *pDecoder, SGetUserAuthRsp *pRs value = taosMemoryCalloc(valuelen + 1, sizeof(char)); if (tDecodeCStrTo(pDecoder, value) < 0) goto _err; - taosHashPut(pRsp->writeTbs, key, strlen(key), value, valuelen + 1); + taosHashPut(pRsp->writeTbs, key, keyLen, value, valuelen + 1); + + taosMemoryFreeClear(key); + taosMemoryFreeClear(value); + } + + for (int32_t i = 0; i < numOfAlterTbs; ++i) { + int32_t keyLen = 0; + if (tDecodeI32(pDecoder, &keyLen) < 0) goto _err; + + key = taosMemoryCalloc(keyLen + 1, sizeof(char)); + if (tDecodeCStrTo(pDecoder, key) < 0) goto _err; + + int32_t valuelen = 0; + if (tDecodeI32(pDecoder, &valuelen) < 0) goto _err; + + value = taosMemoryCalloc(valuelen + 1, sizeof(char)); + if (tDecodeCStrTo(pDecoder, value) < 0) goto _err; + + taosHashPut(pRsp->alterTbs, key, keyLen, value, valuelen + 1); + + taosMemoryFreeClear(key); + taosMemoryFreeClear(value); + } + + for (int32_t i = 0; i < numOfReadViews; ++i) { + int32_t keyLen = 0; + if (tDecodeI32(pDecoder, &keyLen) < 0) goto _err; + + key = taosMemoryCalloc(keyLen + 1, sizeof(char)); + if (tDecodeCStrTo(pDecoder, key) < 0) goto _err; + + int32_t valuelen = 0; + if (tDecodeI32(pDecoder, &valuelen) < 0) goto _err; + + value = taosMemoryCalloc(valuelen + 1, sizeof(char)); + if (tDecodeCStrTo(pDecoder, value) < 0) goto _err; + + taosHashPut(pRsp->readViews, key, keyLen, value, valuelen + 1); + + taosMemoryFreeClear(key); + taosMemoryFreeClear(value); + } + + for (int32_t i = 0; i < numOfWriteViews; ++i) { + int32_t keyLen = 0; + if (tDecodeI32(pDecoder, &keyLen) < 0) goto _err; + + key = taosMemoryCalloc(keyLen + 1, sizeof(char)); + if (tDecodeCStrTo(pDecoder, key) < 0) goto _err; + + int32_t valuelen = 0; + if (tDecodeI32(pDecoder, &valuelen) < 0) goto _err; + + value = taosMemoryCalloc(valuelen + 1, sizeof(char)); + if (tDecodeCStrTo(pDecoder, value) < 0) goto _err; + + taosHashPut(pRsp->writeViews, key, keyLen, value, valuelen + 1); + + taosMemoryFreeClear(key); + taosMemoryFreeClear(value); + } + + for (int32_t i = 0; i < numOfAlterViews; ++i) { + int32_t keyLen = 0; + if (tDecodeI32(pDecoder, &keyLen) < 0) goto _err; + + key = taosMemoryCalloc(keyLen + 1, sizeof(char)); + if (tDecodeCStrTo(pDecoder, key) < 0) goto _err; + + int32_t valuelen = 0; + if (tDecodeI32(pDecoder, &valuelen) < 0) goto _err; + + value = taosMemoryCalloc(valuelen + 1, sizeof(char)); + if (tDecodeCStrTo(pDecoder, value) < 0) goto _err; + + taosHashPut(pRsp->alterViews, key, keyLen, value, valuelen + 1); taosMemoryFreeClear(key); taosMemoryFreeClear(value); @@ -1973,7 +2134,7 @@ int32_t tDeserializeSGetUserAuthRspImpl(SDecoder *pDecoder, SGetUserAuthRsp *pRs int32_t ref = 0; if (tDecodeI32(pDecoder, &ref) < 0) goto _err; - taosHashPut(pRsp->useDbs, key, strlen(key), &ref, sizeof(ref)); + taosHashPut(pRsp->useDbs, key, keyLen, &ref, sizeof(ref)); taosMemoryFreeClear(key); } // since 3.0.7.0 @@ -1993,8 +2154,12 @@ _err: taosHashCleanup(pRsp->createdDbs); taosHashCleanup(pRsp->readDbs); taosHashCleanup(pRsp->writeDbs); - taosHashCleanup(pRsp->writeTbs); taosHashCleanup(pRsp->readTbs); + taosHashCleanup(pRsp->writeTbs); + taosHashCleanup(pRsp->alterTbs); + taosHashCleanup(pRsp->readViews); + taosHashCleanup(pRsp->writeViews); + taosHashCleanup(pRsp->alterViews); taosHashCleanup(pRsp->useDbs); taosMemoryFreeClear(key); @@ -2020,8 +2185,12 @@ void tFreeSGetUserAuthRsp(SGetUserAuthRsp *pRsp) { taosHashCleanup(pRsp->createdDbs); taosHashCleanup(pRsp->readDbs); taosHashCleanup(pRsp->writeDbs); - taosHashCleanup(pRsp->writeTbs); taosHashCleanup(pRsp->readTbs); + taosHashCleanup(pRsp->writeTbs); + taosHashCleanup(pRsp->alterTbs); + taosHashCleanup(pRsp->readViews); + taosHashCleanup(pRsp->writeViews); + taosHashCleanup(pRsp->alterViews); taosHashCleanup(pRsp->useDbs); } @@ -8634,3 +8803,286 @@ void tDeleteMqSubTopicEp(SMqSubTopicEp *pSubTopicEp) { pSubTopicEp->schema.nCols = 0; taosArrayDestroy(pSubTopicEp->vgs); } + +int32_t tSerializeSCMCreateViewReq(void *buf, int32_t bufLen, const SCMCreateViewReq *pReq) { + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, bufLen); + + if (tStartEncode(&encoder) < 0) return -1; + if (tEncodeCStr(&encoder, pReq->fullname) < 0) return -1; + if (tEncodeCStr(&encoder, pReq->name) < 0) return -1; + if (tEncodeCStr(&encoder, pReq->dbFName) < 0) return -1; + if (tEncodeCStr(&encoder, pReq->querySql) < 0) return -1; + if (tEncodeCStr(&encoder, pReq->sql) < 0) return -1; + if (tEncodeI8(&encoder, pReq->orReplace) < 0) return -1; + if (tEncodeI8(&encoder, pReq->precision) < 0) return -1; + if (tEncodeI32(&encoder, pReq->numOfCols) < 0) return -1; + for (int32_t i = 0; i < pReq->numOfCols; ++i) { + SSchema *pSchema = &pReq->pSchema[i]; + if (tEncodeSSchema(&encoder, pSchema) < 0) return -1; + } + + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); + return tlen; +} + +int32_t tDeserializeSCMCreateViewReq(void *buf, int32_t bufLen, SCMCreateViewReq *pReq) { + SDecoder decoder = {0}; + tDecoderInit(&decoder, buf, bufLen); + + if (tStartDecode(&decoder) < 0) return -1; + if (tDecodeCStrTo(&decoder, pReq->fullname) < 0) return -1; + if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1; + if (tDecodeCStrTo(&decoder, pReq->dbFName) < 0) return -1; + if (tDecodeCStrAlloc(&decoder, &pReq->querySql) < 0) return -1; + if (tDecodeCStrAlloc(&decoder, &pReq->sql) < 0) return -1; + if (tDecodeI8(&decoder, &pReq->orReplace) < 0) return -1; + if (tDecodeI8(&decoder, &pReq->precision) < 0) return -1; + if (tDecodeI32(&decoder, &pReq->numOfCols) < 0) return -1; + + if (pReq->numOfCols > 0) { + pReq->pSchema = taosMemoryCalloc(pReq->numOfCols, sizeof(SSchema)); + if (pReq->pSchema == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + + for (int32_t i = 0; i < pReq->numOfCols; ++i) { + SSchema* pSchema = pReq->pSchema + i; + if (tDecodeSSchema(&decoder, pSchema) < 0) return -1; + } + } + + tEndDecode(&decoder); + + tDecoderClear(&decoder); + return 0; +} + +void tFreeSCMCreateViewReq(SCMCreateViewReq* pReq) { + if (NULL == pReq) { + return; + } + + taosMemoryFreeClear(pReq->querySql); + taosMemoryFreeClear(pReq->sql); + taosMemoryFreeClear(pReq->pSchema); +} + +int32_t tSerializeSCMDropViewReq(void* buf, int32_t bufLen, const SCMDropViewReq* pReq) { + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, bufLen); + + if (tStartEncode(&encoder) < 0) return -1; + if (tEncodeCStr(&encoder, pReq->fullname) < 0) return -1; + if (tEncodeCStr(&encoder, pReq->name) < 0) return -1; + if (tEncodeCStr(&encoder, pReq->dbFName) < 0) return -1; + if (tEncodeCStr(&encoder, pReq->sql) < 0) return -1; + if (tEncodeI8(&encoder, pReq->igNotExists) < 0) return -1; + + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); + return tlen; +} + +int32_t tDeserializeSCMDropViewReq(void* buf, int32_t bufLen, SCMDropViewReq* pReq) { + SDecoder decoder = {0}; + tDecoderInit(&decoder, buf, bufLen); + + if (tStartDecode(&decoder) < 0) return -1; + if (tDecodeCStrTo(&decoder, pReq->fullname) < 0) return -1; + if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1; + if (tDecodeCStrTo(&decoder, pReq->dbFName) < 0) return -1; + if (tDecodeCStrAlloc(&decoder, &pReq->sql) < 0) return -1; + if (tDecodeI8(&decoder, &pReq->igNotExists) < 0) return -1; + + tEndDecode(&decoder); + + tDecoderClear(&decoder); + return 0; +} +void tFreeSCMDropViewReq(SCMDropViewReq* pReq) { + if (NULL == pReq) { + return; + } + + taosMemoryFree(pReq->sql); +} + +int32_t tSerializeSViewMetaReq(void* buf, int32_t bufLen, const SViewMetaReq* pReq) { + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, bufLen); + + if (tStartEncode(&encoder) < 0) return -1; + if (tEncodeCStr(&encoder, pReq->fullname) < 0) return -1; + + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); + return tlen; +} + +int32_t tDeserializeSViewMetaReq(void* buf, int32_t bufLen, SViewMetaReq* pReq) { + SDecoder decoder = {0}; + tDecoderInit(&decoder, buf, bufLen); + + if (tStartDecode(&decoder) < 0) return -1; + if (tDecodeCStrTo(&decoder, pReq->fullname) < 0) return -1; + + tEndDecode(&decoder); + + tDecoderClear(&decoder); + return 0; +} + +static int32_t tEncodeSViewMetaRsp(SEncoder *pEncoder, const SViewMetaRsp *pRsp) { + if (tEncodeCStr(pEncoder, pRsp->name) < 0) return -1; + if (tEncodeCStr(pEncoder, pRsp->dbFName) < 0) return -1; + if (tEncodeCStr(pEncoder, pRsp->user) < 0) return -1; + if (tEncodeU64(pEncoder, pRsp->dbId) < 0) return -1; + if (tEncodeU64(pEncoder, pRsp->viewId) < 0) return -1; + if (tEncodeCStr(pEncoder, pRsp->querySql) < 0) return -1; + if (tEncodeI8(pEncoder, pRsp->precision) < 0) return -1; + if (tEncodeI8(pEncoder, pRsp->type) < 0) return -1; + if (tEncodeI32(pEncoder, pRsp->version) < 0) return -1; + if (tEncodeI32(pEncoder, pRsp->numOfCols) < 0) return -1; + for (int32_t i = 0; i < pRsp->numOfCols; ++i) { + SSchema *pSchema = &pRsp->pSchema[i]; + if (tEncodeSSchema(pEncoder, pSchema) < 0) return -1; + } + + return 0; +} + + +int32_t tSerializeSViewMetaRsp(void* buf, int32_t bufLen, const SViewMetaRsp* pRsp) { + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, bufLen); + + if (tStartEncode(&encoder) < 0) return -1; + if (tEncodeSViewMetaRsp(&encoder, pRsp) < 0) return -1; + + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); + return tlen; +} + +static int32_t tDecodeSViewMetaRsp(SDecoder *pDecoder, SViewMetaRsp *pRsp) { + if (tDecodeCStrTo(pDecoder, pRsp->name) < 0) return -1; + if (tDecodeCStrTo(pDecoder, pRsp->dbFName) < 0) return -1; + if (tDecodeCStrAlloc(pDecoder, &pRsp->user) < 0) return -1; + if (tDecodeU64(pDecoder, &pRsp->dbId) < 0) return -1; + if (tDecodeU64(pDecoder, &pRsp->viewId) < 0) return -1; + if (tDecodeCStrAlloc(pDecoder, &pRsp->querySql) < 0) return -1; + if (tDecodeI8(pDecoder, &pRsp->precision) < 0) return -1; + if (tDecodeI8(pDecoder, &pRsp->type) < 0) return -1; + if (tDecodeI32(pDecoder, &pRsp->version) < 0) return -1; + if (tDecodeI32(pDecoder, &pRsp->numOfCols) < 0) return -1; + if (pRsp->numOfCols > 0) { + pRsp->pSchema = taosMemoryCalloc(pRsp->numOfCols, sizeof(SSchema)); + if (pRsp->pSchema == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + + for (int32_t i = 0; i < pRsp->numOfCols; ++i) { + SSchema* pSchema = pRsp->pSchema + i; + if (tDecodeSSchema(pDecoder, pSchema) < 0) return -1; + } + } + + return 0; +} + +int32_t tDeserializeSViewMetaRsp(void* buf, int32_t bufLen, SViewMetaRsp* pRsp) { + SDecoder decoder = {0}; + tDecoderInit(&decoder, buf, bufLen); + + if (tStartDecode(&decoder) < 0) return -1; + if (tDecodeSViewMetaRsp(&decoder, pRsp) < 0) return -1; + + tEndDecode(&decoder); + + tDecoderClear(&decoder); + return 0; +} + +void tFreeSViewMetaRsp(SViewMetaRsp* pRsp) { + if (NULL == pRsp) { + return; + } + + taosMemoryFree(pRsp->user); + taosMemoryFree(pRsp->querySql); + taosMemoryFree(pRsp->pSchema); +} + +int32_t tSerializeSViewHbRsp(void *buf, int32_t bufLen, SViewHbRsp *pRsp) { + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, bufLen); + + if (tStartEncode(&encoder) < 0) return -1; + + int32_t numOfMeta = taosArrayGetSize(pRsp->pViewRsp); + if (tEncodeI32(&encoder, numOfMeta) < 0) return -1; + for (int32_t i = 0; i < numOfMeta; ++i) { + SViewMetaRsp *pMetaRsp = taosArrayGetP(pRsp->pViewRsp, i); + if (tEncodeSViewMetaRsp(&encoder, pMetaRsp) < 0) return -1; + } + + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); + return tlen; +} + +int32_t tDeserializeSViewHbRsp(void *buf, int32_t bufLen, SViewHbRsp *pRsp) { + SDecoder decoder = {0}; + tDecoderInit(&decoder, buf, bufLen); + + if (tStartDecode(&decoder) < 0) return -1; + + int32_t numOfMeta = 0; + if (tDecodeI32(&decoder, &numOfMeta) < 0) return -1; + pRsp->pViewRsp = taosArrayInit(numOfMeta, POINTER_BYTES); + if (pRsp->pViewRsp == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + + for (int32_t i = 0; i < numOfMeta; ++i) { + SViewMetaRsp* metaRsp = taosMemoryCalloc(1, sizeof(SViewMetaRsp)); + if (NULL == metaRsp) return -1; + if (tDecodeSViewMetaRsp(&decoder, metaRsp) < 0) return -1; + taosArrayPush(pRsp->pViewRsp, &metaRsp); + } + + tEndDecode(&decoder); + + tDecoderClear(&decoder); + return 0; +} + +void tFreeSViewHbRsp(SViewHbRsp *pRsp) { + int32_t numOfMeta = taosArrayGetSize(pRsp->pViewRsp); + for (int32_t i = 0; i < numOfMeta; ++i) { + SViewMetaRsp *pMetaRsp = taosArrayGetP(pRsp->pViewRsp, i); + tFreeSViewMetaRsp(pMetaRsp); + taosMemoryFree(pMetaRsp); + } + + taosArrayDestroy(pRsp->pViewRsp); +} + + + + diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c index f3f8d2a27f..737a0338ef 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c @@ -189,6 +189,9 @@ SArray *mmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_INDEX, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_INDEX, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_MND_RESTORE_DNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_VIEW, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_VIEW, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_VIEW_META, mmPutMsgToReadQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SCH_QUERY, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SCH_MERGE_QUERY, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER; diff --git a/source/dnode/mnode/impl/CMakeLists.txt b/source/dnode/mnode/impl/CMakeLists.txt index 48dc71a12b..e613fc2588 100644 --- a/source/dnode/mnode/impl/CMakeLists.txt +++ b/source/dnode/mnode/impl/CMakeLists.txt @@ -7,6 +7,7 @@ IF (TD_ENTERPRISE) LIST(APPEND MNODE_SRC ${TD_ENTERPRISE_DIR}/src/plugins/mnode/src/mndDb.c) LIST(APPEND MNODE_SRC ${TD_ENTERPRISE_DIR}/src/plugins/mnode/src/mndVgroup.c) LIST(APPEND MNODE_SRC ${TD_ENTERPRISE_DIR}/src/plugins/mnode/src/mndDnode.c) + LIST(APPEND MNODE_SRC ${TD_ENTERPRISE_DIR}/src/plugins/view/src/mndView.c) ENDIF () add_library(mnode STATIC ${MNODE_SRC}) diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index f4af2be7b0..efa99db74b 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -74,6 +74,8 @@ typedef enum { MND_OPER_SUBSCRIBE, MND_OPER_CREATE_TOPIC, MND_OPER_DROP_TOPIC, + MND_OPER_CREATE_VIEW, + MND_OPER_DROP_VIEW, } EOperType; typedef enum { @@ -297,6 +299,10 @@ typedef struct { SHashObj* topics; SHashObj* readTbs; SHashObj* writeTbs; + SHashObj* alterTbs; + SHashObj* readViews; + SHashObj* writeViews; + SHashObj* alterViews; SHashObj* useDbs; SRWLatch lock; } SUserObj; @@ -704,6 +710,34 @@ void tFreeStreamObj(SStreamObj* pObj); // SArray* childInfo; // SArray // } SStreamCheckpointObj; +#define VIEW_TYPE_UPDATABLE (1 << 0) +#define VIEW_TYPE_MATERIALIZED (1 << 1) + +typedef struct { + char fullname[TSDB_VIEW_FNAME_LEN]; + char name[TSDB_VIEW_NAME_LEN]; + char dbFName[TSDB_DB_FNAME_LEN]; + char user[TSDB_USER_LEN]; + char* querySql; + char* parameters; + void** defaultValues; + char* targetTable; + uint64_t viewId; + uint64_t dbId; + int64_t createdTime; + int32_t version; + int8_t precision; + int8_t type; + int32_t numOfCols; + SSchema* pSchema; + SRWLatch lock; +} SViewObj; + +int32_t tEncodeSViewObj(SEncoder* pEncoder, const SViewObj* pObj); +int32_t tDecodeSViewObj(SDecoder* pDecoder, SViewObj* pObj, int32_t sver); +void tFreeSViewObj(SViewObj* pObj); + + #ifdef __cplusplus } #endif diff --git a/source/dnode/mnode/impl/inc/mndPrivilege.h b/source/dnode/mnode/impl/inc/mndPrivilege.h index 3aa8a3d2d5..4a8fb20715 100644 --- a/source/dnode/mnode/impl/inc/mndPrivilege.h +++ b/source/dnode/mnode/impl/inc/mndPrivilege.h @@ -28,6 +28,7 @@ void mndCleanupPrivilege(SMnode *pMnode); int32_t mndCheckOperPrivilege(SMnode *pMnode, const char *user, EOperType operType); int32_t mndCheckDbPrivilege(SMnode *pMnode, const char *user, EOperType operType, SDbObj *pDb); int32_t mndCheckDbPrivilegeByName(SMnode *pMnode, const char *user, EOperType operType, const char *dbname); +int32_t mndCheckViewPrivilege(SMnode *pMnode, const char *user, EOperType operType, const char *pViewFName); int32_t mndCheckTopicPrivilege(SMnode *pMnode, const char *user, EOperType operType, SMqTopicObj *pTopic); int32_t mndCheckTopicPrivilegeByName(SMnode *pMnode, const char *user, EOperType operType, const char *topicName); int32_t mndCheckShowPrivilege(SMnode *pMnode, const char *user, EShowType showType, const char *dbname); diff --git a/source/dnode/mnode/impl/inc/mndUser.h b/source/dnode/mnode/impl/inc/mndUser.h index c01741b350..907ec86623 100644 --- a/source/dnode/mnode/impl/inc/mndUser.h +++ b/source/dnode/mnode/impl/inc/mndUser.h @@ -41,6 +41,7 @@ int32_t mndValidateUserAuthInfo(SMnode *pMnode, SUserAuthVersion *pUsers, int3 int32_t *pRspLen); int32_t mndUserRemoveDb(SMnode *pMnode, STrans *pTrans, char *db); int32_t mndUserRemoveStb(SMnode *pMnode, STrans *pTrans, char *stb); +int32_t mndUserRemoveView(SMnode *pMnode, STrans *pTrans, char *view); int32_t mndUserRemoveTopic(SMnode *pMnode, STrans *pTrans, char *topic); int32_t mndUserDupObj(SUserObj *pUser, SUserObj *pNew); diff --git a/source/dnode/mnode/impl/inc/mndView.h b/source/dnode/mnode/impl/inc/mndView.h new file mode 100755 index 0000000000..7ff5f0a763 --- /dev/null +++ b/source/dnode/mnode/impl/inc/mndView.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef _TD_MND_VIEW_H_ +#define _TD_MND_VIEW_H_ + +#include "mndInt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int32_t mndInitView(SMnode *pMnode); +void mndCleanupView(SMnode *pMnode); + +int32_t mndProcessCreateViewReq(SRpcMsg *pReq); +int32_t mndProcessDropViewReq(SRpcMsg *pReq); +int32_t mndProcessGetViewMetaReq(SRpcMsg *pReq); + + +#ifdef TD_ENTERPRISE + +void initDynViewVersion(void); + +SViewObj *mndAcquireView(SMnode *pMnode, char *viewName); +void mndReleaseView(SMnode *pMnode, SViewObj *pView); + +SSdbRaw *mndViewActionEncode(SViewObj *pView); +SSdbRow *mndViewActionDecode(SSdbRaw *pRaw); +int32_t mndViewActionInsert(SSdb *pSdb, SViewObj *pView); +int32_t mndViewActionDelete(SSdb *pSdb, SViewObj *pView); +int32_t mndViewActionUpdate(SSdb *pSdb, SViewObj *pOldView, SViewObj *pNewView); + +int32_t mndProcessCreateViewReqImpl(SCMCreateViewReq* pCreateView, SRpcMsg *pReq); +int32_t mndProcessDropViewReqImpl(SCMDropViewReq* pDropView, SRpcMsg *pReq); +int32_t mndProcessViewMetaReqImpl(SViewMetaReq* pMetaReq, SRpcMsg *pReq); +int32_t mndRetrieveViewImpl(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows); +int32_t mndDropViewByDb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb); +int32_t mndValidateDynViewVersion(SMnode *pMnode, SDynViewVersion* pReqVer, bool *needCheck, SDynViewVersion** ppRspVer); +int32_t mndValidateViewInfo(SMnode *pMnode, SViewVersion *pViewVersions, int32_t numOfViews, void **ppRsp, + int32_t *pRspLen); + +#endif + +int32_t mndRetrieveView(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows); +void mndCancelGetNextView(SMnode *pMnode, void *pIter); + + + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_MND_VIEW_H_*/ diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index 58c8a271bf..54f89f9bc7 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -28,6 +28,7 @@ #include "mndTrans.h" #include "mndUser.h" #include "mndVgroup.h" +#include "mndView.h" #include "systable.h" #include "tjson.h" #include "thttp.h" @@ -1262,6 +1263,9 @@ static int32_t mndDropDb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb) { /*if (mndDropSubByDB(pMnode, pTrans, pDb) != 0) goto _OVER;*/ /*if (mndDropTopicByDB(pMnode, pTrans, pDb) != 0) goto _OVER;*/ if (mndDropStreamByDb(pMnode, pTrans, pDb) != 0) goto _OVER; +#ifdef TD_ENTERPRISE + if (mndDropViewByDb(pMnode, pTrans, pDb) != 0) goto _OVER; +#endif if (mndDropSmasByDb(pMnode, pTrans, pDb) != 0) goto _OVER; if (mndDropIdxsByDb(pMnode, pTrans, pDb) != 0) goto _OVER; if (mndSetDropDbRedoActions(pMnode, pTrans, pDb) != 0) goto _OVER; diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index a9aa96720c..7de6e860f9 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -1018,7 +1018,7 @@ static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq) { char obj[200] = {0}; sprintf(obj, "%s:%d", createReq.fqdn, createReq.port); - auditRecord(pReq, pMnode->clusterId, "createDnode", obj, "", createReq.sql, createReq.sqlLen); + auditRecord(pReq, pMnode->clusterId, "createDnode", "", obj, createReq.sql, createReq.sqlLen); _OVER: if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) { @@ -1167,7 +1167,7 @@ static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) { char obj1[30] = {0}; sprintf(obj1, "%d", dropReq.dnodeId); - auditRecord(pReq, pMnode->clusterId, "dropDnode", obj1, "", dropReq.sql, dropReq.sqlLen); + auditRecord(pReq, pMnode->clusterId, "dropDnode", "", obj1, dropReq.sql, dropReq.sqlLen); _OVER: if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) { @@ -1368,7 +1368,7 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) { char obj[50] = {0}; sprintf(obj, "%d", cfgReq.dnodeId); - auditRecord(pReq, pMnode->clusterId, "alterDnode", obj, "", cfgReq.sql, cfgReq.sqlLen); + auditRecord(pReq, pMnode->clusterId, "alterDnode", "", obj, cfgReq.sql, cfgReq.sqlLen); tFreeSMCfgDnodeReq(&cfgReq); diff --git a/source/dnode/mnode/impl/src/mndInfoSchema.c b/source/dnode/mnode/impl/src/mndInfoSchema.c index f17df28129..689da5a855 100644 --- a/source/dnode/mnode/impl/src/mndInfoSchema.c +++ b/source/dnode/mnode/impl/src/mndInfoSchema.c @@ -78,7 +78,7 @@ int32_t mndBuildInsTableSchema(SMnode *pMnode, const char *dbFName, const char * STableMetaRsp *pMeta = taosHashGet(pMnode->infosMeta, tbName, strlen(tbName)); if (NULL == pMeta) { mError("invalid information schema table name:%s", tbName); - terrno = TSDB_CODE_MND_INVALID_SYS_TABLENAME; + terrno = TSDB_CODE_PAR_TABLE_NOT_EXIST; return -1; } @@ -111,7 +111,7 @@ int32_t mndBuildInsTableCfg(SMnode *pMnode, const char *dbFName, const char *tbN STableMetaRsp *pMeta = taosHashGet(pMnode->infosMeta, tbName, strlen(tbName)); if (NULL == pMeta) { mError("invalid information schema table name:%s", tbName); - terrno = TSDB_CODE_MND_INVALID_SYS_TABLENAME; + terrno = TSDB_CODE_PAR_TABLE_NOT_EXIST; return -1; } diff --git a/source/dnode/mnode/impl/src/mndMain.c b/source/dnode/mnode/impl/src/mndMain.c index 08ad6cc909..8d00dfefb6 100644 --- a/source/dnode/mnode/impl/src/mndMain.c +++ b/source/dnode/mnode/impl/src/mndMain.c @@ -41,6 +41,7 @@ #include "mndTrans.h" #include "mndUser.h" #include "mndVgroup.h" +#include "mndView.h" static inline int32_t mndAcquireRpc(SMnode *pMnode) { int32_t code = 0; @@ -447,6 +448,7 @@ static int32_t mndInitSteps(SMnode *pMnode) { if (mndAllocStep(pMnode, "mnode-perfs", mndInitPerfs, mndCleanupPerfs) != 0) return -1; if (mndAllocStep(pMnode, "mnode-db", mndInitDb, mndCleanupDb) != 0) return -1; if (mndAllocStep(pMnode, "mnode-func", mndInitFunc, mndCleanupFunc) != 0) return -1; + if (mndAllocStep(pMnode, "mnode-view", mndInitView, mndCleanupView) != 0) return -1; if (mndAllocStep(pMnode, "mnode-sdb", mndOpenSdb, NULL) != 0) return -1; if (mndAllocStep(pMnode, "mnode-profile", mndInitProfile, mndCleanupProfile) != 0) return -1; if (mndAllocStep(pMnode, "mnode-show", mndInitShow, mndCleanupShow) != 0) return -1; diff --git a/source/dnode/mnode/impl/src/mndMnode.c b/source/dnode/mnode/impl/src/mndMnode.c index 22b2fec857..5a09072577 100644 --- a/source/dnode/mnode/impl/src/mndMnode.c +++ b/source/dnode/mnode/impl/src/mndMnode.c @@ -656,7 +656,7 @@ static int32_t mndProcessCreateMnodeReq(SRpcMsg *pReq) { char obj[40] = {0}; sprintf(obj, "%d", createReq.dnodeId); - auditRecord(pReq, pMnode->clusterId, "createMnode", obj, "", createReq.sql, createReq.sqlLen); + auditRecord(pReq, pMnode->clusterId, "createMnode", "", obj, createReq.sql, createReq.sqlLen); _OVER: if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) { @@ -798,7 +798,7 @@ static int32_t mndProcessDropMnodeReq(SRpcMsg *pReq) { char obj[40] = {0}; sprintf(obj, "%d", dropReq.dnodeId); - auditRecord(pReq, pMnode->clusterId, "dropMnode", obj, "", dropReq.sql, dropReq.sqlLen); + auditRecord(pReq, pMnode->clusterId, "dropMnode", "", obj, dropReq.sql, dropReq.sqlLen); _OVER: if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) { diff --git a/source/dnode/mnode/impl/src/mndPerfSchema.c b/source/dnode/mnode/impl/src/mndPerfSchema.c index cf463304a1..33dc63bdf4 100644 --- a/source/dnode/mnode/impl/src/mndPerfSchema.c +++ b/source/dnode/mnode/impl/src/mndPerfSchema.c @@ -75,7 +75,7 @@ int32_t mndBuildPerfsTableSchema(SMnode *pMnode, const char *dbFName, const char STableMetaRsp *meta = (STableMetaRsp *)taosHashGet(pMnode->perfsMeta, tbName, strlen(tbName)); if (NULL == meta) { mError("invalid performance schema table name:%s", tbName); - terrno = TSDB_CODE_MND_INVALID_SYS_TABLENAME; + terrno = TSDB_CODE_PAR_TABLE_NOT_EXIST; return -1; } @@ -101,7 +101,7 @@ int32_t mndBuildPerfsTableCfg(SMnode *pMnode, const char *dbFName, const char *t STableMetaRsp *pMeta = taosHashGet(pMnode->perfsMeta, tbName, strlen(tbName)); if (NULL == pMeta) { mError("invalid performance schema table name:%s", tbName); - terrno = TSDB_CODE_MND_INVALID_SYS_TABLENAME; + terrno = TSDB_CODE_PAR_TABLE_NOT_EXIST; return -1; } diff --git a/source/dnode/mnode/impl/src/mndProfile.c b/source/dnode/mnode/impl/src/mndProfile.c index 6b54ec2ebf..471ed99b67 100644 --- a/source/dnode/mnode/impl/src/mndProfile.c +++ b/source/dnode/mnode/impl/src/mndProfile.c @@ -23,6 +23,7 @@ #include "mndShow.h" #include "mndStb.h" #include "mndUser.h" +#include "mndView.h" #include "tglobal.h" #include "tversion.h" #include "audit.h" @@ -311,13 +312,10 @@ _CONNECT: code = 0; - char obj[100] = {0}; - sprintf(obj, "%s:%d", ip, pConn->port); - char detail[1000] = {0}; - sprintf(detail, "app:%s", connReq.app); + sprintf(detail, "%s:%d, app:%s", ip, pConn->port, connReq.app); - auditRecord(pReq, pMnode->clusterId, "login", connReq.user, obj, detail, strlen(detail)); + auditRecord(pReq, pMnode->clusterId, "login", "", "", detail, strlen(detail)); _OVER: @@ -466,7 +464,9 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb SClientHbRsp hbRsp = {.connKey = pHbReq->connKey, .status = 0, .info = NULL, .query = NULL}; SRpcConnInfo connInfo = pMsg->info.conn; - mndUpdateAppInfo(pMnode, pHbReq, &connInfo); + if (0 != pHbReq->app.appId) { + mndUpdateAppInfo(pMnode, pHbReq, &connInfo); + } if (pHbReq->query) { SQueryHbReqBasic *pBasic = pHbReq->query; @@ -529,6 +529,28 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb return -1; } +#ifdef TD_ENTERPRISE + bool needCheck = true; + int32_t key = HEARTBEAT_KEY_DYN_VIEW; + SDynViewVersion* pDynViewVer = NULL; + SKv* pKv = taosHashGet(pHbReq->info, &key, sizeof(key)); + if (NULL != pKv) { + pDynViewVer = pKv->value; + mTrace("recv view dyn ver, bootTs:%" PRId64 ", ver:%" PRIu64, pDynViewVer->svrBootTs, pDynViewVer->dynViewVer); + + SDynViewVersion* pRspVer = NULL; + if (0 != mndValidateDynViewVersion(pMnode, pDynViewVer, &needCheck, &pRspVer)) { + return -1; + } + + if (needCheck) { + SKv kv1 = {.key = HEARTBEAT_KEY_DYN_VIEW, .valueLen = sizeof(*pDynViewVer), .value = pRspVer}; + taosArrayPush(hbRsp.info, &kv1); + mTrace("need to check view ver, lastest bootTs:%" PRId64 ", ver:%" PRIu64, pRspVer->svrBootTs, pRspVer->dynViewVer); + } + } +#endif + void *pIter = taosHashIterate(pHbReq->info, NULL); while (pIter != NULL) { SKv *kv = pIter; @@ -564,6 +586,25 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb } break; } +#ifdef TD_ENTERPRISE + case HEARTBEAT_KEY_DYN_VIEW: { + break; + } + case HEARTBEAT_KEY_VIEWINFO: { + if (!needCheck) { + break; + } + + void *rspMsg = NULL; + int32_t rspLen = 0; + mndValidateViewInfo(pMnode, kv->value, kv->valueLen / sizeof(SViewVersion), &rspMsg, &rspLen); + if (rspMsg && rspLen > 0) { + SKv kv1 = {.key = HEARTBEAT_KEY_VIEWINFO, .valueLen = rspLen, .value = rspMsg}; + taosArrayPush(hbRsp.info, &kv1); + } + break; + } +#endif default: mError("invalid kv key:%d", kv->key); hbRsp.status = TSDB_CODE_APP_ERROR; diff --git a/source/dnode/mnode/impl/src/mndQnode.c b/source/dnode/mnode/impl/src/mndQnode.c index af11476d64..a7d8c81d3f 100644 --- a/source/dnode/mnode/impl/src/mndQnode.c +++ b/source/dnode/mnode/impl/src/mndQnode.c @@ -310,7 +310,7 @@ static int32_t mndProcessCreateQnodeReq(SRpcMsg *pReq) { char obj[33] = {0}; sprintf(obj, "%d", createReq.dnodeId); - auditRecord(pReq, pMnode->clusterId, "createQnode", obj, "", createReq.sql, createReq.sqlLen); + auditRecord(pReq, pMnode->clusterId, "createQnode", "", obj, createReq.sql, createReq.sqlLen); _OVER: if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) { mError("qnode:%d, failed to create since %s", createReq.dnodeId, terrstr()); @@ -424,7 +424,7 @@ static int32_t mndProcessDropQnodeReq(SRpcMsg *pReq) { char obj[33] = {0}; sprintf(obj, "%d", dropReq.dnodeId); - auditRecord(pReq, pMnode->clusterId, "dropQnode", obj, "", dropReq.sql, dropReq.sqlLen); + auditRecord(pReq, pMnode->clusterId, "dropQnode", "", obj, dropReq.sql, dropReq.sqlLen); _OVER: if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) { diff --git a/source/dnode/mnode/impl/src/mndScheduler.c b/source/dnode/mnode/impl/src/mndScheduler.c index 404198a523..88a06cb513 100644 --- a/source/dnode/mnode/impl/src/mndScheduler.c +++ b/source/dnode/mnode/impl/src/mndScheduler.c @@ -728,7 +728,7 @@ int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscrib pVgEp->vgId = pVgroup->vgId; taosArrayPush(pSub->unassignedVgs, &pVgEp); - mDebug("init subscription %s for topic:%s assign vgId:%d", pSub->key, pTopic->name, pVgEp->vgId); + mInfo("init subscription %s for topic:%s assign vgId:%d", pSub->key, pTopic->name, pVgEp->vgId); sdbRelease(pSdb, pVgroup); } diff --git a/source/dnode/mnode/impl/src/mndShow.c b/source/dnode/mnode/impl/src/mndShow.c index 2286186ebb..bdf7df25e1 100644 --- a/source/dnode/mnode/impl/src/mndShow.c +++ b/source/dnode/mnode/impl/src/mndShow.c @@ -116,6 +116,8 @@ static int32_t convertToRetrieveType(char *name, int32_t len) { type = TSDB_MGMT_TABLE_STREAM_TASKS; } else if (strncasecmp(name, TSDB_INS_TABLE_USER_PRIVILEGES, len) == 0) { type = TSDB_MGMT_TABLE_PRIVILEGES; + } else if (strncasecmp(name, TSDB_INS_TABLE_VIEWS, len) == 0) { + type = TSDB_MGMT_TABLE_VIEWS; } else { mError("invalid show name:%s len:%d", name, len); } @@ -211,7 +213,7 @@ static int32_t mndProcessRetrieveSysTableReq(SRpcMsg *pReq) { if (pMeta == NULL) { pMeta = taosHashGet(pMnode->perfsMeta, retrieveReq.tb, strlen(retrieveReq.tb)); if (pMeta == NULL) { - terrno = TSDB_CODE_MND_INVALID_SYS_TABLENAME; + terrno = TSDB_CODE_PAR_TABLE_NOT_EXIST; mError("failed to process show-retrieve req:%p since %s", pShow, terrstr()); return -1; } diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 16825d73b1..1b21d4a017 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -1903,8 +1903,51 @@ static int32_t mndBuildStbCfgImp(SDbObj *pDb, SStbObj *pStb, const char *tbName, return 0; } -static int32_t mndBuildStbSchema(SMnode *pMnode, const char *dbFName, const char *tbName, STableMetaRsp *pRsp, - int32_t *smaVer) { +static int32_t mndValidateStbVersion(SMnode *pMnode, SSTableVersion* pStbVer, bool* schema, bool* sma) { + char tbFName[TSDB_TABLE_FNAME_LEN] = {0}; + snprintf(tbFName, sizeof(tbFName), "%s.%s", pStbVer->dbFName, pStbVer->stbName); + + SDbObj *pDb = mndAcquireDb(pMnode, pStbVer->dbFName); + if (pDb == NULL) { + terrno = TSDB_CODE_MND_DB_NOT_SELECTED; + return -1; + } + + if (pDb->uid != pStbVer->dbId) { + mndReleaseDb(pMnode, pDb); + terrno = TSDB_CODE_MND_DB_NOT_SELECTED; + return -1; + } + + SStbObj *pStb = mndAcquireStb(pMnode, tbFName); + if (pStb == NULL) { + mndReleaseDb(pMnode, pDb); + terrno = TSDB_CODE_PAR_TABLE_NOT_EXIST; + return -1; + } + + taosRLockLatch(&pStb->lock); + + if (pStbVer->sversion != pStb->colVer || pStbVer->tversion != pStb->tagVer) { + *schema = true; + } else { + *schema = false; + } + + if (pStbVer->smaVer && pStbVer->smaVer != pStb->smaVer) { + *sma = true; + } else { + *sma = false; + } + + taosRUnLockLatch(&pStb->lock); + + mndReleaseDb(pMnode, pDb); + mndReleaseStb(pMnode, pStb); + return TSDB_CODE_SUCCESS; +} + +static int32_t mndBuildStbSchema(SMnode *pMnode, const char *dbFName, const char *tbName, STableMetaRsp *pRsp) { char tbFName[TSDB_TABLE_FNAME_LEN] = {0}; snprintf(tbFName, sizeof(tbFName), "%s.%s", dbFName, tbName); @@ -1921,10 +1964,6 @@ static int32_t mndBuildStbSchema(SMnode *pMnode, const char *dbFName, const char return -1; } - if (smaVer) { - *smaVer = pStb->smaVer; - } - int32_t code = mndBuildStbSchemaImp(pDb, pStb, tbName, pRsp); mndReleaseDb(pMnode, pDb); mndReleaseStb(pMnode, pStb); @@ -2563,7 +2602,7 @@ static int32_t mndProcessTableMetaReq(SRpcMsg *pReq) { } } else { mInfo("stb:%s.%s, start to retrieve meta", infoReq.dbFName, infoReq.tbName); - if (mndBuildStbSchema(pMnode, infoReq.dbFName, infoReq.tbName, &metaRsp, NULL) != 0) { + if (mndBuildStbSchema(pMnode, infoReq.dbFName, infoReq.tbName, &metaRsp) != 0) { goto _OVER; } } @@ -2674,14 +2713,15 @@ int32_t mndValidateStbInfo(SMnode *pMnode, SSTableVersion *pStbVersions, int32_t for (int32_t i = 0; i < numOfStbs; ++i) { SSTableVersion *pStbVersion = &pStbVersions[i]; pStbVersion->suid = be64toh(pStbVersion->suid); - pStbVersion->sversion = ntohs(pStbVersion->sversion); - pStbVersion->tversion = ntohs(pStbVersion->tversion); + pStbVersion->sversion = ntohl(pStbVersion->sversion); + pStbVersion->tversion = ntohl(pStbVersion->tversion); pStbVersion->smaVer = ntohl(pStbVersion->smaVer); - STableMetaRsp metaRsp = {0}; - int32_t smaVer = 0; - mInfo("stb:%s.%s, start to retrieve meta", pStbVersion->dbFName, pStbVersion->stbName); - if (mndBuildStbSchema(pMnode, pStbVersion->dbFName, pStbVersion->stbName, &metaRsp, &smaVer) != 0) { + bool schema = false; + bool sma = false; + int32_t code = mndValidateStbVersion(pMnode, pStbVersion, &schema, &sma); + if (TSDB_CODE_SUCCESS != code) { + STableMetaRsp metaRsp = {0}; metaRsp.numOfColumns = -1; metaRsp.suid = pStbVersion->suid; tstrncpy(metaRsp.dbFName, pStbVersion->dbFName, sizeof(metaRsp.dbFName)); @@ -2691,13 +2731,23 @@ int32_t mndValidateStbInfo(SMnode *pMnode, SSTableVersion *pStbVersions, int32_t continue; } - if (pStbVersion->sversion != metaRsp.sversion || pStbVersion->tversion != metaRsp.tversion) { + if (schema) { + STableMetaRsp metaRsp = {0}; + mInfo("stb:%s.%s, start to retrieve meta", pStbVersion->dbFName, pStbVersion->stbName); + if (mndBuildStbSchema(pMnode, pStbVersion->dbFName, pStbVersion->stbName, &metaRsp) != 0) { + metaRsp.numOfColumns = -1; + metaRsp.suid = pStbVersion->suid; + tstrncpy(metaRsp.dbFName, pStbVersion->dbFName, sizeof(metaRsp.dbFName)); + tstrncpy(metaRsp.tbName, pStbVersion->stbName, sizeof(metaRsp.tbName)); + tstrncpy(metaRsp.stbName, pStbVersion->stbName, sizeof(metaRsp.stbName)); + taosArrayPush(hbRsp.pMetaRsp, &metaRsp); + continue; + } + taosArrayPush(hbRsp.pMetaRsp, &metaRsp); - } else { - tFreeSTableMetaRsp(&metaRsp); } - if (pStbVersion->smaVer && pStbVersion->smaVer != smaVer) { + if (sma) { bool exist = false; char tbFName[TSDB_TABLE_FNAME_LEN]; STableIndexRsp indexRsp = {0}; diff --git a/source/dnode/mnode/impl/src/mndStream.c b/source/dnode/mnode/impl/src/mndStream.c index 6f78f99302..fd0c349dd2 100644 --- a/source/dnode/mnode/impl/src/mndStream.c +++ b/source/dnode/mnode/impl/src/mndStream.c @@ -857,12 +857,12 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) { code = TSDB_CODE_ACTION_IN_PROGRESS; SName name = {0}; - tNameFromString(&name, createStreamReq.name, T_NAME_ACCT | T_NAME_DB); + tNameFromString(&name, createStreamReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); //reuse this function for stream //TODO if (createStreamReq.sql != NULL) { - auditRecord(pReq, pMnode->clusterId, "createStream", name.dbname, "", + auditRecord(pReq, pMnode->clusterId, "createStream", name.dbname, name.tname, createStreamReq.sql, strlen(createStreamReq.sql)); } _OVER: @@ -1326,10 +1326,10 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) { removeStreamTasksInBuf(pStream, &execInfo); SName name = {0}; - tNameFromString(&name, dropReq.name, T_NAME_ACCT | T_NAME_DB); + tNameFromString(&name, dropReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); //reuse this function for stream - auditRecord(pReq, pMnode->clusterId, "dropStream", name.dbname, "", dropReq.sql, dropReq.sqlLen); + auditRecord(pReq, pMnode->clusterId, "dropStream", name.dbname, name.tname, dropReq.sql, dropReq.sqlLen); sdbRelease(pMnode->pSdb, pStream); mndTransDrop(pTrans); diff --git a/source/dnode/mnode/impl/src/mndTopic.c b/source/dnode/mnode/impl/src/mndTopic.c index 1e91fe4919..0d23db09e5 100644 --- a/source/dnode/mnode/impl/src/mndTopic.c +++ b/source/dnode/mnode/impl/src/mndTopic.c @@ -611,10 +611,10 @@ static int32_t mndProcessCreateTopicReq(SRpcMsg *pReq) { tNameFromString(&dbname, createTopicReq.subDbName, T_NAME_ACCT | T_NAME_DB); SName topicName = {0}; - tNameFromString(&topicName, createTopicReq.name, T_NAME_ACCT | T_NAME_DB); + tNameFromString(&topicName, createTopicReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); //reuse this function for topic - auditRecord(pReq, pMnode->clusterId, "createTopic", topicName.dbname, dbname.dbname, + auditRecord(pReq, pMnode->clusterId, "createTopic", dbname.dbname, topicName.dbname, createTopicReq.sql, strlen(createTopicReq.sql)); _OVER: @@ -817,10 +817,10 @@ end: } SName name = {0}; - tNameFromString(&name, dropReq.name, T_NAME_ACCT | T_NAME_DB); + tNameFromString(&name, dropReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); //reuse this function for topic - auditRecord(pReq, pMnode->clusterId, "dropTopic", name.dbname, "", dropReq.sql, dropReq.sqlLen); + auditRecord(pReq, pMnode->clusterId, "dropTopic", name.dbname, name.tname, dropReq.sql, dropReq.sqlLen); tFreeSMDropTopicReq(&dropReq); diff --git a/source/dnode/mnode/impl/src/mndTrans.c b/source/dnode/mnode/impl/src/mndTrans.c index 29a8ae1f29..d845d87427 100644 --- a/source/dnode/mnode/impl/src/mndTrans.c +++ b/source/dnode/mnode/impl/src/mndTrans.c @@ -720,7 +720,7 @@ int32_t mndSetRpcInfoForDbTrans(SMnode *pMnode, SRpcMsg *pMsg, EOperType oper, c void mndTransSetDbName(STrans *pTrans, const char *dbname, const char *stbname) { if (dbname != NULL) { - tstrncpy(pTrans->dbname, dbname, TSDB_TABLE_FNAME_LEN); + tstrncpy(pTrans->dbname, dbname, TSDB_DB_FNAME_LEN); } if (stbname != NULL) { tstrncpy(pTrans->stbname, stbname, TSDB_TABLE_FNAME_LEN); diff --git a/source/dnode/mnode/impl/src/mndUser.c b/source/dnode/mnode/impl/src/mndUser.c index 2789f5a9d4..585263ef95 100644 --- a/source/dnode/mnode/impl/src/mndUser.c +++ b/source/dnode/mnode/impl/src/mndUser.c @@ -28,9 +28,53 @@ // clang-format on -#define USER_VER_NUMBER 5 +#define USER_VER_NUMBER 6 #define USER_RESERVE_SIZE 64 +#define BIT_FLAG_MASK(n) (1 << n) +#define BIT_FLAG_SET_MASK(val, mask) ((val) |= (mask)) +#define BIT_FLAG_TEST_MASK(val, mask) (((val) & (mask)) != 0) + +#define PRIVILEGE_TYPE_ALL BIT_FLAG_MASK(0) +#define PRIVILEGE_TYPE_READ BIT_FLAG_MASK(1) +#define PRIVILEGE_TYPE_WRITE BIT_FLAG_MASK(2) +#define PRIVILEGE_TYPE_SUBSCRIBE BIT_FLAG_MASK(3) +#define PRIVILEGE_TYPE_ALTER BIT_FLAG_MASK(4) + +#define ALTER_USER_ADD_PRIVS(_type) ((_type) == TSDB_ALTER_USER_ADD_PRIVILEGES) +#define ALTER_USER_DEL_PRIVS(_type) ((_type) == TSDB_ALTER_USER_DEL_PRIVILEGES) + +#define ALTER_USER_ALL_PRIV(_priv) (BIT_FLAG_TEST_MASK((_priv), PRIVILEGE_TYPE_ALL)) +#define ALTER_USER_READ_PRIV(_priv) (BIT_FLAG_TEST_MASK((_priv), PRIVILEGE_TYPE_READ) || BIT_FLAG_TEST_MASK((_priv), PRIVILEGE_TYPE_ALL)) +#define ALTER_USER_WRITE_PRIV(_priv) (BIT_FLAG_TEST_MASK((_priv), PRIVILEGE_TYPE_WRITE) || BIT_FLAG_TEST_MASK((_priv), PRIVILEGE_TYPE_ALL)) +#define ALTER_USER_ALTER_PRIV(_priv) (BIT_FLAG_TEST_MASK((_priv), PRIVILEGE_TYPE_ALTER) || BIT_FLAG_TEST_MASK((_priv), PRIVILEGE_TYPE_ALL)) +#define ALTER_USER_SUBSCRIBE_PRIV(_priv) (BIT_FLAG_TEST_MASK((_priv), PRIVILEGE_TYPE_SUBSCRIBE)) + +#define ALTER_USER_TARGET_DB(_tbname) (0 == (_tbname)[0]) +#define ALTER_USER_TARGET_TB(_tbname) (0 != (_tbname)[0]) + +#define ALTER_USER_ADD_READ_DB_PRIV(_type, _priv, _tbname) (ALTER_USER_ADD_PRIVS(_type) && ALTER_USER_READ_PRIV(_priv) && ALTER_USER_TARGET_DB(_tbname)) +#define ALTER_USER_DEL_READ_DB_PRIV(_type, _priv, _tbname) (ALTER_USER_DEL_PRIVS(_type) && ALTER_USER_READ_PRIV(_priv) && ALTER_USER_TARGET_DB(_tbname)) +#define ALTER_USER_ADD_WRITE_DB_PRIV(_type, _priv, _tbname) (ALTER_USER_ADD_PRIVS(_type) && ALTER_USER_WRITE_PRIV(_priv) && ALTER_USER_TARGET_DB(_tbname)) +#define ALTER_USER_DEL_WRITE_DB_PRIV(_type, _priv, _tbname) (ALTER_USER_DEL_PRIVS(_type) && ALTER_USER_WRITE_PRIV(_priv) && ALTER_USER_TARGET_DB(_tbname)) +#define ALTER_USER_ADD_ALTER_DB_PRIV(_type, _priv, _tbname) (ALTER_USER_ADD_PRIVS(_type) && ALTER_USER_ALTER_PRIV(_priv) && ALTER_USER_TARGET_DB(_tbname)) +#define ALTER_USER_DEL_ALTER_DB_PRIV(_type, _priv, _tbname) (ALTER_USER_DEL_PRIVS(_type) && ALTER_USER_ALTER_PRIV(_priv) && ALTER_USER_TARGET_DB(_tbname)) +#define ALTER_USER_ADD_ALL_DB_PRIV(_type, _priv, _tbname) (ALTER_USER_ADD_PRIVS(_type) && ALTER_USER_ALL_PRIV(_priv) && ALTER_USER_TARGET_DB(_tbname)) +#define ALTER_USER_DEL_ALL_DB_PRIV(_type, _priv, _tbname) (ALTER_USER_DEL_PRIVS(_type) && ALTER_USER_ALL_PRIV(_priv) && ALTER_USER_TARGET_DB(_tbname)) + +#define ALTER_USER_ADD_READ_TB_PRIV(_type, _priv, _tbname) (ALTER_USER_ADD_PRIVS(_type) && ALTER_USER_READ_PRIV(_priv) && ALTER_USER_TARGET_TB(_tbname)) +#define ALTER_USER_DEL_READ_TB_PRIV(_type, _priv, _tbname) (ALTER_USER_DEL_PRIVS(_type) && ALTER_USER_READ_PRIV(_priv) && ALTER_USER_TARGET_TB(_tbname)) +#define ALTER_USER_ADD_WRITE_TB_PRIV(_type, _priv, _tbname) (ALTER_USER_ADD_PRIVS(_type) && ALTER_USER_WRITE_PRIV(_priv) && ALTER_USER_TARGET_TB(_tbname)) +#define ALTER_USER_DEL_WRITE_TB_PRIV(_type, _priv, _tbname) (ALTER_USER_DEL_PRIVS(_type) && ALTER_USER_WRITE_PRIV(_priv) && ALTER_USER_TARGET_TB(_tbname)) +#define ALTER_USER_ADD_ALTER_TB_PRIV(_type, _priv, _tbname) (ALTER_USER_ADD_PRIVS(_type) && ALTER_USER_ALTER_PRIV(_priv) && ALTER_USER_TARGET_TB(_tbname)) +#define ALTER_USER_DEL_ALTER_TB_PRIV(_type, _priv, _tbname) (ALTER_USER_DEL_PRIVS(_type) && ALTER_USER_ALTER_PRIV(_priv) && ALTER_USER_TARGET_TB(_tbname)) +#define ALTER_USER_ADD_ALL_TB_PRIV(_type, _priv, _tbname) (ALTER_USER_ADD_PRIVS(_type) && ALTER_USER_ALL_PRIV(_priv) && ALTER_USER_TARGET_TB(_tbname)) +#define ALTER_USER_DEL_ALL_TB_PRIV(_type, _priv, _tbname) (ALTER_USER_DEL_PRIVS(_type) && ALTER_USER_ALL_PRIV(_priv) && ALTER_USER_TARGET_TB(_tbname)) + +#define ALTER_USER_ADD_SUBSCRIBE_TOPIC_PRIV(_type, _priv) (ALTER_USER_ADD_PRIVS(_type) && ALTER_USER_SUBSCRIBE_PRIV(_priv)) +#define ALTER_USER_DEL_SUBSCRIBE_TOPIC_PRIV(_type, _priv) (ALTER_USER_DEL_PRIVS(_type) && ALTER_USER_SUBSCRIBE_PRIV(_priv)) + + static SIpWhiteList *createDefaultIpWhiteList(); SIpWhiteList *createIpWhiteList(void *buf, int32_t len); static bool updateIpWhiteList(SIpWhiteList *pOld, SIpWhiteList *pNew); @@ -656,8 +700,12 @@ SSdbRaw *mndUserActionEncode(SUserObj *pUser) { pUser->pIpWhiteList ? (sizeof(SIpV4Range) * pUser->pIpWhiteList->num + sizeof(SIpWhiteList) + 4) : 16; int32_t numOfReadDbs = taosHashGetSize(pUser->readDbs); int32_t numOfWriteDbs = taosHashGetSize(pUser->writeDbs); - int32_t numOfReadStbs = taosHashGetSize(pUser->readTbs); - int32_t numOfWriteStbs = taosHashGetSize(pUser->writeTbs); + int32_t numOfReadTbs = taosHashGetSize(pUser->readTbs); + int32_t numOfWriteTbs = taosHashGetSize(pUser->writeTbs); + int32_t numOfAlterTbs = taosHashGetSize(pUser->alterTbs); + int32_t numOfReadViews = taosHashGetSize(pUser->readViews); + int32_t numOfWriteViews = taosHashGetSize(pUser->writeViews); + int32_t numOfAlterViews = taosHashGetSize(pUser->alterViews); int32_t numOfTopics = taosHashGetSize(pUser->topics); int32_t numOfUseDbs = taosHashGetSize(pUser->useDbs); int32_t size = sizeof(SUserObj) + USER_RESERVE_SIZE + @@ -692,6 +740,62 @@ SSdbRaw *mndUserActionEncode(SUserObj *pUser) { stb = taosHashIterate(pUser->writeTbs, stb); } + stb = taosHashIterate(pUser->alterTbs, NULL); + while (stb != NULL) { + size_t keyLen = 0; + void *key = taosHashGetKey(stb, &keyLen); + size += sizeof(int32_t); + size += keyLen; + + size_t valueLen = 0; + valueLen = strlen(stb); + size += sizeof(int32_t); + size += valueLen; + stb = taosHashIterate(pUser->alterTbs, stb); + } + + stb = taosHashIterate(pUser->readViews, NULL); + while (stb != NULL) { + size_t keyLen = 0; + void *key = taosHashGetKey(stb, &keyLen); + size += sizeof(int32_t); + size += keyLen; + + size_t valueLen = 0; + valueLen = strlen(stb); + size += sizeof(int32_t); + size += valueLen; + stb = taosHashIterate(pUser->readViews, stb); + } + + stb = taosHashIterate(pUser->writeViews, NULL); + while (stb != NULL) { + size_t keyLen = 0; + void *key = taosHashGetKey(stb, &keyLen); + size += sizeof(int32_t); + size += keyLen; + + size_t valueLen = 0; + valueLen = strlen(stb); + size += sizeof(int32_t); + size += valueLen; + stb = taosHashIterate(pUser->writeViews, stb); + } + + stb = taosHashIterate(pUser->alterViews, NULL); + while (stb != NULL) { + size_t keyLen = 0; + void *key = taosHashGetKey(stb, &keyLen); + size += sizeof(int32_t); + size += keyLen; + + size_t valueLen = 0; + valueLen = strlen(stb); + size += sizeof(int32_t); + size += valueLen; + stb = taosHashIterate(pUser->alterViews, stb); + } + SSdbRaw *pRaw = sdbAllocRaw(SDB_USER, USER_VER_NUMBER, size); if (pRaw == NULL) goto _OVER; @@ -729,8 +833,12 @@ SSdbRaw *mndUserActionEncode(SUserObj *pUser) { topic = taosHashIterate(pUser->topics, topic); } - SDB_SET_INT32(pRaw, dataPos, numOfReadStbs, _OVER) - SDB_SET_INT32(pRaw, dataPos, numOfWriteStbs, _OVER) + SDB_SET_INT32(pRaw, dataPos, numOfReadTbs, _OVER) + SDB_SET_INT32(pRaw, dataPos, numOfWriteTbs, _OVER) + SDB_SET_INT32(pRaw, dataPos, numOfAlterTbs, _OVER) + SDB_SET_INT32(pRaw, dataPos, numOfReadViews, _OVER) + SDB_SET_INT32(pRaw, dataPos, numOfWriteViews, _OVER) + SDB_SET_INT32(pRaw, dataPos, numOfAlterViews, _OVER) SDB_SET_INT32(pRaw, dataPos, numOfUseDbs, _OVER) stb = taosHashIterate(pUser->readTbs, NULL); @@ -761,6 +869,62 @@ SSdbRaw *mndUserActionEncode(SUserObj *pUser) { stb = taosHashIterate(pUser->writeTbs, stb); } + stb = taosHashIterate(pUser->alterTbs, NULL); + while (stb != NULL) { + size_t keyLen = 0; + void *key = taosHashGetKey(stb, &keyLen); + SDB_SET_INT32(pRaw, dataPos, keyLen, _OVER) + SDB_SET_BINARY(pRaw, dataPos, key, keyLen, _OVER); + + size_t valueLen = 0; + valueLen = strlen(stb) + 1; + SDB_SET_INT32(pRaw, dataPos, valueLen, _OVER) + SDB_SET_BINARY(pRaw, dataPos, stb, valueLen, _OVER); + stb = taosHashIterate(pUser->alterTbs, stb); + } + + stb = taosHashIterate(pUser->readViews, NULL); + while (stb != NULL) { + size_t keyLen = 0; + void *key = taosHashGetKey(stb, &keyLen); + SDB_SET_INT32(pRaw, dataPos, keyLen, _OVER) + SDB_SET_BINARY(pRaw, dataPos, key, keyLen, _OVER); + + size_t valueLen = 0; + valueLen = strlen(stb) + 1; + SDB_SET_INT32(pRaw, dataPos, valueLen, _OVER) + SDB_SET_BINARY(pRaw, dataPos, stb, valueLen, _OVER); + stb = taosHashIterate(pUser->readViews, stb); + } + + stb = taosHashIterate(pUser->writeViews, NULL); + while (stb != NULL) { + size_t keyLen = 0; + void *key = taosHashGetKey(stb, &keyLen); + SDB_SET_INT32(pRaw, dataPos, keyLen, _OVER) + SDB_SET_BINARY(pRaw, dataPos, key, keyLen, _OVER); + + size_t valueLen = 0; + valueLen = strlen(stb) + 1; + SDB_SET_INT32(pRaw, dataPos, valueLen, _OVER) + SDB_SET_BINARY(pRaw, dataPos, stb, valueLen, _OVER); + stb = taosHashIterate(pUser->writeViews, stb); + } + + stb = taosHashIterate(pUser->alterViews, NULL); + while (stb != NULL) { + size_t keyLen = 0; + void *key = taosHashGetKey(stb, &keyLen); + SDB_SET_INT32(pRaw, dataPos, keyLen, _OVER) + SDB_SET_BINARY(pRaw, dataPos, key, keyLen, _OVER); + + size_t valueLen = 0; + valueLen = strlen(stb) + 1; + SDB_SET_INT32(pRaw, dataPos, valueLen, _OVER) + SDB_SET_BINARY(pRaw, dataPos, stb, valueLen, _OVER); + stb = taosHashIterate(pUser->alterViews, stb); + } + int32_t *useDb = taosHashIterate(pUser->useDbs, NULL); while (useDb != NULL) { size_t keyLen = 0; @@ -873,20 +1037,40 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) { } if (sver >= 3) { - int32_t numOfReadStbs = 0; - int32_t numOfWriteStbs = 0; + int32_t numOfReadTbs = 0; + int32_t numOfWriteTbs = 0; + int32_t numOfAlterTbs = 0; + int32_t numOfReadViews = 0; + int32_t numOfWriteViews = 0; + int32_t numOfAlterViews = 0; int32_t numOfUseDbs = 0; - SDB_GET_INT32(pRaw, dataPos, &numOfReadStbs, _OVER) - SDB_GET_INT32(pRaw, dataPos, &numOfWriteStbs, _OVER) + SDB_GET_INT32(pRaw, dataPos, &numOfReadTbs, _OVER) + SDB_GET_INT32(pRaw, dataPos, &numOfWriteTbs, _OVER) + if (sver >= 6) { + SDB_GET_INT32(pRaw, dataPos, &numOfAlterTbs, _OVER) + SDB_GET_INT32(pRaw, dataPos, &numOfReadViews, _OVER) + SDB_GET_INT32(pRaw, dataPos, &numOfWriteViews, _OVER) + SDB_GET_INT32(pRaw, dataPos, &numOfAlterViews, _OVER) + } SDB_GET_INT32(pRaw, dataPos, &numOfUseDbs, _OVER) pUser->readTbs = - taosHashInit(numOfReadStbs, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); + taosHashInit(numOfReadTbs, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); pUser->writeTbs = - taosHashInit(numOfWriteStbs, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); + taosHashInit(numOfWriteTbs, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); + pUser->alterTbs = + taosHashInit(numOfAlterTbs, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); + + pUser->readViews = + taosHashInit(numOfReadViews, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); + pUser->writeViews = + taosHashInit(numOfWriteViews, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); + pUser->alterViews = + taosHashInit(numOfAlterViews, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); + pUser->useDbs = taosHashInit(numOfUseDbs, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); - for (int32_t i = 0; i < numOfReadStbs; ++i) { + for (int32_t i = 0; i < numOfReadTbs; ++i) { int32_t keyLen = 0; SDB_GET_INT32(pRaw, dataPos, &keyLen, _OVER); @@ -906,7 +1090,7 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) { taosMemoryFree(value); } - for (int32_t i = 0; i < numOfWriteStbs; ++i) { + for (int32_t i = 0; i < numOfWriteTbs; ++i) { int32_t keyLen = 0; SDB_GET_INT32(pRaw, dataPos, &keyLen, _OVER); @@ -926,6 +1110,88 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) { taosMemoryFree(value); } + if (sver >= 6) { + for (int32_t i = 0; i < numOfAlterTbs; ++i) { + int32_t keyLen = 0; + SDB_GET_INT32(pRaw, dataPos, &keyLen, _OVER); + + char *key = taosMemoryCalloc(keyLen, sizeof(char)); + memset(key, 0, keyLen); + SDB_GET_BINARY(pRaw, dataPos, key, keyLen, _OVER); + + int32_t valuelen = 0; + SDB_GET_INT32(pRaw, dataPos, &valuelen, _OVER); + char *value = taosMemoryCalloc(valuelen, sizeof(char)); + memset(value, 0, valuelen); + SDB_GET_BINARY(pRaw, dataPos, value, valuelen, _OVER) + + taosHashPut(pUser->alterTbs, key, keyLen, value, valuelen); + + taosMemoryFree(key); + taosMemoryFree(value); + } + + for (int32_t i = 0; i < numOfReadViews; ++i) { + int32_t keyLen = 0; + SDB_GET_INT32(pRaw, dataPos, &keyLen, _OVER); + + char *key = taosMemoryCalloc(keyLen, sizeof(char)); + memset(key, 0, keyLen); + SDB_GET_BINARY(pRaw, dataPos, key, keyLen, _OVER); + + int32_t valuelen = 0; + SDB_GET_INT32(pRaw, dataPos, &valuelen, _OVER); + char *value = taosMemoryCalloc(valuelen, sizeof(char)); + memset(value, 0, valuelen); + SDB_GET_BINARY(pRaw, dataPos, value, valuelen, _OVER) + + taosHashPut(pUser->readViews, key, keyLen, value, valuelen); + + taosMemoryFree(key); + taosMemoryFree(value); + } + + for (int32_t i = 0; i < numOfWriteViews; ++i) { + int32_t keyLen = 0; + SDB_GET_INT32(pRaw, dataPos, &keyLen, _OVER); + + char *key = taosMemoryCalloc(keyLen, sizeof(char)); + memset(key, 0, keyLen); + SDB_GET_BINARY(pRaw, dataPos, key, keyLen, _OVER); + + int32_t valuelen = 0; + SDB_GET_INT32(pRaw, dataPos, &valuelen, _OVER); + char *value = taosMemoryCalloc(valuelen, sizeof(char)); + memset(value, 0, valuelen); + SDB_GET_BINARY(pRaw, dataPos, value, valuelen, _OVER) + + taosHashPut(pUser->writeViews, key, keyLen, value, valuelen); + + taosMemoryFree(key); + taosMemoryFree(value); + } + + for (int32_t i = 0; i < numOfAlterViews; ++i) { + int32_t keyLen = 0; + SDB_GET_INT32(pRaw, dataPos, &keyLen, _OVER); + + char *key = taosMemoryCalloc(keyLen, sizeof(char)); + memset(key, 0, keyLen); + SDB_GET_BINARY(pRaw, dataPos, key, keyLen, _OVER); + + int32_t valuelen = 0; + SDB_GET_INT32(pRaw, dataPos, &valuelen, _OVER); + char *value = taosMemoryCalloc(valuelen, sizeof(char)); + memset(value, 0, valuelen); + SDB_GET_BINARY(pRaw, dataPos, value, valuelen, _OVER) + + taosHashPut(pUser->alterViews, key, keyLen, value, valuelen); + + taosMemoryFree(key); + taosMemoryFree(value); + } + } + for (int32_t i = 0; i < numOfUseDbs; ++i) { int32_t keyLen = 0; SDB_GET_INT32(pRaw, dataPos, &keyLen, _OVER); @@ -975,6 +1241,10 @@ _OVER: taosHashCleanup(pUser->topics); taosHashCleanup(pUser->readTbs); taosHashCleanup(pUser->writeTbs); + taosHashCleanup(pUser->alterTbs); + taosHashCleanup(pUser->readViews); + taosHashCleanup(pUser->writeViews); + taosHashCleanup(pUser->alterViews); taosHashCleanup(pUser->useDbs); taosMemoryFreeClear(pUser->pIpWhiteList); } @@ -1062,6 +1332,10 @@ int32_t mndUserDupObj(SUserObj *pUser, SUserObj *pNew) { pNew->writeDbs = mndDupDbHash(pUser->writeDbs); pNew->readTbs = mndDupTableHash(pUser->readTbs); pNew->writeTbs = mndDupTableHash(pUser->writeTbs); + pNew->alterTbs = mndDupTableHash(pUser->alterTbs); + pNew->readViews = mndDupTableHash(pUser->readViews); + pNew->writeViews = mndDupTableHash(pUser->writeViews); + pNew->alterViews = mndDupTableHash(pUser->alterViews); pNew->topics = mndDupTopicHash(pUser->topics); pNew->useDbs = mndDupUseDbHash(pUser->useDbs); pNew->pIpWhiteList = cloneIpWhiteList(pUser->pIpWhiteList); @@ -1080,6 +1354,10 @@ void mndUserFreeObj(SUserObj *pUser) { taosHashCleanup(pUser->topics); taosHashCleanup(pUser->readTbs); taosHashCleanup(pUser->writeTbs); + taosHashCleanup(pUser->alterTbs); + taosHashCleanup(pUser->readViews); + taosHashCleanup(pUser->writeViews); + taosHashCleanup(pUser->alterViews); taosHashCleanup(pUser->useDbs); taosMemoryFreeClear(pUser->pIpWhiteList); pUser->readDbs = NULL; @@ -1087,6 +1365,10 @@ void mndUserFreeObj(SUserObj *pUser) { pUser->topics = NULL; pUser->readTbs = NULL; pUser->writeTbs = NULL; + pUser->alterTbs = NULL; + pUser->readViews = NULL; + pUser->writeViews = NULL; + pUser->alterViews = NULL; pUser->useDbs = NULL; } @@ -1110,6 +1392,10 @@ static int32_t mndUserActionUpdate(SSdb *pSdb, SUserObj *pOld, SUserObj *pNew) { TSWAP(pOld->topics, pNew->topics); TSWAP(pOld->readTbs, pNew->readTbs); TSWAP(pOld->writeTbs, pNew->writeTbs); + TSWAP(pOld->alterTbs, pNew->alterTbs); + TSWAP(pOld->readViews, pNew->readViews); + TSWAP(pOld->writeViews, pNew->writeViews); + TSWAP(pOld->alterViews, pNew->alterViews); TSWAP(pOld->useDbs, pNew->useDbs); int32_t sz = sizeof(SIpWhiteList) + pNew->pIpWhiteList->num * sizeof(SIpV4Range); @@ -1275,7 +1561,7 @@ static int32_t mndProcessCreateUserReq(SRpcMsg *pReq) { code = mndCreateUser(pMnode, pOperUser->acct, &createReq, pReq); if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; - auditRecord(pReq, pMnode->clusterId, "createUser", createReq.user, "", createReq.sql, createReq.sqlLen); + auditRecord(pReq, pMnode->clusterId, "createUser", "", createReq.user, createReq.sql, createReq.sqlLen); _OVER: if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) { @@ -1429,7 +1715,7 @@ static int32_t mndTablePriviledge(SMnode *pMnode, SHashObj *hash, SHashObj *useD return -1; } } else { - if (taosHashPut(hash, tbFName, len, "t", 2) != 0) { + if (taosHashPut(hash, tbFName, len, alterReq->isView ? "v" : "t", 2) != 0) { return -1; } } @@ -1460,7 +1746,11 @@ static int32_t mndRemoveTablePriviledge(SMnode *pMnode, SHashObj *hash, SHashObj int32_t dbKeyLen = strlen(alterReq->objname) + 1; int32_t *currRef = taosHashGet(useDbHash, alterReq->objname, dbKeyLen); - if (NULL == currRef || 1 == *currRef) { + if (NULL == currRef) { + return 0; + } + + if (1 == *currRef) { if (taosHashRemove(useDbHash, alterReq->objname, dbKeyLen) != 0) { return -1; } @@ -1481,60 +1771,162 @@ static char *mndUserAuditTypeStr(int32_t type) { if (type == TSDB_ALTER_USER_SUPERUSER) { return "changeSuperUser"; } - if (type == TSDB_ALTER_USER_ADD_READ_DB) { - return "addReadToDB"; - } - if (type == TSDB_ALTER_USER_ADD_READ_DB) { - return "addReadToDB"; - } - if (type == TSDB_ALTER_USER_REMOVE_READ_DB) { - return "removeReadFromDB"; - } - if (type == TSDB_ALTER_USER_ADD_WRITE_DB) { - return "addWriteToDB"; - } - if (type == TSDB_ALTER_USER_REMOVE_WRITE_DB) { - return "removeWriteFromDB"; - } - if (type == TSDB_ALTER_USER_ADD_ALL_DB) { - return "addToAllDB"; - } - if (type == TSDB_ALTER_USER_REMOVE_ALL_DB) { - return "removeFromAllDB"; - } if (type == TSDB_ALTER_USER_ENABLE) { return "enableUser"; } if (type == TSDB_ALTER_USER_SYSINFO) { return "userSysInfo"; } - if (type == TSDB_ALTER_USER_ADD_SUBSCRIBE_TOPIC) { - return "addSubscribeTopic"; - } - if (type == TSDB_ALTER_USER_REMOVE_SUBSCRIBE_TOPIC) { - return "removeSubscribeTopic"; - } - if (type == TSDB_ALTER_USER_ADD_READ_TABLE) { - return "addReadToTable"; - } - if (type == TSDB_ALTER_USER_REMOVE_READ_TABLE) { - return "removeReadFromTable"; - } - if (type == TSDB_ALTER_USER_ADD_WRITE_TABLE) { - return "addWriteToTable"; - } - if (type == TSDB_ALTER_USER_REMOVE_WRITE_TABLE) { - return "removeWriteFromTable"; - } - if (type == TSDB_ALTER_USER_ADD_ALL_TABLE) { - return "addToAllTable"; - } - if (type == TSDB_ALTER_USER_REMOVE_ALL_TABLE) { - return "removeFromAllTable"; - } return "error"; } +static int32_t mndProcessAlterUserPrivilegesReq(SAlterUserReq *pAlterReq, SMnode *pMnode, SUserObj* pNewUser) { + SSdb *pSdb = pMnode->pSdb; + void *pIter = NULL; + + if (ALTER_USER_ADD_READ_DB_PRIV(pAlterReq->alterType, pAlterReq->privileges, pAlterReq->tabName) || + ALTER_USER_ADD_ALL_DB_PRIV(pAlterReq->alterType, pAlterReq->privileges, pAlterReq->tabName)) { + if (strcmp(pAlterReq->objname, "1.*") != 0) { + int32_t len = strlen(pAlterReq->objname) + 1; + SDbObj *pDb = mndAcquireDb(pMnode, pAlterReq->objname); + if (pDb == NULL) { + mndReleaseDb(pMnode, pDb); + return -1; + } + if (taosHashPut(pNewUser->readDbs, pAlterReq->objname, len, pAlterReq->objname, TSDB_DB_FNAME_LEN) != 0) { + mndReleaseDb(pMnode, pDb); + return -1; + } + mndReleaseDb(pMnode, pDb); + } else { + while (1) { + SDbObj *pDb = NULL; + pIter = sdbFetch(pSdb, SDB_DB, pIter, (void **)&pDb); + if (pIter == NULL) break; + int32_t len = strlen(pDb->name) + 1; + taosHashPut(pNewUser->readDbs, pDb->name, len, pDb->name, TSDB_DB_FNAME_LEN); + sdbRelease(pSdb, pDb); + } + } + } + + if (ALTER_USER_ADD_WRITE_DB_PRIV(pAlterReq->alterType, pAlterReq->privileges, pAlterReq->tabName) || ALTER_USER_ADD_ALL_DB_PRIV(pAlterReq->alterType, pAlterReq->privileges, pAlterReq->tabName)) { + if (strcmp(pAlterReq->objname, "1.*") != 0) { + int32_t len = strlen(pAlterReq->objname) + 1; + SDbObj *pDb = mndAcquireDb(pMnode, pAlterReq->objname); + if (pDb == NULL) { + mndReleaseDb(pMnode, pDb); + return -1; + } + if (taosHashPut(pNewUser->writeDbs, pAlterReq->objname, len, pAlterReq->objname, TSDB_DB_FNAME_LEN) != 0) { + mndReleaseDb(pMnode, pDb); + return -1; + } + mndReleaseDb(pMnode, pDb); + } else { + while (1) { + SDbObj *pDb = NULL; + pIter = sdbFetch(pSdb, SDB_DB, pIter, (void **)&pDb); + if (pIter == NULL) break; + int32_t len = strlen(pDb->name) + 1; + taosHashPut(pNewUser->writeDbs, pDb->name, len, pDb->name, TSDB_DB_FNAME_LEN); + sdbRelease(pSdb, pDb); + } + } + } + + if (ALTER_USER_DEL_READ_DB_PRIV(pAlterReq->alterType, pAlterReq->privileges, pAlterReq->tabName) || ALTER_USER_DEL_ALL_DB_PRIV(pAlterReq->alterType, pAlterReq->privileges, pAlterReq->tabName)) { + if (strcmp(pAlterReq->objname, "1.*") != 0) { + int32_t len = strlen(pAlterReq->objname) + 1; + SDbObj *pDb = mndAcquireDb(pMnode, pAlterReq->objname); + if (pDb == NULL) { + mndReleaseDb(pMnode, pDb); + return -1; + } + taosHashRemove(pNewUser->readDbs, pAlterReq->objname, len); + mndReleaseDb(pMnode, pDb); + } else { + taosHashClear(pNewUser->readDbs); + } + } + + if (ALTER_USER_DEL_WRITE_DB_PRIV(pAlterReq->alterType, pAlterReq->privileges, pAlterReq->tabName) || ALTER_USER_DEL_ALL_DB_PRIV(pAlterReq->alterType, pAlterReq->privileges, pAlterReq->tabName)) { + if (strcmp(pAlterReq->objname, "1.*") != 0) { + int32_t len = strlen(pAlterReq->objname) + 1; + SDbObj *pDb = mndAcquireDb(pMnode, pAlterReq->objname); + if (pDb == NULL) { + mndReleaseDb(pMnode, pDb); + return -1; + } + taosHashRemove(pNewUser->writeDbs, pAlterReq->objname, len); + mndReleaseDb(pMnode, pDb); + } else { + taosHashClear(pNewUser->writeDbs); + } + } + + SHashObj* pReadTbs = pNewUser->readTbs; + SHashObj* pWriteTbs = pNewUser->writeTbs; + SHashObj* pAlterTbs = pNewUser->alterTbs; + +#ifdef TD_ENTERPRISE + if (pAlterReq->isView) { + pReadTbs = pNewUser->readViews; + pWriteTbs = pNewUser->writeViews; + pAlterTbs = pNewUser->alterViews; + } +#endif + + if (ALTER_USER_ADD_READ_TB_PRIV(pAlterReq->alterType, pAlterReq->privileges, pAlterReq->tabName) || ALTER_USER_ADD_ALL_TB_PRIV(pAlterReq->alterType, pAlterReq->privileges, pAlterReq->tabName)) { + if (mndTablePriviledge(pMnode, pReadTbs, pNewUser->useDbs, pAlterReq, pSdb) != 0) return -1; + } + + if (ALTER_USER_ADD_WRITE_TB_PRIV(pAlterReq->alterType, pAlterReq->privileges, pAlterReq->tabName) || ALTER_USER_ADD_ALL_TB_PRIV(pAlterReq->alterType, pAlterReq->privileges, pAlterReq->tabName)) { + if (mndTablePriviledge(pMnode, pWriteTbs, pNewUser->useDbs, pAlterReq, pSdb) != 0) return -1; + } + + if (ALTER_USER_ADD_ALTER_TB_PRIV(pAlterReq->alterType, pAlterReq->privileges, pAlterReq->tabName) || ALTER_USER_ADD_ALL_TB_PRIV(pAlterReq->alterType, pAlterReq->privileges, pAlterReq->tabName)) { + if (mndTablePriviledge(pMnode, pAlterTbs, pNewUser->useDbs, pAlterReq, pSdb) != 0) return -1; + } + + if (ALTER_USER_DEL_READ_TB_PRIV(pAlterReq->alterType, pAlterReq->privileges, pAlterReq->tabName) || + ALTER_USER_DEL_ALL_TB_PRIV(pAlterReq->alterType, pAlterReq->privileges, pAlterReq->tabName)) { + if (mndRemoveTablePriviledge(pMnode, pReadTbs, pNewUser->useDbs, pAlterReq, pSdb) != 0) return -1; + } + + if (ALTER_USER_DEL_WRITE_TB_PRIV(pAlterReq->alterType, pAlterReq->privileges, pAlterReq->tabName) || + ALTER_USER_DEL_ALL_TB_PRIV(pAlterReq->alterType, pAlterReq->privileges, pAlterReq->tabName)) { + if (mndRemoveTablePriviledge(pMnode, pWriteTbs, pNewUser->useDbs, pAlterReq, pSdb) != 0) return -1; + } + + if (ALTER_USER_DEL_ALTER_TB_PRIV(pAlterReq->alterType, pAlterReq->privileges, pAlterReq->tabName) || + ALTER_USER_DEL_ALL_TB_PRIV(pAlterReq->alterType, pAlterReq->privileges, pAlterReq->tabName)) { + if (mndRemoveTablePriviledge(pMnode, pAlterTbs, pNewUser->useDbs, pAlterReq, pSdb) != 0) return -1; + } + + if (ALTER_USER_ADD_SUBSCRIBE_TOPIC_PRIV(pAlterReq->alterType, pAlterReq->privileges)) { + int32_t len = strlen(pAlterReq->objname) + 1; + SMqTopicObj *pTopic = mndAcquireTopic(pMnode, pAlterReq->objname); + if (pTopic == NULL) { + mndReleaseTopic(pMnode, pTopic); + return -1; + } + taosHashPut(pNewUser->topics, pTopic->name, len, pTopic->name, TSDB_TOPIC_FNAME_LEN); + } + + if (ALTER_USER_DEL_SUBSCRIBE_TOPIC_PRIV(pAlterReq->alterType, pAlterReq->privileges)) { + int32_t len = strlen(pAlterReq->objname) + 1; + SMqTopicObj *pTopic = mndAcquireTopic(pMnode, pAlterReq->objname); + if (pTopic == NULL) { + mndReleaseTopic(pMnode, pTopic); + return -1; + } + taosHashRemove(pNewUser->topics, pAlterReq->objname, len); + } + + return TSDB_CODE_SUCCESS; +} + static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) { SMnode *pMnode = pReq->info.node; SSdb *pSdb = pMnode->pSdb; @@ -1602,122 +1994,8 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) { newUser.sysInfo = alterReq.sysInfo; } - if (alterReq.alterType == TSDB_ALTER_USER_ADD_READ_DB || alterReq.alterType == TSDB_ALTER_USER_ADD_ALL_DB) { - if (strcmp(alterReq.objname, "1.*") != 0) { - int32_t len = strlen(alterReq.objname) + 1; - SDbObj *pDb = mndAcquireDb(pMnode, alterReq.objname); - if (pDb == NULL) { - mndReleaseDb(pMnode, pDb); - goto _OVER; - } - if (taosHashPut(newUser.readDbs, alterReq.objname, len, alterReq.objname, TSDB_DB_FNAME_LEN) != 0) { - mndReleaseDb(pMnode, pDb); - goto _OVER; - } - mndReleaseDb(pMnode, pDb); - } else { - while (1) { - SDbObj *pDb = NULL; - pIter = sdbFetch(pSdb, SDB_DB, pIter, (void **)&pDb); - if (pIter == NULL) break; - int32_t len = strlen(pDb->name) + 1; - taosHashPut(newUser.readDbs, pDb->name, len, pDb->name, TSDB_DB_FNAME_LEN); - sdbRelease(pSdb, pDb); - } - } - } - - if (alterReq.alterType == TSDB_ALTER_USER_ADD_WRITE_DB || alterReq.alterType == TSDB_ALTER_USER_ADD_ALL_DB) { - if (strcmp(alterReq.objname, "1.*") != 0) { - int32_t len = strlen(alterReq.objname) + 1; - SDbObj *pDb = mndAcquireDb(pMnode, alterReq.objname); - if (pDb == NULL) { - mndReleaseDb(pMnode, pDb); - goto _OVER; - } - if (taosHashPut(newUser.writeDbs, alterReq.objname, len, alterReq.objname, TSDB_DB_FNAME_LEN) != 0) { - mndReleaseDb(pMnode, pDb); - goto _OVER; - } - mndReleaseDb(pMnode, pDb); - } else { - while (1) { - SDbObj *pDb = NULL; - pIter = sdbFetch(pSdb, SDB_DB, pIter, (void **)&pDb); - if (pIter == NULL) break; - int32_t len = strlen(pDb->name) + 1; - taosHashPut(newUser.writeDbs, pDb->name, len, pDb->name, TSDB_DB_FNAME_LEN); - sdbRelease(pSdb, pDb); - } - } - } - - if (alterReq.alterType == TSDB_ALTER_USER_REMOVE_READ_DB || alterReq.alterType == TSDB_ALTER_USER_REMOVE_ALL_DB) { - if (strcmp(alterReq.objname, "1.*") != 0) { - int32_t len = strlen(alterReq.objname) + 1; - SDbObj *pDb = mndAcquireDb(pMnode, alterReq.objname); - if (pDb == NULL) { - mndReleaseDb(pMnode, pDb); - goto _OVER; - } - taosHashRemove(newUser.readDbs, alterReq.objname, len); - mndReleaseDb(pMnode, pDb); - } else { - taosHashClear(newUser.readDbs); - } - } - - if (alterReq.alterType == TSDB_ALTER_USER_REMOVE_WRITE_DB || alterReq.alterType == TSDB_ALTER_USER_REMOVE_ALL_DB) { - if (strcmp(alterReq.objname, "1.*") != 0) { - int32_t len = strlen(alterReq.objname) + 1; - SDbObj *pDb = mndAcquireDb(pMnode, alterReq.objname); - if (pDb == NULL) { - mndReleaseDb(pMnode, pDb); - goto _OVER; - } - taosHashRemove(newUser.writeDbs, alterReq.objname, len); - mndReleaseDb(pMnode, pDb); - } else { - taosHashClear(newUser.writeDbs); - } - } - - if (alterReq.alterType == TSDB_ALTER_USER_ADD_READ_TABLE || alterReq.alterType == TSDB_ALTER_USER_ADD_ALL_TABLE) { - if (mndTablePriviledge(pMnode, newUser.readTbs, newUser.useDbs, &alterReq, pSdb) != 0) goto _OVER; - } - - if (alterReq.alterType == TSDB_ALTER_USER_ADD_WRITE_TABLE || alterReq.alterType == TSDB_ALTER_USER_ADD_ALL_TABLE) { - if (mndTablePriviledge(pMnode, newUser.writeTbs, newUser.useDbs, &alterReq, pSdb) != 0) goto _OVER; - } - - if (alterReq.alterType == TSDB_ALTER_USER_REMOVE_READ_TABLE || - alterReq.alterType == TSDB_ALTER_USER_REMOVE_ALL_TABLE) { - if (mndRemoveTablePriviledge(pMnode, newUser.readTbs, newUser.useDbs, &alterReq, pSdb) != 0) goto _OVER; - } - - if (alterReq.alterType == TSDB_ALTER_USER_REMOVE_WRITE_TABLE || - alterReq.alterType == TSDB_ALTER_USER_REMOVE_ALL_TABLE) { - if (mndRemoveTablePriviledge(pMnode, newUser.writeTbs, newUser.useDbs, &alterReq, pSdb) != 0) goto _OVER; - } - - if (alterReq.alterType == TSDB_ALTER_USER_ADD_SUBSCRIBE_TOPIC) { - int32_t len = strlen(alterReq.objname) + 1; - SMqTopicObj *pTopic = mndAcquireTopic(pMnode, alterReq.objname); - if (pTopic == NULL) { - mndReleaseTopic(pMnode, pTopic); - goto _OVER; - } - taosHashPut(newUser.topics, pTopic->name, len, pTopic->name, TSDB_TOPIC_FNAME_LEN); - } - - if (alterReq.alterType == TSDB_ALTER_USER_REMOVE_SUBSCRIBE_TOPIC) { - int32_t len = strlen(alterReq.objname) + 1; - SMqTopicObj *pTopic = mndAcquireTopic(pMnode, alterReq.objname); - if (pTopic == NULL) { - mndReleaseTopic(pMnode, pTopic); - goto _OVER; - } - taosHashRemove(newUser.topics, alterReq.objname, len); + if (ALTER_USER_ADD_PRIVS(alterReq.alterType) || ALTER_USER_DEL_PRIVS(alterReq.alterType)) { + if (0 != mndProcessAlterUserPrivilegesReq(&alterReq, pMnode, &newUser)) goto _OVER; } if (alterReq.alterType == TSDB_ALTER_USER_ADD_WHITE_LIST) { @@ -1820,45 +2098,45 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) { sprintf(detail, "alterType:%s, enable:%d, superUser:%d, sysInfo:%d, tabName:%s, password:xxx", mndUserAuditTypeStr(alterReq.alterType), alterReq.enable, alterReq.superUser, alterReq.sysInfo, alterReq.tabName); - auditRecord(pReq, pMnode->clusterId, "alterUser", alterReq.user, "", detail, strlen(detail)); + auditRecord(pReq, pMnode->clusterId, "alterUser", "", alterReq.user, detail, strlen(detail)); } else if(alterReq.alterType == TSDB_ALTER_USER_SUPERUSER || alterReq.alterType == TSDB_ALTER_USER_ENABLE || alterReq.alterType == TSDB_ALTER_USER_SYSINFO){ - auditRecord(pReq, pMnode->clusterId, "alterUser", alterReq.user, "", alterReq.sql, alterReq.sqlLen); + auditRecord(pReq, pMnode->clusterId, "alterUser", "", alterReq.user, alterReq.sql, alterReq.sqlLen); } - else if(alterReq.alterType == TSDB_ALTER_USER_ADD_READ_DB|| - alterReq.alterType == TSDB_ALTER_USER_ADD_WRITE_DB|| - alterReq.alterType == TSDB_ALTER_USER_ADD_ALL_DB|| - alterReq.alterType == TSDB_ALTER_USER_ADD_READ_TABLE|| - alterReq.alterType == TSDB_ALTER_USER_ADD_WRITE_TABLE|| - alterReq.alterType == TSDB_ALTER_USER_ADD_ALL_TABLE){ + else if(ALTER_USER_ADD_READ_DB_PRIV(alterReq.alterType, alterReq.privileges, alterReq.tabName)|| + ALTER_USER_ADD_WRITE_DB_PRIV(alterReq.alterType, alterReq.privileges, alterReq.tabName)|| + ALTER_USER_ADD_ALL_DB_PRIV(alterReq.alterType, alterReq.privileges, alterReq.tabName)|| + ALTER_USER_ADD_READ_TB_PRIV(alterReq.alterType, alterReq.privileges, alterReq.tabName)|| + ALTER_USER_ADD_WRITE_TB_PRIV(alterReq.alterType, alterReq.privileges, alterReq.tabName)|| + ALTER_USER_ADD_ALL_TB_PRIV(alterReq.alterType, alterReq.privileges, alterReq.tabName)){ if (strcmp(alterReq.objname, "1.*") != 0){ SName name = {0}; tNameFromString(&name, alterReq.objname, T_NAME_ACCT | T_NAME_DB); - auditRecord(pReq, pMnode->clusterId, "GrantPrivileges", alterReq.user, name.dbname, + auditRecord(pReq, pMnode->clusterId, "GrantPrivileges", name.dbname, alterReq.user, alterReq.sql, alterReq.sqlLen); }else{ - auditRecord(pReq, pMnode->clusterId, "GrantPrivileges", alterReq.user, "*", + auditRecord(pReq, pMnode->clusterId, "GrantPrivileges", "", alterReq.user, alterReq.sql, alterReq.sqlLen); } } - else if(alterReq.alterType == TSDB_ALTER_USER_ADD_SUBSCRIBE_TOPIC){ - auditRecord(pReq, pMnode->clusterId, "GrantPrivileges", alterReq.user, alterReq.objname, + else if(ALTER_USER_ADD_SUBSCRIBE_TOPIC_PRIV(alterReq.alterType, alterReq.privileges)){ + auditRecord(pReq, pMnode->clusterId, "GrantPrivileges", alterReq.objname, alterReq.user, alterReq.sql, alterReq.sqlLen); } - else if(alterReq.alterType == TSDB_ALTER_USER_REMOVE_SUBSCRIBE_TOPIC){ - auditRecord(pReq, pMnode->clusterId, "RevokePrivileges", alterReq.user, alterReq.objname, + else if(ALTER_USER_DEL_SUBSCRIBE_TOPIC_PRIV(alterReq.alterType, alterReq.privileges)){ + auditRecord(pReq, pMnode->clusterId, "RevokePrivileges", alterReq.objname, alterReq.user, alterReq.sql, alterReq.sqlLen); } else{ if (strcmp(alterReq.objname, "1.*") != 0){ SName name = {0}; tNameFromString(&name, alterReq.objname, T_NAME_ACCT | T_NAME_DB); - auditRecord(pReq, pMnode->clusterId, "RevokePrivileges", alterReq.user, name.dbname, + auditRecord(pReq, pMnode->clusterId, "RevokePrivileges", name.dbname, alterReq.user, alterReq.sql, alterReq.sqlLen); }else{ - auditRecord(pReq, pMnode->clusterId, "RevokePrivileges", alterReq.user, "*", + auditRecord(pReq, pMnode->clusterId, "RevokePrivileges", "", alterReq.user, alterReq.sql, alterReq.sqlLen); } } @@ -1933,7 +2211,7 @@ static int32_t mndProcessDropUserReq(SRpcMsg *pReq) { code = mndDropUser(pMnode, pReq, pUser); if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; - auditRecord(pReq, pMnode->clusterId, "dropUser", dropReq.user, "", dropReq.sql, dropReq.sqlLen); + auditRecord(pReq, pMnode->clusterId, "dropUser", "", dropReq.user, dropReq.sql, dropReq.sqlLen); _OVER: if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) { @@ -2092,7 +2370,7 @@ static void mndLoopHash(SHashObj *hash, char *priType, SSDataBlock *pBlock, int3 pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataSetVal(pColInfo, *numOfRows, (const char *)tableNameContent, false); - if (strcmp("t", value) != 0) { + if (strcmp("t", value) != 0 && strcmp("v", value) != 0) { SNode *pAst = NULL; int32_t sqlLen = 0; size_t bufSz = strlen(value) + 1; @@ -2113,12 +2391,22 @@ static void mndLoopHash(SHashObj *hash, char *priType, SSDataBlock *pBlock, int3 colDataSetVal(pColInfo, *numOfRows, (const char *)obj, false); taosMemoryFree(obj); taosMemoryFree(sql); + + char notes[2] = {0}; + STR_WITH_MAXSIZE_TO_VARSTR(notes, "", sizeof(notes)); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataSetVal(pColInfo, *numOfRows, (const char *)notes, false); } else { char *condition = taosMemoryMalloc(TSDB_PRIVILEDGE_CONDITION_LEN + VARSTR_HEADER_SIZE); STR_WITH_MAXSIZE_TO_VARSTR(condition, "", pShow->pMeta->pSchemas[cols].bytes); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataSetVal(pColInfo, *numOfRows, (const char *)condition, false); taosMemoryFree(condition); + + char notes[64 + VARSTR_HEADER_SIZE] = {0}; + STR_WITH_MAXSIZE_TO_VARSTR(notes, value[0] == 'v' ? "view" : "", sizeof(notes)); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataSetVal(pColInfo, *numOfRows, (const char *)notes, false); } (*numOfRows)++; @@ -2155,11 +2443,15 @@ static int32_t mndRetrievePrivileges(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock int32_t numOfTopics = taosHashGetSize(pUser->topics); int32_t numOfReadTbs = taosHashGetSize(pUser->readTbs); int32_t numOfWriteTbs = taosHashGetSize(pUser->writeTbs); - if (numOfRows + numOfReadDbs + numOfWriteDbs + numOfTopics + numOfReadTbs + numOfWriteTbs >= rows) { + int32_t numOfAlterTbs = taosHashGetSize(pUser->alterTbs); + int32_t numOfReadViews = taosHashGetSize(pUser->readViews); + int32_t numOfWriteViews = taosHashGetSize(pUser->writeViews); + int32_t numOfAlterViews = taosHashGetSize(pUser->alterViews); + if (numOfRows + numOfReadDbs + numOfWriteDbs + numOfTopics + numOfReadTbs + numOfWriteTbs + numOfAlterTbs + numOfReadViews + numOfWriteViews + numOfAlterViews >= rows) { mInfo( "will restore. current num of rows: %d, read dbs %d, write dbs %d, topics %d, read tables %d, write tables " - "%d", - numOfRows, numOfReadDbs, numOfWriteDbs, numOfTopics, numOfReadTbs, numOfWriteTbs); + "%d, alter tables %d, read views %d, write views %d, alter views %d", + numOfRows, numOfReadDbs, numOfWriteDbs, numOfTopics, numOfReadTbs, numOfWriteTbs, numOfAlterTbs, numOfReadViews, numOfWriteViews, numOfAlterViews); pShow->restore = true; sdbRelease(pSdb, pUser); break; @@ -2193,6 +2485,11 @@ static int32_t mndRetrievePrivileges(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock colDataSetVal(pColInfo, numOfRows, (const char *)condition, false); taosMemoryFree(condition); + char notes[2] = {0}; + STR_WITH_MAXSIZE_TO_VARSTR(notes, "", sizeof(notes)); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataSetVal(pColInfo, numOfRows, (const char *)notes, false); + numOfRows++; } @@ -2228,6 +2525,11 @@ static int32_t mndRetrievePrivileges(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock colDataSetVal(pColInfo, numOfRows, (const char *)condition, false); taosMemoryFree(condition); + char notes[2] = {0}; + STR_WITH_MAXSIZE_TO_VARSTR(notes, "", sizeof(notes)); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataSetVal(pColInfo, numOfRows, (const char *)notes, false); + numOfRows++; db = taosHashIterate(pUser->readDbs, db); } @@ -2264,6 +2566,11 @@ static int32_t mndRetrievePrivileges(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock colDataSetVal(pColInfo, numOfRows, (const char *)condition, false); taosMemoryFree(condition); + char notes[2] = {0}; + STR_WITH_MAXSIZE_TO_VARSTR(notes, "", sizeof(notes)); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataSetVal(pColInfo, numOfRows, (const char *)notes, false); + numOfRows++; db = taosHashIterate(pUser->writeDbs, db); } @@ -2272,6 +2579,14 @@ static int32_t mndRetrievePrivileges(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock mndLoopHash(pUser->writeTbs, "write", pBlock, &numOfRows, pUser->user, pShow); + mndLoopHash(pUser->alterTbs, "alter", pBlock, &numOfRows, pUser->user, pShow); + + mndLoopHash(pUser->readViews, "read", pBlock, &numOfRows, pUser->user, pShow); + + mndLoopHash(pUser->writeViews, "write", pBlock, &numOfRows, pUser->user, pShow); + + mndLoopHash(pUser->alterViews, "alter", pBlock, &numOfRows, pUser->user, pShow); + char *topic = taosHashIterate(pUser->topics, NULL); while (topic != NULL) { cols = 0; @@ -2302,6 +2617,11 @@ static int32_t mndRetrievePrivileges(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock colDataSetVal(pColInfo, numOfRows, (const char *)condition, false); taosMemoryFree(condition); + char notes[2] = {0}; + STR_WITH_MAXSIZE_TO_VARSTR(notes, "", sizeof(notes)); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataSetVal(pColInfo, numOfRows, (const char *)notes, false); + numOfRows++; topic = taosHashIterate(pUser->topics, topic); } @@ -2450,9 +2770,11 @@ int32_t mndUserRemoveStb(SMnode *pMnode, STrans *pTrans, char *stb) { bool inRead = (taosHashGet(newUser.readTbs, stb, len) != NULL); bool inWrite = (taosHashGet(newUser.writeTbs, stb, len) != NULL); - if (inRead || inWrite) { + bool inAlter = (taosHashGet(newUser.alterTbs, stb, len) != NULL); + if (inRead || inWrite || inAlter) { (void)taosHashRemove(newUser.readTbs, stb, len); (void)taosHashRemove(newUser.writeTbs, stb, len); + (void)taosHashRemove(newUser.alterTbs, stb, len); SSdbRaw *pCommitRaw = mndUserActionEncode(&newUser); if (pCommitRaw == NULL || mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) { @@ -2472,6 +2794,50 @@ int32_t mndUserRemoveStb(SMnode *pMnode, STrans *pTrans, char *stb) { return code; } +int32_t mndUserRemoveView(SMnode *pMnode, STrans *pTrans, char *view) { + int32_t code = 0; + SSdb *pSdb = pMnode->pSdb; + int32_t len = strlen(view) + 1; + void *pIter = NULL; + SUserObj *pUser = NULL; + SUserObj newUser = {0}; + + while (1) { + pIter = sdbFetch(pSdb, SDB_USER, pIter, (void **)&pUser); + if (pIter == NULL) break; + + code = -1; + if (mndUserDupObj(pUser, &newUser) != 0) { + break; + } + + bool inRead = (taosHashGet(newUser.readViews, view, len) != NULL); + bool inWrite = (taosHashGet(newUser.writeViews, view, len) != NULL); + bool inAlter = (taosHashGet(newUser.alterViews, view, len) != NULL); + if (inRead || inWrite || inAlter) { + (void)taosHashRemove(newUser.readViews, view, len); + (void)taosHashRemove(newUser.writeViews, view, len); + (void)taosHashRemove(newUser.alterViews, view, len); + + SSdbRaw *pCommitRaw = mndUserActionEncode(&newUser); + if (pCommitRaw == NULL || mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) { + break; + } + (void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY); + } + + mndUserFreeObj(&newUser); + sdbRelease(pSdb, pUser); + code = 0; + } + + if (pUser != NULL) sdbRelease(pSdb, pUser); + if (pIter != NULL) sdbCancelFetch(pSdb, pIter); + mndUserFreeObj(&newUser); + return code; +} + + int32_t mndUserRemoveTopic(SMnode *pMnode, STrans *pTrans, char *topic) { int32_t code = 0; SSdb *pSdb = pMnode->pSdb; diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index 54e28948ef..af4ccd4ad0 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -2185,7 +2185,7 @@ static int32_t mndProcessRedistributeVgroupMsg(SRpcMsg *pReq) { char obj[33] = {0}; sprintf(obj, "%d", req.vgId); - auditRecord(pReq, pMnode->clusterId, "RedistributeVgroup", obj, "", req.sql, req.sqlLen); + auditRecord(pReq, pMnode->clusterId, "RedistributeVgroup", "", obj, req.sql, req.sqlLen); _OVER: if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) { diff --git a/source/dnode/mnode/impl/src/mndView.c b/source/dnode/mnode/impl/src/mndView.c new file mode 100755 index 0000000000..d53e740736 --- /dev/null +++ b/source/dnode/mnode/impl/src/mndView.c @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "mndView.h" +#include "mndShow.h" + +int32_t mndInitView(SMnode *pMnode) { + mndSetMsgHandle(pMnode, TDMT_MND_CREATE_VIEW, mndProcessCreateViewReq); + mndSetMsgHandle(pMnode, TDMT_MND_DROP_VIEW, mndProcessDropViewReq); + mndSetMsgHandle(pMnode, TDMT_MND_VIEW_META, mndProcessGetViewMetaReq); + + mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_VIEWS, mndRetrieveView); + mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_VIEWS, mndCancelGetNextView); + +#ifdef TD_ENTERPRISE + initDynViewVersion(); + + SSdbTable table = { + .sdbType = SDB_VIEW, + .keyType = SDB_KEY_BINARY, + .encodeFp = (SdbEncodeFp)mndViewActionEncode, + .decodeFp = (SdbDecodeFp)mndViewActionDecode, + .insertFp = (SdbInsertFp)mndViewActionInsert, + .updateFp = (SdbUpdateFp)mndViewActionUpdate, + .deleteFp = (SdbDeleteFp)mndViewActionDelete, + }; + + return sdbSetTable(pMnode->pSdb, table); +#else + return TSDB_CODE_SUCCESS; +#endif +} + +void mndCleanupView(SMnode *pMnode) { + mDebug("mnd view cleanup"); +} + +int32_t mndProcessCreateViewReq(SRpcMsg *pReq) { +#ifndef TD_ENTERPRISE + return TSDB_CODE_OPS_NOT_SUPPORT; +#else + SCMCreateViewReq createViewReq = {0}; + if (tDeserializeSCMCreateViewReq(pReq->pCont, pReq->contLen, &createViewReq) != 0) { + terrno = TSDB_CODE_INVALID_MSG; + return -1; + } + + mInfo("start to create view:%s, sql:%s", createViewReq.fullname, createViewReq.sql); + + return mndProcessCreateViewReqImpl(&createViewReq, pReq); +#endif +} + +int32_t mndProcessDropViewReq(SRpcMsg *pReq) { +#ifndef TD_ENTERPRISE + return TSDB_CODE_OPS_NOT_SUPPORT; +#else + SCMDropViewReq dropViewReq = {0}; + if (tDeserializeSCMDropViewReq(pReq->pCont, pReq->contLen, &dropViewReq) != 0) { + terrno = TSDB_CODE_INVALID_MSG; + return -1; + } + + mInfo("start to drop view:%s, sql:%s", dropViewReq.name, dropViewReq.sql); + + return mndProcessDropViewReqImpl(&dropViewReq, pReq); +#endif +} + +int32_t mndProcessGetViewMetaReq(SRpcMsg *pReq) { +#ifndef TD_ENTERPRISE + return TSDB_CODE_OPS_NOT_SUPPORT; +#else + SViewMetaReq req = {0}; + + if (tDeserializeSViewMetaReq(pReq->pCont, pReq->contLen, &req) != 0) { + terrno = TSDB_CODE_INVALID_MSG; + return -1; + } + + return mndProcessViewMetaReqImpl(&req, pReq); +#endif +} + + +int32_t mndRetrieveView(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { +#ifndef TD_ENTERPRISE + return 0; +#else + return mndRetrieveViewImpl(pReq, pShow, pBlock, rows); +#endif +} + +void mndCancelGetNextView(SMnode *pMnode, void *pIter) { + SSdb *pSdb = pMnode->pSdb; + sdbCancelFetch(pSdb, pIter); +} + + + diff --git a/source/dnode/mnode/impl/test/user/user.cpp b/source/dnode/mnode/impl/test/user/user.cpp index eb8b1d18e9..997b14822e 100644 --- a/source/dnode/mnode/impl/test/user/user.cpp +++ b/source/dnode/mnode/impl/test/user/user.cpp @@ -250,7 +250,8 @@ TEST_F(MndTestUser, 03_Alter_User) { { SAlterUserReq alterReq = {0}; - alterReq.alterType = TSDB_ALTER_USER_REMOVE_ALL_DB; + alterReq.alterType = TSDB_ALTER_USER_DEL_PRIVILEGES; + alterReq.privileges = PRIVILEGE_TYPE_ALL; strcpy(alterReq.user, "u3"); strcpy(alterReq.pass, "1"); strcpy(alterReq.dbname, "1.*"); @@ -266,7 +267,8 @@ TEST_F(MndTestUser, 03_Alter_User) { { SAlterUserReq alterReq = {0}; - alterReq.alterType = TSDB_ALTER_USER_REMOVE_ALL_DB; + alterReq.alterType = TSDB_ALTER_USER_DEL_PRIVILEGES; + alterReq.privileges = PRIVILEGE_TYPE_ALL; strcpy(alterReq.user, "u3"); strcpy(alterReq.pass, "1"); strcpy(alterReq.dbname, "1.*"); @@ -282,7 +284,8 @@ TEST_F(MndTestUser, 03_Alter_User) { { SAlterUserReq alterReq = {0}; - alterReq.alterType = TSDB_ALTER_USER_ADD_READ_DB; + alterReq.alterType = TSDB_ALTER_USER_ADD_PRIVILEGES; + alterReq.privileges = PRIVILEGE_TYPE_READ; strcpy(alterReq.user, "u3"); strcpy(alterReq.pass, "1"); strcpy(alterReq.dbname, "d1"); @@ -329,7 +332,8 @@ TEST_F(MndTestUser, 03_Alter_User) { { SAlterUserReq alterReq = {0}; - alterReq.alterType = TSDB_ALTER_USER_ADD_READ_DB; + alterReq.alterType = TSDB_ALTER_USER_ADD_PRIVILEGES; + alterReq.privileges = PRIVILEGE_TYPE_READ; strcpy(alterReq.user, "u3"); strcpy(alterReq.pass, "1"); strcpy(alterReq.dbname, "1.d2"); @@ -345,7 +349,8 @@ TEST_F(MndTestUser, 03_Alter_User) { { SAlterUserReq alterReq = {0}; - alterReq.alterType = TSDB_ALTER_USER_ADD_READ_DB; + alterReq.alterType = TSDB_ALTER_USER_ADD_PRIVILEGES; + alterReq.privileges = PRIVILEGE_TYPE_READ; strcpy(alterReq.user, "u3"); strcpy(alterReq.pass, "1"); strcpy(alterReq.dbname, "1.d2"); @@ -388,7 +393,8 @@ TEST_F(MndTestUser, 03_Alter_User) { { SAlterUserReq alterReq = {0}; - alterReq.alterType = TSDB_ALTER_USER_REMOVE_READ_DB; + alterReq.alterType = TSDB_ALTER_USER_DEL_PRIVILEGES; + alterReq.alterType = PRIVILEGE_TYPE_READ; strcpy(alterReq.user, "u3"); strcpy(alterReq.pass, "1"); strcpy(alterReq.dbname, "1.d2"); diff --git a/source/dnode/mnode/sdb/inc/sdb.h b/source/dnode/mnode/sdb/inc/sdb.h index 695373d220..ddde645fae 100644 --- a/source/dnode/mnode/sdb/inc/sdb.h +++ b/source/dnode/mnode/sdb/inc/sdb.h @@ -148,7 +148,8 @@ typedef enum { SDB_DB = 19, SDB_FUNC = 20, SDB_IDX = 21, - SDB_MAX = 22 + SDB_VIEW = 22, + SDB_MAX = 23 } ESdbType; typedef struct SSdbRaw { diff --git a/source/dnode/mnode/sdb/src/sdbHash.c b/source/dnode/mnode/sdb/src/sdbHash.c index 09743d549a..df5c399da8 100644 --- a/source/dnode/mnode/sdb/src/sdbHash.c +++ b/source/dnode/mnode/sdb/src/sdbHash.c @@ -62,6 +62,8 @@ const char *sdbTableName(ESdbType type) { return "func"; case SDB_IDX: return "idx"; + case SDB_VIEW: + return "view"; default: return "undefine"; } diff --git a/source/dnode/vnode/src/tsdb/tsdbFSet2.c b/source/dnode/vnode/src/tsdb/tsdbFSet2.c index 642d555366..61bedcb996 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFSet2.c +++ b/source/dnode/vnode/src/tsdb/tsdbFSet2.c @@ -606,8 +606,10 @@ int32_t tsdbTFileSetRemove(STFileSet *fset) { if (fset == NULL) return 0; for (tsdb_ftype_t ftype = TSDB_FTYPE_MIN; ftype < TSDB_FTYPE_MAX; ++ftype) { - if (fset->farr[ftype] == NULL) continue; - tsdbTFileObjRemove(fset->farr[ftype]); + if (fset->farr[ftype] != NULL) { + tsdbTFileObjRemove(fset->farr[ftype]); + fset->farr[ftype] = NULL; + } } TARRAY2_DESTROY(fset->lvlArr, tsdbSttLvlRemove); diff --git a/source/dnode/vnode/src/tsdb/tsdbMerge.c b/source/dnode/vnode/src/tsdb/tsdbMerge.c index 0c20a342d3..0db8cf85ed 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMerge.c +++ b/source/dnode/vnode/src/tsdb/tsdbMerge.c @@ -483,11 +483,12 @@ _exit: } static int32_t tsdbDoMerge(SMerger *merger) { - int32_t code = 0; - int32_t lino = 0; - SSttLvl *lvl = TARRAY2_FIRST(merger->fset->lvlArr); + int32_t code = 0; + int32_t lino = 0; if (TARRAY2_SIZE(merger->fset->lvlArr) == 0) return 0; + + SSttLvl *lvl = TARRAY2_FIRST(merger->fset->lvlArr); if (lvl->level != 0 || TARRAY2_SIZE(lvl->fobjArr) < merger->sttTrigger) return 0; code = tsdbMergerOpen(merger); diff --git a/source/libs/catalog/inc/catalogInt.h b/source/libs/catalog/inc/catalogInt.h index 8c9275eb94..f9f4ee7dfc 100644 --- a/source/libs/catalog/inc/catalogInt.h +++ b/source/libs/catalog/inc/catalogInt.h @@ -30,6 +30,7 @@ extern "C" { #define CTG_DEFAULT_CACHE_VGROUP_NUMBER 100 #define CTG_DEFAULT_CACHE_DB_NUMBER 20 #define CTG_DEFAULT_CACHE_TBLMETA_NUMBER 1000 +#define CTG_DEFAULT_CACHE_VIEW_NUMBER 256 #define CTG_DEFAULT_RENT_SECOND 10 #define CTG_DEFAULT_RENT_SLOT_SIZE 10 #define CTG_DEFAULT_MAX_RETRY_TIMES 3 @@ -67,6 +68,7 @@ typedef enum { CTG_CI_USER, CTG_CI_UDF, CTG_CI_SVR_VER, + CTG_CI_VIEW, CTG_CI_MAX_VALUE, } CTG_CACHE_ITEM; @@ -82,6 +84,7 @@ enum { enum { CTG_RENT_DB = 1, CTG_RENT_STABLE, + CTG_RENT_VIEW, }; enum { @@ -96,6 +99,8 @@ enum { CTG_OP_UPDATE_VG_EPSET, CTG_OP_UPDATE_TB_INDEX, CTG_OP_DROP_TB_INDEX, + CTG_OP_UPDATE_VIEW_META, + CTG_OP_DROP_VIEW_META, CTG_OP_CLEAR_CACHE, CTG_OP_MAX }; @@ -117,6 +122,7 @@ typedef enum { CTG_TASK_GET_TB_META_BATCH, CTG_TASK_GET_TB_HASH_BATCH, CTG_TASK_GET_TB_TAG, + CTG_TASK_GET_VIEW, } CTG_TASK_TYPE; typedef enum { @@ -146,6 +152,7 @@ typedef struct SCtgAuthReq { SGetUserAuthRsp authInfo; AUTH_TYPE singleType; bool onlyCache; + bool tbNotExists; } SCtgAuthReq; typedef struct SCtgAuthRsp { @@ -238,8 +245,17 @@ typedef struct SCtgUdfCtx { typedef struct SCtgUserCtx { SUserAuthInfo user; + int32_t subTaskCode; } SCtgUserCtx; +typedef struct SCtgViewsCtx { + int32_t fetchNum; + SArray* pNames; + SArray* pResList; + SArray* pFetchs; +} SCtgViewsCtx; + + typedef STableIndexRsp STableIndex; typedef struct SCtgTbCache { @@ -259,12 +275,19 @@ typedef struct SCtgCfgCache { SDbCfgInfo* cfgInfo; } SCtgCfgCache; +typedef struct SCtgViewCache { + SRWLatch viewLock; + SViewMeta* pMeta; +} SCtgViewCache; + + typedef struct SCtgDBCache { SRWLatch dbLock; // RC between destroy tbCache/stbCache and all reads uint64_t dbId; int8_t deleted; SCtgVgCache vgCache; SCtgCfgCache cfgCache; + SHashObj* viewCache; // key:viewname, value:SCtgViewCache SHashObj* tbCache; // key:tbname, value:SCtgTbCache SHashObj* stbCache; // key:suid, value:char* uint64_t dbCacheNum[CTG_CI_MAX_VALUE]; @@ -294,13 +317,15 @@ typedef struct SCtgUserAuth { } SCtgUserAuth; typedef struct SCatalog { - uint64_t clusterId; - bool stopUpdate; - SHashObj* userCache; // key:user, value:SCtgUserAuth - SHashObj* dbCache; // key:dbname, value:SCtgDBCache - SCtgRentMgmt dbRent; - SCtgRentMgmt stbRent; - SCtgCacheStat cacheStat; + uint64_t clusterId; + bool stopUpdate; + SDynViewVersion dynViewVer; + SHashObj* userCache; // key:user, value:SCtgUserAuth + SHashObj* dbCache; // key:dbname, value:SCtgDBCache + SCtgRentMgmt dbRent; + SCtgRentMgmt stbRent; + SCtgRentMgmt viewRent; + SCtgCacheStat cacheStat; } SCatalog; typedef struct SCtgBatch { @@ -344,6 +369,7 @@ typedef struct SCtgJob { int32_t tbIndexNum; int32_t tbCfgNum; int32_t svrVerNum; + int32_t viewNum; } SCtgJob; typedef struct SCtgMsgCtx { @@ -509,6 +535,20 @@ typedef struct SCtgUpdateEpsetMsg { SEpSet epSet; } SCtgUpdateEpsetMsg; +typedef struct SCtgUpdateViewMetaMsg { + SCatalog* pCtg; + SViewMetaRsp* pRsp; +} SCtgUpdateViewMetaMsg; + +typedef struct SCtgDropViewMetaMsg { + SCatalog* pCtg; + char dbFName[TSDB_DB_FNAME_LEN]; + char viewName[TSDB_VIEW_NAME_LEN]; + uint64_t dbId; + uint64_t viewId; +} SCtgDropViewMetaMsg; + + typedef struct SCtgCacheOperation { int32_t opId; void* data; @@ -686,10 +726,10 @@ typedef struct SCtgCacheItemInfo { (CTG_FLAG_IS_UNKNOWN_STB(_flag) || (CTG_FLAG_IS_STB(_flag) && (tbType) == TSDB_SUPER_TABLE) || \ (CTG_FLAG_IS_NOT_STB(_flag) && (tbType) != TSDB_SUPER_TABLE)) +#define CTG_IS_BATCH_TASK(_taskType) ((CTG_TASK_GET_TB_META_BATCH == (_taskType)) || (CTG_TASK_GET_TB_HASH_BATCH == (_taskType)) || (CTG_TASK_GET_VIEW == (_taskType))) + #define CTG_GET_TASK_MSGCTX(_task, _id) \ - (((CTG_TASK_GET_TB_META_BATCH == (_task)->type) || (CTG_TASK_GET_TB_HASH_BATCH == (_task)->type)) \ - ? taosArrayGet((_task)->msgCtxs, (_id)) \ - : &(_task)->msgCtx) + (CTG_IS_BATCH_TASK((_task)->type) ? taosArrayGet((_task)->msgCtxs, (_id)) : &(_task)->msgCtx) #define CTG_META_SIZE(pMeta) \ (sizeof(STableMeta) + ((pMeta)->tableInfo.numOfTags + (pMeta)->tableInfo.numOfColumns) * sizeof(SSchema)) @@ -870,6 +910,7 @@ int32_t ctgOpDropDbCache(SCtgCacheOperation* action); int32_t ctgOpDropDbVgroup(SCtgCacheOperation* action); int32_t ctgOpDropStbMeta(SCtgCacheOperation* action); int32_t ctgOpDropTbMeta(SCtgCacheOperation* action); +int32_t ctgOpDropViewMeta(SCtgCacheOperation* action); int32_t ctgOpUpdateUser(SCtgCacheOperation* action); int32_t ctgOpUpdateEpset(SCtgCacheOperation* operation); int32_t ctgAcquireVgInfoFromCache(SCatalog* pCtg, const char* dbFName, SCtgDBCache** pCache); @@ -879,7 +920,7 @@ int32_t ctgTbMetaExistInCache(SCatalog* pCtg, char* dbFName, char* tbName, int32 int32_t ctgReadTbMetaFromCache(SCatalog* pCtg, SCtgTbMetaCtx* ctx, STableMeta** pTableMeta); int32_t ctgReadTbVerFromCache(SCatalog* pCtg, SName* pTableName, int32_t* sver, int32_t* tver, int32_t* tbType, uint64_t* suid, char* stbName); -int32_t ctgChkAuthFromCache(SCatalog* pCtg, SUserAuthInfo* pReq, bool* inCache, SCtgAuthRsp* pRes); +int32_t ctgChkAuthFromCache(SCatalog* pCtg, SUserAuthInfo* pReq, bool tbNotExists, bool* inCache, SCtgAuthRsp* pRes); int32_t ctgDropDbCacheEnqueue(SCatalog* pCtg, const char* dbFName, int64_t dbId); int32_t ctgDropDbVgroupEnqueue(SCatalog* pCtg, const char* dbFName, bool syncReq); int32_t ctgDropStbMetaEnqueue(SCatalog* pCtg, const char* dbFName, int64_t dbId, const char* stbName, uint64_t suid, @@ -891,11 +932,22 @@ int32_t ctgUpdateTbMetaEnqueue(SCatalog* pCtg, STableMetaOutput* output, bool sy int32_t ctgUpdateUserEnqueue(SCatalog* pCtg, SGetUserAuthRsp* pAuth, bool syncReq); int32_t ctgUpdateVgEpsetEnqueue(SCatalog* pCtg, char* dbFName, int32_t vgId, SEpSet* pEpSet); int32_t ctgUpdateTbIndexEnqueue(SCatalog* pCtg, STableIndex** pIndex, bool syncOp); +int32_t ctgDropViewMetaEnqueue(SCatalog *pCtg, const char *dbFName, uint64_t dbId, const char *viewName, uint64_t viewId, bool syncOp); int32_t ctgClearCacheEnqueue(SCatalog* pCtg, bool clearMeta, bool freeCtg, bool stopQueue, bool syncOp); int32_t ctgMetaRentInit(SCtgRentMgmt* mgmt, uint32_t rentSec, int8_t type, int32_t size); int32_t ctgMetaRentAdd(SCtgRentMgmt* mgmt, void* meta, int64_t id, int32_t size); +int32_t ctgMetaRentUpdate(SCtgRentMgmt *mgmt, void *meta, int64_t id, int32_t size, __compar_fn_t sortCompare, + __compar_fn_t searchCompare); int32_t ctgMetaRentGet(SCtgRentMgmt* mgmt, void** res, uint32_t* num, int32_t size); +int32_t ctgMetaRentRemove(SCtgRentMgmt *mgmt, int64_t id, __compar_fn_t sortCompare, __compar_fn_t searchCompare); +void ctgRemoveStbRent(SCatalog *pCtg, SCtgDBCache *dbCache); +void ctgRemoveViewRent(SCatalog *pCtg, SCtgDBCache *dbCache); +int32_t ctgUpdateRentStbVersion(SCatalog *pCtg, char *dbFName, char *tbName, uint64_t dbId, uint64_t suid, + SCtgTbCache *pCache); +int32_t ctgUpdateRentViewVersion(SCatalog *pCtg, char *dbFName, char *viewName, uint64_t dbId, uint64_t viewId, + SCtgViewCache *pCache); int32_t ctgUpdateTbMetaToCache(SCatalog* pCtg, STableMetaOutput* pOut, bool syncReq); +int32_t ctgUpdateViewMetaToCache(SCatalog *pCtg, SViewMetaRsp *pRsp, bool syncReq); int32_t ctgStartUpdateThread(); int32_t ctgRelaunchGetTbMetaTask(SCtgTask* pTask); void ctgReleaseVgInfoToCache(SCatalog* pCtg, SCtgDBCache* dbCache); @@ -904,9 +956,11 @@ int32_t ctgDropTbIndexEnqueue(SCatalog* pCtg, SName* pName, bool syncOp); int32_t ctgOpDropTbIndex(SCtgCacheOperation* operation); int32_t ctgOpUpdateTbIndex(SCtgCacheOperation* operation); int32_t ctgOpClearCache(SCtgCacheOperation* operation); +int32_t ctgOpUpdateViewMeta(SCtgCacheOperation *operation); int32_t ctgReadTbTypeFromCache(SCatalog* pCtg, char* dbFName, char* tableName, int32_t* tbType); int32_t ctgGetTbHashVgroupFromCache(SCatalog* pCtg, const SName* pTableName, SVgroupInfo** pVgroup); - +int32_t ctgGetViewsFromCache(SCatalog *pCtg, SRequestConnInfo *pConn, SCtgViewsCtx *ctx, int32_t dbIdx, + int32_t *fetchIdx, int32_t baseResIdx, SArray *pList); int32_t ctgProcessRspMsg(void* out, int32_t reqType, char* msg, int32_t msgSize, int32_t rspCode, char* target); int32_t ctgGetDBVgInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SBuildUseDBInput* input, SUseDbOutput* out, SCtgTaskReq* tReq); @@ -932,6 +986,8 @@ int32_t ctgGetTableCfgFromVnode(SCatalog* pCtg, SRequestConnInfo* pConn, const S int32_t ctgGetTableCfgFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, STableCfg** out, SCtgTask* pTask); int32_t ctgGetSvrVerFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, char** out, SCtgTask* pTask); +int32_t ctgGetViewInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SName* pName, SViewMetaOutput* out, + SCtgTaskReq* tReq); int32_t ctgLaunchBatchs(SCatalog* pCtg, SCtgJob* pJob, SHashObj* pBatchs); int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const SCatalogReq* pReq, catalogCallback fp, @@ -942,6 +998,7 @@ int32_t ctgLaunchSubTask(SCtgTask** ppTask, CTG_TASK_TYPE type, ctgSubTaskCbFp f int32_t ctgGetTbCfgCb(SCtgTask* pTask); void ctgFreeHandle(SCatalog* pCatalog); +void ctgFreeSViewMeta(SViewMeta* pMeta); void ctgFreeMsgSendParam(void* param); void ctgFreeBatch(SCtgBatch* pBatch); void ctgFreeBatchs(SHashObj* pBatchs); @@ -958,9 +1015,11 @@ int32_t ctgGetVgIdsFromHashValue(SCatalog* pCtg, SDBVgInfo* dbInfo, char* dbFNam void ctgResetTbMetaTask(SCtgTask* pTask); void ctgFreeDbCache(SCtgDBCache* dbCache); int32_t ctgStbVersionSortCompare(const void* key1, const void* key2); +int32_t ctgViewVersionSortCompare(const void* key1, const void* key2); int32_t ctgDbCacheInfoSortCompare(const void* key1, const void* key2); int32_t ctgStbVersionSearchCompare(const void* key1, const void* key2); int32_t ctgDbCacheInfoSearchCompare(const void* key1, const void* key2); +int32_t ctgViewVersionSearchCompare(const void* key1, const void* key2); void ctgFreeSTableMetaOutput(STableMetaOutput* pOutput); int32_t ctgUpdateMsgCtx(SCtgMsgCtx* pCtx, int32_t reqType, void* out, char* target); int32_t ctgAddMsgCtx(SArray* pCtxs, int32_t reqType, void* out, char* target); @@ -974,8 +1033,9 @@ void ctgClearSubTaskRes(SCtgSubRes* pRes); void ctgFreeQNode(SCtgQNode* node); void ctgClearHandle(SCatalog* pCtg); void ctgFreeTbCacheImpl(SCtgTbCache* pCache, bool lock); +void ctgFreeViewCacheImpl(SCtgViewCache* pCache, bool lock); int32_t ctgRemoveTbMeta(SCatalog* pCtg, SName* pTableName); -int32_t ctgRemoveCacheUser(SCatalog* pCtg, const char* user); +int32_t ctgRemoveCacheUser(SCatalog* pCtg, SCtgUserAuth* pUser, const char* user); int32_t ctgGetTbHashVgroup(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, SVgroupInfo* pVgroup, bool* exists); SName* ctgGetFetchName(SArray* pNames, SCtgFetch* pFetch); @@ -993,8 +1053,12 @@ void ctgReleaseVgMetaToCache(SCatalog* pCtg, SCtgDBCache* dbCache, SCtgTbCach void ctgReleaseTbMetaToCache(SCatalog* pCtg, SCtgDBCache* dbCache, SCtgTbCache* pCache); void ctgGetGlobalCacheStat(SCtgCacheStat* pStat); int32_t ctgChkSetAuthRes(SCatalog* pCtg, SCtgAuthReq* req, SCtgAuthRsp* res); +int32_t ctgBuildViewNullRes(SCtgTask* pTask, SCtgViewsCtx* pCtx); +int32_t dupViewMetaFromRsp(SViewMetaRsp* pRsp, SViewMeta* pViewMeta); +void ctgDestroySMetaData(SMetaData* pData); void ctgGetGlobalCacheSize(uint64_t *pSize); uint64_t ctgGetTbIndexCacheSize(STableIndex *pIndex); +uint64_t ctgGetViewMetaCacheSize(SViewMeta *pMeta); uint64_t ctgGetTbMetaCacheSize(STableMeta *pMeta); uint64_t ctgGetDbVgroupCacheSize(SDBVgInfo *pVg); uint64_t ctgGetUserCacheSize(SGetUserAuthRsp *pAuth); diff --git a/source/libs/catalog/src/catalog.c b/source/libs/catalog/src/catalog.c index 44854d334b..c2d88e5ce3 100644 --- a/source/libs/catalog/src/catalog.c +++ b/source/libs/catalog/src/catalog.c @@ -325,7 +325,7 @@ int32_t ctgChkAuth(SCatalog* pCtg, SRequestConnInfo* pConn, SUserAuthInfo *pReq, SCtgAuthRsp rsp = {0}; rsp.pRawRes = pRes; - CTG_ERR_RET(ctgChkAuthFromCache(pCtg, pReq, &inCache, &rsp)); + CTG_ERR_RET(ctgChkAuthFromCache(pCtg, pReq, false, &inCache, &rsp)); if (inCache) { if (exists) { @@ -665,9 +665,32 @@ _return: CTG_RET(code); } + +int32_t ctgRemoveViewMeta(SCatalog* pCtg, const char* dbFName, uint64_t dbId, const char* viewName, uint64_t viewId) { + int32_t code = 0; + + if (NULL == pCtg || NULL == dbFName || NULL == viewName) { + CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT); + } + + if (NULL == pCtg->dbCache) { + return TSDB_CODE_SUCCESS; + } + + CTG_ERR_JRET(ctgDropViewMetaEnqueue(pCtg, dbFName, 0, viewName, viewId, true)); + +_return: + + CTG_RET(code); +} + + void ctgProcessTimerEvent(void *param, void *tmrId) { CTG_API_NENTER(); + ctgdShowCacheInfo(); + ctgdShowStatInfo(); + int32_t cacheMaxSize = atomic_load_32(&tsMetaCacheMaxSize); if (cacheMaxSize >= 0) { uint64_t cacheSize = 0; @@ -732,6 +755,10 @@ int32_t catalogInit(SCatalogCfg* cfg) { gCtgMgmt.cfg.maxTblCacheNum = CTG_DEFAULT_CACHE_TBLMETA_NUMBER; } + if (gCtgMgmt.cfg.maxViewCacheNum == 0) { + gCtgMgmt.cfg.maxViewCacheNum = CTG_DEFAULT_CACHE_VIEW_NUMBER; + } + if (gCtgMgmt.cfg.dbRentSec == 0) { gCtgMgmt.cfg.dbRentSec = CTG_DEFAULT_RENT_SECOND; } @@ -739,11 +766,17 @@ int32_t catalogInit(SCatalogCfg* cfg) { if (gCtgMgmt.cfg.stbRentSec == 0) { gCtgMgmt.cfg.stbRentSec = CTG_DEFAULT_RENT_SECOND; } + + if (gCtgMgmt.cfg.viewRentSec == 0) { + gCtgMgmt.cfg.viewRentSec = CTG_DEFAULT_RENT_SECOND; + } } else { gCtgMgmt.cfg.maxDBCacheNum = CTG_DEFAULT_CACHE_DB_NUMBER; gCtgMgmt.cfg.maxTblCacheNum = CTG_DEFAULT_CACHE_TBLMETA_NUMBER; + gCtgMgmt.cfg.maxViewCacheNum = CTG_DEFAULT_CACHE_VIEW_NUMBER; gCtgMgmt.cfg.dbRentSec = CTG_DEFAULT_RENT_SECOND; gCtgMgmt.cfg.stbRentSec = CTG_DEFAULT_RENT_SECOND; + gCtgMgmt.cfg.viewRentSec = CTG_DEFAULT_RENT_SECOND; } gCtgMgmt.pCluster = taosHashInit(CTG_DEFAULT_CACHE_CLUSTER_NUMBER, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), @@ -828,6 +861,7 @@ int32_t catalogGetHandle(uint64_t clusterId, SCatalog** catalogHandle) { CTG_ERR_JRET(ctgMetaRentInit(&clusterCtg->dbRent, gCtgMgmt.cfg.dbRentSec, CTG_RENT_DB, sizeof(SDbCacheInfo))); CTG_ERR_JRET(ctgMetaRentInit(&clusterCtg->stbRent, gCtgMgmt.cfg.stbRentSec, CTG_RENT_STABLE, sizeof(SSTableVersion))); + CTG_ERR_JRET(ctgMetaRentInit(&clusterCtg->viewRent, gCtgMgmt.cfg.viewRentSec, CTG_RENT_VIEW, sizeof(SViewVersion))); clusterCtg->dbCache = taosHashInit(gCtgMgmt.cfg.maxDBCacheNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK); @@ -1461,6 +1495,25 @@ int32_t catalogGetExpiredSTables(SCatalog* pCtg, SSTableVersion** stables, uint3 CTG_API_LEAVE(ctgMetaRentGet(&pCtg->stbRent, (void**)stables, num, sizeof(SSTableVersion))); } +int32_t catalogGetExpiredViews(SCatalog* pCtg, SViewVersion** views, uint32_t* num, SDynViewVersion** dynViewVersion) { + CTG_API_ENTER(); + + if (NULL == pCtg || NULL == views || NULL == num) { + CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); + } + + *dynViewVersion = taosMemoryMalloc(sizeof(SDynViewVersion)); + if (NULL == *dynViewVersion) { + CTG_API_LEAVE(TSDB_CODE_OUT_OF_MEMORY); + } + + (*dynViewVersion)->svrBootTs = atomic_load_64(&pCtg->dynViewVer.svrBootTs); + (*dynViewVersion)->dynViewVer = atomic_load_64(&pCtg->dynViewVer.dynViewVer); + + CTG_API_LEAVE(ctgMetaRentGet(&pCtg->viewRent, (void**)views, num, sizeof(SViewVersion))); +} + + int32_t catalogGetExpiredDBs(SCatalog* pCtg, SDbCacheInfo** dbs, uint32_t* num) { CTG_API_ENTER(); @@ -1651,6 +1704,71 @@ int32_t catalogUpdateUserAuthInfo(SCatalog* pCtg, SGetUserAuthRsp* pAuth) { CTG_API_LEAVE(ctgUpdateUserEnqueue(pCtg, pAuth, false)); } +void catalogFreeMetaData(SMetaData * pData) { + ctgDestroySMetaData(pData); +} + +int32_t catalogRemoveViewMeta(SCatalog* pCtg, const char* dbFName, uint64_t dbId, const char* viewName, uint64_t viewId) { + CTG_API_ENTER(); + + CTG_API_LEAVE(ctgRemoveViewMeta(pCtg, dbFName, dbId, viewName, viewId)); +} + + +int32_t catalogUpdateDynViewVer(SCatalog* pCtg, SDynViewVersion* pVer) { + CTG_API_ENTER(); + + if (NULL == pCtg || NULL == pVer) { + CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); + } + + atomic_store_64(&pCtg->dynViewVer.svrBootTs, pVer->svrBootTs); + atomic_store_64(&pCtg->dynViewVer.dynViewVer, pVer->dynViewVer); + + ctgDebug("cluster %" PRIx64 " svrBootTs updated to %" PRId64, pCtg->clusterId, pVer->svrBootTs); + ctgDebug("cluster %" PRIx64 " dynViewVer updated to %" PRId64, pCtg->clusterId, pVer->dynViewVer); + + CTG_API_LEAVE(TSDB_CODE_SUCCESS); +} + +int32_t catalogUpdateViewMeta(SCatalog* pCtg, SViewMetaRsp* pMsg) { + CTG_API_ENTER(); + + if (NULL == pCtg || NULL == pMsg) { + tFreeSViewMetaRsp(pMsg); + CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); + } + + int32_t code = 0; + CTG_ERR_JRET(ctgUpdateViewMetaToCache(pCtg, pMsg, true)); + +_return: + + CTG_API_LEAVE(code); +} + + +int32_t catalogAsyncUpdateViewMeta(SCatalog* pCtg, SViewMetaRsp* pMsg) { + CTG_API_ENTER(); + + if (NULL == pCtg || NULL == pMsg) { + CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); + } + + int32_t code = 0; + CTG_ERR_JRET(ctgUpdateViewMetaToCache(pCtg, pMsg, false)); + +_return: + + CTG_API_LEAVE(code); +} + +int32_t catalogGetViewMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pViewName, STableMeta** pTableMeta) { + CTG_API_ENTER(); + + CTG_API_LEAVE(TSDB_CODE_OPS_NOT_SUPPORT); +} + int32_t catalogClearCache(void) { CTG_API_ENTER_NOLOCK(); diff --git a/source/libs/catalog/src/ctgAsync.c b/source/libs/catalog/src/ctgAsync.c index ba7106ea51..00567f0acb 100644 --- a/source/libs/catalog/src/ctgAsync.c +++ b/source/libs/catalog/src/ctgAsync.c @@ -20,6 +20,30 @@ #include "tref.h" #include "trpc.h" + +void ctgIsTaskDone(SCtgJob* pJob, CTG_TASK_TYPE type, bool* done) { + SCtgTask* pTask = NULL; + + *done = true; + + CTG_LOCK(CTG_READ, &pJob->taskLock); + + int32_t taskNum = taosArrayGetSize(pJob->pTasks); + for (int32_t i = 0; i < taskNum; ++i) { + pTask = taosArrayGet(pJob->pTasks, i); + if (type != pTask->type) { + continue; + } + + if (pTask->status != CTG_TASK_DONE) { + *done = false; + break; + } + } + + CTG_UNLOCK(CTG_READ, &pJob->taskLock); +} + int32_t ctgInitGetTbMetaTask(SCtgJob* pJob, int32_t taskIdx, void* param) { SCtgTbMetaParam* pParam = (SCtgTbMetaParam*)param; SName* name = pParam->pName; @@ -53,7 +77,6 @@ int32_t ctgInitGetTbMetaTask(SCtgJob* pJob, int32_t taskIdx, void* param) { } int32_t ctgInitGetTbMetasTask(SCtgJob* pJob, int32_t taskIdx, void* param) { - SName* name = (SName*)param; SCtgTask task = {0}; task.type = CTG_TASK_GET_TB_META_BATCH; @@ -184,7 +207,6 @@ int32_t ctgInitGetTbHashTask(SCtgJob* pJob, int32_t taskIdx, void* param) { } int32_t ctgInitGetTbHashsTask(SCtgJob* pJob, int32_t taskIdx, void* param) { - SName* name = (SName*)param; SCtgTask task = {0}; task.type = CTG_TASK_GET_TB_HASH_BATCH; @@ -417,6 +439,43 @@ int32_t ctgInitGetTbTagTask(SCtgJob* pJob, int32_t taskIdx, void* param) { return TSDB_CODE_SUCCESS; } +int32_t ctgInitGetViewsTask(SCtgJob* pJob, int32_t taskIdx, void* param) { + SCtgTask task = {0}; + + task.type = CTG_TASK_GET_VIEW; + task.taskId = taskIdx; + task.pJob = pJob; + + task.taskCtx = taosMemoryCalloc(1, sizeof(SCtgViewsCtx)); + if (NULL == task.taskCtx) { + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + + SCtgViewsCtx* ctx = task.taskCtx; + ctx->pNames = param; + ctx->pResList = taosArrayInit(pJob->viewNum, sizeof(SMetaRes)); + + taosArrayPush(pJob->pTasks, &task); + + qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, dbNum:%lu, viewNum:%d", pJob->queryId, taskIdx, + ctgTaskTypeStr(task.type), taosArrayGetSize(ctx->pNames), pJob->viewNum); + + return TSDB_CODE_SUCCESS; +} + +int32_t ctgHandleForceUpdateView(SCatalog* pCtg, const SCatalogReq* pReq) { + int32_t viewNum = taosArrayGetSize(pReq->pView); + for (int32_t i = 0; i < viewNum; ++i) { + STablesReq* p = taosArrayGet(pReq->pView, i); + int32_t viewNum = taosArrayGetSize(p->pTables); + for (int32_t m = 0; m < viewNum; ++m) { + SName* name = taosArrayGet(p->pTables, m); + ctgDropViewMetaEnqueue(pCtg, p->dbFName, 0, name->tname, 0, true); + } + } + return TSDB_CODE_SUCCESS; +} + int32_t ctgHandleForceUpdate(SCatalog* pCtg, int32_t taskNum, SCtgJob* pJob, const SCatalogReq* pReq) { SHashObj* pDb = taosHashInit(taskNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); @@ -464,6 +523,12 @@ int32_t ctgHandleForceUpdate(SCatalog* pCtg, int32_t taskNum, SCtgJob* pJob, con } } + dbNum = taosArrayGetSize(pReq->pView); + for (int32_t i = 0; i < dbNum; ++i) { + STablesReq* p = taosArrayGet(pReq->pView, i); + taosHashPut(pDb, p->dbFName, strlen(p->dbFName), p->dbFName, TSDB_DB_FNAME_LEN); + } + for (int32_t i = 0; i < pJob->tbCfgNum; ++i) { SName* name = taosArrayGet(pReq->pTableCfg, i); char dbFName[TSDB_DB_FNAME_LEN]; @@ -508,7 +573,8 @@ int32_t ctgHandleForceUpdate(SCatalog* pCtg, int32_t taskNum, SCtgJob* pJob, con ctgDropTbIndexEnqueue(pCtg, name, true); } - return TSDB_CODE_SUCCESS; + // REFRESH VIEW META + return ctgHandleForceUpdateView(pCtg, pReq); } int32_t ctgInitTask(SCtgJob* pJob, CTG_TASK_TYPE type, void* param, int32_t* taskId) { @@ -547,9 +613,10 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const int32_t tbIndexNum = (int32_t)taosArrayGetSize(pReq->pTableIndex); int32_t tbCfgNum = (int32_t)taosArrayGetSize(pReq->pTableCfg); int32_t tbTagNum = (int32_t)taosArrayGetSize(pReq->pTableTag); + int32_t viewNum = (int32_t)ctgGetTablesReqNum(pReq->pView); int32_t taskNum = tbMetaNum + dbVgNum + udfNum + tbHashNum + qnodeNum + dnodeNum + svrVerNum + dbCfgNum + indexNum + - userNum + dbInfoNum + tbIndexNum + tbCfgNum + tbTagNum; + userNum + dbInfoNum + tbIndexNum + tbCfgNum + tbTagNum + viewNum; *job = taosMemoryCalloc(1, sizeof(SCtgJob)); if (NULL == *job) { @@ -559,6 +626,7 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const SCtgJob* pJob = *job; + pJob->jobRes.ctgFree = true; pJob->subTaskNum = taskNum; pJob->queryId = pConn->requestId; pJob->userFp = fp; @@ -580,6 +648,7 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const pJob->tbCfgNum = tbCfgNum; pJob->svrVerNum = svrVerNum; pJob->tbTagNum = tbTagNum; + pJob->viewNum = viewNum; #if CTG_BATCH_FETCH pJob->pBatchs = @@ -668,6 +737,10 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const CTG_ERR_JRET(ctgInitTask(pJob, CTG_TASK_GET_USER, user, NULL)); } + if (viewNum > 0) { + CTG_ERR_JRET(ctgInitTask(pJob, CTG_TASK_GET_VIEW, pReq->pView, NULL)); + } + if (qnodeNum) { CTG_ERR_JRET(ctgInitTask(pJob, CTG_TASK_GET_QNODE, NULL, NULL)); } @@ -1001,6 +1074,20 @@ int32_t ctgDumpSvrVer(SCtgTask* pTask) { return TSDB_CODE_SUCCESS; } + +int32_t ctgDumpViewsRes(SCtgTask* pTask) { + if (pTask->subTask) { + return TSDB_CODE_SUCCESS; + } + + SCtgJob* pJob = pTask->pJob; + + pJob->jobRes.pView = pTask->res; + + return TSDB_CODE_SUCCESS; +} + + int32_t ctgCallSubCb(SCtgTask* pTask) { int32_t code = 0; @@ -1773,6 +1860,68 @@ _return: CTG_RET(code); } +int32_t ctgHandleGetViewsRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf* pMsg, int32_t rspCode) { + int32_t code = 0; + SCtgTask* pTask = tReq->pTask; + SCatalog* pCtg = pTask->pJob->pCtg; + SRequestConnInfo* pConn = &pTask->pJob->conn; + SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, tReq->msgIdx); + SCtgViewsCtx* ctx = (SCtgViewsCtx*)pTask->taskCtx; + SCtgFetch* pFetch = taosArrayGet(ctx->pFetchs, tReq->msgIdx); + SName* pName = ctgGetFetchName(ctx->pNames, pFetch); + int32_t flag = pFetch->flag; + int32_t* vgId = &pFetch->vgId; + bool taskDone = false; + + CTG_ERR_JRET(ctgProcessRspMsg(pMsgCtx->out, reqType, pMsg->pData, pMsg->len, rspCode, pMsgCtx->target)); + + SViewMetaRsp* pRsp = *(SViewMetaRsp**)pMsgCtx->out; + SViewMeta* pViewMeta = taosMemoryCalloc(1, sizeof(SViewMeta)); + if (NULL == pViewMeta) { + CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + } + + if (TSDB_CODE_SUCCESS != (code = dupViewMetaFromRsp(pRsp, pViewMeta))) { + ctgFreeSViewMeta(pViewMeta); + taosMemoryFree(pViewMeta); + CTG_ERR_JRET(code); + } + + ctgDebug("start to update view meta to cache, view:%s, querySQL:%s", pRsp->name, pRsp->querySql); + ctgUpdateViewMetaToCache(pCtg, pRsp, false); + taosMemoryFreeClear(pMsgCtx->out); + pRsp = NULL; + + SMetaRes* pRes = taosArrayGet(ctx->pResList, pFetch->resIdx); + pRes->code = 0; + pRes->pRes = pViewMeta; + if (0 == atomic_sub_fetch_32(&ctx->fetchNum, 1)) { + TSWAP(pTask->res, ctx->pResList); + taskDone = true; + } + +_return: + + if (code) { + SMetaRes* pRes = taosArrayGet(ctx->pResList, pFetch->resIdx); + pRes->code = code; + pRes->pRes = NULL; + ctgTaskError("Get view %d.%s.%s meta failed with error %s", pName->acctId, pName->dbname, pName->tname, + tstrerror(code)); + if (0 == atomic_sub_fetch_32(&ctx->fetchNum, 1)) { + TSWAP(pTask->res, ctx->pResList); + taskDone = true; + } + } + + if (pTask->res && taskDone) { + ctgHandleTaskEnd(pTask, code); + } + + CTG_RET(code); +} + + int32_t ctgAsyncRefreshTbMeta(SCtgTaskReq* tReq, int32_t flag, SName* pName, int32_t* vgId) { SCtgTask* pTask = tReq->pTask; SCatalog* pCtg = pTask->pJob->pCtg; @@ -2305,6 +2454,7 @@ int32_t ctgLaunchGetUserTask(SCtgTask* pTask) { bool inCache = false; SCtgAuthRsp rsp = {0}; SCtgJob* pJob = pTask->pJob; + bool tbNotExists = false; SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1); if (NULL == pMsgCtx->pBatchs) { pMsgCtx->pBatchs = pJob->pBatchs; @@ -2314,12 +2464,22 @@ int32_t ctgLaunchGetUserTask(SCtgTask* pTask) { if (NULL == rsp.pRawRes) { CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } + + if (TSDB_CODE_SUCCESS != pCtx->subTaskCode) { + if (CTG_TABLE_NOT_EXIST(pCtx->subTaskCode)) { + tbNotExists = true; + pCtx->subTaskCode = 0; + } else { + CTG_ERR_RET(pCtx->subTaskCode); + } + } - CTG_ERR_RET(ctgChkAuthFromCache(pCtg, &pCtx->user, &inCache, &rsp)); + CTG_ERR_RET(ctgChkAuthFromCache(pCtg, &pCtx->user, tbNotExists, &inCache, &rsp)); if (inCache) { pTask->res = rsp.pRawRes; - ctgTaskDebug("Final res got, pass:%d, pCond:%p", rsp.pRawRes->pass, rsp.pRawRes->pCond); + ctgTaskDebug("Final res got, pass:[%d,%d], pCond:[%p,%p]", + rsp.pRawRes->pass[0], rsp.pRawRes->pass[1], rsp.pRawRes->pCond[0], rsp.pRawRes->pCond[1]); CTG_ERR_RET(ctgHandleTaskEnd(pTask, 0)); return TSDB_CODE_SUCCESS; @@ -2355,6 +2515,59 @@ int32_t ctgLaunchGetSvrVerTask(SCtgTask* pTask) { return TSDB_CODE_SUCCESS; } +int32_t ctgLaunchGetViewsTask(SCtgTask* pTask) { + SCatalog* pCtg = pTask->pJob->pCtg; + SRequestConnInfo* pConn = &pTask->pJob->conn; + SCtgViewsCtx* pCtx = (SCtgViewsCtx*)pTask->taskCtx; + SCtgJob* pJob = pTask->pJob; + bool tbMetaDone = false; + + ctgIsTaskDone(pJob, CTG_TASK_GET_TB_META_BATCH, &tbMetaDone); + if (tbMetaDone) { + CTG_ERR_RET(ctgBuildViewNullRes(pTask, pCtx)); + TSWAP(pTask->res, pCtx->pResList); + + CTG_ERR_RET(ctgHandleTaskEnd(pTask, 0)); + return TSDB_CODE_SUCCESS; + } + + int32_t dbNum = taosArrayGetSize(pCtx->pNames); + int32_t fetchIdx = 0; + int32_t baseResIdx = 0; + for (int32_t i = 0; i < dbNum; ++i) { + STablesReq* pReq = taosArrayGet(pCtx->pNames, i); + ctgDebug("start to check views in db %s, viewNum %ld", pReq->dbFName, taosArrayGetSize(pReq->pTables)); + CTG_ERR_RET(ctgGetViewsFromCache(pCtg, pConn, pCtx, i, &fetchIdx, baseResIdx, pReq->pTables)); + baseResIdx += taosArrayGetSize(pReq->pTables); + } + + pCtx->fetchNum = taosArrayGetSize(pCtx->pFetchs); + if (pCtx->fetchNum <= 0) { + TSWAP(pTask->res, pCtx->pResList); + + CTG_ERR_RET(ctgHandleTaskEnd(pTask, 0)); + return TSDB_CODE_SUCCESS; + } + + pTask->msgCtxs = taosArrayInit_s(sizeof(SCtgMsgCtx), pCtx->fetchNum); + for (int32_t i = 0; i < pCtx->fetchNum; ++i) { + SCtgFetch* pFetch = taosArrayGet(pCtx->pFetchs, i); + SName* pName = ctgGetFetchName(pCtx->pNames, pFetch); + SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, i); + if (NULL == pMsgCtx->pBatchs) { + pMsgCtx->pBatchs = pJob->pBatchs; + } + + SCtgTaskReq tReq; + tReq.pTask = pTask; + tReq.msgIdx = pFetch->fetchIdx; + CTG_ERR_RET(ctgGetViewInfoFromMnode(pCtg, pConn, pName, NULL, &tReq)); + } + + return TSDB_CODE_SUCCESS; +} + + int32_t ctgRelaunchGetTbMetaTask(SCtgTask* pTask) { ctgResetTbMetaTask(pTask); @@ -2410,8 +2623,9 @@ _return: int32_t ctgGetUserCb(SCtgTask* pTask) { int32_t code = 0; - CTG_ERR_JRET(pTask->subRes.code); - + SCtgUserCtx* pCtx = (SCtgUserCtx*)pTask->taskCtx; + pCtx->subTaskCode = pTask->subRes.code; + CTG_RET(ctgLaunchGetUserTask(pTask)); _return: @@ -2470,6 +2684,7 @@ SCtgAsyncFps gCtgAsyncFps[] = { {ctgInitGetTbMetasTask, ctgLaunchGetTbMetasTask, ctgHandleGetTbMetasRsp, ctgDumpTbMetasRes, NULL, NULL}, {ctgInitGetTbHashsTask, ctgLaunchGetTbHashsTask, ctgHandleGetTbHashsRsp, ctgDumpTbHashsRes, NULL, NULL}, {ctgInitGetTbTagTask, ctgLaunchGetTbTagTask, ctgHandleGetTbTagRsp, ctgDumpTbTagRes, NULL, NULL}, + {ctgInitGetViewsTask, ctgLaunchGetViewsTask, ctgHandleGetViewsRsp, ctgDumpViewsRes, NULL, NULL}, }; int32_t ctgMakeAsyncRes(SCtgJob* pJob) { diff --git a/source/libs/catalog/src/ctgCache.c b/source/libs/catalog/src/ctgCache.c index 5c8a1f456d..1b693b4e07 100644 --- a/source/libs/catalog/src/ctgCache.c +++ b/source/libs/catalog/src/ctgCache.c @@ -30,6 +30,8 @@ SCtgOperation gCtgCacheOperation[CTG_OP_MAX] = {{CTG_OP_UPDATE_VGROUP, "update v {CTG_OP_UPDATE_VG_EPSET, "update epset", ctgOpUpdateEpset}, {CTG_OP_UPDATE_TB_INDEX, "update tbIndex", ctgOpUpdateTbIndex}, {CTG_OP_DROP_TB_INDEX, "drop tbIndex", ctgOpDropTbIndex}, + {CTG_OP_UPDATE_VIEW_META, "update viewMeta", ctgOpUpdateViewMeta}, + {CTG_OP_DROP_VIEW_META, "drop viewMeta", ctgOpDropViewMeta}, {CTG_OP_CLEAR_CACHE, "clear cache", ctgOpClearCache}}; SCtgCacheItemInfo gCtgStatItem[CTG_CI_MAX_VALUE] = { @@ -49,6 +51,7 @@ SCtgCacheItemInfo gCtgStatItem[CTG_CI_MAX_VALUE] = { {"TblCfg ", CTG_CI_FLAG_LEVEL_DB}, //CTG_CI_TBL_CFG, {"TblTag ", CTG_CI_FLAG_LEVEL_DB}, //CTG_CI_TBL_TAG, {"IndexInfo ", CTG_CI_FLAG_LEVEL_DB}, //CTG_CI_INDEX_INFO, + {"viewMeta ", CTG_CI_FLAG_LEVEL_DB}, //CTG_CI_VIEW, {"User ", CTG_CI_FLAG_LEVEL_CLUSTER}, //CTG_CI_USER, {"UDF ", CTG_CI_FLAG_LEVEL_CLUSTER}, //CTG_CI_UDF, {"SvrVer ", CTG_CI_FLAG_LEVEL_CLUSTER} //CTG_CI_SVR_VER, @@ -171,6 +174,18 @@ void ctgReleaseTbMetaToCache(SCatalog *pCtg, SCtgDBCache *dbCache, SCtgTbCache * } } +void ctgReleaseViewMetaToCache(SCatalog *pCtg, SCtgDBCache *dbCache, SCtgViewCache *pCache) { + if (pCache && dbCache) { + CTG_UNLOCK(CTG_READ, &pCache->viewLock); + taosHashRelease(dbCache->viewCache, pCache); + } + + if (dbCache) { + ctgReleaseDBCache(pCtg, dbCache); + } +} + + void ctgReleaseTbIndexToCache(SCatalog *pCtg, SCtgDBCache *dbCache, SCtgTbCache *pCache) { if (pCache) { CTG_UNLOCK(CTG_READ, &pCache->indexLock); @@ -773,7 +788,7 @@ int32_t ctgGetCachedStbNameFromSuid(SCatalog* pCtg, char* dbFName, uint64_t suid } -int32_t ctgChkAuthFromCache(SCatalog *pCtg, SUserAuthInfo *pReq, bool *inCache, SCtgAuthRsp *pRes) { +int32_t ctgChkAuthFromCache(SCatalog *pCtg, SUserAuthInfo *pReq, bool tbNotExists, bool *inCache, SCtgAuthRsp *pRes) { int32_t code = 0; SCtgUserAuth *pUser = (SCtgUserAuth *)taosHashGet(pCtg->userCache, pReq->user, strlen(pReq->user)); @@ -790,6 +805,7 @@ int32_t ctgChkAuthFromCache(SCatalog *pCtg, SUserAuthInfo *pReq, bool *inCache, SCtgAuthReq req = {0}; req.pRawReq = pReq; req.onlyCache = true; + req.tbNotExists = tbNotExists; CTG_LOCK(CTG_READ, &pUser->lock); memcpy(&req.authInfo, &pUser->userAuth, sizeof(pUser->userAuth)); @@ -1268,208 +1284,75 @@ _return: CTG_RET(code); } -int32_t ctgMetaRentInit(SCtgRentMgmt *mgmt, uint32_t rentSec, int8_t type, int32_t size) { - mgmt->slotRIdx = 0; - mgmt->slotNum = rentSec / CTG_RENT_SLOT_SECOND; - mgmt->type = type; - mgmt->metaSize = size; +int32_t ctgUpdateViewMetaEnqueue(SCatalog *pCtg, SViewMetaRsp *pRsp, bool syncOp) { + int32_t code = 0; + SCtgCacheOperation *op = taosMemoryCalloc(1, sizeof(SCtgCacheOperation)); + op->opId = CTG_OP_UPDATE_VIEW_META; + op->syncOp = syncOp; - size_t msgSize = sizeof(SCtgRentSlot) * mgmt->slotNum; + SCtgUpdateViewMetaMsg *msg = taosMemoryMalloc(sizeof(SCtgUpdateViewMetaMsg)); + if (NULL == msg) { + ctgError("malloc %d failed", (int32_t)sizeof(SCtgUpdateViewMetaMsg)); + taosMemoryFree(op); + CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + } - mgmt->slots = taosMemoryCalloc(1, msgSize); - if (NULL == mgmt->slots) { - qError("calloc %d failed", (int32_t)msgSize); + char *p = strchr(pRsp->dbFName, '.'); + if (p && IS_SYS_DBNAME(p + 1)) { + int32_t len = strlen(p + 1); + memmove(pRsp->dbFName, p + 1, len >= TSDB_DB_FNAME_LEN ? TSDB_DB_FNAME_LEN - 1 : len); + } + + msg->pCtg = pCtg; + msg->pRsp = pRsp; + + op->data = msg; + + CTG_ERR_RET(ctgEnqueue(pCtg, op)); + + return TSDB_CODE_SUCCESS; + + +_return: + + if (pRsp) { + tFreeSViewMetaRsp(pRsp); + taosMemoryFree(pRsp); + } + + CTG_RET(code); +} + +int32_t ctgDropViewMetaEnqueue(SCatalog *pCtg, const char *dbFName, uint64_t dbId, const char *viewName, uint64_t viewId, bool syncOp) { + int32_t code = 0; + SCtgCacheOperation *op = taosMemoryCalloc(1, sizeof(SCtgCacheOperation)); + op->opId = CTG_OP_DROP_VIEW_META; + op->syncOp = syncOp; + + SCtgDropViewMetaMsg *msg = taosMemoryMalloc(sizeof(SCtgDropViewMetaMsg)); + if (NULL == msg) { + ctgError("malloc %d failed", (int32_t)sizeof(SCtgDropViewMetaMsg)); + taosMemoryFree(op); CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } - mgmt->rentCacheSize = msgSize; + msg->pCtg = pCtg; + tstrncpy(msg->dbFName, dbFName, sizeof(msg->dbFName)); + tstrncpy(msg->viewName, viewName, sizeof(msg->viewName)); + msg->dbId = dbId; + msg->viewId = viewId; - qDebug("meta rent initialized, type:%d, slotNum:%d", type, mgmt->slotNum); + op->data = msg; + + CTG_ERR_JRET(ctgEnqueue(pCtg, op)); return TSDB_CODE_SUCCESS; -} - -int32_t ctgMetaRentAdd(SCtgRentMgmt *mgmt, void *meta, int64_t id, int32_t size) { - int16_t widx = abs((int)(id % mgmt->slotNum)); - - SCtgRentSlot *slot = &mgmt->slots[widx]; - int32_t code = 0; - - CTG_LOCK(CTG_WRITE, &slot->lock); - if (NULL == slot->meta) { - slot->meta = taosArrayInit(CTG_DEFAULT_RENT_SLOT_SIZE, size); - if (NULL == slot->meta) { - qError("taosArrayInit %d failed, id:0x%" PRIx64 ", slot idx:%d, type:%d", CTG_DEFAULT_RENT_SLOT_SIZE, id, widx, - mgmt->type); - CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); - } - } - - if (NULL == taosArrayPush(slot->meta, meta)) { - qError("taosArrayPush meta to rent failed, id:0x%" PRIx64 ", slot idx:%d, type:%d", id, widx, mgmt->type); - CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); - } - - mgmt->rentCacheSize += size; - slot->needSort = true; - - qDebug("add meta to rent, id:0x%" PRIx64 ", slot idx:%d, type:%d", id, widx, mgmt->type); _return: - CTG_UNLOCK(CTG_WRITE, &slot->lock); - CTG_RET(code); -} - -int32_t ctgMetaRentUpdate(SCtgRentMgmt *mgmt, void *meta, int64_t id, int32_t size, __compar_fn_t sortCompare, - __compar_fn_t searchCompare) { - int16_t widx = abs((int)(id % mgmt->slotNum)); - - SCtgRentSlot *slot = &mgmt->slots[widx]; - int32_t code = 0; - - CTG_LOCK(CTG_WRITE, &slot->lock); - if (NULL == slot->meta) { - qDebug("empty meta slot, id:0x%" PRIx64 ", slot idx:%d, type:%d", id, widx, mgmt->type); - CTG_ERR_JRET(TSDB_CODE_CTG_INTERNAL_ERROR); - } - - if (slot->needSort) { - qDebug("meta slot before sorte, slot idx:%d, type:%d, size:%d", widx, mgmt->type, - (int32_t)taosArrayGetSize(slot->meta)); - taosArraySort(slot->meta, sortCompare); - slot->needSort = false; - qDebug("meta slot sorted, slot idx:%d, type:%d, size:%d", widx, mgmt->type, (int32_t)taosArrayGetSize(slot->meta)); - } - - void *orig = taosArraySearch(slot->meta, &id, searchCompare, TD_EQ); - if (NULL == orig) { - qDebug("meta not found in slot, id:0x%" PRIx64 ", slot idx:%d, type:%d, size:%d", id, widx, mgmt->type, - (int32_t)taosArrayGetSize(slot->meta)); - CTG_ERR_JRET(TSDB_CODE_CTG_INTERNAL_ERROR); - } - - memcpy(orig, meta, size); - - qDebug("meta in rent updated, id:0x%" PRIx64 ", slot idx:%d, type:%d", id, widx, mgmt->type); - -_return: - - CTG_UNLOCK(CTG_WRITE, &slot->lock); - - if (code) { - qDebug("meta in rent update failed, will try to add it, code:%x, id:0x%" PRIx64 ", slot idx:%d, type:%d", code, id, - widx, mgmt->type); - CTG_RET(ctgMetaRentAdd(mgmt, meta, id, size)); - } - CTG_RET(code); } -int32_t ctgMetaRentRemove(SCtgRentMgmt *mgmt, int64_t id, __compar_fn_t sortCompare, __compar_fn_t searchCompare) { - int16_t widx = abs((int)(id % mgmt->slotNum)); - - SCtgRentSlot *slot = &mgmt->slots[widx]; - int32_t code = 0; - - CTG_LOCK(CTG_WRITE, &slot->lock); - if (NULL == slot->meta) { - qError("empty meta slot, id:0x%" PRIx64 ", slot idx:%d, type:%d", id, widx, mgmt->type); - CTG_ERR_JRET(TSDB_CODE_CTG_INTERNAL_ERROR); - } - - if (slot->needSort) { - taosArraySort(slot->meta, sortCompare); - slot->needSort = false; - qDebug("meta slot sorted, slot idx:%d, type:%d", widx, mgmt->type); - } - - int32_t idx = taosArraySearchIdx(slot->meta, &id, searchCompare, TD_EQ); - if (idx < 0) { - qError("meta not found in slot, id:0x%" PRIx64 ", slot idx:%d, type:%d", id, widx, mgmt->type); - CTG_ERR_JRET(TSDB_CODE_CTG_INTERNAL_ERROR); - } - - taosArrayRemove(slot->meta, idx); - mgmt->rentCacheSize -= mgmt->metaSize; - - qDebug("meta in rent removed, id:0x%" PRIx64 ", slot idx:%d, type:%d", id, widx, mgmt->type); - -_return: - - CTG_UNLOCK(CTG_WRITE, &slot->lock); - - CTG_RET(code); -} - -int32_t ctgMetaRentGetImpl(SCtgRentMgmt *mgmt, void **res, uint32_t *num, int32_t size) { - int16_t ridx = atomic_add_fetch_16(&mgmt->slotRIdx, 1); - if (ridx >= mgmt->slotNum) { - ridx %= mgmt->slotNum; - atomic_store_16(&mgmt->slotRIdx, ridx); - } - - SCtgRentSlot *slot = &mgmt->slots[ridx]; - int32_t code = 0; - - CTG_LOCK(CTG_READ, &slot->lock); - if (NULL == slot->meta) { - qDebug("empty meta in slot:%d, type:%d", ridx, mgmt->type); - *num = 0; - goto _return; - } - - size_t metaNum = taosArrayGetSize(slot->meta); - if (metaNum <= 0) { - qDebug("no meta in slot:%d, type:%d", ridx, mgmt->type); - *num = 0; - goto _return; - } - - size_t msize = metaNum * size; - *res = taosMemoryMalloc(msize); - if (NULL == *res) { - qError("malloc %d failed", (int32_t)msize); - CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); - } - - void *meta = taosArrayGet(slot->meta, 0); - - memcpy(*res, meta, msize); - - *num = (uint32_t)metaNum; - - qDebug("Got %d meta from rent, type:%d", (int32_t)metaNum, mgmt->type); - -_return: - - CTG_UNLOCK(CTG_READ, &slot->lock); - - CTG_RET(code); -} - -int32_t ctgMetaRentGet(SCtgRentMgmt *mgmt, void **res, uint32_t *num, int32_t size) { - while (true) { - int64_t msec = taosGetTimestampMs(); - int64_t lsec = atomic_load_64(&mgmt->lastReadMsec); - if ((msec - lsec) < CTG_RENT_SLOT_SECOND * 1000) { - *res = NULL; - *num = 0; - qDebug("too short time period to get expired meta, type:%d", mgmt->type); - return TSDB_CODE_SUCCESS; - } - - if (lsec != atomic_val_compare_exchange_64(&mgmt->lastReadMsec, lsec, msec)) { - continue; - } - - break; - } - - CTG_ERR_RET(ctgMetaRentGetImpl(mgmt, res, num, size)); - - return TSDB_CODE_SUCCESS; -} int32_t ctgAddNewDBCache(SCatalog *pCtg, const char *dbFName, uint64_t dbId) { int32_t code = 0; @@ -1480,7 +1363,7 @@ int32_t ctgAddNewDBCache(SCatalog *pCtg, const char *dbFName, uint64_t dbId) { newDBCache.tbCache = taosHashInit(gCtgMgmt.cfg.maxTblCacheNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); if (NULL == newDBCache.tbCache) { - ctgError("taosHashInit %d metaCache failed", gCtgMgmt.cfg.maxTblCacheNum); + ctgError("taosHashInit %d tbCache failed", gCtgMgmt.cfg.maxTblCacheNum); CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } @@ -1491,6 +1374,13 @@ int32_t ctgAddNewDBCache(SCatalog *pCtg, const char *dbFName, uint64_t dbId) { CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } + newDBCache.viewCache = taosHashInit(gCtgMgmt.cfg.maxViewCacheNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), + true, HASH_ENTRY_LOCK); + if (NULL == newDBCache.viewCache) { + ctgError("taosHashInit %d viewCache failed", gCtgMgmt.cfg.maxViewCacheNum); + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + code = taosHashPut(pCtg->dbCache, dbFName, strlen(dbFName), &newDBCache, sizeof(SCtgDBCache)); if (code) { if (HASH_NODE_EXIST(code)) { @@ -1524,25 +1414,6 @@ _return: CTG_RET(code); } -void ctgRemoveStbRent(SCatalog *pCtg, SCtgDBCache *dbCache) { - if (NULL == dbCache->stbCache) { - return; - } - - void *pIter = taosHashIterate(dbCache->stbCache, NULL); - while (pIter) { - uint64_t *suid = NULL; - suid = taosHashGetKey(pIter, NULL); - - if (TSDB_CODE_SUCCESS == - ctgMetaRentRemove(&pCtg->stbRent, *suid, ctgStbVersionSortCompare, ctgStbVersionSearchCompare)) { - ctgDebug("stb removed from rent, suid:0x%" PRIx64, *suid); - } - - pIter = taosHashIterate(dbCache->stbCache, pIter); - } -} - int32_t ctgRemoveDBFromCache(SCatalog *pCtg, SCtgDBCache *dbCache, const char *dbFName) { uint64_t dbId = dbCache->dbId; @@ -1552,6 +1423,7 @@ int32_t ctgRemoveDBFromCache(SCatalog *pCtg, SCtgDBCache *dbCache, const char *d atomic_store_8(&dbCache->deleted, 1); ctgRemoveStbRent(pCtg, dbCache); + ctgRemoveViewRent(pCtg, dbCache); ctgFreeDbCache(dbCache); CTG_UNLOCK(CTG_WRITE, &dbCache->dbLock); @@ -1611,30 +1483,6 @@ int32_t ctgGetAddDBCache(SCatalog *pCtg, const char *dbFName, uint64_t dbId, SCt return TSDB_CODE_SUCCESS; } -int32_t ctgUpdateRentStbVersion(SCatalog *pCtg, char *dbFName, char *tbName, uint64_t dbId, uint64_t suid, - SCtgTbCache *pCache) { - SSTableVersion metaRent = {.dbId = dbId, .suid = suid}; - if (pCache->pMeta) { - metaRent.sversion = pCache->pMeta->sversion; - metaRent.tversion = pCache->pMeta->tversion; - } - - if (pCache->pIndex) { - metaRent.smaVer = pCache->pIndex->version; - } - - tstrncpy(metaRent.dbFName, dbFName, sizeof(metaRent.dbFName)); - tstrncpy(metaRent.stbName, tbName, sizeof(metaRent.stbName)); - - CTG_ERR_RET(ctgMetaRentUpdate(&pCtg->stbRent, &metaRent, metaRent.suid, sizeof(SSTableVersion), - ctgStbVersionSortCompare, ctgStbVersionSearchCompare)); - - ctgDebug("db %s,0x%" PRIx64 " stb %s,0x%" PRIx64 " sver %d tver %d smaVer %d updated to stbRent", dbFName, dbId, - tbName, suid, metaRent.sversion, metaRent.tversion, metaRent.smaVer); - - return TSDB_CODE_SUCCESS; -} - int32_t ctgWriteTbMetaToCache(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, uint64_t dbId, char *tbName, STableMeta *meta, int32_t metaSize) { if (NULL == dbCache->tbCache || NULL == dbCache->stbCache) { @@ -1787,6 +1635,65 @@ int32_t ctgWriteTbIndexToCache(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFNa return TSDB_CODE_SUCCESS; } +int32_t ctgWriteViewMetaToCache(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, char *viewName, SViewMeta *pMeta) { + int32_t code = TSDB_CODE_SUCCESS; + if (NULL == dbCache->viewCache) { + ctgWarn("db is dropping, dbId:0x%" PRIx64, dbCache->dbId); + CTG_ERR_JRET(TSDB_CODE_CTG_DB_DROPPED); + } + + SCtgViewCache *pCache = taosHashGet(dbCache->viewCache, viewName, strlen(viewName)); + if (NULL == pCache) { + SCtgViewCache cache = {0}; + cache.pMeta = pMeta; + + if (taosHashPut(dbCache->viewCache, viewName, strlen(viewName), &cache, sizeof(cache)) != 0) { + ctgError("taosHashPut new tbCache failed, viewName:%s", viewName); + CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + } + + atomic_add_fetch_64(&dbCache->dbCacheSize, strlen(viewName) + sizeof(SCtgViewCache) + ctgGetViewMetaCacheSize(pMeta)); + + CTG_DB_NUM_INC(CTG_CI_VIEW); + + ctgDebug("new view meta updated to cache, view:%s, id:%" PRIu64 ", ver:%d, effectiveUser:%s, querySQL:%s", + viewName, pMeta->viewId, pMeta->version, pMeta->user, pMeta->querySql); + + CTG_ERR_RET(ctgUpdateRentViewVersion(pCtg, dbFName, viewName, dbCache->dbId, pMeta->viewId, &cache)); + + return TSDB_CODE_SUCCESS; + } + + CTG_LOCK(CTG_WRITE, &pCache->viewLock); + + if (pCache->pMeta) { + atomic_sub_fetch_64(&dbCache->dbCacheSize, ctgGetViewMetaCacheSize(pCache->pMeta)); + ctgFreeSViewMeta(pCache->pMeta); + taosMemoryFree(pCache->pMeta); + } + + pCache->pMeta = pMeta; + CTG_UNLOCK(CTG_WRITE, &pCache->viewLock); + + atomic_add_fetch_64(&dbCache->dbCacheSize, ctgGetViewMetaCacheSize(pMeta)); + + ctgDebug("view meta updated to cache, view:%s, id:%" PRIu64 ", ver:%d, effectiveUser:%s, querySQL:%s", + viewName, pMeta->viewId, pMeta->version, pMeta->user, pMeta->querySql); + + CTG_ERR_RET(ctgUpdateRentViewVersion(pCtg, dbFName, viewName, dbCache->dbId, pMeta->viewId, pCache)); + + pMeta = NULL; + +_return: + + if (pMeta) { + ctgFreeSViewMeta(pMeta); + taosMemoryFree(pMeta); + } + + CTG_RET(code); +} + int32_t ctgUpdateTbMetaToCache(SCatalog *pCtg, STableMetaOutput *pOut, bool syncReq) { STableMetaOutput *pOutput = NULL; int32_t code = 0; @@ -1804,6 +1711,11 @@ _return: CTG_RET(code); } +int32_t ctgUpdateViewMetaToCache(SCatalog *pCtg, SViewMetaRsp *pRsp, bool syncReq) { + CTG_RET(ctgUpdateViewMetaEnqueue(pCtg, pRsp, syncReq)); +} + + void ctgClearAllHandles(void) { SCatalog *pCtg = NULL; @@ -2138,7 +2050,7 @@ int32_t ctgOpDropStbMeta(SCtgCacheOperation *operation) { goto _return; } - if (msg->dbId && (dbCache->dbId != msg->dbId)) { + if ((0 != msg->dbId) && (dbCache->dbId != msg->dbId)) { ctgDebug("dbId already modified, dbFName:%s, current:0x%" PRIx64 ", dbId:0x%" PRIx64 ", stb:%s, suid:0x%" PRIx64, msg->dbFName, dbCache->dbId, msg->dbId, msg->stbName, msg->suid); goto _return; @@ -2201,7 +2113,7 @@ int32_t ctgOpDropTbMeta(SCtgCacheOperation *operation) { goto _return; } - if (dbCache->dbId != msg->dbId) { + if ((0 != msg->dbId) && (dbCache->dbId != msg->dbId)) { ctgDebug("dbId 0x%" PRIx64 " not match with curId 0x%" PRIx64 ", dbFName:%s, tbName:%s", msg->dbId, dbCache->dbId, msg->dbFName, msg->tbName); goto _return; @@ -2265,7 +2177,7 @@ int32_t ctgOpUpdateUser(SCtgCacheOperation *operation) { return TSDB_CODE_SUCCESS; } else if (msg->userAuth.dropped == 1) { - if (ctgRemoveCacheUser(pCtg, msg->userAuth.user) == 0) { + if (ctgRemoveCacheUser(pCtg, pUser, msg->userAuth.user) == 0) { CTG_CACHE_NUM_DEC(CTG_CI_USER, 1); } goto _return; @@ -2278,6 +2190,10 @@ int32_t ctgOpUpdateUser(SCtgCacheOperation *operation) { taosHashCleanup(pUser->userAuth.writeDbs); taosHashCleanup(pUser->userAuth.readTbs); taosHashCleanup(pUser->userAuth.writeTbs); + taosHashCleanup(pUser->userAuth.alterTbs); + taosHashCleanup(pUser->userAuth.readViews); + taosHashCleanup(pUser->userAuth.writeViews); + taosHashCleanup(pUser->userAuth.alterViews); taosHashCleanup(pUser->userAuth.useDbs); memcpy(&pUser->userAuth, &msg->userAuth, sizeof(msg->userAuth)); @@ -2287,6 +2203,10 @@ int32_t ctgOpUpdateUser(SCtgCacheOperation *operation) { msg->userAuth.writeDbs = NULL; msg->userAuth.readTbs = NULL; msg->userAuth.writeTbs = NULL; + msg->userAuth.alterTbs = NULL; + msg->userAuth.readViews = NULL; + msg->userAuth.writeViews = NULL; + msg->userAuth.alterViews = NULL; msg->userAuth.useDbs = NULL; CTG_UNLOCK(CTG_WRITE, &pUser->lock); @@ -2300,6 +2220,10 @@ _return: taosHashCleanup(msg->userAuth.writeDbs); taosHashCleanup(msg->userAuth.readTbs); taosHashCleanup(msg->userAuth.writeTbs); + taosHashCleanup(msg->userAuth.alterTbs); + taosHashCleanup(msg->userAuth.readViews); + taosHashCleanup(msg->userAuth.writeViews); + taosHashCleanup(msg->userAuth.alterViews); taosHashCleanup(msg->userAuth.useDbs); taosMemoryFreeClear(msg); @@ -2427,6 +2351,106 @@ _return: CTG_RET(code); } + +int32_t ctgOpUpdateViewMeta(SCtgCacheOperation *operation) { + int32_t code = 0; + SCtgUpdateViewMetaMsg *msg = operation->data; + SCatalog *pCtg = msg->pCtg; + SViewMetaRsp *pRsp = msg->pRsp; + SCtgDBCache *dbCache = NULL; + SViewMeta *pMeta = NULL; + + taosMemoryFreeClear(msg); + + if (pCtg->stopUpdate) { + goto _return; + } + + CTG_ERR_JRET(ctgGetAddDBCache(pCtg, pRsp->dbFName, pRsp->dbId, &dbCache)); + if (NULL == dbCache) { + ctgInfo("conflict db update, ignore this update, dbFName:%s, dbId:0x%" PRIx64, pRsp->dbFName, pRsp->dbId); + CTG_ERR_JRET(TSDB_CODE_CTG_INTERNAL_ERROR); + } + + pMeta = taosMemoryCalloc(1, sizeof(SViewMeta)); + if (NULL == pMeta) { + CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + } + + CTG_ERR_JRET(dupViewMetaFromRsp(pRsp, pMeta)); + + code = ctgWriteViewMetaToCache(pCtg, dbCache, pRsp->dbFName, pRsp->name, pMeta); + pMeta = NULL; + +_return: + + tFreeSViewMetaRsp(pRsp); + taosMemoryFree(pRsp); + ctgFreeSViewMeta(pMeta); + taosMemoryFree(pMeta); + + CTG_RET(code); +} + +int32_t ctgOpDropViewMeta(SCtgCacheOperation *operation) { + int32_t code = 0; + SCtgDropViewMetaMsg *msg = operation->data; + SCatalog *pCtg = msg->pCtg; + int32_t tblType = 0; + + if (pCtg->stopUpdate) { + goto _return; + } + + SCtgDBCache *dbCache = NULL; + ctgGetDBCache(pCtg, msg->dbFName, &dbCache); + if (NULL == dbCache) { + goto _return; + } + + if ((0 != msg->dbId) && (dbCache->dbId != msg->dbId)) { + ctgDebug("dbId 0x%" PRIx64 " not match with curId 0x%" PRIx64 ", dbFName:%s, viewName:%s", msg->dbId, dbCache->dbId, + msg->dbFName, msg->viewName); + goto _return; + } + + SCtgViewCache *pViewCache = taosHashGet(dbCache->viewCache, msg->viewName, strlen(msg->viewName)); + if (NULL == pViewCache) { + ctgDebug("view %s already not in cache", msg->viewName); + goto _return; + } + + int64_t viewId = pViewCache->pMeta->viewId; + if (0 != msg->viewId && viewId != msg->viewId) { + ctgDebug("viewId 0x%" PRIx64 " not match with curId 0x%" PRIx64 ", viewName:%s", msg->viewId, viewId, msg->viewName); + goto _return; + } + + atomic_sub_fetch_64(&dbCache->dbCacheSize, ctgGetViewMetaCacheSize(pViewCache->pMeta)); + ctgFreeViewCacheImpl(pViewCache, true); + + if (taosHashRemove(dbCache->viewCache, msg->viewName, strlen(msg->viewName))) { + ctgError("view %s not exist in cache, dbFName:%s", msg->viewName, msg->dbFName); + CTG_ERR_JRET(TSDB_CODE_CTG_INTERNAL_ERROR); + } else { + atomic_sub_fetch_64(&dbCache->dbCacheSize, sizeof(SCtgViewCache) + strlen(msg->viewName)); + CTG_DB_NUM_DEC(CTG_CI_VIEW); + } + + ctgDebug("view %s removed from cache, dbFName:%s", msg->viewName, msg->dbFName); + + CTG_ERR_JRET(ctgMetaRentRemove(&msg->pCtg->viewRent, viewId, ctgViewVersionSortCompare, ctgViewVersionSearchCompare)); + + ctgDebug("view %s removed from rent, dbFName:%s, viewId:0x%" PRIx64, msg->viewName, msg->dbFName, viewId); + +_return: + + taosMemoryFreeClear(msg); + + CTG_RET(code); +} + + void ctgClearFreeCache(SCtgCacheOperation *operation) { SCtgClearCacheMsg *msg = operation->data; SCatalog *pCtg = msg->pCtg; @@ -2529,6 +2553,7 @@ void ctgFreeCacheOperationData(SCtgCacheOperation *op) { case CTG_OP_DROP_TB_META: case CTG_OP_UPDATE_VG_EPSET: case CTG_OP_DROP_TB_INDEX: + case CTG_OP_DROP_VIEW_META: case CTG_OP_CLEAR_CACHE: { taosMemoryFreeClear(op->data); break; @@ -2540,6 +2565,10 @@ void ctgFreeCacheOperationData(SCtgCacheOperation *op) { taosHashCleanup(msg->userAuth.writeDbs); taosHashCleanup(msg->userAuth.readTbs); taosHashCleanup(msg->userAuth.writeTbs); + taosHashCleanup(msg->userAuth.alterTbs); + taosHashCleanup(msg->userAuth.readViews); + taosHashCleanup(msg->userAuth.writeViews); + taosHashCleanup(msg->userAuth.alterViews); taosHashCleanup(msg->userAuth.useDbs); taosMemoryFreeClear(op->data); break; @@ -2787,6 +2816,7 @@ int32_t ctgGetTbMetasFromCache(SCatalog *pCtg, SRequestConnInfo *pConn, SCtgTbMe CTG_LOCK(CTG_READ, &pCache->metaLock); if (NULL == pCache->pMeta) { CTG_UNLOCK(CTG_READ, &pCache->metaLock); + taosHashRelease(dbCache->tbCache, pCache); ctgDebug("tb %s meta not in cache, dbFName:%s", pName->tname, dbFName); ctgAddFetch(&ctx->pFetchs, dbIdx, i, fetchIdx, baseResIdx + i, flag); taosArrayPush(ctx->pResList, &(SMetaRes){0}); @@ -3006,3 +3036,105 @@ _return: CTG_RET(code); } + + +int32_t ctgGetViewsFromCache(SCatalog *pCtg, SRequestConnInfo *pConn, SCtgViewsCtx *ctx, int32_t dbIdx, + int32_t *fetchIdx, int32_t baseResIdx, SArray *pList) { + int32_t tbNum = taosArrayGetSize(pList); + SName *pName = taosArrayGet(pList, 0); + char dbFName[TSDB_DB_FNAME_LEN] = {0}; + int32_t flag = CTG_FLAG_UNKNOWN_STB; + uint64_t lastSuid = 0; + STableMeta *lastTableMeta = NULL; + + if (IS_SYS_DBNAME(pName->dbname)) { + CTG_FLAG_SET_SYS_DB(flag); + strcpy(dbFName, pName->dbname); + } else { + tNameGetFullDbName(pName, dbFName); + } + + SCtgDBCache *dbCache = NULL; + SCtgViewCache *pCache = NULL; + ctgAcquireDBCache(pCtg, dbFName, &dbCache); + + if (NULL == dbCache) { + ctgDebug("db %s not in cache", dbFName); + for (int32_t i = 0; i < tbNum; ++i) { + ctgAddFetch(&ctx->pFetchs, dbIdx, i, fetchIdx, baseResIdx + i, flag); + taosArrayPush(ctx->pResList, &(SMetaData){0}); + } + + return TSDB_CODE_SUCCESS; + } + + for (int32_t i = 0; i < tbNum; ++i) { + pName = taosArrayGet(pList, i); + + pCache = taosHashAcquire(dbCache->viewCache, pName->tname, strlen(pName->tname)); + if (NULL == pCache) { + ctgDebug("view %s not in cache, dbFName:%s", pName->tname, dbFName); + ctgAddFetch(&ctx->pFetchs, dbIdx, i, fetchIdx, baseResIdx + i, flag); + taosArrayPush(ctx->pResList, &(SMetaRes){0}); + CTG_CACHE_NHIT_INC(CTG_CI_VIEW, 1); + + continue; + } + + CTG_LOCK(CTG_READ, &pCache->viewLock); + if (NULL == pCache->pMeta) { + CTG_UNLOCK(CTG_READ, &pCache->viewLock); + taosHashRelease(dbCache->viewCache, pCache); + ctgDebug("view %s meta not in cache, dbFName:%s", pName->tname, dbFName); + ctgAddFetch(&ctx->pFetchs, dbIdx, i, fetchIdx, baseResIdx + i, flag); + taosArrayPush(ctx->pResList, &(SMetaRes){0}); + CTG_CACHE_NHIT_INC(CTG_CI_VIEW, 1); + + continue; + } + + CTG_CACHE_HIT_INC(CTG_CI_VIEW, 1); + + SMetaRes res = {0}; + SViewMeta *pViewMeta = taosMemoryCalloc(1, sizeof(SViewMeta)); + if (NULL == pViewMeta) { + ctgReleaseViewMetaToCache(pCtg, dbCache, pCache); + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + + memcpy(pViewMeta, pCache->pMeta, sizeof(*pViewMeta)); + pViewMeta->querySql = tstrdup(pCache->pMeta->querySql); + pViewMeta->user = tstrdup(pCache->pMeta->user); + if (NULL == pViewMeta->querySql || NULL == pViewMeta->user) { + ctgReleaseViewMetaToCache(pCtg, dbCache, pCache); + pViewMeta->pSchema = NULL; + taosMemoryFree(pViewMeta->querySql); + taosMemoryFree(pViewMeta->user); + taosMemoryFree(pViewMeta); + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + pViewMeta->pSchema = taosMemoryMalloc(pViewMeta->numOfCols * sizeof(SSchema)); + if (pViewMeta->pSchema == NULL) { + ctgReleaseViewMetaToCache(pCtg, dbCache, pCache); + ctgFreeSViewMeta(pViewMeta); + taosMemoryFree(pViewMeta); + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + memcpy(pViewMeta->pSchema, pCache->pMeta->pSchema, pViewMeta->numOfCols * sizeof(SSchema)); + + CTG_UNLOCK(CTG_READ, &pCache->viewLock); + taosHashRelease(dbCache->viewCache, pCache); + + ctgDebug("Got view %s meta from cache, dbFName:%s", pName->tname, dbFName); + + res.pRes = pViewMeta; + taosArrayPush(ctx->pResList, &res); + } + + ctgReleaseDBCache(pCtg, dbCache); + + return TSDB_CODE_SUCCESS; +} + + + diff --git a/source/libs/catalog/src/ctgDbg.c b/source/libs/catalog/src/ctgDbg.c index 7cba6ddf0d..8590080fad 100644 --- a/source/libs/catalog/src/ctgDbg.c +++ b/source/libs/catalog/src/ctgDbg.c @@ -253,6 +253,12 @@ int32_t ctgdEnableDebug(char *option, bool enable) { return TSDB_CODE_SUCCESS; } + if (0 == strcasecmp(option, "stat")) { + gCTGDebug.statEnable = enable; + qDebug("catalog stat debug set to %d", enable); + return TSDB_CODE_SUCCESS; + } + if (0 == strcasecmp(option, "stopUpdate")) { SCatalog *pCtg = NULL; @@ -320,6 +326,11 @@ int32_t ctgdHandleDbgCommand(char *command) { CTG_RET(TSDB_CODE_INVALID_PARA); } + if (NULL == param || NULL == option) { + taosMemoryFree(dup); + CTG_RET(TSDB_CODE_INVALID_PARA); + } + bool enable = atoi(param); int32_t code = ctgdEnableDebug(option, enable); @@ -361,6 +372,10 @@ int32_t ctgdGetTbMetaNum(SCtgDBCache *dbCache) { return dbCache->tbCache ? (int32_t)taosHashGetSize(dbCache->tbCache) : 0; } +int32_t ctgdGetViewNum(SCtgDBCache *dbCache) { + return dbCache->viewCache ? (int32_t)taosHashGetSize(dbCache->viewCache) : 0; +} + int32_t ctgdGetStbNum(SCtgDBCache *dbCache) { return dbCache->stbCache ? (int32_t)taosHashGetSize(dbCache->stbCache) : 0; } @@ -391,6 +406,8 @@ int32_t ctgdGetClusterCacheNum(SCatalog *pCtg, int32_t type) { return ctgdGetRentNum(&pCtg->dbRent); case CTG_DBG_STB_RENT_NUM: return ctgdGetRentNum(&pCtg->stbRent); + case CTG_DBG_VIEW_RENT_NUM: + return ctgdGetRentNum(&pCtg->viewRent); default: break; } @@ -407,6 +424,8 @@ int32_t ctgdGetClusterCacheNum(SCatalog *pCtg, int32_t type) { case CTG_DBG_STB_NUM: num += ctgdGetStbNum(dbCache); break; + case CTG_DBG_VIEW_NUM: + num += ctgdGetViewNum(dbCache); default: ctgError("invalid type:%d", type); break; @@ -459,6 +478,7 @@ void ctgdShowDBCache(SCatalog *pCtg, SHashObj *dbHash) { dbFName = taosHashGetKey(pIter, &len); int32_t metaNum = dbCache->tbCache ? taosHashGetSize(dbCache->tbCache) : 0; + int32_t viewNum = dbCache->viewCache ? taosHashGetSize(dbCache->viewCache) : 0; int32_t stbNum = dbCache->stbCache ? taosHashGetSize(dbCache->stbCache) : 0; int32_t vgVersion = CTG_DEFAULT_INVALID_VERSION; int32_t hashMethod = -1; @@ -479,8 +499,8 @@ void ctgdShowDBCache(SCatalog *pCtg, SHashObj *dbHash) { } ctgDebug("[%d] db [%.*s][0x%" PRIx64 - "] %s: metaNum:%d, stbNum:%d, vgVersion:%d, stateTs:%" PRId64 ", hashMethod:%d, prefix:%d, suffix:%d, vgNum:%d", - i, (int32_t)len, dbFName, dbCache->dbId, dbCache->deleted ? "deleted" : "", metaNum, stbNum, vgVersion, stateTs, + "] %s: metaNum:%d, viewNum:%d, stbNum:%d, vgVersion:%d, stateTs:%" PRId64 ", hashMethod:%d, prefix:%d, suffix:%d, vgNum:%d", + i, (int32_t)len, dbFName, dbCache->dbId, dbCache->deleted ? "deleted" : "", metaNum, viewNum, stbNum, vgVersion, stateTs, hashMethod, hashPrefix, hashSuffix, vgNum); if (dbCache->vgCache.vgInfo) { @@ -530,9 +550,10 @@ void ctgdShowClusterCache(SCatalog *pCtg) { } ctgDebug("## cluster 0x%" PRIx64 " %p cache Info BEGIN ##", pCtg->clusterId, pCtg); - ctgDebug("db:%d meta:%d stb:%d dbRent:%d stbRent:%d", ctgdGetClusterCacheNum(pCtg, CTG_DBG_DB_NUM), - ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM), ctgdGetClusterCacheNum(pCtg, CTG_DBG_STB_NUM), - ctgdGetClusterCacheNum(pCtg, CTG_DBG_DB_RENT_NUM), ctgdGetClusterCacheNum(pCtg, CTG_DBG_STB_RENT_NUM)); + ctgDebug("db:%d tbmeta:%d viewmeta:%d stb:%d dbRent:%d stbRent:%d viewRent:%d", ctgdGetClusterCacheNum(pCtg, CTG_DBG_DB_NUM), + ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM), ctgdGetClusterCacheNum(pCtg, CTG_DBG_VIEW_NUM), + ctgdGetClusterCacheNum(pCtg, CTG_DBG_STB_NUM), ctgdGetClusterCacheNum(pCtg, CTG_DBG_DB_RENT_NUM), + ctgdGetClusterCacheNum(pCtg, CTG_DBG_STB_RENT_NUM), ctgdGetClusterCacheNum(pCtg, CTG_DBG_VIEW_RENT_NUM)); ctgdShowDBCache(pCtg, pCtg->dbCache); diff --git a/source/libs/catalog/src/ctgRemote.c b/source/libs/catalog/src/ctgRemote.c index 4a05510217..3a12d822f4 100644 --- a/source/libs/catalog/src/ctgRemote.c +++ b/source/libs/catalog/src/ctgRemote.c @@ -318,6 +318,21 @@ int32_t ctgProcessRspMsg(void* out, int32_t reqType, char* msg, int32_t msgSize, qDebug("Got svr ver from mnode"); break; } + case TDMT_MND_VIEW_META: { + if (TSDB_CODE_SUCCESS != rspCode) { + qError("error rsp for get view-meta, error:%s, viewFName:%s", tstrerror(rspCode), target); + CTG_ERR_RET(rspCode); + } + + code = queryProcessMsgRsp[TMSG_INDEX(reqType)](out, msg, msgSize); + if (code) { + qError("Process get view-meta rsp failed, error:%s, viewFName:%s", tstrerror(code), target); + CTG_ERR_RET(code); + } + + qDebug("Got view-meta from mnode, viewFName:%s", target); + break; + } default: if (TSDB_CODE_SUCCESS != rspCode) { qError("Got error rsp, error:%s", tstrerror(rspCode)); @@ -1388,3 +1403,60 @@ int32_t ctgGetSvrVerFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, char** ou return TSDB_CODE_SUCCESS; } + +int32_t ctgGetViewInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SName* pName, SViewMetaOutput* out, + SCtgTaskReq* tReq) { + char* msg = NULL; + int32_t msgLen = 0; + int32_t reqType = TDMT_MND_VIEW_META; + SCtgTask* pTask = tReq ? tReq->pTask : NULL; + void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemoryMalloc : (MallocType)rpcMallocCont; + char fullName[TSDB_TABLE_FNAME_LEN]; + tNameExtractFullName(pName, fullName); + + ctgDebug("try to get view info from mnode, viewFName:%s", fullName); + + int32_t code = queryBuildMsg[TMSG_INDEX(reqType)](fullName, &msg, 0, &msgLen, mallocFp); + if (code) { + ctgError("Build view-meta msg failed, code:%x, viewFName:%s", code, fullName); + CTG_ERR_RET(code); + } + + if (pTask) { + void* pOut = taosMemoryCalloc(1, POINTER_BYTES); + if (NULL == pOut) { + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + + CTG_ERR_RET(ctgUpdateMsgCtx(CTG_GET_TASK_MSGCTX(pTask, tReq->msgIdx), reqType, pOut, fullName)); + +#if CTG_BATCH_FETCH + CTG_RET(ctgAddBatch(pCtg, 0, pConn, tReq, reqType, msg, msgLen)); +#else + SArray* pTaskId = taosArrayInit(1, sizeof(int32_t)); + if (NULL == pTaskId) { + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + taosArrayPush(pTaskId, &pTask->taskId); + + CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, NULL, 0, reqType, msg, msgLen)); +#endif + } + + SRpcMsg rpcMsg = { + .msgType = reqType, + .pCont = msg, + .contLen = msgLen, + }; + + SRpcMsg rpcRsp = {0}; + rpcSendRecv(pConn->pTrans, &pConn->mgmtEps, &rpcMsg, &rpcRsp); + + CTG_ERR_RET(ctgProcessRspMsg(out, reqType, rpcRsp.pCont, rpcRsp.contLen, rpcRsp.code, fullName)); + + rpcFreeCont(rpcRsp.pCont); + + return TSDB_CODE_SUCCESS; +} + + diff --git a/source/libs/catalog/src/ctgRent.c b/source/libs/catalog/src/ctgRent.c new file mode 100755 index 0000000000..457285b147 --- /dev/null +++ b/source/libs/catalog/src/ctgRent.c @@ -0,0 +1,306 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "catalogInt.h" +#include "query.h" +#include "systable.h" +#include "tname.h" +#include "trpc.h" + +int32_t ctgMetaRentInit(SCtgRentMgmt *mgmt, uint32_t rentSec, int8_t type, int32_t size) { + mgmt->slotRIdx = 0; + mgmt->slotNum = rentSec / CTG_RENT_SLOT_SECOND; + mgmt->type = type; + mgmt->metaSize = size; + + size_t msgSize = sizeof(SCtgRentSlot) * mgmt->slotNum; + + mgmt->slots = taosMemoryCalloc(1, msgSize); + if (NULL == mgmt->slots) { + qError("calloc %d failed", (int32_t)msgSize); + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + + mgmt->rentCacheSize = msgSize; + + qDebug("meta rent initialized, type:%d, slotNum:%d", type, mgmt->slotNum); + + return TSDB_CODE_SUCCESS; +} + +int32_t ctgMetaRentAdd(SCtgRentMgmt *mgmt, void *meta, int64_t id, int32_t size) { + int16_t widx = abs((int)(id % mgmt->slotNum)); + + SCtgRentSlot *slot = &mgmt->slots[widx]; + int32_t code = 0; + + CTG_LOCK(CTG_WRITE, &slot->lock); + if (NULL == slot->meta) { + slot->meta = taosArrayInit(CTG_DEFAULT_RENT_SLOT_SIZE, size); + if (NULL == slot->meta) { + qError("taosArrayInit %d failed, id:0x%" PRIx64 ", slot idx:%d, type:%d", CTG_DEFAULT_RENT_SLOT_SIZE, id, widx, + mgmt->type); + CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + } + } + + if (NULL == taosArrayPush(slot->meta, meta)) { + qError("taosArrayPush meta to rent failed, id:0x%" PRIx64 ", slot idx:%d, type:%d", id, widx, mgmt->type); + CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + } + + mgmt->rentCacheSize += size; + slot->needSort = true; + + qDebug("add meta to rent, id:0x%" PRIx64 ", slot idx:%d, type:%d", id, widx, mgmt->type); + +_return: + + CTG_UNLOCK(CTG_WRITE, &slot->lock); + CTG_RET(code); +} + +int32_t ctgMetaRentUpdate(SCtgRentMgmt *mgmt, void *meta, int64_t id, int32_t size, __compar_fn_t sortCompare, + __compar_fn_t searchCompare) { + int16_t widx = abs((int)(id % mgmt->slotNum)); + + SCtgRentSlot *slot = &mgmt->slots[widx]; + int32_t code = 0; + + CTG_LOCK(CTG_WRITE, &slot->lock); + if (NULL == slot->meta) { + qDebug("empty meta slot, id:0x%" PRIx64 ", slot idx:%d, type:%d", id, widx, mgmt->type); + CTG_ERR_JRET(TSDB_CODE_CTG_INTERNAL_ERROR); + } + + if (slot->needSort) { + qDebug("meta slot before sorte, slot idx:%d, type:%d, size:%d", widx, mgmt->type, + (int32_t)taosArrayGetSize(slot->meta)); + taosArraySort(slot->meta, sortCompare); + slot->needSort = false; + qDebug("meta slot sorted, slot idx:%d, type:%d, size:%d", widx, mgmt->type, (int32_t)taosArrayGetSize(slot->meta)); + } + + void *orig = taosArraySearch(slot->meta, &id, searchCompare, TD_EQ); + if (NULL == orig) { + qDebug("meta not found in slot, id:0x%" PRIx64 ", slot idx:%d, type:%d, size:%d", id, widx, mgmt->type, + (int32_t)taosArrayGetSize(slot->meta)); + CTG_ERR_JRET(TSDB_CODE_CTG_INTERNAL_ERROR); + } + + memcpy(orig, meta, size); + + qDebug("meta in rent updated, id:0x%" PRIx64 ", slot idx:%d, type:%d", id, widx, mgmt->type); + +_return: + + CTG_UNLOCK(CTG_WRITE, &slot->lock); + + if (code) { + qDebug("meta in rent update failed, will try to add it, code:%x, id:0x%" PRIx64 ", slot idx:%d, type:%d", code, id, + widx, mgmt->type); + CTG_RET(ctgMetaRentAdd(mgmt, meta, id, size)); + } + + CTG_RET(code); +} + +int32_t ctgMetaRentRemove(SCtgRentMgmt *mgmt, int64_t id, __compar_fn_t sortCompare, __compar_fn_t searchCompare) { + int16_t widx = abs((int)(id % mgmt->slotNum)); + + SCtgRentSlot *slot = &mgmt->slots[widx]; + int32_t code = 0; + + CTG_LOCK(CTG_WRITE, &slot->lock); + if (NULL == slot->meta) { + qError("empty meta slot, id:0x%" PRIx64 ", slot idx:%d, type:%d", id, widx, mgmt->type); + CTG_ERR_JRET(TSDB_CODE_CTG_INTERNAL_ERROR); + } + + if (slot->needSort) { + taosArraySort(slot->meta, sortCompare); + slot->needSort = false; + qDebug("meta slot sorted, slot idx:%d, type:%d", widx, mgmt->type); + } + + int32_t idx = taosArraySearchIdx(slot->meta, &id, searchCompare, TD_EQ); + if (idx < 0) { + qError("meta not found in slot, id:0x%" PRIx64 ", slot idx:%d, type:%d", id, widx, mgmt->type); + CTG_ERR_JRET(TSDB_CODE_CTG_INTERNAL_ERROR); + } + + taosArrayRemove(slot->meta, idx); + mgmt->rentCacheSize -= mgmt->metaSize; + + qDebug("meta in rent removed, id:0x%" PRIx64 ", slot idx:%d, type:%d", id, widx, mgmt->type); + +_return: + + CTG_UNLOCK(CTG_WRITE, &slot->lock); + + CTG_RET(code); +} + +int32_t ctgMetaRentGetImpl(SCtgRentMgmt *mgmt, void **res, uint32_t *num, int32_t size) { + int16_t ridx = atomic_add_fetch_16(&mgmt->slotRIdx, 1); + if (ridx >= mgmt->slotNum) { + ridx %= mgmt->slotNum; + atomic_store_16(&mgmt->slotRIdx, ridx); + } + + SCtgRentSlot *slot = &mgmt->slots[ridx]; + int32_t code = 0; + + CTG_LOCK(CTG_READ, &slot->lock); + if (NULL == slot->meta) { + qDebug("empty meta in slot:%d, type:%d", ridx, mgmt->type); + *num = 0; + goto _return; + } + + size_t metaNum = taosArrayGetSize(slot->meta); + if (metaNum <= 0) { + qDebug("no meta in slot:%d, type:%d", ridx, mgmt->type); + *num = 0; + goto _return; + } + + size_t msize = metaNum * size; + *res = taosMemoryMalloc(msize); + if (NULL == *res) { + qError("malloc %d failed", (int32_t)msize); + CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + } + + void *meta = taosArrayGet(slot->meta, 0); + + memcpy(*res, meta, msize); + + *num = (uint32_t)metaNum; + + qDebug("Got %d meta from rent, type:%d", (int32_t)metaNum, mgmt->type); + +_return: + + CTG_UNLOCK(CTG_READ, &slot->lock); + + CTG_RET(code); +} + +int32_t ctgMetaRentGet(SCtgRentMgmt *mgmt, void **res, uint32_t *num, int32_t size) { + while (true) { + int64_t msec = taosGetTimestampMs(); + int64_t lsec = atomic_load_64(&mgmt->lastReadMsec); + if ((msec - lsec) < CTG_RENT_SLOT_SECOND * 1000) { + *res = NULL; + *num = 0; + qDebug("too short time period to get expired meta, type:%d", mgmt->type); + return TSDB_CODE_SUCCESS; + } + + if (lsec != atomic_val_compare_exchange_64(&mgmt->lastReadMsec, lsec, msec)) { + continue; + } + + break; + } + + CTG_ERR_RET(ctgMetaRentGetImpl(mgmt, res, num, size)); + + return TSDB_CODE_SUCCESS; +} + +void ctgRemoveStbRent(SCatalog *pCtg, SCtgDBCache *dbCache) { + if (NULL == dbCache->stbCache) { + return; + } + + void *pIter = taosHashIterate(dbCache->stbCache, NULL); + while (pIter) { + uint64_t *suid = NULL; + suid = taosHashGetKey(pIter, NULL); + + if (TSDB_CODE_SUCCESS == + ctgMetaRentRemove(&pCtg->stbRent, *suid, ctgStbVersionSortCompare, ctgStbVersionSearchCompare)) { + ctgDebug("stb removed from rent, suid:0x%" PRIx64, *suid); + } + + pIter = taosHashIterate(dbCache->stbCache, pIter); + } +} + +void ctgRemoveViewRent(SCatalog *pCtg, SCtgDBCache *dbCache) { + if (NULL == dbCache->stbCache) { + return; + } + + void *pIter = taosHashIterate(dbCache->viewCache, NULL); + while (pIter) { + uint64_t viewId = ((SCtgViewCache*)pIter)->pMeta->viewId; + + if (TSDB_CODE_SUCCESS == + ctgMetaRentRemove(&pCtg->viewRent, viewId, ctgViewVersionSortCompare, ctgViewVersionSearchCompare)) { + ctgDebug("view removed from rent, viewId:0x%" PRIx64, viewId); + } + + pIter = taosHashIterate(dbCache->viewCache, pIter); + } +} + + +int32_t ctgUpdateRentStbVersion(SCatalog *pCtg, char *dbFName, char *tbName, uint64_t dbId, uint64_t suid, + SCtgTbCache *pCache) { + SSTableVersion metaRent = {.dbId = dbId, .suid = suid}; + if (pCache->pMeta) { + metaRent.sversion = pCache->pMeta->sversion; + metaRent.tversion = pCache->pMeta->tversion; + } + + if (pCache->pIndex) { + metaRent.smaVer = pCache->pIndex->version; + } + + tstrncpy(metaRent.dbFName, dbFName, sizeof(metaRent.dbFName)); + tstrncpy(metaRent.stbName, tbName, sizeof(metaRent.stbName)); + + CTG_ERR_RET(ctgMetaRentUpdate(&pCtg->stbRent, &metaRent, metaRent.suid, sizeof(SSTableVersion), + ctgStbVersionSortCompare, ctgStbVersionSearchCompare)); + + ctgDebug("db %s,0x%" PRIx64 " stb %s,0x%" PRIx64 " sver %d tver %d smaVer %d updated to stbRent", dbFName, dbId, + tbName, suid, metaRent.sversion, metaRent.tversion, metaRent.smaVer); + + return TSDB_CODE_SUCCESS; +} + + +int32_t ctgUpdateRentViewVersion(SCatalog *pCtg, char *dbFName, char *viewName, uint64_t dbId, uint64_t viewId, + SCtgViewCache *pCache) { + SViewVersion metaRent = {.dbId = dbId, .viewId = viewId}; + metaRent.version = pCache->pMeta->version; + + tstrncpy(metaRent.dbFName, dbFName, sizeof(metaRent.dbFName)); + tstrncpy(metaRent.viewName, viewName, sizeof(metaRent.viewName)); + + CTG_ERR_RET(ctgMetaRentUpdate(&pCtg->viewRent, &metaRent, metaRent.viewId, sizeof(SViewVersion), + ctgViewVersionSortCompare, ctgViewVersionSearchCompare)); + + ctgDebug("db %s,0x%" PRIx64 " view %s,0x%" PRIx64 " version %d updated to viewRent", dbFName, dbId, viewName, viewId, metaRent.version); + + return TSDB_CODE_SUCCESS; +} + + + + diff --git a/source/libs/catalog/src/ctgUtil.c b/source/libs/catalog/src/ctgUtil.c index ef1fb18cb4..cacdfcb8d6 100644 --- a/source/libs/catalog/src/ctgUtil.c +++ b/source/libs/catalog/src/ctgUtil.c @@ -19,6 +19,16 @@ #include "tname.h" #include "trpc.h" +void ctgFreeSViewMeta(SViewMeta* pMeta) { + if (NULL == pMeta) { + return; + } + + taosMemoryFree(pMeta->user); + taosMemoryFree(pMeta->querySql); + taosMemoryFree(pMeta->pSchema); +} + void ctgFreeMsgSendParam(void* param) { if (NULL == param) { return; @@ -93,6 +103,10 @@ char* ctgTaskTypeStr(CTG_TASK_TYPE type) { return "[bget table meta]"; case CTG_TASK_GET_TB_HASH_BATCH: return "[bget table hash]"; + case CTG_TASK_GET_TB_TAG: + return "[get table tag]"; + case CTG_TASK_GET_VIEW: + return "[get view]"; default: return "unknown"; } @@ -173,6 +187,9 @@ void ctgFreeSMetaData(SMetaData* pData) { taosArrayDestroy(pData->pTableTag); pData->pTableTag = NULL; + taosArrayDestroy(pData->pView); + pData->pView = NULL; + taosMemoryFreeClear(pData->pSvrVer); } @@ -182,6 +199,10 @@ void ctgFreeSCtgUserAuth(SCtgUserAuth* userCache) { taosHashCleanup(userCache->userAuth.writeDbs); taosHashCleanup(userCache->userAuth.readTbs); taosHashCleanup(userCache->userAuth.writeTbs); + taosHashCleanup(userCache->userAuth.alterTbs); + taosHashCleanup(userCache->userAuth.readViews); + taosHashCleanup(userCache->userAuth.writeViews); + taosHashCleanup(userCache->userAuth.alterViews); taosHashCleanup(userCache->userAuth.useDbs); } @@ -235,12 +256,38 @@ void ctgFreeTbCacheImpl(SCtgTbCache* pCache, bool lock) { } } +void ctgFreeViewCacheImpl(SCtgViewCache* pCache, bool lock) { + if (lock) { + CTG_LOCK(CTG_WRITE, &pCache->viewLock); + } + if (pCache->pMeta) { + ctgFreeSViewMeta(pCache->pMeta); + taosMemoryFreeClear(pCache->pMeta); + } + if (lock) { + CTG_UNLOCK(CTG_WRITE, &pCache->viewLock); + } +} + +void ctgFreeViewCache(SCtgDBCache* dbCache) { + if (NULL == dbCache->viewCache) { + return; + } + + SCtgViewCache* pCache = taosHashIterate(dbCache->viewCache, NULL); + while (NULL != pCache) { + ctgFreeViewCacheImpl(pCache, false); + pCache = taosHashIterate(dbCache->viewCache, pCache); + } + taosHashCleanup(dbCache->viewCache); + dbCache->viewCache = NULL; +} + void ctgFreeTbCache(SCtgDBCache* dbCache) { if (NULL == dbCache->tbCache) { return; } - int32_t tblNum = taosHashGetSize(dbCache->tbCache); SCtgTbCache* pCache = taosHashIterate(dbCache->tbCache, NULL); while (NULL != pCache) { ctgFreeTbCacheImpl(pCache, false); @@ -262,6 +309,7 @@ void ctgFreeDbCache(SCtgDBCache* dbCache) { ctgFreeCfgInfoCache(dbCache); ctgFreeStbMetaCache(dbCache); ctgFreeTbCache(dbCache); + ctgFreeViewCache(dbCache); } void ctgFreeInstDbCache(SHashObj* pDbCache) { @@ -304,6 +352,7 @@ void ctgFreeInstUserCache(SHashObj* pUserCache) { void ctgFreeHandleImpl(SCatalog* pCtg) { ctgFreeMetaRent(&pCtg->dbRent); ctgFreeMetaRent(&pCtg->stbRent); + ctgFreeMetaRent(&pCtg->viewRent); ctgFreeInstDbCache(pCtg->dbCache); ctgFreeInstUserCache(pCtg->userCache); @@ -311,17 +360,13 @@ void ctgFreeHandleImpl(SCatalog* pCtg) { taosMemoryFree(pCtg); } -int32_t ctgRemoveCacheUser(SCatalog* pCtg, const char* user) { - if (!pCtg || !user) { - return -1; - } - - SCtgUserAuth* pUser = (SCtgUserAuth*)taosHashGet(pCtg->userCache, user, strlen(user)); - if (pUser) { - ctgFreeSCtgUserAuth(pUser); - if (taosHashRemove(pCtg->userCache, user, strlen(user)) == 0) { - return 0; // user found and removed - } +int32_t ctgRemoveCacheUser(SCatalog* pCtg, SCtgUserAuth* pUser, const char* user) { + CTG_LOCK(CTG_WRITE, &pUser->lock); + ctgFreeSCtgUserAuth(pUser); + CTG_UNLOCK(CTG_WRITE, &pUser->lock); + + if (taosHashRemove(pCtg->userCache, user, strlen(user)) == 0) { + return 0; // user found and removed } return -1; @@ -336,6 +381,7 @@ void ctgFreeHandle(SCatalog* pCtg) { ctgFreeMetaRent(&pCtg->dbRent); ctgFreeMetaRent(&pCtg->stbRent); + ctgFreeMetaRent(&pCtg->viewRent); ctgFreeInstDbCache(pCtg->dbCache); ctgFreeInstUserCache(pCtg->userCache); @@ -421,12 +467,14 @@ void ctgClearHandle(SCatalog* pCtg) { ctgFreeMetaRent(&pCtg->dbRent); ctgFreeMetaRent(&pCtg->stbRent); + ctgFreeMetaRent(&pCtg->viewRent); ctgFreeInstDbCache(pCtg->dbCache); ctgFreeInstUserCache(pCtg->userCache); ctgMetaRentInit(&pCtg->dbRent, gCtgMgmt.cfg.dbRentSec, CTG_RENT_DB, sizeof(SDbCacheInfo)); ctgMetaRentInit(&pCtg->stbRent, gCtgMgmt.cfg.stbRentSec, CTG_RENT_STABLE, sizeof(SSTableVersion)); + ctgMetaRentInit(&pCtg->viewRent, gCtgMgmt.cfg.viewRentSec, CTG_RENT_VIEW, sizeof(SViewVersion)); pCtg->dbCache = taosHashInit(gCtgMgmt.cfg.maxDBCacheNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK); @@ -525,10 +573,25 @@ void ctgFreeMsgCtx(SCtgMsgCtx* pCtx) { taosHashCleanup(pOut->writeDbs); taosHashCleanup(pOut->readTbs); taosHashCleanup(pOut->writeTbs); + taosHashCleanup(pOut->alterTbs); + taosHashCleanup(pOut->readViews); + taosHashCleanup(pOut->writeViews); + taosHashCleanup(pOut->alterViews); taosHashCleanup(pOut->useDbs); taosMemoryFreeClear(pCtx->out); break; } + case TDMT_MND_VIEW_META: { + if (NULL != pCtx->out) { + SViewMetaRsp* pOut = *(SViewMetaRsp**)pCtx->out; + if (NULL != pOut) { + tFreeSViewMetaRsp(pOut); + taosMemoryFree(pOut); + } + taosMemoryFreeClear(pCtx->out); + } + break; + } default: qError("invalid reqType %d", pCtx->reqType); break; @@ -587,6 +650,19 @@ void ctgFreeBatchHash(void* hash) { taosMemoryFreeClear(pRes->pRes); } +void ctgFreeViewMetaRes(void* res) { + if (NULL == res) { + return; + } + + SMetaRes* pRes = (SMetaRes*)res; + if (NULL != pRes->pRes) { + SViewMeta* pMeta = (SViewMeta*)pRes->pRes; + ctgFreeSViewMeta(pMeta); + taosMemoryFreeClear(pRes->pRes); + } +} + void ctgFreeJsonTagVal(void* val) { if (NULL == val) { return; @@ -632,7 +708,9 @@ void ctgFreeTaskRes(CTG_TASK_TYPE type, void** pRes) { case CTG_TASK_GET_USER: { if (*pRes) { SUserAuthRes* pAuth = (SUserAuthRes*)*pRes; - nodesDestroyNode(pAuth->pCond); + for (int32_t i = 0; i < AUTH_RES_MAX_VALUE; ++i) { + nodesDestroyNode(pAuth->pCond[i]); + } taosMemoryFreeClear(*pRes); } break; @@ -673,6 +751,15 @@ void ctgFreeTaskRes(CTG_TASK_TYPE type, void** pRes) { *pRes = NULL; // no need to free it break; } + case CTG_TASK_GET_VIEW: { + SArray* pArray = (SArray*)*pRes; + int32_t num = taosArrayGetSize(pArray); + for (int32_t i = 0; i < num; ++i) { + ctgFreeViewMetaRes(taosArrayGet(pArray, i)); + } + *pRes = NULL; // no need to free it + break; + } default: qError("invalid task type %d", type); break; @@ -825,22 +912,35 @@ void ctgFreeTaskCtx(SCtgTask* pTask) { taosMemoryFreeClear(pTask->taskCtx); break; } + case CTG_TASK_GET_VIEW: { + SCtgViewsCtx* taskCtx = (SCtgViewsCtx*)pTask->taskCtx; + taosArrayDestroyEx(taskCtx->pResList, ctgFreeViewMetaRes); + taosArrayDestroy(taskCtx->pFetchs); + // NO NEED TO FREE pNames + + taosArrayDestroyEx(pTask->msgCtxs, (FDelete)ctgFreeMsgCtx); + + taosMemoryFreeClear(pTask->taskCtx); + break; + } default: qError("invalid task type %d", pTask->type); break; } } -void ctgFreeTask(SCtgTask* pTask) { +void ctgFreeTask(SCtgTask* pTask, bool freeRes) { ctgFreeMsgCtx(&pTask->msgCtx); - ctgFreeTaskRes(pTask->type, &pTask->res); + if (freeRes || pTask->subTask) { + ctgFreeTaskRes(pTask->type, &pTask->res); + } ctgFreeTaskCtx(pTask); taosArrayDestroy(pTask->pParents); ctgClearSubTaskRes(&pTask->subRes); } -void ctgFreeTasks(SArray* pArray) { +void ctgFreeTasks(SArray* pArray, bool freeRes) { if (NULL == pArray) { return; } @@ -848,7 +948,7 @@ void ctgFreeTasks(SArray* pArray) { int32_t num = taosArrayGetSize(pArray); for (int32_t i = 0; i < num; ++i) { SCtgTask* pTask = taosArrayGet(pArray, i); - ctgFreeTask(pTask); + ctgFreeTask(pTask, freeRes); } taosArrayDestroy(pArray); @@ -864,7 +964,7 @@ void ctgFreeJob(void* job) { int64_t rid = pJob->refId; uint64_t qid = pJob->queryId; - ctgFreeTasks(pJob->pTasks); + ctgFreeTasks(pJob->pTasks, pJob->jobRes.ctgFree); ctgFreeBatchs(pJob->pBatchs); ctgFreeSMetaData(&pJob->jobRes); @@ -1218,6 +1318,17 @@ int32_t ctgDbCacheInfoSearchCompare(const void* key1, const void* key2) { } } +int32_t ctgViewVersionSearchCompare(const void* key1, const void* key2) { + if (*(uint64_t*)key1 < ((SViewVersion*)key2)->viewId) { + return -1; + } else if (*(uint64_t*)key1 > ((SViewVersion*)key2)->viewId) { + return 1; + } else { + return 0; + } +} + + int32_t ctgStbVersionSortCompare(const void* key1, const void* key2) { if (((SSTableVersion*)key1)->suid < ((SSTableVersion*)key2)->suid) { return -1; @@ -1238,6 +1349,17 @@ int32_t ctgDbCacheInfoSortCompare(const void* key1, const void* key2) { } } +int32_t ctgViewVersionSortCompare(const void* key1, const void* key2) { + if (((SViewVersion*)key1)->viewId < ((SViewVersion*)key2)->viewId) { + return -1; + } else if (((SViewVersion*)key1)->viewId > ((SViewVersion*)key2)->viewId) { + return 1; + } else { + return 0; + } +} + + int32_t ctgMakeVgArray(SDBVgInfo* dbInfo) { if (NULL == dbInfo) { return TSDB_CODE_SUCCESS; @@ -1452,9 +1574,9 @@ static void* ctgCloneVgroupInfo(void* pSrc) { static void ctgFreeVgroupInfo(void* p) { taosMemoryFree(((SMetaRes*)p)->pRes); } -static void* ctgCloneTableIndices(void* pSrc) { return taosArrayDup((const SArray*)pSrc, NULL); } +static void* ctgCloneTableIndexs(void* pSrc) { return taosArrayDup((const SArray*)pSrc, NULL); } -static void ctgFreeTableIndices(void* p) { taosArrayDestroy((SArray*)((SMetaRes*)p)->pRes); } +static void ctgFreeTableIndexs(void* p) { taosArrayDestroy((SArray*)((SMetaRes*)p)->pRes); } static void* ctgCloneFuncInfo(void* pSrc) { SFuncInfo* pDst = taosMemoryMalloc(sizeof(SFuncInfo)); @@ -1508,6 +1630,34 @@ static void* ctgCloneDnodeList(void* pSrc) { return taosArrayDup((const SArray*) static void ctgFreeDnodeList(void* p) { taosArrayDestroy((SArray*)((SMetaRes*)p)->pRes); } +static void* ctgCloneViewMeta(void* pSrc) { + SViewMeta* pSrcMeta = pSrc; + SViewMeta* pDst = taosMemoryMalloc(sizeof(SViewMeta)); + if (NULL == pDst) { + return NULL; + } + pDst->user = tstrdup(pSrcMeta->user); + pDst->querySql = tstrdup(pSrcMeta->querySql); + pDst->pSchema = taosMemoryMalloc(pSrcMeta->numOfCols * sizeof(*pSrcMeta->pSchema)); + if (NULL == pDst->pSchema) { + return pDst; + } + memcpy(pDst->pSchema, pSrcMeta->pSchema, pSrcMeta->numOfCols * sizeof(*pSrcMeta->pSchema)); + return pDst; +} + +static void ctgFreeViewMeta(void* p) { + SViewMeta* pMeta = ((SMetaRes*)p)->pRes; + if (NULL == pMeta) { + return; + } + taosMemoryFree(pMeta->user); + taosMemoryFree(pMeta->querySql); + taosMemoryFree(pMeta->pSchema); + taosMemoryFree(pMeta); +} + + int32_t ctgChkSetTbAuthRes(SCatalog* pCtg, SCtgAuthReq* req, SCtgAuthRsp* res) { int32_t code = 0; STableMeta* pMeta = NULL; @@ -1523,18 +1673,18 @@ int32_t ctgChkSetTbAuthRes(SCatalog* pCtg, SCtgAuthReq* req, SCtgAuthRsp* res) { while (true) { taosMemoryFreeClear(pMeta); - char* pCond = taosHashGet(pTbs, tbFName, strlen(tbFName)); + char* pCond = taosHashGet(pTbs, tbFName, strlen(tbFName) + 1); if (pCond) { if (strlen(pCond) > 1) { - CTG_ERR_JRET(nodesStringToNode(pCond, &res->pRawRes->pCond)); + CTG_ERR_JRET(nodesStringToNode(pCond, &res->pRawRes->pCond[AUTH_RES_BASIC])); } - res->pRawRes->pass = true; + res->pRawRes->pass[AUTH_RES_BASIC] = true; goto _return; } if (stbName) { - res->pRawRes->pass = false; + res->pRawRes->pass[AUTH_RES_BASIC] = false; goto _return; } @@ -1554,7 +1704,7 @@ int32_t ctgChkSetTbAuthRes(SCatalog* pCtg, SCtgAuthReq* req, SCtgAuthRsp* res) { } if (TSDB_SUPER_TABLE == pMeta->tableType || TSDB_NORMAL_TABLE == pMeta->tableType) { - res->pRawRes->pass = false; + res->pRawRes->pass[AUTH_RES_BASIC] = false; goto _return; } @@ -1586,31 +1736,36 @@ _return: CTG_RET(code); } -int32_t ctgChkSetAuthRes(SCatalog* pCtg, SCtgAuthReq* req, SCtgAuthRsp* res) { +int32_t ctgChkSetBasicAuthRes(SCatalog* pCtg, SCtgAuthReq* req, SCtgAuthRsp* res) { int32_t code = 0; SUserAuthInfo* pReq = req->pRawReq; SUserAuthRes* pRes = res->pRawRes; SGetUserAuthRsp* pInfo = &req->authInfo; - pRes->pass = false; - pRes->pCond = NULL; + pRes->pass[AUTH_RES_BASIC] = false; + pRes->pCond[AUTH_RES_BASIC] = NULL; if (!pInfo->enable) { - pRes->pass = false; return TSDB_CODE_SUCCESS; } if (pInfo->superAuth) { - pRes->pass = true; + pRes->pass[AUTH_RES_BASIC] = true; return TSDB_CODE_SUCCESS; } if (IS_SYS_DBNAME(pReq->tbName.dbname)) { - pRes->pass = true; + pRes->pass[AUTH_RES_BASIC] = true; ctgDebug("sysdb %s, pass", pReq->tbName.dbname); return TSDB_CODE_SUCCESS; } + if (req->tbNotExists) { + //pRes->pass[AUTH_RES_BASIC] = true; + //return TSDB_CODE_SUCCESS; + pReq->tbName.type = TSDB_DB_NAME_T; + } + char dbFName[TSDB_DB_FNAME_LEN]; tNameGetFullDbName(&pReq->tbName, dbFName); @@ -1627,13 +1782,13 @@ int32_t ctgChkSetAuthRes(SCatalog* pCtg, SCtgAuthReq* req, SCtgAuthRsp* res) { if (pReq->tbName.type == TSDB_TABLE_NAME_T && pInfo->readTbs && taosHashGetSize(pInfo->readTbs) > 0) { req->singleType = AUTH_TYPE_READ; CTG_ERR_RET(ctgChkSetTbAuthRes(pCtg, req, res)); - if (pRes->pass || res->metaNotExists) { + if (pRes->pass[AUTH_RES_BASIC] || res->metaNotExists) { return TSDB_CODE_SUCCESS; } } - if (pInfo->readDbs && taosHashGet(pInfo->readDbs, dbFName, strlen(dbFName))) { - pRes->pass = true; + if (pInfo->readDbs && taosHashGet(pInfo->readDbs, dbFName, strlen(dbFName) + 1)) { + pRes->pass[AUTH_RES_BASIC] = true; return TSDB_CODE_SUCCESS; } @@ -1643,23 +1798,23 @@ int32_t ctgChkSetAuthRes(SCatalog* pCtg, SCtgAuthReq* req, SCtgAuthRsp* res) { if (pReq->tbName.type == TSDB_TABLE_NAME_T && pInfo->writeTbs && taosHashGetSize(pInfo->writeTbs) > 0) { req->singleType = AUTH_TYPE_WRITE; CTG_ERR_RET(ctgChkSetTbAuthRes(pCtg, req, res)); - if (pRes->pass || res->metaNotExists) { + if (pRes->pass[AUTH_RES_BASIC] || res->metaNotExists) { return TSDB_CODE_SUCCESS; } } - if (pInfo->writeDbs && taosHashGet(pInfo->writeDbs, dbFName, strlen(dbFName))) { - pRes->pass = true; + if (pInfo->writeDbs && taosHashGet(pInfo->writeDbs, dbFName, strlen(dbFName) + 1)) { + pRes->pass[AUTH_RES_BASIC] = true; return TSDB_CODE_SUCCESS; } break; } case AUTH_TYPE_READ_OR_WRITE: { - if ((pInfo->readDbs && taosHashGet(pInfo->readDbs, dbFName, strlen(dbFName))) || - (pInfo->writeDbs && taosHashGet(pInfo->writeDbs, dbFName, strlen(dbFName))) || - (pInfo->useDbs && taosHashGet(pInfo->useDbs, dbFName, strlen(dbFName)))) { - pRes->pass = true; + if ((pInfo->readDbs && taosHashGet(pInfo->readDbs, dbFName, strlen(dbFName) + 1)) || + (pInfo->writeDbs && taosHashGet(pInfo->writeDbs, dbFName, strlen(dbFName) + 1)) || + (pInfo->useDbs && taosHashGet(pInfo->useDbs, dbFName, strlen(dbFName) + 1))) { + pRes->pass[AUTH_RES_BASIC] = true; return TSDB_CODE_SUCCESS; } @@ -1672,6 +1827,78 @@ int32_t ctgChkSetAuthRes(SCatalog* pCtg, SCtgAuthReq* req, SCtgAuthRsp* res) { return TSDB_CODE_SUCCESS; } +int32_t ctgChkSetViewAuthRes(SCatalog* pCtg, SCtgAuthReq* req, SCtgAuthRsp* res) { + int32_t code = 0; + SUserAuthInfo* pReq = req->pRawReq; + SUserAuthRes* pRes = res->pRawRes; + SGetUserAuthRsp* pInfo = &req->authInfo; + + pRes->pass[AUTH_RES_VIEW] = false; + pRes->pCond[AUTH_RES_VIEW] = NULL; + + if (!pInfo->enable) { + return TSDB_CODE_SUCCESS; + } + + if (pInfo->superAuth) { + pRes->pass[AUTH_RES_VIEW] = true; + return TSDB_CODE_SUCCESS; + } + + if (pReq->tbName.type != TSDB_TABLE_NAME_T) { + return TSDB_CODE_SUCCESS; + } + + char viewFName[TSDB_VIEW_FNAME_LEN]; + if (IS_SYS_DBNAME(req->pRawReq->tbName.dbname)) { + snprintf(viewFName, sizeof(viewFName), "%s.%s", req->pRawReq->tbName.dbname, req->pRawReq->tbName.tname); + } else { + tNameExtractFullName(&req->pRawReq->tbName, viewFName); + } + int32_t len = strlen(viewFName) + 1; + + switch (pReq->type) { + case AUTH_TYPE_READ: { + char *value = taosHashGet(pInfo->readViews, viewFName, len); + if (NULL != value) { + pRes->pass[AUTH_RES_VIEW] = true; + return TSDB_CODE_SUCCESS; + } + break; + } + case AUTH_TYPE_WRITE: { + char *value = taosHashGet(pInfo->writeViews, viewFName, len); + if (NULL != value) { + pRes->pass[AUTH_RES_VIEW] = true; + return TSDB_CODE_SUCCESS; + } + break; + } + case AUTH_TYPE_ALTER: { + char *value = taosHashGet(pInfo->alterViews, viewFName, len); + if (NULL != value) { + pRes->pass[AUTH_RES_VIEW] = true; + return TSDB_CODE_SUCCESS; + } + break; + } + default: + break; + } + + return TSDB_CODE_SUCCESS; +} + +int32_t ctgChkSetAuthRes(SCatalog* pCtg, SCtgAuthReq* req, SCtgAuthRsp* res) { +#ifdef TD_ENTERPRISE + CTG_ERR_RET(ctgChkSetViewAuthRes(pCtg, req, res)); + if (req->pRawReq->isView) { + return TSDB_CODE_SUCCESS; + } +#endif + CTG_RET(ctgChkSetBasicAuthRes(pCtg, req, res)); +} + #if 0 static int32_t ctgCloneMetaDataArray(SArray* pSrc, __array_item_dup_fn_t copyFunc, SArray** pDst) { if (NULL == pSrc) { @@ -1743,8 +1970,9 @@ SMetaData* catalogCloneMetaData(SMetaData* pData) { return pRes; } +#endif -void catalogFreeMetaData(SMetaData* pData) { +void ctgDestroySMetaData(SMetaData* pData) { if (NULL == pData) { return; } @@ -1754,17 +1982,16 @@ void catalogFreeMetaData(SMetaData* pData) { taosArrayDestroyEx(pData->pDbInfo, ctgFreeDbInfo); taosArrayDestroyEx(pData->pTableMeta, ctgFreeTableMeta); taosArrayDestroyEx(pData->pTableHash, ctgFreeVgroupInfo); - taosArrayDestroyEx(pData->pTableIndex, ctgFreeTableIndices); + taosArrayDestroyEx(pData->pTableIndex, ctgFreeTableIndexs); taosArrayDestroyEx(pData->pUdfList, ctgFreeFuncInfo); taosArrayDestroyEx(pData->pIndex, ctgFreeIndexInfo); taosArrayDestroyEx(pData->pUser, ctgFreeUserAuth); taosArrayDestroyEx(pData->pQnodeList, ctgFreeQnodeList); taosArrayDestroyEx(pData->pTableCfg, ctgFreeTableCfg); taosArrayDestroyEx(pData->pDnodeList, ctgFreeDnodeList); + taosArrayDestroyEx(pData->pView, ctgFreeViewMeta); taosMemoryFreeClear(pData->pSvrVer); - taosMemoryFree(pData); } -#endif uint64_t ctgGetTbIndexCacheSize(STableIndex *pIndex) { if (NULL == pIndex) { @@ -1774,6 +2001,15 @@ uint64_t ctgGetTbIndexCacheSize(STableIndex *pIndex) { return sizeof(*pIndex) + pIndex->indexSize; } +uint64_t ctgGetViewMetaCacheSize(SViewMeta *pMeta) { + if (NULL == pMeta) { + return 0; + } + + return sizeof(*pMeta) + strlen(pMeta->querySql) + 1 + strlen(pMeta->user) + 1 + pMeta->numOfCols * sizeof(SSchema); +} + + FORCE_INLINE uint64_t ctgGetTbMetaCacheSize(STableMeta *pMeta) { if (NULL == pMeta) { return 0; @@ -1810,7 +2046,7 @@ uint64_t ctgGetUserCacheSize(SGetUserAuthRsp *pAuth) { while (p != NULL) { size_t len = 0; void* key = taosHashGetKey(p, &len); - cacheSize += len + strlen(p); + cacheSize += len + strlen(p) + 1; p = taosHashIterate(pAuth->createdDbs, p); } @@ -1819,7 +2055,7 @@ uint64_t ctgGetUserCacheSize(SGetUserAuthRsp *pAuth) { while (p != NULL) { size_t len = 0; void* key = taosHashGetKey(p, &len); - cacheSize += len + strlen(p); + cacheSize += len + strlen(p) + 1; p = taosHashIterate(pAuth->readDbs, p); } @@ -1828,7 +2064,7 @@ uint64_t ctgGetUserCacheSize(SGetUserAuthRsp *pAuth) { while (p != NULL) { size_t len = 0; void* key = taosHashGetKey(p, &len); - cacheSize += len + strlen(p); + cacheSize += len + strlen(p) + 1; p = taosHashIterate(pAuth->writeDbs, p); } @@ -1837,7 +2073,7 @@ uint64_t ctgGetUserCacheSize(SGetUserAuthRsp *pAuth) { while (p != NULL) { size_t len = 0; void* key = taosHashGetKey(p, &len); - cacheSize += len + strlen(p); + cacheSize += len + strlen(p) + 1; p = taosHashIterate(pAuth->readTbs, p); } @@ -1846,11 +2082,47 @@ uint64_t ctgGetUserCacheSize(SGetUserAuthRsp *pAuth) { while (p != NULL) { size_t len = 0; void* key = taosHashGetKey(p, &len); - cacheSize += len + strlen(p); + cacheSize += len + strlen(p) + 1; p = taosHashIterate(pAuth->writeTbs, p); } + p = taosHashIterate(pAuth->alterTbs, NULL); + while (p != NULL) { + size_t len = 0; + void* key = taosHashGetKey(p, &len); + cacheSize += len + strlen(p) + 1; + + p = taosHashIterate(pAuth->alterTbs, p); + } + + p = taosHashIterate(pAuth->readViews, NULL); + while (p != NULL) { + size_t len = 0; + void* key = taosHashGetKey(p, &len); + cacheSize += len + strlen(p) + 1; + + p = taosHashIterate(pAuth->readViews, p); + } + + p = taosHashIterate(pAuth->writeViews, NULL); + while (p != NULL) { + size_t len = 0; + void* key = taosHashGetKey(p, &len); + cacheSize += len + strlen(p) + 1; + + p = taosHashIterate(pAuth->writeViews, p); + } + + p = taosHashIterate(pAuth->alterViews, NULL); + while (p != NULL) { + size_t len = 0; + void* key = taosHashGetKey(p, &len); + cacheSize += len + strlen(p) + 1; + + p = taosHashIterate(pAuth->alterViews, p); + } + int32_t *ref = taosHashIterate(pAuth->useDbs, NULL); while (ref != NULL) { size_t len = 0; @@ -1886,6 +2158,7 @@ uint64_t ctgGetClusterCacheSize(SCatalog *pCtg) { cacheSize += pCtg->dbRent.rentCacheSize; cacheSize += pCtg->stbRent.rentCacheSize; + cacheSize += pCtg->viewRent.rentCacheSize; return cacheSize; } @@ -1974,3 +2247,45 @@ void ctgGetGlobalCacheSize(uint64_t *pSize) { } } +int32_t ctgBuildViewNullRes(SCtgTask* pTask, SCtgViewsCtx* pCtx) { + SCatalog* pCtg = pTask->pJob->pCtg; + int32_t dbNum = taosArrayGetSize(pCtx->pNames); + for (int32_t i = 0; i < dbNum; ++i) { + STablesReq* pReq = taosArrayGet(pCtx->pNames, i); + int32_t viewNum = taosArrayGetSize(pReq->pTables); + + ctgDebug("start to check views in db %s, viewNum %d", pReq->dbFName, viewNum); + + for (int32_t m = 0; m < viewNum; ++m) { + taosArrayPush(pCtx->pResList, &(SMetaData){0}); + } + } + + return TSDB_CODE_SUCCESS; +} + +int32_t dupViewMetaFromRsp(SViewMetaRsp* pRsp, SViewMeta* pViewMeta) { + pViewMeta->querySql = tstrdup(pRsp->querySql); + if (NULL == pViewMeta->querySql) { + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + pViewMeta->user = tstrdup(pRsp->user); + if (NULL == pViewMeta->user) { + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + pViewMeta->version = pRsp->version; + pViewMeta->viewId = pRsp->viewId; + pViewMeta->precision = pRsp->precision; + pViewMeta->type = pRsp->type; + pViewMeta->numOfCols = pRsp->numOfCols; + pViewMeta->pSchema = taosMemoryMalloc(pViewMeta->numOfCols * sizeof(SSchema)); + if (pViewMeta->pSchema == NULL) { + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + memcpy(pViewMeta->pSchema, pRsp->pSchema, pViewMeta->numOfCols * sizeof(SSchema)); + + return TSDB_CODE_SUCCESS; +} + + + diff --git a/source/libs/catalog/test/catalogTests.cpp b/source/libs/catalog/test/catalogTests.cpp index e0e456402b..23fa8d000b 100644 --- a/source/libs/catalog/test/catalogTests.cpp +++ b/source/libs/catalog/test/catalogTests.cpp @@ -2814,7 +2814,7 @@ TEST(apiTest, catalogChkAuth_test) { code = catalogChkAuth(pCtg, mockPointer, &authInfo, &authRes); ASSERT_EQ(code, 0); - ASSERT_EQ(authRes.pass, true); + ASSERT_EQ(authRes.pass[AUTH_RES_BASIC], true); while (true) { uint64_t n = 0; @@ -2828,7 +2828,7 @@ TEST(apiTest, catalogChkAuth_test) { code = catalogChkAuthFromCache(pCtg, &authInfo, &authRes, &exists); ASSERT_EQ(code, 0); - ASSERT_EQ(authRes.pass, true); + ASSERT_EQ(authRes.pass[AUTH_RES_BASIC], true); ASSERT_EQ(exists, true); catalogDestroy(); diff --git a/source/libs/command/src/command.c b/source/libs/command/src/command.c index 3d7a88ac03..4cc76c6572 100644 --- a/source/libs/command/src/command.c +++ b/source/libs/command/src/command.c @@ -112,7 +112,11 @@ static int32_t setDescResultIntoDataBlock(bool sysInfoUser, SSDataBlock* pBlock, colDataSetVal(pCol2, pBlock->info.rows, buf, false); int32_t bytes = getSchemaBytes(pMeta->schema + i); colDataSetVal(pCol3, pBlock->info.rows, (const char*)&bytes, false); - STR_TO_VARSTR(buf, i >= pMeta->tableInfo.numOfColumns ? "TAG" : ""); + if (TSDB_VIEW_TABLE != pMeta->tableType) { + STR_TO_VARSTR(buf, i >= pMeta->tableInfo.numOfColumns ? "TAG" : ""); + } else { + STR_TO_VARSTR(buf, "VIEW COL"); + } colDataSetVal(pCol4, pBlock->info.rows, buf, false); ++(pBlock->info.rows); } @@ -458,6 +462,29 @@ static int32_t buildCreateTbResultDataBlock(SSDataBlock** pOutput) { return code; } +static int32_t buildCreateViewResultDataBlock(SSDataBlock** pOutput) { + SSDataBlock* pBlock = createDataBlock(); + if (NULL == pBlock) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + SColumnInfoData infoData = createColumnInfoData(TSDB_DATA_TYPE_VARCHAR, SHOW_CREATE_VIEW_RESULT_FIELD1_LEN, 1); + int32_t code = blockDataAppendColInfo(pBlock, &infoData); + if (TSDB_CODE_SUCCESS == code) { + infoData = createColumnInfoData(TSDB_DATA_TYPE_VARCHAR, SHOW_CREATE_VIEW_RESULT_FIELD2_LEN, 2); + code = blockDataAppendColInfo(pBlock, &infoData); + } + + if (TSDB_CODE_SUCCESS == code) { + *pOutput = pBlock; + } else { + blockDataDestroy(pBlock); + } + return code; +} + + + void appendColumnFields(char* buf, int32_t* len, STableCfg* pCfg) { for (int32_t i = 0; i < pCfg->numOfColumns; ++i) { SSchema* pSchema = pCfg->pSchemas + i; @@ -701,6 +728,36 @@ static int32_t setCreateTBResultIntoDataBlock(SSDataBlock* pBlock, SDbCfgInfo* p return TSDB_CODE_SUCCESS; } +static int32_t setCreateViewResultIntoDataBlock(SSDataBlock* pBlock, SShowCreateViewStmt* pStmt) { + int32_t code = 0; + blockDataEnsureCapacity(pBlock, 1); + pBlock->info.rows = 1; + + SColumnInfoData* pCol1 = taosArrayGet(pBlock->pDataBlock, 0); + char buf1[SHOW_CREATE_VIEW_RESULT_FIELD1_LEN + 1] = {0}; + snprintf(varDataVal(buf1), TSDB_VIEW_FNAME_LEN + 4, "`%s`.`%s`", pStmt->dbName, pStmt->viewName); + varDataSetLen(buf1, strlen(varDataVal(buf1))); + colDataSetVal(pCol1, 0, buf1, false); + + SColumnInfoData* pCol2 = taosArrayGet(pBlock->pDataBlock, 1); + char* buf2 = taosMemoryMalloc(SHOW_CREATE_VIEW_RESULT_FIELD2_LEN); + if (NULL == buf2) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return terrno; + } + + SViewMeta* pMeta = pStmt->pViewMeta; + snprintf(varDataVal(buf2), SHOW_CREATE_VIEW_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE, "CREATE VIEW `%s`.`%s` AS %s", pStmt->dbName, pStmt->viewName, pMeta->querySql); + int32_t len = strlen(varDataVal(buf2)); + varDataLen(buf2) = (len > 65535) ? 65535 : len; + colDataSetVal(pCol2, 0, buf2, false); + + taosMemoryFree(buf2); + + return TSDB_CODE_SUCCESS; +} + + static int32_t execShowCreateTable(SShowCreateTableStmt* pStmt, SRetrieveTableRsp** pRsp) { SSDataBlock* pBlock = NULL; int32_t code = buildCreateTbResultDataBlock(&pBlock); @@ -940,6 +997,19 @@ static int32_t execSelectWithoutFrom(SSelectStmt* pSelect, SRetrieveTableRsp** p return code; } +static int32_t execShowCreateView(SShowCreateViewStmt* pStmt, SRetrieveTableRsp** pRsp) { + SSDataBlock* pBlock = NULL; + int32_t code = buildCreateViewResultDataBlock(&pBlock); + if (TSDB_CODE_SUCCESS == code) { + code = setCreateViewResultIntoDataBlock(pBlock, pStmt); + } + if (TSDB_CODE_SUCCESS == code) { + code = buildRetrieveTableRsp(pBlock, SHOW_CREATE_VIEW_RESULT_COLS, pRsp); + } + blockDataDestroy(pBlock); + return code; +} + int32_t qExecCommand(int64_t* pConnId, bool sysInfoUser, SNode* pStmt, SRetrieveTableRsp** pRsp, int8_t biMode) { switch (nodeType(pStmt)) { case QUERY_NODE_DESCRIBE_STMT: @@ -952,6 +1022,8 @@ int32_t qExecCommand(int64_t* pConnId, bool sysInfoUser, SNode* pStmt, SRetrieve return execShowCreateTable((SShowCreateTableStmt*)pStmt, pRsp); case QUERY_NODE_SHOW_CREATE_STABLE_STMT: return execShowCreateSTable((SShowCreateTableStmt*)pStmt, pRsp); + case QUERY_NODE_SHOW_CREATE_VIEW_STMT: + return execShowCreateView((SShowCreateViewStmt*)pStmt, pRsp); case QUERY_NODE_ALTER_LOCAL_STMT: return execAlterLocal((SAlterLocalStmt*)pStmt); case QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT: diff --git a/source/libs/executor/src/projectoperator.c b/source/libs/executor/src/projectoperator.c index a4fa4192c8..d965f16862 100644 --- a/source/libs/executor/src/projectoperator.c +++ b/source/libs/executor/src/projectoperator.c @@ -152,9 +152,11 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhys optrDefaultBufFn, NULL, optrDefaultGetNextExtFn, NULL); setOperatorStreamStateFn(pOperator, streamOperatorReleaseState, streamOperatorReloadState); - code = appendDownstream(pOperator, &downstream, 1); - if (code != TSDB_CODE_SUCCESS) { - goto _error; + if (NULL != downstream) { + code = appendDownstream(pOperator, &downstream, 1); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } } return pOperator; @@ -263,7 +265,7 @@ SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) { st = taosGetTimestampUs(); } - SOperatorInfo* downstream = pOperator->pDownstream[0]; + SOperatorInfo* downstream = pOperator->numOfDownstream > 0 ? pOperator->pDownstream[0] : NULL; SLimitInfo* pLimitInfo = &pProjectInfo->limitInfo; if (downstream == NULL) { diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index bd73b02c80..7060af6459 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -741,6 +741,19 @@ static int32_t selectStmtCopy(const SSelectStmt* pSrc, SSelectStmt* pDst) { return TSDB_CODE_SUCCESS; } +static int32_t setOperatorCopy(const SSetOperator* pSrc, SSetOperator* pDst) { + COPY_SCALAR_FIELD(opType); + CLONE_NODE_LIST_FIELD(pProjectionList); + CLONE_NODE_FIELD(pLeft); + CLONE_NODE_FIELD(pRight); + CLONE_NODE_LIST_FIELD(pOrderByList); + CLONE_NODE_FIELD(pLimit); + COPY_CHAR_ARRAY_FIELD(stmtName); + COPY_SCALAR_FIELD(precision); + COPY_SCALAR_FIELD(timeLineResMode); + return TSDB_CODE_SUCCESS; +} + SNode* nodesCloneNode(const SNode* pNode) { if (NULL == pNode) { return NULL; @@ -829,6 +842,9 @@ SNode* nodesCloneNode(const SNode* pNode) { case QUERY_NODE_HINT: code = hintNodeCopy((const SHintNode*)pNode, (SHintNode*)pDst); break; + case QUERY_NODE_SET_OPERATOR: + code = setOperatorCopy((const SSetOperator*)pNode, (SSetOperator*)pDst); + break; case QUERY_NODE_SELECT_STMT: code = selectStmtCopy((const SSelectStmt*)pNode, (SSelectStmt*)pDst); break; diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index c2acf0dbdf..c97c920a3b 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -251,6 +251,8 @@ const char* nodesNodeName(ENodeType type) { return "ShowCreateTablesStmt"; case QUERY_NODE_SHOW_CREATE_STABLE_STMT: return "ShowCreateStablesStmt"; + case QUERY_NODE_SHOW_CREATE_VIEW_STMT: + return "ShowCreateViewStmt"; case QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT: return "ShowTableDistributedStmt"; case QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT: @@ -269,6 +271,10 @@ const char* nodesNodeName(ENodeType type) { return "RestoreMnodeStmt"; case QUERY_NODE_RESTORE_VNODE_STMT: return "RestoreVnodeStmt"; + case QUERY_NODE_CREATE_VIEW_STMT: + return "CreateViewStmt"; + case QUERY_NODE_DROP_VIEW_STMT: + return "DropViewStmt"; case QUERY_NODE_LOGIC_PLAN_SCAN: return "LogicScan"; case QUERY_NODE_LOGIC_PLAN_JOIN: @@ -6589,6 +6595,33 @@ static int32_t jsonToShowCreateStableStmt(const SJson* pJson, void* pObj) { return jsonToShowCreateTableStmt(pJson, pObj); } +static const char* jkShowCreateViewStmtDbName = "DbName"; +static const char* jkShowCreateViewStmtViewName = "ViewName"; + +static int32_t showCreateViewStmtToJson(const void* pObj, SJson* pJson) { + const SShowCreateViewStmt* pNode = (const SShowCreateViewStmt*)pObj; + + int32_t code = tjsonAddStringToObject(pJson, jkShowCreateViewStmtDbName, pNode->dbName); + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddStringToObject(pJson, jkShowCreateViewStmtViewName, pNode->viewName); + } + + return code; +} + + +static int32_t jsonToShowCreateViewStmt(const SJson* pJson, void* pObj) { + SShowCreateViewStmt* pNode = (SShowCreateViewStmt*)pObj; + + int32_t code = tjsonGetStringValue(pJson, jkShowCreateViewStmtDbName, pNode->dbName); + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetStringValue(pJson, jkShowCreateViewStmtViewName, pNode->viewName); + } + + return code; +} + + static const char* jkShowTableDistributedStmtDbName = "DbName"; static const char* jkShowTableDistributedStmtTableName = "TableName"; @@ -6956,6 +6989,8 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) { return showCreateTableStmtToJson(pObj, pJson); case QUERY_NODE_SHOW_CREATE_STABLE_STMT: return showCreateStableStmtToJson(pObj, pJson); + case QUERY_NODE_SHOW_CREATE_VIEW_STMT: + return showCreateViewStmtToJson(pObj, pJson); case QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT: return showTableDistributedStmtToJson(pObj, pJson); case QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT: @@ -7277,6 +7312,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) { return jsonToShowCreateTableStmt(pJson, pObj); case QUERY_NODE_SHOW_CREATE_STABLE_STMT: return jsonToShowCreateStableStmt(pJson, pObj); + case QUERY_NODE_SHOW_CREATE_VIEW_STMT: + return jsonToShowCreateViewStmt(pJson, pObj); case QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT: return jsonToShowTableDistributedStmt(pJson, pObj); case QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT: diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index c5a1bfa599..4f6d3d95e1 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -304,6 +304,8 @@ SNode* nodesMakeNode(ENodeType type) { return makeNode(type, sizeof(SEventWindowNode)); case QUERY_NODE_HINT: return makeNode(type, sizeof(SHintNode)); + case QUERY_NODE_VIEW: + return makeNode(type, sizeof(SViewNode)); case QUERY_NODE_SET_OPERATOR: return makeNode(type, sizeof(SSetOperator)); case QUERY_NODE_SELECT_STMT: @@ -436,6 +438,7 @@ SNode* nodesMakeNode(ENodeType type) { case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT: case QUERY_NODE_SHOW_TAGS_STMT: case QUERY_NODE_SHOW_USER_PRIVILEGES_STMT: + case QUERY_NODE_SHOW_VIEWS_STMT: return makeNode(type, sizeof(SShowStmt)); case QUERY_NODE_SHOW_TABLE_TAGS_STMT: return makeNode(type, sizeof(SShowTableTagsStmt)); @@ -449,6 +452,8 @@ SNode* nodesMakeNode(ENodeType type) { case QUERY_NODE_SHOW_CREATE_TABLE_STMT: case QUERY_NODE_SHOW_CREATE_STABLE_STMT: return makeNode(type, sizeof(SShowCreateTableStmt)); + case QUERY_NODE_SHOW_CREATE_VIEW_STMT: + return makeNode(type, sizeof(SShowCreateViewStmt)); case QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT: return makeNode(type, sizeof(SShowTableDistributedStmt)); case QUERY_NODE_KILL_QUERY_STMT: @@ -467,6 +472,10 @@ SNode* nodesMakeNode(ENodeType type) { case QUERY_NODE_RESTORE_MNODE_STMT: case QUERY_NODE_RESTORE_VNODE_STMT: return makeNode(type, sizeof(SRestoreComponentNodeStmt)); + case QUERY_NODE_CREATE_VIEW_STMT: + return makeNode(type, sizeof(SCreateViewStmt)); + case QUERY_NODE_DROP_VIEW_STMT: + return makeNode(type, sizeof(SDropViewStmt)); case QUERY_NODE_LOGIC_PLAN_SCAN: return makeNode(type, sizeof(SScanLogicNode)); case QUERY_NODE_LOGIC_PLAN_JOIN: @@ -832,6 +841,13 @@ void nodesDestroyNode(SNode* pNode) { destroyHintValue(pHint->option, pHint->value); break; } + case QUERY_NODE_VIEW: { + SViewNode* pView = (SViewNode*)pNode; + taosMemoryFreeClear(pView->pMeta); + taosMemoryFreeClear(pView->pVgroupList); + taosArrayDestroyEx(pView->pSmaIndexes, destroySmaIndex); + break; + } case QUERY_NODE_SET_OPERATOR: { SSetOperator* pStmt = (SSetOperator*)pNode; nodesDestroyList(pStmt->pProjectionList); @@ -879,6 +895,10 @@ void nodesDestroyNode(SNode* pNode) { } tdDestroySVCreateTbReq(pStmt->pCreateTblReq); taosMemoryFreeClear(pStmt->pCreateTblReq); + if (pStmt->freeStbRowsCxtFunc) { + pStmt->freeStbRowsCxtFunc(pStmt->pStbRowsCxt); + } + taosMemoryFreeClear(pStmt->pStbRowsCxt); taosCloseFile(&pStmt->fp); break; } @@ -1046,7 +1066,8 @@ void nodesDestroyNode(SNode* pNode) { case QUERY_NODE_SHOW_TRANSACTIONS_STMT: case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT: case QUERY_NODE_SHOW_TAGS_STMT: - case QUERY_NODE_SHOW_USER_PRIVILEGES_STMT: { + case QUERY_NODE_SHOW_USER_PRIVILEGES_STMT: + case QUERY_NODE_SHOW_VIEWS_STMT: { SShowStmt* pStmt = (SShowStmt*)pNode; nodesDestroyNode(pStmt->pDbName); nodesDestroyNode(pStmt->pTbName); @@ -1071,6 +1092,7 @@ void nodesDestroyNode(SNode* pNode) { taosMemoryFreeClear(((SShowCreateTableStmt*)pNode)->pDbCfg); destroyTableCfg((STableCfg*)(((SShowCreateTableStmt*)pNode)->pTableCfg)); break; + case QUERY_NODE_SHOW_CREATE_VIEW_STMT: // no pointer field case QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT: // no pointer field case QUERY_NODE_KILL_CONNECTION_STMT: // no pointer field case QUERY_NODE_KILL_QUERY_STMT: // no pointer field @@ -1115,6 +1137,15 @@ void nodesDestroyNode(SNode* pNode) { case QUERY_NODE_RESTORE_MNODE_STMT: // no pointer field case QUERY_NODE_RESTORE_VNODE_STMT: // no pointer field break; + case QUERY_NODE_CREATE_VIEW_STMT: { + SCreateViewStmt* pStmt = (SCreateViewStmt*)pNode; + taosMemoryFree(pStmt->pQuerySql); + tFreeSCMCreateViewReq(&pStmt->createReq); + nodesDestroyNode(pStmt->pQuery); + break; + } + case QUERY_NODE_DROP_VIEW_STMT: + break; case QUERY_NODE_LOGIC_PLAN_SCAN: { SScanLogicNode* pLogicNode = (SScanLogicNode*)pNode; destroyLogicNode((SLogicNode*)pLogicNode); @@ -2349,4 +2380,4 @@ bool nodesIsStar(SNode* pNode) { bool nodesIsTableStar(SNode* pNode) { return (QUERY_NODE_COLUMN == nodeType(pNode)) && ('\0' != ((SColumnNode*)pNode)->tableAlias[0]) && (0 == strcmp(((SColumnNode*)pNode)->colName, "*")); -} \ No newline at end of file +} diff --git a/source/libs/parser/CMakeLists.txt b/source/libs/parser/CMakeLists.txt index 487b4e3e36..4e4a4def1d 100644 --- a/source/libs/parser/CMakeLists.txt +++ b/source/libs/parser/CMakeLists.txt @@ -1,4 +1,9 @@ aux_source_directory(src PARSER_SRC) + +IF (TD_ENTERPRISE) + LIST(APPEND PARSER_SRC ${TD_ENTERPRISE_DIR}/src/plugins/view/src/parserView.c) +ENDIF () + IF (TD_BI_SUPPORT) LIST(APPEND PARSER_SRC ${TD_ENTERPRISE_DIR}/src/plugins/bi/src/biRewriteQuery.c) ENDIF () diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index 91ba0aa9b5..c863c1e0ee 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -125,6 +125,7 @@ SNode* createNodeListNodeEx(SAstCreateContext* pCxt, SNode* p1, SNode* p2); SNode* createRealTableNode(SAstCreateContext* pCxt, SToken* pDbName, SToken* pTableName, SToken* pTableAlias); SNode* createTempTableNode(SAstCreateContext* pCxt, SNode* pSubquery, const SToken* pTableAlias); SNode* createJoinTableNode(SAstCreateContext* pCxt, EJoinType type, SNode* pLeft, SNode* pRight, SNode* pJoinCond); +SNode* createViewNode(SAstCreateContext* pCxt, SToken* pDbName, SToken* pViewName); SNode* createLimitNode(SAstCreateContext* pCxt, const SToken* pLimit, const SToken* pOffset); SNode* createOrderByExprNode(SAstCreateContext* pCxt, SNode* pExpr, EOrder order, ENullOrder nullOrder); SNode* createSessionWindowNode(SAstCreateContext* pCxt, SNode* pCol, SNode* pGap); @@ -196,6 +197,7 @@ SNode* createShowTablesStmt(SAstCreateContext* pCxt, SShowTablesOption option, S SNode* createShowCreateDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName); SNode* createShowAliveStmt(SAstCreateContext* pCxt, SNode* pDbName, ENodeType type); SNode* createShowCreateTableStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pRealTable); +SNode* createShowCreateViewStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pRealTable); SNode* createShowTableDistributedStmt(SAstCreateContext* pCxt, SNode* pRealTable); SNode* createShowDnodeVariablesStmt(SAstCreateContext* pCxt, SNode* pDnodeId, SNode* pLikePattern); SNode* createShowVnodesStmt(SAstCreateContext* pCxt, SNode* pDnodeId, SNode* pDnodeEndpoint); @@ -256,6 +258,8 @@ SNode* createRevokeStmt(SAstCreateContext* pCxt, int64_t privileges, STokenPair* SNode* pTagCond); SNode* createDeleteStmt(SAstCreateContext* pCxt, SNode* pTable, SNode* pWhere); SNode* createInsertStmt(SAstCreateContext* pCxt, SNode* pTable, SNodeList* pCols, SNode* pQuery); +SNode* createCreateViewStmt(SAstCreateContext* pCxt, bool orReplace, SNode* pView, const SToken* pAs, SNode* pQuery); +SNode* createDropViewStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SNode* pView); #ifdef __cplusplus } diff --git a/source/libs/parser/inc/parInsertUtil.h b/source/libs/parser/inc/parInsertUtil.h index 303d349b34..ce8c2d8a3d 100644 --- a/source/libs/parser/inc/parInsertUtil.h +++ b/source/libs/parser/inc/parInsertUtil.h @@ -45,9 +45,10 @@ int16_t insFindCol(struct SToken *pColname, int16_t start, int16_t end, SSchema void insBuildCreateTbReq(SVCreateTbReq *pTbReq, const char *tname, STag *pTag, int64_t suid, const char *sname, SArray *tagName, uint8_t tagNum, int32_t ttl); int32_t insInitBoundColsInfo(int32_t numOfBound, SBoundColInfo *pInfo); +void insInitColValues(STableMeta* pTableMeta, SArray* aColValues); void insCheckTableDataOrder(STableDataCxt *pTableCxt, TSKEY tsKey); int32_t insGetTableDataCxt(SHashObj *pHash, void *id, int32_t idLen, STableMeta *pTableMeta, - SVCreateTbReq **pCreateTbReq, STableDataCxt **pTableCxt, bool colMode); + SVCreateTbReq **pCreateTbReq, STableDataCxt **pTableCxt, bool colMode, bool ignoreColVals); int32_t initTableColSubmitData(STableDataCxt *pTableCxt); int32_t insMergeTableDataCxt(SHashObj *pTableHash, SArray **pVgDataBlocks); int32_t insBuildVgDataBlocks(SHashObj *pVgroupsHashObj, SArray *pVgDataBlocks, SArray **pDataBlocks); diff --git a/source/libs/parser/inc/parInt.h b/source/libs/parser/inc/parInt.h index 9e95478b3f..a4a7812474 100644 --- a/source/libs/parser/inc/parInt.h +++ b/source/libs/parser/inc/parInt.h @@ -22,6 +22,7 @@ extern "C" { #include "parToken.h" #include "parUtil.h" +#include "parTranslater.h" #include "parser.h" #define QUERY_SMA_OPTIMIZE_DISABLE 0 @@ -36,6 +37,15 @@ int32_t extractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pS int32_t calculateConstant(SParseContext* pParseCxt, SQuery* pQuery); int32_t translatePostCreateStream(SParseContext* pParseCxt, SQuery* pQuery, void** pResRow); int32_t translatePostCreateSmaIndex(SParseContext* pParseCxt, SQuery* pQuery, void** pResRow); +int32_t buildQueryAfterParse(SQuery** pQuery, SNode* pRootNode, int16_t placeholderNo, SArray** pPlaceholderValues); +int32_t translateTable(STranslateContext* pCxt, SNode** pTable); +int32_t getMetaDataFromHash(const char* pKey, int32_t len, SHashObj* pHash, void** pOutput); +void tfreeSParseQueryRes(void* p); + +#ifdef TD_ENTERPRISE +int32_t translateView(STranslateContext* pCxt, SNode** pTable, SName* pName); +int32_t getViewMetaFromMetaCache(STranslateContext* pCxt, SName* pName, SViewMeta** ppViewMeta); +#endif #ifdef __cplusplus } #endif diff --git a/source/libs/parser/inc/parTranslater.h b/source/libs/parser/inc/parTranslater.h index 7f721a2c25..e06626fb00 100644 --- a/source/libs/parser/inc/parTranslater.h +++ b/source/libs/parser/inc/parTranslater.h @@ -48,6 +48,8 @@ typedef struct STranslateContext { int32_t biRewriteSelectStar(STranslateContext* pCxt, SSelectStmt* pSelect); int32_t findTable(STranslateContext* pCxt, const char* pTableAlias, STableNode** pOutput); +int32_t getTargetMetaImpl(SParseContext* pParCxt, SParseMetaCache* pMetaCache, const SName* pName, STableMeta** pMeta, bool couldBeView); + #ifdef __cplusplus } #endif diff --git a/source/libs/parser/inc/parUtil.h b/source/libs/parser/inc/parUtil.h index 41cf45906f..11a3a40a1e 100644 --- a/source/libs/parser/inc/parUtil.h +++ b/source/libs/parser/inc/parUtil.h @@ -69,6 +69,7 @@ typedef struct SParseMetaCache { SHashObj* pUdf; // key is funcName, element is SFuncInfo* SHashObj* pTableIndex; // key is tbFName, element is SArray* SHashObj* pTableCfg; // key is tbFName, element is STableCfg* + SHashObj* pViews; // key is viewFName, element is SViewMeta* SArray* pDnodes; // element is SEpSet bool dnodeRequired; } SParseMetaCache; @@ -93,6 +94,8 @@ int32_t buildCatalogReq(const SParseMetaCache* pMetaCache, SCatalogReq* pCatalog int32_t putMetaDataToCache(const SCatalogReq* pCatalogReq, const SMetaData* pMetaData, SParseMetaCache* pMetaCache); int32_t reserveTableMetaInCache(int32_t acctId, const char* pDb, const char* pTable, SParseMetaCache* pMetaCache); int32_t reserveTableMetaInCacheExt(const SName* pName, SParseMetaCache* pMetaCache); +int32_t reserveViewMetaInCache(int32_t acctId, const char* pDb, const char* pView, SParseMetaCache* pMetaCache); +int32_t reserveViewMetaInCacheExt(const SName* pName, SParseMetaCache* pMetaCache); int32_t reserveDbVgInfoInCache(int32_t acctId, const char* pDb, SParseMetaCache* pMetaCache); int32_t reserveTableVgroupInCache(int32_t acctId, const char* pDb, const char* pTable, SParseMetaCache* pMetaCache); int32_t reserveTableVgroupInCacheExt(const SName* pName, SParseMetaCache* pMetaCache); @@ -100,11 +103,15 @@ int32_t reserveDbVgVersionInCache(int32_t acctId, const char* pDb, SParseMetaCac int32_t reserveDbCfgInCache(int32_t acctId, const char* pDb, SParseMetaCache* pMetaCache); int32_t reserveUserAuthInCache(int32_t acctId, const char* pUser, const char* pDb, const char* pTable, AUTH_TYPE type, SParseMetaCache* pMetaCache); +int32_t reserveViewUserAuthInCache(int32_t acctId, const char* pUser, const char* pDb, const char* pTable, AUTH_TYPE type, + SParseMetaCache* pMetaCache); int32_t reserveUdfInCache(const char* pFunc, SParseMetaCache* pMetaCache); int32_t reserveTableIndexInCache(int32_t acctId, const char* pDb, const char* pTable, SParseMetaCache* pMetaCache); int32_t reserveTableCfgInCache(int32_t acctId, const char* pDb, const char* pTable, SParseMetaCache* pMetaCache); int32_t reserveDnodeRequiredInCache(SParseMetaCache* pMetaCache); int32_t getTableMetaFromCache(SParseMetaCache* pMetaCache, const SName* pName, STableMeta** pMeta); +int32_t getViewMetaFromCache(SParseMetaCache* pMetaCache, const SName* pName, STableMeta** pMeta); +int32_t buildTableMetaFromViewMeta(STableMeta** pMeta, SViewMeta* pViewMeta); int32_t getDbVgInfoFromCache(SParseMetaCache* pMetaCache, const char* pDbFName, SArray** pVgInfo); int32_t getTableVgroupFromCache(SParseMetaCache* pMetaCache, const SName* pName, SVgroupInfo* pVgroup); int32_t getDbVgVersionFromCache(SParseMetaCache* pMetaCache, const char* pDbFName, int32_t* pVersion, int64_t* pDbId, diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index a7b490c0dc..9bcf65dbbe 100755 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -132,6 +132,7 @@ priv_type_list(A) ::= priv_type_list(B) NK_COMMA priv_type(C). %destructor priv_type { } priv_type(A) ::= READ. { A = PRIVILEGE_TYPE_READ; } priv_type(A) ::= WRITE. { A = PRIVILEGE_TYPE_WRITE; } +priv_type(A) ::= ALTER. { A = PRIVILEGE_TYPE_ALTER; } %type priv_level { STokenPair } %destructor priv_level { } @@ -508,6 +509,8 @@ cmd ::= SHOW VNODES. // show alive cmd ::= SHOW db_name_cond_opt(A) ALIVE. { pCxt->pRootNode = createShowAliveStmt(pCxt, A, QUERY_NODE_SHOW_DB_ALIVE_STMT); } cmd ::= SHOW CLUSTER ALIVE. { pCxt->pRootNode = createShowAliveStmt(pCxt, NULL, QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT); } +cmd ::= SHOW db_name_cond_opt(A) VIEWS. { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VIEWS_STMT, A, NULL, OP_TYPE_LIKE); } +cmd ::= SHOW CREATE VIEW full_table_name(A). { pCxt->pRootNode = createShowCreateViewStmt(pCxt, QUERY_NODE_SHOW_CREATE_VIEW_STMT, A); } %type table_kind_db_name_cond_opt { SShowTablesOption } %destructor table_kind_db_name_cond_opt { } @@ -648,6 +651,14 @@ language_opt(A) ::= LANGUAGE NK_STRING(B). or_replace_opt(A) ::= . { A = false; } or_replace_opt(A) ::= OR REPLACE. { A = true; } +/************************************************ create/drop view **************************************************/ +cmd ::= CREATE or_replace_opt(A) VIEW full_view_name(B) AS(C) query_or_subquery(D). + { pCxt->pRootNode = createCreateViewStmt(pCxt, A, B, &C, D); } +cmd ::= DROP VIEW exists_opt(A) full_view_name(B). { pCxt->pRootNode = createDropViewStmt(pCxt, A, B); } + +full_view_name(A) ::= view_name(B). { A = createViewNode(pCxt, NULL, &B); } +full_view_name(A) ::= db_name(B) NK_DOT view_name(C). { A = createViewNode(pCxt, &B, &C); } + /************************************************ create/drop stream **************************************************/ cmd ::= CREATE STREAM not_exists_opt(E) stream_name(A) stream_options(B) INTO full_table_name(C) col_list_opt(H) tag_def_or_ref_opt(F) subtable_opt(G) @@ -781,6 +792,10 @@ column_name(A) ::= NK_ID(B). %destructor function_name { } function_name(A) ::= NK_ID(B). { A = B; } +%type view_name { SToken } +%destructor view_name { } +view_name(A) ::= NK_ID(B). { A = B; } + %type table_alias { SToken } %destructor table_alias { } table_alias(A) ::= NK_ID(B). { A = B; } diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index c6d70667bf..3ae82c3615 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -219,6 +219,16 @@ static bool checkCGroupName(SAstCreateContext* pCxt, SToken* pCGroup) { return true; } +static bool checkViewName(SAstCreateContext* pCxt, SToken* pViewName) { + trimEscape(pViewName); + if (pViewName->n >= TSDB_VIEW_NAME_LEN) { + pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME, pViewName->z); + return false; + } + return true; +} + + static bool checkStreamName(SAstCreateContext* pCxt, SToken* pStreamName) { trimEscape(pStreamName); if (pStreamName->n >= TSDB_STREAM_NAME_LEN) { @@ -772,6 +782,23 @@ SNode* createJoinTableNode(SAstCreateContext* pCxt, EJoinType type, SNode* pLeft return (SNode*)joinTable; } +SNode* createViewNode(SAstCreateContext* pCxt, SToken* pDbName, SToken* pViewName) { + CHECK_PARSER_STATUS(pCxt); + if (!checkDbName(pCxt, pDbName, true) || !checkViewName(pCxt, pViewName)) { + return NULL; + } + SViewNode* pView = (SViewNode*)nodesMakeNode(QUERY_NODE_VIEW); + CHECK_OUT_OF_MEM(pView); + if (NULL != pDbName) { + COPY_STRING_FORM_ID_TOKEN(pView->table.dbName, pDbName); + } else { + snprintf(pView->table.dbName, sizeof(pView->table.dbName), "%s", pCxt->pQueryCxt->db); + } + COPY_STRING_FORM_ID_TOKEN(pView->table.tableName, pViewName); + return (SNode*)pView; +} + + SNode* createLimitNode(SAstCreateContext* pCxt, const SToken* pLimit, const SToken* pOffset) { CHECK_PARSER_STATUS(pCxt); SLimitNode* limitNode = (SLimitNode*)nodesMakeNode(QUERY_NODE_LIMIT); @@ -1600,7 +1627,8 @@ SNode* createUseDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName) { static bool needDbShowStmt(ENodeType type) { return QUERY_NODE_SHOW_TABLES_STMT == type || QUERY_NODE_SHOW_STABLES_STMT == type || QUERY_NODE_SHOW_VGROUPS_STMT == type || QUERY_NODE_SHOW_INDEXES_STMT == type || - QUERY_NODE_SHOW_TAGS_STMT == type || QUERY_NODE_SHOW_TABLE_TAGS_STMT == type; + QUERY_NODE_SHOW_TAGS_STMT == type || QUERY_NODE_SHOW_TABLE_TAGS_STMT == type || + QUERY_NODE_SHOW_VIEWS_STMT == type; } SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type) { @@ -1701,6 +1729,17 @@ SNode* createShowCreateTableStmt(SAstCreateContext* pCxt, ENodeType type, SNode* return (SNode*)pStmt; } +SNode* createShowCreateViewStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pRealTable) { + CHECK_PARSER_STATUS(pCxt); + SShowCreateViewStmt* pStmt = (SShowCreateViewStmt*)nodesMakeNode(type); + CHECK_OUT_OF_MEM(pStmt); + strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName); + strcpy(pStmt->viewName, ((SRealTableNode*)pRealTable)->table.tableName); + nodesDestroyNode(pRealTable); + return (SNode*)pStmt; +} + + SNode* createShowTableDistributedStmt(SAstCreateContext* pCxt, SNode* pRealTable) { CHECK_PARSER_STATUS(pCxt); SShowTableDistributedStmt* pStmt = (SShowTableDistributedStmt*)nodesMakeNode(QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT); @@ -2215,6 +2254,35 @@ SNode* createDropFunctionStmt(SAstCreateContext* pCxt, bool ignoreNotExists, con return (SNode*)pStmt; } +SNode* createCreateViewStmt(SAstCreateContext* pCxt, bool orReplace, SNode* pView, const SToken* pAs, SNode* pQuery) { + CHECK_PARSER_STATUS(pCxt); + SCreateViewStmt* pStmt = (SCreateViewStmt*)nodesMakeNode(QUERY_NODE_CREATE_VIEW_STMT); + CHECK_OUT_OF_MEM(pStmt); + int32_t i = pAs->n; + while (isspace(*(pAs->z + i))) { + ++i; + } + pStmt->pQuerySql = tstrdup(pAs->z + i); + CHECK_OUT_OF_MEM(pStmt->pQuerySql); + strcpy(pStmt->dbName, ((SViewNode*)pView)->table.dbName); + strcpy(pStmt->viewName, ((SViewNode*)pView)->table.tableName); + nodesDestroyNode(pView); + pStmt->orReplace = orReplace; + pStmt->pQuery = pQuery; + return (SNode*)pStmt; +} + +SNode* createDropViewStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SNode* pView) { + CHECK_PARSER_STATUS(pCxt); + SDropViewStmt* pStmt = (SDropViewStmt*)nodesMakeNode(QUERY_NODE_DROP_VIEW_STMT); + CHECK_OUT_OF_MEM(pStmt); + pStmt->ignoreNotExists = ignoreNotExists; + strcpy(pStmt->dbName, ((SViewNode*)pView)->table.dbName); + strcpy(pStmt->viewName, ((SViewNode*)pView)->table.tableName); + nodesDestroyNode(pView); + return (SNode*)pStmt; +} + SNode* createStreamOptions(SAstCreateContext* pCxt) { CHECK_PARSER_STATUS(pCxt); SStreamOptions* pOptions = (SStreamOptions*)nodesMakeNode(QUERY_NODE_STREAM_OPTIONS); diff --git a/source/libs/parser/src/parAstParser.c b/source/libs/parser/src/parAstParser.c index 784281ebae..91625defd0 100644 --- a/source/libs/parser/src/parAstParser.c +++ b/source/libs/parser/src/parAstParser.c @@ -29,6 +29,20 @@ extern void Parse(void*, int, SToken, void*); extern void ParseFree(void*, FFree); extern void ParseTrace(FILE*, char*); +int32_t buildQueryAfterParse(SQuery** pQuery, SNode* pRootNode, int16_t placeholderNo, SArray** pPlaceholderValues) { + *pQuery = (SQuery*)nodesMakeNode(QUERY_NODE_QUERY); + if (NULL == *pQuery) { + return TSDB_CODE_OUT_OF_MEMORY; + } + (*pQuery)->pRoot = pRootNode; + (*pQuery)->placeholderNum = placeholderNo; + TSWAP((*pQuery)->pPlaceholderValues, *pPlaceholderValues); + (*pQuery)->execStage = QUERY_EXEC_STAGE_ANALYSE; + + return TSDB_CODE_SUCCESS; +} + + int32_t parse(SParseContext* pParseCxt, SQuery** pQuery) { SAstCreateContext cxt; initAstCreateContext(pParseCxt, &cxt); @@ -77,14 +91,10 @@ int32_t parse(SParseContext* pParseCxt, SQuery** pQuery) { abort_parse: ParseFree(pParser, (FFree)taosMemoryFree); if (TSDB_CODE_SUCCESS == cxt.errCode) { - *pQuery = (SQuery*)nodesMakeNode(QUERY_NODE_QUERY); - if (NULL == *pQuery) { - return TSDB_CODE_OUT_OF_MEMORY; + int32_t code = buildQueryAfterParse(pQuery, cxt.pRootNode, cxt.placeholderNo, &cxt.pPlaceholderValues); + if (TSDB_CODE_SUCCESS != code) { + return code; } - (*pQuery)->pRoot = cxt.pRootNode; - (*pQuery)->placeholderNum = cxt.placeholderNo; - TSWAP((*pQuery)->pPlaceholderValues, cxt.pPlaceholderValues); - (*pQuery)->execStage = QUERY_EXEC_STAGE_ANALYSE; } taosArrayDestroy(cxt.pPlaceholderValues); return cxt.errCode; @@ -157,6 +167,12 @@ static int32_t collectMetaKeyFromRealTableImpl(SCollectMetaKeyCxt* pCxt, const c code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pDb, pTable, authType, pCxt->pMetaCache); } +#ifdef TD_ENTERPRISE + if (TSDB_CODE_SUCCESS == code && NULL != pCxt->pParseCxt->pEffectiveUser) { + code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pEffectiveUser, pDb, pTable, authType, + pCxt->pMetaCache); + } +#endif if (TSDB_CODE_SUCCESS == code) { code = reserveDbVgInfoInCache(pCxt->pParseCxt->acctId, pDb, pCxt->pMetaCache); } @@ -371,6 +387,13 @@ static int32_t collectMetaKeyFromDescribe(SCollectMetaKeyCxt* pCxt, SDescribeStm strcpy(name.dbname, pStmt->dbName); strcpy(name.tname, pStmt->tableName); int32_t code = catalogRemoveTableMeta(pCxt->pParseCxt->pCatalog, &name); +#ifdef TD_ENTERPRISE + if (TSDB_CODE_SUCCESS == code) { + char dbFName[TSDB_DB_FNAME_LEN]; + tNameGetFullDbName(&name, dbFName); + code = catalogRemoveViewMeta(pCxt->pParseCxt->pCatalog, dbFName, 0, pStmt->tableName, 0); + } +#endif if (TSDB_CODE_SUCCESS == code) { code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache); } @@ -573,6 +596,18 @@ static int32_t collectMetaKeyFromShowUserPrivileges(SCollectMetaKeyCxt* pCxt, SS pCxt->pMetaCache); } +static int32_t collectMetaKeyFromShowViews(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) { + int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_VIEWS, + pCxt->pMetaCache); + if (TSDB_CODE_SUCCESS == code) { + code = + reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, ((SValueNode*)pStmt->pDbName)->literal, + NULL, AUTH_TYPE_READ_OR_WRITE, pCxt->pMetaCache); + } + return code; +} + + static int32_t collectMetaKeyFromShowCreateDatabase(SCollectMetaKeyCxt* pCxt, SShowCreateDatabaseStmt* pStmt) { return reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache); } @@ -595,6 +630,25 @@ static int32_t collectMetaKeyFromShowCreateTable(SCollectMetaKeyCxt* pCxt, SShow return code; } +static int32_t collectMetaKeyFromShowCreateView(SCollectMetaKeyCxt* pCxt, SShowCreateViewStmt* pStmt) { + SName name = {.type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId}; + strcpy(name.dbname, pStmt->dbName); + strcpy(name.tname, pStmt->viewName); + char dbFName[TSDB_DB_FNAME_LEN]; + tNameGetFullDbName(&name, dbFName); + int32_t code = catalogRemoveViewMeta(pCxt->pParseCxt->pCatalog, dbFName, 0, pStmt->viewName, 0); + if (TSDB_CODE_SUCCESS == code) { + code = reserveViewUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, pStmt->viewName, + AUTH_TYPE_READ, pCxt->pMetaCache); + } + if (TSDB_CODE_SUCCESS == code) { + code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->viewName, pCxt->pMetaCache); + } + + return code; +} + + static int32_t collectMetaKeyFromShowApps(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) { return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_APPS, pCxt->pMetaCache); @@ -646,6 +700,35 @@ static int32_t collectMetaKeyFromGrant(SCollectMetaKeyCxt* pCxt, SGrantStmt* pSt return reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->objName, pStmt->tabName, pCxt->pMetaCache); } +static int32_t collectMetaKeyFromRevoke(SCollectMetaKeyCxt* pCxt, SRevokeStmt* pStmt) { + if ('\0' == pStmt->tabName[0]) { + return TSDB_CODE_SUCCESS; + } + return reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->objName, pStmt->tabName, pCxt->pMetaCache); +} + + +static int32_t collectMetaKeyFromCreateViewStmt(SCollectMetaKeyCxt* pCxt, SCreateViewStmt* pStmt) { + int32_t code = + reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->viewName, pCxt->pMetaCache); + if (TSDB_CODE_SUCCESS == code) { + code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, NULL, AUTH_TYPE_WRITE, + pCxt->pMetaCache); + } + if (TSDB_CODE_SUCCESS == code) { + code = reserveViewUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, pStmt->viewName, AUTH_TYPE_ALTER, + pCxt->pMetaCache); + } + return code; +} + +static int32_t collectMetaKeyFromDropViewStmt(SCollectMetaKeyCxt* pCxt, SDropViewStmt* pStmt) { + int32_t code = reserveViewUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, pStmt->viewName, AUTH_TYPE_ALTER, + pCxt->pMetaCache); + return code; +} + + static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) { pCxt->pStmt = pStmt; switch (nodeType(pStmt)) { @@ -685,6 +768,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) { return collectMetaKeyFromCreateStream(pCxt, (SCreateStreamStmt*)pStmt); case QUERY_NODE_GRANT_STMT: return collectMetaKeyFromGrant(pCxt, (SGrantStmt*)pStmt); + case QUERY_NODE_REVOKE_STMT: + return collectMetaKeyFromRevoke(pCxt, (SRevokeStmt*)pStmt); case QUERY_NODE_SHOW_DNODES_STMT: return collectMetaKeyFromShowDnodes(pCxt, (SShowStmt*)pStmt); case QUERY_NODE_SHOW_MNODES_STMT: @@ -737,11 +822,15 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) { return collectMetaKeyFromShowVnodes(pCxt, (SShowVnodesStmt*)pStmt); case QUERY_NODE_SHOW_USER_PRIVILEGES_STMT: return collectMetaKeyFromShowUserPrivileges(pCxt, (SShowStmt*)pStmt); + case QUERY_NODE_SHOW_VIEWS_STMT: + return collectMetaKeyFromShowViews(pCxt, (SShowStmt*)pStmt); case QUERY_NODE_SHOW_CREATE_DATABASE_STMT: return collectMetaKeyFromShowCreateDatabase(pCxt, (SShowCreateDatabaseStmt*)pStmt); case QUERY_NODE_SHOW_CREATE_TABLE_STMT: case QUERY_NODE_SHOW_CREATE_STABLE_STMT: return collectMetaKeyFromShowCreateTable(pCxt, (SShowCreateTableStmt*)pStmt); + case QUERY_NODE_SHOW_CREATE_VIEW_STMT: + return collectMetaKeyFromShowCreateView(pCxt, (SShowCreateViewStmt*)pStmt); case QUERY_NODE_SHOW_APPS_STMT: return collectMetaKeyFromShowApps(pCxt, (SShowStmt*)pStmt); case QUERY_NODE_SHOW_TRANSACTIONS_STMT: @@ -754,6 +843,10 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) { return collectMetaKeyFromShowBlockDist(pCxt, (SShowTableDistributedStmt*)pStmt); case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT: return collectMetaKeyFromShowSubscriptions(pCxt, (SShowStmt*)pStmt); + case QUERY_NODE_CREATE_VIEW_STMT: + return collectMetaKeyFromCreateViewStmt(pCxt, (SCreateViewStmt*)pStmt); + case QUERY_NODE_DROP_VIEW_STMT: + return collectMetaKeyFromDropViewStmt(pCxt, (SDropViewStmt*)pStmt); default: break; } diff --git a/source/libs/parser/src/parAuthenticator.c b/source/libs/parser/src/parAuthenticator.c index 9b2ac662c8..033991f351 100644 --- a/source/libs/parser/src/parAuthenticator.c +++ b/source/libs/parser/src/parAuthenticator.c @@ -35,28 +35,41 @@ typedef struct SAuthRewriteCxt { static int32_t authQuery(SAuthCxt* pCxt, SNode* pStmt); static void setUserAuthInfo(SParseContext* pCxt, const char* pDbName, const char* pTabName, AUTH_TYPE type, - SUserAuthInfo* pAuth) { - snprintf(pAuth->user, sizeof(pAuth->user), "%s", pCxt->pUser); + bool isView, bool effective, SUserAuthInfo* pAuth) { + if (effective) { + snprintf(pAuth->user, sizeof(pAuth->user), "%s", pCxt->pEffectiveUser ? pCxt->pEffectiveUser : ""); + } else { + snprintf(pAuth->user, sizeof(pAuth->user), "%s", pCxt->pUser); + } + if (NULL == pTabName) { tNameSetDbName(&pAuth->tbName, pCxt->acctId, pDbName, strlen(pDbName)); } else { toName(pCxt->acctId, pDbName, pTabName, &pAuth->tbName); } pAuth->type = type; + pAuth->isView = isView; } -static int32_t checkAuth(SAuthCxt* pCxt, const char* pDbName, const char* pTabName, AUTH_TYPE type, SNode** pCond) { +static int32_t checkAuthImpl(SAuthCxt* pCxt, const char* pDbName, const char* pTabName, AUTH_TYPE type, SNode** pCond, bool isView, bool effective) { SParseContext* pParseCxt = pCxt->pParseCxt; if (pParseCxt->isSuperUser) { return TSDB_CODE_SUCCESS; } + AUTH_RES_TYPE auth_res_type = isView ? AUTH_RES_VIEW : AUTH_RES_BASIC; SUserAuthInfo authInfo = {0}; - setUserAuthInfo(pCxt->pParseCxt, pDbName, pTabName, type, &authInfo); + setUserAuthInfo(pCxt->pParseCxt, pDbName, pTabName, type, isView, effective, &authInfo); int32_t code = TSDB_CODE_SUCCESS; SUserAuthRes authRes = {0}; if (NULL != pCxt->pMetaCache) { code = getUserAuthFromCache(pCxt->pMetaCache, &authInfo, &authRes); +#ifdef TD_ENTERPRISE + if (isView && TSDB_CODE_PAR_INTERNAL_ERROR == code) { + authInfo.isView = false; + code = getUserAuthFromCache(pCxt->pMetaCache, &authInfo, &authRes); + } +#endif } else { SRequestConnInfo conn = {.pTrans = pParseCxt->pTransporter, .requestId = pParseCxt->requestId, @@ -65,9 +78,26 @@ static int32_t checkAuth(SAuthCxt* pCxt, const char* pDbName, const char* pTabNa code = catalogChkAuth(pParseCxt->pCatalog, &conn, &authInfo, &authRes); } if (TSDB_CODE_SUCCESS == code && NULL != pCond) { - *pCond = authRes.pCond; + *pCond = authRes.pCond[auth_res_type]; } - return TSDB_CODE_SUCCESS == code ? (authRes.pass ? TSDB_CODE_SUCCESS : TSDB_CODE_PAR_PERMISSION_DENIED) : code; + return TSDB_CODE_SUCCESS == code ? (authRes.pass[auth_res_type] ? TSDB_CODE_SUCCESS : TSDB_CODE_PAR_PERMISSION_DENIED) : code; +} + + +static int32_t checkAuth(SAuthCxt* pCxt, const char* pDbName, const char* pTabName, AUTH_TYPE type, SNode** pCond) { + return checkAuthImpl(pCxt, pDbName, pTabName, type, pCond, false, false); +} + +static int32_t checkEffectiveAuth(SAuthCxt* pCxt, const char* pDbName, const char* pTabName, AUTH_TYPE type, SNode** pCond) { + return checkAuthImpl(pCxt, pDbName, pTabName, type, NULL, false, true); +} + +static int32_t checkViewAuth(SAuthCxt* pCxt, const char* pDbName, const char* pTabName, AUTH_TYPE type, SNode** pCond) { + return checkAuthImpl(pCxt, pDbName, pTabName, type, NULL, true, false); +} + +static int32_t checkViewEffectiveAuth(SAuthCxt* pCxt, const char* pDbName, const char* pTabName, AUTH_TYPE type, SNode** pCond) { + return checkAuthImpl(pCxt, pDbName, pTabName, type, NULL, true, true); } static EDealRes authSubquery(SAuthCxt* pCxt, SNode* pStmt) { @@ -130,12 +160,33 @@ static int32_t rewriteAppendStableTagCond(SNode** pWhere, SNode* pTagCond, STabl static EDealRes authSelectImpl(SNode* pNode, void* pContext) { SSelectAuthCxt* pCxt = pContext; SAuthCxt* pAuthCxt = pCxt->pAuthCxt; + bool isView = false; if (QUERY_NODE_REAL_TABLE == nodeType(pNode)) { SNode* pTagCond = NULL; STableNode* pTable = (STableNode*)pNode; - pAuthCxt->errCode = checkAuth(pAuthCxt, pTable->dbName, pTable->tableName, AUTH_TYPE_READ, &pTagCond); - if (TSDB_CODE_SUCCESS == pAuthCxt->errCode && NULL != pTagCond) { - pAuthCxt->errCode = rewriteAppendStableTagCond(&pCxt->pSelect->pWhere, pTagCond, pTable); +#ifdef TD_ENTERPRISE + SName name; + STableMeta* pTableMeta = NULL; + int32_t code = getTargetMetaImpl( + pAuthCxt->pParseCxt, pAuthCxt->pMetaCache, toName(pAuthCxt->pParseCxt->acctId, pTable->dbName, pTable->tableName, &name), &pTableMeta, true); + if (TSDB_CODE_SUCCESS == code && TSDB_VIEW_TABLE == pTableMeta->tableType) { + isView = true; + } + taosMemoryFree(pTableMeta); +#endif + if (!isView) { + pAuthCxt->errCode = checkAuth(pAuthCxt, pTable->dbName, pTable->tableName, AUTH_TYPE_READ, &pTagCond); + if (TSDB_CODE_SUCCESS != pAuthCxt->errCode && NULL != pAuthCxt->pParseCxt->pEffectiveUser) { + pAuthCxt->errCode = checkEffectiveAuth(pAuthCxt, pTable->dbName, pTable->tableName, AUTH_TYPE_READ, NULL); + } + if (TSDB_CODE_SUCCESS == pAuthCxt->errCode && NULL != pTagCond) { + pAuthCxt->errCode = rewriteAppendStableTagCond(&pCxt->pSelect->pWhere, pTagCond, pTable); + } + } else { + pAuthCxt->errCode = checkViewAuth(pAuthCxt, pTable->dbName, pTable->tableName, AUTH_TYPE_READ, NULL); + if (TSDB_CODE_SUCCESS != pAuthCxt->errCode && NULL != pAuthCxt->pParseCxt->pEffectiveUser) { + pAuthCxt->errCode = checkViewEffectiveAuth(pAuthCxt, pTable->dbName, pTable->tableName, AUTH_TYPE_READ, NULL); + } } return TSDB_CODE_SUCCESS == pAuthCxt->errCode ? DEAL_RES_CONTINUE : DEAL_RES_ERROR; } else if (QUERY_NODE_TEMP_TABLE == nodeType(pNode)) { @@ -196,6 +247,14 @@ static int32_t authShowCreateTable(SAuthCxt* pCxt, SShowCreateTableStmt* pStmt) return checkAuth(pCxt, pStmt->dbName, pStmt->tableName, AUTH_TYPE_READ, &pTagCond); } +static int32_t authShowCreateView(SAuthCxt* pCxt, SShowCreateViewStmt* pStmt) { +#ifndef TD_ENTERPRISE + return TSDB_CODE_OPS_NOT_SUPPORT; +#endif + + return TSDB_CODE_SUCCESS; +} + static int32_t authCreateTable(SAuthCxt* pCxt, SCreateTableStmt* pStmt) { SNode* pTagCond = NULL; // todo check tag condition for subtable @@ -238,6 +297,20 @@ static int32_t authAlterTable(SAuthCxt* pCxt, SAlterTableStmt* pStmt) { return checkAuth(pCxt, pStmt->dbName, pStmt->tableName, AUTH_TYPE_WRITE, NULL); } +static int32_t authCreateView(SAuthCxt* pCxt, SCreateViewStmt* pStmt) { +#ifndef TD_ENTERPRISE + return TSDB_CODE_OPS_NOT_SUPPORT; +#endif + return checkAuth(pCxt, pStmt->dbName, NULL, AUTH_TYPE_WRITE, NULL); +} + +static int32_t authDropView(SAuthCxt* pCxt, SDropViewStmt* pStmt) { +#ifndef TD_ENTERPRISE + return TSDB_CODE_OPS_NOT_SUPPORT; +#endif + return checkViewAuth(pCxt, pStmt->dbName, pStmt->viewName, AUTH_TYPE_ALTER, NULL); +} + static int32_t authQuery(SAuthCxt* pCxt, SNode* pStmt) { switch (nodeType(pStmt)) { case QUERY_NODE_SET_OPERATOR: @@ -283,6 +356,12 @@ static int32_t authQuery(SAuthCxt* pCxt, SNode* pStmt) { case QUERY_NODE_SHOW_CREATE_TABLE_STMT: case QUERY_NODE_SHOW_CREATE_STABLE_STMT: return authShowCreateTable(pCxt, (SShowCreateTableStmt*)pStmt); +// case QUERY_NODE_SHOW_CREATE_VIEW_STMT: +// return authShowCreateView(pCxt, (SShowCreateViewStmt*)pStmt); + case QUERY_NODE_CREATE_VIEW_STMT: + return authCreateView(pCxt, (SCreateViewStmt*)pStmt); + case QUERY_NODE_DROP_VIEW_STMT: + return authDropView(pCxt, (SDropViewStmt*)pStmt); default: break; } diff --git a/source/libs/parser/src/parCalcConst.c b/source/libs/parser/src/parCalcConst.c index 76d7e902ec..23ce3aa77d 100644 --- a/source/libs/parser/src/parCalcConst.c +++ b/source/libs/parser/src/parCalcConst.c @@ -18,10 +18,17 @@ #include "scalar.h" #include "ttime.h" +typedef struct SNodeReplaceContext { + SNode* pTarget; + SNode* pNew; + bool replaced; +} SNodeReplaceContext; + typedef struct SCalcConstContext { - SParseContext* pParseCxt; - SMsgBuf msgBuf; - int32_t code; + SParseContext* pParseCxt; + SNodeReplaceContext replaceCxt; + SMsgBuf msgBuf; + int32_t code; } SCalcConstContext; static int32_t calcConstQuery(SCalcConstContext* pCxt, SNode* pStmt, bool subquery); @@ -166,7 +173,35 @@ static int32_t calcConstStmtCondition(SCalcConstContext* pCxt, SNode** pCond, bo return code; } -static int32_t calcConstProject(SNode* pProject, bool dual, SNode** pNew) { +static EDealRes doFindAndReplaceNode(SNode** pNode, void* pContext) { + SCalcConstContext* pCxt = pContext; + if (pCxt->replaceCxt.pTarget == *pNode) { + nodesDestroyNode(*pNode); + *pNode = nodesCloneNode(pCxt->replaceCxt.pNew); + if (NULL == *pNode) { + pCxt->code = TSDB_CODE_OUT_OF_MEMORY; + return DEAL_RES_ERROR; + } + + pCxt->replaceCxt.replaced = true; + return DEAL_RES_END; + } + return DEAL_RES_CONTINUE; +} + +static int32_t findAndReplaceNode(SCalcConstContext* pCxt, SNode** pRoot, SNode* pTarget, SNode* pNew, bool strict) { + pCxt->replaceCxt.pNew = pNew; + pCxt->replaceCxt.pTarget = pTarget; + + nodesRewriteExprPostOrder(pRoot, doFindAndReplaceNode, pCxt); + if (TSDB_CODE_SUCCESS == pCxt->code && strict && !pCxt->replaceCxt.replaced) { + parserError("target replace node not found, %p", pTarget); + return TSDB_CODE_PAR_INTERNAL_ERROR; + } + return pCxt->code; +} + +static int32_t calcConstProject(SCalcConstContext* pCxt, SNode* pProject, bool dual, SNode** pNew) { SArray* pAssociation = NULL; if (NULL != ((SExprNode*)pProject)->pAssociation) { pAssociation = taosArrayDup(((SExprNode*)pProject)->pAssociation, NULL); @@ -188,12 +223,20 @@ static int32_t calcConstProject(SNode* pProject, bool dual, SNode** pNew) { if (QUERY_NODE_VALUE == nodeType(*pNew) && NULL != pAssociation) { int32_t size = taosArrayGetSize(pAssociation); for (int32_t i = 0; i < size; ++i) { - SNode** pCol = taosArrayGetP(pAssociation, i); - nodesDestroyNode(*pCol); - *pCol = nodesCloneNode(*pNew); - if (NULL == *pCol) { - code = TSDB_CODE_OUT_OF_MEMORY; - break; + SAssociationNode* pAssNode = taosArrayGet(pAssociation, i); + SNode** pCol = pAssNode->pPlace; + if (*pCol == pAssNode->pAssociationNode) { + nodesDestroyNode(*pCol); + *pCol = nodesCloneNode(*pNew); + if (NULL == *pCol) { + code = TSDB_CODE_OUT_OF_MEMORY; + break; + } + } else { + code = findAndReplaceNode(pCxt, pCol, pAssNode->pAssociationNode, *pNew, true); + if (TSDB_CODE_SUCCESS != code) { + break; + } } } } @@ -247,7 +290,7 @@ static int32_t calcConstProjections(SCalcConstContext* pCxt, SSelectStmt* pSelec continue; } SNode* pNew = NULL; - int32_t code = calcConstProject(pProj, (NULL == pSelect->pFromTable), &pNew); + int32_t code = calcConstProject(pCxt, pProj, (NULL == pSelect->pFromTable), &pNew); if (TSDB_CODE_SUCCESS == code) { REPLACE_NODE(pNew); } else { @@ -514,7 +557,7 @@ static void resetProjectNullTypeImpl(SNodeList* pProjects) { SExprNode* pExpr = (SExprNode*)pProj; if (TSDB_DATA_TYPE_NULL == pExpr->resType.type) { pExpr->resType.type = TSDB_DATA_TYPE_VARCHAR; - pExpr->resType.bytes = 0; + pExpr->resType.bytes = VARSTR_HEADER_SIZE; } } } diff --git a/source/libs/parser/src/parInsertSml.c b/source/libs/parser/src/parInsertSml.c index 517bc630c3..f2194402da 100644 --- a/source/libs/parser/src/parInsertSml.c +++ b/source/libs/parser/src/parInsertSml.c @@ -169,7 +169,7 @@ STableDataCxt* smlInitTableDataCtx(SQuery* query, STableMeta* pTableMeta) { STableDataCxt* pTableCxt = NULL; SVCreateTbReq* pCreateTbReq = NULL; int ret = insGetTableDataCxt(((SVnodeModifyOpStmt*)(query->pRoot))->pTableBlockHashObj, &pTableMeta->uid, - sizeof(pTableMeta->uid), pTableMeta, &pCreateTbReq, &pTableCxt, false); + sizeof(pTableMeta->uid), pTableMeta, &pCreateTbReq, &pTableCxt, false, false); if (ret != TSDB_CODE_SUCCESS) { return NULL; } @@ -305,7 +305,7 @@ int32_t smlBindData(SQuery* query, bool dataFormat, SArray* tags, SArray* colsSc STableDataCxt* pTableCxt = NULL; ret = insGetTableDataCxt(((SVnodeModifyOpStmt*)(query->pRoot))->pTableBlockHashObj, &pTableMeta->uid, - sizeof(pTableMeta->uid), pTableMeta, &pCreateTblReq, &pTableCxt, false); + sizeof(pTableMeta->uid), pTableMeta, &pCreateTblReq, &pTableCxt, false, false); if (ret != TSDB_CODE_SUCCESS) { buildInvalidOperationMsg(&pBuf, "insGetTableDataCxt error"); goto end; diff --git a/source/libs/parser/src/parInsertSql.c b/source/libs/parser/src/parInsertSql.c index 0e007e127e..d9e08de6b8 100644 --- a/source/libs/parser/src/parInsertSql.c +++ b/source/libs/parser/src/parInsertSql.c @@ -182,9 +182,32 @@ static int32_t parseDuplicateUsingClause(SInsertParseContext* pCxt, SVnodeModify return TSDB_CODE_SUCCESS; } +typedef enum { + BOUND_TAGS, + BOUND_COLUMNS, + BOUND_ALL_AND_TBNAME +} EBoundColumnsType; + +static int32_t getTbnameSchemaIndex(STableMeta* pTableMeta) { + return pTableMeta->tableInfo.numOfTags + pTableMeta->tableInfo.numOfColumns; +} + // pStmt->pSql -> field1_name, ...) -static int32_t parseBoundColumns(SInsertParseContext* pCxt, const char** pSql, bool isTags, SSchema* pSchema, +static int32_t parseBoundColumns(SInsertParseContext* pCxt, const char** pSql, EBoundColumnsType boundColsType, STableMeta* pTableMeta, SBoundColInfo* pBoundInfo) { + SSchema* pSchema = NULL; + if (boundColsType == BOUND_TAGS) { + pSchema = getTableTagSchema(pTableMeta); + } else if (boundColsType == BOUND_COLUMNS) { + pSchema = getTableColumnSchema(pTableMeta); + } else { + pSchema = pTableMeta->schema; + if (pBoundInfo->numOfCols != getTbnameSchemaIndex(pTableMeta) + 1) { + return TSDB_CODE_PAR_INTERNAL_ERROR; + } + } + int32_t tbnameSchemaIndex = getTbnameSchemaIndex(pTableMeta); + bool* pUseCols = taosMemoryCalloc(pBoundInfo->numOfCols, sizeof(bool)); if (NULL == pUseCols) { return TSDB_CODE_OUT_OF_MEMORY; @@ -207,8 +230,16 @@ static int32_t parseBoundColumns(SInsertParseContext* pCxt, const char** pSql, b token.z = tmpTokenBuf; token.n = strdequote(token.z); + if (boundColsType == BOUND_ALL_AND_TBNAME && + token.n == strlen("tbname") && (strcasecmp(token.z, "tbname") == 0)) { + pBoundInfo->pColIndex[pBoundInfo->numOfBound] = tbnameSchemaIndex; + pUseCols[tbnameSchemaIndex] = true; + ++pBoundInfo->numOfBound; + continue; + } int16_t t = lastColIdx + 1; - int16_t index = insFindCol(&token, t, pBoundInfo->numOfCols, pSchema); + int16_t end = (boundColsType == BOUND_ALL_AND_TBNAME) ? (pBoundInfo->numOfCols - 1) : pBoundInfo->numOfCols; + int16_t index = insFindCol(&token, t, end, pSchema); if (index < 0 && t > 0) { index = insFindCol(&token, 0, t, pSchema); } @@ -224,10 +255,12 @@ static int32_t parseBoundColumns(SInsertParseContext* pCxt, const char** pSql, b } } - if (TSDB_CODE_SUCCESS == code && !isTags && !pUseCols[0]) { + if (TSDB_CODE_SUCCESS == code && (BOUND_TAGS != boundColsType) && !pUseCols[0]) { code = buildInvalidOperationMsg(&pCxt->msg, "primary timestamp column can not be null"); } - + if (TSDB_CODE_SUCCESS == code && (BOUND_ALL_AND_TBNAME == boundColsType) &&!pUseCols[tbnameSchemaIndex]) { + code = buildInvalidOperationMsg(&pCxt->msg, "tbname column can not be null"); + } taosMemoryFree(pUseCols); return code; @@ -586,10 +619,10 @@ static int32_t parseBoundTagsClause(SInsertParseContext* pCxt, SVnodeModifyOpStm } pStmt->pSql += index; - return parseBoundColumns(pCxt, &pStmt->pSql, true, getTableTagSchema(pStmt->pTableMeta), &pCxt->tags); + return parseBoundColumns(pCxt, &pStmt->pSql, BOUND_TAGS, pStmt->pTableMeta, &pCxt->tags); } -static int32_t parseTagValue(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, SSchema* pTagSchema, SToken* pToken, +static int32_t parseTagValue(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, const char** ppSql, SSchema* pTagSchema, SToken* pToken, SArray* pTagName, SArray* pTagVals, STag** pTag) { if (!isNullValue(pTagSchema->type, pToken)) { taosArrayPush(pTagName, pTagSchema->name); @@ -609,7 +642,7 @@ static int32_t parseTagValue(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStm STagVal val = {0}; int32_t code = - parseTagToken(&pStmt->pSql, pToken, pTagSchema, pStmt->pTableMeta->tableInfo.precision, &val, &pCxt->msg); + parseTagToken(ppSql, pToken, pTagSchema, pStmt->pTableMeta->tableInfo.precision, &val, &pCxt->msg); if (TSDB_CODE_SUCCESS == code) { taosArrayPush(pTagVals, &val); } @@ -812,7 +845,7 @@ static int32_t parseTagsClauseImpl(SInsertParseContext* pCxt, SVnodeModifyOpStmt isJson = pTagSchema->type == TSDB_DATA_TYPE_JSON; code = checkAndTrimValue(&token, pCxt->tmpTokenBuf, &pCxt->msg); if (TSDB_CODE_SUCCESS == code) { - code = parseTagValue(pCxt, pStmt, pTagSchema, &token, pTagName, pTagVals, &pTag); + code = parseTagValue(pCxt, pStmt, &pStmt->pSql, pTagSchema, &token, pTagName, pTagVals, &pTag); } } @@ -867,7 +900,7 @@ static int32_t parseTagsClause(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pS return code; } -static int32_t storeTableMeta(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt) { +static int32_t storeChildTableMeta(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt) { pStmt->pTableMeta->suid = pStmt->pTableMeta->uid; pStmt->pTableMeta->uid = pStmt->totalTbNum; pStmt->pTableMeta->tableType = TSDB_CHILD_TABLE; @@ -965,36 +998,21 @@ static int32_t checkAuth(SParseContext* pCxt, SName* pTbName, bool* pMissCache, if (TSDB_CODE_SUCCESS == code) { if (!exists) { *pMissCache = true; - } else if (!authRes.pass) { + } else if (!authRes.pass[AUTH_RES_BASIC]) { code = TSDB_CODE_PAR_PERMISSION_DENIED; - } else if (NULL != authRes.pCond) { - *pTagCond = authRes.pCond; + } else if (NULL != authRes.pCond[AUTH_RES_BASIC]) { + *pTagCond = authRes.pCond[AUTH_RES_BASIC]; } } return code; } -static int32_t checkAuthForTable(SParseContext* pCxt, SName* pTbName, bool* pMissCache, bool* pNeedTableTagVal) { - SNode* pTagCond = NULL; - int32_t code = checkAuth(pCxt, pTbName, pMissCache, &pTagCond); - if (TSDB_CODE_SUCCESS == code) { - *pNeedTableTagVal = ((*pMissCache) || (NULL != pTagCond)); - *pMissCache = (NULL != pTagCond); - } - nodesDestroyNode(pTagCond); - return code; -} - -static int32_t checkAuthForStable(SParseContext* pCxt, SName* pTbName, bool* pMissCache, SNode** pTagCond) { - return checkAuth(pCxt, pTbName, pMissCache, pTagCond); -} - -static int32_t getTableMeta(SInsertParseContext* pCxt, SName* pTbName, bool isStb, STableMeta** pTableMeta, - bool* pMissCache) { +static int32_t getTableMeta(SInsertParseContext* pCxt, SName* pTbName, STableMeta** pTableMeta, + bool* pMissCache, bool bUsingTable) { SParseContext* pComCxt = pCxt->pComCxt; int32_t code = TSDB_CODE_SUCCESS; if (pComCxt->async) { - if (isStb) { + if (bUsingTable) { code = catalogGetCachedSTableMeta(pComCxt->pCatalog, pTbName, pTableMeta); } else { code = catalogGetCachedTableMeta(pComCxt->pCatalog, pTbName, pTableMeta); @@ -1004,7 +1022,7 @@ static int32_t getTableMeta(SInsertParseContext* pCxt, SName* pTbName, bool isSt .requestId = pComCxt->requestId, .requestObjRefId = pComCxt->requestRid, .mgmtEps = pComCxt->mgmtEpSet}; - if (isStb) { + if (bUsingTable) { code = catalogGetSTableMeta(pComCxt->pCatalog, &conn, pTbName, pTableMeta); } else { code = catalogGetTableMeta(pComCxt->pCatalog, &conn, pTbName, pTableMeta); @@ -1013,16 +1031,14 @@ static int32_t getTableMeta(SInsertParseContext* pCxt, SName* pTbName, bool isSt if (TSDB_CODE_SUCCESS == code) { if (NULL == *pTableMeta) { *pMissCache = true; - } else if (isStb && TSDB_SUPER_TABLE != (*pTableMeta)->tableType) { + } else if (bUsingTable && TSDB_SUPER_TABLE != (*pTableMeta)->tableType) { code = buildInvalidOperationMsg(&pCxt->msg, "create table only from super table is allowed"); - } else if (!isStb && TSDB_SUPER_TABLE == (*pTableMeta)->tableType) { - code = buildInvalidOperationMsg(&pCxt->msg, "insert data into super table is not supported"); } } return code; } -static int32_t getTableVgroup(SParseContext* pCxt, SVnodeModifyOpStmt* pStmt, bool isStb, bool* pMissCache) { +static int32_t getTargetTableVgroup(SParseContext* pCxt, SVnodeModifyOpStmt* pStmt, bool isStb, bool* pMissCache) { int32_t code = TSDB_CODE_SUCCESS; SVgroupInfo vg; bool exists = true; @@ -1047,27 +1063,34 @@ static int32_t getTableVgroup(SParseContext* pCxt, SVnodeModifyOpStmt* pStmt, bo return code; } -static int32_t getTableMetaAndVgroupImpl(SParseContext* pCxt, SVnodeModifyOpStmt* pStmt, bool* pMissCache) { - SVgroupInfo vg; - int32_t code = catalogGetCachedTableVgMeta(pCxt->pCatalog, &pStmt->targetTableName, &vg, &pStmt->pTableMeta); - if (TSDB_CODE_SUCCESS == code) { - if (NULL != pStmt->pTableMeta) { - code = taosHashPut(pStmt->pVgroupsHashObj, (const char*)&vg.vgId, sizeof(vg.vgId), (char*)&vg, sizeof(vg)); - } - *pMissCache = (NULL == pStmt->pTableMeta); - } - return code; -} - -static int32_t getTableMetaAndVgroup(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, bool* pMissCache) { +static int32_t getTargetTableMetaAndVgroup(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, bool* pMissCache) { SParseContext* pComCxt = pCxt->pComCxt; int32_t code = TSDB_CODE_SUCCESS; if (pComCxt->async) { - code = getTableMetaAndVgroupImpl(pComCxt, pStmt, pMissCache); + { + SVgroupInfo vg; + code = catalogGetCachedTableVgMeta(pComCxt->pCatalog, &pStmt->targetTableName, &vg, &pStmt->pTableMeta); + if (TSDB_CODE_SUCCESS == code) { + if (NULL != pStmt->pTableMeta) { + if (pStmt->pTableMeta->tableType == TSDB_SUPER_TABLE) { + pStmt->stbSyntax = true; + } else { + code = taosHashPut(pStmt->pVgroupsHashObj, (const char*)&vg.vgId, sizeof(vg.vgId), (char*)&vg, sizeof(vg)); + } + } + *pMissCache = (NULL == pStmt->pTableMeta); + } + } } else { - code = getTableMeta(pCxt, &pStmt->targetTableName, false, &pStmt->pTableMeta, pMissCache); + bool bUsingTable = false; + code = getTableMeta(pCxt, &pStmt->targetTableName, &pStmt->pTableMeta, pMissCache, bUsingTable); if (TSDB_CODE_SUCCESS == code && !pCxt->missCache) { - code = getTableVgroup(pCxt->pComCxt, pStmt, false, &pCxt->missCache); + if (TSDB_SUPER_TABLE == pStmt->pTableMeta->tableType) { + pStmt->stbSyntax = true; + } + if (!pStmt->stbSyntax) { + code = getTargetTableVgroup(pCxt->pComCxt, pStmt, false, &pCxt->missCache); + } } } return code; @@ -1090,11 +1113,21 @@ static int32_t getTargetTableSchema(SInsertParseContext* pCxt, SVnodeModifyOpStm pCxt->missCache = true; return TSDB_CODE_SUCCESS; } - - int32_t code = checkAuthForTable(pCxt->pComCxt, &pStmt->targetTableName, &pCxt->missCache, &pCxt->needTableTagVal); + SNode* pTagCond = NULL; + int32_t code = checkAuth(pCxt->pComCxt, &pStmt->targetTableName, &pCxt->missCache, &pTagCond); if (TSDB_CODE_SUCCESS == code && !pCxt->missCache) { - code = getTableMetaAndVgroup(pCxt, pStmt, &pCxt->missCache); + code = getTargetTableMetaAndVgroup(pCxt, pStmt, &pCxt->missCache); } + if (TSDB_CODE_SUCCESS == code && !pCxt->missCache) { + if (TSDB_SUPER_TABLE != pStmt->pTableMeta->tableType) { + pCxt->needTableTagVal = (NULL != pTagCond); + pCxt->missCache = (NULL != pTagCond); + } else { + pStmt->pTagCond = nodesCloneNode(pTagCond); + } + } + nodesDestroyNode(pTagCond); + if (TSDB_CODE_SUCCESS == code && !pCxt->pComCxt->async) { code = collectUseDatabase(&pStmt->targetTableName, pStmt->pDbFNameHashObj); if (TSDB_CODE_SUCCESS == code) { @@ -1114,12 +1147,13 @@ static int32_t getUsingTableSchema(SInsertParseContext* pCxt, SVnodeModifyOpStmt return TSDB_CODE_SUCCESS; } - int32_t code = checkAuthForStable(pCxt->pComCxt, &pStmt->usingTableName, &pCxt->missCache, &pStmt->pTagCond); + int32_t code = checkAuth(pCxt->pComCxt, &pStmt->usingTableName, &pCxt->missCache, &pStmt->pTagCond); if (TSDB_CODE_SUCCESS == code && !pCxt->missCache) { - code = getTableMeta(pCxt, &pStmt->usingTableName, true, &pStmt->pTableMeta, &pCxt->missCache); + bool bUsingTable = true; + code = getTableMeta(pCxt, &pStmt->usingTableName, &pStmt->pTableMeta, &pCxt->missCache, bUsingTable); } if (TSDB_CODE_SUCCESS == code && !pCxt->missCache) { - code = getTableVgroup(pCxt->pComCxt, pStmt, true, &pCxt->missCache); + code = getTargetTableVgroup(pCxt->pComCxt, pStmt, true, &pCxt->missCache); } if (TSDB_CODE_SUCCESS == code && !pCxt->pComCxt->async) { code = collectUseDatabase(&pStmt->usingTableName, pStmt->pDbFNameHashObj); @@ -1138,7 +1172,7 @@ static int32_t parseUsingTableNameImpl(SInsertParseContext* pCxt, SVnodeModifyOp code = getUsingTableSchema(pCxt, pStmt); } if (TSDB_CODE_SUCCESS == code && !pCxt->missCache) { - code = storeTableMeta(pCxt, pStmt); + code = storeChildTableMeta(pCxt, pStmt); } return code; } @@ -1168,7 +1202,14 @@ static int32_t parseUsingTableName(SInsertParseContext* pCxt, SVnodeModifyOpStmt } static int32_t preParseTargetTableName(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, SToken* pTbName) { - return insCreateSName(&pStmt->targetTableName, pTbName, pCxt->pComCxt->acctId, pCxt->pComCxt->db, &pCxt->msg); + int32_t code = insCreateSName(&pStmt->targetTableName, pTbName, pCxt->pComCxt->acctId, pCxt->pComCxt->db, &pCxt->msg); + if (TSDB_CODE_SUCCESS == code) { + if (IS_SYS_DBNAME(pStmt->targetTableName.dbname)) { + return TSDB_CODE_PAR_SYSTABLE_NOT_ALLOWED; + } + } + + return code; } // input pStmt->pSql: @@ -1195,7 +1236,7 @@ static int32_t preParseBoundColumnsClause(SInsertParseContext* pCxt, SVnodeModif static int32_t getTableDataCxt(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, STableDataCxt** pTableCxt) { if (pCxt->pComCxt->async) { return insGetTableDataCxt(pStmt->pTableBlockHashObj, &pStmt->pTableMeta->uid, sizeof(pStmt->pTableMeta->uid), - pStmt->pTableMeta, &pStmt->pCreateTblReq, pTableCxt, false); + pStmt->pTableMeta, &pStmt->pCreateTblReq, pTableCxt, false, false); } char tbFName[TSDB_TABLE_FNAME_LEN]; @@ -1204,7 +1245,7 @@ static int32_t getTableDataCxt(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pS pStmt->pTableMeta->uid = 0; } return insGetTableDataCxt(pStmt->pTableBlockHashObj, tbFName, strlen(tbFName), pStmt->pTableMeta, - &pStmt->pCreateTblReq, pTableCxt, NULL != pCxt->pComCxt->pStmtCb); + &pStmt->pCreateTblReq, pTableCxt, NULL != pCxt->pComCxt->pStmtCb, false); } static int32_t parseBoundColumnsClause(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, STableDataCxt* pTableCxt) { @@ -1217,12 +1258,12 @@ static int32_t parseBoundColumnsClause(SInsertParseContext* pCxt, SVnodeModifyOp return buildSyntaxErrMsg(&pCxt->msg, "keyword VALUES or FILE is expected", token.z); } // pStmt->pSql -> field1_name, ...) - return parseBoundColumns(pCxt, &pStmt->pSql, false, getTableColumnSchema(pStmt->pTableMeta), + return parseBoundColumns(pCxt, &pStmt->pSql, BOUND_COLUMNS, pStmt->pTableMeta, &pTableCxt->boundColsInfo); } if (NULL != pStmt->pBoundCols) { - return parseBoundColumns(pCxt, &pStmt->pBoundCols, false, getTableColumnSchema(pStmt->pTableMeta), + return parseBoundColumns(pCxt, &pStmt->pBoundCols, BOUND_COLUMNS, pStmt->pTableMeta, &pTableCxt->boundColsInfo); } @@ -1518,8 +1559,282 @@ static void clearColValArray(SArray* pCols) { } } -static int parseOneRow(SInsertParseContext* pCxt, const char** pSql, STableDataCxt* pTableCxt, bool* pGotRow, - SToken* pToken) { +typedef struct SStbRowsDataContext { + SName stbName; + + STableMeta* pStbMeta; + SNode* pTagCond; + SBoundColInfo boundColsInfo; + + // the following fields are for each stb row + SArray* aTagVals; + SArray* aColVals; + SArray* aTagNames; + SName ctbName; + STag* pTag; + STableMeta* pCtbMeta; + SVCreateTbReq* pCreateCtbReq; + bool hasTimestampTag; + bool isJsonTag; +} SStbRowsDataContext; + +typedef union SRowsDataContext{ + STableDataCxt* pTableDataCxt; + SStbRowsDataContext* pStbRowsCxt; +} SRowsDataContext; + +static int32_t parseTbnameToken(SInsertParseContext* pCxt, SStbRowsDataContext* pStbRowsCxt, SToken* pToken, + char* ctbName, bool* pFoundCtbName) { + *pFoundCtbName = false; + int32_t code = checkAndTrimValue(pToken, pCxt->tmpTokenBuf, &pCxt->msg); + if (code == TSDB_CODE_SUCCESS){ + if (isNullValue(TSDB_DATA_TYPE_BINARY, pToken)) { + return buildInvalidOperationMsg(&pCxt->msg, "tbname can not be null value"); + } + + if (pToken->n > 0) { + if (pToken->n <= TSDB_TABLE_NAME_LEN - 1) { + memcpy(ctbName, pToken->z, pToken->n); + ctbName[pToken->n] = '\0'; + *pFoundCtbName = true; + tNameSetDbName(&pStbRowsCxt->ctbName, pStbRowsCxt->stbName.acctId, pStbRowsCxt->stbName.dbname, strlen(pStbRowsCxt->stbName.dbname)); + tNameAddTbName(&pStbRowsCxt->ctbName, ctbName, pToken->n); + } else { + return buildInvalidOperationMsg(&pCxt->msg, "tbname is too long"); + } + } else { + return buildInvalidOperationMsg(&pCxt->msg, "tbname can not be empty"); + } + } + return code; +} + +static int32_t processCtbTagsAfterCtbName(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, + SStbRowsDataContext* pStbRowsCxt, bool ctbFirst, + const SToken* tagTokens, SSchema* const* tagSchemas, + int numOfTagTokens) { + int32_t code = TSDB_CODE_SUCCESS; + + if (code == TSDB_CODE_SUCCESS && ctbFirst) { + for (int32_t i = 0; code == TSDB_CODE_SUCCESS && i < numOfTagTokens; ++i) { + SToken* pTagToken = (SToken*)(tagTokens + i); + SSchema* pTagSchema = tagSchemas[i]; + code = checkAndTrimValue(pTagToken, pCxt->tmpTokenBuf, &pCxt->msg); + if (code == TSDB_CODE_SUCCESS) { + code = parseTagValue(pCxt, pStmt, NULL, pTagSchema, pTagToken, pStbRowsCxt->aTagNames, pStbRowsCxt->aTagVals, + &pStbRowsCxt->pTag); + } + } + if (code == TSDB_CODE_SUCCESS && !pStbRowsCxt->isJsonTag) { + code = tTagNew(pStbRowsCxt->aTagVals, 1, false, &pStbRowsCxt->pTag); + } + } + + if (code == TSDB_CODE_SUCCESS && pStbRowsCxt->pTagCond) { + code = checkSubtablePrivilege(pStbRowsCxt->aTagVals, pStbRowsCxt->aTagNames, &pStbRowsCxt->pTagCond); + } + return code; +} + +static int32_t doGetStbRowValues(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, const char** ppSql, + SStbRowsDataContext* pStbRowsCxt, SToken* pToken, + const SBoundColInfo* pCols, const SSchema* pSchemas, + SToken* tagTokens, SSchema** tagSchemas, int* pNumOfTagTokens, bool* bFoundTbName) { + int32_t code = TSDB_CODE_SUCCESS; + SArray* pTagNames = pStbRowsCxt->aTagNames; + SArray* pTagVals = pStbRowsCxt->aTagVals; + bool canParseTagsAfter = !pStbRowsCxt->pTagCond && !pStbRowsCxt->hasTimestampTag; + for (int i = 0; i < pCols->numOfBound && (code) == TSDB_CODE_SUCCESS; ++i) { + const char* pTmpSql = *ppSql; + bool ignoreComma = false; + NEXT_TOKEN_WITH_PREV_EXT(*ppSql, *pToken, &ignoreComma); + if (ignoreComma) { + code = buildSyntaxErrMsg(&pCxt->msg, "invalid data or symbol", pTmpSql); + break; + } + + if (TK_NK_RP == pToken->type) { + code = generateSyntaxErrMsg(&pCxt->msg, TSDB_CODE_PAR_INVALID_COLUMNS_NUM); + break; + } + + if (pCols->pColIndex[i] < getNumOfColumns(pStbRowsCxt->pStbMeta)) { + const SSchema* pSchema = &pSchemas[pCols->pColIndex[i]]; + SColVal* pVal = taosArrayGet(pStbRowsCxt->aColVals, pCols->pColIndex[i]); + code = parseValueToken(pCxt, ppSql, pToken, (SSchema*)pSchema, getTableInfo(pStbRowsCxt->pStbMeta).precision, pVal); + } else if (pCols->pColIndex[i] < getTbnameSchemaIndex(pStbRowsCxt->pStbMeta)) { + const SSchema* pTagSchema = &pSchemas[pCols->pColIndex[i]]; + if (canParseTagsAfter) { + tagTokens[(*pNumOfTagTokens)] = *pToken; + tagSchemas[(*pNumOfTagTokens)] = (SSchema*)pTagSchema; + ++(*pNumOfTagTokens); + } else { + code = checkAndTrimValue(pToken, pCxt->tmpTokenBuf, &pCxt->msg); + if (code == TSDB_CODE_SUCCESS) { + code = parseTagValue(pCxt, pStmt, ppSql, (SSchema*)pTagSchema, pToken, pTagNames, pTagVals, &pStbRowsCxt->pTag); + } + } + } + else if (pCols->pColIndex[i] == getTbnameSchemaIndex(pStbRowsCxt->pStbMeta)) { + char ctbName[TSDB_TABLE_NAME_LEN]; + code = parseTbnameToken(pCxt, pStbRowsCxt, pToken, ctbName, bFoundTbName); + } + + if (code == TSDB_CODE_SUCCESS && i < pCols->numOfBound - 1) { + NEXT_VALID_TOKEN(*ppSql, *pToken); + if (TK_NK_COMMA != pToken->type) { + code = buildSyntaxErrMsg(&pCxt->msg, ", expected", pToken->z); + } + } + } + return code; +} + +static int32_t getStbRowValues(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, const char** ppSql, + SStbRowsDataContext* pStbRowsCxt, bool* pGotRow, + SToken* pToken, bool *pCtbFirst) { + SBoundColInfo* pCols = &pStbRowsCxt->boundColsInfo; + SSchema* pSchemas = getTableColumnSchema(pStbRowsCxt->pStbMeta); + + bool bFoundTbName = false; + const char* pOrigSql = *ppSql; + + int32_t code = TSDB_CODE_SUCCESS; + SToken tagTokens[TSDB_MAX_TAGS] = {0}; + SSchema* tagSchemas[TSDB_MAX_TAGS] = {0}; + int numOfTagTokens = 0; + + code = doGetStbRowValues(pCxt, pStmt, ppSql, pStbRowsCxt, pToken, pCols, pSchemas, tagTokens, + tagSchemas, &numOfTagTokens, &bFoundTbName); + + if (code == TSDB_CODE_SUCCESS && !bFoundTbName) { + code = buildSyntaxErrMsg(&pCxt->msg, "tbname value expected", pOrigSql); + } + + bool ctbFirst = true; + if (code == TSDB_CODE_SUCCESS) { + char ctbFName[TSDB_TABLE_FNAME_LEN]; + tNameExtractFullName(&pStbRowsCxt->ctbName, ctbFName); + STableMeta** pCtbMeta = taosHashGet(pStmt->pSubTableHashObj, ctbFName, strlen(ctbFName)); + ctbFirst = (pCtbMeta == NULL); + if (!ctbFirst) { + pStbRowsCxt->pCtbMeta->uid = (*pCtbMeta)->uid; + pStbRowsCxt->pCtbMeta->vgId = (*pCtbMeta)->vgId; + } + *pCtbFirst = ctbFirst; + } + + if (code == TSDB_CODE_SUCCESS) { + code = processCtbTagsAfterCtbName(pCxt, pStmt, pStbRowsCxt, ctbFirst, tagTokens, tagSchemas, numOfTagTokens); + } + + if (code == TSDB_CODE_SUCCESS) { + *pGotRow = true; + } + return code; +} + +static int32_t processCtbAutoCreationAndCtbMeta(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, SStbRowsDataContext* pStbRowsCxt) { + int32_t code = TSDB_CODE_SUCCESS; + + pStbRowsCxt->pCreateCtbReq = taosMemoryCalloc(1, sizeof(SVCreateTbReq)); + if (pStbRowsCxt->pCreateCtbReq == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + } + if (code == TSDB_CODE_SUCCESS) { + insBuildCreateTbReq(pStbRowsCxt->pCreateCtbReq, pStbRowsCxt->ctbName.tname, pStbRowsCxt->pTag, pStbRowsCxt->pStbMeta->uid, + pStbRowsCxt->stbName.tname, pStbRowsCxt->aTagNames, getNumOfTags(pStbRowsCxt->pStbMeta), + TSDB_DEFAULT_TABLE_TTL); + pStbRowsCxt->pTag = NULL; + } + + if (code == TSDB_CODE_SUCCESS) { + char ctbFName[TSDB_TABLE_FNAME_LEN]; + tNameExtractFullName(&pStbRowsCxt->ctbName, ctbFName); + SVgroupInfo vg; + SRequestConnInfo conn = {.pTrans = pCxt->pComCxt->pTransporter, + .requestId = pCxt->pComCxt->requestId, + .requestObjRefId = pCxt->pComCxt->requestRid, + .mgmtEps = pCxt->pComCxt->mgmtEpSet}; + code = catalogGetTableHashVgroup(pCxt->pComCxt->pCatalog, &conn, &pStmt->targetTableName, &vg); + if (code == TSDB_CODE_SUCCESS) { + taosHashPut(pStmt->pVgroupsHashObj, (const char*)(&vg.vgId), sizeof(vg.vgId), &vg, sizeof(vg)); + pStbRowsCxt->pCtbMeta->uid = taosHashGetSize(pStmt->pSubTableHashObj) + 1; + pStbRowsCxt->pCtbMeta->vgId = vg.vgId; + + STableMeta* pBackup = NULL; + cloneTableMeta(pStbRowsCxt->pCtbMeta, &pBackup); + taosHashPut(pStmt->pSubTableHashObj, ctbFName, strlen(ctbFName), &pBackup, POINTER_BYTES); + } + collectUseTable(&pStbRowsCxt->ctbName, pStmt->pTableNameHashObj); + } + return code; +} + +static void resetStbRowsDataContextPreStbRow(SStbRowsDataContext* pStbRowsCxt) { + pStbRowsCxt->pCtbMeta->tableType = TSDB_CHILD_TABLE; + pStbRowsCxt->pCtbMeta->suid = pStbRowsCxt->pStbMeta->uid; + + insInitColValues(pStbRowsCxt->pStbMeta, pStbRowsCxt->aColVals); +} + +static void clearStbRowsDataContext(SStbRowsDataContext* pStbRowsCxt) { + if (pStbRowsCxt == NULL) return; + + taosArrayClear(pStbRowsCxt->aTagNames); + for (int i = 0; i < taosArrayGetSize(pStbRowsCxt->aTagVals); ++i) { + STagVal* p = (STagVal*)taosArrayGet(pStbRowsCxt->aTagVals, i); + if (IS_VAR_DATA_TYPE(p->type)) { + taosMemoryFreeClear(p->pData); + } + } + taosArrayClear(pStbRowsCxt->aTagVals); + + clearColValArray(pStbRowsCxt->aColVals); + taosArrayClear(pStbRowsCxt->aColVals); + + tTagFree(pStbRowsCxt->pTag); + pStbRowsCxt->pTag = NULL; + pStbRowsCxt->pCtbMeta->uid = 0; + pStbRowsCxt->pCtbMeta->vgId = 0; + tdDestroySVCreateTbReq(pStbRowsCxt->pCreateCtbReq); + taosMemoryFreeClear(pStbRowsCxt->pCreateCtbReq); +} + +static int32_t parseOneStbRow(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, const char** ppSql, + SStbRowsDataContext* pStbRowsCxt, bool* pGotRow, SToken* pToken) { + resetStbRowsDataContextPreStbRow(pStbRowsCxt); + bool bFirstTable = false; + int32_t code = getStbRowValues(pCxt, pStmt, ppSql, pStbRowsCxt, pGotRow, pToken, &bFirstTable); + if (code != TSDB_CODE_SUCCESS || !*pGotRow) { + return code; + } + + if (code == TSDB_CODE_SUCCESS && bFirstTable) { + code = processCtbAutoCreationAndCtbMeta(pCxt, pStmt, pStbRowsCxt); + } + + STableDataCxt* pTableDataCxt = NULL; + code = insGetTableDataCxt(pStmt->pTableBlockHashObj, &pStbRowsCxt->pCtbMeta->uid, sizeof(pStbRowsCxt->pCtbMeta->uid), + pStbRowsCxt->pCtbMeta, &pStbRowsCxt->pCreateCtbReq, &pTableDataCxt, false, true); + initTableColSubmitData(pTableDataCxt); + if (code == TSDB_CODE_SUCCESS) { + SRow** pRow = taosArrayReserve(pTableDataCxt->pData->aRowP, 1); + code = tRowBuild(pStbRowsCxt->aColVals, pTableDataCxt->pSchema, pRow); + if (TSDB_CODE_SUCCESS == code) { + insCheckTableDataOrder(pTableDataCxt, TD_ROW_KEY(*pRow)); + } + } + if (code == TSDB_CODE_SUCCESS) { + *pGotRow = true; + } + + clearStbRowsDataContext(pStbRowsCxt); + + return TSDB_CODE_SUCCESS; +} + +static int parseOneRow(SInsertParseContext* pCxt, const char** pSql, STableDataCxt* pTableCxt, bool* pGotRow, SToken* pToken) { SBoundColInfo* pCols = &pTableCxt->boundColsInfo; bool isParseBindParam = false; SSchema* pSchemas = getTableColumnSchema(pTableCxt->pMeta); @@ -1586,7 +1901,7 @@ static int parseOneRow(SInsertParseContext* pCxt, const char** pSql, STableDataC } // pSql -> (field1_value, ...) [(field1_value2, ...) ...] -static int32_t parseValues(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, STableDataCxt* pTableCxt, +static int32_t parseValues(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, SRowsDataContext rowsDataCxt, int32_t* pNumOfRows, SToken* pToken) { int32_t code = TSDB_CODE_SUCCESS; @@ -1601,7 +1916,11 @@ static int32_t parseValues(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, bool gotRow = false; if (TSDB_CODE_SUCCESS == code) { - code = parseOneRow(pCxt, &pStmt->pSql, pTableCxt, &gotRow, pToken); + if (!pStmt->stbSyntax) { + code = parseOneRow(pCxt, &pStmt->pSql, rowsDataCxt.pTableDataCxt, &gotRow, pToken); + } else { + code = parseOneStbRow(pCxt, pStmt, &pStmt->pSql, rowsDataCxt.pStbRowsCxt, &gotRow, pToken); + } } if (TSDB_CODE_SUCCESS == code) { @@ -1626,10 +1945,10 @@ static int32_t parseValues(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, } // VALUES (field1_value, ...) [(field1_value2, ...) ...] -static int32_t parseValuesClause(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, STableDataCxt* pTableCxt, +static int32_t parseValuesClause(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, SRowsDataContext rowsDataContext, SToken* pToken) { int32_t numOfRows = 0; - int32_t code = parseValues(pCxt, pStmt, pTableCxt, &numOfRows, pToken); + int32_t code = parseValues(pCxt, pStmt, rowsDataContext, &numOfRows, pToken); if (TSDB_CODE_SUCCESS == code) { pStmt->totalRowsNum += numOfRows; pStmt->totalTbNum += 1; @@ -1638,7 +1957,7 @@ static int32_t parseValuesClause(SInsertParseContext* pCxt, SVnodeModifyOpStmt* return code; } -static int32_t parseCsvFile(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, STableDataCxt* pTableCxt, +static int32_t parseCsvFile(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, SRowsDataContext rowsDataCxt, int32_t* pNumOfRows) { int32_t code = TSDB_CODE_SUCCESS; (*pNumOfRows) = 0; @@ -1661,8 +1980,11 @@ static int32_t parseCsvFile(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt SToken token; strtolower(pLine, pLine); const char* pRow = pLine; - - code = parseOneRow(pCxt, (const char**)&pRow, pTableCxt, &gotRow, &token); + if (!pStmt->stbSyntax) { + code = parseOneRow(pCxt, (const char**)&pRow, rowsDataCxt.pTableDataCxt, &gotRow, &token); + } else { + code = parseOneStbRow(pCxt, pStmt, (const char**)&pRow, rowsDataCxt.pStbRowsCxt, &gotRow, &token); + } if (code && firstLine) { firstLine = false; code = 0; @@ -1692,9 +2014,9 @@ static int32_t parseCsvFile(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt return code; } -static int32_t parseDataFromFileImpl(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, STableDataCxt* pTableCxt) { +static int32_t parseDataFromFileImpl(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, SRowsDataContext rowsDataCxt) { int32_t numOfRows = 0; - int32_t code = parseCsvFile(pCxt, pStmt, pTableCxt, &numOfRows); + int32_t code = parseCsvFile(pCxt, pStmt, rowsDataCxt, &numOfRows); if (TSDB_CODE_SUCCESS == code) { pStmt->totalRowsNum += numOfRows; pStmt->totalTbNum += 1; @@ -1709,7 +2031,7 @@ static int32_t parseDataFromFileImpl(SInsertParseContext* pCxt, SVnodeModifyOpSt } static int32_t parseDataFromFile(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, SToken* pFilePath, - STableDataCxt* pTableCxt) { + SRowsDataContext rowsDataCxt) { char filePathStr[TSDB_FILENAME_LEN] = {0}; if (TK_NK_STRING == pFilePath->type) { trimString(pFilePath->z, pFilePath->n, filePathStr, sizeof(filePathStr)); @@ -1721,10 +2043,10 @@ static int32_t parseDataFromFile(SInsertParseContext* pCxt, SVnodeModifyOpStmt* return TAOS_SYSTEM_ERROR(errno); } - return parseDataFromFileImpl(pCxt, pStmt, pTableCxt); + return parseDataFromFileImpl(pCxt, pStmt, rowsDataCxt); } -static int32_t parseFileClause(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, STableDataCxt* pTableCxt, +static int32_t parseFileClause(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, SRowsDataContext rowsDataCxt, SToken* pToken) { if (tsUseAdapter) { return buildInvalidOperationMsg(&pCxt->msg, "proxy mode does not support csv loading"); @@ -1734,34 +2056,127 @@ static int32_t parseFileClause(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pS if (0 == pToken->n || (TK_NK_STRING != pToken->type && TK_NK_ID != pToken->type)) { return buildSyntaxErrMsg(&pCxt->msg, "file path is required following keyword FILE", pToken->z); } - return parseDataFromFile(pCxt, pStmt, pToken, pTableCxt); + return parseDataFromFile(pCxt, pStmt, pToken, rowsDataCxt); } // VALUES (field1_value, ...) [(field1_value2, ...) ...] | FILE csv_file_path -static int32_t parseDataClause(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, STableDataCxt* pTableCxt) { +static int32_t parseDataClause(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, SRowsDataContext rowsDataCxt) { SToken token; NEXT_TOKEN(pStmt->pSql, token); switch (token.type) { case TK_VALUES: - return parseValuesClause(pCxt, pStmt, pTableCxt, &token); + return parseValuesClause(pCxt, pStmt, rowsDataCxt, &token); case TK_FILE: - return parseFileClause(pCxt, pStmt, pTableCxt, &token); + return parseFileClause(pCxt, pStmt, rowsDataCxt, &token); default: break; } return buildSyntaxErrMsg(&pCxt->msg, "keyword VALUES or FILE is expected", token.z); } +static void destroyStbRowsDataContext(SStbRowsDataContext* pStbRowsCxt) { + if (pStbRowsCxt == NULL) return; + clearStbRowsDataContext(pStbRowsCxt); + taosArrayDestroy(pStbRowsCxt->aColVals); + pStbRowsCxt->aColVals = NULL; + taosArrayDestroy(pStbRowsCxt->aTagVals); + pStbRowsCxt->aTagVals = NULL; + taosArrayDestroy(pStbRowsCxt->aTagNames); + pStbRowsCxt->aTagNames = NULL; + insDestroyBoundColInfo(&pStbRowsCxt->boundColsInfo); + tTagFree(pStbRowsCxt->pTag); + pStbRowsCxt->pTag = NULL; + taosMemoryFreeClear(pStbRowsCxt->pCtbMeta); + tdDestroySVCreateTbReq(pStbRowsCxt->pCreateCtbReq); + taosMemoryFreeClear(pStbRowsCxt->pCreateCtbReq); +} + +static int32_t constructStbRowsDataContext(SVnodeModifyOpStmt* pStmt, SStbRowsDataContext** ppStbRowsCxt) { + SStbRowsDataContext* pStbRowsCxt = taosMemoryCalloc(1, sizeof(SStbRowsDataContext)); + if (!pStbRowsCxt) { + return TSDB_CODE_OUT_OF_MEMORY; + } + tNameAssign(&pStbRowsCxt->stbName, &pStmt->targetTableName); + collectUseTable(&pStbRowsCxt->stbName, pStmt->pTableNameHashObj); + collectUseDatabase(&pStbRowsCxt->stbName, pStmt->pDbFNameHashObj); + + pStbRowsCxt->pTagCond = pStmt->pTagCond; + pStbRowsCxt->pStbMeta = pStmt->pTableMeta; + + cloneTableMeta(pStbRowsCxt->pStbMeta, &pStbRowsCxt->pCtbMeta); + pStbRowsCxt->pCtbMeta->tableType = TSDB_CHILD_TABLE; + pStbRowsCxt->pCtbMeta->suid = pStbRowsCxt->pStbMeta->uid; + + pStbRowsCxt->aTagNames = taosArrayInit(8, TSDB_COL_NAME_LEN); + pStbRowsCxt->aTagVals = taosArrayInit(8, sizeof(STagVal)); + + // col values and bound cols info of STableDataContext is not used + pStbRowsCxt->aColVals = taosArrayInit(getNumOfColumns(pStbRowsCxt->pStbMeta), sizeof(SColVal)); + insInitColValues(pStbRowsCxt->pStbMeta, pStbRowsCxt->aColVals); + + STableComInfo tblInfo = getTableInfo(pStmt->pTableMeta); + insInitBoundColsInfo(tblInfo.numOfColumns + tblInfo.numOfTags + 1, &pStbRowsCxt->boundColsInfo); + + *ppStbRowsCxt = pStbRowsCxt; + return TSDB_CODE_SUCCESS; +} + +static int32_t parseInsertStbClauseBottom(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt) { + int32_t code = TSDB_CODE_SUCCESS; + if (!pStmt->pBoundCols) { + return buildSyntaxErrMsg(&pCxt->msg, "(...tbname, ts...) bounded cols is expected for supertable insertion", pStmt->pSql); + } + + SStbRowsDataContext* pStbRowsCxt = NULL; + code = constructStbRowsDataContext(pStmt, &pStbRowsCxt); + + if (code == TSDB_CODE_SUCCESS) { + code = parseBoundColumns(pCxt, &pStmt->pBoundCols, BOUND_ALL_AND_TBNAME, pStmt->pTableMeta, + &pStbRowsCxt->boundColsInfo); + pStbRowsCxt->hasTimestampTag = false; + for (int32_t i = 0; i < pStbRowsCxt->boundColsInfo.numOfBound; ++i) { + int16_t schemaIndex = pStbRowsCxt->boundColsInfo.pColIndex[i]; + if (schemaIndex != getTbnameSchemaIndex(pStmt->pTableMeta) && schemaIndex >= getNumOfColumns(pStmt->pTableMeta) ) { + if (pStmt->pTableMeta->schema[schemaIndex].type == TSDB_DATA_TYPE_TIMESTAMP) { + pStbRowsCxt->hasTimestampTag = true; + } + if (pStmt->pTableMeta->schema[schemaIndex].type == TSDB_DATA_TYPE_JSON) { + pStbRowsCxt->isJsonTag = true; + } + } + } + pStmt->pStbRowsCxt = pStbRowsCxt; + } + + if (code == TSDB_CODE_SUCCESS) { + SRowsDataContext rowsDataCxt; + rowsDataCxt.pStbRowsCxt = pStbRowsCxt; + code = parseDataClause(pCxt, pStmt, rowsDataCxt); + } + + return code; +} + // input pStmt->pSql: // 1. [(tag1_name, ...)] ... // 2. VALUES ... | FILE ... static int32_t parseInsertTableClauseBottom(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt) { - STableDataCxt* pTableCxt = NULL; - int32_t code = parseSchemaClauseBottom(pCxt, pStmt, &pTableCxt); - if (TSDB_CODE_SUCCESS == code) { - code = parseDataClause(pCxt, pStmt, pTableCxt); + if (pStmt->stbSyntax && TSDB_QUERY_HAS_TYPE(pStmt->insertType, TSDB_QUERY_TYPE_STMT_INSERT)) { + return buildInvalidOperationMsg(&pCxt->msg, "insert into super table syntax is not supported for stmt"); + } + if (!pStmt->stbSyntax) { + STableDataCxt* pTableCxt = NULL; + int32_t code = parseSchemaClauseBottom(pCxt, pStmt, &pTableCxt); + SRowsDataContext rowsDataCxt; + rowsDataCxt.pTableDataCxt = pTableCxt; + if (TSDB_CODE_SUCCESS == code) { + code = parseDataClause(pCxt, pStmt, rowsDataCxt); + } + return code; + } else { + int32_t code = parseInsertStbClauseBottom(pCxt, pStmt); + return code; } - return code; } static void resetEnvPreTable(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt) { @@ -1777,6 +2192,10 @@ static void resetEnvPreTable(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStm pStmt->usingTableProcessing = false; pStmt->fileProcessing = false; pStmt->usingTableName.type = 0; + + destroyStbRowsDataContext(pStmt->pStbRowsCxt); + taosMemoryFreeClear(pStmt->pStbRowsCxt); + pStmt->stbSyntax = false; } // input pStmt->pSql: [(field1_name, ...)] [ USING ... ] VALUES ... | FILE ... @@ -1786,6 +2205,7 @@ static int32_t parseInsertTableClause(SInsertParseContext* pCxt, SVnodeModifyOpS if (TSDB_CODE_SUCCESS == code && !pCxt->missCache) { code = parseInsertTableClauseBottom(pCxt, pStmt); } + return code; } @@ -1901,9 +2321,11 @@ static int32_t createVnodeModifOpStmt(SInsertParseContext* pCxt, bool reentry, S TSDB_QUERY_SET_TYPE(pStmt->insertType, TSDB_QUERY_TYPE_STMT_INSERT); } pStmt->pSql = pCxt->pComCxt->pSql; + pStmt->freeHashFunc = insDestroyTableDataCxtHashMap; pStmt->freeArrayFunc = insDestroyVgroupDataCxtList; - + pStmt->freeStbRowsCxtFunc = destroyStbRowsDataContext; + if (!reentry) { pStmt->pVgroupsHashObj = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK); pStmt->pTableBlockHashObj = @@ -1952,9 +2374,9 @@ static int32_t checkAuthFromMetaData(const SArray* pUsers, SNode** pTagCond) { if (TSDB_CODE_SUCCESS == pRes->code) { SUserAuthRes* pAuth = pRes->pRes; if (NULL != pAuth->pCond) { - *pTagCond = nodesCloneNode(pAuth->pCond); + *pTagCond = nodesCloneNode(pAuth->pCond[AUTH_RES_BASIC]); } - return pAuth->pass ? TSDB_CODE_SUCCESS : TSDB_CODE_PAR_PERMISSION_DENIED; + return pAuth->pass[AUTH_RES_BASIC] ? TSDB_CODE_SUCCESS : TSDB_CODE_PAR_PERMISSION_DENIED; } return pRes->code; } @@ -1975,7 +2397,7 @@ static int32_t getTableMetaFromMetaData(const SArray* pTables, STableMeta** pMet return pRes->code; } -static int32_t getTableVgroupFromMetaData(const SArray* pTables, SVnodeModifyOpStmt* pStmt, bool isStb) { +static int32_t addTableVgroupFromMetaData(const SArray* pTables, SVnodeModifyOpStmt* pStmt, bool isStb) { if (1 != taosArrayGetSize(pTables)) { return TSDB_CODE_FAILED; } @@ -2024,20 +2446,17 @@ static int32_t checkSubtablePrivilegeForTable(const SArray* pTables, SVnodeModif return code; } -static int32_t getTableSchemaFromMetaData(SInsertParseContext* pCxt, const SMetaData* pMetaData, +static int32_t processTableSchemaFromMetaData(SInsertParseContext* pCxt, const SMetaData* pMetaData, SVnodeModifyOpStmt* pStmt, bool isStb) { - int32_t code = checkAuthFromMetaData(pMetaData->pUser, &pStmt->pTagCond); - if (TSDB_CODE_SUCCESS == code) { - code = getTableMetaFromMetaData(pMetaData->pTableMeta, &pStmt->pTableMeta); - } - if (TSDB_CODE_SUCCESS == code && !isStb && TSDB_SUPER_TABLE == pStmt->pTableMeta->tableType) { + int32_t code = TSDB_CODE_SUCCESS; + if (!isStb && TSDB_SUPER_TABLE == pStmt->pTableMeta->tableType) { code = buildInvalidOperationMsg(&pCxt->msg, "insert data into super table is not supported"); } if (TSDB_CODE_SUCCESS == code && isStb) { - code = storeTableMeta(pCxt, pStmt); + code = storeChildTableMeta(pCxt, pStmt); } if (TSDB_CODE_SUCCESS == code) { - code = getTableVgroupFromMetaData(pMetaData->pTableHash, pStmt, isStb); + code = addTableVgroupFromMetaData(pMetaData->pTableHash, pStmt, isStb); } if (TSDB_CODE_SUCCESS == code && !isStb && NULL != pStmt->pTagCond) { code = checkSubtablePrivilegeForTable(pMetaData->pTableTag, pStmt); @@ -2068,11 +2487,22 @@ static void clearCatalogReq(SCatalogReq* pCatalogReq) { static int32_t setVnodeModifOpStmt(SInsertParseContext* pCxt, SCatalogReq* pCatalogReq, const SMetaData* pMetaData, SVnodeModifyOpStmt* pStmt) { clearCatalogReq(pCatalogReq); - - if (pStmt->usingTableProcessing) { - return getTableSchemaFromMetaData(pCxt, pMetaData, pStmt, true); + int32_t code = checkAuthFromMetaData(pMetaData->pUser, &pStmt->pTagCond); + if (code == TSDB_CODE_SUCCESS) { + code = getTableMetaFromMetaData(pMetaData->pTableMeta, &pStmt->pTableMeta); } - return getTableSchemaFromMetaData(pCxt, pMetaData, pStmt, false); + if (code == TSDB_CODE_SUCCESS) { + if (pStmt->pTableMeta->tableType == TSDB_SUPER_TABLE && !pStmt->usingTableProcessing) { + pStmt->stbSyntax = true; + } + if (!pStmt->stbSyntax) { + if (pStmt->usingTableProcessing) { + return processTableSchemaFromMetaData(pCxt, pMetaData, pStmt, true); + } + return processTableSchemaFromMetaData(pCxt, pMetaData, pStmt, false); + } + } + return code; } static int32_t resetVnodeModifOpStmt(SInsertParseContext* pCxt, SQuery* pQuery) { @@ -2118,7 +2548,7 @@ static int32_t initInsertQuery(SInsertParseContext* pCxt, SCatalogReq* pCatalogR return TSDB_CODE_SUCCESS; } -static int32_t setRefreshMate(SQuery* pQuery) { +static int32_t setRefreshMeta(SQuery* pQuery) { SVnodeModifyOpStmt* pStmt = (SVnodeModifyOpStmt*)pQuery->pRoot; if (taosHashGetSize(pStmt->pTableNameHashObj) > 0) { @@ -2159,10 +2589,18 @@ static int32_t parseInsertSqlFromStart(SInsertParseContext* pCxt, SVnodeModifyOp } static int32_t parseInsertSqlFromCsv(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt) { - STableDataCxt* pTableCxt = NULL; - int32_t code = getTableDataCxt(pCxt, pStmt, &pTableCxt); + int32_t code = TSDB_CODE_SUCCESS; + SRowsDataContext rowsDataCxt; + + if (!pStmt->stbSyntax) { + STableDataCxt* pTableCxt = NULL; + code = getTableDataCxt(pCxt, pStmt, &pTableCxt); + rowsDataCxt.pTableDataCxt = pTableCxt; + } else { + rowsDataCxt.pStbRowsCxt = pStmt->pStbRowsCxt; + } if (TSDB_CODE_SUCCESS == code) { - code = parseDataFromFileImpl(pCxt, pStmt, pTableCxt); + code = parseDataFromFileImpl(pCxt, pStmt, rowsDataCxt); } if (TSDB_CODE_SUCCESS == code) { @@ -2291,7 +2729,7 @@ int32_t parseInsertSql(SParseContext* pCxt, SQuery** pQuery, SCatalogReq* pCatal } if ((TSDB_CODE_SUCCESS == code || NEED_CLIENT_HANDLE_ERROR(code)) && QUERY_EXEC_STAGE_SCHEDULE == (*pQuery)->execStage) { - code = setRefreshMate(*pQuery); + code = setRefreshMeta(*pQuery); } insDestroyBoundColInfo(&context.tags); return code; diff --git a/source/libs/parser/src/parInsertUtil.c b/source/libs/parser/src/parInsertUtil.c index 3efb5dafcb..21b093c76c 100644 --- a/source/libs/parser/src/parInsertUtil.c +++ b/source/libs/parser/src/parInsertUtil.c @@ -170,6 +170,10 @@ static void initColValues(STableMeta* pTableMeta, SArray* pValues) { } } +void insInitColValues(STableMeta* pTableMeta, SArray* aColValues) { + initColValues(pTableMeta, aColValues); +} + int32_t insInitBoundColsInfo(int32_t numOfBound, SBoundColInfo* pInfo) { pInfo->numOfCols = numOfBound; pInfo->numOfBound = numOfBound; @@ -177,7 +181,9 @@ int32_t insInitBoundColsInfo(int32_t numOfBound, SBoundColInfo* pInfo) { if (NULL == pInfo->pColIndex) { return TSDB_CODE_OUT_OF_MEMORY; } - initBoundCols(numOfBound, pInfo->pColIndex); + for (int32_t i = 0; i < numOfBound; ++i) { + pInfo->pColIndex[i] = i; + } return TSDB_CODE_SUCCESS; } @@ -202,7 +208,7 @@ void insCheckTableDataOrder(STableDataCxt* pTableCxt, TSKEY tsKey) { void insDestroyBoundColInfo(SBoundColInfo* pInfo) { taosMemoryFreeClear(pInfo->pColIndex); } static int32_t createTableDataCxt(STableMeta* pTableMeta, SVCreateTbReq** pCreateTbReq, STableDataCxt** pOutput, - bool colMode) { + bool colMode, bool ignoreColVals) { STableDataCxt* pTableCxt = taosMemoryCalloc(1, sizeof(STableDataCxt)); if (NULL == pTableCxt) { return TSDB_CODE_OUT_OF_MEMORY; @@ -228,7 +234,7 @@ static int32_t createTableDataCxt(STableMeta* pTableMeta, SVCreateTbReq** pCreat if (TSDB_CODE_SUCCESS == code) { code = insInitBoundColsInfo(pTableMeta->tableInfo.numOfColumns, &pTableCxt->boundColsInfo); } - if (TSDB_CODE_SUCCESS == code) { + if (TSDB_CODE_SUCCESS == code && !ignoreColVals) { pTableCxt->pValues = taosArrayInit(pTableMeta->tableInfo.numOfColumns, sizeof(SColVal)); if (NULL == pTableCxt->pValues) { code = TSDB_CODE_OUT_OF_MEMORY; @@ -316,14 +322,16 @@ static void resetColValues(SArray* pValues) { } int32_t insGetTableDataCxt(SHashObj* pHash, void* id, int32_t idLen, STableMeta* pTableMeta, - SVCreateTbReq** pCreateTbReq, STableDataCxt** pTableCxt, bool colMode) { + SVCreateTbReq** pCreateTbReq, STableDataCxt** pTableCxt, bool colMode, bool ignoreColVals) { STableDataCxt** tmp = (STableDataCxt**)taosHashGet(pHash, id, idLen); if (NULL != tmp) { *pTableCxt = *tmp; - resetColValues((*pTableCxt)->pValues); + if (!ignoreColVals) { + resetColValues((*pTableCxt)->pValues); + } return TSDB_CODE_SUCCESS; } - int32_t code = createTableDataCxt(pTableMeta, pCreateTbReq, pTableCxt, colMode); + int32_t code = createTableDataCxt(pTableMeta, pCreateTbReq, pTableCxt, colMode, ignoreColVals); if (TSDB_CODE_SUCCESS == code) { void* pData = *pTableCxt; // deal scan coverity code = taosHashPut(pHash, id, idLen, &pData, POINTER_BYTES); @@ -616,7 +624,7 @@ int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreate void* tmp = taosHashGet(((SVnodeModifyOpStmt*)(query->pRoot))->pTableBlockHashObj, &pTableMeta->uid, sizeof(pTableMeta->uid)); STableDataCxt* pTableCxt = NULL; int ret = insGetTableDataCxt(((SVnodeModifyOpStmt*)(query->pRoot))->pTableBlockHashObj, &pTableMeta->uid, - sizeof(pTableMeta->uid), pTableMeta, &pCreateTb, &pTableCxt, true); + sizeof(pTableMeta->uid), pTableMeta, &pCreateTb, &pTableCxt, true, false); if (ret != TSDB_CODE_SUCCESS) { uError("insGetTableDataCxt error"); goto end; diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index 7f046abc32..5193bdc47f 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -266,6 +266,8 @@ static SKeyword keywordTable[] = { {"VERBOSE", TK_VERBOSE}, {"VGROUP", TK_VGROUP}, {"VGROUPS", TK_VGROUPS}, + {"VIEW", TK_VIEW}, + {"VIEWS", TK_VIEWS}, {"VNODE", TK_VNODE}, {"VNODES", TK_VNODES}, {"WAL_FSYNC_PERIOD", TK_WAL_FSYNC_PERIOD}, diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 8572ea8c3b..0e51ebba50 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -251,6 +251,12 @@ static const SSysTableShowAdapter sysTableShowAdapter[] = { .numOfShowCols = 1, .pShowCols = {"*"} }, + { .showType = QUERY_NODE_SHOW_VIEWS_STMT, + .pDbName = TSDB_INFORMATION_SCHEMA_DB, + .pTableName = TSDB_INS_TABLE_VIEWS, + .numOfShowCols = 1, + .pShowCols = {"*"} + }, }; // clang-format on @@ -261,7 +267,7 @@ static int32_t createSimpleSelectStmtFromProjList(const char* pDb, const char* SSelectStmt** pStmt); static int32_t createLastTsSelectStmt(char* pDb, char* pTable, STableMeta* pMeta, SNode** pQuery); static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery); -static int32_t setRefreshMate(STranslateContext* pCxt, SQuery* pQuery); +static int32_t setRefreshMeta(STranslateContext* pCxt, SQuery* pQuery); static int32_t replacePsedudoColumnFuncWithColumn(STranslateContext* pCxt, SNode** ppNode); @@ -335,22 +341,67 @@ static int32_t collectUseTable(const SName* pName, SHashObj* pTable) { return taosHashPut(pTable, fullName, strlen(fullName), pName, sizeof(SName)); } -static int32_t getTableMetaImpl(STranslateContext* pCxt, const SName* pName, STableMeta** pMeta) { +static int32_t getViewMetaImpl(SParseContext* pParCxt, SParseMetaCache* pMetaCache, const SName* pName, STableMeta** pMeta) { +#ifndef TD_ENTERPRISE + return TSDB_CODE_PAR_TABLE_NOT_EXIST; +#endif + + int32_t code = TSDB_CODE_SUCCESS; + + if (pParCxt->async) { + code = getViewMetaFromCache(pMetaCache, pName, pMeta); + } else { + SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter, + .requestId = pParCxt->requestId, + .requestObjRefId = pParCxt->requestRid, + .mgmtEps = pParCxt->mgmtEpSet}; + code = catalogGetViewMeta(pParCxt->pCatalog, &conn, pName, pMeta); + } + + if (TSDB_CODE_SUCCESS != code && TSDB_CODE_PAR_TABLE_NOT_EXIST != code) { + parserError("0x%" PRIx64 " catalogGetViewMeta error, code:%s, dbName:%s, viewName:%s", pParCxt->requestId, + tstrerror(code), pName->dbname, pName->tname); + } + return code; +} + +int32_t getTargetMetaImpl(SParseContext* pParCxt, SParseMetaCache* pMetaCache, const SName* pName, STableMeta** pMeta, bool couldBeView) { + int32_t code = TSDB_CODE_SUCCESS; + + if (pParCxt->async) { + code = getTableMetaFromCache(pMetaCache, pName, pMeta); +#ifdef TD_ENTERPRISE + if ((TSDB_CODE_PAR_TABLE_NOT_EXIST == code || TSDB_CODE_PAR_INTERNAL_ERROR == code) && couldBeView) { + int32_t origCode = code; + code = getViewMetaFromCache(pMetaCache, pName, pMeta); + if (TSDB_CODE_SUCCESS != code) { + code = origCode; + } + } +#endif + } else { + SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter, + .requestId = pParCxt->requestId, + .requestObjRefId = pParCxt->requestRid, + .mgmtEps = pParCxt->mgmtEpSet}; + code = catalogGetTableMeta(pParCxt->pCatalog, &conn, pName, pMeta); + } + + if (TSDB_CODE_SUCCESS != code && TSDB_CODE_PAR_TABLE_NOT_EXIST != code) { + parserError("0x%" PRIx64 " catalogGetTableMeta error, code:%s, dbName:%s, tbName:%s", pParCxt->requestId, + tstrerror(code), pName->dbname, pName->tname); + } + return code; +} + +static int32_t getTargetMeta(STranslateContext* pCxt, const SName* pName, STableMeta** pMeta, bool couldBeView) { SParseContext* pParCxt = pCxt->pParseCxt; int32_t code = collectUseDatabase(pName, pCxt->pDbs); if (TSDB_CODE_SUCCESS == code) { code = collectUseTable(pName, pCxt->pTables); } if (TSDB_CODE_SUCCESS == code) { - if (pParCxt->async) { - code = getTableMetaFromCache(pCxt->pMetaCache, pName, pMeta); - } else { - SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter, - .requestId = pParCxt->requestId, - .requestObjRefId = pParCxt->requestRid, - .mgmtEps = pParCxt->mgmtEpSet}; - code = catalogGetTableMeta(pParCxt->pCatalog, &conn, pName, pMeta); - } + code = getTargetMetaImpl(pParCxt, pCxt->pMetaCache, pName, pMeta, couldBeView); } if (TSDB_CODE_SUCCESS != code && TSDB_CODE_PAR_TABLE_NOT_EXIST != code) { parserError("0x%" PRIx64 " catalogGetTableMeta error, code:%s, dbName:%s, tbName:%s", pCxt->pParseCxt->requestId, @@ -361,7 +412,7 @@ static int32_t getTableMetaImpl(STranslateContext* pCxt, const SName* pName, STa static int32_t getTableMeta(STranslateContext* pCxt, const char* pDbName, const char* pTableName, STableMeta** pMeta) { SName name; - return getTableMetaImpl(pCxt, toName(pCxt->pParseCxt->acctId, pDbName, pTableName, &name), pMeta); + return getTargetMeta(pCxt, toName(pCxt->pParseCxt->acctId, pDbName, pTableName, &name), pMeta, false); } static int32_t getTableCfg(STranslateContext* pCxt, const SName* pName, STableCfg** pCfg) { @@ -855,9 +906,13 @@ static void setColumnInfoByExpr(STempTableNode* pTable, SExprNode* pExpr, SColum SColumnNode* pCol = *pColRef; if (NULL == pExpr->pAssociation) { - pExpr->pAssociation = taosArrayInit(TARRAY_MIN_SIZE, POINTER_BYTES); + pExpr->pAssociation = taosArrayInit(TARRAY_MIN_SIZE, sizeof(SAssociationNode)); } - taosArrayPush(pExpr->pAssociation, &pColRef); + SAssociationNode assNode; + assNode.pPlace = (SNode**)pColRef; + assNode.pAssociationNode = (SNode*)*pColRef; + taosArrayPush(pExpr->pAssociation, &assNode); + strcpy(pCol->tableAlias, pTable->table.tableAlias); pCol->colId = isPrimaryKey(pTable, (SNode*)pExpr) ? PRIMARYKEY_TIMESTAMP_COL_ID : 0; strcpy(pCol->colName, pExpr->aliasName); @@ -2839,21 +2894,26 @@ static int32_t checkJoinTable(STranslateContext* pCxt, SJoinTableNode* pJoinTabl return TSDB_CODE_SUCCESS; } -static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) { +int32_t translateTable(STranslateContext* pCxt, SNode** pTable) { int32_t code = TSDB_CODE_SUCCESS; - switch (nodeType(pTable)) { + switch (nodeType(*pTable)) { case QUERY_NODE_REAL_TABLE: { - SRealTableNode* pRealTable = (SRealTableNode*)pTable; + SRealTableNode* pRealTable = (SRealTableNode*)*pTable; pRealTable->ratio = (NULL != pCxt->pExplainOpt ? pCxt->pExplainOpt->ratio : 1.0); // The SRealTableNode created through ROLLUP already has STableMeta. if (NULL == pRealTable->pMeta) { SName name; - code = getTableMetaImpl( + code = getTargetMeta( pCxt, toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, pRealTable->table.tableName, &name), - &(pRealTable->pMeta)); + &(pRealTable->pMeta), true); if (TSDB_CODE_SUCCESS != code) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_GET_META_ERROR, tstrerror(code)); } +#ifdef TD_ENTERPRISE + if (TSDB_VIEW_TABLE == pRealTable->pMeta->tableType) { + return translateView(pCxt, pTable, &name); + } +#endif code = setTableVgroupList(pCxt, &name, pRealTable); if (TSDB_CODE_SUCCESS == code) { code = setTableIndex(pCxt, &name, pRealTable); @@ -2878,7 +2938,7 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) { break; } case QUERY_NODE_TEMP_TABLE: { - STempTableNode* pTempTable = (STempTableNode*)pTable; + STempTableNode* pTempTable = (STempTableNode*)*pTable; code = translateSubquery(pCxt, pTempTable->pSubquery); if (TSDB_CODE_SUCCESS == code) { if (QUERY_NODE_SELECT_STMT == nodeType(pTempTable->pSubquery) && @@ -2893,10 +2953,10 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) { break; } case QUERY_NODE_JOIN_TABLE: { - SJoinTableNode* pJoinTable = (SJoinTableNode*)pTable; - code = translateTable(pCxt, pJoinTable->pLeft); + SJoinTableNode* pJoinTable = (SJoinTableNode*)*pTable; + code = translateTable(pCxt, &pJoinTable->pLeft); if (TSDB_CODE_SUCCESS == code) { - code = translateTable(pCxt, pJoinTable->pRight); + code = translateTable(pCxt, &pJoinTable->pRight); } if (TSDB_CODE_SUCCESS == code) { code = checkJoinTable(pCxt, pJoinTable); @@ -3877,7 +3937,7 @@ static int32_t translateWhere(STranslateContext* pCxt, SSelectStmt* pSelect) { return code; } -static int32_t translateFrom(STranslateContext* pCxt, SNode* pTable) { +static int32_t translateFrom(STranslateContext* pCxt, SNode** pTable) { pCxt->currClause = SQL_CLAUSE_FROM; return translateTable(pCxt, pTable); } @@ -4006,7 +4066,7 @@ static int32_t translateSelectWithoutFrom(STranslateContext* pCxt, SSelectStmt* static int32_t translateSelectFrom(STranslateContext* pCxt, SSelectStmt* pSelect) { pCxt->pCurrStmt = (SNode*)pSelect; - int32_t code = translateFrom(pCxt, pSelect->pFromTable); + int32_t code = translateFrom(pCxt, &pSelect->pFromTable); if (TSDB_CODE_SUCCESS == code) { pSelect->precision = ((STableNode*)pSelect->pFromTable)->precision; code = translateWhere(pCxt, pSelect); @@ -4232,7 +4292,7 @@ static int32_t translateDeleteWhere(STranslateContext* pCxt, SDeleteStmt* pDelet static int32_t translateDelete(STranslateContext* pCxt, SDeleteStmt* pDelete) { pCxt->pCurrStmt = (SNode*)pDelete; - int32_t code = translateFrom(pCxt, pDelete->pFromTable); + int32_t code = translateFrom(pCxt, &pDelete->pFromTable); if (TSDB_CODE_SUCCESS == code) { pDelete->precision = ((STableNode*)pDelete->pFromTable)->precision; code = translateDeleteWhere(pCxt, pDelete); @@ -4313,7 +4373,7 @@ static int32_t translateInsertProject(STranslateContext* pCxt, SInsertStmt* pIns } snprintf(pExpr->aliasName, sizeof(pExpr->aliasName), "%s", pCol->colName); if (PRIMARYKEY_TIMESTAMP_COL_ID == pCol->colId) { - pPrimaryKeyExpr = pProj; + pPrimaryKeyExpr = (SNode*)pExpr; } } @@ -4325,19 +4385,19 @@ static int32_t translateInsertProject(STranslateContext* pCxt, SInsertStmt* pIns return addOrderByPrimaryKeyToQuery(pCxt, pPrimaryKeyExpr, pInsert->pQuery); } -static int32_t translateInsertTable(STranslateContext* pCxt, SNode* pTable) { +static int32_t translateInsertTable(STranslateContext* pCxt, SNode** pTable) { int32_t code = translateFrom(pCxt, pTable); - if (TSDB_CODE_SUCCESS == code && TSDB_CHILD_TABLE != ((SRealTableNode*)pTable)->pMeta->tableType && - TSDB_NORMAL_TABLE != ((SRealTableNode*)pTable)->pMeta->tableType) { - code = generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, - "insert data into super table is not supported"); + if (TSDB_CODE_SUCCESS == code && TSDB_CHILD_TABLE != ((SRealTableNode*)*pTable)->pMeta->tableType && + TSDB_NORMAL_TABLE != ((SRealTableNode*)*pTable)->pMeta->tableType) { + code = buildInvalidOperationMsg(&pCxt->msgBuf, "insert data into super table is not supported"); + } return code; } static int32_t translateInsert(STranslateContext* pCxt, SInsertStmt* pInsert) { pCxt->pCurrStmt = (SNode*)pInsert; - int32_t code = translateInsertTable(pCxt, pInsert->pTable); + int32_t code = translateInsertTable(pCxt, &pInsert->pTable); if (TSDB_CODE_SUCCESS == code) { code = translateInsertCols(pCxt, pInsert); } @@ -6345,7 +6405,7 @@ int32_t translatePostCreateSmaIndex(SParseContext* pParseCxt, SQuery* pQuery, vo if (TSDB_CODE_SUCCESS == code) { code = setQuery(&pCxt, pQuery); } - setRefreshMate(&pCxt, pQuery); + setRefreshMeta(&pCxt, pQuery); destroyTranslateContext(&pCxt); tFreeSMCreateSmaReq(pStmt->pReq); taosMemoryFreeClear(pStmt->pReq); @@ -6583,7 +6643,7 @@ static int32_t buildQueryForTableTopic(STranslateContext* pCxt, SCreateTopicStmt .mgmtEps = pParCxt->mgmtEpSet}; SName name; STableMeta* pMeta = NULL; - int32_t code = getTableMetaImpl(pCxt, toName(pParCxt->acctId, pStmt->subDbName, pStmt->subSTbName, &name), &pMeta); + int32_t code = getTargetMeta(pCxt, toName(pParCxt->acctId, pStmt->subDbName, pStmt->subSTbName, &name), &pMeta, false); if (code) { taosMemoryFree(pMeta); return code; @@ -6687,7 +6747,41 @@ static int32_t translateExplain(STranslateContext* pCxt, SExplainStmt* pStmt) { } static int32_t translateDescribe(STranslateContext* pCxt, SDescribeStmt* pStmt) { - return refreshGetTableMeta(pCxt, pStmt->dbName, pStmt->tableName, &pStmt->pMeta); + int32_t code = refreshGetTableMeta(pCxt, pStmt->dbName, pStmt->tableName, &pStmt->pMeta); +#ifdef TD_ENTERPRISE + if (TSDB_CODE_PAR_TABLE_NOT_EXIST == code) { + int32_t origCode = code; + SName name; + toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name); + SViewMeta* pMeta = NULL; + code = getViewMetaFromMetaCache(pCxt, &name, &pMeta); + if (TSDB_CODE_SUCCESS != code) { + code = origCode; + } else { + SParseSqlRes res = {.resType = PARSE_SQL_RES_SCHEMA}; + char dbFName[TSDB_DB_FNAME_LEN]; + tNameGetFullDbName(&name, dbFName); + code = (*pCxt->pParseCxt->parseSqlFp)(pCxt->pParseCxt->parseSqlParam, name.dbname, pMeta->querySql, false, pMeta->user, &res); + if (TSDB_CODE_SUCCESS == code) { + code = collectUseTable(&name, pCxt->pTargetTables); + } + if (TSDB_CODE_SUCCESS == code) { + SViewMeta viewMeta = {0}; + viewMeta.viewId = pMeta->viewId; + viewMeta.precision = res.schemaRes.precision; + viewMeta.type = pMeta->type; + viewMeta.version = pMeta->version; + viewMeta.numOfCols = res.schemaRes.numOfCols; + viewMeta.pSchema = res.schemaRes.pSchema; + code = buildTableMetaFromViewMeta(&pStmt->pMeta, &viewMeta); + parserDebug("rebuild view meta, view:%s.%s, numOfCols:%d, code:0x%x", dbFName, pStmt->tableName, viewMeta.numOfCols, code); + } + taosMemoryFree(res.schemaRes.pSchema); + } + } +#endif + + return code; } static int32_t translateCompactRange(STranslateContext* pCxt, SCompactDatabaseStmt* pStmt, SCompactDbReq* pReq) { @@ -6762,6 +6856,26 @@ static int32_t checkCreateStream(STranslateContext* pCxt, SCreateStreamStmt* pSt return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY, "Unsupported stream query"); } +#ifdef TD_ENTERPRISE + SRealTableNode* pRealTable = (SRealTableNode*)((SSelectStmt*)pStmt->pQuery)->pFromTable; + SName name; + STableMeta* pMeta = NULL; + int8_t tableType = 0; + int32_t code = getTargetMeta( + pCxt, toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, pRealTable->table.tableName, &name), + &pMeta, true); + if (NULL != pMeta) { + tableType = pMeta->tableType; + taosMemoryFree(pMeta); + } + if (TSDB_CODE_SUCCESS != code) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_GET_META_ERROR, tstrerror(code)); + } + if (TSDB_VIEW_TABLE == tableType) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY, "Unsupported stream query"); + } +#endif + return TSDB_CODE_SUCCESS; } @@ -7564,7 +7678,7 @@ int32_t translatePostCreateStream(SParseContext* pParseCxt, SQuery* pQuery, void if (TSDB_CODE_SUCCESS == code) { code = setQuery(&cxt, pQuery); } - setRefreshMate(&cxt, pQuery); + setRefreshMeta(&cxt, pQuery); destroyTranslateContext(&cxt); tFreeSCMCreateStreamReq(pStmt->pReq); @@ -7603,6 +7717,91 @@ static int32_t translateResumeStream(STranslateContext* pCxt, SResumeStreamStmt* return buildCmdMsg(pCxt, TDMT_MND_RESUME_STREAM, (FSerializeFunc)tSerializeSMResumeStreamReq, &req); } +static int32_t validateCreateView(STranslateContext* pCxt, SCreateViewStmt* pStmt) { + if (QUERY_NODE_SELECT_STMT != nodeType(pStmt->pQuery) && QUERY_NODE_SET_OPERATOR != nodeType(pStmt->pQuery)) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_VIEW_QUERY, "Invalid view query type"); + } + +/* + STableMeta* pMetaCache = NULL; + int32_t code = getTableMeta(pCxt, pStmt->dbName, pStmt->viewName, &pMetaCache); + if (TSDB_CODE_SUCCESS == code) { + taosMemoryFreeClear(pMetaCache); + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_VIEW_CONFLICT_WITH_TABLE, "View name is conflict with table"); + } +*/ + + return TSDB_CODE_SUCCESS; +} + +static int32_t translateCreateView(STranslateContext* pCxt, SCreateViewStmt* pStmt) { +#ifndef TD_ENTERPRISE + return TSDB_CODE_OPS_NOT_SUPPORT; +#endif + + SParseSqlRes res = {.resType = PARSE_SQL_RES_SCHEMA}; + SName name; + char dbFName[TSDB_DB_FNAME_LEN]; + toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->viewName, &name); + tNameGetFullDbName(&name, dbFName); + + int32_t code = validateCreateView(pCxt, pStmt); + if (TSDB_CODE_SUCCESS == code) { + code = (*pCxt->pParseCxt->parseSqlFp)(pCxt->pParseCxt->parseSqlParam, pStmt->dbName, pStmt->pQuerySql, false, NULL, &res); + } + if (TSDB_CODE_SUCCESS == code) { + code = collectUseTable(&name, pCxt->pTargetTables); + } + if (TSDB_CODE_SUCCESS == code) { + pStmt->createReq.precision = res.schemaRes.precision; + pStmt->createReq.numOfCols = res.schemaRes.numOfCols; + pStmt->createReq.pSchema = res.schemaRes.pSchema; + strncpy(pStmt->createReq.name, pStmt->viewName, sizeof(pStmt->createReq.name) - 1); + tstrncpy(pStmt->createReq.dbFName, dbFName, sizeof(pStmt->createReq.dbFName)); + snprintf(pStmt->createReq.fullname, sizeof(pStmt->createReq.fullname) - 1, "%s.%s", pStmt->createReq.dbFName, pStmt->viewName); + TSWAP(pStmt->createReq.querySql, pStmt->pQuerySql); + pStmt->createReq.orReplace = pStmt->orReplace; + pStmt->createReq.sql = tstrdup(pCxt->pParseCxt->pSql); + if (NULL == pStmt->createReq.sql) { + code = TSDB_CODE_OUT_OF_MEMORY; + } + } + if (TSDB_CODE_SUCCESS == code) { + code = buildCmdMsg(pCxt, TDMT_MND_CREATE_VIEW, (FSerializeFunc)tSerializeSCMCreateViewReq, &pStmt->createReq); + } + + tFreeSCMCreateViewReq(&pStmt->createReq); + return code; +} + + +static int32_t translateDropView(STranslateContext* pCxt, SDropViewStmt* pStmt) { +#ifndef TD_ENTERPRISE + return TSDB_CODE_OPS_NOT_SUPPORT; +#endif + + SCMDropViewReq dropReq = {0}; + SName name; + tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName)); + tNameGetFullDbName(&name, dropReq.dbFName); + strncpy(dropReq.name, pStmt->viewName, sizeof(dropReq.name) - 1); + snprintf(dropReq.fullname, sizeof(dropReq.fullname) - 1, "%s.%s", dropReq.dbFName, dropReq.name); + dropReq.sql = (char*)pCxt->pParseCxt->pSql; + if (NULL == dropReq.sql) { + return TSDB_CODE_OUT_OF_MEMORY; + } + dropReq.igNotExists = pStmt->ignoreNotExists; + + toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->viewName, &name); + int32_t code = collectUseTable(&name, pCxt->pTargetTables); + if (TSDB_CODE_SUCCESS != code) { + return code; + } + + return buildCmdMsg(pCxt, TDMT_MND_DROP_VIEW, (FSerializeFunc)tSerializeSCMDropViewReq, &dropReq); +} + + static int32_t readFromFile(char* pName, int32_t* len, char** buf) { int64_t filesize = 0; if (taosStatFile(pName, &filesize, NULL, NULL) < 0) { @@ -7702,8 +7901,8 @@ static int32_t translateGrantTagCond(STranslateContext* pCxt, SGrantStmt* pStmt, int32_t code = createRealTableForGrantTable(pStmt, &pTable); if (TSDB_CODE_SUCCESS == code) { SName name; - code = getTableMetaImpl(pCxt, toName(pCxt->pParseCxt->acctId, pTable->table.dbName, pTable->table.tableName, &name), - &(pTable->pMeta)); + code = getTargetMeta(pCxt, toName(pCxt->pParseCxt->acctId, pTable->table.dbName, pTable->table.tableName, &name), + &(pTable->pMeta), false); if (code) { nodesDestroyNode((SNode*)pTable); return code; @@ -7737,22 +7936,32 @@ static int32_t translateGrantTagCond(STranslateContext* pCxt, SGrantStmt* pStmt, } static int32_t translateGrant(STranslateContext* pCxt, SGrantStmt* pStmt) { + int32_t code = 0; SAlterUserReq req = {0}; - if (BIT_FLAG_TEST_MASK(pStmt->privileges, PRIVILEGE_TYPE_ALL) || - (BIT_FLAG_TEST_MASK(pStmt->privileges, PRIVILEGE_TYPE_READ) && - BIT_FLAG_TEST_MASK(pStmt->privileges, PRIVILEGE_TYPE_WRITE))) { - req.alterType = ('\0' == pStmt->tabName[0] ? TSDB_ALTER_USER_ADD_ALL_DB : TSDB_ALTER_USER_ADD_ALL_TABLE); - } else if (BIT_FLAG_TEST_MASK(pStmt->privileges, PRIVILEGE_TYPE_READ)) { - req.alterType = ('\0' == pStmt->tabName[0] ? TSDB_ALTER_USER_ADD_READ_DB : TSDB_ALTER_USER_ADD_READ_TABLE); - } else if (BIT_FLAG_TEST_MASK(pStmt->privileges, PRIVILEGE_TYPE_WRITE)) { - req.alterType = ('\0' == pStmt->tabName[0] ? TSDB_ALTER_USER_ADD_WRITE_DB : TSDB_ALTER_USER_ADD_WRITE_TABLE); - } else if (BIT_FLAG_TEST_MASK(pStmt->privileges, PRIVILEGE_TYPE_SUBSCRIBE)) { - req.alterType = TSDB_ALTER_USER_ADD_SUBSCRIBE_TOPIC; + req.alterType = TSDB_ALTER_USER_ADD_PRIVILEGES; + req.privileges = pStmt->privileges; +#ifdef TD_ENTERPRISE + if (0 != pStmt->tabName[0]) { + SName name; + STableMeta* pTableMeta = NULL; + code = getTargetMeta(pCxt, toName(pCxt->pParseCxt->acctId, pStmt->objName, pStmt->tabName, &name), &pTableMeta, true); + if (TSDB_CODE_SUCCESS != code) { + if (TSDB_CODE_PAR_TABLE_NOT_EXIST != code) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_GET_META_ERROR, tstrerror(code)); + } + } else if (TSDB_VIEW_TABLE == pTableMeta->tableType) { + req.isView = true; + } + taosMemoryFree(pTableMeta); } +#endif + strcpy(req.user, pStmt->userName); sprintf(req.objname, "%d.%s", pCxt->pParseCxt->acctId, pStmt->objName); sprintf(req.tabName, "%s", pStmt->tabName); - int32_t code = translateGrantTagCond(pCxt, pStmt, &req); + if (!req.isView) { + code = translateGrantTagCond(pCxt, pStmt, &req); + } if (TSDB_CODE_SUCCESS == code) { code = buildCmdMsg(pCxt, TDMT_MND_ALTER_USER, (FSerializeFunc)tSerializeSAlterUserReq, &req); } @@ -7761,22 +7970,31 @@ static int32_t translateGrant(STranslateContext* pCxt, SGrantStmt* pStmt) { } static int32_t translateRevoke(STranslateContext* pCxt, SRevokeStmt* pStmt) { + int32_t code = 0; SAlterUserReq req = {0}; - if (BIT_FLAG_TEST_MASK(pStmt->privileges, PRIVILEGE_TYPE_ALL) || - (BIT_FLAG_TEST_MASK(pStmt->privileges, PRIVILEGE_TYPE_READ) && - BIT_FLAG_TEST_MASK(pStmt->privileges, PRIVILEGE_TYPE_WRITE))) { - req.alterType = ('\0' == pStmt->tabName[0] ? TSDB_ALTER_USER_REMOVE_ALL_DB : TSDB_ALTER_USER_REMOVE_ALL_TABLE); - } else if (BIT_FLAG_TEST_MASK(pStmt->privileges, PRIVILEGE_TYPE_READ)) { - req.alterType = ('\0' == pStmt->tabName[0] ? TSDB_ALTER_USER_REMOVE_READ_DB : TSDB_ALTER_USER_REMOVE_READ_TABLE); - } else if (BIT_FLAG_TEST_MASK(pStmt->privileges, PRIVILEGE_TYPE_WRITE)) { - req.alterType = ('\0' == pStmt->tabName[0] ? TSDB_ALTER_USER_REMOVE_WRITE_DB : TSDB_ALTER_USER_REMOVE_WRITE_TABLE); - } else if (BIT_FLAG_TEST_MASK(pStmt->privileges, PRIVILEGE_TYPE_SUBSCRIBE)) { - req.alterType = TSDB_ALTER_USER_REMOVE_SUBSCRIBE_TOPIC; + req.alterType = TSDB_ALTER_USER_DEL_PRIVILEGES; + req.privileges = pStmt->privileges; + +#ifdef TD_ENTERPRISE + if (0 != pStmt->tabName[0]) { + SName name; + STableMeta* pTableMeta = NULL; + code = getTargetMeta(pCxt, toName(pCxt->pParseCxt->acctId, pStmt->objName, pStmt->tabName, &name), &pTableMeta, true); + if (TSDB_CODE_SUCCESS != code) { + if (TSDB_CODE_PAR_TABLE_NOT_EXIST != code) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_GET_META_ERROR, tstrerror(code)); + } + } else if (TSDB_VIEW_TABLE == pTableMeta->tableType) { + req.isView = true; + } + taosMemoryFree(pTableMeta); } +#endif + strcpy(req.user, pStmt->userName); sprintf(req.objname, "%d.%s", pCxt->pParseCxt->acctId, pStmt->objName); sprintf(req.tabName, "%s", pStmt->tabName); - int32_t code = buildCmdMsg(pCxt, TDMT_MND_ALTER_USER, (FSerializeFunc)tSerializeSAlterUserReq, &req); + code = buildCmdMsg(pCxt, TDMT_MND_ALTER_USER, (FSerializeFunc)tSerializeSAlterUserReq, &req); tFreeSAlterUserReq(&req); return code; } @@ -7878,6 +8096,16 @@ static int32_t translateShowCreateTable(STranslateContext* pCxt, SShowCreateTabl return code; } +static int32_t translateShowCreateView(STranslateContext* pCxt, SShowCreateViewStmt* pStmt) { +#ifndef TD_ENTERPRISE + return TSDB_CODE_OPS_NOT_SUPPORT; +#else + SName name; + toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->viewName, &name); + return getViewMetaFromMetaCache(pCxt, &name, (SViewMeta**)&pStmt->pViewMeta); +#endif +} + static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { int32_t code = TSDB_CODE_SUCCESS; switch (nodeType(pNode)) { @@ -8036,12 +8264,22 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { case QUERY_NODE_SHOW_CREATE_STABLE_STMT: code = translateShowCreateTable(pCxt, (SShowCreateTableStmt*)pNode); break; + case QUERY_NODE_SHOW_CREATE_VIEW_STMT: + code = translateShowCreateView(pCxt, (SShowCreateViewStmt*)pNode); + break; case QUERY_NODE_RESTORE_DNODE_STMT: case QUERY_NODE_RESTORE_QNODE_STMT: case QUERY_NODE_RESTORE_MNODE_STMT: case QUERY_NODE_RESTORE_VNODE_STMT: code = translateRestoreDnode(pCxt, (SRestoreComponentNodeStmt*)pNode); break; + case QUERY_NODE_CREATE_VIEW_STMT: + code = translateCreateView(pCxt, (SCreateViewStmt*)pNode); + break; + case QUERY_NODE_DROP_VIEW_STMT: + code = translateDropView(pCxt, (SDropViewStmt*)pNode); + break; + default: break; } @@ -8073,7 +8311,7 @@ static int32_t extractQueryResultSchema(const SNodeList* pProjections, int32_t* SExprNode* pExpr = (SExprNode*)pNode; if (TSDB_DATA_TYPE_NULL == pExpr->resType.type) { (*pSchema)[index].type = TSDB_DATA_TYPE_VARCHAR; - (*pSchema)[index].bytes = 0; + (*pSchema)[index].bytes = VARSTR_HEADER_SIZE; } else { (*pSchema)[index].type = pExpr->resType.type; (*pSchema)[index].bytes = pExpr->resType.bytes; @@ -8180,6 +8418,25 @@ static int32_t extractShowCreateTableResultSchema(int32_t* numOfCols, SSchema** return TSDB_CODE_SUCCESS; } +static int32_t extractShowCreateViewResultSchema(int32_t* numOfCols, SSchema** pSchema) { + *numOfCols = SHOW_CREATE_VIEW_RESULT_COLS; + *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); + if (NULL == (*pSchema)) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + (*pSchema)[0].type = TSDB_DATA_TYPE_BINARY; + (*pSchema)[0].bytes = SHOW_CREATE_VIEW_RESULT_FIELD1_LEN; + strcpy((*pSchema)[0].name, "View"); + + (*pSchema)[1].type = TSDB_DATA_TYPE_BINARY; + (*pSchema)[1].bytes = SHOW_CREATE_VIEW_RESULT_FIELD2_LEN; + strcpy((*pSchema)[1].name, "Create View"); + + return TSDB_CODE_SUCCESS; +} + + static int32_t extractShowVariablesResultSchema(int32_t* numOfCols, SSchema** pSchema) { *numOfCols = 3; *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); @@ -8223,6 +8480,8 @@ int32_t extractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pS case QUERY_NODE_SHOW_CREATE_TABLE_STMT: case QUERY_NODE_SHOW_CREATE_STABLE_STMT: return extractShowCreateTableResultSchema(numOfCols, pSchema); + case QUERY_NODE_SHOW_CREATE_VIEW_STMT: + return extractShowCreateViewResultSchema(numOfCols, pSchema); case QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT: case QUERY_NODE_SHOW_VARIABLES_STMT: return extractShowVariablesResultSchema(numOfCols, pSchema); @@ -9201,7 +9460,7 @@ static int32_t buildDropTableVgroupHashmap(STranslateContext* pCxt, SDropTableCl SName name; toName(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, &name); STableMeta* pTableMeta = NULL; - int32_t code = getTableMetaImpl(pCxt, &name, &pTableMeta); + int32_t code = getTargetMeta(pCxt, &name, &pTableMeta, false); if (TSDB_CODE_SUCCESS == code) { code = collectUseTable(&name, pCxt->pTargetTables); } @@ -9734,6 +9993,7 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) { case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT: case QUERY_NODE_SHOW_TAGS_STMT: case QUERY_NODE_SHOW_USER_PRIVILEGES_STMT: + case QUERY_NODE_SHOW_VIEWS_STMT: code = rewriteShow(pCxt, pQuery); break; case QUERY_NODE_SHOW_VGROUPS_STMT: @@ -9788,7 +10048,7 @@ static int32_t toMsgType(ENodeType type) { return TDMT_VND_CREATE_TABLE; } -static int32_t setRefreshMate(STranslateContext* pCxt, SQuery* pQuery) { +static int32_t setRefreshMeta(STranslateContext* pCxt, SQuery* pQuery) { if (NULL != pCxt->pDbs) { taosArrayDestroy(pQuery->pDbList); pQuery->pDbList = taosArrayInit(taosHashGetSize(pCxt->pDbs), TSDB_DB_FNAME_LEN); @@ -9863,6 +10123,7 @@ static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) { case QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT: case QUERY_NODE_SHOW_CREATE_TABLE_STMT: case QUERY_NODE_SHOW_CREATE_STABLE_STMT: + case QUERY_NODE_SHOW_CREATE_VIEW_STMT: case QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT: pQuery->execMode = QUERY_EXEC_MODE_LOCAL; pQuery->haveResultSet = true; @@ -9922,7 +10183,7 @@ int32_t translate(SParseContext* pParseCxt, SQuery* pQuery, SParseMetaCache* pMe if (TSDB_CODE_SUCCESS == code) { code = setQuery(&cxt, pQuery); } - setRefreshMate(&cxt, pQuery); + setRefreshMeta(&cxt, pQuery); destroyTranslateContext(&cxt); return code; } diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index 825e02f9aa..26e6111074 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -521,9 +521,9 @@ int32_t getVnodeSysTableTargetName(int32_t acctId, SNode* pWhere, SName* pName) } static int32_t userAuthToString(int32_t acctId, const char* pUser, const char* pDb, const char* pTable, AUTH_TYPE type, - char* pStr) { - return sprintf(pStr, "%s*%d*%s*%s*%d", pUser, acctId, pDb, (NULL == pTable || '\0' == pTable[0]) ? "``" : pTable, - type); + char* pStr, bool isView) { + return sprintf(pStr, "%s*%d*%s*%s*%d*%d", pUser, acctId, pDb, (NULL == pTable || '\0' == pTable[0]) ? "``" : pTable, + type, isView); } static int32_t getIntegerFromAuthStr(const char* pStart, char** pNext) { @@ -565,6 +565,7 @@ static void stringToUserAuth(const char* pStr, int32_t len, SUserAuthInfo* pUser pUserAuth->tbName.type = TSDB_DB_NAME_T; } pUserAuth->type = getIntegerFromAuthStr(p, &p); + pUserAuth->isView = getIntegerFromAuthStr(p, &p); } static int32_t buildTableReq(SHashObj* pTablesHash, SArray** pTables) { @@ -693,6 +694,11 @@ int32_t buildCatalogReq(const SParseMetaCache* pMetaCache, SCatalogReq* pCatalog if (TSDB_CODE_SUCCESS == code) { code = buildTableReq(pMetaCache->pTableCfg, &pCatalogReq->pTableCfg); } +#ifdef TD_ENTERPRISE + if (TSDB_CODE_SUCCESS == code) { + code = buildTableReqFromDb(pMetaCache->pTableMeta, &pCatalogReq->pView); + } +#endif pCatalogReq->dNodeRequired = pMetaCache->dnodeRequired; return code; } @@ -716,7 +722,7 @@ SNode* createSelectStmtImpl(bool isDistinct, SNodeList* pProjectionList, SNode* static int32_t putMetaDataToHash(const char* pKey, int32_t len, const SArray* pData, int32_t index, SHashObj** pHash) { if (NULL == *pHash) { - *pHash = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); + *pHash = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); if (NULL == *pHash) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -725,7 +731,7 @@ static int32_t putMetaDataToHash(const char* pKey, int32_t len, const SArray* pD return taosHashPut(*pHash, pKey, len, &pRes, POINTER_BYTES); } -static int32_t getMetaDataFromHash(const char* pKey, int32_t len, SHashObj* pHash, void** pOutput) { +int32_t getMetaDataFromHash(const char* pKey, int32_t len, SHashObj* pHash, void** pOutput) { SMetaRes** pRes = taosHashGet(pHash, pKey, len); if (NULL == pRes || NULL == *pRes) { return TSDB_CODE_PAR_INTERNAL_ERROR; @@ -783,7 +789,7 @@ static int32_t putUserAuthToCache(const SArray* pUserAuthReq, const SArray* pUse SUserAuthInfo* pUser = taosArrayGet(pUserAuthReq, i); char key[USER_AUTH_KEY_MAX_LEN] = {0}; int32_t len = userAuthToString(pUser->tbName.acctId, pUser->user, pUser->tbName.dbname, pUser->tbName.tname, - pUser->type, key); + pUser->type, key, pUser->isView); if (TSDB_CODE_SUCCESS != putMetaDataToHash(key, len, pUserAuthData, i, pUserAuth)) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -828,6 +834,11 @@ int32_t putMetaDataToCache(const SCatalogReq* pCatalogReq, const SMetaData* pMet if (TSDB_CODE_SUCCESS == code) { code = putTableDataToCache(pCatalogReq->pTableCfg, pMetaData->pTableCfg, &pMetaCache->pTableCfg); } +#ifdef TD_ENTERPRISE + if (TSDB_CODE_SUCCESS == code) { + code = putDbTableDataToCache(pCatalogReq->pView, pMetaData->pView, &pMetaCache->pViews); + } +#endif pMetaCache->pDnodes = pMetaData->pDnodeList; return code; } @@ -896,6 +907,38 @@ int32_t getTableMetaFromCache(SParseMetaCache* pMetaCache, const SName* pName, S return code; } +int32_t buildTableMetaFromViewMeta(STableMeta** pMeta, SViewMeta* pViewMeta) { + *pMeta = taosMemoryCalloc(1, sizeof(STableMeta) + pViewMeta->numOfCols * sizeof(SSchema)); + if (NULL == *pMeta) { + return TSDB_CODE_OUT_OF_MEMORY; + } + (*pMeta)->uid = pViewMeta->viewId; + (*pMeta)->vgId = MNODE_HANDLE; + (*pMeta)->tableType = TSDB_VIEW_TABLE; + (*pMeta)->sversion = pViewMeta->version; + (*pMeta)->tversion = pViewMeta->version; + (*pMeta)->tableInfo.precision = pViewMeta->precision; + (*pMeta)->tableInfo.numOfColumns = pViewMeta->numOfCols; + memcpy((*pMeta)->schema, pViewMeta->pSchema, sizeof(SSchema) * pViewMeta->numOfCols); + + for (int32_t i = 0; i < pViewMeta->numOfCols; ++i) { + (*pMeta)->tableInfo.rowSize += (*pMeta)->schema[i].bytes; + } + return TSDB_CODE_SUCCESS; +} + +int32_t getViewMetaFromCache(SParseMetaCache* pMetaCache, const SName* pName, STableMeta** pMeta) { + char fullName[TSDB_TABLE_FNAME_LEN]; + tNameExtractFullName(pName, fullName); + SViewMeta* pViewMeta = NULL; + int32_t code = getMetaDataFromHash(fullName, strlen(fullName), pMetaCache->pViews, (void**)&pViewMeta); + if (TSDB_CODE_SUCCESS == code) { + code = buildTableMetaFromViewMeta(pMeta, pViewMeta); + } + return code; +} + + static int32_t reserveDbReqInCache(int32_t acctId, const char* pDb, SHashObj** pDbs) { if (NULL == *pDbs) { *pDbs = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); @@ -987,14 +1030,23 @@ static int32_t reserveUserAuthInCacheImpl(const char* pKey, int32_t len, SParseM int32_t reserveUserAuthInCache(int32_t acctId, const char* pUser, const char* pDb, const char* pTable, AUTH_TYPE type, SParseMetaCache* pMetaCache) { char key[USER_AUTH_KEY_MAX_LEN] = {0}; - int32_t len = userAuthToString(acctId, pUser, pDb, pTable, type, key); + int32_t len = userAuthToString(acctId, pUser, pDb, pTable, type, key, false); return reserveUserAuthInCacheImpl(key, len, pMetaCache); } +int32_t reserveViewUserAuthInCache(int32_t acctId, const char* pUser, const char* pDb, const char* pTable, AUTH_TYPE type, + SParseMetaCache* pMetaCache) { + char key[USER_AUTH_KEY_MAX_LEN] = {0}; + int32_t len = userAuthToString(acctId, pUser, pDb, pTable, type, key, true); + return reserveUserAuthInCacheImpl(key, len, pMetaCache); +} + + + int32_t getUserAuthFromCache(SParseMetaCache* pMetaCache, SUserAuthInfo* pAuthReq, SUserAuthRes* pAuthRes) { char key[USER_AUTH_KEY_MAX_LEN] = {0}; int32_t len = userAuthToString(pAuthReq->tbName.acctId, pAuthReq->user, pAuthReq->tbName.dbname, - pAuthReq->tbName.tname, pAuthReq->type, key); + pAuthReq->tbName.tname, pAuthReq->type, key, pAuthReq->isView); SUserAuthRes* pAuth = NULL; int32_t code = getMetaDataFromHash(key, len, pMetaCache->pUserAuth, (void**)&pAuth); if (TSDB_CODE_SUCCESS == code) { @@ -1137,9 +1189,11 @@ void destoryParseMetaCache(SParseMetaCache* pMetaCache, bool request) { if (request) { destoryParseTablesMetaReqHash(pMetaCache->pTableMeta); destoryParseTablesMetaReqHash(pMetaCache->pTableVgroup); + destoryParseTablesMetaReqHash(pMetaCache->pViews); } else { taosHashCleanup(pMetaCache->pTableMeta); taosHashCleanup(pMetaCache->pTableVgroup); + taosHashCleanup(pMetaCache->pViews); } taosHashCleanup(pMetaCache->pDbVgroup); taosHashCleanup(pMetaCache->pDbCfg); diff --git a/source/libs/parser/src/parser.c b/source/libs/parser/src/parser.c index 4034597eed..1fa4c624a7 100644 --- a/source/libs/parser/src/parser.c +++ b/source/libs/parser/src/parser.c @@ -51,6 +51,10 @@ bool qIsInsertValuesSql(const char* pStr, size_t length) { static int32_t analyseSemantic(SParseContext* pCxt, SQuery* pQuery, SParseMetaCache* pMetaCache) { int32_t code = authenticate(pCxt, pQuery, pMetaCache); + if (pCxt->parseOnly) { + return code; + } + if (TSDB_CODE_SUCCESS == code && pQuery->placeholderNum > 0) { TSWAP(pQuery->pPrepareRoot, pQuery->pRoot); return TSDB_CODE_SUCCESS; @@ -244,11 +248,58 @@ int32_t qContinueParsePostQuery(SParseContext* pCxt, SQuery* pQuery, void** pRes return code; } + +static void destoryTablesReq(void *p) { + STablesReq *pRes = (STablesReq *)p; + taosArrayDestroy(pRes->pTables); +} + +void destoryCatalogReq(SCatalogReq *pCatalogReq) { + if (NULL == pCatalogReq) { + return; + } + taosArrayDestroy(pCatalogReq->pDbVgroup); + taosArrayDestroy(pCatalogReq->pDbCfg); + taosArrayDestroy(pCatalogReq->pDbInfo); + if (pCatalogReq->cloned) { + taosArrayDestroy(pCatalogReq->pTableMeta); + taosArrayDestroy(pCatalogReq->pTableHash); +#ifdef TD_ENTERPRISE + taosArrayDestroy(pCatalogReq->pView); +#endif + } else { + taosArrayDestroyEx(pCatalogReq->pTableMeta, destoryTablesReq); + taosArrayDestroyEx(pCatalogReq->pTableHash, destoryTablesReq); +#ifdef TD_ENTERPRISE + taosArrayDestroyEx(pCatalogReq->pView, destoryTablesReq); +#endif + } + taosArrayDestroy(pCatalogReq->pUdf); + taosArrayDestroy(pCatalogReq->pIndex); + taosArrayDestroy(pCatalogReq->pUser); + taosArrayDestroy(pCatalogReq->pTableIndex); + taosArrayDestroy(pCatalogReq->pTableCfg); + taosArrayDestroy(pCatalogReq->pTableTag); +} + + +void tfreeSParseQueryRes(void* p) { + if (NULL == p) { + return; + } + + SParseQueryRes* pRes = p; + destoryCatalogReq(pRes->pCatalogReq); + taosMemoryFree(pRes->pCatalogReq); + catalogFreeMetaData(&pRes->meta); +} + void qDestroyParseContext(SParseContext* pCxt) { if (NULL == pCxt) { return; } + taosArrayDestroyEx(pCxt->pSubMetaList, tfreeSParseQueryRes); taosArrayDestroy(pCxt->pTableMetaPos); taosArrayDestroy(pCxt->pTableVgroupPos); taosMemoryFree(pCxt); diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index a4958c3e80..f012b90941 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -1,5 +1,3 @@ -/* This file is automatically generated by Lemon from input grammar -** source file "sql.y". */ /* ** 2000-05-29 ** @@ -106,29 +104,29 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 504 +#define YYNOCODE 507 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - EShowKind yy33; - EJoinType yy36; - SNode* yy56; - SShowTablesOption yy205; - int8_t yy215; - int64_t yy333; - ENullOrder yy361; - EOperatorType yy380; - bool yy425; - SDataType yy448; - int32_t yy676; - SNodeList* yy712; - EOrder yy722; - EFillMode yy774; - STokenPair yy777; + EFillMode yy36; + SNode* yy80; + SNodeList* yy106; + SDataType yy292; + EOperatorType yy428; + int8_t yy431; + SAlterOption yy455; + EShowKind yy459; + STokenPair yy573; + SShowTablesOption yy709; + ENullOrder yy763; SToken yy785; - SAlterOption yy893; + EOrder yy812; + EJoinType yy828; + bool yy923; + int32_t yy982; + int64_t yy987; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -144,18 +142,18 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 822 -#define YYNRULE 631 -#define YYNRULE_WITH_ACTION 631 -#define YYNTOKEN 345 -#define YY_MAX_SHIFT 821 -#define YY_MIN_SHIFTREDUCE 1220 -#define YY_MAX_SHIFTREDUCE 1850 -#define YY_ERROR_ACTION 1851 -#define YY_ACCEPT_ACTION 1852 -#define YY_NO_ACTION 1853 -#define YY_MIN_REDUCE 1854 -#define YY_MAX_REDUCE 2484 +#define YYNSTATE 835 +#define YYNRULE 639 +#define YYNRULE_WITH_ACTION 639 +#define YYNTOKEN 346 +#define YY_MAX_SHIFT 834 +#define YY_MIN_SHIFTREDUCE 1237 +#define YY_MAX_SHIFTREDUCE 1875 +#define YY_ERROR_ACTION 1876 +#define YY_ACCEPT_ACTION 1877 +#define YY_NO_ACTION 1878 +#define YY_MIN_REDUCE 1879 +#define YY_MAX_REDUCE 2517 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -222,985 +220,895 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (3640) +#define YY_ACTTAB_COUNT (3178) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 2094, 707, 2041, 674, 2030, 2460, 2455, 548, 2455, 2026, - /* 10 */ 549, 1897, 48, 46, 1774, 693, 2460, 668, 412, 2455, - /* 20 */ 409, 133, 1616, 1855, 673, 198, 164, 2459, 590, 2456, - /* 30 */ 675, 2456, 2458, 391, 2043, 1700, 1937, 1614, 2459, 38, - /* 40 */ 314, 2092, 2456, 2457, 123, 2304, 2286, 122, 121, 120, - /* 50 */ 119, 118, 117, 116, 115, 114, 686, 142, 1641, 689, - /* 60 */ 1643, 41, 40, 155, 1695, 47, 45, 44, 43, 42, - /* 70 */ 19, 707, 2041, 1852, 170, 123, 1866, 1622, 122, 121, - /* 80 */ 120, 119, 118, 117, 116, 115, 114, 2304, 41, 40, - /* 90 */ 67, 133, 47, 45, 44, 43, 42, 1877, 595, 2253, - /* 100 */ 1644, 723, 706, 818, 667, 706, 15, 319, 793, 792, - /* 110 */ 791, 790, 421, 1641, 789, 788, 147, 783, 782, 781, - /* 120 */ 780, 779, 778, 777, 146, 771, 770, 769, 420, 419, - /* 130 */ 766, 765, 764, 179, 178, 763, 556, 55, 2285, 549, - /* 140 */ 1897, 2323, 1702, 1703, 110, 2287, 727, 2289, 2290, 722, - /* 150 */ 2253, 717, 424, 686, 142, 706, 181, 423, 2376, 180, - /* 160 */ 1816, 2172, 405, 2372, 294, 2384, 685, 2460, 134, 684, - /* 170 */ 169, 2455, 463, 563, 1675, 1685, 402, 200, 1980, 2169, - /* 180 */ 694, 1701, 1704, 2153, 1643, 2406, 2094, 625, 51, 673, - /* 190 */ 198, 51, 62, 390, 2456, 675, 1617, 669, 1615, 62, - /* 200 */ 649, 2092, 623, 2455, 621, 263, 262, 41, 40, 62, - /* 210 */ 62, 47, 45, 44, 43, 42, 296, 515, 513, 1364, - /* 220 */ 361, 2461, 198, 267, 212, 1778, 2456, 675, 1620, 1621, - /* 230 */ 1672, 1641, 1674, 1677, 1678, 1679, 1680, 1681, 1682, 1683, - /* 240 */ 1684, 719, 715, 1693, 1694, 1696, 1697, 1698, 1699, 2, - /* 250 */ 48, 46, 1854, 686, 142, 360, 194, 1639, 409, 1366, - /* 260 */ 1616, 197, 2384, 2385, 500, 140, 2389, 518, 553, 369, - /* 270 */ 218, 1840, 517, 1700, 550, 1614, 132, 131, 130, 129, - /* 280 */ 128, 127, 126, 125, 124, 609, 608, 607, 483, 567, - /* 290 */ 519, 1260, 599, 139, 603, 485, 1585, 1586, 602, 454, - /* 300 */ 634, 453, 1695, 601, 606, 385, 384, 2018, 19, 600, - /* 310 */ 1645, 88, 596, 1729, 87, 1622, 47, 45, 44, 43, - /* 320 */ 42, 41, 40, 2286, 75, 47, 45, 44, 43, 42, - /* 330 */ 2216, 452, 52, 1262, 1265, 1266, 724, 664, 1906, 232, - /* 340 */ 296, 818, 378, 551, 15, 1904, 418, 417, 298, 2172, - /* 350 */ 41, 40, 298, 471, 47, 45, 44, 43, 42, 298, - /* 360 */ 688, 196, 2384, 2385, 2304, 140, 2389, 2170, 694, 298, - /* 370 */ 298, 1623, 1730, 234, 86, 30, 2253, 551, 723, 1904, - /* 380 */ 1702, 1703, 268, 2159, 2138, 1676, 507, 506, 505, 504, - /* 390 */ 499, 498, 497, 496, 495, 491, 490, 489, 488, 359, - /* 400 */ 480, 479, 478, 1644, 473, 472, 376, 1672, 1508, 1509, - /* 410 */ 1268, 1710, 1675, 1685, 1527, 2285, 1640, 1641, 2323, 1701, - /* 420 */ 1704, 110, 2287, 727, 2289, 2290, 722, 1641, 717, 670, - /* 430 */ 665, 658, 762, 2475, 1617, 2376, 1615, 383, 382, 405, - /* 440 */ 2372, 1673, 760, 157, 156, 757, 756, 755, 154, 1817, - /* 450 */ 2286, 1642, 37, 407, 1724, 1725, 1726, 1727, 1728, 1732, - /* 460 */ 1733, 1734, 1735, 724, 12, 1876, 1620, 1621, 1672, 2246, - /* 470 */ 1674, 1677, 1678, 1679, 1680, 1681, 1682, 1683, 1684, 719, - /* 480 */ 715, 1693, 1694, 1696, 1697, 1698, 1699, 2, 12, 48, - /* 490 */ 46, 2304, 298, 92, 1642, 192, 1285, 409, 1284, 1616, - /* 500 */ 1285, 1847, 1284, 2253, 773, 723, 1875, 2081, 381, 380, - /* 510 */ 379, 592, 1700, 138, 1614, 34, 597, 649, 2253, 2036, - /* 520 */ 2455, 41, 40, 2286, 1731, 47, 45, 44, 43, 42, - /* 530 */ 92, 1286, 1626, 594, 1644, 1286, 689, 593, 2461, 198, - /* 540 */ 1361, 1695, 2285, 2456, 675, 2323, 564, 19, 110, 2287, - /* 550 */ 727, 2289, 2290, 722, 1622, 717, 2037, 1805, 145, 2253, - /* 560 */ 152, 2347, 2376, 1622, 2304, 2017, 405, 2372, 775, 509, - /* 570 */ 1421, 1676, 776, 1456, 1457, 2002, 2253, 1874, 723, 1873, - /* 580 */ 818, 1520, 1521, 15, 1412, 752, 751, 750, 1416, 749, - /* 590 */ 1418, 1419, 748, 745, 1872, 1427, 742, 1429, 1430, 739, - /* 600 */ 736, 733, 565, 2165, 35, 1846, 661, 660, 1803, 1804, - /* 610 */ 1806, 1807, 1808, 1645, 1736, 2285, 1540, 1541, 2323, 1702, - /* 620 */ 1703, 110, 2287, 727, 2289, 2290, 722, 1673, 717, 2028, - /* 630 */ 2253, 222, 2253, 181, 762, 2376, 753, 41, 40, 405, - /* 640 */ 2372, 47, 45, 44, 43, 42, 414, 2253, 180, 2087, - /* 650 */ 2089, 1675, 1685, 508, 36, 1539, 1542, 598, 1701, 1704, - /* 660 */ 41, 40, 2407, 2094, 47, 45, 44, 43, 42, 249, - /* 670 */ 377, 2024, 2152, 1617, 1940, 1615, 1376, 2094, 702, 707, - /* 680 */ 2041, 1359, 707, 2041, 375, 174, 686, 142, 1871, 545, - /* 690 */ 189, 1375, 2092, 584, 580, 576, 572, 543, 248, 203, - /* 700 */ 539, 535, 56, 1870, 266, 1620, 1621, 1672, 265, 1674, - /* 710 */ 1677, 1678, 1679, 1680, 1681, 1682, 1683, 1684, 719, 715, - /* 720 */ 1693, 1694, 1696, 1697, 1698, 1699, 2, 48, 46, 1705, - /* 730 */ 2286, 707, 2041, 102, 1616, 409, 1790, 1616, 1869, 93, - /* 740 */ 1868, 2253, 246, 724, 1645, 2414, 609, 608, 607, 1614, - /* 750 */ 1700, 460, 1614, 599, 139, 603, 2253, 520, 2034, 602, - /* 760 */ 674, 2286, 2094, 2455, 601, 606, 385, 384, 2019, 399, - /* 770 */ 600, 2304, 95, 596, 724, 364, 2427, 2092, 389, 1695, - /* 780 */ 627, 673, 198, 2253, 1865, 723, 2456, 675, 12, 1622, - /* 790 */ 10, 2253, 1622, 2253, 199, 2384, 2385, 1864, 140, 2389, - /* 800 */ 456, 148, 2304, 41, 40, 455, 2045, 47, 45, 44, - /* 810 */ 43, 42, 245, 238, 2253, 818, 723, 273, 818, 243, - /* 820 */ 561, 49, 2285, 707, 2041, 2323, 2286, 1863, 110, 2287, - /* 830 */ 727, 2289, 2290, 722, 1380, 717, 403, 2253, 236, 721, - /* 840 */ 2475, 2263, 2376, 461, 167, 276, 405, 2372, 649, 1379, - /* 850 */ 2253, 2455, 2043, 2285, 1644, 2032, 2323, 1702, 1703, 110, - /* 860 */ 2287, 727, 2289, 2290, 722, 2267, 717, 2304, 412, 2461, - /* 870 */ 198, 2475, 155, 2376, 2456, 675, 167, 405, 2372, 2253, - /* 880 */ 2253, 723, 1641, 2391, 2043, 1862, 648, 41, 40, 1675, - /* 890 */ 1685, 47, 45, 44, 43, 42, 1701, 1704, 2016, 760, - /* 900 */ 157, 156, 757, 756, 755, 154, 718, 2269, 1617, 2388, - /* 910 */ 1615, 1617, 1981, 1615, 709, 522, 2348, 717, 2285, 707, - /* 920 */ 2041, 2323, 707, 2041, 350, 2287, 727, 2289, 2290, 722, - /* 930 */ 720, 717, 708, 2341, 2459, 469, 2148, 2125, 2253, 477, - /* 940 */ 1620, 1621, 492, 1620, 1621, 1672, 1580, 1674, 1677, 1678, - /* 950 */ 1679, 1680, 1681, 1682, 1683, 1684, 719, 715, 1693, 1694, - /* 960 */ 1696, 1697, 1698, 1699, 2, 48, 46, 1797, 2286, 707, - /* 970 */ 2041, 614, 2094, 409, 1867, 1616, 2247, 415, 632, 404, - /* 980 */ 2094, 724, 1798, 656, 214, 167, 626, 2092, 1700, 493, - /* 990 */ 1614, 1861, 2094, 2043, 108, 2093, 707, 2041, 1641, 413, - /* 1000 */ 475, 2148, 264, 305, 306, 502, 2148, 2092, 304, 2304, - /* 1010 */ 193, 143, 60, 444, 2088, 2089, 566, 1695, 617, 2033, - /* 1020 */ 646, 2253, 1796, 723, 649, 611, 649, 2455, 594, 2455, - /* 1030 */ 1622, 261, 593, 760, 157, 156, 757, 756, 755, 154, - /* 1040 */ 446, 442, 9, 690, 2253, 2461, 198, 2461, 198, 216, - /* 1050 */ 2456, 675, 2456, 675, 221, 166, 818, 707, 2041, 49, - /* 1060 */ 2285, 2286, 1860, 2323, 1645, 2263, 110, 2287, 727, 2289, - /* 1070 */ 2290, 722, 71, 717, 724, 70, 2448, 2038, 2475, 2271, - /* 1080 */ 2376, 707, 2041, 1859, 405, 2372, 707, 2041, 711, 2267, - /* 1090 */ 2348, 649, 1673, 1858, 2455, 1702, 1703, 1771, 487, 605, - /* 1100 */ 604, 269, 2304, 707, 2041, 144, 277, 486, 2347, 707, - /* 1110 */ 2041, 678, 2461, 198, 2253, 2253, 723, 2456, 675, 1857, - /* 1120 */ 707, 2041, 167, 692, 2234, 707, 2041, 1675, 1685, 309, - /* 1130 */ 2044, 2269, 406, 2237, 1701, 1704, 2253, 707, 2041, 2391, - /* 1140 */ 704, 717, 14, 13, 2263, 705, 2253, 707, 2041, 1617, - /* 1150 */ 681, 1615, 1676, 2285, 787, 785, 2323, 315, 2272, 110, - /* 1160 */ 2287, 727, 2289, 2290, 722, 2387, 717, 416, 2267, 1288, - /* 1170 */ 1289, 2475, 2253, 2376, 44, 43, 42, 405, 2372, 586, - /* 1180 */ 585, 1620, 1621, 1672, 431, 1674, 1677, 1678, 1679, 1680, - /* 1190 */ 1681, 1682, 1683, 1684, 719, 715, 1693, 1694, 1696, 1697, - /* 1200 */ 1698, 1699, 2, 48, 46, 155, 2286, 2391, 1673, 754, - /* 1210 */ 2269, 409, 2085, 1616, 588, 587, 1882, 813, 677, 724, - /* 1220 */ 717, 2395, 758, 1924, 759, 2085, 1700, 2085, 1614, 328, - /* 1230 */ 1265, 1266, 2071, 2386, 2396, 1763, 2135, 3, 135, 254, - /* 1240 */ 256, 258, 252, 255, 257, 610, 278, 2304, 1743, 54, - /* 1250 */ 85, 260, 1915, 1913, 259, 1695, 629, 50, 628, 2253, - /* 1260 */ 714, 723, 50, 182, 155, 1763, 2420, 50, 1622, 1849, - /* 1270 */ 1850, 303, 1907, 72, 612, 615, 153, 155, 467, 1583, - /* 1280 */ 14, 13, 65, 50, 50, 1625, 2274, 291, 731, 153, - /* 1290 */ 96, 107, 662, 767, 818, 155, 136, 15, 2285, 2286, - /* 1300 */ 104, 2323, 153, 768, 110, 2287, 727, 2289, 2290, 722, - /* 1310 */ 137, 717, 724, 1624, 285, 1319, 2475, 1338, 2376, 418, - /* 1320 */ 417, 2305, 405, 2372, 811, 1978, 1977, 1336, 2157, 1630, - /* 1330 */ 2410, 1802, 659, 1702, 1703, 395, 1801, 283, 691, 422, - /* 1340 */ 2304, 1537, 1700, 2276, 1623, 307, 205, 699, 392, 666, - /* 1350 */ 311, 1406, 2253, 696, 723, 1320, 1737, 1686, 327, 1903, - /* 1360 */ 1898, 1770, 1434, 1438, 2158, 1675, 1685, 679, 2082, 1445, - /* 1370 */ 1443, 1695, 1701, 1704, 2411, 2421, 158, 687, 293, 290, - /* 1380 */ 5, 297, 2003, 425, 1622, 430, 373, 1617, 438, 1615, - /* 1390 */ 1648, 2285, 447, 439, 2323, 206, 448, 110, 2287, 727, - /* 1400 */ 2289, 2290, 722, 207, 717, 450, 209, 1561, 682, 2351, - /* 1410 */ 713, 2376, 322, 1639, 464, 405, 2372, 1640, 1721, 1620, - /* 1420 */ 1621, 1672, 468, 1674, 1677, 1678, 1679, 1680, 1681, 1682, - /* 1430 */ 1683, 1684, 719, 715, 1693, 1694, 1696, 1697, 1698, 1699, - /* 1440 */ 2, 220, 168, 470, 474, 476, 1628, 335, 511, 481, - /* 1450 */ 494, 503, 501, 510, 2150, 512, 523, 524, 521, 224, - /* 1460 */ 225, 526, 227, 527, 332, 74, 529, 531, 73, 1646, - /* 1470 */ 4, 546, 547, 554, 1627, 1642, 555, 557, 357, 235, - /* 1480 */ 558, 237, 1647, 559, 2286, 1649, 560, 1650, 562, 230, - /* 1490 */ 530, 528, 525, 2166, 240, 633, 589, 724, 242, 568, - /* 1500 */ 354, 618, 2225, 1631, 90, 1626, 91, 247, 112, 619, - /* 1510 */ 2222, 591, 2031, 631, 94, 2221, 149, 251, 637, 323, - /* 1520 */ 636, 270, 638, 2027, 274, 2304, 1568, 272, 642, 253, - /* 1530 */ 62, 644, 2426, 160, 161, 1634, 1636, 2253, 2029, 723, - /* 1540 */ 2025, 162, 163, 663, 8, 697, 2425, 175, 2398, 715, - /* 1550 */ 1693, 1694, 1696, 1697, 1698, 1699, 672, 653, 641, 284, - /* 1560 */ 654, 286, 652, 287, 651, 2454, 288, 292, 63, 2478, - /* 1570 */ 1763, 643, 683, 680, 396, 141, 2285, 1643, 280, 2323, - /* 1580 */ 282, 1, 110, 2287, 727, 2289, 2290, 722, 289, 717, - /* 1590 */ 1768, 1766, 201, 299, 2349, 185, 2376, 324, 695, 150, - /* 1600 */ 405, 2372, 2180, 2179, 2178, 325, 700, 2392, 401, 701, - /* 1610 */ 326, 61, 83, 82, 459, 103, 2086, 211, 1244, 2042, - /* 1620 */ 729, 151, 812, 815, 101, 329, 317, 2357, 53, 365, - /* 1630 */ 451, 449, 366, 353, 331, 333, 2245, 159, 2244, 817, - /* 1640 */ 2243, 358, 80, 2286, 440, 2238, 427, 437, 433, 429, - /* 1650 */ 426, 452, 428, 1607, 338, 1608, 724, 204, 432, 2236, - /* 1660 */ 434, 435, 436, 1606, 2235, 374, 2233, 352, 441, 2286, - /* 1670 */ 342, 2232, 443, 2231, 445, 1596, 2212, 208, 2211, 210, - /* 1680 */ 1564, 81, 724, 1563, 2304, 2193, 2192, 2191, 457, 458, - /* 1690 */ 298, 2190, 2189, 2140, 2134, 462, 2253, 1507, 723, 465, - /* 1700 */ 466, 2131, 213, 2130, 2129, 84, 2128, 2133, 2132, 2127, - /* 1710 */ 2304, 482, 215, 2126, 2124, 2123, 2122, 217, 2121, 484, - /* 1720 */ 2137, 2120, 2253, 2119, 723, 2118, 2117, 2116, 2115, 2114, - /* 1730 */ 2113, 2112, 2111, 2110, 2109, 2285, 2286, 219, 2323, 2108, - /* 1740 */ 2107, 110, 2287, 727, 2289, 2290, 722, 2106, 717, 724, - /* 1750 */ 2105, 2104, 2103, 710, 2102, 2376, 2136, 89, 2101, 405, - /* 1760 */ 2372, 2285, 2100, 1513, 2323, 2286, 2099, 111, 2287, 727, - /* 1770 */ 2289, 2290, 722, 2098, 717, 223, 514, 2304, 724, 2097, - /* 1780 */ 516, 2376, 2096, 2095, 1943, 2375, 2372, 1377, 362, 2253, - /* 1790 */ 1381, 723, 363, 1942, 1373, 1941, 1939, 1936, 532, 226, - /* 1800 */ 228, 534, 1935, 1928, 533, 538, 2304, 229, 536, 540, - /* 1810 */ 1917, 537, 542, 544, 1893, 541, 2273, 77, 2253, 231, - /* 1820 */ 723, 190, 1267, 1892, 233, 2210, 191, 552, 2285, 78, - /* 1830 */ 2200, 2323, 2188, 2286, 111, 2287, 727, 2289, 2290, 722, - /* 1840 */ 239, 717, 241, 2187, 2164, 2020, 724, 1938, 2376, 244, - /* 1850 */ 1934, 1312, 712, 2372, 569, 635, 570, 725, 571, 1932, - /* 1860 */ 2323, 573, 574, 111, 2287, 727, 2289, 2290, 722, 575, - /* 1870 */ 717, 1930, 577, 821, 2304, 579, 1927, 2376, 581, 578, - /* 1880 */ 582, 368, 2372, 1912, 583, 1910, 2253, 1911, 723, 321, - /* 1890 */ 1909, 1889, 2022, 1450, 1449, 2021, 1349, 1363, 2286, 64, - /* 1900 */ 1362, 250, 1360, 1358, 1357, 188, 1356, 1355, 784, 1925, - /* 1910 */ 1354, 724, 786, 809, 805, 801, 797, 2286, 318, 1351, - /* 1920 */ 386, 1350, 1916, 1348, 387, 2285, 1914, 388, 2323, 1888, - /* 1930 */ 724, 171, 2287, 727, 2289, 2290, 722, 616, 717, 2304, - /* 1940 */ 620, 613, 1887, 1886, 1885, 622, 1884, 624, 113, 1590, - /* 1950 */ 1592, 2253, 1589, 723, 2209, 1594, 1570, 29, 2304, 109, - /* 1960 */ 1572, 68, 312, 2199, 2186, 2185, 57, 639, 165, 2460, - /* 1970 */ 2253, 275, 723, 650, 2417, 640, 17, 1549, 66, 195, - /* 1980 */ 20, 6, 1548, 31, 7, 1819, 279, 645, 281, 1574, - /* 1990 */ 2285, 657, 2286, 2323, 703, 647, 172, 2287, 727, 2289, - /* 2000 */ 2290, 722, 21, 717, 22, 724, 1800, 173, 655, 2285, - /* 2010 */ 184, 2274, 2323, 183, 33, 111, 2287, 727, 2289, 2290, - /* 2020 */ 722, 1789, 717, 32, 24, 1834, 79, 1833, 1839, 2376, - /* 2030 */ 1840, 397, 301, 2304, 2373, 1838, 1837, 398, 295, 300, - /* 2040 */ 1760, 59, 1759, 2184, 176, 2253, 98, 723, 2163, 2162, - /* 2050 */ 676, 2476, 99, 26, 97, 25, 104, 302, 271, 2286, - /* 2060 */ 1795, 186, 23, 308, 69, 18, 100, 313, 13, 11, - /* 2070 */ 177, 310, 724, 58, 698, 1632, 1712, 1711, 187, 1665, - /* 2080 */ 1722, 1690, 2326, 728, 2285, 2286, 716, 2323, 726, 1688, - /* 2090 */ 171, 2287, 727, 2289, 2290, 722, 730, 717, 724, 39, - /* 2100 */ 2304, 411, 734, 1687, 1657, 393, 737, 16, 27, 28, - /* 2110 */ 1426, 732, 2253, 1435, 723, 740, 1432, 735, 743, 1431, - /* 2120 */ 738, 746, 1428, 741, 316, 744, 2304, 1444, 1440, 1422, - /* 2130 */ 1420, 394, 747, 2418, 1425, 1345, 105, 106, 2253, 76, - /* 2140 */ 723, 1310, 761, 1424, 1342, 1341, 1340, 1339, 1337, 1335, - /* 2150 */ 1334, 2285, 1423, 1333, 2323, 2286, 1371, 351, 2287, 727, - /* 2160 */ 2289, 2290, 722, 772, 717, 1370, 202, 774, 724, 1331, - /* 2170 */ 1328, 1330, 1329, 1327, 1326, 1325, 1367, 2285, 1365, 1322, - /* 2180 */ 2323, 1321, 2286, 351, 2287, 727, 2289, 2290, 722, 1318, - /* 2190 */ 717, 1317, 1316, 1933, 1315, 724, 2304, 794, 795, 1931, - /* 2200 */ 796, 798, 799, 800, 1929, 802, 803, 804, 2253, 1926, - /* 2210 */ 723, 806, 1908, 807, 808, 810, 1257, 1883, 1245, 814, - /* 2220 */ 320, 816, 819, 2304, 1618, 330, 820, 1853, 1853, 1853, - /* 2230 */ 1853, 1853, 1853, 1853, 1853, 2253, 1853, 723, 1853, 1853, - /* 2240 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 2285, 1853, 1853, - /* 2250 */ 2323, 1853, 1853, 344, 2287, 727, 2289, 2290, 722, 1853, - /* 2260 */ 717, 1853, 1853, 1853, 1853, 1853, 2286, 1853, 1853, 1853, - /* 2270 */ 1853, 1853, 1853, 1853, 2285, 1853, 1853, 2323, 1853, 724, - /* 2280 */ 172, 2287, 727, 2289, 2290, 722, 1853, 717, 2286, 1853, - /* 2290 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 671, - /* 2300 */ 1853, 721, 1853, 1853, 1853, 1853, 1853, 2304, 1853, 1853, - /* 2310 */ 1853, 1853, 400, 1853, 1853, 1853, 1853, 1853, 1853, 2253, - /* 2320 */ 1853, 723, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 2304, - /* 2330 */ 1853, 1853, 1853, 1853, 1853, 2477, 1853, 1853, 1853, 1853, - /* 2340 */ 1853, 2253, 1853, 723, 1853, 1853, 1853, 1853, 1853, 1853, - /* 2350 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 2285, 1853, - /* 2360 */ 1853, 2323, 1853, 1853, 351, 2287, 727, 2289, 2290, 722, - /* 2370 */ 1853, 717, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, - /* 2380 */ 2285, 1853, 1853, 2323, 1853, 1853, 350, 2287, 727, 2289, - /* 2390 */ 2290, 722, 1853, 717, 2286, 2342, 1853, 1853, 1853, 1853, - /* 2400 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 724, 1853, 1853, - /* 2410 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, - /* 2420 */ 1853, 2286, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, - /* 2430 */ 1853, 1853, 1853, 1853, 724, 2304, 1853, 1853, 1853, 1853, - /* 2440 */ 408, 1853, 1853, 1853, 1853, 1853, 1853, 2253, 1853, 723, - /* 2450 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, - /* 2460 */ 1853, 1853, 2304, 1853, 1853, 1853, 1853, 410, 1853, 1853, - /* 2470 */ 1853, 1853, 1853, 1853, 2253, 1853, 723, 1853, 1853, 1853, - /* 2480 */ 1853, 1853, 1853, 1853, 1853, 1853, 2285, 2286, 1853, 2323, - /* 2490 */ 1853, 1853, 351, 2287, 727, 2289, 2290, 722, 1853, 717, - /* 2500 */ 724, 1853, 1853, 1853, 2286, 1853, 1853, 1853, 1853, 1853, - /* 2510 */ 1853, 1853, 1853, 2285, 1853, 1853, 2323, 724, 1853, 351, - /* 2520 */ 2287, 727, 2289, 2290, 722, 1853, 717, 1853, 2304, 1853, - /* 2530 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, - /* 2540 */ 2253, 1853, 723, 1853, 1853, 2304, 1853, 1853, 1853, 1853, - /* 2550 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 2253, 1853, 723, - /* 2560 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, - /* 2570 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 630, - /* 2580 */ 1853, 1853, 2323, 1853, 2286, 346, 2287, 727, 2289, 2290, - /* 2590 */ 722, 1853, 717, 1853, 1853, 1853, 2285, 724, 1853, 2323, - /* 2600 */ 1853, 1853, 336, 2287, 727, 2289, 2290, 722, 1853, 717, - /* 2610 */ 1853, 1853, 1853, 1853, 1853, 2286, 1853, 1853, 1853, 1853, - /* 2620 */ 1853, 1853, 1853, 1853, 1853, 2304, 1853, 1853, 724, 1853, - /* 2630 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 2253, 1853, 723, - /* 2640 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, - /* 2650 */ 2286, 1853, 1853, 1853, 1853, 1853, 2304, 1853, 1853, 1853, - /* 2660 */ 1853, 1853, 1853, 724, 1853, 1853, 1853, 1853, 2253, 1853, - /* 2670 */ 723, 1853, 1853, 1853, 1853, 1853, 2285, 1853, 1853, 2323, - /* 2680 */ 1853, 1853, 334, 2287, 727, 2289, 2290, 722, 1853, 717, - /* 2690 */ 1853, 2304, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, - /* 2700 */ 1853, 1853, 1853, 2253, 1853, 723, 1853, 2285, 1853, 1853, - /* 2710 */ 2323, 1853, 1853, 337, 2287, 727, 2289, 2290, 722, 1853, - /* 2720 */ 717, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, - /* 2730 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, - /* 2740 */ 1853, 1853, 2285, 2286, 1853, 2323, 1853, 1853, 343, 2287, - /* 2750 */ 727, 2289, 2290, 722, 1853, 717, 724, 1853, 1853, 1853, - /* 2760 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, - /* 2770 */ 2286, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, - /* 2780 */ 1853, 1853, 1853, 724, 2304, 1853, 1853, 1853, 1853, 1853, - /* 2790 */ 1853, 1853, 1853, 1853, 1853, 1853, 2253, 1853, 723, 1853, - /* 2800 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, - /* 2810 */ 1853, 2304, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, - /* 2820 */ 1853, 1853, 1853, 2253, 1853, 723, 1853, 1853, 1853, 1853, - /* 2830 */ 1853, 1853, 1853, 1853, 1853, 2285, 2286, 1853, 2323, 1853, - /* 2840 */ 1853, 347, 2287, 727, 2289, 2290, 722, 1853, 717, 724, - /* 2850 */ 1853, 1853, 1853, 2286, 1853, 1853, 1853, 1853, 1853, 1853, - /* 2860 */ 1853, 1853, 2285, 1853, 1853, 2323, 724, 1853, 339, 2287, - /* 2870 */ 727, 2289, 2290, 722, 1853, 717, 1853, 2304, 1853, 1853, - /* 2880 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 2253, - /* 2890 */ 1853, 723, 1853, 1853, 2304, 1853, 1853, 1853, 1853, 1853, - /* 2900 */ 1853, 1853, 1853, 1853, 1853, 1853, 2253, 1853, 723, 1853, - /* 2910 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, - /* 2920 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 2285, 1853, - /* 2930 */ 1853, 2323, 1853, 2286, 348, 2287, 727, 2289, 2290, 722, - /* 2940 */ 1853, 717, 1853, 1853, 1853, 2285, 724, 1853, 2323, 1853, - /* 2950 */ 1853, 340, 2287, 727, 2289, 2290, 722, 1853, 717, 1853, - /* 2960 */ 1853, 1853, 1853, 1853, 2286, 1853, 1853, 1853, 1853, 1853, - /* 2970 */ 1853, 1853, 1853, 1853, 2304, 1853, 1853, 724, 1853, 1853, - /* 2980 */ 1853, 1853, 1853, 1853, 1853, 1853, 2253, 1853, 723, 1853, - /* 2990 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 2286, - /* 3000 */ 1853, 1853, 1853, 1853, 1853, 2304, 1853, 1853, 1853, 1853, - /* 3010 */ 1853, 1853, 724, 1853, 1853, 1853, 1853, 2253, 1853, 723, - /* 3020 */ 1853, 1853, 1853, 1853, 1853, 2285, 1853, 1853, 2323, 1853, - /* 3030 */ 1853, 349, 2287, 727, 2289, 2290, 722, 1853, 717, 1853, - /* 3040 */ 2304, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, - /* 3050 */ 1853, 1853, 2253, 1853, 723, 1853, 2285, 1853, 1853, 2323, - /* 3060 */ 1853, 1853, 341, 2287, 727, 2289, 2290, 722, 1853, 717, - /* 3070 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, - /* 3080 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, - /* 3090 */ 1853, 2285, 2286, 1853, 2323, 1853, 1853, 355, 2287, 727, - /* 3100 */ 2289, 2290, 722, 1853, 717, 724, 1853, 1853, 1853, 1853, - /* 3110 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 2286, - /* 3120 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, - /* 3130 */ 1853, 1853, 724, 2304, 1853, 1853, 1853, 1853, 1853, 1853, - /* 3140 */ 1853, 1853, 1853, 1853, 1853, 2253, 1853, 723, 1853, 1853, - /* 3150 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, - /* 3160 */ 2304, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, - /* 3170 */ 1853, 1853, 2253, 1853, 723, 1853, 1853, 1853, 1853, 1853, - /* 3180 */ 1853, 1853, 1853, 1853, 2285, 2286, 1853, 2323, 1853, 1853, - /* 3190 */ 356, 2287, 727, 2289, 2290, 722, 1853, 717, 724, 1853, - /* 3200 */ 1853, 1853, 2286, 1853, 1853, 1853, 1853, 1853, 1853, 1853, - /* 3210 */ 1853, 2285, 1853, 1853, 2323, 724, 1853, 2298, 2287, 727, - /* 3220 */ 2289, 2290, 722, 1853, 717, 1853, 2304, 1853, 1853, 1853, - /* 3230 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 2253, 1853, - /* 3240 */ 723, 1853, 1853, 2304, 1853, 1853, 1853, 1853, 1853, 1853, - /* 3250 */ 1853, 1853, 1853, 1853, 1853, 2253, 1853, 723, 1853, 1853, - /* 3260 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, - /* 3270 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 2285, 1853, 1853, - /* 3280 */ 2323, 1853, 2286, 2297, 2287, 727, 2289, 2290, 722, 1853, - /* 3290 */ 717, 1853, 1853, 1853, 2285, 724, 1853, 2323, 1853, 1853, - /* 3300 */ 2296, 2287, 727, 2289, 2290, 722, 1853, 717, 1853, 1853, - /* 3310 */ 1853, 1853, 1853, 2286, 1853, 1853, 1853, 1853, 1853, 1853, - /* 3320 */ 1853, 1853, 1853, 2304, 1853, 1853, 724, 1853, 1853, 1853, - /* 3330 */ 1853, 1853, 1853, 1853, 1853, 2253, 1853, 723, 1853, 1853, - /* 3340 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 2286, 1853, - /* 3350 */ 1853, 1853, 1853, 1853, 2304, 1853, 1853, 1853, 1853, 1853, - /* 3360 */ 1853, 724, 1853, 1853, 1853, 1853, 2253, 1853, 723, 1853, - /* 3370 */ 1853, 1853, 1853, 1853, 2285, 1853, 1853, 2323, 1853, 1853, - /* 3380 */ 370, 2287, 727, 2289, 2290, 722, 1853, 717, 1853, 2304, - /* 3390 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, - /* 3400 */ 1853, 2253, 1853, 723, 1853, 2285, 1853, 1853, 2323, 1853, - /* 3410 */ 1853, 371, 2287, 727, 2289, 2290, 722, 1853, 717, 1853, - /* 3420 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, - /* 3430 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, - /* 3440 */ 2285, 2286, 1853, 2323, 1853, 1853, 367, 2287, 727, 2289, - /* 3450 */ 2290, 722, 1853, 717, 724, 1853, 1853, 1853, 1853, 1853, - /* 3460 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 2286, 1853, - /* 3470 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, - /* 3480 */ 1853, 724, 2304, 1853, 1853, 1853, 1853, 1853, 1853, 1853, - /* 3490 */ 1853, 1853, 1853, 1853, 2253, 1853, 723, 1853, 1853, 1853, - /* 3500 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 2304, - /* 3510 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, - /* 3520 */ 1853, 2253, 1853, 723, 1853, 1853, 1853, 1853, 1853, 1853, - /* 3530 */ 1853, 1853, 1853, 2285, 2286, 1853, 2323, 1853, 1853, 372, - /* 3540 */ 2287, 727, 2289, 2290, 722, 1853, 717, 724, 1853, 1853, - /* 3550 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, - /* 3560 */ 725, 1853, 1853, 2323, 1853, 1853, 346, 2287, 727, 2289, - /* 3570 */ 2290, 722, 1853, 717, 1853, 2304, 1853, 1853, 1853, 1853, - /* 3580 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 2253, 1853, 723, - /* 3590 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, - /* 3600 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, - /* 3610 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, - /* 3620 */ 1853, 1853, 1853, 1853, 1853, 1853, 2285, 1853, 1853, 2323, - /* 3630 */ 1853, 1853, 345, 2287, 727, 2289, 2290, 722, 1853, 717, + /* 0 */ 173, 409, 462, 418, 2278, 720, 2067, 461, 2006, 171, + /* 10 */ 2007, 168, 48, 46, 1799, 424, 423, 2069, 397, 2069, + /* 20 */ 415, 1669, 1640, 41, 40, 137, 2118, 47, 45, 44, + /* 30 */ 43, 42, 599, 475, 2176, 1725, 1963, 1638, 41, 40, + /* 40 */ 1647, 694, 47, 45, 44, 43, 42, 2319, 1665, 720, + /* 50 */ 2067, 2120, 662, 469, 662, 2488, 681, 2488, 381, 789, + /* 60 */ 702, 184, 2028, 30, 1720, 1880, 2118, 719, 556, 208, + /* 70 */ 19, 557, 1922, 2494, 203, 2494, 203, 1646, 2489, 688, + /* 80 */ 2489, 688, 219, 383, 2337, 2180, 127, 719, 2337, 126, + /* 90 */ 125, 124, 123, 122, 121, 120, 119, 118, 523, 521, + /* 100 */ 2285, 364, 736, 831, 786, 217, 15, 1665, 806, 805, + /* 110 */ 804, 803, 427, 719, 802, 801, 151, 796, 795, 794, + /* 120 */ 793, 792, 791, 790, 150, 784, 783, 782, 426, 425, + /* 130 */ 779, 778, 777, 183, 182, 776, 687, 1842, 573, 2488, + /* 140 */ 561, 2318, 1727, 1728, 2356, 680, 558, 114, 2320, 740, + /* 150 */ 2322, 2323, 735, 51, 730, 2424, 2200, 686, 203, 186, + /* 160 */ 2200, 2409, 2489, 688, 687, 411, 2405, 2488, 788, 720, + /* 170 */ 2067, 408, 699, 146, 2197, 707, 1700, 1710, 2198, 707, + /* 180 */ 205, 2421, 1665, 1726, 1729, 686, 203, 1382, 2439, 137, + /* 190 */ 2489, 688, 1439, 682, 574, 2193, 604, 1877, 1641, 51, + /* 200 */ 1639, 677, 2295, 1650, 2306, 1872, 1430, 765, 764, 763, + /* 210 */ 1434, 762, 1436, 1437, 761, 758, 2303, 1445, 755, 1447, + /* 220 */ 1448, 752, 749, 746, 481, 2176, 2299, 1384, 389, 388, + /* 230 */ 1644, 1645, 1697, 1670, 1699, 1702, 1703, 1704, 1705, 1706, + /* 240 */ 1707, 1708, 1709, 732, 728, 1718, 1719, 1721, 1722, 1723, + /* 250 */ 1724, 2, 48, 46, 509, 2176, 576, 363, 63, 1663, + /* 260 */ 415, 2308, 1640, 1540, 1541, 2319, 507, 184, 63, 526, + /* 270 */ 2301, 412, 95, 221, 525, 1725, 430, 1638, 734, 95, + /* 280 */ 730, 429, 300, 2417, 698, 68, 138, 697, 1668, 2488, + /* 290 */ 489, 2181, 527, 683, 678, 671, 385, 491, 2063, 387, + /* 300 */ 386, 695, 601, 226, 1720, 2062, 2337, 686, 203, 1871, + /* 310 */ 19, 1666, 2489, 688, 618, 617, 616, 1646, 2285, 2424, + /* 320 */ 736, 608, 143, 612, 603, 1822, 662, 611, 602, 2488, + /* 330 */ 720, 2067, 610, 615, 391, 390, 1803, 645, 609, 634, + /* 340 */ 1823, 605, 1665, 831, 384, 2420, 15, 2494, 203, 460, + /* 350 */ 56, 459, 2489, 688, 632, 477, 630, 269, 268, 2318, + /* 360 */ 564, 304, 2356, 557, 1922, 356, 2320, 740, 2322, 2323, + /* 370 */ 735, 733, 730, 721, 2374, 47, 45, 44, 43, 42, + /* 380 */ 1821, 458, 1727, 1728, 63, 2187, 2166, 63, 514, 513, + /* 390 */ 512, 511, 506, 505, 504, 503, 502, 497, 496, 495, + /* 400 */ 494, 367, 486, 485, 484, 1697, 479, 478, 382, 172, + /* 410 */ 38, 320, 1528, 1529, 341, 34, 1700, 1710, 1547, 223, + /* 420 */ 304, 41, 40, 1726, 1729, 47, 45, 44, 43, 42, + /* 430 */ 304, 338, 74, 1474, 1475, 73, 646, 775, 1641, 420, + /* 440 */ 1639, 1966, 2113, 2115, 517, 365, 302, 41, 40, 52, + /* 450 */ 691, 47, 45, 44, 43, 42, 235, 538, 536, 533, + /* 460 */ 90, 41, 40, 89, 1902, 47, 45, 44, 43, 42, + /* 470 */ 1644, 1645, 1697, 1669, 1699, 1702, 1703, 1704, 1705, 1706, + /* 480 */ 1707, 1708, 1709, 732, 728, 1718, 1719, 1721, 1722, 1723, + /* 490 */ 1724, 2, 12, 48, 46, 159, 553, 63, 1701, 720, + /* 500 */ 2067, 415, 2248, 1640, 551, 644, 227, 547, 543, 375, + /* 510 */ 566, 2239, 572, 618, 617, 616, 1725, 2285, 1638, 466, + /* 520 */ 608, 143, 612, 834, 699, 146, 611, 88, 516, 515, + /* 530 */ 1735, 610, 615, 391, 390, 64, 1665, 609, 237, 327, + /* 540 */ 605, 284, 559, 1830, 1930, 1720, 304, 1669, 2319, 304, + /* 550 */ 196, 19, 661, 1754, 1698, 193, 274, 1756, 1646, 720, + /* 560 */ 2067, 702, 2107, 822, 818, 814, 810, 127, 324, 55, + /* 570 */ 126, 125, 124, 123, 122, 121, 120, 119, 118, 467, + /* 580 */ 9, 84, 83, 465, 831, 100, 216, 15, 12, 2337, + /* 590 */ 10, 1640, 674, 673, 1828, 1829, 1831, 1832, 1833, 457, + /* 600 */ 455, 2285, 643, 736, 112, 2493, 1638, 720, 2067, 113, + /* 610 */ 366, 304, 318, 446, 1755, 1666, 443, 439, 435, 432, + /* 620 */ 458, 147, 1668, 1727, 1728, 2044, 1303, 483, 1302, 2059, + /* 630 */ 174, 199, 1891, 701, 201, 2417, 2418, 35, 144, 2422, + /* 640 */ 699, 146, 2318, 142, 716, 2356, 1646, 1761, 114, 2320, + /* 650 */ 740, 2322, 2323, 735, 1901, 730, 2120, 1700, 1710, 304, + /* 660 */ 186, 1304, 2409, 36, 1726, 1729, 411, 2405, 106, 41, + /* 670 */ 40, 706, 831, 47, 45, 44, 43, 42, 2043, 1641, + /* 680 */ 61, 1639, 699, 146, 307, 1670, 720, 2067, 659, 2440, + /* 690 */ 606, 306, 1701, 2060, 37, 413, 1749, 1750, 1751, 1752, + /* 700 */ 1753, 1757, 1758, 1759, 1760, 194, 498, 2285, 692, 1865, + /* 710 */ 277, 1644, 1645, 1697, 1379, 1699, 1702, 1703, 1704, 1705, + /* 720 */ 1706, 1707, 1708, 1709, 732, 728, 1718, 1719, 1721, 1722, + /* 730 */ 1723, 1724, 2, 48, 46, 1730, 2319, 1560, 1561, 1286, + /* 740 */ 239, 415, 1900, 1640, 559, 1664, 1930, 775, 1698, 737, + /* 750 */ 202, 2417, 2418, 603, 144, 2422, 1725, 602, 1638, 1670, + /* 760 */ 773, 161, 160, 770, 769, 768, 158, 1641, 2319, 1639, + /* 770 */ 773, 161, 160, 770, 769, 768, 158, 2337, 1559, 1562, + /* 780 */ 302, 737, 1899, 1932, 727, 1720, 1879, 720, 2067, 2285, + /* 790 */ 1669, 736, 204, 2417, 2418, 2285, 144, 2422, 1646, 1644, + /* 800 */ 1645, 2114, 2115, 1898, 646, 1788, 2319, 499, 2424, 2337, + /* 810 */ 136, 135, 134, 133, 132, 131, 130, 129, 128, 737, + /* 820 */ 1665, 2285, 99, 736, 831, 720, 2067, 49, 1665, 623, + /* 830 */ 2318, 720, 2067, 2356, 2419, 2285, 114, 2320, 740, 2322, + /* 840 */ 2323, 735, 1897, 730, 635, 500, 149, 2337, 156, 2380, + /* 850 */ 2409, 575, 1588, 272, 411, 2405, 2285, 271, 418, 2285, + /* 860 */ 270, 736, 2318, 1727, 1728, 2356, 171, 2151, 114, 2320, + /* 870 */ 740, 2322, 2323, 735, 2069, 730, 626, 2042, 648, 2239, + /* 880 */ 2508, 2120, 2409, 620, 2120, 12, 411, 2405, 396, 267, + /* 890 */ 1646, 405, 720, 2067, 1896, 2285, 2118, 1700, 1710, 2118, + /* 900 */ 2318, 595, 594, 2356, 1726, 1729, 114, 2320, 740, 2322, + /* 910 */ 2323, 735, 2064, 730, 2295, 722, 255, 2381, 2384, 1641, + /* 920 */ 2409, 1639, 1895, 98, 411, 2405, 370, 1894, 2058, 395, + /* 930 */ 72, 636, 178, 71, 2120, 1277, 614, 613, 2299, 766, + /* 940 */ 593, 589, 585, 581, 1746, 254, 1893, 2285, 198, 715, + /* 950 */ 2279, 1644, 1645, 1697, 1284, 1699, 1702, 1703, 1704, 1705, + /* 960 */ 1706, 1707, 1708, 1709, 732, 728, 1718, 1719, 1721, 1722, + /* 970 */ 1723, 1724, 2, 48, 46, 2285, 1701, 1279, 1282, 1283, + /* 980 */ 2285, 415, 2301, 1640, 720, 2067, 96, 720, 2067, 252, + /* 990 */ 2120, 2492, 730, 325, 2120, 2319, 1725, 410, 1638, 2285, + /* 1000 */ 662, 419, 1670, 2488, 275, 2118, 1284, 283, 737, 2118, + /* 1010 */ 2447, 2056, 773, 161, 160, 770, 769, 768, 158, 720, + /* 1020 */ 2067, 2494, 203, 720, 2067, 1720, 2489, 688, 493, 2319, + /* 1030 */ 1282, 1283, 1698, 421, 720, 2067, 2337, 492, 1646, 705, + /* 1040 */ 1698, 171, 737, 315, 2460, 720, 2067, 2052, 2285, 2069, + /* 1050 */ 736, 41, 40, 242, 717, 47, 45, 44, 43, 42, + /* 1060 */ 1796, 251, 244, 450, 831, 718, 2161, 49, 249, 570, + /* 1070 */ 2337, 41, 40, 720, 2067, 47, 45, 44, 43, 42, + /* 1080 */ 1306, 1307, 2285, 1933, 736, 720, 2067, 241, 1337, 2318, + /* 1090 */ 452, 448, 2356, 321, 2054, 114, 2320, 740, 2322, 2323, + /* 1100 */ 735, 641, 730, 1727, 1728, 422, 2266, 2508, 473, 2409, + /* 1110 */ 647, 41, 40, 411, 2405, 47, 45, 44, 43, 42, + /* 1120 */ 1303, 1890, 1302, 2318, 800, 798, 2356, 1889, 1338, 114, + /* 1130 */ 2320, 740, 2322, 2323, 735, 824, 730, 1700, 1710, 597, + /* 1140 */ 596, 2508, 273, 2409, 1726, 1729, 2050, 411, 2405, 2493, + /* 1150 */ 1841, 662, 2488, 148, 2488, 1304, 2380, 311, 312, 1641, + /* 1160 */ 662, 1639, 310, 2488, 724, 2295, 2381, 1888, 1394, 703, + /* 1170 */ 1815, 2492, 2494, 203, 2285, 2489, 2491, 2489, 688, 2304, + /* 1180 */ 2285, 2494, 203, 1393, 14, 13, 2489, 688, 638, 2299, + /* 1190 */ 637, 1644, 1645, 1697, 1887, 1699, 1702, 1703, 1704, 1705, + /* 1200 */ 1706, 1707, 1708, 1709, 732, 728, 1718, 1719, 1721, 1722, + /* 1210 */ 1723, 1724, 2, 48, 46, 2319, 197, 1609, 1610, 662, + /* 1220 */ 2285, 415, 2488, 1640, 1398, 44, 43, 42, 737, 1886, + /* 1230 */ 669, 2493, 767, 2301, 2488, 2111, 1725, 2120, 1638, 1397, + /* 1240 */ 2494, 203, 1885, 730, 1884, 2489, 688, 2285, 2319, 528, + /* 1250 */ 1649, 171, 2119, 2492, 2071, 1883, 2337, 2489, 2490, 2070, + /* 1260 */ 1882, 737, 1648, 2481, 771, 1720, 334, 2111, 2285, 2097, + /* 1270 */ 736, 772, 1907, 826, 2111, 2429, 1788, 690, 1646, 41, + /* 1280 */ 40, 170, 2285, 47, 45, 44, 43, 42, 2269, 2337, + /* 1290 */ 1768, 2045, 1950, 280, 3, 2285, 76, 2285, 139, 260, + /* 1300 */ 159, 2285, 258, 736, 831, 530, 54, 15, 2285, 2318, + /* 1310 */ 86, 2453, 2356, 2285, 619, 114, 2320, 740, 2322, 2323, + /* 1320 */ 735, 731, 730, 607, 152, 262, 1795, 2508, 261, 2409, + /* 1330 */ 210, 424, 423, 411, 2405, 264, 1941, 266, 263, 437, + /* 1340 */ 265, 1654, 2318, 1727, 1728, 2356, 87, 1377, 114, 2320, + /* 1350 */ 740, 2322, 2323, 735, 1725, 730, 1647, 1939, 621, 297, + /* 1360 */ 2508, 1892, 2409, 1874, 1875, 675, 411, 2405, 14, 13, + /* 1370 */ 141, 291, 2338, 2004, 1604, 2319, 780, 1700, 1710, 624, + /* 1380 */ 159, 50, 50, 1720, 1726, 1729, 187, 159, 737, 50, + /* 1390 */ 2428, 309, 75, 111, 157, 781, 1646, 159, 2003, 1641, + /* 1400 */ 1356, 1639, 108, 672, 2185, 1923, 2443, 401, 679, 398, + /* 1410 */ 709, 66, 50, 1652, 50, 428, 2337, 744, 157, 1354, + /* 1420 */ 1929, 159, 726, 140, 157, 1651, 2108, 2186, 2285, 655, + /* 1430 */ 736, 1644, 1645, 1697, 2444, 1699, 1702, 1703, 1704, 1705, + /* 1440 */ 1706, 1707, 1708, 1709, 732, 728, 1718, 1719, 1721, 1722, + /* 1450 */ 1723, 1724, 2, 2454, 1607, 1827, 1826, 700, 299, 296, + /* 1460 */ 289, 704, 2029, 1557, 303, 313, 712, 5, 317, 2318, + /* 1470 */ 431, 1424, 2356, 436, 379, 114, 2320, 740, 2322, 2323, + /* 1480 */ 735, 444, 730, 2319, 445, 1762, 1711, 2508, 333, 2409, + /* 1490 */ 1673, 1452, 1456, 411, 2405, 1463, 737, 1461, 162, 454, + /* 1500 */ 212, 211, 453, 214, 456, 1581, 328, 1663, 470, 1664, + /* 1510 */ 474, 225, 476, 480, 519, 482, 487, 1655, 501, 1650, + /* 1520 */ 508, 2178, 510, 518, 2337, 520, 532, 531, 529, 229, + /* 1530 */ 230, 534, 232, 535, 537, 539, 2285, 1671, 736, 554, + /* 1540 */ 4, 2319, 555, 562, 563, 240, 565, 92, 1666, 1658, + /* 1550 */ 1660, 243, 1672, 567, 737, 1674, 568, 246, 569, 1675, + /* 1560 */ 571, 248, 2194, 728, 1718, 1719, 1721, 1722, 1723, 1724, + /* 1570 */ 93, 577, 598, 94, 253, 97, 642, 2318, 2319, 627, + /* 1580 */ 2356, 2257, 2337, 114, 2320, 740, 2322, 2323, 735, 600, + /* 1590 */ 730, 737, 116, 628, 2285, 2382, 736, 2409, 2057, 257, + /* 1600 */ 360, 411, 2405, 640, 2053, 259, 153, 164, 2254, 165, + /* 1610 */ 2055, 2319, 2051, 166, 167, 329, 276, 1667, 2240, 2337, + /* 1620 */ 650, 649, 651, 281, 737, 657, 2459, 279, 676, 710, + /* 1630 */ 8, 2285, 2253, 736, 2431, 2318, 654, 685, 2356, 666, + /* 1640 */ 2458, 114, 2320, 740, 2322, 2323, 735, 290, 730, 179, + /* 1650 */ 667, 292, 2337, 723, 2319, 2409, 286, 665, 288, 411, + /* 1660 */ 2405, 656, 2487, 402, 2285, 664, 736, 737, 295, 696, + /* 1670 */ 2511, 298, 2318, 693, 1788, 2356, 145, 1668, 115, 2320, + /* 1680 */ 740, 2322, 2323, 735, 1793, 730, 190, 2425, 1791, 293, + /* 1690 */ 294, 2319, 2409, 1, 305, 2337, 2408, 2405, 154, 330, + /* 1700 */ 708, 2208, 2207, 2206, 737, 2318, 331, 2285, 2356, 736, + /* 1710 */ 407, 115, 2320, 740, 2322, 2323, 735, 713, 730, 206, + /* 1720 */ 714, 332, 62, 155, 2390, 2409, 107, 2068, 105, 725, + /* 1730 */ 2405, 742, 2337, 2112, 335, 1261, 825, 323, 828, 371, + /* 1740 */ 53, 359, 372, 830, 2285, 339, 736, 163, 738, 2319, + /* 1750 */ 344, 2356, 2277, 2276, 115, 2320, 740, 2322, 2323, 735, + /* 1760 */ 358, 730, 737, 337, 348, 2275, 2319, 81, 2409, 2270, + /* 1770 */ 433, 434, 374, 2405, 1631, 1632, 209, 438, 2268, 737, + /* 1780 */ 440, 441, 442, 1630, 2267, 2318, 380, 2319, 2356, 2265, + /* 1790 */ 2337, 175, 2320, 740, 2322, 2323, 735, 447, 730, 2264, + /* 1800 */ 737, 449, 2285, 451, 736, 2263, 1620, 2337, 2244, 213, + /* 1810 */ 2243, 215, 1584, 82, 2221, 1583, 2220, 2219, 463, 2285, + /* 1820 */ 464, 736, 2218, 2217, 2168, 468, 1527, 2160, 2337, 471, + /* 1830 */ 2157, 472, 218, 663, 2450, 2156, 85, 2155, 2154, 2159, + /* 1840 */ 2285, 2158, 736, 2318, 220, 2153, 2356, 2152, 2150, 176, + /* 1850 */ 2320, 740, 2322, 2323, 735, 2149, 730, 2148, 222, 2147, + /* 1860 */ 2318, 488, 490, 2356, 2163, 2146, 115, 2320, 740, 2322, + /* 1870 */ 2323, 735, 2145, 730, 2144, 2143, 2142, 2165, 2141, 2140, + /* 1880 */ 2409, 2318, 2139, 2138, 2356, 2406, 2319, 175, 2320, 740, + /* 1890 */ 2322, 2323, 735, 2137, 730, 2136, 2135, 2134, 2133, 737, + /* 1900 */ 2132, 224, 2131, 689, 2509, 91, 2130, 2129, 2128, 2164, + /* 1910 */ 2162, 2127, 2126, 2319, 1533, 2125, 2124, 228, 522, 2123, + /* 1920 */ 524, 2122, 2121, 1395, 1969, 1399, 737, 2337, 1391, 1968, + /* 1930 */ 2451, 368, 399, 231, 369, 233, 1967, 234, 1965, 2285, + /* 1940 */ 1962, 736, 540, 1961, 2319, 541, 542, 1954, 1943, 1918, + /* 1950 */ 544, 1285, 1917, 2242, 2337, 2238, 185, 737, 2228, 400, + /* 1960 */ 546, 2216, 548, 552, 2215, 545, 2285, 2192, 736, 550, + /* 1970 */ 247, 549, 78, 236, 238, 2046, 79, 1964, 1960, 578, + /* 1980 */ 2318, 2319, 2305, 2356, 195, 2337, 357, 2320, 740, 2322, + /* 1990 */ 2323, 735, 245, 730, 737, 560, 579, 2285, 580, 736, + /* 2000 */ 250, 1958, 582, 1330, 584, 583, 1956, 2318, 586, 1953, + /* 2010 */ 2356, 587, 588, 357, 2320, 740, 2322, 2323, 735, 590, + /* 2020 */ 730, 592, 2337, 591, 1938, 1936, 1937, 1935, 1914, 2048, + /* 2030 */ 1468, 65, 1467, 2047, 2285, 1951, 736, 1381, 2318, 1380, + /* 2040 */ 1378, 2356, 1376, 1942, 350, 2320, 740, 2322, 2323, 735, + /* 2050 */ 1375, 730, 1374, 256, 2319, 1373, 1372, 1369, 1368, 1367, + /* 2060 */ 1366, 392, 393, 797, 799, 622, 1940, 737, 394, 625, + /* 2070 */ 1913, 1912, 1911, 629, 1910, 2318, 1909, 633, 2356, 2319, + /* 2080 */ 117, 176, 2320, 740, 2322, 2323, 735, 631, 730, 1614, + /* 2090 */ 684, 1616, 734, 1613, 1618, 2337, 29, 2241, 69, 2237, + /* 2100 */ 406, 1590, 278, 1592, 1594, 2227, 652, 2285, 2214, 736, + /* 2110 */ 2493, 20, 6, 17, 31, 668, 21, 57, 2213, 7, + /* 2120 */ 2337, 22, 2319, 1844, 287, 189, 200, 33, 285, 2306, + /* 2130 */ 67, 23, 2285, 24, 736, 737, 2510, 2319, 282, 18, + /* 2140 */ 670, 58, 301, 1859, 653, 169, 1569, 1568, 2318, 1825, + /* 2150 */ 737, 2356, 2319, 177, 357, 2320, 740, 2322, 2323, 735, + /* 2160 */ 1858, 730, 403, 2337, 188, 737, 1814, 32, 414, 658, + /* 2170 */ 660, 80, 1863, 2318, 1864, 2285, 2356, 736, 2337, 356, + /* 2180 */ 2320, 740, 2322, 2323, 735, 1862, 730, 404, 2375, 1865, + /* 2190 */ 2285, 60, 736, 2337, 1785, 180, 1784, 2212, 416, 2191, + /* 2200 */ 2190, 101, 102, 308, 25, 2285, 103, 736, 1820, 191, + /* 2210 */ 314, 319, 26, 13, 316, 70, 2318, 2319, 104, 2356, + /* 2220 */ 1737, 1736, 357, 2320, 740, 2322, 2323, 735, 108, 730, + /* 2230 */ 737, 639, 1656, 711, 2356, 2319, 11, 352, 2320, 740, + /* 2240 */ 2322, 2323, 735, 2359, 730, 1715, 2318, 729, 737, 2356, + /* 2250 */ 1713, 39, 357, 2320, 740, 2322, 2323, 735, 2337, 730, + /* 2260 */ 59, 1712, 181, 16, 192, 27, 1690, 741, 1682, 28, + /* 2270 */ 2285, 1747, 736, 1453, 743, 417, 2337, 739, 745, 747, + /* 2280 */ 1450, 748, 750, 1449, 751, 753, 756, 1446, 2285, 754, + /* 2290 */ 736, 1440, 757, 759, 1438, 760, 1444, 1443, 1442, 109, + /* 2300 */ 322, 1441, 110, 1462, 77, 1458, 1363, 1328, 1360, 774, + /* 2310 */ 1389, 2318, 1359, 1358, 2356, 1357, 1355, 342, 2320, 740, + /* 2320 */ 2322, 2323, 735, 1353, 730, 1352, 1351, 785, 1388, 2318, + /* 2330 */ 2319, 787, 2356, 207, 1349, 340, 2320, 740, 2322, 2323, + /* 2340 */ 735, 1348, 730, 737, 1347, 1346, 1345, 2319, 1344, 1343, + /* 2350 */ 1383, 1385, 1340, 1339, 1336, 1335, 1334, 1333, 1959, 807, + /* 2360 */ 737, 808, 1957, 2319, 811, 812, 809, 813, 1955, 815, + /* 2370 */ 816, 2337, 1952, 817, 819, 821, 737, 820, 1934, 823, + /* 2380 */ 1274, 1908, 1262, 2285, 827, 736, 326, 829, 2337, 1642, + /* 2390 */ 833, 336, 832, 1878, 1878, 1878, 1878, 1878, 1878, 1878, + /* 2400 */ 2285, 1878, 736, 1878, 2337, 1878, 1878, 1878, 1878, 1878, + /* 2410 */ 1878, 1878, 1878, 1878, 1878, 1878, 2285, 1878, 736, 1878, + /* 2420 */ 1878, 1878, 1878, 1878, 2318, 1878, 1878, 2356, 1878, 1878, + /* 2430 */ 343, 2320, 740, 2322, 2323, 735, 1878, 730, 1878, 1878, + /* 2440 */ 2319, 2318, 1878, 1878, 2356, 1878, 1878, 349, 2320, 740, + /* 2450 */ 2322, 2323, 735, 737, 730, 1878, 1878, 2318, 1878, 2319, + /* 2460 */ 2356, 1878, 1878, 353, 2320, 740, 2322, 2323, 735, 1878, + /* 2470 */ 730, 1878, 737, 1878, 1878, 1878, 1878, 1878, 1878, 1878, + /* 2480 */ 1878, 2337, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, + /* 2490 */ 1878, 1878, 1878, 2285, 1878, 736, 1878, 1878, 1878, 1878, + /* 2500 */ 2337, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, + /* 2510 */ 1878, 1878, 2285, 1878, 736, 1878, 1878, 1878, 1878, 1878, + /* 2520 */ 1878, 1878, 1878, 1878, 1878, 1878, 2319, 1878, 1878, 1878, + /* 2530 */ 1878, 1878, 1878, 1878, 2318, 1878, 1878, 2356, 1878, 737, + /* 2540 */ 345, 2320, 740, 2322, 2323, 735, 1878, 730, 1878, 1878, + /* 2550 */ 1878, 1878, 1878, 2318, 1878, 2319, 2356, 1878, 1878, 354, + /* 2560 */ 2320, 740, 2322, 2323, 735, 1878, 730, 2337, 737, 1878, + /* 2570 */ 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 2285, + /* 2580 */ 1878, 736, 1878, 1878, 2319, 1878, 1878, 1878, 1878, 1878, + /* 2590 */ 1878, 1878, 1878, 1878, 1878, 1878, 2337, 737, 1878, 1878, + /* 2600 */ 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 2285, 1878, + /* 2610 */ 736, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, + /* 2620 */ 2318, 1878, 2319, 2356, 1878, 2337, 346, 2320, 740, 2322, + /* 2630 */ 2323, 735, 1878, 730, 1878, 737, 1878, 2285, 1878, 736, + /* 2640 */ 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 2318, + /* 2650 */ 1878, 1878, 2356, 1878, 1878, 355, 2320, 740, 2322, 2323, + /* 2660 */ 735, 1878, 730, 2337, 1878, 1878, 1878, 1878, 1878, 1878, + /* 2670 */ 1878, 1878, 1878, 1878, 1878, 2285, 1878, 736, 2318, 2319, + /* 2680 */ 1878, 2356, 1878, 1878, 347, 2320, 740, 2322, 2323, 735, + /* 2690 */ 1878, 730, 737, 1878, 1878, 1878, 1878, 2319, 1878, 1878, + /* 2700 */ 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, + /* 2710 */ 737, 1878, 1878, 1878, 1878, 1878, 2318, 1878, 1878, 2356, + /* 2720 */ 2337, 1878, 361, 2320, 740, 2322, 2323, 735, 1878, 730, + /* 2730 */ 1878, 1878, 2285, 1878, 736, 1878, 1878, 1878, 2337, 1878, + /* 2740 */ 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, + /* 2750 */ 2285, 1878, 736, 1878, 2319, 1878, 1878, 1878, 1878, 1878, + /* 2760 */ 1878, 1878, 1878, 1878, 1878, 1878, 1878, 737, 1878, 1878, + /* 2770 */ 1878, 1878, 1878, 2318, 2319, 1878, 2356, 1878, 1878, 362, + /* 2780 */ 2320, 740, 2322, 2323, 735, 1878, 730, 737, 1878, 1878, + /* 2790 */ 2319, 2318, 1878, 1878, 2356, 2337, 1878, 2331, 2320, 740, + /* 2800 */ 2322, 2323, 735, 737, 730, 1878, 1878, 2285, 1878, 736, + /* 2810 */ 1878, 1878, 1878, 1878, 1878, 2337, 1878, 1878, 1878, 1878, + /* 2820 */ 1878, 1878, 1878, 1878, 1878, 1878, 1878, 2285, 1878, 736, + /* 2830 */ 1878, 2337, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, + /* 2840 */ 1878, 1878, 1878, 2285, 1878, 736, 1878, 1878, 2318, 1878, + /* 2850 */ 1878, 2356, 1878, 1878, 2330, 2320, 740, 2322, 2323, 735, + /* 2860 */ 1878, 730, 1878, 1878, 1878, 1878, 1878, 1878, 2318, 1878, + /* 2870 */ 1878, 2356, 1878, 1878, 2329, 2320, 740, 2322, 2323, 735, + /* 2880 */ 1878, 730, 1878, 1878, 2318, 1878, 1878, 2356, 1878, 2319, + /* 2890 */ 376, 2320, 740, 2322, 2323, 735, 1878, 730, 1878, 1878, + /* 2900 */ 1878, 1878, 737, 1878, 1878, 2319, 1878, 1878, 1878, 1878, + /* 2910 */ 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 737, 1878, + /* 2920 */ 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, + /* 2930 */ 2337, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, + /* 2940 */ 1878, 1878, 2285, 1878, 736, 1878, 2337, 1878, 1878, 1878, + /* 2950 */ 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 2285, 1878, + /* 2960 */ 736, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, + /* 2970 */ 1878, 1878, 2319, 1878, 1878, 1878, 1878, 1878, 1878, 1878, + /* 2980 */ 1878, 1878, 1878, 2318, 1878, 737, 2356, 2319, 1878, 377, + /* 2990 */ 2320, 740, 2322, 2323, 735, 1878, 730, 1878, 1878, 2318, + /* 3000 */ 737, 1878, 2356, 1878, 1878, 373, 2320, 740, 2322, 2323, + /* 3010 */ 735, 1878, 730, 2337, 1878, 1878, 1878, 1878, 1878, 1878, + /* 3020 */ 1878, 1878, 1878, 1878, 1878, 2285, 1878, 736, 2337, 1878, + /* 3030 */ 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, + /* 3040 */ 2285, 1878, 736, 1878, 1878, 1878, 1878, 1878, 1878, 1878, + /* 3050 */ 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, + /* 3060 */ 1878, 1878, 1878, 1878, 1878, 1878, 2318, 1878, 1878, 2356, + /* 3070 */ 2319, 1878, 378, 2320, 740, 2322, 2323, 735, 1878, 730, + /* 3080 */ 1878, 738, 1878, 737, 2356, 1878, 1878, 352, 2320, 740, + /* 3090 */ 2322, 2323, 735, 1878, 730, 1878, 1878, 1878, 1878, 1878, + /* 3100 */ 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, + /* 3110 */ 1878, 2337, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, + /* 3120 */ 1878, 1878, 1878, 2285, 1878, 736, 1878, 1878, 1878, 1878, + /* 3130 */ 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, + /* 3140 */ 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, + /* 3150 */ 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, + /* 3160 */ 1878, 1878, 1878, 1878, 2318, 1878, 1878, 2356, 1878, 1878, + /* 3170 */ 351, 2320, 740, 2322, 2323, 735, 1878, 730, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 389, 360, 361, 472, 390, 472, 475, 355, 475, 390, - /* 10 */ 358, 359, 12, 13, 14, 404, 472, 361, 381, 475, - /* 20 */ 20, 380, 22, 0, 493, 494, 389, 494, 387, 498, - /* 30 */ 499, 498, 499, 396, 397, 35, 0, 37, 494, 461, - /* 40 */ 462, 404, 498, 499, 21, 389, 348, 24, 25, 26, - /* 50 */ 27, 28, 29, 30, 31, 32, 360, 361, 20, 361, - /* 60 */ 20, 8, 9, 33, 64, 12, 13, 14, 15, 16, - /* 70 */ 70, 360, 361, 345, 347, 21, 349, 77, 24, 25, - /* 80 */ 26, 27, 28, 29, 30, 31, 32, 389, 8, 9, - /* 90 */ 4, 380, 12, 13, 14, 15, 16, 348, 387, 401, - /* 100 */ 20, 403, 20, 103, 448, 20, 106, 34, 72, 73, + /* 0 */ 371, 382, 425, 382, 425, 361, 362, 430, 379, 390, + /* 10 */ 379, 390, 12, 13, 14, 12, 13, 398, 397, 398, + /* 20 */ 20, 20, 22, 8, 9, 381, 405, 12, 13, 14, + /* 30 */ 15, 16, 388, 361, 362, 35, 0, 37, 8, 9, + /* 40 */ 37, 33, 12, 13, 14, 15, 16, 349, 20, 361, + /* 50 */ 362, 390, 475, 361, 475, 478, 362, 478, 397, 377, + /* 60 */ 362, 390, 380, 33, 64, 0, 405, 20, 356, 381, + /* 70 */ 70, 359, 360, 496, 497, 496, 497, 77, 501, 502, + /* 80 */ 501, 502, 410, 412, 390, 414, 21, 20, 390, 24, + /* 90 */ 25, 26, 27, 28, 29, 30, 31, 32, 406, 407, + /* 100 */ 402, 409, 404, 103, 13, 413, 106, 20, 72, 73, /* 110 */ 74, 75, 76, 20, 78, 79, 80, 81, 82, 83, /* 120 */ 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, - /* 130 */ 94, 95, 96, 97, 98, 99, 355, 107, 440, 358, - /* 140 */ 359, 443, 142, 143, 446, 447, 448, 449, 450, 451, - /* 150 */ 401, 453, 424, 360, 361, 20, 458, 429, 460, 389, - /* 160 */ 107, 403, 464, 465, 468, 469, 470, 3, 472, 473, - /* 170 */ 370, 475, 360, 20, 174, 175, 418, 479, 378, 421, - /* 180 */ 422, 181, 182, 413, 20, 487, 389, 21, 106, 493, - /* 190 */ 494, 106, 106, 396, 498, 499, 196, 20, 198, 106, - /* 200 */ 472, 404, 36, 475, 38, 39, 40, 8, 9, 106, - /* 210 */ 106, 12, 13, 14, 15, 16, 176, 405, 406, 37, - /* 220 */ 408, 493, 494, 136, 412, 14, 498, 499, 228, 229, - /* 230 */ 230, 20, 232, 233, 234, 235, 236, 237, 238, 239, + /* 130 */ 94, 95, 96, 97, 98, 99, 475, 107, 361, 478, + /* 140 */ 14, 443, 142, 143, 446, 451, 20, 449, 450, 451, + /* 150 */ 452, 453, 454, 106, 456, 448, 404, 496, 497, 461, + /* 160 */ 404, 463, 501, 502, 475, 467, 468, 478, 77, 361, + /* 170 */ 362, 419, 361, 362, 422, 423, 176, 177, 422, 423, + /* 180 */ 482, 474, 20, 183, 184, 496, 497, 37, 490, 381, + /* 190 */ 501, 502, 103, 20, 417, 418, 388, 346, 198, 106, + /* 200 */ 200, 182, 378, 200, 49, 190, 117, 118, 119, 120, + /* 210 */ 121, 122, 123, 124, 125, 126, 392, 128, 129, 130, + /* 220 */ 131, 132, 133, 134, 361, 362, 402, 77, 39, 40, + /* 230 */ 230, 231, 232, 232, 234, 235, 236, 237, 238, 239, /* 240 */ 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, - /* 250 */ 12, 13, 0, 360, 361, 18, 176, 20, 20, 77, - /* 260 */ 22, 468, 469, 470, 27, 472, 473, 30, 14, 70, - /* 270 */ 64, 107, 35, 35, 20, 37, 24, 25, 26, 27, - /* 280 */ 28, 29, 30, 31, 32, 72, 73, 74, 51, 69, - /* 290 */ 53, 4, 79, 80, 81, 58, 209, 210, 85, 195, - /* 300 */ 116, 197, 64, 90, 91, 92, 93, 0, 70, 96, - /* 310 */ 230, 105, 99, 114, 108, 77, 12, 13, 14, 15, - /* 320 */ 16, 8, 9, 348, 116, 12, 13, 14, 15, 16, - /* 330 */ 385, 227, 106, 46, 47, 48, 361, 180, 363, 356, - /* 340 */ 176, 103, 105, 360, 106, 362, 12, 13, 266, 403, - /* 350 */ 8, 9, 266, 116, 12, 13, 14, 15, 16, 266, - /* 360 */ 467, 468, 469, 470, 389, 472, 473, 421, 422, 266, - /* 370 */ 266, 37, 173, 356, 166, 33, 401, 360, 403, 362, - /* 380 */ 142, 143, 437, 146, 147, 174, 149, 150, 151, 152, - /* 390 */ 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, - /* 400 */ 163, 164, 165, 20, 167, 168, 169, 230, 171, 172, - /* 410 */ 14, 14, 174, 175, 177, 440, 20, 20, 443, 181, - /* 420 */ 182, 446, 447, 448, 449, 450, 451, 20, 453, 272, - /* 430 */ 273, 274, 69, 458, 196, 460, 198, 39, 40, 464, - /* 440 */ 465, 230, 135, 136, 137, 138, 139, 140, 141, 107, - /* 450 */ 348, 20, 253, 254, 255, 256, 257, 258, 259, 260, - /* 460 */ 261, 262, 263, 361, 250, 348, 228, 229, 230, 424, - /* 470 */ 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, - /* 480 */ 242, 243, 244, 245, 246, 247, 248, 249, 250, 12, - /* 490 */ 13, 389, 266, 369, 20, 388, 20, 20, 22, 22, - /* 500 */ 20, 188, 22, 401, 13, 403, 348, 400, 110, 111, - /* 510 */ 386, 113, 35, 37, 37, 2, 13, 472, 401, 395, - /* 520 */ 475, 8, 9, 348, 173, 12, 13, 14, 15, 16, - /* 530 */ 369, 55, 198, 135, 20, 55, 361, 139, 493, 494, - /* 540 */ 37, 64, 440, 498, 499, 443, 360, 70, 446, 447, - /* 550 */ 448, 449, 450, 451, 77, 453, 395, 228, 456, 401, - /* 560 */ 458, 459, 460, 77, 389, 0, 464, 465, 77, 86, - /* 570 */ 103, 174, 376, 142, 143, 379, 401, 348, 403, 348, - /* 580 */ 103, 174, 175, 106, 117, 118, 119, 120, 121, 122, - /* 590 */ 123, 124, 125, 126, 348, 128, 129, 130, 131, 132, - /* 600 */ 133, 134, 416, 417, 253, 292, 277, 278, 279, 280, - /* 610 */ 281, 282, 283, 230, 263, 440, 142, 143, 443, 142, - /* 620 */ 143, 446, 447, 448, 449, 450, 451, 230, 453, 390, - /* 630 */ 401, 148, 401, 458, 69, 460, 116, 8, 9, 464, - /* 640 */ 465, 12, 13, 14, 15, 16, 399, 401, 389, 402, - /* 650 */ 403, 174, 175, 170, 2, 181, 182, 13, 181, 182, - /* 660 */ 8, 9, 487, 389, 12, 13, 14, 15, 16, 35, - /* 670 */ 411, 390, 413, 196, 0, 198, 22, 389, 404, 360, - /* 680 */ 361, 37, 360, 361, 396, 51, 360, 361, 348, 51, - /* 690 */ 176, 37, 404, 59, 60, 61, 62, 59, 64, 380, - /* 700 */ 62, 63, 380, 348, 137, 228, 229, 230, 141, 232, - /* 710 */ 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, - /* 720 */ 243, 244, 245, 246, 247, 248, 249, 12, 13, 14, - /* 730 */ 348, 360, 361, 367, 22, 20, 107, 22, 348, 105, - /* 740 */ 348, 401, 108, 361, 230, 363, 72, 73, 74, 37, - /* 750 */ 35, 380, 37, 79, 80, 81, 401, 103, 392, 85, - /* 760 */ 472, 348, 389, 475, 90, 91, 92, 93, 0, 396, - /* 770 */ 96, 389, 205, 99, 361, 208, 363, 404, 211, 64, - /* 780 */ 213, 493, 494, 401, 348, 403, 498, 499, 250, 77, - /* 790 */ 252, 401, 77, 401, 468, 469, 470, 348, 472, 473, - /* 800 */ 424, 33, 389, 8, 9, 429, 390, 12, 13, 14, - /* 810 */ 15, 16, 178, 179, 401, 103, 403, 390, 103, 185, - /* 820 */ 186, 106, 440, 360, 361, 443, 348, 348, 446, 447, - /* 830 */ 448, 449, 450, 451, 22, 453, 381, 401, 204, 361, - /* 840 */ 458, 377, 460, 380, 389, 430, 464, 465, 472, 37, - /* 850 */ 401, 475, 397, 440, 20, 391, 443, 142, 143, 446, - /* 860 */ 447, 448, 449, 450, 451, 401, 453, 389, 381, 493, - /* 870 */ 494, 458, 33, 460, 498, 499, 389, 464, 465, 401, - /* 880 */ 401, 403, 20, 445, 397, 348, 50, 8, 9, 174, - /* 890 */ 175, 12, 13, 14, 15, 16, 181, 182, 0, 135, - /* 900 */ 136, 137, 138, 139, 140, 141, 390, 443, 196, 471, - /* 910 */ 198, 196, 378, 198, 457, 103, 459, 453, 440, 360, - /* 920 */ 361, 443, 360, 361, 446, 447, 448, 449, 450, 451, - /* 930 */ 452, 453, 454, 455, 3, 360, 361, 0, 401, 380, - /* 940 */ 228, 229, 380, 228, 229, 230, 107, 232, 233, 234, - /* 950 */ 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, - /* 960 */ 245, 246, 247, 248, 249, 12, 13, 22, 348, 360, - /* 970 */ 361, 4, 389, 20, 349, 22, 424, 381, 424, 396, - /* 980 */ 389, 361, 37, 363, 409, 389, 19, 404, 35, 380, - /* 990 */ 37, 348, 389, 397, 367, 404, 360, 361, 20, 396, - /* 1000 */ 360, 361, 35, 136, 137, 360, 361, 404, 141, 389, - /* 1010 */ 176, 384, 176, 191, 402, 403, 380, 64, 51, 392, - /* 1020 */ 184, 401, 77, 403, 472, 58, 472, 475, 135, 475, - /* 1030 */ 77, 64, 139, 135, 136, 137, 138, 139, 140, 141, - /* 1040 */ 218, 219, 42, 424, 401, 493, 494, 493, 494, 409, - /* 1050 */ 498, 499, 498, 499, 409, 176, 103, 360, 361, 106, - /* 1060 */ 440, 348, 348, 443, 230, 377, 446, 447, 448, 449, - /* 1070 */ 450, 451, 105, 453, 361, 108, 363, 380, 458, 391, - /* 1080 */ 460, 360, 361, 348, 464, 465, 360, 361, 457, 401, - /* 1090 */ 459, 472, 230, 348, 475, 142, 143, 4, 161, 374, - /* 1100 */ 375, 380, 389, 360, 361, 456, 380, 170, 459, 360, - /* 1110 */ 361, 33, 493, 494, 401, 401, 403, 498, 499, 348, - /* 1120 */ 360, 361, 389, 380, 0, 360, 361, 174, 175, 380, - /* 1130 */ 397, 443, 444, 0, 181, 182, 401, 360, 361, 445, - /* 1140 */ 380, 453, 1, 2, 377, 380, 401, 360, 361, 196, - /* 1150 */ 33, 198, 174, 440, 374, 375, 443, 380, 391, 446, - /* 1160 */ 447, 448, 449, 450, 451, 471, 453, 380, 401, 56, - /* 1170 */ 57, 458, 401, 460, 14, 15, 16, 464, 465, 365, - /* 1180 */ 366, 228, 229, 230, 51, 232, 233, 234, 235, 236, - /* 1190 */ 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, - /* 1200 */ 247, 248, 249, 12, 13, 33, 348, 445, 230, 398, - /* 1210 */ 443, 20, 401, 22, 365, 366, 351, 352, 287, 361, - /* 1220 */ 453, 363, 398, 0, 398, 401, 35, 401, 37, 382, - /* 1230 */ 47, 48, 385, 471, 264, 265, 0, 33, 33, 109, - /* 1240 */ 109, 109, 112, 112, 112, 22, 64, 389, 107, 45, - /* 1250 */ 45, 109, 0, 0, 112, 64, 212, 33, 214, 401, - /* 1260 */ 70, 403, 33, 33, 33, 265, 414, 33, 77, 142, - /* 1270 */ 143, 33, 0, 33, 22, 22, 33, 33, 42, 107, - /* 1280 */ 1, 2, 33, 33, 33, 37, 49, 502, 33, 33, - /* 1290 */ 108, 106, 491, 13, 103, 33, 33, 106, 440, 348, - /* 1300 */ 115, 443, 33, 13, 446, 447, 448, 449, 450, 451, - /* 1310 */ 364, 453, 361, 37, 484, 37, 458, 37, 460, 12, - /* 1320 */ 13, 389, 464, 465, 52, 377, 377, 37, 414, 22, - /* 1330 */ 414, 107, 490, 142, 143, 490, 107, 107, 107, 364, - /* 1340 */ 389, 107, 35, 106, 37, 107, 222, 107, 423, 490, - /* 1350 */ 107, 107, 401, 490, 403, 77, 107, 107, 107, 361, - /* 1360 */ 359, 268, 107, 107, 414, 174, 175, 289, 400, 107, - /* 1370 */ 107, 64, 181, 182, 414, 414, 107, 474, 495, 466, - /* 1380 */ 269, 477, 379, 425, 77, 51, 442, 196, 42, 198, - /* 1390 */ 20, 440, 211, 441, 443, 439, 434, 446, 447, 448, - /* 1400 */ 449, 450, 451, 369, 453, 434, 369, 194, 291, 458, - /* 1410 */ 103, 460, 427, 20, 360, 464, 465, 20, 228, 228, - /* 1420 */ 229, 230, 361, 232, 233, 234, 235, 236, 237, 238, - /* 1430 */ 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, - /* 1440 */ 249, 45, 18, 410, 361, 410, 198, 23, 173, 407, - /* 1450 */ 360, 410, 361, 407, 360, 407, 104, 373, 102, 372, - /* 1460 */ 360, 101, 360, 371, 40, 41, 360, 360, 44, 20, - /* 1470 */ 50, 353, 357, 353, 198, 20, 357, 434, 54, 369, - /* 1480 */ 403, 369, 20, 362, 348, 20, 426, 20, 362, 65, - /* 1490 */ 66, 67, 68, 417, 369, 438, 353, 361, 369, 360, - /* 1500 */ 353, 351, 401, 196, 369, 198, 369, 369, 360, 351, - /* 1510 */ 401, 389, 389, 215, 106, 401, 436, 389, 202, 434, - /* 1520 */ 201, 367, 433, 389, 367, 389, 200, 432, 431, 389, - /* 1530 */ 106, 360, 483, 389, 389, 228, 229, 401, 389, 403, - /* 1540 */ 389, 389, 389, 276, 284, 275, 483, 483, 486, 242, - /* 1550 */ 243, 244, 245, 246, 247, 248, 187, 401, 403, 485, - /* 1560 */ 286, 482, 285, 481, 270, 497, 480, 496, 144, 503, - /* 1570 */ 265, 425, 290, 288, 293, 361, 440, 20, 419, 443, - /* 1580 */ 419, 478, 446, 447, 448, 449, 450, 451, 425, 453, - /* 1590 */ 116, 267, 476, 367, 458, 362, 460, 419, 401, 367, - /* 1600 */ 464, 465, 401, 401, 401, 419, 179, 445, 401, 415, - /* 1610 */ 385, 106, 188, 189, 190, 106, 401, 193, 22, 361, - /* 1620 */ 393, 367, 38, 350, 367, 360, 367, 463, 428, 420, - /* 1630 */ 206, 207, 420, 435, 368, 346, 0, 354, 0, 353, - /* 1640 */ 0, 217, 45, 348, 220, 0, 37, 223, 224, 225, - /* 1650 */ 226, 227, 221, 37, 383, 37, 361, 37, 221, 0, - /* 1660 */ 37, 37, 221, 37, 0, 221, 0, 383, 37, 348, - /* 1670 */ 383, 0, 22, 0, 37, 216, 0, 204, 0, 204, - /* 1680 */ 198, 205, 361, 196, 389, 0, 0, 0, 192, 191, - /* 1690 */ 266, 0, 0, 147, 0, 49, 401, 49, 403, 37, - /* 1700 */ 51, 0, 49, 0, 0, 45, 0, 0, 0, 0, - /* 1710 */ 389, 37, 49, 0, 0, 0, 0, 161, 0, 161, - /* 1720 */ 0, 0, 401, 0, 403, 0, 0, 0, 0, 0, - /* 1730 */ 0, 0, 0, 0, 0, 440, 348, 49, 443, 0, - /* 1740 */ 0, 446, 447, 448, 449, 450, 451, 0, 453, 361, - /* 1750 */ 0, 0, 0, 458, 0, 460, 0, 45, 0, 464, - /* 1760 */ 465, 440, 0, 22, 443, 348, 0, 446, 447, 448, - /* 1770 */ 449, 450, 451, 0, 453, 147, 146, 389, 361, 0, - /* 1780 */ 145, 460, 0, 0, 0, 464, 465, 22, 50, 401, - /* 1790 */ 22, 403, 50, 0, 37, 0, 0, 0, 37, 64, - /* 1800 */ 64, 42, 0, 0, 51, 42, 389, 64, 37, 37, - /* 1810 */ 0, 51, 42, 37, 0, 51, 49, 42, 401, 45, - /* 1820 */ 403, 33, 14, 0, 43, 0, 49, 49, 440, 42, - /* 1830 */ 0, 443, 0, 348, 446, 447, 448, 449, 450, 451, - /* 1840 */ 42, 453, 187, 0, 0, 0, 361, 0, 460, 49, - /* 1850 */ 0, 71, 464, 465, 37, 1, 51, 440, 42, 0, - /* 1860 */ 443, 37, 51, 446, 447, 448, 449, 450, 451, 42, - /* 1870 */ 453, 0, 37, 19, 389, 42, 0, 460, 37, 51, - /* 1880 */ 51, 464, 465, 0, 42, 0, 401, 0, 403, 35, - /* 1890 */ 0, 0, 0, 37, 22, 0, 22, 37, 348, 114, - /* 1900 */ 37, 112, 37, 37, 37, 51, 37, 37, 33, 0, - /* 1910 */ 37, 361, 33, 59, 60, 61, 62, 348, 64, 37, - /* 1920 */ 22, 37, 0, 37, 22, 440, 0, 22, 443, 0, - /* 1930 */ 361, 446, 447, 448, 449, 450, 451, 37, 453, 389, - /* 1940 */ 37, 53, 0, 0, 0, 37, 0, 22, 20, 37, - /* 1950 */ 37, 401, 37, 403, 0, 107, 37, 106, 389, 105, - /* 1960 */ 22, 106, 108, 0, 0, 0, 176, 22, 199, 3, - /* 1970 */ 401, 179, 403, 488, 489, 176, 271, 176, 3, 49, - /* 1980 */ 33, 50, 176, 106, 50, 107, 106, 183, 107, 203, - /* 1990 */ 440, 102, 348, 443, 140, 183, 446, 447, 448, 449, - /* 2000 */ 450, 451, 33, 453, 33, 361, 107, 106, 104, 440, - /* 2010 */ 33, 49, 443, 106, 33, 446, 447, 448, 449, 450, - /* 2020 */ 451, 107, 453, 106, 33, 37, 106, 37, 107, 460, - /* 2030 */ 107, 37, 178, 389, 465, 37, 37, 37, 49, 185, - /* 2040 */ 107, 33, 107, 0, 49, 401, 42, 403, 0, 0, - /* 2050 */ 500, 501, 42, 33, 106, 106, 115, 107, 204, 348, - /* 2060 */ 107, 106, 271, 106, 106, 271, 106, 49, 2, 251, - /* 2070 */ 49, 178, 361, 264, 180, 22, 104, 104, 49, 22, - /* 2080 */ 228, 107, 106, 116, 440, 348, 106, 443, 231, 107, - /* 2090 */ 446, 447, 448, 449, 450, 451, 37, 453, 361, 106, - /* 2100 */ 389, 37, 37, 107, 107, 394, 37, 106, 106, 106, - /* 2110 */ 127, 106, 401, 107, 403, 37, 107, 106, 37, 107, - /* 2120 */ 106, 37, 107, 106, 33, 106, 389, 37, 22, 107, - /* 2130 */ 107, 394, 106, 489, 127, 37, 106, 106, 401, 106, - /* 2140 */ 403, 71, 70, 127, 37, 37, 37, 37, 37, 37, - /* 2150 */ 37, 440, 127, 37, 443, 348, 77, 446, 447, 448, - /* 2160 */ 449, 450, 451, 100, 453, 77, 33, 100, 361, 37, - /* 2170 */ 22, 37, 37, 37, 37, 37, 77, 440, 37, 37, - /* 2180 */ 443, 37, 348, 446, 447, 448, 449, 450, 451, 37, - /* 2190 */ 453, 37, 22, 0, 37, 361, 389, 37, 51, 0, - /* 2200 */ 42, 37, 51, 42, 0, 37, 51, 42, 401, 0, - /* 2210 */ 403, 37, 0, 51, 42, 37, 37, 0, 22, 33, - /* 2220 */ 22, 21, 21, 389, 22, 22, 20, 504, 504, 504, - /* 2230 */ 504, 504, 504, 504, 504, 401, 504, 403, 504, 504, - /* 2240 */ 504, 504, 504, 504, 504, 504, 504, 440, 504, 504, - /* 2250 */ 443, 504, 504, 446, 447, 448, 449, 450, 451, 504, - /* 2260 */ 453, 504, 504, 504, 504, 504, 348, 504, 504, 504, - /* 2270 */ 504, 504, 504, 504, 440, 504, 504, 443, 504, 361, - /* 2280 */ 446, 447, 448, 449, 450, 451, 504, 453, 348, 504, - /* 2290 */ 504, 504, 504, 504, 504, 504, 504, 504, 504, 492, - /* 2300 */ 504, 361, 504, 504, 504, 504, 504, 389, 504, 504, - /* 2310 */ 504, 504, 394, 504, 504, 504, 504, 504, 504, 401, - /* 2320 */ 504, 403, 504, 504, 504, 504, 504, 504, 504, 389, - /* 2330 */ 504, 504, 504, 504, 504, 501, 504, 504, 504, 504, - /* 2340 */ 504, 401, 504, 403, 504, 504, 504, 504, 504, 504, - /* 2350 */ 504, 504, 504, 504, 504, 504, 504, 504, 440, 504, - /* 2360 */ 504, 443, 504, 504, 446, 447, 448, 449, 450, 451, - /* 2370 */ 504, 453, 504, 504, 504, 504, 504, 504, 504, 504, - /* 2380 */ 440, 504, 504, 443, 504, 504, 446, 447, 448, 449, - /* 2390 */ 450, 451, 504, 453, 348, 455, 504, 504, 504, 504, - /* 2400 */ 504, 504, 504, 504, 504, 504, 504, 361, 504, 504, - /* 2410 */ 504, 504, 504, 504, 504, 504, 504, 504, 504, 504, - /* 2420 */ 504, 348, 504, 504, 504, 504, 504, 504, 504, 504, - /* 2430 */ 504, 504, 504, 504, 361, 389, 504, 504, 504, 504, - /* 2440 */ 394, 504, 504, 504, 504, 504, 504, 401, 504, 403, - /* 2450 */ 504, 504, 504, 504, 504, 504, 504, 504, 504, 504, - /* 2460 */ 504, 504, 389, 504, 504, 504, 504, 394, 504, 504, - /* 2470 */ 504, 504, 504, 504, 401, 504, 403, 504, 504, 504, - /* 2480 */ 504, 504, 504, 504, 504, 504, 440, 348, 504, 443, - /* 2490 */ 504, 504, 446, 447, 448, 449, 450, 451, 504, 453, - /* 2500 */ 361, 504, 504, 504, 348, 504, 504, 504, 504, 504, - /* 2510 */ 504, 504, 504, 440, 504, 504, 443, 361, 504, 446, - /* 2520 */ 447, 448, 449, 450, 451, 504, 453, 504, 389, 504, - /* 2530 */ 504, 504, 504, 504, 504, 504, 504, 504, 504, 504, - /* 2540 */ 401, 504, 403, 504, 504, 389, 504, 504, 504, 504, - /* 2550 */ 504, 504, 504, 504, 504, 504, 504, 401, 504, 403, - /* 2560 */ 504, 504, 504, 504, 504, 504, 504, 504, 504, 504, - /* 2570 */ 504, 504, 504, 504, 504, 504, 504, 504, 504, 440, - /* 2580 */ 504, 504, 443, 504, 348, 446, 447, 448, 449, 450, - /* 2590 */ 451, 504, 453, 504, 504, 504, 440, 361, 504, 443, - /* 2600 */ 504, 504, 446, 447, 448, 449, 450, 451, 504, 453, - /* 2610 */ 504, 504, 504, 504, 504, 348, 504, 504, 504, 504, - /* 2620 */ 504, 504, 504, 504, 504, 389, 504, 504, 361, 504, - /* 2630 */ 504, 504, 504, 504, 504, 504, 504, 401, 504, 403, - /* 2640 */ 504, 504, 504, 504, 504, 504, 504, 504, 504, 504, - /* 2650 */ 348, 504, 504, 504, 504, 504, 389, 504, 504, 504, - /* 2660 */ 504, 504, 504, 361, 504, 504, 504, 504, 401, 504, - /* 2670 */ 403, 504, 504, 504, 504, 504, 440, 504, 504, 443, - /* 2680 */ 504, 504, 446, 447, 448, 449, 450, 451, 504, 453, - /* 2690 */ 504, 389, 504, 504, 504, 504, 504, 504, 504, 504, - /* 2700 */ 504, 504, 504, 401, 504, 403, 504, 440, 504, 504, - /* 2710 */ 443, 504, 504, 446, 447, 448, 449, 450, 451, 504, - /* 2720 */ 453, 504, 504, 504, 504, 504, 504, 504, 504, 504, - /* 2730 */ 504, 504, 504, 504, 504, 504, 504, 504, 504, 504, - /* 2740 */ 504, 504, 440, 348, 504, 443, 504, 504, 446, 447, - /* 2750 */ 448, 449, 450, 451, 504, 453, 361, 504, 504, 504, - /* 2760 */ 504, 504, 504, 504, 504, 504, 504, 504, 504, 504, - /* 2770 */ 348, 504, 504, 504, 504, 504, 504, 504, 504, 504, - /* 2780 */ 504, 504, 504, 361, 389, 504, 504, 504, 504, 504, - /* 2790 */ 504, 504, 504, 504, 504, 504, 401, 504, 403, 504, - /* 2800 */ 504, 504, 504, 504, 504, 504, 504, 504, 504, 504, - /* 2810 */ 504, 389, 504, 504, 504, 504, 504, 504, 504, 504, - /* 2820 */ 504, 504, 504, 401, 504, 403, 504, 504, 504, 504, - /* 2830 */ 504, 504, 504, 504, 504, 440, 348, 504, 443, 504, - /* 2840 */ 504, 446, 447, 448, 449, 450, 451, 504, 453, 361, - /* 2850 */ 504, 504, 504, 348, 504, 504, 504, 504, 504, 504, - /* 2860 */ 504, 504, 440, 504, 504, 443, 361, 504, 446, 447, - /* 2870 */ 448, 449, 450, 451, 504, 453, 504, 389, 504, 504, - /* 2880 */ 504, 504, 504, 504, 504, 504, 504, 504, 504, 401, - /* 2890 */ 504, 403, 504, 504, 389, 504, 504, 504, 504, 504, - /* 2900 */ 504, 504, 504, 504, 504, 504, 401, 504, 403, 504, - /* 2910 */ 504, 504, 504, 504, 504, 504, 504, 504, 504, 504, - /* 2920 */ 504, 504, 504, 504, 504, 504, 504, 504, 440, 504, - /* 2930 */ 504, 443, 504, 348, 446, 447, 448, 449, 450, 451, - /* 2940 */ 504, 453, 504, 504, 504, 440, 361, 504, 443, 504, - /* 2950 */ 504, 446, 447, 448, 449, 450, 451, 504, 453, 504, - /* 2960 */ 504, 504, 504, 504, 348, 504, 504, 504, 504, 504, - /* 2970 */ 504, 504, 504, 504, 389, 504, 504, 361, 504, 504, - /* 2980 */ 504, 504, 504, 504, 504, 504, 401, 504, 403, 504, - /* 2990 */ 504, 504, 504, 504, 504, 504, 504, 504, 504, 348, - /* 3000 */ 504, 504, 504, 504, 504, 389, 504, 504, 504, 504, - /* 3010 */ 504, 504, 361, 504, 504, 504, 504, 401, 504, 403, - /* 3020 */ 504, 504, 504, 504, 504, 440, 504, 504, 443, 504, - /* 3030 */ 504, 446, 447, 448, 449, 450, 451, 504, 453, 504, - /* 3040 */ 389, 504, 504, 504, 504, 504, 504, 504, 504, 504, - /* 3050 */ 504, 504, 401, 504, 403, 504, 440, 504, 504, 443, - /* 3060 */ 504, 504, 446, 447, 448, 449, 450, 451, 504, 453, - /* 3070 */ 504, 504, 504, 504, 504, 504, 504, 504, 504, 504, - /* 3080 */ 504, 504, 504, 504, 504, 504, 504, 504, 504, 504, - /* 3090 */ 504, 440, 348, 504, 443, 504, 504, 446, 447, 448, - /* 3100 */ 449, 450, 451, 504, 453, 361, 504, 504, 504, 504, - /* 3110 */ 504, 504, 504, 504, 504, 504, 504, 504, 504, 348, - /* 3120 */ 504, 504, 504, 504, 504, 504, 504, 504, 504, 504, - /* 3130 */ 504, 504, 361, 389, 504, 504, 504, 504, 504, 504, - /* 3140 */ 504, 504, 504, 504, 504, 401, 504, 403, 504, 504, - /* 3150 */ 504, 504, 504, 504, 504, 504, 504, 504, 504, 504, - /* 3160 */ 389, 504, 504, 504, 504, 504, 504, 504, 504, 504, - /* 3170 */ 504, 504, 401, 504, 403, 504, 504, 504, 504, 504, - /* 3180 */ 504, 504, 504, 504, 440, 348, 504, 443, 504, 504, - /* 3190 */ 446, 447, 448, 449, 450, 451, 504, 453, 361, 504, - /* 3200 */ 504, 504, 348, 504, 504, 504, 504, 504, 504, 504, - /* 3210 */ 504, 440, 504, 504, 443, 361, 504, 446, 447, 448, - /* 3220 */ 449, 450, 451, 504, 453, 504, 389, 504, 504, 504, - /* 3230 */ 504, 504, 504, 504, 504, 504, 504, 504, 401, 504, - /* 3240 */ 403, 504, 504, 389, 504, 504, 504, 504, 504, 504, - /* 3250 */ 504, 504, 504, 504, 504, 401, 504, 403, 504, 504, - /* 3260 */ 504, 504, 504, 504, 504, 504, 504, 504, 504, 504, - /* 3270 */ 504, 504, 504, 504, 504, 504, 504, 440, 504, 504, - /* 3280 */ 443, 504, 348, 446, 447, 448, 449, 450, 451, 504, - /* 3290 */ 453, 504, 504, 504, 440, 361, 504, 443, 504, 504, - /* 3300 */ 446, 447, 448, 449, 450, 451, 504, 453, 504, 504, - /* 3310 */ 504, 504, 504, 348, 504, 504, 504, 504, 504, 504, - /* 3320 */ 504, 504, 504, 389, 504, 504, 361, 504, 504, 504, - /* 3330 */ 504, 504, 504, 504, 504, 401, 504, 403, 504, 504, - /* 3340 */ 504, 504, 504, 504, 504, 504, 504, 504, 348, 504, - /* 3350 */ 504, 504, 504, 504, 389, 504, 504, 504, 504, 504, - /* 3360 */ 504, 361, 504, 504, 504, 504, 401, 504, 403, 504, - /* 3370 */ 504, 504, 504, 504, 440, 504, 504, 443, 504, 504, - /* 3380 */ 446, 447, 448, 449, 450, 451, 504, 453, 504, 389, - /* 3390 */ 504, 504, 504, 504, 504, 504, 504, 504, 504, 504, - /* 3400 */ 504, 401, 504, 403, 504, 440, 504, 504, 443, 504, - /* 3410 */ 504, 446, 447, 448, 449, 450, 451, 504, 453, 504, - /* 3420 */ 504, 504, 504, 504, 504, 504, 504, 504, 504, 504, - /* 3430 */ 504, 504, 504, 504, 504, 504, 504, 504, 504, 504, - /* 3440 */ 440, 348, 504, 443, 504, 504, 446, 447, 448, 449, - /* 3450 */ 450, 451, 504, 453, 361, 504, 504, 504, 504, 504, - /* 3460 */ 504, 504, 504, 504, 504, 504, 504, 504, 348, 504, - /* 3470 */ 504, 504, 504, 504, 504, 504, 504, 504, 504, 504, - /* 3480 */ 504, 361, 389, 504, 504, 504, 504, 504, 504, 504, - /* 3490 */ 504, 504, 504, 504, 401, 504, 403, 504, 504, 504, - /* 3500 */ 504, 504, 504, 504, 504, 504, 504, 504, 504, 389, - /* 3510 */ 504, 504, 504, 504, 504, 504, 504, 504, 504, 504, - /* 3520 */ 504, 401, 504, 403, 504, 504, 504, 504, 504, 504, - /* 3530 */ 504, 504, 504, 440, 348, 504, 443, 504, 504, 446, - /* 3540 */ 447, 448, 449, 450, 451, 504, 453, 361, 504, 504, - /* 3550 */ 504, 504, 504, 504, 504, 504, 504, 504, 504, 504, - /* 3560 */ 440, 504, 504, 443, 504, 504, 446, 447, 448, 449, - /* 3570 */ 450, 451, 504, 453, 504, 389, 504, 504, 504, 504, - /* 3580 */ 504, 504, 504, 504, 504, 504, 504, 401, 504, 403, - /* 3590 */ 504, 504, 504, 504, 504, 504, 504, 504, 504, 504, - /* 3600 */ 504, 504, 504, 504, 504, 504, 504, 504, 504, 504, - /* 3610 */ 504, 504, 504, 504, 504, 504, 504, 504, 504, 504, - /* 3620 */ 504, 504, 504, 504, 504, 504, 440, 504, 504, 443, - /* 3630 */ 504, 504, 446, 447, 448, 449, 450, 451, 504, 453, - /* 3640 */ 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - /* 3650 */ 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - /* 3660 */ 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - /* 3670 */ 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - /* 3680 */ 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - /* 3690 */ 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - /* 3700 */ 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - /* 3710 */ 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - /* 3720 */ 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - /* 3730 */ 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - /* 3740 */ 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - /* 3750 */ 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - /* 3760 */ 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - /* 3770 */ 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - /* 3780 */ 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - /* 3790 */ 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - /* 3800 */ 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - /* 3810 */ 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - /* 3820 */ 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - /* 3830 */ 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - /* 3840 */ 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - /* 3850 */ 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - /* 3860 */ 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - /* 3870 */ 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - /* 3880 */ 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - /* 3890 */ 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - /* 3900 */ 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - /* 3910 */ 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - /* 3920 */ 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - /* 3930 */ 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - /* 3940 */ 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - /* 3950 */ 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - /* 3960 */ 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - /* 3970 */ 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - /* 3980 */ 345, 345, 345, 345, 345, + /* 250 */ 250, 251, 12, 13, 361, 362, 69, 18, 106, 20, + /* 260 */ 20, 106, 22, 176, 177, 349, 27, 390, 106, 30, + /* 270 */ 446, 447, 370, 410, 35, 35, 425, 37, 362, 370, + /* 280 */ 456, 430, 471, 472, 473, 4, 475, 476, 20, 478, + /* 290 */ 51, 414, 53, 274, 275, 276, 387, 58, 396, 110, + /* 300 */ 111, 293, 113, 410, 64, 396, 390, 496, 497, 294, + /* 310 */ 70, 20, 501, 502, 72, 73, 74, 77, 402, 448, + /* 320 */ 404, 79, 80, 81, 135, 22, 475, 85, 139, 478, + /* 330 */ 361, 362, 90, 91, 92, 93, 14, 20, 96, 21, + /* 340 */ 37, 99, 20, 103, 105, 474, 106, 496, 497, 197, + /* 350 */ 381, 199, 501, 502, 36, 116, 38, 39, 40, 443, + /* 360 */ 356, 268, 446, 359, 360, 449, 450, 451, 452, 453, + /* 370 */ 454, 455, 456, 457, 458, 12, 13, 14, 15, 16, + /* 380 */ 77, 229, 142, 143, 106, 146, 147, 106, 149, 150, + /* 390 */ 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, + /* 400 */ 161, 162, 163, 164, 165, 232, 167, 168, 169, 18, + /* 410 */ 464, 465, 173, 174, 23, 2, 176, 177, 179, 64, + /* 420 */ 268, 8, 9, 183, 184, 12, 13, 14, 15, 16, + /* 430 */ 268, 40, 41, 142, 143, 44, 361, 69, 198, 400, + /* 440 */ 200, 0, 403, 404, 86, 54, 178, 8, 9, 106, + /* 450 */ 33, 12, 13, 14, 15, 16, 65, 66, 67, 68, + /* 460 */ 105, 8, 9, 108, 349, 12, 13, 14, 15, 16, + /* 470 */ 230, 231, 232, 20, 234, 235, 236, 237, 238, 239, + /* 480 */ 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, + /* 490 */ 250, 251, 252, 12, 13, 33, 51, 106, 176, 361, + /* 500 */ 362, 20, 386, 22, 59, 1, 148, 62, 63, 70, + /* 510 */ 435, 436, 20, 72, 73, 74, 35, 402, 37, 381, + /* 520 */ 79, 80, 81, 19, 361, 362, 85, 172, 170, 171, + /* 530 */ 14, 90, 91, 92, 93, 144, 20, 96, 357, 35, + /* 540 */ 99, 64, 361, 230, 363, 64, 268, 20, 349, 268, + /* 550 */ 389, 70, 50, 114, 232, 51, 440, 175, 77, 361, + /* 560 */ 362, 362, 401, 59, 60, 61, 62, 21, 64, 107, + /* 570 */ 24, 25, 26, 27, 28, 29, 30, 31, 32, 381, + /* 580 */ 42, 190, 191, 192, 103, 108, 195, 106, 252, 390, + /* 590 */ 254, 22, 279, 280, 281, 282, 283, 284, 285, 208, + /* 600 */ 209, 402, 116, 404, 368, 3, 37, 361, 362, 105, + /* 610 */ 219, 268, 108, 222, 175, 20, 225, 226, 227, 228, + /* 620 */ 229, 385, 20, 142, 143, 0, 20, 381, 22, 393, + /* 630 */ 348, 178, 350, 470, 471, 472, 473, 255, 475, 476, + /* 640 */ 361, 362, 443, 37, 140, 446, 77, 265, 449, 450, + /* 650 */ 451, 452, 453, 454, 349, 456, 390, 176, 177, 268, + /* 660 */ 461, 55, 463, 2, 183, 184, 467, 468, 368, 8, + /* 670 */ 9, 405, 103, 12, 13, 14, 15, 16, 0, 198, + /* 680 */ 178, 200, 361, 362, 180, 232, 361, 362, 186, 490, + /* 690 */ 13, 187, 176, 393, 255, 256, 257, 258, 259, 260, + /* 700 */ 261, 262, 263, 264, 265, 178, 381, 402, 291, 107, + /* 710 */ 206, 230, 231, 232, 37, 234, 235, 236, 237, 238, + /* 720 */ 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, + /* 730 */ 249, 250, 251, 12, 13, 14, 349, 142, 143, 14, + /* 740 */ 357, 20, 349, 22, 361, 20, 363, 69, 232, 362, + /* 750 */ 471, 472, 473, 135, 475, 476, 35, 139, 37, 232, + /* 760 */ 135, 136, 137, 138, 139, 140, 141, 198, 349, 200, + /* 770 */ 135, 136, 137, 138, 139, 140, 141, 390, 183, 184, + /* 780 */ 178, 362, 349, 364, 70, 64, 0, 361, 362, 402, + /* 790 */ 20, 404, 471, 472, 473, 402, 475, 476, 77, 230, + /* 800 */ 231, 403, 404, 349, 361, 267, 349, 381, 448, 390, + /* 810 */ 24, 25, 26, 27, 28, 29, 30, 31, 32, 362, + /* 820 */ 20, 402, 172, 404, 103, 361, 362, 106, 20, 4, + /* 830 */ 443, 361, 362, 446, 474, 402, 449, 450, 451, 452, + /* 840 */ 453, 454, 349, 456, 19, 381, 459, 390, 461, 462, + /* 850 */ 463, 381, 202, 137, 467, 468, 402, 141, 382, 402, + /* 860 */ 35, 404, 443, 142, 143, 446, 390, 0, 449, 450, + /* 870 */ 451, 452, 453, 454, 398, 456, 51, 0, 435, 436, + /* 880 */ 461, 390, 463, 58, 390, 252, 467, 468, 397, 64, + /* 890 */ 77, 397, 361, 362, 349, 402, 405, 176, 177, 405, + /* 900 */ 443, 366, 367, 446, 183, 184, 449, 450, 451, 452, + /* 910 */ 453, 454, 381, 456, 378, 460, 35, 462, 461, 198, + /* 920 */ 463, 200, 349, 207, 467, 468, 210, 349, 392, 213, + /* 930 */ 105, 215, 51, 108, 390, 4, 375, 376, 402, 116, + /* 940 */ 59, 60, 61, 62, 230, 64, 349, 402, 178, 405, + /* 950 */ 425, 230, 231, 232, 23, 234, 235, 236, 237, 238, + /* 960 */ 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, + /* 970 */ 249, 250, 251, 12, 13, 402, 176, 46, 47, 48, + /* 980 */ 402, 20, 446, 22, 361, 362, 105, 361, 362, 108, + /* 990 */ 390, 3, 456, 34, 390, 349, 35, 397, 37, 402, + /* 1000 */ 475, 397, 232, 478, 381, 405, 23, 381, 362, 405, + /* 1010 */ 364, 391, 135, 136, 137, 138, 139, 140, 141, 361, + /* 1020 */ 362, 496, 497, 361, 362, 64, 501, 502, 161, 349, + /* 1030 */ 47, 48, 232, 382, 361, 362, 390, 170, 77, 381, + /* 1040 */ 232, 390, 362, 381, 364, 361, 362, 391, 402, 398, + /* 1050 */ 404, 8, 9, 172, 381, 12, 13, 14, 15, 16, + /* 1060 */ 4, 180, 181, 193, 103, 381, 0, 106, 187, 188, + /* 1070 */ 390, 8, 9, 361, 362, 12, 13, 14, 15, 16, + /* 1080 */ 56, 57, 402, 0, 404, 361, 362, 206, 37, 443, + /* 1090 */ 220, 221, 446, 381, 391, 449, 450, 451, 452, 453, + /* 1100 */ 454, 425, 456, 142, 143, 381, 0, 461, 42, 463, + /* 1110 */ 425, 8, 9, 467, 468, 12, 13, 14, 15, 16, + /* 1120 */ 20, 349, 22, 443, 375, 376, 446, 349, 77, 449, + /* 1130 */ 450, 451, 452, 453, 454, 52, 456, 176, 177, 366, + /* 1140 */ 367, 461, 136, 463, 183, 184, 391, 467, 468, 475, + /* 1150 */ 107, 475, 478, 459, 478, 55, 462, 136, 137, 198, + /* 1160 */ 475, 200, 141, 478, 460, 378, 462, 349, 22, 425, + /* 1170 */ 107, 497, 496, 497, 402, 501, 502, 501, 502, 392, + /* 1180 */ 402, 496, 497, 37, 1, 2, 501, 502, 214, 402, + /* 1190 */ 216, 230, 231, 232, 349, 234, 235, 236, 237, 238, + /* 1200 */ 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, + /* 1210 */ 249, 250, 251, 12, 13, 349, 431, 211, 212, 475, + /* 1220 */ 402, 20, 478, 22, 22, 14, 15, 16, 362, 349, + /* 1230 */ 364, 475, 399, 446, 478, 402, 35, 390, 37, 37, + /* 1240 */ 496, 497, 349, 456, 349, 501, 502, 402, 349, 103, + /* 1250 */ 37, 390, 405, 497, 391, 349, 390, 501, 502, 398, + /* 1260 */ 349, 362, 37, 364, 399, 64, 383, 402, 402, 386, + /* 1270 */ 404, 399, 352, 353, 402, 266, 267, 289, 77, 8, + /* 1280 */ 9, 178, 402, 12, 13, 14, 15, 16, 0, 390, + /* 1290 */ 107, 0, 0, 391, 33, 402, 116, 402, 33, 109, + /* 1300 */ 33, 402, 112, 404, 103, 103, 45, 106, 402, 443, + /* 1310 */ 45, 415, 446, 402, 22, 449, 450, 451, 452, 453, + /* 1320 */ 454, 391, 456, 13, 33, 109, 270, 461, 112, 463, + /* 1330 */ 224, 12, 13, 467, 468, 109, 0, 109, 112, 51, + /* 1340 */ 112, 22, 443, 142, 143, 446, 166, 37, 449, 450, + /* 1350 */ 451, 452, 453, 454, 35, 456, 37, 0, 22, 505, + /* 1360 */ 461, 350, 463, 142, 143, 494, 467, 468, 1, 2, + /* 1370 */ 365, 487, 390, 378, 107, 349, 13, 176, 177, 22, + /* 1380 */ 33, 33, 33, 64, 183, 184, 33, 33, 362, 33, + /* 1390 */ 364, 33, 33, 106, 33, 13, 77, 33, 378, 198, + /* 1400 */ 37, 200, 115, 493, 415, 360, 415, 493, 493, 424, + /* 1410 */ 493, 33, 33, 200, 33, 365, 390, 33, 33, 37, + /* 1420 */ 362, 33, 103, 33, 33, 200, 401, 415, 402, 432, + /* 1430 */ 404, 230, 231, 232, 415, 234, 235, 236, 237, 238, + /* 1440 */ 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, + /* 1450 */ 249, 250, 251, 415, 107, 107, 107, 477, 498, 469, + /* 1460 */ 107, 107, 380, 107, 480, 107, 107, 271, 107, 443, + /* 1470 */ 426, 107, 446, 51, 445, 449, 450, 451, 452, 453, + /* 1480 */ 454, 42, 456, 349, 444, 107, 107, 461, 107, 463, + /* 1490 */ 20, 107, 107, 467, 468, 107, 362, 107, 107, 437, + /* 1500 */ 370, 442, 213, 370, 437, 196, 428, 20, 361, 20, + /* 1510 */ 362, 45, 411, 362, 175, 411, 408, 198, 361, 200, + /* 1520 */ 362, 361, 411, 408, 390, 408, 374, 104, 102, 373, + /* 1530 */ 361, 101, 361, 372, 361, 361, 402, 20, 404, 354, + /* 1540 */ 50, 349, 358, 354, 358, 370, 437, 370, 20, 230, + /* 1550 */ 231, 370, 20, 404, 362, 20, 363, 370, 427, 20, + /* 1560 */ 363, 370, 418, 244, 245, 246, 247, 248, 249, 250, + /* 1570 */ 370, 361, 354, 370, 370, 106, 441, 443, 349, 352, + /* 1580 */ 446, 402, 390, 449, 450, 451, 452, 453, 454, 390, + /* 1590 */ 456, 362, 361, 352, 402, 461, 404, 463, 390, 390, + /* 1600 */ 354, 467, 468, 217, 390, 390, 439, 390, 402, 390, + /* 1610 */ 390, 349, 390, 390, 390, 437, 368, 20, 436, 390, + /* 1620 */ 204, 203, 434, 368, 362, 361, 486, 433, 278, 277, + /* 1630 */ 286, 402, 402, 404, 489, 443, 404, 189, 446, 402, + /* 1640 */ 486, 449, 450, 451, 452, 453, 454, 488, 456, 486, + /* 1650 */ 288, 485, 390, 461, 349, 463, 420, 287, 420, 467, + /* 1660 */ 468, 426, 500, 295, 402, 272, 404, 362, 426, 292, + /* 1670 */ 506, 499, 443, 290, 267, 446, 362, 20, 449, 450, + /* 1680 */ 451, 452, 453, 454, 116, 456, 363, 448, 269, 484, + /* 1690 */ 483, 349, 463, 481, 368, 390, 467, 468, 368, 420, + /* 1700 */ 402, 402, 402, 402, 362, 443, 420, 402, 446, 404, + /* 1710 */ 402, 449, 450, 451, 452, 453, 454, 181, 456, 479, + /* 1720 */ 416, 386, 106, 368, 466, 463, 106, 362, 368, 467, + /* 1730 */ 468, 394, 390, 402, 361, 22, 38, 368, 351, 421, + /* 1740 */ 429, 438, 421, 354, 402, 347, 404, 355, 443, 349, + /* 1750 */ 384, 446, 0, 0, 449, 450, 451, 452, 453, 454, + /* 1760 */ 384, 456, 362, 369, 384, 0, 349, 45, 463, 0, + /* 1770 */ 37, 223, 467, 468, 37, 37, 37, 223, 0, 362, + /* 1780 */ 37, 37, 223, 37, 0, 443, 223, 349, 446, 0, + /* 1790 */ 390, 449, 450, 451, 452, 453, 454, 37, 456, 0, + /* 1800 */ 362, 22, 402, 37, 404, 0, 218, 390, 0, 206, + /* 1810 */ 0, 206, 200, 207, 0, 198, 0, 0, 194, 402, + /* 1820 */ 193, 404, 0, 0, 147, 49, 49, 0, 390, 37, + /* 1830 */ 0, 51, 49, 491, 492, 0, 45, 0, 0, 0, + /* 1840 */ 402, 0, 404, 443, 49, 0, 446, 0, 0, 449, + /* 1850 */ 450, 451, 452, 453, 454, 0, 456, 0, 161, 0, + /* 1860 */ 443, 37, 161, 446, 0, 0, 449, 450, 451, 452, + /* 1870 */ 453, 454, 0, 456, 0, 0, 0, 0, 0, 0, + /* 1880 */ 463, 443, 0, 0, 446, 468, 349, 449, 450, 451, + /* 1890 */ 452, 453, 454, 0, 456, 0, 0, 0, 0, 362, + /* 1900 */ 0, 49, 0, 503, 504, 45, 0, 0, 0, 0, + /* 1910 */ 0, 0, 0, 349, 22, 0, 0, 147, 146, 0, + /* 1920 */ 145, 0, 0, 22, 0, 22, 362, 390, 37, 0, + /* 1930 */ 492, 50, 395, 64, 50, 64, 0, 64, 0, 402, + /* 1940 */ 0, 404, 37, 0, 349, 51, 42, 0, 0, 0, + /* 1950 */ 37, 14, 0, 0, 390, 0, 33, 362, 0, 395, + /* 1960 */ 42, 0, 37, 37, 0, 51, 402, 0, 404, 42, + /* 1970 */ 189, 51, 42, 45, 43, 0, 42, 0, 0, 37, + /* 1980 */ 443, 349, 49, 446, 49, 390, 449, 450, 451, 452, + /* 1990 */ 453, 454, 42, 456, 362, 49, 51, 402, 42, 404, + /* 2000 */ 49, 0, 37, 71, 42, 51, 0, 443, 37, 0, + /* 2010 */ 446, 51, 42, 449, 450, 451, 452, 453, 454, 37, + /* 2020 */ 456, 42, 390, 51, 0, 0, 0, 0, 0, 0, + /* 2030 */ 37, 114, 22, 0, 402, 0, 404, 37, 443, 37, + /* 2040 */ 37, 446, 37, 0, 449, 450, 451, 452, 453, 454, + /* 2050 */ 37, 456, 37, 112, 349, 37, 37, 37, 37, 22, + /* 2060 */ 37, 22, 22, 33, 33, 53, 0, 362, 22, 37, + /* 2070 */ 0, 0, 0, 37, 0, 443, 0, 22, 446, 349, + /* 2080 */ 20, 449, 450, 451, 452, 453, 454, 37, 456, 37, + /* 2090 */ 495, 37, 362, 37, 107, 390, 106, 0, 106, 0, + /* 2100 */ 395, 37, 49, 22, 205, 0, 22, 402, 0, 404, + /* 2110 */ 3, 33, 50, 273, 106, 104, 33, 178, 0, 50, + /* 2120 */ 390, 33, 349, 107, 107, 33, 49, 33, 106, 49, + /* 2130 */ 3, 273, 402, 33, 404, 362, 504, 349, 181, 273, + /* 2140 */ 102, 178, 49, 37, 178, 201, 178, 178, 443, 107, + /* 2150 */ 362, 446, 349, 106, 449, 450, 451, 452, 453, 454, + /* 2160 */ 37, 456, 37, 390, 106, 362, 107, 106, 395, 185, + /* 2170 */ 185, 106, 37, 443, 107, 402, 446, 404, 390, 449, + /* 2180 */ 450, 451, 452, 453, 454, 37, 456, 37, 458, 107, + /* 2190 */ 402, 33, 404, 390, 107, 49, 107, 0, 395, 0, + /* 2200 */ 0, 106, 42, 107, 106, 402, 42, 404, 107, 106, + /* 2210 */ 106, 49, 33, 2, 180, 106, 443, 349, 106, 446, + /* 2220 */ 104, 104, 449, 450, 451, 452, 453, 454, 115, 456, + /* 2230 */ 362, 443, 22, 182, 446, 349, 253, 449, 450, 451, + /* 2240 */ 452, 453, 454, 106, 456, 107, 443, 106, 362, 446, + /* 2250 */ 107, 106, 449, 450, 451, 452, 453, 454, 390, 456, + /* 2260 */ 266, 107, 49, 106, 49, 106, 22, 116, 107, 106, + /* 2270 */ 402, 230, 404, 107, 37, 37, 390, 233, 106, 37, + /* 2280 */ 107, 106, 37, 107, 106, 37, 37, 107, 402, 106, + /* 2290 */ 404, 107, 106, 37, 107, 106, 127, 127, 127, 106, + /* 2300 */ 33, 127, 106, 37, 106, 22, 37, 71, 37, 70, + /* 2310 */ 77, 443, 37, 37, 446, 37, 37, 449, 450, 451, + /* 2320 */ 452, 453, 454, 37, 456, 37, 37, 100, 77, 443, + /* 2330 */ 349, 100, 446, 33, 37, 449, 450, 451, 452, 453, + /* 2340 */ 454, 37, 456, 362, 37, 22, 37, 349, 37, 37, + /* 2350 */ 37, 77, 37, 37, 37, 37, 22, 37, 0, 37, + /* 2360 */ 362, 51, 0, 349, 37, 51, 42, 42, 0, 37, + /* 2370 */ 51, 390, 0, 42, 37, 42, 362, 51, 0, 37, + /* 2380 */ 37, 0, 22, 402, 33, 404, 22, 21, 390, 22, + /* 2390 */ 20, 22, 21, 507, 507, 507, 507, 507, 507, 507, + /* 2400 */ 402, 507, 404, 507, 390, 507, 507, 507, 507, 507, + /* 2410 */ 507, 507, 507, 507, 507, 507, 402, 507, 404, 507, + /* 2420 */ 507, 507, 507, 507, 443, 507, 507, 446, 507, 507, + /* 2430 */ 449, 450, 451, 452, 453, 454, 507, 456, 507, 507, + /* 2440 */ 349, 443, 507, 507, 446, 507, 507, 449, 450, 451, + /* 2450 */ 452, 453, 454, 362, 456, 507, 507, 443, 507, 349, + /* 2460 */ 446, 507, 507, 449, 450, 451, 452, 453, 454, 507, + /* 2470 */ 456, 507, 362, 507, 507, 507, 507, 507, 507, 507, + /* 2480 */ 507, 390, 507, 507, 507, 507, 507, 507, 507, 507, + /* 2490 */ 507, 507, 507, 402, 507, 404, 507, 507, 507, 507, + /* 2500 */ 390, 507, 507, 507, 507, 507, 507, 507, 507, 507, + /* 2510 */ 507, 507, 402, 507, 404, 507, 507, 507, 507, 507, + /* 2520 */ 507, 507, 507, 507, 507, 507, 349, 507, 507, 507, + /* 2530 */ 507, 507, 507, 507, 443, 507, 507, 446, 507, 362, + /* 2540 */ 449, 450, 451, 452, 453, 454, 507, 456, 507, 507, + /* 2550 */ 507, 507, 507, 443, 507, 349, 446, 507, 507, 449, + /* 2560 */ 450, 451, 452, 453, 454, 507, 456, 390, 362, 507, + /* 2570 */ 507, 507, 507, 507, 507, 507, 507, 507, 507, 402, + /* 2580 */ 507, 404, 507, 507, 349, 507, 507, 507, 507, 507, + /* 2590 */ 507, 507, 507, 507, 507, 507, 390, 362, 507, 507, + /* 2600 */ 507, 507, 507, 507, 507, 507, 507, 507, 402, 507, + /* 2610 */ 404, 507, 507, 507, 507, 507, 507, 507, 507, 507, + /* 2620 */ 443, 507, 349, 446, 507, 390, 449, 450, 451, 452, + /* 2630 */ 453, 454, 507, 456, 507, 362, 507, 402, 507, 404, + /* 2640 */ 507, 507, 507, 507, 507, 507, 507, 507, 507, 443, + /* 2650 */ 507, 507, 446, 507, 507, 449, 450, 451, 452, 453, + /* 2660 */ 454, 507, 456, 390, 507, 507, 507, 507, 507, 507, + /* 2670 */ 507, 507, 507, 507, 507, 402, 507, 404, 443, 349, + /* 2680 */ 507, 446, 507, 507, 449, 450, 451, 452, 453, 454, + /* 2690 */ 507, 456, 362, 507, 507, 507, 507, 349, 507, 507, + /* 2700 */ 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, + /* 2710 */ 362, 507, 507, 507, 507, 507, 443, 507, 507, 446, + /* 2720 */ 390, 507, 449, 450, 451, 452, 453, 454, 507, 456, + /* 2730 */ 507, 507, 402, 507, 404, 507, 507, 507, 390, 507, + /* 2740 */ 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, + /* 2750 */ 402, 507, 404, 507, 349, 507, 507, 507, 507, 507, + /* 2760 */ 507, 507, 507, 507, 507, 507, 507, 362, 507, 507, + /* 2770 */ 507, 507, 507, 443, 349, 507, 446, 507, 507, 449, + /* 2780 */ 450, 451, 452, 453, 454, 507, 456, 362, 507, 507, + /* 2790 */ 349, 443, 507, 507, 446, 390, 507, 449, 450, 451, + /* 2800 */ 452, 453, 454, 362, 456, 507, 507, 402, 507, 404, + /* 2810 */ 507, 507, 507, 507, 507, 390, 507, 507, 507, 507, + /* 2820 */ 507, 507, 507, 507, 507, 507, 507, 402, 507, 404, + /* 2830 */ 507, 390, 507, 507, 507, 507, 507, 507, 507, 507, + /* 2840 */ 507, 507, 507, 402, 507, 404, 507, 507, 443, 507, + /* 2850 */ 507, 446, 507, 507, 449, 450, 451, 452, 453, 454, + /* 2860 */ 507, 456, 507, 507, 507, 507, 507, 507, 443, 507, + /* 2870 */ 507, 446, 507, 507, 449, 450, 451, 452, 453, 454, + /* 2880 */ 507, 456, 507, 507, 443, 507, 507, 446, 507, 349, + /* 2890 */ 449, 450, 451, 452, 453, 454, 507, 456, 507, 507, + /* 2900 */ 507, 507, 362, 507, 507, 349, 507, 507, 507, 507, + /* 2910 */ 507, 507, 507, 507, 507, 507, 507, 507, 362, 507, + /* 2920 */ 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, + /* 2930 */ 390, 507, 507, 507, 507, 507, 507, 507, 507, 507, + /* 2940 */ 507, 507, 402, 507, 404, 507, 390, 507, 507, 507, + /* 2950 */ 507, 507, 507, 507, 507, 507, 507, 507, 402, 507, + /* 2960 */ 404, 507, 507, 507, 507, 507, 507, 507, 507, 507, + /* 2970 */ 507, 507, 349, 507, 507, 507, 507, 507, 507, 507, + /* 2980 */ 507, 507, 507, 443, 507, 362, 446, 349, 507, 449, + /* 2990 */ 450, 451, 452, 453, 454, 507, 456, 507, 507, 443, + /* 3000 */ 362, 507, 446, 507, 507, 449, 450, 451, 452, 453, + /* 3010 */ 454, 507, 456, 390, 507, 507, 507, 507, 507, 507, + /* 3020 */ 507, 507, 507, 507, 507, 402, 507, 404, 390, 507, + /* 3030 */ 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, + /* 3040 */ 402, 507, 404, 507, 507, 507, 507, 507, 507, 507, + /* 3050 */ 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, + /* 3060 */ 507, 507, 507, 507, 507, 507, 443, 507, 507, 446, + /* 3070 */ 349, 507, 449, 450, 451, 452, 453, 454, 507, 456, + /* 3080 */ 507, 443, 507, 362, 446, 507, 507, 449, 450, 451, + /* 3090 */ 452, 453, 454, 507, 456, 507, 507, 507, 507, 507, + /* 3100 */ 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, + /* 3110 */ 507, 390, 507, 507, 507, 507, 507, 507, 507, 507, + /* 3120 */ 507, 507, 507, 402, 507, 404, 507, 507, 507, 507, + /* 3130 */ 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, + /* 3140 */ 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, + /* 3150 */ 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, + /* 3160 */ 507, 507, 507, 507, 443, 507, 507, 446, 507, 507, + /* 3170 */ 449, 450, 451, 452, 453, 454, 507, 456, 346, 346, + /* 3180 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + /* 3190 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + /* 3200 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + /* 3210 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + /* 3220 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + /* 3230 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + /* 3240 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + /* 3250 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + /* 3260 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + /* 3270 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + /* 3280 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + /* 3290 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + /* 3300 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + /* 3310 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + /* 3320 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + /* 3330 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + /* 3340 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + /* 3350 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + /* 3360 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + /* 3370 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + /* 3380 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + /* 3390 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + /* 3400 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + /* 3410 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + /* 3420 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + /* 3430 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + /* 3440 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + /* 3450 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + /* 3460 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + /* 3470 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + /* 3480 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + /* 3490 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + /* 3500 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + /* 3510 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, + /* 3520 */ 346, 346, 346, 346, }; -#define YY_SHIFT_COUNT (821) +#define YY_SHIFT_COUNT (834) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (2217) +#define YY_SHIFT_MAX (2381) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 1424, 0, 238, 0, 477, 477, 477, 477, 477, 477, - /* 10 */ 477, 477, 477, 477, 477, 477, 715, 953, 953, 1191, - /* 20 */ 953, 953, 953, 953, 953, 953, 953, 953, 953, 953, - /* 30 */ 953, 953, 953, 953, 953, 953, 953, 953, 953, 953, - /* 40 */ 953, 953, 953, 953, 953, 953, 953, 953, 953, 953, - /* 50 */ 953, 82, 93, 104, 85, 103, 226, 103, 85, 85, - /* 60 */ 103, 1307, 103, 237, 1307, 1307, 86, 103, 38, 474, - /* 70 */ 135, 135, 474, 287, 287, 407, 431, 254, 254, 177, - /* 80 */ 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, - /* 90 */ 153, 135, 135, 220, 38, 135, 135, 38, 135, 135, - /* 100 */ 38, 135, 135, 38, 135, 38, 38, 38, 135, 363, - /* 110 */ 199, 199, 213, 54, 712, 712, 712, 712, 712, 712, - /* 120 */ 712, 712, 712, 712, 712, 712, 712, 712, 712, 712, - /* 130 */ 712, 712, 712, 398, 164, 407, 431, 1113, 1113, 182, - /* 140 */ 40, 40, 40, 565, 538, 538, 491, 182, 220, 184, - /* 150 */ 38, 38, 214, 38, 486, 38, 486, 486, 520, 73, - /* 160 */ 467, 467, 467, 467, 467, 467, 467, 467, 1854, 674, - /* 170 */ 23, 80, 313, 329, 476, 157, 211, 397, 334, 334, - /* 180 */ 514, 834, 945, 945, 945, 836, 945, 978, 480, 383, - /* 190 */ 1183, 396, 893, 383, 383, 862, 970, 1000, 931, 970, - /* 200 */ 1204, 1093, 491, 1111, 1334, 1346, 1370, 1181, 220, 1370, - /* 210 */ 220, 1213, 1393, 1397, 1396, 1397, 1396, 1275, 1393, 1397, - /* 220 */ 1393, 1396, 1275, 1275, 1352, 1356, 1393, 1360, 1393, 1393, - /* 230 */ 1393, 1449, 1420, 1449, 1420, 1370, 220, 1455, 220, 1462, - /* 240 */ 1465, 220, 1462, 220, 1467, 220, 220, 1393, 220, 1449, - /* 250 */ 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, - /* 260 */ 38, 1393, 73, 73, 1449, 486, 486, 486, 1298, 1408, - /* 270 */ 1370, 363, 1316, 1319, 1455, 363, 1326, 1111, 1393, 486, - /* 280 */ 1267, 1270, 1267, 1270, 1260, 1369, 1267, 1274, 1277, 1294, - /* 290 */ 1111, 1281, 1282, 1285, 1305, 1397, 1557, 1474, 1324, 1462, - /* 300 */ 363, 363, 1270, 486, 486, 486, 486, 1270, 486, 1427, - /* 310 */ 363, 520, 363, 1397, 1505, 1509, 486, 1393, 363, 1596, - /* 320 */ 1584, 1449, 3640, 3640, 3640, 3640, 3640, 3640, 3640, 3640, - /* 330 */ 3640, 36, 634, 252, 342, 967, 53, 629, 307, 513, - /* 340 */ 652, 879, 898, 795, 795, 795, 795, 795, 795, 795, - /* 350 */ 795, 795, 764, 567, 166, 304, 304, 638, 822, 937, - /* 360 */ 206, 483, 654, 812, 87, 867, 867, 1160, 1141, 351, - /* 370 */ 1160, 1160, 1160, 1133, 1124, 30, 1236, 1205, 208, 768, - /* 380 */ 1130, 1131, 1132, 1142, 503, 644, 1223, 1252, 1253, 1044, - /* 390 */ 839, 1172, 1182, 1224, 1229, 1230, 1127, 1078, 1117, 1231, - /* 400 */ 1234, 1238, 1240, 1243, 1244, 1279, 1249, 1190, 1250, 1237, - /* 410 */ 1251, 1255, 1256, 1262, 1263, 1269, 1185, 1248, 1276, 1280, - /* 420 */ 1290, 1278, 1272, 1636, 1638, 1640, 1597, 1645, 1609, 1431, - /* 430 */ 1616, 1618, 1620, 1437, 1659, 1623, 1624, 1441, 1626, 1664, - /* 440 */ 1444, 1666, 1631, 1671, 1650, 1673, 1637, 1459, 1676, 1473, - /* 450 */ 1678, 1475, 1476, 1482, 1487, 1685, 1686, 1687, 1496, 1498, - /* 460 */ 1691, 1692, 1546, 1646, 1648, 1694, 1662, 1649, 1701, 1653, - /* 470 */ 1703, 1660, 1704, 1706, 1707, 1663, 1708, 1709, 1713, 1714, - /* 480 */ 1715, 1716, 1556, 1674, 1718, 1558, 1720, 1721, 1723, 1725, - /* 490 */ 1726, 1727, 1728, 1729, 1730, 1731, 1732, 1733, 1734, 1739, - /* 500 */ 1740, 1747, 1688, 1750, 1712, 1751, 1752, 1754, 1756, 1758, - /* 510 */ 1762, 1741, 1766, 1628, 1773, 1630, 1779, 1635, 1782, 1783, - /* 520 */ 1765, 1738, 1768, 1742, 1784, 1735, 1757, 1793, 1736, 1795, - /* 530 */ 1743, 1796, 1797, 1761, 1753, 1759, 1802, 1771, 1760, 1763, - /* 540 */ 1803, 1772, 1764, 1770, 1810, 1776, 1814, 1774, 1775, 1788, - /* 550 */ 1767, 1777, 1808, 1778, 1823, 1781, 1787, 1825, 1830, 1832, - /* 560 */ 1798, 1655, 1843, 1767, 1800, 1844, 1845, 1780, 1847, 1850, - /* 570 */ 1817, 1805, 1816, 1859, 1824, 1811, 1827, 1871, 1835, 1828, - /* 580 */ 1833, 1876, 1841, 1829, 1842, 1883, 1885, 1887, 1890, 1891, - /* 590 */ 1892, 1785, 1789, 1856, 1872, 1895, 1860, 1863, 1865, 1866, - /* 600 */ 1867, 1869, 1870, 1873, 1875, 1879, 1882, 1884, 1874, 1886, - /* 610 */ 1909, 1898, 1922, 1902, 1888, 1926, 1905, 1900, 1929, 1942, - /* 620 */ 1943, 1903, 1944, 1908, 1946, 1925, 1928, 1912, 1913, 1915, - /* 630 */ 1848, 1851, 1954, 1790, 1855, 1786, 1919, 1938, 1963, 1769, - /* 640 */ 1945, 1799, 1792, 1964, 1965, 1801, 1804, 1806, 1812, 1966, - /* 650 */ 1947, 1705, 1877, 1878, 1880, 1931, 1904, 1934, 1889, 1881, - /* 660 */ 1969, 1971, 1899, 1901, 1907, 1917, 1914, 1977, 1930, 1962, - /* 670 */ 1920, 1981, 1791, 1921, 1923, 1975, 1991, 1794, 1988, 1990, - /* 680 */ 1994, 1998, 1999, 2000, 1933, 1935, 1989, 1809, 2008, 1995, - /* 690 */ 2043, 2048, 1948, 2004, 1949, 1950, 1953, 1955, 1957, 1894, - /* 700 */ 1958, 2049, 2010, 1893, 1960, 1941, 1767, 2018, 2020, 1972, - /* 710 */ 1818, 1973, 2066, 2053, 1852, 1976, 1974, 1980, 1982, 1993, - /* 720 */ 1996, 2021, 2001, 2002, 2029, 1997, 2057, 1857, 2003, 1967, - /* 730 */ 2006, 2059, 2064, 2005, 2009, 2065, 2011, 2012, 2069, 2014, - /* 740 */ 2015, 2078, 2017, 2022, 2081, 2019, 2023, 2084, 2026, 1983, - /* 750 */ 2007, 2016, 2025, 2030, 2091, 2031, 2090, 2033, 2091, 2091, - /* 760 */ 2106, 2070, 2072, 2098, 2107, 2108, 2109, 2110, 2111, 2112, - /* 770 */ 2113, 2116, 2079, 2063, 2088, 2067, 2133, 2132, 2134, 2135, - /* 780 */ 2148, 2136, 2137, 2138, 2099, 1875, 2141, 1879, 2142, 2144, - /* 790 */ 2152, 2154, 2170, 2157, 2193, 2160, 2147, 2158, 2199, 2164, - /* 800 */ 2151, 2161, 2204, 2168, 2155, 2165, 2209, 2174, 2162, 2172, - /* 810 */ 2212, 2178, 2179, 2217, 2196, 2186, 2198, 2200, 2202, 2203, - /* 820 */ 2201, 2206, + /* 0 */ 391, 0, 240, 0, 481, 481, 481, 481, 481, 481, + /* 10 */ 481, 481, 481, 481, 481, 481, 721, 961, 961, 1201, + /* 20 */ 961, 961, 961, 961, 961, 961, 961, 961, 961, 961, + /* 30 */ 961, 961, 961, 961, 961, 961, 961, 961, 961, 961, + /* 40 */ 961, 961, 961, 961, 961, 961, 961, 961, 961, 961, + /* 50 */ 961, 93, 162, 152, 47, 278, 343, 278, 278, 47, + /* 60 */ 47, 278, 1319, 278, 239, 1319, 1319, 281, 278, 28, + /* 70 */ 595, 67, 67, 931, 931, 595, 87, 291, 126, 126, + /* 80 */ 173, 67, 67, 67, 67, 67, 67, 67, 67, 67, + /* 90 */ 67, 67, 317, 492, 67, 67, 187, 28, 67, 317, + /* 100 */ 67, 28, 67, 67, 28, 67, 67, 28, 67, 28, + /* 110 */ 28, 28, 67, 368, 439, 439, 242, 546, 569, 569, + /* 120 */ 569, 569, 569, 569, 569, 569, 569, 569, 569, 569, + /* 130 */ 569, 569, 569, 569, 569, 569, 569, 189, 602, 87, + /* 140 */ 291, 1024, 1024, 150, 268, 268, 268, 678, 336, 336, + /* 150 */ 91, 150, 187, 486, 28, 28, 633, 28, 813, 28, + /* 160 */ 813, 813, 823, 959, 89, 89, 89, 89, 89, 89, + /* 170 */ 89, 89, 504, 441, 65, 453, 15, 313, 606, 19, + /* 180 */ 322, 516, 3, 3, 527, 983, 770, 303, 303, 303, + /* 190 */ 502, 303, 800, 1100, 1, 725, 618, 650, 1, 1, + /* 200 */ 808, 1009, 538, 988, 1009, 1261, 1056, 91, 1196, 1422, + /* 210 */ 1439, 1470, 1289, 187, 1470, 187, 1309, 1487, 1489, 1466, + /* 220 */ 1489, 1466, 1339, 1487, 1489, 1487, 1466, 1339, 1339, 1423, + /* 230 */ 1426, 1487, 1430, 1487, 1487, 1487, 1517, 1490, 1517, 1490, + /* 240 */ 1470, 187, 187, 1528, 187, 1532, 1535, 187, 1532, 187, + /* 250 */ 1539, 187, 187, 1487, 187, 1517, 28, 28, 28, 28, + /* 260 */ 28, 28, 28, 28, 28, 28, 28, 1487, 959, 959, + /* 270 */ 1517, 813, 813, 813, 1386, 1469, 1470, 368, 1597, 1416, + /* 280 */ 1418, 1528, 368, 1196, 1487, 813, 1350, 1352, 1350, 1352, + /* 290 */ 1344, 1448, 1350, 1362, 1370, 1393, 1196, 1368, 1377, 1383, + /* 300 */ 1407, 1489, 1657, 1568, 1419, 1532, 368, 368, 1352, 813, + /* 310 */ 813, 813, 813, 1352, 813, 1536, 368, 823, 368, 1489, + /* 320 */ 1616, 1620, 813, 1487, 368, 1713, 1698, 1517, 3178, 3178, + /* 330 */ 3178, 3178, 3178, 3178, 3178, 3178, 3178, 36, 881, 786, + /* 340 */ 30, 825, 1043, 1063, 625, 413, 661, 1103, 877, 1271, + /* 350 */ 1271, 1271, 1271, 1271, 1271, 1271, 1271, 1271, 635, 716, + /* 360 */ 318, 363, 363, 355, 358, 445, 870, 867, 1146, 1202, + /* 370 */ 1006, 1021, 1021, 1211, 1183, 382, 1211, 1211, 1211, 1288, + /* 380 */ 1106, 462, 1066, 1265, 1180, 1291, 1190, 1216, 1226, 1228, + /* 390 */ 677, 1310, 1292, 1336, 1357, 974, 1267, 1347, 477, 1348, + /* 400 */ 1349, 1353, 1221, 417, 8, 1354, 1356, 1358, 1359, 1361, + /* 410 */ 1364, 1367, 1378, 714, 1379, 155, 1381, 1384, 1385, 1388, + /* 420 */ 1390, 1391, 1287, 1213, 1225, 1363, 1382, 1051, 1083, 1752, + /* 430 */ 1753, 1765, 1722, 1769, 1733, 1548, 1737, 1738, 1739, 1554, + /* 440 */ 1778, 1743, 1744, 1559, 1746, 1784, 1563, 1789, 1760, 1799, + /* 450 */ 1779, 1805, 1766, 1588, 1808, 1603, 1810, 1605, 1606, 1612, + /* 460 */ 1617, 1814, 1816, 1817, 1624, 1627, 1822, 1823, 1677, 1776, + /* 470 */ 1777, 1827, 1792, 1780, 1830, 1783, 1835, 1791, 1837, 1838, + /* 480 */ 1839, 1795, 1841, 1845, 1847, 1848, 1855, 1857, 1697, 1824, + /* 490 */ 1859, 1701, 1864, 1865, 1872, 1874, 1875, 1876, 1877, 1878, + /* 500 */ 1879, 1882, 1883, 1893, 1895, 1896, 1897, 1898, 1900, 1852, + /* 510 */ 1902, 1860, 1906, 1907, 1908, 1909, 1910, 1911, 1912, 1892, + /* 520 */ 1915, 1770, 1916, 1772, 1919, 1775, 1921, 1922, 1901, 1881, + /* 530 */ 1903, 1884, 1924, 1869, 1891, 1929, 1871, 1936, 1873, 1938, + /* 540 */ 1940, 1905, 1894, 1904, 1943, 1913, 1914, 1918, 1947, 1925, + /* 550 */ 1920, 1927, 1948, 1926, 1949, 1928, 1930, 1923, 1933, 1935, + /* 560 */ 1937, 1946, 1952, 1931, 1934, 1953, 1955, 1958, 1961, 1950, + /* 570 */ 1781, 1964, 1933, 1951, 1967, 1975, 1932, 1977, 1978, 1942, + /* 580 */ 1945, 1956, 2001, 1965, 1954, 1962, 2006, 1971, 1960, 1970, + /* 590 */ 2009, 1982, 1972, 1979, 2024, 2025, 2026, 2027, 2028, 2029, + /* 600 */ 1917, 1941, 1993, 2010, 2033, 2000, 2002, 2003, 2005, 2013, + /* 610 */ 2015, 2018, 2019, 2030, 2031, 2020, 2021, 2037, 2023, 2035, + /* 620 */ 2039, 2043, 2040, 2012, 2066, 2046, 2032, 2070, 2071, 2072, + /* 630 */ 2036, 2074, 2050, 2076, 2055, 2060, 2052, 2054, 2056, 1987, + /* 640 */ 1990, 2097, 1939, 1992, 1899, 1933, 2053, 2099, 1963, 2064, + /* 650 */ 2081, 2105, 1944, 2084, 1966, 1957, 2108, 2118, 1968, 1984, + /* 660 */ 1969, 1985, 2107, 2078, 1840, 2008, 2016, 2022, 2062, 2011, + /* 670 */ 2069, 2038, 2017, 2083, 2088, 2042, 2047, 2058, 2061, 2059, + /* 680 */ 2092, 2077, 2080, 2065, 2094, 1858, 2067, 2082, 2127, 2100, + /* 690 */ 1866, 2106, 2123, 2125, 2135, 2148, 2150, 2087, 2089, 2093, + /* 700 */ 1994, 2158, 2146, 2197, 2199, 2095, 2160, 2098, 2096, 2101, + /* 710 */ 2103, 2104, 2051, 2109, 2200, 2164, 2034, 2112, 2113, 1933, + /* 720 */ 2162, 2179, 2116, 1983, 2117, 2211, 2210, 2041, 2137, 2138, + /* 730 */ 2141, 2143, 2145, 2154, 2213, 2157, 2159, 2215, 2161, 2244, + /* 740 */ 2044, 2163, 2151, 2166, 2237, 2238, 2172, 2173, 2242, 2175, + /* 750 */ 2176, 2245, 2178, 2180, 2248, 2183, 2184, 2249, 2186, 2187, + /* 760 */ 2256, 2189, 2169, 2170, 2171, 2174, 2193, 2267, 2196, 2266, + /* 770 */ 2198, 2267, 2267, 2283, 2236, 2239, 2269, 2271, 2275, 2276, + /* 780 */ 2278, 2279, 2286, 2288, 2289, 2233, 2227, 2251, 2231, 2300, + /* 790 */ 2297, 2304, 2307, 2323, 2309, 2311, 2312, 2274, 2030, 2313, + /* 800 */ 2031, 2315, 2316, 2317, 2318, 2334, 2320, 2358, 2322, 2310, + /* 810 */ 2324, 2362, 2327, 2314, 2325, 2368, 2332, 2319, 2331, 2372, + /* 820 */ 2337, 2326, 2333, 2378, 2342, 2343, 2381, 2360, 2351, 2364, + /* 830 */ 2366, 2367, 2369, 2371, 2370, }; -#define YY_REDUCE_COUNT (330) -#define YY_REDUCE_MIN (-469) -#define YY_REDUCE_MAX (3186) +#define YY_REDUCE_COUNT (336) +#define YY_REDUCE_MIN (-423) +#define YY_REDUCE_MAX (2721) static const short yy_reduce_ofst[] = { - /* 0 */ -272, -302, 102, 175, -25, 382, 413, 620, 713, 858, - /* 10 */ 951, 1136, 1295, 1321, 1388, 1417, 478, 1485, 1550, 1569, - /* 20 */ 1644, 1711, 1737, 1807, 1834, 1918, 1940, 2046, 2073, 2139, - /* 30 */ 2156, 2236, 2267, 2302, 2395, 2422, 2488, 2505, 2585, 2616, - /* 40 */ 2651, 2744, 2771, 2837, 2854, 2934, 2965, 3000, 3093, 3120, - /* 50 */ 3186, -304, 288, 376, -107, 45, 552, 554, -207, 326, - /* 60 */ 619, 688, -469, -188, 464, 767, -467, -456, -363, -242, - /* 70 */ -359, -289, -54, -348, -219, 259, 247, -17, 17, -344, - /* 80 */ 319, 322, 371, 463, 575, 640, 559, 562, 609, 645, - /* 90 */ 186, 636, 697, 124, -203, 721, 726, 373, 743, 749, - /* 100 */ 455, 760, 765, 583, 777, 487, 603, 596, 787, 627, - /* 110 */ -422, -422, -200, -273, -251, 117, 158, 229, 231, 246, - /* 120 */ 340, 355, 390, 392, 436, 449, 479, 537, 643, 714, - /* 130 */ 735, 745, 771, 107, 438, -230, 612, 814, 849, 725, - /* 140 */ 438, 694, 762, 366, 457, 631, 196, 780, 161, -55, - /* 150 */ -389, 274, 649, 733, 811, 591, 824, 826, 847, 865, - /* 160 */ -386, -381, 239, 281, 416, 427, 516, 416, 415, 534, - /* 170 */ 625, 852, 785, 801, 946, 830, 932, 932, 948, 949, - /* 180 */ 914, 916, 842, 845, 859, 925, 863, 932, 975, 950, - /* 190 */ 1001, 998, 968, 960, 961, 932, 903, 903, 883, 903, - /* 200 */ 913, 904, 1003, 958, 944, 952, 962, 956, 1034, 971, - /* 210 */ 1037, 985, 1054, 1061, 1033, 1083, 1035, 1042, 1090, 1091, - /* 220 */ 1094, 1041, 1046, 1048, 1084, 1087, 1100, 1092, 1102, 1106, - /* 230 */ 1107, 1118, 1115, 1120, 1119, 1043, 1110, 1077, 1112, 1121, - /* 240 */ 1060, 1125, 1126, 1129, 1076, 1135, 1137, 1139, 1138, 1143, - /* 250 */ 1122, 1123, 1128, 1134, 1140, 1144, 1145, 1149, 1151, 1152, - /* 260 */ 1153, 1148, 1150, 1158, 1147, 1101, 1109, 1114, 1057, 1080, - /* 270 */ 1085, 1154, 1089, 1095, 1155, 1157, 1097, 1146, 1171, 1156, - /* 280 */ 1049, 1159, 1063, 1161, 1062, 1074, 1064, 1079, 1082, 1086, - /* 290 */ 1163, 1066, 1068, 1071, 903, 1214, 1162, 1103, 1116, 1233, - /* 300 */ 1226, 1232, 1178, 1197, 1201, 1202, 1203, 1186, 1207, 1194, - /* 310 */ 1254, 1225, 1257, 1258, 1164, 1227, 1215, 1265, 1259, 1273, - /* 320 */ 1283, 1286, 1200, 1198, 1209, 1212, 1271, 1284, 1287, 1266, - /* 330 */ 1289, + /* 0 */ -149, -302, 387, 199, 419, 646, 680, 866, 899, 1026, + /* 10 */ 457, 1134, 1192, 1229, 1262, 1305, -84, 1342, 1400, 1417, + /* 20 */ 1438, 1537, 1564, 1595, 1632, 1705, 1730, 1773, 1803, 1788, + /* 30 */ 1868, 1886, 1981, 1998, 2014, 2091, 2110, 2177, 2206, 2235, + /* 40 */ 2273, 2330, 2348, 2405, 2425, 2441, 2540, 2556, 2623, 2638, + /* 50 */ 2721, -189, -339, -423, 163, -421, 525, 676, 685, 279, + /* 60 */ 321, 744, -176, -311, -308, 536, 787, 674, 756, -379, + /* 70 */ -248, -356, -192, -288, 4, -244, -329, 39, 181, 383, + /* 80 */ -306, -312, -31, 138, 198, -328, -137, 246, 325, 426, + /* 90 */ 464, -107, 75, -223, 470, 531, -91, 491, 623, 443, + /* 100 */ 626, 494, 658, 662, -381, 673, 684, 600, 712, 476, + /* 110 */ 604, 651, 724, 236, -54, -54, -371, 282, 115, 305, + /* 120 */ 393, 433, 454, 493, 545, 573, 578, 597, 772, 778, + /* 130 */ 818, 845, 880, 893, 895, 906, 911, 161, -293, -123, + /* 140 */ 398, 535, 773, 561, -293, -129, 360, 300, 455, 704, + /* 150 */ -318, 749, -98, 116, 266, 544, 694, 861, 833, 847, + /* 160 */ 865, 872, 883, 920, 620, 656, 703, 755, 863, 902, + /* 170 */ 930, 863, 785, -369, 1011, 896, 854, 871, 1005, 884, + /* 180 */ 982, 982, 995, 1020, 989, 1045, 991, 910, 914, 915, + /* 190 */ 985, 917, 982, 1050, 1012, 1058, 1025, 997, 1019, 1038, + /* 200 */ 982, 980, 980, 960, 980, 990, 984, 1082, 1044, 1029, + /* 210 */ 1040, 1062, 1059, 1130, 1067, 1133, 1078, 1147, 1148, 1101, + /* 220 */ 1151, 1104, 1108, 1157, 1158, 1160, 1111, 1115, 1117, 1152, + /* 230 */ 1156, 1169, 1161, 1171, 1173, 1174, 1185, 1184, 1189, 1186, + /* 240 */ 1109, 1175, 1177, 1149, 1181, 1193, 1131, 1187, 1197, 1191, + /* 250 */ 1144, 1200, 1203, 1210, 1204, 1218, 1199, 1208, 1209, 1214, + /* 260 */ 1215, 1217, 1219, 1220, 1222, 1223, 1224, 1231, 1227, 1241, + /* 270 */ 1246, 1179, 1206, 1230, 1135, 1167, 1178, 1248, 1182, 1188, + /* 280 */ 1194, 1232, 1255, 1235, 1264, 1237, 1140, 1236, 1154, 1238, + /* 290 */ 1145, 1159, 1163, 1166, 1205, 1207, 1242, 1164, 1162, 1172, + /* 300 */ 980, 1314, 1239, 1212, 1240, 1323, 1326, 1330, 1279, 1298, + /* 310 */ 1299, 1300, 1301, 1286, 1308, 1304, 1355, 1335, 1360, 1365, + /* 320 */ 1258, 1337, 1331, 1373, 1369, 1387, 1392, 1389, 1311, 1303, + /* 330 */ 1318, 1321, 1366, 1376, 1380, 1394, 1398, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 10 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 20 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 30 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 40 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 50 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 60 */ 2181, 1851, 1851, 2144, 1851, 1851, 1851, 1851, 1851, 1851, - /* 70 */ 1851, 1851, 1851, 1851, 1851, 2151, 1851, 1851, 1851, 1851, - /* 80 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 90 */ 1851, 1851, 1851, 1947, 1851, 1851, 1851, 1851, 1851, 1851, - /* 100 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1945, - /* 110 */ 2378, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 120 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 130 */ 1851, 1851, 1851, 1851, 2390, 1851, 1851, 1921, 1921, 1851, - /* 140 */ 2390, 2390, 2390, 1945, 2350, 2350, 1851, 1851, 1947, 2215, - /* 150 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 2070, 1881, - /* 160 */ 1851, 1851, 1851, 1851, 2094, 1851, 1851, 1851, 2207, 1851, - /* 170 */ 1851, 2419, 2479, 1851, 1851, 2422, 1851, 1851, 1851, 1851, - /* 180 */ 2156, 2409, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 190 */ 1851, 1851, 2023, 1851, 1851, 1851, 2382, 2396, 2463, 2383, - /* 200 */ 2380, 2403, 1851, 2413, 1851, 2239, 1851, 2229, 1947, 1851, - /* 210 */ 1947, 2194, 2139, 1851, 2149, 1851, 2149, 2146, 1851, 1851, - /* 220 */ 1851, 2149, 2146, 2146, 2012, 2008, 1851, 2006, 1851, 1851, - /* 230 */ 1851, 1851, 1905, 1851, 1905, 1851, 1947, 1851, 1947, 1851, - /* 240 */ 1851, 1947, 1851, 1947, 1851, 1947, 1947, 1851, 1947, 1851, - /* 250 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 260 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 2227, 2213, - /* 270 */ 1851, 1945, 2205, 2203, 1851, 1945, 2201, 2413, 1851, 1851, - /* 280 */ 2433, 2428, 2433, 2428, 2447, 2443, 2433, 2452, 2449, 2415, - /* 290 */ 2413, 2482, 2469, 2465, 2396, 1851, 1851, 2401, 2399, 1851, - /* 300 */ 1945, 1945, 2428, 1851, 1851, 1851, 1851, 2428, 1851, 1851, - /* 310 */ 1945, 1851, 1945, 1851, 1851, 2039, 1851, 1851, 1945, 1851, - /* 320 */ 1890, 1851, 2196, 2218, 2177, 2177, 2073, 2073, 2073, 1948, - /* 330 */ 1856, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 340 */ 1851, 1851, 1851, 2446, 2445, 2303, 1851, 2354, 2353, 2352, - /* 350 */ 2343, 2302, 2035, 1851, 1851, 2301, 2300, 1851, 1851, 1851, - /* 360 */ 1851, 1851, 1851, 1851, 1851, 2168, 2167, 2294, 1851, 1851, - /* 370 */ 2295, 2293, 2292, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 380 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 390 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 2466, 2470, 1851, - /* 400 */ 1851, 1851, 1851, 1851, 1851, 2379, 1851, 1851, 1851, 2275, - /* 410 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 420 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 430 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 440 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 450 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 460 */ 1851, 1851, 2145, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 470 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 480 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 490 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 500 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 510 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 2160, 1851, 1851, - /* 520 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 530 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 540 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1895, - /* 550 */ 2281, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 560 */ 1851, 1851, 1851, 2284, 1851, 1851, 1851, 1851, 1851, 1851, - /* 570 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 580 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 590 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 600 */ 1851, 1851, 1851, 1851, 1987, 1986, 1851, 1851, 1851, 1851, - /* 610 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 620 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 630 */ 2285, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 640 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 2462, - /* 650 */ 2416, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 660 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 2275, - /* 670 */ 1851, 2444, 1851, 1851, 2460, 1851, 2464, 1851, 1851, 1851, - /* 680 */ 1851, 1851, 1851, 1851, 2389, 2385, 1851, 1851, 2381, 1851, - /* 690 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 700 */ 1851, 1851, 1851, 1851, 1851, 1851, 2274, 1851, 2340, 1851, - /* 710 */ 1851, 1851, 2374, 1851, 1851, 2325, 1851, 1851, 1851, 1851, - /* 720 */ 1851, 1851, 1851, 1851, 1851, 2285, 1851, 2288, 1851, 1851, - /* 730 */ 1851, 1851, 1851, 2067, 1851, 1851, 1851, 1851, 1851, 1851, - /* 740 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 2051, - /* 750 */ 2049, 2048, 2047, 1851, 2080, 1851, 1851, 1851, 2076, 2075, - /* 760 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 770 */ 1851, 1851, 1851, 1851, 1851, 1851, 1966, 1851, 1851, 1851, - /* 780 */ 1851, 1851, 1851, 1851, 1851, 1958, 1851, 1957, 1851, 1851, - /* 790 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 800 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, - /* 810 */ 1851, 1851, 1851, 1851, 1851, 1880, 1851, 1851, 1851, 1851, - /* 820 */ 1851, 1851, + /* 0 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 10 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 20 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 30 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 40 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 50 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 60 */ 1876, 2209, 1876, 1876, 2172, 1876, 1876, 1876, 1876, 1876, + /* 70 */ 1876, 1876, 1876, 1876, 1876, 1876, 2179, 1876, 1876, 1876, + /* 80 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 90 */ 1876, 1876, 1876, 1876, 1876, 1876, 1973, 1876, 1876, 1876, + /* 100 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 110 */ 1876, 1876, 1876, 1971, 2411, 1876, 1876, 1876, 1876, 1876, + /* 120 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 130 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 2423, 1876, + /* 140 */ 1876, 1947, 1947, 1876, 2423, 2423, 2423, 1971, 2383, 2383, + /* 150 */ 1876, 1876, 1973, 2247, 1876, 1876, 1876, 1876, 1876, 1876, + /* 160 */ 1876, 1876, 2096, 1906, 1876, 1876, 1876, 1876, 2120, 1876, + /* 170 */ 1876, 1876, 2235, 1876, 1876, 2452, 2512, 1876, 1876, 2455, + /* 180 */ 1876, 1876, 1876, 1876, 2184, 1876, 2442, 1876, 1876, 1876, + /* 190 */ 1876, 1876, 1876, 1876, 1876, 1876, 2049, 2229, 1876, 1876, + /* 200 */ 1876, 2415, 2429, 2496, 2416, 2413, 2436, 1876, 2446, 1876, + /* 210 */ 2271, 1876, 2261, 1973, 1876, 1973, 2222, 2167, 1876, 2177, + /* 220 */ 1876, 2177, 2174, 1876, 1876, 1876, 2177, 2174, 2174, 2038, + /* 230 */ 2034, 1876, 2032, 1876, 1876, 1876, 1876, 1931, 1876, 1931, + /* 240 */ 1876, 1973, 1973, 1876, 1973, 1876, 1876, 1973, 1876, 1973, + /* 250 */ 1876, 1973, 1973, 1876, 1973, 1876, 1876, 1876, 1876, 1876, + /* 260 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 270 */ 1876, 1876, 1876, 1876, 2259, 2245, 1876, 1971, 1876, 2233, + /* 280 */ 2231, 1876, 1971, 2446, 1876, 1876, 2466, 2461, 2466, 2461, + /* 290 */ 2480, 2476, 2466, 2485, 2482, 2448, 2446, 2515, 2502, 2498, + /* 300 */ 2429, 1876, 1876, 2434, 2432, 1876, 1971, 1971, 2461, 1876, + /* 310 */ 1876, 1876, 1876, 2461, 1876, 1876, 1971, 1876, 1971, 1876, + /* 320 */ 1876, 2065, 1876, 1876, 1971, 1876, 1915, 1876, 2224, 2250, + /* 330 */ 2205, 2205, 2099, 2099, 2099, 1974, 1881, 1876, 1876, 1876, + /* 340 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 2479, + /* 350 */ 2478, 2336, 1876, 2387, 2386, 2385, 2376, 2335, 2061, 1876, + /* 360 */ 1876, 2334, 2333, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 370 */ 1876, 2196, 2195, 2327, 1876, 1876, 2328, 2326, 2325, 1876, + /* 380 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 390 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 400 */ 1876, 1876, 1876, 2499, 2503, 1876, 1876, 1876, 1876, 1876, + /* 410 */ 1876, 2412, 1876, 1876, 1876, 2307, 1876, 1876, 1876, 1876, + /* 420 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 430 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 440 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 450 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 460 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 2173, 1876, + /* 470 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 480 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 490 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 500 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 510 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 520 */ 1876, 1876, 1876, 1876, 1876, 2188, 1876, 1876, 1876, 1876, + /* 530 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 540 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 550 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1920, 2314, 1876, + /* 560 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 570 */ 1876, 1876, 2317, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 580 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 590 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 600 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 610 */ 1876, 1876, 1876, 2013, 2012, 1876, 1876, 1876, 1876, 1876, + /* 620 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 630 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 2318, + /* 640 */ 1876, 1876, 1876, 1876, 1876, 2309, 1876, 1876, 1876, 1876, + /* 650 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 660 */ 1876, 1876, 2495, 2449, 1876, 1876, 1876, 1876, 1876, 1876, + /* 670 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 680 */ 1876, 1876, 2307, 1876, 2477, 1876, 1876, 2493, 1876, 2497, + /* 690 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 2422, 2418, 1876, + /* 700 */ 1876, 2414, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 710 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 2306, + /* 720 */ 1876, 2373, 1876, 1876, 1876, 2407, 1876, 1876, 2358, 1876, + /* 730 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 2318, 1876, + /* 740 */ 2321, 1876, 1876, 1876, 1876, 1876, 2093, 1876, 1876, 1876, + /* 750 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 760 */ 1876, 1876, 2077, 2075, 2074, 2073, 1876, 2106, 1876, 1876, + /* 770 */ 1876, 2102, 2101, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 780 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1992, + /* 790 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1984, 1876, + /* 800 */ 1983, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 810 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, + /* 820 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1905, 1876, + /* 830 */ 1876, 1876, 1876, 1876, 1876, }; /********** End of lemon-generated parsing tables *****************************/ @@ -1324,7 +1232,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* BWLIMIT => nothing */ 0, /* START => nothing */ 0, /* TIMESTAMP => nothing */ - 294, /* END => ABORT */ + 296, /* END => ABORT */ 0, /* TABLE => nothing */ 0, /* NK_LP => nothing */ 0, /* NK_RP => nothing */ @@ -1391,6 +1299,8 @@ static const YYCODETYPE yyFallback[] = { 0, /* SUBSCRIPTIONS => nothing */ 0, /* VNODES => nothing */ 0, /* ALIVE => nothing */ + 0, /* VIEWS => nothing */ + 296, /* VIEW => ABORT */ 0, /* NORMAL => nothing */ 0, /* CHILD => nothing */ 0, /* LIKE => nothing */ @@ -1515,56 +1425,55 @@ static const YYCODETYPE yyFallback[] = { 0, /* ASC => nothing */ 0, /* NULLS => nothing */ 0, /* ABORT => nothing */ - 294, /* AFTER => ABORT */ - 294, /* ATTACH => ABORT */ - 294, /* BEFORE => ABORT */ - 294, /* BEGIN => ABORT */ - 294, /* BITAND => ABORT */ - 294, /* BITNOT => ABORT */ - 294, /* BITOR => ABORT */ - 294, /* BLOCKS => ABORT */ - 294, /* CHANGE => ABORT */ - 294, /* COMMA => ABORT */ - 294, /* CONCAT => ABORT */ - 294, /* CONFLICT => ABORT */ - 294, /* COPY => ABORT */ - 294, /* DEFERRED => ABORT */ - 294, /* DELIMITERS => ABORT */ - 294, /* DETACH => ABORT */ - 294, /* DIVIDE => ABORT */ - 294, /* DOT => ABORT */ - 294, /* EACH => ABORT */ - 294, /* FAIL => ABORT */ - 294, /* FILE => ABORT */ - 294, /* FOR => ABORT */ - 294, /* GLOB => ABORT */ - 294, /* ID => ABORT */ - 294, /* IMMEDIATE => ABORT */ - 294, /* IMPORT => ABORT */ - 294, /* INITIALLY => ABORT */ - 294, /* INSTEAD => ABORT */ - 294, /* ISNULL => ABORT */ - 294, /* KEY => ABORT */ - 294, /* MODULES => ABORT */ - 294, /* NK_BITNOT => ABORT */ - 294, /* NK_SEMI => ABORT */ - 294, /* NOTNULL => ABORT */ - 294, /* OF => ABORT */ - 294, /* PLUS => ABORT */ - 294, /* PRIVILEGE => ABORT */ - 294, /* RAISE => ABORT */ - 294, /* RESTRICT => ABORT */ - 294, /* ROW => ABORT */ - 294, /* SEMI => ABORT */ - 294, /* STAR => ABORT */ - 294, /* STATEMENT => ABORT */ - 294, /* STRICT => ABORT */ - 294, /* STRING => ABORT */ - 294, /* TIMES => ABORT */ - 294, /* VALUES => ABORT */ - 294, /* VARIABLE => ABORT */ - 294, /* VIEW => ABORT */ - 294, /* WAL => ABORT */ + 296, /* AFTER => ABORT */ + 296, /* ATTACH => ABORT */ + 296, /* BEFORE => ABORT */ + 296, /* BEGIN => ABORT */ + 296, /* BITAND => ABORT */ + 296, /* BITNOT => ABORT */ + 296, /* BITOR => ABORT */ + 296, /* BLOCKS => ABORT */ + 296, /* CHANGE => ABORT */ + 296, /* COMMA => ABORT */ + 296, /* CONCAT => ABORT */ + 296, /* CONFLICT => ABORT */ + 296, /* COPY => ABORT */ + 296, /* DEFERRED => ABORT */ + 296, /* DELIMITERS => ABORT */ + 296, /* DETACH => ABORT */ + 296, /* DIVIDE => ABORT */ + 296, /* DOT => ABORT */ + 296, /* EACH => ABORT */ + 296, /* FAIL => ABORT */ + 296, /* FILE => ABORT */ + 296, /* FOR => ABORT */ + 296, /* GLOB => ABORT */ + 296, /* ID => ABORT */ + 296, /* IMMEDIATE => ABORT */ + 296, /* IMPORT => ABORT */ + 296, /* INITIALLY => ABORT */ + 296, /* INSTEAD => ABORT */ + 296, /* ISNULL => ABORT */ + 296, /* KEY => ABORT */ + 296, /* MODULES => ABORT */ + 296, /* NK_BITNOT => ABORT */ + 296, /* NK_SEMI => ABORT */ + 296, /* NOTNULL => ABORT */ + 296, /* OF => ABORT */ + 296, /* PLUS => ABORT */ + 296, /* PRIVILEGE => ABORT */ + 296, /* RAISE => ABORT */ + 296, /* RESTRICT => ABORT */ + 296, /* ROW => ABORT */ + 296, /* SEMI => ABORT */ + 296, /* STAR => ABORT */ + 296, /* STATEMENT => ABORT */ + 296, /* STRICT => ABORT */ + 296, /* STRING => ABORT */ + 296, /* TIMES => ABORT */ + 296, /* VALUES => ABORT */ + 296, /* VARIABLE => ABORT */ + 296, /* WAL => ABORT */ }; #endif /* YYFALLBACK */ @@ -1823,339 +1732,342 @@ static const char *const yyTokenName[] = { /* 168 */ "SUBSCRIPTIONS", /* 169 */ "VNODES", /* 170 */ "ALIVE", - /* 171 */ "NORMAL", - /* 172 */ "CHILD", - /* 173 */ "LIKE", - /* 174 */ "TBNAME", - /* 175 */ "QTAGS", - /* 176 */ "AS", - /* 177 */ "SYSTEM", - /* 178 */ "INDEX", - /* 179 */ "FUNCTION", - /* 180 */ "INTERVAL", - /* 181 */ "COUNT", - /* 182 */ "LAST_ROW", - /* 183 */ "META", - /* 184 */ "ONLY", - /* 185 */ "TOPIC", - /* 186 */ "CONSUMER", - /* 187 */ "GROUP", - /* 188 */ "DESC", - /* 189 */ "DESCRIBE", - /* 190 */ "RESET", - /* 191 */ "QUERY", - /* 192 */ "CACHE", - /* 193 */ "EXPLAIN", - /* 194 */ "ANALYZE", - /* 195 */ "VERBOSE", - /* 196 */ "NK_BOOL", - /* 197 */ "RATIO", - /* 198 */ "NK_FLOAT", - /* 199 */ "OUTPUTTYPE", - /* 200 */ "AGGREGATE", - /* 201 */ "BUFSIZE", - /* 202 */ "LANGUAGE", - /* 203 */ "REPLACE", - /* 204 */ "STREAM", - /* 205 */ "INTO", - /* 206 */ "PAUSE", - /* 207 */ "RESUME", - /* 208 */ "TRIGGER", - /* 209 */ "AT_ONCE", - /* 210 */ "WINDOW_CLOSE", - /* 211 */ "IGNORE", - /* 212 */ "EXPIRED", - /* 213 */ "FILL_HISTORY", - /* 214 */ "UPDATE", - /* 215 */ "SUBTABLE", - /* 216 */ "UNTREATED", - /* 217 */ "KILL", - /* 218 */ "CONNECTION", - /* 219 */ "TRANSACTION", - /* 220 */ "BALANCE", - /* 221 */ "VGROUP", - /* 222 */ "LEADER", - /* 223 */ "MERGE", - /* 224 */ "REDISTRIBUTE", - /* 225 */ "SPLIT", - /* 226 */ "DELETE", - /* 227 */ "INSERT", - /* 228 */ "NULL", - /* 229 */ "NK_QUESTION", - /* 230 */ "NK_ALIAS", - /* 231 */ "NK_ARROW", - /* 232 */ "ROWTS", - /* 233 */ "QSTART", - /* 234 */ "QEND", - /* 235 */ "QDURATION", - /* 236 */ "WSTART", - /* 237 */ "WEND", - /* 238 */ "WDURATION", - /* 239 */ "IROWTS", - /* 240 */ "ISFILLED", - /* 241 */ "CAST", - /* 242 */ "NOW", - /* 243 */ "TODAY", - /* 244 */ "TIMEZONE", - /* 245 */ "CLIENT_VERSION", - /* 246 */ "SERVER_VERSION", - /* 247 */ "SERVER_STATUS", - /* 248 */ "CURRENT_USER", - /* 249 */ "CASE", - /* 250 */ "WHEN", - /* 251 */ "THEN", - /* 252 */ "ELSE", - /* 253 */ "BETWEEN", - /* 254 */ "IS", - /* 255 */ "NK_LT", - /* 256 */ "NK_GT", - /* 257 */ "NK_LE", - /* 258 */ "NK_GE", - /* 259 */ "NK_NE", - /* 260 */ "MATCH", - /* 261 */ "NMATCH", - /* 262 */ "CONTAINS", - /* 263 */ "IN", - /* 264 */ "JOIN", - /* 265 */ "INNER", - /* 266 */ "SELECT", - /* 267 */ "NK_HINT", - /* 268 */ "DISTINCT", - /* 269 */ "WHERE", - /* 270 */ "PARTITION", - /* 271 */ "BY", - /* 272 */ "SESSION", - /* 273 */ "STATE_WINDOW", - /* 274 */ "EVENT_WINDOW", - /* 275 */ "SLIDING", - /* 276 */ "FILL", - /* 277 */ "VALUE", - /* 278 */ "VALUE_F", - /* 279 */ "NONE", - /* 280 */ "PREV", - /* 281 */ "NULL_F", - /* 282 */ "LINEAR", - /* 283 */ "NEXT", - /* 284 */ "HAVING", - /* 285 */ "RANGE", - /* 286 */ "EVERY", - /* 287 */ "ORDER", - /* 288 */ "SLIMIT", - /* 289 */ "SOFFSET", - /* 290 */ "LIMIT", - /* 291 */ "OFFSET", - /* 292 */ "ASC", - /* 293 */ "NULLS", - /* 294 */ "ABORT", - /* 295 */ "AFTER", - /* 296 */ "ATTACH", - /* 297 */ "BEFORE", - /* 298 */ "BEGIN", - /* 299 */ "BITAND", - /* 300 */ "BITNOT", - /* 301 */ "BITOR", - /* 302 */ "BLOCKS", - /* 303 */ "CHANGE", - /* 304 */ "COMMA", - /* 305 */ "CONCAT", - /* 306 */ "CONFLICT", - /* 307 */ "COPY", - /* 308 */ "DEFERRED", - /* 309 */ "DELIMITERS", - /* 310 */ "DETACH", - /* 311 */ "DIVIDE", - /* 312 */ "DOT", - /* 313 */ "EACH", - /* 314 */ "FAIL", - /* 315 */ "FILE", - /* 316 */ "FOR", - /* 317 */ "GLOB", - /* 318 */ "ID", - /* 319 */ "IMMEDIATE", - /* 320 */ "IMPORT", - /* 321 */ "INITIALLY", - /* 322 */ "INSTEAD", - /* 323 */ "ISNULL", - /* 324 */ "KEY", - /* 325 */ "MODULES", - /* 326 */ "NK_BITNOT", - /* 327 */ "NK_SEMI", - /* 328 */ "NOTNULL", - /* 329 */ "OF", - /* 330 */ "PLUS", - /* 331 */ "PRIVILEGE", - /* 332 */ "RAISE", - /* 333 */ "RESTRICT", - /* 334 */ "ROW", - /* 335 */ "SEMI", - /* 336 */ "STAR", - /* 337 */ "STATEMENT", - /* 338 */ "STRICT", - /* 339 */ "STRING", - /* 340 */ "TIMES", - /* 341 */ "VALUES", - /* 342 */ "VARIABLE", - /* 343 */ "VIEW", - /* 344 */ "WAL", - /* 345 */ "cmd", - /* 346 */ "account_options", - /* 347 */ "alter_account_options", - /* 348 */ "literal", - /* 349 */ "alter_account_option", - /* 350 */ "ip_range_list", - /* 351 */ "white_list", - /* 352 */ "white_list_opt", - /* 353 */ "user_name", - /* 354 */ "sysinfo_opt", - /* 355 */ "privileges", - /* 356 */ "priv_level", - /* 357 */ "with_opt", - /* 358 */ "priv_type_list", - /* 359 */ "priv_type", - /* 360 */ "db_name", - /* 361 */ "table_name", - /* 362 */ "topic_name", - /* 363 */ "search_condition", - /* 364 */ "dnode_endpoint", - /* 365 */ "force_opt", - /* 366 */ "unsafe_opt", - /* 367 */ "not_exists_opt", - /* 368 */ "db_options", - /* 369 */ "exists_opt", - /* 370 */ "alter_db_options", - /* 371 */ "speed_opt", - /* 372 */ "start_opt", - /* 373 */ "end_opt", - /* 374 */ "integer_list", - /* 375 */ "variable_list", - /* 376 */ "retention_list", - /* 377 */ "signed", - /* 378 */ "alter_db_option", - /* 379 */ "retention", - /* 380 */ "full_table_name", - /* 381 */ "column_def_list", - /* 382 */ "tags_def_opt", - /* 383 */ "table_options", - /* 384 */ "multi_create_clause", - /* 385 */ "tags_def", - /* 386 */ "multi_drop_clause", - /* 387 */ "alter_table_clause", - /* 388 */ "alter_table_options", - /* 389 */ "column_name", - /* 390 */ "type_name", - /* 391 */ "signed_literal", - /* 392 */ "create_subtable_clause", - /* 393 */ "specific_cols_opt", - /* 394 */ "expression_list", - /* 395 */ "drop_table_clause", - /* 396 */ "col_name_list", - /* 397 */ "column_def", - /* 398 */ "duration_list", - /* 399 */ "rollup_func_list", - /* 400 */ "alter_table_option", - /* 401 */ "duration_literal", - /* 402 */ "rollup_func_name", - /* 403 */ "function_name", - /* 404 */ "col_name", - /* 405 */ "db_kind_opt", - /* 406 */ "table_kind_db_name_cond_opt", - /* 407 */ "like_pattern_opt", - /* 408 */ "db_name_cond_opt", - /* 409 */ "table_name_cond", - /* 410 */ "from_db_opt", - /* 411 */ "tag_list_opt", - /* 412 */ "table_kind", - /* 413 */ "tag_item", - /* 414 */ "column_alias", - /* 415 */ "index_options", - /* 416 */ "full_index_name", - /* 417 */ "index_name", - /* 418 */ "func_list", - /* 419 */ "sliding_opt", - /* 420 */ "sma_stream_opt", - /* 421 */ "func", - /* 422 */ "sma_func_name", - /* 423 */ "with_meta", - /* 424 */ "query_or_subquery", - /* 425 */ "where_clause_opt", - /* 426 */ "cgroup_name", - /* 427 */ "analyze_opt", - /* 428 */ "explain_options", - /* 429 */ "insert_query", - /* 430 */ "or_replace_opt", - /* 431 */ "agg_func_opt", - /* 432 */ "bufsize_opt", - /* 433 */ "language_opt", - /* 434 */ "stream_name", - /* 435 */ "stream_options", - /* 436 */ "col_list_opt", - /* 437 */ "tag_def_or_ref_opt", - /* 438 */ "subtable_opt", - /* 439 */ "ignore_opt", - /* 440 */ "expression", - /* 441 */ "on_vgroup_id", - /* 442 */ "dnode_list", - /* 443 */ "literal_func", - /* 444 */ "literal_list", - /* 445 */ "table_alias", - /* 446 */ "expr_or_subquery", - /* 447 */ "pseudo_column", - /* 448 */ "column_reference", - /* 449 */ "function_expression", - /* 450 */ "case_when_expression", - /* 451 */ "star_func", - /* 452 */ "star_func_para_list", - /* 453 */ "noarg_func", - /* 454 */ "other_para_list", - /* 455 */ "star_func_para", - /* 456 */ "when_then_list", - /* 457 */ "case_when_else_opt", - /* 458 */ "common_expression", - /* 459 */ "when_then_expr", - /* 460 */ "predicate", - /* 461 */ "compare_op", - /* 462 */ "in_op", - /* 463 */ "in_predicate_value", - /* 464 */ "boolean_value_expression", - /* 465 */ "boolean_primary", - /* 466 */ "from_clause_opt", - /* 467 */ "table_reference_list", - /* 468 */ "table_reference", - /* 469 */ "table_primary", - /* 470 */ "joined_table", - /* 471 */ "alias_opt", - /* 472 */ "subquery", - /* 473 */ "parenthesized_joined_table", - /* 474 */ "join_type", - /* 475 */ "query_specification", - /* 476 */ "hint_list", - /* 477 */ "set_quantifier_opt", - /* 478 */ "tag_mode_opt", - /* 479 */ "select_list", - /* 480 */ "partition_by_clause_opt", - /* 481 */ "range_opt", - /* 482 */ "every_opt", - /* 483 */ "fill_opt", - /* 484 */ "twindow_clause_opt", - /* 485 */ "group_by_clause_opt", - /* 486 */ "having_clause_opt", - /* 487 */ "select_item", - /* 488 */ "partition_list", - /* 489 */ "partition_item", - /* 490 */ "interval_sliding_duration_literal", - /* 491 */ "fill_mode", - /* 492 */ "group_by_list", - /* 493 */ "query_expression", - /* 494 */ "query_simple", - /* 495 */ "order_by_clause_opt", - /* 496 */ "slimit_clause_opt", - /* 497 */ "limit_clause_opt", - /* 498 */ "union_query_expression", - /* 499 */ "query_simple_or_subquery", - /* 500 */ "sort_specification_list", - /* 501 */ "sort_specification", - /* 502 */ "ordering_specification_opt", - /* 503 */ "null_ordering_opt", + /* 171 */ "VIEWS", + /* 172 */ "VIEW", + /* 173 */ "NORMAL", + /* 174 */ "CHILD", + /* 175 */ "LIKE", + /* 176 */ "TBNAME", + /* 177 */ "QTAGS", + /* 178 */ "AS", + /* 179 */ "SYSTEM", + /* 180 */ "INDEX", + /* 181 */ "FUNCTION", + /* 182 */ "INTERVAL", + /* 183 */ "COUNT", + /* 184 */ "LAST_ROW", + /* 185 */ "META", + /* 186 */ "ONLY", + /* 187 */ "TOPIC", + /* 188 */ "CONSUMER", + /* 189 */ "GROUP", + /* 190 */ "DESC", + /* 191 */ "DESCRIBE", + /* 192 */ "RESET", + /* 193 */ "QUERY", + /* 194 */ "CACHE", + /* 195 */ "EXPLAIN", + /* 196 */ "ANALYZE", + /* 197 */ "VERBOSE", + /* 198 */ "NK_BOOL", + /* 199 */ "RATIO", + /* 200 */ "NK_FLOAT", + /* 201 */ "OUTPUTTYPE", + /* 202 */ "AGGREGATE", + /* 203 */ "BUFSIZE", + /* 204 */ "LANGUAGE", + /* 205 */ "REPLACE", + /* 206 */ "STREAM", + /* 207 */ "INTO", + /* 208 */ "PAUSE", + /* 209 */ "RESUME", + /* 210 */ "TRIGGER", + /* 211 */ "AT_ONCE", + /* 212 */ "WINDOW_CLOSE", + /* 213 */ "IGNORE", + /* 214 */ "EXPIRED", + /* 215 */ "FILL_HISTORY", + /* 216 */ "UPDATE", + /* 217 */ "SUBTABLE", + /* 218 */ "UNTREATED", + /* 219 */ "KILL", + /* 220 */ "CONNECTION", + /* 221 */ "TRANSACTION", + /* 222 */ "BALANCE", + /* 223 */ "VGROUP", + /* 224 */ "LEADER", + /* 225 */ "MERGE", + /* 226 */ "REDISTRIBUTE", + /* 227 */ "SPLIT", + /* 228 */ "DELETE", + /* 229 */ "INSERT", + /* 230 */ "NULL", + /* 231 */ "NK_QUESTION", + /* 232 */ "NK_ALIAS", + /* 233 */ "NK_ARROW", + /* 234 */ "ROWTS", + /* 235 */ "QSTART", + /* 236 */ "QEND", + /* 237 */ "QDURATION", + /* 238 */ "WSTART", + /* 239 */ "WEND", + /* 240 */ "WDURATION", + /* 241 */ "IROWTS", + /* 242 */ "ISFILLED", + /* 243 */ "CAST", + /* 244 */ "NOW", + /* 245 */ "TODAY", + /* 246 */ "TIMEZONE", + /* 247 */ "CLIENT_VERSION", + /* 248 */ "SERVER_VERSION", + /* 249 */ "SERVER_STATUS", + /* 250 */ "CURRENT_USER", + /* 251 */ "CASE", + /* 252 */ "WHEN", + /* 253 */ "THEN", + /* 254 */ "ELSE", + /* 255 */ "BETWEEN", + /* 256 */ "IS", + /* 257 */ "NK_LT", + /* 258 */ "NK_GT", + /* 259 */ "NK_LE", + /* 260 */ "NK_GE", + /* 261 */ "NK_NE", + /* 262 */ "MATCH", + /* 263 */ "NMATCH", + /* 264 */ "CONTAINS", + /* 265 */ "IN", + /* 266 */ "JOIN", + /* 267 */ "INNER", + /* 268 */ "SELECT", + /* 269 */ "NK_HINT", + /* 270 */ "DISTINCT", + /* 271 */ "WHERE", + /* 272 */ "PARTITION", + /* 273 */ "BY", + /* 274 */ "SESSION", + /* 275 */ "STATE_WINDOW", + /* 276 */ "EVENT_WINDOW", + /* 277 */ "SLIDING", + /* 278 */ "FILL", + /* 279 */ "VALUE", + /* 280 */ "VALUE_F", + /* 281 */ "NONE", + /* 282 */ "PREV", + /* 283 */ "NULL_F", + /* 284 */ "LINEAR", + /* 285 */ "NEXT", + /* 286 */ "HAVING", + /* 287 */ "RANGE", + /* 288 */ "EVERY", + /* 289 */ "ORDER", + /* 290 */ "SLIMIT", + /* 291 */ "SOFFSET", + /* 292 */ "LIMIT", + /* 293 */ "OFFSET", + /* 294 */ "ASC", + /* 295 */ "NULLS", + /* 296 */ "ABORT", + /* 297 */ "AFTER", + /* 298 */ "ATTACH", + /* 299 */ "BEFORE", + /* 300 */ "BEGIN", + /* 301 */ "BITAND", + /* 302 */ "BITNOT", + /* 303 */ "BITOR", + /* 304 */ "BLOCKS", + /* 305 */ "CHANGE", + /* 306 */ "COMMA", + /* 307 */ "CONCAT", + /* 308 */ "CONFLICT", + /* 309 */ "COPY", + /* 310 */ "DEFERRED", + /* 311 */ "DELIMITERS", + /* 312 */ "DETACH", + /* 313 */ "DIVIDE", + /* 314 */ "DOT", + /* 315 */ "EACH", + /* 316 */ "FAIL", + /* 317 */ "FILE", + /* 318 */ "FOR", + /* 319 */ "GLOB", + /* 320 */ "ID", + /* 321 */ "IMMEDIATE", + /* 322 */ "IMPORT", + /* 323 */ "INITIALLY", + /* 324 */ "INSTEAD", + /* 325 */ "ISNULL", + /* 326 */ "KEY", + /* 327 */ "MODULES", + /* 328 */ "NK_BITNOT", + /* 329 */ "NK_SEMI", + /* 330 */ "NOTNULL", + /* 331 */ "OF", + /* 332 */ "PLUS", + /* 333 */ "PRIVILEGE", + /* 334 */ "RAISE", + /* 335 */ "RESTRICT", + /* 336 */ "ROW", + /* 337 */ "SEMI", + /* 338 */ "STAR", + /* 339 */ "STATEMENT", + /* 340 */ "STRICT", + /* 341 */ "STRING", + /* 342 */ "TIMES", + /* 343 */ "VALUES", + /* 344 */ "VARIABLE", + /* 345 */ "WAL", + /* 346 */ "cmd", + /* 347 */ "account_options", + /* 348 */ "alter_account_options", + /* 349 */ "literal", + /* 350 */ "alter_account_option", + /* 351 */ "ip_range_list", + /* 352 */ "white_list", + /* 353 */ "white_list_opt", + /* 354 */ "user_name", + /* 355 */ "sysinfo_opt", + /* 356 */ "privileges", + /* 357 */ "priv_level", + /* 358 */ "with_opt", + /* 359 */ "priv_type_list", + /* 360 */ "priv_type", + /* 361 */ "db_name", + /* 362 */ "table_name", + /* 363 */ "topic_name", + /* 364 */ "search_condition", + /* 365 */ "dnode_endpoint", + /* 366 */ "force_opt", + /* 367 */ "unsafe_opt", + /* 368 */ "not_exists_opt", + /* 369 */ "db_options", + /* 370 */ "exists_opt", + /* 371 */ "alter_db_options", + /* 372 */ "speed_opt", + /* 373 */ "start_opt", + /* 374 */ "end_opt", + /* 375 */ "integer_list", + /* 376 */ "variable_list", + /* 377 */ "retention_list", + /* 378 */ "signed", + /* 379 */ "alter_db_option", + /* 380 */ "retention", + /* 381 */ "full_table_name", + /* 382 */ "column_def_list", + /* 383 */ "tags_def_opt", + /* 384 */ "table_options", + /* 385 */ "multi_create_clause", + /* 386 */ "tags_def", + /* 387 */ "multi_drop_clause", + /* 388 */ "alter_table_clause", + /* 389 */ "alter_table_options", + /* 390 */ "column_name", + /* 391 */ "type_name", + /* 392 */ "signed_literal", + /* 393 */ "create_subtable_clause", + /* 394 */ "specific_cols_opt", + /* 395 */ "expression_list", + /* 396 */ "drop_table_clause", + /* 397 */ "col_name_list", + /* 398 */ "column_def", + /* 399 */ "duration_list", + /* 400 */ "rollup_func_list", + /* 401 */ "alter_table_option", + /* 402 */ "duration_literal", + /* 403 */ "rollup_func_name", + /* 404 */ "function_name", + /* 405 */ "col_name", + /* 406 */ "db_kind_opt", + /* 407 */ "table_kind_db_name_cond_opt", + /* 408 */ "like_pattern_opt", + /* 409 */ "db_name_cond_opt", + /* 410 */ "table_name_cond", + /* 411 */ "from_db_opt", + /* 412 */ "tag_list_opt", + /* 413 */ "table_kind", + /* 414 */ "tag_item", + /* 415 */ "column_alias", + /* 416 */ "index_options", + /* 417 */ "full_index_name", + /* 418 */ "index_name", + /* 419 */ "func_list", + /* 420 */ "sliding_opt", + /* 421 */ "sma_stream_opt", + /* 422 */ "func", + /* 423 */ "sma_func_name", + /* 424 */ "with_meta", + /* 425 */ "query_or_subquery", + /* 426 */ "where_clause_opt", + /* 427 */ "cgroup_name", + /* 428 */ "analyze_opt", + /* 429 */ "explain_options", + /* 430 */ "insert_query", + /* 431 */ "or_replace_opt", + /* 432 */ "agg_func_opt", + /* 433 */ "bufsize_opt", + /* 434 */ "language_opt", + /* 435 */ "full_view_name", + /* 436 */ "view_name", + /* 437 */ "stream_name", + /* 438 */ "stream_options", + /* 439 */ "col_list_opt", + /* 440 */ "tag_def_or_ref_opt", + /* 441 */ "subtable_opt", + /* 442 */ "ignore_opt", + /* 443 */ "expression", + /* 444 */ "on_vgroup_id", + /* 445 */ "dnode_list", + /* 446 */ "literal_func", + /* 447 */ "literal_list", + /* 448 */ "table_alias", + /* 449 */ "expr_or_subquery", + /* 450 */ "pseudo_column", + /* 451 */ "column_reference", + /* 452 */ "function_expression", + /* 453 */ "case_when_expression", + /* 454 */ "star_func", + /* 455 */ "star_func_para_list", + /* 456 */ "noarg_func", + /* 457 */ "other_para_list", + /* 458 */ "star_func_para", + /* 459 */ "when_then_list", + /* 460 */ "case_when_else_opt", + /* 461 */ "common_expression", + /* 462 */ "when_then_expr", + /* 463 */ "predicate", + /* 464 */ "compare_op", + /* 465 */ "in_op", + /* 466 */ "in_predicate_value", + /* 467 */ "boolean_value_expression", + /* 468 */ "boolean_primary", + /* 469 */ "from_clause_opt", + /* 470 */ "table_reference_list", + /* 471 */ "table_reference", + /* 472 */ "table_primary", + /* 473 */ "joined_table", + /* 474 */ "alias_opt", + /* 475 */ "subquery", + /* 476 */ "parenthesized_joined_table", + /* 477 */ "join_type", + /* 478 */ "query_specification", + /* 479 */ "hint_list", + /* 480 */ "set_quantifier_opt", + /* 481 */ "tag_mode_opt", + /* 482 */ "select_list", + /* 483 */ "partition_by_clause_opt", + /* 484 */ "range_opt", + /* 485 */ "every_opt", + /* 486 */ "fill_opt", + /* 487 */ "twindow_clause_opt", + /* 488 */ "group_by_clause_opt", + /* 489 */ "having_clause_opt", + /* 490 */ "select_item", + /* 491 */ "partition_list", + /* 492 */ "partition_item", + /* 493 */ "interval_sliding_duration_literal", + /* 494 */ "fill_mode", + /* 495 */ "group_by_list", + /* 496 */ "query_expression", + /* 497 */ "query_simple", + /* 498 */ "order_by_clause_opt", + /* 499 */ "slimit_clause_opt", + /* 500 */ "limit_clause_opt", + /* 501 */ "union_query_expression", + /* 502 */ "query_simple_or_subquery", + /* 503 */ "sort_specification_list", + /* 504 */ "sort_specification", + /* 505 */ "ordering_specification_opt", + /* 506 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -2210,590 +2122,598 @@ static const char *const yyRuleName[] = { /* 44 */ "priv_type_list ::= priv_type_list NK_COMMA priv_type", /* 45 */ "priv_type ::= READ", /* 46 */ "priv_type ::= WRITE", - /* 47 */ "priv_level ::= NK_STAR NK_DOT NK_STAR", - /* 48 */ "priv_level ::= db_name NK_DOT NK_STAR", - /* 49 */ "priv_level ::= db_name NK_DOT table_name", - /* 50 */ "priv_level ::= topic_name", - /* 51 */ "with_opt ::=", - /* 52 */ "with_opt ::= WITH search_condition", - /* 53 */ "cmd ::= CREATE DNODE dnode_endpoint", - /* 54 */ "cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER", - /* 55 */ "cmd ::= DROP DNODE NK_INTEGER force_opt", - /* 56 */ "cmd ::= DROP DNODE dnode_endpoint force_opt", - /* 57 */ "cmd ::= DROP DNODE NK_INTEGER unsafe_opt", - /* 58 */ "cmd ::= DROP DNODE dnode_endpoint unsafe_opt", - /* 59 */ "cmd ::= ALTER DNODE NK_INTEGER NK_STRING", - /* 60 */ "cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING", - /* 61 */ "cmd ::= ALTER ALL DNODES NK_STRING", - /* 62 */ "cmd ::= ALTER ALL DNODES NK_STRING NK_STRING", - /* 63 */ "cmd ::= RESTORE DNODE NK_INTEGER", - /* 64 */ "dnode_endpoint ::= NK_STRING", - /* 65 */ "dnode_endpoint ::= NK_ID", - /* 66 */ "dnode_endpoint ::= NK_IPTOKEN", - /* 67 */ "force_opt ::=", - /* 68 */ "force_opt ::= FORCE", - /* 69 */ "unsafe_opt ::= UNSAFE", - /* 70 */ "cmd ::= ALTER LOCAL NK_STRING", - /* 71 */ "cmd ::= ALTER LOCAL NK_STRING NK_STRING", - /* 72 */ "cmd ::= CREATE QNODE ON DNODE NK_INTEGER", - /* 73 */ "cmd ::= DROP QNODE ON DNODE NK_INTEGER", - /* 74 */ "cmd ::= RESTORE QNODE ON DNODE NK_INTEGER", - /* 75 */ "cmd ::= CREATE BNODE ON DNODE NK_INTEGER", - /* 76 */ "cmd ::= DROP BNODE ON DNODE NK_INTEGER", - /* 77 */ "cmd ::= CREATE SNODE ON DNODE NK_INTEGER", - /* 78 */ "cmd ::= DROP SNODE ON DNODE NK_INTEGER", - /* 79 */ "cmd ::= CREATE MNODE ON DNODE NK_INTEGER", - /* 80 */ "cmd ::= DROP MNODE ON DNODE NK_INTEGER", - /* 81 */ "cmd ::= RESTORE MNODE ON DNODE NK_INTEGER", - /* 82 */ "cmd ::= RESTORE VNODE ON DNODE NK_INTEGER", - /* 83 */ "cmd ::= CREATE DATABASE not_exists_opt db_name db_options", - /* 84 */ "cmd ::= DROP DATABASE exists_opt db_name", - /* 85 */ "cmd ::= USE db_name", - /* 86 */ "cmd ::= ALTER DATABASE db_name alter_db_options", - /* 87 */ "cmd ::= FLUSH DATABASE db_name", - /* 88 */ "cmd ::= TRIM DATABASE db_name speed_opt", - /* 89 */ "cmd ::= COMPACT DATABASE db_name start_opt end_opt", - /* 90 */ "not_exists_opt ::= IF NOT EXISTS", - /* 91 */ "not_exists_opt ::=", - /* 92 */ "exists_opt ::= IF EXISTS", - /* 93 */ "exists_opt ::=", - /* 94 */ "db_options ::=", - /* 95 */ "db_options ::= db_options BUFFER NK_INTEGER", - /* 96 */ "db_options ::= db_options CACHEMODEL NK_STRING", - /* 97 */ "db_options ::= db_options CACHESIZE NK_INTEGER", - /* 98 */ "db_options ::= db_options COMP NK_INTEGER", - /* 99 */ "db_options ::= db_options DURATION NK_INTEGER", - /* 100 */ "db_options ::= db_options DURATION NK_VARIABLE", - /* 101 */ "db_options ::= db_options MAXROWS NK_INTEGER", - /* 102 */ "db_options ::= db_options MINROWS NK_INTEGER", - /* 103 */ "db_options ::= db_options KEEP integer_list", - /* 104 */ "db_options ::= db_options KEEP variable_list", - /* 105 */ "db_options ::= db_options PAGES NK_INTEGER", - /* 106 */ "db_options ::= db_options PAGESIZE NK_INTEGER", - /* 107 */ "db_options ::= db_options TSDB_PAGESIZE NK_INTEGER", - /* 108 */ "db_options ::= db_options PRECISION NK_STRING", - /* 109 */ "db_options ::= db_options REPLICA NK_INTEGER", - /* 110 */ "db_options ::= db_options VGROUPS NK_INTEGER", - /* 111 */ "db_options ::= db_options SINGLE_STABLE NK_INTEGER", - /* 112 */ "db_options ::= db_options RETENTIONS retention_list", - /* 113 */ "db_options ::= db_options SCHEMALESS NK_INTEGER", - /* 114 */ "db_options ::= db_options WAL_LEVEL NK_INTEGER", - /* 115 */ "db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER", - /* 116 */ "db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER", - /* 117 */ "db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER", - /* 118 */ "db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER", - /* 119 */ "db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER", - /* 120 */ "db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER", - /* 121 */ "db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER", - /* 122 */ "db_options ::= db_options STT_TRIGGER NK_INTEGER", - /* 123 */ "db_options ::= db_options TABLE_PREFIX signed", - /* 124 */ "db_options ::= db_options TABLE_SUFFIX signed", - /* 125 */ "db_options ::= db_options KEEP_TIME_OFFSET NK_INTEGER", - /* 126 */ "alter_db_options ::= alter_db_option", - /* 127 */ "alter_db_options ::= alter_db_options alter_db_option", - /* 128 */ "alter_db_option ::= BUFFER NK_INTEGER", - /* 129 */ "alter_db_option ::= CACHEMODEL NK_STRING", - /* 130 */ "alter_db_option ::= CACHESIZE NK_INTEGER", - /* 131 */ "alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER", - /* 132 */ "alter_db_option ::= KEEP integer_list", - /* 133 */ "alter_db_option ::= KEEP variable_list", - /* 134 */ "alter_db_option ::= PAGES NK_INTEGER", - /* 135 */ "alter_db_option ::= REPLICA NK_INTEGER", - /* 136 */ "alter_db_option ::= WAL_LEVEL NK_INTEGER", - /* 137 */ "alter_db_option ::= STT_TRIGGER NK_INTEGER", - /* 138 */ "alter_db_option ::= MINROWS NK_INTEGER", - /* 139 */ "alter_db_option ::= WAL_RETENTION_PERIOD NK_INTEGER", - /* 140 */ "alter_db_option ::= WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER", - /* 141 */ "alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER", - /* 142 */ "alter_db_option ::= WAL_RETENTION_SIZE NK_MINUS NK_INTEGER", - /* 143 */ "alter_db_option ::= KEEP_TIME_OFFSET NK_INTEGER", - /* 144 */ "integer_list ::= NK_INTEGER", - /* 145 */ "integer_list ::= integer_list NK_COMMA NK_INTEGER", - /* 146 */ "variable_list ::= NK_VARIABLE", - /* 147 */ "variable_list ::= variable_list NK_COMMA NK_VARIABLE", - /* 148 */ "retention_list ::= retention", - /* 149 */ "retention_list ::= retention_list NK_COMMA retention", - /* 150 */ "retention ::= NK_VARIABLE NK_COLON NK_VARIABLE", - /* 151 */ "retention ::= NK_MINUS NK_COLON NK_VARIABLE", - /* 152 */ "speed_opt ::=", - /* 153 */ "speed_opt ::= BWLIMIT NK_INTEGER", - /* 154 */ "start_opt ::=", - /* 155 */ "start_opt ::= START WITH NK_INTEGER", - /* 156 */ "start_opt ::= START WITH NK_STRING", - /* 157 */ "start_opt ::= START WITH TIMESTAMP NK_STRING", - /* 158 */ "end_opt ::=", - /* 159 */ "end_opt ::= END WITH NK_INTEGER", - /* 160 */ "end_opt ::= END WITH NK_STRING", - /* 161 */ "end_opt ::= END WITH TIMESTAMP NK_STRING", - /* 162 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", - /* 163 */ "cmd ::= CREATE TABLE multi_create_clause", - /* 164 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", - /* 165 */ "cmd ::= DROP TABLE multi_drop_clause", - /* 166 */ "cmd ::= DROP STABLE exists_opt full_table_name", - /* 167 */ "cmd ::= ALTER TABLE alter_table_clause", - /* 168 */ "cmd ::= ALTER STABLE alter_table_clause", - /* 169 */ "alter_table_clause ::= full_table_name alter_table_options", - /* 170 */ "alter_table_clause ::= full_table_name ADD COLUMN column_name type_name", - /* 171 */ "alter_table_clause ::= full_table_name DROP COLUMN column_name", - /* 172 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name", - /* 173 */ "alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name", - /* 174 */ "alter_table_clause ::= full_table_name ADD TAG column_name type_name", - /* 175 */ "alter_table_clause ::= full_table_name DROP TAG column_name", - /* 176 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name", - /* 177 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name", - /* 178 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal", - /* 179 */ "multi_create_clause ::= create_subtable_clause", - /* 180 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", - /* 181 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options", - /* 182 */ "multi_drop_clause ::= drop_table_clause", - /* 183 */ "multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause", - /* 184 */ "drop_table_clause ::= exists_opt full_table_name", - /* 185 */ "specific_cols_opt ::=", - /* 186 */ "specific_cols_opt ::= NK_LP col_name_list NK_RP", - /* 187 */ "full_table_name ::= table_name", - /* 188 */ "full_table_name ::= db_name NK_DOT table_name", - /* 189 */ "column_def_list ::= column_def", - /* 190 */ "column_def_list ::= column_def_list NK_COMMA column_def", - /* 191 */ "column_def ::= column_name type_name", - /* 192 */ "type_name ::= BOOL", - /* 193 */ "type_name ::= TINYINT", - /* 194 */ "type_name ::= SMALLINT", - /* 195 */ "type_name ::= INT", - /* 196 */ "type_name ::= INTEGER", - /* 197 */ "type_name ::= BIGINT", - /* 198 */ "type_name ::= FLOAT", - /* 199 */ "type_name ::= DOUBLE", - /* 200 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", - /* 201 */ "type_name ::= TIMESTAMP", - /* 202 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", - /* 203 */ "type_name ::= TINYINT UNSIGNED", - /* 204 */ "type_name ::= SMALLINT UNSIGNED", - /* 205 */ "type_name ::= INT UNSIGNED", - /* 206 */ "type_name ::= BIGINT UNSIGNED", - /* 207 */ "type_name ::= JSON", - /* 208 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", - /* 209 */ "type_name ::= MEDIUMBLOB", - /* 210 */ "type_name ::= BLOB", - /* 211 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", - /* 212 */ "type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP", - /* 213 */ "type_name ::= DECIMAL", - /* 214 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", - /* 215 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", - /* 216 */ "tags_def_opt ::=", - /* 217 */ "tags_def_opt ::= tags_def", - /* 218 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", - /* 219 */ "table_options ::=", - /* 220 */ "table_options ::= table_options COMMENT NK_STRING", - /* 221 */ "table_options ::= table_options MAX_DELAY duration_list", - /* 222 */ "table_options ::= table_options WATERMARK duration_list", - /* 223 */ "table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP", - /* 224 */ "table_options ::= table_options TTL NK_INTEGER", - /* 225 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", - /* 226 */ "table_options ::= table_options DELETE_MARK duration_list", - /* 227 */ "alter_table_options ::= alter_table_option", - /* 228 */ "alter_table_options ::= alter_table_options alter_table_option", - /* 229 */ "alter_table_option ::= COMMENT NK_STRING", - /* 230 */ "alter_table_option ::= TTL NK_INTEGER", - /* 231 */ "duration_list ::= duration_literal", - /* 232 */ "duration_list ::= duration_list NK_COMMA duration_literal", - /* 233 */ "rollup_func_list ::= rollup_func_name", - /* 234 */ "rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name", - /* 235 */ "rollup_func_name ::= function_name", - /* 236 */ "rollup_func_name ::= FIRST", - /* 237 */ "rollup_func_name ::= LAST", - /* 238 */ "col_name_list ::= col_name", - /* 239 */ "col_name_list ::= col_name_list NK_COMMA col_name", - /* 240 */ "col_name ::= column_name", - /* 241 */ "cmd ::= SHOW DNODES", - /* 242 */ "cmd ::= SHOW USERS", - /* 243 */ "cmd ::= SHOW USER PRIVILEGES", - /* 244 */ "cmd ::= SHOW db_kind_opt DATABASES", - /* 245 */ "cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt", - /* 246 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt", - /* 247 */ "cmd ::= SHOW db_name_cond_opt VGROUPS", - /* 248 */ "cmd ::= SHOW MNODES", - /* 249 */ "cmd ::= SHOW QNODES", - /* 250 */ "cmd ::= SHOW FUNCTIONS", - /* 251 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", - /* 252 */ "cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name", - /* 253 */ "cmd ::= SHOW STREAMS", - /* 254 */ "cmd ::= SHOW ACCOUNTS", - /* 255 */ "cmd ::= SHOW APPS", - /* 256 */ "cmd ::= SHOW CONNECTIONS", - /* 257 */ "cmd ::= SHOW LICENCES", - /* 258 */ "cmd ::= SHOW GRANTS", - /* 259 */ "cmd ::= SHOW CREATE DATABASE db_name", - /* 260 */ "cmd ::= SHOW CREATE TABLE full_table_name", - /* 261 */ "cmd ::= SHOW CREATE STABLE full_table_name", - /* 262 */ "cmd ::= SHOW QUERIES", - /* 263 */ "cmd ::= SHOW SCORES", - /* 264 */ "cmd ::= SHOW TOPICS", - /* 265 */ "cmd ::= SHOW VARIABLES", - /* 266 */ "cmd ::= SHOW CLUSTER VARIABLES", - /* 267 */ "cmd ::= SHOW LOCAL VARIABLES", - /* 268 */ "cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt", - /* 269 */ "cmd ::= SHOW BNODES", - /* 270 */ "cmd ::= SHOW SNODES", - /* 271 */ "cmd ::= SHOW CLUSTER", - /* 272 */ "cmd ::= SHOW TRANSACTIONS", - /* 273 */ "cmd ::= SHOW TABLE DISTRIBUTED full_table_name", - /* 274 */ "cmd ::= SHOW CONSUMERS", - /* 275 */ "cmd ::= SHOW SUBSCRIPTIONS", - /* 276 */ "cmd ::= SHOW TAGS FROM table_name_cond from_db_opt", - /* 277 */ "cmd ::= SHOW TAGS FROM db_name NK_DOT table_name", - /* 278 */ "cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt", - /* 279 */ "cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name", - /* 280 */ "cmd ::= SHOW VNODES ON DNODE NK_INTEGER", - /* 281 */ "cmd ::= SHOW VNODES", - /* 282 */ "cmd ::= SHOW db_name_cond_opt ALIVE", - /* 283 */ "cmd ::= SHOW CLUSTER ALIVE", - /* 284 */ "table_kind_db_name_cond_opt ::=", - /* 285 */ "table_kind_db_name_cond_opt ::= table_kind", - /* 286 */ "table_kind_db_name_cond_opt ::= db_name NK_DOT", - /* 287 */ "table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT", - /* 288 */ "table_kind ::= NORMAL", - /* 289 */ "table_kind ::= CHILD", - /* 290 */ "db_name_cond_opt ::=", - /* 291 */ "db_name_cond_opt ::= db_name NK_DOT", - /* 292 */ "like_pattern_opt ::=", - /* 293 */ "like_pattern_opt ::= LIKE NK_STRING", - /* 294 */ "table_name_cond ::= table_name", - /* 295 */ "from_db_opt ::=", - /* 296 */ "from_db_opt ::= FROM db_name", - /* 297 */ "tag_list_opt ::=", - /* 298 */ "tag_list_opt ::= tag_item", - /* 299 */ "tag_list_opt ::= tag_list_opt NK_COMMA tag_item", - /* 300 */ "tag_item ::= TBNAME", - /* 301 */ "tag_item ::= QTAGS", - /* 302 */ "tag_item ::= column_name", - /* 303 */ "tag_item ::= column_name column_alias", - /* 304 */ "tag_item ::= column_name AS column_alias", - /* 305 */ "db_kind_opt ::=", - /* 306 */ "db_kind_opt ::= USER", - /* 307 */ "db_kind_opt ::= SYSTEM", - /* 308 */ "cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options", - /* 309 */ "cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP", - /* 310 */ "cmd ::= DROP INDEX exists_opt full_index_name", - /* 311 */ "full_index_name ::= index_name", - /* 312 */ "full_index_name ::= db_name NK_DOT index_name", - /* 313 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", - /* 314 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt", - /* 315 */ "func_list ::= func", - /* 316 */ "func_list ::= func_list NK_COMMA func", - /* 317 */ "func ::= sma_func_name NK_LP expression_list NK_RP", - /* 318 */ "sma_func_name ::= function_name", - /* 319 */ "sma_func_name ::= COUNT", - /* 320 */ "sma_func_name ::= FIRST", - /* 321 */ "sma_func_name ::= LAST", - /* 322 */ "sma_func_name ::= LAST_ROW", - /* 323 */ "sma_stream_opt ::=", - /* 324 */ "sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal", - /* 325 */ "sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal", - /* 326 */ "sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal", - /* 327 */ "with_meta ::= AS", - /* 328 */ "with_meta ::= WITH META AS", - /* 329 */ "with_meta ::= ONLY META AS", - /* 330 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery", - /* 331 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name", - /* 332 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt", - /* 333 */ "cmd ::= DROP TOPIC exists_opt topic_name", - /* 334 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", - /* 335 */ "cmd ::= DESC full_table_name", - /* 336 */ "cmd ::= DESCRIBE full_table_name", - /* 337 */ "cmd ::= RESET QUERY CACHE", - /* 338 */ "cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery", - /* 339 */ "cmd ::= EXPLAIN analyze_opt explain_options insert_query", - /* 340 */ "analyze_opt ::=", - /* 341 */ "analyze_opt ::= ANALYZE", - /* 342 */ "explain_options ::=", - /* 343 */ "explain_options ::= explain_options VERBOSE NK_BOOL", - /* 344 */ "explain_options ::= explain_options RATIO NK_FLOAT", - /* 345 */ "cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt", - /* 346 */ "cmd ::= DROP FUNCTION exists_opt function_name", - /* 347 */ "agg_func_opt ::=", - /* 348 */ "agg_func_opt ::= AGGREGATE", - /* 349 */ "bufsize_opt ::=", - /* 350 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", - /* 351 */ "language_opt ::=", - /* 352 */ "language_opt ::= LANGUAGE NK_STRING", - /* 353 */ "or_replace_opt ::=", - /* 354 */ "or_replace_opt ::= OR REPLACE", - /* 355 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery", - /* 356 */ "cmd ::= DROP STREAM exists_opt stream_name", - /* 357 */ "cmd ::= PAUSE STREAM exists_opt stream_name", - /* 358 */ "cmd ::= RESUME STREAM exists_opt ignore_opt stream_name", - /* 359 */ "col_list_opt ::=", - /* 360 */ "col_list_opt ::= NK_LP col_name_list NK_RP", - /* 361 */ "tag_def_or_ref_opt ::=", - /* 362 */ "tag_def_or_ref_opt ::= tags_def", - /* 363 */ "tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP", - /* 364 */ "stream_options ::=", - /* 365 */ "stream_options ::= stream_options TRIGGER AT_ONCE", - /* 366 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", - /* 367 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", - /* 368 */ "stream_options ::= stream_options WATERMARK duration_literal", - /* 369 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER", - /* 370 */ "stream_options ::= stream_options FILL_HISTORY NK_INTEGER", - /* 371 */ "stream_options ::= stream_options DELETE_MARK duration_literal", - /* 372 */ "stream_options ::= stream_options IGNORE UPDATE NK_INTEGER", - /* 373 */ "subtable_opt ::=", - /* 374 */ "subtable_opt ::= SUBTABLE NK_LP expression NK_RP", - /* 375 */ "ignore_opt ::=", - /* 376 */ "ignore_opt ::= IGNORE UNTREATED", - /* 377 */ "cmd ::= KILL CONNECTION NK_INTEGER", - /* 378 */ "cmd ::= KILL QUERY NK_STRING", - /* 379 */ "cmd ::= KILL TRANSACTION NK_INTEGER", - /* 380 */ "cmd ::= BALANCE VGROUP", - /* 381 */ "cmd ::= BALANCE VGROUP LEADER on_vgroup_id", - /* 382 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", - /* 383 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", - /* 384 */ "cmd ::= SPLIT VGROUP NK_INTEGER", - /* 385 */ "on_vgroup_id ::=", - /* 386 */ "on_vgroup_id ::= ON NK_INTEGER", - /* 387 */ "dnode_list ::= DNODE NK_INTEGER", - /* 388 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", - /* 389 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", - /* 390 */ "cmd ::= query_or_subquery", - /* 391 */ "cmd ::= insert_query", - /* 392 */ "insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", - /* 393 */ "insert_query ::= INSERT INTO full_table_name query_or_subquery", - /* 394 */ "literal ::= NK_INTEGER", - /* 395 */ "literal ::= NK_FLOAT", - /* 396 */ "literal ::= NK_STRING", - /* 397 */ "literal ::= NK_BOOL", - /* 398 */ "literal ::= TIMESTAMP NK_STRING", - /* 399 */ "literal ::= duration_literal", - /* 400 */ "literal ::= NULL", - /* 401 */ "literal ::= NK_QUESTION", - /* 402 */ "duration_literal ::= NK_VARIABLE", - /* 403 */ "signed ::= NK_INTEGER", - /* 404 */ "signed ::= NK_PLUS NK_INTEGER", - /* 405 */ "signed ::= NK_MINUS NK_INTEGER", - /* 406 */ "signed ::= NK_FLOAT", - /* 407 */ "signed ::= NK_PLUS NK_FLOAT", - /* 408 */ "signed ::= NK_MINUS NK_FLOAT", - /* 409 */ "signed_literal ::= signed", - /* 410 */ "signed_literal ::= NK_STRING", - /* 411 */ "signed_literal ::= NK_BOOL", - /* 412 */ "signed_literal ::= TIMESTAMP NK_STRING", - /* 413 */ "signed_literal ::= duration_literal", - /* 414 */ "signed_literal ::= NULL", - /* 415 */ "signed_literal ::= literal_func", - /* 416 */ "signed_literal ::= NK_QUESTION", - /* 417 */ "literal_list ::= signed_literal", - /* 418 */ "literal_list ::= literal_list NK_COMMA signed_literal", - /* 419 */ "db_name ::= NK_ID", - /* 420 */ "table_name ::= NK_ID", - /* 421 */ "column_name ::= NK_ID", - /* 422 */ "function_name ::= NK_ID", - /* 423 */ "table_alias ::= NK_ID", - /* 424 */ "column_alias ::= NK_ID", - /* 425 */ "column_alias ::= NK_ALIAS", - /* 426 */ "user_name ::= NK_ID", - /* 427 */ "topic_name ::= NK_ID", - /* 428 */ "stream_name ::= NK_ID", - /* 429 */ "cgroup_name ::= NK_ID", - /* 430 */ "index_name ::= NK_ID", - /* 431 */ "expr_or_subquery ::= expression", - /* 432 */ "expression ::= literal", - /* 433 */ "expression ::= pseudo_column", - /* 434 */ "expression ::= column_reference", - /* 435 */ "expression ::= function_expression", - /* 436 */ "expression ::= case_when_expression", - /* 437 */ "expression ::= NK_LP expression NK_RP", - /* 438 */ "expression ::= NK_PLUS expr_or_subquery", - /* 439 */ "expression ::= NK_MINUS expr_or_subquery", - /* 440 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", - /* 441 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", - /* 442 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", - /* 443 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", - /* 444 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", - /* 445 */ "expression ::= column_reference NK_ARROW NK_STRING", - /* 446 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", - /* 447 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", - /* 448 */ "expression_list ::= expr_or_subquery", - /* 449 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", - /* 450 */ "column_reference ::= column_name", - /* 451 */ "column_reference ::= table_name NK_DOT column_name", - /* 452 */ "column_reference ::= NK_ALIAS", - /* 453 */ "column_reference ::= table_name NK_DOT NK_ALIAS", - /* 454 */ "pseudo_column ::= ROWTS", - /* 455 */ "pseudo_column ::= TBNAME", - /* 456 */ "pseudo_column ::= table_name NK_DOT TBNAME", - /* 457 */ "pseudo_column ::= QSTART", - /* 458 */ "pseudo_column ::= QEND", - /* 459 */ "pseudo_column ::= QDURATION", - /* 460 */ "pseudo_column ::= WSTART", - /* 461 */ "pseudo_column ::= WEND", - /* 462 */ "pseudo_column ::= WDURATION", - /* 463 */ "pseudo_column ::= IROWTS", - /* 464 */ "pseudo_column ::= ISFILLED", - /* 465 */ "pseudo_column ::= QTAGS", - /* 466 */ "function_expression ::= function_name NK_LP expression_list NK_RP", - /* 467 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", - /* 468 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", - /* 469 */ "function_expression ::= literal_func", - /* 470 */ "literal_func ::= noarg_func NK_LP NK_RP", - /* 471 */ "literal_func ::= NOW", - /* 472 */ "noarg_func ::= NOW", - /* 473 */ "noarg_func ::= TODAY", - /* 474 */ "noarg_func ::= TIMEZONE", - /* 475 */ "noarg_func ::= DATABASE", - /* 476 */ "noarg_func ::= CLIENT_VERSION", - /* 477 */ "noarg_func ::= SERVER_VERSION", - /* 478 */ "noarg_func ::= SERVER_STATUS", - /* 479 */ "noarg_func ::= CURRENT_USER", - /* 480 */ "noarg_func ::= USER", - /* 481 */ "star_func ::= COUNT", - /* 482 */ "star_func ::= FIRST", - /* 483 */ "star_func ::= LAST", - /* 484 */ "star_func ::= LAST_ROW", - /* 485 */ "star_func_para_list ::= NK_STAR", - /* 486 */ "star_func_para_list ::= other_para_list", - /* 487 */ "other_para_list ::= star_func_para", - /* 488 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", - /* 489 */ "star_func_para ::= expr_or_subquery", - /* 490 */ "star_func_para ::= table_name NK_DOT NK_STAR", - /* 491 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", - /* 492 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", - /* 493 */ "when_then_list ::= when_then_expr", - /* 494 */ "when_then_list ::= when_then_list when_then_expr", - /* 495 */ "when_then_expr ::= WHEN common_expression THEN common_expression", - /* 496 */ "case_when_else_opt ::=", - /* 497 */ "case_when_else_opt ::= ELSE common_expression", - /* 498 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", - /* 499 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", - /* 500 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", - /* 501 */ "predicate ::= expr_or_subquery IS NULL", - /* 502 */ "predicate ::= expr_or_subquery IS NOT NULL", - /* 503 */ "predicate ::= expr_or_subquery in_op in_predicate_value", - /* 504 */ "compare_op ::= NK_LT", - /* 505 */ "compare_op ::= NK_GT", - /* 506 */ "compare_op ::= NK_LE", - /* 507 */ "compare_op ::= NK_GE", - /* 508 */ "compare_op ::= NK_NE", - /* 509 */ "compare_op ::= NK_EQ", - /* 510 */ "compare_op ::= LIKE", - /* 511 */ "compare_op ::= NOT LIKE", - /* 512 */ "compare_op ::= MATCH", - /* 513 */ "compare_op ::= NMATCH", - /* 514 */ "compare_op ::= CONTAINS", - /* 515 */ "in_op ::= IN", - /* 516 */ "in_op ::= NOT IN", - /* 517 */ "in_predicate_value ::= NK_LP literal_list NK_RP", - /* 518 */ "boolean_value_expression ::= boolean_primary", - /* 519 */ "boolean_value_expression ::= NOT boolean_primary", - /* 520 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 521 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 522 */ "boolean_primary ::= predicate", - /* 523 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 524 */ "common_expression ::= expr_or_subquery", - /* 525 */ "common_expression ::= boolean_value_expression", - /* 526 */ "from_clause_opt ::=", - /* 527 */ "from_clause_opt ::= FROM table_reference_list", - /* 528 */ "table_reference_list ::= table_reference", - /* 529 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 530 */ "table_reference ::= table_primary", - /* 531 */ "table_reference ::= joined_table", - /* 532 */ "table_primary ::= table_name alias_opt", - /* 533 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 534 */ "table_primary ::= subquery alias_opt", - /* 535 */ "table_primary ::= parenthesized_joined_table", - /* 536 */ "alias_opt ::=", - /* 537 */ "alias_opt ::= table_alias", - /* 538 */ "alias_opt ::= AS table_alias", - /* 539 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 540 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 541 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 542 */ "join_type ::=", - /* 543 */ "join_type ::= INNER", - /* 544 */ "query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt", - /* 545 */ "hint_list ::=", - /* 546 */ "hint_list ::= NK_HINT", - /* 547 */ "tag_mode_opt ::=", - /* 548 */ "tag_mode_opt ::= TAGS", - /* 549 */ "set_quantifier_opt ::=", - /* 550 */ "set_quantifier_opt ::= DISTINCT", - /* 551 */ "set_quantifier_opt ::= ALL", - /* 552 */ "select_list ::= select_item", - /* 553 */ "select_list ::= select_list NK_COMMA select_item", - /* 554 */ "select_item ::= NK_STAR", - /* 555 */ "select_item ::= common_expression", - /* 556 */ "select_item ::= common_expression column_alias", - /* 557 */ "select_item ::= common_expression AS column_alias", - /* 558 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 559 */ "where_clause_opt ::=", - /* 560 */ "where_clause_opt ::= WHERE search_condition", - /* 561 */ "partition_by_clause_opt ::=", - /* 562 */ "partition_by_clause_opt ::= PARTITION BY partition_list", - /* 563 */ "partition_list ::= partition_item", - /* 564 */ "partition_list ::= partition_list NK_COMMA partition_item", - /* 565 */ "partition_item ::= expr_or_subquery", - /* 566 */ "partition_item ::= expr_or_subquery column_alias", - /* 567 */ "partition_item ::= expr_or_subquery AS column_alias", - /* 568 */ "twindow_clause_opt ::=", - /* 569 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP", - /* 570 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", - /* 571 */ "twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt", - /* 572 */ "twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt", - /* 573 */ "twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition", - /* 574 */ "sliding_opt ::=", - /* 575 */ "sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP", - /* 576 */ "interval_sliding_duration_literal ::= NK_VARIABLE", - /* 577 */ "interval_sliding_duration_literal ::= NK_STRING", - /* 578 */ "interval_sliding_duration_literal ::= NK_INTEGER", - /* 579 */ "fill_opt ::=", - /* 580 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 581 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP", - /* 582 */ "fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP", - /* 583 */ "fill_mode ::= NONE", - /* 584 */ "fill_mode ::= PREV", - /* 585 */ "fill_mode ::= NULL", - /* 586 */ "fill_mode ::= NULL_F", - /* 587 */ "fill_mode ::= LINEAR", - /* 588 */ "fill_mode ::= NEXT", - /* 589 */ "group_by_clause_opt ::=", - /* 590 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 591 */ "group_by_list ::= expr_or_subquery", - /* 592 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", - /* 593 */ "having_clause_opt ::=", - /* 594 */ "having_clause_opt ::= HAVING search_condition", - /* 595 */ "range_opt ::=", - /* 596 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", - /* 597 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_RP", - /* 598 */ "every_opt ::=", - /* 599 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", - /* 600 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 601 */ "query_simple ::= query_specification", - /* 602 */ "query_simple ::= union_query_expression", - /* 603 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", - /* 604 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", - /* 605 */ "query_simple_or_subquery ::= query_simple", - /* 606 */ "query_simple_or_subquery ::= subquery", - /* 607 */ "query_or_subquery ::= query_expression", - /* 608 */ "query_or_subquery ::= subquery", - /* 609 */ "order_by_clause_opt ::=", - /* 610 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 611 */ "slimit_clause_opt ::=", - /* 612 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 613 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 614 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 615 */ "limit_clause_opt ::=", - /* 616 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 617 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 618 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 619 */ "subquery ::= NK_LP query_expression NK_RP", - /* 620 */ "subquery ::= NK_LP subquery NK_RP", - /* 621 */ "search_condition ::= common_expression", - /* 622 */ "sort_specification_list ::= sort_specification", - /* 623 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 624 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", - /* 625 */ "ordering_specification_opt ::=", - /* 626 */ "ordering_specification_opt ::= ASC", - /* 627 */ "ordering_specification_opt ::= DESC", - /* 628 */ "null_ordering_opt ::=", - /* 629 */ "null_ordering_opt ::= NULLS FIRST", - /* 630 */ "null_ordering_opt ::= NULLS LAST", + /* 47 */ "priv_type ::= ALTER", + /* 48 */ "priv_level ::= NK_STAR NK_DOT NK_STAR", + /* 49 */ "priv_level ::= db_name NK_DOT NK_STAR", + /* 50 */ "priv_level ::= db_name NK_DOT table_name", + /* 51 */ "priv_level ::= topic_name", + /* 52 */ "with_opt ::=", + /* 53 */ "with_opt ::= WITH search_condition", + /* 54 */ "cmd ::= CREATE DNODE dnode_endpoint", + /* 55 */ "cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER", + /* 56 */ "cmd ::= DROP DNODE NK_INTEGER force_opt", + /* 57 */ "cmd ::= DROP DNODE dnode_endpoint force_opt", + /* 58 */ "cmd ::= DROP DNODE NK_INTEGER unsafe_opt", + /* 59 */ "cmd ::= DROP DNODE dnode_endpoint unsafe_opt", + /* 60 */ "cmd ::= ALTER DNODE NK_INTEGER NK_STRING", + /* 61 */ "cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING", + /* 62 */ "cmd ::= ALTER ALL DNODES NK_STRING", + /* 63 */ "cmd ::= ALTER ALL DNODES NK_STRING NK_STRING", + /* 64 */ "cmd ::= RESTORE DNODE NK_INTEGER", + /* 65 */ "dnode_endpoint ::= NK_STRING", + /* 66 */ "dnode_endpoint ::= NK_ID", + /* 67 */ "dnode_endpoint ::= NK_IPTOKEN", + /* 68 */ "force_opt ::=", + /* 69 */ "force_opt ::= FORCE", + /* 70 */ "unsafe_opt ::= UNSAFE", + /* 71 */ "cmd ::= ALTER LOCAL NK_STRING", + /* 72 */ "cmd ::= ALTER LOCAL NK_STRING NK_STRING", + /* 73 */ "cmd ::= CREATE QNODE ON DNODE NK_INTEGER", + /* 74 */ "cmd ::= DROP QNODE ON DNODE NK_INTEGER", + /* 75 */ "cmd ::= RESTORE QNODE ON DNODE NK_INTEGER", + /* 76 */ "cmd ::= CREATE BNODE ON DNODE NK_INTEGER", + /* 77 */ "cmd ::= DROP BNODE ON DNODE NK_INTEGER", + /* 78 */ "cmd ::= CREATE SNODE ON DNODE NK_INTEGER", + /* 79 */ "cmd ::= DROP SNODE ON DNODE NK_INTEGER", + /* 80 */ "cmd ::= CREATE MNODE ON DNODE NK_INTEGER", + /* 81 */ "cmd ::= DROP MNODE ON DNODE NK_INTEGER", + /* 82 */ "cmd ::= RESTORE MNODE ON DNODE NK_INTEGER", + /* 83 */ "cmd ::= RESTORE VNODE ON DNODE NK_INTEGER", + /* 84 */ "cmd ::= CREATE DATABASE not_exists_opt db_name db_options", + /* 85 */ "cmd ::= DROP DATABASE exists_opt db_name", + /* 86 */ "cmd ::= USE db_name", + /* 87 */ "cmd ::= ALTER DATABASE db_name alter_db_options", + /* 88 */ "cmd ::= FLUSH DATABASE db_name", + /* 89 */ "cmd ::= TRIM DATABASE db_name speed_opt", + /* 90 */ "cmd ::= COMPACT DATABASE db_name start_opt end_opt", + /* 91 */ "not_exists_opt ::= IF NOT EXISTS", + /* 92 */ "not_exists_opt ::=", + /* 93 */ "exists_opt ::= IF EXISTS", + /* 94 */ "exists_opt ::=", + /* 95 */ "db_options ::=", + /* 96 */ "db_options ::= db_options BUFFER NK_INTEGER", + /* 97 */ "db_options ::= db_options CACHEMODEL NK_STRING", + /* 98 */ "db_options ::= db_options CACHESIZE NK_INTEGER", + /* 99 */ "db_options ::= db_options COMP NK_INTEGER", + /* 100 */ "db_options ::= db_options DURATION NK_INTEGER", + /* 101 */ "db_options ::= db_options DURATION NK_VARIABLE", + /* 102 */ "db_options ::= db_options MAXROWS NK_INTEGER", + /* 103 */ "db_options ::= db_options MINROWS NK_INTEGER", + /* 104 */ "db_options ::= db_options KEEP integer_list", + /* 105 */ "db_options ::= db_options KEEP variable_list", + /* 106 */ "db_options ::= db_options PAGES NK_INTEGER", + /* 107 */ "db_options ::= db_options PAGESIZE NK_INTEGER", + /* 108 */ "db_options ::= db_options TSDB_PAGESIZE NK_INTEGER", + /* 109 */ "db_options ::= db_options PRECISION NK_STRING", + /* 110 */ "db_options ::= db_options REPLICA NK_INTEGER", + /* 111 */ "db_options ::= db_options VGROUPS NK_INTEGER", + /* 112 */ "db_options ::= db_options SINGLE_STABLE NK_INTEGER", + /* 113 */ "db_options ::= db_options RETENTIONS retention_list", + /* 114 */ "db_options ::= db_options SCHEMALESS NK_INTEGER", + /* 115 */ "db_options ::= db_options WAL_LEVEL NK_INTEGER", + /* 116 */ "db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER", + /* 117 */ "db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER", + /* 118 */ "db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER", + /* 119 */ "db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER", + /* 120 */ "db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER", + /* 121 */ "db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER", + /* 122 */ "db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER", + /* 123 */ "db_options ::= db_options STT_TRIGGER NK_INTEGER", + /* 124 */ "db_options ::= db_options TABLE_PREFIX signed", + /* 125 */ "db_options ::= db_options TABLE_SUFFIX signed", + /* 126 */ "db_options ::= db_options KEEP_TIME_OFFSET NK_INTEGER", + /* 127 */ "alter_db_options ::= alter_db_option", + /* 128 */ "alter_db_options ::= alter_db_options alter_db_option", + /* 129 */ "alter_db_option ::= BUFFER NK_INTEGER", + /* 130 */ "alter_db_option ::= CACHEMODEL NK_STRING", + /* 131 */ "alter_db_option ::= CACHESIZE NK_INTEGER", + /* 132 */ "alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER", + /* 133 */ "alter_db_option ::= KEEP integer_list", + /* 134 */ "alter_db_option ::= KEEP variable_list", + /* 135 */ "alter_db_option ::= PAGES NK_INTEGER", + /* 136 */ "alter_db_option ::= REPLICA NK_INTEGER", + /* 137 */ "alter_db_option ::= WAL_LEVEL NK_INTEGER", + /* 138 */ "alter_db_option ::= STT_TRIGGER NK_INTEGER", + /* 139 */ "alter_db_option ::= MINROWS NK_INTEGER", + /* 140 */ "alter_db_option ::= WAL_RETENTION_PERIOD NK_INTEGER", + /* 141 */ "alter_db_option ::= WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER", + /* 142 */ "alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER", + /* 143 */ "alter_db_option ::= WAL_RETENTION_SIZE NK_MINUS NK_INTEGER", + /* 144 */ "alter_db_option ::= KEEP_TIME_OFFSET NK_INTEGER", + /* 145 */ "integer_list ::= NK_INTEGER", + /* 146 */ "integer_list ::= integer_list NK_COMMA NK_INTEGER", + /* 147 */ "variable_list ::= NK_VARIABLE", + /* 148 */ "variable_list ::= variable_list NK_COMMA NK_VARIABLE", + /* 149 */ "retention_list ::= retention", + /* 150 */ "retention_list ::= retention_list NK_COMMA retention", + /* 151 */ "retention ::= NK_VARIABLE NK_COLON NK_VARIABLE", + /* 152 */ "retention ::= NK_MINUS NK_COLON NK_VARIABLE", + /* 153 */ "speed_opt ::=", + /* 154 */ "speed_opt ::= BWLIMIT NK_INTEGER", + /* 155 */ "start_opt ::=", + /* 156 */ "start_opt ::= START WITH NK_INTEGER", + /* 157 */ "start_opt ::= START WITH NK_STRING", + /* 158 */ "start_opt ::= START WITH TIMESTAMP NK_STRING", + /* 159 */ "end_opt ::=", + /* 160 */ "end_opt ::= END WITH NK_INTEGER", + /* 161 */ "end_opt ::= END WITH NK_STRING", + /* 162 */ "end_opt ::= END WITH TIMESTAMP NK_STRING", + /* 163 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", + /* 164 */ "cmd ::= CREATE TABLE multi_create_clause", + /* 165 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", + /* 166 */ "cmd ::= DROP TABLE multi_drop_clause", + /* 167 */ "cmd ::= DROP STABLE exists_opt full_table_name", + /* 168 */ "cmd ::= ALTER TABLE alter_table_clause", + /* 169 */ "cmd ::= ALTER STABLE alter_table_clause", + /* 170 */ "alter_table_clause ::= full_table_name alter_table_options", + /* 171 */ "alter_table_clause ::= full_table_name ADD COLUMN column_name type_name", + /* 172 */ "alter_table_clause ::= full_table_name DROP COLUMN column_name", + /* 173 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name", + /* 174 */ "alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name", + /* 175 */ "alter_table_clause ::= full_table_name ADD TAG column_name type_name", + /* 176 */ "alter_table_clause ::= full_table_name DROP TAG column_name", + /* 177 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name", + /* 178 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name", + /* 179 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal", + /* 180 */ "multi_create_clause ::= create_subtable_clause", + /* 181 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", + /* 182 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options", + /* 183 */ "multi_drop_clause ::= drop_table_clause", + /* 184 */ "multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause", + /* 185 */ "drop_table_clause ::= exists_opt full_table_name", + /* 186 */ "specific_cols_opt ::=", + /* 187 */ "specific_cols_opt ::= NK_LP col_name_list NK_RP", + /* 188 */ "full_table_name ::= table_name", + /* 189 */ "full_table_name ::= db_name NK_DOT table_name", + /* 190 */ "column_def_list ::= column_def", + /* 191 */ "column_def_list ::= column_def_list NK_COMMA column_def", + /* 192 */ "column_def ::= column_name type_name", + /* 193 */ "type_name ::= BOOL", + /* 194 */ "type_name ::= TINYINT", + /* 195 */ "type_name ::= SMALLINT", + /* 196 */ "type_name ::= INT", + /* 197 */ "type_name ::= INTEGER", + /* 198 */ "type_name ::= BIGINT", + /* 199 */ "type_name ::= FLOAT", + /* 200 */ "type_name ::= DOUBLE", + /* 201 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", + /* 202 */ "type_name ::= TIMESTAMP", + /* 203 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", + /* 204 */ "type_name ::= TINYINT UNSIGNED", + /* 205 */ "type_name ::= SMALLINT UNSIGNED", + /* 206 */ "type_name ::= INT UNSIGNED", + /* 207 */ "type_name ::= BIGINT UNSIGNED", + /* 208 */ "type_name ::= JSON", + /* 209 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", + /* 210 */ "type_name ::= MEDIUMBLOB", + /* 211 */ "type_name ::= BLOB", + /* 212 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", + /* 213 */ "type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP", + /* 214 */ "type_name ::= DECIMAL", + /* 215 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", + /* 216 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", + /* 217 */ "tags_def_opt ::=", + /* 218 */ "tags_def_opt ::= tags_def", + /* 219 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", + /* 220 */ "table_options ::=", + /* 221 */ "table_options ::= table_options COMMENT NK_STRING", + /* 222 */ "table_options ::= table_options MAX_DELAY duration_list", + /* 223 */ "table_options ::= table_options WATERMARK duration_list", + /* 224 */ "table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP", + /* 225 */ "table_options ::= table_options TTL NK_INTEGER", + /* 226 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", + /* 227 */ "table_options ::= table_options DELETE_MARK duration_list", + /* 228 */ "alter_table_options ::= alter_table_option", + /* 229 */ "alter_table_options ::= alter_table_options alter_table_option", + /* 230 */ "alter_table_option ::= COMMENT NK_STRING", + /* 231 */ "alter_table_option ::= TTL NK_INTEGER", + /* 232 */ "duration_list ::= duration_literal", + /* 233 */ "duration_list ::= duration_list NK_COMMA duration_literal", + /* 234 */ "rollup_func_list ::= rollup_func_name", + /* 235 */ "rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name", + /* 236 */ "rollup_func_name ::= function_name", + /* 237 */ "rollup_func_name ::= FIRST", + /* 238 */ "rollup_func_name ::= LAST", + /* 239 */ "col_name_list ::= col_name", + /* 240 */ "col_name_list ::= col_name_list NK_COMMA col_name", + /* 241 */ "col_name ::= column_name", + /* 242 */ "cmd ::= SHOW DNODES", + /* 243 */ "cmd ::= SHOW USERS", + /* 244 */ "cmd ::= SHOW USER PRIVILEGES", + /* 245 */ "cmd ::= SHOW db_kind_opt DATABASES", + /* 246 */ "cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt", + /* 247 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt", + /* 248 */ "cmd ::= SHOW db_name_cond_opt VGROUPS", + /* 249 */ "cmd ::= SHOW MNODES", + /* 250 */ "cmd ::= SHOW QNODES", + /* 251 */ "cmd ::= SHOW FUNCTIONS", + /* 252 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", + /* 253 */ "cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name", + /* 254 */ "cmd ::= SHOW STREAMS", + /* 255 */ "cmd ::= SHOW ACCOUNTS", + /* 256 */ "cmd ::= SHOW APPS", + /* 257 */ "cmd ::= SHOW CONNECTIONS", + /* 258 */ "cmd ::= SHOW LICENCES", + /* 259 */ "cmd ::= SHOW GRANTS", + /* 260 */ "cmd ::= SHOW CREATE DATABASE db_name", + /* 261 */ "cmd ::= SHOW CREATE TABLE full_table_name", + /* 262 */ "cmd ::= SHOW CREATE STABLE full_table_name", + /* 263 */ "cmd ::= SHOW QUERIES", + /* 264 */ "cmd ::= SHOW SCORES", + /* 265 */ "cmd ::= SHOW TOPICS", + /* 266 */ "cmd ::= SHOW VARIABLES", + /* 267 */ "cmd ::= SHOW CLUSTER VARIABLES", + /* 268 */ "cmd ::= SHOW LOCAL VARIABLES", + /* 269 */ "cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt", + /* 270 */ "cmd ::= SHOW BNODES", + /* 271 */ "cmd ::= SHOW SNODES", + /* 272 */ "cmd ::= SHOW CLUSTER", + /* 273 */ "cmd ::= SHOW TRANSACTIONS", + /* 274 */ "cmd ::= SHOW TABLE DISTRIBUTED full_table_name", + /* 275 */ "cmd ::= SHOW CONSUMERS", + /* 276 */ "cmd ::= SHOW SUBSCRIPTIONS", + /* 277 */ "cmd ::= SHOW TAGS FROM table_name_cond from_db_opt", + /* 278 */ "cmd ::= SHOW TAGS FROM db_name NK_DOT table_name", + /* 279 */ "cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt", + /* 280 */ "cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name", + /* 281 */ "cmd ::= SHOW VNODES ON DNODE NK_INTEGER", + /* 282 */ "cmd ::= SHOW VNODES", + /* 283 */ "cmd ::= SHOW db_name_cond_opt ALIVE", + /* 284 */ "cmd ::= SHOW CLUSTER ALIVE", + /* 285 */ "cmd ::= SHOW db_name_cond_opt VIEWS", + /* 286 */ "cmd ::= SHOW CREATE VIEW full_table_name", + /* 287 */ "table_kind_db_name_cond_opt ::=", + /* 288 */ "table_kind_db_name_cond_opt ::= table_kind", + /* 289 */ "table_kind_db_name_cond_opt ::= db_name NK_DOT", + /* 290 */ "table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT", + /* 291 */ "table_kind ::= NORMAL", + /* 292 */ "table_kind ::= CHILD", + /* 293 */ "db_name_cond_opt ::=", + /* 294 */ "db_name_cond_opt ::= db_name NK_DOT", + /* 295 */ "like_pattern_opt ::=", + /* 296 */ "like_pattern_opt ::= LIKE NK_STRING", + /* 297 */ "table_name_cond ::= table_name", + /* 298 */ "from_db_opt ::=", + /* 299 */ "from_db_opt ::= FROM db_name", + /* 300 */ "tag_list_opt ::=", + /* 301 */ "tag_list_opt ::= tag_item", + /* 302 */ "tag_list_opt ::= tag_list_opt NK_COMMA tag_item", + /* 303 */ "tag_item ::= TBNAME", + /* 304 */ "tag_item ::= QTAGS", + /* 305 */ "tag_item ::= column_name", + /* 306 */ "tag_item ::= column_name column_alias", + /* 307 */ "tag_item ::= column_name AS column_alias", + /* 308 */ "db_kind_opt ::=", + /* 309 */ "db_kind_opt ::= USER", + /* 310 */ "db_kind_opt ::= SYSTEM", + /* 311 */ "cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options", + /* 312 */ "cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP", + /* 313 */ "cmd ::= DROP INDEX exists_opt full_index_name", + /* 314 */ "full_index_name ::= index_name", + /* 315 */ "full_index_name ::= db_name NK_DOT index_name", + /* 316 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", + /* 317 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt", + /* 318 */ "func_list ::= func", + /* 319 */ "func_list ::= func_list NK_COMMA func", + /* 320 */ "func ::= sma_func_name NK_LP expression_list NK_RP", + /* 321 */ "sma_func_name ::= function_name", + /* 322 */ "sma_func_name ::= COUNT", + /* 323 */ "sma_func_name ::= FIRST", + /* 324 */ "sma_func_name ::= LAST", + /* 325 */ "sma_func_name ::= LAST_ROW", + /* 326 */ "sma_stream_opt ::=", + /* 327 */ "sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal", + /* 328 */ "sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal", + /* 329 */ "sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal", + /* 330 */ "with_meta ::= AS", + /* 331 */ "with_meta ::= WITH META AS", + /* 332 */ "with_meta ::= ONLY META AS", + /* 333 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery", + /* 334 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name", + /* 335 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt", + /* 336 */ "cmd ::= DROP TOPIC exists_opt topic_name", + /* 337 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", + /* 338 */ "cmd ::= DESC full_table_name", + /* 339 */ "cmd ::= DESCRIBE full_table_name", + /* 340 */ "cmd ::= RESET QUERY CACHE", + /* 341 */ "cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery", + /* 342 */ "cmd ::= EXPLAIN analyze_opt explain_options insert_query", + /* 343 */ "analyze_opt ::=", + /* 344 */ "analyze_opt ::= ANALYZE", + /* 345 */ "explain_options ::=", + /* 346 */ "explain_options ::= explain_options VERBOSE NK_BOOL", + /* 347 */ "explain_options ::= explain_options RATIO NK_FLOAT", + /* 348 */ "cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt", + /* 349 */ "cmd ::= DROP FUNCTION exists_opt function_name", + /* 350 */ "agg_func_opt ::=", + /* 351 */ "agg_func_opt ::= AGGREGATE", + /* 352 */ "bufsize_opt ::=", + /* 353 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", + /* 354 */ "language_opt ::=", + /* 355 */ "language_opt ::= LANGUAGE NK_STRING", + /* 356 */ "or_replace_opt ::=", + /* 357 */ "or_replace_opt ::= OR REPLACE", + /* 358 */ "cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery", + /* 359 */ "cmd ::= DROP VIEW exists_opt full_view_name", + /* 360 */ "full_view_name ::= view_name", + /* 361 */ "full_view_name ::= db_name NK_DOT view_name", + /* 362 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery", + /* 363 */ "cmd ::= DROP STREAM exists_opt stream_name", + /* 364 */ "cmd ::= PAUSE STREAM exists_opt stream_name", + /* 365 */ "cmd ::= RESUME STREAM exists_opt ignore_opt stream_name", + /* 366 */ "col_list_opt ::=", + /* 367 */ "col_list_opt ::= NK_LP col_name_list NK_RP", + /* 368 */ "tag_def_or_ref_opt ::=", + /* 369 */ "tag_def_or_ref_opt ::= tags_def", + /* 370 */ "tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP", + /* 371 */ "stream_options ::=", + /* 372 */ "stream_options ::= stream_options TRIGGER AT_ONCE", + /* 373 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", + /* 374 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", + /* 375 */ "stream_options ::= stream_options WATERMARK duration_literal", + /* 376 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER", + /* 377 */ "stream_options ::= stream_options FILL_HISTORY NK_INTEGER", + /* 378 */ "stream_options ::= stream_options DELETE_MARK duration_literal", + /* 379 */ "stream_options ::= stream_options IGNORE UPDATE NK_INTEGER", + /* 380 */ "subtable_opt ::=", + /* 381 */ "subtable_opt ::= SUBTABLE NK_LP expression NK_RP", + /* 382 */ "ignore_opt ::=", + /* 383 */ "ignore_opt ::= IGNORE UNTREATED", + /* 384 */ "cmd ::= KILL CONNECTION NK_INTEGER", + /* 385 */ "cmd ::= KILL QUERY NK_STRING", + /* 386 */ "cmd ::= KILL TRANSACTION NK_INTEGER", + /* 387 */ "cmd ::= BALANCE VGROUP", + /* 388 */ "cmd ::= BALANCE VGROUP LEADER on_vgroup_id", + /* 389 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", + /* 390 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", + /* 391 */ "cmd ::= SPLIT VGROUP NK_INTEGER", + /* 392 */ "on_vgroup_id ::=", + /* 393 */ "on_vgroup_id ::= ON NK_INTEGER", + /* 394 */ "dnode_list ::= DNODE NK_INTEGER", + /* 395 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", + /* 396 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", + /* 397 */ "cmd ::= query_or_subquery", + /* 398 */ "cmd ::= insert_query", + /* 399 */ "insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", + /* 400 */ "insert_query ::= INSERT INTO full_table_name query_or_subquery", + /* 401 */ "literal ::= NK_INTEGER", + /* 402 */ "literal ::= NK_FLOAT", + /* 403 */ "literal ::= NK_STRING", + /* 404 */ "literal ::= NK_BOOL", + /* 405 */ "literal ::= TIMESTAMP NK_STRING", + /* 406 */ "literal ::= duration_literal", + /* 407 */ "literal ::= NULL", + /* 408 */ "literal ::= NK_QUESTION", + /* 409 */ "duration_literal ::= NK_VARIABLE", + /* 410 */ "signed ::= NK_INTEGER", + /* 411 */ "signed ::= NK_PLUS NK_INTEGER", + /* 412 */ "signed ::= NK_MINUS NK_INTEGER", + /* 413 */ "signed ::= NK_FLOAT", + /* 414 */ "signed ::= NK_PLUS NK_FLOAT", + /* 415 */ "signed ::= NK_MINUS NK_FLOAT", + /* 416 */ "signed_literal ::= signed", + /* 417 */ "signed_literal ::= NK_STRING", + /* 418 */ "signed_literal ::= NK_BOOL", + /* 419 */ "signed_literal ::= TIMESTAMP NK_STRING", + /* 420 */ "signed_literal ::= duration_literal", + /* 421 */ "signed_literal ::= NULL", + /* 422 */ "signed_literal ::= literal_func", + /* 423 */ "signed_literal ::= NK_QUESTION", + /* 424 */ "literal_list ::= signed_literal", + /* 425 */ "literal_list ::= literal_list NK_COMMA signed_literal", + /* 426 */ "db_name ::= NK_ID", + /* 427 */ "table_name ::= NK_ID", + /* 428 */ "column_name ::= NK_ID", + /* 429 */ "function_name ::= NK_ID", + /* 430 */ "view_name ::= NK_ID", + /* 431 */ "table_alias ::= NK_ID", + /* 432 */ "column_alias ::= NK_ID", + /* 433 */ "column_alias ::= NK_ALIAS", + /* 434 */ "user_name ::= NK_ID", + /* 435 */ "topic_name ::= NK_ID", + /* 436 */ "stream_name ::= NK_ID", + /* 437 */ "cgroup_name ::= NK_ID", + /* 438 */ "index_name ::= NK_ID", + /* 439 */ "expr_or_subquery ::= expression", + /* 440 */ "expression ::= literal", + /* 441 */ "expression ::= pseudo_column", + /* 442 */ "expression ::= column_reference", + /* 443 */ "expression ::= function_expression", + /* 444 */ "expression ::= case_when_expression", + /* 445 */ "expression ::= NK_LP expression NK_RP", + /* 446 */ "expression ::= NK_PLUS expr_or_subquery", + /* 447 */ "expression ::= NK_MINUS expr_or_subquery", + /* 448 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", + /* 449 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", + /* 450 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", + /* 451 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", + /* 452 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", + /* 453 */ "expression ::= column_reference NK_ARROW NK_STRING", + /* 454 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", + /* 455 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", + /* 456 */ "expression_list ::= expr_or_subquery", + /* 457 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", + /* 458 */ "column_reference ::= column_name", + /* 459 */ "column_reference ::= table_name NK_DOT column_name", + /* 460 */ "column_reference ::= NK_ALIAS", + /* 461 */ "column_reference ::= table_name NK_DOT NK_ALIAS", + /* 462 */ "pseudo_column ::= ROWTS", + /* 463 */ "pseudo_column ::= TBNAME", + /* 464 */ "pseudo_column ::= table_name NK_DOT TBNAME", + /* 465 */ "pseudo_column ::= QSTART", + /* 466 */ "pseudo_column ::= QEND", + /* 467 */ "pseudo_column ::= QDURATION", + /* 468 */ "pseudo_column ::= WSTART", + /* 469 */ "pseudo_column ::= WEND", + /* 470 */ "pseudo_column ::= WDURATION", + /* 471 */ "pseudo_column ::= IROWTS", + /* 472 */ "pseudo_column ::= ISFILLED", + /* 473 */ "pseudo_column ::= QTAGS", + /* 474 */ "function_expression ::= function_name NK_LP expression_list NK_RP", + /* 475 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", + /* 476 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", + /* 477 */ "function_expression ::= literal_func", + /* 478 */ "literal_func ::= noarg_func NK_LP NK_RP", + /* 479 */ "literal_func ::= NOW", + /* 480 */ "noarg_func ::= NOW", + /* 481 */ "noarg_func ::= TODAY", + /* 482 */ "noarg_func ::= TIMEZONE", + /* 483 */ "noarg_func ::= DATABASE", + /* 484 */ "noarg_func ::= CLIENT_VERSION", + /* 485 */ "noarg_func ::= SERVER_VERSION", + /* 486 */ "noarg_func ::= SERVER_STATUS", + /* 487 */ "noarg_func ::= CURRENT_USER", + /* 488 */ "noarg_func ::= USER", + /* 489 */ "star_func ::= COUNT", + /* 490 */ "star_func ::= FIRST", + /* 491 */ "star_func ::= LAST", + /* 492 */ "star_func ::= LAST_ROW", + /* 493 */ "star_func_para_list ::= NK_STAR", + /* 494 */ "star_func_para_list ::= other_para_list", + /* 495 */ "other_para_list ::= star_func_para", + /* 496 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", + /* 497 */ "star_func_para ::= expr_or_subquery", + /* 498 */ "star_func_para ::= table_name NK_DOT NK_STAR", + /* 499 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", + /* 500 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", + /* 501 */ "when_then_list ::= when_then_expr", + /* 502 */ "when_then_list ::= when_then_list when_then_expr", + /* 503 */ "when_then_expr ::= WHEN common_expression THEN common_expression", + /* 504 */ "case_when_else_opt ::=", + /* 505 */ "case_when_else_opt ::= ELSE common_expression", + /* 506 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", + /* 507 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", + /* 508 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", + /* 509 */ "predicate ::= expr_or_subquery IS NULL", + /* 510 */ "predicate ::= expr_or_subquery IS NOT NULL", + /* 511 */ "predicate ::= expr_or_subquery in_op in_predicate_value", + /* 512 */ "compare_op ::= NK_LT", + /* 513 */ "compare_op ::= NK_GT", + /* 514 */ "compare_op ::= NK_LE", + /* 515 */ "compare_op ::= NK_GE", + /* 516 */ "compare_op ::= NK_NE", + /* 517 */ "compare_op ::= NK_EQ", + /* 518 */ "compare_op ::= LIKE", + /* 519 */ "compare_op ::= NOT LIKE", + /* 520 */ "compare_op ::= MATCH", + /* 521 */ "compare_op ::= NMATCH", + /* 522 */ "compare_op ::= CONTAINS", + /* 523 */ "in_op ::= IN", + /* 524 */ "in_op ::= NOT IN", + /* 525 */ "in_predicate_value ::= NK_LP literal_list NK_RP", + /* 526 */ "boolean_value_expression ::= boolean_primary", + /* 527 */ "boolean_value_expression ::= NOT boolean_primary", + /* 528 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 529 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 530 */ "boolean_primary ::= predicate", + /* 531 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 532 */ "common_expression ::= expr_or_subquery", + /* 533 */ "common_expression ::= boolean_value_expression", + /* 534 */ "from_clause_opt ::=", + /* 535 */ "from_clause_opt ::= FROM table_reference_list", + /* 536 */ "table_reference_list ::= table_reference", + /* 537 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 538 */ "table_reference ::= table_primary", + /* 539 */ "table_reference ::= joined_table", + /* 540 */ "table_primary ::= table_name alias_opt", + /* 541 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 542 */ "table_primary ::= subquery alias_opt", + /* 543 */ "table_primary ::= parenthesized_joined_table", + /* 544 */ "alias_opt ::=", + /* 545 */ "alias_opt ::= table_alias", + /* 546 */ "alias_opt ::= AS table_alias", + /* 547 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 548 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 549 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 550 */ "join_type ::=", + /* 551 */ "join_type ::= INNER", + /* 552 */ "query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt", + /* 553 */ "hint_list ::=", + /* 554 */ "hint_list ::= NK_HINT", + /* 555 */ "tag_mode_opt ::=", + /* 556 */ "tag_mode_opt ::= TAGS", + /* 557 */ "set_quantifier_opt ::=", + /* 558 */ "set_quantifier_opt ::= DISTINCT", + /* 559 */ "set_quantifier_opt ::= ALL", + /* 560 */ "select_list ::= select_item", + /* 561 */ "select_list ::= select_list NK_COMMA select_item", + /* 562 */ "select_item ::= NK_STAR", + /* 563 */ "select_item ::= common_expression", + /* 564 */ "select_item ::= common_expression column_alias", + /* 565 */ "select_item ::= common_expression AS column_alias", + /* 566 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 567 */ "where_clause_opt ::=", + /* 568 */ "where_clause_opt ::= WHERE search_condition", + /* 569 */ "partition_by_clause_opt ::=", + /* 570 */ "partition_by_clause_opt ::= PARTITION BY partition_list", + /* 571 */ "partition_list ::= partition_item", + /* 572 */ "partition_list ::= partition_list NK_COMMA partition_item", + /* 573 */ "partition_item ::= expr_or_subquery", + /* 574 */ "partition_item ::= expr_or_subquery column_alias", + /* 575 */ "partition_item ::= expr_or_subquery AS column_alias", + /* 576 */ "twindow_clause_opt ::=", + /* 577 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP", + /* 578 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", + /* 579 */ "twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt", + /* 580 */ "twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt", + /* 581 */ "twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition", + /* 582 */ "sliding_opt ::=", + /* 583 */ "sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP", + /* 584 */ "interval_sliding_duration_literal ::= NK_VARIABLE", + /* 585 */ "interval_sliding_duration_literal ::= NK_STRING", + /* 586 */ "interval_sliding_duration_literal ::= NK_INTEGER", + /* 587 */ "fill_opt ::=", + /* 588 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 589 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP", + /* 590 */ "fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP", + /* 591 */ "fill_mode ::= NONE", + /* 592 */ "fill_mode ::= PREV", + /* 593 */ "fill_mode ::= NULL", + /* 594 */ "fill_mode ::= NULL_F", + /* 595 */ "fill_mode ::= LINEAR", + /* 596 */ "fill_mode ::= NEXT", + /* 597 */ "group_by_clause_opt ::=", + /* 598 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 599 */ "group_by_list ::= expr_or_subquery", + /* 600 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", + /* 601 */ "having_clause_opt ::=", + /* 602 */ "having_clause_opt ::= HAVING search_condition", + /* 603 */ "range_opt ::=", + /* 604 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", + /* 605 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_RP", + /* 606 */ "every_opt ::=", + /* 607 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", + /* 608 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 609 */ "query_simple ::= query_specification", + /* 610 */ "query_simple ::= union_query_expression", + /* 611 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", + /* 612 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", + /* 613 */ "query_simple_or_subquery ::= query_simple", + /* 614 */ "query_simple_or_subquery ::= subquery", + /* 615 */ "query_or_subquery ::= query_expression", + /* 616 */ "query_or_subquery ::= subquery", + /* 617 */ "order_by_clause_opt ::=", + /* 618 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 619 */ "slimit_clause_opt ::=", + /* 620 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 621 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 622 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 623 */ "limit_clause_opt ::=", + /* 624 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 625 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 626 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 627 */ "subquery ::= NK_LP query_expression NK_RP", + /* 628 */ "subquery ::= NK_LP subquery NK_RP", + /* 629 */ "search_condition ::= common_expression", + /* 630 */ "sort_specification_list ::= sort_specification", + /* 631 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 632 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", + /* 633 */ "ordering_specification_opt ::=", + /* 634 */ "ordering_specification_opt ::= ASC", + /* 635 */ "ordering_specification_opt ::= DESC", + /* 636 */ "null_ordering_opt ::=", + /* 637 */ "null_ordering_opt ::= NULLS FIRST", + /* 638 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -2920,229 +2840,231 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 345: /* cmd */ - case 348: /* literal */ - case 357: /* with_opt */ - case 363: /* search_condition */ - case 368: /* db_options */ - case 370: /* alter_db_options */ - case 372: /* start_opt */ - case 373: /* end_opt */ - case 377: /* signed */ - case 379: /* retention */ - case 380: /* full_table_name */ - case 383: /* table_options */ - case 387: /* alter_table_clause */ - case 388: /* alter_table_options */ - case 391: /* signed_literal */ - case 392: /* create_subtable_clause */ - case 395: /* drop_table_clause */ - case 397: /* column_def */ - case 401: /* duration_literal */ - case 402: /* rollup_func_name */ - case 404: /* col_name */ - case 407: /* like_pattern_opt */ - case 408: /* db_name_cond_opt */ - case 409: /* table_name_cond */ - case 410: /* from_db_opt */ - case 413: /* tag_item */ - case 415: /* index_options */ - case 416: /* full_index_name */ - case 419: /* sliding_opt */ - case 420: /* sma_stream_opt */ - case 421: /* func */ - case 424: /* query_or_subquery */ - case 425: /* where_clause_opt */ - case 428: /* explain_options */ - case 429: /* insert_query */ - case 435: /* stream_options */ - case 438: /* subtable_opt */ - case 440: /* expression */ - case 443: /* literal_func */ - case 446: /* expr_or_subquery */ - case 447: /* pseudo_column */ - case 448: /* column_reference */ - case 449: /* function_expression */ - case 450: /* case_when_expression */ - case 455: /* star_func_para */ - case 457: /* case_when_else_opt */ - case 458: /* common_expression */ - case 459: /* when_then_expr */ - case 460: /* predicate */ - case 463: /* in_predicate_value */ - case 464: /* boolean_value_expression */ - case 465: /* boolean_primary */ - case 466: /* from_clause_opt */ - case 467: /* table_reference_list */ - case 468: /* table_reference */ - case 469: /* table_primary */ - case 470: /* joined_table */ - case 472: /* subquery */ - case 473: /* parenthesized_joined_table */ - case 475: /* query_specification */ - case 481: /* range_opt */ - case 482: /* every_opt */ - case 483: /* fill_opt */ - case 484: /* twindow_clause_opt */ - case 486: /* having_clause_opt */ - case 487: /* select_item */ - case 489: /* partition_item */ - case 490: /* interval_sliding_duration_literal */ - case 493: /* query_expression */ - case 494: /* query_simple */ - case 496: /* slimit_clause_opt */ - case 497: /* limit_clause_opt */ - case 498: /* union_query_expression */ - case 499: /* query_simple_or_subquery */ - case 501: /* sort_specification */ + case 346: /* cmd */ + case 349: /* literal */ + case 358: /* with_opt */ + case 364: /* search_condition */ + case 369: /* db_options */ + case 371: /* alter_db_options */ + case 373: /* start_opt */ + case 374: /* end_opt */ + case 378: /* signed */ + case 380: /* retention */ + case 381: /* full_table_name */ + case 384: /* table_options */ + case 388: /* alter_table_clause */ + case 389: /* alter_table_options */ + case 392: /* signed_literal */ + case 393: /* create_subtable_clause */ + case 396: /* drop_table_clause */ + case 398: /* column_def */ + case 402: /* duration_literal */ + case 403: /* rollup_func_name */ + case 405: /* col_name */ + case 408: /* like_pattern_opt */ + case 409: /* db_name_cond_opt */ + case 410: /* table_name_cond */ + case 411: /* from_db_opt */ + case 414: /* tag_item */ + case 416: /* index_options */ + case 417: /* full_index_name */ + case 420: /* sliding_opt */ + case 421: /* sma_stream_opt */ + case 422: /* func */ + case 425: /* query_or_subquery */ + case 426: /* where_clause_opt */ + case 429: /* explain_options */ + case 430: /* insert_query */ + case 435: /* full_view_name */ + case 438: /* stream_options */ + case 441: /* subtable_opt */ + case 443: /* expression */ + case 446: /* literal_func */ + case 449: /* expr_or_subquery */ + case 450: /* pseudo_column */ + case 451: /* column_reference */ + case 452: /* function_expression */ + case 453: /* case_when_expression */ + case 458: /* star_func_para */ + case 460: /* case_when_else_opt */ + case 461: /* common_expression */ + case 462: /* when_then_expr */ + case 463: /* predicate */ + case 466: /* in_predicate_value */ + case 467: /* boolean_value_expression */ + case 468: /* boolean_primary */ + case 469: /* from_clause_opt */ + case 470: /* table_reference_list */ + case 471: /* table_reference */ + case 472: /* table_primary */ + case 473: /* joined_table */ + case 475: /* subquery */ + case 476: /* parenthesized_joined_table */ + case 478: /* query_specification */ + case 484: /* range_opt */ + case 485: /* every_opt */ + case 486: /* fill_opt */ + case 487: /* twindow_clause_opt */ + case 489: /* having_clause_opt */ + case 490: /* select_item */ + case 492: /* partition_item */ + case 493: /* interval_sliding_duration_literal */ + case 496: /* query_expression */ + case 497: /* query_simple */ + case 499: /* slimit_clause_opt */ + case 500: /* limit_clause_opt */ + case 501: /* union_query_expression */ + case 502: /* query_simple_or_subquery */ + case 504: /* sort_specification */ { - nodesDestroyNode((yypminor->yy56)); + nodesDestroyNode((yypminor->yy80)); } break; - case 346: /* account_options */ - case 347: /* alter_account_options */ - case 349: /* alter_account_option */ - case 371: /* speed_opt */ - case 423: /* with_meta */ - case 432: /* bufsize_opt */ + case 347: /* account_options */ + case 348: /* alter_account_options */ + case 350: /* alter_account_option */ + case 372: /* speed_opt */ + case 424: /* with_meta */ + case 433: /* bufsize_opt */ { } break; - case 350: /* ip_range_list */ - case 351: /* white_list */ - case 352: /* white_list_opt */ - case 374: /* integer_list */ - case 375: /* variable_list */ - case 376: /* retention_list */ - case 381: /* column_def_list */ - case 382: /* tags_def_opt */ - case 384: /* multi_create_clause */ - case 385: /* tags_def */ - case 386: /* multi_drop_clause */ - case 393: /* specific_cols_opt */ - case 394: /* expression_list */ - case 396: /* col_name_list */ - case 398: /* duration_list */ - case 399: /* rollup_func_list */ - case 411: /* tag_list_opt */ - case 418: /* func_list */ - case 436: /* col_list_opt */ - case 437: /* tag_def_or_ref_opt */ - case 442: /* dnode_list */ - case 444: /* literal_list */ - case 452: /* star_func_para_list */ - case 454: /* other_para_list */ - case 456: /* when_then_list */ - case 476: /* hint_list */ - case 479: /* select_list */ - case 480: /* partition_by_clause_opt */ - case 485: /* group_by_clause_opt */ - case 488: /* partition_list */ - case 492: /* group_by_list */ - case 495: /* order_by_clause_opt */ - case 500: /* sort_specification_list */ + case 351: /* ip_range_list */ + case 352: /* white_list */ + case 353: /* white_list_opt */ + case 375: /* integer_list */ + case 376: /* variable_list */ + case 377: /* retention_list */ + case 382: /* column_def_list */ + case 383: /* tags_def_opt */ + case 385: /* multi_create_clause */ + case 386: /* tags_def */ + case 387: /* multi_drop_clause */ + case 394: /* specific_cols_opt */ + case 395: /* expression_list */ + case 397: /* col_name_list */ + case 399: /* duration_list */ + case 400: /* rollup_func_list */ + case 412: /* tag_list_opt */ + case 419: /* func_list */ + case 439: /* col_list_opt */ + case 440: /* tag_def_or_ref_opt */ + case 445: /* dnode_list */ + case 447: /* literal_list */ + case 455: /* star_func_para_list */ + case 457: /* other_para_list */ + case 459: /* when_then_list */ + case 479: /* hint_list */ + case 482: /* select_list */ + case 483: /* partition_by_clause_opt */ + case 488: /* group_by_clause_opt */ + case 491: /* partition_list */ + case 495: /* group_by_list */ + case 498: /* order_by_clause_opt */ + case 503: /* sort_specification_list */ { - nodesDestroyList((yypminor->yy712)); + nodesDestroyList((yypminor->yy106)); } break; - case 353: /* user_name */ - case 360: /* db_name */ - case 361: /* table_name */ - case 362: /* topic_name */ - case 364: /* dnode_endpoint */ - case 389: /* column_name */ - case 403: /* function_name */ - case 414: /* column_alias */ - case 417: /* index_name */ - case 422: /* sma_func_name */ - case 426: /* cgroup_name */ - case 433: /* language_opt */ - case 434: /* stream_name */ - case 441: /* on_vgroup_id */ - case 445: /* table_alias */ - case 451: /* star_func */ - case 453: /* noarg_func */ - case 471: /* alias_opt */ + case 354: /* user_name */ + case 361: /* db_name */ + case 362: /* table_name */ + case 363: /* topic_name */ + case 365: /* dnode_endpoint */ + case 390: /* column_name */ + case 404: /* function_name */ + case 415: /* column_alias */ + case 418: /* index_name */ + case 423: /* sma_func_name */ + case 427: /* cgroup_name */ + case 434: /* language_opt */ + case 436: /* view_name */ + case 437: /* stream_name */ + case 444: /* on_vgroup_id */ + case 448: /* table_alias */ + case 454: /* star_func */ + case 456: /* noarg_func */ + case 474: /* alias_opt */ { } break; - case 354: /* sysinfo_opt */ + case 355: /* sysinfo_opt */ { } break; - case 355: /* privileges */ - case 358: /* priv_type_list */ - case 359: /* priv_type */ + case 356: /* privileges */ + case 359: /* priv_type_list */ + case 360: /* priv_type */ { } break; - case 356: /* priv_level */ + case 357: /* priv_level */ { } break; - case 365: /* force_opt */ - case 366: /* unsafe_opt */ - case 367: /* not_exists_opt */ - case 369: /* exists_opt */ - case 427: /* analyze_opt */ - case 430: /* or_replace_opt */ - case 431: /* agg_func_opt */ - case 439: /* ignore_opt */ - case 477: /* set_quantifier_opt */ - case 478: /* tag_mode_opt */ + case 366: /* force_opt */ + case 367: /* unsafe_opt */ + case 368: /* not_exists_opt */ + case 370: /* exists_opt */ + case 428: /* analyze_opt */ + case 431: /* or_replace_opt */ + case 432: /* agg_func_opt */ + case 442: /* ignore_opt */ + case 480: /* set_quantifier_opt */ + case 481: /* tag_mode_opt */ { } break; - case 378: /* alter_db_option */ - case 400: /* alter_table_option */ + case 379: /* alter_db_option */ + case 401: /* alter_table_option */ { } break; - case 390: /* type_name */ + case 391: /* type_name */ { } break; - case 405: /* db_kind_opt */ - case 412: /* table_kind */ + case 406: /* db_kind_opt */ + case 413: /* table_kind */ { } break; - case 406: /* table_kind_db_name_cond_opt */ + case 407: /* table_kind_db_name_cond_opt */ { } break; - case 461: /* compare_op */ - case 462: /* in_op */ + case 464: /* compare_op */ + case 465: /* in_op */ { } break; - case 474: /* join_type */ + case 477: /* join_type */ { } break; - case 491: /* fill_mode */ + case 494: /* fill_mode */ { } break; - case 502: /* ordering_specification_opt */ + case 505: /* ordering_specification_opt */ { } break; - case 503: /* null_ordering_opt */ + case 506: /* null_ordering_opt */ { } @@ -3433,637 +3355,645 @@ static void yy_shift( /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side ** of that rule */ static const YYCODETYPE yyRuleInfoLhs[] = { - 345, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ - 345, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ - 346, /* (2) account_options ::= */ - 346, /* (3) account_options ::= account_options PPS literal */ - 346, /* (4) account_options ::= account_options TSERIES literal */ - 346, /* (5) account_options ::= account_options STORAGE literal */ - 346, /* (6) account_options ::= account_options STREAMS literal */ - 346, /* (7) account_options ::= account_options QTIME literal */ - 346, /* (8) account_options ::= account_options DBS literal */ - 346, /* (9) account_options ::= account_options USERS literal */ - 346, /* (10) account_options ::= account_options CONNS literal */ - 346, /* (11) account_options ::= account_options STATE literal */ - 347, /* (12) alter_account_options ::= alter_account_option */ - 347, /* (13) alter_account_options ::= alter_account_options alter_account_option */ - 349, /* (14) alter_account_option ::= PASS literal */ - 349, /* (15) alter_account_option ::= PPS literal */ - 349, /* (16) alter_account_option ::= TSERIES literal */ - 349, /* (17) alter_account_option ::= STORAGE literal */ - 349, /* (18) alter_account_option ::= STREAMS literal */ - 349, /* (19) alter_account_option ::= QTIME literal */ - 349, /* (20) alter_account_option ::= DBS literal */ - 349, /* (21) alter_account_option ::= USERS literal */ - 349, /* (22) alter_account_option ::= CONNS literal */ - 349, /* (23) alter_account_option ::= STATE literal */ - 350, /* (24) ip_range_list ::= NK_STRING */ - 350, /* (25) ip_range_list ::= ip_range_list NK_COMMA NK_STRING */ - 351, /* (26) white_list ::= HOST ip_range_list */ - 352, /* (27) white_list_opt ::= */ - 352, /* (28) white_list_opt ::= white_list */ - 345, /* (29) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt white_list_opt */ - 345, /* (30) cmd ::= ALTER USER user_name PASS NK_STRING */ - 345, /* (31) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ - 345, /* (32) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ - 345, /* (33) cmd ::= ALTER USER user_name ADD white_list */ - 345, /* (34) cmd ::= ALTER USER user_name DROP white_list */ - 345, /* (35) cmd ::= DROP USER user_name */ - 354, /* (36) sysinfo_opt ::= */ - 354, /* (37) sysinfo_opt ::= SYSINFO NK_INTEGER */ - 345, /* (38) cmd ::= GRANT privileges ON priv_level with_opt TO user_name */ - 345, /* (39) cmd ::= REVOKE privileges ON priv_level with_opt FROM user_name */ - 355, /* (40) privileges ::= ALL */ - 355, /* (41) privileges ::= priv_type_list */ - 355, /* (42) privileges ::= SUBSCRIBE */ - 358, /* (43) priv_type_list ::= priv_type */ - 358, /* (44) priv_type_list ::= priv_type_list NK_COMMA priv_type */ - 359, /* (45) priv_type ::= READ */ - 359, /* (46) priv_type ::= WRITE */ - 356, /* (47) priv_level ::= NK_STAR NK_DOT NK_STAR */ - 356, /* (48) priv_level ::= db_name NK_DOT NK_STAR */ - 356, /* (49) priv_level ::= db_name NK_DOT table_name */ - 356, /* (50) priv_level ::= topic_name */ - 357, /* (51) with_opt ::= */ - 357, /* (52) with_opt ::= WITH search_condition */ - 345, /* (53) cmd ::= CREATE DNODE dnode_endpoint */ - 345, /* (54) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ - 345, /* (55) cmd ::= DROP DNODE NK_INTEGER force_opt */ - 345, /* (56) cmd ::= DROP DNODE dnode_endpoint force_opt */ - 345, /* (57) cmd ::= DROP DNODE NK_INTEGER unsafe_opt */ - 345, /* (58) cmd ::= DROP DNODE dnode_endpoint unsafe_opt */ - 345, /* (59) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ - 345, /* (60) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ - 345, /* (61) cmd ::= ALTER ALL DNODES NK_STRING */ - 345, /* (62) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ - 345, /* (63) cmd ::= RESTORE DNODE NK_INTEGER */ - 364, /* (64) dnode_endpoint ::= NK_STRING */ - 364, /* (65) dnode_endpoint ::= NK_ID */ - 364, /* (66) dnode_endpoint ::= NK_IPTOKEN */ - 365, /* (67) force_opt ::= */ - 365, /* (68) force_opt ::= FORCE */ - 366, /* (69) unsafe_opt ::= UNSAFE */ - 345, /* (70) cmd ::= ALTER LOCAL NK_STRING */ - 345, /* (71) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ - 345, /* (72) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ - 345, /* (73) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ - 345, /* (74) cmd ::= RESTORE QNODE ON DNODE NK_INTEGER */ - 345, /* (75) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ - 345, /* (76) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ - 345, /* (77) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ - 345, /* (78) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ - 345, /* (79) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ - 345, /* (80) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ - 345, /* (81) cmd ::= RESTORE MNODE ON DNODE NK_INTEGER */ - 345, /* (82) cmd ::= RESTORE VNODE ON DNODE NK_INTEGER */ - 345, /* (83) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - 345, /* (84) cmd ::= DROP DATABASE exists_opt db_name */ - 345, /* (85) cmd ::= USE db_name */ - 345, /* (86) cmd ::= ALTER DATABASE db_name alter_db_options */ - 345, /* (87) cmd ::= FLUSH DATABASE db_name */ - 345, /* (88) cmd ::= TRIM DATABASE db_name speed_opt */ - 345, /* (89) cmd ::= COMPACT DATABASE db_name start_opt end_opt */ - 367, /* (90) not_exists_opt ::= IF NOT EXISTS */ - 367, /* (91) not_exists_opt ::= */ - 369, /* (92) exists_opt ::= IF EXISTS */ - 369, /* (93) exists_opt ::= */ - 368, /* (94) db_options ::= */ - 368, /* (95) db_options ::= db_options BUFFER NK_INTEGER */ - 368, /* (96) db_options ::= db_options CACHEMODEL NK_STRING */ - 368, /* (97) db_options ::= db_options CACHESIZE NK_INTEGER */ - 368, /* (98) db_options ::= db_options COMP NK_INTEGER */ - 368, /* (99) db_options ::= db_options DURATION NK_INTEGER */ - 368, /* (100) db_options ::= db_options DURATION NK_VARIABLE */ - 368, /* (101) db_options ::= db_options MAXROWS NK_INTEGER */ - 368, /* (102) db_options ::= db_options MINROWS NK_INTEGER */ - 368, /* (103) db_options ::= db_options KEEP integer_list */ - 368, /* (104) db_options ::= db_options KEEP variable_list */ - 368, /* (105) db_options ::= db_options PAGES NK_INTEGER */ - 368, /* (106) db_options ::= db_options PAGESIZE NK_INTEGER */ - 368, /* (107) db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ - 368, /* (108) db_options ::= db_options PRECISION NK_STRING */ - 368, /* (109) db_options ::= db_options REPLICA NK_INTEGER */ - 368, /* (110) db_options ::= db_options VGROUPS NK_INTEGER */ - 368, /* (111) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - 368, /* (112) db_options ::= db_options RETENTIONS retention_list */ - 368, /* (113) db_options ::= db_options SCHEMALESS NK_INTEGER */ - 368, /* (114) db_options ::= db_options WAL_LEVEL NK_INTEGER */ - 368, /* (115) db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ - 368, /* (116) db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ - 368, /* (117) db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ - 368, /* (118) db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ - 368, /* (119) db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ - 368, /* (120) db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ - 368, /* (121) db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ - 368, /* (122) db_options ::= db_options STT_TRIGGER NK_INTEGER */ - 368, /* (123) db_options ::= db_options TABLE_PREFIX signed */ - 368, /* (124) db_options ::= db_options TABLE_SUFFIX signed */ - 368, /* (125) db_options ::= db_options KEEP_TIME_OFFSET NK_INTEGER */ - 370, /* (126) alter_db_options ::= alter_db_option */ - 370, /* (127) alter_db_options ::= alter_db_options alter_db_option */ - 378, /* (128) alter_db_option ::= BUFFER NK_INTEGER */ - 378, /* (129) alter_db_option ::= CACHEMODEL NK_STRING */ - 378, /* (130) alter_db_option ::= CACHESIZE NK_INTEGER */ - 378, /* (131) alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ - 378, /* (132) alter_db_option ::= KEEP integer_list */ - 378, /* (133) alter_db_option ::= KEEP variable_list */ - 378, /* (134) alter_db_option ::= PAGES NK_INTEGER */ - 378, /* (135) alter_db_option ::= REPLICA NK_INTEGER */ - 378, /* (136) alter_db_option ::= WAL_LEVEL NK_INTEGER */ - 378, /* (137) alter_db_option ::= STT_TRIGGER NK_INTEGER */ - 378, /* (138) alter_db_option ::= MINROWS NK_INTEGER */ - 378, /* (139) alter_db_option ::= WAL_RETENTION_PERIOD NK_INTEGER */ - 378, /* (140) alter_db_option ::= WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ - 378, /* (141) alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER */ - 378, /* (142) alter_db_option ::= WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ - 378, /* (143) alter_db_option ::= KEEP_TIME_OFFSET NK_INTEGER */ - 374, /* (144) integer_list ::= NK_INTEGER */ - 374, /* (145) integer_list ::= integer_list NK_COMMA NK_INTEGER */ - 375, /* (146) variable_list ::= NK_VARIABLE */ - 375, /* (147) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ - 376, /* (148) retention_list ::= retention */ - 376, /* (149) retention_list ::= retention_list NK_COMMA retention */ - 379, /* (150) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ - 379, /* (151) retention ::= NK_MINUS NK_COLON NK_VARIABLE */ - 371, /* (152) speed_opt ::= */ - 371, /* (153) speed_opt ::= BWLIMIT NK_INTEGER */ - 372, /* (154) start_opt ::= */ - 372, /* (155) start_opt ::= START WITH NK_INTEGER */ - 372, /* (156) start_opt ::= START WITH NK_STRING */ - 372, /* (157) start_opt ::= START WITH TIMESTAMP NK_STRING */ - 373, /* (158) end_opt ::= */ - 373, /* (159) end_opt ::= END WITH NK_INTEGER */ - 373, /* (160) end_opt ::= END WITH NK_STRING */ - 373, /* (161) end_opt ::= END WITH TIMESTAMP NK_STRING */ - 345, /* (162) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - 345, /* (163) cmd ::= CREATE TABLE multi_create_clause */ - 345, /* (164) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - 345, /* (165) cmd ::= DROP TABLE multi_drop_clause */ - 345, /* (166) cmd ::= DROP STABLE exists_opt full_table_name */ - 345, /* (167) cmd ::= ALTER TABLE alter_table_clause */ - 345, /* (168) cmd ::= ALTER STABLE alter_table_clause */ - 387, /* (169) alter_table_clause ::= full_table_name alter_table_options */ - 387, /* (170) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ - 387, /* (171) alter_table_clause ::= full_table_name DROP COLUMN column_name */ - 387, /* (172) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ - 387, /* (173) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ - 387, /* (174) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ - 387, /* (175) alter_table_clause ::= full_table_name DROP TAG column_name */ - 387, /* (176) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ - 387, /* (177) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ - 387, /* (178) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ - 384, /* (179) multi_create_clause ::= create_subtable_clause */ - 384, /* (180) multi_create_clause ::= multi_create_clause create_subtable_clause */ - 392, /* (181) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */ - 386, /* (182) multi_drop_clause ::= drop_table_clause */ - 386, /* (183) multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause */ - 395, /* (184) drop_table_clause ::= exists_opt full_table_name */ - 393, /* (185) specific_cols_opt ::= */ - 393, /* (186) specific_cols_opt ::= NK_LP col_name_list NK_RP */ - 380, /* (187) full_table_name ::= table_name */ - 380, /* (188) full_table_name ::= db_name NK_DOT table_name */ - 381, /* (189) column_def_list ::= column_def */ - 381, /* (190) column_def_list ::= column_def_list NK_COMMA column_def */ - 397, /* (191) column_def ::= column_name type_name */ - 390, /* (192) type_name ::= BOOL */ - 390, /* (193) type_name ::= TINYINT */ - 390, /* (194) type_name ::= SMALLINT */ - 390, /* (195) type_name ::= INT */ - 390, /* (196) type_name ::= INTEGER */ - 390, /* (197) type_name ::= BIGINT */ - 390, /* (198) type_name ::= FLOAT */ - 390, /* (199) type_name ::= DOUBLE */ - 390, /* (200) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - 390, /* (201) type_name ::= TIMESTAMP */ - 390, /* (202) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - 390, /* (203) type_name ::= TINYINT UNSIGNED */ - 390, /* (204) type_name ::= SMALLINT UNSIGNED */ - 390, /* (205) type_name ::= INT UNSIGNED */ - 390, /* (206) type_name ::= BIGINT UNSIGNED */ - 390, /* (207) type_name ::= JSON */ - 390, /* (208) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - 390, /* (209) type_name ::= MEDIUMBLOB */ - 390, /* (210) type_name ::= BLOB */ - 390, /* (211) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - 390, /* (212) type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP */ - 390, /* (213) type_name ::= DECIMAL */ - 390, /* (214) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - 390, /* (215) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - 382, /* (216) tags_def_opt ::= */ - 382, /* (217) tags_def_opt ::= tags_def */ - 385, /* (218) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - 383, /* (219) table_options ::= */ - 383, /* (220) table_options ::= table_options COMMENT NK_STRING */ - 383, /* (221) table_options ::= table_options MAX_DELAY duration_list */ - 383, /* (222) table_options ::= table_options WATERMARK duration_list */ - 383, /* (223) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ - 383, /* (224) table_options ::= table_options TTL NK_INTEGER */ - 383, /* (225) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - 383, /* (226) table_options ::= table_options DELETE_MARK duration_list */ - 388, /* (227) alter_table_options ::= alter_table_option */ - 388, /* (228) alter_table_options ::= alter_table_options alter_table_option */ - 400, /* (229) alter_table_option ::= COMMENT NK_STRING */ - 400, /* (230) alter_table_option ::= TTL NK_INTEGER */ - 398, /* (231) duration_list ::= duration_literal */ - 398, /* (232) duration_list ::= duration_list NK_COMMA duration_literal */ - 399, /* (233) rollup_func_list ::= rollup_func_name */ - 399, /* (234) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ - 402, /* (235) rollup_func_name ::= function_name */ - 402, /* (236) rollup_func_name ::= FIRST */ - 402, /* (237) rollup_func_name ::= LAST */ - 396, /* (238) col_name_list ::= col_name */ - 396, /* (239) col_name_list ::= col_name_list NK_COMMA col_name */ - 404, /* (240) col_name ::= column_name */ - 345, /* (241) cmd ::= SHOW DNODES */ - 345, /* (242) cmd ::= SHOW USERS */ - 345, /* (243) cmd ::= SHOW USER PRIVILEGES */ - 345, /* (244) cmd ::= SHOW db_kind_opt DATABASES */ - 345, /* (245) cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt */ - 345, /* (246) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ - 345, /* (247) cmd ::= SHOW db_name_cond_opt VGROUPS */ - 345, /* (248) cmd ::= SHOW MNODES */ - 345, /* (249) cmd ::= SHOW QNODES */ - 345, /* (250) cmd ::= SHOW FUNCTIONS */ - 345, /* (251) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ - 345, /* (252) cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name */ - 345, /* (253) cmd ::= SHOW STREAMS */ - 345, /* (254) cmd ::= SHOW ACCOUNTS */ - 345, /* (255) cmd ::= SHOW APPS */ - 345, /* (256) cmd ::= SHOW CONNECTIONS */ - 345, /* (257) cmd ::= SHOW LICENCES */ - 345, /* (258) cmd ::= SHOW GRANTS */ - 345, /* (259) cmd ::= SHOW CREATE DATABASE db_name */ - 345, /* (260) cmd ::= SHOW CREATE TABLE full_table_name */ - 345, /* (261) cmd ::= SHOW CREATE STABLE full_table_name */ - 345, /* (262) cmd ::= SHOW QUERIES */ - 345, /* (263) cmd ::= SHOW SCORES */ - 345, /* (264) cmd ::= SHOW TOPICS */ - 345, /* (265) cmd ::= SHOW VARIABLES */ - 345, /* (266) cmd ::= SHOW CLUSTER VARIABLES */ - 345, /* (267) cmd ::= SHOW LOCAL VARIABLES */ - 345, /* (268) cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ - 345, /* (269) cmd ::= SHOW BNODES */ - 345, /* (270) cmd ::= SHOW SNODES */ - 345, /* (271) cmd ::= SHOW CLUSTER */ - 345, /* (272) cmd ::= SHOW TRANSACTIONS */ - 345, /* (273) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ - 345, /* (274) cmd ::= SHOW CONSUMERS */ - 345, /* (275) cmd ::= SHOW SUBSCRIPTIONS */ - 345, /* (276) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ - 345, /* (277) cmd ::= SHOW TAGS FROM db_name NK_DOT table_name */ - 345, /* (278) cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ - 345, /* (279) cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name */ - 345, /* (280) cmd ::= SHOW VNODES ON DNODE NK_INTEGER */ - 345, /* (281) cmd ::= SHOW VNODES */ - 345, /* (282) cmd ::= SHOW db_name_cond_opt ALIVE */ - 345, /* (283) cmd ::= SHOW CLUSTER ALIVE */ - 406, /* (284) table_kind_db_name_cond_opt ::= */ - 406, /* (285) table_kind_db_name_cond_opt ::= table_kind */ - 406, /* (286) table_kind_db_name_cond_opt ::= db_name NK_DOT */ - 406, /* (287) table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ - 412, /* (288) table_kind ::= NORMAL */ - 412, /* (289) table_kind ::= CHILD */ - 408, /* (290) db_name_cond_opt ::= */ - 408, /* (291) db_name_cond_opt ::= db_name NK_DOT */ - 407, /* (292) like_pattern_opt ::= */ - 407, /* (293) like_pattern_opt ::= LIKE NK_STRING */ - 409, /* (294) table_name_cond ::= table_name */ - 410, /* (295) from_db_opt ::= */ - 410, /* (296) from_db_opt ::= FROM db_name */ - 411, /* (297) tag_list_opt ::= */ - 411, /* (298) tag_list_opt ::= tag_item */ - 411, /* (299) tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ - 413, /* (300) tag_item ::= TBNAME */ - 413, /* (301) tag_item ::= QTAGS */ - 413, /* (302) tag_item ::= column_name */ - 413, /* (303) tag_item ::= column_name column_alias */ - 413, /* (304) tag_item ::= column_name AS column_alias */ - 405, /* (305) db_kind_opt ::= */ - 405, /* (306) db_kind_opt ::= USER */ - 405, /* (307) db_kind_opt ::= SYSTEM */ - 345, /* (308) cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ - 345, /* (309) cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ - 345, /* (310) cmd ::= DROP INDEX exists_opt full_index_name */ - 416, /* (311) full_index_name ::= index_name */ - 416, /* (312) full_index_name ::= db_name NK_DOT index_name */ - 415, /* (313) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ - 415, /* (314) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ - 418, /* (315) func_list ::= func */ - 418, /* (316) func_list ::= func_list NK_COMMA func */ - 421, /* (317) func ::= sma_func_name NK_LP expression_list NK_RP */ - 422, /* (318) sma_func_name ::= function_name */ - 422, /* (319) sma_func_name ::= COUNT */ - 422, /* (320) sma_func_name ::= FIRST */ - 422, /* (321) sma_func_name ::= LAST */ - 422, /* (322) sma_func_name ::= LAST_ROW */ - 420, /* (323) sma_stream_opt ::= */ - 420, /* (324) sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ - 420, /* (325) sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ - 420, /* (326) sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ - 423, /* (327) with_meta ::= AS */ - 423, /* (328) with_meta ::= WITH META AS */ - 423, /* (329) with_meta ::= ONLY META AS */ - 345, /* (330) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ - 345, /* (331) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ - 345, /* (332) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ - 345, /* (333) cmd ::= DROP TOPIC exists_opt topic_name */ - 345, /* (334) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ - 345, /* (335) cmd ::= DESC full_table_name */ - 345, /* (336) cmd ::= DESCRIBE full_table_name */ - 345, /* (337) cmd ::= RESET QUERY CACHE */ - 345, /* (338) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ - 345, /* (339) cmd ::= EXPLAIN analyze_opt explain_options insert_query */ - 427, /* (340) analyze_opt ::= */ - 427, /* (341) analyze_opt ::= ANALYZE */ - 428, /* (342) explain_options ::= */ - 428, /* (343) explain_options ::= explain_options VERBOSE NK_BOOL */ - 428, /* (344) explain_options ::= explain_options RATIO NK_FLOAT */ - 345, /* (345) cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ - 345, /* (346) cmd ::= DROP FUNCTION exists_opt function_name */ - 431, /* (347) agg_func_opt ::= */ - 431, /* (348) agg_func_opt ::= AGGREGATE */ - 432, /* (349) bufsize_opt ::= */ - 432, /* (350) bufsize_opt ::= BUFSIZE NK_INTEGER */ - 433, /* (351) language_opt ::= */ - 433, /* (352) language_opt ::= LANGUAGE NK_STRING */ - 430, /* (353) or_replace_opt ::= */ - 430, /* (354) or_replace_opt ::= OR REPLACE */ - 345, /* (355) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery */ - 345, /* (356) cmd ::= DROP STREAM exists_opt stream_name */ - 345, /* (357) cmd ::= PAUSE STREAM exists_opt stream_name */ - 345, /* (358) cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ - 436, /* (359) col_list_opt ::= */ - 436, /* (360) col_list_opt ::= NK_LP col_name_list NK_RP */ - 437, /* (361) tag_def_or_ref_opt ::= */ - 437, /* (362) tag_def_or_ref_opt ::= tags_def */ - 437, /* (363) tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP */ - 435, /* (364) stream_options ::= */ - 435, /* (365) stream_options ::= stream_options TRIGGER AT_ONCE */ - 435, /* (366) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ - 435, /* (367) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ - 435, /* (368) stream_options ::= stream_options WATERMARK duration_literal */ - 435, /* (369) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ - 435, /* (370) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ - 435, /* (371) stream_options ::= stream_options DELETE_MARK duration_literal */ - 435, /* (372) stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ - 438, /* (373) subtable_opt ::= */ - 438, /* (374) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - 439, /* (375) ignore_opt ::= */ - 439, /* (376) ignore_opt ::= IGNORE UNTREATED */ - 345, /* (377) cmd ::= KILL CONNECTION NK_INTEGER */ - 345, /* (378) cmd ::= KILL QUERY NK_STRING */ - 345, /* (379) cmd ::= KILL TRANSACTION NK_INTEGER */ - 345, /* (380) cmd ::= BALANCE VGROUP */ - 345, /* (381) cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ - 345, /* (382) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - 345, /* (383) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - 345, /* (384) cmd ::= SPLIT VGROUP NK_INTEGER */ - 441, /* (385) on_vgroup_id ::= */ - 441, /* (386) on_vgroup_id ::= ON NK_INTEGER */ - 442, /* (387) dnode_list ::= DNODE NK_INTEGER */ - 442, /* (388) dnode_list ::= dnode_list DNODE NK_INTEGER */ - 345, /* (389) cmd ::= DELETE FROM full_table_name where_clause_opt */ - 345, /* (390) cmd ::= query_or_subquery */ - 345, /* (391) cmd ::= insert_query */ - 429, /* (392) insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ - 429, /* (393) insert_query ::= INSERT INTO full_table_name query_or_subquery */ - 348, /* (394) literal ::= NK_INTEGER */ - 348, /* (395) literal ::= NK_FLOAT */ - 348, /* (396) literal ::= NK_STRING */ - 348, /* (397) literal ::= NK_BOOL */ - 348, /* (398) literal ::= TIMESTAMP NK_STRING */ - 348, /* (399) literal ::= duration_literal */ - 348, /* (400) literal ::= NULL */ - 348, /* (401) literal ::= NK_QUESTION */ - 401, /* (402) duration_literal ::= NK_VARIABLE */ - 377, /* (403) signed ::= NK_INTEGER */ - 377, /* (404) signed ::= NK_PLUS NK_INTEGER */ - 377, /* (405) signed ::= NK_MINUS NK_INTEGER */ - 377, /* (406) signed ::= NK_FLOAT */ - 377, /* (407) signed ::= NK_PLUS NK_FLOAT */ - 377, /* (408) signed ::= NK_MINUS NK_FLOAT */ - 391, /* (409) signed_literal ::= signed */ - 391, /* (410) signed_literal ::= NK_STRING */ - 391, /* (411) signed_literal ::= NK_BOOL */ - 391, /* (412) signed_literal ::= TIMESTAMP NK_STRING */ - 391, /* (413) signed_literal ::= duration_literal */ - 391, /* (414) signed_literal ::= NULL */ - 391, /* (415) signed_literal ::= literal_func */ - 391, /* (416) signed_literal ::= NK_QUESTION */ - 444, /* (417) literal_list ::= signed_literal */ - 444, /* (418) literal_list ::= literal_list NK_COMMA signed_literal */ - 360, /* (419) db_name ::= NK_ID */ - 361, /* (420) table_name ::= NK_ID */ - 389, /* (421) column_name ::= NK_ID */ - 403, /* (422) function_name ::= NK_ID */ - 445, /* (423) table_alias ::= NK_ID */ - 414, /* (424) column_alias ::= NK_ID */ - 414, /* (425) column_alias ::= NK_ALIAS */ - 353, /* (426) user_name ::= NK_ID */ - 362, /* (427) topic_name ::= NK_ID */ - 434, /* (428) stream_name ::= NK_ID */ - 426, /* (429) cgroup_name ::= NK_ID */ - 417, /* (430) index_name ::= NK_ID */ - 446, /* (431) expr_or_subquery ::= expression */ - 440, /* (432) expression ::= literal */ - 440, /* (433) expression ::= pseudo_column */ - 440, /* (434) expression ::= column_reference */ - 440, /* (435) expression ::= function_expression */ - 440, /* (436) expression ::= case_when_expression */ - 440, /* (437) expression ::= NK_LP expression NK_RP */ - 440, /* (438) expression ::= NK_PLUS expr_or_subquery */ - 440, /* (439) expression ::= NK_MINUS expr_or_subquery */ - 440, /* (440) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ - 440, /* (441) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ - 440, /* (442) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ - 440, /* (443) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ - 440, /* (444) expression ::= expr_or_subquery NK_REM expr_or_subquery */ - 440, /* (445) expression ::= column_reference NK_ARROW NK_STRING */ - 440, /* (446) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ - 440, /* (447) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ - 394, /* (448) expression_list ::= expr_or_subquery */ - 394, /* (449) expression_list ::= expression_list NK_COMMA expr_or_subquery */ - 448, /* (450) column_reference ::= column_name */ - 448, /* (451) column_reference ::= table_name NK_DOT column_name */ - 448, /* (452) column_reference ::= NK_ALIAS */ - 448, /* (453) column_reference ::= table_name NK_DOT NK_ALIAS */ - 447, /* (454) pseudo_column ::= ROWTS */ - 447, /* (455) pseudo_column ::= TBNAME */ - 447, /* (456) pseudo_column ::= table_name NK_DOT TBNAME */ - 447, /* (457) pseudo_column ::= QSTART */ - 447, /* (458) pseudo_column ::= QEND */ - 447, /* (459) pseudo_column ::= QDURATION */ - 447, /* (460) pseudo_column ::= WSTART */ - 447, /* (461) pseudo_column ::= WEND */ - 447, /* (462) pseudo_column ::= WDURATION */ - 447, /* (463) pseudo_column ::= IROWTS */ - 447, /* (464) pseudo_column ::= ISFILLED */ - 447, /* (465) pseudo_column ::= QTAGS */ - 449, /* (466) function_expression ::= function_name NK_LP expression_list NK_RP */ - 449, /* (467) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ - 449, /* (468) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ - 449, /* (469) function_expression ::= literal_func */ - 443, /* (470) literal_func ::= noarg_func NK_LP NK_RP */ - 443, /* (471) literal_func ::= NOW */ - 453, /* (472) noarg_func ::= NOW */ - 453, /* (473) noarg_func ::= TODAY */ - 453, /* (474) noarg_func ::= TIMEZONE */ - 453, /* (475) noarg_func ::= DATABASE */ - 453, /* (476) noarg_func ::= CLIENT_VERSION */ - 453, /* (477) noarg_func ::= SERVER_VERSION */ - 453, /* (478) noarg_func ::= SERVER_STATUS */ - 453, /* (479) noarg_func ::= CURRENT_USER */ - 453, /* (480) noarg_func ::= USER */ - 451, /* (481) star_func ::= COUNT */ - 451, /* (482) star_func ::= FIRST */ - 451, /* (483) star_func ::= LAST */ - 451, /* (484) star_func ::= LAST_ROW */ - 452, /* (485) star_func_para_list ::= NK_STAR */ - 452, /* (486) star_func_para_list ::= other_para_list */ - 454, /* (487) other_para_list ::= star_func_para */ - 454, /* (488) other_para_list ::= other_para_list NK_COMMA star_func_para */ - 455, /* (489) star_func_para ::= expr_or_subquery */ - 455, /* (490) star_func_para ::= table_name NK_DOT NK_STAR */ - 450, /* (491) case_when_expression ::= CASE when_then_list case_when_else_opt END */ - 450, /* (492) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ - 456, /* (493) when_then_list ::= when_then_expr */ - 456, /* (494) when_then_list ::= when_then_list when_then_expr */ - 459, /* (495) when_then_expr ::= WHEN common_expression THEN common_expression */ - 457, /* (496) case_when_else_opt ::= */ - 457, /* (497) case_when_else_opt ::= ELSE common_expression */ - 460, /* (498) predicate ::= expr_or_subquery compare_op expr_or_subquery */ - 460, /* (499) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ - 460, /* (500) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ - 460, /* (501) predicate ::= expr_or_subquery IS NULL */ - 460, /* (502) predicate ::= expr_or_subquery IS NOT NULL */ - 460, /* (503) predicate ::= expr_or_subquery in_op in_predicate_value */ - 461, /* (504) compare_op ::= NK_LT */ - 461, /* (505) compare_op ::= NK_GT */ - 461, /* (506) compare_op ::= NK_LE */ - 461, /* (507) compare_op ::= NK_GE */ - 461, /* (508) compare_op ::= NK_NE */ - 461, /* (509) compare_op ::= NK_EQ */ - 461, /* (510) compare_op ::= LIKE */ - 461, /* (511) compare_op ::= NOT LIKE */ - 461, /* (512) compare_op ::= MATCH */ - 461, /* (513) compare_op ::= NMATCH */ - 461, /* (514) compare_op ::= CONTAINS */ - 462, /* (515) in_op ::= IN */ - 462, /* (516) in_op ::= NOT IN */ - 463, /* (517) in_predicate_value ::= NK_LP literal_list NK_RP */ - 464, /* (518) boolean_value_expression ::= boolean_primary */ - 464, /* (519) boolean_value_expression ::= NOT boolean_primary */ - 464, /* (520) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - 464, /* (521) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - 465, /* (522) boolean_primary ::= predicate */ - 465, /* (523) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - 458, /* (524) common_expression ::= expr_or_subquery */ - 458, /* (525) common_expression ::= boolean_value_expression */ - 466, /* (526) from_clause_opt ::= */ - 466, /* (527) from_clause_opt ::= FROM table_reference_list */ - 467, /* (528) table_reference_list ::= table_reference */ - 467, /* (529) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - 468, /* (530) table_reference ::= table_primary */ - 468, /* (531) table_reference ::= joined_table */ - 469, /* (532) table_primary ::= table_name alias_opt */ - 469, /* (533) table_primary ::= db_name NK_DOT table_name alias_opt */ - 469, /* (534) table_primary ::= subquery alias_opt */ - 469, /* (535) table_primary ::= parenthesized_joined_table */ - 471, /* (536) alias_opt ::= */ - 471, /* (537) alias_opt ::= table_alias */ - 471, /* (538) alias_opt ::= AS table_alias */ - 473, /* (539) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - 473, /* (540) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - 470, /* (541) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - 474, /* (542) join_type ::= */ - 474, /* (543) join_type ::= INNER */ - 475, /* (544) query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ - 476, /* (545) hint_list ::= */ - 476, /* (546) hint_list ::= NK_HINT */ - 478, /* (547) tag_mode_opt ::= */ - 478, /* (548) tag_mode_opt ::= TAGS */ - 477, /* (549) set_quantifier_opt ::= */ - 477, /* (550) set_quantifier_opt ::= DISTINCT */ - 477, /* (551) set_quantifier_opt ::= ALL */ - 479, /* (552) select_list ::= select_item */ - 479, /* (553) select_list ::= select_list NK_COMMA select_item */ - 487, /* (554) select_item ::= NK_STAR */ - 487, /* (555) select_item ::= common_expression */ - 487, /* (556) select_item ::= common_expression column_alias */ - 487, /* (557) select_item ::= common_expression AS column_alias */ - 487, /* (558) select_item ::= table_name NK_DOT NK_STAR */ - 425, /* (559) where_clause_opt ::= */ - 425, /* (560) where_clause_opt ::= WHERE search_condition */ - 480, /* (561) partition_by_clause_opt ::= */ - 480, /* (562) partition_by_clause_opt ::= PARTITION BY partition_list */ - 488, /* (563) partition_list ::= partition_item */ - 488, /* (564) partition_list ::= partition_list NK_COMMA partition_item */ - 489, /* (565) partition_item ::= expr_or_subquery */ - 489, /* (566) partition_item ::= expr_or_subquery column_alias */ - 489, /* (567) partition_item ::= expr_or_subquery AS column_alias */ - 484, /* (568) twindow_clause_opt ::= */ - 484, /* (569) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ - 484, /* (570) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ - 484, /* (571) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ - 484, /* (572) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ - 484, /* (573) twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ - 419, /* (574) sliding_opt ::= */ - 419, /* (575) sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ - 490, /* (576) interval_sliding_duration_literal ::= NK_VARIABLE */ - 490, /* (577) interval_sliding_duration_literal ::= NK_STRING */ - 490, /* (578) interval_sliding_duration_literal ::= NK_INTEGER */ - 483, /* (579) fill_opt ::= */ - 483, /* (580) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - 483, /* (581) fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ - 483, /* (582) fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ - 491, /* (583) fill_mode ::= NONE */ - 491, /* (584) fill_mode ::= PREV */ - 491, /* (585) fill_mode ::= NULL */ - 491, /* (586) fill_mode ::= NULL_F */ - 491, /* (587) fill_mode ::= LINEAR */ - 491, /* (588) fill_mode ::= NEXT */ - 485, /* (589) group_by_clause_opt ::= */ - 485, /* (590) group_by_clause_opt ::= GROUP BY group_by_list */ - 492, /* (591) group_by_list ::= expr_or_subquery */ - 492, /* (592) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ - 486, /* (593) having_clause_opt ::= */ - 486, /* (594) having_clause_opt ::= HAVING search_condition */ - 481, /* (595) range_opt ::= */ - 481, /* (596) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ - 481, /* (597) range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ - 482, /* (598) every_opt ::= */ - 482, /* (599) every_opt ::= EVERY NK_LP duration_literal NK_RP */ - 493, /* (600) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ - 494, /* (601) query_simple ::= query_specification */ - 494, /* (602) query_simple ::= union_query_expression */ - 498, /* (603) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ - 498, /* (604) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ - 499, /* (605) query_simple_or_subquery ::= query_simple */ - 499, /* (606) query_simple_or_subquery ::= subquery */ - 424, /* (607) query_or_subquery ::= query_expression */ - 424, /* (608) query_or_subquery ::= subquery */ - 495, /* (609) order_by_clause_opt ::= */ - 495, /* (610) order_by_clause_opt ::= ORDER BY sort_specification_list */ - 496, /* (611) slimit_clause_opt ::= */ - 496, /* (612) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - 496, /* (613) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - 496, /* (614) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - 497, /* (615) limit_clause_opt ::= */ - 497, /* (616) limit_clause_opt ::= LIMIT NK_INTEGER */ - 497, /* (617) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - 497, /* (618) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - 472, /* (619) subquery ::= NK_LP query_expression NK_RP */ - 472, /* (620) subquery ::= NK_LP subquery NK_RP */ - 363, /* (621) search_condition ::= common_expression */ - 500, /* (622) sort_specification_list ::= sort_specification */ - 500, /* (623) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - 501, /* (624) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ - 502, /* (625) ordering_specification_opt ::= */ - 502, /* (626) ordering_specification_opt ::= ASC */ - 502, /* (627) ordering_specification_opt ::= DESC */ - 503, /* (628) null_ordering_opt ::= */ - 503, /* (629) null_ordering_opt ::= NULLS FIRST */ - 503, /* (630) null_ordering_opt ::= NULLS LAST */ + 346, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ + 346, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ + 347, /* (2) account_options ::= */ + 347, /* (3) account_options ::= account_options PPS literal */ + 347, /* (4) account_options ::= account_options TSERIES literal */ + 347, /* (5) account_options ::= account_options STORAGE literal */ + 347, /* (6) account_options ::= account_options STREAMS literal */ + 347, /* (7) account_options ::= account_options QTIME literal */ + 347, /* (8) account_options ::= account_options DBS literal */ + 347, /* (9) account_options ::= account_options USERS literal */ + 347, /* (10) account_options ::= account_options CONNS literal */ + 347, /* (11) account_options ::= account_options STATE literal */ + 348, /* (12) alter_account_options ::= alter_account_option */ + 348, /* (13) alter_account_options ::= alter_account_options alter_account_option */ + 350, /* (14) alter_account_option ::= PASS literal */ + 350, /* (15) alter_account_option ::= PPS literal */ + 350, /* (16) alter_account_option ::= TSERIES literal */ + 350, /* (17) alter_account_option ::= STORAGE literal */ + 350, /* (18) alter_account_option ::= STREAMS literal */ + 350, /* (19) alter_account_option ::= QTIME literal */ + 350, /* (20) alter_account_option ::= DBS literal */ + 350, /* (21) alter_account_option ::= USERS literal */ + 350, /* (22) alter_account_option ::= CONNS literal */ + 350, /* (23) alter_account_option ::= STATE literal */ + 351, /* (24) ip_range_list ::= NK_STRING */ + 351, /* (25) ip_range_list ::= ip_range_list NK_COMMA NK_STRING */ + 352, /* (26) white_list ::= HOST ip_range_list */ + 353, /* (27) white_list_opt ::= */ + 353, /* (28) white_list_opt ::= white_list */ + 346, /* (29) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt white_list_opt */ + 346, /* (30) cmd ::= ALTER USER user_name PASS NK_STRING */ + 346, /* (31) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ + 346, /* (32) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ + 346, /* (33) cmd ::= ALTER USER user_name ADD white_list */ + 346, /* (34) cmd ::= ALTER USER user_name DROP white_list */ + 346, /* (35) cmd ::= DROP USER user_name */ + 355, /* (36) sysinfo_opt ::= */ + 355, /* (37) sysinfo_opt ::= SYSINFO NK_INTEGER */ + 346, /* (38) cmd ::= GRANT privileges ON priv_level with_opt TO user_name */ + 346, /* (39) cmd ::= REVOKE privileges ON priv_level with_opt FROM user_name */ + 356, /* (40) privileges ::= ALL */ + 356, /* (41) privileges ::= priv_type_list */ + 356, /* (42) privileges ::= SUBSCRIBE */ + 359, /* (43) priv_type_list ::= priv_type */ + 359, /* (44) priv_type_list ::= priv_type_list NK_COMMA priv_type */ + 360, /* (45) priv_type ::= READ */ + 360, /* (46) priv_type ::= WRITE */ + 360, /* (47) priv_type ::= ALTER */ + 357, /* (48) priv_level ::= NK_STAR NK_DOT NK_STAR */ + 357, /* (49) priv_level ::= db_name NK_DOT NK_STAR */ + 357, /* (50) priv_level ::= db_name NK_DOT table_name */ + 357, /* (51) priv_level ::= topic_name */ + 358, /* (52) with_opt ::= */ + 358, /* (53) with_opt ::= WITH search_condition */ + 346, /* (54) cmd ::= CREATE DNODE dnode_endpoint */ + 346, /* (55) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ + 346, /* (56) cmd ::= DROP DNODE NK_INTEGER force_opt */ + 346, /* (57) cmd ::= DROP DNODE dnode_endpoint force_opt */ + 346, /* (58) cmd ::= DROP DNODE NK_INTEGER unsafe_opt */ + 346, /* (59) cmd ::= DROP DNODE dnode_endpoint unsafe_opt */ + 346, /* (60) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + 346, /* (61) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + 346, /* (62) cmd ::= ALTER ALL DNODES NK_STRING */ + 346, /* (63) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + 346, /* (64) cmd ::= RESTORE DNODE NK_INTEGER */ + 365, /* (65) dnode_endpoint ::= NK_STRING */ + 365, /* (66) dnode_endpoint ::= NK_ID */ + 365, /* (67) dnode_endpoint ::= NK_IPTOKEN */ + 366, /* (68) force_opt ::= */ + 366, /* (69) force_opt ::= FORCE */ + 367, /* (70) unsafe_opt ::= UNSAFE */ + 346, /* (71) cmd ::= ALTER LOCAL NK_STRING */ + 346, /* (72) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + 346, /* (73) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + 346, /* (74) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + 346, /* (75) cmd ::= RESTORE QNODE ON DNODE NK_INTEGER */ + 346, /* (76) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ + 346, /* (77) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ + 346, /* (78) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ + 346, /* (79) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ + 346, /* (80) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ + 346, /* (81) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ + 346, /* (82) cmd ::= RESTORE MNODE ON DNODE NK_INTEGER */ + 346, /* (83) cmd ::= RESTORE VNODE ON DNODE NK_INTEGER */ + 346, /* (84) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + 346, /* (85) cmd ::= DROP DATABASE exists_opt db_name */ + 346, /* (86) cmd ::= USE db_name */ + 346, /* (87) cmd ::= ALTER DATABASE db_name alter_db_options */ + 346, /* (88) cmd ::= FLUSH DATABASE db_name */ + 346, /* (89) cmd ::= TRIM DATABASE db_name speed_opt */ + 346, /* (90) cmd ::= COMPACT DATABASE db_name start_opt end_opt */ + 368, /* (91) not_exists_opt ::= IF NOT EXISTS */ + 368, /* (92) not_exists_opt ::= */ + 370, /* (93) exists_opt ::= IF EXISTS */ + 370, /* (94) exists_opt ::= */ + 369, /* (95) db_options ::= */ + 369, /* (96) db_options ::= db_options BUFFER NK_INTEGER */ + 369, /* (97) db_options ::= db_options CACHEMODEL NK_STRING */ + 369, /* (98) db_options ::= db_options CACHESIZE NK_INTEGER */ + 369, /* (99) db_options ::= db_options COMP NK_INTEGER */ + 369, /* (100) db_options ::= db_options DURATION NK_INTEGER */ + 369, /* (101) db_options ::= db_options DURATION NK_VARIABLE */ + 369, /* (102) db_options ::= db_options MAXROWS NK_INTEGER */ + 369, /* (103) db_options ::= db_options MINROWS NK_INTEGER */ + 369, /* (104) db_options ::= db_options KEEP integer_list */ + 369, /* (105) db_options ::= db_options KEEP variable_list */ + 369, /* (106) db_options ::= db_options PAGES NK_INTEGER */ + 369, /* (107) db_options ::= db_options PAGESIZE NK_INTEGER */ + 369, /* (108) db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ + 369, /* (109) db_options ::= db_options PRECISION NK_STRING */ + 369, /* (110) db_options ::= db_options REPLICA NK_INTEGER */ + 369, /* (111) db_options ::= db_options VGROUPS NK_INTEGER */ + 369, /* (112) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + 369, /* (113) db_options ::= db_options RETENTIONS retention_list */ + 369, /* (114) db_options ::= db_options SCHEMALESS NK_INTEGER */ + 369, /* (115) db_options ::= db_options WAL_LEVEL NK_INTEGER */ + 369, /* (116) db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ + 369, /* (117) db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ + 369, /* (118) db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ + 369, /* (119) db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ + 369, /* (120) db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ + 369, /* (121) db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ + 369, /* (122) db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ + 369, /* (123) db_options ::= db_options STT_TRIGGER NK_INTEGER */ + 369, /* (124) db_options ::= db_options TABLE_PREFIX signed */ + 369, /* (125) db_options ::= db_options TABLE_SUFFIX signed */ + 369, /* (126) db_options ::= db_options KEEP_TIME_OFFSET NK_INTEGER */ + 371, /* (127) alter_db_options ::= alter_db_option */ + 371, /* (128) alter_db_options ::= alter_db_options alter_db_option */ + 379, /* (129) alter_db_option ::= BUFFER NK_INTEGER */ + 379, /* (130) alter_db_option ::= CACHEMODEL NK_STRING */ + 379, /* (131) alter_db_option ::= CACHESIZE NK_INTEGER */ + 379, /* (132) alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ + 379, /* (133) alter_db_option ::= KEEP integer_list */ + 379, /* (134) alter_db_option ::= KEEP variable_list */ + 379, /* (135) alter_db_option ::= PAGES NK_INTEGER */ + 379, /* (136) alter_db_option ::= REPLICA NK_INTEGER */ + 379, /* (137) alter_db_option ::= WAL_LEVEL NK_INTEGER */ + 379, /* (138) alter_db_option ::= STT_TRIGGER NK_INTEGER */ + 379, /* (139) alter_db_option ::= MINROWS NK_INTEGER */ + 379, /* (140) alter_db_option ::= WAL_RETENTION_PERIOD NK_INTEGER */ + 379, /* (141) alter_db_option ::= WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ + 379, /* (142) alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER */ + 379, /* (143) alter_db_option ::= WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ + 379, /* (144) alter_db_option ::= KEEP_TIME_OFFSET NK_INTEGER */ + 375, /* (145) integer_list ::= NK_INTEGER */ + 375, /* (146) integer_list ::= integer_list NK_COMMA NK_INTEGER */ + 376, /* (147) variable_list ::= NK_VARIABLE */ + 376, /* (148) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ + 377, /* (149) retention_list ::= retention */ + 377, /* (150) retention_list ::= retention_list NK_COMMA retention */ + 380, /* (151) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ + 380, /* (152) retention ::= NK_MINUS NK_COLON NK_VARIABLE */ + 372, /* (153) speed_opt ::= */ + 372, /* (154) speed_opt ::= BWLIMIT NK_INTEGER */ + 373, /* (155) start_opt ::= */ + 373, /* (156) start_opt ::= START WITH NK_INTEGER */ + 373, /* (157) start_opt ::= START WITH NK_STRING */ + 373, /* (158) start_opt ::= START WITH TIMESTAMP NK_STRING */ + 374, /* (159) end_opt ::= */ + 374, /* (160) end_opt ::= END WITH NK_INTEGER */ + 374, /* (161) end_opt ::= END WITH NK_STRING */ + 374, /* (162) end_opt ::= END WITH TIMESTAMP NK_STRING */ + 346, /* (163) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + 346, /* (164) cmd ::= CREATE TABLE multi_create_clause */ + 346, /* (165) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + 346, /* (166) cmd ::= DROP TABLE multi_drop_clause */ + 346, /* (167) cmd ::= DROP STABLE exists_opt full_table_name */ + 346, /* (168) cmd ::= ALTER TABLE alter_table_clause */ + 346, /* (169) cmd ::= ALTER STABLE alter_table_clause */ + 388, /* (170) alter_table_clause ::= full_table_name alter_table_options */ + 388, /* (171) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ + 388, /* (172) alter_table_clause ::= full_table_name DROP COLUMN column_name */ + 388, /* (173) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ + 388, /* (174) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ + 388, /* (175) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ + 388, /* (176) alter_table_clause ::= full_table_name DROP TAG column_name */ + 388, /* (177) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ + 388, /* (178) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ + 388, /* (179) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ + 385, /* (180) multi_create_clause ::= create_subtable_clause */ + 385, /* (181) multi_create_clause ::= multi_create_clause create_subtable_clause */ + 393, /* (182) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */ + 387, /* (183) multi_drop_clause ::= drop_table_clause */ + 387, /* (184) multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause */ + 396, /* (185) drop_table_clause ::= exists_opt full_table_name */ + 394, /* (186) specific_cols_opt ::= */ + 394, /* (187) specific_cols_opt ::= NK_LP col_name_list NK_RP */ + 381, /* (188) full_table_name ::= table_name */ + 381, /* (189) full_table_name ::= db_name NK_DOT table_name */ + 382, /* (190) column_def_list ::= column_def */ + 382, /* (191) column_def_list ::= column_def_list NK_COMMA column_def */ + 398, /* (192) column_def ::= column_name type_name */ + 391, /* (193) type_name ::= BOOL */ + 391, /* (194) type_name ::= TINYINT */ + 391, /* (195) type_name ::= SMALLINT */ + 391, /* (196) type_name ::= INT */ + 391, /* (197) type_name ::= INTEGER */ + 391, /* (198) type_name ::= BIGINT */ + 391, /* (199) type_name ::= FLOAT */ + 391, /* (200) type_name ::= DOUBLE */ + 391, /* (201) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + 391, /* (202) type_name ::= TIMESTAMP */ + 391, /* (203) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + 391, /* (204) type_name ::= TINYINT UNSIGNED */ + 391, /* (205) type_name ::= SMALLINT UNSIGNED */ + 391, /* (206) type_name ::= INT UNSIGNED */ + 391, /* (207) type_name ::= BIGINT UNSIGNED */ + 391, /* (208) type_name ::= JSON */ + 391, /* (209) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + 391, /* (210) type_name ::= MEDIUMBLOB */ + 391, /* (211) type_name ::= BLOB */ + 391, /* (212) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + 391, /* (213) type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP */ + 391, /* (214) type_name ::= DECIMAL */ + 391, /* (215) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + 391, /* (216) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + 383, /* (217) tags_def_opt ::= */ + 383, /* (218) tags_def_opt ::= tags_def */ + 386, /* (219) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + 384, /* (220) table_options ::= */ + 384, /* (221) table_options ::= table_options COMMENT NK_STRING */ + 384, /* (222) table_options ::= table_options MAX_DELAY duration_list */ + 384, /* (223) table_options ::= table_options WATERMARK duration_list */ + 384, /* (224) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ + 384, /* (225) table_options ::= table_options TTL NK_INTEGER */ + 384, /* (226) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + 384, /* (227) table_options ::= table_options DELETE_MARK duration_list */ + 389, /* (228) alter_table_options ::= alter_table_option */ + 389, /* (229) alter_table_options ::= alter_table_options alter_table_option */ + 401, /* (230) alter_table_option ::= COMMENT NK_STRING */ + 401, /* (231) alter_table_option ::= TTL NK_INTEGER */ + 399, /* (232) duration_list ::= duration_literal */ + 399, /* (233) duration_list ::= duration_list NK_COMMA duration_literal */ + 400, /* (234) rollup_func_list ::= rollup_func_name */ + 400, /* (235) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ + 403, /* (236) rollup_func_name ::= function_name */ + 403, /* (237) rollup_func_name ::= FIRST */ + 403, /* (238) rollup_func_name ::= LAST */ + 397, /* (239) col_name_list ::= col_name */ + 397, /* (240) col_name_list ::= col_name_list NK_COMMA col_name */ + 405, /* (241) col_name ::= column_name */ + 346, /* (242) cmd ::= SHOW DNODES */ + 346, /* (243) cmd ::= SHOW USERS */ + 346, /* (244) cmd ::= SHOW USER PRIVILEGES */ + 346, /* (245) cmd ::= SHOW db_kind_opt DATABASES */ + 346, /* (246) cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt */ + 346, /* (247) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ + 346, /* (248) cmd ::= SHOW db_name_cond_opt VGROUPS */ + 346, /* (249) cmd ::= SHOW MNODES */ + 346, /* (250) cmd ::= SHOW QNODES */ + 346, /* (251) cmd ::= SHOW FUNCTIONS */ + 346, /* (252) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + 346, /* (253) cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name */ + 346, /* (254) cmd ::= SHOW STREAMS */ + 346, /* (255) cmd ::= SHOW ACCOUNTS */ + 346, /* (256) cmd ::= SHOW APPS */ + 346, /* (257) cmd ::= SHOW CONNECTIONS */ + 346, /* (258) cmd ::= SHOW LICENCES */ + 346, /* (259) cmd ::= SHOW GRANTS */ + 346, /* (260) cmd ::= SHOW CREATE DATABASE db_name */ + 346, /* (261) cmd ::= SHOW CREATE TABLE full_table_name */ + 346, /* (262) cmd ::= SHOW CREATE STABLE full_table_name */ + 346, /* (263) cmd ::= SHOW QUERIES */ + 346, /* (264) cmd ::= SHOW SCORES */ + 346, /* (265) cmd ::= SHOW TOPICS */ + 346, /* (266) cmd ::= SHOW VARIABLES */ + 346, /* (267) cmd ::= SHOW CLUSTER VARIABLES */ + 346, /* (268) cmd ::= SHOW LOCAL VARIABLES */ + 346, /* (269) cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ + 346, /* (270) cmd ::= SHOW BNODES */ + 346, /* (271) cmd ::= SHOW SNODES */ + 346, /* (272) cmd ::= SHOW CLUSTER */ + 346, /* (273) cmd ::= SHOW TRANSACTIONS */ + 346, /* (274) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ + 346, /* (275) cmd ::= SHOW CONSUMERS */ + 346, /* (276) cmd ::= SHOW SUBSCRIPTIONS */ + 346, /* (277) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ + 346, /* (278) cmd ::= SHOW TAGS FROM db_name NK_DOT table_name */ + 346, /* (279) cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ + 346, /* (280) cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name */ + 346, /* (281) cmd ::= SHOW VNODES ON DNODE NK_INTEGER */ + 346, /* (282) cmd ::= SHOW VNODES */ + 346, /* (283) cmd ::= SHOW db_name_cond_opt ALIVE */ + 346, /* (284) cmd ::= SHOW CLUSTER ALIVE */ + 346, /* (285) cmd ::= SHOW db_name_cond_opt VIEWS */ + 346, /* (286) cmd ::= SHOW CREATE VIEW full_table_name */ + 407, /* (287) table_kind_db_name_cond_opt ::= */ + 407, /* (288) table_kind_db_name_cond_opt ::= table_kind */ + 407, /* (289) table_kind_db_name_cond_opt ::= db_name NK_DOT */ + 407, /* (290) table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ + 413, /* (291) table_kind ::= NORMAL */ + 413, /* (292) table_kind ::= CHILD */ + 409, /* (293) db_name_cond_opt ::= */ + 409, /* (294) db_name_cond_opt ::= db_name NK_DOT */ + 408, /* (295) like_pattern_opt ::= */ + 408, /* (296) like_pattern_opt ::= LIKE NK_STRING */ + 410, /* (297) table_name_cond ::= table_name */ + 411, /* (298) from_db_opt ::= */ + 411, /* (299) from_db_opt ::= FROM db_name */ + 412, /* (300) tag_list_opt ::= */ + 412, /* (301) tag_list_opt ::= tag_item */ + 412, /* (302) tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ + 414, /* (303) tag_item ::= TBNAME */ + 414, /* (304) tag_item ::= QTAGS */ + 414, /* (305) tag_item ::= column_name */ + 414, /* (306) tag_item ::= column_name column_alias */ + 414, /* (307) tag_item ::= column_name AS column_alias */ + 406, /* (308) db_kind_opt ::= */ + 406, /* (309) db_kind_opt ::= USER */ + 406, /* (310) db_kind_opt ::= SYSTEM */ + 346, /* (311) cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ + 346, /* (312) cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ + 346, /* (313) cmd ::= DROP INDEX exists_opt full_index_name */ + 417, /* (314) full_index_name ::= index_name */ + 417, /* (315) full_index_name ::= db_name NK_DOT index_name */ + 416, /* (316) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ + 416, /* (317) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ + 419, /* (318) func_list ::= func */ + 419, /* (319) func_list ::= func_list NK_COMMA func */ + 422, /* (320) func ::= sma_func_name NK_LP expression_list NK_RP */ + 423, /* (321) sma_func_name ::= function_name */ + 423, /* (322) sma_func_name ::= COUNT */ + 423, /* (323) sma_func_name ::= FIRST */ + 423, /* (324) sma_func_name ::= LAST */ + 423, /* (325) sma_func_name ::= LAST_ROW */ + 421, /* (326) sma_stream_opt ::= */ + 421, /* (327) sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ + 421, /* (328) sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ + 421, /* (329) sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ + 424, /* (330) with_meta ::= AS */ + 424, /* (331) with_meta ::= WITH META AS */ + 424, /* (332) with_meta ::= ONLY META AS */ + 346, /* (333) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ + 346, /* (334) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ + 346, /* (335) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ + 346, /* (336) cmd ::= DROP TOPIC exists_opt topic_name */ + 346, /* (337) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ + 346, /* (338) cmd ::= DESC full_table_name */ + 346, /* (339) cmd ::= DESCRIBE full_table_name */ + 346, /* (340) cmd ::= RESET QUERY CACHE */ + 346, /* (341) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ + 346, /* (342) cmd ::= EXPLAIN analyze_opt explain_options insert_query */ + 428, /* (343) analyze_opt ::= */ + 428, /* (344) analyze_opt ::= ANALYZE */ + 429, /* (345) explain_options ::= */ + 429, /* (346) explain_options ::= explain_options VERBOSE NK_BOOL */ + 429, /* (347) explain_options ::= explain_options RATIO NK_FLOAT */ + 346, /* (348) cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ + 346, /* (349) cmd ::= DROP FUNCTION exists_opt function_name */ + 432, /* (350) agg_func_opt ::= */ + 432, /* (351) agg_func_opt ::= AGGREGATE */ + 433, /* (352) bufsize_opt ::= */ + 433, /* (353) bufsize_opt ::= BUFSIZE NK_INTEGER */ + 434, /* (354) language_opt ::= */ + 434, /* (355) language_opt ::= LANGUAGE NK_STRING */ + 431, /* (356) or_replace_opt ::= */ + 431, /* (357) or_replace_opt ::= OR REPLACE */ + 346, /* (358) cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ + 346, /* (359) cmd ::= DROP VIEW exists_opt full_view_name */ + 435, /* (360) full_view_name ::= view_name */ + 435, /* (361) full_view_name ::= db_name NK_DOT view_name */ + 346, /* (362) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery */ + 346, /* (363) cmd ::= DROP STREAM exists_opt stream_name */ + 346, /* (364) cmd ::= PAUSE STREAM exists_opt stream_name */ + 346, /* (365) cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ + 439, /* (366) col_list_opt ::= */ + 439, /* (367) col_list_opt ::= NK_LP col_name_list NK_RP */ + 440, /* (368) tag_def_or_ref_opt ::= */ + 440, /* (369) tag_def_or_ref_opt ::= tags_def */ + 440, /* (370) tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP */ + 438, /* (371) stream_options ::= */ + 438, /* (372) stream_options ::= stream_options TRIGGER AT_ONCE */ + 438, /* (373) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + 438, /* (374) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ + 438, /* (375) stream_options ::= stream_options WATERMARK duration_literal */ + 438, /* (376) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ + 438, /* (377) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ + 438, /* (378) stream_options ::= stream_options DELETE_MARK duration_literal */ + 438, /* (379) stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ + 441, /* (380) subtable_opt ::= */ + 441, /* (381) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + 442, /* (382) ignore_opt ::= */ + 442, /* (383) ignore_opt ::= IGNORE UNTREATED */ + 346, /* (384) cmd ::= KILL CONNECTION NK_INTEGER */ + 346, /* (385) cmd ::= KILL QUERY NK_STRING */ + 346, /* (386) cmd ::= KILL TRANSACTION NK_INTEGER */ + 346, /* (387) cmd ::= BALANCE VGROUP */ + 346, /* (388) cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ + 346, /* (389) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + 346, /* (390) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + 346, /* (391) cmd ::= SPLIT VGROUP NK_INTEGER */ + 444, /* (392) on_vgroup_id ::= */ + 444, /* (393) on_vgroup_id ::= ON NK_INTEGER */ + 445, /* (394) dnode_list ::= DNODE NK_INTEGER */ + 445, /* (395) dnode_list ::= dnode_list DNODE NK_INTEGER */ + 346, /* (396) cmd ::= DELETE FROM full_table_name where_clause_opt */ + 346, /* (397) cmd ::= query_or_subquery */ + 346, /* (398) cmd ::= insert_query */ + 430, /* (399) insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ + 430, /* (400) insert_query ::= INSERT INTO full_table_name query_or_subquery */ + 349, /* (401) literal ::= NK_INTEGER */ + 349, /* (402) literal ::= NK_FLOAT */ + 349, /* (403) literal ::= NK_STRING */ + 349, /* (404) literal ::= NK_BOOL */ + 349, /* (405) literal ::= TIMESTAMP NK_STRING */ + 349, /* (406) literal ::= duration_literal */ + 349, /* (407) literal ::= NULL */ + 349, /* (408) literal ::= NK_QUESTION */ + 402, /* (409) duration_literal ::= NK_VARIABLE */ + 378, /* (410) signed ::= NK_INTEGER */ + 378, /* (411) signed ::= NK_PLUS NK_INTEGER */ + 378, /* (412) signed ::= NK_MINUS NK_INTEGER */ + 378, /* (413) signed ::= NK_FLOAT */ + 378, /* (414) signed ::= NK_PLUS NK_FLOAT */ + 378, /* (415) signed ::= NK_MINUS NK_FLOAT */ + 392, /* (416) signed_literal ::= signed */ + 392, /* (417) signed_literal ::= NK_STRING */ + 392, /* (418) signed_literal ::= NK_BOOL */ + 392, /* (419) signed_literal ::= TIMESTAMP NK_STRING */ + 392, /* (420) signed_literal ::= duration_literal */ + 392, /* (421) signed_literal ::= NULL */ + 392, /* (422) signed_literal ::= literal_func */ + 392, /* (423) signed_literal ::= NK_QUESTION */ + 447, /* (424) literal_list ::= signed_literal */ + 447, /* (425) literal_list ::= literal_list NK_COMMA signed_literal */ + 361, /* (426) db_name ::= NK_ID */ + 362, /* (427) table_name ::= NK_ID */ + 390, /* (428) column_name ::= NK_ID */ + 404, /* (429) function_name ::= NK_ID */ + 436, /* (430) view_name ::= NK_ID */ + 448, /* (431) table_alias ::= NK_ID */ + 415, /* (432) column_alias ::= NK_ID */ + 415, /* (433) column_alias ::= NK_ALIAS */ + 354, /* (434) user_name ::= NK_ID */ + 363, /* (435) topic_name ::= NK_ID */ + 437, /* (436) stream_name ::= NK_ID */ + 427, /* (437) cgroup_name ::= NK_ID */ + 418, /* (438) index_name ::= NK_ID */ + 449, /* (439) expr_or_subquery ::= expression */ + 443, /* (440) expression ::= literal */ + 443, /* (441) expression ::= pseudo_column */ + 443, /* (442) expression ::= column_reference */ + 443, /* (443) expression ::= function_expression */ + 443, /* (444) expression ::= case_when_expression */ + 443, /* (445) expression ::= NK_LP expression NK_RP */ + 443, /* (446) expression ::= NK_PLUS expr_or_subquery */ + 443, /* (447) expression ::= NK_MINUS expr_or_subquery */ + 443, /* (448) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + 443, /* (449) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + 443, /* (450) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + 443, /* (451) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + 443, /* (452) expression ::= expr_or_subquery NK_REM expr_or_subquery */ + 443, /* (453) expression ::= column_reference NK_ARROW NK_STRING */ + 443, /* (454) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + 443, /* (455) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + 395, /* (456) expression_list ::= expr_or_subquery */ + 395, /* (457) expression_list ::= expression_list NK_COMMA expr_or_subquery */ + 451, /* (458) column_reference ::= column_name */ + 451, /* (459) column_reference ::= table_name NK_DOT column_name */ + 451, /* (460) column_reference ::= NK_ALIAS */ + 451, /* (461) column_reference ::= table_name NK_DOT NK_ALIAS */ + 450, /* (462) pseudo_column ::= ROWTS */ + 450, /* (463) pseudo_column ::= TBNAME */ + 450, /* (464) pseudo_column ::= table_name NK_DOT TBNAME */ + 450, /* (465) pseudo_column ::= QSTART */ + 450, /* (466) pseudo_column ::= QEND */ + 450, /* (467) pseudo_column ::= QDURATION */ + 450, /* (468) pseudo_column ::= WSTART */ + 450, /* (469) pseudo_column ::= WEND */ + 450, /* (470) pseudo_column ::= WDURATION */ + 450, /* (471) pseudo_column ::= IROWTS */ + 450, /* (472) pseudo_column ::= ISFILLED */ + 450, /* (473) pseudo_column ::= QTAGS */ + 452, /* (474) function_expression ::= function_name NK_LP expression_list NK_RP */ + 452, /* (475) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ + 452, /* (476) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ + 452, /* (477) function_expression ::= literal_func */ + 446, /* (478) literal_func ::= noarg_func NK_LP NK_RP */ + 446, /* (479) literal_func ::= NOW */ + 456, /* (480) noarg_func ::= NOW */ + 456, /* (481) noarg_func ::= TODAY */ + 456, /* (482) noarg_func ::= TIMEZONE */ + 456, /* (483) noarg_func ::= DATABASE */ + 456, /* (484) noarg_func ::= CLIENT_VERSION */ + 456, /* (485) noarg_func ::= SERVER_VERSION */ + 456, /* (486) noarg_func ::= SERVER_STATUS */ + 456, /* (487) noarg_func ::= CURRENT_USER */ + 456, /* (488) noarg_func ::= USER */ + 454, /* (489) star_func ::= COUNT */ + 454, /* (490) star_func ::= FIRST */ + 454, /* (491) star_func ::= LAST */ + 454, /* (492) star_func ::= LAST_ROW */ + 455, /* (493) star_func_para_list ::= NK_STAR */ + 455, /* (494) star_func_para_list ::= other_para_list */ + 457, /* (495) other_para_list ::= star_func_para */ + 457, /* (496) other_para_list ::= other_para_list NK_COMMA star_func_para */ + 458, /* (497) star_func_para ::= expr_or_subquery */ + 458, /* (498) star_func_para ::= table_name NK_DOT NK_STAR */ + 453, /* (499) case_when_expression ::= CASE when_then_list case_when_else_opt END */ + 453, /* (500) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ + 459, /* (501) when_then_list ::= when_then_expr */ + 459, /* (502) when_then_list ::= when_then_list when_then_expr */ + 462, /* (503) when_then_expr ::= WHEN common_expression THEN common_expression */ + 460, /* (504) case_when_else_opt ::= */ + 460, /* (505) case_when_else_opt ::= ELSE common_expression */ + 463, /* (506) predicate ::= expr_or_subquery compare_op expr_or_subquery */ + 463, /* (507) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + 463, /* (508) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + 463, /* (509) predicate ::= expr_or_subquery IS NULL */ + 463, /* (510) predicate ::= expr_or_subquery IS NOT NULL */ + 463, /* (511) predicate ::= expr_or_subquery in_op in_predicate_value */ + 464, /* (512) compare_op ::= NK_LT */ + 464, /* (513) compare_op ::= NK_GT */ + 464, /* (514) compare_op ::= NK_LE */ + 464, /* (515) compare_op ::= NK_GE */ + 464, /* (516) compare_op ::= NK_NE */ + 464, /* (517) compare_op ::= NK_EQ */ + 464, /* (518) compare_op ::= LIKE */ + 464, /* (519) compare_op ::= NOT LIKE */ + 464, /* (520) compare_op ::= MATCH */ + 464, /* (521) compare_op ::= NMATCH */ + 464, /* (522) compare_op ::= CONTAINS */ + 465, /* (523) in_op ::= IN */ + 465, /* (524) in_op ::= NOT IN */ + 466, /* (525) in_predicate_value ::= NK_LP literal_list NK_RP */ + 467, /* (526) boolean_value_expression ::= boolean_primary */ + 467, /* (527) boolean_value_expression ::= NOT boolean_primary */ + 467, /* (528) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + 467, /* (529) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + 468, /* (530) boolean_primary ::= predicate */ + 468, /* (531) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + 461, /* (532) common_expression ::= expr_or_subquery */ + 461, /* (533) common_expression ::= boolean_value_expression */ + 469, /* (534) from_clause_opt ::= */ + 469, /* (535) from_clause_opt ::= FROM table_reference_list */ + 470, /* (536) table_reference_list ::= table_reference */ + 470, /* (537) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + 471, /* (538) table_reference ::= table_primary */ + 471, /* (539) table_reference ::= joined_table */ + 472, /* (540) table_primary ::= table_name alias_opt */ + 472, /* (541) table_primary ::= db_name NK_DOT table_name alias_opt */ + 472, /* (542) table_primary ::= subquery alias_opt */ + 472, /* (543) table_primary ::= parenthesized_joined_table */ + 474, /* (544) alias_opt ::= */ + 474, /* (545) alias_opt ::= table_alias */ + 474, /* (546) alias_opt ::= AS table_alias */ + 476, /* (547) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + 476, /* (548) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + 473, /* (549) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + 477, /* (550) join_type ::= */ + 477, /* (551) join_type ::= INNER */ + 478, /* (552) query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + 479, /* (553) hint_list ::= */ + 479, /* (554) hint_list ::= NK_HINT */ + 481, /* (555) tag_mode_opt ::= */ + 481, /* (556) tag_mode_opt ::= TAGS */ + 480, /* (557) set_quantifier_opt ::= */ + 480, /* (558) set_quantifier_opt ::= DISTINCT */ + 480, /* (559) set_quantifier_opt ::= ALL */ + 482, /* (560) select_list ::= select_item */ + 482, /* (561) select_list ::= select_list NK_COMMA select_item */ + 490, /* (562) select_item ::= NK_STAR */ + 490, /* (563) select_item ::= common_expression */ + 490, /* (564) select_item ::= common_expression column_alias */ + 490, /* (565) select_item ::= common_expression AS column_alias */ + 490, /* (566) select_item ::= table_name NK_DOT NK_STAR */ + 426, /* (567) where_clause_opt ::= */ + 426, /* (568) where_clause_opt ::= WHERE search_condition */ + 483, /* (569) partition_by_clause_opt ::= */ + 483, /* (570) partition_by_clause_opt ::= PARTITION BY partition_list */ + 491, /* (571) partition_list ::= partition_item */ + 491, /* (572) partition_list ::= partition_list NK_COMMA partition_item */ + 492, /* (573) partition_item ::= expr_or_subquery */ + 492, /* (574) partition_item ::= expr_or_subquery column_alias */ + 492, /* (575) partition_item ::= expr_or_subquery AS column_alias */ + 487, /* (576) twindow_clause_opt ::= */ + 487, /* (577) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ + 487, /* (578) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ + 487, /* (579) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ + 487, /* (580) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ + 487, /* (581) twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ + 420, /* (582) sliding_opt ::= */ + 420, /* (583) sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ + 493, /* (584) interval_sliding_duration_literal ::= NK_VARIABLE */ + 493, /* (585) interval_sliding_duration_literal ::= NK_STRING */ + 493, /* (586) interval_sliding_duration_literal ::= NK_INTEGER */ + 486, /* (587) fill_opt ::= */ + 486, /* (588) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + 486, /* (589) fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ + 486, /* (590) fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ + 494, /* (591) fill_mode ::= NONE */ + 494, /* (592) fill_mode ::= PREV */ + 494, /* (593) fill_mode ::= NULL */ + 494, /* (594) fill_mode ::= NULL_F */ + 494, /* (595) fill_mode ::= LINEAR */ + 494, /* (596) fill_mode ::= NEXT */ + 488, /* (597) group_by_clause_opt ::= */ + 488, /* (598) group_by_clause_opt ::= GROUP BY group_by_list */ + 495, /* (599) group_by_list ::= expr_or_subquery */ + 495, /* (600) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ + 489, /* (601) having_clause_opt ::= */ + 489, /* (602) having_clause_opt ::= HAVING search_condition */ + 484, /* (603) range_opt ::= */ + 484, /* (604) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ + 484, /* (605) range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ + 485, /* (606) every_opt ::= */ + 485, /* (607) every_opt ::= EVERY NK_LP duration_literal NK_RP */ + 496, /* (608) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + 497, /* (609) query_simple ::= query_specification */ + 497, /* (610) query_simple ::= union_query_expression */ + 501, /* (611) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ + 501, /* (612) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ + 502, /* (613) query_simple_or_subquery ::= query_simple */ + 502, /* (614) query_simple_or_subquery ::= subquery */ + 425, /* (615) query_or_subquery ::= query_expression */ + 425, /* (616) query_or_subquery ::= subquery */ + 498, /* (617) order_by_clause_opt ::= */ + 498, /* (618) order_by_clause_opt ::= ORDER BY sort_specification_list */ + 499, /* (619) slimit_clause_opt ::= */ + 499, /* (620) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + 499, /* (621) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + 499, /* (622) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + 500, /* (623) limit_clause_opt ::= */ + 500, /* (624) limit_clause_opt ::= LIMIT NK_INTEGER */ + 500, /* (625) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + 500, /* (626) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + 475, /* (627) subquery ::= NK_LP query_expression NK_RP */ + 475, /* (628) subquery ::= NK_LP subquery NK_RP */ + 364, /* (629) search_condition ::= common_expression */ + 503, /* (630) sort_specification_list ::= sort_specification */ + 503, /* (631) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + 504, /* (632) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ + 505, /* (633) ordering_specification_opt ::= */ + 505, /* (634) ordering_specification_opt ::= ASC */ + 505, /* (635) ordering_specification_opt ::= DESC */ + 506, /* (636) null_ordering_opt ::= */ + 506, /* (637) null_ordering_opt ::= NULLS FIRST */ + 506, /* (638) null_ordering_opt ::= NULLS LAST */ }; /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number @@ -4116,590 +4046,598 @@ static const signed char yyRuleInfoNRhs[] = { -3, /* (44) priv_type_list ::= priv_type_list NK_COMMA priv_type */ -1, /* (45) priv_type ::= READ */ -1, /* (46) priv_type ::= WRITE */ - -3, /* (47) priv_level ::= NK_STAR NK_DOT NK_STAR */ - -3, /* (48) priv_level ::= db_name NK_DOT NK_STAR */ - -3, /* (49) priv_level ::= db_name NK_DOT table_name */ - -1, /* (50) priv_level ::= topic_name */ - 0, /* (51) with_opt ::= */ - -2, /* (52) with_opt ::= WITH search_condition */ - -3, /* (53) cmd ::= CREATE DNODE dnode_endpoint */ - -5, /* (54) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ - -4, /* (55) cmd ::= DROP DNODE NK_INTEGER force_opt */ - -4, /* (56) cmd ::= DROP DNODE dnode_endpoint force_opt */ - -4, /* (57) cmd ::= DROP DNODE NK_INTEGER unsafe_opt */ - -4, /* (58) cmd ::= DROP DNODE dnode_endpoint unsafe_opt */ - -4, /* (59) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ - -5, /* (60) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ - -4, /* (61) cmd ::= ALTER ALL DNODES NK_STRING */ - -5, /* (62) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ - -3, /* (63) cmd ::= RESTORE DNODE NK_INTEGER */ - -1, /* (64) dnode_endpoint ::= NK_STRING */ - -1, /* (65) dnode_endpoint ::= NK_ID */ - -1, /* (66) dnode_endpoint ::= NK_IPTOKEN */ - 0, /* (67) force_opt ::= */ - -1, /* (68) force_opt ::= FORCE */ - -1, /* (69) unsafe_opt ::= UNSAFE */ - -3, /* (70) cmd ::= ALTER LOCAL NK_STRING */ - -4, /* (71) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ - -5, /* (72) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ - -5, /* (73) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ - -5, /* (74) cmd ::= RESTORE QNODE ON DNODE NK_INTEGER */ - -5, /* (75) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ - -5, /* (76) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ - -5, /* (77) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ - -5, /* (78) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ - -5, /* (79) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ - -5, /* (80) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ - -5, /* (81) cmd ::= RESTORE MNODE ON DNODE NK_INTEGER */ - -5, /* (82) cmd ::= RESTORE VNODE ON DNODE NK_INTEGER */ - -5, /* (83) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - -4, /* (84) cmd ::= DROP DATABASE exists_opt db_name */ - -2, /* (85) cmd ::= USE db_name */ - -4, /* (86) cmd ::= ALTER DATABASE db_name alter_db_options */ - -3, /* (87) cmd ::= FLUSH DATABASE db_name */ - -4, /* (88) cmd ::= TRIM DATABASE db_name speed_opt */ - -5, /* (89) cmd ::= COMPACT DATABASE db_name start_opt end_opt */ - -3, /* (90) not_exists_opt ::= IF NOT EXISTS */ - 0, /* (91) not_exists_opt ::= */ - -2, /* (92) exists_opt ::= IF EXISTS */ - 0, /* (93) exists_opt ::= */ - 0, /* (94) db_options ::= */ - -3, /* (95) db_options ::= db_options BUFFER NK_INTEGER */ - -3, /* (96) db_options ::= db_options CACHEMODEL NK_STRING */ - -3, /* (97) db_options ::= db_options CACHESIZE NK_INTEGER */ - -3, /* (98) db_options ::= db_options COMP NK_INTEGER */ - -3, /* (99) db_options ::= db_options DURATION NK_INTEGER */ - -3, /* (100) db_options ::= db_options DURATION NK_VARIABLE */ - -3, /* (101) db_options ::= db_options MAXROWS NK_INTEGER */ - -3, /* (102) db_options ::= db_options MINROWS NK_INTEGER */ - -3, /* (103) db_options ::= db_options KEEP integer_list */ - -3, /* (104) db_options ::= db_options KEEP variable_list */ - -3, /* (105) db_options ::= db_options PAGES NK_INTEGER */ - -3, /* (106) db_options ::= db_options PAGESIZE NK_INTEGER */ - -3, /* (107) db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ - -3, /* (108) db_options ::= db_options PRECISION NK_STRING */ - -3, /* (109) db_options ::= db_options REPLICA NK_INTEGER */ - -3, /* (110) db_options ::= db_options VGROUPS NK_INTEGER */ - -3, /* (111) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - -3, /* (112) db_options ::= db_options RETENTIONS retention_list */ - -3, /* (113) db_options ::= db_options SCHEMALESS NK_INTEGER */ - -3, /* (114) db_options ::= db_options WAL_LEVEL NK_INTEGER */ - -3, /* (115) db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ - -3, /* (116) db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ - -4, /* (117) db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ - -3, /* (118) db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ - -4, /* (119) db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ - -3, /* (120) db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ - -3, /* (121) db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ - -3, /* (122) db_options ::= db_options STT_TRIGGER NK_INTEGER */ - -3, /* (123) db_options ::= db_options TABLE_PREFIX signed */ - -3, /* (124) db_options ::= db_options TABLE_SUFFIX signed */ - -3, /* (125) db_options ::= db_options KEEP_TIME_OFFSET NK_INTEGER */ - -1, /* (126) alter_db_options ::= alter_db_option */ - -2, /* (127) alter_db_options ::= alter_db_options alter_db_option */ - -2, /* (128) alter_db_option ::= BUFFER NK_INTEGER */ - -2, /* (129) alter_db_option ::= CACHEMODEL NK_STRING */ - -2, /* (130) alter_db_option ::= CACHESIZE NK_INTEGER */ - -2, /* (131) alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ - -2, /* (132) alter_db_option ::= KEEP integer_list */ - -2, /* (133) alter_db_option ::= KEEP variable_list */ - -2, /* (134) alter_db_option ::= PAGES NK_INTEGER */ - -2, /* (135) alter_db_option ::= REPLICA NK_INTEGER */ - -2, /* (136) alter_db_option ::= WAL_LEVEL NK_INTEGER */ - -2, /* (137) alter_db_option ::= STT_TRIGGER NK_INTEGER */ - -2, /* (138) alter_db_option ::= MINROWS NK_INTEGER */ - -2, /* (139) alter_db_option ::= WAL_RETENTION_PERIOD NK_INTEGER */ - -3, /* (140) alter_db_option ::= WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ - -2, /* (141) alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER */ - -3, /* (142) alter_db_option ::= WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ - -2, /* (143) alter_db_option ::= KEEP_TIME_OFFSET NK_INTEGER */ - -1, /* (144) integer_list ::= NK_INTEGER */ - -3, /* (145) integer_list ::= integer_list NK_COMMA NK_INTEGER */ - -1, /* (146) variable_list ::= NK_VARIABLE */ - -3, /* (147) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ - -1, /* (148) retention_list ::= retention */ - -3, /* (149) retention_list ::= retention_list NK_COMMA retention */ - -3, /* (150) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ - -3, /* (151) retention ::= NK_MINUS NK_COLON NK_VARIABLE */ - 0, /* (152) speed_opt ::= */ - -2, /* (153) speed_opt ::= BWLIMIT NK_INTEGER */ - 0, /* (154) start_opt ::= */ - -3, /* (155) start_opt ::= START WITH NK_INTEGER */ - -3, /* (156) start_opt ::= START WITH NK_STRING */ - -4, /* (157) start_opt ::= START WITH TIMESTAMP NK_STRING */ - 0, /* (158) end_opt ::= */ - -3, /* (159) end_opt ::= END WITH NK_INTEGER */ - -3, /* (160) end_opt ::= END WITH NK_STRING */ - -4, /* (161) end_opt ::= END WITH TIMESTAMP NK_STRING */ - -9, /* (162) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - -3, /* (163) cmd ::= CREATE TABLE multi_create_clause */ - -9, /* (164) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - -3, /* (165) cmd ::= DROP TABLE multi_drop_clause */ - -4, /* (166) cmd ::= DROP STABLE exists_opt full_table_name */ - -3, /* (167) cmd ::= ALTER TABLE alter_table_clause */ - -3, /* (168) cmd ::= ALTER STABLE alter_table_clause */ - -2, /* (169) alter_table_clause ::= full_table_name alter_table_options */ - -5, /* (170) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ - -4, /* (171) alter_table_clause ::= full_table_name DROP COLUMN column_name */ - -5, /* (172) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ - -5, /* (173) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ - -5, /* (174) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ - -4, /* (175) alter_table_clause ::= full_table_name DROP TAG column_name */ - -5, /* (176) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ - -5, /* (177) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ - -6, /* (178) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ - -1, /* (179) multi_create_clause ::= create_subtable_clause */ - -2, /* (180) multi_create_clause ::= multi_create_clause create_subtable_clause */ - -10, /* (181) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */ - -1, /* (182) multi_drop_clause ::= drop_table_clause */ - -3, /* (183) multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause */ - -2, /* (184) drop_table_clause ::= exists_opt full_table_name */ - 0, /* (185) specific_cols_opt ::= */ - -3, /* (186) specific_cols_opt ::= NK_LP col_name_list NK_RP */ - -1, /* (187) full_table_name ::= table_name */ - -3, /* (188) full_table_name ::= db_name NK_DOT table_name */ - -1, /* (189) column_def_list ::= column_def */ - -3, /* (190) column_def_list ::= column_def_list NK_COMMA column_def */ - -2, /* (191) column_def ::= column_name type_name */ - -1, /* (192) type_name ::= BOOL */ - -1, /* (193) type_name ::= TINYINT */ - -1, /* (194) type_name ::= SMALLINT */ - -1, /* (195) type_name ::= INT */ - -1, /* (196) type_name ::= INTEGER */ - -1, /* (197) type_name ::= BIGINT */ - -1, /* (198) type_name ::= FLOAT */ - -1, /* (199) type_name ::= DOUBLE */ - -4, /* (200) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - -1, /* (201) type_name ::= TIMESTAMP */ - -4, /* (202) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - -2, /* (203) type_name ::= TINYINT UNSIGNED */ - -2, /* (204) type_name ::= SMALLINT UNSIGNED */ - -2, /* (205) type_name ::= INT UNSIGNED */ - -2, /* (206) type_name ::= BIGINT UNSIGNED */ - -1, /* (207) type_name ::= JSON */ - -4, /* (208) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - -1, /* (209) type_name ::= MEDIUMBLOB */ - -1, /* (210) type_name ::= BLOB */ - -4, /* (211) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - -4, /* (212) type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP */ - -1, /* (213) type_name ::= DECIMAL */ - -4, /* (214) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - -6, /* (215) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - 0, /* (216) tags_def_opt ::= */ - -1, /* (217) tags_def_opt ::= tags_def */ - -4, /* (218) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - 0, /* (219) table_options ::= */ - -3, /* (220) table_options ::= table_options COMMENT NK_STRING */ - -3, /* (221) table_options ::= table_options MAX_DELAY duration_list */ - -3, /* (222) table_options ::= table_options WATERMARK duration_list */ - -5, /* (223) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ - -3, /* (224) table_options ::= table_options TTL NK_INTEGER */ - -5, /* (225) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - -3, /* (226) table_options ::= table_options DELETE_MARK duration_list */ - -1, /* (227) alter_table_options ::= alter_table_option */ - -2, /* (228) alter_table_options ::= alter_table_options alter_table_option */ - -2, /* (229) alter_table_option ::= COMMENT NK_STRING */ - -2, /* (230) alter_table_option ::= TTL NK_INTEGER */ - -1, /* (231) duration_list ::= duration_literal */ - -3, /* (232) duration_list ::= duration_list NK_COMMA duration_literal */ - -1, /* (233) rollup_func_list ::= rollup_func_name */ - -3, /* (234) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ - -1, /* (235) rollup_func_name ::= function_name */ - -1, /* (236) rollup_func_name ::= FIRST */ - -1, /* (237) rollup_func_name ::= LAST */ - -1, /* (238) col_name_list ::= col_name */ - -3, /* (239) col_name_list ::= col_name_list NK_COMMA col_name */ - -1, /* (240) col_name ::= column_name */ - -2, /* (241) cmd ::= SHOW DNODES */ - -2, /* (242) cmd ::= SHOW USERS */ - -3, /* (243) cmd ::= SHOW USER PRIVILEGES */ - -3, /* (244) cmd ::= SHOW db_kind_opt DATABASES */ - -4, /* (245) cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt */ - -4, /* (246) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ - -3, /* (247) cmd ::= SHOW db_name_cond_opt VGROUPS */ - -2, /* (248) cmd ::= SHOW MNODES */ - -2, /* (249) cmd ::= SHOW QNODES */ - -2, /* (250) cmd ::= SHOW FUNCTIONS */ - -5, /* (251) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ - -6, /* (252) cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name */ - -2, /* (253) cmd ::= SHOW STREAMS */ - -2, /* (254) cmd ::= SHOW ACCOUNTS */ - -2, /* (255) cmd ::= SHOW APPS */ - -2, /* (256) cmd ::= SHOW CONNECTIONS */ - -2, /* (257) cmd ::= SHOW LICENCES */ - -2, /* (258) cmd ::= SHOW GRANTS */ - -4, /* (259) cmd ::= SHOW CREATE DATABASE db_name */ - -4, /* (260) cmd ::= SHOW CREATE TABLE full_table_name */ - -4, /* (261) cmd ::= SHOW CREATE STABLE full_table_name */ - -2, /* (262) cmd ::= SHOW QUERIES */ - -2, /* (263) cmd ::= SHOW SCORES */ - -2, /* (264) cmd ::= SHOW TOPICS */ - -2, /* (265) cmd ::= SHOW VARIABLES */ - -3, /* (266) cmd ::= SHOW CLUSTER VARIABLES */ - -3, /* (267) cmd ::= SHOW LOCAL VARIABLES */ - -5, /* (268) cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ - -2, /* (269) cmd ::= SHOW BNODES */ - -2, /* (270) cmd ::= SHOW SNODES */ - -2, /* (271) cmd ::= SHOW CLUSTER */ - -2, /* (272) cmd ::= SHOW TRANSACTIONS */ - -4, /* (273) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ - -2, /* (274) cmd ::= SHOW CONSUMERS */ - -2, /* (275) cmd ::= SHOW SUBSCRIPTIONS */ - -5, /* (276) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ - -6, /* (277) cmd ::= SHOW TAGS FROM db_name NK_DOT table_name */ - -7, /* (278) cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ - -8, /* (279) cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name */ - -5, /* (280) cmd ::= SHOW VNODES ON DNODE NK_INTEGER */ - -2, /* (281) cmd ::= SHOW VNODES */ - -3, /* (282) cmd ::= SHOW db_name_cond_opt ALIVE */ - -3, /* (283) cmd ::= SHOW CLUSTER ALIVE */ - 0, /* (284) table_kind_db_name_cond_opt ::= */ - -1, /* (285) table_kind_db_name_cond_opt ::= table_kind */ - -2, /* (286) table_kind_db_name_cond_opt ::= db_name NK_DOT */ - -3, /* (287) table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ - -1, /* (288) table_kind ::= NORMAL */ - -1, /* (289) table_kind ::= CHILD */ - 0, /* (290) db_name_cond_opt ::= */ - -2, /* (291) db_name_cond_opt ::= db_name NK_DOT */ - 0, /* (292) like_pattern_opt ::= */ - -2, /* (293) like_pattern_opt ::= LIKE NK_STRING */ - -1, /* (294) table_name_cond ::= table_name */ - 0, /* (295) from_db_opt ::= */ - -2, /* (296) from_db_opt ::= FROM db_name */ - 0, /* (297) tag_list_opt ::= */ - -1, /* (298) tag_list_opt ::= tag_item */ - -3, /* (299) tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ - -1, /* (300) tag_item ::= TBNAME */ - -1, /* (301) tag_item ::= QTAGS */ - -1, /* (302) tag_item ::= column_name */ - -2, /* (303) tag_item ::= column_name column_alias */ - -3, /* (304) tag_item ::= column_name AS column_alias */ - 0, /* (305) db_kind_opt ::= */ - -1, /* (306) db_kind_opt ::= USER */ - -1, /* (307) db_kind_opt ::= SYSTEM */ - -8, /* (308) cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ - -9, /* (309) cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ - -4, /* (310) cmd ::= DROP INDEX exists_opt full_index_name */ - -1, /* (311) full_index_name ::= index_name */ - -3, /* (312) full_index_name ::= db_name NK_DOT index_name */ - -10, /* (313) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ - -12, /* (314) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ - -1, /* (315) func_list ::= func */ - -3, /* (316) func_list ::= func_list NK_COMMA func */ - -4, /* (317) func ::= sma_func_name NK_LP expression_list NK_RP */ - -1, /* (318) sma_func_name ::= function_name */ - -1, /* (319) sma_func_name ::= COUNT */ - -1, /* (320) sma_func_name ::= FIRST */ - -1, /* (321) sma_func_name ::= LAST */ - -1, /* (322) sma_func_name ::= LAST_ROW */ - 0, /* (323) sma_stream_opt ::= */ - -3, /* (324) sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ - -3, /* (325) sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ - -3, /* (326) sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ - -1, /* (327) with_meta ::= AS */ - -3, /* (328) with_meta ::= WITH META AS */ - -3, /* (329) with_meta ::= ONLY META AS */ - -6, /* (330) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ - -7, /* (331) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ - -8, /* (332) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ - -4, /* (333) cmd ::= DROP TOPIC exists_opt topic_name */ - -7, /* (334) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ - -2, /* (335) cmd ::= DESC full_table_name */ - -2, /* (336) cmd ::= DESCRIBE full_table_name */ - -3, /* (337) cmd ::= RESET QUERY CACHE */ - -4, /* (338) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ - -4, /* (339) cmd ::= EXPLAIN analyze_opt explain_options insert_query */ - 0, /* (340) analyze_opt ::= */ - -1, /* (341) analyze_opt ::= ANALYZE */ - 0, /* (342) explain_options ::= */ - -3, /* (343) explain_options ::= explain_options VERBOSE NK_BOOL */ - -3, /* (344) explain_options ::= explain_options RATIO NK_FLOAT */ - -12, /* (345) cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ - -4, /* (346) cmd ::= DROP FUNCTION exists_opt function_name */ - 0, /* (347) agg_func_opt ::= */ - -1, /* (348) agg_func_opt ::= AGGREGATE */ - 0, /* (349) bufsize_opt ::= */ - -2, /* (350) bufsize_opt ::= BUFSIZE NK_INTEGER */ - 0, /* (351) language_opt ::= */ - -2, /* (352) language_opt ::= LANGUAGE NK_STRING */ - 0, /* (353) or_replace_opt ::= */ - -2, /* (354) or_replace_opt ::= OR REPLACE */ - -12, /* (355) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery */ - -4, /* (356) cmd ::= DROP STREAM exists_opt stream_name */ - -4, /* (357) cmd ::= PAUSE STREAM exists_opt stream_name */ - -5, /* (358) cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ - 0, /* (359) col_list_opt ::= */ - -3, /* (360) col_list_opt ::= NK_LP col_name_list NK_RP */ - 0, /* (361) tag_def_or_ref_opt ::= */ - -1, /* (362) tag_def_or_ref_opt ::= tags_def */ - -4, /* (363) tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP */ - 0, /* (364) stream_options ::= */ - -3, /* (365) stream_options ::= stream_options TRIGGER AT_ONCE */ - -3, /* (366) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ - -4, /* (367) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ - -3, /* (368) stream_options ::= stream_options WATERMARK duration_literal */ - -4, /* (369) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ - -3, /* (370) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ - -3, /* (371) stream_options ::= stream_options DELETE_MARK duration_literal */ - -4, /* (372) stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ - 0, /* (373) subtable_opt ::= */ - -4, /* (374) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - 0, /* (375) ignore_opt ::= */ - -2, /* (376) ignore_opt ::= IGNORE UNTREATED */ - -3, /* (377) cmd ::= KILL CONNECTION NK_INTEGER */ - -3, /* (378) cmd ::= KILL QUERY NK_STRING */ - -3, /* (379) cmd ::= KILL TRANSACTION NK_INTEGER */ - -2, /* (380) cmd ::= BALANCE VGROUP */ - -4, /* (381) cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ - -4, /* (382) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - -4, /* (383) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - -3, /* (384) cmd ::= SPLIT VGROUP NK_INTEGER */ - 0, /* (385) on_vgroup_id ::= */ - -2, /* (386) on_vgroup_id ::= ON NK_INTEGER */ - -2, /* (387) dnode_list ::= DNODE NK_INTEGER */ - -3, /* (388) dnode_list ::= dnode_list DNODE NK_INTEGER */ - -4, /* (389) cmd ::= DELETE FROM full_table_name where_clause_opt */ - -1, /* (390) cmd ::= query_or_subquery */ - -1, /* (391) cmd ::= insert_query */ - -7, /* (392) insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ - -4, /* (393) insert_query ::= INSERT INTO full_table_name query_or_subquery */ - -1, /* (394) literal ::= NK_INTEGER */ - -1, /* (395) literal ::= NK_FLOAT */ - -1, /* (396) literal ::= NK_STRING */ - -1, /* (397) literal ::= NK_BOOL */ - -2, /* (398) literal ::= TIMESTAMP NK_STRING */ - -1, /* (399) literal ::= duration_literal */ - -1, /* (400) literal ::= NULL */ - -1, /* (401) literal ::= NK_QUESTION */ - -1, /* (402) duration_literal ::= NK_VARIABLE */ - -1, /* (403) signed ::= NK_INTEGER */ - -2, /* (404) signed ::= NK_PLUS NK_INTEGER */ - -2, /* (405) signed ::= NK_MINUS NK_INTEGER */ - -1, /* (406) signed ::= NK_FLOAT */ - -2, /* (407) signed ::= NK_PLUS NK_FLOAT */ - -2, /* (408) signed ::= NK_MINUS NK_FLOAT */ - -1, /* (409) signed_literal ::= signed */ - -1, /* (410) signed_literal ::= NK_STRING */ - -1, /* (411) signed_literal ::= NK_BOOL */ - -2, /* (412) signed_literal ::= TIMESTAMP NK_STRING */ - -1, /* (413) signed_literal ::= duration_literal */ - -1, /* (414) signed_literal ::= NULL */ - -1, /* (415) signed_literal ::= literal_func */ - -1, /* (416) signed_literal ::= NK_QUESTION */ - -1, /* (417) literal_list ::= signed_literal */ - -3, /* (418) literal_list ::= literal_list NK_COMMA signed_literal */ - -1, /* (419) db_name ::= NK_ID */ - -1, /* (420) table_name ::= NK_ID */ - -1, /* (421) column_name ::= NK_ID */ - -1, /* (422) function_name ::= NK_ID */ - -1, /* (423) table_alias ::= NK_ID */ - -1, /* (424) column_alias ::= NK_ID */ - -1, /* (425) column_alias ::= NK_ALIAS */ - -1, /* (426) user_name ::= NK_ID */ - -1, /* (427) topic_name ::= NK_ID */ - -1, /* (428) stream_name ::= NK_ID */ - -1, /* (429) cgroup_name ::= NK_ID */ - -1, /* (430) index_name ::= NK_ID */ - -1, /* (431) expr_or_subquery ::= expression */ - -1, /* (432) expression ::= literal */ - -1, /* (433) expression ::= pseudo_column */ - -1, /* (434) expression ::= column_reference */ - -1, /* (435) expression ::= function_expression */ - -1, /* (436) expression ::= case_when_expression */ - -3, /* (437) expression ::= NK_LP expression NK_RP */ - -2, /* (438) expression ::= NK_PLUS expr_or_subquery */ - -2, /* (439) expression ::= NK_MINUS expr_or_subquery */ - -3, /* (440) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ - -3, /* (441) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ - -3, /* (442) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ - -3, /* (443) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ - -3, /* (444) expression ::= expr_or_subquery NK_REM expr_or_subquery */ - -3, /* (445) expression ::= column_reference NK_ARROW NK_STRING */ - -3, /* (446) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ - -3, /* (447) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ - -1, /* (448) expression_list ::= expr_or_subquery */ - -3, /* (449) expression_list ::= expression_list NK_COMMA expr_or_subquery */ - -1, /* (450) column_reference ::= column_name */ - -3, /* (451) column_reference ::= table_name NK_DOT column_name */ - -1, /* (452) column_reference ::= NK_ALIAS */ - -3, /* (453) column_reference ::= table_name NK_DOT NK_ALIAS */ - -1, /* (454) pseudo_column ::= ROWTS */ - -1, /* (455) pseudo_column ::= TBNAME */ - -3, /* (456) pseudo_column ::= table_name NK_DOT TBNAME */ - -1, /* (457) pseudo_column ::= QSTART */ - -1, /* (458) pseudo_column ::= QEND */ - -1, /* (459) pseudo_column ::= QDURATION */ - -1, /* (460) pseudo_column ::= WSTART */ - -1, /* (461) pseudo_column ::= WEND */ - -1, /* (462) pseudo_column ::= WDURATION */ - -1, /* (463) pseudo_column ::= IROWTS */ - -1, /* (464) pseudo_column ::= ISFILLED */ - -1, /* (465) pseudo_column ::= QTAGS */ - -4, /* (466) function_expression ::= function_name NK_LP expression_list NK_RP */ - -4, /* (467) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ - -6, /* (468) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ - -1, /* (469) function_expression ::= literal_func */ - -3, /* (470) literal_func ::= noarg_func NK_LP NK_RP */ - -1, /* (471) literal_func ::= NOW */ - -1, /* (472) noarg_func ::= NOW */ - -1, /* (473) noarg_func ::= TODAY */ - -1, /* (474) noarg_func ::= TIMEZONE */ - -1, /* (475) noarg_func ::= DATABASE */ - -1, /* (476) noarg_func ::= CLIENT_VERSION */ - -1, /* (477) noarg_func ::= SERVER_VERSION */ - -1, /* (478) noarg_func ::= SERVER_STATUS */ - -1, /* (479) noarg_func ::= CURRENT_USER */ - -1, /* (480) noarg_func ::= USER */ - -1, /* (481) star_func ::= COUNT */ - -1, /* (482) star_func ::= FIRST */ - -1, /* (483) star_func ::= LAST */ - -1, /* (484) star_func ::= LAST_ROW */ - -1, /* (485) star_func_para_list ::= NK_STAR */ - -1, /* (486) star_func_para_list ::= other_para_list */ - -1, /* (487) other_para_list ::= star_func_para */ - -3, /* (488) other_para_list ::= other_para_list NK_COMMA star_func_para */ - -1, /* (489) star_func_para ::= expr_or_subquery */ - -3, /* (490) star_func_para ::= table_name NK_DOT NK_STAR */ - -4, /* (491) case_when_expression ::= CASE when_then_list case_when_else_opt END */ - -5, /* (492) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ - -1, /* (493) when_then_list ::= when_then_expr */ - -2, /* (494) when_then_list ::= when_then_list when_then_expr */ - -4, /* (495) when_then_expr ::= WHEN common_expression THEN common_expression */ - 0, /* (496) case_when_else_opt ::= */ - -2, /* (497) case_when_else_opt ::= ELSE common_expression */ - -3, /* (498) predicate ::= expr_or_subquery compare_op expr_or_subquery */ - -5, /* (499) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ - -6, /* (500) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ - -3, /* (501) predicate ::= expr_or_subquery IS NULL */ - -4, /* (502) predicate ::= expr_or_subquery IS NOT NULL */ - -3, /* (503) predicate ::= expr_or_subquery in_op in_predicate_value */ - -1, /* (504) compare_op ::= NK_LT */ - -1, /* (505) compare_op ::= NK_GT */ - -1, /* (506) compare_op ::= NK_LE */ - -1, /* (507) compare_op ::= NK_GE */ - -1, /* (508) compare_op ::= NK_NE */ - -1, /* (509) compare_op ::= NK_EQ */ - -1, /* (510) compare_op ::= LIKE */ - -2, /* (511) compare_op ::= NOT LIKE */ - -1, /* (512) compare_op ::= MATCH */ - -1, /* (513) compare_op ::= NMATCH */ - -1, /* (514) compare_op ::= CONTAINS */ - -1, /* (515) in_op ::= IN */ - -2, /* (516) in_op ::= NOT IN */ - -3, /* (517) in_predicate_value ::= NK_LP literal_list NK_RP */ - -1, /* (518) boolean_value_expression ::= boolean_primary */ - -2, /* (519) boolean_value_expression ::= NOT boolean_primary */ - -3, /* (520) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - -3, /* (521) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - -1, /* (522) boolean_primary ::= predicate */ - -3, /* (523) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - -1, /* (524) common_expression ::= expr_or_subquery */ - -1, /* (525) common_expression ::= boolean_value_expression */ - 0, /* (526) from_clause_opt ::= */ - -2, /* (527) from_clause_opt ::= FROM table_reference_list */ - -1, /* (528) table_reference_list ::= table_reference */ - -3, /* (529) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - -1, /* (530) table_reference ::= table_primary */ - -1, /* (531) table_reference ::= joined_table */ - -2, /* (532) table_primary ::= table_name alias_opt */ - -4, /* (533) table_primary ::= db_name NK_DOT table_name alias_opt */ - -2, /* (534) table_primary ::= subquery alias_opt */ - -1, /* (535) table_primary ::= parenthesized_joined_table */ - 0, /* (536) alias_opt ::= */ - -1, /* (537) alias_opt ::= table_alias */ - -2, /* (538) alias_opt ::= AS table_alias */ - -3, /* (539) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - -3, /* (540) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - -6, /* (541) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - 0, /* (542) join_type ::= */ - -1, /* (543) join_type ::= INNER */ - -14, /* (544) query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ - 0, /* (545) hint_list ::= */ - -1, /* (546) hint_list ::= NK_HINT */ - 0, /* (547) tag_mode_opt ::= */ - -1, /* (548) tag_mode_opt ::= TAGS */ - 0, /* (549) set_quantifier_opt ::= */ - -1, /* (550) set_quantifier_opt ::= DISTINCT */ - -1, /* (551) set_quantifier_opt ::= ALL */ - -1, /* (552) select_list ::= select_item */ - -3, /* (553) select_list ::= select_list NK_COMMA select_item */ - -1, /* (554) select_item ::= NK_STAR */ - -1, /* (555) select_item ::= common_expression */ - -2, /* (556) select_item ::= common_expression column_alias */ - -3, /* (557) select_item ::= common_expression AS column_alias */ - -3, /* (558) select_item ::= table_name NK_DOT NK_STAR */ - 0, /* (559) where_clause_opt ::= */ - -2, /* (560) where_clause_opt ::= WHERE search_condition */ - 0, /* (561) partition_by_clause_opt ::= */ - -3, /* (562) partition_by_clause_opt ::= PARTITION BY partition_list */ - -1, /* (563) partition_list ::= partition_item */ - -3, /* (564) partition_list ::= partition_list NK_COMMA partition_item */ - -1, /* (565) partition_item ::= expr_or_subquery */ - -2, /* (566) partition_item ::= expr_or_subquery column_alias */ - -3, /* (567) partition_item ::= expr_or_subquery AS column_alias */ - 0, /* (568) twindow_clause_opt ::= */ - -6, /* (569) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ - -4, /* (570) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ - -6, /* (571) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ - -8, /* (572) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ - -7, /* (573) twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ - 0, /* (574) sliding_opt ::= */ - -4, /* (575) sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ - -1, /* (576) interval_sliding_duration_literal ::= NK_VARIABLE */ - -1, /* (577) interval_sliding_duration_literal ::= NK_STRING */ - -1, /* (578) interval_sliding_duration_literal ::= NK_INTEGER */ - 0, /* (579) fill_opt ::= */ - -4, /* (580) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - -6, /* (581) fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ - -6, /* (582) fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ - -1, /* (583) fill_mode ::= NONE */ - -1, /* (584) fill_mode ::= PREV */ - -1, /* (585) fill_mode ::= NULL */ - -1, /* (586) fill_mode ::= NULL_F */ - -1, /* (587) fill_mode ::= LINEAR */ - -1, /* (588) fill_mode ::= NEXT */ - 0, /* (589) group_by_clause_opt ::= */ - -3, /* (590) group_by_clause_opt ::= GROUP BY group_by_list */ - -1, /* (591) group_by_list ::= expr_or_subquery */ - -3, /* (592) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ - 0, /* (593) having_clause_opt ::= */ - -2, /* (594) having_clause_opt ::= HAVING search_condition */ - 0, /* (595) range_opt ::= */ - -6, /* (596) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ - -4, /* (597) range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ - 0, /* (598) every_opt ::= */ - -4, /* (599) every_opt ::= EVERY NK_LP duration_literal NK_RP */ - -4, /* (600) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ - -1, /* (601) query_simple ::= query_specification */ - -1, /* (602) query_simple ::= union_query_expression */ - -4, /* (603) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ - -3, /* (604) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ - -1, /* (605) query_simple_or_subquery ::= query_simple */ - -1, /* (606) query_simple_or_subquery ::= subquery */ - -1, /* (607) query_or_subquery ::= query_expression */ - -1, /* (608) query_or_subquery ::= subquery */ - 0, /* (609) order_by_clause_opt ::= */ - -3, /* (610) order_by_clause_opt ::= ORDER BY sort_specification_list */ - 0, /* (611) slimit_clause_opt ::= */ - -2, /* (612) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - -4, /* (613) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - -4, /* (614) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - 0, /* (615) limit_clause_opt ::= */ - -2, /* (616) limit_clause_opt ::= LIMIT NK_INTEGER */ - -4, /* (617) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - -4, /* (618) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - -3, /* (619) subquery ::= NK_LP query_expression NK_RP */ - -3, /* (620) subquery ::= NK_LP subquery NK_RP */ - -1, /* (621) search_condition ::= common_expression */ - -1, /* (622) sort_specification_list ::= sort_specification */ - -3, /* (623) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - -3, /* (624) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ - 0, /* (625) ordering_specification_opt ::= */ - -1, /* (626) ordering_specification_opt ::= ASC */ - -1, /* (627) ordering_specification_opt ::= DESC */ - 0, /* (628) null_ordering_opt ::= */ - -2, /* (629) null_ordering_opt ::= NULLS FIRST */ - -2, /* (630) null_ordering_opt ::= NULLS LAST */ + -1, /* (47) priv_type ::= ALTER */ + -3, /* (48) priv_level ::= NK_STAR NK_DOT NK_STAR */ + -3, /* (49) priv_level ::= db_name NK_DOT NK_STAR */ + -3, /* (50) priv_level ::= db_name NK_DOT table_name */ + -1, /* (51) priv_level ::= topic_name */ + 0, /* (52) with_opt ::= */ + -2, /* (53) with_opt ::= WITH search_condition */ + -3, /* (54) cmd ::= CREATE DNODE dnode_endpoint */ + -5, /* (55) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ + -4, /* (56) cmd ::= DROP DNODE NK_INTEGER force_opt */ + -4, /* (57) cmd ::= DROP DNODE dnode_endpoint force_opt */ + -4, /* (58) cmd ::= DROP DNODE NK_INTEGER unsafe_opt */ + -4, /* (59) cmd ::= DROP DNODE dnode_endpoint unsafe_opt */ + -4, /* (60) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + -5, /* (61) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + -4, /* (62) cmd ::= ALTER ALL DNODES NK_STRING */ + -5, /* (63) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + -3, /* (64) cmd ::= RESTORE DNODE NK_INTEGER */ + -1, /* (65) dnode_endpoint ::= NK_STRING */ + -1, /* (66) dnode_endpoint ::= NK_ID */ + -1, /* (67) dnode_endpoint ::= NK_IPTOKEN */ + 0, /* (68) force_opt ::= */ + -1, /* (69) force_opt ::= FORCE */ + -1, /* (70) unsafe_opt ::= UNSAFE */ + -3, /* (71) cmd ::= ALTER LOCAL NK_STRING */ + -4, /* (72) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + -5, /* (73) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + -5, /* (74) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + -5, /* (75) cmd ::= RESTORE QNODE ON DNODE NK_INTEGER */ + -5, /* (76) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ + -5, /* (77) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ + -5, /* (78) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ + -5, /* (79) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ + -5, /* (80) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ + -5, /* (81) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ + -5, /* (82) cmd ::= RESTORE MNODE ON DNODE NK_INTEGER */ + -5, /* (83) cmd ::= RESTORE VNODE ON DNODE NK_INTEGER */ + -5, /* (84) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + -4, /* (85) cmd ::= DROP DATABASE exists_opt db_name */ + -2, /* (86) cmd ::= USE db_name */ + -4, /* (87) cmd ::= ALTER DATABASE db_name alter_db_options */ + -3, /* (88) cmd ::= FLUSH DATABASE db_name */ + -4, /* (89) cmd ::= TRIM DATABASE db_name speed_opt */ + -5, /* (90) cmd ::= COMPACT DATABASE db_name start_opt end_opt */ + -3, /* (91) not_exists_opt ::= IF NOT EXISTS */ + 0, /* (92) not_exists_opt ::= */ + -2, /* (93) exists_opt ::= IF EXISTS */ + 0, /* (94) exists_opt ::= */ + 0, /* (95) db_options ::= */ + -3, /* (96) db_options ::= db_options BUFFER NK_INTEGER */ + -3, /* (97) db_options ::= db_options CACHEMODEL NK_STRING */ + -3, /* (98) db_options ::= db_options CACHESIZE NK_INTEGER */ + -3, /* (99) db_options ::= db_options COMP NK_INTEGER */ + -3, /* (100) db_options ::= db_options DURATION NK_INTEGER */ + -3, /* (101) db_options ::= db_options DURATION NK_VARIABLE */ + -3, /* (102) db_options ::= db_options MAXROWS NK_INTEGER */ + -3, /* (103) db_options ::= db_options MINROWS NK_INTEGER */ + -3, /* (104) db_options ::= db_options KEEP integer_list */ + -3, /* (105) db_options ::= db_options KEEP variable_list */ + -3, /* (106) db_options ::= db_options PAGES NK_INTEGER */ + -3, /* (107) db_options ::= db_options PAGESIZE NK_INTEGER */ + -3, /* (108) db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ + -3, /* (109) db_options ::= db_options PRECISION NK_STRING */ + -3, /* (110) db_options ::= db_options REPLICA NK_INTEGER */ + -3, /* (111) db_options ::= db_options VGROUPS NK_INTEGER */ + -3, /* (112) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + -3, /* (113) db_options ::= db_options RETENTIONS retention_list */ + -3, /* (114) db_options ::= db_options SCHEMALESS NK_INTEGER */ + -3, /* (115) db_options ::= db_options WAL_LEVEL NK_INTEGER */ + -3, /* (116) db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ + -3, /* (117) db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ + -4, /* (118) db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ + -3, /* (119) db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ + -4, /* (120) db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ + -3, /* (121) db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ + -3, /* (122) db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ + -3, /* (123) db_options ::= db_options STT_TRIGGER NK_INTEGER */ + -3, /* (124) db_options ::= db_options TABLE_PREFIX signed */ + -3, /* (125) db_options ::= db_options TABLE_SUFFIX signed */ + -3, /* (126) db_options ::= db_options KEEP_TIME_OFFSET NK_INTEGER */ + -1, /* (127) alter_db_options ::= alter_db_option */ + -2, /* (128) alter_db_options ::= alter_db_options alter_db_option */ + -2, /* (129) alter_db_option ::= BUFFER NK_INTEGER */ + -2, /* (130) alter_db_option ::= CACHEMODEL NK_STRING */ + -2, /* (131) alter_db_option ::= CACHESIZE NK_INTEGER */ + -2, /* (132) alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ + -2, /* (133) alter_db_option ::= KEEP integer_list */ + -2, /* (134) alter_db_option ::= KEEP variable_list */ + -2, /* (135) alter_db_option ::= PAGES NK_INTEGER */ + -2, /* (136) alter_db_option ::= REPLICA NK_INTEGER */ + -2, /* (137) alter_db_option ::= WAL_LEVEL NK_INTEGER */ + -2, /* (138) alter_db_option ::= STT_TRIGGER NK_INTEGER */ + -2, /* (139) alter_db_option ::= MINROWS NK_INTEGER */ + -2, /* (140) alter_db_option ::= WAL_RETENTION_PERIOD NK_INTEGER */ + -3, /* (141) alter_db_option ::= WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ + -2, /* (142) alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER */ + -3, /* (143) alter_db_option ::= WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ + -2, /* (144) alter_db_option ::= KEEP_TIME_OFFSET NK_INTEGER */ + -1, /* (145) integer_list ::= NK_INTEGER */ + -3, /* (146) integer_list ::= integer_list NK_COMMA NK_INTEGER */ + -1, /* (147) variable_list ::= NK_VARIABLE */ + -3, /* (148) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ + -1, /* (149) retention_list ::= retention */ + -3, /* (150) retention_list ::= retention_list NK_COMMA retention */ + -3, /* (151) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ + -3, /* (152) retention ::= NK_MINUS NK_COLON NK_VARIABLE */ + 0, /* (153) speed_opt ::= */ + -2, /* (154) speed_opt ::= BWLIMIT NK_INTEGER */ + 0, /* (155) start_opt ::= */ + -3, /* (156) start_opt ::= START WITH NK_INTEGER */ + -3, /* (157) start_opt ::= START WITH NK_STRING */ + -4, /* (158) start_opt ::= START WITH TIMESTAMP NK_STRING */ + 0, /* (159) end_opt ::= */ + -3, /* (160) end_opt ::= END WITH NK_INTEGER */ + -3, /* (161) end_opt ::= END WITH NK_STRING */ + -4, /* (162) end_opt ::= END WITH TIMESTAMP NK_STRING */ + -9, /* (163) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + -3, /* (164) cmd ::= CREATE TABLE multi_create_clause */ + -9, /* (165) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + -3, /* (166) cmd ::= DROP TABLE multi_drop_clause */ + -4, /* (167) cmd ::= DROP STABLE exists_opt full_table_name */ + -3, /* (168) cmd ::= ALTER TABLE alter_table_clause */ + -3, /* (169) cmd ::= ALTER STABLE alter_table_clause */ + -2, /* (170) alter_table_clause ::= full_table_name alter_table_options */ + -5, /* (171) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ + -4, /* (172) alter_table_clause ::= full_table_name DROP COLUMN column_name */ + -5, /* (173) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ + -5, /* (174) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ + -5, /* (175) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ + -4, /* (176) alter_table_clause ::= full_table_name DROP TAG column_name */ + -5, /* (177) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ + -5, /* (178) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ + -6, /* (179) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ + -1, /* (180) multi_create_clause ::= create_subtable_clause */ + -2, /* (181) multi_create_clause ::= multi_create_clause create_subtable_clause */ + -10, /* (182) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */ + -1, /* (183) multi_drop_clause ::= drop_table_clause */ + -3, /* (184) multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause */ + -2, /* (185) drop_table_clause ::= exists_opt full_table_name */ + 0, /* (186) specific_cols_opt ::= */ + -3, /* (187) specific_cols_opt ::= NK_LP col_name_list NK_RP */ + -1, /* (188) full_table_name ::= table_name */ + -3, /* (189) full_table_name ::= db_name NK_DOT table_name */ + -1, /* (190) column_def_list ::= column_def */ + -3, /* (191) column_def_list ::= column_def_list NK_COMMA column_def */ + -2, /* (192) column_def ::= column_name type_name */ + -1, /* (193) type_name ::= BOOL */ + -1, /* (194) type_name ::= TINYINT */ + -1, /* (195) type_name ::= SMALLINT */ + -1, /* (196) type_name ::= INT */ + -1, /* (197) type_name ::= INTEGER */ + -1, /* (198) type_name ::= BIGINT */ + -1, /* (199) type_name ::= FLOAT */ + -1, /* (200) type_name ::= DOUBLE */ + -4, /* (201) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + -1, /* (202) type_name ::= TIMESTAMP */ + -4, /* (203) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + -2, /* (204) type_name ::= TINYINT UNSIGNED */ + -2, /* (205) type_name ::= SMALLINT UNSIGNED */ + -2, /* (206) type_name ::= INT UNSIGNED */ + -2, /* (207) type_name ::= BIGINT UNSIGNED */ + -1, /* (208) type_name ::= JSON */ + -4, /* (209) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + -1, /* (210) type_name ::= MEDIUMBLOB */ + -1, /* (211) type_name ::= BLOB */ + -4, /* (212) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + -4, /* (213) type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP */ + -1, /* (214) type_name ::= DECIMAL */ + -4, /* (215) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + -6, /* (216) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + 0, /* (217) tags_def_opt ::= */ + -1, /* (218) tags_def_opt ::= tags_def */ + -4, /* (219) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + 0, /* (220) table_options ::= */ + -3, /* (221) table_options ::= table_options COMMENT NK_STRING */ + -3, /* (222) table_options ::= table_options MAX_DELAY duration_list */ + -3, /* (223) table_options ::= table_options WATERMARK duration_list */ + -5, /* (224) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ + -3, /* (225) table_options ::= table_options TTL NK_INTEGER */ + -5, /* (226) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + -3, /* (227) table_options ::= table_options DELETE_MARK duration_list */ + -1, /* (228) alter_table_options ::= alter_table_option */ + -2, /* (229) alter_table_options ::= alter_table_options alter_table_option */ + -2, /* (230) alter_table_option ::= COMMENT NK_STRING */ + -2, /* (231) alter_table_option ::= TTL NK_INTEGER */ + -1, /* (232) duration_list ::= duration_literal */ + -3, /* (233) duration_list ::= duration_list NK_COMMA duration_literal */ + -1, /* (234) rollup_func_list ::= rollup_func_name */ + -3, /* (235) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ + -1, /* (236) rollup_func_name ::= function_name */ + -1, /* (237) rollup_func_name ::= FIRST */ + -1, /* (238) rollup_func_name ::= LAST */ + -1, /* (239) col_name_list ::= col_name */ + -3, /* (240) col_name_list ::= col_name_list NK_COMMA col_name */ + -1, /* (241) col_name ::= column_name */ + -2, /* (242) cmd ::= SHOW DNODES */ + -2, /* (243) cmd ::= SHOW USERS */ + -3, /* (244) cmd ::= SHOW USER PRIVILEGES */ + -3, /* (245) cmd ::= SHOW db_kind_opt DATABASES */ + -4, /* (246) cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt */ + -4, /* (247) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ + -3, /* (248) cmd ::= SHOW db_name_cond_opt VGROUPS */ + -2, /* (249) cmd ::= SHOW MNODES */ + -2, /* (250) cmd ::= SHOW QNODES */ + -2, /* (251) cmd ::= SHOW FUNCTIONS */ + -5, /* (252) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + -6, /* (253) cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name */ + -2, /* (254) cmd ::= SHOW STREAMS */ + -2, /* (255) cmd ::= SHOW ACCOUNTS */ + -2, /* (256) cmd ::= SHOW APPS */ + -2, /* (257) cmd ::= SHOW CONNECTIONS */ + -2, /* (258) cmd ::= SHOW LICENCES */ + -2, /* (259) cmd ::= SHOW GRANTS */ + -4, /* (260) cmd ::= SHOW CREATE DATABASE db_name */ + -4, /* (261) cmd ::= SHOW CREATE TABLE full_table_name */ + -4, /* (262) cmd ::= SHOW CREATE STABLE full_table_name */ + -2, /* (263) cmd ::= SHOW QUERIES */ + -2, /* (264) cmd ::= SHOW SCORES */ + -2, /* (265) cmd ::= SHOW TOPICS */ + -2, /* (266) cmd ::= SHOW VARIABLES */ + -3, /* (267) cmd ::= SHOW CLUSTER VARIABLES */ + -3, /* (268) cmd ::= SHOW LOCAL VARIABLES */ + -5, /* (269) cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ + -2, /* (270) cmd ::= SHOW BNODES */ + -2, /* (271) cmd ::= SHOW SNODES */ + -2, /* (272) cmd ::= SHOW CLUSTER */ + -2, /* (273) cmd ::= SHOW TRANSACTIONS */ + -4, /* (274) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ + -2, /* (275) cmd ::= SHOW CONSUMERS */ + -2, /* (276) cmd ::= SHOW SUBSCRIPTIONS */ + -5, /* (277) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ + -6, /* (278) cmd ::= SHOW TAGS FROM db_name NK_DOT table_name */ + -7, /* (279) cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ + -8, /* (280) cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name */ + -5, /* (281) cmd ::= SHOW VNODES ON DNODE NK_INTEGER */ + -2, /* (282) cmd ::= SHOW VNODES */ + -3, /* (283) cmd ::= SHOW db_name_cond_opt ALIVE */ + -3, /* (284) cmd ::= SHOW CLUSTER ALIVE */ + -3, /* (285) cmd ::= SHOW db_name_cond_opt VIEWS */ + -4, /* (286) cmd ::= SHOW CREATE VIEW full_table_name */ + 0, /* (287) table_kind_db_name_cond_opt ::= */ + -1, /* (288) table_kind_db_name_cond_opt ::= table_kind */ + -2, /* (289) table_kind_db_name_cond_opt ::= db_name NK_DOT */ + -3, /* (290) table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ + -1, /* (291) table_kind ::= NORMAL */ + -1, /* (292) table_kind ::= CHILD */ + 0, /* (293) db_name_cond_opt ::= */ + -2, /* (294) db_name_cond_opt ::= db_name NK_DOT */ + 0, /* (295) like_pattern_opt ::= */ + -2, /* (296) like_pattern_opt ::= LIKE NK_STRING */ + -1, /* (297) table_name_cond ::= table_name */ + 0, /* (298) from_db_opt ::= */ + -2, /* (299) from_db_opt ::= FROM db_name */ + 0, /* (300) tag_list_opt ::= */ + -1, /* (301) tag_list_opt ::= tag_item */ + -3, /* (302) tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ + -1, /* (303) tag_item ::= TBNAME */ + -1, /* (304) tag_item ::= QTAGS */ + -1, /* (305) tag_item ::= column_name */ + -2, /* (306) tag_item ::= column_name column_alias */ + -3, /* (307) tag_item ::= column_name AS column_alias */ + 0, /* (308) db_kind_opt ::= */ + -1, /* (309) db_kind_opt ::= USER */ + -1, /* (310) db_kind_opt ::= SYSTEM */ + -8, /* (311) cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ + -9, /* (312) cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ + -4, /* (313) cmd ::= DROP INDEX exists_opt full_index_name */ + -1, /* (314) full_index_name ::= index_name */ + -3, /* (315) full_index_name ::= db_name NK_DOT index_name */ + -10, /* (316) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ + -12, /* (317) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ + -1, /* (318) func_list ::= func */ + -3, /* (319) func_list ::= func_list NK_COMMA func */ + -4, /* (320) func ::= sma_func_name NK_LP expression_list NK_RP */ + -1, /* (321) sma_func_name ::= function_name */ + -1, /* (322) sma_func_name ::= COUNT */ + -1, /* (323) sma_func_name ::= FIRST */ + -1, /* (324) sma_func_name ::= LAST */ + -1, /* (325) sma_func_name ::= LAST_ROW */ + 0, /* (326) sma_stream_opt ::= */ + -3, /* (327) sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ + -3, /* (328) sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ + -3, /* (329) sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ + -1, /* (330) with_meta ::= AS */ + -3, /* (331) with_meta ::= WITH META AS */ + -3, /* (332) with_meta ::= ONLY META AS */ + -6, /* (333) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ + -7, /* (334) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ + -8, /* (335) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ + -4, /* (336) cmd ::= DROP TOPIC exists_opt topic_name */ + -7, /* (337) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ + -2, /* (338) cmd ::= DESC full_table_name */ + -2, /* (339) cmd ::= DESCRIBE full_table_name */ + -3, /* (340) cmd ::= RESET QUERY CACHE */ + -4, /* (341) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ + -4, /* (342) cmd ::= EXPLAIN analyze_opt explain_options insert_query */ + 0, /* (343) analyze_opt ::= */ + -1, /* (344) analyze_opt ::= ANALYZE */ + 0, /* (345) explain_options ::= */ + -3, /* (346) explain_options ::= explain_options VERBOSE NK_BOOL */ + -3, /* (347) explain_options ::= explain_options RATIO NK_FLOAT */ + -12, /* (348) cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ + -4, /* (349) cmd ::= DROP FUNCTION exists_opt function_name */ + 0, /* (350) agg_func_opt ::= */ + -1, /* (351) agg_func_opt ::= AGGREGATE */ + 0, /* (352) bufsize_opt ::= */ + -2, /* (353) bufsize_opt ::= BUFSIZE NK_INTEGER */ + 0, /* (354) language_opt ::= */ + -2, /* (355) language_opt ::= LANGUAGE NK_STRING */ + 0, /* (356) or_replace_opt ::= */ + -2, /* (357) or_replace_opt ::= OR REPLACE */ + -6, /* (358) cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ + -4, /* (359) cmd ::= DROP VIEW exists_opt full_view_name */ + -1, /* (360) full_view_name ::= view_name */ + -3, /* (361) full_view_name ::= db_name NK_DOT view_name */ + -12, /* (362) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery */ + -4, /* (363) cmd ::= DROP STREAM exists_opt stream_name */ + -4, /* (364) cmd ::= PAUSE STREAM exists_opt stream_name */ + -5, /* (365) cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ + 0, /* (366) col_list_opt ::= */ + -3, /* (367) col_list_opt ::= NK_LP col_name_list NK_RP */ + 0, /* (368) tag_def_or_ref_opt ::= */ + -1, /* (369) tag_def_or_ref_opt ::= tags_def */ + -4, /* (370) tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP */ + 0, /* (371) stream_options ::= */ + -3, /* (372) stream_options ::= stream_options TRIGGER AT_ONCE */ + -3, /* (373) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + -4, /* (374) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ + -3, /* (375) stream_options ::= stream_options WATERMARK duration_literal */ + -4, /* (376) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ + -3, /* (377) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ + -3, /* (378) stream_options ::= stream_options DELETE_MARK duration_literal */ + -4, /* (379) stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ + 0, /* (380) subtable_opt ::= */ + -4, /* (381) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + 0, /* (382) ignore_opt ::= */ + -2, /* (383) ignore_opt ::= IGNORE UNTREATED */ + -3, /* (384) cmd ::= KILL CONNECTION NK_INTEGER */ + -3, /* (385) cmd ::= KILL QUERY NK_STRING */ + -3, /* (386) cmd ::= KILL TRANSACTION NK_INTEGER */ + -2, /* (387) cmd ::= BALANCE VGROUP */ + -4, /* (388) cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ + -4, /* (389) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + -4, /* (390) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + -3, /* (391) cmd ::= SPLIT VGROUP NK_INTEGER */ + 0, /* (392) on_vgroup_id ::= */ + -2, /* (393) on_vgroup_id ::= ON NK_INTEGER */ + -2, /* (394) dnode_list ::= DNODE NK_INTEGER */ + -3, /* (395) dnode_list ::= dnode_list DNODE NK_INTEGER */ + -4, /* (396) cmd ::= DELETE FROM full_table_name where_clause_opt */ + -1, /* (397) cmd ::= query_or_subquery */ + -1, /* (398) cmd ::= insert_query */ + -7, /* (399) insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ + -4, /* (400) insert_query ::= INSERT INTO full_table_name query_or_subquery */ + -1, /* (401) literal ::= NK_INTEGER */ + -1, /* (402) literal ::= NK_FLOAT */ + -1, /* (403) literal ::= NK_STRING */ + -1, /* (404) literal ::= NK_BOOL */ + -2, /* (405) literal ::= TIMESTAMP NK_STRING */ + -1, /* (406) literal ::= duration_literal */ + -1, /* (407) literal ::= NULL */ + -1, /* (408) literal ::= NK_QUESTION */ + -1, /* (409) duration_literal ::= NK_VARIABLE */ + -1, /* (410) signed ::= NK_INTEGER */ + -2, /* (411) signed ::= NK_PLUS NK_INTEGER */ + -2, /* (412) signed ::= NK_MINUS NK_INTEGER */ + -1, /* (413) signed ::= NK_FLOAT */ + -2, /* (414) signed ::= NK_PLUS NK_FLOAT */ + -2, /* (415) signed ::= NK_MINUS NK_FLOAT */ + -1, /* (416) signed_literal ::= signed */ + -1, /* (417) signed_literal ::= NK_STRING */ + -1, /* (418) signed_literal ::= NK_BOOL */ + -2, /* (419) signed_literal ::= TIMESTAMP NK_STRING */ + -1, /* (420) signed_literal ::= duration_literal */ + -1, /* (421) signed_literal ::= NULL */ + -1, /* (422) signed_literal ::= literal_func */ + -1, /* (423) signed_literal ::= NK_QUESTION */ + -1, /* (424) literal_list ::= signed_literal */ + -3, /* (425) literal_list ::= literal_list NK_COMMA signed_literal */ + -1, /* (426) db_name ::= NK_ID */ + -1, /* (427) table_name ::= NK_ID */ + -1, /* (428) column_name ::= NK_ID */ + -1, /* (429) function_name ::= NK_ID */ + -1, /* (430) view_name ::= NK_ID */ + -1, /* (431) table_alias ::= NK_ID */ + -1, /* (432) column_alias ::= NK_ID */ + -1, /* (433) column_alias ::= NK_ALIAS */ + -1, /* (434) user_name ::= NK_ID */ + -1, /* (435) topic_name ::= NK_ID */ + -1, /* (436) stream_name ::= NK_ID */ + -1, /* (437) cgroup_name ::= NK_ID */ + -1, /* (438) index_name ::= NK_ID */ + -1, /* (439) expr_or_subquery ::= expression */ + -1, /* (440) expression ::= literal */ + -1, /* (441) expression ::= pseudo_column */ + -1, /* (442) expression ::= column_reference */ + -1, /* (443) expression ::= function_expression */ + -1, /* (444) expression ::= case_when_expression */ + -3, /* (445) expression ::= NK_LP expression NK_RP */ + -2, /* (446) expression ::= NK_PLUS expr_or_subquery */ + -2, /* (447) expression ::= NK_MINUS expr_or_subquery */ + -3, /* (448) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + -3, /* (449) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + -3, /* (450) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + -3, /* (451) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + -3, /* (452) expression ::= expr_or_subquery NK_REM expr_or_subquery */ + -3, /* (453) expression ::= column_reference NK_ARROW NK_STRING */ + -3, /* (454) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + -3, /* (455) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + -1, /* (456) expression_list ::= expr_or_subquery */ + -3, /* (457) expression_list ::= expression_list NK_COMMA expr_or_subquery */ + -1, /* (458) column_reference ::= column_name */ + -3, /* (459) column_reference ::= table_name NK_DOT column_name */ + -1, /* (460) column_reference ::= NK_ALIAS */ + -3, /* (461) column_reference ::= table_name NK_DOT NK_ALIAS */ + -1, /* (462) pseudo_column ::= ROWTS */ + -1, /* (463) pseudo_column ::= TBNAME */ + -3, /* (464) pseudo_column ::= table_name NK_DOT TBNAME */ + -1, /* (465) pseudo_column ::= QSTART */ + -1, /* (466) pseudo_column ::= QEND */ + -1, /* (467) pseudo_column ::= QDURATION */ + -1, /* (468) pseudo_column ::= WSTART */ + -1, /* (469) pseudo_column ::= WEND */ + -1, /* (470) pseudo_column ::= WDURATION */ + -1, /* (471) pseudo_column ::= IROWTS */ + -1, /* (472) pseudo_column ::= ISFILLED */ + -1, /* (473) pseudo_column ::= QTAGS */ + -4, /* (474) function_expression ::= function_name NK_LP expression_list NK_RP */ + -4, /* (475) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ + -6, /* (476) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ + -1, /* (477) function_expression ::= literal_func */ + -3, /* (478) literal_func ::= noarg_func NK_LP NK_RP */ + -1, /* (479) literal_func ::= NOW */ + -1, /* (480) noarg_func ::= NOW */ + -1, /* (481) noarg_func ::= TODAY */ + -1, /* (482) noarg_func ::= TIMEZONE */ + -1, /* (483) noarg_func ::= DATABASE */ + -1, /* (484) noarg_func ::= CLIENT_VERSION */ + -1, /* (485) noarg_func ::= SERVER_VERSION */ + -1, /* (486) noarg_func ::= SERVER_STATUS */ + -1, /* (487) noarg_func ::= CURRENT_USER */ + -1, /* (488) noarg_func ::= USER */ + -1, /* (489) star_func ::= COUNT */ + -1, /* (490) star_func ::= FIRST */ + -1, /* (491) star_func ::= LAST */ + -1, /* (492) star_func ::= LAST_ROW */ + -1, /* (493) star_func_para_list ::= NK_STAR */ + -1, /* (494) star_func_para_list ::= other_para_list */ + -1, /* (495) other_para_list ::= star_func_para */ + -3, /* (496) other_para_list ::= other_para_list NK_COMMA star_func_para */ + -1, /* (497) star_func_para ::= expr_or_subquery */ + -3, /* (498) star_func_para ::= table_name NK_DOT NK_STAR */ + -4, /* (499) case_when_expression ::= CASE when_then_list case_when_else_opt END */ + -5, /* (500) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ + -1, /* (501) when_then_list ::= when_then_expr */ + -2, /* (502) when_then_list ::= when_then_list when_then_expr */ + -4, /* (503) when_then_expr ::= WHEN common_expression THEN common_expression */ + 0, /* (504) case_when_else_opt ::= */ + -2, /* (505) case_when_else_opt ::= ELSE common_expression */ + -3, /* (506) predicate ::= expr_or_subquery compare_op expr_or_subquery */ + -5, /* (507) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + -6, /* (508) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + -3, /* (509) predicate ::= expr_or_subquery IS NULL */ + -4, /* (510) predicate ::= expr_or_subquery IS NOT NULL */ + -3, /* (511) predicate ::= expr_or_subquery in_op in_predicate_value */ + -1, /* (512) compare_op ::= NK_LT */ + -1, /* (513) compare_op ::= NK_GT */ + -1, /* (514) compare_op ::= NK_LE */ + -1, /* (515) compare_op ::= NK_GE */ + -1, /* (516) compare_op ::= NK_NE */ + -1, /* (517) compare_op ::= NK_EQ */ + -1, /* (518) compare_op ::= LIKE */ + -2, /* (519) compare_op ::= NOT LIKE */ + -1, /* (520) compare_op ::= MATCH */ + -1, /* (521) compare_op ::= NMATCH */ + -1, /* (522) compare_op ::= CONTAINS */ + -1, /* (523) in_op ::= IN */ + -2, /* (524) in_op ::= NOT IN */ + -3, /* (525) in_predicate_value ::= NK_LP literal_list NK_RP */ + -1, /* (526) boolean_value_expression ::= boolean_primary */ + -2, /* (527) boolean_value_expression ::= NOT boolean_primary */ + -3, /* (528) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + -3, /* (529) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + -1, /* (530) boolean_primary ::= predicate */ + -3, /* (531) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + -1, /* (532) common_expression ::= expr_or_subquery */ + -1, /* (533) common_expression ::= boolean_value_expression */ + 0, /* (534) from_clause_opt ::= */ + -2, /* (535) from_clause_opt ::= FROM table_reference_list */ + -1, /* (536) table_reference_list ::= table_reference */ + -3, /* (537) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + -1, /* (538) table_reference ::= table_primary */ + -1, /* (539) table_reference ::= joined_table */ + -2, /* (540) table_primary ::= table_name alias_opt */ + -4, /* (541) table_primary ::= db_name NK_DOT table_name alias_opt */ + -2, /* (542) table_primary ::= subquery alias_opt */ + -1, /* (543) table_primary ::= parenthesized_joined_table */ + 0, /* (544) alias_opt ::= */ + -1, /* (545) alias_opt ::= table_alias */ + -2, /* (546) alias_opt ::= AS table_alias */ + -3, /* (547) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + -3, /* (548) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + -6, /* (549) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + 0, /* (550) join_type ::= */ + -1, /* (551) join_type ::= INNER */ + -14, /* (552) query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + 0, /* (553) hint_list ::= */ + -1, /* (554) hint_list ::= NK_HINT */ + 0, /* (555) tag_mode_opt ::= */ + -1, /* (556) tag_mode_opt ::= TAGS */ + 0, /* (557) set_quantifier_opt ::= */ + -1, /* (558) set_quantifier_opt ::= DISTINCT */ + -1, /* (559) set_quantifier_opt ::= ALL */ + -1, /* (560) select_list ::= select_item */ + -3, /* (561) select_list ::= select_list NK_COMMA select_item */ + -1, /* (562) select_item ::= NK_STAR */ + -1, /* (563) select_item ::= common_expression */ + -2, /* (564) select_item ::= common_expression column_alias */ + -3, /* (565) select_item ::= common_expression AS column_alias */ + -3, /* (566) select_item ::= table_name NK_DOT NK_STAR */ + 0, /* (567) where_clause_opt ::= */ + -2, /* (568) where_clause_opt ::= WHERE search_condition */ + 0, /* (569) partition_by_clause_opt ::= */ + -3, /* (570) partition_by_clause_opt ::= PARTITION BY partition_list */ + -1, /* (571) partition_list ::= partition_item */ + -3, /* (572) partition_list ::= partition_list NK_COMMA partition_item */ + -1, /* (573) partition_item ::= expr_or_subquery */ + -2, /* (574) partition_item ::= expr_or_subquery column_alias */ + -3, /* (575) partition_item ::= expr_or_subquery AS column_alias */ + 0, /* (576) twindow_clause_opt ::= */ + -6, /* (577) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ + -4, /* (578) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ + -6, /* (579) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ + -8, /* (580) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ + -7, /* (581) twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ + 0, /* (582) sliding_opt ::= */ + -4, /* (583) sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ + -1, /* (584) interval_sliding_duration_literal ::= NK_VARIABLE */ + -1, /* (585) interval_sliding_duration_literal ::= NK_STRING */ + -1, /* (586) interval_sliding_duration_literal ::= NK_INTEGER */ + 0, /* (587) fill_opt ::= */ + -4, /* (588) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + -6, /* (589) fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ + -6, /* (590) fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ + -1, /* (591) fill_mode ::= NONE */ + -1, /* (592) fill_mode ::= PREV */ + -1, /* (593) fill_mode ::= NULL */ + -1, /* (594) fill_mode ::= NULL_F */ + -1, /* (595) fill_mode ::= LINEAR */ + -1, /* (596) fill_mode ::= NEXT */ + 0, /* (597) group_by_clause_opt ::= */ + -3, /* (598) group_by_clause_opt ::= GROUP BY group_by_list */ + -1, /* (599) group_by_list ::= expr_or_subquery */ + -3, /* (600) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ + 0, /* (601) having_clause_opt ::= */ + -2, /* (602) having_clause_opt ::= HAVING search_condition */ + 0, /* (603) range_opt ::= */ + -6, /* (604) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ + -4, /* (605) range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ + 0, /* (606) every_opt ::= */ + -4, /* (607) every_opt ::= EVERY NK_LP duration_literal NK_RP */ + -4, /* (608) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + -1, /* (609) query_simple ::= query_specification */ + -1, /* (610) query_simple ::= union_query_expression */ + -4, /* (611) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ + -3, /* (612) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ + -1, /* (613) query_simple_or_subquery ::= query_simple */ + -1, /* (614) query_simple_or_subquery ::= subquery */ + -1, /* (615) query_or_subquery ::= query_expression */ + -1, /* (616) query_or_subquery ::= subquery */ + 0, /* (617) order_by_clause_opt ::= */ + -3, /* (618) order_by_clause_opt ::= ORDER BY sort_specification_list */ + 0, /* (619) slimit_clause_opt ::= */ + -2, /* (620) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + -4, /* (621) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + -4, /* (622) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + 0, /* (623) limit_clause_opt ::= */ + -2, /* (624) limit_clause_opt ::= LIMIT NK_INTEGER */ + -4, /* (625) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + -4, /* (626) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + -3, /* (627) subquery ::= NK_LP query_expression NK_RP */ + -3, /* (628) subquery ::= NK_LP subquery NK_RP */ + -1, /* (629) search_condition ::= common_expression */ + -1, /* (630) sort_specification_list ::= sort_specification */ + -3, /* (631) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + -3, /* (632) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ + 0, /* (633) ordering_specification_opt ::= */ + -1, /* (634) ordering_specification_opt ::= ASC */ + -1, /* (635) ordering_specification_opt ::= DESC */ + 0, /* (636) null_ordering_opt ::= */ + -2, /* (637) null_ordering_opt ::= NULLS FIRST */ + -2, /* (638) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -4791,11 +4729,11 @@ static YYACTIONTYPE yy_reduce( YYMINORTYPE yylhsminor; case 0: /* cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } - yy_destructor(yypParser,346,&yymsp[0].minor); + yy_destructor(yypParser,347,&yymsp[0].minor); break; case 1: /* cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } - yy_destructor(yypParser,347,&yymsp[0].minor); + yy_destructor(yypParser,348,&yymsp[0].minor); break; case 2: /* account_options ::= */ { } @@ -4809,20 +4747,20 @@ static YYACTIONTYPE yy_reduce( case 9: /* account_options ::= account_options USERS literal */ yytestcase(yyruleno==9); case 10: /* account_options ::= account_options CONNS literal */ yytestcase(yyruleno==10); case 11: /* account_options ::= account_options STATE literal */ yytestcase(yyruleno==11); -{ yy_destructor(yypParser,346,&yymsp[-2].minor); +{ yy_destructor(yypParser,347,&yymsp[-2].minor); { } - yy_destructor(yypParser,348,&yymsp[0].minor); + yy_destructor(yypParser,349,&yymsp[0].minor); } break; case 12: /* alter_account_options ::= alter_account_option */ -{ yy_destructor(yypParser,349,&yymsp[0].minor); +{ yy_destructor(yypParser,350,&yymsp[0].minor); { } } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ -{ yy_destructor(yypParser,347,&yymsp[-1].minor); +{ yy_destructor(yypParser,348,&yymsp[-1].minor); { } - yy_destructor(yypParser,349,&yymsp[0].minor); + yy_destructor(yypParser,350,&yymsp[0].minor); } break; case 14: /* alter_account_option ::= PASS literal */ @@ -4836,41 +4774,41 @@ static YYACTIONTYPE yy_reduce( case 22: /* alter_account_option ::= CONNS literal */ yytestcase(yyruleno==22); case 23: /* alter_account_option ::= STATE literal */ yytestcase(yyruleno==23); { } - yy_destructor(yypParser,348,&yymsp[0].minor); + yy_destructor(yypParser,349,&yymsp[0].minor); break; case 24: /* ip_range_list ::= NK_STRING */ -{ yylhsminor.yy712 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy712 = yylhsminor.yy712; +{ yylhsminor.yy106 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy106 = yylhsminor.yy106; break; case 25: /* ip_range_list ::= ip_range_list NK_COMMA NK_STRING */ -{ yylhsminor.yy712 = addNodeToList(pCxt, yymsp[-2].minor.yy712, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy712 = yylhsminor.yy712; +{ yylhsminor.yy106 = addNodeToList(pCxt, yymsp[-2].minor.yy106, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy106 = yylhsminor.yy106; break; case 26: /* white_list ::= HOST ip_range_list */ -{ yymsp[-1].minor.yy712 = yymsp[0].minor.yy712; } +{ yymsp[-1].minor.yy106 = yymsp[0].minor.yy106; } break; case 27: /* white_list_opt ::= */ - case 185: /* specific_cols_opt ::= */ yytestcase(yyruleno==185); - case 216: /* tags_def_opt ::= */ yytestcase(yyruleno==216); - case 297: /* tag_list_opt ::= */ yytestcase(yyruleno==297); - case 359: /* col_list_opt ::= */ yytestcase(yyruleno==359); - case 361: /* tag_def_or_ref_opt ::= */ yytestcase(yyruleno==361); - case 561: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==561); - case 589: /* group_by_clause_opt ::= */ yytestcase(yyruleno==589); - case 609: /* order_by_clause_opt ::= */ yytestcase(yyruleno==609); -{ yymsp[1].minor.yy712 = NULL; } + case 186: /* specific_cols_opt ::= */ yytestcase(yyruleno==186); + case 217: /* tags_def_opt ::= */ yytestcase(yyruleno==217); + case 300: /* tag_list_opt ::= */ yytestcase(yyruleno==300); + case 366: /* col_list_opt ::= */ yytestcase(yyruleno==366); + case 368: /* tag_def_or_ref_opt ::= */ yytestcase(yyruleno==368); + case 569: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==569); + case 597: /* group_by_clause_opt ::= */ yytestcase(yyruleno==597); + case 617: /* order_by_clause_opt ::= */ yytestcase(yyruleno==617); +{ yymsp[1].minor.yy106 = NULL; } break; case 28: /* white_list_opt ::= white_list */ - case 217: /* tags_def_opt ::= tags_def */ yytestcase(yyruleno==217); - case 362: /* tag_def_or_ref_opt ::= tags_def */ yytestcase(yyruleno==362); - case 486: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==486); -{ yylhsminor.yy712 = yymsp[0].minor.yy712; } - yymsp[0].minor.yy712 = yylhsminor.yy712; + case 218: /* tags_def_opt ::= tags_def */ yytestcase(yyruleno==218); + case 369: /* tag_def_or_ref_opt ::= tags_def */ yytestcase(yyruleno==369); + case 494: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==494); +{ yylhsminor.yy106 = yymsp[0].minor.yy106; } + yymsp[0].minor.yy106 = yylhsminor.yy106; break; case 29: /* cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt white_list_opt */ { - pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-4].minor.yy785, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy215); - pCxt->pRootNode = addCreateUserStmtWhiteList(pCxt, pCxt->pRootNode, yymsp[0].minor.yy712); + pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-4].minor.yy785, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy431); + pCxt->pRootNode = addCreateUserStmtWhiteList(pCxt, pCxt->pRootNode, yymsp[0].minor.yy106); } break; case 30: /* cmd ::= ALTER USER user_name PASS NK_STRING */ @@ -4883,1690 +4821,1714 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy785, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } break; case 33: /* cmd ::= ALTER USER user_name ADD white_list */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy785, TSDB_ALTER_USER_ADD_WHITE_LIST, yymsp[0].minor.yy712); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy785, TSDB_ALTER_USER_ADD_WHITE_LIST, yymsp[0].minor.yy106); } break; case 34: /* cmd ::= ALTER USER user_name DROP white_list */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy785, TSDB_ALTER_USER_DROP_WHITE_LIST, yymsp[0].minor.yy712); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy785, TSDB_ALTER_USER_DROP_WHITE_LIST, yymsp[0].minor.yy106); } break; case 35: /* cmd ::= DROP USER user_name */ { pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy785); } break; case 36: /* sysinfo_opt ::= */ -{ yymsp[1].minor.yy215 = 1; } +{ yymsp[1].minor.yy431 = 1; } break; case 37: /* sysinfo_opt ::= SYSINFO NK_INTEGER */ -{ yymsp[-1].minor.yy215 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } +{ yymsp[-1].minor.yy431 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } break; case 38: /* cmd ::= GRANT privileges ON priv_level with_opt TO user_name */ -{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-5].minor.yy333, &yymsp[-3].minor.yy777, &yymsp[0].minor.yy785, yymsp[-2].minor.yy56); } +{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-5].minor.yy987, &yymsp[-3].minor.yy573, &yymsp[0].minor.yy785, yymsp[-2].minor.yy80); } break; case 39: /* cmd ::= REVOKE privileges ON priv_level with_opt FROM user_name */ -{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-5].minor.yy333, &yymsp[-3].minor.yy777, &yymsp[0].minor.yy785, yymsp[-2].minor.yy56); } +{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-5].minor.yy987, &yymsp[-3].minor.yy573, &yymsp[0].minor.yy785, yymsp[-2].minor.yy80); } break; case 40: /* privileges ::= ALL */ -{ yymsp[0].minor.yy333 = PRIVILEGE_TYPE_ALL; } +{ yymsp[0].minor.yy987 = PRIVILEGE_TYPE_ALL; } break; case 41: /* privileges ::= priv_type_list */ case 43: /* priv_type_list ::= priv_type */ yytestcase(yyruleno==43); -{ yylhsminor.yy333 = yymsp[0].minor.yy333; } - yymsp[0].minor.yy333 = yylhsminor.yy333; +{ yylhsminor.yy987 = yymsp[0].minor.yy987; } + yymsp[0].minor.yy987 = yylhsminor.yy987; break; case 42: /* privileges ::= SUBSCRIBE */ -{ yymsp[0].minor.yy333 = PRIVILEGE_TYPE_SUBSCRIBE; } +{ yymsp[0].minor.yy987 = PRIVILEGE_TYPE_SUBSCRIBE; } break; case 44: /* priv_type_list ::= priv_type_list NK_COMMA priv_type */ -{ yylhsminor.yy333 = yymsp[-2].minor.yy333 | yymsp[0].minor.yy333; } - yymsp[-2].minor.yy333 = yylhsminor.yy333; +{ yylhsminor.yy987 = yymsp[-2].minor.yy987 | yymsp[0].minor.yy987; } + yymsp[-2].minor.yy987 = yylhsminor.yy987; break; case 45: /* priv_type ::= READ */ -{ yymsp[0].minor.yy333 = PRIVILEGE_TYPE_READ; } +{ yymsp[0].minor.yy987 = PRIVILEGE_TYPE_READ; } break; case 46: /* priv_type ::= WRITE */ -{ yymsp[0].minor.yy333 = PRIVILEGE_TYPE_WRITE; } +{ yymsp[0].minor.yy987 = PRIVILEGE_TYPE_WRITE; } break; - case 47: /* priv_level ::= NK_STAR NK_DOT NK_STAR */ -{ yylhsminor.yy777.first = yymsp[-2].minor.yy0; yylhsminor.yy777.second = yymsp[0].minor.yy0; } - yymsp[-2].minor.yy777 = yylhsminor.yy777; + case 47: /* priv_type ::= ALTER */ +{ yymsp[0].minor.yy987 = PRIVILEGE_TYPE_ALTER; } break; - case 48: /* priv_level ::= db_name NK_DOT NK_STAR */ -{ yylhsminor.yy777.first = yymsp[-2].minor.yy785; yylhsminor.yy777.second = yymsp[0].minor.yy0; } - yymsp[-2].minor.yy777 = yylhsminor.yy777; + case 48: /* priv_level ::= NK_STAR NK_DOT NK_STAR */ +{ yylhsminor.yy573.first = yymsp[-2].minor.yy0; yylhsminor.yy573.second = yymsp[0].minor.yy0; } + yymsp[-2].minor.yy573 = yylhsminor.yy573; break; - case 49: /* priv_level ::= db_name NK_DOT table_name */ -{ yylhsminor.yy777.first = yymsp[-2].minor.yy785; yylhsminor.yy777.second = yymsp[0].minor.yy785; } - yymsp[-2].minor.yy777 = yylhsminor.yy777; + case 49: /* priv_level ::= db_name NK_DOT NK_STAR */ +{ yylhsminor.yy573.first = yymsp[-2].minor.yy785; yylhsminor.yy573.second = yymsp[0].minor.yy0; } + yymsp[-2].minor.yy573 = yylhsminor.yy573; break; - case 50: /* priv_level ::= topic_name */ -{ yylhsminor.yy777.first = yymsp[0].minor.yy785; yylhsminor.yy777.second = nil_token; } - yymsp[0].minor.yy777 = yylhsminor.yy777; + case 50: /* priv_level ::= db_name NK_DOT table_name */ +{ yylhsminor.yy573.first = yymsp[-2].minor.yy785; yylhsminor.yy573.second = yymsp[0].minor.yy785; } + yymsp[-2].minor.yy573 = yylhsminor.yy573; break; - case 51: /* with_opt ::= */ - case 154: /* start_opt ::= */ yytestcase(yyruleno==154); - case 158: /* end_opt ::= */ yytestcase(yyruleno==158); - case 292: /* like_pattern_opt ::= */ yytestcase(yyruleno==292); - case 373: /* subtable_opt ::= */ yytestcase(yyruleno==373); - case 496: /* case_when_else_opt ::= */ yytestcase(yyruleno==496); - case 526: /* from_clause_opt ::= */ yytestcase(yyruleno==526); - case 559: /* where_clause_opt ::= */ yytestcase(yyruleno==559); - case 568: /* twindow_clause_opt ::= */ yytestcase(yyruleno==568); - case 574: /* sliding_opt ::= */ yytestcase(yyruleno==574); - case 579: /* fill_opt ::= */ yytestcase(yyruleno==579); - case 593: /* having_clause_opt ::= */ yytestcase(yyruleno==593); - case 595: /* range_opt ::= */ yytestcase(yyruleno==595); - case 598: /* every_opt ::= */ yytestcase(yyruleno==598); - case 611: /* slimit_clause_opt ::= */ yytestcase(yyruleno==611); - case 615: /* limit_clause_opt ::= */ yytestcase(yyruleno==615); -{ yymsp[1].minor.yy56 = NULL; } + case 51: /* priv_level ::= topic_name */ +{ yylhsminor.yy573.first = yymsp[0].minor.yy785; yylhsminor.yy573.second = nil_token; } + yymsp[0].minor.yy573 = yylhsminor.yy573; break; - case 52: /* with_opt ::= WITH search_condition */ - case 527: /* from_clause_opt ::= FROM table_reference_list */ yytestcase(yyruleno==527); - case 560: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==560); - case 594: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==594); -{ yymsp[-1].minor.yy56 = yymsp[0].minor.yy56; } + case 52: /* with_opt ::= */ + case 155: /* start_opt ::= */ yytestcase(yyruleno==155); + case 159: /* end_opt ::= */ yytestcase(yyruleno==159); + case 295: /* like_pattern_opt ::= */ yytestcase(yyruleno==295); + case 380: /* subtable_opt ::= */ yytestcase(yyruleno==380); + case 504: /* case_when_else_opt ::= */ yytestcase(yyruleno==504); + case 534: /* from_clause_opt ::= */ yytestcase(yyruleno==534); + case 567: /* where_clause_opt ::= */ yytestcase(yyruleno==567); + case 576: /* twindow_clause_opt ::= */ yytestcase(yyruleno==576); + case 582: /* sliding_opt ::= */ yytestcase(yyruleno==582); + case 587: /* fill_opt ::= */ yytestcase(yyruleno==587); + case 601: /* having_clause_opt ::= */ yytestcase(yyruleno==601); + case 603: /* range_opt ::= */ yytestcase(yyruleno==603); + case 606: /* every_opt ::= */ yytestcase(yyruleno==606); + case 619: /* slimit_clause_opt ::= */ yytestcase(yyruleno==619); + case 623: /* limit_clause_opt ::= */ yytestcase(yyruleno==623); +{ yymsp[1].minor.yy80 = NULL; } break; - case 53: /* cmd ::= CREATE DNODE dnode_endpoint */ + case 53: /* with_opt ::= WITH search_condition */ + case 535: /* from_clause_opt ::= FROM table_reference_list */ yytestcase(yyruleno==535); + case 568: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==568); + case 602: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==602); +{ yymsp[-1].minor.yy80 = yymsp[0].minor.yy80; } + break; + case 54: /* cmd ::= CREATE DNODE dnode_endpoint */ { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy785, NULL); } break; - case 54: /* cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ + case 55: /* cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy0); } break; - case 55: /* cmd ::= DROP DNODE NK_INTEGER force_opt */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy425, false); } + case 56: /* cmd ::= DROP DNODE NK_INTEGER force_opt */ +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy923, false); } break; - case 56: /* cmd ::= DROP DNODE dnode_endpoint force_opt */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy785, yymsp[0].minor.yy425, false); } + case 57: /* cmd ::= DROP DNODE dnode_endpoint force_opt */ +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy785, yymsp[0].minor.yy923, false); } break; - case 57: /* cmd ::= DROP DNODE NK_INTEGER unsafe_opt */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, false, yymsp[0].minor.yy425); } + case 58: /* cmd ::= DROP DNODE NK_INTEGER unsafe_opt */ +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, false, yymsp[0].minor.yy923); } break; - case 58: /* cmd ::= DROP DNODE dnode_endpoint unsafe_opt */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy785, false, yymsp[0].minor.yy425); } + case 59: /* cmd ::= DROP DNODE dnode_endpoint unsafe_opt */ +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy785, false, yymsp[0].minor.yy923); } break; - case 59: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + case 60: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } break; - case 60: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + case 61: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-2].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 61: /* cmd ::= ALTER ALL DNODES NK_STRING */ + case 62: /* cmd ::= ALTER ALL DNODES NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, NULL, &yymsp[0].minor.yy0, NULL); } break; - case 62: /* cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + case 63: /* cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, NULL, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 63: /* cmd ::= RESTORE DNODE NK_INTEGER */ + case 64: /* cmd ::= RESTORE DNODE NK_INTEGER */ { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_DNODE_STMT, &yymsp[0].minor.yy0); } break; - case 64: /* dnode_endpoint ::= NK_STRING */ - case 65: /* dnode_endpoint ::= NK_ID */ yytestcase(yyruleno==65); - case 66: /* dnode_endpoint ::= NK_IPTOKEN */ yytestcase(yyruleno==66); - case 319: /* sma_func_name ::= COUNT */ yytestcase(yyruleno==319); - case 320: /* sma_func_name ::= FIRST */ yytestcase(yyruleno==320); - case 321: /* sma_func_name ::= LAST */ yytestcase(yyruleno==321); - case 322: /* sma_func_name ::= LAST_ROW */ yytestcase(yyruleno==322); - case 419: /* db_name ::= NK_ID */ yytestcase(yyruleno==419); - case 420: /* table_name ::= NK_ID */ yytestcase(yyruleno==420); - case 421: /* column_name ::= NK_ID */ yytestcase(yyruleno==421); - case 422: /* function_name ::= NK_ID */ yytestcase(yyruleno==422); - case 423: /* table_alias ::= NK_ID */ yytestcase(yyruleno==423); - case 424: /* column_alias ::= NK_ID */ yytestcase(yyruleno==424); - case 425: /* column_alias ::= NK_ALIAS */ yytestcase(yyruleno==425); - case 426: /* user_name ::= NK_ID */ yytestcase(yyruleno==426); - case 427: /* topic_name ::= NK_ID */ yytestcase(yyruleno==427); - case 428: /* stream_name ::= NK_ID */ yytestcase(yyruleno==428); - case 429: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==429); - case 430: /* index_name ::= NK_ID */ yytestcase(yyruleno==430); - case 472: /* noarg_func ::= NOW */ yytestcase(yyruleno==472); - case 473: /* noarg_func ::= TODAY */ yytestcase(yyruleno==473); - case 474: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==474); - case 475: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==475); - case 476: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==476); - case 477: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==477); - case 478: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==478); - case 479: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==479); - case 480: /* noarg_func ::= USER */ yytestcase(yyruleno==480); - case 481: /* star_func ::= COUNT */ yytestcase(yyruleno==481); - case 482: /* star_func ::= FIRST */ yytestcase(yyruleno==482); - case 483: /* star_func ::= LAST */ yytestcase(yyruleno==483); - case 484: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==484); + case 65: /* dnode_endpoint ::= NK_STRING */ + case 66: /* dnode_endpoint ::= NK_ID */ yytestcase(yyruleno==66); + case 67: /* dnode_endpoint ::= NK_IPTOKEN */ yytestcase(yyruleno==67); + case 322: /* sma_func_name ::= COUNT */ yytestcase(yyruleno==322); + case 323: /* sma_func_name ::= FIRST */ yytestcase(yyruleno==323); + case 324: /* sma_func_name ::= LAST */ yytestcase(yyruleno==324); + case 325: /* sma_func_name ::= LAST_ROW */ yytestcase(yyruleno==325); + case 426: /* db_name ::= NK_ID */ yytestcase(yyruleno==426); + case 427: /* table_name ::= NK_ID */ yytestcase(yyruleno==427); + case 428: /* column_name ::= NK_ID */ yytestcase(yyruleno==428); + case 429: /* function_name ::= NK_ID */ yytestcase(yyruleno==429); + case 430: /* view_name ::= NK_ID */ yytestcase(yyruleno==430); + case 431: /* table_alias ::= NK_ID */ yytestcase(yyruleno==431); + case 432: /* column_alias ::= NK_ID */ yytestcase(yyruleno==432); + case 433: /* column_alias ::= NK_ALIAS */ yytestcase(yyruleno==433); + case 434: /* user_name ::= NK_ID */ yytestcase(yyruleno==434); + case 435: /* topic_name ::= NK_ID */ yytestcase(yyruleno==435); + case 436: /* stream_name ::= NK_ID */ yytestcase(yyruleno==436); + case 437: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==437); + case 438: /* index_name ::= NK_ID */ yytestcase(yyruleno==438); + case 480: /* noarg_func ::= NOW */ yytestcase(yyruleno==480); + case 481: /* noarg_func ::= TODAY */ yytestcase(yyruleno==481); + case 482: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==482); + case 483: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==483); + case 484: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==484); + case 485: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==485); + case 486: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==486); + case 487: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==487); + case 488: /* noarg_func ::= USER */ yytestcase(yyruleno==488); + case 489: /* star_func ::= COUNT */ yytestcase(yyruleno==489); + case 490: /* star_func ::= FIRST */ yytestcase(yyruleno==490); + case 491: /* star_func ::= LAST */ yytestcase(yyruleno==491); + case 492: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==492); { yylhsminor.yy785 = yymsp[0].minor.yy0; } yymsp[0].minor.yy785 = yylhsminor.yy785; break; - case 67: /* force_opt ::= */ - case 91: /* not_exists_opt ::= */ yytestcase(yyruleno==91); - case 93: /* exists_opt ::= */ yytestcase(yyruleno==93); - case 340: /* analyze_opt ::= */ yytestcase(yyruleno==340); - case 347: /* agg_func_opt ::= */ yytestcase(yyruleno==347); - case 353: /* or_replace_opt ::= */ yytestcase(yyruleno==353); - case 375: /* ignore_opt ::= */ yytestcase(yyruleno==375); - case 547: /* tag_mode_opt ::= */ yytestcase(yyruleno==547); - case 549: /* set_quantifier_opt ::= */ yytestcase(yyruleno==549); -{ yymsp[1].minor.yy425 = false; } + case 68: /* force_opt ::= */ + case 92: /* not_exists_opt ::= */ yytestcase(yyruleno==92); + case 94: /* exists_opt ::= */ yytestcase(yyruleno==94); + case 343: /* analyze_opt ::= */ yytestcase(yyruleno==343); + case 350: /* agg_func_opt ::= */ yytestcase(yyruleno==350); + case 356: /* or_replace_opt ::= */ yytestcase(yyruleno==356); + case 382: /* ignore_opt ::= */ yytestcase(yyruleno==382); + case 555: /* tag_mode_opt ::= */ yytestcase(yyruleno==555); + case 557: /* set_quantifier_opt ::= */ yytestcase(yyruleno==557); +{ yymsp[1].minor.yy923 = false; } break; - case 68: /* force_opt ::= FORCE */ - case 69: /* unsafe_opt ::= UNSAFE */ yytestcase(yyruleno==69); - case 341: /* analyze_opt ::= ANALYZE */ yytestcase(yyruleno==341); - case 348: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==348); - case 548: /* tag_mode_opt ::= TAGS */ yytestcase(yyruleno==548); - case 550: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==550); -{ yymsp[0].minor.yy425 = true; } + case 69: /* force_opt ::= FORCE */ + case 70: /* unsafe_opt ::= UNSAFE */ yytestcase(yyruleno==70); + case 344: /* analyze_opt ::= ANALYZE */ yytestcase(yyruleno==344); + case 351: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==351); + case 556: /* tag_mode_opt ::= TAGS */ yytestcase(yyruleno==556); + case 558: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==558); +{ yymsp[0].minor.yy923 = true; } break; - case 70: /* cmd ::= ALTER LOCAL NK_STRING */ + case 71: /* cmd ::= ALTER LOCAL NK_STRING */ { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 71: /* cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + case 72: /* cmd ::= ALTER LOCAL NK_STRING NK_STRING */ { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 72: /* cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + case 73: /* cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_QNODE_STMT, &yymsp[0].minor.yy0); } break; - case 73: /* cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + case 74: /* cmd ::= DROP QNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_QNODE_STMT, &yymsp[0].minor.yy0); } break; - case 74: /* cmd ::= RESTORE QNODE ON DNODE NK_INTEGER */ + case 75: /* cmd ::= RESTORE QNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_QNODE_STMT, &yymsp[0].minor.yy0); } break; - case 75: /* cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ + case 76: /* cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_BNODE_STMT, &yymsp[0].minor.yy0); } break; - case 76: /* cmd ::= DROP BNODE ON DNODE NK_INTEGER */ + case 77: /* cmd ::= DROP BNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_BNODE_STMT, &yymsp[0].minor.yy0); } break; - case 77: /* cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ + case 78: /* cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_SNODE_STMT, &yymsp[0].minor.yy0); } break; - case 78: /* cmd ::= DROP SNODE ON DNODE NK_INTEGER */ + case 79: /* cmd ::= DROP SNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_SNODE_STMT, &yymsp[0].minor.yy0); } break; - case 79: /* cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ + case 80: /* cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_MNODE_STMT, &yymsp[0].minor.yy0); } break; - case 80: /* cmd ::= DROP MNODE ON DNODE NK_INTEGER */ + case 81: /* cmd ::= DROP MNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_MNODE_STMT, &yymsp[0].minor.yy0); } break; - case 81: /* cmd ::= RESTORE MNODE ON DNODE NK_INTEGER */ + case 82: /* cmd ::= RESTORE MNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_MNODE_STMT, &yymsp[0].minor.yy0); } break; - case 82: /* cmd ::= RESTORE VNODE ON DNODE NK_INTEGER */ + case 83: /* cmd ::= RESTORE VNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_VNODE_STMT, &yymsp[0].minor.yy0); } break; - case 83: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy425, &yymsp[-1].minor.yy785, yymsp[0].minor.yy56); } + case 84: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy923, &yymsp[-1].minor.yy785, yymsp[0].minor.yy80); } break; - case 84: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy425, &yymsp[0].minor.yy785); } + case 85: /* cmd ::= DROP DATABASE exists_opt db_name */ +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy923, &yymsp[0].minor.yy785); } break; - case 85: /* cmd ::= USE db_name */ + case 86: /* cmd ::= USE db_name */ { pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy785); } break; - case 86: /* cmd ::= ALTER DATABASE db_name alter_db_options */ -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy785, yymsp[0].minor.yy56); } + case 87: /* cmd ::= ALTER DATABASE db_name alter_db_options */ +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy785, yymsp[0].minor.yy80); } break; - case 87: /* cmd ::= FLUSH DATABASE db_name */ + case 88: /* cmd ::= FLUSH DATABASE db_name */ { pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy785); } break; - case 88: /* cmd ::= TRIM DATABASE db_name speed_opt */ -{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[-1].minor.yy785, yymsp[0].minor.yy676); } + case 89: /* cmd ::= TRIM DATABASE db_name speed_opt */ +{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[-1].minor.yy785, yymsp[0].minor.yy982); } break; - case 89: /* cmd ::= COMPACT DATABASE db_name start_opt end_opt */ -{ pCxt->pRootNode = createCompactStmt(pCxt, &yymsp[-2].minor.yy785, yymsp[-1].minor.yy56, yymsp[0].minor.yy56); } + case 90: /* cmd ::= COMPACT DATABASE db_name start_opt end_opt */ +{ pCxt->pRootNode = createCompactStmt(pCxt, &yymsp[-2].minor.yy785, yymsp[-1].minor.yy80, yymsp[0].minor.yy80); } break; - case 90: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy425 = true; } + case 91: /* not_exists_opt ::= IF NOT EXISTS */ +{ yymsp[-2].minor.yy923 = true; } break; - case 92: /* exists_opt ::= IF EXISTS */ - case 354: /* or_replace_opt ::= OR REPLACE */ yytestcase(yyruleno==354); - case 376: /* ignore_opt ::= IGNORE UNTREATED */ yytestcase(yyruleno==376); -{ yymsp[-1].minor.yy425 = true; } + case 93: /* exists_opt ::= IF EXISTS */ + case 357: /* or_replace_opt ::= OR REPLACE */ yytestcase(yyruleno==357); + case 383: /* ignore_opt ::= IGNORE UNTREATED */ yytestcase(yyruleno==383); +{ yymsp[-1].minor.yy923 = true; } break; - case 94: /* db_options ::= */ -{ yymsp[1].minor.yy56 = createDefaultDatabaseOptions(pCxt); } + case 95: /* db_options ::= */ +{ yymsp[1].minor.yy80 = createDefaultDatabaseOptions(pCxt); } break; - case 95: /* db_options ::= db_options BUFFER NK_INTEGER */ -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 96: /* db_options ::= db_options BUFFER NK_INTEGER */ +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 96: /* db_options ::= db_options CACHEMODEL NK_STRING */ -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 97: /* db_options ::= db_options CACHEMODEL NK_STRING */ +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 97: /* db_options ::= db_options CACHESIZE NK_INTEGER */ -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 98: /* db_options ::= db_options CACHESIZE NK_INTEGER */ +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 98: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 99: /* db_options ::= db_options COMP NK_INTEGER */ +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_COMP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 99: /* db_options ::= db_options DURATION NK_INTEGER */ - case 100: /* db_options ::= db_options DURATION NK_VARIABLE */ yytestcase(yyruleno==100); -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 100: /* db_options ::= db_options DURATION NK_INTEGER */ + case 101: /* db_options ::= db_options DURATION NK_VARIABLE */ yytestcase(yyruleno==101); +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 101: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 102: /* db_options ::= db_options MAXROWS NK_INTEGER */ +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 102: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 103: /* db_options ::= db_options MINROWS NK_INTEGER */ +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 103: /* db_options ::= db_options KEEP integer_list */ - case 104: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==104); -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_KEEP, yymsp[0].minor.yy712); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 104: /* db_options ::= db_options KEEP integer_list */ + case 105: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==105); +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_KEEP, yymsp[0].minor.yy106); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 105: /* db_options ::= db_options PAGES NK_INTEGER */ -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 106: /* db_options ::= db_options PAGES NK_INTEGER */ +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 106: /* db_options ::= db_options PAGESIZE NK_INTEGER */ -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 107: /* db_options ::= db_options PAGESIZE NK_INTEGER */ +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 107: /* db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 108: /* db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 108: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 109: /* db_options ::= db_options PRECISION NK_STRING */ +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 109: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 110: /* db_options ::= db_options REPLICA NK_INTEGER */ +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 110: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 111: /* db_options ::= db_options VGROUPS NK_INTEGER */ +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 111: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 112: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 112: /* db_options ::= db_options RETENTIONS retention_list */ -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_RETENTIONS, yymsp[0].minor.yy712); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 113: /* db_options ::= db_options RETENTIONS retention_list */ +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_RETENTIONS, yymsp[0].minor.yy106); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 113: /* db_options ::= db_options SCHEMALESS NK_INTEGER */ -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 114: /* db_options ::= db_options SCHEMALESS NK_INTEGER */ +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 114: /* db_options ::= db_options WAL_LEVEL NK_INTEGER */ -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 115: /* db_options ::= db_options WAL_LEVEL NK_INTEGER */ +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_WAL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 115: /* db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 116: /* db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 116: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 117: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 117: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ + case 118: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-3].minor.yy56, DB_OPTION_WAL_RETENTION_PERIOD, &t); + yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-3].minor.yy80, DB_OPTION_WAL_RETENTION_PERIOD, &t); } - yymsp[-3].minor.yy56 = yylhsminor.yy56; + yymsp[-3].minor.yy80 = yylhsminor.yy80; break; - case 118: /* db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 119: /* db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 119: /* db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ + case 120: /* db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-3].minor.yy56, DB_OPTION_WAL_RETENTION_SIZE, &t); + yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-3].minor.yy80, DB_OPTION_WAL_RETENTION_SIZE, &t); } - yymsp[-3].minor.yy56 = yylhsminor.yy56; + yymsp[-3].minor.yy80 = yylhsminor.yy80; break; - case 120: /* db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 121: /* db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 121: /* db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 122: /* db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 122: /* db_options ::= db_options STT_TRIGGER NK_INTEGER */ -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 123: /* db_options ::= db_options STT_TRIGGER NK_INTEGER */ +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 123: /* db_options ::= db_options TABLE_PREFIX signed */ -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_TABLE_PREFIX, yymsp[0].minor.yy56); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 124: /* db_options ::= db_options TABLE_PREFIX signed */ +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_TABLE_PREFIX, yymsp[0].minor.yy80); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 124: /* db_options ::= db_options TABLE_SUFFIX signed */ -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_TABLE_SUFFIX, yymsp[0].minor.yy56); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 125: /* db_options ::= db_options TABLE_SUFFIX signed */ +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_TABLE_SUFFIX, yymsp[0].minor.yy80); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 125: /* db_options ::= db_options KEEP_TIME_OFFSET NK_INTEGER */ -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_KEEP_TIME_OFFSET, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 126: /* db_options ::= db_options KEEP_TIME_OFFSET NK_INTEGER */ +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_KEEP_TIME_OFFSET, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 126: /* alter_db_options ::= alter_db_option */ -{ yylhsminor.yy56 = createAlterDatabaseOptions(pCxt); yylhsminor.yy56 = setAlterDatabaseOption(pCxt, yylhsminor.yy56, &yymsp[0].minor.yy893); } - yymsp[0].minor.yy56 = yylhsminor.yy56; + case 127: /* alter_db_options ::= alter_db_option */ +{ yylhsminor.yy80 = createAlterDatabaseOptions(pCxt); yylhsminor.yy80 = setAlterDatabaseOption(pCxt, yylhsminor.yy80, &yymsp[0].minor.yy455); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 127: /* alter_db_options ::= alter_db_options alter_db_option */ -{ yylhsminor.yy56 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy56, &yymsp[0].minor.yy893); } - yymsp[-1].minor.yy56 = yylhsminor.yy56; + case 128: /* alter_db_options ::= alter_db_options alter_db_option */ +{ yylhsminor.yy80 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy80, &yymsp[0].minor.yy455); } + yymsp[-1].minor.yy80 = yylhsminor.yy80; break; - case 128: /* alter_db_option ::= BUFFER NK_INTEGER */ -{ yymsp[-1].minor.yy893.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } + case 129: /* alter_db_option ::= BUFFER NK_INTEGER */ +{ yymsp[-1].minor.yy455.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy455.val = yymsp[0].minor.yy0; } break; - case 129: /* alter_db_option ::= CACHEMODEL NK_STRING */ -{ yymsp[-1].minor.yy893.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } + case 130: /* alter_db_option ::= CACHEMODEL NK_STRING */ +{ yymsp[-1].minor.yy455.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy455.val = yymsp[0].minor.yy0; } break; - case 130: /* alter_db_option ::= CACHESIZE NK_INTEGER */ -{ yymsp[-1].minor.yy893.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } + case 131: /* alter_db_option ::= CACHESIZE NK_INTEGER */ +{ yymsp[-1].minor.yy455.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy455.val = yymsp[0].minor.yy0; } break; - case 131: /* alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ -{ yymsp[-1].minor.yy893.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } + case 132: /* alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ +{ yymsp[-1].minor.yy455.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy455.val = yymsp[0].minor.yy0; } break; - case 132: /* alter_db_option ::= KEEP integer_list */ - case 133: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==133); -{ yymsp[-1].minor.yy893.type = DB_OPTION_KEEP; yymsp[-1].minor.yy893.pList = yymsp[0].minor.yy712; } + case 133: /* alter_db_option ::= KEEP integer_list */ + case 134: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==134); +{ yymsp[-1].minor.yy455.type = DB_OPTION_KEEP; yymsp[-1].minor.yy455.pList = yymsp[0].minor.yy106; } break; - case 134: /* alter_db_option ::= PAGES NK_INTEGER */ -{ yymsp[-1].minor.yy893.type = DB_OPTION_PAGES; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } + case 135: /* alter_db_option ::= PAGES NK_INTEGER */ +{ yymsp[-1].minor.yy455.type = DB_OPTION_PAGES; yymsp[-1].minor.yy455.val = yymsp[0].minor.yy0; } break; - case 135: /* alter_db_option ::= REPLICA NK_INTEGER */ -{ yymsp[-1].minor.yy893.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } + case 136: /* alter_db_option ::= REPLICA NK_INTEGER */ +{ yymsp[-1].minor.yy455.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy455.val = yymsp[0].minor.yy0; } break; - case 136: /* alter_db_option ::= WAL_LEVEL NK_INTEGER */ -{ yymsp[-1].minor.yy893.type = DB_OPTION_WAL; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } + case 137: /* alter_db_option ::= WAL_LEVEL NK_INTEGER */ +{ yymsp[-1].minor.yy455.type = DB_OPTION_WAL; yymsp[-1].minor.yy455.val = yymsp[0].minor.yy0; } break; - case 137: /* alter_db_option ::= STT_TRIGGER NK_INTEGER */ -{ yymsp[-1].minor.yy893.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } + case 138: /* alter_db_option ::= STT_TRIGGER NK_INTEGER */ +{ yymsp[-1].minor.yy455.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy455.val = yymsp[0].minor.yy0; } break; - case 138: /* alter_db_option ::= MINROWS NK_INTEGER */ -{ yymsp[-1].minor.yy893.type = DB_OPTION_MINROWS; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } + case 139: /* alter_db_option ::= MINROWS NK_INTEGER */ +{ yymsp[-1].minor.yy455.type = DB_OPTION_MINROWS; yymsp[-1].minor.yy455.val = yymsp[0].minor.yy0; } break; - case 139: /* alter_db_option ::= WAL_RETENTION_PERIOD NK_INTEGER */ -{ yymsp[-1].minor.yy893.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } + case 140: /* alter_db_option ::= WAL_RETENTION_PERIOD NK_INTEGER */ +{ yymsp[-1].minor.yy455.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-1].minor.yy455.val = yymsp[0].minor.yy0; } break; - case 140: /* alter_db_option ::= WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ + case 141: /* alter_db_option ::= WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yymsp[-2].minor.yy893.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-2].minor.yy893.val = t; + yymsp[-2].minor.yy455.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-2].minor.yy455.val = t; } break; - case 141: /* alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER */ -{ yymsp[-1].minor.yy893.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } + case 142: /* alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER */ +{ yymsp[-1].minor.yy455.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-1].minor.yy455.val = yymsp[0].minor.yy0; } break; - case 142: /* alter_db_option ::= WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ + case 143: /* alter_db_option ::= WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yymsp[-2].minor.yy893.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-2].minor.yy893.val = t; + yymsp[-2].minor.yy455.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-2].minor.yy455.val = t; } break; - case 143: /* alter_db_option ::= KEEP_TIME_OFFSET NK_INTEGER */ -{ yymsp[-1].minor.yy893.type = DB_OPTION_KEEP_TIME_OFFSET; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } - break; - case 144: /* integer_list ::= NK_INTEGER */ -{ yylhsminor.yy712 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy712 = yylhsminor.yy712; - break; - case 145: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ - case 388: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==388); -{ yylhsminor.yy712 = addNodeToList(pCxt, yymsp[-2].minor.yy712, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy712 = yylhsminor.yy712; - break; - case 146: /* variable_list ::= NK_VARIABLE */ -{ yylhsminor.yy712 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy712 = yylhsminor.yy712; - break; - case 147: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ -{ yylhsminor.yy712 = addNodeToList(pCxt, yymsp[-2].minor.yy712, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy712 = yylhsminor.yy712; - break; - case 148: /* retention_list ::= retention */ - case 179: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==179); - case 182: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==182); - case 189: /* column_def_list ::= column_def */ yytestcase(yyruleno==189); - case 233: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==233); - case 238: /* col_name_list ::= col_name */ yytestcase(yyruleno==238); - case 298: /* tag_list_opt ::= tag_item */ yytestcase(yyruleno==298); - case 315: /* func_list ::= func */ yytestcase(yyruleno==315); - case 417: /* literal_list ::= signed_literal */ yytestcase(yyruleno==417); - case 487: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==487); - case 493: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==493); - case 552: /* select_list ::= select_item */ yytestcase(yyruleno==552); - case 563: /* partition_list ::= partition_item */ yytestcase(yyruleno==563); - case 622: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==622); -{ yylhsminor.yy712 = createNodeList(pCxt, yymsp[0].minor.yy56); } - yymsp[0].minor.yy712 = yylhsminor.yy712; - break; - case 149: /* retention_list ::= retention_list NK_COMMA retention */ - case 183: /* multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause */ yytestcase(yyruleno==183); - case 190: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==190); - case 234: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==234); - case 239: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==239); - case 299: /* tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ yytestcase(yyruleno==299); - case 316: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==316); - case 418: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==418); - case 488: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==488); - case 553: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==553); - case 564: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==564); - case 623: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==623); -{ yylhsminor.yy712 = addNodeToList(pCxt, yymsp[-2].minor.yy712, yymsp[0].minor.yy56); } - yymsp[-2].minor.yy712 = yylhsminor.yy712; - break; - case 150: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ - case 151: /* retention ::= NK_MINUS NK_COLON NK_VARIABLE */ yytestcase(yyruleno==151); -{ yylhsminor.yy56 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; - break; - case 152: /* speed_opt ::= */ - case 349: /* bufsize_opt ::= */ yytestcase(yyruleno==349); -{ yymsp[1].minor.yy676 = 0; } - break; - case 153: /* speed_opt ::= BWLIMIT NK_INTEGER */ - case 350: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==350); -{ yymsp[-1].minor.yy676 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } - break; - case 155: /* start_opt ::= START WITH NK_INTEGER */ - case 159: /* end_opt ::= END WITH NK_INTEGER */ yytestcase(yyruleno==159); -{ yymsp[-2].minor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } - break; - case 156: /* start_opt ::= START WITH NK_STRING */ - case 160: /* end_opt ::= END WITH NK_STRING */ yytestcase(yyruleno==160); -{ yymsp[-2].minor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } - break; - case 157: /* start_opt ::= START WITH TIMESTAMP NK_STRING */ - case 161: /* end_opt ::= END WITH TIMESTAMP NK_STRING */ yytestcase(yyruleno==161); -{ yymsp[-3].minor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } - break; - case 162: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - case 164: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==164); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy425, yymsp[-5].minor.yy56, yymsp[-3].minor.yy712, yymsp[-1].minor.yy712, yymsp[0].minor.yy56); } - break; - case 163: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy712); } - break; - case 165: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy712); } - break; - case 166: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy425, yymsp[0].minor.yy56); } - break; - case 167: /* cmd ::= ALTER TABLE alter_table_clause */ - case 390: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==390); - case 391: /* cmd ::= insert_query */ yytestcase(yyruleno==391); -{ pCxt->pRootNode = yymsp[0].minor.yy56; } - break; - case 168: /* cmd ::= ALTER STABLE alter_table_clause */ -{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy56); } - break; - case 169: /* alter_table_clause ::= full_table_name alter_table_options */ -{ yylhsminor.yy56 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy56, yymsp[0].minor.yy56); } - yymsp[-1].minor.yy56 = yylhsminor.yy56; - break; - case 170: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ -{ yylhsminor.yy56 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy56, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy785, yymsp[0].minor.yy448); } - yymsp[-4].minor.yy56 = yylhsminor.yy56; - break; - case 171: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ -{ yylhsminor.yy56 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy56, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy785); } - yymsp[-3].minor.yy56 = yylhsminor.yy56; - break; - case 172: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ -{ yylhsminor.yy56 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy56, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy785, yymsp[0].minor.yy448); } - yymsp[-4].minor.yy56 = yylhsminor.yy56; - break; - case 173: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ -{ yylhsminor.yy56 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy56, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy785, &yymsp[0].minor.yy785); } - yymsp[-4].minor.yy56 = yylhsminor.yy56; - break; - case 174: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ -{ yylhsminor.yy56 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy56, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy785, yymsp[0].minor.yy448); } - yymsp[-4].minor.yy56 = yylhsminor.yy56; - break; - case 175: /* alter_table_clause ::= full_table_name DROP TAG column_name */ -{ yylhsminor.yy56 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy56, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy785); } - yymsp[-3].minor.yy56 = yylhsminor.yy56; + case 144: /* alter_db_option ::= KEEP_TIME_OFFSET NK_INTEGER */ +{ yymsp[-1].minor.yy455.type = DB_OPTION_KEEP_TIME_OFFSET; yymsp[-1].minor.yy455.val = yymsp[0].minor.yy0; } + break; + case 145: /* integer_list ::= NK_INTEGER */ +{ yylhsminor.yy106 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy106 = yylhsminor.yy106; + break; + case 146: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ + case 395: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==395); +{ yylhsminor.yy106 = addNodeToList(pCxt, yymsp[-2].minor.yy106, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy106 = yylhsminor.yy106; + break; + case 147: /* variable_list ::= NK_VARIABLE */ +{ yylhsminor.yy106 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy106 = yylhsminor.yy106; + break; + case 148: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ +{ yylhsminor.yy106 = addNodeToList(pCxt, yymsp[-2].minor.yy106, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy106 = yylhsminor.yy106; + break; + case 149: /* retention_list ::= retention */ + case 180: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==180); + case 183: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==183); + case 190: /* column_def_list ::= column_def */ yytestcase(yyruleno==190); + case 234: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==234); + case 239: /* col_name_list ::= col_name */ yytestcase(yyruleno==239); + case 301: /* tag_list_opt ::= tag_item */ yytestcase(yyruleno==301); + case 318: /* func_list ::= func */ yytestcase(yyruleno==318); + case 424: /* literal_list ::= signed_literal */ yytestcase(yyruleno==424); + case 495: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==495); + case 501: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==501); + case 560: /* select_list ::= select_item */ yytestcase(yyruleno==560); + case 571: /* partition_list ::= partition_item */ yytestcase(yyruleno==571); + case 630: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==630); +{ yylhsminor.yy106 = createNodeList(pCxt, yymsp[0].minor.yy80); } + yymsp[0].minor.yy106 = yylhsminor.yy106; + break; + case 150: /* retention_list ::= retention_list NK_COMMA retention */ + case 184: /* multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause */ yytestcase(yyruleno==184); + case 191: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==191); + case 235: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==235); + case 240: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==240); + case 302: /* tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ yytestcase(yyruleno==302); + case 319: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==319); + case 425: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==425); + case 496: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==496); + case 561: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==561); + case 572: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==572); + case 631: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==631); +{ yylhsminor.yy106 = addNodeToList(pCxt, yymsp[-2].minor.yy106, yymsp[0].minor.yy80); } + yymsp[-2].minor.yy106 = yylhsminor.yy106; + break; + case 151: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ + case 152: /* retention ::= NK_MINUS NK_COLON NK_VARIABLE */ yytestcase(yyruleno==152); +{ yylhsminor.yy80 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; + break; + case 153: /* speed_opt ::= */ + case 352: /* bufsize_opt ::= */ yytestcase(yyruleno==352); +{ yymsp[1].minor.yy982 = 0; } + break; + case 154: /* speed_opt ::= BWLIMIT NK_INTEGER */ + case 353: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==353); +{ yymsp[-1].minor.yy982 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } + break; + case 156: /* start_opt ::= START WITH NK_INTEGER */ + case 160: /* end_opt ::= END WITH NK_INTEGER */ yytestcase(yyruleno==160); +{ yymsp[-2].minor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } + break; + case 157: /* start_opt ::= START WITH NK_STRING */ + case 161: /* end_opt ::= END WITH NK_STRING */ yytestcase(yyruleno==161); +{ yymsp[-2].minor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } + break; + case 158: /* start_opt ::= START WITH TIMESTAMP NK_STRING */ + case 162: /* end_opt ::= END WITH TIMESTAMP NK_STRING */ yytestcase(yyruleno==162); +{ yymsp[-3].minor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } + break; + case 163: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + case 165: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==165); +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy923, yymsp[-5].minor.yy80, yymsp[-3].minor.yy106, yymsp[-1].minor.yy106, yymsp[0].minor.yy80); } + break; + case 164: /* cmd ::= CREATE TABLE multi_create_clause */ +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy106); } + break; + case 166: /* cmd ::= DROP TABLE multi_drop_clause */ +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy106); } + break; + case 167: /* cmd ::= DROP STABLE exists_opt full_table_name */ +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy923, yymsp[0].minor.yy80); } + break; + case 168: /* cmd ::= ALTER TABLE alter_table_clause */ + case 397: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==397); + case 398: /* cmd ::= insert_query */ yytestcase(yyruleno==398); +{ pCxt->pRootNode = yymsp[0].minor.yy80; } + break; + case 169: /* cmd ::= ALTER STABLE alter_table_clause */ +{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy80); } + break; + case 170: /* alter_table_clause ::= full_table_name alter_table_options */ +{ yylhsminor.yy80 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy80, yymsp[0].minor.yy80); } + yymsp[-1].minor.yy80 = yylhsminor.yy80; + break; + case 171: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ +{ yylhsminor.yy80 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy80, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy785, yymsp[0].minor.yy292); } + yymsp[-4].minor.yy80 = yylhsminor.yy80; + break; + case 172: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ +{ yylhsminor.yy80 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy80, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy785); } + yymsp[-3].minor.yy80 = yylhsminor.yy80; + break; + case 173: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ +{ yylhsminor.yy80 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy80, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy785, yymsp[0].minor.yy292); } + yymsp[-4].minor.yy80 = yylhsminor.yy80; + break; + case 174: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ +{ yylhsminor.yy80 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy80, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy785, &yymsp[0].minor.yy785); } + yymsp[-4].minor.yy80 = yylhsminor.yy80; + break; + case 175: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ +{ yylhsminor.yy80 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy80, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy785, yymsp[0].minor.yy292); } + yymsp[-4].minor.yy80 = yylhsminor.yy80; + break; + case 176: /* alter_table_clause ::= full_table_name DROP TAG column_name */ +{ yylhsminor.yy80 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy80, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy785); } + yymsp[-3].minor.yy80 = yylhsminor.yy80; break; - case 176: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ -{ yylhsminor.yy56 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy56, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy785, yymsp[0].minor.yy448); } - yymsp[-4].minor.yy56 = yylhsminor.yy56; + case 177: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ +{ yylhsminor.yy80 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy80, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy785, yymsp[0].minor.yy292); } + yymsp[-4].minor.yy80 = yylhsminor.yy80; break; - case 177: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ -{ yylhsminor.yy56 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy56, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy785, &yymsp[0].minor.yy785); } - yymsp[-4].minor.yy56 = yylhsminor.yy56; + case 178: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ +{ yylhsminor.yy80 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy80, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy785, &yymsp[0].minor.yy785); } + yymsp[-4].minor.yy80 = yylhsminor.yy80; break; - case 178: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ -{ yylhsminor.yy56 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy56, &yymsp[-2].minor.yy785, yymsp[0].minor.yy56); } - yymsp[-5].minor.yy56 = yylhsminor.yy56; + case 179: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ +{ yylhsminor.yy80 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy80, &yymsp[-2].minor.yy785, yymsp[0].minor.yy80); } + yymsp[-5].minor.yy80 = yylhsminor.yy80; break; - case 180: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ - case 494: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==494); -{ yylhsminor.yy712 = addNodeToList(pCxt, yymsp[-1].minor.yy712, yymsp[0].minor.yy56); } - yymsp[-1].minor.yy712 = yylhsminor.yy712; + case 181: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ + case 502: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==502); +{ yylhsminor.yy106 = addNodeToList(pCxt, yymsp[-1].minor.yy106, yymsp[0].minor.yy80); } + yymsp[-1].minor.yy106 = yylhsminor.yy106; break; - case 181: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */ -{ yylhsminor.yy56 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy425, yymsp[-8].minor.yy56, yymsp[-6].minor.yy56, yymsp[-5].minor.yy712, yymsp[-2].minor.yy712, yymsp[0].minor.yy56); } - yymsp[-9].minor.yy56 = yylhsminor.yy56; + case 182: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */ +{ yylhsminor.yy80 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy923, yymsp[-8].minor.yy80, yymsp[-6].minor.yy80, yymsp[-5].minor.yy106, yymsp[-2].minor.yy106, yymsp[0].minor.yy80); } + yymsp[-9].minor.yy80 = yylhsminor.yy80; break; - case 184: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy56 = createDropTableClause(pCxt, yymsp[-1].minor.yy425, yymsp[0].minor.yy56); } - yymsp[-1].minor.yy56 = yylhsminor.yy56; + case 185: /* drop_table_clause ::= exists_opt full_table_name */ +{ yylhsminor.yy80 = createDropTableClause(pCxt, yymsp[-1].minor.yy923, yymsp[0].minor.yy80); } + yymsp[-1].minor.yy80 = yylhsminor.yy80; break; - case 186: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */ - case 360: /* col_list_opt ::= NK_LP col_name_list NK_RP */ yytestcase(yyruleno==360); -{ yymsp[-2].minor.yy712 = yymsp[-1].minor.yy712; } + case 187: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */ + case 367: /* col_list_opt ::= NK_LP col_name_list NK_RP */ yytestcase(yyruleno==367); +{ yymsp[-2].minor.yy106 = yymsp[-1].minor.yy106; } break; - case 187: /* full_table_name ::= table_name */ -{ yylhsminor.yy56 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy785, NULL); } - yymsp[0].minor.yy56 = yylhsminor.yy56; + case 188: /* full_table_name ::= table_name */ +{ yylhsminor.yy80 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy785, NULL); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 188: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy56 = createRealTableNode(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy785, NULL); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 189: /* full_table_name ::= db_name NK_DOT table_name */ +{ yylhsminor.yy80 = createRealTableNode(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy785, NULL); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 191: /* column_def ::= column_name type_name */ -{ yylhsminor.yy56 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy785, yymsp[0].minor.yy448, NULL); } - yymsp[-1].minor.yy56 = yylhsminor.yy56; + case 192: /* column_def ::= column_name type_name */ +{ yylhsminor.yy80 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy785, yymsp[0].minor.yy292, NULL); } + yymsp[-1].minor.yy80 = yylhsminor.yy80; break; - case 192: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_BOOL); } + case 193: /* type_name ::= BOOL */ +{ yymsp[0].minor.yy292 = createDataType(TSDB_DATA_TYPE_BOOL); } break; - case 193: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_TINYINT); } + case 194: /* type_name ::= TINYINT */ +{ yymsp[0].minor.yy292 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; - case 194: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_SMALLINT); } + case 195: /* type_name ::= SMALLINT */ +{ yymsp[0].minor.yy292 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; - case 195: /* type_name ::= INT */ - case 196: /* type_name ::= INTEGER */ yytestcase(yyruleno==196); -{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_INT); } + case 196: /* type_name ::= INT */ + case 197: /* type_name ::= INTEGER */ yytestcase(yyruleno==197); +{ yymsp[0].minor.yy292 = createDataType(TSDB_DATA_TYPE_INT); } break; - case 197: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_BIGINT); } + case 198: /* type_name ::= BIGINT */ +{ yymsp[0].minor.yy292 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; - case 198: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_FLOAT); } + case 199: /* type_name ::= FLOAT */ +{ yymsp[0].minor.yy292 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; - case 199: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_DOUBLE); } + case 200: /* type_name ::= DOUBLE */ +{ yymsp[0].minor.yy292 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; - case 200: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy448 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } + case 201: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy292 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; - case 201: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } + case 202: /* type_name ::= TIMESTAMP */ +{ yymsp[0].minor.yy292 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; - case 202: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy448 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } + case 203: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy292 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; - case 203: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy448 = createDataType(TSDB_DATA_TYPE_UTINYINT); } + case 204: /* type_name ::= TINYINT UNSIGNED */ +{ yymsp[-1].minor.yy292 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; - case 204: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy448 = createDataType(TSDB_DATA_TYPE_USMALLINT); } + case 205: /* type_name ::= SMALLINT UNSIGNED */ +{ yymsp[-1].minor.yy292 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; - case 205: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy448 = createDataType(TSDB_DATA_TYPE_UINT); } + case 206: /* type_name ::= INT UNSIGNED */ +{ yymsp[-1].minor.yy292 = createDataType(TSDB_DATA_TYPE_UINT); } break; - case 206: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy448 = createDataType(TSDB_DATA_TYPE_UBIGINT); } + case 207: /* type_name ::= BIGINT UNSIGNED */ +{ yymsp[-1].minor.yy292 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; - case 207: /* type_name ::= JSON */ -{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_JSON); } + case 208: /* type_name ::= JSON */ +{ yymsp[0].minor.yy292 = createDataType(TSDB_DATA_TYPE_JSON); } break; - case 208: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy448 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } + case 209: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy292 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; - case 209: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } + case 210: /* type_name ::= MEDIUMBLOB */ +{ yymsp[0].minor.yy292 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; - case 210: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_BLOB); } + case 211: /* type_name ::= BLOB */ +{ yymsp[0].minor.yy292 = createDataType(TSDB_DATA_TYPE_BLOB); } break; - case 211: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy448 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } + case 212: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy292 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; - case 212: /* type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy448 = createVarLenDataType(TSDB_DATA_TYPE_GEOMETRY, &yymsp[-1].minor.yy0); } + case 213: /* type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy292 = createVarLenDataType(TSDB_DATA_TYPE_GEOMETRY, &yymsp[-1].minor.yy0); } break; - case 213: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 214: /* type_name ::= DECIMAL */ +{ yymsp[0].minor.yy292 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 214: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy448 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 215: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy292 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 215: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy448 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 216: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ +{ yymsp[-5].minor.yy292 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 218: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ - case 363: /* tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP */ yytestcase(yyruleno==363); -{ yymsp[-3].minor.yy712 = yymsp[-1].minor.yy712; } + case 219: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ + case 370: /* tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP */ yytestcase(yyruleno==370); +{ yymsp[-3].minor.yy106 = yymsp[-1].minor.yy106; } break; - case 219: /* table_options ::= */ -{ yymsp[1].minor.yy56 = createDefaultTableOptions(pCxt); } + case 220: /* table_options ::= */ +{ yymsp[1].minor.yy80 = createDefaultTableOptions(pCxt); } break; - case 220: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy56 = setTableOption(pCxt, yymsp[-2].minor.yy56, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 221: /* table_options ::= table_options COMMENT NK_STRING */ +{ yylhsminor.yy80 = setTableOption(pCxt, yymsp[-2].minor.yy80, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 221: /* table_options ::= table_options MAX_DELAY duration_list */ -{ yylhsminor.yy56 = setTableOption(pCxt, yymsp[-2].minor.yy56, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy712); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 222: /* table_options ::= table_options MAX_DELAY duration_list */ +{ yylhsminor.yy80 = setTableOption(pCxt, yymsp[-2].minor.yy80, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy106); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 222: /* table_options ::= table_options WATERMARK duration_list */ -{ yylhsminor.yy56 = setTableOption(pCxt, yymsp[-2].minor.yy56, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy712); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 223: /* table_options ::= table_options WATERMARK duration_list */ +{ yylhsminor.yy80 = setTableOption(pCxt, yymsp[-2].minor.yy80, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy106); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 223: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ -{ yylhsminor.yy56 = setTableOption(pCxt, yymsp[-4].minor.yy56, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy712); } - yymsp[-4].minor.yy56 = yylhsminor.yy56; + case 224: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ +{ yylhsminor.yy80 = setTableOption(pCxt, yymsp[-4].minor.yy80, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy106); } + yymsp[-4].minor.yy80 = yylhsminor.yy80; break; - case 224: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy56 = setTableOption(pCxt, yymsp[-2].minor.yy56, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 225: /* table_options ::= table_options TTL NK_INTEGER */ +{ yylhsminor.yy80 = setTableOption(pCxt, yymsp[-2].minor.yy80, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 225: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy56 = setTableOption(pCxt, yymsp[-4].minor.yy56, TABLE_OPTION_SMA, yymsp[-1].minor.yy712); } - yymsp[-4].minor.yy56 = yylhsminor.yy56; + case 226: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ +{ yylhsminor.yy80 = setTableOption(pCxt, yymsp[-4].minor.yy80, TABLE_OPTION_SMA, yymsp[-1].minor.yy106); } + yymsp[-4].minor.yy80 = yylhsminor.yy80; break; - case 226: /* table_options ::= table_options DELETE_MARK duration_list */ -{ yylhsminor.yy56 = setTableOption(pCxt, yymsp[-2].minor.yy56, TABLE_OPTION_DELETE_MARK, yymsp[0].minor.yy712); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 227: /* table_options ::= table_options DELETE_MARK duration_list */ +{ yylhsminor.yy80 = setTableOption(pCxt, yymsp[-2].minor.yy80, TABLE_OPTION_DELETE_MARK, yymsp[0].minor.yy106); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 227: /* alter_table_options ::= alter_table_option */ -{ yylhsminor.yy56 = createAlterTableOptions(pCxt); yylhsminor.yy56 = setTableOption(pCxt, yylhsminor.yy56, yymsp[0].minor.yy893.type, &yymsp[0].minor.yy893.val); } - yymsp[0].minor.yy56 = yylhsminor.yy56; + case 228: /* alter_table_options ::= alter_table_option */ +{ yylhsminor.yy80 = createAlterTableOptions(pCxt); yylhsminor.yy80 = setTableOption(pCxt, yylhsminor.yy80, yymsp[0].minor.yy455.type, &yymsp[0].minor.yy455.val); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 228: /* alter_table_options ::= alter_table_options alter_table_option */ -{ yylhsminor.yy56 = setTableOption(pCxt, yymsp[-1].minor.yy56, yymsp[0].minor.yy893.type, &yymsp[0].minor.yy893.val); } - yymsp[-1].minor.yy56 = yylhsminor.yy56; + case 229: /* alter_table_options ::= alter_table_options alter_table_option */ +{ yylhsminor.yy80 = setTableOption(pCxt, yymsp[-1].minor.yy80, yymsp[0].minor.yy455.type, &yymsp[0].minor.yy455.val); } + yymsp[-1].minor.yy80 = yylhsminor.yy80; break; - case 229: /* alter_table_option ::= COMMENT NK_STRING */ -{ yymsp[-1].minor.yy893.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } + case 230: /* alter_table_option ::= COMMENT NK_STRING */ +{ yymsp[-1].minor.yy455.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy455.val = yymsp[0].minor.yy0; } break; - case 230: /* alter_table_option ::= TTL NK_INTEGER */ -{ yymsp[-1].minor.yy893.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } + case 231: /* alter_table_option ::= TTL NK_INTEGER */ +{ yymsp[-1].minor.yy455.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy455.val = yymsp[0].minor.yy0; } break; - case 231: /* duration_list ::= duration_literal */ - case 448: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==448); -{ yylhsminor.yy712 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy56)); } - yymsp[0].minor.yy712 = yylhsminor.yy712; + case 232: /* duration_list ::= duration_literal */ + case 456: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==456); +{ yylhsminor.yy106 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy80)); } + yymsp[0].minor.yy106 = yylhsminor.yy106; break; - case 232: /* duration_list ::= duration_list NK_COMMA duration_literal */ - case 449: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==449); -{ yylhsminor.yy712 = addNodeToList(pCxt, yymsp[-2].minor.yy712, releaseRawExprNode(pCxt, yymsp[0].minor.yy56)); } - yymsp[-2].minor.yy712 = yylhsminor.yy712; + case 233: /* duration_list ::= duration_list NK_COMMA duration_literal */ + case 457: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==457); +{ yylhsminor.yy106 = addNodeToList(pCxt, yymsp[-2].minor.yy106, releaseRawExprNode(pCxt, yymsp[0].minor.yy80)); } + yymsp[-2].minor.yy106 = yylhsminor.yy106; break; - case 235: /* rollup_func_name ::= function_name */ -{ yylhsminor.yy56 = createFunctionNode(pCxt, &yymsp[0].minor.yy785, NULL); } - yymsp[0].minor.yy56 = yylhsminor.yy56; + case 236: /* rollup_func_name ::= function_name */ +{ yylhsminor.yy80 = createFunctionNode(pCxt, &yymsp[0].minor.yy785, NULL); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 236: /* rollup_func_name ::= FIRST */ - case 237: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==237); - case 301: /* tag_item ::= QTAGS */ yytestcase(yyruleno==301); -{ yylhsminor.yy56 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } - yymsp[0].minor.yy56 = yylhsminor.yy56; + case 237: /* rollup_func_name ::= FIRST */ + case 238: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==238); + case 304: /* tag_item ::= QTAGS */ yytestcase(yyruleno==304); +{ yylhsminor.yy80 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 240: /* col_name ::= column_name */ - case 302: /* tag_item ::= column_name */ yytestcase(yyruleno==302); -{ yylhsminor.yy56 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy785); } - yymsp[0].minor.yy56 = yylhsminor.yy56; + case 241: /* col_name ::= column_name */ + case 305: /* tag_item ::= column_name */ yytestcase(yyruleno==305); +{ yylhsminor.yy80 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy785); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 241: /* cmd ::= SHOW DNODES */ + case 242: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT); } break; - case 242: /* cmd ::= SHOW USERS */ + case 243: /* cmd ::= SHOW USERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT); } break; - case 243: /* cmd ::= SHOW USER PRIVILEGES */ + case 244: /* cmd ::= SHOW USER PRIVILEGES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USER_PRIVILEGES_STMT); } break; - case 244: /* cmd ::= SHOW db_kind_opt DATABASES */ + case 245: /* cmd ::= SHOW db_kind_opt DATABASES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); - setShowKind(pCxt, pCxt->pRootNode, yymsp[-1].minor.yy33); + setShowKind(pCxt, pCxt->pRootNode, yymsp[-1].minor.yy459); } break; - case 245: /* cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt */ + case 246: /* cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt */ { - pCxt->pRootNode = createShowTablesStmt(pCxt, yymsp[-2].minor.yy205, yymsp[0].minor.yy56, OP_TYPE_LIKE); + pCxt->pRootNode = createShowTablesStmt(pCxt, yymsp[-2].minor.yy709, yymsp[0].minor.yy80, OP_TYPE_LIKE); } break; - case 246: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy56, yymsp[0].minor.yy56, OP_TYPE_LIKE); } + case 247: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy80, yymsp[0].minor.yy80, OP_TYPE_LIKE); } break; - case 247: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy56, NULL, OP_TYPE_LIKE); } + case 248: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy80, NULL, OP_TYPE_LIKE); } break; - case 248: /* cmd ::= SHOW MNODES */ + case 249: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); } break; - case 249: /* cmd ::= SHOW QNODES */ + case 250: /* cmd ::= SHOW QNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT); } break; - case 250: /* cmd ::= SHOW FUNCTIONS */ + case 251: /* cmd ::= SHOW FUNCTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT); } break; - case 251: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy56, yymsp[-1].minor.yy56, OP_TYPE_EQUAL); } + case 252: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy80, yymsp[-1].minor.yy80, OP_TYPE_EQUAL); } break; - case 252: /* cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name */ + case 253: /* cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name */ { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy785), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy785), OP_TYPE_EQUAL); } break; - case 253: /* cmd ::= SHOW STREAMS */ + case 254: /* cmd ::= SHOW STREAMS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT); } break; - case 254: /* cmd ::= SHOW ACCOUNTS */ + case 255: /* cmd ::= SHOW ACCOUNTS */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } break; - case 255: /* cmd ::= SHOW APPS */ + case 256: /* cmd ::= SHOW APPS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_APPS_STMT); } break; - case 256: /* cmd ::= SHOW CONNECTIONS */ + case 257: /* cmd ::= SHOW CONNECTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONNECTIONS_STMT); } break; - case 257: /* cmd ::= SHOW LICENCES */ - case 258: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==258); + case 258: /* cmd ::= SHOW LICENCES */ + case 259: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==259); { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCES_STMT); } break; - case 259: /* cmd ::= SHOW CREATE DATABASE db_name */ + case 260: /* cmd ::= SHOW CREATE DATABASE db_name */ { pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy785); } break; - case 260: /* cmd ::= SHOW CREATE TABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy56); } + case 261: /* cmd ::= SHOW CREATE TABLE full_table_name */ +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy80); } break; - case 261: /* cmd ::= SHOW CREATE STABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy56); } + case 262: /* cmd ::= SHOW CREATE STABLE full_table_name */ +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy80); } break; - case 262: /* cmd ::= SHOW QUERIES */ + case 263: /* cmd ::= SHOW QUERIES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); } break; - case 263: /* cmd ::= SHOW SCORES */ + case 264: /* cmd ::= SHOW SCORES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SCORES_STMT); } break; - case 264: /* cmd ::= SHOW TOPICS */ + case 265: /* cmd ::= SHOW TOPICS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TOPICS_STMT); } break; - case 265: /* cmd ::= SHOW VARIABLES */ - case 266: /* cmd ::= SHOW CLUSTER VARIABLES */ yytestcase(yyruleno==266); + case 266: /* cmd ::= SHOW VARIABLES */ + case 267: /* cmd ::= SHOW CLUSTER VARIABLES */ yytestcase(yyruleno==267); { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VARIABLES_STMT); } break; - case 267: /* cmd ::= SHOW LOCAL VARIABLES */ + case 268: /* cmd ::= SHOW LOCAL VARIABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT); } break; - case 268: /* cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowDnodeVariablesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[-2].minor.yy0), yymsp[0].minor.yy56); } + case 269: /* cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ +{ pCxt->pRootNode = createShowDnodeVariablesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[-2].minor.yy0), yymsp[0].minor.yy80); } break; - case 269: /* cmd ::= SHOW BNODES */ + case 270: /* cmd ::= SHOW BNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT); } break; - case 270: /* cmd ::= SHOW SNODES */ + case 271: /* cmd ::= SHOW SNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SNODES_STMT); } break; - case 271: /* cmd ::= SHOW CLUSTER */ + case 272: /* cmd ::= SHOW CLUSTER */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_STMT); } break; - case 272: /* cmd ::= SHOW TRANSACTIONS */ + case 273: /* cmd ::= SHOW TRANSACTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); } break; - case 273: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ -{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy56); } + case 274: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ +{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy80); } break; - case 274: /* cmd ::= SHOW CONSUMERS */ + case 275: /* cmd ::= SHOW CONSUMERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); } break; - case 275: /* cmd ::= SHOW SUBSCRIPTIONS */ + case 276: /* cmd ::= SHOW SUBSCRIPTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); } break; - case 276: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy56, yymsp[-1].minor.yy56, OP_TYPE_EQUAL); } + case 277: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy80, yymsp[-1].minor.yy80, OP_TYPE_EQUAL); } break; - case 277: /* cmd ::= SHOW TAGS FROM db_name NK_DOT table_name */ + case 278: /* cmd ::= SHOW TAGS FROM db_name NK_DOT table_name */ { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy785), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy785), OP_TYPE_EQUAL); } break; - case 278: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, yymsp[-1].minor.yy56, yymsp[0].minor.yy56, yymsp[-3].minor.yy712); } + case 279: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ +{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, yymsp[-1].minor.yy80, yymsp[0].minor.yy80, yymsp[-3].minor.yy106); } break; - case 279: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name */ -{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, createIdentifierValueNode(pCxt, &yymsp[0].minor.yy785), createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy785), yymsp[-4].minor.yy712); } + case 280: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name */ +{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, createIdentifierValueNode(pCxt, &yymsp[0].minor.yy785), createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy785), yymsp[-4].minor.yy106); } break; - case 280: /* cmd ::= SHOW VNODES ON DNODE NK_INTEGER */ + case 281: /* cmd ::= SHOW VNODES ON DNODE NK_INTEGER */ { pCxt->pRootNode = createShowVnodesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0), NULL); } break; - case 281: /* cmd ::= SHOW VNODES */ + case 282: /* cmd ::= SHOW VNODES */ { pCxt->pRootNode = createShowVnodesStmt(pCxt, NULL, NULL); } break; - case 282: /* cmd ::= SHOW db_name_cond_opt ALIVE */ -{ pCxt->pRootNode = createShowAliveStmt(pCxt, yymsp[-1].minor.yy56, QUERY_NODE_SHOW_DB_ALIVE_STMT); } + case 283: /* cmd ::= SHOW db_name_cond_opt ALIVE */ +{ pCxt->pRootNode = createShowAliveStmt(pCxt, yymsp[-1].minor.yy80, QUERY_NODE_SHOW_DB_ALIVE_STMT); } break; - case 283: /* cmd ::= SHOW CLUSTER ALIVE */ + case 284: /* cmd ::= SHOW CLUSTER ALIVE */ { pCxt->pRootNode = createShowAliveStmt(pCxt, NULL, QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT); } break; - case 284: /* table_kind_db_name_cond_opt ::= */ -{ yymsp[1].minor.yy205.kind = SHOW_KIND_ALL; yymsp[1].minor.yy205.dbName = nil_token; } + case 285: /* cmd ::= SHOW db_name_cond_opt VIEWS */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VIEWS_STMT, yymsp[-1].minor.yy80, NULL, OP_TYPE_LIKE); } break; - case 285: /* table_kind_db_name_cond_opt ::= table_kind */ -{ yylhsminor.yy205.kind = yymsp[0].minor.yy33; yylhsminor.yy205.dbName = nil_token; } - yymsp[0].minor.yy205 = yylhsminor.yy205; + case 286: /* cmd ::= SHOW CREATE VIEW full_table_name */ +{ pCxt->pRootNode = createShowCreateViewStmt(pCxt, QUERY_NODE_SHOW_CREATE_VIEW_STMT, yymsp[0].minor.yy80); } break; - case 286: /* table_kind_db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy205.kind = SHOW_KIND_ALL; yylhsminor.yy205.dbName = yymsp[-1].minor.yy785; } - yymsp[-1].minor.yy205 = yylhsminor.yy205; + case 287: /* table_kind_db_name_cond_opt ::= */ +{ yymsp[1].minor.yy709.kind = SHOW_KIND_ALL; yymsp[1].minor.yy709.dbName = nil_token; } break; - case 287: /* table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ -{ yylhsminor.yy205.kind = yymsp[-2].minor.yy33; yylhsminor.yy205.dbName = yymsp[-1].minor.yy785; } - yymsp[-2].minor.yy205 = yylhsminor.yy205; + case 288: /* table_kind_db_name_cond_opt ::= table_kind */ +{ yylhsminor.yy709.kind = yymsp[0].minor.yy459; yylhsminor.yy709.dbName = nil_token; } + yymsp[0].minor.yy709 = yylhsminor.yy709; break; - case 288: /* table_kind ::= NORMAL */ -{ yymsp[0].minor.yy33 = SHOW_KIND_TABLES_NORMAL; } + case 289: /* table_kind_db_name_cond_opt ::= db_name NK_DOT */ +{ yylhsminor.yy709.kind = SHOW_KIND_ALL; yylhsminor.yy709.dbName = yymsp[-1].minor.yy785; } + yymsp[-1].minor.yy709 = yylhsminor.yy709; break; - case 289: /* table_kind ::= CHILD */ -{ yymsp[0].minor.yy33 = SHOW_KIND_TABLES_CHILD; } + case 290: /* table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ +{ yylhsminor.yy709.kind = yymsp[-2].minor.yy459; yylhsminor.yy709.dbName = yymsp[-1].minor.yy785; } + yymsp[-2].minor.yy709 = yylhsminor.yy709; break; - case 290: /* db_name_cond_opt ::= */ - case 295: /* from_db_opt ::= */ yytestcase(yyruleno==295); -{ yymsp[1].minor.yy56 = createDefaultDatabaseCondValue(pCxt); } + case 291: /* table_kind ::= NORMAL */ +{ yymsp[0].minor.yy459 = SHOW_KIND_TABLES_NORMAL; } break; - case 291: /* db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy56 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy785); } - yymsp[-1].minor.yy56 = yylhsminor.yy56; + case 292: /* table_kind ::= CHILD */ +{ yymsp[0].minor.yy459 = SHOW_KIND_TABLES_CHILD; } break; - case 293: /* like_pattern_opt ::= LIKE NK_STRING */ -{ yymsp[-1].minor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + case 293: /* db_name_cond_opt ::= */ + case 298: /* from_db_opt ::= */ yytestcase(yyruleno==298); +{ yymsp[1].minor.yy80 = createDefaultDatabaseCondValue(pCxt); } break; - case 294: /* table_name_cond ::= table_name */ -{ yylhsminor.yy56 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy785); } - yymsp[0].minor.yy56 = yylhsminor.yy56; + case 294: /* db_name_cond_opt ::= db_name NK_DOT */ +{ yylhsminor.yy80 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy785); } + yymsp[-1].minor.yy80 = yylhsminor.yy80; break; - case 296: /* from_db_opt ::= FROM db_name */ -{ yymsp[-1].minor.yy56 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy785); } + case 296: /* like_pattern_opt ::= LIKE NK_STRING */ +{ yymsp[-1].minor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; - case 300: /* tag_item ::= TBNAME */ -{ yylhsminor.yy56 = setProjectionAlias(pCxt, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL), &yymsp[0].minor.yy0); } - yymsp[0].minor.yy56 = yylhsminor.yy56; + case 297: /* table_name_cond ::= table_name */ +{ yylhsminor.yy80 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy785); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 303: /* tag_item ::= column_name column_alias */ -{ yylhsminor.yy56 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy785), &yymsp[0].minor.yy785); } - yymsp[-1].minor.yy56 = yylhsminor.yy56; + case 299: /* from_db_opt ::= FROM db_name */ +{ yymsp[-1].minor.yy80 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy785); } break; - case 304: /* tag_item ::= column_name AS column_alias */ -{ yylhsminor.yy56 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-2].minor.yy785), &yymsp[0].minor.yy785); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 303: /* tag_item ::= TBNAME */ +{ yylhsminor.yy80 = setProjectionAlias(pCxt, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL), &yymsp[0].minor.yy0); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 305: /* db_kind_opt ::= */ -{ yymsp[1].minor.yy33 = SHOW_KIND_ALL; } + case 306: /* tag_item ::= column_name column_alias */ +{ yylhsminor.yy80 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy785), &yymsp[0].minor.yy785); } + yymsp[-1].minor.yy80 = yylhsminor.yy80; break; - case 306: /* db_kind_opt ::= USER */ -{ yymsp[0].minor.yy33 = SHOW_KIND_DATABASES_USER; } + case 307: /* tag_item ::= column_name AS column_alias */ +{ yylhsminor.yy80 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-2].minor.yy785), &yymsp[0].minor.yy785); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 307: /* db_kind_opt ::= SYSTEM */ -{ yymsp[0].minor.yy33 = SHOW_KIND_DATABASES_SYSTEM; } + case 308: /* db_kind_opt ::= */ +{ yymsp[1].minor.yy459 = SHOW_KIND_ALL; } break; - case 308: /* cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy425, yymsp[-3].minor.yy56, yymsp[-1].minor.yy56, NULL, yymsp[0].minor.yy56); } + case 309: /* db_kind_opt ::= USER */ +{ yymsp[0].minor.yy459 = SHOW_KIND_DATABASES_USER; } break; - case 309: /* cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, yymsp[-6].minor.yy425, yymsp[-5].minor.yy56, yymsp[-3].minor.yy56, yymsp[-1].minor.yy712, NULL); } + case 310: /* db_kind_opt ::= SYSTEM */ +{ yymsp[0].minor.yy459 = SHOW_KIND_DATABASES_SYSTEM; } break; - case 310: /* cmd ::= DROP INDEX exists_opt full_index_name */ -{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy425, yymsp[0].minor.yy56); } + case 311: /* cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy923, yymsp[-3].minor.yy80, yymsp[-1].minor.yy80, NULL, yymsp[0].minor.yy80); } break; - case 311: /* full_index_name ::= index_name */ -{ yylhsminor.yy56 = createRealTableNodeForIndexName(pCxt, NULL, &yymsp[0].minor.yy785); } - yymsp[0].minor.yy56 = yylhsminor.yy56; + case 312: /* cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, yymsp[-6].minor.yy923, yymsp[-5].minor.yy80, yymsp[-3].minor.yy80, yymsp[-1].minor.yy106, NULL); } break; - case 312: /* full_index_name ::= db_name NK_DOT index_name */ -{ yylhsminor.yy56 = createRealTableNodeForIndexName(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy785); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 313: /* cmd ::= DROP INDEX exists_opt full_index_name */ +{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy923, yymsp[0].minor.yy80); } break; - case 313: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ -{ yymsp[-9].minor.yy56 = createIndexOption(pCxt, yymsp[-7].minor.yy712, releaseRawExprNode(pCxt, yymsp[-3].minor.yy56), NULL, yymsp[-1].minor.yy56, yymsp[0].minor.yy56); } + case 314: /* full_index_name ::= index_name */ +{ yylhsminor.yy80 = createRealTableNodeForIndexName(pCxt, NULL, &yymsp[0].minor.yy785); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 314: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ -{ yymsp[-11].minor.yy56 = createIndexOption(pCxt, yymsp[-9].minor.yy712, releaseRawExprNode(pCxt, yymsp[-5].minor.yy56), releaseRawExprNode(pCxt, yymsp[-3].minor.yy56), yymsp[-1].minor.yy56, yymsp[0].minor.yy56); } + case 315: /* full_index_name ::= db_name NK_DOT index_name */ +{ yylhsminor.yy80 = createRealTableNodeForIndexName(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy785); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 317: /* func ::= sma_func_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy56 = createFunctionNode(pCxt, &yymsp[-3].minor.yy785, yymsp[-1].minor.yy712); } - yymsp[-3].minor.yy56 = yylhsminor.yy56; + case 316: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ +{ yymsp[-9].minor.yy80 = createIndexOption(pCxt, yymsp[-7].minor.yy106, releaseRawExprNode(pCxt, yymsp[-3].minor.yy80), NULL, yymsp[-1].minor.yy80, yymsp[0].minor.yy80); } break; - case 318: /* sma_func_name ::= function_name */ - case 537: /* alias_opt ::= table_alias */ yytestcase(yyruleno==537); + case 317: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ +{ yymsp[-11].minor.yy80 = createIndexOption(pCxt, yymsp[-9].minor.yy106, releaseRawExprNode(pCxt, yymsp[-5].minor.yy80), releaseRawExprNode(pCxt, yymsp[-3].minor.yy80), yymsp[-1].minor.yy80, yymsp[0].minor.yy80); } + break; + case 320: /* func ::= sma_func_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy80 = createFunctionNode(pCxt, &yymsp[-3].minor.yy785, yymsp[-1].minor.yy106); } + yymsp[-3].minor.yy80 = yylhsminor.yy80; + break; + case 321: /* sma_func_name ::= function_name */ + case 545: /* alias_opt ::= table_alias */ yytestcase(yyruleno==545); { yylhsminor.yy785 = yymsp[0].minor.yy785; } yymsp[0].minor.yy785 = yylhsminor.yy785; break; - case 323: /* sma_stream_opt ::= */ - case 364: /* stream_options ::= */ yytestcase(yyruleno==364); -{ yymsp[1].minor.yy56 = createStreamOptions(pCxt); } + case 326: /* sma_stream_opt ::= */ + case 371: /* stream_options ::= */ yytestcase(yyruleno==371); +{ yymsp[1].minor.yy80 = createStreamOptions(pCxt); } break; - case 324: /* sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy56)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy56); yylhsminor.yy56 = yymsp[-2].minor.yy56; } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 327: /* sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ +{ ((SStreamOptions*)yymsp[-2].minor.yy80)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy80); yylhsminor.yy80 = yymsp[-2].minor.yy80; } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 325: /* sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy56)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy56); yylhsminor.yy56 = yymsp[-2].minor.yy56; } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 328: /* sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ +{ ((SStreamOptions*)yymsp[-2].minor.yy80)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy80); yylhsminor.yy80 = yymsp[-2].minor.yy80; } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 326: /* sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy56)->pDeleteMark = releaseRawExprNode(pCxt, yymsp[0].minor.yy56); yylhsminor.yy56 = yymsp[-2].minor.yy56; } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 329: /* sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ +{ ((SStreamOptions*)yymsp[-2].minor.yy80)->pDeleteMark = releaseRawExprNode(pCxt, yymsp[0].minor.yy80); yylhsminor.yy80 = yymsp[-2].minor.yy80; } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 327: /* with_meta ::= AS */ -{ yymsp[0].minor.yy676 = 0; } + case 330: /* with_meta ::= AS */ +{ yymsp[0].minor.yy982 = 0; } break; - case 328: /* with_meta ::= WITH META AS */ -{ yymsp[-2].minor.yy676 = 1; } + case 331: /* with_meta ::= WITH META AS */ +{ yymsp[-2].minor.yy982 = 1; } break; - case 329: /* with_meta ::= ONLY META AS */ -{ yymsp[-2].minor.yy676 = 2; } + case 332: /* with_meta ::= ONLY META AS */ +{ yymsp[-2].minor.yy982 = 2; } break; - case 330: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ -{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy425, &yymsp[-2].minor.yy785, yymsp[0].minor.yy56); } + case 333: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ +{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy923, &yymsp[-2].minor.yy785, yymsp[0].minor.yy80); } break; - case 331: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy425, &yymsp[-3].minor.yy785, &yymsp[0].minor.yy785, yymsp[-2].minor.yy676); } + case 334: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy923, &yymsp[-3].minor.yy785, &yymsp[0].minor.yy785, yymsp[-2].minor.yy982); } break; - case 332: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-5].minor.yy425, &yymsp[-4].minor.yy785, yymsp[-1].minor.yy56, yymsp[-3].minor.yy676, yymsp[0].minor.yy56); } + case 335: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-5].minor.yy923, &yymsp[-4].minor.yy785, yymsp[-1].minor.yy80, yymsp[-3].minor.yy982, yymsp[0].minor.yy80); } break; - case 333: /* cmd ::= DROP TOPIC exists_opt topic_name */ -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy425, &yymsp[0].minor.yy785); } + case 336: /* cmd ::= DROP TOPIC exists_opt topic_name */ +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy923, &yymsp[0].minor.yy785); } break; - case 334: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ -{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy425, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy785); } + case 337: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ +{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy923, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy785); } break; - case 335: /* cmd ::= DESC full_table_name */ - case 336: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==336); -{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy56); } + case 338: /* cmd ::= DESC full_table_name */ + case 339: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==339); +{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy80); } break; - case 337: /* cmd ::= RESET QUERY CACHE */ + case 340: /* cmd ::= RESET QUERY CACHE */ { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } break; - case 338: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ - case 339: /* cmd ::= EXPLAIN analyze_opt explain_options insert_query */ yytestcase(yyruleno==339); -{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy425, yymsp[-1].minor.yy56, yymsp[0].minor.yy56); } + case 341: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ + case 342: /* cmd ::= EXPLAIN analyze_opt explain_options insert_query */ yytestcase(yyruleno==342); +{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy923, yymsp[-1].minor.yy80, yymsp[0].minor.yy80); } break; - case 342: /* explain_options ::= */ -{ yymsp[1].minor.yy56 = createDefaultExplainOptions(pCxt); } + case 345: /* explain_options ::= */ +{ yymsp[1].minor.yy80 = createDefaultExplainOptions(pCxt); } break; - case 343: /* explain_options ::= explain_options VERBOSE NK_BOOL */ -{ yylhsminor.yy56 = setExplainVerbose(pCxt, yymsp[-2].minor.yy56, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 346: /* explain_options ::= explain_options VERBOSE NK_BOOL */ +{ yylhsminor.yy80 = setExplainVerbose(pCxt, yymsp[-2].minor.yy80, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 344: /* explain_options ::= explain_options RATIO NK_FLOAT */ -{ yylhsminor.yy56 = setExplainRatio(pCxt, yymsp[-2].minor.yy56, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 347: /* explain_options ::= explain_options RATIO NK_FLOAT */ +{ yylhsminor.yy80 = setExplainRatio(pCxt, yymsp[-2].minor.yy80, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 345: /* cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ -{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-7].minor.yy425, yymsp[-9].minor.yy425, &yymsp[-6].minor.yy785, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy448, yymsp[-1].minor.yy676, &yymsp[0].minor.yy785, yymsp[-10].minor.yy425); } + case 348: /* cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ +{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-7].minor.yy923, yymsp[-9].minor.yy923, &yymsp[-6].minor.yy785, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy292, yymsp[-1].minor.yy982, &yymsp[0].minor.yy785, yymsp[-10].minor.yy923); } break; - case 346: /* cmd ::= DROP FUNCTION exists_opt function_name */ -{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy425, &yymsp[0].minor.yy785); } + case 349: /* cmd ::= DROP FUNCTION exists_opt function_name */ +{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy923, &yymsp[0].minor.yy785); } break; - case 351: /* language_opt ::= */ - case 385: /* on_vgroup_id ::= */ yytestcase(yyruleno==385); + case 354: /* language_opt ::= */ + case 392: /* on_vgroup_id ::= */ yytestcase(yyruleno==392); { yymsp[1].minor.yy785 = nil_token; } break; - case 352: /* language_opt ::= LANGUAGE NK_STRING */ - case 386: /* on_vgroup_id ::= ON NK_INTEGER */ yytestcase(yyruleno==386); + case 355: /* language_opt ::= LANGUAGE NK_STRING */ + case 393: /* on_vgroup_id ::= ON NK_INTEGER */ yytestcase(yyruleno==393); { yymsp[-1].minor.yy785 = yymsp[0].minor.yy0; } break; - case 355: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery */ -{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-9].minor.yy425, &yymsp[-8].minor.yy785, yymsp[-5].minor.yy56, yymsp[-7].minor.yy56, yymsp[-3].minor.yy712, yymsp[-2].minor.yy56, yymsp[0].minor.yy56, yymsp[-4].minor.yy712); } + case 358: /* cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ +{ pCxt->pRootNode = createCreateViewStmt(pCxt, yymsp[-4].minor.yy923, yymsp[-2].minor.yy80, &yymsp[-1].minor.yy0, yymsp[0].minor.yy80); } break; - case 356: /* cmd ::= DROP STREAM exists_opt stream_name */ -{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy425, &yymsp[0].minor.yy785); } + case 359: /* cmd ::= DROP VIEW exists_opt full_view_name */ +{ pCxt->pRootNode = createDropViewStmt(pCxt, yymsp[-1].minor.yy923, yymsp[0].minor.yy80); } break; - case 357: /* cmd ::= PAUSE STREAM exists_opt stream_name */ -{ pCxt->pRootNode = createPauseStreamStmt(pCxt, yymsp[-1].minor.yy425, &yymsp[0].minor.yy785); } + case 360: /* full_view_name ::= view_name */ +{ yylhsminor.yy80 = createViewNode(pCxt, NULL, &yymsp[0].minor.yy785); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 358: /* cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ -{ pCxt->pRootNode = createResumeStreamStmt(pCxt, yymsp[-2].minor.yy425, yymsp[-1].minor.yy425, &yymsp[0].minor.yy785); } + case 361: /* full_view_name ::= db_name NK_DOT view_name */ +{ yylhsminor.yy80 = createViewNode(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy785); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 365: /* stream_options ::= stream_options TRIGGER AT_ONCE */ - case 366: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ yytestcase(yyruleno==366); -{ yylhsminor.yy56 = setStreamOptions(pCxt, yymsp[-2].minor.yy56, SOPT_TRIGGER_TYPE_SET, &yymsp[0].minor.yy0, NULL); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 362: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery */ +{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-9].minor.yy923, &yymsp[-8].minor.yy785, yymsp[-5].minor.yy80, yymsp[-7].minor.yy80, yymsp[-3].minor.yy106, yymsp[-2].minor.yy80, yymsp[0].minor.yy80, yymsp[-4].minor.yy106); } break; - case 367: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ -{ yylhsminor.yy56 = setStreamOptions(pCxt, yymsp[-3].minor.yy56, SOPT_TRIGGER_TYPE_SET, &yymsp[-1].minor.yy0, releaseRawExprNode(pCxt, yymsp[0].minor.yy56)); } - yymsp[-3].minor.yy56 = yylhsminor.yy56; + case 363: /* cmd ::= DROP STREAM exists_opt stream_name */ +{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy923, &yymsp[0].minor.yy785); } break; - case 368: /* stream_options ::= stream_options WATERMARK duration_literal */ -{ yylhsminor.yy56 = setStreamOptions(pCxt, yymsp[-2].minor.yy56, SOPT_WATERMARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy56)); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 364: /* cmd ::= PAUSE STREAM exists_opt stream_name */ +{ pCxt->pRootNode = createPauseStreamStmt(pCxt, yymsp[-1].minor.yy923, &yymsp[0].minor.yy785); } break; - case 369: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ -{ yylhsminor.yy56 = setStreamOptions(pCxt, yymsp[-3].minor.yy56, SOPT_IGNORE_EXPIRED_SET, &yymsp[0].minor.yy0, NULL); } - yymsp[-3].minor.yy56 = yylhsminor.yy56; + case 365: /* cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ +{ pCxt->pRootNode = createResumeStreamStmt(pCxt, yymsp[-2].minor.yy923, yymsp[-1].minor.yy923, &yymsp[0].minor.yy785); } break; - case 370: /* stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ -{ yylhsminor.yy56 = setStreamOptions(pCxt, yymsp[-2].minor.yy56, SOPT_FILL_HISTORY_SET, &yymsp[0].minor.yy0, NULL); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 372: /* stream_options ::= stream_options TRIGGER AT_ONCE */ + case 373: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ yytestcase(yyruleno==373); +{ yylhsminor.yy80 = setStreamOptions(pCxt, yymsp[-2].minor.yy80, SOPT_TRIGGER_TYPE_SET, &yymsp[0].minor.yy0, NULL); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 371: /* stream_options ::= stream_options DELETE_MARK duration_literal */ -{ yylhsminor.yy56 = setStreamOptions(pCxt, yymsp[-2].minor.yy56, SOPT_DELETE_MARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy56)); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 374: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ +{ yylhsminor.yy80 = setStreamOptions(pCxt, yymsp[-3].minor.yy80, SOPT_TRIGGER_TYPE_SET, &yymsp[-1].minor.yy0, releaseRawExprNode(pCxt, yymsp[0].minor.yy80)); } + yymsp[-3].minor.yy80 = yylhsminor.yy80; break; - case 372: /* stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ -{ yylhsminor.yy56 = setStreamOptions(pCxt, yymsp[-3].minor.yy56, SOPT_IGNORE_UPDATE_SET, &yymsp[0].minor.yy0, NULL); } - yymsp[-3].minor.yy56 = yylhsminor.yy56; + case 375: /* stream_options ::= stream_options WATERMARK duration_literal */ +{ yylhsminor.yy80 = setStreamOptions(pCxt, yymsp[-2].minor.yy80, SOPT_WATERMARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy80)); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 374: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - case 575: /* sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ yytestcase(yyruleno==575); - case 599: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==599); -{ yymsp[-3].minor.yy56 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy56); } + case 376: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ +{ yylhsminor.yy80 = setStreamOptions(pCxt, yymsp[-3].minor.yy80, SOPT_IGNORE_EXPIRED_SET, &yymsp[0].minor.yy0, NULL); } + yymsp[-3].minor.yy80 = yylhsminor.yy80; break; - case 377: /* cmd ::= KILL CONNECTION NK_INTEGER */ + case 377: /* stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ +{ yylhsminor.yy80 = setStreamOptions(pCxt, yymsp[-2].minor.yy80, SOPT_FILL_HISTORY_SET, &yymsp[0].minor.yy0, NULL); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; + break; + case 378: /* stream_options ::= stream_options DELETE_MARK duration_literal */ +{ yylhsminor.yy80 = setStreamOptions(pCxt, yymsp[-2].minor.yy80, SOPT_DELETE_MARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy80)); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; + break; + case 379: /* stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ +{ yylhsminor.yy80 = setStreamOptions(pCxt, yymsp[-3].minor.yy80, SOPT_IGNORE_UPDATE_SET, &yymsp[0].minor.yy0, NULL); } + yymsp[-3].minor.yy80 = yylhsminor.yy80; + break; + case 381: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + case 583: /* sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ yytestcase(yyruleno==583); + case 607: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==607); +{ yymsp[-3].minor.yy80 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy80); } + break; + case 384: /* cmd ::= KILL CONNECTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } break; - case 378: /* cmd ::= KILL QUERY NK_STRING */ + case 385: /* cmd ::= KILL QUERY NK_STRING */ { pCxt->pRootNode = createKillQueryStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 379: /* cmd ::= KILL TRANSACTION NK_INTEGER */ + case 386: /* cmd ::= KILL TRANSACTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &yymsp[0].minor.yy0); } break; - case 380: /* cmd ::= BALANCE VGROUP */ + case 387: /* cmd ::= BALANCE VGROUP */ { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); } break; - case 381: /* cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ + case 388: /* cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ { pCxt->pRootNode = createBalanceVgroupLeaderStmt(pCxt, &yymsp[0].minor.yy785); } break; - case 382: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + case 389: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 383: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ -{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy712); } + case 390: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ +{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy106); } break; - case 384: /* cmd ::= SPLIT VGROUP NK_INTEGER */ + case 391: /* cmd ::= SPLIT VGROUP NK_INTEGER */ { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 387: /* dnode_list ::= DNODE NK_INTEGER */ -{ yymsp[-1].minor.yy712 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + case 394: /* dnode_list ::= DNODE NK_INTEGER */ +{ yymsp[-1].minor.yy106 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } break; - case 389: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ -{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy56, yymsp[0].minor.yy56); } + case 396: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ +{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy80, yymsp[0].minor.yy80); } break; - case 392: /* insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ -{ yymsp[-6].minor.yy56 = createInsertStmt(pCxt, yymsp[-4].minor.yy56, yymsp[-2].minor.yy712, yymsp[0].minor.yy56); } + case 399: /* insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ +{ yymsp[-6].minor.yy80 = createInsertStmt(pCxt, yymsp[-4].minor.yy80, yymsp[-2].minor.yy106, yymsp[0].minor.yy80); } break; - case 393: /* insert_query ::= INSERT INTO full_table_name query_or_subquery */ -{ yymsp[-3].minor.yy56 = createInsertStmt(pCxt, yymsp[-1].minor.yy56, NULL, yymsp[0].minor.yy56); } + case 400: /* insert_query ::= INSERT INTO full_table_name query_or_subquery */ +{ yymsp[-3].minor.yy80 = createInsertStmt(pCxt, yymsp[-1].minor.yy80, NULL, yymsp[0].minor.yy80); } break; - case 394: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy56 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy56 = yylhsminor.yy56; + case 401: /* literal ::= NK_INTEGER */ +{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 395: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy56 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy56 = yylhsminor.yy56; + case 402: /* literal ::= NK_FLOAT */ +{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 396: /* literal ::= NK_STRING */ -{ yylhsminor.yy56 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy56 = yylhsminor.yy56; + case 403: /* literal ::= NK_STRING */ +{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 397: /* literal ::= NK_BOOL */ -{ yylhsminor.yy56 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy56 = yylhsminor.yy56; + case 404: /* literal ::= NK_BOOL */ +{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 398: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy56 = yylhsminor.yy56; + case 405: /* literal ::= TIMESTAMP NK_STRING */ +{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy80 = yylhsminor.yy80; break; - case 399: /* literal ::= duration_literal */ - case 409: /* signed_literal ::= signed */ yytestcase(yyruleno==409); - case 431: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==431); - case 432: /* expression ::= literal */ yytestcase(yyruleno==432); - case 434: /* expression ::= column_reference */ yytestcase(yyruleno==434); - case 435: /* expression ::= function_expression */ yytestcase(yyruleno==435); - case 436: /* expression ::= case_when_expression */ yytestcase(yyruleno==436); - case 469: /* function_expression ::= literal_func */ yytestcase(yyruleno==469); - case 518: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==518); - case 522: /* boolean_primary ::= predicate */ yytestcase(yyruleno==522); - case 524: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==524); - case 525: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==525); - case 528: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==528); - case 530: /* table_reference ::= table_primary */ yytestcase(yyruleno==530); - case 531: /* table_reference ::= joined_table */ yytestcase(yyruleno==531); - case 535: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==535); - case 601: /* query_simple ::= query_specification */ yytestcase(yyruleno==601); - case 602: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==602); - case 605: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==605); - case 607: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==607); -{ yylhsminor.yy56 = yymsp[0].minor.yy56; } - yymsp[0].minor.yy56 = yylhsminor.yy56; + case 406: /* literal ::= duration_literal */ + case 416: /* signed_literal ::= signed */ yytestcase(yyruleno==416); + case 439: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==439); + case 440: /* expression ::= literal */ yytestcase(yyruleno==440); + case 442: /* expression ::= column_reference */ yytestcase(yyruleno==442); + case 443: /* expression ::= function_expression */ yytestcase(yyruleno==443); + case 444: /* expression ::= case_when_expression */ yytestcase(yyruleno==444); + case 477: /* function_expression ::= literal_func */ yytestcase(yyruleno==477); + case 526: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==526); + case 530: /* boolean_primary ::= predicate */ yytestcase(yyruleno==530); + case 532: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==532); + case 533: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==533); + case 536: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==536); + case 538: /* table_reference ::= table_primary */ yytestcase(yyruleno==538); + case 539: /* table_reference ::= joined_table */ yytestcase(yyruleno==539); + case 543: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==543); + case 609: /* query_simple ::= query_specification */ yytestcase(yyruleno==609); + case 610: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==610); + case 613: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==613); + case 615: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==615); +{ yylhsminor.yy80 = yymsp[0].minor.yy80; } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 400: /* literal ::= NULL */ -{ yylhsminor.yy56 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy56 = yylhsminor.yy56; + case 407: /* literal ::= NULL */ +{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 401: /* literal ::= NK_QUESTION */ -{ yylhsminor.yy56 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy56 = yylhsminor.yy56; + case 408: /* literal ::= NK_QUESTION */ +{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 402: /* duration_literal ::= NK_VARIABLE */ - case 576: /* interval_sliding_duration_literal ::= NK_VARIABLE */ yytestcase(yyruleno==576); - case 577: /* interval_sliding_duration_literal ::= NK_STRING */ yytestcase(yyruleno==577); - case 578: /* interval_sliding_duration_literal ::= NK_INTEGER */ yytestcase(yyruleno==578); -{ yylhsminor.yy56 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy56 = yylhsminor.yy56; + case 409: /* duration_literal ::= NK_VARIABLE */ + case 584: /* interval_sliding_duration_literal ::= NK_VARIABLE */ yytestcase(yyruleno==584); + case 585: /* interval_sliding_duration_literal ::= NK_STRING */ yytestcase(yyruleno==585); + case 586: /* interval_sliding_duration_literal ::= NK_INTEGER */ yytestcase(yyruleno==586); +{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 403: /* signed ::= NK_INTEGER */ -{ yylhsminor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy56 = yylhsminor.yy56; + case 410: /* signed ::= NK_INTEGER */ +{ yylhsminor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 404: /* signed ::= NK_PLUS NK_INTEGER */ -{ yymsp[-1].minor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } + case 411: /* signed ::= NK_PLUS NK_INTEGER */ +{ yymsp[-1].minor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } break; - case 405: /* signed ::= NK_MINUS NK_INTEGER */ + case 412: /* signed ::= NK_MINUS NK_INTEGER */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); + yylhsminor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } - yymsp[-1].minor.yy56 = yylhsminor.yy56; + yymsp[-1].minor.yy80 = yylhsminor.yy80; break; - case 406: /* signed ::= NK_FLOAT */ -{ yylhsminor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy56 = yylhsminor.yy56; + case 413: /* signed ::= NK_FLOAT */ +{ yylhsminor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 407: /* signed ::= NK_PLUS NK_FLOAT */ -{ yymsp[-1].minor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + case 414: /* signed ::= NK_PLUS NK_FLOAT */ +{ yymsp[-1].minor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } break; - case 408: /* signed ::= NK_MINUS NK_FLOAT */ + case 415: /* signed ::= NK_MINUS NK_FLOAT */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); + yylhsminor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } - yymsp[-1].minor.yy56 = yylhsminor.yy56; + yymsp[-1].minor.yy80 = yylhsminor.yy80; break; - case 410: /* signed_literal ::= NK_STRING */ -{ yylhsminor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy56 = yylhsminor.yy56; + case 417: /* signed_literal ::= NK_STRING */ +{ yylhsminor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 411: /* signed_literal ::= NK_BOOL */ -{ yylhsminor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy56 = yylhsminor.yy56; + case 418: /* signed_literal ::= NK_BOOL */ +{ yylhsminor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 412: /* signed_literal ::= TIMESTAMP NK_STRING */ -{ yymsp[-1].minor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } + case 419: /* signed_literal ::= TIMESTAMP NK_STRING */ +{ yymsp[-1].minor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } break; - case 413: /* signed_literal ::= duration_literal */ - case 415: /* signed_literal ::= literal_func */ yytestcase(yyruleno==415); - case 489: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==489); - case 555: /* select_item ::= common_expression */ yytestcase(yyruleno==555); - case 565: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==565); - case 606: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==606); - case 608: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==608); - case 621: /* search_condition ::= common_expression */ yytestcase(yyruleno==621); -{ yylhsminor.yy56 = releaseRawExprNode(pCxt, yymsp[0].minor.yy56); } - yymsp[0].minor.yy56 = yylhsminor.yy56; + case 420: /* signed_literal ::= duration_literal */ + case 422: /* signed_literal ::= literal_func */ yytestcase(yyruleno==422); + case 497: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==497); + case 563: /* select_item ::= common_expression */ yytestcase(yyruleno==563); + case 573: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==573); + case 614: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==614); + case 616: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==616); + case 629: /* search_condition ::= common_expression */ yytestcase(yyruleno==629); +{ yylhsminor.yy80 = releaseRawExprNode(pCxt, yymsp[0].minor.yy80); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 414: /* signed_literal ::= NULL */ -{ yylhsminor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy56 = yylhsminor.yy56; + case 421: /* signed_literal ::= NULL */ +{ yylhsminor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 416: /* signed_literal ::= NK_QUESTION */ -{ yylhsminor.yy56 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy56 = yylhsminor.yy56; + case 423: /* signed_literal ::= NK_QUESTION */ +{ yylhsminor.yy80 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 433: /* expression ::= pseudo_column */ -{ yylhsminor.yy56 = yymsp[0].minor.yy56; setRawExprNodeIsPseudoColumn(pCxt, yylhsminor.yy56, true); } - yymsp[0].minor.yy56 = yylhsminor.yy56; + case 441: /* expression ::= pseudo_column */ +{ yylhsminor.yy80 = yymsp[0].minor.yy80; setRawExprNodeIsPseudoColumn(pCxt, yylhsminor.yy80, true); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 437: /* expression ::= NK_LP expression NK_RP */ - case 523: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==523); - case 620: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==620); -{ yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy56)); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 445: /* expression ::= NK_LP expression NK_RP */ + case 531: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==531); + case 628: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==628); +{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy80)); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 438: /* expression ::= NK_PLUS expr_or_subquery */ + case 446: /* expression ::= NK_PLUS expr_or_subquery */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy56); - yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy56)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); + yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy80)); } - yymsp[-1].minor.yy56 = yylhsminor.yy56; + yymsp[-1].minor.yy80 = yylhsminor.yy80; break; - case 439: /* expression ::= NK_MINUS expr_or_subquery */ + case 447: /* expression ::= NK_MINUS expr_or_subquery */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy56); - yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy56), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); + yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy80), NULL)); } - yymsp[-1].minor.yy56 = yylhsminor.yy56; + yymsp[-1].minor.yy80 = yylhsminor.yy80; break; - case 440: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + case 448: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy56); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy56); - yylhsminor.yy56 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), releaseRawExprNode(pCxt, yymsp[0].minor.yy56))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); + yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 441: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + case 449: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy56); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy56); - yylhsminor.yy56 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), releaseRawExprNode(pCxt, yymsp[0].minor.yy56))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); + yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 442: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + case 450: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy56); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy56); - yylhsminor.yy56 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), releaseRawExprNode(pCxt, yymsp[0].minor.yy56))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); + yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 443: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + case 451: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy56); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy56); - yylhsminor.yy56 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), releaseRawExprNode(pCxt, yymsp[0].minor.yy56))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); + yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 444: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ + case 452: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy56); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy56); - yylhsminor.yy56 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), releaseRawExprNode(pCxt, yymsp[0].minor.yy56))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); + yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 445: /* expression ::= column_reference NK_ARROW NK_STRING */ + case 453: /* expression ::= column_reference NK_ARROW NK_STRING */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy56); - yylhsminor.yy56 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80); + yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 446: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + case 454: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy56); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy56); - yylhsminor.yy56 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), releaseRawExprNode(pCxt, yymsp[0].minor.yy56))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); + yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 447: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + case 455: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy56); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy56); - yylhsminor.yy56 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), releaseRawExprNode(pCxt, yymsp[0].minor.yy56))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); + yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 450: /* column_reference ::= column_name */ -{ yylhsminor.yy56 = createRawExprNode(pCxt, &yymsp[0].minor.yy785, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy785)); } - yymsp[0].minor.yy56 = yylhsminor.yy56; + case 458: /* column_reference ::= column_name */ +{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy785, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy785)); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 451: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy785, createColumnNode(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy785)); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 459: /* column_reference ::= table_name NK_DOT column_name */ +{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy785, createColumnNode(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy785)); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 452: /* column_reference ::= NK_ALIAS */ -{ yylhsminor.yy56 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy56 = yylhsminor.yy56; + case 460: /* column_reference ::= NK_ALIAS */ +{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 453: /* column_reference ::= table_name NK_DOT NK_ALIAS */ -{ yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy0, createColumnNode(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 461: /* column_reference ::= table_name NK_DOT NK_ALIAS */ +{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy0, createColumnNode(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 454: /* pseudo_column ::= ROWTS */ - case 455: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==455); - case 457: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==457); - case 458: /* pseudo_column ::= QEND */ yytestcase(yyruleno==458); - case 459: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==459); - case 460: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==460); - case 461: /* pseudo_column ::= WEND */ yytestcase(yyruleno==461); - case 462: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==462); - case 463: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==463); - case 464: /* pseudo_column ::= ISFILLED */ yytestcase(yyruleno==464); - case 465: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==465); - case 471: /* literal_func ::= NOW */ yytestcase(yyruleno==471); -{ yylhsminor.yy56 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } - yymsp[0].minor.yy56 = yylhsminor.yy56; + case 462: /* pseudo_column ::= ROWTS */ + case 463: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==463); + case 465: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==465); + case 466: /* pseudo_column ::= QEND */ yytestcase(yyruleno==466); + case 467: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==467); + case 468: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==468); + case 469: /* pseudo_column ::= WEND */ yytestcase(yyruleno==469); + case 470: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==470); + case 471: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==471); + case 472: /* pseudo_column ::= ISFILLED */ yytestcase(yyruleno==472); + case 473: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==473); + case 479: /* literal_func ::= NOW */ yytestcase(yyruleno==479); +{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 456: /* pseudo_column ::= table_name NK_DOT TBNAME */ -{ yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy785)))); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 464: /* pseudo_column ::= table_name NK_DOT TBNAME */ +{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy785)))); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 466: /* function_expression ::= function_name NK_LP expression_list NK_RP */ - case 467: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==467); -{ yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy785, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy785, yymsp[-1].minor.yy712)); } - yymsp[-3].minor.yy56 = yylhsminor.yy56; + case 474: /* function_expression ::= function_name NK_LP expression_list NK_RP */ + case 475: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==475); +{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy785, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy785, yymsp[-1].minor.yy106)); } + yymsp[-3].minor.yy80 = yylhsminor.yy80; break; - case 468: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ -{ yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy56), yymsp[-1].minor.yy448)); } - yymsp[-5].minor.yy56 = yylhsminor.yy56; + case 476: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ +{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy80), yymsp[-1].minor.yy292)); } + yymsp[-5].minor.yy80 = yylhsminor.yy80; break; - case 470: /* literal_func ::= noarg_func NK_LP NK_RP */ -{ yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy785, NULL)); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 478: /* literal_func ::= noarg_func NK_LP NK_RP */ +{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy785, NULL)); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 485: /* star_func_para_list ::= NK_STAR */ -{ yylhsminor.yy712 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy712 = yylhsminor.yy712; + case 493: /* star_func_para_list ::= NK_STAR */ +{ yylhsminor.yy106 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy106 = yylhsminor.yy106; break; - case 490: /* star_func_para ::= table_name NK_DOT NK_STAR */ - case 558: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==558); -{ yylhsminor.yy56 = createColumnNode(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 498: /* star_func_para ::= table_name NK_DOT NK_STAR */ + case 566: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==566); +{ yylhsminor.yy80 = createColumnNode(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 491: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ -{ yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy712, yymsp[-1].minor.yy56)); } - yymsp[-3].minor.yy56 = yylhsminor.yy56; + case 499: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ +{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy106, yymsp[-1].minor.yy80)); } + yymsp[-3].minor.yy80 = yylhsminor.yy80; break; - case 492: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ -{ yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy56), yymsp[-2].minor.yy712, yymsp[-1].minor.yy56)); } - yymsp[-4].minor.yy56 = yylhsminor.yy56; + case 500: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ +{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy80), yymsp[-2].minor.yy106, yymsp[-1].minor.yy80)); } + yymsp[-4].minor.yy80 = yylhsminor.yy80; break; - case 495: /* when_then_expr ::= WHEN common_expression THEN common_expression */ -{ yymsp[-3].minor.yy56 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), releaseRawExprNode(pCxt, yymsp[0].minor.yy56)); } + case 503: /* when_then_expr ::= WHEN common_expression THEN common_expression */ +{ yymsp[-3].minor.yy80 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80)); } break; - case 497: /* case_when_else_opt ::= ELSE common_expression */ -{ yymsp[-1].minor.yy56 = releaseRawExprNode(pCxt, yymsp[0].minor.yy56); } + case 505: /* case_when_else_opt ::= ELSE common_expression */ +{ yymsp[-1].minor.yy80 = releaseRawExprNode(pCxt, yymsp[0].minor.yy80); } break; - case 498: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ - case 503: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==503); + case 506: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ + case 511: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==511); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy56); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy56); - yylhsminor.yy56 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy380, releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), releaseRawExprNode(pCxt, yymsp[0].minor.yy56))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); + yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy428, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 499: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + case 507: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy56); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy56); - yylhsminor.yy56 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy56), releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), releaseRawExprNode(pCxt, yymsp[0].minor.yy56))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy80); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); + yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy80), releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); } - yymsp[-4].minor.yy56 = yylhsminor.yy56; + yymsp[-4].minor.yy80 = yylhsminor.yy80; break; - case 500: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + case 508: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy56); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy56); - yylhsminor.yy56 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy56), releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), releaseRawExprNode(pCxt, yymsp[0].minor.yy56))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy80); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); + yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy80), releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); } - yymsp[-5].minor.yy56 = yylhsminor.yy56; + yymsp[-5].minor.yy80 = yylhsminor.yy80; break; - case 501: /* predicate ::= expr_or_subquery IS NULL */ + case 509: /* predicate ::= expr_or_subquery IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy56); - yylhsminor.yy56 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80); + yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), NULL)); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 502: /* predicate ::= expr_or_subquery IS NOT NULL */ + case 510: /* predicate ::= expr_or_subquery IS NOT NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy56); - yylhsminor.yy56 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy56), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy80); + yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy80), NULL)); } - yymsp[-3].minor.yy56 = yylhsminor.yy56; + yymsp[-3].minor.yy80 = yylhsminor.yy80; break; - case 504: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy380 = OP_TYPE_LOWER_THAN; } + case 512: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy428 = OP_TYPE_LOWER_THAN; } break; - case 505: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy380 = OP_TYPE_GREATER_THAN; } + case 513: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy428 = OP_TYPE_GREATER_THAN; } break; - case 506: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy380 = OP_TYPE_LOWER_EQUAL; } + case 514: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy428 = OP_TYPE_LOWER_EQUAL; } break; - case 507: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy380 = OP_TYPE_GREATER_EQUAL; } + case 515: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy428 = OP_TYPE_GREATER_EQUAL; } break; - case 508: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy380 = OP_TYPE_NOT_EQUAL; } + case 516: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy428 = OP_TYPE_NOT_EQUAL; } break; - case 509: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy380 = OP_TYPE_EQUAL; } + case 517: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy428 = OP_TYPE_EQUAL; } break; - case 510: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy380 = OP_TYPE_LIKE; } + case 518: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy428 = OP_TYPE_LIKE; } break; - case 511: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy380 = OP_TYPE_NOT_LIKE; } + case 519: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy428 = OP_TYPE_NOT_LIKE; } break; - case 512: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy380 = OP_TYPE_MATCH; } + case 520: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy428 = OP_TYPE_MATCH; } break; - case 513: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy380 = OP_TYPE_NMATCH; } + case 521: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy428 = OP_TYPE_NMATCH; } break; - case 514: /* compare_op ::= CONTAINS */ -{ yymsp[0].minor.yy380 = OP_TYPE_JSON_CONTAINS; } + case 522: /* compare_op ::= CONTAINS */ +{ yymsp[0].minor.yy428 = OP_TYPE_JSON_CONTAINS; } break; - case 515: /* in_op ::= IN */ -{ yymsp[0].minor.yy380 = OP_TYPE_IN; } + case 523: /* in_op ::= IN */ +{ yymsp[0].minor.yy428 = OP_TYPE_IN; } break; - case 516: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy380 = OP_TYPE_NOT_IN; } + case 524: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy428 = OP_TYPE_NOT_IN; } break; - case 517: /* in_predicate_value ::= NK_LP literal_list NK_RP */ -{ yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy712)); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 525: /* in_predicate_value ::= NK_LP literal_list NK_RP */ +{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy106)); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 519: /* boolean_value_expression ::= NOT boolean_primary */ + case 527: /* boolean_value_expression ::= NOT boolean_primary */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy56); - yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy56), NULL)); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); + yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy80), NULL)); } - yymsp[-1].minor.yy56 = yylhsminor.yy56; + yymsp[-1].minor.yy80 = yylhsminor.yy80; break; - case 520: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 528: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy56); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy56); - yylhsminor.yy56 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), releaseRawExprNode(pCxt, yymsp[0].minor.yy56))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); + yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 521: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 529: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy56); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy56); - yylhsminor.yy56 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), releaseRawExprNode(pCxt, yymsp[0].minor.yy56))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); + yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 529: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy56 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy56, yymsp[0].minor.yy56, NULL); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 537: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +{ yylhsminor.yy80 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy80, yymsp[0].minor.yy80, NULL); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 532: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy56 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy785, &yymsp[0].minor.yy785); } - yymsp[-1].minor.yy56 = yylhsminor.yy56; + case 540: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy80 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy785, &yymsp[0].minor.yy785); } + yymsp[-1].minor.yy80 = yylhsminor.yy80; break; - case 533: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy56 = createRealTableNode(pCxt, &yymsp[-3].minor.yy785, &yymsp[-1].minor.yy785, &yymsp[0].minor.yy785); } - yymsp[-3].minor.yy56 = yylhsminor.yy56; + case 541: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy80 = createRealTableNode(pCxt, &yymsp[-3].minor.yy785, &yymsp[-1].minor.yy785, &yymsp[0].minor.yy785); } + yymsp[-3].minor.yy80 = yylhsminor.yy80; break; - case 534: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy56 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy56), &yymsp[0].minor.yy785); } - yymsp[-1].minor.yy56 = yylhsminor.yy56; + case 542: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy80 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy80), &yymsp[0].minor.yy785); } + yymsp[-1].minor.yy80 = yylhsminor.yy80; break; - case 536: /* alias_opt ::= */ + case 544: /* alias_opt ::= */ { yymsp[1].minor.yy785 = nil_token; } break; - case 538: /* alias_opt ::= AS table_alias */ + case 546: /* alias_opt ::= AS table_alias */ { yymsp[-1].minor.yy785 = yymsp[0].minor.yy785; } break; - case 539: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 540: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==540); -{ yymsp[-2].minor.yy56 = yymsp[-1].minor.yy56; } + case 547: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 548: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==548); +{ yymsp[-2].minor.yy80 = yymsp[-1].minor.yy80; } break; - case 541: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy56 = createJoinTableNode(pCxt, yymsp[-4].minor.yy36, yymsp[-5].minor.yy56, yymsp[-2].minor.yy56, yymsp[0].minor.yy56); } - yymsp[-5].minor.yy56 = yylhsminor.yy56; + case 549: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy80 = createJoinTableNode(pCxt, yymsp[-4].minor.yy828, yymsp[-5].minor.yy80, yymsp[-2].minor.yy80, yymsp[0].minor.yy80); } + yymsp[-5].minor.yy80 = yylhsminor.yy80; break; - case 542: /* join_type ::= */ -{ yymsp[1].minor.yy36 = JOIN_TYPE_INNER; } + case 550: /* join_type ::= */ +{ yymsp[1].minor.yy828 = JOIN_TYPE_INNER; } break; - case 543: /* join_type ::= INNER */ -{ yymsp[0].minor.yy36 = JOIN_TYPE_INNER; } + case 551: /* join_type ::= INNER */ +{ yymsp[0].minor.yy828 = JOIN_TYPE_INNER; } break; - case 544: /* query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + case 552: /* query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ { - yymsp[-13].minor.yy56 = createSelectStmt(pCxt, yymsp[-11].minor.yy425, yymsp[-9].minor.yy712, yymsp[-8].minor.yy56, yymsp[-12].minor.yy712); - yymsp[-13].minor.yy56 = setSelectStmtTagMode(pCxt, yymsp[-13].minor.yy56, yymsp[-10].minor.yy425); - yymsp[-13].minor.yy56 = addWhereClause(pCxt, yymsp[-13].minor.yy56, yymsp[-7].minor.yy56); - yymsp[-13].minor.yy56 = addPartitionByClause(pCxt, yymsp[-13].minor.yy56, yymsp[-6].minor.yy712); - yymsp[-13].minor.yy56 = addWindowClauseClause(pCxt, yymsp[-13].minor.yy56, yymsp[-2].minor.yy56); - yymsp[-13].minor.yy56 = addGroupByClause(pCxt, yymsp[-13].minor.yy56, yymsp[-1].minor.yy712); - yymsp[-13].minor.yy56 = addHavingClause(pCxt, yymsp[-13].minor.yy56, yymsp[0].minor.yy56); - yymsp[-13].minor.yy56 = addRangeClause(pCxt, yymsp[-13].minor.yy56, yymsp[-5].minor.yy56); - yymsp[-13].minor.yy56 = addEveryClause(pCxt, yymsp[-13].minor.yy56, yymsp[-4].minor.yy56); - yymsp[-13].minor.yy56 = addFillClause(pCxt, yymsp[-13].minor.yy56, yymsp[-3].minor.yy56); + yymsp[-13].minor.yy80 = createSelectStmt(pCxt, yymsp[-11].minor.yy923, yymsp[-9].minor.yy106, yymsp[-8].minor.yy80, yymsp[-12].minor.yy106); + yymsp[-13].minor.yy80 = setSelectStmtTagMode(pCxt, yymsp[-13].minor.yy80, yymsp[-10].minor.yy923); + yymsp[-13].minor.yy80 = addWhereClause(pCxt, yymsp[-13].minor.yy80, yymsp[-7].minor.yy80); + yymsp[-13].minor.yy80 = addPartitionByClause(pCxt, yymsp[-13].minor.yy80, yymsp[-6].minor.yy106); + yymsp[-13].minor.yy80 = addWindowClauseClause(pCxt, yymsp[-13].minor.yy80, yymsp[-2].minor.yy80); + yymsp[-13].minor.yy80 = addGroupByClause(pCxt, yymsp[-13].minor.yy80, yymsp[-1].minor.yy106); + yymsp[-13].minor.yy80 = addHavingClause(pCxt, yymsp[-13].minor.yy80, yymsp[0].minor.yy80); + yymsp[-13].minor.yy80 = addRangeClause(pCxt, yymsp[-13].minor.yy80, yymsp[-5].minor.yy80); + yymsp[-13].minor.yy80 = addEveryClause(pCxt, yymsp[-13].minor.yy80, yymsp[-4].minor.yy80); + yymsp[-13].minor.yy80 = addFillClause(pCxt, yymsp[-13].minor.yy80, yymsp[-3].minor.yy80); } break; - case 545: /* hint_list ::= */ -{ yymsp[1].minor.yy712 = createHintNodeList(pCxt, NULL); } + case 553: /* hint_list ::= */ +{ yymsp[1].minor.yy106 = createHintNodeList(pCxt, NULL); } break; - case 546: /* hint_list ::= NK_HINT */ -{ yylhsminor.yy712 = createHintNodeList(pCxt, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy712 = yylhsminor.yy712; + case 554: /* hint_list ::= NK_HINT */ +{ yylhsminor.yy106 = createHintNodeList(pCxt, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy106 = yylhsminor.yy106; break; - case 551: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy425 = false; } + case 559: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy923 = false; } break; - case 554: /* select_item ::= NK_STAR */ -{ yylhsminor.yy56 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy56 = yylhsminor.yy56; + case 562: /* select_item ::= NK_STAR */ +{ yylhsminor.yy80 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 556: /* select_item ::= common_expression column_alias */ - case 566: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==566); -{ yylhsminor.yy56 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy56), &yymsp[0].minor.yy785); } - yymsp[-1].minor.yy56 = yylhsminor.yy56; + case 564: /* select_item ::= common_expression column_alias */ + case 574: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==574); +{ yylhsminor.yy80 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy80), &yymsp[0].minor.yy785); } + yymsp[-1].minor.yy80 = yylhsminor.yy80; break; - case 557: /* select_item ::= common_expression AS column_alias */ - case 567: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==567); -{ yylhsminor.yy56 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), &yymsp[0].minor.yy785); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 565: /* select_item ::= common_expression AS column_alias */ + case 575: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==575); +{ yylhsminor.yy80 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), &yymsp[0].minor.yy785); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 562: /* partition_by_clause_opt ::= PARTITION BY partition_list */ - case 590: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==590); - case 610: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==610); -{ yymsp[-2].minor.yy712 = yymsp[0].minor.yy712; } + case 570: /* partition_by_clause_opt ::= PARTITION BY partition_list */ + case 598: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==598); + case 618: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==618); +{ yymsp[-2].minor.yy106 = yymsp[0].minor.yy106; } break; - case 569: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ -{ yymsp[-5].minor.yy56 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy56), releaseRawExprNode(pCxt, yymsp[-1].minor.yy56)); } + case 577: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ +{ yymsp[-5].minor.yy80 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy80), releaseRawExprNode(pCxt, yymsp[-1].minor.yy80)); } break; - case 570: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ -{ yymsp[-3].minor.yy56 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy56)); } + case 578: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ +{ yymsp[-3].minor.yy80 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy80)); } break; - case 571: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy56 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy56), NULL, yymsp[-1].minor.yy56, yymsp[0].minor.yy56); } + case 579: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-5].minor.yy80 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy80), NULL, yymsp[-1].minor.yy80, yymsp[0].minor.yy80); } break; - case 572: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy56 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy56), releaseRawExprNode(pCxt, yymsp[-3].minor.yy56), yymsp[-1].minor.yy56, yymsp[0].minor.yy56); } + case 580: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-7].minor.yy80 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy80), releaseRawExprNode(pCxt, yymsp[-3].minor.yy80), yymsp[-1].minor.yy80, yymsp[0].minor.yy80); } break; - case 573: /* twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ -{ yymsp[-6].minor.yy56 = createEventWindowNode(pCxt, yymsp[-3].minor.yy56, yymsp[0].minor.yy56); } + case 581: /* twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ +{ yymsp[-6].minor.yy80 = createEventWindowNode(pCxt, yymsp[-3].minor.yy80, yymsp[0].minor.yy80); } break; - case 580: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy56 = createFillNode(pCxt, yymsp[-1].minor.yy774, NULL); } + case 588: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy80 = createFillNode(pCxt, yymsp[-1].minor.yy36, NULL); } break; - case 581: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ -{ yymsp[-5].minor.yy56 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy712)); } + case 589: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ +{ yymsp[-5].minor.yy80 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy106)); } break; - case 582: /* fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ -{ yymsp[-5].minor.yy56 = createFillNode(pCxt, FILL_MODE_VALUE_F, createNodeListNode(pCxt, yymsp[-1].minor.yy712)); } + case 590: /* fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ +{ yymsp[-5].minor.yy80 = createFillNode(pCxt, FILL_MODE_VALUE_F, createNodeListNode(pCxt, yymsp[-1].minor.yy106)); } break; - case 583: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy774 = FILL_MODE_NONE; } + case 591: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy36 = FILL_MODE_NONE; } break; - case 584: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy774 = FILL_MODE_PREV; } + case 592: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy36 = FILL_MODE_PREV; } break; - case 585: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy774 = FILL_MODE_NULL; } + case 593: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy36 = FILL_MODE_NULL; } break; - case 586: /* fill_mode ::= NULL_F */ -{ yymsp[0].minor.yy774 = FILL_MODE_NULL_F; } + case 594: /* fill_mode ::= NULL_F */ +{ yymsp[0].minor.yy36 = FILL_MODE_NULL_F; } break; - case 587: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy774 = FILL_MODE_LINEAR; } + case 595: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy36 = FILL_MODE_LINEAR; } break; - case 588: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy774 = FILL_MODE_NEXT; } + case 596: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy36 = FILL_MODE_NEXT; } break; - case 591: /* group_by_list ::= expr_or_subquery */ -{ yylhsminor.yy712 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy56))); } - yymsp[0].minor.yy712 = yylhsminor.yy712; + case 599: /* group_by_list ::= expr_or_subquery */ +{ yylhsminor.yy106 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); } + yymsp[0].minor.yy106 = yylhsminor.yy106; break; - case 592: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ -{ yylhsminor.yy712 = addNodeToList(pCxt, yymsp[-2].minor.yy712, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy56))); } - yymsp[-2].minor.yy712 = yylhsminor.yy712; + case 600: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ +{ yylhsminor.yy106 = addNodeToList(pCxt, yymsp[-2].minor.yy106, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); } + yymsp[-2].minor.yy106 = yylhsminor.yy106; break; - case 596: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ -{ yymsp[-5].minor.yy56 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy56), releaseRawExprNode(pCxt, yymsp[-1].minor.yy56)); } + case 604: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ +{ yymsp[-5].minor.yy80 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy80), releaseRawExprNode(pCxt, yymsp[-1].minor.yy80)); } break; - case 597: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ -{ yymsp[-3].minor.yy56 = createInterpTimePoint(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy56)); } + case 605: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ +{ yymsp[-3].minor.yy80 = createInterpTimePoint(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy80)); } break; - case 600: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 608: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ { - yylhsminor.yy56 = addOrderByClause(pCxt, yymsp[-3].minor.yy56, yymsp[-2].minor.yy712); - yylhsminor.yy56 = addSlimitClause(pCxt, yylhsminor.yy56, yymsp[-1].minor.yy56); - yylhsminor.yy56 = addLimitClause(pCxt, yylhsminor.yy56, yymsp[0].minor.yy56); + yylhsminor.yy80 = addOrderByClause(pCxt, yymsp[-3].minor.yy80, yymsp[-2].minor.yy106); + yylhsminor.yy80 = addSlimitClause(pCxt, yylhsminor.yy80, yymsp[-1].minor.yy80); + yylhsminor.yy80 = addLimitClause(pCxt, yylhsminor.yy80, yymsp[0].minor.yy80); } - yymsp[-3].minor.yy56 = yylhsminor.yy56; + yymsp[-3].minor.yy80 = yylhsminor.yy80; break; - case 603: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ -{ yylhsminor.yy56 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy56, yymsp[0].minor.yy56); } - yymsp[-3].minor.yy56 = yylhsminor.yy56; + case 611: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ +{ yylhsminor.yy80 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy80, yymsp[0].minor.yy80); } + yymsp[-3].minor.yy80 = yylhsminor.yy80; break; - case 604: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ -{ yylhsminor.yy56 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy56, yymsp[0].minor.yy56); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 612: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ +{ yylhsminor.yy80 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy80, yymsp[0].minor.yy80); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 612: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 616: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==616); -{ yymsp[-1].minor.yy56 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 620: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 624: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==624); +{ yymsp[-1].minor.yy80 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 613: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 617: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==617); -{ yymsp[-3].minor.yy56 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 621: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 625: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==625); +{ yymsp[-3].minor.yy80 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 614: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 618: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==618); -{ yymsp[-3].minor.yy56 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 622: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 626: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==626); +{ yymsp[-3].minor.yy80 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 619: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy56); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 627: /* subquery ::= NK_LP query_expression NK_RP */ +{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy80); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 624: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy56 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), yymsp[-1].minor.yy722, yymsp[0].minor.yy361); } - yymsp[-2].minor.yy56 = yylhsminor.yy56; + case 632: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy80 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), yymsp[-1].minor.yy812, yymsp[0].minor.yy763); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 625: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy722 = ORDER_ASC; } + case 633: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy812 = ORDER_ASC; } break; - case 626: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy722 = ORDER_ASC; } + case 634: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy812 = ORDER_ASC; } break; - case 627: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy722 = ORDER_DESC; } + case 635: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy812 = ORDER_DESC; } break; - case 628: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy361 = NULL_ORDER_DEFAULT; } + case 636: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy763 = NULL_ORDER_DEFAULT; } break; - case 629: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy361 = NULL_ORDER_FIRST; } + case 637: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy763 = NULL_ORDER_FIRST; } break; - case 630: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy361 = NULL_ORDER_LAST; } + case 638: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy763 = NULL_ORDER_LAST; } break; default: break; diff --git a/source/libs/parser/test/mockCatalog.cpp b/source/libs/parser/test/mockCatalog.cpp index be4f3cd80b..3cabd94c95 100644 --- a/source/libs/parser/test/mockCatalog.cpp +++ b/source/libs/parser/test/mockCatalog.cpp @@ -110,6 +110,10 @@ void generateInformationSchema(MockCatalogService* mcs) { .addColumn("user_name", TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN) .addColumn("privilege", TSDB_DATA_TYPE_BINARY, 10) .done(); + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_VIEWS, TSDB_SYSTEM_TABLE, 2) + .addColumn("view_name", TSDB_DATA_TYPE_BINARY, TSDB_VIEW_NAME_LEN) + .addColumn("create_time", TSDB_DATA_TYPE_TIMESTAMP) + .done(); } void generatePerformanceSchema(MockCatalogService* mcs) { @@ -280,12 +284,12 @@ int32_t __catalogGetDBCfg(SCatalog* pCtg, SRequestConnInfo* pConn, const char* d } int32_t __catalogChkAuth(SCatalog* pCtg, SRequestConnInfo* pConn, SUserAuthInfo *pAuth, SUserAuthRes* pRes) { - pRes->pass = true; + pRes->pass[0] = true; return 0; } int32_t __catalogChkAuthFromCache(SCatalog* pCtg, SUserAuthInfo *pAuth, SUserAuthRes* pRes, bool* exists) { - pRes->pass = true; + pRes->pass[0] = true; *exists = true; return 0; } @@ -301,6 +305,8 @@ int32_t __catalogRefreshGetTableMeta(SCatalog* pCatalog, SRequestConnInfo* pConn int32_t __catalogRemoveTableMeta(SCatalog* pCtg, SName* pTableName) { return 0; } +int32_t __catalogRemoveViewMeta(SCatalog* pCtg, SName* pTableName) { return 0; } + int32_t __catalogGetTableIndex(SCatalog* pCtg, void* pTrans, const SEpSet* pMgmtEps, const SName* pName, SArray** pRes) { return g_mockCatalogService->catalogGetTableIndex(pName, pRes); @@ -337,6 +343,7 @@ void initMetaDataEnv() { stub.set(catalogGetUdfInfo, __catalogGetUdfInfo); stub.set(catalogRefreshGetTableMeta, __catalogRefreshGetTableMeta); stub.set(catalogRemoveTableMeta, __catalogRemoveTableMeta); + stub.set(catalogRemoveViewMeta, __catalogRemoveViewMeta); stub.set(catalogGetTableIndex, __catalogGetTableIndex); stub.set(catalogGetDnodeList, __catalogGetDnodeList); stub.set(catalogRefreshGetTableCfg, __catalogRefreshGetTableCfg); diff --git a/source/libs/parser/test/mockCatalogService.cpp b/source/libs/parser/test/mockCatalogService.cpp index f6a8b407d7..f1b43c535d 100644 --- a/source/libs/parser/test/mockCatalogService.cpp +++ b/source/libs/parser/test/mockCatalogService.cpp @@ -225,6 +225,9 @@ class MockCatalogServiceImpl { if (TSDB_CODE_SUCCESS == code) { code = getAllTableCfg(pCatalogReq->pTableCfg, &pMetaData->pTableCfg); } + if (TSDB_CODE_SUCCESS == code) { + code = getAllViewMeta(pCatalogReq->pView, &pMetaData->pView); + } return code; } @@ -590,7 +593,7 @@ class MockCatalogServiceImpl { for (int32_t i = 0; i < num; ++i) { SMetaRes res = {0}; res.pRes = taosMemoryCalloc(1, sizeof(SUserAuthRes)); - ((SUserAuthRes*)res.pRes)->pass = true; + ((SUserAuthRes*)res.pRes)->pass[0] = true; taosArrayPush(*pUserAuthData, &res); } } @@ -638,6 +641,20 @@ class MockCatalogServiceImpl { return TSDB_CODE_SUCCESS; } + int32_t getAllViewMeta(SArray* pViewMetaReq, SArray** pViewMetaData) const { + if (NULL != pViewMetaReq) { + int32_t nviews = taosArrayGetSize(pViewMetaReq); + *pViewMetaData = taosArrayInit(nviews, sizeof(SMetaRes)); + for (int32_t i = 0; i < nviews; ++i) { + SMetaRes res = {0}; + res.pRes = NULL; + res.code = TSDB_CODE_PAR_TABLE_NOT_EXIST; + taosArrayPush(*pViewMetaData, &res); + } + } + return TSDB_CODE_SUCCESS; + } + int32_t getAllDnodeList(SArray** pDnodes) const { SMetaRes res = {0}; catalogGetDnodeList((SArray**)&res.pRes); diff --git a/source/libs/parser/test/parExplainToSyncdbTest.cpp b/source/libs/parser/test/parExplainToSyncdbTest.cpp index 014374af7e..fbb9ce227c 100644 --- a/source/libs/parser/test/parExplainToSyncdbTest.cpp +++ b/source/libs/parser/test/parExplainToSyncdbTest.cpp @@ -36,8 +36,10 @@ TEST_F(ParserExplainToSyncdbTest, grant) { SAlterUserReq expect = {0}; - auto setAlterUserReq = [&](int8_t alterType, const string& user, const string& obj) { + auto setAlterUserReq = [&](int8_t alterType, int64_t privileges, const string& user, const string& obj) { expect.alterType = alterType; + expect.privileges = privileges; + expect.tabName[0] = 0; snprintf(expect.user, sizeof(expect.user), "%s", user.c_str()); snprintf(expect.objname, sizeof(expect.objname), "%s", obj.c_str()); }; @@ -52,19 +54,22 @@ TEST_F(ParserExplainToSyncdbTest, grant) { ASSERT_EQ(string(req.objname), string(expect.objname)); }); - setAlterUserReq(TSDB_ALTER_USER_ADD_ALL_DB, "wxy", "0.*"); + setAlterUserReq(TSDB_ALTER_USER_ADD_PRIVILEGES, PRIVILEGE_TYPE_ALL, "wxy", "0.*"); run("GRANT ALL ON *.* TO wxy"); - setAlterUserReq(TSDB_ALTER_USER_ADD_READ_DB, "wxy", "0.test"); + setAlterUserReq(TSDB_ALTER_USER_ADD_PRIVILEGES, PRIVILEGE_TYPE_READ, "wxy", "0.test"); run("GRANT READ ON test.* TO wxy"); - setAlterUserReq(TSDB_ALTER_USER_ADD_WRITE_DB, "wxy", "0.test"); + setAlterUserReq(TSDB_ALTER_USER_ADD_PRIVILEGES, PRIVILEGE_TYPE_WRITE, "wxy", "0.test"); run("GRANT WRITE ON test.* TO wxy"); - setAlterUserReq(TSDB_ALTER_USER_ADD_ALL_DB, "wxy", "0.test"); + setAlterUserReq(TSDB_ALTER_USER_ADD_PRIVILEGES, PRIVILEGE_TYPE_ALTER, "wxy", "0.test"); + run("GRANT ALTER ON test.* TO wxy"); + + setAlterUserReq(TSDB_ALTER_USER_ADD_PRIVILEGES, PRIVILEGE_TYPE_READ | PRIVILEGE_TYPE_WRITE, "wxy", "0.test"); run("GRANT READ, WRITE ON test.* TO wxy"); - setAlterUserReq(TSDB_ALTER_USER_ADD_SUBSCRIBE_TOPIC, "wxy", "0.tp1"); + setAlterUserReq(TSDB_ALTER_USER_ADD_PRIVILEGES, PRIVILEGE_TYPE_SUBSCRIBE, "wxy", "0.tp1"); run("GRANT SUBSCRIBE ON tp1 TO wxy"); } @@ -251,8 +256,10 @@ TEST_F(ParserExplainToSyncdbTest, revoke) { SAlterUserReq expect = {0}; - auto setAlterUserReq = [&](int8_t alterType, const string& user, const string& obj) { + auto setAlterUserReq = [&](int8_t alterType, int64_t privileges, const string& user, const string& obj) { expect.alterType = alterType; + expect.privileges = privileges; + expect.tabName[0] = 0; snprintf(expect.user, sizeof(expect.user), "%s", user.c_str()); snprintf(expect.objname, sizeof(expect.objname), "%s", obj.c_str()); }; @@ -267,19 +274,22 @@ TEST_F(ParserExplainToSyncdbTest, revoke) { ASSERT_EQ(string(req.objname), string(expect.objname)); }); - setAlterUserReq(TSDB_ALTER_USER_REMOVE_ALL_DB, "wxy", "0.*"); + setAlterUserReq(TSDB_ALTER_USER_DEL_PRIVILEGES, PRIVILEGE_TYPE_ALL, "wxy", "0.*"); run("REVOKE ALL ON *.* FROM wxy"); - setAlterUserReq(TSDB_ALTER_USER_REMOVE_READ_DB, "wxy", "0.test"); + setAlterUserReq(TSDB_ALTER_USER_DEL_PRIVILEGES, PRIVILEGE_TYPE_READ, "wxy", "0.test"); run("REVOKE READ ON test.* FROM wxy"); - setAlterUserReq(TSDB_ALTER_USER_REMOVE_WRITE_DB, "wxy", "0.test"); + setAlterUserReq(TSDB_ALTER_USER_DEL_PRIVILEGES, PRIVILEGE_TYPE_WRITE, "wxy", "0.test"); run("REVOKE WRITE ON test.* FROM wxy"); - setAlterUserReq(TSDB_ALTER_USER_REMOVE_ALL_DB, "wxy", "0.test"); + setAlterUserReq(TSDB_ALTER_USER_DEL_PRIVILEGES, PRIVILEGE_TYPE_ALTER, "wxy", "0.test"); + run("REVOKE ALTER ON test.* FROM wxy"); + + setAlterUserReq(TSDB_ALTER_USER_DEL_PRIVILEGES, PRIVILEGE_TYPE_READ|PRIVILEGE_TYPE_WRITE, "wxy", "0.test"); run("REVOKE READ, WRITE ON test.* FROM wxy"); - setAlterUserReq(TSDB_ALTER_USER_REMOVE_SUBSCRIBE_TOPIC, "wxy", "0.tp1"); + setAlterUserReq(TSDB_ALTER_USER_DEL_PRIVILEGES, PRIVILEGE_TYPE_SUBSCRIBE, "wxy", "0.tp1"); run("REVOKE SUBSCRIBE ON tp1 FROM wxy"); } diff --git a/source/libs/parser/test/parInitialCTest.cpp b/source/libs/parser/test/parInitialCTest.cpp index 6219676c50..0f6aa22050 100644 --- a/source/libs/parser/test/parInitialCTest.cpp +++ b/source/libs/parser/test/parInitialCTest.cpp @@ -458,6 +458,130 @@ TEST_F(ParserInitialCTest, createFunction) { run("CREATE OR REPLACE AGGREGATE FUNCTION IF NOT EXISTS udf2 AS 'udf' OUTPUTTYPE DOUBLE BUFSIZE 8 LANGUAGE 'python'"); } +/* + * CREATE [ OR REPLACE ] VIEW name [ ( column_name [, ...] ) ] AS query + * + */ +TEST_F(ParserInitialCTest, createView) { + useDb("root", "test"); + + SCMCreateStreamReq expect = {0}; + + auto clearCreateStreamReq = [&]() { + tFreeSCMCreateStreamReq(&expect); + memset(&expect, 0, sizeof(SCMCreateStreamReq)); + }; + + auto setCreateStreamReq = [&](const char* pStream, const char* pSrcDb, const char* pSql, const char* pDstStb, + int8_t igExists = 0) { + snprintf(expect.name, sizeof(expect.name), "0.%s", pStream); + snprintf(expect.sourceDB, sizeof(expect.sourceDB), "0.%s", pSrcDb); + snprintf(expect.targetStbFullName, sizeof(expect.targetStbFullName), "0.test.%s", pDstStb); + expect.igExists = igExists; + expect.sql = taosStrdup(pSql); + }; + + auto setStreamOptions = + [&](int8_t createStb = STREAM_CREATE_STABLE_TRUE, int8_t triggerType = STREAM_TRIGGER_WINDOW_CLOSE, + int64_t maxDelay = 0, int64_t watermark = 0, int8_t igExpired = STREAM_DEFAULT_IGNORE_EXPIRED, + int8_t fillHistory = STREAM_DEFAULT_FILL_HISTORY, int8_t igUpdate = STREAM_DEFAULT_IGNORE_UPDATE) { + expect.createStb = createStb; + expect.triggerType = triggerType; + expect.maxDelay = maxDelay; + expect.watermark = watermark; + expect.fillHistory = fillHistory; + expect.igExpired = igExpired; + expect.igUpdate = igUpdate; + }; + + auto addTag = [&](const char* pFieldName, uint8_t type, int32_t bytes = 0) { + SField field = {0}; + strcpy(field.name, pFieldName); + field.type = type; + field.bytes = bytes > 0 ? bytes : tDataTypes[type].bytes; + field.flags |= COL_SMA_ON; + + if (NULL == expect.pTags) { + expect.pTags = taosArrayInit(TARRAY_MIN_SIZE, sizeof(SField)); + } + taosArrayPush(expect.pTags, &field); + expect.numOfTags += 1; + }; + + setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) { + ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_CREATE_STREAM_STMT); + SCMCreateStreamReq req = {0}; + ASSERT_TRUE(TSDB_CODE_SUCCESS == + tDeserializeSCMCreateStreamReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req)); + + ASSERT_EQ(std::string(req.name), std::string(expect.name)); + ASSERT_EQ(std::string(req.sourceDB), std::string(expect.sourceDB)); + ASSERT_EQ(std::string(req.targetStbFullName), std::string(expect.targetStbFullName)); + ASSERT_EQ(req.igExists, expect.igExists); + ASSERT_EQ(std::string(req.sql), std::string(expect.sql)); + ASSERT_EQ(req.triggerType, expect.triggerType); + ASSERT_EQ(req.maxDelay, expect.maxDelay); + ASSERT_EQ(req.watermark, expect.watermark); + ASSERT_EQ(req.fillHistory, expect.fillHistory); + ASSERT_EQ(req.igExpired, expect.igExpired); + ASSERT_EQ(req.numOfTags, expect.numOfTags); + if (expect.numOfTags > 0) { + ASSERT_EQ(taosArrayGetSize(req.pTags), expect.numOfTags); + ASSERT_EQ(taosArrayGetSize(req.pTags), taosArrayGetSize(expect.pTags)); + for (int32_t i = 0; i < expect.numOfTags; ++i) { + SField* pField = (SField*)taosArrayGet(req.pTags, i); + SField* pExpectField = (SField*)taosArrayGet(expect.pTags, i); + ASSERT_EQ(std::string(pField->name), std::string(pExpectField->name)); + ASSERT_EQ(pField->type, pExpectField->type); + ASSERT_EQ(pField->bytes, pExpectField->bytes); + ASSERT_EQ(pField->flags, pExpectField->flags); + } + } + ASSERT_EQ(req.checkpointFreq, expect.checkpointFreq); + ASSERT_EQ(req.createStb, expect.createStb); + ASSERT_EQ(req.igUpdate, expect.igUpdate); + tFreeSCMCreateStreamReq(&req); + }); + + setCreateStreamReq("s1", "test", "create stream s1 into st3 as select count(*) from t1 interval(10s)", "st3"); + setStreamOptions(); + run("CREATE STREAM s1 INTO st3 AS SELECT COUNT(*) FROM t1 INTERVAL(10S)"); + clearCreateStreamReq(); + + setCreateStreamReq( + "s1", "test", + "create stream if not exists s1 trigger max_delay 20s watermark 10s ignore expired 0 fill_history 0 ignore " + "update 1 into st3 as select count(*) from t1 interval(10s)", + "st3", 1); + setStreamOptions(STREAM_CREATE_STABLE_TRUE, STREAM_TRIGGER_MAX_DELAY, 20 * MILLISECOND_PER_SECOND, + 10 * MILLISECOND_PER_SECOND, 0, 0, 1); + run("CREATE STREAM IF NOT EXISTS s1 TRIGGER MAX_DELAY 20s WATERMARK 10s IGNORE EXPIRED 0 FILL_HISTORY 0 IGNORE " + "UPDATE 1 INTO st3 AS SELECT COUNT(*) FROM t1 INTERVAL(10S)"); + clearCreateStreamReq(); + + setCreateStreamReq("s1", "test", + "create stream s1 into st3 tags(tname varchar(10), id int) subtable(concat('new-', tname)) as " + "select _wstart wstart, count(*) cnt from st1 partition by tbname tname, tag1 id interval(10s)", + "st3"); + addTag("tname", TSDB_DATA_TYPE_VARCHAR, 10 + VARSTR_HEADER_SIZE); + addTag("id", TSDB_DATA_TYPE_INT); + setStreamOptions(); + run("CREATE STREAM s1 INTO st3 TAGS(tname VARCHAR(10), id INT) SUBTABLE(CONCAT('new-', tname)) " + "AS SELECT _WSTART wstart, COUNT(*) cnt FROM st1 PARTITION BY TBNAME tname, tag1 id INTERVAL(10S)"); + clearCreateStreamReq(); + + // st1 already exists + setCreateStreamReq( + "s1", "test", + "create stream s1 into st1 tags(tag2) as select max(c1), c2 from t1 partition by tbname tag2 interval(10s)", + "st1"); + setStreamOptions(STREAM_CREATE_STABLE_FALSE); + run("CREATE STREAM s1 INTO st1 TAGS(tag2) AS SELECT MAX(c1), c2 FROM t1 PARTITION BY TBNAME tag2 INTERVAL(10S)"); + clearCreateStreamReq(); +} + + + /* * CREATE MNODE ON DNODE dnode_id */ diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index 0e56615451..222aec9813 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -568,6 +568,7 @@ static int32_t createJoinLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect if (TSDB_CODE_SUCCESS == code && NULL != pColList) { code = createColumnByRewriteExprs(pColList, &pJoin->node.pTargets); } + nodesDestroyList(pColList); } if (TSDB_CODE_SUCCESS == code) { @@ -587,6 +588,7 @@ static int32_t createJoinLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect if (TSDB_CODE_SUCCESS == code && NULL != pColList) { code = createColumnByRewriteExprs(pColList, &pJoin->node.pTargets); } + nodesDestroyList(pColList); } if (NULL == pJoin->node.pTargets && NULL != pLeft) { diff --git a/source/libs/qcom/src/querymsg.c b/source/libs/qcom/src/querymsg.c index 01b136d5e0..bf87803908 100644 --- a/source/libs/qcom/src/querymsg.c +++ b/source/libs/qcom/src/querymsg.c @@ -286,6 +286,24 @@ int32_t queryBuildGetTbCfgMsg(void *input, char **msg, int32_t msgSize, int32_t return TSDB_CODE_SUCCESS; } +int32_t queryBuildGetViewMetaMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) { + if (NULL == msg || NULL == msgLen) { + return TSDB_CODE_TSC_INVALID_INPUT; + } + + SViewMetaReq req = {0}; + strncpy(req.fullname, input, sizeof(req.fullname) - 1); + + int32_t bufLen = tSerializeSViewMetaReq(NULL, 0, &req); + void *pBuf = (*mallcFp)(bufLen); + tSerializeSViewMetaReq(pBuf, bufLen, &req); + + *msg = pBuf; + *msgLen = bufLen; + + return TSDB_CODE_SUCCESS; +} + int32_t queryProcessUseDBRsp(void *output, char *msg, int32_t msgSize) { SUseDbOutput *pOut = output; SUseDbRsp usedbRsp = {0}; @@ -637,6 +655,27 @@ int32_t queryProcessGetTbCfgRsp(void *output, char *msg, int32_t msgSize) { return TSDB_CODE_SUCCESS; } +int32_t queryProcessGetViewMetaRsp(void *output, char *msg, int32_t msgSize) { + if (NULL == output || NULL == msg || msgSize <= 0) { + return TSDB_CODE_TSC_INVALID_INPUT; + } + + SViewMetaRsp *out = taosMemoryCalloc(1, sizeof(SViewMetaRsp)); + if (tDeserializeSViewMetaRsp(msg, msgSize, out) != 0) { + qError("tDeserializeSViewMetaRsp failed, msgSize:%d", msgSize); + tFreeSViewMetaRsp(out); + taosMemoryFree(out); + return TSDB_CODE_INVALID_MSG; + } + + qDebugL("view meta recved, dbFName:%s, view:%s, querySQL:%s", out->dbFName, out->name, out->querySql); + + *(SViewMetaRsp **)output = out; + + return TSDB_CODE_SUCCESS; +} + + void initQueryModuleMsgHandle() { queryBuildMsg[TMSG_INDEX(TDMT_VND_TABLE_META)] = queryBuildTableMetaReqMsg; queryBuildMsg[TMSG_INDEX(TDMT_MND_TABLE_META)] = queryBuildTableMetaReqMsg; @@ -651,6 +690,7 @@ void initQueryModuleMsgHandle() { queryBuildMsg[TMSG_INDEX(TDMT_VND_TABLE_CFG)] = queryBuildGetTbCfgMsg; queryBuildMsg[TMSG_INDEX(TDMT_MND_TABLE_CFG)] = queryBuildGetTbCfgMsg; queryBuildMsg[TMSG_INDEX(TDMT_MND_SERVER_VERSION)] = queryBuildGetSerVerMsg; + queryBuildMsg[TMSG_INDEX(TDMT_MND_VIEW_META)] = queryBuildGetViewMetaMsg; queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_TABLE_META)] = queryProcessTableMetaRsp; queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_TABLE_META)] = queryProcessTableMetaRsp; @@ -665,6 +705,7 @@ void initQueryModuleMsgHandle() { queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_TABLE_CFG)] = queryProcessGetTbCfgRsp; queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_TABLE_CFG)] = queryProcessGetTbCfgRsp; queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_SERVER_VERSION)] = queryProcessGetSerVerRsp; + queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_VIEW_META)] = queryProcessGetViewMetaRsp; } #pragma GCC diagnostic pop diff --git a/source/libs/scalar/src/filter.c b/source/libs/scalar/src/filter.c index adc3e9fd27..6945029718 100644 --- a/source/libs/scalar/src/filter.c +++ b/source/libs/scalar/src/filter.c @@ -1543,6 +1543,15 @@ EDealRes fltTreeToGroup(SNode *pNode, void *pContext) { return DEAL_RES_IGNORE_CHILD; } + if (QUERY_NODE_VALUE == nType && ((SValueNode*)pNode)->node.resType.type == TSDB_DATA_TYPE_BOOL) { + if (((SValueNode*)pNode)->datum.b) { + FILTER_SET_FLAG(ctx->info->status, FI_STATUS_ALL); + } else { + FILTER_SET_FLAG(ctx->info->status, FI_STATUS_EMPTY); + } + return DEAL_RES_END; + } + fltError("invalid node type for filter, type:%d", nodeType(pNode)); code = TSDB_CODE_QRY_INVALID_INPUT; @@ -3450,7 +3459,9 @@ int32_t fltInitFromNode(SNode *tree, SFilterInfo *info, uint32_t options) { return code; _return: - qInfo("init from node failed, code:%d", code); + if (code) { + qInfo("init from node failed, code:%d", code); + } return code; } diff --git a/source/util/src/terror.c b/source/util/src/terror.c index 30daad62bf..1714126a32 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -317,6 +317,11 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_SMA_ALREADY_EXIST, "index already exists TAOS_DEFINE_ERROR(TSDB_CODE_MND_SMA_NOT_EXIST, "index not exist") TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_SMA_OPTION, "Invalid sma index option") +// mnode-view +TAOS_DEFINE_ERROR(TSDB_CODE_MND_VIEW_ALREADY_EXIST, "view already exists in db") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_VIEW_NOT_EXIST, "view not exists in db") + + // dnode TAOS_DEFINE_ERROR(TSDB_CODE_DNODE_OFFLINE, "Dnode is offline") TAOS_DEFINE_ERROR(TSDB_CODE_MNODE_NOT_FOUND, "Mnode not found") @@ -590,6 +595,10 @@ TAOS_DEFINE_ERROR(TSDB_CODE_PAR_SYSTABLE_NOT_ALLOWED, "System table not al TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_VARBINARY, "Invalidate varbinary value") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_IP_RANGE, "Invalid IPV4 address ranges") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INTERNAL_ERROR, "Parser internal error") +TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_STREAM_QUERY, "Invalid stream query") +TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_VIEW_QUERY, "Invalid view query type") +TAOS_DEFINE_ERROR(TSDB_CODE_PAR_COL_QUERY_MISMATCH, "Columns number mismatch with query result") +TAOS_DEFINE_ERROR(TSDB_CODE_PAR_VIEW_CONFLICT_WITH_TABLE, "View name is conflict with table") //planner TAOS_DEFINE_ERROR(TSDB_CODE_PLAN_INTERNAL_ERROR, "Planner internal error") diff --git a/source/util/src/tlog.c b/source/util/src/tlog.c index b858421e25..6fc0c15cec 100644 --- a/source/util/src/tlog.c +++ b/source/util/src/tlog.c @@ -795,7 +795,12 @@ static void *taosAsyncOutputLog(void *param) { updateCron = 0; } - if (pLogBuf->stop || pSlowBuf->stop) break; + if (pLogBuf->stop || pSlowBuf->stop) { + pLogBuf->lastDuration = LOG_MAX_WAIT_MSEC; + taosWriteLog(pLogBuf); + taosWriteLog(pSlowBuf); + break; + } } return NULL; @@ -822,7 +827,7 @@ bool taosAssertDebug(bool condition, const char *file, int32_t line, const char taosPrintTrace(flags, level, dflag, -1); if (tsAssert) { - // taosCloseLog(); + taosCloseLog(); taosMsleep(300); #ifdef NDEBUG diff --git a/tests/develop-test/2-query/table_count_scan.py b/tests/develop-test/2-query/table_count_scan.py index d6e49964eb..758d28948d 100644 --- a/tests/develop-test/2-query/table_count_scan.py +++ b/tests/develop-test/2-query/table_count_scan.py @@ -65,7 +65,7 @@ class TDTestCase: tdSql.query('select count(*),db_name, stable_name from information_schema.ins_tables group by db_name, stable_name;') tdSql.checkRows(3) - tdSql.checkData(0, 0, 23) + tdSql.checkData(0, 0, 24) tdSql.checkData(0, 1, 'information_schema') tdSql.checkData(0, 2, None) tdSql.checkData(1, 0, 3) @@ -77,7 +77,7 @@ class TDTestCase: tdSql.query('select count(1) v,db_name, stable_name from information_schema.ins_tables group by db_name, stable_name order by v desc;') tdSql.checkRows(3) - tdSql.checkData(0, 0, 23) + tdSql.checkData(0, 0, 24) tdSql.checkData(0, 1, 'information_schema') tdSql.checkData(0, 2, None) tdSql.checkData(1, 0, 5) @@ -93,7 +93,7 @@ class TDTestCase: tdSql.checkData(1, 1, 'performance_schema') tdSql.checkData(0, 0, 3) tdSql.checkData(0, 1, 'tbl_count') - tdSql.checkData(2, 0, 23) + tdSql.checkData(2, 0, 24) tdSql.checkData(2, 1, 'information_schema') tdSql.query("select count(*) from information_schema.ins_tables where db_name='tbl_count'") @@ -106,7 +106,7 @@ class TDTestCase: tdSql.query('select count(*) from information_schema.ins_tables') tdSql.checkRows(1) - tdSql.checkData(0, 0, 31) + tdSql.checkData(0, 0, 32) tdSql.execute('create table stba (ts timestamp, c1 bool, c2 tinyint, c3 smallint, c4 int, c5 bigint, c6 float, c7 double, c8 binary(10), c9 nchar(10), c10 tinyint unsigned, c11 smallint unsigned, c12 int unsigned, c13 bigint unsigned) TAGS(t1 int, t2 binary(10), t3 double);') @@ -189,7 +189,7 @@ class TDTestCase: tdSql.checkData(2, 0, 5) tdSql.checkData(2, 1, 'performance_schema') tdSql.checkData(2, 2, None) - tdSql.checkData(3, 0, 23) + tdSql.checkData(3, 0, 24) tdSql.checkData(3, 1, 'information_schema') tdSql.checkData(3, 2, None) @@ -204,7 +204,7 @@ class TDTestCase: tdSql.checkData(2, 0, 5) tdSql.checkData(2, 1, 'performance_schema') tdSql.checkData(2, 2, None) - tdSql.checkData(3, 0, 23) + tdSql.checkData(3, 0, 24) tdSql.checkData(3, 1, 'information_schema') tdSql.checkData(3, 2, None) @@ -215,7 +215,7 @@ class TDTestCase: tdSql.checkData(0, 1, 'tbl_count') tdSql.checkData(1, 0, 5) tdSql.checkData(1, 1, 'performance_schema') - tdSql.checkData(2, 0, 23) + tdSql.checkData(2, 0, 24) tdSql.checkData(2, 1, 'information_schema') tdSql.query("select count(*) from information_schema.ins_tables where db_name='tbl_count'") @@ -228,7 +228,7 @@ class TDTestCase: tdSql.query('select count(*) from information_schema.ins_tables') tdSql.checkRows(1) - tdSql.checkData(0, 0, 32) + tdSql.checkData(0, 0, 33) tdSql.execute('drop database tbl_count') diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index a8d3125030..21dcd16441 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -87,6 +87,7 @@ ,,n,system-test,python3 ./test.py -f 7-tmq/tmqDropConsumer.py +,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/insert_stb.py ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/delete_stable.py ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/out_of_order.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/out_of_order.py @@ -182,7 +183,7 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmq3mnodeSwitch.py -N 6 -M 3 -n 3 -i True ,,y,system-test,./pytest.sh python3 test.py -f 7-tmq/tmqVnodeTransform-stb.py -N 2 -n 1 ,,y,system-test,./pytest.sh python3 test.py -f 7-tmq/tmqVnodeTransform-stb.py -N 6 -n 3 -,,y,system-test,./pytest.sh python3 test.py -f 7-tmq/tmqVnodeTransform-db.py -N 6 -n 3 +#,,y,system-test,./pytest.sh python3 test.py -f 7-tmq/tmqVnodeTransform-db.py -N 6 -n 3 ,,y,system-test,./pytest.sh python3 test.py -f 7-tmq/tmqVnodeSplit-stb-select.py -N 2 -n 1 ,,y,system-test,./pytest.sh python3 test.py -f 7-tmq/tmqVnodeSplit-stb-select-duplicatedata.py -N 3 -n 3 ,,y,system-test,./pytest.sh python3 test.py -f 7-tmq/tmqVnodeSplit-stb-select.py -N 3 -n 3 @@ -942,6 +943,7 @@ e ,,y,script,./test.sh -f tsim/insert/delete0.sim ,,y,script,./test.sh -f tsim/insert/update1_sort_merge.sim ,,y,script,./test.sh -f tsim/insert/update2.sim +,,y,script,./test.sh -f tsim/insert/insert_stb.sim ,,y,script,./test.sh -f tsim/parser/alter__for_community_version.sim ,,y,script,./test.sh -f tsim/parser/alter_column.sim ,,y,script,./test.sh -f tsim/parser/alter_stable.sim @@ -1285,6 +1287,7 @@ e ,,y,script,./test.sh -f tmp/monitor.sim ,,y,script,./test.sh -f tsim/tagindex/add_index.sim ,,n,script,./test.sh -f tsim/tagindex/sma_and_tag_index.sim +,,y,script,./test.sh -f tsim/view/view.sim #develop test diff --git a/tests/script/api/insert_stb.c b/tests/script/api/insert_stb.c new file mode 100644 index 0000000000..66430b0337 --- /dev/null +++ b/tests/script/api/insert_stb.c @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +// TAOS standard API example. The same syntax as MySQL, but only a subset +// to compile: gcc -o demo demo.c -ltaos + +#include +#include +#include +#include +#include + +#include "taos.h" // TAOS header file + +static void executeSql(TAOS *taos, char *command) { + int i; + TAOS_RES *pSql = NULL; + int32_t code = -1; + + for (i = 0; i < 5; i++) { + if (NULL != pSql) { + taos_free_result(pSql); + pSql = NULL; + } + + pSql = taos_query(taos, command); + code = taos_errno(pSql); + if (0 == code) { + break; + } + } + + if (code != 0) { + fprintf(stderr, "Failed to run %s, reason: %s\n", command, taos_errstr(pSql)); + taos_free_result(pSql); + taos_close(taos); + exit(EXIT_FAILURE); + } + + taos_free_result(pSql); +} + +void testInsert(TAOS *taos, char *qstr) { + executeSql(taos, "drop database if exists demo2"); + executeSql(taos, "create database demo2"); + executeSql(taos, "use demo2"); + + executeSql(taos, "create table st (ts timestamp, ti tinyint, si smallint, i int, bi bigint, f float, d double, b binary(10)) tags(t1 int, t2 float, t3 binary(10))"); + printf("success to create table\n"); + + struct timeval start_time; + gettimeofday(&start_time, NULL); + + for (int tblIdx = 0; tblIdx < 10; ++tblIdx) { + int len = 0; + len += sprintf(qstr+len, "insert into ct%d using st tags(%d, %f, '%s')", tblIdx, tblIdx, (float)tblIdx, "childtable"); + int batchStart = len; + for (int batchIdx = 0; batchIdx < 10000; ++batchIdx) { + len = batchStart; + len += sprintf(qstr+len, " values"); + + for (int rowIdx = 0; rowIdx < 100; ++ rowIdx) { + int i = rowIdx + batchIdx * 100 + tblIdx*10000*100; + len += sprintf(qstr+len, " (%" PRId64 ", %d, %d, %d, %d, %f, %lf, '%s')", (uint64_t)(1546300800000 + i), (int8_t)i, (int16_t)i, i, i, i*1.0, i*2.0, "hello"); + } + TAOS_RES *result1 = taos_query(taos, qstr); + if (result1 == NULL || taos_errno(result1) != 0) { + printf("failed to insert row, reason:%s. qstr: %s\n", taos_errstr(result1), qstr); + taos_free_result(result1); + exit(1); + } + taos_free_result(result1); + } + } + struct timeval end_time; + gettimeofday(&end_time, NULL); + double elapsed_time = (double)(end_time.tv_sec - start_time.tv_sec) + + (double)(end_time.tv_usec - start_time.tv_usec) / 1000000.0; + printf("elapsed time: %.3f\n", elapsed_time); + executeSql(taos, "drop database if exists demo2"); +} + +void testInsertStb(TAOS *taos, char *qstr) { + executeSql(taos, "drop database if exists demo"); + executeSql(taos, "create database demo"); + executeSql(taos, "use demo"); + + executeSql(taos, "create table st (ts timestamp, ti tinyint, si smallint, i int, bi bigint, f float, d double, b binary(10)) tags(t1 int, t2 float, t3 binary(10))"); + printf("success to create table\n"); + + struct timeval start_time; + gettimeofday(&start_time, NULL); + + for (int tblIdx = 0; tblIdx < 10; ++tblIdx) { + int len = 0; + len += sprintf(qstr+len, "insert into st(tbname, t1, t2, t3, ts, ti, si, i, bi, f, d, b)"); + int batchStart = len; + for (int batchIdx = 0; batchIdx < 10000; ++batchIdx) { + len = batchStart; + len += sprintf(qstr+len, " values"); + + for (int rowIdx = 0; rowIdx < 100; ++rowIdx) { + int i = rowIdx + batchIdx * 100 + tblIdx*10000*100; + len += sprintf(qstr+len, " ('ct%d', %d, %f, '%s', %" PRId64 ", %d, %d, %d, %d, %f, %lf, '%s')", tblIdx, tblIdx, (float)tblIdx, "childtable", + (uint64_t)(1546300800000 + i), (int8_t)i, (int16_t)i, i, i, i*1.0, i*2.0, "hello"); + } + TAOS_RES *result1 = taos_query(taos, qstr); + if (result1 == NULL || taos_errno(result1) != 0) { + printf("failed to insert row, reason:%s. qstr: %s\n", taos_errstr(result1), qstr); + taos_free_result(result1); + exit(1); + } + taos_free_result(result1); + } + } + struct timeval end_time; + gettimeofday(&end_time, NULL); + double elapsed_time = (double)(end_time.tv_sec - start_time.tv_sec) + + (double)(end_time.tv_usec - start_time.tv_usec) / 1000000.0; + + printf("elapsed time: %.3f\n", elapsed_time); + executeSql(taos, "drop database if exists demo"); +} + + +int main(int argc, char *argv[]) { + + // connect to server + if (argc < 2) { + printf("please input server-ip \n"); + return 0; + } + + TAOS *taos = taos_connect(argv[1], "root", "taosdata", NULL, 0); + if (taos == NULL) { + printf("failed to connect to server, reason:%s\n", taos_errstr(NULL)); + exit(1); + } + char* qstr = malloc(1024*1024); + printf("test insert into tb using stb\n\n"); + for (int i =0; i < 5; ++i) { + testInsert(taos, qstr); + } + printf("test insert into stb tbname\n\n"); + for (int i =0; i < 5; ++i) { + testInsertStb(taos, qstr); + } + free(qstr); + taos_close(taos); + taos_cleanup(); +} + diff --git a/tests/script/api/makefile b/tests/script/api/makefile index ac5c5c9138..699b390c20 100644 --- a/tests/script/api/makefile +++ b/tests/script/api/makefile @@ -17,6 +17,8 @@ exe: gcc $(CFLAGS) ./insertSameTs.c -o $(ROOT)insertSameTs $(LFLAGS) gcc $(CFLAGS) ./passwdTest.c -o $(ROOT)passwdTest $(LFLAGS) gcc $(CFLAGS) ./whiteListTest.c -o $(ROOT)whiteListTest $(LFLAGS) + gcc $(CFLAGS) ./insert_stb.c -o $(ROOT)insert_stb $(LFLAGS) + gcc $(CFLAGS) ./tmqViewTest.c -o $(ROOT)tmqViewTest $(LFLAGS) clean: rm $(ROOT)batchprepare @@ -25,3 +27,5 @@ clean: rm $(ROOT)insertSameTs rm $(ROOT)passwdTest rm $(ROOT)whiteListTest + rm $(ROOT)insert_stb + rm $(ROOT)tmqViewTest diff --git a/tests/script/api/tmqViewTest.c b/tests/script/api/tmqViewTest.c new file mode 100644 index 0000000000..8225a4c795 --- /dev/null +++ b/tests/script/api/tmqViewTest.c @@ -0,0 +1,341 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include +#include +#include "taos.h" + +static int running = 1; +const char* topic_name = "topicname"; + +static int32_t msg_process(TAOS_RES* msg) { + char buf[1024]; + int32_t rows = 0; + + const char* topicName = tmq_get_topic_name(msg); + const char* dbName = tmq_get_db_name(msg); + int32_t vgroupId = tmq_get_vgroup_id(msg); + + printf("topic: %s\n", topicName); + printf("db: %s\n", dbName); + printf("vgroup id: %d\n", vgroupId); + + while (1) { + TAOS_ROW row = taos_fetch_row(msg); + if (row == NULL) break; + + TAOS_FIELD* fields = taos_fetch_fields(msg); + int32_t numOfFields = taos_field_count(msg); + // int32_t* length = taos_fetch_lengths(msg); + int32_t precision = taos_result_precision(msg); + rows++; + taos_print_row(buf, row, fields, numOfFields); + printf("precision: %d, row content: %s\n", precision, buf); + } + + return rows; +} + +static int32_t init_env() { + TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); + if (pConn == NULL) { + return -1; + } + + TAOS_RES* pRes; + // drop database if exists + printf("create database\n"); + pRes = taos_query(pConn, "drop topic topicname"); + if (taos_errno(pRes) != 0) { + printf("error in drop topicname, reason:%s\n", taos_errstr(pRes)); + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "drop database if exists tmqdb"); + if (taos_errno(pRes) != 0) { + printf("error in drop tmqdb, reason:%s\n", taos_errstr(pRes)); + } + taos_free_result(pRes); + + // create database + pRes = taos_query(pConn, "create database tmqdb precision 'ns' WAL_RETENTION_PERIOD 3600"); + if (taos_errno(pRes) != 0) { + printf("error in create tmqdb, reason:%s\n", taos_errstr(pRes)); + goto END; + } + taos_free_result(pRes); + + // create super table + printf("create super table\n"); + pRes = taos_query( + pConn, "create table tmqdb.stb (ts timestamp, c1 int, c2 float, c3 varchar(16)) tags(t1 int, t3 varchar(16))"); + if (taos_errno(pRes) != 0) { + printf("failed to create super table stb, reason:%s\n", taos_errstr(pRes)); + goto END; + } + taos_free_result(pRes); + + // create sub tables + printf("create sub tables\n"); + pRes = taos_query(pConn, "create table tmqdb.ctb0 using tmqdb.stb tags(0, 'subtable0')"); + if (taos_errno(pRes) != 0) { + printf("failed to create super table ctb0, reason:%s\n", taos_errstr(pRes)); + goto END; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "create table tmqdb.ctb1 using tmqdb.stb tags(1, 'subtable1')"); + if (taos_errno(pRes) != 0) { + printf("failed to create super table ctb1, reason:%s\n", taos_errstr(pRes)); + goto END; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "create table tmqdb.ctb2 using tmqdb.stb tags(2, 'subtable2')"); + if (taos_errno(pRes) != 0) { + printf("failed to create super table ctb2, reason:%s\n", taos_errstr(pRes)); + goto END; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "create table tmqdb.ctb3 using tmqdb.stb tags(3, 'subtable3')"); + if (taos_errno(pRes) != 0) { + printf("failed to create super table ctb3, reason:%s\n", taos_errstr(pRes)); + goto END; + } + taos_free_result(pRes); + + // insert data + printf("insert data into sub tables\n"); + pRes = taos_query(pConn, "insert into tmqdb.ctb0 values(now, 0, 0, 'a0')(now+1s, 0, 0, 'a00')"); + if (taos_errno(pRes) != 0) { + printf("failed to insert into ctb0, reason:%s\n", taos_errstr(pRes)); + goto END; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "insert into tmqdb.ctb1 values(now, 1, 1, 'a1')(now+1s, 11, 11, 'a11')"); + if (taos_errno(pRes) != 0) { + printf("failed to insert into ctb0, reason:%s\n", taos_errstr(pRes)); + goto END; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "insert into tmqdb.ctb2 values(now, 2, 2, 'a1')(now+1s, 22, 22, 'a22')"); + if (taos_errno(pRes) != 0) { + printf("failed to insert into ctb0, reason:%s\n", taos_errstr(pRes)); + goto END; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "insert into tmqdb.ctb3 values(now, 3, 3, 'a1')(now+1s, 33, 33, 'a33')"); + if (taos_errno(pRes) != 0) { + printf("failed to insert into ctb0, reason:%s\n", taos_errstr(pRes)); + goto END; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "create or replace view tmqdb.view1 as select ts, c1, t1 from tmqdb.stb"); + if (taos_errno(pRes) != 0) { + printf("failed to create view, reason:%s\n", taos_errstr(pRes)); + goto END; + } + taos_free_result(pRes); + + taos_close(pConn); + return 0; + +END: + taos_free_result(pRes); + taos_close(pConn); + return -1; +} + +int32_t create_topic() { + printf("create topic\n"); + TAOS_RES* pRes; + TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); + if (pConn == NULL) { + return -1; + } + + pRes = taos_query(pConn, "use tmqdb"); + if (taos_errno(pRes) != 0) { + printf("error in use tmqdb, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "create topic topicname as select * from tmqdb.view1 where c1 > 1 and c1 <= 22"); + if (taos_errno(pRes) != 0) { + printf("failed to create topic topicname, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + taos_close(pConn); + return 0; +} + +void tmq_commit_cb_print(tmq_t* tmq, int32_t code, void* param) { + printf("tmq_commit_cb_print() code: %d, tmq: %p, param: %p\n", code, tmq, param); +} + +tmq_t* build_consumer() { + tmq_conf_res_t code; + tmq_t* tmq = NULL; + + tmq_conf_t* conf = tmq_conf_new(); + code = tmq_conf_set(conf, "enable.auto.commit", "true"); + if (TMQ_CONF_OK != code) { + tmq_conf_destroy(conf); + return NULL; + } + code = tmq_conf_set(conf, "auto.commit.interval.ms", "1000"); + if (TMQ_CONF_OK != code) { + tmq_conf_destroy(conf); + return NULL; + } + code = tmq_conf_set(conf, "group.id", "cgrpName"); + if (TMQ_CONF_OK != code) { + tmq_conf_destroy(conf); + return NULL; + } + code = tmq_conf_set(conf, "client.id", "user defined name"); + if (TMQ_CONF_OK != code) { + tmq_conf_destroy(conf); + return NULL; + } + code = tmq_conf_set(conf, "td.connect.user", "root"); + if (TMQ_CONF_OK != code) { + tmq_conf_destroy(conf); + return NULL; + } + code = tmq_conf_set(conf, "td.connect.pass", "taosdata"); + if (TMQ_CONF_OK != code) { + tmq_conf_destroy(conf); + return NULL; + } + code = tmq_conf_set(conf, "auto.offset.reset", "earliest"); + if (TMQ_CONF_OK != code) { + tmq_conf_destroy(conf); + return NULL; + } + + tmq_conf_set_auto_commit_cb(conf, tmq_commit_cb_print, NULL); + tmq = tmq_consumer_new(conf, NULL, 0); + +_end: + tmq_conf_destroy(conf); + return tmq; +} + +tmq_list_t* build_topic_list() { + tmq_list_t* topicList = tmq_list_new(); + int32_t code = tmq_list_append(topicList, topic_name); + if (code) { + tmq_list_destroy(topicList); + return NULL; + } + return topicList; +} + +void basic_consume_loop(tmq_t* tmq) { + int32_t totalRows = 0; + int32_t msgCnt = 0; + int32_t timeout = 5000; + while (running) { + TAOS_RES* tmqmsg = tmq_consumer_poll(tmq, timeout); + if (tmqmsg) { + msgCnt++; + totalRows += msg_process(tmqmsg); + taos_free_result(tmqmsg); + } else { + break; + } + } + + fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); +} + +void consume_repeatly(tmq_t* tmq) { + int32_t numOfAssignment = 0; + tmq_topic_assignment* pAssign = NULL; + + int32_t code = tmq_get_topic_assignment(tmq, topic_name, &pAssign, &numOfAssignment); + if (code != 0) { + fprintf(stderr, "failed to get assignment, reason:%s", tmq_err2str(code)); + } + + // seek to the earliest offset + for(int32_t i = 0; i < numOfAssignment; ++i) { + tmq_topic_assignment* p = &pAssign[i]; + + code = tmq_offset_seek(tmq, topic_name, p->vgId, p->begin); + if (code != 0) { + fprintf(stderr, "failed to seek to %d, reason:%s", (int)p->begin, tmq_err2str(code)); + } + } + + tmq_free_assignment(pAssign); + + // let's do it again + basic_consume_loop(tmq); +} + +int main(int argc, char* argv[]) { + int32_t code; + + if (init_env() < 0) { + return -1; + } + + if (create_topic() < 0) { + return -1; + } + + tmq_t* tmq = build_consumer(); + if (NULL == tmq) { + fprintf(stderr, "build_consumer() fail!\n"); + return -1; + } + + tmq_list_t* topic_list = build_topic_list(); + if (NULL == topic_list) { + return -1; + } + + if ((code = tmq_subscribe(tmq, topic_list))) { + fprintf(stderr, "Failed to tmq_subscribe(): %s\n", tmq_err2str(code)); + } + + tmq_list_destroy(topic_list); + + basic_consume_loop(tmq); + + consume_repeatly(tmq); + + code = tmq_consumer_close(tmq); + if (code) { + fprintf(stderr, "Failed to close consumer: %s\n", tmq_err2str(code)); + } else { + fprintf(stderr, "Consumer closed\n"); + } + + return 0; +} diff --git a/tests/script/tsim/insert/insert_stb.sim b/tests/script/tsim/insert/insert_stb.sim new file mode 100644 index 0000000000..890d8937a5 --- /dev/null +++ b/tests/script/tsim/insert/insert_stb.sim @@ -0,0 +1,60 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create database d1 +sql create database d2 + +sql use d1; +sql create table st(ts timestamp, f int) tags(t int); +sql insert into ct1 using st tags(1) values('2021-04-19 00:00:00', 1); +sql insert into ct2 using st tags(2) values('2021-04-19 00:00:01', 2); +sql insert into ct1 values('2021-04-19 00:00:02', 2); +sql create table st2(ts timestamp, f int) tags(t int); + +sql use d2; +sql create table st(ts timestamp, f int) tags(t int); +sql insert into ct1 using st tags(1) values('2021-04-19 00:00:00', 1); +sql insert into ct2 using st tags(2) values('2021-04-19 00:00:01', 2); + +sql create database db1 vgroups 1; +sql create table db1.stb (ts timestamp, c1 int, c2 int) tags(t1 int, t2 int); + +sql use d1; +sql insert into st (tbname, ts, f, t) values('ct3', '2021-04-19 08:00:03', 3, 3); +sql insert into d1.st (tbname, ts, f) values('ct6', '2021-04-19 08:00:04', 6); +sql insert into d1.st (tbname, ts, f) values('ct6', '2021-04-19 08:00:05', 7)('ct8', '2021-04-19 08:00:06', 8); +sql insert into d1.st (tbname, ts, f, t) values('ct6', '2021-04-19 08:00:07', 9, 9)('ct8', '2021-04-19 08:00:08', 10, 10); +sql insert into d1.st (tbname, ts, f, t) values('ct6', '2021-04-19 08:00:09', 9, 9)('ct8', '2021-04-19 08:00:10', 10, 10) d2.st (tbname, ts, f, t) values('ct6', '2021-04-19 08:00:11', 9, 9)('ct8', '2021-04-19 08:00:12', 10, 10); + +sql select * from d1.st +print $rows +if $rows != 11 then + return -1 +endi +sql select * from d2.st; +print $rows +if $rows != 4 then + return -1 +endi + +sql insert into d2.st(ts, f, tbname) values('2021-04-19 08:00:13', 1, 'ct1') d1.ct1 values('2021-04-19 08:00:14', 1); + +sql select * from d1.st +print $rows +if $rows != 12 then + return -1 +endi +sql select * from d2.st; +print $rows +if $rows != 5 then + return -1 +endi +sql_error insert into d2.st values(now, 1, 1) +sql_error insert into d2.st(ts, f) values(now, 1); +sql_error insert into d2.st(ts, f, tbname) values(now, 1); +sql_error insert into d2.st(ts, f, tbname) values(now, 1, ''); +sql_error insert into d2.st(ts, tbname) values(now, 1, 34) +sql_error insert into st using st2 tags(2) values(now,1); +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/query/sys_tbname.sim b/tests/script/tsim/query/sys_tbname.sim index 6ed978aa15..f49a8e0a7d 100644 --- a/tests/script/tsim/query/sys_tbname.sim +++ b/tests/script/tsim/query/sys_tbname.sim @@ -58,7 +58,7 @@ endi sql select tbname from information_schema.ins_tables; print $rows $data00 -if $rows != 32 then +if $rows != 33 then return -1 endi if $data00 != @ins_tables@ then diff --git a/tests/script/tsim/query/tableCount.sim b/tests/script/tsim/query/tableCount.sim index 524b43620c..6e65852dcc 100644 --- a/tests/script/tsim/query/tableCount.sim +++ b/tests/script/tsim/query/tableCount.sim @@ -53,7 +53,7 @@ sql select stable_name,count(table_name) from information_schema.ins_tables grou if $rows != 3 then return -1 endi -if $data01 != 29 then +if $data01 != 30 then return -1 endi if $data11 != 10 then @@ -72,7 +72,7 @@ endi if $data11 != 5 then return -1 endi -if $data21 != 23 then +if $data21 != 24 then return -1 endi if $data31 != 5 then @@ -97,7 +97,7 @@ endi if $data42 != 3 then return -1 endi -if $data52 != 23 then +if $data52 != 24 then return -1 endi if $data62 != 5 then diff --git a/tests/script/tsim/view/create_drop_view.sim b/tests/script/tsim/view/create_drop_view.sim new file mode 100644 index 0000000000..ca829f7456 --- /dev/null +++ b/tests/script/tsim/view/create_drop_view.sim @@ -0,0 +1,47 @@ +sql connect +sql use testa; + +sql create view view1 as select * from sta1; +sql drop view view1; + +sql create or replace view view2 as select f from cta11; +sql_error create view view2 as select * from cta11; +sql drop view if exists view2; +sql drop view if exists view3; +sql_error drop view view2; +sql_error drop view view3; + +sql create view view3 as select avg(f) from st2; +sql create or replace view view3 as select f fa from st2; +sql_error create view view3 as select * from st2; +sql create view view4 as select * from view3; +sql create or replace view view4 as select fa from view3; +sql drop view view3; +sql_error create view view5 as select * from view3; +sql drop view view4; + +sql create view testa.view1 as select * from testa.sta1; +sql create view testa.view2 as select * from testb.st2; +sql create view testb.view1 as select * from testb.stb1; +sql create view testb.view2 as select * from testa.st2; +sql drop view view1; +sql drop view view2; +sql drop view testb.view1; +sql drop view testb.view2; + +sql_error create view view1 as show tables; +sql_error create view view1 as desc sta1; +sql_error create view view1 as select * from st; +sql_error create view view1 as select count(*) from sta1 group by f interval(1s); + +sql use information_schema; +sql create view view1 as select * from ins_tables; +sql drop view view1; +sql create view information_schema.view1 as select * from ins_tags; +sql drop view information_schema.view1; + +sql use testa +sql_error create view testb.view1 as select * from sta1; +sql create view testb.view1 as select * from stb1; +sql_error drop view view1 +sql drop view testb.view1 diff --git a/tests/script/tsim/view/insert_view.sim b/tests/script/tsim/view/insert_view.sim new file mode 100644 index 0000000000..48b7c75059 --- /dev/null +++ b/tests/script/tsim/view/insert_view.sim @@ -0,0 +1,15 @@ +sql connect +sql use testa; + +sql create view view1 as select * from cta11; +sql_error insert into view1 values (now, 1); +sql create table ctat using sta1 tags(1); +sql insert into ctat select * from view1; +sql drop view view1; +sql drop table ctat; + +sql use information_schema; +sql create view view1 as select * from ins_dnodes; +sql_error insert into ins_dnodes select * from view1; +sql drop view view1; + diff --git a/tests/script/tsim/view/privilege_basic_view.sim b/tests/script/tsim/view/privilege_basic_view.sim new file mode 100644 index 0000000000..579c25a9d7 --- /dev/null +++ b/tests/script/tsim/view/privilege_basic_view.sim @@ -0,0 +1,170 @@ +sql connect +sql use testa; + +sql create user u1 pass "taosdata" +sql create user u2 pass "taosdata" +sql create user u3 pass "taosdata" + +print == root create views == +sql create view view1 as select * from sta1; +sql create view view2 as select * from view1; +sql create view view3 as select * from view2; + +sql_error grant all on view1 to root; +sql_error revoke all on view1 from root; + +sql_error grant read on view1 to u1; +sql grant read on testa.view1 to u1; + +sql select * from information_schema.ins_user_privileges order by user_name, privilege; +if $rows != 2 then + return -1 +endi +if $data10 != u1 then + return -1 +endi +if $data11 != read then + return -1 +endi + +sql connect u1 +sql use testa +sql_error select * from sta1; +sql select * from view1; +sql_error select * from view2; +sql_error select * from testb.view1; +sql_error insert into view1 values (now, 1); +sql_error create or replace view1 as select * from st2; +sql_error create viewa as select * from sta1; +sql_error drop view view1; +sql show views; +sql show create view view1; +sql desc view1; +sql select * from information_schema.ins_views; +if $rows != 3 then + return -1 +endi +sql_error grant read on testa.view1 to u2; +sql_error revoke read on testa.view1 from u1; + +sql connect root +sql use testa +sql drop view testa.view1; +sql select * from information_schema.ins_user_privileges order by user_name, privilege; +if $rows != 1 then + return -1 +endi +if $data00 != root then + return -1 +endi +sql grant all on testa.* to u1; +sql reset query cache + +print == u1 create view1 == +sql connect u1 +sql use testa +sql select * from sta1; +sql_error insert into view1 values (now, 1); +sql create view view1 as select * from sta1; + +sql connect root +sql grant read on testa.view1 to u2; +sql_error insert into view1 values (now, 1); + +sql connect u2 +sql use testa +sql_error select * from sta1; +sql_error insert into view1 values (now, 1); +sql select * from view1; + +sql connect root +sql revoke all on testa.* from u1 +sql reset query cache + +sql connect u1 +sql use testa +sql_error select * from sta1; +sql_error select * from view1; + +sql connect u2 +sql use testa +sql_error select * from view1; + +sql connect root +sql grant all on testa.* to u2 +sql reset query cache + +sql connect u2 +sql use testa +sql select * from view1; +sql_error create or replace view1 as select * from st2; + +sql connect u1 +sql use testa +sql_error create or replace view1 as select * from st2; + +sql connect root +sql grant all on testa.* to u1 +sql reset query cache + +sql connect u1 +sql use testa +sql create or replace view view1 as select * from st2; + +sql connect root +sql grant alter on testa.view1 to u2 +sql revoke all on testa.* from u1 +sql reset query cache + +print == u2 replace view1 == +sql connect u2 +sql use testa +sql select * from view1; +sql create or replace view view1 as select * from sta1; +sql_error insert into view1 values (now, 1); +sql select * from information_schema.ins_views where view_name = 'view1'; +if $rows != 1 then + return -1 +endi +if $data01 != testa then + return -1 +endi +if $data02 != u2 then + return -1 +endi + +sql connect root +sql grant all on testa.view1 to u3; + +sql connect u3 +sql use testa +sql_error select * from sta1 +sql_error insert into view1 values (now, 1); +sql select * from view1 + +sql connect root +sql revoke all on testa.* from u2 +sql reset query cache + +sql connect u3 +sql use testa +sql_error select * from view1 +sql_error insert into view1 values (now, 1); + +sql connect root +sql grant all on testa.* to u3 +sql drop user u1; +sql drop user u2; +sql reset query cache + +sql connect u3 +sql use testa +sql select * from view1 +sql_error insert into view1 values (now, 1); + +sql connect root +sql drop user u3; +sql drop view testa.view1; +sql drop view testa.view2; +sql drop view testa.view3; + diff --git a/tests/script/tsim/view/privilege_nested_view.sim b/tests/script/tsim/view/privilege_nested_view.sim new file mode 100644 index 0000000000..89ccb03018 --- /dev/null +++ b/tests/script/tsim/view/privilege_nested_view.sim @@ -0,0 +1,117 @@ +sql connect +sql use testa; + +sql create user u1 pass "taosdata" +sql create user u2 pass "taosdata" +sql create user u3 pass "taosdata" + +sql grant all on testa.* to u1; +sql grant all on testb.* to u2; +sql grant all on testa.stt to u3; + +sql connect u1 +sql use testa +sql create view view1 as select ts, f from st2; + +sql connect u2 +sql use testb +sql create view view1 as select ts, f from st2; + +sql connect root +sql use testa +sql_error create view view2 as select * from view1 union all select * from view2; +sql create view view2 as select * from view1 union all select * from testb.view1; +sql use testb +sql create view view2 as select a.ts, a.f, b.f from testa.view1 a, view1 b where a.ts=b.ts; +sql grant all on testa.view2 to u3; +sql grant all on testb.view2 to u3; + +print == start to query == +sql connect u3 +sql reset query cache +sql select * from testa.view2 order by f; +if $rows != 8 then + return -1 +endi +if $data01 != 100221 then + return -1 +endi +if $data11 != 100222 then + return -1 +endi +if $data21 != 100223 then + return -1 +endi +if $data31 != 100224 then + return -1 +endi +if $data41 != 110221 then + return -1 +endi +if $data51 != 110222 then + return -1 +endi +if $data61 != 110223 then + return -1 +endi +if $data71 != 110224 then + return -1 +endi +sql_error insert into tt (ts, f) select * from testa.view1; +sql_error insert into tt (ts, f) select * from testb.view1; +sql insert into testa.tt (ts, f) select * from testa.view2 order by ts, f; +if $rows != 4 then + return -1 +endi +# insert result is not correct now +#if $data01 != 110221 then +# print $data01 +# return -1 +#endi +#if $data11 != 110222 then +# print $data11 +# return -1 +#endi +sql delete from testa.tt; +sql_error select * from testa.st2; +sql_error select * from testb.st2; + +sql connect root +sql revoke all on testa.* from u1; + +sql connect u3 +sql reset query cache +sql_error select * from testa.view2; +sql_error select * from testa.view1; + +sql connect root +sql use testb; +sql create or replace view testa.view1 as select ts, f from st2; +sql select * from testa.view1 order by ts; +if $rows != 4 then + return -1 +endi +if $data01 != 100221 then + print $data01 + return -1 +endi +if $data11 != 100222 then + print $data11 + return -1 +endi + +sql connect u3 +sql reset query cache +sql select * from testa.view2; +sql_error select * from testa.view1; + +print == drop user and views == +sql connect root +sql drop user u1; +sql drop user u2; +sql drop user u3; +sql drop view testa.view1; +sql drop view testb.view1; +sql drop view testa.view2; +sql drop view testb.view2; + diff --git a/tests/script/tsim/view/query_view.sim b/tests/script/tsim/view/query_view.sim new file mode 100644 index 0000000000..38ec71208e --- /dev/null +++ b/tests/script/tsim/view/query_view.sim @@ -0,0 +1,238 @@ +sql connect +sql use testa; + +sql create view view1 as select * from sta1; +sql explain select * from view1 order by ts; +sql explain analyze select * from view1 order by ts; +sql select * from view1 order by ts; +if $rows != 4 then + return -1 +endi +if $data00 != @23-10-16 09:10:11.000@ then + return -1 +endi +if $data01 != 100111 then + return -1 +endi +sql select ts from view1 order by ts; +if $rows != 4 then + return -1 +endi +if $data00 != @23-10-16 09:10:11.000@ then + return -1 +endi +sql select view1.ts from view1 order by view1.ts; +if $rows != 4 then + return -1 +endi +if $data00 != @23-10-16 09:10:11.000@ then + return -1 +endi + +sql create or replace view view1 as select 1, 2; +sql explain select * from view1; +sql explain analyze select * from view1; +sql select * from view1; +if $rows != 1 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data01 != 2 then + return -1 +endi + +sql create or replace view view1 as select tbname as a, f from sta1; +sql explain select cast(avg(f) as int) b from view1 group by a having avg(f) > 100111 order by b; +sql explain analyze select cast(avg(f) as int) b from view1 group by a having avg(f) > 100111 order by b; +sql select cast(avg(f) as int) b from view1 group by a having avg(f) > 100111 order by b; +if $rows != 3 then + return -1 +endi +if $data00 != 100112 then + return -1 +endi +if $data10 != 100113 then + return -1 +endi +if $data20 != 100114 then + return -1 +endi + +sql create or replace view view1 as select tbname, avg(f) from sta1 partition by tbname; +sql explain select * from view1 partition by view1.tbname; +sql explain analyze select * from view1 partition by view1.tbname; +sql select * from view1 partition by view1.tbname; +if $rows != 4 then + return -1 +endi + +sql create or replace view view1 as select * from sta1; +sql create or replace view testb.view2 as select * from testb.stb1; +sql_error explain select avg(t1.f), avg(t2.f) from view1 t1, view2 t2 where t1.ts = t2.ts and t1.f < 100114; +sql_error explain analyze select avg(t1.f), avg(t2.f) from view1 t1, view2 t2 where t1.ts = t2.ts and t1.f < 100114; +sql_error select avg(t1.f), avg(t2.f) from view1 t1, view2 t2 where t1.ts = t2.ts and t1.f < 100114; +sql explain select avg(t1.f), avg(t2.f) from view1 t1, testb.view2 t2 where t1.ts = t2.ts and t1.f < 100114; +sql explain analyze select avg(t1.f), avg(t2.f) from view1 t1, testb.view2 t2 where t1.ts = t2.ts and t1.f < 100114; +sql select avg(t1.f), avg(t2.f) from view1 t1, testb.view2 t2 where t1.ts = t2.ts and t1.f < 100114; +if $rows != 1 then + return -1 +endi +if $data00 != 100112.000000000 then + print $data00 + return -1 +endi +if $data01 != 110112.000000000 then + return -1 +endi + +sql create or replace view view3 as select t1.ts ts, t1.f a1, t2.f a2 from view1 t1, testb.view2 t2 where t1.ts = t2.ts; +sql create or replace view view4 as select t1.ts ts, t1.f a1, t2.f a2 from testa.st2 t1, testb.st2 t2 where t1.ts = t2.ts; +sql create view view5 as select t3.ts, cast((t3.a1 + t4.a1) as bigint), cast((t3.a2 - t4.a2) as bigint) from view3 t3, view4 t4 where t3.ts = t4.ts order by t3.ts; +sql explain select * from view5; +sql explain analyze select * from view5; +sql select * from view5; +if $rows != 4 then + return -1 +endi +if $data00 != @23-10-16 09:10:11.000@ then + print $data00 + return -1 +endi +if $data01 != 200332 then + return -1 +endi +if $data02 != -110 then + return -1 +endi +if $data11 != 200334 then + return -1 +endi +if $data21 != 200336 then + return -1 +endi +if $data31 != 200338 then + return -1 +endi + +sql drop view view1; +sql drop view testb.view2; +sql drop view view3; +sql drop view view4; +sql drop view view5; + +sql create or replace view view1 as select * from sta1; +sql create or replace view view2 as select * from st2; +sql explain select avg(view1.f), avg(view2.f) from view1, view2 where view1.ts = view2.ts and view1.f < 100114; +sql explain analyze select avg(view1.f), avg(view2.f) from view1, view2 where view1.ts = view2.ts and view1.f < 100114; +sql select avg(view1.f), avg(view2.f) from view1, view2 where view1.ts = view2.ts and view1.f < 100114; +if $rows != 1 then + return -1 +endi +if $data00 != 100112.000000000 then + print $data00 + return -1 +endi +if $data01 != 100222.000000000 then + return -1 +endi + +sql drop view view1; +sql drop view view2; + +sql create view view1 as select * from sta1; +sql create view view2 as select * from st2; +sql create view view3 as select a.ts ts, a.f af, b.f bf from view1 a join view2 b on a.ts = b.ts; +sql create view view3a as select a.ts ts, a.f, b.f from view1 a join view2 b on a.ts = b.ts; +sql create view view4 as select _wstart, avg(bf) - avg(af) as b from view3 interval(1s); +sql_error create view view4a as select _wstart, avg(b.f) - avg(a.f) as b from view3 interval(1s); +sql create view view5 as select count(*),avg(b) from view4 interval(1s) having avg(b) > 0; +sql explain select * from view5; +sql explain analyze select * from view5; +sql select * from view5; +if $rows != 4 then + return -1 +endi +if $data00 != 1 then + print $data00 + return -1 +endi +if $data01 != 110.000000000 then + return -1 +endi +sql drop view view1; +sql drop view view2; +sql drop view view3; +sql drop view view3a; +sql drop view view4; +sql drop view view5; + +sql use information_schema; +sql create view view1 as select * from ins_views; +sql explain select * from view1; +sql explain analyze select * from view1; +sql select * from view1; +if $rows != 1 then + return -1 +endi +sql drop view view1; +sql use testa; +sql create view information_schema.view1 as select * from information_schema.ins_views; +sql explain select * from information_schema.view1; +sql explain analyze select * from information_schema.view1; +sql select * from information_schema.view1; +if $rows != 1 then + return -1 +endi +sql drop view information_schema.view1; + +sql use testa; +sql create view view1 as select * from st2; +sql use testb; +sql explain select f from testa.view1 order by f; +sql explain analyze select f from testa.view1 order by f; +sql select f from testa.view1 order by f; +if $rows != 4 then + return -1 +endi +if $data00 != 100221 then + print $data00 + return -1 +endi +if $data10 != 100222 then + return -1 +endi +sql drop view testa.view1; + +sql use performance_schema; +sql create view view1 as select 1; +sql create view view2 as select 2; +sql create view view3 as select server_status(); +sql create view view4 as select conn_id from perf_connections where 0>1; +sql create view view5 as select abs(-1) a; +sql create view view6 as select 1 union select conn_id from perf_connections; +sql create view view7 as select 1 union select conn_id from perf_connections where 0>1; +sql create view view8 as select 1 union all select case when conn_id != 1 then conn_id else conn_id + 1 end from perf_connections; +sql explain select * from view1 union all select * from view2 union all select * from view3 union all select * from view4 union all select a from view5 union all select * from view6 union all select * from view7 union all select * from view8; +sql explain analyze select * from view1 union all select * from view2 union all select * from view3 union all select * from view4 union all select a from view5 union all select * from view6 union all select * from view7 union all select * from view8; +sql select * from view1 union all select * from view2 union all select * from view3 union all select * from view4 union all select a from view5 union all select * from view6 union all select * from view7 union all select * from view8; +sql explain select * from view1 union select a from view5; +sql explain analyze select * from view1 union select a from view5; +sql select * from view1 union select a from view5; +if $rows != 1 then + return -1 +endi +if $data00 != 1 then + print $data00 + return -1 +endi +sql drop view view1; +sql drop view view2; +sql drop view view3; +sql drop view view4; +sql drop view view5; +sql drop view view6; +sql drop view view7; +sql drop view view8; + diff --git a/tests/script/tsim/view/same_name_tb_view.sim b/tests/script/tsim/view/same_name_tb_view.sim new file mode 100644 index 0000000000..b49e4df913 --- /dev/null +++ b/tests/script/tsim/view/same_name_tb_view.sim @@ -0,0 +1,72 @@ +sql connect +sql use testa; + +print == create view sta1 +sql create view sta1 as select * from stv; +sql select * from sta1; +if $rows != 4 then + return -1 +endi +sql desc sta1; +if $rows != 4 then + return -1 +endi +sql show create table sta1; +sql show create view sta1; +sql create view view1 as select * from sta1; +sql select * from view1; +if $rows != 4 then + return -1 +endi + +print == drop view sta1 +sql reset query cache +sql drop view sta1; +sql select * from sta1; +if $rows != 4 then + return -1 +endi +sql desc sta1; +if $rows != 4 then + return -1 +endi +sql show create table sta1; +sql_error show create view sta1; +sql select * from view1; +if $rows != 4 then + return -1 +endi + +print == create view sta1, drop table sta1 +sql reset query cache +sql create view sta1 as select * from stv; +sql drop table sta1; +sql select * from sta1; +if $rows != 1 then + return -1 +endi +sql desc sta1; +if $rows != 3 then + print $rows + return -1 +endi +sql_error show create table sta1; +sql show create view sta1; +sql select * from view1; +if $rows != 1 then + return -1 +endi +sql desc view1; +if $rows != 3 then + return -1 +endi + +print == restore data +sql drop view sta1; +sql drop view view1; +sql create table sta1(ts timestamp, f int, g int) tags (t int); +sql insert into cta11 using sta1 tags(1) values('2023-10-16 09:10:11', 100111, 1001110); +sql insert into cta12 using sta1 tags(2) values('2023-10-16 09:10:12', 100112, 1001120); +sql insert into cta13 using sta1 tags(3) values('2023-10-16 09:10:13', 100113, 1001130); +sql insert into cta14 using sta1 tags(4) values('2023-10-16 09:10:14', 100114, 1001140); + diff --git a/tests/script/tsim/view/show_desc_view.sim b/tests/script/tsim/view/show_desc_view.sim new file mode 100644 index 0000000000..307d52964d --- /dev/null +++ b/tests/script/tsim/view/show_desc_view.sim @@ -0,0 +1,153 @@ +sql connect +sql use testa; + +sql create view view1 as select * from sta1; +sql show views; +if $rows != 1 then + return -1 +endi +if $data00 != view1 then + return -1 +endi +if $data01 != testa then + return -1 +endi +if $data02 != root then + return -1 +endi +if $data04 != NORMAL then + return -1 +endi +if $data05 != @select * from sta1;@ then + return -1 +endi +if $data06 != NULL then + return -1 +endi +if $data07 != NULL then + return -1 +endi +if $data08 != NULL then + return -1 +endi +sql desc view1 +if $rows != 4 then + return -1 +endi +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data02 != 8 then + return -1 +endi +if $data03 != @VIEW COL@ then + return -1 +endi +if $data10 != f then + return -1 +endi +if $data20 != g then + return -1 +endi +if $data30 != t then + return -1 +endi +sql show create view view1; +if $rows != 1 then + return -1 +endi +if $data00 != @`testa`.`view1`@ then + return -1 +endi +if $data01 != @CREATE VIEW `testa`.`view1` AS select * from sta1;@ then + return -1 +endi + +sql create or replace view view2 as select null; +sql desc view2; +if $rows != 1 then + return -1 +endi +if $data00 != null then + return -1 +endi +if $data01 != VARCHAR then + return -1 +endi +if $data02 != 0 then + return -1 +endi +sql create or replace view view2 as select null a; +sql desc view2; +if $rows != 1 then + return -1 +endi +if $data00 != a then + return -1 +endi +if $data01 != VARCHAR then + return -1 +endi +if $data02 != 0 then + return -1 +endi +sql show views; +if $rows != 2 then + return -1 +endi + +sql create view testb.view1 as select * from stb1; +sql show views; +if $rows != 2 then + return -1 +endi +sql show testb.views; +if $rows != 1 then + return -1 +endi +sql show create view testb.view1; +if $rows != 1 then + return -1 +endi +if $data00 != @`testb`.`view1`@ then + return -1 +endi +if $data01 != @CREATE VIEW `testb`.`view1` AS select * from stb1;@ then + return -1 +endi +sql desc testb.view1; +if $rows != 4 then + return -1 +endi + +sql use information_schema; +sql create view view1 as select * from ins_views; +sql select * from view1; +if $rows != 4 then + return -1 +endi +sql select * from view1 where db_name = 'testa'; +if $rows != 2 then + return -1 +endi +sql select * from view1 where db_name like 'test%'; +if $rows != 3 then + return -1 +endi +sql select * from view1 where view_name='view1'; +if $rows != 3 then + return -1 +endi +sql select concat(db_name, '.', view_name) from view1 where view_name='view1'; +if $rows != 3 then + return -1 +endi + +sql drop view testa.view1; +sql drop view testa.view2; +sql drop view testb.view1; +sql drop view information_schema.view1; + diff --git a/tests/script/tsim/view/stream_view.sim b/tests/script/tsim/view/stream_view.sim new file mode 100644 index 0000000000..bf77bbf095 --- /dev/null +++ b/tests/script/tsim/view/stream_view.sim @@ -0,0 +1,8 @@ +sql connect +sql use testa; + +sql create view view1 as select * from sta1; +sql_error CREATE STREAM s1 INTO s1t AS SELECT _wstart, count(*) FROM view1 PARTITION BY f INTERVAL(1m); + +sql drop view view1; + diff --git a/tests/script/tsim/view/view.sim b/tests/script/tsim/view/view.sim new file mode 100644 index 0000000000..6b4372fe8c --- /dev/null +++ b/tests/script/tsim/view/view.sim @@ -0,0 +1,66 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect +sql drop database if exists testa +sql create database testa vgroups 3; +sql use testa; + +sql create table sta1(ts timestamp, f int, g int) tags (t int); +sql insert into cta11 using sta1 tags(1) values('2023-10-16 09:10:11', 100111, 1001110); +sql insert into cta12 using sta1 tags(2) values('2023-10-16 09:10:12', 100112, 1001120); +sql insert into cta13 using sta1 tags(3) values('2023-10-16 09:10:13', 100113, 1001130); +sql insert into cta14 using sta1 tags(4) values('2023-10-16 09:10:14', 100114, 1001140); + +sql create table st2(ts timestamp, f int, g int) tags (t int); +sql insert into cta21 using st2 tags(1) values('2023-10-16 09:10:11', 100221, 1002210); +sql insert into cta22 using st2 tags(2) values('2023-10-16 09:10:12', 100222, 1002220); +sql insert into cta23 using st2 tags(3) values('2023-10-16 09:10:13', 100223, 1002230); +sql insert into cta24 using st2 tags(4) values('2023-10-16 09:10:14', 100224, 1002240); + +sql create table stt(ts timestamp, f int, g int) tags (t int); +sql create table tt using stt tags(99); + +sql create table stv(ts timestamp, h int) tags (t1 int); +sql insert into ctv1 using stv tags(1) values('2023-10-16 10:10:10', 1); + +sql drop database if exists testb +sql create database testb vgroups 1; +sql use testb; + +sql create table stb1(ts timestamp, f int,g int) tags (t int); +sql insert into ctb11 using stb1 tags(1) values('2023-10-16 09:10:11', 110111, 1101110); +sql insert into ctb12 using stb1 tags(2) values('2023-10-16 09:10:12', 110112, 1101120); +sql insert into ctb13 using stb1 tags(3) values('2023-10-16 09:10:13', 110113, 1101130); +sql insert into ctb14 using stb1 tags(4) values('2023-10-16 09:10:14', 110114, 1101140); + +sql create table st2(ts timestamp, f int, g int) tags (t int); +sql insert into ctb21 using st2 tags(1) values('2023-10-16 09:10:11', 110221, 1102210); +sql insert into ctb22 using st2 tags(2) values('2023-10-16 09:10:12', 110222, 1102220); +sql insert into ctb23 using st2 tags(3) values('2023-10-16 09:10:13', 110223, 1102230); +sql insert into ctb24 using st2 tags(4) values('2023-10-16 09:10:14', 110224, 1102240); + +run tsim/view/privilege_basic_view.sim +run tsim/view/privilege_nested_view.sim +run tsim/view/create_drop_view.sim +run tsim/view/query_view.sim +run tsim/view/insert_view.sim +run tsim/view/stream_view.sim +run tsim/view/show_desc_view.sim +run tsim/view/same_name_tb_view.sim + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed + +run tsim/view/privilege_basic_view.sim +run tsim/view/privilege_nested_view.sim +run tsim/view/create_drop_view.sim +run tsim/view/query_view.sim +run tsim/view/insert_view.sim +run tsim/view/stream_view.sim +run tsim/view/show_desc_view.sim +run tsim/view/same_name_tb_view.sim + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/system-test/0-others/information_schema.py b/tests/system-test/0-others/information_schema.py index 51347f5f64..ac952d383a 100644 --- a/tests/system-test/0-others/information_schema.py +++ b/tests/system-test/0-others/information_schema.py @@ -57,7 +57,7 @@ class TDTestCase: self.nchar_str = '涛思数据' self.ins_list = ['ins_dnodes','ins_mnodes','ins_qnodes','ins_snodes','ins_cluster','ins_databases','ins_functions',\ 'ins_indexes','ins_stables','ins_tables','ins_tags','ins_columns','ins_users','ins_grants','ins_vgroups','ins_configs','ins_dnode_variables',\ - 'ins_topics','ins_subscriptions','ins_streams','ins_stream_tasks','ins_vnodes','ins_user_privileges'] + 'ins_topics','ins_subscriptions','ins_streams','ins_stream_tasks','ins_vnodes','ins_user_privileges','ins_views'] self.perf_list = ['perf_connections','perf_queries','perf_consumers','perf_trans','perf_apps'] def insert_data(self,column_dict,tbname,row_num): insert_sql = self.setsql.set_insertsql(column_dict,tbname,self.binary_str,self.nchar_str) @@ -217,7 +217,7 @@ class TDTestCase: tdSql.checkEqual(20470,len(tdSql.queryResult)) tdSql.query("select * from information_schema.ins_columns where db_name ='information_schema'") - tdSql.checkEqual(198, len(tdSql.queryResult)) + tdSql.checkEqual(208, len(tdSql.queryResult)) tdSql.query("select * from information_schema.ins_columns where db_name ='performance_schema'") tdSql.checkEqual(54, len(tdSql.queryResult)) diff --git a/tests/system-test/1-insert/insert_stb.py b/tests/system-test/1-insert/insert_stb.py new file mode 100644 index 0000000000..605bee7d8b --- /dev/null +++ b/tests/system-test/1-insert/insert_stb.py @@ -0,0 +1,627 @@ +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import tdDnodes +from math import inf +import taos + +class TDTestCase: + def caseDescription(self): + ''' + case1: [TS-3932] insert into stb + ''' + return + + def init(self, conn, logSql, replicaVer=1): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), True) + self.conn = conn + + + def restartTaosd(self, index=1, dbname="db"): + tdDnodes.stop(index) + tdDnodes.startWithoutSleep(index) + tdSql.execute(f"use insert_stb") + + + def run_normal(self): + print("running {}".format(__file__)) + tdSql.execute("drop database if exists insert_stb") + tdSql.execute("create database if not exists insert_stb") + tdSql.execute('use insert_stb') + tdSql.execute('create database d1') + + tdSql.execute('create database d2') + + tdSql.execute('use d1;') + + tdSql.execute('create table st(ts timestamp, f int) tags(t int);') + + tdSql.execute("insert into ct1 using st tags(1) values('2021-04-19 00:00:00', 1);") + + tdSql.execute("insert into ct2 using st tags(2) values('2021-04-19 00:00:01', 2);") + + tdSql.execute("insert into ct1 values('2021-04-19 00:00:02', 2);") + + tdSql.execute('use d2;') + + tdSql.execute('create table st(ts timestamp, f int) tags(t int);') + + tdSql.execute("insert into ct1 using st tags(1) values('2021-04-19 00:00:00', 1);") + + tdSql.execute("insert into ct2 using st tags(2) values('2021-04-19 00:00:01', 2);") + + tdSql.execute('create database db1 vgroups 1;') + + tdSql.execute('create table db1.stb (ts timestamp, c1 int, c2 int) tags(t1 int, t2 int);') + + tdSql.execute('use d1;') + + tdSql.execute("insert into st (tbname, ts, f, t) values('ct3', '2021-04-19 08:00:03', 3, 3);") + + tdSql.execute("insert into d1.st (tbname, ts, f) values('ct6', '2021-04-19 08:00:04', 6);") + + tdSql.execute("insert into d1.st (tbname, ts, f) values('ct6', '2021-04-19 08:00:05', 7)('ct8', '2021-04-19 08:00:06', 8);") + + tdSql.execute("insert into d1.st (tbname, ts, f, t) values('ct6', '2021-04-19 08:00:07', 9, 9)('ct8', '2021-04-19 08:00:08', 10, 10);") + + tdSql.execute("insert into d1.st (tbname, ts, f, t) values('ct6', '2021-04-19 08:00:09', 9, 9)('ct8', '2021-04-19 08:00:10', 10, 10) d2.st (tbname, ts, f, t) values('ct6', '2021-04-19 08:00:11', 9, 9)('ct8', '2021-04-19 08:00:12', 10, 10);") + + tdSql.query('select * from d1.st order by ts;') + tdSql.checkRows(11) + tdSql.checkData(0, 0, datetime.datetime(2021, 4, 19, 0, 0)) + tdSql.checkData(0, 1, 1) + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 0, datetime.datetime(2021, 4, 19, 0, 0, 1)) + tdSql.checkData(1, 1, 2) + tdSql.checkData(1, 2, 2) + tdSql.checkData(2, 0, datetime.datetime(2021, 4, 19, 0, 0, 2)) + tdSql.checkData(2, 1, 2) + tdSql.checkData(2, 2, 1) + tdSql.checkData(3, 0, datetime.datetime(2021, 4, 19, 8, 0, 3)) + tdSql.checkData(3, 1, 3) + tdSql.checkData(3, 2, 3) + tdSql.checkData(4, 0, datetime.datetime(2021, 4, 19, 8, 0, 4)) + tdSql.checkData(4, 1, 6) + tdSql.checkData(4, 2, None) + tdSql.checkData(5, 0, datetime.datetime(2021, 4, 19, 8, 0, 5)) + tdSql.checkData(5, 1, 7) + tdSql.checkData(5, 2, None) + tdSql.checkData(6, 0, datetime.datetime(2021, 4, 19, 8, 0, 6)) + tdSql.checkData(6, 1, 8) + tdSql.checkData(6, 2, None) + tdSql.checkData(7, 0, datetime.datetime(2021, 4, 19, 8, 0, 7)) + tdSql.checkData(7, 1, 9) + tdSql.checkData(7, 2, None) + tdSql.checkData(8, 0, datetime.datetime(2021, 4, 19, 8, 0, 8)) + tdSql.checkData(8, 1, 10) + tdSql.checkData(8, 2, None) + tdSql.checkData(9, 0, datetime.datetime(2021, 4, 19, 8, 0, 9)) + tdSql.checkData(9, 1, 9) + tdSql.checkData(9, 2, None) + tdSql.checkData(10, 0, datetime.datetime(2021, 4, 19, 8, 0, 10)) + tdSql.checkData(10, 1, 10) + tdSql.checkData(10, 2, None) + + tdSql.query('select * from d2.st order by ts;') + tdSql.checkRows(4) + tdSql.checkData(0, 0, datetime.datetime(2021, 4, 19, 0, 0)) + tdSql.checkData(0, 1, 1) + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 0, datetime.datetime(2021, 4, 19, 0, 0, 1)) + tdSql.checkData(1, 1, 2) + tdSql.checkData(1, 2, 2) + tdSql.checkData(2, 0, datetime.datetime(2021, 4, 19, 8, 0, 11)) + tdSql.checkData(2, 1, 9) + tdSql.checkData(2, 2, 9) + tdSql.checkData(3, 0, datetime.datetime(2021, 4, 19, 8, 0, 12)) + tdSql.checkData(3, 1, 10) + tdSql.checkData(3, 2, 10) + + tdSql.execute("insert into d2.st(ts, f, tbname) values('2021-04-19 08:00:13', 1, 'ct1') d1.ct1 values('2021-04-19 08:00:14', 1);") + + tdSql.query('select * from d1.st order by ts;') + tdSql.checkRows(12) + tdSql.checkData(0, 0, datetime.datetime(2021, 4, 19, 0, 0)) + tdSql.checkData(0, 1, 1) + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 0, datetime.datetime(2021, 4, 19, 0, 0, 1)) + tdSql.checkData(1, 1, 2) + tdSql.checkData(1, 2, 2) + tdSql.checkData(2, 0, datetime.datetime(2021, 4, 19, 0, 0, 2)) + tdSql.checkData(2, 1, 2) + tdSql.checkData(2, 2, 1) + tdSql.checkData(3, 0, datetime.datetime(2021, 4, 19, 8, 0, 3)) + tdSql.checkData(3, 1, 3) + tdSql.checkData(3, 2, 3) + tdSql.checkData(4, 0, datetime.datetime(2021, 4, 19, 8, 0, 4)) + tdSql.checkData(4, 1, 6) + tdSql.checkData(4, 2, None) + tdSql.checkData(5, 0, datetime.datetime(2021, 4, 19, 8, 0, 5)) + tdSql.checkData(5, 1, 7) + tdSql.checkData(5, 2, None) + tdSql.checkData(6, 0, datetime.datetime(2021, 4, 19, 8, 0, 6)) + tdSql.checkData(6, 1, 8) + tdSql.checkData(6, 2, None) + tdSql.checkData(7, 0, datetime.datetime(2021, 4, 19, 8, 0, 7)) + tdSql.checkData(7, 1, 9) + tdSql.checkData(7, 2, None) + tdSql.checkData(8, 0, datetime.datetime(2021, 4, 19, 8, 0, 8)) + tdSql.checkData(8, 1, 10) + tdSql.checkData(8, 2, None) + tdSql.checkData(9, 0, datetime.datetime(2021, 4, 19, 8, 0, 9)) + tdSql.checkData(9, 1, 9) + tdSql.checkData(9, 2, None) + tdSql.checkData(10, 0, datetime.datetime(2021, 4, 19, 8, 0, 10)) + tdSql.checkData(10, 1, 10) + tdSql.checkData(10, 2, None) + tdSql.checkData(11, 0, datetime.datetime(2021, 4, 19, 8, 0, 14)) + tdSql.checkData(11, 1, 1) + tdSql.checkData(11, 2, 1) + + tdSql.query('select * from d2.st order by ts;') + tdSql.checkRows(5) + tdSql.checkData(0, 0, datetime.datetime(2021, 4, 19, 0, 0)) + tdSql.checkData(0, 1, 1) + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 0, datetime.datetime(2021, 4, 19, 0, 0, 1)) + tdSql.checkData(1, 1, 2) + tdSql.checkData(1, 2, 2) + tdSql.checkData(2, 0, datetime.datetime(2021, 4, 19, 8, 0, 11)) + tdSql.checkData(2, 1, 9) + tdSql.checkData(2, 2, 9) + tdSql.checkData(3, 0, datetime.datetime(2021, 4, 19, 8, 0, 12)) + tdSql.checkData(3, 1, 10) + tdSql.checkData(3, 2, 10) + tdSql.checkData(4, 0, datetime.datetime(2021, 4, 19, 8, 0, 13)) + tdSql.checkData(4, 1, 1) + tdSql.checkData(4, 2, None) + + def run_insert_stb(self): + print("running {}".format('insert_stb')) + self.conn.select_db('insert_stb') + tdSql.execute('create table stb1 (ts timestamp, c1 bool, c2 tinyint, c3 smallint, c4 int, c5 bigint, c6 float, c7 double, c8 binary(10), c9 nchar(10), c10 tinyint unsigned, c11 smallint unsigned, c12 int unsigned, c13 bigint unsigned) TAGS(t1 int, t2 binary(10), t3 double);') + + tdSql.execute('insert into stb1(ts,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,t1,t2,t3,tbname) values (\'2021-11-11 09:00:00\',true,1,1,1,1,1,1,"123","1234",1,1,1,1, 1, \'1\', 1.0, \'tb1\');') + + tdSql.execute("insert into stb1(ts,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,t1,t2,t3,tbname) values ('2021-11-11 09:00:01',true,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, 2, '2', 2.0, 'tb1');") + + tdSql.execute('insert into stb1(ts,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,t1,t2,t3,tbname) values (\'2021-11-11 09:00:02\',true,2,NULL,2,NULL,2,NULL,"234",NULL,2,NULL,2,NULL, 2, \'2\', 2.0, \'tb2\');') + + tdSql.execute('insert into stb1(ts,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,t1,t2,t3,tbname) values (\'2021-11-11 09:00:03\',false,NULL,3,NULL,3,NULL,3,NULL,"3456",NULL,3,NULL,3, 3, \'3\', 3.0, \'tb3\');') + + tdSql.execute('insert into stb1(ts,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,t1,t2,t3,tbname) values (\'2021-11-11 09:00:04\',true,4,4,4,4,4,4,"456","4567",4,4,4,4, 4, \'4.0\', 4.0, \'tb4\');') + + tdSql.execute('insert into stb1(ts,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,t1,t2,t3,tbname) values (\'2021-11-11 09:00:05\',true,127,32767,2147483647,9223372036854775807,3.402823466e+38,1.79769e+308,"567","5678",254,65534,4294967294,9223372036854775807, 5, \'5\', 5, \'max\' );') + + tdSql.execute('insert into stb1(ts,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,t1,t2,t3,tbname) values (\'2021-11-11 09:00:06\',true,-127,-32767,-2147483647,-9223372036854775807,-3.402823466e+38,-1.79769e+308,"678","6789",0,0,0,0, 6, \'6\', 6, \'min\');') + + tdSql.execute('insert into stb1(ts,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,tbname,t1,t2,t3) values (\'2021-11-11 09:00:07\',true,-127,-32767,-2147483647,-9223372036854775807,-3.402823466e+38,-1.79769e+308,"678","6789",0,0,0,0, \'min\', 6, \'6\', 6);') + + tdSql.query('select tbname,* from stb1 order by ts;') + tdSql.checkRows(8) + tdSql.checkData(0, 0, 'tb1') + tdSql.checkData(0, 1, datetime.datetime(2021, 11, 11, 9, 0)) + tdSql.checkData(0, 2, True) + tdSql.checkData(0, 3, 1) + tdSql.checkData(0, 4, 1) + tdSql.checkData(0, 5, 1) + tdSql.checkData(0, 6, 1) + tdSql.checkData(0, 7, 1.0) + tdSql.checkData(0, 8, 1.0) + tdSql.checkData(0, 9, '123') + tdSql.checkData(0, 10, '1234') + tdSql.checkData(0, 11, 1) + tdSql.checkData(0, 12, 1) + tdSql.checkData(0, 13, 1) + tdSql.checkData(0, 14, 1) + tdSql.checkData(0, 15, 1) + tdSql.checkData(0, 16, '1') + tdSql.checkData(0, 17, 1.0) + tdSql.checkData(1, 0, 'tb1') + tdSql.checkData(1, 1, datetime.datetime(2021, 11, 11, 9, 0, 1)) + tdSql.checkData(1, 2, True) + tdSql.checkData(1, 3, None) + tdSql.checkData(1, 4, None) + tdSql.checkData(1, 5, None) + tdSql.checkData(1, 6, None) + tdSql.checkData(1, 7, None) + tdSql.checkData(1, 8, None) + tdSql.checkData(1, 9, None) + tdSql.checkData(1, 10, None) + tdSql.checkData(1, 11, None) + tdSql.checkData(1, 12, None) + tdSql.checkData(1, 13, None) + tdSql.checkData(1, 14, None) + tdSql.checkData(1, 15, 1) + tdSql.checkData(1, 16, '1') + tdSql.checkData(1, 17, 1.0) + tdSql.checkData(2, 0, 'tb2') + tdSql.checkData(2, 1, datetime.datetime(2021, 11, 11, 9, 0, 2)) + tdSql.checkData(2, 2, True) + tdSql.checkData(2, 3, 2) + tdSql.checkData(2, 4, None) + tdSql.checkData(2, 5, 2) + tdSql.checkData(2, 6, None) + tdSql.checkData(2, 7, 2.0) + tdSql.checkData(2, 8, None) + tdSql.checkData(2, 9, '234') + tdSql.checkData(2, 10, None) + tdSql.checkData(2, 11, 2) + tdSql.checkData(2, 12, None) + tdSql.checkData(2, 13, 2) + tdSql.checkData(2, 14, None) + tdSql.checkData(2, 15, 2) + tdSql.checkData(2, 16, '2') + tdSql.checkData(2, 17, 2.0) + tdSql.checkData(3, 0, 'tb3') + tdSql.checkData(3, 1, datetime.datetime(2021, 11, 11, 9, 0, 3)) + tdSql.checkData(3, 2, False) + tdSql.checkData(3, 3, None) + tdSql.checkData(3, 4, 3) + tdSql.checkData(3, 5, None) + tdSql.checkData(3, 6, 3) + tdSql.checkData(3, 7, None) + tdSql.checkData(3, 8, 3.0) + tdSql.checkData(3, 9, None) + tdSql.checkData(3, 10, '3456') + tdSql.checkData(3, 11, None) + tdSql.checkData(3, 12, 3) + tdSql.checkData(3, 13, None) + tdSql.checkData(3, 14, 3) + tdSql.checkData(3, 15, 3) + tdSql.checkData(3, 16, '3') + tdSql.checkData(3, 17, 3.0) + tdSql.checkData(4, 0, 'tb4') + tdSql.checkData(4, 1, datetime.datetime(2021, 11, 11, 9, 0, 4)) + tdSql.checkData(4, 2, True) + tdSql.checkData(4, 3, 4) + tdSql.checkData(4, 4, 4) + tdSql.checkData(4, 5, 4) + tdSql.checkData(4, 6, 4) + tdSql.checkData(4, 7, 4.0) + tdSql.checkData(4, 8, 4.0) + tdSql.checkData(4, 9, '456') + tdSql.checkData(4, 10, '4567') + tdSql.checkData(4, 11, 4) + tdSql.checkData(4, 12, 4) + tdSql.checkData(4, 13, 4) + tdSql.checkData(4, 14, 4) + tdSql.checkData(4, 15, 4) + tdSql.checkData(4, 16, '4.0') + tdSql.checkData(4, 17, 4.0) + tdSql.checkData(5, 0, 'max') + tdSql.checkData(5, 1, datetime.datetime(2021, 11, 11, 9, 0, 5)) + tdSql.checkData(5, 2, True) + tdSql.checkData(5, 3, 127) + tdSql.checkData(5, 4, 32767) + tdSql.checkData(5, 5, 2147483647) + tdSql.checkData(5, 6, 9223372036854775807) + tdSql.checkData(5, 7, 3.4028234663852886e+38) + tdSql.checkData(5, 8, 1.79769e+308) + tdSql.checkData(5, 9, '567') + tdSql.checkData(5, 10, '5678') + tdSql.checkData(5, 11, 254) + tdSql.checkData(5, 12, 65534) + tdSql.checkData(5, 13, 4294967294) + tdSql.checkData(5, 14, 9223372036854775807) + tdSql.checkData(5, 15, 5) + tdSql.checkData(5, 16, '5') + tdSql.checkData(5, 17, 5.0) + tdSql.checkData(6, 0, 'min') + tdSql.checkData(6, 1, datetime.datetime(2021, 11, 11, 9, 0, 6)) + tdSql.checkData(6, 2, True) + tdSql.checkData(6, 3, -127) + tdSql.checkData(6, 4, -32767) + tdSql.checkData(6, 5, -2147483647) + tdSql.checkData(6, 6, -9223372036854775807) + tdSql.checkData(6, 7, -3.4028234663852886e+38) + tdSql.checkData(6, 8, -1.79769e+308) + tdSql.checkData(6, 9, '678') + tdSql.checkData(6, 10, '6789') + tdSql.checkData(6, 11, 0) + tdSql.checkData(6, 12, 0) + tdSql.checkData(6, 13, 0) + tdSql.checkData(6, 14, 0) + tdSql.checkData(6, 15, 6) + tdSql.checkData(6, 16, '6') + tdSql.checkData(6, 17, 6.0) + tdSql.checkData(7, 0, 'min') + tdSql.checkData(7, 1, datetime.datetime(2021, 11, 11, 9, 0, 7)) + tdSql.checkData(7, 2, True) + tdSql.checkData(7, 3, -127) + tdSql.checkData(7, 4, -32767) + tdSql.checkData(7, 5, -2147483647) + tdSql.checkData(7, 6, -9223372036854775807) + tdSql.checkData(7, 7, -3.4028234663852886e+38) + tdSql.checkData(7, 8, -1.79769e+308) + tdSql.checkData(7, 9, '678') + tdSql.checkData(7, 10, '6789') + tdSql.checkData(7, 11, 0) + tdSql.checkData(7, 12, 0) + tdSql.checkData(7, 13, 0) + tdSql.checkData(7, 14, 0) + tdSql.checkData(7, 15, 6) + tdSql.checkData(7, 16, '6') + tdSql.checkData(7, 17, 6.0) + + def run_stmt_error(self): + conn = self.conn + conn.select_db('insert_stb') + conn.execute('create table stb9(ts timestamp, f int) tags (t int)') + try: + stmt = conn.statement("insert into stb9(tbname, f, t) values('ctb91', 1, ?)") + params = taos.new_bind_params(1) + params[0].int(1) + stmt.bind_param(params) + stmt.execute() + result = stmt.use_result() + except Exception as err: + print(str(err)) + + def run_consecutive_seq(self): + print("running {}".format("consecutive_seq")) + tdSql.execute("drop database if exists insert_stb3") + tdSql.execute("create database if not exists insert_stb3") + tdSql.execute('use insert_stb3') + tdSql.execute('create table st (ts timestamp, ti tinyint, si smallint, i int, bi bigint, f float, d double, b binary(10)) tags(t1 int, t2 float, t3 binary(10))') + + tdSql.execute("insert into st(tbname, t1, t2, t3, ts, ti, si, i, bi, f, d, b) values ('ct0', 0, 0.000000, 'childtable', 1546300800000, 0, 0, 0, 0, 0.000000, 0.000000, 'hello') ('ct0', 0, 0.000000, 'childtable', 1546300800001, 1, 1, 1, 1, 1.000000, 2.000000, 'hello')") + + tdSql.execute("insert into st(tbname, t1, t2, t3, ts, ti, si, i, bi, f, d, b) values ('ct1', 1, 1.000000, 'childtable', 1546301800000, 64, 16960, 1000000, 1000000, 1000000.000000, 2000000.000000, 'hello') ('ct1', 1, 1.000000, 'childtable', 1546301800001, 65, 16961, 1000001, 1000001, 1000001.000000, 2000002.000000, 'hello')") + + tdSql.execute("insert into st(tbname, t1, t2, t3, ts, ti, si, i, bi, f, d, b) values ('ct2', 2, 2.000000, 'childtable', 1546302800000, -128, -31616, 2000000, 2000000, 2000000.000000, 4000000.000000, 'hello') ('ct2', 2, 2.000000, 'childtable', 1546302800001, -127, -31615, 2000001, 2000001, 2000001.000000, 4000002.000000, 'hello')") + + tdSql.execute("insert into st(tbname, t1, t2, t3, ts, ti, si, i, bi, f, d, b) values ('ct3', 3, 3.000000, 'childtable', 1546303800000, -64, -14656, 3000000, 3000000, 3000000.000000, 6000000.000000, 'hello') ('ct3', 3, 3.000000, 'childtable', 1546303800001, -63, -14655, 3000001, 3000001, 3000001.000000, 6000002.000000, 'hello')") + + tdSql.execute("insert into st(tbname, t1, t2, t3, ts, ti, si, i, bi, f, d, b) values ('ct4', 4, 4.000000, 'childtable', 1546304800000, 0, 2304, 4000000, 4000000, 4000000.000000, 8000000.000000, 'hello') ('ct4', 4, 4.000000, 'childtable', 1546304800001, 1, 2305, 4000001, 4000001, 4000001.000000, 8000002.000000, 'hello')") + + tdSql.execute("insert into st(tbname, t1, t2, t3, ts, ti, si, i, bi, f, d, b) values ('ct5', 5, 5.000000, 'childtable', 1546305800000, 64, 19264, 5000000, 5000000, 5000000.000000, 10000000.000000, 'hello') ('ct5', 5, 5.000000, 'childtable', 1546305800001, 65, 19265, 5000001, 5000001, 5000001.000000, 10000002.000000, 'hello')") + + tdSql.execute("insert into st(tbname, t1, t2, t3, ts, ti, si, i, bi, f, d, b) values ('ct6', 6, 6.000000, 'childtable', 1546306800000, -128, -29312, 6000000, 6000000, 6000000.000000, 12000000.000000, 'hello') ('ct6', 6, 6.000000, 'childtable', 1546306800001, -127, -29311, 6000001, 6000001, 6000001.000000, 12000002.000000, 'hello')") + + tdSql.execute("insert into st(tbname, t1, t2, t3, ts, ti, si, i, bi, f, d, b) values ('ct7', 7, 7.000000, 'childtable', 1546307800000, -64, -12352, 7000000, 7000000, 7000000.000000, 14000000.000000, 'hello') ('ct7', 7, 7.000000, 'childtable', 1546307800001, -63, -12351, 7000001, 7000001, 7000001.000000, 14000002.000000, 'hello')") + + tdSql.execute("insert into st(tbname, t1, t2, t3, ts, ti, si, i, bi, f, d, b) values ('ct8', 8, 8.000000, 'childtable', 1546308800000, 0, 4608, 8000000, 8000000, 8000000.000000, 16000000.000000, 'hello') ('ct8', 8, 8.000000, 'childtable', 1546308800001, 1, 4609, 8000001, 8000001, 8000001.000000, 16000002.000000, 'hello')") + + tdSql.execute("insert into st(tbname, t1, t2, t3, ts, ti, si, i, bi, f, d, b) values ('ct9', 9, 9.000000, 'childtable', 1546309800000, 64, 21568, 9000000, 9000000, 9000000.000000, 18000000.000000, 'hello') ('ct9', 9, 9.000000, 'childtable', 1546309800001, 65, 21569, 9000001, 9000001, 9000001.000000, 18000002.000000, 'hello')") + + tdSql.query('select * from st order by ts') + tdSql.checkRows(20) + tdSql.checkData(0, 0, datetime.datetime(2019, 1, 1, 8, 0)) + tdSql.checkData(0, 1, 0) + tdSql.checkData(0, 2, 0) + tdSql.checkData(0, 3, 0) + tdSql.checkData(0, 4, 0) + tdSql.checkData(0, 5, 0.0) + tdSql.checkData(0, 6, 0.0) + tdSql.checkData(0, 7, 'hello') + tdSql.checkData(0, 8, 0) + tdSql.checkData(0, 9, 0.0) + tdSql.checkData(0, 10, 'childtable') + tdSql.checkData(1, 0, datetime.datetime(2019, 1, 1, 8, 0, 0, 1000)) + tdSql.checkData(1, 1, 1) + tdSql.checkData(1, 2, 1) + tdSql.checkData(1, 3, 1) + tdSql.checkData(1, 4, 1) + tdSql.checkData(1, 5, 1.0) + tdSql.checkData(1, 6, 2.0) + tdSql.checkData(1, 7, 'hello') + tdSql.checkData(1, 8, 0) + tdSql.checkData(1, 9, 0.0) + tdSql.checkData(1, 10, 'childtable') + tdSql.checkData(2, 0, datetime.datetime(2019, 1, 1, 8, 16, 40)) + tdSql.checkData(2, 1, 64) + tdSql.checkData(2, 2, 16960) + tdSql.checkData(2, 3, 1000000) + tdSql.checkData(2, 4, 1000000) + tdSql.checkData(2, 5, 1000000.0) + tdSql.checkData(2, 6, 2000000.0) + tdSql.checkData(2, 7, 'hello') + tdSql.checkData(2, 8, 1) + tdSql.checkData(2, 9, 1.0) + tdSql.checkData(2, 10, 'childtable') + tdSql.checkData(3, 0, datetime.datetime(2019, 1, 1, 8, 16, 40, 1000)) + tdSql.checkData(3, 1, 65) + tdSql.checkData(3, 2, 16961) + tdSql.checkData(3, 3, 1000001) + tdSql.checkData(3, 4, 1000001) + tdSql.checkData(3, 5, 1000001.0) + tdSql.checkData(3, 6, 2000002.0) + tdSql.checkData(3, 7, 'hello') + tdSql.checkData(3, 8, 1) + tdSql.checkData(3, 9, 1.0) + tdSql.checkData(3, 10, 'childtable') + tdSql.checkData(4, 0, datetime.datetime(2019, 1, 1, 8, 33, 20)) + tdSql.checkData(4, 1, -128) + tdSql.checkData(4, 2, -31616) + tdSql.checkData(4, 3, 2000000) + tdSql.checkData(4, 4, 2000000) + tdSql.checkData(4, 5, 2000000.0) + tdSql.checkData(4, 6, 4000000.0) + tdSql.checkData(4, 7, 'hello') + tdSql.checkData(4, 8, 2) + tdSql.checkData(4, 9, 2.0) + tdSql.checkData(4, 10, 'childtable') + tdSql.checkData(5, 0, datetime.datetime(2019, 1, 1, 8, 33, 20, 1000)) + tdSql.checkData(5, 1, -127) + tdSql.checkData(5, 2, -31615) + tdSql.checkData(5, 3, 2000001) + tdSql.checkData(5, 4, 2000001) + tdSql.checkData(5, 5, 2000001.0) + tdSql.checkData(5, 6, 4000002.0) + tdSql.checkData(5, 7, 'hello') + tdSql.checkData(5, 8, 2) + tdSql.checkData(5, 9, 2.0) + tdSql.checkData(5, 10, 'childtable') + tdSql.checkData(6, 0, datetime.datetime(2019, 1, 1, 8, 50)) + tdSql.checkData(6, 1, -64) + tdSql.checkData(6, 2, -14656) + tdSql.checkData(6, 3, 3000000) + tdSql.checkData(6, 4, 3000000) + tdSql.checkData(6, 5, 3000000.0) + tdSql.checkData(6, 6, 6000000.0) + tdSql.checkData(6, 7, 'hello') + tdSql.checkData(6, 8, 3) + tdSql.checkData(6, 9, 3.0) + tdSql.checkData(6, 10, 'childtable') + tdSql.checkData(7, 0, datetime.datetime(2019, 1, 1, 8, 50, 0, 1000)) + tdSql.checkData(7, 1, -63) + tdSql.checkData(7, 2, -14655) + tdSql.checkData(7, 3, 3000001) + tdSql.checkData(7, 4, 3000001) + tdSql.checkData(7, 5, 3000001.0) + tdSql.checkData(7, 6, 6000002.0) + tdSql.checkData(7, 7, 'hello') + tdSql.checkData(7, 8, 3) + tdSql.checkData(7, 9, 3.0) + tdSql.checkData(7, 10, 'childtable') + tdSql.checkData(8, 0, datetime.datetime(2019, 1, 1, 9, 6, 40)) + tdSql.checkData(8, 1, 0) + tdSql.checkData(8, 2, 2304) + tdSql.checkData(8, 3, 4000000) + tdSql.checkData(8, 4, 4000000) + tdSql.checkData(8, 5, 4000000.0) + tdSql.checkData(8, 6, 8000000.0) + tdSql.checkData(8, 7, 'hello') + tdSql.checkData(8, 8, 4) + tdSql.checkData(8, 9, 4.0) + tdSql.checkData(8, 10, 'childtable') + tdSql.checkData(9, 0, datetime.datetime(2019, 1, 1, 9, 6, 40, 1000)) + tdSql.checkData(9, 1, 1) + tdSql.checkData(9, 2, 2305) + tdSql.checkData(9, 3, 4000001) + tdSql.checkData(9, 4, 4000001) + tdSql.checkData(9, 5, 4000001.0) + tdSql.checkData(9, 6, 8000002.0) + tdSql.checkData(9, 7, 'hello') + tdSql.checkData(9, 8, 4) + tdSql.checkData(9, 9, 4.0) + tdSql.checkData(9, 10, 'childtable') + tdSql.checkData(10, 0, datetime.datetime(2019, 1, 1, 9, 23, 20)) + tdSql.checkData(10, 1, 64) + tdSql.checkData(10, 2, 19264) + tdSql.checkData(10, 3, 5000000) + tdSql.checkData(10, 4, 5000000) + tdSql.checkData(10, 5, 5000000.0) + tdSql.checkData(10, 6, 10000000.0) + tdSql.checkData(10, 7, 'hello') + tdSql.checkData(10, 8, 5) + tdSql.checkData(10, 9, 5.0) + tdSql.checkData(10, 10, 'childtable') + tdSql.checkData(11, 0, datetime.datetime(2019, 1, 1, 9, 23, 20, 1000)) + tdSql.checkData(11, 1, 65) + tdSql.checkData(11, 2, 19265) + tdSql.checkData(11, 3, 5000001) + tdSql.checkData(11, 4, 5000001) + tdSql.checkData(11, 5, 5000001.0) + tdSql.checkData(11, 6, 10000002.0) + tdSql.checkData(11, 7, 'hello') + tdSql.checkData(11, 8, 5) + tdSql.checkData(11, 9, 5.0) + tdSql.checkData(11, 10, 'childtable') + tdSql.checkData(12, 0, datetime.datetime(2019, 1, 1, 9, 40)) + tdSql.checkData(12, 1, -128) + tdSql.checkData(12, 2, -29312) + tdSql.checkData(12, 3, 6000000) + tdSql.checkData(12, 4, 6000000) + tdSql.checkData(12, 5, 6000000.0) + tdSql.checkData(12, 6, 12000000.0) + tdSql.checkData(12, 7, 'hello') + tdSql.checkData(12, 8, 6) + tdSql.checkData(12, 9, 6.0) + tdSql.checkData(12, 10, 'childtable') + tdSql.checkData(13, 0, datetime.datetime(2019, 1, 1, 9, 40, 0, 1000)) + tdSql.checkData(13, 1, -127) + tdSql.checkData(13, 2, -29311) + tdSql.checkData(13, 3, 6000001) + tdSql.checkData(13, 4, 6000001) + tdSql.checkData(13, 5, 6000001.0) + tdSql.checkData(13, 6, 12000002.0) + tdSql.checkData(13, 7, 'hello') + tdSql.checkData(13, 8, 6) + tdSql.checkData(13, 9, 6.0) + tdSql.checkData(13, 10, 'childtable') + tdSql.checkData(14, 0, datetime.datetime(2019, 1, 1, 9, 56, 40)) + tdSql.checkData(14, 1, -64) + tdSql.checkData(14, 2, -12352) + tdSql.checkData(14, 3, 7000000) + tdSql.checkData(14, 4, 7000000) + tdSql.checkData(14, 5, 7000000.0) + tdSql.checkData(14, 6, 14000000.0) + tdSql.checkData(14, 7, 'hello') + tdSql.checkData(14, 8, 7) + tdSql.checkData(14, 9, 7.0) + tdSql.checkData(14, 10, 'childtable') + tdSql.checkData(15, 0, datetime.datetime(2019, 1, 1, 9, 56, 40, 1000)) + tdSql.checkData(15, 1, -63) + tdSql.checkData(15, 2, -12351) + tdSql.checkData(15, 3, 7000001) + tdSql.checkData(15, 4, 7000001) + tdSql.checkData(15, 5, 7000001.0) + tdSql.checkData(15, 6, 14000002.0) + tdSql.checkData(15, 7, 'hello') + tdSql.checkData(15, 8, 7) + tdSql.checkData(15, 9, 7.0) + tdSql.checkData(15, 10, 'childtable') + tdSql.checkData(16, 0, datetime.datetime(2019, 1, 1, 10, 13, 20)) + tdSql.checkData(16, 1, 0) + tdSql.checkData(16, 2, 4608) + tdSql.checkData(16, 3, 8000000) + tdSql.checkData(16, 4, 8000000) + tdSql.checkData(16, 5, 8000000.0) + tdSql.checkData(16, 6, 16000000.0) + tdSql.checkData(16, 7, 'hello') + tdSql.checkData(16, 8, 8) + tdSql.checkData(16, 9, 8.0) + tdSql.checkData(16, 10, 'childtable') + tdSql.checkData(17, 0, datetime.datetime(2019, 1, 1, 10, 13, 20, 1000)) + tdSql.checkData(17, 1, 1) + tdSql.checkData(17, 2, 4609) + tdSql.checkData(17, 3, 8000001) + tdSql.checkData(17, 4, 8000001) + tdSql.checkData(17, 5, 8000001.0) + tdSql.checkData(17, 6, 16000002.0) + tdSql.checkData(17, 7, 'hello') + tdSql.checkData(17, 8, 8) + tdSql.checkData(17, 9, 8.0) + tdSql.checkData(17, 10, 'childtable') + tdSql.checkData(18, 0, datetime.datetime(2019, 1, 1, 10, 30)) + tdSql.checkData(18, 1, 64) + tdSql.checkData(18, 2, 21568) + tdSql.checkData(18, 3, 9000000) + tdSql.checkData(18, 4, 9000000) + tdSql.checkData(18, 5, 9000000.0) + tdSql.checkData(18, 6, 18000000.0) + tdSql.checkData(18, 7, 'hello') + tdSql.checkData(18, 8, 9) + tdSql.checkData(18, 9, 9.0) + tdSql.checkData(18, 10, 'childtable') + tdSql.checkData(19, 0, datetime.datetime(2019, 1, 1, 10, 30, 0, 1000)) + tdSql.checkData(19, 1, 65) + tdSql.checkData(19, 2, 21569) + tdSql.checkData(19, 3, 9000001) + tdSql.checkData(19, 4, 9000001) + tdSql.checkData(19, 5, 9000001.0) + tdSql.checkData(19, 6, 18000002.0) + tdSql.checkData(19, 7, 'hello') + tdSql.checkData(19, 8, 9) + tdSql.checkData(19, 9, 9.0) + tdSql.checkData(19, 10, 'childtable') + + tdSql.execute('drop database insert_stb3') + + def run(self): + self.run_normal() + self.run_insert_stb() + self.run_stmt_error() + self.run_consecutive_seq() + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/2-query/megeFileSttQuery.json b/tests/system-test/2-query/megeFileSttQuery.json new file mode 100644 index 0000000000..5e70674f58 --- /dev/null +++ b/tests/system-test/2-query/megeFileSttQuery.json @@ -0,0 +1,91 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "connection_pool_size": 8, + "thread_count": 100, + "create_table_thread_count": 7, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 100, + "num_of_records_per_req": 100, + "prepared_rand": 10000, + "chinese": "no", + "databases": [ + { + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "precision": "ms", + "vgroups": 1, + "duration": "1d", + "keep": 3650, + "minRows": 100, + "maxRows": 200, + "STT_TRIGGER": 1, + "comp": 2 + }, + "super_tables": [ + { + "name": "meters", + "child_table_exists": "no", + "childtable_count": 1, + "childtable_prefix": "d", + "escape_character": "yes", + "auto_create_table": "no", + "batch_create_tbl_num": 5, + "data_source": "rand", + "insert_mode": "taosc", + "non_stop_mode": "no", + "line_protocol": "line", + "insert_rows": 10000, + "childtable_limit": 0, + "childtable_offset": 100, + "interlace_rows": 0, + "insert_interval": 0, + "partial_col_num": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1000, + "start_timestamp": "2021-10-02 00:01:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "use_sample_ts": "no", + "tags_file": "", + "columns": [ + { + "type": "FLOAT", + "name": "current", + "count": 1, + "max": 12, + "min": 8 + }, + { "type": "INT", "name": "voltage", "max": 225, "min": 215 }, + { "type": "FLOAT", "name": "phase", "max": 1, "min": 0 } + ], + "tags": [ + { + "type": "INT", + "name": "groupid", + "max": -10000, + "min": 10000 + }, + { + "name": "location", + "type": "BINARY", + "len": 16, + "values": ["San Francisco", "Los Angles", "San Diego", + "San Jose", "Palo Alto", "Campbell", "Mountain View", + "Sunnyvale", "Santa Clara", "Cupertino"] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/system-test/2-query/megeFileSttQueryUpdate.json b/tests/system-test/2-query/megeFileSttQueryUpdate.json new file mode 100644 index 0000000000..5d5887649f --- /dev/null +++ b/tests/system-test/2-query/megeFileSttQueryUpdate.json @@ -0,0 +1,91 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "connection_pool_size": 8, + "thread_count": 100, + "create_table_thread_count": 7, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 100, + "num_of_records_per_req": 100, + "prepared_rand": 10000, + "chinese": "no", + "databases": [ + { + "dbinfo": { + "name": "db", + "drop": "no", + "replica": 1, + "precision": "ms", + "vgroups": 1, + "duration": "1d", + "keep": 3650, + "minRows": 100, + "maxRows": 200, + "STT_TRIGGER": 1, + "comp": 2 + }, + "super_tables": [ + { + "name": "meters", + "child_table_exists": "yes", + "childtable_count": 1, + "childtable_prefix": "d", + "escape_character": "yes", + "auto_create_table": "no", + "batch_create_tbl_num": 5, + "data_source": "rand", + "insert_mode": "taosc", + "non_stop_mode": "no", + "line_protocol": "line", + "insert_rows": 4, + "childtable_limit": 0, + "childtable_offset": 100, + "interlace_rows": 0, + "insert_interval": 0, + "partial_col_num": 0, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 3600000, + "start_timestamp": "2021-10-02 00:00:00.001", + "sample_format": "csv", + "sample_file": "./sample.csv", + "use_sample_ts": "no", + "tags_file": "", + "columns": [ + { + "type": "FLOAT", + "name": "current", + "count": 1, + "max": 12, + "min": 8 + }, + { "type": "INT", "name": "voltage", "max": 225, "min": 215 }, + { "type": "FLOAT", "name": "phase", "max": 1, "min": 0 } + ], + "tags": [ + { + "type": "INT", + "name": "groupid", + "max": -10000, + "min": 10000 + }, + { + "name": "location", + "type": "BINARY", + "len": 16, + "values": ["San Francisco", "Los Angles", "San Diego", + "San Jose", "Palo Alto", "Campbell", "Mountain View", + "Sunnyvale", "Santa Clara", "Cupertino"] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/system-test/2-query/mergeFileSttQuery.py b/tests/system-test/2-query/mergeFileSttQuery.py new file mode 100644 index 0000000000..7d2695a760 --- /dev/null +++ b/tests/system-test/2-query/mergeFileSttQuery.py @@ -0,0 +1,71 @@ +import sys +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import time +from datetime import datetime + +class TDTestCase: + def init(self, conn, logSql, replicaVar=1): + self.replicaVar = int(replicaVar) + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def getPath(self, tool="taosBenchmark"): + if (platform.system().lower() == 'windows'): + tool = tool + ".exe" + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + paths = [] + for root, dirs, files in os.walk(projPath): + if ((tool) in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + paths.append(os.path.join(root, tool)) + break + if (len(paths) == 0): + tdLog.exit("taosBenchmark not found!") + return + else: + tdLog.info("taosBenchmark found in %s" % paths[0]) + return paths[0] + + def run(self): + binPath = self.getPath() + tdLog.debug("insert full data block and flush db") + os.system(f"{binPath} -f ./2-query/megeFileSttQuery.json") + tdSql.execute("flush database db;") + tdLog.debug("insert disorder data and flush db") + os.system(f"{binPath} -f ./2-query/megeFileSttQueryUpdate.json") + tdSql.execute("flush database db;") + tdLog.debug("check data") + tdSql.query("select ts from db.d0 limit 5;") + tdSql.checkData(0, 0, '2021-10-02 00:00:00.001') + tdSql.checkData(1, 0, '2021-10-02 00:01:00.000') + tdLog.debug("update disorder data and flush db") + + os.system(f"{binPath} -f ./2-query/megeFileSttQueryUpdate.json") + tdSql.query("select ts from db.d0 limit 5;") + tdSql.checkData(0, 0, '2021-10-02 00:00:00.001') + tdSql.checkData(1, 0, '2021-10-02 00:01:00.000') + tdSql.execute("flush database db;") + tdSql.query("select ts from db.d0 limit 5;") + tdSql.checkData(0, 0, '2021-10-02 00:00:00.001') + tdSql.checkData(1, 0, '2021-10-02 00:01:00.000') + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/7-tmq/tmqVnodeTransform-stb.py b/tests/system-test/7-tmq/tmqVnodeTransform-stb.py index 18c5f8880b..ec1331ae59 100644 --- a/tests/system-test/7-tmq/tmqVnodeTransform-stb.py +++ b/tests/system-test/7-tmq/tmqVnodeTransform-stb.py @@ -49,7 +49,7 @@ class TDTestCase: 'rowsPerTbl': 10000, 'batchNum': 10, 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 - 'pollDelay': 30, + 'pollDelay': 60, 'showMsg': 1, 'showRow': 1, 'snapshot': 0} diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index ea8b5e6169..a1c5405253 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -108,16 +108,17 @@ ELSE () ) EXECUTE_PROCESS( WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/taosadapter - COMMAND git rev-parse --short HEAD + COMMAND git rev-parse HEAD RESULT_VARIABLE commit_sha1 OUTPUT_VARIABLE taosadapter_commit_sha1 ) IF ("${taosadapter_commit_sha1}" STREQUAL "") SET(taosadapter_commit_sha1 "unknown") ELSE () - STRING(SUBSTRING "${taosadapter_commit_sha1}" 0 7 taosadapter_commit_sha1) +# STRING(SUBSTRING "${taosadapter_commit_sha1}" 0 7 taosadapter_commit_sha1) STRING(STRIP "${taosadapter_commit_sha1}" taosadapter_commit_sha1) ENDIF () + SET(taos_version ${TD_VER_NUMBER}) MESSAGE("${Green} taosAdapter will use ${taos_version} and commit ${taosadapter_commit_sha1} as version ${ColourReset}") EXECUTE_PROCESS( COMMAND cd .. @@ -139,9 +140,8 @@ ELSE () BUILD_COMMAND COMMAND set CGO_CFLAGS=-I${CMAKE_CURRENT_SOURCE_DIR}/../include/client COMMAND set CGO_LDFLAGS=-L${CMAKE_BINARY_DIR}/build/lib - # COMMAND go build -a -o taosadapter.exe -ldflags "-X github.com/taosdata/taosadapter/v3/version.Version=${taos_version} -X github.com/taosdata/taosadapter/v3/version.CommitID=${taosadapter_commit_sha1}" - COMMAND go build -a -o taosadapter.exe -ldflags "-s -w -X github.com/taosdata/taosadapter/v3/version.Version=${taos_version} -X github.com/taosdata/taosadapter/v3/version.CommitID=${taosadapter_commit_sha1}" - COMMAND go build -a -o taosadapter-debug.exe -ldflags "-X github.com/taosdata/taosadapter/v3/version.Version=${taos_version} -X github.com/taosdata/taosadapter/v3/version.CommitID=${taosadapter_commit_sha1}" + COMMAND go build -a -o taosadapter.exe -ldflags "-s -w -X 'github.com/taosdata/taosadapter/v3/version.Version=${taos_version}' -X 'github.com/taosdata/taosadapter/v3/version.CommitID=${taosadapter_commit_sha1}' -X 'github.com/taosdata/taosadapter/v3/version.BuildInfo=${TD_VER_DATE}'" + COMMAND go build -a -o taosadapter-debug.exe -ldflags "-X 'github.com/taosdata/taosadapter/v3/version.Version=${taos_version}' -X 'github.com/taosdata/taosadapter/v3/version.CommitID=${taosadapter_commit_sha1}' -X 'github.com/taosdata/taosadapter/v3/version.BuildInfo=${TD_VER_DATE}'" INSTALL_COMMAND COMMAND cmake -E echo "Comparessing taosadapter.exe" @@ -167,9 +167,8 @@ ELSE () PATCH_COMMAND COMMAND git clean -f -d BUILD_COMMAND - # COMMAND CGO_CFLAGS=-I${CMAKE_CURRENT_SOURCE_DIR}/../include/client CGO_LDFLAGS=-L${CMAKE_BINARY_DIR}/build/lib go build -a -ldflags "-X github.com/taosdata/taosadapter/v3/version.Version=${taos_version} -X github.com/taosdata/taosadapter/v3/version.CommitID=${taosadapter_commit_sha1}" - COMMAND CGO_CFLAGS=-I${CMAKE_CURRENT_SOURCE_DIR}/../include/client CGO_LDFLAGS=-L${CMAKE_BINARY_DIR}/build/lib go build -a -ldflags "-s -w -X github.com/taosdata/taosadapter/v3/version.Version=${taos_version} -X github.com/taosdata/taosadapter/v3/version.CommitID=${taosadapter_commit_sha1}" - COMMAND CGO_CFLAGS=-I${CMAKE_CURRENT_SOURCE_DIR}/../include/client CGO_LDFLAGS=-L${CMAKE_BINARY_DIR}/build/lib go build -a -o taosadapter-debug -ldflags "-X github.com/taosdata/taosadapter/v3/version.Version=${taos_version} -X github.com/taosdata/taosadapter/v3/version.CommitID=${taosadapter_commit_sha1}" + COMMAND CGO_CFLAGS=-I${CMAKE_CURRENT_SOURCE_DIR}/../include/client CGO_LDFLAGS=-L${CMAKE_BINARY_DIR}/build/lib go build -a -ldflags "-s -w -X 'github.com/taosdata/taosadapter/v3/version.Version=${taos_version}' -X 'github.com/taosdata/taosadapter/v3/version.CommitID=${taosadapter_commit_sha1}' -X 'github.com/taosdata/taosadapter/v3/version.BuildInfo=${TD_VER_DATE}'" + COMMAND CGO_CFLAGS=-I${CMAKE_CURRENT_SOURCE_DIR}/../include/client CGO_LDFLAGS=-L${CMAKE_BINARY_DIR}/build/lib go build -a -o taosadapter-debug -ldflags "-X 'github.com/taosdata/taosadapter/v3/version.Version=${taos_version}' -X 'github.com/taosdata/taosadapter/v3/version.CommitID=${taosadapter_commit_sha1}' -X 'github.com/taosdata/taosadapter/v3/version.BuildInfo=${TD_VER_DATE}'" INSTALL_COMMAND COMMAND cmake -E echo "Copy taosadapter" COMMAND cmake -E copy taosadapter ${CMAKE_BINARY_DIR}/build/bin @@ -193,9 +192,8 @@ ELSE () PATCH_COMMAND COMMAND git clean -f -d BUILD_COMMAND - # COMMAND CGO_CFLAGS=-I${CMAKE_CURRENT_SOURCE_DIR}/../include/client CGO_LDFLAGS=-L${CMAKE_BINARY_DIR}/build/lib go build -a -ldflags "-X github.com/taosdata/taosadapter/v3/version.Version=${taos_version} -X github.com/taosdata/taosadapter/v3/version.CommitID=${taosadapter_commit_sha1}" - COMMAND CGO_CFLAGS=-I${CMAKE_CURRENT_SOURCE_DIR}/../include/client CGO_LDFLAGS=-L${CMAKE_BINARY_DIR}/build/lib go build -a -ldflags "-s -w -X github.com/taosdata/taosadapter/v3/version.Version=${taos_version} -X github.com/taosdata/taosadapter/v3/version.CommitID=${taosadapter_commit_sha1}" - COMMAND CGO_CFLAGS=-I${CMAKE_CURRENT_SOURCE_DIR}/../include/client CGO_LDFLAGS=-L${CMAKE_BINARY_DIR}/build/lib go build -a -o taosadapter-debug -ldflags "-X github.com/taosdata/taosadapter/v3/version.Version=${taos_version} -X github.com/taosdata/taosadapter/v3/version.CommitID=${taosadapter_commit_sha1}" + COMMAND CGO_CFLAGS=-I${CMAKE_CURRENT_SOURCE_DIR}/../include/client CGO_LDFLAGS=-L${CMAKE_BINARY_DIR}/build/lib go build -a -ldflags "-s -w -X 'github.com/taosdata/taosadapter/v3/version.Version=${taos_version}' -X 'github.com/taosdata/taosadapter/v3/version.CommitID=${taosadapter_commit_sha1}' -X 'github.com/taosdata/taosadapter/v3/version.BuildInfo=${TD_VER_DATE}'" + COMMAND CGO_CFLAGS=-I${CMAKE_CURRENT_SOURCE_DIR}/../include/client CGO_LDFLAGS=-L${CMAKE_BINARY_DIR}/build/lib go build -a -o taosadapter-debug -ldflags "-X 'github.com/taosdata/taosadapter/v3/version.Version=${taos_version}' -X 'github.com/taosdata/taosadapter/v3/version.CommitID=${taosadapter_commit_sha1}' -X 'github.com/taosdata/taosadapter/v3/version.BuildInfo=${TD_VER_DATE}'" INSTALL_COMMAND COMMAND cmake -E echo "Comparessing taosadapter.exe" COMMAND upx taosadapter || : diff --git a/utils/test/c/sml_test.c b/utils/test/c/sml_test.c index 64da4f83e3..9153706d23 100644 --- a/utils/test/c/sml_test.c +++ b/utils/test/c/sml_test.c @@ -1678,8 +1678,8 @@ int main(int argc, char *argv[]) { ASSERT(!ret); ret = sml_td18789_Test(); ASSERT(!ret); -// ret = sml_td24070_Test(); -// ASSERT(!ret); + ret = sml_td24070_Test(); + ASSERT(!ret); ret = sml_td23881_Test(); ASSERT(ret); ret = sml_escape_Test();