diff --git a/Jenkinsfile2 b/Jenkinsfile2 index 165d203a22..f308db759d 100644 --- a/Jenkinsfile2 +++ b/Jenkinsfile2 @@ -424,7 +424,7 @@ pipeline { echo "${WKDIR}/restore.sh -p ${BRANCH_NAME} -n ${BUILD_ID} -c {container name}" } catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { - timeout(time: 130, unit: 'MINUTES'){ + timeout(time: 150, unit: 'MINUTES'){ pre_test() script { sh ''' 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/tglobal.h b/include/common/tglobal.h index 3e29703070..1d0da9e150 100644 --- a/include/common/tglobal.h +++ b/include/common/tglobal.h @@ -195,7 +195,8 @@ extern int64_t tsWalFsyncDataSizeLimit; // internal extern int32_t tsTransPullupInterval; extern int32_t tsMqRebalanceInterval; -extern int32_t tsStreamCheckpointTickInterval; +extern int32_t tsStreamCheckpointInterval; +extern float tsSinkDataRate; extern int32_t tsStreamNodeCheckInterval; extern int32_t tsTtlUnit; extern int32_t tsTtlPushIntervalSec; @@ -204,9 +205,6 @@ extern int32_t tsTrimVDbIntervalSec; extern int32_t tsGrantHBInterval; extern int32_t tsUptimeInterval; -extern int32_t tsRpcRetryLimit; -extern int32_t tsRpcRetryInterval; - extern bool tsDisableStream; extern int64_t tsStreamBufferSize; extern bool tsFilterScalarMode; diff --git a/include/common/tmsg.h b/include/common/tmsg.h index fa123b11f8..4ef4273631 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, @@ -451,7 +445,7 @@ typedef struct SRetention { int8_t keepUnit; } SRetention; -#define RETENTION_VALID(r) (((r)->freq > 0) && ((r)->keep > 0)) +#define RETENTION_VALID(l, r) ((((l) == 0 && (r)->freq >= 0) || ((r)->freq > 0)) && ((r)->keep > 0)) #pragma pack(push, 1) @@ -943,6 +937,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 @@ -951,6 +946,7 @@ typedef struct { int32_t tagCondLen; int32_t numIpRanges; SIpV4Range* pIpRanges; + int64_t privileges; int32_t sqlLen; char* sql; } SAlterUserReq; @@ -979,6 +975,10 @@ typedef struct { SHashObj* writeDbs; SHashObj* readTbs; SHashObj* writeTbs; + SHashObj* alterTbs; + SHashObj* readViews; + SHashObj* writeViews; + SHashObj* alterViews; SHashObj* useDbs; int64_t whiteListVer; } SGetUserAuthRsp; @@ -1568,9 +1568,7 @@ typedef struct { typedef struct { int32_t id; int8_t isMnode; -#ifdef TD_GRANT_HB_OPTIMIZE int8_t offlineReason; -#endif SEp ep; char active[TSDB_ACTIVE_KEY_LEN]; char connActive[TSDB_CONN_ACTIVE_KEY_LEN]; @@ -1811,6 +1809,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; @@ -3883,6 +3890,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..6bc6418467 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, 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/libs/stream/tstream.h b/include/libs/stream/tstream.h index 629efa00b3..5e145d8fbb 100644 --- a/include/libs/stream/tstream.h +++ b/include/libs/stream/tstream.h @@ -38,16 +38,25 @@ extern "C" { #define TASK_DOWNSTREAM_READY 0x0 #define TASK_DOWNSTREAM_NOT_READY 0x1 #define TASK_DOWNSTREAM_NOT_LEADER 0x2 -#define TASK_SELF_NEW_STAGE 0x3 +#define TASK_UPSTREAM_NEW_STAGE 0x3 #define NODE_ROLE_UNINIT 0x1 #define NODE_ROLE_LEADER 0x2 #define NODE_ROLE_FOLLOWER 0x3 -typedef struct SStreamTask SStreamTask; -typedef struct SStreamQueue SStreamQueue; +#define HAS_RELATED_FILLHISTORY_TASK(_t) ((_t)->hTaskInfo.id.taskId != 0) +#define CLEAR_RELATED_FILLHISTORY_TASK(_t) \ + do { \ + (_t)->hTaskInfo.id.taskId = 0; \ + (_t)->hTaskInfo.id.streamId = 0; \ + } while (0) + +typedef struct SStreamTask SStreamTask; +typedef struct SStreamQueue SStreamQueue; +typedef struct SStreamTaskSM SStreamTaskSM; #define SSTREAM_TASK_VER 2 + enum { STREAM_STATUS__NORMAL = 0, STREAM_STATUS__STOP, @@ -58,7 +67,7 @@ enum { }; typedef enum ETaskStatus { - TASK_STATUS__NORMAL = 0, + TASK_STATUS__READY = 0, TASK_STATUS__DROPPING, TASK_STATUS__UNINIT, // not used, an placeholder TASK_STATUS__STOP, @@ -66,6 +75,7 @@ typedef enum ETaskStatus { TASK_STATUS__HALT, // pause, but not be manipulated by user command TASK_STATUS__PAUSE, // pause TASK_STATUS__CK, // stream task is in checkpoint status, no data are allowed to put into inputQ anymore + TASK_STATUS__STREAM_SCAN_HISTORY, } ETaskStatus; enum { @@ -118,6 +128,22 @@ enum { STREAM_META_OK_TO_STOP = 2, }; +typedef enum EStreamTaskEvent { + TASK_EVENT_INIT = 0x1, + TASK_EVENT_INIT_SCANHIST = 0x2, + TASK_EVENT_INIT_STREAM_SCANHIST = 0x3, + TASK_EVENT_SCANHIST_DONE = 0x4, + TASK_EVENT_STOP = 0x5, + TASK_EVENT_GEN_CHECKPOINT = 0x6, + TASK_EVENT_CHECKPOINT_DONE = 0x7, + TASK_EVENT_PAUSE = 0x8, + TASK_EVENT_RESUME = 0x9, + TASK_EVENT_HALT = 0xA, + TASK_EVENT_DROPPING = 0xB, + TASK_EVENT_SCAN_TSDB = 0xC, + TASK_EVENT_SCAN_WAL = 0xD, +} EStreamTaskEvent; + typedef struct { int8_t type; } SStreamQueueItem; @@ -155,11 +181,6 @@ typedef struct { SSDataBlock* pBlock; } SStreamRefDataBlock; -typedef struct { - int8_t type; - SSDataBlock* pBlock; -} SStreamTrigger; - typedef struct SStreamQueueNode SStreamQueueNode; struct SStreamQueueNode { @@ -215,6 +236,11 @@ typedef struct { SUseDbRsp dbInfo; } STaskDispatcherShuffle; +typedef struct { + int32_t nodeId; + SEpSet epset; +} SDownstreamTaskEpset; + typedef struct { int64_t stbUid; char stbFullName[TSDB_TABLE_FNAME_LEN]; @@ -265,14 +291,15 @@ typedef struct SCheckpointInfo { } SCheckpointInfo; typedef struct SStreamStatus { - int8_t taskStatus; - int8_t downstreamReady; // downstream tasks are all ready now, if this flag is set - int8_t schedStatus; - int8_t keepTaskStatus; - bool appendTranstateBlock; // has append the transfer state data block already, todo: remove it - int8_t pauseAllowed; // allowed task status to be set to be paused - int32_t timerActive; // timer is active - int32_t inScanHistorySentinel; + SStreamTaskSM* pSM; + int8_t taskStatus; + int8_t downstreamReady; // downstream tasks are all ready now, if this flag is set + int8_t schedStatus; + int8_t keepTaskStatus; + bool appendTranstateBlock; // has append the transfer state data block already, todo: remove it + int8_t pauseAllowed; // allowed task status to be set to be paused + int32_t timerActive; // timer is active + int32_t inScanHistorySentinel; } SStreamStatus; typedef struct SDataRange { @@ -305,15 +332,10 @@ typedef struct SDispatchMsgInfo { void* pTimer; // used to dispatch data after a given time duration } SDispatchMsgInfo; -typedef struct STaskOutputQueue { +typedef struct STaskQueue { int8_t status; SStreamQueue* queue; -} STaskOutputQueue; - -typedef struct STaskInputInfo { - int8_t status; - SStreamQueue* queue; -} STaskInputInfo; +} STaskQueue; typedef struct STaskSchedInfo { int8_t status; @@ -349,6 +371,7 @@ typedef struct SHistoryTaskInfo { int32_t tickCount; int32_t retryTimes; int32_t waitInterval; + int64_t haltVer; // offset in wal when halt the stream task } SHistoryTaskInfo; typedef struct STaskOutputInfo { @@ -361,6 +384,7 @@ typedef struct STaskOutputInfo { }; int8_t type; STokenBucket* pTokenBucket; + SArray* pDownstreamUpdateList; } STaskOutputInfo; typedef struct SUpstreamInfo { @@ -372,8 +396,8 @@ struct SStreamTask { int64_t ver; SStreamTaskId id; SSTaskBasicInfo info; - STaskOutputQueue outputq; - STaskInputInfo inputInfo; + STaskQueue outputq; + STaskQueue inputq; STaskSchedInfo schedInfo; STaskOutputInfo outputInfo; SDispatchMsgInfo msgInfo; @@ -408,38 +432,43 @@ struct SStreamTask { typedef struct STaskStartInfo { int64_t startTs; int64_t readyTs; - int32_t startedAfterNodeUpdate; + int32_t startAllTasksFlag; SHashObj* pReadyTaskSet; // tasks that are all ready for running stream processing int32_t elapsedTime; } STaskStartInfo; +typedef struct STaskUpdateInfo { + SHashObj* pTasks; + int32_t transId; +} STaskUpdateInfo; + // meta typedef struct SStreamMeta { - char* path; - TDB* db; - TTB* pTaskDb; - TTB* pCheckpointDb; - SHashObj* pTasksMap; - SArray* pTaskList; // SArray - void* ahandle; - TXN* txn; - FTaskExpand* expandFunc; - int32_t vgId; - int64_t stage; - int32_t role; - STaskStartInfo startInfo; - SRWLatch lock; - int32_t walScanCounter; - void* streamBackend; - int64_t streamBackendRid; - SHashObj* pTaskBackendUnique; - TdThreadMutex backendMutex; - SMetaHbInfo* pHbInfo; - SHashObj* pUpdateTaskSet; - int32_t numOfStreamTasks; // this value should be increased when a new task is added into the meta - int32_t numOfPausedTasks; - int32_t chkptNotReadyTasks; - int64_t rid; + char* path; + TDB* db; + TTB* pTaskDb; + TTB* pCheckpointDb; + SHashObj* pTasksMap; + SArray* pTaskList; // SArray + void* ahandle; + TXN* txn; + FTaskExpand* expandFunc; + int32_t vgId; + int64_t stage; + int32_t role; + STaskStartInfo startInfo; + SRWLatch lock; + int32_t walScanCounter; + void* streamBackend; + int64_t streamBackendRid; + SHashObj* pTaskBackendUnique; + TdThreadMutex backendMutex; + SMetaHbInfo* pHbInfo; + STaskUpdateInfo updateInfo; + int32_t numOfStreamTasks; // this value should be increased when a new task is added into the meta + int32_t numOfPausedTasks; + int32_t chkptNotReadyTasks; + int64_t rid; int64_t chkpId; SArray* chkpSaved; @@ -617,7 +646,8 @@ typedef struct STaskStatusEntry { typedef struct SStreamHbMsg { int32_t vgId; int32_t numOfTasks; - SArray* pTaskStatus; // SArray + SArray* pTaskStatus; // SArray + SArray* pUpdateNodes; // SArray, needs update the epsets in stream tasks for those nodes. } SStreamHbMsg; int32_t tEncodeStreamHbMsg(SEncoder* pEncoder, const SStreamHbMsg* pRsp); @@ -641,6 +671,7 @@ typedef struct SNodeUpdateInfo { } SNodeUpdateInfo; typedef struct SStreamTaskNodeUpdateMsg { + int32_t transId; // to identify the msg int64_t streamId; int32_t taskId; SArray* pNodeList; // SArray @@ -686,24 +717,36 @@ SStreamChildEpInfo* streamTaskGetUpstreamTaskEpInfo(SStreamTask* pTask, int32_t void streamTaskInputFail(SStreamTask* pTask); int32_t streamExecTask(SStreamTask* pTask); int32_t streamSchedExec(SStreamTask* pTask); -bool streamTaskShouldStop(const SStreamStatus* pStatus); -bool streamTaskShouldPause(const SStreamStatus* pStatus); +bool streamTaskShouldStop(const SStreamTask* pStatus); +bool streamTaskShouldPause(const SStreamTask* pStatus); bool streamTaskIsIdle(const SStreamTask* pTask); +bool streamTaskReadyToRun(const SStreamTask* pTask, char** pStatus); + +char* createStreamTaskIdStr(int64_t streamId, int32_t taskId); +ETaskStatus streamTaskGetStatus(const SStreamTask* pTask, char** pStr); +const char* streamTaskGetStatusStr(ETaskStatus status); +void streamTaskResetStatus(SStreamTask* pTask); +void streamTaskSetStatusReady(SStreamTask* pTask); void initRpcMsg(SRpcMsg* pMsg, int32_t msgType, void* pCont, int32_t contLen); -char* createStreamTaskIdStr(int64_t streamId, int32_t taskId); - // recover and fill history void streamTaskCheckDownstream(SStreamTask* pTask); -int32_t streamTaskStartScanHistory(SStreamTask* pTask); +int32_t onNormalTaskReady(SStreamTask* pTask); +int32_t onScanhistoryTaskReady(SStreamTask* pTask); + int32_t streamTaskCheckStatus(SStreamTask* pTask, int32_t upstreamTaskId, int32_t vgId, int64_t stage); int32_t streamTaskUpdateEpsetInfo(SStreamTask* pTask, SArray* pNodeList); void streamTaskResetUpstreamStageInfo(SStreamTask* pTask); bool streamTaskAllUpstreamClosed(SStreamTask* pTask); bool streamTaskSetSchedStatusWait(SStreamTask* pTask); int8_t streamTaskSetSchedStatusActive(SStreamTask* pTask); -int8_t streamTaskSetSchedStatusInActive(SStreamTask* pTask); +int8_t streamTaskSetSchedStatusInactive(SStreamTask* pTask); +int32_t streamTaskClearHTaskAttr(SStreamTask* pTask); + +int32_t streamTaskHandleEvent(SStreamTaskSM* pSM, EStreamTaskEvent event); +int32_t streamTaskOnHandleEventSuccess(SStreamTaskSM* pSM, EStreamTaskEvent event); +void streamTaskRestoreStatus(SStreamTask* pTask); int32_t streamTaskStop(SStreamTask* pTask); int32_t streamSendCheckRsp(const SStreamMeta* pMeta, const SStreamTaskCheckReq* pReq, SStreamTaskCheckRsp* pRsp, @@ -714,16 +757,11 @@ int32_t streamTaskScanHistoryDataComplete(SStreamTask* pTask); int32_t streamStartScanHistoryAsync(SStreamTask* pTask, int8_t igUntreated); bool streamHistoryTaskSetVerRangeStep2(SStreamTask* pTask, int64_t latestVer); int32_t streamQueueGetNumOfItems(const SStreamQueue* pQueue); -int32_t streamQueueGetAvailableSpace(const SStreamQueue* pQueue, int32_t* availNum, double* availSize); // common int32_t streamRestoreParam(SStreamTask* pTask); -int32_t streamSetStatusNormal(SStreamTask* pTask); -int32_t streamSetStatusUnint(SStreamTask* pTask); -const char* streamGetTaskStatusStr(int32_t status); void streamTaskPause(SStreamTask* pTask, SStreamMeta* pMeta); -void streamTaskResume(SStreamTask* pTask, SStreamMeta* pMeta); -void streamTaskResumeFromHalt(SStreamTask* pTask); +void streamTaskResume(SStreamTask* pTask); void streamTaskDisablePause(SStreamTask* pTask); void streamTaskEnablePause(SStreamTask* pTask); int32_t streamTaskSetUpstreamInfo(SStreamTask* pTask, const SStreamTask* pUpstreamTask); @@ -759,7 +797,6 @@ int32_t streamMetaRemoveTask(SStreamMeta* pMeta, STaskId* pKey); int32_t streamMetaRegisterTask(SStreamMeta* pMeta, int64_t ver, SStreamTask* pTask, bool* pAdded); int32_t streamMetaUnregisterTask(SStreamMeta* pMeta, int64_t streamId, int32_t taskId); int32_t streamMetaGetNumOfTasks(SStreamMeta* pMeta); -int32_t streamMetaGetNumOfStreamTasks(SStreamMeta* pMeta); SStreamTask* streamMetaAcquireTask(SStreamMeta* pMeta, int64_t streamId, int32_t taskId); void streamMetaReleaseTask(SStreamMeta* pMeta, SStreamTask* pTask); int32_t streamMetaReopen(SStreamMeta* pMeta); @@ -768,12 +805,13 @@ int32_t streamMetaLoadAllTasks(SStreamMeta* pMeta); void streamMetaNotifyClose(SStreamMeta* pMeta); void streamMetaStartHb(SStreamMeta* pMeta); void streamMetaInitForSnode(SStreamMeta* pMeta); +bool streamMetaTaskInTimer(SStreamMeta* pMeta); +int32_t streamMetaUpdateTaskReadyInfo(SStreamTask* pTask); // checkpoint int32_t streamProcessCheckpointSourceReq(SStreamTask* pTask, SStreamCheckpointSourceReq* pReq); int32_t streamProcessCheckpointReadyMsg(SStreamTask* pTask); void streamTaskClearCheckInfo(SStreamTask* pTask); - int32_t streamAlignTransferState(SStreamTask* pTask); int32_t streamBuildAndSendDropTaskMsg(SMsgCb* pMsgCb, int32_t vgId, SStreamTaskId* pTaskId); int32_t streamAddCheckpointSourceRspMsg(SStreamCheckpointSourceReq* pReq, SRpcHandleInfo* pRpcInfo, SStreamTask* pTask, diff --git a/include/util/taoserror.h b/include/util/taoserror.h index b89ea93c7b..6094dbf635 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -332,6 +332,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_MND_INVALID_REPLICA TAOS_DEF_ERROR_CODE(0, 0x03B7) #define TSDB_CODE_MND_DNODE_IN_CREATING TAOS_DEF_ERROR_CODE(0, 0x03B8) #define TSDB_CODE_MND_DNODE_IN_DROPPING TAOS_DEF_ERROR_CODE(0, 0x03B9) +#define TSDB_CODE_MND_NO_ENOUGH_VNODES TAOS_DEF_ERROR_CODE(0, 0x03BA) // mnode-stable-part2 #define TSDB_CODE_MND_NAME_CONFLICT_WITH_TOPIC TAOS_DEF_ERROR_CODE(0, 0x03C0) @@ -383,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 @@ -418,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 @@ -725,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/tconfig.h b/include/util/tconfig.h index aaad467737..34798f3816 100644 --- a/include/util/tconfig.h +++ b/include/util/tconfig.h @@ -65,7 +65,6 @@ typedef struct SConfigItem { union { bool bval; float fval; - double dval; int32_t i32; int64_t i64; char *str; @@ -104,7 +103,6 @@ int32_t cfgAddBool(SConfig *pCfg, const char *name, bool defaultVal, int8_t scop int32_t cfgAddInt32(SConfig *pCfg, const char *name, int32_t defaultVal, int64_t minval, int64_t maxval, int8_t scope); int32_t cfgAddInt64(SConfig *pCfg, const char *name, int64_t defaultVal, int64_t minval, int64_t maxval, int8_t scope); int32_t cfgAddFloat(SConfig *pCfg, const char *name, float defaultVal, float minval, float maxval, int8_t scope); -int32_t cfgAddDouble(SConfig *pCfg, const char *name, double defaultVal, double minval, double maxval, int8_t scope); int32_t cfgAddString(SConfig *pCfg, const char *name, const char *defaultVal, int8_t scope); int32_t cfgAddDir(SConfig *pCfg, const char *name, const char *defaultVal, int8_t scope); int32_t cfgAddLocale(SConfig *pCfg, const char *name, const char *defaultVal, int8_t scope); diff --git a/include/util/tdef.h b/include/util/tdef.h index ffe69dd118..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 @@ -327,7 +330,7 @@ typedef enum ELogicConditionType { #define TSDB_MAX_DAYS_PER_FILE (3650 * 1440) #define TSDB_DEFAULT_DAYS_PER_FILE (10 * 1440) #define TSDB_MIN_DURATION_PER_FILE 60 // unit minute -#define TSDB_MAX_DURATION_PER_FILE (3650 * 1440) +#define TSDB_MAX_DURATION_PER_FILE (90 * 1440) #define TSDB_DEFAULT_DURATION_PER_FILE (10 * 1440) #define TSDB_MIN_KEEP (1 * 1440) // data in db to be reserved. unit minute #define TSDB_MAX_KEEP (365000 * 1440) // data in db to be reserved. diff --git a/include/util/tqueue.h b/include/util/tqueue.h index 503d15e793..9f09bd2930 100644 --- a/include/util/tqueue.h +++ b/include/util/tqueue.h @@ -101,6 +101,9 @@ struct STaosQall { STaosQnode *current; STaosQnode *start; int32_t numOfItems; + int64_t memOfItems; + int32_t unAccessedNumOfItems; + int64_t unAccessMemOfItems; }; STaosQueue *taosOpenQueue(); @@ -123,6 +126,9 @@ int32_t taosReadAllQitems(STaosQueue *queue, STaosQall *qall); int32_t taosGetQitem(STaosQall *qall, void **ppItem); void taosResetQitems(STaosQall *qall); int32_t taosQallItemSize(STaosQall *qall); +int64_t taosQallMemSize(STaosQall *qll); +int64_t taosQallUnAccessedItemSize(STaosQall *qall); +int64_t taosQallUnAccessedMemSize(STaosQall *qall); STaosQset *taosOpenQset(); void taosCloseQset(STaosQset *qset); @@ -135,8 +141,6 @@ int32_t taosReadQitemFromQset(STaosQset *qset, void **ppItem, SQueueInfo *qinfo) int32_t taosReadAllQitemsFromQset(STaosQset *qset, STaosQall *qall, SQueueInfo *qinfo); void taosResetQsetThread(STaosQset *qset, void *pItem); -extern int64_t tsRpcQueueMemoryAllowed; - #ifdef __cplusplus } #endif 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/tglobal.c b/source/common/src/tglobal.c index c6cff27011..d74a704894 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -254,7 +254,8 @@ int32_t tsTtlBatchDropNum = 10000; // number of tables dropped per batch // internal int32_t tsTransPullupInterval = 2; int32_t tsMqRebalanceInterval = 2; -int32_t tsStreamCheckpointTickInterval = 300; +int32_t tsStreamCheckpointInterval = 60; +float tsSinkDataRate = 2.0; int32_t tsStreamNodeCheckInterval = 30; int32_t tsTtlUnit = 86400; int32_t tsTtlPushIntervalSec = 10; @@ -282,8 +283,6 @@ char tsS3Hostname[TSDB_FQDN_LEN] = ""; int32_t tsS3BlockSize = 4096; // number of tsdb pages int32_t tsS3BlockCacheSize = 16; // number of blocks -int32_t tsCheckpointInterval = 300; - #ifndef _STORAGE int32_t taosSetTfsCfg(SConfig *pCfg) { SConfigItem *pItem = cfgGetItem(pCfg, "dataDir"); @@ -512,11 +511,11 @@ static int32_t taosAddSystemCfg(SConfig *pCfg) { if (cfgAddBool(pCfg, "enableCoreFile", 1, CFG_SCOPE_BOTH) != 0) return -1; if (cfgAddFloat(pCfg, "numOfCores", tsNumOfCores, 1, 100000, CFG_SCOPE_BOTH) != 0) return -1; - if (cfgAddBool(pCfg, "SSE42", tsSSE42Enable, CFG_SCOPE_BOTH) != 0) return -1; - if (cfgAddBool(pCfg, "AVX", tsAVXEnable, CFG_SCOPE_BOTH) != 0) return -1; - if (cfgAddBool(pCfg, "AVX2", tsAVX2Enable, CFG_SCOPE_BOTH) != 0) return -1; - if (cfgAddBool(pCfg, "FMA", tsFMAEnable, CFG_SCOPE_BOTH) != 0) return -1; - if (cfgAddBool(pCfg, "SIMD-builtins", tsSIMDBuiltins, CFG_SCOPE_BOTH) != 0) return -1; + if (cfgAddBool(pCfg, "ssd42", tsSSE42Enable, CFG_SCOPE_BOTH) != 0) return -1; + if (cfgAddBool(pCfg, "avx", tsAVXEnable, CFG_SCOPE_BOTH) != 0) return -1; + if (cfgAddBool(pCfg, "avx2", tsAVX2Enable, CFG_SCOPE_BOTH) != 0) return -1; + if (cfgAddBool(pCfg, "fma", tsFMAEnable, CFG_SCOPE_BOTH) != 0) return -1; + if (cfgAddBool(pCfg, "simdEnable", tsSIMDBuiltins, CFG_SCOPE_BOTH) != 0) return -1; if (cfgAddBool(pCfg, "tagFilterCache", tsTagFilterCache, CFG_SCOPE_BOTH) != 0) return -1; if (cfgAddInt64(pCfg, "openMax", tsOpenMax, 0, INT64_MAX, CFG_SCOPE_BOTH) != 0) return -1; @@ -673,18 +672,18 @@ static int32_t taosAddServerCfg(SConfig *pCfg) { if (cfgAddBool(pCfg, "disableStream", tsDisableStream, CFG_SCOPE_SERVER) != 0) return -1; if (cfgAddInt64(pCfg, "streamBufferSize", tsStreamBufferSize, 0, INT64_MAX, CFG_SCOPE_SERVER) != 0) return -1; - if (cfgAddInt64(pCfg, "checkpointInterval", tsStreamCheckpointTickInterval, 60, 1200, CFG_SCOPE_SERVER) != 0) return -1; + if (cfgAddInt64(pCfg, "checkpointInterval", tsStreamCheckpointInterval, 60, 1200, CFG_SCOPE_SERVER) != 0) return -1; + if (cfgAddFloat(pCfg, "streamSinkDataRate", tsSinkDataRate, 0.1, 5, CFG_SCOPE_SERVER) != 0) return -1; - if (cfgAddInt32(pCfg, "cacheLazyLoadThreshold", tsCacheLazyLoadThreshold, 0, 100000, CFG_SCOPE_SERVER) != 0) - return -1; + if (cfgAddInt32(pCfg, "cacheLazyLoadThreshold", tsCacheLazyLoadThreshold, 0, 100000, CFG_SCOPE_SERVER) != 0) return -1; - if (cfgAddString(pCfg, "LossyColumns", tsLossyColumns, CFG_SCOPE_SERVER) != 0) return -1; - if (cfgAddFloat(pCfg, "FPrecision", tsFPrecision, 0.0f, 100000.0f, CFG_SCOPE_SERVER) != 0) return -1; - if (cfgAddDouble(pCfg, "DPrecision", tsDPrecision, 0.0f, 1000000.0f, CFG_SCOPE_SERVER) != 0) return -1; - if (cfgAddInt32(pCfg, "MaxRange", tsMaxRange, 0, 65536, CFG_SCOPE_SERVER) != 0) return -1; - if (cfgAddInt32(pCfg, "CurRange", tsCurRange, 0, 65536, CFG_SCOPE_SERVER) != 0) return -1; - if (cfgAddBool(pCfg, "IfAdtFse", tsIfAdtFse, CFG_SCOPE_SERVER) != 0) return -1; - if (cfgAddString(pCfg, "Compressor", tsCompressor, CFG_SCOPE_SERVER) != 0) return -1; + if (cfgAddString(pCfg, "lossyColumns", tsLossyColumns, CFG_SCOPE_SERVER) != 0) return -1; + if (cfgAddFloat(pCfg, "fPrecision", tsFPrecision, 0.0f, 100000.0f, CFG_SCOPE_SERVER) != 0) return -1; + if (cfgAddFloat(pCfg, "dPrecision", tsDPrecision, 0.0f, 1000000.0f, CFG_SCOPE_SERVER) != 0) return -1; + if (cfgAddInt32(pCfg, "maxRange", tsMaxRange, 0, 65536, CFG_SCOPE_SERVER) != 0) return -1; + if (cfgAddInt32(pCfg, "curRange", tsCurRange, 0, 65536, CFG_SCOPE_SERVER) != 0) return -1; + if (cfgAddBool(pCfg, "ifAdtFse", tsIfAdtFse, CFG_SCOPE_SERVER) != 0) return -1; + if (cfgAddString(pCfg, "compressor", tsCompressor, CFG_SCOPE_SERVER) != 0) return -1; if (cfgAddBool(pCfg, "filterScalarMode", tsFilterScalarMode, CFG_SCOPE_SERVER) != 0) return -1; if (cfgAddInt32(pCfg, "maxStreamBackendCache", tsMaxStreamBackendCache, 16, 1024, CFG_SCOPE_SERVER) != 0) return -1; @@ -1046,7 +1045,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) { tsNumOfSnodeWriteThreads = cfgGetItem(pCfg, "numOfSnodeUniqueThreads")->i32; tsRpcQueueMemoryAllowed = cfgGetItem(pCfg, "rpcQueueMemoryAllowed")->i64; - tsSIMDBuiltins = (bool)cfgGetItem(pCfg, "SIMD-builtins")->bval; + tsSIMDBuiltins = (bool)cfgGetItem(pCfg, "simdEnable")->bval; tsTagFilterCache = (bool)cfgGetItem(pCfg, "tagFilterCache")->bval; tsEnableMonitor = cfgGetItem(pCfg, "monitor")->bval; @@ -1105,16 +1104,18 @@ static int32_t taosSetServerCfg(SConfig *pCfg) { tsCacheLazyLoadThreshold = cfgGetItem(pCfg, "cacheLazyLoadThreshold")->i32; - tstrncpy(tsLossyColumns, cfgGetItem(pCfg, "LossyColumns")->str, sizeof(tsLossyColumns)); - tsFPrecision = cfgGetItem(pCfg, "FPrecision")->fval; - tsDPrecision = cfgGetItem(pCfg, "DPrecision")->dval; - tsMaxRange = cfgGetItem(pCfg, "MaxRange")->i32; - tsCurRange = cfgGetItem(pCfg, "CurRange")->i32; - tsIfAdtFse = cfgGetItem(pCfg, "IfAdtFse")->bval; - tstrncpy(tsCompressor, cfgGetItem(pCfg, "Compressor")->str, sizeof(tsCompressor)); + tstrncpy(tsLossyColumns, cfgGetItem(pCfg, "lossyColumns")->str, sizeof(tsLossyColumns)); + tsFPrecision = cfgGetItem(pCfg, "fPrecision")->fval; + tsDPrecision = cfgGetItem(pCfg, "dPrecision")->fval; + tsMaxRange = cfgGetItem(pCfg, "maxRange")->i32; + tsCurRange = cfgGetItem(pCfg, "curRange")->i32; + tsIfAdtFse = cfgGetItem(pCfg, "ifAdtFse")->bval; + tstrncpy(tsCompressor, cfgGetItem(pCfg, "compressor")->str, sizeof(tsCompressor)); tsDisableStream = cfgGetItem(pCfg, "disableStream")->bval; tsStreamBufferSize = cfgGetItem(pCfg, "streamBufferSize")->i64; + tsStreamCheckpointInterval = cfgGetItem(pCfg, "checkpointInterval")->i32; + tsSinkDataRate = cfgGetItem(pCfg, "streamSinkDataRate")->fval; tsFilterScalarMode = cfgGetItem(pCfg, "filterScalarMode")->bval; tsMaxStreamBackendCache = cfgGetItem(pCfg, "maxStreamBackendCache")->i32; diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index bd6eb46bad..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); } @@ -8405,7 +8574,7 @@ void tDestroySubmitTbData(SSubmitTbData *pTbData, int32_t flag) { } else { tDestroySVCreateTbReq(pTbData->pCreateTbReq, TSDB_MSG_FLG_DECODE); } - taosMemoryFree(pTbData->pCreateTbReq); + taosMemoryFreeClear(pTbData->pCreateTbReq); } if (pTbData->flags & SUBMIT_REQ_COLUMN_DATA_FORMAT) { @@ -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/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c index cc542f51ce..c4d525a871 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c @@ -137,7 +137,7 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) { SRetention *pRetention = &pCfg->tsdbCfg.retentions[i]; memcpy(pRetention, taosArrayGet(pCreate->pRetensions, i), sizeof(SRetention)); if (i == 0) { - if ((pRetention->freq > 0 && pRetention->keep > 0)) pCfg->isRsma = 1; + if ((pRetention->freq >= 0 && pRetention->keep > 0)) pCfg->isRsma = 1; } } diff --git a/source/dnode/mgmt/node_mgmt/inc/dmMgmt.h b/source/dnode/mgmt/node_mgmt/inc/dmMgmt.h index b04d336c51..36097438a2 100644 --- a/source/dnode/mgmt/node_mgmt/inc/dmMgmt.h +++ b/source/dnode/mgmt/node_mgmt/inc/dmMgmt.h @@ -97,11 +97,7 @@ int32_t dmMarkWrapper(SMgmtWrapper *pWrapper); void dmReleaseWrapper(SMgmtWrapper *pWrapper); int32_t dmInitVars(SDnode *pDnode); void dmClearVars(SDnode *pDnode); -#if defined(TD_MODULE_OPTIMIZE) || !defined(TD_ENTERPRISE) int32_t dmInitModule(SDnode *pDnode, SMgmtWrapper *wrappers); -#else -int32_t dmInitModule(SDnode *pDnode); -#endif bool dmRequireNode(SDnode *pDnode, SMgmtWrapper *pWrapper); SMgmtInputOpt dmBuildMgmtInputOpt(SMgmtWrapper *pWrapper); void dmSetStatus(SDnode *pDnode, EDndRunStatus stype); @@ -123,11 +119,7 @@ int32_t dmInitStatusClient(SDnode *pDnode); void dmCleanupClient(SDnode *pDnode); void dmCleanupStatusClient(SDnode *pDnode); SMsgCb dmGetMsgcb(SDnode *pDnode); -#if defined(TD_MODULE_OPTIMIZE) || !defined(TD_ENTERPRISE) int32_t dmInitMsgHandle(SDnode *pDnode, SMgmtWrapper *wrappers); -#else -int32_t dmInitMsgHandle(SDnode *pDnode); -#endif int32_t dmProcessNodeMsg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg); // dmMonitor.c diff --git a/source/dnode/mgmt/node_mgmt/src/dmMgmt.c b/source/dnode/mgmt/node_mgmt/src/dmMgmt.c index e9ce4c4f89..409ee45cd3 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmMgmt.c +++ b/source/dnode/mgmt/node_mgmt/src/dmMgmt.c @@ -66,15 +66,9 @@ int32_t dmInitDnode(SDnode *pDnode) { goto _OVER; } -#if defined(TD_MODULE_OPTIMIZE) || !defined(TD_ENTERPRISE) if (dmInitModule(pDnode, pDnode->wrappers) != 0) { goto _OVER; } -#else - if (dmInitModule(pDnode) != 0) { - goto _OVER; - } -#endif indexInit(tsNumOfCommitThreads); streamMetaInit(); @@ -113,7 +107,6 @@ void dmCleanupDnode(SDnode *pDnode) { dDebug("dnode is closed, ptr:%p", pDnode); } -#if defined(TD_MODULE_OPTIMIZE) || !defined(TD_ENTERPRISE) int32_t dmInitVars(SDnode *pDnode) { SDnodeData *pData = &pDnode->data; pData->dnodeId = 0; @@ -182,7 +175,6 @@ void dmClearVars(SDnode *pDnode) { taosThreadMutexDestroy(&pDnode->mutex); memset(&pDnode->mutex, 0, sizeof(pDnode->mutex)); } -#endif void dmSetStatus(SDnode *pDnode, EDndRunStatus status) { if (pDnode->status != status) { diff --git a/source/dnode/mgmt/node_mgmt/src/dmTransport.c b/source/dnode/mgmt/node_mgmt/src/dmTransport.c index b7381891d1..ad5ca2cecf 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmTransport.c +++ b/source/dnode/mgmt/node_mgmt/src/dmTransport.c @@ -251,7 +251,6 @@ _OVER: dmReleaseWrapper(pWrapper); } -#if defined(TD_MODULE_OPTIMIZE) || !defined(TD_ENTERPRISE) int32_t dmInitMsgHandle(SDnode *pDnode, SMgmtWrapper *wrappers) { SDnodeTrans *pTrans = &pDnode->trans; @@ -277,33 +276,6 @@ int32_t dmInitMsgHandle(SDnode *pDnode, SMgmtWrapper *wrappers) { return 0; } -#else -int32_t dmInitMsgHandle(SDnode *pDnode) { - SDnodeTrans *pTrans = &pDnode->trans; - - for (EDndNodeType ntype = DNODE; ntype < NODE_END; ++ntype) { - SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype]; - SArray *pArray = (*pWrapper->func.getHandlesFp)(); - if (pArray == NULL) return -1; - - for (int32_t i = 0; i < taosArrayGetSize(pArray); ++i) { - SMgmtHandle *pMgmt = taosArrayGet(pArray, i); - SDnodeHandle *pHandle = &pTrans->msgHandles[TMSG_INDEX(pMgmt->msgType)]; - if (pMgmt->needCheckVgId) { - pHandle->needCheckVgId = pMgmt->needCheckVgId; - } - if (!pMgmt->needCheckVgId) { - pHandle->defaultNtype = ntype; - } - pWrapper->msgFps[TMSG_INDEX(pMgmt->msgType)] = pMgmt->msgFp; - } - - taosArrayDestroy(pArray); - } - - return 0; -} -#endif static inline int32_t dmSendReq(const SEpSet *pEpSet, SRpcMsg *pMsg) { SDnode *pDnode = dmInstance(); 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 4e93bcdbe7..a9aa96720c 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -397,9 +397,7 @@ void mndGetDnodeData(SMnode *pMnode, SArray *pDnodeInfo) { SDnodeInfo dInfo; dInfo.id = pDnode->id; dInfo.ep.port = pDnode->port; -#ifdef TD_GRANT_HB_OPTIMIZE dInfo.offlineReason = pDnode->offlineReason; -#endif tstrncpy(dInfo.ep.fqdn, pDnode->fqdn, TSDB_FQDN_LEN); tstrncpy(dInfo.active, pDnode->active, TSDB_ACTIVE_KEY_LEN); tstrncpy(dInfo.connActive, pDnode->connActive, TSDB_CONN_ACTIVE_KEY_LEN); 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 1c87cde78a..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; @@ -281,7 +282,7 @@ static void *mndThreadFp(void *param) { mndCalMqRebalance(pMnode); } - if (sec % tsStreamCheckpointTickInterval == 0) { + if (sec % tsStreamCheckpointInterval == 0) { mndStreamCheckpointTick(pMnode, sec); } @@ -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/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..b149e96c14 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" @@ -466,7 +467,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 +532,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 +589,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/mndScheduler.c b/source/dnode/mnode/impl/src/mndScheduler.c index 2931f6be6b..88a06cb513 100644 --- a/source/dnode/mnode/impl/src/mndScheduler.c +++ b/source/dnode/mnode/impl/src/mndScheduler.c @@ -569,6 +569,10 @@ static int32_t addSinkTasks(SArray* pTasksList, SMnode* pMnode, SStreamObj* pStr } static void setSinkTaskUpstreamInfo(SArray* pTasksList, const SStreamTask* pUpstreamTask) { + if (taosArrayGetSize(pTasksList) < SINK_NODE_LEVEL || pUpstreamTask == NULL) { + return; + } + SArray* pSinkTaskList = taosArrayGetP(pTasksList, SINK_NODE_LEVEL); for(int32_t i = 0; i < taosArrayGetSize(pSinkTaskList); ++i) { SStreamTask* pSinkTask = taosArrayGetP(pSinkTaskList, i); @@ -628,7 +632,9 @@ static int32_t doScheduleStream(SStreamObj* pStream, SMnode* pMnode, SQueryPlan* } setSinkTaskUpstreamInfo(pStream->tasks, pAggTask); - setSinkTaskUpstreamInfo(pStream->pHTasksList, pHAggTask); + if (pHAggTask != NULL) { + setSinkTaskUpstreamInfo(pStream->pHTasksList, pHAggTask); + } // source level return addSourceTasksForMultiLevelStream(pMnode, pPlan, pStream, pAggTask, pHAggTask, pEpset, nextWindowSkey); @@ -722,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 06c0e96c02..6f78f99302 100644 --- a/source/dnode/mnode/impl/src/mndStream.c +++ b/source/dnode/mnode/impl/src/mndStream.c @@ -42,22 +42,22 @@ typedef struct SNodeEntry { int64_t hbTimestamp; // second } SNodeEntry; -typedef struct SStreamExecNodeInfo { +typedef struct SStreamExecInfo { SArray *pNodeEntryList; int64_t ts; // snapshot ts int64_t activeCheckpoint; // active check point id SHashObj *pTaskMap; SArray *pTaskList; TdThreadMutex lock; -} SStreamExecNodeInfo; +} SStreamExecInfo; typedef struct SVgroupChangeInfo { SHashObj *pDBMap; SArray *pUpdateNodeList; // SArray } SVgroupChangeInfo; -static int32_t mndNodeCheckSentinel = 0; -static SStreamExecNodeInfo execNodeList; +static int32_t mndNodeCheckSentinel = 0; +static SStreamExecInfo execInfo; static int32_t mndStreamActionInsert(SSdb *pSdb, SStreamObj *pStream); static int32_t mndStreamActionDelete(SSdb *pSdb, SStreamObj *pStream); @@ -77,19 +77,21 @@ static int32_t mndBuildStreamCheckpointSourceReq2(void **pBuf, int32_t *pLen, in int64_t streamId, int32_t taskId); static int32_t mndProcessNodeCheck(SRpcMsg *pReq); static int32_t mndProcessNodeCheckReq(SRpcMsg *pMsg); +static SArray *extractNodeListFromStream(SMnode *pMnode); +static SArray *mndTakeVgroupSnapshot(SMnode *pMnode, bool* allReady); -static SArray *extractNodeListFromStream(SMnode *pMnode); -static SArray *mndTakeVgroupSnapshot(SMnode *pMnode); static SVgroupChangeInfo mndFindChangedNodeInfo(SMnode *pMnode, const SArray *pPrevNodeList, const SArray *pNodeList); static STrans *doCreateTrans(SMnode *pMnode, SStreamObj *pStream, const char *name); static int32_t mndPersistTransLog(SStreamObj *pStream, STrans *pTrans); -static void initTransAction(STransAction *pAction, void *pCont, int32_t contLen, int32_t msgType, const SEpSet *pEpset); -static int32_t createStreamUpdateTrans(SMnode *pMnode, SStreamObj *pStream, SVgroupChangeInfo *pInfo); - -static void removeStreamTasksInBuf(SStreamObj* pStream, SStreamExecNodeInfo * pExecNode); -static void keepStreamTasksInBuf(SStreamObj *pStream, SStreamExecNodeInfo *pExecNode); +static void initTransAction(STransAction *pAction, void *pCont, int32_t contLen, int32_t msgType, const SEpSet *pEpset, + int32_t retryCode); +static int32_t createStreamUpdateTrans(SStreamObj *pStream, SVgroupChangeInfo *pInfo, STrans *pTrans); +static void removeStreamTasksInBuf(SStreamObj *pStream, SStreamExecInfo *pExecNode); +static void keepStreamTasksInBuf(SStreamObj *pStream, SStreamExecInfo *pExecNode); static int32_t removeExpirednodeEntryAndTask(SArray *pNodeSnapshot); +static int32_t doKillActiveCheckpointTrans(SMnode *pMnode); +static int32_t setNodeEpsetExpiredFlag(const SArray* pNodeList); int32_t mndInitStream(SMnode *pMnode) { SSdbTable table = { @@ -129,18 +131,18 @@ int32_t mndInitStream(SMnode *pMnode) { mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_STREAM_TASKS, mndRetrieveStreamTask); mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_STREAM_TASKS, mndCancelGetNextStreamTask); - taosThreadMutexInit(&execNodeList.lock, NULL); - execNodeList.pTaskMap = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR), true, HASH_NO_LOCK); - execNodeList.pTaskList = taosArrayInit(4, sizeof(STaskId)); + taosThreadMutexInit(&execInfo.lock, NULL); + execInfo.pTaskMap = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR), true, HASH_NO_LOCK); + execInfo.pTaskList = taosArrayInit(4, sizeof(STaskId)); return sdbSetTable(pMnode->pSdb, table); } void mndCleanupStream(SMnode *pMnode) { - taosArrayDestroy(execNodeList.pTaskList); - taosHashCleanup(execNodeList.pTaskMap); - taosThreadMutexDestroy(&execNodeList.lock); - mDebug("mnd stream cleanup"); + taosArrayDestroy(execInfo.pTaskList); + taosHashCleanup(execInfo.pTaskMap); + taosThreadMutexDestroy(&execInfo.lock); + mDebug("mnd stream exec info cleanup"); } SSdbRaw *mndStreamActionEncode(SStreamObj *pStream) { @@ -286,7 +288,7 @@ void mndReleaseStream(SMnode *pMnode, SStreamObj *pStream) { static void mndShowStreamStatus(char *dst, SStreamObj *pStream) { int8_t status = atomic_load_8(&pStream->status); if (status == STREAM_STATUS__NORMAL) { - strcpy(dst, "normal"); + strcpy(dst, "ready"); } else if (status == STREAM_STATUS__STOP) { strcpy(dst, "stop"); } else if (status == STREAM_STATUS__FAILED) { @@ -294,7 +296,7 @@ static void mndShowStreamStatus(char *dst, SStreamObj *pStream) { } else if (status == STREAM_STATUS__RECOVER) { strcpy(dst, "recover"); } else if (status == STREAM_STATUS__PAUSE) { - strcpy(dst, "pause"); + strcpy(dst, "paused"); } } @@ -516,7 +518,7 @@ int32_t mndPersistTaskDeployReq(STrans *pTrans, SStreamTask *pTask) { STransAction action = {0}; action.mTraceId = pTrans->mTraceId; - initTransAction(&action, buf, tlen, TDMT_STREAM_TASK_DEPLOY, &pTask->info.epSet); + initTransAction(&action, buf, tlen, TDMT_STREAM_TASK_DEPLOY, &pTask->info.epSet, 0); if (mndTransAppendRedoAction(pTrans, &action) != 0) { taosMemoryFree(buf); return -1; @@ -688,7 +690,7 @@ static int32_t mndPersistTaskDropReq(STrans *pTrans, SStreamTask *pTask) { pReq->streamId = pTask->id.streamId; STransAction action = {0}; - initTransAction(&action, pReq, sizeof(SVDropStreamTaskReq), TDMT_STREAM_TASK_DROP, &pTask->info.epSet); + initTransAction(&action, pReq, sizeof(SVDropStreamTaskReq), TDMT_STREAM_TASK_DROP, &pTask->info.epSet, 0); if (mndTransAppendRedoAction(pTrans, &action) != 0) { taosMemoryFree(pReq); return -1; @@ -847,10 +849,10 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) { mndTransDrop(pTrans); - taosThreadMutexLock(&execNodeList.lock); + taosThreadMutexLock(&execInfo.lock); mDebug("register to stream task node list"); - keepStreamTasksInBuf(&streamObj, &execNodeList); - taosThreadMutexUnlock(&execNodeList.lock); + keepStreamTasksInBuf(&streamObj, &execInfo); + taosThreadMutexUnlock(&execInfo.lock); code = TSDB_CODE_ACTION_IN_PROGRESS; @@ -882,9 +884,8 @@ static int32_t mndProcessStreamCheckpointTmr(SRpcMsg *pReq) { return 0; } - int64_t checkpointId = taosGetTimestampMs(); SMStreamDoCheckpointMsg *pMsg = rpcMallocCont(sizeof(SMStreamDoCheckpointMsg)); - pMsg->checkpointId = checkpointId; + pMsg->checkpointId = taosGetTimestampMs(); int32_t size = sizeof(SMStreamDoCheckpointMsg); SRpcMsg rpcMsg = {.msgType = TDMT_MND_STREAM_BEGIN_CHECKPOINT, .pCont = pMsg, .contLen = size}; @@ -936,7 +937,7 @@ static int32_t mndBuildStreamCheckpointSourceReq2(void **pBuf, int32_t *pLen, in } // static int32_t mndProcessStreamCheckpointTrans(SMnode *pMnode, SStreamObj *pStream, int64_t checkpointId) { // int64_t timestampMs = taosGetTimestampMs(); -// if (timestampMs - pStream->checkpointFreq < tsStreamCheckpointTickInterval * 1000) { +// if (timestampMs - pStream->checkpointFreq < tsStreamCheckpointInterval * 1000) { // return -1; // } @@ -1069,7 +1070,7 @@ static int32_t mndAddStreamCheckpointToTrans(STrans *pTrans, SStreamObj *pStream STransAction action = {0}; SEpSet epset = mndGetVgroupEpset(pMnode, pVgObj); - initTransAction(&action, buf, tlen, TDMT_VND_STREAM_CHECK_POINT_SOURCE, &epset); + initTransAction(&action, buf, tlen, TDMT_VND_STREAM_CHECK_POINT_SOURCE, &epset, TSDB_CODE_SYN_PROPOSE_NOT_READY); mndReleaseVgroup(pMnode, pVgObj); if (mndTransAppendRedoAction(pTrans, &action) != 0) { @@ -1084,6 +1085,7 @@ static int32_t mndAddStreamCheckpointToTrans(STrans *pTrans, SStreamObj *pStream pStream->checkpointId = chkptId; pStream->checkpointFreq = taosGetTimestampMs(); pStream->currentTick = 0; + // 3. commit log: stream checkpoint info pStream->version = pStream->version + 1; @@ -1133,31 +1135,37 @@ static int32_t mndProcessStreamDoCheckpoint(SRpcMsg *pReq) { { // check if the node update happens or not int64_t ts = taosGetTimestampSec(); - if (execNodeList.pNodeEntryList == NULL || (taosArrayGetSize(execNodeList.pNodeEntryList) == 0)) { - if (execNodeList.pNodeEntryList != NULL) { - execNodeList.pNodeEntryList = taosArrayDestroy(execNodeList.pNodeEntryList); + if (execInfo.pNodeEntryList == NULL || (taosArrayGetSize(execInfo.pNodeEntryList) == 0)) { + if (execInfo.pNodeEntryList != NULL) { + execInfo.pNodeEntryList = taosArrayDestroy(execInfo.pNodeEntryList); } - execNodeList.pNodeEntryList = extractNodeListFromStream(pMnode); + execInfo.pNodeEntryList = extractNodeListFromStream(pMnode); } - if (taosArrayGetSize(execNodeList.pNodeEntryList) == 0) { + if (taosArrayGetSize(execInfo.pNodeEntryList) == 0) { mDebug("stream task node change checking done, no vgroups exist, do nothing"); - execNodeList.ts = ts; + execInfo.ts = ts; return 0; } - for(int32_t i = 0; i < taosArrayGetSize(execNodeList.pNodeEntryList); ++i) { - SNodeEntry* pNodeEntry = taosArrayGet(execNodeList.pNodeEntryList, i); + for(int32_t i = 0; i < taosArrayGetSize(execInfo.pNodeEntryList); ++i) { + SNodeEntry* pNodeEntry = taosArrayGet(execInfo.pNodeEntryList, i); if (pNodeEntry->stageUpdated) { mDebug("stream task not ready due to node update detected, checkpoint not issued"); return 0; } } - SArray *pNodeSnapshot = mndTakeVgroupSnapshot(pMnode); + bool allReady = true; + SArray *pNodeSnapshot = mndTakeVgroupSnapshot(pMnode, &allReady); + if (!allReady) { + mWarn("not all vnodes are ready, ignore the checkpoint") + taosArrayDestroy(pNodeSnapshot); + return 0; + } - SVgroupChangeInfo changeInfo = mndFindChangedNodeInfo(pMnode, execNodeList.pNodeEntryList, pNodeSnapshot); + SVgroupChangeInfo changeInfo = mndFindChangedNodeInfo(pMnode, execInfo.pNodeEntryList, pNodeSnapshot); bool nodeUpdated = (taosArrayGetSize(changeInfo.pUpdateNodeList) > 0); taosArrayDestroy(changeInfo.pUpdateNodeList); taosHashCleanup(changeInfo.pDBMap); @@ -1169,26 +1177,25 @@ static int32_t mndProcessStreamDoCheckpoint(SRpcMsg *pReq) { } } - { // check if all tasks are in TASK_STATUS__NORMAL status + { // check if all tasks are in TASK_STATUS__READY status bool ready = true; - taosThreadMutexLock(&execNodeList.lock); - for (int32_t i = 0; i < taosArrayGetSize(execNodeList.pTaskList); ++i) { - STaskId *p = taosArrayGet(execNodeList.pTaskList, i); - STaskStatusEntry* pEntry = taosHashGet(execNodeList.pTaskMap, p, sizeof(*p)); + taosThreadMutexLock(&execInfo.lock); + for (int32_t i = 0; i < taosArrayGetSize(execInfo.pTaskList); ++i) { + STaskId *p = taosArrayGet(execInfo.pTaskList, i); + STaskStatusEntry* pEntry = taosHashGet(execInfo.pTaskMap, p, sizeof(*p)); if (pEntry == NULL) { continue; } - if (pEntry->status != TASK_STATUS__NORMAL) { + if (pEntry->status != TASK_STATUS__READY) { mDebug("s-task:0x%" PRIx64 "-0x%x (nodeId:%d) status:%s not ready, checkpoint msg not issued", - pEntry->id.streamId, (int32_t)pEntry->id.taskId, 0, streamGetTaskStatusStr(pEntry->status)); + pEntry->id.streamId, (int32_t)pEntry->id.taskId, 0, streamTaskGetStatusStr(pEntry->status)); ready = false; break; } } - taosThreadMutexUnlock(&execNodeList.lock); - + taosThreadMutexUnlock(&execInfo.lock); if (!ready) { return 0; } @@ -1202,7 +1209,8 @@ static int32_t mndProcessStreamDoCheckpoint(SRpcMsg *pReq) { mError("failed to trigger checkpoint, reason: %s", tstrerror(TSDB_CODE_OUT_OF_MEMORY)); return -1; } - mDebug("start to trigger checkpoint, checkpointId: %" PRId64 "", checkpointId); + + mDebug("start to trigger checkpoint, checkpointId: %" PRId64, checkpointId); const char *pDb = mndGetStreamDB(pMnode); mndTransSetDbName(pTrans, pDb, "checkpoint"); @@ -1228,11 +1236,16 @@ static int32_t mndProcessStreamDoCheckpoint(SRpcMsg *pReq) { if (code == 0) { if (mndTransPrepare(pMnode, pTrans) != 0) { - mError("failed to prepre trans rebalance since %s", terrstr()); + mError("failed to prepare trans rebalance since %s", terrstr()); } } mndTransDrop(pTrans); + + // only one trans here + taosThreadMutexLock(&execInfo.lock); + execInfo.activeCheckpoint = checkpointId; + taosThreadMutexUnlock(&execInfo.lock); return code; } @@ -1310,7 +1323,7 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) { return -1; } - removeStreamTasksInBuf(pStream, &execNodeList); + removeStreamTasksInBuf(pStream, &execInfo); SName name = {0}; tNameFromString(&name, dropReq.name, T_NAME_ACCT | T_NAME_DB); @@ -1561,12 +1574,12 @@ static int32_t mndRetrieveStreamTask(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock char status[20 + VARSTR_HEADER_SIZE] = {0}; STaskId id = {.streamId = pTask->id.streamId, .taskId = pTask->id.taskId}; - STaskStatusEntry* pe = taosHashGet(execNodeList.pTaskMap, &id, sizeof(id)); + STaskStatusEntry* pe = taosHashGet(execInfo.pTaskMap, &id, sizeof(id)); if (pe == NULL) { continue; } - const char* pStatus = streamGetTaskStatusStr(pe->status); + const char* pStatus = streamTaskGetStatusStr(pe->status); STR_TO_VARSTR(status, pStatus); // status @@ -1641,7 +1654,7 @@ static int32_t mndPauseStreamTask(STrans *pTrans, SStreamTask *pTask) { pReq->streamId = pTask->id.streamId; STransAction action = {0}; - initTransAction(&action, pReq, sizeof(SVPauseStreamTaskReq), TDMT_STREAM_TASK_PAUSE, &pTask->info.epSet); + initTransAction(&action, pReq, sizeof(SVPauseStreamTaskReq), TDMT_STREAM_TASK_PAUSE, &pTask->info.epSet, 0); if (mndTransAppendRedoAction(pTrans, &action) != 0) { taosMemoryFree(pReq); return -1; @@ -1774,7 +1787,7 @@ static int32_t mndResumeStreamTask(STrans *pTrans, SStreamTask *pTask, int8_t ig pReq->igUntreated = igUntreated; STransAction action = {0}; - initTransAction(&action, pReq, sizeof(SVResumeStreamTaskReq), TDMT_STREAM_TASK_RESUME, &pTask->info.epSet); + initTransAction(&action, pReq, sizeof(SVResumeStreamTaskReq), TDMT_STREAM_TASK_RESUME, &pTask->info.epSet, 0); if (mndTransAppendRedoAction(pTrans, &action) != 0) { taosMemoryFree(pReq); return -1; @@ -1878,18 +1891,19 @@ static int32_t mndProcessResumeStreamReq(SRpcMsg *pReq) { return TSDB_CODE_ACTION_IN_PROGRESS; } -static void initNodeUpdateMsg(SStreamTaskNodeUpdateMsg *pMsg, const SVgroupChangeInfo *pInfo, int64_t streamId, - int32_t taskId) { - pMsg->streamId = streamId; - pMsg->taskId = taskId; +static void initNodeUpdateMsg(SStreamTaskNodeUpdateMsg *pMsg, const SVgroupChangeInfo *pInfo, SStreamTaskId *pId, + int32_t transId) { + pMsg->streamId = pId->streamId; + pMsg->taskId = pId->taskId; + pMsg->transId = transId; pMsg->pNodeList = taosArrayInit(taosArrayGetSize(pInfo->pUpdateNodeList), sizeof(SNodeUpdateInfo)); taosArrayAddAll(pMsg->pNodeList, pInfo->pUpdateNodeList); } static int32_t doBuildStreamTaskUpdateMsg(void **pBuf, int32_t *pLen, SVgroupChangeInfo *pInfo, int32_t nodeId, - int64_t streamId, int32_t taskId) { + SStreamTaskId* pId, int32_t transId) { SStreamTaskNodeUpdateMsg req = {0}; - initNodeUpdateMsg(&req, pInfo, streamId, taskId); + initNodeUpdateMsg(&req, pInfo, pId, transId); int32_t code = 0; int32_t blen; @@ -1953,20 +1967,19 @@ int32_t mndPersistTransLog(SStreamObj *pStream, STrans *pTrans) { return 0; } -void initTransAction(STransAction *pAction, void *pCont, int32_t contLen, int32_t msgType, const SEpSet *pEpset) { +void initTransAction(STransAction *pAction, void *pCont, int32_t contLen, int32_t msgType, const SEpSet *pEpset, + int32_t retryCode) { pAction->epSet = *pEpset; pAction->contLen = contLen; pAction->pCont = pCont; pAction->msgType = msgType; + pAction->retryCode = retryCode; } // todo extract method: traverse stream tasks // build trans to update the epset -static int32_t createStreamUpdateTrans(SMnode *pMnode, SStreamObj *pStream, SVgroupChangeInfo *pInfo) { - STrans* pTrans = doCreateTrans(pMnode, pStream, "stream-task-update"); - if (pTrans == NULL) { - return terrno; - } +static int32_t createStreamUpdateTrans(SStreamObj *pStream, SVgroupChangeInfo *pInfo, STrans *pTrans) { + mDebug("start to build stream:0x%" PRIx64 " tasks epset update", pStream->uid); taosWLockLatch(&pStream->lock); int32_t numOfLevels = taosArrayGetSize(pStream->tasks); @@ -1981,38 +1994,20 @@ static int32_t createStreamUpdateTrans(SMnode *pMnode, SStreamObj *pStream, SVgr void *pBuf = NULL; int32_t len = 0; streamTaskUpdateEpsetInfo(pTask, pInfo->pUpdateNodeList); - doBuildStreamTaskUpdateMsg(&pBuf, &len, pInfo, pTask->info.nodeId, pTask->id.streamId, pTask->id.taskId); + doBuildStreamTaskUpdateMsg(&pBuf, &len, pInfo, pTask->info.nodeId, &pTask->id, pTrans->id); STransAction action = {0}; - initTransAction(&action, pBuf, len, TDMT_VND_STREAM_TASK_UPDATE, &pTask->info.epSet); + initTransAction(&action, pBuf, len, TDMT_VND_STREAM_TASK_UPDATE, &pTask->info.epSet, 0); if (mndTransAppendRedoAction(pTrans, &action) != 0) { taosMemoryFree(pBuf); taosWUnLockLatch(&pStream->lock); - mndTransDrop(pTrans); return -1; } } } taosWUnLockLatch(&pStream->lock); - - int32_t code = mndPersistTransLog(pStream, pTrans); - if (code != TSDB_CODE_SUCCESS) { - sdbRelease(pMnode->pSdb, pStream); - return -1; - } - - if (mndTransPrepare(pMnode, pTrans) != 0) { - mError("trans:%d, failed to prepare update stream trans since %s", pTrans->id, terrstr()); - sdbRelease(pMnode->pSdb, pStream); - mndTransDrop(pTrans); - return -1; - } - - sdbRelease(pMnode->pSdb, pStream); - mndTransDrop(pTrans); - - return TSDB_CODE_ACTION_IN_PROGRESS; + return 0; } static bool isNodeEpsetChanged(const SEpSet *pPrevEpset, const SEpSet *pCurrent) { @@ -2050,8 +2045,8 @@ static SVgroupChangeInfo mndFindChangedNodeInfo(SMnode *pMnode, const SArray *pP char buf[256] = {0}; EPSET_TO_STR(&pCurrent->epset, buf); - mDebug("nodeId:%d epset changed detected, old:%s:%d -> new:%s", pCurrent->nodeId, pPrevEp->fqdn, - pPrevEp->port, buf); + mDebug("nodeId:%d restart/epset changed detected, old:%s:%d -> new:%s, stageUpdate:%d", pCurrent->nodeId, + pPrevEp->fqdn, pPrevEp->port, buf, pPrevEntry->stageUpdated); SNodeUpdateInfo updateInfo = {.nodeId = pPrevEntry->nodeId}; epsetAssign(&updateInfo.prevEp, &pPrevEntry->epset); @@ -2071,11 +2066,12 @@ static SVgroupChangeInfo mndFindChangedNodeInfo(SMnode *pMnode, const SArray *pP return info; } -static SArray *mndTakeVgroupSnapshot(SMnode *pMnode) { +static SArray *mndTakeVgroupSnapshot(SMnode *pMnode, bool* allReady) { SSdb *pSdb = pMnode->pSdb; void *pIter = NULL; SVgObj *pVgroup = NULL; + *allReady = true; SArray *pVgroupListSnapshot = taosArrayInit(4, sizeof(SNodeEntry)); while (1) { @@ -2087,8 +2083,26 @@ static SArray *mndTakeVgroupSnapshot(SMnode *pMnode) { SNodeEntry entry = {0}; entry.epset = mndGetVgroupEpset(pMnode, pVgroup); entry.nodeId = pVgroup->vgId; - entry.hbTimestamp = -1; + entry.hbTimestamp = pVgroup->updateTime; + if (*allReady) { + for (int32_t i = 0; i < pVgroup->replica; ++i) { + if (!pVgroup->vnodeGid[i].syncRestore) { + *allReady = false; + break; + } + + ESyncState state = pVgroup->vnodeGid[i].syncState; + if (state == TAOS_SYNC_STATE_OFFLINE || state == TAOS_SYNC_STATE_ERROR) { + *allReady = false; + break; + } + } + } + + char buf[256] = {0}; + EPSET_TO_STR(&entry.epset, buf); + mDebug("take node snapshot, nodeId:%d %s", entry.nodeId, buf); taosArrayPush(pVgroupListSnapshot, &entry); sdbRelease(pSdb, pVgroup); } @@ -2102,27 +2116,63 @@ static int32_t mndProcessVgroupChange(SMnode *pMnode, SVgroupChangeInfo *pChange // check all streams that involved this vnode should update the epset info SStreamObj *pStream = NULL; void *pIter = NULL; + STrans *pTrans = NULL; + while (1) { pIter = sdbFetch(pSdb, SDB_STREAM, pIter, (void **)&pStream); if (pIter == NULL) { break; } + // here create only one trans + if (pTrans == NULL) { + pTrans = doCreateTrans(pMnode, pStream, "stream-task-update"); + if (pTrans == NULL) { + sdbRelease(pSdb, pStream); + sdbCancelFetch(pSdb, pIter); + return terrno; + } + } + void *p = taosHashGet(pChangeInfo->pDBMap, pStream->targetDb, strlen(pStream->targetDb)); void *p1 = taosHashGet(pChangeInfo->pDBMap, pStream->sourceDb, strlen(pStream->sourceDb)); if (p == NULL && p1 == NULL) { - mndReleaseStream(pMnode, pStream); + mDebug("stream:0x%" PRIx64 " %s not involved nodeUpdate, ignore", pStream->uid, pStream->name); + sdbRelease(pSdb, pStream); continue; } - mDebug("stream:0x%" PRIx64 " involved node changed, create update trans", pStream->uid); - int32_t code = createStreamUpdateTrans(pMnode, pStream, pChangeInfo); + mDebug("stream:0x%" PRIx64 " %s involved node changed, create update trans, transId:%d", pStream->uid, + pStream->name, pTrans->id); + + int32_t code = createStreamUpdateTrans(pStream, pChangeInfo, pTrans); + + // todo: not continue, drop all and retry again + if (code != TSDB_CODE_SUCCESS) { + mError("stream:0x%" PRIx64 " build nodeUpdate trans failed, ignore and continue, code:%s", pStream->uid, + tstrerror(code)); + sdbRelease(pSdb, pStream); + continue; + } + + code = mndPersistTransLog(pStream, pTrans); + sdbRelease(pSdb, pStream); + if (code != TSDB_CODE_SUCCESS) { sdbCancelFetch(pSdb, pIter); - return code; + return -1; } } + if (mndTransPrepare(pMnode, pTrans) != 0) { + mError("trans:%d, failed to prepare update stream trans since %s", pTrans->id, terrstr()); + sdbRelease(pMnode->pSdb, pStream); + mndTransDrop(pTrans); + return -1; + } + + sdbRelease(pMnode->pSdb, pStream); + mndTransDrop(pTrans); return 0; } @@ -2165,6 +2215,10 @@ static SArray *extractNodeListFromStream(SMnode *pMnode) { while ((pIter = taosHashIterate(pHash, pIter)) != NULL) { SNodeEntry *pEntry = (SNodeEntry *)pIter; taosArrayPush(plist, pEntry); + + char buf[256] = {0}; + EPSET_TO_STR(&pEntry->epset, buf); + mDebug("extract nodeInfo from stream obj, nodeId:%d, %s", pEntry->nodeId, buf); } taosHashCleanup(pHash); @@ -2182,28 +2236,31 @@ static void doExtractTasksFromStream(SMnode *pMnode) { break; } - keepStreamTasksInBuf(pStream, &execNodeList); + keepStreamTasksInBuf(pStream, &execInfo); sdbRelease(pSdb, pStream); } } -static int32_t doRemoveFromTask(SStreamExecNodeInfo* pExecNode, STaskId* pRemovedId) { +static int32_t doRemoveTasks(SStreamExecInfo *pExecNode, STaskId *pRemovedId) { void *p = taosHashGet(pExecNode->pTaskMap, pRemovedId, sizeof(*pRemovedId)); + if (p == NULL) { + return TSDB_CODE_SUCCESS; + } - if (p != NULL) { - taosHashRemove(pExecNode->pTaskMap, pRemovedId, sizeof(*pRemovedId)); + taosHashRemove(pExecNode->pTaskMap, pRemovedId, sizeof(*pRemovedId)); - for(int32_t k = 0; k < taosArrayGetSize(pExecNode->pTaskList); ++k) { - STaskId* pId = taosArrayGet(pExecNode->pTaskList, k); - if (pId->taskId == pRemovedId->taskId && pId->streamId == pRemovedId->streamId) { - taosArrayRemove(pExecNode->pTaskList, k); - mInfo("s-task:0x%x removed from buffer, remain:%d", (int32_t) pRemovedId->taskId, - (int32_t)taosArrayGetSize(pExecNode->pTaskList)); - break; - } + for (int32_t k = 0; k < taosArrayGetSize(pExecNode->pTaskList); ++k) { + STaskId *pId = taosArrayGet(pExecNode->pTaskList, k); + if (pId->taskId == pRemovedId->taskId && pId->streamId == pRemovedId->streamId) { + taosArrayRemove(pExecNode->pTaskList, k); + + int32_t num = taosArrayGetSize(pExecNode->pTaskList); + mInfo("s-task:0x%x removed from buffer, remain:%d", (int32_t)pRemovedId->taskId, num); + break; } } - return 0; + + return TSDB_CODE_SUCCESS; } static bool taskNodeExists(SArray* pList, int32_t nodeId) { @@ -2220,31 +2277,31 @@ static bool taskNodeExists(SArray* pList, int32_t nodeId) { } int32_t removeExpirednodeEntryAndTask(SArray *pNodeSnapshot) { - SArray* pRemoveTaskList = taosArrayInit(4, sizeof(STaskId)); + SArray* pRemovedTasks = taosArrayInit(4, sizeof(STaskId)); - int32_t numOfTask = taosArrayGetSize(execNodeList.pTaskList); + int32_t numOfTask = taosArrayGetSize(execInfo.pTaskList); for(int32_t i = 0; i < numOfTask; ++i) { - STaskId* pId = taosArrayGet(execNodeList.pTaskList, i); - STaskStatusEntry* pEntry = taosHashGet(execNodeList.pTaskMap, pId, sizeof(*pId)); + STaskId* pId = taosArrayGet(execInfo.pTaskList, i); + STaskStatusEntry* pEntry = taosHashGet(execInfo.pTaskMap, pId, sizeof(*pId)); bool existed = taskNodeExists(pNodeSnapshot, pEntry->nodeId); if (!existed) { - taosArrayPush(pRemoveTaskList, pId); + taosArrayPush(pRemovedTasks, pId); } } - for(int32_t i = 0; i < taosArrayGetSize(pRemoveTaskList); ++i) { - STaskId* pId = taosArrayGet(pRemoveTaskList, i); - doRemoveFromTask(&execNodeList, pId); + for(int32_t i = 0; i < taosArrayGetSize(pRemovedTasks); ++i) { + STaskId* pId = taosArrayGet(pRemovedTasks, i); + doRemoveTasks(&execInfo, pId); } - mDebug("remove invalid stream tasks:%d, remain:%d", (int32_t)taosArrayGetSize(pRemoveTaskList), - (int32_t) taosArrayGetSize(execNodeList.pTaskList)); + mDebug("remove invalid stream tasks:%d, remain:%d", (int32_t)taosArrayGetSize(pRemovedTasks), + (int32_t) taosArrayGetSize(execInfo.pTaskList)); int32_t size = taosArrayGetSize(pNodeSnapshot); SArray* pValidNodeEntryList = taosArrayInit(4, sizeof(SNodeEntry)); - for(int32_t i = 0; i < taosArrayGetSize(execNodeList.pNodeEntryList); ++i) { - SNodeEntry* p = taosArrayGet(execNodeList.pNodeEntryList, i); + for(int32_t i = 0; i < taosArrayGetSize(execInfo.pNodeEntryList); ++i) { + SNodeEntry* p = taosArrayGet(execInfo.pNodeEntryList, i); for(int32_t j = 0; j < size; ++j) { SNodeEntry* pEntry = taosArrayGet(pNodeSnapshot, j); @@ -2255,10 +2312,11 @@ int32_t removeExpirednodeEntryAndTask(SArray *pNodeSnapshot) { } } - execNodeList.pNodeEntryList = taosArrayDestroy(execNodeList.pNodeEntryList); - execNodeList.pNodeEntryList = pValidNodeEntryList; + execInfo.pNodeEntryList = taosArrayDestroy(execInfo.pNodeEntryList); + execInfo.pNodeEntryList = pValidNodeEntryList; - taosArrayDestroy(pRemoveTaskList); + mDebug("remain %d valid node entries", (int32_t) taosArrayGetSize(pValidNodeEntryList)); + taosArrayDestroy(pRemovedTasks); return 0; } @@ -2275,43 +2333,55 @@ static int32_t mndProcessNodeCheckReq(SRpcMsg *pMsg) { int64_t ts = taosGetTimestampSec(); SMnode *pMnode = pMsg->info.node; - if (execNodeList.pNodeEntryList == NULL || (taosArrayGetSize(execNodeList.pNodeEntryList) == 0)) { - if (execNodeList.pNodeEntryList != NULL) { - execNodeList.pNodeEntryList = taosArrayDestroy(execNodeList.pNodeEntryList); + if (execInfo.pNodeEntryList == NULL || (taosArrayGetSize(execInfo.pNodeEntryList) == 0)) { + if (execInfo.pNodeEntryList != NULL) { + execInfo.pNodeEntryList = taosArrayDestroy(execInfo.pNodeEntryList); } - - execNodeList.pNodeEntryList = extractNodeListFromStream(pMnode); + execInfo.pNodeEntryList = extractNodeListFromStream(pMnode); } - if (taosArrayGetSize(execNodeList.pNodeEntryList) == 0) { + if (taosArrayGetSize(execInfo.pNodeEntryList) == 0) { mDebug("end to do stream task node change checking, no vgroup exists, do nothing"); - execNodeList.ts = ts; + execInfo.ts = ts; atomic_store_32(&mndNodeCheckSentinel, 0); return 0; } - SArray *pNodeSnapshot = mndTakeVgroupSnapshot(pMnode); + bool allVnodeReady = true; + SArray *pNodeSnapshot = mndTakeVgroupSnapshot(pMnode, &allVnodeReady); + if (!allVnodeReady) { + taosArrayDestroy(pNodeSnapshot); + atomic_store_32(&mndNodeCheckSentinel, 0); + mWarn("not all vnodes are ready, ignore the exec nodeUpdate check"); + return 0; + } - taosThreadMutexLock(&execNodeList.lock); + taosThreadMutexLock(&execInfo.lock); removeExpirednodeEntryAndTask(pNodeSnapshot); - SVgroupChangeInfo changeInfo = mndFindChangedNodeInfo(pMnode, execNodeList.pNodeEntryList, pNodeSnapshot); + SVgroupChangeInfo changeInfo = mndFindChangedNodeInfo(pMnode, execInfo.pNodeEntryList, pNodeSnapshot); if (taosArrayGetSize(changeInfo.pUpdateNodeList) > 0) { + + // kill current active checkpoint transaction, since the transaction is vnode wide. + doKillActiveCheckpointTrans(pMnode); code = mndProcessVgroupChange(pMnode, &changeInfo); // keep the new vnode snapshot if (code == TSDB_CODE_SUCCESS || code == TSDB_CODE_ACTION_IN_PROGRESS) { mDebug("create trans successfully, update cached node list"); - taosArrayDestroy(execNodeList.pNodeEntryList); - execNodeList.pNodeEntryList = pNodeSnapshot; - execNodeList.ts = ts; + taosArrayDestroy(execInfo.pNodeEntryList); + execInfo.pNodeEntryList = pNodeSnapshot; + execInfo.ts = ts; + } else { + mDebug("unexpect code during create nodeUpdate trans, code:%s", tstrerror(code)); + taosArrayDestroy(pNodeSnapshot); } } else { mDebug("no update found in nodeList"); taosArrayDestroy(pNodeSnapshot); } - taosThreadMutexUnlock(&execNodeList.lock); + taosThreadMutexUnlock(&execInfo.lock); taosArrayDestroy(changeInfo.pUpdateNodeList); taosHashCleanup(changeInfo.pDBMap); @@ -2324,10 +2394,6 @@ typedef struct SMStreamNodeCheckMsg { int8_t placeHolder; // // to fix windows compile error, define place holder } SMStreamNodeCheckMsg; -typedef struct SMStreamTaskResetMsg { - int8_t placeHolder; -} SMStreamTaskResetMsg; - static int32_t mndProcessNodeCheck(SRpcMsg *pReq) { SMnode *pMnode = pReq->info.node; SSdb *pSdb = pMnode->pSdb; @@ -2343,7 +2409,7 @@ static int32_t mndProcessNodeCheck(SRpcMsg *pReq) { return 0; } -void keepStreamTasksInBuf(SStreamObj *pStream, SStreamExecNodeInfo *pExecNode) { +void keepStreamTasksInBuf(SStreamObj *pStream, SStreamExecInfo *pExecNode) { int32_t level = taosArrayGetSize(pStream->tasks); for (int32_t i = 0; i < level; i++) { @@ -2368,7 +2434,7 @@ void keepStreamTasksInBuf(SStreamObj *pStream, SStreamExecNodeInfo *pExecNode) { } } -void removeStreamTasksInBuf(SStreamObj* pStream, SStreamExecNodeInfo * pExecNode) { +void removeStreamTasksInBuf(SStreamObj* pStream, SStreamExecInfo * pExecNode) { int32_t level = taosArrayGetSize(pStream->tasks); for (int32_t i = 0; i < level; i++) { SArray *pLevel = taosArrayGetP(pStream->tasks, i); @@ -2399,7 +2465,7 @@ void removeStreamTasksInBuf(SStreamObj* pStream, SStreamExecNodeInfo * pExecNode ASSERT(taosHashGetSize(pExecNode->pTaskMap) == taosArrayGetSize(pExecNode->pTaskList)); } -static STrans* doCreateTrans(SMnode* pMnode, SStreamObj* pStream, const char* name) { +STrans *doCreateTrans(SMnode *pMnode, SStreamObj *pStream, const char *name) { STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB_INSIDE, NULL, name); if (pTrans == NULL) { mError("failed to build trans:%s, reason: %s", name, tstrerror(TSDB_CODE_OUT_OF_MEMORY)); @@ -2451,7 +2517,7 @@ int32_t createStreamResetStatusTrans(SMnode* pMnode, SStreamObj* pStream) { pReq->streamId = pTask->id.streamId; STransAction action = {0}; - initTransAction(&action, pReq, sizeof(SVResetStreamTaskReq), TDMT_VND_STREAM_TASK_RESET, &pTask->info.epSet); + initTransAction(&action, pReq, sizeof(SVResetStreamTaskReq), TDMT_VND_STREAM_TASK_RESET, &pTask->info.epSet, 0); if (mndTransAppendRedoAction(pTrans, &action) != 0) { taosMemoryFree(pReq); taosWUnLockLatch(&pStream->lock); @@ -2482,29 +2548,26 @@ int32_t createStreamResetStatusTrans(SMnode* pMnode, SStreamObj* pStream) { return TSDB_CODE_ACTION_IN_PROGRESS; } -int32_t mndResetFromCheckpoint(SMnode* pMnode) { - // find the checkpoint trans id +int32_t doKillActiveCheckpointTrans(SMnode *pMnode) { int32_t transId = 0; + SSdb *pSdb = pMnode->pSdb; + STrans *pTrans = NULL; + void *pIter = NULL; - { - SSdb *pSdb = pMnode->pSdb; - STrans *pTrans = NULL; - void* pIter = NULL; - while (1) { - pIter = sdbFetch(pSdb, SDB_TRANS, pIter, (void **)&pTrans); - if (pIter == NULL) { - break; - } - - if (strncmp(pTrans->opername, MND_STREAM_CHECKPOINT_NAME, tListLen(pTrans->opername) - 1) == 0) { - transId = pTrans->id; - sdbRelease(pSdb, pTrans); - sdbCancelFetch(pSdb, pIter); - break; - } - - sdbRelease(pSdb, pTrans); + while (1) { + pIter = sdbFetch(pSdb, SDB_TRANS, pIter, (void **)&pTrans); + if (pIter == NULL) { + break; } + + if (strncmp(pTrans->opername, MND_STREAM_CHECKPOINT_NAME, tListLen(pTrans->opername) - 1) == 0) { + transId = pTrans->id; + sdbRelease(pSdb, pTrans); + sdbCancelFetch(pSdb, pIter); + break; + } + + sdbRelease(pSdb, pTrans); } if (transId == 0) { @@ -2512,8 +2575,16 @@ int32_t mndResetFromCheckpoint(SMnode* pMnode) { return TSDB_CODE_SUCCESS; } - STrans* pTrans = mndAcquireTrans(pMnode, transId); + pTrans = mndAcquireTrans(pMnode, transId); + mInfo("kill checkpoint trans:%d", transId); + mndKillTrans(pMnode, pTrans); + mndReleaseTrans(pMnode, pTrans); + return TSDB_CODE_SUCCESS; +} + +int32_t mndResetFromCheckpoint(SMnode* pMnode) { + doKillActiveCheckpointTrans(pMnode); // set all tasks status to be normal, refactor later to be stream level, instead of vnode level. SSdb *pSdb = pMnode->pSdb; @@ -2525,6 +2596,7 @@ int32_t mndResetFromCheckpoint(SMnode* pMnode) { break; } + // todo this transaction should exist be only one mDebug("stream:%s (0x%" PRIx64 ") reset checkpoint procedure, create reset trans", pStream->name, pStream->uid); int32_t code = createStreamResetStatusTrans(pMnode, pStream); if (code != TSDB_CODE_SUCCESS) { @@ -2536,6 +2608,43 @@ int32_t mndResetFromCheckpoint(SMnode* pMnode) { return 0; } +int32_t setNodeEpsetExpiredFlag(const SArray* pNodeList) { + int32_t num = taosArrayGetSize(pNodeList); + + for (int k = 0; k < num; ++k) { + int32_t* pVgId = taosArrayGet(pNodeList, k); + + int32_t numOfNodes = taosArrayGetSize(execInfo.pNodeEntryList); + for (int i = 0; i < numOfNodes; ++i) { + SNodeEntry* pNodeEntry = taosArrayGet(execInfo.pNodeEntryList, i); + + if (pNodeEntry->nodeId == *pVgId) { + mInfo("vgId:%d expired in stream task, needs update nodeEp", *pVgId); + pNodeEntry->stageUpdated = true; + break; + } + } + } + + return TSDB_CODE_SUCCESS; +} + +static void updateStageInfo(STaskStatusEntry* pTaskEntry, int32_t stage) { + int32_t numOfNodes = taosArrayGetSize(execInfo.pNodeEntryList); + for(int32_t j = 0; j < numOfNodes; ++j) { + SNodeEntry* pNodeEntry = taosArrayGet(execInfo.pNodeEntryList, j); + if (pNodeEntry->nodeId == pTaskEntry->nodeId) { + + mInfo("vgId:%d stage updated from %d to %d, nodeUpdate trigger by s-task:0x%" PRIx64, pTaskEntry->nodeId, + pTaskEntry->stage, stage, pTaskEntry->id.taskId); + + pNodeEntry->stageUpdated = true; + pTaskEntry->stage = stage; + break; + } + } +} + int32_t mndProcessStreamHb(SRpcMsg *pReq) { SMnode *pMnode = pReq->info.node; SStreamHbMsg req = {0}; @@ -2555,35 +2664,26 @@ int32_t mndProcessStreamHb(SRpcMsg *pReq) { mTrace("receive stream-meta hb from vgId:%d, active numOfTasks:%d", req.vgId, req.numOfTasks); - taosThreadMutexLock(&execNodeList.lock); - int32_t numOfExisted = taosHashGetSize(execNodeList.pTaskMap); + taosThreadMutexLock(&execInfo.lock); + int32_t numOfExisted = taosHashGetSize(execInfo.pTaskMap); if (numOfExisted == 0) { doExtractTasksFromStream(pMnode); } + setNodeEpsetExpiredFlag(req.pUpdateNodes); + for (int32_t i = 0; i < req.numOfTasks; ++i) { STaskStatusEntry *p = taosArrayGet(req.pTaskStatus, i); - STaskStatusEntry *pEntry = taosHashGet(execNodeList.pTaskMap, &p->id, sizeof(p->id)); - if (pEntry == NULL) { + STaskStatusEntry *pTaskEntry = taosHashGet(execInfo.pTaskMap, &p->id, sizeof(p->id)); + if (pTaskEntry == NULL) { mError("s-task:0x%" PRIx64 " not found in mnode task list", p->id.taskId); continue; } - if (p->stage != pEntry->stage && pEntry->stage != -1) { - int32_t numOfNodes = taosArrayGetSize(execNodeList.pNodeEntryList); - for(int32_t j = 0; j < numOfNodes; ++j) { - SNodeEntry* pNodeEntry = taosArrayGet(execNodeList.pNodeEntryList, j); - if (pNodeEntry->nodeId == pEntry->nodeId) { - mInfo("vgId:%d stage updated, from %d to %d, nodeUpdate trigger by s-task:0x%" PRIx64, - pEntry->nodeId, pEntry->stage, p->stage, pEntry->id.taskId); - - pNodeEntry->stageUpdated = true; - pEntry->stage = p->stage; - break; - } - } + if (pTaskEntry->stage != p->stage && pTaskEntry->stage != -1) { + updateStageInfo(pTaskEntry, p->stage); } else { - streamTaskStatusCopy(pEntry, p); + streamTaskStatusCopy(pTaskEntry, p); if (p->activeCheckpointId != 0) { if (activeCheckpointId != 0) { ASSERT(activeCheckpointId == p->activeCheckpointId); @@ -2597,26 +2697,32 @@ int32_t mndProcessStreamHb(SRpcMsg *pReq) { } } - pEntry->status = p->status; - if (p->status != TASK_STATUS__NORMAL) { - mDebug("received s-task:0x%"PRIx64" not in ready status:%s", p->id.taskId, streamGetTaskStatusStr(p->status)); + pTaskEntry->status = p->status; + if (p->status != TASK_STATUS__READY) { + mDebug("received s-task:0x%"PRIx64" not in ready status:%s", p->id.taskId, streamTaskGetStatusStr(p->status)); } } // current checkpoint is failed, rollback from the checkpoint trans // kill the checkpoint trans and then set all tasks status to be normal if (checkpointFailed && activeCheckpointId != 0) { - if (execNodeList.activeCheckpoint != activeCheckpointId) { - mInfo("checkpointId:%"PRId64" failed, issue task-reset trans to reset all tasks status", activeCheckpointId); - execNodeList.activeCheckpoint = activeCheckpointId; + bool allReady = true; + SArray* p = mndTakeVgroupSnapshot(pMnode, &allReady); + taosArrayDestroy(p); + + if (allReady) { + // if the execInfo.activeCheckpoint == 0, the checkpoint is restoring from wal + mInfo("checkpointId:%" PRId64 " failed, issue task-reset trans to reset all tasks status", + execInfo.activeCheckpoint); mndResetFromCheckpoint(pMnode); } else { - mDebug("checkpoint:%"PRId64" reset has issued already, ignore it", activeCheckpointId); + mInfo("not all vgroups are ready, wait for next HB from stream tasks"); } } - taosThreadMutexUnlock(&execNodeList.lock); + taosThreadMutexUnlock(&execInfo.lock); taosArrayDestroy(req.pTaskStatus); + taosArrayDestroy(req.pUpdateNodes); return TSDB_CODE_SUCCESS; } 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..11d75934be 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); @@ -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; } } @@ -1481,60 +1767,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 +1990,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) { @@ -1827,12 +2101,12 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) { alterReq.alterType == TSDB_ALTER_USER_SYSINFO){ 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); @@ -1843,11 +2117,11 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) { alterReq.sql, alterReq.sqlLen); } } - else if(alterReq.alterType == TSDB_ALTER_USER_ADD_SUBSCRIBE_TOPIC){ + else if(ALTER_USER_ADD_SUBSCRIBE_TOPIC_PRIV(alterReq.alterType, alterReq.privileges)){ auditRecord(pReq, pMnode->clusterId, "GrantPrivileges", alterReq.user, alterReq.objname, alterReq.sql, alterReq.sqlLen); } - else if(alterReq.alterType == TSDB_ALTER_USER_REMOVE_SUBSCRIBE_TOPIC){ + else if(ALTER_USER_DEL_SUBSCRIBE_TOPIC_PRIV(alterReq.alterType, alterReq.privileges)){ auditRecord(pReq, pMnode->clusterId, "RevokePrivileges", alterReq.user, alterReq.objname, alterReq.sql, alterReq.sqlLen); } @@ -2092,7 +2366,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 +2387,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 +2439,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 +2481,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 +2521,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 +2562,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 +2575,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 +2613,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 +2766,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 +2790,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 417dcb0ce0..54e28948ef 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -754,10 +754,14 @@ static int32_t mndGetAvailableDnode(SMnode *pMnode, SDbObj *pDb, SVgObj *pVgroup for (int32_t v = 0; v < pVgroup->replica; ++v) { SVnodeGid *pVgid = &pVgroup->vnodeGid[v]; SDnodeObj *pDnode = taosArrayGet(pArray, v); - if (pDnode == NULL || pDnode->numOfVnodes >= pDnode->numOfSupportVnodes) { + if (pDnode == NULL) { terrno = TSDB_CODE_MND_NO_ENOUGH_DNODES; return -1; } + if (pDnode->numOfVnodes >= pDnode->numOfSupportVnodes) { + terrno = TSDB_CODE_MND_NO_ENOUGH_VNODES; + return -1; + } int64_t vgMem = mndGetVgroupMemory(pMnode, pDb, pVgroup); if (pDnode->memAvail - vgMem - pDnode->memUsed <= 0) { @@ -1180,10 +1184,14 @@ static int32_t mndAddVnodeToVgroup(SMnode *pMnode, STrans *pTrans, SVgObj *pVgro } if (used) continue; - if (pDnode == NULL || pDnode->numOfVnodes >= pDnode->numOfSupportVnodes) { + if (pDnode == NULL) { terrno = TSDB_CODE_MND_NO_ENOUGH_DNODES; return -1; } + if (pDnode->numOfVnodes >= pDnode->numOfSupportVnodes) { + terrno = TSDB_CODE_MND_NO_ENOUGH_VNODES; + return -1; + } int64_t vgMem = mndGetVgroupMemory(pMnode, NULL, pVgroup); if (pDnode->memAvail - vgMem - pDnode->memUsed <= 0) { @@ -1912,7 +1920,7 @@ static int32_t mndRedistributeVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, if (numOfVnodes >= pNew1->numOfSupportVnodes) { mError("vgId:%d, no enough vnodes in dnode:%d, numOfVnodes:%d support:%d", newVg.vgId, pNew1->id, numOfVnodes, pNew1->numOfSupportVnodes); - terrno = TSDB_CODE_MND_NO_ENOUGH_DNODES; + terrno = TSDB_CODE_MND_NO_ENOUGH_VNODES; goto _OVER; } @@ -1935,7 +1943,7 @@ static int32_t mndRedistributeVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, if (numOfVnodes >= pNew2->numOfSupportVnodes) { mError("vgId:%d, no enough vnodes in dnode:%d, numOfVnodes:%d support:%d", newVg.vgId, pNew2->id, numOfVnodes, pNew2->numOfSupportVnodes); - terrno = TSDB_CODE_MND_NO_ENOUGH_DNODES; + terrno = TSDB_CODE_MND_NO_ENOUGH_VNODES; goto _OVER; } int64_t vgMem = mndGetVgroupMemory(pMnode, NULL, pVgroup); @@ -1956,7 +1964,7 @@ static int32_t mndRedistributeVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, if (numOfVnodes >= pNew3->numOfSupportVnodes) { mError("vgId:%d, no enough vnodes in dnode:%d, numOfVnodes:%d support:%d", newVg.vgId, pNew3->id, numOfVnodes, pNew3->numOfSupportVnodes); - terrno = TSDB_CODE_MND_NO_ENOUGH_DNODES; + terrno = TSDB_CODE_MND_NO_ENOUGH_VNODES; goto _OVER; } int64_t vgMem = mndGetVgroupMemory(pMnode, NULL, pVgroup); 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/snode/src/snode.c b/source/dnode/snode/src/snode.c index 6451dba2da..4e84b4cd26 100644 --- a/source/dnode/snode/src/snode.c +++ b/source/dnode/snode/src/snode.c @@ -92,11 +92,13 @@ int32_t sndExpandTask(SSnode *pSnode, SStreamTask *pTask, int64_t nextProcessVer } } - qInfo("snode:%d expand stream task, s-task:%s, checkpointId:%" PRId64 " checkpointVer:%" PRId64 " nextProcessVer:%" PRId64 - " child id:%d, level:%d, status:%s fill-history:%d, trigger:%" PRId64 " ms", + char* p = NULL; + streamTaskGetStatus(pTask, &p); + + qInfo("snode:%d expand stream task, s-task:%s, checkpointId:%" PRId64 " checkpointVer:%" PRId64 + " nextProcessVer:%" PRId64 " child id:%d, level:%d, status:%s fill-history:%d, trigger:%" PRId64 " ms", SNODE_HANDLE, pTask->id.idStr, pChkInfo->checkpointId, pChkInfo->checkpointVer, pChkInfo->nextProcessVer, - pTask->info.selfChildId, pTask->info.taskLevel, streamGetTaskStatusStr(pTask->status.taskStatus), - pTask->info.fillHistory, pTask->info.triggerParam); + pTask->info.selfChildId, pTask->info.taskLevel, p, pTask->info.fillHistory, pTask->info.triggerParam); return 0; } @@ -174,9 +176,15 @@ int32_t sndProcessTaskDeployReq(SSnode *pSnode, char *msg, int32_t msgLen) { int32_t numOfTasks = streamMetaGetNumOfTasks(pSnode->pMeta); taosWUnLockLatch(&pSnode->pMeta->lock); - qDebug("snode:%d s-task:%s is deployed on snode and add into meta, status:%s, numOfTasks:%d", SNODE_HANDLE, pTask->id.idStr, - streamGetTaskStatusStr(pTask->status.taskStatus), numOfTasks); + char* p = NULL; + streamTaskGetStatus(pTask, &p); + + qDebug("snode:%d s-task:%s is deployed on snode and add into meta, status:%s, numOfTasks:%d", SNODE_HANDLE, + pTask->id.idStr, p, numOfTasks); + + EStreamTaskEvent event = (HAS_RELATED_FILLHISTORY_TASK(pTask)) ? TASK_EVENT_INIT_STREAM_SCANHIST : TASK_EVENT_INIT; + streamTaskHandleEvent(pTask->status.pSM, event); streamTaskCheckDownstream(pTask); return 0; } @@ -352,10 +360,10 @@ int32_t sndProcessStreamTaskCheckReq(SSnode *pSnode, SRpcMsg *pMsg) { if (pTask != NULL) { rsp.status = streamTaskCheckStatus(pTask, req.upstreamTaskId, req.upstreamNodeId, req.stage); streamMetaReleaseTask(pSnode->pMeta, pTask); - - const char* pStatus = streamGetTaskStatusStr(pTask->status.taskStatus); + char* p = NULL; + streamTaskGetStatus(pTask, &p); qDebug("s-task:%s status:%s, recv task check req(reqId:0x%" PRIx64 ") task:0x%x (vgId:%d), ready:%d", - pTask->id.idStr, pStatus, rsp.reqId, rsp.upstreamTaskId, rsp.upstreamNodeId, rsp.status); + pTask->id.idStr, p, rsp.reqId, rsp.upstreamTaskId, rsp.upstreamNodeId, rsp.status); } else { rsp.status = TASK_DOWNSTREAM_NOT_READY; qDebug("recv task check(taskId:0x%x not built yet) req(reqId:0x%" PRIx64 ") from task:0x%x (vgId:%d), rsp status %d", diff --git a/source/dnode/vnode/src/inc/tq.h b/source/dnode/vnode/src/inc/tq.h index 6ab2bc75c7..76d89be802 100644 --- a/source/dnode/vnode/src/inc/tq.h +++ b/source/dnode/vnode/src/inc/tq.h @@ -126,7 +126,6 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxR int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp, int32_t numOfCols, int8_t precision); int32_t tqSendDataRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataRsp* pRsp, int32_t type, int32_t vgId); -//int32_t tqPushDataRsp(STqHandle* pHandle, int32_t vgId); int32_t tqPushEmptyDataRsp(STqHandle* pHandle, int32_t vgId); // tqMeta @@ -134,7 +133,6 @@ int32_t tqMetaOpen(STQ* pTq); int32_t tqMetaClose(STQ* pTq); int32_t tqMetaSaveHandle(STQ* pTq, const char* key, const STqHandle* pHandle); int32_t tqMetaDeleteHandle(STQ* pTq, const char* key); -//int32_t tqMetaRestoreHandle(STQ* pTq); int32_t tqMetaSaveCheckInfo(STQ* pTq, const char* key, const void* value, int32_t vLen); int32_t tqMetaDeleteCheckInfo(STQ* pTq, const char* key); int32_t tqMetaRestoreCheckInfo(STQ* pTq); @@ -160,8 +158,8 @@ int32_t tqOffsetRestoreFromFile(STqOffsetStore* pStore, const char* fname); // tqStream int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int64_t ver); int32_t tqScanWal(STQ* pTq); -int32_t tqCheckAndRunStreamTask(STQ* pTq); -int32_t tqStartStreamTasks(STQ* pTq); +int32_t tqStartStreamTask(STQ* pTq); +int32_t tqResetStreamTaskStatus(STQ* pTq); int32_t tqStopStreamTasks(STQ* pTq); // tq util @@ -171,6 +169,12 @@ int32_t tqDoSendDataRsp(const SRpcHandleInfo* pRpcHandleInfo, const SMqDataRsp* int32_t type, int64_t sver, int64_t ever); int32_t tqInitDataRsp(SMqDataRsp* pRsp, STqOffsetVal pOffset); void tqUpdateNodeStage(STQ* pTq, bool isLeader); +int32_t setDstTableDataPayload(uint64_t suid, const STSchema* pTSchema, int32_t blockIndex, SSDataBlock* pDataBlock, + SSubmitTbData* pTableData, const char* id); +int32_t doMergeExistedRows(SSubmitTbData* pExisted, const SSubmitTbData* pNew, const char* id); + +SVCreateTbReq* buildAutoCreateTableReq(const char* stbFullName, int64_t suid, int32_t numOfCols, + SSDataBlock* pDataBlock, SArray* pTagArray); #ifdef __cplusplus } diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index 12e273c32d..89d70bfabb 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -231,7 +231,7 @@ int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp) int32_t tqProcessTaskCheckpointReadyMsg(STQ* pTq, SRpcMsg* pMsg); int32_t tqProcessTaskUpdateReq(STQ* pTq, SRpcMsg* pMsg); int32_t tqProcessTaskResetReq(STQ* pTq, SRpcMsg* pMsg); -int32_t tqCheckAndRunStreamTaskAsync(STQ* pTq); +int32_t tqLaunchStreamTaskAsync(STQ* pTq); int tqCommit(STQ*); int32_t tqUpdateTbUidList(STQ* pTq, const SArray* tbUidList, bool isAdd); diff --git a/source/dnode/vnode/src/sma/smaOpen.c b/source/dnode/vnode/src/sma/smaOpen.c index 49f25c0b0a..633e096314 100644 --- a/source/dnode/vnode/src/sma/smaOpen.c +++ b/source/dnode/vnode/src/sma/smaOpen.c @@ -31,21 +31,21 @@ static int32_t rsmaRestore(SSma *pSma); } while (0) #define SMA_OPEN_RSMA_IMPL(v, l, force) \ - do { \ - SRetention *r = (SRetention *)VND_RETENTIONS(v) + l; \ - if (!RETENTION_VALID(r)) { \ - if (l == 0) { \ - code = TSDB_CODE_INVALID_PARA; \ - TSDB_CHECK_CODE(code, lino, _exit); \ - } \ - break; \ - } \ - code = smaSetKeepCfg(v, &keepCfg, pCfg, TSDB_TYPE_RSMA_L##l); \ - TSDB_CHECK_CODE(code, lino, _exit); \ + do { \ + SRetention *r = (SRetention *)VND_RETENTIONS(v) + l; \ + if (!RETENTION_VALID(l, r)) { \ + if (l == 0) { \ + code = TSDB_CODE_INVALID_PARA; \ + TSDB_CHECK_CODE(code, lino, _exit); \ + } \ + break; \ + } \ + code = smaSetKeepCfg(v, &keepCfg, pCfg, TSDB_TYPE_RSMA_L##l); \ + TSDB_CHECK_CODE(code, lino, _exit); \ if (tsdbOpen(v, &SMA_RSMA_TSDB##l(pSma), VNODE_RSMA##l##_DIR, &keepCfg, rollback, force) < 0) { \ - code = terrno; \ - TSDB_CHECK_CODE(code, lino, _exit); \ - } \ + code = terrno; \ + TSDB_CHECK_CODE(code, lino, _exit); \ + } \ } while (0) /** @@ -79,20 +79,18 @@ static int32_t smaEvalDays(SVnode *pVnode, SRetention *r, int8_t level, int8_t p freqDuration = convertTimeFromPrecisionToUnit((r + level)->freq, precision, TIME_UNIT_MINUTE); keepDuration = convertTimeFromPrecisionToUnit((r + level)->keep, precision, TIME_UNIT_MINUTE); - int32_t nFreqTimes = (r + level)->freq / (r + TSDB_RETENTION_L0)->freq; + int32_t nFreqTimes = (r + level)->freq / (60 * 1000); // use 60s for freq of 1st level days *= (nFreqTimes > 1 ? nFreqTimes : 1); - if (days > keepDuration) { - days = keepDuration; - } - - if (days > TSDB_MAX_DURATION_PER_FILE) { - days = TSDB_MAX_DURATION_PER_FILE; - } - if (days < freqDuration) { days = freqDuration; } + + int32_t maxKeepDuration = TMIN(keepDuration, TSDB_MAX_DURATION_PER_FILE); + if (days > maxKeepDuration) { + days = maxKeepDuration; + } + _exit: smaInfo("vgId:%d, evaluated duration for level %d is %d, raw val:%d", TD_VID(pVnode), level + 1, days, duration); return days; @@ -157,6 +155,7 @@ int32_t smaOpen(SVnode *pVnode, int8_t rollback, bool force) { _exit: if (code) { smaError("vgId:%d, %s failed at line %d since %s", TD_VID(pVnode), __func__, lino, tstrerror(code)); + terrno = code; } return code; } diff --git a/source/dnode/vnode/src/sma/smaTimeRange.c b/source/dnode/vnode/src/sma/smaTimeRange.c index 0c37008344..08ddc4bd7b 100644 --- a/source/dnode/vnode/src/sma/smaTimeRange.c +++ b/source/dnode/vnode/src/sma/smaTimeRange.c @@ -35,8 +35,8 @@ int32_t tdProcessTSmaInsert(SSma *pSma, int64_t indexUid, const char *msg) { return code; } -int32_t tdProcessTSmaCreate(SSma *pSma, int64_t version, const char *msg) { - int32_t code = tdProcessTSmaCreateImpl(pSma, version, msg); +int32_t tdProcessTSmaCreate(SSma *pSma, int64_t ver, const char *msg) { + int32_t code = tdProcessTSmaCreateImpl(pSma, ver, msg); return code; } @@ -109,7 +109,7 @@ _exit: * @param pMsg * @return int32_t */ -static int32_t tdProcessTSmaCreateImpl(SSma *pSma, int64_t version, const char *pMsg) { +static int32_t tdProcessTSmaCreateImpl(SSma *pSma, int64_t ver, const char *pMsg) { int32_t code = 0; int32_t lino = 0; SSmaCfg *pCfg = (SSmaCfg *)pMsg; @@ -118,7 +118,7 @@ static int32_t tdProcessTSmaCreateImpl(SSma *pSma, int64_t version, const char * if (TD_VID(pSma->pVnode) == pCfg->dstVgId) { // create tsma meta in dstVgId - if (metaCreateTSma(SMA_META(pSma), version, pCfg) < 0) { + if (metaCreateTSma(SMA_META(pSma), ver, pCfg) < 0) { code = terrno; TSDB_CHECK_CODE(code, lino, _exit); } @@ -130,7 +130,7 @@ static int32_t tdProcessTSmaCreateImpl(SSma *pSma, int64_t version, const char * pReq.schemaRow = pCfg->schemaRow; pReq.schemaTag = pCfg->schemaTag; - if (metaCreateSTable(SMA_META(pSma), version, &pReq) < 0) { + if (metaCreateSTable(SMA_META(pSma), ver, &pReq) < 0) { code = terrno; TSDB_CHECK_CODE(code, lino, _exit); } @@ -154,94 +154,36 @@ _exit: return code; } -int32_t smaBlockToSubmit(SVnode *pVnode, const SArray *pBlocks, const STSchema *pTSchema, - SSchemaWrapper *pTagSchemaWrapper, bool createTb, int64_t suid, const char *stbFullName, - SBatchDeleteReq *pDeleteReq, void **ppData, int32_t *pLen) { +int32_t smaBlockToSubmit(SVnode *pVnode, const SArray *pBlocks, const STSchema *pTSchema, int64_t suid, + const char *stbFullName, SBatchDeleteReq *pDeleteReq, void **ppData, int32_t *pLen) { int32_t code = 0; int32_t lino = 0; void *pBuf = NULL; int32_t len = 0; SSubmitReq2 *pReq = NULL; SArray *tagArray = NULL; - SArray *createTbArray = NULL; - SArray *pVals = NULL; - int32_t sz = taosArrayGetSize(pBlocks); + int32_t numOfBlocks = taosArrayGetSize(pBlocks); tagArray = taosArrayInit(1, sizeof(STagVal)); - createTbArray = taosArrayInit(sz, POINTER_BYTES); pReq = taosMemoryCalloc(1, sizeof(SSubmitReq2)); - pReq->aSubmitTbData = taosArrayInit(1, sizeof(SSubmitTbData)); - if(!tagArray || !createTbArray || !pReq || !pReq->aSubmitTbData) { + if (!tagArray || !pReq) { code = terrno == TSDB_CODE_SUCCESS ? TSDB_CODE_OUT_OF_MEMORY : terrno; TSDB_CHECK_CODE(code, lino, _exit); } - // create table req - if (createTb) { - for (int32_t i = 0; i < sz; ++i) { - SSDataBlock *pDataBlock = taosArrayGet(pBlocks, i); - SVCreateTbReq *pCreateTbReq = NULL; - if (pDataBlock->info.type == STREAM_DELETE_RESULT) { - taosArrayPush(createTbArray, &pCreateTbReq); - continue; - } - - if (!(pCreateTbReq = taosMemoryCalloc(1, sizeof(SVCreateStbReq)))) { - code = TSDB_CODE_OUT_OF_MEMORY; - TSDB_CHECK_CODE(code, lino, _exit); - }; - - // don't move to the end of loop as to destroy in the end of func when error occur - taosArrayPush(createTbArray, &pCreateTbReq); - - // set const - pCreateTbReq->flags = 0; - pCreateTbReq->type = TSDB_CHILD_TABLE; - pCreateTbReq->ctb.suid = suid; - - // set super table name - SName name = {0}; - tNameFromString(&name, stbFullName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); - pCreateTbReq->ctb.stbName = taosStrdup((char *)tNameGetTableName(&name)); // taosStrdup(stbFullName); - - // set tag content - taosArrayClear(tagArray); - STagVal tagVal = { - .cid = taosArrayGetSize(pDataBlock->pDataBlock) + 1, - .type = TSDB_DATA_TYPE_UBIGINT, - .i64 = (int64_t)pDataBlock->info.id.groupId, - }; - taosArrayPush(tagArray, &tagVal); - pCreateTbReq->ctb.tagNum = taosArrayGetSize(tagArray); - - STag *pTag = NULL; - tTagNew(tagArray, 1, false, &pTag); - if (pTag == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - TSDB_CHECK_CODE(code, lino, _exit); - } - pCreateTbReq->ctb.pTag = (uint8_t *)pTag; - - // set tag name - SArray *tagName = taosArrayInit(1, TSDB_COL_NAME_LEN); - char tagNameStr[TSDB_COL_NAME_LEN] = {0}; - strcpy(tagNameStr, "group_id"); - taosArrayPush(tagName, tagNameStr); - pCreateTbReq->ctb.tagName = tagName; - - // set table name - if (pDataBlock->info.parTbName[0]) { - pCreateTbReq->name = taosStrdup(pDataBlock->info.parTbName); - } else { - pCreateTbReq->name = buildCtbNameByGroupId(stbFullName, pDataBlock->info.id.groupId); - } - } + pReq->aSubmitTbData = taosArrayInit(1, sizeof(SSubmitTbData)); + if (pReq->aSubmitTbData == NULL) { + code = terrno == TSDB_CODE_SUCCESS ? TSDB_CODE_OUT_OF_MEMORY : terrno; + TSDB_CHECK_CODE(code, lino, _exit); } + SHashObj *pTableIndexMap = + taosHashInit(numOfBlocks, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK); + // SSubmitTbData req - for (int32_t i = 0; i < sz; ++i) { + for (int32_t i = 0; i < numOfBlocks; ++i) { SSDataBlock *pDataBlock = taosArrayGet(pBlocks, i); if (pDataBlock->info.type == STREAM_DELETE_RESULT) { pDeleteReq->suid = suid; @@ -250,62 +192,42 @@ int32_t smaBlockToSubmit(SVnode *pVnode, const SArray *pBlocks, const STSchema * continue; } - int32_t rows = pDataBlock->info.rows; + SSubmitTbData tbData = {.suid = suid, .uid = 0, .sver = pTSchema->version, .flags = SUBMIT_REQ_AUTO_CREATE_TABLE,}; - SSubmitTbData tbData = {0}; + int32_t cid = taosArrayGetSize(pDataBlock->pDataBlock) + 1; + tbData.pCreateTbReq = buildAutoCreateTableReq(stbFullName, suid, cid, pDataBlock, tagArray); - if (!(tbData.aRowP = taosArrayInit(rows, sizeof(SRow *)))) { - code = terrno; - TSDB_CHECK_CODE(code, lino, _exit); - } - tbData.suid = suid; - tbData.uid = 0; // uid is assigned by vnode - tbData.sver = pTSchema->version; + { + uint64_t groupId = pDataBlock->info.id.groupId; - if (createTb) { - tbData.pCreateTbReq = taosArrayGetP(createTbArray, i); - if (tbData.pCreateTbReq) tbData.flags = SUBMIT_REQ_AUTO_CREATE_TABLE; - } + int32_t *index = taosHashGet(pTableIndexMap, &groupId, sizeof(groupId)); + if (index == NULL) { // no data yet, append it + code = setDstTableDataPayload(suid, pTSchema, i, pDataBlock, &tbData, ""); + if (code != TSDB_CODE_SUCCESS) { + continue; + } - if (!pVals && !(pVals = taosArrayInit(pTSchema->numOfCols, sizeof(SColVal)))) { - taosArrayDestroy(tbData.aRowP); - code = terrno; - TSDB_CHECK_CODE(code, lino, _exit); - } + taosArrayPush(pReq->aSubmitTbData, &tbData); - for (int32_t j = 0; j < rows; ++j) { - taosArrayClear(pVals); - for (int32_t k = 0; k < pTSchema->numOfCols; k++) { - const STColumn *pCol = &pTSchema->columns[k]; - SColumnInfoData *pColData = taosArrayGet(pDataBlock->pDataBlock, k); - if (colDataIsNull_s(pColData, j)) { - SColVal cv = COL_VAL_NULL(pCol->colId, pCol->type); - taosArrayPush(pVals, &cv); - } else { - void *data = colDataGetData(pColData, j); - if (IS_STR_DATA_TYPE(pCol->type)) { - SValue sv = (SValue){.nData = varDataLen(data), .pData = varDataVal(data)}; // address copy, no value - SColVal cv = COL_VAL_VALUE(pCol->colId, pCol->type, sv); - taosArrayPush(pVals, &cv); - } else { - SValue sv; - memcpy(&sv.val, data, tDataTypes[pCol->type].bytes); - SColVal cv = COL_VAL_VALUE(pCol->colId, pCol->type, sv); - taosArrayPush(pVals, &cv); - } + int32_t size = (int32_t)taosArrayGetSize(pReq->aSubmitTbData) - 1; + taosHashPut(pTableIndexMap, &groupId, sizeof(groupId), &size, sizeof(size)); + } else { + code = setDstTableDataPayload(suid, pTSchema, i, pDataBlock, &tbData, ""); + if (code != TSDB_CODE_SUCCESS) { + continue; + } + + SSubmitTbData *pExisted = taosArrayGet(pReq->aSubmitTbData, *index); + code = doMergeExistedRows(pExisted, &tbData, "id"); + if (code != TSDB_CODE_SUCCESS) { + continue; } } - SRow *pRow = NULL; - if ((code = tRowBuild(pVals, (STSchema *)pTSchema, &pRow)) < 0) { - tDestroySubmitTbData(&tbData, TSDB_MSG_FLG_ENCODE); - TSDB_CHECK_CODE(code, lino, _exit); - } - taosArrayPush(tbData.aRowP, &pRow); } - - taosArrayPush(pReq->aSubmitTbData, &tbData); } + taosHashCleanup(pTableIndexMap); + // encode tEncodeSize(tEncodeSubmitReq, pReq, len, code); if (TSDB_CODE_SUCCESS == code) { @@ -327,11 +249,10 @@ int32_t smaBlockToSubmit(SVnode *pVnode, const SArray *pBlocks, const STSchema * } tEncoderClear(&encoder); } + _exit: - taosArrayDestroy(createTbArray); taosArrayDestroy(tagArray); - taosArrayDestroy(pVals); - if (pReq) { + if (pReq != NULL) { tDestroySubmitReq(pReq, TSDB_MSG_FLG_ENCODE); taosMemoryFree(pReq); } @@ -442,8 +363,8 @@ static int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char void *pSubmitReq = NULL; int32_t contLen = 0; - code = smaBlockToSubmit(pSma->pVnode, (const SArray *)msg, pTsmaStat->pTSchema, &pTsmaStat->pTSma->schemaTag, true, - pTsmaStat->pTSma->dstTbUid, pTsmaStat->pTSma->dstTbName, &deleteReq, &pSubmitReq, &contLen); + code = smaBlockToSubmit(pSma->pVnode, (const SArray *)msg, pTsmaStat->pTSchema, pTsmaStat->pTSma->dstTbUid, + pTsmaStat->pTSma->dstTbName, &deleteReq, &pSubmitReq, &contLen); TSDB_CHECK_CODE(code, lino, _exit); if ((terrno = tsmaProcessDelReq(pSma, indexUid, &deleteReq)) != 0) { diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index a5832d3c66..e1b27049af 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -20,6 +20,12 @@ typedef struct { int8_t inited; } STqMgmt; +typedef struct STaskUpdateEntry { + int64_t streamId; + int32_t taskId; + int32_t transId; +} STaskUpdateEntry; + static STqMgmt tqMgmt = {0}; // 0: not init @@ -820,28 +826,29 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int64_t nextProcessVer) { } // sink - if (pTask->outputInfo.type == TASK_OUTPUT__SMA) { - pTask->outputInfo.smaSink.vnode = pTq->pVnode; - pTask->outputInfo.smaSink.smaSink = smaHandleRes; - } else if (pTask->outputInfo.type == TASK_OUTPUT__TABLE) { - pTask->outputInfo.tbSink.vnode = pTq->pVnode; - pTask->outputInfo.tbSink.tbSinkFunc = tqSinkDataIntoDstTable; + STaskOutputInfo* pOutputInfo = &pTask->outputInfo; + if (pOutputInfo->type == TASK_OUTPUT__SMA) { + pOutputInfo->smaSink.vnode = pTq->pVnode; + pOutputInfo->smaSink.smaSink = smaHandleRes; + } else if (pOutputInfo->type == TASK_OUTPUT__TABLE) { + pOutputInfo->tbSink.vnode = pTq->pVnode; + pOutputInfo->tbSink.tbSinkFunc = tqSinkDataIntoDstTable; int32_t ver1 = 1; SMetaInfo info = {0}; - code = metaGetInfo(pTq->pVnode->pMeta, pTask->outputInfo.tbSink.stbUid, &info, NULL); + code = metaGetInfo(pTq->pVnode->pMeta, pOutputInfo->tbSink.stbUid, &info, NULL); if (code == TSDB_CODE_SUCCESS) { ver1 = info.skmVer; } - SSchemaWrapper* pschemaWrapper = pTask->outputInfo.tbSink.pSchemaWrapper; - pTask->outputInfo.tbSink.pTSchema = tBuildTSchema(pschemaWrapper->pSchema, pschemaWrapper->nCols, ver1); - if (pTask->outputInfo.tbSink.pTSchema == NULL) { + SSchemaWrapper* pschemaWrapper = pOutputInfo->tbSink.pSchemaWrapper; + pOutputInfo->tbSink.pTSchema = tBuildTSchema(pschemaWrapper->pSchema, pschemaWrapper->nCols, ver1); + if (pOutputInfo->tbSink.pTSchema == NULL) { return -1; } - pTask->outputInfo.tbSink.pTblInfo = tSimpleHashInit(10240, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT)); - tSimpleHashSetFreeFp(pTask->outputInfo.tbSink.pTblInfo, freePtr); + pOutputInfo->tbSink.pTblInfo = tSimpleHashInit(10240, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT)); + tSimpleHashSetFreeFp(pOutputInfo->tbSink.pTblInfo, freePtr); } if (pTask->info.taskLevel == TASK_LEVEL__SOURCE) { @@ -849,11 +856,11 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int64_t nextProcessVer) { pTask->exec.pWalReader = walOpenReader(pTq->pVnode->pWal, &cond, pTask->id.taskId); } - // reset the task status from unfinished transaction - if (pTask->status.taskStatus == TASK_STATUS__PAUSE) { - tqWarn("s-task:%s reset task status to be normal, status kept in taskMeta: Paused", pTask->id.idStr); - pTask->status.taskStatus = TASK_STATUS__NORMAL; - } +// // reset the task status from unfinished transaction +// if (pTask->status.taskStatus == TASK_STATUS__PAUSE) { +// tqWarn("s-task:%s reset task status to be normal, status kept in taskMeta: Paused", pTask->id.idStr); +// pTask->status.taskStatus = TASK_STATUS__READY; +// } streamTaskResetUpstreamStageInfo(pTask); streamSetupScheduleTrigger(pTask); @@ -866,20 +873,23 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int64_t nextProcessVer) { pChkInfo->checkpointId, pChkInfo->checkpointVer, pChkInfo->nextProcessVer); } + char* p = NULL; + streamTaskGetStatus(pTask, &p); + if (pTask->info.fillHistory) { tqInfo("vgId:%d expand stream task, s-task:%s, checkpointId:%" PRId64 " checkpointVer:%" PRId64 " nextProcessVer:%" PRId64 " child id:%d, level:%d, status:%s fill-history:%d, related stream task:0x%x trigger:%" PRId64 " ms", vgId, pTask->id.idStr, pChkInfo->checkpointId, pChkInfo->checkpointVer, pChkInfo->nextProcessVer, - pTask->info.selfChildId, pTask->info.taskLevel, streamGetTaskStatusStr(pTask->status.taskStatus), - pTask->info.fillHistory, (int32_t)pTask->streamTaskId.taskId, pTask->info.triggerParam); + pTask->info.selfChildId, pTask->info.taskLevel, p, pTask->info.fillHistory, + (int32_t)pTask->streamTaskId.taskId, pTask->info.triggerParam); } else { tqInfo("vgId:%d expand stream task, s-task:%s, checkpointId:%" PRId64 " checkpointVer:%" PRId64 " nextProcessVer:%" PRId64 " child id:%d, level:%d, status:%s fill-history:%d, related fill-task:0x%x trigger:%" PRId64 " ms", vgId, pTask->id.idStr, pChkInfo->checkpointId, pChkInfo->checkpointVer, pChkInfo->nextProcessVer, - pTask->info.selfChildId, pTask->info.taskLevel, streamGetTaskStatusStr(pTask->status.taskStatus), - pTask->info.fillHistory, (int32_t)pTask->hTaskInfo.id.taskId, pTask->info.triggerParam); + pTask->info.selfChildId, pTask->info.taskLevel, p, pTask->info.fillHistory, + (int32_t)pTask->hTaskInfo.id.taskId, pTask->info.triggerParam); } return 0; @@ -921,9 +931,10 @@ int32_t tqProcessTaskCheckReq(STQ* pTq, SRpcMsg* pMsg) { rsp.status = streamTaskCheckStatus(pTask, req.upstreamTaskId, req.upstreamNodeId, req.stage); streamMetaReleaseTask(pMeta, pTask); - const char* pStatus = streamGetTaskStatusStr(pTask->status.taskStatus); + char* p = NULL; + streamTaskGetStatus(pTask, &p); tqDebug("s-task:%s status:%s, stage:%d recv task check req(reqId:0x%" PRIx64 ") task:0x%x (vgId:%d), check_status:%d", - pTask->id.idStr, pStatus, rsp.oldStage, rsp.reqId, rsp.upstreamTaskId, rsp.upstreamNodeId, rsp.status); + pTask->id.idStr, p, rsp.oldStage, rsp.reqId, rsp.upstreamTaskId, rsp.upstreamNodeId, rsp.status); } else { rsp.status = TASK_DOWNSTREAM_NOT_READY; tqDebug("tq recv task check(taskId:0x%" PRIx64 "-0x%x not built yet) req(reqId:0x%" PRIx64 @@ -957,6 +968,12 @@ int32_t tqProcessTaskCheckRsp(STQ* pTq, SRpcMsg* pMsg) { tqDebug("tq task:0x%x (vgId:%d) recv check rsp(reqId:0x%" PRIx64 ") from 0x%x (vgId:%d) status %d", rsp.upstreamTaskId, rsp.upstreamNodeId, rsp.reqId, rsp.downstreamTaskId, rsp.downstreamNodeId, rsp.status); + if (!vnodeIsRoleLeader(pTq->pVnode)) { + tqError("vgId:%d not leader, task:0x%x not handle the check rsp, downstream:0x%x (vgId:%d)", vgId, + rsp.upstreamTaskId, rsp.downstreamTaskId, rsp.downstreamNodeId); + return code; + } + SStreamTask* pTask = streamMetaAcquireTask(pTq->pStreamMeta, rsp.streamId, rsp.upstreamTaskId); if (pTask == NULL) { tqError("tq failed to locate the stream task:0x%" PRIx64 "-0x%x (vgId:%d), it may have been destroyed or stopped", @@ -1026,11 +1043,9 @@ int32_t tqProcessTaskDeployReq(STQ* pTq, int64_t sversion, char* msg, int32_t ms SStreamTask* p = streamMetaAcquireTask(pStreamMeta, streamId, taskId); bool restored = pTq->pVnode->restored; - if (p != NULL && restored) { - p->execInfo.init = taosGetTimestampMs(); - tqDebug("s-task:%s set the init ts:%"PRId64, p->id.idStr, p->execInfo.init); - - streamTaskCheckDownstream(p); + if (p != NULL && restored && p->info.fillHistory == 0) { + EStreamTaskEvent event = (HAS_RELATED_FILLHISTORY_TASK(p)) ? TASK_EVENT_INIT_STREAM_SCANHIST : TASK_EVENT_INIT; + streamTaskHandleEvent(p->status.pSM, event); } else if (!restored) { tqWarn("s-task:%s not launched since vnode(vgId:%d) not ready", p->id.idStr, vgId); } @@ -1064,7 +1079,8 @@ int32_t tqProcessTaskScanHistory(STQ* pTq, SRpcMsg* pMsg) { // do recovery step1 const char* id = pTask->id.idStr; - const char* pStatus = streamGetTaskStatusStr(pTask->status.taskStatus); + char* pStatus = NULL; + streamTaskGetStatus(pTask, &pStatus); // avoid multi-thread exec while(1) { @@ -1117,8 +1133,8 @@ int32_t tqProcessTaskScanHistory(STQ* pTq, SRpcMsg* pMsg) { streamScanHistoryData(pTask); double el = (taosGetTimestampMs() - pTask->execInfo.step1Start) / 1000.0; - if (pTask->status.taskStatus == TASK_STATUS__PAUSE) { - int8_t status = streamTaskSetSchedStatusInActive(pTask); + if (streamTaskGetStatus(pTask, NULL) == TASK_STATUS__PAUSE) { + int8_t status = streamTaskSetSchedStatusInactive(pTask); tqDebug("s-task:%s is paused in the step1, elapsed time:%.2fs, sched-status:%d", pTask->id.idStr, el, status); atomic_store_32(&pTask->status.inScanHistorySentinel, 0); @@ -1127,12 +1143,11 @@ int32_t tqProcessTaskScanHistory(STQ* pTq, SRpcMsg* pMsg) { } // the following procedure should be executed, no matter status is stop/pause or not - tqDebug("s-task:%s scan-history stage(step 1) ended, elapsed time:%.2fs", id, el); + tqDebug("s-task:%s scan-history(step 1) ended, elapsed time:%.2fs", id, el); if (pTask->info.fillHistory) { SVersionRange* pRange = NULL; SStreamTask* pStreamTask = NULL; - bool done = false; // 1. get the related stream task pStreamTask = streamMetaAcquireTask(pMeta, pTask->streamTaskId.streamId, pTask->streamTaskId.taskId); @@ -1151,10 +1166,10 @@ int32_t tqProcessTaskScanHistory(STQ* pTq, SRpcMsg* pMsg) { } ASSERT(pStreamTask->info.taskLevel == TASK_LEVEL__SOURCE); - +#if 0 // 2. it cannot be paused, when the stream task in TASK_STATUS__SCAN_HISTORY status. Let's wait for the // stream task get ready for scan history data - while (pStreamTask->status.taskStatus == TASK_STATUS__SCAN_HISTORY) { + while (streamTaskGetStatus(pStreamTask, NULL) == TASK_STATUS__SCAN_HISTORY) { tqDebug( "s-task:%s level:%d related stream task:%s(status:%s) not ready for halt, wait for it and recheck in 100ms", id, pTask->info.taskLevel, pStreamTask->id.idStr, streamGetTaskStatusStr(pStreamTask->status.taskStatus)); @@ -1199,6 +1214,7 @@ int32_t tqProcessTaskScanHistory(STQ* pTq, SRpcMsg* pMsg) { pStreamTask->status.keepTaskStatus = status; pStreamTask->status.taskStatus = TASK_STATUS__HALT; + // wal scan not start yet, reset it to be the start position nextProcessedVer = walReaderGetCurrentVer(pStreamTask->exec.pWalReader); if (nextProcessedVer == -1) { nextProcessedVer = pStreamTask->dataRange.range.maxVer + 1; @@ -1211,21 +1227,26 @@ int32_t tqProcessTaskScanHistory(STQ* pTq, SRpcMsg* pMsg) { taosThreadMutexUnlock(&pStreamTask->lock); break; } +#endif + + streamTaskHandleEvent(pStreamTask->status.pSM, TASK_EVENT_HALT); + int64_t nextProcessedVer = pStreamTask->hTaskInfo.haltVer; // if it's an source task, extract the last version in wal. pRange = &pTask->dataRange.range; - done = streamHistoryTaskSetVerRangeStep2(pTask, nextProcessedVer); + bool done = streamHistoryTaskSetVerRangeStep2(pTask, nextProcessedVer); pTask->execInfo.step2Start = taosGetTimestampMs(); if (done) { qDebug("s-task:%s scan-history from WAL stage(step 2) ended, elapsed time:%.2fs", id, 0.0); streamTaskPutTranstateIntoInputQ(pTask); +// streamTaskRestoreStatus(pTask); - if (pTask->status.taskStatus == TASK_STATUS__PAUSE) { - pTask->status.keepTaskStatus = TASK_STATUS__NORMAL; - qDebug("s-task:%s prev status is %s, update the kept status to be:%s when after step 2", id, - streamGetTaskStatusStr(TASK_STATUS__PAUSE), streamGetTaskStatusStr(pTask->status.keepTaskStatus)); - } +// if (pTask->status.taskStatus == TASK_STATUS__PAUSE) { +// pTask->status.keepTaskStatus = TASK_STATUS__READY; +// qDebug("s-task:%s prev status is %s, update the kept status to be:%s when after step 2", id, +// streamGetTaskStatusStr(TASK_STATUS__PAUSE), streamGetTaskStatusStr(pTask->status.keepTaskStatus)); +// } streamExecTask(pTask); // exec directly } else { @@ -1245,35 +1266,24 @@ int32_t tqProcessTaskScanHistory(STQ* pTq, SRpcMsg* pMsg) { tqDebug("s-task:%s wal reader start scan WAL verRange:%" PRId64 "-%" PRId64 ", set sched-status:%d", id, dstVer, pTask->dataRange.range.maxVer, TASK_SCHED_STATUS__INACTIVE); - /*int8_t status = */streamTaskSetSchedStatusInActive(pTask); - - // the fill-history task starts to process data in wal, let's set it status to be normal now - if (pTask->info.fillHistory == 1 && !streamTaskShouldStop(&pTask->status)) { - streamSetStatusNormal(pTask); - } + /*int8_t status = */streamTaskSetSchedStatusInactive(pTask); + // now the fill-history task starts to scan data from wal files. + streamTaskHandleEvent(pTask->status.pSM, TASK_EVENT_SCANHIST_DONE); tqScanWalAsync(pTq, false); } streamMetaReleaseTask(pMeta, pStreamTask); } else { STimeWindow* pWindow = &pTask->dataRange.window; + ASSERT(HAS_RELATED_FILLHISTORY_TASK(pTask)); - if (pTask->hTaskInfo.id.taskId == 0) { - *pWindow = (STimeWindow){INT64_MIN, INT64_MAX}; - tqDebug( - "s-task:%s scan-history in stream time window completed, no related fill-history task, reset the time " - "window:%" PRId64 " - %" PRId64, - id, pWindow->skey, pWindow->ekey); - qStreamInfoResetTimewindowFilter(pTask->exec.pExecutor); - } else { - // when related fill-history task exists, update the fill-history time window only when the - // state transfer is completed. - tqDebug( - "s-task:%s scan-history in stream time window completed, now start to handle data from WAL, start " - "ver:%" PRId64 ", window:%" PRId64 " - %" PRId64, - id, pTask->chkInfo.nextProcessVer, pWindow->skey, pWindow->ekey); - } + // Not update the fill-history time window until the state transfer is completed if the related fill-history task + // exists. + tqDebug( + "s-task:%s scan-history in stream time window completed, now start to handle data from WAL, startVer:%" PRId64 + ", window:%" PRId64 " - %" PRId64, + id, pTask->chkInfo.nextProcessVer, pWindow->skey, pWindow->ekey); code = streamTaskScanHistoryDataComplete(pTask); } @@ -1352,7 +1362,7 @@ int32_t tqProcessTaskRunReq(STQ* pTq, SRpcMsg* pMsg) { int32_t vgId = TD_VID(pTq->pVnode); if (taskId == STREAM_EXEC_TASK_STATUS_CHECK_ID) { - tqCheckAndRunStreamTask(pTq); + tqStartStreamTask(pTq); return 0; } @@ -1362,17 +1372,16 @@ int32_t tqProcessTaskRunReq(STQ* pTq, SRpcMsg* pMsg) { } SStreamTask* pTask = streamMetaAcquireTask(pTq->pStreamMeta, pReq->streamId, taskId); - if (pTask != NULL) { - // even in halt status, the data in inputQ must be processed - int8_t st = pTask->status.taskStatus; - if (st == TASK_STATUS__NORMAL || st == TASK_STATUS__SCAN_HISTORY || st == TASK_STATUS__CK) { + if (pTask != NULL) { // even in halt status, the data in inputQ must be processed + char* p = NULL; + if (streamTaskReadyToRun(pTask, &p)) { tqDebug("vgId:%d s-task:%s start to process block from inputQ, next checked ver:%" PRId64, vgId, pTask->id.idStr, pTask->chkInfo.nextProcessVer); streamExecTask(pTask); } else { - int8_t status = streamTaskSetSchedStatusInActive(pTask); + int8_t status = streamTaskSetSchedStatusInactive(pTask); tqDebug("vgId:%d s-task:%s ignore run req since not in ready state, status:%s, sched-status:%d", vgId, - pTask->id.idStr, streamGetTaskStatusStr(st), status); + pTask->id.idStr, p, status); } streamMetaReleaseTask(pTq->pStreamMeta, pTask); @@ -1446,7 +1455,7 @@ int32_t tqProcessTaskDropReq(STQ* pTq, char* msg, int32_t msgLen) { SStreamTask* pTask = streamMetaAcquireTask(pMeta, pReq->streamId, pReq->taskId); if (pTask != NULL) { // drop the related fill-history task firstly - if (pTask->hTaskInfo.id.taskId != 0) { + if (HAS_RELATED_FILLHISTORY_TASK(pTask)) { STaskId* pHTaskId = &pTask->hTaskInfo.id; streamMetaUnregisterTask(pMeta, pHTaskId->streamId, pHTaskId->taskId); tqDebug("vgId:%d drop fill-history task:0x%x dropped firstly", vgId, (int32_t)pHTaskId->taskId); @@ -1486,7 +1495,7 @@ int32_t tqProcessTaskPauseReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg streamTaskPause(pTask, pMeta); SStreamTask* pHistoryTask = NULL; - if (pTask->hTaskInfo.id.taskId != 0) { + if (HAS_RELATED_FILLHISTORY_TASK(pTask)) { pHistoryTask = streamMetaAcquireTask(pMeta, pTask->hTaskInfo.id.streamId, pTask->hTaskInfo.id.taskId); if (pHistoryTask == NULL) { tqError("vgId:%d process pause req, failed to acquire fill-history task:0x%" PRIx64 @@ -1514,17 +1523,19 @@ int32_t tqProcessTaskResumeImpl(STQ* pTq, SStreamTask* pTask, int64_t sversion, return -1; } - // todo: handle the case: resume from halt to pause/ from halt to normal/ from pause to normal - streamTaskResume(pTask, pTq->pStreamMeta); + streamTaskResume(pTask); + ETaskStatus status = streamTaskGetStatus(pTask, NULL); int32_t level = pTask->info.taskLevel; if (level == TASK_LEVEL__SINK) { + if (status == TASK_STATUS__UNINIT) { + + } streamMetaReleaseTask(pTq->pStreamMeta, pTask); return 0; } - int8_t status = pTask->status.taskStatus; - if (status == TASK_STATUS__NORMAL || status == TASK_STATUS__SCAN_HISTORY || status == TASK_STATUS__CK) { + if (status == TASK_STATUS__READY || status == TASK_STATUS__SCAN_HISTORY || status == TASK_STATUS__CK) { // no lock needs to secure the access of the version if (igUntreated && level == TASK_LEVEL__SOURCE && !pTask->info.fillHistory) { // discard all the data when the stream task is suspended. @@ -1537,14 +1548,18 @@ int32_t tqProcessTaskResumeImpl(STQ* pTq, SStreamTask* pTask, int64_t sversion, vgId, pTask->id.idStr, pTask->chkInfo.nextProcessVer, sversion, pTask->status.schedStatus); } - if (level == TASK_LEVEL__SOURCE && pTask->info.fillHistory && - pTask->status.taskStatus == TASK_STATUS__SCAN_HISTORY) { + if (level == TASK_LEVEL__SOURCE && pTask->info.fillHistory && status == TASK_STATUS__SCAN_HISTORY) { streamStartScanHistoryAsync(pTask, igUntreated); - } else if (level == TASK_LEVEL__SOURCE && (streamQueueGetNumOfItems(pTask->inputInfo.queue) == 0)) { + } else if (level == TASK_LEVEL__SOURCE && (streamQueueGetNumOfItems(pTask->inputq.queue) == 0)) { tqScanWalAsync(pTq, false); } else { streamSchedExec(pTask); } + } else if (status == TASK_STATUS__UNINIT) { + if (pTask->info.fillHistory == 0) { + EStreamTaskEvent event = HAS_RELATED_FILLHISTORY_TASK(pTask) ? TASK_EVENT_INIT_STREAM_SCANHIST : TASK_EVENT_INIT; + streamTaskHandleEvent(pTask->status.pSM, event); + } } streamMetaReleaseTask(pTq->pStreamMeta, pTask); @@ -1683,7 +1698,6 @@ FAIL: return -1; } -// todo error code cannot be return, since this is invoked by an mnode-launched transaction. int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp) { int32_t vgId = TD_VID(pTq->pVnode); SStreamMeta* pMeta = pTq->pStreamMeta; @@ -1694,7 +1708,6 @@ int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp) // disable auto rsp to mnode pRsp->info.handle = NULL; - // todo: add counter to make sure other tasks would not be trapped in checkpoint state SStreamCheckpointSourceReq req = {0}; if (!vnodeIsRoleLeader(pTq->pVnode)) { tqDebug("vgId:%d not leader, ignore checkpoint-source msg", vgId); @@ -1725,6 +1738,7 @@ int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp) } tDecoderClear(&decoder); + // todo handle failure to reset from checkpoint procedure SStreamTask* pTask = streamMetaAcquireTask(pMeta, req.streamId, req.taskId); if (pTask == NULL) { tqError("vgId:%d failed to find s-task:0x%x, ignore checkpoint msg. it may have been destroyed already", vgId, @@ -1735,6 +1749,7 @@ int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp) return TSDB_CODE_SUCCESS; } + // todo handle failure to reset from checkpoint procedure // downstream not ready, current the stream tasks are not all ready. Ignore this checkpoint req. if (pTask->status.downstreamReady != 1) { pTask->chkInfo.failedId = req.checkpointId; // record the latest failed checkpoint id @@ -1750,8 +1765,11 @@ int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp) return TSDB_CODE_SUCCESS; } + // todo save the checkpoint failed info taosThreadMutexLock(&pTask->lock); - if (pTask->status.taskStatus == TASK_STATUS__HALT) { + ETaskStatus status = streamTaskGetStatus(pTask, NULL); + + if (status == TASK_STATUS__HALT || status == TASK_STATUS__PAUSE) { qError("s-task:%s not ready for checkpoint, since it is halt, ignore this checkpoint:%" PRId64 ", set it failure", pTask->id.idStr, req.checkpointId); taosThreadMutexUnlock(&pTask->lock); @@ -1832,7 +1850,6 @@ int32_t tqProcessTaskUpdateReq(STQ* pTq, SRpcMsg* pMsg) { char* msg = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)); int32_t len = pMsg->contLen - sizeof(SMsgHead); SRpcMsg rsp = {.info = pMsg->info, .code = TSDB_CODE_SUCCESS}; - bool allStopped = false; SStreamTaskNodeUpdateMsg req = {0}; @@ -1863,17 +1880,43 @@ int32_t tqProcessTaskUpdateReq(STQ* pTq, SRpcMsg* pMsg) { } SStreamTask* pTask = *ppTask; - tqDebug("s-task:%s receive nodeEp update msg from mnode", pTask->id.idStr); + if (pMeta->updateInfo.transId != req.transId) { + pMeta->updateInfo.transId = req.transId; + tqDebug("s-task:%s receive new trans to update nodeEp msg from mnode, transId:%d", pTask->id.idStr, req.transId); + // info needs to be kept till the new trans to update the nodeEp arrived. + taosHashClear(pMeta->updateInfo.pTasks); + } else { + tqDebug("s-task:%s recv trans to update nodeEp from mnode, transId:%d", pTask->id.idStr, req.transId); + } + + STaskUpdateEntry entry = {.streamId = req.streamId, .taskId = req.taskId, .transId = req.transId}; + void* exist = taosHashGet(pMeta->updateInfo.pTasks, &entry, sizeof(STaskUpdateEntry)); + if (exist != NULL) { + tqDebug("s-task:%s (vgId:%d) already update in trans:%d, discard the nodeEp update msg", pTask->id.idStr, vgId, + req.transId); + rsp.code = TSDB_CODE_SUCCESS; + taosWUnLockLatch(&pMeta->lock); + taosArrayDestroy(req.pNodeList); + return rsp.code; + } + + taosWUnLockLatch(&pMeta->lock); + + // the following two functions should not be executed within the scope of meta lock to avoid deadlock streamTaskUpdateEpsetInfo(pTask, req.pNodeList); - streamSetStatusNormal(pTask); + streamTaskResetStatus(pTask); + + // continue after lock the meta again + taosWLockLatch(&pMeta->lock); SStreamTask** ppHTask = NULL; - if (pTask->hTaskInfo.id.taskId != 0) { + if (HAS_RELATED_FILLHISTORY_TASK(pTask)) { ppHTask = (SStreamTask**)taosHashGet(pMeta->pTasksMap, &pTask->hTaskInfo.id, sizeof(pTask->hTaskInfo.id)); if (ppHTask == NULL || *ppHTask == NULL) { tqError("vgId:%d failed to acquire fill-history task:0x%x when handling update, it may have been dropped already", pMeta->vgId, req.taskId); + CLEAR_RELATED_FILLHISTORY_TASK(pTask); } else { tqDebug("s-task:%s fill-history task update nodeEp along with stream task", (*ppHTask)->id.idStr); streamTaskUpdateEpsetInfo(*ppHTask, req.pNodeList); @@ -1892,12 +1935,14 @@ int32_t tqProcessTaskUpdateReq(STQ* pTq, SRpcMsg* pMsg) { } streamTaskStop(pTask); - taosHashPut(pMeta->pUpdateTaskSet, &pTask->id, sizeof(pTask->id), NULL, 0); + + // keep the already handled info + taosHashPut(pMeta->updateInfo.pTasks, &entry, sizeof(entry), NULL, 0); if (ppHTask != NULL) { streamTaskStop(*ppHTask); tqDebug("s-task:%s task nodeEp update completed, streamTask and related fill-history task closed", pTask->id.idStr); - taosHashPut(pMeta->pUpdateTaskSet, &(*ppHTask)->id, sizeof(pTask->id), NULL, 0); + taosHashPut(pMeta->updateInfo.pTasks, &(*ppHTask)->id, sizeof(pTask->id), NULL, 0); } else { tqDebug("s-task:%s task nodeEp update completed, streamTask closed", pTask->id.idStr); } @@ -1906,25 +1951,30 @@ int32_t tqProcessTaskUpdateReq(STQ* pTq, SRpcMsg* pMsg) { // possibly only handle the stream task. int32_t numOfTasks = streamMetaGetNumOfTasks(pMeta); - int32_t updateTasks = taosHashGetSize(pMeta->pUpdateTaskSet); + int32_t updateTasks = taosHashGetSize(pMeta->updateInfo.pTasks); - pMeta->startInfo.startedAfterNodeUpdate = 1; + pMeta->startInfo.startAllTasksFlag = 1; if (updateTasks < numOfTasks) { tqDebug("vgId:%d closed tasks:%d, unclosed:%d, all tasks will be started when nodeEp update completed", vgId, updateTasks, (numOfTasks - updateTasks)); taosWUnLockLatch(&pMeta->lock); } else { - taosHashClear(pMeta->pUpdateTaskSet); - if (!pTq->pVnode->restored) { tqDebug("vgId:%d vnode restore not completed, not restart the tasks, clear the start after nodeUpdate flag", vgId); - pMeta->startInfo.startedAfterNodeUpdate = 0; + pMeta->startInfo.startAllTasksFlag = 0; taosWUnLockLatch(&pMeta->lock); } else { tqDebug("vgId:%d tasks are all updated and stopped, restart them", vgId); - terrno = 0; + taosWUnLockLatch(&pMeta->lock); + + while (streamMetaTaskInTimer(pMeta)) { + qDebug("vgId:%d some tasks in timer, wait for 100ms and recheck", pMeta->vgId); + taosMsleep(100); + } + + taosWLockLatch(&pMeta->lock); int32_t code = streamMetaReopen(pMeta); if (code != 0) { tqError("vgId:%d failed to reopen stream meta", vgId); @@ -1942,8 +1992,8 @@ int32_t tqProcessTaskUpdateReq(STQ* pTq, SRpcMsg* pMsg) { if (vnodeIsRoleLeader(pTq->pVnode) && !tsDisableStream) { vInfo("vgId:%d restart all stream tasks after all tasks being updated", vgId); - tqStartStreamTasks(pTq); - tqCheckAndRunStreamTaskAsync(pTq); + tqResetStreamTaskStatus(pTq); + tqLaunchStreamTaskAsync(pTq); } else { vInfo("vgId:%d, follower node not start stream tasks", vgId); } @@ -1970,10 +2020,10 @@ int32_t tqProcessTaskResetReq(STQ* pTq, SRpcMsg* pMsg) { tqDebug("s-task:%s receive task-reset msg from mnode, reset status and ready for data processing", pTask->id.idStr); // clear flag set during do checkpoint, and open inputQ for all upstream tasks - if (pTask->status.taskStatus == TASK_STATUS__CK) { + if (streamTaskGetStatus(pTask, NULL) == TASK_STATUS__CK) { streamTaskClearCheckInfo(pTask); taosArrayClear(pTask->pReadyMsgList); - streamSetStatusNormal(pTask); + streamTaskSetStatusReady(pTask); } streamMetaReleaseTask(pMeta, pTask); diff --git a/source/dnode/vnode/src/tq/tqPush.c b/source/dnode/vnode/src/tq/tqPush.c index 62952078bc..50ee52f45b 100644 --- a/source/dnode/vnode/src/tq/tqPush.c +++ b/source/dnode/vnode/src/tq/tqPush.c @@ -39,7 +39,7 @@ int32_t tqPushMsg(STQ* pTq, tmsg_t msgType) { int32_t numOfTasks = streamMetaGetNumOfTasks(pTq->pStreamMeta); taosRUnLockLatch(&pTq->pStreamMeta->lock); - tqDebug("handle submit, restore:%d, numOfTasks:%d", pTq->pVnode->restored, numOfTasks); +// tqTrace("vgId:%d handle submit, restore:%d, numOfTasks:%d", TD_VID(pTq->pVnode), pTq->pVnode->restored, numOfTasks); // push data for stream processing: // 1. the vnode has already been restored. diff --git a/source/dnode/vnode/src/tq/tqSink.c b/source/dnode/vnode/src/tq/tqSink.c index 7d1c754005..51d51ebbef 100644 --- a/source/dnode/vnode/src/tq/tqSink.c +++ b/source/dnode/vnode/src/tq/tqSink.c @@ -13,6 +13,7 @@ * along with this program. If not, see . */ +#include #include "tcommon.h" #include "tmsg.h" #include "tq.h" @@ -28,19 +29,19 @@ static bool hasOnlySubmitData(const SArray* pBlocks, int32_t numOfBlocks); static int32_t tsAscendingSortFn(const void* p1, const void* p2); static int32_t setDstTableDataUid(SVnode* pVnode, SStreamTask* pTask, SSDataBlock* pDataBlock, char* stbFullName, SSubmitTbData* pTableData); -static int32_t setDstTableDataPayload(SStreamTask* pTask, int32_t blockIndex, SSDataBlock* pDataBlock, - SSubmitTbData* pTableData); static int32_t doBuildAndSendDeleteMsg(SVnode* pVnode, char* stbFullName, SSDataBlock* pDataBlock, SStreamTask* pTask, int64_t suid); static int32_t doBuildAndSendSubmitMsg(SVnode* pVnode, SStreamTask* pTask, SSubmitReq2* pReq, int32_t numOfBlocks); static int32_t buildSubmitMsgImpl(SSubmitReq2* pSubmitReq, int32_t vgId, void** pMsg, int32_t* msgLen); -static int32_t doConvertRows(SSubmitTbData* pTableData, STSchema* pTSchema, SSDataBlock* pDataBlock, const char* id); +static int32_t doConvertRows(SSubmitTbData* pTableData, const STSchema* pTSchema, SSDataBlock* pDataBlock, const char* id); static int32_t doWaitForDstTableCreated(SVnode* pVnode, SStreamTask* pTask, STableSinkInfo* pTableSinkInfo, const char* dstTableName, int64_t* uid); static int32_t doPutIntoCache(SSHashObj* pSinkTableMap, STableSinkInfo* pTableSinkInfo, uint64_t groupId, const char* id); -static int32_t doMergeExistedRows(SSubmitTbData* pExisted, const SSubmitTbData* pNew, const char* id); static bool isValidDstChildTable(SMetaReader* pReader, int32_t vgId, const char* ctbName, int64_t suid); -static SVCreateTbReq* buildAutoCreateTableReq(char* stbFullName, int64_t suid, int32_t numOfCols, SSDataBlock* pDataBlock); +static int32_t initCreateTableMsg(SVCreateTbReq* pCreateTableReq, uint64_t suid, const char* stbFullName, int32_t numOfTags); +static SArray* createDefaultTagColName(); +static void setCreateTableMsgTableName(SVCreateTbReq* pCreateTableReq, SSDataBlock* pDataBlock, const char* stbFullName, + int64_t gid); int32_t tqBuildDeleteReq(const char* stbFullName, const SSDataBlock* pDataBlock, SBatchDeleteReq* deleteReq, const char* pIdStr) { @@ -138,61 +139,68 @@ static int32_t tqPutReqToQueue(SVnode* pVnode, SVCreateTbBatchReq* pReqs) { return TSDB_CODE_SUCCESS; } +int32_t initCreateTableMsg(SVCreateTbReq* pCreateTableReq, uint64_t suid, const char* stbFullName, int32_t numOfTags) { + pCreateTableReq->flags = 0; + pCreateTableReq->type = TSDB_CHILD_TABLE; + pCreateTableReq->ctb.suid = suid; + + // set super table name + SName name = {0}; + tNameFromString(&name, stbFullName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); + pCreateTableReq->ctb.stbName = taosStrdup((char*)tNameGetTableName(&name)); + + pCreateTableReq->ctb.tagNum = numOfTags; + return TSDB_CODE_SUCCESS; +} + +SArray* createDefaultTagColName() { + SArray* pTagColNameList = taosArrayInit(1, TSDB_COL_NAME_LEN); + char tagNameStr[TSDB_COL_NAME_LEN] = "group_id"; + taosArrayPush(pTagColNameList, tagNameStr); + return pTagColNameList; +} + +void setCreateTableMsgTableName(SVCreateTbReq* pCreateTableReq, SSDataBlock* pDataBlock, const char* stbFullName, + int64_t gid) { + if (pDataBlock->info.parTbName[0]) { + pCreateTableReq->name = taosStrdup(pDataBlock->info.parTbName); + } else { + pCreateTableReq->name = buildCtbNameByGroupId(stbFullName, gid); + } +} + static int32_t doBuildAndSendCreateTableMsg(SVnode* pVnode, char* stbFullName, SSDataBlock* pDataBlock, SStreamTask* pTask, int64_t suid) { tqDebug("s-task:%s build create table msg", pTask->id.idStr); STSchema* pTSchema = pTask->outputInfo.tbSink.pTSchema; int32_t rows = pDataBlock->info.rows; - SArray* tagArray = NULL; + SArray* tagArray = taosArrayInit(4, sizeof(STagVal));; int32_t code = 0; SVCreateTbBatchReq reqs = {0}; - SArray* crTblArray = reqs.pArray = taosArrayInit(1, sizeof(SVCreateTbReq)); if (NULL == reqs.pArray) { + tqError("s-task:%s failed to init create table msg, code:%s", pTask->id.idStr, tstrerror(terrno)); goto _end; } for (int32_t rowId = 0; rowId < rows; rowId++) { SVCreateTbReq* pCreateTbReq = &((SVCreateTbReq){0}); - // set const - pCreateTbReq->flags = 0; - pCreateTbReq->type = TSDB_CHILD_TABLE; - pCreateTbReq->ctb.suid = suid; - - // set super table name - SName name = {0}; - tNameFromString(&name, stbFullName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); - pCreateTbReq->ctb.stbName = taosStrdup((char*)tNameGetTableName(&name)); // taosStrdup(stbFullName); - - // set tag content int32_t size = taosArrayGetSize(pDataBlock->pDataBlock); - if (size == 2) { - tagArray = taosArrayInit(1, sizeof(STagVal)); - if (!tagArray) { - tdDestroySVCreateTbReq(pCreateTbReq); - goto _end; - } + int32_t numOfTags = TMAX(size - UD_TAG_COLUMN_INDEX, 1); + initCreateTableMsg(pCreateTbReq, suid, stbFullName, numOfTags); + taosArrayClear(tagArray); + + if (size == 2) { STagVal tagVal = { .cid = pTSchema->numOfCols + 1, .type = TSDB_DATA_TYPE_UBIGINT, .i64 = pDataBlock->info.id.groupId}; taosArrayPush(tagArray, &tagVal); - - // set tag name - SArray* tagName = taosArrayInit(1, TSDB_COL_NAME_LEN); - char tagNameStr[TSDB_COL_NAME_LEN] = "group_id"; - taosArrayPush(tagName, tagNameStr); - pCreateTbReq->ctb.tagName = tagName; + pCreateTbReq->ctb.tagName = createDefaultTagColName(); } else { - tagArray = taosArrayInit(size - 1, sizeof(STagVal)); - if (!tagArray) { - tdDestroySVCreateTbReq(pCreateTbReq); - goto _end; - } - for (int32_t tagId = UD_TAG_COLUMN_INDEX, step = 1; tagId < size; tagId++, step++) { SColumnInfoData* pTagData = taosArrayGet(pDataBlock->pDataBlock, tagId); @@ -209,29 +217,26 @@ static int32_t doBuildAndSendCreateTableMsg(SVnode* pVnode, char* stbFullName, S taosArrayPush(tagArray, &tagVal); } } - pCreateTbReq->ctb.tagNum = TMAX(size - UD_TAG_COLUMN_INDEX, 1); - STag* pTag = NULL; - tTagNew(tagArray, 1, false, &pTag); + tTagNew(tagArray, 1, false, (STag**)&pCreateTbReq->ctb.pTag); tagArray = taosArrayDestroy(tagArray); - if (pTag == NULL) { + if (pCreateTbReq->ctb.pTag == NULL) { tdDestroySVCreateTbReq(pCreateTbReq); code = TSDB_CODE_OUT_OF_MEMORY; goto _end; } - pCreateTbReq->ctb.pTag = (uint8_t*)pTag; - - // set table name - if (!pDataBlock->info.parTbName[0]) { + uint64_t gid = pDataBlock->info.id.groupId; + if (taosArrayGetSize(pDataBlock->pDataBlock) > UD_GROUPID_COLUMN_INDEX) { SColumnInfoData* pGpIdColInfo = taosArrayGet(pDataBlock->pDataBlock, UD_GROUPID_COLUMN_INDEX); + // todo remove this void* pGpIdData = colDataGetData(pGpIdColInfo, rowId); - pCreateTbReq->name = buildCtbNameByGroupId(stbFullName, *(uint64_t*)pGpIdData); - } else { - pCreateTbReq->name = taosStrdup(pDataBlock->info.parTbName); + ASSERT(gid == *(int64_t*)pGpIdData); } + setCreateTableMsgTableName(pCreateTbReq, pDataBlock, stbFullName, gid); + taosArrayPush(reqs.pArray, pCreateTbReq); tqDebug("s-task:%s build create table:%s msg complete", pTask->id.idStr, pCreateTbReq->name); } @@ -330,6 +335,9 @@ int32_t doMergeExistedRows(SSubmitTbData* pExisted, const SSubmitTbData* pNew, c tqTrace("s-task:%s rows merged, final rows:%d, uid:%" PRId64 ", existed auto-create table:%d, new-block:%d", id, (int32_t)taosArrayGetSize(pFinal), pExisted->uid, (pExisted->pCreateTbReq != NULL), (pNew->pCreateTbReq != NULL)); + + tdDestroySVCreateTbReq(pNew->pCreateTbReq); + taosMemoryFree(pNew->pCreateTbReq); return TSDB_CODE_SUCCESS; } @@ -390,60 +398,33 @@ bool isValidDstChildTable(SMetaReader* pReader, int32_t vgId, const char* ctbNam return true; } -SVCreateTbReq* buildAutoCreateTableReq(char* stbFullName, int64_t suid, int32_t numOfCols, SSDataBlock* pDataBlock) { - char* ctbName = pDataBlock->info.parTbName; - - SVCreateTbReq* pCreateTbReq = taosMemoryCalloc(1, sizeof(SVCreateStbReq)); +SVCreateTbReq* buildAutoCreateTableReq(const char* stbFullName, int64_t suid, int32_t numOfCols, + SSDataBlock* pDataBlock, SArray* pTagArray) { + SVCreateTbReq* pCreateTbReq = taosMemoryCalloc(1, sizeof(SVCreateTbReq)); if (pCreateTbReq == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } - // set tag content - SArray* tagArray = taosArrayInit(1, sizeof(STagVal)); - if (tagArray == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - tdDestroySVCreateTbReq(pCreateTbReq); - taosMemoryFreeClear(pCreateTbReq); - return NULL; - } - - // set const - pCreateTbReq->flags = 0; - pCreateTbReq->type = TSDB_CHILD_TABLE; - pCreateTbReq->ctb.suid = suid; - - // set super table name - SName name = {0}; - tNameFromString(&name, stbFullName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); - pCreateTbReq->ctb.stbName = taosStrdup((char*)tNameGetTableName(&name)); + taosArrayClear(pTagArray); + initCreateTableMsg(pCreateTbReq, suid, stbFullName, 1); STagVal tagVal = { .cid = numOfCols, .type = TSDB_DATA_TYPE_UBIGINT, .i64 = pDataBlock->info.id.groupId}; - taosArrayPush(tagArray, &tagVal); - pCreateTbReq->ctb.tagNum = taosArrayGetSize(tagArray); + taosArrayPush(pTagArray, &tagVal); - STag* pTag = NULL; - tTagNew(tagArray, 1, false, &pTag); - taosArrayDestroy(tagArray); + tTagNew(pTagArray, 1, false, (STag**) &pCreateTbReq->ctb.pTag); - if (pTag == NULL) { + if (pCreateTbReq->ctb.pTag == NULL) { tdDestroySVCreateTbReq(pCreateTbReq); taosMemoryFreeClear(pCreateTbReq); terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } - pCreateTbReq->ctb.pTag = (uint8_t*)pTag; - - // set tag name - SArray* tagName = taosArrayInit(1, TSDB_COL_NAME_LEN); - char k[TSDB_COL_NAME_LEN] = "group_id"; - taosArrayPush(tagName, k); - - pCreateTbReq->ctb.tagName = tagName; + pCreateTbReq->ctb.tagName = createDefaultTagColName(); // set table name - pCreateTbReq->name = taosStrdup(ctbName); + setCreateTableMsgTableName(pCreateTbReq, pDataBlock, stbFullName, pDataBlock->info.id.groupId); return pCreateTbReq; } @@ -514,7 +495,7 @@ int32_t tsAscendingSortFn(const void* p1, const void* p2) { } } -int32_t doConvertRows(SSubmitTbData* pTableData, STSchema* pTSchema, SSDataBlock* pDataBlock, const char* id) { +int32_t doConvertRows(SSubmitTbData* pTableData, const STSchema* pTSchema, SSDataBlock* pDataBlock, const char* id) { int32_t numOfRows = pDataBlock->info.rows; int32_t code = TSDB_CODE_SUCCESS; @@ -592,7 +573,7 @@ int32_t doWaitForDstTableCreated(SVnode* pVnode, SStreamTask* pTask, STableSinkI const char* id = pTask->id.idStr; while (pTableSinkInfo->uid == 0) { - if (streamTaskShouldStop(&pTask->status)) { + if (streamTaskShouldStop(pTask)) { tqDebug("s-task:%s task will stop, quit from waiting for table:%s create", id, dstTableName); return TSDB_CODE_STREAM_EXEC_CANCELLED; } @@ -693,8 +674,13 @@ int32_t setDstTableDataUid(SVnode* pVnode, SStreamTask* pTask, SSDataBlock* pDat tqDebug("s-task:%s stream write into table:%s, table auto created", id, dstTableName); + SArray* pTagArray = taosArrayInit(pTSchema->numOfCols + 1, sizeof(STagVal)); + pTableData->flags = SUBMIT_REQ_AUTO_CREATE_TABLE; - pTableData->pCreateTbReq = buildAutoCreateTableReq(stbFullName, suid, pTSchema->numOfCols + 1, pDataBlock); + pTableData->pCreateTbReq = + buildAutoCreateTableReq(stbFullName, suid, pTSchema->numOfCols + 1, pDataBlock, pTagArray); + taosArrayDestroy(pTagArray); + if (pTableData->pCreateTbReq == NULL) { tqError("s-task:%s failed to build auto create table req, code:%s", id, tstrerror(terrno)); taosMemoryFree(pTableSinkInfo); @@ -724,17 +710,16 @@ int32_t setDstTableDataUid(SVnode* pVnode, SStreamTask* pTask, SSDataBlock* pDat return TSDB_CODE_SUCCESS; } -int32_t setDstTableDataPayload(SStreamTask* pTask, int32_t blockIndex, SSDataBlock* pDataBlock, - SSubmitTbData* pTableData) { - int32_t numOfRows = pDataBlock->info.rows; - const char* id = pTask->id.idStr; +int32_t setDstTableDataPayload(uint64_t suid, const STSchema *pTSchema, int32_t blockIndex, SSDataBlock* pDataBlock, + SSubmitTbData* pTableData, const char* id) { + int32_t numOfRows = pDataBlock->info.rows; tqDebug("s-task:%s sink data pipeline, build submit msg from %dth resBlock, including %d rows, dst suid:%" PRId64, - id, blockIndex + 1, numOfRows, pTask->outputInfo.tbSink.stbUid); + id, blockIndex + 1, numOfRows, suid); char* dstTableName = pDataBlock->info.parTbName; // convert all rows - int32_t code = doConvertRows(pTableData, pTask->outputInfo.tbSink.pTSchema, pDataBlock, id); + int32_t code = doConvertRows(pTableData, pTSchema, pDataBlock, id); if (code != TSDB_CODE_SUCCESS) { tqError("s-task:%s failed to convert rows from result block, code:%s", id, tstrerror(terrno)); return code; @@ -773,7 +758,7 @@ void tqSinkDataIntoDstTable(SStreamTask* pTask, void* vnode, void* data) { numOfBlocks); for(int32_t i = 0; i < numOfBlocks; ++i) { - if (streamTaskShouldStop(&pTask->status)) { + if (streamTaskShouldStop(pTask)) { return; } @@ -800,7 +785,7 @@ void tqSinkDataIntoDstTable(SStreamTask* pTask, void* vnode, void* data) { continue; } - code = setDstTableDataPayload(pTask, i, pDataBlock, &tbData); + code = setDstTableDataPayload(suid, pTSchema, i, pDataBlock, &tbData, id); if (code != TSDB_CODE_SUCCESS) { continue; } @@ -823,7 +808,7 @@ void tqSinkDataIntoDstTable(SStreamTask* pTask, void* vnode, void* data) { bool hasSubmit = false; for (int32_t i = 0; i < numOfBlocks; i++) { - if (streamTaskShouldStop(&pTask->status)) { + if (streamTaskShouldStop(pTask)) { taosHashCleanup(pTableIndexMap); tDestroySubmitReq(&submitReq, TSDB_MSG_FLG_ENCODE); return; @@ -847,7 +832,7 @@ void tqSinkDataIntoDstTable(SStreamTask* pTask, void* vnode, void* data) { continue; } - code = setDstTableDataPayload(pTask, i, pDataBlock, &tbData); + code = setDstTableDataPayload(suid, pTSchema, i, pDataBlock, &tbData, id); if (code != TSDB_CODE_SUCCESS) { continue; } @@ -857,7 +842,7 @@ void tqSinkDataIntoDstTable(SStreamTask* pTask, void* vnode, void* data) { int32_t size = (int32_t)taosArrayGetSize(submitReq.aSubmitTbData) - 1; taosHashPut(pTableIndexMap, &groupId, sizeof(groupId), &size, sizeof(size)); } else { - code = setDstTableDataPayload(pTask, i, pDataBlock, &tbData); + code = setDstTableDataPayload(suid, pTSchema, i, pDataBlock, &tbData, id); if (code != TSDB_CODE_SUCCESS) { continue; } diff --git a/source/dnode/vnode/src/tq/tqStreamTask.c b/source/dnode/vnode/src/tq/tqStreamTask.c index b9cb22e7a4..1f1dd61c3c 100644 --- a/source/dnode/vnode/src/tq/tqStreamTask.c +++ b/source/dnode/vnode/src/tq/tqStreamTask.c @@ -60,7 +60,7 @@ int32_t tqScanWal(STQ* pTq) { return 0; } -int32_t tqCheckAndRunStreamTask(STQ* pTq) { +int32_t tqStartStreamTask(STQ* pTq) { int32_t vgId = TD_VID(pTq->pVnode); SStreamMeta* pMeta = pTq->pStreamMeta; @@ -92,19 +92,19 @@ int32_t tqCheckAndRunStreamTask(STQ* pTq) { } if (pTask->status.downstreamReady == 1) { - tqDebug("s-task:%s downstream ready, no need to check downstream, check only related fill-history task", - pTask->id.idStr); - streamLaunchFillHistoryTask(pTask); + if (HAS_RELATED_FILLHISTORY_TASK(pTask)) { + tqDebug("s-task:%s downstream ready, no need to check downstream, check only related fill-history task", + pTask->id.idStr); + streamLaunchFillHistoryTask(pTask); + } + + streamMetaUpdateTaskReadyInfo(pTask); streamMetaReleaseTask(pMeta, pTask); continue; } - pTask->execInfo.init = taosGetTimestampMs(); - tqDebug("s-task:%s start check downstream tasks, set the init ts:%"PRId64, pTask->id.idStr, pTask->execInfo.init); - - streamSetStatusNormal(pTask); - streamTaskCheckDownstream(pTask); - + EStreamTaskEvent event = (HAS_RELATED_FILLHISTORY_TASK(pTask)) ? TASK_EVENT_INIT_STREAM_SCANHIST : TASK_EVENT_INIT; + streamTaskHandleEvent(pTask->status.pSM, event); streamMetaReleaseTask(pMeta, pTask); } @@ -112,9 +112,9 @@ int32_t tqCheckAndRunStreamTask(STQ* pTq) { return 0; } -int32_t tqCheckAndRunStreamTaskAsync(STQ* pTq) { - int32_t vgId = TD_VID(pTq->pVnode); +int32_t tqLaunchStreamTaskAsync(STQ* pTq) { SStreamMeta* pMeta = pTq->pStreamMeta; + int32_t vgId = pMeta->vgId; int32_t numOfTasks = taosArrayGetSize(pMeta->pTaskList); if (numOfTasks == 0) { @@ -228,7 +228,7 @@ int32_t tqStopStreamTasks(STQ* pTq) { return 0; } -int32_t tqStartStreamTasks(STQ* pTq) { +int32_t tqResetStreamTaskStatus(STQ* pTq) { SStreamMeta* pMeta = pTq->pStreamMeta; int32_t vgId = TD_VID(pTq->pVnode); int32_t numOfTasks = taosArrayGetSize(pMeta->pTaskList); @@ -243,11 +243,7 @@ int32_t tqStartStreamTasks(STQ* pTq) { STaskId id = {.streamId = pTaskId->streamId, .taskId = pTaskId->taskId}; SStreamTask** pTask = taosHashGet(pMeta->pTasksMap, &id, sizeof(id)); - - int8_t status = (*pTask)->status.taskStatus; - if (status == TASK_STATUS__STOP && (*pTask)->info.fillHistory != 1) { - streamSetStatusNormal(*pTask); - } + streamTaskResetStatus(*pTask); } return 0; @@ -328,15 +324,17 @@ static bool taskReadyForDataFromWal(SStreamTask* pTask) { } // not in ready state, do not handle the data from wal - int32_t status = pTask->status.taskStatus; - if (status != TASK_STATUS__NORMAL) { - tqTrace("s-task:%s not ready for submit block in wal, status:%s", pTask->id.idStr, streamGetTaskStatusStr(status)); +// int32_t status = pTask->status.taskStatus; + char* p = NULL; + int32_t status = streamTaskGetStatus(pTask, &p); + if (streamTaskGetStatus(pTask, &p) != TASK_STATUS__READY) { + tqTrace("s-task:%s not ready for submit block in wal, status:%s", pTask->id.idStr, p); return false; } // fill-history task has entered into the last phase, no need to anything if ((pTask->info.fillHistory == 1) && pTask->status.appendTranstateBlock) { - ASSERT(status == TASK_STATUS__NORMAL); + ASSERT(status == TASK_STATUS__READY); // the maximum version of data in the WAL has reached already, the step2 is done tqDebug("s-task:%s fill-history reach the maximum ver:%" PRId64 ", not scan wal anymore", pTask->id.idStr, pTask->dataRange.range.maxVer); @@ -344,13 +342,13 @@ static bool taskReadyForDataFromWal(SStreamTask* pTask) { } // check if input queue is full or not - if (streamQueueIsFull(pTask->inputInfo.queue)) { + if (streamQueueIsFull(pTask->inputq.queue)) { tqTrace("s-task:%s input queue is full, do nothing", pTask->id.idStr); return false; } // the input queue of downstream task is full, so the output is blocked, stopped for a while - if (pTask->inputInfo.status == TASK_INPUT_STATUS__BLOCKED) { + if (pTask->inputq.status == TASK_INPUT_STATUS__BLOCKED) { tqDebug("s-task:%s inputQ is blocked, do nothing", pTask->id.idStr); return false; } @@ -444,14 +442,15 @@ int32_t doScanWalForAllTasks(SStreamMeta* pStreamMeta, bool* pScanIdle) { continue; } - int32_t numOfItems = streamQueueGetNumOfItems(pTask->inputInfo.queue); + int32_t numOfItems = streamQueueGetNumOfItems(pTask->inputq.queue); int64_t maxVer = (pTask->info.fillHistory == 1) ? pTask->dataRange.range.maxVer : INT64_MAX; taosThreadMutexLock(&pTask->lock); - const char* pStatus = streamGetTaskStatusStr(pTask->status.taskStatus); - if (pTask->status.taskStatus != TASK_STATUS__NORMAL) { - tqDebug("s-task:%s not ready for submit block from wal, status:%s", pTask->id.idStr, pStatus); + char* p = NULL; + ETaskStatus status = streamTaskGetStatus(pTask, &p); + if (status != TASK_STATUS__READY) { + tqDebug("s-task:%s not ready for submit block from wal, status:%s", pTask->id.idStr, p); taosThreadMutexUnlock(&pTask->lock); streamMetaReleaseTask(pStreamMeta, pTask); continue; diff --git a/source/dnode/vnode/src/tsdb/tsdbRead2.c b/source/dnode/vnode/src/tsdb/tsdbRead2.c index 41e0bd373e..d1919d95ba 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead2.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead2.c @@ -1200,11 +1200,28 @@ static bool overlapWithNeighborBlock2(SFileDataBlockInfo* pBlock, SBrinRecord* p } } -static bool bufferDataInFileBlockGap(int32_t order, TSDBKEY key, SFileDataBlockInfo* pBlock) { +static int64_t getBoarderKeyInFiles(SFileDataBlockInfo* pBlock, SLastBlockReader* pLastBlockReader, int32_t order) { bool ascScan = ASCENDING_TRAVERSE(order); + bool bHasDataInLastBlock = hasDataInLastBlock(pLastBlockReader); - return (ascScan && (key.ts != TSKEY_INITIAL_VAL && key.ts <= pBlock->record.firstKey)) || - (!ascScan && (key.ts != TSKEY_INITIAL_VAL && key.ts >= pBlock->record.lastKey)); + int64_t key = 0; + if (bHasDataInLastBlock) { + int64_t keyInStt = getCurrentKeyInLastBlock(pLastBlockReader); + key = ascScan ? TMIN(pBlock->record.firstKey, keyInStt) : TMAX(pBlock->record.lastKey, keyInStt); + } else { + key = ascScan ? pBlock->record.firstKey : pBlock->record.lastKey; + } + + return key; +} + +static bool bufferDataInFileBlockGap(TSDBKEY keyInBuf, SFileDataBlockInfo* pBlock, + SLastBlockReader* pLastBlockReader, int32_t order) { + bool ascScan = ASCENDING_TRAVERSE(order); + int64_t key = getBoarderKeyInFiles(pBlock, pLastBlockReader, order); + + return (ascScan && (keyInBuf.ts != TSKEY_INITIAL_VAL && keyInBuf.ts < key)) || + (!ascScan && (keyInBuf.ts != TSKEY_INITIAL_VAL && keyInBuf.ts > key)); } static bool keyOverlapFileBlock(TSDBKEY key, SFileDataBlockInfo* pBlock, SVersionRange* pVerRange) { @@ -2667,6 +2684,15 @@ static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) { } } +static bool notOverlapWithSttFiles(SFileDataBlockInfo* pBlockInfo, SLastBlockReader* pLastBlockReader, bool asc) { + if(!hasDataInLastBlock(pLastBlockReader)) { + return true; + } else { + int64_t keyInStt = getCurrentKeyInLastBlock(pLastBlockReader); + return (asc && pBlockInfo->record.lastKey < keyInStt) || (!asc && pBlockInfo->record.firstKey > keyInStt); + } +} + static int32_t doBuildDataBlock(STsdbReader* pReader) { int32_t code = TSDB_CODE_SUCCESS; @@ -2702,17 +2728,13 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) { // build composed data block code = buildComposedDataBlock(pReader); - } else if (bufferDataInFileBlockGap(pReader->info.order, keyInBuf, pBlockInfo)) { - // data in memory that are earlier than current file block + } else if (bufferDataInFileBlockGap(keyInBuf, pBlockInfo, pLastBlockReader, pReader->info.order)) { + // data in memory that are earlier than current file block and stt blocks // rows in buffer should be less than the file block in asc, greater than file block in desc - int64_t endKey = - (ASCENDING_TRAVERSE(pReader->info.order)) ? pBlockInfo->record.firstKey : pBlockInfo->record.lastKey; + int64_t endKey = getBoarderKeyInFiles(pBlockInfo, pLastBlockReader, pReader->info.order); code = buildDataBlockFromBuf(pReader, pScanInfo, endKey); } else { - bool bHasDataInLastBlock = hasDataInLastBlock(pLastBlockReader); - int64_t tsLast = bHasDataInLastBlock ? getCurrentKeyInLastBlock(pLastBlockReader) : INT64_MIN; - if (!bHasDataInLastBlock || - ((asc && pBlockInfo->record.lastKey < tsLast) || (!asc && pBlockInfo->record.firstKey > tsLast))) { + if (notOverlapWithSttFiles(pBlockInfo, pLastBlockReader, asc)) { // whole block is required, return it directly SDataBlockInfo* pInfo = &pReader->resBlockInfo.pResBlock->info; pInfo->rows = pBlockInfo->record.numRow; @@ -2723,7 +2745,7 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) { setBlockAllDumped(&pStatus->fBlockDumpInfo, pBlockInfo->record.lastKey, pReader->info.order); // update the last key for the corresponding table - pScanInfo->lastKey = ASCENDING_TRAVERSE(pReader->info.order) ? pInfo->window.ekey : pInfo->window.skey; + pScanInfo->lastKey = asc ? pInfo->window.ekey : pInfo->window.skey; tsdbDebug("%p uid:%" PRIu64 " clean file block retrieved from file, global index:%d, " "table index:%d, rows:%d, brange:%" PRId64 "-%" PRId64 ", %s", @@ -2750,10 +2772,11 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) { } // data in stt now overlaps with current active file data block, need to composed with file data block. - int64_t keyInStt = getCurrentKeyInLastBlock(pLastBlockReader); - if ((keyInStt >= pBlockInfo->record.firstKey && asc) || (keyInStt <= pBlockInfo->record.lastKey && (!asc))) { - tsdbDebug("%p keyInStt:%" PRId64 ", overlap with file block, brange:%" PRId64 "-%" PRId64 " %s", pReader, - keyInStt, pBlockInfo->record.firstKey, pBlockInfo->record.lastKey, pReader->idStr); + int64_t lastKeyInStt = getCurrentKeyInLastBlock(pLastBlockReader); + if ((lastKeyInStt >= pBlockInfo->record.firstKey && asc) || + (lastKeyInStt <= pBlockInfo->record.lastKey && (!asc))) { + tsdbDebug("%p lastKeyInStt:%" PRId64 ", overlap with file block, brange:%" PRId64 "-%" PRId64 " %s", pReader, + lastKeyInStt, pBlockInfo->record.firstKey, pBlockInfo->record.lastKey, pReader->idStr); break; } } diff --git a/source/dnode/vnode/src/vnd/vnodeCfg.c b/source/dnode/vnode/src/vnd/vnodeCfg.c index bbd67611cb..07bfa6c719 100644 --- a/source/dnode/vnode/src/vnd/vnodeCfg.c +++ b/source/dnode/vnode/src/vnd/vnodeCfg.c @@ -106,7 +106,7 @@ int vnodeEncodeConfig(const void *pObj, SJson *pJson) { if (tjsonAddIntegerToObject(pJson, "keep1", pCfg->tsdbCfg.keep1) < 0) return -1; if (tjsonAddIntegerToObject(pJson, "keep2", pCfg->tsdbCfg.keep2) < 0) return -1; if (tjsonAddIntegerToObject(pJson, "keepTimeOffset", pCfg->tsdbCfg.keepTimeOffset) < 0) return -1; - if (pCfg->tsdbCfg.retentions[0].freq > 0) { + if (pCfg->tsdbCfg.retentions[0].keep > 0) { int32_t nRetention = 1; if (pCfg->tsdbCfg.retentions[1].freq > 0) { ++nRetention; diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index b6a4aaf388..12883a34af 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -585,7 +585,7 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t ver, SRpcMsg } } break; case TDMT_VND_STREAM_TASK_RESET: { - if (pVnode->restored/* && vnodeIsLeader(pVnode)*/) { + if (pVnode->restored && vnodeIsLeader(pVnode)) { tqProcessTaskResetReq(pVnode->pTq, pMsg); } } break; diff --git a/source/dnode/vnode/src/vnd/vnodeSync.c b/source/dnode/vnode/src/vnd/vnodeSync.c index c9e805d80b..dcc31526f7 100644 --- a/source/dnode/vnode/src/vnd/vnodeSync.c +++ b/source/dnode/vnode/src/vnd/vnodeSync.c @@ -555,7 +555,7 @@ static void vnodeRestoreFinish(const SSyncFSM *pFsm, const SyncIndex commitIdx) pVnode->restored = true; taosWLockLatch(&pVnode->pTq->pStreamMeta->lock); - if (pVnode->pTq->pStreamMeta->startInfo.startedAfterNodeUpdate) { + if (pVnode->pTq->pStreamMeta->startInfo.startAllTasksFlag) { vInfo("vgId:%d, sync restore finished, stream tasks will be launched by other thread", vgId); taosWUnLockLatch(&pVnode->pTq->pStreamMeta->lock); return; @@ -567,8 +567,8 @@ static void vnodeRestoreFinish(const SSyncFSM *pFsm, const SyncIndex commitIdx) vInfo("vgId:%d, sync restore finished, not launch stream tasks, since stream tasks are disabled", vgId); } else { vInfo("vgId:%d sync restore finished, start to launch stream tasks", pVnode->config.vgId); - tqStartStreamTasks(pVnode->pTq); - tqCheckAndRunStreamTaskAsync(pVnode->pTq); + tqResetStreamTaskStatus(pVnode->pTq); + tqLaunchStreamTaskAsync(pVnode->pTq); } } else { vInfo("vgId:%d, sync restore finished, not launch stream tasks since not leader", vgId); 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 f204f239b4..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); } @@ -215,37 +219,28 @@ int64_t getValOfDiffPrecision(int8_t unit, int64_t val) { return v; } -char* buildRetension(SArray* pRetension) { +static char* buildRetension(SArray* pRetension) { size_t size = taosArrayGetSize(pRetension); if (size == 0) { return NULL; } - char* p1 = taosMemoryCalloc(1, 100); - SRetention* p = taosArrayGet(pRetension, 0); - + char* p1 = taosMemoryCalloc(1, 100); int32_t len = 0; - int64_t v1 = getValOfDiffPrecision(p->freqUnit, p->freq); - int64_t v2 = getValOfDiffPrecision(p->keepUnit, p->keep); - len += sprintf(p1 + len, "%" PRId64 "%c:%" PRId64 "%c", v1, p->freqUnit, v2, p->keepUnit); + for (int32_t i = 0; i < size; ++i) { + SRetention* p = TARRAY_GET_ELEM(pRetension, i); + int64_t v1 = getValOfDiffPrecision(p->freqUnit, p->freq); + int64_t v2 = getValOfDiffPrecision(p->keepUnit, p->keep); + if (i == 0) { + len += sprintf(p1 + len, "-:%" PRId64 "%c", v2, p->keepUnit); + } else { + len += sprintf(p1 + len, "%" PRId64 "%c:%" PRId64 "%c", v1, p->freqUnit, v2, p->keepUnit); + } - if (size > 1) { - len += sprintf(p1 + len, ","); - p = taosArrayGet(pRetension, 1); - - v1 = getValOfDiffPrecision(p->freqUnit, p->freq); - v2 = getValOfDiffPrecision(p->keepUnit, p->keep); - len += sprintf(p1 + len, "%" PRId64 "%c:%" PRId64 "%c", v1, p->freqUnit, v2, p->keepUnit); - } - - if (size > 2) { - len += sprintf(p1 + len, ","); - p = taosArrayGet(pRetension, 2); - - v1 = getValOfDiffPrecision(p->freqUnit, p->freq); - v2 = getValOfDiffPrecision(p->keepUnit, p->keep); - len += sprintf(p1 + len, "%" PRId64 "%c:%" PRId64 "%c", v1, p->freqUnit, v2, p->keepUnit); + if (i < size - 1) { + len += sprintf(p1 + len, ","); + } } return p1; @@ -467,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; @@ -710,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); @@ -949,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: @@ -961,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..6e37a09938 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); @@ -1046,7 +1062,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 +1088,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 +1133,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 +2376,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/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 149306b23c..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 { } @@ -304,6 +305,7 @@ retention_list(A) ::= retention(B). retention_list(A) ::= retention_list(B) NK_COMMA retention(C). { A = addNodeToList(pCxt, B, C); } retention(A) ::= NK_VARIABLE(B) NK_COLON NK_VARIABLE(C). { A = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &B), createDurationValueNode(pCxt, &C)); } +retention(A) ::= NK_MINUS(B) NK_COLON NK_VARIABLE(C). { A = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &B), createDurationValueNode(pCxt, &C)); } %type speed_opt { int32_t } %destructor speed_opt { } @@ -507,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 { } @@ -647,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) @@ -780,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 8fd98f64de..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); @@ -1028,9 +1055,13 @@ SNode* createSelectStmt(SAstCreateContext* pCxt, bool isDistinct, SNodeList* pPr return select; } -SNode* setSelectStmtTagMode(SAstCreateContext* pCxt, SNode* pStmt, bool bSelectTags) { +SNode* setSelectStmtTagMode(SAstCreateContext* pCxt, SNode* pStmt, bool bSelectTags) { if (pStmt && QUERY_NODE_SELECT_STMT == nodeType(pStmt)) { - ((SSelectStmt*)pStmt)->tagScan = bSelectTags; + if (pCxt->pQueryCxt->biMode) { + ((SSelectStmt*)pStmt)->tagScan = true; + } else { + ((SSelectStmt*)pStmt)->tagScan = bSelectTags; + } } return pStmt; } @@ -1596,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) { @@ -1697,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); @@ -2211,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/parInsertSql.c b/source/libs/parser/src/parInsertSql.c index 0e007e127e..3a12d59776 100644 --- a/source/libs/parser/src/parInsertSql.c +++ b/source/libs/parser/src/parInsertSql.c @@ -965,10 +965,10 @@ 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; @@ -1168,7 +1168,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: @@ -1952,9 +1959,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; } 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 81ea550bbe..e464562ea0 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 @@ -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); } @@ -4605,10 +4665,22 @@ static int32_t checkDbRetentionsOption(STranslateContext* pCxt, SNodeList* pRete SValueNode* pPrevFreq = NULL; SValueNode* pPrevKeep = NULL; SNode* pRetention = NULL; + bool firstFreq = true; FOREACH(pRetention, pRetentions) { SNode* pNode = NULL; FOREACH(pNode, ((SNodeListNode*)pRetention)->pNodeList) { SValueNode* pVal = (SValueNode*)pNode; + if (firstFreq) { + firstFreq = false; + if (pVal->literal[0] != '-' || strlen(pVal->literal) != 1) { + return generateSyntaxErrMsgExt( + &pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DB_OPTION, + "Invalid option retentions(freq): %s, the interval of 1st retention level should be '-'", pVal->literal); + } + pVal->unit = TIME_UNIT_SECOND; // assign minimum unit + pVal->datum.i = 0; // assign minimum value + continue; + } if (DEAL_RES_ERROR == translateValue(pCxt, pVal)) { return pCxt->errCode; } @@ -4633,7 +4705,7 @@ static int32_t checkDbRetentionsOption(STranslateContext* pCxt, SNodeList* pRete } // check value range - if (pFreq->datum.i <= 0) { + if (pPrevFreq != NULL && pFreq->datum.i <= 0) { return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DB_OPTION, "Invalid option retentions(freq): %s should larger than 0", pFreq->literal); } @@ -6571,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; @@ -6675,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) { @@ -6750,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; } @@ -7591,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) { @@ -7690,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; @@ -7725,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); } @@ -7749,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; } @@ -7866,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)) { @@ -8024,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; } @@ -8061,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; @@ -8168,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)); @@ -8211,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); @@ -9189,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); } @@ -9722,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: @@ -9851,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; 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 43382c08b1..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 ** @@ -24,8 +22,9 @@ ** The following is the concatenation of all %include directives from the ** input grammar file: */ +#include +#include /************ Begin %include sections from the grammar ************************/ -#line 11 "sql.y" #include #include @@ -42,357 +41,12 @@ #include "parAst.h" #define YYSTACKDEPTH 0 -#line 46 "sql.c" /**************** End of %include directives **********************************/ -/* These constants specify the various numeric values for terminal symbols. -***************** Begin token definitions *************************************/ -#ifndef TK_OR -#define TK_OR 1 -#define TK_AND 2 -#define TK_UNION 3 -#define TK_ALL 4 -#define TK_MINUS 5 -#define TK_EXCEPT 6 -#define TK_INTERSECT 7 -#define TK_NK_BITAND 8 -#define TK_NK_BITOR 9 -#define TK_NK_LSHIFT 10 -#define TK_NK_RSHIFT 11 -#define TK_NK_PLUS 12 -#define TK_NK_MINUS 13 -#define TK_NK_STAR 14 -#define TK_NK_SLASH 15 -#define TK_NK_REM 16 -#define TK_NK_CONCAT 17 -#define TK_CREATE 18 -#define TK_ACCOUNT 19 -#define TK_NK_ID 20 -#define TK_PASS 21 -#define TK_NK_STRING 22 -#define TK_ALTER 23 -#define TK_PPS 24 -#define TK_TSERIES 25 -#define TK_STORAGE 26 -#define TK_STREAMS 27 -#define TK_QTIME 28 -#define TK_DBS 29 -#define TK_USERS 30 -#define TK_CONNS 31 -#define TK_STATE 32 -#define TK_NK_COMMA 33 -#define TK_HOST 34 -#define TK_USER 35 -#define TK_ENABLE 36 -#define TK_NK_INTEGER 37 -#define TK_SYSINFO 38 -#define TK_ADD 39 -#define TK_DROP 40 -#define TK_GRANT 41 -#define TK_ON 42 -#define TK_TO 43 -#define TK_REVOKE 44 -#define TK_FROM 45 -#define TK_SUBSCRIBE 46 -#define TK_READ 47 -#define TK_WRITE 48 -#define TK_NK_DOT 49 -#define TK_WITH 50 -#define TK_DNODE 51 -#define TK_PORT 52 -#define TK_DNODES 53 -#define TK_RESTORE 54 -#define TK_NK_IPTOKEN 55 -#define TK_FORCE 56 -#define TK_UNSAFE 57 -#define TK_LOCAL 58 -#define TK_QNODE 59 -#define TK_BNODE 60 -#define TK_SNODE 61 -#define TK_MNODE 62 -#define TK_VNODE 63 -#define TK_DATABASE 64 -#define TK_USE 65 -#define TK_FLUSH 66 -#define TK_TRIM 67 -#define TK_COMPACT 68 -#define TK_IF 69 -#define TK_NOT 70 -#define TK_EXISTS 71 -#define TK_BUFFER 72 -#define TK_CACHEMODEL 73 -#define TK_CACHESIZE 74 -#define TK_COMP 75 -#define TK_DURATION 76 -#define TK_NK_VARIABLE 77 -#define TK_MAXROWS 78 -#define TK_MINROWS 79 -#define TK_KEEP 80 -#define TK_PAGES 81 -#define TK_PAGESIZE 82 -#define TK_TSDB_PAGESIZE 83 -#define TK_PRECISION 84 -#define TK_REPLICA 85 -#define TK_VGROUPS 86 -#define TK_SINGLE_STABLE 87 -#define TK_RETENTIONS 88 -#define TK_SCHEMALESS 89 -#define TK_WAL_LEVEL 90 -#define TK_WAL_FSYNC_PERIOD 91 -#define TK_WAL_RETENTION_PERIOD 92 -#define TK_WAL_RETENTION_SIZE 93 -#define TK_WAL_ROLL_PERIOD 94 -#define TK_WAL_SEGMENT_SIZE 95 -#define TK_STT_TRIGGER 96 -#define TK_TABLE_PREFIX 97 -#define TK_TABLE_SUFFIX 98 -#define TK_KEEP_TIME_OFFSET 99 -#define TK_NK_COLON 100 -#define TK_BWLIMIT 101 -#define TK_START 102 -#define TK_TIMESTAMP 103 -#define TK_END 104 -#define TK_TABLE 105 -#define TK_NK_LP 106 -#define TK_NK_RP 107 -#define TK_STABLE 108 -#define TK_COLUMN 109 -#define TK_MODIFY 110 -#define TK_RENAME 111 -#define TK_TAG 112 -#define TK_SET 113 -#define TK_NK_EQ 114 -#define TK_USING 115 -#define TK_TAGS 116 -#define TK_BOOL 117 -#define TK_TINYINT 118 -#define TK_SMALLINT 119 -#define TK_INT 120 -#define TK_INTEGER 121 -#define TK_BIGINT 122 -#define TK_FLOAT 123 -#define TK_DOUBLE 124 -#define TK_BINARY 125 -#define TK_NCHAR 126 -#define TK_UNSIGNED 127 -#define TK_JSON 128 -#define TK_VARCHAR 129 -#define TK_MEDIUMBLOB 130 -#define TK_BLOB 131 -#define TK_VARBINARY 132 -#define TK_GEOMETRY 133 -#define TK_DECIMAL 134 -#define TK_COMMENT 135 -#define TK_MAX_DELAY 136 -#define TK_WATERMARK 137 -#define TK_ROLLUP 138 -#define TK_TTL 139 -#define TK_SMA 140 -#define TK_DELETE_MARK 141 -#define TK_FIRST 142 -#define TK_LAST 143 -#define TK_SHOW 144 -#define TK_PRIVILEGES 145 -#define TK_DATABASES 146 -#define TK_TABLES 147 -#define TK_STABLES 148 -#define TK_MNODES 149 -#define TK_QNODES 150 -#define TK_FUNCTIONS 151 -#define TK_INDEXES 152 -#define TK_ACCOUNTS 153 -#define TK_APPS 154 -#define TK_CONNECTIONS 155 -#define TK_LICENCES 156 -#define TK_GRANTS 157 -#define TK_QUERIES 158 -#define TK_SCORES 159 -#define TK_TOPICS 160 -#define TK_VARIABLES 161 -#define TK_CLUSTER 162 -#define TK_BNODES 163 -#define TK_SNODES 164 -#define TK_TRANSACTIONS 165 -#define TK_DISTRIBUTED 166 -#define TK_CONSUMERS 167 -#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 -#endif -/**************** End token definitions ***************************************/ +/* These constants specify the various numeric values for terminal symbols +** in a format understandable to "makeheaders". This section is blank unless +** "lemon" is run with the "-m" command-line option. +***************** Begin makeheaders token definitions *************************/ +/**************** End makeheaders token definitions ***************************/ /* The next sections is a series of control #defines. ** various aspects of the generated parser. @@ -450,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 @@ -488,18 +142,18 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 820 -#define YYNRULE 630 -#define YYNRULE_WITH_ACTION 630 -#define YYNTOKEN 345 -#define YY_MAX_SHIFT 819 -#define YY_MIN_SHIFTREDUCE 1217 -#define YY_MAX_SHIFTREDUCE 1846 -#define YY_ERROR_ACTION 1847 -#define YY_ACCEPT_ACTION 1848 -#define YY_NO_ACTION 1849 -#define YY_MIN_REDUCE 1850 -#define YY_MAX_REDUCE 2479 +#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]))) @@ -566,983 +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 */ 2089, 707, 2036, 674, 2025, 2455, 2450, 548, 2450, 2021, - /* 10 */ 549, 1893, 48, 46, 1770, 693, 2455, 668, 412, 2450, - /* 20 */ 409, 133, 1612, 1851, 673, 198, 164, 2454, 590, 2451, - /* 30 */ 675, 2451, 2453, 391, 2038, 1696, 1933, 1610, 2454, 38, - /* 40 */ 313, 2087, 2451, 2452, 123, 2299, 2281, 122, 121, 120, - /* 50 */ 119, 118, 117, 116, 115, 114, 686, 142, 1637, 689, - /* 60 */ 1639, 41, 40, 154, 1691, 47, 45, 44, 43, 42, - /* 70 */ 19, 707, 2036, 1848, 170, 123, 1862, 1618, 122, 121, - /* 80 */ 120, 119, 118, 117, 116, 115, 114, 2299, 41, 40, - /* 90 */ 67, 133, 47, 45, 44, 43, 42, 1873, 595, 2248, - /* 100 */ 1640, 723, 706, 816, 667, 706, 15, 319, 791, 790, - /* 110 */ 789, 788, 421, 1637, 787, 786, 146, 781, 780, 779, - /* 120 */ 778, 777, 776, 775, 158, 771, 770, 769, 420, 419, - /* 130 */ 766, 765, 764, 179, 178, 763, 556, 55, 2280, 549, - /* 140 */ 1893, 2318, 1698, 1699, 110, 2282, 727, 2284, 2285, 722, - /* 150 */ 2248, 717, 424, 686, 142, 634, 181, 423, 2371, 180, - /* 160 */ 1812, 2167, 405, 2367, 293, 2379, 685, 2455, 134, 684, - /* 170 */ 169, 2450, 463, 706, 1671, 1681, 402, 200, 1976, 2164, - /* 180 */ 694, 1697, 1700, 2148, 1639, 2401, 2089, 625, 51, 673, - /* 190 */ 198, 51, 62, 390, 2451, 675, 1613, 669, 1611, 62, - /* 200 */ 649, 2087, 623, 2450, 621, 262, 261, 41, 40, 62, - /* 210 */ 62, 47, 45, 44, 43, 42, 295, 515, 513, 1361, - /* 220 */ 361, 2456, 198, 266, 211, 1774, 2451, 675, 1616, 1617, - /* 230 */ 1668, 1637, 1670, 1673, 1674, 1675, 1676, 1677, 1678, 1679, - /* 240 */ 1680, 719, 715, 1689, 1690, 1692, 1693, 1694, 1695, 2, - /* 250 */ 48, 46, 1850, 686, 142, 360, 194, 1635, 409, 1363, - /* 260 */ 1612, 197, 2379, 2380, 500, 140, 2384, 518, 553, 369, - /* 270 */ 217, 1836, 517, 1696, 550, 1610, 132, 131, 130, 129, - /* 280 */ 128, 127, 126, 125, 124, 609, 608, 607, 483, 563, - /* 290 */ 519, 1257, 599, 139, 603, 485, 1581, 1582, 602, 454, - /* 300 */ 12, 453, 1691, 601, 606, 385, 384, 2013, 19, 600, - /* 310 */ 1641, 88, 596, 1725, 87, 1618, 47, 45, 44, 43, - /* 320 */ 42, 41, 40, 2281, 75, 47, 45, 44, 43, 42, - /* 330 */ 2211, 452, 52, 1259, 1262, 1263, 724, 664, 1902, 231, - /* 340 */ 295, 816, 378, 551, 15, 1900, 418, 417, 297, 2167, - /* 350 */ 41, 40, 297, 471, 47, 45, 44, 43, 42, 297, - /* 360 */ 688, 196, 2379, 2380, 2299, 140, 2384, 2165, 694, 297, - /* 370 */ 297, 1619, 1726, 233, 86, 30, 2248, 551, 723, 1900, - /* 380 */ 1698, 1699, 267, 2154, 2133, 1672, 507, 506, 505, 504, - /* 390 */ 499, 498, 497, 496, 495, 491, 490, 489, 488, 359, - /* 400 */ 480, 479, 478, 1640, 473, 472, 376, 1668, 1504, 1505, - /* 410 */ 1265, 1706, 1671, 1681, 1523, 2280, 1636, 1637, 2318, 1697, - /* 420 */ 1700, 110, 2282, 727, 2284, 2285, 722, 1637, 717, 670, - /* 430 */ 665, 658, 567, 2470, 1613, 2371, 1611, 383, 382, 405, - /* 440 */ 2367, 1669, 760, 156, 155, 757, 756, 755, 153, 1813, - /* 450 */ 2281, 1638, 37, 407, 1720, 1721, 1722, 1723, 1724, 1728, - /* 460 */ 1729, 1730, 1731, 724, 762, 1872, 1616, 1617, 1668, 2241, - /* 470 */ 1670, 1673, 1674, 1675, 1676, 1677, 1678, 1679, 1680, 719, - /* 480 */ 715, 1689, 1690, 1692, 1693, 1694, 1695, 2, 12, 48, - /* 490 */ 46, 2299, 297, 92, 1638, 192, 1282, 409, 1281, 1612, - /* 500 */ 1282, 1843, 1281, 2248, 92, 723, 1871, 2076, 381, 380, - /* 510 */ 379, 592, 1696, 138, 1610, 34, 597, 649, 2248, 2031, - /* 520 */ 2450, 41, 40, 2281, 1727, 47, 45, 44, 43, 42, - /* 530 */ 2032, 1283, 1622, 594, 1640, 1283, 689, 593, 2456, 198, - /* 540 */ 1358, 1691, 2280, 2451, 675, 2318, 564, 19, 110, 2282, - /* 550 */ 727, 2284, 2285, 722, 1618, 717, 3, 1801, 145, 2248, - /* 560 */ 151, 2342, 2371, 1618, 2299, 2012, 405, 2367, 54, 509, - /* 570 */ 1417, 1672, 144, 1452, 1453, 2342, 2248, 1870, 723, 1869, - /* 580 */ 816, 1516, 1517, 15, 1408, 752, 751, 750, 1412, 749, - /* 590 */ 1414, 1415, 748, 745, 1868, 1423, 742, 1425, 1426, 739, - /* 600 */ 736, 733, 565, 2160, 35, 1842, 661, 660, 1799, 1800, - /* 610 */ 1802, 1803, 1804, 1641, 1732, 2280, 1536, 1537, 2318, 1698, - /* 620 */ 1699, 110, 2282, 727, 2284, 2285, 722, 1669, 717, 2023, - /* 630 */ 2248, 221, 2248, 181, 762, 2371, 753, 41, 40, 405, - /* 640 */ 2367, 47, 45, 44, 43, 42, 414, 2248, 180, 2082, - /* 650 */ 2084, 1671, 1681, 508, 36, 1535, 1538, 598, 1697, 1700, - /* 660 */ 41, 40, 2402, 2089, 47, 45, 44, 43, 42, 248, - /* 670 */ 377, 773, 2147, 1613, 1936, 1611, 1372, 2089, 702, 707, - /* 680 */ 2036, 1356, 707, 2036, 375, 174, 686, 142, 1867, 545, - /* 690 */ 189, 1371, 2087, 584, 580, 576, 572, 543, 247, 202, - /* 700 */ 539, 535, 56, 1866, 265, 1616, 1617, 1668, 264, 1670, - /* 710 */ 1673, 1674, 1675, 1676, 1677, 1678, 1679, 1680, 719, 715, - /* 720 */ 1689, 1690, 1692, 1693, 1694, 1695, 2, 48, 46, 1701, - /* 730 */ 2281, 707, 2036, 102, 1612, 409, 1786, 1612, 1865, 93, - /* 740 */ 1864, 2248, 245, 724, 1641, 2409, 609, 608, 607, 1610, - /* 750 */ 1696, 460, 1610, 599, 139, 603, 2248, 520, 2029, 602, - /* 760 */ 674, 2281, 2089, 2450, 601, 606, 385, 384, 2014, 399, - /* 770 */ 600, 2299, 95, 596, 724, 364, 2422, 2087, 389, 1691, - /* 780 */ 627, 673, 198, 2248, 1861, 723, 2451, 675, 12, 1618, - /* 790 */ 10, 2248, 1618, 2248, 199, 2379, 2380, 1860, 140, 2384, - /* 800 */ 456, 147, 2299, 41, 40, 455, 2019, 47, 45, 44, - /* 810 */ 43, 42, 244, 237, 2248, 816, 723, 2040, 816, 242, - /* 820 */ 561, 49, 2280, 707, 2036, 2318, 2281, 1859, 110, 2282, - /* 830 */ 727, 2284, 2285, 722, 1376, 717, 403, 2248, 235, 721, - /* 840 */ 2470, 2258, 2371, 461, 167, 275, 405, 2367, 649, 1375, - /* 850 */ 2248, 2450, 2038, 2280, 1640, 2027, 2318, 1698, 1699, 110, - /* 860 */ 2282, 727, 2284, 2285, 722, 2262, 717, 2299, 412, 2456, - /* 870 */ 198, 2470, 154, 2371, 2451, 675, 167, 405, 2367, 2248, - /* 880 */ 2248, 723, 1637, 2386, 2038, 1858, 648, 41, 40, 1671, - /* 890 */ 1681, 47, 45, 44, 43, 42, 1697, 1700, 2011, 760, - /* 900 */ 156, 155, 757, 756, 755, 153, 272, 2264, 1613, 2383, - /* 910 */ 1611, 1613, 718, 1611, 709, 522, 2343, 717, 2280, 707, - /* 920 */ 2036, 2318, 707, 2036, 350, 2282, 727, 2284, 2285, 722, - /* 930 */ 720, 717, 708, 2336, 2454, 469, 2143, 2120, 2248, 477, - /* 940 */ 1616, 1617, 492, 1616, 1617, 1668, 1576, 1670, 1673, 1674, - /* 950 */ 1675, 1676, 1677, 1678, 1679, 1680, 719, 715, 1689, 1690, - /* 960 */ 1692, 1693, 1694, 1695, 2, 48, 46, 1793, 2281, 707, - /* 970 */ 2036, 614, 2089, 409, 1863, 1612, 2242, 415, 632, 404, - /* 980 */ 2089, 724, 1794, 656, 213, 167, 626, 2087, 1696, 493, - /* 990 */ 1610, 1857, 2089, 2038, 108, 2088, 707, 2036, 1637, 413, - /* 1000 */ 475, 2143, 263, 304, 305, 502, 2143, 2087, 303, 2299, - /* 1010 */ 193, 143, 60, 444, 2083, 2084, 566, 1691, 617, 2028, - /* 1020 */ 646, 2248, 1792, 723, 649, 611, 649, 2450, 594, 2450, - /* 1030 */ 1618, 260, 593, 760, 156, 155, 757, 756, 755, 153, - /* 1040 */ 446, 442, 9, 690, 2248, 2456, 198, 2456, 198, 215, - /* 1050 */ 2451, 675, 2451, 675, 220, 166, 816, 707, 2036, 49, - /* 1060 */ 2280, 2281, 1856, 2318, 1641, 2258, 110, 2282, 727, 2284, - /* 1070 */ 2285, 722, 71, 717, 724, 70, 2443, 2033, 2470, 2266, - /* 1080 */ 2371, 707, 2036, 1855, 405, 2367, 707, 2036, 711, 2262, - /* 1090 */ 2343, 649, 1669, 1854, 2450, 1698, 1699, 167, 487, 605, - /* 1100 */ 604, 268, 2299, 707, 2036, 2039, 276, 486, 754, 707, - /* 1110 */ 2036, 2080, 2456, 198, 2248, 2248, 723, 2451, 675, 1853, - /* 1120 */ 707, 2036, 1767, 692, 2229, 707, 2036, 1671, 1681, 308, - /* 1130 */ 758, 2264, 406, 2080, 1697, 1700, 2248, 707, 2036, 2386, - /* 1140 */ 704, 717, 14, 13, 2258, 705, 2248, 707, 2036, 1613, - /* 1150 */ 678, 1611, 1672, 2280, 785, 783, 2318, 314, 2267, 110, - /* 1160 */ 2282, 727, 2284, 2285, 722, 2382, 717, 416, 2262, 1285, - /* 1170 */ 1286, 2470, 2248, 2371, 44, 43, 42, 405, 2367, 586, - /* 1180 */ 585, 1616, 1617, 1668, 1621, 1670, 1673, 1674, 1675, 1676, - /* 1190 */ 1677, 1678, 1679, 1680, 719, 715, 1689, 1690, 1692, 1693, - /* 1200 */ 1694, 1695, 2, 48, 46, 2232, 2281, 2386, 1669, 759, - /* 1210 */ 2264, 409, 2080, 1612, 588, 587, 1878, 811, 677, 724, - /* 1220 */ 717, 2390, 328, 277, 774, 2066, 1696, 1998, 1610, 1262, - /* 1230 */ 1263, 2130, 135, 2381, 2391, 1759, 253, 255, 257, 251, - /* 1240 */ 254, 256, 259, 154, 85, 258, 681, 2299, 1739, 1920, - /* 1250 */ 1911, 629, 50, 628, 50, 1691, 431, 1909, 182, 2248, - /* 1260 */ 714, 723, 1845, 1846, 2269, 1759, 1977, 96, 1618, 154, - /* 1270 */ 1316, 610, 612, 467, 50, 302, 72, 152, 1903, 615, - /* 1280 */ 2415, 154, 107, 14, 13, 65, 50, 50, 731, 152, - /* 1290 */ 767, 104, 290, 154, 816, 136, 152, 15, 2280, 2281, - /* 1300 */ 768, 2318, 1620, 137, 110, 2282, 727, 2284, 2285, 722, - /* 1310 */ 1317, 717, 724, 284, 1335, 662, 2470, 1579, 2371, 418, - /* 1320 */ 417, 2271, 405, 2367, 1333, 2300, 1798, 1974, 1797, 1626, - /* 1330 */ 809, 1973, 282, 1698, 1699, 2152, 2405, 659, 392, 422, - /* 1340 */ 2299, 395, 1696, 691, 1619, 1624, 204, 666, 1533, 306, - /* 1350 */ 699, 310, 2248, 696, 723, 1402, 2153, 1894, 1899, 1733, - /* 1360 */ 1682, 327, 1430, 1434, 2077, 1671, 1681, 1441, 687, 1439, - /* 1370 */ 157, 1691, 1697, 1700, 2406, 2416, 292, 289, 296, 5, - /* 1380 */ 425, 430, 373, 438, 1618, 439, 1766, 1613, 1644, 1611, - /* 1390 */ 448, 2280, 447, 206, 2318, 208, 205, 110, 2282, 727, - /* 1400 */ 2284, 2285, 722, 450, 717, 1557, 679, 322, 464, 2346, - /* 1410 */ 713, 2371, 1635, 1636, 468, 405, 2367, 219, 1717, 1616, - /* 1420 */ 1617, 1668, 470, 1670, 1673, 1674, 1675, 1676, 1677, 1678, - /* 1430 */ 1679, 1680, 719, 715, 1689, 1690, 1692, 1693, 1694, 1695, - /* 1440 */ 2, 474, 168, 476, 511, 481, 494, 335, 501, 2145, - /* 1450 */ 503, 510, 512, 523, 524, 521, 223, 224, 526, 527, - /* 1460 */ 226, 529, 531, 1623, 332, 74, 1642, 546, 73, 4, - /* 1470 */ 557, 1638, 547, 555, 554, 234, 558, 236, 357, 1643, - /* 1480 */ 1645, 559, 560, 1646, 2281, 562, 2161, 589, 591, 229, - /* 1490 */ 530, 528, 525, 2026, 239, 241, 250, 724, 568, 90, - /* 1500 */ 91, 246, 618, 1627, 682, 1622, 112, 619, 354, 631, - /* 1510 */ 2220, 2022, 2217, 2216, 633, 94, 269, 323, 148, 637, - /* 1520 */ 636, 273, 1564, 638, 252, 2299, 160, 271, 161, 2024, - /* 1530 */ 62, 2020, 162, 163, 642, 1630, 1632, 2248, 644, 723, - /* 1540 */ 663, 2421, 697, 2420, 283, 8, 672, 2393, 641, 715, - /* 1550 */ 1689, 1690, 1692, 1693, 1694, 1695, 654, 175, 653, 285, - /* 1560 */ 652, 651, 396, 683, 2449, 2473, 286, 680, 63, 279, - /* 1570 */ 1759, 281, 287, 643, 291, 141, 2280, 1639, 288, 2318, - /* 1580 */ 1764, 1762, 110, 2282, 727, 2284, 2285, 722, 185, 717, - /* 1590 */ 298, 149, 324, 695, 2344, 2175, 2371, 2174, 2173, 325, - /* 1600 */ 405, 2367, 401, 2387, 700, 150, 101, 326, 701, 61, - /* 1610 */ 103, 729, 83, 82, 459, 1241, 1999, 210, 2081, 2037, - /* 1620 */ 810, 353, 813, 53, 365, 2240, 2352, 815, 329, 366, - /* 1630 */ 451, 449, 333, 317, 159, 2239, 2238, 80, 201, 1, - /* 1640 */ 2233, 358, 338, 2281, 440, 427, 1603, 437, 433, 429, - /* 1650 */ 426, 452, 331, 428, 1604, 203, 724, 432, 2231, 352, - /* 1660 */ 434, 435, 436, 1602, 342, 2230, 374, 2228, 441, 2281, - /* 1670 */ 2227, 443, 2226, 1592, 445, 2207, 207, 2206, 209, 1560, - /* 1680 */ 81, 2188, 724, 1559, 2299, 2187, 2186, 457, 458, 2185, - /* 1690 */ 297, 2184, 2135, 2129, 462, 1503, 2248, 465, 723, 466, - /* 1700 */ 2126, 212, 2125, 2124, 84, 2123, 2128, 2127, 2122, 2121, - /* 1710 */ 2299, 214, 2119, 2118, 2117, 216, 482, 2116, 2132, 484, - /* 1720 */ 2115, 2114, 2248, 2113, 723, 2112, 2111, 2110, 2109, 2108, - /* 1730 */ 2107, 2106, 2105, 2104, 2103, 2280, 2281, 218, 2318, 2102, - /* 1740 */ 2101, 110, 2282, 727, 2284, 2285, 722, 2100, 717, 724, - /* 1750 */ 2099, 2098, 2097, 710, 2131, 2371, 2096, 2095, 1509, 405, - /* 1760 */ 2367, 2280, 2094, 222, 2318, 2281, 2093, 111, 2282, 727, - /* 1770 */ 2284, 2285, 722, 514, 717, 2092, 2091, 2299, 724, 516, - /* 1780 */ 89, 2371, 2090, 1373, 1939, 2370, 2367, 1377, 362, 2248, - /* 1790 */ 1369, 723, 363, 1938, 1937, 1935, 1932, 532, 1931, 533, - /* 1800 */ 534, 536, 1924, 1913, 1889, 225, 2299, 227, 228, 538, - /* 1810 */ 537, 540, 542, 230, 541, 544, 190, 1888, 2248, 77, - /* 1820 */ 723, 2268, 191, 1264, 232, 2205, 2195, 78, 2280, 552, - /* 1830 */ 2183, 2318, 238, 2281, 111, 2282, 727, 2284, 2285, 722, - /* 1840 */ 240, 717, 2182, 2159, 2015, 1934, 724, 1930, 2371, 243, - /* 1850 */ 1309, 569, 712, 2367, 571, 635, 570, 725, 1928, 573, - /* 1860 */ 2318, 574, 575, 111, 2282, 727, 2284, 2285, 722, 1926, - /* 1870 */ 717, 579, 577, 819, 2299, 578, 1923, 2371, 581, 582, - /* 1880 */ 583, 368, 2367, 1908, 1906, 1907, 2248, 1905, 723, 321, - /* 1890 */ 1885, 2017, 1446, 1445, 2016, 782, 1360, 1359, 2281, 249, - /* 1900 */ 64, 1357, 1355, 1354, 1353, 188, 784, 1352, 1346, 1351, - /* 1910 */ 1921, 724, 1348, 807, 803, 799, 795, 2281, 318, 1347, - /* 1920 */ 386, 1912, 387, 1910, 388, 2280, 1345, 613, 2318, 616, - /* 1930 */ 724, 171, 2282, 727, 2284, 2285, 722, 1884, 717, 2299, - /* 1940 */ 620, 1881, 622, 1880, 624, 113, 1586, 1590, 1588, 1585, - /* 1950 */ 2204, 2248, 1883, 723, 1882, 29, 68, 1566, 2299, 109, - /* 1960 */ 1568, 2194, 311, 2181, 57, 640, 639, 2180, 165, 2455, - /* 1970 */ 2248, 66, 723, 650, 2412, 1545, 274, 6, 20, 7, - /* 1980 */ 21, 17, 1544, 31, 645, 1815, 278, 23, 280, 22, - /* 1990 */ 2280, 647, 2281, 2318, 703, 1570, 172, 2282, 727, 2284, - /* 2000 */ 2285, 722, 1796, 717, 1785, 724, 184, 173, 655, 2280, - /* 2010 */ 657, 195, 2318, 183, 2269, 111, 2282, 727, 2284, 2285, - /* 2020 */ 722, 32, 717, 79, 33, 24, 1835, 1830, 294, 2371, - /* 2030 */ 1829, 1836, 300, 2299, 2368, 397, 1834, 1833, 398, 299, - /* 2040 */ 1756, 1755, 18, 59, 176, 2248, 98, 723, 2179, 2158, - /* 2050 */ 676, 2471, 97, 2157, 25, 58, 301, 186, 270, 2281, - /* 2060 */ 1791, 307, 99, 69, 100, 312, 26, 11, 698, 13, - /* 2070 */ 2321, 309, 724, 1708, 104, 1707, 1628, 1686, 716, 1718, - /* 2080 */ 177, 1684, 39, 16, 2280, 2281, 27, 2318, 1683, 187, - /* 2090 */ 171, 2282, 727, 2284, 2285, 722, 1653, 717, 724, 1661, - /* 2100 */ 2299, 728, 28, 730, 1431, 393, 411, 734, 732, 735, - /* 2110 */ 726, 737, 2248, 1428, 723, 1427, 1424, 738, 740, 741, - /* 2120 */ 743, 1418, 1416, 744, 746, 747, 2299, 105, 315, 106, - /* 2130 */ 1440, 394, 1422, 2413, 1421, 76, 1436, 1342, 2248, 1420, - /* 2140 */ 723, 1339, 1307, 1338, 1337, 1419, 761, 1336, 1334, 1332, - /* 2150 */ 1331, 2280, 1330, 316, 2318, 2281, 1367, 351, 2282, 727, - /* 2160 */ 2284, 2285, 722, 772, 717, 1328, 1327, 1326, 724, 1325, - /* 2170 */ 1324, 1323, 1322, 1364, 1362, 1319, 1313, 2280, 1318, 1315, - /* 2180 */ 2318, 1314, 2281, 351, 2282, 727, 2284, 2285, 722, 1312, - /* 2190 */ 717, 1929, 792, 794, 793, 724, 2299, 1927, 796, 797, - /* 2200 */ 798, 1925, 800, 1922, 801, 802, 804, 1904, 2248, 806, - /* 2210 */ 723, 805, 808, 1254, 1879, 1242, 812, 320, 1614, 814, - /* 2220 */ 818, 330, 1849, 2299, 1849, 817, 1849, 1849, 1849, 1849, - /* 2230 */ 1849, 1849, 1849, 1849, 1849, 2248, 1849, 723, 1849, 1849, - /* 2240 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 2280, 1849, 1849, - /* 2250 */ 2318, 1849, 1849, 344, 2282, 727, 2284, 2285, 722, 1849, - /* 2260 */ 717, 1849, 1849, 1849, 1849, 1849, 2281, 1849, 1849, 1849, - /* 2270 */ 1849, 1849, 1849, 1849, 2280, 1849, 1849, 2318, 1849, 724, - /* 2280 */ 172, 2282, 727, 2284, 2285, 722, 1849, 717, 2281, 1849, - /* 2290 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 671, - /* 2300 */ 1849, 721, 1849, 1849, 1849, 1849, 1849, 2299, 1849, 1849, - /* 2310 */ 1849, 1849, 400, 1849, 1849, 1849, 1849, 1849, 1849, 2248, - /* 2320 */ 1849, 723, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 2299, - /* 2330 */ 1849, 1849, 1849, 1849, 1849, 2472, 1849, 1849, 1849, 1849, - /* 2340 */ 1849, 2248, 1849, 723, 1849, 1849, 1849, 1849, 1849, 1849, - /* 2350 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 2280, 1849, - /* 2360 */ 1849, 2318, 1849, 1849, 351, 2282, 727, 2284, 2285, 722, - /* 2370 */ 1849, 717, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 2380 */ 2280, 1849, 1849, 2318, 1849, 1849, 350, 2282, 727, 2284, - /* 2390 */ 2285, 722, 1849, 717, 2281, 2337, 1849, 1849, 1849, 1849, - /* 2400 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 724, 1849, 1849, - /* 2410 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 2420 */ 1849, 2281, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 2430 */ 1849, 1849, 1849, 1849, 724, 2299, 1849, 1849, 1849, 1849, - /* 2440 */ 408, 1849, 1849, 1849, 1849, 1849, 1849, 2248, 1849, 723, - /* 2450 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 2460 */ 1849, 1849, 2299, 1849, 1849, 1849, 1849, 410, 1849, 1849, - /* 2470 */ 1849, 1849, 1849, 1849, 2248, 1849, 723, 1849, 1849, 1849, - /* 2480 */ 1849, 1849, 1849, 1849, 1849, 1849, 2280, 2281, 1849, 2318, - /* 2490 */ 1849, 1849, 351, 2282, 727, 2284, 2285, 722, 1849, 717, - /* 2500 */ 724, 1849, 1849, 1849, 2281, 1849, 1849, 1849, 1849, 1849, - /* 2510 */ 1849, 1849, 1849, 2280, 1849, 1849, 2318, 724, 1849, 351, - /* 2520 */ 2282, 727, 2284, 2285, 722, 1849, 717, 1849, 2299, 1849, - /* 2530 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 2540 */ 2248, 1849, 723, 1849, 1849, 2299, 1849, 1849, 1849, 1849, - /* 2550 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 2248, 1849, 723, - /* 2560 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 2570 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 630, - /* 2580 */ 1849, 1849, 2318, 1849, 2281, 346, 2282, 727, 2284, 2285, - /* 2590 */ 722, 1849, 717, 1849, 1849, 1849, 2280, 724, 1849, 2318, - /* 2600 */ 1849, 1849, 336, 2282, 727, 2284, 2285, 722, 1849, 717, - /* 2610 */ 1849, 1849, 1849, 1849, 1849, 2281, 1849, 1849, 1849, 1849, - /* 2620 */ 1849, 1849, 1849, 1849, 1849, 2299, 1849, 1849, 724, 1849, - /* 2630 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 2248, 1849, 723, - /* 2640 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 2650 */ 2281, 1849, 1849, 1849, 1849, 1849, 2299, 1849, 1849, 1849, - /* 2660 */ 1849, 1849, 1849, 724, 1849, 1849, 1849, 1849, 2248, 1849, - /* 2670 */ 723, 1849, 1849, 1849, 1849, 1849, 2280, 1849, 1849, 2318, - /* 2680 */ 1849, 1849, 334, 2282, 727, 2284, 2285, 722, 1849, 717, - /* 2690 */ 1849, 2299, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 2700 */ 1849, 1849, 1849, 2248, 1849, 723, 1849, 2280, 1849, 1849, - /* 2710 */ 2318, 1849, 1849, 337, 2282, 727, 2284, 2285, 722, 1849, - /* 2720 */ 717, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 2730 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 2740 */ 1849, 1849, 2280, 2281, 1849, 2318, 1849, 1849, 343, 2282, - /* 2750 */ 727, 2284, 2285, 722, 1849, 717, 724, 1849, 1849, 1849, - /* 2760 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 2770 */ 2281, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 2780 */ 1849, 1849, 1849, 724, 2299, 1849, 1849, 1849, 1849, 1849, - /* 2790 */ 1849, 1849, 1849, 1849, 1849, 1849, 2248, 1849, 723, 1849, - /* 2800 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 2810 */ 1849, 2299, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 2820 */ 1849, 1849, 1849, 2248, 1849, 723, 1849, 1849, 1849, 1849, - /* 2830 */ 1849, 1849, 1849, 1849, 1849, 2280, 2281, 1849, 2318, 1849, - /* 2840 */ 1849, 347, 2282, 727, 2284, 2285, 722, 1849, 717, 724, - /* 2850 */ 1849, 1849, 1849, 2281, 1849, 1849, 1849, 1849, 1849, 1849, - /* 2860 */ 1849, 1849, 2280, 1849, 1849, 2318, 724, 1849, 339, 2282, - /* 2870 */ 727, 2284, 2285, 722, 1849, 717, 1849, 2299, 1849, 1849, - /* 2880 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 2248, - /* 2890 */ 1849, 723, 1849, 1849, 2299, 1849, 1849, 1849, 1849, 1849, - /* 2900 */ 1849, 1849, 1849, 1849, 1849, 1849, 2248, 1849, 723, 1849, - /* 2910 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 2920 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 2280, 1849, - /* 2930 */ 1849, 2318, 1849, 2281, 348, 2282, 727, 2284, 2285, 722, - /* 2940 */ 1849, 717, 1849, 1849, 1849, 2280, 724, 1849, 2318, 1849, - /* 2950 */ 1849, 340, 2282, 727, 2284, 2285, 722, 1849, 717, 1849, - /* 2960 */ 1849, 1849, 1849, 1849, 2281, 1849, 1849, 1849, 1849, 1849, - /* 2970 */ 1849, 1849, 1849, 1849, 2299, 1849, 1849, 724, 1849, 1849, - /* 2980 */ 1849, 1849, 1849, 1849, 1849, 1849, 2248, 1849, 723, 1849, - /* 2990 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 2281, - /* 3000 */ 1849, 1849, 1849, 1849, 1849, 2299, 1849, 1849, 1849, 1849, - /* 3010 */ 1849, 1849, 724, 1849, 1849, 1849, 1849, 2248, 1849, 723, - /* 3020 */ 1849, 1849, 1849, 1849, 1849, 2280, 1849, 1849, 2318, 1849, - /* 3030 */ 1849, 349, 2282, 727, 2284, 2285, 722, 1849, 717, 1849, - /* 3040 */ 2299, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3050 */ 1849, 1849, 2248, 1849, 723, 1849, 2280, 1849, 1849, 2318, - /* 3060 */ 1849, 1849, 341, 2282, 727, 2284, 2285, 722, 1849, 717, - /* 3070 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3080 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3090 */ 1849, 2280, 2281, 1849, 2318, 1849, 1849, 355, 2282, 727, - /* 3100 */ 2284, 2285, 722, 1849, 717, 724, 1849, 1849, 1849, 1849, - /* 3110 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 2281, - /* 3120 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3130 */ 1849, 1849, 724, 2299, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3140 */ 1849, 1849, 1849, 1849, 1849, 2248, 1849, 723, 1849, 1849, - /* 3150 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3160 */ 2299, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3170 */ 1849, 1849, 2248, 1849, 723, 1849, 1849, 1849, 1849, 1849, - /* 3180 */ 1849, 1849, 1849, 1849, 2280, 2281, 1849, 2318, 1849, 1849, - /* 3190 */ 356, 2282, 727, 2284, 2285, 722, 1849, 717, 724, 1849, - /* 3200 */ 1849, 1849, 2281, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3210 */ 1849, 2280, 1849, 1849, 2318, 724, 1849, 2293, 2282, 727, - /* 3220 */ 2284, 2285, 722, 1849, 717, 1849, 2299, 1849, 1849, 1849, - /* 3230 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 2248, 1849, - /* 3240 */ 723, 1849, 1849, 2299, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3250 */ 1849, 1849, 1849, 1849, 1849, 2248, 1849, 723, 1849, 1849, - /* 3260 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3270 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 2280, 1849, 1849, - /* 3280 */ 2318, 1849, 2281, 2292, 2282, 727, 2284, 2285, 722, 1849, - /* 3290 */ 717, 1849, 1849, 1849, 2280, 724, 1849, 2318, 1849, 1849, - /* 3300 */ 2291, 2282, 727, 2284, 2285, 722, 1849, 717, 1849, 1849, - /* 3310 */ 1849, 1849, 1849, 2281, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3320 */ 1849, 1849, 1849, 2299, 1849, 1849, 724, 1849, 1849, 1849, - /* 3330 */ 1849, 1849, 1849, 1849, 1849, 2248, 1849, 723, 1849, 1849, - /* 3340 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 2281, 1849, - /* 3350 */ 1849, 1849, 1849, 1849, 2299, 1849, 1849, 1849, 1849, 1849, - /* 3360 */ 1849, 724, 1849, 1849, 1849, 1849, 2248, 1849, 723, 1849, - /* 3370 */ 1849, 1849, 1849, 1849, 2280, 1849, 1849, 2318, 1849, 1849, - /* 3380 */ 370, 2282, 727, 2284, 2285, 722, 1849, 717, 1849, 2299, - /* 3390 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3400 */ 1849, 2248, 1849, 723, 1849, 2280, 1849, 1849, 2318, 1849, - /* 3410 */ 1849, 371, 2282, 727, 2284, 2285, 722, 1849, 717, 1849, - /* 3420 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3430 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3440 */ 2280, 2281, 1849, 2318, 1849, 1849, 367, 2282, 727, 2284, - /* 3450 */ 2285, 722, 1849, 717, 724, 1849, 1849, 1849, 1849, 1849, - /* 3460 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 2281, 1849, - /* 3470 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3480 */ 1849, 724, 2299, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3490 */ 1849, 1849, 1849, 1849, 2248, 1849, 723, 1849, 1849, 1849, - /* 3500 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 2299, - /* 3510 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3520 */ 1849, 2248, 1849, 723, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3530 */ 1849, 1849, 1849, 2280, 2281, 1849, 2318, 1849, 1849, 372, - /* 3540 */ 2282, 727, 2284, 2285, 722, 1849, 717, 724, 1849, 1849, - /* 3550 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3560 */ 725, 1849, 1849, 2318, 1849, 1849, 346, 2282, 727, 2284, - /* 3570 */ 2285, 722, 1849, 717, 1849, 2299, 1849, 1849, 1849, 1849, - /* 3580 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 2248, 1849, 723, - /* 3590 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3600 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3610 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3620 */ 1849, 1849, 1849, 1849, 1849, 1849, 2280, 1849, 1849, 2318, - /* 3630 */ 1849, 1849, 345, 2282, 727, 2284, 2285, 722, 1849, 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, 116, 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, 20, - /* 290 */ 53, 4, 79, 80, 81, 58, 209, 210, 85, 195, - /* 300 */ 250, 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, 69, 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, 369, 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 */ 395, 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, 33, 228, 456, 401, - /* 560 */ 458, 459, 460, 77, 389, 0, 464, 465, 45, 86, - /* 570 */ 103, 174, 456, 142, 143, 459, 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, 77, 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, 390, 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, 389, 161, 374, - /* 1100 */ 375, 380, 389, 360, 361, 397, 380, 170, 398, 360, - /* 1110 */ 361, 401, 493, 494, 401, 401, 403, 498, 499, 348, - /* 1120 */ 360, 361, 4, 380, 0, 360, 361, 174, 175, 380, - /* 1130 */ 398, 443, 444, 401, 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, 37, 232, 233, 234, 235, 236, - /* 1190 */ 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, - /* 1200 */ 247, 248, 249, 12, 13, 0, 348, 445, 230, 398, - /* 1210 */ 443, 20, 401, 22, 365, 366, 351, 352, 287, 361, - /* 1220 */ 453, 363, 382, 64, 376, 385, 35, 379, 37, 47, - /* 1230 */ 48, 0, 33, 471, 264, 265, 109, 109, 109, 112, - /* 1240 */ 112, 112, 109, 33, 45, 112, 33, 389, 107, 0, - /* 1250 */ 0, 212, 33, 214, 33, 64, 51, 0, 33, 401, - /* 1260 */ 70, 403, 142, 143, 49, 265, 378, 108, 77, 33, - /* 1270 */ 37, 22, 22, 42, 33, 33, 33, 33, 0, 22, - /* 1280 */ 414, 33, 106, 1, 2, 33, 33, 33, 33, 33, - /* 1290 */ 13, 115, 502, 33, 103, 33, 33, 106, 440, 348, - /* 1300 */ 13, 443, 37, 364, 446, 447, 448, 449, 450, 451, - /* 1310 */ 77, 453, 361, 484, 37, 491, 458, 107, 460, 12, - /* 1320 */ 13, 106, 464, 465, 37, 389, 107, 377, 107, 22, - /* 1330 */ 52, 377, 107, 142, 143, 414, 414, 490, 423, 364, - /* 1340 */ 389, 490, 35, 107, 37, 198, 222, 490, 107, 107, - /* 1350 */ 107, 107, 401, 490, 403, 107, 414, 359, 361, 107, - /* 1360 */ 107, 107, 107, 107, 400, 174, 175, 107, 474, 107, - /* 1370 */ 107, 64, 181, 182, 414, 414, 495, 466, 477, 269, - /* 1380 */ 425, 51, 442, 42, 77, 441, 268, 196, 20, 198, - /* 1390 */ 434, 440, 211, 369, 443, 369, 439, 446, 447, 448, - /* 1400 */ 449, 450, 451, 434, 453, 194, 289, 427, 360, 458, - /* 1410 */ 103, 460, 20, 20, 361, 464, 465, 45, 228, 228, - /* 1420 */ 229, 230, 410, 232, 233, 234, 235, 236, 237, 238, - /* 1430 */ 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, - /* 1440 */ 249, 361, 18, 410, 173, 407, 360, 23, 361, 360, - /* 1450 */ 410, 407, 407, 104, 373, 102, 372, 360, 101, 371, - /* 1460 */ 360, 360, 360, 198, 40, 41, 20, 353, 44, 50, - /* 1470 */ 434, 20, 357, 357, 353, 369, 403, 369, 54, 20, - /* 1480 */ 20, 362, 426, 20, 348, 362, 417, 353, 389, 65, - /* 1490 */ 66, 67, 68, 389, 369, 369, 389, 361, 360, 369, - /* 1500 */ 369, 369, 351, 196, 291, 198, 360, 351, 353, 215, - /* 1510 */ 401, 389, 401, 401, 438, 106, 367, 434, 436, 202, - /* 1520 */ 201, 367, 200, 433, 389, 389, 389, 432, 389, 389, - /* 1530 */ 106, 389, 389, 389, 431, 228, 229, 401, 360, 403, - /* 1540 */ 276, 483, 275, 483, 485, 284, 187, 486, 403, 242, - /* 1550 */ 243, 244, 245, 246, 247, 248, 286, 483, 401, 482, - /* 1560 */ 285, 270, 293, 290, 497, 503, 481, 288, 144, 419, - /* 1570 */ 265, 419, 480, 425, 496, 361, 440, 20, 425, 443, - /* 1580 */ 116, 267, 446, 447, 448, 449, 450, 451, 362, 453, - /* 1590 */ 367, 367, 419, 401, 458, 401, 460, 401, 401, 419, - /* 1600 */ 464, 465, 401, 445, 179, 367, 367, 385, 415, 106, - /* 1610 */ 106, 393, 188, 189, 190, 22, 379, 193, 401, 361, - /* 1620 */ 38, 435, 350, 428, 420, 0, 463, 353, 360, 420, - /* 1630 */ 206, 207, 346, 367, 354, 0, 0, 45, 476, 478, - /* 1640 */ 0, 217, 383, 348, 220, 37, 37, 223, 224, 225, - /* 1650 */ 226, 227, 368, 221, 37, 37, 361, 221, 0, 383, - /* 1660 */ 37, 37, 221, 37, 383, 0, 221, 0, 37, 348, - /* 1670 */ 0, 22, 0, 216, 37, 0, 204, 0, 204, 198, - /* 1680 */ 205, 0, 361, 196, 389, 0, 0, 192, 191, 0, - /* 1690 */ 266, 0, 147, 0, 49, 49, 401, 37, 403, 51, - /* 1700 */ 0, 49, 0, 0, 45, 0, 0, 0, 0, 0, - /* 1710 */ 389, 49, 0, 0, 0, 161, 37, 0, 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, 0, 22, 464, - /* 1760 */ 465, 440, 0, 147, 443, 348, 0, 446, 447, 448, - /* 1770 */ 449, 450, 451, 146, 453, 0, 0, 389, 361, 145, - /* 1780 */ 45, 460, 0, 22, 0, 464, 465, 22, 50, 401, - /* 1790 */ 37, 403, 50, 0, 0, 0, 0, 37, 0, 51, - /* 1800 */ 42, 37, 0, 0, 0, 64, 389, 64, 64, 42, - /* 1810 */ 51, 37, 42, 45, 51, 37, 33, 0, 401, 42, - /* 1820 */ 403, 49, 49, 14, 43, 0, 0, 42, 440, 49, - /* 1830 */ 0, 443, 42, 348, 446, 447, 448, 449, 450, 451, - /* 1840 */ 187, 453, 0, 0, 0, 0, 361, 0, 460, 49, - /* 1850 */ 71, 37, 464, 465, 42, 1, 51, 440, 0, 37, - /* 1860 */ 443, 51, 42, 446, 447, 448, 449, 450, 451, 0, - /* 1870 */ 453, 42, 37, 19, 389, 51, 0, 460, 37, 51, - /* 1880 */ 42, 464, 465, 0, 0, 0, 401, 0, 403, 35, - /* 1890 */ 0, 0, 37, 22, 0, 33, 37, 37, 348, 112, - /* 1900 */ 114, 37, 37, 37, 37, 51, 33, 37, 22, 37, - /* 1910 */ 0, 361, 37, 59, 60, 61, 62, 348, 64, 37, - /* 1920 */ 22, 0, 22, 0, 22, 440, 37, 53, 443, 37, - /* 1930 */ 361, 446, 447, 448, 449, 450, 451, 0, 453, 389, - /* 1940 */ 37, 0, 37, 0, 22, 20, 37, 107, 37, 37, - /* 1950 */ 0, 401, 0, 403, 0, 106, 106, 37, 389, 105, - /* 1960 */ 22, 0, 108, 0, 176, 176, 22, 0, 199, 3, - /* 1970 */ 401, 3, 403, 488, 489, 176, 179, 50, 33, 50, - /* 1980 */ 33, 271, 176, 106, 183, 107, 106, 271, 107, 33, - /* 1990 */ 440, 183, 348, 443, 140, 203, 446, 447, 448, 449, - /* 2000 */ 450, 451, 107, 453, 107, 361, 33, 106, 104, 440, - /* 2010 */ 102, 49, 443, 106, 49, 446, 447, 448, 449, 450, - /* 2020 */ 451, 106, 453, 106, 33, 33, 107, 37, 49, 460, - /* 2030 */ 37, 107, 178, 389, 465, 37, 37, 37, 37, 185, - /* 2040 */ 107, 107, 271, 33, 49, 401, 42, 403, 0, 0, - /* 2050 */ 500, 501, 106, 0, 106, 264, 107, 106, 204, 348, - /* 2060 */ 107, 106, 42, 106, 106, 49, 33, 251, 180, 2, - /* 2070 */ 106, 178, 361, 104, 115, 104, 22, 107, 106, 228, - /* 2080 */ 49, 107, 106, 106, 440, 348, 106, 443, 107, 49, - /* 2090 */ 446, 447, 448, 449, 450, 451, 107, 453, 361, 22, - /* 2100 */ 389, 116, 106, 37, 107, 394, 37, 37, 106, 106, - /* 2110 */ 231, 37, 401, 107, 403, 107, 107, 106, 37, 106, - /* 2120 */ 37, 107, 107, 106, 37, 106, 389, 106, 33, 106, - /* 2130 */ 37, 394, 127, 489, 127, 106, 22, 37, 401, 127, - /* 2140 */ 403, 37, 71, 37, 37, 127, 70, 37, 37, 37, - /* 2150 */ 37, 440, 37, 33, 443, 348, 77, 446, 447, 448, - /* 2160 */ 449, 450, 451, 100, 453, 37, 37, 37, 361, 22, - /* 2170 */ 37, 37, 37, 77, 37, 37, 22, 440, 37, 37, - /* 2180 */ 443, 37, 348, 446, 447, 448, 449, 450, 451, 37, - /* 2190 */ 453, 0, 37, 42, 51, 361, 389, 0, 37, 51, - /* 2200 */ 42, 0, 37, 0, 51, 42, 37, 0, 401, 42, - /* 2210 */ 403, 51, 37, 37, 0, 22, 33, 22, 22, 21, - /* 2220 */ 20, 22, 504, 389, 504, 21, 504, 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 (819) +#define YY_SHIFT_COUNT (834) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (2214) +#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 */ 153, 153, 474, 287, 287, 407, 431, 254, 254, 177, - /* 80 */ 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, - /* 90 */ 269, 153, 153, 363, 38, 153, 153, 38, 153, 153, - /* 100 */ 38, 153, 153, 38, 153, 38, 38, 38, 153, 395, - /* 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, 182, 363, 39, 38, - /* 150 */ 38, 50, 38, 486, 38, 486, 486, 520, 594, 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 */ 1182, 396, 893, 383, 383, 862, 970, 1000, 931, 970, - /* 200 */ 523, 1118, 1110, 1330, 1341, 1368, 1181, 363, 1368, 363, - /* 210 */ 1211, 1392, 1393, 1372, 1393, 1372, 1271, 1392, 1393, 1392, - /* 220 */ 1372, 1271, 1271, 1349, 1353, 1392, 1357, 1392, 1392, 1392, - /* 230 */ 1446, 1419, 1446, 1419, 1368, 363, 1451, 363, 1459, 1460, - /* 240 */ 363, 1459, 363, 1463, 363, 363, 1392, 363, 1446, 38, - /* 250 */ 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, - /* 260 */ 1392, 73, 73, 1446, 486, 486, 486, 1294, 1409, 1368, - /* 270 */ 395, 1317, 1319, 1451, 395, 1322, 1110, 1392, 486, 1264, - /* 280 */ 1267, 1264, 1267, 1261, 1359, 1264, 1270, 1275, 1291, 1110, - /* 290 */ 1269, 1273, 1279, 1305, 1393, 1557, 1464, 1314, 1459, 395, - /* 300 */ 395, 1267, 486, 486, 486, 486, 1267, 486, 1425, 395, - /* 310 */ 520, 395, 1393, 1503, 1504, 486, 594, 1392, 395, 1593, - /* 320 */ 1582, 1446, 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, 1205, 1124, 30, 1231, 1199, 208, 768, - /* 380 */ 1127, 1128, 1129, 1133, 503, 644, 1249, 1250, 1257, 1039, - /* 390 */ 839, 1210, 1159, 1219, 1221, 1225, 1120, 1117, 1213, 1236, - /* 400 */ 1241, 1242, 1243, 1244, 1248, 1282, 1252, 1190, 1253, 1215, - /* 410 */ 1254, 1255, 1256, 1260, 1262, 1263, 1176, 1147, 1265, 1277, - /* 420 */ 1287, 1233, 1278, 1625, 1635, 1636, 1592, 1640, 1608, 1432, - /* 430 */ 1609, 1617, 1618, 1436, 1658, 1623, 1624, 1441, 1626, 1665, - /* 440 */ 1445, 1667, 1631, 1670, 1649, 1672, 1637, 1457, 1675, 1472, - /* 450 */ 1677, 1474, 1475, 1481, 1487, 1681, 1685, 1686, 1495, 1497, - /* 460 */ 1689, 1691, 1545, 1645, 1646, 1693, 1660, 1648, 1700, 1652, - /* 470 */ 1702, 1659, 1703, 1705, 1706, 1662, 1707, 1708, 1709, 1712, - /* 480 */ 1713, 1714, 1554, 1679, 1717, 1558, 1718, 1720, 1721, 1723, - /* 490 */ 1725, 1726, 1727, 1728, 1729, 1730, 1731, 1732, 1733, 1734, - /* 500 */ 1739, 1740, 1688, 1747, 1735, 1750, 1751, 1752, 1754, 1756, - /* 510 */ 1757, 1736, 1762, 1616, 1766, 1627, 1775, 1634, 1776, 1782, - /* 520 */ 1761, 1738, 1765, 1742, 1784, 1741, 1753, 1793, 1743, 1794, - /* 530 */ 1744, 1795, 1796, 1760, 1748, 1758, 1798, 1764, 1759, 1767, - /* 540 */ 1802, 1774, 1763, 1770, 1803, 1778, 1804, 1768, 1777, 1783, - /* 550 */ 1772, 1773, 1809, 1780, 1817, 1781, 1785, 1825, 1826, 1830, - /* 560 */ 1790, 1653, 1842, 1772, 1800, 1843, 1844, 1779, 1845, 1847, - /* 570 */ 1814, 1805, 1812, 1858, 1822, 1810, 1820, 1869, 1835, 1824, - /* 580 */ 1829, 1876, 1841, 1828, 1838, 1883, 1884, 1885, 1887, 1890, - /* 590 */ 1891, 1786, 1787, 1855, 1871, 1894, 1859, 1860, 1864, 1865, - /* 600 */ 1866, 1867, 1870, 1872, 1862, 1873, 1875, 1882, 1886, 1889, - /* 610 */ 1910, 1898, 1921, 1900, 1874, 1923, 1902, 1892, 1937, 1952, - /* 620 */ 1954, 1903, 1941, 1905, 1943, 1922, 1925, 1909, 1911, 1912, - /* 630 */ 1840, 1849, 1950, 1788, 1850, 1792, 1920, 1938, 1961, 1769, - /* 640 */ 1944, 1789, 1797, 1963, 1967, 1799, 1801, 1806, 1808, 1966, - /* 650 */ 1945, 1710, 1877, 1878, 1880, 1927, 1904, 1929, 1908, 1881, - /* 660 */ 1947, 1956, 1895, 1901, 1907, 1915, 1897, 1973, 1962, 1965, - /* 670 */ 1917, 1991, 1716, 1919, 1924, 1968, 1992, 1771, 1990, 1993, - /* 680 */ 1998, 1999, 2000, 2001, 1933, 1934, 1979, 1791, 2010, 1995, - /* 690 */ 2048, 2049, 1946, 2004, 1948, 1949, 1953, 1951, 1955, 1888, - /* 700 */ 1957, 2053, 2020, 1893, 1958, 1959, 1772, 2016, 2033, 1969, - /* 710 */ 1816, 1971, 2067, 2054, 1851, 1964, 1970, 1972, 1974, 1976, - /* 720 */ 1981, 2031, 1977, 1980, 2040, 1989, 2077, 1879, 1996, 1985, - /* 730 */ 1997, 2066, 2069, 2002, 2006, 2070, 2003, 2008, 2074, 2011, - /* 740 */ 2009, 2081, 2013, 2014, 2083, 2017, 2015, 2087, 2019, 2005, - /* 750 */ 2007, 2012, 2018, 2021, 2095, 2023, 2093, 2029, 2095, 2095, - /* 760 */ 2114, 2071, 2076, 2100, 2104, 2106, 2107, 2110, 2111, 2112, - /* 770 */ 2113, 2115, 2079, 2063, 2120, 2128, 2129, 2130, 2147, 2133, - /* 780 */ 2134, 2135, 2096, 1862, 2137, 1873, 2138, 2141, 2142, 2144, - /* 790 */ 2154, 2152, 2191, 2155, 2143, 2151, 2197, 2161, 2148, 2158, - /* 800 */ 2201, 2165, 2153, 2163, 2203, 2169, 2160, 2167, 2207, 2175, - /* 810 */ 2176, 2214, 2193, 2183, 2195, 2198, 2196, 2199, 2204, 2200, + /* 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, 780, 135, -55, -389, - /* 150 */ 274, 116, 708, 710, 591, 732, 811, 840, 848, 865, - /* 160 */ -386, -381, 239, 416, 427, 516, 522, 427, 415, 888, - /* 170 */ 625, 866, 790, 824, 939, 829, 936, 936, 950, 954, - /* 180 */ 921, 922, 847, 851, 857, 915, 863, 936, 975, 942, - /* 190 */ 998, 997, 964, 960, 961, 936, 894, 894, 881, 894, - /* 200 */ 911, 901, 955, 940, 944, 956, 957, 1024, 969, 1026, - /* 210 */ 980, 1048, 1053, 1012, 1080, 1033, 1038, 1086, 1087, 1089, - /* 220 */ 1040, 1044, 1045, 1081, 1084, 1097, 1088, 1100, 1101, 1102, - /* 230 */ 1114, 1115, 1121, 1116, 1036, 1106, 1073, 1108, 1119, 1056, - /* 240 */ 1125, 1123, 1126, 1069, 1130, 1131, 1138, 1132, 1134, 1099, - /* 250 */ 1104, 1107, 1122, 1135, 1137, 1139, 1140, 1142, 1143, 1144, - /* 260 */ 1146, 1151, 1156, 1155, 1109, 1111, 1112, 1076, 1082, 1083, - /* 270 */ 1149, 1090, 1095, 1145, 1154, 1103, 1148, 1178, 1157, 1058, - /* 280 */ 1150, 1060, 1152, 1061, 1059, 1074, 1077, 1085, 1092, 1153, - /* 290 */ 1062, 1067, 1078, 894, 1214, 1158, 1161, 1162, 1226, 1223, - /* 300 */ 1224, 1173, 1192, 1194, 1196, 1197, 1180, 1201, 1193, 1238, - /* 310 */ 1222, 1239, 1258, 1163, 1218, 1217, 1237, 1268, 1266, 1272, - /* 320 */ 1280, 1274, 1195, 1186, 1204, 1209, 1259, 1276, 1281, 1284, - /* 330 */ 1286, + /* 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 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 10 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 20 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 30 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 40 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 50 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 60 */ 2176, 1847, 1847, 2139, 1847, 1847, 1847, 1847, 1847, 1847, - /* 70 */ 1847, 1847, 1847, 1847, 1847, 2146, 1847, 1847, 1847, 1847, - /* 80 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 90 */ 1847, 1847, 1847, 1943, 1847, 1847, 1847, 1847, 1847, 1847, - /* 100 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1941, - /* 110 */ 2373, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 120 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 130 */ 1847, 1847, 1847, 1847, 2385, 1847, 1847, 1917, 1917, 1847, - /* 140 */ 2385, 2385, 2385, 1941, 2345, 2345, 1847, 1943, 2210, 1847, - /* 150 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 2065, 1847, 1877, - /* 160 */ 1847, 1847, 1847, 1847, 2089, 1847, 1847, 1847, 2202, 1847, - /* 170 */ 1847, 2414, 2474, 1847, 1847, 2417, 1847, 1847, 1847, 1847, - /* 180 */ 2151, 2404, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 190 */ 1847, 1847, 2018, 1847, 1847, 1847, 2377, 2391, 2458, 2378, - /* 200 */ 2375, 2398, 2408, 1847, 2234, 1847, 2224, 1943, 1847, 1943, - /* 210 */ 2189, 2134, 1847, 2144, 1847, 2144, 2141, 1847, 1847, 1847, - /* 220 */ 2144, 2141, 2141, 2007, 2003, 1847, 2001, 1847, 1847, 1847, - /* 230 */ 1847, 1901, 1847, 1901, 1847, 1943, 1847, 1943, 1847, 1847, - /* 240 */ 1943, 1847, 1943, 1847, 1943, 1943, 1847, 1943, 1847, 1847, - /* 250 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 260 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 2222, 2208, 1847, - /* 270 */ 1941, 2200, 2198, 1847, 1941, 2196, 2408, 1847, 1847, 2428, - /* 280 */ 2423, 2428, 2423, 2442, 2438, 2428, 2447, 2444, 2410, 2408, - /* 290 */ 2477, 2464, 2460, 2391, 1847, 1847, 2396, 2394, 1847, 1941, - /* 300 */ 1941, 2423, 1847, 1847, 1847, 1847, 2423, 1847, 1847, 1941, - /* 310 */ 1847, 1941, 1847, 1847, 2034, 1847, 1847, 1847, 1941, 1847, - /* 320 */ 1886, 1847, 2191, 2213, 2172, 2172, 2068, 2068, 2068, 1944, - /* 330 */ 1852, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 340 */ 1847, 1847, 1847, 2441, 2440, 2298, 1847, 2349, 2348, 2347, - /* 350 */ 2338, 2297, 2030, 1847, 1847, 2296, 2295, 1847, 1847, 1847, - /* 360 */ 1847, 1847, 1847, 1847, 1847, 2163, 2162, 2289, 1847, 1847, - /* 370 */ 2290, 2288, 2287, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 380 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 390 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 2461, 2465, 1847, - /* 400 */ 1847, 1847, 1847, 1847, 1847, 2374, 1847, 1847, 1847, 2270, - /* 410 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 420 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 430 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 440 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 450 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 460 */ 1847, 1847, 2140, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 470 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 480 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 490 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 500 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 510 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 2155, 1847, 1847, - /* 520 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 530 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 540 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1891, - /* 550 */ 2276, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 560 */ 1847, 1847, 1847, 2279, 1847, 1847, 1847, 1847, 1847, 1847, - /* 570 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 580 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 590 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 600 */ 1847, 1847, 1847, 1847, 1983, 1982, 1847, 1847, 1847, 1847, - /* 610 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 620 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 630 */ 2280, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 640 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 2457, - /* 650 */ 2411, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 660 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 2270, - /* 670 */ 1847, 2439, 1847, 1847, 2455, 1847, 2459, 1847, 1847, 1847, - /* 680 */ 1847, 1847, 1847, 1847, 2384, 2380, 1847, 1847, 2376, 1847, - /* 690 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 700 */ 1847, 1847, 1847, 1847, 1847, 1847, 2269, 1847, 2335, 1847, - /* 710 */ 1847, 1847, 2369, 1847, 1847, 2320, 1847, 1847, 1847, 1847, - /* 720 */ 1847, 1847, 1847, 1847, 1847, 2280, 1847, 2283, 1847, 1847, - /* 730 */ 1847, 1847, 1847, 2062, 1847, 1847, 1847, 1847, 1847, 1847, - /* 740 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 2046, - /* 750 */ 2044, 2043, 2042, 1847, 2075, 1847, 1847, 1847, 2071, 2070, - /* 760 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 770 */ 1847, 1847, 1847, 1847, 1962, 1847, 1847, 1847, 1847, 1847, - /* 780 */ 1847, 1847, 1847, 1954, 1847, 1953, 1847, 1847, 1847, 1847, - /* 790 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 800 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 810 */ 1847, 1847, 1847, 1876, 1847, 1847, 1847, 1847, 1847, 1847, + /* 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 *****************************/ @@ -1666,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 */ @@ -1733,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 */ @@ -1857,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 */ @@ -1960,7 +1527,6 @@ typedef struct yyParser yyParser; #ifndef NDEBUG #include -#include static FILE *yyTraceFILE = 0; static char *yyTracePrompt = 0; #endif /* NDEBUG */ @@ -2166,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) */ @@ -2553,589 +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 */ "speed_opt ::=", - /* 152 */ "speed_opt ::= BWLIMIT NK_INTEGER", - /* 153 */ "start_opt ::=", - /* 154 */ "start_opt ::= START WITH NK_INTEGER", - /* 155 */ "start_opt ::= START WITH NK_STRING", - /* 156 */ "start_opt ::= START WITH TIMESTAMP NK_STRING", - /* 157 */ "end_opt ::=", - /* 158 */ "end_opt ::= END WITH NK_INTEGER", - /* 159 */ "end_opt ::= END WITH NK_STRING", - /* 160 */ "end_opt ::= END WITH TIMESTAMP NK_STRING", - /* 161 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", - /* 162 */ "cmd ::= CREATE TABLE multi_create_clause", - /* 163 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", - /* 164 */ "cmd ::= DROP TABLE multi_drop_clause", - /* 165 */ "cmd ::= DROP STABLE exists_opt full_table_name", - /* 166 */ "cmd ::= ALTER TABLE alter_table_clause", - /* 167 */ "cmd ::= ALTER STABLE alter_table_clause", - /* 168 */ "alter_table_clause ::= full_table_name alter_table_options", - /* 169 */ "alter_table_clause ::= full_table_name ADD COLUMN column_name type_name", - /* 170 */ "alter_table_clause ::= full_table_name DROP COLUMN column_name", - /* 171 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name", - /* 172 */ "alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name", - /* 173 */ "alter_table_clause ::= full_table_name ADD TAG column_name type_name", - /* 174 */ "alter_table_clause ::= full_table_name DROP TAG column_name", - /* 175 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name", - /* 176 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name", - /* 177 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal", - /* 178 */ "multi_create_clause ::= create_subtable_clause", - /* 179 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", - /* 180 */ "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", - /* 181 */ "multi_drop_clause ::= drop_table_clause", - /* 182 */ "multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause", - /* 183 */ "drop_table_clause ::= exists_opt full_table_name", - /* 184 */ "specific_cols_opt ::=", - /* 185 */ "specific_cols_opt ::= NK_LP col_name_list NK_RP", - /* 186 */ "full_table_name ::= table_name", - /* 187 */ "full_table_name ::= db_name NK_DOT table_name", - /* 188 */ "column_def_list ::= column_def", - /* 189 */ "column_def_list ::= column_def_list NK_COMMA column_def", - /* 190 */ "column_def ::= column_name type_name", - /* 191 */ "type_name ::= BOOL", - /* 192 */ "type_name ::= TINYINT", - /* 193 */ "type_name ::= SMALLINT", - /* 194 */ "type_name ::= INT", - /* 195 */ "type_name ::= INTEGER", - /* 196 */ "type_name ::= BIGINT", - /* 197 */ "type_name ::= FLOAT", - /* 198 */ "type_name ::= DOUBLE", - /* 199 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", - /* 200 */ "type_name ::= TIMESTAMP", - /* 201 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", - /* 202 */ "type_name ::= TINYINT UNSIGNED", - /* 203 */ "type_name ::= SMALLINT UNSIGNED", - /* 204 */ "type_name ::= INT UNSIGNED", - /* 205 */ "type_name ::= BIGINT UNSIGNED", - /* 206 */ "type_name ::= JSON", - /* 207 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", - /* 208 */ "type_name ::= MEDIUMBLOB", - /* 209 */ "type_name ::= BLOB", - /* 210 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", - /* 211 */ "type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP", - /* 212 */ "type_name ::= DECIMAL", - /* 213 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", - /* 214 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", - /* 215 */ "tags_def_opt ::=", - /* 216 */ "tags_def_opt ::= tags_def", - /* 217 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", - /* 218 */ "table_options ::=", - /* 219 */ "table_options ::= table_options COMMENT NK_STRING", - /* 220 */ "table_options ::= table_options MAX_DELAY duration_list", - /* 221 */ "table_options ::= table_options WATERMARK duration_list", - /* 222 */ "table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP", - /* 223 */ "table_options ::= table_options TTL NK_INTEGER", - /* 224 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", - /* 225 */ "table_options ::= table_options DELETE_MARK duration_list", - /* 226 */ "alter_table_options ::= alter_table_option", - /* 227 */ "alter_table_options ::= alter_table_options alter_table_option", - /* 228 */ "alter_table_option ::= COMMENT NK_STRING", - /* 229 */ "alter_table_option ::= TTL NK_INTEGER", - /* 230 */ "duration_list ::= duration_literal", - /* 231 */ "duration_list ::= duration_list NK_COMMA duration_literal", - /* 232 */ "rollup_func_list ::= rollup_func_name", - /* 233 */ "rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name", - /* 234 */ "rollup_func_name ::= function_name", - /* 235 */ "rollup_func_name ::= FIRST", - /* 236 */ "rollup_func_name ::= LAST", - /* 237 */ "col_name_list ::= col_name", - /* 238 */ "col_name_list ::= col_name_list NK_COMMA col_name", - /* 239 */ "col_name ::= column_name", - /* 240 */ "cmd ::= SHOW DNODES", - /* 241 */ "cmd ::= SHOW USERS", - /* 242 */ "cmd ::= SHOW USER PRIVILEGES", - /* 243 */ "cmd ::= SHOW db_kind_opt DATABASES", - /* 244 */ "cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt", - /* 245 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt", - /* 246 */ "cmd ::= SHOW db_name_cond_opt VGROUPS", - /* 247 */ "cmd ::= SHOW MNODES", - /* 248 */ "cmd ::= SHOW QNODES", - /* 249 */ "cmd ::= SHOW FUNCTIONS", - /* 250 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", - /* 251 */ "cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name", - /* 252 */ "cmd ::= SHOW STREAMS", - /* 253 */ "cmd ::= SHOW ACCOUNTS", - /* 254 */ "cmd ::= SHOW APPS", - /* 255 */ "cmd ::= SHOW CONNECTIONS", - /* 256 */ "cmd ::= SHOW LICENCES", - /* 257 */ "cmd ::= SHOW GRANTS", - /* 258 */ "cmd ::= SHOW CREATE DATABASE db_name", - /* 259 */ "cmd ::= SHOW CREATE TABLE full_table_name", - /* 260 */ "cmd ::= SHOW CREATE STABLE full_table_name", - /* 261 */ "cmd ::= SHOW QUERIES", - /* 262 */ "cmd ::= SHOW SCORES", - /* 263 */ "cmd ::= SHOW TOPICS", - /* 264 */ "cmd ::= SHOW VARIABLES", - /* 265 */ "cmd ::= SHOW CLUSTER VARIABLES", - /* 266 */ "cmd ::= SHOW LOCAL VARIABLES", - /* 267 */ "cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt", - /* 268 */ "cmd ::= SHOW BNODES", - /* 269 */ "cmd ::= SHOW SNODES", - /* 270 */ "cmd ::= SHOW CLUSTER", - /* 271 */ "cmd ::= SHOW TRANSACTIONS", - /* 272 */ "cmd ::= SHOW TABLE DISTRIBUTED full_table_name", - /* 273 */ "cmd ::= SHOW CONSUMERS", - /* 274 */ "cmd ::= SHOW SUBSCRIPTIONS", - /* 275 */ "cmd ::= SHOW TAGS FROM table_name_cond from_db_opt", - /* 276 */ "cmd ::= SHOW TAGS FROM db_name NK_DOT table_name", - /* 277 */ "cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt", - /* 278 */ "cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name", - /* 279 */ "cmd ::= SHOW VNODES ON DNODE NK_INTEGER", - /* 280 */ "cmd ::= SHOW VNODES", - /* 281 */ "cmd ::= SHOW db_name_cond_opt ALIVE", - /* 282 */ "cmd ::= SHOW CLUSTER ALIVE", - /* 283 */ "table_kind_db_name_cond_opt ::=", - /* 284 */ "table_kind_db_name_cond_opt ::= table_kind", - /* 285 */ "table_kind_db_name_cond_opt ::= db_name NK_DOT", - /* 286 */ "table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT", - /* 287 */ "table_kind ::= NORMAL", - /* 288 */ "table_kind ::= CHILD", - /* 289 */ "db_name_cond_opt ::=", - /* 290 */ "db_name_cond_opt ::= db_name NK_DOT", - /* 291 */ "like_pattern_opt ::=", - /* 292 */ "like_pattern_opt ::= LIKE NK_STRING", - /* 293 */ "table_name_cond ::= table_name", - /* 294 */ "from_db_opt ::=", - /* 295 */ "from_db_opt ::= FROM db_name", - /* 296 */ "tag_list_opt ::=", - /* 297 */ "tag_list_opt ::= tag_item", - /* 298 */ "tag_list_opt ::= tag_list_opt NK_COMMA tag_item", - /* 299 */ "tag_item ::= TBNAME", - /* 300 */ "tag_item ::= QTAGS", - /* 301 */ "tag_item ::= column_name", - /* 302 */ "tag_item ::= column_name column_alias", - /* 303 */ "tag_item ::= column_name AS column_alias", - /* 304 */ "db_kind_opt ::=", - /* 305 */ "db_kind_opt ::= USER", - /* 306 */ "db_kind_opt ::= SYSTEM", - /* 307 */ "cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options", - /* 308 */ "cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP", - /* 309 */ "cmd ::= DROP INDEX exists_opt full_index_name", - /* 310 */ "full_index_name ::= index_name", - /* 311 */ "full_index_name ::= db_name NK_DOT index_name", - /* 312 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", - /* 313 */ "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", - /* 314 */ "func_list ::= func", - /* 315 */ "func_list ::= func_list NK_COMMA func", - /* 316 */ "func ::= sma_func_name NK_LP expression_list NK_RP", - /* 317 */ "sma_func_name ::= function_name", - /* 318 */ "sma_func_name ::= COUNT", - /* 319 */ "sma_func_name ::= FIRST", - /* 320 */ "sma_func_name ::= LAST", - /* 321 */ "sma_func_name ::= LAST_ROW", - /* 322 */ "sma_stream_opt ::=", - /* 323 */ "sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal", - /* 324 */ "sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal", - /* 325 */ "sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal", - /* 326 */ "with_meta ::= AS", - /* 327 */ "with_meta ::= WITH META AS", - /* 328 */ "with_meta ::= ONLY META AS", - /* 329 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery", - /* 330 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name", - /* 331 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt", - /* 332 */ "cmd ::= DROP TOPIC exists_opt topic_name", - /* 333 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", - /* 334 */ "cmd ::= DESC full_table_name", - /* 335 */ "cmd ::= DESCRIBE full_table_name", - /* 336 */ "cmd ::= RESET QUERY CACHE", - /* 337 */ "cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery", - /* 338 */ "cmd ::= EXPLAIN analyze_opt explain_options insert_query", - /* 339 */ "analyze_opt ::=", - /* 340 */ "analyze_opt ::= ANALYZE", - /* 341 */ "explain_options ::=", - /* 342 */ "explain_options ::= explain_options VERBOSE NK_BOOL", - /* 343 */ "explain_options ::= explain_options RATIO NK_FLOAT", - /* 344 */ "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 */ "cmd ::= DROP FUNCTION exists_opt function_name", - /* 346 */ "agg_func_opt ::=", - /* 347 */ "agg_func_opt ::= AGGREGATE", - /* 348 */ "bufsize_opt ::=", - /* 349 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", - /* 350 */ "language_opt ::=", - /* 351 */ "language_opt ::= LANGUAGE NK_STRING", - /* 352 */ "or_replace_opt ::=", - /* 353 */ "or_replace_opt ::= OR REPLACE", - /* 354 */ "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", - /* 355 */ "cmd ::= DROP STREAM exists_opt stream_name", - /* 356 */ "cmd ::= PAUSE STREAM exists_opt stream_name", - /* 357 */ "cmd ::= RESUME STREAM exists_opt ignore_opt stream_name", - /* 358 */ "col_list_opt ::=", - /* 359 */ "col_list_opt ::= NK_LP col_name_list NK_RP", - /* 360 */ "tag_def_or_ref_opt ::=", - /* 361 */ "tag_def_or_ref_opt ::= tags_def", - /* 362 */ "tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP", - /* 363 */ "stream_options ::=", - /* 364 */ "stream_options ::= stream_options TRIGGER AT_ONCE", - /* 365 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", - /* 366 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", - /* 367 */ "stream_options ::= stream_options WATERMARK duration_literal", - /* 368 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER", - /* 369 */ "stream_options ::= stream_options FILL_HISTORY NK_INTEGER", - /* 370 */ "stream_options ::= stream_options DELETE_MARK duration_literal", - /* 371 */ "stream_options ::= stream_options IGNORE UPDATE NK_INTEGER", - /* 372 */ "subtable_opt ::=", - /* 373 */ "subtable_opt ::= SUBTABLE NK_LP expression NK_RP", - /* 374 */ "ignore_opt ::=", - /* 375 */ "ignore_opt ::= IGNORE UNTREATED", - /* 376 */ "cmd ::= KILL CONNECTION NK_INTEGER", - /* 377 */ "cmd ::= KILL QUERY NK_STRING", - /* 378 */ "cmd ::= KILL TRANSACTION NK_INTEGER", - /* 379 */ "cmd ::= BALANCE VGROUP", - /* 380 */ "cmd ::= BALANCE VGROUP LEADER on_vgroup_id", - /* 381 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", - /* 382 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", - /* 383 */ "cmd ::= SPLIT VGROUP NK_INTEGER", - /* 384 */ "on_vgroup_id ::=", - /* 385 */ "on_vgroup_id ::= ON NK_INTEGER", - /* 386 */ "dnode_list ::= DNODE NK_INTEGER", - /* 387 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", - /* 388 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", - /* 389 */ "cmd ::= query_or_subquery", - /* 390 */ "cmd ::= insert_query", - /* 391 */ "insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", - /* 392 */ "insert_query ::= INSERT INTO full_table_name query_or_subquery", - /* 393 */ "literal ::= NK_INTEGER", - /* 394 */ "literal ::= NK_FLOAT", - /* 395 */ "literal ::= NK_STRING", - /* 396 */ "literal ::= NK_BOOL", - /* 397 */ "literal ::= TIMESTAMP NK_STRING", - /* 398 */ "literal ::= duration_literal", - /* 399 */ "literal ::= NULL", - /* 400 */ "literal ::= NK_QUESTION", - /* 401 */ "duration_literal ::= NK_VARIABLE", - /* 402 */ "signed ::= NK_INTEGER", - /* 403 */ "signed ::= NK_PLUS NK_INTEGER", - /* 404 */ "signed ::= NK_MINUS NK_INTEGER", - /* 405 */ "signed ::= NK_FLOAT", - /* 406 */ "signed ::= NK_PLUS NK_FLOAT", - /* 407 */ "signed ::= NK_MINUS NK_FLOAT", - /* 408 */ "signed_literal ::= signed", - /* 409 */ "signed_literal ::= NK_STRING", - /* 410 */ "signed_literal ::= NK_BOOL", - /* 411 */ "signed_literal ::= TIMESTAMP NK_STRING", - /* 412 */ "signed_literal ::= duration_literal", - /* 413 */ "signed_literal ::= NULL", - /* 414 */ "signed_literal ::= literal_func", - /* 415 */ "signed_literal ::= NK_QUESTION", - /* 416 */ "literal_list ::= signed_literal", - /* 417 */ "literal_list ::= literal_list NK_COMMA signed_literal", - /* 418 */ "db_name ::= NK_ID", - /* 419 */ "table_name ::= NK_ID", - /* 420 */ "column_name ::= NK_ID", - /* 421 */ "function_name ::= NK_ID", - /* 422 */ "table_alias ::= NK_ID", - /* 423 */ "column_alias ::= NK_ID", - /* 424 */ "column_alias ::= NK_ALIAS", - /* 425 */ "user_name ::= NK_ID", - /* 426 */ "topic_name ::= NK_ID", - /* 427 */ "stream_name ::= NK_ID", - /* 428 */ "cgroup_name ::= NK_ID", - /* 429 */ "index_name ::= NK_ID", - /* 430 */ "expr_or_subquery ::= expression", - /* 431 */ "expression ::= literal", - /* 432 */ "expression ::= pseudo_column", - /* 433 */ "expression ::= column_reference", - /* 434 */ "expression ::= function_expression", - /* 435 */ "expression ::= case_when_expression", - /* 436 */ "expression ::= NK_LP expression NK_RP", - /* 437 */ "expression ::= NK_PLUS expr_or_subquery", - /* 438 */ "expression ::= NK_MINUS expr_or_subquery", - /* 439 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", - /* 440 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", - /* 441 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", - /* 442 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", - /* 443 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", - /* 444 */ "expression ::= column_reference NK_ARROW NK_STRING", - /* 445 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", - /* 446 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", - /* 447 */ "expression_list ::= expr_or_subquery", - /* 448 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", - /* 449 */ "column_reference ::= column_name", - /* 450 */ "column_reference ::= table_name NK_DOT column_name", - /* 451 */ "column_reference ::= NK_ALIAS", - /* 452 */ "column_reference ::= table_name NK_DOT NK_ALIAS", - /* 453 */ "pseudo_column ::= ROWTS", - /* 454 */ "pseudo_column ::= TBNAME", - /* 455 */ "pseudo_column ::= table_name NK_DOT TBNAME", - /* 456 */ "pseudo_column ::= QSTART", - /* 457 */ "pseudo_column ::= QEND", - /* 458 */ "pseudo_column ::= QDURATION", - /* 459 */ "pseudo_column ::= WSTART", - /* 460 */ "pseudo_column ::= WEND", - /* 461 */ "pseudo_column ::= WDURATION", - /* 462 */ "pseudo_column ::= IROWTS", - /* 463 */ "pseudo_column ::= ISFILLED", - /* 464 */ "pseudo_column ::= QTAGS", - /* 465 */ "function_expression ::= function_name NK_LP expression_list NK_RP", - /* 466 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", - /* 467 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", - /* 468 */ "function_expression ::= literal_func", - /* 469 */ "literal_func ::= noarg_func NK_LP NK_RP", - /* 470 */ "literal_func ::= NOW", - /* 471 */ "noarg_func ::= NOW", - /* 472 */ "noarg_func ::= TODAY", - /* 473 */ "noarg_func ::= TIMEZONE", - /* 474 */ "noarg_func ::= DATABASE", - /* 475 */ "noarg_func ::= CLIENT_VERSION", - /* 476 */ "noarg_func ::= SERVER_VERSION", - /* 477 */ "noarg_func ::= SERVER_STATUS", - /* 478 */ "noarg_func ::= CURRENT_USER", - /* 479 */ "noarg_func ::= USER", - /* 480 */ "star_func ::= COUNT", - /* 481 */ "star_func ::= FIRST", - /* 482 */ "star_func ::= LAST", - /* 483 */ "star_func ::= LAST_ROW", - /* 484 */ "star_func_para_list ::= NK_STAR", - /* 485 */ "star_func_para_list ::= other_para_list", - /* 486 */ "other_para_list ::= star_func_para", - /* 487 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", - /* 488 */ "star_func_para ::= expr_or_subquery", - /* 489 */ "star_func_para ::= table_name NK_DOT NK_STAR", - /* 490 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", - /* 491 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", - /* 492 */ "when_then_list ::= when_then_expr", - /* 493 */ "when_then_list ::= when_then_list when_then_expr", - /* 494 */ "when_then_expr ::= WHEN common_expression THEN common_expression", - /* 495 */ "case_when_else_opt ::=", - /* 496 */ "case_when_else_opt ::= ELSE common_expression", - /* 497 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", - /* 498 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", - /* 499 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", - /* 500 */ "predicate ::= expr_or_subquery IS NULL", - /* 501 */ "predicate ::= expr_or_subquery IS NOT NULL", - /* 502 */ "predicate ::= expr_or_subquery in_op in_predicate_value", - /* 503 */ "compare_op ::= NK_LT", - /* 504 */ "compare_op ::= NK_GT", - /* 505 */ "compare_op ::= NK_LE", - /* 506 */ "compare_op ::= NK_GE", - /* 507 */ "compare_op ::= NK_NE", - /* 508 */ "compare_op ::= NK_EQ", - /* 509 */ "compare_op ::= LIKE", - /* 510 */ "compare_op ::= NOT LIKE", - /* 511 */ "compare_op ::= MATCH", - /* 512 */ "compare_op ::= NMATCH", - /* 513 */ "compare_op ::= CONTAINS", - /* 514 */ "in_op ::= IN", - /* 515 */ "in_op ::= NOT IN", - /* 516 */ "in_predicate_value ::= NK_LP literal_list NK_RP", - /* 517 */ "boolean_value_expression ::= boolean_primary", - /* 518 */ "boolean_value_expression ::= NOT boolean_primary", - /* 519 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 520 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 521 */ "boolean_primary ::= predicate", - /* 522 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 523 */ "common_expression ::= expr_or_subquery", - /* 524 */ "common_expression ::= boolean_value_expression", - /* 525 */ "from_clause_opt ::=", - /* 526 */ "from_clause_opt ::= FROM table_reference_list", - /* 527 */ "table_reference_list ::= table_reference", - /* 528 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 529 */ "table_reference ::= table_primary", - /* 530 */ "table_reference ::= joined_table", - /* 531 */ "table_primary ::= table_name alias_opt", - /* 532 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 533 */ "table_primary ::= subquery alias_opt", - /* 534 */ "table_primary ::= parenthesized_joined_table", - /* 535 */ "alias_opt ::=", - /* 536 */ "alias_opt ::= table_alias", - /* 537 */ "alias_opt ::= AS table_alias", - /* 538 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 539 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 540 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 541 */ "join_type ::=", - /* 542 */ "join_type ::= INNER", - /* 543 */ "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", - /* 544 */ "hint_list ::=", - /* 545 */ "hint_list ::= NK_HINT", - /* 546 */ "tag_mode_opt ::=", - /* 547 */ "tag_mode_opt ::= TAGS", - /* 548 */ "set_quantifier_opt ::=", - /* 549 */ "set_quantifier_opt ::= DISTINCT", - /* 550 */ "set_quantifier_opt ::= ALL", - /* 551 */ "select_list ::= select_item", - /* 552 */ "select_list ::= select_list NK_COMMA select_item", - /* 553 */ "select_item ::= NK_STAR", - /* 554 */ "select_item ::= common_expression", - /* 555 */ "select_item ::= common_expression column_alias", - /* 556 */ "select_item ::= common_expression AS column_alias", - /* 557 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 558 */ "where_clause_opt ::=", - /* 559 */ "where_clause_opt ::= WHERE search_condition", - /* 560 */ "partition_by_clause_opt ::=", - /* 561 */ "partition_by_clause_opt ::= PARTITION BY partition_list", - /* 562 */ "partition_list ::= partition_item", - /* 563 */ "partition_list ::= partition_list NK_COMMA partition_item", - /* 564 */ "partition_item ::= expr_or_subquery", - /* 565 */ "partition_item ::= expr_or_subquery column_alias", - /* 566 */ "partition_item ::= expr_or_subquery AS column_alias", - /* 567 */ "twindow_clause_opt ::=", - /* 568 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP", - /* 569 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", - /* 570 */ "twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt", - /* 571 */ "twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt", - /* 572 */ "twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition", - /* 573 */ "sliding_opt ::=", - /* 574 */ "sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP", - /* 575 */ "interval_sliding_duration_literal ::= NK_VARIABLE", - /* 576 */ "interval_sliding_duration_literal ::= NK_STRING", - /* 577 */ "interval_sliding_duration_literal ::= NK_INTEGER", - /* 578 */ "fill_opt ::=", - /* 579 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 580 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP", - /* 581 */ "fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP", - /* 582 */ "fill_mode ::= NONE", - /* 583 */ "fill_mode ::= PREV", - /* 584 */ "fill_mode ::= NULL", - /* 585 */ "fill_mode ::= NULL_F", - /* 586 */ "fill_mode ::= LINEAR", - /* 587 */ "fill_mode ::= NEXT", - /* 588 */ "group_by_clause_opt ::=", - /* 589 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 590 */ "group_by_list ::= expr_or_subquery", - /* 591 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", - /* 592 */ "having_clause_opt ::=", - /* 593 */ "having_clause_opt ::= HAVING search_condition", - /* 594 */ "range_opt ::=", - /* 595 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", - /* 596 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_RP", - /* 597 */ "every_opt ::=", - /* 598 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", - /* 599 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 600 */ "query_simple ::= query_specification", - /* 601 */ "query_simple ::= union_query_expression", - /* 602 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", - /* 603 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", - /* 604 */ "query_simple_or_subquery ::= query_simple", - /* 605 */ "query_simple_or_subquery ::= subquery", - /* 606 */ "query_or_subquery ::= query_expression", - /* 607 */ "query_or_subquery ::= subquery", - /* 608 */ "order_by_clause_opt ::=", - /* 609 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 610 */ "slimit_clause_opt ::=", - /* 611 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 612 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 613 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 614 */ "limit_clause_opt ::=", - /* 615 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 616 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 617 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 618 */ "subquery ::= NK_LP query_expression NK_RP", - /* 619 */ "subquery ::= NK_LP subquery NK_RP", - /* 620 */ "search_condition ::= common_expression", - /* 621 */ "sort_specification_list ::= sort_specification", - /* 622 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 623 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", - /* 624 */ "ordering_specification_opt ::=", - /* 625 */ "ordering_specification_opt ::= ASC", - /* 626 */ "ordering_specification_opt ::= DESC", - /* 627 */ "null_ordering_opt ::=", - /* 628 */ "null_ordering_opt ::= NULLS FIRST", - /* 629 */ "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 */ @@ -3262,265 +2840,233 @@ 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 */ { -#line 7 "sql.y" - nodesDestroyNode((yypminor->yy56)); -#line 3343 "sql.c" + 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 */ { -#line 54 "sql.y" -#line 3355 "sql.c" } 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 */ { -#line 85 "sql.y" - nodesDestroyList((yypminor->yy712)); -#line 3394 "sql.c" + 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 */ { -#line 793 "sql.y" -#line 3418 "sql.c" } break; - case 354: /* sysinfo_opt */ + case 355: /* sysinfo_opt */ { -#line 112 "sql.y" -#line 3425 "sql.c" } 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 */ { -#line 121 "sql.y" -#line 3434 "sql.c" } break; - case 356: /* priv_level */ + case 357: /* priv_level */ { -#line 137 "sql.y" -#line 3441 "sql.c" } 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 */ { -#line 166 "sql.y" -#line 3457 "sql.c" } break; - case 378: /* alter_db_option */ - case 400: /* alter_table_option */ + case 379: /* alter_db_option */ + case 401: /* alter_table_option */ { -#line 264 "sql.y" -#line 3465 "sql.c" } break; - case 390: /* type_name */ + case 391: /* type_name */ { -#line 386 "sql.y" -#line 3472 "sql.c" } break; - case 405: /* db_kind_opt */ - case 412: /* table_kind */ + case 406: /* db_kind_opt */ + case 413: /* table_kind */ { -#line 547 "sql.y" -#line 3480 "sql.c" } break; - case 406: /* table_kind_db_name_cond_opt */ + case 407: /* table_kind_db_name_cond_opt */ { -#line 512 "sql.y" -#line 3487 "sql.c" } break; - case 461: /* compare_op */ - case 462: /* in_op */ + case 464: /* compare_op */ + case 465: /* in_op */ { -#line 983 "sql.y" -#line 3495 "sql.c" } break; - case 474: /* join_type */ + case 477: /* join_type */ { -#line 1059 "sql.y" -#line 3502 "sql.c" } break; - case 491: /* fill_mode */ + case 494: /* fill_mode */ { -#line 1150 "sql.y" -#line 3509 "sql.c" } break; - case 502: /* ordering_specification_opt */ + case 505: /* ordering_specification_opt */ { -#line 1235 "sql.y" -#line 3516 "sql.c" } break; - case 503: /* null_ordering_opt */ + case 506: /* null_ordering_opt */ { -#line 1241 "sql.y" -#line 3523 "sql.c" } break; /********* End destructor definitions *****************************************/ @@ -3687,7 +3233,7 @@ static YYACTIONTYPE yy_find_shift_action( #endif /* YYWILDCARD */ return yy_default[stateno]; }else{ - assert( i>=0 && i<(int)(sizeof(yy_action)/sizeof(yy_action[0])) ); + assert( i>=0 && iyytos; - assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ); #ifndef NDEBUG - if( yyTraceFILE ){ + if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ yysize = yyRuleInfoNRhs[yyruleno]; if( yysize ){ fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", @@ -5165,21 +4728,15 @@ static YYACTIONTYPE yy_reduce( /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; case 0: /* cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ -#line 50 "sql.y" { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } -#line 5170 "sql.c" - yy_destructor(yypParser,346,&yymsp[0].minor); - break; - case 1: /* cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ -#line 51 "sql.y" -{ pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } -#line 5176 "sql.c" 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,348,&yymsp[0].minor); + break; case 2: /* account_options ::= */ -#line 55 "sql.y" { } -#line 5182 "sql.c" break; case 3: /* account_options ::= account_options PPS literal */ case 4: /* account_options ::= account_options TSERIES literal */ yytestcase(yyruleno==4); @@ -5190,26 +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); -#line 56 "sql.y" +{ yy_destructor(yypParser,347,&yymsp[-2].minor); { } -#line 5196 "sql.c" - 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); -#line 68 "sql.y" +{ yy_destructor(yypParser,350,&yymsp[0].minor); { } -#line 5204 "sql.c" } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ -{ yy_destructor(yypParser,347,&yymsp[-1].minor); -#line 69 "sql.y" +{ yy_destructor(yypParser,348,&yymsp[-1].minor); { } -#line 5211 "sql.c" - yy_destructor(yypParser,349,&yymsp[0].minor); + yy_destructor(yypParser,350,&yymsp[0].minor); } break; case 14: /* alter_account_option ::= PASS literal */ @@ -5222,2579 +4773,1762 @@ static YYACTIONTYPE yy_reduce( case 21: /* alter_account_option ::= USERS literal */ yytestcase(yyruleno==21); case 22: /* alter_account_option ::= CONNS literal */ yytestcase(yyruleno==22); case 23: /* alter_account_option ::= STATE literal */ yytestcase(yyruleno==23); -#line 73 "sql.y" { } -#line 5227 "sql.c" - yy_destructor(yypParser,348,&yymsp[0].minor); + yy_destructor(yypParser,349,&yymsp[0].minor); break; case 24: /* ip_range_list ::= NK_STRING */ -#line 86 "sql.y" -{ yylhsminor.yy712 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } -#line 5233 "sql.c" - 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 */ -#line 87 "sql.y" -{ yylhsminor.yy712 = addNodeToList(pCxt, yymsp[-2].minor.yy712, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } -#line 5239 "sql.c" - 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 */ -#line 91 "sql.y" -{ yymsp[-1].minor.yy712 = yymsp[0].minor.yy712; } -#line 5245 "sql.c" +{ yymsp[-1].minor.yy106 = yymsp[0].minor.yy106; } break; case 27: /* white_list_opt ::= */ - case 184: /* specific_cols_opt ::= */ yytestcase(yyruleno==184); - case 215: /* tags_def_opt ::= */ yytestcase(yyruleno==215); - case 296: /* tag_list_opt ::= */ yytestcase(yyruleno==296); - case 358: /* col_list_opt ::= */ yytestcase(yyruleno==358); - case 360: /* tag_def_or_ref_opt ::= */ yytestcase(yyruleno==360); - case 560: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==560); - case 588: /* group_by_clause_opt ::= */ yytestcase(yyruleno==588); - case 608: /* order_by_clause_opt ::= */ yytestcase(yyruleno==608); -#line 95 "sql.y" -{ yymsp[1].minor.yy712 = NULL; } -#line 5258 "sql.c" + 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 216: /* tags_def_opt ::= tags_def */ yytestcase(yyruleno==216); - case 361: /* tag_def_or_ref_opt ::= tags_def */ yytestcase(yyruleno==361); - case 485: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==485); -#line 96 "sql.y" -{ yylhsminor.yy712 = yymsp[0].minor.yy712; } -#line 5266 "sql.c" - 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 */ -#line 100 "sql.y" { - 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); } -#line 5275 "sql.c" break; case 30: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -#line 104 "sql.y" { pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy785, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } -#line 5280 "sql.c" break; case 31: /* cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ -#line 105 "sql.y" { pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy785, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } -#line 5285 "sql.c" break; case 32: /* cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ -#line 106 "sql.y" { pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy785, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } -#line 5290 "sql.c" break; case 33: /* cmd ::= ALTER USER user_name ADD white_list */ -#line 107 "sql.y" -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy785, TSDB_ALTER_USER_ADD_WHITE_LIST, yymsp[0].minor.yy712); } -#line 5295 "sql.c" +{ 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 */ -#line 108 "sql.y" -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy785, TSDB_ALTER_USER_DROP_WHITE_LIST, yymsp[0].minor.yy712); } -#line 5300 "sql.c" +{ 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 */ -#line 109 "sql.y" { pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy785); } -#line 5305 "sql.c" break; case 36: /* sysinfo_opt ::= */ -#line 113 "sql.y" -{ yymsp[1].minor.yy215 = 1; } -#line 5310 "sql.c" +{ yymsp[1].minor.yy431 = 1; } break; case 37: /* sysinfo_opt ::= SYSINFO NK_INTEGER */ -#line 114 "sql.y" -{ yymsp[-1].minor.yy215 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } -#line 5315 "sql.c" +{ 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 */ -#line 117 "sql.y" -{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-5].minor.yy333, &yymsp[-3].minor.yy777, &yymsp[0].minor.yy785, yymsp[-2].minor.yy56); } -#line 5320 "sql.c" +{ 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 */ -#line 118 "sql.y" -{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-5].minor.yy333, &yymsp[-3].minor.yy777, &yymsp[0].minor.yy785, yymsp[-2].minor.yy56); } -#line 5325 "sql.c" +{ 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 */ -#line 122 "sql.y" -{ yymsp[0].minor.yy333 = PRIVILEGE_TYPE_ALL; } -#line 5330 "sql.c" +{ yymsp[0].minor.yy987 = PRIVILEGE_TYPE_ALL; } break; case 41: /* privileges ::= priv_type_list */ case 43: /* priv_type_list ::= priv_type */ yytestcase(yyruleno==43); -#line 123 "sql.y" -{ yylhsminor.yy333 = yymsp[0].minor.yy333; } -#line 5336 "sql.c" - yymsp[0].minor.yy333 = yylhsminor.yy333; +{ yylhsminor.yy987 = yymsp[0].minor.yy987; } + yymsp[0].minor.yy987 = yylhsminor.yy987; break; case 42: /* privileges ::= SUBSCRIBE */ -#line 124 "sql.y" -{ yymsp[0].minor.yy333 = PRIVILEGE_TYPE_SUBSCRIBE; } -#line 5342 "sql.c" +{ yymsp[0].minor.yy987 = PRIVILEGE_TYPE_SUBSCRIBE; } break; case 44: /* priv_type_list ::= priv_type_list NK_COMMA priv_type */ -#line 129 "sql.y" -{ yylhsminor.yy333 = yymsp[-2].minor.yy333 | yymsp[0].minor.yy333; } -#line 5347 "sql.c" - 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 */ -#line 133 "sql.y" -{ yymsp[0].minor.yy333 = PRIVILEGE_TYPE_READ; } -#line 5353 "sql.c" +{ yymsp[0].minor.yy987 = PRIVILEGE_TYPE_READ; } break; case 46: /* priv_type ::= WRITE */ -#line 134 "sql.y" -{ yymsp[0].minor.yy333 = PRIVILEGE_TYPE_WRITE; } -#line 5358 "sql.c" +{ yymsp[0].minor.yy987 = PRIVILEGE_TYPE_WRITE; } break; - case 47: /* priv_level ::= NK_STAR NK_DOT NK_STAR */ -#line 138 "sql.y" -{ yylhsminor.yy777.first = yymsp[-2].minor.yy0; yylhsminor.yy777.second = yymsp[0].minor.yy0; } -#line 5363 "sql.c" - 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 */ -#line 139 "sql.y" -{ yylhsminor.yy777.first = yymsp[-2].minor.yy785; yylhsminor.yy777.second = yymsp[0].minor.yy0; } -#line 5369 "sql.c" - 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 */ -#line 140 "sql.y" -{ yylhsminor.yy777.first = yymsp[-2].minor.yy785; yylhsminor.yy777.second = yymsp[0].minor.yy785; } -#line 5375 "sql.c" - 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 */ -#line 141 "sql.y" -{ yylhsminor.yy777.first = yymsp[0].minor.yy785; yylhsminor.yy777.second = nil_token; } -#line 5381 "sql.c" - 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 153: /* start_opt ::= */ yytestcase(yyruleno==153); - case 157: /* end_opt ::= */ yytestcase(yyruleno==157); - case 291: /* like_pattern_opt ::= */ yytestcase(yyruleno==291); - case 372: /* subtable_opt ::= */ yytestcase(yyruleno==372); - case 495: /* case_when_else_opt ::= */ yytestcase(yyruleno==495); - case 525: /* from_clause_opt ::= */ yytestcase(yyruleno==525); - case 558: /* where_clause_opt ::= */ yytestcase(yyruleno==558); - case 567: /* twindow_clause_opt ::= */ yytestcase(yyruleno==567); - case 573: /* sliding_opt ::= */ yytestcase(yyruleno==573); - case 578: /* fill_opt ::= */ yytestcase(yyruleno==578); - case 592: /* having_clause_opt ::= */ yytestcase(yyruleno==592); - case 594: /* range_opt ::= */ yytestcase(yyruleno==594); - case 597: /* every_opt ::= */ yytestcase(yyruleno==597); - case 610: /* slimit_clause_opt ::= */ yytestcase(yyruleno==610); - case 614: /* limit_clause_opt ::= */ yytestcase(yyruleno==614); -#line 143 "sql.y" -{ yymsp[1].minor.yy56 = NULL; } -#line 5402 "sql.c" + 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 526: /* from_clause_opt ::= FROM table_reference_list */ yytestcase(yyruleno==526); - case 559: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==559); - case 593: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==593); -#line 144 "sql.y" -{ yymsp[-1].minor.yy56 = yymsp[0].minor.yy56; } -#line 5410 "sql.c" + 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 */ -#line 147 "sql.y" + 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); } -#line 5415 "sql.c" break; - case 54: /* cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ -#line 148 "sql.y" + case 55: /* cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy0); } -#line 5420 "sql.c" break; - case 55: /* cmd ::= DROP DNODE NK_INTEGER force_opt */ -#line 149 "sql.y" -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy425, false); } -#line 5425 "sql.c" + 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 */ -#line 150 "sql.y" -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy785, yymsp[0].minor.yy425, false); } -#line 5430 "sql.c" + 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 */ -#line 151 "sql.y" -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, false, yymsp[0].minor.yy425); } -#line 5435 "sql.c" + 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 */ -#line 152 "sql.y" -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy785, false, yymsp[0].minor.yy425); } -#line 5440 "sql.c" + 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 */ -#line 153 "sql.y" + case 60: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } -#line 5445 "sql.c" break; - case 60: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ -#line 154 "sql.y" + 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); } -#line 5450 "sql.c" break; - case 61: /* cmd ::= ALTER ALL DNODES NK_STRING */ -#line 155 "sql.y" + case 62: /* cmd ::= ALTER ALL DNODES NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, NULL, &yymsp[0].minor.yy0, NULL); } -#line 5455 "sql.c" break; - case 62: /* cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ -#line 156 "sql.y" + case 63: /* cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, NULL, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } -#line 5460 "sql.c" break; - case 63: /* cmd ::= RESTORE DNODE NK_INTEGER */ -#line 157 "sql.y" + case 64: /* cmd ::= RESTORE DNODE NK_INTEGER */ { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_DNODE_STMT, &yymsp[0].minor.yy0); } -#line 5465 "sql.c" 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 318: /* sma_func_name ::= COUNT */ yytestcase(yyruleno==318); - case 319: /* sma_func_name ::= FIRST */ yytestcase(yyruleno==319); - case 320: /* sma_func_name ::= LAST */ yytestcase(yyruleno==320); - case 321: /* sma_func_name ::= LAST_ROW */ yytestcase(yyruleno==321); - case 418: /* db_name ::= NK_ID */ yytestcase(yyruleno==418); - case 419: /* table_name ::= NK_ID */ yytestcase(yyruleno==419); - case 420: /* column_name ::= NK_ID */ yytestcase(yyruleno==420); - case 421: /* function_name ::= NK_ID */ yytestcase(yyruleno==421); - case 422: /* table_alias ::= NK_ID */ yytestcase(yyruleno==422); - case 423: /* column_alias ::= NK_ID */ yytestcase(yyruleno==423); - case 424: /* column_alias ::= NK_ALIAS */ yytestcase(yyruleno==424); - case 425: /* user_name ::= NK_ID */ yytestcase(yyruleno==425); - case 426: /* topic_name ::= NK_ID */ yytestcase(yyruleno==426); - case 427: /* stream_name ::= NK_ID */ yytestcase(yyruleno==427); - case 428: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==428); - case 429: /* index_name ::= NK_ID */ yytestcase(yyruleno==429); - case 471: /* noarg_func ::= NOW */ yytestcase(yyruleno==471); - case 472: /* noarg_func ::= TODAY */ yytestcase(yyruleno==472); - case 473: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==473); - case 474: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==474); - case 475: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==475); - case 476: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==476); - case 477: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==477); - case 478: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==478); - case 479: /* noarg_func ::= USER */ yytestcase(yyruleno==479); - case 480: /* star_func ::= COUNT */ yytestcase(yyruleno==480); - case 481: /* star_func ::= FIRST */ yytestcase(yyruleno==481); - case 482: /* star_func ::= LAST */ yytestcase(yyruleno==482); - case 483: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==483); -#line 161 "sql.y" + 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; } -#line 5501 "sql.c" 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 339: /* analyze_opt ::= */ yytestcase(yyruleno==339); - case 346: /* agg_func_opt ::= */ yytestcase(yyruleno==346); - case 352: /* or_replace_opt ::= */ yytestcase(yyruleno==352); - case 374: /* ignore_opt ::= */ yytestcase(yyruleno==374); - case 546: /* tag_mode_opt ::= */ yytestcase(yyruleno==546); - case 548: /* set_quantifier_opt ::= */ yytestcase(yyruleno==548); -#line 167 "sql.y" -{ yymsp[1].minor.yy425 = false; } -#line 5515 "sql.c" + 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 340: /* analyze_opt ::= ANALYZE */ yytestcase(yyruleno==340); - case 347: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==347); - case 547: /* tag_mode_opt ::= TAGS */ yytestcase(yyruleno==547); - case 549: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==549); -#line 168 "sql.y" -{ yymsp[0].minor.yy425 = true; } -#line 5525 "sql.c" + 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 */ -#line 175 "sql.y" + case 71: /* cmd ::= ALTER LOCAL NK_STRING */ { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } -#line 5530 "sql.c" break; - case 71: /* cmd ::= ALTER LOCAL NK_STRING NK_STRING */ -#line 176 "sql.y" + case 72: /* cmd ::= ALTER LOCAL NK_STRING NK_STRING */ { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } -#line 5535 "sql.c" break; - case 72: /* cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ -#line 179 "sql.y" + case 73: /* cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_QNODE_STMT, &yymsp[0].minor.yy0); } -#line 5540 "sql.c" break; - case 73: /* cmd ::= DROP QNODE ON DNODE NK_INTEGER */ -#line 180 "sql.y" + case 74: /* cmd ::= DROP QNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_QNODE_STMT, &yymsp[0].minor.yy0); } -#line 5545 "sql.c" break; - case 74: /* cmd ::= RESTORE QNODE ON DNODE NK_INTEGER */ -#line 181 "sql.y" + case 75: /* cmd ::= RESTORE QNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_QNODE_STMT, &yymsp[0].minor.yy0); } -#line 5550 "sql.c" break; - case 75: /* cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ -#line 184 "sql.y" + case 76: /* cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_BNODE_STMT, &yymsp[0].minor.yy0); } -#line 5555 "sql.c" break; - case 76: /* cmd ::= DROP BNODE ON DNODE NK_INTEGER */ -#line 185 "sql.y" + case 77: /* cmd ::= DROP BNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_BNODE_STMT, &yymsp[0].minor.yy0); } -#line 5560 "sql.c" break; - case 77: /* cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ -#line 188 "sql.y" + case 78: /* cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_SNODE_STMT, &yymsp[0].minor.yy0); } -#line 5565 "sql.c" break; - case 78: /* cmd ::= DROP SNODE ON DNODE NK_INTEGER */ -#line 189 "sql.y" + case 79: /* cmd ::= DROP SNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_SNODE_STMT, &yymsp[0].minor.yy0); } -#line 5570 "sql.c" break; - case 79: /* cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ -#line 192 "sql.y" + case 80: /* cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_MNODE_STMT, &yymsp[0].minor.yy0); } -#line 5575 "sql.c" break; - case 80: /* cmd ::= DROP MNODE ON DNODE NK_INTEGER */ -#line 193 "sql.y" + case 81: /* cmd ::= DROP MNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_MNODE_STMT, &yymsp[0].minor.yy0); } -#line 5580 "sql.c" break; - case 81: /* cmd ::= RESTORE MNODE ON DNODE NK_INTEGER */ -#line 194 "sql.y" + case 82: /* cmd ::= RESTORE MNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_MNODE_STMT, &yymsp[0].minor.yy0); } -#line 5585 "sql.c" break; - case 82: /* cmd ::= RESTORE VNODE ON DNODE NK_INTEGER */ -#line 197 "sql.y" + case 83: /* cmd ::= RESTORE VNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_VNODE_STMT, &yymsp[0].minor.yy0); } -#line 5590 "sql.c" break; - case 83: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -#line 200 "sql.y" -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy425, &yymsp[-1].minor.yy785, yymsp[0].minor.yy56); } -#line 5595 "sql.c" + 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 */ -#line 201 "sql.y" -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy425, &yymsp[0].minor.yy785); } -#line 5600 "sql.c" + 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 */ -#line 202 "sql.y" + case 86: /* cmd ::= USE db_name */ { pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy785); } -#line 5605 "sql.c" break; - case 86: /* cmd ::= ALTER DATABASE db_name alter_db_options */ -#line 203 "sql.y" -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy785, yymsp[0].minor.yy56); } -#line 5610 "sql.c" + 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 */ -#line 204 "sql.y" + case 88: /* cmd ::= FLUSH DATABASE db_name */ { pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy785); } -#line 5615 "sql.c" break; - case 88: /* cmd ::= TRIM DATABASE db_name speed_opt */ -#line 205 "sql.y" -{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[-1].minor.yy785, yymsp[0].minor.yy676); } -#line 5620 "sql.c" + 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 */ -#line 206 "sql.y" -{ pCxt->pRootNode = createCompactStmt(pCxt, &yymsp[-2].minor.yy785, yymsp[-1].minor.yy56, yymsp[0].minor.yy56); } -#line 5625 "sql.c" + 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 */ -#line 210 "sql.y" -{ yymsp[-2].minor.yy425 = true; } -#line 5630 "sql.c" + case 91: /* not_exists_opt ::= IF NOT EXISTS */ +{ yymsp[-2].minor.yy923 = true; } break; - case 92: /* exists_opt ::= IF EXISTS */ - case 353: /* or_replace_opt ::= OR REPLACE */ yytestcase(yyruleno==353); - case 375: /* ignore_opt ::= IGNORE UNTREATED */ yytestcase(yyruleno==375); -#line 215 "sql.y" -{ yymsp[-1].minor.yy425 = true; } -#line 5637 "sql.c" + 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 ::= */ -#line 218 "sql.y" -{ yymsp[1].minor.yy56 = createDefaultDatabaseOptions(pCxt); } -#line 5642 "sql.c" + case 95: /* db_options ::= */ +{ yymsp[1].minor.yy80 = createDefaultDatabaseOptions(pCxt); } break; - case 95: /* db_options ::= db_options BUFFER NK_INTEGER */ -#line 219 "sql.y" -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } -#line 5647 "sql.c" - 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 */ -#line 220 "sql.y" -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } -#line 5653 "sql.c" - 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 */ -#line 221 "sql.y" -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } -#line 5659 "sql.c" - 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 */ -#line 222 "sql.y" -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_COMP, &yymsp[0].minor.yy0); } -#line 5665 "sql.c" - 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); -#line 223 "sql.y" -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } -#line 5672 "sql.c" - 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 */ -#line 225 "sql.y" -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } -#line 5678 "sql.c" - 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 */ -#line 226 "sql.y" -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } -#line 5684 "sql.c" - 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); -#line 227 "sql.y" -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_KEEP, yymsp[0].minor.yy712); } -#line 5691 "sql.c" - 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 */ -#line 229 "sql.y" -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } -#line 5697 "sql.c" - 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 */ -#line 230 "sql.y" -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } -#line 5703 "sql.c" - 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 */ -#line 231 "sql.y" -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } -#line 5709 "sql.c" - 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 */ -#line 232 "sql.y" -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } -#line 5715 "sql.c" - 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 */ -#line 233 "sql.y" -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } -#line 5721 "sql.c" - 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 */ -#line 235 "sql.y" -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } -#line 5727 "sql.c" - 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 */ -#line 236 "sql.y" -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } -#line 5733 "sql.c" - 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 */ -#line 237 "sql.y" -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_RETENTIONS, yymsp[0].minor.yy712); } -#line 5739 "sql.c" - 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 */ -#line 238 "sql.y" -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } -#line 5745 "sql.c" - 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 */ -#line 239 "sql.y" -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_WAL, &yymsp[0].minor.yy0); } -#line 5751 "sql.c" - 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 */ -#line 240 "sql.y" -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } -#line 5757 "sql.c" - 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 */ -#line 241 "sql.y" -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } -#line 5763 "sql.c" - 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 */ -#line 242 "sql.y" + 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); } -#line 5773 "sql.c" - yymsp[-3].minor.yy56 = yylhsminor.yy56; + yymsp[-3].minor.yy80 = yylhsminor.yy80; break; - case 118: /* db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ -#line 247 "sql.y" -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } -#line 5779 "sql.c" - 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 */ -#line 248 "sql.y" + 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); } -#line 5789 "sql.c" - yymsp[-3].minor.yy56 = yylhsminor.yy56; + yymsp[-3].minor.yy80 = yylhsminor.yy80; break; - case 120: /* db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ -#line 253 "sql.y" -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } -#line 5795 "sql.c" - 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 */ -#line 254 "sql.y" -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } -#line 5801 "sql.c" - 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 */ -#line 255 "sql.y" -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } -#line 5807 "sql.c" - 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 */ -#line 256 "sql.y" -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_TABLE_PREFIX, yymsp[0].minor.yy56); } -#line 5813 "sql.c" - 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 */ -#line 257 "sql.y" -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_TABLE_SUFFIX, yymsp[0].minor.yy56); } -#line 5819 "sql.c" - 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 */ -#line 258 "sql.y" -{ yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_KEEP_TIME_OFFSET, &yymsp[0].minor.yy0); } -#line 5825 "sql.c" - 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 */ -#line 260 "sql.y" -{ yylhsminor.yy56 = createAlterDatabaseOptions(pCxt); yylhsminor.yy56 = setAlterDatabaseOption(pCxt, yylhsminor.yy56, &yymsp[0].minor.yy893); } -#line 5831 "sql.c" - 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 */ -#line 261 "sql.y" -{ yylhsminor.yy56 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy56, &yymsp[0].minor.yy893); } -#line 5837 "sql.c" - 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 */ -#line 265 "sql.y" -{ yymsp[-1].minor.yy893.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } -#line 5843 "sql.c" + 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 */ -#line 266 "sql.y" -{ yymsp[-1].minor.yy893.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } -#line 5848 "sql.c" + 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 */ -#line 267 "sql.y" -{ yymsp[-1].minor.yy893.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } -#line 5853 "sql.c" + 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 */ -#line 268 "sql.y" -{ yymsp[-1].minor.yy893.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } -#line 5858 "sql.c" + 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); -#line 269 "sql.y" -{ yymsp[-1].minor.yy893.type = DB_OPTION_KEEP; yymsp[-1].minor.yy893.pList = yymsp[0].minor.yy712; } -#line 5864 "sql.c" + 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 */ -#line 271 "sql.y" -{ yymsp[-1].minor.yy893.type = DB_OPTION_PAGES; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } -#line 5869 "sql.c" + 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 */ -#line 272 "sql.y" -{ yymsp[-1].minor.yy893.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } -#line 5874 "sql.c" + 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 */ -#line 274 "sql.y" -{ yymsp[-1].minor.yy893.type = DB_OPTION_WAL; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } -#line 5879 "sql.c" + 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 */ -#line 275 "sql.y" -{ yymsp[-1].minor.yy893.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } -#line 5884 "sql.c" + 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 */ -#line 276 "sql.y" -{ yymsp[-1].minor.yy893.type = DB_OPTION_MINROWS; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } -#line 5889 "sql.c" + 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 */ -#line 277 "sql.y" -{ yymsp[-1].minor.yy893.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } -#line 5894 "sql.c" + 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 */ -#line 278 "sql.y" + 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; } -#line 5903 "sql.c" break; - case 141: /* alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER */ -#line 283 "sql.y" -{ yymsp[-1].minor.yy893.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } -#line 5908 "sql.c" + 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 */ -#line 284 "sql.y" + 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; } -#line 5917 "sql.c" - break; - case 143: /* alter_db_option ::= KEEP_TIME_OFFSET NK_INTEGER */ -#line 289 "sql.y" -{ yymsp[-1].minor.yy893.type = DB_OPTION_KEEP_TIME_OFFSET; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } -#line 5922 "sql.c" - break; - case 144: /* integer_list ::= NK_INTEGER */ -#line 293 "sql.y" -{ yylhsminor.yy712 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } -#line 5927 "sql.c" - yymsp[0].minor.yy712 = yylhsminor.yy712; - break; - case 145: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ - case 387: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==387); -#line 294 "sql.y" -{ yylhsminor.yy712 = addNodeToList(pCxt, yymsp[-2].minor.yy712, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } -#line 5934 "sql.c" - yymsp[-2].minor.yy712 = yylhsminor.yy712; - break; - case 146: /* variable_list ::= NK_VARIABLE */ -#line 298 "sql.y" -{ yylhsminor.yy712 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } -#line 5940 "sql.c" - yymsp[0].minor.yy712 = yylhsminor.yy712; - break; - case 147: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ -#line 299 "sql.y" -{ yylhsminor.yy712 = addNodeToList(pCxt, yymsp[-2].minor.yy712, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } -#line 5946 "sql.c" - yymsp[-2].minor.yy712 = yylhsminor.yy712; - break; - case 148: /* retention_list ::= retention */ - case 178: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==178); - case 181: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==181); - case 188: /* column_def_list ::= column_def */ yytestcase(yyruleno==188); - case 232: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==232); - case 237: /* col_name_list ::= col_name */ yytestcase(yyruleno==237); - case 297: /* tag_list_opt ::= tag_item */ yytestcase(yyruleno==297); - case 314: /* func_list ::= func */ yytestcase(yyruleno==314); - case 416: /* literal_list ::= signed_literal */ yytestcase(yyruleno==416); - case 486: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==486); - case 492: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==492); - case 551: /* select_list ::= select_item */ yytestcase(yyruleno==551); - case 562: /* partition_list ::= partition_item */ yytestcase(yyruleno==562); - case 621: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==621); -#line 303 "sql.y" -{ yylhsminor.yy712 = createNodeList(pCxt, yymsp[0].minor.yy56); } -#line 5965 "sql.c" - yymsp[0].minor.yy712 = yylhsminor.yy712; - break; - case 149: /* retention_list ::= retention_list NK_COMMA retention */ - case 182: /* multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause */ yytestcase(yyruleno==182); - case 189: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==189); - case 233: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==233); - case 238: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==238); - case 298: /* tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ yytestcase(yyruleno==298); - case 315: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==315); - case 417: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==417); - case 487: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==487); - case 552: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==552); - case 563: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==563); - case 622: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==622); -#line 304 "sql.y" -{ yylhsminor.yy712 = addNodeToList(pCxt, yymsp[-2].minor.yy712, yymsp[0].minor.yy56); } -#line 5982 "sql.c" - yymsp[-2].minor.yy712 = yylhsminor.yy712; - break; - case 150: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ -#line 306 "sql.y" -{ yylhsminor.yy56 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } -#line 5988 "sql.c" - yymsp[-2].minor.yy56 = yylhsminor.yy56; - break; - case 151: /* speed_opt ::= */ - case 348: /* bufsize_opt ::= */ yytestcase(yyruleno==348); -#line 310 "sql.y" -{ yymsp[1].minor.yy676 = 0; } -#line 5995 "sql.c" - break; - case 152: /* speed_opt ::= BWLIMIT NK_INTEGER */ - case 349: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==349); -#line 311 "sql.y" -{ yymsp[-1].minor.yy676 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } -#line 6001 "sql.c" - break; - case 154: /* start_opt ::= START WITH NK_INTEGER */ - case 158: /* end_opt ::= END WITH NK_INTEGER */ yytestcase(yyruleno==158); -#line 314 "sql.y" -{ yymsp[-2].minor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } -#line 6007 "sql.c" - break; - case 155: /* start_opt ::= START WITH NK_STRING */ - case 159: /* end_opt ::= END WITH NK_STRING */ yytestcase(yyruleno==159); -#line 315 "sql.y" -{ yymsp[-2].minor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } -#line 6013 "sql.c" - break; - case 156: /* start_opt ::= START WITH TIMESTAMP NK_STRING */ - case 160: /* end_opt ::= END WITH TIMESTAMP NK_STRING */ yytestcase(yyruleno==160); -#line 316 "sql.y" -{ yymsp[-3].minor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } -#line 6019 "sql.c" - break; - case 161: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - case 163: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==163); -#line 325 "sql.y" -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy425, yymsp[-5].minor.yy56, yymsp[-3].minor.yy712, yymsp[-1].minor.yy712, yymsp[0].minor.yy56); } -#line 6025 "sql.c" - break; - case 162: /* cmd ::= CREATE TABLE multi_create_clause */ -#line 326 "sql.y" -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy712); } -#line 6030 "sql.c" - break; - case 164: /* cmd ::= DROP TABLE multi_drop_clause */ -#line 329 "sql.y" -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy712); } -#line 6035 "sql.c" - break; - case 165: /* cmd ::= DROP STABLE exists_opt full_table_name */ -#line 330 "sql.y" -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy425, yymsp[0].minor.yy56); } -#line 6040 "sql.c" - break; - case 166: /* cmd ::= ALTER TABLE alter_table_clause */ - case 389: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==389); - case 390: /* cmd ::= insert_query */ yytestcase(yyruleno==390); -#line 332 "sql.y" -{ pCxt->pRootNode = yymsp[0].minor.yy56; } -#line 6047 "sql.c" - break; - case 167: /* cmd ::= ALTER STABLE alter_table_clause */ -#line 333 "sql.y" -{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy56); } -#line 6052 "sql.c" - break; - case 168: /* alter_table_clause ::= full_table_name alter_table_options */ -#line 335 "sql.y" -{ yylhsminor.yy56 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy56, yymsp[0].minor.yy56); } -#line 6057 "sql.c" - yymsp[-1].minor.yy56 = yylhsminor.yy56; - break; - case 169: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ -#line 337 "sql.y" -{ yylhsminor.yy56 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy56, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy785, yymsp[0].minor.yy448); } -#line 6063 "sql.c" - yymsp[-4].minor.yy56 = yylhsminor.yy56; - break; - case 170: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ -#line 338 "sql.y" -{ yylhsminor.yy56 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy56, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy785); } -#line 6069 "sql.c" - yymsp[-3].minor.yy56 = yylhsminor.yy56; - break; - case 171: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ -#line 340 "sql.y" -{ yylhsminor.yy56 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy56, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy785, yymsp[0].minor.yy448); } -#line 6075 "sql.c" - yymsp[-4].minor.yy56 = yylhsminor.yy56; - break; - case 172: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ -#line 342 "sql.y" -{ yylhsminor.yy56 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy56, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy785, &yymsp[0].minor.yy785); } -#line 6081 "sql.c" - yymsp[-4].minor.yy56 = yylhsminor.yy56; - break; - case 173: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ -#line 344 "sql.y" -{ yylhsminor.yy56 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy56, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy785, yymsp[0].minor.yy448); } -#line 6087 "sql.c" - yymsp[-4].minor.yy56 = yylhsminor.yy56; - break; - case 174: /* alter_table_clause ::= full_table_name DROP TAG column_name */ -#line 345 "sql.y" -{ yylhsminor.yy56 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy56, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy785); } -#line 6093 "sql.c" - yymsp[-3].minor.yy56 = yylhsminor.yy56; - break; - case 175: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ -#line 347 "sql.y" -{ yylhsminor.yy56 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy56, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy785, yymsp[0].minor.yy448); } -#line 6099 "sql.c" - yymsp[-4].minor.yy56 = yylhsminor.yy56; - break; - case 176: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ -#line 349 "sql.y" -{ yylhsminor.yy56 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy56, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy785, &yymsp[0].minor.yy785); } -#line 6105 "sql.c" - yymsp[-4].minor.yy56 = yylhsminor.yy56; - break; - case 177: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ -#line 351 "sql.y" -{ yylhsminor.yy56 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy56, &yymsp[-2].minor.yy785, yymsp[0].minor.yy56); } -#line 6111 "sql.c" - yymsp[-5].minor.yy56 = yylhsminor.yy56; - break; - case 179: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ - case 493: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==493); -#line 356 "sql.y" -{ yylhsminor.yy712 = addNodeToList(pCxt, yymsp[-1].minor.yy712, yymsp[0].minor.yy56); } -#line 6118 "sql.c" - yymsp[-1].minor.yy712 = yylhsminor.yy712; - break; - case 180: /* 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 */ -#line 360 "sql.y" -{ 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); } -#line 6124 "sql.c" - yymsp[-9].minor.yy56 = yylhsminor.yy56; - break; - case 183: /* drop_table_clause ::= exists_opt full_table_name */ -#line 367 "sql.y" -{ yylhsminor.yy56 = createDropTableClause(pCxt, yymsp[-1].minor.yy425, yymsp[0].minor.yy56); } -#line 6130 "sql.c" - yymsp[-1].minor.yy56 = yylhsminor.yy56; - break; - case 185: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */ - case 359: /* col_list_opt ::= NK_LP col_name_list NK_RP */ yytestcase(yyruleno==359); -#line 372 "sql.y" -{ yymsp[-2].minor.yy712 = yymsp[-1].minor.yy712; } -#line 6137 "sql.c" - break; - case 186: /* full_table_name ::= table_name */ -#line 374 "sql.y" -{ yylhsminor.yy56 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy785, NULL); } -#line 6142 "sql.c" - yymsp[0].minor.yy56 = yylhsminor.yy56; - break; - case 187: /* full_table_name ::= db_name NK_DOT table_name */ -#line 375 "sql.y" -{ yylhsminor.yy56 = createRealTableNode(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy785, NULL); } -#line 6148 "sql.c" - yymsp[-2].minor.yy56 = yylhsminor.yy56; - break; - case 190: /* column_def ::= column_name type_name */ -#line 382 "sql.y" -{ yylhsminor.yy56 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy785, yymsp[0].minor.yy448, NULL); } -#line 6154 "sql.c" - yymsp[-1].minor.yy56 = yylhsminor.yy56; - break; - case 191: /* type_name ::= BOOL */ -#line 387 "sql.y" -{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_BOOL); } -#line 6160 "sql.c" - break; - case 192: /* type_name ::= TINYINT */ -#line 388 "sql.y" -{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_TINYINT); } -#line 6165 "sql.c" - break; - case 193: /* type_name ::= SMALLINT */ -#line 389 "sql.y" -{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_SMALLINT); } -#line 6170 "sql.c" - break; - case 194: /* type_name ::= INT */ - case 195: /* type_name ::= INTEGER */ yytestcase(yyruleno==195); -#line 390 "sql.y" -{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_INT); } -#line 6176 "sql.c" - break; - case 196: /* type_name ::= BIGINT */ -#line 392 "sql.y" -{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_BIGINT); } -#line 6181 "sql.c" - break; - case 197: /* type_name ::= FLOAT */ -#line 393 "sql.y" -{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_FLOAT); } -#line 6186 "sql.c" - break; - case 198: /* type_name ::= DOUBLE */ -#line 394 "sql.y" -{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_DOUBLE); } -#line 6191 "sql.c" - break; - case 199: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -#line 395 "sql.y" -{ yymsp[-3].minor.yy448 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } -#line 6196 "sql.c" - break; - case 200: /* type_name ::= TIMESTAMP */ -#line 396 "sql.y" -{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } -#line 6201 "sql.c" - break; - case 201: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -#line 397 "sql.y" -{ yymsp[-3].minor.yy448 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } -#line 6206 "sql.c" - break; - case 202: /* type_name ::= TINYINT UNSIGNED */ -#line 398 "sql.y" -{ yymsp[-1].minor.yy448 = createDataType(TSDB_DATA_TYPE_UTINYINT); } -#line 6211 "sql.c" - break; - case 203: /* type_name ::= SMALLINT UNSIGNED */ -#line 399 "sql.y" -{ yymsp[-1].minor.yy448 = createDataType(TSDB_DATA_TYPE_USMALLINT); } -#line 6216 "sql.c" - break; - case 204: /* type_name ::= INT UNSIGNED */ -#line 400 "sql.y" -{ yymsp[-1].minor.yy448 = createDataType(TSDB_DATA_TYPE_UINT); } -#line 6221 "sql.c" - break; - case 205: /* type_name ::= BIGINT UNSIGNED */ -#line 401 "sql.y" -{ yymsp[-1].minor.yy448 = createDataType(TSDB_DATA_TYPE_UBIGINT); } -#line 6226 "sql.c" - break; - case 206: /* type_name ::= JSON */ -#line 402 "sql.y" -{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_JSON); } -#line 6231 "sql.c" - break; - case 207: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -#line 403 "sql.y" -{ yymsp[-3].minor.yy448 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } -#line 6236 "sql.c" - break; - case 208: /* type_name ::= MEDIUMBLOB */ -#line 404 "sql.y" -{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } -#line 6241 "sql.c" - break; - case 209: /* type_name ::= BLOB */ -#line 405 "sql.y" -{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_BLOB); } -#line 6246 "sql.c" - break; - case 210: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -#line 406 "sql.y" -{ yymsp[-3].minor.yy448 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } -#line 6251 "sql.c" - break; - case 211: /* type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP */ -#line 407 "sql.y" -{ yymsp[-3].minor.yy448 = createVarLenDataType(TSDB_DATA_TYPE_GEOMETRY, &yymsp[-1].minor.yy0); } -#line 6256 "sql.c" - break; - case 212: /* type_name ::= DECIMAL */ -#line 408 "sql.y" -{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_DECIMAL); } -#line 6261 "sql.c" - break; - case 213: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -#line 409 "sql.y" -{ yymsp[-3].minor.yy448 = createDataType(TSDB_DATA_TYPE_DECIMAL); } -#line 6266 "sql.c" - break; - case 214: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -#line 410 "sql.y" -{ yymsp[-5].minor.yy448 = createDataType(TSDB_DATA_TYPE_DECIMAL); } -#line 6271 "sql.c" - break; - case 217: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ - case 362: /* tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP */ yytestcase(yyruleno==362); -#line 419 "sql.y" -{ yymsp[-3].minor.yy712 = yymsp[-1].minor.yy712; } -#line 6277 "sql.c" - break; - case 218: /* table_options ::= */ -#line 421 "sql.y" -{ yymsp[1].minor.yy56 = createDefaultTableOptions(pCxt); } -#line 6282 "sql.c" - break; - case 219: /* table_options ::= table_options COMMENT NK_STRING */ -#line 422 "sql.y" -{ yylhsminor.yy56 = setTableOption(pCxt, yymsp[-2].minor.yy56, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } -#line 6287 "sql.c" - yymsp[-2].minor.yy56 = yylhsminor.yy56; - break; - case 220: /* table_options ::= table_options MAX_DELAY duration_list */ -#line 423 "sql.y" -{ yylhsminor.yy56 = setTableOption(pCxt, yymsp[-2].minor.yy56, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy712); } -#line 6293 "sql.c" - yymsp[-2].minor.yy56 = yylhsminor.yy56; - break; - case 221: /* table_options ::= table_options WATERMARK duration_list */ -#line 424 "sql.y" -{ yylhsminor.yy56 = setTableOption(pCxt, yymsp[-2].minor.yy56, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy712); } -#line 6299 "sql.c" - yymsp[-2].minor.yy56 = yylhsminor.yy56; - break; - case 222: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ -#line 425 "sql.y" -{ yylhsminor.yy56 = setTableOption(pCxt, yymsp[-4].minor.yy56, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy712); } -#line 6305 "sql.c" - yymsp[-4].minor.yy56 = yylhsminor.yy56; - break; - case 223: /* table_options ::= table_options TTL NK_INTEGER */ -#line 426 "sql.y" -{ yylhsminor.yy56 = setTableOption(pCxt, yymsp[-2].minor.yy56, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } -#line 6311 "sql.c" - yymsp[-2].minor.yy56 = yylhsminor.yy56; - break; - case 224: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -#line 427 "sql.y" -{ yylhsminor.yy56 = setTableOption(pCxt, yymsp[-4].minor.yy56, TABLE_OPTION_SMA, yymsp[-1].minor.yy712); } -#line 6317 "sql.c" - yymsp[-4].minor.yy56 = yylhsminor.yy56; - break; - case 225: /* table_options ::= table_options DELETE_MARK duration_list */ -#line 428 "sql.y" -{ yylhsminor.yy56 = setTableOption(pCxt, yymsp[-2].minor.yy56, TABLE_OPTION_DELETE_MARK, yymsp[0].minor.yy712); } -#line 6323 "sql.c" - yymsp[-2].minor.yy56 = yylhsminor.yy56; - break; - case 226: /* alter_table_options ::= alter_table_option */ -#line 430 "sql.y" -{ yylhsminor.yy56 = createAlterTableOptions(pCxt); yylhsminor.yy56 = setTableOption(pCxt, yylhsminor.yy56, yymsp[0].minor.yy893.type, &yymsp[0].minor.yy893.val); } -#line 6329 "sql.c" - yymsp[0].minor.yy56 = yylhsminor.yy56; - break; - case 227: /* alter_table_options ::= alter_table_options alter_table_option */ -#line 431 "sql.y" -{ yylhsminor.yy56 = setTableOption(pCxt, yymsp[-1].minor.yy56, yymsp[0].minor.yy893.type, &yymsp[0].minor.yy893.val); } -#line 6335 "sql.c" - yymsp[-1].minor.yy56 = yylhsminor.yy56; - break; - case 228: /* alter_table_option ::= COMMENT NK_STRING */ -#line 435 "sql.y" -{ yymsp[-1].minor.yy893.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } -#line 6341 "sql.c" - break; - case 229: /* alter_table_option ::= TTL NK_INTEGER */ -#line 436 "sql.y" -{ yymsp[-1].minor.yy893.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } -#line 6346 "sql.c" - break; - case 230: /* duration_list ::= duration_literal */ - case 447: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==447); -#line 440 "sql.y" -{ yylhsminor.yy712 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy56)); } -#line 6352 "sql.c" - yymsp[0].minor.yy712 = yylhsminor.yy712; - break; - case 231: /* duration_list ::= duration_list NK_COMMA duration_literal */ - case 448: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==448); -#line 441 "sql.y" -{ yylhsminor.yy712 = addNodeToList(pCxt, yymsp[-2].minor.yy712, releaseRawExprNode(pCxt, yymsp[0].minor.yy56)); } -#line 6359 "sql.c" - yymsp[-2].minor.yy712 = yylhsminor.yy712; - break; - case 234: /* rollup_func_name ::= function_name */ -#line 448 "sql.y" -{ yylhsminor.yy56 = createFunctionNode(pCxt, &yymsp[0].minor.yy785, NULL); } -#line 6365 "sql.c" - yymsp[0].minor.yy56 = yylhsminor.yy56; - break; - case 235: /* rollup_func_name ::= FIRST */ - case 236: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==236); - case 300: /* tag_item ::= QTAGS */ yytestcase(yyruleno==300); -#line 449 "sql.y" -{ yylhsminor.yy56 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } -#line 6373 "sql.c" - yymsp[0].minor.yy56 = yylhsminor.yy56; - break; - case 239: /* col_name ::= column_name */ - case 301: /* tag_item ::= column_name */ yytestcase(yyruleno==301); -#line 457 "sql.y" -{ yylhsminor.yy56 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy785); } -#line 6380 "sql.c" - yymsp[0].minor.yy56 = yylhsminor.yy56; - break; - case 240: /* cmd ::= SHOW DNODES */ -#line 460 "sql.y" + break; + 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 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 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 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 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 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 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 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 188: /* full_table_name ::= table_name */ +{ yylhsminor.yy80 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy785, NULL); } + yymsp[0].minor.yy80 = yylhsminor.yy80; + break; + 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 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 193: /* type_name ::= BOOL */ +{ yymsp[0].minor.yy292 = createDataType(TSDB_DATA_TYPE_BOOL); } + break; + case 194: /* type_name ::= TINYINT */ +{ yymsp[0].minor.yy292 = createDataType(TSDB_DATA_TYPE_TINYINT); } + break; + case 195: /* type_name ::= SMALLINT */ +{ yymsp[0].minor.yy292 = createDataType(TSDB_DATA_TYPE_SMALLINT); } + break; + case 196: /* type_name ::= INT */ + case 197: /* type_name ::= INTEGER */ yytestcase(yyruleno==197); +{ yymsp[0].minor.yy292 = createDataType(TSDB_DATA_TYPE_INT); } + break; + case 198: /* type_name ::= BIGINT */ +{ yymsp[0].minor.yy292 = createDataType(TSDB_DATA_TYPE_BIGINT); } + break; + case 199: /* type_name ::= FLOAT */ +{ yymsp[0].minor.yy292 = createDataType(TSDB_DATA_TYPE_FLOAT); } + break; + case 200: /* type_name ::= DOUBLE */ +{ yymsp[0].minor.yy292 = createDataType(TSDB_DATA_TYPE_DOUBLE); } + break; + 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 202: /* type_name ::= TIMESTAMP */ +{ yymsp[0].minor.yy292 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } + break; + 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 204: /* type_name ::= TINYINT UNSIGNED */ +{ yymsp[-1].minor.yy292 = createDataType(TSDB_DATA_TYPE_UTINYINT); } + break; + case 205: /* type_name ::= SMALLINT UNSIGNED */ +{ yymsp[-1].minor.yy292 = createDataType(TSDB_DATA_TYPE_USMALLINT); } + break; + case 206: /* type_name ::= INT UNSIGNED */ +{ yymsp[-1].minor.yy292 = createDataType(TSDB_DATA_TYPE_UINT); } + break; + case 207: /* type_name ::= BIGINT UNSIGNED */ +{ yymsp[-1].minor.yy292 = createDataType(TSDB_DATA_TYPE_UBIGINT); } + break; + case 208: /* type_name ::= JSON */ +{ yymsp[0].minor.yy292 = createDataType(TSDB_DATA_TYPE_JSON); } + break; + 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 210: /* type_name ::= MEDIUMBLOB */ +{ yymsp[0].minor.yy292 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } + break; + case 211: /* type_name ::= BLOB */ +{ yymsp[0].minor.yy292 = createDataType(TSDB_DATA_TYPE_BLOB); } + break; + 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 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 214: /* type_name ::= DECIMAL */ +{ yymsp[0].minor.yy292 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + break; + case 215: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy292 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + break; + 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 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 220: /* table_options ::= */ +{ yymsp[1].minor.yy80 = createDefaultTableOptions(pCxt); } + break; + 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 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 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 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 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 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 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 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 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 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 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 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 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 236: /* rollup_func_name ::= function_name */ +{ yylhsminor.yy80 = createFunctionNode(pCxt, &yymsp[0].minor.yy785, NULL); } + yymsp[0].minor.yy80 = yylhsminor.yy80; + break; + 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 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 242: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT); } -#line 6386 "sql.c" break; - case 241: /* cmd ::= SHOW USERS */ -#line 461 "sql.y" + case 243: /* cmd ::= SHOW USERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT); } -#line 6391 "sql.c" break; - case 242: /* cmd ::= SHOW USER PRIVILEGES */ -#line 462 "sql.y" + case 244: /* cmd ::= SHOW USER PRIVILEGES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USER_PRIVILEGES_STMT); } -#line 6396 "sql.c" break; - case 243: /* cmd ::= SHOW db_kind_opt DATABASES */ -#line 463 "sql.y" + 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); } -#line 6404 "sql.c" break; - case 244: /* cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt */ -#line 467 "sql.y" + 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); } -#line 6411 "sql.c" break; - case 245: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ -#line 470 "sql.y" -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy56, yymsp[0].minor.yy56, OP_TYPE_LIKE); } -#line 6416 "sql.c" + 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 246: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ -#line 471 "sql.y" -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy56, NULL, OP_TYPE_LIKE); } -#line 6421 "sql.c" + 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 247: /* cmd ::= SHOW MNODES */ -#line 472 "sql.y" + case 249: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); } -#line 6426 "sql.c" break; - case 248: /* cmd ::= SHOW QNODES */ -#line 474 "sql.y" + case 250: /* cmd ::= SHOW QNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT); } -#line 6431 "sql.c" break; - case 249: /* cmd ::= SHOW FUNCTIONS */ -#line 475 "sql.y" + case 251: /* cmd ::= SHOW FUNCTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT); } -#line 6436 "sql.c" break; - case 250: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ -#line 476 "sql.y" -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy56, yymsp[-1].minor.yy56, OP_TYPE_EQUAL); } -#line 6441 "sql.c" + 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 251: /* cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name */ -#line 477 "sql.y" + 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); } -#line 6446 "sql.c" break; - case 252: /* cmd ::= SHOW STREAMS */ -#line 478 "sql.y" + case 254: /* cmd ::= SHOW STREAMS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT); } -#line 6451 "sql.c" break; - case 253: /* cmd ::= SHOW ACCOUNTS */ -#line 479 "sql.y" + case 255: /* cmd ::= SHOW ACCOUNTS */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } -#line 6456 "sql.c" break; - case 254: /* cmd ::= SHOW APPS */ -#line 480 "sql.y" + case 256: /* cmd ::= SHOW APPS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_APPS_STMT); } -#line 6461 "sql.c" break; - case 255: /* cmd ::= SHOW CONNECTIONS */ -#line 481 "sql.y" + case 257: /* cmd ::= SHOW CONNECTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONNECTIONS_STMT); } -#line 6466 "sql.c" break; - case 256: /* cmd ::= SHOW LICENCES */ - case 257: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==257); -#line 482 "sql.y" + case 258: /* cmd ::= SHOW LICENCES */ + case 259: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==259); { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCES_STMT); } -#line 6472 "sql.c" break; - case 258: /* cmd ::= SHOW CREATE DATABASE db_name */ -#line 484 "sql.y" + case 260: /* cmd ::= SHOW CREATE DATABASE db_name */ { pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy785); } -#line 6477 "sql.c" break; - case 259: /* cmd ::= SHOW CREATE TABLE full_table_name */ -#line 485 "sql.y" -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy56); } -#line 6482 "sql.c" + 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 260: /* cmd ::= SHOW CREATE STABLE full_table_name */ -#line 486 "sql.y" -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy56); } -#line 6487 "sql.c" + 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 261: /* cmd ::= SHOW QUERIES */ -#line 487 "sql.y" + case 263: /* cmd ::= SHOW QUERIES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); } -#line 6492 "sql.c" break; - case 262: /* cmd ::= SHOW SCORES */ -#line 488 "sql.y" + case 264: /* cmd ::= SHOW SCORES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SCORES_STMT); } -#line 6497 "sql.c" break; - case 263: /* cmd ::= SHOW TOPICS */ -#line 489 "sql.y" + case 265: /* cmd ::= SHOW TOPICS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TOPICS_STMT); } -#line 6502 "sql.c" break; - case 264: /* cmd ::= SHOW VARIABLES */ - case 265: /* cmd ::= SHOW CLUSTER VARIABLES */ yytestcase(yyruleno==265); -#line 490 "sql.y" + case 266: /* cmd ::= SHOW VARIABLES */ + case 267: /* cmd ::= SHOW CLUSTER VARIABLES */ yytestcase(yyruleno==267); { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VARIABLES_STMT); } -#line 6508 "sql.c" break; - case 266: /* cmd ::= SHOW LOCAL VARIABLES */ -#line 492 "sql.y" + case 268: /* cmd ::= SHOW LOCAL VARIABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT); } -#line 6513 "sql.c" break; - case 267: /* cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ -#line 493 "sql.y" -{ pCxt->pRootNode = createShowDnodeVariablesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[-2].minor.yy0), yymsp[0].minor.yy56); } -#line 6518 "sql.c" + 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 268: /* cmd ::= SHOW BNODES */ -#line 494 "sql.y" + case 270: /* cmd ::= SHOW BNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT); } -#line 6523 "sql.c" break; - case 269: /* cmd ::= SHOW SNODES */ -#line 495 "sql.y" + case 271: /* cmd ::= SHOW SNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SNODES_STMT); } -#line 6528 "sql.c" break; - case 270: /* cmd ::= SHOW CLUSTER */ -#line 496 "sql.y" + case 272: /* cmd ::= SHOW CLUSTER */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_STMT); } -#line 6533 "sql.c" break; - case 271: /* cmd ::= SHOW TRANSACTIONS */ -#line 497 "sql.y" + case 273: /* cmd ::= SHOW TRANSACTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); } -#line 6538 "sql.c" break; - case 272: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ -#line 498 "sql.y" -{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy56); } -#line 6543 "sql.c" + case 274: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ +{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy80); } break; - case 273: /* cmd ::= SHOW CONSUMERS */ -#line 499 "sql.y" + case 275: /* cmd ::= SHOW CONSUMERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); } -#line 6548 "sql.c" break; - case 274: /* cmd ::= SHOW SUBSCRIPTIONS */ -#line 500 "sql.y" + case 276: /* cmd ::= SHOW SUBSCRIPTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); } -#line 6553 "sql.c" break; - case 275: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ -#line 501 "sql.y" -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy56, yymsp[-1].minor.yy56, OP_TYPE_EQUAL); } -#line 6558 "sql.c" + 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 276: /* cmd ::= SHOW TAGS FROM db_name NK_DOT table_name */ -#line 502 "sql.y" + 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); } -#line 6563 "sql.c" break; - case 277: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ -#line 503 "sql.y" -{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, yymsp[-1].minor.yy56, yymsp[0].minor.yy56, yymsp[-3].minor.yy712); } -#line 6568 "sql.c" + 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 278: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name */ -#line 504 "sql.y" -{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, createIdentifierValueNode(pCxt, &yymsp[0].minor.yy785), createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy785), yymsp[-4].minor.yy712); } -#line 6573 "sql.c" + 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 279: /* cmd ::= SHOW VNODES ON DNODE NK_INTEGER */ -#line 505 "sql.y" + case 281: /* cmd ::= SHOW VNODES ON DNODE NK_INTEGER */ { pCxt->pRootNode = createShowVnodesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0), NULL); } -#line 6578 "sql.c" break; - case 280: /* cmd ::= SHOW VNODES */ -#line 506 "sql.y" + case 282: /* cmd ::= SHOW VNODES */ { pCxt->pRootNode = createShowVnodesStmt(pCxt, NULL, NULL); } -#line 6583 "sql.c" break; - case 281: /* cmd ::= SHOW db_name_cond_opt ALIVE */ -#line 508 "sql.y" -{ pCxt->pRootNode = createShowAliveStmt(pCxt, yymsp[-1].minor.yy56, QUERY_NODE_SHOW_DB_ALIVE_STMT); } -#line 6588 "sql.c" + 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 282: /* cmd ::= SHOW CLUSTER ALIVE */ -#line 509 "sql.y" + case 284: /* cmd ::= SHOW CLUSTER ALIVE */ { pCxt->pRootNode = createShowAliveStmt(pCxt, NULL, QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT); } -#line 6593 "sql.c" break; - case 283: /* table_kind_db_name_cond_opt ::= */ -#line 513 "sql.y" -{ yymsp[1].minor.yy205.kind = SHOW_KIND_ALL; yymsp[1].minor.yy205.dbName = nil_token; } -#line 6598 "sql.c" + 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 284: /* table_kind_db_name_cond_opt ::= table_kind */ -#line 514 "sql.y" -{ yylhsminor.yy205.kind = yymsp[0].minor.yy33; yylhsminor.yy205.dbName = nil_token; } -#line 6603 "sql.c" - 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 285: /* table_kind_db_name_cond_opt ::= db_name NK_DOT */ -#line 515 "sql.y" -{ yylhsminor.yy205.kind = SHOW_KIND_ALL; yylhsminor.yy205.dbName = yymsp[-1].minor.yy785; } -#line 6609 "sql.c" - 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 286: /* table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ -#line 516 "sql.y" -{ yylhsminor.yy205.kind = yymsp[-2].minor.yy33; yylhsminor.yy205.dbName = yymsp[-1].minor.yy785; } -#line 6615 "sql.c" - 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 287: /* table_kind ::= NORMAL */ -#line 520 "sql.y" -{ yymsp[0].minor.yy33 = SHOW_KIND_TABLES_NORMAL; } -#line 6621 "sql.c" + 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 288: /* table_kind ::= CHILD */ -#line 521 "sql.y" -{ yymsp[0].minor.yy33 = SHOW_KIND_TABLES_CHILD; } -#line 6626 "sql.c" + 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 289: /* db_name_cond_opt ::= */ - case 294: /* from_db_opt ::= */ yytestcase(yyruleno==294); -#line 523 "sql.y" -{ yymsp[1].minor.yy56 = createDefaultDatabaseCondValue(pCxt); } -#line 6632 "sql.c" + case 291: /* table_kind ::= NORMAL */ +{ yymsp[0].minor.yy459 = SHOW_KIND_TABLES_NORMAL; } break; - case 290: /* db_name_cond_opt ::= db_name NK_DOT */ -#line 524 "sql.y" -{ yylhsminor.yy56 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy785); } -#line 6637 "sql.c" - yymsp[-1].minor.yy56 = yylhsminor.yy56; + case 292: /* table_kind ::= CHILD */ +{ yymsp[0].minor.yy459 = SHOW_KIND_TABLES_CHILD; } break; - case 292: /* like_pattern_opt ::= LIKE NK_STRING */ -#line 527 "sql.y" -{ yymsp[-1].minor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } -#line 6643 "sql.c" + case 293: /* db_name_cond_opt ::= */ + case 298: /* from_db_opt ::= */ yytestcase(yyruleno==298); +{ yymsp[1].minor.yy80 = createDefaultDatabaseCondValue(pCxt); } break; - case 293: /* table_name_cond ::= table_name */ -#line 529 "sql.y" -{ yylhsminor.yy56 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy785); } -#line 6648 "sql.c" - 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 295: /* from_db_opt ::= FROM db_name */ -#line 532 "sql.y" -{ yymsp[-1].minor.yy56 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy785); } -#line 6654 "sql.c" + case 296: /* like_pattern_opt ::= LIKE NK_STRING */ +{ yymsp[-1].minor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; - case 299: /* tag_item ::= TBNAME */ -#line 540 "sql.y" -{ yylhsminor.yy56 = setProjectionAlias(pCxt, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL), &yymsp[0].minor.yy0); } -#line 6659 "sql.c" - 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 302: /* tag_item ::= column_name column_alias */ -#line 543 "sql.y" -{ yylhsminor.yy56 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy785), &yymsp[0].minor.yy785); } -#line 6665 "sql.c" - 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 303: /* tag_item ::= column_name AS column_alias */ -#line 544 "sql.y" -{ yylhsminor.yy56 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-2].minor.yy785), &yymsp[0].minor.yy785); } -#line 6671 "sql.c" - 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 304: /* db_kind_opt ::= */ -#line 548 "sql.y" -{ yymsp[1].minor.yy33 = SHOW_KIND_ALL; } -#line 6677 "sql.c" + 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 305: /* db_kind_opt ::= USER */ -#line 549 "sql.y" -{ yymsp[0].minor.yy33 = SHOW_KIND_DATABASES_USER; } -#line 6682 "sql.c" + 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 306: /* db_kind_opt ::= SYSTEM */ -#line 550 "sql.y" -{ yymsp[0].minor.yy33 = SHOW_KIND_DATABASES_SYSTEM; } -#line 6687 "sql.c" + case 308: /* db_kind_opt ::= */ +{ yymsp[1].minor.yy459 = SHOW_KIND_ALL; } break; - case 307: /* cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ -#line 554 "sql.y" -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy425, yymsp[-3].minor.yy56, yymsp[-1].minor.yy56, NULL, yymsp[0].minor.yy56); } -#line 6692 "sql.c" + case 309: /* db_kind_opt ::= USER */ +{ yymsp[0].minor.yy459 = SHOW_KIND_DATABASES_USER; } break; - case 308: /* cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ -#line 556 "sql.y" -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, yymsp[-6].minor.yy425, yymsp[-5].minor.yy56, yymsp[-3].minor.yy56, yymsp[-1].minor.yy712, NULL); } -#line 6697 "sql.c" + case 310: /* db_kind_opt ::= SYSTEM */ +{ yymsp[0].minor.yy459 = SHOW_KIND_DATABASES_SYSTEM; } break; - case 309: /* cmd ::= DROP INDEX exists_opt full_index_name */ -#line 557 "sql.y" -{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy425, yymsp[0].minor.yy56); } -#line 6702 "sql.c" + 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 310: /* full_index_name ::= index_name */ -#line 559 "sql.y" -{ yylhsminor.yy56 = createRealTableNodeForIndexName(pCxt, NULL, &yymsp[0].minor.yy785); } -#line 6707 "sql.c" - 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 311: /* full_index_name ::= db_name NK_DOT index_name */ -#line 560 "sql.y" -{ yylhsminor.yy56 = createRealTableNodeForIndexName(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy785); } -#line 6713 "sql.c" - 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 312: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ -#line 563 "sql.y" -{ 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); } -#line 6719 "sql.c" + case 314: /* full_index_name ::= index_name */ +{ yylhsminor.yy80 = createRealTableNodeForIndexName(pCxt, NULL, &yymsp[0].minor.yy785); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 313: /* 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 */ -#line 566 "sql.y" -{ 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); } -#line 6724 "sql.c" + 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 316: /* func ::= sma_func_name NK_LP expression_list NK_RP */ -#line 573 "sql.y" -{ yylhsminor.yy56 = createFunctionNode(pCxt, &yymsp[-3].minor.yy785, yymsp[-1].minor.yy712); } -#line 6729 "sql.c" - 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 317: /* sma_func_name ::= function_name */ - case 536: /* alias_opt ::= table_alias */ yytestcase(yyruleno==536); -#line 577 "sql.y" + 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; } -#line 6736 "sql.c" yymsp[0].minor.yy785 = yylhsminor.yy785; break; - case 322: /* sma_stream_opt ::= */ - case 363: /* stream_options ::= */ yytestcase(yyruleno==363); -#line 583 "sql.y" -{ yymsp[1].minor.yy56 = createStreamOptions(pCxt); } -#line 6743 "sql.c" + case 326: /* sma_stream_opt ::= */ + case 371: /* stream_options ::= */ yytestcase(yyruleno==371); +{ yymsp[1].minor.yy80 = createStreamOptions(pCxt); } break; - case 323: /* sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ -#line 584 "sql.y" -{ ((SStreamOptions*)yymsp[-2].minor.yy56)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy56); yylhsminor.yy56 = yymsp[-2].minor.yy56; } -#line 6748 "sql.c" - 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 324: /* sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ -#line 585 "sql.y" -{ ((SStreamOptions*)yymsp[-2].minor.yy56)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy56); yylhsminor.yy56 = yymsp[-2].minor.yy56; } -#line 6754 "sql.c" - 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 325: /* sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ -#line 586 "sql.y" -{ ((SStreamOptions*)yymsp[-2].minor.yy56)->pDeleteMark = releaseRawExprNode(pCxt, yymsp[0].minor.yy56); yylhsminor.yy56 = yymsp[-2].minor.yy56; } -#line 6760 "sql.c" - 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 326: /* with_meta ::= AS */ -#line 591 "sql.y" -{ yymsp[0].minor.yy676 = 0; } -#line 6766 "sql.c" + case 330: /* with_meta ::= AS */ +{ yymsp[0].minor.yy982 = 0; } break; - case 327: /* with_meta ::= WITH META AS */ -#line 592 "sql.y" -{ yymsp[-2].minor.yy676 = 1; } -#line 6771 "sql.c" + case 331: /* with_meta ::= WITH META AS */ +{ yymsp[-2].minor.yy982 = 1; } break; - case 328: /* with_meta ::= ONLY META AS */ -#line 593 "sql.y" -{ yymsp[-2].minor.yy676 = 2; } -#line 6776 "sql.c" + case 332: /* with_meta ::= ONLY META AS */ +{ yymsp[-2].minor.yy982 = 2; } break; - case 329: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ -#line 595 "sql.y" -{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy425, &yymsp[-2].minor.yy785, yymsp[0].minor.yy56); } -#line 6781 "sql.c" + 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 330: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ -#line 597 "sql.y" -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy425, &yymsp[-3].minor.yy785, &yymsp[0].minor.yy785, yymsp[-2].minor.yy676); } -#line 6786 "sql.c" + 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 331: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ -#line 599 "sql.y" -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-5].minor.yy425, &yymsp[-4].minor.yy785, yymsp[-1].minor.yy56, yymsp[-3].minor.yy676, yymsp[0].minor.yy56); } -#line 6791 "sql.c" + 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 332: /* cmd ::= DROP TOPIC exists_opt topic_name */ -#line 601 "sql.y" -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy425, &yymsp[0].minor.yy785); } -#line 6796 "sql.c" + case 336: /* cmd ::= DROP TOPIC exists_opt topic_name */ +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy923, &yymsp[0].minor.yy785); } break; - case 333: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ -#line 602 "sql.y" -{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy425, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy785); } -#line 6801 "sql.c" + 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 334: /* cmd ::= DESC full_table_name */ - case 335: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==335); -#line 605 "sql.y" -{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy56); } -#line 6807 "sql.c" + 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 336: /* cmd ::= RESET QUERY CACHE */ -#line 609 "sql.y" + case 340: /* cmd ::= RESET QUERY CACHE */ { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } -#line 6812 "sql.c" break; - case 337: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ - case 338: /* cmd ::= EXPLAIN analyze_opt explain_options insert_query */ yytestcase(yyruleno==338); -#line 612 "sql.y" -{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy425, yymsp[-1].minor.yy56, yymsp[0].minor.yy56); } -#line 6818 "sql.c" + 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 341: /* explain_options ::= */ -#line 620 "sql.y" -{ yymsp[1].minor.yy56 = createDefaultExplainOptions(pCxt); } -#line 6823 "sql.c" + case 345: /* explain_options ::= */ +{ yymsp[1].minor.yy80 = createDefaultExplainOptions(pCxt); } break; - case 342: /* explain_options ::= explain_options VERBOSE NK_BOOL */ -#line 621 "sql.y" -{ yylhsminor.yy56 = setExplainVerbose(pCxt, yymsp[-2].minor.yy56, &yymsp[0].minor.yy0); } -#line 6828 "sql.c" - 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 343: /* explain_options ::= explain_options RATIO NK_FLOAT */ -#line 622 "sql.y" -{ yylhsminor.yy56 = setExplainRatio(pCxt, yymsp[-2].minor.yy56, &yymsp[0].minor.yy0); } -#line 6834 "sql.c" - 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 344: /* cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ -#line 627 "sql.y" -{ 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); } -#line 6840 "sql.c" + 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 345: /* cmd ::= DROP FUNCTION exists_opt function_name */ -#line 628 "sql.y" -{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy425, &yymsp[0].minor.yy785); } -#line 6845 "sql.c" + case 349: /* cmd ::= DROP FUNCTION exists_opt function_name */ +{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy923, &yymsp[0].minor.yy785); } break; - case 350: /* language_opt ::= */ - case 384: /* on_vgroup_id ::= */ yytestcase(yyruleno==384); -#line 642 "sql.y" + case 354: /* language_opt ::= */ + case 392: /* on_vgroup_id ::= */ yytestcase(yyruleno==392); { yymsp[1].minor.yy785 = nil_token; } -#line 6851 "sql.c" break; - case 351: /* language_opt ::= LANGUAGE NK_STRING */ - case 385: /* on_vgroup_id ::= ON NK_INTEGER */ yytestcase(yyruleno==385); -#line 643 "sql.y" + 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; } -#line 6857 "sql.c" break; - case 354: /* 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 */ -#line 653 "sql.y" -{ 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); } -#line 6862 "sql.c" + 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 355: /* cmd ::= DROP STREAM exists_opt stream_name */ -#line 654 "sql.y" -{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy425, &yymsp[0].minor.yy785); } -#line 6867 "sql.c" + case 359: /* cmd ::= DROP VIEW exists_opt full_view_name */ +{ pCxt->pRootNode = createDropViewStmt(pCxt, yymsp[-1].minor.yy923, yymsp[0].minor.yy80); } break; - case 356: /* cmd ::= PAUSE STREAM exists_opt stream_name */ -#line 655 "sql.y" -{ pCxt->pRootNode = createPauseStreamStmt(pCxt, yymsp[-1].minor.yy425, &yymsp[0].minor.yy785); } -#line 6872 "sql.c" + case 360: /* full_view_name ::= view_name */ +{ yylhsminor.yy80 = createViewNode(pCxt, NULL, &yymsp[0].minor.yy785); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 357: /* cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ -#line 656 "sql.y" -{ pCxt->pRootNode = createResumeStreamStmt(pCxt, yymsp[-2].minor.yy425, yymsp[-1].minor.yy425, &yymsp[0].minor.yy785); } -#line 6877 "sql.c" + 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 364: /* stream_options ::= stream_options TRIGGER AT_ONCE */ - case 365: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ yytestcase(yyruleno==365); -#line 670 "sql.y" -{ yylhsminor.yy56 = setStreamOptions(pCxt, yymsp[-2].minor.yy56, SOPT_TRIGGER_TYPE_SET, &yymsp[0].minor.yy0, NULL); } -#line 6883 "sql.c" - 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 366: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ -#line 672 "sql.y" -{ yylhsminor.yy56 = setStreamOptions(pCxt, yymsp[-3].minor.yy56, SOPT_TRIGGER_TYPE_SET, &yymsp[-1].minor.yy0, releaseRawExprNode(pCxt, yymsp[0].minor.yy56)); } -#line 6889 "sql.c" - 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 367: /* stream_options ::= stream_options WATERMARK duration_literal */ -#line 673 "sql.y" -{ yylhsminor.yy56 = setStreamOptions(pCxt, yymsp[-2].minor.yy56, SOPT_WATERMARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy56)); } -#line 6895 "sql.c" - 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 368: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ -#line 674 "sql.y" -{ yylhsminor.yy56 = setStreamOptions(pCxt, yymsp[-3].minor.yy56, SOPT_IGNORE_EXPIRED_SET, &yymsp[0].minor.yy0, NULL); } -#line 6901 "sql.c" - 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 369: /* stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ -#line 675 "sql.y" -{ yylhsminor.yy56 = setStreamOptions(pCxt, yymsp[-2].minor.yy56, SOPT_FILL_HISTORY_SET, &yymsp[0].minor.yy0, NULL); } -#line 6907 "sql.c" - 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 370: /* stream_options ::= stream_options DELETE_MARK duration_literal */ -#line 676 "sql.y" -{ yylhsminor.yy56 = setStreamOptions(pCxt, yymsp[-2].minor.yy56, SOPT_DELETE_MARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy56)); } -#line 6913 "sql.c" - 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 371: /* stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ -#line 677 "sql.y" -{ yylhsminor.yy56 = setStreamOptions(pCxt, yymsp[-3].minor.yy56, SOPT_IGNORE_UPDATE_SET, &yymsp[0].minor.yy0, NULL); } -#line 6919 "sql.c" - 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 373: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - case 574: /* sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ yytestcase(yyruleno==574); - case 598: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==598); -#line 680 "sql.y" -{ yymsp[-3].minor.yy56 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy56); } -#line 6927 "sql.c" + 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 376: /* cmd ::= KILL CONNECTION NK_INTEGER */ -#line 688 "sql.y" + 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); } -#line 6932 "sql.c" break; - case 377: /* cmd ::= KILL QUERY NK_STRING */ -#line 689 "sql.y" + case 385: /* cmd ::= KILL QUERY NK_STRING */ { pCxt->pRootNode = createKillQueryStmt(pCxt, &yymsp[0].minor.yy0); } -#line 6937 "sql.c" break; - case 378: /* cmd ::= KILL TRANSACTION NK_INTEGER */ -#line 690 "sql.y" + case 386: /* cmd ::= KILL TRANSACTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &yymsp[0].minor.yy0); } -#line 6942 "sql.c" break; - case 379: /* cmd ::= BALANCE VGROUP */ -#line 693 "sql.y" + case 387: /* cmd ::= BALANCE VGROUP */ { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); } -#line 6947 "sql.c" break; - case 380: /* cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ -#line 694 "sql.y" + case 388: /* cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ { pCxt->pRootNode = createBalanceVgroupLeaderStmt(pCxt, &yymsp[0].minor.yy785); } -#line 6952 "sql.c" break; - case 381: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ -#line 695 "sql.y" + case 389: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } -#line 6957 "sql.c" break; - case 382: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ -#line 696 "sql.y" -{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy712); } -#line 6962 "sql.c" + case 390: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ +{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy106); } break; - case 383: /* cmd ::= SPLIT VGROUP NK_INTEGER */ -#line 697 "sql.y" + case 391: /* cmd ::= SPLIT VGROUP NK_INTEGER */ { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } -#line 6967 "sql.c" break; - case 386: /* dnode_list ::= DNODE NK_INTEGER */ -#line 706 "sql.y" -{ yymsp[-1].minor.yy712 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } -#line 6972 "sql.c" + 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 388: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ -#line 713 "sql.y" -{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy56, yymsp[0].minor.yy56); } -#line 6977 "sql.c" + 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 391: /* insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ -#line 722 "sql.y" -{ yymsp[-6].minor.yy56 = createInsertStmt(pCxt, yymsp[-4].minor.yy56, yymsp[-2].minor.yy712, yymsp[0].minor.yy56); } -#line 6982 "sql.c" + 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 392: /* insert_query ::= INSERT INTO full_table_name query_or_subquery */ -#line 723 "sql.y" -{ yymsp[-3].minor.yy56 = createInsertStmt(pCxt, yymsp[-1].minor.yy56, NULL, yymsp[0].minor.yy56); } -#line 6987 "sql.c" + 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 393: /* literal ::= NK_INTEGER */ -#line 726 "sql.y" -{ yylhsminor.yy56 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } -#line 6992 "sql.c" - 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 394: /* literal ::= NK_FLOAT */ -#line 727 "sql.y" -{ yylhsminor.yy56 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } -#line 6998 "sql.c" - 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 395: /* literal ::= NK_STRING */ -#line 728 "sql.y" -{ yylhsminor.yy56 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } -#line 7004 "sql.c" - 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 396: /* literal ::= NK_BOOL */ -#line 729 "sql.y" -{ yylhsminor.yy56 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } -#line 7010 "sql.c" - 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 397: /* literal ::= TIMESTAMP NK_STRING */ -#line 730 "sql.y" -{ yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } -#line 7016 "sql.c" - 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 398: /* literal ::= duration_literal */ - case 408: /* signed_literal ::= signed */ yytestcase(yyruleno==408); - case 430: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==430); - case 431: /* expression ::= literal */ yytestcase(yyruleno==431); - case 433: /* expression ::= column_reference */ yytestcase(yyruleno==433); - case 434: /* expression ::= function_expression */ yytestcase(yyruleno==434); - case 435: /* expression ::= case_when_expression */ yytestcase(yyruleno==435); - case 468: /* function_expression ::= literal_func */ yytestcase(yyruleno==468); - case 517: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==517); - case 521: /* boolean_primary ::= predicate */ yytestcase(yyruleno==521); - case 523: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==523); - case 524: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==524); - case 527: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==527); - case 529: /* table_reference ::= table_primary */ yytestcase(yyruleno==529); - case 530: /* table_reference ::= joined_table */ yytestcase(yyruleno==530); - case 534: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==534); - case 600: /* query_simple ::= query_specification */ yytestcase(yyruleno==600); - case 601: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==601); - case 604: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==604); - case 606: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==606); -#line 731 "sql.y" -{ yylhsminor.yy56 = yymsp[0].minor.yy56; } -#line 7041 "sql.c" - 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 399: /* literal ::= NULL */ -#line 732 "sql.y" -{ yylhsminor.yy56 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } -#line 7047 "sql.c" - 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 400: /* literal ::= NK_QUESTION */ -#line 733 "sql.y" -{ yylhsminor.yy56 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } -#line 7053 "sql.c" - 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 401: /* duration_literal ::= NK_VARIABLE */ - case 575: /* interval_sliding_duration_literal ::= NK_VARIABLE */ yytestcase(yyruleno==575); - case 576: /* interval_sliding_duration_literal ::= NK_STRING */ yytestcase(yyruleno==576); - case 577: /* interval_sliding_duration_literal ::= NK_INTEGER */ yytestcase(yyruleno==577); -#line 735 "sql.y" -{ yylhsminor.yy56 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } -#line 7062 "sql.c" - 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 402: /* signed ::= NK_INTEGER */ -#line 737 "sql.y" -{ yylhsminor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } -#line 7068 "sql.c" - 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 403: /* signed ::= NK_PLUS NK_INTEGER */ -#line 738 "sql.y" -{ yymsp[-1].minor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } -#line 7074 "sql.c" + case 411: /* signed ::= NK_PLUS NK_INTEGER */ +{ yymsp[-1].minor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } break; - case 404: /* signed ::= NK_MINUS NK_INTEGER */ -#line 739 "sql.y" + 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); } -#line 7083 "sql.c" - yymsp[-1].minor.yy56 = yylhsminor.yy56; + yymsp[-1].minor.yy80 = yylhsminor.yy80; break; - case 405: /* signed ::= NK_FLOAT */ -#line 744 "sql.y" -{ yylhsminor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } -#line 7089 "sql.c" - 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 406: /* signed ::= NK_PLUS NK_FLOAT */ -#line 745 "sql.y" -{ yymsp[-1].minor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } -#line 7095 "sql.c" + case 414: /* signed ::= NK_PLUS NK_FLOAT */ +{ yymsp[-1].minor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } break; - case 407: /* signed ::= NK_MINUS NK_FLOAT */ -#line 746 "sql.y" + 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); } -#line 7104 "sql.c" - yymsp[-1].minor.yy56 = yylhsminor.yy56; + yymsp[-1].minor.yy80 = yylhsminor.yy80; break; - case 409: /* signed_literal ::= NK_STRING */ -#line 753 "sql.y" -{ yylhsminor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } -#line 7110 "sql.c" - 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 410: /* signed_literal ::= NK_BOOL */ -#line 754 "sql.y" -{ yylhsminor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } -#line 7116 "sql.c" - 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 411: /* signed_literal ::= TIMESTAMP NK_STRING */ -#line 755 "sql.y" -{ yymsp[-1].minor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } -#line 7122 "sql.c" + case 419: /* signed_literal ::= TIMESTAMP NK_STRING */ +{ yymsp[-1].minor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } break; - case 412: /* signed_literal ::= duration_literal */ - case 414: /* signed_literal ::= literal_func */ yytestcase(yyruleno==414); - case 488: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==488); - case 554: /* select_item ::= common_expression */ yytestcase(yyruleno==554); - case 564: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==564); - case 605: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==605); - case 607: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==607); - case 620: /* search_condition ::= common_expression */ yytestcase(yyruleno==620); -#line 756 "sql.y" -{ yylhsminor.yy56 = releaseRawExprNode(pCxt, yymsp[0].minor.yy56); } -#line 7134 "sql.c" - 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 413: /* signed_literal ::= NULL */ -#line 757 "sql.y" -{ yylhsminor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } -#line 7140 "sql.c" - 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 415: /* signed_literal ::= NK_QUESTION */ -#line 759 "sql.y" -{ yylhsminor.yy56 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } -#line 7146 "sql.c" - 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 432: /* expression ::= pseudo_column */ -#line 817 "sql.y" -{ yylhsminor.yy56 = yymsp[0].minor.yy56; setRawExprNodeIsPseudoColumn(pCxt, yylhsminor.yy56, true); } -#line 7152 "sql.c" - 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 436: /* expression ::= NK_LP expression NK_RP */ - case 522: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==522); - case 619: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==619); -#line 821 "sql.y" -{ yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy56)); } -#line 7160 "sql.c" - 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 437: /* expression ::= NK_PLUS expr_or_subquery */ -#line 822 "sql.y" + 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)); } -#line 7169 "sql.c" - yymsp[-1].minor.yy56 = yylhsminor.yy56; + yymsp[-1].minor.yy80 = yylhsminor.yy80; break; - case 438: /* expression ::= NK_MINUS expr_or_subquery */ -#line 826 "sql.y" + 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)); } -#line 7178 "sql.c" - yymsp[-1].minor.yy56 = yylhsminor.yy56; + yymsp[-1].minor.yy80 = yylhsminor.yy80; break; - case 439: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ -#line 830 "sql.y" + 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))); } -#line 7188 "sql.c" - yymsp[-2].minor.yy56 = yylhsminor.yy56; + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 440: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ -#line 835 "sql.y" + 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))); } -#line 7198 "sql.c" - yymsp[-2].minor.yy56 = yylhsminor.yy56; + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 441: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ -#line 840 "sql.y" + 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))); } -#line 7208 "sql.c" - yymsp[-2].minor.yy56 = yylhsminor.yy56; + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 442: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ -#line 845 "sql.y" + 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))); } -#line 7218 "sql.c" - yymsp[-2].minor.yy56 = yylhsminor.yy56; + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 443: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ -#line 850 "sql.y" + 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))); } -#line 7228 "sql.c" - yymsp[-2].minor.yy56 = yylhsminor.yy56; + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 444: /* expression ::= column_reference NK_ARROW NK_STRING */ -#line 855 "sql.y" + 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))); } -#line 7237 "sql.c" - yymsp[-2].minor.yy56 = yylhsminor.yy56; + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 445: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ -#line 859 "sql.y" + 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))); } -#line 7247 "sql.c" - yymsp[-2].minor.yy56 = yylhsminor.yy56; + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 446: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ -#line 864 "sql.y" + 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))); } -#line 7257 "sql.c" - yymsp[-2].minor.yy56 = yylhsminor.yy56; + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 449: /* column_reference ::= column_name */ -#line 875 "sql.y" -{ yylhsminor.yy56 = createRawExprNode(pCxt, &yymsp[0].minor.yy785, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy785)); } -#line 7263 "sql.c" - 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 450: /* column_reference ::= table_name NK_DOT column_name */ -#line 876 "sql.y" -{ yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy785, createColumnNode(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy785)); } -#line 7269 "sql.c" - 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 451: /* column_reference ::= NK_ALIAS */ -#line 877 "sql.y" -{ yylhsminor.yy56 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } -#line 7275 "sql.c" - 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 452: /* column_reference ::= table_name NK_DOT NK_ALIAS */ -#line 878 "sql.y" -{ yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy0, createColumnNode(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy0)); } -#line 7281 "sql.c" - 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 453: /* pseudo_column ::= ROWTS */ - case 454: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==454); - case 456: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==456); - case 457: /* pseudo_column ::= QEND */ yytestcase(yyruleno==457); - case 458: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==458); - case 459: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==459); - case 460: /* pseudo_column ::= WEND */ yytestcase(yyruleno==460); - case 461: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==461); - case 462: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==462); - case 463: /* pseudo_column ::= ISFILLED */ yytestcase(yyruleno==463); - case 464: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==464); - case 470: /* literal_func ::= NOW */ yytestcase(yyruleno==470); -#line 880 "sql.y" -{ yylhsminor.yy56 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } -#line 7298 "sql.c" - 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 455: /* pseudo_column ::= table_name NK_DOT TBNAME */ -#line 882 "sql.y" -{ 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)))); } -#line 7304 "sql.c" - 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 465: /* function_expression ::= function_name NK_LP expression_list NK_RP */ - case 466: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==466); -#line 893 "sql.y" -{ yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy785, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy785, yymsp[-1].minor.yy712)); } -#line 7311 "sql.c" - 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 467: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ -#line 896 "sql.y" -{ yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy56), yymsp[-1].minor.yy448)); } -#line 7317 "sql.c" - 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 469: /* literal_func ::= noarg_func NK_LP NK_RP */ -#line 899 "sql.y" -{ yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy785, NULL)); } -#line 7323 "sql.c" - 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 484: /* star_func_para_list ::= NK_STAR */ -#line 923 "sql.y" -{ yylhsminor.yy712 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } -#line 7329 "sql.c" - 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 489: /* star_func_para ::= table_name NK_DOT NK_STAR */ - case 557: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==557); -#line 932 "sql.y" -{ yylhsminor.yy56 = createColumnNode(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy0); } -#line 7336 "sql.c" - 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 490: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ -#line 935 "sql.y" -{ yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy712, yymsp[-1].minor.yy56)); } -#line 7342 "sql.c" - 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 491: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ -#line 937 "sql.y" -{ 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)); } -#line 7348 "sql.c" - 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 494: /* when_then_expr ::= WHEN common_expression THEN common_expression */ -#line 944 "sql.y" -{ yymsp[-3].minor.yy56 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), releaseRawExprNode(pCxt, yymsp[0].minor.yy56)); } -#line 7354 "sql.c" + 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 496: /* case_when_else_opt ::= ELSE common_expression */ -#line 947 "sql.y" -{ yymsp[-1].minor.yy56 = releaseRawExprNode(pCxt, yymsp[0].minor.yy56); } -#line 7359 "sql.c" + case 505: /* case_when_else_opt ::= ELSE common_expression */ +{ yymsp[-1].minor.yy80 = releaseRawExprNode(pCxt, yymsp[0].minor.yy80); } break; - case 497: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ - case 502: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==502); -#line 950 "sql.y" + 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))); } -#line 7369 "sql.c" - yymsp[-2].minor.yy56 = yylhsminor.yy56; + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 498: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ -#line 957 "sql.y" + 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))); } -#line 7379 "sql.c" - yymsp[-4].minor.yy56 = yylhsminor.yy56; + yymsp[-4].minor.yy80 = yylhsminor.yy80; break; - case 499: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ -#line 963 "sql.y" + 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))); } -#line 7389 "sql.c" - yymsp[-5].minor.yy56 = yylhsminor.yy56; + yymsp[-5].minor.yy80 = yylhsminor.yy80; break; - case 500: /* predicate ::= expr_or_subquery IS NULL */ -#line 968 "sql.y" + 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)); } -#line 7398 "sql.c" - yymsp[-2].minor.yy56 = yylhsminor.yy56; + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 501: /* predicate ::= expr_or_subquery IS NOT NULL */ -#line 972 "sql.y" + 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)); } -#line 7407 "sql.c" - yymsp[-3].minor.yy56 = yylhsminor.yy56; + yymsp[-3].minor.yy80 = yylhsminor.yy80; break; - case 503: /* compare_op ::= NK_LT */ -#line 984 "sql.y" -{ yymsp[0].minor.yy380 = OP_TYPE_LOWER_THAN; } -#line 7413 "sql.c" + case 512: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy428 = OP_TYPE_LOWER_THAN; } break; - case 504: /* compare_op ::= NK_GT */ -#line 985 "sql.y" -{ yymsp[0].minor.yy380 = OP_TYPE_GREATER_THAN; } -#line 7418 "sql.c" + case 513: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy428 = OP_TYPE_GREATER_THAN; } break; - case 505: /* compare_op ::= NK_LE */ -#line 986 "sql.y" -{ yymsp[0].minor.yy380 = OP_TYPE_LOWER_EQUAL; } -#line 7423 "sql.c" + case 514: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy428 = OP_TYPE_LOWER_EQUAL; } break; - case 506: /* compare_op ::= NK_GE */ -#line 987 "sql.y" -{ yymsp[0].minor.yy380 = OP_TYPE_GREATER_EQUAL; } -#line 7428 "sql.c" + case 515: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy428 = OP_TYPE_GREATER_EQUAL; } break; - case 507: /* compare_op ::= NK_NE */ -#line 988 "sql.y" -{ yymsp[0].minor.yy380 = OP_TYPE_NOT_EQUAL; } -#line 7433 "sql.c" + case 516: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy428 = OP_TYPE_NOT_EQUAL; } break; - case 508: /* compare_op ::= NK_EQ */ -#line 989 "sql.y" -{ yymsp[0].minor.yy380 = OP_TYPE_EQUAL; } -#line 7438 "sql.c" + case 517: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy428 = OP_TYPE_EQUAL; } break; - case 509: /* compare_op ::= LIKE */ -#line 990 "sql.y" -{ yymsp[0].minor.yy380 = OP_TYPE_LIKE; } -#line 7443 "sql.c" + case 518: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy428 = OP_TYPE_LIKE; } break; - case 510: /* compare_op ::= NOT LIKE */ -#line 991 "sql.y" -{ yymsp[-1].minor.yy380 = OP_TYPE_NOT_LIKE; } -#line 7448 "sql.c" + case 519: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy428 = OP_TYPE_NOT_LIKE; } break; - case 511: /* compare_op ::= MATCH */ -#line 992 "sql.y" -{ yymsp[0].minor.yy380 = OP_TYPE_MATCH; } -#line 7453 "sql.c" + case 520: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy428 = OP_TYPE_MATCH; } break; - case 512: /* compare_op ::= NMATCH */ -#line 993 "sql.y" -{ yymsp[0].minor.yy380 = OP_TYPE_NMATCH; } -#line 7458 "sql.c" + case 521: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy428 = OP_TYPE_NMATCH; } break; - case 513: /* compare_op ::= CONTAINS */ -#line 994 "sql.y" -{ yymsp[0].minor.yy380 = OP_TYPE_JSON_CONTAINS; } -#line 7463 "sql.c" + case 522: /* compare_op ::= CONTAINS */ +{ yymsp[0].minor.yy428 = OP_TYPE_JSON_CONTAINS; } break; - case 514: /* in_op ::= IN */ -#line 998 "sql.y" -{ yymsp[0].minor.yy380 = OP_TYPE_IN; } -#line 7468 "sql.c" + case 523: /* in_op ::= IN */ +{ yymsp[0].minor.yy428 = OP_TYPE_IN; } break; - case 515: /* in_op ::= NOT IN */ -#line 999 "sql.y" -{ yymsp[-1].minor.yy380 = OP_TYPE_NOT_IN; } -#line 7473 "sql.c" + case 524: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy428 = OP_TYPE_NOT_IN; } break; - case 516: /* in_predicate_value ::= NK_LP literal_list NK_RP */ -#line 1001 "sql.y" -{ yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy712)); } -#line 7478 "sql.c" - 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 518: /* boolean_value_expression ::= NOT boolean_primary */ -#line 1005 "sql.y" + 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)); } -#line 7487 "sql.c" - yymsp[-1].minor.yy56 = yylhsminor.yy56; + yymsp[-1].minor.yy80 = yylhsminor.yy80; break; - case 519: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ -#line 1010 "sql.y" + 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))); } -#line 7497 "sql.c" - yymsp[-2].minor.yy56 = yylhsminor.yy56; + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 520: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ -#line 1016 "sql.y" + 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))); } -#line 7507 "sql.c" - yymsp[-2].minor.yy56 = yylhsminor.yy56; + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 528: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -#line 1034 "sql.y" -{ yylhsminor.yy56 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy56, yymsp[0].minor.yy56, NULL); } -#line 7513 "sql.c" - 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 531: /* table_primary ::= table_name alias_opt */ -#line 1040 "sql.y" -{ yylhsminor.yy56 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy785, &yymsp[0].minor.yy785); } -#line 7519 "sql.c" - 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 532: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -#line 1041 "sql.y" -{ yylhsminor.yy56 = createRealTableNode(pCxt, &yymsp[-3].minor.yy785, &yymsp[-1].minor.yy785, &yymsp[0].minor.yy785); } -#line 7525 "sql.c" - 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 533: /* table_primary ::= subquery alias_opt */ -#line 1042 "sql.y" -{ yylhsminor.yy56 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy56), &yymsp[0].minor.yy785); } -#line 7531 "sql.c" - 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 535: /* alias_opt ::= */ -#line 1047 "sql.y" + case 544: /* alias_opt ::= */ { yymsp[1].minor.yy785 = nil_token; } -#line 7537 "sql.c" break; - case 537: /* alias_opt ::= AS table_alias */ -#line 1049 "sql.y" + case 546: /* alias_opt ::= AS table_alias */ { yymsp[-1].minor.yy785 = yymsp[0].minor.yy785; } -#line 7542 "sql.c" break; - case 538: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 539: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==539); -#line 1051 "sql.y" -{ yymsp[-2].minor.yy56 = yymsp[-1].minor.yy56; } -#line 7548 "sql.c" + 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 540: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -#line 1056 "sql.y" -{ yylhsminor.yy56 = createJoinTableNode(pCxt, yymsp[-4].minor.yy36, yymsp[-5].minor.yy56, yymsp[-2].minor.yy56, yymsp[0].minor.yy56); } -#line 7553 "sql.c" - 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 541: /* join_type ::= */ -#line 1060 "sql.y" -{ yymsp[1].minor.yy36 = JOIN_TYPE_INNER; } -#line 7559 "sql.c" + case 550: /* join_type ::= */ +{ yymsp[1].minor.yy828 = JOIN_TYPE_INNER; } break; - case 542: /* join_type ::= INNER */ -#line 1061 "sql.y" -{ yymsp[0].minor.yy36 = JOIN_TYPE_INNER; } -#line 7564 "sql.c" + case 551: /* join_type ::= INNER */ +{ yymsp[0].minor.yy828 = JOIN_TYPE_INNER; } break; - case 543: /* 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 */ -#line 1067 "sql.y" + 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); } -#line 7580 "sql.c" break; - case 544: /* hint_list ::= */ -#line 1082 "sql.y" -{ yymsp[1].minor.yy712 = createHintNodeList(pCxt, NULL); } -#line 7585 "sql.c" + case 553: /* hint_list ::= */ +{ yymsp[1].minor.yy106 = createHintNodeList(pCxt, NULL); } break; - case 545: /* hint_list ::= NK_HINT */ -#line 1083 "sql.y" -{ yylhsminor.yy712 = createHintNodeList(pCxt, &yymsp[0].minor.yy0); } -#line 7590 "sql.c" - 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 550: /* set_quantifier_opt ::= ALL */ -#line 1094 "sql.y" -{ yymsp[0].minor.yy425 = false; } -#line 7596 "sql.c" + case 559: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy923 = false; } break; - case 553: /* select_item ::= NK_STAR */ -#line 1101 "sql.y" -{ yylhsminor.yy56 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } -#line 7601 "sql.c" - 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 555: /* select_item ::= common_expression column_alias */ - case 565: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==565); -#line 1103 "sql.y" -{ yylhsminor.yy56 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy56), &yymsp[0].minor.yy785); } -#line 7608 "sql.c" - 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 556: /* select_item ::= common_expression AS column_alias */ - case 566: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==566); -#line 1104 "sql.y" -{ yylhsminor.yy56 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), &yymsp[0].minor.yy785); } -#line 7615 "sql.c" - 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 561: /* partition_by_clause_opt ::= PARTITION BY partition_list */ - case 589: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==589); - case 609: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==609); -#line 1113 "sql.y" -{ yymsp[-2].minor.yy712 = yymsp[0].minor.yy712; } -#line 7623 "sql.c" + 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 568: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ -#line 1126 "sql.y" -{ yymsp[-5].minor.yy56 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy56), releaseRawExprNode(pCxt, yymsp[-1].minor.yy56)); } -#line 7628 "sql.c" + 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 569: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ -#line 1127 "sql.y" -{ yymsp[-3].minor.yy56 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy56)); } -#line 7633 "sql.c" + 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 570: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ -#line 1129 "sql.y" -{ yymsp[-5].minor.yy56 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy56), NULL, yymsp[-1].minor.yy56, yymsp[0].minor.yy56); } -#line 7638 "sql.c" + 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 571: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ -#line 1133 "sql.y" -{ 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); } -#line 7643 "sql.c" + 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 572: /* twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ -#line 1135 "sql.y" -{ yymsp[-6].minor.yy56 = createEventWindowNode(pCxt, yymsp[-3].minor.yy56, yymsp[0].minor.yy56); } -#line 7648 "sql.c" + 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 579: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -#line 1145 "sql.y" -{ yymsp[-3].minor.yy56 = createFillNode(pCxt, yymsp[-1].minor.yy774, NULL); } -#line 7653 "sql.c" + case 588: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy80 = createFillNode(pCxt, yymsp[-1].minor.yy36, NULL); } break; - case 580: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ -#line 1146 "sql.y" -{ yymsp[-5].minor.yy56 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy712)); } -#line 7658 "sql.c" + 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 581: /* fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ -#line 1147 "sql.y" -{ yymsp[-5].minor.yy56 = createFillNode(pCxt, FILL_MODE_VALUE_F, createNodeListNode(pCxt, yymsp[-1].minor.yy712)); } -#line 7663 "sql.c" + 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 582: /* fill_mode ::= NONE */ -#line 1151 "sql.y" -{ yymsp[0].minor.yy774 = FILL_MODE_NONE; } -#line 7668 "sql.c" + case 591: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy36 = FILL_MODE_NONE; } break; - case 583: /* fill_mode ::= PREV */ -#line 1152 "sql.y" -{ yymsp[0].minor.yy774 = FILL_MODE_PREV; } -#line 7673 "sql.c" + case 592: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy36 = FILL_MODE_PREV; } break; - case 584: /* fill_mode ::= NULL */ -#line 1153 "sql.y" -{ yymsp[0].minor.yy774 = FILL_MODE_NULL; } -#line 7678 "sql.c" + case 593: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy36 = FILL_MODE_NULL; } break; - case 585: /* fill_mode ::= NULL_F */ -#line 1154 "sql.y" -{ yymsp[0].minor.yy774 = FILL_MODE_NULL_F; } -#line 7683 "sql.c" + case 594: /* fill_mode ::= NULL_F */ +{ yymsp[0].minor.yy36 = FILL_MODE_NULL_F; } break; - case 586: /* fill_mode ::= LINEAR */ -#line 1155 "sql.y" -{ yymsp[0].minor.yy774 = FILL_MODE_LINEAR; } -#line 7688 "sql.c" + case 595: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy36 = FILL_MODE_LINEAR; } break; - case 587: /* fill_mode ::= NEXT */ -#line 1156 "sql.y" -{ yymsp[0].minor.yy774 = FILL_MODE_NEXT; } -#line 7693 "sql.c" + case 596: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy36 = FILL_MODE_NEXT; } break; - case 590: /* group_by_list ::= expr_or_subquery */ -#line 1165 "sql.y" -{ yylhsminor.yy712 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy56))); } -#line 7698 "sql.c" - 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 591: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ -#line 1166 "sql.y" -{ yylhsminor.yy712 = addNodeToList(pCxt, yymsp[-2].minor.yy712, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy56))); } -#line 7704 "sql.c" - 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 595: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ -#line 1173 "sql.y" -{ yymsp[-5].minor.yy56 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy56), releaseRawExprNode(pCxt, yymsp[-1].minor.yy56)); } -#line 7710 "sql.c" + 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 596: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ -#line 1175 "sql.y" -{ yymsp[-3].minor.yy56 = createInterpTimePoint(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy56)); } -#line 7715 "sql.c" + 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 599: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ -#line 1182 "sql.y" + 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); } -#line 7724 "sql.c" - yymsp[-3].minor.yy56 = yylhsminor.yy56; + yymsp[-3].minor.yy80 = yylhsminor.yy80; break; - case 602: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ -#line 1192 "sql.y" -{ yylhsminor.yy56 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy56, yymsp[0].minor.yy56); } -#line 7730 "sql.c" - 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 603: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ -#line 1194 "sql.y" -{ yylhsminor.yy56 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy56, yymsp[0].minor.yy56); } -#line 7736 "sql.c" - 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 611: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 615: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==615); -#line 1208 "sql.y" -{ yymsp[-1].minor.yy56 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } -#line 7743 "sql.c" + 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 612: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 616: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==616); -#line 1209 "sql.y" -{ yymsp[-3].minor.yy56 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } -#line 7749 "sql.c" + 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 613: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 617: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==617); -#line 1210 "sql.y" -{ yymsp[-3].minor.yy56 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } -#line 7755 "sql.c" + 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 618: /* subquery ::= NK_LP query_expression NK_RP */ -#line 1218 "sql.y" -{ yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy56); } -#line 7760 "sql.c" - 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 623: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ -#line 1232 "sql.y" -{ yylhsminor.yy56 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), yymsp[-1].minor.yy722, yymsp[0].minor.yy361); } -#line 7766 "sql.c" - 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 624: /* ordering_specification_opt ::= */ -#line 1236 "sql.y" -{ yymsp[1].minor.yy722 = ORDER_ASC; } -#line 7772 "sql.c" + case 633: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy812 = ORDER_ASC; } break; - case 625: /* ordering_specification_opt ::= ASC */ -#line 1237 "sql.y" -{ yymsp[0].minor.yy722 = ORDER_ASC; } -#line 7777 "sql.c" + case 634: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy812 = ORDER_ASC; } break; - case 626: /* ordering_specification_opt ::= DESC */ -#line 1238 "sql.y" -{ yymsp[0].minor.yy722 = ORDER_DESC; } -#line 7782 "sql.c" + case 635: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy812 = ORDER_DESC; } break; - case 627: /* null_ordering_opt ::= */ -#line 1242 "sql.y" -{ yymsp[1].minor.yy361 = NULL_ORDER_DEFAULT; } -#line 7787 "sql.c" + case 636: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy763 = NULL_ORDER_DEFAULT; } break; - case 628: /* null_ordering_opt ::= NULLS FIRST */ -#line 1243 "sql.y" -{ yymsp[-1].minor.yy361 = NULL_ORDER_FIRST; } -#line 7792 "sql.c" + case 637: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy763 = NULL_ORDER_FIRST; } break; - case 629: /* null_ordering_opt ::= NULLS LAST */ -#line 1244 "sql.y" -{ yymsp[-1].minor.yy361 = NULL_ORDER_LAST; } -#line 7797 "sql.c" + case 638: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy763 = NULL_ORDER_LAST; } break; default: break; @@ -7856,7 +6590,6 @@ static void yy_syntax_error( ParseCTX_FETCH #define TOKEN yyminor /************ Begin %syntax_error code ****************************************/ -#line 29 "sql.y" if (TSDB_CODE_SUCCESS == pCxt->errCode) { if(TOKEN.z) { @@ -7867,7 +6600,6 @@ static void yy_syntax_error( } else if (TSDB_CODE_PAR_DB_NOT_SPECIFIED == pCxt->errCode && TK_NK_FLOAT == TOKEN.type) { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, TOKEN.z); } -#line 7870 "sql.c" /************ End %syntax_error code ******************************************/ ParseARG_STORE /* Suppress warning about unused %extra_argument variable */ ParseCTX_STORE 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 856fdb4804..0f6aa22050 100644 --- a/source/libs/parser/test/parInitialCTest.cpp +++ b/source/libs/parser/test/parInitialCTest.cpp @@ -247,7 +247,11 @@ TEST_F(ParserInitialCTest, createDatabase) { for (int32_t i = 0; i < expect.numOfRetensions; ++i) { SRetention* pReten = (SRetention*)taosArrayGet(req.pRetensions, i); SRetention* pExpectReten = (SRetention*)taosArrayGet(expect.pRetensions, i); - ASSERT_EQ(pReten->freq, pExpectReten->freq); + if(i == 0) { + ASSERT_EQ(pReten->freq, 0); + } else { + ASSERT_EQ(pReten->freq, pExpectReten->freq); + } ASSERT_EQ(pReten->keep, pExpectReten->keep); ASSERT_EQ(pReten->freqUnit, pExpectReten->freqUnit); ASSERT_EQ(pReten->keepUnit, pExpectReten->keepUnit); @@ -304,7 +308,7 @@ TEST_F(ParserInitialCTest, createDatabase) { "PAGESIZE 8 " "PRECISION 'ns' " "REPLICA 3 " - "RETENTIONS 15s:7d,1m:21d,15m:500d " + "RETENTIONS -:7d,1m:21d,15m:500d " // "STRICT 'on' " "WAL_LEVEL 2 " "VGROUPS 100 " @@ -340,12 +344,12 @@ TEST_F(ParserInitialCTest, createDatabase) { TEST_F(ParserInitialCTest, createDatabaseSemanticCheck) { useDb("root", "test"); - run("create database db2 retentions 0s:1d", TSDB_CODE_PAR_INVALID_DB_OPTION); - run("create database db2 retentions 10s:0d", TSDB_CODE_PAR_INVALID_DB_OPTION); - run("create database db2 retentions 1w:1d", TSDB_CODE_PAR_INVALID_DB_OPTION); - run("create database db2 retentions 1w:1n", TSDB_CODE_PAR_INVALID_DB_OPTION); - run("create database db2 retentions 15s:7d,15m:21d,10m:500d", TSDB_CODE_PAR_INVALID_DB_OPTION); - run("create database db2 retentions 15s:7d,5m:21d,10m:10d", TSDB_CODE_PAR_INVALID_DB_OPTION); + run("create database db2 retentions -:1d,0s:1d", TSDB_CODE_PAR_INVALID_DB_OPTION); + run("create database db2 retentions -:0d", TSDB_CODE_PAR_INVALID_DB_OPTION); + run("create database db2 retentions -:1d,1w:1d", TSDB_CODE_PAR_INVALID_DB_OPTION); + run("create database db2 retentions -:1n,1w:1d", TSDB_CODE_PAR_INVALID_DB_OPTION); + run("create database db2 retentions -:7d,15m:21d,10m:500d", TSDB_CODE_PAR_INVALID_DB_OPTION); + run("create database db2 retentions -:7d,5m:21d,10m:10d", TSDB_CODE_PAR_INVALID_DB_OPTION); } /* @@ -454,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/libs/stream/inc/streamInt.h b/source/libs/stream/inc/streamInt.h index 4cd8319a07..c63b51d745 100644 --- a/source/libs/stream/inc/streamInt.h +++ b/source/libs/stream/inc/streamInt.h @@ -52,6 +52,11 @@ extern "C" { #define stTrace(...) do { if (stDebugFlag & DEBUG_TRACE) { taosPrintLog("STM ", DEBUG_TRACE, tqDebugFlag, __VA_ARGS__); }} while(0) // clang-format on +typedef struct { + int8_t type; + SSDataBlock* pBlock; +} SStreamTrigger; + typedef struct SStreamGlobalEnv { int8_t inited; void* timer; @@ -122,7 +127,7 @@ int32_t streamNotifyUpstreamContinue(SStreamTask* pTask); int32_t streamTaskFillHistoryFinished(SStreamTask* pTask); int32_t streamTransferStateToStreamTask(SStreamTask* pTask); -int32_t streamTaskInitTokenBucket(STokenBucket* pBucket, int32_t numCap, int32_t numRate, int32_t quotaRate); +int32_t streamTaskInitTokenBucket(STokenBucket* pBucket, int32_t numCap, int32_t numRate, float quotaRate); STaskId streamTaskExtractKey(const SStreamTask* pTask); void streamTaskInitForLaunchHTask(SHistoryTaskInfo* pInfo); void streamTaskSetRetryInfoForLaunch(SHistoryTaskInfo* pInfo); diff --git a/source/libs/stream/inc/streamsm.h b/source/libs/stream/inc/streamsm.h new file mode 100644 index 0000000000..be3665fde7 --- /dev/null +++ b/source/libs/stream/inc/streamsm.h @@ -0,0 +1,73 @@ +/* + * 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 TDENGINE_STREAMSM_H +#define TDENGINE_STREAMSM_H + +#include "tstream.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// moore finite state machine for stream task +typedef struct SStreamTaskState { + ETaskStatus state; + char* name; +} SStreamTaskState; + +typedef int32_t (*__state_trans_fn)(SStreamTask*); +typedef int32_t (*__state_trans_succ_fn)(SStreamTask*); + +typedef struct SAttachedEventInfo { + ETaskStatus status; // required status that this event can be handled + EStreamTaskEvent event; // the delayed handled event +} SAttachedEventInfo; + +typedef struct STaskStateTrans { + bool autoInvokeEndFn; + SStreamTaskState state; + EStreamTaskEvent event; + SStreamTaskState next; + __state_trans_fn pAction; + __state_trans_succ_fn pSuccAction; + SAttachedEventInfo attachEvent; +} STaskStateTrans; + +struct SStreamTaskSM { + SStreamTask* pTask; + STaskStateTrans* pActiveTrans; + int64_t startTs; + SStreamTaskState current; + struct { + SStreamTaskState state; + EStreamTaskEvent evt; + } prev; + // register the next handled event, if current state is not allowed to handle this event + SArray* pWaitingEventList; +}; + +typedef struct SStreamEventInfo { + EStreamTaskEvent event; + const char* name; +} SStreamEventInfo; + +SStreamTaskSM* streamCreateStateMachine(SStreamTask* pTask); +void* streamDestroyStateMachine(SStreamTaskSM* pSM); +#ifdef __cplusplus +} +#endif + +#endif // TDENGINE_STREAMSM_H diff --git a/source/libs/stream/src/stream.c b/source/libs/stream/src/stream.c index 03ba796b2c..34b4677235 100644 --- a/source/libs/stream/src/stream.c +++ b/source/libs/stream/src/stream.c @@ -62,14 +62,14 @@ static void streamSchedByTimer(void* param, void* tmrId) { int32_t nextTrigger = (int32_t)pTask->info.triggerParam; int8_t status = atomic_load_8(&pTask->schedInfo.status); - stDebug("s-task:%s in scheduler, trigger status:%d, next:%dms", id, status, nextTrigger); + stTrace("s-task:%s in scheduler, trigger status:%d, next:%dms", id, status, nextTrigger); - if (streamTaskShouldStop(&pTask->status) || streamTaskShouldPause(&pTask->status)) { + if (streamTaskShouldStop(pTask) || streamTaskShouldPause(pTask)) { stDebug("s-task:%s jump out of schedTimer", id); return; } - if (pTask->status.taskStatus == TASK_STATUS__CK) { + if (streamTaskGetStatus(pTask, NULL) == TASK_STATUS__CK) { stDebug("s-task:%s in checkpoint procedure, not retrieve result, next:%dms", id, nextTrigger); } else { if (status == TASK_TRIGGER_STATUS__ACTIVE) { @@ -127,7 +127,7 @@ int32_t streamSchedExec(SStreamTask* pTask) { SStreamTaskRunReq* pRunReq = rpcMallocCont(sizeof(SStreamTaskRunReq)); if (pRunReq == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; - /*int8_t status = */streamTaskSetSchedStatusInActive(pTask); + /*int8_t status = */streamTaskSetSchedStatusInactive(pTask); stError("failed to create msg to aunch s-task:%s, reason out of memory", pTask->id.idStr); return -1; } @@ -267,8 +267,7 @@ int32_t streamProcessDispatchMsg(SStreamTask* pTask, SStreamDispatchReq* pReq, S } // disable the data from upstream tasks - int8_t st = pTask->status.taskStatus; - if (st == TASK_STATUS__HALT) { + if (streamTaskGetStatus(pTask, NULL) == TASK_STATUS__HALT) { status = TASK_INPUT_STATUS__BLOCKED; } @@ -297,7 +296,7 @@ int32_t streamProcessRetrieveReq(SStreamTask* pTask, SStreamRetrieveReq* pReq, S return 0; } -void streamTaskInputFail(SStreamTask* pTask) { atomic_store_8(&pTask->inputInfo.status, TASK_INPUT_STATUS__FAILED); } +void streamTaskInputFail(SStreamTask* pTask) { atomic_store_8(&pTask->inputq.status, TASK_INPUT_STATUS__FAILED); } void streamTaskOpenAllUpstreamInput(SStreamTask* pTask) { int32_t num = taosArrayGetSize(pTask->upstreamInfo.pList); diff --git a/source/libs/stream/src/streamBackendRocksdb.c b/source/libs/stream/src/streamBackendRocksdb.c index 422db0f591..8f93f259ef 100644 --- a/source/libs/stream/src/streamBackendRocksdb.c +++ b/source/libs/stream/src/streamBackendRocksdb.c @@ -993,7 +993,7 @@ int32_t streamBackendDoCheckpoint(void* arg, uint64_t checkpointId) { stDebug("stream backend:%p end to do checkpoint at:%s, time cost:%" PRId64 "ms", pHandle, pChkpIdDir, taosGetTimestampMs() - st); } - } else { + } else { stError("stream backend:%p failed to flush db at:%s", pHandle, pChkpIdDir); } // release all ref to cfWrapper; @@ -1467,16 +1467,24 @@ rocksdb_compactionfilter_t* compactFilteFactoryCreateFilter(void* arg, rocksdb_c void destroyRocksdbCfInst(RocksdbCfInst* inst) { int cfLen = sizeof(ginitDict) / sizeof(ginitDict[0]); - for (int i = 0; i < cfLen; i++) { - if (inst->pHandle[i]) rocksdb_column_family_handle_destroy((inst->pHandle)[i]); + if (inst->pHandle) { + for (int i = 0; i < cfLen; i++) { + if (inst->pHandle[i]) rocksdb_column_family_handle_destroy((inst->pHandle)[i]); + } + taosMemoryFree(inst->pHandle); } - rocksdb_writeoptions_destroy(inst->wOpt); - inst->wOpt = NULL; + if (inst->cfOpt) { + for (int i = 0; i < cfLen; i++) { + rocksdb_options_destroy(inst->cfOpt[i]); + rocksdb_block_based_options_destroy(((RocksdbCfParam*)inst->param)[i].tableOpt); + } + taosMemoryFreeClear(inst->cfOpt); + taosMemoryFreeClear(inst->param); + } + if (inst->wOpt) rocksdb_writeoptions_destroy(inst->wOpt); + if (inst->rOpt) rocksdb_readoptions_destroy(inst->rOpt); - rocksdb_readoptions_destroy(inst->rOpt); - taosMemoryFree(inst->cfOpt); - taosMemoryFreeClear(inst->param); taosMemoryFree(inst); } @@ -1645,6 +1653,13 @@ int streamStateOpenBackend(void* backend, SStreamState* pState) { pState->pTdbState->backendCfWrapperId = id; pState->pTdbState->pBackendCfWrapper = pBackendCfWrapper; stInfo("succ to open state %p on backendWrapper, %p, %s", pState, pBackendCfWrapper, pBackendCfWrapper->idstr); + + inst->pHandle = NULL; + inst->cfOpt = NULL; + inst->param = NULL; + + inst->wOpt = NULL; + inst->rOpt = NULL; return 0; } taosThreadMutexUnlock(&handle->cfMutex); @@ -1992,14 +2007,12 @@ int32_t streamStateAddIfNotExist_rocksdb(SStreamState* pState, const SWinKey* ke return 0; } int32_t streamStateCurPrev_rocksdb(SStreamStateCur* pCur) { - stDebug("streamStateCurPrev_rocksdb"); if (!pCur) return -1; rocksdb_iter_prev(pCur->iter); return 0; } int32_t streamStateGetKVByCur_rocksdb(SStreamStateCur* pCur, SWinKey* pKey, const void** pVal, int32_t* pVLen) { - stDebug("streamStateGetKVByCur_rocksdb"); if (!pCur) return -1; SStateKey tkey; SStateKey* pKtmp = &tkey; @@ -2024,7 +2037,6 @@ int32_t streamStateGetKVByCur_rocksdb(SStreamStateCur* pCur, SWinKey* pKey, cons return -1; } SStreamStateCur* streamStateGetAndCheckCur_rocksdb(SStreamState* pState, SWinKey* key) { - stDebug("streamStateGetAndCheckCur_rocksdb"); SStreamStateCur* pCur = streamStateFillGetCur_rocksdb(pState, key); if (pCur) { int32_t code = streamStateGetGroupKVByCur_rocksdb(pCur, key, NULL, 0); @@ -2035,7 +2047,6 @@ SStreamStateCur* streamStateGetAndCheckCur_rocksdb(SStreamState* pState, SWinKey } SStreamStateCur* streamStateSeekKeyNext_rocksdb(SStreamState* pState, const SWinKey* key) { - stDebug("streamStateSeekKeyNext_rocksdb"); SStreamStateCur* pCur = createStreamStateCursor(); if (pCur == NULL) { return NULL; @@ -2074,7 +2085,6 @@ SStreamStateCur* streamStateSeekKeyNext_rocksdb(SStreamState* pState, const SWin } SStreamStateCur* streamStateSeekToLast_rocksdb(SStreamState* pState) { - stDebug("streamStateGetCur_rocksdb"); int32_t code = 0; const SStateKey maxStateKey = {.key = {.groupId = UINT64_MAX, .ts = INT64_MAX}, .opNum = INT64_MAX}; @@ -2115,7 +2125,6 @@ SStreamStateCur* streamStateSeekToLast_rocksdb(SStreamState* pState) { } SStreamStateCur* streamStateGetCur_rocksdb(SStreamState* pState, const SWinKey* key) { - stDebug("streamStateGetCur_rocksdb"); SBackendCfWrapper* wrapper = pState->pTdbState->pBackendCfWrapper; SStreamStateCur* pCur = createStreamStateCursor(); diff --git a/source/libs/stream/src/streamCheckpoint.c b/source/libs/stream/src/streamCheckpoint.c index 2cde368195..9eaa9fcb92 100644 --- a/source/libs/stream/src/streamCheckpoint.c +++ b/source/libs/stream/src/streamCheckpoint.c @@ -135,12 +135,13 @@ static int32_t appendCheckpointIntoInputQ(SStreamTask* pTask, int32_t checkpoint int32_t streamProcessCheckpointSourceReq(SStreamTask* pTask, SStreamCheckpointSourceReq* pReq) { ASSERT(pTask->info.taskLevel == TASK_LEVEL__SOURCE); + // todo this status may not be set here. // 1. set task status to be prepared for check point, no data are allowed to put into inputQ. - pTask->status.taskStatus = TASK_STATUS__CK; + streamTaskHandleEvent(pTask->status.pSM, TASK_EVENT_GEN_CHECKPOINT); + pTask->checkpointingId = pReq->checkpointId; pTask->checkpointNotReadyTasks = streamTaskGetNumOfDownstream(pTask); pTask->chkInfo.startTs = taosGetTimestampMs(); - pTask->execInfo.checkpoint += 1; // 2. Put the checkpoint block into inputQ, to make sure all blocks with less version have been handled by this task @@ -171,11 +172,15 @@ int32_t streamProcessCheckpointBlock(SStreamTask* pTask, SStreamDataBlock* pBloc const char* id = pTask->id.idStr; int32_t code = TSDB_CODE_SUCCESS; - // set the task status - pTask->checkpointingId = checkpointId; - // set task status - pTask->status.taskStatus = TASK_STATUS__CK; + if (streamTaskGetStatus(pTask, NULL) != TASK_STATUS__CK) { + pTask->checkpointingId = checkpointId; + code = streamTaskHandleEvent(pTask->status.pSM, TASK_EVENT_GEN_CHECKPOINT); + if (code != TSDB_CODE_SUCCESS) { + stError("s-task:%s handle checkpoint-trigger block failed, code:%s", id, tstrerror(code)); + return code; + } + } { // todo: remove this when the pipeline checkpoint generating is used. SStreamMeta* pMeta = pTask->pMeta; @@ -195,6 +200,7 @@ int32_t streamProcessCheckpointBlock(SStreamTask* pTask, SStreamDataBlock* pBloc stDebug("s-task:%s set childIdx:%d, and add checkpoint-trigger block into outputQ", id, pTask->info.selfChildId); continueDispatchCheckpointBlock(pBlock, pTask); } else { // only one task exists, no need to dispatch downstream info + atomic_add_fetch_32(&pTask->checkpointNotReadyTasks, 1); streamProcessCheckpointReadyMsg(pTask); streamFreeQitem((SStreamQueueItem*)pBlock); } @@ -274,6 +280,8 @@ void streamTaskClearCheckInfo(SStreamTask* pTask) { } int32_t streamSaveAllTaskStatus(SStreamMeta* pMeta, int64_t checkpointId) { + int32_t vgId = pMeta->vgId; + taosWLockLatch(&pMeta->lock); for (int32_t i = 0; i < taosArrayGetSize(pMeta->pTaskList); ++i) { @@ -288,27 +296,34 @@ int32_t streamSaveAllTaskStatus(SStreamMeta* pMeta, int64_t checkpointId) { continue; } - int8_t prev = p->status.taskStatus; ASSERT(p->chkInfo.checkpointId < p->checkpointingId && p->checkpointingId == checkpointId); p->chkInfo.checkpointId = p->checkpointingId; streamTaskClearCheckInfo(p); - streamSetStatusNormal(p); - // save the task - streamMetaSaveTask(pMeta, p); + char* str = NULL; + streamTaskGetStatus(p, &str); + + int32_t code = streamTaskHandleEvent(p->status.pSM, TASK_EVENT_CHECKPOINT_DONE); + if (code != TSDB_CODE_SUCCESS) { + stDebug("s-task:%s vgId:%d save task status failed, since handle event failed", p->id.idStr, vgId); + taosWUnLockLatch(&pMeta->lock); + return -1; + } else { // save the task + streamMetaSaveTask(pMeta, p); + } stDebug( "vgId:%d s-task:%s level:%d open upstream inputQ, commit task status after checkpoint completed, " "checkpointId:%" PRId64 ", Ver(saved):%" PRId64 " currentVer:%" PRId64 ", status to be normal, prev:%s", pMeta->vgId, p->id.idStr, p->info.taskLevel, checkpointId, p->chkInfo.checkpointVer, p->chkInfo.nextProcessVer, - streamGetTaskStatusStr(prev)); + str); } if (streamMetaCommit(pMeta) < 0) { taosWUnLockLatch(&pMeta->lock); stError("vgId:%d failed to commit stream meta after do checkpoint, checkpointId:%" PRId64 ", since %s", pMeta->vgId, - checkpointId, terrstr()); + checkpointId, terrstr()); return -1; } else { taosWUnLockLatch(&pMeta->lock); diff --git a/source/libs/stream/src/streamDispatch.c b/source/libs/stream/src/streamDispatch.c index a7a06dd884..cd8bbacb98 100644 --- a/source/libs/stream/src/streamDispatch.c +++ b/source/libs/stream/src/streamDispatch.c @@ -420,7 +420,7 @@ static void doRetryDispatchData(void* param, void* tmrId) { const char* id = pTask->id.idStr; int32_t msgId = pTask->execInfo.dispatch; - if (streamTaskShouldStop(&pTask->status)) { + if (streamTaskShouldStop(pTask)) { int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1); stDebug("s-task:%s should stop, abort from timer, ref:%d", pTask->id.idStr, ref); return; @@ -474,10 +474,10 @@ static void doRetryDispatchData(void* param, void* tmrId) { } if (code != TSDB_CODE_SUCCESS) { - if (!streamTaskShouldStop(&pTask->status)) { + if (!streamTaskShouldStop(pTask)) { // stDebug("s-task:%s reset the waitRspCnt to be 0 before launch retry dispatch", pTask->id.idStr); // atomic_store_32(&pTask->outputInfo.shuffleDispatcher.waitingRspCnt, 0); - if (streamTaskShouldPause(&pTask->status)) { + if (streamTaskShouldPause(pTask)) { streamRetryDispatchData(pTask, DISPATCH_RETRY_INTERVAL_MS * 10); } else { streamRetryDispatchData(pTask, DISPATCH_RETRY_INTERVAL_MS); @@ -662,8 +662,10 @@ int32_t streamDispatchScanHistoryFinishMsg(SStreamTask* pTask) { int32_t numOfVgs = taosArrayGetSize(vgInfo); pTask->notReadyTasks = numOfVgs; + char* p = NULL; + streamTaskGetStatus(pTask, &p); stDebug("s-task:%s send scan-history data complete msg to downstream (shuffle-dispatch) %d tasks, status:%s", pTask->id.idStr, - numOfVgs, streamGetTaskStatusStr(pTask->status.taskStatus)); + numOfVgs, p); for (int32_t i = 0; i < numOfVgs; i++) { SVgroupInfo* pVgInfo = taosArrayGet(vgInfo, i); req.downstreamTaskId = pVgInfo->taskId; @@ -775,8 +777,9 @@ int32_t doDispatchScanHistoryFinishMsg(SStreamTask* pTask, const SStreamScanHist initRpcMsg(&msg, TDMT_VND_STREAM_SCAN_HISTORY_FINISH, buf, tlen + sizeof(SMsgHead)); tmsgSendReq(pEpSet, &msg); - const char* pStatus = streamGetTaskStatusStr(pTask->status.taskStatus); - stDebug("s-task:%s status:%s dispatch scan-history finish msg to taskId:0x%x (vgId:%d)", pTask->id.idStr, pStatus, + char* p = NULL; + streamTaskGetStatus(pTask, &p); + stDebug("s-task:%s status:%s dispatch scan-history finish msg to taskId:0x%x (vgId:%d)", pTask->id.idStr, p, pReq->downstreamTaskId, vgId); return 0; } @@ -1008,7 +1011,7 @@ int32_t streamAddEndScanHistoryMsg(SStreamTask* pTask, SRpcHandleInfo* pRpcInfo, taosThreadMutexUnlock(&pTask->lock); int32_t num = taosArrayGetSize(pTask->pRspMsgList); - stDebug("s-task:%s add scan history finish rsp msg for task:0x%x, total:%d", pTask->id.idStr, pReq->upstreamTaskId, + stDebug("s-task:%s add scan-history finish rsp msg for task:0x%x, total:%d", pTask->id.idStr, pReq->upstreamTaskId, num); return TSDB_CODE_SUCCESS; } @@ -1024,7 +1027,7 @@ int32_t streamNotifyUpstreamContinue(SStreamTask* pTask) { SStreamContinueExecInfo* pInfo = taosArrayGet(pTask->pRspMsgList, i); tmsgSendRsp(&pInfo->msg); - stDebug("s-task:%s level:%d notify upstream:0x%x continuing scan data in WAL", id, level, pInfo->taskId); + stDebug("s-task:%s level:%d notify upstream:0x%x continuing handle data in WAL", id, level, pInfo->taskId); } taosArrayClear(pTask->pRspMsgList); @@ -1040,8 +1043,8 @@ static int32_t handleDispatchSuccessRsp(SStreamTask* pTask, int32_t downstreamId int64_t el = taosGetTimestampMs() - pTask->msgInfo.startTs; // put data into inputQ of current task is also allowed - if (pTask->inputInfo.status == TASK_INPUT_STATUS__BLOCKED) { - pTask->inputInfo.status = TASK_INPUT_STATUS__NORMAL; + if (pTask->inputq.status == TASK_INPUT_STATUS__BLOCKED) { + pTask->inputq.status = TASK_INPUT_STATUS__NORMAL; stDebug("s-task:%s downstream task:0x%x resume to normal from inputQ blocking, blocking time:%" PRId64 "ms", pTask->id.idStr, downstreamId, el); } else { @@ -1093,7 +1096,7 @@ int32_t streamProcessDispatchRsp(SStreamTask* pTask, SStreamDispatchRsp* pRsp, i } else { // code == 0 if (pRsp->inputStatus == TASK_INPUT_STATUS__BLOCKED) { - pTask->inputInfo.status = TASK_INPUT_STATUS__BLOCKED; + pTask->inputq.status = TASK_INPUT_STATUS__BLOCKED; // block the input of current task, to push pressure to upstream taosThreadMutexLock(&pTask->lock); taosArrayPush(pTask->msgInfo.pRetryList, &pRsp->downstreamNodeId); @@ -1113,16 +1116,16 @@ int32_t streamProcessDispatchRsp(SStreamTask* pTask, SStreamDispatchRsp* pRsp, i ASSERT(leftRsp >= 0); if (leftRsp > 0) { - stDebug( "s-task:%s recv dispatch rsp, msgId:%d from 0x%x(vgId:%d), downstream task input status:%d code:%d, waiting for %d rsp", - id, msgId, pRsp->downstreamTaskId, pRsp->downstreamNodeId, pRsp->inputStatus, code, leftRsp); + stDebug( "s-task:%s recv dispatch rsp, msgId:%d from 0x%x(vgId:%d), downstream task input status:%d code:%s, waiting for %d rsp", + id, msgId, pRsp->downstreamTaskId, pRsp->downstreamNodeId, pRsp->inputStatus, tstrerror(code), leftRsp); } else { stDebug( - "s-task:%s recv dispatch rsp, msgId:%d from 0x%x(vgId:%d), downstream task input status:%d code:%d, all rsp", - id, msgId, pRsp->downstreamTaskId, pRsp->downstreamNodeId, pRsp->inputStatus, code); + "s-task:%s recv dispatch rsp, msgId:%d from 0x%x(vgId:%d), downstream task input status:%d code:%s, all rsp", + id, msgId, pRsp->downstreamTaskId, pRsp->downstreamNodeId, pRsp->inputStatus, tstrerror(code)); } } else { - stDebug("s-task:%s recv fix-dispatch rsp, msgId:%d from 0x%x(vgId:%d), downstream task input status:%d code:%d", - id, msgId, pRsp->downstreamTaskId, pRsp->downstreamNodeId, pRsp->inputStatus, code); + stDebug("s-task:%s recv fix-dispatch rsp, msgId:%d from 0x%x(vgId:%d), downstream task input status:%d code:%s", + id, msgId, pRsp->downstreamTaskId, pRsp->downstreamNodeId, pRsp->inputStatus, tstrerror(code)); } ASSERT(leftRsp >= 0); @@ -1181,6 +1184,9 @@ int32_t tEncodeStreamTaskUpdateMsg(SEncoder* pEncoder, const SStreamTaskNodeUpda if (tEncodeSEpSet(pEncoder, &pInfo->prevEp) < 0) return -1; if (tEncodeSEpSet(pEncoder, &pInfo->newEp) < 0) return -1; } + + // todo this new attribute will be result in being incompatible with previous version + if (tEncodeI32(pEncoder, pMsg->transId) < 0) return -1; tEndEncode(pEncoder); return pEncoder->pos; } @@ -1201,6 +1207,8 @@ int32_t tDecodeStreamTaskUpdateMsg(SDecoder* pDecoder, SStreamTaskNodeUpdateMsg* taosArrayPush(pMsg->pNodeList, &info); } + if (tDecodeI32(pDecoder, &pMsg->transId) < 0) return -1; + tEndDecode(pDecoder); return 0; } diff --git a/source/libs/stream/src/streamExec.c b/source/libs/stream/src/streamExec.c index c49c647906..15b809d6bd 100644 --- a/source/libs/stream/src/streamExec.c +++ b/source/libs/stream/src/streamExec.c @@ -22,14 +22,13 @@ static int32_t streamDoTransferStateToStreamTask(SStreamTask* pTask); -bool streamTaskShouldStop(const SStreamStatus* pStatus) { - int32_t status = atomic_load_8((int8_t*)&pStatus->taskStatus); - return (status == TASK_STATUS__STOP) || (status == TASK_STATUS__DROPPING); +bool streamTaskShouldStop(const SStreamTask* pTask) { + ETaskStatus s = streamTaskGetStatus(pTask, NULL); + return (s == TASK_STATUS__STOP) || (s == TASK_STATUS__DROPPING); } -bool streamTaskShouldPause(const SStreamStatus* pStatus) { - int32_t status = atomic_load_8((int8_t*)&pStatus->taskStatus); - return (status == TASK_STATUS__PAUSE); +bool streamTaskShouldPause(const SStreamTask* pTask) { + return (streamTaskGetStatus(pTask, NULL) == TASK_STATUS__PAUSE); } static int32_t doOutputResultBlockImpl(SStreamTask* pTask, SStreamDataBlock* pBlock) { @@ -102,12 +101,12 @@ static int32_t streamTaskExecImpl(SStreamTask* pTask, SStreamQueueItem* pItem, i pRes = taosArrayInit(4, sizeof(SSDataBlock)); } - if (streamTaskShouldStop(&pTask->status)) { + if (streamTaskShouldStop(pTask)) { taosArrayDestroyEx(pRes, (FDelete)blockDataFreeRes); return 0; } - if (pTask->inputInfo.status == TASK_INPUT_STATUS__BLOCKED) { + if (pTask->inputq.status == TASK_INPUT_STATUS__BLOCKED) { stWarn("s-task:%s downstream task inputQ blocked, idle for 1sec and retry exec task", pTask->id.idStr); taosMsleep(1000); continue; @@ -198,7 +197,7 @@ int32_t streamScanHistoryData(SStreamTask* pTask) { qSetStreamOpOpen(exec); while (!finished) { - if (streamTaskShouldPause(&pTask->status)) { + if (streamTaskShouldPause(pTask)) { double el = (taosGetTimestampMs() - pTask->execInfo.step1Start) / 1000.0; stDebug("s-task:%s paused from the scan-history task, elapsed time:%.2fsec", pTask->id.idStr, el); break; @@ -213,12 +212,12 @@ int32_t streamScanHistoryData(SStreamTask* pTask) { int32_t size = 0; int32_t numOfBlocks = 0; while (1) { - if (streamTaskShouldStop(&pTask->status)) { + if (streamTaskShouldStop(pTask)) { taosArrayDestroyEx(pRes, (FDelete)blockDataFreeRes); return 0; } - if (pTask->inputInfo.status == TASK_INPUT_STATUS__BLOCKED) { + if (pTask->inputq.status == TASK_INPUT_STATUS__BLOCKED) { stDebug("s-task:%s inputQ is blocked, wait for 10sec and retry", pTask->id.idStr); taosMsleep(10000); continue; @@ -309,21 +308,19 @@ int32_t streamDoTransferStateToStreamTask(SStreamTask* pTask) { pStreamTask->id.idStr); } - ASSERT(((pStreamTask->status.taskStatus == TASK_STATUS__STOP) || - (pStreamTask->hTaskInfo.id.taskId == pTask->id.taskId)) && + ETaskStatus status = streamTaskGetStatus(pStreamTask, NULL); + ASSERT(((status == TASK_STATUS__DROPPING) || (pStreamTask->hTaskInfo.id.taskId == pTask->id.taskId)) && pTask->status.appendTranstateBlock == true); STimeWindow* pTimeWindow = &pStreamTask->dataRange.window; - // todo. the dropping status should be append to the status after the halt completed. // It must be halted for a source stream task, since when the related scan-history-data task start scan the history // for the step 2. - int8_t status = pStreamTask->status.taskStatus; if (pStreamTask->info.taskLevel == TASK_LEVEL__SOURCE) { - ASSERT(status == TASK_STATUS__HALT || status == TASK_STATUS__DROPPING); + ASSERT(status == TASK_STATUS__HALT || status == TASK_STATUS__DROPPING || status == TASK_STATUS__STOP); } else { - ASSERT(status == TASK_STATUS__NORMAL); - pStreamTask->status.taskStatus = TASK_STATUS__HALT; + ASSERT(status == TASK_STATUS__READY|| status == TASK_STATUS__DROPPING || status == TASK_STATUS__STOP); + streamTaskHandleEvent(pStreamTask->status.pSM, TASK_EVENT_HALT); stDebug("s-task:%s halt by related fill-history task:%s", pStreamTask->id.idStr, pTask->id.idStr); } @@ -333,13 +330,14 @@ int32_t streamDoTransferStateToStreamTask(SStreamTask* pTask) { // In case of sink tasks, no need to halt them. // In case of source tasks and agg tasks, we should HALT them, and wait for them to be idle. And then, it's safe to // start the task state transfer procedure. - // When a task is idle with halt status, all data in inputQ are consumed. + char* p = NULL; + streamTaskGetStatus(pStreamTask, &p); if (pStreamTask->info.taskLevel == TASK_LEVEL__SOURCE) { // update the scan data range for source task. stDebug("s-task:%s level:%d stream task window %" PRId64 " - %" PRId64 " update to %" PRId64 " - %" PRId64 - ", status:%s, sched-status:%d", - pStreamTask->id.idStr, TASK_LEVEL__SOURCE, pTimeWindow->skey, pTimeWindow->ekey, INT64_MIN, - pTimeWindow->ekey, streamGetTaskStatusStr(TASK_STATUS__NORMAL), pStreamTask->status.schedStatus); + ", status:%s, sched-status:%d", + pStreamTask->id.idStr, TASK_LEVEL__SOURCE, pTimeWindow->skey, pTimeWindow->ekey, INT64_MIN, + pTimeWindow->ekey, p, pStreamTask->status.schedStatus); } else { stDebug("s-task:%s no need to update time window for non-source task", pStreamTask->id.idStr); } @@ -354,7 +352,7 @@ int32_t streamDoTransferStateToStreamTask(SStreamTask* pTask) { // 3. resume the state of stream task, after this function, the stream task will run immidately. But it can not be // pause, since the pause allowed attribute is not set yet. - streamTaskResumeFromHalt(pStreamTask); + streamTaskResume(pStreamTask); // todo refactor: use streamTaskResume. stDebug("s-task:%s fill-history task set status to be dropping, save the state into disk", pTask->id.idStr); @@ -362,20 +360,21 @@ int32_t streamDoTransferStateToStreamTask(SStreamTask* pTask) { streamBuildAndSendDropTaskMsg(pTask->pMsgCb, pMeta->vgId, &pTask->id); // 5. clear the link between fill-history task and stream task info - pStreamTask->hTaskInfo.id.taskId = 0; - pStreamTask->hTaskInfo.id.streamId = 0; +// CLEAR_RELATED_FILLHISTORY_TASK(pStreamTask); // 6. save to disk taosWLockLatch(&pMeta->lock); - streamMetaSaveTask(pMeta, pStreamTask); - if (streamMetaCommit(pMeta) < 0) { + + pStreamTask->status.taskStatus = streamTaskGetStatus(pStreamTask, NULL); +// streamMetaSaveTask(pMeta, pStreamTask); +// if (streamMetaCommit(pMeta) < 0) { // persist to disk - } +// } taosWUnLockLatch(&pMeta->lock); // 7. pause allowed. streamTaskEnablePause(pStreamTask); - if (taosQueueEmpty(pStreamTask->inputInfo.queue->pQueue)) { + if ((pStreamTask->info.taskLevel == TASK_LEVEL__SOURCE) && taosQueueEmpty(pStreamTask->inputq.queue->pQueue)) { SStreamRefDataBlock* pItem = taosAllocateQitem(sizeof(SStreamRefDataBlock), DEF_QITEM, 0); SSDataBlock* pDelBlock = createSpecialDataBlock(STREAM_DELETE_DATA); @@ -492,7 +491,7 @@ int32_t streamProcessTranstateBlock(SStreamTask* pTask, SStreamDataBlock* pBlock code = taosWriteQitem(pTask->outputq.queue->pQueue, pBlock); if (code == 0) { streamDispatchStreamBlock(pTask); - } else { + } else { // todo put into queue failed, retry streamFreeQitem((SStreamQueueItem*)pBlock); } } else { // level == TASK_LEVEL__SINK @@ -500,12 +499,12 @@ int32_t streamProcessTranstateBlock(SStreamTask* pTask, SStreamDataBlock* pBlock } } else { // non-dispatch task, do task state transfer directly streamFreeQitem((SStreamQueueItem*)pBlock); - stDebug("s-task:%s non-dispatch task, start to transfer state directly", id); + stDebug("s-task:%s non-dispatch task, level:%d start to transfer state directly", id, pTask->info.taskLevel); ASSERT(pTask->info.fillHistory == 1); - code = streamTransferStateToStreamTask(pTask); + code = streamTransferStateToStreamTask(pTask); if (code != TSDB_CODE_SUCCESS) { - /*int8_t status = */ streamTaskSetSchedStatusInActive(pTask); + /*int8_t status = */ streamTaskSetSchedStatusInactive(pTask); } } @@ -526,7 +525,7 @@ int32_t streamExecForAll(SStreamTask* pTask) { int32_t blockSize = 0; int32_t numOfBlocks = 0; SStreamQueueItem* pInput = NULL; - if (streamTaskShouldStop(&pTask->status)) { + if (streamTaskShouldStop(pTask) || (streamTaskGetStatus(pTask, NULL) == TASK_STATUS__UNINIT)) { stDebug("s-task:%s stream task is stopped", id); break; } @@ -592,8 +591,9 @@ int32_t streamExecForAll(SStreamTask* pTask) { // todo other thread may change the status // do nothing after sync executor state to storage backend, untill the vnode-level checkpoint is completed. if (type == STREAM_INPUT__CHECKPOINT) { - stDebug("s-task:%s checkpoint block received, set status:%s", pTask->id.idStr, - streamGetTaskStatusStr(pTask->status.taskStatus)); + char* p = NULL; + streamTaskGetStatus(pTask, &p); + stDebug("s-task:%s checkpoint block received, set status:%s", pTask->id.idStr, p); streamTaskBuildCheckpoint(pTask); return 0; } @@ -605,8 +605,15 @@ int32_t streamExecForAll(SStreamTask* pTask) { // the task may be set dropping/stopping, while it is still in the task queue, therefore, the sched-status can not // be updated by tryExec function, therefore, the schedStatus will always be the TASK_SCHED_STATUS__WAITING. bool streamTaskIsIdle(const SStreamTask* pTask) { - return (pTask->status.schedStatus == TASK_SCHED_STATUS__INACTIVE || pTask->status.taskStatus == TASK_STATUS__STOP || - pTask->status.taskStatus == TASK_STATUS__DROPPING); + ETaskStatus status = streamTaskGetStatus(pTask, NULL); + return (pTask->status.schedStatus == TASK_SCHED_STATUS__INACTIVE || status == TASK_STATUS__STOP || + status == TASK_STATUS__DROPPING); +} + +bool streamTaskReadyToRun(const SStreamTask* pTask, char** pStatus) { + ETaskStatus st = streamTaskGetStatus(pTask, NULL); + return (st == TASK_STATUS__READY || st == TASK_STATUS__SCAN_HISTORY || st == TASK_STATUS__STREAM_SCAN_HISTORY || + st == TASK_STATUS__CK); } int32_t streamExecTask(SStreamTask* pTask) { @@ -623,20 +630,23 @@ int32_t streamExecTask(SStreamTask* pTask) { } taosThreadMutexLock(&pTask->lock); - if ((streamQueueGetNumOfItems(pTask->inputInfo.queue) == 0) || streamTaskShouldStop(&pTask->status) || - streamTaskShouldPause(&pTask->status)) { + if ((streamQueueGetNumOfItems(pTask->inputq.queue) == 0) || streamTaskShouldStop(pTask) || + streamTaskShouldPause(pTask)) { atomic_store_8(&pTask->status.schedStatus, TASK_SCHED_STATUS__INACTIVE); taosThreadMutexUnlock(&pTask->lock); - stDebug("s-task:%s exec completed, status:%s, sched-status:%d", id, - streamGetTaskStatusStr(pTask->status.taskStatus), pTask->status.schedStatus); + char* p = NULL; + streamTaskGetStatus(pTask, &p); + stDebug("s-task:%s exec completed, status:%s, sched-status:%d", id, p, pTask->status.schedStatus); return 0; } taosThreadMutexUnlock(&pTask->lock); } } else { - stDebug("s-task:%s already started to exec by other thread, status:%s, sched-status:%d", id, - streamGetTaskStatusStr(pTask->status.taskStatus), pTask->status.schedStatus); + char* p = NULL; + streamTaskGetStatus(pTask, &p); + stDebug("s-task:%s already started to exec by other thread, status:%s, sched-status:%d", id, p, + pTask->status.schedStatus); } return 0; diff --git a/source/libs/stream/src/streamMeta.c b/source/libs/stream/src/streamMeta.c index 86f9afe59f..f788e244cd 100644 --- a/source/libs/stream/src/streamMeta.c +++ b/source/libs/stream/src/streamMeta.c @@ -143,8 +143,8 @@ SStreamMeta* streamMetaOpen(const char* path, void* ahandle, FTaskExpand expandF goto _err; } - pMeta->pUpdateTaskSet = taosHashInit(64, fp, false, HASH_NO_LOCK); - if (pMeta->pUpdateTaskSet == NULL) { + pMeta->updateInfo.pTasks = taosHashInit(64, fp, false, HASH_NO_LOCK); + if (pMeta->updateInfo.pTasks == NULL) { goto _err; } @@ -211,7 +211,7 @@ SStreamMeta* streamMetaOpen(const char* path, void* ahandle, FTaskExpand expandF stage); return pMeta; -_err: + _err: taosMemoryFree(pMeta->path); if (pMeta->pTasksMap) taosHashCleanup(pMeta->pTasksMap); if (pMeta->pTaskList) taosArrayDestroy(pMeta->pTaskList); @@ -219,7 +219,7 @@ _err: if (pMeta->pCheckpointDb) tdbTbClose(pMeta->pCheckpointDb); if (pMeta->db) tdbClose(pMeta->db); if (pMeta->pHbInfo) taosMemoryFreeClear(pMeta->pHbInfo); - if (pMeta->pUpdateTaskSet) taosHashCleanup(pMeta->pUpdateTaskSet); + if (pMeta->updateInfo.pTasks) taosHashCleanup(pMeta->updateInfo.pTasks); if (pMeta->startInfo.pReadyTaskSet) taosHashCleanup(pMeta->startInfo.pReadyTaskSet); taosMemoryFree(pMeta); @@ -228,11 +228,15 @@ _err: } int32_t streamMetaReopen(SStreamMeta* pMeta) { + // backup the restart flag + int32_t restartFlag = pMeta->startInfo.startAllTasksFlag; streamMetaClear(pMeta); + pMeta->startInfo.startAllTasksFlag = restartFlag; + + // NOTE: role should not be changed during reopen meta pMeta->streamBackendRid = -1; pMeta->streamBackend = NULL; - pMeta->role = NODE_ROLE_UNINIT; char* defaultPath = taosMemoryCalloc(1, strlen(pMeta->path) + 128); sprintf(defaultPath, "%s%s%s", pMeta->path, TD_DIRSEP, "state"); @@ -274,6 +278,7 @@ int32_t streamMetaReopen(SStreamMeta* pMeta) { } void streamMetaClear(SStreamMeta* pMeta) { + // remove all existed tasks in this vnode void* pIter = NULL; while ((pIter = taosHashIterate(pMeta->pTasksMap, pIter)) != NULL) { SStreamTask* p = *(SStreamTask**)pIter; @@ -299,6 +304,9 @@ void streamMetaClear(SStreamMeta* pMeta) { taosArrayClear(pMeta->chkpInUse); pMeta->numOfStreamTasks = 0; pMeta->numOfPausedTasks = 0; + pMeta->chkptNotReadyTasks = 0; + + streamMetaResetStartInfo(&pMeta->startInfo); } void streamMetaClose(SStreamMeta* pMeta) { @@ -336,7 +344,7 @@ void streamMetaCloseImpl(void* arg) { taosHashCleanup(pMeta->pTasksMap); taosHashCleanup(pMeta->pTaskBackendUnique); - taosHashCleanup(pMeta->pUpdateTaskSet); + taosHashCleanup(pMeta->updateInfo.pTasks); taosHashCleanup(pMeta->startInfo.pReadyTaskSet); taosMemoryFree(pMeta->pHbInfo); @@ -348,6 +356,7 @@ void streamMetaCloseImpl(void* arg) { stDebug("end to close stream meta"); } +// todo let's check the status for each task int32_t streamMetaSaveTask(SStreamMeta* pMeta, SStreamTask* pTask) { void* buf = NULL; int32_t len; @@ -437,31 +446,13 @@ int32_t streamMetaGetNumOfTasks(SStreamMeta* pMeta) { return (int32_t)size; } -int32_t streamMetaGetNumOfStreamTasks(SStreamMeta* pMeta) { - int32_t num = 0; - size_t size = taosArrayGetSize(pMeta->pTaskList); - for (int32_t i = 0; i < size; ++i) { - STaskId* pId = taosArrayGet(pMeta->pTaskList, i); - SStreamTask** p = taosHashGet(pMeta->pTasksMap, pId, sizeof(*pId)); - if (p == NULL) { - continue; - } - - if ((*p)->info.fillHistory == 0) { - num += 1; - } - } - - return num; -} - SStreamTask* streamMetaAcquireTask(SStreamMeta* pMeta, int64_t streamId, int32_t taskId) { taosRLockLatch(&pMeta->lock); STaskId id = {.streamId = streamId, .taskId = taskId}; SStreamTask** ppTask = (SStreamTask**)taosHashGet(pMeta->pTasksMap, &id, sizeof(id)); if (ppTask != NULL) { - if (!streamTaskShouldStop(&(*ppTask)->status)) { + if (!streamTaskShouldStop(*ppTask)) { int32_t ref = atomic_add_fetch_32(&(*ppTask)->refCnt, 1); taosRUnLockLatch(&pMeta->lock); stTrace("s-task:%s acquire task, ref:%d", (*ppTask)->id.idStr, ref); @@ -478,7 +469,7 @@ void streamMetaReleaseTask(SStreamMeta* UNUSED_PARAM(pMeta), SStreamTask* pTask) if (ref > 0) { stTrace("s-task:%s release task, ref:%d", pTask->id.idStr, ref); } else if (ref == 0) { - ASSERT(streamTaskShouldStop(&pTask->status)); + ASSERT(streamTaskShouldStop(pTask)); stTrace("s-task:%s all refs are gone, free it", pTask->id.idStr); tFreeStreamTask(pTask); } else if (ref < 0) { @@ -506,11 +497,15 @@ int32_t streamMetaUnregisterTask(SStreamMeta* pMeta, int64_t streamId, int32_t t SStreamTask** ppTask = (SStreamTask**)taosHashGet(pMeta->pTasksMap, &id, sizeof(id)); if (ppTask) { pTask = *ppTask; - if (streamTaskShouldPause(&pTask->status)) { + + // desc the paused task counter + if (streamTaskShouldPause(pTask)) { int32_t num = atomic_sub_fetch_32(&pMeta->numOfPausedTasks, 1); stInfo("vgId:%d s-task:%s drop stream task. pause task num:%d", pMeta->vgId, pTask->id.idStr, num); } - atomic_store_8(&pTask->status.taskStatus, TASK_STATUS__DROPPING); + + // handle the dropping event + streamTaskHandleEvent(pTask->status.pSM, TASK_EVENT_DROPPING); } else { stDebug("vgId:%d failed to find the task:0x%x, it may be dropped already", pMeta->vgId, taskId); taosWUnLockLatch(&pMeta->lock); @@ -518,13 +513,12 @@ int32_t streamMetaUnregisterTask(SStreamMeta* pMeta, int64_t streamId, int32_t t } taosWUnLockLatch(&pMeta->lock); - stDebug("s-task:0x%x set task status:%s and start to unregister it", taskId, - streamGetTaskStatusStr(TASK_STATUS__DROPPING)); + stDebug("s-task:0x%x set task status:dropping and start to unregister it", taskId); while (1) { taosRLockLatch(&pMeta->lock); - ppTask = (SStreamTask**)taosHashGet(pMeta->pTasksMap, &id, sizeof(id)); + ppTask = (SStreamTask**)taosHashGet(pMeta->pTasksMap, &id, sizeof(id)); if (ppTask) { if ((*ppTask)->status.timerActive == 0) { taosRUnLockLatch(&pMeta->lock); @@ -544,23 +538,19 @@ int32_t streamMetaUnregisterTask(SStreamMeta* pMeta, int64_t streamId, int32_t t taosWLockLatch(&pMeta->lock); ppTask = (SStreamTask**)taosHashGet(pMeta->pTasksMap, &id, sizeof(id)); if (ppTask) { + pTask = *ppTask; + // it is an fill-history task, remove the related stream task's id that points to it - if ((*ppTask)->info.fillHistory == 1) { - STaskId streamTaskId = {.streamId = (*ppTask)->streamTaskId.streamId, .taskId = (*ppTask)->streamTaskId.taskId}; - SStreamTask** ppStreamTask = (SStreamTask**)taosHashGet(pMeta->pTasksMap, &streamTaskId, sizeof(streamTaskId)); - if (ppStreamTask != NULL) { - (*ppStreamTask)->hTaskInfo.id.taskId = 0; - (*ppStreamTask)->hTaskInfo.id.streamId = 0; - } + if (pTask->info.fillHistory == 1) { + streamTaskClearHTaskAttr(pTask); } else { atomic_sub_fetch_32(&pMeta->numOfStreamTasks, 1); } taosHashRemove(pMeta->pTasksMap, &id, sizeof(id)); - atomic_store_8(&pTask->status.taskStatus, TASK_STATUS__DROPPING); + doRemoveIdFromList(pMeta, (int32_t)taosArrayGetSize(pMeta->pTaskList), &pTask->id); ASSERT(pTask->status.timerActive == 0); - doRemoveIdFromList(pMeta, (int32_t)taosArrayGetSize(pMeta->pTaskList), &pTask->id); if (pTask->info.triggerParam != 0 && pTask->info.fillHistory == 0) { stDebug("s-task:%s stop schedTimer, and (before) desc ref:%d", pTask->id.idStr, pTask->refCnt); @@ -691,7 +681,8 @@ int32_t streamMetaLoadAllTasks(SStreamMeta* pMeta) { tFreeStreamTask(pTask); stError( "vgId:%d stream read incompatible data, rm %s/vnode/vnode*/tq/stream if taosd cannot start, and rebuild " - "stream manually", vgId, tsDataDir); + "stream manually", + vgId, tsDataDir); return -1; } tDecoderClear(&decoder); @@ -701,8 +692,8 @@ int32_t streamMetaLoadAllTasks(SStreamMeta* pMeta) { tFreeStreamTask(pTask); STaskId id = streamTaskExtractKey(pTask); - taosArrayPush(pRecycleList, &id); + int32_t total = taosArrayGetSize(pRecycleList); stDebug("s-task:0x%x is already dropped, add into recycle list, total:%d", taskId, total); continue; @@ -738,7 +729,7 @@ int32_t streamMetaLoadAllTasks(SStreamMeta* pMeta) { atomic_add_fetch_32(&pMeta->numOfStreamTasks, 1); } - if (streamTaskShouldPause(&pTask->status)) { + if (streamTaskShouldPause(pTask)) { atomic_add_fetch_32(&pMeta->numOfPausedTasks, 1); } @@ -790,6 +781,15 @@ int32_t tEncodeStreamHbMsg(SEncoder* pEncoder, const SStreamHbMsg* pReq) { if (tEncodeI64(pEncoder, ps->activeCheckpointId) < 0) return -1; if (tEncodeI8(pEncoder, ps->checkpointFailed) < 0) return -1; } + + int32_t numOfVgs = taosArrayGetSize(pReq->pUpdateNodes); + if (tEncodeI32(pEncoder, numOfVgs) < 0) return -1; + + for (int j = 0; j < numOfVgs; ++j) { + int32_t* pVgId = taosArrayGet(pReq->pUpdateNodes, j); + if (tEncodeI32(pEncoder, *pVgId) < 0) return -1; + } + tEndEncode(pEncoder); return pEncoder->pos; } @@ -823,6 +823,17 @@ int32_t tDecodeStreamHbMsg(SDecoder* pDecoder, SStreamHbMsg* pReq) { taosArrayPush(pReq->pTaskStatus, &entry); } + int32_t numOfVgs = 0; + if (tDecodeI32(pDecoder, &numOfVgs) < 0) return -1; + + pReq->pUpdateNodes = taosArrayInit(numOfVgs, sizeof(int32_t)); + + for (int j = 0; j < numOfVgs; ++j) { + int32_t vgId = 0; + if (tDecodeI32(pDecoder, &vgId) < 0) return -1; + taosArrayPush(pReq->pUpdateNodes, &vgId); + } + tEndDecode(pDecoder); return 0; } @@ -852,8 +863,8 @@ void metaHbToMnode(void* param, void* tmrId) { } // not leader not send msg - if (pMeta->role == NODE_ROLE_FOLLOWER) { - stInfo("vgId:%d follower not send hb to mnode", pMeta->vgId); + if (pMeta->role != NODE_ROLE_LEADER) { + stInfo("vgId:%d role:%d not leader not send hb to mnode", pMeta->vgId, pMeta->role); taosReleaseRef(streamMetaId, rid); pMeta->pHbInfo->hbStart = 0; return; @@ -877,13 +888,14 @@ void metaHbToMnode(void* param, void* tmrId) { int32_t numOfTasks = streamMetaGetNumOfTasks(pMeta); SEpSet epset = {0}; - bool hasValEpset = false; + bool hasMnodeEpset = false; + hbMsg.vgId = pMeta->vgId; hbMsg.pTaskStatus = taosArrayInit(numOfTasks, sizeof(STaskStatusEntry)); + hbMsg.pUpdateNodes = taosArrayInit(numOfTasks, sizeof(int32_t)); for (int32_t i = 0; i < numOfTasks; ++i) { - STaskId* pId = taosArrayGet(pMeta->pTaskList, i); - + STaskId* pId = taosArrayGet(pMeta->pTaskList, i); SStreamTask** pTask = taosHashGet(pMeta->pTasksMap, pId, sizeof(*pId)); // not report the status of fill-history task @@ -893,10 +905,10 @@ void metaHbToMnode(void* param, void* tmrId) { STaskStatusEntry entry = { .id = *pId, - .status = (*pTask)->status.taskStatus, + .status = streamTaskGetStatus(*pTask, NULL), .nodeId = pMeta->vgId, .stage = pMeta->stage, - .inputQUsed = SIZE_IN_MiB(streamQueueGetItemSize((*pTask)->inputInfo.queue)), + .inputQUsed = SIZE_IN_MiB(streamQueueGetItemSize((*pTask)->inputq.queue)), }; entry.inputRate = entry.inputQUsed*100.0/STREAM_TASK_QUEUE_CAPACITY_IN_SIZE; @@ -915,18 +927,39 @@ void metaHbToMnode(void* param, void* tmrId) { walReaderValidVersionRange((*pTask)->exec.pWalReader, &entry.verStart, &entry.verEnd); } - taosArrayPush(hbMsg.pTaskStatus, &entry); + taosThreadMutexLock(&(*pTask)->lock); + int32_t num = taosArrayGetSize((*pTask)->outputInfo.pDownstreamUpdateList); + for (int j = 0; j < num; ++j) { + int32_t *pNodeId = taosArrayGet((*pTask)->outputInfo.pDownstreamUpdateList, j); - if (!hasValEpset) { + bool exist = false; + int32_t numOfExisted = taosArrayGetSize(hbMsg.pUpdateNodes); + for (int k = 0; k < numOfExisted; ++k) { + if (*pNodeId == *(int32_t*)taosArrayGet(hbMsg.pUpdateNodes, k)) { + exist = true; + break; + } + } + + if (!exist) { + taosArrayPush(hbMsg.pUpdateNodes, pNodeId); + } + } + + taosArrayClear((*pTask)->outputInfo.pDownstreamUpdateList); + taosThreadMutexUnlock(&(*pTask)->lock); + + taosArrayPush(hbMsg.pTaskStatus, &entry); + if (!hasMnodeEpset) { epsetAssign(&epset, &(*pTask)->info.mnodeEpset); - hasValEpset = true; + hasMnodeEpset = true; } } hbMsg.numOfTasks = taosArrayGetSize(hbMsg.pTaskStatus); taosRUnLockLatch(&pMeta->lock); - if (hasValEpset) { + if (hasMnodeEpset) { int32_t code = 0; int32_t tlen = 0; @@ -971,13 +1004,14 @@ void metaHbToMnode(void* param, void* tmrId) { } taosArrayDestroy(hbMsg.pTaskStatus); + taosArrayDestroy(hbMsg.pUpdateNodes); + taosTmrReset(metaHbToMnode, META_HB_CHECK_INTERVAL, param, streamEnv.timer, &pMeta->pHbInfo->hbTmr); taosReleaseRef(streamMetaId, rid); } -static bool hasStreamTaskInTimer(SStreamMeta* pMeta) { +bool streamMetaTaskInTimer(SStreamMeta* pMeta) { bool inTimer = false; - taosWLockLatch(&pMeta->lock); void* pIter = NULL; @@ -1031,7 +1065,7 @@ void streamMetaNotifyClose(SStreamMeta* pMeta) { stDebug("vgId:%d start to check all tasks", vgId); int64_t st = taosGetTimestampMs(); - while (hasStreamTaskInTimer(pMeta)) { + while (streamMetaTaskInTimer(pMeta)) { stDebug("vgId:%d some tasks in timer, wait for 100ms and recheck", pMeta->vgId); taosMsleep(100); } @@ -1054,5 +1088,6 @@ void streamMetaInitForSnode(SStreamMeta* pMeta) { void streamMetaResetStartInfo(STaskStartInfo* pStartInfo) { taosHashClear(pStartInfo->pReadyTaskSet); - pStartInfo->startedAfterNodeUpdate = 0; + pStartInfo->startAllTasksFlag = 0; + pStartInfo->readyTs = 0; } \ No newline at end of file diff --git a/source/libs/stream/src/streamQueue.c b/source/libs/stream/src/streamQueue.c index ae285046ef..eae4605dbc 100644 --- a/source/libs/stream/src/streamQueue.c +++ b/source/libs/stream/src/streamQueue.c @@ -18,7 +18,7 @@ #define MAX_STREAM_EXEC_BATCH_NUM 32 #define MAX_SMOOTH_BURST_RATIO 5 // 5 sec #define WAIT_FOR_DURATION 40 -#define SINK_TASK_IDLE_DURATION 200 // 200 ms +#define OUTPUT_QUEUE_FULL_WAIT_DURATION 500 // 500 ms // todo refactor: // read data from input queue @@ -119,17 +119,8 @@ int32_t streamQueueGetNumOfItems(const SStreamQueue* pQueue) { return numOfItems1 + numOfItems2; } -int32_t streamQueueGetAvailableSpace(const SStreamQueue* pQueue, int32_t* availNum, double* availSize) { - int32_t num = streamQueueGetNumOfItems(pQueue); - *availNum = STREAM_TASK_QUEUE_CAPACITY - num; - - *availSize = STREAM_TASK_QUEUE_CAPACITY_IN_SIZE - taosQueueMemorySize(pQueue->pQueue); - return 0; -} - -// todo: fix it: data in Qall is not included here int32_t streamQueueGetItemSize(const SStreamQueue* pQueue) { - return taosQueueMemorySize(pQueue->pQueue); + return taosQueueMemorySize(pQueue->pQueue) + taosQallUnAccessedMemSize(pQueue->qall); } int32_t streamQueueItemGetSize(const SStreamQueueItem* pItem) { @@ -173,12 +164,12 @@ int32_t streamTaskGetDataFromInputQ(SStreamTask* pTask, SStreamQueueItem** pInpu } while (1) { - if (streamTaskShouldPause(&pTask->status) || streamTaskShouldStop(&pTask->status)) { + if (streamTaskShouldPause(pTask) || streamTaskShouldStop(pTask)) { stDebug("s-task:%s task should pause, extract input blocks:%d", pTask->id.idStr, *numOfBlocks); return TSDB_CODE_SUCCESS; } - SStreamQueueItem* qItem = streamQueueNextItem(pTask->inputInfo.queue); + SStreamQueueItem* qItem = streamQueueNextItem(pTask->inputq.queue); if (qItem == NULL) { if ((taskLevel == TASK_LEVEL__SOURCE || taskLevel == TASK_LEVEL__SINK) && (++retryTimes) < MAX_RETRY_TIMES) { taosMsleep(WAIT_FOR_DURATION); @@ -220,7 +211,7 @@ int32_t streamTaskGetDataFromInputQ(SStreamTask* pTask, SStreamQueueItem** pInpu streamTaskConsumeQuota(pTask->outputInfo.pTokenBucket, *blockSize); } - streamQueueProcessFail(pTask->inputInfo.queue); + streamQueueProcessFail(pTask->inputq.queue); return TSDB_CODE_SUCCESS; } } else { @@ -241,7 +232,7 @@ int32_t streamTaskGetDataFromInputQ(SStreamTask* pTask, SStreamQueueItem** pInpu streamTaskConsumeQuota(pTask->outputInfo.pTokenBucket, *blockSize); } - streamQueueProcessFail(pTask->inputInfo.queue); + streamQueueProcessFail(pTask->inputq.queue); return TSDB_CODE_SUCCESS; } @@ -249,7 +240,7 @@ int32_t streamTaskGetDataFromInputQ(SStreamTask* pTask, SStreamQueueItem** pInpu } *numOfBlocks += 1; - streamQueueProcessSuccess(pTask->inputInfo.queue); + streamQueueProcessSuccess(pTask->inputq.queue); if (*numOfBlocks >= MAX_STREAM_EXEC_BATCH_NUM) { stDebug("s-task:%s batch size limit:%d reached, start to process blocks", id, MAX_STREAM_EXEC_BATCH_NUM); @@ -267,12 +258,12 @@ int32_t streamTaskGetDataFromInputQ(SStreamTask* pTask, SStreamQueueItem** pInpu int32_t streamTaskPutDataIntoInputQ(SStreamTask* pTask, SStreamQueueItem* pItem) { int8_t type = pItem->type; - STaosQueue* pQueue = pTask->inputInfo.queue->pQueue; - int32_t total = streamQueueGetNumOfItems(pTask->inputInfo.queue) + 1; + STaosQueue* pQueue = pTask->inputq.queue->pQueue; + int32_t total = streamQueueGetNumOfItems(pTask->inputq.queue) + 1; if (type == STREAM_INPUT__DATA_SUBMIT) { SStreamDataSubmit* px = (SStreamDataSubmit*)pItem; - if ((pTask->info.taskLevel == TASK_LEVEL__SOURCE) && streamQueueIsFull(pTask->inputInfo.queue)) { + if ((pTask->info.taskLevel == TASK_LEVEL__SOURCE) && streamQueueIsFull(pTask->inputq.queue)) { double size = SIZE_IN_MiB(taosQueueMemorySize(pQueue)); stTrace( "s-task:%s inputQ is full, capacity(size:%d num:%dMiB), current(blocks:%d, size:%.2fMiB) stop to push data", @@ -299,7 +290,7 @@ int32_t streamTaskPutDataIntoInputQ(SStreamTask* pTask, SStreamQueueItem* pItem) msgLen, ver, total, size + SIZE_IN_MiB(msgLen)); } else if (type == STREAM_INPUT__DATA_BLOCK || type == STREAM_INPUT__DATA_RETRIEVE || type == STREAM_INPUT__REF_DATA_BLOCK) { - if (streamQueueIsFull(pTask->inputInfo.queue)) { + if (streamQueueIsFull(pTask->inputq.queue)) { double size = SIZE_IN_MiB(taosQueueMemorySize(pQueue)); stTrace("s-task:%s input queue is full, capacity:%d size:%d MiB, current(blocks:%d, size:%.2fMiB) abort", @@ -354,7 +345,7 @@ int32_t streamTaskPutDataIntoOutputQ(SStreamTask* pTask, SStreamDataBlock* pBloc STaosQueue* pQueue = pTask->outputq.queue->pQueue; while (streamQueueIsFull(pTask->outputq.queue)) { - if (streamTaskShouldStop(&pTask->status)) { + if (streamTaskShouldStop(pTask)) { stInfo("s-task:%s discard result block due to task stop", pTask->id.idStr); return TSDB_CODE_STREAM_EXEC_CANCELLED; } @@ -362,9 +353,10 @@ int32_t streamTaskPutDataIntoOutputQ(SStreamTask* pTask, SStreamDataBlock* pBloc int32_t total = streamQueueGetNumOfItems(pTask->outputq.queue); double size = SIZE_IN_MiB(taosQueueMemorySize(pQueue)); // let's wait for there are enough space to hold this result pBlock - stDebug("s-task:%s outputQ is full, wait for 500ms and retry, outputQ items:%d, size:%.2fMiB", pTask->id.idStr, - total, size); - taosMsleep(500); + stDebug("s-task:%s outputQ is full, wait for %dms and retry, outputQ items:%d, size:%.2fMiB", pTask->id.idStr, + OUTPUT_QUEUE_FULL_WAIT_DURATION, total, size); + + taosMsleep(OUTPUT_QUEUE_FULL_WAIT_DURATION); } int32_t code = taosWriteQitem(pQueue, pBlock); @@ -381,7 +373,7 @@ int32_t streamTaskPutDataIntoOutputQ(SStreamTask* pTask, SStreamDataBlock* pBloc return TSDB_CODE_SUCCESS; } -int32_t streamTaskInitTokenBucket(STokenBucket* pBucket, int32_t numCap, int32_t numRate, int32_t quotaRate) { +int32_t streamTaskInitTokenBucket(STokenBucket* pBucket, int32_t numCap, int32_t numRate, float quotaRate) { if (numCap < 10 || numRate < 10 || pBucket == NULL) { stError("failed to init sink task bucket, cap:%d, rate:%d", numCap, numRate); return TSDB_CODE_INVALID_PARA; diff --git a/source/libs/stream/src/streamRecover.c b/source/libs/stream/src/streamStart.c similarity index 79% rename from source/libs/stream/src/streamRecover.c rename to source/libs/stream/src/streamStart.c index cd15595411..2d951147d0 100644 --- a/source/libs/stream/src/streamRecover.c +++ b/source/libs/stream/src/streamStart.c @@ -17,6 +17,7 @@ #include "trpc.h" #include "ttimer.h" #include "wal.h" +#include "streamsm.h" typedef struct SLaunchHTaskInfo { SStreamMeta* pMeta; @@ -34,16 +35,18 @@ static void streamTaskSetRangeStreamCalc(SStreamTask* pTask); static int32_t initScanHistoryReq(SStreamTask* pTask, SStreamScanHistoryReq* pReq, int8_t igUntreated); static SLaunchHTaskInfo* createHTaskLaunchInfo(SStreamMeta* pMeta, int64_t streamId, int32_t taskId); static void tryLaunchHistoryTask(void* param, void* tmrId); +static void doProcessDownstreamReadyRsp(SStreamTask* pTask); -static void streamTaskSetReady(SStreamTask* pTask, int32_t numOfReqs) { - SStreamMeta* pMeta = pTask->pMeta; - int32_t vgId = pMeta->vgId; +int32_t streamTaskSetReady(SStreamTask* pTask) { + char* p = NULL; + int32_t numOfDowns = streamTaskGetNumOfDownstream(pTask); + ETaskStatus status = streamTaskGetStatus(pTask, &p); - if (pTask->status.taskStatus == TASK_STATUS__SCAN_HISTORY && pTask->info.taskLevel != TASK_LEVEL__SOURCE) { + if ((status == TASK_STATUS__SCAN_HISTORY || status == TASK_STATUS__STREAM_SCAN_HISTORY) && + pTask->info.taskLevel != TASK_LEVEL__SOURCE) { pTask->numOfWaitingUpstream = taosArrayGetSize(pTask->upstreamInfo.pList); stDebug("s-task:%s level:%d task wait for %d upstream tasks complete scan-history procedure, status:%s", - pTask->id.idStr, pTask->info.taskLevel, pTask->numOfWaitingUpstream, - streamGetTaskStatusStr(pTask->status.taskStatus)); + pTask->id.idStr, pTask->info.taskLevel, pTask->numOfWaitingUpstream, p); } ASSERT(pTask->status.downstreamReady == 0); @@ -52,34 +55,10 @@ static void streamTaskSetReady(SStreamTask* pTask, int32_t numOfReqs) { pTask->execInfo.start = taosGetTimestampMs(); int64_t el = (pTask->execInfo.start - pTask->execInfo.init); stDebug("s-task:%s all %d downstream ready, init completed, elapsed time:%" PRId64 "ms, task status:%s", - pTask->id.idStr, numOfReqs, el, streamGetTaskStatusStr(pTask->status.taskStatus)); + pTask->id.idStr, numOfDowns, el, p); - taosWLockLatch(&pMeta->lock); - - STaskId id = streamTaskExtractKey(pTask); - taosHashPut(pMeta->startInfo.pReadyTaskSet, &id, sizeof(id), NULL, 0); - - int32_t numOfTotal = streamMetaGetNumOfTasks(pMeta); - - if (taosHashGetSize(pMeta->startInfo.pReadyTaskSet) == numOfTotal) { - STaskStartInfo* pStartInfo = &pMeta->startInfo; - pStartInfo->readyTs = pTask->execInfo.start; - - if (pStartInfo->startTs != 0) { - pStartInfo->elapsedTime = pStartInfo->readyTs - pStartInfo->startTs; - } else { - pStartInfo->elapsedTime = 0; - } - - streamMetaResetStartInfo(pStartInfo); - - stDebug("vgId:%d all %d task(s) are started successfully, last ready task:%s level:%d, startTs:%" PRId64 - ", readyTs:%" PRId64 " total elapsed time:%.2fs", - vgId, numOfTotal, pTask->id.idStr, pTask->info.taskLevel, pStartInfo->startTs, pStartInfo->readyTs, - pStartInfo->elapsedTime / 1000.0); - } - - taosWUnLockLatch(&pMeta->lock); + streamMetaUpdateTaskReadyInfo(pTask); + return TSDB_CODE_SUCCESS; } int32_t streamStartScanHistoryAsync(SStreamTask* pTask, int8_t igUntreated) { @@ -114,33 +93,28 @@ static int32_t doStartScanHistoryTask(SStreamTask* pTask) { } int32_t streamTaskStartScanHistory(SStreamTask* pTask) { - ASSERT(pTask->status.downstreamReady == 1); + int32_t level = pTask->info.taskLevel; + ETaskStatus status = streamTaskGetStatus(pTask, NULL); - if (pTask->info.taskLevel == TASK_LEVEL__SOURCE) { - if (pTask->status.taskStatus == TASK_STATUS__SCAN_HISTORY) { - return doStartScanHistoryTask(pTask); - } else { - ASSERT(pTask->status.taskStatus == TASK_STATUS__NORMAL); - stDebug("s-task:%s no need to scan-history data, status:%s, sched-status:%d, ver:%" PRId64, pTask->id.idStr, - streamGetTaskStatusStr(pTask->status.taskStatus), pTask->status.schedStatus, - walReaderGetCurrentVer(pTask->exec.pWalReader)); - streamTaskEnablePause(pTask); - } - } else if (pTask->info.taskLevel == TASK_LEVEL__AGG) { + ASSERT(pTask->status.downstreamReady == 1 && + ((status == TASK_STATUS__SCAN_HISTORY) || (status == TASK_STATUS__STREAM_SCAN_HISTORY))); + + if (level == TASK_LEVEL__SOURCE) { + return doStartScanHistoryTask(pTask); + } else if (level == TASK_LEVEL__AGG) { if (pTask->info.fillHistory) { streamSetParamForScanHistory(pTask); streamTaskEnablePause(pTask); } - } else if (pTask->info.taskLevel == TASK_LEVEL__SINK) { - if (pTask->status.taskStatus == TASK_STATUS__SCAN_HISTORY) { - stDebug("s-task:%s sink task do nothing to handle scan-history", pTask->id.idStr); - } + } else if (level == TASK_LEVEL__SINK) { + stDebug("s-task:%s sink task do nothing to handle scan-history", pTask->id.idStr); } + return 0; } // check status -static int32_t doCheckDownstreamStatus(SStreamTask* pTask) { +void streamTaskCheckDownstream(SStreamTask* pTask) { SDataRange* pRange = &pTask->dataRange; STimeWindow* pWindow = &pRange->window; @@ -152,6 +126,8 @@ static int32_t doCheckDownstreamStatus(SStreamTask* pTask) { .stage = pTask->pMeta->stage, }; + ASSERT(pTask->status.downstreamReady == 0); + // serialize streamProcessScanHistoryFinishRsp if (pTask->outputInfo.type == TASK_OUTPUT__FIXED_DISPATCH) { req.reqId = tGenIdPI64(); @@ -187,14 +163,8 @@ static int32_t doCheckDownstreamStatus(SStreamTask* pTask) { } } else { stDebug("s-task:%s (vgId:%d) set downstream ready, since no downstream", pTask->id.idStr, pTask->info.nodeId); - - streamTaskSetReady(pTask, 0); - streamTaskSetRangeStreamCalc(pTask); - streamTaskStartScanHistory(pTask); - streamLaunchFillHistoryTask(pTask); + doProcessDownstreamReadyRsp(pTask); } - - return 0; } static STaskRecheckInfo* createRecheckInfo(SStreamTask* pTask, const SStreamTaskCheckRsp* pRsp) { @@ -280,56 +250,88 @@ int32_t streamTaskCheckStatus(SStreamTask* pTask, int32_t upstreamTaskId, int32_ } if (pInfo->stage != stage) { - return TASK_SELF_NEW_STAGE; + return TASK_UPSTREAM_NEW_STAGE; } else if (pTask->status.downstreamReady != 1) { + stDebug("s-task:%s vgId:%d leader:%d, downstream not ready", id, vgId, (pTask->pMeta->role == NODE_ROLE_LEADER)); return TASK_DOWNSTREAM_NOT_READY; } else { return TASK_DOWNSTREAM_READY; } } -static void doProcessDownstreamReadyRsp(SStreamTask* pTask, int32_t numOfReqs) { - streamTaskSetReady(pTask, numOfReqs); +int32_t onNormalTaskReady(SStreamTask* pTask) { const char* id = pTask->id.idStr; - int8_t status = pTask->status.taskStatus; - const char* str = streamGetTaskStatusStr(status); - - ASSERT(status == TASK_STATUS__SCAN_HISTORY || status == TASK_STATUS__NORMAL); + streamTaskSetReady(pTask); streamTaskSetRangeStreamCalc(pTask); - if (status == TASK_STATUS__SCAN_HISTORY) { - stDebug("s-task:%s enter into scan-history data stage, status:%s", id, str); - streamTaskStartScanHistory(pTask); - } else { - // fill-history tasks are not allowed to reach here. - if (pTask->info.fillHistory == 1) { - stDebug("s-task:%s fill-history is set normal when start it, try to remove it,set it task to be dropping", id); - pTask->status.taskStatus = TASK_STATUS__DROPPING; - ASSERT(pTask->hTaskInfo.id.taskId == 0); - } else { - stDebug("s-task:%s downstream tasks are ready, now ready for data from wal, status:%s", id, str); - streamTaskEnablePause(pTask); + char* p = NULL; + ETaskStatus status = streamTaskGetStatus(pTask, &p); + ASSERT(status == TASK_STATUS__READY); + + if (pTask->info.taskLevel == TASK_LEVEL__SOURCE) { + int64_t startVer = walReaderGetCurrentVer(pTask->exec.pWalReader); + if (startVer == -1) { + startVer = pTask->chkInfo.nextProcessVer; } + + stDebug("s-task:%s no need to scan-history data, status:%s, sched-status:%d, ready for data from wal ver:%" PRId64, + id, p, pTask->status.schedStatus, startVer); + } else { + stDebug("s-task:%s level:%d status:%s sched-status:%d", id, pTask->info.taskLevel, p, pTask->status.schedStatus); } - // when current stream task is ready, check the related fill history task. - streamLaunchFillHistoryTask(pTask); + streamTaskEnablePause(pTask); + return TSDB_CODE_SUCCESS; +} + +int32_t onScanhistoryTaskReady(SStreamTask* pTask) { + const char* id = pTask->id.idStr; + + // set the state to be ready + streamTaskSetReady(pTask); + streamTaskSetRangeStreamCalc(pTask); + + char* p = NULL; + ETaskStatus status = streamTaskGetStatus(pTask, &p); + ASSERT(status == TASK_STATUS__SCAN_HISTORY || status == TASK_STATUS__STREAM_SCAN_HISTORY); + + stDebug("s-task:%s enter into scan-history data stage, status:%s", id, p); + streamTaskStartScanHistory(pTask); + + // start the related fill-history task, when current task is ready + if (HAS_RELATED_FILLHISTORY_TASK(pTask)) { + streamLaunchFillHistoryTask(pTask); + } + + return TSDB_CODE_SUCCESS; +} + +void doProcessDownstreamReadyRsp(SStreamTask* pTask) { + EStreamTaskEvent event; + if (pTask->info.fillHistory == 0) { + event = HAS_RELATED_FILLHISTORY_TASK(pTask)? TASK_EVENT_INIT_STREAM_SCANHIST:TASK_EVENT_INIT; + } else { + event = TASK_EVENT_INIT_SCANHIST; + } + + streamTaskOnHandleEventSuccess(pTask->status.pSM, event); } int32_t streamProcessCheckRsp(SStreamTask* pTask, const SStreamTaskCheckRsp* pRsp) { ASSERT(pTask->id.taskId == pRsp->upstreamTaskId); const char* id = pTask->id.idStr; + int32_t vgId = pTask->pMeta->vgId; - if (streamTaskShouldStop(&pTask->status)) { + if (streamTaskShouldStop(pTask)) { stDebug("s-task:%s should stop, do not do check downstream again", id); return TSDB_CODE_SUCCESS; } if (pRsp->status == TASK_DOWNSTREAM_READY) { if (pTask->outputInfo.type == TASK_OUTPUT__SHUFFLE_DISPATCH) { - bool found = false; + bool found = false; int32_t numOfReqs = taosArrayGetSize(pTask->checkReqIds); for (int32_t i = 0; i < numOfReqs; i++) { int64_t reqId = *(int64_t*)taosArrayGet(pTask->checkReqIds, i); @@ -350,7 +352,7 @@ int32_t streamProcessCheckRsp(SStreamTask* pTask, const SStreamTaskCheckRsp* pRs taosArrayDestroy(pTask->checkReqIds); pTask->checkReqIds = NULL; - doProcessDownstreamReadyRsp(pTask, numOfReqs); + doProcessDownstreamReadyRsp(pTask); } else { int32_t total = taosArrayGetSize(pTask->outputInfo.shuffleDispatcher.dbInfo.pVgroupInfos); stDebug("s-task:%s (vgId:%d) recv check rsp from task:0x%x (vgId:%d) status:%d, total:%d not ready:%d", id, @@ -362,27 +364,49 @@ int32_t streamProcessCheckRsp(SStreamTask* pTask, const SStreamTaskCheckRsp* pRs return -1; } - doProcessDownstreamReadyRsp(pTask, 1); + doProcessDownstreamReadyRsp(pTask); } } else { // not ready, wait for 100ms and retry - if (pRsp->status == TASK_DOWNSTREAM_NOT_LEADER) { + if (pRsp->status == TASK_UPSTREAM_NEW_STAGE) { stError( - "s-task:%s downstream taskId:0x%x (vgId:%d) vnode-transfer/leader-change detected, not send check again, " - "roll-back needed", - id, pRsp->downstreamTaskId, pRsp->downstreamNodeId); - } else if (pRsp->status == TASK_SELF_NEW_STAGE) { - stError( - "s-task:%s vnode-transfer/leader-change/restart detected, old stage:%d, current stage:%d, not send check " - "again, roll-back needed", - id, pRsp->oldStage, (int32_t)pTask->pMeta->stage); + "s-task:%s vgId:%d self vnode-transfer/leader-change/restart detected, old stage:%d, current stage:%d, " + "not check wait for downstream task nodeUpdate, and all tasks restart", + id, pRsp->upstreamNodeId, pRsp->oldStage, (int32_t)pTask->pMeta->stage); } else { + if (pRsp->status == TASK_DOWNSTREAM_NOT_LEADER) { + stError( + "s-task:%s downstream taskId:0x%x (vgId:%d) not leader, self dispatch epset needs to be updated, not check " + "downstream again, nodeUpdate needed", + id, pRsp->downstreamTaskId, pRsp->downstreamNodeId); + + taosThreadMutexLock(&pTask->lock); + int32_t num = taosArrayGetSize(pTask->outputInfo.pDownstreamUpdateList); + bool existed = false; + for (int i = 0; i < num; ++i) { + SDownstreamTaskEpset* p = taosArrayGet(pTask->outputInfo.pDownstreamUpdateList, i); + if (p->nodeId == pRsp->downstreamNodeId) { + existed = true; + break; + } + } + + if (!existed) { + SDownstreamTaskEpset t = {.nodeId = pRsp->downstreamNodeId}; + taosArrayPush(pTask->outputInfo.pDownstreamUpdateList, &t); + stInfo("s-task:%s vgId:%d downstream nodeId:%d needs to be updated, total needs updated:%d", id, vgId, + t.nodeId, (int32_t)taosArrayGetSize(pTask->outputInfo.pDownstreamUpdateList)); + } + + taosThreadMutexUnlock(&pTask->lock); + return 0; + } + STaskRecheckInfo* pInfo = createRecheckInfo(pTask, pRsp); int32_t ref = atomic_add_fetch_32(&pTask->status.timerActive, 1); stDebug("s-task:%s downstream taskId:0x%x (vgId:%d) not ready, stage:%d, retry in 100ms, ref:%d ", id, pRsp->downstreamTaskId, pRsp->downstreamNodeId, pRsp->oldStage, ref); - - taosTmrReset(recheckDownstreamTasks, CHECK_DOWNSTREAM_INTERVAL, pInfo, streamEnv.timer, &pInfo->checkTimer); + pInfo->checkTimer = taosTmrStart(recheckDownstreamTasks, CHECK_DOWNSTREAM_INTERVAL, pInfo, streamEnv.timer); } } @@ -426,30 +450,6 @@ int32_t streamRestoreParam(SStreamTask* pTask) { return qRestoreStreamOperatorOption(pTask->exec.pExecutor); } -int32_t streamSetStatusNormal(SStreamTask* pTask) { - int32_t status = atomic_load_8(&pTask->status.taskStatus); - if (status == TASK_STATUS__DROPPING) { - stError("s-task:%s cannot be set normal, since in dropping state", pTask->id.idStr); - return -1; - } else { - stDebug("s-task:%s set task status to be normal, prev:%s", pTask->id.idStr, streamGetTaskStatusStr(status)); - atomic_store_8(&pTask->status.taskStatus, TASK_STATUS__NORMAL); - return 0; - } -} - -int32_t streamSetStatusUnint(SStreamTask* pTask) { - int32_t status = atomic_load_8(&pTask->status.taskStatus); - if (status == TASK_STATUS__DROPPING) { - stError("s-task:%s cannot be set uninit, since in dropping state", pTask->id.idStr); - return -1; - } else { - stDebug("s-task:%s set task status to be uninit, prev:%s", pTask->id.idStr, streamGetTaskStatusStr(status)); - atomic_store_8(&pTask->status.taskStatus, TASK_STATUS__UNINIT); - return 0; - } -} - // source int32_t streamSetParamForStreamScannerStep1(SStreamTask* pTask, SVersionRange *pVerRange, STimeWindow* pWindow) { return qStreamSourceScanParamForHistoryScanStep1(pTask->exec.pExecutor, pVerRange, pWindow); @@ -515,9 +515,13 @@ int32_t streamProcessScanHistoryFinishReq(SStreamTask* pTask, SStreamScanHistory int32_t taskLevel = pTask->info.taskLevel; ASSERT(taskLevel == TASK_LEVEL__AGG || taskLevel == TASK_LEVEL__SINK); - if (pTask->status.taskStatus != TASK_STATUS__SCAN_HISTORY) { + const char* id = pTask->id.idStr; + char* p = NULL; + ETaskStatus status = streamTaskGetStatus(pTask, &p); + + if (status != TASK_STATUS__SCAN_HISTORY && status != TASK_STATUS__STREAM_SCAN_HISTORY) { stError("s-task:%s not in scan-history status, status:%s return upstream:0x%x scan-history finish directly", - pTask->id.idStr, streamGetTaskStatusStr(pTask->status.taskStatus), pReq->upstreamTaskId); + id, p, pReq->upstreamTaskId); void* pBuf = NULL; int32_t len = 0; @@ -527,8 +531,8 @@ int32_t streamProcessScanHistoryFinishReq(SStreamTask* pTask, SStreamScanHistory initRpcMsg(&msg, 0, pBuf, sizeof(SMsgHead) + len); tmsgSendRsp(&msg); - stDebug("s-task:%s level:%d notify upstream:0x%x(vgId:%d) to continue process data in WAL", pTask->id.idStr, - pTask->info.taskLevel, pReq->upstreamTaskId, pReq->upstreamNodeId); + stDebug("s-task:%s level:%d notify upstream:0x%x(vgId:%d) to continue process data in WAL", id, + taskLevel, pReq->upstreamTaskId, pReq->upstreamNodeId); return 0; } @@ -540,13 +544,15 @@ int32_t streamProcessScanHistoryFinishReq(SStreamTask* pTask, SStreamScanHistory if (left == 0) { int32_t numOfTasks = taosArrayGetSize(pTask->upstreamInfo.pList); - stDebug( - "s-task:%s all %d upstream tasks finish scan-history data, set param for agg task for stream data and send " - "rsp to all upstream tasks", - pTask->id.idStr, numOfTasks); - - if (pTask->info.taskLevel == TASK_LEVEL__AGG) { + if (taskLevel == TASK_LEVEL__AGG) { + stDebug( + "s-task:%s all %d upstream tasks finish scan-history data, set param for agg task for stream data processing " + "and send rsp to all upstream tasks", + id, numOfTasks); streamAggUpstreamScanHistoryFinish(pTask); + } else { + stDebug("s-task:%s all %d upstream task(s) finish scan-history data, and rsp to all upstream tasks", id, + numOfTasks); } // all upstream tasks have completed the scan-history task in the stream time window, let's start to extract data @@ -557,26 +563,25 @@ int32_t streamProcessScanHistoryFinishReq(SStreamTask* pTask, SStreamScanHistory if (taskLevel == TASK_LEVEL__AGG) { /*int32_t code = */streamTaskScanHistoryDataComplete(pTask); } else { // for sink task, set normal - if (pTask->status.taskStatus != TASK_STATUS__PAUSE && pTask->status.taskStatus != TASK_STATUS__STOP && - pTask->status.taskStatus != TASK_STATUS__DROPPING) { - streamSetStatusNormal(pTask); - } + streamTaskHandleEvent(pTask->status.pSM, TASK_EVENT_SCANHIST_DONE); } } else { stDebug("s-task:%s receive scan-history data finish msg from upstream:0x%x(index:%d), unfinished:%d", - pTask->id.idStr, pReq->upstreamTaskId, pReq->childId, left); + id, pReq->upstreamTaskId, pReq->childId, left); } return 0; } int32_t streamProcessScanHistoryFinishRsp(SStreamTask* pTask) { - ASSERT(pTask->status.taskStatus == TASK_STATUS__SCAN_HISTORY); + ETaskStatus status = streamTaskGetStatus(pTask, NULL); + + ASSERT(status == TASK_STATUS__SCAN_HISTORY || status == TASK_STATUS__STREAM_SCAN_HISTORY); SStreamMeta* pMeta = pTask->pMeta; // execute in the scan history complete call back msg, ready to process data from inputQ - streamSetStatusNormal(pTask); - streamTaskSetSchedStatusInActive(pTask); + streamTaskHandleEvent(pTask->status.pSM, TASK_EVENT_SCANHIST_DONE); + streamTaskSetSchedStatusInactive(pTask); taosWLockLatch(&pMeta->lock); streamMetaSaveTask(pMeta, pTask); @@ -604,15 +609,15 @@ static void checkFillhistoryTaskStatus(SStreamTask* pTask, SStreamTask* pHTask) if (pTask->info.taskLevel == TASK_LEVEL__SOURCE) { stDebug("s-task:%s set the launch condition for fill-history s-task:%s, window:%" PRId64 " - %" PRId64 - " ver range:%" PRId64 " - %" PRId64", init:%"PRId64, + " verRange:%" PRId64 " - %" PRId64", init:%"PRId64, pTask->id.idStr, pHTask->id.idStr, pRange->window.skey, pRange->window.ekey, pRange->range.minVer, pRange->range.maxVer, pHTask->execInfo.init); } else { - stDebug("s-task:%s no fill history condition for non-source task:%s", pTask->id.idStr, pHTask->id.idStr); + stDebug("s-task:%s no fill-history condition for non-source task:%s", pTask->id.idStr, pHTask->id.idStr); } // check if downstream tasks have been ready - doCheckDownstreamStatus(pHTask); + streamTaskHandleEvent(pHTask->status.pSM, TASK_EVENT_INIT_SCANHIST); } static void tryLaunchHistoryTask(void* param, void* tmrId) { @@ -624,12 +629,12 @@ static void tryLaunchHistoryTask(void* param, void* tmrId) { if (ppTask) { ASSERT((*ppTask)->status.timerActive >= 1); - if (streamTaskShouldStop(&(*ppTask)->status)) { - const char* pStatus = streamGetTaskStatusStr((*ppTask)->status.taskStatus); - + if (streamTaskShouldStop(*ppTask)) { + char* p = NULL; + streamTaskGetStatus((*ppTask), &p); int32_t ref = atomic_sub_fetch_32(&(*ppTask)->status.timerActive, 1); stDebug("s-task:%s status:%s should stop, quit launch fill-history task timer, retry:%d, ref:%d", - (*ppTask)->id.idStr, pStatus, (*ppTask)->hTaskInfo.retryTimes, ref); + (*ppTask)->id.idStr, p, (*ppTask)->hTaskInfo.retryTimes, ref); taosMemoryFree(pInfo); taosWUnLockLatch(&pMeta->lock); @@ -665,9 +670,11 @@ static void tryLaunchHistoryTask(void* param, void* tmrId) { // abort the timer if intend to stop task SStreamTask* pHTask = streamMetaAcquireTask(pMeta, pHTaskInfo->id.streamId, pHTaskInfo->id.taskId); - if (pHTask == NULL && (!streamTaskShouldStop(&pTask->status))) { - const char* p = streamGetTaskStatusStr(pTask->status.taskStatus); - int32_t hTaskId = pHTaskInfo->id.taskId; + if (pHTask == NULL && (!streamTaskShouldStop(pTask))) { + char* p = NULL; + int32_t hTaskId = pHTaskInfo->id.taskId; + + streamTaskGetStatus(pTask, &p); stDebug( "s-task:%s status:%s failed to launch fill-history task:0x%x, retry launch:%dms, retryCount:%d", pTask->id.idStr, p, hTaskId, pHTaskInfo->waitInterval, pHTaskInfo->retryTimes); @@ -713,11 +720,8 @@ SLaunchHTaskInfo* createHTaskLaunchInfo(SStreamMeta* pMeta, int64_t streamId, in int32_t streamLaunchFillHistoryTask(SStreamTask* pTask) { SStreamMeta* pMeta = pTask->pMeta; int32_t hTaskId = pTask->hTaskInfo.id.taskId; - if (hTaskId == 0) { - return TSDB_CODE_SUCCESS; - } - ASSERT(pTask->status.downstreamReady == 1); + ASSERT((hTaskId != 0) && (pTask->status.downstreamReady == 1)); stDebug("s-task:%s start to launch related fill-history task:0x%" PRIx64 "-0x%x", pTask->id.idStr, pTask->hTaskInfo.id.streamId, hTaskId); @@ -765,7 +769,7 @@ int32_t streamLaunchFillHistoryTask(SStreamTask* pTask) { } int32_t streamTaskScanHistoryDataComplete(SStreamTask* pTask) { - if (atomic_load_8(&pTask->status.taskStatus) == TASK_STATUS__DROPPING) { + if (streamTaskGetStatus(pTask, NULL) == TASK_STATUS__DROPPING) { return 0; } @@ -897,7 +901,7 @@ int32_t tDecodeStreamScanHistoryFinishReq(SDecoder* pDecoder, SStreamScanHistory void streamTaskSetRangeStreamCalc(SStreamTask* pTask) { SDataRange* pRange = &pTask->dataRange; - if (pTask->hTaskInfo.id.taskId == 0) { + if (!HAS_RELATED_FILLHISTORY_TASK(pTask)) { if (pTask->info.fillHistory == 1) { stDebug("s-task:%s fill-history task, time window:%" PRId64 "-%" PRId64 ", verRange:%" PRId64 "-%" PRId64, pTask->id.idStr, pRange->window.skey, pRange->window.ekey, pRange->range.minVer, pRange->range.maxVer); @@ -929,21 +933,8 @@ void streamTaskSetRangeStreamCalc(SStreamTask* pTask) { } } -// only the downstream tasks are ready, set the task to be ready to work. -void streamTaskCheckDownstream(SStreamTask* pTask) { - if (pTask->info.fillHistory) { - stDebug("s-task:%s fill history task, wait for being launched", pTask->id.idStr); - return; - } - - ASSERT(pTask->status.downstreamReady == 0); - doCheckDownstreamStatus(pTask); -} - -// normal -> pause, pause/stop/dropping -> pause, halt -> pause, scan-history -> pause void streamTaskPause(SStreamTask* pTask, SStreamMeta* pMeta) { - int64_t st = taosGetTimestampMs(); - +#if 0 int8_t status = pTask->status.taskStatus; if (status == TASK_STATUS__DROPPING) { stDebug("vgId:%d s-task:%s task already dropped, do nothing", pMeta->vgId, pTask->id.idStr); @@ -1001,43 +992,54 @@ void streamTaskPause(SStreamTask* pTask, SStreamMeta* pMeta) { stInfo("vgId:%d s-task:%s pause stream task. pause task num:%d", pMeta->vgId, pTask->id.idStr, num); taosWUnLockLatch(&pMeta->lock); +#endif + + streamTaskHandleEvent(pTask->status.pSM, TASK_EVENT_PAUSE); + + int32_t num = atomic_add_fetch_32(&pMeta->numOfPausedTasks, 1); + stInfo("vgId:%d s-task:%s pause stream task. pause task num:%d", pMeta->vgId, pTask->id.idStr, num); + // in case of fill-history task, stop the tsdb file scan operation. if (pTask->info.fillHistory == 1) { void* pExecutor = pTask->exec.pExecutor; qKillTask(pExecutor, TSDB_CODE_SUCCESS); } - int64_t el = taosGetTimestampMs() - st; - stDebug("vgId:%d s-task:%s set pause flag, prev:%s, pause elapsed time:%dms", pMeta->vgId, pTask->id.idStr, - streamGetTaskStatusStr(pTask->status.keepTaskStatus), (int32_t)el); + stDebug("vgId:%d s-task:%s set pause flag and pause task", pMeta->vgId, pTask->id.idStr); } -void streamTaskResume(SStreamTask* pTask, SStreamMeta* pMeta) { - int8_t status = pTask->status.taskStatus; - if (status == TASK_STATUS__PAUSE) { - pTask->status.taskStatus = pTask->status.keepTaskStatus; - pTask->status.keepTaskStatus = TASK_STATUS__NORMAL; - int32_t num = atomic_sub_fetch_32(&pMeta->numOfPausedTasks, 1); - stInfo("vgId:%d s-task:%s resume from pause, status:%s. pause task num:%d", pMeta->vgId, pTask->id.idStr, streamGetTaskStatusStr(status), num); - } else if (pTask->info.taskLevel == TASK_LEVEL__SINK) { - int32_t num = atomic_sub_fetch_32(&pMeta->numOfPausedTasks, 1); - stInfo("vgId:%d s-task:%s sink task.resume from pause, status:%s. pause task num:%d", pMeta->vgId, pTask->id.idStr, streamGetTaskStatusStr(status), num); +void streamTaskResume(SStreamTask* pTask) { + char* p = NULL; + ETaskStatus status = streamTaskGetStatus(pTask, &p); + SStreamMeta* pMeta = pTask->pMeta; + + if (status == TASK_STATUS__PAUSE || status == TASK_STATUS__HALT) { + streamTaskRestoreStatus(pTask); + + char* pNew = NULL; + streamTaskGetStatus(pTask, &pNew); + if (status == TASK_STATUS__PAUSE) { + int32_t num = atomic_sub_fetch_32(&pMeta->numOfPausedTasks, 1); + stInfo("s-task:%s status:%s resume from %s, paused task(s):%d", pTask->id.idStr, pNew, p, num); + } else { + stInfo("s-task:%s status:%s resume from %s", pTask->id.idStr, pNew, p); + } } else { - stError("s-task:%s not in pause, failed to resume, status:%s", pTask->id.idStr, streamGetTaskStatusStr(status)); + stDebug("s-task:%s status:%s not in pause/halt status, no need to resume", pTask->id.idStr, p); } } // todo fix race condition void streamTaskDisablePause(SStreamTask* pTask) { // pre-condition check - const char* id = pTask->id.idStr; - while (pTask->status.taskStatus == TASK_STATUS__PAUSE) { - stDebug("s-task:%s already in pause, wait for pause being cancelled, and set pause disabled, recheck in 100ms", id); - taosMsleep(100); - } - - stDebug("s-task:%s disable task pause", id); - pTask->status.pauseAllowed = 0; +// const char* id = pTask->id.idStr; +// while (pTask->status.taskStatus == TASK_STATUS__PAUSE) { +// stDebug("s-task:%s already in pause, wait for pause being cancelled, and set pause disabled, recheck in 100ms", id); +// taosMsleep(100); +// } +// +// stDebug("s-task:%s disable task pause", id); +// pTask->status.pauseAllowed = 0; } void streamTaskEnablePause(SStreamTask* pTask) { @@ -1045,15 +1047,30 @@ void streamTaskEnablePause(SStreamTask* pTask) { pTask->status.pauseAllowed = 1; } -void streamTaskResumeFromHalt(SStreamTask* pTask) { - const char* id = pTask->id.idStr; - int8_t status = pTask->status.taskStatus; - if (status != TASK_STATUS__HALT) { - stError("s-task:%s not in halt status, status:%s", id, streamGetTaskStatusStr(status)); - return; +int32_t streamMetaUpdateTaskReadyInfo(SStreamTask* pTask) { + SStreamMeta* pMeta = pTask->pMeta; + + taosWLockLatch(&pMeta->lock); + + STaskId id = streamTaskExtractKey(pTask); + taosHashPut(pMeta->startInfo.pReadyTaskSet, &id, sizeof(id), NULL, 0); + + int32_t numOfTotal = streamMetaGetNumOfTasks(pMeta); + + if (taosHashGetSize(pMeta->startInfo.pReadyTaskSet) == numOfTotal) { + STaskStartInfo* pStartInfo = &pMeta->startInfo; + + pStartInfo->readyTs = pTask->execInfo.start; + pStartInfo->elapsedTime = (pStartInfo->startTs != 0) ? pStartInfo->readyTs - pStartInfo->startTs : 0; + + streamMetaResetStartInfo(pStartInfo); + + stDebug("vgId:%d all %d task(s) are started successfully, last ready task:%s level:%d, startTs:%" PRId64 + ", readyTs:%" PRId64 " total elapsed time:%.2fs", + pMeta->vgId, numOfTotal, pTask->id.idStr, pTask->info.taskLevel, pStartInfo->startTs, pStartInfo->readyTs, + pStartInfo->elapsedTime / 1000.0); } - pTask->status.taskStatus = pTask->status.keepTaskStatus; - pTask->status.keepTaskStatus = TASK_STATUS__NORMAL; - stDebug("s-task:%s resume from halt, current status:%s", id, streamGetTaskStatusStr(pTask->status.taskStatus)); + taosWUnLockLatch(&pMeta->lock); + return TSDB_CODE_SUCCESS; } diff --git a/source/libs/stream/src/streamTask.c b/source/libs/stream/src/streamTask.c index 37af1ce64f..f949d46315 100644 --- a/source/libs/stream/src/streamTask.c +++ b/source/libs/stream/src/streamTask.c @@ -19,6 +19,7 @@ #include "tstream.h" #include "ttimer.h" #include "wal.h" +#include "streamsm.h" static void streamTaskDestroyUpstreamInfo(SUpstreamInfo* pUpstreamInfo); @@ -34,8 +35,11 @@ SStreamTask* tNewStreamTask(int64_t streamId, int8_t taskLevel, bool fillHistory SStreamTask* pTask = (SStreamTask*)taosMemoryCalloc(1, sizeof(SStreamTask)); if (pTask == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; + stError("s-task:0x%" PRIx64 " failed malloc new stream task, size:%d, code:%s", streamId, + (int32_t)sizeof(SStreamTask), tstrerror(terrno)); return NULL; } + pTask->ver = SSTREAM_TASK_VER; pTask->id.taskId = tGenIdPI32(); pTask->id.streamId = streamId; @@ -43,13 +47,19 @@ SStreamTask* tNewStreamTask(int64_t streamId, int8_t taskLevel, bool fillHistory pTask->info.fillHistory = fillHistory; pTask->info.triggerParam = triggerParam; + pTask->status.pSM = streamCreateStateMachine(pTask); + if (pTask->status.pSM == NULL) { + taosMemoryFreeClear(pTask); + return NULL; + } + char buf[128] = {0}; sprintf(buf, "0x%" PRIx64 "-%d", pTask->id.streamId, pTask->id.taskId); pTask->id.idStr = taosStrdup(buf); pTask->status.schedStatus = TASK_SCHED_STATUS__INACTIVE; - pTask->status.taskStatus = (fillHistory || hasFillhistory)? TASK_STATUS__SCAN_HISTORY:TASK_STATUS__NORMAL; - pTask->inputInfo.status = TASK_INPUT_STATUS__NORMAL; + pTask->status.taskStatus = (fillHistory || hasFillhistory) ? TASK_STATUS__SCAN_HISTORY : TASK_STATUS__READY; + pTask->inputq.status = TASK_INPUT_STATUS__NORMAL; pTask->outputq.status = TASK_OUTPUT_STATUS__NORMAL; if (fillHistory) { @@ -296,9 +306,7 @@ void tFreeStreamTask(SStreamTask* pTask) { int32_t taskId = pTask->id.taskId; STaskExecStatisInfo* pStatis = &pTask->execInfo; - - stDebug("start to free s-task:0x%x, %p, state:%p, status:%s", taskId, pTask, pTask->pState, - streamGetTaskStatusStr(pTask->status.taskStatus)); + stDebug("start to free s-task:0x%x, %p, state:%p", taskId, pTask, pTask->pState); stDebug("s-task:0x%x task exec summary: create:%" PRId64 ", init:%" PRId64 ", start:%" PRId64 ", updateCount:%d latestUpdate:%" PRId64 ", latestCheckPoint:%" PRId64 ", ver:%" PRId64 @@ -309,8 +317,8 @@ void tFreeStreamTask(SStreamTask* pTask) { // remove the ref by timer while (pTask->status.timerActive > 0) { - stDebug("s-task:%s wait for task stop timer activities", pTask->id.idStr); - taosMsleep(10); + stDebug("s-task:%s wait for task stop timer activities, ref:%d", pTask->id.idStr, pTask->status.timerActive); + taosMsleep(100); } if (pTask->schedInfo.pTimer != NULL) { @@ -329,8 +337,8 @@ void tFreeStreamTask(SStreamTask* pTask) { } int32_t status = atomic_load_8((int8_t*)&(pTask->status.taskStatus)); - if (pTask->inputInfo.queue) { - streamQueueClose(pTask->inputInfo.queue, pTask->id.taskId); + if (pTask->inputq.queue) { + streamQueueClose(pTask->inputq.queue, pTask->id.taskId); } if (pTask->outputq.queue) { @@ -384,13 +392,18 @@ void tFreeStreamTask(SStreamTask* pTask) { pTask->pRspMsgList = NULL; } + pTask->status.pSM = streamDestroyStateMachine(pTask->status.pSM); + streamTaskDestroyUpstreamInfo(&pTask->upstreamInfo); pTask->msgInfo.pRetryList = taosArrayDestroy(pTask->msgInfo.pRetryList); taosMemoryFree(pTask->outputInfo.pTokenBucket); taosThreadMutexDestroy(&pTask->lock); - taosMemoryFree(pTask); + taosArrayDestroy(pTask->outputInfo.pDownstreamUpdateList); + pTask->outputInfo.pDownstreamUpdateList = NULL; + + taosMemoryFree(pTask); stDebug("s-task:0x%x free task completed", taskId); } @@ -399,16 +412,23 @@ int32_t streamTaskInit(SStreamTask* pTask, SStreamMeta* pMeta, SMsgCb* pMsgCb, i pTask->refCnt = 1; pTask->status.schedStatus = TASK_SCHED_STATUS__INACTIVE; pTask->status.timerActive = 0; - pTask->inputInfo.queue = streamQueueOpen(512 << 10); + pTask->inputq.queue = streamQueueOpen(512 << 10); pTask->outputq.queue = streamQueueOpen(512 << 10); - if (pTask->inputInfo.queue == NULL || pTask->outputq.queue == NULL) { + if (pTask->inputq.queue == NULL || pTask->outputq.queue == NULL) { stError("s-task:%s failed to prepare the input/output queue, initialize task failed", pTask->id.idStr); return TSDB_CODE_OUT_OF_MEMORY; } + pTask->status.pSM = streamCreateStateMachine(pTask); + if (pTask->status.pSM == NULL) { + stError("s-task:%s failed create state-machine for stream task, initialization failed, code:%s", pTask->id.idStr, + tstrerror(terrno)); + return terrno; + } + pTask->execInfo.created = taosGetTimestampMs(); - pTask->inputInfo.status = TASK_INPUT_STATUS__NORMAL; + pTask->inputq.status = TASK_INPUT_STATUS__NORMAL; pTask->outputq.status = TASK_OUTPUT_STATUS__NORMAL; pTask->pMeta = pMeta; @@ -427,7 +447,7 @@ int32_t streamTaskInit(SStreamTask* pTask, SStreamMeta* pMeta, SMsgCb* pMsgCb, i // 2MiB per second for sink task // 50 times sink operator per second - streamTaskInitTokenBucket(pTask->outputInfo.pTokenBucket, 50, 50, 2); + streamTaskInitTokenBucket(pTask->outputInfo.pTokenBucket, 50, 50, tsSinkDataRate); TdThreadMutexAttr attr = {0}; int code = taosThreadMutexAttrInit(&attr); @@ -445,6 +465,11 @@ int32_t streamTaskInit(SStreamTask* pTask, SStreamMeta* pMeta, SMsgCb* pMsgCb, i taosThreadMutexInit(&pTask->lock, &attr); streamTaskOpenAllUpstreamInput(pTask); + pTask->outputInfo.pDownstreamUpdateList = taosArrayInit(4, sizeof(SDownstreamTaskEpset)); + if (pTask->outputInfo.pDownstreamUpdateList == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + return TSDB_CODE_SUCCESS; } @@ -453,7 +478,9 @@ int32_t streamTaskGetNumOfDownstream(const SStreamTask* pTask) { return 0; } else { int32_t type = pTask->outputInfo.type; - if (type == TASK_OUTPUT__FIXED_DISPATCH || type == TASK_OUTPUT__TABLE) { + if (type == TASK_OUTPUT__TABLE) { + return 0; + } else if (type == TASK_OUTPUT__FIXED_DISPATCH) { return 1; } else { SArray* vgInfo = pTask->outputInfo.shuffleDispatcher.dbInfo.pVgroupInfos; @@ -562,13 +589,7 @@ int32_t streamTaskStop(SStreamTask* pTask) { int64_t st = taosGetTimestampMs(); const char* id = pTask->id.idStr; - taosThreadMutexLock(&pTask->lock); - if (pTask->status.taskStatus == TASK_STATUS__CK) { - stDebug("s-task:%s in checkpoint will be discarded since task is stopped", id); - } - pTask->status.taskStatus = TASK_STATUS__STOP; - taosThreadMutexUnlock(&pTask->lock); - + streamTaskHandleEvent(pTask->status.pSM, TASK_EVENT_STOP); qKillTask(pTask->exec.pExecutor, TSDB_CODE_SUCCESS); while (/*pTask->status.schedStatus != TASK_SCHED_STATUS__INACTIVE */ !streamTaskIsIdle(pTask)) { stDebug("s-task:%s level:%d wait for task to be idle and then close, check again in 100ms", id, @@ -612,7 +633,7 @@ int32_t streamTaskUpdateEpsetInfo(SStreamTask* pTask, SArray* pNodeList) { p->latestUpdateTs = taosGetTimestampMs(); p->updateCount += 1; - stDebug("s-task:%s update task nodeEp epset, updatedNodes:%d, updateCount:%d, prevTs:%" PRId64, pTask->id.idStr, + stDebug("s-task:0x%x update task nodeEp epset, updatedNodes:%d, updateCount:%d, prevTs:%" PRId64, pTask->id.taskId, numOfNodes, p->updateCount, prevTs); for (int32_t i = 0; i < taosArrayGetSize(pNodeList); ++i) { @@ -667,7 +688,7 @@ int8_t streamTaskSetSchedStatusActive(SStreamTask* pTask) { return status; } -int8_t streamTaskSetSchedStatusInActive(SStreamTask* pTask) { +int8_t streamTaskSetSchedStatusInactive(SStreamTask* pTask) { taosThreadMutexLock(&pTask->lock); int8_t status = pTask->status.schedStatus; ASSERT(status == TASK_SCHED_STATUS__WAITING || status == TASK_SCHED_STATUS__ACTIVE || @@ -678,6 +699,25 @@ int8_t streamTaskSetSchedStatusInActive(SStreamTask* pTask) { return status; } +int32_t streamTaskClearHTaskAttr(SStreamTask* pTask) { + SStreamMeta* pMeta = pTask->pMeta; + if (pTask->info.fillHistory == 0) { + return TSDB_CODE_SUCCESS; + } + + STaskId sTaskId = {.streamId = pTask->streamTaskId.streamId, .taskId = pTask->streamTaskId.taskId}; + SStreamTask** ppStreamTask = (SStreamTask**)taosHashGet(pMeta->pTasksMap, &sTaskId, sizeof(sTaskId)); + + if (ppStreamTask != NULL) { + CLEAR_RELATED_FILLHISTORY_TASK((*ppStreamTask)); + streamMetaSaveTask(pMeta, *ppStreamTask); + stDebug("s-task:%s clear the related stream task:0x%x attr to fill-history task", pTask->id.idStr, + (int32_t)sTaskId.taskId); + } + + return TSDB_CODE_SUCCESS; +} + int32_t streamBuildAndSendDropTaskMsg(SMsgCb* pMsgCb, int32_t vgId, SStreamTaskId* pTaskId) { SVDropStreamTaskReq *pReq = rpcMallocCont(sizeof(SVDropStreamTaskReq)); if (pReq == NULL) { @@ -696,7 +736,7 @@ int32_t streamBuildAndSendDropTaskMsg(SMsgCb* pMsgCb, int32_t vgId, SStreamTaskI return code; } - stDebug("vgId:%d build and send drop table:0x%x msg", vgId, pTaskId->taskId); + stDebug("vgId:%d build and send drop task:0x%x msg", vgId, pTaskId->taskId); return code; } @@ -719,20 +759,6 @@ void streamTaskSetRetryInfoForLaunch(SHistoryTaskInfo* pInfo) { pInfo->retryTimes += 1; } -const char* streamGetTaskStatusStr(int32_t status) { - switch(status) { - case TASK_STATUS__NORMAL: return "normal"; - case TASK_STATUS__SCAN_HISTORY: return "scan-history"; - case TASK_STATUS__HALT: return "halt"; - case TASK_STATUS__PAUSE: return "paused"; - case TASK_STATUS__CK: return "check-point"; - case TASK_STATUS__DROPPING: return "dropping"; - case TASK_STATUS__STOP: return "stop"; - case TASK_STATUS__UNINIT: return "uninitialized"; - default:return ""; - } -} - void streamTaskStatusInit(STaskStatusEntry* pEntry, const SStreamTask* pTask) { pEntry->id.streamId = pTask->id.streamId; pEntry->id.taskId = pTask->id.taskId; diff --git a/source/libs/stream/src/streamTaskSm.c b/source/libs/stream/src/streamTaskSm.c new file mode 100644 index 0000000000..1aa4dd8e13 --- /dev/null +++ b/source/libs/stream/src/streamTaskSm.c @@ -0,0 +1,529 @@ +/* + * 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 "streamInt.h" +#include "streamsm.h" +#include "tmisce.h" +#include "tstream.h" +#include "ttimer.h" +#include "wal.h" + +SStreamTaskState StreamTaskStatusList[9] = { + {.state = TASK_STATUS__READY, .name = "ready"}, + {.state = TASK_STATUS__DROPPING, .name = "dropped"}, + {.state = TASK_STATUS__UNINIT, .name = "uninit"}, + {.state = TASK_STATUS__STOP, .name = "stop"}, + {.state = TASK_STATUS__SCAN_HISTORY, .name = "scan-history"}, + {.state = TASK_STATUS__HALT, .name = "halt"}, + {.state = TASK_STATUS__PAUSE, .name = "paused"}, + {.state = TASK_STATUS__CK, .name = "checkpoint"}, + {.state = TASK_STATUS__STREAM_SCAN_HISTORY, .name = "stream-scan-history"}, +}; + +SStreamEventInfo StreamTaskEventList[12] = { + {.event = 0, .name = ""}, // dummy event, place holder + {.event = TASK_EVENT_INIT, .name = "initialize"}, + {.event = TASK_EVENT_INIT_SCANHIST, .name = "scan-history-init"}, + {.event = TASK_EVENT_INIT_STREAM_SCANHIST, .name = "stream-scan-history-init"}, + {.event = TASK_EVENT_SCANHIST_DONE, .name = "scan-history-completed"}, + {.event = TASK_EVENT_STOP, .name = "stopping"}, + {.event = TASK_EVENT_GEN_CHECKPOINT, .name = "checkpoint"}, + {.event = TASK_EVENT_CHECKPOINT_DONE, .name = "checkpoint-done"}, + {.event = TASK_EVENT_PAUSE, .name = "pausing"}, + {.event = TASK_EVENT_RESUME, .name = "resuming"}, + {.event = TASK_EVENT_HALT, .name = "halting"}, + {.event = TASK_EVENT_DROPPING, .name = "dropping"}, +}; + +static TdThreadOnce streamTaskStateMachineInit = PTHREAD_ONCE_INIT; +static SArray* streamTaskSMTrans = NULL; + +static int32_t streamTaskInitStatus(SStreamTask* pTask); +static int32_t streamTaskKeepCurrentVerInWal(SStreamTask* pTask); +static int32_t initStateTransferTable(); +static void doInitStateTransferTable(void); + +static STaskStateTrans createStateTransform(ETaskStatus current, ETaskStatus next, EStreamTaskEvent event, + __state_trans_fn fn, __state_trans_succ_fn succFn, + SAttachedEventInfo* pEventInfo, bool autoInvoke); + +static int32_t dummyFn(SStreamTask* UNUSED_PARAM(p)) { return TSDB_CODE_SUCCESS; } + +static int32_t attachEvent(SStreamTask* pTask, SAttachedEventInfo* pEvtInfo) { + char* p = NULL; + streamTaskGetStatus(pTask, &p); + + stDebug("s-task:%s status:%s attach event:%s required status:%s, since not allowed to handle it", pTask->id.idStr, p, + StreamTaskEventList[pEvtInfo->event].name, StreamTaskStatusList[pEvtInfo->status].name); + taosArrayPush(pTask->status.pSM->pWaitingEventList, pEvtInfo); + return 0; +} + +int32_t streamTaskInitStatus(SStreamTask* pTask) { + pTask->execInfo.init = taosGetTimestampMs(); + + stDebug("s-task:%s start init, and check downstream tasks, set the init ts:%" PRId64, pTask->id.idStr, + pTask->execInfo.init); + streamTaskCheckDownstream(pTask); + return 0; +} + +int32_t streamTaskSetReadyForWal(SStreamTask* pTask) { + if (pTask->info.taskLevel == TASK_LEVEL__SOURCE) { + stDebug("s-task:%s ready for extract data from wal", pTask->id.idStr); + } + return TSDB_CODE_SUCCESS; +} + +static int32_t streamTaskDoCheckpoint(SStreamTask* pTask) { + stDebug("s-task:%s start to do checkpoint", pTask->id.idStr); + return 0; +} + +int32_t streamTaskKeepCurrentVerInWal(SStreamTask* pTask) { + ASSERT(HAS_RELATED_FILLHISTORY_TASK(pTask)); + + if (pTask->info.taskLevel == TASK_LEVEL__SOURCE) { + pTask->hTaskInfo.haltVer = walReaderGetCurrentVer(pTask->exec.pWalReader); + if (pTask->hTaskInfo.haltVer == -1) { + pTask->hTaskInfo.haltVer = pTask->dataRange.range.maxVer + 1; + } + } + + return TSDB_CODE_SUCCESS; +} + +// todo optimize the perf of find the trans objs by using hash table +static STaskStateTrans* streamTaskFindTransform(ETaskStatus state, const EStreamTaskEvent event) { + int32_t numOfTrans = taosArrayGetSize(streamTaskSMTrans); + for (int32_t i = 0; i < numOfTrans; ++i) { + STaskStateTrans* pTrans = taosArrayGet(streamTaskSMTrans, i); + if (pTrans->state.state == state && pTrans->event == event) { + return pTrans; + } + } + + if (event == TASK_EVENT_CHECKPOINT_DONE && state == TASK_STATUS__STOP) { + + } else if (event == TASK_EVENT_GEN_CHECKPOINT && state == TASK_STATUS__UNINIT) { + // the task is set to uninit due to nodeEpset update, during processing checkpoint-trigger block. + } else { + ASSERT(0); + } + + return NULL; +} + +void streamTaskRestoreStatus(SStreamTask* pTask) { + SStreamTaskSM* pSM = pTask->status.pSM; + taosThreadMutexLock(&pTask->lock); + ASSERT(pSM->pActiveTrans == NULL); + + ASSERT(pSM->current.state == TASK_STATUS__PAUSE || pSM->current.state == TASK_STATUS__HALT); + + SStreamTaskState state = pSM->current; + pSM->current = pSM->prev.state; + + pSM->prev.state = state; + pSM->prev.evt = 0; + + pSM->startTs = taosGetTimestampMs(); + stDebug("s-task:%s restore status, %s -> %s", pTask->id.idStr, pSM->prev.state.name, pSM->current.name); + + taosThreadMutexUnlock(&pTask->lock); +} + +SStreamTaskSM* streamCreateStateMachine(SStreamTask* pTask) { + initStateTransferTable(); + const char* id = pTask->id.idStr; + + SStreamTaskSM* pSM = taosMemoryCalloc(1, sizeof(SStreamTaskSM)); + if (pSM == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + stError("s-task:%s failed to create task stateMachine, size:%d, code:%s", id, (int32_t)sizeof(SStreamTaskSM), + tstrerror(terrno)); + return NULL; + } + + pSM->pTask = pTask; + pSM->pWaitingEventList = taosArrayInit(4, sizeof(SAttachedEventInfo)); + if (pSM->pWaitingEventList == NULL) { + taosMemoryFree(pSM); + + terrno = TSDB_CODE_OUT_OF_MEMORY; + stError("s-task:%s failed to create task stateMachine, size:%d, code:%s", id, (int32_t)sizeof(SStreamTaskSM), + tstrerror(terrno)); + return NULL; + } + + // set the initial state for the state-machine of stream task + pSM->current = StreamTaskStatusList[TASK_STATUS__UNINIT]; + pSM->startTs = taosGetTimestampMs(); + return pSM; +} + +void* streamDestroyStateMachine(SStreamTaskSM* pSM) { + if (pSM == NULL) { + return NULL; + } + + taosArrayDestroy(pSM->pWaitingEventList); + taosMemoryFree(pSM); + return NULL; +} + +static int32_t doHandleEvent(SStreamTaskSM* pSM, EStreamTaskEvent event, STaskStateTrans* pTrans) { + SStreamTask* pTask = pSM->pTask; + const char* id = pTask->id.idStr; + + if (pTrans->attachEvent.event != 0) { + attachEvent(pTask, &pTrans->attachEvent); + taosThreadMutexUnlock(&pTask->lock); + + while (1) { + // wait for the task to be here + taosThreadMutexLock(&pTask->lock); + ETaskStatus s = streamTaskGetStatus(pTask, NULL); + taosThreadMutexUnlock(&pTask->lock); + + if ((s == pTrans->next.state) && (pSM->prev.evt == pTrans->event)) { + stDebug("s-task:%s attached event:%s handled", id, StreamTaskEventList[pTrans->event].name); + return TSDB_CODE_SUCCESS; + } else if (s != TASK_STATUS__DROPPING && s != TASK_STATUS__STOP) { // this event has been handled already + stDebug("s-task:%s not handle event:%s yet, wait for 100ms and recheck", id, StreamTaskEventList[event].name); + taosMsleep(100); + } else { + stDebug("s-task:%s is dropped or stopped already, not wait.", id); + return TSDB_CODE_INVALID_PARA; + } + } + + } else { // override current active trans + pSM->pActiveTrans = pTrans; + pSM->startTs = taosGetTimestampMs(); + taosThreadMutexUnlock(&pTask->lock); + + int32_t code = pTrans->pAction(pTask); + // todo handle error code; + + if (pTrans->autoInvokeEndFn) { + streamTaskOnHandleEventSuccess(pSM, event); + } + } + + return TSDB_CODE_SUCCESS; +} + +int32_t streamTaskHandleEvent(SStreamTaskSM* pSM, EStreamTaskEvent event) { + SStreamTask* pTask = pSM->pTask; + STaskStateTrans* pTrans = NULL; + + while (1) { + taosThreadMutexLock(&pTask->lock); + if (pSM->pActiveTrans != NULL && pSM->pActiveTrans->autoInvokeEndFn) { + taosThreadMutexUnlock(&pTask->lock); + taosMsleep(100); + stDebug("s-task:%s status:%s handling event:%s by some other thread, wait for 100ms and check if completed", + pTask->id.idStr, pSM->current.name, StreamTaskEventList[pSM->pActiveTrans->event].name); + } else { + pTrans = streamTaskFindTransform(pSM->current.state, event); + if (pTrans == NULL) { + stDebug("s-task:%s failed to handle event:%s", pTask->id.idStr, StreamTaskEventList[event].name); + taosThreadMutexUnlock(&pTask->lock); + return TSDB_CODE_INVALID_PARA; // todo: set new error code// failed to handle the event. + } + + if (pSM->pActiveTrans != NULL) { + // currently in some state transfer procedure, not auto invoke transfer, abort it + stDebug("s-task:%s event:%s handle procedure quit, status %s -> %s failed, handle event %s now", + pTask->id.idStr, StreamTaskEventList[pSM->pActiveTrans->event].name, pSM->current.name, + pSM->pActiveTrans->next.name, StreamTaskEventList[event].name); + } + + doHandleEvent(pSM, event, pTrans); + break; + } + } + + return TSDB_CODE_SUCCESS; +} + +static void keepPrevInfo(SStreamTaskSM* pSM) { + STaskStateTrans* pTrans = pSM->pActiveTrans; + + pSM->prev.state = pSM->current; + pSM->prev.evt = pTrans->event; +} + +int32_t streamTaskOnHandleEventSuccess(SStreamTaskSM* pSM, EStreamTaskEvent event) { + SStreamTask* pTask = pSM->pTask; + + // do update the task status + taosThreadMutexLock(&pTask->lock); + STaskStateTrans* pTrans = pSM->pActiveTrans; + + if (pTrans == NULL) { + ETaskStatus s = pSM->current.state; + ASSERT(s == TASK_STATUS__DROPPING || s == TASK_STATUS__PAUSE || s == TASK_STATUS__STOP); + // the pSM->prev.evt may be 0, so print string is not appropriate. + stDebug("s-task:%s event:%s handled failed, current status:%s, trigger event:%s", pTask->id.idStr, + StreamTaskEventList[event].name, pSM->current.name, StreamTaskEventList[pSM->prev.evt].name); + + taosThreadMutexUnlock(&pTask->lock); + return TSDB_CODE_INVALID_PARA; + } + + if (pTrans->event != event) { + stWarn("s-task:%s handle event:%s failed, current status:%s, active trans evt:%s", pTask->id.idStr, + StreamTaskEventList[event].name, pSM->current.name, StreamTaskEventList[pTrans->event].name); + taosThreadMutexUnlock(&pTask->lock); + return TSDB_CODE_INVALID_PARA; + } + + keepPrevInfo(pSM); + + pSM->current = pTrans->next; + pSM->pActiveTrans = NULL; + + // on success callback, add into lock if necessary, or maybe we should add an option for this? + pTrans->pSuccAction(pTask); + + if (taosArrayGetSize(pSM->pWaitingEventList) > 0) { + int64_t el = (taosGetTimestampMs() - pSM->startTs); + stDebug("s-task:%s handle event:%s completed, elapsed time:%" PRId64 "ms state:%s -> %s", pTask->id.idStr, + StreamTaskEventList[pTrans->event].name, el, pSM->prev.state.name, pSM->current.name); + + SAttachedEventInfo* pEvtInfo = taosArrayPop(pSM->pWaitingEventList); + + // OK, let's handle the attached event, since the task has reached the required status now + if (pSM->current.state == pEvtInfo->status) { + stDebug("s-task:%s handle the attached event:%s, state:%s", pTask->id.idStr, + StreamTaskEventList[pEvtInfo->event].name, pSM->current.name); + + STaskStateTrans* pNextTrans = streamTaskFindTransform(pSM->current.state, pEvtInfo->event); + ASSERT(pSM->pActiveTrans == NULL && pNextTrans != NULL); + + pSM->pActiveTrans = pNextTrans; + pSM->startTs = taosGetTimestampMs(); + taosThreadMutexUnlock(&pTask->lock); + + int32_t code = pNextTrans->pAction(pSM->pTask); + if (pNextTrans->autoInvokeEndFn) { + return streamTaskOnHandleEventSuccess(pSM, pNextTrans->event); + } else { + return code; + } + } + } else { + taosThreadMutexUnlock(&pTask->lock); + + int64_t el = (taosGetTimestampMs() - pSM->startTs); + stDebug("s-task:%s handle event:%s completed, elapsed time:%" PRId64 "ms state:%s -> %s", pTask->id.idStr, + StreamTaskEventList[pTrans->event].name, el, pSM->prev.state.name, pSM->current.name); + } + + return TSDB_CODE_SUCCESS; +} + +ETaskStatus streamTaskGetStatus(const SStreamTask* pTask, char** pStr) { + SStreamTaskState s = pTask->status.pSM->current; // copy one obj in case of multi-thread environment + if (pStr != NULL) { + *pStr = s.name; + } + return s.state; +} + +const char* streamTaskGetStatusStr(ETaskStatus status) { + return StreamTaskStatusList[status].name; +} + +void streamTaskResetStatus(SStreamTask* pTask) { + SStreamTaskSM* pSM = pTask->status.pSM; + + taosThreadMutexLock(&pTask->lock); + stDebug("s-task:%s level:%d fill-history:%d vgId:%d set uninit, prev status:%s", pTask->id.idStr, + pTask->info.taskLevel, pTask->info.fillHistory, pTask->pMeta->vgId, pSM->current.name); + + pSM->current = StreamTaskStatusList[TASK_STATUS__UNINIT]; + pSM->pActiveTrans = NULL; + taosArrayClear(pSM->pWaitingEventList); + taosThreadMutexUnlock(&pTask->lock); + + // clear the downstream ready status + pTask->status.downstreamReady = 0; +} + +void streamTaskSetStatusReady(SStreamTask* pTask) { + SStreamTaskSM* pSM = pTask->status.pSM; + if (pSM->current.state == TASK_STATUS__DROPPING) { + stError("s-task:%s task in dropping state, cannot be set ready", pTask->id.idStr); + return; + } + + taosThreadMutexLock(&pTask->lock); + + pSM->prev.state = pSM->current; + pSM->prev.evt = 0; + + pSM->current = StreamTaskStatusList[TASK_STATUS__READY]; + pSM->startTs = taosGetTimestampMs(); + pSM->pActiveTrans = NULL; + taosArrayClear(pSM->pWaitingEventList); + + taosThreadMutexUnlock(&pTask->lock); +} + +STaskStateTrans createStateTransform(ETaskStatus current, ETaskStatus next, EStreamTaskEvent event, __state_trans_fn fn, + __state_trans_succ_fn succFn, SAttachedEventInfo* pEventInfo, bool autoInvoke) { + STaskStateTrans trans = {0}; + trans.state = StreamTaskStatusList[current]; + trans.next = StreamTaskStatusList[next]; + trans.event = event; + + if (pEventInfo != NULL) { + trans.attachEvent = *pEventInfo; + } else { + trans.attachEvent.event = 0; + trans.attachEvent.status = 0; + } + + trans.pAction = (fn != NULL) ? fn : dummyFn; + trans.pSuccAction = (succFn != NULL) ? succFn : dummyFn; + trans.autoInvokeEndFn = autoInvoke; + return trans; +} + +int32_t initStateTransferTable() { + taosThreadOnce(&streamTaskStateMachineInit, doInitStateTransferTable); + return TSDB_CODE_SUCCESS; +} + +void doInitStateTransferTable(void) { + streamTaskSMTrans = taosArrayInit(8, sizeof(STaskStateTrans)); + + // initialization event handle + STaskStateTrans trans = createStateTransform(TASK_STATUS__UNINIT, TASK_STATUS__READY, TASK_EVENT_INIT, + streamTaskInitStatus, onNormalTaskReady, false, false); + taosArrayPush(streamTaskSMTrans, &trans); + + trans = createStateTransform(TASK_STATUS__UNINIT, TASK_STATUS__SCAN_HISTORY, TASK_EVENT_INIT_SCANHIST, + streamTaskInitStatus, onScanhistoryTaskReady, false, false); + taosArrayPush(streamTaskSMTrans, &trans); + + trans = createStateTransform(TASK_STATUS__UNINIT, TASK_STATUS__STREAM_SCAN_HISTORY, TASK_EVENT_INIT_STREAM_SCANHIST, + streamTaskInitStatus, onScanhistoryTaskReady, false, false); + taosArrayPush(streamTaskSMTrans, &trans); + + // scan-history related event + trans = createStateTransform(TASK_STATUS__SCAN_HISTORY, TASK_STATUS__READY, TASK_EVENT_SCANHIST_DONE, NULL, NULL, + NULL, true); + taosArrayPush(streamTaskSMTrans, &trans); + + trans = createStateTransform(TASK_STATUS__STREAM_SCAN_HISTORY, TASK_STATUS__READY, TASK_EVENT_SCANHIST_DONE, NULL, + NULL, NULL, true); + taosArrayPush(streamTaskSMTrans, &trans); + + // halt stream task, from other task status + trans = createStateTransform(TASK_STATUS__READY, TASK_STATUS__HALT, TASK_EVENT_HALT, NULL, + streamTaskKeepCurrentVerInWal, NULL, true); + taosArrayPush(streamTaskSMTrans, &trans); + + SAttachedEventInfo info = {.status = TASK_STATUS__READY, .event = TASK_EVENT_HALT}; + trans = createStateTransform(TASK_STATUS__STREAM_SCAN_HISTORY, TASK_STATUS__HALT, TASK_EVENT_HALT, NULL, + streamTaskKeepCurrentVerInWal, &info, true); + taosArrayPush(streamTaskSMTrans, &trans); + + trans = createStateTransform(TASK_STATUS__CK, TASK_STATUS__HALT, TASK_EVENT_HALT, NULL, streamTaskKeepCurrentVerInWal, + &info, true); + taosArrayPush(streamTaskSMTrans, &trans); + + trans = createStateTransform(TASK_STATUS__PAUSE, TASK_STATUS__HALT, TASK_EVENT_HALT, NULL, + streamTaskKeepCurrentVerInWal, NULL, true); + taosArrayPush(streamTaskSMTrans, &trans); + + // checkpoint related event + trans = createStateTransform(TASK_STATUS__READY, TASK_STATUS__CK, TASK_EVENT_GEN_CHECKPOINT, NULL, + streamTaskDoCheckpoint, NULL, true); + taosArrayPush(streamTaskSMTrans, &trans); + + trans = + createStateTransform(TASK_STATUS__CK, TASK_STATUS__READY, TASK_EVENT_CHECKPOINT_DONE, NULL, NULL, NULL, true); + taosArrayPush(streamTaskSMTrans, &trans); + + // pause & resume related event handle + trans = createStateTransform(TASK_STATUS__READY, TASK_STATUS__PAUSE, TASK_EVENT_PAUSE, NULL, NULL, NULL, true); + taosArrayPush(streamTaskSMTrans, &trans); + trans = createStateTransform(TASK_STATUS__SCAN_HISTORY, TASK_STATUS__PAUSE, TASK_EVENT_PAUSE, NULL, NULL, NULL, true); + taosArrayPush(streamTaskSMTrans, &trans); + + info = (SAttachedEventInfo){.status = TASK_STATUS__READY, .event = TASK_EVENT_PAUSE}; + trans = createStateTransform(TASK_STATUS__STREAM_SCAN_HISTORY, TASK_STATUS__PAUSE, TASK_EVENT_PAUSE, NULL, NULL, &info, true); + taosArrayPush(streamTaskSMTrans, &trans); + trans = createStateTransform(TASK_STATUS__CK, TASK_STATUS__PAUSE, TASK_EVENT_PAUSE, NULL, NULL, &info, true); + taosArrayPush(streamTaskSMTrans, &trans); + trans = createStateTransform(TASK_STATUS__HALT, TASK_STATUS__PAUSE, TASK_EVENT_PAUSE, NULL, NULL, &info, true); + taosArrayPush(streamTaskSMTrans, &trans); + + trans = createStateTransform(TASK_STATUS__UNINIT, TASK_STATUS__PAUSE, TASK_EVENT_PAUSE, NULL, NULL, NULL, true); + taosArrayPush(streamTaskSMTrans, &trans); + trans = createStateTransform(TASK_STATUS__PAUSE, TASK_STATUS__PAUSE, TASK_EVENT_PAUSE, NULL, NULL, NULL, true); + taosArrayPush(streamTaskSMTrans, &trans); + trans = createStateTransform(TASK_STATUS__STOP, TASK_STATUS__STOP, TASK_EVENT_PAUSE, NULL, NULL, NULL, true); + taosArrayPush(streamTaskSMTrans, &trans); + trans = createStateTransform(TASK_STATUS__DROPPING, TASK_STATUS__DROPPING, TASK_EVENT_PAUSE, NULL, NULL, NULL, true); + taosArrayPush(streamTaskSMTrans, &trans); + + // resume is completed by restore status of state-machine + + // stop related event + trans = createStateTransform(TASK_STATUS__READY, TASK_STATUS__STOP, TASK_EVENT_STOP, NULL, NULL, NULL, true); + taosArrayPush(streamTaskSMTrans, &trans); + trans = createStateTransform(TASK_STATUS__DROPPING, TASK_STATUS__STOP, TASK_EVENT_STOP, NULL, NULL, NULL, true); + taosArrayPush(streamTaskSMTrans, &trans); + trans = createStateTransform(TASK_STATUS__UNINIT, TASK_STATUS__STOP, TASK_EVENT_STOP, NULL, NULL, NULL, true); + taosArrayPush(streamTaskSMTrans, &trans); + trans = createStateTransform(TASK_STATUS__STOP, TASK_STATUS__STOP, TASK_EVENT_STOP, NULL, NULL, NULL, true); + taosArrayPush(streamTaskSMTrans, &trans); + trans = createStateTransform(TASK_STATUS__SCAN_HISTORY, TASK_STATUS__STOP, TASK_EVENT_STOP, NULL, NULL, NULL, true); + taosArrayPush(streamTaskSMTrans, &trans); + trans = createStateTransform(TASK_STATUS__HALT, TASK_STATUS__STOP, TASK_EVENT_STOP, NULL, NULL, NULL, true); + taosArrayPush(streamTaskSMTrans, &trans); + trans = createStateTransform(TASK_STATUS__PAUSE, TASK_STATUS__STOP, TASK_EVENT_STOP, NULL, NULL, NULL, true); + taosArrayPush(streamTaskSMTrans, &trans); + trans = createStateTransform(TASK_STATUS__CK, TASK_STATUS__STOP, TASK_EVENT_STOP, NULL, NULL, NULL, true); + taosArrayPush(streamTaskSMTrans, &trans); + trans = createStateTransform(TASK_STATUS__STREAM_SCAN_HISTORY, TASK_STATUS__STOP, TASK_EVENT_STOP, NULL, NULL, NULL, true); + taosArrayPush(streamTaskSMTrans, &trans); + + // dropping related event + trans = createStateTransform(TASK_STATUS__READY, TASK_STATUS__DROPPING, TASK_EVENT_DROPPING, NULL, NULL, NULL, true); + taosArrayPush(streamTaskSMTrans, &trans); + trans = createStateTransform(TASK_STATUS__DROPPING, TASK_STATUS__DROPPING, TASK_EVENT_DROPPING, NULL, NULL, NULL, true); + taosArrayPush(streamTaskSMTrans, &trans); + trans = createStateTransform(TASK_STATUS__UNINIT, TASK_STATUS__DROPPING, TASK_EVENT_DROPPING, NULL, NULL, NULL, true); + taosArrayPush(streamTaskSMTrans, &trans); + trans = createStateTransform(TASK_STATUS__STOP, TASK_STATUS__DROPPING, TASK_EVENT_DROPPING, NULL, NULL, NULL, true); + taosArrayPush(streamTaskSMTrans, &trans); + trans = createStateTransform(TASK_STATUS__SCAN_HISTORY, TASK_STATUS__DROPPING, TASK_EVENT_DROPPING, NULL, NULL, NULL, true); + taosArrayPush(streamTaskSMTrans, &trans); + trans = createStateTransform(TASK_STATUS__HALT, TASK_STATUS__DROPPING, TASK_EVENT_DROPPING, NULL, NULL, NULL, true); + taosArrayPush(streamTaskSMTrans, &trans); + trans = createStateTransform(TASK_STATUS__PAUSE, TASK_STATUS__DROPPING, TASK_EVENT_DROPPING, NULL, NULL, NULL, true); + taosArrayPush(streamTaskSMTrans, &trans); + trans = createStateTransform(TASK_STATUS__CK, TASK_STATUS__DROPPING, TASK_EVENT_DROPPING, NULL, NULL, NULL, true); + taosArrayPush(streamTaskSMTrans, &trans); + trans = createStateTransform(TASK_STATUS__STREAM_SCAN_HISTORY, TASK_STATUS__DROPPING, TASK_EVENT_DROPPING, NULL, NULL, NULL, true); + taosArrayPush(streamTaskSMTrans, &trans); +} \ No newline at end of file diff --git a/source/util/src/tarray.c b/source/util/src/tarray.c index a7c28df22b..26d149b5b5 100644 --- a/source/util/src/tarray.c +++ b/source/util/src/tarray.c @@ -191,7 +191,7 @@ void* taosArrayGet(const SArray* pArray, size_t index) { } if (index >= pArray->size) { - uError("index is out of range, current:%" PRIzu " max:%d", index, pArray->capacity); + uError("index is out of range, current:%" PRIzu " max:%"PRIzu, index, pArray->size); return NULL; } diff --git a/source/util/src/tconfig.c b/source/util/src/tconfig.c index 34c3222bff..08bb8ecabf 100644 --- a/source/util/src/tconfig.c +++ b/source/util/src/tconfig.c @@ -416,16 +416,6 @@ int32_t cfgAddFloat(SConfig *pCfg, const char *name, float defaultVal, float min return cfgAddItem(pCfg, &item, name); } -int32_t cfgAddDouble(SConfig *pCfg, const char *name, double defaultVal, double minval, double maxval, int8_t scope) { - if (defaultVal < minval || defaultVal > maxval) { - terrno = TSDB_CODE_OUT_OF_RANGE; - return -1; - } - - SConfigItem item = {.dtype = CFG_DTYPE_DOUBLE, .dval = defaultVal, .fmin = minval, .fmax = maxval, .scope = scope}; - return cfgAddItem(pCfg, &item, name); -} - int32_t cfgAddString(SConfig *pCfg, const char *name, const char *defaultVal, int8_t scope) { SConfigItem item = {.dtype = CFG_DTYPE_STRING, .scope = scope}; item.str = taosStrdup(defaultVal); @@ -611,8 +601,7 @@ void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump) { switch (pItem->dtype) { case CFG_DTYPE_BOOL: if (dump) { - printf("%s %s %u", src, name, pItem->bval); - printf("\n"); + printf("%s %s %u\n", src, name, pItem->bval); } else { uInfo("%s %s %u", src, name, pItem->bval); } @@ -620,25 +609,22 @@ void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump) { break; case CFG_DTYPE_INT32: if (dump) { - printf("%s %s %d", src, name, pItem->i32); - printf("\n"); + printf("%s %s %d\n", src, name, pItem->i32); } else { uInfo("%s %s %d", src, name, pItem->i32); } break; case CFG_DTYPE_INT64: if (dump) { - printf("%s %s %" PRId64, src, name, pItem->i64); - printf("\n"); + printf("%s %s %" PRId64"\n", src, name, pItem->i64); } else { uInfo("%s %s %" PRId64, src, name, pItem->i64); } break; - case CFG_DTYPE_FLOAT: case CFG_DTYPE_DOUBLE: + case CFG_DTYPE_FLOAT: if (dump) { - printf("%s %s %.2f", src, name, pItem->fval); - printf("\n"); + printf("%s %s %.2f\n", src, name, pItem->fval); } else { uInfo("%s %s %.2f", src, name, pItem->fval); } @@ -650,8 +636,7 @@ void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump) { case CFG_DTYPE_TIMEZONE: case CFG_DTYPE_NONE: if (dump) { - printf("%s %s %s", src, name, pItem->str); - printf("\n"); + printf("%s %s %s\n", src, name, pItem->str); } else { uInfo("%s %s %s", src, name, pItem->str); } @@ -660,8 +645,7 @@ void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump) { } if (dump) { - printf("================================================================="); - printf("\n"); + printf("=================================================================\n"); } else { uInfo("================================================================="); } diff --git a/source/util/src/terror.c b/source/util/src/terror.c index 12a37a041a..1714126a32 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -259,6 +259,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_DNODE_ID, "Invalid dnode id") TAOS_DEFINE_ERROR(TSDB_CODE_MND_VGROUP_UN_CHANGED, "Vgroup distribution has not changed") TAOS_DEFINE_ERROR(TSDB_CODE_MND_HAS_OFFLINE_DNODE, "Offline dnode exists") TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_REPLICA, "Invalid vgroup replica") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_NO_ENOUGH_VNODES, "Vnodes exhausted") // mnode-stable-part2 TAOS_DEFINE_ERROR(TSDB_CODE_MND_NAME_CONFLICT_WITH_TOPIC, "STable confilct with topic") @@ -316,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") @@ -553,7 +559,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_PAR_TOO_MANY_COLUMNS, "Too many columns") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_FIRST_COLUMN, "First column must be timestamp") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_VAR_COLUMN_LEN, "Invalid varbinary/binary/nchar column/tag length") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_TAGS_NUM, "Invalid number of tag columns") -TAOS_DEFINE_ERROR(TSDB_CODE_PAR_PERMISSION_DENIED, "Permission denied") +TAOS_DEFINE_ERROR(TSDB_CODE_PAR_PERMISSION_DENIED, "Permission denied or target object not exist") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_STREAM_QUERY, "Invalid stream query") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_INTERNAL_PK, "Invalid _c0 or _rowts expression") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_TIMELINE_FUNC, "Invalid timeline function") @@ -589,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/source/util/src/tqueue.c b/source/util/src/tqueue.c index 81350dddd2..1dfdd637b6 100644 --- a/source/util/src/tqueue.c +++ b/source/util/src/tqueue.c @@ -242,6 +242,11 @@ int32_t taosReadAllQitems(STaosQueue *queue, STaosQall *qall) { qall->current = queue->head; qall->start = queue->head; qall->numOfItems = queue->numOfItems; + qall->memOfItems = queue->memOfItems; + + qall->unAccessedNumOfItems = queue->numOfItems; + qall->unAccessMemOfItems = queue->memOfItems; + numOfItems = qall->numOfItems; queue->head = NULL; @@ -274,6 +279,10 @@ int32_t taosGetQitem(STaosQall *qall, void **ppItem) { if (pNode) { *ppItem = pNode->item; num = 1; + + qall->unAccessedNumOfItems -= 1; + qall->unAccessMemOfItems -= pNode->dataSize; + uTrace("item:%p is fetched", *ppItem); } else { *ppItem = NULL; @@ -449,6 +458,8 @@ int32_t taosReadAllQitemsFromQset(STaosQset *qset, STaosQall *qall, SQueueInfo * qall->current = queue->head; qall->start = queue->head; qall->numOfItems = queue->numOfItems; + qall->memOfItems = queue->memOfItems; + code = qall->numOfItems; qinfo->ahandle = queue->ahandle; qinfo->fp = queue->itemsFp; @@ -476,6 +487,11 @@ int32_t taosReadAllQitemsFromQset(STaosQset *qset, STaosQall *qall, SQueueInfo * } int32_t taosQallItemSize(STaosQall *qall) { return qall->numOfItems; } +int64_t taosQallMemSize(STaosQall *qall) { return qall->memOfItems; } + +int64_t taosQallUnAccessedItemSize(STaosQall *qall) {return qall->unAccessedNumOfItems;} +int64_t taosQallUnAccessedMemSize(STaosQall *qall) {return qall->unAccessMemOfItems;} + void taosResetQitems(STaosQall *qall) { qall->current = qall->start; } int32_t taosGetQueueNumber(STaosQset *qset) { return qset->numOfQueues; } 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 d841acebfe..15cb1f034f 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -1048,6 +1048,7 @@ e ,,y,script,./test.sh -f tsim/query/tableCount.sim ,,y,script,./test.sh -f tsim/query/show_db_table_kind.sim ,,y,script,./test.sh -f tsim/query/bi_star_table.sim +,,y,script,./test.sh -f tsim/query/bi_tag_scan.sim ,,y,script,./test.sh -f tsim/query/tag_scan.sim ,,y,script,./test.sh -f tsim/query/nullColSma.sim ,,y,script,./test.sh -f tsim/query/bug3398.sim @@ -1284,6 +1285,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/pytest/util/dnodes.py b/tests/pytest/util/dnodes.py index d0ed1d874d..67c3d37960 100644 --- a/tests/pytest/util/dnodes.py +++ b/tests/pytest/util/dnodes.py @@ -130,14 +130,16 @@ class TDDnode: "locale": "en_US.UTF-8", "charset": "UTF-8", "asyncLog": "0", - "mDebugFlag": "135", - "dDebugFlag": "135", - "vDebugFlag": "135", - "tqDebugFlag": "135", - "cDebugFlag": "135", - "jniDebugFlag": "135", - "qDebugFlag": "135", - "rpcDebugFlag": "135", + "mDebugFlag": "143", + "dDebugFlag": "143", + "vDebugFlag": "143", + "tqDebugFlag": "143", + "cDebugFlag": "143", + "stDebugFlag": "143", + "smaDebugFlag": "143", + "jniDebugFlag": "143", + "qDebugFlag": "143", + "rpcDebugFlag": "143", "tmrDebugFlag": "131", "uDebugFlag": "135", "sDebugFlag": "135", diff --git a/tests/script/api/makefile b/tests/script/api/makefile index ac5c5c9138..9630f79a7c 100644 --- a/tests/script/api/makefile +++ b/tests/script/api/makefile @@ -17,6 +17,7 @@ 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) ./tmqViewTest.c -o $(ROOT)tmqViewTest $(LFLAGS) clean: rm $(ROOT)batchprepare @@ -25,3 +26,4 @@ clean: rm $(ROOT)insertSameTs rm $(ROOT)passwdTest rm $(ROOT)whiteListTest + 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/query/bi_tag_scan.sim b/tests/script/tsim/query/bi_tag_scan.sim new file mode 100644 index 0000000000..5b8af68b5a --- /dev/null +++ b/tests/script/tsim/query/bi_tag_scan.sim @@ -0,0 +1,31 @@ +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 db1; +sql create database db1 vgroups 3; +sql create database db1; +sql use db1; +sql create stable sta (ts timestamp, f1 int, f2 binary(200)) tags(t1 int, t2 int, t3 int); +sql create stable stb (ts timestamp, f1 int, f2 binary(200)) tags(t1 int, t2 int, t3 int); +sql create table tba1 using sta tags(1, 1, 1); +sql create table tba2 using sta tags(2, 2, 2); +sql insert into tba1 values(now, 1, "1")(now+3s, 3, "3")(now+5s, 5, "5"); +sql insert into tba2 values(now + 1s, 2, "2")(now+2s, 2, "2")(now+4s, 4, "4"); +sql create table tbn1 (ts timestamp, f1 int); + +set_bi_mode 1 +sql select t1,t2,t3 from db1.sta order by t1; +print $rows $data00 $data10 +if $rows != 2 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 2 then + return -1 +endi + +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/sma/rsmaCreateInsertQuery.sim b/tests/script/tsim/sma/rsmaCreateInsertQuery.sim index b3144e4e0d..e5e07dfaec 100644 --- a/tests/script/tsim/sma/rsmaCreateInsertQuery.sim +++ b/tests/script/tsim/sma/rsmaCreateInsertQuery.sim @@ -5,7 +5,7 @@ sleep 50 sql connect print =============== create database with retentions -sql create database d0 retentions 5s:7d,10s:21d,15s:365d; +sql create database d0 retentions -:7d,10s:21d,15s:365d; sql use d0 print =============== create super table and register rsma diff --git a/tests/script/tsim/sma/rsmaPersistenceRecovery.sim b/tests/script/tsim/sma/rsmaPersistenceRecovery.sim index 0b3938d773..6f78829db7 100644 --- a/tests/script/tsim/sma/rsmaPersistenceRecovery.sim +++ b/tests/script/tsim/sma/rsmaPersistenceRecovery.sim @@ -8,7 +8,7 @@ sql connect return 1 print =============== create database with retentions -sql create database d0 retentions 5s:7d,5m:21d,15m:365d; +sql create database d0 retentions -:7d,5m:21d,15m:365d; sql use d0 print =============== create super table and register rsma diff --git a/tests/script/tsim/stream/distributeIntervalRetrive0.sim b/tests/script/tsim/stream/distributeIntervalRetrive0.sim index 194b5b1ae5..39c3353429 100644 --- a/tests/script/tsim/stream/distributeIntervalRetrive0.sim +++ b/tests/script/tsim/stream/distributeIntervalRetrive0.sim @@ -268,7 +268,6 @@ sql create table t2 using st tags(2,2,2); sql create stream streams1 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 delete_mark 20s into streamt1 as select _wstart as c0, count(*) c1, count(a) c2 from st interval(10s) ; sleep 1000 - sql insert into t1 values(1648791211000,1,2,3); sql insert into t1 values(1262275200000,2,2,3); diff --git a/tests/script/tsim/stream/pauseAndResume.sim b/tests/script/tsim/stream/pauseAndResume.sim index 402e0086f7..673bc77c0f 100644 --- a/tests/script/tsim/stream/pauseAndResume.sim +++ b/tests/script/tsim/stream/pauseAndResume.sim @@ -16,7 +16,9 @@ sql create table ts2 using st tags(2,2,2); sql create table ts3 using st tags(3,2,2); sql create table ts4 using st tags(4,2,2); sql create stream streams1 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 watermark 1d into streamt1 as select _wstart, count(*) c1, sum(a) c3 from st interval(10s); +sleep 1000 +sleep 1000 sql pause stream streams1; sql insert into ts1 values(1648791213001,1,12,3,1.0); @@ -246,6 +248,7 @@ sql create table ts4 using st tags(4,2,2); sql create stream streams3 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 watermark 1d into streamt3 as select _wstart, count(*) c1, sum(a) c3 from st interval(10s); sql create stream streams4 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 watermark 1d into streamt4 as select _wstart, count(*) c1, sum(a) c3 from st interval(10s); sql create stream streams5 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 watermark 1d into streamt5 as select _wstart, count(*) c1, sum(a) c3 from ts1 interval(10s); +sleep 1000 sql pause stream streams3; diff --git a/tests/script/tsim/sync/vnodesnapshot-rsma-test.sim b/tests/script/tsim/sync/vnodesnapshot-rsma-test.sim index 6f8c095162..3b3cd01521 100644 --- a/tests/script/tsim/sync/vnodesnapshot-rsma-test.sim +++ b/tests/script/tsim/sync/vnodesnapshot-rsma-test.sim @@ -47,7 +47,7 @@ endi $replica = 3 $vgroups = 1 -$retentions = 5s:7d,15s:21d,1m:365d +$retentions = -:7d,15s:21d,1m:365d print ============= create database sql create database db replica $replica vgroups $vgroups retentions $retentions 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/0-others/timeRangeWise.py b/tests/system-test/0-others/timeRangeWise.py index 5ef5aa4a75..7a258f5dd3 100644 --- a/tests/system-test/0-others/timeRangeWise.py +++ b/tests/system-test/0-others/timeRangeWise.py @@ -23,7 +23,8 @@ from util.cases import * from util.sql import * class TDTestCase: - + updatecfgDict = {'vdebugFlag': 143, 'qdebugflag':135, 'tqdebugflag':135, 'udebugflag':135, 'rpcdebugflag':135, + 'asynclog': 0, 'stdebugflag':135} # random string def random_string(self, count): letters = string.ascii_letters diff --git a/tests/system-test/1-insert/block_wise.py b/tests/system-test/1-insert/block_wise.py index 8222000cd6..1aff2e7708 100644 --- a/tests/system-test/1-insert/block_wise.py +++ b/tests/system-test/1-insert/block_wise.py @@ -417,7 +417,7 @@ class TDTestCase: self.all_test() tdLog.printNoPrefix("==========step2:create table in rollup database") - tdSql.execute("create database db3 retentions 1s:4m,2s:8m,3s:12m") + tdSql.execute("create database db3 retentions -:4m,2s:8m,3s:12m") tdSql.execute("use db3") tdSql.query(f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(first) watermark 5s max_delay 1m sma({INT_COL})") @@ -438,7 +438,7 @@ class TDTestCase: tdSql.execute("drop database if exists db_s20 ") tdLog.printNoPrefix("==========step4:insert and flush in rollup database") - tdSql.execute("create database db4 retentions 1s:4m,2s:8m,3s:12m") + tdSql.execute("create database db4 retentions -:4m,2s:8m,3s:12m") tdSql.execute("use db4") self.__create_tb(rollup="first") self.__insert_data(rollup="first") diff --git a/tests/system-test/1-insert/create_retentions.py b/tests/system-test/1-insert/create_retentions.py index 9435dcd081..a4b2cae68a 100644 --- a/tests/system-test/1-insert/create_retentions.py +++ b/tests/system-test/1-insert/create_retentions.py @@ -54,53 +54,63 @@ class TDTestCase: return [ # check grammar "create database db1 retentions", - "create database db1 retentions 1s:1d,2s:2d,3s:3d,4s:4d", + "create database db1 retentions 1s:1d", + "create database db1 retentions 1s:1d,2s:2d", + "create database db1 retentions 1s:1d,2s:2d,3s:3d", + "create database db1 retentions -:1d,2s:2d,3s:3d,4s:4d", + "create database db1 retentions -:-", + "create database db1 retentions --:1d", + "create database db1 retentions +:1d", + "create database db1 retentions :1d", + "create database db1 retentions -:1d,-:2d", + "create database db1 retentions -:1d,1s:-", + "create database db1 retentions -:1d,15s:2d,-:3d", + # check unit - "create database db1 retentions 1b:1d", - "create database db1 retentions 1u:1d", - "create database db1 retentions 1a:1d", - "create database db1 retentions 1n:1d", - "create database db1 retentions 1y:1d", - "create database db1 retentions 1s:86400s", - "create database db1 retentions 1s:86400000a", - "create database db1 retentions 1s:86400000000u", - "create database db1 retentions 1s:86400000000000b", - "create database db1 retentions 1s:1w", - "create database db1 retentions 1s:1n", - "create database db1 retentions 1s:1y", + "create database db1 retentions -:1d,1b:1d", + "create database db1 retentions -:1d,1u:1d", + "create database db1 retentions -:1d,1a:1d", + "create database db1 retentions -:1d,1n:1d", + "create database db1 retentions -:1d,1y:1d", + "create database db1 retentions -:1d,1s:86400s", + "create database db1 retentions -:1d,1s:86400000a", + "create database db1 retentions -:1d,1s:86400000000u", + "create database db1 retentions -:1d,1s:86400000000000b", + "create database db1 retentions -:1d,1s:1w", + "create database db1 retentions -:1d,1s:1n", + "create database db1 retentions -:1d,1s:1y", + # check value range - "create database db1 retentions -1s:1d", - "create database db1 retentions 0s:1d", - "create database db3 retentions 1s:-1d", - "create database db3 retentions 1s:0d", - "create database db3 retentions 1s:1439m", - "create database db3 retentions 1s:365001d", - "create database db3 retentions 1s:8760001h", - "create database db3 retentions 1s:525600001m", - "create database db3 retentions 1s:106581d precision 'ns'", - "create database db3 retentions 1s:2557921h precision 'ns'", - "create database db3 retentions 1s:153475201m precision 'ns'", + "create database db3 retentions -:-1d", + "create database db3 retentions -:0d", + "create database db3 retentions -:1439m", + "create database db3 retentions -:365001d", + "create database db3 retentions -:8760001h", + "create database db3 retentions -:525600001m", + "create database db3 retentions -:106581d precision 'ns'", + "create database db3 retentions -:2557921h precision 'ns'", + "create database db3 retentions -:153475201m precision 'ns'", # check relationships - "create database db5 retentions 1441m:1440m,2d:3d", - "create database db5 retentions 2m:1d,1s:2d", - "create database db5 retentions 1s:2880m,2s:2879m", - "create database db5 retentions 1s:1d,2s:2d,2s:3d", - "create database db5 retentions 1s:1d,3s:2d,2s:3d", - "create database db1 retentions 1s:1d,2s:3d,3s:2d", + "create database db5 retentions -:1440m,1441m:1440m,2d:3d", + "create database db5 retentions -:1d,2m:1d,1s:2d", + "create database db5 retentions -:1440m,1s:2880m,2s:2879m", + "create database db5 retentions -:1d,2s:2d,2s:3d", + "create database db5 retentions -:1d,3s:2d,2s:3d", + "create database db1 retentions -:1d,2s:3d,3s:2d", ] @property def create_databases_sql_current(self): return [ - f"create database {DB1} retentions 1s:1d", - f"create database {DB2} retentions 1s:1d,2m:2d,3h:3d", + f"create database {DB1} retentions -:1d", + f"create database {DB2} retentions -:1d,2m:2d,3h:3d", ] @property def alter_database_sql(self): return [ - "alter database db1 retentions 99h:99d", - "alter database db2 retentions 97h:97d,98h:98d,99h:99d,", + "alter database db1 retentions -:99d", + "alter database db2 retentions -:97d,98h:98d,99h:99d,", ] @property @@ -172,9 +182,17 @@ class TDTestCase: def test_create_databases(self): for err_sql in self.create_databases_sql_err: tdSql.error(err_sql) + index = 0 for cur_sql in self.create_databases_sql_current: tdSql.execute(cur_sql) - # tdSql.query("select * from information_schema.ins_databases") + if(index == 0): + tdSql.query(f"show create database {DB1}") + else: + tdSql.query(f"show create database {DB2}") + tdSql.checkEqual(len(tdSql.queryResult),1) + tdLog.info("%s" % (tdSql.queryResult[0][1])) + tdSql.checkEqual(tdSql.queryResult[0][1].find("RETENTIONS -:") > 0, True) + index += 1 for alter_sql in self.alter_database_sql: tdSql.error(alter_sql) @@ -281,7 +299,7 @@ class TDTestCase: tdLog.printNoPrefix("==========step2:create table in rollup database") tdLog.printNoPrefix("==========step2.1 : rolluo func is not last/first") - tdSql.prepare(dbname=DB3, **{"retentions": "1s:1d, 3s:3d, 5s:5d"}) + tdSql.prepare(dbname=DB3, **{"retentions": "-:1d, 3s:3d, 5s:5d"}) db3_ctb_num = 10 self.__create_tb(rsma=True, dbname=DB3, ctb_num=db3_ctb_num, stb=STBNAME) @@ -338,7 +356,7 @@ class TDTestCase: tdLog.printNoPrefix("==========step2.2 : rolluo func is last/first") - tdSql.prepare(dbname=DB4, **{"retentions": "1s:1d, 2m:3d, 3m:5d"}) + tdSql.prepare(dbname=DB4, **{"retentions": "-:1d, 2m:3d, 3m:5d"}) db4_ctb_num = 10 tdSql.execute(f"use {DB4}") diff --git a/tests/system-test/1-insert/time_range_wise.py b/tests/system-test/1-insert/time_range_wise.py index df1cc516c5..14b717d1da 100644 --- a/tests/system-test/1-insert/time_range_wise.py +++ b/tests/system-test/1-insert/time_range_wise.py @@ -584,7 +584,7 @@ class TDTestCase: self.all_test() tdLog.printNoPrefix("==========step2:create table in rollup database") - tdSql.execute("create database db3 retentions 1s:4m,2s:8m,3s:12m") + tdSql.execute("create database db3 retentions -:4m,2s:8m,3s:12m") tdSql.execute("use db3") tdSql.execute(f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(first) watermark 5s max_delay 1m sma({INT_COL}) ") self.all_test() @@ -603,7 +603,7 @@ class TDTestCase: # add for TS-2440 for i in range(self.rows): tdSql.execute("drop database if exists db3 ") - tdSql.execute("create database db3 retentions 1s:4m,2s:8m,3s:12m") + tdSql.execute("create database db3 retentions -:4m,2s:8m,3s:12m") def stop(self): tdSql.close() 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/tests/system-test/8-stream/max_delay_session.py b/tests/system-test/8-stream/max_delay_session.py index 1a734e0e61..46c4c5801d 100644 --- a/tests/system-test/8-stream/max_delay_session.py +++ b/tests/system-test/8-stream/max_delay_session.py @@ -35,6 +35,8 @@ class TDTestCase: self.tdCom.create_stream(stream_name=f'{self.ctb_name}{self.tdCom.stream_suffix}', des_table=self.ctb_stream_des_table, source_sql=f'select _wstart AS wstart, _wend AS wend, {self.tdCom.stb_source_select_str} from {self.ctb_name} session(ts, {self.tdCom.dataDict["session"]}s)', trigger_mode="max_delay", watermark=watermark_value, max_delay=max_delay_value, fill_history_value=fill_history_value) self.tdCom.create_stream(stream_name=f'{self.tb_name}{self.tdCom.stream_suffix}', des_table=self.tb_stream_des_table, source_sql=f'select _wstart AS wstart, _wend AS wend, {self.tdCom.tb_source_select_str} from {self.tb_name} session(ts, {self.tdCom.dataDict["session"]}s)', trigger_mode="max_delay", watermark=watermark_value, max_delay=max_delay_value, fill_history_value=fill_history_value) init_num = 0 + time.sleep(1) + for i in range(self.tdCom.range_count): if i == 0: window_close_ts = self.tdCom.cal_watermark_window_close_session_endts(self.tdCom.date_time, self.tdCom.dataDict['watermark'], self.tdCom.dataDict['session']) diff --git a/tests/system-test/8-stream/scalar_function.py b/tests/system-test/8-stream/scalar_function.py index 3bc44a7dc7..eda643f661 100644 --- a/tests/system-test/8-stream/scalar_function.py +++ b/tests/system-test/8-stream/scalar_function.py @@ -7,7 +7,7 @@ from util.common import * class TDTestCase: updatecfgDict = {'vdebugFlag': 143, 'qdebugflag':135, 'tqdebugflag':135, 'udebugflag':135, 'rpcdebugflag':135, - 'asynclog': 0} + 'asynclog': 0, 'stdebugflag':135} def init(self, conn, logSql, replicaVar=1): self.replicaVar = int(replicaVar) tdLog.debug("start to execute %s" % __file__) diff --git a/tests/system-test/test.py b/tests/system-test/test.py index 6813530a5c..81f98fea22 100644 --- a/tests/system-test/test.py +++ b/tests/system-test/test.py @@ -398,7 +398,7 @@ if __name__ == "__main__": tdDnodes.setValgrind(valgrind) tdDnodes.stopAll() for dnode in tdDnodes.dnodes: - tdDnodes.deploy(dnode.index,{}) + tdDnodes.deploy(dnode.index, updateCfgDict) for dnode in tdDnodes.dnodes: tdDnodes.starttaosd(dnode.index) tdCases.logSql(logSql) 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();