提交 311b044e 编写于 作者: H Hongze Cheng

Merge branch '3.0' into feature/vnode

...@@ -193,6 +193,9 @@ DLL_EXPORT void taos_close_stream(TAOS_STREAM *tstr); ...@@ -193,6 +193,9 @@ DLL_EXPORT void taos_close_stream(TAOS_STREAM *tstr);
DLL_EXPORT int taos_load_table_info(TAOS *taos, const char* tableNameList); DLL_EXPORT int taos_load_table_info(TAOS *taos, const char* tableNameList);
DLL_EXPORT TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int protocol, int precision); DLL_EXPORT TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int protocol, int precision);
DLL_EXPORT TAOS_RES *tmq_create_topic(TAOS* taos, const char* name, const char* sql, int sqlLen);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -13,5 +13,6 @@ int taosGetFqdnPortFromEp(const char *ep, char *fqdn, uint16_t *port); ...@@ -13,5 +13,6 @@ int taosGetFqdnPortFromEp(const char *ep, char *fqdn, uint16_t *port);
bool isEpsetEqual(const SEpSet *s1, const SEpSet *s2); bool isEpsetEqual(const SEpSet *s1, const SEpSet *s2);
void updateEpSet_s(SCorEpSet *pEpSet, SEpSet *pNewEpSet); void updateEpSet_s(SCorEpSet *pEpSet, SEpSet *pNewEpSet);
SEpSet getEpSet_s(SCorEpSet *pEpSet);
#endif // TDENGINE_TEP_H #endif // TDENGINE_TEP_H
...@@ -219,26 +219,6 @@ typedef struct { ...@@ -219,26 +219,6 @@ typedef struct {
char data[]; char data[];
} SMDCreateTableMsg; } SMDCreateTableMsg;
// typedef struct {
// int32_t len; // one create table message
// char tableName[TSDB_TABLE_FNAME_LEN];
// int16_t numOfColumns;
// int16_t sqlLen; // the length of SQL, it starts after schema , sql is a null-terminated string
// int8_t igExists;
// int8_t rspMeta;
// int8_t reserved[16];
// char schema[];
//} SCreateTableMsg;
typedef struct {
char tableName[TSDB_TABLE_FNAME_LEN];
int16_t numOfColumns;
int16_t numOfTags;
int8_t igExists;
int8_t rspMeta;
char schema[];
} SCreateCTableMsg;
typedef struct { typedef struct {
char name[TSDB_TABLE_FNAME_LEN]; char name[TSDB_TABLE_FNAME_LEN];
int8_t igExists; int8_t igExists;
...@@ -372,7 +352,7 @@ typedef struct SColIndex { ...@@ -372,7 +352,7 @@ typedef struct SColIndex {
int16_t colId; // column id int16_t colId; // column id
int16_t colIndex; // column index in colList if it is a normal column or index in tagColList if a tag int16_t colIndex; // column index in colList if it is a normal column or index in tagColList if a tag
int16_t flag; // denote if it is a tag or a normal column int16_t flag; // denote if it is a tag or a normal column
char name[TSDB_COL_NAME_LEN + TSDB_DB_NAME_LEN + 1]; char name[TSDB_DB_FNAME_LEN];
} SColIndex; } SColIndex;
typedef struct SColumnFilterInfo { typedef struct SColumnFilterInfo {
...@@ -519,7 +499,7 @@ typedef struct SRetrieveTableRsp { ...@@ -519,7 +499,7 @@ typedef struct SRetrieveTableRsp {
} SRetrieveTableRsp; } SRetrieveTableRsp;
typedef struct { typedef struct {
char db[TSDB_FULL_DB_NAME_LEN]; char db[TSDB_DB_FNAME_LEN];
int32_t numOfVgroups; int32_t numOfVgroups;
int32_t cacheBlockSize; // MB int32_t cacheBlockSize; // MB
int32_t totalBlocks; int32_t totalBlocks;
...@@ -543,7 +523,7 @@ typedef struct { ...@@ -543,7 +523,7 @@ typedef struct {
} SCreateDbMsg; } SCreateDbMsg;
typedef struct { typedef struct {
char db[TSDB_FULL_DB_NAME_LEN]; char db[TSDB_DB_FNAME_LEN];
int32_t totalBlocks; int32_t totalBlocks;
int32_t daysToKeep0; int32_t daysToKeep0;
int32_t daysToKeep1; int32_t daysToKeep1;
...@@ -693,7 +673,7 @@ typedef struct { ...@@ -693,7 +673,7 @@ typedef struct {
typedef struct { typedef struct {
int32_t vgId; int32_t vgId;
int32_t dnodeId; int32_t dnodeId;
char db[TSDB_FULL_DB_NAME_LEN]; char db[TSDB_DB_FNAME_LEN];
uint64_t dbUid; uint64_t dbUid;
int32_t vgVersion; int32_t vgVersion;
int32_t cacheBlockSize; int32_t cacheBlockSize;
...@@ -720,7 +700,7 @@ typedef struct { ...@@ -720,7 +700,7 @@ typedef struct {
typedef struct { typedef struct {
int32_t vgId; int32_t vgId;
int32_t dnodeId; int32_t dnodeId;
char db[TSDB_FULL_DB_NAME_LEN]; char db[TSDB_DB_FNAME_LEN];
uint64_t dbUid; uint64_t dbUid;
} SDropVnodeMsg, SSyncVnodeMsg, SCompactVnodeMsg; } SDropVnodeMsg, SSyncVnodeMsg, SCompactVnodeMsg;
...@@ -796,7 +776,7 @@ typedef struct { ...@@ -796,7 +776,7 @@ typedef struct {
} STagData; } STagData;
typedef struct { typedef struct {
char db[TSDB_FULL_DB_NAME_LEN]; char db[TSDB_DB_FNAME_LEN];
int32_t vgVersion; int32_t vgVersion;
int32_t vgNum; int32_t vgNum;
int8_t hashMethod; int8_t hashMethod;
...@@ -810,13 +790,13 @@ typedef struct { ...@@ -810,13 +790,13 @@ typedef struct {
*/ */
typedef struct { typedef struct {
int8_t type; int8_t type;
char db[TSDB_FULL_DB_NAME_LEN]; char db[TSDB_DB_FNAME_LEN];
int16_t payloadLen; int16_t payloadLen;
char payload[]; char payload[];
} SShowMsg; } SShowMsg;
typedef struct { typedef struct {
char db[TSDB_FULL_DB_NAME_LEN]; char db[TSDB_DB_FNAME_LEN];
int32_t numOfVgroup; int32_t numOfVgroup;
int32_t vgid[]; int32_t vgid[];
} SCompactMsg; } SCompactMsg;
...@@ -827,7 +807,7 @@ typedef struct SShowRsp { ...@@ -827,7 +807,7 @@ typedef struct SShowRsp {
} SShowRsp; } SShowRsp;
typedef struct { typedef struct {
char ep[TSDB_FQDN_LEN]; // end point, hostname:port char fqdn[TSDB_FQDN_LEN]; // end point, hostname:port
int32_t port; int32_t port;
} SCreateDnodeMsg; } SCreateDnodeMsg;
...@@ -1019,7 +999,7 @@ typedef struct { ...@@ -1019,7 +999,7 @@ typedef struct {
} SUpdateTagValRsp; } SUpdateTagValRsp;
typedef struct SSubQueryMsg { typedef struct SSubQueryMsg {
uint64_t schedulerId; uint64_t sId;
uint64_t queryId; uint64_t queryId;
uint64_t taskId; uint64_t taskId;
uint32_t contentLen; uint32_t contentLen;
...@@ -1027,7 +1007,7 @@ typedef struct SSubQueryMsg { ...@@ -1027,7 +1007,7 @@ typedef struct SSubQueryMsg {
} SSubQueryMsg; } SSubQueryMsg;
typedef struct SResReadyMsg { typedef struct SResReadyMsg {
uint64_t schedulerId; uint64_t sId;
uint64_t queryId; uint64_t queryId;
uint64_t taskId; uint64_t taskId;
} SResReadyMsg; } SResReadyMsg;
...@@ -1037,13 +1017,13 @@ typedef struct SResReadyRsp { ...@@ -1037,13 +1017,13 @@ typedef struct SResReadyRsp {
} SResReadyRsp; } SResReadyRsp;
typedef struct SResFetchMsg { typedef struct SResFetchMsg {
uint64_t schedulerId; uint64_t sId;
uint64_t queryId; uint64_t queryId;
uint64_t taskId; uint64_t taskId;
} SResFetchMsg; } SResFetchMsg;
typedef struct SSchTasksStatusMsg { typedef struct SSchTasksStatusMsg {
uint64_t schedulerId; uint64_t sId;
} SSchTasksStatusMsg; } SSchTasksStatusMsg;
typedef struct STaskStatus { typedef struct STaskStatus {
...@@ -1058,7 +1038,7 @@ typedef struct SSchedulerStatusRsp { ...@@ -1058,7 +1038,7 @@ typedef struct SSchedulerStatusRsp {
} SSchedulerStatusRsp; } SSchedulerStatusRsp;
typedef struct STaskCancelMsg { typedef struct STaskCancelMsg {
uint64_t schedulerId; uint64_t sId;
uint64_t queryId; uint64_t queryId;
uint64_t taskId; uint64_t taskId;
} STaskCancelMsg; } STaskCancelMsg;
...@@ -1068,7 +1048,7 @@ typedef struct STaskCancelRsp { ...@@ -1068,7 +1048,7 @@ typedef struct STaskCancelRsp {
} STaskCancelRsp; } STaskCancelRsp;
typedef struct STaskDropMsg { typedef struct STaskDropMsg {
uint64_t schedulerId; uint64_t sId;
uint64_t queryId; uint64_t queryId;
uint64_t taskId; uint64_t taskId;
} STaskDropMsg; } STaskDropMsg;
...@@ -1077,6 +1057,27 @@ typedef struct STaskDropRsp { ...@@ -1077,6 +1057,27 @@ typedef struct STaskDropRsp {
int32_t code; int32_t code;
} STaskDropRsp; } STaskDropRsp;
typedef struct {
int8_t igExists;
char* name;
char* phyPlan;
} SCMCreateTopicReq;
static FORCE_INLINE int tSerializeSCMCreateTopicReq(void** buf, const SCMCreateTopicReq* pReq) {
int tlen = 0;
tlen += taosEncodeString(buf, pReq->name);
tlen += taosEncodeFixedI8(buf, pReq->igExists);
tlen += taosEncodeString(buf, pReq->phyPlan);
return tlen;
}
static FORCE_INLINE void* tDeserializeSCMCreateTopicReq(void* buf, SCMCreateTopicReq* pReq) {
buf = taosDecodeFixedI8(buf, &(pReq->igExists));
buf = taosDecodeString(buf, &(pReq->name));
buf = taosDecodeString(buf, &(pReq->phyPlan));
return buf;
}
typedef struct { typedef struct {
char name[TSDB_TOPIC_FNAME_LEN]; char name[TSDB_TOPIC_FNAME_LEN];
int8_t igExists; int8_t igExists;
......
...@@ -13,205 +13,199 @@ ...@@ -13,205 +13,199 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef _TD_COMMON_TOKEN_DEF_H_ #ifndef TDENGINE_TTOKENDEF_H
#define _TD_COMMON_TOKEN_DEF_H_ #define TDENGINE_TTOKENDEF_H
#define TK_ID 1 #define TK_ID 1
#define TK_BOOL 2 #define TK_BOOL 2
#define TK_TINYINT 3 #define TK_INTEGER 3
#define TK_SMALLINT 4 #define TK_FLOAT 4
#define TK_INTEGER 5 #define TK_STRING 5
#define TK_BIGINT 6 #define TK_TIMESTAMP 6
#define TK_FLOAT 7 #define TK_OR 7
#define TK_DOUBLE 8 #define TK_AND 8
#define TK_STRING 9 #define TK_NOT 9
#define TK_TIMESTAMP 10 #define TK_EQ 10
#define TK_BINARY 11 #define TK_NE 11
#define TK_NCHAR 12 #define TK_ISNULL 12
#define TK_OR 13 #define TK_NOTNULL 13
#define TK_AND 14 #define TK_IS 14
#define TK_NOT 15 #define TK_LIKE 15
#define TK_EQ 16 #define TK_MATCH 16
#define TK_NE 17 #define TK_NMATCH 17
#define TK_ISNULL 18 #define TK_GLOB 18
#define TK_NOTNULL 19 #define TK_BETWEEN 19
#define TK_IS 20 #define TK_IN 20
#define TK_LIKE 21 #define TK_GT 21
#define TK_MATCH 22 #define TK_GE 22
#define TK_NMATCH 23 #define TK_LT 23
#define TK_GLOB 24 #define TK_LE 24
#define TK_BETWEEN 25 #define TK_BITAND 25
#define TK_IN 26 #define TK_BITOR 26
#define TK_GT 27 #define TK_LSHIFT 27
#define TK_GE 28 #define TK_RSHIFT 28
#define TK_LT 29 #define TK_PLUS 29
#define TK_LE 30 #define TK_MINUS 30
#define TK_BITAND 31 #define TK_DIVIDE 31
#define TK_BITOR 32 #define TK_TIMES 32
#define TK_LSHIFT 33 #define TK_STAR 33
#define TK_RSHIFT 34 #define TK_SLASH 34
#define TK_PLUS 35 #define TK_REM 35
#define TK_MINUS 36 #define TK_CONCAT 36
#define TK_DIVIDE 37 #define TK_UMINUS 37
#define TK_TIMES 38 #define TK_UPLUS 38
#define TK_STAR 39 #define TK_BITNOT 39
#define TK_SLASH 40 #define TK_SHOW 40
#define TK_REM 41 #define TK_DATABASES 41
#define TK_CONCAT 42 #define TK_TOPICS 42
#define TK_UMINUS 43 #define TK_FUNCTIONS 43
#define TK_UPLUS 44 #define TK_MNODES 44
#define TK_BITNOT 45 #define TK_DNODES 45
#define TK_SHOW 46 #define TK_ACCOUNTS 46
#define TK_DATABASES 47 #define TK_USERS 47
#define TK_TOPICS 48 #define TK_MODULES 48
#define TK_FUNCTIONS 49 #define TK_QUERIES 49
#define TK_MNODES 50 #define TK_CONNECTIONS 50
#define TK_DNODES 51 #define TK_STREAMS 51
#define TK_ACCOUNTS 52 #define TK_VARIABLES 52
#define TK_USERS 53 #define TK_SCORES 53
#define TK_MODULES 54 #define TK_GRANTS 54
#define TK_QUERIES 55 #define TK_VNODES 55
#define TK_CONNECTIONS 56 #define TK_DOT 56
#define TK_STREAMS 57 #define TK_CREATE 57
#define TK_VARIABLES 58 #define TK_TABLE 58
#define TK_SCORES 59 #define TK_STABLE 59
#define TK_GRANTS 60 #define TK_DATABASE 60
#define TK_VNODES 61 #define TK_TABLES 61
#define TK_DOT 62 #define TK_STABLES 62
#define TK_CREATE 63 #define TK_VGROUPS 63
#define TK_TABLE 64 #define TK_DROP 64
#define TK_STABLE 65 #define TK_TOPIC 65
#define TK_DATABASE 66 #define TK_FUNCTION 66
#define TK_TABLES 67 #define TK_DNODE 67
#define TK_STABLES 68 #define TK_USER 68
#define TK_VGROUPS 69 #define TK_ACCOUNT 69
#define TK_DROP 70 #define TK_USE 70
#define TK_TOPIC 71 #define TK_DESCRIBE 71
#define TK_FUNCTION 72 #define TK_DESC 72
#define TK_DNODE 73 #define TK_ALTER 73
#define TK_USER 74 #define TK_PASS 74
#define TK_ACCOUNT 75 #define TK_PRIVILEGE 75
#define TK_USE 76 #define TK_LOCAL 76
#define TK_DESCRIBE 77 #define TK_COMPACT 77
#define TK_DESC 78 #define TK_LP 78
#define TK_ALTER 79 #define TK_RP 79
#define TK_PASS 80 #define TK_IF 80
#define TK_PRIVILEGE 81 #define TK_EXISTS 81
#define TK_LOCAL 82 #define TK_PORT 82
#define TK_COMPACT 83 #define TK_IPTOKEN 83
#define TK_LP 84 #define TK_AS 84
#define TK_RP 85 #define TK_OUTPUTTYPE 85
#define TK_IF 86 #define TK_AGGREGATE 86
#define TK_EXISTS 87 #define TK_BUFSIZE 87
#define TK_AS 88 #define TK_PPS 88
#define TK_OUTPUTTYPE 89 #define TK_TSERIES 89
#define TK_AGGREGATE 90 #define TK_DBS 90
#define TK_BUFSIZE 91 #define TK_STORAGE 91
#define TK_PPS 92 #define TK_QTIME 92
#define TK_TSERIES 93 #define TK_CONNS 93
#define TK_DBS 94 #define TK_STATE 94
#define TK_STORAGE 95 #define TK_COMMA 95
#define TK_QTIME 96 #define TK_KEEP 96
#define TK_CONNS 97 #define TK_CACHE 97
#define TK_STATE 98 #define TK_REPLICA 98
#define TK_COMMA 99 #define TK_QUORUM 99
#define TK_KEEP 100 #define TK_DAYS 100
#define TK_CACHE 101 #define TK_MINROWS 101
#define TK_REPLICA 102 #define TK_MAXROWS 102
#define TK_QUORUM 103 #define TK_BLOCKS 103
#define TK_DAYS 104 #define TK_CTIME 104
#define TK_MINROWS 105 #define TK_WAL 105
#define TK_MAXROWS 106 #define TK_FSYNC 106
#define TK_BLOCKS 107 #define TK_COMP 107
#define TK_CTIME 108 #define TK_PRECISION 108
#define TK_WAL 109 #define TK_UPDATE 109
#define TK_FSYNC 110 #define TK_CACHELAST 110
#define TK_COMP 111 #define TK_UNSIGNED 111
#define TK_PRECISION 112 #define TK_TAGS 112
#define TK_UPDATE 113 #define TK_USING 113
#define TK_CACHELAST 114 #define TK_NULL 114
#define TK_PARTITIONS 115 #define TK_NOW 115
#define TK_UNSIGNED 116 #define TK_SELECT 116
#define TK_TAGS 117 #define TK_UNION 117
#define TK_USING 118 #define TK_ALL 118
#define TK_NULL 119 #define TK_DISTINCT 119
#define TK_NOW 120 #define TK_FROM 120
#define TK_SELECT 121 #define TK_VARIABLE 121
#define TK_UNION 122 #define TK_INTERVAL 122
#define TK_ALL 123 #define TK_EVERY 123
#define TK_DISTINCT 124 #define TK_SESSION 124
#define TK_FROM 125 #define TK_STATE_WINDOW 125
#define TK_VARIABLE 126 #define TK_FILL 126
#define TK_INTERVAL 127 #define TK_SLIDING 127
#define TK_EVERY 128 #define TK_ORDER 128
#define TK_SESSION 129 #define TK_BY 129
#define TK_STATE_WINDOW 130 #define TK_ASC 130
#define TK_FILL 131 #define TK_GROUP 131
#define TK_SLIDING 132 #define TK_HAVING 132
#define TK_ORDER 133 #define TK_LIMIT 133
#define TK_BY 134 #define TK_OFFSET 134
#define TK_ASC 135 #define TK_SLIMIT 135
#define TK_GROUP 136 #define TK_SOFFSET 136
#define TK_HAVING 137 #define TK_WHERE 137
#define TK_LIMIT 138 #define TK_RESET 138
#define TK_OFFSET 139 #define TK_QUERY 139
#define TK_SLIMIT 140 #define TK_SYNCDB 140
#define TK_SOFFSET 141 #define TK_ADD 141
#define TK_WHERE 142 #define TK_COLUMN 142
#define TK_RESET 143 #define TK_MODIFY 143
#define TK_QUERY 144 #define TK_TAG 144
#define TK_SYNCDB 145 #define TK_CHANGE 145
#define TK_ADD 146 #define TK_SET 146
#define TK_COLUMN 147 #define TK_KILL 147
#define TK_MODIFY 148 #define TK_CONNECTION 148
#define TK_TAG 149 #define TK_STREAM 149
#define TK_CHANGE 150 #define TK_COLON 150
#define TK_SET 151 #define TK_ABORT 151
#define TK_KILL 152 #define TK_AFTER 152
#define TK_CONNECTION 153 #define TK_ATTACH 153
#define TK_STREAM 154 #define TK_BEFORE 154
#define TK_COLON 155 #define TK_BEGIN 155
#define TK_ABORT 156 #define TK_CASCADE 156
#define TK_AFTER 157 #define TK_CLUSTER 157
#define TK_ATTACH 158 #define TK_CONFLICT 158
#define TK_BEFORE 159 #define TK_COPY 159
#define TK_BEGIN 160 #define TK_DEFERRED 160
#define TK_CASCADE 161 #define TK_DELIMITERS 161
#define TK_CLUSTER 162 #define TK_DETACH 162
#define TK_CONFLICT 163 #define TK_EACH 163
#define TK_COPY 164 #define TK_END 164
#define TK_DEFERRED 165 #define TK_EXPLAIN 165
#define TK_DELIMITERS 166 #define TK_FAIL 166
#define TK_DETACH 167 #define TK_FOR 167
#define TK_EACH 168 #define TK_IGNORE 168
#define TK_END 169 #define TK_IMMEDIATE 169
#define TK_EXPLAIN 170 #define TK_INITIALLY 170
#define TK_FAIL 171 #define TK_INSTEAD 171
#define TK_FOR 172 #define TK_KEY 172
#define TK_IGNORE 173 #define TK_OF 173
#define TK_IMMEDIATE 174 #define TK_RAISE 174
#define TK_INITIALLY 175 #define TK_REPLACE 175
#define TK_INSTEAD 176 #define TK_RESTRICT 176
#define TK_KEY 177 #define TK_ROW 177
#define TK_OF 178 #define TK_STATEMENT 178
#define TK_RAISE 179 #define TK_TRIGGER 179
#define TK_REPLACE 180 #define TK_VIEW 180
#define TK_RESTRICT 181 #define TK_SEMI 181
#define TK_ROW 182 #define TK_NONE 182
#define TK_STATEMENT 183 #define TK_PREV 183
#define TK_TRIGGER 184 #define TK_LINEAR 184
#define TK_VIEW 185 #define TK_IMPORT 185
#define TK_IPTOKEN 186 #define TK_TBNAME 186
#define TK_SEMI 187 #define TK_JOIN 187
#define TK_NONE 188 #define TK_INSERT 188
#define TK_PREV 189 #define TK_INTO 189
#define TK_LINEAR 190 #define TK_VALUES 190
#define TK_IMPORT 191
#define TK_TBNAME 192
#define TK_JOIN 193
#define TK_INSERT 194
#define TK_INTO 195
#define TK_VALUES 196
#define TK_SPACE 300 #define TK_SPACE 300
...@@ -223,6 +217,6 @@ ...@@ -223,6 +217,6 @@
#define TK_FILE 306 #define TK_FILE 306
#define TK_QUESTION 307 // denoting the placeholder of "?",when invoking statement bind query #define TK_QUESTION 307 // denoting the placeholder of "?",when invoking statement bind query
#endif /*_TD_COMMON_TOKEN_DEF_H_*/ #endif
...@@ -49,10 +49,11 @@ typedef struct { ...@@ -49,10 +49,11 @@ typedef struct {
/** /**
* @brief Start one Bnode in Dnode. * @brief Start one Bnode in Dnode.
* *
* @param path Path of the bnode.
* @param pOption Option of the bnode. * @param pOption Option of the bnode.
* @return SBnode* The bnode object. * @return SBnode* The bnode object.
*/ */
SBnode *bndOpen(const SBnodeOpt *pOption); SBnode *bndOpen(const char *path, const SBnodeOpt *pOption);
/** /**
* @brief Stop Bnode in Dnode. * @brief Stop Bnode in Dnode.
...@@ -79,6 +80,13 @@ int32_t bndGetLoad(SBnode *pBnode, SBnodeLoad *pLoad); ...@@ -79,6 +80,13 @@ int32_t bndGetLoad(SBnode *pBnode, SBnodeLoad *pLoad);
*/ */
int32_t bndProcessWMsgs(SBnode *pBnode, SArray *pMsgs); int32_t bndProcessWMsgs(SBnode *pBnode, SArray *pMsgs);
/**
* @brief Drop a bnode.
*
* @param path Path of the bnode.
*/
void bndDestroy(const char *path);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -147,28 +147,12 @@ void mndCleanupMsg(SMnodeMsg *pMsg); ...@@ -147,28 +147,12 @@ void mndCleanupMsg(SMnodeMsg *pMsg);
void mndSendRsp(SMnodeMsg *pMsg, int32_t code); void mndSendRsp(SMnodeMsg *pMsg, int32_t code);
/** /**
* @brief Process the read request. * @brief Process the read, write, sync request.
* *
* @param pMsg The request msg. * @param pMsg The request msg.
* @return int32_t 0 for success, -1 for failure. * @return int32_t 0 for success, -1 for failure.
*/ */
void mndProcessReadMsg(SMnodeMsg *pMsg); void mndProcessMsg(SMnodeMsg *pMsg);
/**
* @brief Process the write request.
*
* @param pMsg The request msg.
* @return int32_t 0 for success, -1 for failure.
*/
void mndProcessWriteMsg(SMnodeMsg *pMsg);
/**
* @brief Process the sync request.
*
* @param pMsg The request msg.
* @return int32_t 0 for success, -1 for failure.
*/
void mndProcessSyncMsg(SMnodeMsg *pMsg);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -78,24 +78,14 @@ void qndClose(SQnode *pQnode); ...@@ -78,24 +78,14 @@ void qndClose(SQnode *pQnode);
int32_t qndGetLoad(SQnode *pQnode, SQnodeLoad *pLoad); int32_t qndGetLoad(SQnode *pQnode, SQnodeLoad *pLoad);
/** /**
* @brief Process a query message. * @brief Process a query or fetch message.
* *
* @param pQnode The qnode object. * @param pQnode The qnode object.
* @param pMsg The request message * @param pMsg The request message
* @param pRsp The response message * @param pRsp The response message
* @return int32_t 0 for success, -1 for failure * @return int32_t 0 for success, -1 for failure
*/ */
int32_t qndProcessQueryReq(SQnode *pQnode, SRpcMsg *pMsg, SRpcMsg **pRsp); int32_t qndProcessMsg(SQnode *pQnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
/**
* @brief Process a fetch message.
*
* @param pQnode The qnode object.
* @param pMsg The request message
* @param pRsp The response message
* @return int32_t 0 for success, -1 for failure
*/
int32_t qndProcessFetchReq(SQnode *pQnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -49,10 +49,11 @@ typedef struct { ...@@ -49,10 +49,11 @@ typedef struct {
/** /**
* @brief Start one Snode in Dnode. * @brief Start one Snode in Dnode.
* *
* @param path Path of the snode.
* @param pOption Option of the snode. * @param pOption Option of the snode.
* @return SSnode* The snode object. * @return SSnode* The snode object.
*/ */
SSnode *sndOpen(const SSnodeOpt *pOption); SSnode *sndOpen(const char *path, const SSnodeOpt *pOption);
/** /**
* @brief Stop Snode in Dnode. * @brief Stop Snode in Dnode.
...@@ -78,7 +79,14 @@ int32_t sndGetLoad(SSnode *pSnode, SSnodeLoad *pLoad); ...@@ -78,7 +79,14 @@ int32_t sndGetLoad(SSnode *pSnode, SSnodeLoad *pLoad);
* @param pRsp The response message * @param pRsp The response message
* @return int32_t 0 for success, -1 for failure * @return int32_t 0 for success, -1 for failure
*/ */
int32_t sndProcessWriteMsg(SSnode *pSnode, SRpcMsg *pMsg, SRpcMsg **pRsp); int32_t sndProcessMsg(SSnode *pSnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
/**
* @brief Drop a snode.
*
* @param path Path of the snode.
*/
void sndDestroy(const char *path);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -251,6 +251,8 @@ typedef struct STqMetaStore { ...@@ -251,6 +251,8 @@ typedef struct STqMetaStore {
STqMetaList* bucket[TQ_BUCKET_SIZE]; STqMetaList* bucket[TQ_BUCKET_SIZE];
// a table head // a table head
STqMetaList* unpersistHead; STqMetaList* unpersistHead;
// topics that are not connectted
STqMetaList* unconnectTopic;
// TODO:temporaral use, to be replaced by unified tfile // TODO:temporaral use, to be replaced by unified tfile
int fileFd; int fileFd;
......
...@@ -67,14 +67,14 @@ int32_t catalogUpdateDBVgroupCache(struct SCatalog* pCatalog, const char* dbName ...@@ -67,14 +67,14 @@ int32_t catalogUpdateDBVgroupCache(struct SCatalog* pCatalog, const char* dbName
/** /**
* Get a table's meta data. * Get a table's meta data.
* @param pCatalog (input, got with catalogGetHandle) * @param pCatalog (input, got with catalogGetHandle)
* @param pRpc (input, rpc object) * @param pTransporter (input, rpc object)
* @param pMgmtEps (input, mnode EPs) * @param pMgmtEps (input, mnode EPs)
* @param pDBName (input, full db name) * @param pDBName (input, full db name)
* @param pTableName (input, table name, NOT including db name) * @param pTableName (input, table name, NOT including db name)
* @param pTableMeta(output, table meta data, NEED to free it by calller) * @param pTableMeta(output, table meta data, NEED to free it by calller)
* @return error code * @return error code
*/ */
int32_t catalogGetTableMeta(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const char* pDBName, const char* pTableName, STableMeta** pTableMeta); int32_t catalogGetTableMeta(struct SCatalog* pCatalog, void * pTransporter, const SEpSet* pMgmtEps, const char* pDBName, const char* pTableName, STableMeta** pTableMeta);
/** /**
* Force renew a table's local cached meta data. * Force renew a table's local cached meta data.
......
...@@ -44,9 +44,12 @@ typedef struct SField { ...@@ -44,9 +44,12 @@ typedef struct SField {
} SField; } SField;
typedef struct SParseBasicCtx { typedef struct SParseBasicCtx {
const char *db;
int32_t acctId;
uint64_t requestId; uint64_t requestId;
int32_t acctId;
const char *db;
void *pTransporter;
SEpSet mgmtEpSet;
struct SCatalog *pCatalog;
} SParseBasicCtx; } SParseBasicCtx;
typedef struct SFieldInfo { typedef struct SFieldInfo {
...@@ -163,6 +166,7 @@ typedef struct SInsertStmtInfo { ...@@ -163,6 +166,7 @@ typedef struct SInsertStmtInfo {
typedef struct SDclStmtInfo { typedef struct SDclStmtInfo {
int16_t nodeType; int16_t nodeType;
int16_t msgType; int16_t msgType;
SEpSet epSet;
char* pMsg; char* pMsg;
int32_t msgLen; int32_t msgLen;
} SDclStmtInfo; } SDclStmtInfo;
......
...@@ -24,9 +24,6 @@ extern "C" { ...@@ -24,9 +24,6 @@ extern "C" {
typedef struct SParseContext { typedef struct SParseContext {
SParseBasicCtx ctx; SParseBasicCtx ctx;
void *pRpc;
struct SCatalog *pCatalog;
const SEpSet *pEpSet;
int8_t schemaAttached; // denote if submit block is built with table schema or not int8_t schemaAttached; // denote if submit block is built with table schema or not
const char *pSql; // sql string const char *pSql; // sql string
size_t sqlLen; // length of the sql string size_t sqlLen; // length of the sql string
...@@ -46,7 +43,7 @@ int32_t qParseQuerySql(SParseContext* pContext, SQueryNode** pQuery); ...@@ -46,7 +43,7 @@ int32_t qParseQuerySql(SParseContext* pContext, SQueryNode** pQuery);
bool qIsDdlQuery(const SQueryNode* pQuery); bool qIsDdlQuery(const SQueryNode* pQuery);
void qDestoryQuery(SQueryNode* pQuery); void qDestroyQuery(SQueryNode* pQuery);
/** /**
* Convert a normal sql statement to only query tags information to enable that the subscribe client can be aware quickly of the true vgroup ids that * Convert a normal sql statement to only query tags information to enable that the subscribe client can be aware quickly of the true vgroup ids that
......
...@@ -21,6 +21,7 @@ extern "C" { ...@@ -21,6 +21,7 @@ extern "C" {
#endif #endif
#include "tmsg.h" #include "tmsg.h"
#include "tarray.h"
#define QUERY_TYPE_MERGE 1 #define QUERY_TYPE_MERGE 1
#define QUERY_TYPE_PARTIAL 2 #define QUERY_TYPE_PARTIAL 2
...@@ -131,7 +132,7 @@ typedef struct SSubplan { ...@@ -131,7 +132,7 @@ typedef struct SSubplan {
typedef struct SQueryDag { typedef struct SQueryDag {
uint64_t queryId; uint64_t queryId;
int32_t numOfSubplans; int32_t numOfSubplans;
SArray *pSubplans; // Element is SArray*, and nested element is SSubplan. The execution level of subplan, starting from 0. SArray *pSubplans; // SArray*<SArray*<SSubplan*>>. The execution level of subplan, starting from 0.
} SQueryDag; } SQueryDag;
struct SQueryNode; struct SQueryNode;
...@@ -165,6 +166,9 @@ void qDestroySubplan(SSubplan* pSubplan); ...@@ -165,6 +166,9 @@ void qDestroySubplan(SSubplan* pSubplan);
*/ */
void qDestroyQueryDag(SQueryDag* pDag); void qDestroyQueryDag(SQueryDag* pDag);
char* qDagToString(const SQueryDag* pDag);
SQueryDag* qStringToDag(const char* pStr);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -81,7 +81,7 @@ typedef struct SDBVgroupInfo { ...@@ -81,7 +81,7 @@ typedef struct SDBVgroupInfo {
} SDBVgroupInfo; } SDBVgroupInfo;
typedef struct SUseDbOutput { typedef struct SUseDbOutput {
char db[TSDB_FULL_DB_NAME_LEN]; char db[TSDB_DB_FNAME_LEN];
SDBVgroupInfo dbVgroup; SDBVgroupInfo dbVgroup;
} SUseDbOutput; } SUseDbOutput;
......
...@@ -69,6 +69,7 @@ int32_t* taosGetErrno(); ...@@ -69,6 +69,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_CHECKSUM_ERROR TAOS_DEF_ERROR_CODE(0, 0x0107) #define TSDB_CODE_CHECKSUM_ERROR TAOS_DEF_ERROR_CODE(0, 0x0107)
#define TSDB_CODE_INVALID_MSG TAOS_DEF_ERROR_CODE(0, 0x0108) #define TSDB_CODE_INVALID_MSG TAOS_DEF_ERROR_CODE(0, 0x0108)
#define TSDB_CODE_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0109) #define TSDB_CODE_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0109)
#define TSDB_CODE_INVALID_PARA TAOS_DEF_ERROR_CODE(0, 0x010A)
#define TSDB_CODE_REF_NO_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0110) #define TSDB_CODE_REF_NO_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0110)
#define TSDB_CODE_REF_FULL TAOS_DEF_ERROR_CODE(0, 0x0111) #define TSDB_CODE_REF_FULL TAOS_DEF_ERROR_CODE(0, 0x0111)
#define TSDB_CODE_REF_ID_REMOVED TAOS_DEF_ERROR_CODE(0, 0x0112) #define TSDB_CODE_REF_ID_REMOVED TAOS_DEF_ERROR_CODE(0, 0x0112)
......
...@@ -149,7 +149,7 @@ do { \ ...@@ -149,7 +149,7 @@ do { \
#define IS_RELATION_OPTR(op) (((op) >= TSDB_RELATION_LESS) && ((op) < TSDB_RELATION_IN)) #define IS_RELATION_OPTR(op) (((op) >= TSDB_RELATION_LESS) && ((op) < TSDB_RELATION_IN))
#define IS_ARITHMETIC_OPTR(op) (((op) >= TSDB_BINARY_OP_ADD) && ((op) <= TSDB_BINARY_OP_REMAINDER)) #define IS_ARITHMETIC_OPTR(op) (((op) >= TSDB_BINARY_OP_ADD) && ((op) <= TSDB_BINARY_OP_REMAINDER))
#define TS_PATH_DELIMITER_LEN 1 #define TSDB_NAME_DELIMITER_LEN 1
#define TSDB_UNI_LEN 24 #define TSDB_UNI_LEN 24
#define TSDB_USER_LEN TSDB_UNI_LEN #define TSDB_USER_LEN TSDB_UNI_LEN
...@@ -165,7 +165,7 @@ do { \ ...@@ -165,7 +165,7 @@ do { \
#define TSDB_TABLE_NAME_LEN 193 // it is a null-terminated string #define TSDB_TABLE_NAME_LEN 193 // it is a null-terminated string
#define TSDB_TOPIC_NAME_LEN 193 // it is a null-terminated string #define TSDB_TOPIC_NAME_LEN 193 // it is a null-terminated string
#define TSDB_DB_NAME_LEN 65 #define TSDB_DB_NAME_LEN 65
#define TSDB_FULL_DB_NAME_LEN (TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN) #define TSDB_DB_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
#define TSDB_FUNC_NAME_LEN 65 #define TSDB_FUNC_NAME_LEN 65
#define TSDB_FUNC_COMMENT_LEN 4096 #define TSDB_FUNC_COMMENT_LEN 4096
...@@ -175,7 +175,7 @@ do { \ ...@@ -175,7 +175,7 @@ do { \
#define TSDB_FUNC_TYPE_AGGREGATE 2 #define TSDB_FUNC_TYPE_AGGREGATE 2
#define TSDB_TYPE_STR_MAX_LEN 32 #define TSDB_TYPE_STR_MAX_LEN 32
#define TSDB_TABLE_FNAME_LEN (TSDB_FULL_DB_NAME_LEN + TSDB_TABLE_NAME_LEN) #define TSDB_TABLE_FNAME_LEN (TSDB_DB_FNAME_LEN + TSDB_TABLE_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
#define TSDB_TOPIC_FNAME_LEN TSDB_TABLE_FNAME_LEN #define TSDB_TOPIC_FNAME_LEN TSDB_TABLE_FNAME_LEN
#define TSDB_COL_NAME_LEN 65 #define TSDB_COL_NAME_LEN 65
#define TSDB_MAX_SAVED_SQL_LEN TSDB_MAX_COLUMNS * 64 #define TSDB_MAX_SAVED_SQL_LEN TSDB_MAX_COLUMNS * 64
...@@ -317,7 +317,7 @@ do { \ ...@@ -317,7 +317,7 @@ do { \
#define TSDB_MAX_FIELD_LEN 16384 #define TSDB_MAX_FIELD_LEN 16384
#define TSDB_MAX_BINARY_LEN (TSDB_MAX_FIELD_LEN-TSDB_KEYSIZE) // keep 16384 #define TSDB_MAX_BINARY_LEN (TSDB_MAX_FIELD_LEN-TSDB_KEYSIZE) // keep 16384
#define TSDB_MAX_NCHAR_LEN (TSDB_MAX_FIELD_LEN-TSDB_KEYSIZE) // keep 16384 #define TSDB_MAX_NCHAR_LEN (TSDB_MAX_FIELD_LEN-TSDB_KEYSIZE) // keep 16384
#define PRIMARYKEY_TIMESTAMP_COL_ID 0 #define PRIMARYKEY_TIMESTAMP_COL_ID 1
#define TSDB_MAX_RPC_THREADS 5 #define TSDB_MAX_RPC_THREADS 5
......
...@@ -77,7 +77,7 @@ typedef struct SAppInfo { ...@@ -77,7 +77,7 @@ typedef struct SAppInfo {
typedef struct STscObj { typedef struct STscObj {
char user[TSDB_USER_LEN]; char user[TSDB_USER_LEN];
char pass[TSDB_PASSWORD_LEN]; char pass[TSDB_PASSWORD_LEN];
char db[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN]; char db[TSDB_DB_FNAME_LEN];
int32_t acctId; int32_t acctId;
uint32_t connId; uint32_t connId;
uint64_t id; // ref ID returned by taosAddRef uint64_t id; // ref ID returned by taosAddRef
......
...@@ -227,7 +227,7 @@ void taos_init_imp(void) { ...@@ -227,7 +227,7 @@ void taos_init_imp(void) {
rpcInit(); rpcInit();
SCatalogCfg cfg = {.enableVgroupCache = true, .maxDBCacheNum = 100, .maxTblCacheNum = 100}; SCatalogCfg cfg = {.maxDBCacheNum = 100, .maxTblCacheNum = 100};
catalogInit(&cfg); catalogInit(&cfg);
tscDebug("starting to initialize TAOS driver, local ep: %s", tsLocalEp); tscDebug("starting to initialize TAOS driver, local ep: %s", tsLocalEp);
......
...@@ -145,15 +145,32 @@ int32_t buildRequest(STscObj *pTscObj, const char *sql, int sqlLen, SRequestObj* ...@@ -145,15 +145,32 @@ int32_t buildRequest(STscObj *pTscObj, const char *sql, int sqlLen, SRequestObj*
} }
int32_t parseSql(SRequestObj* pRequest, SQueryNode** pQuery) { int32_t parseSql(SRequestObj* pRequest, SQueryNode** pQuery) {
STscObj* pTscObj = pRequest->pTscObj;
SParseContext cxt = { SParseContext cxt = {
.ctx = {.requestId = pRequest->requestId, .acctId = pRequest->pTscObj->acctId, .db = getConnectionDB(pRequest->pTscObj)}, .ctx = {.requestId = pRequest->requestId, .acctId = pTscObj->acctId, .db = getConnectionDB(pTscObj), .pTransporter = pTscObj->pTransporter},
.pSql = pRequest->sqlstr, .pSql = pRequest->sqlstr,
.sqlLen = pRequest->sqlLen, .sqlLen = pRequest->sqlLen,
.pMsg = pRequest->msgBuf, .pMsg = pRequest->msgBuf,
.msgLen = ERROR_MSG_BUF_DEFAULT_SIZE .msgLen = ERROR_MSG_BUF_DEFAULT_SIZE
}; };
int32_t code = qParseQuerySql(&cxt, pQuery); cxt.ctx.mgmtEpSet = getEpSet_s(&pTscObj->pAppInfo->mgmtEp);
// todo OPT performance
char buf[12] = {0};
sprintf(buf, "%"PRId64, pTscObj->pAppInfo->clusterId);
struct SCatalog* pCatalog = NULL;
int32_t code = catalogGetHandle(buf, &pCatalog);
if (code != TSDB_CODE_SUCCESS) {
tfree(cxt.ctx.db);
return code;
}
cxt.ctx.pCatalog = pCatalog;
code = qParseQuerySql(&cxt, pQuery);
tfree(cxt.ctx.db); tfree(cxt.ctx.db);
return code; return code;
} }
...@@ -165,52 +182,103 @@ int32_t execDdlQuery(SRequestObj* pRequest, SQueryNode* pQuery) { ...@@ -165,52 +182,103 @@ int32_t execDdlQuery(SRequestObj* pRequest, SQueryNode* pQuery) {
STscObj* pTscObj = pRequest->pTscObj; STscObj* pTscObj = pRequest->pTscObj;
SMsgSendInfo* body = buildSendMsgInfoImpl(pRequest);
SMsgSendInfo* pSendMsg = buildSendMsgInfoImpl(pRequest);
SEpSet* pEpSet = &pTscObj->pAppInfo->mgmtEp.epSet; SEpSet* pEpSet = &pTscObj->pAppInfo->mgmtEp.epSet;
if (pDcl->msgType == TDMT_VND_CREATE_TABLE) { if (pDcl->msgType == TDMT_VND_CREATE_TABLE) {
struct SCatalog* pCatalog = NULL; // struct SCatalog* pCatalog = NULL;
//
char buf[18] = {0}; // char buf[18] = {0};
sprintf(buf, "%" PRId64, pRequest->pTscObj->pAppInfo->clusterId); // sprintf(buf, "%" PRId64, pRequest->pTscObj->pAppInfo->clusterId);
int32_t code = catalogGetHandle(buf, &pCatalog); // int32_t code = catalogGetHandle(buf, &pCatalog);
if (code != TSDB_CODE_SUCCESS) { // if (code != TSDB_CODE_SUCCESS) {
return code; // return code;
// }
//
// SCreateTableMsg* pMsg = pSendMsg->msgInfo.pData;
//
// SName t = {0};
// tNameFromString(&t, pMsg->name, T_NAME_ACCT|T_NAME_DB|T_NAME_TABLE);
//
// char db[TSDB_DB_NAME_LEN + TSDB_NAME_DELIMITER_LEN + TSDB_ACCT_ID_LEN] = {0};
// tNameGetFullDbName(&t, db);
//
// SVgroupInfo info = {0};
// catalogGetTableHashVgroup(pCatalog, pRequest->pTscObj->pTransporter, pEpSet, db, tNameGetTableName(&t), &info);
//
int64_t transporterId = 0;
// SEpSet ep = {0};
// ep.inUse = info.inUse;
// ep.numOfEps = info.numOfEps;
// for(int32_t i = 0; i < ep.numOfEps; ++i) {
// ep.port[i] = info.epAddr[i].port;
// tstrncpy(ep.fqdn[i], info.epAddr[i].fqdn, tListLen(ep.fqdn[i]));
// }
asyncSendMsgToServer(pTscObj->pTransporter, &pDcl->epSet, &transporterId, pSendMsg);
} else {
int64_t transporterId = 0;
asyncSendMsgToServer(pTscObj->pTransporter, pEpSet, &transporterId, pSendMsg);
} }
SCreateTableMsg* pMsg = body->msgInfo.pData; tsem_wait(&pRequest->body.rspSem);
destroySendMsgInfo(pSendMsg);
return TSDB_CODE_SUCCESS;
}
int32_t scheduleQuery(SRequestObj* pRequest, SQueryDag* pDag, void** pJob) {
return scheduleAsyncExecJob(pRequest->pTscObj->pTransporter, NULL/*todo appInfo.xxx*/, pDag, pJob);
}
TAOS_RES *tmq_create_topic(TAOS* taos, const char* name, const char* sql, int sqlLen) {
STscObj* pTscObj = (STscObj*)taos;
SRequestObj* pRequest = NULL;
SQueryNode* pQuery = NULL;
SQueryDag* pDag = NULL;
char *dagStr = NULL;
SName t = {0}; terrno = TSDB_CODE_SUCCESS;
tNameFromString(&t, pMsg->name, T_NAME_ACCT|T_NAME_DB|T_NAME_TABLE);
char db[TSDB_DB_NAME_LEN + TS_PATH_DELIMITER_LEN + TSDB_ACCT_ID_LEN] = {0}; CHECK_CODE_GOTO(buildRequest(pTscObj, sql, sqlLen, &pRequest), _return);
tNameGetFullDbName(&t, db); CHECK_CODE_GOTO(parseSql(pRequest, &pQuery), _return);
//TODO: check sql valid
SVgroupInfo info = {0}; CHECK_CODE_GOTO(qCreateQueryDag(pQuery, &pDag), _return);
catalogGetTableHashVgroup(pCatalog, pRequest->pTscObj->pTransporter, pEpSet, db, tNameGetTableName(&t), &info);
int64_t transporterId = 0; dagStr = qDagToString(pDag);
SEpSet ep = {0}; if(dagStr == NULL) {
ep.inUse = info.inUse; //TODO
ep.numOfEps = info.numOfEps;
for(int32_t i = 0; i < ep.numOfEps; ++i) {
ep.port[i] = info.epAddr[i].port;
tstrncpy(ep.fqdn[i], info.epAddr[i].fqdn, tListLen(ep.fqdn[i]));
} }
asyncSendMsgToServer(pTscObj->pTransporter, &ep, &transporterId, body); SCMCreateTopicReq req = {
} else { .name = (char*)name,
.igExists = 0,
.phyPlan = dagStr,
};
void* buf = NULL;
int tlen = tSerializeSCMCreateTopicReq(&buf, &req);
pRequest->body.requestMsg = (SDataBuf){ .pData = buf, .len = tlen };
SMsgSendInfo* body = buildSendMsgInfoImpl(pRequest);
SEpSet* pEpSet = &pTscObj->pAppInfo->mgmtEp.epSet;
int64_t transporterId = 0; int64_t transporterId = 0;
asyncSendMsgToServer(pTscObj->pTransporter, pEpSet, &transporterId, body); asyncSendMsgToServer(pTscObj->pTransporter, pEpSet, &transporterId, body);
}
tsem_wait(&pRequest->body.rspSem); tsem_wait(&pRequest->body.rspSem);
destroySendMsgInfo(body); destroySendMsgInfo(body);
return TSDB_CODE_SUCCESS;
}
int32_t scheduleQuery(SRequestObj* pRequest, SQueryDag* pDag, void** pJob) { _return:
return scheduleAsyncExecJob(pRequest->pTscObj->pTransporter, NULL/*todo appInfo.xxx*/, pDag, pJob); qDestroyQuery(pQuery);
qDestroyQueryDag(pDag);
destroySendMsgInfo(body);
if (pRequest != NULL && terrno != TSDB_CODE_SUCCESS) {
pRequest->code = terrno;
}
return pRequest;
} }
TAOS_RES *taos_query_l(TAOS *taos, const char *sql, int sqlLen) { TAOS_RES *taos_query_l(TAOS *taos, const char *sql, int sqlLen) {
...@@ -240,7 +308,7 @@ TAOS_RES *taos_query_l(TAOS *taos, const char *sql, int sqlLen) { ...@@ -240,7 +308,7 @@ TAOS_RES *taos_query_l(TAOS *taos, const char *sql, int sqlLen) {
} }
_return: _return:
qDestoryQuery(pQuery); qDestroyQuery(pQuery);
qDestroyQueryDag(pDag); qDestroyQueryDag(pDag);
if (NULL != pRequest && TSDB_CODE_SUCCESS != terrno) { if (NULL != pRequest && TSDB_CODE_SUCCESS != terrno) {
pRequest->code = terrno; pRequest->code = terrno;
...@@ -332,7 +400,7 @@ static SMsgSendInfo* buildConnectMsg(SRequestObj *pRequest) { ...@@ -332,7 +400,7 @@ static SMsgSendInfo* buildConnectMsg(SRequestObj *pRequest) {
pMsgSendInfo->msgInfo.len = sizeof(SConnectMsg); pMsgSendInfo->msgInfo.len = sizeof(SConnectMsg);
pMsgSendInfo->requestObjRefId = pRequest->self; pMsgSendInfo->requestObjRefId = pRequest->self;
pMsgSendInfo->requestId = pRequest->requestId; pMsgSendInfo->requestId = pRequest->requestId;
pMsgSendInfo->fp = handleRequestRspFp[pMsgSendInfo->msgType]; pMsgSendInfo->fp = handleRequestRspFp[TMSG_INDEX(pMsgSendInfo->msgType)];
pMsgSendInfo->param = pRequest; pMsgSendInfo->param = pRequest;
SConnectMsg *pConnect = calloc(1, sizeof(SConnectMsg)); SConnectMsg *pConnect = calloc(1, sizeof(SConnectMsg));
......
...@@ -79,7 +79,7 @@ static int32_t buildRetrieveMnodeMsg(SRequestObj *pRequest, SMsgSendInfo* pMsgSe ...@@ -79,7 +79,7 @@ static int32_t buildRetrieveMnodeMsg(SRequestObj *pRequest, SMsgSendInfo* pMsgSe
pMsgSendInfo->msgInfo.len = sizeof(SRetrieveTableMsg); pMsgSendInfo->msgInfo.len = sizeof(SRetrieveTableMsg);
pMsgSendInfo->requestObjRefId = pRequest->self; pMsgSendInfo->requestObjRefId = pRequest->self;
pMsgSendInfo->param = pRequest; pMsgSendInfo->param = pRequest;
pMsgSendInfo->fp = handleRequestRspFp[pMsgSendInfo->msgType]; pMsgSendInfo->fp = handleRequestRspFp[TMSG_INDEX(pMsgSendInfo->msgType)];
SRetrieveTableMsg *pRetrieveMsg = calloc(1, sizeof(SRetrieveTableMsg)); SRetrieveTableMsg *pRetrieveMsg = calloc(1, sizeof(SRetrieveTableMsg));
if (pRetrieveMsg == NULL) { if (pRetrieveMsg == NULL) {
...@@ -104,7 +104,7 @@ SMsgSendInfo* buildSendMsgInfoImpl(SRequestObj *pRequest) { ...@@ -104,7 +104,7 @@ SMsgSendInfo* buildSendMsgInfoImpl(SRequestObj *pRequest) {
pMsgSendInfo->requestId = pRequest->requestId; pMsgSendInfo->requestId = pRequest->requestId;
pMsgSendInfo->param = pRequest; pMsgSendInfo->param = pRequest;
pMsgSendInfo->fp = (handleRequestRspFp[pRequest->type] == NULL)? genericRspCallback:handleRequestRspFp[pRequest->type]; pMsgSendInfo->fp = (handleRequestRspFp[TMSG_INDEX(pRequest->type)] == NULL)? genericRspCallback:handleRequestRspFp[TMSG_INDEX(pRequest->type)];
} }
return pMsgSendInfo; return pMsgSendInfo;
...@@ -139,7 +139,7 @@ int32_t processShowRsp(void* param, const SDataBuf* pMsg, int32_t code) { ...@@ -139,7 +139,7 @@ int32_t processShowRsp(void* param, const SDataBuf* pMsg, int32_t code) {
pFields[i].bytes = pSchema[i].bytes; pFields[i].bytes = pSchema[i].bytes;
} }
// pRequest->body.resInfo.pRspMsg = pMsg->pData; pRequest->body.resInfo.pRspMsg = pMsg->pData;
SReqResultInfo* pResInfo = &pRequest->body.resInfo; SReqResultInfo* pResInfo = &pRequest->body.resInfo;
pResInfo->fields = pFields; pResInfo->fields = pFields;
...@@ -290,11 +290,11 @@ void initMsgHandleFp() { ...@@ -290,11 +290,11 @@ void initMsgHandleFp() {
tscProcessMsgRsp[TSDB_SQL_SHOW_CREATE_DATABASE] = tscProcessShowCreateRsp; tscProcessMsgRsp[TSDB_SQL_SHOW_CREATE_DATABASE] = tscProcessShowCreateRsp;
#endif #endif
handleRequestRspFp[TDMT_MND_CONNECT] = processConnectRsp; handleRequestRspFp[TMSG_INDEX(TDMT_MND_CONNECT)] = processConnectRsp;
handleRequestRspFp[TDMT_MND_SHOW] = processShowRsp; handleRequestRspFp[TMSG_INDEX(TDMT_MND_SHOW)] = processShowRsp;
handleRequestRspFp[TDMT_MND_SHOW_RETRIEVE] = processRetrieveMnodeRsp; handleRequestRspFp[TMSG_INDEX(TDMT_MND_SHOW_RETRIEVE)] = processRetrieveMnodeRsp;
handleRequestRspFp[TDMT_MND_CREATE_DB] = processCreateDbRsp; handleRequestRspFp[TMSG_INDEX(TDMT_MND_CREATE_DB)] = processCreateDbRsp;
handleRequestRspFp[TDMT_MND_USE_DB] = processUseDbRsp; handleRequestRspFp[TMSG_INDEX(TDMT_MND_USE_DB)] = processUseDbRsp;
handleRequestRspFp[TDMT_MND_CREATE_STB] = processCreateTableRsp; handleRequestRspFp[TMSG_INDEX(TDMT_MND_CREATE_STB)] = processCreateTableRsp;
handleRequestRspFp[TDMT_MND_DROP_DB] = processDropDbRsp; handleRequestRspFp[TMSG_INDEX(TDMT_MND_DROP_DB)] = processDropDbRsp;
} }
\ No newline at end of file
...@@ -177,14 +177,14 @@ TEST(testCase, create_dnode_Test) { ...@@ -177,14 +177,14 @@ TEST(testCase, create_dnode_Test) {
if (taos_errno(pRes) != 0) { if (taos_errno(pRes) != 0) {
printf("error in create dnode, reason:%s\n", taos_errstr(pRes)); printf("error in create dnode, reason:%s\n", taos_errstr(pRes));
} }
taos_free_result(pRes);
TAOS_FIELD* pFields = taos_fetch_fields(pRes); pRes = taos_query(pConn, "create dnode 1.1.1.1 port 9000");
ASSERT_TRUE(pFields == NULL); if (taos_errno(pRes) != 0) {
printf("failed to create dnode, reason:%s\n", taos_errstr(pRes));
int32_t numOfFields = taos_num_fields(pRes); }
ASSERT_EQ(numOfFields, 0);
taos_free_result(pRes); taos_free_result(pRes);
taos_close(pConn); taos_close(pConn);
} }
...@@ -399,6 +399,41 @@ TEST(testCase, drop_stable_Test) { ...@@ -399,6 +399,41 @@ TEST(testCase, drop_stable_Test) {
taos_close(pConn); taos_close(pConn);
} }
TEST(testCase, create_topic_Test) {
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
assert(pConn != NULL);
TAOS_RES* pRes = taos_query(pConn, "create database abc1");
if (taos_errno(pRes) != 0) {
printf("error in create db, reason:%s\n", taos_errstr(pRes));
}
taos_free_result(pRes);
pRes = taos_query(pConn, "use abc1");
if (taos_errno(pRes) != 0) {
printf("error in use db, reason:%s\n", taos_errstr(pRes));
}
taos_free_result(pRes);
pRes = taos_query(pConn, "create stable st1(ts timestamp, k int) tags(a int)");
if (taos_errno(pRes) != 0) {
printf("error in create stable, reason:%s\n", taos_errstr(pRes));
}
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
ASSERT_TRUE(pFields == NULL);
int32_t numOfFields = taos_num_fields(pRes);
ASSERT_EQ(numOfFields, 0);
taos_free_result(pRes);
char* sql = "select * from st1";
tmq_create_topic(pConn, "test_topic_1", sql, strlen(sql));
taos_close(pConn);
}
//TEST(testCase, show_table_Test) { //TEST(testCase, show_table_Test) {
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); // TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
// assert(pConn != NULL); // assert(pConn != NULL);
......
...@@ -39,3 +39,12 @@ void updateEpSet_s(SCorEpSet *pEpSet, SEpSet *pNewEpSet) { ...@@ -39,3 +39,12 @@ void updateEpSet_s(SCorEpSet *pEpSet, SEpSet *pNewEpSet) {
taosCorEndWrite(&pEpSet->version); taosCorEndWrite(&pEpSet->version);
} }
SEpSet getEpSet_s(SCorEpSet *pEpSet) {
SEpSet ep = {0};
taosCorBeginRead(&pEpSet->version);
ep = pEpSet->epSet;
taosCorEndRead(&pEpSet->version);
return ep;
}
...@@ -110,7 +110,7 @@ int32_t tNameExtractFullName(const SName* name, char* dst) { ...@@ -110,7 +110,7 @@ int32_t tNameExtractFullName(const SName* name, char* dst) {
return -1; return -1;
} }
int32_t len = snprintf(dst, TSDB_FULL_DB_NAME_LEN, "%d.%s", name->acctId, name->dbname); int32_t len = snprintf(dst, TSDB_DB_FNAME_LEN, "%d.%s", name->acctId, name->dbname);
size_t tnameLen = strlen(name->tname); size_t tnameLen = strlen(name->tname);
if (tnameLen > 0) { if (tnameLen > 0) {
...@@ -134,10 +134,10 @@ int32_t tNameLen(const SName* name) { ...@@ -134,10 +134,10 @@ int32_t tNameLen(const SName* name) {
if (name->type == TSDB_DB_NAME_T) { if (name->type == TSDB_DB_NAME_T) {
assert(len2 == 0); assert(len2 == 0);
return len + len1 + TS_PATH_DELIMITER_LEN; return len + len1 + TSDB_NAME_DELIMITER_LEN;
} else { } else {
assert(len2 > 0); assert(len2 > 0);
return len + len1 + len2 + TS_PATH_DELIMITER_LEN * 2; return len + len1 + len2 + TSDB_NAME_DELIMITER_LEN * 2;
} }
} }
...@@ -171,8 +171,7 @@ int32_t tNameGetDbName(const SName* name, char* dst) { ...@@ -171,8 +171,7 @@ int32_t tNameGetDbName(const SName* name, char* dst) {
int32_t tNameGetFullDbName(const SName* name, char* dst) { int32_t tNameGetFullDbName(const SName* name, char* dst) {
assert(name != NULL && dst != NULL); assert(name != NULL && dst != NULL);
snprintf(dst, TSDB_ACCT_ID_LEN + TS_PATH_DELIMITER_LEN + TSDB_DB_NAME_LEN, // there is a over write risk snprintf(dst, TSDB_DB_FNAME_LEN, "%d.%s", name->acctId, name->dbname);
"%d.%s", name->acctId, name->dbname);
return 0; return 0;
} }
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "taos.h" #include "taos.h"
#include "taosdef.h" #include "taosdef.h"
#include "thash.h"
#include "ttime.h" #include "ttime.h"
#include "ttokendef.h" #include "ttokendef.h"
#include "ttypes.h" #include "ttypes.h"
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include "bndInt.h" #include "bndInt.h"
SBnode *bndOpen(const SBnodeOpt *pOption) { SBnode *bndOpen(const char *path, const SBnodeOpt *pOption) {
SBnode *pBnode = calloc(1, sizeof(SBnode)); SBnode *pBnode = calloc(1, sizeof(SBnode));
return pBnode; return pBnode;
} }
...@@ -25,3 +25,5 @@ void bndClose(SBnode *pBnode) { free(pBnode); } ...@@ -25,3 +25,5 @@ void bndClose(SBnode *pBnode) { free(pBnode); }
int32_t bndGetLoad(SBnode *pBnode, SBnodeLoad *pLoad) { return 0; } int32_t bndGetLoad(SBnode *pBnode, SBnodeLoad *pLoad) { return 0; }
int32_t bndProcessWMsgs(SBnode *pBnode, SArray *pMsgs) { return 0; } int32_t bndProcessWMsgs(SBnode *pBnode, SArray *pMsgs) { return 0; }
void bndDestroy(const char *path) {}
...@@ -24,7 +24,7 @@ extern "C" { ...@@ -24,7 +24,7 @@ extern "C" {
int32_t dndInitBnode(SDnode *pDnode); int32_t dndInitBnode(SDnode *pDnode);
void dndCleanupBnode(SDnode *pDnode); void dndCleanupBnode(SDnode *pDnode);
ioid dndProcessBnodeWriteMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet); void dndProcessBnodeWriteMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet);
int32_t dndProcessCreateBnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg); int32_t dndProcessCreateBnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg);
int32_t dndProcessDropBnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg); int32_t dndProcessDropBnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg);
......
...@@ -54,8 +54,23 @@ extern int32_t dDebugFlag; ...@@ -54,8 +54,23 @@ extern int32_t dDebugFlag;
#define dTrace(...) { if (dDebugFlag & DEBUG_TRACE) { taosPrintLog("DND ", dDebugFlag, __VA_ARGS__); }} #define dTrace(...) { if (dDebugFlag & DEBUG_TRACE) { taosPrintLog("DND ", dDebugFlag, __VA_ARGS__); }}
typedef enum { DND_STAT_INIT, DND_STAT_RUNNING, DND_STAT_STOPPED } EStat; typedef enum { DND_STAT_INIT, DND_STAT_RUNNING, DND_STAT_STOPPED } EStat;
typedef enum { DND_WORKER_SINGLE, DND_WORKER_MULTI } EWorkerType;
typedef void (*DndMsgFp)(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEps); typedef void (*DndMsgFp)(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEps);
typedef struct {
EWorkerType type;
const char *name;
int32_t minNum;
int32_t maxNum;
void *queueFp;
SDnode *pDnode;
taos_queue queue;
union {
SWorkerPool pool;
SMWorkerPool mpool;
};
} SDnodeWorker;
typedef struct { typedef struct {
char *dnode; char *dnode;
char *mnode; char *mnode;
...@@ -85,53 +100,42 @@ typedef struct { ...@@ -85,53 +100,42 @@ typedef struct {
int32_t refCount; int32_t refCount;
int8_t deployed; int8_t deployed;
int8_t dropped; int8_t dropped;
SMnode *pMnode;
SRWLatch latch;
SDnodeWorker readWorker;
SDnodeWorker writeWorker;
SDnodeWorker syncWorker;
int8_t replica; int8_t replica;
int8_t selfIndex; int8_t selfIndex;
SReplica replicas[TSDB_MAX_REPLICA]; SReplica replicas[TSDB_MAX_REPLICA];
char *file;
SMnode *pMnode;
SRWLatch latch;
taos_queue pReadQ;
taos_queue pWriteQ;
taos_queue pSyncQ;
SWorkerPool readPool;
SWorkerPool writePool;
SWorkerPool syncPool;
} SMnodeMgmt; } SMnodeMgmt;
typedef struct { typedef struct {
int32_t refCount; int32_t refCount;
int8_t deployed; int8_t deployed;
int8_t dropped; int8_t dropped;
char *file;
SQnode *pQnode; SQnode *pQnode;
SRWLatch latch; SRWLatch latch;
taos_queue pQueryQ; SDnodeWorker queryWorker;
taos_queue pFetchQ; SDnodeWorker fetchWorker;
SWorkerPool queryPool;
SWorkerPool fetchPool;
} SQnodeMgmt; } SQnodeMgmt;
typedef struct { typedef struct {
int32_t refCount; int32_t refCount;
int8_t deployed; int8_t deployed;
int8_t dropped; int8_t dropped;
char *file;
SSnode *pSnode; SSnode *pSnode;
SRWLatch latch; SRWLatch latch;
taos_queue pWriteQ; SDnodeWorker writeWorker;
SWorkerPool writePool;
} SSnodeMgmt; } SSnodeMgmt;
typedef struct { typedef struct {
int32_t refCount; int32_t refCount;
int8_t deployed; int8_t deployed;
int8_t dropped; int8_t dropped;
char *file;
SBnode *pBnode; SBnode *pBnode;
SRWLatch latch; SRWLatch latch;
taos_queue pWriteQ; SDnodeWorker writeWorker;
SMWorkerPool writePool;
} SBnodeMgmt; } SBnodeMgmt;
typedef struct { typedef struct {
......
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_DND_WORKER_H_
#define _TD_DND_WORKER_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "dndInt.h"
int32_t dndInitWorker(SDnode *pDnode, SDnodeWorker *pWorker, EWorkerType type, const char *name, int32_t minNum,
int32_t maxNum, void *queueFp);
void dndCleanupWorker(SDnodeWorker *pWorker);
int32_t dndWriteMsgToWorker(SDnodeWorker *pWorker, void *pCont, int32_t contLen);
#ifdef __cplusplus
}
#endif
#endif /*_TD_DND_WORKER_H_*/
\ No newline at end of file
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http:www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "dndBnode.h"
#include "dndDnode.h"
#include "dndTransport.h"
#include "dndWorker.h"
static void dndProcessBnodeQueue(SDnode *pDnode, taos_qall qall, int32_t numOfMsgs);
static SBnode *dndAcquireBnode(SDnode *pDnode) {
SBnodeMgmt *pMgmt = &pDnode->bmgmt;
SBnode *pBnode = NULL;
int32_t refCount = 0;
taosRLockLatch(&pMgmt->latch);
if (pMgmt->deployed && !pMgmt->dropped) {
refCount = atomic_add_fetch_32(&pMgmt->refCount, 1);
pBnode = pMgmt->pBnode;
} else {
terrno = TSDB_CODE_DND_BNODE_NOT_DEPLOYED;
}
taosRUnLockLatch(&pMgmt->latch);
if (pBnode != NULL) {
dTrace("acquire bnode, refCount:%d", refCount);
}
return pBnode;
}
static void dndReleaseBnode(SDnode *pDnode, SBnode *pBnode) {
SBnodeMgmt *pMgmt = &pDnode->bmgmt;
int32_t refCount = 0;
taosRLockLatch(&pMgmt->latch);
if (pBnode != NULL) {
refCount = atomic_sub_fetch_32(&pMgmt->refCount, 1);
}
taosRUnLockLatch(&pMgmt->latch);
if (pBnode != NULL) {
dTrace("release bnode, refCount:%d", refCount);
}
}
static int32_t dndReadBnodeFile(SDnode *pDnode) {
SBnodeMgmt *pMgmt = &pDnode->bmgmt;
int32_t code = TSDB_CODE_DND_BNODE_READ_FILE_ERROR;
int32_t len = 0;
int32_t maxLen = 4096;
char *content = calloc(1, maxLen + 1);
cJSON *root = NULL;
char file[PATH_MAX + 20];
snprintf(file, PATH_MAX + 20, "%s/bnode.json", pDnode->dir.dnode);
FILE *fp = fopen(file, "r");
if (fp == NULL) {
dDebug("file %s not exist", file);
code = 0;
goto PRASE_BNODE_OVER;
}
len = (int32_t)fread(content, 1, maxLen, fp);
if (len <= 0) {
dError("failed to read %s since content is null", file);
goto PRASE_BNODE_OVER;
}
content[len] = 0;
root = cJSON_Parse(content);
if (root == NULL) {
dError("failed to read %s since invalid json format", file);
goto PRASE_BNODE_OVER;
}
cJSON *deployed = cJSON_GetObjectItem(root, "deployed");
if (!deployed || deployed->type != cJSON_Number) {
dError("failed to read %s since deployed not found", file);
goto PRASE_BNODE_OVER;
}
pMgmt->deployed = deployed->valueint;
cJSON *dropped = cJSON_GetObjectItem(root, "dropped");
if (!dropped || dropped->type != cJSON_Number) {
dError("failed to read %s since dropped not found", file);
goto PRASE_BNODE_OVER;
}
pMgmt->dropped = dropped->valueint;
code = 0;
dDebug("succcessed to read file %s, deployed:%d dropped:%d", file, pMgmt->deployed, pMgmt->dropped);
PRASE_BNODE_OVER:
if (content != NULL) free(content);
if (root != NULL) cJSON_Delete(root);
if (fp != NULL) fclose(fp);
terrno = code;
return code;
}
static int32_t dndWriteBnodeFile(SDnode *pDnode) {
SBnodeMgmt *pMgmt = &pDnode->bmgmt;
char file[PATH_MAX + 20];
snprintf(file, PATH_MAX + 20, "%s/bnode.json", pDnode->dir.dnode);
FILE *fp = fopen(file, "w");
if (fp == NULL) {
terrno = TSDB_CODE_DND_BNODE_WRITE_FILE_ERROR;
dError("failed to write %s since %s", file, terrstr());
return -1;
}
int32_t len = 0;
int32_t maxLen = 4096;
char *content = calloc(1, maxLen + 1);
len += snprintf(content + len, maxLen - len, "{\n");
len += snprintf(content + len, maxLen - len, " \"deployed\": %d,\n", pMgmt->deployed);
len += snprintf(content + len, maxLen - len, " \"dropped\": %d\n", pMgmt->dropped);
len += snprintf(content + len, maxLen - len, "}\n");
fwrite(content, 1, len, fp);
taosFsyncFile(fileno(fp));
fclose(fp);
free(content);
char realfile[PATH_MAX + 20];
snprintf(realfile, PATH_MAX + 20, "%s/bnode.json", pDnode->dir.dnode);
if (taosRenameFile(file, realfile) != 0) {
terrno = TSDB_CODE_DND_BNODE_WRITE_FILE_ERROR;
dError("failed to rename %s since %s", file, terrstr());
return -1;
}
dInfo("successed to write %s, deployed:%d dropped:%d", realfile, pMgmt->deployed, pMgmt->dropped);
return 0;
}
static int32_t dndStartBnodeWorker(SDnode *pDnode) {
SBnodeMgmt *pMgmt = &pDnode->bmgmt;
if (dndInitWorker(pDnode, &pMgmt->writeWorker, DND_WORKER_MULTI, "bnode-write", 0, 1, dndProcessBnodeQueue) != 0) {
dError("failed to start bnode write worker since %s", terrstr());
return -1;
}
return 0;
}
static void dndStopBnodeWorker(SDnode *pDnode) {
SBnodeMgmt *pMgmt = &pDnode->bmgmt;
taosWLockLatch(&pMgmt->latch);
pMgmt->deployed = 0;
taosWUnLockLatch(&pMgmt->latch);
while (pMgmt->refCount > 1) {
taosMsleep(10);
}
dndCleanupWorker(&pMgmt->writeWorker);
}
static void dndBuildBnodeOption(SDnode *pDnode, SBnodeOpt *pOption) {
pOption->pDnode = pDnode;
pOption->sendMsgToDnodeFp = dndSendMsgToDnode;
pOption->sendMsgToMnodeFp = dndSendMsgToMnode;
pOption->sendRedirectMsgFp = dndSendRedirectMsg;
pOption->dnodeId = dndGetDnodeId(pDnode);
pOption->clusterId = dndGetClusterId(pDnode);
pOption->cfg.sver = pDnode->opt.sver;
}
static int32_t dndOpenBnode(SDnode *pDnode) {
SBnodeMgmt *pMgmt = &pDnode->bmgmt;
SBnodeOpt option = {0};
dndBuildBnodeOption(pDnode, &option);
SBnode *pBnode = bndOpen(pDnode->dir.bnode, &option);
if (pBnode == NULL) {
dError("failed to open bnode since %s", terrstr());
return -1;
}
if (dndStartBnodeWorker(pDnode) != 0) {
dError("failed to start bnode worker since %s", terrstr());
bndClose(pBnode);
return -1;
}
pMgmt->deployed = 1;
if (dndWriteBnodeFile(pDnode) != 0) {
pMgmt->deployed = 0;
dError("failed to write bnode file since %s", terrstr());
dndStopBnodeWorker(pDnode);
bndClose(pBnode);
return -1;
}
taosWLockLatch(&pMgmt->latch);
pMgmt->pBnode = pBnode;
taosWUnLockLatch(&pMgmt->latch);
dInfo("bnode open successfully");
return 0;
}
static int32_t dndDropBnode(SDnode *pDnode) {
SBnodeMgmt *pMgmt = &pDnode->bmgmt;
SBnode *pBnode = dndAcquireBnode(pDnode);
if (pBnode == NULL) {
dError("failed to drop bnode since %s", terrstr());
return -1;
}
taosRLockLatch(&pMgmt->latch);
pMgmt->dropped = 1;
taosRUnLockLatch(&pMgmt->latch);
if (dndWriteBnodeFile(pDnode) != 0) {
taosRLockLatch(&pMgmt->latch);
pMgmt->dropped = 0;
taosRUnLockLatch(&pMgmt->latch);
dndReleaseBnode(pDnode, pBnode);
dError("failed to drop bnode since %s", terrstr());
return -1;
}
dndReleaseBnode(pDnode, pBnode);
dndStopBnodeWorker(pDnode);
pMgmt->deployed = 0;
dndWriteBnodeFile(pDnode);
bndClose(pBnode);
pMgmt->pBnode = NULL;
bndDestroy(pDnode->dir.bnode);
return 0;
}
int32_t dndProcessCreateBnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
SCreateBnodeInMsg *pMsg = pRpcMsg->pCont;
pMsg->dnodeId = htonl(pMsg->dnodeId);
if (pMsg->dnodeId != dndGetDnodeId(pDnode)) {
terrno = TSDB_CODE_DND_BNODE_ID_INVALID;
return -1;
} else {
return dndOpenBnode(pDnode);
}
}
int32_t dndProcessDropBnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
SDropBnodeInMsg *pMsg = pRpcMsg->pCont;
pMsg->dnodeId = htonl(pMsg->dnodeId);
if (pMsg->dnodeId != dndGetDnodeId(pDnode)) {
terrno = TSDB_CODE_DND_BNODE_ID_INVALID;
return -1;
} else {
return dndDropBnode(pDnode);
}
}
static void dndSendBnodeErrorRsp(SRpcMsg *pMsg, int32_t code) {
SRpcMsg rpcRsp = {.handle = pMsg->handle, .ahandle = pMsg->ahandle, .code = code};
rpcSendResponse(&rpcRsp);
rpcFreeCont(pMsg->pCont);
taosFreeQitem(pMsg);
}
static void dndSendBnodeErrorRsps(taos_qall qall, int32_t numOfMsgs, int32_t code) {
for (int32_t i = 0; i < numOfMsgs; ++i) {
SRpcMsg *pMsg = NULL;
taosGetQitem(qall, (void **)&pMsg);
dndSendBnodeErrorRsp(pMsg, code);
}
}
static void dndProcessBnodeQueue(SDnode *pDnode, taos_qall qall, int32_t numOfMsgs) {
SBnode *pBnode = dndAcquireBnode(pDnode);
if (pBnode == NULL) {
dndSendBnodeErrorRsps(qall, numOfMsgs, TSDB_CODE_OUT_OF_MEMORY);
return;
}
SArray *pArray = taosArrayInit(numOfMsgs, sizeof(SRpcMsg *));
if (pArray == NULL) {
dndReleaseBnode(pDnode, pBnode);
dndSendBnodeErrorRsps(qall, numOfMsgs, TSDB_CODE_OUT_OF_MEMORY);
return;
}
for (int32_t i = 0; i < numOfMsgs; ++i) {
SRpcMsg *pMsg = NULL;
taosGetQitem(qall, (void **)&pMsg);
void *ptr = taosArrayPush(pArray, &pMsg);
if (ptr == NULL) {
dndSendBnodeErrorRsp(pMsg, TSDB_CODE_OUT_OF_MEMORY);
}
}
bndProcessWMsgs(pBnode, pArray);
for (size_t i = 0; i < numOfMsgs; i++) {
SRpcMsg *pMsg = *(SRpcMsg **)taosArrayGet(pArray, i);
rpcFreeCont(pMsg->pCont);
taosFreeQitem(pMsg);
}
taosArrayDestroy(pArray);
dndReleaseBnode(pDnode, pBnode);
}
static void dndWriteBnodeMsgToWorker(SDnode *pDnode, SDnodeWorker *pWorker, SRpcMsg *pMsg) {
int32_t code = TSDB_CODE_DND_BNODE_NOT_DEPLOYED;
SBnode *pBnode = dndAcquireBnode(pDnode);
if (pBnode != NULL) {
code = dndWriteMsgToWorker(pWorker, pMsg, sizeof(SRpcMsg));
}
dndReleaseBnode(pDnode, pBnode);
if (code != 0) {
if (pMsg->msgType & 1u) {
SRpcMsg rsp = {.handle = pMsg->handle, .ahandle = pMsg->ahandle, .code = code};
rpcSendResponse(&rsp);
}
rpcFreeCont(pMsg->pCont);
}
}
void dndProcessBnodeWriteMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) {
dndWriteBnodeMsgToWorker(pDnode, &pDnode->bmgmt.writeWorker, pMsg);
}
int32_t dndInitBnode(SDnode *pDnode) {
SBnodeMgmt *pMgmt = &pDnode->bmgmt;
taosInitRWLatch(&pMgmt->latch);
if (dndReadBnodeFile(pDnode) != 0) {
return -1;
}
if (pMgmt->dropped) {
dInfo("bnode has been deployed and needs to be deleted");
bndDestroy(pDnode->dir.bnode);
return 0;
}
if (!pMgmt->deployed) return 0;
return dndOpenBnode(pDnode);
}
void dndCleanupBnode(SDnode *pDnode) {
SBnodeMgmt *pMgmt = &pDnode->bmgmt;
if (pMgmt->pBnode) {
dndStopBnodeWorker(pDnode);
bndClose(pMgmt->pBnode);
pMgmt->pBnode = NULL;
}
}
...@@ -17,42 +17,9 @@ ...@@ -17,42 +17,9 @@
#include "dndMnode.h" #include "dndMnode.h"
#include "dndDnode.h" #include "dndDnode.h"
#include "dndTransport.h" #include "dndTransport.h"
#include "dndWorker.h"
static int32_t dndInitMnodeReadWorker(SDnode *pDnode); static void dndProcessMnodeQueue(SDnode *pDnode, SMnodeMsg *pMsg);
static int32_t dndInitMnodeWriteWorker(SDnode *pDnode);
static int32_t dndInitMnodeSyncWorker(SDnode *pDnode);
static void dndCleanupMnodeReadWorker(SDnode *pDnode);
static void dndCleanupMnodeWriteWorker(SDnode *pDnode);
static void dndCleanupMnodeSyncWorker(SDnode *pDnode);
static void dndCleanupMnodeMgmtWorker(SDnode *pDnode);
static int32_t dndAllocMnodeReadQueue(SDnode *pDnode);
static int32_t dndAllocMnodeWriteQueue(SDnode *pDnode);
static int32_t dndAllocMnodeSyncQueue(SDnode *pDnode);
static void dndFreeMnodeReadQueue(SDnode *pDnode);
static void dndFreeMnodeWriteQueue(SDnode *pDnode);
static void dndFreeMnodeSyncQueue(SDnode *pDnode);
static void dndFreeMnodeMgmtQueue(SDnode *pDnode);
static void dndProcessMnodeReadQueue(SDnode *pDnode, SMnodeMsg *pMsg);
static void dndProcessMnodeWriteQueue(SDnode *pDnode, SMnodeMsg *pMsg);
static void dndProcessMnodeSyncQueue(SDnode *pDnode, SMnodeMsg *pMsg);
static int32_t dndWriteMnodeMsgToQueue(SMnode *pMnode, taos_queue pQueue, SRpcMsg *pRpcMsg);
void dndProcessMnodeReadMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet);
void dndProcessMnodeWriteMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet);
void dndProcessMnodeSyncMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet);
static int32_t dndStartMnodeWorker(SDnode *pDnode);
static void dndStopMnodeWorker(SDnode *pDnode);
static SMnode *dndAcquireMnode(SDnode *pDnode);
static void dndReleaseMnode(SDnode *pDnode, SMnode *pMnode);
static int32_t dndReadMnodeFile(SDnode *pDnode);
static int32_t dndWriteMnodeFile(SDnode *pDnode);
static int32_t dndOpenMnode(SDnode *pDnode, SMnodeOpt *pOption);
static int32_t dndAlterMnode(SDnode *pDnode, SMnodeOpt *pOption);
static int32_t dndDropMnode(SDnode *pDnode);
static SMnode *dndAcquireMnode(SDnode *pDnode) { static SMnode *dndAcquireMnode(SDnode *pDnode) {
SMnodeMgmt *pMgmt = &pDnode->mmgmt; SMnodeMgmt *pMgmt = &pDnode->mmgmt;
...@@ -97,49 +64,52 @@ static int32_t dndReadMnodeFile(SDnode *pDnode) { ...@@ -97,49 +64,52 @@ static int32_t dndReadMnodeFile(SDnode *pDnode) {
char *content = calloc(1, maxLen + 1); char *content = calloc(1, maxLen + 1);
cJSON *root = NULL; cJSON *root = NULL;
FILE *fp = fopen(pMgmt->file, "r"); char file[PATH_MAX + 20];
snprintf(file, PATH_MAX + 20, "%s/mnode.json", pDnode->dir.dnode);
FILE *fp = fopen(file, "r");
if (fp == NULL) { if (fp == NULL) {
dDebug("file %s not exist", pMgmt->file); dDebug("file %s not exist", file);
code = 0; code = 0;
goto PRASE_MNODE_OVER; goto PRASE_MNODE_OVER;
} }
len = (int32_t)fread(content, 1, maxLen, fp); len = (int32_t)fread(content, 1, maxLen, fp);
if (len <= 0) { if (len <= 0) {
dError("failed to read %s since content is null", pMgmt->file); dError("failed to read %s since content is null", file);
goto PRASE_MNODE_OVER; goto PRASE_MNODE_OVER;
} }
content[len] = 0; content[len] = 0;
root = cJSON_Parse(content); root = cJSON_Parse(content);
if (root == NULL) { if (root == NULL) {
dError("failed to read %s since invalid json format", pMgmt->file); dError("failed to read %s since invalid json format", file);
goto PRASE_MNODE_OVER; goto PRASE_MNODE_OVER;
} }
cJSON *deployed = cJSON_GetObjectItem(root, "deployed"); cJSON *deployed = cJSON_GetObjectItem(root, "deployed");
if (!deployed || deployed->type != cJSON_Number) { if (!deployed || deployed->type != cJSON_Number) {
dError("failed to read %s since deployed not found", pMgmt->file); dError("failed to read %s since deployed not found", file);
goto PRASE_MNODE_OVER; goto PRASE_MNODE_OVER;
} }
pMgmt->deployed = deployed->valueint; pMgmt->deployed = deployed->valueint;
cJSON *dropped = cJSON_GetObjectItem(root, "dropped"); cJSON *dropped = cJSON_GetObjectItem(root, "dropped");
if (!dropped || dropped->type != cJSON_Number) { if (!dropped || dropped->type != cJSON_Number) {
dError("failed to read %s since dropped not found", pMgmt->file); dError("failed to read %s since dropped not found", file);
goto PRASE_MNODE_OVER; goto PRASE_MNODE_OVER;
} }
pMgmt->dropped = dropped->valueint; pMgmt->dropped = dropped->valueint;
cJSON *mnodes = cJSON_GetObjectItem(root, "mnodes"); cJSON *mnodes = cJSON_GetObjectItem(root, "mnodes");
if (!mnodes || mnodes->type != cJSON_Array) { if (!mnodes || mnodes->type != cJSON_Array) {
dError("failed to read %s since nodes not found", pMgmt->file); dError("failed to read %s since nodes not found", file);
goto PRASE_MNODE_OVER; goto PRASE_MNODE_OVER;
} }
pMgmt->replica = cJSON_GetArraySize(mnodes); pMgmt->replica = cJSON_GetArraySize(mnodes);
if (pMgmt->replica <= 0 || pMgmt->replica > TSDB_MAX_REPLICA) { if (pMgmt->replica <= 0 || pMgmt->replica > TSDB_MAX_REPLICA) {
dError("failed to read %s since mnodes size %d invalid", pMgmt->file, pMgmt->replica); dError("failed to read %s since mnodes size %d invalid", file, pMgmt->replica);
goto PRASE_MNODE_OVER; goto PRASE_MNODE_OVER;
} }
...@@ -151,28 +121,28 @@ static int32_t dndReadMnodeFile(SDnode *pDnode) { ...@@ -151,28 +121,28 @@ static int32_t dndReadMnodeFile(SDnode *pDnode) {
cJSON *id = cJSON_GetObjectItem(node, "id"); cJSON *id = cJSON_GetObjectItem(node, "id");
if (!id || id->type != cJSON_Number) { if (!id || id->type != cJSON_Number) {
dError("failed to read %s since id not found", pMgmt->file); dError("failed to read %s since id not found", file);
goto PRASE_MNODE_OVER; goto PRASE_MNODE_OVER;
} }
pReplica->id = id->valueint; pReplica->id = id->valueint;
cJSON *fqdn = cJSON_GetObjectItem(node, "fqdn"); cJSON *fqdn = cJSON_GetObjectItem(node, "fqdn");
if (!fqdn || fqdn->type != cJSON_String || fqdn->valuestring == NULL) { if (!fqdn || fqdn->type != cJSON_String || fqdn->valuestring == NULL) {
dError("failed to read %s since fqdn not found", pMgmt->file); dError("failed to read %s since fqdn not found", file);
goto PRASE_MNODE_OVER; goto PRASE_MNODE_OVER;
} }
tstrncpy(pReplica->fqdn, fqdn->valuestring, TSDB_FQDN_LEN); tstrncpy(pReplica->fqdn, fqdn->valuestring, TSDB_FQDN_LEN);
cJSON *port = cJSON_GetObjectItem(node, "port"); cJSON *port = cJSON_GetObjectItem(node, "port");
if (!port || port->type != cJSON_Number) { if (!port || port->type != cJSON_Number) {
dError("failed to read %s since port not found", pMgmt->file); dError("failed to read %s since port not found", file);
goto PRASE_MNODE_OVER; goto PRASE_MNODE_OVER;
} }
pReplica->port = port->valueint; pReplica->port = port->valueint;
} }
code = 0; code = 0;
dDebug("succcessed to read file %s, deployed:%d dropped:%d", pMgmt->file, pMgmt->deployed, pMgmt->dropped); dDebug("succcessed to read file %s, deployed:%d dropped:%d", file, pMgmt->deployed, pMgmt->dropped);
PRASE_MNODE_OVER: PRASE_MNODE_OVER:
if (content != NULL) free(content); if (content != NULL) free(content);
...@@ -186,8 +156,8 @@ PRASE_MNODE_OVER: ...@@ -186,8 +156,8 @@ PRASE_MNODE_OVER:
static int32_t dndWriteMnodeFile(SDnode *pDnode) { static int32_t dndWriteMnodeFile(SDnode *pDnode) {
SMnodeMgmt *pMgmt = &pDnode->mmgmt; SMnodeMgmt *pMgmt = &pDnode->mmgmt;
char file[PATH_MAX + 20] = {0}; char file[PATH_MAX + 20];
snprintf(file, sizeof(file), "%s.bak", pMgmt->file); snprintf(file, PATH_MAX + 20, "%s/mnode.json.bak", pDnode->dir.dnode);
FILE *fp = fopen(file, "w"); FILE *fp = fopen(file, "w");
if (fp == NULL) { if (fp == NULL) {
...@@ -223,47 +193,36 @@ static int32_t dndWriteMnodeFile(SDnode *pDnode) { ...@@ -223,47 +193,36 @@ static int32_t dndWriteMnodeFile(SDnode *pDnode) {
fclose(fp); fclose(fp);
free(content); free(content);
if (taosRenameFile(file, pMgmt->file) != 0) { char realfile[PATH_MAX + 20];
snprintf(realfile, PATH_MAX + 20, "%s/mnode.json", pDnode->dir.dnode);
if (taosRenameFile(file, realfile) != 0) {
terrno = TSDB_CODE_DND_MNODE_WRITE_FILE_ERROR; terrno = TSDB_CODE_DND_MNODE_WRITE_FILE_ERROR;
dError("failed to rename %s since %s", pMgmt->file, terrstr()); dError("failed to rename %s since %s", file, terrstr());
return -1; return -1;
} }
dInfo("successed to write %s, deployed:%d dropped:%d", pMgmt->file, pMgmt->deployed, pMgmt->dropped); dInfo("successed to write %s, deployed:%d dropped:%d", realfile, pMgmt->deployed, pMgmt->dropped);
return 0; return 0;
} }
static int32_t dndStartMnodeWorker(SDnode *pDnode) { static int32_t dndStartMnodeWorker(SDnode *pDnode) {
if (dndInitMnodeReadWorker(pDnode) != 0) { SMnodeMgmt *pMgmt = &pDnode->mmgmt;
if (dndInitWorker(pDnode, &pMgmt->readWorker, DND_WORKER_SINGLE, "mnode-read", 0, 1, dndProcessMnodeQueue) != 0) {
dError("failed to start mnode read worker since %s", terrstr()); dError("failed to start mnode read worker since %s", terrstr());
return -1; return -1;
} }
if (dndInitMnodeWriteWorker(pDnode) != 0) { if (dndInitWorker(pDnode, &pMgmt->writeWorker, DND_WORKER_SINGLE, "mnode-write", 0, 1, dndProcessMnodeQueue) != 0) {
dError("failed to start mnode write worker since %s", terrstr()); dError("failed to start mnode write worker since %s", terrstr());
return -1; return -1;
} }
if (dndInitMnodeSyncWorker(pDnode) != 0) { if (dndInitWorker(pDnode, &pMgmt->syncWorker, DND_WORKER_SINGLE, "mnode-sync", 0, 1, dndProcessMnodeQueue) != 0) {
dError("failed to start mnode sync worker since %s", terrstr()); dError("failed to start mnode sync worker since %s", terrstr());
return -1; return -1;
} }
if (dndAllocMnodeReadQueue(pDnode) != 0) {
dError("failed to alloc mnode read queue since %s", terrstr());
return -1;
}
if (dndAllocMnodeWriteQueue(pDnode) != 0) {
dError("failed to alloc mnode write queue since %s", terrstr());
return -1;
}
if (dndAllocMnodeSyncQueue(pDnode) != 0) {
dError("failed to alloc mnode sync queue since %s", terrstr());
return -1;
}
return 0; return 0;
} }
...@@ -274,18 +233,13 @@ static void dndStopMnodeWorker(SDnode *pDnode) { ...@@ -274,18 +233,13 @@ static void dndStopMnodeWorker(SDnode *pDnode) {
pMgmt->deployed = 0; pMgmt->deployed = 0;
taosWUnLockLatch(&pMgmt->latch); taosWUnLockLatch(&pMgmt->latch);
while (pMgmt->refCount > 1) taosMsleep(10); while (pMgmt->refCount > 1) {
while (!taosQueueEmpty(pMgmt->pReadQ)) taosMsleep(10); taosMsleep(10);
while (!taosQueueEmpty(pMgmt->pWriteQ)) taosMsleep(10); }
while (!taosQueueEmpty(pMgmt->pSyncQ)) taosMsleep(10);
dndCleanupMnodeReadWorker(pDnode);
dndCleanupMnodeWriteWorker(pDnode);
dndCleanupMnodeSyncWorker(pDnode);
dndFreeMnodeReadQueue(pDnode); dndCleanupWorker(&pMgmt->readWorker);
dndFreeMnodeWriteQueue(pDnode); dndCleanupWorker(&pMgmt->writeWorker);
dndFreeMnodeSyncQueue(pDnode); dndCleanupWorker(&pMgmt->syncWorker);
} }
static bool dndNeedDeployMnode(SDnode *pDnode) { static bool dndNeedDeployMnode(SDnode *pDnode) {
...@@ -383,28 +337,21 @@ static int32_t dndOpenMnode(SDnode *pDnode, SMnodeOpt *pOption) { ...@@ -383,28 +337,21 @@ static int32_t dndOpenMnode(SDnode *pDnode, SMnodeOpt *pOption) {
dError("failed to open mnode since %s", terrstr()); dError("failed to open mnode since %s", terrstr());
return -1; return -1;
} }
pMgmt->deployed = 1;
int32_t code = dndWriteMnodeFile(pDnode); if (dndStartMnodeWorker(pDnode) != 0) {
if (code != 0) { dError("failed to start mnode worker since %s", terrstr());
dError("failed to write mnode file since %s", terrstr());
code = terrno;
pMgmt->deployed = 0;
mndClose(pMnode); mndClose(pMnode);
mndDestroy(pDnode->dir.mnode); mndDestroy(pDnode->dir.mnode);
terrno = code;
return -1; return -1;
} }
code = dndStartMnodeWorker(pDnode); pMgmt->deployed = 1;
if (code != 0) { if (dndWriteMnodeFile(pDnode) != 0) {
dError("failed to start mnode worker since %s", terrstr()); dError("failed to write mnode file since %s", terrstr());
code = terrno;
pMgmt->deployed = 0; pMgmt->deployed = 0;
dndStopMnodeWorker(pDnode); dndStopMnodeWorker(pDnode);
mndClose(pMnode); mndClose(pMnode);
mndDestroy(pDnode->dir.mnode); mndDestroy(pDnode->dir.mnode);
terrno = code;
return -1; return -1;
} }
...@@ -461,6 +408,7 @@ static int32_t dndDropMnode(SDnode *pDnode) { ...@@ -461,6 +408,7 @@ static int32_t dndDropMnode(SDnode *pDnode) {
dndReleaseMnode(pDnode, pMnode); dndReleaseMnode(pDnode, pMnode);
dndStopMnodeWorker(pDnode); dndStopMnodeWorker(pDnode);
pMgmt->deployed = 0;
dndWriteMnodeFile(pDnode); dndWriteMnodeFile(pDnode);
mndClose(pMnode); mndClose(pMnode);
pMgmt->pMnode = NULL; pMgmt->pMnode = NULL;
...@@ -528,13 +476,12 @@ int32_t dndProcessDropMnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) { ...@@ -528,13 +476,12 @@ int32_t dndProcessDropMnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
} }
} }
static void dndProcessMnodeQueue(SDnode *pDnode, SMnodeMsg *pMsg) {
static void dndProcessMnodeReadQueue(SDnode *pDnode, SMnodeMsg *pMsg) {
SMnodeMgmt *pMgmt = &pDnode->mmgmt; SMnodeMgmt *pMgmt = &pDnode->mmgmt;
SMnode *pMnode = dndAcquireMnode(pDnode); SMnode *pMnode = dndAcquireMnode(pDnode);
if (pMnode != NULL) { if (pMnode != NULL) {
mndProcessReadMsg(pMsg); mndProcessMsg(pMsg);
dndReleaseMnode(pDnode, pMnode); dndReleaseMnode(pDnode, pMnode);
} else { } else {
mndSendRsp(pMsg, terrno); mndSendRsp(pMsg, terrno);
...@@ -543,208 +490,43 @@ static void dndProcessMnodeReadQueue(SDnode *pDnode, SMnodeMsg *pMsg) { ...@@ -543,208 +490,43 @@ static void dndProcessMnodeReadQueue(SDnode *pDnode, SMnodeMsg *pMsg) {
mndCleanupMsg(pMsg); mndCleanupMsg(pMsg);
} }
static void dndProcessMnodeWriteQueue(SDnode *pDnode, SMnodeMsg *pMsg) { static void dndWriteMnodeMsgToWorker(SDnode *pDnode, SDnodeWorker *pWorker, SRpcMsg *pRpcMsg) {
SMnodeMgmt *pMgmt = &pDnode->mmgmt; int32_t code = TSDB_CODE_DND_MNODE_NOT_DEPLOYED;
SMnode *pMnode = dndAcquireMnode(pDnode); SMnode *pMnode = dndAcquireMnode(pDnode);
if (pMnode != NULL) { if (pMnode != NULL) {
mndProcessWriteMsg(pMsg);
dndReleaseMnode(pDnode, pMnode);
} else {
mndSendRsp(pMsg, terrno);
}
mndCleanupMsg(pMsg);
}
static void dndProcessMnodeSyncQueue(SDnode *pDnode, SMnodeMsg *pMsg) {
SMnodeMgmt *pMgmt = &pDnode->mmgmt;
SMnode *pMnode = dndAcquireMnode(pDnode);
if (pMnode != NULL) {
mndProcessSyncMsg(pMsg);
dndReleaseMnode(pDnode, pMnode);
} else {
mndSendRsp(pMsg, terrno);
}
mndCleanupMsg(pMsg);
}
static int32_t dndWriteMnodeMsgToQueue(SMnode *pMnode, taos_queue pQueue, SRpcMsg *pRpcMsg) {
SMnodeMsg *pMsg = mndInitMsg(pMnode, pRpcMsg); SMnodeMsg *pMsg = mndInitMsg(pMnode, pRpcMsg);
if (pMsg == NULL) { if (pMsg == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; code = TSDB_CODE_OUT_OF_MEMORY;
return -1; } else {
code = dndWriteMsgToWorker(pWorker, pMsg, 0);
} }
if (taosWriteQitem(pQueue, pMsg) != 0) { if (code != 0) {
mndCleanupMsg(pMsg); mndCleanupMsg(pMsg);
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
return 0;
}
void dndProcessMnodeWriteMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) {
SMnodeMgmt *pMgmt = &pDnode->mmgmt;
SMnode *pMnode = dndAcquireMnode(pDnode);
if (pMnode == NULL || dndWriteMnodeMsgToQueue(pMnode, pMgmt->pWriteQ, pMsg) != 0) {
if (pMsg->msgType & 1u) {
SRpcMsg rsp = {.handle = pMsg->handle, .code = terrno};
rpcSendResponse(&rsp);
}
rpcFreeCont(pMsg->pCont);
pMsg->pCont = NULL;
}
dndReleaseMnode(pDnode, pMnode);
}
void dndProcessMnodeSyncMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) {
SMnodeMgmt *pMgmt = &pDnode->mmgmt;
SMnode *pMnode = dndAcquireMnode(pDnode);
if (pMnode == NULL || dndWriteMnodeMsgToQueue(pMnode, pMgmt->pSyncQ, pMsg) != 0) {
if (pMsg->msgType & 1u) {
SRpcMsg rsp = {.handle = pMsg->handle, .code = terrno};
rpcSendResponse(&rsp);
} }
rpcFreeCont(pMsg->pCont);
pMsg->pCont = NULL;
} }
dndReleaseMnode(pDnode, pMnode); dndReleaseMnode(pDnode, pMnode);
}
void dndProcessMnodeReadMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) { if (code != 0) {
SMnodeMgmt *pMgmt = &pDnode->mmgmt; if (pRpcMsg->msgType & 1u) {
SMnode *pMnode = dndAcquireMnode(pDnode); SRpcMsg rsp = {.handle = pRpcMsg->handle, .ahandle = pRpcMsg->ahandle, .code = code};
if (pMnode == NULL || dndWriteMnodeMsgToQueue(pMnode, pMgmt->pReadQ, pMsg) != 0) {
if (pMsg->msgType & 1u) {
SRpcMsg rsp = {.handle = pMsg->handle, .code = terrno};
rpcSendResponse(&rsp); rpcSendResponse(&rsp);
} }
rpcFreeCont(pMsg->pCont); rpcFreeCont(pRpcMsg->pCont);
pMsg->pCont = NULL;
} }
dndReleaseMnode(pDnode, pMnode);
} }
void dndProcessMnodeWriteMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) {
static int32_t dndAllocMnodeReadQueue(SDnode *pDnode) { dndWriteMnodeMsgToWorker(pDnode, &pDnode->mmgmt.writeWorker, pMsg);
SMnodeMgmt *pMgmt = &pDnode->mmgmt;
pMgmt->pReadQ = tWorkerAllocQueue(&pMgmt->readPool, pDnode, (FProcessItem)dndProcessMnodeReadQueue);
if (pMgmt->pReadQ == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
return 0;
}
static void dndFreeMnodeReadQueue(SDnode *pDnode) {
SMnodeMgmt *pMgmt = &pDnode->mmgmt;
tWorkerFreeQueue(&pMgmt->readPool, pMgmt->pReadQ);
pMgmt->pReadQ = NULL;
}
static int32_t dndInitMnodeReadWorker(SDnode *pDnode) {
SMnodeMgmt *pMgmt = &pDnode->mmgmt;
SWorkerPool *pPool = &pMgmt->readPool;
pPool->name = "mnode-read";
pPool->min = 0;
pPool->max = 1;
if (tWorkerInit(pPool) != 0) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
dDebug("mnode read worker is initialized");
return 0;
}
static void dndCleanupMnodeReadWorker(SDnode *pDnode) {
SMnodeMgmt *pMgmt = &pDnode->mmgmt;
tWorkerCleanup(&pMgmt->readPool);
dDebug("mnode read worker is closed");
}
static int32_t dndAllocMnodeWriteQueue(SDnode *pDnode) {
SMnodeMgmt *pMgmt = &pDnode->mmgmt;
pMgmt->pWriteQ = tWorkerAllocQueue(&pMgmt->writePool, pDnode, (FProcessItem)dndProcessMnodeWriteQueue);
if (pMgmt->pWriteQ == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
return 0;
}
static void dndFreeMnodeWriteQueue(SDnode *pDnode) {
SMnodeMgmt *pMgmt = &pDnode->mmgmt;
tWorkerFreeQueue(&pMgmt->writePool, pMgmt->pWriteQ);
pMgmt->pWriteQ = NULL;
}
static int32_t dndInitMnodeWriteWorker(SDnode *pDnode) {
SMnodeMgmt *pMgmt = &pDnode->mmgmt;
SWorkerPool *pPool = &pMgmt->writePool;
pPool->name = "mnode-write";
pPool->min = 0;
pPool->max = 1;
if (tWorkerInit(pPool) != 0) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
dDebug("mnode write worker is initialized");
return 0;
}
static void dndCleanupMnodeWriteWorker(SDnode *pDnode) {
SMnodeMgmt *pMgmt = &pDnode->mmgmt;
tWorkerCleanup(&pMgmt->writePool);
dDebug("mnode write worker is closed");
}
static int32_t dndAllocMnodeSyncQueue(SDnode *pDnode) {
SMnodeMgmt *pMgmt = &pDnode->mmgmt;
pMgmt->pSyncQ = tWorkerAllocQueue(&pMgmt->syncPool, pDnode, (FProcessItem)dndProcessMnodeSyncQueue);
if (pMgmt->pSyncQ == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
return 0;
}
static void dndFreeMnodeSyncQueue(SDnode *pDnode) {
SMnodeMgmt *pMgmt = &pDnode->mmgmt;
tWorkerFreeQueue(&pMgmt->syncPool, pMgmt->pSyncQ);
pMgmt->pSyncQ = NULL;
} }
static int32_t dndInitMnodeSyncWorker(SDnode *pDnode) { void dndProcessMnodeSyncMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) {
SMnodeMgmt *pMgmt = &pDnode->mmgmt; dndWriteMnodeMsgToWorker(pDnode, &pDnode->mmgmt.syncWorker, pMsg);
SWorkerPool *pPool = &pMgmt->syncPool;
pPool->name = "mnode-sync";
pPool->min = 0;
pPool->max = 1;
if (tWorkerInit(pPool) != 0) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
dDebug("mnode sync worker is initialized");
return 0;
} }
static void dndCleanupMnodeSyncWorker(SDnode *pDnode) { void dndProcessMnodeReadMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) {
SMnodeMgmt *pMgmt = &pDnode->mmgmt; dndWriteMnodeMsgToWorker(pDnode, &pDnode->mmgmt.readWorker, pMsg);
tWorkerCleanup(&pMgmt->syncPool);
dDebug("mnode sync worker is closed");
} }
int32_t dndInitMnode(SDnode *pDnode) { int32_t dndInitMnode(SDnode *pDnode) {
...@@ -752,14 +534,6 @@ int32_t dndInitMnode(SDnode *pDnode) { ...@@ -752,14 +534,6 @@ int32_t dndInitMnode(SDnode *pDnode) {
SMnodeMgmt *pMgmt = &pDnode->mmgmt; SMnodeMgmt *pMgmt = &pDnode->mmgmt;
taosInitRWLatch(&pMgmt->latch); taosInitRWLatch(&pMgmt->latch);
char path[PATH_MAX];
snprintf(path, PATH_MAX, "%s/mnode.json", pDnode->dir.dnode);
pMgmt->file = strdup(path);
if (pMgmt->file == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
if (dndReadMnodeFile(pDnode) != 0) { if (dndReadMnodeFile(pDnode) != 0) {
return -1; return -1;
} }
...@@ -790,13 +564,13 @@ int32_t dndInitMnode(SDnode *pDnode) { ...@@ -790,13 +564,13 @@ int32_t dndInitMnode(SDnode *pDnode) {
} }
void dndCleanupMnode(SDnode *pDnode) { void dndCleanupMnode(SDnode *pDnode) {
SMnodeMgmt *pMgmt = &pDnode->mmgmt;
dInfo("dnode-mnode start to clean up"); dInfo("dnode-mnode start to clean up");
if (pMgmt->pMnode) dndStopMnodeWorker(pDnode); SMnodeMgmt *pMgmt = &pDnode->mmgmt;
tfree(pMgmt->file); if (pMgmt->pMnode) {
dndStopMnodeWorker(pDnode);
mndClose(pMgmt->pMnode); mndClose(pMgmt->pMnode);
pMgmt->pMnode = NULL; pMgmt->pMnode = NULL;
}
dInfo("dnode-mnode is cleaned up"); dInfo("dnode-mnode is cleaned up");
} }
......
...@@ -17,30 +17,9 @@ ...@@ -17,30 +17,9 @@
#include "dndQnode.h" #include "dndQnode.h"
#include "dndDnode.h" #include "dndDnode.h"
#include "dndTransport.h" #include "dndTransport.h"
#include "dndWorker.h"
static int32_t dndInitQnodeQueryWorker(SDnode *pDnode);
static int32_t dndInitQnodeFetchWorker(SDnode *pDnode);
static void dndCleanupQnodeQueryWorker(SDnode *pDnode);
static void dndCleanupQnodeFetchWorker(SDnode *pDnode);
static int32_t dndAllocQnodeQueryQueue(SDnode *pDnode);
static int32_t dndAllocQnodeFetchQueue(SDnode *pDnode);
static void dndFreeQnodeQueryQueue(SDnode *pDnode);
static void dndFreeQnodeFetchQueue(SDnode *pDnode);
static void dndProcessQnodeQueue(SDnode *pDnode, SRpcMsg *pMsg); static void dndProcessQnodeQueue(SDnode *pDnode, SRpcMsg *pMsg);
static int32_t dndWriteQnodeMsgToQueue(SQnode *pQnode, taos_queue pQueue, SRpcMsg *pRpcMsg);
static int32_t dndStartQnodeWorker(SDnode *pDnode);
static void dndStopQnodeWorker(SDnode *pDnode);
static SQnode *dndAcquireQnode(SDnode *pDnode);
static void dndReleaseQnode(SDnode *pDnode, SQnode *pQnode);
static int32_t dndReadQnodeFile(SDnode *pDnode);
static int32_t dndWriteQnodeFile(SDnode *pDnode);
static int32_t dndOpenQnode(SDnode *pDnode);
static int32_t dndDropQnode(SDnode *pDnode);
static SQnode *dndAcquireQnode(SDnode *pDnode) { static SQnode *dndAcquireQnode(SDnode *pDnode) {
SQnodeMgmt *pMgmt = &pDnode->qmgmt; SQnodeMgmt *pMgmt = &pDnode->qmgmt;
...@@ -85,44 +64,47 @@ static int32_t dndReadQnodeFile(SDnode *pDnode) { ...@@ -85,44 +64,47 @@ static int32_t dndReadQnodeFile(SDnode *pDnode) {
char *content = calloc(1, maxLen + 1); char *content = calloc(1, maxLen + 1);
cJSON *root = NULL; cJSON *root = NULL;
FILE *fp = fopen(pMgmt->file, "r"); char file[PATH_MAX + 20];
snprintf(file, PATH_MAX + 20, "%s/qnode.json", pDnode->dir.dnode);
FILE *fp = fopen(file, "r");
if (fp == NULL) { if (fp == NULL) {
dDebug("file %s not exist", pMgmt->file); dDebug("file %s not exist", file);
code = 0; code = 0;
goto PRASE_MNODE_OVER; goto PRASE_QNODE_OVER;
} }
len = (int32_t)fread(content, 1, maxLen, fp); len = (int32_t)fread(content, 1, maxLen, fp);
if (len <= 0) { if (len <= 0) {
dError("failed to read %s since content is null", pMgmt->file); dError("failed to read %s since content is null", file);
goto PRASE_MNODE_OVER; goto PRASE_QNODE_OVER;
} }
content[len] = 0; content[len] = 0;
root = cJSON_Parse(content); root = cJSON_Parse(content);
if (root == NULL) { if (root == NULL) {
dError("failed to read %s since invalid json format", pMgmt->file); dError("failed to read %s since invalid json format", file);
goto PRASE_MNODE_OVER; goto PRASE_QNODE_OVER;
} }
cJSON *deployed = cJSON_GetObjectItem(root, "deployed"); cJSON *deployed = cJSON_GetObjectItem(root, "deployed");
if (!deployed || deployed->type != cJSON_Number) { if (!deployed || deployed->type != cJSON_Number) {
dError("failed to read %s since deployed not found", pMgmt->file); dError("failed to read %s since deployed not found", file);
goto PRASE_MNODE_OVER; goto PRASE_QNODE_OVER;
} }
pMgmt->deployed = deployed->valueint; pMgmt->deployed = deployed->valueint;
cJSON *dropped = cJSON_GetObjectItem(root, "dropped"); cJSON *dropped = cJSON_GetObjectItem(root, "dropped");
if (!dropped || dropped->type != cJSON_Number) { if (!dropped || dropped->type != cJSON_Number) {
dError("failed to read %s since dropped not found", pMgmt->file); dError("failed to read %s since dropped not found", file);
goto PRASE_MNODE_OVER; goto PRASE_QNODE_OVER;
} }
pMgmt->dropped = dropped->valueint; pMgmt->dropped = dropped->valueint;
code = 0; code = 0;
dDebug("succcessed to read file %s, deployed:%d dropped:%d", pMgmt->file, pMgmt->deployed, pMgmt->dropped); dDebug("succcessed to read file %s, deployed:%d dropped:%d", file, pMgmt->deployed, pMgmt->dropped);
PRASE_MNODE_OVER: PRASE_QNODE_OVER:
if (content != NULL) free(content); if (content != NULL) free(content);
if (root != NULL) cJSON_Delete(root); if (root != NULL) cJSON_Delete(root);
if (fp != NULL) fclose(fp); if (fp != NULL) fclose(fp);
...@@ -134,8 +116,8 @@ PRASE_MNODE_OVER: ...@@ -134,8 +116,8 @@ PRASE_MNODE_OVER:
static int32_t dndWriteQnodeFile(SDnode *pDnode) { static int32_t dndWriteQnodeFile(SDnode *pDnode) {
SQnodeMgmt *pMgmt = &pDnode->qmgmt; SQnodeMgmt *pMgmt = &pDnode->qmgmt;
char file[PATH_MAX + 20] = {0}; char file[PATH_MAX + 20];
snprintf(file, sizeof(file), "%s.bak", pMgmt->file); snprintf(file, PATH_MAX + 20, "%s/qnode.json", pDnode->dir.dnode);
FILE *fp = fopen(file, "w"); FILE *fp = fopen(file, "w");
if (fp == NULL) { if (fp == NULL) {
...@@ -154,41 +136,35 @@ static int32_t dndWriteQnodeFile(SDnode *pDnode) { ...@@ -154,41 +136,35 @@ static int32_t dndWriteQnodeFile(SDnode *pDnode) {
len += snprintf(content + len, maxLen - len, "}\n"); len += snprintf(content + len, maxLen - len, "}\n");
fwrite(content, 1, len, fp); fwrite(content, 1, len, fp);
taosFfetchFile(fileno(fp)); taosFsyncFile(fileno(fp));
fclose(fp); fclose(fp);
free(content); free(content);
if (taosRenameFile(file, pMgmt->file) != 0) { char realfile[PATH_MAX + 20];
snprintf(realfile, PATH_MAX + 20, "%s/qnode.json", pDnode->dir.dnode);
if (taosRenameFile(file, realfile) != 0) {
terrno = TSDB_CODE_DND_QNODE_WRITE_FILE_ERROR; terrno = TSDB_CODE_DND_QNODE_WRITE_FILE_ERROR;
dError("failed to rename %s since %s", pMgmt->file, terrstr()); dError("failed to rename %s since %s", file, terrstr());
return -1; return -1;
} }
dInfo("successed to write %s, deployed:%d dropped:%d", pMgmt->file, pMgmt->deployed, pMgmt->dropped); dInfo("successed to write %s, deployed:%d dropped:%d", realfile, pMgmt->deployed, pMgmt->dropped);
return 0; return 0;
} }
static int32_t dndStartQnodeWorker(SDnode *pDnode) { static int32_t dndStartQnodeWorker(SDnode *pDnode) {
if (dndInitQnodeQueryWorker(pDnode) != 0) { SQnodeMgmt *pMgmt = &pDnode->qmgmt;
if (dndInitWorker(pDnode, &pMgmt->queryWorker, DND_WORKER_SINGLE, "qnode-query", 0, 1, dndProcessQnodeQueue) != 0) {
dError("failed to start qnode query worker since %s", terrstr()); dError("failed to start qnode query worker since %s", terrstr());
return -1; return -1;
} }
if (dndInitQnodeFetchWorker(pDnode) != 0) { if (dndInitWorker(pDnode, &pMgmt->fetchWorker, DND_WORKER_SINGLE, "qnode-fetch", 0, 1, dndProcessQnodeQueue) != 0) {
dError("failed to start qnode fetch worker since %s", terrstr()); dError("failed to start qnode fetch worker since %s", terrstr());
return -1; return -1;
} }
if (dndAllocQnodeQueryQueue(pDnode) != 0) {
dError("failed to alloc qnode query queue since %s", terrstr());
return -1;
}
if (dndAllocQnodeFetchQueue(pDnode) != 0) {
dError("failed to alloc qnode fetch queue since %s", terrstr());
return -1;
}
return 0; return 0;
} }
...@@ -199,15 +175,12 @@ static void dndStopQnodeWorker(SDnode *pDnode) { ...@@ -199,15 +175,12 @@ static void dndStopQnodeWorker(SDnode *pDnode) {
pMgmt->deployed = 0; pMgmt->deployed = 0;
taosWUnLockLatch(&pMgmt->latch); taosWUnLockLatch(&pMgmt->latch);
while (pMgmt->refCount > 1) taosMsleep(10); while (pMgmt->refCount > 1) {
while (!taosQueueEmpty(pMgmt->pQueryQ)) taosMsleep(10); taosMsleep(10);
while (!taosQueueEmpty(pMgmt->pFetchQ)) taosMsleep(10); }
dndCleanupQnodeQueryWorker(pDnode);
dndCleanupQnodeFetchWorker(pDnode);
dndFreeQnodeQueryQueue(pDnode); dndCleanupWorker(&pMgmt->queryWorker);
dndFreeQnodeFetchQueue(pDnode); dndCleanupWorker(&pMgmt->fetchWorker);
} }
static void dndBuildQnodeOption(SDnode *pDnode, SQnodeOpt *pOption) { static void dndBuildQnodeOption(SDnode *pDnode, SQnodeOpt *pOption) {
...@@ -230,34 +203,24 @@ static int32_t dndOpenQnode(SDnode *pDnode) { ...@@ -230,34 +203,24 @@ static int32_t dndOpenQnode(SDnode *pDnode) {
dError("failed to open qnode since %s", terrstr()); dError("failed to open qnode since %s", terrstr());
return -1; return -1;
} }
pMgmt->deployed = 1;
int32_t code = dndWriteQnodeFile(pDnode); if (dndStartQnodeWorker(pDnode) != 0) {
if (code != 0) { dError("failed to start qnode worker since %s", terrstr());
dError("failed to write qnode file since %s", terrstr());
code = terrno;
pMgmt->deployed = 0;
qndClose(pQnode); qndClose(pQnode);
// qndDestroy(pDnode->dir.qnode);
terrno = code;
return -1; return -1;
} }
code = dndStartQnodeWorker(pDnode); pMgmt->deployed = 1;
if (code != 0) { if (dndWriteQnodeFile(pDnode) != 0) {
dError("failed to start qnode worker since %s", terrstr());
code = terrno;
pMgmt->deployed = 0; pMgmt->deployed = 0;
dError("failed to write qnode file since %s", terrstr());
dndStopQnodeWorker(pDnode); dndStopQnodeWorker(pDnode);
qndClose(pQnode); qndClose(pQnode);
// qndDestroy(pDnode->dir.qnode);
terrno = code;
return -1; return -1;
} }
taosWLockLatch(&pMgmt->latch); taosWLockLatch(&pMgmt->latch);
pMgmt->pQnode = pQnode; pMgmt->pQnode = pQnode;
pMgmt->deployed = 1;
taosWUnLockLatch(&pMgmt->latch); taosWUnLockLatch(&pMgmt->latch);
dInfo("qnode open successfully"); dInfo("qnode open successfully");
...@@ -289,10 +252,10 @@ static int32_t dndDropQnode(SDnode *pDnode) { ...@@ -289,10 +252,10 @@ static int32_t dndDropQnode(SDnode *pDnode) {
dndReleaseQnode(pDnode, pQnode); dndReleaseQnode(pDnode, pQnode);
dndStopQnodeWorker(pDnode); dndStopQnodeWorker(pDnode);
pMgmt->deployed = 0;
dndWriteQnodeFile(pDnode); dndWriteQnodeFile(pDnode);
qndClose(pQnode); qndClose(pQnode);
pMgmt->pQnode = NULL; pMgmt->pQnode = NULL;
// qndDestroy(pDnode->dir.qnode);
return 0; return 0;
} }
...@@ -324,13 +287,11 @@ int32_t dndProcessDropQnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) { ...@@ -324,13 +287,11 @@ int32_t dndProcessDropQnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
static void dndProcessQnodeQueue(SDnode *pDnode, SRpcMsg *pMsg) { static void dndProcessQnodeQueue(SDnode *pDnode, SRpcMsg *pMsg) {
SQnodeMgmt *pMgmt = &pDnode->qmgmt; SQnodeMgmt *pMgmt = &pDnode->qmgmt;
SRpcMsg *pRsp = NULL; SRpcMsg *pRsp = NULL;
int32_t code = 0; int32_t code = TSDB_CODE_DND_QNODE_NOT_DEPLOYED;
SQnode *pQnode = dndAcquireQnode(pDnode); SQnode *pQnode = dndAcquireQnode(pDnode);
if (pQnode == NULL) { if (pQnode != NULL) {
code = -1; code = qndProcessMsg(pQnode, pMsg, &pRsp);
} else {
code = qndProcessQueryReq(pQnode, pMsg, &pRsp);
} }
if (pRsp != NULL) { if (pRsp != NULL) {
...@@ -347,135 +308,36 @@ static void dndProcessQnodeQueue(SDnode *pDnode, SRpcMsg *pMsg) { ...@@ -347,135 +308,36 @@ static void dndProcessQnodeQueue(SDnode *pDnode, SRpcMsg *pMsg) {
taosFreeQitem(pMsg); taosFreeQitem(pMsg);
} }
static int32_t dndWriteQnodeMsgToQueue(SQnode *pQnode, taos_queue pQueue, SRpcMsg *pRpcMsg) { static void dndWriteQnodeMsgToWorker(SDnode *pDnode, SDnodeWorker *pWorker, SRpcMsg *pMsg) {
int32_t code = 0; int32_t code = TSDB_CODE_DND_QNODE_NOT_DEPLOYED;
if (pQnode == NULL || pQueue == NULL) { SQnode *pQnode = dndAcquireQnode(pDnode);
code = TSDB_CODE_DND_QNODE_NOT_DEPLOYED; if (pQnode != NULL) {
} else { code = dndWriteMsgToWorker(pWorker, pMsg, sizeof(SRpcMsg));
SRpcMsg *pMsg = taosAllocateQitem(sizeof(SRpcMsg));
if (pMsg == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
} else {
*pMsg = *pRpcMsg;
if (taosWriteQitem(pQueue, pMsg) != 0) {
code = TSDB_CODE_OUT_OF_MEMORY;
}
}
} }
dndReleaseQnode(pDnode, pQnode);
if (code != 0) { if (code != 0) {
if (pRpcMsg->msgType & 1u) { if (pMsg->msgType & 1u) {
SRpcMsg rsp = {.handle = pRpcMsg->handle, .code = code}; SRpcMsg rsp = {.handle = pMsg->handle, .ahandle = pMsg->ahandle, .code = code};
rpcSendResponse(&rsp); rpcSendResponse(&rsp);
} }
rpcFreeCont(pRpcMsg->pCont); rpcFreeCont(pMsg->pCont);
} }
} }
void dndProcessQnodeQueryMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) { void dndProcessQnodeQueryMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) {
SQnodeMgmt *pMgmt = &pDnode->qmgmt; dndWriteQnodeMsgToWorker(pDnode, &pDnode->qmgmt.queryWorker, pMsg);
SQnode *pQnode = dndAcquireQnode(pDnode);
dndWriteQnodeMsgToQueue(pQnode, pMgmt->pQueryQ, pMsg);
dndReleaseQnode(pDnode, pQnode);
} }
void dndProcessQnodeFetchMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) { void dndProcessQnodeFetchMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) {
SQnodeMgmt *pMgmt = &pDnode->qmgmt; dndWriteQnodeMsgToWorker(pDnode, &pDnode->qmgmt.queryWorker, pMsg);
SQnode *pQnode = dndAcquireQnode(pDnode);
dndWriteQnodeMsgToQueue(pQnode, pMgmt->pFetchQ, pMsg);
dndReleaseQnode(pDnode, pQnode);
}
static int32_t dndAllocQnodeQueryQueue(SDnode *pDnode) {
SQnodeMgmt *pMgmt = &pDnode->qmgmt;
pMgmt->pQueryQ = tWorkerAllocQueue(&pMgmt->queryPool, pDnode, (FProcessItem)dndProcessQnodeQueue);
if (pMgmt->pQueryQ == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
return 0;
}
static void dndFreeQnodeQueryQueue(SDnode *pDnode) {
SQnodeMgmt *pMgmt = &pDnode->qmgmt;
tWorkerFreeQueue(&pMgmt->queryPool, pMgmt->pQueryQ);
pMgmt->pQueryQ = NULL;
}
static int32_t dndInitQnodeQueryWorker(SDnode *pDnode) {
SQnodeMgmt *pMgmt = &pDnode->qmgmt;
SWorkerPool *pPool = &pMgmt->queryPool;
pPool->name = "qnode-query";
pPool->min = 0;
pPool->max = 1;
if (tWorkerInit(pPool) != 0) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
dDebug("qnode query worker is initialized");
return 0;
}
static void dndCleanupQnodeQueryWorker(SDnode *pDnode) {
SQnodeMgmt *pMgmt = &pDnode->qmgmt;
tWorkerCleanup(&pMgmt->queryPool);
dDebug("qnode query worker is closed");
}
static int32_t dndAllocQnodeFetchQueue(SDnode *pDnode) {
SQnodeMgmt *pMgmt = &pDnode->qmgmt;
pMgmt->pFetchQ = tWorkerAllocQueue(&pMgmt->queryPool, pDnode, (FProcessItem)dndProcessQnodeQueue);
if (pMgmt->pFetchQ == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
return 0;
}
static void dndFreeQnodeFetchQueue(SDnode *pDnode) {
SQnodeMgmt *pMgmt = &pDnode->qmgmt;
tWorkerFreeQueue(&pMgmt->fetchPool, pMgmt->pFetchQ);
pMgmt->pFetchQ = NULL;
}
static int32_t dndInitQnodeFetchWorker(SDnode *pDnode) {
SQnodeMgmt *pMgmt = &pDnode->qmgmt;
SWorkerPool *pPool = &pMgmt->fetchPool;
pPool->name = "qnode-fetch";
pPool->min = 0;
pPool->max = 1;
if (tWorkerInit(pPool) != 0) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
dDebug("qnode fetch worker is initialized");
return 0;
}
static void dndCleanupQnodeFetchWorker(SDnode *pDnode) {
SQnodeMgmt *pMgmt = &pDnode->qmgmt;
tWorkerCleanup(&pMgmt->fetchPool);
dDebug("qnode fetch worker is closed");
} }
int32_t dndInitQnode(SDnode *pDnode) { int32_t dndInitQnode(SDnode *pDnode) {
dInfo("dnode-qnode start to init");
SQnodeMgmt *pMgmt = &pDnode->qmgmt; SQnodeMgmt *pMgmt = &pDnode->qmgmt;
taosInitRWLatch(&pMgmt->latch); taosInitRWLatch(&pMgmt->latch);
char path[PATH_MAX];
snprintf(path, PATH_MAX, "%s/qnode.json", pDnode->dir.dnode);
pMgmt->file = strdup(path);
if (pMgmt->file == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
if (dndReadQnodeFile(pDnode) != 0) { if (dndReadQnodeFile(pDnode) != 0) {
return -1; return -1;
} }
...@@ -488,11 +350,9 @@ int32_t dndInitQnode(SDnode *pDnode) { ...@@ -488,11 +350,9 @@ int32_t dndInitQnode(SDnode *pDnode) {
void dndCleanupQnode(SDnode *pDnode) { void dndCleanupQnode(SDnode *pDnode) {
SQnodeMgmt *pMgmt = &pDnode->qmgmt; SQnodeMgmt *pMgmt = &pDnode->qmgmt;
if (pMgmt->pQnode) {
dInfo("dnode-qnode start to clean up"); dndStopQnodeWorker(pDnode);
if (pMgmt->pQnode) dndStopQnodeWorker(pDnode);
tfree(pMgmt->file);
qndClose(pMgmt->pQnode); qndClose(pMgmt->pQnode);
pMgmt->pQnode = NULL; pMgmt->pQnode = NULL;
dInfo("dnode-qnode is cleaned up"); }
} }
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http:www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "dndSnode.h"
#include "dndDnode.h"
#include "dndTransport.h"
#include "dndWorker.h"
static void dndProcessSnodeQueue(SDnode *pDnode, SRpcMsg *pMsg);
static SSnode *dndAcquireSnode(SDnode *pDnode) {
SSnodeMgmt *pMgmt = &pDnode->smgmt;
SSnode *pSnode = NULL;
int32_t refCount = 0;
taosRLockLatch(&pMgmt->latch);
if (pMgmt->deployed && !pMgmt->dropped) {
refCount = atomic_add_fetch_32(&pMgmt->refCount, 1);
pSnode = pMgmt->pSnode;
} else {
terrno = TSDB_CODE_DND_SNODE_NOT_DEPLOYED;
}
taosRUnLockLatch(&pMgmt->latch);
if (pSnode != NULL) {
dTrace("acquire snode, refCount:%d", refCount);
}
return pSnode;
}
static void dndReleaseSnode(SDnode *pDnode, SSnode *pSnode) {
SSnodeMgmt *pMgmt = &pDnode->smgmt;
int32_t refCount = 0;
taosRLockLatch(&pMgmt->latch);
if (pSnode != NULL) {
refCount = atomic_sub_fetch_32(&pMgmt->refCount, 1);
}
taosRUnLockLatch(&pMgmt->latch);
if (pSnode != NULL) {
dTrace("release snode, refCount:%d", refCount);
}
}
static int32_t dndReadSnodeFile(SDnode *pDnode) {
SSnodeMgmt *pMgmt = &pDnode->smgmt;
int32_t code = TSDB_CODE_DND_SNODE_READ_FILE_ERROR;
int32_t len = 0;
int32_t maxLen = 4096;
char *content = calloc(1, maxLen + 1);
cJSON *root = NULL;
char file[PATH_MAX + 20];
snprintf(file, PATH_MAX + 20, "%s/snode.json", pDnode->dir.dnode);
FILE *fp = fopen(file, "r");
if (fp == NULL) {
dDebug("file %s not exist", file);
code = 0;
goto PRASE_SNODE_OVER;
}
len = (int32_t)fread(content, 1, maxLen, fp);
if (len <= 0) {
dError("failed to read %s since content is null", file);
goto PRASE_SNODE_OVER;
}
content[len] = 0;
root = cJSON_Parse(content);
if (root == NULL) {
dError("failed to read %s since invalid json format", file);
goto PRASE_SNODE_OVER;
}
cJSON *deployed = cJSON_GetObjectItem(root, "deployed");
if (!deployed || deployed->type != cJSON_Number) {
dError("failed to read %s since deployed not found", file);
goto PRASE_SNODE_OVER;
}
pMgmt->deployed = deployed->valueint;
cJSON *dropped = cJSON_GetObjectItem(root, "dropped");
if (!dropped || dropped->type != cJSON_Number) {
dError("failed to read %s since dropped not found", file);
goto PRASE_SNODE_OVER;
}
pMgmt->dropped = dropped->valueint;
code = 0;
dDebug("succcessed to read file %s, deployed:%d dropped:%d", file, pMgmt->deployed, pMgmt->dropped);
PRASE_SNODE_OVER:
if (content != NULL) free(content);
if (root != NULL) cJSON_Delete(root);
if (fp != NULL) fclose(fp);
terrno = code;
return code;
}
static int32_t dndWriteSnodeFile(SDnode *pDnode) {
SSnodeMgmt *pMgmt = &pDnode->smgmt;
char file[PATH_MAX + 20];
snprintf(file, PATH_MAX + 20, "%s/snode.json", pDnode->dir.dnode);
FILE *fp = fopen(file, "w");
if (fp == NULL) {
terrno = TSDB_CODE_DND_SNODE_WRITE_FILE_ERROR;
dError("failed to write %s since %s", file, terrstr());
return -1;
}
int32_t len = 0;
int32_t maxLen = 4096;
char *content = calloc(1, maxLen + 1);
len += snprintf(content + len, maxLen - len, "{\n");
len += snprintf(content + len, maxLen - len, " \"deployed\": %d,\n", pMgmt->deployed);
len += snprintf(content + len, maxLen - len, " \"dropped\": %d\n", pMgmt->dropped);
len += snprintf(content + len, maxLen - len, "}\n");
fwrite(content, 1, len, fp);
taosFsyncFile(fileno(fp));
fclose(fp);
free(content);
char realfile[PATH_MAX + 20];
snprintf(realfile, PATH_MAX + 20, "%s/snode.json", pDnode->dir.dnode);
if (taosRenameFile(file, realfile) != 0) {
terrno = TSDB_CODE_DND_SNODE_WRITE_FILE_ERROR;
dError("failed to rename %s since %s", file, terrstr());
return -1;
}
dInfo("successed to write %s, deployed:%d dropped:%d", realfile, pMgmt->deployed, pMgmt->dropped);
return 0;
}
static int32_t dndStartSnodeWorker(SDnode *pDnode) {
SSnodeMgmt *pMgmt = &pDnode->smgmt;
if (dndInitWorker(pDnode, &pMgmt->writeWorker, DND_WORKER_SINGLE, "snode-write", 0, 1, dndProcessSnodeQueue) != 0) {
dError("failed to start snode write worker since %s", terrstr());
return -1;
}
return 0;
}
static void dndStopSnodeWorker(SDnode *pDnode) {
SSnodeMgmt *pMgmt = &pDnode->smgmt;
taosWLockLatch(&pMgmt->latch);
pMgmt->deployed = 0;
taosWUnLockLatch(&pMgmt->latch);
while (pMgmt->refCount > 1) {
taosMsleep(10);
}
dndCleanupWorker(&pMgmt->writeWorker);
}
static void dndBuildSnodeOption(SDnode *pDnode, SSnodeOpt *pOption) {
pOption->pDnode = pDnode;
pOption->sendMsgToDnodeFp = dndSendMsgToDnode;
pOption->sendMsgToMnodeFp = dndSendMsgToMnode;
pOption->sendRedirectMsgFp = dndSendRedirectMsg;
pOption->dnodeId = dndGetDnodeId(pDnode);
pOption->clusterId = dndGetClusterId(pDnode);
pOption->cfg.sver = pDnode->opt.sver;
}
static int32_t dndOpenSnode(SDnode *pDnode) {
SSnodeMgmt *pMgmt = &pDnode->smgmt;
SSnodeOpt option = {0};
dndBuildSnodeOption(pDnode, &option);
SSnode *pSnode = sndOpen(pDnode->dir.snode, &option);
if (pSnode == NULL) {
dError("failed to open snode since %s", terrstr());
return -1;
}
if (dndStartSnodeWorker(pDnode) != 0) {
dError("failed to start snode worker since %s", terrstr());
sndClose(pSnode);
return -1;
}
pMgmt->deployed = 1;
if (dndWriteSnodeFile(pDnode) != 0) {
pMgmt->deployed = 0;
dError("failed to write snode file since %s", terrstr());
dndStopSnodeWorker(pDnode);
sndClose(pSnode);
return -1;
}
taosWLockLatch(&pMgmt->latch);
pMgmt->pSnode = pSnode;
taosWUnLockLatch(&pMgmt->latch);
dInfo("snode open successfully");
return 0;
}
static int32_t dndDropSnode(SDnode *pDnode) {
SSnodeMgmt *pMgmt = &pDnode->smgmt;
SSnode *pSnode = dndAcquireSnode(pDnode);
if (pSnode == NULL) {
dError("failed to drop snode since %s", terrstr());
return -1;
}
taosRLockLatch(&pMgmt->latch);
pMgmt->dropped = 1;
taosRUnLockLatch(&pMgmt->latch);
if (dndWriteSnodeFile(pDnode) != 0) {
taosRLockLatch(&pMgmt->latch);
pMgmt->dropped = 0;
taosRUnLockLatch(&pMgmt->latch);
dndReleaseSnode(pDnode, pSnode);
dError("failed to drop snode since %s", terrstr());
return -1;
}
dndReleaseSnode(pDnode, pSnode);
dndStopSnodeWorker(pDnode);
pMgmt->deployed = 0;
dndWriteSnodeFile(pDnode);
sndClose(pSnode);
pMgmt->pSnode = NULL;
sndDestroy(pDnode->dir.snode);
return 0;
}
int32_t dndProcessCreateSnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
SCreateSnodeInMsg *pMsg = pRpcMsg->pCont;
pMsg->dnodeId = htonl(pMsg->dnodeId);
if (pMsg->dnodeId != dndGetDnodeId(pDnode)) {
terrno = TSDB_CODE_DND_SNODE_ID_INVALID;
return -1;
} else {
return dndOpenSnode(pDnode);
}
}
int32_t dndProcessDropSnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
SDropSnodeInMsg *pMsg = pRpcMsg->pCont;
pMsg->dnodeId = htonl(pMsg->dnodeId);
if (pMsg->dnodeId != dndGetDnodeId(pDnode)) {
terrno = TSDB_CODE_DND_SNODE_ID_INVALID;
return -1;
} else {
return dndDropSnode(pDnode);
}
}
static void dndProcessSnodeQueue(SDnode *pDnode, SRpcMsg *pMsg) {
SSnodeMgmt *pMgmt = &pDnode->smgmt;
SRpcMsg *pRsp = NULL;
int32_t code = TSDB_CODE_DND_SNODE_NOT_DEPLOYED;
SSnode *pSnode = dndAcquireSnode(pDnode);
if (pSnode != NULL) {
code = sndProcessMsg(pSnode, pMsg, &pRsp);
}
if (pRsp != NULL) {
pRsp->ahandle = pMsg->ahandle;
rpcSendResponse(pRsp);
free(pRsp);
} else {
if (code != 0) code = terrno;
SRpcMsg rpcRsp = {.handle = pMsg->handle, .ahandle = pMsg->ahandle, .code = code};
rpcSendResponse(&rpcRsp);
}
rpcFreeCont(pMsg->pCont);
taosFreeQitem(pMsg);
}
static void dndWriteSnodeMsgToWorker(SDnode *pDnode, SDnodeWorker *pWorker, SRpcMsg *pMsg) {
int32_t code = TSDB_CODE_DND_SNODE_NOT_DEPLOYED;
SSnode *pSnode = dndAcquireSnode(pDnode);
if (pSnode != NULL) {
code = dndWriteMsgToWorker(pWorker, pMsg, sizeof(SRpcMsg));
}
dndReleaseSnode(pDnode, pSnode);
if (code != 0) {
if (pMsg->msgType & 1u) {
SRpcMsg rsp = {.handle = pMsg->handle, .ahandle = pMsg->ahandle, .code = code};
rpcSendResponse(&rsp);
}
rpcFreeCont(pMsg->pCont);
}
}
void dndProcessSnodeWriteMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) {
dndWriteSnodeMsgToWorker(pDnode, &pDnode->smgmt.writeWorker, pMsg);
}
int32_t dndInitSnode(SDnode *pDnode) {
SSnodeMgmt *pMgmt = &pDnode->smgmt;
taosInitRWLatch(&pMgmt->latch);
if (dndReadSnodeFile(pDnode) != 0) {
return -1;
}
if (pMgmt->dropped) {
dInfo("snode has been deployed and needs to be deleted");
sndDestroy(pDnode->dir.snode);
return 0;
}
if (!pMgmt->deployed) return 0;
return dndOpenSnode(pDnode);
}
void dndCleanupSnode(SDnode *pDnode) {
SSnodeMgmt *pMgmt = &pDnode->smgmt;
if (pMgmt->pSnode) {
dndStopSnodeWorker(pDnode);
sndClose(pMgmt->pSnode);
pMgmt->pSnode = NULL;
}
}
...@@ -22,7 +22,7 @@ typedef struct { ...@@ -22,7 +22,7 @@ typedef struct {
int32_t vgVersion; int32_t vgVersion;
int8_t dropped; int8_t dropped;
uint64_t dbUid; uint64_t dbUid;
char db[TSDB_FULL_DB_NAME_LEN]; char db[TSDB_DB_FNAME_LEN];
char path[PATH_MAX + 20]; char path[PATH_MAX + 20];
} SWrapperCfg; } SWrapperCfg;
...@@ -319,7 +319,7 @@ static int32_t dndGetVnodesFromFile(SDnode *pDnode, SWrapperCfg **ppCfgs, int32_ ...@@ -319,7 +319,7 @@ static int32_t dndGetVnodesFromFile(SDnode *pDnode, SWrapperCfg **ppCfgs, int32_
dError("failed to read %s since db not found", file); dError("failed to read %s since db not found", file);
goto PRASE_VNODE_OVER; goto PRASE_VNODE_OVER;
} }
tstrncpy(pCfg->db, db->valuestring, TSDB_FULL_DB_NAME_LEN); tstrncpy(pCfg->db, db->valuestring, TSDB_DB_FNAME_LEN);
} }
*ppCfgs = pCfgs; *ppCfgs = pCfgs;
...@@ -569,7 +569,7 @@ static void dndGenerateVnodeCfg(SCreateVnodeMsg *pCreate, SVnodeCfg *pCfg) { ...@@ -569,7 +569,7 @@ static void dndGenerateVnodeCfg(SCreateVnodeMsg *pCreate, SVnodeCfg *pCfg) {
} }
static void dndGenerateWrapperCfg(SDnode *pDnode, SCreateVnodeMsg *pCreate, SWrapperCfg *pCfg) { static void dndGenerateWrapperCfg(SDnode *pDnode, SCreateVnodeMsg *pCreate, SWrapperCfg *pCfg) {
memcpy(pCfg->db, pCreate->db, TSDB_FULL_DB_NAME_LEN); memcpy(pCfg->db, pCreate->db, TSDB_DB_FNAME_LEN);
pCfg->dbUid = pCreate->dbUid; pCfg->dbUid = pCreate->dbUid;
pCfg->dropped = 0; pCfg->dropped = 0;
snprintf(pCfg->path, sizeof(pCfg->path), "%s/vnode%d", pDnode->dir.vnodes, pCreate->vgId); snprintf(pCfg->path, sizeof(pCfg->path), "%s/vnode%d", pDnode->dir.vnodes, pCreate->vgId);
......
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http:www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "dndWorker.h"
int32_t dndInitWorker(SDnode *pDnode, SDnodeWorker *pWorker, EWorkerType type, const char *name, int32_t minNum,
int32_t maxNum, void *queueFp) {
if (pDnode == NULL || pWorker == NULL || name == NULL || minNum < 0 || maxNum <= 0 || queueFp == NULL) {
terrno = TSDB_CODE_INVALID_PARA;
return -1;
}
pWorker->type = type;
pWorker->name = name;
pWorker->minNum = minNum;
pWorker->maxNum = maxNum;
pWorker->queueFp = queueFp;
pWorker->pDnode = pDnode;
if (pWorker->type == DND_WORKER_SINGLE) {
SWorkerPool *pPool = &pWorker->pool;
pPool->name = name;
pPool->min = minNum;
pPool->max = maxNum;
if (tWorkerInit(pPool) != 0) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
pWorker->queue = tWorkerAllocQueue(pPool, pDnode, (FProcessItem)queueFp);
if (pWorker->queue == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
} else if (pWorker->type == DND_WORKER_MULTI) {
SMWorkerPool *pPool = &pWorker->mpool;
pPool->name = name;
pPool->max = maxNum;
if (tMWorkerInit(pPool) != 0) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
pWorker->queue = tMWorkerAllocQueue(pPool, pDnode, (FProcessItems)queueFp);
if (pWorker->queue == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
} else {
terrno = TSDB_CODE_INVALID_PARA;
}
return 0;
}
void dndCleanupWorker(SDnodeWorker *pWorker) {
while (!taosQueueEmpty(pWorker->queue)) {
taosMsleep(10);
}
if (pWorker->type == DND_WORKER_SINGLE) {
tWorkerCleanup(&pWorker->pool);
tWorkerFreeQueue(&pWorker->pool, pWorker->queue);
} else if (pWorker->type == DND_WORKER_MULTI) {
tMWorkerCleanup(&pWorker->mpool);
tMWorkerFreeQueue(&pWorker->mpool, pWorker->queue);
} else {
}
}
int32_t dndWriteMsgToWorker(SDnodeWorker *pWorker, void *pCont, int32_t contLen) {
if (pWorker == NULL || pWorker->queue == NULL) {
terrno = TSDB_CODE_INVALID_PARA;
return -1;
}
void *pMsg = NULL;
if (contLen != 0) {
pMsg = taosAllocateQitem(contLen);
if (pMsg != NULL) {
memcpy(pMsg, pCont, contLen);
}
} else {
pMsg = pCont;
}
if (pMsg == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
if (taosWriteQitem(pWorker->queue, pMsg) != 0) {
taosFreeQitem(pMsg);
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
return 0;
}
\ No newline at end of file
...@@ -91,7 +91,8 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) { ...@@ -91,7 +91,8 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
int32_t contLen = sizeof(SCreateDnodeMsg); int32_t contLen = sizeof(SCreateDnodeMsg);
SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen); SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen);
strcpy(pReq->ep, "localhost:9042"); strcpy(pReq->fqdn, "localhost");
pReq->port = htonl(9042);
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen); SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen);
ASSERT_NE(pMsg, nullptr); ASSERT_NE(pMsg, nullptr);
...@@ -148,7 +149,8 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) { ...@@ -148,7 +149,8 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
int32_t contLen = sizeof(SCreateDnodeMsg); int32_t contLen = sizeof(SCreateDnodeMsg);
SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen); SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen);
strcpy(pReq->ep, "localhost:9043"); strcpy(pReq->fqdn, "localhost");
pReq->port = htonl(9043);
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen); SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen);
ASSERT_NE(pMsg, nullptr); ASSERT_NE(pMsg, nullptr);
...@@ -159,7 +161,8 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) { ...@@ -159,7 +161,8 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
int32_t contLen = sizeof(SCreateDnodeMsg); int32_t contLen = sizeof(SCreateDnodeMsg);
SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen); SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen);
strcpy(pReq->ep, "localhost:9044"); strcpy(pReq->fqdn, "localhost");
pReq->port = htonl(9044);
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen); SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen);
ASSERT_NE(pMsg, nullptr); ASSERT_NE(pMsg, nullptr);
...@@ -170,7 +173,8 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) { ...@@ -170,7 +173,8 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
int32_t contLen = sizeof(SCreateDnodeMsg); int32_t contLen = sizeof(SCreateDnodeMsg);
SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen); SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen);
strcpy(pReq->ep, "localhost:9045"); strcpy(pReq->fqdn, "localhost");
pReq->port = htonl(9045);
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen); SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen);
ASSERT_NE(pMsg, nullptr); ASSERT_NE(pMsg, nullptr);
......
...@@ -102,7 +102,8 @@ TEST_F(DndTestMnode, 04_Create_Mnode) { ...@@ -102,7 +102,8 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
int32_t contLen = sizeof(SCreateDnodeMsg); int32_t contLen = sizeof(SCreateDnodeMsg);
SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen); SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen);
strcpy(pReq->ep, "localhost:9062"); strcpy(pReq->fqdn, "localhost");
pReq->port = htonl(9062);
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen); SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen);
ASSERT_NE(pMsg, nullptr); ASSERT_NE(pMsg, nullptr);
......
...@@ -68,7 +68,6 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) { ...@@ -68,7 +68,6 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
{ {
SSchema* pSchema = &pReq->pSchema[0]; SSchema* pSchema = &pReq->pSchema[0];
pSchema->colId = htonl(0);
pSchema->bytes = htonl(8); pSchema->bytes = htonl(8);
pSchema->type = TSDB_DATA_TYPE_TIMESTAMP; pSchema->type = TSDB_DATA_TYPE_TIMESTAMP;
strcpy(pSchema->name, "ts"); strcpy(pSchema->name, "ts");
...@@ -76,7 +75,6 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) { ...@@ -76,7 +75,6 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
{ {
SSchema* pSchema = &pReq->pSchema[1]; SSchema* pSchema = &pReq->pSchema[1];
pSchema->colId = htonl(1);
pSchema->bytes = htonl(4); pSchema->bytes = htonl(4);
pSchema->type = TSDB_DATA_TYPE_INT; pSchema->type = TSDB_DATA_TYPE_INT;
strcpy(pSchema->name, "col1"); strcpy(pSchema->name, "col1");
...@@ -84,7 +82,6 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) { ...@@ -84,7 +82,6 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
{ {
SSchema* pSchema = &pReq->pSchema[2]; SSchema* pSchema = &pReq->pSchema[2];
pSchema->colId = htonl(2);
pSchema->bytes = htonl(2); pSchema->bytes = htonl(2);
pSchema->type = TSDB_DATA_TYPE_TINYINT; pSchema->type = TSDB_DATA_TYPE_TINYINT;
strcpy(pSchema->name, "tag1"); strcpy(pSchema->name, "tag1");
...@@ -92,7 +89,6 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) { ...@@ -92,7 +89,6 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
{ {
SSchema* pSchema = &pReq->pSchema[3]; SSchema* pSchema = &pReq->pSchema[3];
pSchema->colId = htonl(3);
pSchema->bytes = htonl(8); pSchema->bytes = htonl(8);
pSchema->type = TSDB_DATA_TYPE_BIGINT; pSchema->type = TSDB_DATA_TYPE_BIGINT;
strcpy(pSchema->name, "tag2"); strcpy(pSchema->name, "tag2");
...@@ -100,7 +96,6 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) { ...@@ -100,7 +96,6 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
{ {
SSchema* pSchema = &pReq->pSchema[4]; SSchema* pSchema = &pReq->pSchema[4];
pSchema->colId = htonl(4);
pSchema->bytes = htonl(16); pSchema->bytes = htonl(16);
pSchema->type = TSDB_DATA_TYPE_BINARY; pSchema->type = TSDB_DATA_TYPE_BINARY;
strcpy(pSchema->name, "tag3"); strcpy(pSchema->name, "tag3");
...@@ -167,10 +162,42 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) { ...@@ -167,10 +162,42 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
{ {
SSchema* pSchema = &pRsp->pSchema[0]; SSchema* pSchema = &pRsp->pSchema[0];
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_TIMESTAMP); EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_TIMESTAMP);
EXPECT_EQ(pSchema->colId, 0); EXPECT_EQ(pSchema->colId, 1);
EXPECT_EQ(pSchema->bytes, 8); EXPECT_EQ(pSchema->bytes, 8);
EXPECT_STREQ(pSchema->name, "ts"); EXPECT_STREQ(pSchema->name, "ts");
} }
{
SSchema* pSchema = &pRsp->pSchema[1];
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_INT);
EXPECT_EQ(pSchema->colId, 2);
EXPECT_EQ(pSchema->bytes, 4);
EXPECT_STREQ(pSchema->name, "col1");
}
{
SSchema* pSchema = &pRsp->pSchema[2];
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_TINYINT);
EXPECT_EQ(pSchema->colId, 3);
EXPECT_EQ(pSchema->bytes, 2);
EXPECT_STREQ(pSchema->name, "tag1");
}
{
SSchema* pSchema = &pRsp->pSchema[3];
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_BIGINT);
EXPECT_EQ(pSchema->colId, 4);
EXPECT_EQ(pSchema->bytes, 8);
EXPECT_STREQ(pSchema->name, "tag2");
}
{
SSchema* pSchema = &pRsp->pSchema[4];
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_BINARY);
EXPECT_EQ(pSchema->colId, 5);
EXPECT_EQ(pSchema->bytes, 16);
EXPECT_STREQ(pSchema->name, "tag3");
}
} }
// restart // restart
......
...@@ -209,7 +209,7 @@ typedef struct { ...@@ -209,7 +209,7 @@ typedef struct {
} SDbCfg; } SDbCfg;
typedef struct { typedef struct {
char name[TSDB_FULL_DB_NAME_LEN]; char name[TSDB_DB_FNAME_LEN];
char acct[TSDB_USER_LEN]; char acct[TSDB_USER_LEN];
int64_t createdTime; int64_t createdTime;
int64_t updateTime; int64_t updateTime;
...@@ -232,7 +232,7 @@ typedef struct { ...@@ -232,7 +232,7 @@ typedef struct {
int32_t version; int32_t version;
uint32_t hashBegin; uint32_t hashBegin;
uint32_t hashEnd; uint32_t hashEnd;
char dbName[TSDB_FULL_DB_NAME_LEN]; char dbName[TSDB_DB_FNAME_LEN];
int64_t dbUid; int64_t dbUid;
int32_t numOfTables; int32_t numOfTables;
int32_t numOfTimeSeries; int32_t numOfTimeSeries;
...@@ -246,7 +246,7 @@ typedef struct { ...@@ -246,7 +246,7 @@ typedef struct {
typedef struct { typedef struct {
char name[TSDB_TABLE_FNAME_LEN]; char name[TSDB_TABLE_FNAME_LEN];
char db[TSDB_FULL_DB_NAME_LEN]; char db[TSDB_DB_FNAME_LEN];
int64_t createdTime; int64_t createdTime;
int64_t updateTime; int64_t updateTime;
uint64_t uid; uint64_t uid;
...@@ -286,7 +286,7 @@ typedef struct { ...@@ -286,7 +286,7 @@ typedef struct {
int32_t payloadLen; int32_t payloadLen;
void *pIter; void *pIter;
SMnode *pMnode; SMnode *pMnode;
char db[TSDB_FULL_DB_NAME_LEN]; char db[TSDB_DB_FNAME_LEN];
int16_t offset[TSDB_MAX_COLUMNS]; int16_t offset[TSDB_MAX_COLUMNS];
int32_t bytes[TSDB_MAX_COLUMNS]; int32_t bytes[TSDB_MAX_COLUMNS];
char payload[]; char payload[];
...@@ -294,7 +294,7 @@ typedef struct { ...@@ -294,7 +294,7 @@ typedef struct {
typedef struct { typedef struct {
char name[TSDB_TOPIC_FNAME_LEN]; char name[TSDB_TOPIC_FNAME_LEN];
char db[TSDB_FULL_DB_NAME_LEN]; char db[TSDB_DB_FNAME_LEN];
int64_t createTime; int64_t createTime;
int64_t updateTime; int64_t updateTime;
uint64_t uid; uint64_t uid;
...@@ -309,7 +309,7 @@ typedef struct { ...@@ -309,7 +309,7 @@ typedef struct {
typedef struct SMnodeMsg { typedef struct SMnodeMsg {
char user[TSDB_USER_LEN]; char user[TSDB_USER_LEN];
char db[TSDB_FULL_DB_NAME_LEN]; char db[TSDB_DB_FNAME_LEN];
int32_t acctId; int32_t acctId;
SMnode *pMnode; SMnode *pMnode;
int64_t createdTime; int64_t createdTime;
......
...@@ -69,7 +69,7 @@ static SSdbRaw *mndDbActionEncode(SDbObj *pDb) { ...@@ -69,7 +69,7 @@ static SSdbRaw *mndDbActionEncode(SDbObj *pDb) {
if (pRaw == NULL) return NULL; if (pRaw == NULL) return NULL;
int32_t dataPos = 0; int32_t dataPos = 0;
SDB_SET_BINARY(pRaw, dataPos, pDb->name, TSDB_FULL_DB_NAME_LEN) SDB_SET_BINARY(pRaw, dataPos, pDb->name, TSDB_DB_FNAME_LEN)
SDB_SET_BINARY(pRaw, dataPos, pDb->acct, TSDB_USER_LEN) SDB_SET_BINARY(pRaw, dataPos, pDb->acct, TSDB_USER_LEN)
SDB_SET_INT64(pRaw, dataPos, pDb->createdTime) SDB_SET_INT64(pRaw, dataPos, pDb->createdTime)
SDB_SET_INT64(pRaw, dataPos, pDb->updateTime) SDB_SET_INT64(pRaw, dataPos, pDb->updateTime)
...@@ -116,7 +116,7 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) { ...@@ -116,7 +116,7 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) {
if (pDb == NULL) return NULL; if (pDb == NULL) return NULL;
int32_t dataPos = 0; int32_t dataPos = 0;
SDB_GET_BINARY(pRaw, pRow, dataPos, pDb->name, TSDB_FULL_DB_NAME_LEN) SDB_GET_BINARY(pRaw, pRow, dataPos, pDb->name, TSDB_DB_FNAME_LEN)
SDB_GET_BINARY(pRaw, pRow, dataPos, pDb->acct, TSDB_USER_LEN) SDB_GET_BINARY(pRaw, pRow, dataPos, pDb->acct, TSDB_USER_LEN)
SDB_GET_INT64(pRaw, pRow, dataPos, &pDb->createdTime) SDB_GET_INT64(pRaw, pRow, dataPos, &pDb->createdTime)
SDB_GET_INT64(pRaw, pRow, dataPos, &pDb->updateTime) SDB_GET_INT64(pRaw, pRow, dataPos, &pDb->updateTime)
...@@ -353,11 +353,11 @@ static int32_t mndSetCreateDbUndoActions(SMnode *pMnode, STrans *pTrans, SDbObj ...@@ -353,11 +353,11 @@ static int32_t mndSetCreateDbUndoActions(SMnode *pMnode, STrans *pTrans, SDbObj
static int32_t mndCreateDb(SMnode *pMnode, SMnodeMsg *pMsg, SCreateDbMsg *pCreate, SUserObj *pUser) { static int32_t mndCreateDb(SMnode *pMnode, SMnodeMsg *pMsg, SCreateDbMsg *pCreate, SUserObj *pUser) {
SDbObj dbObj = {0}; SDbObj dbObj = {0};
memcpy(dbObj.name, pCreate->db, TSDB_FULL_DB_NAME_LEN); memcpy(dbObj.name, pCreate->db, TSDB_DB_FNAME_LEN);
memcpy(dbObj.acct, pUser->acct, TSDB_USER_LEN); memcpy(dbObj.acct, pUser->acct, TSDB_USER_LEN);
dbObj.createdTime = taosGetTimestampMs(); dbObj.createdTime = taosGetTimestampMs();
dbObj.updateTime = dbObj.createdTime; dbObj.updateTime = dbObj.createdTime;
dbObj.uid = mndGenerateUid(dbObj.name, TSDB_FULL_DB_NAME_LEN); dbObj.uid = mndGenerateUid(dbObj.name, TSDB_DB_FNAME_LEN);
dbObj.cfgVersion = 1; dbObj.cfgVersion = 1;
dbObj.vgVersion = 1; dbObj.vgVersion = 1;
dbObj.hashMethod = 1; dbObj.hashMethod = 1;
...@@ -891,7 +891,7 @@ static int32_t mndProcessUseDbMsg(SMnodeMsg *pMsg) { ...@@ -891,7 +891,7 @@ static int32_t mndProcessUseDbMsg(SMnodeMsg *pMsg) {
} }
} }
memcpy(pRsp->db, pDb->name, TSDB_FULL_DB_NAME_LEN); memcpy(pRsp->db, pDb->name, TSDB_DB_FNAME_LEN);
pRsp->vgVersion = htonl(pDb->vgVersion); pRsp->vgVersion = htonl(pDb->vgVersion);
pRsp->vgNum = htonl(vindex); pRsp->vgNum = htonl(vindex);
pRsp->hashMethod = pDb->hashMethod; pRsp->hashMethod = pDb->hashMethod;
......
...@@ -386,20 +386,16 @@ static int32_t mndCreateDnode(SMnode *pMnode, SMnodeMsg *pMsg, SCreateDnodeMsg * ...@@ -386,20 +386,16 @@ static int32_t mndCreateDnode(SMnode *pMnode, SMnodeMsg *pMsg, SCreateDnodeMsg *
dnodeObj.id = sdbGetMaxId(pMnode->pSdb, SDB_DNODE); dnodeObj.id = sdbGetMaxId(pMnode->pSdb, SDB_DNODE);
dnodeObj.createdTime = taosGetTimestampMs(); dnodeObj.createdTime = taosGetTimestampMs();
dnodeObj.updateTime = dnodeObj.createdTime; dnodeObj.updateTime = dnodeObj.createdTime;
taosGetFqdnPortFromEp(pCreate->ep, dnodeObj.fqdn, &dnodeObj.port); dnodeObj.port = pCreate->port;
memcpy(dnodeObj.fqdn, pCreate->fqdn, TSDB_FQDN_LEN);
if (dnodeObj.fqdn[0] == 0 || dnodeObj.port <= 0) { snprintf(dnodeObj.ep, TSDB_EP_LEN, "%s:%u", dnodeObj.fqdn, dnodeObj.port);
terrno = TSDB_CODE_MND_INVALID_DNODE_EP;
mError("dnode:%s, failed to create since %s", pCreate->ep, terrstr());
return terrno;
}
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, &pMsg->rpcMsg); STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, &pMsg->rpcMsg);
if (pTrans == NULL) { if (pTrans == NULL) {
mError("dnode:%s, failed to create since %s", pCreate->ep, terrstr()); mError("dnode:%s, failed to create since %s", dnodeObj.ep, terrstr());
return -1; return -1;
} }
mDebug("trans:%d, used to create dnode:%s", pTrans->id, pCreate->ep); mDebug("trans:%d, used to create dnode:%s", pTrans->id, dnodeObj.ep);
SSdbRaw *pRedoRaw = mndDnodeActionEncode(&dnodeObj); SSdbRaw *pRedoRaw = mndDnodeActionEncode(&dnodeObj);
if (pRedoRaw == NULL || mndTransAppendRedolog(pTrans, pRedoRaw) != 0) { if (pRedoRaw == NULL || mndTransAppendRedolog(pTrans, pRedoRaw) != 0) {
...@@ -423,17 +419,20 @@ static int32_t mndProcessCreateDnodeMsg(SMnodeMsg *pMsg) { ...@@ -423,17 +419,20 @@ static int32_t mndProcessCreateDnodeMsg(SMnodeMsg *pMsg) {
SMnode *pMnode = pMsg->pMnode; SMnode *pMnode = pMsg->pMnode;
SCreateDnodeMsg *pCreate = pMsg->rpcMsg.pCont; SCreateDnodeMsg *pCreate = pMsg->rpcMsg.pCont;
mDebug("dnode:%s, start to create", pCreate->ep); mDebug("dnode:%s:%d, start to create", pCreate->fqdn, pCreate->port);
if (pCreate->ep[0] == 0) { pCreate->port = htonl(pCreate->port);
if (pCreate->fqdn[0] == 0 || pCreate->port <= 0 || pCreate->port > UINT16_MAX) {
terrno = TSDB_CODE_MND_INVALID_DNODE_EP; terrno = TSDB_CODE_MND_INVALID_DNODE_EP;
mError("dnode:%s, failed to create since %s", pCreate->ep, terrstr()); mError("dnode:%s:%d, failed to create since %s", pCreate->fqdn, pCreate->port, terrstr());
return -1; return -1;
} }
SDnodeObj *pDnode = mndAcquireDnodeByEp(pMnode, pCreate->ep); char ep[TSDB_EP_LEN];
snprintf(ep, TSDB_EP_LEN, "%s:%d", pCreate->fqdn, pCreate->port);
SDnodeObj *pDnode = mndAcquireDnodeByEp(pMnode, ep);
if (pDnode != NULL) { if (pDnode != NULL) {
mError("dnode:%d, already exist", pDnode->id); mError("dnode:%d, already exist, %s:%u", pDnode->id, pCreate->fqdn, pCreate->port);
mndReleaseDnode(pMnode, pDnode); mndReleaseDnode(pMnode, pDnode);
terrno = TSDB_CODE_MND_DNODE_ALREADY_EXIST; terrno = TSDB_CODE_MND_DNODE_ALREADY_EXIST;
return -1; return -1;
...@@ -442,7 +441,7 @@ static int32_t mndProcessCreateDnodeMsg(SMnodeMsg *pMsg) { ...@@ -442,7 +441,7 @@ static int32_t mndProcessCreateDnodeMsg(SMnodeMsg *pMsg) {
int32_t code = mndCreateDnode(pMnode, pMsg, pCreate); int32_t code = mndCreateDnode(pMnode, pMsg, pCreate);
if (code != 0) { if (code != 0) {
mError("dnode:%s, failed to create since %s", pCreate->ep, terrstr()); mError("dnode:%s:%d, failed to create since %s", pCreate->fqdn, pCreate->port, terrstr());
return -1; return -1;
} }
......
...@@ -194,7 +194,7 @@ static int32_t mndProcessConnectMsg(SMnodeMsg *pMsg) { ...@@ -194,7 +194,7 @@ static int32_t mndProcessConnectMsg(SMnodeMsg *pMsg) {
taosIp2String(info.clientIp, ip); taosIp2String(info.clientIp, ip);
if (pReq->db[0]) { if (pReq->db[0]) {
snprintf(pMsg->db, TSDB_FULL_DB_NAME_LEN, "%d%s%s", pMsg->acctId, TS_PATH_DELIMITER, pReq->db); snprintf(pMsg->db, TSDB_DB_FNAME_LEN, "%d%s%s", pMsg->acctId, TS_PATH_DELIMITER, pReq->db);
SDbObj *pDb = mndAcquireDb(pMnode, pMsg->db); SDbObj *pDb = mndAcquireDb(pMnode, pMsg->db);
if (pDb == NULL) { if (pDb == NULL) {
terrno = TSDB_CODE_MND_INVALID_DB; terrno = TSDB_CODE_MND_INVALID_DB;
......
...@@ -62,7 +62,7 @@ static SShowObj *mndCreateShowObj(SMnode *pMnode, SShowMsg *pMsg) { ...@@ -62,7 +62,7 @@ static SShowObj *mndCreateShowObj(SMnode *pMnode, SShowMsg *pMsg) {
pShow->pMnode = pMnode; pShow->pMnode = pMnode;
pShow->type = pMsg->type; pShow->type = pMsg->type;
pShow->payloadLen = pMsg->payloadLen; pShow->payloadLen = pMsg->payloadLen;
memcpy(pShow->db, pMsg->db, TSDB_FULL_DB_NAME_LEN); memcpy(pShow->db, pMsg->db, TSDB_DB_FNAME_LEN);
memcpy(pShow->payload, pMsg->payload, pMsg->payloadLen); memcpy(pShow->payload, pMsg->payload, pMsg->payloadLen);
} else { } else {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
......
...@@ -76,7 +76,7 @@ static SSdbRaw *mndStbActionEncode(SStbObj *pStb) { ...@@ -76,7 +76,7 @@ static SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
int32_t dataPos = 0; int32_t dataPos = 0;
SDB_SET_BINARY(pRaw, dataPos, pStb->name, TSDB_TABLE_FNAME_LEN) SDB_SET_BINARY(pRaw, dataPos, pStb->name, TSDB_TABLE_FNAME_LEN)
SDB_SET_BINARY(pRaw, dataPos, pStb->db, TSDB_FULL_DB_NAME_LEN) SDB_SET_BINARY(pRaw, dataPos, pStb->db, TSDB_DB_FNAME_LEN)
SDB_SET_INT64(pRaw, dataPos, pStb->createdTime) SDB_SET_INT64(pRaw, dataPos, pStb->createdTime)
SDB_SET_INT64(pRaw, dataPos, pStb->updateTime) SDB_SET_INT64(pRaw, dataPos, pStb->updateTime)
SDB_SET_INT64(pRaw, dataPos, pStb->uid) SDB_SET_INT64(pRaw, dataPos, pStb->uid)
...@@ -117,7 +117,7 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) { ...@@ -117,7 +117,7 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
int32_t dataPos = 0; int32_t dataPos = 0;
SDB_GET_BINARY(pRaw, pRow, dataPos, pStb->name, TSDB_TABLE_FNAME_LEN) SDB_GET_BINARY(pRaw, pRow, dataPos, pStb->name, TSDB_TABLE_FNAME_LEN)
SDB_GET_BINARY(pRaw, pRow, dataPos, pStb->db, TSDB_FULL_DB_NAME_LEN) SDB_GET_BINARY(pRaw, pRow, dataPos, pStb->db, TSDB_DB_FNAME_LEN)
SDB_GET_INT64(pRaw, pRow, dataPos, &pStb->createdTime) SDB_GET_INT64(pRaw, pRow, dataPos, &pStb->createdTime)
SDB_GET_INT64(pRaw, pRow, dataPos, &pStb->updateTime) SDB_GET_INT64(pRaw, pRow, dataPos, &pStb->updateTime)
SDB_GET_INT64(pRaw, pRow, dataPos, &pStb->uid) SDB_GET_INT64(pRaw, pRow, dataPos, &pStb->uid)
...@@ -291,7 +291,6 @@ static int32_t mndCheckCreateStbMsg(SCreateStbMsg *pCreate) { ...@@ -291,7 +291,6 @@ static int32_t mndCheckCreateStbMsg(SCreateStbMsg *pCreate) {
int32_t totalCols = pCreate->numOfColumns + pCreate->numOfTags; int32_t totalCols = pCreate->numOfColumns + pCreate->numOfTags;
for (int32_t i = 0; i < totalCols; ++i) { for (int32_t i = 0; i < totalCols; ++i) {
SSchema *pSchema = &pCreate->pSchema[i]; SSchema *pSchema = &pCreate->pSchema[i];
pSchema->colId = htonl(pSchema->colId);
pSchema->bytes = htonl(pSchema->bytes); pSchema->bytes = htonl(pSchema->bytes);
} }
...@@ -317,10 +316,6 @@ static int32_t mndCheckCreateStbMsg(SCreateStbMsg *pCreate) { ...@@ -317,10 +316,6 @@ static int32_t mndCheckCreateStbMsg(SCreateStbMsg *pCreate) {
terrno = TSDB_CODE_MND_INVALID_STB_OPTION; terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
return -1; return -1;
} }
if (pSchema->colId < 0 || pSchema->colId >= maxColId) {
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
return -1;
}
if (pSchema->bytes <= 0) { if (pSchema->bytes <= 0) {
terrno = TSDB_CODE_MND_INVALID_STB_OPTION; terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
return -1; return -1;
...@@ -435,7 +430,7 @@ static int32_t mndSetCreateStbUndoActions(SMnode *pMnode, STrans *pTrans, SDbObj ...@@ -435,7 +430,7 @@ static int32_t mndSetCreateStbUndoActions(SMnode *pMnode, STrans *pTrans, SDbObj
static int32_t mndCreateStb(SMnode *pMnode, SMnodeMsg *pMsg, SCreateStbMsg *pCreate, SDbObj *pDb) { static int32_t mndCreateStb(SMnode *pMnode, SMnodeMsg *pMsg, SCreateStbMsg *pCreate, SDbObj *pDb) {
SStbObj stbObj = {0}; SStbObj stbObj = {0};
tstrncpy(stbObj.name, pCreate->name, TSDB_TABLE_FNAME_LEN); tstrncpy(stbObj.name, pCreate->name, TSDB_TABLE_FNAME_LEN);
tstrncpy(stbObj.db, pDb->name, TSDB_FULL_DB_NAME_LEN); tstrncpy(stbObj.db, pDb->name, TSDB_DB_FNAME_LEN);
stbObj.createdTime = taosGetTimestampMs(); stbObj.createdTime = taosGetTimestampMs();
stbObj.updateTime = stbObj.createdTime; stbObj.updateTime = stbObj.createdTime;
stbObj.uid = mndGenerateUid(pCreate->name, TSDB_TABLE_FNAME_LEN); stbObj.uid = mndGenerateUid(pCreate->name, TSDB_TABLE_FNAME_LEN);
...@@ -453,6 +448,10 @@ static int32_t mndCreateStb(SMnode *pMnode, SMnodeMsg *pMsg, SCreateStbMsg *pCre ...@@ -453,6 +448,10 @@ static int32_t mndCreateStb(SMnode *pMnode, SMnodeMsg *pMsg, SCreateStbMsg *pCre
} }
memcpy(stbObj.pSchema, pCreate->pSchema, totalSize); memcpy(stbObj.pSchema, pCreate->pSchema, totalSize);
for (int32_t i = 0; i < totalCols; ++i) {
stbObj.pSchema[i].colId = i + 1;
}
int32_t code = 0; int32_t code = 0;
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, &pMsg->rpcMsg); STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, &pMsg->rpcMsg);
if (pTrans == NULL) { if (pTrans == NULL) {
...@@ -767,7 +766,7 @@ static int32_t mndProcessStbMetaMsg(SMnodeMsg *pMsg) { ...@@ -767,7 +766,7 @@ static int32_t mndProcessStbMetaMsg(SMnodeMsg *pMsg) {
return -1; return -1;
} }
memcpy(pMeta->stbFname, pStb->name, TSDB_TABLE_FNAME_LEN); memcpy(pMeta->tbFname, pStb->name, TSDB_TABLE_FNAME_LEN);
pMeta->numOfTags = htonl(pStb->numOfTags); pMeta->numOfTags = htonl(pStb->numOfTags);
pMeta->numOfColumns = htonl(pStb->numOfColumns); pMeta->numOfColumns = htonl(pStb->numOfColumns);
pMeta->precision = pDb->cfg.precision; pMeta->precision = pDb->cfg.precision;
......
...@@ -79,7 +79,7 @@ static SSdbRaw *mndTopicActionEncode(STopicObj *pTopic) { ...@@ -79,7 +79,7 @@ static SSdbRaw *mndTopicActionEncode(STopicObj *pTopic) {
int32_t dataPos = 0; int32_t dataPos = 0;
SDB_SET_BINARY(pRaw, dataPos, pTopic->name, TSDB_TABLE_FNAME_LEN); SDB_SET_BINARY(pRaw, dataPos, pTopic->name, TSDB_TABLE_FNAME_LEN);
SDB_SET_BINARY(pRaw, dataPos, pTopic->db, TSDB_FULL_DB_NAME_LEN); SDB_SET_BINARY(pRaw, dataPos, pTopic->db, TSDB_DB_FNAME_LEN);
SDB_SET_INT64(pRaw, dataPos, pTopic->createTime); SDB_SET_INT64(pRaw, dataPos, pTopic->createTime);
SDB_SET_INT64(pRaw, dataPos, pTopic->updateTime); SDB_SET_INT64(pRaw, dataPos, pTopic->updateTime);
SDB_SET_INT64(pRaw, dataPos, pTopic->uid); SDB_SET_INT64(pRaw, dataPos, pTopic->uid);
...@@ -113,7 +113,7 @@ static SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) { ...@@ -113,7 +113,7 @@ static SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
int32_t dataPos = 0; int32_t dataPos = 0;
SDB_GET_BINARY(pRaw, pRow, dataPos, pTopic->name, TSDB_TABLE_FNAME_LEN); SDB_GET_BINARY(pRaw, pRow, dataPos, pTopic->name, TSDB_TABLE_FNAME_LEN);
SDB_GET_BINARY(pRaw, pRow, dataPos, pTopic->db, TSDB_FULL_DB_NAME_LEN); SDB_GET_BINARY(pRaw, pRow, dataPos, pTopic->db, TSDB_DB_FNAME_LEN);
SDB_GET_INT64(pRaw, pRow, dataPos, &pTopic->createTime); SDB_GET_INT64(pRaw, pRow, dataPos, &pTopic->createTime);
SDB_GET_INT64(pRaw, pRow, dataPos, &pTopic->updateTime); SDB_GET_INT64(pRaw, pRow, dataPos, &pTopic->updateTime);
SDB_GET_INT64(pRaw, pRow, dataPos, &pTopic->uid); SDB_GET_INT64(pRaw, pRow, dataPos, &pTopic->uid);
...@@ -348,7 +348,7 @@ static int32_t mndSetCreateTopicUndoActions(SMnode *pMnode, STrans *pTrans, SDbO ...@@ -348,7 +348,7 @@ static int32_t mndSetCreateTopicUndoActions(SMnode *pMnode, STrans *pTrans, SDbO
static int32_t mndCreateTopic(SMnode *pMnode, SMnodeMsg *pMsg, SCreateTopicMsg *pCreate, SDbObj *pDb) { static int32_t mndCreateTopic(SMnode *pMnode, SMnodeMsg *pMsg, SCreateTopicMsg *pCreate, SDbObj *pDb) {
STopicObj topicObj = {0}; STopicObj topicObj = {0};
tstrncpy(topicObj.name, pCreate->name, TSDB_TABLE_FNAME_LEN); tstrncpy(topicObj.name, pCreate->name, TSDB_TABLE_FNAME_LEN);
tstrncpy(topicObj.db, pDb->name, TSDB_FULL_DB_NAME_LEN); tstrncpy(topicObj.db, pDb->name, TSDB_DB_FNAME_LEN);
topicObj.createTime = taosGetTimestampMs(); topicObj.createTime = taosGetTimestampMs();
topicObj.updateTime = topicObj.createTime; topicObj.updateTime = topicObj.createTime;
topicObj.uid = mndGenerateUid(pCreate->name, TSDB_TABLE_FNAME_LEN); topicObj.uid = mndGenerateUid(pCreate->name, TSDB_TABLE_FNAME_LEN);
......
...@@ -80,7 +80,7 @@ SSdbRaw *mndVgroupActionEncode(SVgObj *pVgroup) { ...@@ -80,7 +80,7 @@ SSdbRaw *mndVgroupActionEncode(SVgObj *pVgroup) {
SDB_SET_INT32(pRaw, dataPos, pVgroup->version) SDB_SET_INT32(pRaw, dataPos, pVgroup->version)
SDB_SET_INT32(pRaw, dataPos, pVgroup->hashBegin) SDB_SET_INT32(pRaw, dataPos, pVgroup->hashBegin)
SDB_SET_INT32(pRaw, dataPos, pVgroup->hashEnd) SDB_SET_INT32(pRaw, dataPos, pVgroup->hashEnd)
SDB_SET_BINARY(pRaw, dataPos, pVgroup->dbName, TSDB_FULL_DB_NAME_LEN) SDB_SET_BINARY(pRaw, dataPos, pVgroup->dbName, TSDB_DB_FNAME_LEN)
SDB_SET_INT64(pRaw, dataPos, pVgroup->dbUid) SDB_SET_INT64(pRaw, dataPos, pVgroup->dbUid)
SDB_SET_INT8(pRaw, dataPos, pVgroup->replica) SDB_SET_INT8(pRaw, dataPos, pVgroup->replica)
for (int8_t i = 0; i < pVgroup->replica; ++i) { for (int8_t i = 0; i < pVgroup->replica; ++i) {
...@@ -115,7 +115,7 @@ SSdbRow *mndVgroupActionDecode(SSdbRaw *pRaw) { ...@@ -115,7 +115,7 @@ SSdbRow *mndVgroupActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT32(pRaw, pRow, dataPos, &pVgroup->version) SDB_GET_INT32(pRaw, pRow, dataPos, &pVgroup->version)
SDB_GET_INT32(pRaw, pRow, dataPos, &pVgroup->hashBegin) SDB_GET_INT32(pRaw, pRow, dataPos, &pVgroup->hashBegin)
SDB_GET_INT32(pRaw, pRow, dataPos, &pVgroup->hashEnd) SDB_GET_INT32(pRaw, pRow, dataPos, &pVgroup->hashEnd)
SDB_GET_BINARY(pRaw, pRow, dataPos, pVgroup->dbName, TSDB_FULL_DB_NAME_LEN) SDB_GET_BINARY(pRaw, pRow, dataPos, pVgroup->dbName, TSDB_DB_FNAME_LEN)
SDB_GET_INT64(pRaw, pRow, dataPos, &pVgroup->dbUid) SDB_GET_INT64(pRaw, pRow, dataPos, &pVgroup->dbUid)
SDB_GET_INT8(pRaw, pRow, dataPos, &pVgroup->replica) SDB_GET_INT8(pRaw, pRow, dataPos, &pVgroup->replica)
for (int8_t i = 0; i < pVgroup->replica; ++i) { for (int8_t i = 0; i < pVgroup->replica; ++i) {
...@@ -172,7 +172,7 @@ SCreateVnodeMsg *mndBuildCreateVnodeMsg(SMnode *pMnode, SDnodeObj *pDnode, SDbOb ...@@ -172,7 +172,7 @@ SCreateVnodeMsg *mndBuildCreateVnodeMsg(SMnode *pMnode, SDnodeObj *pDnode, SDbOb
pCreate->vgId = htonl(pVgroup->vgId); pCreate->vgId = htonl(pVgroup->vgId);
pCreate->dnodeId = htonl(pDnode->id); pCreate->dnodeId = htonl(pDnode->id);
memcpy(pCreate->db, pDb->name, TSDB_FULL_DB_NAME_LEN); memcpy(pCreate->db, pDb->name, TSDB_DB_FNAME_LEN);
pCreate->dbUid = htobe64(pDb->uid); pCreate->dbUid = htobe64(pDb->uid);
pCreate->vgVersion = htonl(pVgroup->version); pCreate->vgVersion = htonl(pVgroup->version);
pCreate->cacheBlockSize = htonl(pDb->cfg.cacheBlockSize); pCreate->cacheBlockSize = htonl(pDb->cfg.cacheBlockSize);
...@@ -231,7 +231,7 @@ SDropVnodeMsg *mndBuildDropVnodeMsg(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *p ...@@ -231,7 +231,7 @@ SDropVnodeMsg *mndBuildDropVnodeMsg(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *p
pDrop->dnodeId = htonl(pDnode->id); pDrop->dnodeId = htonl(pDnode->id);
pDrop->vgId = htonl(pVgroup->vgId); pDrop->vgId = htonl(pVgroup->vgId);
memcpy(pDrop->db, pDb->name, TSDB_FULL_DB_NAME_LEN); memcpy(pDrop->db, pDb->name, TSDB_DB_FNAME_LEN);
pDrop->dbUid = htobe64(pDb->uid); pDrop->dbUid = htobe64(pDb->uid);
return pDrop; return pDrop;
...@@ -294,7 +294,7 @@ int32_t mndAllocVgroup(SMnode *pMnode, SDbObj *pDb, SVgObj **ppVgroups) { ...@@ -294,7 +294,7 @@ int32_t mndAllocVgroup(SMnode *pMnode, SDbObj *pDb, SVgObj **ppVgroups) {
pVgroup->hashEnd = hashMin + hashInterval * (v + 1) - 1; pVgroup->hashEnd = hashMin + hashInterval * (v + 1) - 1;
} }
memcpy(pVgroup->dbName, pDb->name, TSDB_FULL_DB_NAME_LEN); memcpy(pVgroup->dbName, pDb->name, TSDB_DB_FNAME_LEN);
pVgroup->dbUid = pDb->uid; pVgroup->dbUid = pDb->uid;
pVgroup->replica = pDb->cfg.replications; pVgroup->replica = pDb->cfg.replications;
......
...@@ -390,7 +390,7 @@ void mndSendRsp(SMnodeMsg *pMsg, int32_t code) { ...@@ -390,7 +390,7 @@ void mndSendRsp(SMnodeMsg *pMsg, int32_t code) {
rpcSendResponse(&rpcRsp); rpcSendResponse(&rpcRsp);
} }
static void mndProcessRpcMsg(SMnodeMsg *pMsg) { void mndProcessMsg(SMnodeMsg *pMsg) {
SMnode *pMnode = pMsg->pMnode; SMnode *pMnode = pMsg->pMnode;
int32_t code = 0; int32_t code = 0;
tmsg_t msgType = pMsg->rpcMsg.msgType; tmsg_t msgType = pMsg->rpcMsg.msgType;
...@@ -451,12 +451,6 @@ void mndSetMsgHandle(SMnode *pMnode, tmsg_t msgType, MndMsgFp fp) { ...@@ -451,12 +451,6 @@ void mndSetMsgHandle(SMnode *pMnode, tmsg_t msgType, MndMsgFp fp) {
} }
} }
void mndProcessReadMsg(SMnodeMsg *pMsg) { mndProcessRpcMsg(pMsg); }
void mndProcessWriteMsg(SMnodeMsg *pMsg) { mndProcessRpcMsg(pMsg); }
void mndProcessSyncMsg(SMnodeMsg *pMsg) { mndProcessRpcMsg(pMsg); }
uint64_t mndGenerateUid(char *name, int32_t len) { uint64_t mndGenerateUid(char *name, int32_t len) {
int64_t us = taosGetTimestampUs(); int64_t us = taosGetTimestampUs();
int32_t hashval = MurmurHash3_32(name, len); int32_t hashval = MurmurHash3_32(name, len);
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include "sndInt.h" #include "sndInt.h"
SSnode *sndOpen(const SSnodeOpt *pOption) { SSnode *sndOpen(const char *path, const SSnodeOpt *pOption) {
SSnode *pSnode = calloc(1, sizeof(SSnode)); SSnode *pSnode = calloc(1, sizeof(SSnode));
return pSnode; return pSnode;
} }
...@@ -28,3 +28,5 @@ int32_t sndProcessWriteMsg(SSnode *pSnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { ...@@ -28,3 +28,5 @@ int32_t sndProcessWriteMsg(SSnode *pSnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
*pRsp = NULL; *pRsp = NULL;
return 0; return 0;
} }
void sndDestroy(const char *path) {}
\ No newline at end of file
...@@ -73,7 +73,7 @@ struct SVnode { ...@@ -73,7 +73,7 @@ struct SVnode {
SVnodeSync* pSync; SVnodeSync* pSync;
SVnodeFS* pFs; SVnodeFS* pFs;
tsem_t canCommit; tsem_t canCommit;
void* pQuery; SQHandle* pQuery;
}; };
int vnodeScheduleTask(SVnodeTask* task); int vnodeScheduleTask(SVnodeTask* task);
......
...@@ -22,6 +22,9 @@ extern "C" { ...@@ -22,6 +22,9 @@ extern "C" {
#include "vnodeInt.h" #include "vnodeInt.h"
#include "qworker.h" #include "qworker.h"
typedef struct SQWorkerMgmt SQHandle;
int vnodeQueryOpen(SVnode *pVnode); int vnodeQueryOpen(SVnode *pVnode);
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -20,13 +20,27 @@ int vnodeQueryOpen(SVnode *pVnode) { return qWorkerInit(NULL, &pVnode->pQuery); ...@@ -20,13 +20,27 @@ int vnodeQueryOpen(SVnode *pVnode) { return qWorkerInit(NULL, &pVnode->pQuery);
int vnodeProcessQueryReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { int vnodeProcessQueryReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
vInfo("query message is processed"); vInfo("query message is processed");
qWorkerProcessQueryMsg(pVnode, pVnode->pQuery, pMsg); return qWorkerProcessQueryMsg(pVnode, pVnode->pQuery, pMsg);
return 0;
} }
int vnodeProcessFetchReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { int vnodeProcessFetchReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
vInfo("fetch message is processed"); vInfo("fetch message is processed");
qWorkerProcessFetchMsg(pVnode, pVnode->pQuery, pMsg); switch (pMsg->msgType) {
case TDMT_VND_FETCH:
return qWorkerProcessFetchMsg(pVnode, pVnode->pQuery, pMsg);
case TDMT_VND_RES_READY:
return qWorkerProcessReadyMsg(pVnode, pVnode->pQuery, pMsg);
case TDMT_VND_TASKS_STATUS:
return qWorkerProcessStatusMsg(pVnode, pVnode->pQuery, pMsg);
case TDMT_VND_CANCEL_TASK:
return qWorkerProcessCancelMsg(pVnode, pVnode->pQuery, pMsg);
case TDMT_VND_DROP_TASK:
return qWorkerProcessDropMsg(pVnode, pVnode->pQuery, pMsg);
default:
vError("unknown msg type:%d in fetch queue", pMsg->msgType);
return TSDB_CODE_VND_APP_ERROR;
break;
}
return 0; return 0;
} }
......
...@@ -46,7 +46,6 @@ typedef struct STableMetaCache { ...@@ -46,7 +46,6 @@ typedef struct STableMetaCache {
} STableMetaCache; } STableMetaCache;
typedef struct SCatalog { typedef struct SCatalog {
SVgroupListCache vgroupCache;
SDBVgroupCache dbCache; SDBVgroupCache dbCache;
STableMetaCache tableCache; STableMetaCache tableCache;
} SCatalog; } SCatalog;
...@@ -67,6 +66,7 @@ typedef uint32_t (*tableNameHashFp)(const char *, uint32_t); ...@@ -67,6 +66,7 @@ typedef uint32_t (*tableNameHashFp)(const char *, uint32_t);
#define ctgTrace(...) do { if (ctgDebugFlag & DEBUG_TRACE) { taosPrintLog("CTG ", ctgDebugFlag, __VA_ARGS__); }} while(0) #define ctgTrace(...) do { if (ctgDebugFlag & DEBUG_TRACE) { taosPrintLog("CTG ", ctgDebugFlag, __VA_ARGS__); }} while(0)
#define ctgDebugL(...) do { if (ctgDebugFlag & DEBUG_DEBUG) { taosPrintLongString("CTG ", ctgDebugFlag, __VA_ARGS__); }} while(0) #define ctgDebugL(...) do { if (ctgDebugFlag & DEBUG_DEBUG) { taosPrintLongString("CTG ", ctgDebugFlag, __VA_ARGS__); }} while(0)
#define CTG_CACHE_ENABLED() (ctgMgmt.cfg.maxDBCacheNum > 0 || ctgMgmt.cfg.maxTblCacheNum > 0)
#define CTG_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0) #define CTG_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0)
#define CTG_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0) #define CTG_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0)
......
...@@ -49,22 +49,11 @@ int32_t ctgGetDBVgroupFromMnode(struct SCatalog* pCatalog, void *pRpc, const SEp ...@@ -49,22 +49,11 @@ int32_t ctgGetDBVgroupFromMnode(struct SCatalog* pCatalog, void *pRpc, const SEp
SEpSet *pVnodeEpSet = NULL; SEpSet *pVnodeEpSet = NULL;
int32_t msgLen = 0; int32_t msgLen = 0;
CTG_ERR_RET(queryBuildMsg[TDMT_MND_USE_DB](input, &msg, 0, &msgLen)); CTG_ERR_RET(queryBuildMsg[TMSG_INDEX(TDMT_MND_USE_DB)](input, &msg, 0, &msgLen));
char *pMsg = rpcMallocCont(msgLen);
if (NULL == pMsg) {
ctgError("rpc malloc %d failed", msgLen);
tfree(msg);
CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR);
}
memcpy(pMsg, msg, msgLen);
tfree(msg);
SRpcMsg rpcMsg = { SRpcMsg rpcMsg = {
.msgType = TDMT_MND_USE_DB, .msgType = TDMT_MND_USE_DB,
.pCont = pMsg, .pCont = msg,
.contLen = msgLen, .contLen = msgLen,
}; };
...@@ -76,7 +65,7 @@ int32_t ctgGetDBVgroupFromMnode(struct SCatalog* pCatalog, void *pRpc, const SEp ...@@ -76,7 +65,7 @@ int32_t ctgGetDBVgroupFromMnode(struct SCatalog* pCatalog, void *pRpc, const SEp
CTG_ERR_RET(rpcRsp.code); CTG_ERR_RET(rpcRsp.code);
} }
CTG_ERR_RET(queryProcessMsgRsp[TDMT_MND_USE_DB](out, rpcRsp.pCont, rpcRsp.contLen)); CTG_ERR_RET(queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_USE_DB)](out, rpcRsp.pCont, rpcRsp.contLen));
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
...@@ -146,8 +135,44 @@ void ctgGenEpSet(SEpSet *epSet, SVgroupInfo *vgroupInfo) { ...@@ -146,8 +135,44 @@ void ctgGenEpSet(SEpSet *epSet, SVgroupInfo *vgroupInfo) {
} }
} }
int32_t ctgGetTableMetaFromMnode(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const char *pDBName, const char* pTableName, STableMetaOutput* output) {
if (NULL == pCatalog || NULL == pRpc || NULL == pMgmtEps || NULL == pDBName || NULL == pTableName || NULL == output) {
CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT);
}
char tbFullName[TSDB_TABLE_FNAME_LEN];
snprintf(tbFullName, sizeof(tbFullName), "%s.%s", pDBName, pTableName);
SBuildTableMetaInput bInput = {.vgId = 0, .tableFullName = tbFullName};
char *msg = NULL;
SEpSet *pVnodeEpSet = NULL;
int32_t msgLen = 0;
CTG_ERR_RET(queryBuildMsg[TMSG_INDEX(TDMT_MND_STB_META)](&bInput, &msg, 0, &msgLen));
SRpcMsg rpcMsg = {
.msgType = TDMT_MND_STB_META,
.pCont = msg,
.contLen = msgLen,
};
SRpcMsg rpcRsp = {0};
rpcSendRecv(pRpc, (SEpSet*)pMgmtEps, &rpcMsg, &rpcRsp);
if (TSDB_CODE_SUCCESS != rpcRsp.code) {
ctgError("error rsp for table meta, code:%x", rpcRsp.code);
CTG_ERR_RET(rpcRsp.code);
}
int32_t ctgGetTableMetaFromMnode(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const char *pDBName, const char* pTableName, SVgroupInfo *vgroupInfo, STableMetaOutput* output) { CTG_ERR_RET(queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_STB_META)](output, rpcRsp.pCont, rpcRsp.contLen));
return TSDB_CODE_SUCCESS;
}
int32_t ctgGetTableMetaFromVnode(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const char *pDBName, const char* pTableName, SVgroupInfo *vgroupInfo, STableMetaOutput* output) {
if (NULL == pCatalog || NULL == pRpc || NULL == pMgmtEps || NULL == pDBName || NULL == pTableName || NULL == vgroupInfo || NULL == output) { if (NULL == pCatalog || NULL == pRpc || NULL == pMgmtEps || NULL == pDBName || NULL == pTableName || NULL == vgroupInfo || NULL == output) {
CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT); CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT);
} }
...@@ -161,7 +186,7 @@ int32_t ctgGetTableMetaFromMnode(struct SCatalog* pCatalog, void *pRpc, const SE ...@@ -161,7 +186,7 @@ int32_t ctgGetTableMetaFromMnode(struct SCatalog* pCatalog, void *pRpc, const SE
SEpSet *pVnodeEpSet = NULL; SEpSet *pVnodeEpSet = NULL;
int32_t msgLen = 0; int32_t msgLen = 0;
CTG_ERR_RET(queryBuildMsg[TDMT_VND_TABLE_META](&bInput, &msg, 0, &msgLen)); CTG_ERR_RET(queryBuildMsg[TMSG_INDEX(TDMT_VND_TABLE_META)](&bInput, &msg, 0, &msgLen));
SRpcMsg rpcMsg = { SRpcMsg rpcMsg = {
.msgType = TDMT_VND_TABLE_META, .msgType = TDMT_VND_TABLE_META,
...@@ -181,7 +206,7 @@ int32_t ctgGetTableMetaFromMnode(struct SCatalog* pCatalog, void *pRpc, const SE ...@@ -181,7 +206,7 @@ int32_t ctgGetTableMetaFromMnode(struct SCatalog* pCatalog, void *pRpc, const SE
CTG_ERR_RET(rpcRsp.code); CTG_ERR_RET(rpcRsp.code);
} }
CTG_ERR_RET(queryProcessMsgRsp[TDMT_VND_TABLE_META](output, rpcRsp.pCont, rpcRsp.contLen)); CTG_ERR_RET(queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_TABLE_META)](output, rpcRsp.pCont, rpcRsp.contLen));
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
...@@ -307,7 +332,9 @@ int32_t ctgUpdateTableMetaCache(struct SCatalog *pCatalog, STableMetaOutput *out ...@@ -307,7 +332,9 @@ int32_t ctgUpdateTableMetaCache(struct SCatalog *pCatalog, STableMetaOutput *out
ctgError("init hash[%d] for tablemeta cache failed", ctgMgmt.cfg.maxTblCacheNum); ctgError("init hash[%d] for tablemeta cache failed", ctgMgmt.cfg.maxTblCacheNum);
CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR); CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR);
} }
}
if (NULL == pCatalog->tableCache.stableCache) {
pCatalog->tableCache.stableCache = taosHashInit(ctgMgmt.cfg.maxTblCacheNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), true, HASH_ENTRY_LOCK); pCatalog->tableCache.stableCache = taosHashInit(ctgMgmt.cfg.maxTblCacheNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), true, HASH_ENTRY_LOCK);
if (NULL == pCatalog->tableCache.stableCache) { if (NULL == pCatalog->tableCache.stableCache) {
ctgError("init hash[%d] for stablemeta cache failed", ctgMgmt.cfg.maxTblCacheNum); ctgError("init hash[%d] for stablemeta cache failed", ctgMgmt.cfg.maxTblCacheNum);
...@@ -318,55 +345,51 @@ int32_t ctgUpdateTableMetaCache(struct SCatalog *pCatalog, STableMetaOutput *out ...@@ -318,55 +345,51 @@ int32_t ctgUpdateTableMetaCache(struct SCatalog *pCatalog, STableMetaOutput *out
if (output->metaNum == 2) { if (output->metaNum == 2) {
if (taosHashPut(pCatalog->tableCache.cache, output->ctbFname, strlen(output->ctbFname), &output->ctbMeta, sizeof(output->ctbMeta)) != 0) { if (taosHashPut(pCatalog->tableCache.cache, output->ctbFname, strlen(output->ctbFname), &output->ctbMeta, sizeof(output->ctbMeta)) != 0) {
ctgError("push ctable[%s] to table cache failed", output->ctbFname); ctgError("push ctable[%s] to table cache failed", output->ctbFname);
goto error_exit; CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR);
} }
if (TSDB_SUPER_TABLE != output->tbMeta->tableType) { if (TSDB_SUPER_TABLE != output->tbMeta->tableType) {
ctgError("table type[%d] error, expected:%d", output->tbMeta->tableType, TSDB_SUPER_TABLE); ctgError("table type[%d] error, expected:%d", output->tbMeta->tableType, TSDB_SUPER_TABLE);
goto error_exit; CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR);
} }
} }
int32_t tbSize = sizeof(*output->tbMeta) + sizeof(SSchema) * (output->tbMeta->tableInfo.numOfColumns + output->tbMeta->tableInfo.numOfTags); int32_t tbSize = sizeof(*output->tbMeta) + sizeof(SSchema) * (output->tbMeta->tableInfo.numOfColumns + output->tbMeta->tableInfo.numOfTags);
if (taosHashPut(pCatalog->tableCache.cache, output->tbFname, strlen(output->tbFname), output->tbMeta, tbSize) != 0) { if (taosHashPut(pCatalog->tableCache.cache, output->tbFname, strlen(output->tbFname), output->tbMeta, tbSize) != 0) {
ctgError("push table[%s] to table cache failed", output->tbFname); ctgError("push table[%s] to table cache failed", output->tbFname);
goto error_exit; CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR);
} }
if (TSDB_SUPER_TABLE == output->tbMeta->tableType) { if (TSDB_SUPER_TABLE == output->tbMeta->tableType) {
if (taosHashPut(pCatalog->tableCache.stableCache, &output->tbMeta->suid, sizeof(output->tbMeta->suid), &output->tbMeta, POINTER_BYTES) != 0) { if (taosHashPut(pCatalog->tableCache.stableCache, &output->tbMeta->suid, sizeof(output->tbMeta->suid), &output->tbMeta, POINTER_BYTES) != 0) {
ctgError("push suid[%"PRIu64"] to stable cache failed", output->tbMeta->suid); ctgError("push suid[%"PRIu64"] to stable cache failed", output->tbMeta->suid);
goto error_exit; CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR);
} }
} }
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
error_exit:
if (pCatalog->vgroupCache.cache) {
taosHashCleanup(pCatalog->vgroupCache.cache);
pCatalog->vgroupCache.cache = NULL;
}
pCatalog->vgroupCache.vgroupVersion = CTG_DEFAULT_INVALID_VERSION;
CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR);
} }
int32_t catalogInit(SCatalogCfg *cfg) { int32_t catalogInit(SCatalogCfg *cfg) {
ctgMgmt.pCluster = taosHashInit(CTG_DEFAULT_CACHE_CLUSTER_NUMBER, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); if (ctgMgmt.pCluster) {
if (NULL == ctgMgmt.pCluster) { ctgError("catalog already init");
CTG_ERR_LRET(TSDB_CODE_CTG_INTERNAL_ERROR, "init %d cluster cache failed", CTG_DEFAULT_CACHE_CLUSTER_NUMBER); CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT);
} }
if (cfg) { if (cfg) {
memcpy(&ctgMgmt.cfg, cfg, sizeof(*cfg)); memcpy(&ctgMgmt.cfg, cfg, sizeof(*cfg));
} else { } else {
ctgMgmt.cfg.enableVgroupCache = true;
ctgMgmt.cfg.maxDBCacheNum = CTG_DEFAULT_CACHE_DB_NUMBER; ctgMgmt.cfg.maxDBCacheNum = CTG_DEFAULT_CACHE_DB_NUMBER;
ctgMgmt.cfg.maxTblCacheNum = CTG_DEFAULT_CACHE_TABLEMETA_NUMBER; ctgMgmt.cfg.maxTblCacheNum = CTG_DEFAULT_CACHE_TABLEMETA_NUMBER;
} }
if (CTG_CACHE_ENABLED()) {
ctgMgmt.pCluster = taosHashInit(CTG_DEFAULT_CACHE_CLUSTER_NUMBER, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK);
if (NULL == ctgMgmt.pCluster) {
CTG_ERR_LRET(TSDB_CODE_CTG_INTERNAL_ERROR, "init %d cluster cache failed", CTG_DEFAULT_CACHE_CLUSTER_NUMBER);
}
}
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
...@@ -381,21 +404,19 @@ int32_t catalogGetHandle(const char* clusterId , struct SCatalog** catalogHandle ...@@ -381,21 +404,19 @@ int32_t catalogGetHandle(const char* clusterId , struct SCatalog** catalogHandle
} }
size_t clen = strlen(clusterId); size_t clen = strlen(clusterId);
SCatalog *clusterCtg = (SCatalog *)taosHashGet(ctgMgmt.pCluster, clusterId, clen); SCatalog **ctg = (SCatalog **)taosHashGet(ctgMgmt.pCluster, clusterId, clen);
if (clusterCtg) { if (ctg && (*ctg)) {
*catalogHandle = clusterCtg; *catalogHandle = *ctg;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
clusterCtg = calloc(1, sizeof(*clusterCtg)); SCatalog *clusterCtg = calloc(1, sizeof(SCatalog));
if (NULL == clusterCtg) { if (NULL == clusterCtg) {
ctgError("calloc %d failed", (int32_t)sizeof(*clusterCtg)); ctgError("calloc %d failed", (int32_t)sizeof(SCatalog));
CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR); CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR);
} }
clusterCtg->vgroupCache.vgroupVersion = CTG_DEFAULT_INVALID_VERSION;
if (taosHashPut(ctgMgmt.pCluster, clusterId, clen, &clusterCtg, POINTER_BYTES)) { if (taosHashPut(ctgMgmt.pCluster, clusterId, clen, &clusterCtg, POINTER_BYTES)) {
ctgError("put cluster %s cache to hash failed", clusterId); ctgError("put cluster %s cache to hash failed", clusterId);
tfree(clusterCtg); tfree(clusterCtg);
...@@ -443,7 +464,7 @@ int32_t catalogUpdateDBVgroupCache(struct SCatalog* pCatalog, const char* dbName ...@@ -443,7 +464,7 @@ int32_t catalogUpdateDBVgroupCache(struct SCatalog* pCatalog, const char* dbName
} }
if (NULL == pCatalog->dbCache.cache) { if (NULL == pCatalog->dbCache.cache) {
pCatalog->dbCache.cache = taosHashInit(CTG_DEFAULT_CACHE_DB_NUMBER, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); pCatalog->dbCache.cache = taosHashInit(ctgMgmt.cfg.maxDBCacheNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK);
if (NULL == pCatalog->dbCache.cache) { if (NULL == pCatalog->dbCache.cache) {
ctgError("init hash[%d] for db cache failed", CTG_DEFAULT_CACHE_DB_NUMBER); ctgError("init hash[%d] for db cache failed", CTG_DEFAULT_CACHE_DB_NUMBER);
CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR); CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR);
...@@ -500,8 +521,8 @@ int32_t catalogGetDBVgroup(struct SCatalog* pCatalog, void *pRpc, const SEpSet* ...@@ -500,8 +521,8 @@ int32_t catalogGetDBVgroup(struct SCatalog* pCatalog, void *pRpc, const SEpSet*
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t catalogGetTableMeta(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const char* pDBName, const char* pTableName, STableMeta** pTableMeta) { int32_t catalogGetTableMeta(struct SCatalog* pCatalog, void *pTransporter, const SEpSet* pMgmtEps, const char* pDBName, const char* pTableName, STableMeta** pTableMeta) {
return ctgGetTableMetaImpl(pCatalog, pRpc, pMgmtEps, pDBName, pTableName, false, pTableMeta); return ctgGetTableMetaImpl(pCatalog, pTransporter, pMgmtEps, pDBName, pTableName, false, pTableMeta);
} }
int32_t catalogRenewTableMeta(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const char* pDBName, const char* pTableName) { int32_t catalogRenewTableMeta(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const char* pDBName, const char* pTableName) {
...@@ -515,7 +536,9 @@ int32_t catalogRenewTableMeta(struct SCatalog* pCatalog, void *pRpc, const SEpSe ...@@ -515,7 +536,9 @@ int32_t catalogRenewTableMeta(struct SCatalog* pCatalog, void *pRpc, const SEpSe
STableMetaOutput output = {0}; STableMetaOutput output = {0};
CTG_ERR_RET(ctgGetTableMetaFromMnode(pCatalog, pRpc, pMgmtEps, pDBName, pTableName, &vgroupInfo, &output)); //CTG_ERR_RET(ctgGetTableMetaFromVnode(pCatalog, pRpc, pMgmtEps, pDBName, pTableName, &vgroupInfo, &output));
CTG_ERR_RET(ctgGetTableMetaFromMnode(pCatalog, pRpc, pMgmtEps, pDBName, pTableName, &output));
CTG_ERR_RET(ctgUpdateTableMetaCache(pCatalog, &output)); CTG_ERR_RET(ctgUpdateTableMetaCache(pCatalog, &output));
...@@ -602,7 +625,7 @@ int32_t catalogGetAllMeta(struct SCatalog* pCatalog, void *pRpc, const SEpSet* p ...@@ -602,7 +625,7 @@ int32_t catalogGetAllMeta(struct SCatalog* pCatalog, void *pRpc, const SEpSet* p
int32_t code = 0; int32_t code = 0;
if (pReq->pTableName) { if (pReq->pTableName) {
char dbName[TSDB_FULL_DB_NAME_LEN]; char dbName[TSDB_DB_FNAME_LEN];
int32_t tbNum = (int32_t)taosArrayGetSize(pReq->pTableName); int32_t tbNum = (int32_t)taosArrayGetSize(pReq->pTableName);
if (tbNum > 0) { if (tbNum > 0) {
pRsp->pTableMeta = taosArrayInit(tbNum, POINTER_BYTES); pRsp->pTableMeta = taosArrayInit(tbNum, POINTER_BYTES);
......
...@@ -39,6 +39,7 @@ typedef struct IndexCache { ...@@ -39,6 +39,7 @@ typedef struct IndexCache {
int32_t nTerm; int32_t nTerm;
int8_t type; int8_t type;
pthread_mutex_t mtx;
} IndexCache; } IndexCache;
#define CACHE_VERSION(cache) atomic_load_32(&cache->version) #define CACHE_VERSION(cache) atomic_load_32(&cache->version)
...@@ -71,7 +72,7 @@ void indexCacheUnRef(IndexCache* cache); ...@@ -71,7 +72,7 @@ void indexCacheUnRef(IndexCache* cache);
void indexCacheDebug(IndexCache* cache); void indexCacheDebug(IndexCache* cache);
void indexCacheDestroySkiplist(SSkipList* slt); void indexCacheDestroyImm(IndexCache* cache);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -436,9 +436,7 @@ int indexFlushCacheTFile(SIndex* sIdx, void* cache) { ...@@ -436,9 +436,7 @@ int indexFlushCacheTFile(SIndex* sIdx, void* cache) {
if (ret != 0) { indexError("faile to write into tindex "); } if (ret != 0) { indexError("faile to write into tindex "); }
} }
// not free later, just put int table cache // not free later, just put int table cache
SSkipList* timm = (SSkipList*)pCache->imm; indexCacheDestroyImm(pCache);
pCache->imm = NULL; // or throw int bg thread
indexCacheDestroySkiplist(timm);
tfileWriteClose(tw); tfileWriteClose(tw);
indexCacheIteratorDestroy(cacheIter); indexCacheIteratorDestroy(cacheIter);
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#define MAX_INDEX_KEY_LEN 256 // test only, change later #define MAX_INDEX_KEY_LEN 256 // test only, change later
#define CACH_LIMIT 1000000 #define MEM_TERM_LIMIT 1000000
// ref index_cache.h:22 // ref index_cache.h:22
//#define CACHE_KEY_LEN(p) \ //#define CACHE_KEY_LEN(p) \
// (sizeof(int32_t) + sizeof(uint16_t) + sizeof(p->colType) + sizeof(p->nColVal) + p->nColVal + sizeof(uint64_t) + sizeof(p->operType)) // (sizeof(int32_t) + sizeof(uint16_t) + sizeof(p->colType) + sizeof(p->nColVal) + p->nColVal + sizeof(uint64_t) + sizeof(p->operType))
...@@ -78,6 +78,7 @@ IndexCache* indexCacheCreate(SIndex* idx, const char* colName, int8_t type) { ...@@ -78,6 +78,7 @@ IndexCache* indexCacheCreate(SIndex* idx, const char* colName, int8_t type) {
cache->index = idx; cache->index = idx;
cache->version = 0; cache->version = 0;
pthread_mutex_init(&cache->mtx, NULL);
indexCacheRef(cache); indexCacheRef(cache);
return cache; return cache;
} }
...@@ -103,13 +104,21 @@ void indexCacheDestroySkiplist(SSkipList* slt) { ...@@ -103,13 +104,21 @@ void indexCacheDestroySkiplist(SSkipList* slt) {
} }
tSkipListDestroyIter(iter); tSkipListDestroyIter(iter);
} }
void indexCacheDestroyImm(IndexCache* cache) {
pthread_mutex_lock(&cache->mtx);
SSkipList* timm = (SSkipList*)cache->imm;
cache->imm = NULL; // or throw int bg thread
pthread_mutex_unlock(&cache->mtx);
indexCacheDestroySkiplist(timm);
}
void indexCacheDestroy(void* cache) { void indexCacheDestroy(void* cache) {
IndexCache* pCache = cache; IndexCache* pCache = cache;
if (pCache == NULL) { return; } if (pCache == NULL) { return; }
tSkipListDestroy(pCache->mem); tSkipListDestroy(pCache->mem);
tSkipListDestroy(pCache->imm); tSkipListDestroy(pCache->imm);
free(pCache->colName); free(pCache->colName);
free(pCache); free(pCache);
} }
...@@ -170,6 +179,27 @@ int indexCacheSchedToMerge(IndexCache* pCache) { ...@@ -170,6 +179,27 @@ int indexCacheSchedToMerge(IndexCache* pCache) {
taosScheduleTask(indexQhandle, &schedMsg); taosScheduleTask(indexQhandle, &schedMsg);
} }
static void indexCacheMakeRoomForWrite(IndexCache* cache) {
while (true) {
if (cache->nTerm < MEM_TERM_LIMIT) {
cache->nTerm += 1;
break;
} else if (cache->imm != NULL) {
// TODO: wake up by condition variable
pthread_mutex_unlock(&cache->mtx);
taosMsleep(50);
pthread_mutex_lock(&cache->mtx);
} else {
cache->imm = cache->mem;
cache->mem = indexInternalCacheCreate(cache->type);
cache->nTerm = 1;
// sched to merge
// unref cache in bgwork
indexCacheSchedToMerge(cache);
}
}
}
int indexCachePut(void* cache, SIndexTerm* term, uint64_t uid) { int indexCachePut(void* cache, SIndexTerm* term, uint64_t uid) {
if (cache == NULL) { return -1; } if (cache == NULL) { return -1; }
...@@ -188,23 +218,12 @@ int indexCachePut(void* cache, SIndexTerm* term, uint64_t uid) { ...@@ -188,23 +218,12 @@ int indexCachePut(void* cache, SIndexTerm* term, uint64_t uid) {
ct->uid = uid; ct->uid = uid;
ct->operaType = term->operType; ct->operaType = term->operType;
// ugly code, refactor later
pthread_mutex_lock(&pCache->mtx);
indexCacheMakeRoomForWrite(pCache);
tSkipListPut(pCache->mem, (char*)ct); tSkipListPut(pCache->mem, (char*)ct);
pCache->nTerm += 1; pthread_mutex_unlock(&pCache->mtx);
if (pCache->nTerm >= CACH_LIMIT) {
pCache->nTerm = 0;
while (pCache->imm != NULL) {
// do nothong
}
pCache->imm = pCache->mem;
pCache->mem = indexInternalCacheCreate(pCache->type);
// sched to merge
// unref cache int bgwork
indexCacheSchedToMerge(pCache);
}
indexCacheUnRef(pCache); indexCacheUnRef(pCache);
return 0; return 0;
// encode end // encode end
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
%default_type {SToken} %default_type {SToken}
%extra_argument {SSqlInfo* pInfo} %extra_argument {SSqlInfo* pInfo}
%fallback ID BOOL TINYINT SMALLINT INTEGER BIGINT FLOAT DOUBLE STRING TIMESTAMP BINARY NCHAR. %fallback ID BOOL INTEGER FLOAT STRING TIMESTAMP.
%left OR. %left OR.
%left AND. %left AND.
...@@ -201,6 +201,7 @@ ifnotexists(X) ::= . { X.n = 0;} ...@@ -201,6 +201,7 @@ ifnotexists(X) ::= . { X.n = 0;}
/////////////////////////////////THE CREATE STATEMENT/////////////////////////////////////// /////////////////////////////////THE CREATE STATEMENT///////////////////////////////////////
//create option for dnode/db/user/account //create option for dnode/db/user/account
cmd ::= CREATE DNODE ids(X) PORT ids(Y). { setDCLSqlElems(pInfo, TSDB_SQL_CREATE_DNODE, 2, &X, &Y);} cmd ::= CREATE DNODE ids(X) PORT ids(Y). { setDCLSqlElems(pInfo, TSDB_SQL_CREATE_DNODE, 2, &X, &Y);}
cmd ::= CREATE DNODE IPTOKEN(X) PORT ids(Y). { setDCLSqlElems(pInfo, TSDB_SQL_CREATE_DNODE, 2, &X, &Y);}
cmd ::= CREATE ACCOUNT ids(X) PASS ids(Y) acct_optr(Z). cmd ::= CREATE ACCOUNT ids(X) PASS ids(Y) acct_optr(Z).
{ setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &X, &Y, &Z);} { setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &X, &Y, &Z);}
cmd ::= CREATE DATABASE ifnotexists(Z) ids(X) db_optr(Y). { setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &X, &Y, &Z);} cmd ::= CREATE DATABASE ifnotexists(Z) ids(X) db_optr(Y). { setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &X, &Y, &Z);}
...@@ -445,6 +446,15 @@ tagitemlist1(A) ::= tagitem1(Y). { A = taosArrayInit(4, sizeof(SToken)); taosArr ...@@ -445,6 +446,15 @@ tagitemlist1(A) ::= tagitem1(Y). { A = taosArrayInit(4, sizeof(SToken)); taosArr
%type tagitem1 {SToken} %type tagitem1 {SToken}
tagitem1(A) ::= MINUS(X) INTEGER(Y). { A.n = X.n + Y.n; A.type = Y.type; } tagitem1(A) ::= MINUS(X) INTEGER(Y). { A.n = X.n + Y.n; A.type = Y.type; }
tagitem1(A) ::= MINUS(X) FLOAT(Y). { A.n = X.n + Y.n; A.type = Y.type; }
tagitem1(A) ::= PLUS(X) INTEGER(Y). { A.n = X.n + Y.n; A.type = Y.type; }
tagitem1(A) ::= PLUS(X) FLOAT(Y). { A.n = X.n + Y.n; A.type = Y.type; }
tagitem1(A) ::= INTEGER(X). { A = X; }
tagitem1(A) ::= FLOAT(X). { A = X; }
tagitem1(A) ::= STRING(X). { A = X; }
tagitem1(A) ::= BOOL(X). { A = X; }
tagitem1(A) ::= NULL(X). { A = X; }
tagitem1(A) ::= NOW(X). { A = X; }
%type tagitemlist {SArray*} %type tagitemlist {SArray*}
%destructor tagitemlist {taosArrayDestroy($$);} %destructor tagitemlist {taosArrayDestroy($$);}
......
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_TTOKENDEF_H
#define TDENGINE_TTOKENDEF_H
#define TK_ID 1
#define TK_BOOL 2
#define TK_TINYINT 3
#define TK_SMALLINT 4
#define TK_INTEGER 5
#define TK_BIGINT 6
#define TK_FLOAT 7
#define TK_DOUBLE 8
#define TK_STRING 9
#define TK_TIMESTAMP 10
#define TK_BINARY 11
#define TK_NCHAR 12
#define TK_OR 13
#define TK_AND 14
#define TK_NOT 15
#define TK_EQ 16
#define TK_NE 17
#define TK_ISNULL 18
#define TK_NOTNULL 19
#define TK_IS 20
#define TK_LIKE 21
#define TK_MATCH 22
#define TK_NMATCH 23
#define TK_GLOB 24
#define TK_BETWEEN 25
#define TK_IN 26
#define TK_GT 27
#define TK_GE 28
#define TK_LT 29
#define TK_LE 30
#define TK_BITAND 31
#define TK_BITOR 32
#define TK_LSHIFT 33
#define TK_RSHIFT 34
#define TK_PLUS 35
#define TK_MINUS 36
#define TK_DIVIDE 37
#define TK_TIMES 38
#define TK_STAR 39
#define TK_SLASH 40
#define TK_REM 41
#define TK_CONCAT 42
#define TK_UMINUS 43
#define TK_UPLUS 44
#define TK_BITNOT 45
#define TK_SHOW 46
#define TK_DATABASES 47
#define TK_TOPICS 48
#define TK_FUNCTIONS 49
#define TK_MNODES 50
#define TK_DNODES 51
#define TK_ACCOUNTS 52
#define TK_USERS 53
#define TK_MODULES 54
#define TK_QUERIES 55
#define TK_CONNECTIONS 56
#define TK_STREAMS 57
#define TK_VARIABLES 58
#define TK_SCORES 59
#define TK_GRANTS 60
#define TK_VNODES 61
#define TK_DOT 62
#define TK_CREATE 63
#define TK_TABLE 64
#define TK_STABLE 65
#define TK_DATABASE 66
#define TK_TABLES 67
#define TK_STABLES 68
#define TK_VGROUPS 69
#define TK_DROP 70
#define TK_TOPIC 71
#define TK_FUNCTION 72
#define TK_DNODE 73
#define TK_USER 74
#define TK_ACCOUNT 75
#define TK_USE 76
#define TK_DESCRIBE 77
#define TK_DESC 78
#define TK_ALTER 79
#define TK_PASS 80
#define TK_PRIVILEGE 81
#define TK_LOCAL 82
#define TK_COMPACT 83
#define TK_LP 84
#define TK_RP 85
#define TK_IF 86
#define TK_EXISTS 87
#define TK_PORT 88
#define TK_AS 89
#define TK_OUTPUTTYPE 90
#define TK_AGGREGATE 91
#define TK_BUFSIZE 92
#define TK_PPS 93
#define TK_TSERIES 94
#define TK_DBS 95
#define TK_STORAGE 96
#define TK_QTIME 97
#define TK_CONNS 98
#define TK_STATE 99
#define TK_COMMA 100
#define TK_KEEP 101
#define TK_CACHE 102
#define TK_REPLICA 103
#define TK_QUORUM 104
#define TK_DAYS 105
#define TK_MINROWS 106
#define TK_MAXROWS 107
#define TK_BLOCKS 108
#define TK_CTIME 109
#define TK_WAL 110
#define TK_FSYNC 111
#define TK_COMP 112
#define TK_PRECISION 113
#define TK_UPDATE 114
#define TK_CACHELAST 115
#define TK_UNSIGNED 116
#define TK_TAGS 117
#define TK_USING 118
#define TK_NULL 119
#define TK_NOW 120
#define TK_SELECT 121
#define TK_UNION 122
#define TK_ALL 123
#define TK_DISTINCT 124
#define TK_FROM 125
#define TK_VARIABLE 126
#define TK_INTERVAL 127
#define TK_EVERY 128
#define TK_SESSION 129
#define TK_STATE_WINDOW 130
#define TK_FILL 131
#define TK_SLIDING 132
#define TK_ORDER 133
#define TK_BY 134
#define TK_ASC 135
#define TK_GROUP 136
#define TK_HAVING 137
#define TK_LIMIT 138
#define TK_OFFSET 139
#define TK_SLIMIT 140
#define TK_SOFFSET 141
#define TK_WHERE 142
#define TK_RESET 143
#define TK_QUERY 144
#define TK_SYNCDB 145
#define TK_ADD 146
#define TK_COLUMN 147
#define TK_MODIFY 148
#define TK_TAG 149
#define TK_CHANGE 150
#define TK_SET 151
#define TK_KILL 152
#define TK_CONNECTION 153
#define TK_STREAM 154
#define TK_COLON 155
#define TK_ABORT 156
#define TK_AFTER 157
#define TK_ATTACH 158
#define TK_BEFORE 159
#define TK_BEGIN 160
#define TK_CASCADE 161
#define TK_CLUSTER 162
#define TK_CONFLICT 163
#define TK_COPY 164
#define TK_DEFERRED 165
#define TK_DELIMITERS 166
#define TK_DETACH 167
#define TK_EACH 168
#define TK_END 169
#define TK_EXPLAIN 170
#define TK_FAIL 171
#define TK_FOR 172
#define TK_IGNORE 173
#define TK_IMMEDIATE 174
#define TK_INITIALLY 175
#define TK_INSTEAD 176
#define TK_KEY 177
#define TK_OF 178
#define TK_RAISE 179
#define TK_REPLACE 180
#define TK_RESTRICT 181
#define TK_ROW 182
#define TK_STATEMENT 183
#define TK_TRIGGER 184
#define TK_VIEW 185
#define TK_IPTOKEN 186
#define TK_SEMI 187
#define TK_NONE 188
#define TK_PREV 189
#define TK_LINEAR 190
#define TK_IMPORT 191
#define TK_TBNAME 192
#define TK_JOIN 193
#define TK_INSERT 194
#define TK_INTO 195
#define TK_VALUES 196
#define TK_SPACE 300
#define TK_COMMENT 301
#define TK_ILLEGAL 302
#define TK_HEX 303 // hex number 0x123
#define TK_OCT 304 // oct number
#define TK_BIN 305 // bin format data 0b111
#define TK_FILE 306
#define TK_QUESTION 307 // denoting the placeholder of "?",when invoking statement bind query
#endif
...@@ -276,7 +276,7 @@ bool tSqlExprIsLeaf(tSqlExpr *pExpr) { ...@@ -276,7 +276,7 @@ bool tSqlExprIsLeaf(tSqlExpr *pExpr) {
return (pExpr->pRight == NULL && pExpr->pLeft == NULL) && return (pExpr->pRight == NULL && pExpr->pLeft == NULL) &&
(pExpr->tokenId == 0 || (pExpr->tokenId == 0 ||
(pExpr->tokenId == TK_ID) || (pExpr->tokenId == TK_ID) ||
(pExpr->tokenId >= TK_BOOL && pExpr->tokenId <= TK_NCHAR) || (pExpr->tokenId == TK_BOOL || pExpr->tokenId == TK_STRING || pExpr->tokenId == TK_FLOAT) ||
(pExpr->tokenId == TK_NULL) || (pExpr->tokenId == TK_NULL) ||
(pExpr->tokenId == TK_SET)); (pExpr->tokenId == TK_SET));
} }
......
...@@ -388,7 +388,7 @@ SCreateDnodeMsg *buildCreateDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMs ...@@ -388,7 +388,7 @@ SCreateDnodeMsg *buildCreateDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMs
} }
SToken* id = taosArrayGet(pInfo->pMiscInfo->a, 0); SToken* id = taosArrayGet(pInfo->pMiscInfo->a, 0);
if (id->type != TK_ID) { if (id->type != TK_ID && id->type != TK_IPTOKEN) {
buildInvalidOperationMsg(pMsgBuf, msg2); buildInvalidOperationMsg(pMsgBuf, msg2);
return NULL; return NULL;
} }
...@@ -414,8 +414,8 @@ SCreateDnodeMsg *buildCreateDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMs ...@@ -414,8 +414,8 @@ SCreateDnodeMsg *buildCreateDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMs
return NULL; return NULL;
} }
strncpy(pCreate->ep, id->z, id->n); strncpy(pCreate->fqdn, id->z, id->n);
pCreate->port = val; pCreate->port = htonl(val);
*len = sizeof(SCreateDnodeMsg); *len = sizeof(SCreateDnodeMsg);
return pCreate; return pCreate;
...@@ -428,6 +428,7 @@ SDropDnodeMsg *buildDropDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMsgBuf ...@@ -428,6 +428,7 @@ SDropDnodeMsg *buildDropDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMsgBuf
char* end = NULL; char* end = NULL;
SDropDnodeMsg * pDrop = (SDropDnodeMsg *)calloc(1, sizeof(SDropDnodeMsg)); SDropDnodeMsg * pDrop = (SDropDnodeMsg *)calloc(1, sizeof(SDropDnodeMsg));
pDrop->dnodeId = strtoll(pzName->z, &end, 10); pDrop->dnodeId = strtoll(pzName->z, &end, 10);
pDrop->dnodeId = htonl(pDrop->dnodeId);
*len = sizeof(SDropDnodeMsg); *len = sizeof(SDropDnodeMsg);
if (end - pzName->z != pzName->n) { if (end - pzName->z != pzName->n) {
......
#include <tmsg.h>
#include <ttime.h> #include <ttime.h>
#include "astToMsg.h" #include "astToMsg.h"
#include "parserInt.h" #include "parserInt.h"
...@@ -283,7 +284,7 @@ int32_t doCheckForCreateTable(SSqlInfo* pInfo, SMsgBuf* pMsgBuf) { ...@@ -283,7 +284,7 @@ int32_t doCheckForCreateTable(SSqlInfo* pInfo, SMsgBuf* pMsgBuf) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* pMsgBuf) { int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* pMsgBuf, char** pOutput, int32_t* len, SEpSet* pEpSet) {
const char* msg1 = "invalid table name"; const char* msg1 = "invalid table name";
const char* msg2 = "tags number not matched"; const char* msg2 = "tags number not matched";
const char* msg3 = "tag value too long"; const char* msg3 = "tag value too long";
...@@ -313,16 +314,18 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p ...@@ -313,16 +314,18 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p
return code; return code;
} }
code = tNameExtractFullName(&name, pCreateTableInfo->tagdata.name); const char* pStableName = tNameGetTableName(&name);
SArray* pValList = pCreateTableInfo->pTagVals; SArray* pValList = pCreateTableInfo->pTagVals;
if (code != TSDB_CODE_SUCCESS) {
return code;
}
size_t valSize = taosArrayGetSize(pValList); size_t numOfInputTag = taosArrayGetSize(pValList);
STableMeta* pSuperTableMeta = NULL; STableMeta* pSuperTableMeta = NULL;
char dbName[TSDB_DB_FNAME_LEN] = {0};
tNameGetFullDbName(&name, dbName);
catalogGetTableMeta(pCtx->pCatalog, pCtx->pTransporter, &pCtx->mgmtEpSet, dbName, pStableName, &pSuperTableMeta);
assert(pSuperTableMeta != NULL);
// too long tag values will return invalid sql, not be truncated automatically // too long tag values will return invalid sql, not be truncated automatically
SSchema *pTagSchema = getTableTagSchema(pSuperTableMeta); SSchema *pTagSchema = getTableTagSchema(pSuperTableMeta);
STableComInfo tinfo = getTableInfo(pSuperTableMeta); STableComInfo tinfo = getTableInfo(pSuperTableMeta);
...@@ -341,7 +344,7 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p ...@@ -341,7 +344,7 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p
pNameList = pCreateTableInfo->pTagNames; pNameList = pCreateTableInfo->pTagNames;
nameSize = taosArrayGetSize(pNameList); nameSize = taosArrayGetSize(pNameList);
if (valSize != nameSize || schemaSize < valSize) { if (numOfInputTag != nameSize || schemaSize < numOfInputTag) {
tdDestroyKVRowBuilder(&kvRowBuilder); tdDestroyKVRowBuilder(&kvRowBuilder);
return buildInvalidOperationMsg(pMsgBuf, msg2); return buildInvalidOperationMsg(pMsgBuf, msg2);
} }
...@@ -417,33 +420,36 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p ...@@ -417,33 +420,36 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p
} }
} }
} else { } else {
if (schemaSize != valSize) { if (schemaSize != numOfInputTag) {
tdDestroyKVRowBuilder(&kvRowBuilder); tdDestroyKVRowBuilder(&kvRowBuilder);
return buildInvalidOperationMsg(pMsgBuf, msg2); return buildInvalidOperationMsg(pMsgBuf, msg2);
} }
for (int32_t i = 0; i < valSize; ++i) { for (int32_t i = 0; i < numOfInputTag; ++i) {
SSchema *pSchema = &pTagSchema[i]; SSchema *pSchema = &pTagSchema[i];
SListItem *pItem = taosArrayGet(pValList, i); SToken* pItem = taosArrayGet(pValList, i);
char tagVal[TSDB_MAX_TAGS_LEN]; char tagVal[TSDB_MAX_TAGS_LEN];
if (pSchema->type == TSDB_DATA_TYPE_BINARY || pSchema->type == TSDB_DATA_TYPE_NCHAR) { if (pSchema->type == TSDB_DATA_TYPE_BINARY || pSchema->type == TSDB_DATA_TYPE_NCHAR) {
if (pItem->pVar.nLen > pSchema->bytes) { if (pItem->n > pSchema->bytes) {
tdDestroyKVRowBuilder(&kvRowBuilder); tdDestroyKVRowBuilder(&kvRowBuilder);
return buildInvalidOperationMsg(pMsgBuf, msg3); return buildInvalidOperationMsg(pMsgBuf, msg3);
} }
} else if (pSchema->type == TSDB_DATA_TYPE_TIMESTAMP) { } else if (pSchema->type == TSDB_DATA_TYPE_TIMESTAMP) {
if (pItem->pVar.nType == TSDB_DATA_TYPE_BINARY) { // if (pItem->pVar.nType == TSDB_DATA_TYPE_BINARY) {
// code = convertTimestampStrToInt64(&(pItem->pVar), tinfo.precision); //// code = convertTimestampStrToInt64(&(pItem->pVar), tinfo.precision);
if (code != TSDB_CODE_SUCCESS) { // if (code != TSDB_CODE_SUCCESS) {
return buildInvalidOperationMsg(pMsgBuf, msg4); // return buildInvalidOperationMsg(pMsgBuf, msg4);
} // }
} else if (pItem->pVar.nType == TSDB_DATA_TYPE_TIMESTAMP) { // } else if (pItem->pVar.nType == TSDB_DATA_TYPE_TIMESTAMP) {
pItem->pVar.i = convertTimePrecision(pItem->pVar.i, TSDB_TIME_PRECISION_NANO, tinfo.precision); // pItem->pVar.i = convertTimePrecision(pItem->pVar.i, TSDB_TIME_PRECISION_NANO, tinfo.precision);
} // }
} }
code = taosVariantDump(&(pItem->pVar), tagVal, pSchema->type, true); char* endPtr = NULL;
int64_t v = strtoll(pItem->z, &endPtr, 10);
*(int32_t*) tagVal = v;
// code = taosVariantDump(&(pItem->pVar), tagVal, pSchema->type, true);
// check again after the convert since it may be converted from binary to nchar. // check again after the convert since it may be converted from binary to nchar.
if (pSchema->type == TSDB_DATA_TYPE_BINARY || pSchema->type == TSDB_DATA_TYPE_NCHAR) { if (pSchema->type == TSDB_DATA_TYPE_BINARY || pSchema->type == TSDB_DATA_TYPE_NCHAR) {
...@@ -468,33 +474,37 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p ...@@ -468,33 +474,37 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p
if (row == NULL) { if (row == NULL) {
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
tdSortKVRowByColIdx(row); tdSortKVRowByColIdx(row);
pTag->dataLen = kvRowLen(row);
if (pTag->data == NULL) { SName tableName = {0};
pTag->data = malloc(pTag->dataLen); code = createSName(&tableName, &pCreateTableInfo->name, pCtx, pMsgBuf);
if (code != TSDB_CODE_SUCCESS) {
return code;
} }
kvRowCpy(pTag->data, row); struct SVCreateTbReq req = {0};
free(row); req.type = TD_CHILD_TABLE;
req.name = strdup(tNameGetTableName(&tableName));
req.ctbCfg.suid = pSuperTableMeta->suid;
req.ctbCfg.pTag = row;
bool dbIncluded2 = false; int32_t serLen = tSerializeSVCreateTbReq(NULL, &req);
// table name char* buf1 = calloc(1, serLen);
// if (tscValidateName(&(pCreateTableInfo->name), true, &dbIncluded2) != TSDB_CODE_SUCCESS) { char* p = buf1;
// return buildInvalidOperationMsg(pMsgBuf, msg1); tSerializeSVCreateTbReq((void*) &buf1, &req);
// } *pOutput = p;
*len = serLen;
// STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, TABLE_INDEX); SVgroupInfo info = {0};
// code = tscSetTableFullName(&pTableMetaInfo->name, &pCreateTableInfo->name, pSql, dbIncluded2); catalogGetTableHashVgroup(pCtx->pCatalog, pCtx->pTransporter, &pCtx->mgmtEpSet, dbName, req.name, &info);
// if (code != TSDB_CODE_SUCCESS) {
// return code;
// }
// pCreateTableInfo->fullname = calloc(1, tNameLen(&pTableMetaInfo->name) + 1); pEpSet->inUse = info.inUse;
// code = tNameExtractFullName(&pTableMetaInfo->name, pCreateTableInfo->fullname); pEpSet->numOfEps = info.numOfEps;
// if (code != TSDB_CODE_SUCCESS) { for(int32_t i = 0; i < pEpSet->numOfEps; ++i) {
// return buildInvalidOperationMsg(pMsgBuf, msg1); pEpSet->port[i] = info.epAddr[i].port;
// } tstrncpy(pEpSet->fqdn[i], info.epAddr[i].fqdn, tListLen(pEpSet->fqdn[i]));
}
} }
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
...@@ -691,10 +701,11 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, SDclStm ...@@ -691,10 +701,11 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, SDclStm
pDcl->pMsg = (char*)buildCreateTableMsg(pCreateTable, &pDcl->msgLen, pCtx, pMsgBuf); pDcl->pMsg = (char*)buildCreateTableMsg(pCreateTable, &pDcl->msgLen, pCtx, pMsgBuf);
pDcl->msgType = (pCreateTable->type == TSQL_CREATE_TABLE)? TDMT_VND_CREATE_TABLE:TDMT_MND_CREATE_STB; pDcl->msgType = (pCreateTable->type == TSQL_CREATE_TABLE)? TDMT_VND_CREATE_TABLE:TDMT_MND_CREATE_STB;
} else if (pCreateTable->type == TSQL_CREATE_CTABLE) { } else if (pCreateTable->type == TSQL_CREATE_CTABLE) {
if ((code = doCheckForCreateCTable(pInfo, pCtx, pMsgBuf)) != TSDB_CODE_SUCCESS) { if ((code = doCheckForCreateCTable(pInfo, pCtx, pMsgBuf, &pDcl->pMsg, &pDcl->msgLen, &pDcl->epSet)) != TSDB_CODE_SUCCESS) {
return code; return code;
} }
pDcl->msgType = TDMT_VND_CREATE_TABLE;
} else if (pCreateTable->type == TSQL_CREATE_STREAM) { } else if (pCreateTable->type == TSQL_CREATE_STREAM) {
// if ((code = doCheckForStream(pSql, pInfo)) != TSDB_CODE_SUCCESS) { // if ((code = doCheckForStream(pSql, pInfo)) != TSDB_CODE_SUCCESS) {
// return code; // return code;
......
...@@ -162,7 +162,7 @@ static int32_t buildName(SInsertParseContext* pCxt, SToken* pStname, char* fullD ...@@ -162,7 +162,7 @@ static int32_t buildName(SInsertParseContext* pCxt, SToken* pStname, char* fullD
strncpy(fullDbName + n, pStname->z, p - pStname->z); strncpy(fullDbName + n, pStname->z, p - pStname->z);
strncpy(tableName, p + 1, pStname->n - (p - pStname->z) - 1); strncpy(tableName, p + 1, pStname->n - (p - pStname->z) - 1);
} else { } else {
snprintf(fullDbName, TSDB_FULL_DB_NAME_LEN, "%d.%s", pCxt->pComCxt->ctx.acctId, pCxt->pComCxt->ctx.db); snprintf(fullDbName, TSDB_DB_FNAME_LEN, "%d.%s", pCxt->pComCxt->ctx.acctId, pCxt->pComCxt->ctx.db);
strncpy(tableName, pStname->z, pStname->n); strncpy(tableName, pStname->z, pStname->n);
} }
...@@ -170,12 +170,12 @@ static int32_t buildName(SInsertParseContext* pCxt, SToken* pStname, char* fullD ...@@ -170,12 +170,12 @@ static int32_t buildName(SInsertParseContext* pCxt, SToken* pStname, char* fullD
} }
static int32_t getTableMeta(SInsertParseContext* pCxt, SToken* pTname) { static int32_t getTableMeta(SInsertParseContext* pCxt, SToken* pTname) {
char fullDbName[TSDB_FULL_DB_NAME_LEN] = {0}; char fullDbName[TSDB_DB_FNAME_LEN] = {0};
char tableName[TSDB_TABLE_NAME_LEN] = {0}; char tableName[TSDB_TABLE_NAME_LEN] = {0};
CHECK_CODE(buildName(pCxt, pTname, fullDbName, tableName)); CHECK_CODE(buildName(pCxt, pTname, fullDbName, tableName));
CHECK_CODE(catalogGetTableMeta(pCxt->pComCxt->pCatalog, pCxt->pComCxt->pRpc, pCxt->pComCxt->pEpSet, fullDbName, tableName, &pCxt->pTableMeta)); CHECK_CODE(catalogGetTableMeta(pCxt->pComCxt->ctx.pCatalog, pCxt->pComCxt->ctx.pTransporter, &pCxt->pComCxt->ctx.mgmtEpSet, fullDbName, tableName, &pCxt->pTableMeta));
SVgroupInfo vg; SVgroupInfo vg;
CHECK_CODE(catalogGetTableHashVgroup(pCxt->pComCxt->pCatalog, pCxt->pComCxt->pRpc, pCxt->pComCxt->pEpSet, fullDbName, tableName, &vg)); CHECK_CODE(catalogGetTableHashVgroup(pCxt->pComCxt->ctx.pCatalog, pCxt->pComCxt->ctx.pTransporter, &pCxt->pComCxt->ctx.mgmtEpSet, fullDbName, tableName, &vg));
CHECK_CODE(taosHashPut(pCxt->pVgroupsHashObj, (const char*)&vg.vgId, sizeof(vg.vgId), (char*)&vg, sizeof(vg))); CHECK_CODE(taosHashPut(pCxt->pVgroupsHashObj, (const char*)&vg.vgId, sizeof(vg.vgId), (char*)&vg, sizeof(vg)));
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
......
...@@ -229,6 +229,6 @@ void qParserClearupMetaRequestInfo(SCatalogReq* pMetaReq) { ...@@ -229,6 +229,6 @@ void qParserClearupMetaRequestInfo(SCatalogReq* pMetaReq) {
taosArrayDestroy(pMetaReq->pUdf); taosArrayDestroy(pMetaReq->pUdf);
} }
void qDestoryQuery(SQueryNode* pQuery) { void qDestroyQuery(SQueryNode* pQuery) {
// todo // todo
} }
...@@ -1918,7 +1918,7 @@ char* cloneCurrentDBName(SSqlObj* pSql) { ...@@ -1918,7 +1918,7 @@ char* cloneCurrentDBName(SSqlObj* pSql) {
case TAOS_REQ_FROM_HTTP: case TAOS_REQ_FROM_HTTP:
pCtx = pSql->param; pCtx = pSql->param;
if (pCtx && pCtx->db[0] != '\0') { if (pCtx && pCtx->db[0] != '\0') {
char db[TSDB_FULL_DB_NAME_LEN] = {0}; char db[TSDB_DB_FNAME_LEN] = {0};
int32_t len = sprintf(db, "%s%s%s", pTscObj->acctId, TS_PATH_DELIMITER, pCtx->db); int32_t len = sprintf(db, "%s%s%s", pTscObj->acctId, TS_PATH_DELIMITER, pCtx->db);
assert(len <= sizeof(db)); assert(len <= sizeof(db));
......
...@@ -26,7 +26,7 @@ size_t getNumOfExprs(SQueryStmtInfo* pQueryInfo) { ...@@ -26,7 +26,7 @@ size_t getNumOfExprs(SQueryStmtInfo* pQueryInfo) {
} }
SSchema* getOneColumnSchema(const STableMeta* pTableMeta, int32_t colIndex) { SSchema* getOneColumnSchema(const STableMeta* pTableMeta, int32_t colIndex) {
assert(pTableMeta != NULL && pTableMeta->schema != NULL && colIndex >= 0 && colIndex < getNumOfColumns(pTableMeta)); assert(pTableMeta != NULL && pTableMeta->schema != NULL && colIndex >= 0 && colIndex < (getNumOfColumns(pTableMeta) + getNumOfTags(pTableMeta)));
SSchema* pSchema = (SSchema*) pTableMeta->schema; SSchema* pSchema = (SSchema*) pTableMeta->schema;
return &pSchema[colIndex]; return &pSchema[colIndex];
......
...@@ -97,30 +97,30 @@ ...@@ -97,30 +97,30 @@
#endif #endif
/************* Begin control #defines *****************************************/ /************* Begin control #defines *****************************************/
#define YYCODETYPE unsigned short int #define YYCODETYPE unsigned short int
#define YYNOCODE 279 #define YYNOCODE 273
#define YYACTIONTYPE unsigned short int #define YYACTIONTYPE unsigned short int
#define ParseTOKENTYPE SToken #define ParseTOKENTYPE SToken
typedef union { typedef union {
int yyinit; int yyinit;
ParseTOKENTYPE yy0; ParseTOKENTYPE yy0;
SRelationInfo* yy8; SSqlNode* yy24;
SWindowStateVal yy40; int yy60;
SSqlNode* yy56; SSubclause* yy129;
SVariant yy69; SIntervalVal yy136;
SCreateDbInfo yy90; int64_t yy157;
int yy96;
SField yy100;
int32_t yy104;
SSessionWindowVal yy147;
SSubclause* yy149;
SCreatedTableInfo yy152;
SCreateAcctInfo yy171; SCreateAcctInfo yy171;
SLimit yy231; SSessionWindowVal yy251;
int64_t yy325; SCreateDbInfo yy254;
SIntervalVal yy400; SWindowStateVal yy256;
SArray* yy421; SField yy280;
SRelationInfo* yy292;
tSqlExpr* yy370;
SArray* yy413;
SCreateTableSql* yy438; SCreateTableSql* yy438;
tSqlExpr* yy439; SVariant yy461;
SLimit yy503;
int32_t yy516;
SCreatedTableInfo yy544;
} YYMINORTYPE; } YYMINORTYPE;
#ifndef YYSTACKDEPTH #ifndef YYSTACKDEPTH
#define YYSTACKDEPTH 100 #define YYSTACKDEPTH 100
...@@ -130,17 +130,17 @@ typedef union { ...@@ -130,17 +130,17 @@ typedef union {
#define ParseARG_FETCH SSqlInfo* pInfo = yypParser->pInfo #define ParseARG_FETCH SSqlInfo* pInfo = yypParser->pInfo
#define ParseARG_STORE yypParser->pInfo = pInfo #define ParseARG_STORE yypParser->pInfo = pInfo
#define YYFALLBACK 1 #define YYFALLBACK 1
#define YYNSTATE 362 #define YYNSTATE 365
#define YYNRULE 291 #define YYNRULE 301
#define YYNTOKEN 197 #define YYNTOKEN 191
#define YY_MAX_SHIFT 361 #define YY_MAX_SHIFT 364
#define YY_MIN_SHIFTREDUCE 571 #define YY_MIN_SHIFTREDUCE 584
#define YY_MAX_SHIFTREDUCE 861 #define YY_MAX_SHIFTREDUCE 884
#define YY_ERROR_ACTION 862 #define YY_ERROR_ACTION 885
#define YY_ACCEPT_ACTION 863 #define YY_ACCEPT_ACTION 886
#define YY_NO_ACTION 864 #define YY_NO_ACTION 887
#define YY_MIN_REDUCE 865 #define YY_MIN_REDUCE 888
#define YY_MAX_REDUCE 1155 #define YY_MAX_REDUCE 1188
/************* End control #defines *******************************************/ /************* End control #defines *******************************************/
/* Define the yytestcase() macro to be a no-op if is not already defined /* Define the yytestcase() macro to be a no-op if is not already defined
...@@ -206,291 +206,292 @@ typedef union { ...@@ -206,291 +206,292 @@ typedef union {
** yy_default[] Default action for each state. ** yy_default[] Default action for each state.
** **
*********** Begin parsing tables **********************************************/ *********** Begin parsing tables **********************************************/
#define YY_ACTTAB_COUNT (767) #define YY_ACTTAB_COUNT (779)
static const YYACTIONTYPE yy_action[] = { static const YYACTIONTYPE yy_action[] = {
/* 0 */ 94, 622, 34, 1008, 622, 21, 246, 700, 205, 623, /* 0 */ 1073, 635, 155, 363, 230, 636, 671, 55, 56, 635,
/* 10 */ 360, 229, 623, 55, 56, 1000, 59, 60, 160, 1131, /* 10 */ 59, 60, 1032, 636, 252, 49, 48, 47, 162, 58,
/* 20 */ 249, 49, 48, 47, 1040, 58, 319, 63, 61, 64, /* 20 */ 322, 63, 61, 64, 62, 236, 1050, 242, 206, 54,
/* 30 */ 62, 997, 998, 31, 1001, 54, 53, 339, 338, 52, /* 30 */ 53, 1038, 635, 52, 51, 50, 636, 55, 56, 1164,
/* 40 */ 51, 50, 55, 56, 231, 59, 60, 242, 1011, 249, /* 40 */ 59, 60, 936, 1063, 252, 49, 48, 47, 188, 58,
/* 50 */ 49, 48, 47, 297, 58, 319, 63, 61, 64, 62, /* 50 */ 322, 63, 61, 64, 62, 1010, 243, 1008, 1009, 54,
/* 60 */ 657, 245, 863, 361, 54, 53, 205, 258, 52, 51, /* 60 */ 53, 233, 1011, 52, 51, 50, 1012, 1070, 1013, 1014,
/* 70 */ 50, 55, 56, 202, 59, 60, 175, 1132, 249, 49, /* 70 */ 280, 279, 947, 55, 56, 246, 59, 60, 188, 1038,
/* 80 */ 48, 47, 622, 58, 319, 63, 61, 64, 62, 79, /* 80 */ 252, 49, 48, 47, 81, 58, 322, 63, 61, 64,
/* 90 */ 623, 1037, 1078, 54, 53, 235, 1017, 52, 51, 50, /* 90 */ 62, 320, 1112, 99, 292, 54, 53, 352, 635, 52,
/* 100 */ 622, 316, 247, 55, 57, 160, 59, 60, 623, 1030, /* 100 */ 51, 50, 636, 55, 57, 261, 59, 60, 318, 821,
/* 110 */ 249, 49, 48, 47, 798, 58, 319, 63, 61, 64, /* 110 */ 252, 49, 48, 47, 176, 58, 322, 63, 61, 64,
/* 120 */ 62, 205, 913, 153, 4, 54, 53, 271, 187, 52, /* 120 */ 62, 42, 249, 358, 357, 54, 53, 1026, 356, 52,
/* 130 */ 51, 50, 1132, 196, 194, 192, 160, 52, 51, 50, /* 130 */ 51, 50, 355, 87, 354, 353, 886, 364, 585, 586,
/* 140 */ 191, 139, 138, 137, 136, 316, 572, 573, 574, 575, /* 140 */ 587, 588, 589, 590, 591, 592, 593, 594, 595, 596,
/* 150 */ 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, /* 150 */ 597, 598, 153, 56, 231, 59, 60, 767, 1063, 252,
/* 160 */ 151, 56, 230, 59, 60, 25, 92, 249, 49, 48, /* 160 */ 49, 48, 47, 171, 58, 322, 63, 61, 64, 62,
/* 170 */ 47, 97, 58, 319, 63, 61, 64, 62, 321, 1079, /* 170 */ 162, 43, 1024, 86, 54, 53, 234, 21, 52, 51,
/* 180 */ 80, 289, 54, 53, 160, 34, 52, 51, 50, 59, /* 180 */ 50, 282, 206, 1063, 635, 59, 60, 203, 636, 252,
/* 190 */ 60, 277, 276, 249, 49, 48, 47, 263, 58, 319, /* 190 */ 49, 48, 47, 1165, 58, 322, 63, 61, 64, 62,
/* 200 */ 63, 61, 64, 62, 250, 1002, 267, 266, 54, 53, /* 200 */ 162, 274, 827, 830, 54, 53, 786, 787, 52, 51,
/* 210 */ 91, 85, 52, 51, 50, 42, 314, 355, 354, 313, /* 210 */ 50, 36, 42, 316, 358, 357, 315, 314, 313, 356,
/* 220 */ 312, 311, 353, 310, 309, 308, 352, 307, 351, 350, /* 220 */ 312, 311, 310, 355, 309, 354, 353, 1004, 992, 993,
/* 230 */ 22, 1010, 980, 968, 969, 970, 971, 972, 973, 974, /* 230 */ 994, 995, 996, 997, 998, 999, 1000, 1001, 1002, 1003,
/* 240 */ 975, 976, 977, 978, 979, 981, 982, 214, 43, 248, /* 240 */ 1005, 1006, 294, 771, 92, 22, 63, 61, 64, 62,
/* 250 */ 813, 763, 764, 802, 215, 805, 291, 808, 90, 252, /* 250 */ 826, 829, 318, 232, 54, 53, 204, 1035, 52, 51,
/* 260 */ 135, 134, 133, 216, 205, 248, 813, 324, 85, 802, /* 260 */ 50, 27, 215, 36, 251, 836, 825, 828, 831, 216,
/* 270 */ 34, 805, 34, 808, 169, 1132, 12, 63, 61, 64, /* 270 */ 750, 747, 748, 749, 1111, 137, 136, 135, 217, 162,
/* 280 */ 62, 93, 817, 227, 228, 54, 53, 320, 34, 52, /* 280 */ 266, 255, 327, 87, 251, 836, 825, 828, 831, 270,
/* 290 */ 51, 50, 279, 3, 37, 177, 804, 258, 807, 227, /* 290 */ 269, 96, 228, 229, 261, 261, 323, 257, 258, 742,
/* 300 */ 228, 103, 108, 99, 106, 43, 176, 34, 727, 34, /* 300 */ 739, 740, 741, 177, 1036, 240, 3, 39, 178, 1035,
/* 310 */ 96, 724, 239, 725, 240, 726, 1011, 34, 1011, 803, /* 310 */ 260, 209, 228, 229, 105, 77, 101, 108, 250, 248,
/* 320 */ 303, 806, 258, 349, 257, 122, 744, 270, 203, 77, /* 320 */ 834, 43, 1021, 1022, 33, 1025, 244, 245, 197, 195,
/* 330 */ 328, 1012, 65, 34, 1011, 253, 223, 251, 349, 327, /* 330 */ 193, 52, 51, 50, 305, 192, 141, 140, 139, 138,
/* 340 */ 326, 254, 255, 42, 208, 355, 354, 272, 65, 329, /* 340 */ 4, 65, 253, 273, 80, 79, 122, 116, 126, 152,
/* 350 */ 353, 330, 85, 1011, 352, 1011, 351, 350, 986, 331, /* 350 */ 150, 149, 224, 93, 36, 131, 134, 125, 256, 36,
/* 360 */ 984, 985, 35, 1011, 34, 987, 34, 814, 809, 988, /* 360 */ 254, 65, 330, 329, 128, 54, 53, 714, 835, 52,
/* 370 */ 73, 989, 990, 1032, 810, 335, 120, 114, 124, 1011, /* 370 */ 51, 50, 87, 36, 36, 36, 1023, 837, 832, 206,
/* 380 */ 356, 950, 34, 814, 809, 129, 132, 123, 780, 43, /* 380 */ 36, 36, 751, 752, 833, 36, 36, 262, 36, 259,
/* 390 */ 810, 84, 54, 53, 126, 78, 52, 51, 50, 1016, /* 390 */ 1165, 337, 336, 342, 341, 803, 241, 837, 832, 764,
/* 400 */ 259, 923, 256, 1030, 334, 333, 336, 187, 337, 74, /* 400 */ 1035, 331, 206, 12, 833, 1035, 84, 85, 937, 95,
/* 410 */ 1011, 748, 1011, 359, 358, 144, 1030, 811, 150, 148, /* 410 */ 43, 743, 744, 1165, 188, 332, 333, 334, 324, 1035,
/* 420 */ 147, 232, 741, 82, 341, 728, 729, 999, 1011, 241, /* 420 */ 1035, 1035, 338, 339, 7, 124, 1035, 1035, 340, 94,
/* 430 */ 914, 70, 83, 1014, 233, 760, 187, 243, 770, 800, /* 430 */ 344, 1034, 1035, 275, 1035, 362, 361, 146, 98, 352,
/* 440 */ 812, 1014, 209, 771, 710, 779, 294, 7, 712, 296, /* 440 */ 359, 974, 783, 82, 70, 70, 793, 794, 71, 37,
/* 450 */ 155, 711, 30, 66, 1151, 836, 815, 210, 24, 35, /* 450 */ 724, 74, 297, 802, 726, 299, 737, 738, 157, 735,
/* 460 */ 69, 35, 76, 172, 95, 621, 172, 131, 130, 69, /* 460 */ 736, 725, 66, 24, 32, 823, 37, 859, 37, 838,
/* 470 */ 23, 23, 71, 14, 113, 13, 112, 801, 1126, 16, /* 470 */ 67, 97, 634, 14, 115, 13, 114, 67, 78, 16,
/* 480 */ 23, 15, 732, 1125, 733, 298, 730, 18, 731, 17, /* 480 */ 18, 15, 17, 23, 121, 23, 120, 210, 23, 72,
/* 490 */ 119, 20, 118, 19, 699, 1089, 1143, 1124, 225, 226, /* 490 */ 75, 211, 755, 756, 753, 754, 1159, 824, 300, 20,
/* 500 */ 206, 207, 211, 204, 212, 213, 218, 219, 1088, 220, /* 500 */ 1158, 19, 133, 132, 1157, 226, 1037, 1049, 1065, 227,
/* 510 */ 217, 237, 201, 1085, 1084, 238, 340, 268, 152, 1039, /* 510 */ 207, 713, 208, 212, 205, 213, 214, 219, 220, 221,
/* 520 */ 44, 1050, 149, 1047, 1048, 1031, 274, 1071, 1052, 154, /* 520 */ 218, 202, 1184, 840, 1176, 44, 1122, 1121, 321, 271,
/* 530 */ 159, 1070, 162, 285, 170, 1009, 171, 1007, 304, 173, /* 530 */ 238, 1118, 1117, 239, 343, 154, 1104, 1072, 1083, 1080,
/* 540 */ 167, 174, 927, 278, 1028, 300, 759, 161, 301, 302, /* 540 */ 1081, 1085, 156, 161, 1064, 277, 288, 1103, 1033, 173,
/* 550 */ 164, 305, 306, 163, 234, 199, 40, 288, 280, 282, /* 550 */ 151, 281, 172, 1031, 174, 175, 951, 782, 306, 302,
/* 560 */ 317, 75, 922, 292, 72, 318, 46, 325, 290, 1150, /* 560 */ 303, 170, 164, 304, 307, 163, 308, 1061, 295, 291,
/* 570 */ 165, 286, 110, 1149, 1146, 178, 332, 1142, 284, 116, /* 570 */ 165, 200, 40, 319, 946, 945, 235, 328, 1183, 112,
/* 580 */ 281, 1141, 1138, 179, 947, 41, 36, 45, 200, 911, /* 580 */ 283, 1182, 285, 1179, 76, 179, 335, 73, 1175, 118,
/* 590 */ 125, 909, 127, 128, 907, 906, 260, 189, 190, 903, /* 590 */ 1174, 1171, 180, 971, 46, 41, 38, 201, 934, 127,
/* 600 */ 902, 901, 900, 899, 898, 897, 193, 195, 894, 892, /* 600 */ 932, 129, 130, 293, 930, 929, 263, 190, 191, 926,
/* 610 */ 890, 888, 197, 885, 198, 881, 121, 342, 273, 81, /* 610 */ 925, 924, 923, 922, 921, 920, 194, 196, 917, 915,
/* 620 */ 86, 283, 343, 1072, 344, 345, 347, 346, 348, 224, /* 620 */ 913, 911, 289, 198, 908, 199, 904, 287, 284, 276,
/* 630 */ 357, 861, 262, 244, 261, 299, 860, 264, 265, 859, /* 630 */ 83, 88, 45, 286, 1105, 123, 345, 346, 347, 348,
/* 640 */ 842, 221, 222, 841, 104, 926, 925, 269, 69, 293, /* 640 */ 349, 225, 350, 247, 301, 351, 360, 884, 264, 265,
/* 650 */ 8, 275, 735, 87, 158, 26, 156, 905, 904, 186, /* 650 */ 883, 222, 267, 950, 949, 106, 223, 268, 882, 865,
/* 660 */ 181, 948, 180, 182, 140, 141, 184, 183, 185, 896, /* 660 */ 864, 272, 70, 8, 928, 296, 927, 758, 183, 182,
/* 670 */ 2, 142, 895, 1, 143, 949, 887, 886, 166, 168, /* 670 */ 972, 181, 142, 184, 185, 187, 186, 143, 919, 918,
/* 680 */ 29, 1013, 761, 772, 157, 236, 766, 88, 27, 768, /* 680 */ 973, 144, 145, 910, 909, 28, 278, 89, 31, 784,
/* 690 */ 89, 287, 9, 28, 10, 11, 38, 295, 721, 39, /* 690 */ 2, 166, 167, 158, 168, 169, 795, 159, 1, 789,
/* 700 */ 96, 98, 101, 32, 635, 100, 670, 33, 102, 668, /* 700 */ 160, 90, 237, 791, 91, 290, 29, 9, 30, 10,
/* 710 */ 667, 666, 664, 663, 662, 659, 626, 315, 105, 5, /* 710 */ 11, 25, 298, 26, 98, 100, 34, 103, 102, 649,
/* 720 */ 107, 816, 322, 6, 818, 323, 109, 67, 111, 68, /* 720 */ 684, 35, 104, 682, 681, 680, 678, 677, 676, 673,
/* 730 */ 115, 702, 117, 701, 698, 651, 649, 35, 641, 647, /* 730 */ 639, 107, 109, 325, 110, 839, 317, 5, 6, 841,
/* 740 */ 643, 645, 639, 637, 672, 671, 669, 665, 661, 660, /* 740 */ 326, 68, 111, 113, 69, 716, 117, 119, 37, 715,
/* 750 */ 188, 589, 624, 145, 865, 864, 864, 864, 864, 864, /* 750 */ 712, 665, 663, 655, 661, 657, 659, 653, 651, 686,
/* 760 */ 864, 864, 864, 864, 864, 864, 146, /* 760 */ 685, 683, 679, 675, 674, 189, 602, 637, 888, 887,
/* 770 */ 887, 887, 887, 887, 887, 887, 887, 147, 148,
}; };
static const YYCODETYPE yy_lookahead[] = { static const YYCODETYPE yy_lookahead[] = {
/* 0 */ 207, 1, 200, 200, 1, 266, 206, 5, 266, 9, /* 0 */ 194, 1, 194, 194, 195, 5, 3, 7, 8, 1,
/* 10 */ 200, 201, 9, 13, 14, 0, 16, 17, 200, 277, /* 10 */ 10, 11, 194, 5, 14, 15, 16, 17, 194, 19,
/* 20 */ 20, 21, 22, 23, 200, 25, 26, 27, 28, 29, /* 20 */ 20, 21, 22, 23, 24, 242, 243, 237, 260, 29,
/* 30 */ 30, 238, 239, 240, 241, 35, 36, 35, 36, 39, /* 30 */ 30, 241, 1, 33, 34, 35, 5, 7, 8, 271,
/* 40 */ 40, 41, 13, 14, 242, 16, 17, 244, 246, 20, /* 40 */ 10, 11, 199, 239, 14, 15, 16, 17, 205, 19,
/* 50 */ 21, 22, 23, 36, 25, 26, 27, 28, 29, 30, /* 50 */ 20, 21, 22, 23, 24, 216, 238, 218, 219, 29,
/* 60 */ 5, 206, 198, 199, 35, 36, 266, 200, 39, 40, /* 60 */ 30, 257, 223, 33, 34, 35, 227, 261, 229, 230,
/* 70 */ 41, 13, 14, 266, 16, 17, 209, 277, 20, 21, /* 70 */ 262, 263, 199, 7, 8, 237, 10, 11, 205, 241,
/* 80 */ 22, 23, 1, 25, 26, 27, 28, 29, 30, 89, /* 80 */ 14, 15, 16, 17, 84, 19, 20, 21, 22, 23,
/* 90 */ 9, 267, 274, 35, 36, 248, 249, 39, 40, 41, /* 90 */ 24, 83, 268, 201, 270, 29, 30, 88, 1, 33,
/* 100 */ 1, 86, 62, 13, 14, 200, 16, 17, 9, 245, /* 100 */ 34, 35, 5, 7, 8, 194, 10, 11, 80, 79,
/* 110 */ 20, 21, 22, 23, 85, 25, 26, 27, 28, 29, /* 110 */ 14, 15, 16, 17, 203, 19, 20, 21, 22, 23,
/* 120 */ 30, 266, 205, 200, 84, 35, 36, 263, 211, 39, /* 120 */ 24, 96, 200, 98, 99, 29, 30, 235, 103, 33,
/* 130 */ 40, 41, 277, 64, 65, 66, 200, 39, 40, 41, /* 130 */ 34, 35, 107, 78, 109, 110, 192, 193, 41, 42,
/* 140 */ 71, 72, 73, 74, 75, 86, 47, 48, 49, 50, /* 140 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
/* 150 */ 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, /* 150 */ 53, 54, 55, 8, 57, 10, 11, 33, 239, 14,
/* 160 */ 61, 14, 63, 16, 17, 84, 250, 20, 21, 22, /* 160 */ 15, 16, 17, 247, 19, 20, 21, 22, 23, 24,
/* 170 */ 23, 207, 25, 26, 27, 28, 29, 30, 15, 274, /* 170 */ 194, 116, 0, 118, 29, 30, 257, 260, 33, 34,
/* 180 */ 264, 276, 35, 36, 200, 200, 39, 40, 41, 16, /* 180 */ 35, 265, 260, 239, 1, 10, 11, 260, 5, 14,
/* 190 */ 17, 268, 269, 20, 21, 22, 23, 144, 25, 26, /* 190 */ 15, 16, 17, 271, 19, 20, 21, 22, 23, 24,
/* 200 */ 27, 28, 29, 30, 206, 241, 153, 154, 35, 36, /* 200 */ 194, 257, 3, 4, 29, 30, 122, 123, 33, 34,
/* 210 */ 274, 84, 39, 40, 41, 101, 102, 103, 104, 105, /* 210 */ 35, 194, 96, 97, 98, 99, 100, 101, 102, 103,
/* 220 */ 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, /* 220 */ 104, 105, 106, 107, 108, 109, 110, 216, 217, 218,
/* 230 */ 46, 246, 222, 223, 224, 225, 226, 227, 228, 229, /* 230 */ 219, 220, 221, 222, 223, 224, 225, 226, 227, 228,
/* 240 */ 230, 231, 232, 233, 234, 235, 236, 63, 121, 1, /* 240 */ 229, 230, 266, 119, 268, 40, 21, 22, 23, 24,
/* 250 */ 2, 127, 128, 5, 70, 7, 272, 9, 274, 70, /* 250 */ 3, 4, 80, 236, 29, 30, 260, 240, 33, 34,
/* 260 */ 76, 77, 78, 79, 266, 1, 2, 83, 84, 5, /* 260 */ 35, 78, 57, 194, 1, 2, 3, 4, 5, 64,
/* 270 */ 200, 7, 200, 9, 253, 277, 84, 27, 28, 29, /* 270 */ 2, 3, 4, 5, 268, 70, 71, 72, 73, 194,
/* 280 */ 30, 89, 119, 35, 36, 35, 36, 39, 200, 39, /* 280 */ 139, 64, 77, 78, 1, 2, 3, 4, 5, 148,
/* 290 */ 40, 41, 271, 64, 65, 66, 5, 200, 7, 35, /* 290 */ 149, 201, 29, 30, 194, 194, 33, 29, 30, 2,
/* 300 */ 36, 72, 73, 74, 75, 121, 209, 200, 2, 200, /* 300 */ 3, 4, 5, 203, 203, 236, 58, 59, 60, 240,
/* 310 */ 118, 5, 242, 7, 242, 9, 246, 200, 246, 5, /* 310 */ 64, 260, 29, 30, 66, 67, 68, 69, 56, 200,
/* 320 */ 91, 7, 200, 93, 70, 80, 39, 143, 266, 145, /* 320 */ 121, 116, 232, 233, 234, 235, 29, 30, 58, 59,
/* 330 */ 242, 209, 84, 200, 246, 146, 152, 148, 93, 150, /* 330 */ 60, 33, 34, 35, 86, 65, 66, 67, 68, 69,
/* 340 */ 151, 35, 36, 101, 266, 103, 104, 85, 84, 242, /* 340 */ 78, 78, 200, 138, 201, 140, 58, 59, 60, 58,
/* 350 */ 108, 242, 84, 246, 112, 246, 114, 115, 222, 242, /* 350 */ 59, 60, 147, 268, 194, 67, 68, 69, 141, 194,
/* 360 */ 224, 225, 100, 246, 200, 229, 200, 119, 120, 233, /* 360 */ 143, 78, 145, 146, 76, 29, 30, 3, 121, 33,
/* 370 */ 100, 235, 236, 245, 126, 242, 64, 65, 66, 246, /* 370 */ 34, 35, 78, 194, 194, 194, 233, 114, 115, 260,
/* 380 */ 220, 221, 200, 119, 120, 73, 74, 75, 78, 121, /* 380 */ 194, 194, 114, 115, 121, 194, 194, 141, 194, 143,
/* 390 */ 126, 123, 35, 36, 82, 207, 39, 40, 41, 249, /* 390 */ 271, 145, 146, 29, 30, 72, 236, 114, 115, 95,
/* 400 */ 146, 205, 148, 245, 150, 151, 242, 211, 242, 139, /* 400 */ 240, 236, 260, 78, 121, 240, 79, 79, 199, 84,
/* 410 */ 246, 124, 246, 67, 68, 69, 245, 126, 64, 65, /* 410 */ 116, 114, 115, 271, 205, 236, 236, 236, 9, 240,
/* 420 */ 66, 263, 100, 85, 242, 119, 120, 239, 246, 243, /* 420 */ 240, 240, 236, 236, 120, 74, 240, 240, 236, 244,
/* 430 */ 205, 100, 85, 247, 263, 85, 211, 243, 85, 1, /* 430 */ 236, 240, 240, 79, 240, 61, 62, 63, 113, 88,
/* 440 */ 126, 247, 266, 85, 85, 135, 85, 125, 85, 85, /* 440 */ 214, 215, 79, 258, 117, 117, 79, 79, 95, 95,
/* 450 */ 100, 85, 84, 100, 249, 85, 85, 266, 100, 100, /* 450 */ 79, 95, 79, 130, 79, 79, 3, 4, 95, 3,
/* 460 */ 122, 100, 84, 100, 100, 85, 100, 80, 81, 122, /* 460 */ 4, 79, 95, 95, 78, 1, 95, 79, 95, 79,
/* 470 */ 100, 100, 141, 147, 147, 149, 149, 39, 266, 147, /* 470 */ 95, 95, 79, 142, 142, 144, 144, 95, 78, 142,
/* 480 */ 100, 149, 5, 266, 7, 117, 5, 147, 7, 149, /* 480 */ 142, 144, 144, 95, 142, 95, 144, 260, 95, 136,
/* 490 */ 147, 147, 149, 149, 116, 237, 249, 266, 266, 266, /* 490 */ 134, 260, 3, 4, 3, 4, 260, 33, 112, 142,
/* 500 */ 266, 266, 266, 266, 266, 266, 266, 266, 237, 266, /* 500 */ 260, 144, 74, 75, 260, 260, 241, 243, 239, 260,
/* 510 */ 266, 237, 266, 237, 237, 237, 237, 200, 200, 200, /* 510 */ 260, 111, 260, 260, 260, 260, 260, 260, 260, 260,
/* 520 */ 265, 200, 62, 200, 200, 245, 245, 275, 200, 200, /* 520 */ 260, 260, 243, 114, 243, 259, 231, 231, 194, 194,
/* 530 */ 200, 275, 260, 200, 251, 245, 200, 200, 92, 200, /* 530 */ 231, 231, 231, 231, 231, 194, 269, 194, 194, 194,
/* 540 */ 255, 200, 200, 270, 262, 200, 126, 261, 200, 200, /* 540 */ 194, 194, 194, 194, 239, 239, 194, 269, 239, 194,
/* 550 */ 258, 200, 200, 259, 270, 200, 200, 131, 270, 270, /* 550 */ 56, 264, 245, 194, 194, 194, 194, 121, 87, 194,
/* 560 */ 200, 138, 200, 133, 140, 200, 137, 200, 136, 200, /* 560 */ 194, 248, 254, 194, 194, 255, 194, 256, 128, 126,
/* 570 */ 257, 130, 200, 200, 200, 200, 200, 200, 129, 200, /* 570 */ 253, 194, 194, 194, 194, 194, 264, 194, 194, 194,
/* 580 */ 132, 200, 200, 200, 200, 200, 200, 142, 200, 200, /* 580 */ 264, 194, 264, 194, 133, 194, 194, 135, 194, 194,
/* 590 */ 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, /* 590 */ 194, 194, 194, 194, 132, 194, 194, 194, 194, 194,
/* 600 */ 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, /* 600 */ 194, 194, 194, 131, 194, 194, 194, 194, 194, 194,
/* 610 */ 200, 200, 200, 200, 200, 200, 99, 98, 202, 202, /* 610 */ 194, 194, 194, 194, 194, 194, 194, 194, 194, 194,
/* 620 */ 202, 202, 53, 202, 95, 97, 96, 57, 94, 202, /* 620 */ 194, 194, 125, 194, 194, 194, 194, 124, 127, 196,
/* 630 */ 86, 5, 5, 202, 155, 202, 5, 155, 5, 5, /* 630 */ 196, 196, 137, 196, 196, 94, 93, 47, 90, 92,
/* 640 */ 103, 202, 202, 102, 207, 210, 210, 144, 122, 117, /* 640 */ 51, 196, 91, 196, 196, 89, 80, 3, 150, 3,
/* 650 */ 84, 100, 85, 100, 100, 84, 84, 202, 202, 212, /* 650 */ 3, 196, 150, 204, 204, 201, 196, 3, 3, 98,
/* 660 */ 217, 219, 218, 213, 203, 203, 214, 216, 215, 202, /* 660 */ 97, 139, 117, 78, 196, 112, 196, 79, 207, 211,
/* 670 */ 204, 203, 202, 208, 203, 221, 202, 202, 256, 254, /* 670 */ 213, 212, 197, 210, 208, 206, 209, 197, 196, 196,
/* 680 */ 252, 247, 85, 85, 84, 1, 85, 84, 100, 85, /* 680 */ 215, 197, 197, 196, 196, 78, 95, 95, 246, 79,
/* 690 */ 84, 84, 134, 100, 134, 84, 84, 117, 5, 84, /* 690 */ 198, 252, 251, 78, 250, 249, 79, 78, 202, 79,
/* 700 */ 118, 80, 72, 90, 5, 89, 9, 90, 89, 5, /* 700 */ 95, 78, 1, 79, 78, 78, 95, 129, 95, 129,
/* 710 */ 5, 5, 5, 5, 5, 5, 87, 15, 80, 84, /* 710 */ 78, 78, 112, 78, 113, 74, 85, 66, 84, 3,
/* 720 */ 88, 85, 26, 84, 119, 61, 149, 16, 149, 16, /* 720 */ 5, 85, 84, 3, 3, 3, 3, 3, 3, 3,
/* 730 */ 149, 5, 149, 5, 85, 5, 5, 100, 5, 5, /* 730 */ 81, 74, 82, 20, 82, 79, 9, 78, 78, 114,
/* 740 */ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, /* 740 */ 55, 10, 144, 144, 10, 3, 144, 144, 95, 3,
/* 750 */ 100, 62, 87, 21, 0, 278, 278, 278, 278, 278, /* 750 */ 79, 3, 3, 3, 3, 3, 3, 3, 3, 3,
/* 760 */ 278, 278, 278, 278, 278, 278, 21, 278, 278, 278, /* 760 */ 3, 3, 3, 3, 3, 95, 56, 81, 0, 272,
/* 770 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, /* 770 */ 272, 272, 272, 272, 272, 272, 272, 15, 15, 272,
/* 780 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, /* 780 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272,
/* 790 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, /* 790 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272,
/* 800 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, /* 800 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272,
/* 810 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, /* 810 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272,
/* 820 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, /* 820 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272,
/* 830 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, /* 830 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272,
/* 840 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, /* 840 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272,
/* 850 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, /* 850 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272,
/* 860 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, /* 860 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272,
/* 870 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, /* 870 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272,
/* 880 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, /* 880 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272,
/* 890 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, /* 890 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272,
/* 900 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, /* 900 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272,
/* 910 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, /* 910 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272,
/* 920 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, /* 920 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272,
/* 930 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, /* 930 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272,
/* 940 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, /* 940 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272,
/* 950 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, /* 950 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272,
/* 960 */ 278, 278, 278, 278, /* 960 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272,
}; };
#define YY_SHIFT_COUNT (361) #define YY_SHIFT_COUNT (364)
#define YY_SHIFT_MIN (0) #define YY_SHIFT_MIN (0)
#define YY_SHIFT_MAX (754) #define YY_SHIFT_MAX (768)
static const unsigned short int yy_shift_ofst[] = { static const unsigned short int yy_shift_ofst[] = {
/* 0 */ 184, 114, 242, 59, 248, 264, 264, 81, 3, 3, /* 0 */ 205, 116, 25, 28, 263, 283, 283, 183, 31, 31,
/* 10 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 10 */ 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
/* 20 */ 3, 0, 99, 264, 306, 127, 127, 3, 3, 124, /* 20 */ 31, 0, 97, 283, 268, 297, 297, 294, 294, 31,
/* 30 */ 3, 15, 3, 3, 3, 3, 245, 59, 17, 17, /* 30 */ 31, 84, 31, 172, 31, 31, 31, 31, 351, 28,
/* 40 */ 230, 230, 55, 767, 264, 264, 264, 264, 264, 264, /* 40 */ 9, 9, 3, 779, 283, 283, 283, 283, 283, 283,
/* 50 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, /* 50 */ 283, 283, 283, 283, 283, 283, 283, 283, 283, 283,
/* 60 */ 264, 264, 264, 264, 264, 264, 306, 306, 306, 268, /* 60 */ 283, 283, 283, 283, 283, 283, 268, 297, 268, 268,
/* 70 */ 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, /* 70 */ 55, 364, 364, 364, 364, 364, 364, 8, 364, 31,
/* 80 */ 287, 3, 3, 3, 127, 127, 3, 3, 3, 3, /* 80 */ 31, 31, 124, 31, 31, 31, 294, 294, 31, 31,
/* 90 */ 310, 310, 322, 127, 3, 3, 3, 3, 3, 3, /* 90 */ 31, 31, 323, 323, 304, 294, 31, 31, 31, 31,
/* 100 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 100 */ 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
/* 110 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 110 */ 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
/* 120 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 120 */ 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
/* 130 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 130 */ 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
/* 140 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 140 */ 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
/* 150 */ 3, 3, 460, 460, 460, 420, 420, 420, 420, 460, /* 150 */ 31, 31, 31, 31, 494, 494, 494, 436, 436, 436,
/* 160 */ 460, 423, 424, 430, 429, 432, 426, 441, 449, 448, /* 160 */ 436, 494, 494, 451, 452, 440, 462, 472, 443, 497,
/* 170 */ 445, 460, 17, 460, 460, 446, 446, 59, 460, 460, /* 170 */ 503, 501, 495, 494, 494, 494, 471, 471, 28, 494,
/* 180 */ 517, 519, 569, 529, 528, 570, 530, 534, 55, 460, /* 180 */ 494, 541, 543, 590, 548, 547, 589, 551, 556, 3,
/* 190 */ 460, 544, 544, 460, 544, 460, 544, 460, 460, 767, /* 190 */ 494, 494, 566, 566, 494, 566, 494, 566, 494, 494,
/* 200 */ 767, 29, 58, 58, 90, 58, 147, 173, 250, 250, /* 200 */ 779, 779, 30, 66, 66, 96, 66, 145, 175, 225,
/* 210 */ 250, 250, 250, 250, 229, 69, 312, 357, 357, 357, /* 210 */ 225, 225, 225, 225, 225, 248, 270, 288, 336, 336,
/* 220 */ 357, 189, 254, 53, 192, 98, 98, 291, 314, 346, /* 220 */ 336, 336, 217, 246, 141, 325, 298, 298, 199, 247,
/* 230 */ 354, 262, 338, 347, 350, 353, 358, 331, 270, 359, /* 230 */ 374, 291, 354, 327, 328, 363, 367, 368, 353, 356,
/* 240 */ 361, 363, 364, 366, 368, 370, 371, 438, 40, 163, /* 240 */ 371, 373, 375, 376, 453, 456, 382, 386, 388, 390,
/* 250 */ 380, 326, 327, 332, 477, 481, 340, 343, 378, 344, /* 250 */ 464, 262, 409, 393, 331, 332, 337, 489, 491, 338,
/* 260 */ 387, 626, 479, 627, 631, 482, 633, 634, 537, 541, /* 260 */ 342, 400, 357, 428, 644, 498, 646, 647, 502, 654,
/* 270 */ 503, 526, 532, 566, 567, 571, 551, 553, 597, 572, /* 270 */ 655, 561, 563, 522, 545, 553, 585, 588, 607, 591,
/* 280 */ 598, 600, 601, 554, 603, 604, 606, 684, 607, 588, /* 280 */ 592, 610, 615, 617, 619, 620, 605, 623, 624, 626,
/* 290 */ 558, 593, 560, 611, 532, 612, 580, 693, 615, 582, /* 290 */ 701, 627, 611, 578, 613, 580, 632, 553, 633, 600,
/* 300 */ 621, 613, 616, 630, 699, 617, 619, 697, 704, 705, /* 300 */ 635, 601, 641, 631, 634, 651, 716, 636, 638, 715,
/* 310 */ 706, 707, 708, 709, 710, 629, 702, 638, 632, 635, /* 310 */ 720, 721, 722, 723, 724, 725, 726, 649, 727, 657,
/* 320 */ 636, 605, 639, 696, 664, 711, 577, 579, 637, 637, /* 320 */ 650, 652, 659, 656, 625, 660, 713, 685, 731, 598,
/* 330 */ 637, 637, 713, 581, 583, 637, 637, 637, 726, 728, /* 330 */ 599, 653, 653, 653, 653, 734, 602, 603, 653, 653,
/* 340 */ 649, 637, 730, 731, 733, 734, 735, 736, 737, 738, /* 340 */ 653, 742, 746, 671, 653, 748, 749, 750, 751, 752,
/* 350 */ 739, 740, 741, 742, 743, 744, 650, 665, 732, 745, /* 350 */ 753, 754, 755, 756, 757, 758, 759, 760, 761, 670,
/* 360 */ 689, 754, /* 360 */ 686, 762, 763, 710, 768,
}; };
#define YY_REDUCE_COUNT (200) #define YY_REDUCE_COUNT (201)
#define YY_REDUCE_MIN (-261) #define YY_REDUCE_MIN (-232)
#define YY_REDUCE_MAX (475) #define YY_REDUCE_MAX (496)
static const short yy_reduce_ofst[] = { static const short yy_reduce_ofst[] = {
/* 0 */ -136, 10, 136, -207, -200, -145, -2, -77, -198, -95, /* 0 */ -56, 11, -161, 90, -78, 119, 142, -192, 17, -176,
/* 10 */ -16, 70, 72, 88, 107, 109, 117, 133, 164, 166, /* 10 */ -24, 69, 160, 165, 179, 180, 181, 186, 187, 192,
/* 20 */ 182, -176, -190, -258, -153, 158, 171, -182, -64, 21, /* 20 */ 194, -194, -191, -232, -217, -210, -162, -196, -81, 6,
/* 30 */ -197, -36, -133, 97, 122, -15, -83, 188, 186, 194, /* 30 */ 85, -84, -182, -108, -89, 100, 101, 191, -157, 143,
/* 40 */ 196, 225, 160, -84, -261, -193, 62, 78, 176, 191, /* 40 */ -127, 209, 226, 185, -83, -73, -4, 51, 227, 231,
/* 50 */ 212, 217, 231, 232, 233, 234, 235, 236, 237, 238, /* 50 */ 236, 240, 244, 245, 249, 250, 252, 253, 254, 255,
/* 60 */ 239, 240, 241, 243, 244, 246, 150, 205, 247, 128, /* 60 */ 256, 257, 258, 259, 260, 261, 264, 265, 279, 281,
/* 70 */ 258, 271, 274, 276, 277, 278, 279, 317, 318, 319, /* 70 */ 269, 295, 296, 299, 300, 301, 302, 334, 303, 335,
/* 80 */ 255, 321, 323, 324, 280, 281, 328, 329, 330, 333, /* 80 */ 341, 343, 266, 344, 345, 346, 305, 306, 347, 348,
/* 90 */ 252, 256, 283, 290, 336, 337, 339, 341, 342, 345, /* 90 */ 349, 352, 267, 278, 307, 309, 355, 359, 360, 361,
/* 100 */ 348, 349, 351, 352, 355, 356, 360, 362, 365, 367, /* 100 */ 362, 365, 366, 369, 370, 372, 377, 378, 379, 380,
/* 110 */ 369, 372, 373, 374, 375, 376, 377, 379, 381, 382, /* 110 */ 381, 383, 384, 385, 387, 389, 391, 392, 394, 395,
/* 120 */ 383, 384, 385, 386, 388, 389, 390, 391, 392, 393, /* 120 */ 396, 397, 398, 399, 401, 402, 403, 404, 405, 406,
/* 130 */ 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, /* 130 */ 407, 408, 410, 411, 412, 413, 414, 415, 416, 417,
/* 140 */ 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, /* 140 */ 418, 419, 420, 421, 422, 423, 424, 425, 426, 427,
/* 150 */ 414, 415, 416, 417, 418, 273, 284, 288, 289, 419, /* 150 */ 429, 430, 431, 432, 433, 434, 435, 287, 312, 316,
/* 160 */ 421, 282, 286, 272, 294, 292, 313, 422, 285, 425, /* 160 */ 318, 437, 438, 311, 310, 308, 317, 439, 441, 444,
/* 170 */ 428, 427, 434, 431, 433, 435, 436, 437, 439, 440, /* 170 */ 446, 313, 442, 445, 447, 448, 449, 450, 454, 455,
/* 180 */ 442, 444, 443, 450, 451, 452, 453, 447, 454, 455, /* 180 */ 460, 457, 459, 458, 461, 463, 466, 467, 469, 465,
/* 190 */ 456, 461, 462, 467, 468, 470, 471, 474, 475, 465, /* 190 */ 468, 470, 475, 480, 482, 484, 483, 485, 487, 488,
/* 200 */ 466, /* 200 */ 496, 492,
}; };
static const YYACTIONTYPE yy_default[] = { static const YYACTIONTYPE yy_default[] = {
/* 0 */ 862, 924, 912, 921, 1134, 1134, 1134, 862, 862, 862, /* 0 */ 885, 948, 935, 944, 1167, 1167, 1167, 885, 885, 885,
/* 10 */ 862, 862, 862, 862, 862, 862, 862, 862, 862, 862, /* 10 */ 885, 885, 885, 885, 885, 885, 885, 885, 885, 885,
/* 20 */ 862, 1041, 882, 1134, 862, 862, 862, 862, 862, 1056, /* 20 */ 885, 1074, 905, 1167, 885, 885, 885, 885, 885, 885,
/* 30 */ 862, 921, 862, 862, 862, 862, 930, 921, 862, 862, /* 30 */ 885, 1089, 885, 944, 885, 885, 885, 885, 954, 944,
/* 40 */ 930, 930, 862, 1036, 862, 862, 862, 862, 862, 862, /* 40 */ 954, 954, 885, 1069, 885, 885, 885, 885, 885, 885,
/* 50 */ 862, 862, 862, 862, 862, 862, 862, 862, 862, 862, /* 50 */ 885, 885, 885, 885, 885, 885, 885, 885, 885, 885,
/* 60 */ 862, 862, 862, 862, 862, 862, 862, 862, 862, 862, /* 60 */ 885, 885, 885, 885, 885, 885, 885, 885, 885, 885,
/* 70 */ 862, 862, 862, 862, 862, 862, 862, 862, 862, 862, /* 70 */ 885, 885, 885, 885, 885, 885, 885, 885, 885, 885,
/* 80 */ 1043, 1049, 1046, 862, 862, 862, 1051, 862, 862, 862, /* 80 */ 885, 885, 1076, 1082, 1079, 885, 885, 885, 1084, 885,
/* 90 */ 1075, 1075, 1034, 862, 862, 862, 862, 862, 862, 862, /* 90 */ 885, 885, 1108, 1108, 1067, 885, 885, 885, 885, 885,
/* 100 */ 862, 862, 862, 862, 862, 862, 862, 862, 862, 862, /* 100 */ 885, 885, 885, 885, 885, 885, 885, 885, 885, 885,
/* 110 */ 862, 862, 862, 862, 862, 862, 862, 862, 862, 862, /* 110 */ 885, 885, 885, 885, 885, 885, 885, 885, 885, 885,
/* 120 */ 862, 862, 862, 862, 862, 910, 862, 908, 862, 862, /* 120 */ 885, 885, 885, 885, 885, 885, 885, 933, 885, 931,
/* 130 */ 862, 862, 862, 862, 862, 862, 862, 862, 862, 862, /* 130 */ 885, 885, 885, 885, 885, 885, 885, 885, 885, 885,
/* 140 */ 862, 862, 862, 862, 893, 862, 862, 862, 862, 862, /* 140 */ 885, 885, 885, 885, 885, 885, 916, 885, 885, 885,
/* 150 */ 862, 880, 884, 884, 884, 862, 862, 862, 862, 884, /* 150 */ 885, 885, 885, 903, 907, 907, 907, 885, 885, 885,
/* 160 */ 884, 1082, 1086, 1068, 1080, 1076, 1063, 1061, 1059, 1067, /* 160 */ 885, 907, 907, 1115, 1119, 1101, 1113, 1109, 1096, 1094,
/* 170 */ 1090, 884, 862, 884, 884, 928, 928, 921, 884, 884, /* 170 */ 1092, 1100, 1123, 907, 907, 907, 952, 952, 944, 907,
/* 180 */ 946, 944, 942, 934, 940, 936, 938, 932, 862, 884, /* 180 */ 907, 970, 968, 966, 958, 964, 960, 962, 956, 885,
/* 190 */ 884, 919, 919, 884, 919, 884, 919, 884, 884, 967, /* 190 */ 907, 907, 942, 942, 907, 942, 907, 942, 907, 907,
/* 200 */ 983, 862, 1091, 1081, 862, 1133, 1121, 1120, 1129, 1128, /* 200 */ 991, 1007, 885, 1124, 1114, 885, 1166, 1154, 1153, 1162,
/* 210 */ 1127, 1119, 1118, 1117, 862, 862, 862, 1113, 1116, 1115, /* 210 */ 1161, 1160, 1152, 1151, 1150, 885, 885, 885, 1146, 1149,
/* 220 */ 1114, 862, 862, 862, 862, 1123, 1122, 862, 862, 862, /* 220 */ 1148, 1147, 885, 885, 885, 885, 1156, 1155, 885, 885,
/* 230 */ 862, 862, 862, 862, 862, 862, 862, 1087, 1083, 862, /* 230 */ 885, 885, 885, 885, 885, 885, 885, 885, 1120, 1116,
/* 240 */ 862, 862, 862, 862, 862, 862, 862, 862, 1093, 862, /* 240 */ 885, 885, 885, 885, 885, 885, 885, 885, 885, 885,
/* 250 */ 862, 862, 862, 862, 862, 862, 862, 862, 991, 862, /* 250 */ 885, 1126, 885, 885, 885, 885, 885, 885, 885, 885,
/* 260 */ 862, 862, 862, 862, 862, 862, 862, 862, 862, 862, /* 260 */ 885, 1015, 885, 885, 885, 885, 885, 885, 885, 885,
/* 270 */ 862, 1033, 862, 862, 862, 862, 1045, 1044, 862, 862, /* 270 */ 885, 885, 885, 885, 1066, 885, 885, 885, 885, 1078,
/* 280 */ 862, 862, 862, 862, 862, 862, 862, 862, 862, 1077, /* 280 */ 1077, 885, 885, 885, 885, 885, 885, 885, 885, 885,
/* 290 */ 862, 1069, 862, 862, 1003, 862, 862, 862, 862, 862, /* 290 */ 885, 885, 1110, 885, 1102, 885, 885, 1027, 885, 885,
/* 300 */ 862, 862, 862, 862, 862, 862, 862, 862, 862, 862, /* 300 */ 885, 885, 885, 885, 885, 885, 885, 885, 885, 885,
/* 310 */ 862, 862, 862, 862, 862, 862, 862, 862, 862, 862, /* 310 */ 885, 885, 885, 885, 885, 885, 885, 885, 885, 885,
/* 320 */ 862, 862, 862, 862, 862, 862, 862, 862, 1152, 1147, /* 320 */ 885, 885, 885, 885, 885, 885, 885, 885, 885, 885,
/* 330 */ 1148, 1145, 862, 862, 862, 1144, 1139, 1140, 862, 862, /* 330 */ 885, 1185, 1180, 1181, 1178, 885, 885, 885, 1177, 1172,
/* 340 */ 862, 1137, 862, 862, 862, 862, 862, 862, 862, 862, /* 340 */ 1173, 885, 885, 885, 1170, 885, 885, 885, 885, 885,
/* 350 */ 862, 862, 862, 862, 862, 862, 952, 862, 891, 889, /* 350 */ 885, 885, 885, 885, 885, 885, 885, 885, 885, 976,
/* 360 */ 862, 862, /* 360 */ 885, 914, 912, 885, 885,
}; };
/********** End of lemon-generated parsing tables *****************************/ /********** End of lemon-generated parsing tables *****************************/
...@@ -513,16 +514,10 @@ static const YYCODETYPE yyFallback[] = { ...@@ -513,16 +514,10 @@ static const YYCODETYPE yyFallback[] = {
0, /* $ => nothing */ 0, /* $ => nothing */
0, /* ID => nothing */ 0, /* ID => nothing */
1, /* BOOL => ID */ 1, /* BOOL => ID */
1, /* TINYINT => ID */
1, /* SMALLINT => ID */
1, /* INTEGER => ID */ 1, /* INTEGER => ID */
1, /* BIGINT => ID */
1, /* FLOAT => ID */ 1, /* FLOAT => ID */
1, /* DOUBLE => ID */
1, /* STRING => ID */ 1, /* STRING => ID */
1, /* TIMESTAMP => ID */ 1, /* TIMESTAMP => ID */
1, /* BINARY => ID */
1, /* NCHAR => ID */
0, /* OR => nothing */ 0, /* OR => nothing */
0, /* AND => nothing */ 0, /* AND => nothing */
0, /* NOT => nothing */ 0, /* NOT => nothing */
...@@ -599,6 +594,7 @@ static const YYCODETYPE yyFallback[] = { ...@@ -599,6 +594,7 @@ static const YYCODETYPE yyFallback[] = {
0, /* IF => nothing */ 0, /* IF => nothing */
0, /* EXISTS => nothing */ 0, /* EXISTS => nothing */
0, /* PORT => nothing */ 0, /* PORT => nothing */
1, /* IPTOKEN => ID */
0, /* AS => nothing */ 0, /* AS => nothing */
0, /* OUTPUTTYPE => nothing */ 0, /* OUTPUTTYPE => nothing */
0, /* AGGREGATE => nothing */ 0, /* AGGREGATE => nothing */
...@@ -696,7 +692,6 @@ static const YYCODETYPE yyFallback[] = { ...@@ -696,7 +692,6 @@ static const YYCODETYPE yyFallback[] = {
1, /* STATEMENT => ID */ 1, /* STATEMENT => ID */
1, /* TRIGGER => ID */ 1, /* TRIGGER => ID */
1, /* VIEW => ID */ 1, /* VIEW => ID */
1, /* IPTOKEN => ID */
1, /* SEMI => ID */ 1, /* SEMI => ID */
1, /* NONE => ID */ 1, /* NONE => ID */
1, /* PREV => ID */ 1, /* PREV => ID */
...@@ -796,281 +791,275 @@ static const char *const yyTokenName[] = { ...@@ -796,281 +791,275 @@ static const char *const yyTokenName[] = {
/* 0 */ "$", /* 0 */ "$",
/* 1 */ "ID", /* 1 */ "ID",
/* 2 */ "BOOL", /* 2 */ "BOOL",
/* 3 */ "TINYINT", /* 3 */ "INTEGER",
/* 4 */ "SMALLINT", /* 4 */ "FLOAT",
/* 5 */ "INTEGER", /* 5 */ "STRING",
/* 6 */ "BIGINT", /* 6 */ "TIMESTAMP",
/* 7 */ "FLOAT", /* 7 */ "OR",
/* 8 */ "DOUBLE", /* 8 */ "AND",
/* 9 */ "STRING", /* 9 */ "NOT",
/* 10 */ "TIMESTAMP", /* 10 */ "EQ",
/* 11 */ "BINARY", /* 11 */ "NE",
/* 12 */ "NCHAR", /* 12 */ "ISNULL",
/* 13 */ "OR", /* 13 */ "NOTNULL",
/* 14 */ "AND", /* 14 */ "IS",
/* 15 */ "NOT", /* 15 */ "LIKE",
/* 16 */ "EQ", /* 16 */ "MATCH",
/* 17 */ "NE", /* 17 */ "NMATCH",
/* 18 */ "ISNULL", /* 18 */ "GLOB",
/* 19 */ "NOTNULL", /* 19 */ "BETWEEN",
/* 20 */ "IS", /* 20 */ "IN",
/* 21 */ "LIKE", /* 21 */ "GT",
/* 22 */ "MATCH", /* 22 */ "GE",
/* 23 */ "NMATCH", /* 23 */ "LT",
/* 24 */ "GLOB", /* 24 */ "LE",
/* 25 */ "BETWEEN", /* 25 */ "BITAND",
/* 26 */ "IN", /* 26 */ "BITOR",
/* 27 */ "GT", /* 27 */ "LSHIFT",
/* 28 */ "GE", /* 28 */ "RSHIFT",
/* 29 */ "LT", /* 29 */ "PLUS",
/* 30 */ "LE", /* 30 */ "MINUS",
/* 31 */ "BITAND", /* 31 */ "DIVIDE",
/* 32 */ "BITOR", /* 32 */ "TIMES",
/* 33 */ "LSHIFT", /* 33 */ "STAR",
/* 34 */ "RSHIFT", /* 34 */ "SLASH",
/* 35 */ "PLUS", /* 35 */ "REM",
/* 36 */ "MINUS", /* 36 */ "CONCAT",
/* 37 */ "DIVIDE", /* 37 */ "UMINUS",
/* 38 */ "TIMES", /* 38 */ "UPLUS",
/* 39 */ "STAR", /* 39 */ "BITNOT",
/* 40 */ "SLASH", /* 40 */ "SHOW",
/* 41 */ "REM", /* 41 */ "DATABASES",
/* 42 */ "CONCAT", /* 42 */ "TOPICS",
/* 43 */ "UMINUS", /* 43 */ "FUNCTIONS",
/* 44 */ "UPLUS", /* 44 */ "MNODES",
/* 45 */ "BITNOT", /* 45 */ "DNODES",
/* 46 */ "SHOW", /* 46 */ "ACCOUNTS",
/* 47 */ "DATABASES", /* 47 */ "USERS",
/* 48 */ "TOPICS", /* 48 */ "MODULES",
/* 49 */ "FUNCTIONS", /* 49 */ "QUERIES",
/* 50 */ "MNODES", /* 50 */ "CONNECTIONS",
/* 51 */ "DNODES", /* 51 */ "STREAMS",
/* 52 */ "ACCOUNTS", /* 52 */ "VARIABLES",
/* 53 */ "USERS", /* 53 */ "SCORES",
/* 54 */ "MODULES", /* 54 */ "GRANTS",
/* 55 */ "QUERIES", /* 55 */ "VNODES",
/* 56 */ "CONNECTIONS", /* 56 */ "DOT",
/* 57 */ "STREAMS", /* 57 */ "CREATE",
/* 58 */ "VARIABLES", /* 58 */ "TABLE",
/* 59 */ "SCORES", /* 59 */ "STABLE",
/* 60 */ "GRANTS", /* 60 */ "DATABASE",
/* 61 */ "VNODES", /* 61 */ "TABLES",
/* 62 */ "DOT", /* 62 */ "STABLES",
/* 63 */ "CREATE", /* 63 */ "VGROUPS",
/* 64 */ "TABLE", /* 64 */ "DROP",
/* 65 */ "STABLE", /* 65 */ "TOPIC",
/* 66 */ "DATABASE", /* 66 */ "FUNCTION",
/* 67 */ "TABLES", /* 67 */ "DNODE",
/* 68 */ "STABLES", /* 68 */ "USER",
/* 69 */ "VGROUPS", /* 69 */ "ACCOUNT",
/* 70 */ "DROP", /* 70 */ "USE",
/* 71 */ "TOPIC", /* 71 */ "DESCRIBE",
/* 72 */ "FUNCTION", /* 72 */ "DESC",
/* 73 */ "DNODE", /* 73 */ "ALTER",
/* 74 */ "USER", /* 74 */ "PASS",
/* 75 */ "ACCOUNT", /* 75 */ "PRIVILEGE",
/* 76 */ "USE", /* 76 */ "LOCAL",
/* 77 */ "DESCRIBE", /* 77 */ "COMPACT",
/* 78 */ "DESC", /* 78 */ "LP",
/* 79 */ "ALTER", /* 79 */ "RP",
/* 80 */ "PASS", /* 80 */ "IF",
/* 81 */ "PRIVILEGE", /* 81 */ "EXISTS",
/* 82 */ "LOCAL", /* 82 */ "PORT",
/* 83 */ "COMPACT", /* 83 */ "IPTOKEN",
/* 84 */ "LP", /* 84 */ "AS",
/* 85 */ "RP", /* 85 */ "OUTPUTTYPE",
/* 86 */ "IF", /* 86 */ "AGGREGATE",
/* 87 */ "EXISTS", /* 87 */ "BUFSIZE",
/* 88 */ "PORT", /* 88 */ "PPS",
/* 89 */ "AS", /* 89 */ "TSERIES",
/* 90 */ "OUTPUTTYPE", /* 90 */ "DBS",
/* 91 */ "AGGREGATE", /* 91 */ "STORAGE",
/* 92 */ "BUFSIZE", /* 92 */ "QTIME",
/* 93 */ "PPS", /* 93 */ "CONNS",
/* 94 */ "TSERIES", /* 94 */ "STATE",
/* 95 */ "DBS", /* 95 */ "COMMA",
/* 96 */ "STORAGE", /* 96 */ "KEEP",
/* 97 */ "QTIME", /* 97 */ "CACHE",
/* 98 */ "CONNS", /* 98 */ "REPLICA",
/* 99 */ "STATE", /* 99 */ "QUORUM",
/* 100 */ "COMMA", /* 100 */ "DAYS",
/* 101 */ "KEEP", /* 101 */ "MINROWS",
/* 102 */ "CACHE", /* 102 */ "MAXROWS",
/* 103 */ "REPLICA", /* 103 */ "BLOCKS",
/* 104 */ "QUORUM", /* 104 */ "CTIME",
/* 105 */ "DAYS", /* 105 */ "WAL",
/* 106 */ "MINROWS", /* 106 */ "FSYNC",
/* 107 */ "MAXROWS", /* 107 */ "COMP",
/* 108 */ "BLOCKS", /* 108 */ "PRECISION",
/* 109 */ "CTIME", /* 109 */ "UPDATE",
/* 110 */ "WAL", /* 110 */ "CACHELAST",
/* 111 */ "FSYNC", /* 111 */ "UNSIGNED",
/* 112 */ "COMP", /* 112 */ "TAGS",
/* 113 */ "PRECISION", /* 113 */ "USING",
/* 114 */ "UPDATE", /* 114 */ "NULL",
/* 115 */ "CACHELAST", /* 115 */ "NOW",
/* 116 */ "UNSIGNED", /* 116 */ "SELECT",
/* 117 */ "TAGS", /* 117 */ "UNION",
/* 118 */ "USING", /* 118 */ "ALL",
/* 119 */ "NULL", /* 119 */ "DISTINCT",
/* 120 */ "NOW", /* 120 */ "FROM",
/* 121 */ "SELECT", /* 121 */ "VARIABLE",
/* 122 */ "UNION", /* 122 */ "INTERVAL",
/* 123 */ "ALL", /* 123 */ "EVERY",
/* 124 */ "DISTINCT", /* 124 */ "SESSION",
/* 125 */ "FROM", /* 125 */ "STATE_WINDOW",
/* 126 */ "VARIABLE", /* 126 */ "FILL",
/* 127 */ "INTERVAL", /* 127 */ "SLIDING",
/* 128 */ "EVERY", /* 128 */ "ORDER",
/* 129 */ "SESSION", /* 129 */ "BY",
/* 130 */ "STATE_WINDOW", /* 130 */ "ASC",
/* 131 */ "FILL", /* 131 */ "GROUP",
/* 132 */ "SLIDING", /* 132 */ "HAVING",
/* 133 */ "ORDER", /* 133 */ "LIMIT",
/* 134 */ "BY", /* 134 */ "OFFSET",
/* 135 */ "ASC", /* 135 */ "SLIMIT",
/* 136 */ "GROUP", /* 136 */ "SOFFSET",
/* 137 */ "HAVING", /* 137 */ "WHERE",
/* 138 */ "LIMIT", /* 138 */ "RESET",
/* 139 */ "OFFSET", /* 139 */ "QUERY",
/* 140 */ "SLIMIT", /* 140 */ "SYNCDB",
/* 141 */ "SOFFSET", /* 141 */ "ADD",
/* 142 */ "WHERE", /* 142 */ "COLUMN",
/* 143 */ "RESET", /* 143 */ "MODIFY",
/* 144 */ "QUERY", /* 144 */ "TAG",
/* 145 */ "SYNCDB", /* 145 */ "CHANGE",
/* 146 */ "ADD", /* 146 */ "SET",
/* 147 */ "COLUMN", /* 147 */ "KILL",
/* 148 */ "MODIFY", /* 148 */ "CONNECTION",
/* 149 */ "TAG", /* 149 */ "STREAM",
/* 150 */ "CHANGE", /* 150 */ "COLON",
/* 151 */ "SET", /* 151 */ "ABORT",
/* 152 */ "KILL", /* 152 */ "AFTER",
/* 153 */ "CONNECTION", /* 153 */ "ATTACH",
/* 154 */ "STREAM", /* 154 */ "BEFORE",
/* 155 */ "COLON", /* 155 */ "BEGIN",
/* 156 */ "ABORT", /* 156 */ "CASCADE",
/* 157 */ "AFTER", /* 157 */ "CLUSTER",
/* 158 */ "ATTACH", /* 158 */ "CONFLICT",
/* 159 */ "BEFORE", /* 159 */ "COPY",
/* 160 */ "BEGIN", /* 160 */ "DEFERRED",
/* 161 */ "CASCADE", /* 161 */ "DELIMITERS",
/* 162 */ "CLUSTER", /* 162 */ "DETACH",
/* 163 */ "CONFLICT", /* 163 */ "EACH",
/* 164 */ "COPY", /* 164 */ "END",
/* 165 */ "DEFERRED", /* 165 */ "EXPLAIN",
/* 166 */ "DELIMITERS", /* 166 */ "FAIL",
/* 167 */ "DETACH", /* 167 */ "FOR",
/* 168 */ "EACH", /* 168 */ "IGNORE",
/* 169 */ "END", /* 169 */ "IMMEDIATE",
/* 170 */ "EXPLAIN", /* 170 */ "INITIALLY",
/* 171 */ "FAIL", /* 171 */ "INSTEAD",
/* 172 */ "FOR", /* 172 */ "KEY",
/* 173 */ "IGNORE", /* 173 */ "OF",
/* 174 */ "IMMEDIATE", /* 174 */ "RAISE",
/* 175 */ "INITIALLY", /* 175 */ "REPLACE",
/* 176 */ "INSTEAD", /* 176 */ "RESTRICT",
/* 177 */ "KEY", /* 177 */ "ROW",
/* 178 */ "OF", /* 178 */ "STATEMENT",
/* 179 */ "RAISE", /* 179 */ "TRIGGER",
/* 180 */ "REPLACE", /* 180 */ "VIEW",
/* 181 */ "RESTRICT", /* 181 */ "SEMI",
/* 182 */ "ROW", /* 182 */ "NONE",
/* 183 */ "STATEMENT", /* 183 */ "PREV",
/* 184 */ "TRIGGER", /* 184 */ "LINEAR",
/* 185 */ "VIEW", /* 185 */ "IMPORT",
/* 186 */ "IPTOKEN", /* 186 */ "TBNAME",
/* 187 */ "SEMI", /* 187 */ "JOIN",
/* 188 */ "NONE", /* 188 */ "INSERT",
/* 189 */ "PREV", /* 189 */ "INTO",
/* 190 */ "LINEAR", /* 190 */ "VALUES",
/* 191 */ "IMPORT", /* 191 */ "error",
/* 192 */ "TBNAME", /* 192 */ "program",
/* 193 */ "JOIN", /* 193 */ "cmd",
/* 194 */ "INSERT", /* 194 */ "ids",
/* 195 */ "INTO", /* 195 */ "dbPrefix",
/* 196 */ "VALUES", /* 196 */ "cpxName",
/* 197 */ "error", /* 197 */ "ifexists",
/* 198 */ "program", /* 198 */ "alter_db_optr",
/* 199 */ "cmd", /* 199 */ "acct_optr",
/* 200 */ "ids", /* 200 */ "exprlist",
/* 201 */ "dbPrefix", /* 201 */ "ifnotexists",
/* 202 */ "cpxName", /* 202 */ "db_optr",
/* 203 */ "ifexists", /* 203 */ "typename",
/* 204 */ "alter_db_optr", /* 204 */ "bufsize",
/* 205 */ "acct_optr", /* 205 */ "pps",
/* 206 */ "exprlist", /* 206 */ "tseries",
/* 207 */ "ifnotexists", /* 207 */ "dbs",
/* 208 */ "db_optr", /* 208 */ "streams",
/* 209 */ "typename", /* 209 */ "storage",
/* 210 */ "bufsize", /* 210 */ "qtime",
/* 211 */ "pps", /* 211 */ "users",
/* 212 */ "tseries", /* 212 */ "conns",
/* 213 */ "dbs", /* 213 */ "state",
/* 214 */ "streams", /* 214 */ "intitemlist",
/* 215 */ "storage", /* 215 */ "intitem",
/* 216 */ "qtime", /* 216 */ "keep",
/* 217 */ "users", /* 217 */ "cache",
/* 218 */ "conns", /* 218 */ "replica",
/* 219 */ "state", /* 219 */ "quorum",
/* 220 */ "intitemlist", /* 220 */ "days",
/* 221 */ "intitem", /* 221 */ "minrows",
/* 222 */ "keep", /* 222 */ "maxrows",
/* 223 */ "cache", /* 223 */ "blocks",
/* 224 */ "replica", /* 224 */ "ctime",
/* 225 */ "quorum", /* 225 */ "wal",
/* 226 */ "days", /* 226 */ "fsync",
/* 227 */ "minrows", /* 227 */ "comp",
/* 228 */ "maxrows", /* 228 */ "prec",
/* 229 */ "blocks", /* 229 */ "update",
/* 230 */ "ctime", /* 230 */ "cachelast",
/* 231 */ "wal", /* 231 */ "signed",
/* 232 */ "fsync", /* 232 */ "create_table_args",
/* 233 */ "comp", /* 233 */ "create_stable_args",
/* 234 */ "prec", /* 234 */ "create_table_list",
/* 235 */ "update", /* 235 */ "create_from_stable",
/* 236 */ "cachelast", /* 236 */ "columnlist",
/* 237 */ "signed", /* 237 */ "tagitemlist1",
/* 238 */ "create_table_args", /* 238 */ "tagNamelist",
/* 239 */ "create_stable_args", /* 239 */ "select",
/* 240 */ "create_table_list", /* 240 */ "column",
/* 241 */ "create_from_stable", /* 241 */ "tagitem1",
/* 242 */ "columnlist", /* 242 */ "tagitemlist",
/* 243 */ "tagitemlist1", /* 243 */ "tagitem",
/* 244 */ "tagNamelist", /* 244 */ "selcollist",
/* 245 */ "select", /* 245 */ "from",
/* 246 */ "column", /* 246 */ "where_opt",
/* 247 */ "tagitem1", /* 247 */ "interval_option",
/* 248 */ "tagitemlist", /* 248 */ "sliding_opt",
/* 249 */ "tagitem", /* 249 */ "session_option",
/* 250 */ "selcollist", /* 250 */ "windowstate_option",
/* 251 */ "from", /* 251 */ "fill_opt",
/* 252 */ "where_opt", /* 252 */ "groupby_opt",
/* 253 */ "interval_option", /* 253 */ "having_opt",
/* 254 */ "sliding_opt", /* 254 */ "orderby_opt",
/* 255 */ "session_option", /* 255 */ "slimit_opt",
/* 256 */ "windowstate_option", /* 256 */ "limit_opt",
/* 257 */ "fill_opt", /* 257 */ "union",
/* 258 */ "groupby_opt", /* 258 */ "sclp",
/* 259 */ "having_opt", /* 259 */ "distinct",
/* 260 */ "orderby_opt", /* 260 */ "expr",
/* 261 */ "slimit_opt", /* 261 */ "as",
/* 262 */ "limit_opt", /* 262 */ "tablelist",
/* 263 */ "union", /* 263 */ "sub",
/* 264 */ "sclp", /* 264 */ "tmvar",
/* 265 */ "distinct", /* 265 */ "intervalKey",
/* 266 */ "expr", /* 266 */ "sortlist",
/* 267 */ "as", /* 267 */ "sortitem",
/* 268 */ "tablelist", /* 268 */ "item",
/* 269 */ "sub", /* 269 */ "sortorder",
/* 270 */ "tmvar", /* 270 */ "grouplist",
/* 271 */ "intervalKey", /* 271 */ "expritem",
/* 272 */ "sortlist",
/* 273 */ "sortitem",
/* 274 */ "item",
/* 275 */ "sortorder",
/* 276 */ "grouplist",
/* 277 */ "expritem",
}; };
#endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
...@@ -1136,239 +1125,249 @@ static const char *const yyRuleName[] = { ...@@ -1136,239 +1125,249 @@ static const char *const yyRuleName[] = {
/* 55 */ "ifnotexists ::= IF NOT EXISTS", /* 55 */ "ifnotexists ::= IF NOT EXISTS",
/* 56 */ "ifnotexists ::=", /* 56 */ "ifnotexists ::=",
/* 57 */ "cmd ::= CREATE DNODE ids PORT ids", /* 57 */ "cmd ::= CREATE DNODE ids PORT ids",
/* 58 */ "cmd ::= CREATE ACCOUNT ids PASS ids acct_optr", /* 58 */ "cmd ::= CREATE DNODE IPTOKEN PORT ids",
/* 59 */ "cmd ::= CREATE DATABASE ifnotexists ids db_optr", /* 59 */ "cmd ::= CREATE ACCOUNT ids PASS ids acct_optr",
/* 60 */ "cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize", /* 60 */ "cmd ::= CREATE DATABASE ifnotexists ids db_optr",
/* 61 */ "cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize", /* 61 */ "cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize",
/* 62 */ "cmd ::= CREATE USER ids PASS ids", /* 62 */ "cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize",
/* 63 */ "bufsize ::=", /* 63 */ "cmd ::= CREATE USER ids PASS ids",
/* 64 */ "bufsize ::= BUFSIZE INTEGER", /* 64 */ "bufsize ::=",
/* 65 */ "pps ::=", /* 65 */ "bufsize ::= BUFSIZE INTEGER",
/* 66 */ "pps ::= PPS INTEGER", /* 66 */ "pps ::=",
/* 67 */ "tseries ::=", /* 67 */ "pps ::= PPS INTEGER",
/* 68 */ "tseries ::= TSERIES INTEGER", /* 68 */ "tseries ::=",
/* 69 */ "dbs ::=", /* 69 */ "tseries ::= TSERIES INTEGER",
/* 70 */ "dbs ::= DBS INTEGER", /* 70 */ "dbs ::=",
/* 71 */ "streams ::=", /* 71 */ "dbs ::= DBS INTEGER",
/* 72 */ "streams ::= STREAMS INTEGER", /* 72 */ "streams ::=",
/* 73 */ "storage ::=", /* 73 */ "streams ::= STREAMS INTEGER",
/* 74 */ "storage ::= STORAGE INTEGER", /* 74 */ "storage ::=",
/* 75 */ "qtime ::=", /* 75 */ "storage ::= STORAGE INTEGER",
/* 76 */ "qtime ::= QTIME INTEGER", /* 76 */ "qtime ::=",
/* 77 */ "users ::=", /* 77 */ "qtime ::= QTIME INTEGER",
/* 78 */ "users ::= USERS INTEGER", /* 78 */ "users ::=",
/* 79 */ "conns ::=", /* 79 */ "users ::= USERS INTEGER",
/* 80 */ "conns ::= CONNS INTEGER", /* 80 */ "conns ::=",
/* 81 */ "state ::=", /* 81 */ "conns ::= CONNS INTEGER",
/* 82 */ "state ::= STATE ids", /* 82 */ "state ::=",
/* 83 */ "acct_optr ::= pps tseries storage streams qtime dbs users conns state", /* 83 */ "state ::= STATE ids",
/* 84 */ "intitemlist ::= intitemlist COMMA intitem", /* 84 */ "acct_optr ::= pps tseries storage streams qtime dbs users conns state",
/* 85 */ "intitemlist ::= intitem", /* 85 */ "intitemlist ::= intitemlist COMMA intitem",
/* 86 */ "intitem ::= INTEGER", /* 86 */ "intitemlist ::= intitem",
/* 87 */ "keep ::= KEEP intitemlist", /* 87 */ "intitem ::= INTEGER",
/* 88 */ "cache ::= CACHE INTEGER", /* 88 */ "keep ::= KEEP intitemlist",
/* 89 */ "replica ::= REPLICA INTEGER", /* 89 */ "cache ::= CACHE INTEGER",
/* 90 */ "quorum ::= QUORUM INTEGER", /* 90 */ "replica ::= REPLICA INTEGER",
/* 91 */ "days ::= DAYS INTEGER", /* 91 */ "quorum ::= QUORUM INTEGER",
/* 92 */ "minrows ::= MINROWS INTEGER", /* 92 */ "days ::= DAYS INTEGER",
/* 93 */ "maxrows ::= MAXROWS INTEGER", /* 93 */ "minrows ::= MINROWS INTEGER",
/* 94 */ "blocks ::= BLOCKS INTEGER", /* 94 */ "maxrows ::= MAXROWS INTEGER",
/* 95 */ "ctime ::= CTIME INTEGER", /* 95 */ "blocks ::= BLOCKS INTEGER",
/* 96 */ "wal ::= WAL INTEGER", /* 96 */ "ctime ::= CTIME INTEGER",
/* 97 */ "fsync ::= FSYNC INTEGER", /* 97 */ "wal ::= WAL INTEGER",
/* 98 */ "comp ::= COMP INTEGER", /* 98 */ "fsync ::= FSYNC INTEGER",
/* 99 */ "prec ::= PRECISION STRING", /* 99 */ "comp ::= COMP INTEGER",
/* 100 */ "update ::= UPDATE INTEGER", /* 100 */ "prec ::= PRECISION STRING",
/* 101 */ "cachelast ::= CACHELAST INTEGER", /* 101 */ "update ::= UPDATE INTEGER",
/* 102 */ "db_optr ::=", /* 102 */ "cachelast ::= CACHELAST INTEGER",
/* 103 */ "db_optr ::= db_optr cache", /* 103 */ "db_optr ::=",
/* 104 */ "db_optr ::= db_optr replica", /* 104 */ "db_optr ::= db_optr cache",
/* 105 */ "db_optr ::= db_optr quorum", /* 105 */ "db_optr ::= db_optr replica",
/* 106 */ "db_optr ::= db_optr days", /* 106 */ "db_optr ::= db_optr quorum",
/* 107 */ "db_optr ::= db_optr minrows", /* 107 */ "db_optr ::= db_optr days",
/* 108 */ "db_optr ::= db_optr maxrows", /* 108 */ "db_optr ::= db_optr minrows",
/* 109 */ "db_optr ::= db_optr blocks", /* 109 */ "db_optr ::= db_optr maxrows",
/* 110 */ "db_optr ::= db_optr ctime", /* 110 */ "db_optr ::= db_optr blocks",
/* 111 */ "db_optr ::= db_optr wal", /* 111 */ "db_optr ::= db_optr ctime",
/* 112 */ "db_optr ::= db_optr fsync", /* 112 */ "db_optr ::= db_optr wal",
/* 113 */ "db_optr ::= db_optr comp", /* 113 */ "db_optr ::= db_optr fsync",
/* 114 */ "db_optr ::= db_optr prec", /* 114 */ "db_optr ::= db_optr comp",
/* 115 */ "db_optr ::= db_optr keep", /* 115 */ "db_optr ::= db_optr prec",
/* 116 */ "db_optr ::= db_optr update", /* 116 */ "db_optr ::= db_optr keep",
/* 117 */ "db_optr ::= db_optr cachelast", /* 117 */ "db_optr ::= db_optr update",
/* 118 */ "alter_db_optr ::=", /* 118 */ "db_optr ::= db_optr cachelast",
/* 119 */ "alter_db_optr ::= alter_db_optr replica", /* 119 */ "alter_db_optr ::=",
/* 120 */ "alter_db_optr ::= alter_db_optr quorum", /* 120 */ "alter_db_optr ::= alter_db_optr replica",
/* 121 */ "alter_db_optr ::= alter_db_optr keep", /* 121 */ "alter_db_optr ::= alter_db_optr quorum",
/* 122 */ "alter_db_optr ::= alter_db_optr blocks", /* 122 */ "alter_db_optr ::= alter_db_optr keep",
/* 123 */ "alter_db_optr ::= alter_db_optr comp", /* 123 */ "alter_db_optr ::= alter_db_optr blocks",
/* 124 */ "alter_db_optr ::= alter_db_optr update", /* 124 */ "alter_db_optr ::= alter_db_optr comp",
/* 125 */ "alter_db_optr ::= alter_db_optr cachelast", /* 125 */ "alter_db_optr ::= alter_db_optr update",
/* 126 */ "typename ::= ids", /* 126 */ "alter_db_optr ::= alter_db_optr cachelast",
/* 127 */ "typename ::= ids LP signed RP", /* 127 */ "typename ::= ids",
/* 128 */ "typename ::= ids UNSIGNED", /* 128 */ "typename ::= ids LP signed RP",
/* 129 */ "signed ::= INTEGER", /* 129 */ "typename ::= ids UNSIGNED",
/* 130 */ "signed ::= PLUS INTEGER", /* 130 */ "signed ::= INTEGER",
/* 131 */ "signed ::= MINUS INTEGER", /* 131 */ "signed ::= PLUS INTEGER",
/* 132 */ "cmd ::= CREATE TABLE create_table_args", /* 132 */ "signed ::= MINUS INTEGER",
/* 133 */ "cmd ::= CREATE TABLE create_stable_args", /* 133 */ "cmd ::= CREATE TABLE create_table_args",
/* 134 */ "cmd ::= CREATE STABLE create_stable_args", /* 134 */ "cmd ::= CREATE TABLE create_stable_args",
/* 135 */ "cmd ::= CREATE TABLE create_table_list", /* 135 */ "cmd ::= CREATE STABLE create_stable_args",
/* 136 */ "create_table_list ::= create_from_stable", /* 136 */ "cmd ::= CREATE TABLE create_table_list",
/* 137 */ "create_table_list ::= create_table_list create_from_stable", /* 137 */ "create_table_list ::= create_from_stable",
/* 138 */ "create_table_args ::= ifnotexists ids cpxName LP columnlist RP", /* 138 */ "create_table_list ::= create_table_list create_from_stable",
/* 139 */ "create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP", /* 139 */ "create_table_args ::= ifnotexists ids cpxName LP columnlist RP",
/* 140 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist1 RP", /* 140 */ "create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP",
/* 141 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist1 RP", /* 141 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist1 RP",
/* 142 */ "tagNamelist ::= tagNamelist COMMA ids", /* 142 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist1 RP",
/* 143 */ "tagNamelist ::= ids", /* 143 */ "tagNamelist ::= tagNamelist COMMA ids",
/* 144 */ "create_table_args ::= ifnotexists ids cpxName AS select", /* 144 */ "tagNamelist ::= ids",
/* 145 */ "columnlist ::= columnlist COMMA column", /* 145 */ "create_table_args ::= ifnotexists ids cpxName AS select",
/* 146 */ "columnlist ::= column", /* 146 */ "columnlist ::= columnlist COMMA column",
/* 147 */ "column ::= ids typename", /* 147 */ "columnlist ::= column",
/* 148 */ "tagitemlist1 ::= tagitemlist1 COMMA tagitem1", /* 148 */ "column ::= ids typename",
/* 149 */ "tagitemlist1 ::= tagitem1", /* 149 */ "tagitemlist1 ::= tagitemlist1 COMMA tagitem1",
/* 150 */ "tagitem1 ::= MINUS INTEGER", /* 150 */ "tagitemlist1 ::= tagitem1",
/* 151 */ "tagitemlist ::= tagitemlist COMMA tagitem", /* 151 */ "tagitem1 ::= MINUS INTEGER",
/* 152 */ "tagitemlist ::= tagitem", /* 152 */ "tagitem1 ::= MINUS FLOAT",
/* 153 */ "tagitem ::= INTEGER", /* 153 */ "tagitem1 ::= PLUS INTEGER",
/* 154 */ "tagitem ::= FLOAT", /* 154 */ "tagitem1 ::= PLUS FLOAT",
/* 155 */ "tagitem ::= STRING", /* 155 */ "tagitem1 ::= INTEGER",
/* 156 */ "tagitem ::= BOOL", /* 156 */ "tagitem1 ::= FLOAT",
/* 157 */ "tagitem ::= NULL", /* 157 */ "tagitem1 ::= STRING",
/* 158 */ "tagitem ::= NOW", /* 158 */ "tagitem1 ::= BOOL",
/* 159 */ "tagitem ::= MINUS INTEGER", /* 159 */ "tagitem1 ::= NULL",
/* 160 */ "tagitem ::= MINUS FLOAT", /* 160 */ "tagitem1 ::= NOW",
/* 161 */ "tagitem ::= PLUS INTEGER", /* 161 */ "tagitemlist ::= tagitemlist COMMA tagitem",
/* 162 */ "tagitem ::= PLUS FLOAT", /* 162 */ "tagitemlist ::= tagitem",
/* 163 */ "select ::= SELECT selcollist from where_opt interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt", /* 163 */ "tagitem ::= INTEGER",
/* 164 */ "select ::= LP select RP", /* 164 */ "tagitem ::= FLOAT",
/* 165 */ "union ::= select", /* 165 */ "tagitem ::= STRING",
/* 166 */ "union ::= union UNION ALL select", /* 166 */ "tagitem ::= BOOL",
/* 167 */ "union ::= union UNION select", /* 167 */ "tagitem ::= NULL",
/* 168 */ "cmd ::= union", /* 168 */ "tagitem ::= NOW",
/* 169 */ "select ::= SELECT selcollist", /* 169 */ "tagitem ::= MINUS INTEGER",
/* 170 */ "sclp ::= selcollist COMMA", /* 170 */ "tagitem ::= MINUS FLOAT",
/* 171 */ "sclp ::=", /* 171 */ "tagitem ::= PLUS INTEGER",
/* 172 */ "selcollist ::= sclp distinct expr as", /* 172 */ "tagitem ::= PLUS FLOAT",
/* 173 */ "selcollist ::= sclp STAR", /* 173 */ "select ::= SELECT selcollist from where_opt interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt",
/* 174 */ "as ::= AS ids", /* 174 */ "select ::= LP select RP",
/* 175 */ "as ::= ids", /* 175 */ "union ::= select",
/* 176 */ "as ::=", /* 176 */ "union ::= union UNION ALL select",
/* 177 */ "distinct ::= DISTINCT", /* 177 */ "union ::= union UNION select",
/* 178 */ "distinct ::=", /* 178 */ "cmd ::= union",
/* 179 */ "from ::= FROM tablelist", /* 179 */ "select ::= SELECT selcollist",
/* 180 */ "from ::= FROM sub", /* 180 */ "sclp ::= selcollist COMMA",
/* 181 */ "sub ::= LP union RP", /* 181 */ "sclp ::=",
/* 182 */ "sub ::= LP union RP ids", /* 182 */ "selcollist ::= sclp distinct expr as",
/* 183 */ "sub ::= sub COMMA LP union RP ids", /* 183 */ "selcollist ::= sclp STAR",
/* 184 */ "tablelist ::= ids cpxName", /* 184 */ "as ::= AS ids",
/* 185 */ "tablelist ::= ids cpxName ids", /* 185 */ "as ::= ids",
/* 186 */ "tablelist ::= tablelist COMMA ids cpxName", /* 186 */ "as ::=",
/* 187 */ "tablelist ::= tablelist COMMA ids cpxName ids", /* 187 */ "distinct ::= DISTINCT",
/* 188 */ "tmvar ::= VARIABLE", /* 188 */ "distinct ::=",
/* 189 */ "interval_option ::= intervalKey LP tmvar RP", /* 189 */ "from ::= FROM tablelist",
/* 190 */ "interval_option ::= intervalKey LP tmvar COMMA tmvar RP", /* 190 */ "from ::= FROM sub",
/* 191 */ "interval_option ::=", /* 191 */ "sub ::= LP union RP",
/* 192 */ "intervalKey ::= INTERVAL", /* 192 */ "sub ::= LP union RP ids",
/* 193 */ "intervalKey ::= EVERY", /* 193 */ "sub ::= sub COMMA LP union RP ids",
/* 194 */ "session_option ::=", /* 194 */ "tablelist ::= ids cpxName",
/* 195 */ "session_option ::= SESSION LP ids cpxName COMMA tmvar RP", /* 195 */ "tablelist ::= ids cpxName ids",
/* 196 */ "windowstate_option ::=", /* 196 */ "tablelist ::= tablelist COMMA ids cpxName",
/* 197 */ "windowstate_option ::= STATE_WINDOW LP ids RP", /* 197 */ "tablelist ::= tablelist COMMA ids cpxName ids",
/* 198 */ "fill_opt ::=", /* 198 */ "tmvar ::= VARIABLE",
/* 199 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP", /* 199 */ "interval_option ::= intervalKey LP tmvar RP",
/* 200 */ "fill_opt ::= FILL LP ID RP", /* 200 */ "interval_option ::= intervalKey LP tmvar COMMA tmvar RP",
/* 201 */ "sliding_opt ::= SLIDING LP tmvar RP", /* 201 */ "interval_option ::=",
/* 202 */ "sliding_opt ::=", /* 202 */ "intervalKey ::= INTERVAL",
/* 203 */ "orderby_opt ::=", /* 203 */ "intervalKey ::= EVERY",
/* 204 */ "orderby_opt ::= ORDER BY sortlist", /* 204 */ "session_option ::=",
/* 205 */ "sortlist ::= sortlist COMMA item sortorder", /* 205 */ "session_option ::= SESSION LP ids cpxName COMMA tmvar RP",
/* 206 */ "sortlist ::= item sortorder", /* 206 */ "windowstate_option ::=",
/* 207 */ "item ::= ids cpxName", /* 207 */ "windowstate_option ::= STATE_WINDOW LP ids RP",
/* 208 */ "sortorder ::= ASC", /* 208 */ "fill_opt ::=",
/* 209 */ "sortorder ::= DESC", /* 209 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP",
/* 210 */ "sortorder ::=", /* 210 */ "fill_opt ::= FILL LP ID RP",
/* 211 */ "groupby_opt ::=", /* 211 */ "sliding_opt ::= SLIDING LP tmvar RP",
/* 212 */ "groupby_opt ::= GROUP BY grouplist", /* 212 */ "sliding_opt ::=",
/* 213 */ "grouplist ::= grouplist COMMA item", /* 213 */ "orderby_opt ::=",
/* 214 */ "grouplist ::= item", /* 214 */ "orderby_opt ::= ORDER BY sortlist",
/* 215 */ "having_opt ::=", /* 215 */ "sortlist ::= sortlist COMMA item sortorder",
/* 216 */ "having_opt ::= HAVING expr", /* 216 */ "sortlist ::= item sortorder",
/* 217 */ "limit_opt ::=", /* 217 */ "item ::= ids cpxName",
/* 218 */ "limit_opt ::= LIMIT signed", /* 218 */ "sortorder ::= ASC",
/* 219 */ "limit_opt ::= LIMIT signed OFFSET signed", /* 219 */ "sortorder ::= DESC",
/* 220 */ "limit_opt ::= LIMIT signed COMMA signed", /* 220 */ "sortorder ::=",
/* 221 */ "slimit_opt ::=", /* 221 */ "groupby_opt ::=",
/* 222 */ "slimit_opt ::= SLIMIT signed", /* 222 */ "groupby_opt ::= GROUP BY grouplist",
/* 223 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", /* 223 */ "grouplist ::= grouplist COMMA item",
/* 224 */ "slimit_opt ::= SLIMIT signed COMMA signed", /* 224 */ "grouplist ::= item",
/* 225 */ "where_opt ::=", /* 225 */ "having_opt ::=",
/* 226 */ "where_opt ::= WHERE expr", /* 226 */ "having_opt ::= HAVING expr",
/* 227 */ "expr ::= LP expr RP", /* 227 */ "limit_opt ::=",
/* 228 */ "expr ::= ID", /* 228 */ "limit_opt ::= LIMIT signed",
/* 229 */ "expr ::= ID DOT ID", /* 229 */ "limit_opt ::= LIMIT signed OFFSET signed",
/* 230 */ "expr ::= ID DOT STAR", /* 230 */ "limit_opt ::= LIMIT signed COMMA signed",
/* 231 */ "expr ::= INTEGER", /* 231 */ "slimit_opt ::=",
/* 232 */ "expr ::= MINUS INTEGER", /* 232 */ "slimit_opt ::= SLIMIT signed",
/* 233 */ "expr ::= PLUS INTEGER", /* 233 */ "slimit_opt ::= SLIMIT signed SOFFSET signed",
/* 234 */ "expr ::= FLOAT", /* 234 */ "slimit_opt ::= SLIMIT signed COMMA signed",
/* 235 */ "expr ::= MINUS FLOAT", /* 235 */ "where_opt ::=",
/* 236 */ "expr ::= PLUS FLOAT", /* 236 */ "where_opt ::= WHERE expr",
/* 237 */ "expr ::= STRING", /* 237 */ "expr ::= LP expr RP",
/* 238 */ "expr ::= NOW", /* 238 */ "expr ::= ID",
/* 239 */ "expr ::= VARIABLE", /* 239 */ "expr ::= ID DOT ID",
/* 240 */ "expr ::= PLUS VARIABLE", /* 240 */ "expr ::= ID DOT STAR",
/* 241 */ "expr ::= MINUS VARIABLE", /* 241 */ "expr ::= INTEGER",
/* 242 */ "expr ::= BOOL", /* 242 */ "expr ::= MINUS INTEGER",
/* 243 */ "expr ::= NULL", /* 243 */ "expr ::= PLUS INTEGER",
/* 244 */ "expr ::= ID LP exprlist RP", /* 244 */ "expr ::= FLOAT",
/* 245 */ "expr ::= ID LP STAR RP", /* 245 */ "expr ::= MINUS FLOAT",
/* 246 */ "expr ::= expr IS NULL", /* 246 */ "expr ::= PLUS FLOAT",
/* 247 */ "expr ::= expr IS NOT NULL", /* 247 */ "expr ::= STRING",
/* 248 */ "expr ::= expr LT expr", /* 248 */ "expr ::= NOW",
/* 249 */ "expr ::= expr GT expr", /* 249 */ "expr ::= VARIABLE",
/* 250 */ "expr ::= expr LE expr", /* 250 */ "expr ::= PLUS VARIABLE",
/* 251 */ "expr ::= expr GE expr", /* 251 */ "expr ::= MINUS VARIABLE",
/* 252 */ "expr ::= expr NE expr", /* 252 */ "expr ::= BOOL",
/* 253 */ "expr ::= expr EQ expr", /* 253 */ "expr ::= NULL",
/* 254 */ "expr ::= expr BETWEEN expr AND expr", /* 254 */ "expr ::= ID LP exprlist RP",
/* 255 */ "expr ::= expr AND expr", /* 255 */ "expr ::= ID LP STAR RP",
/* 256 */ "expr ::= expr OR expr", /* 256 */ "expr ::= expr IS NULL",
/* 257 */ "expr ::= expr PLUS expr", /* 257 */ "expr ::= expr IS NOT NULL",
/* 258 */ "expr ::= expr MINUS expr", /* 258 */ "expr ::= expr LT expr",
/* 259 */ "expr ::= expr STAR expr", /* 259 */ "expr ::= expr GT expr",
/* 260 */ "expr ::= expr SLASH expr", /* 260 */ "expr ::= expr LE expr",
/* 261 */ "expr ::= expr REM expr", /* 261 */ "expr ::= expr GE expr",
/* 262 */ "expr ::= expr LIKE expr", /* 262 */ "expr ::= expr NE expr",
/* 263 */ "expr ::= expr MATCH expr", /* 263 */ "expr ::= expr EQ expr",
/* 264 */ "expr ::= expr NMATCH expr", /* 264 */ "expr ::= expr BETWEEN expr AND expr",
/* 265 */ "expr ::= expr IN LP exprlist RP", /* 265 */ "expr ::= expr AND expr",
/* 266 */ "exprlist ::= exprlist COMMA expritem", /* 266 */ "expr ::= expr OR expr",
/* 267 */ "exprlist ::= expritem", /* 267 */ "expr ::= expr PLUS expr",
/* 268 */ "expritem ::= expr", /* 268 */ "expr ::= expr MINUS expr",
/* 269 */ "expritem ::=", /* 269 */ "expr ::= expr STAR expr",
/* 270 */ "cmd ::= RESET QUERY CACHE", /* 270 */ "expr ::= expr SLASH expr",
/* 271 */ "cmd ::= SYNCDB ids REPLICA", /* 271 */ "expr ::= expr REM expr",
/* 272 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", /* 272 */ "expr ::= expr LIKE expr",
/* 273 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", /* 273 */ "expr ::= expr MATCH expr",
/* 274 */ "cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist", /* 274 */ "expr ::= expr NMATCH expr",
/* 275 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", /* 275 */ "expr ::= expr IN LP exprlist RP",
/* 276 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", /* 276 */ "exprlist ::= exprlist COMMA expritem",
/* 277 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", /* 277 */ "exprlist ::= expritem",
/* 278 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", /* 278 */ "expritem ::= expr",
/* 279 */ "cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist", /* 279 */ "expritem ::=",
/* 280 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist", /* 280 */ "cmd ::= RESET QUERY CACHE",
/* 281 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids", /* 281 */ "cmd ::= SYNCDB ids REPLICA",
/* 282 */ "cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist", /* 282 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist",
/* 283 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist", /* 283 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids",
/* 284 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids", /* 284 */ "cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist",
/* 285 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids", /* 285 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist",
/* 286 */ "cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem", /* 286 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids",
/* 287 */ "cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist", /* 287 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids",
/* 288 */ "cmd ::= KILL CONNECTION INTEGER", /* 288 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem",
/* 289 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", /* 289 */ "cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist",
/* 290 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", /* 290 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist",
/* 291 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids",
/* 292 */ "cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist",
/* 293 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist",
/* 294 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids",
/* 295 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids",
/* 296 */ "cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem",
/* 297 */ "cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist",
/* 298 */ "cmd ::= KILL CONNECTION INTEGER",
/* 299 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER",
/* 300 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER",
}; };
#endif /* NDEBUG */ #endif /* NDEBUG */
...@@ -1489,61 +1488,61 @@ static void yy_destructor( ...@@ -1489,61 +1488,61 @@ static void yy_destructor(
** inside the C code. ** inside the C code.
*/ */
/********* Begin destructor definitions ***************************************/ /********* Begin destructor definitions ***************************************/
case 206: /* exprlist */ case 200: /* exprlist */
case 250: /* selcollist */ case 244: /* selcollist */
case 264: /* sclp */ case 258: /* sclp */
{ {
tSqlExprListDestroy((yypminor->yy421)); tSqlExprListDestroy((yypminor->yy413));
} }
break; break;
case 220: /* intitemlist */ case 214: /* intitemlist */
case 222: /* keep */ case 216: /* keep */
case 242: /* columnlist */ case 236: /* columnlist */
case 243: /* tagitemlist1 */ case 237: /* tagitemlist1 */
case 244: /* tagNamelist */ case 238: /* tagNamelist */
case 248: /* tagitemlist */ case 242: /* tagitemlist */
case 257: /* fill_opt */ case 251: /* fill_opt */
case 258: /* groupby_opt */ case 252: /* groupby_opt */
case 260: /* orderby_opt */ case 254: /* orderby_opt */
case 272: /* sortlist */ case 266: /* sortlist */
case 276: /* grouplist */ case 270: /* grouplist */
{ {
taosArrayDestroy((yypminor->yy421)); taosArrayDestroy((yypminor->yy413));
} }
break; break;
case 240: /* create_table_list */ case 234: /* create_table_list */
{ {
destroyCreateTableSql((yypminor->yy438)); destroyCreateTableSql((yypminor->yy438));
} }
break; break;
case 245: /* select */ case 239: /* select */
{ {
destroySqlNode((yypminor->yy56)); destroySqlNode((yypminor->yy24));
} }
break; break;
case 251: /* from */ case 245: /* from */
case 268: /* tablelist */ case 262: /* tablelist */
case 269: /* sub */ case 263: /* sub */
{ {
destroyRelationInfo((yypminor->yy8)); destroyRelationInfo((yypminor->yy292));
} }
break; break;
case 252: /* where_opt */ case 246: /* where_opt */
case 259: /* having_opt */ case 253: /* having_opt */
case 266: /* expr */ case 260: /* expr */
case 277: /* expritem */ case 271: /* expritem */
{ {
tSqlExprDestroy((yypminor->yy439)); tSqlExprDestroy((yypminor->yy370));
} }
break; break;
case 263: /* union */ case 257: /* union */
{ {
destroyAllSqlNode((yypminor->yy149)); destroyAllSqlNode((yypminor->yy129));
} }
break; break;
case 273: /* sortitem */ case 267: /* sortitem */
{ {
taosVariantDestroy(&(yypminor->yy69)); taosVariantDestroy(&(yypminor->yy461));
} }
break; break;
/********* End destructor definitions *****************************************/ /********* End destructor definitions *****************************************/
...@@ -1837,297 +1836,307 @@ static const struct { ...@@ -1837,297 +1836,307 @@ static const struct {
YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
signed char nrhs; /* Negative of the number of RHS symbols in the rule */ signed char nrhs; /* Negative of the number of RHS symbols in the rule */
} yyRuleInfo[] = { } yyRuleInfo[] = {
{ 198, -1 }, /* (0) program ::= cmd */ { 192, -1 }, /* (0) program ::= cmd */
{ 199, -2 }, /* (1) cmd ::= SHOW DATABASES */ { 193, -2 }, /* (1) cmd ::= SHOW DATABASES */
{ 199, -2 }, /* (2) cmd ::= SHOW TOPICS */ { 193, -2 }, /* (2) cmd ::= SHOW TOPICS */
{ 199, -2 }, /* (3) cmd ::= SHOW FUNCTIONS */ { 193, -2 }, /* (3) cmd ::= SHOW FUNCTIONS */
{ 199, -2 }, /* (4) cmd ::= SHOW MNODES */ { 193, -2 }, /* (4) cmd ::= SHOW MNODES */
{ 199, -2 }, /* (5) cmd ::= SHOW DNODES */ { 193, -2 }, /* (5) cmd ::= SHOW DNODES */
{ 199, -2 }, /* (6) cmd ::= SHOW ACCOUNTS */ { 193, -2 }, /* (6) cmd ::= SHOW ACCOUNTS */
{ 199, -2 }, /* (7) cmd ::= SHOW USERS */ { 193, -2 }, /* (7) cmd ::= SHOW USERS */
{ 199, -2 }, /* (8) cmd ::= SHOW MODULES */ { 193, -2 }, /* (8) cmd ::= SHOW MODULES */
{ 199, -2 }, /* (9) cmd ::= SHOW QUERIES */ { 193, -2 }, /* (9) cmd ::= SHOW QUERIES */
{ 199, -2 }, /* (10) cmd ::= SHOW CONNECTIONS */ { 193, -2 }, /* (10) cmd ::= SHOW CONNECTIONS */
{ 199, -2 }, /* (11) cmd ::= SHOW STREAMS */ { 193, -2 }, /* (11) cmd ::= SHOW STREAMS */
{ 199, -2 }, /* (12) cmd ::= SHOW VARIABLES */ { 193, -2 }, /* (12) cmd ::= SHOW VARIABLES */
{ 199, -2 }, /* (13) cmd ::= SHOW SCORES */ { 193, -2 }, /* (13) cmd ::= SHOW SCORES */
{ 199, -2 }, /* (14) cmd ::= SHOW GRANTS */ { 193, -2 }, /* (14) cmd ::= SHOW GRANTS */
{ 199, -2 }, /* (15) cmd ::= SHOW VNODES */ { 193, -2 }, /* (15) cmd ::= SHOW VNODES */
{ 199, -3 }, /* (16) cmd ::= SHOW VNODES ids */ { 193, -3 }, /* (16) cmd ::= SHOW VNODES ids */
{ 201, 0 }, /* (17) dbPrefix ::= */ { 195, 0 }, /* (17) dbPrefix ::= */
{ 201, -2 }, /* (18) dbPrefix ::= ids DOT */ { 195, -2 }, /* (18) dbPrefix ::= ids DOT */
{ 202, 0 }, /* (19) cpxName ::= */ { 196, 0 }, /* (19) cpxName ::= */
{ 202, -2 }, /* (20) cpxName ::= DOT ids */ { 196, -2 }, /* (20) cpxName ::= DOT ids */
{ 199, -5 }, /* (21) cmd ::= SHOW CREATE TABLE ids cpxName */ { 193, -5 }, /* (21) cmd ::= SHOW CREATE TABLE ids cpxName */
{ 199, -5 }, /* (22) cmd ::= SHOW CREATE STABLE ids cpxName */ { 193, -5 }, /* (22) cmd ::= SHOW CREATE STABLE ids cpxName */
{ 199, -4 }, /* (23) cmd ::= SHOW CREATE DATABASE ids */ { 193, -4 }, /* (23) cmd ::= SHOW CREATE DATABASE ids */
{ 199, -3 }, /* (24) cmd ::= SHOW dbPrefix TABLES */ { 193, -3 }, /* (24) cmd ::= SHOW dbPrefix TABLES */
{ 199, -5 }, /* (25) cmd ::= SHOW dbPrefix TABLES LIKE ids */ { 193, -5 }, /* (25) cmd ::= SHOW dbPrefix TABLES LIKE ids */
{ 199, -3 }, /* (26) cmd ::= SHOW dbPrefix STABLES */ { 193, -3 }, /* (26) cmd ::= SHOW dbPrefix STABLES */
{ 199, -5 }, /* (27) cmd ::= SHOW dbPrefix STABLES LIKE ids */ { 193, -5 }, /* (27) cmd ::= SHOW dbPrefix STABLES LIKE ids */
{ 199, -3 }, /* (28) cmd ::= SHOW dbPrefix VGROUPS */ { 193, -3 }, /* (28) cmd ::= SHOW dbPrefix VGROUPS */
{ 199, -4 }, /* (29) cmd ::= SHOW dbPrefix VGROUPS ids */ { 193, -4 }, /* (29) cmd ::= SHOW dbPrefix VGROUPS ids */
{ 199, -5 }, /* (30) cmd ::= DROP TABLE ifexists ids cpxName */ { 193, -5 }, /* (30) cmd ::= DROP TABLE ifexists ids cpxName */
{ 199, -5 }, /* (31) cmd ::= DROP STABLE ifexists ids cpxName */ { 193, -5 }, /* (31) cmd ::= DROP STABLE ifexists ids cpxName */
{ 199, -4 }, /* (32) cmd ::= DROP DATABASE ifexists ids */ { 193, -4 }, /* (32) cmd ::= DROP DATABASE ifexists ids */
{ 199, -4 }, /* (33) cmd ::= DROP TOPIC ifexists ids */ { 193, -4 }, /* (33) cmd ::= DROP TOPIC ifexists ids */
{ 199, -3 }, /* (34) cmd ::= DROP FUNCTION ids */ { 193, -3 }, /* (34) cmd ::= DROP FUNCTION ids */
{ 199, -3 }, /* (35) cmd ::= DROP DNODE ids */ { 193, -3 }, /* (35) cmd ::= DROP DNODE ids */
{ 199, -3 }, /* (36) cmd ::= DROP USER ids */ { 193, -3 }, /* (36) cmd ::= DROP USER ids */
{ 199, -3 }, /* (37) cmd ::= DROP ACCOUNT ids */ { 193, -3 }, /* (37) cmd ::= DROP ACCOUNT ids */
{ 199, -2 }, /* (38) cmd ::= USE ids */ { 193, -2 }, /* (38) cmd ::= USE ids */
{ 199, -3 }, /* (39) cmd ::= DESCRIBE ids cpxName */ { 193, -3 }, /* (39) cmd ::= DESCRIBE ids cpxName */
{ 199, -3 }, /* (40) cmd ::= DESC ids cpxName */ { 193, -3 }, /* (40) cmd ::= DESC ids cpxName */
{ 199, -5 }, /* (41) cmd ::= ALTER USER ids PASS ids */ { 193, -5 }, /* (41) cmd ::= ALTER USER ids PASS ids */
{ 199, -5 }, /* (42) cmd ::= ALTER USER ids PRIVILEGE ids */ { 193, -5 }, /* (42) cmd ::= ALTER USER ids PRIVILEGE ids */
{ 199, -4 }, /* (43) cmd ::= ALTER DNODE ids ids */ { 193, -4 }, /* (43) cmd ::= ALTER DNODE ids ids */
{ 199, -5 }, /* (44) cmd ::= ALTER DNODE ids ids ids */ { 193, -5 }, /* (44) cmd ::= ALTER DNODE ids ids ids */
{ 199, -3 }, /* (45) cmd ::= ALTER LOCAL ids */ { 193, -3 }, /* (45) cmd ::= ALTER LOCAL ids */
{ 199, -4 }, /* (46) cmd ::= ALTER LOCAL ids ids */ { 193, -4 }, /* (46) cmd ::= ALTER LOCAL ids ids */
{ 199, -4 }, /* (47) cmd ::= ALTER DATABASE ids alter_db_optr */ { 193, -4 }, /* (47) cmd ::= ALTER DATABASE ids alter_db_optr */
{ 199, -4 }, /* (48) cmd ::= ALTER ACCOUNT ids acct_optr */ { 193, -4 }, /* (48) cmd ::= ALTER ACCOUNT ids acct_optr */
{ 199, -6 }, /* (49) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ { 193, -6 }, /* (49) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */
{ 199, -6 }, /* (50) cmd ::= COMPACT VNODES IN LP exprlist RP */ { 193, -6 }, /* (50) cmd ::= COMPACT VNODES IN LP exprlist RP */
{ 200, -1 }, /* (51) ids ::= ID */ { 194, -1 }, /* (51) ids ::= ID */
{ 200, -1 }, /* (52) ids ::= STRING */ { 194, -1 }, /* (52) ids ::= STRING */
{ 203, -2 }, /* (53) ifexists ::= IF EXISTS */ { 197, -2 }, /* (53) ifexists ::= IF EXISTS */
{ 203, 0 }, /* (54) ifexists ::= */ { 197, 0 }, /* (54) ifexists ::= */
{ 207, -3 }, /* (55) ifnotexists ::= IF NOT EXISTS */ { 201, -3 }, /* (55) ifnotexists ::= IF NOT EXISTS */
{ 207, 0 }, /* (56) ifnotexists ::= */ { 201, 0 }, /* (56) ifnotexists ::= */
{ 199, -5 }, /* (57) cmd ::= CREATE DNODE ids PORT ids */ { 193, -5 }, /* (57) cmd ::= CREATE DNODE ids PORT ids */
{ 199, -6 }, /* (58) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ { 193, -5 }, /* (58) cmd ::= CREATE DNODE IPTOKEN PORT ids */
{ 199, -5 }, /* (59) cmd ::= CREATE DATABASE ifnotexists ids db_optr */ { 193, -6 }, /* (59) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */
{ 199, -8 }, /* (60) cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ { 193, -5 }, /* (60) cmd ::= CREATE DATABASE ifnotexists ids db_optr */
{ 199, -9 }, /* (61) cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ { 193, -8 }, /* (61) cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */
{ 199, -5 }, /* (62) cmd ::= CREATE USER ids PASS ids */ { 193, -9 }, /* (62) cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */
{ 210, 0 }, /* (63) bufsize ::= */ { 193, -5 }, /* (63) cmd ::= CREATE USER ids PASS ids */
{ 210, -2 }, /* (64) bufsize ::= BUFSIZE INTEGER */ { 204, 0 }, /* (64) bufsize ::= */
{ 211, 0 }, /* (65) pps ::= */ { 204, -2 }, /* (65) bufsize ::= BUFSIZE INTEGER */
{ 211, -2 }, /* (66) pps ::= PPS INTEGER */ { 205, 0 }, /* (66) pps ::= */
{ 212, 0 }, /* (67) tseries ::= */ { 205, -2 }, /* (67) pps ::= PPS INTEGER */
{ 212, -2 }, /* (68) tseries ::= TSERIES INTEGER */ { 206, 0 }, /* (68) tseries ::= */
{ 213, 0 }, /* (69) dbs ::= */ { 206, -2 }, /* (69) tseries ::= TSERIES INTEGER */
{ 213, -2 }, /* (70) dbs ::= DBS INTEGER */ { 207, 0 }, /* (70) dbs ::= */
{ 214, 0 }, /* (71) streams ::= */ { 207, -2 }, /* (71) dbs ::= DBS INTEGER */
{ 214, -2 }, /* (72) streams ::= STREAMS INTEGER */ { 208, 0 }, /* (72) streams ::= */
{ 215, 0 }, /* (73) storage ::= */ { 208, -2 }, /* (73) streams ::= STREAMS INTEGER */
{ 215, -2 }, /* (74) storage ::= STORAGE INTEGER */ { 209, 0 }, /* (74) storage ::= */
{ 216, 0 }, /* (75) qtime ::= */ { 209, -2 }, /* (75) storage ::= STORAGE INTEGER */
{ 216, -2 }, /* (76) qtime ::= QTIME INTEGER */ { 210, 0 }, /* (76) qtime ::= */
{ 217, 0 }, /* (77) users ::= */ { 210, -2 }, /* (77) qtime ::= QTIME INTEGER */
{ 217, -2 }, /* (78) users ::= USERS INTEGER */ { 211, 0 }, /* (78) users ::= */
{ 218, 0 }, /* (79) conns ::= */ { 211, -2 }, /* (79) users ::= USERS INTEGER */
{ 218, -2 }, /* (80) conns ::= CONNS INTEGER */ { 212, 0 }, /* (80) conns ::= */
{ 219, 0 }, /* (81) state ::= */ { 212, -2 }, /* (81) conns ::= CONNS INTEGER */
{ 219, -2 }, /* (82) state ::= STATE ids */ { 213, 0 }, /* (82) state ::= */
{ 205, -9 }, /* (83) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ { 213, -2 }, /* (83) state ::= STATE ids */
{ 220, -3 }, /* (84) intitemlist ::= intitemlist COMMA intitem */ { 199, -9 }, /* (84) acct_optr ::= pps tseries storage streams qtime dbs users conns state */
{ 220, -1 }, /* (85) intitemlist ::= intitem */ { 214, -3 }, /* (85) intitemlist ::= intitemlist COMMA intitem */
{ 221, -1 }, /* (86) intitem ::= INTEGER */ { 214, -1 }, /* (86) intitemlist ::= intitem */
{ 222, -2 }, /* (87) keep ::= KEEP intitemlist */ { 215, -1 }, /* (87) intitem ::= INTEGER */
{ 223, -2 }, /* (88) cache ::= CACHE INTEGER */ { 216, -2 }, /* (88) keep ::= KEEP intitemlist */
{ 224, -2 }, /* (89) replica ::= REPLICA INTEGER */ { 217, -2 }, /* (89) cache ::= CACHE INTEGER */
{ 225, -2 }, /* (90) quorum ::= QUORUM INTEGER */ { 218, -2 }, /* (90) replica ::= REPLICA INTEGER */
{ 226, -2 }, /* (91) days ::= DAYS INTEGER */ { 219, -2 }, /* (91) quorum ::= QUORUM INTEGER */
{ 227, -2 }, /* (92) minrows ::= MINROWS INTEGER */ { 220, -2 }, /* (92) days ::= DAYS INTEGER */
{ 228, -2 }, /* (93) maxrows ::= MAXROWS INTEGER */ { 221, -2 }, /* (93) minrows ::= MINROWS INTEGER */
{ 229, -2 }, /* (94) blocks ::= BLOCKS INTEGER */ { 222, -2 }, /* (94) maxrows ::= MAXROWS INTEGER */
{ 230, -2 }, /* (95) ctime ::= CTIME INTEGER */ { 223, -2 }, /* (95) blocks ::= BLOCKS INTEGER */
{ 231, -2 }, /* (96) wal ::= WAL INTEGER */ { 224, -2 }, /* (96) ctime ::= CTIME INTEGER */
{ 232, -2 }, /* (97) fsync ::= FSYNC INTEGER */ { 225, -2 }, /* (97) wal ::= WAL INTEGER */
{ 233, -2 }, /* (98) comp ::= COMP INTEGER */ { 226, -2 }, /* (98) fsync ::= FSYNC INTEGER */
{ 234, -2 }, /* (99) prec ::= PRECISION STRING */ { 227, -2 }, /* (99) comp ::= COMP INTEGER */
{ 235, -2 }, /* (100) update ::= UPDATE INTEGER */ { 228, -2 }, /* (100) prec ::= PRECISION STRING */
{ 236, -2 }, /* (101) cachelast ::= CACHELAST INTEGER */ { 229, -2 }, /* (101) update ::= UPDATE INTEGER */
{ 208, 0 }, /* (102) db_optr ::= */ { 230, -2 }, /* (102) cachelast ::= CACHELAST INTEGER */
{ 208, -2 }, /* (103) db_optr ::= db_optr cache */ { 202, 0 }, /* (103) db_optr ::= */
{ 208, -2 }, /* (104) db_optr ::= db_optr replica */ { 202, -2 }, /* (104) db_optr ::= db_optr cache */
{ 208, -2 }, /* (105) db_optr ::= db_optr quorum */ { 202, -2 }, /* (105) db_optr ::= db_optr replica */
{ 208, -2 }, /* (106) db_optr ::= db_optr days */ { 202, -2 }, /* (106) db_optr ::= db_optr quorum */
{ 208, -2 }, /* (107) db_optr ::= db_optr minrows */ { 202, -2 }, /* (107) db_optr ::= db_optr days */
{ 208, -2 }, /* (108) db_optr ::= db_optr maxrows */ { 202, -2 }, /* (108) db_optr ::= db_optr minrows */
{ 208, -2 }, /* (109) db_optr ::= db_optr blocks */ { 202, -2 }, /* (109) db_optr ::= db_optr maxrows */
{ 208, -2 }, /* (110) db_optr ::= db_optr ctime */ { 202, -2 }, /* (110) db_optr ::= db_optr blocks */
{ 208, -2 }, /* (111) db_optr ::= db_optr wal */ { 202, -2 }, /* (111) db_optr ::= db_optr ctime */
{ 208, -2 }, /* (112) db_optr ::= db_optr fsync */ { 202, -2 }, /* (112) db_optr ::= db_optr wal */
{ 208, -2 }, /* (113) db_optr ::= db_optr comp */ { 202, -2 }, /* (113) db_optr ::= db_optr fsync */
{ 208, -2 }, /* (114) db_optr ::= db_optr prec */ { 202, -2 }, /* (114) db_optr ::= db_optr comp */
{ 208, -2 }, /* (115) db_optr ::= db_optr keep */ { 202, -2 }, /* (115) db_optr ::= db_optr prec */
{ 208, -2 }, /* (116) db_optr ::= db_optr update */ { 202, -2 }, /* (116) db_optr ::= db_optr keep */
{ 208, -2 }, /* (117) db_optr ::= db_optr cachelast */ { 202, -2 }, /* (117) db_optr ::= db_optr update */
{ 204, 0 }, /* (118) alter_db_optr ::= */ { 202, -2 }, /* (118) db_optr ::= db_optr cachelast */
{ 204, -2 }, /* (119) alter_db_optr ::= alter_db_optr replica */ { 198, 0 }, /* (119) alter_db_optr ::= */
{ 204, -2 }, /* (120) alter_db_optr ::= alter_db_optr quorum */ { 198, -2 }, /* (120) alter_db_optr ::= alter_db_optr replica */
{ 204, -2 }, /* (121) alter_db_optr ::= alter_db_optr keep */ { 198, -2 }, /* (121) alter_db_optr ::= alter_db_optr quorum */
{ 204, -2 }, /* (122) alter_db_optr ::= alter_db_optr blocks */ { 198, -2 }, /* (122) alter_db_optr ::= alter_db_optr keep */
{ 204, -2 }, /* (123) alter_db_optr ::= alter_db_optr comp */ { 198, -2 }, /* (123) alter_db_optr ::= alter_db_optr blocks */
{ 204, -2 }, /* (124) alter_db_optr ::= alter_db_optr update */ { 198, -2 }, /* (124) alter_db_optr ::= alter_db_optr comp */
{ 204, -2 }, /* (125) alter_db_optr ::= alter_db_optr cachelast */ { 198, -2 }, /* (125) alter_db_optr ::= alter_db_optr update */
{ 209, -1 }, /* (126) typename ::= ids */ { 198, -2 }, /* (126) alter_db_optr ::= alter_db_optr cachelast */
{ 209, -4 }, /* (127) typename ::= ids LP signed RP */ { 203, -1 }, /* (127) typename ::= ids */
{ 209, -2 }, /* (128) typename ::= ids UNSIGNED */ { 203, -4 }, /* (128) typename ::= ids LP signed RP */
{ 237, -1 }, /* (129) signed ::= INTEGER */ { 203, -2 }, /* (129) typename ::= ids UNSIGNED */
{ 237, -2 }, /* (130) signed ::= PLUS INTEGER */ { 231, -1 }, /* (130) signed ::= INTEGER */
{ 237, -2 }, /* (131) signed ::= MINUS INTEGER */ { 231, -2 }, /* (131) signed ::= PLUS INTEGER */
{ 199, -3 }, /* (132) cmd ::= CREATE TABLE create_table_args */ { 231, -2 }, /* (132) signed ::= MINUS INTEGER */
{ 199, -3 }, /* (133) cmd ::= CREATE TABLE create_stable_args */ { 193, -3 }, /* (133) cmd ::= CREATE TABLE create_table_args */
{ 199, -3 }, /* (134) cmd ::= CREATE STABLE create_stable_args */ { 193, -3 }, /* (134) cmd ::= CREATE TABLE create_stable_args */
{ 199, -3 }, /* (135) cmd ::= CREATE TABLE create_table_list */ { 193, -3 }, /* (135) cmd ::= CREATE STABLE create_stable_args */
{ 240, -1 }, /* (136) create_table_list ::= create_from_stable */ { 193, -3 }, /* (136) cmd ::= CREATE TABLE create_table_list */
{ 240, -2 }, /* (137) create_table_list ::= create_table_list create_from_stable */ { 234, -1 }, /* (137) create_table_list ::= create_from_stable */
{ 238, -6 }, /* (138) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ { 234, -2 }, /* (138) create_table_list ::= create_table_list create_from_stable */
{ 239, -10 }, /* (139) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ { 232, -6 }, /* (139) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */
{ 241, -10 }, /* (140) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist1 RP */ { 233, -10 }, /* (140) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */
{ 241, -13 }, /* (141) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist1 RP */ { 235, -10 }, /* (141) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist1 RP */
{ 244, -3 }, /* (142) tagNamelist ::= tagNamelist COMMA ids */ { 235, -13 }, /* (142) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist1 RP */
{ 244, -1 }, /* (143) tagNamelist ::= ids */ { 238, -3 }, /* (143) tagNamelist ::= tagNamelist COMMA ids */
{ 238, -5 }, /* (144) create_table_args ::= ifnotexists ids cpxName AS select */ { 238, -1 }, /* (144) tagNamelist ::= ids */
{ 242, -3 }, /* (145) columnlist ::= columnlist COMMA column */ { 232, -5 }, /* (145) create_table_args ::= ifnotexists ids cpxName AS select */
{ 242, -1 }, /* (146) columnlist ::= column */ { 236, -3 }, /* (146) columnlist ::= columnlist COMMA column */
{ 246, -2 }, /* (147) column ::= ids typename */ { 236, -1 }, /* (147) columnlist ::= column */
{ 243, -3 }, /* (148) tagitemlist1 ::= tagitemlist1 COMMA tagitem1 */ { 240, -2 }, /* (148) column ::= ids typename */
{ 243, -1 }, /* (149) tagitemlist1 ::= tagitem1 */ { 237, -3 }, /* (149) tagitemlist1 ::= tagitemlist1 COMMA tagitem1 */
{ 247, -2 }, /* (150) tagitem1 ::= MINUS INTEGER */ { 237, -1 }, /* (150) tagitemlist1 ::= tagitem1 */
{ 248, -3 }, /* (151) tagitemlist ::= tagitemlist COMMA tagitem */ { 241, -2 }, /* (151) tagitem1 ::= MINUS INTEGER */
{ 248, -1 }, /* (152) tagitemlist ::= tagitem */ { 241, -2 }, /* (152) tagitem1 ::= MINUS FLOAT */
{ 249, -1 }, /* (153) tagitem ::= INTEGER */ { 241, -2 }, /* (153) tagitem1 ::= PLUS INTEGER */
{ 249, -1 }, /* (154) tagitem ::= FLOAT */ { 241, -2 }, /* (154) tagitem1 ::= PLUS FLOAT */
{ 249, -1 }, /* (155) tagitem ::= STRING */ { 241, -1 }, /* (155) tagitem1 ::= INTEGER */
{ 249, -1 }, /* (156) tagitem ::= BOOL */ { 241, -1 }, /* (156) tagitem1 ::= FLOAT */
{ 249, -1 }, /* (157) tagitem ::= NULL */ { 241, -1 }, /* (157) tagitem1 ::= STRING */
{ 249, -1 }, /* (158) tagitem ::= NOW */ { 241, -1 }, /* (158) tagitem1 ::= BOOL */
{ 249, -2 }, /* (159) tagitem ::= MINUS INTEGER */ { 241, -1 }, /* (159) tagitem1 ::= NULL */
{ 249, -2 }, /* (160) tagitem ::= MINUS FLOAT */ { 241, -1 }, /* (160) tagitem1 ::= NOW */
{ 249, -2 }, /* (161) tagitem ::= PLUS INTEGER */ { 242, -3 }, /* (161) tagitemlist ::= tagitemlist COMMA tagitem */
{ 249, -2 }, /* (162) tagitem ::= PLUS FLOAT */ { 242, -1 }, /* (162) tagitemlist ::= tagitem */
{ 245, -14 }, /* (163) select ::= SELECT selcollist from where_opt interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ { 243, -1 }, /* (163) tagitem ::= INTEGER */
{ 245, -3 }, /* (164) select ::= LP select RP */ { 243, -1 }, /* (164) tagitem ::= FLOAT */
{ 263, -1 }, /* (165) union ::= select */ { 243, -1 }, /* (165) tagitem ::= STRING */
{ 263, -4 }, /* (166) union ::= union UNION ALL select */ { 243, -1 }, /* (166) tagitem ::= BOOL */
{ 263, -3 }, /* (167) union ::= union UNION select */ { 243, -1 }, /* (167) tagitem ::= NULL */
{ 199, -1 }, /* (168) cmd ::= union */ { 243, -1 }, /* (168) tagitem ::= NOW */
{ 245, -2 }, /* (169) select ::= SELECT selcollist */ { 243, -2 }, /* (169) tagitem ::= MINUS INTEGER */
{ 264, -2 }, /* (170) sclp ::= selcollist COMMA */ { 243, -2 }, /* (170) tagitem ::= MINUS FLOAT */
{ 264, 0 }, /* (171) sclp ::= */ { 243, -2 }, /* (171) tagitem ::= PLUS INTEGER */
{ 250, -4 }, /* (172) selcollist ::= sclp distinct expr as */ { 243, -2 }, /* (172) tagitem ::= PLUS FLOAT */
{ 250, -2 }, /* (173) selcollist ::= sclp STAR */ { 239, -14 }, /* (173) select ::= SELECT selcollist from where_opt interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */
{ 267, -2 }, /* (174) as ::= AS ids */ { 239, -3 }, /* (174) select ::= LP select RP */
{ 267, -1 }, /* (175) as ::= ids */ { 257, -1 }, /* (175) union ::= select */
{ 267, 0 }, /* (176) as ::= */ { 257, -4 }, /* (176) union ::= union UNION ALL select */
{ 265, -1 }, /* (177) distinct ::= DISTINCT */ { 257, -3 }, /* (177) union ::= union UNION select */
{ 265, 0 }, /* (178) distinct ::= */ { 193, -1 }, /* (178) cmd ::= union */
{ 251, -2 }, /* (179) from ::= FROM tablelist */ { 239, -2 }, /* (179) select ::= SELECT selcollist */
{ 251, -2 }, /* (180) from ::= FROM sub */ { 258, -2 }, /* (180) sclp ::= selcollist COMMA */
{ 269, -3 }, /* (181) sub ::= LP union RP */ { 258, 0 }, /* (181) sclp ::= */
{ 269, -4 }, /* (182) sub ::= LP union RP ids */ { 244, -4 }, /* (182) selcollist ::= sclp distinct expr as */
{ 269, -6 }, /* (183) sub ::= sub COMMA LP union RP ids */ { 244, -2 }, /* (183) selcollist ::= sclp STAR */
{ 268, -2 }, /* (184) tablelist ::= ids cpxName */ { 261, -2 }, /* (184) as ::= AS ids */
{ 268, -3 }, /* (185) tablelist ::= ids cpxName ids */ { 261, -1 }, /* (185) as ::= ids */
{ 268, -4 }, /* (186) tablelist ::= tablelist COMMA ids cpxName */ { 261, 0 }, /* (186) as ::= */
{ 268, -5 }, /* (187) tablelist ::= tablelist COMMA ids cpxName ids */ { 259, -1 }, /* (187) distinct ::= DISTINCT */
{ 270, -1 }, /* (188) tmvar ::= VARIABLE */ { 259, 0 }, /* (188) distinct ::= */
{ 253, -4 }, /* (189) interval_option ::= intervalKey LP tmvar RP */ { 245, -2 }, /* (189) from ::= FROM tablelist */
{ 253, -6 }, /* (190) interval_option ::= intervalKey LP tmvar COMMA tmvar RP */ { 245, -2 }, /* (190) from ::= FROM sub */
{ 253, 0 }, /* (191) interval_option ::= */ { 263, -3 }, /* (191) sub ::= LP union RP */
{ 271, -1 }, /* (192) intervalKey ::= INTERVAL */ { 263, -4 }, /* (192) sub ::= LP union RP ids */
{ 271, -1 }, /* (193) intervalKey ::= EVERY */ { 263, -6 }, /* (193) sub ::= sub COMMA LP union RP ids */
{ 255, 0 }, /* (194) session_option ::= */ { 262, -2 }, /* (194) tablelist ::= ids cpxName */
{ 255, -7 }, /* (195) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ { 262, -3 }, /* (195) tablelist ::= ids cpxName ids */
{ 256, 0 }, /* (196) windowstate_option ::= */ { 262, -4 }, /* (196) tablelist ::= tablelist COMMA ids cpxName */
{ 256, -4 }, /* (197) windowstate_option ::= STATE_WINDOW LP ids RP */ { 262, -5 }, /* (197) tablelist ::= tablelist COMMA ids cpxName ids */
{ 257, 0 }, /* (198) fill_opt ::= */ { 264, -1 }, /* (198) tmvar ::= VARIABLE */
{ 257, -6 }, /* (199) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ { 247, -4 }, /* (199) interval_option ::= intervalKey LP tmvar RP */
{ 257, -4 }, /* (200) fill_opt ::= FILL LP ID RP */ { 247, -6 }, /* (200) interval_option ::= intervalKey LP tmvar COMMA tmvar RP */
{ 254, -4 }, /* (201) sliding_opt ::= SLIDING LP tmvar RP */ { 247, 0 }, /* (201) interval_option ::= */
{ 254, 0 }, /* (202) sliding_opt ::= */ { 265, -1 }, /* (202) intervalKey ::= INTERVAL */
{ 260, 0 }, /* (203) orderby_opt ::= */ { 265, -1 }, /* (203) intervalKey ::= EVERY */
{ 260, -3 }, /* (204) orderby_opt ::= ORDER BY sortlist */ { 249, 0 }, /* (204) session_option ::= */
{ 272, -4 }, /* (205) sortlist ::= sortlist COMMA item sortorder */ { 249, -7 }, /* (205) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */
{ 272, -2 }, /* (206) sortlist ::= item sortorder */ { 250, 0 }, /* (206) windowstate_option ::= */
{ 274, -2 }, /* (207) item ::= ids cpxName */ { 250, -4 }, /* (207) windowstate_option ::= STATE_WINDOW LP ids RP */
{ 275, -1 }, /* (208) sortorder ::= ASC */ { 251, 0 }, /* (208) fill_opt ::= */
{ 275, -1 }, /* (209) sortorder ::= DESC */ { 251, -6 }, /* (209) fill_opt ::= FILL LP ID COMMA tagitemlist RP */
{ 275, 0 }, /* (210) sortorder ::= */ { 251, -4 }, /* (210) fill_opt ::= FILL LP ID RP */
{ 258, 0 }, /* (211) groupby_opt ::= */ { 248, -4 }, /* (211) sliding_opt ::= SLIDING LP tmvar RP */
{ 258, -3 }, /* (212) groupby_opt ::= GROUP BY grouplist */ { 248, 0 }, /* (212) sliding_opt ::= */
{ 276, -3 }, /* (213) grouplist ::= grouplist COMMA item */ { 254, 0 }, /* (213) orderby_opt ::= */
{ 276, -1 }, /* (214) grouplist ::= item */ { 254, -3 }, /* (214) orderby_opt ::= ORDER BY sortlist */
{ 259, 0 }, /* (215) having_opt ::= */ { 266, -4 }, /* (215) sortlist ::= sortlist COMMA item sortorder */
{ 259, -2 }, /* (216) having_opt ::= HAVING expr */ { 266, -2 }, /* (216) sortlist ::= item sortorder */
{ 262, 0 }, /* (217) limit_opt ::= */ { 268, -2 }, /* (217) item ::= ids cpxName */
{ 262, -2 }, /* (218) limit_opt ::= LIMIT signed */ { 269, -1 }, /* (218) sortorder ::= ASC */
{ 262, -4 }, /* (219) limit_opt ::= LIMIT signed OFFSET signed */ { 269, -1 }, /* (219) sortorder ::= DESC */
{ 262, -4 }, /* (220) limit_opt ::= LIMIT signed COMMA signed */ { 269, 0 }, /* (220) sortorder ::= */
{ 261, 0 }, /* (221) slimit_opt ::= */ { 252, 0 }, /* (221) groupby_opt ::= */
{ 261, -2 }, /* (222) slimit_opt ::= SLIMIT signed */ { 252, -3 }, /* (222) groupby_opt ::= GROUP BY grouplist */
{ 261, -4 }, /* (223) slimit_opt ::= SLIMIT signed SOFFSET signed */ { 270, -3 }, /* (223) grouplist ::= grouplist COMMA item */
{ 261, -4 }, /* (224) slimit_opt ::= SLIMIT signed COMMA signed */ { 270, -1 }, /* (224) grouplist ::= item */
{ 252, 0 }, /* (225) where_opt ::= */ { 253, 0 }, /* (225) having_opt ::= */
{ 252, -2 }, /* (226) where_opt ::= WHERE expr */ { 253, -2 }, /* (226) having_opt ::= HAVING expr */
{ 266, -3 }, /* (227) expr ::= LP expr RP */ { 256, 0 }, /* (227) limit_opt ::= */
{ 266, -1 }, /* (228) expr ::= ID */ { 256, -2 }, /* (228) limit_opt ::= LIMIT signed */
{ 266, -3 }, /* (229) expr ::= ID DOT ID */ { 256, -4 }, /* (229) limit_opt ::= LIMIT signed OFFSET signed */
{ 266, -3 }, /* (230) expr ::= ID DOT STAR */ { 256, -4 }, /* (230) limit_opt ::= LIMIT signed COMMA signed */
{ 266, -1 }, /* (231) expr ::= INTEGER */ { 255, 0 }, /* (231) slimit_opt ::= */
{ 266, -2 }, /* (232) expr ::= MINUS INTEGER */ { 255, -2 }, /* (232) slimit_opt ::= SLIMIT signed */
{ 266, -2 }, /* (233) expr ::= PLUS INTEGER */ { 255, -4 }, /* (233) slimit_opt ::= SLIMIT signed SOFFSET signed */
{ 266, -1 }, /* (234) expr ::= FLOAT */ { 255, -4 }, /* (234) slimit_opt ::= SLIMIT signed COMMA signed */
{ 266, -2 }, /* (235) expr ::= MINUS FLOAT */ { 246, 0 }, /* (235) where_opt ::= */
{ 266, -2 }, /* (236) expr ::= PLUS FLOAT */ { 246, -2 }, /* (236) where_opt ::= WHERE expr */
{ 266, -1 }, /* (237) expr ::= STRING */ { 260, -3 }, /* (237) expr ::= LP expr RP */
{ 266, -1 }, /* (238) expr ::= NOW */ { 260, -1 }, /* (238) expr ::= ID */
{ 266, -1 }, /* (239) expr ::= VARIABLE */ { 260, -3 }, /* (239) expr ::= ID DOT ID */
{ 266, -2 }, /* (240) expr ::= PLUS VARIABLE */ { 260, -3 }, /* (240) expr ::= ID DOT STAR */
{ 266, -2 }, /* (241) expr ::= MINUS VARIABLE */ { 260, -1 }, /* (241) expr ::= INTEGER */
{ 266, -1 }, /* (242) expr ::= BOOL */ { 260, -2 }, /* (242) expr ::= MINUS INTEGER */
{ 266, -1 }, /* (243) expr ::= NULL */ { 260, -2 }, /* (243) expr ::= PLUS INTEGER */
{ 266, -4 }, /* (244) expr ::= ID LP exprlist RP */ { 260, -1 }, /* (244) expr ::= FLOAT */
{ 266, -4 }, /* (245) expr ::= ID LP STAR RP */ { 260, -2 }, /* (245) expr ::= MINUS FLOAT */
{ 266, -3 }, /* (246) expr ::= expr IS NULL */ { 260, -2 }, /* (246) expr ::= PLUS FLOAT */
{ 266, -4 }, /* (247) expr ::= expr IS NOT NULL */ { 260, -1 }, /* (247) expr ::= STRING */
{ 266, -3 }, /* (248) expr ::= expr LT expr */ { 260, -1 }, /* (248) expr ::= NOW */
{ 266, -3 }, /* (249) expr ::= expr GT expr */ { 260, -1 }, /* (249) expr ::= VARIABLE */
{ 266, -3 }, /* (250) expr ::= expr LE expr */ { 260, -2 }, /* (250) expr ::= PLUS VARIABLE */
{ 266, -3 }, /* (251) expr ::= expr GE expr */ { 260, -2 }, /* (251) expr ::= MINUS VARIABLE */
{ 266, -3 }, /* (252) expr ::= expr NE expr */ { 260, -1 }, /* (252) expr ::= BOOL */
{ 266, -3 }, /* (253) expr ::= expr EQ expr */ { 260, -1 }, /* (253) expr ::= NULL */
{ 266, -5 }, /* (254) expr ::= expr BETWEEN expr AND expr */ { 260, -4 }, /* (254) expr ::= ID LP exprlist RP */
{ 266, -3 }, /* (255) expr ::= expr AND expr */ { 260, -4 }, /* (255) expr ::= ID LP STAR RP */
{ 266, -3 }, /* (256) expr ::= expr OR expr */ { 260, -3 }, /* (256) expr ::= expr IS NULL */
{ 266, -3 }, /* (257) expr ::= expr PLUS expr */ { 260, -4 }, /* (257) expr ::= expr IS NOT NULL */
{ 266, -3 }, /* (258) expr ::= expr MINUS expr */ { 260, -3 }, /* (258) expr ::= expr LT expr */
{ 266, -3 }, /* (259) expr ::= expr STAR expr */ { 260, -3 }, /* (259) expr ::= expr GT expr */
{ 266, -3 }, /* (260) expr ::= expr SLASH expr */ { 260, -3 }, /* (260) expr ::= expr LE expr */
{ 266, -3 }, /* (261) expr ::= expr REM expr */ { 260, -3 }, /* (261) expr ::= expr GE expr */
{ 266, -3 }, /* (262) expr ::= expr LIKE expr */ { 260, -3 }, /* (262) expr ::= expr NE expr */
{ 266, -3 }, /* (263) expr ::= expr MATCH expr */ { 260, -3 }, /* (263) expr ::= expr EQ expr */
{ 266, -3 }, /* (264) expr ::= expr NMATCH expr */ { 260, -5 }, /* (264) expr ::= expr BETWEEN expr AND expr */
{ 266, -5 }, /* (265) expr ::= expr IN LP exprlist RP */ { 260, -3 }, /* (265) expr ::= expr AND expr */
{ 206, -3 }, /* (266) exprlist ::= exprlist COMMA expritem */ { 260, -3 }, /* (266) expr ::= expr OR expr */
{ 206, -1 }, /* (267) exprlist ::= expritem */ { 260, -3 }, /* (267) expr ::= expr PLUS expr */
{ 277, -1 }, /* (268) expritem ::= expr */ { 260, -3 }, /* (268) expr ::= expr MINUS expr */
{ 277, 0 }, /* (269) expritem ::= */ { 260, -3 }, /* (269) expr ::= expr STAR expr */
{ 199, -3 }, /* (270) cmd ::= RESET QUERY CACHE */ { 260, -3 }, /* (270) expr ::= expr SLASH expr */
{ 199, -3 }, /* (271) cmd ::= SYNCDB ids REPLICA */ { 260, -3 }, /* (271) expr ::= expr REM expr */
{ 199, -7 }, /* (272) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ { 260, -3 }, /* (272) expr ::= expr LIKE expr */
{ 199, -7 }, /* (273) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ { 260, -3 }, /* (273) expr ::= expr MATCH expr */
{ 199, -7 }, /* (274) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ { 260, -3 }, /* (274) expr ::= expr NMATCH expr */
{ 199, -7 }, /* (275) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ { 260, -5 }, /* (275) expr ::= expr IN LP exprlist RP */
{ 199, -7 }, /* (276) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ { 200, -3 }, /* (276) exprlist ::= exprlist COMMA expritem */
{ 199, -8 }, /* (277) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ { 200, -1 }, /* (277) exprlist ::= expritem */
{ 199, -9 }, /* (278) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ { 271, -1 }, /* (278) expritem ::= expr */
{ 199, -7 }, /* (279) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ { 271, 0 }, /* (279) expritem ::= */
{ 199, -7 }, /* (280) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ { 193, -3 }, /* (280) cmd ::= RESET QUERY CACHE */
{ 199, -7 }, /* (281) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ { 193, -3 }, /* (281) cmd ::= SYNCDB ids REPLICA */
{ 199, -7 }, /* (282) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ { 193, -7 }, /* (282) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */
{ 199, -7 }, /* (283) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ { 193, -7 }, /* (283) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */
{ 199, -7 }, /* (284) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ { 193, -7 }, /* (284) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */
{ 199, -8 }, /* (285) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ { 193, -7 }, /* (285) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */
{ 199, -9 }, /* (286) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ { 193, -7 }, /* (286) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */
{ 199, -7 }, /* (287) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ { 193, -8 }, /* (287) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */
{ 199, -3 }, /* (288) cmd ::= KILL CONNECTION INTEGER */ { 193, -9 }, /* (288) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */
{ 199, -5 }, /* (289) cmd ::= KILL STREAM INTEGER COLON INTEGER */ { 193, -7 }, /* (289) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */
{ 199, -5 }, /* (290) cmd ::= KILL QUERY INTEGER COLON INTEGER */ { 193, -7 }, /* (290) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */
{ 193, -7 }, /* (291) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */
{ 193, -7 }, /* (292) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */
{ 193, -7 }, /* (293) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */
{ 193, -7 }, /* (294) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */
{ 193, -8 }, /* (295) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */
{ 193, -9 }, /* (296) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */
{ 193, -7 }, /* (297) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */
{ 193, -3 }, /* (298) cmd ::= KILL CONNECTION INTEGER */
{ 193, -5 }, /* (299) cmd ::= KILL STREAM INTEGER COLON INTEGER */
{ 193, -5 }, /* (300) cmd ::= KILL QUERY INTEGER COLON INTEGER */
}; };
static void yy_accept(yyParser*); /* Forward Declaration */ static void yy_accept(yyParser*); /* Forward Declaration */
...@@ -2208,9 +2217,9 @@ static void yy_reduce( ...@@ -2208,9 +2217,9 @@ static void yy_reduce(
/********** Begin reduce actions **********************************************/ /********** Begin reduce actions **********************************************/
YYMINORTYPE yylhsminor; YYMINORTYPE yylhsminor;
case 0: /* program ::= cmd */ case 0: /* program ::= cmd */
case 132: /* cmd ::= CREATE TABLE create_table_args */ yytestcase(yyruleno==132); case 133: /* cmd ::= CREATE TABLE create_table_args */ yytestcase(yyruleno==133);
case 133: /* cmd ::= CREATE TABLE create_stable_args */ yytestcase(yyruleno==133); case 134: /* cmd ::= CREATE TABLE create_stable_args */ yytestcase(yyruleno==134);
case 134: /* cmd ::= CREATE STABLE create_stable_args */ yytestcase(yyruleno==134); case 135: /* cmd ::= CREATE STABLE create_stable_args */ yytestcase(yyruleno==135);
{} {}
break; break;
case 1: /* cmd ::= SHOW DATABASES */ case 1: /* cmd ::= SHOW DATABASES */
...@@ -2386,7 +2395,7 @@ static void yy_reduce( ...@@ -2386,7 +2395,7 @@ static void yy_reduce(
{ setDCLSqlElems(pInfo, TSDB_SQL_CFG_LOCAL, 2, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } { setDCLSqlElems(pInfo, TSDB_SQL_CFG_LOCAL, 2, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); }
break; break;
case 47: /* cmd ::= ALTER DATABASE ids alter_db_optr */ case 47: /* cmd ::= ALTER DATABASE ids alter_db_optr */
{ SToken t = {0}; setCreateDbInfo(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy90, &t);} { SToken t = {0}; setCreateDbInfo(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy254, &t);}
break; break;
case 48: /* cmd ::= ALTER ACCOUNT ids acct_optr */ case 48: /* cmd ::= ALTER ACCOUNT ids acct_optr */
{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy171);} { setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy171);}
...@@ -2395,7 +2404,7 @@ static void yy_reduce( ...@@ -2395,7 +2404,7 @@ static void yy_reduce(
{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy171);} { setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy171);}
break; break;
case 50: /* cmd ::= COMPACT VNODES IN LP exprlist RP */ case 50: /* cmd ::= COMPACT VNODES IN LP exprlist RP */
{ setCompactVnodeSql(pInfo, TSDB_SQL_COMPACT_VNODE, yymsp[-1].minor.yy421);} { setCompactVnodeSql(pInfo, TSDB_SQL_COMPACT_VNODE, yymsp[-1].minor.yy413);}
break; break;
case 51: /* ids ::= ID */ case 51: /* ids ::= ID */
case 52: /* ids ::= STRING */ yytestcase(yyruleno==52); case 52: /* ids ::= STRING */ yytestcase(yyruleno==52);
...@@ -2407,55 +2416,56 @@ static void yy_reduce( ...@@ -2407,55 +2416,56 @@ static void yy_reduce(
break; break;
case 54: /* ifexists ::= */ case 54: /* ifexists ::= */
case 56: /* ifnotexists ::= */ yytestcase(yyruleno==56); case 56: /* ifnotexists ::= */ yytestcase(yyruleno==56);
case 178: /* distinct ::= */ yytestcase(yyruleno==178); case 188: /* distinct ::= */ yytestcase(yyruleno==188);
{ yymsp[1].minor.yy0.n = 0;} { yymsp[1].minor.yy0.n = 0;}
break; break;
case 55: /* ifnotexists ::= IF NOT EXISTS */ case 55: /* ifnotexists ::= IF NOT EXISTS */
{ yymsp[-2].minor.yy0.n = 1;} { yymsp[-2].minor.yy0.n = 1;}
break; break;
case 57: /* cmd ::= CREATE DNODE ids PORT ids */ case 57: /* cmd ::= CREATE DNODE ids PORT ids */
case 58: /* cmd ::= CREATE DNODE IPTOKEN PORT ids */ yytestcase(yyruleno==58);
{ setDCLSqlElems(pInfo, TSDB_SQL_CREATE_DNODE, 2, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);} { setDCLSqlElems(pInfo, TSDB_SQL_CREATE_DNODE, 2, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);}
break; break;
case 58: /* cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ case 59: /* cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */
{ setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy171);} { setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy171);}
break; break;
case 59: /* cmd ::= CREATE DATABASE ifnotexists ids db_optr */ case 60: /* cmd ::= CREATE DATABASE ifnotexists ids db_optr */
{ setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy90, &yymsp[-2].minor.yy0);} { setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy254, &yymsp[-2].minor.yy0);}
break; break;
case 60: /* cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ case 61: /* cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */
{ setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &yymsp[-5].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy100, &yymsp[0].minor.yy0, 1);} { setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &yymsp[-5].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy280, &yymsp[0].minor.yy0, 1);}
break; break;
case 61: /* cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ case 62: /* cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */
{ setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &yymsp[-5].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy100, &yymsp[0].minor.yy0, 2);} { setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &yymsp[-5].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy280, &yymsp[0].minor.yy0, 2);}
break; break;
case 62: /* cmd ::= CREATE USER ids PASS ids */ case 63: /* cmd ::= CREATE USER ids PASS ids */
{ setCreateUserSql(pInfo, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);} { setCreateUserSql(pInfo, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);}
break; break;
case 63: /* bufsize ::= */ case 64: /* bufsize ::= */
case 65: /* pps ::= */ yytestcase(yyruleno==65); case 66: /* pps ::= */ yytestcase(yyruleno==66);
case 67: /* tseries ::= */ yytestcase(yyruleno==67); case 68: /* tseries ::= */ yytestcase(yyruleno==68);
case 69: /* dbs ::= */ yytestcase(yyruleno==69); case 70: /* dbs ::= */ yytestcase(yyruleno==70);
case 71: /* streams ::= */ yytestcase(yyruleno==71); case 72: /* streams ::= */ yytestcase(yyruleno==72);
case 73: /* storage ::= */ yytestcase(yyruleno==73); case 74: /* storage ::= */ yytestcase(yyruleno==74);
case 75: /* qtime ::= */ yytestcase(yyruleno==75); case 76: /* qtime ::= */ yytestcase(yyruleno==76);
case 77: /* users ::= */ yytestcase(yyruleno==77); case 78: /* users ::= */ yytestcase(yyruleno==78);
case 79: /* conns ::= */ yytestcase(yyruleno==79); case 80: /* conns ::= */ yytestcase(yyruleno==80);
case 81: /* state ::= */ yytestcase(yyruleno==81); case 82: /* state ::= */ yytestcase(yyruleno==82);
{ yymsp[1].minor.yy0.n = 0; } { yymsp[1].minor.yy0.n = 0; }
break; break;
case 64: /* bufsize ::= BUFSIZE INTEGER */ case 65: /* bufsize ::= BUFSIZE INTEGER */
case 66: /* pps ::= PPS INTEGER */ yytestcase(yyruleno==66); case 67: /* pps ::= PPS INTEGER */ yytestcase(yyruleno==67);
case 68: /* tseries ::= TSERIES INTEGER */ yytestcase(yyruleno==68); case 69: /* tseries ::= TSERIES INTEGER */ yytestcase(yyruleno==69);
case 70: /* dbs ::= DBS INTEGER */ yytestcase(yyruleno==70); case 71: /* dbs ::= DBS INTEGER */ yytestcase(yyruleno==71);
case 72: /* streams ::= STREAMS INTEGER */ yytestcase(yyruleno==72); case 73: /* streams ::= STREAMS INTEGER */ yytestcase(yyruleno==73);
case 74: /* storage ::= STORAGE INTEGER */ yytestcase(yyruleno==74); case 75: /* storage ::= STORAGE INTEGER */ yytestcase(yyruleno==75);
case 76: /* qtime ::= QTIME INTEGER */ yytestcase(yyruleno==76); case 77: /* qtime ::= QTIME INTEGER */ yytestcase(yyruleno==77);
case 78: /* users ::= USERS INTEGER */ yytestcase(yyruleno==78); case 79: /* users ::= USERS INTEGER */ yytestcase(yyruleno==79);
case 80: /* conns ::= CONNS INTEGER */ yytestcase(yyruleno==80); case 81: /* conns ::= CONNS INTEGER */ yytestcase(yyruleno==81);
case 82: /* state ::= STATE ids */ yytestcase(yyruleno==82); case 83: /* state ::= STATE ids */ yytestcase(yyruleno==83);
{ yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; }
break; break;
case 83: /* acct_optr ::= pps tseries storage streams qtime dbs users conns state */ case 84: /* acct_optr ::= pps tseries storage streams qtime dbs users conns state */
{ {
yylhsminor.yy171.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1; yylhsminor.yy171.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1;
yylhsminor.yy171.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1; yylhsminor.yy171.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1;
...@@ -2469,177 +2479,177 @@ static void yy_reduce( ...@@ -2469,177 +2479,177 @@ static void yy_reduce(
} }
yymsp[-8].minor.yy171 = yylhsminor.yy171; yymsp[-8].minor.yy171 = yylhsminor.yy171;
break; break;
case 84: /* intitemlist ::= intitemlist COMMA intitem */ case 85: /* intitemlist ::= intitemlist COMMA intitem */
case 151: /* tagitemlist ::= tagitemlist COMMA tagitem */ yytestcase(yyruleno==151); case 161: /* tagitemlist ::= tagitemlist COMMA tagitem */ yytestcase(yyruleno==161);
{ yylhsminor.yy421 = tListItemAppend(yymsp[-2].minor.yy421, &yymsp[0].minor.yy69, -1); } { yylhsminor.yy413 = tListItemAppend(yymsp[-2].minor.yy413, &yymsp[0].minor.yy461, -1); }
yymsp[-2].minor.yy421 = yylhsminor.yy421; yymsp[-2].minor.yy413 = yylhsminor.yy413;
break; break;
case 85: /* intitemlist ::= intitem */ case 86: /* intitemlist ::= intitem */
case 152: /* tagitemlist ::= tagitem */ yytestcase(yyruleno==152); case 162: /* tagitemlist ::= tagitem */ yytestcase(yyruleno==162);
{ yylhsminor.yy421 = tListItemAppend(NULL, &yymsp[0].minor.yy69, -1); } { yylhsminor.yy413 = tListItemAppend(NULL, &yymsp[0].minor.yy461, -1); }
yymsp[0].minor.yy421 = yylhsminor.yy421; yymsp[0].minor.yy413 = yylhsminor.yy413;
break; break;
case 86: /* intitem ::= INTEGER */ case 87: /* intitem ::= INTEGER */
case 153: /* tagitem ::= INTEGER */ yytestcase(yyruleno==153); case 163: /* tagitem ::= INTEGER */ yytestcase(yyruleno==163);
case 154: /* tagitem ::= FLOAT */ yytestcase(yyruleno==154); case 164: /* tagitem ::= FLOAT */ yytestcase(yyruleno==164);
case 155: /* tagitem ::= STRING */ yytestcase(yyruleno==155); case 165: /* tagitem ::= STRING */ yytestcase(yyruleno==165);
case 156: /* tagitem ::= BOOL */ yytestcase(yyruleno==156); case 166: /* tagitem ::= BOOL */ yytestcase(yyruleno==166);
{ toTSDBType(yymsp[0].minor.yy0.type); taosVariantCreate(&yylhsminor.yy69, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.type); } { toTSDBType(yymsp[0].minor.yy0.type); taosVariantCreate(&yylhsminor.yy461, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.type); }
yymsp[0].minor.yy69 = yylhsminor.yy69; yymsp[0].minor.yy461 = yylhsminor.yy461;
break; break;
case 87: /* keep ::= KEEP intitemlist */ case 88: /* keep ::= KEEP intitemlist */
{ yymsp[-1].minor.yy421 = yymsp[0].minor.yy421; } { yymsp[-1].minor.yy413 = yymsp[0].minor.yy413; }
break; break;
case 88: /* cache ::= CACHE INTEGER */ case 89: /* cache ::= CACHE INTEGER */
case 89: /* replica ::= REPLICA INTEGER */ yytestcase(yyruleno==89); case 90: /* replica ::= REPLICA INTEGER */ yytestcase(yyruleno==90);
case 90: /* quorum ::= QUORUM INTEGER */ yytestcase(yyruleno==90); case 91: /* quorum ::= QUORUM INTEGER */ yytestcase(yyruleno==91);
case 91: /* days ::= DAYS INTEGER */ yytestcase(yyruleno==91); case 92: /* days ::= DAYS INTEGER */ yytestcase(yyruleno==92);
case 92: /* minrows ::= MINROWS INTEGER */ yytestcase(yyruleno==92); case 93: /* minrows ::= MINROWS INTEGER */ yytestcase(yyruleno==93);
case 93: /* maxrows ::= MAXROWS INTEGER */ yytestcase(yyruleno==93); case 94: /* maxrows ::= MAXROWS INTEGER */ yytestcase(yyruleno==94);
case 94: /* blocks ::= BLOCKS INTEGER */ yytestcase(yyruleno==94); case 95: /* blocks ::= BLOCKS INTEGER */ yytestcase(yyruleno==95);
case 95: /* ctime ::= CTIME INTEGER */ yytestcase(yyruleno==95); case 96: /* ctime ::= CTIME INTEGER */ yytestcase(yyruleno==96);
case 96: /* wal ::= WAL INTEGER */ yytestcase(yyruleno==96); case 97: /* wal ::= WAL INTEGER */ yytestcase(yyruleno==97);
case 97: /* fsync ::= FSYNC INTEGER */ yytestcase(yyruleno==97); case 98: /* fsync ::= FSYNC INTEGER */ yytestcase(yyruleno==98);
case 98: /* comp ::= COMP INTEGER */ yytestcase(yyruleno==98); case 99: /* comp ::= COMP INTEGER */ yytestcase(yyruleno==99);
case 99: /* prec ::= PRECISION STRING */ yytestcase(yyruleno==99); case 100: /* prec ::= PRECISION STRING */ yytestcase(yyruleno==100);
case 100: /* update ::= UPDATE INTEGER */ yytestcase(yyruleno==100); case 101: /* update ::= UPDATE INTEGER */ yytestcase(yyruleno==101);
case 101: /* cachelast ::= CACHELAST INTEGER */ yytestcase(yyruleno==101); case 102: /* cachelast ::= CACHELAST INTEGER */ yytestcase(yyruleno==102);
{ yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; }
break; break;
case 102: /* db_optr ::= */ case 103: /* db_optr ::= */
{setDefaultCreateDbOption(&yymsp[1].minor.yy90);} {setDefaultCreateDbOption(&yymsp[1].minor.yy254);}
break; break;
case 103: /* db_optr ::= db_optr cache */ case 104: /* db_optr ::= db_optr cache */
{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy90 = yylhsminor.yy90; yymsp[-1].minor.yy254 = yylhsminor.yy254;
break; break;
case 104: /* db_optr ::= db_optr replica */ case 105: /* db_optr ::= db_optr replica */
case 119: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==119); case 120: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==120);
{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy90 = yylhsminor.yy90; yymsp[-1].minor.yy254 = yylhsminor.yy254;
break; break;
case 105: /* db_optr ::= db_optr quorum */ case 106: /* db_optr ::= db_optr quorum */
case 120: /* alter_db_optr ::= alter_db_optr quorum */ yytestcase(yyruleno==120); case 121: /* alter_db_optr ::= alter_db_optr quorum */ yytestcase(yyruleno==121);
{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy90 = yylhsminor.yy90; yymsp[-1].minor.yy254 = yylhsminor.yy254;
break; break;
case 106: /* db_optr ::= db_optr days */ case 107: /* db_optr ::= db_optr days */
{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy90 = yylhsminor.yy90; yymsp[-1].minor.yy254 = yylhsminor.yy254;
break; break;
case 107: /* db_optr ::= db_optr minrows */ case 108: /* db_optr ::= db_optr minrows */
{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } { yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); }
yymsp[-1].minor.yy90 = yylhsminor.yy90; yymsp[-1].minor.yy254 = yylhsminor.yy254;
break; break;
case 108: /* db_optr ::= db_optr maxrows */ case 109: /* db_optr ::= db_optr maxrows */
{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } { yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); }
yymsp[-1].minor.yy90 = yylhsminor.yy90; yymsp[-1].minor.yy254 = yylhsminor.yy254;
break; break;
case 109: /* db_optr ::= db_optr blocks */ case 110: /* db_optr ::= db_optr blocks */
case 122: /* alter_db_optr ::= alter_db_optr blocks */ yytestcase(yyruleno==122); case 123: /* alter_db_optr ::= alter_db_optr blocks */ yytestcase(yyruleno==123);
{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy90 = yylhsminor.yy90; yymsp[-1].minor.yy254 = yylhsminor.yy254;
break; break;
case 110: /* db_optr ::= db_optr ctime */ case 111: /* db_optr ::= db_optr ctime */
{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy90 = yylhsminor.yy90; yymsp[-1].minor.yy254 = yylhsminor.yy254;
break; break;
case 111: /* db_optr ::= db_optr wal */ case 112: /* db_optr ::= db_optr wal */
{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy90 = yylhsminor.yy90; yymsp[-1].minor.yy254 = yylhsminor.yy254;
break; break;
case 112: /* db_optr ::= db_optr fsync */ case 113: /* db_optr ::= db_optr fsync */
{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy90 = yylhsminor.yy90; yymsp[-1].minor.yy254 = yylhsminor.yy254;
break; break;
case 113: /* db_optr ::= db_optr comp */ case 114: /* db_optr ::= db_optr comp */
case 123: /* alter_db_optr ::= alter_db_optr comp */ yytestcase(yyruleno==123); case 124: /* alter_db_optr ::= alter_db_optr comp */ yytestcase(yyruleno==124);
{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy90 = yylhsminor.yy90; yymsp[-1].minor.yy254 = yylhsminor.yy254;
break; break;
case 114: /* db_optr ::= db_optr prec */ case 115: /* db_optr ::= db_optr prec */
{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.precision = yymsp[0].minor.yy0; } { yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.precision = yymsp[0].minor.yy0; }
yymsp[-1].minor.yy90 = yylhsminor.yy90; yymsp[-1].minor.yy254 = yylhsminor.yy254;
break; break;
case 115: /* db_optr ::= db_optr keep */ case 116: /* db_optr ::= db_optr keep */
case 121: /* alter_db_optr ::= alter_db_optr keep */ yytestcase(yyruleno==121); case 122: /* alter_db_optr ::= alter_db_optr keep */ yytestcase(yyruleno==122);
{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.keep = yymsp[0].minor.yy421; } { yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.keep = yymsp[0].minor.yy413; }
yymsp[-1].minor.yy90 = yylhsminor.yy90; yymsp[-1].minor.yy254 = yylhsminor.yy254;
break; break;
case 116: /* db_optr ::= db_optr update */ case 117: /* db_optr ::= db_optr update */
case 124: /* alter_db_optr ::= alter_db_optr update */ yytestcase(yyruleno==124); case 125: /* alter_db_optr ::= alter_db_optr update */ yytestcase(yyruleno==125);
{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy90 = yylhsminor.yy90; yymsp[-1].minor.yy254 = yylhsminor.yy254;
break; break;
case 117: /* db_optr ::= db_optr cachelast */ case 118: /* db_optr ::= db_optr cachelast */
case 125: /* alter_db_optr ::= alter_db_optr cachelast */ yytestcase(yyruleno==125); case 126: /* alter_db_optr ::= alter_db_optr cachelast */ yytestcase(yyruleno==126);
{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy90 = yylhsminor.yy90; yymsp[-1].minor.yy254 = yylhsminor.yy254;
break; break;
case 118: /* alter_db_optr ::= */ case 119: /* alter_db_optr ::= */
{ setDefaultCreateDbOption(&yymsp[1].minor.yy90);} { setDefaultCreateDbOption(&yymsp[1].minor.yy254);}
break; break;
case 126: /* typename ::= ids */ case 127: /* typename ::= ids */
{ {
yymsp[0].minor.yy0.type = 0; yymsp[0].minor.yy0.type = 0;
tSetColumnType (&yylhsminor.yy100, &yymsp[0].minor.yy0); tSetColumnType (&yylhsminor.yy280, &yymsp[0].minor.yy0);
} }
yymsp[0].minor.yy100 = yylhsminor.yy100; yymsp[0].minor.yy280 = yylhsminor.yy280;
break; break;
case 127: /* typename ::= ids LP signed RP */ case 128: /* typename ::= ids LP signed RP */
{ {
if (yymsp[-1].minor.yy325 <= 0) { if (yymsp[-1].minor.yy157 <= 0) {
yymsp[-3].minor.yy0.type = 0; yymsp[-3].minor.yy0.type = 0;
tSetColumnType(&yylhsminor.yy100, &yymsp[-3].minor.yy0); tSetColumnType(&yylhsminor.yy280, &yymsp[-3].minor.yy0);
} else { } else {
yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy325; // negative value of name length yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy157; // negative value of name length
tSetColumnType(&yylhsminor.yy100, &yymsp[-3].minor.yy0); tSetColumnType(&yylhsminor.yy280, &yymsp[-3].minor.yy0);
} }
} }
yymsp[-3].minor.yy100 = yylhsminor.yy100; yymsp[-3].minor.yy280 = yylhsminor.yy280;
break; break;
case 128: /* typename ::= ids UNSIGNED */ case 129: /* typename ::= ids UNSIGNED */
{ {
yymsp[-1].minor.yy0.type = 0; yymsp[-1].minor.yy0.type = 0;
yymsp[-1].minor.yy0.n = ((yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z); yymsp[-1].minor.yy0.n = ((yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z);
tSetColumnType (&yylhsminor.yy100, &yymsp[-1].minor.yy0); tSetColumnType (&yylhsminor.yy280, &yymsp[-1].minor.yy0);
} }
yymsp[-1].minor.yy100 = yylhsminor.yy100; yymsp[-1].minor.yy280 = yylhsminor.yy280;
break; break;
case 129: /* signed ::= INTEGER */ case 130: /* signed ::= INTEGER */
{ yylhsminor.yy325 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy157 = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[0].minor.yy325 = yylhsminor.yy325; yymsp[0].minor.yy157 = yylhsminor.yy157;
break; break;
case 130: /* signed ::= PLUS INTEGER */ case 131: /* signed ::= PLUS INTEGER */
{ yymsp[-1].minor.yy325 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yymsp[-1].minor.yy157 = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
break; break;
case 131: /* signed ::= MINUS INTEGER */ case 132: /* signed ::= MINUS INTEGER */
{ yymsp[-1].minor.yy325 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} { yymsp[-1].minor.yy157 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);}
break; break;
case 135: /* cmd ::= CREATE TABLE create_table_list */ case 136: /* cmd ::= CREATE TABLE create_table_list */
{ pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = yymsp[0].minor.yy438;} { pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = yymsp[0].minor.yy438;}
break; break;
case 136: /* create_table_list ::= create_from_stable */ case 137: /* create_table_list ::= create_from_stable */
{ {
SCreateTableSql* pCreateTable = calloc(1, sizeof(SCreateTableSql)); SCreateTableSql* pCreateTable = calloc(1, sizeof(SCreateTableSql));
pCreateTable->childTableInfo = taosArrayInit(4, sizeof(SCreatedTableInfo)); pCreateTable->childTableInfo = taosArrayInit(4, sizeof(SCreatedTableInfo));
taosArrayPush(pCreateTable->childTableInfo, &yymsp[0].minor.yy152); taosArrayPush(pCreateTable->childTableInfo, &yymsp[0].minor.yy544);
pCreateTable->type = TSQL_CREATE_CTABLE; pCreateTable->type = TSQL_CREATE_CTABLE;
yylhsminor.yy438 = pCreateTable; yylhsminor.yy438 = pCreateTable;
} }
yymsp[0].minor.yy438 = yylhsminor.yy438; yymsp[0].minor.yy438 = yylhsminor.yy438;
break; break;
case 137: /* create_table_list ::= create_table_list create_from_stable */ case 138: /* create_table_list ::= create_table_list create_from_stable */
{ {
taosArrayPush(yymsp[-1].minor.yy438->childTableInfo, &yymsp[0].minor.yy152); taosArrayPush(yymsp[-1].minor.yy438->childTableInfo, &yymsp[0].minor.yy544);
yylhsminor.yy438 = yymsp[-1].minor.yy438; yylhsminor.yy438 = yymsp[-1].minor.yy438;
} }
yymsp[-1].minor.yy438 = yylhsminor.yy438; yymsp[-1].minor.yy438 = yylhsminor.yy438;
break; break;
case 138: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ case 139: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */
{ {
yylhsminor.yy438 = tSetCreateTableInfo(yymsp[-1].minor.yy421, NULL, NULL, TSQL_CREATE_TABLE); yylhsminor.yy438 = tSetCreateTableInfo(yymsp[-1].minor.yy413, NULL, NULL, TSQL_CREATE_TABLE);
setSqlInfo(pInfo, yylhsminor.yy438, NULL, TSDB_SQL_CREATE_TABLE); setSqlInfo(pInfo, yylhsminor.yy438, NULL, TSDB_SQL_CREATE_TABLE);
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
...@@ -2647,9 +2657,9 @@ static void yy_reduce( ...@@ -2647,9 +2657,9 @@ static void yy_reduce(
} }
yymsp[-5].minor.yy438 = yylhsminor.yy438; yymsp[-5].minor.yy438 = yylhsminor.yy438;
break; break;
case 139: /* create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ case 140: /* create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */
{ {
yylhsminor.yy438 = tSetCreateTableInfo(yymsp[-5].minor.yy421, yymsp[-1].minor.yy421, NULL, TSQL_CREATE_STABLE); yylhsminor.yy438 = tSetCreateTableInfo(yymsp[-5].minor.yy413, yymsp[-1].minor.yy413, NULL, TSQL_CREATE_STABLE);
setSqlInfo(pInfo, yylhsminor.yy438, NULL, TSDB_SQL_CREATE_TABLE); setSqlInfo(pInfo, yylhsminor.yy438, NULL, TSDB_SQL_CREATE_TABLE);
yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n;
...@@ -2657,33 +2667,33 @@ static void yy_reduce( ...@@ -2657,33 +2667,33 @@ static void yy_reduce(
} }
yymsp[-9].minor.yy438 = yylhsminor.yy438; yymsp[-9].minor.yy438 = yylhsminor.yy438;
break; break;
case 140: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist1 RP */ case 141: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist1 RP */
{ {
yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n;
yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n;
yylhsminor.yy152 = createNewChildTableInfo(&yymsp[-5].minor.yy0, NULL, yymsp[-1].minor.yy421, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0); yylhsminor.yy544 = createNewChildTableInfo(&yymsp[-5].minor.yy0, NULL, yymsp[-1].minor.yy413, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0);
} }
yymsp[-9].minor.yy152 = yylhsminor.yy152; yymsp[-9].minor.yy544 = yylhsminor.yy544;
break; break;
case 141: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist1 RP */ case 142: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist1 RP */
{ {
yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n;
yymsp[-11].minor.yy0.n += yymsp[-10].minor.yy0.n; yymsp[-11].minor.yy0.n += yymsp[-10].minor.yy0.n;
yylhsminor.yy152 = createNewChildTableInfo(&yymsp[-8].minor.yy0, yymsp[-5].minor.yy421, yymsp[-1].minor.yy421, &yymsp[-11].minor.yy0, &yymsp[-12].minor.yy0); yylhsminor.yy544 = createNewChildTableInfo(&yymsp[-8].minor.yy0, yymsp[-5].minor.yy413, yymsp[-1].minor.yy413, &yymsp[-11].minor.yy0, &yymsp[-12].minor.yy0);
} }
yymsp[-12].minor.yy152 = yylhsminor.yy152; yymsp[-12].minor.yy544 = yylhsminor.yy544;
break; break;
case 142: /* tagNamelist ::= tagNamelist COMMA ids */ case 143: /* tagNamelist ::= tagNamelist COMMA ids */
{taosArrayPush(yymsp[-2].minor.yy421, &yymsp[0].minor.yy0); yylhsminor.yy421 = yymsp[-2].minor.yy421; } {taosArrayPush(yymsp[-2].minor.yy413, &yymsp[0].minor.yy0); yylhsminor.yy413 = yymsp[-2].minor.yy413; }
yymsp[-2].minor.yy421 = yylhsminor.yy421; yymsp[-2].minor.yy413 = yylhsminor.yy413;
break; break;
case 143: /* tagNamelist ::= ids */ case 144: /* tagNamelist ::= ids */
{yylhsminor.yy421 = taosArrayInit(4, sizeof(SToken)); taosArrayPush(yylhsminor.yy421, &yymsp[0].minor.yy0);} {yylhsminor.yy413 = taosArrayInit(4, sizeof(SToken)); taosArrayPush(yylhsminor.yy413, &yymsp[0].minor.yy0);}
yymsp[0].minor.yy421 = yylhsminor.yy421; yymsp[0].minor.yy413 = yylhsminor.yy413;
break; break;
case 144: /* create_table_args ::= ifnotexists ids cpxName AS select */ case 145: /* create_table_args ::= ifnotexists ids cpxName AS select */
{ {
yylhsminor.yy438 = tSetCreateTableInfo(NULL, NULL, yymsp[0].minor.yy56, TSQL_CREATE_STREAM); yylhsminor.yy438 = tSetCreateTableInfo(NULL, NULL, yymsp[0].minor.yy24, TSQL_CREATE_STREAM);
setSqlInfo(pInfo, yylhsminor.yy438, NULL, TSDB_SQL_CREATE_TABLE); setSqlInfo(pInfo, yylhsminor.yy438, NULL, TSDB_SQL_CREATE_TABLE);
yymsp[-3].minor.yy0.n += yymsp[-2].minor.yy0.n; yymsp[-3].minor.yy0.n += yymsp[-2].minor.yy0.n;
...@@ -2691,474 +2701,486 @@ static void yy_reduce( ...@@ -2691,474 +2701,486 @@ static void yy_reduce(
} }
yymsp[-4].minor.yy438 = yylhsminor.yy438; yymsp[-4].minor.yy438 = yylhsminor.yy438;
break; break;
case 145: /* columnlist ::= columnlist COMMA column */ case 146: /* columnlist ::= columnlist COMMA column */
{taosArrayPush(yymsp[-2].minor.yy421, &yymsp[0].minor.yy100); yylhsminor.yy421 = yymsp[-2].minor.yy421; } {taosArrayPush(yymsp[-2].minor.yy413, &yymsp[0].minor.yy280); yylhsminor.yy413 = yymsp[-2].minor.yy413; }
yymsp[-2].minor.yy421 = yylhsminor.yy421; yymsp[-2].minor.yy413 = yylhsminor.yy413;
break; break;
case 146: /* columnlist ::= column */ case 147: /* columnlist ::= column */
{yylhsminor.yy421 = taosArrayInit(4, sizeof(SField)); taosArrayPush(yylhsminor.yy421, &yymsp[0].minor.yy100);} {yylhsminor.yy413 = taosArrayInit(4, sizeof(SField)); taosArrayPush(yylhsminor.yy413, &yymsp[0].minor.yy280);}
yymsp[0].minor.yy421 = yylhsminor.yy421; yymsp[0].minor.yy413 = yylhsminor.yy413;
break; break;
case 147: /* column ::= ids typename */ case 148: /* column ::= ids typename */
{ {
tSetColumnInfo(&yylhsminor.yy100, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy100); tSetColumnInfo(&yylhsminor.yy280, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy280);
} }
yymsp[-1].minor.yy100 = yylhsminor.yy100; yymsp[-1].minor.yy280 = yylhsminor.yy280;
break; break;
case 148: /* tagitemlist1 ::= tagitemlist1 COMMA tagitem1 */ case 149: /* tagitemlist1 ::= tagitemlist1 COMMA tagitem1 */
{ taosArrayPush(yymsp[-2].minor.yy421, &yymsp[0].minor.yy0); yylhsminor.yy421 = yymsp[-2].minor.yy421;} { taosArrayPush(yymsp[-2].minor.yy413, &yymsp[0].minor.yy0); yylhsminor.yy413 = yymsp[-2].minor.yy413;}
yymsp[-2].minor.yy421 = yylhsminor.yy421; yymsp[-2].minor.yy413 = yylhsminor.yy413;
break; break;
case 149: /* tagitemlist1 ::= tagitem1 */ case 150: /* tagitemlist1 ::= tagitem1 */
{ yylhsminor.yy421 = taosArrayInit(4, sizeof(SToken)); taosArrayPush(yylhsminor.yy421, &yymsp[0].minor.yy0); } { yylhsminor.yy413 = taosArrayInit(4, sizeof(SToken)); taosArrayPush(yylhsminor.yy413, &yymsp[0].minor.yy0); }
yymsp[0].minor.yy421 = yylhsminor.yy421; yymsp[0].minor.yy413 = yylhsminor.yy413;
break; break;
case 150: /* tagitem1 ::= MINUS INTEGER */ case 151: /* tagitem1 ::= MINUS INTEGER */
case 152: /* tagitem1 ::= MINUS FLOAT */ yytestcase(yyruleno==152);
case 153: /* tagitem1 ::= PLUS INTEGER */ yytestcase(yyruleno==153);
case 154: /* tagitem1 ::= PLUS FLOAT */ yytestcase(yyruleno==154);
{ yylhsminor.yy0.n = yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n; yylhsminor.yy0.type = yymsp[0].minor.yy0.type; } { yylhsminor.yy0.n = yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n; yylhsminor.yy0.type = yymsp[0].minor.yy0.type; }
yymsp[-1].minor.yy0 = yylhsminor.yy0; yymsp[-1].minor.yy0 = yylhsminor.yy0;
break; break;
case 157: /* tagitem ::= NULL */ case 155: /* tagitem1 ::= INTEGER */
{ yymsp[0].minor.yy0.type = 0; taosVariantCreate(&yylhsminor.yy69, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.type); } case 156: /* tagitem1 ::= FLOAT */ yytestcase(yyruleno==156);
yymsp[0].minor.yy69 = yylhsminor.yy69; case 157: /* tagitem1 ::= STRING */ yytestcase(yyruleno==157);
case 158: /* tagitem1 ::= BOOL */ yytestcase(yyruleno==158);
case 159: /* tagitem1 ::= NULL */ yytestcase(yyruleno==159);
case 160: /* tagitem1 ::= NOW */ yytestcase(yyruleno==160);
{ yylhsminor.yy0 = yymsp[0].minor.yy0; }
yymsp[0].minor.yy0 = yylhsminor.yy0;
break;
case 167: /* tagitem ::= NULL */
{ yymsp[0].minor.yy0.type = 0; taosVariantCreate(&yylhsminor.yy461, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.type); }
yymsp[0].minor.yy461 = yylhsminor.yy461;
break; break;
case 158: /* tagitem ::= NOW */ case 168: /* tagitem ::= NOW */
{ yymsp[0].minor.yy0.type = TSDB_DATA_TYPE_TIMESTAMP; taosVariantCreate(&yylhsminor.yy69, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.type);} { yymsp[0].minor.yy0.type = TSDB_DATA_TYPE_TIMESTAMP; taosVariantCreate(&yylhsminor.yy461, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.type);}
yymsp[0].minor.yy69 = yylhsminor.yy69; yymsp[0].minor.yy461 = yylhsminor.yy461;
break; break;
case 159: /* tagitem ::= MINUS INTEGER */ case 169: /* tagitem ::= MINUS INTEGER */
case 160: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==160); case 170: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==170);
case 161: /* tagitem ::= PLUS INTEGER */ yytestcase(yyruleno==161); case 171: /* tagitem ::= PLUS INTEGER */ yytestcase(yyruleno==171);
case 162: /* tagitem ::= PLUS FLOAT */ yytestcase(yyruleno==162); case 172: /* tagitem ::= PLUS FLOAT */ yytestcase(yyruleno==172);
{ {
yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n;
yymsp[-1].minor.yy0.type = yymsp[0].minor.yy0.type; yymsp[-1].minor.yy0.type = yymsp[0].minor.yy0.type;
toTSDBType(yymsp[-1].minor.yy0.type); toTSDBType(yymsp[-1].minor.yy0.type);
taosVariantCreate(&yylhsminor.yy69, yymsp[-1].minor.yy0.z, yymsp[-1].minor.yy0.n, yymsp[-1].minor.yy0.type); taosVariantCreate(&yylhsminor.yy461, yymsp[-1].minor.yy0.z, yymsp[-1].minor.yy0.n, yymsp[-1].minor.yy0.type);
} }
yymsp[-1].minor.yy69 = yylhsminor.yy69; yymsp[-1].minor.yy461 = yylhsminor.yy461;
break; break;
case 163: /* select ::= SELECT selcollist from where_opt interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ case 173: /* select ::= SELECT selcollist from where_opt interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */
{ {
yylhsminor.yy56 = tSetQuerySqlNode(&yymsp[-13].minor.yy0, yymsp[-12].minor.yy421, yymsp[-11].minor.yy8, yymsp[-10].minor.yy439, yymsp[-4].minor.yy421, yymsp[-2].minor.yy421, &yymsp[-9].minor.yy400, &yymsp[-7].minor.yy147, &yymsp[-6].minor.yy40, &yymsp[-8].minor.yy0, yymsp[-5].minor.yy421, &yymsp[0].minor.yy231, &yymsp[-1].minor.yy231, yymsp[-3].minor.yy439); yylhsminor.yy24 = tSetQuerySqlNode(&yymsp[-13].minor.yy0, yymsp[-12].minor.yy413, yymsp[-11].minor.yy292, yymsp[-10].minor.yy370, yymsp[-4].minor.yy413, yymsp[-2].minor.yy413, &yymsp[-9].minor.yy136, &yymsp[-7].minor.yy251, &yymsp[-6].minor.yy256, &yymsp[-8].minor.yy0, yymsp[-5].minor.yy413, &yymsp[0].minor.yy503, &yymsp[-1].minor.yy503, yymsp[-3].minor.yy370);
} }
yymsp[-13].minor.yy56 = yylhsminor.yy56; yymsp[-13].minor.yy24 = yylhsminor.yy24;
break; break;
case 164: /* select ::= LP select RP */ case 174: /* select ::= LP select RP */
{yymsp[-2].minor.yy56 = yymsp[-1].minor.yy56;} {yymsp[-2].minor.yy24 = yymsp[-1].minor.yy24;}
break; break;
case 165: /* union ::= select */ case 175: /* union ::= select */
{ yylhsminor.yy149 = setSubclause(NULL, yymsp[0].minor.yy56); } { yylhsminor.yy129 = setSubclause(NULL, yymsp[0].minor.yy24); }
yymsp[0].minor.yy149 = yylhsminor.yy149; yymsp[0].minor.yy129 = yylhsminor.yy129;
break; break;
case 166: /* union ::= union UNION ALL select */ case 176: /* union ::= union UNION ALL select */
{ yylhsminor.yy149 = appendSelectClause(yymsp[-3].minor.yy149, SQL_TYPE_UNIONALL, yymsp[0].minor.yy56); } { yylhsminor.yy129 = appendSelectClause(yymsp[-3].minor.yy129, SQL_TYPE_UNIONALL, yymsp[0].minor.yy24); }
yymsp[-3].minor.yy149 = yylhsminor.yy149; yymsp[-3].minor.yy129 = yylhsminor.yy129;
break; break;
case 167: /* union ::= union UNION select */ case 177: /* union ::= union UNION select */
{ yylhsminor.yy149 = appendSelectClause(yymsp[-2].minor.yy149, SQL_TYPE_UNION, yymsp[0].minor.yy56); } { yylhsminor.yy129 = appendSelectClause(yymsp[-2].minor.yy129, SQL_TYPE_UNION, yymsp[0].minor.yy24); }
yymsp[-2].minor.yy149 = yylhsminor.yy149; yymsp[-2].minor.yy129 = yylhsminor.yy129;
break; break;
case 168: /* cmd ::= union */ case 178: /* cmd ::= union */
{ setSqlInfo(pInfo, yymsp[0].minor.yy149, NULL, TSDB_SQL_SELECT); } { setSqlInfo(pInfo, yymsp[0].minor.yy129, NULL, TSDB_SQL_SELECT); }
break; break;
case 169: /* select ::= SELECT selcollist */ case 179: /* select ::= SELECT selcollist */
{ {
yylhsminor.yy56 = tSetQuerySqlNode(&yymsp[-1].minor.yy0, yymsp[0].minor.yy421, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); yylhsminor.yy24 = tSetQuerySqlNode(&yymsp[-1].minor.yy0, yymsp[0].minor.yy413, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
} }
yymsp[-1].minor.yy56 = yylhsminor.yy56; yymsp[-1].minor.yy24 = yylhsminor.yy24;
break; break;
case 170: /* sclp ::= selcollist COMMA */ case 180: /* sclp ::= selcollist COMMA */
{yylhsminor.yy421 = yymsp[-1].minor.yy421;} {yylhsminor.yy413 = yymsp[-1].minor.yy413;}
yymsp[-1].minor.yy421 = yylhsminor.yy421; yymsp[-1].minor.yy413 = yylhsminor.yy413;
break; break;
case 171: /* sclp ::= */ case 181: /* sclp ::= */
case 203: /* orderby_opt ::= */ yytestcase(yyruleno==203); case 213: /* orderby_opt ::= */ yytestcase(yyruleno==213);
{yymsp[1].minor.yy421 = 0;} {yymsp[1].minor.yy413 = 0;}
break; break;
case 172: /* selcollist ::= sclp distinct expr as */ case 182: /* selcollist ::= sclp distinct expr as */
{ {
yylhsminor.yy421 = tSqlExprListAppend(yymsp[-3].minor.yy421, yymsp[-1].minor.yy439, yymsp[-2].minor.yy0.n? &yymsp[-2].minor.yy0:0, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); yylhsminor.yy413 = tSqlExprListAppend(yymsp[-3].minor.yy413, yymsp[-1].minor.yy370, yymsp[-2].minor.yy0.n? &yymsp[-2].minor.yy0:0, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0);
} }
yymsp[-3].minor.yy421 = yylhsminor.yy421; yymsp[-3].minor.yy413 = yylhsminor.yy413;
break; break;
case 173: /* selcollist ::= sclp STAR */ case 183: /* selcollist ::= sclp STAR */
{ {
tSqlExpr *pNode = tSqlExprCreateIdValue(NULL, TK_ALL); tSqlExpr *pNode = tSqlExprCreateIdValue(NULL, TK_ALL);
yylhsminor.yy421 = tSqlExprListAppend(yymsp[-1].minor.yy421, pNode, 0, 0); yylhsminor.yy413 = tSqlExprListAppend(yymsp[-1].minor.yy413, pNode, 0, 0);
} }
yymsp[-1].minor.yy421 = yylhsminor.yy421; yymsp[-1].minor.yy413 = yylhsminor.yy413;
break; break;
case 174: /* as ::= AS ids */ case 184: /* as ::= AS ids */
{ yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; }
break; break;
case 175: /* as ::= ids */ case 185: /* as ::= ids */
{ yylhsminor.yy0 = yymsp[0].minor.yy0; } { yylhsminor.yy0 = yymsp[0].minor.yy0; }
yymsp[0].minor.yy0 = yylhsminor.yy0; yymsp[0].minor.yy0 = yylhsminor.yy0;
break; break;
case 176: /* as ::= */ case 186: /* as ::= */
{ yymsp[1].minor.yy0.n = 0; } { yymsp[1].minor.yy0.n = 0; }
break; break;
case 177: /* distinct ::= DISTINCT */ case 187: /* distinct ::= DISTINCT */
{ yylhsminor.yy0 = yymsp[0].minor.yy0; } { yylhsminor.yy0 = yymsp[0].minor.yy0; }
yymsp[0].minor.yy0 = yylhsminor.yy0; yymsp[0].minor.yy0 = yylhsminor.yy0;
break; break;
case 179: /* from ::= FROM tablelist */ case 189: /* from ::= FROM tablelist */
case 180: /* from ::= FROM sub */ yytestcase(yyruleno==180); case 190: /* from ::= FROM sub */ yytestcase(yyruleno==190);
{yymsp[-1].minor.yy8 = yymsp[0].minor.yy8;} {yymsp[-1].minor.yy292 = yymsp[0].minor.yy292;}
break; break;
case 181: /* sub ::= LP union RP */ case 191: /* sub ::= LP union RP */
{yymsp[-2].minor.yy8 = addSubquery(NULL, yymsp[-1].minor.yy149, NULL);} {yymsp[-2].minor.yy292 = addSubquery(NULL, yymsp[-1].minor.yy129, NULL);}
break; break;
case 182: /* sub ::= LP union RP ids */ case 192: /* sub ::= LP union RP ids */
{yymsp[-3].minor.yy8 = addSubquery(NULL, yymsp[-2].minor.yy149, &yymsp[0].minor.yy0);} {yymsp[-3].minor.yy292 = addSubquery(NULL, yymsp[-2].minor.yy129, &yymsp[0].minor.yy0);}
break; break;
case 183: /* sub ::= sub COMMA LP union RP ids */ case 193: /* sub ::= sub COMMA LP union RP ids */
{yylhsminor.yy8 = addSubquery(yymsp[-5].minor.yy8, yymsp[-2].minor.yy149, &yymsp[0].minor.yy0);} {yylhsminor.yy292 = addSubquery(yymsp[-5].minor.yy292, yymsp[-2].minor.yy129, &yymsp[0].minor.yy0);}
yymsp[-5].minor.yy8 = yylhsminor.yy8; yymsp[-5].minor.yy292 = yylhsminor.yy292;
break; break;
case 184: /* tablelist ::= ids cpxName */ case 194: /* tablelist ::= ids cpxName */
{ {
yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n;
yylhsminor.yy8 = setTableNameList(NULL, &yymsp[-1].minor.yy0, NULL); yylhsminor.yy292 = setTableNameList(NULL, &yymsp[-1].minor.yy0, NULL);
} }
yymsp[-1].minor.yy8 = yylhsminor.yy8; yymsp[-1].minor.yy292 = yylhsminor.yy292;
break; break;
case 185: /* tablelist ::= ids cpxName ids */ case 195: /* tablelist ::= ids cpxName ids */
{ {
yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n;
yylhsminor.yy8 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); yylhsminor.yy292 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
} }
yymsp[-2].minor.yy8 = yylhsminor.yy8; yymsp[-2].minor.yy292 = yylhsminor.yy292;
break; break;
case 186: /* tablelist ::= tablelist COMMA ids cpxName */ case 196: /* tablelist ::= tablelist COMMA ids cpxName */
{ {
yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n;
yylhsminor.yy8 = setTableNameList(yymsp[-3].minor.yy8, &yymsp[-1].minor.yy0, NULL); yylhsminor.yy292 = setTableNameList(yymsp[-3].minor.yy292, &yymsp[-1].minor.yy0, NULL);
} }
yymsp[-3].minor.yy8 = yylhsminor.yy8; yymsp[-3].minor.yy292 = yylhsminor.yy292;
break; break;
case 187: /* tablelist ::= tablelist COMMA ids cpxName ids */ case 197: /* tablelist ::= tablelist COMMA ids cpxName ids */
{ {
yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n;
yylhsminor.yy8 = setTableNameList(yymsp[-4].minor.yy8, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); yylhsminor.yy292 = setTableNameList(yymsp[-4].minor.yy292, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
} }
yymsp[-4].minor.yy8 = yylhsminor.yy8; yymsp[-4].minor.yy292 = yylhsminor.yy292;
break; break;
case 188: /* tmvar ::= VARIABLE */ case 198: /* tmvar ::= VARIABLE */
{yylhsminor.yy0 = yymsp[0].minor.yy0;} {yylhsminor.yy0 = yymsp[0].minor.yy0;}
yymsp[0].minor.yy0 = yylhsminor.yy0; yymsp[0].minor.yy0 = yylhsminor.yy0;
break; break;
case 189: /* interval_option ::= intervalKey LP tmvar RP */ case 199: /* interval_option ::= intervalKey LP tmvar RP */
{yylhsminor.yy400.interval = yymsp[-1].minor.yy0; yylhsminor.yy400.offset.n = 0; yylhsminor.yy400.token = yymsp[-3].minor.yy104;} {yylhsminor.yy136.interval = yymsp[-1].minor.yy0; yylhsminor.yy136.offset.n = 0; yylhsminor.yy136.token = yymsp[-3].minor.yy516;}
yymsp[-3].minor.yy400 = yylhsminor.yy400; yymsp[-3].minor.yy136 = yylhsminor.yy136;
break; break;
case 190: /* interval_option ::= intervalKey LP tmvar COMMA tmvar RP */ case 200: /* interval_option ::= intervalKey LP tmvar COMMA tmvar RP */
{yylhsminor.yy400.interval = yymsp[-3].minor.yy0; yylhsminor.yy400.offset = yymsp[-1].minor.yy0; yylhsminor.yy400.token = yymsp[-5].minor.yy104;} {yylhsminor.yy136.interval = yymsp[-3].minor.yy0; yylhsminor.yy136.offset = yymsp[-1].minor.yy0; yylhsminor.yy136.token = yymsp[-5].minor.yy516;}
yymsp[-5].minor.yy400 = yylhsminor.yy400; yymsp[-5].minor.yy136 = yylhsminor.yy136;
break; break;
case 191: /* interval_option ::= */ case 201: /* interval_option ::= */
{memset(&yymsp[1].minor.yy400, 0, sizeof(yymsp[1].minor.yy400));} {memset(&yymsp[1].minor.yy136, 0, sizeof(yymsp[1].minor.yy136));}
break; break;
case 192: /* intervalKey ::= INTERVAL */ case 202: /* intervalKey ::= INTERVAL */
{yymsp[0].minor.yy104 = TK_INTERVAL;} {yymsp[0].minor.yy516 = TK_INTERVAL;}
break; break;
case 193: /* intervalKey ::= EVERY */ case 203: /* intervalKey ::= EVERY */
{yymsp[0].minor.yy104 = TK_EVERY; } {yymsp[0].minor.yy516 = TK_EVERY; }
break; break;
case 194: /* session_option ::= */ case 204: /* session_option ::= */
{yymsp[1].minor.yy147.col.n = 0; yymsp[1].minor.yy147.gap.n = 0;} {yymsp[1].minor.yy251.col.n = 0; yymsp[1].minor.yy251.gap.n = 0;}
break; break;
case 195: /* session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ case 205: /* session_option ::= SESSION LP ids cpxName COMMA tmvar RP */
{ {
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
yymsp[-6].minor.yy147.col = yymsp[-4].minor.yy0; yymsp[-6].minor.yy251.col = yymsp[-4].minor.yy0;
yymsp[-6].minor.yy147.gap = yymsp[-1].minor.yy0; yymsp[-6].minor.yy251.gap = yymsp[-1].minor.yy0;
} }
break; break;
case 196: /* windowstate_option ::= */ case 206: /* windowstate_option ::= */
{ yymsp[1].minor.yy40.col.n = 0; yymsp[1].minor.yy40.col.z = NULL;} { yymsp[1].minor.yy256.col.n = 0; yymsp[1].minor.yy256.col.z = NULL;}
break; break;
case 197: /* windowstate_option ::= STATE_WINDOW LP ids RP */ case 207: /* windowstate_option ::= STATE_WINDOW LP ids RP */
{ yymsp[-3].minor.yy40.col = yymsp[-1].minor.yy0; } { yymsp[-3].minor.yy256.col = yymsp[-1].minor.yy0; }
break; break;
case 198: /* fill_opt ::= */ case 208: /* fill_opt ::= */
{ yymsp[1].minor.yy421 = 0; } { yymsp[1].minor.yy413 = 0; }
break; break;
case 199: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ case 209: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */
{ {
SVariant A = {0}; SVariant A = {0};
toTSDBType(yymsp[-3].minor.yy0.type); toTSDBType(yymsp[-3].minor.yy0.type);
taosVariantCreate(&A, yymsp[-3].minor.yy0.z, yymsp[-3].minor.yy0.n, yymsp[-3].minor.yy0.type); taosVariantCreate(&A, yymsp[-3].minor.yy0.z, yymsp[-3].minor.yy0.n, yymsp[-3].minor.yy0.type);
tListItemInsert(yymsp[-1].minor.yy421, &A, -1, 0); tListItemInsert(yymsp[-1].minor.yy413, &A, -1, 0);
yymsp[-5].minor.yy421 = yymsp[-1].minor.yy421; yymsp[-5].minor.yy413 = yymsp[-1].minor.yy413;
} }
break; break;
case 200: /* fill_opt ::= FILL LP ID RP */ case 210: /* fill_opt ::= FILL LP ID RP */
{ {
toTSDBType(yymsp[-1].minor.yy0.type); toTSDBType(yymsp[-1].minor.yy0.type);
yymsp[-3].minor.yy421 = tListItemAppendToken(NULL, &yymsp[-1].minor.yy0, -1); yymsp[-3].minor.yy413 = tListItemAppendToken(NULL, &yymsp[-1].minor.yy0, -1);
} }
break; break;
case 201: /* sliding_opt ::= SLIDING LP tmvar RP */ case 211: /* sliding_opt ::= SLIDING LP tmvar RP */
{yymsp[-3].minor.yy0 = yymsp[-1].minor.yy0; } {yymsp[-3].minor.yy0 = yymsp[-1].minor.yy0; }
break; break;
case 202: /* sliding_opt ::= */ case 212: /* sliding_opt ::= */
{yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = NULL; yymsp[1].minor.yy0.type = 0; } {yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = NULL; yymsp[1].minor.yy0.type = 0; }
break; break;
case 204: /* orderby_opt ::= ORDER BY sortlist */ case 214: /* orderby_opt ::= ORDER BY sortlist */
{yymsp[-2].minor.yy421 = yymsp[0].minor.yy421;} {yymsp[-2].minor.yy413 = yymsp[0].minor.yy413;}
break; break;
case 205: /* sortlist ::= sortlist COMMA item sortorder */ case 215: /* sortlist ::= sortlist COMMA item sortorder */
{ {
yylhsminor.yy421 = tListItemAppend(yymsp[-3].minor.yy421, &yymsp[-1].minor.yy69, yymsp[0].minor.yy96); yylhsminor.yy413 = tListItemAppend(yymsp[-3].minor.yy413, &yymsp[-1].minor.yy461, yymsp[0].minor.yy60);
} }
yymsp[-3].minor.yy421 = yylhsminor.yy421; yymsp[-3].minor.yy413 = yylhsminor.yy413;
break; break;
case 206: /* sortlist ::= item sortorder */ case 216: /* sortlist ::= item sortorder */
{ {
yylhsminor.yy421 = tListItemAppend(NULL, &yymsp[-1].minor.yy69, yymsp[0].minor.yy96); yylhsminor.yy413 = tListItemAppend(NULL, &yymsp[-1].minor.yy461, yymsp[0].minor.yy60);
} }
yymsp[-1].minor.yy421 = yylhsminor.yy421; yymsp[-1].minor.yy413 = yylhsminor.yy413;
break; break;
case 207: /* item ::= ids cpxName */ case 217: /* item ::= ids cpxName */
{ {
toTSDBType(yymsp[-1].minor.yy0.type); toTSDBType(yymsp[-1].minor.yy0.type);
yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n;
taosVariantCreate(&yylhsminor.yy69, yymsp[-1].minor.yy0.z, yymsp[-1].minor.yy0.n, yymsp[-1].minor.yy0.type); taosVariantCreate(&yylhsminor.yy461, yymsp[-1].minor.yy0.z, yymsp[-1].minor.yy0.n, yymsp[-1].minor.yy0.type);
} }
yymsp[-1].minor.yy69 = yylhsminor.yy69; yymsp[-1].minor.yy461 = yylhsminor.yy461;
break; break;
case 208: /* sortorder ::= ASC */ case 218: /* sortorder ::= ASC */
{ yymsp[0].minor.yy96 = TSDB_ORDER_ASC; } { yymsp[0].minor.yy60 = TSDB_ORDER_ASC; }
break; break;
case 209: /* sortorder ::= DESC */ case 219: /* sortorder ::= DESC */
{ yymsp[0].minor.yy96 = TSDB_ORDER_DESC;} { yymsp[0].minor.yy60 = TSDB_ORDER_DESC;}
break; break;
case 210: /* sortorder ::= */ case 220: /* sortorder ::= */
{ yymsp[1].minor.yy96 = TSDB_ORDER_ASC; } { yymsp[1].minor.yy60 = TSDB_ORDER_ASC; }
break; break;
case 211: /* groupby_opt ::= */ case 221: /* groupby_opt ::= */
{ yymsp[1].minor.yy421 = 0;} { yymsp[1].minor.yy413 = 0;}
break; break;
case 212: /* groupby_opt ::= GROUP BY grouplist */ case 222: /* groupby_opt ::= GROUP BY grouplist */
{ yymsp[-2].minor.yy421 = yymsp[0].minor.yy421;} { yymsp[-2].minor.yy413 = yymsp[0].minor.yy413;}
break; break;
case 213: /* grouplist ::= grouplist COMMA item */ case 223: /* grouplist ::= grouplist COMMA item */
{ {
yylhsminor.yy421 = tListItemAppend(yymsp[-2].minor.yy421, &yymsp[0].minor.yy69, -1); yylhsminor.yy413 = tListItemAppend(yymsp[-2].minor.yy413, &yymsp[0].minor.yy461, -1);
} }
yymsp[-2].minor.yy421 = yylhsminor.yy421; yymsp[-2].minor.yy413 = yylhsminor.yy413;
break; break;
case 214: /* grouplist ::= item */ case 224: /* grouplist ::= item */
{ {
yylhsminor.yy421 = tListItemAppend(NULL, &yymsp[0].minor.yy69, -1); yylhsminor.yy413 = tListItemAppend(NULL, &yymsp[0].minor.yy461, -1);
} }
yymsp[0].minor.yy421 = yylhsminor.yy421; yymsp[0].minor.yy413 = yylhsminor.yy413;
break; break;
case 215: /* having_opt ::= */ case 225: /* having_opt ::= */
case 225: /* where_opt ::= */ yytestcase(yyruleno==225); case 235: /* where_opt ::= */ yytestcase(yyruleno==235);
case 269: /* expritem ::= */ yytestcase(yyruleno==269); case 279: /* expritem ::= */ yytestcase(yyruleno==279);
{yymsp[1].minor.yy439 = 0;} {yymsp[1].minor.yy370 = 0;}
break; break;
case 216: /* having_opt ::= HAVING expr */ case 226: /* having_opt ::= HAVING expr */
case 226: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==226); case 236: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==236);
{yymsp[-1].minor.yy439 = yymsp[0].minor.yy439;} {yymsp[-1].minor.yy370 = yymsp[0].minor.yy370;}
break; break;
case 217: /* limit_opt ::= */ case 227: /* limit_opt ::= */
case 221: /* slimit_opt ::= */ yytestcase(yyruleno==221); case 231: /* slimit_opt ::= */ yytestcase(yyruleno==231);
{yymsp[1].minor.yy231.limit = -1; yymsp[1].minor.yy231.offset = 0;} {yymsp[1].minor.yy503.limit = -1; yymsp[1].minor.yy503.offset = 0;}
break; break;
case 218: /* limit_opt ::= LIMIT signed */ case 228: /* limit_opt ::= LIMIT signed */
case 222: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==222); case 232: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==232);
{yymsp[-1].minor.yy231.limit = yymsp[0].minor.yy325; yymsp[-1].minor.yy231.offset = 0;} {yymsp[-1].minor.yy503.limit = yymsp[0].minor.yy157; yymsp[-1].minor.yy503.offset = 0;}
break; break;
case 219: /* limit_opt ::= LIMIT signed OFFSET signed */ case 229: /* limit_opt ::= LIMIT signed OFFSET signed */
{ yymsp[-3].minor.yy231.limit = yymsp[-2].minor.yy325; yymsp[-3].minor.yy231.offset = yymsp[0].minor.yy325;} { yymsp[-3].minor.yy503.limit = yymsp[-2].minor.yy157; yymsp[-3].minor.yy503.offset = yymsp[0].minor.yy157;}
break; break;
case 220: /* limit_opt ::= LIMIT signed COMMA signed */ case 230: /* limit_opt ::= LIMIT signed COMMA signed */
{ yymsp[-3].minor.yy231.limit = yymsp[0].minor.yy325; yymsp[-3].minor.yy231.offset = yymsp[-2].minor.yy325;} { yymsp[-3].minor.yy503.limit = yymsp[0].minor.yy157; yymsp[-3].minor.yy503.offset = yymsp[-2].minor.yy157;}
break; break;
case 223: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ case 233: /* slimit_opt ::= SLIMIT signed SOFFSET signed */
{yymsp[-3].minor.yy231.limit = yymsp[-2].minor.yy325; yymsp[-3].minor.yy231.offset = yymsp[0].minor.yy325;} {yymsp[-3].minor.yy503.limit = yymsp[-2].minor.yy157; yymsp[-3].minor.yy503.offset = yymsp[0].minor.yy157;}
break; break;
case 224: /* slimit_opt ::= SLIMIT signed COMMA signed */ case 234: /* slimit_opt ::= SLIMIT signed COMMA signed */
{yymsp[-3].minor.yy231.limit = yymsp[0].minor.yy325; yymsp[-3].minor.yy231.offset = yymsp[-2].minor.yy325;} {yymsp[-3].minor.yy503.limit = yymsp[0].minor.yy157; yymsp[-3].minor.yy503.offset = yymsp[-2].minor.yy157;}
break; break;
case 227: /* expr ::= LP expr RP */ case 237: /* expr ::= LP expr RP */
{yylhsminor.yy439 = yymsp[-1].minor.yy439; yylhsminor.yy439->exprToken.z = yymsp[-2].minor.yy0.z; yylhsminor.yy439->exprToken.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);} {yylhsminor.yy370 = yymsp[-1].minor.yy370; yylhsminor.yy370->exprToken.z = yymsp[-2].minor.yy0.z; yylhsminor.yy370->exprToken.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);}
yymsp[-2].minor.yy439 = yylhsminor.yy439; yymsp[-2].minor.yy370 = yylhsminor.yy370;
break; break;
case 228: /* expr ::= ID */ case 238: /* expr ::= ID */
{ yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_ID);} { yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_ID);}
yymsp[0].minor.yy439 = yylhsminor.yy439; yymsp[0].minor.yy370 = yylhsminor.yy370;
break; break;
case 229: /* expr ::= ID DOT ID */ case 239: /* expr ::= ID DOT ID */
{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ID);} { yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ID);}
yymsp[-2].minor.yy439 = yylhsminor.yy439; yymsp[-2].minor.yy370 = yylhsminor.yy370;
break; break;
case 230: /* expr ::= ID DOT STAR */ case 240: /* expr ::= ID DOT STAR */
{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ALL);} { yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ALL);}
yymsp[-2].minor.yy439 = yylhsminor.yy439; yymsp[-2].minor.yy370 = yylhsminor.yy370;
break; break;
case 231: /* expr ::= INTEGER */ case 241: /* expr ::= INTEGER */
{ yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_INTEGER);} { yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_INTEGER);}
yymsp[0].minor.yy439 = yylhsminor.yy439; yymsp[0].minor.yy370 = yylhsminor.yy370;
break; break;
case 232: /* expr ::= MINUS INTEGER */ case 242: /* expr ::= MINUS INTEGER */
case 233: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==233); case 243: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==243);
{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_INTEGER);} { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_INTEGER);}
yymsp[-1].minor.yy439 = yylhsminor.yy439; yymsp[-1].minor.yy370 = yylhsminor.yy370;
break; break;
case 234: /* expr ::= FLOAT */ case 244: /* expr ::= FLOAT */
{ yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_FLOAT);} { yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_FLOAT);}
yymsp[0].minor.yy439 = yylhsminor.yy439; yymsp[0].minor.yy370 = yylhsminor.yy370;
break; break;
case 235: /* expr ::= MINUS FLOAT */ case 245: /* expr ::= MINUS FLOAT */
case 236: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==236); case 246: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==246);
{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_FLOAT);} { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_FLOAT);}
yymsp[-1].minor.yy439 = yylhsminor.yy439; yymsp[-1].minor.yy370 = yylhsminor.yy370;
break; break;
case 237: /* expr ::= STRING */ case 247: /* expr ::= STRING */
{ yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_STRING);} { yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_STRING);}
yymsp[0].minor.yy439 = yylhsminor.yy439; yymsp[0].minor.yy370 = yylhsminor.yy370;
break; break;
case 238: /* expr ::= NOW */ case 248: /* expr ::= NOW */
{ yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NOW); } { yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NOW); }
yymsp[0].minor.yy439 = yylhsminor.yy439; yymsp[0].minor.yy370 = yylhsminor.yy370;
break; break;
case 239: /* expr ::= VARIABLE */ case 249: /* expr ::= VARIABLE */
{ yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_VARIABLE);} { yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_VARIABLE);}
yymsp[0].minor.yy439 = yylhsminor.yy439; yymsp[0].minor.yy370 = yylhsminor.yy370;
break; break;
case 240: /* expr ::= PLUS VARIABLE */ case 250: /* expr ::= PLUS VARIABLE */
case 241: /* expr ::= MINUS VARIABLE */ yytestcase(yyruleno==241); case 251: /* expr ::= MINUS VARIABLE */ yytestcase(yyruleno==251);
{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_VARIABLE; yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_VARIABLE);} { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_VARIABLE; yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_VARIABLE);}
yymsp[-1].minor.yy439 = yylhsminor.yy439; yymsp[-1].minor.yy370 = yylhsminor.yy370;
break; break;
case 242: /* expr ::= BOOL */ case 252: /* expr ::= BOOL */
{ yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_BOOL);} { yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_BOOL);}
yymsp[0].minor.yy439 = yylhsminor.yy439; yymsp[0].minor.yy370 = yylhsminor.yy370;
break; break;
case 243: /* expr ::= NULL */ case 253: /* expr ::= NULL */
{ yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NULL);} { yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NULL);}
yymsp[0].minor.yy439 = yylhsminor.yy439; yymsp[0].minor.yy370 = yylhsminor.yy370;
break; break;
case 244: /* expr ::= ID LP exprlist RP */ case 254: /* expr ::= ID LP exprlist RP */
{ tRecordFuncName(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy439 = tSqlExprCreateFunction(yymsp[-1].minor.yy421, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } { tRecordFuncName(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy370 = tSqlExprCreateFunction(yymsp[-1].minor.yy413, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); }
yymsp[-3].minor.yy439 = yylhsminor.yy439; yymsp[-3].minor.yy370 = yylhsminor.yy370;
break; break;
case 245: /* expr ::= ID LP STAR RP */ case 255: /* expr ::= ID LP STAR RP */
{ tRecordFuncName(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy439 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } { tRecordFuncName(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy370 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); }
yymsp[-3].minor.yy439 = yylhsminor.yy439; yymsp[-3].minor.yy370 = yylhsminor.yy370;
break; break;
case 246: /* expr ::= expr IS NULL */ case 256: /* expr ::= expr IS NULL */
{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, NULL, TK_ISNULL);} {yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, NULL, TK_ISNULL);}
yymsp[-2].minor.yy439 = yylhsminor.yy439; yymsp[-2].minor.yy370 = yylhsminor.yy370;
break; break;
case 247: /* expr ::= expr IS NOT NULL */ case 257: /* expr ::= expr IS NOT NULL */
{yylhsminor.yy439 = tSqlExprCreate(yymsp[-3].minor.yy439, NULL, TK_NOTNULL);} {yylhsminor.yy370 = tSqlExprCreate(yymsp[-3].minor.yy370, NULL, TK_NOTNULL);}
yymsp[-3].minor.yy439 = yylhsminor.yy439; yymsp[-3].minor.yy370 = yylhsminor.yy370;
break; break;
case 248: /* expr ::= expr LT expr */ case 258: /* expr ::= expr LT expr */
{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_LT);} {yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_LT);}
yymsp[-2].minor.yy439 = yylhsminor.yy439; yymsp[-2].minor.yy370 = yylhsminor.yy370;
break; break;
case 249: /* expr ::= expr GT expr */ case 259: /* expr ::= expr GT expr */
{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_GT);} {yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_GT);}
yymsp[-2].minor.yy439 = yylhsminor.yy439; yymsp[-2].minor.yy370 = yylhsminor.yy370;
break; break;
case 250: /* expr ::= expr LE expr */ case 260: /* expr ::= expr LE expr */
{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_LE);} {yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_LE);}
yymsp[-2].minor.yy439 = yylhsminor.yy439; yymsp[-2].minor.yy370 = yylhsminor.yy370;
break; break;
case 251: /* expr ::= expr GE expr */ case 261: /* expr ::= expr GE expr */
{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_GE);} {yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_GE);}
yymsp[-2].minor.yy439 = yylhsminor.yy439; yymsp[-2].minor.yy370 = yylhsminor.yy370;
break; break;
case 252: /* expr ::= expr NE expr */ case 262: /* expr ::= expr NE expr */
{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_NE);} {yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_NE);}
yymsp[-2].minor.yy439 = yylhsminor.yy439; yymsp[-2].minor.yy370 = yylhsminor.yy370;
break; break;
case 253: /* expr ::= expr EQ expr */ case 263: /* expr ::= expr EQ expr */
{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_EQ);} {yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_EQ);}
yymsp[-2].minor.yy439 = yylhsminor.yy439; yymsp[-2].minor.yy370 = yylhsminor.yy370;
break; break;
case 254: /* expr ::= expr BETWEEN expr AND expr */ case 264: /* expr ::= expr BETWEEN expr AND expr */
{ tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy439); yylhsminor.yy439 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy439, yymsp[-2].minor.yy439, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy439, TK_LE), TK_AND);} { tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy370); yylhsminor.yy370 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy370, yymsp[-2].minor.yy370, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy370, TK_LE), TK_AND);}
yymsp[-4].minor.yy439 = yylhsminor.yy439; yymsp[-4].minor.yy370 = yylhsminor.yy370;
break; break;
case 255: /* expr ::= expr AND expr */ case 265: /* expr ::= expr AND expr */
{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_AND);} {yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_AND);}
yymsp[-2].minor.yy439 = yylhsminor.yy439; yymsp[-2].minor.yy370 = yylhsminor.yy370;
break; break;
case 256: /* expr ::= expr OR expr */ case 266: /* expr ::= expr OR expr */
{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_OR); } {yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_OR); }
yymsp[-2].minor.yy439 = yylhsminor.yy439; yymsp[-2].minor.yy370 = yylhsminor.yy370;
break; break;
case 257: /* expr ::= expr PLUS expr */ case 267: /* expr ::= expr PLUS expr */
{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_PLUS); } {yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_PLUS); }
yymsp[-2].minor.yy439 = yylhsminor.yy439; yymsp[-2].minor.yy370 = yylhsminor.yy370;
break; break;
case 258: /* expr ::= expr MINUS expr */ case 268: /* expr ::= expr MINUS expr */
{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_MINUS); } {yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_MINUS); }
yymsp[-2].minor.yy439 = yylhsminor.yy439; yymsp[-2].minor.yy370 = yylhsminor.yy370;
break; break;
case 259: /* expr ::= expr STAR expr */ case 269: /* expr ::= expr STAR expr */
{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_STAR); } {yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_STAR); }
yymsp[-2].minor.yy439 = yylhsminor.yy439; yymsp[-2].minor.yy370 = yylhsminor.yy370;
break; break;
case 260: /* expr ::= expr SLASH expr */ case 270: /* expr ::= expr SLASH expr */
{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_DIVIDE);} {yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_DIVIDE);}
yymsp[-2].minor.yy439 = yylhsminor.yy439; yymsp[-2].minor.yy370 = yylhsminor.yy370;
break; break;
case 261: /* expr ::= expr REM expr */ case 271: /* expr ::= expr REM expr */
{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_REM); } {yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_REM); }
yymsp[-2].minor.yy439 = yylhsminor.yy439; yymsp[-2].minor.yy370 = yylhsminor.yy370;
break; break;
case 262: /* expr ::= expr LIKE expr */ case 272: /* expr ::= expr LIKE expr */
{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_LIKE); } {yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_LIKE); }
yymsp[-2].minor.yy439 = yylhsminor.yy439; yymsp[-2].minor.yy370 = yylhsminor.yy370;
break; break;
case 263: /* expr ::= expr MATCH expr */ case 273: /* expr ::= expr MATCH expr */
{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_MATCH); } {yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_MATCH); }
yymsp[-2].minor.yy439 = yylhsminor.yy439; yymsp[-2].minor.yy370 = yylhsminor.yy370;
break; break;
case 264: /* expr ::= expr NMATCH expr */ case 274: /* expr ::= expr NMATCH expr */
{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_NMATCH); } {yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_NMATCH); }
yymsp[-2].minor.yy439 = yylhsminor.yy439; yymsp[-2].minor.yy370 = yylhsminor.yy370;
break; break;
case 265: /* expr ::= expr IN LP exprlist RP */ case 275: /* expr ::= expr IN LP exprlist RP */
{yylhsminor.yy439 = tSqlExprCreate(yymsp[-4].minor.yy439, (tSqlExpr*)yymsp[-1].minor.yy421, TK_IN); } {yylhsminor.yy370 = tSqlExprCreate(yymsp[-4].minor.yy370, (tSqlExpr*)yymsp[-1].minor.yy413, TK_IN); }
yymsp[-4].minor.yy439 = yylhsminor.yy439; yymsp[-4].minor.yy370 = yylhsminor.yy370;
break; break;
case 266: /* exprlist ::= exprlist COMMA expritem */ case 276: /* exprlist ::= exprlist COMMA expritem */
{yylhsminor.yy421 = tSqlExprListAppend(yymsp[-2].minor.yy421,yymsp[0].minor.yy439,0, 0);} {yylhsminor.yy413 = tSqlExprListAppend(yymsp[-2].minor.yy413,yymsp[0].minor.yy370,0, 0);}
yymsp[-2].minor.yy421 = yylhsminor.yy421; yymsp[-2].minor.yy413 = yylhsminor.yy413;
break; break;
case 267: /* exprlist ::= expritem */ case 277: /* exprlist ::= expritem */
{yylhsminor.yy421 = tSqlExprListAppend(0,yymsp[0].minor.yy439,0, 0);} {yylhsminor.yy413 = tSqlExprListAppend(0,yymsp[0].minor.yy370,0, 0);}
yymsp[0].minor.yy421 = yylhsminor.yy421; yymsp[0].minor.yy413 = yylhsminor.yy413;
break; break;
case 268: /* expritem ::= expr */ case 278: /* expritem ::= expr */
{yylhsminor.yy439 = yymsp[0].minor.yy439;} {yylhsminor.yy370 = yymsp[0].minor.yy370;}
yymsp[0].minor.yy439 = yylhsminor.yy439; yymsp[0].minor.yy370 = yylhsminor.yy370;
break; break;
case 270: /* cmd ::= RESET QUERY CACHE */ case 280: /* cmd ::= RESET QUERY CACHE */
{ setDCLSqlElems(pInfo, TSDB_SQL_RESET_CACHE, 0);} { setDCLSqlElems(pInfo, TSDB_SQL_RESET_CACHE, 0);}
break; break;
case 271: /* cmd ::= SYNCDB ids REPLICA */ case 281: /* cmd ::= SYNCDB ids REPLICA */
{ setDCLSqlElems(pInfo, TSDB_SQL_SYNC_DB_REPLICA, 1, &yymsp[-1].minor.yy0);} { setDCLSqlElems(pInfo, TSDB_SQL_SYNC_DB_REPLICA, 1, &yymsp[-1].minor.yy0);}
break; break;
case 272: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ case 282: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */
{ {
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy413, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 273: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ case 283: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */
{ {
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
toTSDBType(yymsp[0].minor.yy0.type); toTSDBType(yymsp[0].minor.yy0.type);
...@@ -3167,21 +3189,21 @@ static void yy_reduce( ...@@ -3167,21 +3189,21 @@ static void yy_reduce(
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 274: /* cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ case 284: /* cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */
{ {
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, -1); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy413, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, -1);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 275: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ case 285: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */
{ {
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy413, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 276: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ case 286: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */
{ {
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
...@@ -3192,7 +3214,7 @@ static void yy_reduce( ...@@ -3192,7 +3214,7 @@ static void yy_reduce(
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 277: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ case 287: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */
{ {
yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n;
...@@ -3206,33 +3228,33 @@ static void yy_reduce( ...@@ -3206,33 +3228,33 @@ static void yy_reduce(
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 278: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ case 288: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */
{ {
yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n; yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n;
toTSDBType(yymsp[-2].minor.yy0.type); toTSDBType(yymsp[-2].minor.yy0.type);
SArray* A = tListItemAppendToken(NULL, &yymsp[-2].minor.yy0, -1); SArray* A = tListItemAppendToken(NULL, &yymsp[-2].minor.yy0, -1);
A = tListItemAppend(A, &yymsp[0].minor.yy69, -1); A = tListItemAppend(A, &yymsp[0].minor.yy461, -1);
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-6].minor.yy0, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL, -1); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-6].minor.yy0, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL, -1);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 279: /* cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ case 289: /* cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */
{ {
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, -1); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy413, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, -1);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 280: /* cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ case 290: /* cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */
{ {
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy413, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 281: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ case 291: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */
{ {
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
...@@ -3243,21 +3265,21 @@ static void yy_reduce( ...@@ -3243,21 +3265,21 @@ static void yy_reduce(
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 282: /* cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ case 292: /* cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */
{ {
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, TSDB_SUPER_TABLE); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy413, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 283: /* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ case 293: /* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */
{ {
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy413, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 284: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ case 294: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */
{ {
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
...@@ -3268,7 +3290,7 @@ static void yy_reduce( ...@@ -3268,7 +3290,7 @@ static void yy_reduce(
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 285: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ case 295: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */
{ {
yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n;
...@@ -3282,32 +3304,32 @@ static void yy_reduce( ...@@ -3282,32 +3304,32 @@ static void yy_reduce(
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 286: /* cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ case 296: /* cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */
{ {
yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n; yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n;
toTSDBType(yymsp[-2].minor.yy0.type); toTSDBType(yymsp[-2].minor.yy0.type);
SArray* A = tListItemAppendToken(NULL, &yymsp[-2].minor.yy0, -1); SArray* A = tListItemAppendToken(NULL, &yymsp[-2].minor.yy0, -1);
A = tListItemAppend(A, &yymsp[0].minor.yy69, -1); A = tListItemAppend(A, &yymsp[0].minor.yy461, -1);
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-6].minor.yy0, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL, TSDB_SUPER_TABLE); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-6].minor.yy0, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 287: /* cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ case 297: /* cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */
{ {
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, TSDB_SUPER_TABLE); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy413, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 288: /* cmd ::= KILL CONNECTION INTEGER */ case 298: /* cmd ::= KILL CONNECTION INTEGER */
{setKillSql(pInfo, TSDB_SQL_KILL_CONNECTION, &yymsp[0].minor.yy0);} {setKillSql(pInfo, TSDB_SQL_KILL_CONNECTION, &yymsp[0].minor.yy0);}
break; break;
case 289: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */ case 299: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */
{yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setKillSql(pInfo, TSDB_SQL_KILL_STREAM, &yymsp[-2].minor.yy0);} {yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setKillSql(pInfo, TSDB_SQL_KILL_STREAM, &yymsp[-2].minor.yy0);}
break; break;
case 290: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */ case 300: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */
{yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setKillSql(pInfo, TSDB_SQL_KILL_QUERY, &yymsp[-2].minor.yy0);} {yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setKillSql(pInfo, TSDB_SQL_KILL_QUERY, &yymsp[-2].minor.yy0);}
break; break;
default: default:
......
...@@ -31,17 +31,17 @@ typedef struct SKeyword { ...@@ -31,17 +31,17 @@ typedef struct SKeyword {
static SKeyword keywordTable[] = { static SKeyword keywordTable[] = {
{"ID", TK_ID}, {"ID", TK_ID},
{"BOOL", TK_BOOL}, {"BOOL", TK_BOOL},
{"TINYINT", TK_TINYINT}, // {"TINYINT", TK_TINYINT},
{"SMALLINT", TK_SMALLINT}, // {"SMALLINT", TK_SMALLINT},
{"INTEGER", TK_INTEGER}, {"INTEGER", TK_INTEGER},
{"INT", TK_INTEGER}, {"INT", TK_INTEGER},
{"BIGINT", TK_BIGINT}, // {"BIGINT", TK_BIGINT},
{"FLOAT", TK_FLOAT}, {"FLOAT", TK_FLOAT},
{"DOUBLE", TK_DOUBLE}, // {"DOUBLE", TK_DOUBLE},
{"STRING", TK_STRING}, {"STRING", TK_STRING},
{"TIMESTAMP", TK_TIMESTAMP}, {"TIMESTAMP", TK_TIMESTAMP},
{"BINARY", TK_BINARY}, // {"BINARY", TK_BINARY},
{"NCHAR", TK_NCHAR}, // {"NCHAR", TK_NCHAR},
{"OR", TK_OR}, {"OR", TK_OR},
{"AND", TK_AND}, {"AND", TK_AND},
{"NOT", TK_NOT}, {"NOT", TK_NOT},
...@@ -672,7 +672,7 @@ SToken tStrGetToken(const char* str, int32_t* i, bool isPrevOptr) { ...@@ -672,7 +672,7 @@ SToken tStrGetToken(const char* str, int32_t* i, bool isPrevOptr) {
} }
} }
t0.z = str + (*i); t0.z = (char*) str + (*i);
*i += t0.n; *i += t0.n;
return t0; return t0;
......
...@@ -715,7 +715,7 @@ TEST(testCase, show_user_Test) { ...@@ -715,7 +715,7 @@ TEST(testCase, show_user_Test) {
ASSERT_EQ(info1.valid, true); ASSERT_EQ(info1.valid, true);
SDclStmtInfo output; SDclStmtInfo output;
SParseBasicCtx ct= {.db= "abc", .acctId = 1, .requestId = 1}; SParseBasicCtx ct= {.requestId = 1, .acctId = 1, .db = "abc", .pTransporter = NULL};
int32_t code = qParserValidateDclSqlNode(&info1, &ct, &output, msg, buf.len); int32_t code = qParserValidateDclSqlNode(&info1, &ct, &output, msg, buf.len);
ASSERT_EQ(code, 0); ASSERT_EQ(code, 0);
...@@ -736,7 +736,7 @@ TEST(testCase, create_user_Test) { ...@@ -736,7 +736,7 @@ TEST(testCase, create_user_Test) {
ASSERT_EQ(isDclSqlStatement(&info1), true); ASSERT_EQ(isDclSqlStatement(&info1), true);
SDclStmtInfo output; SDclStmtInfo output;
SParseBasicCtx ct= {.db= "abc", .acctId = 1, .requestId = 1}; SParseBasicCtx ct= {.requestId = 1, .acctId = 1, .db = "abc"};
int32_t code = qParserValidateDclSqlNode(&info1, &ct, &output, msg, buf.len); int32_t code = qParserValidateDclSqlNode(&info1, &ct, &output, msg, buf.len);
ASSERT_EQ(code, 0); ASSERT_EQ(code, 0);
......
...@@ -857,3 +857,84 @@ int32_t stringToSubplan(const char* str, SSubplan** subplan) { ...@@ -857,3 +857,84 @@ int32_t stringToSubplan(const char* str, SSubplan** subplan) {
*subplan = subplanFromJson(json); *subplan = subplanFromJson(json);
return (NULL == *subplan ? TSDB_CODE_FAILED : TSDB_CODE_SUCCESS); return (NULL == *subplan ? TSDB_CODE_FAILED : TSDB_CODE_SUCCESS);
} }
cJSON* qDagToJson(const SQueryDag* pDag) {
cJSON* pRoot = cJSON_CreateObject();
if(pRoot == NULL) {
return NULL;
}
cJSON_AddNumberToObject(pRoot, "numOfSubplans", pDag->numOfSubplans);
cJSON_AddNumberToObject(pRoot, "queryId", pDag->queryId);
cJSON *pLevels = cJSON_CreateArray();
if(pLevels == NULL) {
cJSON_Delete(pRoot);
return NULL;
}
cJSON_AddItemToObject(pRoot, "pSubplans", pLevels);
size_t level = taosArrayGetSize(pDag->pSubplans);
for(size_t i = 0; i < level; i++) {
const SArray* pSubplans = (const SArray*)taosArrayGetP(pDag->pSubplans, i);
size_t num = taosArrayGetSize(pSubplans);
cJSON* plansOneLevel = cJSON_CreateArray();
if(plansOneLevel == NULL) {
cJSON_Delete(pRoot);
return NULL;
}
cJSON_AddItemToArray(pLevels, plansOneLevel);
for(size_t j = 0; j < num; j++) {
cJSON* pSubplan = subplanToJson((const SSubplan*)taosArrayGetP(pSubplans, j));
if(pSubplan == NULL) {
cJSON_Delete(pRoot);
return NULL;
}
cJSON_AddItemToArray(plansOneLevel, pSubplan);
}
}
return pRoot;
}
char* qDagToString(const SQueryDag* pDag) {
cJSON* pRoot = qDagToJson(pDag);
return cJSON_Print(pRoot);
}
SQueryDag* qJsonToDag(const cJSON* pRoot) {
SQueryDag* pDag = malloc(sizeof(SQueryDag));
if(pDag == NULL) {
return NULL;
}
pDag->numOfSubplans = cJSON_GetNumberValue(cJSON_GetObjectItem(pRoot, "numOfSubplans"));
pDag->queryId = cJSON_GetNumberValue(cJSON_GetObjectItem(pRoot, "queryId"));
pDag->pSubplans = taosArrayInit(0, sizeof(SArray));
if (pDag->pSubplans == NULL) {
free(pDag);
return NULL;
}
cJSON* pLevels = cJSON_GetObjectItem(pRoot, "pSubplans");
int level = cJSON_GetArraySize(pLevels);
for(int i = 0; i < level; i++) {
SArray* plansOneLevel = taosArrayInit(0, sizeof(void*));
if(plansOneLevel == NULL) {
for(int j = 0; j < i; j++) {
taosArrayDestroy(taosArrayGetP(pDag->pSubplans, j));
}
taosArrayDestroy(pDag->pSubplans);
free(pDag);
return NULL;
}
cJSON* pItem = cJSON_GetArrayItem(pLevels, i);
int sz = cJSON_GetArraySize(pItem);
for(int j = 0; j < sz; j++) {
cJSON* pSubplanJson = cJSON_GetArrayItem(pItem, j);
SSubplan* pSubplan = subplanFromJson(pSubplanJson);
taosArrayPush(plansOneLevel, &pSubplan);
}
taosArrayPush(pDag->pSubplans, plansOneLevel);
}
return pDag;
}
SQueryDag* qStringToDag(const char* pStr) {
cJSON* pRoot = cJSON_Parse(pStr);
return qJsonToDag(pRoot);
}
...@@ -83,7 +83,7 @@ protected: ...@@ -83,7 +83,7 @@ protected:
} }
} }
SQueryDag* reslut() { SQueryDag* result() {
return dag_.get(); return dag_.get();
} }
...@@ -149,16 +149,23 @@ TEST_F(PhyPlanTest, tableScanTest) { ...@@ -149,16 +149,23 @@ TEST_F(PhyPlanTest, tableScanTest) {
pushScan("test", "t1", QNODE_TABLESCAN); pushScan("test", "t1", QNODE_TABLESCAN);
ASSERT_EQ(run(), TSDB_CODE_SUCCESS); ASSERT_EQ(run(), TSDB_CODE_SUCCESS);
explain(); explain();
SQueryDag* dag = reslut(); SQueryDag* dag = result();
// todo check // todo check
} }
TEST_F(PhyPlanTest, serializeTest) {
pushScan("test", "t1", QNODE_TABLESCAN);
ASSERT_EQ(run(), TSDB_CODE_SUCCESS);
SQueryDag* dag = result();
cout << qDagToString(dag) << endl;
}
// select * from supertable // select * from supertable
TEST_F(PhyPlanTest, superTableScanTest) { TEST_F(PhyPlanTest, superTableScanTest) {
pushScan("test", "st1", QNODE_TABLESCAN); pushScan("test", "st1", QNODE_TABLESCAN);
ASSERT_EQ(run(), TSDB_CODE_SUCCESS); ASSERT_EQ(run(), TSDB_CODE_SUCCESS);
explain(); explain();
SQueryDag* dag = reslut(); SQueryDag* dag = result();
// todo check // todo check
} }
...@@ -166,6 +173,6 @@ TEST_F(PhyPlanTest, superTableScanTest) { ...@@ -166,6 +173,6 @@ TEST_F(PhyPlanTest, superTableScanTest) {
TEST_F(PhyPlanTest, insertTest) { TEST_F(PhyPlanTest, insertTest) {
ASSERT_EQ(run("test", "insert into t1 values (now, 1, \"beijing\")"), TSDB_CODE_SUCCESS); ASSERT_EQ(run("test", "insert into t1 values (now, 1, \"beijing\")"), TSDB_CODE_SUCCESS);
explain(); explain();
SQueryDag* dag = reslut(); SQueryDag* dag = result();
// todo check // todo check
} }
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "tmsg.h" #include "tmsg.h"
#include "queryInt.h" #include "queryInt.h"
#include "query.h" #include "query.h"
#include "trpc.h"
int32_t (*queryBuildMsg[TDMT_MAX])(void* input, char **msg, int32_t msgSize, int32_t *msgLen) = {0}; int32_t (*queryBuildMsg[TDMT_MAX])(void* input, char **msg, int32_t msgSize, int32_t *msgLen) = {0};
...@@ -31,7 +32,7 @@ int32_t queryBuildTableMetaReqMsg(void* input, char **msg, int32_t msgSize, int3 ...@@ -31,7 +32,7 @@ int32_t queryBuildTableMetaReqMsg(void* input, char **msg, int32_t msgSize, int3
int32_t estimateSize = sizeof(STableInfoMsg); int32_t estimateSize = sizeof(STableInfoMsg);
if (NULL == *msg || msgSize < estimateSize) { if (NULL == *msg || msgSize < estimateSize) {
tfree(*msg); tfree(*msg);
*msg = calloc(1, estimateSize); *msg = rpcMallocCont(estimateSize);
if (NULL == *msg) { if (NULL == *msg) {
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
...@@ -59,7 +60,7 @@ int32_t queryBuildUseDbMsg(void* input, char **msg, int32_t msgSize, int32_t *ms ...@@ -59,7 +60,7 @@ int32_t queryBuildUseDbMsg(void* input, char **msg, int32_t msgSize, int32_t *ms
int32_t estimateSize = sizeof(SUseDbMsg); int32_t estimateSize = sizeof(SUseDbMsg);
if (NULL == *msg || msgSize < estimateSize) { if (NULL == *msg || msgSize < estimateSize) {
tfree(*msg); tfree(*msg);
*msg = calloc(1, estimateSize); *msg = rpcMallocCont(estimateSize);
if (NULL == *msg) { if (NULL == *msg) {
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
...@@ -265,11 +266,13 @@ int32_t queryProcessTableMetaRsp(void* output, char *msg, int32_t msgSize) { ...@@ -265,11 +266,13 @@ int32_t queryProcessTableMetaRsp(void* output, char *msg, int32_t msgSize) {
void initQueryModuleMsgHandle() { void initQueryModuleMsgHandle() {
queryBuildMsg[TDMT_VND_TABLE_META] = queryBuildTableMetaReqMsg; queryBuildMsg[TMSG_INDEX(TDMT_VND_TABLE_META)] = queryBuildTableMetaReqMsg;
queryBuildMsg[TDMT_MND_USE_DB] = queryBuildUseDbMsg; queryBuildMsg[TMSG_INDEX(TDMT_MND_STB_META)] = queryBuildTableMetaReqMsg;
queryBuildMsg[TMSG_INDEX(TDMT_MND_USE_DB)] = queryBuildUseDbMsg;
queryProcessMsgRsp[TDMT_VND_TABLE_META] = queryProcessTableMetaRsp; queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_TABLE_META)] = queryProcessTableMetaRsp;
queryProcessMsgRsp[TDMT_MND_USE_DB] = queryProcessUseDBRsp; queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_STB_META)] = queryProcessTableMetaRsp;
queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_USE_DB)] = queryProcessUseDBRsp;
} }
......
...@@ -42,25 +42,41 @@ enum { ...@@ -42,25 +42,41 @@ enum {
QW_WRITE, QW_WRITE,
}; };
typedef struct SQWorkerTaskStatus { enum {
QW_EXIST_ACQUIRE = 1,
QW_EXIST_RET_ERR,
};
enum {
QW_NOT_EXIST_RET_ERR = 1,
QW_NOT_EXIST_ADD,
};
enum {
QW_ADD_RET_ERR = 1,
QW_ADD_ACQUIRE,
};
typedef struct SQWTaskStatus {
SRWLatch lock; SRWLatch lock;
int32_t code; int32_t code;
int8_t status; int8_t status;
int8_t ready; int8_t ready;
bool cancel; bool cancel;
bool drop; bool drop;
} SQWorkerTaskStatus; } SQWTaskStatus;
typedef struct SQWorkerResCache { typedef struct SQWorkerResCache {
SRWLatch lock; SRWLatch lock;
void *data; void *data;
} SQWorkerResCache; } SQWorkerResCache;
typedef struct SQWorkerSchStatus { typedef struct SQWSchStatus {
int32_t lastAccessTs; // timestamp in second int32_t lastAccessTs; // timestamp in second
SRWLatch tasksLock; SRWLatch tasksLock;
SHashObj *tasksHash; // key:queryId+taskId, value: SQWorkerTaskStatus SHashObj *tasksHash; // key:queryId+taskId, value: SQWorkerTaskStatus
} SQWorkerSchStatus; } SQWSchStatus;
// Qnode/Vnode level task management // Qnode/Vnode level task management
typedef struct SQWorkerMgmt { typedef struct SQWorkerMgmt {
...@@ -71,7 +87,7 @@ typedef struct SQWorkerMgmt { ...@@ -71,7 +87,7 @@ typedef struct SQWorkerMgmt {
SHashObj *resHash; //key: queryId+taskId, value: SQWorkerResCache SHashObj *resHash; //key: queryId+taskId, value: SQWorkerResCache
} SQWorkerMgmt; } SQWorkerMgmt;
#define QW_GOT_RES_DATA(data) (false) #define QW_GOT_RES_DATA(data) (true)
#define QW_LOW_RES_DATA(data) (false) #define QW_LOW_RES_DATA(data) (false)
#define QW_TASK_NOT_EXIST(code) (TSDB_CODE_QRY_SCH_NOT_EXIST == (code) || TSDB_CODE_QRY_TASK_NOT_EXIST == (code)) #define QW_TASK_NOT_EXIST(code) (TSDB_CODE_QRY_SCH_NOT_EXIST == (code) || TSDB_CODE_QRY_TASK_NOT_EXIST == (code))
...@@ -86,8 +102,31 @@ typedef struct SQWorkerMgmt { ...@@ -86,8 +102,31 @@ typedef struct SQWorkerMgmt {
#define QW_ERR_LRET(c,...) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { qError(__VA_ARGS__); terrno = _code; return _code; } } while (0) #define QW_ERR_LRET(c,...) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { qError(__VA_ARGS__); terrno = _code; return _code; } } while (0)
#define QW_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0) #define QW_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0)
#define QW_LOCK(type, _lock) (QW_READ == (type) ? taosRLockLatch(_lock) : taosWLockLatch(_lock)) #define QW_LOCK(type, _lock) do { \
#define QW_UNLOCK(type, _lock) (QW_READ == (type) ? taosRUnLockLatch(_lock) : taosWUnLockLatch(_lock)) if (QW_READ == (type)) { \
if ((*(_lock)) < 0) assert(0); \
taosRLockLatch(_lock); \
qDebug("RLOCK%p, %s:%d", (_lock), __FILE__, __LINE__); \
} else { \
if ((*(_lock)) < 0) assert(0); \
taosWLockLatch(_lock); \
qDebug("WLOCK%p, %s:%d", (_lock), __FILE__, __LINE__); \
} \
} while (0)
#define QW_UNLOCK(type, _lock) do { \
if (QW_READ == (type)) { \
if ((*(_lock)) <= 0) assert(0); \
taosRUnLockLatch(_lock); \
qDebug("RULOCK%p, %s:%d", (_lock), __FILE__, __LINE__); \
} else { \
if ((*(_lock)) <= 0) assert(0); \
taosWUnLockLatch(_lock); \
qDebug("WULOCK%p, %s:%d", (_lock), __FILE__, __LINE__); \
} \
} while (0)
static int32_t qwAcquireScheduler(int32_t rwType, SQWorkerMgmt *mgmt, uint64_t sId, SQWSchStatus **sch, int32_t nOpt);
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -4,38 +4,42 @@ ...@@ -4,38 +4,42 @@
#include "qworkerInt.h" #include "qworkerInt.h"
#include "planner.h" #include "planner.h"
int32_t qwCheckStatusSwitch(int8_t oriStatus, int8_t newStatus) { int32_t qwValidateStatus(int8_t oriStatus, int8_t newStatus) {
int32_t code = 0; int32_t code = 0;
if (oriStatus == newStatus) { if (oriStatus == newStatus) {
if (newStatus == JOB_TASK_STATUS_CANCELLING) {
return TSDB_CODE_SUCCESS;
}
QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
} }
switch (oriStatus) { switch (oriStatus) {
case JOB_TASK_STATUS_NULL: case JOB_TASK_STATUS_NULL:
if (newStatus != JOB_TASK_STATUS_EXECUTING && newStatus != JOB_TASK_STATUS_FAILED ) { if (newStatus != JOB_TASK_STATUS_EXECUTING
&& newStatus != JOB_TASK_STATUS_FAILED
&& newStatus != JOB_TASK_STATUS_NOT_START) {
QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
} }
break; break;
case JOB_TASK_STATUS_NOT_START: case JOB_TASK_STATUS_NOT_START:
if (newStatus != JOB_TASK_STATUS_EXECUTING && newStatus != JOB_TASK_STATUS_FAILED) { if (newStatus != JOB_TASK_STATUS_CANCELLED) {
QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
} }
break; break;
case JOB_TASK_STATUS_EXECUTING: case JOB_TASK_STATUS_EXECUTING:
if (newStatus != JOB_TASK_STATUS_SUCCEED && newStatus != JOB_TASK_STATUS_FAILED && newStatus != JOB_TASK_STATUS_CANCELLING) { if (newStatus != JOB_TASK_STATUS_PARTIAL_SUCCEED
&& newStatus != JOB_TASK_STATUS_FAILED
&& newStatus != JOB_TASK_STATUS_CANCELLING
&& newStatus != JOB_TASK_STATUS_CANCELLED
&& newStatus != JOB_TASK_STATUS_DROPPING) {
QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
} }
break; break;
case JOB_TASK_STATUS_PARTIAL_SUCCEED: case JOB_TASK_STATUS_PARTIAL_SUCCEED:
if (newStatus != JOB_TASK_STATUS_EXECUTING && newStatus != JOB_TASK_STATUS_CANCELLING) { if (newStatus != JOB_TASK_STATUS_EXECUTING
&& newStatus != JOB_TASK_STATUS_SUCCEED
&& newStatus != JOB_TASK_STATUS_CANCELLED) {
QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
} }
...@@ -49,6 +53,10 @@ int32_t qwCheckStatusSwitch(int8_t oriStatus, int8_t newStatus) { ...@@ -49,6 +53,10 @@ int32_t qwCheckStatusSwitch(int8_t oriStatus, int8_t newStatus) {
break; break;
case JOB_TASK_STATUS_CANCELLED: case JOB_TASK_STATUS_CANCELLED:
case JOB_TASK_STATUS_DROPPING:
QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
break;
default: default:
qError("invalid task status:%d", oriStatus); qError("invalid task status:%d", oriStatus);
return TSDB_CODE_QRY_APP_ERROR; return TSDB_CODE_QRY_APP_ERROR;
...@@ -58,17 +66,17 @@ int32_t qwCheckStatusSwitch(int8_t oriStatus, int8_t newStatus) { ...@@ -58,17 +66,17 @@ int32_t qwCheckStatusSwitch(int8_t oriStatus, int8_t newStatus) {
_return: _return:
qError("invalid task status:%d", oriStatus); qError("invalid task status, from %d to %d", oriStatus, newStatus);
QW_ERR_RET(code); QW_ERR_RET(code);
} }
int32_t qwUpdateTaskInfo(SQWorkerTaskStatus *task, int8_t type, void *data) { int32_t qwUpdateTaskInfo(SQWTaskStatus *task, int8_t type, void *data) {
int32_t code = 0; int32_t code = 0;
switch (type) { switch (type) {
case QW_TASK_INFO_STATUS: { case QW_TASK_INFO_STATUS: {
int8_t newStatus = *(int8_t *)data; int8_t newStatus = *(int8_t *)data;
QW_ERR_RET(qwCheckStatusSwitch(task->status, newStatus)); QW_ERR_RET(qwValidateStatus(task->status, newStatus));
task->status = newStatus; task->status = newStatus;
break; break;
} }
...@@ -80,9 +88,9 @@ int32_t qwUpdateTaskInfo(SQWorkerTaskStatus *task, int8_t type, void *data) { ...@@ -80,9 +88,9 @@ int32_t qwUpdateTaskInfo(SQWorkerTaskStatus *task, int8_t type, void *data) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t qwAddTaskResult(SQWorkerMgmt *mgmt, uint64_t queryId, uint64_t taskId, void *data) { int32_t qwAddTaskResCache(SQWorkerMgmt *mgmt, uint64_t qId, uint64_t tId, void *data) {
char id[sizeof(queryId) + sizeof(taskId)] = {0}; char id[sizeof(qId) + sizeof(tId)] = {0};
QW_SET_QTID(id, queryId, taskId); QW_SET_QTID(id, qId, tId);
SQWorkerResCache resCache = {0}; SQWorkerResCache resCache = {0};
resCache.data = data; resCache.data = data;
...@@ -90,7 +98,7 @@ int32_t qwAddTaskResult(SQWorkerMgmt *mgmt, uint64_t queryId, uint64_t taskId, v ...@@ -90,7 +98,7 @@ int32_t qwAddTaskResult(SQWorkerMgmt *mgmt, uint64_t queryId, uint64_t taskId, v
QW_LOCK(QW_WRITE, &mgmt->resLock); QW_LOCK(QW_WRITE, &mgmt->resLock);
if (0 != taosHashPut(mgmt->resHash, id, sizeof(id), &resCache, sizeof(SQWorkerResCache))) { if (0 != taosHashPut(mgmt->resHash, id, sizeof(id), &resCache, sizeof(SQWorkerResCache))) {
QW_UNLOCK(QW_WRITE, &mgmt->resLock); QW_UNLOCK(QW_WRITE, &mgmt->resLock);
qError("taosHashPut queryId[%"PRIx64"] taskId[%"PRIx64"] to resHash failed", queryId, taskId); qError("taosHashPut queryId[%"PRIx64"] taskId[%"PRIx64"] to resHash failed", qId, tId);
return TSDB_CODE_QRY_APP_ERROR; return TSDB_CODE_QRY_APP_ERROR;
} }
...@@ -99,37 +107,8 @@ int32_t qwAddTaskResult(SQWorkerMgmt *mgmt, uint64_t queryId, uint64_t taskId, v ...@@ -99,37 +107,8 @@ int32_t qwAddTaskResult(SQWorkerMgmt *mgmt, uint64_t queryId, uint64_t taskId, v
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
static int32_t qwAddScheduler(int32_t rwType, SQWorkerMgmt *mgmt, uint64_t sId, SQWSchStatus **sch) {
int32_t qwGetTaskResult(SQWorkerMgmt *mgmt, uint64_t queryId, uint64_t taskId, void **data) { SQWSchStatus newSch = {0};
char id[sizeof(queryId) + sizeof(taskId)] = {0};
QW_SET_QTID(id, queryId, taskId);
SQWorkerResCache *resCache = taosHashGet(mgmt->resHash, id, sizeof(id));
if (NULL == resCache) {
qError("no task res for queryId[%"PRIx64"] taskId[%"PRIx64"]", queryId, taskId);
return TSDB_CODE_QRY_APP_ERROR;
}
*data = resCache->data;
return TSDB_CODE_SUCCESS;
}
static FORCE_INLINE int32_t qwAcquireScheduler(int32_t rwType, SQWorkerMgmt *mgmt, uint64_t schedulerId, SQWorkerSchStatus **sch) {
QW_LOCK(rwType, &mgmt->schLock);
*sch = taosHashGet(mgmt->schHash, &schedulerId, sizeof(schedulerId));
if (NULL == (*sch)) {
QW_LOCK(rwType, &mgmt->schLock);
return TSDB_CODE_QRY_SCH_NOT_EXIST;
}
return TSDB_CODE_SUCCESS;
}
static FORCE_INLINE int32_t qwInsertAndAcquireScheduler(int32_t rwType, SQWorkerMgmt *mgmt, uint64_t schedulerId, SQWorkerSchStatus **sch) {
SQWorkerSchStatus newSch = {0};
newSch.tasksHash = taosHashInit(mgmt->cfg.maxSchTaskNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); newSch.tasksHash = taosHashInit(mgmt->cfg.maxSchTaskNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
if (NULL == newSch.tasksHash) { if (NULL == newSch.tasksHash) {
qError("taosHashInit %d failed", mgmt->cfg.maxSchTaskNum); qError("taosHashInit %d failed", mgmt->cfg.maxSchTaskNum);
...@@ -138,19 +117,18 @@ static FORCE_INLINE int32_t qwInsertAndAcquireScheduler(int32_t rwType, SQWorker ...@@ -138,19 +117,18 @@ static FORCE_INLINE int32_t qwInsertAndAcquireScheduler(int32_t rwType, SQWorker
while (true) { while (true) {
QW_LOCK(QW_WRITE, &mgmt->schLock); QW_LOCK(QW_WRITE, &mgmt->schLock);
int32_t code = taosHashPut(mgmt->schHash, &schedulerId, sizeof(schedulerId), &newSch, sizeof(newSch)); int32_t code = taosHashPut(mgmt->schHash, &sId, sizeof(sId), &newSch, sizeof(newSch));
if (0 != code) { if (0 != code) {
if (!HASH_NODE_EXIST(code)) { if (!HASH_NODE_EXIST(code)) {
QW_UNLOCK(QW_WRITE, &mgmt->schLock); QW_UNLOCK(QW_WRITE, &mgmt->schLock);
qError("taosHashPut schedulerId[%"PRIx64"] to scheduleHash failed", schedulerId); qError("taosHashPut sId[%"PRIx64"] to scheduleHash failed", sId);
taosHashCleanup(newSch.tasksHash); taosHashCleanup(newSch.tasksHash);
return TSDB_CODE_QRY_APP_ERROR; return TSDB_CODE_QRY_APP_ERROR;
} }
} }
QW_UNLOCK(QW_WRITE, &mgmt->schLock); QW_UNLOCK(QW_WRITE, &mgmt->schLock);
if (TSDB_CODE_SUCCESS == qwAcquireScheduler(rwType, mgmt, schedulerId, sch)) { if (TSDB_CODE_SUCCESS == qwAcquireScheduler(rwType, mgmt, sId, sch, QW_NOT_EXIST_ADD)) {
taosHashCleanup(newSch.tasksHash);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
} }
...@@ -159,63 +137,122 @@ static FORCE_INLINE int32_t qwInsertAndAcquireScheduler(int32_t rwType, SQWorker ...@@ -159,63 +137,122 @@ static FORCE_INLINE int32_t qwInsertAndAcquireScheduler(int32_t rwType, SQWorker
} }
static int32_t qwAcquireScheduler(int32_t rwType, SQWorkerMgmt *mgmt, uint64_t sId, SQWSchStatus **sch, int32_t nOpt) {
QW_LOCK(rwType, &mgmt->schLock);
*sch = taosHashGet(mgmt->schHash, &sId, sizeof(sId));
if (NULL == (*sch)) {
QW_UNLOCK(rwType, &mgmt->schLock);
if (QW_NOT_EXIST_ADD == nOpt) {
return qwAddScheduler(rwType, mgmt, sId, sch);
} else if (QW_NOT_EXIST_RET_ERR == nOpt) {
return TSDB_CODE_QRY_SCH_NOT_EXIST;
} else {
assert(0);
}
}
return TSDB_CODE_SUCCESS;
}
static FORCE_INLINE void qwReleaseScheduler(int32_t rwType, SQWorkerMgmt *mgmt) { static FORCE_INLINE void qwReleaseScheduler(int32_t rwType, SQWorkerMgmt *mgmt) {
QW_UNLOCK(rwType, &mgmt->schLock); QW_UNLOCK(rwType, &mgmt->schLock);
} }
static FORCE_INLINE int32_t qwAcquireTask(int32_t rwType, SQWorkerSchStatus *sch, uint64_t queryId, uint64_t taskId, SQWorkerTaskStatus **task) { static int32_t qwAcquireTaskImpl(int32_t rwType, SQWSchStatus *sch, uint64_t qId, uint64_t tId, SQWTaskStatus **task) {
char id[sizeof(queryId) + sizeof(taskId)] = {0}; char id[sizeof(qId) + sizeof(tId)] = {0};
QW_SET_QTID(id, queryId, taskId); QW_SET_QTID(id, qId, tId);
QW_LOCK(rwType, &sch->tasksLock); QW_LOCK(rwType, &sch->tasksLock);
*task = taosHashGet(sch->tasksHash, id, sizeof(id)); *task = taosHashGet(sch->tasksHash, id, sizeof(id));
if (NULL == (*task)) { if (NULL == (*task)) {
QW_UNLOCK(rwType, &sch->tasksLock); QW_UNLOCK(rwType, &sch->tasksLock);
return TSDB_CODE_QRY_TASK_NOT_EXIST; return TSDB_CODE_QRY_TASK_NOT_EXIST;
} }
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
static FORCE_INLINE int32_t qwInsertAndAcquireTask(int32_t rwType, SQWorkerSchStatus *sch, uint64_t queryId, uint64_t taskId, int8_t status, bool *inserted, SQWorkerTaskStatus **task) { static int32_t qwAcquireTask(int32_t rwType, SQWSchStatus *sch, uint64_t qId, uint64_t tId, SQWTaskStatus **task) {
char id[sizeof(queryId) + sizeof(taskId)] = {0}; return qwAcquireTaskImpl(rwType, sch, qId, tId, task);
QW_SET_QTID(id, queryId, taskId); }
while (true) {
*inserted = false;
static FORCE_INLINE void qwReleaseTask(int32_t rwType, SQWSchStatus *sch) {
QW_UNLOCK(rwType, &sch->tasksLock);
}
int32_t qwAddTaskToSch(int32_t rwType, SQWSchStatus *sch, uint64_t qId, uint64_t tId, int8_t status, int32_t eOpt, SQWTaskStatus **task) {
int32_t code = 0;
char id[sizeof(qId) + sizeof(tId)] = {0};
QW_SET_QTID(id, qId, tId);
SQWTaskStatus ntask = {0};
ntask.status = status;
while (true) {
QW_LOCK(QW_WRITE, &sch->tasksLock); QW_LOCK(QW_WRITE, &sch->tasksLock);
int32_t code = taosHashPut(sch->tasksHash, id, sizeof(id), &status, sizeof(status)); int32_t code = taosHashPut(sch->tasksHash, id, sizeof(id), &ntask, sizeof(ntask));
if (0 != code) { if (0 != code) {
QW_UNLOCK(QW_WRITE, &sch->tasksLock); QW_UNLOCK(QW_WRITE, &sch->tasksLock);
if (HASH_NODE_EXIST(code)) { if (HASH_NODE_EXIST(code)) {
if (qwAcquireTask(rwType, sch, queryId, taskId, task)) { if (QW_EXIST_ACQUIRE == eOpt && rwType && task) {
if (qwAcquireTask(rwType, sch, qId, tId, task)) {
continue; continue;
} }
} else if (QW_EXIST_RET_ERR == eOpt) {
return TSDB_CODE_QRY_TASK_ALREADY_EXIST;
} else {
assert(0);
}
break; break;
} else { } else {
qError("taosHashPut queryId[%"PRIx64"] taskId[%"PRIx64"] to scheduleHash failed", queryId, taskId); qError("taosHashPut queryId[%"PRIx64"] taskId[%"PRIx64"] to scheduleHash failed", qId, tId);
return TSDB_CODE_QRY_APP_ERROR; return TSDB_CODE_QRY_APP_ERROR;
} }
} }
QW_UNLOCK(QW_WRITE, &sch->tasksLock);
*inserted = true; QW_UNLOCK(QW_WRITE, &sch->tasksLock);
if (TSDB_CODE_SUCCESS == qwAcquireTask(rwType, sch, queryId, taskId, task)) { if (rwType && task) {
if (TSDB_CODE_SUCCESS == qwAcquireTask(rwType, sch, qId, tId, task)) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
} else {
break;
}
} }
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
static FORCE_INLINE void qwReleaseTask(int32_t rwType, SQWorkerSchStatus *sch) { static int32_t qwAddTask(SQWorkerMgmt *mgmt, uint64_t sId, uint64_t qId, uint64_t tId, int32_t status, int32_t eOpt, SQWSchStatus **sch, SQWTaskStatus **task) {
QW_UNLOCK(rwType, &sch->tasksLock); SQWSchStatus *tsch = NULL;
QW_ERR_RET(qwAcquireScheduler(QW_READ, mgmt, sId, &tsch, QW_NOT_EXIST_ADD));
int32_t code = qwAddTaskToSch(QW_READ, tsch, qId, tId, status, eOpt, task);
if (code) {
qwReleaseScheduler(QW_WRITE, mgmt);
}
if (NULL == task) {
qwReleaseScheduler(QW_READ, mgmt);
} else if (sch) {
*sch = tsch;
}
QW_RET(code);
} }
static FORCE_INLINE int32_t qwAcquireTaskResCache(int32_t rwType, SQWorkerMgmt *mgmt, uint64_t queryId, uint64_t taskId, SQWorkerResCache **res) { static FORCE_INLINE int32_t qwAcquireTaskResCache(int32_t rwType, SQWorkerMgmt *mgmt, uint64_t queryId, uint64_t taskId, SQWorkerResCache **res) {
char id[sizeof(queryId) + sizeof(taskId)] = {0}; char id[sizeof(queryId) + sizeof(taskId)] = {0};
QW_SET_QTID(id, queryId, taskId); QW_SET_QTID(id, queryId, taskId);
...@@ -235,27 +272,24 @@ static FORCE_INLINE void qwReleaseTaskResCache(int32_t rwType, SQWorkerMgmt *mgm ...@@ -235,27 +272,24 @@ static FORCE_INLINE void qwReleaseTaskResCache(int32_t rwType, SQWorkerMgmt *mgm
} }
int32_t qwGetSchTasksStatus(SQWorkerMgmt *mgmt, uint64_t schedulerId, SSchedulerStatusRsp **rsp) { int32_t qwGetSchTasksStatus(SQWorkerMgmt *mgmt, uint64_t sId, SSchedulerStatusRsp **rsp) {
SQWorkerSchStatus *schStatus = NULL; SQWSchStatus *sch = NULL;
int32_t taskNum = 0; int32_t taskNum = 0;
if (qwAcquireScheduler(QW_READ, mgmt, schedulerId, &schStatus)) { QW_ERR_RET(qwAcquireScheduler(QW_READ, mgmt, sId, &sch, QW_NOT_EXIST_RET_ERR));
qWarn("no scheduler for schedulerId[%"PRIx64"]", schedulerId);
} else {
schStatus->lastAccessTs = taosGetTimestampSec();
QW_LOCK(QW_READ, &schStatus->tasksLock); sch->lastAccessTs = taosGetTimestampSec();
taskNum = taosHashGetSize(schStatus->tasksHash);
} QW_LOCK(QW_READ, &sch->tasksLock);
taskNum = taosHashGetSize(sch->tasksHash);
int32_t size = sizeof(SSchedulerStatusRsp) + sizeof((*rsp)->status[0]) * taskNum; int32_t size = sizeof(SSchedulerStatusRsp) + sizeof((*rsp)->status[0]) * taskNum;
*rsp = calloc(1, size); *rsp = calloc(1, size);
if (NULL == *rsp) { if (NULL == *rsp) {
qError("calloc %d failed", size); qError("calloc %d failed", size);
if (schStatus) { QW_UNLOCK(QW_READ, &sch->tasksLock);
QW_UNLOCK(QW_READ, &schStatus->tasksLock);
qwReleaseScheduler(QW_READ, mgmt); qwReleaseScheduler(QW_READ, mgmt);
}
return TSDB_CODE_QRY_OUT_OF_MEMORY; return TSDB_CODE_QRY_OUT_OF_MEMORY;
} }
...@@ -264,23 +298,19 @@ int32_t qwGetSchTasksStatus(SQWorkerMgmt *mgmt, uint64_t schedulerId, SScheduler ...@@ -264,23 +298,19 @@ int32_t qwGetSchTasksStatus(SQWorkerMgmt *mgmt, uint64_t schedulerId, SScheduler
size_t keyLen = 0; size_t keyLen = 0;
int32_t i = 0; int32_t i = 0;
if (schStatus) { void *pIter = taosHashIterate(sch->tasksHash, NULL);
void *pIter = taosHashIterate(schStatus->tasksHash, NULL);
while (pIter) { while (pIter) {
SQWorkerTaskStatus *taskStatus = (SQWorkerTaskStatus *)pIter; SQWTaskStatus *taskStatus = (SQWTaskStatus *)pIter;
taosHashGetKey(pIter, &key, &keyLen); taosHashGetKey(pIter, &key, &keyLen);
QW_GET_QTID(key, (*rsp)->status[i].queryId, (*rsp)->status[i].taskId); QW_GET_QTID(key, (*rsp)->status[i].queryId, (*rsp)->status[i].taskId);
(*rsp)->status[i].status = taskStatus->status; (*rsp)->status[i].status = taskStatus->status;
pIter = taosHashIterate(schStatus->tasksHash, pIter); pIter = taosHashIterate(sch->tasksHash, pIter);
}
} }
if (schStatus) { QW_UNLOCK(QW_READ, &sch->tasksLock);
QW_UNLOCK(QW_READ, &schStatus->tasksLock);
qwReleaseScheduler(QW_READ, mgmt); qwReleaseScheduler(QW_READ, mgmt);
}
(*rsp)->num = taskNum; (*rsp)->num = taskNum;
...@@ -289,88 +319,58 @@ int32_t qwGetSchTasksStatus(SQWorkerMgmt *mgmt, uint64_t schedulerId, SScheduler ...@@ -289,88 +319,58 @@ int32_t qwGetSchTasksStatus(SQWorkerMgmt *mgmt, uint64_t schedulerId, SScheduler
int32_t qwUpdateSchLastAccess(SQWorkerMgmt *mgmt, uint64_t schedulerId) { int32_t qwUpdateSchLastAccess(SQWorkerMgmt *mgmt, uint64_t sId) {
SQWorkerSchStatus *schStatus = NULL; SQWSchStatus *sch = NULL;
QW_ERR_RET(qwAcquireScheduler(QW_READ, mgmt, schedulerId, &schStatus)); QW_ERR_RET(qwAcquireScheduler(QW_READ, mgmt, sId, &sch, QW_NOT_EXIST_RET_ERR));
schStatus->lastAccessTs = taosGetTimestampSec(); sch->lastAccessTs = taosGetTimestampSec();
qwReleaseScheduler(QW_READ, mgmt); qwReleaseScheduler(QW_READ, mgmt);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t qwUpdateTaskStatus(SQWorkerMgmt *mgmt, uint64_t sId, uint64_t qId, uint64_t tId, int8_t status) {
int32_t qwGetTaskStatus(SQWorkerMgmt *mgmt, uint64_t schedulerId, uint64_t queryId, uint64_t taskId, int8_t *taskStatus) { SQWSchStatus *sch = NULL;
SQWorkerSchStatus *sch = NULL; SQWTaskStatus *task = NULL;
SQWorkerTaskStatus *task = NULL;
int32_t code = 0; int32_t code = 0;
QW_ERR_RET(qwAcquireScheduler(QW_READ, mgmt, schedulerId, &sch)); QW_ERR_RET(qwAcquireScheduler(QW_READ, mgmt, sId, &sch, QW_NOT_EXIST_RET_ERR));
QW_ERR_JRET(qwAcquireTask(QW_READ, sch, queryId, taskId, &task)); QW_ERR_JRET(qwAcquireTask(QW_READ, sch, qId, tId, &task));
*taskStatus = task->status; QW_LOCK(QW_WRITE, &task->lock);
qwUpdateTaskInfo(task, QW_TASK_INFO_STATUS, &status);
QW_UNLOCK(QW_WRITE, &task->lock);
_return: _return:
if (task) {
qwReleaseTask(QW_READ, sch);
}
if (sch) { qwReleaseTask(QW_READ, sch);
qwReleaseScheduler(QW_READ, mgmt); qwReleaseScheduler(QW_READ, mgmt);
}
QW_RET(code); QW_RET(code);
} }
int32_t qwSwitchTaskStatus(SQWorkerMgmt *mgmt, uint64_t schedulerId, uint64_t queryId, uint64_t taskId, int8_t taskStatus) { int32_t qwGetTaskStatus(SQWorkerMgmt *mgmt, uint64_t sId, uint64_t queryId, uint64_t taskId, int8_t *taskStatus) {
SQWorkerSchStatus *sch = NULL; SQWSchStatus *sch = NULL;
SQWorkerTaskStatus *task = NULL; SQWTaskStatus *task = NULL;
int32_t code = 0; int32_t code = 0;
bool inserted = false;
if (qwAcquireScheduler(QW_READ, mgmt, schedulerId, &sch)) {
if (qwCheckStatusSwitch(JOB_TASK_STATUS_NULL, taskStatus)) {
qError("switch status error, not start to %d", taskStatus);
QW_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
}
QW_ERR_RET(qwInsertAndAcquireScheduler(QW_READ, mgmt, schedulerId, &sch)); if (qwAcquireScheduler(QW_READ, mgmt, sId, &sch, QW_NOT_EXIST_RET_ERR)) {
*taskStatus = JOB_TASK_STATUS_NULL;
return TSDB_CODE_SUCCESS;
} }
if (qwAcquireTask(QW_READ, sch, queryId, taskId, &task)) { if (qwAcquireTask(QW_READ, sch, queryId, taskId, &task)) {
if (qwCheckStatusSwitch(JOB_TASK_STATUS_NOT_START, taskStatus)) {
qwReleaseScheduler(QW_READ, mgmt); qwReleaseScheduler(QW_READ, mgmt);
qError("switch status error, not start to %d", taskStatus);
QW_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
}
QW_ERR_JRET(qwInsertAndAcquireTask(QW_READ, sch, queryId, taskId, taskStatus, &inserted, &task)); *taskStatus = JOB_TASK_STATUS_NULL;
if (inserted) {
qwReleaseTask(QW_READ, sch);
qwReleaseScheduler(QW_READ, mgmt);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
QW_LOCK(QW_WRITE, &task->lock); *taskStatus = task->status;
code = qwUpdateTaskInfo(task, QW_TASK_INFO_STATUS, &taskStatus);
QW_UNLOCK(QW_WRITE, &task->lock);
qwReleaseTask(QW_READ, sch);
qwReleaseScheduler(QW_READ, mgmt);
QW_RET(code);
}
QW_LOCK(QW_WRITE, &task->lock);
code = qwUpdateTaskInfo(task, QW_TASK_INFO_STATUS, &taskStatus);
QW_UNLOCK(QW_WRITE, &task->lock);
_return:
qwReleaseTask(QW_READ, sch); qwReleaseTask(QW_READ, sch);
qwReleaseScheduler(QW_READ, mgmt); qwReleaseScheduler(QW_READ, mgmt);
...@@ -379,25 +379,21 @@ _return: ...@@ -379,25 +379,21 @@ _return:
} }
int32_t qwCancelTask(SQWorkerMgmt *mgmt, uint64_t schedulerId, uint64_t queryId, uint64_t taskId) { int32_t qwCancelTask(SQWorkerMgmt *mgmt, uint64_t sId, uint64_t queryId, uint64_t taskId) {
SQWorkerSchStatus *sch = NULL; SQWSchStatus *sch = NULL;
SQWorkerTaskStatus *task = NULL; SQWTaskStatus *task = NULL;
int32_t code = 0; int32_t code = 0;
if (TSDB_CODE_SUCCESS != qwAcquireScheduler(QW_READ, mgmt, schedulerId, &sch)) { QW_ERR_RET(qwAcquireScheduler(QW_READ, mgmt, sId, &sch, QW_NOT_EXIST_ADD));
QW_ERR_RET(qwSwitchTaskStatus(mgmt, schedulerId, queryId, taskId, JOB_TASK_STATUS_NOT_START));
QW_ERR_RET(qwAcquireScheduler(QW_READ, mgmt, schedulerId, &sch));
}
if (qwAcquireTask(QW_READ, sch, queryId, taskId, &task)) { if (qwAcquireTask(QW_READ, sch, queryId, taskId, &task)) {
code = qwSwitchTaskStatus(mgmt, schedulerId, queryId, taskId, JOB_TASK_STATUS_NOT_START); qwReleaseScheduler(QW_READ, mgmt);
code = qwAddTask(mgmt, sId, queryId, taskId, JOB_TASK_STATUS_NOT_START, QW_EXIST_ACQUIRE, &sch, &task);
if (code) { if (code) {
qwReleaseScheduler(QW_READ, mgmt); qwReleaseScheduler(QW_READ, mgmt);
QW_ERR_RET(code); QW_ERR_RET(code);
} }
QW_ERR_JRET(qwAcquireTask(QW_READ, sch, queryId, taskId, &task));
} }
QW_LOCK(QW_WRITE, &task->lock); QW_LOCK(QW_WRITE, &task->lock);
...@@ -423,6 +419,7 @@ int32_t qwCancelTask(SQWorkerMgmt *mgmt, uint64_t schedulerId, uint64_t queryId, ...@@ -423,6 +419,7 @@ int32_t qwCancelTask(SQWorkerMgmt *mgmt, uint64_t schedulerId, uint64_t queryId,
} }
QW_UNLOCK(QW_WRITE, &task->lock); QW_UNLOCK(QW_WRITE, &task->lock);
qwReleaseTask(QW_READ, sch); qwReleaseTask(QW_READ, sch);
qwReleaseScheduler(QW_READ, mgmt); qwReleaseScheduler(QW_READ, mgmt);
...@@ -449,9 +446,9 @@ _return: ...@@ -449,9 +446,9 @@ _return:
int32_t qwDropTask(SQWorkerMgmt *mgmt, uint64_t schedulerId, uint64_t queryId, uint64_t taskId) { int32_t qwDropTask(SQWorkerMgmt *mgmt, uint64_t sId, uint64_t queryId, uint64_t taskId) {
SQWorkerSchStatus *sch = NULL; SQWSchStatus *sch = NULL;
SQWorkerTaskStatus *task = NULL; SQWTaskStatus *task = NULL;
int32_t code = 0; int32_t code = 0;
char id[sizeof(queryId) + sizeof(taskId)] = {0}; char id[sizeof(queryId) + sizeof(taskId)] = {0};
QW_SET_QTID(id, queryId, taskId); QW_SET_QTID(id, queryId, taskId);
...@@ -462,15 +459,15 @@ int32_t qwDropTask(SQWorkerMgmt *mgmt, uint64_t schedulerId, uint64_t queryId, u ...@@ -462,15 +459,15 @@ int32_t qwDropTask(SQWorkerMgmt *mgmt, uint64_t schedulerId, uint64_t queryId, u
} }
QW_UNLOCK(QW_WRITE, &mgmt->resLock); QW_UNLOCK(QW_WRITE, &mgmt->resLock);
if (TSDB_CODE_SUCCESS != qwAcquireScheduler(QW_WRITE, mgmt, schedulerId, &sch)) { if (TSDB_CODE_SUCCESS != qwAcquireScheduler(QW_WRITE, mgmt, sId, &sch, QW_NOT_EXIST_RET_ERR)) {
qWarn("scheduler %"PRIx64" doesn't exist", schedulerId); qWarn("scheduler %"PRIx64" doesn't exist", sId);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
if (qwAcquireTask(QW_WRITE, sch, queryId, taskId, &task)) { if (qwAcquireTask(QW_WRITE, sch, queryId, taskId, &task)) {
qwReleaseScheduler(QW_WRITE, mgmt); qwReleaseScheduler(QW_WRITE, mgmt);
qWarn("scheduler %"PRIx64" queryId %"PRIx64" taskId:%"PRIx64" doesn't exist", schedulerId, queryId, taskId); qWarn("scheduler %"PRIx64" queryId %"PRIx64" taskId:%"PRIx64" doesn't exist", sId, queryId, taskId);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
...@@ -483,21 +480,21 @@ int32_t qwDropTask(SQWorkerMgmt *mgmt, uint64_t schedulerId, uint64_t queryId, u ...@@ -483,21 +480,21 @@ int32_t qwDropTask(SQWorkerMgmt *mgmt, uint64_t schedulerId, uint64_t queryId, u
} }
int32_t qwCancelDropTask(SQWorkerMgmt *mgmt, uint64_t schedulerId, uint64_t queryId, uint64_t taskId) { int32_t qwCancelDropTask(SQWorkerMgmt *mgmt, uint64_t sId, uint64_t queryId, uint64_t taskId) {
SQWorkerSchStatus *sch = NULL; SQWSchStatus *sch = NULL;
SQWorkerTaskStatus *task = NULL; SQWTaskStatus *task = NULL;
int32_t code = 0; int32_t code = 0;
if (TSDB_CODE_SUCCESS != qwAcquireScheduler(QW_READ, mgmt, schedulerId, &sch)) { QW_ERR_RET(qwAcquireScheduler(QW_READ, mgmt, sId, &sch, QW_NOT_EXIST_ADD));
qWarn("scheduler %"PRIx64" doesn't exist", schedulerId);
return TSDB_CODE_SUCCESS;
}
if (qwAcquireTask(QW_READ, sch, queryId, taskId, &task)) { if (qwAcquireTask(QW_READ, sch, queryId, taskId, &task)) {
qwReleaseScheduler(QW_READ, mgmt); qwReleaseScheduler(QW_READ, mgmt);
qWarn("scheduler %"PRIx64" queryId %"PRIx64" taskId:%"PRIx64" doesn't exist", schedulerId, queryId, taskId); code = qwAddTask(mgmt, sId, queryId, taskId, JOB_TASK_STATUS_NOT_START, QW_EXIST_ACQUIRE, &sch, &task);
return TSDB_CODE_SUCCESS; if (code) {
qwReleaseScheduler(QW_READ, mgmt);
QW_ERR_RET(code);
}
} }
QW_LOCK(QW_WRITE, &task->lock); QW_LOCK(QW_WRITE, &task->lock);
...@@ -508,7 +505,7 @@ int32_t qwCancelDropTask(SQWorkerMgmt *mgmt, uint64_t schedulerId, uint64_t quer ...@@ -508,7 +505,7 @@ int32_t qwCancelDropTask(SQWorkerMgmt *mgmt, uint64_t schedulerId, uint64_t quer
int8_t newStatus = 0; int8_t newStatus = 0;
if (task->status == JOB_TASK_STATUS_EXECUTING) { if (task->status == JOB_TASK_STATUS_EXECUTING) {
newStatus = JOB_TASK_STATUS_CANCELLING; newStatus = JOB_TASK_STATUS_DROPPING;
QW_ERR_JRET(qwUpdateTaskInfo(task, QW_TASK_INFO_STATUS, &newStatus)); QW_ERR_JRET(qwUpdateTaskInfo(task, QW_TASK_INFO_STATUS, &newStatus));
} else if (task->status == JOB_TASK_STATUS_CANCELLING || task->status == JOB_TASK_STATUS_DROPPING || task->status == JOB_TASK_STATUS_NOT_START) { } else if (task->status == JOB_TASK_STATUS_CANCELLING || task->status == JOB_TASK_STATUS_DROPPING || task->status == JOB_TASK_STATUS_NOT_START) {
QW_UNLOCK(QW_WRITE, &task->lock); QW_UNLOCK(QW_WRITE, &task->lock);
...@@ -521,7 +518,7 @@ int32_t qwCancelDropTask(SQWorkerMgmt *mgmt, uint64_t schedulerId, uint64_t quer ...@@ -521,7 +518,7 @@ int32_t qwCancelDropTask(SQWorkerMgmt *mgmt, uint64_t schedulerId, uint64_t quer
qwReleaseTask(QW_READ, sch); qwReleaseTask(QW_READ, sch);
qwReleaseScheduler(QW_READ, mgmt); qwReleaseScheduler(QW_READ, mgmt);
QW_ERR_RET(qwDropTask(mgmt, schedulerId, queryId, taskId)); QW_ERR_RET(qwDropTask(mgmt, sId, queryId, taskId));
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
...@@ -604,6 +601,7 @@ int32_t qwBuildAndSendStatusRsp(SRpcMsg *pMsg, SSchedulerStatusRsp *sStatus) { ...@@ -604,6 +601,7 @@ int32_t qwBuildAndSendStatusRsp(SRpcMsg *pMsg, SSchedulerStatusRsp *sStatus) {
} }
SRpcMsg rpcRsp = { SRpcMsg rpcRsp = {
.msgType = pMsg->msgType + 1,
.handle = pMsg->handle, .handle = pMsg->handle,
.ahandle = pMsg->ahandle, .ahandle = pMsg->ahandle,
.pCont = pRsp, .pCont = pRsp,
...@@ -673,12 +671,12 @@ int32_t qwBuildAndSendDropRsp(SRpcMsg *pMsg, int32_t code) { ...@@ -673,12 +671,12 @@ int32_t qwBuildAndSendDropRsp(SRpcMsg *pMsg, int32_t code) {
int32_t qwCheckAndSendReadyRsp(SQWorkerMgmt *mgmt, uint64_t schedulerId, uint64_t queryId, uint64_t taskId, SRpcMsg *pMsg, int32_t rspCode) { int32_t qwCheckAndSendReadyRsp(SQWorkerMgmt *mgmt, uint64_t sId, uint64_t queryId, uint64_t taskId, SRpcMsg *pMsg, int32_t rspCode) {
SQWorkerSchStatus *sch = NULL; SQWSchStatus *sch = NULL;
SQWorkerTaskStatus *task = NULL; SQWTaskStatus *task = NULL;
int32_t code = 0; int32_t code = 0;
QW_ERR_RET(qwAcquireScheduler(QW_READ, mgmt, schedulerId, &sch)); QW_ERR_RET(qwAcquireScheduler(QW_READ, mgmt, sId, &sch, QW_NOT_EXIST_RET_ERR));
QW_ERR_JRET(qwAcquireTask(QW_READ, sch, queryId, taskId, &task)); QW_ERR_JRET(qwAcquireTask(QW_READ, sch, queryId, taskId, &task));
...@@ -706,10 +704,8 @@ _return: ...@@ -706,10 +704,8 @@ _return:
if (task) { if (task) {
QW_UNLOCK(QW_WRITE, &task->lock); QW_UNLOCK(QW_WRITE, &task->lock);
}
if (sch) {
qwReleaseTask(QW_READ, sch); qwReleaseTask(QW_READ, sch);
} }
qwReleaseScheduler(QW_READ, mgmt); qwReleaseScheduler(QW_READ, mgmt);
...@@ -717,12 +713,12 @@ _return: ...@@ -717,12 +713,12 @@ _return:
QW_RET(code); QW_RET(code);
} }
int32_t qwSetAndSendReadyRsp(SQWorkerMgmt *mgmt, uint64_t schedulerId, uint64_t queryId, uint64_t taskId, SRpcMsg *pMsg) { int32_t qwSetAndSendReadyRsp(SQWorkerMgmt *mgmt, uint64_t sId, uint64_t queryId, uint64_t taskId, SRpcMsg *pMsg) {
SQWorkerSchStatus *sch = NULL; SQWSchStatus *sch = NULL;
SQWorkerTaskStatus *task = NULL; SQWTaskStatus *task = NULL;
int32_t code = 0; int32_t code = 0;
QW_ERR_RET(qwAcquireScheduler(QW_READ, mgmt, schedulerId, &sch)); QW_ERR_RET(qwAcquireScheduler(QW_READ, mgmt, sId, &sch, QW_NOT_EXIST_RET_ERR));
QW_ERR_JRET(qwAcquireTask(QW_READ, sch, queryId, taskId, &task)); QW_ERR_JRET(qwAcquireTask(QW_READ, sch, queryId, taskId, &task));
...@@ -745,9 +741,6 @@ _return: ...@@ -745,9 +741,6 @@ _return:
if (task) { if (task) {
QW_UNLOCK(QW_WRITE, &task->lock); QW_UNLOCK(QW_WRITE, &task->lock);
}
if (sch) {
qwReleaseTask(QW_READ, sch); qwReleaseTask(QW_READ, sch);
} }
...@@ -756,15 +749,15 @@ _return: ...@@ -756,15 +749,15 @@ _return:
QW_RET(code); QW_RET(code);
} }
int32_t qwCheckTaskCancelDrop( SQWorkerMgmt *mgmt, uint64_t schedulerId, uint64_t queryId, uint64_t taskId, bool *needStop) { int32_t qwCheckTaskCancelDrop( SQWorkerMgmt *mgmt, uint64_t sId, uint64_t queryId, uint64_t taskId, bool *needStop) {
SQWorkerSchStatus *sch = NULL; SQWSchStatus *sch = NULL;
SQWorkerTaskStatus *task = NULL; SQWTaskStatus *task = NULL;
int32_t code = 0; int32_t code = 0;
int8_t status = JOB_TASK_STATUS_CANCELLED; int8_t status = JOB_TASK_STATUS_CANCELLED;
*needStop = false; *needStop = false;
if (qwAcquireScheduler(QW_READ, mgmt, schedulerId, &sch)) { if (qwAcquireScheduler(QW_READ, mgmt, sId, &sch, QW_NOT_EXIST_RET_ERR)) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
...@@ -776,11 +769,13 @@ int32_t qwCheckTaskCancelDrop( SQWorkerMgmt *mgmt, uint64_t schedulerId, uint64_ ...@@ -776,11 +769,13 @@ int32_t qwCheckTaskCancelDrop( SQWorkerMgmt *mgmt, uint64_t schedulerId, uint64_
QW_LOCK(QW_READ, &task->lock); QW_LOCK(QW_READ, &task->lock);
if ((!task->cancel) && (!task->drop)) { if ((!task->cancel) && (!task->drop)) {
qError("no cancel or drop, but task:%"PRIx64" exists", taskId);
QW_UNLOCK(QW_READ, &task->lock); QW_UNLOCK(QW_READ, &task->lock);
qwReleaseTask(QW_READ, sch); qwReleaseTask(QW_READ, sch);
qwReleaseScheduler(QW_READ, mgmt); qwReleaseScheduler(QW_READ, mgmt);
return TSDB_CODE_SUCCESS; QW_RET(TSDB_CODE_QRY_APP_ERROR);
} }
QW_UNLOCK(QW_READ, &task->lock); QW_UNLOCK(QW_READ, &task->lock);
...@@ -791,30 +786,40 @@ int32_t qwCheckTaskCancelDrop( SQWorkerMgmt *mgmt, uint64_t schedulerId, uint64_ ...@@ -791,30 +786,40 @@ int32_t qwCheckTaskCancelDrop( SQWorkerMgmt *mgmt, uint64_t schedulerId, uint64_
QW_LOCK(QW_WRITE, &task->lock); QW_LOCK(QW_WRITE, &task->lock);
qwUpdateTaskInfo(task, QW_TASK_INFO_STATUS, &status); qwUpdateTaskInfo(task, QW_TASK_INFO_STATUS, &status);
QW_UNLOCK(QW_WRITE, &task->lock); QW_UNLOCK(QW_WRITE, &task->lock);
} else if (task->drop) { }
if (task->drop) {
qwReleaseTask(QW_READ, sch); qwReleaseTask(QW_READ, sch);
qwReleaseScheduler(QW_READ, mgmt); qwReleaseScheduler(QW_READ, mgmt);
qwDropTask(mgmt, schedulerId, queryId, taskId); return qwDropTask(mgmt, sId, queryId, taskId);
} }
qwReleaseTask(QW_READ, sch);
qwReleaseScheduler(QW_READ, mgmt);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t qwHandleFetch(SQWorkerResCache *res, SQWorkerMgmt *mgmt, uint64_t schedulerId, uint64_t queryId, uint64_t taskId, SRpcMsg *pMsg) { int32_t qwHandleFetch(SQWorkerResCache *res, SQWorkerMgmt *mgmt, uint64_t sId, uint64_t queryId, uint64_t taskId, SRpcMsg *pMsg) {
SQWorkerSchStatus *sch = NULL; SQWSchStatus *sch = NULL;
SQWorkerTaskStatus *task = NULL; SQWTaskStatus *task = NULL;
int32_t code = 0; int32_t code = 0;
int32_t needRsp = true; int32_t needRsp = true;
void *data = NULL; void *data = NULL;
QW_ERR_JRET(qwAcquireScheduler(QW_READ, mgmt, schedulerId, &sch)); QW_ERR_JRET(qwAcquireScheduler(QW_READ, mgmt, sId, &sch, QW_NOT_EXIST_RET_ERR));
QW_ERR_JRET(qwAcquireTask(QW_READ, sch, queryId, taskId, &task)); QW_ERR_JRET(qwAcquireTask(QW_READ, sch, queryId, taskId, &task));
QW_LOCK(QW_READ, &task->lock); QW_LOCK(QW_READ, &task->lock);
if (task->status != JOB_TASK_STATUS_EXECUTING && task->status != JOB_TASK_STATUS_PARTIAL_SUCCEED && task->status != JOB_TASK_STATUS_SUCCEED) { if (task->cancel || task->drop) {
qError("task is already cancelled or dropped");
QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
}
if (task->status != JOB_TASK_STATUS_EXECUTING && task->status != JOB_TASK_STATUS_PARTIAL_SUCCEED) {
qError("invalid status %d for fetch", task->status); qError("invalid status %d for fetch", task->status);
QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
} }
...@@ -840,10 +845,10 @@ int32_t qwHandleFetch(SQWorkerResCache *res, SQWorkerMgmt *mgmt, uint64_t schedu ...@@ -840,10 +845,10 @@ int32_t qwHandleFetch(SQWorkerResCache *res, SQWorkerMgmt *mgmt, uint64_t schedu
_return: _return:
if (task) { if (task) {
QW_UNLOCK(QW_READ, &task->lock); QW_UNLOCK(QW_READ, &task->lock);
qwReleaseTask(QW_READ, sch);
} }
if (sch) { if (sch) {
qwReleaseTask(QW_READ, sch);
qwReleaseScheduler(QW_READ, mgmt); qwReleaseScheduler(QW_READ, mgmt);
} }
...@@ -854,37 +859,46 @@ _return: ...@@ -854,37 +859,46 @@ _return:
QW_RET(code); QW_RET(code);
} }
int32_t qwQueryPostProcess(SQWorkerMgmt *mgmt, uint64_t schedulerId, uint64_t queryId, uint64_t taskId, int8_t status, int32_t errCode) { int32_t qwQueryPostProcess(SQWorkerMgmt *mgmt, uint64_t sId, uint64_t qId, uint64_t tId, int8_t status, int32_t errCode) {
SQWorkerSchStatus *sch = NULL; SQWSchStatus *sch = NULL;
SQWorkerTaskStatus *task = NULL; SQWTaskStatus *task = NULL;
int32_t code = 0; int32_t code = 0;
int8_t newStatus = JOB_TASK_STATUS_CANCELLED; int8_t newStatus = JOB_TASK_STATUS_CANCELLED;
code = qwAcquireScheduler(QW_READ, mgmt, schedulerId, &sch); code = qwAcquireScheduler(QW_READ, mgmt, sId, &sch, QW_NOT_EXIST_ADD);
if (code) { if (code) {
qError("schedulerId:%"PRIx64" not in cache", schedulerId); qError("sId:%"PRIx64" not in cache", sId);
QW_ERR_RET(code); QW_ERR_RET(code);
} }
code = qwAcquireTask(QW_READ, sch, queryId, taskId, &task); code = qwAcquireTask(QW_READ, sch, qId, tId, &task);
if (code) { if (code) {
qwReleaseScheduler(QW_READ, mgmt); qwReleaseScheduler(QW_READ, mgmt);
qError("schedulerId:%"PRIx64" queryId:%"PRIx64" taskId:%"PRIx64" not in cache", schedulerId, queryId, taskId);
if (JOB_TASK_STATUS_PARTIAL_SUCCEED == status || JOB_TASK_STATUS_SUCCEED == status) {
qError("sId:%"PRIx64" queryId:%"PRIx64" taskId:%"PRIx64" not in cache", sId, qId, tId);
QW_ERR_RET(code); QW_ERR_RET(code);
} }
QW_ERR_RET(qwAddTask(mgmt, sId, qId, tId, status, QW_EXIST_ACQUIRE, &sch, &task));
}
if (task->cancel) { if (task->cancel) {
QW_LOCK(QW_WRITE, &task->lock); QW_LOCK(QW_WRITE, &task->lock);
qwUpdateTaskInfo(task, QW_TASK_INFO_STATUS, &newStatus); qwUpdateTaskInfo(task, QW_TASK_INFO_STATUS, &newStatus);
QW_UNLOCK(QW_WRITE, &task->lock); QW_UNLOCK(QW_WRITE, &task->lock);
} else if (task->drop) { }
if (task->drop) {
qwReleaseTask(QW_READ, sch); qwReleaseTask(QW_READ, sch);
qwReleaseScheduler(QW_READ, mgmt); qwReleaseScheduler(QW_READ, mgmt);
qwDropTask(mgmt, schedulerId, queryId, taskId); qwDropTask(mgmt, sId, qId, tId);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} else { }
if (!(task->cancel || task->drop)) {
QW_LOCK(QW_WRITE, &task->lock); QW_LOCK(QW_WRITE, &task->lock);
qwUpdateTaskInfo(task, QW_TASK_INFO_STATUS, &status); qwUpdateTaskInfo(task, QW_TASK_INFO_STATUS, &status);
task->code = errCode; task->code = errCode;
...@@ -938,24 +952,24 @@ int32_t qWorkerProcessQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) { ...@@ -938,24 +952,24 @@ int32_t qWorkerProcessQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) {
QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
} }
int32_t code = 0;
SSubQueryMsg *msg = pMsg->pCont; SSubQueryMsg *msg = pMsg->pCont;
if (NULL == msg || pMsg->contLen <= sizeof(*msg)) { if (NULL == msg || pMsg->contLen <= sizeof(*msg)) {
qError("invalid query msg"); qError("invalid query msg");
QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); QW_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT);
} }
msg->schedulerId = htobe64(msg->schedulerId); msg->sId = htobe64(msg->sId);
msg->queryId = htobe64(msg->queryId); msg->queryId = htobe64(msg->queryId);
msg->taskId = htobe64(msg->taskId); msg->taskId = htobe64(msg->taskId);
msg->contentLen = ntohl(msg->contentLen); msg->contentLen = ntohl(msg->contentLen);
bool queryDone = false; bool queryDone = false;
bool queryRsp = false; bool queryRsped = false;
bool needStop = false; bool needStop = false;
SSubplan *plan = NULL; SSubplan *plan = NULL;
int32_t code = 0;
QW_ERR_JRET(qwCheckTaskCancelDrop(qWorkerMgmt, msg->schedulerId, msg->queryId, msg->taskId, &needStop)); QW_ERR_JRET(qwCheckTaskCancelDrop(qWorkerMgmt, msg->sId, msg->queryId, msg->taskId, &needStop));
if (needStop) { if (needStop) {
qWarn("task need stop"); qWarn("task need stop");
QW_ERR_JRET(TSDB_CODE_QRY_TASK_CANCELLED); QW_ERR_JRET(TSDB_CODE_QRY_TASK_CANCELLED);
...@@ -963,7 +977,7 @@ int32_t qWorkerProcessQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) { ...@@ -963,7 +977,7 @@ int32_t qWorkerProcessQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) {
code = qStringToSubplan(msg->msg, &plan); code = qStringToSubplan(msg->msg, &plan);
if (TSDB_CODE_SUCCESS != code) { if (TSDB_CODE_SUCCESS != code) {
qError("schId:%"PRIx64",qId:%"PRIx64",taskId:%"PRIx64" string to subplan failed, code:%d", msg->schedulerId, msg->queryId, msg->taskId, code); qError("schId:%"PRIx64",qId:%"PRIx64",taskId:%"PRIx64" string to subplan failed, code:%d", msg->sId, msg->queryId, msg->taskId, code);
QW_ERR_JRET(code); QW_ERR_JRET(code);
} }
...@@ -974,12 +988,12 @@ int32_t qWorkerProcessQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) { ...@@ -974,12 +988,12 @@ int32_t qWorkerProcessQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) {
if (code) { if (code) {
QW_ERR_JRET(code); QW_ERR_JRET(code);
} else { } else {
QW_ERR_JRET(qwSwitchTaskStatus(qWorkerMgmt, msg->schedulerId, msg->queryId, msg->taskId, JOB_TASK_STATUS_EXECUTING)); QW_ERR_JRET(qwAddTask(qWorkerMgmt, msg->sId, msg->queryId, msg->taskId, JOB_TASK_STATUS_EXECUTING, QW_EXIST_RET_ERR, NULL, NULL));
} }
QW_ERR_JRET(qwBuildAndSendQueryRsp(pMsg, TSDB_CODE_SUCCESS)); QW_ERR_JRET(qwBuildAndSendQueryRsp(pMsg, TSDB_CODE_SUCCESS));
queryRsp = true; queryRsped = true;
//TODO call executer to execute subquery //TODO call executer to execute subquery
code = 0; code = 0;
...@@ -990,29 +1004,29 @@ int32_t qWorkerProcessQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) { ...@@ -990,29 +1004,29 @@ int32_t qWorkerProcessQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) {
if (code) { if (code) {
QW_ERR_JRET(code); QW_ERR_JRET(code);
} else { } else {
QW_ERR_JRET(qwAddTaskResult(qWorkerMgmt, msg->queryId, msg->taskId, data)); QW_ERR_JRET(qwAddTaskResCache(qWorkerMgmt, msg->queryId, msg->taskId, data));
QW_ERR_JRET(qwSwitchTaskStatus(qWorkerMgmt, msg->schedulerId, msg->queryId, msg->taskId, JOB_TASK_STATUS_PARTIAL_SUCCEED)); QW_ERR_JRET(qwUpdateTaskStatus(qWorkerMgmt, msg->sId, msg->queryId, msg->taskId, JOB_TASK_STATUS_PARTIAL_SUCCEED));
} }
_return: _return:
if (queryRsp) { if (queryRsped) {
code = qwCheckAndSendReadyRsp(qWorkerMgmt, msg->schedulerId, msg->queryId, msg->taskId, pMsg, code); code = qwCheckAndSendReadyRsp(qWorkerMgmt, msg->sId, msg->queryId, msg->taskId, pMsg, code);
} else { } else {
code = qwBuildAndSendQueryRsp(pMsg, code); code = qwBuildAndSendQueryRsp(pMsg, code);
} }
int8_t status = 0; int8_t status = 0;
if (TSDB_CODE_SUCCESS != code || queryDone) { if (TSDB_CODE_SUCCESS != code) {
if (code) { status = JOB_TASK_STATUS_FAILED;
status = JOB_TASK_STATUS_FAILED; //TODO set CANCELLED from code } else if (queryDone) {
} else {
status = JOB_TASK_STATUS_SUCCEED; status = JOB_TASK_STATUS_SUCCEED;
} else {
status = JOB_TASK_STATUS_PARTIAL_SUCCEED;
} }
qwQueryPostProcess(qWorkerMgmt, msg->schedulerId, msg->queryId, msg->taskId, status, code); qwQueryPostProcess(qWorkerMgmt, msg->sId, msg->queryId, msg->taskId, status, code);
}
QW_RET(code); QW_RET(code);
} }
...@@ -1023,12 +1037,16 @@ int32_t qWorkerProcessReadyMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg){ ...@@ -1023,12 +1037,16 @@ int32_t qWorkerProcessReadyMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg){
} }
SResReadyMsg *msg = pMsg->pCont; SResReadyMsg *msg = pMsg->pCont;
if (NULL == msg || pMsg->contLen <= sizeof(*msg)) { if (NULL == msg || pMsg->contLen < sizeof(*msg)) {
qError("invalid task status msg"); qError("invalid task status msg");
QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
} }
QW_ERR_RET(qwSetAndSendReadyRsp(qWorkerMgmt, msg->schedulerId, msg->queryId, msg->taskId, pMsg)); msg->sId = htobe64(msg->sId);
msg->queryId = htobe64(msg->queryId);
msg->taskId = htobe64(msg->taskId);
QW_ERR_RET(qwSetAndSendReadyRsp(qWorkerMgmt, msg->sId, msg->queryId, msg->taskId, pMsg));
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
...@@ -1040,14 +1058,16 @@ int32_t qWorkerProcessStatusMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) { ...@@ -1040,14 +1058,16 @@ int32_t qWorkerProcessStatusMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) {
int32_t code = 0; int32_t code = 0;
SSchTasksStatusMsg *msg = pMsg->pCont; SSchTasksStatusMsg *msg = pMsg->pCont;
if (NULL == msg || pMsg->contLen <= sizeof(*msg)) { if (NULL == msg || pMsg->contLen < sizeof(*msg)) {
qError("invalid task status msg"); qError("invalid task status msg");
QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
} }
msg->sId = htobe64(msg->sId);
SSchedulerStatusRsp *sStatus = NULL; SSchedulerStatusRsp *sStatus = NULL;
QW_ERR_JRET(qwGetSchTasksStatus(qWorkerMgmt, msg->schedulerId, &sStatus)); QW_ERR_JRET(qwGetSchTasksStatus(qWorkerMgmt, msg->sId, &sStatus));
_return: _return:
...@@ -1062,11 +1082,15 @@ int32_t qWorkerProcessFetchMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) { ...@@ -1062,11 +1082,15 @@ int32_t qWorkerProcessFetchMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) {
} }
SResFetchMsg *msg = pMsg->pCont; SResFetchMsg *msg = pMsg->pCont;
if (NULL == msg || pMsg->contLen <= sizeof(*msg)) { if (NULL == msg || pMsg->contLen < sizeof(*msg)) {
QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
} }
QW_ERR_RET(qwUpdateSchLastAccess(qWorkerMgmt, msg->schedulerId)); msg->sId = htobe64(msg->sId);
msg->queryId = htobe64(msg->queryId);
msg->taskId = htobe64(msg->taskId);
QW_ERR_RET(qwUpdateSchLastAccess(qWorkerMgmt, msg->sId));
void *data = NULL; void *data = NULL;
SQWorkerResCache *res = NULL; SQWorkerResCache *res = NULL;
...@@ -1074,7 +1098,7 @@ int32_t qWorkerProcessFetchMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) { ...@@ -1074,7 +1098,7 @@ int32_t qWorkerProcessFetchMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) {
QW_ERR_RET(qwAcquireTaskResCache(QW_READ, qWorkerMgmt, msg->queryId, msg->taskId, &res)); QW_ERR_RET(qwAcquireTaskResCache(QW_READ, qWorkerMgmt, msg->queryId, msg->taskId, &res));
QW_ERR_JRET(qwHandleFetch(res, qWorkerMgmt, msg->schedulerId, msg->queryId, msg->taskId, pMsg)); QW_ERR_JRET(qwHandleFetch(res, qWorkerMgmt, msg->sId, msg->queryId, msg->taskId, pMsg));
_return: _return:
...@@ -1090,12 +1114,16 @@ int32_t qWorkerProcessCancelMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) { ...@@ -1090,12 +1114,16 @@ int32_t qWorkerProcessCancelMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) {
int32_t code = 0; int32_t code = 0;
STaskCancelMsg *msg = pMsg->pCont; STaskCancelMsg *msg = pMsg->pCont;
if (NULL == msg || pMsg->contLen <= sizeof(*msg)) { if (NULL == msg || pMsg->contLen < sizeof(*msg)) {
qError("invalid task cancel msg"); qError("invalid task cancel msg");
QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
} }
QW_ERR_JRET(qwCancelTask(qWorkerMgmt, msg->schedulerId, msg->queryId, msg->taskId)); msg->sId = htobe64(msg->sId);
msg->queryId = htobe64(msg->queryId);
msg->taskId = htobe64(msg->taskId);
QW_ERR_JRET(qwCancelTask(qWorkerMgmt, msg->sId, msg->queryId, msg->taskId));
_return: _return:
...@@ -1111,12 +1139,16 @@ int32_t qWorkerProcessDropMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) { ...@@ -1111,12 +1139,16 @@ int32_t qWorkerProcessDropMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) {
int32_t code = 0; int32_t code = 0;
STaskDropMsg *msg = pMsg->pCont; STaskDropMsg *msg = pMsg->pCont;
if (NULL == msg || pMsg->contLen <= sizeof(*msg)) { if (NULL == msg || pMsg->contLen < sizeof(*msg)) {
qError("invalid task drop msg"); qError("invalid task drop msg");
QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
} }
QW_ERR_JRET(qwCancelDropTask(qWorkerMgmt, msg->schedulerId, msg->queryId, msg->taskId)); msg->sId = htobe64(msg->sId);
msg->queryId = htobe64(msg->queryId);
msg->taskId = htobe64(msg->taskId);
QW_ERR_JRET(qwCancelDropTask(qWorkerMgmt, msg->sId, msg->queryId, msg->taskId));
_return: _return:
...@@ -1125,6 +1157,31 @@ _return: ...@@ -1125,6 +1157,31 @@ _return:
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t qWorkerContinueQuery(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) {
int32_t code = 0;
int8_t status = 0;
bool queryDone = false;
uint64_t sId, qId, tId;
//TODO call executer to continue execute subquery
code = 0;
void *data = NULL;
queryDone = false;
//TODO call executer to continue execute subquery
if (TSDB_CODE_SUCCESS != code) {
status = JOB_TASK_STATUS_FAILED;
} else if (queryDone) {
status = JOB_TASK_STATUS_SUCCEED;
} else {
status = JOB_TASK_STATUS_PARTIAL_SUCCEED;
}
code = qwQueryPostProcess(qWorkerMgmt, sId, qId, tId, status, code);
QW_RET(code);
}
void qWorkerDestroy(void **qWorkerMgmt) { void qWorkerDestroy(void **qWorkerMgmt) {
if (NULL == qWorkerMgmt || NULL == *qWorkerMgmt) { if (NULL == qWorkerMgmt || NULL == *qWorkerMgmt) {
......
...@@ -36,10 +36,25 @@ ...@@ -36,10 +36,25 @@
namespace { namespace {
bool testStop = false;
int32_t qwtStringToPlan(const char* str, SSubplan** subplan) { int32_t qwtStringToPlan(const char* str, SSubplan** subplan) {
return 0; return 0;
} }
void qwtRpcSendResponse(const SRpcMsg *pRsp) {
if (TDMT_VND_TASKS_STATUS_RSP == pRsp->msgType) {
SSchedulerStatusRsp *rsp = (SSchedulerStatusRsp *)pRsp->pCont;
printf("task num:%d\n", rsp->num);
for (int32_t i = 0; i < rsp->num; ++i) {
STaskStatus *task = &rsp->status[i];
printf("qId:%"PRIx64",tId:%"PRIx64",status:%d\n", task->queryId, task->taskId, task->status);
}
}
return;
}
void stubSetStringToPlan() { void stubSetStringToPlan() {
static Stub stub; static Stub stub;
...@@ -54,11 +69,148 @@ void stubSetStringToPlan() { ...@@ -54,11 +69,148 @@ void stubSetStringToPlan() {
} }
} }
void stubSetRpcSendResponse() {
static Stub stub;
stub.set(rpcSendResponse, qwtRpcSendResponse);
{
AddrAny any("libplanner.so");
std::map<std::string,void*> result;
any.get_global_func_addr_dynsym("^rpcSendResponse$", result);
for (const auto& f : result) {
stub.set(f.second, qwtRpcSendResponse);
}
}
}
void *queryThread(void *param) {
SRpcMsg queryRpc = {0};
int32_t code = 0;
uint32_t n = 0;
void *mockPointer = (void *)0x1;
void *mgmt = param;
SSubQueryMsg *queryMsg = (SSubQueryMsg *)calloc(1, sizeof(SSubQueryMsg) + 100);
queryMsg->queryId = htobe64(1);
queryMsg->sId = htobe64(1);
queryMsg->taskId = htobe64(1);
queryMsg->contentLen = htonl(100);
queryRpc.pCont = queryMsg;
queryRpc.contLen = sizeof(SSubQueryMsg) + 100;
while (!testStop) {
qWorkerProcessQueryMsg(mockPointer, mgmt, &queryRpc);
usleep(rand()%5);
if (++n % 50000 == 0) {
printf("query:%d\n", n);
}
}
return NULL;
}
void *readyThread(void *param) {
SRpcMsg readyRpc = {0};
int32_t code = 0;
uint32_t n = 0;
void *mockPointer = (void *)0x1;
void *mgmt = param;
SResReadyMsg readyMsg = {0};
readyMsg.sId = htobe64(1);
readyMsg.queryId = htobe64(1);
readyMsg.taskId = htobe64(1);
readyRpc.pCont = &readyMsg;
readyRpc.contLen = sizeof(SResReadyMsg);
while (!testStop) {
code = qWorkerProcessReadyMsg(mockPointer, mgmt, &readyRpc);
usleep(rand()%5);
if (++n % 50000 == 0) {
printf("ready:%d\n", n);
}
}
return NULL;
} }
void *fetchThread(void *param) {
SRpcMsg fetchRpc = {0};
int32_t code = 0;
uint32_t n = 0;
void *mockPointer = (void *)0x1;
void *mgmt = param;
SResFetchMsg fetchMsg = {0};
fetchMsg.sId = htobe64(1);
fetchMsg.queryId = htobe64(1);
fetchMsg.taskId = htobe64(1);
fetchRpc.pCont = &fetchMsg;
fetchRpc.contLen = sizeof(SResFetchMsg);
TEST(testCase, normalCase) { while (!testStop) {
code = qWorkerProcessFetchMsg(mockPointer, mgmt, &fetchRpc);
usleep(rand()%5);
if (++n % 50000 == 0) {
printf("fetch:%d\n", n);
}
}
return NULL;
}
void *dropThread(void *param) {
SRpcMsg dropRpc = {0};
int32_t code = 0;
uint32_t n = 0;
void *mockPointer = (void *)0x1;
void *mgmt = param;
STaskDropMsg dropMsg = {0};
dropMsg.sId = htobe64(1);
dropMsg.queryId = htobe64(1);
dropMsg.taskId = htobe64(1);
dropRpc.pCont = &dropMsg;
dropRpc.contLen = sizeof(STaskDropMsg);
while (!testStop) {
code = qWorkerProcessDropMsg(mockPointer, mgmt, &dropRpc);
usleep(rand()%5);
if (++n % 50000 == 0) {
printf("drop:%d\n", n);
}
}
return NULL;
}
void *statusThread(void *param) {
SRpcMsg statusRpc = {0};
int32_t code = 0;
uint32_t n = 0;
void *mockPointer = (void *)0x1;
void *mgmt = param;
SSchTasksStatusMsg statusMsg = {0};
statusMsg.sId = htobe64(1);
statusRpc.pCont = &statusMsg;
statusRpc.contLen = sizeof(SSchTasksStatusMsg);
statusRpc.msgType = TDMT_VND_TASKS_STATUS;
while (!testStop) {
statusMsg.sId = htobe64(1);
code = qWorkerProcessStatusMsg(mockPointer, mgmt, &statusRpc);
usleep(rand()%5);
if (++n % 50000 == 0) {
printf("status:%d\n", n);
}
}
return NULL;
}
}
TEST(seqTest, normalCase) {
void *mgmt = NULL; void *mgmt = NULL;
int32_t code = 0; int32_t code = 0;
void *mockPointer = (void *)0x1; void *mockPointer = (void *)0x1;
...@@ -66,48 +218,254 @@ TEST(testCase, normalCase) { ...@@ -66,48 +218,254 @@ TEST(testCase, normalCase) {
SRpcMsg readyRpc = {0}; SRpcMsg readyRpc = {0};
SRpcMsg fetchRpc = {0}; SRpcMsg fetchRpc = {0};
SRpcMsg dropRpc = {0}; SRpcMsg dropRpc = {0};
SRpcMsg statusRpc = {0};
SSubQueryMsg *queryMsg = (SSubQueryMsg *)calloc(1, sizeof(SSubQueryMsg) + 100); SSubQueryMsg *queryMsg = (SSubQueryMsg *)calloc(1, sizeof(SSubQueryMsg) + 100);
queryMsg->queryId = htobe64(1); queryMsg->queryId = htobe64(1);
queryMsg->schedulerId = htobe64(1); queryMsg->sId = htobe64(1);
queryMsg->taskId = htobe64(1); queryMsg->taskId = htobe64(1);
queryMsg->contentLen = htonl(100); queryMsg->contentLen = htonl(100);
queryRpc.pCont = queryMsg; queryRpc.pCont = queryMsg;
queryRpc.contLen = sizeof(SSubQueryMsg) + 100;
SResReadyMsg readyMsg = {0}; SResReadyMsg readyMsg = {0};
readyMsg.schedulerId = htobe64(1); readyMsg.sId = htobe64(1);
readyMsg.queryId = htobe64(1); readyMsg.queryId = htobe64(1);
readyMsg.taskId = htobe64(1); readyMsg.taskId = htobe64(1);
readyRpc.pCont = &readyMsg; readyRpc.pCont = &readyMsg;
readyRpc.contLen = sizeof(SResReadyMsg);
SResFetchMsg fetchMsg = {0}; SResFetchMsg fetchMsg = {0};
fetchMsg.schedulerId = htobe64(1); fetchMsg.sId = htobe64(1);
fetchMsg.queryId = htobe64(1); fetchMsg.queryId = htobe64(1);
fetchMsg.taskId = htobe64(1); fetchMsg.taskId = htobe64(1);
fetchRpc.pCont = &fetchMsg; fetchRpc.pCont = &fetchMsg;
fetchRpc.contLen = sizeof(SResFetchMsg);
STaskDropMsg dropMsg = {0}; STaskDropMsg dropMsg = {0};
dropMsg.schedulerId = htobe64(1); dropMsg.sId = htobe64(1);
dropMsg.queryId = htobe64(1); dropMsg.queryId = htobe64(1);
dropMsg.taskId = htobe64(1); dropMsg.taskId = htobe64(1);
dropRpc.pCont = &dropMsg; dropRpc.pCont = &dropMsg;
dropRpc.contLen = sizeof(STaskDropMsg);
SSchTasksStatusMsg statusMsg = {0};
statusMsg.sId = htobe64(1);
statusRpc.pCont = &statusMsg;
statusRpc.contLen = sizeof(SSchTasksStatusMsg);
statusRpc.msgType = TDMT_VND_TASKS_STATUS;
stubSetStringToPlan(); stubSetStringToPlan();
stubSetRpcSendResponse();
code = qWorkerInit(NULL, &mgmt); code = qWorkerInit(NULL, &mgmt);
ASSERT_EQ(code, 0); ASSERT_EQ(code, 0);
statusMsg.sId = htobe64(1);
code = qWorkerProcessStatusMsg(mockPointer, mgmt, &statusRpc);
ASSERT_EQ(code, 0);
code = qWorkerProcessQueryMsg(mockPointer, mgmt, &queryRpc); code = qWorkerProcessQueryMsg(mockPointer, mgmt, &queryRpc);
ASSERT_EQ(code, 0); ASSERT_EQ(code, 0);
statusMsg.sId = htobe64(1);
code = qWorkerProcessStatusMsg(mockPointer, mgmt, &statusRpc);
ASSERT_EQ(code, 0);
code = qWorkerProcessReadyMsg(mockPointer, mgmt, &readyRpc); code = qWorkerProcessReadyMsg(mockPointer, mgmt, &readyRpc);
ASSERT_EQ(code, 0); ASSERT_EQ(code, 0);
statusMsg.sId = htobe64(1);
code = qWorkerProcessStatusMsg(mockPointer, mgmt, &statusRpc);
ASSERT_EQ(code, 0);
code = qWorkerProcessFetchMsg(mockPointer, mgmt, &fetchRpc); code = qWorkerProcessFetchMsg(mockPointer, mgmt, &fetchRpc);
ASSERT_EQ(code, 0); ASSERT_EQ(code, 0);
statusMsg.sId = htobe64(1);
code = qWorkerProcessStatusMsg(mockPointer, mgmt, &statusRpc);
ASSERT_EQ(code, 0);
code = qWorkerProcessDropMsg(mockPointer, mgmt, &dropRpc); code = qWorkerProcessDropMsg(mockPointer, mgmt, &dropRpc);
ASSERT_EQ(code, 0); ASSERT_EQ(code, 0);
statusMsg.sId = htobe64(1);
code = qWorkerProcessStatusMsg(mockPointer, mgmt, &statusRpc);
ASSERT_EQ(code, 0);
qWorkerDestroy(&mgmt);
}
TEST(seqTest, cancelFirst) {
void *mgmt = NULL;
int32_t code = 0;
void *mockPointer = (void *)0x1;
SRpcMsg queryRpc = {0};
SRpcMsg dropRpc = {0};
SRpcMsg statusRpc = {0};
SSubQueryMsg *queryMsg = (SSubQueryMsg *)calloc(1, sizeof(SSubQueryMsg) + 100);
queryMsg->queryId = htobe64(1);
queryMsg->sId = htobe64(1);
queryMsg->taskId = htobe64(1);
queryMsg->contentLen = htonl(100);
queryRpc.pCont = queryMsg;
queryRpc.contLen = sizeof(SSubQueryMsg) + 100;
STaskDropMsg dropMsg = {0};
dropMsg.sId = htobe64(1);
dropMsg.queryId = htobe64(1);
dropMsg.taskId = htobe64(1);
dropRpc.pCont = &dropMsg;
dropRpc.contLen = sizeof(STaskDropMsg);
SSchTasksStatusMsg statusMsg = {0};
statusMsg.sId = htobe64(1);
statusRpc.pCont = &statusMsg;
statusRpc.contLen = sizeof(SSchTasksStatusMsg);
statusRpc.msgType = TDMT_VND_TASKS_STATUS;
stubSetStringToPlan();
stubSetRpcSendResponse();
code = qWorkerInit(NULL, &mgmt);
ASSERT_EQ(code, 0);
statusMsg.sId = htobe64(1);
code = qWorkerProcessStatusMsg(mockPointer, mgmt, &statusRpc);
ASSERT_EQ(code, 0);
code = qWorkerProcessDropMsg(mockPointer, mgmt, &dropRpc);
ASSERT_EQ(code, 0);
statusMsg.sId = htobe64(1);
code = qWorkerProcessStatusMsg(mockPointer, mgmt, &statusRpc);
ASSERT_EQ(code, 0);
code = qWorkerProcessQueryMsg(mockPointer, mgmt, &queryRpc);
ASSERT_EQ(code, 0);
statusMsg.sId = htobe64(1);
code = qWorkerProcessStatusMsg(mockPointer, mgmt, &statusRpc);
ASSERT_EQ(code, 0);
qWorkerDestroy(&mgmt);
}
TEST(seqTest, randCase) {
void *mgmt = NULL;
int32_t code = 0;
void *mockPointer = (void *)0x1;
SRpcMsg queryRpc = {0};
SRpcMsg readyRpc = {0};
SRpcMsg fetchRpc = {0};
SRpcMsg dropRpc = {0};
SRpcMsg statusRpc = {0};
SSubQueryMsg *queryMsg = (SSubQueryMsg *)calloc(1, sizeof(SSubQueryMsg) + 100);
queryMsg->queryId = htobe64(1);
queryMsg->sId = htobe64(1);
queryMsg->taskId = htobe64(1);
queryMsg->contentLen = htonl(100);
queryRpc.pCont = queryMsg;
queryRpc.contLen = sizeof(SSubQueryMsg) + 100;
SResReadyMsg readyMsg = {0};
readyMsg.sId = htobe64(1);
readyMsg.queryId = htobe64(1);
readyMsg.taskId = htobe64(1);
readyRpc.pCont = &readyMsg;
readyRpc.contLen = sizeof(SResReadyMsg);
SResFetchMsg fetchMsg = {0};
fetchMsg.sId = htobe64(1);
fetchMsg.queryId = htobe64(1);
fetchMsg.taskId = htobe64(1);
fetchRpc.pCont = &fetchMsg;
fetchRpc.contLen = sizeof(SResFetchMsg);
STaskDropMsg dropMsg = {0};
dropMsg.sId = htobe64(1);
dropMsg.queryId = htobe64(1);
dropMsg.taskId = htobe64(1);
dropRpc.pCont = &dropMsg;
dropRpc.contLen = sizeof(STaskDropMsg);
SSchTasksStatusMsg statusMsg = {0};
statusMsg.sId = htobe64(1);
statusRpc.pCont = &statusMsg;
statusRpc.contLen = sizeof(SSchTasksStatusMsg);
statusRpc.msgType = TDMT_VND_TASKS_STATUS;
stubSetStringToPlan();
stubSetRpcSendResponse();
srand(time(NULL));
code = qWorkerInit(NULL, &mgmt);
ASSERT_EQ(code, 0);
int32_t t = 0;
int32_t maxr = 10001;
while (true) {
int32_t r = rand() % maxr;
if (r >= 0 && r < maxr/5) {
printf("Query,%d\n", t++);
code = qWorkerProcessQueryMsg(mockPointer, mgmt, &queryRpc);
} else if (r >= maxr/5 && r < maxr * 2/5) {
printf("Ready,%d\n", t++);
code = qWorkerProcessReadyMsg(mockPointer, mgmt, &readyRpc);
} else if (r >= maxr * 2/5 && r < maxr* 3/5) {
printf("Fetch,%d\n", t++);
code = qWorkerProcessFetchMsg(mockPointer, mgmt, &fetchRpc);
} else if (r >= maxr * 3/5 && r < maxr * 4/5) {
printf("Drop,%d\n", t++);
code = qWorkerProcessDropMsg(mockPointer, mgmt, &dropRpc);
} else if (r >= maxr * 4/5 && r < maxr-1) {
printf("Status,%d\n", t++);
statusMsg.sId = htobe64(1);
code = qWorkerProcessStatusMsg(mockPointer, mgmt, &statusRpc);
ASSERT_EQ(code, 0);
} else {
printf("QUIT RAND NOW");
break;
}
}
qWorkerDestroy(&mgmt);
}
TEST(seqTest, multithreadRand) {
void *mgmt = NULL;
int32_t code = 0;
void *mockPointer = (void *)0x1;
stubSetStringToPlan();
stubSetRpcSendResponse();
srand(time(NULL));
code = qWorkerInit(NULL, &mgmt);
ASSERT_EQ(code, 0);
pthread_attr_t thattr;
pthread_attr_init(&thattr);
pthread_t t1,t2,t3,t4,t5;
pthread_create(&(t1), &thattr, queryThread, mgmt);
pthread_create(&(t2), &thattr, readyThread, NULL);
pthread_create(&(t3), &thattr, fetchThread, NULL);
pthread_create(&(t4), &thattr, dropThread, NULL);
pthread_create(&(t5), &thattr, statusThread, NULL);
int32_t t = 0;
int32_t maxr = 10001;
sleep(300);
testStop = true;
sleep(1);
qWorkerDestroy(&mgmt);
} }
......
...@@ -38,11 +38,16 @@ enum { ...@@ -38,11 +38,16 @@ enum {
typedef struct SSchedulerMgmt { typedef struct SSchedulerMgmt {
uint64_t taskId; uint64_t taskId;
uint64_t schedulerId; uint64_t sId;
SSchedulerCfg cfg; SSchedulerCfg cfg;
SHashObj *jobs; // key: queryId, value: SQueryJob* SHashObj *jobs; // key: queryId, value: SQueryJob*
} SSchedulerMgmt; } SSchedulerMgmt;
typedef struct SSchCallbackParam {
uint64_t queryId;
uint64_t taskId;
} SSchCallbackParam;
typedef struct SSchLevel { typedef struct SSchLevel {
int32_t level; int32_t level;
int8_t status; int8_t status;
...@@ -120,6 +125,7 @@ typedef struct SSchJob { ...@@ -120,6 +125,7 @@ typedef struct SSchJob {
extern int32_t schLaunchTask(SSchJob *job, SSchTask *task); extern int32_t schLaunchTask(SSchJob *job, SSchTask *task);
extern int32_t schBuildAndSendMsg(SSchJob *job, SSchTask *task, int32_t msgType);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -21,36 +21,6 @@ ...@@ -21,36 +21,6 @@
SSchedulerMgmt schMgmt = {0}; SSchedulerMgmt schMgmt = {0};
int32_t schBuildAndSendRequest(void *pRpc, const SEpSet* pMgmtEps, __taos_async_fn_t fp) {
/*
SRequestObj *pRequest = createRequest(pTscObj, fp, param, TSDB_SQL_CONNECT);
if (pRequest == NULL) {
return TSDB_CODE_TSC_OUT_OF_MEMORY;
}
SRequestMsgBody body = {0};
buildConnectMsg(pRequest, &body);
int64_t transporterId = 0;
asyncSendMsgToServer(pTscObj->pTransporter, &pTscObj->pAppInfo->mgmtEp.epSet, &body, &transporterId);
tsem_wait(&pRequest->body.rspSem);
destroyConnectMsg(&body);
if (pRequest->code != TSDB_CODE_SUCCESS) {
const char *errorMsg = (pRequest->code == TSDB_CODE_RPC_FQDN_ERROR) ? taos_errstr(pRequest) : tstrerror(terrno);
printf("failed to connect to server, reason: %s\n\n", errorMsg);
destroyRequest(pRequest);
taos_close(pTscObj);
pTscObj = NULL;
} else {
tscDebug("0x%"PRIx64" connection is opening, connId:%d, dnodeConn:%p", pTscObj->id, pTscObj->connId, pTscObj->pTransporter);
destroyRequest(pRequest);
}
*/
}
int32_t schBuildTaskRalation(SSchJob *job, SHashObj *planToTask) { int32_t schBuildTaskRalation(SSchJob *job, SHashObj *planToTask) {
for (int32_t i = 0; i < job->levelNum; ++i) { for (int32_t i = 0; i < job->levelNum; ++i) {
SSchLevel *level = taosArrayGet(job->levels, i); SSchLevel *level = taosArrayGet(job->levels, i);
...@@ -312,100 +282,6 @@ int32_t schMoveTaskToFailList(SSchJob *job, SSchTask *task, bool *moved) { ...@@ -312,100 +282,6 @@ int32_t schMoveTaskToFailList(SSchJob *job, SSchTask *task, bool *moved) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t schAsyncSendMsg(SSchJob *job, SSchTask *task, int32_t msgType) {
int32_t msgSize = 0;
void *msg = NULL;
switch (msgType) {
case TDMT_VND_SUBMIT: {
if (NULL == task->msg || task->msgLen <= 0) {
qError("submit msg is NULL");
SCH_ERR_RET(TSDB_CODE_SCH_INTERNAL_ERROR);
}
msgSize = task->msgLen;
msg = task->msg;
break;
}
case TDMT_VND_QUERY: {
if (NULL == task->msg) {
qError("query msg is NULL");
SCH_ERR_RET(TSDB_CODE_SCH_INTERNAL_ERROR);
}
msgSize = sizeof(SSubQueryMsg) + task->msgLen;
msg = calloc(1, msgSize);
if (NULL == msg) {
qError("calloc %d failed", msgSize);
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
}
SSubQueryMsg *pMsg = msg;
pMsg->schedulerId = htobe64(schMgmt.schedulerId);
pMsg->queryId = htobe64(job->queryId);
pMsg->taskId = htobe64(task->taskId);
pMsg->contentLen = htonl(task->msgLen);
memcpy(pMsg->msg, task->msg, task->msgLen);
break;
}
case TDMT_VND_RES_READY: {
msgSize = sizeof(SResReadyMsg);
msg = calloc(1, msgSize);
if (NULL == msg) {
qError("calloc %d failed", msgSize);
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
}
SResReadyMsg *pMsg = msg;
pMsg->schedulerId = htobe64(schMgmt.schedulerId);
pMsg->queryId = htobe64(job->queryId);
pMsg->taskId = htobe64(task->taskId);
break;
}
case TDMT_VND_FETCH: {
if (NULL == task) {
SCH_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
}
msgSize = sizeof(SResFetchMsg);
msg = calloc(1, msgSize);
if (NULL == msg) {
qError("calloc %d failed", msgSize);
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
}
SResFetchMsg *pMsg = msg;
pMsg->schedulerId = htobe64(schMgmt.schedulerId);
pMsg->queryId = htobe64(job->queryId);
pMsg->taskId = htobe64(task->taskId);
break;
}
case TDMT_VND_DROP_TASK:{
msgSize = sizeof(STaskDropMsg);
msg = calloc(1, msgSize);
if (NULL == msg) {
qError("calloc %d failed", msgSize);
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
}
STaskDropMsg *pMsg = msg;
pMsg->schedulerId = htobe64(schMgmt.schedulerId);
pMsg->queryId = htobe64(job->queryId);
pMsg->taskId = htobe64(task->taskId);
break;
}
default:
qError("unknown msg type:%d", msgType);
break;
}
//TODO SEND MSG
//taosAsyncExec(rpcSendRequest(void * shandle, const SEpSet * pEpSet, SRpcMsg * pMsg, int64_t * pRid), p, &code);
return TSDB_CODE_SUCCESS;
}
int32_t schTaskCheckAndSetRetry(SSchJob *job, SSchTask *task, int32_t errCode, bool *needRetry) { int32_t schTaskCheckAndSetRetry(SSchJob *job, SSchTask *task, int32_t errCode, bool *needRetry) {
// TODO set retry or not based on task type/errCode/retry times/job status/available eps... // TODO set retry or not based on task type/errCode/retry times/job status/available eps...
// TODO if needRetry, set task retry info // TODO if needRetry, set task retry info
...@@ -424,7 +300,7 @@ int32_t schFetchFromRemote(SSchJob *job) { ...@@ -424,7 +300,7 @@ int32_t schFetchFromRemote(SSchJob *job) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
SCH_ERR_JRET(schAsyncSendMsg(job, job->fetchTask, TDMT_VND_FETCH)); SCH_ERR_JRET(schBuildAndSendMsg(job, job->fetchTask, TDMT_VND_FETCH));
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
...@@ -577,11 +453,11 @@ int32_t schProcessOnTaskFailure(SSchJob *job, SSchTask *task, int32_t errCode) { ...@@ -577,11 +453,11 @@ int32_t schProcessOnTaskFailure(SSchJob *job, SSchTask *task, int32_t errCode) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t schHandleRspMsg(SSchJob *job, SSchTask *task, int32_t msgType, char *msg, int32_t msgSize, int32_t rspCode) { int32_t schProcessRspMsg(SSchJob *job, SSchTask *task, int32_t msgType, char *msg, int32_t msgSize, int32_t rspCode) {
int32_t code = 0; int32_t code = 0;
switch (msgType) { switch (msgType) {
case TDMT_VND_SUBMIT: { case TDMT_VND_SUBMIT_RSP: {
SShellSubmitRspMsg *rsp = (SShellSubmitRspMsg *)msg; SShellSubmitRspMsg *rsp = (SShellSubmitRspMsg *)msg;
if (rsp->code != TSDB_CODE_SUCCESS) { if (rsp->code != TSDB_CODE_SUCCESS) {
SCH_ERR_JRET(schProcessOnTaskFailure(job, task, rsp->code)); SCH_ERR_JRET(schProcessOnTaskFailure(job, task, rsp->code));
...@@ -595,20 +471,20 @@ int32_t schHandleRspMsg(SSchJob *job, SSchTask *task, int32_t msgType, char *msg ...@@ -595,20 +471,20 @@ int32_t schHandleRspMsg(SSchJob *job, SSchTask *task, int32_t msgType, char *msg
} }
break; break;
} }
case TDMT_VND_QUERY: { case TDMT_VND_QUERY_RSP: {
SQueryTableRsp *rsp = (SQueryTableRsp *)msg; SQueryTableRsp *rsp = (SQueryTableRsp *)msg;
if (rsp->code != TSDB_CODE_SUCCESS) { if (rsp->code != TSDB_CODE_SUCCESS) {
SCH_ERR_JRET(schProcessOnTaskFailure(job, task, rsp->code)); SCH_ERR_JRET(schProcessOnTaskFailure(job, task, rsp->code));
} else { } else {
code = schAsyncSendMsg(job, task, TDMT_VND_RES_READY); code = schBuildAndSendMsg(job, task, TDMT_VND_RES_READY);
if (code) { if (code) {
goto _task_error; goto _task_error;
} }
} }
break; break;
} }
case TDMT_VND_RES_READY: { case TDMT_VND_RES_READY_RSP: {
SResReadyRsp *rsp = (SResReadyRsp *)msg; SResReadyRsp *rsp = (SResReadyRsp *)msg;
if (rsp->code != TSDB_CODE_SUCCESS) { if (rsp->code != TSDB_CODE_SUCCESS) {
...@@ -621,7 +497,7 @@ int32_t schHandleRspMsg(SSchJob *job, SSchTask *task, int32_t msgType, char *msg ...@@ -621,7 +497,7 @@ int32_t schHandleRspMsg(SSchJob *job, SSchTask *task, int32_t msgType, char *msg
} }
break; break;
} }
case TDMT_VND_FETCH: { case TDMT_VND_FETCH_RSP: {
SCH_ERR_JRET(rspCode); SCH_ERR_JRET(rspCode);
SRetrieveTableRsp *rsp = (SRetrieveTableRsp *)msg; SRetrieveTableRsp *rsp = (SRetrieveTableRsp *)msg;
...@@ -631,6 +507,9 @@ int32_t schHandleRspMsg(SSchJob *job, SSchTask *task, int32_t msgType, char *msg ...@@ -631,6 +507,9 @@ int32_t schHandleRspMsg(SSchJob *job, SSchTask *task, int32_t msgType, char *msg
SCH_ERR_JRET(schProcessOnDataFetched(job)); SCH_ERR_JRET(schProcessOnDataFetched(job));
break; break;
} }
case TDMT_VND_DROP_TASK: {
}
default: default:
qError("unknown msg type:%d received", msgType); qError("unknown msg type:%d received", msgType);
return TSDB_CODE_QRY_INVALID_INPUT; return TSDB_CODE_QRY_INVALID_INPUT;
...@@ -648,6 +527,211 @@ _return: ...@@ -648,6 +527,211 @@ _return:
} }
int32_t schHandleCallback(void* param, const SDataBuf* pMsg, int32_t msgType, int32_t rspCode) {
int32_t code = 0;
SSchCallbackParam *pParam = (SSchCallbackParam *)param;
SSchJob **job = taosHashGet(schMgmt.jobs, &pParam->queryId, sizeof(pParam->queryId));
if (NULL == job || NULL == (*job)) {
qError("taosHashGet queryId:%"PRIx64" not exist", pParam->queryId);
SCH_ERR_JRET(TSDB_CODE_SCH_INTERNAL_ERROR);
}
SSchTask **task = taosHashGet((*job)->execTasks, &pParam->taskId, sizeof(pParam->taskId));
if (NULL == task || NULL == (*task)) {
qError("taosHashGet taskId:%"PRIx64" not exist", pParam->taskId);
SCH_ERR_JRET(TSDB_CODE_SCH_INTERNAL_ERROR);
}
schProcessRspMsg(*job, *task, msgType, pMsg->pData, pMsg->len, rspCode);
_return:
tfree(param);
SCH_RET(code);
}
int32_t schHandleSubmitCallback(void* param, const SDataBuf* pMsg, int32_t code) {
return schHandleCallback(param, pMsg, TDMT_VND_SUBMIT_RSP, code);
}
int32_t schHandleQueryCallback(void* param, const SDataBuf* pMsg, int32_t code) {
return schHandleCallback(param, pMsg, TDMT_VND_QUERY_RSP, code);
}
int32_t schHandleFetchCallback(void* param, const SDataBuf* pMsg, int32_t code) {
return schHandleCallback(param, pMsg, TDMT_VND_FETCH_RSP, code);
}
int32_t schHandleReadyCallback(void* param, const SDataBuf* pMsg, int32_t code) {
return schHandleCallback(param, pMsg, TDMT_VND_RES_READY_RSP, code);
}
int32_t schHandleDropCallback(void* param, const SDataBuf* pMsg, int32_t code) {
SSchCallbackParam *pParam = (SSchCallbackParam *)param;
qDebug("drop task rsp received, queryId:%"PRIx64 ",taksId:%"PRIx64 ",code:%d", pParam->queryId, pParam->taskId, code);
}
int32_t schGetCallbackFp(int32_t msgType, __async_send_cb_fn_t *fp) {
switch (msgType) {
case TDMT_VND_SUBMIT:
*fp = schHandleSubmitCallback;
break;
case TDMT_VND_QUERY:
*fp = schHandleQueryCallback;
break;
case TDMT_VND_RES_READY:
*fp = schHandleReadyCallback;
break;
case TDMT_VND_FETCH:
*fp = schHandleFetchCallback;
break;
case TDMT_VND_DROP_TASK:
*fp = schHandleDropCallback;
break;
default:
qError("unknown msg type:%d", msgType);
SCH_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
}
return TSDB_CODE_SUCCESS;
}
int32_t schAsyncSendMsg(void *transport, SEpSet* epSet, uint64_t qId, uint64_t tId, int32_t msgType, void *msg, uint32_t msgSize) {
int32_t code = 0;
SMsgSendInfo* pMsgSendInfo = calloc(1, sizeof(SMsgSendInfo));
if (NULL == pMsgSendInfo) {
qError("calloc %d failed", (int32_t)sizeof(SMsgSendInfo));
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
}
SSchCallbackParam *param = calloc(1, sizeof(SSchCallbackParam));
if (NULL == param) {
qError("calloc %d failed", (int32_t)sizeof(SSchCallbackParam));
SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
}
__async_send_cb_fn_t fp = NULL;
SCH_ERR_JRET(schGetCallbackFp(msgType, &fp));
param->queryId = qId;
param->taskId = tId;
pMsgSendInfo->param = param;
pMsgSendInfo->msgInfo.pData = msg;
pMsgSendInfo->msgInfo.len = msgSize;
pMsgSendInfo->msgType = msgType;
pMsgSendInfo->fp = fp;
int64_t transporterId = 0;
SCH_ERR_JRET(asyncSendMsgToServer(transport, epSet, &transporterId, pMsgSendInfo));
return TSDB_CODE_SUCCESS;
_return:
tfree(param);
tfree(pMsgSendInfo);
SCH_RET(code);
}
int32_t schBuildAndSendMsg(SSchJob *job, SSchTask *task, int32_t msgType) {
uint32_t msgSize = 0;
void *msg = NULL;
int32_t code = 0;
switch (msgType) {
case TDMT_VND_SUBMIT: {
if (NULL == task->msg || task->msgLen <= 0) {
qError("submit msg is NULL");
SCH_ERR_RET(TSDB_CODE_SCH_INTERNAL_ERROR);
}
msgSize = task->msgLen;
msg = task->msg;
break;
}
case TDMT_VND_QUERY: {
if (NULL == task->msg) {
qError("query msg is NULL");
SCH_ERR_RET(TSDB_CODE_SCH_INTERNAL_ERROR);
}
msgSize = sizeof(SSubQueryMsg) + task->msgLen;
msg = calloc(1, msgSize);
if (NULL == msg) {
qError("calloc %d failed", msgSize);
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
}
SSubQueryMsg *pMsg = msg;
pMsg->sId = htobe64(schMgmt.sId);
pMsg->queryId = htobe64(job->queryId);
pMsg->taskId = htobe64(task->taskId);
pMsg->contentLen = htonl(task->msgLen);
memcpy(pMsg->msg, task->msg, task->msgLen);
break;
}
case TDMT_VND_RES_READY: {
msgSize = sizeof(SResReadyMsg);
msg = calloc(1, msgSize);
if (NULL == msg) {
qError("calloc %d failed", msgSize);
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
}
SResReadyMsg *pMsg = msg;
pMsg->sId = htobe64(schMgmt.sId);
pMsg->queryId = htobe64(job->queryId);
pMsg->taskId = htobe64(task->taskId);
break;
}
case TDMT_VND_FETCH: {
if (NULL == task) {
SCH_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
}
msgSize = sizeof(SResFetchMsg);
msg = calloc(1, msgSize);
if (NULL == msg) {
qError("calloc %d failed", msgSize);
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
}
SResFetchMsg *pMsg = msg;
pMsg->sId = htobe64(schMgmt.sId);
pMsg->queryId = htobe64(job->queryId);
pMsg->taskId = htobe64(task->taskId);
break;
}
case TDMT_VND_DROP_TASK:{
msgSize = sizeof(STaskDropMsg);
msg = calloc(1, msgSize);
if (NULL == msg) {
qError("calloc %d failed", msgSize);
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
}
STaskDropMsg *pMsg = msg;
pMsg->sId = htobe64(schMgmt.sId);
pMsg->queryId = htobe64(job->queryId);
pMsg->taskId = htobe64(task->taskId);
break;
}
default:
qError("unknown msg type:%d", msgType);
SCH_ERR_RET(TSDB_CODE_SCH_INTERNAL_ERROR);
break;
}
SCH_ERR_JRET(schAsyncSendMsg(job->transport, &task->plan->execEpSet, job->queryId, task->taskId, msgType, msg, msgSize));
return TSDB_CODE_SUCCESS;
_return:
tfree(msg);
SCH_RET(code);
}
int32_t schLaunchTask(SSchJob *job, SSchTask *task) { int32_t schLaunchTask(SSchJob *job, SSchTask *task) {
...@@ -664,7 +748,7 @@ int32_t schLaunchTask(SSchJob *job, SSchTask *task) { ...@@ -664,7 +748,7 @@ int32_t schLaunchTask(SSchJob *job, SSchTask *task) {
int32_t msgType = (plan->type == QUERY_TYPE_MODIFY) ? TDMT_VND_SUBMIT : TDMT_VND_QUERY; int32_t msgType = (plan->type == QUERY_TYPE_MODIFY) ? TDMT_VND_SUBMIT : TDMT_VND_QUERY;
SCH_ERR_RET(schAsyncSendMsg(job, task, msgType)); SCH_ERR_RET(schBuildAndSendMsg(job, task, msgType));
SCH_ERR_RET(schPushTaskToExecList(job, task)); SCH_ERR_RET(schPushTaskToExecList(job, task));
...@@ -673,6 +757,8 @@ int32_t schLaunchTask(SSchJob *job, SSchTask *task) { ...@@ -673,6 +757,8 @@ int32_t schLaunchTask(SSchJob *job, SSchTask *task) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t schLaunchJob(SSchJob *job) { int32_t schLaunchJob(SSchJob *job) {
SSchLevel *level = taosArrayGet(job->levels, job->levelIdx); SSchLevel *level = taosArrayGet(job->levels, job->levelIdx);
for (int32_t i = 0; i < level->taskNum; ++i) { for (int32_t i = 0; i < level->taskNum; ++i) {
...@@ -690,7 +776,7 @@ void schDropJobAllTasks(SSchJob *job) { ...@@ -690,7 +776,7 @@ void schDropJobAllTasks(SSchJob *job) {
while (pIter) { while (pIter) {
SSchTask *task = *(SSchTask **)pIter; SSchTask *task = *(SSchTask **)pIter;
schAsyncSendMsg(job, task, TDMT_VND_DROP_TASK); schBuildAndSendMsg(job, task, TDMT_VND_DROP_TASK);
pIter = taosHashIterate(job->succTasks, pIter); pIter = taosHashIterate(job->succTasks, pIter);
} }
...@@ -699,7 +785,7 @@ void schDropJobAllTasks(SSchJob *job) { ...@@ -699,7 +785,7 @@ void schDropJobAllTasks(SSchJob *job) {
while (pIter) { while (pIter) {
SSchTask *task = *(SSchTask **)pIter; SSchTask *task = *(SSchTask **)pIter;
schAsyncSendMsg(job, task, TDMT_VND_DROP_TASK); schBuildAndSendMsg(job, task, TDMT_VND_DROP_TASK);
pIter = taosHashIterate(job->succTasks, pIter); pIter = taosHashIterate(job->succTasks, pIter);
} }
...@@ -717,7 +803,7 @@ int32_t schedulerInit(SSchedulerCfg *cfg) { ...@@ -717,7 +803,7 @@ int32_t schedulerInit(SSchedulerCfg *cfg) {
SCH_ERR_LRET(TSDB_CODE_QRY_OUT_OF_MEMORY, "init %d schduler jobs failed", schMgmt.cfg.maxJobNum); SCH_ERR_LRET(TSDB_CODE_QRY_OUT_OF_MEMORY, "init %d schduler jobs failed", schMgmt.cfg.maxJobNum);
} }
schMgmt.schedulerId = 1; //TODO GENERATE A UUID schMgmt.sId = 1; //TODO GENERATE A UUID
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
namespace { namespace {
extern "C" int32_t schHandleRspMsg(SSchJob *job, SSchTask *task, int32_t msgType, char *msg, int32_t msgSize, int32_t rspCode); extern "C" int32_t schProcessRspMsg(SSchJob *job, SSchTask *task, int32_t msgType, char *msg, int32_t msgSize, int32_t rspCode);
void schtBuildQueryDag(SQueryDag *dag) { void schtBuildQueryDag(SQueryDag *dag) {
uint64_t qId = 0x0000000000000001; uint64_t qId = 0x0000000000000001;
...@@ -182,7 +182,7 @@ void *schtSendRsp(void *param) { ...@@ -182,7 +182,7 @@ void *schtSendRsp(void *param) {
SShellSubmitRspMsg rsp = {0}; SShellSubmitRspMsg rsp = {0};
rsp.affectedRows = 10; rsp.affectedRows = 10;
schHandleRspMsg(job, task, TDMT_VND_SUBMIT, (char *)&rsp, sizeof(rsp), 0); schProcessRspMsg(job, task, TDMT_VND_SUBMIT, (char *)&rsp, sizeof(rsp), 0);
pIter = taosHashIterate(job->execTasks, pIter); pIter = taosHashIterate(job->execTasks, pIter);
} }
...@@ -227,7 +227,7 @@ TEST(queryTest, normalCase) { ...@@ -227,7 +227,7 @@ TEST(queryTest, normalCase) {
SSchTask *task = *(SSchTask **)pIter; SSchTask *task = *(SSchTask **)pIter;
SQueryTableRsp rsp = {0}; SQueryTableRsp rsp = {0};
code = schHandleRspMsg(job, task, TDMT_VND_QUERY, (char *)&rsp, sizeof(rsp), 0); code = schProcessRspMsg(job, task, TDMT_VND_QUERY, (char *)&rsp, sizeof(rsp), 0);
ASSERT_EQ(code, 0); ASSERT_EQ(code, 0);
pIter = taosHashIterate(job->execTasks, pIter); pIter = taosHashIterate(job->execTasks, pIter);
...@@ -238,7 +238,7 @@ TEST(queryTest, normalCase) { ...@@ -238,7 +238,7 @@ TEST(queryTest, normalCase) {
SSchTask *task = *(SSchTask **)pIter; SSchTask *task = *(SSchTask **)pIter;
SResReadyRsp rsp = {0}; SResReadyRsp rsp = {0};
code = schHandleRspMsg(job, task, TDMT_VND_RES_READY, (char *)&rsp, sizeof(rsp), 0); code = schProcessRspMsg(job, task, TDMT_VND_RES_READY, (char *)&rsp, sizeof(rsp), 0);
ASSERT_EQ(code, 0); ASSERT_EQ(code, 0);
pIter = taosHashIterate(job->execTasks, pIter); pIter = taosHashIterate(job->execTasks, pIter);
...@@ -249,7 +249,7 @@ TEST(queryTest, normalCase) { ...@@ -249,7 +249,7 @@ TEST(queryTest, normalCase) {
SSchTask *task = *(SSchTask **)pIter; SSchTask *task = *(SSchTask **)pIter;
SQueryTableRsp rsp = {0}; SQueryTableRsp rsp = {0};
code = schHandleRspMsg(job, task, TDMT_VND_QUERY, (char *)&rsp, sizeof(rsp), 0); code = schProcessRspMsg(job, task, TDMT_VND_QUERY, (char *)&rsp, sizeof(rsp), 0);
ASSERT_EQ(code, 0); ASSERT_EQ(code, 0);
pIter = taosHashIterate(job->execTasks, pIter); pIter = taosHashIterate(job->execTasks, pIter);
...@@ -260,7 +260,7 @@ TEST(queryTest, normalCase) { ...@@ -260,7 +260,7 @@ TEST(queryTest, normalCase) {
SSchTask *task = *(SSchTask **)pIter; SSchTask *task = *(SSchTask **)pIter;
SResReadyRsp rsp = {0}; SResReadyRsp rsp = {0};
code = schHandleRspMsg(job, task, TDMT_VND_RES_READY, (char *)&rsp, sizeof(rsp), 0); code = schProcessRspMsg(job, task, TDMT_VND_RES_READY, (char *)&rsp, sizeof(rsp), 0);
ASSERT_EQ(code, 0); ASSERT_EQ(code, 0);
pIter = taosHashIterate(job->execTasks, pIter); pIter = taosHashIterate(job->execTasks, pIter);
...@@ -269,7 +269,7 @@ TEST(queryTest, normalCase) { ...@@ -269,7 +269,7 @@ TEST(queryTest, normalCase) {
SRetrieveTableRsp rsp = {0}; SRetrieveTableRsp rsp = {0};
rsp.completed = 1; rsp.completed = 1;
rsp.numOfRows = 10; rsp.numOfRows = 10;
code = schHandleRspMsg(job, NULL, TDMT_VND_FETCH, (char *)&rsp, sizeof(rsp), 0); code = schProcessRspMsg(job, NULL, TDMT_VND_FETCH, (char *)&rsp, sizeof(rsp), 0);
ASSERT_EQ(code, 0); ASSERT_EQ(code, 0);
......
...@@ -79,6 +79,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_FILE_CORRUPTED, "Data file corrupted") ...@@ -79,6 +79,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_FILE_CORRUPTED, "Data file corrupted")
TAOS_DEFINE_ERROR(TSDB_CODE_CHECKSUM_ERROR, "Checksum error") TAOS_DEFINE_ERROR(TSDB_CODE_CHECKSUM_ERROR, "Checksum error")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_MSG, "Invalid config message") TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_MSG, "Invalid config message")
TAOS_DEFINE_ERROR(TSDB_CODE_MSG_NOT_PROCESSED, "Message not processed") TAOS_DEFINE_ERROR(TSDB_CODE_MSG_NOT_PROCESSED, "Message not processed")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_PARA, "Invalid parameters")
TAOS_DEFINE_ERROR(TSDB_CODE_REF_NO_MEMORY, "Ref out of memory") TAOS_DEFINE_ERROR(TSDB_CODE_REF_NO_MEMORY, "Ref out of memory")
TAOS_DEFINE_ERROR(TSDB_CODE_REF_FULL, "too many Ref Objs") TAOS_DEFINE_ERROR(TSDB_CODE_REF_FULL, "too many Ref Objs")
TAOS_DEFINE_ERROR(TSDB_CODE_REF_ID_REMOVED, "Ref ID is removed") TAOS_DEFINE_ERROR(TSDB_CODE_REF_ID_REMOVED, "Ref ID is removed")
......
run general/user/basic1.sim
run general/user/monitor.sim
run general/user/pass_alter.sim
run general/user/pass_len.sim
run general/user/user_create.sim
run general/user/user_len.sim
\ No newline at end of file
...@@ -10,4 +10,7 @@ ...@@ -10,4 +10,7 @@
# ---- table # ---- table
./test.sh -f general/table/basic1.sim ./test.sh -f general/table/basic1.sim
# ---- dnode
./test.sh -f unique/dnode/basic1.sim
#======================b1-end=============== #======================b1-end===============
cd ../../../debug; cmake ..
cd ../../../debug; make
#./test.sh -f general/alter/cached_schema_after_alter.sim
./test.sh -f general/alter/count.sim
./test.sh -f general/alter/import.sim
#./test.sh -f general/alter/insert1.sim
./test.sh -f general/alter/insert2.sim
./test.sh -f general/alter/metrics.sim
./test.sh -f general/alter/table.sim
./test.sh -f general/cache/new_metrics.sim
./test.sh -f general/cache/restart_metrics.sim
./test.sh -f general/cache/restart_table.sim
./test.sh -f general/connection/connection.sim
./test.sh -f general/column/commit.sim
./test.sh -f general/column/metrics.sim
./test.sh -f general/column/table.sim
./test.sh -f general/compress/commitlog.sim
./test.sh -f general/compress/compress.sim
./test.sh -f general/compress/compress2.sim
./test.sh -f general/compress/uncompress.sim
./test.sh -f general/compute/avg.sim
./test.sh -f general/compute/bottom.sim
./test.sh -f general/compute/count.sim
./test.sh -f general/compute/diff.sim
./test.sh -f general/compute/diff2.sim
./test.sh -f general/compute/first.sim
./test.sh -f general/compute/interval.sim
./test.sh -f general/compute/last.sim
./test.sh -f general/compute/leastsquare.sim
./test.sh -f general/compute/max.sim
./test.sh -f general/compute/min.sim
./test.sh -f general/compute/null.sim
./test.sh -f general/compute/percentile.sim
./test.sh -f general/compute/stddev.sim
./test.sh -f general/compute/sum.sim
./test.sh -f general/compute/top.sim
./test.sh -f general/db/alter_option.sim
./test.sh -f general/db/alter_tables_d2.sim
./test.sh -f general/db/alter_tables_v1.sim
./test.sh -f general/db/alter_tables_v4.sim
./test.sh -f general/db/alter_vgroups.sim
./test.sh -f general/db/basic.sim
./test.sh -f general/db/basic1.sim
./test.sh -f general/db/basic2.sim
./test.sh -f general/db/basic3.sim
./test.sh -f general/db/basic4.sim
./test.sh -f general/db/basic5.sim
./test.sh -f general/db/delete_reuse1.sim
./test.sh -f general/db/delete_reuse2.sim
./test.sh -f general/db/delete_reusevnode.sim
./test.sh -f general/db/delete_reusevnode2.sim
./test.sh -f general/db/delete_writing1.sim
./test.sh -f general/db/delete_writing2.sim
./test.sh -f general/db/delete.sim
./test.sh -f general/db/len.sim
./test.sh -f general/db/repeat.sim
./test.sh -f general/db/tables.sim
./test.sh -f general/db/vnodes.sim
./test.sh -f general/field/2.sim
./test.sh -f general/field/3.sim
./test.sh -f general/field/4.sim
./test.sh -f general/field/5.sim
./test.sh -f general/field/6.sim
./test.sh -f general/field/bigint.sim
./test.sh -f general/field/binary.sim
./test.sh -f general/field/bool.sim
./test.sh -f general/field/single.sim
./test.sh -f general/field/smallint.sim
./test.sh -f general/field/tinyint.sim
./test.sh -f general/http/restful.sim
./test.sh -f general/http/restful_insert.sim
./test.sh -f general/http/restful_limit.sim
./test.sh -f general/http/restful_full.sim
./test.sh -f general/http/prepare.sim
./test.sh -f general/http/telegraf.sim
./test.sh -f general/http/grafana_bug.sim
./test.sh -f general/http/grafana.sim
./test.sh -f general/import/basic.sim
./test.sh -f general/import/commit.sim
./test.sh -f general/import/large.sim
./test.sh -f general/import/replica1.sim
./test.sh -f general/insert/basic.sim
./test.sh -f general/insert/insert_drop.sim
./test.sh -f general/insert/query_block1_memory.sim
./test.sh -f general/insert/query_block2_memory.sim
./test.sh -f general/insert/query_block1_file.sim
./test.sh -f general/insert/query_block2_file.sim
./test.sh -f general/insert/query_file_memory.sim
./test.sh -f general/insert/query_multi_file.sim
./test.sh -f general/insert/tcp.sim
./test.sh -f general/parser/alter.sim
./test.sh -f general/parser/alter1.sim
./test.sh -f general/parser/alter_stable.sim
./test.sh -f general/parser/auto_create_tb.sim
./test.sh -f general/parser/auto_create_tb_drop_tb.sim
./test.sh -f general/parser/col_arithmetic_operation.sim
./test.sh -f general/parser/columnValue.sim
./test.sh -f general/parser/commit.sim
./test.sh -f general/parser/create_db.sim
./test.sh -f general/parser/create_mt.sim
./test.sh -f general/parser/create_tb.sim
./test.sh -f general/parser/dbtbnameValidate.sim
./test.sh -f general/parser/import_commit1.sim
./test.sh -f general/parser/import_commit2.sim
./test.sh -f general/parser/import_commit3.sim
./test.sh -f general/parser/insert_tb.sim
./test.sh -f general/parser/first_last.sim
#./test.sh -f general/parser/import_file.sim
./test.sh -f general/parser/lastrow.sim
./test.sh -f general/parser/nchar.sim
./test.sh -f general/parser/null_char.sim
./test.sh -f general/parser/single_row_in_tb.sim
./test.sh -f general/parser/select_from_cache_disk.sim
./test.sh -f general/parser/mixed_blocks.sim
./test.sh -f general/parser/selectResNum.sim
./test.sh -f general/parser/limit.sim
./test.sh -f general/parser/limit1.sim
./test.sh -f general/parser/limit1_tblocks100.sim
./test.sh -f general/parser/select_across_vnodes.sim
./test.sh -f general/parser/slimit1.sim
./test.sh -f general/parser/tbnameIn.sim
./test.sh -f general/parser/projection_limit_offset.sim
./test.sh -f general/parser/limit2.sim
./test.sh -f general/parser/fill.sim
./test.sh -f general/parser/fill_stb.sim
./test.sh -f general/parser/where.sim
./test.sh -f general/parser/slimit.sim
./test.sh -f general/parser/select_with_tags.sim
./test.sh -f general/parser/interp.sim
./test.sh -f general/parser/tags_dynamically_specifiy.sim
./test.sh -f general/parser/groupby.sim
./test.sh -f general/parser/set_tag_vals.sim
#./test.sh -f general/parser/slimit_alter_tags.sim
./test.sh -f general/parser/join.sim
./test.sh -f general/parser/join_multivnode.sim
./test.sh -f general/parser/binary_escapeCharacter.sim
./test.sh -f general/parser/bug.sim
./test.sh -f general/parser/repeatAlter.sim
./test.sh -f general/stable/disk.sim
./test.sh -f general/stable/dnode3.sim
./test.sh -f general/stable/metrics.sim
./test.sh -f general/stable/refcount.sim
./test.sh -f general/stable/show.sim
./test.sh -f general/stable/values.sim
./test.sh -f general/stable/vnode3.sim
./test.sh -f general/table/autocreate.sim
./test.sh -f general/table/basic1.sim
./test.sh -f general/table/basic2.sim
./test.sh -f general/table/basic3.sim
./test.sh -f general/table/bigint.sim
./test.sh -f general/table/binary.sim
./test.sh -f general/table/bool.sim
./test.sh -f general/table/column_name.sim
./test.sh -f general/table/column_num.sim
./test.sh -f general/table/column_value.sim
./test.sh -f general/table/column2.sim
./test.sh -f general/table/date.sim
./test.sh -f general/table/db.table.sim
./test.sh -f general/table/delete_reuse1.sim
./test.sh -f general/table/delete_reuse2.sim
./test.sh -f general/table/delete_writing.sim
./test.sh -f general/table/describe.sim
./test.sh -f general/table/double.sim
./test.sh -f general/table/fill.sim
./test.sh -f general/table/float.sim
./test.sh -f general/table/int.sim
./test.sh -f general/table/limit.sim
./test.sh -f general/table/smallint.sim
./test.sh -f general/table/table_len.sim
./test.sh -f general/table/table.sim
./test.sh -f general/table/tinyint.sim
./test.sh -f general/table/vgroup.sim
./test.sh -f general/tag/3.sim
./test.sh -f general/tag/4.sim
./test.sh -f general/tag/5.sim
./test.sh -f general/tag/6.sim
./test.sh -f general/tag/add.sim
./test.sh -f general/tag/bigint.sim
./test.sh -f general/tag/binary_binary.sim
./test.sh -f general/tag/binary.sim
./test.sh -f general/tag/bool_binary.sim
./test.sh -f general/tag/bool_int.sim
./test.sh -f general/tag/bool.sim
./test.sh -f general/tag/change.sim
./test.sh -f general/tag/column.sim
#./test.sh -f general/tag/commit.sim
./test.sh -f general/tag/create.sim
./test.sh -f general/tag/delete.sim
./test.sh -f general/tag/double.sim
./test.sh -f general/tag/filter.sim
./test.sh -f general/tag/float.sim
./test.sh -f general/tag/int_binary.sim
./test.sh -f general/tag/int_float.sim
./test.sh -f general/tag/int.sim
./test.sh -f general/tag/set.sim
./test.sh -f general/tag/smallint.sim
./test.sh -f general/tag/tinyint.sim
./test.sh -f general/user/authority.sim
./test.sh -f general/user/monitor.sim
./test.sh -f general/user/pass_alter.sim
./test.sh -f general/user/pass_len.sim
./test.sh -f general/user/user_create.sim
./test.sh -f general/user/user_len.sim
./test.sh -f general/vector/metrics_field.sim
./test.sh -f general/vector/metrics_mix.sim
./test.sh -f general/vector/metrics_query.sim
./test.sh -f general/vector/metrics_tag.sim
./test.sh -f general/vector/metrics_time.sim
./test.sh -f general/vector/multi.sim
./test.sh -f general/vector/single.sim
./test.sh -f general/vector/table_field.sim
./test.sh -f general/vector/table_mix.sim
./test.sh -f general/vector/table_query.sim
./test.sh -f general/vector/table_time.sim
cd ../../../debug; cmake ..
cd ../../../debug; make
./test.sh -f unique/big/balance.sim
./test.sh -f unique/big/maxvnodes.sim
./test.sh -f unique/big/tcp.sim
./test.sh -f unique/cluster/alter.sim
./test.sh -f unique/cluster/balance1.sim
./test.sh -f unique/cluster/balance2.sim
./test.sh -f unique/cluster/balance3.sim
./test.sh -f unique/cluster/cache.sim
./test.sh -f unique/cluster/vgroup100.sim
./test.sh -f unique/column/replica3.sim
./test.sh -f unique/db/commit.sim
./test.sh -f unique/db/delete.sim
./test.sh -f unique/db/delete_part.sim
./test.sh -f unique/db/replica_add12.sim
./test.sh -f unique/db/replica_add13.sim
./test.sh -f unique/db/replica_add23.sim
./test.sh -f unique/db/replica_reduce21.sim
./test.sh -f unique/db/replica_reduce32.sim
./test.sh -f unique/db/replica_reduce31.sim
./test.sh -f unique/db/replica_part.sim
./test.sh -f unique/dnode/alternativeRole.sim
./test.sh -f unique/dnode/monitor.sim
./test.sh -f unique/dnode/monitor_bug.sim
./test.sh -f unique/dnode/simple.sim
./test.sh -f unique/dnode/balance1.sim
./test.sh -f unique/dnode/balance2.sim
./test.sh -f unique/dnode/balance3.sim
./test.sh -f unique/dnode/balancex.sim
./test.sh -f unique/dnode/data1.sim
./test.sh -f unique/dnode/m2.sim
./test.sh -f unique/dnode/m3.sim
./test.sh -f unique/dnode/lossdata.sim
./test.sh -f unique/dnode/offline1.sim
./test.sh -f unique/dnode/offline2.sim
./test.sh -f unique/dnode/offline3.sim
./test.sh -f unique/dnode/reason.sim
./test.sh -f unique/dnode/remove1.sim
./test.sh -f unique/dnode/remove2.sim
./test.sh -f unique/dnode/vnode_clean.sim
./test.sh -f unique/http/admin.sim
./test.sh -f unique/http/opentsdb.sim
./test.sh -f unique/import/replica2.sim
./test.sh -f unique/import/replica3.sim
./test.sh -f unique/stable/balance_replica1.sim
./test.sh -f unique/stable/dnode2_stop.sim
./test.sh -f unique/stable/dnode2.sim
./test.sh -f unique/stable/dnode3.sim
./test.sh -f unique/stable/replica2_dnode4.sim
./test.sh -f unique/stable/replica2_vnode3.sim
./test.sh -f unique/stable/replica3_dnode6.sim
./test.sh -f unique/stable/replica3_vnode3.sim
./test.sh -f unique/mnode/mgmt20.sim
./test.sh -f unique/mnode/mgmt21.sim
./test.sh -f unique/mnode/mgmt22.sim
./test.sh -f unique/mnode/mgmt23.sim
./test.sh -f unique/mnode/mgmt24.sim
./test.sh -f unique/mnode/mgmt25.sim
./test.sh -f unique/mnode/mgmt26.sim
./test.sh -f unique/mnode/mgmt30.sim
./test.sh -f unique/mnode/mgmt33.sim
./test.sh -f unique/mnode/mgmt34.sim
./test.sh -f unique/mnode/mgmtr2.sim
./test.sh -f unique/vnode/many.sim
./test.sh -f unique/vnode/replica2_basic2.sim
./test.sh -f unique/vnode/replica2_repeat.sim
./test.sh -f unique/vnode/replica3_basic.sim
./test.sh -f unique/vnode/replica3_repeat.sim
./test.sh -f unique/vnode/replica3_vgroup.sim
./test.sh -f unique/arbitrator/check_cluster_cfg_para.sim
#./test.sh -f unique/arbitrator/dn2_mn1_cache_file_sync.sim
./test.sh -f unique/arbitrator/dn3_mn1_full_createTableFail.sim
./test.sh -f unique/arbitrator/dn3_mn1_multiCreateDropTable.sim
#./test.sh -f unique/arbitrator/dn3_mn1_nw_disable_timeout_autoDropDnode.sim
#./test.sh -f unique/arbitrator/dn3_mn1_replica2_wal1_AddDelDnode.sim
./test.sh -f unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim
./test.sh -f unique/arbitrator/dn3_mn1_replica_change.sim
#./test.sh -f unique/arbitrator/dn3_mn1_stopDnode_timeout.sim
# lower the priority while file corruption
#./test.sh -f unique/arbitrator/dn3_mn1_vnode_change.sim
#./test.sh -f unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim
#./test.sh -f unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim
#./test.sh -f unique/arbitrator/dn3_mn1_vnode_createErrData_online.sim
./test.sh -f unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim
./test.sh -f unique/arbitrator/dn3_mn1_vnode_delDir.sim
./test.sh -f unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim
./test.sh -f unique/arbitrator/dn3_mn1_r3_vnode_delDir.sim
./test.sh -f unique/arbitrator/dn3_mn1_vnode_nomaster.sim
./test.sh -f unique/arbitrator/dn3_mn2_killDnode.sim
./test.sh -f unique/arbitrator/insert_duplicationTs.sim
./test.sh -f unique/arbitrator/offline_replica2_alterTable_online.sim
./test.sh -f unique/arbitrator/offline_replica2_alterTag_online.sim
./test.sh -f unique/arbitrator/offline_replica2_createTable_online.sim
./test.sh -f unique/arbitrator/offline_replica2_dropDb_online.sim
./test.sh -f unique/arbitrator/offline_replica2_dropTable_online.sim
./test.sh -f unique/arbitrator/offline_replica3_alterTable_online.sim
./test.sh -f unique/arbitrator/offline_replica3_alterTag_online.sim
./test.sh -f unique/arbitrator/offline_replica3_createTable_online.sim
./test.sh -f unique/arbitrator/offline_replica3_dropDb_online.sim
./test.sh -f unique/arbitrator/offline_replica3_dropTable_online.sim
./test.sh -f unique/arbitrator/replica_changeWithArbitrator.sim
./test.sh -f unique/arbitrator/sync_replica2_alterTable_add.sim
./test.sh -f unique/arbitrator/sync_replica2_alterTable_drop.sim
./test.sh -f unique/arbitrator/sync_replica2_dropDb.sim
./test.sh -f unique/arbitrator/sync_replica2_dropTable.sim
./test.sh -f unique/arbitrator/sync_replica3_alterTable_add.sim
./test.sh -f unique/arbitrator/sync_replica3_alterTable_drop.sim
./test.sh -f unique/arbitrator/sync_replica3_dropDb.sim
./test.sh -f unique/arbitrator/sync_replica3_dropTable.sim
./test.sh -f unique/migrate/mn2_vn2_repl2_rmMnodeDir.sim
./test.sh -f unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir.sim
./test.sh -f unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir_stopAll_starAll.sim
./test.sh -f unique/migrate/mn2_vn2_repl2_rmVnodeDir.sim
wtest.bat -f issue/TD-2677.sim
wtest.bat -f issue/TD-2680.sim
wtest.bat -f issue/TD-2713.sim
wtest.bat -f general/alter/cached_schema_after_alter.sim
wtest.bat -f general/alter/count.sim
wtest.bat -f general/alter/dnode.sim
wtest.bat -f general/alter/import.sim
wtest.bat -f general/alter/insert1.sim
wtest.bat -f general/alter/insert2.sim
wtest.bat -f general/alter/metrics.sim
wtest.bat -f general/alter/table.sim
wtest.bat -f general/cache/new_metrics.sim
wtest.bat -f general/cache/restart_metrics.sim
wtest.bat -f general/cache/restart_table.sim
wtest.bat -f general/connection/connection.sim
wtest.bat -f general/column/commit.sim
wtest.bat -f general/column/metrics.sim
wtest.bat -f general/column/table.sim
wtest.bat -f general/compress/commitlog.sim
wtest.bat -f general/compress/compress.sim
wtest.bat -f general/compress/compress2.sim
wtest.bat -f general/compress/uncompress.sim
wtest.bat -f general/compute/avg.sim
wtest.bat -f general/compute/bottom.sim
wtest.bat -f general/compute/count.sim
wtest.bat -f general/compute/diff.sim
wtest.bat -f general/compute/diff2.sim
wtest.bat -f general/compute/first.sim
wtest.bat -f general/compute/interval.sim
wtest.bat -f general/compute/last.sim
wtest.bat -f general/compute/leastsquare.sim
wtest.bat -f general/compute/max.sim
wtest.bat -f general/compute/min.sim
wtest.bat -f general/compute/null.sim
wtest.bat -f general/compute/percentile.sim
wtest.bat -f general/compute/stddev.sim
wtest.bat -f general/compute/sum.sim
wtest.bat -f general/compute/top.sim
wtest.bat -f general/db/alter_option.sim
wtest.bat -f general/db/alter_tables_d2.sim
wtest.bat -f general/db/alter_tables_v1.sim
wtest.bat -f general/db/alter_tables_v4.sim
wtest.bat -f general/db/alter_vgroups.sim
wtest.bat -f general/db/basic.sim
wtest.bat -f general/db/basic1.sim
wtest.bat -f general/db/basic2.sim
wtest.bat -f general/db/basic3.sim
wtest.bat -f general/db/basic4.sim
wtest.bat -f general/db/basic5.sim
wtest.bat -f general/db/delete_reuse1.sim
wtest.bat -f general/db/delete_reuse2.sim
wtest.bat -f general/db/delete_reusevnode.sim
wtest.bat -f general/db/delete_reusevnode2.sim
wtest.bat -f general/db/delete_writing1.sim
wtest.bat -f general/db/delete_writing2.sim
wtest.bat -f general/db/delete.sim
wtest.bat -f general/db/len.sim
wtest.bat -f general/db/repeat.sim
wtest.bat -f general/db/tables.sim
wtest.bat -f general/db/vnodes.sim
wtest.bat -f general/db/nosuchfile.sim
wtest.bat -f general/field/2.sim
wtest.bat -f general/field/3.sim
wtest.bat -f general/field/4.sim
wtest.bat -f general/field/5.sim
wtest.bat -f general/field/6.sim
wtest.bat -f general/field/bigint.sim
wtest.bat -f general/field/binary.sim
wtest.bat -f general/field/bool.sim
wtest.bat -f general/field/single.sim
wtest.bat -f general/field/smallint.sim
wtest.bat -f general/field/tinyint.sim
wtest.bat -f general/http/autocreate.sim
wtest.bat -f general/http/chunked.sim
wtest.bat -f general/http/gzip.sim
wtest.bat -f general/http/restful.sim
wtest.bat -f general/http/restful_insert.sim
wtest.bat -f general/http/restful_limit.sim
wtest.bat -f general/http/restful_full.sim
wtest.bat -f general/http/prepare.sim
wtest.bat -f general/http/telegraf.sim
wtest.bat -f general/http/grafana_bug.sim
wtest.bat -f general/http/grafana.sim
wtest.bat -f general/import/basic.sim
wtest.bat -f general/import/commit.sim
wtest.bat -f general/import/large.sim
wtest.bat -f general/import/replica1.sim
wtest.bat -f general/insert/basic.sim
wtest.bat -f general/insert/insert_drop.sim
wtest.bat -f general/insert/query_block1_memory.sim
wtest.bat -f general/insert/query_block2_memory.sim
wtest.bat -f general/insert/query_block1_file.sim
wtest.bat -f general/insert/query_block2_file.sim
wtest.bat -f general/insert/query_file_memory.sim
wtest.bat -f general/insert/query_multi_file.sim
wtest.bat -f general/insert/tcp.sim
wtest.bat -f general/parser/alter.sim
wtest.bat -f general/parser/alter1.sim
wtest.bat -f general/parser/alter_stable.sim
wtest.bat -f general/parser/auto_create_tb.sim
wtest.bat -f general/parser/auto_create_tb_drop_tb.sim
wtest.bat -f general/parser/col_arithmetic_operation.sim
wtest.bat -f general/parser/columnValue.sim
wtest.bat -f general/parser/commit.sim
wtest.bat -f general/parser/create_db.sim
wtest.bat -f general/parser/create_mt.sim
wtest.bat -f general/parser/create_tb.sim
wtest.bat -f general/parser/dbtbnameValidate.sim
wtest.bat -f general/parser/import_commit1.sim
wtest.bat -f general/parser/import_commit2.sim
wtest.bat -f general/parser/import_commit3.sim
wtest.bat -f general/parser/insert_tb.sim
wtest.bat -f general/parser/first_last.sim
wtest.bat -f general/parser/lastrow.sim
wtest.bat -f general/parser/nchar.sim
wtest.bat -f general/parser/null_char.sim
wtest.bat -f general/parser/single_row_in_tb.sim
wtest.bat -f general/parser/select_from_cache_disk.sim
wtest.bat -f general/parser/mixed_blocks.sim
wtest.bat -f general/parser/selectResNum.sim
wtest.bat -f general/parser/limit.sim
wtest.bat -f general/parser/limit1.sim
wtest.bat -f general/parser/limit1_tblocks100.sim
wtest.bat -f general/parser/select_across_vnodes.sim
wtest.bat -f general/parser/slimit1.sim
wtest.bat -f general/parser/tbnameIn.sim
wtest.bat -f general/parser/projection_limit_offset.sim
wtest.bat -f general/parser/limit2.sim
wtest.bat -f general/parser/fill.sim
wtest.bat -f general/parser/fill_stb.sim
wtest.bat -f general/parser/where.sim
wtest.bat -f general/parser/slimit.sim
wtest.bat -f general/parser/select_with_tags.sim
wtest.bat -f general/parser/interp.sim
wtest.bat -f general/parser/tags_dynamically_specifiy.sim
wtest.bat -f general/parser/groupby.sim
wtest.bat -f general/parser/set_tag_vals.sim
wtest.bat -f general/parser/tags_filter.sim
wtest.bat -f general/parser/slimit_alter_tags.sim
wtest.bat -f general/parser/join.sim
wtest.bat -f general/parser/join_multivnode.sim
wtest.bat -f general/parser/binary_escapeCharacter.sim
wtest.bat -f general/parser/repeatAlter.sim
wtest.bat -f general/parser/union.sim
wtest.bat -f general/parser/topbot.sim
wtest.bat -f general/parser/function.sim
wtest.bat -f general/stable/disk.sim
wtest.bat -f general/stable/dnode3.sim
wtest.bat -f general/stable/metrics.sim
wtest.bat -f general/stable/refcount.sim
wtest.bat -f general/stable/show.sim
wtest.bat -f general/stable/values.sim
wtest.bat -f general/stable/vnode3.sim
wtest.bat -f general/table/autocreate.sim
wtest.bat -f general/table/basic1.sim
wtest.bat -f general/table/basic2.sim
wtest.bat -f general/table/basic3.sim
wtest.bat -f general/table/bigint.sim
wtest.bat -f general/table/binary.sim
wtest.bat -f general/table/bool.sim
wtest.bat -f general/table/column_name.sim
wtest.bat -f general/table/column_num.sim
wtest.bat -f general/table/column_value.sim
wtest.bat -f general/table/column2.sim
wtest.bat -f general/table/date.sim
wtest.bat -f general/table/db.table.sim
wtest.bat -f general/table/delete_reuse1.sim
wtest.bat -f general/table/delete_reuse2.sim
wtest.bat -f general/table/delete_writing.sim
wtest.bat -f general/table/describe.sim
wtest.bat -f general/table/double.sim
wtest.bat -f general/table/fill.sim
wtest.bat -f general/table/float.sim
wtest.bat -f general/table/int.sim
wtest.bat -f general/table/limit.sim
wtest.bat -f general/table/smallint.sim
wtest.bat -f general/table/table_len.sim
wtest.bat -f general/table/table.sim
wtest.bat -f general/table/tinyint.sim
wtest.bat -f general/table/vgroup.sim
wtest.bat -f general/tag/3.sim
wtest.bat -f general/tag/4.sim
wtest.bat -f general/tag/5.sim
wtest.bat -f general/tag/6.sim
wtest.bat -f general/tag/add.sim
wtest.bat -f general/tag/bigint.sim
wtest.bat -f general/tag/binary_binary.sim
wtest.bat -f general/tag/binary.sim
wtest.bat -f general/tag/bool_binary.sim
wtest.bat -f general/tag/bool_int.sim
wtest.bat -f general/tag/bool.sim
wtest.bat -f general/tag/change.sim
wtest.bat -f general/tag/column.sim
wtest.bat -f general/tag/commit.sim
wtest.bat -f general/tag/create.sim
wtest.bat -f general/tag/delete.sim
wtest.bat -f general/tag/double.sim
wtest.bat -f general/tag/filter.sim
wtest.bat -f general/tag/float.sim
wtest.bat -f general/tag/int_binary.sim
wtest.bat -f general/tag/int_float.sim
wtest.bat -f general/tag/int.sim
wtest.bat -f general/tag/set.sim
wtest.bat -f general/tag/smallint.sim
wtest.bat -f general/tag/tinyint.sim
wtest.bat -f general/user/authority.sim
wtest.bat -f general/user/monitor.sim
wtest.bat -f general/user/pass_alter.sim
wtest.bat -f general/user/pass_len.sim
wtest.bat -f general/user/user_create.sim
wtest.bat -f general/user/user_len.sim
wtest.bat -f general/vector/metrics_field.sim
wtest.bat -f general/vector/metrics_mix.sim
wtest.bat -f general/vector/metrics_query.sim
wtest.bat -f general/vector/metrics_tag.sim
wtest.bat -f general/vector/metrics_time.sim
wtest.bat -f general/vector/multi.sim
wtest.bat -f general/vector/single.sim
wtest.bat -f general/vector/table_field.sim
wtest.bat -f general/vector/table_mix.sim
wtest.bat -f general/vector/table_query.sim
wtest.bat -f general/vector/table_time.sim
wtest.bat -f general/wal/sync.sim
wtest.bat -f general/wal/kill.sim
wtest.bat -f general/wal/maxtables.sim
wtest.bat -f unique/account/account_create.sim
wtest.bat -f unique/account/account_delete.sim
wtest.bat -f unique/account/account_len.sim
wtest.bat -f unique/account/authority.sim
wtest.bat -f unique/account/basic.sim
wtest.bat -f unique/account/paras.sim
wtest.bat -f unique/account/pass_alter.sim
wtest.bat -f unique/account/pass_len.sim
wtest.bat -f unique/account/usage.sim
wtest.bat -f unique/account/user_create.sim
wtest.bat -f unique/account/user_len.sim
wtest.bat -f unique/big/balance.sim
wtest.bat -f unique/big/maxvnodes.sim
wtest.bat -f unique/big/tcp.sim
wtest.bat -f unique/cluster/alter.sim
wtest.bat -f unique/cluster/balance1.sim
wtest.bat -f unique/cluster/balance2.sim
wtest.bat -f unique/cluster/balance3.sim
wtest.bat -f unique/cluster/cache.sim
wtest.bat -f unique/cluster/vgroup100.sim
wtest.bat -f unique/column/replica3.sim
wtest.bat -f unique/db/commit.sim
wtest.bat -f unique/db/delete.sim
wtest.bat -f unique/db/delete_part.sim
wtest.bat -f unique/db/replica_add12.sim
wtest.bat -f unique/db/replica_add13.sim
wtest.bat -f unique/db/replica_add23.sim
wtest.bat -f unique/db/replica_reduce21.sim
wtest.bat -f unique/db/replica_reduce32.sim
wtest.bat -f unique/db/replica_reduce31.sim
wtest.bat -f unique/db/replica_part.sim
wtest.bat -f unique/dnode/alternativeRole.sim
wtest.bat -f unique/dnode/monitor.sim
wtest.bat -f unique/dnode/monitor_bug.sim
wtest.bat -f unique/dnode/simple.sim
wtest.bat -f unique/dnode/balance1.sim
wtest.bat -f unique/dnode/balance2.sim
wtest.bat -f unique/dnode/balance3.sim
wtest.bat -f unique/dnode/balancex.sim
wtest.bat -f unique/dnode/data1.sim
wtest.bat -f unique/dnode/m2.sim
wtest.bat -f unique/dnode/m3.sim
wtest.bat -f unique/dnode/lossdata.sim
wtest.bat -f unique/dnode/offline1.sim
wtest.bat -f unique/dnode/offline2.sim
wtest.bat -f unique/dnode/offline3.sim
wtest.bat -f unique/dnode/reason.sim
wtest.bat -f unique/dnode/remove1.sim
wtest.bat -f unique/dnode/remove2.sim
wtest.bat -f unique/dnode/vnode_clean.sim
wtest.bat -f unique/http/admin.sim
wtest.bat -f unique/http/opentsdb.sim
wtest.bat -f unique/import/replica2.sim
wtest.bat -f unique/import/replica3.sim
wtest.bat -f unique/stable/balance_replica1.sim
wtest.bat -f unique/stable/dnode2_stop.sim
wtest.bat -f unique/stable/dnode2.sim
wtest.bat -f unique/stable/dnode3.sim
wtest.bat -f unique/stable/replica2_dnode4.sim
wtest.bat -f unique/stable/replica2_vnode3.sim
wtest.bat -f unique/stable/replica3_dnode6.sim
wtest.bat -f unique/stable/replica3_vnode3.sim
wtest.bat -f unique/mnode/mgmt20.sim
wtest.bat -f unique/mnode/mgmt21.sim
wtest.bat -f unique/mnode/mgmt22.sim
wtest.bat -f unique/mnode/mgmt23.sim
wtest.bat -f unique/mnode/mgmt24.sim
wtest.bat -f unique/mnode/mgmt25.sim
wtest.bat -f unique/mnode/mgmt26.sim
wtest.bat -f unique/mnode/mgmt30.sim
wtest.bat -f unique/mnode/mgmt33.sim
wtest.bat -f unique/mnode/mgmt34.sim
wtest.bat -f unique/mnode/mgmtr2.sim
wtest.bat -f unique/vnode/many.sim
wtest.bat -f unique/vnode/replica2_basic2.sim
wtest.bat -f unique/vnode/replica2_repeat.sim
wtest.bat -f unique/vnode/replica3_basic.sim
wtest.bat -f unique/vnode/replica3_repeat.sim
wtest.bat -f unique/vnode/replica3_vgroup.sim
wtest.bat -f general/stream/metrics_del.sim
wtest.bat -f general/stream/metrics_replica1_vnoden.sim
wtest.bat -f general/stream/restart_stream.sim
wtest.bat -f general/stream/stream_3.sim
wtest.bat -f general/stream/stream_restart.sim
wtest.bat -f general/stream/table_del.sim
wtest.bat -f general/stream/table_replica1_vnoden.sim
wtest.bat -f unique/arbitrator/check_cluster_cfg_para.sim
#wtest.bat -f unique/arbitrator/dn2_mn1_cache_file_sync.sim
wtest.bat -f unique/arbitrator/dn3_mn1_full_createTableFail.sim
wtest.bat -f unique/arbitrator/dn3_mn1_multiCreateDropTable.sim
#wtest.bat -f unique/arbitrator/dn3_mn1_nw_disable_timeout_autoDropDnode.sim
#wtest.bat -f unique/arbitrator/dn3_mn1_replica2_wal1_AddDelDnode.sim
wtest.bat -f unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim
wtest.bat -f unique/arbitrator/dn3_mn1_replica_change.sim
#wtest.bat -f unique/arbitrator/dn3_mn1_stopDnode_timeout.sim
# lower the priority while file corruption
#wtest.bat -f unique/arbitrator/dn3_mn1_vnode_change.sim
#wtest.bat -f unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim
#wtest.bat -f unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim
#wtest.bat -f unique/arbitrator/dn3_mn1_vnode_createErrData_online.sim
wtest.bat -f unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim
wtest.bat -f unique/arbitrator/dn3_mn1_vnode_delDir.sim
wtest.bat -f unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim
wtest.bat -f unique/arbitrator/dn3_mn1_r3_vnode_delDir.sim
wtest.bat -f unique/arbitrator/dn3_mn1_vnode_nomaster.sim
wtest.bat -f unique/arbitrator/dn3_mn2_killDnode.sim
wtest.bat -f unique/arbitrator/insert_duplicationTs.sim
wtest.bat -f unique/arbitrator/offline_replica2_alterTable_online.sim
wtest.bat -f unique/arbitrator/offline_replica2_alterTag_online.sim
wtest.bat -f unique/arbitrator/offline_replica2_createTable_online.sim
wtest.bat -f unique/arbitrator/offline_replica2_dropDb_online.sim
wtest.bat -f unique/arbitrator/offline_replica2_dropTable_online.sim
wtest.bat -f unique/arbitrator/offline_replica3_alterTable_online.sim
wtest.bat -f unique/arbitrator/offline_replica3_alterTag_online.sim
wtest.bat -f unique/arbitrator/offline_replica3_createTable_online.sim
wtest.bat -f unique/arbitrator/offline_replica3_dropDb_online.sim
wtest.bat -f unique/arbitrator/offline_replica3_dropTable_online.sim
wtest.bat -f unique/arbitrator/replica_changeWithArbitrator.sim
wtest.bat -f unique/arbitrator/sync_replica2_alterTable_add.sim
wtest.bat -f unique/arbitrator/sync_replica2_alterTable_drop.sim
wtest.bat -f unique/arbitrator/sync_replica2_dropDb.sim
wtest.bat -f unique/arbitrator/sync_replica2_dropTable.sim
wtest.bat -f unique/arbitrator/sync_replica3_alterTable_add.sim
wtest.bat -f unique/arbitrator/sync_replica3_alterTable_drop.sim
wtest.bat -f unique/arbitrator/sync_replica3_dropDb.sim
wtest.bat -f unique/arbitrator/sync_replica3_dropTable.sim
wtest.bat -f unique/migrate/mn2_vn2_repl2_rmMnodeDir.sim
wtest.bat -f unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir.sim
wtest.bat -f unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir_stopAll_starAll.sim
wtest.bat -f unique/migrate/mn2_vn2_repl2_rmVnodeDir.sim
wtest.bat -f general/connection/test_old_data.sim
wtest.bat -f unique/dnode/datatrans_3node.sim
wtest.bat -f unique/dnode/datatrans_3node_2.sim
...@@ -118,49 +118,30 @@ fi ...@@ -118,49 +118,30 @@ fi
echo " " >> $TAOS_CFG echo " " >> $TAOS_CFG
echo "firstEp ${HOSTNAME}:7100" >> $TAOS_CFG echo "firstEp ${HOSTNAME}:7100" >> $TAOS_CFG
echo "secondEp ${HOSTNAME}:7200" >> $TAOS_CFG echo "secondEp ${HOSTNAME}:7200" >> $TAOS_CFG
echo "fqdn ${HOSTNAME}" >> $TAOS_CFG
echo "serverPort ${NODE}" >> $TAOS_CFG echo "serverPort ${NODE}" >> $TAOS_CFG
echo "dataDir $DATA_DIR" >> $TAOS_CFG echo "dataDir $DATA_DIR" >> $TAOS_CFG
echo "logDir $LOG_DIR" >> $TAOS_CFG echo "logDir $LOG_DIR" >> $TAOS_CFG
echo "debugFlag 0" >> $TAOS_CFG echo "debugFlag 0" >> $TAOS_CFG
echo "mDebugFlag 143" >> $TAOS_CFG echo "mDebugFlag 143" >> $TAOS_CFG
echo "sdbDebugFlag 143" >> $TAOS_CFG
echo "dDebugFlag 143" >> $TAOS_CFG echo "dDebugFlag 143" >> $TAOS_CFG
echo "vDebugFlag 143" >> $TAOS_CFG echo "vDebugFlag 143" >> $TAOS_CFG
echo "tsdbDebugFlag 143" >> $TAOS_CFG echo "tsdbDebugFlag 143" >> $TAOS_CFG
echo "cDebugFlag 143" >> $TAOS_CFG echo "cDebugFlag 143" >> $TAOS_CFG
echo "jnidebugFlag 143" >> $TAOS_CFG echo "jnidebugFlag 143" >> $TAOS_CFG
echo "odbcdebugFlag 143" >> $TAOS_CFG
echo "httpDebugFlag 143" >> $TAOS_CFG
echo "monDebugFlag 143" >> $TAOS_CFG
echo "mqttDebugFlag 143" >> $TAOS_CFG
echo "qdebugFlag 143" >> $TAOS_CFG echo "qdebugFlag 143" >> $TAOS_CFG
echo "rpcDebugFlag 143" >> $TAOS_CFG echo "rpcDebugFlag 143" >> $TAOS_CFG
echo "tmrDebugFlag 131" >> $TAOS_CFG echo "tmrDebugFlag 131" >> $TAOS_CFG
echo "udebugFlag 143" >> $TAOS_CFG echo "udebugFlag 143" >> $TAOS_CFG
echo "sdebugFlag 143" >> $TAOS_CFG echo "sdebugFlag 143" >> $TAOS_CFG
echo "wdebugFlag 143" >> $TAOS_CFG echo "wdebugFlag 143" >> $TAOS_CFG
echo "cqdebugFlag 143" >> $TAOS_CFG
echo "monitor 0" >> $TAOS_CFG
echo "monitorInterval 1" >> $TAOS_CFG
echo "http 0" >> $TAOS_CFG
echo "slaveQuery 0" >> $TAOS_CFG echo "slaveQuery 0" >> $TAOS_CFG
echo "numOfThreadsPerCore 2.0" >> $TAOS_CFG echo "numOfThreadsPerCore 2.0" >> $TAOS_CFG
echo "defaultPass taosdata" >> $TAOS_CFG echo "defaultPass taosdata" >> $TAOS_CFG
echo "numOfLogLines 20000000" >> $TAOS_CFG echo "numOfLogLines 20000000" >> $TAOS_CFG
echo "mnodeEqualVnodeNum 0" >> $TAOS_CFG
echo "balanceInterval 1" >> $TAOS_CFG
echo "clog 2" >> $TAOS_CFG
#echo "cache 1" >> $TAOS_CFG
echo "days 10" >> $TAOS_CFG
echo "statusInterval 1" >> $TAOS_CFG echo "statusInterval 1" >> $TAOS_CFG
echo "maxVgroupsPerDb 4" >> $TAOS_CFG
echo "minTablesPerVnode 4" >> $TAOS_CFG
echo "maxTablesPerVnode 1000" >> $TAOS_CFG
echo "tableIncStepPerVnode 10000" >> $TAOS_CFG
echo "asyncLog 0" >> $TAOS_CFG echo "asyncLog 0" >> $TAOS_CFG
echo "numOfMnodes 1" >> $TAOS_CFG
echo "locale en_US.UTF-8" >> $TAOS_CFG echo "locale en_US.UTF-8" >> $TAOS_CFG
echo "fsync 0" >> $TAOS_CFG echo "fsync 0" >> $TAOS_CFG
echo "telemetryReporting 0" >> $TAOS_CFG echo "telemetryReporting 0" >> $TAOS_CFG
echo " " >> $TAOS_CFG echo " " >> $TAOS_CFG
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3
system sh/deploy.sh -n dnode4 -i 4
system sh/cfg.sh -n dnode1 -c walLevel -v 2
system sh/cfg.sh -n dnode2 -c walLevel -v 2
system sh/cfg.sh -n dnode3 -c walLevel -v 2
system sh/cfg.sh -n dnode4 -c walLevel -v 2
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode1 -c activeCode -v eglxDLzRpslJWl7OxrPZ2K3sQ5631AP9SVpezsaz2dhJWl7OxrPZ2ElaXs7Gs9nYSVpezsaz2djGIj5StnQ3ZvLHcsE8cwcN
system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 100000
system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 100000
system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 100000
system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 100000
system sh/cfg.sh -n dnode1 -c http -v 1
system sh/cfg.sh -n dnode2 -c http -v 1
system sh/cfg.sh -n dnode3 -c http -v 1
system sh/cfg.sh -n dnode4 -c http -v 1
system sh/cfg.sh -n dnode1 -c httpMaxThreads -v 4
system sh/cfg.sh -n dnode1 -c firstEp -v 127.0.0.1:6030
system sh/cfg.sh -n dnode1 -c secondEp -v 127.0.0.1:6030
system sh/cfg.sh -n dnode1 -c serverPort -v 6030
system sh/cfg.sh -n dnode1 -c fqdn -v 127.0.0.1
system sh/exec.sh -n dnode1 -s start
system sh/stop_dnodes.sh
############## config parameter #####################
$node1 = 192.168.101.174
$node2 = 192.168.0.202
$node2 = 192.168.0.203
$node3 = 192.168.0.204
$first = 1
$num = 5
$self = $node1
############### deploy firstEp #####################
$firstEp = $node1 . :7100
$firstPort = 7100
if $first == 1 then
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c firstEp -v $firstEp
system sh/cfg.sh -n dnode1 -c secondEp -v $firstEp
system sh/cfg.sh -n dnode1 -c fqdn -v $node1
system sh/cfg.sh -n dnode1 -c serverPort -v $firstPort
system sh/exec.sh -n dnode1 -s start
sql connect
$i = 0
while $i < $num
$port = $i * 100
$port = $port + 8000
$i = $i + 1
sql create dnode $node1 port $port
endw
$i = 0
while $i < $num
$port = $i * 100
$port = $port + 8000
$i = $i + 1
sql create dnode $node2 port $port
endw
$i = 0
while $i < $num
$port = $i * 100
$port = $port + 8000
$i = $i + 1
sql create dnode $node3 port $port
endw
$i = 0
while $i < $num
$port = $i * 100
$port = $port + 8000
$i = $i + 1
sql create dnode $node4 port $port
endw
endi
############### deploy nodes #####################
$i = 0
while $i < $num
$index = $i + 80
$port = $i * 100
$port = $port + 8000
$dnodename = dnode . $index
$i = $i + 1
system sh/deploy.sh -n $dnodename -i 1
system sh/cfg.sh -n $dnodename -c firstEp -v $firstEp
system sh/cfg.sh -n $dnodename -c secondEp -v $firstEp
system sh/cfg.sh -n $dnodename -c fqdn -v $self
system sh/cfg.sh -n $dnodename -c serverPort -v $port
#system sh/exec.sh -n $dnodename -s start
endw
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3
system sh/deploy.sh -n dnode4 -i 4
system sh/cfg.sh -n dnode1 -c walLevel -v 2
system sh/cfg.sh -n dnode2 -c walLevel -v 2
system sh/cfg.sh -n dnode3 -c walLevel -v 2
system sh/cfg.sh -n dnode4 -c walLevel -v 2
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode1 -c http -v 1
system sh/cfg.sh -n dnode2 -c http -v 1
system sh/cfg.sh -n dnode3 -c http -v 1
system sh/cfg.sh -n dnode1 -c monitor -v 1
system sh/cfg.sh -n dnode2 -c monitor -v 1
system sh/cfg.sh -n dnode3 -c monitor -v 1
system sh/cfg.sh -n dnode1 -c monitorInterval -v 1
system sh/cfg.sh -n dnode2 -c monitorInterval -v 1
system sh/cfg.sh -n dnode3 -c monitorInterval -v 1
system sh/exec.sh -n dnode1 -s start
\ No newline at end of file
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3
system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode1 -c http -v 0
system sh/cfg.sh -n dnode2 -c http -v 0
system sh/cfg.sh -n dnode3 -c http -v 0
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 20000
system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 20000
system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 20000
system sh/cfg.sh -n dnode1 -c minTablesPerVnode -v 1000
system sh/cfg.sh -n dnode2 -c minTablesPerVnode -v 1000
system sh/cfg.sh -n dnode3 -c minTablesPerVnode -v 1000
system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 20
system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 20
system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 20
system sh/cfg.sh -n dnode1 -c replica -v 3
system sh/cfg.sh -n dnode2 -c replica -v 3
system sh/cfg.sh -n dnode3 -c replica -v 3
print ============== deploy
system sh/exec.sh -n dnode1 -s start
sql connect
sql create dnode $hostname2
sql create dnode $hostname3
system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode3 -s start
print =============== step1
$x = 0
step1:
$x = $x + 1
sleep 1000
if $x == 10 then
return -1
endi
sql show dnodes
print dnode1 $data4_1
print dnode2 $data4_2
print dnode3 $data4_3
if $data4_1 != ready then
goto step1
endi
if $data4_2 != ready then
goto step1
endi
if $data4_3 != ready then
goto step1
endi
sql show mnodes
$mnode1Role = $data2_1
print mnode1Role $mnode1Role
$mnode2Role = $data2_2
print mnode2Role $mnode2Role
$mnode3Role = $data2_3
print mnode3Role $mnode3Role
if $mnode1Role != master then
goto step1
endi
if $mnode2Role != slave then
goto step1
endi
if $mnode3Role != slave then
goto step1
endi
$x = 1
show2:
print =============== step $x
sql show mnodes
print $data0_1 $data2_1
sql show dnodes
print dnode1 $data4_1
print dnode2 $data4_2
print dnode3 $data4_3
if $data4_1 != ready then
goto step1
endi
if $data4_2 != ready then
goto step1
endi
if $data4_3 != ready then
goto step1
endi
$x = $x + 1
sleep 3000
if $x == 100000 then
return -1
endi
goto show2
...@@ -9,41 +9,3 @@ system sh/cfg.sh -n dnode1 -c walLevel -v 2 ...@@ -9,41 +9,3 @@ system sh/cfg.sh -n dnode1 -c walLevel -v 2
system sh/cfg.sh -n dnode2 -c walLevel -v 2 system sh/cfg.sh -n dnode2 -c walLevel -v 2
system sh/cfg.sh -n dnode3 -c walLevel -v 2 system sh/cfg.sh -n dnode3 -c walLevel -v 2
system sh/cfg.sh -n dnode4 -c walLevel -v 2 system sh/cfg.sh -n dnode4 -c walLevel -v 2
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode1 -c activeCode -v eglxDLzRpslJWl7OxrPZ2K3sQ5631AP9SVpezsaz2dhJWl7OxrPZ2ElaXs7Gs9nYSVpezsaz2djGIj5StnQ3ZvLHcsE8cwcN
system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 100000
system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 100000
system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 100000
system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 100000
system sh/cfg.sh -n dnode1 -c http -v 1
system sh/cfg.sh -n dnode2 -c http -v 1
system sh/cfg.sh -n dnode3 -c http -v 1
system sh/cfg.sh -n dnode4 -c http -v 1
return
# for crash_gen
system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 10
system sh/cfg.sh -n dnode1 -c rpcMaxTime -v 101
system sh/cfg.sh -n dnode1 -c cache -v 2
system sh/cfg.sh -n dnode1 -c keep -v 36500
system sh/cfg.sh -n dnode1 -c walLevel -v 1
# for windows
system sh/cfg.sh -n dnode1 -c firstEp -v 152.136.17.116:6030
system sh/cfg.sh -n dnode1 -c secondEp -v 152.136.17.116:6030
system sh/cfg.sh -n dnode1 -c serverPort -v 6030
system sh/cfg.sh -n dnode1 -c fqdn -v 152.136.17.116
...@@ -33,7 +33,9 @@ if $data02 != master then ...@@ -33,7 +33,9 @@ if $data02 != master then
endi endi
print =============== create dnodes print =============== create dnodes
sql create dnode $hostname2 sql create dnode $hostname port 7200
sleep 2000
sql show dnodes; sql show dnodes;
if $rows != 2 then if $rows != 2 then
return -1 return -1
...@@ -47,6 +49,22 @@ if $data10 != 2 then ...@@ -47,6 +49,22 @@ if $data10 != 2 then
return -1 return -1
endi endi
if $data02 != 0 then
return -1
endi
if $data12 != 0 then
return -1
endi
if $data04 != ready then
return -1
endi
if $data14 != ready then
return -1
endi
sql show mnodes; sql show mnodes;
if $rows != 1 then if $rows != 1 then
return -1 return -1
...@@ -56,7 +74,7 @@ if $data00 != 1 then ...@@ -56,7 +74,7 @@ if $data00 != 1 then
return -1 return -1
endi endi
if $data01 != master then if $data02 != master then
return -1 return -1
endi endi
...@@ -76,5 +94,16 @@ if $rows != 2 then ...@@ -76,5 +94,16 @@ if $rows != 2 then
return -1 return -1
endi endi
print =============== drop dnode
sql drop dnode 2;
sql show dnodes;
if $rows != 1 then
return -1
endi
if $data00 != 1 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s stop -x SIGINT system sh/exec.sh -n dnode2 -s stop -x SIGINT
\ No newline at end of file
...@@ -42,41 +42,7 @@ char *simParseArbitratorName(char *varName) { ...@@ -42,41 +42,7 @@ char *simParseArbitratorName(char *varName) {
char *simParseHostName(char *varName) { char *simParseHostName(char *varName) {
static char hostName[140]; static char hostName[140];
sprintf(hostName, "%s", simHostName);
int32_t index = atoi(varName + 8);
int32_t port = 7100;
switch (index) {
case 1:
port = 7100;
break;
case 2:
port = 7200;
break;
case 3:
port = 7300;
break;
case 4:
port = 7400;
break;
case 5:
port = 7500;
break;
case 6:
port = 7600;
break;
case 7:
port = 7700;
break;
case 8:
port = 7800;
break;
case 9:
port = 7900;
break;
}
sprintf(hostName, "'%s:%d'", simHostName, port);
// simInfo("hostName:%s", hostName);
return hostName; return hostName;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册