提交 817c7d21 编写于 作者: L Liu Jicong

Merge branch '3.0' into feature/tq

...@@ -86,5 +86,6 @@ SpacesInSquareBrackets: false ...@@ -86,5 +86,6 @@ SpacesInSquareBrackets: false
Standard: Auto Standard: Auto
TabWidth: 8 TabWidth: 8
UseTab: Never UseTab: Never
AlignConsecutiveDeclarations: true
... ...
#!/bin/bash #!/bin/bash
rm -rf 127.0.0.1* rm -rf 127.0.0.1*
rm -rf ./data
#ifndef TDENGINE_COMMON_H
#define TDENGINE_COMMON_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#define MAX_PEERS 10
#define COMMAND_LEN 512
#define TOKEN_LEN 128
#define DIR_LEN 256
#define HOST_LEN 64
#define ADDRESS_LEN (HOST_LEN + 16)
typedef struct {
char host[HOST_LEN];
uint32_t port;
} Addr;
typedef struct {
Addr me;
Addr peers[MAX_PEERS];
int peersCount;
char dir[DIR_LEN];
char dataDir[DIR_LEN + HOST_LEN * 2];
} SRaftServerConfig;
#ifdef __cplusplus
}
#endif
#endif // TDENGINE_COMMON_H
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#include <string.h>
#include <assert.h>
#include <getopt.h>
#include <time.h>
#include <stdlib.h>
#include <getopt.h>
#include <raft.h>
#include <raft/uv.h>
#include "raftServer.h"
#include "common.h"
const char *exe_name;
void parseAddr(const char *addr, char *host, int len, uint32_t *port) {
char* tmp = (char*)malloc(strlen(addr) + 1);
strcpy(tmp, addr);
char* context;
char* separator = ":";
char* token = strtok_r(tmp, separator, &context);
if (token) {
snprintf(host, len, "%s", token);
}
token = strtok_r(NULL, separator, &context);
if (token) {
sscanf(token, "%u", port);
}
free(tmp);
}
// only parse 3 tokens
int parseCommand(const char* str, char* token1, char* token2, char* token3, int len)
{
char* tmp = (char*)malloc(strlen(str) + 1);
strcpy(tmp, str);
char* context;
char* separator = " ";
int n = 0;
char* token = strtok_r(tmp, separator, &context);
if (!token) {
goto ret;
}
if (strcmp(token, "") != 0) {
strncpy(token1, token, len);
n++;
}
token = strtok_r(NULL, separator, &context);
if (!token) {
goto ret;
}
if (strcmp(token, "") != 0) {
strncpy(token2, token, len);
n++;
}
token = strtok_r(NULL, separator, &context);
if (!token) {
goto ret;
}
if (strcmp(token, "") != 0) {
strncpy(token3, token, len);
n++;
}
ret:
return n;
free(tmp);
}
void *startServerFunc(void *param) {
SRaftServer *pServer = (SRaftServer*)param;
int32_t r = raftServerStart(pServer);
assert(r == 0);
return NULL;
}
// Console ---------------------------------
const char* state2String(unsigned short state) {
if (state == RAFT_UNAVAILABLE) {
return "RAFT_UNAVAILABLE";
} else if (state == RAFT_FOLLOWER) {
return "RAFT_FOLLOWER";
} else if (state == RAFT_CANDIDATE) {
return "RAFT_CANDIDATE";
} else if (state == RAFT_LEADER) {
return "RAFT_LEADER";
}
return "UNKNOWN_RAFT_STATE";
}
void printRaftConfiguration(struct raft_configuration *c) {
printf("configuration: \n");
for (int i = 0; i < c->n; ++i) {
printf("%llu -- %d -- %s\n", c->servers->id, c->servers->role, c->servers->address);
}
}
void printRaftState(struct raft *r) {
printf("----Raft State: -----------\n");
printf("my_id: %llu \n", r->id);
printf("address: %s \n", r->address);
printf("current_term: %llu \n", r->current_term);
printf("voted_for: %llu \n", r->voted_for);
printf("role: %s \n", state2String(r->state));
printf("commit_index: %llu \n", r->commit_index);
printf("last_applied: %llu \n", r->last_applied);
printf("last_stored: %llu \n", r->last_stored);
/*
printf("configuration_index: %llu \n", r->configuration_index);
printf("configuration_uncommitted_index: %llu \n", r->configuration_uncommitted_index);
printRaftConfiguration(&r->configuration);
*/
printf("----------------------------\n");
}
void putValueCb(struct raft_apply *req, int status, void *result) {
raft_free(req);
struct raft *r = req->data;
if (status != 0) {
printf("putValueCb: %s \n", raft_errmsg(r));
} else {
printf("putValueCb: %s \n", "ok");
}
}
void putValue(struct raft *r, const char *value) {
struct raft_buffer buf;
buf.len = TOKEN_LEN;;
buf.base = raft_malloc(buf.len);
snprintf(buf.base, buf.len, "%s", value);
struct raft_apply *req = raft_malloc(sizeof(struct raft_apply));
req->data = r;
int ret = raft_apply(r, req, &buf, 1, putValueCb);
if (ret == 0) {
printf("put %s \n", (char*)buf.base);
} else {
printf("put error: %s \n", raft_errmsg(r));
}
}
void getValue(const char *key) {
char *ptr = getKV(key);
if (ptr) {
printf("get value: [%s] \n", ptr);
} else {
printf("value not found for key: [%s] \n", key);
}
}
void console(SRaftServer *pRaftServer) {
while (1) {
char cmd_buf[COMMAND_LEN];
memset(cmd_buf, 0, sizeof(cmd_buf));
char *ret = fgets(cmd_buf, COMMAND_LEN, stdin);
if (!ret) {
exit(-1);
}
int pos = strlen(cmd_buf);
if(cmd_buf[pos - 1] == '\n') {
cmd_buf[pos - 1] = '\0';
}
if (strncmp(cmd_buf, "", COMMAND_LEN) == 0) {
continue;
}
char cmd[TOKEN_LEN];
memset(cmd, 0, sizeof(cmd));
char param1[TOKEN_LEN];
memset(param1, 0, sizeof(param1));
char param2[TOKEN_LEN];
memset(param2, 0, sizeof(param2));
parseCommand(cmd_buf, cmd, param1, param2, TOKEN_LEN);
if (strcmp(cmd, "addnode") == 0) {
printf("not support \n");
/*
char host[HOST_LEN];
uint32_t port;
parseAddr(param1, host, HOST_LEN, &port);
uint64_t rid = raftId(host, port);
struct raft_change *req = raft_malloc(sizeof(*req));
int r = raft_add(&pRaftServer->raft, req, rid, param1, NULL);
if (r != 0) {
printf("raft_add: %s \n", raft_errmsg(&pRaftServer->raft));
}
printf("add node: %lu %s \n", rid, param1);
struct raft_change *req2 = raft_malloc(sizeof(*req2));
r = raft_assign(&pRaftServer->raft, req2, rid, RAFT_VOTER, NULL);
if (r != 0) {
printf("raft_assign: %s \n", raft_errmsg(&pRaftServer->raft));
}
*/
} else if (strcmp(cmd, "dropnode") == 0) {
printf("not support \n");
} else if (strcmp(cmd, "put") == 0) {
char buf[256];
snprintf(buf, sizeof(buf), "%s--%s", param1, param2);
putValue(&pRaftServer->raft, buf);
} else if (strcmp(cmd, "get") == 0) {
getValue(param1);
} else if (strcmp(cmd, "state") == 0) {
printRaftState(&pRaftServer->raft);
} else if (strcmp(cmd, "snapshot") == 0) {
printf("not support \n");
} else if (strcmp(cmd, "help") == 0) {
printf("addnode \"127.0.0.1:8888\" \n");
printf("dropnode \"127.0.0.1:8888\" \n");
printf("put key value \n");
printf("get key \n");
printf("state \n");
} else {
printf("unknown command: [%s], type \"help\" to see help \n", cmd);
}
//printf("cmd_buf: [%s] \n", cmd_buf);
}
}
void *startConsoleFunc(void *param) {
SRaftServer *pServer = (SRaftServer*)param;
console(pServer);
return NULL;
}
// Config ---------------------------------
void usage() {
printf("\nusage: \n");
printf("%s --me=127.0.0.1:10000 --dir=./data \n", exe_name);
printf("\n");
printf("%s --me=127.0.0.1:10000 --peers=127.0.0.1:10001,127.0.0.1:10002 --dir=./data \n", exe_name);
printf("%s --me=127.0.0.1:10001 --peers=127.0.0.1:10000,127.0.0.1:10002 --dir=./data \n", exe_name);
printf("%s --me=127.0.0.1:10002 --peers=127.0.0.1:10000,127.0.0.1:10001 --dir=./data \n", exe_name);
printf("\n");
}
void parseConf(int argc, char **argv, SRaftServerConfig *pConf) {
memset(pConf, 0, sizeof(*pConf));
int option_index, option_value;
option_index = 0;
static struct option long_options[] = {
{"help", no_argument, NULL, 'h'},
{"peers", required_argument, NULL, 'p'},
{"me", required_argument, NULL, 'm'},
{"dir", required_argument, NULL, 'd'},
{NULL, 0, NULL, 0}
};
while ((option_value = getopt_long(argc, argv, "hp:m:d:", long_options, &option_index)) != -1) {
switch (option_value) {
case 'm': {
parseAddr(optarg, pConf->me.host, sizeof(pConf->me.host), &pConf->me.port);
break;
}
case 'p': {
char tokens[MAX_PEERS][MAX_TOKEN_LEN];
int peerCount = splitString(optarg, ",", tokens, MAX_PEERS);
pConf->peersCount = peerCount;
for (int i = 0; i < peerCount; ++i) {
Addr *pAddr = &pConf->peers[i];
parseAddr(tokens[i], pAddr->host, sizeof(pAddr->host), &pAddr->port);
}
break;
}
case 'd': {
snprintf(pConf->dir, sizeof(pConf->dir), "%s", optarg);
break;
}
case 'h': {
usage();
exit(-1);
}
default: {
usage();
exit(-1);
}
}
}
snprintf(pConf->dataDir, sizeof(pConf->dataDir), "%s/%s:%u", pConf->dir, pConf->me.host, pConf->me.port);
}
void printConf(SRaftServerConfig *pConf) {
printf("\nconf: \n");
printf("me: %s:%u \n", pConf->me.host, pConf->me.port);
printf("peersCount: %d \n", pConf->peersCount);
for (int i = 0; i < pConf->peersCount; ++i) {
Addr *pAddr = &pConf->peers[i];
printf("peer%d: %s:%u \n", i, pAddr->host, pAddr->port);
}
printf("dataDir: %s \n\n", pConf->dataDir);
}
int main(int argc, char **argv) {
srand(time(NULL));
int32_t ret;
exe_name = argv[0];
if (argc < 3) {
usage();
exit(-1);
}
SRaftServerConfig conf;
parseConf(argc, argv, &conf);
printConf(&conf);
char cmd_buf[COMMAND_LEN];
snprintf(cmd_buf, sizeof(cmd_buf), "mkdir -p %s", conf.dataDir);
system(cmd_buf);
struct raft_fsm fsm;
initFsm(&fsm);
SRaftServer raftServer;
ret = raftServerInit(&raftServer, &conf, &fsm);
assert(ret == 0);
pthread_t tidRaftServer;
pthread_create(&tidRaftServer, NULL, startServerFunc, &raftServer);
pthread_t tidConsole;
pthread_create(&tidConsole, NULL, startConsoleFunc, &raftServer);
while (1) {
sleep(10);
}
return 0;
}
#include <stdlib.h>
#include "common.h"
#include "raftServer.h"
char *keys;
char *values;
void initStore() {
keys = malloc(MAX_RECORD_COUNT * MAX_KV_LEN);
values = malloc(MAX_RECORD_COUNT * MAX_KV_LEN);
writeIndex = 0;
}
void destroyStore() {
free(keys);
free(values);
}
void putKV(const char *key, const char *value) {
if (writeIndex < MAX_RECORD_COUNT) {
strncpy(&keys[writeIndex], key, MAX_KV_LEN);
strncpy(&values[writeIndex], value, MAX_KV_LEN);
writeIndex++;
}
}
char *getKV(const char *key) {
for (int i = 0; i < MAX_RECORD_COUNT; ++i) {
if (strcmp(&keys[i], key) == 0) {
return &values[i];
}
}
return NULL;
}
int splitString(const char* str, char* separator, char (*arr)[MAX_TOKEN_LEN], int n_arr)
{
if (n_arr <= 0) {
return -1;
}
char* tmp = (char*)malloc(strlen(str) + 1);
strcpy(tmp, str);
char* context;
int n = 0;
char* token = strtok_r(tmp, separator, &context);
if (!token) {
goto ret;
}
strncpy(arr[n], token, MAX_TOKEN_LEN);
n++;
while (1) {
token = strtok_r(NULL, separator, &context);
if (!token || n >= n_arr) {
goto ret;
}
strncpy(arr[n], token, MAX_TOKEN_LEN);
n++;
}
ret:
free(tmp);
return n;
}
uint64_t raftId(const char *host, uint32_t port) {
uint32_t host_uint32 = (uint32_t)inet_addr(host);
assert(host_uint32 != (uint32_t)-1);
uint64_t code = ((uint64_t)host_uint32) << 32 | port;
return code;
}
int32_t raftServerInit(SRaftServer *pRaftServer, const SRaftServerConfig *pConf, struct raft_fsm *pFsm) {
int ret;
snprintf(pRaftServer->host, sizeof(pRaftServer->host), "%s", pConf->me.host);
pRaftServer->port = pConf->me.port;
snprintf(pRaftServer->address, sizeof(pRaftServer->address), "%s:%u", pRaftServer->host, pRaftServer->port);
strncpy(pRaftServer->dir, pConf->dataDir, sizeof(pRaftServer->dir));
pRaftServer->raftId = raftId(pRaftServer->host, pRaftServer->port);
pRaftServer->fsm = pFsm;
ret = uv_loop_init(&pRaftServer->loop);
if (!ret) {
fprintf(stderr, "%s \n", raft_errmsg(&pRaftServer->raft));
}
ret = raft_uv_tcp_init(&pRaftServer->transport, &pRaftServer->loop);
if (!ret) {
fprintf(stderr, "%s \n", raft_errmsg(&pRaftServer->raft));
}
ret = raft_uv_init(&pRaftServer->io, &pRaftServer->loop, pRaftServer->dir, &pRaftServer->transport);
if (!ret) {
fprintf(stderr, "%s \n", raft_errmsg(&pRaftServer->raft));
}
ret = raft_init(&pRaftServer->raft, &pRaftServer->io, pRaftServer->fsm, pRaftServer->raftId, pRaftServer->address);
if (!ret) {
fprintf(stderr, "%s \n", raft_errmsg(&pRaftServer->raft));
}
struct raft_configuration conf;
raft_configuration_init(&conf);
raft_configuration_add(&conf, pRaftServer->raftId, pRaftServer->address, RAFT_VOTER);
printf("add myself: %llu - %s \n", pRaftServer->raftId, pRaftServer->address);
for (int i = 0; i < pConf->peersCount; ++i) {
const Addr *pAddr = &pConf->peers[i];
raft_id rid = raftId(pAddr->host, pAddr->port);
char addrBuf[ADDRESS_LEN];
snprintf(addrBuf, sizeof(addrBuf), "%s:%u", pAddr->host, pAddr->port);
raft_configuration_add(&conf, rid, addrBuf, RAFT_VOTER);
printf("add peers: %llu - %s \n", rid, addrBuf);
}
raft_bootstrap(&pRaftServer->raft, &conf);
return 0;
}
int32_t raftServerStart(SRaftServer *pRaftServer) {
int ret;
ret = raft_start(&pRaftServer->raft);
if (!ret) {
fprintf(stderr, "%s \n", raft_errmsg(&pRaftServer->raft));
}
uv_run(&pRaftServer->loop, UV_RUN_DEFAULT);
}
void raftServerClose(SRaftServer *pRaftServer) {
}
int fsmApplyCb(struct raft_fsm *pFsm, const struct raft_buffer *buf, void **result) {
char *msg = (char*)buf->base;
printf("fsm apply: %s \n", msg);
char arr[2][MAX_TOKEN_LEN];
splitString(msg, "--", arr, 2);
putKV(arr[0], arr[1]);
return 0;
}
int32_t initFsm(struct raft_fsm *fsm) {
initStore();
fsm->apply = fsmApplyCb;
return 0;
}
#ifndef TDENGINE_RAFT_SERVER_H
#define TDENGINE_RAFT_SERVER_H
#ifdef __cplusplus
extern "C" {
#endif
#include <netinet/in.h>
#include <arpa/inet.h>
#include <assert.h>
#include <string.h>
#include "raft.h"
#include "raft/uv.h"
#include "common.h"
// simulate a db store, just for test
#define MAX_KV_LEN 100
#define MAX_RECORD_COUNT 500
char *keys;
char *values;
int writeIndex;
void initStore();
void destroyStore();
void putKV(const char *key, const char *value);
char *getKV(const char *key);
typedef struct {
char dir[DIR_LEN + HOST_LEN * 2]; /* Data dir of UV I/O backend */
char host[HOST_LEN];
uint32_t port;
char address[ADDRESS_LEN]; /* Raft instance address */
raft_id raftId; /* For vote */
struct raft_fsm *fsm; /* Sample application FSM */
struct raft raft; /* Raft instance */
struct raft_io io; /* UV I/O backend */
struct uv_loop_s loop; /* UV loop */
struct raft_uv_transport transport; /* UV I/O backend transport */
} SRaftServer;
#define MAX_TOKEN_LEN 32
int splitString(const char* str, char* separator, char (*arr)[MAX_TOKEN_LEN], int n_arr);
uint64_t raftId(const char *host, uint32_t port);
int32_t raftServerInit(SRaftServer *pRaftServer, const SRaftServerConfig *pConf, struct raft_fsm *pFsm);
int32_t raftServerStart(SRaftServer *pRaftServer);
void raftServerClose(SRaftServer *pRaftServer);
int initFsm(struct raft_fsm *fsm);
#ifdef __cplusplus
}
#endif
#endif // TDENGINE_RAFT_SERVER_H
...@@ -52,6 +52,10 @@ TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MQ_CONNECT, "mq-connect" ) ...@@ -52,6 +52,10 @@ TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MQ_CONNECT, "mq-connect" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MQ_DISCONNECT, "mq-disconnect" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MQ_DISCONNECT, "mq-disconnect" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MQ_SET_CUR, "mq-set-cur" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MQ_SET_CUR, "mq-set-cur" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_RES_READY, "res-ready" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_RES_READY, "res-ready" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_TASKS_STATUS, "tasks-status" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CANCEL_TASK, "cancel-task" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DROP_TASK, "drop-task" )
// message from client to mnode // message from client to mnode
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CONNECT, "connect" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CONNECT, "connect" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CREATE_ACCT, "create-acct" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CREATE_ACCT, "create-acct" )
...@@ -317,17 +321,25 @@ typedef struct { ...@@ -317,17 +321,25 @@ 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 { typedef struct {
int32_t len; // one create table message
char tableName[TSDB_TABLE_FNAME_LEN]; char tableName[TSDB_TABLE_FNAME_LEN];
int16_t numOfTags;
int16_t numOfColumns; int16_t numOfColumns;
int16_t sqlLen; // the length of SQL, it starts after schema , sql is a null-terminated string int16_t numOfTags;
int8_t igExists; int8_t igExists;
int8_t rspMeta; int8_t rspMeta;
int8_t reserved[16];
char schema[]; char schema[];
} SCreateTableMsg; } SCreateCTableMsg;
typedef struct { typedef struct {
char name[TSDB_TABLE_FNAME_LEN]; char name[TSDB_TABLE_FNAME_LEN];
...@@ -335,7 +347,7 @@ typedef struct { ...@@ -335,7 +347,7 @@ typedef struct {
int32_t numOfTags; int32_t numOfTags;
int32_t numOfColumns; int32_t numOfColumns;
SSchema pSchema[]; SSchema pSchema[];
} SCreateStbMsg; } SCreateStbMsg, SCreateTableMsg;
typedef struct { typedef struct {
char name[TSDB_TABLE_FNAME_LEN]; char name[TSDB_TABLE_FNAME_LEN];
...@@ -378,6 +390,7 @@ typedef struct { ...@@ -378,6 +390,7 @@ typedef struct {
typedef struct { typedef struct {
SMsgHead head; SMsgHead head;
char name[TSDB_TABLE_FNAME_LEN]; char name[TSDB_TABLE_FNAME_LEN];
int8_t ignoreNotExists;
} SDropTableMsg; } SDropTableMsg;
typedef struct { typedef struct {
...@@ -583,10 +596,6 @@ typedef struct { ...@@ -583,10 +596,6 @@ typedef struct {
typedef struct { typedef struct {
int32_t code; int32_t code;
union {
uint64_t qhandle;
uint64_t qId;
}; // query handle
} SQueryTableRsp; } SQueryTableRsp;
// todo: the show handle should be replaced with id // todo: the show handle should be replaced with id
...@@ -918,18 +927,15 @@ typedef struct SShowRsp { ...@@ -918,18 +927,15 @@ typedef struct SShowRsp {
typedef struct { typedef struct {
char ep[TSDB_EP_LEN]; // end point, hostname:port char ep[TSDB_EP_LEN]; // end point, hostname:port
int32_t reserve[8];
} SCreateDnodeMsg; } SCreateDnodeMsg;
typedef struct { typedef struct {
int32_t dnodeId; int32_t dnodeId;
int32_t reserve[8];
} SDropDnodeMsg; } SDropDnodeMsg;
typedef struct { typedef struct {
int32_t dnodeId; int32_t dnodeId;
char config[TSDB_DNODE_CONFIG_LEN]; char config[TSDB_DNODE_CONFIG_LEN];
int32_t reserve[8];
} SCfgDnodeMsg; } SCfgDnodeMsg;
typedef struct { typedef struct {
...@@ -938,7 +944,6 @@ typedef struct { ...@@ -938,7 +944,6 @@ typedef struct {
typedef struct { typedef struct {
int32_t dnodeId; int32_t dnodeId;
int8_t align[3];
int8_t replica; int8_t replica;
SReplica replicas[TSDB_MAX_REPLICA]; SReplica replicas[TSDB_MAX_REPLICA];
} SCreateMnodeInMsg, SAlterMnodeInMsg; } SCreateMnodeInMsg, SAlterMnodeInMsg;
...@@ -1107,29 +1112,33 @@ typedef struct { ...@@ -1107,29 +1112,33 @@ typedef struct {
/* data */ /* data */
} SUpdateTagValRsp; } SUpdateTagValRsp;
typedef struct SSchedulerQueryMsg { typedef struct SSubQueryMsg {
uint64_t schedulerId; uint64_t schedulerId;
uint64_t queryId; uint64_t queryId;
uint64_t taskId; uint64_t taskId;
uint32_t contentLen; uint32_t contentLen;
char msg[]; char msg[];
} SSchedulerQueryMsg; } SSubQueryMsg;
typedef struct SSchedulerReadyMsg { typedef struct SResReadyMsg {
uint64_t schedulerId; uint64_t schedulerId;
uint64_t queryId; uint64_t queryId;
uint64_t taskId; uint64_t taskId;
} SSchedulerReadyMsg; } SResReadyMsg;
typedef struct SResReadyRsp {
int32_t code;
} SResReadyRsp;
typedef struct SSchedulerFetchMsg { typedef struct SResFetchMsg {
uint64_t schedulerId; uint64_t schedulerId;
uint64_t queryId; uint64_t queryId;
uint64_t taskId; uint64_t taskId;
} SSchedulerFetchMsg; } SResFetchMsg;
typedef struct SSchedulerStatusMsg { typedef struct SSchTasksStatusMsg {
uint64_t schedulerId; uint64_t schedulerId;
} SSchedulerStatusMsg; } SSchTasksStatusMsg;
typedef struct STaskStatus { typedef struct STaskStatus {
uint64_t queryId; uint64_t queryId;
...@@ -1143,16 +1152,32 @@ typedef struct SSchedulerStatusRsp { ...@@ -1143,16 +1152,32 @@ typedef struct SSchedulerStatusRsp {
} SSchedulerStatusRsp; } SSchedulerStatusRsp;
typedef struct SSchedulerCancelMsg { typedef struct STaskCancelMsg {
uint64_t schedulerId; uint64_t schedulerId;
uint64_t queryId; uint64_t queryId;
uint64_t taskId; uint64_t taskId;
} SSchedulerCancelMsg; } STaskCancelMsg;
typedef struct STaskCancelRsp {
int32_t code;
} STaskCancelRsp;
typedef struct STaskDropMsg {
uint64_t schedulerId;
uint64_t queryId;
uint64_t taskId;
} STaskDropMsg;
typedef struct STaskDropRsp {
int32_t code;
} STaskDropRsp;
typedef struct { typedef struct {
char name[TSDB_TOPIC_FNAME_LEN]; char name[TSDB_TOPIC_FNAME_LEN];
int8_t igExists; int8_t igExists;
int32_t execLen;
void* executor; void* executor;
int32_t sqlLen;
char* sql; char* sql;
} SCreateTopicMsg; } SCreateTopicMsg;
......
...@@ -115,14 +115,14 @@ int32_t catalogGetTableDistVgroup(struct SCatalog* pCatalog, void *pRpc, const S ...@@ -115,14 +115,14 @@ int32_t catalogGetTableDistVgroup(struct SCatalog* pCatalog, void *pRpc, const S
/** /**
* Get a table's vgroup from its name's hash value. * Get a table's vgroup from its name's hash value.
* @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 vgInfo (output, vgroup info) * @param vgInfo (output, vgroup info)
* @return error code * @return error code
*/ */
int32_t catalogGetTableHashVgroup(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const char* pDBName, const char* pTableName, SVgroupInfo* vgInfo); int32_t catalogGetTableHashVgroup(struct SCatalog* pCatalog, void * pTransporter, const SEpSet* pMgmtEps, const char* pDBName, const char* pTableName, SVgroupInfo* vgInfo);
/** /**
......
...@@ -40,7 +40,7 @@ typedef struct SQueryNode { ...@@ -40,7 +40,7 @@ typedef struct SQueryNode {
typedef struct SField { typedef struct SField {
char name[TSDB_COL_NAME_LEN]; char name[TSDB_COL_NAME_LEN];
uint8_t type; uint8_t type;
int16_t bytes; int32_t bytes;
} SField; } SField;
typedef struct SParseBasicCtx { typedef struct SParseBasicCtx {
...@@ -160,6 +160,13 @@ typedef struct SInsertStmtInfo { ...@@ -160,6 +160,13 @@ typedef struct SInsertStmtInfo {
const char* sql; // current sql statement position const char* sql; // current sql statement position
} SInsertStmtInfo; } SInsertStmtInfo;
typedef struct SDclStmtInfo {
int16_t nodeType;
int16_t msgType;
char* pMsg;
int32_t msgLen;
} SDclStmtInfo;
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -22,20 +22,11 @@ extern "C" { ...@@ -22,20 +22,11 @@ extern "C" {
#include "parsenodes.h" #include "parsenodes.h"
/**
* True will be returned if the input sql string is insert, false otherwise.
* @param pStr sql string
* @param length length of the sql string
* @return
*/
bool qIsInsertSql(const char* pStr, size_t length);
typedef struct SParseContext { typedef struct SParseContext {
SParseBasicCtx ctx; SParseBasicCtx ctx;
void *pRpc; void *pRpc;
struct SCatalog *pCatalog; struct SCatalog *pCatalog;
const SEpSet *pEpSet; const SEpSet *pEpSet;
int64_t id; // query id, generated by uuid generator
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
...@@ -51,17 +42,9 @@ typedef struct SParseContext { ...@@ -51,17 +42,9 @@ typedef struct SParseContext {
* @param msg extended error message if exists. * @param msg extended error message if exists.
* @return error code * @return error code
*/ */
int32_t qParseQuerySql(const char* pStr, size_t length, SParseBasicCtx* pParseCtx, int32_t* type, void** pOutput, int32_t* outputLen, char* msg, int32_t msgLen); int32_t qParseQuerySql(SParseContext* pContext, SQueryNode** pQuery);
/** bool qIsDclQuery(const SQueryNode* pQuery);
* Parse the insert sql statement.
* @param pStr sql string
* @param length length of the sql string
* @param id operator id, generated by uuid generator.
* @param msg extended error message if exists to help avoid the problem in sql statement.
* @return data in binary format to submit to vnode directly.
*/
int32_t qParseInsertSql(SParseContext* pContext, struct SInsertStmtInfo** pInfo);
/** /**
* 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
......
...@@ -119,9 +119,9 @@ typedef struct SSubplanId { ...@@ -119,9 +119,9 @@ typedef struct SSubplanId {
typedef struct SSubplan { typedef struct SSubplan {
SSubplanId id; // unique id of the subplan SSubplanId id; // unique id of the subplan
int32_t type; // QUERY_TYPE_MERGE|QUERY_TYPE_PARTIAL|QUERY_TYPE_SCAN int32_t type; // QUERY_TYPE_MERGE|QUERY_TYPE_PARTIAL|QUERY_TYPE_SCAN|QUERY_TYPE_MODIFY
int32_t level; // the execution level of current subplan, starting from 0. int32_t level; // the execution level of current subplan, starting from 0.
SEpSet execEpSet; // for the scan sub plan, the optional execution node SEpSet execEpSet; // for the scan/modify subplan, the optional execution node
SArray *pChildern; // the datasource subplan,from which to fetch the result SArray *pChildern; // the datasource subplan,from which to fetch the result
SArray *pParents; // the data destination subplan, get data from current subplan SArray *pParents; // the data destination subplan, get data from current subplan
SPhyNode *pNode; // physical plan of current subplan SPhyNode *pNode; // physical plan of current subplan
...@@ -152,7 +152,7 @@ int32_t qExplainQuery(const struct SQueryNode* pQueryInfo, struct SEpSet* pQnode ...@@ -152,7 +152,7 @@ int32_t qExplainQuery(const struct SQueryNode* pQueryInfo, struct SEpSet* pQnode
/** /**
* Convert to subplan to string for the scheduler to send to the executor * Convert to subplan to string for the scheduler to send to the executor
*/ */
int32_t qSubPlanToString(const SSubplan* subplan, char** str); int32_t qSubPlanToString(const SSubplan* subplan, char** str, int32_t* len);
int32_t qStringToSubplan(const char* str, SSubplan** subplan); int32_t qStringToSubplan(const char* str, SSubplan** subplan);
......
...@@ -25,12 +25,15 @@ extern "C" { ...@@ -25,12 +25,15 @@ extern "C" {
#include "tlog.h" #include "tlog.h"
enum { enum {
JOB_TASK_STATUS_NULL = 0,
JOB_TASK_STATUS_NOT_START = 1, JOB_TASK_STATUS_NOT_START = 1,
JOB_TASK_STATUS_EXECUTING, JOB_TASK_STATUS_EXECUTING,
JOB_TASK_STATUS_PARTIAL_SUCCEED,
JOB_TASK_STATUS_SUCCEED, JOB_TASK_STATUS_SUCCEED,
JOB_TASK_STATUS_FAILED, JOB_TASK_STATUS_FAILED,
JOB_TASK_STATUS_CANCELLING, JOB_TASK_STATUS_CANCELLING,
JOB_TASK_STATUS_CANCELLED JOB_TASK_STATUS_CANCELLED,
JOB_TASK_STATUS_DROPPING,
}; };
typedef struct STableComInfo { typedef struct STableComInfo {
...@@ -107,7 +110,7 @@ int32_t cleanupTaskQueue(); ...@@ -107,7 +110,7 @@ int32_t cleanupTaskQueue();
int32_t taosAsyncExec(__async_exec_fn_t execFn, void* execParam, int32_t* code); int32_t taosAsyncExec(__async_exec_fn_t execFn, void* execParam, int32_t* code);
SSchema* tGetTbnameColumnSchema(); SSchema* tGetTbnameColumnSchema();
void msgInit(); void initQueryModuleMsgHandle();
extern int32_t (*queryBuildMsg[TSDB_MSG_TYPE_MAX])(void* input, char **msg, int32_t msgSize, int32_t *msgLen); extern int32_t (*queryBuildMsg[TSDB_MSG_TYPE_MAX])(void* input, char **msg, int32_t msgSize, int32_t *msgLen);
extern int32_t (*queryProcessMsgRsp[TSDB_MSG_TYPE_MAX])(void* output, char *msg, int32_t msgSize); extern int32_t (*queryProcessMsgRsp[TSDB_MSG_TYPE_MAX])(void* output, char *msg, int32_t msgSize);
......
...@@ -42,15 +42,17 @@ typedef struct { ...@@ -42,15 +42,17 @@ typedef struct {
int32_t qWorkerInit(SQWorkerCfg *cfg, void **qWorkerMgmt); int32_t qWorkerInit(SQWorkerCfg *cfg, void **qWorkerMgmt);
int32_t qWorkerProcessQueryMsg(void *qWorkerMgmt, SSchedulerQueryMsg *msg, SRpcMsg *rsp); int32_t qWorkerProcessQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg);
int32_t qWorkerProcessReadyMsg(void *qWorkerMgmt, SSchedulerReadyMsg *msg, SRpcMsg *rsp); int32_t qWorkerProcessReadyMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg);
int32_t qWorkerProcessStatusMsg(void *qWorkerMgmt, SSchedulerStatusMsg *msg, SRpcMsg *rsp); int32_t qWorkerProcessStatusMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg);
int32_t qWorkerProcessFetchMsg(void *qWorkerMgmt, SSchedulerFetchMsg *msg, SRpcMsg *rsp); int32_t qWorkerProcessFetchMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg);
int32_t qWorkerProcessCancelMsg(void *qWorkerMgmt, SSchedulerCancelMsg *msg, SRpcMsg *rsp); int32_t qWorkerProcessCancelMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg);
int32_t qWorkerProcessDropMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg);
void qWorkerDestroy(void **qWorkerMgmt); void qWorkerDestroy(void **qWorkerMgmt);
......
...@@ -324,6 +324,11 @@ int32_t* taosGetErrno(); ...@@ -324,6 +324,11 @@ int32_t* taosGetErrno();
#define TSDB_CODE_QRY_INVALID_TIME_CONDITION TAOS_DEF_ERROR_CODE(0, 0x070D) //"invalid time condition") #define TSDB_CODE_QRY_INVALID_TIME_CONDITION TAOS_DEF_ERROR_CODE(0, 0x070D) //"invalid time condition")
#define TSDB_CODE_QRY_SYS_ERROR TAOS_DEF_ERROR_CODE(0, 0x070E) //"System error") #define TSDB_CODE_QRY_SYS_ERROR TAOS_DEF_ERROR_CODE(0, 0x070E) //"System error")
#define TSDB_CODE_QRY_INVALID_INPUT TAOS_DEF_ERROR_CODE(0, 0x070F) //"invalid input") #define TSDB_CODE_QRY_INVALID_INPUT TAOS_DEF_ERROR_CODE(0, 0x070F) //"invalid input")
#define TSDB_CODE_QRY_SCH_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0710) //"Scheduler not exist")
#define TSDB_CODE_QRY_TASK_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0711) //"Task not exist")
#define TSDB_CODE_QRY_TASK_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0712) //"Task already exist")
#define TSDB_CODE_QRY_RES_CACHE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0713) //"Task result cache not exist")
#define TSDB_CODE_QRY_TASK_CANCELLED TAOS_DEF_ERROR_CODE(0, 0x0714) //"Task cancelled")
// grant // grant
......
...@@ -33,6 +33,8 @@ typedef void (*_hash_free_fn_t)(void *); ...@@ -33,6 +33,8 @@ typedef void (*_hash_free_fn_t)(void *);
#define HASH_INDEX(v, c) ((v) & ((c)-1)) #define HASH_INDEX(v, c) ((v) & ((c)-1))
#define HASH_NODE_EXIST(code) (code == -2)
/** /**
* murmur hash algorithm * murmur hash algorithm
* @key usually string * @key usually string
......
...@@ -137,15 +137,14 @@ typedef struct SRequestMsgBody { ...@@ -137,15 +137,14 @@ typedef struct SRequestMsgBody {
extern SAppInfo appInfo; extern SAppInfo appInfo;
extern int32_t tscReqRef; extern int32_t tscReqRef;
extern void *tscQhandle;
extern int32_t tscConnRef; extern int32_t tscConnRef;
extern int (*buildRequestMsgFp[TSDB_SQL_MAX])(SRequestObj *pRequest, SRequestMsgBody *pMsgBody); SRequestMsgBody buildRequestMsgImpl(SRequestObj *pRequest);
extern int (*handleRequestRspFp[TSDB_SQL_MAX])(SRequestObj *pRequest, const char* pMsg, int32_t msgLen); extern int (*handleRequestRspFp[TSDB_MSG_TYPE_MAX])(SRequestObj *pRequest, const char* pMsg, int32_t msgLen);
int taos_init(); int taos_init();
void* createTscObj(const char* user, const char* auth, const char *ip, uint32_t port, SAppInstInfo* pAppInfo); void* createTscObj(const char* user, const char* auth, const char *db, SAppInstInfo* pAppInfo);
void destroyTscObj(void*pObj); void destroyTscObj(void*pObj);
void *createRequest(STscObj* pObj, __taos_async_fn_t fp, void* param, int32_t type); void *createRequest(STscObj* pObj, __taos_async_fn_t fp, void* param, int32_t type);
......
...@@ -13,11 +13,12 @@ ...@@ -13,11 +13,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "os.h" #include <catalog.h>
#include "taosmsg.h"
#include "query.h"
#include "clientInt.h" #include "clientInt.h"
#include "clientLog.h" #include "clientLog.h"
#include "os.h"
#include "query.h"
#include "taosmsg.h"
#include "tcache.h" #include "tcache.h"
#include "tconfig.h" #include "tconfig.h"
#include "tglobal.h" #include "tglobal.h"
...@@ -129,7 +130,7 @@ void destroyTscObj(void *pObj) { ...@@ -129,7 +130,7 @@ void destroyTscObj(void *pObj) {
tfree(pTscObj); tfree(pTscObj);
} }
void* createTscObj(const char* user, const char* auth, const char *ip, uint32_t port, SAppInstInfo* pAppInfo) { void* createTscObj(const char* user, const char* auth, const char *db, SAppInstInfo* pAppInfo) {
STscObj *pObj = (STscObj *)calloc(1, sizeof(STscObj)); STscObj *pObj = (STscObj *)calloc(1, sizeof(STscObj));
if (NULL == pObj) { if (NULL == pObj) {
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
...@@ -144,6 +145,10 @@ void* createTscObj(const char* user, const char* auth, const char *ip, uint32_t ...@@ -144,6 +145,10 @@ void* createTscObj(const char* user, const char* auth, const char *ip, uint32_t
tstrncpy(pObj->user, user, sizeof(pObj->user)); tstrncpy(pObj->user, user, sizeof(pObj->user));
memcpy(pObj->pass, auth, TSDB_PASSWORD_LEN); memcpy(pObj->pass, auth, TSDB_PASSWORD_LEN);
if (db != NULL) {
tstrncpy(pObj->db, db, tListLen(pObj->db));
}
pthread_mutex_init(&pObj->mutex, NULL); pthread_mutex_init(&pObj->mutex, NULL);
pObj->id = taosAddRef(tscConnRef, pObj); pObj->id = taosAddRef(tscConnRef, pObj);
...@@ -220,9 +225,13 @@ void taos_init_imp(void) { ...@@ -220,9 +225,13 @@ void taos_init_imp(void) {
taosInitNotes(); taosInitNotes();
initMsgHandleFp(); initMsgHandleFp();
initQueryModuleMsgHandle();
rpcInit(); rpcInit();
SCatalogCfg cfg = {.enableVgroupCache = true, .maxDBCacheNum = 100, .maxTblCacheNum = 100};
catalogInit(&cfg);
tscDebug("starting to initialize TAOS driver, local ep: %s", tsLocalEp); tscDebug("starting to initialize TAOS driver, local ep: %s", tsLocalEp);
taosSetCoreDump(true); taosSetCoreDump(true);
......
...@@ -113,6 +113,13 @@ TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass, ...@@ -113,6 +113,13 @@ TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass,
return taosConnectImpl(ip, user, &secretEncrypt[0], db, port, NULL, NULL, *pInst); return taosConnectImpl(ip, user, &secretEncrypt[0], db, port, NULL, NULL, *pInst);
} }
static bool supportedQueryType(int32_t type) {
return (type == TSDB_MSG_TYPE_CREATE_USER || type == TSDB_MSG_TYPE_SHOW || type == TSDB_MSG_TYPE_DROP_USER ||
type == TSDB_MSG_TYPE_DROP_ACCT || type == TSDB_MSG_TYPE_CREATE_DB || type == TSDB_MSG_TYPE_CREATE_ACCT ||
type == TSDB_MSG_TYPE_CREATE_TABLE || type == TSDB_MSG_TYPE_CREATE_STB || type == TSDB_MSG_TYPE_USE_DB ||
type == TSDB_MSG_TYPE_DROP_DB || type == TSDB_MSG_TYPE_DROP_STB);
}
TAOS_RES *taos_query_l(TAOS *taos, const char *sql, int sqlLen) { TAOS_RES *taos_query_l(TAOS *taos, const char *sql, int sqlLen) {
STscObj *pTscObj = (STscObj *)taos; STscObj *pTscObj = (STscObj *)taos;
if (sqlLen > (size_t) tsMaxSQLStringLen) { if (sqlLen > (size_t) tsMaxSQLStringLen) {
...@@ -144,37 +151,67 @@ TAOS_RES *taos_query_l(TAOS *taos, const char *sql, int sqlLen) { ...@@ -144,37 +151,67 @@ TAOS_RES *taos_query_l(TAOS *taos, const char *sql, int sqlLen) {
tscDebugL("0x%"PRIx64" SQL: %s", pRequest->requestId, pRequest->sqlstr); tscDebugL("0x%"PRIx64" SQL: %s", pRequest->requestId, pRequest->sqlstr);
int32_t code = 0; SParseContext cxt = {
if (qIsInsertSql(pRequest->sqlstr, sqlLen)) { .ctx = {.requestId = pRequest->requestId, .acctId = pTscObj->acctId, .db = getConnectionDB(pTscObj)},
// todo add .pSql = pRequest->sqlstr,
} else { .sqlLen = sqlLen,
int32_t type = 0; .pMsg = pRequest->msgBuf,
void* output = NULL; .msgLen = ERROR_MSG_BUF_DEFAULT_SIZE
int32_t outputLen = 0; };
SParseBasicCtx c = {.requestId = pRequest->requestId, .acctId = pTscObj->acctId, .db = getConnectionDB(pTscObj)};
code = qParseQuerySql(pRequest->sqlstr, sqlLen, &c, &type, &output, &outputLen, pRequest->msgBuf, ERROR_MSG_BUF_DEFAULT_SIZE);
if (type == TSDB_SQL_CREATE_USER || type == TSDB_SQL_SHOW || type == TSDB_SQL_DROP_USER ||
type == TSDB_SQL_DROP_ACCT || type == TSDB_SQL_CREATE_DB || type == TSDB_SQL_CREATE_ACCT ||
type == TSDB_SQL_CREATE_TABLE || type == TSDB_SQL_USE_DB) {
pRequest->type = type;
pRequest->body.requestMsg = (SReqMsgInfo){.pMsg = output, .len = outputLen};
SRequestMsgBody body = {0}; SQueryNode* pQuery = NULL;
buildRequestMsgFp[type](pRequest, &body); int32_t code = qParseQuerySql(&cxt, &pQuery);
if (qIsDclQuery(pQuery)) {
SDclStmtInfo* pDcl = (SDclStmtInfo*) pQuery;
pRequest->type = pDcl->msgType;
pRequest->body.requestMsg = (SReqMsgInfo){.pMsg = pDcl->pMsg, .len = pDcl->msgLen};
SRequestMsgBody body = buildRequestMsgImpl(pRequest);
SEpSet* pEpSet = &pTscObj->pAppInfo->mgmtEp.epSet;
if (pDcl->msgType == TSDB_MSG_TYPE_CREATE_TABLE) {
struct SCatalog* pCatalog = NULL;
char buf[12] = {0};
sprintf(buf, "%d", pTscObj->pAppInfo->clusterId);
code = catalogGetHandle(buf, &pCatalog);
if (code != 0) {
pRequest->code = code;
return pRequest;
}
SCreateTableMsg* pMsg = body.msgInfo.pMsg;
SName t = {0};
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};
tNameGetFullDbName(&t, db);
SVgroupInfo info = {0};
catalogGetTableHashVgroup(pCatalog, pTscObj->pTransporter, pEpSet, db, tNameGetTableName(&t), &info);
int64_t transporterId = 0; int64_t transporterId = 0;
sendMsgToServer(pTscObj->pTransporter, &pTscObj->pAppInfo->mgmtEp.epSet, &body, &transporterId); 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]));
}
tsem_wait(&pRequest->body.rspSem); sendMsgToServer(pTscObj->pTransporter, &ep, &body, &transporterId);
destroyRequestMsgBody(&body);
} else { } else {
assert(0); int64_t transporterId = 0;
sendMsgToServer(pTscObj->pTransporter, pEpSet, &body, &transporterId);
} }
tfree(c.db); tsem_wait(&pRequest->body.rspSem);
destroyRequestMsgBody(&body);
} }
tfree(cxt.ctx.db);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
pRequest->code = code; pRequest->code = code;
return pRequest; return pRequest;
...@@ -186,7 +223,7 @@ TAOS_RES *taos_query_l(TAOS *taos, const char *sql, int sqlLen) { ...@@ -186,7 +223,7 @@ TAOS_RES *taos_query_l(TAOS *taos, const char *sql, int sqlLen) {
int initEpSetFromCfg(const char *firstEp, const char *secondEp, SCorEpSet *pEpSet) { int initEpSetFromCfg(const char *firstEp, const char *secondEp, SCorEpSet *pEpSet) {
pEpSet->version = 0; pEpSet->version = 0;
// init mgmt ip set // init mnode ip set
SEpSet *mgmtEpSet = &(pEpSet->epSet); SEpSet *mgmtEpSet = &(pEpSet->epSet);
mgmtEpSet->numOfEps = 0; mgmtEpSet->numOfEps = 0;
mgmtEpSet->inUse = 0; mgmtEpSet->inUse = 0;
...@@ -220,13 +257,13 @@ int initEpSetFromCfg(const char *firstEp, const char *secondEp, SCorEpSet *pEpSe ...@@ -220,13 +257,13 @@ int initEpSetFromCfg(const char *firstEp, const char *secondEp, SCorEpSet *pEpSe
} }
STscObj* taosConnectImpl(const char *ip, const char *user, const char *auth, const char *db, uint16_t port, __taos_async_fn_t fp, void *param, SAppInstInfo* pAppInfo) { STscObj* taosConnectImpl(const char *ip, const char *user, const char *auth, const char *db, uint16_t port, __taos_async_fn_t fp, void *param, SAppInstInfo* pAppInfo) {
STscObj *pTscObj = createTscObj(user, auth, ip, port, pAppInfo); STscObj *pTscObj = createTscObj(user, auth, db, pAppInfo);
if (NULL == pTscObj) { if (NULL == pTscObj) {
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
return pTscObj; return pTscObj;
} }
SRequestObj *pRequest = createRequest(pTscObj, fp, param, TSDB_SQL_CONNECT); SRequestObj *pRequest = createRequest(pTscObj, fp, param, TSDB_MSG_TYPE_CONNECT);
if (pRequest == NULL) { if (pRequest == NULL) {
destroyTscObj(pTscObj); destroyTscObj(pTscObj);
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
...@@ -268,16 +305,11 @@ static int32_t buildConnectMsg(SRequestObj *pRequest, SRequestMsgBody* pMsgBody) ...@@ -268,16 +305,11 @@ static int32_t buildConnectMsg(SRequestObj *pRequest, SRequestMsgBody* pMsgBody)
return -1; return -1;
} }
// TODO refactor full_name
char *db; // ugly code to move the space
STscObj *pObj = pRequest->pTscObj; STscObj *pObj = pRequest->pTscObj;
pthread_mutex_lock(&pObj->mutex);
db = strstr(pObj->db, TS_PATH_DELIMITER);
db = (db == NULL) ? pObj->db : db + 1; char* db = getConnectionDB(pObj);
tstrncpy(pConnect->db, db, sizeof(pConnect->db)); tstrncpy(pConnect->db, db, sizeof(pConnect->db));
pthread_mutex_unlock(&pObj->mutex); tfree(db);
pConnect->pid = htonl(appInfo.pid); pConnect->pid = htonl(appInfo.pid);
pConnect->startTime = htobe64(appInfo.startTime); pConnect->startTime = htobe64(appInfo.startTime);
...@@ -395,10 +427,9 @@ void* doFetchRow(SRequestObj* pRequest) { ...@@ -395,10 +427,9 @@ void* doFetchRow(SRequestObj* pRequest) {
SReqResultInfo* pResultInfo = &pRequest->body.resInfo; SReqResultInfo* pResultInfo = &pRequest->body.resInfo;
if (pResultInfo->pData == NULL || pResultInfo->current >= pResultInfo->numOfRows) { if (pResultInfo->pData == NULL || pResultInfo->current >= pResultInfo->numOfRows) {
pRequest->type = TSDB_SQL_RETRIEVE_MNODE; pRequest->type = TSDB_MSG_TYPE_SHOW_RETRIEVE;
SRequestMsgBody body = {0}; SRequestMsgBody body = buildRequestMsgImpl(pRequest);
buildRequestMsgFp[pRequest->type](pRequest, &body);
int64_t transporterId = 0; int64_t transporterId = 0;
STscObj* pTscObj = pRequest->pTscObj; STscObj* pTscObj = pRequest->pTscObj;
......
...@@ -21,8 +21,7 @@ ...@@ -21,8 +21,7 @@
#include "tmsgtype.h" #include "tmsgtype.h"
#include "trpc.h" #include "trpc.h"
int (*buildRequestMsgFp[TSDB_SQL_MAX])(SRequestObj *pRequest, SRequestMsgBody *pMsgBody) = {0}; int (*handleRequestRspFp[TSDB_MSG_TYPE_MAX])(SRequestObj *pRequest, const char* pMsg, int32_t msgLen);
int (*handleRequestRspFp[TSDB_SQL_MAX])(SRequestObj *pRequest, const char* pMsg, int32_t msgLen);
int32_t buildConnectMsg(SRequestObj *pRequest, SRequestMsgBody* pMsgBody) { int32_t buildConnectMsg(SRequestObj *pRequest, SRequestMsgBody* pMsgBody) {
pMsgBody->msgType = TSDB_MSG_TYPE_CONNECT; pMsgBody->msgType = TSDB_MSG_TYPE_CONNECT;
...@@ -67,15 +66,6 @@ int processConnectRsp(SRequestObj *pRequest, const char* pMsg, int32_t msgLen) { ...@@ -67,15 +66,6 @@ int processConnectRsp(SRequestObj *pRequest, const char* pMsg, int32_t msgLen) {
pConnect->epSet.port[i] = htons(pConnect->epSet.port[i]); pConnect->epSet.port[i] = htons(pConnect->epSet.port[i]);
} }
// TODO refactor
pthread_mutex_lock(&pTscObj->mutex);
char temp[TSDB_TABLE_FNAME_LEN * 2] = {0};
int32_t len = sprintf(temp, "%d%s%s", pTscObj->acctId, TS_PATH_DELIMITER, pTscObj->db);
assert(len <= sizeof(pTscObj->db));
tstrncpy(pTscObj->db, temp, sizeof(pTscObj->db));
pthread_mutex_unlock(&pTscObj->mutex);
if (!isEpsetEqual(&pTscObj->pAppInfo->mgmtEp.epSet, &pConnect->epSet)) { if (!isEpsetEqual(&pTscObj->pAppInfo->mgmtEp.epSet, &pConnect->epSet)) {
updateEpSet_s(&pTscObj->pAppInfo->mgmtEp, &pConnect->epSet); updateEpSet_s(&pTscObj->pAppInfo->mgmtEp, &pConnect->epSet);
} }
...@@ -96,47 +86,35 @@ int processConnectRsp(SRequestObj *pRequest, const char* pMsg, int32_t msgLen) { ...@@ -96,47 +86,35 @@ int processConnectRsp(SRequestObj *pRequest, const char* pMsg, int32_t msgLen) {
return 0; return 0;
} }
int32_t doBuildMsgSupp(SRequestObj *pRequest, SRequestMsgBody* pMsgBody) { static int32_t buildRetrieveMnodeMsg(SRequestObj *pRequest, SRequestMsgBody* pMsgBody) {
pMsgBody->msgType = TSDB_MSG_TYPE_SHOW_RETRIEVE;
pMsgBody->msgInfo.len = sizeof(SRetrieveTableMsg);
pMsgBody->requestObjRefId = pRequest->self; pMsgBody->requestObjRefId = pRequest->self;
pMsgBody->msgInfo = pRequest->body.requestMsg;
switch(pRequest->type) {
case TSDB_SQL_CREATE_USER:
pMsgBody->msgType = TSDB_MSG_TYPE_CREATE_USER;
break;
case TSDB_SQL_DROP_USER:
pMsgBody->msgType = TSDB_MSG_TYPE_DROP_USER;
break;
case TSDB_SQL_CREATE_ACCT:
pMsgBody->msgType = TSDB_MSG_TYPE_CREATE_ACCT;
break;
case TSDB_SQL_DROP_ACCT:
pMsgBody->msgType = TSDB_MSG_TYPE_DROP_ACCT;
break;
case TSDB_SQL_CREATE_DB: {
pMsgBody->msgType = TSDB_MSG_TYPE_CREATE_DB;
SCreateDbMsg* pCreateMsg = pRequest->body.requestMsg.pMsg;
SName name = {0};
int32_t ret = tNameSetDbName(&name, pRequest->pTscObj->acctId, pCreateMsg->db, strnlen(pCreateMsg->db, tListLen(pCreateMsg->db)));
if (ret != TSDB_CODE_SUCCESS) {
return -1;
}
tNameGetFullDbName(&name, pCreateMsg->db); SRetrieveTableMsg *pRetrieveMsg = calloc(1, sizeof(SRetrieveTableMsg));
break; if (pRetrieveMsg == NULL) {
} return TSDB_CODE_TSC_OUT_OF_MEMORY;
case TSDB_SQL_USE_DB: {
pMsgBody->msgType = TSDB_MSG_TYPE_USE_DB;
break;
}
case TSDB_SQL_CREATE_TABLE: {
pMsgBody->msgType = TSDB_MSG_TYPE_CREATE_STB;
break;
} }
case TSDB_SQL_SHOW:
pMsgBody->msgType = TSDB_MSG_TYPE_SHOW; pRetrieveMsg->showId = htonl(pRequest->body.execId);
break; pMsgBody->msgInfo.pMsg = pRetrieveMsg;
return TSDB_CODE_SUCCESS;
}
SRequestMsgBody buildRequestMsgImpl(SRequestObj *pRequest) {
if (pRequest->type == TSDB_MSG_TYPE_SHOW_RETRIEVE) {
SRequestMsgBody body = {0};
buildRetrieveMnodeMsg(pRequest, &body);
return body;
} else {
assert(pRequest != NULL);
SRequestMsgBody body = {
.requestObjRefId = pRequest->self,
.msgInfo = pRequest->body.requestMsg,
.msgType = pRequest->type,
.requestId = pRequest->requestId,
};
return body;
} }
} }
...@@ -175,18 +153,6 @@ int32_t processShowRsp(SRequestObj *pRequest, const char* pMsg, int32_t msgLen) ...@@ -175,18 +153,6 @@ int32_t processShowRsp(SRequestObj *pRequest, const char* pMsg, int32_t msgLen)
return 0; return 0;
} }
int buildRetrieveMnodeMsg(SRequestObj *pRequest, SRequestMsgBody* pMsgBody) {
pMsgBody->msgType = TSDB_MSG_TYPE_SHOW_RETRIEVE;
pMsgBody->msgInfo.len = sizeof(SRetrieveTableMsg);
pMsgBody->requestObjRefId = pRequest->self;
SRetrieveTableMsg *pRetrieveMsg = calloc(1, sizeof(SRetrieveTableMsg));
pRetrieveMsg->showId = htonl(pRequest->body.execId);
pMsgBody->msgInfo.pMsg = pRetrieveMsg;
return TSDB_CODE_SUCCESS;
}
int32_t processRetrieveMnodeRsp(SRequestObj *pRequest, const char* pMsg, int32_t msgLen) { int32_t processRetrieveMnodeRsp(SRequestObj *pRequest, const char* pMsg, int32_t msgLen) {
assert(msgLen >= sizeof(SRetrieveTableRsp)); assert(msgLen >= sizeof(SRetrieveTableRsp));
...@@ -227,6 +193,10 @@ int32_t processCreateTableRsp(SRequestObj *pRequest, const char* pMsg, int32_t m ...@@ -227,6 +193,10 @@ int32_t processCreateTableRsp(SRequestObj *pRequest, const char* pMsg, int32_t m
assert(pMsg != NULL); assert(pMsg != NULL);
} }
int32_t processDropDbRsp(SRequestObj *pRequest, const char* pMsg, int32_t msgLen) {
// todo: Remove cache in catalog cache.
}
void initMsgHandleFp() { void initMsgHandleFp() {
#if 0 #if 0
tscBuildMsg[TSDB_SQL_SELECT] = tscBuildQueryMsg; tscBuildMsg[TSDB_SQL_SELECT] = tscBuildQueryMsg;
...@@ -303,27 +273,11 @@ void initMsgHandleFp() { ...@@ -303,27 +273,11 @@ void initMsgHandleFp() {
tscProcessMsgRsp[TSDB_SQL_SHOW_CREATE_DATABASE] = tscProcessShowCreateRsp; tscProcessMsgRsp[TSDB_SQL_SHOW_CREATE_DATABASE] = tscProcessShowCreateRsp;
#endif #endif
buildRequestMsgFp[TSDB_SQL_CONNECT] = buildConnectMsg; handleRequestRspFp[TSDB_MSG_TYPE_CONNECT] = processConnectRsp;
handleRequestRspFp[TSDB_SQL_CONNECT] = processConnectRsp; handleRequestRspFp[TSDB_MSG_TYPE_SHOW] = processShowRsp;
handleRequestRspFp[TSDB_MSG_TYPE_SHOW_RETRIEVE] = processRetrieveMnodeRsp;
buildRequestMsgFp[TSDB_SQL_CREATE_USER] = doBuildMsgSupp; handleRequestRspFp[TSDB_MSG_TYPE_CREATE_DB] = processCreateDbRsp;
buildRequestMsgFp[TSDB_SQL_DROP_USER] = doBuildMsgSupp; handleRequestRspFp[TSDB_MSG_TYPE_USE_DB] = processUseDbRsp;
handleRequestRspFp[TSDB_MSG_TYPE_CREATE_TABLE] = processCreateTableRsp;
buildRequestMsgFp[TSDB_SQL_CREATE_ACCT] = doBuildMsgSupp; handleRequestRspFp[TSDB_MSG_TYPE_DROP_DB] = processDropDbRsp;
buildRequestMsgFp[TSDB_SQL_DROP_ACCT] = doBuildMsgSupp;
buildRequestMsgFp[TSDB_SQL_SHOW] = doBuildMsgSupp;
handleRequestRspFp[TSDB_SQL_SHOW] = processShowRsp;
buildRequestMsgFp[TSDB_SQL_RETRIEVE_MNODE] = buildRetrieveMnodeMsg;
handleRequestRspFp[TSDB_SQL_RETRIEVE_MNODE]= processRetrieveMnodeRsp;
buildRequestMsgFp[TSDB_SQL_CREATE_DB] = doBuildMsgSupp;
handleRequestRspFp[TSDB_SQL_CREATE_DB] = processCreateDbRsp;
buildRequestMsgFp[TSDB_SQL_USE_DB] = doBuildMsgSupp;
handleRequestRspFp[TSDB_SQL_USE_DB] = processUseDbRsp;
buildRequestMsgFp[TSDB_SQL_CREATE_TABLE] = doBuildMsgSupp;
handleRequestRspFp[TSDB_SQL_CREATE_TABLE] = processCreateTableRsp;
} }
\ No newline at end of file
...@@ -22,11 +22,24 @@ ...@@ -22,11 +22,24 @@
#pragma GCC diagnostic ignored "-Wunused-variable" #pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wsign-compare" #pragma GCC diagnostic ignored "-Wsign-compare"
#include "../inc/clientInt.h"
#include "taos.h" #include "taos.h"
#include "tglobal.h" #include "tglobal.h"
#include "../inc/clientInt.h"
namespace { namespace {
void showDB(TAOS* pConn) {
TAOS_RES* pRes = taos_query(pConn, "show databases");
TAOS_ROW pRow = NULL;
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
int32_t numOfFields = taos_num_fields(pRes);
char str[512] = {0};
while ((pRow = taos_fetch_row(pRes)) != NULL) {
int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
printf("%s\n", str);
}
}
} // namespace } // namespace
int main(int argc, char** argv) { int main(int argc, char** argv) {
...@@ -34,19 +47,17 @@ int main(int argc, char** argv) { ...@@ -34,19 +47,17 @@ int main(int argc, char** argv) {
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }
TEST(testCase, driverInit_Test) { TEST(testCase, driverInit_Test) { taos_init(); }
taos_init();
}
TEST(testCase, connect_Test) { TEST(testCase, connect_Test) {
TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0); TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0);
// assert(pConn != NULL); // assert(pConn != NULL);
taos_close(pConn); taos_close(pConn);
} }
TEST(testCase, create_user_Test) { TEST(testCase, create_user_Test) {
TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0); TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0);
// assert(pConn != NULL); assert(pConn != NULL);
TAOS_RES* pRes = taos_query(pConn, "create user abc pass 'abc'"); TAOS_RES* pRes = taos_query(pConn, "create user abc pass 'abc'");
if (taos_errno(pRes) != TSDB_CODE_SUCCESS) { if (taos_errno(pRes) != TSDB_CODE_SUCCESS) {
...@@ -57,7 +68,7 @@ TEST(testCase, create_user_Test) { ...@@ -57,7 +68,7 @@ TEST(testCase, create_user_Test) {
taos_close(pConn); taos_close(pConn);
} }
TEST(testCase, create_account_Test) { TEST(testCase, create_account_Test) {
TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0); TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0);
assert(pConn != NULL); assert(pConn != NULL);
...@@ -70,7 +81,7 @@ TEST(testCase, create_account_Test) { ...@@ -70,7 +81,7 @@ TEST(testCase, create_account_Test) {
taos_close(pConn); taos_close(pConn);
} }
TEST(testCase, drop_account_Test) { TEST(testCase, drop_account_Test) {
TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0); TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0);
assert(pConn != NULL); assert(pConn != NULL);
...@@ -83,7 +94,7 @@ TEST(testCase, drop_account_Test) { ...@@ -83,7 +94,7 @@ TEST(testCase, drop_account_Test) {
taos_close(pConn); taos_close(pConn);
} }
TEST(testCase, show_user_Test) { TEST(testCase, show_user_Test) {
TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0); TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0);
// assert(pConn != NULL); // assert(pConn != NULL);
...@@ -102,7 +113,7 @@ TEST(testCase, show_user_Test) { ...@@ -102,7 +113,7 @@ TEST(testCase, show_user_Test) {
taos_close(pConn); taos_close(pConn);
} }
TEST(testCase, drop_user_Test) { TEST(testCase, drop_user_Test) {
TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0); TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0);
assert(pConn != NULL); assert(pConn != NULL);
...@@ -115,7 +126,7 @@ TEST(testCase, drop_user_Test) { ...@@ -115,7 +126,7 @@ TEST(testCase, drop_user_Test) {
taos_close(pConn); taos_close(pConn);
} }
TEST(testCase, show_db_Test) { TEST(testCase, show_db_Test) {
TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0); TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0);
// assert(pConn != NULL); // assert(pConn != NULL);
...@@ -139,6 +150,9 @@ TEST(testCase, create_db_Test) { ...@@ -139,6 +150,9 @@ TEST(testCase, create_db_Test) {
assert(pConn != NULL); assert(pConn != NULL);
TAOS_RES* pRes = taos_query(pConn, "create database abc1"); 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_FIELD* pFields = taos_fetch_fields(pRes); TAOS_FIELD* pFields = taos_fetch_fields(pRes);
ASSERT_TRUE(pFields == NULL); ASSERT_TRUE(pFields == NULL);
...@@ -154,6 +168,9 @@ TEST(testCase, use_db_test) { ...@@ -154,6 +168,9 @@ TEST(testCase, use_db_test) {
assert(pConn != NULL); assert(pConn != NULL);
TAOS_RES* pRes = taos_query(pConn, "use abc1"); TAOS_RES* pRes = taos_query(pConn, "use abc1");
if (taos_errno(pRes) != 0) {
printf("error in use db, reason:%s\n", taos_errstr(pRes));
}
TAOS_FIELD* pFields = taos_fetch_fields(pRes); TAOS_FIELD* pFields = taos_fetch_fields(pRes);
ASSERT_TRUE(pFields == NULL); ASSERT_TRUE(pFields == NULL);
...@@ -164,20 +181,124 @@ TEST(testCase, use_db_test) { ...@@ -164,20 +181,124 @@ TEST(testCase, use_db_test) {
taos_close(pConn); taos_close(pConn);
} }
TEST(testCase, create_stable_Test) { TEST(testCase, drop_db_test) {
TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0); TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0);
assert(pConn != NULL); assert(pConn != NULL);
TAOS_RES* pRes = taos_query(pConn, "use abc1"); showDB(pConn);
TAOS_RES* pRes = taos_query(pConn, "drop database abc1");
if (taos_errno(pRes) != 0) {
printf("failed to drop db, reason:%s\n", taos_errstr(pRes));
}
taos_free_result(pRes); taos_free_result(pRes);
pRes = taos_query(pConn, "create stable st1(ts timestamp, k int) tags(a int)"); showDB(pConn);
taos_close(pConn);
}
TAOS_FIELD* pFields = taos_fetch_fields(pRes); // TEST(testCase, create_stable_Test) {
ASSERT_TRUE(pFields == NULL); // TAOS* pConn = taos_connect("ubuntu", "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);
// taos_close(pConn);
//}
TEST(testCase, create_table_Test) {
// TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0);
// assert(pConn != NULL);
//
// TAOS_RES* pRes = taos_query(pConn, "use abc1");
// taos_free_result(pRes);
//
// pRes = taos_query(pConn, "create table tm0(ts timestamp, k int)");
// taos_free_result(pRes);
//
// taos_close(pConn);
}
TEST(testCase, create_ctable_Test) {}
TEST(testCase, show_stable_Test) {
TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0);
assert(pConn != NULL);
TAOS_RES* pRes = taos_query(pConn, "show stables");
TAOS_ROW pRow = NULL;
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
int32_t numOfFields = taos_num_fields(pRes); int32_t numOfFields = taos_num_fields(pRes);
ASSERT_EQ(numOfFields, 0);
char str[512] = {0};
while((pRow = taos_fetch_row(pRes)) != NULL) {
int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
printf("%s\n", str);
}
taos_free_result(pRes);
taos_close(pConn); taos_close(pConn);
} }
TEST(testCase, drop_stable_Test) {
TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0);
assert(pConn != NULL);
TAOS_RES* pRes = taos_query(pConn, "create database abc1");
if (taos_errno(pRes) != 0) {
printf("error in creating 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 using db, reason:%s\n", taos_errstr(pRes));
}
taos_free_result(pRes);
pRes = taos_query(pConn, "drop stable st1");
if (taos_errno(pRes) != 0) {
printf("failed to drop stable, reason:%s\n", taos_errstr(pRes));
}
taos_free_result(pRes);
taos_close(pConn);
}
//TEST(testCase, show_table_Test) {
// TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0);
// assert(pConn != NULL);
//
// TAOS_RES* pRes = taos_query(pConn, "use abc1");
// taos_free_result(pRes);
//
// pRes = taos_query(pConn, "show tables");
// taos_free_result(pRes);
//
// taos_close(pConn);
//}
...@@ -349,7 +349,7 @@ static void dndBuildMnodeDeployOption(SDnode *pDnode, SMnodeOpt *pOption) { ...@@ -349,7 +349,7 @@ static void dndBuildMnodeDeployOption(SDnode *pDnode, SMnodeOpt *pOption) {
SReplica *pReplica = &pOption->replicas[0]; SReplica *pReplica = &pOption->replicas[0];
pReplica->id = 1; pReplica->id = 1;
pReplica->port = pDnode->opt.serverPort; pReplica->port = pDnode->opt.serverPort;
tstrncpy(pReplica->fqdn, pDnode->opt.localFqdn, TSDB_FQDN_LEN); memcpy(pReplica->fqdn, pDnode->opt.localFqdn, TSDB_FQDN_LEN);
SMnodeMgmt *pMgmt = &pDnode->mmgmt; SMnodeMgmt *pMgmt = &pDnode->mmgmt;
pMgmt->selfIndex = pOption->selfIndex; pMgmt->selfIndex = pOption->selfIndex;
...@@ -376,7 +376,7 @@ static int32_t dndBuildMnodeOptionFromMsg(SDnode *pDnode, SMnodeOpt *pOption, SC ...@@ -376,7 +376,7 @@ static int32_t dndBuildMnodeOptionFromMsg(SDnode *pDnode, SMnodeOpt *pOption, SC
SReplica *pReplica = &pOption->replicas[i]; SReplica *pReplica = &pOption->replicas[i];
pReplica->id = pMsg->replicas[i].id; pReplica->id = pMsg->replicas[i].id;
pReplica->port = pMsg->replicas[i].port; pReplica->port = pMsg->replicas[i].port;
tstrncpy(pReplica->fqdn, pMsg->replicas[i].fqdn, TSDB_FQDN_LEN); memcpy(pReplica->fqdn, pMsg->replicas[i].fqdn, TSDB_FQDN_LEN);
if (pReplica->id == pOption->dnodeId) { if (pReplica->id == pOption->dnodeId) {
pOption->selfIndex = i; pOption->selfIndex = i;
} }
...@@ -479,9 +479,11 @@ static int32_t dndDropMnode(SDnode *pDnode) { ...@@ -479,9 +479,11 @@ static int32_t dndDropMnode(SDnode *pDnode) {
return -1; return -1;
} }
dndReleaseMnode(pDnode, pMnode);
dndStopMnodeWorker(pDnode); dndStopMnodeWorker(pDnode);
dndWriteMnodeFile(pDnode); dndWriteMnodeFile(pDnode);
mndClose(pMnode); mndClose(pMnode);
pMgmt->pMnode = NULL;
mndDestroy(pDnode->dir.mnode); mndDestroy(pDnode->dir.mnode);
return 0; return 0;
...@@ -499,7 +501,7 @@ static SCreateMnodeInMsg *dndParseCreateMnodeMsg(SRpcMsg *pRpcMsg) { ...@@ -499,7 +501,7 @@ static SCreateMnodeInMsg *dndParseCreateMnodeMsg(SRpcMsg *pRpcMsg) {
} }
static int32_t dndProcessCreateMnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) { static int32_t dndProcessCreateMnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
SCreateMnodeInMsg *pMsg = dndParseCreateMnodeMsg(pRpcMsg->pCont); SCreateMnodeInMsg *pMsg = dndParseCreateMnodeMsg(pRpcMsg);
if (pMsg->dnodeId != dndGetDnodeId(pDnode)) { if (pMsg->dnodeId != dndGetDnodeId(pDnode)) {
terrno = TSDB_CODE_DND_MNODE_ID_INVALID; terrno = TSDB_CODE_DND_MNODE_ID_INVALID;
...@@ -515,18 +517,23 @@ static int32_t dndProcessCreateMnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) { ...@@ -515,18 +517,23 @@ static int32_t dndProcessCreateMnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
} }
static int32_t dndProcessAlterMnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) { static int32_t dndProcessAlterMnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
SAlterMnodeInMsg *pMsg = dndParseCreateMnodeMsg(pRpcMsg->pCont); SAlterMnodeInMsg *pMsg = dndParseCreateMnodeMsg(pRpcMsg);
if (pMsg->dnodeId != dndGetDnodeId(pDnode)) { if (pMsg->dnodeId != dndGetDnodeId(pDnode)) {
terrno = TSDB_CODE_DND_MNODE_ID_INVALID; terrno = TSDB_CODE_DND_MNODE_ID_INVALID;
return -1; return -1;
} else { }
SMnodeOpt option = {0}; SMnodeOpt option = {0};
if (dndBuildMnodeOptionFromMsg(pDnode, &option, pMsg) != 0) { if (dndBuildMnodeOptionFromMsg(pDnode, &option, pMsg) != 0) {
return -1; return -1;
} }
return dndAlterMnode(pDnode, &option);
if (dndAlterMnode(pDnode, &option) != 0) {
return -1;
} }
return dndWriteMnodeFile(pDnode);
} }
static int32_t dndProcessDropMnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) { static int32_t dndProcessDropMnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
...@@ -555,16 +562,17 @@ static void dndProcessMnodeMgmtQueue(SDnode *pDnode, SRpcMsg *pMsg) { ...@@ -555,16 +562,17 @@ static void dndProcessMnodeMgmtQueue(SDnode *pDnode, SRpcMsg *pMsg) {
code = dndProcessDropMnodeReq(pDnode, pMsg); code = dndProcessDropMnodeReq(pDnode, pMsg);
break; break;
default: default:
code = TSDB_CODE_MSG_NOT_PROCESSED; terrno = TSDB_CODE_MSG_NOT_PROCESSED;
code = -1;
break; break;
} }
if (pMsg->msgType & 1u) { if (pMsg->msgType & 1u) {
if (code != 0) code = terrno;
SRpcMsg rsp = {.code = code, .handle = pMsg->handle}; SRpcMsg rsp = {.code = code, .handle = pMsg->handle};
rpcSendResponse(&rsp); rpcSendResponse(&rsp);
} }
rpcFreeCont(pMsg->pCont); rpcFreeCont(pMsg->pCont);
pMsg->pCont = NULL;
taosFreeQitem(pMsg); taosFreeQitem(pMsg);
} }
...@@ -625,8 +633,6 @@ static void dndProcessMnodeSyncQueue(SDnode *pDnode, SMnodeMsg *pMsg) { ...@@ -625,8 +633,6 @@ static void dndProcessMnodeSyncQueue(SDnode *pDnode, SMnodeMsg *pMsg) {
} }
static int32_t dndWriteMnodeMsgToQueue(SMnode *pMnode, taos_queue pQueue, SRpcMsg *pRpcMsg) { static int32_t dndWriteMnodeMsgToQueue(SMnode *pMnode, taos_queue pQueue, SRpcMsg *pRpcMsg) {
assert(pQueue);
SMnodeMsg *pMsg = mndInitMsg(pMnode, pRpcMsg); SMnodeMsg *pMsg = mndInitMsg(pMnode, pRpcMsg);
if (pMsg == NULL) { if (pMsg == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
...@@ -647,15 +653,18 @@ void dndProcessMnodeMgmtMsg(SDnode *pDnode, SRpcMsg *pRpcMsg, SEpSet *pEpSet) { ...@@ -647,15 +653,18 @@ void dndProcessMnodeMgmtMsg(SDnode *pDnode, SRpcMsg *pRpcMsg, SEpSet *pEpSet) {
SMnode *pMnode = dndAcquireMnode(pDnode); SMnode *pMnode = dndAcquireMnode(pDnode);
SRpcMsg *pMsg = taosAllocateQitem(sizeof(SRpcMsg)); SRpcMsg *pMsg = taosAllocateQitem(sizeof(SRpcMsg));
if (pMsg != NULL) *pMsg = *pRpcMsg;
if (pMsg == NULL || taosWriteQitem(pMgmt->pMgmtQ, pMsg) != 0) { if (pMsg == NULL || taosWriteQitem(pMgmt->pMgmtQ, pMsg) != 0) {
if (pRpcMsg->msgType & 1u) { if (pRpcMsg->msgType & 1u) {
SRpcMsg rsp = {.handle = pRpcMsg->handle, .code = TSDB_CODE_OUT_OF_MEMORY}; SRpcMsg rsp = {.handle = pRpcMsg->handle, .code = TSDB_CODE_OUT_OF_MEMORY};
rpcSendResponse(&rsp); rpcSendResponse(&rsp);
} }
rpcFreeCont(pRpcMsg->pCont); rpcFreeCont(pRpcMsg->pCont);
pRpcMsg->pCont = NULL;
taosFreeQitem(pMsg); taosFreeQitem(pMsg);
} }
dndReleaseMnode(pDnode, pMnode);
} }
void dndProcessMnodeWriteMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) { void dndProcessMnodeWriteMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) {
...@@ -894,6 +903,11 @@ int32_t dndInitMnode(SDnode *pDnode) { ...@@ -894,6 +903,11 @@ int32_t dndInitMnode(SDnode *pDnode) {
return -1; return -1;
} }
if (dndAllocMnodeMgmtQueue(pDnode) != 0) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
char path[PATH_MAX]; char path[PATH_MAX];
snprintf(path, PATH_MAX, "%s/mnode.json", pDnode->dir.dnode); snprintf(path, PATH_MAX, "%s/mnode.json", pDnode->dir.dnode);
pMgmt->file = strdup(path); pMgmt->file = strdup(path);
...@@ -935,8 +949,9 @@ void dndCleanupMnode(SDnode *pDnode) { ...@@ -935,8 +949,9 @@ void dndCleanupMnode(SDnode *pDnode) {
SMnodeMgmt *pMgmt = &pDnode->mmgmt; SMnodeMgmt *pMgmt = &pDnode->mmgmt;
dInfo("dnode-mnode start to clean up"); dInfo("dnode-mnode start to clean up");
dndStopMnodeWorker(pDnode); if (pMgmt->pMnode) dndStopMnodeWorker(pDnode);
dndCleanupMnodeMgmtWorker(pDnode); dndCleanupMnodeMgmtWorker(pDnode);
dndFreeMnodeMgmtQueue(pDnode);
tfree(pMgmt->file); tfree(pMgmt->file);
mndClose(pMgmt->pMnode); mndClose(pMgmt->pMnode);
dInfo("dnode-mnode is cleaned up"); dInfo("dnode-mnode is cleaned up");
......
...@@ -45,6 +45,10 @@ static void dndInitMsgFp(STransMgmt *pMgmt) { ...@@ -45,6 +45,10 @@ static void dndInitMsgFp(STransMgmt *pMgmt) {
pMgmt->msgFp[TSDB_MSG_TYPE_MQ_CONNECT] = dndProcessVnodeWriteMsg; pMgmt->msgFp[TSDB_MSG_TYPE_MQ_CONNECT] = dndProcessVnodeWriteMsg;
pMgmt->msgFp[TSDB_MSG_TYPE_MQ_DISCONNECT] = dndProcessVnodeWriteMsg; pMgmt->msgFp[TSDB_MSG_TYPE_MQ_DISCONNECT] = dndProcessVnodeWriteMsg;
pMgmt->msgFp[TSDB_MSG_TYPE_MQ_SET_CUR] = dndProcessVnodeWriteMsg; pMgmt->msgFp[TSDB_MSG_TYPE_MQ_SET_CUR] = dndProcessVnodeWriteMsg;
pMgmt->msgFp[TSDB_MSG_TYPE_RES_READY] = dndProcessVnodeFetchMsg;
pMgmt->msgFp[TSDB_MSG_TYPE_TASKS_STATUS] = dndProcessVnodeFetchMsg;
pMgmt->msgFp[TSDB_MSG_TYPE_CANCEL_TASK] = dndProcessVnodeFetchMsg;
pMgmt->msgFp[TSDB_MSG_TYPE_DROP_TASK] = dndProcessVnodeFetchMsg;
// msg from client to mnode // msg from client to mnode
pMgmt->msgFp[TSDB_MSG_TYPE_CONNECT] = dndProcessMnodeReadMsg; pMgmt->msgFp[TSDB_MSG_TYPE_CONNECT] = dndProcessMnodeReadMsg;
...@@ -136,7 +140,7 @@ static void dndProcessResponse(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) { ...@@ -136,7 +140,7 @@ static void dndProcessResponse(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) {
DndMsgFp fp = pMgmt->msgFp[msgType]; DndMsgFp fp = pMgmt->msgFp[msgType];
if (fp != NULL) { if (fp != NULL) {
(*fp)(pDnode, pMsg, pEpSet); (*fp)(pDnode, pMsg, pEpSet);
dTrace("RPC %p, rsp:%s is processed, code:0x%0X", pMsg->handle, taosMsg[msgType], pMsg->code & 0XFFFF); dTrace("RPC %p, rsp:%s is processed, code:0x%x", pMsg->handle, taosMsg[msgType], pMsg->code & 0XFFFF);
} else { } else {
dError("RPC %p, rsp:%s not processed", pMsg->handle, taosMsg[msgType]); dError("RPC %p, rsp:%s not processed", pMsg->handle, taosMsg[msgType]);
rpcFreeCont(pMsg->pCont); rpcFreeCont(pMsg->pCont);
...@@ -184,7 +188,7 @@ static void dndProcessRequest(void *param, SRpcMsg *pMsg, SEpSet *pEpSet) { ...@@ -184,7 +188,7 @@ static void dndProcessRequest(void *param, SRpcMsg *pMsg, SEpSet *pEpSet) {
int32_t msgType = pMsg->msgType; int32_t msgType = pMsg->msgType;
if (msgType == TSDB_MSG_TYPE_NETWORK_TEST) { if (msgType == TSDB_MSG_TYPE_NETWORK_TEST) {
dTrace("RPC %p, network test req, app:%p will be processed", pMsg->handle, pMsg->ahandle); dTrace("RPC %p, network test req, app:%p will be processed, code:0x%x", pMsg->handle, pMsg->ahandle, pMsg->code);
dndProcessDnodeReq(pDnode, pMsg, pEpSet); dndProcessDnodeReq(pDnode, pMsg, pEpSet);
return; return;
} }
......
...@@ -7,7 +7,7 @@ add_subdirectory(cluster) ...@@ -7,7 +7,7 @@ add_subdirectory(cluster)
add_subdirectory(db) add_subdirectory(db)
add_subdirectory(dnode) add_subdirectory(dnode)
# add_subdirectory(func) # add_subdirectory(func)
# add_subdirectory(mnode) add_subdirectory(mnode)
add_subdirectory(profile) add_subdirectory(profile)
add_subdirectory(show) add_subdirectory(show)
add_subdirectory(stb) add_subdirectory(stb)
......
...@@ -27,24 +27,25 @@ Testbase DndTestDb::test; ...@@ -27,24 +27,25 @@ Testbase DndTestDb::test;
TEST_F(DndTestDb, 01_ShowDb) { TEST_F(DndTestDb, 01_ShowDb) {
test.SendShowMetaMsg(TSDB_MGMT_TABLE_DB, ""); test.SendShowMetaMsg(TSDB_MGMT_TABLE_DB, "");
CHECK_META("show databases", 17); CHECK_META("show databases", 18);
CHECK_SCHEMA(0, TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN - 1 + VARSTR_HEADER_SIZE, "name"); CHECK_SCHEMA(0, TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN - 1 + VARSTR_HEADER_SIZE, "name");
CHECK_SCHEMA(1, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); CHECK_SCHEMA(1, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time");
CHECK_SCHEMA(2, TSDB_DATA_TYPE_SMALLINT, 2, "vgroups"); CHECK_SCHEMA(2, TSDB_DATA_TYPE_SMALLINT, 2, "vgroups");
CHECK_SCHEMA(3, TSDB_DATA_TYPE_SMALLINT, 2, "replica"); CHECK_SCHEMA(3, TSDB_DATA_TYPE_INT, 4, "ntables");
CHECK_SCHEMA(4, TSDB_DATA_TYPE_SMALLINT, 2, "quorum"); CHECK_SCHEMA(4, TSDB_DATA_TYPE_SMALLINT, 2, "replica");
CHECK_SCHEMA(5, TSDB_DATA_TYPE_SMALLINT, 2, "days"); CHECK_SCHEMA(5, TSDB_DATA_TYPE_SMALLINT, 2, "quorum");
CHECK_SCHEMA(6, TSDB_DATA_TYPE_BINARY, 24 + VARSTR_HEADER_SIZE, "keep0,keep1,keep2"); CHECK_SCHEMA(6, TSDB_DATA_TYPE_SMALLINT, 2, "days");
CHECK_SCHEMA(7, TSDB_DATA_TYPE_INT, 4, "cache"); CHECK_SCHEMA(7, TSDB_DATA_TYPE_BINARY, 24 + VARSTR_HEADER_SIZE, "keep0,keep1,keep2");
CHECK_SCHEMA(8, TSDB_DATA_TYPE_INT, 4, "blocks"); CHECK_SCHEMA(8, TSDB_DATA_TYPE_INT, 4, "cache");
CHECK_SCHEMA(9, TSDB_DATA_TYPE_INT, 4, "minrows"); CHECK_SCHEMA(9, TSDB_DATA_TYPE_INT, 4, "blocks");
CHECK_SCHEMA(10, TSDB_DATA_TYPE_INT, 4, "maxrows"); CHECK_SCHEMA(10, TSDB_DATA_TYPE_INT, 4, "minrows");
CHECK_SCHEMA(11, TSDB_DATA_TYPE_TINYINT, 1, "wallevel"); CHECK_SCHEMA(11, TSDB_DATA_TYPE_INT, 4, "maxrows");
CHECK_SCHEMA(12, TSDB_DATA_TYPE_INT, 4, "fsync"); CHECK_SCHEMA(12, TSDB_DATA_TYPE_TINYINT, 1, "wallevel");
CHECK_SCHEMA(13, TSDB_DATA_TYPE_TINYINT, 1, "comp"); CHECK_SCHEMA(13, TSDB_DATA_TYPE_INT, 4, "fsync");
CHECK_SCHEMA(14, TSDB_DATA_TYPE_TINYINT, 1, "cachelast"); CHECK_SCHEMA(14, TSDB_DATA_TYPE_TINYINT, 1, "comp");
CHECK_SCHEMA(15, TSDB_DATA_TYPE_BINARY, 3 + VARSTR_HEADER_SIZE, "precision"); CHECK_SCHEMA(15, TSDB_DATA_TYPE_TINYINT, 1, "cachelast");
CHECK_SCHEMA(16, TSDB_DATA_TYPE_TINYINT, 1, "update"); CHECK_SCHEMA(16, TSDB_DATA_TYPE_BINARY, 3 + VARSTR_HEADER_SIZE, "precision");
CHECK_SCHEMA(17, TSDB_DATA_TYPE_TINYINT, 1, "update");
test.SendShowRetrieveMsg(); test.SendShowRetrieveMsg();
EXPECT_EQ(test.GetShowRows(), 0); EXPECT_EQ(test.GetShowRows(), 0);
...@@ -82,13 +83,14 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) { ...@@ -82,13 +83,14 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) {
} }
test.SendShowMetaMsg(TSDB_MGMT_TABLE_DB, ""); test.SendShowMetaMsg(TSDB_MGMT_TABLE_DB, "");
CHECK_META("show databases", 17); CHECK_META("show databases", 18);
test.SendShowRetrieveMsg(); test.SendShowRetrieveMsg();
EXPECT_EQ(test.GetShowRows(), 1); EXPECT_EQ(test.GetShowRows(), 1);
CheckBinary("d1", TSDB_DB_NAME_LEN - 1); CheckBinary("d1", TSDB_DB_NAME_LEN - 1);
CheckTimestamp(); CheckTimestamp();
CheckInt16(2); // vgroups CheckInt16(2); // vgroups
CheckInt32(0); // ntables
CheckInt16(1); // replica CheckInt16(1); // replica
CheckInt16(1); // quorum CheckInt16(1); // quorum
CheckInt16(10); // days CheckInt16(10); // days
...@@ -147,6 +149,7 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) { ...@@ -147,6 +149,7 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) {
CheckBinary("d1", TSDB_DB_NAME_LEN - 1); CheckBinary("d1", TSDB_DB_NAME_LEN - 1);
CheckTimestamp(); CheckTimestamp();
CheckInt16(2); // vgroups CheckInt16(2); // vgroups
CheckInt32(0);
CheckInt16(1); // replica CheckInt16(1); // replica
CheckInt16(2); // quorum CheckInt16(2); // quorum
CheckInt16(10); // days CheckInt16(10); // days
...@@ -166,7 +169,7 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) { ...@@ -166,7 +169,7 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) {
test.Restart(); test.Restart();
test.SendShowMetaMsg(TSDB_MGMT_TABLE_DB, ""); test.SendShowMetaMsg(TSDB_MGMT_TABLE_DB, "");
CHECK_META("show databases", 17); CHECK_META("show databases", 18);
test.SendShowRetrieveMsg(); test.SendShowRetrieveMsg();
EXPECT_EQ(test.GetShowRows(), 1); EXPECT_EQ(test.GetShowRows(), 1);
...@@ -174,6 +177,7 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) { ...@@ -174,6 +177,7 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) {
CheckBinary("d1", TSDB_DB_NAME_LEN - 1); CheckBinary("d1", TSDB_DB_NAME_LEN - 1);
CheckTimestamp(); CheckTimestamp();
CheckInt16(2); // vgroups CheckInt16(2); // vgroups
CheckInt32(0);
CheckInt16(1); // replica CheckInt16(1); // replica
CheckInt16(2); // quorum CheckInt16(2); // quorum
CheckInt16(10); // days CheckInt16(10); // days
...@@ -201,7 +205,7 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) { ...@@ -201,7 +205,7 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) {
} }
test.SendShowMetaMsg(TSDB_MGMT_TABLE_DB, ""); test.SendShowMetaMsg(TSDB_MGMT_TABLE_DB, "");
CHECK_META("show databases", 17); CHECK_META("show databases", 18);
test.SendShowRetrieveMsg(); test.SendShowRetrieveMsg();
EXPECT_EQ(test.GetShowRows(), 0); EXPECT_EQ(test.GetShowRows(), 0);
...@@ -239,7 +243,7 @@ TEST_F(DndTestDb, 03_Create_Use_Restart_Use_Db) { ...@@ -239,7 +243,7 @@ TEST_F(DndTestDb, 03_Create_Use_Restart_Use_Db) {
} }
test.SendShowMetaMsg(TSDB_MGMT_TABLE_DB, ""); test.SendShowMetaMsg(TSDB_MGMT_TABLE_DB, "");
CHECK_META("show databases", 17); CHECK_META("show databases", 18);
test.SendShowRetrieveMsg(); test.SendShowRetrieveMsg();
EXPECT_EQ(test.GetShowRows(), 1); EXPECT_EQ(test.GetShowRows(), 1);
......
aux_source_directory(. MTEST_SRC)
add_executable(dnode_test_mnode ${MTEST_SRC})
target_link_libraries(
dnode_test_mnode
PUBLIC sut
)
add_test(
NAME dnode_test_mnode
COMMAND dnode_test_mnode
)
/**
* @file dnode.cpp
* @author slguan (slguan@taosdata.com)
* @brief DNODE module dnode-msg tests
* @version 0.1
* @date 2021-12-15
*
* @copyright Copyright (c) 2021
*
*/
#include "base.h"
class DndTestMnode : public ::testing::Test {
public:
void SetUp() override {}
void TearDown() override {}
public:
static void SetUpTestSuite() {
test.Init("/tmp/dnode_test_mnode1", 9061);
const char* fqdn = "localhost";
const char* firstEp = "localhost:9061";
server2.Start("/tmp/dnode_test_mnode2", fqdn, 9062, firstEp);
server3.Start("/tmp/dnode_test_mnode3", fqdn, 9063, firstEp);
server4.Start("/tmp/dnode_test_mnode4", fqdn, 9064, firstEp);
server5.Start("/tmp/dnode_test_mnode5", fqdn, 9065, firstEp);
taosMsleep(300);
}
static void TearDownTestSuite() {
server2.Stop();
server3.Stop();
server4.Stop();
server5.Stop();
test.Cleanup();
}
static Testbase test;
static TestServer server2;
static TestServer server3;
static TestServer server4;
static TestServer server5;
};
Testbase DndTestMnode::test;
TestServer DndTestMnode::server2;
TestServer DndTestMnode::server3;
TestServer DndTestMnode::server4;
TestServer DndTestMnode::server5;
TEST_F(DndTestMnode, 01_ShowDnode) {
test.SendShowMetaMsg(TSDB_MGMT_TABLE_MNODE, "");
CHECK_META("show mnodes", 5);
CHECK_SCHEMA(0, TSDB_DATA_TYPE_SMALLINT, 2, "id");
CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN + VARSTR_HEADER_SIZE, "endpoint");
CHECK_SCHEMA(2, TSDB_DATA_TYPE_BINARY, 12 + VARSTR_HEADER_SIZE, "role");
CHECK_SCHEMA(3, TSDB_DATA_TYPE_TIMESTAMP, 8, "role_time");
CHECK_SCHEMA(4, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time");
test.SendShowRetrieveMsg();
EXPECT_EQ(test.GetShowRows(), 1);
CheckInt16(1);
CheckBinary("localhost:9061", TSDB_EP_LEN);
CheckBinary("master", 12);
CheckInt64(0);
CheckTimestamp();
}
TEST_F(DndTestMnode, 02_Create_Mnode_Invalid_Id) {
{
int32_t contLen = sizeof(SCreateMnodeMsg);
SCreateMnodeMsg* pReq = (SCreateMnodeMsg*)rpcMallocCont(contLen);
pReq->dnodeId = htonl(1);
SRpcMsg* pMsg = test.SendMsg(TSDB_MSG_TYPE_CREATE_MNODE, pReq, contLen);
ASSERT_NE(pMsg, nullptr);
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_MNODE_ALREADY_EXIST);
}
}
TEST_F(DndTestMnode, 03_Create_Mnode_Invalid_Id) {
{
int32_t contLen = sizeof(SCreateMnodeMsg);
SCreateMnodeMsg* pReq = (SCreateMnodeMsg*)rpcMallocCont(contLen);
pReq->dnodeId = htonl(2);
SRpcMsg* pMsg = test.SendMsg(TSDB_MSG_TYPE_CREATE_MNODE, pReq, contLen);
ASSERT_NE(pMsg, nullptr);
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_DNODE_NOT_EXIST);
}
}
TEST_F(DndTestMnode, 04_Create_Mnode) {
{
// create dnode
int32_t contLen = sizeof(SCreateDnodeMsg);
SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen);
strcpy(pReq->ep, "localhost:9062");
SRpcMsg* pMsg = test.SendMsg(TSDB_MSG_TYPE_CREATE_DNODE, pReq, contLen);
ASSERT_NE(pMsg, nullptr);
ASSERT_EQ(pMsg->code, 0);
taosMsleep(1300);
test.SendShowMetaMsg(TSDB_MGMT_TABLE_DNODE, "");
test.SendShowRetrieveMsg();
EXPECT_EQ(test.GetShowRows(), 2);
}
{
// create mnode
int32_t contLen = sizeof(SCreateMnodeMsg);
SCreateMnodeMsg* pReq = (SCreateMnodeMsg*)rpcMallocCont(contLen);
pReq->dnodeId = htonl(2);
SRpcMsg* pMsg = test.SendMsg(TSDB_MSG_TYPE_CREATE_MNODE, pReq, contLen);
ASSERT_NE(pMsg, nullptr);
ASSERT_EQ(pMsg->code, 0);
test.SendShowMetaMsg(TSDB_MGMT_TABLE_MNODE, "");
test.SendShowRetrieveMsg();
EXPECT_EQ(test.GetShowRows(), 2);
CheckInt16(1);
CheckInt16(2);
CheckBinary("localhost:9061", TSDB_EP_LEN);
CheckBinary("localhost:9062", TSDB_EP_LEN);
CheckBinary("master", 12);
CheckBinary("slave", 12);
CheckInt64(0);
CheckInt64(0);
CheckTimestamp();
CheckTimestamp();
}
{
// drop mnode
int32_t contLen = sizeof(SDropMnodeMsg);
SDropMnodeMsg* pReq = (SDropMnodeMsg*)rpcMallocCont(contLen);
pReq->dnodeId = htonl(2);
SRpcMsg* pMsg = test.SendMsg(TSDB_MSG_TYPE_DROP_MNODE, pReq, contLen);
ASSERT_NE(pMsg, nullptr);
ASSERT_EQ(pMsg->code, 0);
test.SendShowMetaMsg(TSDB_MGMT_TABLE_MNODE, "");
test.SendShowRetrieveMsg();
EXPECT_EQ(test.GetShowRows(), 1);
CheckInt16(1);
CheckBinary("localhost:9061", TSDB_EP_LEN);
CheckBinary("master", 12);
CheckInt64(0);
CheckTimestamp();
}
}
// {
// int32_t contLen = sizeof(SDropDnodeMsg);
// SDropDnodeMsg* pReq = (SDropDnodeMsg*)rpcMallocCont(contLen);
// pReq->dnodeId = htonl(2);
// SRpcMsg* pMsg = test.SendMsg(TSDB_MSG_TYPE_DROP_DNODE, pReq, contLen);
// ASSERT_NE(pMsg, nullptr);
// ASSERT_EQ(pMsg->code, 0);
// }
// test.SendShowMetaMsg(TSDB_MGMT_TABLE_DNODE, "");
// CHECK_META("show dnodes", 7);
// test.SendShowRetrieveMsg();
// EXPECT_EQ(test.GetShowRows(), 1);
// CheckInt16(1);
// CheckBinary("localhost:9061", TSDB_EP_LEN);
// CheckInt16(0);
// CheckInt16(1);
// CheckBinary("ready", 10);
// CheckTimestamp();
// CheckBinary("", 24);
// {
// int32_t contLen = sizeof(SCreateDnodeMsg);
// SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen);
// strcpy(pReq->ep, "localhost:9063");
// SRpcMsg* pMsg = test.SendMsg(TSDB_MSG_TYPE_CREATE_DNODE, pReq, contLen);
// ASSERT_NE(pMsg, nullptr);
// ASSERT_EQ(pMsg->code, 0);
// }
// {
// int32_t contLen = sizeof(SCreateDnodeMsg);
// SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen);
// strcpy(pReq->ep, "localhost:9064");
// SRpcMsg* pMsg = test.SendMsg(TSDB_MSG_TYPE_CREATE_DNODE, pReq, contLen);
// ASSERT_NE(pMsg, nullptr);
// ASSERT_EQ(pMsg->code, 0);
// }
// {
// int32_t contLen = sizeof(SCreateDnodeMsg);
// SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen);
// strcpy(pReq->ep, "localhost:9065");
// SRpcMsg* pMsg = test.SendMsg(TSDB_MSG_TYPE_CREATE_DNODE, pReq, contLen);
// ASSERT_NE(pMsg, nullptr);
// ASSERT_EQ(pMsg->code, 0);
// }
// taosMsleep(1300);
// test.SendShowMetaMsg(TSDB_MGMT_TABLE_DNODE, "");
// CHECK_META("show dnodes", 7);
// test.SendShowRetrieveMsg();
// EXPECT_EQ(test.GetShowRows(), 4);
// CheckInt16(1);
// CheckInt16(3);
// CheckInt16(4);
// CheckInt16(5);
// CheckBinary("localhost:9061", TSDB_EP_LEN);
// CheckBinary("localhost:9063", TSDB_EP_LEN);
// CheckBinary("localhost:9064", TSDB_EP_LEN);
// CheckBinary("localhost:9065", TSDB_EP_LEN);
// CheckInt16(0);
// CheckInt16(0);
// CheckInt16(0);
// CheckInt16(0);
// CheckInt16(1);
// CheckInt16(1);
// CheckInt16(1);
// CheckInt16(1);
// CheckBinary("ready", 10);
// CheckBinary("ready", 10);
// CheckBinary("ready", 10);
// CheckBinary("ready", 10);
// CheckTimestamp();
// CheckTimestamp();
// CheckTimestamp();
// CheckTimestamp();
// CheckBinary("", 24);
// CheckBinary("", 24);
// CheckBinary("", 24);
// CheckBinary("", 24);
// // restart
// uInfo("stop all server");
// test.Restart();
// server2.Restart();
// server3.Restart();
// server4.Restart();
// server5.Restart();
// taosMsleep(1300);
// test.SendShowMetaMsg(TSDB_MGMT_TABLE_DNODE, "");
// CHECK_META("show dnodes", 7);
// test.SendShowRetrieveMsg();
// EXPECT_EQ(test.GetShowRows(), 4);
// CheckInt16(1);
// CheckInt16(3);
// CheckInt16(4);
// CheckInt16(5);
// CheckBinary("localhost:9061", TSDB_EP_LEN);
// CheckBinary("localhost:9063", TSDB_EP_LEN);
// CheckBinary("localhost:9064", TSDB_EP_LEN);
// CheckBinary("localhost:9065", TSDB_EP_LEN);
// CheckInt16(0);
// CheckInt16(0);
// CheckInt16(0);
// CheckInt16(0);
// CheckInt16(1);
// CheckInt16(1);
// CheckInt16(1);
// CheckInt16(1);
// CheckBinary("ready", 10);
// CheckBinary("ready", 10);
// CheckBinary("ready", 10);
// CheckBinary("ready", 10);
// CheckTimestamp();
// CheckTimestamp();
// CheckTimestamp();
// CheckTimestamp();
// CheckBinary("", 24);
// CheckBinary("", 24);
// CheckBinary("", 24);
// CheckBinary("", 24);
// }
...@@ -305,11 +305,6 @@ typedef struct SMnodeMsg { ...@@ -305,11 +305,6 @@ typedef struct SMnodeMsg {
char db[TSDB_FULL_DB_NAME_LEN]; char db[TSDB_FULL_DB_NAME_LEN];
int32_t acctId; int32_t acctId;
SMnode *pMnode; SMnode *pMnode;
int16_t received;
int16_t successed;
int16_t expected;
int16_t retry;
int32_t code;
int64_t createdTime; int64_t createdTime;
SRpcMsg rpcMsg; SRpcMsg rpcMsg;
int32_t contLen; int32_t contLen;
......
...@@ -27,6 +27,7 @@ void mndCleanupMnode(SMnode *pMnode); ...@@ -27,6 +27,7 @@ void mndCleanupMnode(SMnode *pMnode);
bool mndIsMnode(SMnode *pMnode, int32_t dnodeId); bool mndIsMnode(SMnode *pMnode, int32_t dnodeId);
void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet); void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet);
char *mndGetRoleStr(int32_t role); char *mndGetRoleStr(int32_t role);
void mndUpdateMnodeRole(SMnode *pMnode);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -828,9 +828,9 @@ static int32_t mndProcessUseDbMsg(SMnodeMsg *pMsg) { ...@@ -828,9 +828,9 @@ static int32_t mndProcessUseDbMsg(SMnodeMsg *pMsg) {
static int32_t mndProcessSyncDbMsg(SMnodeMsg *pMsg) { static int32_t mndProcessSyncDbMsg(SMnodeMsg *pMsg) {
SMnode *pMnode = pMsg->pMnode; SMnode *pMnode = pMsg->pMnode;
SSyncDbMsg *pSync = pMsg->rpcMsg.pCont; SSyncDbMsg *pSync = pMsg->rpcMsg.pCont;
SDbObj *pDb = mndAcquireDb(pMnode, pMsg->db); SDbObj *pDb = mndAcquireDb(pMnode, pSync->db);
if (pDb == NULL) { if (pDb == NULL) {
mError("db:%s, failed to process sync db msg since %s", pMsg->db, terrstr()); mError("db:%s, failed to process sync db msg since %s", pSync->db, terrstr());
return -1; return -1;
} }
...@@ -841,9 +841,9 @@ static int32_t mndProcessSyncDbMsg(SMnodeMsg *pMsg) { ...@@ -841,9 +841,9 @@ static int32_t mndProcessSyncDbMsg(SMnodeMsg *pMsg) {
static int32_t mndProcessCompactDbMsg(SMnodeMsg *pMsg) { static int32_t mndProcessCompactDbMsg(SMnodeMsg *pMsg) {
SMnode *pMnode = pMsg->pMnode; SMnode *pMnode = pMsg->pMnode;
SCompactDbMsg *pCompact = pMsg->rpcMsg.pCont; SCompactDbMsg *pCompact = pMsg->rpcMsg.pCont;
SDbObj *pDb = mndAcquireDb(pMnode, pMsg->db); SDbObj *pDb = mndAcquireDb(pMnode, pCompact->db);
if (pDb == NULL) { if (pDb == NULL) {
mError("db:%s, failed to process compact db msg since %s", pMsg->db, terrstr()); mError("db:%s, failed to process compact db msg since %s", pCompact->db, terrstr());
return -1; return -1;
} }
...@@ -876,6 +876,12 @@ static int32_t mndGetDbMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pMe ...@@ -876,6 +876,12 @@ static int32_t mndGetDbMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pMe
pSchema[cols].bytes = htonl(pShow->bytes[cols]); pSchema[cols].bytes = htonl(pShow->bytes[cols]);
cols++; cols++;
pShow->bytes[cols] = 4;
pSchema[cols].type = TSDB_DATA_TYPE_INT;
strcpy(pSchema[cols].name, "ntables");
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
cols++;
pShow->bytes[cols] = 2; pShow->bytes[cols] = 2;
pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT; pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
strcpy(pSchema[cols].name, "replica"); strcpy(pSchema[cols].name, "replica");
...@@ -1017,6 +1023,10 @@ static int32_t mndRetrieveDbs(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int3 ...@@ -1017,6 +1023,10 @@ static int32_t mndRetrieveDbs(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int3
*(int16_t *)pWrite = pDb->cfg.numOfVgroups; *(int16_t *)pWrite = pDb->cfg.numOfVgroups;
cols++; cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
*(int16_t *)pWrite = 0; // todo
cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
*(int16_t *)pWrite = pDb->cfg.replications; *(int16_t *)pWrite = pDb->cfg.replications;
cols++; cols++;
......
...@@ -23,14 +23,15 @@ ...@@ -23,14 +23,15 @@
#define TSDB_MNODE_RESERVE_SIZE 64 #define TSDB_MNODE_RESERVE_SIZE 64
static int32_t mndCreateDefaultMnode(SMnode *pMnode); static int32_t mndCreateDefaultMnode(SMnode *pMnode);
static SSdbRaw *mndMnodeActionEncode(SMnodeObj *pMnodeObj); static SSdbRaw *mndMnodeActionEncode(SMnodeObj *pObj);
static SSdbRow *mndMnodeActionDecode(SSdbRaw *pRaw); static SSdbRow *mndMnodeActionDecode(SSdbRaw *pRaw);
static int32_t mndMnodeActionInsert(SSdb *pSdb, SMnodeObj *pMnodeObj); static int32_t mndMnodeActionInsert(SSdb *pSdb, SMnodeObj *pObj);
static int32_t mndMnodeActionDelete(SSdb *pSdb, SMnodeObj *pMnodeObj); static int32_t mndMnodeActionDelete(SSdb *pSdb, SMnodeObj *pObj);
static int32_t mndMnodeActionUpdate(SSdb *pSdb, SMnodeObj *pOldMnode, SMnodeObj *pNewMnode); static int32_t mndMnodeActionUpdate(SSdb *pSdb, SMnodeObj *pOldMnode, SMnodeObj *pNewMnode);
static int32_t mndProcessCreateMnodeMsg(SMnodeMsg *pMsg); static int32_t mndProcessCreateMnodeReq(SMnodeMsg *pMsg);
static int32_t mndProcessDropMnodeMsg(SMnodeMsg *pMsg); static int32_t mndProcessDropMnodeReq(SMnodeMsg *pMsg);
static int32_t mndProcessCreateMnodeRsp(SMnodeMsg *pMsg); static int32_t mndProcessCreateMnodeRsp(SMnodeMsg *pMsg);
static int32_t mndProcessAlterMnodeRsp(SMnodeMsg *pMsg);
static int32_t mndProcessDropMnodeRsp(SMnodeMsg *pMsg); static int32_t mndProcessDropMnodeRsp(SMnodeMsg *pMsg);
static int32_t mndGetMnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pMeta); static int32_t mndGetMnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pMeta);
static int32_t mndRetrieveMnodes(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int32_t rows); static int32_t mndRetrieveMnodes(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int32_t rows);
...@@ -46,9 +47,10 @@ int32_t mndInitMnode(SMnode *pMnode) { ...@@ -46,9 +47,10 @@ int32_t mndInitMnode(SMnode *pMnode) {
.updateFp = (SdbUpdateFp)mndMnodeActionUpdate, .updateFp = (SdbUpdateFp)mndMnodeActionUpdate,
.deleteFp = (SdbDeleteFp)mndMnodeActionDelete}; .deleteFp = (SdbDeleteFp)mndMnodeActionDelete};
mndSetMsgHandle(pMnode, TSDB_MSG_TYPE_CREATE_MNODE, mndProcessCreateMnodeMsg); mndSetMsgHandle(pMnode, TSDB_MSG_TYPE_CREATE_MNODE, mndProcessCreateMnodeReq);
mndSetMsgHandle(pMnode, TSDB_MSG_TYPE_DROP_MNODE, mndProcessDropMnodeMsg); mndSetMsgHandle(pMnode, TSDB_MSG_TYPE_DROP_MNODE, mndProcessDropMnodeReq);
mndSetMsgHandle(pMnode, TSDB_MSG_TYPE_CREATE_MNODE_IN_RSP, mndProcessCreateMnodeRsp); mndSetMsgHandle(pMnode, TSDB_MSG_TYPE_CREATE_MNODE_IN_RSP, mndProcessCreateMnodeRsp);
mndSetMsgHandle(pMnode, TSDB_MSG_TYPE_ALTER_MNODE_IN_RSP, mndProcessAlterMnodeRsp);
mndSetMsgHandle(pMnode, TSDB_MSG_TYPE_DROP_MNODE_IN_RSP, mndProcessDropMnodeRsp); mndSetMsgHandle(pMnode, TSDB_MSG_TYPE_DROP_MNODE_IN_RSP, mndProcessDropMnodeRsp);
mndAddShowMetaHandle(pMnode, TSDB_MGMT_TABLE_MNODE, mndGetMnodeMeta); mndAddShowMetaHandle(pMnode, TSDB_MGMT_TABLE_MNODE, mndGetMnodeMeta);
...@@ -69,9 +71,9 @@ static SMnodeObj *mndAcquireMnode(SMnode *pMnode, int32_t mnodeId) { ...@@ -69,9 +71,9 @@ static SMnodeObj *mndAcquireMnode(SMnode *pMnode, int32_t mnodeId) {
return pObj; return pObj;
} }
static void mndReleaseMnode(SMnode *pMnode, SMnodeObj *pMnodeObj) { static void mndReleaseMnode(SMnode *pMnode, SMnodeObj *pObj) {
SSdb *pSdb = pMnode->pSdb; SSdb *pSdb = pMnode->pSdb;
sdbRelease(pSdb, pMnodeObj); sdbRelease(pSdb, pObj);
} }
char *mndGetRoleStr(int32_t showType) { char *mndGetRoleStr(int32_t showType) {
...@@ -87,6 +89,24 @@ char *mndGetRoleStr(int32_t showType) { ...@@ -87,6 +89,24 @@ char *mndGetRoleStr(int32_t showType) {
} }
} }
void mndUpdateMnodeRole(SMnode *pMnode) {
SSdb *pSdb = pMnode->pSdb;
void *pIter = NULL;
while (1) {
SMnodeObj *pObj = NULL;
pIter = sdbFetch(pSdb, SDB_MNODE, pIter, (void **)&pObj);
if (pIter == NULL) break;
if (pObj->id == 1) {
pObj->role = TAOS_SYNC_STATE_LEADER;
} else {
pObj->role = TAOS_SYNC_STATE_CANDIDATE;
}
sdbRelease(pSdb, pObj);
}
}
static int32_t mndCreateDefaultMnode(SMnode *pMnode) { static int32_t mndCreateDefaultMnode(SMnode *pMnode) {
SMnodeObj mnodeObj = {0}; SMnodeObj mnodeObj = {0};
mnodeObj.id = 1; mnodeObj.id = 1;
...@@ -101,14 +121,14 @@ static int32_t mndCreateDefaultMnode(SMnode *pMnode) { ...@@ -101,14 +121,14 @@ static int32_t mndCreateDefaultMnode(SMnode *pMnode) {
return sdbWrite(pMnode->pSdb, pRaw); return sdbWrite(pMnode->pSdb, pRaw);
} }
static SSdbRaw *mndMnodeActionEncode(SMnodeObj *pMnodeObj) { static SSdbRaw *mndMnodeActionEncode(SMnodeObj *pObj) {
SSdbRaw *pRaw = sdbAllocRaw(SDB_MNODE, TSDB_MNODE_VER_NUMBER, sizeof(SMnodeObj) + TSDB_MNODE_RESERVE_SIZE); SSdbRaw *pRaw = sdbAllocRaw(SDB_MNODE, TSDB_MNODE_VER_NUMBER, sizeof(SMnodeObj) + TSDB_MNODE_RESERVE_SIZE);
if (pRaw == NULL) return NULL; if (pRaw == NULL) return NULL;
int32_t dataPos = 0; int32_t dataPos = 0;
SDB_SET_INT32(pRaw, dataPos, pMnodeObj->id); SDB_SET_INT32(pRaw, dataPos, pObj->id);
SDB_SET_INT64(pRaw, dataPos, pMnodeObj->createdTime) SDB_SET_INT64(pRaw, dataPos, pObj->createdTime)
SDB_SET_INT64(pRaw, dataPos, pMnodeObj->updateTime) SDB_SET_INT64(pRaw, dataPos, pObj->updateTime)
SDB_SET_RESERVE(pRaw, dataPos, TSDB_MNODE_RESERVE_SIZE) SDB_SET_RESERVE(pRaw, dataPos, TSDB_MNODE_RESERVE_SIZE)
return pRaw; return pRaw;
...@@ -125,42 +145,38 @@ static SSdbRow *mndMnodeActionDecode(SSdbRaw *pRaw) { ...@@ -125,42 +145,38 @@ static SSdbRow *mndMnodeActionDecode(SSdbRaw *pRaw) {
} }
SSdbRow *pRow = sdbAllocRow(sizeof(SMnodeObj)); SSdbRow *pRow = sdbAllocRow(sizeof(SMnodeObj));
SMnodeObj *pMnodeObj = sdbGetRowObj(pRow); SMnodeObj *pObj = sdbGetRowObj(pRow);
if (pMnodeObj == NULL) return NULL; if (pObj == NULL) return NULL;
int32_t dataPos = 0; int32_t dataPos = 0;
SDB_GET_INT32(pRaw, pRow, dataPos, &pMnodeObj->id) SDB_GET_INT32(pRaw, pRow, dataPos, &pObj->id)
SDB_GET_INT64(pRaw, pRow, dataPos, &pMnodeObj->createdTime) SDB_GET_INT64(pRaw, pRow, dataPos, &pObj->createdTime)
SDB_GET_INT64(pRaw, pRow, dataPos, &pMnodeObj->updateTime) SDB_GET_INT64(pRaw, pRow, dataPos, &pObj->updateTime)
SDB_GET_RESERVE(pRaw, pRow, dataPos, TSDB_MNODE_RESERVE_SIZE) SDB_GET_RESERVE(pRaw, pRow, dataPos, TSDB_MNODE_RESERVE_SIZE)
return pRow; return pRow;
} }
static void mnodeResetMnode(SMnodeObj *pMnodeObj) { static void mnodeResetMnode(SMnodeObj *pObj) { pObj->role = TAOS_SYNC_STATE_FOLLOWER; }
pMnodeObj->role = TAOS_SYNC_STATE_FOLLOWER;
pMnodeObj->roleTerm = 0;
pMnodeObj->roleTime = 0;
}
static int32_t mndMnodeActionInsert(SSdb *pSdb, SMnodeObj *pMnodeObj) { static int32_t mndMnodeActionInsert(SSdb *pSdb, SMnodeObj *pObj) {
mTrace("mnode:%d, perform insert action", pMnodeObj->id); mTrace("mnode:%d, perform insert action", pObj->id);
pMnodeObj->pDnode = sdbAcquire(pSdb, SDB_DNODE, &pMnodeObj->id); pObj->pDnode = sdbAcquire(pSdb, SDB_DNODE, &pObj->id);
if (pMnodeObj->pDnode == NULL) { if (pObj->pDnode == NULL) {
terrno = TSDB_CODE_MND_DNODE_NOT_EXIST; terrno = TSDB_CODE_MND_DNODE_NOT_EXIST;
mError("mnode:%d, failed to perform insert action since %s", pMnodeObj->id, terrstr()); mError("mnode:%d, failed to perform insert action since %s", pObj->id, terrstr());
return -1; return -1;
} }
mnodeResetMnode(pMnodeObj); mnodeResetMnode(pObj);
return 0; return 0;
} }
static int32_t mndMnodeActionDelete(SSdb *pSdb, SMnodeObj *pMnodeObj) { static int32_t mndMnodeActionDelete(SSdb *pSdb, SMnodeObj *pObj) {
mTrace("mnode:%d, perform delete action", pMnodeObj->id); mTrace("mnode:%d, perform delete action", pObj->id);
if (pMnodeObj->pDnode != NULL) { if (pObj->pDnode != NULL) {
sdbRelease(pSdb, pMnodeObj->pDnode); sdbRelease(pSdb, pObj->pDnode);
pMnodeObj->pDnode = NULL; pObj->pDnode = NULL;
} }
return 0; return 0;
...@@ -168,8 +184,6 @@ static int32_t mndMnodeActionDelete(SSdb *pSdb, SMnodeObj *pMnodeObj) { ...@@ -168,8 +184,6 @@ static int32_t mndMnodeActionDelete(SSdb *pSdb, SMnodeObj *pMnodeObj) {
static int32_t mndMnodeActionUpdate(SSdb *pSdb, SMnodeObj *pOldMnode, SMnodeObj *pNewMnode) { static int32_t mndMnodeActionUpdate(SSdb *pSdb, SMnodeObj *pOldMnode, SMnodeObj *pNewMnode) {
mTrace("mnode:%d, perform update action", pOldMnode->id); mTrace("mnode:%d, perform update action", pOldMnode->id);
pOldMnode->id = pNewMnode->id;
pOldMnode->createdTime = pNewMnode->createdTime;
pOldMnode->updateTime = pNewMnode->updateTime; pOldMnode->updateTime = pNewMnode->updateTime;
return 0; return 0;
} }
...@@ -177,12 +191,12 @@ static int32_t mndMnodeActionUpdate(SSdb *pSdb, SMnodeObj *pOldMnode, SMnodeObj ...@@ -177,12 +191,12 @@ static int32_t mndMnodeActionUpdate(SSdb *pSdb, SMnodeObj *pOldMnode, SMnodeObj
bool mndIsMnode(SMnode *pMnode, int32_t dnodeId) { bool mndIsMnode(SMnode *pMnode, int32_t dnodeId) {
SSdb *pSdb = pMnode->pSdb; SSdb *pSdb = pMnode->pSdb;
SMnodeObj *pMnodeObj = sdbAcquire(pSdb, SDB_MNODE, &dnodeId); SMnodeObj *pObj = sdbAcquire(pSdb, SDB_MNODE, &dnodeId);
if (pMnodeObj == NULL) { if (pObj == NULL) {
return false; return false;
} }
sdbRelease(pSdb, pMnodeObj); sdbRelease(pSdb, pObj);
return true; return true;
} }
...@@ -193,14 +207,14 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) { ...@@ -193,14 +207,14 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
void *pIter = NULL; void *pIter = NULL;
while (1) { while (1) {
SMnodeObj *pMnodeObj = NULL; SMnodeObj *pObj = NULL;
pIter = sdbFetch(pSdb, SDB_MNODE, pIter, (void **)&pMnodeObj); pIter = sdbFetch(pSdb, SDB_MNODE, pIter, (void **)&pObj);
if (pIter == NULL) break; if (pIter == NULL) break;
if (pMnodeObj->pDnode == NULL) break; if (pObj->pDnode == NULL) break;
pEpSet->port[pEpSet->numOfEps] = htons(pMnodeObj->pDnode->port); pEpSet->port[pEpSet->numOfEps] = htons(pObj->pDnode->port);
tstrncpy(pEpSet->fqdn[pEpSet->numOfEps], pMnodeObj->pDnode->fqdn, TSDB_FQDN_LEN); memcpy(pEpSet->fqdn[pEpSet->numOfEps], pObj->pDnode->fqdn, TSDB_FQDN_LEN);
if (pMnodeObj->role == TAOS_SYNC_STATE_LEADER) { if (pObj->role == TAOS_SYNC_STATE_LEADER) {
pEpSet->inUse = pEpSet->numOfEps; pEpSet->inUse = pEpSet->numOfEps;
} }
...@@ -208,54 +222,153 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) { ...@@ -208,54 +222,153 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
} }
} }
static int32_t mndCreateMnode(SMnode *pMnode, SMnodeMsg *pMsg, SCreateMnodeMsg *pCreate) { static int32_t mndSetCreateMnodeRedoLogs(SMnode *pMnode, STrans *pTrans, SMnodeObj *pObj) {
SSdbRaw *pRedoRaw = mndMnodeActionEncode(pObj);
if (pRedoRaw == NULL) return -1;
if (mndTransAppendRedolog(pTrans, pRedoRaw) != 0) return -1;
if (sdbSetRawStatus(pRedoRaw, SDB_STATUS_CREATING) != 0) return -1;
return 0;
}
static int32_t mndSetCreateMnodeUndoLogs(SMnode *pMnode, STrans *pTrans, SMnodeObj *pObj) {
SSdbRaw *pUndoRaw = mndMnodeActionEncode(pObj);
if (pUndoRaw == NULL) return -1;
if (mndTransAppendUndolog(pTrans, pUndoRaw) != 0) return -1;
if (sdbSetRawStatus(pUndoRaw, SDB_STATUS_DROPPED) != 0) return -1;
return 0;
}
static int32_t mndSetCreateMnodeCommitLogs(SMnode *pMnode, STrans *pTrans, SMnodeObj *pObj) {
SSdbRaw *pCommitRaw = mndMnodeActionEncode(pObj);
if (pCommitRaw == NULL) return -1;
if (mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) return -1;
if (sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY) != 0) return -1;
return 0;
}
static int32_t mndSetCreateMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnodeObj *pDnode, SMnodeObj *pObj) {
SSdb *pSdb = pMnode->pSdb;
void *pIter = NULL;
int32_t numOfReplicas = 0;
SCreateMnodeInMsg createMsg = {0};
while (1) {
SMnodeObj *pMObj = NULL;
pIter = sdbFetch(pSdb, SDB_MNODE, pIter, (void **)&pMObj);
if (pIter == NULL) break;
SReplica *pReplica = &createMsg.replicas[numOfReplicas];
pReplica->id = htonl(pMObj->id);
pReplica->port = htons(pMObj->pDnode->port);
memcpy(pReplica->fqdn, pMObj->pDnode->fqdn, TSDB_FQDN_LEN);
numOfReplicas++;
sdbRelease(pSdb, pMObj);
}
SReplica *pReplica = &createMsg.replicas[numOfReplicas];
pReplica->id = htonl(pDnode->id);
pReplica->port = htons(pDnode->port);
memcpy(pReplica->fqdn, pDnode->fqdn, TSDB_FQDN_LEN);
numOfReplicas++;
createMsg.replica = numOfReplicas;
while (1) {
SMnodeObj *pMObj = NULL;
pIter = sdbFetch(pSdb, SDB_MNODE, pIter, (void **)&pMObj);
if (pIter == NULL) break;
STransAction action = {0};
SAlterMnodeInMsg *pMsg = malloc(sizeof(SAlterMnodeInMsg));
if (pMsg == NULL) {
sdbCancelFetch(pSdb, pIter);
sdbRelease(pSdb, pMObj);
return -1;
}
memcpy(pMsg, &createMsg, sizeof(SAlterMnodeInMsg));
pMsg->dnodeId = htonl(pMObj->id);
action.epSet = mndGetDnodeEpset(pMObj->pDnode);
action.pCont = pMsg;
action.contLen = sizeof(SAlterMnodeInMsg);
action.msgType = TSDB_MSG_TYPE_ALTER_MNODE_IN;
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
free(pMsg);
sdbCancelFetch(pSdb, pIter);
sdbRelease(pSdb, pMObj);
return -1;
}
sdbRelease(pSdb, pMObj);
}
{
STransAction action = {0};
action.epSet = mndGetDnodeEpset(pDnode);
SCreateMnodeInMsg *pMsg = malloc(sizeof(SCreateMnodeInMsg));
if (pMsg == NULL) return -1;
memcpy(pMsg, &createMsg, sizeof(SAlterMnodeInMsg));
pMsg->dnodeId = htonl(pObj->id);
action.epSet = mndGetDnodeEpset(pDnode);
action.pCont = pMsg;
action.contLen = sizeof(SCreateMnodeInMsg);
action.msgType = TSDB_MSG_TYPE_CREATE_MNODE_IN;
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
free(pMsg);
return -1;
}
}
return 0;
}
static int32_t mndCreateMnode(SMnode *pMnode, SMnodeMsg *pMsg, SDnodeObj *pDnode, SCreateMnodeMsg *pCreate) {
SMnodeObj mnodeObj = {0}; SMnodeObj mnodeObj = {0};
mnodeObj.id = 1; // todo mnodeObj.id = sdbGetMaxId(pMnode->pSdb, SDB_MNODE);
mnodeObj.createdTime = taosGetTimestampMs(); mnodeObj.createdTime = taosGetTimestampMs();
mnodeObj.updateTime = mnodeObj.createdTime; mnodeObj.updateTime = mnodeObj.createdTime;
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, pMsg->rpcMsg.handle); int32_t code = -1;
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, pMsg->rpcMsg.handle);
if (pTrans == NULL) { if (pTrans == NULL) {
mError("dnode:%d, failed to create since %s", pCreate->dnodeId, terrstr()); mError("mnode:%d, failed to create since %s", pCreate->dnodeId, terrstr());
return -1; goto CREATE_MNODE_OVER;
} }
mDebug("trans:%d, used to create dnode:%d", pTrans->id, pCreate->dnodeId); mDebug("trans:%d, used to create mnode:%d", pTrans->id, pCreate->dnodeId);
SSdbRaw *pRedoRaw = mndMnodeActionEncode(&mnodeObj); if (mndSetCreateMnodeRedoLogs(pMnode, pTrans, &mnodeObj) != 0) {
if (pRedoRaw == NULL || mndTransAppendRedolog(pTrans, pRedoRaw) != 0) { mError("trans:%d, failed to set redo log since %s", pTrans->id, terrstr());
mError("trans:%d, failed to append redo log since %s", pTrans->id, terrstr()); goto CREATE_MNODE_OVER;
mndTransDrop(pTrans);
return -1;
} }
sdbSetRawStatus(pRedoRaw, SDB_STATUS_CREATING);
SSdbRaw *pUndoRaw = mndMnodeActionEncode(&mnodeObj); if (mndSetCreateMnodeCommitLogs(pMnode, pTrans, &mnodeObj) != 0) {
if (pUndoRaw == NULL || mndTransAppendUndolog(pTrans, pUndoRaw) != 0) { mError("trans:%d, failed to set commit log since %s", pTrans->id, terrstr());
mError("trans:%d, failed to append undo log since %s", pTrans->id, terrstr()); goto CREATE_MNODE_OVER;
mndTransDrop(pTrans);
return -1;
} }
sdbSetRawStatus(pUndoRaw, SDB_STATUS_DROPPED);
SSdbRaw *pCommitRaw = mndMnodeActionEncode(&mnodeObj); if (mndSetCreateMnodeRedoActions(pMnode, pTrans, pDnode, &mnodeObj) != 0) {
if (pCommitRaw == NULL || mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) { mError("trans:%d, failed to set redo actions since %s", pTrans->id, terrstr());
mError("trans:%d, failed to append commit log since %s", pTrans->id, terrstr()); goto CREATE_MNODE_OVER;
mndTransDrop(pTrans);
return -1;
} }
sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
if (mndTransPrepare(pMnode, pTrans) != 0) { if (mndTransPrepare(pMnode, pTrans) != 0) {
mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr()); mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr());
mndTransDrop(pTrans); goto CREATE_MNODE_OVER;
return -1;
} }
code = 0;
CREATE_MNODE_OVER:
mndTransDrop(pTrans); mndTransDrop(pTrans);
return 0; return code;
} }
static int32_t mndProcessCreateMnodeMsg(SMnodeMsg *pMsg) { static int32_t mndProcessCreateMnodeReq(SMnodeMsg *pMsg) {
SMnode *pMnode = pMsg->pMnode; SMnode *pMnode = pMsg->pMnode;
SCreateMnodeMsg *pCreate = pMsg->rpcMsg.pCont; SCreateMnodeMsg *pCreate = pMsg->rpcMsg.pCont;
...@@ -263,22 +376,23 @@ static int32_t mndProcessCreateMnodeMsg(SMnodeMsg *pMsg) { ...@@ -263,22 +376,23 @@ static int32_t mndProcessCreateMnodeMsg(SMnodeMsg *pMsg) {
mDebug("mnode:%d, start to create", pCreate->dnodeId); mDebug("mnode:%d, start to create", pCreate->dnodeId);
SDnodeObj *pDnode = mndAcquireDnode(pMnode, pCreate->dnodeId); SMnodeObj *pObj = mndAcquireMnode(pMnode, pCreate->dnodeId);
if (pDnode == NULL) { if (pObj != NULL) {
mError("mnode:%d, dnode not exist", pDnode->id); mndReleaseMnode(pMnode, pObj);
terrno = TSDB_CODE_MND_DNODE_NOT_EXIST; mError("mnode:%d, mnode already exist", pObj->id);
terrno = TSDB_CODE_MND_MNODE_ALREADY_EXIST;
return -1; return -1;
} }
mndReleaseDnode(pMnode, pDnode);
SMnodeObj *pMnodeObj = mndAcquireMnode(pMnode, pCreate->dnodeId); SDnodeObj *pDnode = mndAcquireDnode(pMnode, pCreate->dnodeId);
if (pMnodeObj != NULL) { if (pDnode == NULL) {
mError("mnode:%d, mnode already exist", pMnodeObj->id); mError("mnode:%d, dnode not exist", pCreate->dnodeId);
terrno = TSDB_CODE_MND_MNODE_ALREADY_EXIST; terrno = TSDB_CODE_MND_DNODE_NOT_EXIST;
return -1; return -1;
} }
int32_t code = mndCreateMnode(pMnode, pMsg, pCreate); int32_t code = mndCreateMnode(pMnode, pMsg, pDnode, pCreate);
mndReleaseDnode(pMnode, pDnode);
if (code != 0) { if (code != 0) {
mError("mnode:%d, failed to create since %s", pCreate->dnodeId, terrstr()); mError("mnode:%d, failed to create since %s", pCreate->dnodeId, terrstr());
...@@ -288,49 +402,140 @@ static int32_t mndProcessCreateMnodeMsg(SMnodeMsg *pMsg) { ...@@ -288,49 +402,140 @@ static int32_t mndProcessCreateMnodeMsg(SMnodeMsg *pMsg) {
return TSDB_CODE_MND_ACTION_IN_PROGRESS; return TSDB_CODE_MND_ACTION_IN_PROGRESS;
} }
static int32_t mndDropMnode(SMnode *pMnode, SMnodeMsg *pMsg, SMnodeObj *pMnodeObj) { static int32_t mndSetDropMnodeRedoLogs(SMnode *pMnode, STrans *pTrans, SMnodeObj *pObj) {
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, pMsg->rpcMsg.handle); SSdbRaw *pRedoRaw = mndMnodeActionEncode(pObj);
if (pTrans == NULL) { if (pRedoRaw == NULL) return -1;
mError("mnode:%d, failed to drop since %s", pMnodeObj->id, terrstr()); if (mndTransAppendRedolog(pTrans, pRedoRaw) != 0) return -1;
return -1; if (sdbSetRawStatus(pRedoRaw, SDB_STATUS_DROPPING) != 0) return -1;
return 0;
}
static int32_t mndSetDropMnodeCommitLogs(SMnode *pMnode, STrans *pTrans, SMnodeObj *pObj) {
SSdbRaw *pCommitRaw = mndMnodeActionEncode(pObj);
if (pCommitRaw == NULL) return -1;
if (mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) return -1;
if (sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED) != 0) return -1;
return 0;
}
static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnodeObj *pDnode, SMnodeObj *pObj) {
SSdb *pSdb = pMnode->pSdb;
void *pIter = NULL;
int32_t numOfReplicas = 0;
SAlterMnodeInMsg alterMsg = {0};
while (1) {
SMnodeObj *pMObj = NULL;
pIter = sdbFetch(pSdb, SDB_MNODE, pIter, (void **)&pMObj);
if (pIter == NULL) break;
if (pMObj->id != pObj->id) {
SReplica *pReplica = &alterMsg.replicas[numOfReplicas];
pReplica->id = htonl(pMObj->id);
pReplica->port = htons(pMObj->pDnode->port);
memcpy(pReplica->fqdn, pMObj->pDnode->fqdn, TSDB_FQDN_LEN);
numOfReplicas++;
} }
mDebug("trans:%d, used to drop user:%d", pTrans->id, pMnodeObj->id);
SSdbRaw *pRedoRaw = mndMnodeActionEncode(pMnodeObj); sdbRelease(pSdb, pMObj);
if (pRedoRaw == NULL || mndTransAppendRedolog(pTrans, pRedoRaw) != 0) { }
mError("trans:%d, failed to append redo log since %s", pTrans->id, terrstr());
mndTransDrop(pTrans); alterMsg.replica = numOfReplicas;
while (1) {
SMnodeObj *pMObj = NULL;
pIter = sdbFetch(pSdb, SDB_MNODE, pIter, (void **)&pMObj);
if (pIter == NULL) break;
if (pMObj->id != pObj->id) {
STransAction action = {0};
SAlterMnodeInMsg *pMsg = malloc(sizeof(SAlterMnodeInMsg));
if (pMsg == NULL) {
sdbCancelFetch(pSdb, pIter);
sdbRelease(pSdb, pMObj);
return -1; return -1;
} }
sdbSetRawStatus(pRedoRaw, SDB_STATUS_DROPPING); memcpy(pMsg, &alterMsg, sizeof(SAlterMnodeInMsg));
SSdbRaw *pUndoRaw = mndMnodeActionEncode(pMnodeObj); pMsg->dnodeId = htonl(pMObj->id);
if (pUndoRaw == NULL || mndTransAppendUndolog(pTrans, pUndoRaw) != 0) { action.epSet = mndGetDnodeEpset(pMObj->pDnode);
mError("trans:%d, failed to append undo log since %s", pTrans->id, terrstr()); action.pCont = pMsg;
mndTransDrop(pTrans); action.contLen = sizeof(SAlterMnodeInMsg);
action.msgType = TSDB_MSG_TYPE_ALTER_MNODE_IN;
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
free(pMsg);
sdbCancelFetch(pSdb, pIter);
sdbRelease(pSdb, pMObj);
return -1; return -1;
} }
sdbSetRawStatus(pUndoRaw, SDB_STATUS_READY); }
SSdbRaw *pCommitRaw = mndMnodeActionEncode(pMnodeObj); sdbRelease(pSdb, pMObj);
if (pCommitRaw == NULL || mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) { }
mError("trans:%d, failed to append commit log since %s", pTrans->id, terrstr());
mndTransDrop(pTrans); {
STransAction action = {0};
action.epSet = mndGetDnodeEpset(pDnode);
SDropMnodeInMsg *pMsg = malloc(sizeof(SDropMnodeInMsg));
if (pMsg == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1; return -1;
} }
sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED); pMsg->dnodeId = htonl(pObj->id);
action.epSet = mndGetDnodeEpset(pDnode);
action.pCont = pMsg;
action.contLen = sizeof(SDropMnodeInMsg);
action.msgType = TSDB_MSG_TYPE_DROP_MNODE_IN;
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
free(pMsg);
return -1;
}
}
return 0;
}
static int32_t mndDropMnode(SMnode *pMnode, SMnodeMsg *pMsg, SMnodeObj *pObj) {
int32_t code = -1;
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, pMsg->rpcMsg.handle);
if (pTrans == NULL) {
mError("mnode:%d, failed to drop since %s", pObj->id, terrstr());
goto DROP_MNODE_OVER;
}
mDebug("trans:%d, used to drop mnode:%d", pTrans->id, pObj->id);
if (mndSetDropMnodeRedoLogs(pMnode, pTrans, pObj) != 0) {
mError("trans:%d, failed to set redo log since %s", pTrans->id, terrstr());
goto DROP_MNODE_OVER;
}
if (mndSetDropMnodeCommitLogs(pMnode, pTrans, pObj) != 0) {
mError("trans:%d, failed to set commit log since %s", pTrans->id, terrstr());
goto DROP_MNODE_OVER;
}
if (mndSetDropMnodeRedoActions(pMnode, pTrans, pObj->pDnode, pObj) != 0) {
mError("trans:%d, failed to set redo actions since %s", pTrans->id, terrstr());
goto DROP_MNODE_OVER;
}
if (mndTransPrepare(pMnode, pTrans) != 0) { if (mndTransPrepare(pMnode, pTrans) != 0) {
mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr()); mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr());
mndTransDrop(pTrans); goto DROP_MNODE_OVER;
return -1;
} }
code = 0;
DROP_MNODE_OVER:
mndTransDrop(pTrans); mndTransDrop(pTrans);
return 0; return code;
} }
static int32_t mndProcessDropMnodeMsg(SMnodeMsg *pMsg) { static int32_t mndProcessDropMnodeReq(SMnodeMsg *pMsg) {
SMnode *pMnode = pMsg->pMnode; SMnode *pMnode = pMsg->pMnode;
SDropMnodeMsg *pDrop = pMsg->rpcMsg.pCont; SDropMnodeMsg *pDrop = pMsg->rpcMsg.pCont;
pDrop->dnodeId = htonl(pDrop->dnodeId); pDrop->dnodeId = htonl(pDrop->dnodeId);
...@@ -343,14 +548,14 @@ static int32_t mndProcessDropMnodeMsg(SMnodeMsg *pMsg) { ...@@ -343,14 +548,14 @@ static int32_t mndProcessDropMnodeMsg(SMnodeMsg *pMsg) {
return -1; return -1;
} }
SMnodeObj *pMnodeObj = mndAcquireMnode(pMnode, pDrop->dnodeId); SMnodeObj *pObj = mndAcquireMnode(pMnode, pDrop->dnodeId);
if (pMnodeObj == NULL) { if (pObj == NULL) {
mError("mnode:%d, not exist", pDrop->dnodeId); mError("mnode:%d, not exist", pDrop->dnodeId);
terrno = TSDB_CODE_MND_DNODE_NOT_EXIST; terrno = TSDB_CODE_MND_DNODE_NOT_EXIST;
return -1; return -1;
} }
int32_t code = mndDropMnode(pMnode, pMsg, pMnodeObj); int32_t code = mndDropMnode(pMnode, pMsg, pObj);
if (code != 0) { if (code != 0) {
mError("mnode:%d, failed to drop since %s", pMnode->dnodeId, terrstr()); mError("mnode:%d, failed to drop since %s", pMnode->dnodeId, terrstr());
...@@ -361,9 +566,20 @@ static int32_t mndProcessDropMnodeMsg(SMnodeMsg *pMsg) { ...@@ -361,9 +566,20 @@ static int32_t mndProcessDropMnodeMsg(SMnodeMsg *pMsg) {
return TSDB_CODE_MND_ACTION_IN_PROGRESS; return TSDB_CODE_MND_ACTION_IN_PROGRESS;
} }
static int32_t mndProcessCreateMnodeRsp(SMnodeMsg *pMsg) { return 0; } static int32_t mndProcessCreateMnodeRsp(SMnodeMsg *pMsg) {
mndTransHandleActionRsp(pMsg);
return 0;
}
static int32_t mndProcessDropMnodeRsp(SMnodeMsg *pMsg) { return 0; } static int32_t mndProcessAlterMnodeRsp(SMnodeMsg *pMsg) {
mndTransHandleActionRsp(pMsg);
return 0;
}
static int32_t mndProcessDropMnodeRsp(SMnodeMsg *pMsg) {
mndTransHandleActionRsp(pMsg);
return 0;
}
static int32_t mndGetMnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pMeta) { static int32_t mndGetMnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pMeta) {
SMnode *pMnode = pMsg->pMnode; SMnode *pMnode = pMsg->pMnode;
...@@ -414,6 +630,7 @@ static int32_t mndGetMnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg * ...@@ -414,6 +630,7 @@ static int32_t mndGetMnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *
pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1]; pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
strcpy(pMeta->tbFname, mndShowStr(pShow->type)); strcpy(pMeta->tbFname, mndShowStr(pShow->type));
mndUpdateMnodeRole(pMnode);
return 0; return 0;
} }
...@@ -422,46 +639,39 @@ static int32_t mndRetrieveMnodes(SMnodeMsg *pMsg, SShowObj *pShow, char *data, i ...@@ -422,46 +639,39 @@ static int32_t mndRetrieveMnodes(SMnodeMsg *pMsg, SShowObj *pShow, char *data, i
SSdb *pSdb = pMnode->pSdb; SSdb *pSdb = pMnode->pSdb;
int32_t numOfRows = 0; int32_t numOfRows = 0;
int32_t cols = 0; int32_t cols = 0;
SMnodeObj *pMnodeObj = NULL; SMnodeObj *pObj = NULL;
char *pWrite; char *pWrite;
while (numOfRows < rows) { while (numOfRows < rows) {
pShow->pIter = sdbFetch(pSdb, SDB_MNODE, pShow->pIter, (void **)&pMnodeObj); pShow->pIter = sdbFetch(pSdb, SDB_MNODE, pShow->pIter, (void **)&pObj);
if (pShow->pIter == NULL) break; if (pShow->pIter == NULL) break;
cols = 0; cols = 0;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
*(int16_t *)pWrite = pMnodeObj->id; *(int16_t *)pWrite = pObj->id;
cols++; cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pObj->pDnode->ep, pShow->bytes[cols]);
SDnodeObj *pDnode = mndAcquireDnode(pMnode, pMnodeObj->id);
if (pDnode != NULL) {
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pDnode->ep, pShow->bytes[cols]);
} else {
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, "invalid ep", pShow->bytes[cols]);
}
mndReleaseDnode(pMnode, pDnode);
cols++; cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
char *roles = mndGetRoleStr(pMnodeObj->role); char *roles = mndGetRoleStr(pObj->role);
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, roles, pShow->bytes[cols]); STR_WITH_MAXSIZE_TO_VARSTR(pWrite, roles, pShow->bytes[cols]);
cols++; cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
*(int64_t *)pWrite = pMnodeObj->roleTime; *(int64_t *)pWrite = pObj->roleTime;
cols++; cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
*(int64_t *)pWrite = pMnodeObj->createdTime; *(int64_t *)pWrite = pObj->createdTime;
cols++; cols++;
numOfRows++; numOfRows++;
sdbRelease(pSdb, pMnodeObj); sdbRelease(pSdb, pObj);
} }
mndVacuumResult(data, pShow->numOfColumns, numOfRows, rows, pShow); mndVacuumResult(data, pShow->numOfColumns, numOfRows, rows, pShow);
......
...@@ -492,7 +492,6 @@ static int32_t mndProcessCreateStbMsg(SMnodeMsg *pMsg) { ...@@ -492,7 +492,6 @@ static int32_t mndProcessCreateStbMsg(SMnodeMsg *pMsg) {
mError("stb:%s, failed to create since %s", pCreate->name, terrstr()); mError("stb:%s, failed to create since %s", pCreate->name, terrstr());
return -1; return -1;
} }
sdbRelease(pMnode->pSdb, pTopic);
SDbObj *pDb = mndAcquireDbByStb(pMnode, pCreate->name); SDbObj *pDb = mndAcquireDbByStb(pMnode, pCreate->name);
if (pDb == NULL) { if (pDb == NULL) {
......
...@@ -33,4 +33,7 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw) { ...@@ -33,4 +33,7 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw) {
return code; return code;
} }
bool mndIsMaster(SMnode *pMnode) { return true; } bool mndIsMaster(SMnode *pMnode) {
\ No newline at end of file // pMnode->role = TAOS_SYNC_STATE_LEADER;
return true;
}
\ No newline at end of file
...@@ -444,7 +444,6 @@ static int32_t mndProcessCreateTopicMsg(SMnodeMsg *pMsg) { ...@@ -444,7 +444,6 @@ static int32_t mndProcessCreateTopicMsg(SMnodeMsg *pMsg) {
mError("topic:%s, failed to create since %s", pCreate->name, terrstr()); mError("topic:%s, failed to create since %s", pCreate->name, terrstr());
return -1; return -1;
} }
sdbRelease(pMnode->pSdb, pStb);
SDbObj *pDb = mndAcquireDbByTopic(pMnode, pCreate->name); SDbObj *pDb = mndAcquireDbByTopic(pMnode, pCreate->name);
if (pDb == NULL) { if (pDb == NULL) {
...@@ -647,6 +646,7 @@ static int32_t mndProcessTopicMetaMsg(SMnodeMsg *pMsg) { ...@@ -647,6 +646,7 @@ static int32_t mndProcessTopicMetaMsg(SMnodeMsg *pMsg) {
mDebug("topic:%s, start to retrieve meta", pInfo->tableFname); mDebug("topic:%s, start to retrieve meta", pInfo->tableFname);
#if 0
SDbObj *pDb = mndAcquireDbByTopic(pMnode, pInfo->tableFname); SDbObj *pDb = mndAcquireDbByTopic(pMnode, pInfo->tableFname);
if (pDb == NULL) { if (pDb == NULL) {
terrno = TSDB_CODE_MND_DB_NOT_SELECTED; terrno = TSDB_CODE_MND_DB_NOT_SELECTED;
...@@ -661,7 +661,6 @@ static int32_t mndProcessTopicMetaMsg(SMnodeMsg *pMsg) { ...@@ -661,7 +661,6 @@ static int32_t mndProcessTopicMetaMsg(SMnodeMsg *pMsg) {
mError("topic:%s, failed to get meta since %s", pInfo->tableFname, terrstr()); mError("topic:%s, failed to get meta since %s", pInfo->tableFname, terrstr());
return -1; return -1;
} }
#if 0
taosRLockLatch(&pTopic->lock); taosRLockLatch(&pTopic->lock);
int32_t totalCols = pTopic->numOfColumns + pTopic->numOfTags; int32_t totalCols = pTopic->numOfColumns + pTopic->numOfTags;
......
...@@ -622,10 +622,10 @@ void mndTransHandleActionRsp(SMnodeMsg *pMsg) { ...@@ -622,10 +622,10 @@ void mndTransHandleActionRsp(SMnodeMsg *pMsg) {
STransAction *pAction = taosArrayGet(pArray, action); STransAction *pAction = taosArrayGet(pArray, action);
if (pAction != NULL) { if (pAction != NULL) {
pAction->msgReceived = 1; pAction->msgReceived = 1;
pAction->errCode = pMsg->code; pAction->errCode = pMsg->rpcMsg.code;
} }
mDebug("trans:%d, action:%d response is received, code:0x%x", transId, action, pMsg->code); mDebug("trans:%d, action:%d response is received, code:0x%x", transId, action, pMsg->rpcMsg.code);
mndTransExecute(pMnode, pTrans); mndTransExecute(pMnode, pTrans);
HANDLE_ACTION_RSP_OVER: HANDLE_ACTION_RSP_OVER:
...@@ -696,7 +696,7 @@ static int32_t mndTransExecuteActions(SMnode *pMnode, STrans *pTrans, SArray *pA ...@@ -696,7 +696,7 @@ static int32_t mndTransExecuteActions(SMnode *pMnode, STrans *pTrans, SArray *pA
for (int32_t action = 0; action < numOfActions; ++action) { for (int32_t action = 0; action < numOfActions; ++action) {
STransAction *pAction = taosArrayGet(pArray, action); STransAction *pAction = taosArrayGet(pArray, action);
if (pAction == NULL) continue; if (pAction == NULL) continue;
if (pAction->msgSent) continue; if (pAction->msgReceived && pAction->errCode == 0) continue;
int64_t signature = pTrans->id; int64_t signature = pTrans->id;
signature = (signature << 32); signature = (signature << 32);
...@@ -736,6 +736,7 @@ static int32_t mndTransExecuteActions(SMnode *pMnode, STrans *pTrans, SArray *pA ...@@ -736,6 +736,7 @@ static int32_t mndTransExecuteActions(SMnode *pMnode, STrans *pTrans, SArray *pA
terrno = errorCode; terrno = errorCode;
return errorCode; return errorCode;
} else { } else {
mDebug("trans:%d, %d of %d actions executed, code:0x%x", pTrans->id, numOfReceivedMsgs, numOfActions, errorCode);
return TSDB_CODE_MND_ACTION_IN_PROGRESS; return TSDB_CODE_MND_ACTION_IN_PROGRESS;
} }
} }
......
...@@ -178,8 +178,10 @@ static int32_t mndExecSteps(SMnode *pMnode) { ...@@ -178,8 +178,10 @@ static int32_t mndExecSteps(SMnode *pMnode) {
// (*pMnode->reportProgress)(pStep->name, "start initialize"); // (*pMnode->reportProgress)(pStep->name, "start initialize");
if ((*pStep->initFp)(pMnode) != 0) { if ((*pStep->initFp)(pMnode) != 0) {
int32_t code = terrno;
mError("step:%s exec failed since %s, start to cleanup", pStep->name, terrstr()); mError("step:%s exec failed since %s, start to cleanup", pStep->name, terrstr());
mndCleanupSteps(pMnode, pos); mndCleanupSteps(pMnode, pos);
terrno = code;
return -1; return -1;
} else { } else {
mDebug("step:%s is initialized", pStep->name); mDebug("step:%s is initialized", pStep->name);
......
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
#include "sdbInt.h" #include "sdbInt.h"
static int32_t sdbCreateDir(SSdb *pSdb);
SSdb *sdbInit(SSdbOpt *pOption) { SSdb *sdbInit(SSdbOpt *pOption) {
mDebug("start to init sdb in %s", pOption->path); mDebug("start to init sdb in %s", pOption->path);
...@@ -40,6 +42,11 @@ SSdb *sdbInit(SSdbOpt *pOption) { ...@@ -40,6 +42,11 @@ SSdb *sdbInit(SSdbOpt *pOption) {
return NULL; return NULL;
} }
if (sdbCreateDir(pSdb) != 0) {
sdbCleanup(pSdb);
return NULL;
}
for (ESdbType i = 0; i < SDB_MAX; ++i) { for (ESdbType i = 0; i < SDB_MAX; ++i) {
taosInitRWLatch(&pSdb->locks[i]); taosInitRWLatch(&pSdb->locks[i]);
} }
...@@ -134,3 +141,25 @@ int32_t sdbSetTable(SSdb *pSdb, SSdbTable table) { ...@@ -134,3 +141,25 @@ int32_t sdbSetTable(SSdb *pSdb, SSdbTable table) {
return 0; return 0;
} }
static int32_t sdbCreateDir(SSdb *pSdb) {
if (taosMkDir(pSdb->currDir) != 0) {
terrno = TAOS_SYSTEM_ERROR(errno);
mError("failed to create dir:%s since %s", pSdb->currDir, terrstr());
return -1;
}
if (taosMkDir(pSdb->syncDir) != 0) {
terrno = TAOS_SYSTEM_ERROR(errno);
mError("failed to create dir:%s since %s", pSdb->syncDir, terrstr());
return -1;
}
if (taosMkDir(pSdb->tmpDir) != 0) {
terrno = TAOS_SYSTEM_ERROR(errno);
mError("failed to create dir:%s since %s", pSdb->tmpDir, terrstr());
return -1;
}
return 0;
}
...@@ -17,28 +17,6 @@ ...@@ -17,28 +17,6 @@
#include "sdbInt.h" #include "sdbInt.h"
#include "tchecksum.h" #include "tchecksum.h"
static int32_t sdbCreateDir(SSdb *pSdb) {
if (taosMkDir(pSdb->currDir) != 0) {
terrno = TAOS_SYSTEM_ERROR(errno);
mError("failed to create dir:%s since %s", pSdb->currDir, terrstr());
return -1;
}
if (taosMkDir(pSdb->syncDir) != 0) {
terrno = TAOS_SYSTEM_ERROR(errno);
mError("failed to create dir:%s since %s", pSdb->syncDir, terrstr());
return -1;
}
if (taosMkDir(pSdb->tmpDir) != 0) {
terrno = TAOS_SYSTEM_ERROR(errno);
mError("failed to create dir:%s since %s", pSdb->tmpDir, terrstr());
return -1;
}
return 0;
}
static int32_t sdbRunDeployFp(SSdb *pSdb) { static int32_t sdbRunDeployFp(SSdb *pSdb) {
mDebug("start to deploy sdb"); mDebug("start to deploy sdb");
...@@ -77,7 +55,7 @@ int32_t sdbReadFile(SSdb *pSdb) { ...@@ -77,7 +55,7 @@ int32_t sdbReadFile(SSdb *pSdb) {
free(pRaw); free(pRaw);
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
mError("failed to read file:%s since %s", file, terrstr()); mError("failed to read file:%s since %s", file, terrstr());
return -1; return 0;
} }
while (1) { while (1) {
...@@ -225,10 +203,6 @@ int32_t sdbWriteFile(SSdb *pSdb) { ...@@ -225,10 +203,6 @@ int32_t sdbWriteFile(SSdb *pSdb) {
} }
int32_t sdbDeploy(SSdb *pSdb) { int32_t sdbDeploy(SSdb *pSdb) {
if (sdbCreateDir(pSdb) != 0) {
return -1;
}
if (sdbRunDeployFp(pSdb) != 0) { if (sdbRunDeployFp(pSdb) != 0) {
return -1; return -1;
} }
......
...@@ -15,6 +15,7 @@ target_link_libraries( ...@@ -15,6 +15,7 @@ target_link_libraries(
PUBLIC wal PUBLIC wal
PUBLIC sync PUBLIC sync
PUBLIC cjson PUBLIC cjson
PUBLIC qworker
) )
# test # test
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "vnodeRequest.h" #include "vnodeRequest.h"
#include "vnodeStateMgr.h" #include "vnodeStateMgr.h"
#include "vnodeSync.h" #include "vnodeSync.h"
#include "vnodeQuery.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -72,6 +73,7 @@ struct SVnode { ...@@ -72,6 +73,7 @@ struct SVnode {
SVnodeSync* pSync; SVnodeSync* pSync;
SVnodeFS* pFs; SVnodeFS* pFs;
tsem_t canCommit; tsem_t canCommit;
void* pQuery;
}; };
int vnodeScheduleTask(SVnodeTask* task); int vnodeScheduleTask(SVnodeTask* task);
......
/*
* 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_VNODE_READ_H_
#define _TD_VNODE_READ_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "vnodeInt.h"
#include "qworker.h"
int vnodeQueryOpen(SVnode *pVnode);
#ifdef __cplusplus
}
#endif
#endif /*_TD_VNODE_READ_H_*/
...@@ -24,16 +24,6 @@ int32_t vnodeSync(SVnode *pVnode) { return 0; } ...@@ -24,16 +24,6 @@ int32_t vnodeSync(SVnode *pVnode) { return 0; }
int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) { return 0; } int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) { return 0; }
int vnodeProcessQueryReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
vInfo("query message is processed");
return 0;
}
int vnodeProcessFetchReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
vInfo("fetch message is processed");
return 0;
}
int vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { int vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
vInfo("sync message is processed"); vInfo("sync message is processed");
return 0; return 0;
......
...@@ -127,6 +127,11 @@ static int vnodeOpenImpl(SVnode *pVnode) { ...@@ -127,6 +127,11 @@ static int vnodeOpenImpl(SVnode *pVnode) {
return -1; return -1;
} }
// Open Query
if (vnodeQueryOpen(pVnode)) {
return -1;
}
// TODO // TODO
return 0; return 0;
} }
......
/*
* 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/>.
*/
#include "vnodeDef.h"
#include "vnodeQuery.h"
int vnodeQueryOpen(SVnode *pVnode) {
return qWorkerInit(NULL, &pVnode->pQuery);
}
int vnodeProcessQueryReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
vInfo("query message is processed");
qWorkerProcessQueryMsg(pVnode, pVnode->pQuery, pMsg);
return 0;
}
int vnodeProcessFetchReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
vInfo("fetch message is processed");
qWorkerProcessFetchMsg(pVnode, pVnode->pQuery, pMsg);
return 0;
}
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* 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_META_QUERY_H_ #ifndef _VNODE_QUERY_H_
#define _TD_META_QUERY_H_ #define _VNODE_QUERY_H_
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -24,4 +24,4 @@ extern "C" { ...@@ -24,4 +24,4 @@ extern "C" {
} }
#endif #endif
#endif /*_TD_META_QUERY_H_*/ #endif /*_VNODE_QUERY_H_*/
\ No newline at end of file \ No newline at end of file
...@@ -59,8 +59,6 @@ typedef struct SCatalogMgmt { ...@@ -59,8 +59,6 @@ typedef struct SCatalogMgmt {
typedef uint32_t (*tableNameHashFp)(const char *, uint32_t); typedef uint32_t (*tableNameHashFp)(const char *, uint32_t);
extern int32_t ctgDebugFlag;
#define ctgFatal(...) do { if (ctgDebugFlag & DEBUG_FATAL) { taosPrintLog("CTG FATAL ", ctgDebugFlag, __VA_ARGS__); }} while(0) #define ctgFatal(...) do { if (ctgDebugFlag & DEBUG_FATAL) { taosPrintLog("CTG FATAL ", ctgDebugFlag, __VA_ARGS__); }} while(0)
#define ctgError(...) do { if (ctgDebugFlag & DEBUG_ERROR) { taosPrintLog("CTG ERROR ", ctgDebugFlag, __VA_ARGS__); }} while(0) #define ctgError(...) do { if (ctgDebugFlag & DEBUG_ERROR) { taosPrintLog("CTG ERROR ", ctgDebugFlag, __VA_ARGS__); }} while(0)
#define ctgWarn(...) do { if (ctgDebugFlag & DEBUG_WARN) { taosPrintLog("CTG WARN ", ctgDebugFlag, __VA_ARGS__); }} while(0) #define ctgWarn(...) do { if (ctgDebugFlag & DEBUG_WARN) { taosPrintLog("CTG WARN ", ctgDebugFlag, __VA_ARGS__); }} while(0)
...@@ -75,7 +73,6 @@ extern int32_t ctgDebugFlag; ...@@ -75,7 +73,6 @@ extern int32_t ctgDebugFlag;
#define CTG_ERR_LRET(c,...) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { ctgError(__VA_ARGS__); terrno = _code; return _code; } } while (0) #define CTG_ERR_LRET(c,...) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { ctgError(__VA_ARGS__); terrno = _code; return _code; } } while (0)
#define CTG_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0) #define CTG_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0)
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -371,7 +371,7 @@ int32_t catalogInit(SCatalogCfg *cfg) { ...@@ -371,7 +371,7 @@ int32_t catalogInit(SCatalogCfg *cfg) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t catalogGetHandle(const char *clusterId, struct SCatalog** catalogHandle) { int32_t catalogGetHandle(const char* clusterId , struct SCatalog** catalogHandle) {
if (NULL == clusterId || NULL == catalogHandle) { if (NULL == clusterId || NULL == catalogHandle) {
CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT); CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT);
} }
...@@ -565,12 +565,12 @@ _return: ...@@ -565,12 +565,12 @@ _return:
} }
int32_t catalogGetTableHashVgroup(struct SCatalog *pCatalog, void *pRpc, const SEpSet *pMgmtEps, const char *pDBName, const char *pTableName, SVgroupInfo *pVgroup) { int32_t catalogGetTableHashVgroup(struct SCatalog *pCatalog, void *pTransporter, const SEpSet *pMgmtEps, const char *pDBName, const char *pTableName, SVgroupInfo *pVgroup) {
SDBVgroupInfo dbInfo = {0}; SDBVgroupInfo dbInfo = {0};
int32_t code = 0; int32_t code = 0;
int32_t vgId = 0; int32_t vgId = 0;
CTG_ERR_RET(catalogGetDBVgroup(pCatalog, pRpc, pMgmtEps, pDBName, false, &dbInfo)); CTG_ERR_RET(catalogGetDBVgroup(pCatalog, pTransporter, pMgmtEps, pDBName, false, &dbInfo));
if (dbInfo.vgVersion < 0 || NULL == dbInfo.vgInfo) { if (dbInfo.vgVersion < 0 || NULL == dbInfo.vgInfo) {
ctgError("db[%s] vgroup cache invalid, vgroup version:%d, vgInfo:%p", pDBName, dbInfo.vgVersion, dbInfo.vgInfo); ctgError("db[%s] vgroup cache invalid, vgroup version:%d, vgInfo:%p", pDBName, dbInfo.vgVersion, dbInfo.vgInfo);
......
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
#include "catalog.h" #include "catalog.h"
#include "tep.h" #include "tep.h"
#include "trpc.h" #include "trpc.h"
#include "stub.h"
#include "addr_any.h"
typedef struct SAppInstInfo { typedef struct SAppInstInfo {
int64_t numOfConns; int64_t numOfConns;
...@@ -86,6 +88,27 @@ void sendCreateDbMsg(void *shandle, SEpSet *pEpSet) { ...@@ -86,6 +88,27 @@ void sendCreateDbMsg(void *shandle, SEpSet *pEpSet) {
ASSERT_EQ(rpcRsp.code, 0); ASSERT_EQ(rpcRsp.code, 0);
} }
void __rpcSendRecv(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) {
SUseDbRsp *rspMsg = NULL; //todo
return;
}
void initTestEnv() {
static Stub stub;
stub.set(rpcSendRecv, __rpcSendRecv);
{
AddrAny any("libtransport.so");
std::map<std::string,void*> result;
any.get_global_func_addr_dynsym("^rpcSendRecv$", result);
for (const auto& f : result) {
stub.set(f.second, __rpcSendRecv);
}
}
}
} }
TEST(testCase, normalCase) { TEST(testCase, normalCase) {
...@@ -99,7 +122,7 @@ TEST(testCase, normalCase) { ...@@ -99,7 +122,7 @@ TEST(testCase, normalCase) {
void *mockPointer = (void *)0x1; void *mockPointer = (void *)0x1;
SVgroupInfo vgInfo = {0}; SVgroupInfo vgInfo = {0};
msgInit(); initQueryModuleMsgHandle();
sendCreateDbMsg(pConn->pTransporter, &pConn->pAppInfo->mgmtEp.epSet); sendCreateDbMsg(pConn->pTransporter, &pConn->pAppInfo->mgmtEp.epSet);
......
...@@ -42,7 +42,12 @@ typedef struct TFileHeader { ...@@ -42,7 +42,12 @@ typedef struct TFileHeader {
#define TFILE_HEADER_SIZE (sizeof(TFileHeader)) #define TFILE_HEADER_SIZE (sizeof(TFileHeader))
#define TFILE_HEADER_NO_FST (TFILE_HEADER_SIZE - sizeof(int32_t)) #define TFILE_HEADER_NO_FST (TFILE_HEADER_SIZE - sizeof(int32_t))
//#define TFILE_HADER_PRE_SIZE (sizeof(uint64_t) + sizeof(int32_t) + sizeof(int32_t))
typedef struct TFileValue {
char* colVal; // null terminated
SArray* tableId;
int32_t offset;
} TFileValue;
typedef struct TFileCacheKey { typedef struct TFileCacheKey {
uint64_t suid; uint64_t suid;
......
...@@ -41,7 +41,7 @@ static pthread_once_t isInit = PTHREAD_ONCE_INIT; ...@@ -41,7 +41,7 @@ static pthread_once_t isInit = PTHREAD_ONCE_INIT;
static void indexInit(); static void indexInit();
static int indexTermSearch(SIndex* sIdx, SIndexTermQuery* term, SArray** result); static int indexTermSearch(SIndex* sIdx, SIndexTermQuery* term, SArray** result);
static int indexMergeCacheIntoTindex(SIndex* sIdx); static int indexFlushCacheToTindex(SIndex* sIdx);
static void indexInterResultsDestroy(SArray* results); static void indexInterResultsDestroy(SArray* results);
static int indexMergeFinalResults(SArray* interResults, EIndexOperatorType oType, SArray* finalResult); static int indexMergeFinalResults(SArray* interResults, EIndexOperatorType oType, SArray* finalResult);
...@@ -49,9 +49,7 @@ static int indexMergeFinalResults(SArray* interResults, EIndexOperatorType oTyp ...@@ -49,9 +49,7 @@ static int indexMergeFinalResults(SArray* interResults, EIndexOperatorType oTyp
int indexOpen(SIndexOpts* opts, const char* path, SIndex** index) { int indexOpen(SIndexOpts* opts, const char* path, SIndex** index) {
pthread_once(&isInit, indexInit); pthread_once(&isInit, indexInit);
SIndex* sIdx = calloc(1, sizeof(SIndex)); SIndex* sIdx = calloc(1, sizeof(SIndex));
if (sIdx == NULL) { if (sIdx == NULL) { return -1; }
return -1;
}
#ifdef USE_LUCENE #ifdef USE_LUCENE
index_t* index = index_open(path); index_t* index = index_open(path);
...@@ -131,9 +129,7 @@ int indexPut(SIndex* index, SIndexMultiTerm* fVals, uint64_t uid) { ...@@ -131,9 +129,7 @@ int indexPut(SIndex* index, SIndexMultiTerm* fVals, uint64_t uid) {
int32_t colId = fi->colId; int32_t colId = fi->colId;
int32_t version = index->cVersion; int32_t version = index->cVersion;
int ret = indexCachePut(index->cache, p, colId, version, uid); int ret = indexCachePut(index->cache, p, colId, version, uid);
if (ret != 0) { if (ret != 0) { return ret; }
return ret;
}
} }
#endif #endif
...@@ -221,9 +217,7 @@ void indexOptsDestroy(SIndexOpts* opts){ ...@@ -221,9 +217,7 @@ void indexOptsDestroy(SIndexOpts* opts){
SIndexMultiTermQuery* indexMultiTermQueryCreate(EIndexOperatorType opera) { SIndexMultiTermQuery* indexMultiTermQueryCreate(EIndexOperatorType opera) {
SIndexMultiTermQuery* p = (SIndexMultiTermQuery*)malloc(sizeof(SIndexMultiTermQuery)); SIndexMultiTermQuery* p = (SIndexMultiTermQuery*)malloc(sizeof(SIndexMultiTermQuery));
if (p == NULL) { if (p == NULL) { return NULL; }
return NULL;
}
p->opera = opera; p->opera = opera;
p->query = taosArrayInit(4, sizeof(SIndexTermQuery)); p->query = taosArrayInit(4, sizeof(SIndexTermQuery));
return p; return p;
...@@ -250,9 +244,7 @@ SIndexTerm* indexTermCreate(int64_t suid, ...@@ -250,9 +244,7 @@ SIndexTerm* indexTermCreate(int64_t suid,
const char* colVal, const char* colVal,
int32_t nColVal) { int32_t nColVal) {
SIndexTerm* t = (SIndexTerm*)calloc(1, (sizeof(SIndexTerm))); SIndexTerm* t = (SIndexTerm*)calloc(1, (sizeof(SIndexTerm)));
if (t == NULL) { if (t == NULL) { return NULL; }
return NULL;
}
t->suid = suid; t->suid = suid;
t->operType = oper; t->operType = oper;
...@@ -332,9 +324,7 @@ static int indexTermSearch(SIndex* sIdx, SIndexTermQuery* query, SArray** result ...@@ -332,9 +324,7 @@ static int indexTermSearch(SIndex* sIdx, SIndexTermQuery* query, SArray** result
return 0; return 0;
} }
static void indexInterResultsDestroy(SArray* results) { static void indexInterResultsDestroy(SArray* results) {
if (results == NULL) { if (results == NULL) { return; }
return;
}
size_t sz = taosArrayGetSize(results); size_t sz = taosArrayGetSize(results);
for (size_t i = 0; i < sz; i++) { for (size_t i = 0; i < sz; i++) {
...@@ -363,10 +353,10 @@ static int indexMergeFinalResults(SArray* interResults, EIndexOperatorType oType ...@@ -363,10 +353,10 @@ static int indexMergeFinalResults(SArray* interResults, EIndexOperatorType oType
} }
return 0; return 0;
} }
static int indexMergeCacheIntoTindex(SIndex* sIdx) { static int indexFlushCacheToTindex(SIndex* sIdx) {
if (sIdx == NULL) { if (sIdx == NULL) { return -1; }
return -1;
}
indexWarn("suid %" PRIu64 " merge cache into tindex", sIdx->suid); indexWarn("suid %" PRIu64 " merge cache into tindex", sIdx->suid);
return 0; return 0;
} }
...@@ -151,7 +151,6 @@ int indexCacheSearch(void* cache, SIndexTermQuery* query, int16_t colId, int32_t ...@@ -151,7 +151,6 @@ int indexCacheSearch(void* cache, SIndexTermQuery* query, int16_t colId, int32_t
EIndexQueryType qtype = query->qType; EIndexQueryType qtype = query->qType;
int32_t keyLen = CACHE_KEY_LEN(term); int32_t keyLen = CACHE_KEY_LEN(term);
char* buf = calloc(1, keyLen); char* buf = calloc(1, keyLen);
if (qtype == QUERY_TERM) { if (qtype == QUERY_TERM) {
// //
......
...@@ -69,9 +69,9 @@ WriterCtx* writerCtxCreate(WriterType type, const char* path, bool readOnly, int ...@@ -69,9 +69,9 @@ WriterCtx* writerCtxCreate(WriterType type, const char* path, bool readOnly, int
// ugly code, refactor later // ugly code, refactor later
ctx->file.readOnly = readOnly; ctx->file.readOnly = readOnly;
if (readOnly == false) { if (readOnly == false) {
ctx->file.fd = tfOpenCreateWriteAppend(tmpFile); ctx->file.fd = tfOpenCreateWriteAppend(path);
} else { } else {
ctx->file.fd = tfOpenReadWrite(tmpFile); ctx->file.fd = tfOpenReadWrite(path);
} }
if (ctx->file.fd < 0) { if (ctx->file.fd < 0) {
indexError("open file error %d", errno); indexError("open file error %d", errno);
...@@ -93,6 +93,7 @@ WriterCtx* writerCtxCreate(WriterType type, const char* path, bool readOnly, int ...@@ -93,6 +93,7 @@ WriterCtx* writerCtxCreate(WriterType type, const char* path, bool readOnly, int
END: END:
if (ctx->type == TMemory) { free(ctx->mem.buf); } if (ctx->type == TMemory) { free(ctx->mem.buf); }
free(ctx); free(ctx);
return NULL;
} }
void writerCtxDestroy(WriterCtx* ctx) { void writerCtxDestroy(WriterCtx* ctx) {
if (ctx->type == TMemory) { if (ctx->type == TMemory) {
......
...@@ -25,12 +25,7 @@ ...@@ -25,12 +25,7 @@
#define TF_TABLE_TATOAL_SIZE(sz) (sizeof(sz) + sz * sizeof(uint64_t)) #define TF_TABLE_TATOAL_SIZE(sz) (sizeof(sz) + sz * sizeof(uint64_t))
typedef struct TFileValue { static int tfileStrCompare(const void* a, const void* b);
char* colVal; // null terminated
SArray* tableId;
int32_t offset;
} TFileValue;
static int tfileValueCompare(const void* a, const void* b, const void* param); static int tfileValueCompare(const void* a, const void* b, const void* param);
static void tfileSerialTableIdsToBuf(char* buf, SArray* tableIds); static void tfileSerialTableIdsToBuf(char* buf, SArray* tableIds);
...@@ -38,17 +33,18 @@ static int tfileWriteHeader(TFileWriter* writer); ...@@ -38,17 +33,18 @@ static int tfileWriteHeader(TFileWriter* writer);
static int tfileWriteFstOffset(TFileWriter* tw, int32_t offset); static int tfileWriteFstOffset(TFileWriter* tw, int32_t offset);
static int tfileWriteData(TFileWriter* write, TFileValue* tval); static int tfileWriteData(TFileWriter* write, TFileValue* tval);
static int tfileReadLoadHeader(TFileReader* reader); static int tfileReaderLoadHeader(TFileReader* reader);
static int tfileReadLoadFst(TFileReader* reader); static int tfileReaderLoadFst(TFileReader* reader);
static int tfileReadLoadTableIds(TFileReader* reader, int32_t offset, SArray* result); static int tfileReaderLoadTableIds(TFileReader* reader, int32_t offset, SArray* result);
static void tfileReadRef(TFileReader* reader); static void tfileReaderRef(TFileReader* reader);
static void tfileReadUnRef(TFileReader* reader); static void tfileReaderUnRef(TFileReader* reader);
static int tfileGetFileList(const char* path, SArray* result); static int tfileGetFileList(const char* path, SArray* result);
static int tfileRmExpireFile(SArray* result); static int tfileRmExpireFile(SArray* result);
static void tfileDestroyFileName(void* elem); static void tfileDestroyFileName(void* elem);
static int tfileCompare(const void* a, const void* b); static int tfileCompare(const void* a, const void* b);
static int tfileParseFileName(const char* filename, uint64_t* suid, int* colId, int* version); static int tfileParseFileName(const char* filename, uint64_t* suid, int* colId, int* version);
static void tfileGenFileName(char* filename, uint64_t suid, int colId, int version);
static void tfileSerialCacheKey(TFileCacheKey* key, char* buf); static void tfileSerialCacheKey(TFileCacheKey* key, char* buf);
TFileCache* tfileCacheCreate(const char* path) { TFileCache* tfileCacheCreate(const char* path) {
...@@ -74,23 +70,12 @@ TFileCache* tfileCacheCreate(const char* path) { ...@@ -74,23 +70,12 @@ TFileCache* tfileCacheCreate(const char* path) {
WriterCtx* wc = writerCtxCreate(TFile, file, true, 1024 * 64); WriterCtx* wc = writerCtxCreate(TFile, file, true, 1024 * 64);
if (wc == NULL) { if (wc == NULL) {
indexError("failed to open index: %s", file); indexError("failed to open index:%s", file);
goto End; goto End;
} }
TFileReader* reader = tfileReaderCreate(wc); TFileReader* reader = tfileReaderCreate(wc);
if (0 != tfileReadLoadHeader(reader)) { tfileReaderRef(reader);
tfileReaderDestroy(reader);
indexError("failed to load index header, index file: %s", file);
goto End;
}
if (0 != tfileReadLoadFst(reader)) {
tfileReaderDestroy(reader);
indexError("failed to load index fst, index file: %s", file);
goto End;
}
tfileReadRef(reader);
// loader fst and validate it // loader fst and validate it
TFileHeader* header = &reader->header; TFileHeader* header = &reader->header;
TFileCacheKey key = {.suid = header->suid, .colName = header->colName, .nColName = strlen(header->colName), .colType = header->colType}; TFileCacheKey key = {.suid = header->suid, .colName = header->colName, .nColName = strlen(header->colName), .colType = header->colType};
...@@ -115,7 +100,7 @@ void tfileCacheDestroy(TFileCache* tcache) { ...@@ -115,7 +100,7 @@ void tfileCacheDestroy(TFileCache* tcache) {
TFileReader* p = *reader; TFileReader* p = *reader;
indexInfo("drop table cache suid: %" PRIu64 ", colName: %s, colType: %d", p->header.suid, p->header.colName, p->header.colType); indexInfo("drop table cache suid: %" PRIu64 ", colName: %s, colType: %d", p->header.suid, p->header.colName, p->header.colType);
tfileReadUnRef(p); tfileReaderUnRef(p);
reader = taosHashIterate(tcache->tableCache, reader); reader = taosHashIterate(tcache->tableCache, reader);
} }
taosHashCleanup(tcache->tableCache); taosHashCleanup(tcache->tableCache);
...@@ -127,7 +112,7 @@ TFileReader* tfileCacheGet(TFileCache* tcache, TFileCacheKey* key) { ...@@ -127,7 +112,7 @@ TFileReader* tfileCacheGet(TFileCache* tcache, TFileCacheKey* key) {
tfileSerialCacheKey(key, buf); tfileSerialCacheKey(key, buf);
TFileReader* reader = taosHashGet(tcache->tableCache, buf, strlen(buf)); TFileReader* reader = taosHashGet(tcache->tableCache, buf, strlen(buf));
tfileReadRef(reader); tfileReaderRef(reader);
return reader; return reader;
} }
...@@ -139,10 +124,10 @@ void tfileCachePut(TFileCache* tcache, TFileCacheKey* key, TFileReader* reader) ...@@ -139,10 +124,10 @@ void tfileCachePut(TFileCache* tcache, TFileCacheKey* key, TFileReader* reader)
if (*p != NULL) { if (*p != NULL) {
TFileReader* oldReader = *p; TFileReader* oldReader = *p;
taosHashRemove(tcache->tableCache, buf, strlen(buf)); taosHashRemove(tcache->tableCache, buf, strlen(buf));
tfileReadUnRef(oldReader); tfileReaderUnRef(oldReader);
} }
tfileReadRef(reader); tfileReaderRef(reader);
taosHashPut(tcache->tableCache, buf, strlen(buf), &reader, sizeof(void*)); taosHashPut(tcache->tableCache, buf, strlen(buf), &reader, sizeof(void*));
return; return;
} }
...@@ -153,6 +138,19 @@ TFileReader* tfileReaderCreate(WriterCtx* ctx) { ...@@ -153,6 +138,19 @@ TFileReader* tfileReaderCreate(WriterCtx* ctx) {
// T_REF_INC(reader); // T_REF_INC(reader);
reader->ctx = ctx; reader->ctx = ctx;
if (0 != tfileReaderLoadHeader(reader)) {
tfileReaderDestroy(reader);
indexError("failed to load index header, suid: %" PRIu64 ", colName: %s", reader->header.suid, reader->header.colName);
return NULL;
}
if (0 != tfileReaderLoadFst(reader)) {
tfileReaderDestroy(reader);
indexError("failed to load index fst, suid: %" PRIu64 ", colName: %s", reader->header.suid, reader->header.colName);
return NULL;
}
return reader; return reader;
} }
void tfileReaderDestroy(TFileReader* reader) { void tfileReaderDestroy(TFileReader* reader) {
...@@ -174,7 +172,7 @@ int tfileReaderSearch(TFileReader* reader, SIndexTermQuery* query, SArray* resul ...@@ -174,7 +172,7 @@ int tfileReaderSearch(TFileReader* reader, SIndexTermQuery* query, SArray* resul
FstSlice key = fstSliceCreate(term->colVal, term->nColVal); FstSlice key = fstSliceCreate(term->colVal, term->nColVal);
if (fstGet(reader->fst, &key, &offset)) { if (fstGet(reader->fst, &key, &offset)) {
indexInfo("index: %" PRIu64 ", col: %s, colVal: %s, found table info in tindex", term->suid, term->colName, term->colVal); indexInfo("index: %" PRIu64 ", col: %s, colVal: %s, found table info in tindex", term->suid, term->colName, term->colVal);
ret = tfileReadLoadTableIds(reader, offset, result); ret = tfileReaderLoadTableIds(reader, offset, result);
} else { } else {
indexInfo("index: %" PRIu64 ", col: %s, colVal: %s, not found table info in tindex", term->suid, term->colName, term->colVal); indexInfo("index: %" PRIu64 ", col: %s, colVal: %s, not found table info in tindex", term->suid, term->colName, term->colVal);
} }
...@@ -185,7 +183,7 @@ int tfileReaderSearch(TFileReader* reader, SIndexTermQuery* query, SArray* resul ...@@ -185,7 +183,7 @@ int tfileReaderSearch(TFileReader* reader, SIndexTermQuery* query, SArray* resul
} else { } else {
// handle later // handle later
} }
tfileReadUnRef(reader); tfileReaderUnRef(reader);
return ret; return ret;
} }
...@@ -214,11 +212,18 @@ TFileWriter* tfileWriterCreate(WriterCtx* ctx, TFileHeader* header) { ...@@ -214,11 +212,18 @@ TFileWriter* tfileWriterCreate(WriterCtx* ctx, TFileHeader* header) {
int tfileWriterPut(TFileWriter* tw, void* data) { int tfileWriterPut(TFileWriter* tw, void* data) {
// sort by coltype and write to tindex // sort by coltype and write to tindex
__compar_fn_t fn = getComparFunc(tw->header.colType, 0); __compar_fn_t fn;
int8_t colType = tw->header.colType;
if (colType == TSDB_DATA_TYPE_BINARY || colType == TSDB_DATA_TYPE_NCHAR) {
fn = tfileStrCompare;
} else {
fn = getComparFunc(colType, 0);
}
taosArraySortPWithExt((SArray*)(data), tfileValueCompare, &fn); taosArraySortPWithExt((SArray*)(data), tfileValueCompare, &fn);
int32_t bufLimit = 4096, offset = 0; int32_t bufLimit = 4096, offset = 0;
char* buf = calloc(1, sizeof(bufLimit)); char* buf = calloc(1, sizeof(char) * bufLimit);
char* p = buf; char* p = buf;
int32_t sz = taosArrayGetSize((SArray*)data); int32_t sz = taosArrayGetSize((SArray*)data);
int32_t fstOffset = tw->offset; int32_t fstOffset = tw->offset;
...@@ -259,6 +264,11 @@ int tfileWriterPut(TFileWriter* tw, void* data) { ...@@ -259,6 +264,11 @@ int tfileWriterPut(TFileWriter* tw, void* data) {
} }
tfree(buf); tfree(buf);
tw->fb = fstBuilderCreate(tw->ctx, 0);
if (tw->fb == NULL) {
tfileWriterDestroy(tw);
return -1;
}
// write fst // write fst
for (size_t i = 0; i < sz; i++) { for (size_t i = 0; i < sz; i++) {
// TODO, fst batch write later // TODO, fst batch write later
...@@ -267,6 +277,9 @@ int tfileWriterPut(TFileWriter* tw, void* data) { ...@@ -267,6 +277,9 @@ int tfileWriterPut(TFileWriter* tw, void* data) {
// //
} }
} }
fstBuilderFinish(tw->fb);
fstBuilderDestroy(tw->fb);
tw->fb = NULL;
return 0; return 0;
} }
void tfileWriterDestroy(TFileWriter* tw) { void tfileWriterDestroy(TFileWriter* tw) {
...@@ -305,6 +318,12 @@ int indexTFilePut(void* tfile, SIndexTerm* term, uint64_t uid) { ...@@ -305,6 +318,12 @@ int indexTFilePut(void* tfile, SIndexTerm* term, uint64_t uid) {
return 0; return 0;
} }
static int tfileStrCompare(const void* a, const void* b) {
int ret = strcmp((char*)a, (char*)b);
if (ret == 0) { return ret; }
return ret < 0 ? -1 : 1;
}
static int tfileValueCompare(const void* a, const void* b, const void* param) { static int tfileValueCompare(const void* a, const void* b, const void* param) {
__compar_fn_t fn = *(__compar_fn_t*)param; __compar_fn_t fn = *(__compar_fn_t*)param;
...@@ -326,6 +345,7 @@ static int tfileWriteFstOffset(TFileWriter* tw, int32_t offset) { ...@@ -326,6 +345,7 @@ static int tfileWriteFstOffset(TFileWriter* tw, int32_t offset) {
int32_t fstOffset = offset + sizeof(tw->header.fstOffset); int32_t fstOffset = offset + sizeof(tw->header.fstOffset);
tw->header.fstOffset = fstOffset; tw->header.fstOffset = fstOffset;
if (sizeof(fstOffset) != tw->ctx->write(tw->ctx, (char*)&fstOffset, sizeof(fstOffset))) { return -1; } if (sizeof(fstOffset) != tw->ctx->write(tw->ctx, (char*)&fstOffset, sizeof(fstOffset))) { return -1; }
tw->offset += sizeof(fstOffset);
return 0; return 0;
} }
static int tfileWriteHeader(TFileWriter* writer) { static int tfileWriteHeader(TFileWriter* writer) {
...@@ -355,16 +375,16 @@ static int tfileWriteData(TFileWriter* write, TFileValue* tval) { ...@@ -355,16 +375,16 @@ static int tfileWriteData(TFileWriter* write, TFileValue* tval) {
} }
return 0; return 0;
} }
static int tfileReadLoadHeader(TFileReader* reader) { static int tfileReaderLoadHeader(TFileReader* reader) {
// TODO simple tfile header later // TODO simple tfile header later
char buf[TFILE_HEADER_SIZE] = {0}; char buf[TFILE_HEADER_SIZE] = {0};
int64_t nread = reader->ctx->read(reader->ctx, buf, sizeof(buf)); int64_t nread = reader->ctx->readFrom(reader->ctx, buf, sizeof(buf), 0);
assert(nread == sizeof(buf)); assert(nread == sizeof(buf));
memcpy(&reader->header, buf, sizeof(buf)); memcpy(&reader->header, buf, sizeof(buf));
return 0; return 0;
} }
static int tfileReadLoadFst(TFileReader* reader) { static int tfileReaderLoadFst(TFileReader* reader) {
// current load fst into memory, refactor it later // current load fst into memory, refactor it later
static int FST_MAX_SIZE = 16 * 1024; static int FST_MAX_SIZE = 16 * 1024;
...@@ -381,9 +401,9 @@ static int tfileReadLoadFst(TFileReader* reader) { ...@@ -381,9 +401,9 @@ static int tfileReadLoadFst(TFileReader* reader) {
free(buf); free(buf);
fstSliceDestroy(&st); fstSliceDestroy(&st);
return reader->fst == NULL ? 0 : -1; return reader->fst != NULL ? 0 : -1;
} }
static int tfileReadLoadTableIds(TFileReader* reader, int32_t offset, SArray* result) { static int tfileReaderLoadTableIds(TFileReader* reader, int32_t offset, SArray* result) {
int32_t nid; int32_t nid;
WriterCtx* ctx = reader->ctx; WriterCtx* ctx = reader->ctx;
...@@ -403,12 +423,12 @@ static int tfileReadLoadTableIds(TFileReader* reader, int32_t offset, SArray* re ...@@ -403,12 +423,12 @@ static int tfileReadLoadTableIds(TFileReader* reader, int32_t offset, SArray* re
free(buf); free(buf);
return 0; return 0;
} }
static void tfileReadRef(TFileReader* reader) { static void tfileReaderRef(TFileReader* reader) {
int ref = T_REF_INC(reader); int ref = T_REF_INC(reader);
UNUSED(ref); UNUSED(ref);
} }
static void tfileReadUnRef(TFileReader* reader) { static void tfileReaderUnRef(TFileReader* reader) {
int ref = T_REF_DEC(reader); int ref = T_REF_DEC(reader);
if (ref == 0) { tfileReaderDestroy(reader); } if (ref == 0) { tfileReaderDestroy(reader); }
} }
...@@ -445,6 +465,10 @@ static int tfileCompare(const void* a, const void* b) { ...@@ -445,6 +465,10 @@ static int tfileCompare(const void* a, const void* b) {
return strncmp(aName, bName, aLen > bLen ? aLen : bLen); return strncmp(aName, bName, aLen > bLen ? aLen : bLen);
} }
// tfile name suid-colId-version.tindex // tfile name suid-colId-version.tindex
static void tfileGenFileName(char* filename, uint64_t suid, int colId, int version) {
sprintf(filename, "%" PRIu64 "-%d-%d.tindex", suid, colId, version);
return;
}
static int tfileParseFileName(const char* filename, uint64_t* suid, int* colId, int* version) { static int tfileParseFileName(const char* filename, uint64_t* suid, int* colId, int* version) {
if (3 == sscanf(filename, "%" PRIu64 "-%d-%d.tindex", suid, colId, version)) { if (3 == sscanf(filename, "%" PRIu64 "-%d-%d.tindex", suid, colId, version)) {
// read suid & colid & version success // read suid & colid & version success
......
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com> * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
* *
* This program is free software: you can use, redistribute, and/or modify * 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 * it under the terms of the GNU Affero General Public License, version 3 * or later ("AGPL"), as published by the Free Software Foundation.
* or later ("AGPL"), as published by the Free Software Foundation.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
...@@ -13,24 +12,24 @@ ...@@ -13,24 +12,24 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <string>
#include <iostream> #include <iostream>
#include <string>
#include "index.h" #include "index.h"
#include "tutil.h"
#include "indexInt.h" #include "indexInt.h"
#include "index_fst.h" #include "index_fst.h"
#include "index_fst_util.h"
#include "index_fst_counting_writer.h" #include "index_fst_counting_writer.h"
#include "index_fst_util.h"
#include "index_tfile.h"
#include "tutil.h"
using namespace std;
class FstWriter { class FstWriter {
public: public:
FstWriter() { FstWriter() {
_wc = writerCtxCreate(TFile, "/tmp/tindex", false, 0); _wc = writerCtxCreate(TFile, "/tmp/tindex", false, 64 * 1024 * 1024);
_b = fstBuilderCreate(NULL, 0); _b = fstBuilderCreate(NULL, 0);
} }
bool Put(const std::string &key, uint64_t val) { bool Put(const std::string& key, uint64_t val) {
FstSlice skey = fstSliceCreate((uint8_t *)key.c_str(), key.size()); FstSlice skey = fstSliceCreate((uint8_t*)key.c_str(), key.size());
bool ok = fstBuilderInsert(_b, skey, val); bool ok = fstBuilderInsert(_b, skey, val);
fstSliceDestroy(&skey); fstSliceDestroy(&skey);
return ok; return ok;
...@@ -41,36 +40,37 @@ class FstWriter { ...@@ -41,36 +40,37 @@ class FstWriter {
writerCtxDestroy(_wc); writerCtxDestroy(_wc);
} }
private: private:
FstBuilder *_b; FstBuilder* _b;
WriterCtx *_wc; WriterCtx* _wc;
}; };
class FstReadMemory { class FstReadMemory {
public: public:
FstReadMemory(size_t size) { FstReadMemory(size_t size) {
_wc = writerCtxCreate(TFile, "/tmp/tindex", true, 0); _wc = writerCtxCreate(TFile, "/tmp/tindex", true, 64 * 1024);
_w = fstCountingWriterCreate(_wc); _w = fstCountingWriterCreate(_wc);
_size = size; _size = size;
memset((void *)&_s, 0, sizeof(_s)); memset((void*)&_s, 0, sizeof(_s));
} }
bool init() { bool init() {
char *buf = (char *)calloc(1, sizeof(char) * _size); char* buf = (char*)calloc(1, sizeof(char) * _size);
int nRead = fstCountingWriterRead(_w, (uint8_t *)buf, _size); int nRead = fstCountingWriterRead(_w, (uint8_t*)buf, _size);
if (nRead <= 0) { return false; } if (nRead <= 0) { return false; }
_size = nRead; _size = nRead;
_s = fstSliceCreate((uint8_t *)buf, _size); _s = fstSliceCreate((uint8_t*)buf, _size);
_fst = fstCreate(&_s); _fst = fstCreate(&_s);
free(buf); free(buf);
return _fst != NULL; return _fst != NULL;
} }
bool Get(const std::string &key, uint64_t *val) { bool Get(const std::string& key, uint64_t* val) {
FstSlice skey = fstSliceCreate((uint8_t *)key.c_str(), key.size()); FstSlice skey = fstSliceCreate((uint8_t*)key.c_str(), key.size());
bool ok = fstGet(_fst, &skey, val); bool ok = fstGet(_fst, &skey, val);
fstSliceDestroy(&skey); fstSliceDestroy(&skey);
return ok; return ok;
} }
bool GetWithTimeCostUs(const std::string &key, uint64_t *val, uint64_t *elapse) { bool GetWithTimeCostUs(const std::string& key, uint64_t* val, uint64_t* elapse) {
int64_t s = taosGetTimestampUs(); int64_t s = taosGetTimestampUs();
bool ok = this->Get(key, val); bool ok = this->Get(key, val);
int64_t e = taosGetTimestampUs(); int64_t e = taosGetTimestampUs();
...@@ -78,17 +78,17 @@ class FstReadMemory { ...@@ -78,17 +78,17 @@ class FstReadMemory {
return ok; return ok;
} }
// add later // add later
bool Search(AutomationCtx *ctx, std::vector<uint64_t> &result) { bool Search(AutomationCtx* ctx, std::vector<uint64_t>& result) {
FstStreamBuilder *sb = fstSearch(_fst, ctx); FstStreamBuilder* sb = fstSearch(_fst, ctx);
StreamWithState *st = streamBuilderIntoStream(sb); StreamWithState* st = streamBuilderIntoStream(sb);
StreamWithStateResult *rt = NULL; StreamWithStateResult* rt = NULL;
while ((rt = streamWithStateNextWith(st, NULL)) != NULL) { while ((rt = streamWithStateNextWith(st, NULL)) != NULL) {
result.push_back((uint64_t)(rt->out.out)); result.push_back((uint64_t)(rt->out.out));
} }
return true; return true;
} }
bool SearchWithTimeCostUs(AutomationCtx *ctx, std::vector<uint64_t> &result) { bool SearchWithTimeCostUs(AutomationCtx* ctx, std::vector<uint64_t>& result) {
int64_t s = taosGetTimestampUs(); int64_t s = taosGetTimestampUs();
bool ok = this->Search(ctx, result); bool ok = this->Search(ctx, result);
int64_t e = taosGetTimestampUs(); int64_t e = taosGetTimestampUs();
...@@ -103,15 +103,14 @@ class FstReadMemory { ...@@ -103,15 +103,14 @@ class FstReadMemory {
} }
private: private:
FstCountingWriter *_w; FstCountingWriter* _w;
Fst *_fst; Fst* _fst;
FstSlice _s; FstSlice _s;
WriterCtx *_wc; WriterCtx* _wc;
size_t _size; size_t _size;
}; };
//TEST(IndexTest, index_create_test) { // TEST(IndexTest, index_create_test) {
// SIndexOpts *opts = indexOptsCreate(); // SIndexOpts *opts = indexOptsCreate();
// SIndex *index = indexOpen(opts, "./test"); // SIndex *index = indexOpen(opts, "./test");
// if (index == NULL) { // if (index == NULL) {
...@@ -163,17 +162,16 @@ class FstReadMemory { ...@@ -163,17 +162,16 @@ class FstReadMemory {
// // // //
//} //}
#define L 100 #define L 100
#define M 100 #define M 100
#define N 100 #define N 100
int Performance_fstWriteRecords(FstWriter *b) { int Performance_fstWriteRecords(FstWriter* b) {
std::string str("aa"); std::string str("aa");
for (int i = 0; i < L; i++) { for (int i = 0; i < L; i++) {
str[0] = 'a' + i; str[0] = 'a' + i;
str.resize(2); str.resize(2);
for(int j = 0; j < M; j++) { for (int j = 0; j < M; j++) {
str[1] = 'a' + j; str[1] = 'a' + j;
str.resize(2); str.resize(2);
for (int k = 0; k < N; k++) { for (int k = 0; k < N; k++) {
...@@ -186,19 +184,19 @@ int Performance_fstWriteRecords(FstWriter *b) { ...@@ -186,19 +184,19 @@ int Performance_fstWriteRecords(FstWriter *b) {
return L * M * N; return L * M * N;
} }
void Performance_fstReadRecords(FstReadMemory *m) { void Performance_fstReadRecords(FstReadMemory* m) {
std::string str("aa"); std::string str("aa");
for (int i = 0; i < M; i++) { for (int i = 0; i < M; i++) {
str[0] = 'a' + i; str[0] = 'a' + i;
str.resize(2); str.resize(2);
for(int j = 0; j < N; j++) { for (int j = 0; j < N; j++) {
str[1] = 'a' + j; str[1] = 'a' + j;
str.resize(2); str.resize(2);
for (int k = 0; k < L; k++) { for (int k = 0; k < L; k++) {
str.push_back('a'); str.push_back('a');
uint64_t val, cost; uint64_t val, cost;
if (m->GetWithTimeCostUs(str, &val, &cost)) { if (m->GetWithTimeCostUs(str, &val, &cost)) {
printf("succes to get kv(%s, %" PRId64"), cost: %" PRId64"\n", str.c_str(), val, cost); printf("succes to get kv(%s, %" PRId64 "), cost: %" PRId64 "\n", str.c_str(), val, cost);
} else { } else {
printf("failed to get key: %s\n", str.c_str()); printf("failed to get key: %s\n", str.c_str());
} }
...@@ -207,24 +205,22 @@ void Performance_fstReadRecords(FstReadMemory *m) { ...@@ -207,24 +205,22 @@ void Performance_fstReadRecords(FstReadMemory *m) {
} }
} }
void checkFstPerf() { void checkFstPerf() {
FstWriter *fw = new FstWriter; FstWriter* fw = new FstWriter;
int64_t s = taosGetTimestampUs(); int64_t s = taosGetTimestampUs();
int num = Performance_fstWriteRecords(fw); int num = Performance_fstWriteRecords(fw);
int64_t e = taosGetTimestampUs(); int64_t e = taosGetTimestampUs();
printf("write %d record cost %" PRId64"us\n", num, e - s); printf("write %d record cost %" PRId64 "us\n", num, e - s);
delete fw; delete fw;
FstReadMemory *m = new FstReadMemory(1024 * 64); FstReadMemory* m = new FstReadMemory(1024 * 64);
if (m->init()) { if (m->init()) { printf("success to init fst read"); }
printf("success to init fst read");
}
Performance_fstReadRecords(m); Performance_fstReadRecords(m);
delete m; delete m;
} }
void checkFstPrefixSearch() { void checkFstPrefixSearch() {
FstWriter *fw = new FstWriter; FstWriter* fw = new FstWriter;
int64_t s = taosGetTimestampUs(); int64_t s = taosGetTimestampUs();
int count = 2; int count = 2;
std::string key("ab"); std::string key("ab");
...@@ -238,7 +234,7 @@ void checkFstPrefixSearch() { ...@@ -238,7 +234,7 @@ void checkFstPrefixSearch() {
std::cout << "insert data count : " << count << "elapas time: " << e - s << std::endl; std::cout << "insert data count : " << count << "elapas time: " << e - s << std::endl;
delete fw; delete fw;
FstReadMemory *m = new FstReadMemory(1024 * 64); FstReadMemory* m = new FstReadMemory(1024 * 64);
if (m->init() == false) { if (m->init() == false) {
std::cout << "init readMemory failed" << std::endl; std::cout << "init readMemory failed" << std::endl;
delete m; delete m;
...@@ -247,7 +243,8 @@ void checkFstPrefixSearch() { ...@@ -247,7 +243,8 @@ void checkFstPrefixSearch() {
// prefix search // prefix search
std::vector<uint64_t> result; std::vector<uint64_t> result;
AutomationCtx *ctx = automCtxCreate((void *)"ab", AUTOMATION_PREFIX);
AutomationCtx* ctx = automCtxCreate((void*)"ab", AUTOMATION_PREFIX);
m->Search(ctx, result); m->Search(ctx, result);
assert(result.size() == count); assert(result.size() == count);
for (int i = 0; i < result.size(); i++) { for (int i = 0; i < result.size(); i++) {
...@@ -260,7 +257,7 @@ void checkFstPrefixSearch() { ...@@ -260,7 +257,7 @@ void checkFstPrefixSearch() {
void validateFst() { void validateFst() {
int val = 100; int val = 100;
int count = 100; int count = 100;
FstWriter *fw = new FstWriter; FstWriter* fw = new FstWriter;
// write // write
{ {
std::string key("ab"); std::string key("ab");
...@@ -272,7 +269,7 @@ void validateFst() { ...@@ -272,7 +269,7 @@ void validateFst() {
delete fw; delete fw;
// read // read
FstReadMemory *m = new FstReadMemory(1024 * 64); FstReadMemory* m = new FstReadMemory(1024 * 64);
if (m->init() == false) { if (m->init() == false) {
std::cout << "init readMemory failed" << std::endl; std::cout << "init readMemory failed" << std::endl;
delete m; delete m;
...@@ -283,15 +280,15 @@ void validateFst() { ...@@ -283,15 +280,15 @@ void validateFst() {
std::string key("ab"); std::string key("ab");
uint64_t out; uint64_t out;
if (m->Get(key, &out)) { if (m->Get(key, &out)) {
printf("success to get (%s, %" PRId64")\n", key.c_str(), out); printf("success to get (%s, %" PRId64 ")\n", key.c_str(), out);
} else { } else {
printf("failed to get(%s)\n", key.c_str()); printf("failed to get(%s)\n", key.c_str());
} }
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
key.push_back('a' + i); key.push_back('a' + i);
if (m->Get(key, &out) ) { if (m->Get(key, &out)) {
assert(val - i == out); assert(val - i == out);
printf("success to get (%s, %" PRId64")\n", key.c_str(), out); printf("success to get (%s, %" PRId64 ")\n", key.c_str(), out);
} else { } else {
printf("failed to get(%s)\n", key.c_str()); printf("failed to get(%s)\n", key.c_str());
} }
...@@ -313,58 +310,214 @@ class IndexEnv : public ::testing::Test { ...@@ -313,58 +310,214 @@ class IndexEnv : public ::testing::Test {
indexOptsDestroy(opts); indexOptsDestroy(opts);
} }
const char *path = "/tmp/tindex"; const char* path = "/tmp/tindex";
SIndexOpts *opts; SIndexOpts* opts;
SIndex *index; SIndex* index;
}; };
TEST_F(IndexEnv, testPut) { // TEST_F(IndexEnv, testPut) {
// // single index column
// {
// std::string colName("tag1"), colVal("Hello world");
// SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), colVal.c_str(),
// colVal.size()); SIndexMultiTerm* terms = indexMultiTermCreate(); indexMultiTermAdd(terms, term);
//
// for (size_t i = 0; i < 100; i++) {
// int tableId = i;
// int ret = indexPut(index, terms, tableId);
// assert(ret == 0);
// }
// indexMultiTermDestroy(terms);
// }
// // multi index column
// {
// SIndexMultiTerm* terms = indexMultiTermCreate();
// {
// std::string colName("tag1"), colVal("Hello world");
// SIndexTerm* term =
// indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), colVal.c_str(), colVal.size());
// indexMultiTermAdd(terms, term);
// }
// {
// std::string colName("tag2"), colVal("Hello world");
// SIndexTerm* term =
// indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), colVal.c_str(), colVal.size());
// indexMultiTermAdd(terms, term);
// }
//
// for (int i = 0; i < 100; i++) {
// int tableId = i;
// int ret = indexPut(index, terms, tableId);
// assert(ret == 0);
// }
// indexMultiTermDestroy(terms);
// }
// //
//}
// single index column class TFileObj {
{ public:
TFileObj(const std::string& path = "/tmp/tindex", const std::string& colName = "voltage") : path_(path), colName_(colName) {
colId_ = 10;
// Do Nothing
//
}
int Put(SArray* tv) {
if (reader_ != NULL) {
tfileReaderDestroy(reader_);
reader_ = NULL;
}
if (writer_ == NULL) { InitWriter(); }
return tfileWriterPut(writer_, tv);
}
bool InitWriter() {
TFileHeader header;
header.suid = 1;
header.version = 1;
memcpy(header.colName, colName_.c_str(), colName_.size());
header.colType = TSDB_DATA_TYPE_BINARY;
std::string colName("tag1"), colVal("Hello world"); std::string path(path_);
SIndexTerm *term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), colVal.c_str(), colVal.size()); int colId = 2;
SIndexMultiTerm *terms = indexMultiTermCreate(); char buf[64] = {0};
indexMultiTermAdd(terms, term); sprintf(buf, "%" PRIu64 "-%d-%d.tindex", header.suid, colId_, header.version);
path.append("/").append(buf);
for (size_t i = 0; i < 100; i++) { fileName_ = path;
int tableId = i;
int ret = indexPut(index, terms, tableId); WriterCtx* ctx = writerCtxCreate(TFile, path.c_str(), false, 64 * 1024 * 1024);
assert(ret == 0);
writer_ = tfileWriterCreate(ctx, &header);
return writer_ != NULL ? true : false;
} }
indexMultiTermDestroy(terms); bool InitReader() {
WriterCtx* ctx = writerCtxCreate(TFile, fileName_.c_str(), true, 64 * 1024 * 1024);
reader_ = tfileReaderCreate(ctx);
return reader_ != NULL ? true : false;
} }
// multi index column int Get(SIndexTermQuery* query, SArray* result) {
{ if (writer_ != NULL) {
tfileWriterDestroy(writer_);
SIndexMultiTerm *terms = indexMultiTermCreate(); writer_ = NULL;
{
std::string colName("tag1"), colVal("Hello world");
SIndexTerm *term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), colVal.c_str(), colVal.size());
indexMultiTermAdd(terms, term);
} }
{ if (reader_ == NULL && InitReader()) {
std::string colName("tag2"), colVal("Hello world"); //
SIndexTerm *term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), colVal.c_str(), colVal.size()); //
indexMultiTermAdd(terms, term);
} }
return tfileReaderSearch(reader_, query, result);
for (int i = 0; i < 100; i++) {
int tableId = i;
int ret = indexPut(index, terms, tableId);
assert(ret == 0);
} }
indexMultiTermDestroy(terms); ~TFileObj() {
if (writer_) { tfileWriterDestroy(writer_); }
if (reader_) { tfileReaderDestroy(reader_); }
} }
//
}
TEST_F(IndexEnv, testDel) { private:
std::string path_;
std::string colName_;
std::string fileName_;
TFileWriter* writer_;
TFileReader* reader_;
int colId_;
};
class IndexTFileEnv : public ::testing::Test {
protected:
virtual void SetUp() {
taosRemoveDir(dir.c_str());
taosMkDir(dir.c_str());
tfInit();
fObj = new TFileObj(dir, colName);
// std::string colName("voltage");
// header.suid = 1;
// header.version = 1;
// memcpy(header.colName, colName.c_str(), colName.size());
// header.colType = TSDB_DATA_TYPE_BINARY;
// std::string path(dir);
// int colId = 2;
// char buf[64] = {0};
// sprintf(buf, "%" PRIu64 "-%d-%d.tindex", header.suid, colId, header.version);
// path.append("/").append(buf);
// ctx = writerCtxCreate(TFile, path.c_str(), false, 64 * 1024 * 1024);
// twrite = tfileWriterCreate(ctx, &header);
}
virtual void TearDown() {
// indexClose(index);
// indexeptsDestroy(opts);
delete fObj;
tfCleanup();
// tfileWriterDestroy(twrite);
}
TFileObj* fObj;
std::string dir = "/tmp/tindex";
std::string colName = "voltage";
int coldId = 2;
int version = 1;
int colType = TSDB_DATA_TYPE_BINARY;
// WriterCtx* ctx = NULL;
// TFileHeader header;
// TFileWriter* twrite = NULL;
};
// static TFileWriter* genTFileWriter(const char* path, TFileHeader* header) {
// char buf[128] = {0};
// WriterCtx* ctx = writerCtxCreate(TFile, path, false, )
//}
static TFileValue* genTFileValue(const char* val) {
TFileValue* tv = (TFileValue*)calloc(1, sizeof(TFileValue));
int32_t vlen = strlen(val) + 1;
tv->colVal = (char*)calloc(1, vlen);
memcpy(tv->colVal, val, vlen);
tv->tableId = (SArray*)taosArrayInit(1, sizeof(uint64_t));
for (size_t i = 0; i < 10; i++) {
uint64_t v = i;
taosArrayPush(tv->tableId, &v);
}
return tv;
}
static void destroyTFileValue(void* val) {
TFileValue* tv = (TFileValue*)val;
free(tv->colVal);
taosArrayDestroy(tv->tableId);
free(tv);
} }
TEST_F(IndexTFileEnv, test_tfile_write) {
TFileValue* v1 = genTFileValue("c");
TFileValue* v2 = genTFileValue("a");
TFileValue* v3 = genTFileValue("b");
TFileValue* v4 = genTFileValue("d");
SArray* data = (SArray*)taosArrayInit(4, sizeof(void*));
taosArrayPush(data, &v1);
taosArrayPush(data, &v2);
taosArrayPush(data, &v3);
taosArrayPush(data, &v4);
fObj->Put(data);
for (size_t i = 0; i < taosArrayGetSize(data); i++) {
destroyTFileValue(taosArrayGetP(data, i));
}
taosArrayDestroy(data);
std::string colName("voltage");
std::string colVal("b");
SIndexTerm* term = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), colVal.c_str(), colVal.size());
SIndexTermQuery query = {.term = term, .qType = QUERY_TERM};
SArray* result = (SArray*)taosArrayInit(1, sizeof(uint64_t));
fObj->Get(&query, result);
assert(taosArrayGetSize(result) == 10);
indexTermDestroy(term);
// tfileWriterDestroy(twrite);
}
...@@ -8,7 +8,8 @@ SCreateUserMsg* buildUserManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, in ...@@ -8,7 +8,8 @@ SCreateUserMsg* buildUserManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, in
SCreateAcctMsg* buildAcctManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id, char* msgBuf, int32_t msgLen); SCreateAcctMsg* buildAcctManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id, char* msgBuf, int32_t msgLen);
SDropUserMsg* buildDropUserMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id, char* msgBuf, int32_t msgLen); SDropUserMsg* buildDropUserMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id, char* msgBuf, int32_t msgLen);
SShowMsg* buildShowMsg(SShowInfo* pShowInfo, int64_t id, char* msgBuf, int32_t msgLen); SShowMsg* buildShowMsg(SShowInfo* pShowInfo, int64_t id, char* msgBuf, int32_t msgLen);
SCreateDbMsg* buildCreateDbMsg(SCreateDbInfo* pCreateDbInfo, char* msgBuf, int32_t msgLen); SCreateDbMsg* buildCreateDbMsg(SCreateDbInfo* pCreateDbInfo, SParseBasicCtx *pCtx, SMsgBuf* pMsgBuf);
SCreateStbMsg* buildCreateTableMsg(SCreateTableSql* pCreateTableSql, int32_t* len, SParseBasicCtx* pParseCtx, SMsgBuf* pMsgBuf); SCreateStbMsg* buildCreateTableMsg(SCreateTableSql* pCreateTableSql, int32_t* len, SParseBasicCtx* pParseCtx, SMsgBuf* pMsgBuf);
SDropTableMsg* buildDropTableMsg(SSqlInfo* pInfo, int32_t* len, SParseBasicCtx* pParseCtx, SMsgBuf* pMsgBuf);
#endif // TDENGINE_ASTTOMSG_H #endif // TDENGINE_ASTTOMSG_H
...@@ -68,7 +68,7 @@ int32_t qParserValidateSqlNode(struct SCatalog* pCatalog, SSqlInfo* pSqlInfo, SQ ...@@ -68,7 +68,7 @@ int32_t qParserValidateSqlNode(struct SCatalog* pCatalog, SSqlInfo* pSqlInfo, SQ
* @param type * @param type
* @return * @return
*/ */
int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, void** output, int32_t* outputLen, int32_t* type, char* msgBuf, int32_t msgBufLen); int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, SDclStmtInfo* pDcl, char* msgBuf, int32_t msgBufLen);
/** /**
* Evaluate the numeric and timestamp arithmetic expression in the WHERE clause. * Evaluate the numeric and timestamp arithmetic expression in the WHERE clause.
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "ttoken.h" #include "ttoken.h"
#include "ttokendef.h" #include "ttokendef.h"
#include "tvariant.h" #include "tvariant.h"
#include "parserInt.h"
} }
%syntax_error { %syntax_error {
...@@ -173,7 +174,7 @@ cmd ::= ALTER DNODE ids(X) ids(Y) ids(Z). { setDCLSqlElems(pInfo, TSDB_SQL ...@@ -173,7 +174,7 @@ cmd ::= ALTER DNODE ids(X) ids(Y) ids(Z). { setDCLSqlElems(pInfo, TSDB_SQL
cmd ::= ALTER LOCAL ids(X). { setDCLSqlElems(pInfo, TSDB_SQL_CFG_LOCAL, 1, &X); } cmd ::= ALTER LOCAL ids(X). { setDCLSqlElems(pInfo, TSDB_SQL_CFG_LOCAL, 1, &X); }
cmd ::= ALTER LOCAL ids(X) ids(Y). { setDCLSqlElems(pInfo, TSDB_SQL_CFG_LOCAL, 2, &X, &Y); } cmd ::= ALTER LOCAL ids(X) ids(Y). { setDCLSqlElems(pInfo, TSDB_SQL_CFG_LOCAL, 2, &X, &Y); }
cmd ::= ALTER DATABASE ids(X) alter_db_optr(Y). { SToken t = {0}; setCreateDbInfo(pInfo, TSDB_SQL_ALTER_DB, &X, &Y, &t);} cmd ::= ALTER DATABASE ids(X) alter_db_optr(Y). { SToken t = {0}; setCreateDbInfo(pInfo, TSDB_SQL_ALTER_DB, &X, &Y, &t);}
cmd ::= ALTER TOPIC ids(X) alter_topic_optr(Y). { SToken t = {0}; setCreateDbInfo(pInfo, TSDB_SQL_ALTER_DB, &X, &Y, &t);} //cmd ::= ALTER TOPIC ids(X) alter_topic_optr(Y). { SToken t = {0}; setCreateDbInfo(pInfo, TSDB_SQL_ALTER_DB, &X, &Y, &t);}
cmd ::= ALTER ACCOUNT ids(X) acct_optr(Z). { setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &X, NULL, &Z);} cmd ::= ALTER ACCOUNT ids(X) acct_optr(Z). { setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &X, NULL, &Z);}
cmd ::= ALTER ACCOUNT ids(X) PASS ids(Y) acct_optr(Z). { setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &X, &Y, &Z);} cmd ::= ALTER ACCOUNT ids(X) PASS ids(Y) acct_optr(Z). { setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &X, &Y, &Z);}
...@@ -203,7 +204,7 @@ cmd ::= CREATE DNODE ids(X). { setDCLSqlElems(pInfo, TSDB_SQL_CREATE_DNODE ...@@ -203,7 +204,7 @@ cmd ::= CREATE DNODE ids(X). { setDCLSqlElems(pInfo, TSDB_SQL_CREATE_DNODE
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);}
cmd ::= CREATE TOPIC ifnotexists(Z) ids(X) topic_optr(Y). { setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &X, &Y, &Z);} //cmd ::= CREATE TOPIC ifnotexists(Z) ids(X) topic_optr(Y). { setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &X, &Y, &Z);}
cmd ::= CREATE FUNCTION ids(X) AS ids(Y) OUTPUTTYPE typename(Z) bufsize(B). { setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &X, &Y, &Z, &B, 1);} cmd ::= CREATE FUNCTION ids(X) AS ids(Y) OUTPUTTYPE typename(Z) bufsize(B). { setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &X, &Y, &Z, &B, 1);}
cmd ::= CREATE AGGREGATE FUNCTION ids(X) AS ids(Y) OUTPUTTYPE typename(Z) bufsize(B). { setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &X, &Y, &Z, &B, 2);} cmd ::= CREATE AGGREGATE FUNCTION ids(X) AS ids(Y) OUTPUTTYPE typename(Z) bufsize(B). { setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &X, &Y, &Z, &B, 2);}
cmd ::= CREATE USER ids(X) PASS ids(Y). { setCreateUserSql(pInfo, &X, &Y);} cmd ::= CREATE USER ids(X) PASS ids(Y). { setCreateUserSql(pInfo, &X, &Y);}
...@@ -278,10 +279,10 @@ comp(Y) ::= COMP INTEGER(X). { Y = X; } ...@@ -278,10 +279,10 @@ comp(Y) ::= COMP INTEGER(X). { Y = X; }
prec(Y) ::= PRECISION STRING(X). { Y = X; } prec(Y) ::= PRECISION STRING(X). { Y = X; }
update(Y) ::= UPDATE INTEGER(X). { Y = X; } update(Y) ::= UPDATE INTEGER(X). { Y = X; }
cachelast(Y) ::= CACHELAST INTEGER(X). { Y = X; } cachelast(Y) ::= CACHELAST INTEGER(X). { Y = X; }
partitions(Y) ::= PARTITIONS INTEGER(X). { Y = X; } //partitions(Y) ::= PARTITIONS INTEGER(X). { Y = X; }
%type db_optr {SCreateDbInfo} %type db_optr {SCreateDbInfo}
db_optr(Y) ::= . {setDefaultCreateDbOption(&Y); Y.dbType = TSDB_DB_TYPE_DEFAULT;} db_optr(Y) ::= . {setDefaultCreateDbOption(&Y);}
db_optr(Y) ::= db_optr(Z) cache(X). { Y = Z; Y.cacheBlockSize = strtol(X.z, NULL, 10); } db_optr(Y) ::= db_optr(Z) cache(X). { Y = Z; Y.cacheBlockSize = strtol(X.z, NULL, 10); }
db_optr(Y) ::= db_optr(Z) replica(X). { Y = Z; Y.replica = strtol(X.z, NULL, 10); } db_optr(Y) ::= db_optr(Z) replica(X). { Y = Z; Y.replica = strtol(X.z, NULL, 10); }
...@@ -299,13 +300,13 @@ db_optr(Y) ::= db_optr(Z) keep(X). { Y = Z; Y.keep = X; } ...@@ -299,13 +300,13 @@ db_optr(Y) ::= db_optr(Z) keep(X). { Y = Z; Y.keep = X; }
db_optr(Y) ::= db_optr(Z) update(X). { Y = Z; Y.update = strtol(X.z, NULL, 10); } db_optr(Y) ::= db_optr(Z) update(X). { Y = Z; Y.update = strtol(X.z, NULL, 10); }
db_optr(Y) ::= db_optr(Z) cachelast(X). { Y = Z; Y.cachelast = strtol(X.z, NULL, 10); } db_optr(Y) ::= db_optr(Z) cachelast(X). { Y = Z; Y.cachelast = strtol(X.z, NULL, 10); }
%type topic_optr {SCreateDbInfo} //%type topic_optr {SCreateDbInfo}
//
topic_optr(Y) ::= db_optr(Z). { Y = Z; Y.dbType = TSDB_DB_TYPE_TOPIC; } //topic_optr(Y) ::= db_optr(Z). { Y = Z; Y.dbType = TSDB_DB_TYPE_TOPIC; }
topic_optr(Y) ::= topic_optr(Z) partitions(X). { Y = Z; Y.partitions = strtol(X.z, NULL, 10); } //topic_optr(Y) ::= topic_optr(Z) partitions(X). { Y = Z; Y.partitions = strtol(X.z, NULL, 10); }
%type alter_db_optr {SCreateDbInfo} %type alter_db_optr {SCreateDbInfo}
alter_db_optr(Y) ::= . { setDefaultCreateDbOption(&Y); Y.dbType = TSDB_DB_TYPE_DEFAULT;} alter_db_optr(Y) ::= . { setDefaultCreateDbOption(&Y);}
alter_db_optr(Y) ::= alter_db_optr(Z) replica(X). { Y = Z; Y.replica = strtol(X.z, NULL, 10); } alter_db_optr(Y) ::= alter_db_optr(Z) replica(X). { Y = Z; Y.replica = strtol(X.z, NULL, 10); }
alter_db_optr(Y) ::= alter_db_optr(Z) quorum(X). { Y = Z; Y.quorum = strtol(X.z, NULL, 10); } alter_db_optr(Y) ::= alter_db_optr(Z) quorum(X). { Y = Z; Y.quorum = strtol(X.z, NULL, 10); }
...@@ -319,10 +320,10 @@ alter_db_optr(Y) ::= alter_db_optr(Z) cachelast(X). { Y = Z; Y.cachelast = str ...@@ -319,10 +320,10 @@ alter_db_optr(Y) ::= alter_db_optr(Z) cachelast(X). { Y = Z; Y.cachelast = str
//alter_db_optr(Y) ::= alter_db_optr(Z) fsync(X). { Y = Z; Y.fsyncPeriod = strtol(X.z, NULL, 10); } //alter_db_optr(Y) ::= alter_db_optr(Z) fsync(X). { Y = Z; Y.fsyncPeriod = strtol(X.z, NULL, 10); }
//alter_db_optr(Y) ::= alter_db_optr(Z) wal(X). { Y = Z; Y.walLevel = strtol(X.z, NULL, 10); } not support yet //alter_db_optr(Y) ::= alter_db_optr(Z) wal(X). { Y = Z; Y.walLevel = strtol(X.z, NULL, 10); } not support yet
%type alter_topic_optr {SCreateDbInfo} //%type alter_topic_optr {SCreateDbInfo}
alter_topic_optr(Y) ::= alter_db_optr(Z). { Y = Z; Y.dbType = TSDB_DB_TYPE_TOPIC; } //alter_topic_optr(Y) ::= alter_db_optr(Z). { Y = Z; Y.dbType = TSDB_DB_TYPE_TOPIC; }
alter_topic_optr(Y) ::= alter_topic_optr(Z) partitions(X). { Y = Z; Y.partitions = strtol(X.z, NULL, 10); } //alter_topic_optr(Y) ::= alter_topic_optr(Z) partitions(X). { Y = Z; Y.partitions = strtol(X.z, NULL, 10); }
%type typename {SField} %type typename {SField}
typename(A) ::= ids(X). { typename(A) ::= ids(X). {
......
...@@ -130,88 +130,88 @@ ...@@ -130,88 +130,88 @@
#define TK_PRECISION 112 #define TK_PRECISION 112
#define TK_UPDATE 113 #define TK_UPDATE 113
#define TK_CACHELAST 114 #define TK_CACHELAST 114
#define TK_PARTITIONS 115 #define TK_UNSIGNED 115
#define TK_UNSIGNED 116 #define TK_TAGS 116
#define TK_TAGS 117 #define TK_USING 117
#define TK_USING 118 #define TK_NULL 118
#define TK_NULL 119 #define TK_NOW 119
#define TK_NOW 120 #define TK_SELECT 120
#define TK_SELECT 121 #define TK_UNION 121
#define TK_UNION 122 #define TK_ALL 122
#define TK_ALL 123 #define TK_DISTINCT 123
#define TK_DISTINCT 124 #define TK_FROM 124
#define TK_FROM 125 #define TK_VARIABLE 125
#define TK_VARIABLE 126 #define TK_INTERVAL 126
#define TK_INTERVAL 127 #define TK_EVERY 127
#define TK_EVERY 128 #define TK_SESSION 128
#define TK_SESSION 129 #define TK_STATE_WINDOW 129
#define TK_STATE_WINDOW 130 #define TK_FILL 130
#define TK_FILL 131 #define TK_SLIDING 131
#define TK_SLIDING 132 #define TK_ORDER 132
#define TK_ORDER 133 #define TK_BY 133
#define TK_BY 134 #define TK_ASC 134
#define TK_ASC 135 #define TK_GROUP 135
#define TK_GROUP 136 #define TK_HAVING 136
#define TK_HAVING 137 #define TK_LIMIT 137
#define TK_LIMIT 138 #define TK_OFFSET 138
#define TK_OFFSET 139 #define TK_SLIMIT 139
#define TK_SLIMIT 140 #define TK_SOFFSET 140
#define TK_SOFFSET 141 #define TK_WHERE 141
#define TK_WHERE 142 #define TK_RESET 142
#define TK_RESET 143 #define TK_QUERY 143
#define TK_QUERY 144 #define TK_SYNCDB 144
#define TK_SYNCDB 145 #define TK_ADD 145
#define TK_ADD 146 #define TK_COLUMN 146
#define TK_COLUMN 147 #define TK_MODIFY 147
#define TK_MODIFY 148 #define TK_TAG 148
#define TK_TAG 149 #define TK_CHANGE 149
#define TK_CHANGE 150 #define TK_SET 150
#define TK_SET 151 #define TK_KILL 151
#define TK_KILL 152 #define TK_CONNECTION 152
#define TK_CONNECTION 153 #define TK_STREAM 153
#define TK_STREAM 154 #define TK_COLON 154
#define TK_COLON 155 #define TK_ABORT 155
#define TK_ABORT 156 #define TK_AFTER 156
#define TK_AFTER 157 #define TK_ATTACH 157
#define TK_ATTACH 158 #define TK_BEFORE 158
#define TK_BEFORE 159 #define TK_BEGIN 159
#define TK_BEGIN 160 #define TK_CASCADE 160
#define TK_CASCADE 161 #define TK_CLUSTER 161
#define TK_CLUSTER 162 #define TK_CONFLICT 162
#define TK_CONFLICT 163 #define TK_COPY 163
#define TK_COPY 164 #define TK_DEFERRED 164
#define TK_DEFERRED 165 #define TK_DELIMITERS 165
#define TK_DELIMITERS 166 #define TK_DETACH 166
#define TK_DETACH 167 #define TK_EACH 167
#define TK_EACH 168 #define TK_END 168
#define TK_END 169 #define TK_EXPLAIN 169
#define TK_EXPLAIN 170 #define TK_FAIL 170
#define TK_FAIL 171 #define TK_FOR 171
#define TK_FOR 172 #define TK_IGNORE 172
#define TK_IGNORE 173 #define TK_IMMEDIATE 173
#define TK_IMMEDIATE 174 #define TK_INITIALLY 174
#define TK_INITIALLY 175 #define TK_INSTEAD 175
#define TK_INSTEAD 176 #define TK_KEY 176
#define TK_KEY 177 #define TK_OF 177
#define TK_OF 178 #define TK_RAISE 178
#define TK_RAISE 179 #define TK_REPLACE 179
#define TK_REPLACE 180 #define TK_RESTRICT 180
#define TK_RESTRICT 181 #define TK_ROW 181
#define TK_ROW 182 #define TK_STATEMENT 182
#define TK_STATEMENT 183 #define TK_TRIGGER 183
#define TK_TRIGGER 184 #define TK_VIEW 184
#define TK_VIEW 185 #define TK_IPTOKEN 185
#define TK_IPTOKEN 186 #define TK_SEMI 186
#define TK_SEMI 187 #define TK_NONE 187
#define TK_NONE 188 #define TK_PREV 188
#define TK_PREV 189 #define TK_LINEAR 189
#define TK_LINEAR 190 #define TK_IMPORT 190
#define TK_IMPORT 191 #define TK_TBNAME 191
#define TK_TBNAME 192 #define TK_JOIN 192
#define TK_JOIN 193 #define TK_INSERT 193
#define TK_INSERT 194 #define TK_INTO 194
#define TK_INTO 195 #define TK_VALUES 195
#define TK_VALUES 196
#define TK_SPACE 300 #define TK_SPACE 300
......
...@@ -207,17 +207,23 @@ int32_t setDbOptions(SCreateDbMsg* pCreateDbMsg, const SCreateDbInfo* pCreateDbS ...@@ -207,17 +207,23 @@ int32_t setDbOptions(SCreateDbMsg* pCreateDbMsg, const SCreateDbInfo* pCreateDbS
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
SCreateDbMsg* buildCreateDbMsg(SCreateDbInfo* pCreateDbInfo, char* msgBuf, int32_t msgLen) { SCreateDbMsg* buildCreateDbMsg(SCreateDbInfo* pCreateDbInfo, SParseBasicCtx *pCtx, SMsgBuf* pMsgBuf) {
SCreateDbMsg* pCreateMsg = calloc(1, sizeof(SCreateDbMsg)); SCreateDbMsg* pCreateMsg = calloc(1, sizeof(SCreateDbMsg));
if (setDbOptions(pCreateMsg, pCreateDbInfo, pMsgBuf) != TSDB_CODE_SUCCESS) {
SMsgBuf msg = {.buf = msgBuf, .len = msgLen};
if (setDbOptions(pCreateMsg, pCreateDbInfo, &msg) != TSDB_CODE_SUCCESS) {
tfree(pCreateMsg); tfree(pCreateMsg);
terrno = TSDB_CODE_TSC_INVALID_OPERATION; terrno = TSDB_CODE_TSC_INVALID_OPERATION;
return NULL; return NULL;
} }
SName name = {0};
int32_t ret = tNameSetDbName(&name, pCtx->acctId, pCreateDbInfo->dbname.z, pCreateDbInfo->dbname.n);
if (ret != TSDB_CODE_SUCCESS) {
terrno = ret;
return NULL;
}
tNameGetFullDbName(&name, pCreateMsg->db);
return pCreateMsg; return pCreateMsg;
} }
...@@ -263,14 +269,17 @@ int32_t createSName(SName* pName, SToken* pTableName, SParseBasicCtx* pParseCtx, ...@@ -263,14 +269,17 @@ int32_t createSName(SName* pName, SToken* pTableName, SParseBasicCtx* pParseCtx,
SCreateStbMsg* buildCreateTableMsg(SCreateTableSql* pCreateTableSql, int32_t* len, SParseBasicCtx* pParseCtx, SMsgBuf* pMsgBuf) { SCreateStbMsg* buildCreateTableMsg(SCreateTableSql* pCreateTableSql, int32_t* len, SParseBasicCtx* pParseCtx, SMsgBuf* pMsgBuf) {
SSchema* pSchema; SSchema* pSchema;
int32_t numOfTags = 0;
int32_t numOfCols = (int32_t) taosArrayGetSize(pCreateTableSql->colInfo.pColumns); int32_t numOfCols = (int32_t) taosArrayGetSize(pCreateTableSql->colInfo.pColumns);
int32_t numOfTags = (int32_t) taosArrayGetSize(pCreateTableSql->colInfo.pTagColumns); if (pCreateTableSql->colInfo.pTagColumns != NULL) {
numOfTags = (int32_t) taosArrayGetSize(pCreateTableSql->colInfo.pTagColumns);
}
SCreateStbMsg* pCreateTableMsg = (SCreateStbMsg*)calloc(1, sizeof(SCreateStbMsg) + (numOfCols + numOfTags) * sizeof(SSchema)); SCreateStbMsg* pCreateTableMsg = (SCreateStbMsg*)calloc(1, sizeof(SCreateStbMsg) + (numOfCols + numOfTags) * sizeof(SSchema));
char* pMsg = NULL; char* pMsg = NULL;
int8_t type = pCreateTableSql->type; int32_t tableType = pCreateTableSql->type;
if (type == TSQL_CREATE_TABLE) { // create by using super table, tags value if (tableType != TSQL_CREATE_TABLE && tableType != TSQL_CREATE_STABLE) { // create by using super table, tags value
#if 0 #if 0
SArray* list = pInfo->pCreateTableInfo->childTableInfo; SArray* list = pInfo->pCreateTableInfo->childTableInfo;
...@@ -310,14 +319,12 @@ SCreateStbMsg* buildCreateTableMsg(SCreateTableSql* pCreateTableSql, int32_t* le ...@@ -310,14 +319,12 @@ SCreateStbMsg* buildCreateTableMsg(SCreateTableSql* pCreateTableSql, int32_t* le
} }
pCreateTableMsg->igExists = pCreateTableSql->existCheck ? 1 : 0; pCreateTableMsg->igExists = pCreateTableSql->existCheck ? 1 : 0;
pCreateTableMsg->numOfColumns = htonl(numOfCols); pCreateTableMsg->numOfColumns = htonl(numOfCols);
pCreateTableMsg->numOfTags = htonl(numOfTags); pCreateTableMsg->numOfTags = htonl(numOfTags);
pSchema = (SSchema*) pCreateTableMsg->pSchema; pSchema = (SSchema*) pCreateTableMsg->pSchema;
for (int i = 0; i < numOfCols; ++i) { for (int i = 0; i < numOfCols; ++i) {
TAOS_FIELD* pField = taosArrayGet(pCreateTableSql->colInfo.pColumns, i); SField* pField = taosArrayGet(pCreateTableSql->colInfo.pColumns, i);
pSchema->type = pField->type; pSchema->type = pField->type;
pSchema->bytes = htonl(pField->bytes); pSchema->bytes = htonl(pField->bytes);
strcpy(pSchema->name, pField->name); strcpy(pSchema->name, pField->name);
...@@ -326,8 +333,7 @@ SCreateStbMsg* buildCreateTableMsg(SCreateTableSql* pCreateTableSql, int32_t* le ...@@ -326,8 +333,7 @@ SCreateStbMsg* buildCreateTableMsg(SCreateTableSql* pCreateTableSql, int32_t* le
} }
for(int32_t i = 0; i < numOfTags; ++i) { for(int32_t i = 0; i < numOfTags; ++i) {
TAOS_FIELD* pField = taosArrayGet(pCreateTableSql->colInfo.pTagColumns, i); SField* pField = taosArrayGet(pCreateTableSql->colInfo.pTagColumns, i);
pSchema->type = pField->type; pSchema->type = pField->type;
pSchema->bytes = htonl(pField->bytes); pSchema->bytes = htonl(pField->bytes);
strcpy(pSchema->name, pField->name); strcpy(pSchema->name, pField->name);
...@@ -343,3 +349,24 @@ SCreateStbMsg* buildCreateTableMsg(SCreateTableSql* pCreateTableSql, int32_t* le ...@@ -343,3 +349,24 @@ SCreateStbMsg* buildCreateTableMsg(SCreateTableSql* pCreateTableSql, int32_t* le
return pCreateTableMsg; return pCreateTableMsg;
} }
SDropTableMsg* buildDropTableMsg(SSqlInfo* pInfo, int32_t* len, SParseBasicCtx* pParseCtx, SMsgBuf* pMsgBuf) {
SToken* tableName = taosArrayGet(pInfo->pMiscInfo->a, 0);
SName name = {0};
int32_t code = createSName(&name, tableName, pParseCtx, pMsgBuf);
if (code != TSDB_CODE_SUCCESS) {
terrno = buildInvalidOperationMsg(pMsgBuf, "invalid table name");
return NULL;
}
SDropTableMsg *pDropTableMsg = (SDropTableMsg*) calloc(1, sizeof(SDropTableMsg));
code = tNameExtractFullName(&name, pDropTableMsg->name);
assert(code == TSDB_CODE_SUCCESS && name.type == TSDB_TABLE_NAME_T);
pDropTableMsg->ignoreNotExists = pInfo->pMiscInfo->existsCheck ? 1 : 0;
*len = sizeof(SDropTableMsg);
return pDropTableMsg;
}
...@@ -4028,7 +4028,7 @@ int32_t qParserValidateSqlNode(struct SCatalog* pCatalog, SSqlInfo* pInfo, SQuer ...@@ -4028,7 +4028,7 @@ int32_t qParserValidateSqlNode(struct SCatalog* pCatalog, SSqlInfo* pInfo, SQuer
} }
// todo remove it // todo remove it
static int32_t setShowInfo(struct SSqlInfo* pInfo, void** output, int32_t* msgLen, SMsgBuf* pMsgBuf) { static int32_t setShowInfo(SShowInfo* pShowInfo, SParseBasicCtx *pCtx, void** output, int32_t* outputLen, SMsgBuf* pMsgBuf) {
const char* msg1 = "invalid name"; const char* msg1 = "invalid name";
const char* msg2 = "wildcard string should be less than %d characters"; const char* msg2 = "wildcard string should be less than %d characters";
const char* msg3 = "database name too long"; const char* msg3 = "database name too long";
...@@ -4040,9 +4040,8 @@ static int32_t setShowInfo(struct SSqlInfo* pInfo, void** output, int32_t* msgLe ...@@ -4040,9 +4040,8 @@ static int32_t setShowInfo(struct SSqlInfo* pInfo, void** output, int32_t* msgLe
* database prefix in pInfo->pMiscInfo->a[0] * database prefix in pInfo->pMiscInfo->a[0]
* wildcard in like clause in pInfo->pMiscInfo->a[1] * wildcard in like clause in pInfo->pMiscInfo->a[1]
*/ */
SShowInfo* pShowInfo = &pInfo->pMiscInfo->showOpt;
int16_t showType = pShowInfo->showType; int16_t showType = pShowInfo->showType;
if (showType == TSDB_MGMT_TABLE_TABLE || showType == TSDB_MGMT_TABLE_VGROUP) { if (showType == TSDB_MGMT_TABLE_STB || showType == TSDB_MGMT_TABLE_VGROUP) {
SToken* pDbPrefixToken = &pShowInfo->prefix; SToken* pDbPrefixToken = &pShowInfo->prefix;
if (pDbPrefixToken->type != 0) { if (pDbPrefixToken->type != 0) {
if (pDbPrefixToken->n >= TSDB_DB_NAME_LEN) { // db name is too long if (pDbPrefixToken->n >= TSDB_DB_NAME_LEN) { // db name is too long
...@@ -4091,8 +4090,8 @@ static int32_t setShowInfo(struct SSqlInfo* pInfo, void** output, int32_t* msgLe ...@@ -4091,8 +4090,8 @@ static int32_t setShowInfo(struct SSqlInfo* pInfo, void** output, int32_t* msgLe
} }
} }
*output = buildShowMsg(pShowInfo, 0, pMsgBuf->buf, pMsgBuf->len); *output = buildShowMsg(pShowInfo, pCtx->requestId, pMsgBuf->buf, pMsgBuf->len);
*msgLen = sizeof(SShowMsg)/* + htons(pShowMsg->payloadLen)*/; *outputLen = sizeof(SShowMsg)/* + htons(pShowMsg->payloadLen)*/;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
...@@ -4246,7 +4245,7 @@ static int32_t validateTableColumnInfo(SArray* pFieldList, SMsgBuf* pMsgBuf) { ...@@ -4246,7 +4245,7 @@ static int32_t validateTableColumnInfo(SArray* pFieldList, SMsgBuf* pMsgBuf) {
const char* msg8 = "illegal number of columns"; const char* msg8 = "illegal number of columns";
// first column must be timestamp // first column must be timestamp
TAOS_FIELD* pField = taosArrayGet(pFieldList, 0); SField* pField = taosArrayGet(pFieldList, 0);
if (pField->type != TSDB_DATA_TYPE_TIMESTAMP) { if (pField->type != TSDB_DATA_TYPE_TIMESTAMP) {
return buildInvalidOperationMsg(pMsgBuf, msg1); return buildInvalidOperationMsg(pMsgBuf, msg1);
} }
...@@ -4274,7 +4273,7 @@ static int32_t validateTagParams(SArray* pTagsList, SArray* pFieldList, SMsgBuf* ...@@ -4274,7 +4273,7 @@ static int32_t validateTagParams(SArray* pTagsList, SArray* pFieldList, SMsgBuf*
// field name must be unique // field name must be unique
for (int32_t i = 0; i < numOfTags; ++i) { for (int32_t i = 0; i < numOfTags; ++i) {
TAOS_FIELD* p = taosArrayGet(pTagsList, i); SField* p = taosArrayGet(pTagsList, i);
if (has(pFieldList, 0, p->name) == true) { if (has(pFieldList, 0, p->name) == true) {
return buildInvalidOperationMsg(pMsgBuf, msg3); return buildInvalidOperationMsg(pMsgBuf, msg3);
} }
...@@ -4295,7 +4294,6 @@ int32_t doCheckForCreateTable(SSqlInfo* pInfo, SMsgBuf* pMsgBuf) { ...@@ -4295,7 +4294,6 @@ int32_t doCheckForCreateTable(SSqlInfo* pInfo, SMsgBuf* pMsgBuf) {
// if sql specifies db, use it, otherwise use default db // if sql specifies db, use it, otherwise use default db
SToken* pzTableName = &(pCreateTable->name); SToken* pzTableName = &(pCreateTable->name);
bool dbIncluded = false;
if (parserValidateNameToken(pzTableName) != TSDB_CODE_SUCCESS) { if (parserValidateNameToken(pzTableName) != TSDB_CODE_SUCCESS) {
return buildInvalidOperationMsg(pMsgBuf, msg1); return buildInvalidOperationMsg(pMsgBuf, msg1);
} }
...@@ -4308,14 +4306,12 @@ int32_t doCheckForCreateTable(SSqlInfo* pInfo, SMsgBuf* pMsgBuf) { ...@@ -4308,14 +4306,12 @@ int32_t doCheckForCreateTable(SSqlInfo* pInfo, SMsgBuf* pMsgBuf) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, void** output, int32_t* outputLen, int32_t* type, char* msgBuf, int32_t msgBufLen) { int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, SDclStmtInfo* pDcl, char* msgBuf, int32_t msgBufLen) {
int32_t code = 0; int32_t code = 0;
SMsgBuf m = {.buf = msgBuf, .len = msgBufLen}; SMsgBuf m = {.buf = msgBuf, .len = msgBufLen};
SMsgBuf *pMsgBuf = &m; SMsgBuf *pMsgBuf = &m;
*type = pInfo->type;
switch (pInfo->type) { switch (pInfo->type) {
case TSDB_SQL_CREATE_USER: case TSDB_SQL_CREATE_USER:
case TSDB_SQL_ALTER_USER: { case TSDB_SQL_ALTER_USER: {
...@@ -4361,7 +4357,8 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, void** ...@@ -4361,7 +4357,8 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, void**
} }
} }
*output = buildUserManipulationMsg(pInfo, outputLen, pCtx->requestId, msgBuf, msgBufLen); pDcl->pMsg = (char*)buildUserManipulationMsg(pInfo, &pDcl->msgLen, pCtx->requestId, msgBuf, msgBufLen);
pDcl->msgType = (pInfo->type == TSDB_SQL_CREATE_USER)? TSDB_MSG_TYPE_CREATE_USER:TSDB_MSG_TYPE_ALTER_USER;
break; break;
} }
...@@ -4397,18 +4394,21 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, void** ...@@ -4397,18 +4394,21 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, void**
} }
} }
*output = buildAcctManipulationMsg(pInfo, outputLen, pCtx->requestId, msgBuf, msgBufLen); pDcl->pMsg = (char*)buildAcctManipulationMsg(pInfo, &pDcl->msgLen, pCtx->requestId, msgBuf, msgBufLen);
pDcl->msgType = (pInfo->type == TSDB_SQL_CREATE_ACCT)? TSDB_MSG_TYPE_CREATE_ACCT:TSDB_MSG_TYPE_ALTER_ACCT;
break; break;
} }
case TSDB_SQL_DROP_ACCT: case TSDB_SQL_DROP_ACCT:
case TSDB_SQL_DROP_USER: { case TSDB_SQL_DROP_USER: {
*output = buildDropUserMsg(pInfo, outputLen, pCtx->requestId, msgBuf, msgBufLen); pDcl->pMsg = (char*)buildDropUserMsg(pInfo, &pDcl->msgLen, pCtx->requestId, msgBuf, msgBufLen);
pDcl->msgType = (pInfo->type == TSDB_SQL_DROP_ACCT)? TSDB_MSG_TYPE_DROP_ACCT:TSDB_MSG_TYPE_DROP_USER;
break; break;
} }
case TSDB_SQL_SHOW: { case TSDB_SQL_SHOW: {
code = setShowInfo(pInfo, output, outputLen, pMsgBuf); code = setShowInfo(&pInfo->pMiscInfo->showOpt, pCtx, (void**)&pDcl->pMsg, &pDcl->msgLen, pMsgBuf);
pDcl->msgType = TSDB_MSG_TYPE_SHOW;
break; break;
} }
...@@ -4429,8 +4429,9 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, void** ...@@ -4429,8 +4429,9 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, void**
SUseDbMsg *pUseDbMsg = (SUseDbMsg *) calloc(1, sizeof(SUseDbMsg)); SUseDbMsg *pUseDbMsg = (SUseDbMsg *) calloc(1, sizeof(SUseDbMsg));
tNameExtractFullName(&n, pUseDbMsg->db); tNameExtractFullName(&n, pUseDbMsg->db);
*output = pUseDbMsg; pDcl->pMsg = (char*)pUseDbMsg;
*outputLen = sizeof(SUseDbMsg); pDcl->msgLen = sizeof(SUseDbMsg);
pDcl->msgType = TSDB_MSG_TYPE_USE_DB;
break; break;
} }
...@@ -4451,18 +4452,41 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, void** ...@@ -4451,18 +4452,41 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, void**
return buildInvalidOperationMsg(pMsgBuf, msg1); return buildInvalidOperationMsg(pMsgBuf, msg1);
} }
SCreateDbMsg* pCreateMsg = buildCreateDbMsg(pCreateDB, pMsgBuf->buf, pMsgBuf->len); SCreateDbMsg* pCreateMsg = buildCreateDbMsg(pCreateDB, pCtx, pMsgBuf);
if (doCheckDbOptions(pCreateMsg, pMsgBuf) != TSDB_CODE_SUCCESS) { if (doCheckDbOptions(pCreateMsg, pMsgBuf) != TSDB_CODE_SUCCESS) {
return TSDB_CODE_TSC_INVALID_OPERATION; return TSDB_CODE_TSC_INVALID_OPERATION;
} }
strncpy(pCreateMsg->db, token.z, token.n); pDcl->pMsg = (char*)pCreateMsg;
pDcl->msgLen = sizeof(SCreateDbMsg);
*output = pCreateMsg; pDcl->msgType = (pInfo->type == TSDB_SQL_CREATE_DB)? TSDB_MSG_TYPE_CREATE_DB:TSDB_MSG_TYPE_ALTER_DB;
*outputLen = sizeof(SCreateDbMsg);
break; break;
} }
case TSDB_SQL_DROP_DB: {
const char* msg1 = "invalid database name";
assert(taosArrayGetSize(pInfo->pMiscInfo->a) == 1);
SToken* dbName = taosArrayGet(pInfo->pMiscInfo->a, 0);
SName name = {0};
code = tNameSetDbName(&name, pCtx->acctId, dbName->z, dbName->n);
if (code != TSDB_CODE_SUCCESS) {
return buildInvalidOperationMsg(pMsgBuf, msg1);
}
SDropDbMsg *pDropDbMsg = (SDropDbMsg*) calloc(1, sizeof(SDropDbMsg));
code = tNameExtractFullName(&name, pDropDbMsg->db);
pDropDbMsg->ignoreNotExists = pInfo->pMiscInfo->existsCheck ? 1 : 0;
assert(code == TSDB_CODE_SUCCESS && name.type == TSDB_DB_NAME_T);
pDcl->msgType = TSDB_MSG_TYPE_DROP_DB;
pDcl->msgLen = sizeof(SDropDbMsg);
pDcl->pMsg = (char*)pDropDbMsg;
return TSDB_CODE_SUCCESS;
}
case TSDB_SQL_CREATE_TABLE: { case TSDB_SQL_CREATE_TABLE: {
SCreateTableSql* pCreateTable = pInfo->pCreateTableInfo; SCreateTableSql* pCreateTable = pInfo->pCreateTableInfo;
...@@ -4470,7 +4494,8 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, void** ...@@ -4470,7 +4494,8 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, void**
if ((code = doCheckForCreateTable(pInfo, pMsgBuf)) != TSDB_CODE_SUCCESS) { if ((code = doCheckForCreateTable(pInfo, pMsgBuf)) != TSDB_CODE_SUCCESS) {
return code; return code;
} }
*output = buildCreateTableMsg(pCreateTable, outputLen, pCtx, pMsgBuf); pDcl->pMsg = (char*)buildCreateTableMsg(pCreateTable, &pDcl->msgLen, pCtx, pMsgBuf);
pDcl->msgType = (pCreateTable->type == TSQL_CREATE_TABLE)? TSDB_MSG_TYPE_CREATE_TABLE:TSDB_MSG_TYPE_CREATE_STB;
} else if (pCreateTable->type == TSQL_CREATE_CTABLE) { } else if (pCreateTable->type == TSQL_CREATE_CTABLE) {
// if ((code = doCheckForCreateFromStable(pSql, pInfo)) != TSDB_CODE_SUCCESS) { // if ((code = doCheckForCreateFromStable(pSql, pInfo)) != TSDB_CODE_SUCCESS) {
// return code; // return code;
...@@ -4483,6 +4508,18 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, void** ...@@ -4483,6 +4508,18 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, void**
break; break;
} }
case TSDB_SQL_DROP_TABLE: {
pDcl->pMsg = (char*)buildDropTableMsg(pInfo, &pDcl->msgLen, pCtx, pMsgBuf);
if (pDcl->pMsg == NULL) {
return terrno;
}
pDcl->msgType = TSDB_MSG_TYPE_DROP_STB;
return TSDB_CODE_SUCCESS;
break;
}
default: default:
break; break;
} }
......
...@@ -909,6 +909,7 @@ int32_t parseInsertSql(SParseContext* pContext, SInsertStmtInfo** pInfo) { ...@@ -909,6 +909,7 @@ int32_t parseInsertSql(SParseContext* pContext, SInsertStmtInfo** pInfo) {
} }
*pInfo = context.pOutput; *pInfo = context.pOutput;
context.pOutput->nodeType = TSDB_SQL_INSERT;
context.pOutput->schemaAttache = pContext->schemaAttached; context.pOutput->schemaAttache = pContext->schemaAttached;
context.pOutput->payloadType = PAYLOAD_TYPE_KV; context.pOutput->payloadType = PAYLOAD_TYPE_KV;
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include "function.h" #include "function.h"
#include "insertParser.h" #include "insertParser.h"
bool qIsInsertSql(const char* pStr, size_t length) { bool isInsertSql(const char* pStr, size_t length) {
int32_t index = 0; int32_t index = 0;
do { do {
...@@ -31,18 +31,28 @@ bool qIsInsertSql(const char* pStr, size_t length) { ...@@ -31,18 +31,28 @@ bool qIsInsertSql(const char* pStr, size_t length) {
} while (1); } while (1);
} }
int32_t qParseQuerySql(const char* pStr, size_t length, SParseBasicCtx* pParseCtx, int32_t *type, void** pOutput, int32_t* outputLen, char* msg, int32_t msgLen) { bool qIsDclQuery(const SQueryNode* pQuery) {
SSqlInfo info = doGenerateAST(pStr); return TSDB_SQL_INSERT != pQuery->type && TSDB_SQL_SELECT != pQuery->type;
}
int32_t parseQuerySql(SParseContext* pCxt, SQueryNode** pQuery) {
SSqlInfo info = doGenerateAST(pCxt->pSql);
if (!info.valid) { if (!info.valid) {
strncpy(msg, info.msg, msgLen); strncpy(pCxt->pMsg, info.msg, pCxt->msgLen);
terrno = TSDB_CODE_TSC_SQL_SYNTAX_ERROR; terrno = TSDB_CODE_TSC_SQL_SYNTAX_ERROR;
return terrno; return terrno;
} }
if (!isDqlSqlStatement(&info)) { if (!isDqlSqlStatement(&info)) {
int32_t code = qParserValidateDclSqlNode(&info, pParseCtx, pOutput, outputLen, type, msg, msgLen); SDclStmtInfo* pDcl = calloc(1, sizeof(SQueryStmtInfo));
if (NULL == pDcl) {
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; // set correct error code.
return terrno;
}
pDcl->nodeType = info.type;
int32_t code = qParserValidateDclSqlNode(&info, &pCxt->ctx, pDcl, pCxt->pMsg, pCxt->msgLen);
if (code == TSDB_CODE_SUCCESS) { if (code == TSDB_CODE_SUCCESS) {
// do nothing *pQuery = (SQueryNode*)pDcl;
} }
} else { } else {
SQueryStmtInfo* pQueryInfo = calloc(1, sizeof(SQueryStmtInfo)); SQueryStmtInfo* pQueryInfo = calloc(1, sizeof(SQueryStmtInfo));
...@@ -53,9 +63,9 @@ int32_t qParseQuerySql(const char* pStr, size_t length, SParseBasicCtx* pParseCt ...@@ -53,9 +63,9 @@ int32_t qParseQuerySql(const char* pStr, size_t length, SParseBasicCtx* pParseCt
struct SCatalog* pCatalog = NULL; struct SCatalog* pCatalog = NULL;
int32_t code = catalogGetHandle(NULL, &pCatalog); int32_t code = catalogGetHandle(NULL, &pCatalog);
code = qParserValidateSqlNode(pCatalog, &info, pQueryInfo, pParseCtx->requestId, msg, msgLen); code = qParserValidateSqlNode(pCatalog, &info, pQueryInfo, pCxt->ctx.requestId, pCxt->pMsg, pCxt->msgLen);
if (code == TSDB_CODE_SUCCESS) { if (code == TSDB_CODE_SUCCESS) {
*pOutput = pQueryInfo; *pQuery = (SQueryNode*)pQueryInfo;
} }
} }
...@@ -63,8 +73,12 @@ int32_t qParseQuerySql(const char* pStr, size_t length, SParseBasicCtx* pParseCt ...@@ -63,8 +73,12 @@ int32_t qParseQuerySql(const char* pStr, size_t length, SParseBasicCtx* pParseCt
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t qParseInsertSql(SParseContext* pContext, SInsertStmtInfo** pInfo) { int32_t qParseQuerySql(SParseContext* pCxt, SQueryNode** pQuery) {
return parseInsertSql(pContext, pInfo); if (isInsertSql(pCxt->pSql, pCxt->sqlLen)) {
return parseInsertSql(pCxt, (SInsertStmtInfo**)pQuery);
} else {
return parseQuerySql(pCxt, pQuery);
}
} }
int32_t qParserConvertSql(const char* pStr, size_t length, char** pConvertSql) { int32_t qParserConvertSql(const char* pStr, size_t length, char** pConvertSql) {
......
...@@ -31,11 +31,11 @@ ...@@ -31,11 +31,11 @@
#include <assert.h> #include <assert.h>
#include <stdbool.h> #include <stdbool.h>
#include "astGenerator.h" #include "astGenerator.h"
#include "parserInt.h"
#include "tmsgtype.h" #include "tmsgtype.h"
#include "ttoken.h" #include "ttoken.h"
#include "ttokendef.h" #include "ttokendef.h"
#include "tvariant.h" #include "tvariant.h"
#include "parserInt.h"
/**************** End of %include directives **********************************/ /**************** End of %include directives **********************************/
/* These constants specify the various numeric values for terminal symbols /* These constants specify the various numeric values for terminal symbols
** in a format understandable to "makeheaders". This section is blank unless ** in a format understandable to "makeheaders". This section is blank unless
...@@ -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 280 #define YYNOCODE 276
#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;
SCreatedTableInfo yy78; SSessionWindowVal yy39;
SCreateTableSql* yy110; SCreateDbInfo yy42;
int yy130; SVariant yy43;
SArray* yy135; int yy44;
SIntervalVal yy160; tSqlExpr* yy46;
SVariant yy191; SLimit yy55;
SLimit yy247; SCreatedTableInfo yy96;
SCreateDbInfo yy256; SArray* yy131;
SWindowStateVal yy258; SSqlNode* yy256;
int32_t yy262; SCreateTableSql* yy272;
SCreateAcctInfo yy277; SField yy290;
SField yy304; SSubclause* yy303;
SRelationInfo* yy460; int32_t yy310;
SSqlNode* yy488; SCreateAcctInfo yy341;
SSessionWindowVal yy511; int64_t yy459;
tSqlExpr* yy526; SIntervalVal yy530;
int64_t yy531; SWindowStateVal yy538;
SSubclause* yy551; SRelationInfo* 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 368 #define YYNSTATE 358
#define YYNRULE 295 #define YYNRULE 288
#define YYNTOKEN 197 #define YYNTOKEN 196
#define YY_MAX_SHIFT 367 #define YY_MAX_SHIFT 357
#define YY_MIN_SHIFTREDUCE 577 #define YY_MIN_SHIFTREDUCE 564
#define YY_MAX_SHIFTREDUCE 871 #define YY_MAX_SHIFTREDUCE 851
#define YY_ERROR_ACTION 872 #define YY_ERROR_ACTION 852
#define YY_ACCEPT_ACTION 873 #define YY_ACCEPT_ACTION 853
#define YY_NO_ACTION 874 #define YY_NO_ACTION 854
#define YY_MIN_REDUCE 875 #define YY_MIN_REDUCE 855
#define YY_MAX_REDUCE 1169 #define YY_MAX_REDUCE 1142
/************* 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,293 +206,287 @@ typedef union { ...@@ -206,293 +206,287 @@ 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 (776) #define YY_ACTTAB_COUNT (762)
static const YYACTIONTYPE yy_action[] = { static const YYACTIONTYPE yy_action[] = {
/* 0 */ 23, 629, 366, 236, 1054, 209, 242, 713, 212, 630, /* 0 */ 94, 615, 233, 244, 356, 227, 1004, 239, 243, 616,
/* 10 */ 1031, 873, 367, 59, 60, 174, 63, 64, 1044, 1145, /* 10 */ 615, 1004, 21, 55, 56, 241, 59, 60, 616, 1004,
/* 20 */ 256, 53, 52, 51, 629, 62, 324, 67, 65, 68, /* 20 */ 247, 49, 48, 47, 200, 58, 315, 63, 61, 64,
/* 30 */ 66, 158, 630, 286, 239, 58, 57, 344, 343, 56, /* 30 */ 62, 987, 988, 33, 991, 54, 53, 853, 357, 52,
/* 40 */ 55, 54, 59, 60, 248, 63, 64, 253, 1031, 256, /* 40 */ 51, 50, 55, 56, 97, 59, 60, 650, 248, 247,
/* 50 */ 53, 52, 51, 665, 62, 324, 67, 65, 68, 66, /* 50 */ 49, 48, 47, 201, 58, 315, 63, 61, 64, 62,
/* 60 */ 1001, 1044, 999, 1000, 58, 57, 210, 1002, 56, 55, /* 60 */ 976, 203, 974, 975, 54, 53, 203, 977, 52, 51,
/* 70 */ 54, 1003, 1051, 1004, 1005, 58, 57, 278, 216, 56, /* 70 */ 50, 978, 1119, 979, 980, 54, 53, 1119, 992, 52,
/* 80 */ 55, 54, 59, 60, 165, 63, 64, 38, 83, 256, /* 80 */ 51, 50, 55, 56, 1017, 59, 60, 159, 79, 247,
/* 90 */ 53, 52, 51, 89, 62, 324, 67, 65, 68, 66, /* 90 */ 49, 48, 47, 27, 58, 315, 63, 61, 64, 62,
/* 100 */ 284, 283, 250, 754, 58, 57, 1031, 212, 56, 55, /* 100 */ 269, 313, 693, 990, 54, 53, 203, 998, 52, 51,
/* 110 */ 54, 38, 59, 61, 808, 63, 64, 1044, 1146, 256, /* 110 */ 50, 345, 55, 57, 788, 59, 60, 1119, 36, 247,
/* 120 */ 53, 52, 51, 629, 62, 324, 67, 65, 68, 66, /* 120 */ 49, 48, 47, 615, 58, 315, 63, 61, 64, 62,
/* 130 */ 45, 630, 238, 240, 58, 57, 1028, 165, 56, 55, /* 130 */ 1017, 616, 335, 334, 54, 53, 152, 615, 52, 51,
/* 140 */ 54, 60, 1025, 63, 64, 773, 774, 256, 53, 52, /* 140 */ 50, 56, 36, 59, 60, 616, 230, 247, 49, 48,
/* 150 */ 51, 96, 62, 324, 67, 65, 68, 66, 165, 1093, /* 150 */ 47, 240, 58, 315, 63, 61, 64, 62, 159, 1066,
/* 160 */ 1027, 296, 58, 57, 89, 84, 56, 55, 54, 578, /* 160 */ 229, 287, 54, 53, 1001, 73, 52, 51, 50, 565,
/* 170 */ 579, 580, 581, 582, 583, 584, 585, 586, 587, 588, /* 170 */ 566, 567, 568, 569, 570, 571, 572, 573, 574, 575,
/* 180 */ 589, 590, 591, 156, 322, 237, 63, 64, 758, 249, /* 180 */ 576, 577, 578, 150, 237, 228, 59, 60, 1001, 313,
/* 190 */ 256, 53, 52, 51, 629, 62, 324, 67, 65, 68, /* 190 */ 247, 49, 48, 47, 250, 58, 315, 63, 61, 64,
/* 200 */ 66, 45, 630, 88, 1017, 58, 57, 362, 962, 56, /* 200 */ 62, 203, 275, 274, 74, 54, 53, 753, 754, 52,
/* 210 */ 55, 54, 1092, 44, 320, 361, 360, 319, 318, 317, /* 210 */ 51, 50, 1118, 42, 311, 351, 350, 310, 309, 308,
/* 220 */ 359, 316, 315, 314, 358, 313, 357, 356, 155, 153, /* 220 */ 349, 307, 306, 305, 348, 304, 347, 346, 289, 22,
/* 230 */ 152, 298, 24, 94, 993, 981, 982, 983, 984, 985, /* 230 */ 90, 970, 958, 959, 960, 961, 962, 963, 964, 965,
/* 240 */ 986, 987, 988, 989, 990, 991, 992, 994, 995, 215, /* 240 */ 966, 967, 968, 969, 971, 972, 212, 1017, 246, 803,
/* 250 */ 751, 255, 823, 924, 126, 812, 223, 815, 354, 818, /* 250 */ 36, 36, 792, 213, 795, 36, 798, 168, 36, 134,
/* 260 */ 193, 98, 140, 139, 138, 222, 354, 255, 823, 329, /* 260 */ 133, 132, 214, 231, 246, 803, 320, 85, 792, 251,
/* 270 */ 89, 812, 252, 815, 270, 818, 9, 29, 217, 67, /* 270 */ 795, 249, 798, 323, 322, 277, 63, 61, 64, 62,
/* 280 */ 65, 68, 66, 274, 273, 234, 235, 58, 57, 325, /* 280 */ 206, 255, 225, 226, 54, 53, 316, 85, 52, 51,
/* 290 */ 322, 56, 55, 54, 1014, 1015, 35, 1018, 814, 218, /* 290 */ 50, 12, 238, 324, 85, 93, 1001, 1001, 225, 226,
/* 300 */ 817, 234, 235, 259, 5, 41, 183, 45, 56, 55, /* 300 */ 325, 1000, 717, 43, 1001, 714, 261, 715, 207, 716,
/* 310 */ 54, 182, 107, 112, 103, 111, 38, 264, 737, 38, /* 310 */ 194, 192, 190, 159, 1027, 265, 264, 189, 138, 137,
/* 320 */ 934, 734, 742, 735, 743, 736, 165, 193, 257, 277, /* 320 */ 136, 135, 36, 43, 96, 268, 42, 77, 351, 350,
/* 330 */ 309, 81, 212, 38, 69, 124, 118, 129, 230, 813, /* 330 */ 43, 65, 84, 349, 221, 252, 253, 348, 36, 347,
/* 340 */ 1140, 816, 128, 1146, 134, 137, 127, 203, 201, 199, /* 340 */ 346, 3, 39, 175, 119, 113, 123, 65, 36, 103,
/* 350 */ 69, 261, 262, 131, 198, 144, 143, 142, 141, 38, /* 350 */ 107, 99, 106, 128, 131, 122, 257, 36, 254, 36,
/* 360 */ 44, 246, 361, 360, 247, 1028, 101, 359, 1028, 824, /* 360 */ 330, 329, 125, 159, 326, 804, 799, 300, 1001, 734,
/* 370 */ 819, 358, 38, 357, 356, 38, 820, 38, 333, 260, /* 370 */ 36, 121, 800, 52, 51, 50, 794, 256, 797, 1024,
/* 380 */ 38, 258, 1028, 332, 331, 824, 819, 790, 212, 365, /* 380 */ 327, 804, 799, 345, 1001, 1065, 173, 793, 800, 796,
/* 390 */ 364, 149, 820, 266, 38, 263, 38, 339, 338, 1146, /* 390 */ 331, 149, 147, 146, 1001, 355, 354, 143, 256, 332,
/* 400 */ 265, 95, 1019, 14, 334, 265, 82, 97, 1028, 86, /* 400 */ 256, 333, 903, 1001, 770, 1001, 78, 174, 185, 1002,
/* 410 */ 77, 179, 265, 3, 194, 87, 180, 335, 326, 821, /* 410 */ 352, 940, 337, 70, 92, 731, 1001, 913, 718, 719,
/* 420 */ 336, 1028, 340, 1029, 1028, 341, 1028, 925, 279, 1028, /* 420 */ 904, 82, 270, 185, 790, 83, 185, 750, 80, 760,
/* 430 */ 74, 1, 181, 770, 193, 738, 739, 100, 34, 342, /* 430 */ 761, 703, 292, 705, 294, 91, 37, 704, 989, 32,
/* 440 */ 1016, 346, 39, 1028, 789, 1028, 73, 160, 780, 781, /* 440 */ 7, 154, 826, 66, 24, 37, 37, 66, 95, 805,
/* 450 */ 78, 723, 73, 301, 725, 303, 724, 810, 254, 846, /* 450 */ 245, 66, 317, 738, 71, 614, 23, 69, 76, 208,
/* 460 */ 822, 825, 70, 26, 628, 39, 80, 39, 70, 99, /* 460 */ 769, 69, 791, 23, 14, 112, 13, 111, 16, 23,
/* 470 */ 70, 304, 75, 25, 16, 25, 15, 1139, 25, 117, /* 470 */ 15, 295, 4, 722, 720, 723, 721, 18, 118, 17,
/* 480 */ 6, 116, 18, 1138, 17, 740, 20, 741, 19, 123, /* 480 */ 117, 20, 1113, 19, 130, 129, 1112, 1111, 223, 692,
/* 490 */ 232, 122, 22, 233, 21, 811, 136, 135, 712, 213, /* 490 */ 224, 204, 205, 209, 202, 210, 801, 211, 216, 217,
/* 500 */ 275, 214, 219, 211, 220, 221, 225, 1030, 226, 227, /* 500 */ 218, 215, 199, 1003, 1138, 1130, 1019, 802, 1076, 1075,
/* 510 */ 224, 208, 1165, 1157, 1103, 1046, 1102, 244, 1099, 1098, /* 510 */ 235, 1072, 1071, 44, 236, 336, 266, 1058, 169, 151,
/* 520 */ 245, 345, 827, 157, 48, 1053, 1064, 1085, 1061, 1062, /* 520 */ 1026, 148, 1037, 1034, 1035, 1018, 272, 1057, 1039, 999,
/* 530 */ 1045, 1084, 281, 1066, 1026, 154, 159, 164, 292, 175, /* 530 */ 1015, 276, 153, 232, 278, 280, 31, 158, 283, 163,
/* 540 */ 176, 1024, 33, 285, 177, 168, 178, 939, 769, 306, /* 540 */ 170, 160, 997, 161, 749, 162, 164, 165, 166, 171,
/* 550 */ 307, 308, 311, 312, 1042, 46, 206, 42, 323, 933, /* 550 */ 172, 301, 917, 297, 290, 807, 284, 298, 299, 302,
/* 560 */ 330, 1164, 114, 241, 79, 1163, 287, 1160, 289, 76, /* 560 */ 303, 197, 40, 75, 314, 912, 321, 1137, 109, 72,
/* 570 */ 166, 299, 184, 337, 167, 1156, 50, 120, 1155, 297, /* 570 */ 46, 1136, 1133, 288, 176, 328, 1129, 115, 1128, 1125,
/* 580 */ 1152, 185, 295, 959, 43, 40, 47, 207, 921, 130, /* 580 */ 177, 286, 937, 41, 38, 198, 901, 279, 124, 899,
/* 590 */ 919, 132, 133, 917, 916, 267, 293, 196, 197, 913, /* 590 */ 126, 127, 897, 896, 258, 187, 188, 893, 892, 891,
/* 600 */ 912, 911, 910, 291, 909, 908, 907, 200, 202, 904, /* 600 */ 890, 889, 888, 282, 887, 191, 193, 884, 882, 880,
/* 610 */ 902, 900, 898, 204, 895, 205, 288, 891, 49, 310, /* 610 */ 878, 195, 875, 196, 871, 45, 120, 271, 81, 86,
/* 620 */ 280, 85, 90, 290, 355, 1086, 348, 125, 347, 349, /* 620 */ 338, 281, 1059, 339, 340, 341, 222, 343, 342, 242,
/* 630 */ 350, 351, 231, 352, 251, 305, 353, 363, 871, 269, /* 630 */ 296, 344, 353, 851, 259, 260, 219, 220, 850, 104,
/* 640 */ 870, 268, 271, 228, 229, 108, 938, 937, 109, 272, /* 640 */ 916, 915, 262, 263, 849, 832, 895, 894, 831, 267,
/* 650 */ 869, 852, 276, 851, 73, 10, 915, 300, 282, 914, /* 650 */ 291, 139, 69, 886, 180, 140, 179, 938, 178, 181,
/* 660 */ 745, 145, 188, 146, 187, 960, 186, 189, 190, 192, /* 660 */ 182, 184, 183, 939, 141, 885, 8, 142, 877, 2,
/* 670 */ 191, 906, 905, 961, 147, 997, 2, 30, 148, 897, /* 670 */ 1, 876, 725, 28, 273, 167, 87, 751, 155, 157,
/* 680 */ 896, 91, 171, 169, 172, 170, 173, 1007, 771, 4, /* 680 */ 762, 156, 234, 756, 88, 29, 758, 89, 285, 9,
/* 690 */ 161, 163, 782, 162, 243, 776, 92, 31, 778, 93, /* 690 */ 30, 10, 11, 25, 293, 26, 96, 98, 101, 34,
/* 700 */ 294, 11, 12, 32, 13, 27, 302, 28, 100, 102, /* 700 */ 100, 628, 35, 102, 663, 661, 660, 659, 657, 656,
/* 710 */ 105, 36, 104, 643, 37, 106, 678, 676, 675, 674, /* 710 */ 655, 652, 619, 312, 105, 5, 318, 806, 319, 6,
/* 720 */ 672, 671, 670, 667, 633, 321, 110, 7, 327, 328, /* 720 */ 808, 108, 110, 67, 68, 695, 37, 694, 691, 114,
/* 730 */ 828, 39, 826, 8, 113, 71, 115, 72, 715, 714, /* 730 */ 644, 116, 642, 634, 640, 636, 638, 632, 630, 665,
/* 740 */ 119, 711, 659, 121, 657, 649, 655, 651, 653, 647, /* 740 */ 664, 662, 658, 654, 653, 186, 617, 144, 582, 855,
/* 750 */ 645, 681, 680, 679, 677, 673, 669, 668, 195, 631, /* 750 */ 854, 854, 854, 854, 854, 854, 854, 854, 854, 854,
/* 760 */ 595, 875, 874, 874, 874, 874, 874, 874, 874, 874, /* 760 */ 854, 145,
/* 770 */ 874, 874, 874, 874, 150, 151,
}; };
static const YYCODETYPE yy_lookahead[] = { static const YYCODETYPE yy_lookahead[] = {
/* 0 */ 267, 1, 200, 201, 200, 267, 246, 5, 267, 9, /* 0 */ 206, 1, 242, 205, 199, 200, 246, 242, 205, 9,
/* 10 */ 250, 198, 199, 13, 14, 254, 16, 17, 248, 278, /* 10 */ 1, 246, 263, 13, 14, 242, 16, 17, 9, 246,
/* 20 */ 20, 21, 22, 23, 1, 25, 26, 27, 28, 29, /* 20 */ 20, 21, 22, 23, 263, 25, 26, 27, 28, 29,
/* 30 */ 30, 200, 9, 272, 264, 35, 36, 35, 36, 39, /* 30 */ 30, 237, 238, 239, 240, 35, 36, 197, 198, 39,
/* 40 */ 40, 41, 13, 14, 246, 16, 17, 207, 250, 20, /* 40 */ 40, 41, 13, 14, 206, 16, 17, 5, 205, 20,
/* 50 */ 21, 22, 23, 5, 25, 26, 27, 28, 29, 30, /* 50 */ 21, 22, 23, 263, 25, 26, 27, 28, 29, 30,
/* 60 */ 224, 248, 226, 227, 35, 36, 267, 231, 39, 40, /* 60 */ 221, 263, 223, 224, 35, 36, 263, 228, 39, 40,
/* 70 */ 41, 235, 268, 237, 238, 35, 36, 264, 267, 39, /* 70 */ 41, 232, 274, 234, 235, 35, 36, 274, 240, 39,
/* 80 */ 40, 41, 13, 14, 200, 16, 17, 200, 88, 20, /* 80 */ 40, 41, 13, 14, 244, 16, 17, 199, 88, 20,
/* 90 */ 21, 22, 23, 84, 25, 26, 27, 28, 29, 30, /* 90 */ 21, 22, 23, 84, 25, 26, 27, 28, 29, 30,
/* 100 */ 269, 270, 246, 39, 35, 36, 250, 267, 39, 40, /* 100 */ 260, 86, 5, 0, 35, 36, 263, 199, 39, 40,
/* 110 */ 41, 200, 13, 14, 85, 16, 17, 248, 278, 20, /* 110 */ 41, 92, 13, 14, 85, 16, 17, 274, 199, 20,
/* 120 */ 21, 22, 23, 1, 25, 26, 27, 28, 29, 30, /* 120 */ 21, 22, 23, 1, 25, 26, 27, 28, 29, 30,
/* 130 */ 121, 9, 245, 264, 35, 36, 249, 200, 39, 40, /* 130 */ 244, 9, 35, 36, 35, 36, 199, 1, 39, 40,
/* 140 */ 41, 14, 200, 16, 17, 127, 128, 20, 21, 22, /* 140 */ 41, 14, 199, 16, 17, 9, 260, 20, 21, 22,
/* 150 */ 23, 251, 25, 26, 27, 28, 29, 30, 200, 275, /* 150 */ 23, 243, 25, 26, 27, 28, 29, 30, 199, 271,
/* 160 */ 249, 277, 35, 36, 84, 265, 39, 40, 41, 47, /* 160 */ 241, 273, 35, 36, 245, 99, 39, 40, 41, 47,
/* 170 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, /* 170 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
/* 180 */ 58, 59, 60, 61, 86, 63, 16, 17, 124, 247, /* 180 */ 58, 59, 60, 61, 241, 63, 16, 17, 245, 86,
/* 190 */ 20, 21, 22, 23, 1, 25, 26, 27, 28, 29, /* 190 */ 20, 21, 22, 23, 70, 25, 26, 27, 28, 29,
/* 200 */ 30, 121, 9, 123, 0, 35, 36, 222, 223, 39, /* 200 */ 30, 263, 265, 266, 138, 35, 36, 126, 127, 39,
/* 210 */ 40, 41, 275, 100, 101, 102, 103, 104, 105, 106, /* 210 */ 40, 41, 274, 100, 101, 102, 103, 104, 105, 106,
/* 220 */ 107, 108, 109, 110, 111, 112, 113, 114, 64, 65, /* 220 */ 107, 108, 109, 110, 111, 112, 113, 114, 269, 46,
/* 230 */ 66, 273, 46, 275, 224, 225, 226, 227, 228, 229, /* 230 */ 271, 221, 222, 223, 224, 225, 226, 227, 228, 229,
/* 240 */ 230, 231, 232, 233, 234, 235, 236, 237, 238, 63, /* 240 */ 230, 231, 232, 233, 234, 235, 63, 244, 1, 2,
/* 250 */ 99, 1, 2, 206, 80, 5, 70, 7, 92, 9, /* 250 */ 199, 199, 5, 70, 7, 199, 9, 250, 199, 76,
/* 260 */ 213, 208, 76, 77, 78, 79, 92, 1, 2, 83, /* 260 */ 77, 78, 79, 260, 1, 2, 83, 84, 5, 145,
/* 270 */ 84, 5, 207, 7, 144, 9, 125, 84, 267, 27, /* 270 */ 7, 147, 9, 149, 150, 268, 27, 28, 29, 30,
/* 280 */ 28, 29, 30, 153, 154, 35, 36, 35, 36, 39, /* 280 */ 263, 70, 35, 36, 35, 36, 39, 84, 39, 40,
/* 290 */ 86, 39, 40, 41, 241, 242, 243, 244, 5, 267, /* 290 */ 41, 84, 241, 241, 84, 88, 245, 245, 35, 36,
/* 300 */ 7, 35, 36, 70, 64, 65, 66, 121, 39, 40, /* 300 */ 241, 245, 2, 120, 245, 5, 143, 7, 263, 9,
/* 310 */ 41, 71, 72, 73, 74, 75, 200, 70, 2, 200, /* 310 */ 64, 65, 66, 199, 199, 152, 153, 71, 72, 73,
/* 320 */ 206, 5, 5, 7, 7, 9, 200, 213, 207, 143, /* 320 */ 74, 75, 199, 120, 117, 142, 100, 144, 102, 103,
/* 330 */ 90, 145, 267, 200, 84, 64, 65, 66, 152, 5, /* 330 */ 120, 84, 122, 107, 151, 35, 36, 111, 199, 113,
/* 340 */ 267, 7, 71, 278, 73, 74, 75, 64, 65, 66, /* 340 */ 114, 64, 65, 66, 64, 65, 66, 84, 199, 72,
/* 350 */ 84, 35, 36, 82, 71, 72, 73, 74, 75, 200, /* 350 */ 73, 74, 75, 73, 74, 75, 145, 199, 147, 199,
/* 360 */ 100, 245, 102, 103, 245, 249, 208, 107, 249, 119, /* 360 */ 149, 150, 82, 199, 241, 118, 119, 90, 245, 39,
/* 370 */ 120, 111, 200, 113, 114, 200, 126, 200, 245, 146, /* 370 */ 199, 80, 125, 39, 40, 41, 5, 199, 7, 264,
/* 380 */ 200, 148, 249, 150, 151, 119, 120, 78, 267, 67, /* 380 */ 241, 118, 119, 92, 245, 271, 208, 5, 125, 7,
/* 390 */ 68, 69, 126, 146, 200, 148, 200, 150, 151, 278, /* 390 */ 241, 64, 65, 66, 245, 67, 68, 69, 199, 241,
/* 400 */ 200, 275, 244, 84, 245, 200, 208, 88, 249, 85, /* 400 */ 199, 241, 204, 245, 78, 245, 206, 208, 210, 208,
/* 410 */ 99, 211, 200, 204, 205, 85, 211, 245, 15, 126, /* 410 */ 219, 220, 241, 99, 247, 99, 245, 204, 118, 119,
/* 420 */ 245, 249, 245, 211, 249, 245, 249, 206, 85, 249, /* 420 */ 204, 85, 85, 210, 1, 85, 210, 85, 261, 85,
/* 430 */ 99, 209, 210, 85, 213, 119, 120, 118, 84, 245, /* 430 */ 85, 85, 85, 85, 85, 271, 99, 85, 238, 84,
/* 440 */ 242, 245, 99, 249, 135, 249, 122, 99, 85, 85, /* 440 */ 124, 99, 85, 99, 99, 99, 99, 99, 99, 85,
/* 450 */ 139, 85, 122, 85, 85, 85, 85, 1, 62, 85, /* 450 */ 62, 99, 15, 123, 140, 85, 99, 121, 84, 263,
/* 460 */ 126, 85, 99, 99, 85, 99, 84, 99, 99, 99, /* 460 */ 134, 121, 39, 99, 146, 146, 148, 148, 146, 99,
/* 470 */ 99, 117, 141, 99, 147, 99, 149, 267, 99, 147, /* 470 */ 148, 116, 84, 5, 5, 7, 7, 146, 146, 148,
/* 480 */ 84, 149, 147, 267, 149, 5, 147, 7, 149, 147, /* 480 */ 148, 146, 263, 148, 80, 81, 263, 263, 263, 115,
/* 490 */ 267, 149, 147, 267, 149, 39, 80, 81, 116, 267, /* 490 */ 263, 263, 263, 263, 263, 263, 125, 263, 263, 263,
/* 500 */ 200, 267, 267, 267, 267, 267, 267, 250, 267, 267, /* 500 */ 263, 263, 263, 246, 246, 246, 244, 125, 236, 236,
/* 510 */ 267, 267, 250, 250, 240, 248, 240, 240, 240, 240, /* 510 */ 236, 236, 236, 262, 236, 236, 199, 272, 248, 199,
/* 520 */ 240, 240, 119, 200, 266, 200, 200, 276, 200, 200, /* 520 */ 199, 62, 199, 199, 199, 244, 244, 272, 199, 244,
/* 530 */ 248, 276, 248, 200, 248, 62, 200, 200, 200, 252, /* 530 */ 259, 267, 199, 267, 267, 267, 249, 199, 199, 255,
/* 540 */ 200, 200, 253, 271, 200, 260, 200, 200, 126, 200, /* 540 */ 199, 258, 199, 257, 125, 256, 254, 253, 252, 199,
/* 550 */ 200, 200, 200, 200, 263, 200, 200, 200, 200, 200, /* 550 */ 199, 91, 199, 199, 132, 118, 129, 199, 199, 199,
/* 560 */ 200, 200, 200, 271, 138, 200, 271, 200, 271, 140, /* 560 */ 199, 199, 199, 137, 199, 199, 199, 199, 199, 139,
/* 570 */ 262, 133, 200, 200, 261, 200, 137, 200, 200, 136, /* 570 */ 136, 199, 199, 135, 199, 199, 199, 199, 199, 199,
/* 580 */ 200, 200, 131, 200, 200, 200, 200, 200, 200, 200, /* 580 */ 199, 130, 199, 199, 199, 199, 199, 131, 199, 199,
/* 590 */ 200, 200, 200, 200, 200, 200, 130, 200, 200, 200, /* 590 */ 199, 199, 199, 199, 199, 199, 199, 199, 199, 199,
/* 600 */ 200, 200, 200, 129, 200, 200, 200, 200, 200, 200, /* 600 */ 199, 199, 199, 128, 199, 199, 199, 199, 199, 199,
/* 610 */ 200, 200, 200, 200, 200, 200, 132, 200, 142, 91, /* 610 */ 199, 199, 199, 199, 199, 141, 98, 201, 201, 201,
/* 620 */ 202, 202, 202, 202, 115, 202, 53, 98, 97, 94, /* 620 */ 97, 201, 201, 53, 94, 96, 201, 95, 57, 201,
/* 630 */ 96, 57, 202, 95, 202, 202, 93, 86, 5, 5, /* 630 */ 201, 93, 86, 5, 154, 5, 201, 201, 5, 206,
/* 640 */ 5, 155, 155, 202, 202, 208, 212, 212, 208, 5, /* 640 */ 209, 209, 154, 5, 5, 102, 201, 201, 101, 143,
/* 650 */ 5, 102, 144, 101, 122, 84, 202, 117, 99, 202, /* 650 */ 116, 202, 121, 201, 212, 202, 216, 218, 217, 215,
/* 660 */ 85, 203, 215, 203, 219, 221, 220, 218, 216, 214, /* 660 */ 213, 211, 214, 220, 202, 201, 84, 202, 201, 203,
/* 670 */ 217, 202, 202, 223, 203, 239, 209, 84, 203, 202, /* 670 */ 207, 201, 85, 84, 99, 251, 99, 85, 84, 99,
/* 680 */ 202, 99, 257, 259, 256, 258, 255, 239, 85, 204, /* 680 */ 85, 84, 1, 85, 84, 99, 85, 84, 84, 133,
/* 690 */ 84, 99, 85, 84, 1, 85, 84, 99, 85, 84, /* 690 */ 99, 133, 84, 84, 116, 84, 117, 80, 72, 89,
/* 700 */ 84, 134, 134, 99, 84, 84, 117, 84, 118, 80, /* 700 */ 88, 5, 89, 88, 9, 5, 5, 5, 5, 5,
/* 710 */ 72, 89, 88, 5, 89, 88, 9, 5, 5, 5, /* 710 */ 5, 5, 87, 15, 80, 84, 26, 85, 61, 84,
/* 720 */ 5, 5, 5, 5, 87, 15, 80, 84, 26, 61, /* 720 */ 118, 148, 148, 16, 16, 5, 99, 5, 85, 148,
/* 730 */ 119, 99, 85, 84, 149, 16, 149, 16, 5, 5, /* 730 */ 5, 148, 5, 5, 5, 5, 5, 5, 5, 5,
/* 740 */ 149, 85, 5, 149, 5, 5, 5, 5, 5, 5, /* 740 */ 5, 5, 5, 5, 5, 99, 87, 21, 62, 0,
/* 750 */ 5, 5, 5, 5, 5, 5, 5, 5, 99, 87, /* 750 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275,
/* 760 */ 62, 0, 279, 279, 279, 279, 279, 279, 279, 279, /* 760 */ 275, 21, 275, 275, 275, 275, 275, 275, 275, 275,
/* 770 */ 279, 279, 279, 279, 21, 21, 279, 279, 279, 279, /* 770 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275,
/* 780 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, /* 780 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275,
/* 790 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, /* 790 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275,
/* 800 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, /* 800 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275,
/* 810 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, /* 810 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275,
/* 820 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, /* 820 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275,
/* 830 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, /* 830 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275,
/* 840 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, /* 840 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275,
/* 850 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, /* 850 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275,
/* 860 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, /* 860 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275,
/* 870 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, /* 870 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275,
/* 880 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, /* 880 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275,
/* 890 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, /* 890 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275,
/* 900 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, /* 900 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275,
/* 910 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, /* 910 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275,
/* 920 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, /* 920 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275,
/* 930 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, /* 930 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275,
/* 940 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, /* 940 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275,
/* 950 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, /* 950 */ 275, 275, 275, 275, 275, 275, 275, 275,
/* 960 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279,
/* 970 */ 279, 279, 279,
}; };
#define YY_SHIFT_COUNT (367) #define YY_SHIFT_COUNT (357)
#define YY_SHIFT_MIN (0) #define YY_SHIFT_MIN (0)
#define YY_SHIFT_MAX (761) #define YY_SHIFT_MAX (749)
static const unsigned short int yy_shift_ofst[] = { static const unsigned short int yy_shift_ofst[] = {
/* 0 */ 186, 113, 113, 260, 260, 98, 250, 266, 266, 193, /* 0 */ 183, 113, 226, 15, 247, 263, 263, 9, 136, 136,
/* 10 */ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, /* 10 */ 136, 136, 136, 136, 136, 136, 136, 136, 136, 136,
/* 20 */ 23, 23, 23, 0, 122, 266, 316, 316, 316, 9, /* 20 */ 136, 0, 122, 263, 300, 300, 300, 203, 203, 136,
/* 30 */ 9, 23, 23, 18, 23, 204, 23, 23, 23, 23, /* 30 */ 136, 81, 136, 103, 136, 136, 136, 136, 291, 15,
/* 40 */ 174, 98, 166, 166, 48, 776, 776, 776, 266, 266, /* 40 */ 19, 19, 42, 762, 263, 263, 263, 263, 263, 263,
/* 50 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, /* 50 */ 263, 263, 263, 263, 263, 263, 263, 263, 263, 263,
/* 60 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, /* 60 */ 263, 263, 263, 263, 263, 263, 300, 300, 300, 210,
/* 70 */ 316, 316, 316, 80, 2, 2, 2, 2, 2, 2, /* 70 */ 97, 97, 97, 97, 97, 97, 97, 136, 136, 136,
/* 80 */ 2, 23, 23, 23, 64, 23, 23, 23, 9, 9, /* 80 */ 330, 136, 136, 136, 203, 203, 136, 136, 136, 136,
/* 90 */ 23, 23, 23, 23, 309, 309, 151, 9, 23, 23, /* 90 */ 326, 326, 316, 203, 136, 136, 136, 136, 136, 136,
/* 100 */ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, /* 100 */ 136, 136, 136, 136, 136, 136, 136, 136, 136, 136,
/* 110 */ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, /* 110 */ 136, 136, 136, 136, 136, 136, 136, 136, 136, 136,
/* 120 */ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, /* 120 */ 136, 136, 136, 136, 136, 136, 136, 136, 136, 136,
/* 130 */ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, /* 130 */ 136, 136, 136, 136, 136, 136, 136, 136, 136, 136,
/* 140 */ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, /* 140 */ 136, 136, 136, 136, 136, 136, 136, 136, 136, 136,
/* 150 */ 23, 23, 23, 23, 23, 23, 23, 473, 473, 473, /* 150 */ 136, 459, 459, 459, 419, 419, 419, 419, 459, 459,
/* 160 */ 422, 422, 422, 422, 473, 473, 426, 429, 438, 439, /* 160 */ 426, 430, 422, 434, 438, 451, 427, 475, 456, 474,
/* 170 */ 443, 451, 466, 474, 484, 476, 473, 473, 473, 528, /* 170 */ 459, 459, 459, 460, 460, 15, 459, 459, 518, 523,
/* 180 */ 528, 509, 98, 98, 473, 473, 529, 531, 573, 535, /* 180 */ 570, 530, 529, 571, 532, 538, 42, 459, 459, 546,
/* 190 */ 534, 574, 538, 543, 509, 48, 473, 473, 551, 551, /* 190 */ 546, 459, 546, 459, 546, 459, 459, 762, 762, 29,
/* 200 */ 473, 551, 473, 551, 473, 473, 776, 776, 29, 69, /* 200 */ 69, 69, 99, 69, 127, 170, 249, 249, 249, 249,
/* 210 */ 69, 99, 69, 127, 170, 240, 252, 252, 252, 252, /* 210 */ 249, 249, 277, 246, 280, 40, 40, 40, 40, 124,
/* 220 */ 252, 252, 271, 283, 40, 40, 40, 40, 233, 247, /* 220 */ 211, 163, 207, 334, 334, 371, 382, 328, 327, 337,
/* 230 */ 130, 319, 269, 269, 293, 334, 322, 164, 343, 324, /* 230 */ 336, 340, 342, 344, 345, 314, 66, 346, 347, 348,
/* 240 */ 330, 348, 363, 364, 331, 311, 366, 368, 369, 370, /* 240 */ 349, 352, 355, 357, 364, 423, 388, 437, 370, 318,
/* 250 */ 371, 354, 374, 376, 456, 396, 403, 379, 327, 332, /* 250 */ 319, 322, 468, 469, 331, 332, 374, 335, 404, 628,
/* 260 */ 335, 317, 480, 339, 342, 382, 345, 416, 633, 486, /* 260 */ 480, 630, 633, 488, 638, 639, 543, 547, 506, 531,
/* 270 */ 634, 635, 487, 644, 645, 549, 552, 508, 532, 540, /* 270 */ 534, 582, 587, 589, 575, 577, 592, 594, 595, 597,
/* 280 */ 571, 575, 593, 559, 582, 603, 606, 607, 609, 610, /* 280 */ 598, 580, 600, 601, 603, 681, 604, 586, 556, 591,
/* 290 */ 592, 612, 613, 615, 693, 616, 598, 567, 604, 568, /* 290 */ 558, 608, 534, 609, 578, 611, 579, 617, 610, 612,
/* 300 */ 620, 540, 621, 589, 623, 590, 629, 622, 624, 638, /* 300 */ 626, 696, 613, 615, 695, 700, 701, 702, 703, 704,
/* 310 */ 708, 625, 627, 707, 712, 713, 714, 715, 716, 717, /* 310 */ 705, 706, 625, 698, 634, 631, 632, 602, 635, 690,
/* 320 */ 718, 637, 710, 646, 643, 647, 611, 649, 702, 668, /* 320 */ 657, 707, 573, 574, 627, 627, 627, 627, 708, 581,
/* 330 */ 719, 585, 587, 632, 632, 632, 632, 721, 591, 594, /* 330 */ 583, 627, 627, 627, 720, 722, 643, 627, 725, 727,
/* 340 */ 632, 632, 632, 733, 734, 656, 632, 737, 739, 740, /* 340 */ 728, 729, 730, 731, 732, 733, 734, 735, 736, 737,
/* 350 */ 741, 742, 743, 744, 745, 746, 747, 748, 749, 750, /* 350 */ 738, 739, 646, 659, 726, 740, 686, 749,
/* 360 */ 751, 752, 659, 672, 753, 754, 698, 761,
}; };
#define YY_REDUCE_COUNT (207) #define YY_REDUCE_COUNT (198)
#define YY_REDUCE_MIN (-267) #define YY_REDUCE_MIN (-251)
#define YY_REDUCE_MAX (485) #define YY_REDUCE_MAX (470)
static const short yy_reduce_ofst[] = { static const short yy_reduce_ofst[] = {
/* 0 */ -187, 10, 10, -164, -164, 53, -160, 65, 121, -169, /* 0 */ -160, 10, -161, -206, -202, -197, -157, -63, -81, -112,
/* 10 */ -113, -116, -42, 116, 119, 133, 159, 172, 175, 177, /* 10 */ -41, -57, 51, 52, 59, 123, 139, 149, 158, 160,
/* 20 */ 180, 194, 196, -196, -198, -259, -240, -202, -144, -230, /* 20 */ 171, 115, -195, -62, -240, -235, -227, -114, 3, 114,
/* 30 */ -131, -63, 126, -239, -58, 158, 200, 205, 212, -89, /* 30 */ 164, 7, -92, -162, 178, 199, 201, 56, 198, 200,
/* 40 */ 47, 198, 114, 221, -15, -100, 222, 209, -267, -262, /* 40 */ 213, 216, 191, 167, -251, -239, -210, 17, 45, 196,
/* 50 */ -201, -189, 11, 32, 73, 210, 216, 223, 226, 232, /* 50 */ 219, 223, 224, 225, 227, 228, 229, 230, 231, 232,
/* 60 */ 234, 235, 236, 237, 238, 239, 241, 242, 243, 244, /* 60 */ 234, 235, 236, 237, 238, 239, 257, 258, 259, 262,
/* 70 */ 257, 262, 263, 267, 274, 276, 277, 278, 279, 280, /* 70 */ 272, 273, 274, 275, 276, 278, 279, 317, 320, 321,
/* 80 */ 281, 300, 323, 325, 258, 326, 328, 329, 282, 284, /* 80 */ 251, 323, 324, 325, 281, 282, 329, 333, 338, 339,
/* 90 */ 333, 336, 337, 338, 251, 255, 287, 286, 340, 341, /* 90 */ 245, 255, 270, 285, 341, 343, 350, 351, 353, 354,
/* 100 */ 344, 346, 347, 349, 350, 351, 352, 353, 355, 356, /* 100 */ 358, 359, 360, 361, 362, 363, 365, 366, 367, 368,
/* 110 */ 357, 358, 359, 360, 361, 362, 365, 367, 372, 373, /* 110 */ 369, 372, 373, 375, 376, 377, 378, 379, 380, 381,
/* 120 */ 375, 377, 378, 380, 381, 383, 384, 385, 386, 387, /* 120 */ 383, 384, 385, 386, 387, 389, 390, 391, 392, 393,
/* 130 */ 388, 389, 390, 391, 392, 393, 394, 395, 397, 398, /* 130 */ 394, 395, 396, 397, 398, 399, 400, 401, 402, 403,
/* 140 */ 399, 400, 401, 402, 404, 405, 406, 407, 408, 409, /* 140 */ 405, 406, 407, 408, 409, 410, 411, 412, 413, 414,
/* 150 */ 410, 411, 412, 413, 414, 415, 417, 418, 419, 420, /* 150 */ 415, 416, 417, 418, 264, 266, 267, 268, 420, 421,
/* 160 */ 272, 292, 295, 297, 421, 423, 291, 308, 313, 285, /* 160 */ 271, 283, 286, 289, 284, 292, 294, 296, 424, 287,
/* 170 */ 424, 427, 425, 428, 431, 289, 430, 432, 433, 434, /* 170 */ 425, 428, 429, 431, 432, 433, 435, 436, 439, 441,
/* 180 */ 435, 436, 437, 440, 441, 442, 444, 446, 445, 447, /* 180 */ 440, 442, 444, 447, 448, 450, 443, 445, 446, 449,
/* 190 */ 449, 452, 453, 455, 448, 450, 454, 457, 458, 460, /* 190 */ 453, 452, 462, 464, 465, 467, 470, 463, 466,
/* 200 */ 469, 471, 470, 475, 477, 478, 467, 485,
}; };
static const YYACTIONTYPE yy_default[] = { static const YYACTIONTYPE yy_default[] = {
/* 0 */ 872, 996, 935, 1006, 922, 932, 1148, 1148, 1148, 872, /* 0 */ 852, 914, 902, 911, 1121, 1121, 1121, 852, 852, 852,
/* 10 */ 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, /* 10 */ 852, 852, 852, 852, 852, 852, 852, 852, 852, 852,
/* 20 */ 872, 872, 872, 1055, 892, 1148, 872, 872, 872, 872, /* 20 */ 852, 1028, 872, 1121, 852, 852, 852, 852, 852, 852,
/* 30 */ 872, 872, 872, 1070, 872, 932, 872, 872, 872, 872, /* 30 */ 852, 1043, 852, 911, 852, 852, 852, 852, 920, 911,
/* 40 */ 942, 932, 942, 942, 872, 1050, 980, 998, 872, 872, /* 40 */ 920, 920, 852, 1023, 852, 852, 852, 852, 852, 852,
/* 50 */ 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, /* 50 */ 852, 852, 852, 852, 852, 852, 852, 852, 852, 852,
/* 60 */ 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, /* 60 */ 852, 852, 852, 852, 852, 852, 852, 852, 852, 852,
/* 70 */ 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, /* 70 */ 852, 852, 852, 852, 852, 852, 852, 852, 852, 852,
/* 80 */ 872, 872, 872, 872, 1057, 1063, 1060, 872, 872, 872, /* 80 */ 1030, 1036, 1033, 852, 852, 852, 1038, 852, 852, 852,
/* 90 */ 1065, 872, 872, 872, 1089, 1089, 1048, 872, 872, 872, /* 90 */ 1062, 1062, 1021, 852, 852, 852, 852, 852, 852, 852,
/* 100 */ 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, /* 100 */ 852, 852, 852, 852, 852, 852, 852, 852, 852, 852,
/* 110 */ 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, /* 110 */ 852, 852, 852, 852, 852, 852, 852, 852, 852, 852,
/* 120 */ 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, /* 120 */ 852, 852, 852, 852, 900, 852, 898, 852, 852, 852,
/* 130 */ 920, 872, 918, 872, 872, 872, 872, 872, 872, 872, /* 130 */ 852, 852, 852, 852, 852, 852, 852, 852, 852, 852,
/* 140 */ 872, 872, 872, 872, 872, 872, 872, 872, 872, 903, /* 140 */ 852, 852, 852, 883, 852, 852, 852, 852, 852, 852,
/* 150 */ 872, 872, 872, 872, 872, 872, 890, 894, 894, 894, /* 150 */ 870, 874, 874, 874, 852, 852, 852, 852, 874, 874,
/* 160 */ 872, 872, 872, 872, 894, 894, 1096, 1100, 1082, 1094, /* 160 */ 1069, 1073, 1055, 1067, 1063, 1050, 1048, 1046, 1054, 1077,
/* 170 */ 1090, 1077, 1075, 1073, 1081, 1104, 894, 894, 894, 940, /* 170 */ 874, 874, 874, 918, 918, 911, 874, 874, 936, 934,
/* 180 */ 940, 936, 932, 932, 894, 894, 958, 956, 954, 946, /* 180 */ 932, 924, 930, 926, 928, 922, 852, 874, 874, 909,
/* 190 */ 952, 948, 950, 944, 923, 872, 894, 894, 930, 930, /* 190 */ 909, 874, 909, 874, 909, 874, 874, 957, 973, 852,
/* 200 */ 894, 930, 894, 930, 894, 894, 980, 998, 872, 1105, /* 200 */ 1078, 1068, 852, 1120, 1108, 1107, 1116, 1115, 1114, 1106,
/* 210 */ 1095, 872, 1147, 1135, 1134, 872, 1143, 1142, 1141, 1133, /* 210 */ 1105, 1104, 852, 852, 852, 1100, 1103, 1102, 1101, 852,
/* 220 */ 1132, 1131, 872, 872, 1127, 1130, 1129, 1128, 872, 872, /* 220 */ 852, 852, 852, 1110, 1109, 852, 852, 852, 852, 852,
/* 230 */ 872, 872, 1137, 1136, 872, 872, 872, 872, 872, 872, /* 230 */ 852, 852, 852, 852, 852, 1074, 1070, 852, 852, 852,
/* 240 */ 872, 872, 872, 872, 1101, 1097, 872, 872, 872, 872, /* 240 */ 852, 852, 852, 852, 852, 852, 1080, 852, 852, 852,
/* 250 */ 872, 872, 872, 872, 872, 1107, 872, 872, 872, 872, /* 250 */ 852, 852, 852, 852, 852, 852, 981, 852, 852, 852,
/* 260 */ 872, 872, 872, 872, 872, 1008, 872, 872, 872, 872, /* 260 */ 852, 852, 852, 852, 852, 852, 852, 852, 852, 1020,
/* 270 */ 872, 872, 872, 872, 872, 872, 872, 872, 1047, 872, /* 270 */ 852, 852, 852, 852, 1032, 1031, 852, 852, 852, 852,
/* 280 */ 872, 872, 872, 1059, 1058, 872, 872, 872, 872, 872, /* 280 */ 852, 852, 852, 852, 852, 852, 852, 1064, 852, 1056,
/* 290 */ 872, 872, 872, 872, 872, 872, 1091, 872, 1083, 872, /* 290 */ 852, 852, 993, 852, 852, 852, 852, 852, 852, 852,
/* 300 */ 872, 1020, 872, 872, 872, 872, 872, 872, 872, 872, /* 300 */ 852, 852, 852, 852, 852, 852, 852, 852, 852, 852,
/* 310 */ 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, /* 310 */ 852, 852, 852, 852, 852, 852, 852, 852, 852, 852,
/* 320 */ 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, /* 320 */ 852, 852, 852, 852, 1139, 1134, 1135, 1132, 852, 852,
/* 330 */ 872, 872, 872, 1166, 1161, 1162, 1159, 872, 872, 872, /* 330 */ 852, 1131, 1126, 1127, 852, 852, 852, 1124, 852, 852,
/* 340 */ 1158, 1153, 1154, 872, 872, 872, 1151, 872, 872, 872, /* 340 */ 852, 852, 852, 852, 852, 852, 852, 852, 852, 852,
/* 350 */ 872, 872, 872, 872, 872, 872, 872, 872, 872, 872, /* 350 */ 852, 852, 942, 852, 881, 879, 852, 852,
/* 360 */ 872, 872, 964, 872, 901, 899, 872, 872,
}; };
/********** End of lemon-generated parsing tables *****************************/ /********** End of lemon-generated parsing tables *****************************/
...@@ -627,7 +621,6 @@ static const YYCODETYPE yyFallback[] = { ...@@ -627,7 +621,6 @@ static const YYCODETYPE yyFallback[] = {
0, /* PRECISION => nothing */ 0, /* PRECISION => nothing */
0, /* UPDATE => nothing */ 0, /* UPDATE => nothing */
0, /* CACHELAST => nothing */ 0, /* CACHELAST => nothing */
0, /* PARTITIONS => nothing */
0, /* UNSIGNED => nothing */ 0, /* UNSIGNED => nothing */
0, /* TAGS => nothing */ 0, /* TAGS => nothing */
0, /* USING => nothing */ 0, /* USING => nothing */
...@@ -910,170 +903,166 @@ static const char *const yyTokenName[] = { ...@@ -910,170 +903,166 @@ static const char *const yyTokenName[] = {
/* 112 */ "PRECISION", /* 112 */ "PRECISION",
/* 113 */ "UPDATE", /* 113 */ "UPDATE",
/* 114 */ "CACHELAST", /* 114 */ "CACHELAST",
/* 115 */ "PARTITIONS", /* 115 */ "UNSIGNED",
/* 116 */ "UNSIGNED", /* 116 */ "TAGS",
/* 117 */ "TAGS", /* 117 */ "USING",
/* 118 */ "USING", /* 118 */ "NULL",
/* 119 */ "NULL", /* 119 */ "NOW",
/* 120 */ "NOW", /* 120 */ "SELECT",
/* 121 */ "SELECT", /* 121 */ "UNION",
/* 122 */ "UNION", /* 122 */ "ALL",
/* 123 */ "ALL", /* 123 */ "DISTINCT",
/* 124 */ "DISTINCT", /* 124 */ "FROM",
/* 125 */ "FROM", /* 125 */ "VARIABLE",
/* 126 */ "VARIABLE", /* 126 */ "INTERVAL",
/* 127 */ "INTERVAL", /* 127 */ "EVERY",
/* 128 */ "EVERY", /* 128 */ "SESSION",
/* 129 */ "SESSION", /* 129 */ "STATE_WINDOW",
/* 130 */ "STATE_WINDOW", /* 130 */ "FILL",
/* 131 */ "FILL", /* 131 */ "SLIDING",
/* 132 */ "SLIDING", /* 132 */ "ORDER",
/* 133 */ "ORDER", /* 133 */ "BY",
/* 134 */ "BY", /* 134 */ "ASC",
/* 135 */ "ASC", /* 135 */ "GROUP",
/* 136 */ "GROUP", /* 136 */ "HAVING",
/* 137 */ "HAVING", /* 137 */ "LIMIT",
/* 138 */ "LIMIT", /* 138 */ "OFFSET",
/* 139 */ "OFFSET", /* 139 */ "SLIMIT",
/* 140 */ "SLIMIT", /* 140 */ "SOFFSET",
/* 141 */ "SOFFSET", /* 141 */ "WHERE",
/* 142 */ "WHERE", /* 142 */ "RESET",
/* 143 */ "RESET", /* 143 */ "QUERY",
/* 144 */ "QUERY", /* 144 */ "SYNCDB",
/* 145 */ "SYNCDB", /* 145 */ "ADD",
/* 146 */ "ADD", /* 146 */ "COLUMN",
/* 147 */ "COLUMN", /* 147 */ "MODIFY",
/* 148 */ "MODIFY", /* 148 */ "TAG",
/* 149 */ "TAG", /* 149 */ "CHANGE",
/* 150 */ "CHANGE", /* 150 */ "SET",
/* 151 */ "SET", /* 151 */ "KILL",
/* 152 */ "KILL", /* 152 */ "CONNECTION",
/* 153 */ "CONNECTION", /* 153 */ "STREAM",
/* 154 */ "STREAM", /* 154 */ "COLON",
/* 155 */ "COLON", /* 155 */ "ABORT",
/* 156 */ "ABORT", /* 156 */ "AFTER",
/* 157 */ "AFTER", /* 157 */ "ATTACH",
/* 158 */ "ATTACH", /* 158 */ "BEFORE",
/* 159 */ "BEFORE", /* 159 */ "BEGIN",
/* 160 */ "BEGIN", /* 160 */ "CASCADE",
/* 161 */ "CASCADE", /* 161 */ "CLUSTER",
/* 162 */ "CLUSTER", /* 162 */ "CONFLICT",
/* 163 */ "CONFLICT", /* 163 */ "COPY",
/* 164 */ "COPY", /* 164 */ "DEFERRED",
/* 165 */ "DEFERRED", /* 165 */ "DELIMITERS",
/* 166 */ "DELIMITERS", /* 166 */ "DETACH",
/* 167 */ "DETACH", /* 167 */ "EACH",
/* 168 */ "EACH", /* 168 */ "END",
/* 169 */ "END", /* 169 */ "EXPLAIN",
/* 170 */ "EXPLAIN", /* 170 */ "FAIL",
/* 171 */ "FAIL", /* 171 */ "FOR",
/* 172 */ "FOR", /* 172 */ "IGNORE",
/* 173 */ "IGNORE", /* 173 */ "IMMEDIATE",
/* 174 */ "IMMEDIATE", /* 174 */ "INITIALLY",
/* 175 */ "INITIALLY", /* 175 */ "INSTEAD",
/* 176 */ "INSTEAD", /* 176 */ "KEY",
/* 177 */ "KEY", /* 177 */ "OF",
/* 178 */ "OF", /* 178 */ "RAISE",
/* 179 */ "RAISE", /* 179 */ "REPLACE",
/* 180 */ "REPLACE", /* 180 */ "RESTRICT",
/* 181 */ "RESTRICT", /* 181 */ "ROW",
/* 182 */ "ROW", /* 182 */ "STATEMENT",
/* 183 */ "STATEMENT", /* 183 */ "TRIGGER",
/* 184 */ "TRIGGER", /* 184 */ "VIEW",
/* 185 */ "VIEW", /* 185 */ "IPTOKEN",
/* 186 */ "IPTOKEN", /* 186 */ "SEMI",
/* 187 */ "SEMI", /* 187 */ "NONE",
/* 188 */ "NONE", /* 188 */ "PREV",
/* 189 */ "PREV", /* 189 */ "LINEAR",
/* 190 */ "LINEAR", /* 190 */ "IMPORT",
/* 191 */ "IMPORT", /* 191 */ "TBNAME",
/* 192 */ "TBNAME", /* 192 */ "JOIN",
/* 193 */ "JOIN", /* 193 */ "INSERT",
/* 194 */ "INSERT", /* 194 */ "INTO",
/* 195 */ "INTO", /* 195 */ "VALUES",
/* 196 */ "VALUES", /* 196 */ "error",
/* 197 */ "error", /* 197 */ "program",
/* 198 */ "program", /* 198 */ "cmd",
/* 199 */ "cmd", /* 199 */ "ids",
/* 200 */ "ids", /* 200 */ "dbPrefix",
/* 201 */ "dbPrefix", /* 201 */ "cpxName",
/* 202 */ "cpxName", /* 202 */ "ifexists",
/* 203 */ "ifexists", /* 203 */ "alter_db_optr",
/* 204 */ "alter_db_optr", /* 204 */ "acct_optr",
/* 205 */ "alter_topic_optr", /* 205 */ "exprlist",
/* 206 */ "acct_optr", /* 206 */ "ifnotexists",
/* 207 */ "exprlist", /* 207 */ "db_optr",
/* 208 */ "ifnotexists", /* 208 */ "typename",
/* 209 */ "db_optr", /* 209 */ "bufsize",
/* 210 */ "topic_optr", /* 210 */ "pps",
/* 211 */ "typename", /* 211 */ "tseries",
/* 212 */ "bufsize", /* 212 */ "dbs",
/* 213 */ "pps", /* 213 */ "streams",
/* 214 */ "tseries", /* 214 */ "storage",
/* 215 */ "dbs", /* 215 */ "qtime",
/* 216 */ "streams", /* 216 */ "users",
/* 217 */ "storage", /* 217 */ "conns",
/* 218 */ "qtime", /* 218 */ "state",
/* 219 */ "users", /* 219 */ "intitemlist",
/* 220 */ "conns", /* 220 */ "intitem",
/* 221 */ "state", /* 221 */ "keep",
/* 222 */ "intitemlist", /* 222 */ "cache",
/* 223 */ "intitem", /* 223 */ "replica",
/* 224 */ "keep", /* 224 */ "quorum",
/* 225 */ "cache", /* 225 */ "days",
/* 226 */ "replica", /* 226 */ "minrows",
/* 227 */ "quorum", /* 227 */ "maxrows",
/* 228 */ "days", /* 228 */ "blocks",
/* 229 */ "minrows", /* 229 */ "ctime",
/* 230 */ "maxrows", /* 230 */ "wal",
/* 231 */ "blocks", /* 231 */ "fsync",
/* 232 */ "ctime", /* 232 */ "comp",
/* 233 */ "wal", /* 233 */ "prec",
/* 234 */ "fsync", /* 234 */ "update",
/* 235 */ "comp", /* 235 */ "cachelast",
/* 236 */ "prec", /* 236 */ "signed",
/* 237 */ "update", /* 237 */ "create_table_args",
/* 238 */ "cachelast", /* 238 */ "create_stable_args",
/* 239 */ "partitions", /* 239 */ "create_table_list",
/* 240 */ "signed", /* 240 */ "create_from_stable",
/* 241 */ "create_table_args", /* 241 */ "columnlist",
/* 242 */ "create_stable_args", /* 242 */ "tagitemlist",
/* 243 */ "create_table_list", /* 243 */ "tagNamelist",
/* 244 */ "create_from_stable", /* 244 */ "select",
/* 245 */ "columnlist", /* 245 */ "column",
/* 246 */ "tagitemlist", /* 246 */ "tagitem",
/* 247 */ "tagNamelist", /* 247 */ "selcollist",
/* 248 */ "select", /* 248 */ "from",
/* 249 */ "column", /* 249 */ "where_opt",
/* 250 */ "tagitem", /* 250 */ "interval_option",
/* 251 */ "selcollist", /* 251 */ "sliding_opt",
/* 252 */ "from", /* 252 */ "session_option",
/* 253 */ "where_opt", /* 253 */ "windowstate_option",
/* 254 */ "interval_option", /* 254 */ "fill_opt",
/* 255 */ "sliding_opt", /* 255 */ "groupby_opt",
/* 256 */ "session_option", /* 256 */ "having_opt",
/* 257 */ "windowstate_option", /* 257 */ "orderby_opt",
/* 258 */ "fill_opt", /* 258 */ "slimit_opt",
/* 259 */ "groupby_opt", /* 259 */ "limit_opt",
/* 260 */ "having_opt", /* 260 */ "union",
/* 261 */ "orderby_opt", /* 261 */ "sclp",
/* 262 */ "slimit_opt", /* 262 */ "distinct",
/* 263 */ "limit_opt", /* 263 */ "expr",
/* 264 */ "union", /* 264 */ "as",
/* 265 */ "sclp", /* 265 */ "tablelist",
/* 266 */ "distinct", /* 266 */ "sub",
/* 267 */ "expr", /* 267 */ "tmvar",
/* 268 */ "as", /* 268 */ "intervalKey",
/* 269 */ "tablelist", /* 269 */ "sortlist",
/* 270 */ "sub", /* 270 */ "sortitem",
/* 271 */ "tmvar", /* 271 */ "item",
/* 272 */ "intervalKey", /* 272 */ "sortorder",
/* 273 */ "sortlist", /* 273 */ "grouplist",
/* 274 */ "sortitem", /* 274 */ "expritem",
/* 275 */ "item",
/* 276 */ "sortorder",
/* 277 */ "grouplist",
/* 278 */ "expritem",
}; };
#endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
...@@ -1129,253 +1118,246 @@ static const char *const yyRuleName[] = { ...@@ -1129,253 +1118,246 @@ static const char *const yyRuleName[] = {
/* 45 */ "cmd ::= ALTER LOCAL ids", /* 45 */ "cmd ::= ALTER LOCAL ids",
/* 46 */ "cmd ::= ALTER LOCAL ids ids", /* 46 */ "cmd ::= ALTER LOCAL ids ids",
/* 47 */ "cmd ::= ALTER DATABASE ids alter_db_optr", /* 47 */ "cmd ::= ALTER DATABASE ids alter_db_optr",
/* 48 */ "cmd ::= ALTER TOPIC ids alter_topic_optr", /* 48 */ "cmd ::= ALTER ACCOUNT ids acct_optr",
/* 49 */ "cmd ::= ALTER ACCOUNT ids acct_optr", /* 49 */ "cmd ::= ALTER ACCOUNT ids PASS ids acct_optr",
/* 50 */ "cmd ::= ALTER ACCOUNT ids PASS ids acct_optr", /* 50 */ "cmd ::= COMPACT VNODES IN LP exprlist RP",
/* 51 */ "cmd ::= COMPACT VNODES IN LP exprlist RP", /* 51 */ "ids ::= ID",
/* 52 */ "ids ::= ID", /* 52 */ "ids ::= STRING",
/* 53 */ "ids ::= STRING", /* 53 */ "ifexists ::= IF EXISTS",
/* 54 */ "ifexists ::= IF EXISTS", /* 54 */ "ifexists ::=",
/* 55 */ "ifexists ::=", /* 55 */ "ifnotexists ::= IF NOT EXISTS",
/* 56 */ "ifnotexists ::= IF NOT EXISTS", /* 56 */ "ifnotexists ::=",
/* 57 */ "ifnotexists ::=", /* 57 */ "cmd ::= CREATE DNODE ids",
/* 58 */ "cmd ::= CREATE DNODE ids", /* 58 */ "cmd ::= CREATE ACCOUNT ids PASS ids acct_optr",
/* 59 */ "cmd ::= CREATE ACCOUNT ids PASS ids acct_optr", /* 59 */ "cmd ::= CREATE DATABASE ifnotexists ids db_optr",
/* 60 */ "cmd ::= CREATE DATABASE ifnotexists ids db_optr", /* 60 */ "cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize",
/* 61 */ "cmd ::= CREATE TOPIC ifnotexists ids topic_optr", /* 61 */ "cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize",
/* 62 */ "cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize", /* 62 */ "cmd ::= CREATE USER ids PASS ids",
/* 63 */ "cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize", /* 63 */ "bufsize ::=",
/* 64 */ "cmd ::= CREATE USER ids PASS ids", /* 64 */ "bufsize ::= BUFSIZE INTEGER",
/* 65 */ "bufsize ::=", /* 65 */ "pps ::=",
/* 66 */ "bufsize ::= BUFSIZE INTEGER", /* 66 */ "pps ::= PPS INTEGER",
/* 67 */ "pps ::=", /* 67 */ "tseries ::=",
/* 68 */ "pps ::= PPS INTEGER", /* 68 */ "tseries ::= TSERIES INTEGER",
/* 69 */ "tseries ::=", /* 69 */ "dbs ::=",
/* 70 */ "tseries ::= TSERIES INTEGER", /* 70 */ "dbs ::= DBS INTEGER",
/* 71 */ "dbs ::=", /* 71 */ "streams ::=",
/* 72 */ "dbs ::= DBS INTEGER", /* 72 */ "streams ::= STREAMS INTEGER",
/* 73 */ "streams ::=", /* 73 */ "storage ::=",
/* 74 */ "streams ::= STREAMS INTEGER", /* 74 */ "storage ::= STORAGE INTEGER",
/* 75 */ "storage ::=", /* 75 */ "qtime ::=",
/* 76 */ "storage ::= STORAGE INTEGER", /* 76 */ "qtime ::= QTIME INTEGER",
/* 77 */ "qtime ::=", /* 77 */ "users ::=",
/* 78 */ "qtime ::= QTIME INTEGER", /* 78 */ "users ::= USERS INTEGER",
/* 79 */ "users ::=", /* 79 */ "conns ::=",
/* 80 */ "users ::= USERS INTEGER", /* 80 */ "conns ::= CONNS INTEGER",
/* 81 */ "conns ::=", /* 81 */ "state ::=",
/* 82 */ "conns ::= CONNS INTEGER", /* 82 */ "state ::= STATE ids",
/* 83 */ "state ::=", /* 83 */ "acct_optr ::= pps tseries storage streams qtime dbs users conns state",
/* 84 */ "state ::= STATE ids", /* 84 */ "intitemlist ::= intitemlist COMMA intitem",
/* 85 */ "acct_optr ::= pps tseries storage streams qtime dbs users conns state", /* 85 */ "intitemlist ::= intitem",
/* 86 */ "intitemlist ::= intitemlist COMMA intitem", /* 86 */ "intitem ::= INTEGER",
/* 87 */ "intitemlist ::= intitem", /* 87 */ "keep ::= KEEP intitemlist",
/* 88 */ "intitem ::= INTEGER", /* 88 */ "cache ::= CACHE INTEGER",
/* 89 */ "keep ::= KEEP intitemlist", /* 89 */ "replica ::= REPLICA INTEGER",
/* 90 */ "cache ::= CACHE INTEGER", /* 90 */ "quorum ::= QUORUM INTEGER",
/* 91 */ "replica ::= REPLICA INTEGER", /* 91 */ "days ::= DAYS INTEGER",
/* 92 */ "quorum ::= QUORUM INTEGER", /* 92 */ "minrows ::= MINROWS INTEGER",
/* 93 */ "days ::= DAYS INTEGER", /* 93 */ "maxrows ::= MAXROWS INTEGER",
/* 94 */ "minrows ::= MINROWS INTEGER", /* 94 */ "blocks ::= BLOCKS INTEGER",
/* 95 */ "maxrows ::= MAXROWS INTEGER", /* 95 */ "ctime ::= CTIME INTEGER",
/* 96 */ "blocks ::= BLOCKS INTEGER", /* 96 */ "wal ::= WAL INTEGER",
/* 97 */ "ctime ::= CTIME INTEGER", /* 97 */ "fsync ::= FSYNC INTEGER",
/* 98 */ "wal ::= WAL INTEGER", /* 98 */ "comp ::= COMP INTEGER",
/* 99 */ "fsync ::= FSYNC INTEGER", /* 99 */ "prec ::= PRECISION STRING",
/* 100 */ "comp ::= COMP INTEGER", /* 100 */ "update ::= UPDATE INTEGER",
/* 101 */ "prec ::= PRECISION STRING", /* 101 */ "cachelast ::= CACHELAST INTEGER",
/* 102 */ "update ::= UPDATE INTEGER", /* 102 */ "db_optr ::=",
/* 103 */ "cachelast ::= CACHELAST INTEGER", /* 103 */ "db_optr ::= db_optr cache",
/* 104 */ "partitions ::= PARTITIONS INTEGER", /* 104 */ "db_optr ::= db_optr replica",
/* 105 */ "db_optr ::=", /* 105 */ "db_optr ::= db_optr quorum",
/* 106 */ "db_optr ::= db_optr cache", /* 106 */ "db_optr ::= db_optr days",
/* 107 */ "db_optr ::= db_optr replica", /* 107 */ "db_optr ::= db_optr minrows",
/* 108 */ "db_optr ::= db_optr quorum", /* 108 */ "db_optr ::= db_optr maxrows",
/* 109 */ "db_optr ::= db_optr days", /* 109 */ "db_optr ::= db_optr blocks",
/* 110 */ "db_optr ::= db_optr minrows", /* 110 */ "db_optr ::= db_optr ctime",
/* 111 */ "db_optr ::= db_optr maxrows", /* 111 */ "db_optr ::= db_optr wal",
/* 112 */ "db_optr ::= db_optr blocks", /* 112 */ "db_optr ::= db_optr fsync",
/* 113 */ "db_optr ::= db_optr ctime", /* 113 */ "db_optr ::= db_optr comp",
/* 114 */ "db_optr ::= db_optr wal", /* 114 */ "db_optr ::= db_optr prec",
/* 115 */ "db_optr ::= db_optr fsync", /* 115 */ "db_optr ::= db_optr keep",
/* 116 */ "db_optr ::= db_optr comp", /* 116 */ "db_optr ::= db_optr update",
/* 117 */ "db_optr ::= db_optr prec", /* 117 */ "db_optr ::= db_optr cachelast",
/* 118 */ "db_optr ::= db_optr keep", /* 118 */ "alter_db_optr ::=",
/* 119 */ "db_optr ::= db_optr update", /* 119 */ "alter_db_optr ::= alter_db_optr replica",
/* 120 */ "db_optr ::= db_optr cachelast", /* 120 */ "alter_db_optr ::= alter_db_optr quorum",
/* 121 */ "topic_optr ::= db_optr", /* 121 */ "alter_db_optr ::= alter_db_optr keep",
/* 122 */ "topic_optr ::= topic_optr partitions", /* 122 */ "alter_db_optr ::= alter_db_optr blocks",
/* 123 */ "alter_db_optr ::=", /* 123 */ "alter_db_optr ::= alter_db_optr comp",
/* 124 */ "alter_db_optr ::= alter_db_optr replica", /* 124 */ "alter_db_optr ::= alter_db_optr update",
/* 125 */ "alter_db_optr ::= alter_db_optr quorum", /* 125 */ "alter_db_optr ::= alter_db_optr cachelast",
/* 126 */ "alter_db_optr ::= alter_db_optr keep", /* 126 */ "typename ::= ids",
/* 127 */ "alter_db_optr ::= alter_db_optr blocks", /* 127 */ "typename ::= ids LP signed RP",
/* 128 */ "alter_db_optr ::= alter_db_optr comp", /* 128 */ "typename ::= ids UNSIGNED",
/* 129 */ "alter_db_optr ::= alter_db_optr update", /* 129 */ "signed ::= INTEGER",
/* 130 */ "alter_db_optr ::= alter_db_optr cachelast", /* 130 */ "signed ::= PLUS INTEGER",
/* 131 */ "alter_topic_optr ::= alter_db_optr", /* 131 */ "signed ::= MINUS INTEGER",
/* 132 */ "alter_topic_optr ::= alter_topic_optr partitions", /* 132 */ "cmd ::= CREATE TABLE create_table_args",
/* 133 */ "typename ::= ids", /* 133 */ "cmd ::= CREATE TABLE create_stable_args",
/* 134 */ "typename ::= ids LP signed RP", /* 134 */ "cmd ::= CREATE STABLE create_stable_args",
/* 135 */ "typename ::= ids UNSIGNED", /* 135 */ "cmd ::= CREATE TABLE create_table_list",
/* 136 */ "signed ::= INTEGER", /* 136 */ "create_table_list ::= create_from_stable",
/* 137 */ "signed ::= PLUS INTEGER", /* 137 */ "create_table_list ::= create_table_list create_from_stable",
/* 138 */ "signed ::= MINUS INTEGER", /* 138 */ "create_table_args ::= ifnotexists ids cpxName LP columnlist RP",
/* 139 */ "cmd ::= CREATE TABLE create_table_args", /* 139 */ "create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP",
/* 140 */ "cmd ::= CREATE TABLE create_stable_args", /* 140 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP",
/* 141 */ "cmd ::= CREATE STABLE create_stable_args", /* 141 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP",
/* 142 */ "cmd ::= CREATE TABLE create_table_list", /* 142 */ "tagNamelist ::= tagNamelist COMMA ids",
/* 143 */ "create_table_list ::= create_from_stable", /* 143 */ "tagNamelist ::= ids",
/* 144 */ "create_table_list ::= create_table_list create_from_stable", /* 144 */ "create_table_args ::= ifnotexists ids cpxName AS select",
/* 145 */ "create_table_args ::= ifnotexists ids cpxName LP columnlist RP", /* 145 */ "columnlist ::= columnlist COMMA column",
/* 146 */ "create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP", /* 146 */ "columnlist ::= column",
/* 147 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP", /* 147 */ "column ::= ids typename",
/* 148 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP", /* 148 */ "tagitemlist ::= tagitemlist COMMA tagitem",
/* 149 */ "tagNamelist ::= tagNamelist COMMA ids", /* 149 */ "tagitemlist ::= tagitem",
/* 150 */ "tagNamelist ::= ids", /* 150 */ "tagitem ::= INTEGER",
/* 151 */ "create_table_args ::= ifnotexists ids cpxName AS select", /* 151 */ "tagitem ::= FLOAT",
/* 152 */ "columnlist ::= columnlist COMMA column", /* 152 */ "tagitem ::= STRING",
/* 153 */ "columnlist ::= column", /* 153 */ "tagitem ::= BOOL",
/* 154 */ "column ::= ids typename", /* 154 */ "tagitem ::= NULL",
/* 155 */ "tagitemlist ::= tagitemlist COMMA tagitem", /* 155 */ "tagitem ::= NOW",
/* 156 */ "tagitemlist ::= tagitem", /* 156 */ "tagitem ::= MINUS INTEGER",
/* 157 */ "tagitem ::= INTEGER", /* 157 */ "tagitem ::= MINUS FLOAT",
/* 158 */ "tagitem ::= FLOAT", /* 158 */ "tagitem ::= PLUS INTEGER",
/* 159 */ "tagitem ::= STRING", /* 159 */ "tagitem ::= PLUS FLOAT",
/* 160 */ "tagitem ::= BOOL", /* 160 */ "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",
/* 161 */ "tagitem ::= NULL", /* 161 */ "select ::= LP select RP",
/* 162 */ "tagitem ::= NOW", /* 162 */ "union ::= select",
/* 163 */ "tagitem ::= MINUS INTEGER", /* 163 */ "union ::= union UNION ALL select",
/* 164 */ "tagitem ::= MINUS FLOAT", /* 164 */ "union ::= union UNION select",
/* 165 */ "tagitem ::= PLUS INTEGER", /* 165 */ "cmd ::= union",
/* 166 */ "tagitem ::= PLUS FLOAT", /* 166 */ "select ::= SELECT selcollist",
/* 167 */ "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", /* 167 */ "sclp ::= selcollist COMMA",
/* 168 */ "select ::= LP select RP", /* 168 */ "sclp ::=",
/* 169 */ "union ::= select", /* 169 */ "selcollist ::= sclp distinct expr as",
/* 170 */ "union ::= union UNION ALL select", /* 170 */ "selcollist ::= sclp STAR",
/* 171 */ "union ::= union UNION select", /* 171 */ "as ::= AS ids",
/* 172 */ "cmd ::= union", /* 172 */ "as ::= ids",
/* 173 */ "select ::= SELECT selcollist", /* 173 */ "as ::=",
/* 174 */ "sclp ::= selcollist COMMA", /* 174 */ "distinct ::= DISTINCT",
/* 175 */ "sclp ::=", /* 175 */ "distinct ::=",
/* 176 */ "selcollist ::= sclp distinct expr as", /* 176 */ "from ::= FROM tablelist",
/* 177 */ "selcollist ::= sclp STAR", /* 177 */ "from ::= FROM sub",
/* 178 */ "as ::= AS ids", /* 178 */ "sub ::= LP union RP",
/* 179 */ "as ::= ids", /* 179 */ "sub ::= LP union RP ids",
/* 180 */ "as ::=", /* 180 */ "sub ::= sub COMMA LP union RP ids",
/* 181 */ "distinct ::= DISTINCT", /* 181 */ "tablelist ::= ids cpxName",
/* 182 */ "distinct ::=", /* 182 */ "tablelist ::= ids cpxName ids",
/* 183 */ "from ::= FROM tablelist", /* 183 */ "tablelist ::= tablelist COMMA ids cpxName",
/* 184 */ "from ::= FROM sub", /* 184 */ "tablelist ::= tablelist COMMA ids cpxName ids",
/* 185 */ "sub ::= LP union RP", /* 185 */ "tmvar ::= VARIABLE",
/* 186 */ "sub ::= LP union RP ids", /* 186 */ "interval_option ::= intervalKey LP tmvar RP",
/* 187 */ "sub ::= sub COMMA LP union RP ids", /* 187 */ "interval_option ::= intervalKey LP tmvar COMMA tmvar RP",
/* 188 */ "tablelist ::= ids cpxName", /* 188 */ "interval_option ::=",
/* 189 */ "tablelist ::= ids cpxName ids", /* 189 */ "intervalKey ::= INTERVAL",
/* 190 */ "tablelist ::= tablelist COMMA ids cpxName", /* 190 */ "intervalKey ::= EVERY",
/* 191 */ "tablelist ::= tablelist COMMA ids cpxName ids", /* 191 */ "session_option ::=",
/* 192 */ "tmvar ::= VARIABLE", /* 192 */ "session_option ::= SESSION LP ids cpxName COMMA tmvar RP",
/* 193 */ "interval_option ::= intervalKey LP tmvar RP", /* 193 */ "windowstate_option ::=",
/* 194 */ "interval_option ::= intervalKey LP tmvar COMMA tmvar RP", /* 194 */ "windowstate_option ::= STATE_WINDOW LP ids RP",
/* 195 */ "interval_option ::=", /* 195 */ "fill_opt ::=",
/* 196 */ "intervalKey ::= INTERVAL", /* 196 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP",
/* 197 */ "intervalKey ::= EVERY", /* 197 */ "fill_opt ::= FILL LP ID RP",
/* 198 */ "session_option ::=", /* 198 */ "sliding_opt ::= SLIDING LP tmvar RP",
/* 199 */ "session_option ::= SESSION LP ids cpxName COMMA tmvar RP", /* 199 */ "sliding_opt ::=",
/* 200 */ "windowstate_option ::=", /* 200 */ "orderby_opt ::=",
/* 201 */ "windowstate_option ::= STATE_WINDOW LP ids RP", /* 201 */ "orderby_opt ::= ORDER BY sortlist",
/* 202 */ "fill_opt ::=", /* 202 */ "sortlist ::= sortlist COMMA item sortorder",
/* 203 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP", /* 203 */ "sortlist ::= item sortorder",
/* 204 */ "fill_opt ::= FILL LP ID RP", /* 204 */ "item ::= ids cpxName",
/* 205 */ "sliding_opt ::= SLIDING LP tmvar RP", /* 205 */ "sortorder ::= ASC",
/* 206 */ "sliding_opt ::=", /* 206 */ "sortorder ::= DESC",
/* 207 */ "orderby_opt ::=", /* 207 */ "sortorder ::=",
/* 208 */ "orderby_opt ::= ORDER BY sortlist", /* 208 */ "groupby_opt ::=",
/* 209 */ "sortlist ::= sortlist COMMA item sortorder", /* 209 */ "groupby_opt ::= GROUP BY grouplist",
/* 210 */ "sortlist ::= item sortorder", /* 210 */ "grouplist ::= grouplist COMMA item",
/* 211 */ "item ::= ids cpxName", /* 211 */ "grouplist ::= item",
/* 212 */ "sortorder ::= ASC", /* 212 */ "having_opt ::=",
/* 213 */ "sortorder ::= DESC", /* 213 */ "having_opt ::= HAVING expr",
/* 214 */ "sortorder ::=", /* 214 */ "limit_opt ::=",
/* 215 */ "groupby_opt ::=", /* 215 */ "limit_opt ::= LIMIT signed",
/* 216 */ "groupby_opt ::= GROUP BY grouplist", /* 216 */ "limit_opt ::= LIMIT signed OFFSET signed",
/* 217 */ "grouplist ::= grouplist COMMA item", /* 217 */ "limit_opt ::= LIMIT signed COMMA signed",
/* 218 */ "grouplist ::= item", /* 218 */ "slimit_opt ::=",
/* 219 */ "having_opt ::=", /* 219 */ "slimit_opt ::= SLIMIT signed",
/* 220 */ "having_opt ::= HAVING expr", /* 220 */ "slimit_opt ::= SLIMIT signed SOFFSET signed",
/* 221 */ "limit_opt ::=", /* 221 */ "slimit_opt ::= SLIMIT signed COMMA signed",
/* 222 */ "limit_opt ::= LIMIT signed", /* 222 */ "where_opt ::=",
/* 223 */ "limit_opt ::= LIMIT signed OFFSET signed", /* 223 */ "where_opt ::= WHERE expr",
/* 224 */ "limit_opt ::= LIMIT signed COMMA signed", /* 224 */ "expr ::= LP expr RP",
/* 225 */ "slimit_opt ::=", /* 225 */ "expr ::= ID",
/* 226 */ "slimit_opt ::= SLIMIT signed", /* 226 */ "expr ::= ID DOT ID",
/* 227 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", /* 227 */ "expr ::= ID DOT STAR",
/* 228 */ "slimit_opt ::= SLIMIT signed COMMA signed", /* 228 */ "expr ::= INTEGER",
/* 229 */ "where_opt ::=", /* 229 */ "expr ::= MINUS INTEGER",
/* 230 */ "where_opt ::= WHERE expr", /* 230 */ "expr ::= PLUS INTEGER",
/* 231 */ "expr ::= LP expr RP", /* 231 */ "expr ::= FLOAT",
/* 232 */ "expr ::= ID", /* 232 */ "expr ::= MINUS FLOAT",
/* 233 */ "expr ::= ID DOT ID", /* 233 */ "expr ::= PLUS FLOAT",
/* 234 */ "expr ::= ID DOT STAR", /* 234 */ "expr ::= STRING",
/* 235 */ "expr ::= INTEGER", /* 235 */ "expr ::= NOW",
/* 236 */ "expr ::= MINUS INTEGER", /* 236 */ "expr ::= VARIABLE",
/* 237 */ "expr ::= PLUS INTEGER", /* 237 */ "expr ::= PLUS VARIABLE",
/* 238 */ "expr ::= FLOAT", /* 238 */ "expr ::= MINUS VARIABLE",
/* 239 */ "expr ::= MINUS FLOAT", /* 239 */ "expr ::= BOOL",
/* 240 */ "expr ::= PLUS FLOAT", /* 240 */ "expr ::= NULL",
/* 241 */ "expr ::= STRING", /* 241 */ "expr ::= ID LP exprlist RP",
/* 242 */ "expr ::= NOW", /* 242 */ "expr ::= ID LP STAR RP",
/* 243 */ "expr ::= VARIABLE", /* 243 */ "expr ::= expr IS NULL",
/* 244 */ "expr ::= PLUS VARIABLE", /* 244 */ "expr ::= expr IS NOT NULL",
/* 245 */ "expr ::= MINUS VARIABLE", /* 245 */ "expr ::= expr LT expr",
/* 246 */ "expr ::= BOOL", /* 246 */ "expr ::= expr GT expr",
/* 247 */ "expr ::= NULL", /* 247 */ "expr ::= expr LE expr",
/* 248 */ "expr ::= ID LP exprlist RP", /* 248 */ "expr ::= expr GE expr",
/* 249 */ "expr ::= ID LP STAR RP", /* 249 */ "expr ::= expr NE expr",
/* 250 */ "expr ::= expr IS NULL", /* 250 */ "expr ::= expr EQ expr",
/* 251 */ "expr ::= expr IS NOT NULL", /* 251 */ "expr ::= expr BETWEEN expr AND expr",
/* 252 */ "expr ::= expr LT expr", /* 252 */ "expr ::= expr AND expr",
/* 253 */ "expr ::= expr GT expr", /* 253 */ "expr ::= expr OR expr",
/* 254 */ "expr ::= expr LE expr", /* 254 */ "expr ::= expr PLUS expr",
/* 255 */ "expr ::= expr GE expr", /* 255 */ "expr ::= expr MINUS expr",
/* 256 */ "expr ::= expr NE expr", /* 256 */ "expr ::= expr STAR expr",
/* 257 */ "expr ::= expr EQ expr", /* 257 */ "expr ::= expr SLASH expr",
/* 258 */ "expr ::= expr BETWEEN expr AND expr", /* 258 */ "expr ::= expr REM expr",
/* 259 */ "expr ::= expr AND expr", /* 259 */ "expr ::= expr LIKE expr",
/* 260 */ "expr ::= expr OR expr", /* 260 */ "expr ::= expr MATCH expr",
/* 261 */ "expr ::= expr PLUS expr", /* 261 */ "expr ::= expr NMATCH expr",
/* 262 */ "expr ::= expr MINUS expr", /* 262 */ "expr ::= expr IN LP exprlist RP",
/* 263 */ "expr ::= expr STAR expr", /* 263 */ "exprlist ::= exprlist COMMA expritem",
/* 264 */ "expr ::= expr SLASH expr", /* 264 */ "exprlist ::= expritem",
/* 265 */ "expr ::= expr REM expr", /* 265 */ "expritem ::= expr",
/* 266 */ "expr ::= expr LIKE expr", /* 266 */ "expritem ::=",
/* 267 */ "expr ::= expr MATCH expr", /* 267 */ "cmd ::= RESET QUERY CACHE",
/* 268 */ "expr ::= expr NMATCH expr", /* 268 */ "cmd ::= SYNCDB ids REPLICA",
/* 269 */ "expr ::= expr IN LP exprlist RP", /* 269 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist",
/* 270 */ "exprlist ::= exprlist COMMA expritem", /* 270 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids",
/* 271 */ "exprlist ::= expritem", /* 271 */ "cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist",
/* 272 */ "expritem ::= expr", /* 272 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist",
/* 273 */ "expritem ::=", /* 273 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids",
/* 274 */ "cmd ::= RESET QUERY CACHE", /* 274 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids",
/* 275 */ "cmd ::= SYNCDB ids REPLICA", /* 275 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem",
/* 276 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", /* 276 */ "cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist",
/* 277 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", /* 277 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist",
/* 278 */ "cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist", /* 278 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids",
/* 279 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", /* 279 */ "cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist",
/* 280 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", /* 280 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist",
/* 281 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", /* 281 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids",
/* 282 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", /* 282 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids",
/* 283 */ "cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist", /* 283 */ "cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem",
/* 284 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist", /* 284 */ "cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist",
/* 285 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids", /* 285 */ "cmd ::= KILL CONNECTION INTEGER",
/* 286 */ "cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist", /* 286 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER",
/* 287 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist", /* 287 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER",
/* 288 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids",
/* 289 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids",
/* 290 */ "cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem",
/* 291 */ "cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist",
/* 292 */ "cmd ::= KILL CONNECTION INTEGER",
/* 293 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER",
/* 294 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER",
}; };
#endif /* NDEBUG */ #endif /* NDEBUG */
...@@ -1496,60 +1478,60 @@ static void yy_destructor( ...@@ -1496,60 +1478,60 @@ static void yy_destructor(
** inside the C code. ** inside the C code.
*/ */
/********* Begin destructor definitions ***************************************/ /********* Begin destructor definitions ***************************************/
case 207: /* exprlist */ case 205: /* exprlist */
case 251: /* selcollist */ case 247: /* selcollist */
case 265: /* sclp */ case 261: /* sclp */
{ {
tSqlExprListDestroy((yypminor->yy135)); tSqlExprListDestroy((yypminor->yy131));
} }
break; break;
case 222: /* intitemlist */ case 219: /* intitemlist */
case 224: /* keep */ case 221: /* keep */
case 245: /* columnlist */ case 241: /* columnlist */
case 246: /* tagitemlist */ case 242: /* tagitemlist */
case 247: /* tagNamelist */ case 243: /* tagNamelist */
case 258: /* fill_opt */ case 254: /* fill_opt */
case 259: /* groupby_opt */ case 255: /* groupby_opt */
case 261: /* orderby_opt */ case 257: /* orderby_opt */
case 273: /* sortlist */ case 269: /* sortlist */
case 277: /* grouplist */ case 273: /* grouplist */
{ {
taosArrayDestroy((yypminor->yy135)); taosArrayDestroy((yypminor->yy131));
} }
break; break;
case 243: /* create_table_list */ case 239: /* create_table_list */
{ {
destroyCreateTableSql((yypminor->yy110)); destroyCreateTableSql((yypminor->yy272));
} }
break; break;
case 248: /* select */ case 244: /* select */
{ {
destroySqlNode((yypminor->yy488)); destroySqlNode((yypminor->yy256));
} }
break; break;
case 252: /* from */ case 248: /* from */
case 269: /* tablelist */ case 265: /* tablelist */
case 270: /* sub */ case 266: /* sub */
{ {
destroyRelationInfo((yypminor->yy460)); destroyRelationInfo((yypminor->yy544));
} }
break; break;
case 253: /* where_opt */ case 249: /* where_opt */
case 260: /* having_opt */ case 256: /* having_opt */
case 267: /* expr */ case 263: /* expr */
case 278: /* expritem */ case 274: /* expritem */
{ {
tSqlExprDestroy((yypminor->yy526)); tSqlExprDestroy((yypminor->yy46));
} }
break; break;
case 264: /* union */ case 260: /* union */
{ {
destroyAllSqlNode((yypminor->yy551)); destroyAllSqlNode((yypminor->yy303));
} }
break; break;
case 274: /* sortitem */ case 270: /* sortitem */
{ {
taosVariantDestroy(&(yypminor->yy191)); taosVariantDestroy(&(yypminor->yy43));
} }
break; break;
/********* End destructor definitions *****************************************/ /********* End destructor definitions *****************************************/
...@@ -1843,301 +1825,294 @@ static const struct { ...@@ -1843,301 +1825,294 @@ 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 */ { 197, -1 }, /* (0) program ::= cmd */
{ 199, -2 }, /* (1) cmd ::= SHOW DATABASES */ { 198, -2 }, /* (1) cmd ::= SHOW DATABASES */
{ 199, -2 }, /* (2) cmd ::= SHOW TOPICS */ { 198, -2 }, /* (2) cmd ::= SHOW TOPICS */
{ 199, -2 }, /* (3) cmd ::= SHOW FUNCTIONS */ { 198, -2 }, /* (3) cmd ::= SHOW FUNCTIONS */
{ 199, -2 }, /* (4) cmd ::= SHOW MNODES */ { 198, -2 }, /* (4) cmd ::= SHOW MNODES */
{ 199, -2 }, /* (5) cmd ::= SHOW DNODES */ { 198, -2 }, /* (5) cmd ::= SHOW DNODES */
{ 199, -2 }, /* (6) cmd ::= SHOW ACCOUNTS */ { 198, -2 }, /* (6) cmd ::= SHOW ACCOUNTS */
{ 199, -2 }, /* (7) cmd ::= SHOW USERS */ { 198, -2 }, /* (7) cmd ::= SHOW USERS */
{ 199, -2 }, /* (8) cmd ::= SHOW MODULES */ { 198, -2 }, /* (8) cmd ::= SHOW MODULES */
{ 199, -2 }, /* (9) cmd ::= SHOW QUERIES */ { 198, -2 }, /* (9) cmd ::= SHOW QUERIES */
{ 199, -2 }, /* (10) cmd ::= SHOW CONNECTIONS */ { 198, -2 }, /* (10) cmd ::= SHOW CONNECTIONS */
{ 199, -2 }, /* (11) cmd ::= SHOW STREAMS */ { 198, -2 }, /* (11) cmd ::= SHOW STREAMS */
{ 199, -2 }, /* (12) cmd ::= SHOW VARIABLES */ { 198, -2 }, /* (12) cmd ::= SHOW VARIABLES */
{ 199, -2 }, /* (13) cmd ::= SHOW SCORES */ { 198, -2 }, /* (13) cmd ::= SHOW SCORES */
{ 199, -2 }, /* (14) cmd ::= SHOW GRANTS */ { 198, -2 }, /* (14) cmd ::= SHOW GRANTS */
{ 199, -2 }, /* (15) cmd ::= SHOW VNODES */ { 198, -2 }, /* (15) cmd ::= SHOW VNODES */
{ 199, -3 }, /* (16) cmd ::= SHOW VNODES ids */ { 198, -3 }, /* (16) cmd ::= SHOW VNODES ids */
{ 201, 0 }, /* (17) dbPrefix ::= */ { 200, 0 }, /* (17) dbPrefix ::= */
{ 201, -2 }, /* (18) dbPrefix ::= ids DOT */ { 200, -2 }, /* (18) dbPrefix ::= ids DOT */
{ 202, 0 }, /* (19) cpxName ::= */ { 201, 0 }, /* (19) cpxName ::= */
{ 202, -2 }, /* (20) cpxName ::= DOT ids */ { 201, -2 }, /* (20) cpxName ::= DOT ids */
{ 199, -5 }, /* (21) cmd ::= SHOW CREATE TABLE ids cpxName */ { 198, -5 }, /* (21) cmd ::= SHOW CREATE TABLE ids cpxName */
{ 199, -5 }, /* (22) cmd ::= SHOW CREATE STABLE ids cpxName */ { 198, -5 }, /* (22) cmd ::= SHOW CREATE STABLE ids cpxName */
{ 199, -4 }, /* (23) cmd ::= SHOW CREATE DATABASE ids */ { 198, -4 }, /* (23) cmd ::= SHOW CREATE DATABASE ids */
{ 199, -3 }, /* (24) cmd ::= SHOW dbPrefix TABLES */ { 198, -3 }, /* (24) cmd ::= SHOW dbPrefix TABLES */
{ 199, -5 }, /* (25) cmd ::= SHOW dbPrefix TABLES LIKE ids */ { 198, -5 }, /* (25) cmd ::= SHOW dbPrefix TABLES LIKE ids */
{ 199, -3 }, /* (26) cmd ::= SHOW dbPrefix STABLES */ { 198, -3 }, /* (26) cmd ::= SHOW dbPrefix STABLES */
{ 199, -5 }, /* (27) cmd ::= SHOW dbPrefix STABLES LIKE ids */ { 198, -5 }, /* (27) cmd ::= SHOW dbPrefix STABLES LIKE ids */
{ 199, -3 }, /* (28) cmd ::= SHOW dbPrefix VGROUPS */ { 198, -3 }, /* (28) cmd ::= SHOW dbPrefix VGROUPS */
{ 199, -4 }, /* (29) cmd ::= SHOW dbPrefix VGROUPS ids */ { 198, -4 }, /* (29) cmd ::= SHOW dbPrefix VGROUPS ids */
{ 199, -5 }, /* (30) cmd ::= DROP TABLE ifexists ids cpxName */ { 198, -5 }, /* (30) cmd ::= DROP TABLE ifexists ids cpxName */
{ 199, -5 }, /* (31) cmd ::= DROP STABLE ifexists ids cpxName */ { 198, -5 }, /* (31) cmd ::= DROP STABLE ifexists ids cpxName */
{ 199, -4 }, /* (32) cmd ::= DROP DATABASE ifexists ids */ { 198, -4 }, /* (32) cmd ::= DROP DATABASE ifexists ids */
{ 199, -4 }, /* (33) cmd ::= DROP TOPIC ifexists ids */ { 198, -4 }, /* (33) cmd ::= DROP TOPIC ifexists ids */
{ 199, -3 }, /* (34) cmd ::= DROP FUNCTION ids */ { 198, -3 }, /* (34) cmd ::= DROP FUNCTION ids */
{ 199, -3 }, /* (35) cmd ::= DROP DNODE ids */ { 198, -3 }, /* (35) cmd ::= DROP DNODE ids */
{ 199, -3 }, /* (36) cmd ::= DROP USER ids */ { 198, -3 }, /* (36) cmd ::= DROP USER ids */
{ 199, -3 }, /* (37) cmd ::= DROP ACCOUNT ids */ { 198, -3 }, /* (37) cmd ::= DROP ACCOUNT ids */
{ 199, -2 }, /* (38) cmd ::= USE ids */ { 198, -2 }, /* (38) cmd ::= USE ids */
{ 199, -3 }, /* (39) cmd ::= DESCRIBE ids cpxName */ { 198, -3 }, /* (39) cmd ::= DESCRIBE ids cpxName */
{ 199, -3 }, /* (40) cmd ::= DESC ids cpxName */ { 198, -3 }, /* (40) cmd ::= DESC ids cpxName */
{ 199, -5 }, /* (41) cmd ::= ALTER USER ids PASS ids */ { 198, -5 }, /* (41) cmd ::= ALTER USER ids PASS ids */
{ 199, -5 }, /* (42) cmd ::= ALTER USER ids PRIVILEGE ids */ { 198, -5 }, /* (42) cmd ::= ALTER USER ids PRIVILEGE ids */
{ 199, -4 }, /* (43) cmd ::= ALTER DNODE ids ids */ { 198, -4 }, /* (43) cmd ::= ALTER DNODE ids ids */
{ 199, -5 }, /* (44) cmd ::= ALTER DNODE ids ids ids */ { 198, -5 }, /* (44) cmd ::= ALTER DNODE ids ids ids */
{ 199, -3 }, /* (45) cmd ::= ALTER LOCAL ids */ { 198, -3 }, /* (45) cmd ::= ALTER LOCAL ids */
{ 199, -4 }, /* (46) cmd ::= ALTER LOCAL ids ids */ { 198, -4 }, /* (46) cmd ::= ALTER LOCAL ids ids */
{ 199, -4 }, /* (47) cmd ::= ALTER DATABASE ids alter_db_optr */ { 198, -4 }, /* (47) cmd ::= ALTER DATABASE ids alter_db_optr */
{ 199, -4 }, /* (48) cmd ::= ALTER TOPIC ids alter_topic_optr */ { 198, -4 }, /* (48) cmd ::= ALTER ACCOUNT ids acct_optr */
{ 199, -4 }, /* (49) cmd ::= ALTER ACCOUNT ids acct_optr */ { 198, -6 }, /* (49) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */
{ 199, -6 }, /* (50) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ { 198, -6 }, /* (50) cmd ::= COMPACT VNODES IN LP exprlist RP */
{ 199, -6 }, /* (51) cmd ::= COMPACT VNODES IN LP exprlist RP */ { 199, -1 }, /* (51) ids ::= ID */
{ 200, -1 }, /* (52) ids ::= ID */ { 199, -1 }, /* (52) ids ::= STRING */
{ 200, -1 }, /* (53) ids ::= STRING */ { 202, -2 }, /* (53) ifexists ::= IF EXISTS */
{ 203, -2 }, /* (54) ifexists ::= IF EXISTS */ { 202, 0 }, /* (54) ifexists ::= */
{ 203, 0 }, /* (55) ifexists ::= */ { 206, -3 }, /* (55) ifnotexists ::= IF NOT EXISTS */
{ 208, -3 }, /* (56) ifnotexists ::= IF NOT EXISTS */ { 206, 0 }, /* (56) ifnotexists ::= */
{ 208, 0 }, /* (57) ifnotexists ::= */ { 198, -3 }, /* (57) cmd ::= CREATE DNODE ids */
{ 199, -3 }, /* (58) cmd ::= CREATE DNODE ids */ { 198, -6 }, /* (58) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */
{ 199, -6 }, /* (59) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ { 198, -5 }, /* (59) cmd ::= CREATE DATABASE ifnotexists ids db_optr */
{ 199, -5 }, /* (60) cmd ::= CREATE DATABASE ifnotexists ids db_optr */ { 198, -8 }, /* (60) cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */
{ 199, -5 }, /* (61) cmd ::= CREATE TOPIC ifnotexists ids topic_optr */ { 198, -9 }, /* (61) cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */
{ 199, -8 }, /* (62) cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ { 198, -5 }, /* (62) cmd ::= CREATE USER ids PASS ids */
{ 199, -9 }, /* (63) cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ { 209, 0 }, /* (63) bufsize ::= */
{ 199, -5 }, /* (64) cmd ::= CREATE USER ids PASS ids */ { 209, -2 }, /* (64) bufsize ::= BUFSIZE INTEGER */
{ 212, 0 }, /* (65) bufsize ::= */ { 210, 0 }, /* (65) pps ::= */
{ 212, -2 }, /* (66) bufsize ::= BUFSIZE INTEGER */ { 210, -2 }, /* (66) pps ::= PPS INTEGER */
{ 213, 0 }, /* (67) pps ::= */ { 211, 0 }, /* (67) tseries ::= */
{ 213, -2 }, /* (68) pps ::= PPS INTEGER */ { 211, -2 }, /* (68) tseries ::= TSERIES INTEGER */
{ 214, 0 }, /* (69) tseries ::= */ { 212, 0 }, /* (69) dbs ::= */
{ 214, -2 }, /* (70) tseries ::= TSERIES INTEGER */ { 212, -2 }, /* (70) dbs ::= DBS INTEGER */
{ 215, 0 }, /* (71) dbs ::= */ { 213, 0 }, /* (71) streams ::= */
{ 215, -2 }, /* (72) dbs ::= DBS INTEGER */ { 213, -2 }, /* (72) streams ::= STREAMS INTEGER */
{ 216, 0 }, /* (73) streams ::= */ { 214, 0 }, /* (73) storage ::= */
{ 216, -2 }, /* (74) streams ::= STREAMS INTEGER */ { 214, -2 }, /* (74) storage ::= STORAGE INTEGER */
{ 217, 0 }, /* (75) storage ::= */ { 215, 0 }, /* (75) qtime ::= */
{ 217, -2 }, /* (76) storage ::= STORAGE INTEGER */ { 215, -2 }, /* (76) qtime ::= QTIME INTEGER */
{ 218, 0 }, /* (77) qtime ::= */ { 216, 0 }, /* (77) users ::= */
{ 218, -2 }, /* (78) qtime ::= QTIME INTEGER */ { 216, -2 }, /* (78) users ::= USERS INTEGER */
{ 219, 0 }, /* (79) users ::= */ { 217, 0 }, /* (79) conns ::= */
{ 219, -2 }, /* (80) users ::= USERS INTEGER */ { 217, -2 }, /* (80) conns ::= CONNS INTEGER */
{ 220, 0 }, /* (81) conns ::= */ { 218, 0 }, /* (81) state ::= */
{ 220, -2 }, /* (82) conns ::= CONNS INTEGER */ { 218, -2 }, /* (82) state ::= STATE ids */
{ 221, 0 }, /* (83) state ::= */ { 204, -9 }, /* (83) acct_optr ::= pps tseries storage streams qtime dbs users conns state */
{ 221, -2 }, /* (84) state ::= STATE ids */ { 219, -3 }, /* (84) intitemlist ::= intitemlist COMMA intitem */
{ 206, -9 }, /* (85) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ { 219, -1 }, /* (85) intitemlist ::= intitem */
{ 222, -3 }, /* (86) intitemlist ::= intitemlist COMMA intitem */ { 220, -1 }, /* (86) intitem ::= INTEGER */
{ 222, -1 }, /* (87) intitemlist ::= intitem */ { 221, -2 }, /* (87) keep ::= KEEP intitemlist */
{ 223, -1 }, /* (88) intitem ::= INTEGER */ { 222, -2 }, /* (88) cache ::= CACHE INTEGER */
{ 224, -2 }, /* (89) keep ::= KEEP intitemlist */ { 223, -2 }, /* (89) replica ::= REPLICA INTEGER */
{ 225, -2 }, /* (90) cache ::= CACHE INTEGER */ { 224, -2 }, /* (90) quorum ::= QUORUM INTEGER */
{ 226, -2 }, /* (91) replica ::= REPLICA INTEGER */ { 225, -2 }, /* (91) days ::= DAYS INTEGER */
{ 227, -2 }, /* (92) quorum ::= QUORUM INTEGER */ { 226, -2 }, /* (92) minrows ::= MINROWS INTEGER */
{ 228, -2 }, /* (93) days ::= DAYS INTEGER */ { 227, -2 }, /* (93) maxrows ::= MAXROWS INTEGER */
{ 229, -2 }, /* (94) minrows ::= MINROWS INTEGER */ { 228, -2 }, /* (94) blocks ::= BLOCKS INTEGER */
{ 230, -2 }, /* (95) maxrows ::= MAXROWS INTEGER */ { 229, -2 }, /* (95) ctime ::= CTIME INTEGER */
{ 231, -2 }, /* (96) blocks ::= BLOCKS INTEGER */ { 230, -2 }, /* (96) wal ::= WAL INTEGER */
{ 232, -2 }, /* (97) ctime ::= CTIME INTEGER */ { 231, -2 }, /* (97) fsync ::= FSYNC INTEGER */
{ 233, -2 }, /* (98) wal ::= WAL INTEGER */ { 232, -2 }, /* (98) comp ::= COMP INTEGER */
{ 234, -2 }, /* (99) fsync ::= FSYNC INTEGER */ { 233, -2 }, /* (99) prec ::= PRECISION STRING */
{ 235, -2 }, /* (100) comp ::= COMP INTEGER */ { 234, -2 }, /* (100) update ::= UPDATE INTEGER */
{ 236, -2 }, /* (101) prec ::= PRECISION STRING */ { 235, -2 }, /* (101) cachelast ::= CACHELAST INTEGER */
{ 237, -2 }, /* (102) update ::= UPDATE INTEGER */ { 207, 0 }, /* (102) db_optr ::= */
{ 238, -2 }, /* (103) cachelast ::= CACHELAST INTEGER */ { 207, -2 }, /* (103) db_optr ::= db_optr cache */
{ 239, -2 }, /* (104) partitions ::= PARTITIONS INTEGER */ { 207, -2 }, /* (104) db_optr ::= db_optr replica */
{ 209, 0 }, /* (105) db_optr ::= */ { 207, -2 }, /* (105) db_optr ::= db_optr quorum */
{ 209, -2 }, /* (106) db_optr ::= db_optr cache */ { 207, -2 }, /* (106) db_optr ::= db_optr days */
{ 209, -2 }, /* (107) db_optr ::= db_optr replica */ { 207, -2 }, /* (107) db_optr ::= db_optr minrows */
{ 209, -2 }, /* (108) db_optr ::= db_optr quorum */ { 207, -2 }, /* (108) db_optr ::= db_optr maxrows */
{ 209, -2 }, /* (109) db_optr ::= db_optr days */ { 207, -2 }, /* (109) db_optr ::= db_optr blocks */
{ 209, -2 }, /* (110) db_optr ::= db_optr minrows */ { 207, -2 }, /* (110) db_optr ::= db_optr ctime */
{ 209, -2 }, /* (111) db_optr ::= db_optr maxrows */ { 207, -2 }, /* (111) db_optr ::= db_optr wal */
{ 209, -2 }, /* (112) db_optr ::= db_optr blocks */ { 207, -2 }, /* (112) db_optr ::= db_optr fsync */
{ 209, -2 }, /* (113) db_optr ::= db_optr ctime */ { 207, -2 }, /* (113) db_optr ::= db_optr comp */
{ 209, -2 }, /* (114) db_optr ::= db_optr wal */ { 207, -2 }, /* (114) db_optr ::= db_optr prec */
{ 209, -2 }, /* (115) db_optr ::= db_optr fsync */ { 207, -2 }, /* (115) db_optr ::= db_optr keep */
{ 209, -2 }, /* (116) db_optr ::= db_optr comp */ { 207, -2 }, /* (116) db_optr ::= db_optr update */
{ 209, -2 }, /* (117) db_optr ::= db_optr prec */ { 207, -2 }, /* (117) db_optr ::= db_optr cachelast */
{ 209, -2 }, /* (118) db_optr ::= db_optr keep */ { 203, 0 }, /* (118) alter_db_optr ::= */
{ 209, -2 }, /* (119) db_optr ::= db_optr update */ { 203, -2 }, /* (119) alter_db_optr ::= alter_db_optr replica */
{ 209, -2 }, /* (120) db_optr ::= db_optr cachelast */ { 203, -2 }, /* (120) alter_db_optr ::= alter_db_optr quorum */
{ 210, -1 }, /* (121) topic_optr ::= db_optr */ { 203, -2 }, /* (121) alter_db_optr ::= alter_db_optr keep */
{ 210, -2 }, /* (122) topic_optr ::= topic_optr partitions */ { 203, -2 }, /* (122) alter_db_optr ::= alter_db_optr blocks */
{ 204, 0 }, /* (123) alter_db_optr ::= */ { 203, -2 }, /* (123) alter_db_optr ::= alter_db_optr comp */
{ 204, -2 }, /* (124) alter_db_optr ::= alter_db_optr replica */ { 203, -2 }, /* (124) alter_db_optr ::= alter_db_optr update */
{ 204, -2 }, /* (125) alter_db_optr ::= alter_db_optr quorum */ { 203, -2 }, /* (125) alter_db_optr ::= alter_db_optr cachelast */
{ 204, -2 }, /* (126) alter_db_optr ::= alter_db_optr keep */ { 208, -1 }, /* (126) typename ::= ids */
{ 204, -2 }, /* (127) alter_db_optr ::= alter_db_optr blocks */ { 208, -4 }, /* (127) typename ::= ids LP signed RP */
{ 204, -2 }, /* (128) alter_db_optr ::= alter_db_optr comp */ { 208, -2 }, /* (128) typename ::= ids UNSIGNED */
{ 204, -2 }, /* (129) alter_db_optr ::= alter_db_optr update */ { 236, -1 }, /* (129) signed ::= INTEGER */
{ 204, -2 }, /* (130) alter_db_optr ::= alter_db_optr cachelast */ { 236, -2 }, /* (130) signed ::= PLUS INTEGER */
{ 205, -1 }, /* (131) alter_topic_optr ::= alter_db_optr */ { 236, -2 }, /* (131) signed ::= MINUS INTEGER */
{ 205, -2 }, /* (132) alter_topic_optr ::= alter_topic_optr partitions */ { 198, -3 }, /* (132) cmd ::= CREATE TABLE create_table_args */
{ 211, -1 }, /* (133) typename ::= ids */ { 198, -3 }, /* (133) cmd ::= CREATE TABLE create_stable_args */
{ 211, -4 }, /* (134) typename ::= ids LP signed RP */ { 198, -3 }, /* (134) cmd ::= CREATE STABLE create_stable_args */
{ 211, -2 }, /* (135) typename ::= ids UNSIGNED */ { 198, -3 }, /* (135) cmd ::= CREATE TABLE create_table_list */
{ 240, -1 }, /* (136) signed ::= INTEGER */ { 239, -1 }, /* (136) create_table_list ::= create_from_stable */
{ 240, -2 }, /* (137) signed ::= PLUS INTEGER */ { 239, -2 }, /* (137) create_table_list ::= create_table_list create_from_stable */
{ 240, -2 }, /* (138) signed ::= MINUS INTEGER */ { 237, -6 }, /* (138) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */
{ 199, -3 }, /* (139) cmd ::= CREATE TABLE create_table_args */ { 238, -10 }, /* (139) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */
{ 199, -3 }, /* (140) cmd ::= CREATE TABLE create_stable_args */ { 240, -10 }, /* (140) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */
{ 199, -3 }, /* (141) cmd ::= CREATE STABLE create_stable_args */ { 240, -13 }, /* (141) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */
{ 199, -3 }, /* (142) cmd ::= CREATE TABLE create_table_list */ { 243, -3 }, /* (142) tagNamelist ::= tagNamelist COMMA ids */
{ 243, -1 }, /* (143) create_table_list ::= create_from_stable */ { 243, -1 }, /* (143) tagNamelist ::= ids */
{ 243, -2 }, /* (144) create_table_list ::= create_table_list create_from_stable */ { 237, -5 }, /* (144) create_table_args ::= ifnotexists ids cpxName AS select */
{ 241, -6 }, /* (145) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ { 241, -3 }, /* (145) columnlist ::= columnlist COMMA column */
{ 242, -10 }, /* (146) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ { 241, -1 }, /* (146) columnlist ::= column */
{ 244, -10 }, /* (147) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ { 245, -2 }, /* (147) column ::= ids typename */
{ 244, -13 }, /* (148) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ { 242, -3 }, /* (148) tagitemlist ::= tagitemlist COMMA tagitem */
{ 247, -3 }, /* (149) tagNamelist ::= tagNamelist COMMA ids */ { 242, -1 }, /* (149) tagitemlist ::= tagitem */
{ 247, -1 }, /* (150) tagNamelist ::= ids */ { 246, -1 }, /* (150) tagitem ::= INTEGER */
{ 241, -5 }, /* (151) create_table_args ::= ifnotexists ids cpxName AS select */ { 246, -1 }, /* (151) tagitem ::= FLOAT */
{ 245, -3 }, /* (152) columnlist ::= columnlist COMMA column */ { 246, -1 }, /* (152) tagitem ::= STRING */
{ 245, -1 }, /* (153) columnlist ::= column */ { 246, -1 }, /* (153) tagitem ::= BOOL */
{ 249, -2 }, /* (154) column ::= ids typename */ { 246, -1 }, /* (154) tagitem ::= NULL */
{ 246, -3 }, /* (155) tagitemlist ::= tagitemlist COMMA tagitem */ { 246, -1 }, /* (155) tagitem ::= NOW */
{ 246, -1 }, /* (156) tagitemlist ::= tagitem */ { 246, -2 }, /* (156) tagitem ::= MINUS INTEGER */
{ 250, -1 }, /* (157) tagitem ::= INTEGER */ { 246, -2 }, /* (157) tagitem ::= MINUS FLOAT */
{ 250, -1 }, /* (158) tagitem ::= FLOAT */ { 246, -2 }, /* (158) tagitem ::= PLUS INTEGER */
{ 250, -1 }, /* (159) tagitem ::= STRING */ { 246, -2 }, /* (159) tagitem ::= PLUS FLOAT */
{ 250, -1 }, /* (160) tagitem ::= BOOL */ { 244, -14 }, /* (160) 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 */
{ 250, -1 }, /* (161) tagitem ::= NULL */ { 244, -3 }, /* (161) select ::= LP select RP */
{ 250, -1 }, /* (162) tagitem ::= NOW */ { 260, -1 }, /* (162) union ::= select */
{ 250, -2 }, /* (163) tagitem ::= MINUS INTEGER */ { 260, -4 }, /* (163) union ::= union UNION ALL select */
{ 250, -2 }, /* (164) tagitem ::= MINUS FLOAT */ { 260, -3 }, /* (164) union ::= union UNION select */
{ 250, -2 }, /* (165) tagitem ::= PLUS INTEGER */ { 198, -1 }, /* (165) cmd ::= union */
{ 250, -2 }, /* (166) tagitem ::= PLUS FLOAT */ { 244, -2 }, /* (166) select ::= SELECT selcollist */
{ 248, -14 }, /* (167) 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 */ { 261, -2 }, /* (167) sclp ::= selcollist COMMA */
{ 248, -3 }, /* (168) select ::= LP select RP */ { 261, 0 }, /* (168) sclp ::= */
{ 264, -1 }, /* (169) union ::= select */ { 247, -4 }, /* (169) selcollist ::= sclp distinct expr as */
{ 264, -4 }, /* (170) union ::= union UNION ALL select */ { 247, -2 }, /* (170) selcollist ::= sclp STAR */
{ 264, -3 }, /* (171) union ::= union UNION select */ { 264, -2 }, /* (171) as ::= AS ids */
{ 199, -1 }, /* (172) cmd ::= union */ { 264, -1 }, /* (172) as ::= ids */
{ 248, -2 }, /* (173) select ::= SELECT selcollist */ { 264, 0 }, /* (173) as ::= */
{ 265, -2 }, /* (174) sclp ::= selcollist COMMA */ { 262, -1 }, /* (174) distinct ::= DISTINCT */
{ 265, 0 }, /* (175) sclp ::= */ { 262, 0 }, /* (175) distinct ::= */
{ 251, -4 }, /* (176) selcollist ::= sclp distinct expr as */ { 248, -2 }, /* (176) from ::= FROM tablelist */
{ 251, -2 }, /* (177) selcollist ::= sclp STAR */ { 248, -2 }, /* (177) from ::= FROM sub */
{ 268, -2 }, /* (178) as ::= AS ids */ { 266, -3 }, /* (178) sub ::= LP union RP */
{ 268, -1 }, /* (179) as ::= ids */ { 266, -4 }, /* (179) sub ::= LP union RP ids */
{ 268, 0 }, /* (180) as ::= */ { 266, -6 }, /* (180) sub ::= sub COMMA LP union RP ids */
{ 266, -1 }, /* (181) distinct ::= DISTINCT */ { 265, -2 }, /* (181) tablelist ::= ids cpxName */
{ 266, 0 }, /* (182) distinct ::= */ { 265, -3 }, /* (182) tablelist ::= ids cpxName ids */
{ 252, -2 }, /* (183) from ::= FROM tablelist */ { 265, -4 }, /* (183) tablelist ::= tablelist COMMA ids cpxName */
{ 252, -2 }, /* (184) from ::= FROM sub */ { 265, -5 }, /* (184) tablelist ::= tablelist COMMA ids cpxName ids */
{ 270, -3 }, /* (185) sub ::= LP union RP */ { 267, -1 }, /* (185) tmvar ::= VARIABLE */
{ 270, -4 }, /* (186) sub ::= LP union RP ids */ { 250, -4 }, /* (186) interval_option ::= intervalKey LP tmvar RP */
{ 270, -6 }, /* (187) sub ::= sub COMMA LP union RP ids */ { 250, -6 }, /* (187) interval_option ::= intervalKey LP tmvar COMMA tmvar RP */
{ 269, -2 }, /* (188) tablelist ::= ids cpxName */ { 250, 0 }, /* (188) interval_option ::= */
{ 269, -3 }, /* (189) tablelist ::= ids cpxName ids */ { 268, -1 }, /* (189) intervalKey ::= INTERVAL */
{ 269, -4 }, /* (190) tablelist ::= tablelist COMMA ids cpxName */ { 268, -1 }, /* (190) intervalKey ::= EVERY */
{ 269, -5 }, /* (191) tablelist ::= tablelist COMMA ids cpxName ids */ { 252, 0 }, /* (191) session_option ::= */
{ 271, -1 }, /* (192) tmvar ::= VARIABLE */ { 252, -7 }, /* (192) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */
{ 254, -4 }, /* (193) interval_option ::= intervalKey LP tmvar RP */ { 253, 0 }, /* (193) windowstate_option ::= */
{ 254, -6 }, /* (194) interval_option ::= intervalKey LP tmvar COMMA tmvar RP */ { 253, -4 }, /* (194) windowstate_option ::= STATE_WINDOW LP ids RP */
{ 254, 0 }, /* (195) interval_option ::= */ { 254, 0 }, /* (195) fill_opt ::= */
{ 272, -1 }, /* (196) intervalKey ::= INTERVAL */ { 254, -6 }, /* (196) fill_opt ::= FILL LP ID COMMA tagitemlist RP */
{ 272, -1 }, /* (197) intervalKey ::= EVERY */ { 254, -4 }, /* (197) fill_opt ::= FILL LP ID RP */
{ 256, 0 }, /* (198) session_option ::= */ { 251, -4 }, /* (198) sliding_opt ::= SLIDING LP tmvar RP */
{ 256, -7 }, /* (199) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ { 251, 0 }, /* (199) sliding_opt ::= */
{ 257, 0 }, /* (200) windowstate_option ::= */ { 257, 0 }, /* (200) orderby_opt ::= */
{ 257, -4 }, /* (201) windowstate_option ::= STATE_WINDOW LP ids RP */ { 257, -3 }, /* (201) orderby_opt ::= ORDER BY sortlist */
{ 258, 0 }, /* (202) fill_opt ::= */ { 269, -4 }, /* (202) sortlist ::= sortlist COMMA item sortorder */
{ 258, -6 }, /* (203) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ { 269, -2 }, /* (203) sortlist ::= item sortorder */
{ 258, -4 }, /* (204) fill_opt ::= FILL LP ID RP */ { 271, -2 }, /* (204) item ::= ids cpxName */
{ 255, -4 }, /* (205) sliding_opt ::= SLIDING LP tmvar RP */ { 272, -1 }, /* (205) sortorder ::= ASC */
{ 255, 0 }, /* (206) sliding_opt ::= */ { 272, -1 }, /* (206) sortorder ::= DESC */
{ 261, 0 }, /* (207) orderby_opt ::= */ { 272, 0 }, /* (207) sortorder ::= */
{ 261, -3 }, /* (208) orderby_opt ::= ORDER BY sortlist */ { 255, 0 }, /* (208) groupby_opt ::= */
{ 273, -4 }, /* (209) sortlist ::= sortlist COMMA item sortorder */ { 255, -3 }, /* (209) groupby_opt ::= GROUP BY grouplist */
{ 273, -2 }, /* (210) sortlist ::= item sortorder */ { 273, -3 }, /* (210) grouplist ::= grouplist COMMA item */
{ 275, -2 }, /* (211) item ::= ids cpxName */ { 273, -1 }, /* (211) grouplist ::= item */
{ 276, -1 }, /* (212) sortorder ::= ASC */ { 256, 0 }, /* (212) having_opt ::= */
{ 276, -1 }, /* (213) sortorder ::= DESC */ { 256, -2 }, /* (213) having_opt ::= HAVING expr */
{ 276, 0 }, /* (214) sortorder ::= */ { 259, 0 }, /* (214) limit_opt ::= */
{ 259, 0 }, /* (215) groupby_opt ::= */ { 259, -2 }, /* (215) limit_opt ::= LIMIT signed */
{ 259, -3 }, /* (216) groupby_opt ::= GROUP BY grouplist */ { 259, -4 }, /* (216) limit_opt ::= LIMIT signed OFFSET signed */
{ 277, -3 }, /* (217) grouplist ::= grouplist COMMA item */ { 259, -4 }, /* (217) limit_opt ::= LIMIT signed COMMA signed */
{ 277, -1 }, /* (218) grouplist ::= item */ { 258, 0 }, /* (218) slimit_opt ::= */
{ 260, 0 }, /* (219) having_opt ::= */ { 258, -2 }, /* (219) slimit_opt ::= SLIMIT signed */
{ 260, -2 }, /* (220) having_opt ::= HAVING expr */ { 258, -4 }, /* (220) slimit_opt ::= SLIMIT signed SOFFSET signed */
{ 263, 0 }, /* (221) limit_opt ::= */ { 258, -4 }, /* (221) slimit_opt ::= SLIMIT signed COMMA signed */
{ 263, -2 }, /* (222) limit_opt ::= LIMIT signed */ { 249, 0 }, /* (222) where_opt ::= */
{ 263, -4 }, /* (223) limit_opt ::= LIMIT signed OFFSET signed */ { 249, -2 }, /* (223) where_opt ::= WHERE expr */
{ 263, -4 }, /* (224) limit_opt ::= LIMIT signed COMMA signed */ { 263, -3 }, /* (224) expr ::= LP expr RP */
{ 262, 0 }, /* (225) slimit_opt ::= */ { 263, -1 }, /* (225) expr ::= ID */
{ 262, -2 }, /* (226) slimit_opt ::= SLIMIT signed */ { 263, -3 }, /* (226) expr ::= ID DOT ID */
{ 262, -4 }, /* (227) slimit_opt ::= SLIMIT signed SOFFSET signed */ { 263, -3 }, /* (227) expr ::= ID DOT STAR */
{ 262, -4 }, /* (228) slimit_opt ::= SLIMIT signed COMMA signed */ { 263, -1 }, /* (228) expr ::= INTEGER */
{ 253, 0 }, /* (229) where_opt ::= */ { 263, -2 }, /* (229) expr ::= MINUS INTEGER */
{ 253, -2 }, /* (230) where_opt ::= WHERE expr */ { 263, -2 }, /* (230) expr ::= PLUS INTEGER */
{ 267, -3 }, /* (231) expr ::= LP expr RP */ { 263, -1 }, /* (231) expr ::= FLOAT */
{ 267, -1 }, /* (232) expr ::= ID */ { 263, -2 }, /* (232) expr ::= MINUS FLOAT */
{ 267, -3 }, /* (233) expr ::= ID DOT ID */ { 263, -2 }, /* (233) expr ::= PLUS FLOAT */
{ 267, -3 }, /* (234) expr ::= ID DOT STAR */ { 263, -1 }, /* (234) expr ::= STRING */
{ 267, -1 }, /* (235) expr ::= INTEGER */ { 263, -1 }, /* (235) expr ::= NOW */
{ 267, -2 }, /* (236) expr ::= MINUS INTEGER */ { 263, -1 }, /* (236) expr ::= VARIABLE */
{ 267, -2 }, /* (237) expr ::= PLUS INTEGER */ { 263, -2 }, /* (237) expr ::= PLUS VARIABLE */
{ 267, -1 }, /* (238) expr ::= FLOAT */ { 263, -2 }, /* (238) expr ::= MINUS VARIABLE */
{ 267, -2 }, /* (239) expr ::= MINUS FLOAT */ { 263, -1 }, /* (239) expr ::= BOOL */
{ 267, -2 }, /* (240) expr ::= PLUS FLOAT */ { 263, -1 }, /* (240) expr ::= NULL */
{ 267, -1 }, /* (241) expr ::= STRING */ { 263, -4 }, /* (241) expr ::= ID LP exprlist RP */
{ 267, -1 }, /* (242) expr ::= NOW */ { 263, -4 }, /* (242) expr ::= ID LP STAR RP */
{ 267, -1 }, /* (243) expr ::= VARIABLE */ { 263, -3 }, /* (243) expr ::= expr IS NULL */
{ 267, -2 }, /* (244) expr ::= PLUS VARIABLE */ { 263, -4 }, /* (244) expr ::= expr IS NOT NULL */
{ 267, -2 }, /* (245) expr ::= MINUS VARIABLE */ { 263, -3 }, /* (245) expr ::= expr LT expr */
{ 267, -1 }, /* (246) expr ::= BOOL */ { 263, -3 }, /* (246) expr ::= expr GT expr */
{ 267, -1 }, /* (247) expr ::= NULL */ { 263, -3 }, /* (247) expr ::= expr LE expr */
{ 267, -4 }, /* (248) expr ::= ID LP exprlist RP */ { 263, -3 }, /* (248) expr ::= expr GE expr */
{ 267, -4 }, /* (249) expr ::= ID LP STAR RP */ { 263, -3 }, /* (249) expr ::= expr NE expr */
{ 267, -3 }, /* (250) expr ::= expr IS NULL */ { 263, -3 }, /* (250) expr ::= expr EQ expr */
{ 267, -4 }, /* (251) expr ::= expr IS NOT NULL */ { 263, -5 }, /* (251) expr ::= expr BETWEEN expr AND expr */
{ 267, -3 }, /* (252) expr ::= expr LT expr */ { 263, -3 }, /* (252) expr ::= expr AND expr */
{ 267, -3 }, /* (253) expr ::= expr GT expr */ { 263, -3 }, /* (253) expr ::= expr OR expr */
{ 267, -3 }, /* (254) expr ::= expr LE expr */ { 263, -3 }, /* (254) expr ::= expr PLUS expr */
{ 267, -3 }, /* (255) expr ::= expr GE expr */ { 263, -3 }, /* (255) expr ::= expr MINUS expr */
{ 267, -3 }, /* (256) expr ::= expr NE expr */ { 263, -3 }, /* (256) expr ::= expr STAR expr */
{ 267, -3 }, /* (257) expr ::= expr EQ expr */ { 263, -3 }, /* (257) expr ::= expr SLASH expr */
{ 267, -5 }, /* (258) expr ::= expr BETWEEN expr AND expr */ { 263, -3 }, /* (258) expr ::= expr REM expr */
{ 267, -3 }, /* (259) expr ::= expr AND expr */ { 263, -3 }, /* (259) expr ::= expr LIKE expr */
{ 267, -3 }, /* (260) expr ::= expr OR expr */ { 263, -3 }, /* (260) expr ::= expr MATCH expr */
{ 267, -3 }, /* (261) expr ::= expr PLUS expr */ { 263, -3 }, /* (261) expr ::= expr NMATCH expr */
{ 267, -3 }, /* (262) expr ::= expr MINUS expr */ { 263, -5 }, /* (262) expr ::= expr IN LP exprlist RP */
{ 267, -3 }, /* (263) expr ::= expr STAR expr */ { 205, -3 }, /* (263) exprlist ::= exprlist COMMA expritem */
{ 267, -3 }, /* (264) expr ::= expr SLASH expr */ { 205, -1 }, /* (264) exprlist ::= expritem */
{ 267, -3 }, /* (265) expr ::= expr REM expr */ { 274, -1 }, /* (265) expritem ::= expr */
{ 267, -3 }, /* (266) expr ::= expr LIKE expr */ { 274, 0 }, /* (266) expritem ::= */
{ 267, -3 }, /* (267) expr ::= expr MATCH expr */ { 198, -3 }, /* (267) cmd ::= RESET QUERY CACHE */
{ 267, -3 }, /* (268) expr ::= expr NMATCH expr */ { 198, -3 }, /* (268) cmd ::= SYNCDB ids REPLICA */
{ 267, -5 }, /* (269) expr ::= expr IN LP exprlist RP */ { 198, -7 }, /* (269) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */
{ 207, -3 }, /* (270) exprlist ::= exprlist COMMA expritem */ { 198, -7 }, /* (270) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */
{ 207, -1 }, /* (271) exprlist ::= expritem */ { 198, -7 }, /* (271) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */
{ 278, -1 }, /* (272) expritem ::= expr */ { 198, -7 }, /* (272) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */
{ 278, 0 }, /* (273) expritem ::= */ { 198, -7 }, /* (273) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */
{ 199, -3 }, /* (274) cmd ::= RESET QUERY CACHE */ { 198, -8 }, /* (274) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */
{ 199, -3 }, /* (275) cmd ::= SYNCDB ids REPLICA */ { 198, -9 }, /* (275) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */
{ 199, -7 }, /* (276) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ { 198, -7 }, /* (276) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */
{ 199, -7 }, /* (277) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ { 198, -7 }, /* (277) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */
{ 199, -7 }, /* (278) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ { 198, -7 }, /* (278) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */
{ 199, -7 }, /* (279) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ { 198, -7 }, /* (279) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */
{ 199, -7 }, /* (280) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ { 198, -7 }, /* (280) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */
{ 199, -8 }, /* (281) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ { 198, -7 }, /* (281) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */
{ 199, -9 }, /* (282) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ { 198, -8 }, /* (282) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */
{ 199, -7 }, /* (283) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ { 198, -9 }, /* (283) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */
{ 199, -7 }, /* (284) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ { 198, -7 }, /* (284) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */
{ 199, -7 }, /* (285) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ { 198, -3 }, /* (285) cmd ::= KILL CONNECTION INTEGER */
{ 199, -7 }, /* (286) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ { 198, -5 }, /* (286) cmd ::= KILL STREAM INTEGER COLON INTEGER */
{ 199, -7 }, /* (287) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ { 198, -5 }, /* (287) cmd ::= KILL QUERY INTEGER COLON INTEGER */
{ 199, -7 }, /* (288) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */
{ 199, -8 }, /* (289) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */
{ 199, -9 }, /* (290) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */
{ 199, -7 }, /* (291) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */
{ 199, -3 }, /* (292) cmd ::= KILL CONNECTION INTEGER */
{ 199, -5 }, /* (293) cmd ::= KILL STREAM INTEGER COLON INTEGER */
{ 199, -5 }, /* (294) cmd ::= KILL QUERY INTEGER COLON INTEGER */
}; };
static void yy_accept(yyParser*); /* Forward Declaration */ static void yy_accept(yyParser*); /* Forward Declaration */
...@@ -2218,9 +2193,9 @@ static void yy_reduce( ...@@ -2218,9 +2193,9 @@ static void yy_reduce(
/********** Begin reduce actions **********************************************/ /********** Begin reduce actions **********************************************/
YYMINORTYPE yylhsminor; YYMINORTYPE yylhsminor;
case 0: /* program ::= cmd */ case 0: /* program ::= cmd */
case 139: /* cmd ::= CREATE TABLE create_table_args */ yytestcase(yyruleno==139); case 132: /* cmd ::= CREATE TABLE create_table_args */ yytestcase(yyruleno==132);
case 140: /* cmd ::= CREATE TABLE create_stable_args */ yytestcase(yyruleno==140); case 133: /* cmd ::= CREATE TABLE create_stable_args */ yytestcase(yyruleno==133);
case 141: /* cmd ::= CREATE STABLE create_stable_args */ yytestcase(yyruleno==141); case 134: /* cmd ::= CREATE STABLE create_stable_args */ yytestcase(yyruleno==134);
{} {}
break; break;
case 1: /* cmd ::= SHOW DATABASES */ case 1: /* cmd ::= SHOW DATABASES */
...@@ -2396,780 +2371,767 @@ static void yy_reduce( ...@@ -2396,780 +2371,767 @@ 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 */
case 48: /* cmd ::= ALTER TOPIC ids alter_topic_optr */ yytestcase(yyruleno==48); { SToken t = {0}; setCreateDbInfo(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy42, &t);}
{ SToken t = {0}; setCreateDbInfo(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy256, &t);}
break; break;
case 49: /* 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.yy277);} { setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy341);}
break; break;
case 50: /* cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ case 49: /* cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */
{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy277);} { setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy341);}
break; break;
case 51: /* 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.yy135);} { setCompactVnodeSql(pInfo, TSDB_SQL_COMPACT_VNODE, yymsp[-1].minor.yy131);}
break; break;
case 52: /* ids ::= ID */ case 51: /* ids ::= ID */
case 53: /* ids ::= STRING */ yytestcase(yyruleno==53); case 52: /* ids ::= STRING */ yytestcase(yyruleno==52);
{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 54: /* ifexists ::= IF EXISTS */ case 53: /* ifexists ::= IF EXISTS */
{ yymsp[-1].minor.yy0.n = 1;} { yymsp[-1].minor.yy0.n = 1;}
break; break;
case 55: /* ifexists ::= */ case 54: /* ifexists ::= */
case 57: /* ifnotexists ::= */ yytestcase(yyruleno==57); case 56: /* ifnotexists ::= */ yytestcase(yyruleno==56);
case 182: /* distinct ::= */ yytestcase(yyruleno==182); case 175: /* distinct ::= */ yytestcase(yyruleno==175);
{ yymsp[1].minor.yy0.n = 0;} { yymsp[1].minor.yy0.n = 0;}
break; break;
case 56: /* 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 58: /* cmd ::= CREATE DNODE ids */ case 57: /* cmd ::= CREATE DNODE ids */
{ setDCLSqlElems(pInfo, TSDB_SQL_CREATE_DNODE, 1, &yymsp[0].minor.yy0);} { setDCLSqlElems(pInfo, TSDB_SQL_CREATE_DNODE, 1, &yymsp[0].minor.yy0);}
break; break;
case 59: /* cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ case 58: /* 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.yy277);} { setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy341);}
break; break;
case 60: /* cmd ::= CREATE DATABASE ifnotexists ids db_optr */ case 59: /* cmd ::= CREATE DATABASE ifnotexists ids db_optr */
case 61: /* cmd ::= CREATE TOPIC ifnotexists ids topic_optr */ yytestcase(yyruleno==61); { setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy42, &yymsp[-2].minor.yy0);}
{ setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy256, &yymsp[-2].minor.yy0);}
break; break;
case 62: /* cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ case 60: /* 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.yy304, &yymsp[0].minor.yy0, 1);} { setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &yymsp[-5].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy290, &yymsp[0].minor.yy0, 1);}
break; break;
case 63: /* cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ case 61: /* 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.yy304, &yymsp[0].minor.yy0, 2);} { setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &yymsp[-5].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy290, &yymsp[0].minor.yy0, 2);}
break; break;
case 64: /* cmd ::= CREATE USER ids PASS ids */ case 62: /* 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 65: /* bufsize ::= */ case 63: /* bufsize ::= */
case 67: /* pps ::= */ yytestcase(yyruleno==67); case 65: /* pps ::= */ yytestcase(yyruleno==65);
case 69: /* tseries ::= */ yytestcase(yyruleno==69); case 67: /* tseries ::= */ yytestcase(yyruleno==67);
case 71: /* dbs ::= */ yytestcase(yyruleno==71); case 69: /* dbs ::= */ yytestcase(yyruleno==69);
case 73: /* streams ::= */ yytestcase(yyruleno==73); case 71: /* streams ::= */ yytestcase(yyruleno==71);
case 75: /* storage ::= */ yytestcase(yyruleno==75); case 73: /* storage ::= */ yytestcase(yyruleno==73);
case 77: /* qtime ::= */ yytestcase(yyruleno==77); case 75: /* qtime ::= */ yytestcase(yyruleno==75);
case 79: /* users ::= */ yytestcase(yyruleno==79); case 77: /* users ::= */ yytestcase(yyruleno==77);
case 81: /* conns ::= */ yytestcase(yyruleno==81); case 79: /* conns ::= */ yytestcase(yyruleno==79);
case 83: /* state ::= */ yytestcase(yyruleno==83); case 81: /* state ::= */ yytestcase(yyruleno==81);
{ yymsp[1].minor.yy0.n = 0; } { yymsp[1].minor.yy0.n = 0; }
break; break;
case 66: /* bufsize ::= BUFSIZE INTEGER */ case 64: /* bufsize ::= BUFSIZE INTEGER */
case 68: /* pps ::= PPS INTEGER */ yytestcase(yyruleno==68); case 66: /* pps ::= PPS INTEGER */ yytestcase(yyruleno==66);
case 70: /* tseries ::= TSERIES INTEGER */ yytestcase(yyruleno==70); case 68: /* tseries ::= TSERIES INTEGER */ yytestcase(yyruleno==68);
case 72: /* dbs ::= DBS INTEGER */ yytestcase(yyruleno==72); case 70: /* dbs ::= DBS INTEGER */ yytestcase(yyruleno==70);
case 74: /* streams ::= STREAMS INTEGER */ yytestcase(yyruleno==74); case 72: /* streams ::= STREAMS INTEGER */ yytestcase(yyruleno==72);
case 76: /* storage ::= STORAGE INTEGER */ yytestcase(yyruleno==76); case 74: /* storage ::= STORAGE INTEGER */ yytestcase(yyruleno==74);
case 78: /* qtime ::= QTIME INTEGER */ yytestcase(yyruleno==78); case 76: /* qtime ::= QTIME INTEGER */ yytestcase(yyruleno==76);
case 80: /* users ::= USERS INTEGER */ yytestcase(yyruleno==80); case 78: /* users ::= USERS INTEGER */ yytestcase(yyruleno==78);
case 82: /* conns ::= CONNS INTEGER */ yytestcase(yyruleno==82); case 80: /* conns ::= CONNS INTEGER */ yytestcase(yyruleno==80);
case 84: /* state ::= STATE ids */ yytestcase(yyruleno==84); case 82: /* state ::= STATE ids */ yytestcase(yyruleno==82);
{ yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; }
break; break;
case 85: /* acct_optr ::= pps tseries storage streams qtime dbs users conns state */ case 83: /* acct_optr ::= pps tseries storage streams qtime dbs users conns state */
{ {
yylhsminor.yy277.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1; yylhsminor.yy341.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1;
yylhsminor.yy277.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1; yylhsminor.yy341.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1;
yylhsminor.yy277.maxTimeSeries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1; yylhsminor.yy341.maxTimeSeries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1;
yylhsminor.yy277.maxStreams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1; yylhsminor.yy341.maxStreams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1;
yylhsminor.yy277.maxPointsPerSecond = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1; yylhsminor.yy341.maxPointsPerSecond = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1;
yylhsminor.yy277.maxStorage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1; yylhsminor.yy341.maxStorage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1;
yylhsminor.yy277.maxQueryTime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1; yylhsminor.yy341.maxQueryTime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1;
yylhsminor.yy277.maxConnections = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1; yylhsminor.yy341.maxConnections = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1;
yylhsminor.yy277.stat = yymsp[0].minor.yy0; yylhsminor.yy341.stat = yymsp[0].minor.yy0;
} }
yymsp[-8].minor.yy277 = yylhsminor.yy277; yymsp[-8].minor.yy341 = yylhsminor.yy341;
break; break;
case 86: /* intitemlist ::= intitemlist COMMA intitem */ case 84: /* intitemlist ::= intitemlist COMMA intitem */
case 155: /* tagitemlist ::= tagitemlist COMMA tagitem */ yytestcase(yyruleno==155); case 148: /* tagitemlist ::= tagitemlist COMMA tagitem */ yytestcase(yyruleno==148);
{ yylhsminor.yy135 = tListItemAppend(yymsp[-2].minor.yy135, &yymsp[0].minor.yy191, -1); } { yylhsminor.yy131 = tListItemAppend(yymsp[-2].minor.yy131, &yymsp[0].minor.yy43, -1); }
yymsp[-2].minor.yy135 = yylhsminor.yy135; yymsp[-2].minor.yy131 = yylhsminor.yy131;
break; break;
case 87: /* intitemlist ::= intitem */ case 85: /* intitemlist ::= intitem */
case 156: /* tagitemlist ::= tagitem */ yytestcase(yyruleno==156); case 149: /* tagitemlist ::= tagitem */ yytestcase(yyruleno==149);
{ yylhsminor.yy135 = tListItemAppend(NULL, &yymsp[0].minor.yy191, -1); } { yylhsminor.yy131 = tListItemAppend(NULL, &yymsp[0].minor.yy43, -1); }
yymsp[0].minor.yy135 = yylhsminor.yy135; yymsp[0].minor.yy131 = yylhsminor.yy131;
break; break;
case 88: /* intitem ::= INTEGER */ case 86: /* intitem ::= INTEGER */
case 157: /* tagitem ::= INTEGER */ yytestcase(yyruleno==157); case 150: /* tagitem ::= INTEGER */ yytestcase(yyruleno==150);
case 158: /* tagitem ::= FLOAT */ yytestcase(yyruleno==158); case 151: /* tagitem ::= FLOAT */ yytestcase(yyruleno==151);
case 159: /* tagitem ::= STRING */ yytestcase(yyruleno==159); case 152: /* tagitem ::= STRING */ yytestcase(yyruleno==152);
case 160: /* tagitem ::= BOOL */ yytestcase(yyruleno==160); case 153: /* tagitem ::= BOOL */ yytestcase(yyruleno==153);
{ toTSDBType(yymsp[0].minor.yy0.type); taosVariantCreate(&yylhsminor.yy191, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.type); } { toTSDBType(yymsp[0].minor.yy0.type); taosVariantCreate(&yylhsminor.yy43, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.type); }
yymsp[0].minor.yy191 = yylhsminor.yy191; yymsp[0].minor.yy43 = yylhsminor.yy43;
break; break;
case 89: /* keep ::= KEEP intitemlist */ case 87: /* keep ::= KEEP intitemlist */
{ yymsp[-1].minor.yy135 = yymsp[0].minor.yy135; } { yymsp[-1].minor.yy131 = yymsp[0].minor.yy131; }
break; break;
case 90: /* cache ::= CACHE INTEGER */ case 88: /* cache ::= CACHE INTEGER */
case 91: /* replica ::= REPLICA INTEGER */ yytestcase(yyruleno==91); case 89: /* replica ::= REPLICA INTEGER */ yytestcase(yyruleno==89);
case 92: /* quorum ::= QUORUM INTEGER */ yytestcase(yyruleno==92); case 90: /* quorum ::= QUORUM INTEGER */ yytestcase(yyruleno==90);
case 93: /* days ::= DAYS INTEGER */ yytestcase(yyruleno==93); case 91: /* days ::= DAYS INTEGER */ yytestcase(yyruleno==91);
case 94: /* minrows ::= MINROWS INTEGER */ yytestcase(yyruleno==94); case 92: /* minrows ::= MINROWS INTEGER */ yytestcase(yyruleno==92);
case 95: /* maxrows ::= MAXROWS INTEGER */ yytestcase(yyruleno==95); case 93: /* maxrows ::= MAXROWS INTEGER */ yytestcase(yyruleno==93);
case 96: /* blocks ::= BLOCKS INTEGER */ yytestcase(yyruleno==96); case 94: /* blocks ::= BLOCKS INTEGER */ yytestcase(yyruleno==94);
case 97: /* ctime ::= CTIME INTEGER */ yytestcase(yyruleno==97); case 95: /* ctime ::= CTIME INTEGER */ yytestcase(yyruleno==95);
case 98: /* wal ::= WAL INTEGER */ yytestcase(yyruleno==98); case 96: /* wal ::= WAL INTEGER */ yytestcase(yyruleno==96);
case 99: /* fsync ::= FSYNC INTEGER */ yytestcase(yyruleno==99); case 97: /* fsync ::= FSYNC INTEGER */ yytestcase(yyruleno==97);
case 100: /* comp ::= COMP INTEGER */ yytestcase(yyruleno==100); case 98: /* comp ::= COMP INTEGER */ yytestcase(yyruleno==98);
case 101: /* prec ::= PRECISION STRING */ yytestcase(yyruleno==101); case 99: /* prec ::= PRECISION STRING */ yytestcase(yyruleno==99);
case 102: /* update ::= UPDATE INTEGER */ yytestcase(yyruleno==102); case 100: /* update ::= UPDATE INTEGER */ yytestcase(yyruleno==100);
case 103: /* cachelast ::= CACHELAST INTEGER */ yytestcase(yyruleno==103); case 101: /* cachelast ::= CACHELAST INTEGER */ yytestcase(yyruleno==101);
case 104: /* partitions ::= PARTITIONS INTEGER */ yytestcase(yyruleno==104);
{ yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; }
break; break;
case 105: /* db_optr ::= */ case 102: /* db_optr ::= */
{setDefaultCreateDbOption(&yymsp[1].minor.yy256);} {setDefaultCreateDbOption(&yymsp[1].minor.yy42);}
break; break;
case 106: /* db_optr ::= db_optr cache */ case 103: /* db_optr ::= db_optr cache */
{ yylhsminor.yy256 = yymsp[-1].minor.yy256; yylhsminor.yy256.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy42 = yymsp[-1].minor.yy42; yylhsminor.yy42.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy256 = yylhsminor.yy256; yymsp[-1].minor.yy42 = yylhsminor.yy42;
break; break;
case 107: /* db_optr ::= db_optr replica */ case 104: /* db_optr ::= db_optr replica */
case 124: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==124); case 119: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==119);
{ yylhsminor.yy256 = yymsp[-1].minor.yy256; yylhsminor.yy256.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy42 = yymsp[-1].minor.yy42; yylhsminor.yy42.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy256 = yylhsminor.yy256; yymsp[-1].minor.yy42 = yylhsminor.yy42;
break; break;
case 108: /* db_optr ::= db_optr quorum */ case 105: /* db_optr ::= db_optr quorum */
case 125: /* alter_db_optr ::= alter_db_optr quorum */ yytestcase(yyruleno==125); case 120: /* alter_db_optr ::= alter_db_optr quorum */ yytestcase(yyruleno==120);
{ yylhsminor.yy256 = yymsp[-1].minor.yy256; yylhsminor.yy256.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy42 = yymsp[-1].minor.yy42; yylhsminor.yy42.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy256 = yylhsminor.yy256; yymsp[-1].minor.yy42 = yylhsminor.yy42;
break; break;
case 109: /* db_optr ::= db_optr days */ case 106: /* db_optr ::= db_optr days */
{ yylhsminor.yy256 = yymsp[-1].minor.yy256; yylhsminor.yy256.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy42 = yymsp[-1].minor.yy42; yylhsminor.yy42.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy256 = yylhsminor.yy256; yymsp[-1].minor.yy42 = yylhsminor.yy42;
break; break;
case 110: /* db_optr ::= db_optr minrows */ case 107: /* db_optr ::= db_optr minrows */
{ yylhsminor.yy256 = yymsp[-1].minor.yy256; yylhsminor.yy256.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } { yylhsminor.yy42 = yymsp[-1].minor.yy42; yylhsminor.yy42.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); }
yymsp[-1].minor.yy256 = yylhsminor.yy256; yymsp[-1].minor.yy42 = yylhsminor.yy42;
break; break;
case 111: /* db_optr ::= db_optr maxrows */ case 108: /* db_optr ::= db_optr maxrows */
{ yylhsminor.yy256 = yymsp[-1].minor.yy256; yylhsminor.yy256.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } { yylhsminor.yy42 = yymsp[-1].minor.yy42; yylhsminor.yy42.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); }
yymsp[-1].minor.yy256 = yylhsminor.yy256; yymsp[-1].minor.yy42 = yylhsminor.yy42;
break; break;
case 112: /* db_optr ::= db_optr blocks */ case 109: /* db_optr ::= db_optr blocks */
case 127: /* alter_db_optr ::= alter_db_optr blocks */ yytestcase(yyruleno==127); case 122: /* alter_db_optr ::= alter_db_optr blocks */ yytestcase(yyruleno==122);
{ yylhsminor.yy256 = yymsp[-1].minor.yy256; yylhsminor.yy256.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy42 = yymsp[-1].minor.yy42; yylhsminor.yy42.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy256 = yylhsminor.yy256; yymsp[-1].minor.yy42 = yylhsminor.yy42;
break; break;
case 113: /* db_optr ::= db_optr ctime */ case 110: /* db_optr ::= db_optr ctime */
{ yylhsminor.yy256 = yymsp[-1].minor.yy256; yylhsminor.yy256.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy42 = yymsp[-1].minor.yy42; yylhsminor.yy42.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy256 = yylhsminor.yy256; yymsp[-1].minor.yy42 = yylhsminor.yy42;
break; break;
case 114: /* db_optr ::= db_optr wal */ case 111: /* db_optr ::= db_optr wal */
{ yylhsminor.yy256 = yymsp[-1].minor.yy256; yylhsminor.yy256.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy42 = yymsp[-1].minor.yy42; yylhsminor.yy42.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy256 = yylhsminor.yy256; yymsp[-1].minor.yy42 = yylhsminor.yy42;
break; break;
case 115: /* db_optr ::= db_optr fsync */ case 112: /* db_optr ::= db_optr fsync */
{ yylhsminor.yy256 = yymsp[-1].minor.yy256; yylhsminor.yy256.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy42 = yymsp[-1].minor.yy42; yylhsminor.yy42.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy256 = yylhsminor.yy256; yymsp[-1].minor.yy42 = yylhsminor.yy42;
break;
case 116: /* db_optr ::= db_optr comp */
case 128: /* alter_db_optr ::= alter_db_optr comp */ yytestcase(yyruleno==128);
{ yylhsminor.yy256 = yymsp[-1].minor.yy256; yylhsminor.yy256.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy256 = yylhsminor.yy256;
break;
case 117: /* db_optr ::= db_optr prec */
{ yylhsminor.yy256 = yymsp[-1].minor.yy256; yylhsminor.yy256.precision = yymsp[0].minor.yy0; }
yymsp[-1].minor.yy256 = yylhsminor.yy256;
break; break;
case 118: /* db_optr ::= db_optr keep */ case 113: /* db_optr ::= db_optr comp */
case 126: /* alter_db_optr ::= alter_db_optr keep */ yytestcase(yyruleno==126); case 123: /* alter_db_optr ::= alter_db_optr comp */ yytestcase(yyruleno==123);
{ yylhsminor.yy256 = yymsp[-1].minor.yy256; yylhsminor.yy256.keep = yymsp[0].minor.yy135; } { yylhsminor.yy42 = yymsp[-1].minor.yy42; yylhsminor.yy42.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy256 = yylhsminor.yy256; yymsp[-1].minor.yy42 = yylhsminor.yy42;
break; break;
case 119: /* db_optr ::= db_optr update */ case 114: /* db_optr ::= db_optr prec */
case 129: /* alter_db_optr ::= alter_db_optr update */ yytestcase(yyruleno==129); { yylhsminor.yy42 = yymsp[-1].minor.yy42; yylhsminor.yy42.precision = yymsp[0].minor.yy0; }
{ yylhsminor.yy256 = yymsp[-1].minor.yy256; yylhsminor.yy256.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy42 = yylhsminor.yy42;
yymsp[-1].minor.yy256 = yylhsminor.yy256;
break; break;
case 120: /* db_optr ::= db_optr cachelast */ case 115: /* db_optr ::= db_optr keep */
case 130: /* alter_db_optr ::= alter_db_optr cachelast */ yytestcase(yyruleno==130); case 121: /* alter_db_optr ::= alter_db_optr keep */ yytestcase(yyruleno==121);
{ yylhsminor.yy256 = yymsp[-1].minor.yy256; yylhsminor.yy256.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy42 = yymsp[-1].minor.yy42; yylhsminor.yy42.keep = yymsp[0].minor.yy131; }
yymsp[-1].minor.yy256 = yylhsminor.yy256; yymsp[-1].minor.yy42 = yylhsminor.yy42;
break; break;
case 121: /* topic_optr ::= db_optr */ case 116: /* db_optr ::= db_optr update */
case 131: /* alter_topic_optr ::= alter_db_optr */ yytestcase(yyruleno==131); case 124: /* alter_db_optr ::= alter_db_optr update */ yytestcase(yyruleno==124);
{ yylhsminor.yy256 = yymsp[0].minor.yy256;} { yylhsminor.yy42 = yymsp[-1].minor.yy42; yylhsminor.yy42.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[0].minor.yy256 = yylhsminor.yy256; yymsp[-1].minor.yy42 = yylhsminor.yy42;
break; break;
case 122: /* topic_optr ::= topic_optr partitions */ case 117: /* db_optr ::= db_optr cachelast */
case 132: /* alter_topic_optr ::= alter_topic_optr partitions */ yytestcase(yyruleno==132); case 125: /* alter_db_optr ::= alter_db_optr cachelast */ yytestcase(yyruleno==125);
{ yylhsminor.yy256 = yymsp[-1].minor.yy256; } { yylhsminor.yy42 = yymsp[-1].minor.yy42; yylhsminor.yy42.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy256 = yylhsminor.yy256; yymsp[-1].minor.yy42 = yylhsminor.yy42;
break; break;
case 123: /* alter_db_optr ::= */ case 118: /* alter_db_optr ::= */
{ setDefaultCreateDbOption(&yymsp[1].minor.yy256); } { setDefaultCreateDbOption(&yymsp[1].minor.yy42);}
break; break;
case 133: /* typename ::= ids */ case 126: /* typename ::= ids */
{ {
yymsp[0].minor.yy0.type = 0; yymsp[0].minor.yy0.type = 0;
tSetColumnType (&yylhsminor.yy304, &yymsp[0].minor.yy0); tSetColumnType (&yylhsminor.yy290, &yymsp[0].minor.yy0);
} }
yymsp[0].minor.yy304 = yylhsminor.yy304; yymsp[0].minor.yy290 = yylhsminor.yy290;
break; break;
case 134: /* typename ::= ids LP signed RP */ case 127: /* typename ::= ids LP signed RP */
{ {
if (yymsp[-1].minor.yy531 <= 0) { if (yymsp[-1].minor.yy459 <= 0) {
yymsp[-3].minor.yy0.type = 0; yymsp[-3].minor.yy0.type = 0;
tSetColumnType(&yylhsminor.yy304, &yymsp[-3].minor.yy0); tSetColumnType(&yylhsminor.yy290, &yymsp[-3].minor.yy0);
} else { } else {
yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy531; // negative value of name length yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy459; // negative value of name length
tSetColumnType(&yylhsminor.yy304, &yymsp[-3].minor.yy0); tSetColumnType(&yylhsminor.yy290, &yymsp[-3].minor.yy0);
} }
} }
yymsp[-3].minor.yy304 = yylhsminor.yy304; yymsp[-3].minor.yy290 = yylhsminor.yy290;
break; break;
case 135: /* typename ::= ids UNSIGNED */ case 128: /* 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.yy304, &yymsp[-1].minor.yy0); tSetColumnType (&yylhsminor.yy290, &yymsp[-1].minor.yy0);
} }
yymsp[-1].minor.yy304 = yylhsminor.yy304; yymsp[-1].minor.yy290 = yylhsminor.yy290;
break; break;
case 136: /* signed ::= INTEGER */ case 129: /* signed ::= INTEGER */
{ yylhsminor.yy531 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy459 = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[0].minor.yy531 = yylhsminor.yy531; yymsp[0].minor.yy459 = yylhsminor.yy459;
break; break;
case 137: /* signed ::= PLUS INTEGER */ case 130: /* signed ::= PLUS INTEGER */
{ yymsp[-1].minor.yy531 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yymsp[-1].minor.yy459 = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
break; break;
case 138: /* signed ::= MINUS INTEGER */ case 131: /* signed ::= MINUS INTEGER */
{ yymsp[-1].minor.yy531 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} { yymsp[-1].minor.yy459 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);}
break; break;
case 142: /* cmd ::= CREATE TABLE create_table_list */ case 135: /* cmd ::= CREATE TABLE create_table_list */
{ pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = yymsp[0].minor.yy110;} { pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = yymsp[0].minor.yy272;}
break; break;
case 143: /* create_table_list ::= create_from_stable */ case 136: /* 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.yy78); taosArrayPush(pCreateTable->childTableInfo, &yymsp[0].minor.yy96);
pCreateTable->type = TSQL_CREATE_CTABLE; pCreateTable->type = TSQL_CREATE_CTABLE;
yylhsminor.yy110 = pCreateTable; yylhsminor.yy272 = pCreateTable;
} }
yymsp[0].minor.yy110 = yylhsminor.yy110; yymsp[0].minor.yy272 = yylhsminor.yy272;
break; break;
case 144: /* create_table_list ::= create_table_list create_from_stable */ case 137: /* create_table_list ::= create_table_list create_from_stable */
{ {
taosArrayPush(yymsp[-1].minor.yy110->childTableInfo, &yymsp[0].minor.yy78); taosArrayPush(yymsp[-1].minor.yy272->childTableInfo, &yymsp[0].minor.yy96);
yylhsminor.yy110 = yymsp[-1].minor.yy110; yylhsminor.yy272 = yymsp[-1].minor.yy272;
} }
yymsp[-1].minor.yy110 = yylhsminor.yy110; yymsp[-1].minor.yy272 = yylhsminor.yy272;
break; break;
case 145: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ case 138: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */
{ {
yylhsminor.yy110 = tSetCreateTableInfo(yymsp[-1].minor.yy135, NULL, NULL, TSQL_CREATE_TABLE); yylhsminor.yy272 = tSetCreateTableInfo(yymsp[-1].minor.yy131, NULL, NULL, TSQL_CREATE_TABLE);
setSqlInfo(pInfo, yylhsminor.yy110, NULL, TSDB_SQL_CREATE_TABLE); setSqlInfo(pInfo, yylhsminor.yy272, 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;
setCreatedTableName(pInfo, &yymsp[-4].minor.yy0, &yymsp[-5].minor.yy0); setCreatedTableName(pInfo, &yymsp[-4].minor.yy0, &yymsp[-5].minor.yy0);
} }
yymsp[-5].minor.yy110 = yylhsminor.yy110; yymsp[-5].minor.yy272 = yylhsminor.yy272;
break; break;
case 146: /* create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ case 139: /* create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */
{ {
yylhsminor.yy110 = tSetCreateTableInfo(yymsp[-5].minor.yy135, yymsp[-1].minor.yy135, NULL, TSQL_CREATE_STABLE); yylhsminor.yy272 = tSetCreateTableInfo(yymsp[-5].minor.yy131, yymsp[-1].minor.yy131, NULL, TSQL_CREATE_STABLE);
setSqlInfo(pInfo, yylhsminor.yy110, NULL, TSDB_SQL_CREATE_TABLE); setSqlInfo(pInfo, yylhsminor.yy272, 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;
setCreatedTableName(pInfo, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0); setCreatedTableName(pInfo, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0);
} }
yymsp[-9].minor.yy110 = yylhsminor.yy110; yymsp[-9].minor.yy272 = yylhsminor.yy272;
break; break;
case 147: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ case 140: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist 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.yy78 = createNewChildTableInfo(&yymsp[-5].minor.yy0, NULL, yymsp[-1].minor.yy135, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0); yylhsminor.yy96 = createNewChildTableInfo(&yymsp[-5].minor.yy0, NULL, yymsp[-1].minor.yy131, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0);
} }
yymsp[-9].minor.yy78 = yylhsminor.yy78; yymsp[-9].minor.yy96 = yylhsminor.yy96;
break; break;
case 148: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ case 141: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist 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.yy78 = createNewChildTableInfo(&yymsp[-8].minor.yy0, yymsp[-5].minor.yy135, yymsp[-1].minor.yy135, &yymsp[-11].minor.yy0, &yymsp[-12].minor.yy0); yylhsminor.yy96 = createNewChildTableInfo(&yymsp[-8].minor.yy0, yymsp[-5].minor.yy131, yymsp[-1].minor.yy131, &yymsp[-11].minor.yy0, &yymsp[-12].minor.yy0);
} }
yymsp[-12].minor.yy78 = yylhsminor.yy78; yymsp[-12].minor.yy96 = yylhsminor.yy96;
break; break;
case 149: /* tagNamelist ::= tagNamelist COMMA ids */ case 142: /* tagNamelist ::= tagNamelist COMMA ids */
{taosArrayPush(yymsp[-2].minor.yy135, &yymsp[0].minor.yy0); yylhsminor.yy135 = yymsp[-2].minor.yy135; } {taosArrayPush(yymsp[-2].minor.yy131, &yymsp[0].minor.yy0); yylhsminor.yy131 = yymsp[-2].minor.yy131; }
yymsp[-2].minor.yy135 = yylhsminor.yy135; yymsp[-2].minor.yy131 = yylhsminor.yy131;
break; break;
case 150: /* tagNamelist ::= ids */ case 143: /* tagNamelist ::= ids */
{yylhsminor.yy135 = taosArrayInit(4, sizeof(SToken)); taosArrayPush(yylhsminor.yy135, &yymsp[0].minor.yy0);} {yylhsminor.yy131 = taosArrayInit(4, sizeof(SToken)); taosArrayPush(yylhsminor.yy131, &yymsp[0].minor.yy0);}
yymsp[0].minor.yy135 = yylhsminor.yy135; yymsp[0].minor.yy131 = yylhsminor.yy131;
break; break;
case 151: /* create_table_args ::= ifnotexists ids cpxName AS select */ case 144: /* create_table_args ::= ifnotexists ids cpxName AS select */
{ {
yylhsminor.yy110 = tSetCreateTableInfo(NULL, NULL, yymsp[0].minor.yy488, TSQL_CREATE_STREAM); yylhsminor.yy272 = tSetCreateTableInfo(NULL, NULL, yymsp[0].minor.yy256, TSQL_CREATE_STREAM);
setSqlInfo(pInfo, yylhsminor.yy110, NULL, TSDB_SQL_CREATE_TABLE); setSqlInfo(pInfo, yylhsminor.yy272, 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;
setCreatedTableName(pInfo, &yymsp[-3].minor.yy0, &yymsp[-4].minor.yy0); setCreatedTableName(pInfo, &yymsp[-3].minor.yy0, &yymsp[-4].minor.yy0);
} }
yymsp[-4].minor.yy110 = yylhsminor.yy110; yymsp[-4].minor.yy272 = yylhsminor.yy272;
break; break;
case 152: /* columnlist ::= columnlist COMMA column */ case 145: /* columnlist ::= columnlist COMMA column */
{taosArrayPush(yymsp[-2].minor.yy135, &yymsp[0].minor.yy304); yylhsminor.yy135 = yymsp[-2].minor.yy135; } {taosArrayPush(yymsp[-2].minor.yy131, &yymsp[0].minor.yy290); yylhsminor.yy131 = yymsp[-2].minor.yy131; }
yymsp[-2].minor.yy135 = yylhsminor.yy135; yymsp[-2].minor.yy131 = yylhsminor.yy131;
break; break;
case 153: /* columnlist ::= column */ case 146: /* columnlist ::= column */
{yylhsminor.yy135 = taosArrayInit(4, sizeof(SField)); taosArrayPush(yylhsminor.yy135, &yymsp[0].minor.yy304);} {yylhsminor.yy131 = taosArrayInit(4, sizeof(SField)); taosArrayPush(yylhsminor.yy131, &yymsp[0].minor.yy290);}
yymsp[0].minor.yy135 = yylhsminor.yy135; yymsp[0].minor.yy131 = yylhsminor.yy131;
break; break;
case 154: /* column ::= ids typename */ case 147: /* column ::= ids typename */
{ {
tSetColumnInfo(&yylhsminor.yy304, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy304); tSetColumnInfo(&yylhsminor.yy290, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy290);
} }
yymsp[-1].minor.yy304 = yylhsminor.yy304; yymsp[-1].minor.yy290 = yylhsminor.yy290;
break; break;
case 161: /* tagitem ::= NULL */ case 154: /* tagitem ::= NULL */
{ yymsp[0].minor.yy0.type = 0; taosVariantCreate(&yylhsminor.yy191, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.type); } { yymsp[0].minor.yy0.type = 0; taosVariantCreate(&yylhsminor.yy43, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.type); }
yymsp[0].minor.yy191 = yylhsminor.yy191; yymsp[0].minor.yy43 = yylhsminor.yy43;
break; break;
case 162: /* tagitem ::= NOW */ case 155: /* tagitem ::= NOW */
{ yymsp[0].minor.yy0.type = TSDB_DATA_TYPE_TIMESTAMP; taosVariantCreate(&yylhsminor.yy191, 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.yy43, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.type);}
yymsp[0].minor.yy191 = yylhsminor.yy191; yymsp[0].minor.yy43 = yylhsminor.yy43;
break; break;
case 163: /* tagitem ::= MINUS INTEGER */ case 156: /* tagitem ::= MINUS INTEGER */
case 164: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==164); case 157: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==157);
case 165: /* tagitem ::= PLUS INTEGER */ yytestcase(yyruleno==165); case 158: /* tagitem ::= PLUS INTEGER */ yytestcase(yyruleno==158);
case 166: /* tagitem ::= PLUS FLOAT */ yytestcase(yyruleno==166); case 159: /* tagitem ::= PLUS FLOAT */ yytestcase(yyruleno==159);
{ {
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.yy191, yymsp[-1].minor.yy0.z, yymsp[-1].minor.yy0.n, yymsp[-1].minor.yy0.type); taosVariantCreate(&yylhsminor.yy43, yymsp[-1].minor.yy0.z, yymsp[-1].minor.yy0.n, yymsp[-1].minor.yy0.type);
} }
yymsp[-1].minor.yy191 = yylhsminor.yy191; yymsp[-1].minor.yy43 = yylhsminor.yy43;
break; break;
case 167: /* 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 160: /* 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.yy488 = tSetQuerySqlNode(&yymsp[-13].minor.yy0, yymsp[-12].minor.yy135, yymsp[-11].minor.yy460, yymsp[-10].minor.yy526, yymsp[-4].minor.yy135, yymsp[-2].minor.yy135, &yymsp[-9].minor.yy160, &yymsp[-7].minor.yy511, &yymsp[-6].minor.yy258, &yymsp[-8].minor.yy0, yymsp[-5].minor.yy135, &yymsp[0].minor.yy247, &yymsp[-1].minor.yy247, yymsp[-3].minor.yy526); yylhsminor.yy256 = tSetQuerySqlNode(&yymsp[-13].minor.yy0, yymsp[-12].minor.yy131, yymsp[-11].minor.yy544, yymsp[-10].minor.yy46, yymsp[-4].minor.yy131, yymsp[-2].minor.yy131, &yymsp[-9].minor.yy530, &yymsp[-7].minor.yy39, &yymsp[-6].minor.yy538, &yymsp[-8].minor.yy0, yymsp[-5].minor.yy131, &yymsp[0].minor.yy55, &yymsp[-1].minor.yy55, yymsp[-3].minor.yy46);
} }
yymsp[-13].minor.yy488 = yylhsminor.yy488; yymsp[-13].minor.yy256 = yylhsminor.yy256;
break; break;
case 168: /* select ::= LP select RP */ case 161: /* select ::= LP select RP */
{yymsp[-2].minor.yy488 = yymsp[-1].minor.yy488;} {yymsp[-2].minor.yy256 = yymsp[-1].minor.yy256;}
break; break;
case 169: /* union ::= select */ case 162: /* union ::= select */
{ yylhsminor.yy551 = setSubclause(NULL, yymsp[0].minor.yy488); } { yylhsminor.yy303 = setSubclause(NULL, yymsp[0].minor.yy256); }
yymsp[0].minor.yy551 = yylhsminor.yy551; yymsp[0].minor.yy303 = yylhsminor.yy303;
break; break;
case 170: /* union ::= union UNION ALL select */ case 163: /* union ::= union UNION ALL select */
{ yylhsminor.yy551 = appendSelectClause(yymsp[-3].minor.yy551, SQL_TYPE_UNIONALL, yymsp[0].minor.yy488); } { yylhsminor.yy303 = appendSelectClause(yymsp[-3].minor.yy303, SQL_TYPE_UNIONALL, yymsp[0].minor.yy256); }
yymsp[-3].minor.yy551 = yylhsminor.yy551; yymsp[-3].minor.yy303 = yylhsminor.yy303;
break; break;
case 171: /* union ::= union UNION select */ case 164: /* union ::= union UNION select */
{ yylhsminor.yy551 = appendSelectClause(yymsp[-2].minor.yy551, SQL_TYPE_UNION, yymsp[0].minor.yy488); } { yylhsminor.yy303 = appendSelectClause(yymsp[-2].minor.yy303, SQL_TYPE_UNION, yymsp[0].minor.yy256); }
yymsp[-2].minor.yy551 = yylhsminor.yy551; yymsp[-2].minor.yy303 = yylhsminor.yy303;
break; break;
case 172: /* cmd ::= union */ case 165: /* cmd ::= union */
{ setSqlInfo(pInfo, yymsp[0].minor.yy551, NULL, TSDB_SQL_SELECT); } { setSqlInfo(pInfo, yymsp[0].minor.yy303, NULL, TSDB_SQL_SELECT); }
break; break;
case 173: /* select ::= SELECT selcollist */ case 166: /* select ::= SELECT selcollist */
{ {
yylhsminor.yy488 = tSetQuerySqlNode(&yymsp[-1].minor.yy0, yymsp[0].minor.yy135, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); yylhsminor.yy256 = tSetQuerySqlNode(&yymsp[-1].minor.yy0, yymsp[0].minor.yy131, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
} }
yymsp[-1].minor.yy488 = yylhsminor.yy488; yymsp[-1].minor.yy256 = yylhsminor.yy256;
break; break;
case 174: /* sclp ::= selcollist COMMA */ case 167: /* sclp ::= selcollist COMMA */
{yylhsminor.yy135 = yymsp[-1].minor.yy135;} {yylhsminor.yy131 = yymsp[-1].minor.yy131;}
yymsp[-1].minor.yy135 = yylhsminor.yy135; yymsp[-1].minor.yy131 = yylhsminor.yy131;
break; break;
case 175: /* sclp ::= */ case 168: /* sclp ::= */
case 207: /* orderby_opt ::= */ yytestcase(yyruleno==207); case 200: /* orderby_opt ::= */ yytestcase(yyruleno==200);
{yymsp[1].minor.yy135 = 0;} {yymsp[1].minor.yy131 = 0;}
break; break;
case 176: /* selcollist ::= sclp distinct expr as */ case 169: /* selcollist ::= sclp distinct expr as */
{ {
yylhsminor.yy135 = tSqlExprListAppend(yymsp[-3].minor.yy135, yymsp[-1].minor.yy526, yymsp[-2].minor.yy0.n? &yymsp[-2].minor.yy0:0, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); yylhsminor.yy131 = tSqlExprListAppend(yymsp[-3].minor.yy131, yymsp[-1].minor.yy46, yymsp[-2].minor.yy0.n? &yymsp[-2].minor.yy0:0, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0);
} }
yymsp[-3].minor.yy135 = yylhsminor.yy135; yymsp[-3].minor.yy131 = yylhsminor.yy131;
break; break;
case 177: /* selcollist ::= sclp STAR */ case 170: /* selcollist ::= sclp STAR */
{ {
tSqlExpr *pNode = tSqlExprCreateIdValue(NULL, TK_ALL); tSqlExpr *pNode = tSqlExprCreateIdValue(NULL, TK_ALL);
yylhsminor.yy135 = tSqlExprListAppend(yymsp[-1].minor.yy135, pNode, 0, 0); yylhsminor.yy131 = tSqlExprListAppend(yymsp[-1].minor.yy131, pNode, 0, 0);
} }
yymsp[-1].minor.yy135 = yylhsminor.yy135; yymsp[-1].minor.yy131 = yylhsminor.yy131;
break; break;
case 178: /* as ::= AS ids */ case 171: /* as ::= AS ids */
{ yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; }
break; break;
case 179: /* as ::= ids */ case 172: /* 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 180: /* as ::= */ case 173: /* as ::= */
{ yymsp[1].minor.yy0.n = 0; } { yymsp[1].minor.yy0.n = 0; }
break; break;
case 181: /* distinct ::= DISTINCT */ case 174: /* 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 183: /* from ::= FROM tablelist */ case 176: /* from ::= FROM tablelist */
case 184: /* from ::= FROM sub */ yytestcase(yyruleno==184); case 177: /* from ::= FROM sub */ yytestcase(yyruleno==177);
{yymsp[-1].minor.yy460 = yymsp[0].minor.yy460;} {yymsp[-1].minor.yy544 = yymsp[0].minor.yy544;}
break; break;
case 185: /* sub ::= LP union RP */ case 178: /* sub ::= LP union RP */
{yymsp[-2].minor.yy460 = addSubquery(NULL, yymsp[-1].minor.yy551, NULL);} {yymsp[-2].minor.yy544 = addSubquery(NULL, yymsp[-1].minor.yy303, NULL);}
break; break;
case 186: /* sub ::= LP union RP ids */ case 179: /* sub ::= LP union RP ids */
{yymsp[-3].minor.yy460 = addSubquery(NULL, yymsp[-2].minor.yy551, &yymsp[0].minor.yy0);} {yymsp[-3].minor.yy544 = addSubquery(NULL, yymsp[-2].minor.yy303, &yymsp[0].minor.yy0);}
break; break;
case 187: /* sub ::= sub COMMA LP union RP ids */ case 180: /* sub ::= sub COMMA LP union RP ids */
{yylhsminor.yy460 = addSubquery(yymsp[-5].minor.yy460, yymsp[-2].minor.yy551, &yymsp[0].minor.yy0);} {yylhsminor.yy544 = addSubquery(yymsp[-5].minor.yy544, yymsp[-2].minor.yy303, &yymsp[0].minor.yy0);}
yymsp[-5].minor.yy460 = yylhsminor.yy460; yymsp[-5].minor.yy544 = yylhsminor.yy544;
break; break;
case 188: /* tablelist ::= ids cpxName */ case 181: /* tablelist ::= ids cpxName */
{ {
yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n;
yylhsminor.yy460 = setTableNameList(NULL, &yymsp[-1].minor.yy0, NULL); yylhsminor.yy544 = setTableNameList(NULL, &yymsp[-1].minor.yy0, NULL);
} }
yymsp[-1].minor.yy460 = yylhsminor.yy460; yymsp[-1].minor.yy544 = yylhsminor.yy544;
break; break;
case 189: /* tablelist ::= ids cpxName ids */ case 182: /* 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.yy460 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); yylhsminor.yy544 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
} }
yymsp[-2].minor.yy460 = yylhsminor.yy460; yymsp[-2].minor.yy544 = yylhsminor.yy544;
break; break;
case 190: /* tablelist ::= tablelist COMMA ids cpxName */ case 183: /* 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.yy460 = setTableNameList(yymsp[-3].minor.yy460, &yymsp[-1].minor.yy0, NULL); yylhsminor.yy544 = setTableNameList(yymsp[-3].minor.yy544, &yymsp[-1].minor.yy0, NULL);
} }
yymsp[-3].minor.yy460 = yylhsminor.yy460; yymsp[-3].minor.yy544 = yylhsminor.yy544;
break; break;
case 191: /* tablelist ::= tablelist COMMA ids cpxName ids */ case 184: /* 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.yy460 = setTableNameList(yymsp[-4].minor.yy460, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); yylhsminor.yy544 = setTableNameList(yymsp[-4].minor.yy544, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
} }
yymsp[-4].minor.yy460 = yylhsminor.yy460; yymsp[-4].minor.yy544 = yylhsminor.yy544;
break; break;
case 192: /* tmvar ::= VARIABLE */ case 185: /* 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 193: /* interval_option ::= intervalKey LP tmvar RP */ case 186: /* interval_option ::= intervalKey LP tmvar RP */
{yylhsminor.yy160.interval = yymsp[-1].minor.yy0; yylhsminor.yy160.offset.n = 0; yylhsminor.yy160.token = yymsp[-3].minor.yy262;} {yylhsminor.yy530.interval = yymsp[-1].minor.yy0; yylhsminor.yy530.offset.n = 0; yylhsminor.yy530.token = yymsp[-3].minor.yy310;}
yymsp[-3].minor.yy160 = yylhsminor.yy160; yymsp[-3].minor.yy530 = yylhsminor.yy530;
break; break;
case 194: /* interval_option ::= intervalKey LP tmvar COMMA tmvar RP */ case 187: /* interval_option ::= intervalKey LP tmvar COMMA tmvar RP */
{yylhsminor.yy160.interval = yymsp[-3].minor.yy0; yylhsminor.yy160.offset = yymsp[-1].minor.yy0; yylhsminor.yy160.token = yymsp[-5].minor.yy262;} {yylhsminor.yy530.interval = yymsp[-3].minor.yy0; yylhsminor.yy530.offset = yymsp[-1].minor.yy0; yylhsminor.yy530.token = yymsp[-5].minor.yy310;}
yymsp[-5].minor.yy160 = yylhsminor.yy160; yymsp[-5].minor.yy530 = yylhsminor.yy530;
break; break;
case 195: /* interval_option ::= */ case 188: /* interval_option ::= */
{memset(&yymsp[1].minor.yy160, 0, sizeof(yymsp[1].minor.yy160));} {memset(&yymsp[1].minor.yy530, 0, sizeof(yymsp[1].minor.yy530));}
break; break;
case 196: /* intervalKey ::= INTERVAL */ case 189: /* intervalKey ::= INTERVAL */
{yymsp[0].minor.yy262 = TK_INTERVAL;} {yymsp[0].minor.yy310 = TK_INTERVAL;}
break; break;
case 197: /* intervalKey ::= EVERY */ case 190: /* intervalKey ::= EVERY */
{yymsp[0].minor.yy262 = TK_EVERY; } {yymsp[0].minor.yy310 = TK_EVERY; }
break; break;
case 198: /* session_option ::= */ case 191: /* session_option ::= */
{yymsp[1].minor.yy511.col.n = 0; yymsp[1].minor.yy511.gap.n = 0;} {yymsp[1].minor.yy39.col.n = 0; yymsp[1].minor.yy39.gap.n = 0;}
break; break;
case 199: /* session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ case 192: /* 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.yy511.col = yymsp[-4].minor.yy0; yymsp[-6].minor.yy39.col = yymsp[-4].minor.yy0;
yymsp[-6].minor.yy511.gap = yymsp[-1].minor.yy0; yymsp[-6].minor.yy39.gap = yymsp[-1].minor.yy0;
} }
break; break;
case 200: /* windowstate_option ::= */ case 193: /* windowstate_option ::= */
{ yymsp[1].minor.yy258.col.n = 0; yymsp[1].minor.yy258.col.z = NULL;} { yymsp[1].minor.yy538.col.n = 0; yymsp[1].minor.yy538.col.z = NULL;}
break; break;
case 201: /* windowstate_option ::= STATE_WINDOW LP ids RP */ case 194: /* windowstate_option ::= STATE_WINDOW LP ids RP */
{ yymsp[-3].minor.yy258.col = yymsp[-1].minor.yy0; } { yymsp[-3].minor.yy538.col = yymsp[-1].minor.yy0; }
break; break;
case 202: /* fill_opt ::= */ case 195: /* fill_opt ::= */
{ yymsp[1].minor.yy135 = 0; } { yymsp[1].minor.yy131 = 0; }
break; break;
case 203: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ case 196: /* 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.yy135, &A, -1, 0); tListItemInsert(yymsp[-1].minor.yy131, &A, -1, 0);
yymsp[-5].minor.yy135 = yymsp[-1].minor.yy135; yymsp[-5].minor.yy131 = yymsp[-1].minor.yy131;
} }
break; break;
case 204: /* fill_opt ::= FILL LP ID RP */ case 197: /* fill_opt ::= FILL LP ID RP */
{ {
toTSDBType(yymsp[-1].minor.yy0.type); toTSDBType(yymsp[-1].minor.yy0.type);
yymsp[-3].minor.yy135 = tListItemAppendToken(NULL, &yymsp[-1].minor.yy0, -1); yymsp[-3].minor.yy131 = tListItemAppendToken(NULL, &yymsp[-1].minor.yy0, -1);
} }
break; break;
case 205: /* sliding_opt ::= SLIDING LP tmvar RP */ case 198: /* 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 206: /* sliding_opt ::= */ case 199: /* 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 208: /* orderby_opt ::= ORDER BY sortlist */ case 201: /* orderby_opt ::= ORDER BY sortlist */
{yymsp[-2].minor.yy135 = yymsp[0].minor.yy135;} {yymsp[-2].minor.yy131 = yymsp[0].minor.yy131;}
break; break;
case 209: /* sortlist ::= sortlist COMMA item sortorder */ case 202: /* sortlist ::= sortlist COMMA item sortorder */
{ {
yylhsminor.yy135 = tListItemAppend(yymsp[-3].minor.yy135, &yymsp[-1].minor.yy191, yymsp[0].minor.yy130); yylhsminor.yy131 = tListItemAppend(yymsp[-3].minor.yy131, &yymsp[-1].minor.yy43, yymsp[0].minor.yy44);
} }
yymsp[-3].minor.yy135 = yylhsminor.yy135; yymsp[-3].minor.yy131 = yylhsminor.yy131;
break; break;
case 210: /* sortlist ::= item sortorder */ case 203: /* sortlist ::= item sortorder */
{ {
yylhsminor.yy135 = tListItemAppend(NULL, &yymsp[-1].minor.yy191, yymsp[0].minor.yy130); yylhsminor.yy131 = tListItemAppend(NULL, &yymsp[-1].minor.yy43, yymsp[0].minor.yy44);
} }
yymsp[-1].minor.yy135 = yylhsminor.yy135; yymsp[-1].minor.yy131 = yylhsminor.yy131;
break; break;
case 211: /* item ::= ids cpxName */ case 204: /* 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.yy191, yymsp[-1].minor.yy0.z, yymsp[-1].minor.yy0.n, yymsp[-1].minor.yy0.type); taosVariantCreate(&yylhsminor.yy43, yymsp[-1].minor.yy0.z, yymsp[-1].minor.yy0.n, yymsp[-1].minor.yy0.type);
} }
yymsp[-1].minor.yy191 = yylhsminor.yy191; yymsp[-1].minor.yy43 = yylhsminor.yy43;
break; break;
case 212: /* sortorder ::= ASC */ case 205: /* sortorder ::= ASC */
{ yymsp[0].minor.yy130 = TSDB_ORDER_ASC; } { yymsp[0].minor.yy44 = TSDB_ORDER_ASC; }
break; break;
case 213: /* sortorder ::= DESC */ case 206: /* sortorder ::= DESC */
{ yymsp[0].minor.yy130 = TSDB_ORDER_DESC;} { yymsp[0].minor.yy44 = TSDB_ORDER_DESC;}
break; break;
case 214: /* sortorder ::= */ case 207: /* sortorder ::= */
{ yymsp[1].minor.yy130 = TSDB_ORDER_ASC; } { yymsp[1].minor.yy44 = TSDB_ORDER_ASC; }
break; break;
case 215: /* groupby_opt ::= */ case 208: /* groupby_opt ::= */
{ yymsp[1].minor.yy135 = 0;} { yymsp[1].minor.yy131 = 0;}
break; break;
case 216: /* groupby_opt ::= GROUP BY grouplist */ case 209: /* groupby_opt ::= GROUP BY grouplist */
{ yymsp[-2].minor.yy135 = yymsp[0].minor.yy135;} { yymsp[-2].minor.yy131 = yymsp[0].minor.yy131;}
break; break;
case 217: /* grouplist ::= grouplist COMMA item */ case 210: /* grouplist ::= grouplist COMMA item */
{ {
yylhsminor.yy135 = tListItemAppend(yymsp[-2].minor.yy135, &yymsp[0].minor.yy191, -1); yylhsminor.yy131 = tListItemAppend(yymsp[-2].minor.yy131, &yymsp[0].minor.yy43, -1);
} }
yymsp[-2].minor.yy135 = yylhsminor.yy135; yymsp[-2].minor.yy131 = yylhsminor.yy131;
break; break;
case 218: /* grouplist ::= item */ case 211: /* grouplist ::= item */
{ {
yylhsminor.yy135 = tListItemAppend(NULL, &yymsp[0].minor.yy191, -1); yylhsminor.yy131 = tListItemAppend(NULL, &yymsp[0].minor.yy43, -1);
} }
yymsp[0].minor.yy135 = yylhsminor.yy135; yymsp[0].minor.yy131 = yylhsminor.yy131;
break; break;
case 219: /* having_opt ::= */ case 212: /* having_opt ::= */
case 229: /* where_opt ::= */ yytestcase(yyruleno==229); case 222: /* where_opt ::= */ yytestcase(yyruleno==222);
case 273: /* expritem ::= */ yytestcase(yyruleno==273); case 266: /* expritem ::= */ yytestcase(yyruleno==266);
{yymsp[1].minor.yy526 = 0;} {yymsp[1].minor.yy46 = 0;}
break; break;
case 220: /* having_opt ::= HAVING expr */ case 213: /* having_opt ::= HAVING expr */
case 230: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==230); case 223: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==223);
{yymsp[-1].minor.yy526 = yymsp[0].minor.yy526;} {yymsp[-1].minor.yy46 = yymsp[0].minor.yy46;}
break; break;
case 221: /* limit_opt ::= */ case 214: /* limit_opt ::= */
case 225: /* slimit_opt ::= */ yytestcase(yyruleno==225); case 218: /* slimit_opt ::= */ yytestcase(yyruleno==218);
{yymsp[1].minor.yy247.limit = -1; yymsp[1].minor.yy247.offset = 0;} {yymsp[1].minor.yy55.limit = -1; yymsp[1].minor.yy55.offset = 0;}
break; break;
case 222: /* limit_opt ::= LIMIT signed */ case 215: /* limit_opt ::= LIMIT signed */
case 226: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==226); case 219: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==219);
{yymsp[-1].minor.yy247.limit = yymsp[0].minor.yy531; yymsp[-1].minor.yy247.offset = 0;} {yymsp[-1].minor.yy55.limit = yymsp[0].minor.yy459; yymsp[-1].minor.yy55.offset = 0;}
break; break;
case 223: /* limit_opt ::= LIMIT signed OFFSET signed */ case 216: /* limit_opt ::= LIMIT signed OFFSET signed */
{ yymsp[-3].minor.yy247.limit = yymsp[-2].minor.yy531; yymsp[-3].minor.yy247.offset = yymsp[0].minor.yy531;} { yymsp[-3].minor.yy55.limit = yymsp[-2].minor.yy459; yymsp[-3].minor.yy55.offset = yymsp[0].minor.yy459;}
break; break;
case 224: /* limit_opt ::= LIMIT signed COMMA signed */ case 217: /* limit_opt ::= LIMIT signed COMMA signed */
{ yymsp[-3].minor.yy247.limit = yymsp[0].minor.yy531; yymsp[-3].minor.yy247.offset = yymsp[-2].minor.yy531;} { yymsp[-3].minor.yy55.limit = yymsp[0].minor.yy459; yymsp[-3].minor.yy55.offset = yymsp[-2].minor.yy459;}
break; break;
case 227: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ case 220: /* slimit_opt ::= SLIMIT signed SOFFSET signed */
{yymsp[-3].minor.yy247.limit = yymsp[-2].minor.yy531; yymsp[-3].minor.yy247.offset = yymsp[0].minor.yy531;} {yymsp[-3].minor.yy55.limit = yymsp[-2].minor.yy459; yymsp[-3].minor.yy55.offset = yymsp[0].minor.yy459;}
break; break;
case 228: /* slimit_opt ::= SLIMIT signed COMMA signed */ case 221: /* slimit_opt ::= SLIMIT signed COMMA signed */
{yymsp[-3].minor.yy247.limit = yymsp[0].minor.yy531; yymsp[-3].minor.yy247.offset = yymsp[-2].minor.yy531;} {yymsp[-3].minor.yy55.limit = yymsp[0].minor.yy459; yymsp[-3].minor.yy55.offset = yymsp[-2].minor.yy459;}
break; break;
case 231: /* expr ::= LP expr RP */ case 224: /* expr ::= LP expr RP */
{yylhsminor.yy526 = yymsp[-1].minor.yy526; yylhsminor.yy526->exprToken.z = yymsp[-2].minor.yy0.z; yylhsminor.yy526->exprToken.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);} {yylhsminor.yy46 = yymsp[-1].minor.yy46; yylhsminor.yy46->exprToken.z = yymsp[-2].minor.yy0.z; yylhsminor.yy46->exprToken.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);}
yymsp[-2].minor.yy526 = yylhsminor.yy526; yymsp[-2].minor.yy46 = yylhsminor.yy46;
break; break;
case 232: /* expr ::= ID */ case 225: /* expr ::= ID */
{ yylhsminor.yy526 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_ID);} { yylhsminor.yy46 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_ID);}
yymsp[0].minor.yy526 = yylhsminor.yy526; yymsp[0].minor.yy46 = yylhsminor.yy46;
break; break;
case 233: /* expr ::= ID DOT ID */ case 226: /* expr ::= ID DOT ID */
{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy526 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ID);} { yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy46 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ID);}
yymsp[-2].minor.yy526 = yylhsminor.yy526; yymsp[-2].minor.yy46 = yylhsminor.yy46;
break; break;
case 234: /* expr ::= ID DOT STAR */ case 227: /* expr ::= ID DOT STAR */
{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy526 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ALL);} { yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy46 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ALL);}
yymsp[-2].minor.yy526 = yylhsminor.yy526; yymsp[-2].minor.yy46 = yylhsminor.yy46;
break; break;
case 235: /* expr ::= INTEGER */ case 228: /* expr ::= INTEGER */
{ yylhsminor.yy526 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_INTEGER);} { yylhsminor.yy46 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_INTEGER);}
yymsp[0].minor.yy526 = yylhsminor.yy526; yymsp[0].minor.yy46 = yylhsminor.yy46;
break; break;
case 236: /* expr ::= MINUS INTEGER */ case 229: /* expr ::= MINUS INTEGER */
case 237: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==237); case 230: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==230);
{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy526 = 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.yy46 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_INTEGER);}
yymsp[-1].minor.yy526 = yylhsminor.yy526; yymsp[-1].minor.yy46 = yylhsminor.yy46;
break; break;
case 238: /* expr ::= FLOAT */ case 231: /* expr ::= FLOAT */
{ yylhsminor.yy526 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_FLOAT);} { yylhsminor.yy46 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_FLOAT);}
yymsp[0].minor.yy526 = yylhsminor.yy526; yymsp[0].minor.yy46 = yylhsminor.yy46;
break; break;
case 239: /* expr ::= MINUS FLOAT */ case 232: /* expr ::= MINUS FLOAT */
case 240: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==240); case 233: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==233);
{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy526 = 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.yy46 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_FLOAT);}
yymsp[-1].minor.yy526 = yylhsminor.yy526; yymsp[-1].minor.yy46 = yylhsminor.yy46;
break; break;
case 241: /* expr ::= STRING */ case 234: /* expr ::= STRING */
{ yylhsminor.yy526 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_STRING);} { yylhsminor.yy46 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_STRING);}
yymsp[0].minor.yy526 = yylhsminor.yy526; yymsp[0].minor.yy46 = yylhsminor.yy46;
break; break;
case 242: /* expr ::= NOW */ case 235: /* expr ::= NOW */
{ yylhsminor.yy526 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NOW); } { yylhsminor.yy46 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NOW); }
yymsp[0].minor.yy526 = yylhsminor.yy526; yymsp[0].minor.yy46 = yylhsminor.yy46;
break; break;
case 243: /* expr ::= VARIABLE */ case 236: /* expr ::= VARIABLE */
{ yylhsminor.yy526 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_VARIABLE);} { yylhsminor.yy46 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_VARIABLE);}
yymsp[0].minor.yy526 = yylhsminor.yy526; yymsp[0].minor.yy46 = yylhsminor.yy46;
break; break;
case 244: /* expr ::= PLUS VARIABLE */ case 237: /* expr ::= PLUS VARIABLE */
case 245: /* expr ::= MINUS VARIABLE */ yytestcase(yyruleno==245); case 238: /* expr ::= MINUS VARIABLE */ yytestcase(yyruleno==238);
{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_VARIABLE; yylhsminor.yy526 = 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.yy46 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_VARIABLE);}
yymsp[-1].minor.yy526 = yylhsminor.yy526; yymsp[-1].minor.yy46 = yylhsminor.yy46;
break; break;
case 246: /* expr ::= BOOL */ case 239: /* expr ::= BOOL */
{ yylhsminor.yy526 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_BOOL);} { yylhsminor.yy46 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_BOOL);}
yymsp[0].minor.yy526 = yylhsminor.yy526; yymsp[0].minor.yy46 = yylhsminor.yy46;
break; break;
case 247: /* expr ::= NULL */ case 240: /* expr ::= NULL */
{ yylhsminor.yy526 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NULL);} { yylhsminor.yy46 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NULL);}
yymsp[0].minor.yy526 = yylhsminor.yy526; yymsp[0].minor.yy46 = yylhsminor.yy46;
break; break;
case 248: /* expr ::= ID LP exprlist RP */ case 241: /* expr ::= ID LP exprlist RP */
{ tRecordFuncName(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy526 = tSqlExprCreateFunction(yymsp[-1].minor.yy135, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } { tRecordFuncName(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy46 = tSqlExprCreateFunction(yymsp[-1].minor.yy131, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); }
yymsp[-3].minor.yy526 = yylhsminor.yy526; yymsp[-3].minor.yy46 = yylhsminor.yy46;
break; break;
case 249: /* expr ::= ID LP STAR RP */ case 242: /* expr ::= ID LP STAR RP */
{ tRecordFuncName(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy526 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } { tRecordFuncName(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy46 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); }
yymsp[-3].minor.yy526 = yylhsminor.yy526; yymsp[-3].minor.yy46 = yylhsminor.yy46;
break; break;
case 250: /* expr ::= expr IS NULL */ case 243: /* expr ::= expr IS NULL */
{yylhsminor.yy526 = tSqlExprCreate(yymsp[-2].minor.yy526, NULL, TK_ISNULL);} {yylhsminor.yy46 = tSqlExprCreate(yymsp[-2].minor.yy46, NULL, TK_ISNULL);}
yymsp[-2].minor.yy526 = yylhsminor.yy526; yymsp[-2].minor.yy46 = yylhsminor.yy46;
break; break;
case 251: /* expr ::= expr IS NOT NULL */ case 244: /* expr ::= expr IS NOT NULL */
{yylhsminor.yy526 = tSqlExprCreate(yymsp[-3].minor.yy526, NULL, TK_NOTNULL);} {yylhsminor.yy46 = tSqlExprCreate(yymsp[-3].minor.yy46, NULL, TK_NOTNULL);}
yymsp[-3].minor.yy526 = yylhsminor.yy526; yymsp[-3].minor.yy46 = yylhsminor.yy46;
break; break;
case 252: /* expr ::= expr LT expr */ case 245: /* expr ::= expr LT expr */
{yylhsminor.yy526 = tSqlExprCreate(yymsp[-2].minor.yy526, yymsp[0].minor.yy526, TK_LT);} {yylhsminor.yy46 = tSqlExprCreate(yymsp[-2].minor.yy46, yymsp[0].minor.yy46, TK_LT);}
yymsp[-2].minor.yy526 = yylhsminor.yy526; yymsp[-2].minor.yy46 = yylhsminor.yy46;
break; break;
case 253: /* expr ::= expr GT expr */ case 246: /* expr ::= expr GT expr */
{yylhsminor.yy526 = tSqlExprCreate(yymsp[-2].minor.yy526, yymsp[0].minor.yy526, TK_GT);} {yylhsminor.yy46 = tSqlExprCreate(yymsp[-2].minor.yy46, yymsp[0].minor.yy46, TK_GT);}
yymsp[-2].minor.yy526 = yylhsminor.yy526; yymsp[-2].minor.yy46 = yylhsminor.yy46;
break; break;
case 254: /* expr ::= expr LE expr */ case 247: /* expr ::= expr LE expr */
{yylhsminor.yy526 = tSqlExprCreate(yymsp[-2].minor.yy526, yymsp[0].minor.yy526, TK_LE);} {yylhsminor.yy46 = tSqlExprCreate(yymsp[-2].minor.yy46, yymsp[0].minor.yy46, TK_LE);}
yymsp[-2].minor.yy526 = yylhsminor.yy526; yymsp[-2].minor.yy46 = yylhsminor.yy46;
break; break;
case 255: /* expr ::= expr GE expr */ case 248: /* expr ::= expr GE expr */
{yylhsminor.yy526 = tSqlExprCreate(yymsp[-2].minor.yy526, yymsp[0].minor.yy526, TK_GE);} {yylhsminor.yy46 = tSqlExprCreate(yymsp[-2].minor.yy46, yymsp[0].minor.yy46, TK_GE);}
yymsp[-2].minor.yy526 = yylhsminor.yy526; yymsp[-2].minor.yy46 = yylhsminor.yy46;
break; break;
case 256: /* expr ::= expr NE expr */ case 249: /* expr ::= expr NE expr */
{yylhsminor.yy526 = tSqlExprCreate(yymsp[-2].minor.yy526, yymsp[0].minor.yy526, TK_NE);} {yylhsminor.yy46 = tSqlExprCreate(yymsp[-2].minor.yy46, yymsp[0].minor.yy46, TK_NE);}
yymsp[-2].minor.yy526 = yylhsminor.yy526; yymsp[-2].minor.yy46 = yylhsminor.yy46;
break; break;
case 257: /* expr ::= expr EQ expr */ case 250: /* expr ::= expr EQ expr */
{yylhsminor.yy526 = tSqlExprCreate(yymsp[-2].minor.yy526, yymsp[0].minor.yy526, TK_EQ);} {yylhsminor.yy46 = tSqlExprCreate(yymsp[-2].minor.yy46, yymsp[0].minor.yy46, TK_EQ);}
yymsp[-2].minor.yy526 = yylhsminor.yy526; yymsp[-2].minor.yy46 = yylhsminor.yy46;
break; break;
case 258: /* expr ::= expr BETWEEN expr AND expr */ case 251: /* expr ::= expr BETWEEN expr AND expr */
{ tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy526); yylhsminor.yy526 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy526, yymsp[-2].minor.yy526, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy526, TK_LE), TK_AND);} { tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy46); yylhsminor.yy46 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy46, yymsp[-2].minor.yy46, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy46, TK_LE), TK_AND);}
yymsp[-4].minor.yy526 = yylhsminor.yy526; yymsp[-4].minor.yy46 = yylhsminor.yy46;
break; break;
case 259: /* expr ::= expr AND expr */ case 252: /* expr ::= expr AND expr */
{yylhsminor.yy526 = tSqlExprCreate(yymsp[-2].minor.yy526, yymsp[0].minor.yy526, TK_AND);} {yylhsminor.yy46 = tSqlExprCreate(yymsp[-2].minor.yy46, yymsp[0].minor.yy46, TK_AND);}
yymsp[-2].minor.yy526 = yylhsminor.yy526; yymsp[-2].minor.yy46 = yylhsminor.yy46;
break; break;
case 260: /* expr ::= expr OR expr */ case 253: /* expr ::= expr OR expr */
{yylhsminor.yy526 = tSqlExprCreate(yymsp[-2].minor.yy526, yymsp[0].minor.yy526, TK_OR); } {yylhsminor.yy46 = tSqlExprCreate(yymsp[-2].minor.yy46, yymsp[0].minor.yy46, TK_OR); }
yymsp[-2].minor.yy526 = yylhsminor.yy526; yymsp[-2].minor.yy46 = yylhsminor.yy46;
break; break;
case 261: /* expr ::= expr PLUS expr */ case 254: /* expr ::= expr PLUS expr */
{yylhsminor.yy526 = tSqlExprCreate(yymsp[-2].minor.yy526, yymsp[0].minor.yy526, TK_PLUS); } {yylhsminor.yy46 = tSqlExprCreate(yymsp[-2].minor.yy46, yymsp[0].minor.yy46, TK_PLUS); }
yymsp[-2].minor.yy526 = yylhsminor.yy526; yymsp[-2].minor.yy46 = yylhsminor.yy46;
break; break;
case 262: /* expr ::= expr MINUS expr */ case 255: /* expr ::= expr MINUS expr */
{yylhsminor.yy526 = tSqlExprCreate(yymsp[-2].minor.yy526, yymsp[0].minor.yy526, TK_MINUS); } {yylhsminor.yy46 = tSqlExprCreate(yymsp[-2].minor.yy46, yymsp[0].minor.yy46, TK_MINUS); }
yymsp[-2].minor.yy526 = yylhsminor.yy526; yymsp[-2].minor.yy46 = yylhsminor.yy46;
break; break;
case 263: /* expr ::= expr STAR expr */ case 256: /* expr ::= expr STAR expr */
{yylhsminor.yy526 = tSqlExprCreate(yymsp[-2].minor.yy526, yymsp[0].minor.yy526, TK_STAR); } {yylhsminor.yy46 = tSqlExprCreate(yymsp[-2].minor.yy46, yymsp[0].minor.yy46, TK_STAR); }
yymsp[-2].minor.yy526 = yylhsminor.yy526; yymsp[-2].minor.yy46 = yylhsminor.yy46;
break; break;
case 264: /* expr ::= expr SLASH expr */ case 257: /* expr ::= expr SLASH expr */
{yylhsminor.yy526 = tSqlExprCreate(yymsp[-2].minor.yy526, yymsp[0].minor.yy526, TK_DIVIDE);} {yylhsminor.yy46 = tSqlExprCreate(yymsp[-2].minor.yy46, yymsp[0].minor.yy46, TK_DIVIDE);}
yymsp[-2].minor.yy526 = yylhsminor.yy526; yymsp[-2].minor.yy46 = yylhsminor.yy46;
break; break;
case 265: /* expr ::= expr REM expr */ case 258: /* expr ::= expr REM expr */
{yylhsminor.yy526 = tSqlExprCreate(yymsp[-2].minor.yy526, yymsp[0].minor.yy526, TK_REM); } {yylhsminor.yy46 = tSqlExprCreate(yymsp[-2].minor.yy46, yymsp[0].minor.yy46, TK_REM); }
yymsp[-2].minor.yy526 = yylhsminor.yy526; yymsp[-2].minor.yy46 = yylhsminor.yy46;
break; break;
case 266: /* expr ::= expr LIKE expr */ case 259: /* expr ::= expr LIKE expr */
{yylhsminor.yy526 = tSqlExprCreate(yymsp[-2].minor.yy526, yymsp[0].minor.yy526, TK_LIKE); } {yylhsminor.yy46 = tSqlExprCreate(yymsp[-2].minor.yy46, yymsp[0].minor.yy46, TK_LIKE); }
yymsp[-2].minor.yy526 = yylhsminor.yy526; yymsp[-2].minor.yy46 = yylhsminor.yy46;
break; break;
case 267: /* expr ::= expr MATCH expr */ case 260: /* expr ::= expr MATCH expr */
{yylhsminor.yy526 = tSqlExprCreate(yymsp[-2].minor.yy526, yymsp[0].minor.yy526, TK_MATCH); } {yylhsminor.yy46 = tSqlExprCreate(yymsp[-2].minor.yy46, yymsp[0].minor.yy46, TK_MATCH); }
yymsp[-2].minor.yy526 = yylhsminor.yy526; yymsp[-2].minor.yy46 = yylhsminor.yy46;
break; break;
case 268: /* expr ::= expr NMATCH expr */ case 261: /* expr ::= expr NMATCH expr */
{yylhsminor.yy526 = tSqlExprCreate(yymsp[-2].minor.yy526, yymsp[0].minor.yy526, TK_NMATCH); } {yylhsminor.yy46 = tSqlExprCreate(yymsp[-2].minor.yy46, yymsp[0].minor.yy46, TK_NMATCH); }
yymsp[-2].minor.yy526 = yylhsminor.yy526; yymsp[-2].minor.yy46 = yylhsminor.yy46;
break; break;
case 269: /* expr ::= expr IN LP exprlist RP */ case 262: /* expr ::= expr IN LP exprlist RP */
{yylhsminor.yy526 = tSqlExprCreate(yymsp[-4].minor.yy526, (tSqlExpr*)yymsp[-1].minor.yy135, TK_IN); } {yylhsminor.yy46 = tSqlExprCreate(yymsp[-4].minor.yy46, (tSqlExpr*)yymsp[-1].minor.yy131, TK_IN); }
yymsp[-4].minor.yy526 = yylhsminor.yy526; yymsp[-4].minor.yy46 = yylhsminor.yy46;
break; break;
case 270: /* exprlist ::= exprlist COMMA expritem */ case 263: /* exprlist ::= exprlist COMMA expritem */
{yylhsminor.yy135 = tSqlExprListAppend(yymsp[-2].minor.yy135,yymsp[0].minor.yy526,0, 0);} {yylhsminor.yy131 = tSqlExprListAppend(yymsp[-2].minor.yy131,yymsp[0].minor.yy46,0, 0);}
yymsp[-2].minor.yy135 = yylhsminor.yy135; yymsp[-2].minor.yy131 = yylhsminor.yy131;
break; break;
case 271: /* exprlist ::= expritem */ case 264: /* exprlist ::= expritem */
{yylhsminor.yy135 = tSqlExprListAppend(0,yymsp[0].minor.yy526,0, 0);} {yylhsminor.yy131 = tSqlExprListAppend(0,yymsp[0].minor.yy46,0, 0);}
yymsp[0].minor.yy135 = yylhsminor.yy135; yymsp[0].minor.yy131 = yylhsminor.yy131;
break; break;
case 272: /* expritem ::= expr */ case 265: /* expritem ::= expr */
{yylhsminor.yy526 = yymsp[0].minor.yy526;} {yylhsminor.yy46 = yymsp[0].minor.yy46;}
yymsp[0].minor.yy526 = yylhsminor.yy526; yymsp[0].minor.yy46 = yylhsminor.yy46;
break; break;
case 274: /* cmd ::= RESET QUERY CACHE */ case 267: /* cmd ::= RESET QUERY CACHE */
{ setDCLSqlElems(pInfo, TSDB_SQL_RESET_CACHE, 0);} { setDCLSqlElems(pInfo, TSDB_SQL_RESET_CACHE, 0);}
break; break;
case 275: /* cmd ::= SYNCDB ids REPLICA */ case 268: /* 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 276: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ case 269: /* 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.yy135, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy131, 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 277: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ case 270: /* 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);
...@@ -3178,21 +3140,21 @@ static void yy_reduce( ...@@ -3178,21 +3140,21 @@ 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 MODIFY COLUMN columnlist */ case 271: /* 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.yy135, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, -1); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy131, 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 279: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ case 272: /* 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.yy135, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy131, 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 280: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ case 273: /* 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;
...@@ -3203,7 +3165,7 @@ static void yy_reduce( ...@@ -3203,7 +3165,7 @@ static void yy_reduce(
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 281: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ case 274: /* 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;
...@@ -3217,33 +3179,33 @@ static void yy_reduce( ...@@ -3217,33 +3179,33 @@ 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 TABLE ids cpxName SET TAG ids EQ tagitem */ case 275: /* 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.yy191, -1); A = tListItemAppend(A, &yymsp[0].minor.yy43, -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 283: /* cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ case 276: /* 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.yy135, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, -1); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy131, 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 284: /* cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ case 277: /* 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.yy135, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy131, 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 285: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ case 278: /* 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;
...@@ -3254,21 +3216,21 @@ static void yy_reduce( ...@@ -3254,21 +3216,21 @@ 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 MODIFY COLUMN columnlist */ case 279: /* 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.yy135, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, TSDB_SUPER_TABLE); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy131, 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 287: /* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ case 280: /* 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.yy135, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy131, 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 288: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ case 281: /* 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;
...@@ -3279,7 +3241,7 @@ static void yy_reduce( ...@@ -3279,7 +3241,7 @@ static void yy_reduce(
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 289: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ case 282: /* 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;
...@@ -3293,32 +3255,32 @@ static void yy_reduce( ...@@ -3293,32 +3255,32 @@ static void yy_reduce(
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 290: /* cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ case 283: /* 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.yy191, -1); A = tListItemAppend(A, &yymsp[0].minor.yy43, -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 291: /* cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ case 284: /* 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.yy135, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, TSDB_SUPER_TABLE); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy131, 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 292: /* cmd ::= KILL CONNECTION INTEGER */ case 285: /* 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 293: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */ case 286: /* 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 294: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */ case 287: /* 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:
......
...@@ -217,7 +217,7 @@ static SKeyword keywordTable[] = { ...@@ -217,7 +217,7 @@ static SKeyword keywordTable[] = {
{"UNION", TK_UNION}, {"UNION", TK_UNION},
{"CACHELAST", TK_CACHELAST}, {"CACHELAST", TK_CACHELAST},
{"DISTINCT", TK_DISTINCT}, {"DISTINCT", TK_DISTINCT},
{"PARTITIONS", TK_PARTITIONS}, // {"PARTITIONS", TK_PARTITIONS},
{"TOPIC", TK_TOPIC}, {"TOPIC", TK_TOPIC},
{"TOPICS", TK_TOPICS}, {"TOPICS", TK_TOPICS},
{"COMPACT", TK_COMPACT}, {"COMPACT", TK_COMPACT},
......
...@@ -23,20 +23,20 @@ ...@@ -23,20 +23,20 @@
namespace { namespace {
void generateTestT1(MockCatalogService* mcs) { void generateTestT1(MockCatalogService* mcs) {
ITableBuilder& builder = mcs->createTableBuilder("root.test", "t1", TSDB_NORMAL_TABLE, 3) ITableBuilder& builder = mcs->createTableBuilder("test", "t1", TSDB_NORMAL_TABLE, 3)
.setPrecision(TSDB_TIME_PRECISION_MILLI).setVgid(1).addColumn("ts", TSDB_DATA_TYPE_TIMESTAMP) .setPrecision(TSDB_TIME_PRECISION_MILLI).setVgid(1).addColumn("ts", TSDB_DATA_TYPE_TIMESTAMP)
.addColumn("c1", TSDB_DATA_TYPE_INT).addColumn("c2", TSDB_DATA_TYPE_BINARY, 20); .addColumn("c1", TSDB_DATA_TYPE_INT).addColumn("c2", TSDB_DATA_TYPE_BINARY, 20);
builder.done(); builder.done();
} }
void generateTestST1(MockCatalogService* mcs) { void generateTestST1(MockCatalogService* mcs) {
ITableBuilder& builder = mcs->createTableBuilder("root.test", "st1", TSDB_SUPER_TABLE, 3, 2) ITableBuilder& builder = mcs->createTableBuilder("test", "st1", TSDB_SUPER_TABLE, 3, 2)
.setPrecision(TSDB_TIME_PRECISION_MILLI).addColumn("ts", TSDB_DATA_TYPE_TIMESTAMP) .setPrecision(TSDB_TIME_PRECISION_MILLI).addColumn("ts", TSDB_DATA_TYPE_TIMESTAMP)
.addTag("tag1", TSDB_DATA_TYPE_INT).addTag("tag2", TSDB_DATA_TYPE_BINARY, 20) .addTag("tag1", TSDB_DATA_TYPE_INT).addTag("tag2", TSDB_DATA_TYPE_BINARY, 20)
.addColumn("c1", TSDB_DATA_TYPE_INT).addColumn("c2", TSDB_DATA_TYPE_BINARY, 20); .addColumn("c1", TSDB_DATA_TYPE_INT).addColumn("c2", TSDB_DATA_TYPE_BINARY, 20);
builder.done(); builder.done();
mcs->createSubTable("root.test", "st1", "st1s1", 1); mcs->createSubTable("test", "st1", "st1s1", 1);
mcs->createSubTable("root.test", "st1", "st1s2", 2); mcs->createSubTable("test", "st1", "st1s2", 2);
} }
} }
......
...@@ -94,9 +94,9 @@ public: ...@@ -94,9 +94,9 @@ public:
return 0; return 0;
} }
int32_t catalogGetTableMeta(const char* pDBName, const char* pTableName, STableMeta** pTableMeta) const { int32_t catalogGetTableMeta(const char* pDbFullName, const char* pTableName, STableMeta** pTableMeta) const {
std::unique_ptr<STableMeta> table; std::unique_ptr<STableMeta> table;
int32_t code = copyTableSchemaMeta(pDBName, pTableName, &table); int32_t code = copyTableSchemaMeta(toDbname(pDbFullName), pTableName, &table);
if (TSDB_CODE_SUCCESS != code) { if (TSDB_CODE_SUCCESS != code) {
return code; return code;
} }
...@@ -104,7 +104,7 @@ public: ...@@ -104,7 +104,7 @@ public:
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t catalogGetTableHashVgroup(const char* pDBName, const char* pTableName, SVgroupInfo* vgInfo) const { int32_t catalogGetTableHashVgroup(const char* pDbFullName, const char* pTableName, SVgroupInfo* vgInfo) const {
// todo // todo
return 0; return 0;
} }
...@@ -195,6 +195,14 @@ private: ...@@ -195,6 +195,14 @@ private:
typedef std::map<std::string, std::shared_ptr<MockTableMeta>> TableMetaCache; typedef std::map<std::string, std::shared_ptr<MockTableMeta>> TableMetaCache;
typedef std::map<std::string, TableMetaCache> DbMetaCache; typedef std::map<std::string, TableMetaCache> DbMetaCache;
std::string toDbname(const std::string& dbFullName) const {
std::string::size_type n = dbFullName.find(".");
if (n == std::string::npos) {
return dbFullName;
}
return dbFullName.substr(n + 1);
}
std::string ttToString(int8_t tableType) const { std::string ttToString(int8_t tableType) const {
switch (tableType) { switch (tableType) {
case TSDB_SUPER_TABLE: case TSDB_SUPER_TABLE:
......
...@@ -714,12 +714,9 @@ TEST(testCase, show_user_Test) { ...@@ -714,12 +714,9 @@ TEST(testCase, show_user_Test) {
SSqlInfo info1 = doGenerateAST(sql1); SSqlInfo info1 = doGenerateAST(sql1);
ASSERT_EQ(info1.valid, true); ASSERT_EQ(info1.valid, true);
void* output = NULL; SDclStmtInfo output;
int32_t type = 0;
int32_t len = 0;
SParseBasicCtx ct= {.db= "abc", .acctId = 1, .requestId = 1}; SParseBasicCtx ct= {.db= "abc", .acctId = 1, .requestId = 1};
int32_t code = qParserValidateDclSqlNode(&info1, &ct, &output, &len, &type, msg, buf.len); int32_t code = qParserValidateDclSqlNode(&info1, &ct, &output, msg, buf.len);
ASSERT_EQ(code, 0); ASSERT_EQ(code, 0);
// convert the show command to be the select query // convert the show command to be the select query
...@@ -738,12 +735,9 @@ TEST(testCase, create_user_Test) { ...@@ -738,12 +735,9 @@ TEST(testCase, create_user_Test) {
ASSERT_EQ(info1.valid, true); ASSERT_EQ(info1.valid, true);
ASSERT_EQ(isDclSqlStatement(&info1), true); ASSERT_EQ(isDclSqlStatement(&info1), true);
void* output = NULL; SDclStmtInfo output;
int32_t type = 0;
int32_t len = 0;
SParseBasicCtx ct= {.db= "abc", .acctId = 1, .requestId = 1}; SParseBasicCtx ct= {.db= "abc", .acctId = 1, .requestId = 1};
int32_t code = qParserValidateDclSqlNode(&info1, &ct, &output, &len, &type, msg, buf.len); int32_t code = qParserValidateDclSqlNode(&info1, &ct, &output, msg, buf.len);
ASSERT_EQ(code, 0); ASSERT_EQ(code, 0);
destroySqlInfo(&info1); destroySqlInfo(&info1);
......
...@@ -102,7 +102,7 @@ int32_t queryPlanToSql(struct SQueryPlanNode* pQueryNode, char** sql); ...@@ -102,7 +102,7 @@ int32_t queryPlanToSql(struct SQueryPlanNode* pQueryNode, char** sql);
int32_t createDag(SQueryPlanNode* pQueryNode, struct SCatalog* pCatalog, SQueryDag** pDag); int32_t createDag(SQueryPlanNode* pQueryNode, struct SCatalog* pCatalog, SQueryDag** pDag);
int32_t setSubplanExecutionNode(SSubplan* subplan, uint64_t templateId, SEpAddr* ep); int32_t setSubplanExecutionNode(SSubplan* subplan, uint64_t templateId, SEpAddr* ep);
int32_t subPlanToString(const SSubplan *pPhyNode, char** str); int32_t subPlanToString(const SSubplan *pPhyNode, char** str, int32_t* len);
int32_t stringToSubplan(const char* str, SSubplan** subplan); int32_t stringToSubplan(const char* str, SSubplan** subplan);
/** /**
...@@ -121,6 +121,9 @@ void* destroyQueryPhyPlan(struct SPhyNode* pQueryPhyNode); ...@@ -121,6 +121,9 @@ void* destroyQueryPhyPlan(struct SPhyNode* pQueryPhyNode);
const char* opTypeToOpName(int32_t type); const char* opTypeToOpName(int32_t type);
int32_t opNameToOpType(const char* name); int32_t opNameToOpType(const char* name);
const char* dsinkTypeToDsinkName(int32_t type);
int32_t dsinkNameToDsinkType(const char* name);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -47,16 +47,38 @@ const char* opTypeToOpName(int32_t type) { ...@@ -47,16 +47,38 @@ const char* opTypeToOpName(int32_t type) {
int32_t opNameToOpType(const char* name) { int32_t opNameToOpType(const char* name) {
for (int32_t i = 1; i < sizeof(gOpName) / sizeof(gOpName[0]); ++i) { for (int32_t i = 1; i < sizeof(gOpName) / sizeof(gOpName[0]); ++i) {
if (strcmp(name, gOpName[i])) { if (0 == strcmp(name, gOpName[i])) {
return i; return i;
} }
} }
return OP_Unknown; return OP_Unknown;
} }
const char* dsinkTypeToDsinkName(int32_t type) {
switch (type) {
case DSINK_Dispatch:
return "Dispatch";
case DSINK_Insert:
return "Insert";
default:
break;
}
return "Unknown";
}
int32_t dsinkNameToDsinkType(const char* name) {
if (0 == strcmp(name, "Dispatch")) {
return DSINK_Dispatch;
} else if (0 == strcmp(name, "Insert")) {
return DSINK_Insert;
}
return DSINK_Unknown;
}
static SDataSink* initDataSink(int32_t type, int32_t size) { static SDataSink* initDataSink(int32_t type, int32_t size) {
SDataSink* sink = (SDataSink*)vailidPointer(calloc(1, size)); SDataSink* sink = (SDataSink*)vailidPointer(calloc(1, size));
sink->info.type = type; sink->info.type = type;
sink->info.name = dsinkTypeToDsinkName(type);
return sink; return sink;
} }
......
...@@ -695,6 +695,70 @@ static bool phyNodeFromJson(const cJSON* json, void* obj) { ...@@ -695,6 +695,70 @@ static bool phyNodeFromJson(const cJSON* json, void* obj) {
return res; return res;
} }
static const char* jkInserterNumOfTables = "NumOfTables";
static const char* jkInserterDataSize = "DataSize";
static bool inserterToJson(const void* obj, cJSON* json) {
const SDataInserter* inserter = (const SDataInserter*)obj;
bool res = cJSON_AddNumberToObject(json, jkInserterNumOfTables, inserter->numOfTables);
if (res) {
res = cJSON_AddNumberToObject(json, jkInserterDataSize, inserter->size);
}
// todo pData
return res;
}
static bool inserterFromJson(const cJSON* json, void* obj) {
SDataInserter* inserter = (SDataInserter*)obj;
inserter->numOfTables = getNumber(json, jkInserterNumOfTables);
inserter->size = getNumber(json, jkInserterDataSize);
// todo pData
}
static bool specificDataSinkToJson(const void* obj, cJSON* json) {
const SDataSink* dsink = (const SDataSink*)obj;
switch (dsink->info.type) {
case DSINK_Dispatch:
return true;
case DSINK_Insert:
return inserterToJson(obj, json);
default:
break;
}
return false;
}
static bool specificDataSinkFromJson(const cJSON* json, void* obj) {
SDataSink* dsink = (SDataSink*)obj;
switch (dsink->info.type) {
case DSINK_Dispatch:
return true;
case DSINK_Insert:
return inserterFromJson(json, obj);
default:
break;
}
return false;
}
static const char* jkDataSinkName = "Name";
static bool dataSinkToJson(const void* obj, cJSON* json) {
const SDataSink* dsink = (const SDataSink*)obj;
bool res = cJSON_AddStringToObject(json, jkDataSinkName, dsink->info.name);
if (res) {
res = addObject(json, dsink->info.name, specificDataSinkToJson, dsink);
}
return res;
}
static bool dataSinkFromJson(const cJSON* json, void* obj) {
SDataSink* dsink = (SDataSink*)obj;
dsink->info.name = getString(json, jkDataSinkName);
dsink->info.type = dsinkNameToDsinkType(dsink->info.name);
return fromObject(json, dsink->info.name, specificDataSinkFromJson, dsink, true);
}
static const char* jkIdQueryId = "QueryId"; static const char* jkIdQueryId = "QueryId";
static const char* jkIdTemplateId = "TemplateId"; static const char* jkIdTemplateId = "TemplateId";
static const char* jkIdSubplanId = "SubplanId"; static const char* jkIdSubplanId = "SubplanId";
...@@ -721,6 +785,7 @@ static bool subplanIdFromJson(const cJSON* json, void* obj) { ...@@ -721,6 +785,7 @@ static bool subplanIdFromJson(const cJSON* json, void* obj) {
static const char* jkSubplanId = "Id"; static const char* jkSubplanId = "Id";
static const char* jkSubplanNode = "Node"; static const char* jkSubplanNode = "Node";
static const char* jkSubplanDataSink = "DataSink";
static cJSON* subplanToJson(const SSubplan* subplan) { static cJSON* subplanToJson(const SSubplan* subplan) {
cJSON* jSubplan = cJSON_CreateObject(); cJSON* jSubplan = cJSON_CreateObject();
...@@ -734,6 +799,9 @@ static cJSON* subplanToJson(const SSubplan* subplan) { ...@@ -734,6 +799,9 @@ static cJSON* subplanToJson(const SSubplan* subplan) {
if (res) { if (res) {
res = addObject(jSubplan, jkSubplanNode, phyNodeToJson, subplan->pNode); res = addObject(jSubplan, jkSubplanNode, phyNodeToJson, subplan->pNode);
} }
if (res) {
res = addObject(jSubplan, jkSubplanDataSink, dataSinkToJson, subplan->pDataSink);
}
if (!res) { if (!res) {
cJSON_Delete(jSubplan); cJSON_Delete(jSubplan);
...@@ -751,6 +819,9 @@ static SSubplan* subplanFromJson(const cJSON* json) { ...@@ -751,6 +819,9 @@ static SSubplan* subplanFromJson(const cJSON* json) {
if (res) { if (res) {
res = fromObjectWithAlloc(json, jkSubplanNode, phyNodeFromJson, (void**)&subplan->pNode, sizeof(SPhyNode), false); res = fromObjectWithAlloc(json, jkSubplanNode, phyNodeFromJson, (void**)&subplan->pNode, sizeof(SPhyNode), false);
} }
if (res) {
res = fromObjectWithAlloc(json, jkSubplanDataSink, dataSinkFromJson, (void**)&subplan->pDataSink, sizeof(SDataSink), false);
}
if (!res) { if (!res) {
qDestroySubplan(subplan); qDestroySubplan(subplan);
...@@ -759,13 +830,22 @@ static SSubplan* subplanFromJson(const cJSON* json) { ...@@ -759,13 +830,22 @@ static SSubplan* subplanFromJson(const cJSON* json) {
return subplan; return subplan;
} }
int32_t subPlanToString(const SSubplan* subplan, char** str) { int32_t subPlanToString(const SSubplan* subplan, char** str, int32_t* len) {
if (QUERY_TYPE_MODIFY == subplan->type) {
SDataInserter* insert = (SDataInserter*)(subplan->pDataSink);
*len = insert->size;
*str = insert->pData;
insert->pData == NULL;
return TSDB_CODE_SUCCESS;
}
cJSON* json = subplanToJson(subplan); cJSON* json = subplanToJson(subplan);
if (NULL == json) { if (NULL == json) {
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
return TSDB_CODE_FAILED; return TSDB_CODE_FAILED;
} }
*str = cJSON_Print(json); *str = cJSON_Print(json);
*len = strlen(*str) + 1;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
......
...@@ -50,8 +50,8 @@ int32_t qSetSubplanExecutionNode(SSubplan* subplan, uint64_t templateId, SEpAddr ...@@ -50,8 +50,8 @@ int32_t qSetSubplanExecutionNode(SSubplan* subplan, uint64_t templateId, SEpAddr
return setSubplanExecutionNode(subplan, templateId, ep); return setSubplanExecutionNode(subplan, templateId, ep);
} }
int32_t qSubPlanToString(const SSubplan *subplan, char** str) { int32_t qSubPlanToString(const SSubplan *subplan, char** str, int32_t* len) {
return subPlanToString(subplan, str); return subPlanToString(subplan, str, len);
} }
int32_t qStringToSubplan(const char* str, SSubplan** subplan) { int32_t qStringToSubplan(const char* str, SSubplan** subplan) {
......
...@@ -33,10 +33,6 @@ protected: ...@@ -33,10 +33,6 @@ protected:
void pushScan(const string& db, const string& table, int32_t scanOp) { void pushScan(const string& db, const string& table, int32_t scanOp) {
shared_ptr<MockTableMeta> meta = mockCatalogService->getTableMeta(db, table); shared_ptr<MockTableMeta> meta = mockCatalogService->getTableMeta(db, table);
EXPECT_TRUE(meta); EXPECT_TRUE(meta);
// typedef struct SQueryPlanNode {
// SArray *pExpr; // the query functions or sql aggregations
// int32_t numOfExpr; // number of result columns, which is also the number of pExprs
// } SQueryPlanNode;
unique_ptr<SQueryPlanNode> scan((SQueryPlanNode*)calloc(1, sizeof(SQueryPlanNode))); unique_ptr<SQueryPlanNode> scan((SQueryPlanNode*)calloc(1, sizeof(SQueryPlanNode)));
scan->info.type = scanOp; scan->info.type = scanOp;
scan->numOfCols = meta->schema->tableInfo.numOfColumns; scan->numOfCols = meta->schema->tableInfo.numOfColumns;
...@@ -54,6 +50,21 @@ protected: ...@@ -54,6 +50,21 @@ protected:
return code; return code;
} }
int32_t run(const string& db, const string& sql) {
SParseContext cxt;
buildParseContext(db, sql, &cxt);
SQueryNode* query;
int32_t code = qParseQuerySql(&cxt, &query);
if (TSDB_CODE_SUCCESS != code) {
cout << "error no:" << code << ", msg:" << cxt.pMsg << endl;
return code;
}
SQueryDag* dag = nullptr;
code = qCreateQueryDag(query, nullptr, &dag);
dag_.reset(dag);
return code;
}
void explain() { void explain() {
size_t level = taosArrayGetSize(dag_->pSubplans); size_t level = taosArrayGetSize(dag_->pSubplans);
for (size_t i = 0; i < level; ++i) { for (size_t i = 0; i < level; ++i) {
...@@ -62,8 +73,10 @@ protected: ...@@ -62,8 +73,10 @@ protected:
size_t num = taosArrayGetSize(subplans); size_t num = taosArrayGetSize(subplans);
for (size_t j = 0; j < num; ++j) { for (size_t j = 0; j < num; ++j) {
std::cout << "no " << j << ":" << std::endl; std::cout << "no " << j << ":" << std::endl;
int32_t len = 0;
char* str = nullptr; char* str = nullptr;
ASSERT_EQ (TSDB_CODE_SUCCESS, qSubPlanToString((const SSubplan*)taosArrayGetP(subplans, j), &str)); ASSERT_EQ(TSDB_CODE_SUCCESS, qSubPlanToString((const SSubplan*)taosArrayGetP(subplans, j), &str, &len));
std::cout << "len:" << len << std::endl;
std::cout << str << std::endl; std::cout << str << std::endl;
free(str); free(str);
} }
...@@ -107,6 +120,25 @@ private: ...@@ -107,6 +120,25 @@ private:
return info; return info;
} }
void buildParseContext(const string& db, const string& sql, SParseContext* pCxt) {
static string _db;
static string _sql;
static const int32_t _msgMaxLen = 4096;
static char _msg[_msgMaxLen];
_db = db;
_sql = sql;
memset(_msg, 0, _msgMaxLen);
pCxt->ctx.acctId = 1;
pCxt->ctx.db = _db.c_str();
pCxt->ctx.requestId = 1;
pCxt->pSql = _sql.c_str();
pCxt->sqlLen = _sql.length();
pCxt->pMsg = _msg;
pCxt->msgLen = _msgMaxLen;
}
shared_ptr<MockTableMeta> meta_; shared_ptr<MockTableMeta> meta_;
unique_ptr<SQueryPlanNode> logicPlan_; unique_ptr<SQueryPlanNode> logicPlan_;
unique_ptr<SQueryDag> dag_; unique_ptr<SQueryDag> dag_;
...@@ -114,7 +146,7 @@ private: ...@@ -114,7 +146,7 @@ private:
// select * from table // select * from table
TEST_F(PhyPlanTest, tableScanTest) { TEST_F(PhyPlanTest, tableScanTest) {
pushScan("root.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 = reslut();
...@@ -123,9 +155,17 @@ TEST_F(PhyPlanTest, tableScanTest) { ...@@ -123,9 +155,17 @@ TEST_F(PhyPlanTest, tableScanTest) {
// select * from supertable // select * from supertable
TEST_F(PhyPlanTest, superTableScanTest) { TEST_F(PhyPlanTest, superTableScanTest) {
pushScan("root.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 = reslut();
// todo check // todo check
} }
// insert into t values(...)
TEST_F(PhyPlanTest, insertTest) {
ASSERT_EQ(run("test", "insert into t1 values (now, 1, \"beijing\")"), TSDB_CODE_SUCCESS);
explain();
SQueryDag* dag = reslut();
// todo check
}
...@@ -263,87 +263,12 @@ int32_t queryProcessTableMetaRsp(void* output, char *msg, int32_t msgSize) { ...@@ -263,87 +263,12 @@ int32_t queryProcessTableMetaRsp(void* output, char *msg, int32_t msgSize) {
} }
void msgInit() { void initQueryModuleMsgHandle() {
queryBuildMsg[TSDB_MSG_TYPE_TABLE_META] = queryBuildTableMetaReqMsg; queryBuildMsg[TSDB_MSG_TYPE_TABLE_META] = queryBuildTableMetaReqMsg;
queryBuildMsg[TSDB_MSG_TYPE_USE_DB] = queryBuildUseDbMsg; queryBuildMsg[TSDB_MSG_TYPE_USE_DB] = queryBuildUseDbMsg;
queryProcessMsgRsp[TSDB_MSG_TYPE_TABLE_META] = queryProcessTableMetaRsp; queryProcessMsgRsp[TSDB_MSG_TYPE_TABLE_META] = queryProcessTableMetaRsp;
queryProcessMsgRsp[TSDB_MSG_TYPE_USE_DB] = queryProcessUseDBRsp; queryProcessMsgRsp[TSDB_MSG_TYPE_USE_DB] = queryProcessUseDBRsp;
/*
tscBuildMsg[TSDB_SQL_SELECT] = tscBuildQueryMsg;
tscBuildMsg[TSDB_SQL_INSERT] = tscBuildSubmitMsg;
tscBuildMsg[TSDB_SQL_FETCH] = tscBuildFetchMsg;
tscBuildMsg[TSDB_SQL_CREATE_DB] = tscBuildCreateDbMsg;
tscBuildMsg[TSDB_SQL_CREATE_USER] = tscBuildUserMsg;
tscBuildMsg[TSDB_SQL_CREATE_FUNCTION] = tscBuildCreateFuncMsg;
tscBuildMsg[TSDB_SQL_CREATE_ACCT] = tscBuildAcctMsg;
tscBuildMsg[TSDB_SQL_ALTER_ACCT] = tscBuildAcctMsg;
tscBuildMsg[TSDB_SQL_CREATE_TABLE] = tscBuildCreateTableMsg;
tscBuildMsg[TSDB_SQL_DROP_USER] = tscBuildDropUserAcctMsg;
tscBuildMsg[TSDB_SQL_DROP_ACCT] = tscBuildDropUserAcctMsg;
tscBuildMsg[TSDB_SQL_DROP_DB] = tscBuildDropDbMsg;
tscBuildMsg[TSDB_SQL_DROP_FUNCTION] = tscBuildDropFuncMsg;
tscBuildMsg[TSDB_SQL_SYNC_DB_REPLICA] = tscBuildSyncDbReplicaMsg;
tscBuildMsg[TSDB_SQL_DROP_TABLE] = tscBuildDropTableMsg;
tscBuildMsg[TSDB_SQL_ALTER_USER] = tscBuildUserMsg;
tscBuildMsg[TSDB_SQL_CREATE_DNODE] = tscBuildCreateDnodeMsg;
tscBuildMsg[TSDB_SQL_DROP_DNODE] = tscBuildDropDnodeMsg;
tscBuildMsg[TSDB_SQL_CFG_DNODE] = tscBuildCfgDnodeMsg;
tscBuildMsg[TSDB_SQL_ALTER_TABLE] = tscBuildAlterTableMsg;
tscBuildMsg[TSDB_SQL_UPDATE_TAG_VAL] = tscBuildUpdateTagMsg;
tscBuildMsg[TSDB_SQL_ALTER_DB] = tscAlterDbMsg;
tscBuildMsg[TSDB_SQL_COMPACT_VNODE] = tscBuildCompactMsg;
tscBuildMsg[TSDB_SQL_CONNECT] = tscBuildConnectMsg;
tscBuildMsg[TSDB_SQL_USE_DB] = tscBuildUseDbMsg;
tscBuildMsg[TSDB_SQL_STABLEVGROUP] = tscBuildSTableVgroupMsg;
tscBuildMsg[TSDB_SQL_RETRIEVE_FUNC] = tscBuildRetrieveFuncMsg;
tscBuildMsg[TSDB_SQL_HB] = tscBuildHeartBeatMsg;
tscBuildMsg[TSDB_SQL_SHOW] = tscBuildShowMsg;
tscBuildMsg[TSDB_SQL_RETRIEVE_MNODE] = tscBuildRetrieveFromMgmtMsg;
tscBuildMsg[TSDB_SQL_KILL_QUERY] = tscBuildKillMsg;
tscBuildMsg[TSDB_SQL_KILL_STREAM] = tscBuildKillMsg;
tscBuildMsg[TSDB_SQL_KILL_CONNECTION] = tscBuildKillMsg;
tscProcessMsgRsp[TSDB_SQL_SELECT] = tscProcessQueryRsp;
tscProcessMsgRsp[TSDB_SQL_FETCH] = tscProcessRetrieveRspFromNode;
tscProcessMsgRsp[TSDB_SQL_DROP_DB] = tscProcessDropDbRsp;
tscProcessMsgRsp[TSDB_SQL_DROP_TABLE] = tscProcessDropTableRsp;
tscProcessMsgRsp[TSDB_SQL_CONNECT] = tscProcessConnectRsp;
tscProcessMsgRsp[TSDB_SQL_USE_DB] = tscProcessUseDbRsp;
tscProcessMsgRsp[TSDB_SQL_META] = tscProcessTableMetaRsp;
tscProcessMsgRsp[TSDB_SQL_STABLEVGROUP] = tscProcessSTableVgroupRsp;
tscProcessMsgRsp[TSDB_SQL_MULTI_META] = tscProcessMultiTableMetaRsp;
tscProcessMsgRsp[TSDB_SQL_RETRIEVE_FUNC] = tscProcessRetrieveFuncRsp;
tscProcessMsgRsp[TSDB_SQL_SHOW] = tscProcessShowRsp;
tscProcessMsgRsp[TSDB_SQL_RETRIEVE_MNODE] = tscProcessRetrieveRspFromNode; // rsp handled by same function.
tscProcessMsgRsp[TSDB_SQL_DESCRIBE_TABLE] = tscProcessDescribeTableRsp;
tscProcessMsgRsp[TSDB_SQL_CURRENT_DB] = tscProcessLocalRetrieveRsp;
tscProcessMsgRsp[TSDB_SQL_CURRENT_USER] = tscProcessLocalRetrieveRsp;
tscProcessMsgRsp[TSDB_SQL_SERV_VERSION] = tscProcessLocalRetrieveRsp;
tscProcessMsgRsp[TSDB_SQL_CLI_VERSION] = tscProcessLocalRetrieveRsp;
tscProcessMsgRsp[TSDB_SQL_SERV_STATUS] = tscProcessLocalRetrieveRsp;
tscProcessMsgRsp[TSDB_SQL_RETRIEVE_EMPTY_RESULT] = tscProcessEmptyResultRsp;
tscProcessMsgRsp[TSDB_SQL_RETRIEVE_GLOBALMERGE] = tscProcessRetrieveGlobalMergeRsp;
tscProcessMsgRsp[TSDB_SQL_ALTER_TABLE] = tscProcessAlterTableMsgRsp;
tscProcessMsgRsp[TSDB_SQL_ALTER_DB] = tscProcessAlterDbMsgRsp;
tscProcessMsgRsp[TSDB_SQL_COMPACT_VNODE] = tscProcessCompactRsp;
tscProcessMsgRsp[TSDB_SQL_SHOW_CREATE_TABLE] = tscProcessShowCreateRsp;
tscProcessMsgRsp[TSDB_SQL_SHOW_CREATE_STABLE] = tscProcessShowCreateRsp;
tscProcessMsgRsp[TSDB_SQL_SHOW_CREATE_DATABASE] = tscProcessShowCreateRsp;
*/
} }
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
extern "C" { extern "C" {
#endif #endif
#include "tlockfree.h"
#define QWORKER_DEFAULT_SCHEDULER_NUMBER 10000 #define QWORKER_DEFAULT_SCHEDULER_NUMBER 10000
#define QWORKER_DEFAULT_RES_CACHE_NUMBER 10000 #define QWORKER_DEFAULT_RES_CACHE_NUMBER 10000
#define QWORKER_DEFAULT_SCH_TASK_NUMBER 10000 #define QWORKER_DEFAULT_SCH_TASK_NUMBER 10000
...@@ -30,36 +32,63 @@ enum { ...@@ -30,36 +32,63 @@ enum {
QW_READY_RESPONSED, QW_READY_RESPONSED,
}; };
enum {
QW_TASK_INFO_STATUS = 1,
QW_TASK_INFO_READY,
};
enum {
QW_READ = 1,
QW_WRITE,
};
typedef struct SQWorkerTaskStatus { typedef struct SQWorkerTaskStatus {
SRWLatch lock;
int32_t code;
int8_t status; int8_t status;
int8_t ready; int8_t ready;
bool cancel;
bool drop;
} SQWorkerTaskStatus; } SQWorkerTaskStatus;
typedef struct SQWorkerResCache { typedef struct SQWorkerResCache {
SRWLatch lock;
void *data; void *data;
} SQWorkerResCache; } SQWorkerResCache;
typedef struct SQWorkerSchTaskStatus { typedef struct SQWorkerSchStatus {
int32_t lastAccessTs; // timestamp in second int32_t lastAccessTs; // timestamp in second
SHashObj *taskStatus; // key:queryId+taskId, value: SQWorkerTaskStatus SRWLatch tasksLock;
} SQWorkerSchTaskStatus; SHashObj *tasksHash; // key:queryId+taskId, value: SQWorkerTaskStatus
} SQWorkerSchStatus;
// Qnode/Vnode level task management // Qnode/Vnode level task management
typedef struct SQWorkerMgmt { typedef struct SQWorkerMgmt {
SQWorkerCfg cfg; SQWorkerCfg cfg;
SHashObj *scheduleHash; //key: schedulerId, value: SQWorkerSchTaskStatus SRWLatch schLock;
SRWLatch resLock;
SHashObj *schHash; //key: schedulerId, value: SQWorkerSchStatus
SHashObj *resHash; //key: queryId+taskId, value: SQWorkerResCache SHashObj *resHash; //key: queryId+taskId, value: SQWorkerResCache
} SQWorkerMgmt; } SQWorkerMgmt;
#define QW_TASK_DONE(status) (status == JOB_TASK_STATUS_SUCCEED || status == JOB_TASK_STATUS_FAILED || status == status == JOB_TASK_STATUS_CANCELLED) #define QW_GOT_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_ALREADY_EXIST(code) (TSDB_CODE_QRY_TASK_ALREADY_EXIST == (code))
#define QW_TASK_READY_RESP(status) (status == JOB_TASK_STATUS_SUCCEED || status == JOB_TASK_STATUS_FAILED || status == JOB_TASK_STATUS_CANCELLED || status == JOB_TASK_STATUS_PARTIAL_SUCCEED)
#define QW_SET_QTID(id, qid, tid) do { *(uint64_t *)(id) = (qid); *(uint64_t *)((char *)(id) + sizeof(qid)) = (tid); } while (0) #define QW_SET_QTID(id, qid, tid) do { *(uint64_t *)(id) = (qid); *(uint64_t *)((char *)(id) + sizeof(qid)) = (tid); } while (0)
#define QW_GET_QTID(id, qid, tid) do { (qid) = *(uint64_t *)(id); (tid) = *(uint64_t *)((char *)(id) + sizeof(qid)); } while (0) #define QW_GET_QTID(id, qid, tid) do { (qid) = *(uint64_t *)(id); (tid) = *(uint64_t *)((char *)(id) + sizeof(qid)); } while (0)
#define QW_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0) #define QW_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0)
#define QW_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0) #define QW_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { 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_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_UNLOCK(type, _lock) (QW_READ == (type) ? taosRUnLockLatch(_lock) : taosWUnLockLatch(_lock))
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -4,69 +4,79 @@ ...@@ -4,69 +4,79 @@
#include "qworkerInt.h" #include "qworkerInt.h"
#include "planner.h" #include "planner.h"
int32_t qwAddTaskStatus(SQWorkerMgmt *mgmt, uint64_t schedulerId, uint64_t queryId, uint64_t taskId, int8_t taskStatus) { int32_t qwCheckStatusSwitch(int8_t oriStatus, int8_t newStatus) {
SQWorkerTaskStatus tStatus = {0}; int32_t code = 0;
tStatus.status = taskStatus;
char id[sizeof(queryId) + sizeof(taskId)] = {0}; if (oriStatus == newStatus) {
QW_SET_QTID(id, queryId, taskId); if (newStatus == JOB_TASK_STATUS_CANCELLING) {
return TSDB_CODE_SUCCESS;
}
SQWorkerSchTaskStatus *schStatus = taosHashGet(mgmt->scheduleHash, &schedulerId, sizeof(schedulerId)); QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
if (NULL == schStatus) {
SQWorkerSchTaskStatus newSchStatus = {0};
newSchStatus.taskStatus = taosHashInit(mgmt->cfg.maxSchTaskNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK);
if (NULL == newSchStatus.taskStatus) {
qError("taosHashInit %d failed", mgmt->cfg.maxSchTaskNum);
return TSDB_CODE_QRY_OUT_OF_MEMORY;
} }
if (0 != taosHashPut(newSchStatus.taskStatus, id, sizeof(id), &tStatus, sizeof(tStatus))) { switch (oriStatus) {
qError("taosHashPut schedulerId[%"PRIx64"]queryId[%"PRIx64"] taskId[%"PRIx64"] to scheduleHash failed", schedulerId, queryId, taskId); case JOB_TASK_STATUS_NULL:
taosHashCleanup(newSchStatus.taskStatus); if (newStatus != JOB_TASK_STATUS_EXECUTING && newStatus != JOB_TASK_STATUS_FAILED ) {
return TSDB_CODE_QRY_APP_ERROR; QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
} }
newSchStatus.lastAccessTs = taosGetTimestampSec(); break;
case JOB_TASK_STATUS_NOT_START:
if (newStatus != JOB_TASK_STATUS_EXECUTING && newStatus != JOB_TASK_STATUS_FAILED) {
QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
}
if (0 != taosHashPut(mgmt->scheduleHash, &schedulerId, sizeof(schedulerId), &newSchStatus, sizeof(newSchStatus))) { break;
qError("taosHashPut schedulerId[%"PRIx64"] to scheduleHash failed", schedulerId); case JOB_TASK_STATUS_EXECUTING:
taosHashCleanup(newSchStatus.taskStatus); if (newStatus != JOB_TASK_STATUS_SUCCEED && newStatus != JOB_TASK_STATUS_FAILED && newStatus != JOB_TASK_STATUS_CANCELLING) {
return TSDB_CODE_QRY_APP_ERROR; QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
} }
return TSDB_CODE_SUCCESS; break;
case JOB_TASK_STATUS_PARTIAL_SUCCEED:
if (newStatus != JOB_TASK_STATUS_EXECUTING && newStatus != JOB_TASK_STATUS_CANCELLING) {
QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
} }
schStatus->lastAccessTs = taosGetTimestampSec(); break;
case JOB_TASK_STATUS_SUCCEED:
case JOB_TASK_STATUS_FAILED:
case JOB_TASK_STATUS_CANCELLING:
if (newStatus != JOB_TASK_STATUS_CANCELLED) {
QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
}
if (0 != taosHashPut(schStatus->taskStatus, id, sizeof(id), &tStatus, sizeof(tStatus))) { break;
qError("taosHashPut schedulerId[%"PRIx64"]queryId[%"PRIx64"] taskId[%"PRIx64"] to scheduleHash failed", schedulerId, queryId, taskId); case JOB_TASK_STATUS_CANCELLED:
default:
qError("invalid task status:%d", oriStatus);
return TSDB_CODE_QRY_APP_ERROR; return TSDB_CODE_QRY_APP_ERROR;
} }
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
}
int32_t qwGetTaskStatus(SQWorkerMgmt *mgmt, uint64_t schedulerId, uint64_t queryId, uint64_t taskId, SQWorkerTaskStatus **taskStatus) { _return:
SQWorkerSchTaskStatus *schStatus = taosHashGet(mgmt->scheduleHash, &schedulerId, sizeof(schedulerId));
if (NULL == schStatus) {
qError("no scheduler for schedulerId[%"PRIx64"]", schedulerId);
return TSDB_CODE_QRY_APP_ERROR;
}
schStatus->lastAccessTs = taosGetTimestampSec(); qError("invalid task status:%d", oriStatus);
QW_ERR_RET(code);
}
char id[sizeof(queryId) + sizeof(taskId)] = {0}; int32_t qwUpdateTaskInfo(SQWorkerTaskStatus *task, int8_t type, void *data) {
QW_SET_QTID(id, queryId, taskId); int32_t code = 0;
SQWorkerTaskStatus *tStatus = taosHashGet(schStatus->taskStatus, id, sizeof(id)); switch (type) {
if (NULL == tStatus) { case QW_TASK_INFO_STATUS: {
qError("no task status for schedulerId[%"PRIx64"] queryId[%"PRIx64"] taskId[%"PRIx64"]", schedulerId, queryId, taskId); int8_t newStatus = *(int8_t *)data;
QW_ERR_RET(qwCheckStatusSwitch(task->status, newStatus));
task->status = newStatus;
break;
}
default:
qError("uknown task info type:%d", type);
return TSDB_CODE_QRY_APP_ERROR; return TSDB_CODE_QRY_APP_ERROR;
} }
*taskStatus = tStatus;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
...@@ -77,11 +87,15 @@ int32_t qwAddTaskResult(SQWorkerMgmt *mgmt, uint64_t queryId, uint64_t taskId, v ...@@ -77,11 +87,15 @@ int32_t qwAddTaskResult(SQWorkerMgmt *mgmt, uint64_t queryId, uint64_t taskId, v
SQWorkerResCache resCache = {0}; SQWorkerResCache resCache = {0};
resCache.data = data; resCache.data = data;
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);
qError("taosHashPut queryId[%"PRIx64"] taskId[%"PRIx64"] to resHash failed", queryId, taskId); qError("taosHashPut queryId[%"PRIx64"] taskId[%"PRIx64"] to resHash failed", queryId, taskId);
return TSDB_CODE_QRY_APP_ERROR; return TSDB_CODE_QRY_APP_ERROR;
} }
QW_UNLOCK(QW_WRITE, &mgmt->resLock);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
...@@ -101,39 +115,157 @@ int32_t qwGetTaskResult(SQWorkerMgmt *mgmt, uint64_t queryId, uint64_t taskId, v ...@@ -101,39 +115,157 @@ int32_t qwGetTaskResult(SQWorkerMgmt *mgmt, uint64_t queryId, uint64_t taskId, v
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t qwUpdateSchLastAccess(SQWorkerMgmt *mgmt, uint64_t schedulerId) {
SQWorkerSchTaskStatus *schStatus = taosHashGet(mgmt->scheduleHash, &schedulerId, sizeof(schedulerId)); static FORCE_INLINE int32_t qwAcquireScheduler(int32_t rwType, SQWorkerMgmt *mgmt, uint64_t schedulerId, SQWorkerSchStatus **sch) {
if (NULL == schStatus) { QW_LOCK(rwType, &mgmt->schLock);
qError("no scheduler for schedulerId[%"PRIx64"]", schedulerId); *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);
if (NULL == newSch.tasksHash) {
qError("taosHashInit %d failed", mgmt->cfg.maxSchTaskNum);
return TSDB_CODE_QRY_OUT_OF_MEMORY;
}
while (true) {
QW_LOCK(QW_WRITE, &mgmt->schLock);
int32_t code = taosHashPut(mgmt->schHash, &schedulerId, sizeof(schedulerId), &newSch, sizeof(newSch));
if (0 != code) {
if (!HASH_NODE_EXIST(code)) {
QW_UNLOCK(QW_WRITE, &mgmt->schLock);
qError("taosHashPut schedulerId[%"PRIx64"] to scheduleHash failed", schedulerId);
taosHashCleanup(newSch.tasksHash);
return TSDB_CODE_QRY_APP_ERROR; return TSDB_CODE_QRY_APP_ERROR;
} }
}
schStatus->lastAccessTs = taosGetTimestampSec(); QW_UNLOCK(QW_WRITE, &mgmt->schLock);
if (TSDB_CODE_SUCCESS == qwAcquireScheduler(rwType, mgmt, schedulerId, sch)) {
taosHashCleanup(newSch.tasksHash);
return TSDB_CODE_SUCCESS;
}
}
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t qwGetSchTasksStatus(SQWorkerMgmt *mgmt, uint64_t schedulerId, SSchedulerStatusRsp **rsp) {
SQWorkerSchTaskStatus *schStatus = taosHashGet(mgmt->scheduleHash, &schedulerId, sizeof(schedulerId)); static FORCE_INLINE void qwReleaseScheduler(int32_t rwType, SQWorkerMgmt *mgmt) {
if (NULL == schStatus) { QW_UNLOCK(rwType, &mgmt->schLock);
qError("no scheduler for schedulerId[%"PRIx64"]", schedulerId); }
static FORCE_INLINE int32_t qwAcquireTask(int32_t rwType, SQWorkerSchStatus *sch, uint64_t queryId, uint64_t taskId, SQWorkerTaskStatus **task) {
char id[sizeof(queryId) + sizeof(taskId)] = {0};
QW_SET_QTID(id, queryId, taskId);
QW_LOCK(rwType, &sch->tasksLock);
*task = taosHashGet(sch->tasksHash, id, sizeof(id));
if (NULL == (*task)) {
QW_UNLOCK(rwType, &sch->tasksLock);
return TSDB_CODE_QRY_TASK_NOT_EXIST;
}
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) {
char id[sizeof(queryId) + sizeof(taskId)] = {0};
QW_SET_QTID(id, queryId, taskId);
while (true) {
*inserted = false;
QW_LOCK(QW_WRITE, &sch->tasksLock);
int32_t code = taosHashPut(sch->tasksHash, id, sizeof(id), &status, sizeof(status));
if (0 != code) {
QW_UNLOCK(QW_WRITE, &sch->tasksLock);
if (HASH_NODE_EXIST(code)) {
if (qwAcquireTask(rwType, sch, queryId, taskId, task)) {
continue;
}
break;
} else {
qError("taosHashPut queryId[%"PRIx64"] taskId[%"PRIx64"] to scheduleHash failed", queryId, taskId);
return TSDB_CODE_QRY_APP_ERROR; return TSDB_CODE_QRY_APP_ERROR;
} }
}
QW_UNLOCK(QW_WRITE, &sch->tasksLock);
*inserted = true;
if (TSDB_CODE_SUCCESS == qwAcquireTask(rwType, sch, queryId, taskId, task)) {
return TSDB_CODE_SUCCESS;
}
}
return TSDB_CODE_SUCCESS;
}
static FORCE_INLINE void qwReleaseTask(int32_t rwType, SQWorkerSchStatus *sch) {
QW_UNLOCK(rwType, &sch->tasksLock);
}
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};
QW_SET_QTID(id, queryId, taskId);
QW_LOCK(rwType, &mgmt->resLock);
*res = taosHashGet(mgmt->resHash, id, sizeof(id));
if (NULL == (*res)) {
QW_UNLOCK(rwType, &mgmt->resLock);
return TSDB_CODE_QRY_RES_CACHE_NOT_EXIST;
}
return TSDB_CODE_SUCCESS;
}
static FORCE_INLINE void qwReleaseTaskResCache(int32_t rwType, SQWorkerMgmt *mgmt) {
QW_UNLOCK(rwType, &mgmt->resLock);
}
int32_t qwGetSchTasksStatus(SQWorkerMgmt *mgmt, uint64_t schedulerId, SSchedulerStatusRsp **rsp) {
SQWorkerSchStatus *schStatus = NULL;
int32_t taskNum = 0;
if (qwAcquireScheduler(QW_READ, mgmt, schedulerId, &schStatus)) {
qWarn("no scheduler for schedulerId[%"PRIx64"]", schedulerId);
} else {
schStatus->lastAccessTs = taosGetTimestampSec(); schStatus->lastAccessTs = taosGetTimestampSec();
int32_t i = 0; QW_LOCK(QW_READ, &schStatus->tasksLock);
int32_t taskNum = taosHashGetSize(schStatus->taskStatus); taskNum = taosHashGetSize(schStatus->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, &schStatus->tasksLock);
qwReleaseScheduler(QW_READ, mgmt);
}
return TSDB_CODE_QRY_OUT_OF_MEMORY; return TSDB_CODE_QRY_OUT_OF_MEMORY;
} }
void *key = NULL; void *key = NULL;
size_t keyLen = 0; size_t keyLen = 0;
void *pIter = taosHashIterate(schStatus->taskStatus, NULL); int32_t i = 0;
if (schStatus) {
void *pIter = taosHashIterate(schStatus->tasksHash, NULL);
while (pIter) { while (pIter) {
SQWorkerTaskStatus *taskStatus = (SQWorkerTaskStatus *)pIter; SQWorkerTaskStatus *taskStatus = (SQWorkerTaskStatus *)pIter;
taosHashGetKey(pIter, &key, &keyLen); taosHashGetKey(pIter, &key, &keyLen);
...@@ -141,7 +273,13 @@ int32_t qwGetSchTasksStatus(SQWorkerMgmt *mgmt, uint64_t schedulerId, SScheduler ...@@ -141,7 +273,13 @@ int32_t qwGetSchTasksStatus(SQWorkerMgmt *mgmt, uint64_t schedulerId, SScheduler
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->taskStatus, pIter); pIter = taosHashIterate(schStatus->tasksHash, pIter);
}
}
if (schStatus) {
QW_UNLOCK(QW_READ, &schStatus->tasksLock);
qwReleaseScheduler(QW_READ, mgmt);
} }
(*rsp)->num = taskNum; (*rsp)->num = taskNum;
...@@ -149,14 +287,622 @@ int32_t qwGetSchTasksStatus(SQWorkerMgmt *mgmt, uint64_t schedulerId, SScheduler ...@@ -149,14 +287,622 @@ int32_t qwGetSchTasksStatus(SQWorkerMgmt *mgmt, uint64_t schedulerId, SScheduler
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t qwBuildRspMsg(void *data, int32_t msgType);
int32_t qwUpdateSchLastAccess(SQWorkerMgmt *mgmt, uint64_t schedulerId) {
SQWorkerSchStatus *schStatus = NULL;
QW_ERR_RET(qwAcquireScheduler(QW_READ, mgmt, schedulerId, &schStatus));
schStatus->lastAccessTs = taosGetTimestampSec();
qwReleaseScheduler(QW_READ, mgmt);
return TSDB_CODE_SUCCESS;
}
int32_t qwGetTaskStatus(SQWorkerMgmt *mgmt, uint64_t schedulerId, uint64_t queryId, uint64_t taskId, int8_t *taskStatus) {
SQWorkerSchStatus *sch = NULL;
SQWorkerTaskStatus *task = NULL;
int32_t code = 0;
QW_ERR_RET(qwAcquireScheduler(QW_READ, mgmt, schedulerId, &sch));
QW_ERR_JRET(qwAcquireTask(QW_READ, sch, queryId, taskId, &task));
*taskStatus = task->status;
_return:
if (task) {
qwReleaseTask(QW_READ, sch);
}
if (sch) {
qwReleaseScheduler(QW_READ, mgmt);
}
QW_RET(code);
}
int32_t qwSwitchTaskStatus(SQWorkerMgmt *mgmt, uint64_t schedulerId, uint64_t queryId, uint64_t taskId, int8_t taskStatus) {
SQWorkerSchStatus *sch = NULL;
SQWorkerTaskStatus *task = NULL;
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 (qwAcquireTask(QW_READ, sch, queryId, taskId, &task)) {
if (qwCheckStatusSwitch(JOB_TASK_STATUS_NOT_START, taskStatus)) {
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));
if (inserted) {
qwReleaseTask(QW_READ, sch);
qwReleaseScheduler(QW_READ, mgmt);
return TSDB_CODE_SUCCESS;
}
QW_LOCK(QW_WRITE, &task->lock);
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);
qwReleaseScheduler(QW_READ, mgmt);
QW_RET(code);
}
int32_t qwCancelTask(SQWorkerMgmt *mgmt, uint64_t schedulerId, uint64_t queryId, uint64_t taskId) {
SQWorkerSchStatus *sch = NULL;
SQWorkerTaskStatus *task = NULL;
int32_t code = 0;
if (TSDB_CODE_SUCCESS != qwAcquireScheduler(QW_READ, mgmt, schedulerId, &sch)) {
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)) {
code = qwSwitchTaskStatus(mgmt, schedulerId, queryId, taskId, JOB_TASK_STATUS_NOT_START);
if (code) {
qwReleaseScheduler(QW_READ, mgmt);
QW_ERR_RET(code);
}
QW_ERR_JRET(qwAcquireTask(QW_READ, sch, queryId, taskId, &task));
}
QW_LOCK(QW_WRITE, &task->lock);
task->cancel = true;
int8_t oriStatus = task->status;
int8_t newStatus = 0;
if (task->status == JOB_TASK_STATUS_CANCELLED || task->status == JOB_TASK_STATUS_NOT_START || task->status == JOB_TASK_STATUS_CANCELLING || task->status == JOB_TASK_STATUS_DROPPING) {
QW_UNLOCK(QW_WRITE, &task->lock);
qwReleaseTask(QW_READ, sch);
qwReleaseScheduler(QW_READ, mgmt);
return TSDB_CODE_SUCCESS;
} else if (task->status == JOB_TASK_STATUS_FAILED || task->status == JOB_TASK_STATUS_SUCCEED || task->status == JOB_TASK_STATUS_PARTIAL_SUCCEED) {
newStatus = JOB_TASK_STATUS_CANCELLED;
QW_ERR_JRET(qwUpdateTaskInfo(task, QW_TASK_INFO_STATUS, &newStatus));
} else {
newStatus = JOB_TASK_STATUS_CANCELLING;
QW_ERR_JRET(qwUpdateTaskInfo(task, QW_TASK_INFO_STATUS, &newStatus));
}
QW_UNLOCK(QW_WRITE, &task->lock);
qwReleaseTask(QW_READ, sch);
qwReleaseScheduler(QW_READ, mgmt);
if (oriStatus == JOB_TASK_STATUS_EXECUTING) {
//TODO call executer to cancel subquery async
}
return TSDB_CODE_SUCCESS;
_return:
if (task) {
QW_UNLOCK(QW_WRITE, &task->lock);
qwReleaseTask(QW_READ, sch);
}
if (sch) {
qwReleaseScheduler(QW_READ, mgmt);
}
QW_RET(code);
}
int32_t qwDropTask(SQWorkerMgmt *mgmt, uint64_t schedulerId, uint64_t queryId, uint64_t taskId) {
SQWorkerSchStatus *sch = NULL;
SQWorkerTaskStatus *task = NULL;
int32_t code = 0;
char id[sizeof(queryId) + sizeof(taskId)] = {0};
QW_SET_QTID(id, queryId, taskId);
QW_LOCK(QW_WRITE, &mgmt->resLock);
if (mgmt->resHash) {
taosHashRemove(mgmt->resHash, id, sizeof(id));
}
QW_UNLOCK(QW_WRITE, &mgmt->resLock);
if (TSDB_CODE_SUCCESS != qwAcquireScheduler(QW_WRITE, mgmt, schedulerId, &sch)) {
qWarn("scheduler %"PRIx64" doesn't exist", schedulerId);
return TSDB_CODE_SUCCESS;
}
if (qwAcquireTask(QW_WRITE, sch, queryId, taskId, &task)) {
qwReleaseScheduler(QW_WRITE, mgmt);
qWarn("scheduler %"PRIx64" queryId %"PRIx64" taskId:%"PRIx64" doesn't exist", schedulerId, queryId, taskId);
return TSDB_CODE_SUCCESS;
}
taosHashRemove(sch->tasksHash, id, sizeof(id));
qwReleaseTask(QW_WRITE, sch);
qwReleaseScheduler(QW_WRITE, mgmt);
return TSDB_CODE_SUCCESS;
}
int32_t qwCancelDropTask(SQWorkerMgmt *mgmt, uint64_t schedulerId, uint64_t queryId, uint64_t taskId) {
SQWorkerSchStatus *sch = NULL;
SQWorkerTaskStatus *task = NULL;
int32_t code = 0;
if (TSDB_CODE_SUCCESS != qwAcquireScheduler(QW_READ, mgmt, schedulerId, &sch)) {
qWarn("scheduler %"PRIx64" doesn't exist", schedulerId);
return TSDB_CODE_SUCCESS;
}
if (qwAcquireTask(QW_READ, sch, queryId, taskId, &task)) {
qwReleaseScheduler(QW_READ, mgmt);
qWarn("scheduler %"PRIx64" queryId %"PRIx64" taskId:%"PRIx64" doesn't exist", schedulerId, queryId, taskId);
return TSDB_CODE_SUCCESS;
}
QW_LOCK(QW_WRITE, &task->lock);
task->drop = true;
int8_t oriStatus = task->status;
int8_t newStatus = 0;
if (task->status == JOB_TASK_STATUS_EXECUTING) {
newStatus = JOB_TASK_STATUS_CANCELLING;
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) {
QW_UNLOCK(QW_WRITE, &task->lock);
qwReleaseTask(QW_READ, sch);
qwReleaseScheduler(QW_READ, mgmt);
return TSDB_CODE_SUCCESS;
} else {
QW_UNLOCK(QW_WRITE, &task->lock);
qwReleaseTask(QW_READ, sch);
qwReleaseScheduler(QW_READ, mgmt);
QW_ERR_RET(qwDropTask(mgmt, schedulerId, queryId, taskId));
return TSDB_CODE_SUCCESS;
}
QW_UNLOCK(QW_WRITE, &task->lock);
qwReleaseTask(QW_READ, sch);
qwReleaseScheduler(QW_READ, mgmt);
if (oriStatus == JOB_TASK_STATUS_EXECUTING) {
//TODO call executer to cancel subquery async
}
return TSDB_CODE_SUCCESS;
_return:
if (task) {
QW_UNLOCK(QW_WRITE, &task->lock);
qwReleaseTask(QW_READ, sch);
}
if (sch) {
qwReleaseScheduler(QW_READ, mgmt);
}
QW_RET(code);
}
int32_t qwBuildAndSendQueryRsp(SRpcMsg *pMsg, int32_t code) {
SQueryTableRsp *pRsp = (SQueryTableRsp *)rpcMallocCont(sizeof(SQueryTableRsp));
pRsp->code = code;
SRpcMsg rpcRsp = {
.handle = pMsg->handle,
.ahandle = pMsg->ahandle,
.pCont = pRsp,
.contLen = sizeof(*pRsp),
.code = code,
};
rpcSendResponse(&rpcRsp);
return TSDB_CODE_SUCCESS;
}
int32_t qwBuildAndSendReadyRsp(SRpcMsg *pMsg, int32_t code) {
SResReadyRsp *pRsp = (SResReadyRsp *)rpcMallocCont(sizeof(SResReadyRsp));
pRsp->code = code;
SRpcMsg rpcRsp = {
.handle = pMsg->handle,
.ahandle = pMsg->ahandle,
.pCont = pRsp,
.contLen = sizeof(*pRsp),
.code = code,
};
rpcSendResponse(&rpcRsp);
return TSDB_CODE_SUCCESS;
}
int32_t qwBuildAndSendStatusRsp(SRpcMsg *pMsg, SSchedulerStatusRsp *sStatus) {
int32_t size = 0;
if (sStatus) {
size = sizeof(SSchedulerStatusRsp) + sizeof(sStatus->status[0]) * sStatus->num;
} else {
size = sizeof(SSchedulerStatusRsp);
}
SSchedulerStatusRsp *pRsp = (SSchedulerStatusRsp *)rpcMallocCont(size);
if (sStatus) {
memcpy(pRsp, sStatus, size);
} else {
pRsp->num = 0;
}
SRpcMsg rpcRsp = {
.handle = pMsg->handle,
.ahandle = pMsg->ahandle,
.pCont = pRsp,
.contLen = size,
.code = 0,
};
rpcSendResponse(&rpcRsp);
return TSDB_CODE_SUCCESS;
}
int32_t qwBuildAndSendFetchRsp(SRpcMsg *pMsg, void *data) {
SRetrieveTableRsp *pRsp = (SRetrieveTableRsp *)rpcMallocCont(sizeof(SRetrieveTableRsp));
memset(pRsp, 0, sizeof(SRetrieveTableRsp));
//TODO fill msg
pRsp->completed = true;
SRpcMsg rpcRsp = {
.handle = pMsg->handle,
.ahandle = pMsg->ahandle,
.pCont = pRsp,
.contLen = sizeof(*pRsp),
.code = 0,
};
rpcSendResponse(&rpcRsp);
return TSDB_CODE_SUCCESS;
}
int32_t qwBuildAndSendCancelRsp(SRpcMsg *pMsg, int32_t code) {
STaskCancelRsp *pRsp = (STaskCancelRsp *)rpcMallocCont(sizeof(STaskCancelRsp));
pRsp->code = code;
SRpcMsg rpcRsp = {
.handle = pMsg->handle,
.ahandle = pMsg->ahandle,
.pCont = pRsp,
.contLen = sizeof(*pRsp),
.code = code,
};
rpcSendResponse(&rpcRsp);
return TSDB_CODE_SUCCESS;
}
int32_t qwBuildAndSendDropRsp(SRpcMsg *pMsg, int32_t code) {
STaskDropRsp *pRsp = (STaskDropRsp *)rpcMallocCont(sizeof(STaskDropRsp));
pRsp->code = code;
SRpcMsg rpcRsp = {
.handle = pMsg->handle,
.ahandle = pMsg->ahandle,
.pCont = pRsp,
.contLen = sizeof(*pRsp),
.code = code,
};
rpcSendResponse(&rpcRsp);
return TSDB_CODE_SUCCESS;
}
int32_t qwCheckAndSendReadyRsp(SQWorkerMgmt *mgmt, uint64_t schedulerId, uint64_t queryId, uint64_t taskId, SRpcMsg *pMsg, int32_t rspCode) {
SQWorkerSchStatus *sch = NULL;
SQWorkerTaskStatus *task = NULL;
int32_t code = 0;
QW_ERR_RET(qwAcquireScheduler(QW_READ, mgmt, schedulerId, &sch));
QW_ERR_JRET(qwAcquireTask(QW_READ, sch, queryId, taskId, &task));
QW_LOCK(QW_WRITE, &task->lock);
if (QW_READY_NOT_RECEIVED == task->ready) {
QW_UNLOCK(QW_WRITE, &task->lock);
qwReleaseTask(QW_READ, sch);
qwReleaseScheduler(QW_READ, mgmt);
return TSDB_CODE_SUCCESS;
} else if (QW_READY_RECEIVED == task->ready) {
QW_ERR_JRET(qwBuildAndSendReadyRsp(pMsg, rspCode));
task->ready = QW_READY_RESPONSED;
} else if (QW_READY_RESPONSED == task->ready) {
qError("query response already send");
QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
} else {
assert(0);
}
_return:
if (task) {
QW_UNLOCK(QW_WRITE, &task->lock);
}
if (sch) {
qwReleaseTask(QW_READ, sch);
}
qwReleaseScheduler(QW_READ, mgmt);
QW_RET(code);
}
int32_t qwSetAndSendReadyRsp(SQWorkerMgmt *mgmt, uint64_t schedulerId, uint64_t queryId, uint64_t taskId, SRpcMsg *pMsg) {
SQWorkerSchStatus *sch = NULL;
SQWorkerTaskStatus *task = NULL;
int32_t code = 0;
QW_ERR_RET(qwAcquireScheduler(QW_READ, mgmt, schedulerId, &sch));
QW_ERR_JRET(qwAcquireTask(QW_READ, sch, queryId, taskId, &task));
QW_LOCK(QW_WRITE, &task->lock);
if (QW_TASK_READY_RESP(task->status)) {
QW_ERR_JRET(qwBuildAndSendReadyRsp(pMsg, task->code));
task->ready = QW_READY_RESPONSED;
} else {
task->ready = QW_READY_RECEIVED;
QW_UNLOCK(QW_WRITE, &task->lock);
qwReleaseTask(QW_READ, sch);
qwReleaseScheduler(QW_READ, mgmt);
return TSDB_CODE_SUCCESS;
}
_return:
if (task) {
QW_UNLOCK(QW_WRITE, &task->lock);
}
if (sch) {
qwReleaseTask(QW_READ, sch);
}
qwReleaseScheduler(QW_READ, mgmt);
QW_RET(code);
}
int32_t qwCheckTaskCancelDrop( SQWorkerMgmt *mgmt, uint64_t schedulerId, uint64_t queryId, uint64_t taskId, bool *needStop) {
SQWorkerSchStatus *sch = NULL;
SQWorkerTaskStatus *task = NULL;
int32_t code = 0;
int8_t status = JOB_TASK_STATUS_CANCELLED;
*needStop = false;
if (qwAcquireScheduler(QW_READ, mgmt, schedulerId, &sch)) {
return TSDB_CODE_SUCCESS;
}
if (qwAcquireTask(QW_READ, sch, queryId, taskId, &task)) {
qwReleaseScheduler(QW_READ, mgmt);
return TSDB_CODE_SUCCESS;
}
QW_LOCK(QW_READ, &task->lock);
if ((!task->cancel) && (!task->drop)) {
QW_UNLOCK(QW_READ, &task->lock);
qwReleaseTask(QW_READ, sch);
qwReleaseScheduler(QW_READ, mgmt);
return TSDB_CODE_SUCCESS;
}
QW_UNLOCK(QW_READ, &task->lock);
*needStop = true;
if (task->cancel) {
QW_LOCK(QW_WRITE, &task->lock);
qwUpdateTaskInfo(task, QW_TASK_INFO_STATUS, &status);
QW_UNLOCK(QW_WRITE, &task->lock);
} else if (task->drop) {
qwReleaseTask(QW_READ, sch);
qwReleaseScheduler(QW_READ, mgmt);
qwDropTask(mgmt, schedulerId, queryId, taskId);
}
return TSDB_CODE_SUCCESS;
}
int32_t qwHandleFetch(SQWorkerResCache *res, SQWorkerMgmt *mgmt, uint64_t schedulerId, uint64_t queryId, uint64_t taskId, SRpcMsg *pMsg) {
SQWorkerSchStatus *sch = NULL;
SQWorkerTaskStatus *task = NULL;
int32_t code = 0;
int32_t needRsp = true;
void *data = NULL;
QW_ERR_JRET(qwAcquireScheduler(QW_READ, mgmt, schedulerId, &sch));
QW_ERR_JRET(qwAcquireTask(QW_READ, sch, queryId, taskId, &task));
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) {
qError("invalid status %d for fetch", task->status);
QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
}
if (QW_GOT_RES_DATA(res->data)) {
data = res->data;
if (QW_LOW_RES_DATA(res->data)) {
if (task->status == JOB_TASK_STATUS_PARTIAL_SUCCEED) {
//TODO add query back to queue
}
}
} else {
if (task->status != JOB_TASK_STATUS_EXECUTING) {
qError("invalid status %d for fetch without res", task->status);
QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
}
//TODO SET FLAG FOR QUERY TO SEND RSP WHEN RES READY
needRsp = false;
}
_return:
if (task) {
QW_UNLOCK(QW_READ, &task->lock);
}
if (sch) {
qwReleaseTask(QW_READ, sch);
qwReleaseScheduler(QW_READ, mgmt);
}
if (needRsp) {
qwBuildAndSendFetchRsp(pMsg, res->data);
}
QW_RET(code);
}
int32_t qwQueryPostProcess(SQWorkerMgmt *mgmt, uint64_t schedulerId, uint64_t queryId, uint64_t taskId, int8_t status, int32_t errCode) {
SQWorkerSchStatus *sch = NULL;
SQWorkerTaskStatus *task = NULL;
int32_t code = 0;
int8_t newStatus = JOB_TASK_STATUS_CANCELLED;
code = qwAcquireScheduler(QW_READ, mgmt, schedulerId, &sch);
if (code) {
qError("schedulerId:%"PRIx64" not in cache", schedulerId);
QW_ERR_RET(code);
}
code = qwAcquireTask(QW_READ, sch, queryId, taskId, &task);
if (code) {
qwReleaseScheduler(QW_READ, mgmt);
qError("schedulerId:%"PRIx64" queryId:%"PRIx64" taskId:%"PRIx64" not in cache", schedulerId, queryId, taskId);
QW_ERR_RET(code);
}
if (task->cancel) {
QW_LOCK(QW_WRITE, &task->lock);
qwUpdateTaskInfo(task, QW_TASK_INFO_STATUS, &newStatus);
QW_UNLOCK(QW_WRITE, &task->lock);
} else if (task->drop) {
qwReleaseTask(QW_READ, sch);
qwReleaseScheduler(QW_READ, mgmt);
qwDropTask(mgmt, schedulerId, queryId, taskId);
return TSDB_CODE_SUCCESS;
} else {
QW_LOCK(QW_WRITE, &task->lock);
qwUpdateTaskInfo(task, QW_TASK_INFO_STATUS, &status);
task->code = errCode;
QW_UNLOCK(QW_WRITE, &task->lock);
}
qwReleaseTask(QW_READ, sch);
qwReleaseScheduler(QW_READ, mgmt);
return TSDB_CODE_SUCCESS;
}
int32_t qWorkerInit(SQWorkerCfg *cfg, void **qWorkerMgmt) { int32_t qWorkerInit(SQWorkerCfg *cfg, void **qWorkerMgmt) {
SQWorkerMgmt *mgmt = calloc(1, sizeof(SQWorkerMgmt)); SQWorkerMgmt *mgmt = calloc(1, sizeof(SQWorkerMgmt));
if (NULL == mgmt) { if (NULL == mgmt) {
qError("calloc %d failed", (int32_t)sizeof(SQWorkerMgmt)); qError("calloc %d failed", (int32_t)sizeof(SQWorkerMgmt));
return TSDB_CODE_QRY_OUT_OF_MEMORY; QW_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
} }
if (cfg) { if (cfg) {
...@@ -167,16 +913,16 @@ int32_t qWorkerInit(SQWorkerCfg *cfg, void **qWorkerMgmt) { ...@@ -167,16 +913,16 @@ int32_t qWorkerInit(SQWorkerCfg *cfg, void **qWorkerMgmt) {
mgmt->cfg.maxSchTaskNum = QWORKER_DEFAULT_SCH_TASK_NUMBER; mgmt->cfg.maxSchTaskNum = QWORKER_DEFAULT_SCH_TASK_NUMBER;
} }
mgmt->scheduleHash = taosHashInit(mgmt->cfg.maxSchedulerNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false, HASH_ENTRY_LOCK); mgmt->schHash = taosHashInit(mgmt->cfg.maxSchedulerNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false, HASH_NO_LOCK);
if (NULL == mgmt->scheduleHash) { if (NULL == mgmt->schHash) {
tfree(mgmt); tfree(mgmt);
QW_ERR_LRET(TSDB_CODE_QRY_OUT_OF_MEMORY, "init %d schduler hash failed", mgmt->cfg.maxSchedulerNum); QW_ERR_LRET(TSDB_CODE_QRY_OUT_OF_MEMORY, "init %d schduler hash failed", mgmt->cfg.maxSchedulerNum);
} }
mgmt->resHash = taosHashInit(mgmt->cfg.maxResCacheNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK); mgmt->resHash = taosHashInit(mgmt->cfg.maxResCacheNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
if (NULL == mgmt->resHash) { if (NULL == mgmt->resHash) {
taosHashCleanup(mgmt->scheduleHash); taosHashCleanup(mgmt->schHash);
mgmt->scheduleHash = NULL; mgmt->schHash = NULL;
tfree(mgmt); tfree(mgmt);
QW_ERR_LRET(TSDB_CODE_QRY_OUT_OF_MEMORY, "init %d res cache hash failed", mgmt->cfg.maxResCacheNum); QW_ERR_LRET(TSDB_CODE_QRY_OUT_OF_MEMORY, "init %d res cache hash failed", mgmt->cfg.maxResCacheNum);
...@@ -187,99 +933,193 @@ int32_t qWorkerInit(SQWorkerCfg *cfg, void **qWorkerMgmt) { ...@@ -187,99 +933,193 @@ int32_t qWorkerInit(SQWorkerCfg *cfg, void **qWorkerMgmt) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t qWorkerProcessQueryMsg(void *qWorkerMgmt, SSchedulerQueryMsg *msg, SRpcMsg *rsp) { int32_t qWorkerProcessQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) {
if (NULL == qWorkerMgmt || NULL == msg || NULL == rsp) { if (NULL == node || NULL == qWorkerMgmt || NULL == pMsg) {
return TSDB_CODE_QRY_INVALID_INPUT; QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
} }
SSubQueryMsg *msg = pMsg->pCont;
if (NULL == msg || pMsg->contLen <= sizeof(*msg)) {
qError("invalid query msg");
QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
}
bool queryDone = false;
bool queryRsp = false;
bool needStop = false;
SSubplan *plan = NULL; SSubplan *plan = NULL;
SQWorkerTaskStatus *tStatus = NULL; int32_t code = 0;
int32_t code = qStringToSubplan(msg->msg, &plan); QW_ERR_JRET(qwCheckTaskCancelDrop(qWorkerMgmt, msg->schedulerId, msg->queryId, msg->taskId, &needStop));
if (needStop) {
qWarn("task need stop");
QW_ERR_JRET(TSDB_CODE_QRY_TASK_CANCELLED);
}
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->schedulerId, msg->queryId, msg->taskId, code);
return code; QW_ERR_JRET(code);
} }
//TODO call executer to init subquery
code = 0; // return error directly
//TODO call executer to init subquery //TODO call executer to init subquery
QW_ERR_JRET(qwAddTaskStatus(qWorkerMgmt, msg->schedulerId, msg->queryId, msg->taskId, JOB_TASK_STATUS_EXECUTING)); if (code) {
QW_ERR_JRET(code);
} else {
QW_ERR_JRET(qwSwitchTaskStatus(qWorkerMgmt, msg->schedulerId, msg->queryId, msg->taskId, JOB_TASK_STATUS_EXECUTING));
}
QW_ERR_JRET(qwBuildRspMsg(NULL, TSDB_MSG_TYPE_QUERY_RSP)); QW_ERR_JRET(qwBuildAndSendQueryRsp(pMsg, TSDB_CODE_SUCCESS));
queryRsp = true;
//TODO call executer to execute subquery //TODO call executer to execute subquery
code = 0; code = 0;
void *data = NULL; void *data = NULL;
queryDone = false;
//TODO call executer to execute subquery //TODO call executer to execute subquery
QW_ERR_JRET(qwGetTaskStatus(qWorkerMgmt, msg->schedulerId, msg->queryId, msg->taskId, &tStatus)); if (code) {
QW_ERR_JRET(code);
tStatus->status = (code) ? JOB_TASK_STATUS_FAILED : JOB_TASK_STATUS_SUCCEED; } else {
QW_ERR_JRET(qwAddTaskResult(qWorkerMgmt, msg->queryId, msg->taskId, data)); QW_ERR_JRET(qwAddTaskResult(qWorkerMgmt, msg->queryId, msg->taskId, data));
QW_ERR_JRET(qwSwitchTaskStatus(qWorkerMgmt, msg->schedulerId, msg->queryId, msg->taskId, JOB_TASK_STATUS_PARTIAL_SUCCEED));
}
_return: _return:
if (tStatus && QW_TASK_DONE(tStatus->status) && QW_READY_RECEIVED == tStatus->ready) { if (queryRsp) {
QW_ERR_RET(qwBuildRspMsg(NULL, TSDB_MSG_TYPE_RES_READY_RSP)); code = qwCheckAndSendReadyRsp(qWorkerMgmt, msg->schedulerId, msg->queryId, msg->taskId, pMsg, code);
} else {
code = qwBuildAndSendQueryRsp(pMsg, code);
} }
qDestroySubplan(plan); int8_t status = 0;
if (TSDB_CODE_SUCCESS != code || queryDone) {
if (code) {
status = JOB_TASK_STATUS_FAILED; //TODO set CANCELLED from code
} else {
status = JOB_TASK_STATUS_SUCCEED;
}
return code; qwQueryPostProcess(qWorkerMgmt, msg->schedulerId, msg->queryId, msg->taskId, status, code);
}
QW_RET(code);
} }
int32_t qWorkerProcessReadyMsg(void *qWorkerMgmt, SSchedulerReadyMsg *msg, SRpcMsg *rsp){ int32_t qWorkerProcessReadyMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg){
if (NULL == qWorkerMgmt || NULL == msg || NULL == rsp) { if (NULL == node || NULL == qWorkerMgmt || NULL == pMsg) {
return TSDB_CODE_QRY_INVALID_INPUT; return TSDB_CODE_QRY_INVALID_INPUT;
} }
SQWorkerTaskStatus *tStatus = NULL; SResReadyMsg *msg = pMsg->pCont;
if (NULL == msg || pMsg->contLen <= sizeof(*msg)) {
QW_ERR_RET(qwGetTaskStatus(qWorkerMgmt, msg->schedulerId, msg->queryId, msg->taskId, &tStatus)); qError("invalid task status msg");
QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
if (QW_TASK_DONE(tStatus->status)) {
QW_ERR_RET(qwBuildRspMsg(tStatus, TSDB_MSG_TYPE_RES_READY_RSP));
} else {
tStatus->ready = QW_READY_RECEIVED;
return TSDB_CODE_SUCCESS;
} }
tStatus->ready = QW_READY_RESPONSED; QW_ERR_RET(qwSetAndSendReadyRsp(qWorkerMgmt, msg->schedulerId, msg->queryId, msg->taskId, pMsg));
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t qWorkerProcessStatusMsg(void *qWorkerMgmt, SSchedulerStatusMsg *msg, SRpcMsg *rsp) { int32_t qWorkerProcessStatusMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) {
if (NULL == qWorkerMgmt || NULL == msg || NULL == rsp) { if (NULL == node || NULL == qWorkerMgmt || NULL == pMsg) {
return TSDB_CODE_QRY_INVALID_INPUT; return TSDB_CODE_QRY_INVALID_INPUT;
} }
int32_t code = 0;
SSchTasksStatusMsg *msg = pMsg->pCont;
if (NULL == msg || pMsg->contLen <= sizeof(*msg)) {
qError("invalid task status msg");
QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
}
SSchedulerStatusRsp *sStatus = NULL; SSchedulerStatusRsp *sStatus = NULL;
QW_ERR_RET(qwGetSchTasksStatus(qWorkerMgmt, msg->schedulerId, &sStatus)); QW_ERR_JRET(qwGetSchTasksStatus(qWorkerMgmt, msg->schedulerId, &sStatus));
_return:
QW_ERR_RET(qwBuildAndSendStatusRsp(pMsg, sStatus));
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t qWorkerProcessFetchMsg(void *qWorkerMgmt, SSchedulerFetchMsg *msg, SRpcMsg *rsp) { int32_t qWorkerProcessFetchMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) {
if (NULL == qWorkerMgmt || NULL == msg || NULL == rsp) { if (NULL == node || NULL == qWorkerMgmt || NULL == pMsg) {
return TSDB_CODE_QRY_INVALID_INPUT; return TSDB_CODE_QRY_INVALID_INPUT;
} }
SResFetchMsg *msg = pMsg->pCont;
if (NULL == msg || pMsg->contLen <= sizeof(*msg)) {
QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
}
QW_ERR_RET(qwUpdateSchLastAccess(qWorkerMgmt, msg->schedulerId)); QW_ERR_RET(qwUpdateSchLastAccess(qWorkerMgmt, msg->schedulerId));
void *data = NULL; void *data = NULL;
SQWorkerResCache *res = NULL;
int32_t code = 0;
QW_ERR_RET(qwGetTaskResult(qWorkerMgmt, msg->queryId, msg->taskId, &data)); 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));
_return:
qwReleaseTaskResCache(QW_READ, qWorkerMgmt);
QW_RET(code);
}
int32_t qWorkerProcessCancelMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) {
if (NULL == node || NULL == qWorkerMgmt || NULL == pMsg) {
return TSDB_CODE_QRY_INVALID_INPUT;
}
int32_t code = 0;
STaskCancelMsg *msg = pMsg->pCont;
if (NULL == msg || pMsg->contLen <= sizeof(*msg)) {
qError("invalid task cancel msg");
QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
}
QW_ERR_JRET(qwCancelTask(qWorkerMgmt, msg->schedulerId, msg->queryId, msg->taskId));
_return:
QW_ERR_RET(qwBuildAndSendCancelRsp(pMsg, code));
return TSDB_CODE_SUCCESS;
}
int32_t qWorkerProcessDropMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) {
if (NULL == node || NULL == qWorkerMgmt || NULL == pMsg) {
return TSDB_CODE_QRY_INVALID_INPUT;
}
int32_t code = 0;
STaskDropMsg *msg = pMsg->pCont;
if (NULL == msg || pMsg->contLen <= sizeof(*msg)) {
qError("invalid task drop msg");
QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
}
QW_ERR_JRET(qwCancelDropTask(qWorkerMgmt, msg->schedulerId, msg->queryId, msg->taskId));
_return:
QW_ERR_RET(qwBuildRspMsg(data, TSDB_MSG_TYPE_FETCH_RSP)); QW_ERR_RET(qwBuildAndSendDropRsp(pMsg, code));
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t qWorkerProcessCancelMsg(void *qWorkerMgmt, SSchedulerCancelMsg *msg, SRpcMsg *rsp);
void qWorkerDestroy(void **qWorkerMgmt) { void qWorkerDestroy(void **qWorkerMgmt) {
if (NULL == qWorkerMgmt || NULL == *qWorkerMgmt) { if (NULL == qWorkerMgmt || NULL == *qWorkerMgmt) {
......
...@@ -31,17 +31,35 @@ extern "C" { ...@@ -31,17 +31,35 @@ extern "C" {
#define SCH_MAX_CONDIDATE_EP_NUM TSDB_MAX_REPLICA #define SCH_MAX_CONDIDATE_EP_NUM TSDB_MAX_REPLICA
enum {
SCH_READ = 1,
SCH_WRITE,
};
typedef struct SSchedulerMgmt { typedef struct SSchedulerMgmt {
uint64_t taskId; uint64_t taskId;
uint64_t schedulerId; uint64_t schedulerId;
SSchedulerCfg cfg; SSchedulerCfg cfg;
SHashObj *Jobs; // key: queryId, value: SQueryJob* SHashObj *jobs; // key: queryId, value: SQueryJob*
} SSchedulerMgmt; } SSchedulerMgmt;
typedef struct SQueryLevel {
int32_t level;
int8_t status;
SRWLatch lock;
int32_t taskFailed;
int32_t taskSucceed;
int32_t taskNum;
SArray *subTasks; // Element is SQueryTask
} SQueryLevel;
typedef struct SQueryTask { typedef struct SQueryTask {
uint64_t taskId; // task id uint64_t taskId; // task id
SQueryLevel *level; // level
SSubplan *plan; // subplan SSubplan *plan; // subplan
char *msg; // operator tree char *msg; // operator tree
int32_t msgLen; // msg length
int8_t status; // task status int8_t status; // task status
SEpAddr execAddr; // task actual executed node address SEpAddr execAddr; // task actual executed node address
SQueryProfileSummary summary; // task execution summary SQueryProfileSummary summary; // task execution summary
...@@ -50,13 +68,6 @@ typedef struct SQueryTask { ...@@ -50,13 +68,6 @@ typedef struct SQueryTask {
SArray *parents; // the data destination tasks, get data from current task, element is SQueryTask* SArray *parents; // the data destination tasks, get data from current task, element is SQueryTask*
} SQueryTask; } SQueryTask;
typedef struct SQueryLevel {
int32_t level;
int8_t status;
int32_t taskNum;
SArray *subTasks; // Element is SQueryTask
} SQueryLevel;
typedef struct SQueryJob { typedef struct SQueryJob {
uint64_t queryId; uint64_t queryId;
int32_t levelNum; int32_t levelNum;
...@@ -74,6 +85,7 @@ typedef struct SQueryJob { ...@@ -74,6 +85,7 @@ typedef struct SQueryJob {
SHashObj *execTasks; // executing tasks, key:taskid, value:SQueryTask* SHashObj *execTasks; // executing tasks, key:taskid, value:SQueryTask*
SHashObj *succTasks; // succeed tasks, key:taskid, value:SQueryTask* SHashObj *succTasks; // succeed tasks, key:taskid, value:SQueryTask*
SHashObj *failTasks; // failed tasks, key:taskid, value:SQueryTask*
SArray *levels; // Element is SQueryLevel, starting from 0. SArray *levels; // Element is SQueryLevel, starting from 0.
SArray *subPlans; // Element is SArray*, and nested element is SSubplan. The execution level of subplan, starting from 0. SArray *subPlans; // Element is SArray*, and nested element is SSubplan. The execution level of subplan, starting from 0.
...@@ -81,7 +93,8 @@ typedef struct SQueryJob { ...@@ -81,7 +93,8 @@ typedef struct SQueryJob {
#define SCH_HAS_QNODE_IN_CLUSTER(type) (false) //TODO CLUSTER TYPE #define SCH_HAS_QNODE_IN_CLUSTER(type) (false) //TODO CLUSTER TYPE
#define SCH_TASK_READY_TO_LUNCH(task) ((task)->childReady >= taosArrayGetSize((task)->children)) // MAY NEED TO ENHANCE #define SCH_TASK_READY_TO_LUNCH(task) ((task)->childReady >= taosArrayGetSize((task)->children)) // MAY NEED TO ENHANCE
#define SCH_IS_DATA_SRC_TASK(task) (task->plan->type == QUERY_TYPE_SCAN) #define SCH_IS_DATA_SRC_TASK(task) ((task)->plan->type == QUERY_TYPE_SCAN)
#define SCH_TASK_NEED_WAIT_ALL(task) ((task)->plan->type == QUERY_TYPE_MODIFY)
#define SCH_JOB_ERR_LOG(param, ...) qError("QID:%"PRIx64 param, job->queryId, __VA_ARGS__) #define SCH_JOB_ERR_LOG(param, ...) qError("QID:%"PRIx64 param, job->queryId, __VA_ARGS__)
#define SCH_TASK_ERR_LOG(param, ...) qError("QID:%"PRIx64",TID:%"PRIx64 param, job->queryId, task->taskId, __VA_ARGS__) #define SCH_TASK_ERR_LOG(param, ...) qError("QID:%"PRIx64",TID:%"PRIx64 param, job->queryId, task->taskId, __VA_ARGS__)
...@@ -91,6 +104,9 @@ typedef struct SQueryJob { ...@@ -91,6 +104,9 @@ typedef struct SQueryJob {
#define SCH_ERR_LRET(c,...) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { qError(__VA_ARGS__); terrno = _code; return _code; } } while (0) #define SCH_ERR_LRET(c,...) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { qError(__VA_ARGS__); terrno = _code; return _code; } } while (0)
#define SCH_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0) #define SCH_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0)
#define SCH_LOCK(type, _lock) (SCH_READ == (type) ? taosRLockLatch(_lock) : taosWLockLatch(_lock))
#define SCH_UNLOCK(type, _lock) (SCH_READ == (type) ? taosRUnLockLatch(_lock) : taosWUnLockLatch(_lock))
extern int32_t schLaunchTask(SQueryJob *job, SQueryTask *task); extern int32_t schLaunchTask(SQueryJob *job, SQueryTask *task);
......
...@@ -160,11 +160,19 @@ int32_t schValidateAndBuildJob(SQueryDag *dag, SQueryJob *job) { ...@@ -160,11 +160,19 @@ int32_t schValidateAndBuildJob(SQueryDag *dag, SQueryJob *job) {
SQueryLevel level = {0}; SQueryLevel level = {0};
SArray *levelPlans = NULL; SArray *levelPlans = NULL;
int32_t levelPlanNum = 0; int32_t levelPlanNum = 0;
SQueryLevel *pLevel = NULL;
level.status = JOB_TASK_STATUS_NOT_START; level.status = JOB_TASK_STATUS_NOT_START;
for (int32_t i = 0; i < levelNum; ++i) { for (int32_t i = 0; i < levelNum; ++i) {
level.level = i; if (NULL == taosArrayPush(job->levels, &level)) {
qError("taosArrayPush failed");
SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
}
pLevel = taosArrayGet(job->levels, i);
pLevel->level = i;
levelPlans = taosArrayGetP(dag->pSubplans, i); levelPlans = taosArrayGetP(dag->pSubplans, i);
if (NULL == levelPlans) { if (NULL == levelPlans) {
qError("no level plans for level %d", i); qError("no level plans for level %d", i);
...@@ -177,10 +185,10 @@ int32_t schValidateAndBuildJob(SQueryDag *dag, SQueryJob *job) { ...@@ -177,10 +185,10 @@ int32_t schValidateAndBuildJob(SQueryDag *dag, SQueryJob *job) {
SCH_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT); SCH_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT);
} }
level.taskNum = levelPlanNum; pLevel->taskNum = levelPlanNum;
level.subTasks = taosArrayInit(levelPlanNum, sizeof(SQueryTask)); pLevel->subTasks = taosArrayInit(levelPlanNum, sizeof(SQueryTask));
if (NULL == level.subTasks) { if (NULL == pLevel->subTasks) {
qError("taosArrayInit %d failed", levelPlanNum); qError("taosArrayInit %d failed", levelPlanNum);
SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
} }
...@@ -191,9 +199,10 @@ int32_t schValidateAndBuildJob(SQueryDag *dag, SQueryJob *job) { ...@@ -191,9 +199,10 @@ int32_t schValidateAndBuildJob(SQueryDag *dag, SQueryJob *job) {
task.taskId = atomic_add_fetch_64(&schMgmt.taskId, 1); task.taskId = atomic_add_fetch_64(&schMgmt.taskId, 1);
task.plan = plan; task.plan = plan;
task.level = pLevel;
task.status = JOB_TASK_STATUS_NOT_START; task.status = JOB_TASK_STATUS_NOT_START;
void *p = taosArrayPush(level.subTasks, &task); void *p = taosArrayPush(pLevel->subTasks, &task);
if (NULL == p) { if (NULL == p) {
qError("taosArrayPush failed"); qError("taosArrayPush failed");
SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
...@@ -205,10 +214,6 @@ int32_t schValidateAndBuildJob(SQueryDag *dag, SQueryJob *job) { ...@@ -205,10 +214,6 @@ int32_t schValidateAndBuildJob(SQueryDag *dag, SQueryJob *job) {
} }
} }
if (NULL == taosArrayPush(job->levels, &level)) {
qError("taosArrayPush failed");
SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
}
} }
SCH_ERR_JRET(schBuildTaskRalation(job, planToTask)); SCH_ERR_JRET(schBuildTaskRalation(job, planToTask));
...@@ -220,8 +225,8 @@ int32_t schValidateAndBuildJob(SQueryDag *dag, SQueryJob *job) { ...@@ -220,8 +225,8 @@ int32_t schValidateAndBuildJob(SQueryDag *dag, SQueryJob *job) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
_return: _return:
if (level.subTasks) { if (pLevel->subTasks) {
taosArrayDestroy(level.subTasks); taosArrayDestroy(pLevel->subTasks);
} }
if (planToTask) { if (planToTask) {
...@@ -273,7 +278,23 @@ int32_t schMoveTaskToSuccList(SQueryJob *job, SQueryTask *task, bool *moved) { ...@@ -273,7 +278,23 @@ int32_t schMoveTaskToSuccList(SQueryJob *job, SQueryTask *task, bool *moved) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
if (0 != taosHashPut(job->execTasks, &task->taskId, sizeof(task->taskId), &task, POINTER_BYTES)) { if (0 != taosHashPut(job->succTasks, &task->taskId, sizeof(task->taskId), &task, POINTER_BYTES)) {
qError("taosHashPut failed");
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
}
*moved = true;
return TSDB_CODE_SUCCESS;
}
int32_t schMoveTaskToFailList(SQueryJob *job, SQueryTask *task, bool *moved) {
if (0 != taosHashRemove(job->execTasks, &task->taskId, sizeof(task->taskId))) {
qWarn("remove task[%"PRIx64"] from execTasks failed", task->taskId);
return TSDB_CODE_SUCCESS;
}
if (0 != taosHashPut(job->failTasks, &task->taskId, sizeof(task->taskId), &task, POINTER_BYTES)) {
qError("taosHashPut failed"); qError("taosHashPut failed");
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
} }
...@@ -289,51 +310,76 @@ int32_t schAsyncSendMsg(SQueryJob *job, SQueryTask *task, int32_t msgType) { ...@@ -289,51 +310,76 @@ int32_t schAsyncSendMsg(SQueryJob *job, SQueryTask *task, int32_t msgType) {
void *msg = NULL; void *msg = NULL;
switch (msgType) { switch (msgType) {
case TSDB_MSG_TYPE_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 TSDB_MSG_TYPE_QUERY: { case TSDB_MSG_TYPE_QUERY: {
if (NULL == task->msg) { if (NULL == task->msg) {
qError("query msg is NULL"); qError("query msg is NULL");
SCH_ERR_RET(TSDB_CODE_SCH_INTERNAL_ERROR); SCH_ERR_RET(TSDB_CODE_SCH_INTERNAL_ERROR);
} }
int32_t len = strlen(task->msg); msgSize = sizeof(SSubQueryMsg) + task->msgLen;
msgSize = sizeof(SSchedulerQueryMsg) + len;
msg = calloc(1, msgSize); msg = calloc(1, msgSize);
if (NULL == msg) { if (NULL == msg) {
qError("calloc %d failed", msgSize); qError("calloc %d failed", msgSize);
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
} }
SSchedulerQueryMsg *pMsg = msg; SSubQueryMsg *pMsg = msg;
pMsg->schedulerId = htobe64(schMgmt.schedulerId); pMsg->schedulerId = htobe64(schMgmt.schedulerId);
pMsg->queryId = htobe64(job->queryId); pMsg->queryId = htobe64(job->queryId);
pMsg->taskId = htobe64(task->taskId); pMsg->taskId = htobe64(task->taskId);
pMsg->contentLen = htonl(len); pMsg->contentLen = htonl(task->msgLen);
memcpy(pMsg->msg, task->msg, len); memcpy(pMsg->msg, task->msg, task->msgLen);
break; break;
} }
case TSDB_MSG_TYPE_RES_READY: { case TSDB_MSG_TYPE_RES_READY: {
msgSize = sizeof(SSchedulerReadyMsg); msgSize = sizeof(SResReadyMsg);
msg = calloc(1, msgSize); msg = calloc(1, msgSize);
if (NULL == msg) { if (NULL == msg) {
qError("calloc %d failed", msgSize); qError("calloc %d failed", msgSize);
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
} }
SSchedulerReadyMsg *pMsg = msg; SResReadyMsg *pMsg = msg;
pMsg->schedulerId = htobe64(schMgmt.schedulerId);
pMsg->queryId = htobe64(job->queryId); pMsg->queryId = htobe64(job->queryId);
pMsg->taskId = htobe64(task->taskId); pMsg->taskId = htobe64(task->taskId);
break; break;
} }
case TSDB_MSG_TYPE_FETCH: { case TSDB_MSG_TYPE_FETCH: {
msgSize = sizeof(SSchedulerFetchMsg); 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 TSDB_MSG_TYPE_DROP_TASK:{
msgSize = sizeof(STaskDropMsg);
msg = calloc(1, msgSize); msg = calloc(1, msgSize);
if (NULL == msg) { if (NULL == msg) {
qError("calloc %d failed", msgSize); qError("calloc %d failed", msgSize);
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
} }
SSchedulerFetchMsg *pMsg = msg; STaskDropMsg *pMsg = msg;
pMsg->schedulerId = htobe64(schMgmt.schedulerId);
pMsg->queryId = htobe64(job->queryId); pMsg->queryId = htobe64(job->queryId);
pMsg->taskId = htobe64(task->taskId); pMsg->taskId = htobe64(task->taskId);
break; break;
...@@ -344,6 +390,7 @@ int32_t schAsyncSendMsg(SQueryJob *job, SQueryTask *task, int32_t msgType) { ...@@ -344,6 +390,7 @@ int32_t schAsyncSendMsg(SQueryJob *job, SQueryTask *task, int32_t msgType) {
} }
//TODO SEND MSG //TODO SEND MSG
//taosAsyncExec(rpcSendRequest(void * shandle, const SEpSet * pEpSet, SRpcMsg * pMsg, int64_t * pRid), p, &code);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
...@@ -424,8 +471,29 @@ int32_t schProcessOnTaskSuccess(SQueryJob *job, SQueryTask *task) { ...@@ -424,8 +471,29 @@ int32_t schProcessOnTaskSuccess(SQueryJob *job, SQueryTask *task) {
SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
} }
int32_t taskDone = 0;
if (SCH_TASK_NEED_WAIT_ALL(task)) {
SCH_LOCK(SCH_WRITE, &task->level->lock);
task->level->taskFailed++;
taskDone = task->level->taskSucceed + task->level->taskFailed;
SCH_UNLOCK(SCH_WRITE, &task->level->lock);
if (taskDone < task->level->taskNum) {
qDebug("wait all tasks, done:%d, all:%d", taskDone, task->level->taskNum);
return TSDB_CODE_SUCCESS;
}
if (task->level->taskFailed > 0) {
job->status = JOB_TASK_STATUS_FAILED;
SCH_ERR_RET(schProcessOnJobFailure(job));
return TSDB_CODE_SUCCESS;
}
} else {
strncpy(job->resEp.fqdn, task->execAddr.fqdn, sizeof(job->resEp.fqdn)); strncpy(job->resEp.fqdn, task->execAddr.fqdn, sizeof(job->resEp.fqdn));
job->resEp.port = task->execAddr.port; job->resEp.port = task->execAddr.port;
}
SCH_ERR_RET(schProcessOnJobSuccess(job)); SCH_ERR_RET(schProcessOnJobSuccess(job));
...@@ -456,11 +524,31 @@ int32_t schProcessOnTaskSuccess(SQueryJob *job, SQueryTask *task) { ...@@ -456,11 +524,31 @@ int32_t schProcessOnTaskSuccess(SQueryJob *job, SQueryTask *task) {
int32_t schProcessOnTaskFailure(SQueryJob *job, SQueryTask *task, int32_t errCode) { int32_t schProcessOnTaskFailure(SQueryJob *job, SQueryTask *task, int32_t errCode) {
bool needRetry = false; bool needRetry = false;
bool moved = false;
int32_t taskDone = 0;
SCH_ERR_RET(schTaskCheckAndSetRetry(job, task, errCode, &needRetry)); SCH_ERR_RET(schTaskCheckAndSetRetry(job, task, errCode, &needRetry));
if (!needRetry) { if (!needRetry) {
SCH_TASK_ERR_LOG("task failed[%x], no more retry", errCode); SCH_TASK_ERR_LOG("task failed[%x], no more retry", errCode);
SCH_ERR_RET(schMoveTaskToFailList(job, task, &moved));
if (!moved) {
SCH_TASK_ERR_LOG("task may already moved, status:%d", task->status);
return TSDB_CODE_SUCCESS;
}
if (SCH_TASK_NEED_WAIT_ALL(task)) {
SCH_LOCK(SCH_WRITE, &task->level->lock);
task->level->taskFailed++;
taskDone = task->level->taskSucceed + task->level->taskFailed;
SCH_UNLOCK(SCH_WRITE, &task->level->lock);
if (taskDone < task->level->taskNum) {
qDebug("wait all tasks, done:%d, all:%d", taskDone, task->level->taskNum);
return TSDB_CODE_SUCCESS;
}
}
job->status = JOB_TASK_STATUS_FAILED; job->status = JOB_TASK_STATUS_FAILED;
SCH_ERR_RET(schProcessOnJobFailure(job)); SCH_ERR_RET(schProcessOnJobFailure(job));
...@@ -521,8 +609,7 @@ _return: ...@@ -521,8 +609,7 @@ _return:
int32_t schLaunchTask(SQueryJob *job, SQueryTask *task) { int32_t schLaunchTask(SQueryJob *job, SQueryTask *task) {
SSubplan *plan = task->plan; SSubplan *plan = task->plan;
SCH_ERR_RET(qSubPlanToString(plan, &task->msg, &task->msgLen));
SCH_ERR_RET(qSubPlanToString(plan, &task->msg));
if (plan->execEpSet.numOfEps <= 0) { if (plan->execEpSet.numOfEps <= 0) {
SCH_ERR_RET(schSetTaskExecEpSet(job, &plan->execEpSet)); SCH_ERR_RET(schSetTaskExecEpSet(job, &plan->execEpSet));
} }
...@@ -532,7 +619,9 @@ int32_t schLaunchTask(SQueryJob *job, SQueryTask *task) { ...@@ -532,7 +619,9 @@ int32_t schLaunchTask(SQueryJob *job, SQueryTask *task) {
SCH_ERR_RET(TSDB_CODE_SCH_INTERNAL_ERROR); SCH_ERR_RET(TSDB_CODE_SCH_INTERNAL_ERROR);
} }
SCH_ERR_RET(schAsyncSendMsg(job, task, TSDB_MSG_TYPE_QUERY)); int32_t msgType = (plan->type == QUERY_TYPE_MODIFY) ? TSDB_MSG_TYPE_SUBMIT : TSDB_MSG_TYPE_QUERY;
SCH_ERR_RET(schAsyncSendMsg(job, task, msgType));
SCH_ERR_RET(schPushTaskToExecList(job, task)); SCH_ERR_RET(schPushTaskToExecList(job, task));
...@@ -553,6 +642,25 @@ int32_t schLaunchJob(SQueryJob *job) { ...@@ -553,6 +642,25 @@ int32_t schLaunchJob(SQueryJob *job) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
void schDropJobAllTasks(SQueryJob *job) {
void *pIter = taosHashIterate(job->succTasks, NULL);
while (pIter) {
SQueryTask *task = *(SQueryTask **)pIter;
schAsyncSendMsg(job, task, TSDB_MSG_TYPE_DROP_TASK);
pIter = taosHashIterate(job->succTasks, pIter);
}
pIter = taosHashIterate(job->failTasks, NULL);
while (pIter) {
SQueryTask *task = *(SQueryTask **)pIter;
schAsyncSendMsg(job, task, TSDB_MSG_TYPE_DROP_TASK);
pIter = taosHashIterate(job->succTasks, pIter);
}
}
int32_t schedulerInit(SSchedulerCfg *cfg) { int32_t schedulerInit(SSchedulerCfg *cfg) {
if (cfg) { if (cfg) {
...@@ -561,8 +669,8 @@ int32_t schedulerInit(SSchedulerCfg *cfg) { ...@@ -561,8 +669,8 @@ int32_t schedulerInit(SSchedulerCfg *cfg) {
schMgmt.cfg.maxJobNum = SCHEDULE_DEFAULT_JOB_NUMBER; schMgmt.cfg.maxJobNum = SCHEDULE_DEFAULT_JOB_NUMBER;
} }
schMgmt.Jobs = taosHashInit(schMgmt.cfg.maxJobNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false, HASH_ENTRY_LOCK); schMgmt.jobs = taosHashInit(schMgmt.cfg.maxJobNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false, HASH_ENTRY_LOCK);
if (NULL == schMgmt.Jobs) { if (NULL == schMgmt.jobs) {
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);
} }
...@@ -604,9 +712,15 @@ int32_t scheduleExecJob(void *transport, SArray *qnodeList, SQueryDag* pDag, voi ...@@ -604,9 +712,15 @@ int32_t scheduleExecJob(void *transport, SArray *qnodeList, SQueryDag* pDag, voi
SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
} }
job->failTasks = taosHashInit(pDag->numOfSubplans, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false, HASH_ENTRY_LOCK);
if (NULL == job->failTasks) {
qError("taosHashInit %d failed", pDag->numOfSubplans);
SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
}
tsem_init(&job->rspSem, 0, 0); tsem_init(&job->rspSem, 0, 0);
if (0 != taosHashPut(schMgmt.Jobs, &job->queryId, sizeof(job->queryId), &job, POINTER_BYTES)) { if (0 != taosHashPut(schMgmt.jobs, &job->queryId, sizeof(job->queryId), &job, POINTER_BYTES)) {
qError("taosHashPut queryId:%"PRIx64" failed", job->queryId); qError("taosHashPut queryId:%"PRIx64" failed", job->queryId);
SCH_ERR_JRET(TSDB_CODE_SCH_INTERNAL_ERROR); SCH_ERR_JRET(TSDB_CODE_SCH_INTERNAL_ERROR);
} }
...@@ -658,6 +772,8 @@ _return: ...@@ -658,6 +772,8 @@ _return:
int32_t scheduleCancelJob(void *pJob) { int32_t scheduleCancelJob(void *pJob) {
//TODO //TODO
//TODO MOVE ALL TASKS FROM EXEC LIST TO FAIL LIST
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
...@@ -669,7 +785,7 @@ void scheduleFreeJob(void *pJob) { ...@@ -669,7 +785,7 @@ void scheduleFreeJob(void *pJob) {
SQueryJob *job = pJob; SQueryJob *job = pJob;
if (job->status > 0) { if (job->status > 0) {
if (0 != taosHashRemove(schMgmt.Jobs, &job->queryId, sizeof(job->queryId))) { if (0 != taosHashRemove(schMgmt.jobs, &job->queryId, sizeof(job->queryId))) {
qError("remove job:%"PRIx64"from mgmt failed", job->queryId); // maybe already freed qError("remove job:%"PRIx64"from mgmt failed", job->queryId); // maybe already freed
return; return;
} }
...@@ -677,15 +793,17 @@ void scheduleFreeJob(void *pJob) { ...@@ -677,15 +793,17 @@ void scheduleFreeJob(void *pJob) {
if (job->status == JOB_TASK_STATUS_EXECUTING) { if (job->status == JOB_TASK_STATUS_EXECUTING) {
scheduleCancelJob(pJob); scheduleCancelJob(pJob);
} }
schDropJobAllTasks(job);
} }
//TODO free job //TODO free job
} }
void schedulerDestroy(void) { void schedulerDestroy(void) {
if (schMgmt.Jobs) { if (schMgmt.jobs) {
taosHashCleanup(schMgmt.Jobs); //TODO taosHashCleanup(schMgmt.jobs); //TODO
schMgmt.Jobs = NULL; schMgmt.jobs = NULL;
} }
} }
......
...@@ -323,7 +323,10 @@ TAOS_DEFINE_ERROR(TSDB_CODE_QRY_INCONSISTAN, "File inconsistance in ...@@ -323,7 +323,10 @@ TAOS_DEFINE_ERROR(TSDB_CODE_QRY_INCONSISTAN, "File inconsistance in
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_INVALID_TIME_CONDITION, "One valid time range condition expected") TAOS_DEFINE_ERROR(TSDB_CODE_QRY_INVALID_TIME_CONDITION, "One valid time range condition expected")
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_SYS_ERROR, "System error") TAOS_DEFINE_ERROR(TSDB_CODE_QRY_SYS_ERROR, "System error")
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_INVALID_INPUT, "invalid input") TAOS_DEFINE_ERROR(TSDB_CODE_QRY_INVALID_INPUT, "invalid input")
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_SCH_NOT_EXIST, "Scheduler not exist")
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_TASK_NOT_EXIST, "Task not exist")
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_TASK_ALREADY_EXIST, "Task already exist")
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_RES_CACHE_NOT_EXIST, "Task result cache not exist")
// grant // grant
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_EXPIRED, "License expired") TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_EXPIRED, "License expired")
......
...@@ -291,7 +291,7 @@ int32_t taosHashPut(SHashObj *pHashObj, const void *key, size_t keyLen, void *da ...@@ -291,7 +291,7 @@ int32_t taosHashPut(SHashObj *pHashObj, const void *key, size_t keyLen, void *da
// enable resize // enable resize
__rd_unlock(&pHashObj->lock, pHashObj->type); __rd_unlock(&pHashObj->lock, pHashObj->type);
return pHashObj->enableUpdate ? 0 : -1; return pHashObj->enableUpdate ? 0 : -2;
} }
} }
......
...@@ -38,6 +38,7 @@ int32_t tWorkerInit(SWorkerPool *pool) { ...@@ -38,6 +38,7 @@ int32_t tWorkerInit(SWorkerPool *pool) {
void tWorkerCleanup(SWorkerPool *pool) { void tWorkerCleanup(SWorkerPool *pool) {
for (int i = 0; i < pool->max; ++i) { for (int i = 0; i < pool->max; ++i) {
SWorker *worker = pool->workers + i; SWorker *worker = pool->workers + i;
if (worker == NULL) continue;
if (taosCheckPthreadValid(worker->thread)) { if (taosCheckPthreadValid(worker->thread)) {
taosQsetThreadResume(pool->qset); taosQsetThreadResume(pool->qset);
} }
...@@ -45,6 +46,7 @@ void tWorkerCleanup(SWorkerPool *pool) { ...@@ -45,6 +46,7 @@ void tWorkerCleanup(SWorkerPool *pool) {
for (int i = 0; i < pool->max; ++i) { for (int i = 0; i < pool->max; ++i) {
SWorker *worker = pool->workers + i; SWorker *worker = pool->workers + i;
if (worker == NULL) continue;
if (taosCheckPthreadValid(worker->thread)) { if (taosCheckPthreadValid(worker->thread)) {
pthread_join(worker->thread, NULL); pthread_join(worker->thread, NULL);
} }
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "ttokendef.h" #include "ttokendef.h"
#include "tutil.h" #include "tutil.h"
#include "tvariant.h" #include "tvariant.h"
#include "parserInt.h"
} }
%syntax_error { %syntax_error {
...@@ -302,8 +303,8 @@ db_optr(Y) ::= db_optr(Z) cachelast(X). { Y = Z; Y.cachelast = strtol(X.z, ...@@ -302,8 +303,8 @@ db_optr(Y) ::= db_optr(Z) cachelast(X). { Y = Z; Y.cachelast = strtol(X.z,
%type topic_optr {SCreateDbInfo} %type topic_optr {SCreateDbInfo}
topic_optr(Y) ::= db_optr(Z). { Y = Z; Y.dbType = TSDB_DB_TYPE_TOPIC; } //topic_optr(Y) ::= db_optr(Z). { Y = Z; Y.dbType = TSDB_DB_TYPE_TOPIC; }
topic_optr(Y) ::= topic_optr(Z) partitions(X). { Y = Z; Y.partitions = strtol(X.z, NULL, 10); } //topic_optr(Y) ::= topic_optr(Z) partitions(X). { Y = Z; Y.partitions = strtol(X.z, NULL, 10); }
%type alter_db_optr {SCreateDbInfo} %type alter_db_optr {SCreateDbInfo}
alter_db_optr(Y) ::= . { setDefaultCreateDbOption(&Y); Y.dbType = TSDB_DB_TYPE_DEFAULT;} alter_db_optr(Y) ::= . { setDefaultCreateDbOption(&Y); Y.dbType = TSDB_DB_TYPE_DEFAULT;}
...@@ -325,7 +326,7 @@ alter_db_optr(Y) ::= alter_db_optr(Z) cachelast(X). { Y = Z; Y.cachelast = str ...@@ -325,7 +326,7 @@ alter_db_optr(Y) ::= alter_db_optr(Z) cachelast(X). { Y = Z; Y.cachelast = str
alter_topic_optr(Y) ::= alter_db_optr(Z). { Y = Z; Y.dbType = TSDB_DB_TYPE_TOPIC; } alter_topic_optr(Y) ::= alter_db_optr(Z). { Y = Z; Y.dbType = TSDB_DB_TYPE_TOPIC; }
alter_topic_optr(Y) ::= alter_topic_optr(Z) partitions(X). { Y = Z; Y.partitions = strtol(X.z, NULL, 10); } alter_topic_optr(Y) ::= alter_topic_optr(Z) partitions(X). { Y = Z; Y.partitions = strtol(X.z, NULL, 10); }
%type typename {TAOS_FIELD} %type typename {SField}
typename(A) ::= ids(X). { typename(A) ::= ids(X). {
X.type = 0; X.type = 0;
tSetColumnType (&A, &X); tSetColumnType (&A, &X);
...@@ -425,11 +426,11 @@ create_table_args(A) ::= ifnotexists(U) ids(V) cpxName(Z) AS select(S). { ...@@ -425,11 +426,11 @@ create_table_args(A) ::= ifnotexists(U) ids(V) cpxName(Z) AS select(S). {
setCreatedTableName(pInfo, &V, &U); setCreatedTableName(pInfo, &V, &U);
} }
%type column{TAOS_FIELD} %type column{SField}
%type columnlist{SArray*} %type columnlist{SArray*}
%destructor columnlist {taosArrayDestroy($$);} %destructor columnlist {taosArrayDestroy($$);}
columnlist(A) ::= columnlist(X) COMMA column(Y). {taosArrayPush(X, &Y); A = X; } columnlist(A) ::= columnlist(X) COMMA column(Y). {taosArrayPush(X, &Y); A = X; }
columnlist(A) ::= column(X). {A = taosArrayInit(4, sizeof(TAOS_FIELD)); taosArrayPush(A, &X);} columnlist(A) ::= column(X). {A = taosArrayInit(4, sizeof(SField)); taosArrayPush(A, &X);}
// The information used for a column is the name and type of column: // The information used for a column is the name and type of column:
// tinyint smallint int bigint float double bool timestamp binary(x) nchar(x) // tinyint smallint int bigint float double bool timestamp binary(x) nchar(x)
......
...@@ -15,7 +15,7 @@ if $data00 != d1 then ...@@ -15,7 +15,7 @@ if $data00 != d1 then
return -1 return -1
endi endi
if $data02 != 0 then if $data02 != 2 then
return -1 return -1
endi endi
...@@ -51,7 +51,7 @@ if $data00 != d4 then ...@@ -51,7 +51,7 @@ if $data00 != d4 then
return -1 return -1
endi endi
if $data02 != 0 then if $data02 != 2 then
return -1 return -1
endi endi
......
#======================b1-start=============== #======================b1-start===============
# ---- user
./test.sh -f general/user/basic1.sim ./test.sh -f general/user/basic1.sim
# ---- db
./test.sh -f general/db/basic1.sim
#======================b1-end=============== #======================b1-end===============
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册