Merge pull request #13943 from taosdata/feature/3.0_debug_wxy
feat: rollup options adjust
This commit is contained in:
commit
3599b26526
|
@ -429,8 +429,10 @@ STSchema* tdGetSTSChemaFromSSChema(SSchema** pSchema, int32_t nCols);
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char name[TSDB_TABLE_FNAME_LEN];
|
char name[TSDB_TABLE_FNAME_LEN];
|
||||||
int8_t igExists;
|
int8_t igExists;
|
||||||
float xFilesFactor;
|
int64_t delay1;
|
||||||
int32_t delay;
|
int64_t delay2;
|
||||||
|
int64_t watermark1;
|
||||||
|
int64_t watermark2;
|
||||||
int32_t ttl;
|
int32_t ttl;
|
||||||
int32_t numOfColumns;
|
int32_t numOfColumns;
|
||||||
int32_t numOfTags;
|
int32_t numOfTags;
|
||||||
|
|
|
@ -127,134 +127,133 @@
|
||||||
#define TK_BLOB 109
|
#define TK_BLOB 109
|
||||||
#define TK_VARBINARY 110
|
#define TK_VARBINARY 110
|
||||||
#define TK_DECIMAL 111
|
#define TK_DECIMAL 111
|
||||||
#define TK_FILE_FACTOR 112
|
#define TK_MAX_DELAY 112
|
||||||
#define TK_NK_FLOAT 113
|
#define TK_WATERMARK 113
|
||||||
#define TK_ROLLUP 114
|
#define TK_ROLLUP 114
|
||||||
#define TK_TTL 115
|
#define TK_TTL 115
|
||||||
#define TK_SMA 116
|
#define TK_SMA 116
|
||||||
#define TK_SHOW 117
|
#define TK_FIRST 117
|
||||||
#define TK_DATABASES 118
|
#define TK_LAST 118
|
||||||
#define TK_TABLES 119
|
#define TK_SHOW 119
|
||||||
#define TK_STABLES 120
|
#define TK_DATABASES 120
|
||||||
#define TK_MNODES 121
|
#define TK_TABLES 121
|
||||||
#define TK_MODULES 122
|
#define TK_STABLES 122
|
||||||
#define TK_QNODES 123
|
#define TK_MNODES 123
|
||||||
#define TK_FUNCTIONS 124
|
#define TK_MODULES 124
|
||||||
#define TK_INDEXES 125
|
#define TK_QNODES 125
|
||||||
#define TK_ACCOUNTS 126
|
#define TK_FUNCTIONS 126
|
||||||
#define TK_APPS 127
|
#define TK_INDEXES 127
|
||||||
#define TK_CONNECTIONS 128
|
#define TK_ACCOUNTS 128
|
||||||
#define TK_LICENCE 129
|
#define TK_APPS 129
|
||||||
#define TK_GRANTS 130
|
#define TK_CONNECTIONS 130
|
||||||
#define TK_QUERIES 131
|
#define TK_LICENCE 131
|
||||||
#define TK_SCORES 132
|
#define TK_GRANTS 132
|
||||||
#define TK_TOPICS 133
|
#define TK_QUERIES 133
|
||||||
#define TK_VARIABLES 134
|
#define TK_SCORES 134
|
||||||
#define TK_BNODES 135
|
#define TK_TOPICS 135
|
||||||
#define TK_SNODES 136
|
#define TK_VARIABLES 136
|
||||||
#define TK_CLUSTER 137
|
#define TK_BNODES 137
|
||||||
#define TK_TRANSACTIONS 138
|
#define TK_SNODES 138
|
||||||
#define TK_LIKE 139
|
#define TK_CLUSTER 139
|
||||||
#define TK_INDEX 140
|
#define TK_TRANSACTIONS 140
|
||||||
#define TK_FULLTEXT 141
|
#define TK_LIKE 141
|
||||||
#define TK_FUNCTION 142
|
#define TK_INDEX 142
|
||||||
#define TK_INTERVAL 143
|
#define TK_FULLTEXT 143
|
||||||
#define TK_TOPIC 144
|
#define TK_FUNCTION 144
|
||||||
#define TK_AS 145
|
#define TK_INTERVAL 145
|
||||||
#define TK_CONSUMER 146
|
#define TK_TOPIC 146
|
||||||
#define TK_GROUP 147
|
#define TK_AS 147
|
||||||
#define TK_DESC 148
|
#define TK_CONSUMER 148
|
||||||
#define TK_DESCRIBE 149
|
#define TK_GROUP 149
|
||||||
#define TK_RESET 150
|
#define TK_DESC 150
|
||||||
#define TK_QUERY 151
|
#define TK_DESCRIBE 151
|
||||||
#define TK_CACHE 152
|
#define TK_RESET 152
|
||||||
#define TK_EXPLAIN 153
|
#define TK_QUERY 153
|
||||||
#define TK_ANALYZE 154
|
#define TK_CACHE 154
|
||||||
#define TK_VERBOSE 155
|
#define TK_EXPLAIN 155
|
||||||
#define TK_NK_BOOL 156
|
#define TK_ANALYZE 156
|
||||||
#define TK_RATIO 157
|
#define TK_VERBOSE 157
|
||||||
#define TK_COMPACT 158
|
#define TK_NK_BOOL 158
|
||||||
#define TK_VNODES 159
|
#define TK_RATIO 159
|
||||||
#define TK_IN 160
|
#define TK_NK_FLOAT 160
|
||||||
#define TK_OUTPUTTYPE 161
|
#define TK_COMPACT 161
|
||||||
#define TK_AGGREGATE 162
|
#define TK_VNODES 162
|
||||||
#define TK_BUFSIZE 163
|
#define TK_IN 163
|
||||||
#define TK_STREAM 164
|
#define TK_OUTPUTTYPE 164
|
||||||
#define TK_INTO 165
|
#define TK_AGGREGATE 165
|
||||||
#define TK_TRIGGER 166
|
#define TK_BUFSIZE 166
|
||||||
#define TK_AT_ONCE 167
|
#define TK_STREAM 167
|
||||||
#define TK_WINDOW_CLOSE 168
|
#define TK_INTO 168
|
||||||
#define TK_MAX_DELAY 169
|
#define TK_TRIGGER 169
|
||||||
#define TK_WATERMARK 170
|
#define TK_AT_ONCE 170
|
||||||
#define TK_KILL 171
|
#define TK_WINDOW_CLOSE 171
|
||||||
#define TK_CONNECTION 172
|
#define TK_KILL 172
|
||||||
#define TK_TRANSACTION 173
|
#define TK_CONNECTION 173
|
||||||
#define TK_BALANCE 174
|
#define TK_TRANSACTION 174
|
||||||
#define TK_VGROUP 175
|
#define TK_BALANCE 175
|
||||||
#define TK_MERGE 176
|
#define TK_VGROUP 176
|
||||||
#define TK_REDISTRIBUTE 177
|
#define TK_MERGE 177
|
||||||
#define TK_SPLIT 178
|
#define TK_REDISTRIBUTE 178
|
||||||
#define TK_SYNCDB 179
|
#define TK_SPLIT 179
|
||||||
#define TK_DELETE 180
|
#define TK_SYNCDB 180
|
||||||
#define TK_NULL 181
|
#define TK_DELETE 181
|
||||||
#define TK_NK_QUESTION 182
|
#define TK_NULL 182
|
||||||
#define TK_NK_ARROW 183
|
#define TK_NK_QUESTION 183
|
||||||
#define TK_ROWTS 184
|
#define TK_NK_ARROW 184
|
||||||
#define TK_TBNAME 185
|
#define TK_ROWTS 185
|
||||||
#define TK_QSTARTTS 186
|
#define TK_TBNAME 186
|
||||||
#define TK_QENDTS 187
|
#define TK_QSTARTTS 187
|
||||||
#define TK_WSTARTTS 188
|
#define TK_QENDTS 188
|
||||||
#define TK_WENDTS 189
|
#define TK_WSTARTTS 189
|
||||||
#define TK_WDURATION 190
|
#define TK_WENDTS 190
|
||||||
#define TK_CAST 191
|
#define TK_WDURATION 191
|
||||||
#define TK_NOW 192
|
#define TK_CAST 192
|
||||||
#define TK_TODAY 193
|
#define TK_NOW 193
|
||||||
#define TK_TIMEZONE 194
|
#define TK_TODAY 194
|
||||||
#define TK_COUNT 195
|
#define TK_TIMEZONE 195
|
||||||
#define TK_FIRST 196
|
#define TK_COUNT 196
|
||||||
#define TK_LAST 197
|
#define TK_LAST_ROW 197
|
||||||
#define TK_LAST_ROW 198
|
#define TK_BETWEEN 198
|
||||||
#define TK_BETWEEN 199
|
#define TK_IS 199
|
||||||
#define TK_IS 200
|
#define TK_NK_LT 200
|
||||||
#define TK_NK_LT 201
|
#define TK_NK_GT 201
|
||||||
#define TK_NK_GT 202
|
#define TK_NK_LE 202
|
||||||
#define TK_NK_LE 203
|
#define TK_NK_GE 203
|
||||||
#define TK_NK_GE 204
|
#define TK_NK_NE 204
|
||||||
#define TK_NK_NE 205
|
#define TK_MATCH 205
|
||||||
#define TK_MATCH 206
|
#define TK_NMATCH 206
|
||||||
#define TK_NMATCH 207
|
#define TK_CONTAINS 207
|
||||||
#define TK_CONTAINS 208
|
#define TK_JOIN 208
|
||||||
#define TK_JOIN 209
|
#define TK_INNER 209
|
||||||
#define TK_INNER 210
|
#define TK_SELECT 210
|
||||||
#define TK_SELECT 211
|
#define TK_DISTINCT 211
|
||||||
#define TK_DISTINCT 212
|
#define TK_WHERE 212
|
||||||
#define TK_WHERE 213
|
#define TK_PARTITION 213
|
||||||
#define TK_PARTITION 214
|
#define TK_BY 214
|
||||||
#define TK_BY 215
|
#define TK_SESSION 215
|
||||||
#define TK_SESSION 216
|
#define TK_STATE_WINDOW 216
|
||||||
#define TK_STATE_WINDOW 217
|
#define TK_SLIDING 217
|
||||||
#define TK_SLIDING 218
|
#define TK_FILL 218
|
||||||
#define TK_FILL 219
|
#define TK_VALUE 219
|
||||||
#define TK_VALUE 220
|
#define TK_NONE 220
|
||||||
#define TK_NONE 221
|
#define TK_PREV 221
|
||||||
#define TK_PREV 222
|
#define TK_LINEAR 222
|
||||||
#define TK_LINEAR 223
|
#define TK_NEXT 223
|
||||||
#define TK_NEXT 224
|
#define TK_HAVING 224
|
||||||
#define TK_HAVING 225
|
#define TK_ORDER 225
|
||||||
#define TK_ORDER 226
|
#define TK_SLIMIT 226
|
||||||
#define TK_SLIMIT 227
|
#define TK_SOFFSET 227
|
||||||
#define TK_SOFFSET 228
|
#define TK_LIMIT 228
|
||||||
#define TK_LIMIT 229
|
#define TK_OFFSET 229
|
||||||
#define TK_OFFSET 230
|
#define TK_ASC 230
|
||||||
#define TK_ASC 231
|
#define TK_NULLS 231
|
||||||
#define TK_NULLS 232
|
#define TK_ID 232
|
||||||
#define TK_ID 233
|
#define TK_NK_BITNOT 233
|
||||||
#define TK_NK_BITNOT 234
|
#define TK_INSERT 234
|
||||||
#define TK_INSERT 235
|
#define TK_VALUES 235
|
||||||
#define TK_VALUES 236
|
#define TK_IMPORT 236
|
||||||
#define TK_IMPORT 237
|
#define TK_NK_SEMI 237
|
||||||
#define TK_NK_SEMI 238
|
#define TK_FILE 238
|
||||||
#define TK_FILE 239
|
|
||||||
|
|
||||||
#define TK_NK_SPACE 300
|
#define TK_NK_SPACE 300
|
||||||
#define TK_NK_COMMENT 301
|
#define TK_NK_COMMENT 301
|
||||||
|
|
|
@ -88,8 +88,12 @@ typedef struct SAlterDatabaseStmt {
|
||||||
typedef struct STableOptions {
|
typedef struct STableOptions {
|
||||||
ENodeType type;
|
ENodeType type;
|
||||||
char comment[TSDB_TB_COMMENT_LEN];
|
char comment[TSDB_TB_COMMENT_LEN];
|
||||||
double filesFactor;
|
SNodeList* pMaxDelay;
|
||||||
int32_t delay;
|
int64_t maxDelay1;
|
||||||
|
int64_t maxDelay2;
|
||||||
|
SNodeList* pWatermark;
|
||||||
|
int64_t watermark1;
|
||||||
|
int64_t watermark2;
|
||||||
SNodeList* pRollupFuncs;
|
SNodeList* pRollupFuncs;
|
||||||
int32_t ttl;
|
int32_t ttl;
|
||||||
SNodeList* pSma;
|
SNodeList* pSma;
|
||||||
|
@ -204,11 +208,18 @@ typedef struct SShowStmt {
|
||||||
SNode* pTbNamePattern; // SValueNode
|
SNode* pTbNamePattern; // SValueNode
|
||||||
} SShowStmt;
|
} SShowStmt;
|
||||||
|
|
||||||
typedef struct SShowCreatStmt {
|
typedef struct SShowCreateDatabaseStmt {
|
||||||
ENodeType type;
|
ENodeType type;
|
||||||
char dbName[TSDB_DB_NAME_LEN];
|
char dbName[TSDB_DB_NAME_LEN];
|
||||||
char tableName[TSDB_TABLE_NAME_LEN];
|
void* pCfg; // SDbCfgInfo
|
||||||
} SShowCreatStmt;
|
} SShowCreateDatabaseStmt;
|
||||||
|
|
||||||
|
typedef struct SShowCreateTableStmt {
|
||||||
|
ENodeType type;
|
||||||
|
char dbName[TSDB_DB_NAME_LEN];
|
||||||
|
char tableName[TSDB_TABLE_NAME_LEN];
|
||||||
|
STableMeta* pMeta;
|
||||||
|
} SShowCreateTableStmt;
|
||||||
|
|
||||||
typedef enum EIndexType { INDEX_TYPE_SMA = 1, INDEX_TYPE_FULLTEXT } EIndexType;
|
typedef enum EIndexType { INDEX_TYPE_SMA = 1, INDEX_TYPE_FULLTEXT } EIndexType;
|
||||||
|
|
||||||
|
|
|
@ -562,6 +562,7 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_PAR_WINDOW_NOT_ALLOWED_FUNC TAOS_DEF_ERROR_CODE(0, 0x2659)
|
#define TSDB_CODE_PAR_WINDOW_NOT_ALLOWED_FUNC TAOS_DEF_ERROR_CODE(0, 0x2659)
|
||||||
#define TSDB_CODE_PAR_STREAM_NOT_ALLOWED_FUNC TAOS_DEF_ERROR_CODE(0, 0x265A)
|
#define TSDB_CODE_PAR_STREAM_NOT_ALLOWED_FUNC TAOS_DEF_ERROR_CODE(0, 0x265A)
|
||||||
#define TSDB_CODE_PAR_GROUP_BY_NOT_ALLOWED_FUNC TAOS_DEF_ERROR_CODE(0, 0x265B)
|
#define TSDB_CODE_PAR_GROUP_BY_NOT_ALLOWED_FUNC TAOS_DEF_ERROR_CODE(0, 0x265B)
|
||||||
|
#define TSDB_CODE_PAR_INVALID_TABLE_OPTION TAOS_DEF_ERROR_CODE(0, 0x265C)
|
||||||
|
|
||||||
//planner
|
//planner
|
||||||
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
|
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
|
||||||
|
|
|
@ -344,14 +344,13 @@ typedef enum ELogicConditionType {
|
||||||
#define TSDB_DB_SCHEMALESS_OFF 0
|
#define TSDB_DB_SCHEMALESS_OFF 0
|
||||||
#define TSDB_DEFAULT_DB_SCHEMALESS TSDB_DB_SCHEMALESS_OFF
|
#define TSDB_DEFAULT_DB_SCHEMALESS TSDB_DB_SCHEMALESS_OFF
|
||||||
|
|
||||||
// #define TSDB_MIN_ROLLUP_DELAY 1
|
#define TSDB_MIN_ROLLUP_MAX_DELAY 1 // unit millisecond
|
||||||
// #define TSDB_MAX_ROLLUP_DELAY 10
|
#define TSDB_MAX_ROLLUP_MAX_DELAY (15 * 60 * 1000)
|
||||||
// #define TSDB_DEFAULT_ROLLUP_DELAY 1
|
#define TSDB_MIN_ROLLUP_WATERMARK 0 // unit millisecond
|
||||||
#define TSDB_MIN_ROLLUP_FILE_FACTOR 0
|
#define TSDB_MAX_ROLLUP_WATERMARK (15 * 60 * 1000)
|
||||||
#define TSDB_MAX_ROLLUP_FILE_FACTOR 10
|
#define TSDB_DEFAULT_ROLLUP_WATERMARK 5000
|
||||||
#define TSDB_DEFAULT_ROLLUP_FILE_FACTOR 0.1
|
#define TSDB_MIN_TABLE_TTL 0
|
||||||
#define TSDB_MIN_TABLE_TTL 0
|
#define TSDB_DEFAULT_TABLE_TTL 0
|
||||||
#define TSDB_DEFAULT_TABLE_TTL 0
|
|
||||||
|
|
||||||
#define TSDB_MIN_EXPLAIN_RATIO 0
|
#define TSDB_MIN_EXPLAIN_RATIO 0
|
||||||
#define TSDB_MAX_EXPLAIN_RATIO 1
|
#define TSDB_MAX_EXPLAIN_RATIO 1
|
||||||
|
|
|
@ -204,7 +204,7 @@ static int32_t tSerializeSClientHbReq(SEncoder *pEncoder, const SClientHbReq *pR
|
||||||
if (tEncodeU64(pEncoder, pReq->app.summary.numOfSlowQueries) < 0) return -1;
|
if (tEncodeU64(pEncoder, pReq->app.summary.numOfSlowQueries) < 0) return -1;
|
||||||
if (tEncodeU64(pEncoder, pReq->app.summary.totalRequests) < 0) return -1;
|
if (tEncodeU64(pEncoder, pReq->app.summary.totalRequests) < 0) return -1;
|
||||||
if (tEncodeU64(pEncoder, pReq->app.summary.currentRequests) < 0) return -1;
|
if (tEncodeU64(pEncoder, pReq->app.summary.currentRequests) < 0) return -1;
|
||||||
|
|
||||||
int32_t queryNum = 0;
|
int32_t queryNum = 0;
|
||||||
if (pReq->query) {
|
if (pReq->query) {
|
||||||
queryNum = 1;
|
queryNum = 1;
|
||||||
|
@ -288,7 +288,7 @@ static int32_t tDeserializeSClientHbReq(SDecoder *pDecoder, SClientHbReq *pReq)
|
||||||
if (tDecodeI64(pDecoder, &desc.useconds) < 0) return -1;
|
if (tDecodeI64(pDecoder, &desc.useconds) < 0) return -1;
|
||||||
if (tDecodeI64(pDecoder, &desc.stime) < 0) return -1;
|
if (tDecodeI64(pDecoder, &desc.stime) < 0) return -1;
|
||||||
if (tDecodeI64(pDecoder, &desc.reqRid) < 0) return -1;
|
if (tDecodeI64(pDecoder, &desc.reqRid) < 0) return -1;
|
||||||
if (tDecodeI8(pDecoder, (int8_t*)&desc.stableQuery) < 0) return -1;
|
if (tDecodeI8(pDecoder, (int8_t *)&desc.stableQuery) < 0) return -1;
|
||||||
if (tDecodeCStrTo(pDecoder, desc.fqdn) < 0) return -1;
|
if (tDecodeCStrTo(pDecoder, desc.fqdn) < 0) return -1;
|
||||||
if (tDecodeI32(pDecoder, &desc.subPlanNum) < 0) return -1;
|
if (tDecodeI32(pDecoder, &desc.subPlanNum) < 0) return -1;
|
||||||
|
|
||||||
|
@ -496,8 +496,10 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
|
||||||
if (tStartEncode(&encoder) < 0) return -1;
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
if (tEncodeCStr(&encoder, pReq->name) < 0) return -1;
|
if (tEncodeCStr(&encoder, pReq->name) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pReq->igExists) < 0) return -1;
|
if (tEncodeI8(&encoder, pReq->igExists) < 0) return -1;
|
||||||
if (tEncodeFloat(&encoder, pReq->xFilesFactor) < 0) return -1;
|
if (tEncodeI64(&encoder, pReq->delay1) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, pReq->delay) < 0) return -1;
|
if (tEncodeI64(&encoder, pReq->delay2) < 0) return -1;
|
||||||
|
if (tEncodeI64(&encoder, pReq->watermark1) < 0) return -1;
|
||||||
|
if (tEncodeI64(&encoder, pReq->watermark2) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, pReq->ttl) < 0) return -1;
|
if (tEncodeI32(&encoder, pReq->ttl) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, pReq->numOfColumns) < 0) return -1;
|
if (tEncodeI32(&encoder, pReq->numOfColumns) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, pReq->numOfTags) < 0) return -1;
|
if (tEncodeI32(&encoder, pReq->numOfTags) < 0) return -1;
|
||||||
|
@ -544,8 +546,10 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
|
||||||
if (tStartDecode(&decoder) < 0) return -1;
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &pReq->igExists) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->igExists) < 0) return -1;
|
||||||
if (tDecodeFloat(&decoder, &pReq->xFilesFactor) < 0) return -1;
|
if (tDecodeI64(&decoder, &pReq->delay1) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &pReq->delay) < 0) return -1;
|
if (tDecodeI64(&decoder, &pReq->delay2) < 0) return -1;
|
||||||
|
if (tDecodeI64(&decoder, &pReq->watermark1) < 0) return -1;
|
||||||
|
if (tDecodeI64(&decoder, &pReq->watermark2) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &pReq->ttl) < 0) return -1;
|
if (tDecodeI32(&decoder, &pReq->ttl) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &pReq->numOfColumns) < 0) return -1;
|
if (tDecodeI32(&decoder, &pReq->numOfColumns) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &pReq->numOfTags) < 0) return -1;
|
if (tDecodeI32(&decoder, &pReq->numOfTags) < 0) return -1;
|
||||||
|
|
|
@ -669,8 +669,8 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat
|
||||||
pDst->tagVer = 1;
|
pDst->tagVer = 1;
|
||||||
pDst->colVer = 1;
|
pDst->colVer = 1;
|
||||||
pDst->nextColId = 1;
|
pDst->nextColId = 1;
|
||||||
pDst->xFilesFactor = pCreate->xFilesFactor;
|
// pDst->xFilesFactor = pCreate->xFilesFactor;
|
||||||
pDst->delay = pCreate->delay;
|
// pDst->delay = pCreate->delay;
|
||||||
pDst->ttl = pCreate->ttl;
|
pDst->ttl = pCreate->ttl;
|
||||||
pDst->numOfColumns = pCreate->numOfColumns;
|
pDst->numOfColumns = pCreate->numOfColumns;
|
||||||
pDst->numOfTags = pCreate->numOfTags;
|
pDst->numOfTags = pCreate->numOfTags;
|
||||||
|
|
|
@ -47,7 +47,8 @@ static SSDataBlock* buildDescResultDataBlock() {
|
||||||
taosArrayPush(pBlock->pDataBlock, &infoData);
|
taosArrayPush(pBlock->pDataBlock, &infoData);
|
||||||
|
|
||||||
infoData.info.type = TSDB_DATA_TYPE_INT;
|
infoData.info.type = TSDB_DATA_TYPE_INT;
|
||||||
infoData.info.bytes = tDataTypes[TSDB_DATA_TYPE_INT].bytes;;
|
infoData.info.bytes = tDataTypes[TSDB_DATA_TYPE_INT].bytes;
|
||||||
|
|
||||||
taosArrayPush(pBlock->pDataBlock, &infoData);
|
taosArrayPush(pBlock->pDataBlock, &infoData);
|
||||||
|
|
||||||
infoData.info.type = TSDB_DATA_TYPE_VARCHAR;
|
infoData.info.type = TSDB_DATA_TYPE_VARCHAR;
|
||||||
|
@ -63,7 +64,7 @@ static void setDescResultIntoDataBlock(SSDataBlock* pBlock, int32_t numOfRows, S
|
||||||
|
|
||||||
// field
|
// field
|
||||||
SColumnInfoData* pCol1 = taosArrayGet(pBlock->pDataBlock, 0);
|
SColumnInfoData* pCol1 = taosArrayGet(pBlock->pDataBlock, 0);
|
||||||
char buf[DESCRIBE_RESULT_FIELD_LEN] = {0};
|
char buf[DESCRIBE_RESULT_FIELD_LEN] = {0};
|
||||||
for (int32_t i = 0; i < numOfRows; ++i) {
|
for (int32_t i = 0; i < numOfRows; ++i) {
|
||||||
STR_TO_VARSTR(buf, pMeta->schema[i].name);
|
STR_TO_VARSTR(buf, pMeta->schema[i].name);
|
||||||
colDataAppend(pCol1, i, buf, false);
|
colDataAppend(pCol1, i, buf, false);
|
||||||
|
@ -92,8 +93,8 @@ static void setDescResultIntoDataBlock(SSDataBlock* pBlock, int32_t numOfRows, S
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t execDescribe(SNode* pStmt, SRetrieveTableRsp** pRsp) {
|
static int32_t execDescribe(SNode* pStmt, SRetrieveTableRsp** pRsp) {
|
||||||
SDescribeStmt* pDesc = (SDescribeStmt*) pStmt;
|
SDescribeStmt* pDesc = (SDescribeStmt*)pStmt;
|
||||||
int32_t numOfRows = TABLE_TOTAL_COL_NUM(pDesc->pMeta);
|
int32_t numOfRows = TABLE_TOTAL_COL_NUM(pDesc->pMeta);
|
||||||
|
|
||||||
SSDataBlock* pBlock = buildDescResultDataBlock();
|
SSDataBlock* pBlock = buildDescResultDataBlock();
|
||||||
setDescResultIntoDataBlock(pBlock, numOfRows, pDesc->pMeta);
|
setDescResultIntoDataBlock(pBlock, numOfRows, pDesc->pMeta);
|
||||||
|
@ -120,9 +121,15 @@ static int32_t execDescribe(SNode* pStmt, SRetrieveTableRsp** pRsp) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t execResetQueryCache() {
|
static int32_t execResetQueryCache() { return catalogClearCache(); }
|
||||||
return catalogClearCache();
|
|
||||||
}
|
static int32_t execShowCreateDatabase(SShowCreateDatabaseStmt* pStmt) { return TSDB_CODE_FAILED; }
|
||||||
|
|
||||||
|
static int32_t execShowCreateTable(SShowCreateTableStmt* pStmt) { return TSDB_CODE_FAILED; }
|
||||||
|
|
||||||
|
static int32_t execShowCreateSTable(SShowCreateTableStmt* pStmt) { return TSDB_CODE_FAILED; }
|
||||||
|
|
||||||
|
static int32_t execAlterLocal(SAlterLocalStmt* pStmt) { return TSDB_CODE_FAILED; }
|
||||||
|
|
||||||
int32_t qExecCommand(SNode* pStmt, SRetrieveTableRsp** pRsp) {
|
int32_t qExecCommand(SNode* pStmt, SRetrieveTableRsp** pRsp) {
|
||||||
switch (nodeType(pStmt)) {
|
switch (nodeType(pStmt)) {
|
||||||
|
@ -130,6 +137,14 @@ int32_t qExecCommand(SNode* pStmt, SRetrieveTableRsp** pRsp) {
|
||||||
return execDescribe(pStmt, pRsp);
|
return execDescribe(pStmt, pRsp);
|
||||||
case QUERY_NODE_RESET_QUERY_CACHE_STMT:
|
case QUERY_NODE_RESET_QUERY_CACHE_STMT:
|
||||||
return execResetQueryCache();
|
return execResetQueryCache();
|
||||||
|
case QUERY_NODE_SHOW_CREATE_DATABASE_STMT:
|
||||||
|
return execShowCreateDatabase((SShowCreateDatabaseStmt*)pStmt);
|
||||||
|
case QUERY_NODE_SHOW_CREATE_TABLE_STMT:
|
||||||
|
return execShowCreateTable((SShowCreateTableStmt*)pStmt);
|
||||||
|
case QUERY_NODE_SHOW_CREATE_STABLE_STMT:
|
||||||
|
return execShowCreateSTable((SShowCreateTableStmt*)pStmt);
|
||||||
|
case QUERY_NODE_ALTER_LOCAL_STMT:
|
||||||
|
return execAlterLocal((SAlterLocalStmt*)pStmt);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,6 +150,8 @@ SNode* nodesMakeNode(ENodeType type) {
|
||||||
return makeNode(type, sizeof(SDropTopicStmt));
|
return makeNode(type, sizeof(SDropTopicStmt));
|
||||||
case QUERY_NODE_DROP_CGROUP_STMT:
|
case QUERY_NODE_DROP_CGROUP_STMT:
|
||||||
return makeNode(type, sizeof(SDropCGroupStmt));
|
return makeNode(type, sizeof(SDropCGroupStmt));
|
||||||
|
case QUERY_NODE_ALTER_LOCAL_STMT:
|
||||||
|
return makeNode(type, sizeof(SAlterLocalStmt));
|
||||||
case QUERY_NODE_EXPLAIN_STMT:
|
case QUERY_NODE_EXPLAIN_STMT:
|
||||||
return makeNode(type, sizeof(SExplainStmt));
|
return makeNode(type, sizeof(SExplainStmt));
|
||||||
case QUERY_NODE_DESCRIBE_STMT:
|
case QUERY_NODE_DESCRIBE_STMT:
|
||||||
|
@ -206,11 +208,13 @@ SNode* nodesMakeNode(ENodeType type) {
|
||||||
case QUERY_NODE_SHOW_APPS_STMT:
|
case QUERY_NODE_SHOW_APPS_STMT:
|
||||||
case QUERY_NODE_SHOW_SCORES_STMT:
|
case QUERY_NODE_SHOW_SCORES_STMT:
|
||||||
case QUERY_NODE_SHOW_VARIABLE_STMT:
|
case QUERY_NODE_SHOW_VARIABLE_STMT:
|
||||||
case QUERY_NODE_SHOW_CREATE_DATABASE_STMT:
|
|
||||||
case QUERY_NODE_SHOW_CREATE_TABLE_STMT:
|
|
||||||
case QUERY_NODE_SHOW_CREATE_STABLE_STMT:
|
|
||||||
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
||||||
return makeNode(type, sizeof(SShowStmt));
|
return makeNode(type, sizeof(SShowStmt));
|
||||||
|
case QUERY_NODE_SHOW_CREATE_DATABASE_STMT:
|
||||||
|
return makeNode(type, sizeof(SShowCreateDatabaseStmt));
|
||||||
|
case QUERY_NODE_SHOW_CREATE_TABLE_STMT:
|
||||||
|
case QUERY_NODE_SHOW_CREATE_STABLE_STMT:
|
||||||
|
return makeNode(type, sizeof(SShowCreateTableStmt));
|
||||||
case QUERY_NODE_KILL_QUERY_STMT:
|
case QUERY_NODE_KILL_QUERY_STMT:
|
||||||
return makeNode(type, sizeof(SKillQueryStmt));
|
return makeNode(type, sizeof(SKillQueryStmt));
|
||||||
case QUERY_NODE_KILL_TRANSACTION_STMT:
|
case QUERY_NODE_KILL_TRANSACTION_STMT:
|
||||||
|
|
|
@ -59,8 +59,8 @@ typedef enum EDatabaseOptionType {
|
||||||
|
|
||||||
typedef enum ETableOptionType {
|
typedef enum ETableOptionType {
|
||||||
TABLE_OPTION_COMMENT = 1,
|
TABLE_OPTION_COMMENT = 1,
|
||||||
TABLE_OPTION_FILE_FACTOR,
|
TABLE_OPTION_MAXDELAY,
|
||||||
TABLE_OPTION_DELAY,
|
TABLE_OPTION_WATERMARK,
|
||||||
TABLE_OPTION_ROLLUP,
|
TABLE_OPTION_ROLLUP,
|
||||||
TABLE_OPTION_TTL,
|
TABLE_OPTION_TTL,
|
||||||
TABLE_OPTION_SMA
|
TABLE_OPTION_SMA
|
||||||
|
@ -152,7 +152,7 @@ SNode* createAlterTableRenameCol(SAstCreateContext* pCxt, SNode* pRealTable, int
|
||||||
SNode* createAlterTableSetTag(SAstCreateContext* pCxt, SNode* pRealTable, SToken* pTagName, SNode* pVal);
|
SNode* createAlterTableSetTag(SAstCreateContext* pCxt, SNode* pRealTable, SToken* pTagName, SNode* pVal);
|
||||||
SNode* createUseDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName);
|
SNode* createUseDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName);
|
||||||
SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pDbName, SNode* pTbNamePattern);
|
SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pDbName, SNode* pTbNamePattern);
|
||||||
SNode* createShowCreateDatabaseStmt(SAstCreateContext* pCxt, const SToken* pDbName);
|
SNode* createShowCreateDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName);
|
||||||
SNode* createShowCreateTableStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pRealTable);
|
SNode* createShowCreateTableStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pRealTable);
|
||||||
SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const SToken* pPassword);
|
SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const SToken* pPassword);
|
||||||
SNode* createAlterUserStmt(SAstCreateContext* pCxt, SToken* pUserName, int8_t alterType, const SToken* pVal);
|
SNode* createAlterUserStmt(SAstCreateContext* pCxt, SToken* pUserName, int8_t alterType, const SToken* pVal);
|
||||||
|
|
|
@ -111,7 +111,7 @@ priv_level(A) ::= db_name(B) NK_DOT NK_STAR.
|
||||||
|
|
||||||
/************************************************ create/drop/alter dnode *********************************************/
|
/************************************************ create/drop/alter dnode *********************************************/
|
||||||
cmd ::= CREATE DNODE dnode_endpoint(A). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, NULL); }
|
cmd ::= CREATE DNODE dnode_endpoint(A). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, NULL); }
|
||||||
cmd ::= CREATE DNODE dnode_host_name(A) PORT NK_INTEGER(B). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, &B); }
|
cmd ::= CREATE DNODE dnode_endpoint(A) PORT NK_INTEGER(B). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, &B); }
|
||||||
cmd ::= DROP DNODE NK_INTEGER(A). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A); }
|
cmd ::= DROP DNODE NK_INTEGER(A). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A); }
|
||||||
cmd ::= DROP DNODE dnode_endpoint(A). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A); }
|
cmd ::= DROP DNODE dnode_endpoint(A). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A); }
|
||||||
cmd ::= ALTER DNODE NK_INTEGER(A) NK_STRING(B). { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &A, &B, NULL); }
|
cmd ::= ALTER DNODE NK_INTEGER(A) NK_STRING(B). { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &A, &B, NULL); }
|
||||||
|
@ -122,11 +122,8 @@ cmd ::= ALTER ALL DNODES NK_STRING(A) NK_STRING(B).
|
||||||
%type dnode_endpoint { SToken }
|
%type dnode_endpoint { SToken }
|
||||||
%destructor dnode_endpoint { }
|
%destructor dnode_endpoint { }
|
||||||
dnode_endpoint(A) ::= NK_STRING(B). { A = B; }
|
dnode_endpoint(A) ::= NK_STRING(B). { A = B; }
|
||||||
|
dnode_endpoint(A) ::= NK_ID(B). { A = B; }
|
||||||
%type dnode_host_name { SToken }
|
dnode_endpoint(A) ::= NK_IPTOKEN(B). { A = B; }
|
||||||
%destructor dnode_host_name { }
|
|
||||||
dnode_host_name(A) ::= NK_ID(B). { A = B; }
|
|
||||||
dnode_host_name(A) ::= NK_IPTOKEN(B). { A = B; }
|
|
||||||
|
|
||||||
/************************************************ alter local *********************************************************/
|
/************************************************ alter local *********************************************************/
|
||||||
cmd ::= ALTER LOCAL NK_STRING(A). { pCxt->pRootNode = createAlterLocalStmt(pCxt, &A, NULL); }
|
cmd ::= ALTER LOCAL NK_STRING(A). { pCxt->pRootNode = createAlterLocalStmt(pCxt, &A, NULL); }
|
||||||
|
@ -317,8 +314,8 @@ tags_def(A) ::= TAGS NK_LP column_def_list(B) NK_RP.
|
||||||
|
|
||||||
table_options(A) ::= . { A = createDefaultTableOptions(pCxt); }
|
table_options(A) ::= . { A = createDefaultTableOptions(pCxt); }
|
||||||
table_options(A) ::= table_options(B) COMMENT NK_STRING(C). { A = setTableOption(pCxt, B, TABLE_OPTION_COMMENT, &C); }
|
table_options(A) ::= table_options(B) COMMENT NK_STRING(C). { A = setTableOption(pCxt, B, TABLE_OPTION_COMMENT, &C); }
|
||||||
//table_options(A) ::= table_options(B) DELAY NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_DELAY, &C); }
|
table_options(A) ::= table_options(B) MAX_DELAY duration_list(C). { A = setTableOption(pCxt, B, TABLE_OPTION_MAXDELAY, C); }
|
||||||
table_options(A) ::= table_options(B) FILE_FACTOR NK_FLOAT(C). { A = setTableOption(pCxt, B, TABLE_OPTION_FILE_FACTOR, &C); }
|
table_options(A) ::= table_options(B) WATERMARK duration_list(C). { A = setTableOption(pCxt, B, TABLE_OPTION_WATERMARK, C); }
|
||||||
table_options(A) ::= table_options(B) ROLLUP NK_LP rollup_func_list(C) NK_RP. { A = setTableOption(pCxt, B, TABLE_OPTION_ROLLUP, C); }
|
table_options(A) ::= table_options(B) ROLLUP NK_LP rollup_func_list(C) NK_RP. { A = setTableOption(pCxt, B, TABLE_OPTION_ROLLUP, C); }
|
||||||
table_options(A) ::= table_options(B) TTL NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_TTL, &C); }
|
table_options(A) ::= table_options(B) TTL NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_TTL, &C); }
|
||||||
table_options(A) ::= table_options(B) SMA NK_LP col_name_list(C) NK_RP. { A = setTableOption(pCxt, B, TABLE_OPTION_SMA, C); }
|
table_options(A) ::= table_options(B) SMA NK_LP col_name_list(C) NK_RP. { A = setTableOption(pCxt, B, TABLE_OPTION_SMA, C); }
|
||||||
|
@ -331,6 +328,11 @@ alter_table_options(A) ::= alter_table_options(B) alter_table_option(C).
|
||||||
alter_table_option(A) ::= COMMENT NK_STRING(B). { A.type = TABLE_OPTION_COMMENT; A.val = B; }
|
alter_table_option(A) ::= COMMENT NK_STRING(B). { A.type = TABLE_OPTION_COMMENT; A.val = B; }
|
||||||
alter_table_option(A) ::= TTL NK_INTEGER(B). { A.type = TABLE_OPTION_TTL; A.val = B; }
|
alter_table_option(A) ::= TTL NK_INTEGER(B). { A.type = TABLE_OPTION_TTL; A.val = B; }
|
||||||
|
|
||||||
|
%type duration_list { SNodeList* }
|
||||||
|
%destructor duration_list { nodesDestroyList($$); }
|
||||||
|
duration_list(A) ::= duration_literal(B). { A = createNodeList(pCxt, releaseRawExprNode(pCxt, B)); }
|
||||||
|
duration_list(A) ::= duration_list(B) NK_COMMA duration_literal(C). { A = addNodeToList(pCxt, B, releaseRawExprNode(pCxt, C)); }
|
||||||
|
|
||||||
%type rollup_func_list { SNodeList* }
|
%type rollup_func_list { SNodeList* }
|
||||||
%destructor rollup_func_list { nodesDestroyList($$); }
|
%destructor rollup_func_list { nodesDestroyList($$); }
|
||||||
rollup_func_list(A) ::= rollup_func_name(B). { A = createNodeList(pCxt, B); }
|
rollup_func_list(A) ::= rollup_func_name(B). { A = createNodeList(pCxt, B); }
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
#include "parAst.h"
|
#include "parAst.h"
|
||||||
#include "parUtil.h"
|
#include "parUtil.h"
|
||||||
|
#include "tglobal.h"
|
||||||
#include "ttime.h"
|
#include "ttime.h"
|
||||||
|
|
||||||
#define CHECK_OUT_OF_MEM(p) \
|
#define CHECK_OUT_OF_MEM(p) \
|
||||||
|
@ -36,6 +37,14 @@
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
#define COPY_STRING_FORM_ID_TOKEN(buf, pToken) strncpy(buf, (pToken)->z, TMIN((pToken)->n, sizeof(buf) - 1))
|
||||||
|
#define COPY_STRING_FORM_STR_TOKEN(buf, pToken) \
|
||||||
|
do { \
|
||||||
|
if ((pToken)->n > 2) { \
|
||||||
|
strncpy(buf, (pToken)->z + 1, TMIN((pToken)->n - 2, sizeof(buf) - 1)); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
SToken nil_token = {.type = TK_NK_NIL, .n = 0, .z = NULL};
|
SToken nil_token = {.type = TK_NK_NIL, .n = 0, .z = NULL};
|
||||||
|
|
||||||
void initAstCreateContext(SParseContext* pParseCxt, SAstCreateContext* pCxt) {
|
void initAstCreateContext(SParseContext* pParseCxt, SAstCreateContext* pCxt) {
|
||||||
|
@ -50,12 +59,6 @@ void initAstCreateContext(SParseContext* pParseCxt, SAstCreateContext* pCxt) {
|
||||||
pCxt->errCode = TSDB_CODE_SUCCESS;
|
pCxt->errCode = TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void copyStringFormStringToken(SToken* pToken, char* pBuf, int32_t len) {
|
|
||||||
if (pToken->n > 2) {
|
|
||||||
strncpy(pBuf, pToken->z + 1, TMIN(pToken->n - 2, len - 1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void trimEscape(SToken* pName) {
|
static void trimEscape(SToken* pName) {
|
||||||
// todo need to deal with `ioo``ii` -> ioo`ii
|
// todo need to deal with `ioo``ii` -> ioo`ii
|
||||||
if (NULL != pName && pName->n > 1 && '`' == pName->z[0]) {
|
if (NULL != pName && pName->n > 1 && '`' == pName->z[0]) {
|
||||||
|
@ -108,50 +111,52 @@ static bool checkPassword(SAstCreateContext* pCxt, const SToken* pPasswordToken,
|
||||||
return TSDB_CODE_SUCCESS == pCxt->errCode;
|
return TSDB_CODE_SUCCESS == pCxt->errCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool checkAndSplitEndpoint(SAstCreateContext* pCxt, const SToken* pEp, char* pFqdn, int32_t* pPort) {
|
static int32_t parsePort(SAstCreateContext* pCxt, const char* p, int32_t* pPort) {
|
||||||
|
*pPort = taosStr2Int32(p, NULL, 10);
|
||||||
|
if (*pPort >= UINT16_MAX || *pPort <= 0) {
|
||||||
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_PORT);
|
||||||
|
}
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t parseEndpoint(SAstCreateContext* pCxt, const SToken* pEp, char* pFqdn, int32_t* pPort) {
|
||||||
|
if (pEp->n >= (NULL == pPort ? (TSDB_FQDN_LEN + 1 + 5) : TSDB_FQDN_LEN)) { // format 'fqdn:port' or 'fqdn'
|
||||||
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NAME_OR_PASSWD_TOO_LONG);
|
||||||
|
}
|
||||||
|
|
||||||
|
char ep[TSDB_FQDN_LEN + 1 + 5] = {0};
|
||||||
|
COPY_STRING_FORM_ID_TOKEN(ep, pEp);
|
||||||
|
strdequote(ep);
|
||||||
|
strtrim(ep);
|
||||||
|
if (NULL == pPort) {
|
||||||
|
strcpy(pFqdn, ep);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
char* pColon = strchr(ep, ':');
|
||||||
|
if (NULL == pColon) {
|
||||||
|
*pPort = tsServerPort;
|
||||||
|
strcpy(pFqdn, ep);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
strncpy(pFqdn, ep, pColon - ep);
|
||||||
|
return parsePort(pCxt, pColon + 1, pPort);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool checkAndSplitEndpoint(SAstCreateContext* pCxt, const SToken* pEp, const SToken* pPortToken, char* pFqdn,
|
||||||
|
int32_t* pPort) {
|
||||||
if (NULL == pEp) {
|
if (NULL == pEp) {
|
||||||
pCxt->errCode = TSDB_CODE_PAR_SYNTAX_ERROR;
|
pCxt->errCode = TSDB_CODE_PAR_SYNTAX_ERROR;
|
||||||
} else if (pEp->n >= TSDB_FQDN_LEN + 2 + 6) { // format 'fqdn:port'
|
return false;
|
||||||
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NAME_OR_PASSWD_TOO_LONG);
|
|
||||||
} else {
|
|
||||||
char ep[TSDB_FQDN_LEN + 2 + 6];
|
|
||||||
strncpy(ep, pEp->z, pEp->n);
|
|
||||||
strdequote(ep);
|
|
||||||
strtrim(ep);
|
|
||||||
char* pColon = strchr(ep, ':');
|
|
||||||
if (NULL == pColon) {
|
|
||||||
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ENDPOINT);
|
|
||||||
} else {
|
|
||||||
strncpy(pFqdn, ep, pColon - ep);
|
|
||||||
*pPort = taosStr2Int32(pColon + 1, NULL, 10);
|
|
||||||
if (*pPort >= UINT16_MAX || *pPort <= 0) {
|
|
||||||
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_PORT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS == pCxt->errCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool checkFqdn(SAstCreateContext* pCxt, const SToken* pFqdn) {
|
if (NULL != pPortToken) {
|
||||||
if (NULL == pFqdn) {
|
pCxt->errCode = parsePort(pCxt, pPortToken->z, pPort);
|
||||||
pCxt->errCode = TSDB_CODE_PAR_SYNTAX_ERROR;
|
|
||||||
} else {
|
|
||||||
if (pFqdn->n >= TSDB_FQDN_LEN) {
|
|
||||||
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NAME_OR_PASSWD_TOO_LONG);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS == pCxt->errCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool checkPort(SAstCreateContext* pCxt, const SToken* pPortToken, int32_t* pPort) {
|
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
|
||||||
if (NULL == pPortToken) {
|
pCxt->errCode = parseEndpoint(pCxt, pEp, pFqdn, (NULL != pPortToken ? NULL : pPort));
|
||||||
pCxt->errCode = TSDB_CODE_PAR_SYNTAX_ERROR;
|
|
||||||
} else {
|
|
||||||
*pPort = taosStr2Int32(pPortToken->z, NULL, 10);
|
|
||||||
if (*pPort >= UINT16_MAX || *pPort <= 0) {
|
|
||||||
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_PORT);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS == pCxt->errCode;
|
return TSDB_CODE_SUCCESS == pCxt->errCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,9 +279,9 @@ SNode* createColumnNode(SAstCreateContext* pCxt, SToken* pTableAlias, SToken* pC
|
||||||
SColumnNode* col = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
SColumnNode* col = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||||
CHECK_OUT_OF_MEM(col);
|
CHECK_OUT_OF_MEM(col);
|
||||||
if (NULL != pTableAlias) {
|
if (NULL != pTableAlias) {
|
||||||
strncpy(col->tableAlias, pTableAlias->z, pTableAlias->n);
|
COPY_STRING_FORM_ID_TOKEN(col->tableAlias, pTableAlias);
|
||||||
}
|
}
|
||||||
strncpy(col->colName, pColumnName->z, pColumnName->n);
|
COPY_STRING_FORM_ID_TOKEN(col->colName, pColumnName);
|
||||||
return (SNode*)col;
|
return (SNode*)col;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -417,7 +422,7 @@ SNode* createFunctionNode(SAstCreateContext* pCxt, const SToken* pFuncName, SNod
|
||||||
}
|
}
|
||||||
SFunctionNode* func = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
SFunctionNode* func = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||||
CHECK_OUT_OF_MEM(func);
|
CHECK_OUT_OF_MEM(func);
|
||||||
strncpy(func->functionName, pFuncName->z, pFuncName->n);
|
COPY_STRING_FORM_ID_TOKEN(func->functionName, pFuncName);
|
||||||
func->pParameterList = pParameterList;
|
func->pParameterList = pParameterList;
|
||||||
return (SNode*)func;
|
return (SNode*)func;
|
||||||
}
|
}
|
||||||
|
@ -464,16 +469,16 @@ SNode* createRealTableNode(SAstCreateContext* pCxt, SToken* pDbName, SToken* pTa
|
||||||
SRealTableNode* realTable = (SRealTableNode*)nodesMakeNode(QUERY_NODE_REAL_TABLE);
|
SRealTableNode* realTable = (SRealTableNode*)nodesMakeNode(QUERY_NODE_REAL_TABLE);
|
||||||
CHECK_OUT_OF_MEM(realTable);
|
CHECK_OUT_OF_MEM(realTable);
|
||||||
if (NULL != pDbName) {
|
if (NULL != pDbName) {
|
||||||
strncpy(realTable->table.dbName, pDbName->z, pDbName->n);
|
COPY_STRING_FORM_ID_TOKEN(realTable->table.dbName, pDbName);
|
||||||
} else {
|
} else {
|
||||||
strcpy(realTable->table.dbName, pCxt->pQueryCxt->db);
|
strcpy(realTable->table.dbName, pCxt->pQueryCxt->db);
|
||||||
}
|
}
|
||||||
if (NULL != pTableAlias && TK_NK_NIL != pTableAlias->type) {
|
if (NULL != pTableAlias && TK_NK_NIL != pTableAlias->type) {
|
||||||
strncpy(realTable->table.tableAlias, pTableAlias->z, pTableAlias->n);
|
COPY_STRING_FORM_ID_TOKEN(realTable->table.tableAlias, pTableAlias);
|
||||||
} else {
|
} else {
|
||||||
strncpy(realTable->table.tableAlias, pTableName->z, pTableName->n);
|
COPY_STRING_FORM_ID_TOKEN(realTable->table.tableAlias, pTableName);
|
||||||
}
|
}
|
||||||
strncpy(realTable->table.tableName, pTableName->z, pTableName->n);
|
COPY_STRING_FORM_ID_TOKEN(realTable->table.tableName, pTableName);
|
||||||
return (SNode*)realTable;
|
return (SNode*)realTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -483,7 +488,7 @@ SNode* createTempTableNode(SAstCreateContext* pCxt, SNode* pSubquery, const STok
|
||||||
CHECK_OUT_OF_MEM(tempTable);
|
CHECK_OUT_OF_MEM(tempTable);
|
||||||
tempTable->pSubquery = pSubquery;
|
tempTable->pSubquery = pSubquery;
|
||||||
if (NULL != pTableAlias && TK_NK_NIL != pTableAlias->type) {
|
if (NULL != pTableAlias && TK_NK_NIL != pTableAlias->type) {
|
||||||
strncpy(tempTable->table.tableAlias, pTableAlias->z, pTableAlias->n);
|
COPY_STRING_FORM_ID_TOKEN(tempTable->table.tableAlias, pTableAlias);
|
||||||
} else {
|
} else {
|
||||||
sprintf(tempTable->table.tableAlias, "%p", tempTable);
|
sprintf(tempTable->table.tableAlias, "%p", tempTable);
|
||||||
}
|
}
|
||||||
|
@ -785,8 +790,7 @@ SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOpti
|
||||||
((SDatabaseOptions*)pOptions)->pagesize = taosStr2Int32(((SToken*)pVal)->z, NULL, 10);
|
((SDatabaseOptions*)pOptions)->pagesize = taosStr2Int32(((SToken*)pVal)->z, NULL, 10);
|
||||||
break;
|
break;
|
||||||
case DB_OPTION_PRECISION:
|
case DB_OPTION_PRECISION:
|
||||||
copyStringFormStringToken((SToken*)pVal, ((SDatabaseOptions*)pOptions)->precisionStr,
|
COPY_STRING_FORM_STR_TOKEN(((SDatabaseOptions*)pOptions)->precisionStr, (SToken*)pVal);
|
||||||
sizeof(((SDatabaseOptions*)pOptions)->precisionStr));
|
|
||||||
break;
|
break;
|
||||||
case DB_OPTION_REPLICA:
|
case DB_OPTION_REPLICA:
|
||||||
((SDatabaseOptions*)pOptions)->replica = taosStr2Int8(((SToken*)pVal)->z, NULL, 10);
|
((SDatabaseOptions*)pOptions)->replica = taosStr2Int8(((SToken*)pVal)->z, NULL, 10);
|
||||||
|
@ -835,7 +839,7 @@ SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, STok
|
||||||
}
|
}
|
||||||
SCreateDatabaseStmt* pStmt = (SCreateDatabaseStmt*)nodesMakeNode(QUERY_NODE_CREATE_DATABASE_STMT);
|
SCreateDatabaseStmt* pStmt = (SCreateDatabaseStmt*)nodesMakeNode(QUERY_NODE_CREATE_DATABASE_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
strncpy(pStmt->dbName, pDbName->z, pDbName->n);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->dbName, pDbName);
|
||||||
pStmt->ignoreExists = ignoreExists;
|
pStmt->ignoreExists = ignoreExists;
|
||||||
pStmt->pOptions = (SDatabaseOptions*)pOptions;
|
pStmt->pOptions = (SDatabaseOptions*)pOptions;
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
|
@ -848,7 +852,7 @@ SNode* createDropDatabaseStmt(SAstCreateContext* pCxt, bool ignoreNotExists, STo
|
||||||
}
|
}
|
||||||
SDropDatabaseStmt* pStmt = (SDropDatabaseStmt*)nodesMakeNode(QUERY_NODE_DROP_DATABASE_STMT);
|
SDropDatabaseStmt* pStmt = (SDropDatabaseStmt*)nodesMakeNode(QUERY_NODE_DROP_DATABASE_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
strncpy(pStmt->dbName, pDbName->z, pDbName->n);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->dbName, pDbName);
|
||||||
pStmt->ignoreNotExists = ignoreNotExists;
|
pStmt->ignoreNotExists = ignoreNotExists;
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
@ -860,7 +864,7 @@ SNode* createAlterDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName, SNode*
|
||||||
}
|
}
|
||||||
SAlterDatabaseStmt* pStmt = (SAlterDatabaseStmt*)nodesMakeNode(QUERY_NODE_ALTER_DATABASE_STMT);
|
SAlterDatabaseStmt* pStmt = (SAlterDatabaseStmt*)nodesMakeNode(QUERY_NODE_ALTER_DATABASE_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
strncpy(pStmt->dbName, pDbName->z, pDbName->n);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->dbName, pDbName);
|
||||||
pStmt->pOptions = (SDatabaseOptions*)pOptions;
|
pStmt->pOptions = (SDatabaseOptions*)pOptions;
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
@ -869,8 +873,10 @@ SNode* createDefaultTableOptions(SAstCreateContext* pCxt) {
|
||||||
CHECK_PARSER_STATUS(pCxt);
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
STableOptions* pOptions = (STableOptions*)nodesMakeNode(QUERY_NODE_TABLE_OPTIONS);
|
STableOptions* pOptions = (STableOptions*)nodesMakeNode(QUERY_NODE_TABLE_OPTIONS);
|
||||||
CHECK_OUT_OF_MEM(pOptions);
|
CHECK_OUT_OF_MEM(pOptions);
|
||||||
// pOptions->delay = TSDB_DEFAULT_ROLLUP_DELAY;
|
pOptions->maxDelay1 = -1;
|
||||||
pOptions->filesFactor = TSDB_DEFAULT_ROLLUP_FILE_FACTOR;
|
pOptions->maxDelay2 = -1;
|
||||||
|
pOptions->watermark1 = TSDB_DEFAULT_ROLLUP_WATERMARK;
|
||||||
|
pOptions->watermark2 = TSDB_DEFAULT_ROLLUP_WATERMARK;
|
||||||
pOptions->ttl = TSDB_DEFAULT_TABLE_TTL;
|
pOptions->ttl = TSDB_DEFAULT_TABLE_TTL;
|
||||||
return (SNode*)pOptions;
|
return (SNode*)pOptions;
|
||||||
}
|
}
|
||||||
|
@ -879,7 +885,6 @@ SNode* createAlterTableOptions(SAstCreateContext* pCxt) {
|
||||||
CHECK_PARSER_STATUS(pCxt);
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
STableOptions* pOptions = (STableOptions*)nodesMakeNode(QUERY_NODE_TABLE_OPTIONS);
|
STableOptions* pOptions = (STableOptions*)nodesMakeNode(QUERY_NODE_TABLE_OPTIONS);
|
||||||
CHECK_OUT_OF_MEM(pOptions);
|
CHECK_OUT_OF_MEM(pOptions);
|
||||||
pOptions->delay = -1;
|
|
||||||
pOptions->ttl = -1;
|
pOptions->ttl = -1;
|
||||||
return (SNode*)pOptions;
|
return (SNode*)pOptions;
|
||||||
}
|
}
|
||||||
|
@ -889,12 +894,14 @@ SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case TABLE_OPTION_COMMENT:
|
case TABLE_OPTION_COMMENT:
|
||||||
if (checkComment(pCxt, (SToken*)pVal, true)) {
|
if (checkComment(pCxt, (SToken*)pVal, true)) {
|
||||||
copyStringFormStringToken((SToken*)pVal, ((STableOptions*)pOptions)->comment,
|
COPY_STRING_FORM_STR_TOKEN(((STableOptions*)pOptions)->comment, (SToken*)pVal);
|
||||||
sizeof(((STableOptions*)pOptions)->comment));
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TABLE_OPTION_DELAY:
|
case TABLE_OPTION_MAXDELAY:
|
||||||
((STableOptions*)pOptions)->delay = taosStr2Int32(((SToken*)pVal)->z, NULL, 10);
|
((STableOptions*)pOptions)->pMaxDelay = pVal;
|
||||||
|
break;
|
||||||
|
case TABLE_OPTION_WATERMARK:
|
||||||
|
((STableOptions*)pOptions)->pWatermark = pVal;
|
||||||
break;
|
break;
|
||||||
case TABLE_OPTION_ROLLUP:
|
case TABLE_OPTION_ROLLUP:
|
||||||
((STableOptions*)pOptions)->pRollupFuncs = pVal;
|
((STableOptions*)pOptions)->pRollupFuncs = pVal;
|
||||||
|
@ -918,7 +925,7 @@ SNode* createColumnDefNode(SAstCreateContext* pCxt, SToken* pColName, SDataType
|
||||||
}
|
}
|
||||||
SColumnDefNode* pCol = (SColumnDefNode*)nodesMakeNode(QUERY_NODE_COLUMN_DEF);
|
SColumnDefNode* pCol = (SColumnDefNode*)nodesMakeNode(QUERY_NODE_COLUMN_DEF);
|
||||||
CHECK_OUT_OF_MEM(pCol);
|
CHECK_OUT_OF_MEM(pCol);
|
||||||
strncpy(pCol->colName, pColName->z, pColName->n);
|
COPY_STRING_FORM_ID_TOKEN(pCol->colName, pColName);
|
||||||
pCol->dataType = dataType;
|
pCol->dataType = dataType;
|
||||||
if (NULL != pComment) {
|
if (NULL != pComment) {
|
||||||
trimString(pComment->z, pComment->n, pCol->comments, sizeof(pCol->comments));
|
trimString(pComment->z, pComment->n, pCol->comments, sizeof(pCol->comments));
|
||||||
|
@ -1033,7 +1040,7 @@ SNode* createAlterTableAddModifyCol(SAstCreateContext* pCxt, SNode* pRealTable,
|
||||||
SAlterTableStmt* pStmt = (SAlterTableStmt*)nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT);
|
SAlterTableStmt* pStmt = (SAlterTableStmt*)nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
pStmt->alterType = alterType;
|
pStmt->alterType = alterType;
|
||||||
strncpy(pStmt->colName, pColName->z, pColName->n);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->colName, pColName);
|
||||||
pStmt->dataType = dataType;
|
pStmt->dataType = dataType;
|
||||||
return createAlterTableStmtFinalize(pRealTable, pStmt);
|
return createAlterTableStmtFinalize(pRealTable, pStmt);
|
||||||
}
|
}
|
||||||
|
@ -1046,7 +1053,7 @@ SNode* createAlterTableDropCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_
|
||||||
SAlterTableStmt* pStmt = (SAlterTableStmt*)nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT);
|
SAlterTableStmt* pStmt = (SAlterTableStmt*)nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
pStmt->alterType = alterType;
|
pStmt->alterType = alterType;
|
||||||
strncpy(pStmt->colName, pColName->z, pColName->n);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->colName, pColName);
|
||||||
return createAlterTableStmtFinalize(pRealTable, pStmt);
|
return createAlterTableStmtFinalize(pRealTable, pStmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1059,8 +1066,8 @@ SNode* createAlterTableRenameCol(SAstCreateContext* pCxt, SNode* pRealTable, int
|
||||||
SAlterTableStmt* pStmt = (SAlterTableStmt*)nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT);
|
SAlterTableStmt* pStmt = (SAlterTableStmt*)nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
pStmt->alterType = alterType;
|
pStmt->alterType = alterType;
|
||||||
strncpy(pStmt->colName, pOldColName->z, pOldColName->n);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->colName, pOldColName);
|
||||||
strncpy(pStmt->newColName, pNewColName->z, pNewColName->n);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->newColName, pNewColName);
|
||||||
return createAlterTableStmtFinalize(pRealTable, pStmt);
|
return createAlterTableStmtFinalize(pRealTable, pStmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1072,7 +1079,7 @@ SNode* createAlterTableSetTag(SAstCreateContext* pCxt, SNode* pRealTable, SToken
|
||||||
SAlterTableStmt* pStmt = (SAlterTableStmt*)nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT);
|
SAlterTableStmt* pStmt = (SAlterTableStmt*)nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
pStmt->alterType = TSDB_ALTER_TABLE_UPDATE_TAG_VAL;
|
pStmt->alterType = TSDB_ALTER_TABLE_UPDATE_TAG_VAL;
|
||||||
strncpy(pStmt->colName, pTagName->z, pTagName->n);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->colName, pTagName);
|
||||||
pStmt->pVal = (SValueNode*)pVal;
|
pStmt->pVal = (SValueNode*)pVal;
|
||||||
return createAlterTableStmtFinalize(pRealTable, pStmt);
|
return createAlterTableStmtFinalize(pRealTable, pStmt);
|
||||||
}
|
}
|
||||||
|
@ -1084,7 +1091,7 @@ SNode* createUseDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName) {
|
||||||
}
|
}
|
||||||
SUseDatabaseStmt* pStmt = (SUseDatabaseStmt*)nodesMakeNode(QUERY_NODE_USE_DATABASE_STMT);
|
SUseDatabaseStmt* pStmt = (SUseDatabaseStmt*)nodesMakeNode(QUERY_NODE_USE_DATABASE_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
strncpy(pStmt->dbName, pDbName->z, pDbName->n);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->dbName, pDbName);
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1107,18 +1114,24 @@ SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pDbName, S
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createShowCreateDatabaseStmt(SAstCreateContext* pCxt, const SToken* pDbName) {
|
SNode* createShowCreateDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName) {
|
||||||
CHECK_PARSER_STATUS(pCxt);
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
SNode* pStmt = nodesMakeNode(QUERY_NODE_SHOW_CREATE_DATABASE_STMT);
|
if (!checkDbName(pCxt, pDbName, true)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
SShowCreateDatabaseStmt* pStmt = (SShowCreateDatabaseStmt*)nodesMakeNode(QUERY_NODE_SHOW_CREATE_DATABASE_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
return pStmt;
|
COPY_STRING_FORM_ID_TOKEN(pStmt->dbName, pDbName);
|
||||||
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createShowCreateTableStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pRealTable) {
|
SNode* createShowCreateTableStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pRealTable) {
|
||||||
CHECK_PARSER_STATUS(pCxt);
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
SNode* pStmt = nodesMakeNode(type);
|
SShowCreateTableStmt* pStmt = (SShowCreateTableStmt*)nodesMakeNode(type);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
return pStmt;
|
strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName);
|
||||||
|
strcpy(pStmt->tableName, ((SRealTableNode*)pRealTable)->table.tableName);
|
||||||
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const SToken* pPassword) {
|
SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const SToken* pPassword) {
|
||||||
|
@ -1129,7 +1142,7 @@ SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const ST
|
||||||
}
|
}
|
||||||
SCreateUserStmt* pStmt = (SCreateUserStmt*)nodesMakeNode(QUERY_NODE_CREATE_USER_STMT);
|
SCreateUserStmt* pStmt = (SCreateUserStmt*)nodesMakeNode(QUERY_NODE_CREATE_USER_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
strncpy(pStmt->useName, pUserName->z, pUserName->n);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->useName, pUserName);
|
||||||
strcpy(pStmt->password, password);
|
strcpy(pStmt->password, password);
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
@ -1141,7 +1154,7 @@ SNode* createAlterUserStmt(SAstCreateContext* pCxt, SToken* pUserName, int8_t al
|
||||||
}
|
}
|
||||||
SAlterUserStmt* pStmt = (SAlterUserStmt*)nodesMakeNode(QUERY_NODE_ALTER_USER_STMT);
|
SAlterUserStmt* pStmt = (SAlterUserStmt*)nodesMakeNode(QUERY_NODE_ALTER_USER_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
strncpy(pStmt->useName, pUserName->z, pUserName->n);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->useName, pUserName);
|
||||||
if (TSDB_ALTER_USER_PASSWD == alterType) {
|
if (TSDB_ALTER_USER_PASSWD == alterType) {
|
||||||
char password[TSDB_USET_PASSWORD_LEN] = {0};
|
char password[TSDB_USET_PASSWORD_LEN] = {0};
|
||||||
if (!checkPassword(pCxt, pVal, password)) {
|
if (!checkPassword(pCxt, pVal, password)) {
|
||||||
|
@ -1161,29 +1174,18 @@ SNode* createDropUserStmt(SAstCreateContext* pCxt, SToken* pUserName) {
|
||||||
}
|
}
|
||||||
SDropUserStmt* pStmt = (SDropUserStmt*)nodesMakeNode(QUERY_NODE_DROP_USER_STMT);
|
SDropUserStmt* pStmt = (SDropUserStmt*)nodesMakeNode(QUERY_NODE_DROP_USER_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
strncpy(pStmt->useName, pUserName->z, pUserName->n);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->useName, pUserName);
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createCreateDnodeStmt(SAstCreateContext* pCxt, const SToken* pFqdn, const SToken* pPort) {
|
SNode* createCreateDnodeStmt(SAstCreateContext* pCxt, const SToken* pFqdn, const SToken* pPort) {
|
||||||
CHECK_PARSER_STATUS(pCxt);
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
int32_t port = 0;
|
|
||||||
char fqdn[TSDB_FQDN_LEN] = {0};
|
|
||||||
if (NULL == pPort) {
|
|
||||||
if (!checkAndSplitEndpoint(pCxt, pFqdn, fqdn, &port)) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
} else if (!checkFqdn(pCxt, pFqdn) || !checkPort(pCxt, pPort, &port)) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
SCreateDnodeStmt* pStmt = (SCreateDnodeStmt*)nodesMakeNode(QUERY_NODE_CREATE_DNODE_STMT);
|
SCreateDnodeStmt* pStmt = (SCreateDnodeStmt*)nodesMakeNode(QUERY_NODE_CREATE_DNODE_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
if (NULL == pPort) {
|
if (!checkAndSplitEndpoint(pCxt, pFqdn, pPort, pStmt->fqdn, &pStmt->port)) {
|
||||||
strcpy(pStmt->fqdn, fqdn);
|
nodesDestroyNode((SNode*)pStmt);
|
||||||
} else {
|
return NULL;
|
||||||
strncpy(pStmt->fqdn, pFqdn->z, pFqdn->n);
|
|
||||||
}
|
}
|
||||||
pStmt->port = port;
|
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1194,7 +1196,7 @@ SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode) {
|
||||||
if (TK_NK_INTEGER == pDnode->type) {
|
if (TK_NK_INTEGER == pDnode->type) {
|
||||||
pStmt->dnodeId = taosStr2Int32(pDnode->z, NULL, 10);
|
pStmt->dnodeId = taosStr2Int32(pDnode->z, NULL, 10);
|
||||||
} else {
|
} else {
|
||||||
if (!checkAndSplitEndpoint(pCxt, pDnode, pStmt->fqdn, &pStmt->port)) {
|
if (!checkAndSplitEndpoint(pCxt, pDnode, NULL, pStmt->fqdn, &pStmt->port)) {
|
||||||
nodesDestroyNode((SNode*)pStmt);
|
nodesDestroyNode((SNode*)pStmt);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1225,8 +1227,8 @@ SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool igno
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
pStmt->indexType = type;
|
pStmt->indexType = type;
|
||||||
pStmt->ignoreExists = ignoreExists;
|
pStmt->ignoreExists = ignoreExists;
|
||||||
strncpy(pStmt->indexName, pIndexName->z, pIndexName->n);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->indexName, pIndexName);
|
||||||
strncpy(pStmt->tableName, pTableName->z, pTableName->n);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->tableName, pTableName);
|
||||||
pStmt->pCols = pCols;
|
pStmt->pCols = pCols;
|
||||||
pStmt->pOptions = (SIndexOptions*)pOptions;
|
pStmt->pOptions = (SIndexOptions*)pOptions;
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
|
@ -1252,8 +1254,8 @@ SNode* createDropIndexStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken
|
||||||
SDropIndexStmt* pStmt = (SDropIndexStmt*)nodesMakeNode(QUERY_NODE_DROP_INDEX_STMT);
|
SDropIndexStmt* pStmt = (SDropIndexStmt*)nodesMakeNode(QUERY_NODE_DROP_INDEX_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
pStmt->ignoreNotExists = ignoreNotExists;
|
pStmt->ignoreNotExists = ignoreNotExists;
|
||||||
strncpy(pStmt->indexName, pIndexName->z, pIndexName->n);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->indexName, pIndexName);
|
||||||
strncpy(pStmt->tableName, pTableName->z, pTableName->n);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->tableName, pTableName);
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1278,14 +1280,14 @@ SNode* createCreateTopicStmt(SAstCreateContext* pCxt, bool ignoreExists, const S
|
||||||
CHECK_PARSER_STATUS(pCxt);
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
SCreateTopicStmt* pStmt = (SCreateTopicStmt*)nodesMakeNode(QUERY_NODE_CREATE_TOPIC_STMT);
|
SCreateTopicStmt* pStmt = (SCreateTopicStmt*)nodesMakeNode(QUERY_NODE_CREATE_TOPIC_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
strncpy(pStmt->topicName, pTopicName->z, pTopicName->n);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->topicName, pTopicName);
|
||||||
pStmt->ignoreExists = ignoreExists;
|
pStmt->ignoreExists = ignoreExists;
|
||||||
if (NULL != pRealTable) {
|
if (NULL != pRealTable) {
|
||||||
strcpy(pStmt->subDbName, ((SRealTableNode*)pRealTable)->table.dbName);
|
strcpy(pStmt->subDbName, ((SRealTableNode*)pRealTable)->table.dbName);
|
||||||
strcpy(pStmt->subSTbName, ((SRealTableNode*)pRealTable)->table.tableName);
|
strcpy(pStmt->subSTbName, ((SRealTableNode*)pRealTable)->table.tableName);
|
||||||
nodesDestroyNode(pRealTable);
|
nodesDestroyNode(pRealTable);
|
||||||
} else if (NULL != pSubDbName) {
|
} else if (NULL != pSubDbName) {
|
||||||
strncpy(pStmt->subDbName, pSubDbName->z, pSubDbName->n);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->subDbName, pSubDbName);
|
||||||
} else {
|
} else {
|
||||||
pStmt->pQuery = pQuery;
|
pStmt->pQuery = pQuery;
|
||||||
}
|
}
|
||||||
|
@ -1296,7 +1298,7 @@ SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const
|
||||||
CHECK_PARSER_STATUS(pCxt);
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
SDropTopicStmt* pStmt = (SDropTopicStmt*)nodesMakeNode(QUERY_NODE_DROP_TOPIC_STMT);
|
SDropTopicStmt* pStmt = (SDropTopicStmt*)nodesMakeNode(QUERY_NODE_DROP_TOPIC_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
strncpy(pStmt->topicName, pTopicName->z, pTopicName->n);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->topicName, pTopicName);
|
||||||
pStmt->ignoreNotExists = ignoreNotExists;
|
pStmt->ignoreNotExists = ignoreNotExists;
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
@ -1307,8 +1309,8 @@ SNode* createDropCGroupStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const
|
||||||
SDropCGroupStmt* pStmt = (SDropCGroupStmt*)nodesMakeNode(QUERY_NODE_DROP_CGROUP_STMT);
|
SDropCGroupStmt* pStmt = (SDropCGroupStmt*)nodesMakeNode(QUERY_NODE_DROP_CGROUP_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
pStmt->ignoreNotExists = ignoreNotExists;
|
pStmt->ignoreNotExists = ignoreNotExists;
|
||||||
strncpy(pStmt->topicName, pTopicName->z, pTopicName->n);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->topicName, pTopicName);
|
||||||
strncpy(pStmt->cgroup, pCGroupId->z, pCGroupId->n);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->cgroup, pCGroupId);
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1388,9 +1390,9 @@ SNode* createCreateFunctionStmt(SAstCreateContext* pCxt, bool ignoreExists, bool
|
||||||
SCreateFunctionStmt* pStmt = (SCreateFunctionStmt*)nodesMakeNode(QUERY_NODE_CREATE_FUNCTION_STMT);
|
SCreateFunctionStmt* pStmt = (SCreateFunctionStmt*)nodesMakeNode(QUERY_NODE_CREATE_FUNCTION_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
pStmt->ignoreExists = ignoreExists;
|
pStmt->ignoreExists = ignoreExists;
|
||||||
strncpy(pStmt->funcName, pFuncName->z, pFuncName->n);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->funcName, pFuncName);
|
||||||
pStmt->isAgg = aggFunc;
|
pStmt->isAgg = aggFunc;
|
||||||
strncpy(pStmt->libraryPath, pLibPath->z + 1, pLibPath->n - 2);
|
COPY_STRING_FORM_STR_TOKEN(pStmt->libraryPath, pLibPath);
|
||||||
pStmt->outputDt = dataType;
|
pStmt->outputDt = dataType;
|
||||||
pStmt->bufSize = bufSize;
|
pStmt->bufSize = bufSize;
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
|
@ -1401,7 +1403,7 @@ SNode* createDropFunctionStmt(SAstCreateContext* pCxt, bool ignoreNotExists, con
|
||||||
SDropFunctionStmt* pStmt = (SDropFunctionStmt*)nodesMakeNode(QUERY_NODE_DROP_FUNCTION_STMT);
|
SDropFunctionStmt* pStmt = (SDropFunctionStmt*)nodesMakeNode(QUERY_NODE_DROP_FUNCTION_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
pStmt->ignoreNotExists = ignoreNotExists;
|
pStmt->ignoreNotExists = ignoreNotExists;
|
||||||
strncpy(pStmt->funcName, pFuncName->z, pFuncName->n);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->funcName, pFuncName);
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1418,7 +1420,7 @@ SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, const
|
||||||
CHECK_PARSER_STATUS(pCxt);
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
SCreateStreamStmt* pStmt = (SCreateStreamStmt*)nodesMakeNode(QUERY_NODE_CREATE_STREAM_STMT);
|
SCreateStreamStmt* pStmt = (SCreateStreamStmt*)nodesMakeNode(QUERY_NODE_CREATE_STREAM_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
strncpy(pStmt->streamName, pStreamName->z, pStreamName->n);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->streamName, pStreamName);
|
||||||
if (NULL != pRealTable) {
|
if (NULL != pRealTable) {
|
||||||
strcpy(pStmt->targetDbName, ((SRealTableNode*)pRealTable)->table.dbName);
|
strcpy(pStmt->targetDbName, ((SRealTableNode*)pRealTable)->table.dbName);
|
||||||
strcpy(pStmt->targetTabName, ((SRealTableNode*)pRealTable)->table.tableName);
|
strcpy(pStmt->targetTabName, ((SRealTableNode*)pRealTable)->table.tableName);
|
||||||
|
@ -1434,7 +1436,7 @@ SNode* createDropStreamStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const
|
||||||
CHECK_PARSER_STATUS(pCxt);
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
SDropStreamStmt* pStmt = (SDropStreamStmt*)nodesMakeNode(QUERY_NODE_DROP_STREAM_STMT);
|
SDropStreamStmt* pStmt = (SDropStreamStmt*)nodesMakeNode(QUERY_NODE_DROP_STREAM_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
strncpy(pStmt->streamName, pStreamName->z, TMIN(pStreamName->n, sizeof(pStmt->streamName) - 1));
|
COPY_STRING_FORM_ID_TOKEN(pStmt->streamName, pStreamName);
|
||||||
pStmt->ignoreNotExists = ignoreNotExists;
|
pStmt->ignoreNotExists = ignoreNotExists;
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
@ -1503,8 +1505,8 @@ SNode* createGrantStmt(SAstCreateContext* pCxt, int64_t privileges, SToken* pDbN
|
||||||
SGrantStmt* pStmt = (SGrantStmt*)nodesMakeNode(QUERY_NODE_GRANT_STMT);
|
SGrantStmt* pStmt = (SGrantStmt*)nodesMakeNode(QUERY_NODE_GRANT_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
pStmt->privileges = privileges;
|
pStmt->privileges = privileges;
|
||||||
strncpy(pStmt->dbName, pDbName->z, pDbName->n);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->dbName, pDbName);
|
||||||
strncpy(pStmt->userName, pUserName->z, pUserName->n);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->userName, pUserName);
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1516,8 +1518,8 @@ SNode* createRevokeStmt(SAstCreateContext* pCxt, int64_t privileges, SToken* pDb
|
||||||
SRevokeStmt* pStmt = (SRevokeStmt*)nodesMakeNode(QUERY_NODE_REVOKE_STMT);
|
SRevokeStmt* pStmt = (SRevokeStmt*)nodesMakeNode(QUERY_NODE_REVOKE_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
pStmt->privileges = privileges;
|
pStmt->privileges = privileges;
|
||||||
strncpy(pStmt->dbName, pDbName->z, pDbName->n);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->dbName, pDbName);
|
||||||
strncpy(pStmt->userName, pUserName->z, pUserName->n);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->userName, pUserName);
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -397,6 +397,14 @@ static int32_t collectMetaKeyFromShowVariables(SCollectMetaKeyCxt* pCxt, SShowSt
|
||||||
pCxt->pMetaCache);
|
pCxt->pMetaCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t collectMetaKeyFromShowCreateDatabase(SCollectMetaKeyCxt* pCxt, SShowCreateDatabaseStmt* pStmt) {
|
||||||
|
return reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t collectMetaKeyFromShowCreateTable(SCollectMetaKeyCxt* pCxt, SShowCreateTableStmt* pStmt) {
|
||||||
|
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache);
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t collectMetaKeyFromShowApps(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
static int32_t collectMetaKeyFromShowApps(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
||||||
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_APPS,
|
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_APPS,
|
||||||
pCxt->pMetaCache);
|
pCxt->pMetaCache);
|
||||||
|
@ -478,6 +486,11 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
|
||||||
return collectMetaKeyFromShowQueries(pCxt, (SShowStmt*)pStmt);
|
return collectMetaKeyFromShowQueries(pCxt, (SShowStmt*)pStmt);
|
||||||
case QUERY_NODE_SHOW_VARIABLE_STMT:
|
case QUERY_NODE_SHOW_VARIABLE_STMT:
|
||||||
return collectMetaKeyFromShowVariables(pCxt, (SShowStmt*)pStmt);
|
return collectMetaKeyFromShowVariables(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_APPS_STMT:
|
case QUERY_NODE_SHOW_APPS_STMT:
|
||||||
return collectMetaKeyFromShowApps(pCxt, (SShowStmt*)pStmt);
|
return collectMetaKeyFromShowApps(pCxt, (SShowStmt*)pStmt);
|
||||||
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
||||||
|
|
|
@ -81,7 +81,7 @@ static SKeyword keywordTable[] = {
|
||||||
{"DURATION", TK_DURATION},
|
{"DURATION", TK_DURATION},
|
||||||
{"EXISTS", TK_EXISTS},
|
{"EXISTS", TK_EXISTS},
|
||||||
{"EXPLAIN", TK_EXPLAIN},
|
{"EXPLAIN", TK_EXPLAIN},
|
||||||
{"FILE_FACTOR", TK_FILE_FACTOR},
|
// {"FILE_FACTOR", TK_FILE_FACTOR},
|
||||||
{"FILL", TK_FILL},
|
{"FILL", TK_FILL},
|
||||||
{"FIRST", TK_FIRST},
|
{"FIRST", TK_FIRST},
|
||||||
{"FLOAT", TK_FLOAT},
|
{"FLOAT", TK_FLOAT},
|
||||||
|
|
|
@ -2625,7 +2625,7 @@ static int32_t checkDbDaysOption(STranslateContext* pCxt, SDatabaseOptions* pOpt
|
||||||
if (TIME_UNIT_MINUTE != pOptions->pDaysPerFile->unit && TIME_UNIT_HOUR != pOptions->pDaysPerFile->unit &&
|
if (TIME_UNIT_MINUTE != pOptions->pDaysPerFile->unit && TIME_UNIT_HOUR != pOptions->pDaysPerFile->unit &&
|
||||||
TIME_UNIT_DAY != pOptions->pDaysPerFile->unit) {
|
TIME_UNIT_DAY != pOptions->pDaysPerFile->unit) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_OPTION_UNIT, "daysPerFile",
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_OPTION_UNIT, "daysPerFile",
|
||||||
pOptions->pDaysPerFile->unit);
|
pOptions->pDaysPerFile->unit, TIME_UNIT_MINUTE, TIME_UNIT_HOUR, TIME_UNIT_DAY);
|
||||||
}
|
}
|
||||||
pOptions->daysPerFile = getBigintFromValueNode(pOptions->pDaysPerFile);
|
pOptions->daysPerFile = getBigintFromValueNode(pOptions->pDaysPerFile);
|
||||||
}
|
}
|
||||||
|
@ -2927,14 +2927,6 @@ static SColumnDefNode* findColDef(SNodeList* pCols, const SColumnNode* pCol) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t checTableFactorOption(STranslateContext* pCxt, float val) {
|
|
||||||
if (val < TSDB_MIN_ROLLUP_FILE_FACTOR || val > TSDB_MAX_ROLLUP_FILE_FACTOR) {
|
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_F_RANGE_OPTION, "file_factor", val,
|
|
||||||
TSDB_MIN_ROLLUP_FILE_FACTOR, TSDB_MAX_ROLLUP_FILE_FACTOR);
|
|
||||||
}
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t checkTableSmaOption(STranslateContext* pCxt, SCreateTableStmt* pStmt) {
|
static int32_t checkTableSmaOption(STranslateContext* pCxt, SCreateTableStmt* pStmt) {
|
||||||
if (NULL != pStmt->pOptions->pSma) {
|
if (NULL != pStmt->pOptions->pSma) {
|
||||||
SNode* pNode = NULL;
|
SNode* pNode = NULL;
|
||||||
|
@ -3084,27 +3076,74 @@ static int32_t checkTableSchema(STranslateContext* pCxt, SCreateTableStmt* pStmt
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t checkSchemalessDb(STranslateContext* pCxt, const char* pDbName) {
|
static int32_t getTableDelayOrWatermarkOption(STranslateContext* pCxt, const char* pName, int64_t minVal,
|
||||||
// if (0 != pCxt->pParseCxt->schemalessType) {
|
int64_t maxVal, SValueNode* pVal, int64_t* pMaxDelay) {
|
||||||
// return TSDB_CODE_SUCCESS;
|
int32_t code = (DEAL_RES_ERROR == translateValue(pCxt, pVal) ? pCxt->errCode : TSDB_CODE_SUCCESS);
|
||||||
// }
|
if (TSDB_CODE_SUCCESS == code && TIME_UNIT_MILLISECOND != pVal->unit && TIME_UNIT_SECOND != pVal->unit &&
|
||||||
// SDbCfgInfo info = {0};
|
TIME_UNIT_MINUTE != pVal->unit) {
|
||||||
// int32_t code = getDBCfg(pCxt, pDbName, &info);
|
code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_OPTION_UNIT, pName, pVal->unit,
|
||||||
// if (TSDB_CODE_SUCCESS == code) {
|
TIME_UNIT_MILLISECOND, TIME_UNIT_SECOND, TIME_UNIT_MINUTE);
|
||||||
// code = info.schemaless ? TSDB_CODE_SML_INVALID_DB_CONF : TSDB_CODE_SUCCESS;
|
}
|
||||||
// }
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
// return code;
|
code = checkRangeOption(pCxt, pName, pVal->datum.i, minVal, maxVal);
|
||||||
return TSDB_CODE_SUCCESS;
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
*pMaxDelay = pVal->datum.i;
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t getTableMaxDelayOption(STranslateContext* pCxt, SValueNode* pVal, int64_t* pMaxDelay) {
|
||||||
|
return getTableDelayOrWatermarkOption(pCxt, "maxDelay", TSDB_MIN_ROLLUP_MAX_DELAY, TSDB_MAX_ROLLUP_MAX_DELAY, pVal,
|
||||||
|
pMaxDelay);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t checkTableMaxDelayOption(STranslateContext* pCxt, STableOptions* pOptions) {
|
||||||
|
if (NULL == pOptions->pMaxDelay) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (LIST_LENGTH(pOptions->pMaxDelay) > 2) {
|
||||||
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TABLE_OPTION, "maxdelay");
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t code =
|
||||||
|
getTableMaxDelayOption(pCxt, (SValueNode*)nodesListGetNode(pOptions->pMaxDelay, 0), &pOptions->maxDelay1);
|
||||||
|
if (TSDB_CODE_SUCCESS == code && 2 == LIST_LENGTH(pOptions->pMaxDelay)) {
|
||||||
|
code = getTableMaxDelayOption(pCxt, (SValueNode*)nodesListGetNode(pOptions->pMaxDelay, 1), &pOptions->maxDelay2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t getTableWatermarkOption(STranslateContext* pCxt, SValueNode* pVal, int64_t* pMaxDelay) {
|
||||||
|
return getTableDelayOrWatermarkOption(pCxt, "watermark", TSDB_MIN_ROLLUP_WATERMARK, TSDB_MAX_ROLLUP_WATERMARK, pVal,
|
||||||
|
pMaxDelay);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t checkTableWatermarkOption(STranslateContext* pCxt, STableOptions* pOptions) {
|
||||||
|
if (NULL == pOptions->pWatermark) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (LIST_LENGTH(pOptions->pWatermark) > 2) {
|
||||||
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TABLE_OPTION, "watermark");
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t code =
|
||||||
|
getTableWatermarkOption(pCxt, (SValueNode*)nodesListGetNode(pOptions->pWatermark, 0), &pOptions->watermark1);
|
||||||
|
if (TSDB_CODE_SUCCESS == code && 2 == LIST_LENGTH(pOptions->pWatermark)) {
|
||||||
|
code = getTableWatermarkOption(pCxt, (SValueNode*)nodesListGetNode(pOptions->pWatermark, 1), &pOptions->watermark2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t checkCreateTable(STranslateContext* pCxt, SCreateTableStmt* pStmt) {
|
static int32_t checkCreateTable(STranslateContext* pCxt, SCreateTableStmt* pStmt) {
|
||||||
int32_t code = checkSchemalessDb(pCxt, pStmt->dbName);
|
int32_t code = checkTableMaxDelayOption(pCxt, pStmt->pOptions);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = checTableFactorOption(pCxt, pStmt->pOptions->filesFactor);
|
code = checkTableWatermarkOption(pCxt, pStmt->pOptions);
|
||||||
}
|
}
|
||||||
// if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
// code = checkRangeOption(pCxt, "delay", pStmt->pOptions->delay, TSDB_MIN_ROLLUP_DELAY, TSDB_MAX_ROLLUP_DELAY);
|
|
||||||
// }
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = checkTableRollupOption(pCxt, pStmt->pOptions->pRollupFuncs);
|
code = checkTableRollupOption(pCxt, pStmt->pOptions->pRollupFuncs);
|
||||||
}
|
}
|
||||||
|
@ -3347,8 +3386,10 @@ static int32_t buildRollupAst(STranslateContext* pCxt, SCreateTableStmt* pStmt,
|
||||||
|
|
||||||
static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStmt, SMCreateStbReq* pReq) {
|
static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStmt, SMCreateStbReq* pReq) {
|
||||||
pReq->igExists = pStmt->ignoreExists;
|
pReq->igExists = pStmt->ignoreExists;
|
||||||
// pReq->delay = pStmt->pOptions->delay;
|
pReq->delay1 = pStmt->pOptions->maxDelay1;
|
||||||
pReq->xFilesFactor = pStmt->pOptions->filesFactor;
|
pReq->delay2 = pStmt->pOptions->maxDelay2;
|
||||||
|
pReq->watermark1 = pStmt->pOptions->watermark1;
|
||||||
|
pReq->watermark2 = pStmt->pOptions->watermark2;
|
||||||
pReq->ttl = pStmt->pOptions->ttl;
|
pReq->ttl = pStmt->pOptions->ttl;
|
||||||
columnDefNodeToField(pStmt->pCols, &pReq->pColumns);
|
columnDefNodeToField(pStmt->pCols, &pReq->pColumns);
|
||||||
columnDefNodeToField(pStmt->pTags, &pReq->pTags);
|
columnDefNodeToField(pStmt->pTags, &pReq->pTags);
|
||||||
|
@ -3573,27 +3614,6 @@ static int32_t translateAlterDnode(STranslateContext* pCxt, SAlterDnodeStmt* pSt
|
||||||
return buildCmdMsg(pCxt, TDMT_MND_CONFIG_DNODE, (FSerializeFunc)tSerializeSMCfgDnodeReq, &cfgReq);
|
return buildCmdMsg(pCxt, TDMT_MND_CONFIG_DNODE, (FSerializeFunc)tSerializeSMCfgDnodeReq, &cfgReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t nodeTypeToShowType(ENodeType nt) {
|
|
||||||
switch (nt) {
|
|
||||||
case QUERY_NODE_SHOW_CONNECTIONS_STMT:
|
|
||||||
return TSDB_MGMT_TABLE_CONNS;
|
|
||||||
case QUERY_NODE_SHOW_LICENCE_STMT:
|
|
||||||
return TSDB_MGMT_TABLE_GRANTS;
|
|
||||||
case QUERY_NODE_SHOW_QUERIES_STMT:
|
|
||||||
return TSDB_MGMT_TABLE_QUERIES;
|
|
||||||
case QUERY_NODE_SHOW_VARIABLE_STMT:
|
|
||||||
return TSDB_MGMT_TABLE_CONFIGS;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t translateShow(STranslateContext* pCxt, SShowStmt* pStmt) {
|
|
||||||
SShowReq showReq = {.type = nodeTypeToShowType(nodeType(pStmt))};
|
|
||||||
return buildCmdMsg(pCxt, TDMT_MND_SHOW, (FSerializeFunc)tSerializeSShowReq, &showReq);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t getSmaIndexDstVgId(STranslateContext* pCxt, char* pTableName, int32_t* pVgId) {
|
static int32_t getSmaIndexDstVgId(STranslateContext* pCxt, char* pTableName, int32_t* pVgId) {
|
||||||
SVgroupInfo vg = {0};
|
SVgroupInfo vg = {0};
|
||||||
int32_t code = getTableHashVgroup(pCxt, pCxt->pParseCxt->db, pTableName, &vg);
|
int32_t code = getTableHashVgroup(pCxt, pCxt->pParseCxt->db, pTableName, &vg);
|
||||||
|
@ -4139,6 +4159,18 @@ static int32_t translateSplitVgroup(STranslateContext* pCxt, SSplitVgroupStmt* p
|
||||||
return buildCmdMsg(pCxt, TDMT_MND_SPLIT_VGROUP, (FSerializeFunc)tSerializeSSplitVgroupReq, &req);
|
return buildCmdMsg(pCxt, TDMT_MND_SPLIT_VGROUP, (FSerializeFunc)tSerializeSSplitVgroupReq, &req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t translateShowCreateDatabase(STranslateContext* pCxt, SShowCreateDatabaseStmt* pStmt) {
|
||||||
|
pStmt->pCfg = taosMemoryCalloc(1, sizeof(SDbCfgInfo));
|
||||||
|
if (NULL == pStmt->pCfg) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
return getDBCfg(pCxt, pStmt->dbName, (SDbCfgInfo*)pStmt->pCfg);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t translateShowCreateTable(STranslateContext* pCxt, SShowCreateTableStmt* pStmt) {
|
||||||
|
return getTableMeta(pCxt, pStmt->dbName, pStmt->tableName, &pStmt->pMeta);
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
|
static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
switch (nodeType(pNode)) {
|
switch (nodeType(pNode)) {
|
||||||
|
@ -4193,12 +4225,6 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
|
||||||
case QUERY_NODE_ALTER_DNODE_STMT:
|
case QUERY_NODE_ALTER_DNODE_STMT:
|
||||||
code = translateAlterDnode(pCxt, (SAlterDnodeStmt*)pNode);
|
code = translateAlterDnode(pCxt, (SAlterDnodeStmt*)pNode);
|
||||||
break;
|
break;
|
||||||
case QUERY_NODE_SHOW_CONNECTIONS_STMT:
|
|
||||||
case QUERY_NODE_SHOW_QUERIES_STMT:
|
|
||||||
case QUERY_NODE_SHOW_TOPICS_STMT:
|
|
||||||
case QUERY_NODE_SHOW_VARIABLE_STMT:
|
|
||||||
code = translateShow(pCxt, (SShowStmt*)pNode);
|
|
||||||
break;
|
|
||||||
case QUERY_NODE_CREATE_INDEX_STMT:
|
case QUERY_NODE_CREATE_INDEX_STMT:
|
||||||
code = translateCreateIndex(pCxt, (SCreateIndexStmt*)pNode);
|
code = translateCreateIndex(pCxt, (SCreateIndexStmt*)pNode);
|
||||||
break;
|
break;
|
||||||
|
@ -4274,6 +4300,13 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
|
||||||
case QUERY_NODE_SPLIT_VGROUP_STMT:
|
case QUERY_NODE_SPLIT_VGROUP_STMT:
|
||||||
code = translateSplitVgroup(pCxt, (SSplitVgroupStmt*)pNode);
|
code = translateSplitVgroup(pCxt, (SSplitVgroupStmt*)pNode);
|
||||||
break;
|
break;
|
||||||
|
case QUERY_NODE_SHOW_CREATE_DATABASE_STMT:
|
||||||
|
code = translateShowCreateDatabase(pCxt, (SShowCreateDatabaseStmt*)pNode);
|
||||||
|
break;
|
||||||
|
case QUERY_NODE_SHOW_CREATE_TABLE_STMT:
|
||||||
|
case QUERY_NODE_SHOW_CREATE_STABLE_STMT:
|
||||||
|
code = translateShowCreateTable(pCxt, (SShowCreateTableStmt*)pNode);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -4356,6 +4389,42 @@ static int32_t extractDescribeResultSchema(int32_t* numOfCols, SSchema** pSchema
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t extractShowCreateDatabaseResultSchema(int32_t* numOfCols, SSchema** pSchema) {
|
||||||
|
*numOfCols = 2;
|
||||||
|
*pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema));
|
||||||
|
if (NULL == (*pSchema)) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
(*pSchema)[0].type = TSDB_DATA_TYPE_BINARY;
|
||||||
|
(*pSchema)[0].bytes = TSDB_DB_NAME_LEN;
|
||||||
|
strcpy((*pSchema)[0].name, "Database");
|
||||||
|
|
||||||
|
(*pSchema)[1].type = TSDB_DATA_TYPE_BINARY;
|
||||||
|
(*pSchema)[1].bytes = TSDB_MAX_BINARY_LEN;
|
||||||
|
strcpy((*pSchema)[1].name, "Create Database");
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t extractShowCreateTableResultSchema(int32_t* numOfCols, SSchema** pSchema) {
|
||||||
|
*numOfCols = 2;
|
||||||
|
*pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema));
|
||||||
|
if (NULL == (*pSchema)) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
(*pSchema)[0].type = TSDB_DATA_TYPE_BINARY;
|
||||||
|
(*pSchema)[0].bytes = TSDB_TABLE_NAME_LEN;
|
||||||
|
strcpy((*pSchema)[0].name, "Table");
|
||||||
|
|
||||||
|
(*pSchema)[1].type = TSDB_DATA_TYPE_BINARY;
|
||||||
|
(*pSchema)[1].bytes = TSDB_MAX_BINARY_LEN;
|
||||||
|
strcpy((*pSchema)[1].name, "Create Table");
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t extractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pSchema) {
|
int32_t extractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pSchema) {
|
||||||
if (NULL == pRoot) {
|
if (NULL == pRoot) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -4369,6 +4438,11 @@ int32_t extractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pS
|
||||||
return extractExplainResultSchema(numOfCols, pSchema);
|
return extractExplainResultSchema(numOfCols, pSchema);
|
||||||
case QUERY_NODE_DESCRIBE_STMT:
|
case QUERY_NODE_DESCRIBE_STMT:
|
||||||
return extractDescribeResultSchema(numOfCols, pSchema);
|
return extractDescribeResultSchema(numOfCols, pSchema);
|
||||||
|
case QUERY_NODE_SHOW_CREATE_DATABASE_STMT:
|
||||||
|
return extractShowCreateDatabaseResultSchema(numOfCols, pSchema);
|
||||||
|
case QUERY_NODE_SHOW_CREATE_TABLE_STMT:
|
||||||
|
case QUERY_NODE_SHOW_CREATE_STABLE_STMT:
|
||||||
|
return extractShowCreateTableResultSchema(numOfCols, pSchema);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -5016,10 +5090,7 @@ static int32_t rewriteCreateMultiTable(STranslateContext* pCxt, SQuery* pQuery)
|
||||||
SNode* pNode;
|
SNode* pNode;
|
||||||
FOREACH(pNode, pStmt->pSubTables) {
|
FOREACH(pNode, pStmt->pSubTables) {
|
||||||
SCreateSubTableClause* pClause = (SCreateSubTableClause*)pNode;
|
SCreateSubTableClause* pClause = (SCreateSubTableClause*)pNode;
|
||||||
code = checkSchemalessDb(pCxt, pClause->dbName);
|
code = rewriteCreateSubTable(pCxt, pClause, pVgroupHashmap);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = rewriteCreateSubTable(pCxt, pClause, pVgroupHashmap);
|
|
||||||
}
|
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
taosHashCleanup(pVgroupHashmap);
|
taosHashCleanup(pVgroupHashmap);
|
||||||
return code;
|
return code;
|
||||||
|
@ -5592,10 +5663,14 @@ static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) {
|
||||||
pQuery->msgType = toMsgType(((SVnodeModifOpStmt*)pQuery->pRoot)->sqlNodeType);
|
pQuery->msgType = toMsgType(((SVnodeModifOpStmt*)pQuery->pRoot)->sqlNodeType);
|
||||||
break;
|
break;
|
||||||
case QUERY_NODE_DESCRIBE_STMT:
|
case QUERY_NODE_DESCRIBE_STMT:
|
||||||
|
case QUERY_NODE_SHOW_CREATE_DATABASE_STMT:
|
||||||
|
case QUERY_NODE_SHOW_CREATE_TABLE_STMT:
|
||||||
|
case QUERY_NODE_SHOW_CREATE_STABLE_STMT:
|
||||||
pQuery->execMode = QUERY_EXEC_MODE_LOCAL;
|
pQuery->execMode = QUERY_EXEC_MODE_LOCAL;
|
||||||
pQuery->haveResultSet = true;
|
pQuery->haveResultSet = true;
|
||||||
break;
|
break;
|
||||||
case QUERY_NODE_RESET_QUERY_CACHE_STMT:
|
case QUERY_NODE_RESET_QUERY_CACHE_STMT:
|
||||||
|
case QUERY_NODE_ALTER_LOCAL_STMT:
|
||||||
pQuery->execMode = QUERY_EXEC_MODE_LOCAL;
|
pQuery->execMode = QUERY_EXEC_MODE_LOCAL;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -90,7 +90,7 @@ static char* getSyntaxErrFormat(int32_t errCode) {
|
||||||
case TSDB_CODE_PAR_GROUPBY_WINDOW_COEXIST:
|
case TSDB_CODE_PAR_GROUPBY_WINDOW_COEXIST:
|
||||||
return "GROUP BY and WINDOW-clause can't be used together";
|
return "GROUP BY and WINDOW-clause can't be used together";
|
||||||
case TSDB_CODE_PAR_INVALID_OPTION_UNIT:
|
case TSDB_CODE_PAR_INVALID_OPTION_UNIT:
|
||||||
return "Invalid option %s unit: %c, only m, h, d allowed";
|
return "Invalid option %s unit: %c, only %c, %c, %c allowed";
|
||||||
case TSDB_CODE_PAR_INVALID_KEEP_UNIT:
|
case TSDB_CODE_PAR_INVALID_KEEP_UNIT:
|
||||||
return "Invalid option keep unit: %c, only m, h, d allowed";
|
return "Invalid option keep unit: %c, only m, h, d allowed";
|
||||||
case TSDB_CODE_PAR_AGG_FUNC_NESTING:
|
case TSDB_CODE_PAR_AGG_FUNC_NESTING:
|
||||||
|
@ -194,6 +194,8 @@ static char* getSyntaxErrFormat(int32_t errCode) {
|
||||||
return "%s function does not supportted in stream query";
|
return "%s function does not supportted in stream query";
|
||||||
case TSDB_CODE_PAR_GROUP_BY_NOT_ALLOWED_FUNC:
|
case TSDB_CODE_PAR_GROUP_BY_NOT_ALLOWED_FUNC:
|
||||||
return "%s function does not supportted in group query";
|
return "%s function does not supportted in group query";
|
||||||
|
case TSDB_CODE_PAR_INVALID_TABLE_OPTION:
|
||||||
|
return "Invalid option %s";
|
||||||
case TSDB_CODE_OUT_OF_MEMORY:
|
case TSDB_CODE_OUT_OF_MEMORY:
|
||||||
return "Out of memory";
|
return "Out of memory";
|
||||||
default:
|
default:
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -43,7 +43,40 @@ TEST_F(ParserInitialATest, alterDatabase) {
|
||||||
run("ALTER DATABASE wxy_db KEEP 2400");
|
run("ALTER DATABASE wxy_db KEEP 2400");
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo ALTER local
|
TEST_F(ParserInitialATest, alterLocal) {
|
||||||
|
useDb("root", "test");
|
||||||
|
|
||||||
|
pair<string, string> expect;
|
||||||
|
|
||||||
|
auto clearAlterLocal = [&]() {
|
||||||
|
expect.first.clear();
|
||||||
|
expect.second.clear();
|
||||||
|
};
|
||||||
|
|
||||||
|
auto setAlterLocalFunc = [&](const char* pConfig, const char* pValue = nullptr) {
|
||||||
|
expect.first.assign(pConfig);
|
||||||
|
if (nullptr != pValue) {
|
||||||
|
expect.second.assign(pValue);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) {
|
||||||
|
ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_ALTER_LOCAL_STMT);
|
||||||
|
ASSERT_EQ(pQuery->execMode, QUERY_EXEC_MODE_LOCAL);
|
||||||
|
SAlterLocalStmt* pStmt = (SAlterLocalStmt*)pQuery->pRoot;
|
||||||
|
ASSERT_EQ(string(pStmt->config), expect.first);
|
||||||
|
ASSERT_EQ(string(pStmt->value), expect.second);
|
||||||
|
});
|
||||||
|
|
||||||
|
setAlterLocalFunc("resetlog");
|
||||||
|
run("ALTER LOCAL 'resetlog'");
|
||||||
|
clearAlterLocal();
|
||||||
|
|
||||||
|
setAlterLocalFunc("querypolicy", "2");
|
||||||
|
run("ALTER LOCAL 'querypolicy' '2'");
|
||||||
|
clearAlterLocal();
|
||||||
|
}
|
||||||
|
|
||||||
// todo ALTER stable
|
// todo ALTER stable
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "parTestUtil.h"
|
#include "parTestUtil.h"
|
||||||
#include "ttime.h"
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -242,9 +241,47 @@ TEST_F(ParserInitialCTest, createDatabaseSemanticCheck) {
|
||||||
TEST_F(ParserInitialCTest, createDnode) {
|
TEST_F(ParserInitialCTest, createDnode) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("CREATE DNODE abc1 PORT 7000");
|
SCreateDnodeReq expect = {0};
|
||||||
|
|
||||||
run("CREATE DNODE 1.1.1.1 PORT 9000");
|
auto clearCreateDnodeReq = [&]() { memset(&expect, 0, sizeof(SCreateDnodeReq)); };
|
||||||
|
|
||||||
|
auto setCreateDnodeReqFunc = [&](const char* pFqdn, int32_t port = tsServerPort) {
|
||||||
|
strcpy(expect.fqdn, pFqdn);
|
||||||
|
expect.port = port;
|
||||||
|
};
|
||||||
|
|
||||||
|
setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) {
|
||||||
|
ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_CREATE_DNODE_STMT);
|
||||||
|
SCreateDnodeReq req = {0};
|
||||||
|
ASSERT_TRUE(TSDB_CODE_SUCCESS == tDeserializeSCreateDnodeReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req));
|
||||||
|
|
||||||
|
ASSERT_EQ(std::string(req.fqdn), std::string(expect.fqdn));
|
||||||
|
ASSERT_EQ(req.port, expect.port);
|
||||||
|
});
|
||||||
|
|
||||||
|
setCreateDnodeReqFunc("abc1", 7030);
|
||||||
|
run("CREATE DNODE 'abc1' PORT 7030");
|
||||||
|
clearCreateDnodeReq();
|
||||||
|
|
||||||
|
setCreateDnodeReqFunc("1.1.1.1", 8030);
|
||||||
|
run("CREATE DNODE 1.1.1.1 PORT 8030");
|
||||||
|
clearCreateDnodeReq();
|
||||||
|
|
||||||
|
setCreateDnodeReqFunc("host1", 9030);
|
||||||
|
run("CREATE DNODE host1 PORT 9030");
|
||||||
|
clearCreateDnodeReq();
|
||||||
|
|
||||||
|
setCreateDnodeReqFunc("abc2", 7040);
|
||||||
|
run("CREATE DNODE 'abc2:7040'");
|
||||||
|
clearCreateDnodeReq();
|
||||||
|
|
||||||
|
setCreateDnodeReqFunc("1.1.1.2");
|
||||||
|
run("CREATE DNODE 1.1.1.2");
|
||||||
|
clearCreateDnodeReq();
|
||||||
|
|
||||||
|
setCreateDnodeReqFunc("host2");
|
||||||
|
run("CREATE DNODE host2");
|
||||||
|
clearCreateDnodeReq();
|
||||||
}
|
}
|
||||||
|
|
||||||
// CREATE [AGGREGATE] FUNCTION [IF NOT EXISTS] func_name AS library_path OUTPUTTYPE type_name [BUFSIZE value]
|
// CREATE [AGGREGATE] FUNCTION [IF NOT EXISTS] func_name AS library_path OUTPUTTYPE type_name [BUFSIZE value]
|
||||||
|
@ -322,13 +359,17 @@ TEST_F(ParserInitialCTest, createStable) {
|
||||||
memset(&expect, 0, sizeof(SMCreateStbReq));
|
memset(&expect, 0, sizeof(SMCreateStbReq));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto setCreateStbReqFunc = [&](const char* pTbname, int8_t igExists = 0,
|
auto setCreateStbReqFunc = [&](const char* pTbname, int8_t igExists = 0, int64_t delay1 = -1, int64_t delay2 = -1,
|
||||||
float xFilesFactor = TSDB_DEFAULT_ROLLUP_FILE_FACTOR,
|
int64_t watermark1 = TSDB_DEFAULT_ROLLUP_WATERMARK,
|
||||||
|
int64_t watermark2 = TSDB_DEFAULT_ROLLUP_WATERMARK,
|
||||||
int32_t ttl = TSDB_DEFAULT_TABLE_TTL, const char* pComment = nullptr) {
|
int32_t ttl = TSDB_DEFAULT_TABLE_TTL, const char* pComment = nullptr) {
|
||||||
int32_t len = snprintf(expect.name, sizeof(expect.name), "0.test.%s", pTbname);
|
int32_t len = snprintf(expect.name, sizeof(expect.name), "0.test.%s", pTbname);
|
||||||
expect.name[len] = '\0';
|
expect.name[len] = '\0';
|
||||||
expect.igExists = igExists;
|
expect.igExists = igExists;
|
||||||
expect.xFilesFactor = xFilesFactor;
|
expect.delay1 = delay1;
|
||||||
|
expect.delay2 = delay2;
|
||||||
|
expect.watermark1 = watermark1;
|
||||||
|
expect.watermark2 = watermark2;
|
||||||
expect.ttl = ttl;
|
expect.ttl = ttl;
|
||||||
if (nullptr != pComment) {
|
if (nullptr != pComment) {
|
||||||
expect.comment = strdup(pComment);
|
expect.comment = strdup(pComment);
|
||||||
|
@ -366,8 +407,10 @@ TEST_F(ParserInitialCTest, createStable) {
|
||||||
|
|
||||||
ASSERT_EQ(std::string(req.name), std::string(expect.name));
|
ASSERT_EQ(std::string(req.name), std::string(expect.name));
|
||||||
ASSERT_EQ(req.igExists, expect.igExists);
|
ASSERT_EQ(req.igExists, expect.igExists);
|
||||||
ASSERT_EQ(req.xFilesFactor, expect.xFilesFactor);
|
ASSERT_EQ(req.delay1, expect.delay1);
|
||||||
ASSERT_EQ(req.delay, expect.delay);
|
ASSERT_EQ(req.delay2, expect.delay2);
|
||||||
|
ASSERT_EQ(req.watermark1, expect.watermark1);
|
||||||
|
ASSERT_EQ(req.watermark2, expect.watermark2);
|
||||||
ASSERT_EQ(req.ttl, expect.ttl);
|
ASSERT_EQ(req.ttl, expect.ttl);
|
||||||
ASSERT_EQ(req.numOfColumns, expect.numOfColumns);
|
ASSERT_EQ(req.numOfColumns, expect.numOfColumns);
|
||||||
ASSERT_EQ(req.numOfTags, expect.numOfTags);
|
ASSERT_EQ(req.numOfTags, expect.numOfTags);
|
||||||
|
@ -418,7 +461,8 @@ TEST_F(ParserInitialCTest, createStable) {
|
||||||
run("CREATE STABLE t1(ts TIMESTAMP, c1 INT) TAGS(id INT)");
|
run("CREATE STABLE t1(ts TIMESTAMP, c1 INT) TAGS(id INT)");
|
||||||
clearCreateStbReq();
|
clearCreateStbReq();
|
||||||
|
|
||||||
setCreateStbReqFunc("t1", 1, 0.1, 100, "test create table");
|
setCreateStbReqFunc("t1", 1, 100 * MILLISECOND_PER_SECOND, 10 * MILLISECOND_PER_MINUTE, 10,
|
||||||
|
1 * MILLISECOND_PER_MINUTE, 100, "test create table");
|
||||||
addFieldToCreateStbReqFunc(true, "ts", TSDB_DATA_TYPE_TIMESTAMP, 0, 0);
|
addFieldToCreateStbReqFunc(true, "ts", TSDB_DATA_TYPE_TIMESTAMP, 0, 0);
|
||||||
addFieldToCreateStbReqFunc(true, "c1", TSDB_DATA_TYPE_INT);
|
addFieldToCreateStbReqFunc(true, "c1", TSDB_DATA_TYPE_INT);
|
||||||
addFieldToCreateStbReqFunc(true, "c2", TSDB_DATA_TYPE_UINT);
|
addFieldToCreateStbReqFunc(true, "c2", TSDB_DATA_TYPE_UINT);
|
||||||
|
@ -456,15 +500,20 @@ TEST_F(ParserInitialCTest, createStable) {
|
||||||
"TAGS (a1 TIMESTAMP, a2 INT, a3 INT UNSIGNED, a4 BIGINT, a5 BIGINT UNSIGNED, a6 FLOAT, a7 DOUBLE, "
|
"TAGS (a1 TIMESTAMP, a2 INT, a3 INT UNSIGNED, a4 BIGINT, a5 BIGINT UNSIGNED, a6 FLOAT, a7 DOUBLE, "
|
||||||
"a8 BINARY(20), a9 SMALLINT, a10 SMALLINT UNSIGNED COMMENT 'test column comment', a11 TINYINT, "
|
"a8 BINARY(20), a9 SMALLINT, a10 SMALLINT UNSIGNED COMMENT 'test column comment', a11 TINYINT, "
|
||||||
"a12 TINYINT UNSIGNED, a13 BOOL, a14 NCHAR(30), a15 VARCHAR(50)) "
|
"a12 TINYINT UNSIGNED, a13 BOOL, a14 NCHAR(30), a15 VARCHAR(50)) "
|
||||||
"TTL 100 COMMENT 'test create table' SMA(c1, c2, c3) ROLLUP (MIN) FILE_FACTOR 0.1");
|
"TTL 100 COMMENT 'test create table' SMA(c1, c2, c3) ROLLUP (MIN) MAX_DELAY 100s,10m WATERMARK 10a,1m");
|
||||||
clearCreateStbReq();
|
clearCreateStbReq();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserInitialCTest, createStableSemanticCheck) {
|
TEST_F(ParserInitialCTest, createStableSemanticCheck) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("CREATE STABLE stb2 (ts TIMESTAMP, c1 INT) TAGS (tag1 INT) ROLLUP(CEIL) FILE_FACTOR 0.1",
|
run("CREATE STABLE stb2 (ts TIMESTAMP, c1 INT) TAGS (tag1 INT) ROLLUP(CEIL)", TSDB_CODE_PAR_INVALID_ROLLUP_OPTION);
|
||||||
TSDB_CODE_PAR_INVALID_ROLLUP_OPTION, PARSER_STAGE_TRANSLATE);
|
|
||||||
|
run("CREATE STABLE stb2 (ts TIMESTAMP, c1 INT) TAGS (tag1 INT) ROLLUP(MAX) MAX_DELAY 0s WATERMARK 1m",
|
||||||
|
TSDB_CODE_PAR_INVALID_RANGE_OPTION);
|
||||||
|
|
||||||
|
run("CREATE STABLE stb2 (ts TIMESTAMP, c1 INT) TAGS (tag1 INT) ROLLUP(MAX) MAX_DELAY 10s WATERMARK 18m",
|
||||||
|
TSDB_CODE_PAR_INVALID_RANGE_OPTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserInitialCTest, createStream) {
|
TEST_F(ParserInitialCTest, createStream) {
|
||||||
|
@ -477,7 +526,7 @@ TEST_F(ParserInitialCTest, createStream) {
|
||||||
memset(&expect, 0, sizeof(SCMCreateStreamReq));
|
memset(&expect, 0, sizeof(SCMCreateStreamReq));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto setCreateStbReqFunc =
|
auto setCreateStreamReqFunc =
|
||||||
[&](const char* pStream, const char* pSrcDb, const char* pSql, const char* pDstStb = nullptr, int8_t igExists = 0,
|
[&](const char* pStream, const char* pSrcDb, const char* pSql, const char* pDstStb = nullptr, int8_t igExists = 0,
|
||||||
int8_t triggerType = STREAM_TRIGGER_AT_ONCE, int64_t maxDelay = 0, int64_t watermark = 0) {
|
int8_t triggerType = STREAM_TRIGGER_AT_ONCE, int64_t maxDelay = 0, int64_t watermark = 0) {
|
||||||
snprintf(expect.name, sizeof(expect.name), "0.%s", pStream);
|
snprintf(expect.name, sizeof(expect.name), "0.%s", pStream);
|
||||||
|
@ -509,21 +558,21 @@ TEST_F(ParserInitialCTest, createStream) {
|
||||||
tFreeSCMCreateStreamReq(&req);
|
tFreeSCMCreateStreamReq(&req);
|
||||||
});
|
});
|
||||||
|
|
||||||
setCreateStbReqFunc("s1", "test", "create stream s1 as select * from t1");
|
setCreateStreamReqFunc("s1", "test", "create stream s1 as select * from t1");
|
||||||
run("CREATE STREAM s1 AS SELECT * FROM t1");
|
run("CREATE STREAM s1 AS SELECT * FROM t1");
|
||||||
clearCreateStreamReq();
|
clearCreateStreamReq();
|
||||||
|
|
||||||
setCreateStbReqFunc("s1", "test", "create stream if not exists s1 as select * from t1", nullptr, 1);
|
setCreateStreamReqFunc("s1", "test", "create stream if not exists s1 as select * from t1", nullptr, 1);
|
||||||
run("CREATE STREAM IF NOT EXISTS s1 AS SELECT * FROM t1");
|
run("CREATE STREAM IF NOT EXISTS s1 AS SELECT * FROM t1");
|
||||||
clearCreateStreamReq();
|
clearCreateStreamReq();
|
||||||
|
|
||||||
setCreateStbReqFunc("s1", "test", "create stream s1 into st1 as select * from t1", "st1");
|
setCreateStreamReqFunc("s1", "test", "create stream s1 into st1 as select * from t1", "st1");
|
||||||
run("CREATE STREAM s1 INTO st1 AS SELECT * FROM t1");
|
run("CREATE STREAM s1 INTO st1 AS SELECT * FROM t1");
|
||||||
clearCreateStreamReq();
|
clearCreateStreamReq();
|
||||||
|
|
||||||
setCreateStbReqFunc("s1", "test",
|
setCreateStreamReqFunc(
|
||||||
"create stream if not exists s1 trigger max_delay 20s watermark 10s into st1 as select * from t1",
|
"s1", "test", "create stream if not exists s1 trigger max_delay 20s watermark 10s into st1 as select * from t1",
|
||||||
"st1", 1, STREAM_TRIGGER_MAX_DELAY, 20 * MILLISECOND_PER_SECOND, 10 * MILLISECOND_PER_SECOND);
|
"st1", 1, STREAM_TRIGGER_MAX_DELAY, 20 * MILLISECOND_PER_SECOND, 10 * MILLISECOND_PER_SECOND);
|
||||||
run("CREATE STREAM IF NOT EXISTS s1 TRIGGER MAX_DELAY 20s WATERMARK 10s INTO st1 AS SELECT * FROM t1");
|
run("CREATE STREAM IF NOT EXISTS s1 TRIGGER MAX_DELAY 20s WATERMARK 10s INTO st1 AS SELECT * FROM t1");
|
||||||
clearCreateStreamReq();
|
clearCreateStreamReq();
|
||||||
}
|
}
|
||||||
|
@ -552,7 +601,7 @@ TEST_F(ParserInitialCTest, createTable) {
|
||||||
"TAGS (a1 TIMESTAMP, a2 INT, a3 INT UNSIGNED, a4 BIGINT, a5 BIGINT UNSIGNED, a6 FLOAT, a7 DOUBLE, a8 BINARY(20), "
|
"TAGS (a1 TIMESTAMP, a2 INT, a3 INT UNSIGNED, a4 BIGINT, a5 BIGINT UNSIGNED, a6 FLOAT, a7 DOUBLE, a8 BINARY(20), "
|
||||||
"a9 SMALLINT, a10 SMALLINT UNSIGNED COMMENT 'test column comment', a11 TINYINT, a12 TINYINT UNSIGNED, a13 BOOL, "
|
"a9 SMALLINT, a10 SMALLINT UNSIGNED COMMENT 'test column comment', a11 TINYINT, a12 TINYINT UNSIGNED, a13 BOOL, "
|
||||||
"a14 NCHAR(30), a15 VARCHAR(50)) "
|
"a14 NCHAR(30), a15 VARCHAR(50)) "
|
||||||
"TTL 100 COMMENT 'test create table' SMA(c1, c2, c3) ROLLUP (MIN) FILE_FACTOR 0.1");
|
"TTL 100 COMMENT 'test create table' SMA(c1, c2, c3) ROLLUP (MIN)");
|
||||||
|
|
||||||
run("CREATE TABLE IF NOT EXISTS t1 USING st1 TAGS(1, 'wxy', NOW)");
|
run("CREATE TABLE IF NOT EXISTS t1 USING st1 TAGS(1, 'wxy', NOW)");
|
||||||
|
|
||||||
|
|
|
@ -64,8 +64,9 @@ TEST_F(ParserInitialDTest, dropConsumerGroup) {
|
||||||
|
|
||||||
SMDropCgroupReq expect = {0};
|
SMDropCgroupReq expect = {0};
|
||||||
|
|
||||||
auto setDropCgroupReqFunc = [&](const char* pTopicName, const char* pCGroupName, int8_t igNotExists = 0) {
|
auto clearDropCgroupReq = [&]() { memset(&expect, 0, sizeof(SMDropCgroupReq)); };
|
||||||
memset(&expect, 0, sizeof(SMDropCgroupReq));
|
|
||||||
|
auto setDropCgroupReq = [&](const char* pTopicName, const char* pCGroupName, int8_t igNotExists = 0) {
|
||||||
snprintf(expect.topic, sizeof(expect.topic), "0.%s", pTopicName);
|
snprintf(expect.topic, sizeof(expect.topic), "0.%s", pTopicName);
|
||||||
strcpy(expect.cgroup, pCGroupName);
|
strcpy(expect.cgroup, pCGroupName);
|
||||||
expect.igNotExists = igNotExists;
|
expect.igNotExists = igNotExists;
|
||||||
|
@ -81,15 +82,51 @@ TEST_F(ParserInitialDTest, dropConsumerGroup) {
|
||||||
ASSERT_EQ(req.igNotExists, expect.igNotExists);
|
ASSERT_EQ(req.igNotExists, expect.igNotExists);
|
||||||
});
|
});
|
||||||
|
|
||||||
setDropCgroupReqFunc("tp1", "cg1");
|
setDropCgroupReq("tp1", "cg1");
|
||||||
run("DROP CONSUMER GROUP cg1 ON tp1");
|
run("DROP CONSUMER GROUP cg1 ON tp1");
|
||||||
|
clearDropCgroupReq();
|
||||||
|
|
||||||
setDropCgroupReqFunc("tp1", "cg1", 1);
|
setDropCgroupReq("tp1", "cg1", 1);
|
||||||
run("DROP CONSUMER GROUP IF EXISTS cg1 ON tp1");
|
run("DROP CONSUMER GROUP IF EXISTS cg1 ON tp1");
|
||||||
|
clearDropCgroupReq();
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo DROP database
|
// todo DROP database
|
||||||
|
|
||||||
// todo DROP dnode
|
// todo DROP dnode
|
||||||
|
TEST_F(ParserInitialDTest, dropDnode) {
|
||||||
|
useDb("root", "test");
|
||||||
|
|
||||||
|
SDropDnodeReq expect = {0};
|
||||||
|
|
||||||
|
auto clearDropDnodeReq = [&]() { memset(&expect, 0, sizeof(SDropDnodeReq)); };
|
||||||
|
|
||||||
|
auto setDropDnodeReqById = [&](int32_t dnodeId) { expect.dnodeId = dnodeId; };
|
||||||
|
|
||||||
|
auto setDropDnodeReqByEndpoint = [&](const char* pFqdn, int32_t port) {
|
||||||
|
strcpy(expect.fqdn, pFqdn);
|
||||||
|
expect.port = port;
|
||||||
|
};
|
||||||
|
|
||||||
|
setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) {
|
||||||
|
ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_DROP_DNODE_STMT);
|
||||||
|
SDropDnodeReq req = {0};
|
||||||
|
ASSERT_TRUE(TSDB_CODE_SUCCESS == tDeserializeSDropDnodeReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req));
|
||||||
|
|
||||||
|
ASSERT_EQ(req.dnodeId, expect.dnodeId);
|
||||||
|
ASSERT_EQ(std::string(req.fqdn), std::string(expect.fqdn));
|
||||||
|
ASSERT_EQ(req.port, expect.port);
|
||||||
|
});
|
||||||
|
|
||||||
|
setDropDnodeReqById(1);
|
||||||
|
run("DROP DNODE 1");
|
||||||
|
clearDropDnodeReq();
|
||||||
|
|
||||||
|
setDropDnodeReqByEndpoint("host1", 7030);
|
||||||
|
run("DROP DNODE 'host1:7030'");
|
||||||
|
clearDropDnodeReq();
|
||||||
|
}
|
||||||
|
|
||||||
// todo DROP function
|
// todo DROP function
|
||||||
|
|
||||||
TEST_F(ParserInitialDTest, dropIndex) {
|
TEST_F(ParserInitialDTest, dropIndex) {
|
||||||
|
|
|
@ -24,9 +24,45 @@ class ParserShowToUseTest : public ParserDdlTest {};
|
||||||
// todo SHOW accounts
|
// todo SHOW accounts
|
||||||
// todo SHOW apps
|
// todo SHOW apps
|
||||||
// todo SHOW connections
|
// todo SHOW connections
|
||||||
// todo SHOW create database
|
|
||||||
// todo SHOW create stable
|
TEST_F(ParserShowToUseTest, showCreateDatabase) {
|
||||||
// todo SHOW create table
|
useDb("root", "test");
|
||||||
|
|
||||||
|
setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) {
|
||||||
|
ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_SHOW_CREATE_DATABASE_STMT);
|
||||||
|
ASSERT_EQ(pQuery->execMode, QUERY_EXEC_MODE_LOCAL);
|
||||||
|
ASSERT_TRUE(pQuery->haveResultSet);
|
||||||
|
ASSERT_NE(((SShowCreateDatabaseStmt*)pQuery->pRoot)->pCfg, nullptr);
|
||||||
|
});
|
||||||
|
|
||||||
|
run("SHOW CREATE DATABASE test");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(ParserShowToUseTest, showCreateSTable) {
|
||||||
|
useDb("root", "test");
|
||||||
|
|
||||||
|
setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) {
|
||||||
|
ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_SHOW_CREATE_STABLE_STMT);
|
||||||
|
ASSERT_EQ(pQuery->execMode, QUERY_EXEC_MODE_LOCAL);
|
||||||
|
ASSERT_TRUE(pQuery->haveResultSet);
|
||||||
|
ASSERT_NE(((SShowCreateTableStmt*)pQuery->pRoot)->pMeta, nullptr);
|
||||||
|
});
|
||||||
|
|
||||||
|
run("SHOW CREATE STABLE st1");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(ParserShowToUseTest, showCreateTable) {
|
||||||
|
useDb("root", "test");
|
||||||
|
|
||||||
|
setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) {
|
||||||
|
ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_SHOW_CREATE_TABLE_STMT);
|
||||||
|
ASSERT_EQ(pQuery->execMode, QUERY_EXEC_MODE_LOCAL);
|
||||||
|
ASSERT_TRUE(pQuery->haveResultSet);
|
||||||
|
ASSERT_NE(((SShowCreateTableStmt*)pQuery->pRoot)->pMeta, nullptr);
|
||||||
|
});
|
||||||
|
|
||||||
|
run("SHOW CREATE TABLE t1");
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(ParserShowToUseTest, showDatabases) {
|
TEST_F(ParserShowToUseTest, showDatabases) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
|
@ -20,8 +20,11 @@
|
||||||
|
|
||||||
#define ALLOW_FORBID_FUNC
|
#define ALLOW_FORBID_FUNC
|
||||||
|
|
||||||
|
#include "cmdnodes.h"
|
||||||
#include "querynodes.h"
|
#include "querynodes.h"
|
||||||
#include "taoserror.h"
|
#include "taoserror.h"
|
||||||
|
#include "tglobal.h"
|
||||||
|
#include "ttime.h"
|
||||||
|
|
||||||
namespace ParserTest {
|
namespace ParserTest {
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ sql create database d0 keep 365000d,365000d,365000d
|
||||||
sql use d0
|
sql use d0
|
||||||
|
|
||||||
print =============== create super table and register rsma
|
print =============== create super table and register rsma
|
||||||
sql create table if not exists stb (ts timestamp, c1 int) tags (city binary(20),district binary(20)) rollup(min) file_factor 0.1;
|
sql create table if not exists stb (ts timestamp, c1 int) tags (city binary(20),district binary(20)) rollup(min);
|
||||||
|
|
||||||
sql show stables
|
sql show stables
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
|
|
|
@ -9,7 +9,7 @@ sql create database d0 retentions 15s:7d,1m:21d,15m:365d;
|
||||||
sql use d0
|
sql use d0
|
||||||
|
|
||||||
print =============== create super table and register rsma
|
print =============== create super table and register rsma
|
||||||
sql create table if not exists stb (ts timestamp, c1 int) tags (city binary(20),district binary(20)) rollup(min) file_factor 0.1;
|
sql create table if not exists stb (ts timestamp, c1 int) tags (city binary(20),district binary(20)) rollup(min);
|
||||||
|
|
||||||
sql show stables
|
sql show stables
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
|
|
Loading…
Reference in New Issue