feat: the compact command adds 'start with end with' clause
This commit is contained in:
parent
9a983f2d9e
commit
df0d200f59
|
@ -1032,6 +1032,7 @@ void tFreeSUserAuthBatchRsp(SUserAuthBatchRsp* pRsp);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char db[TSDB_DB_FNAME_LEN];
|
char db[TSDB_DB_FNAME_LEN];
|
||||||
|
STimeWindow timeRange;
|
||||||
} SCompactDbReq;
|
} SCompactDbReq;
|
||||||
|
|
||||||
int32_t tSerializeSCompactDbReq(void* buf, int32_t bufLen, SCompactDbReq* pReq);
|
int32_t tSerializeSCompactDbReq(void* buf, int32_t bufLen, SCompactDbReq* pReq);
|
||||||
|
|
|
@ -110,168 +110,168 @@
|
||||||
#define TK_TABLE_SUFFIX 92
|
#define TK_TABLE_SUFFIX 92
|
||||||
#define TK_NK_COLON 93
|
#define TK_NK_COLON 93
|
||||||
#define TK_MAX_SPEED 94
|
#define TK_MAX_SPEED 94
|
||||||
#define TK_TABLE 95
|
#define TK_START 95
|
||||||
#define TK_NK_LP 96
|
#define TK_WITH 96
|
||||||
#define TK_NK_RP 97
|
#define TK_TIMESTAMP 97
|
||||||
#define TK_STABLE 98
|
#define TK_END 98
|
||||||
#define TK_ADD 99
|
#define TK_TABLE 99
|
||||||
#define TK_COLUMN 100
|
#define TK_NK_LP 100
|
||||||
#define TK_MODIFY 101
|
#define TK_NK_RP 101
|
||||||
#define TK_RENAME 102
|
#define TK_STABLE 102
|
||||||
#define TK_TAG 103
|
#define TK_ADD 103
|
||||||
#define TK_SET 104
|
#define TK_COLUMN 104
|
||||||
#define TK_NK_EQ 105
|
#define TK_MODIFY 105
|
||||||
#define TK_USING 106
|
#define TK_RENAME 106
|
||||||
#define TK_TAGS 107
|
#define TK_TAG 107
|
||||||
#define TK_COMMENT 108
|
#define TK_SET 108
|
||||||
#define TK_BOOL 109
|
#define TK_NK_EQ 109
|
||||||
#define TK_TINYINT 110
|
#define TK_USING 110
|
||||||
#define TK_SMALLINT 111
|
#define TK_TAGS 111
|
||||||
#define TK_INT 112
|
#define TK_COMMENT 112
|
||||||
#define TK_INTEGER 113
|
#define TK_BOOL 113
|
||||||
#define TK_BIGINT 114
|
#define TK_TINYINT 114
|
||||||
#define TK_FLOAT 115
|
#define TK_SMALLINT 115
|
||||||
#define TK_DOUBLE 116
|
#define TK_INT 116
|
||||||
#define TK_BINARY 117
|
#define TK_INTEGER 117
|
||||||
#define TK_TIMESTAMP 118
|
#define TK_BIGINT 118
|
||||||
#define TK_NCHAR 119
|
#define TK_FLOAT 119
|
||||||
#define TK_UNSIGNED 120
|
#define TK_DOUBLE 120
|
||||||
#define TK_JSON 121
|
#define TK_BINARY 121
|
||||||
#define TK_VARCHAR 122
|
#define TK_NCHAR 122
|
||||||
#define TK_MEDIUMBLOB 123
|
#define TK_UNSIGNED 123
|
||||||
#define TK_BLOB 124
|
#define TK_JSON 124
|
||||||
#define TK_VARBINARY 125
|
#define TK_VARCHAR 125
|
||||||
#define TK_DECIMAL 126
|
#define TK_MEDIUMBLOB 126
|
||||||
#define TK_MAX_DELAY 127
|
#define TK_BLOB 127
|
||||||
#define TK_WATERMARK 128
|
#define TK_VARBINARY 128
|
||||||
#define TK_ROLLUP 129
|
#define TK_DECIMAL 129
|
||||||
#define TK_TTL 130
|
#define TK_MAX_DELAY 130
|
||||||
#define TK_SMA 131
|
#define TK_WATERMARK 131
|
||||||
#define TK_DELETE_MARK 132
|
#define TK_ROLLUP 132
|
||||||
#define TK_FIRST 133
|
#define TK_TTL 133
|
||||||
#define TK_LAST 134
|
#define TK_SMA 134
|
||||||
#define TK_SHOW 135
|
#define TK_DELETE_MARK 135
|
||||||
#define TK_PRIVILEGES 136
|
#define TK_FIRST 136
|
||||||
#define TK_DATABASES 137
|
#define TK_LAST 137
|
||||||
#define TK_TABLES 138
|
#define TK_SHOW 138
|
||||||
#define TK_STABLES 139
|
#define TK_PRIVILEGES 139
|
||||||
#define TK_MNODES 140
|
#define TK_DATABASES 140
|
||||||
#define TK_QNODES 141
|
#define TK_TABLES 141
|
||||||
#define TK_FUNCTIONS 142
|
#define TK_STABLES 142
|
||||||
#define TK_INDEXES 143
|
#define TK_MNODES 143
|
||||||
#define TK_ACCOUNTS 144
|
#define TK_QNODES 144
|
||||||
#define TK_APPS 145
|
#define TK_FUNCTIONS 145
|
||||||
#define TK_CONNECTIONS 146
|
#define TK_INDEXES 146
|
||||||
#define TK_LICENCES 147
|
#define TK_ACCOUNTS 147
|
||||||
#define TK_GRANTS 148
|
#define TK_APPS 148
|
||||||
#define TK_QUERIES 149
|
#define TK_CONNECTIONS 149
|
||||||
#define TK_SCORES 150
|
#define TK_LICENCES 150
|
||||||
#define TK_TOPICS 151
|
#define TK_GRANTS 151
|
||||||
#define TK_VARIABLES 152
|
#define TK_QUERIES 152
|
||||||
#define TK_CLUSTER 153
|
#define TK_SCORES 153
|
||||||
#define TK_BNODES 154
|
#define TK_TOPICS 154
|
||||||
#define TK_SNODES 155
|
#define TK_VARIABLES 155
|
||||||
#define TK_TRANSACTIONS 156
|
#define TK_CLUSTER 156
|
||||||
#define TK_DISTRIBUTED 157
|
#define TK_BNODES 157
|
||||||
#define TK_CONSUMERS 158
|
#define TK_SNODES 158
|
||||||
#define TK_SUBSCRIPTIONS 159
|
#define TK_TRANSACTIONS 159
|
||||||
#define TK_VNODES 160
|
#define TK_DISTRIBUTED 160
|
||||||
#define TK_ALIVE 161
|
#define TK_CONSUMERS 161
|
||||||
#define TK_LIKE 162
|
#define TK_SUBSCRIPTIONS 162
|
||||||
#define TK_TBNAME 163
|
#define TK_VNODES 163
|
||||||
#define TK_QTAGS 164
|
#define TK_ALIVE 164
|
||||||
#define TK_AS 165
|
#define TK_LIKE 165
|
||||||
#define TK_INDEX 166
|
#define TK_TBNAME 166
|
||||||
#define TK_FUNCTION 167
|
#define TK_QTAGS 167
|
||||||
#define TK_INTERVAL 168
|
#define TK_AS 168
|
||||||
#define TK_COUNT 169
|
#define TK_INDEX 169
|
||||||
#define TK_LAST_ROW 170
|
#define TK_FUNCTION 170
|
||||||
#define TK_TOPIC 171
|
#define TK_INTERVAL 171
|
||||||
#define TK_WITH 172
|
#define TK_COUNT 172
|
||||||
#define TK_META 173
|
#define TK_LAST_ROW 173
|
||||||
#define TK_CONSUMER 174
|
#define TK_TOPIC 174
|
||||||
#define TK_GROUP 175
|
#define TK_META 175
|
||||||
#define TK_DESC 176
|
#define TK_CONSUMER 176
|
||||||
#define TK_DESCRIBE 177
|
#define TK_GROUP 177
|
||||||
#define TK_RESET 178
|
#define TK_DESC 178
|
||||||
#define TK_QUERY 179
|
#define TK_DESCRIBE 179
|
||||||
#define TK_CACHE 180
|
#define TK_RESET 180
|
||||||
#define TK_EXPLAIN 181
|
#define TK_QUERY 181
|
||||||
#define TK_ANALYZE 182
|
#define TK_CACHE 182
|
||||||
#define TK_VERBOSE 183
|
#define TK_EXPLAIN 183
|
||||||
#define TK_NK_BOOL 184
|
#define TK_ANALYZE 184
|
||||||
#define TK_RATIO 185
|
#define TK_VERBOSE 185
|
||||||
#define TK_NK_FLOAT 186
|
#define TK_NK_BOOL 186
|
||||||
#define TK_OUTPUTTYPE 187
|
#define TK_RATIO 187
|
||||||
#define TK_AGGREGATE 188
|
#define TK_NK_FLOAT 188
|
||||||
#define TK_BUFSIZE 189
|
#define TK_OUTPUTTYPE 189
|
||||||
#define TK_STREAM 190
|
#define TK_AGGREGATE 190
|
||||||
#define TK_INTO 191
|
#define TK_BUFSIZE 191
|
||||||
#define TK_TRIGGER 192
|
#define TK_STREAM 192
|
||||||
#define TK_AT_ONCE 193
|
#define TK_INTO 193
|
||||||
#define TK_WINDOW_CLOSE 194
|
#define TK_TRIGGER 194
|
||||||
#define TK_IGNORE 195
|
#define TK_AT_ONCE 195
|
||||||
#define TK_EXPIRED 196
|
#define TK_WINDOW_CLOSE 196
|
||||||
#define TK_FILL_HISTORY 197
|
#define TK_IGNORE 197
|
||||||
#define TK_UPDATE 198
|
#define TK_EXPIRED 198
|
||||||
#define TK_SUBTABLE 199
|
#define TK_FILL_HISTORY 199
|
||||||
#define TK_KILL 200
|
#define TK_UPDATE 200
|
||||||
#define TK_CONNECTION 201
|
#define TK_SUBTABLE 201
|
||||||
#define TK_TRANSACTION 202
|
#define TK_KILL 202
|
||||||
#define TK_BALANCE 203
|
#define TK_CONNECTION 203
|
||||||
#define TK_VGROUP 204
|
#define TK_TRANSACTION 204
|
||||||
#define TK_MERGE 205
|
#define TK_BALANCE 205
|
||||||
#define TK_REDISTRIBUTE 206
|
#define TK_VGROUP 206
|
||||||
#define TK_SPLIT 207
|
#define TK_MERGE 207
|
||||||
#define TK_DELETE 208
|
#define TK_REDISTRIBUTE 208
|
||||||
#define TK_INSERT 209
|
#define TK_SPLIT 209
|
||||||
#define TK_NULL 210
|
#define TK_DELETE 210
|
||||||
#define TK_NK_QUESTION 211
|
#define TK_INSERT 211
|
||||||
#define TK_NK_ARROW 212
|
#define TK_NULL 212
|
||||||
#define TK_ROWTS 213
|
#define TK_NK_QUESTION 213
|
||||||
#define TK_QSTART 214
|
#define TK_NK_ARROW 214
|
||||||
#define TK_QEND 215
|
#define TK_ROWTS 215
|
||||||
#define TK_QDURATION 216
|
#define TK_QSTART 216
|
||||||
#define TK_WSTART 217
|
#define TK_QEND 217
|
||||||
#define TK_WEND 218
|
#define TK_QDURATION 218
|
||||||
#define TK_WDURATION 219
|
#define TK_WSTART 219
|
||||||
#define TK_IROWTS 220
|
#define TK_WEND 220
|
||||||
#define TK_ISFILLED 221
|
#define TK_WDURATION 221
|
||||||
#define TK_CAST 222
|
#define TK_IROWTS 222
|
||||||
#define TK_NOW 223
|
#define TK_ISFILLED 223
|
||||||
#define TK_TODAY 224
|
#define TK_CAST 224
|
||||||
#define TK_TIMEZONE 225
|
#define TK_NOW 225
|
||||||
#define TK_CLIENT_VERSION 226
|
#define TK_TODAY 226
|
||||||
#define TK_SERVER_VERSION 227
|
#define TK_TIMEZONE 227
|
||||||
#define TK_SERVER_STATUS 228
|
#define TK_CLIENT_VERSION 228
|
||||||
#define TK_CURRENT_USER 229
|
#define TK_SERVER_VERSION 229
|
||||||
#define TK_CASE 230
|
#define TK_SERVER_STATUS 230
|
||||||
#define TK_END 231
|
#define TK_CURRENT_USER 231
|
||||||
#define TK_WHEN 232
|
#define TK_CASE 232
|
||||||
#define TK_THEN 233
|
#define TK_WHEN 233
|
||||||
#define TK_ELSE 234
|
#define TK_THEN 234
|
||||||
#define TK_BETWEEN 235
|
#define TK_ELSE 235
|
||||||
#define TK_IS 236
|
#define TK_BETWEEN 236
|
||||||
#define TK_NK_LT 237
|
#define TK_IS 237
|
||||||
#define TK_NK_GT 238
|
#define TK_NK_LT 238
|
||||||
#define TK_NK_LE 239
|
#define TK_NK_GT 239
|
||||||
#define TK_NK_GE 240
|
#define TK_NK_LE 240
|
||||||
#define TK_NK_NE 241
|
#define TK_NK_GE 241
|
||||||
#define TK_MATCH 242
|
#define TK_NK_NE 242
|
||||||
#define TK_NMATCH 243
|
#define TK_MATCH 243
|
||||||
#define TK_CONTAINS 244
|
#define TK_NMATCH 244
|
||||||
#define TK_IN 245
|
#define TK_CONTAINS 245
|
||||||
#define TK_JOIN 246
|
#define TK_IN 246
|
||||||
#define TK_INNER 247
|
#define TK_JOIN 247
|
||||||
#define TK_SELECT 248
|
#define TK_INNER 248
|
||||||
#define TK_DISTINCT 249
|
#define TK_SELECT 249
|
||||||
#define TK_WHERE 250
|
#define TK_DISTINCT 250
|
||||||
#define TK_PARTITION 251
|
#define TK_WHERE 251
|
||||||
#define TK_BY 252
|
#define TK_PARTITION 252
|
||||||
#define TK_SESSION 253
|
#define TK_BY 253
|
||||||
#define TK_STATE_WINDOW 254
|
#define TK_SESSION 254
|
||||||
#define TK_EVENT_WINDOW 255
|
#define TK_STATE_WINDOW 255
|
||||||
#define TK_START 256
|
#define TK_EVENT_WINDOW 256
|
||||||
#define TK_SLIDING 257
|
#define TK_SLIDING 257
|
||||||
#define TK_FILL 258
|
#define TK_FILL 258
|
||||||
#define TK_VALUE 259
|
#define TK_VALUE 259
|
||||||
|
|
|
@ -128,6 +128,8 @@ typedef struct STrimDatabaseStmt {
|
||||||
typedef struct SCompactDatabaseStmt {
|
typedef struct SCompactDatabaseStmt {
|
||||||
ENodeType type;
|
ENodeType type;
|
||||||
char dbName[TSDB_DB_NAME_LEN];
|
char dbName[TSDB_DB_NAME_LEN];
|
||||||
|
SNode* pStart;
|
||||||
|
SNode* pEnd;
|
||||||
} SCompactDatabaseStmt;
|
} SCompactDatabaseStmt;
|
||||||
|
|
||||||
typedef struct STableOptions {
|
typedef struct STableOptions {
|
||||||
|
|
|
@ -2531,6 +2531,8 @@ int32_t tSerializeSCompactDbReq(void *buf, int32_t bufLen, SCompactDbReq *pReq)
|
||||||
|
|
||||||
if (tStartEncode(&encoder) < 0) return -1;
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
if (tEncodeCStr(&encoder, pReq->db) < 0) return -1;
|
if (tEncodeCStr(&encoder, pReq->db) < 0) return -1;
|
||||||
|
if (tEncodeI64(&encoder, pReq->timeRange.skey) < 0) return -1;
|
||||||
|
if (tEncodeI64(&encoder, pReq->timeRange.ekey) < 0) return -1;
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
|
@ -2544,6 +2546,8 @@ int32_t tDeserializeSCompactDbReq(void *buf, int32_t bufLen, SCompactDbReq *pReq
|
||||||
|
|
||||||
if (tStartDecode(&decoder) < 0) return -1;
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
if (tDecodeCStrTo(&decoder, pReq->db) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->db) < 0) return -1;
|
||||||
|
if (tDecodeI64(&decoder, &pReq->timeRange.skey) < 0) return -1;
|
||||||
|
if (tDecodeI64(&decoder, &pReq->timeRange.ekey) < 0) return -1;
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
|
|
@ -151,7 +151,7 @@ SNode* createDropDatabaseStmt(SAstCreateContext* pCxt, bool ignoreNotExists, STo
|
||||||
SNode* createAlterDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName, SNode* pOptions);
|
SNode* createAlterDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName, SNode* pOptions);
|
||||||
SNode* createFlushDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName);
|
SNode* createFlushDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName);
|
||||||
SNode* createTrimDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName, int32_t maxSpeed);
|
SNode* createTrimDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName, int32_t maxSpeed);
|
||||||
SNode* createCompactStmt(SAstCreateContext* pCxt, SToken* pDbName);
|
SNode* createCompactStmt(SAstCreateContext* pCxt, SToken* pDbName, SNode* pStart, SNode* pEnd);
|
||||||
SNode* createDefaultTableOptions(SAstCreateContext* pCxt);
|
SNode* createDefaultTableOptions(SAstCreateContext* pCxt);
|
||||||
SNode* createAlterTableOptions(SAstCreateContext* pCxt);
|
SNode* createAlterTableOptions(SAstCreateContext* pCxt);
|
||||||
SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType type, void* pVal);
|
SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType type, void* pVal);
|
||||||
|
|
|
@ -167,7 +167,7 @@ cmd ::= USE db_name(A).
|
||||||
cmd ::= ALTER DATABASE db_name(A) alter_db_options(B). { pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &A, B); }
|
cmd ::= ALTER DATABASE db_name(A) alter_db_options(B). { pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &A, B); }
|
||||||
cmd ::= FLUSH DATABASE db_name(A). { pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &A); }
|
cmd ::= FLUSH DATABASE db_name(A). { pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &A); }
|
||||||
cmd ::= TRIM DATABASE db_name(A) speed_opt(B). { pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &A, B); }
|
cmd ::= TRIM DATABASE db_name(A) speed_opt(B). { pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &A, B); }
|
||||||
cmd ::= COMPACT DATABASE db_name(A). { pCxt->pRootNode = createCompactStmt(pCxt, &A); }
|
cmd ::= COMPACT DATABASE db_name(A) start_opt(B) end_opt(C). { pCxt->pRootNode = createCompactStmt(pCxt, &A, B, C); }
|
||||||
|
|
||||||
%type not_exists_opt { bool }
|
%type not_exists_opt { bool }
|
||||||
%destructor not_exists_opt { }
|
%destructor not_exists_opt { }
|
||||||
|
@ -259,6 +259,16 @@ retention(A) ::= NK_VARIABLE(B) NK_COLON NK_VARIABLE(C).
|
||||||
speed_opt(A) ::= . { A = 0; }
|
speed_opt(A) ::= . { A = 0; }
|
||||||
speed_opt(A) ::= MAX_SPEED NK_INTEGER(B). { A = taosStr2Int32(B.z, NULL, 10); }
|
speed_opt(A) ::= MAX_SPEED NK_INTEGER(B). { A = taosStr2Int32(B.z, NULL, 10); }
|
||||||
|
|
||||||
|
start_opt(A) ::= . { A = NULL; }
|
||||||
|
start_opt(A) ::= START WITH NK_INTEGER(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &B); }
|
||||||
|
start_opt(A) ::= START WITH NK_STRING(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &B); }
|
||||||
|
start_opt(A) ::= START WITH TIMESTAMP NK_STRING(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &B); }
|
||||||
|
|
||||||
|
end_opt(A) ::= . { A = NULL; }
|
||||||
|
end_opt(A) ::= END WITH NK_INTEGER(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &B); }
|
||||||
|
end_opt(A) ::= END WITH NK_STRING(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &B); }
|
||||||
|
end_opt(A) ::= END WITH TIMESTAMP NK_STRING(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &B); }
|
||||||
|
|
||||||
/************************************************ create/drop table/stable ********************************************/
|
/************************************************ create/drop table/stable ********************************************/
|
||||||
cmd ::= CREATE TABLE not_exists_opt(A) full_table_name(B)
|
cmd ::= CREATE TABLE not_exists_opt(A) full_table_name(B)
|
||||||
NK_LP column_def_list(C) NK_RP tags_def_opt(D) table_options(E). { pCxt->pRootNode = createCreateTableStmt(pCxt, A, B, C, D, E); }
|
NK_LP column_def_list(C) NK_RP tags_def_opt(D) table_options(E). { pCxt->pRootNode = createCreateTableStmt(pCxt, A, B, C, D, E); }
|
||||||
|
|
|
@ -1105,7 +1105,7 @@ SNode* createTrimDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName, int32_t
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createCompactStmt(SAstCreateContext* pCxt, SToken* pDbName) {
|
SNode* createCompactStmt(SAstCreateContext* pCxt, SToken* pDbName, SNode* pStart, SNode* pEnd) {
|
||||||
CHECK_PARSER_STATUS(pCxt);
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
if (!checkDbName(pCxt, pDbName, false)) {
|
if (!checkDbName(pCxt, pDbName, false)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1113,6 +1113,8 @@ SNode* createCompactStmt(SAstCreateContext* pCxt, SToken* pDbName) {
|
||||||
SCompactDatabaseStmt* pStmt = (SCompactDatabaseStmt*)nodesMakeNode(QUERY_NODE_COMPACT_DATABASE_STMT);
|
SCompactDatabaseStmt* pStmt = (SCompactDatabaseStmt*)nodesMakeNode(QUERY_NODE_COMPACT_DATABASE_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
COPY_STRING_FORM_ID_TOKEN(pStmt->dbName, pDbName);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->dbName, pDbName);
|
||||||
|
pStmt->pStart = pStart;
|
||||||
|
pStmt->pEnd = pEnd;
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -166,7 +166,8 @@ static int32_t collectMetaKeyFromRealTableImpl(SCollectMetaKeyCxt* pCxt, const c
|
||||||
code = reserveDnodeRequiredInCache(pCxt->pMetaCache);
|
code = reserveDnodeRequiredInCache(pCxt->pMetaCache);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code &&
|
if (TSDB_CODE_SUCCESS == code &&
|
||||||
(0 == strcmp(pTable, TSDB_INS_TABLE_TAGS) || 0 == strcmp(pTable, TSDB_INS_TABLE_TABLES) || 0 == strcmp(pTable, TSDB_INS_TABLE_COLS)) &&
|
(0 == strcmp(pTable, TSDB_INS_TABLE_TAGS) || 0 == strcmp(pTable, TSDB_INS_TABLE_TABLES) ||
|
||||||
|
0 == strcmp(pTable, TSDB_INS_TABLE_COLS)) &&
|
||||||
QUERY_NODE_SELECT_STMT == nodeType(pCxt->pStmt)) {
|
QUERY_NODE_SELECT_STMT == nodeType(pCxt->pStmt)) {
|
||||||
code = collectMetaKeyFromInsTags(pCxt);
|
code = collectMetaKeyFromInsTags(pCxt);
|
||||||
}
|
}
|
||||||
|
@ -605,6 +606,10 @@ static int32_t collectMetaKeyFromShowSubscriptions(SCollectMetaKeyCxt* pCxt, SSh
|
||||||
pCxt->pMetaCache);
|
pCxt->pMetaCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t collectMetaKeyFromCompactDatabase(SCollectMetaKeyCxt* pCxt, SCompactDatabaseStmt* pStmt) {
|
||||||
|
return reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
|
static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
|
||||||
pCxt->pStmt = pStmt;
|
pCxt->pStmt = pStmt;
|
||||||
switch (nodeType(pStmt)) {
|
switch (nodeType(pStmt)) {
|
||||||
|
@ -636,6 +641,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
|
||||||
return collectMetaKeyFromExplain(pCxt, (SExplainStmt*)pStmt);
|
return collectMetaKeyFromExplain(pCxt, (SExplainStmt*)pStmt);
|
||||||
case QUERY_NODE_DESCRIBE_STMT:
|
case QUERY_NODE_DESCRIBE_STMT:
|
||||||
return collectMetaKeyFromDescribe(pCxt, (SDescribeStmt*)pStmt);
|
return collectMetaKeyFromDescribe(pCxt, (SDescribeStmt*)pStmt);
|
||||||
|
case QUERY_NODE_COMPACT_DATABASE_STMT:
|
||||||
|
return collectMetaKeyFromCompactDatabase(pCxt, (SCompactDatabaseStmt*)pStmt);
|
||||||
case QUERY_NODE_CREATE_STREAM_STMT:
|
case QUERY_NODE_CREATE_STREAM_STMT:
|
||||||
return collectMetaKeyFromCreateStream(pCxt, (SCreateStreamStmt*)pStmt);
|
return collectMetaKeyFromCreateStream(pCxt, (SCreateStreamStmt*)pStmt);
|
||||||
case QUERY_NODE_SHOW_DNODES_STMT:
|
case QUERY_NODE_SHOW_DNODES_STMT:
|
||||||
|
|
|
@ -5626,12 +5626,36 @@ static int32_t translateDescribe(STranslateContext* pCxt, SDescribeStmt* pStmt)
|
||||||
return refreshGetTableMeta(pCxt, pStmt->dbName, pStmt->tableName, &pStmt->pMeta);
|
return refreshGetTableMeta(pCxt, pStmt->dbName, pStmt->tableName, &pStmt->pMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t translateCompactRange(STranslateContext* pCxt, SCompactDatabaseStmt* pStmt, SCompactDbReq* pReq) {
|
||||||
|
SDbCfgInfo dbCfg = {0};
|
||||||
|
int32_t code = getDBCfg(pCxt, pStmt->dbName, &dbCfg);
|
||||||
|
if (TSDB_CODE_SUCCESS == code && NULL != pStmt->pStart) {
|
||||||
|
((SValueNode*)pStmt->pStart)->node.resType.precision = dbCfg.precision;
|
||||||
|
((SValueNode*)pStmt->pStart)->node.resType.type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||||
|
code = doTranslateValue(pCxt, (SValueNode*)pStmt->pStart);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code && NULL != pStmt->pEnd) {
|
||||||
|
((SValueNode*)pStmt->pEnd)->node.resType.precision = dbCfg.precision;
|
||||||
|
((SValueNode*)pStmt->pEnd)->node.resType.type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||||
|
code = doTranslateValue(pCxt, (SValueNode*)pStmt->pEnd);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
pReq->timeRange.skey = NULL != pStmt->pStart ? ((SValueNode*)pStmt->pStart)->datum.i : INT64_MIN;
|
||||||
|
pReq->timeRange.ekey = NULL != pStmt->pEnd ? ((SValueNode*)pStmt->pEnd)->datum.i : INT64_MAX;
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t translateCompact(STranslateContext* pCxt, SCompactDatabaseStmt* pStmt) {
|
static int32_t translateCompact(STranslateContext* pCxt, SCompactDatabaseStmt* pStmt) {
|
||||||
SCompactDbReq compactReq = {0};
|
SCompactDbReq compactReq = {0};
|
||||||
SName name;
|
SName name;
|
||||||
tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName));
|
tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName));
|
||||||
tNameGetFullDbName(&name, compactReq.db);
|
tNameGetFullDbName(&name, compactReq.db);
|
||||||
return buildCmdMsg(pCxt, TDMT_MND_COMPACT_DB, (FSerializeFunc)tSerializeSCompactDbReq, &compactReq);
|
int32_t code = translateCompactRange(pCxt, pStmt, &compactReq);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = buildCmdMsg(pCxt, TDMT_MND_COMPACT_DB, (FSerializeFunc)tSerializeSCompactDbReq, &compactReq);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t translateKillConnection(STranslateContext* pCxt, SKillStmt* pStmt) {
|
static int32_t translateKillConnection(STranslateContext* pCxt, SKillStmt* pStmt) {
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -226,6 +226,7 @@ void generateDatabases(MockCatalogService* mcs) {
|
||||||
generateTestTables(g_mockCatalogService.get(), "cache_db");
|
generateTestTables(g_mockCatalogService.get(), "cache_db");
|
||||||
generateTestStables(g_mockCatalogService.get(), "cache_db");
|
generateTestStables(g_mockCatalogService.get(), "cache_db");
|
||||||
mcs->createDatabase("rollup_db", true);
|
mcs->createDatabase("rollup_db", true);
|
||||||
|
mcs->createDatabase("testus", false, 0, TSDB_TIME_PRECISION_NANO);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -252,7 +253,8 @@ int32_t __catalogGetCachedTableHashVgroup(SCatalog* pCtg, const SName* pTableNam
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t __catalogGetCachedTableVgMeta(SCatalog* pCtg, const SName* pTableName, SVgroupInfo* pVgroup, STableMeta** pTableMeta) {
|
int32_t __catalogGetCachedTableVgMeta(SCatalog* pCtg, const SName* pTableName, SVgroupInfo* pVgroup,
|
||||||
|
STableMeta** pTableMeta) {
|
||||||
int32_t code = g_mockCatalogService->catalogGetTableMeta(pTableName, pTableMeta, true);
|
int32_t code = g_mockCatalogService->catalogGetTableMeta(pTableName, pTableMeta, true);
|
||||||
if (code) return code;
|
if (code) return code;
|
||||||
code = g_mockCatalogService->catalogGetTableHashVgroup(pTableName, pVgroup, true);
|
code = g_mockCatalogService->catalogGetTableHashVgroup(pTableName, pVgroup, true);
|
||||||
|
|
|
@ -346,12 +346,13 @@ class MockCatalogServiceImpl {
|
||||||
dnode_.insert(std::make_pair(dnodeId, epSet));
|
dnode_.insert(std::make_pair(dnodeId, epSet));
|
||||||
}
|
}
|
||||||
|
|
||||||
void createDatabase(const string& db, bool rollup, int8_t cacheLast) {
|
void createDatabase(const string& db, bool rollup, int8_t cacheLast, int8_t precision) {
|
||||||
SDbCfgInfo cfg = {0};
|
SDbCfgInfo cfg = {0};
|
||||||
if (rollup) {
|
if (rollup) {
|
||||||
cfg.pRetensions = taosArrayInit(TARRAY_MIN_SIZE, sizeof(SRetention));
|
cfg.pRetensions = taosArrayInit(TARRAY_MIN_SIZE, sizeof(SRetention));
|
||||||
}
|
}
|
||||||
cfg.cacheLast = cacheLast;
|
cfg.cacheLast = cacheLast;
|
||||||
|
cfg.precision = precision;
|
||||||
dbCfg_.insert(std::make_pair(db, cfg));
|
dbCfg_.insert(std::make_pair(db, cfg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -681,8 +682,8 @@ void MockCatalogService::createDnode(int32_t dnodeId, const string& host, int16_
|
||||||
impl_->createDnode(dnodeId, host, port);
|
impl_->createDnode(dnodeId, host, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MockCatalogService::createDatabase(const string& db, bool rollup, int8_t cacheLast) {
|
void MockCatalogService::createDatabase(const string& db, bool rollup, int8_t cacheLast, int8_t precision) {
|
||||||
impl_->createDatabase(db, rollup, cacheLast);
|
impl_->createDatabase(db, rollup, cacheLast, precision);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t MockCatalogService::catalogGetTableMeta(const SName* pTableName, STableMeta** pTableMeta,
|
int32_t MockCatalogService::catalogGetTableMeta(const SName* pTableName, STableMeta** pTableMeta,
|
||||||
|
|
|
@ -65,7 +65,8 @@ class MockCatalogService {
|
||||||
void createFunction(const std::string& func, int8_t funcType, int8_t outputType, int32_t outputLen, int32_t bufSize);
|
void createFunction(const std::string& func, int8_t funcType, int8_t outputType, int32_t outputLen, int32_t bufSize);
|
||||||
void createSmaIndex(const SMCreateSmaReq* pReq);
|
void createSmaIndex(const SMCreateSmaReq* pReq);
|
||||||
void createDnode(int32_t dnodeId, const std::string& host, int16_t port);
|
void createDnode(int32_t dnodeId, const std::string& host, int16_t port);
|
||||||
void createDatabase(const std::string& db, bool rollup = false, int8_t cacheLast = 0);
|
void createDatabase(const std::string& db, bool rollup = false, int8_t cacheLast = 0,
|
||||||
|
int8_t precision = TSDB_TIME_PRECISION_MILLI);
|
||||||
|
|
||||||
int32_t catalogGetTableMeta(const SName* pTableName, STableMeta** pTableMeta, bool onlyCache = false) const;
|
int32_t catalogGetTableMeta(const SName* pTableName, STableMeta** pTableMeta, bool onlyCache = false) const;
|
||||||
int32_t catalogGetTableHashVgroup(const SName* pTableName, SVgroupInfo* vgInfo, bool onlyCache = false) const;
|
int32_t catalogGetTableHashVgroup(const SName* pTableName, SVgroupInfo* vgInfo, bool onlyCache = false) const;
|
||||||
|
|
|
@ -22,12 +22,16 @@ namespace ParserTest {
|
||||||
class ParserInitialCTest : public ParserDdlTest {};
|
class ParserInitialCTest : public ParserDdlTest {};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* COMPACT DATABASE db_name
|
* COMPACT DATABASE db_name [START WITH start_time] [END WITH END_time]
|
||||||
*/
|
*/
|
||||||
TEST_F(ParserInitialCTest, compact) {
|
TEST_F(ParserInitialCTest, compact) {
|
||||||
SCompactDbReq expect = {0};
|
SCompactDbReq expect = {0};
|
||||||
|
|
||||||
auto setCompactDbReq = [&](const char* pDb) { snprintf(expect.db, sizeof(expect.db), "0.%s", pDb); };
|
auto setCompactDbReq = [&](const char* pDb, int64_t start = INT64_MIN, int64_t end = INT64_MAX) {
|
||||||
|
snprintf(expect.db, sizeof(expect.db), "0.%s", pDb);
|
||||||
|
expect.timeRange.skey = start;
|
||||||
|
expect.timeRange.ekey = end;
|
||||||
|
};
|
||||||
|
|
||||||
setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) {
|
setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) {
|
||||||
ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_COMPACT_DATABASE_STMT);
|
ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_COMPACT_DATABASE_STMT);
|
||||||
|
@ -35,10 +39,21 @@ TEST_F(ParserInitialCTest, compact) {
|
||||||
SCompactDbReq req = {0};
|
SCompactDbReq req = {0};
|
||||||
ASSERT_EQ(tDeserializeSCompactDbReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req), TSDB_CODE_SUCCESS);
|
ASSERT_EQ(tDeserializeSCompactDbReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req), TSDB_CODE_SUCCESS);
|
||||||
ASSERT_EQ(std::string(req.db), std::string(expect.db));
|
ASSERT_EQ(std::string(req.db), std::string(expect.db));
|
||||||
|
ASSERT_EQ(req.timeRange.skey, expect.timeRange.skey);
|
||||||
|
ASSERT_EQ(req.timeRange.ekey, expect.timeRange.ekey);
|
||||||
});
|
});
|
||||||
|
|
||||||
setCompactDbReq("wxy_db");
|
setCompactDbReq("test");
|
||||||
run("COMPACT DATABASE wxy_db");
|
run("COMPACT DATABASE test");
|
||||||
|
|
||||||
|
setCompactDbReq("test", 1678168883000, 1678255283000);
|
||||||
|
run("COMPACT DATABASE test START WITH '2023-03-07 14:01:23' END WITH '2023-03-08 14:01:23'");
|
||||||
|
|
||||||
|
setCompactDbReq("testus", 1673071283000000000);
|
||||||
|
run("COMPACT DATABASE testus START WITH TIMESTAMP '2023-01-07 14:01:23'");
|
||||||
|
|
||||||
|
setCompactDbReq("testus", INT64_MIN, 1675749683000000000);
|
||||||
|
run("COMPACT DATABASE testus END WITH 1675749683000000000");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -65,15 +65,16 @@ int32_t getLogLevel() { return g_logLevel; }
|
||||||
|
|
||||||
class ParserTestBaseImpl {
|
class ParserTestBaseImpl {
|
||||||
public:
|
public:
|
||||||
ParserTestBaseImpl(ParserTestBase* pBase) : pBase_(pBase), sqlNo_(0), sqlNum_(0) {}
|
ParserTestBaseImpl(ParserTestBase* pBase) : pBase_(pBase), sqlNo_(0), sqlNum_(0) {
|
||||||
|
caseEnv_.numOfSkipSql_ = g_skipSql;
|
||||||
|
caseEnv_.numOfLimitSql_ = g_limitSql;
|
||||||
|
}
|
||||||
|
|
||||||
void login(const std::string& user) { caseEnv_.user_ = user; }
|
void login(const std::string& user) { caseEnv_.user_ = user; }
|
||||||
|
|
||||||
void useDb(const string& acctId, const string& db) {
|
void useDb(const string& acctId, const string& db) {
|
||||||
caseEnv_.acctId_ = acctId;
|
caseEnv_.acctId_ = acctId;
|
||||||
caseEnv_.db_ = db;
|
caseEnv_.db_ = db;
|
||||||
caseEnv_.numOfSkipSql_ = g_skipSql;
|
|
||||||
caseEnv_.numOfLimitSql_ = g_limitSql;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void run(const string& sql, int32_t expect, ParserStage checkStage) {
|
void run(const string& sql, int32_t expect, ParserStage checkStage) {
|
||||||
|
|
Loading…
Reference in New Issue