提交 6f41437a 编写于 作者: D dapan1121

Merge remote-tracking branch 'origin/3.0' into feature/qnode

......@@ -135,30 +135,30 @@ void basic_consume_loop(tmq_t *tmq,
fprintf(stderr, "%% Consumer closed\n");
}
void sync_consume_loop(tmq_t *rk,
void sync_consume_loop(tmq_t *tmq,
tmq_list_t *topics) {
static const int MIN_COMMIT_COUNT = 1000;
int msg_count = 0;
tmq_resp_err_t err;
if ((err = tmq_subscribe(rk, topics))) {
if ((err = tmq_subscribe(tmq, topics))) {
fprintf(stderr, "%% Failed to start consuming topics: %s\n", tmq_err2str(err));
return;
}
while (running) {
tmq_message_t *tmqmessage = tmq_consumer_poll(rk, 500);
tmq_message_t *tmqmessage = tmq_consumer_poll(tmq, 500);
if (tmqmessage) {
msg_process(tmqmessage);
tmq_message_destroy(tmqmessage);
if ((++msg_count % MIN_COMMIT_COUNT) == 0)
tmq_commit(rk, NULL, 0);
tmq_commit(tmq, NULL, 0);
}
}
err = tmq_consumer_close(rk);
err = tmq_consumer_close(tmq);
if (err)
fprintf(stderr, "%% Failed to close consumer: %s\n", tmq_err2str(err));
else
......
......@@ -113,13 +113,13 @@ typedef enum _mgmt_table {
#define TSDB_ALTER_TABLE_ADD_TAG_COLUMN 1
#define TSDB_ALTER_TABLE_DROP_TAG_COLUMN 2
#define TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN 3
#define TSDB_ALTER_TABLE_UPDATE_TAG_NAME 3
#define TSDB_ALTER_TABLE_UPDATE_TAG_VAL 4
#define TSDB_ALTER_TABLE_ADD_COLUMN 5
#define TSDB_ALTER_TABLE_DROP_COLUMN 6
#define TSDB_ALTER_TABLE_CHANGE_COLUMN 7
#define TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN 8
#define TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES 7
#define TSDB_ALTER_TABLE_UPDATE_TAG_BYTES 8
#define TSDB_FILL_NONE 0
#define TSDB_FILL_NULL 1
......@@ -254,7 +254,7 @@ typedef struct {
int8_t igExists;
int32_t numOfTags;
int32_t numOfColumns;
SSchema pSchema[];
SSchema pSchemas[];
} SMCreateStbReq;
typedef struct {
......@@ -265,8 +265,9 @@ typedef struct {
typedef struct {
char name[TSDB_TABLE_FNAME_LEN];
int8_t alterType;
SSchema schema;
} SMAlterStbReq;
int32_t numOfSchemas;
SSchema pSchemas[];
} SMAltertbReq;
typedef struct {
int32_t pid;
......@@ -1178,31 +1179,28 @@ typedef struct SVCreateTbReq {
SSchema* pSchema;
} ntbCfg;
};
} SVCreateTbReq;
} SVCreateTbReq, SVUpdateTbReq;
typedef struct {
uint64_t ver; // use a general definition
SArray* pArray;
} SVCreateTbBatchReq;
} SVCreateTbRsp, SVUpdateTbRsp;
int tSerializeSVCreateTbReq(void** buf, SVCreateTbReq* pReq);
void* tDeserializeSVCreateTbReq(void* buf, SVCreateTbReq* pReq);
int tSVCreateTbBatchReqSerialize(void** buf, SVCreateTbBatchReq* pReq);
void* tSVCreateTbBatchReqDeserialize(void* buf, SVCreateTbBatchReq* pReq);
int32_t tSerializeSVCreateTbReq(void** buf, SVCreateTbReq* pReq);
void* tDeserializeSVCreateTbReq(void* buf, SVCreateTbReq* pReq);
int32_t tSerializeSVCreateTbRsp(void** buf, SVCreateTbRsp* pRsp);
void* tDeserializeSVCreateTbRsp(void* buf, SVCreateTbRsp* pRsp);
typedef struct {
SMsgHead head;
} SVCreateTbRsp;
uint64_t ver; // use a general definition
SArray* pArray;
} SVCreateTbBatchReq;
typedef struct {
SMsgHead head;
char name[TSDB_TABLE_FNAME_LEN];
int8_t ignoreNotExists;
} SVAlterTbReq;
} SVCreateTbBatchRsp;
typedef struct {
SMsgHead head;
} SVAlterTbRsp;
int32_t tSerializeSVCreateTbBatchReq(void** buf, SVCreateTbBatchReq* pReq);
void* tDeserializeSVCreateTbBatchReq(void* buf, SVCreateTbBatchReq* pReq);
int32_t tSerializeSVCreateTbBatchReqp(void** buf, SVCreateTbBatchReq* pRsp);
void* tDeserializeSVCreateTbBatchReq(void* buf, SVCreateTbBatchReq* pRsp);
typedef struct {
uint64_t ver;
......
......@@ -273,12 +273,11 @@
#define NEW_TK_SOFFSET 64
#define NEW_TK_LIMIT 65
#define NEW_TK_OFFSET 66
#define NEW_TK_NK_LR 67
#define NEW_TK_ASC 68
#define NEW_TK_DESC 69
#define NEW_TK_NULLS 70
#define NEW_TK_FIRST 71
#define NEW_TK_LAST 72
#define NEW_TK_ASC 67
#define NEW_TK_DESC 68
#define NEW_TK_NULLS 69
#define NEW_TK_FIRST 70
#define NEW_TK_LAST 71
#define TK_SPACE 300
#define TK_COMMENT 301
......
......@@ -54,6 +54,9 @@ typedef enum ENodeType {
QUERY_NODE_NODE_LIST,
QUERY_NODE_FILL,
// only for parser
QUERY_NODE_TARGET_EXPR,
QUERY_NODE_SET_OPERATOR,
QUERY_NODE_SELECT_STMT,
QUERY_NODE_SHOW_STMT
......@@ -78,11 +81,6 @@ typedef struct SNodeList {
SListCell* pTail;
} SNodeList;
typedef struct SNameStr {
int32_t len;
char* pName;
} SNameStr;
typedef struct SDataType {
uint8_t type;
uint8_t precision;
......@@ -114,7 +112,7 @@ typedef struct SColumnNode {
} SColumnNode;
typedef struct SValueNode {
SExprNode type; // QUERY_NODE_VALUE
SExprNode node; // QUERY_NODE_VALUE
char* literal;
} SValueNode;
......@@ -146,7 +144,7 @@ typedef enum EOperatorType {
} EOperatorType;
typedef struct SOperatorNode {
SExprNode type; // QUERY_NODE_OPERATOR
SExprNode node; // QUERY_NODE_OPERATOR
EOperatorType opType;
SNode* pLeft;
SNode* pRight;
......@@ -332,6 +330,10 @@ void nodesCloneNode(const SNode* pNode);
int32_t nodesNodeToString(const SNode* pNode, char** pStr, int32_t* pLen);
int32_t nodesStringToNode(const char* pStr, SNode** pNode);
bool nodesIsArithmeticOp(const SOperatorNode* pOp);
bool nodesIsComparisonOp(const SOperatorNode* pOp);
bool nodesIsJsonOp(const SOperatorNode* pOp);
bool nodesIsTimeorderQuery(const SNode* pQuery);
bool nodesIsTimelineQuery(const SNode* pQuery);
......
......@@ -228,7 +228,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_MND_TOO_MANY_COLUMNS TAOS_DEF_ERROR_CODE(0, 0x03A9)
#define TSDB_CODE_MND_COLUMN_ALREAY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AA)
#define TSDB_CODE_MND_COLUMN_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AB)
#define TSDB_CODE_MND_EXCEED_MAX_ROW_BYTES TAOS_DEF_ERROR_CODE(0, 0x03AC)
#define TSDB_CODE_MND_INVALID_ROW_BYTES TAOS_DEF_ERROR_CODE(0, 0x03AC)
#define TSDB_CODE_MND_NAME_CONFLICT_WITH_TOPIC TAOS_DEF_ERROR_CODE(0, 0x03AD)
// mnode-func
......@@ -446,6 +446,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_PARSER_INVALID_COLUMN TAOS_DEF_ERROR_CODE(0, 0x2601) //invalid column name
#define TSDB_CODE_PARSER_TABLE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x2602) //table not exist
#define TSDB_CODE_PARSER_AMBIGUOUS_COLUMN TAOS_DEF_ERROR_CODE(0, 0x2603) //ambiguous column
#define TSDB_CODE_PARSER_WRONG_VALUE_TYPE TAOS_DEF_ERROR_CODE(0, 0x2604) //wrong value type
#ifdef __cplusplus
}
......
......@@ -105,8 +105,9 @@ TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass,
pthread_mutex_lock(&appInfo.mutex);
pInst = taosHashGet(appInfo.pInstMap, key, strlen(key));
SAppInstInfo* p = NULL;
if (pInst == NULL) {
SAppInstInfo* p = calloc(1, sizeof(struct SAppInstInfo));
p = calloc(1, sizeof(struct SAppInstInfo));
p->mgmtEp = epSet;
p->pTransporter = openTransporter(user, secretEncrypt, tsNumOfCores);
p->pAppHbMgr = appHbMgrInit(p, key);
......
......@@ -5,14 +5,26 @@ MESSAGE(STATUS "build parser unit test")
SET(CMAKE_CXX_STANDARD 11)
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST)
ADD_EXECUTABLE(clientTest ${SOURCE_LIST})
ADD_EXECUTABLE(clientTest clientTests.cpp)
TARGET_LINK_LIBRARIES(
clientTest
PUBLIC os util common transport parser catalog scheduler function gtest taos qcom
)
ADD_EXECUTABLE(tmqTest tmqTest.cpp)
TARGET_LINK_LIBRARIES(
tmqTest
PUBLIC os util common transport parser catalog scheduler function gtest taos qcom
)
TARGET_INCLUDE_DIRECTORIES(
clientTest
PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/client/"
PRIVATE "${CMAKE_SOURCE_DIR}/source/libs/client/inc"
)
TARGET_INCLUDE_DIRECTORIES(
tmqTest
PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/client/"
PRIVATE "${CMAKE_SOURCE_DIR}/source/libs/client/inc"
)
......@@ -564,119 +564,6 @@ TEST(testCase, insert_test) {
}
#endif
TEST(testCase, create_topic_ctb_Test) {
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
assert(pConn != NULL);
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_free_result(pRes);
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
ASSERT_TRUE(pFields == nullptr);
int32_t numOfFields = taos_num_fields(pRes);
ASSERT_EQ(numOfFields, 0);
taos_free_result(pRes);
char* sql = "select * from tu";
pRes = tmq_create_topic(pConn, "test_ctb_topic_1", sql, strlen(sql));
taos_free_result(pRes);
taos_close(pConn);
}
TEST(testCase, create_topic_stb_Test) {
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
assert(pConn != NULL);
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_free_result(pRes);
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
ASSERT_TRUE(pFields == nullptr);
int32_t numOfFields = taos_num_fields(pRes);
ASSERT_EQ(numOfFields, 0);
taos_free_result(pRes);
char* sql = "select * from st1";
pRes = tmq_create_topic(pConn, "test_stb_topic_1", sql, strlen(sql));
taos_free_result(pRes);
taos_close(pConn);
}
#if 0
TEST(testCase, tmq_subscribe_ctb_Test) {
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
assert(pConn != NULL);
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_free_result(pRes);
tmq_conf_t* conf = tmq_conf_new();
tmq_conf_set(conf, "group.id", "tg1");
tmq_t* tmq = tmq_consumer_new(pConn, conf, NULL, 0);
tmq_list_t* topic_list = tmq_list_new();
tmq_list_append(topic_list, "test_ctb_topic_1");
tmq_subscribe(tmq, topic_list);
while (1) {
tmq_message_t* msg = tmq_consumer_poll(tmq, 1000);
tmq_message_destroy(msg);
//printf("get msg\n");
//if (msg == NULL) break;
}
}
#endif
TEST(testCase, tmq_subscribe_stb_Test) {
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
assert(pConn != NULL);
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_free_result(pRes);
tmq_conf_t* conf = tmq_conf_new();
tmq_conf_set(conf, "group.id", "tg2");
tmq_t* tmq = tmq_consumer_new(pConn, conf, NULL, 0);
tmq_list_t* topic_list = tmq_list_new();
tmq_list_append(topic_list, "test_stb_topic_1");
tmq_subscribe(tmq, topic_list);
int cnt = 1;
while (1) {
tmq_message_t* msg = tmq_consumer_poll(tmq, 1000);
if (msg == NULL) continue;
tmqShowMsg(msg);
if (cnt++ % 10 == 0){
tmq_commit(tmq, NULL, 0);
}
//tmq_commit(tmq, NULL, 0);
tmq_message_destroy(msg);
//printf("get msg\n");
}
}
TEST(testCase, tmq_consume_Test) {
}
TEST(testCase, tmq_commit_TEST) {
}
#if 0
TEST(testCase, projection_query_tables) {
......
/*
* 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 <gtest/gtest.h>
#include <taoserror.h>
#include <tglobal.h>
#include <iostream>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wwrite-strings"
#pragma GCC diagnostic ignored "-Wunused-function"
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wsign-compare"
#include "../inc/clientInt.h"
#include "taos.h"
int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
TEST(testCase, driverInit_Test) {
taosInitGlobalCfg();
// taos_init();
}
TEST(testCase, create_topic_ctb_Test) {
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
assert(pConn != NULL);
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_free_result(pRes);
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
ASSERT_TRUE(pFields == nullptr);
int32_t numOfFields = taos_num_fields(pRes);
ASSERT_EQ(numOfFields, 0);
taos_free_result(pRes);
char* sql = "select * from tu";
pRes = tmq_create_topic(pConn, "test_ctb_topic_1", sql, strlen(sql));
taos_free_result(pRes);
taos_close(pConn);
}
TEST(testCase, create_topic_stb_Test) {
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
assert(pConn != NULL);
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_free_result(pRes);
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
ASSERT_TRUE(pFields == nullptr);
int32_t numOfFields = taos_num_fields(pRes);
ASSERT_EQ(numOfFields, 0);
taos_free_result(pRes);
char* sql = "select * from st1";
pRes = tmq_create_topic(pConn, "test_stb_topic_1", sql, strlen(sql));
taos_free_result(pRes);
taos_close(pConn);
}
#if 0
TEST(testCase, tmq_subscribe_ctb_Test) {
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
assert(pConn != NULL);
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_free_result(pRes);
tmq_conf_t* conf = tmq_conf_new();
tmq_conf_set(conf, "group.id", "tg1");
tmq_t* tmq = tmq_consumer_new(pConn, conf, NULL, 0);
tmq_list_t* topic_list = tmq_list_new();
tmq_list_append(topic_list, "test_ctb_topic_1");
tmq_subscribe(tmq, topic_list);
while (1) {
tmq_message_t* msg = tmq_consumer_poll(tmq, 1000);
tmq_message_destroy(msg);
//printf("get msg\n");
//if (msg == NULL) break;
}
}
TEST(testCase, tmq_subscribe_stb_Test) {
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
assert(pConn != NULL);
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_free_result(pRes);
tmq_conf_t* conf = tmq_conf_new();
tmq_conf_set(conf, "group.id", "tg2");
tmq_t* tmq = tmq_consumer_new(pConn, conf, NULL, 0);
tmq_list_t* topic_list = tmq_list_new();
tmq_list_append(topic_list, "test_stb_topic_1");
tmq_subscribe(tmq, topic_list);
int cnt = 1;
while (1) {
tmq_message_t* msg = tmq_consumer_poll(tmq, 1000);
if (msg == NULL) continue;
tmqShowMsg(msg);
if (cnt++ % 10 == 0){
tmq_commit(tmq, NULL, 0);
}
//tmq_commit(tmq, NULL, 0);
tmq_message_destroy(msg);
//printf("get msg\n");
}
}
TEST(testCase, tmq_consume_Test) {
}
TEST(testCase, tmq_commit_Test) {
}
#endif
......@@ -293,7 +293,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
return buf;
}
int tSVCreateTbBatchReqSerialize(void **buf, SVCreateTbBatchReq *pReq) {
int tSerializeSVCreateTbBatchReq(void **buf, SVCreateTbBatchReq *pReq) {
int tlen = 0;
tlen += taosEncodeFixedU64(buf, pReq->ver);
......@@ -306,7 +306,7 @@ int tSVCreateTbBatchReqSerialize(void **buf, SVCreateTbBatchReq *pReq) {
return tlen;
}
void *tSVCreateTbBatchReqDeserialize(void *buf, SVCreateTbBatchReq *pReq) {
void *tDeserializeSVCreateTbBatchReq(void *buf, SVCreateTbBatchReq *pReq) {
uint32_t nsize = 0;
buf = taosDecodeFixedU64(buf, &pReq->ver);
......
......@@ -220,15 +220,69 @@ TEST_F(DndTestVnode, 03_Create_Stb) {
}
TEST_F(DndTestVnode, 04_ALTER_Stb) {
#if 0
{
for (int i = 0; i < 3; ++i) {
SRpcMsg* pRsp = test.SendReq(TDMT_VND_ALTER_STB, pReq, contLen);
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, 0);
for (int i = 0; i < 1; ++i) {
SVCreateTbReq req = {0};
req.ver = 0;
req.name = (char*)"stb1";
req.ttl = 0;
req.keep = 0;
req.type = TD_SUPER_TABLE;
SSchema schemas[5] = {0};
{
SSchema* pSchema = &schemas[0];
pSchema->bytes = htonl(8);
pSchema->type = TSDB_DATA_TYPE_TIMESTAMP;
strcpy(pSchema->name, "ts");
}
{
SSchema* pSchema = &schemas[1];
pSchema->bytes = htonl(4);
pSchema->type = TSDB_DATA_TYPE_INT;
strcpy(pSchema->name, "col1");
}
{
SSchema* pSchema = &schemas[2];
pSchema->bytes = htonl(2);
pSchema->type = TSDB_DATA_TYPE_TINYINT;
strcpy(pSchema->name, "_tag1");
}
{
SSchema* pSchema = &schemas[3];
pSchema->bytes = htonl(8);
pSchema->type = TSDB_DATA_TYPE_BIGINT;
strcpy(pSchema->name, "_tag2");
}
{
SSchema* pSchema = &schemas[4];
pSchema->bytes = htonl(16);
pSchema->type = TSDB_DATA_TYPE_BINARY;
strcpy(pSchema->name, "_tag3");
}
req.stbCfg.suid = 9527;
req.stbCfg.nCols = 2;
req.stbCfg.pSchema = &schemas[0];
req.stbCfg.nTagCols = 3;
req.stbCfg.pTagSchema = &schemas[2];
int32_t contLen = tSerializeSVCreateTbReq(NULL, &req) + sizeof(SMsgHead);
SMsgHead* pHead = (SMsgHead*)rpcMallocCont(contLen);
pHead->contLen = htonl(contLen);
pHead->vgId = htonl(2);
void* pBuf = POINTER_SHIFT(pHead, sizeof(SMsgHead));
tSerializeSVCreateTbReq(&pBuf, &req);
SRpcMsg* pRsp = test.SendReq(TDMT_VND_ALTER_STB, (void*)pHead, contLen);
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, 0);
}
#endif
}
TEST_F(DndTestVnode, 05_DROP_Stb) {
......
......@@ -301,10 +301,12 @@ typedef struct {
uint64_t uid;
uint64_t dbUid;
int32_t version;
int32_t nextColId;
int32_t numOfColumns;
int32_t numOfTags;
SSchema* pTags;
SSchema* pColumns;
SRWLatch lock;
SSchema* pSchema;
} SStbObj;
typedef struct {
......@@ -617,7 +619,7 @@ typedef struct SMqTopicObj {
int64_t createTime;
int64_t updateTime;
uint64_t uid;
uint64_t dbUid;
int64_t dbUid;
int32_t version;
SRWLatch lock;
int32_t sqlLen;
......
......@@ -84,12 +84,20 @@ static SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
SDB_SET_INT64(pRaw, dataPos, pStb->uid, STB_ENCODE_OVER)
SDB_SET_INT64(pRaw, dataPos, pStb->dbUid, STB_ENCODE_OVER)
SDB_SET_INT32(pRaw, dataPos, pStb->version, STB_ENCODE_OVER)
SDB_SET_INT32(pRaw, dataPos, pStb->nextColId, STB_ENCODE_OVER)
SDB_SET_INT32(pRaw, dataPos, pStb->numOfColumns, STB_ENCODE_OVER)
SDB_SET_INT32(pRaw, dataPos, pStb->numOfTags, STB_ENCODE_OVER)
int32_t totalCols = pStb->numOfColumns + pStb->numOfTags;
for (int32_t i = 0; i < totalCols; ++i) {
SSchema *pSchema = &pStb->pSchema[i];
for (int32_t i = 0; i < pStb->numOfColumns; ++i) {
SSchema *pSchema = &pStb->pColumns[i];
SDB_SET_INT8(pRaw, dataPos, pSchema->type, STB_ENCODE_OVER)
SDB_SET_INT32(pRaw, dataPos, pSchema->colId, STB_ENCODE_OVER)
SDB_SET_INT32(pRaw, dataPos, pSchema->bytes, STB_ENCODE_OVER)
SDB_SET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, STB_ENCODE_OVER)
}
for (int32_t i = 0; i < pStb->numOfTags; ++i) {
SSchema *pSchema = &pStb->pTags[i];
SDB_SET_INT8(pRaw, dataPos, pSchema->type, STB_ENCODE_OVER)
SDB_SET_INT32(pRaw, dataPos, pSchema->colId, STB_ENCODE_OVER)
SDB_SET_INT32(pRaw, dataPos, pSchema->bytes, STB_ENCODE_OVER)
......@@ -137,17 +145,26 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT64(pRaw, dataPos, &pStb->uid, STB_DECODE_OVER)
SDB_GET_INT64(pRaw, dataPos, &pStb->dbUid, STB_DECODE_OVER)
SDB_GET_INT32(pRaw, dataPos, &pStb->version, STB_DECODE_OVER)
SDB_GET_INT32(pRaw, dataPos, &pStb->nextColId, STB_DECODE_OVER)
SDB_GET_INT32(pRaw, dataPos, &pStb->numOfColumns, STB_DECODE_OVER)
SDB_GET_INT32(pRaw, dataPos, &pStb->numOfTags, STB_DECODE_OVER)
int32_t totalCols = pStb->numOfColumns + pStb->numOfTags;
pStb->pSchema = calloc(totalCols, sizeof(SSchema));
if (pStb->pSchema == NULL) {
pStb->pColumns = calloc(pStb->numOfColumns, sizeof(SSchema));
pStb->pTags = calloc(pStb->numOfTags, sizeof(SSchema));
if (pStb->pColumns == NULL || pStb->pTags == NULL) {
goto STB_DECODE_OVER;
}
for (int32_t i = 0; i < totalCols; ++i) {
SSchema *pSchema = &pStb->pSchema[i];
for (int32_t i = 0; i < pStb->numOfColumns; ++i) {
SSchema *pSchema = &pStb->pColumns[i];
SDB_GET_INT8(pRaw, dataPos, &pSchema->type, STB_DECODE_OVER)
SDB_GET_INT32(pRaw, dataPos, &pSchema->colId, STB_DECODE_OVER)
SDB_GET_INT32(pRaw, dataPos, &pSchema->bytes, STB_DECODE_OVER)
SDB_GET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, STB_DECODE_OVER)
}
for (int32_t i = 0; i < pStb->numOfTags; ++i) {
SSchema *pSchema = &pStb->pTags[i];
SDB_GET_INT8(pRaw, dataPos, &pSchema->type, STB_DECODE_OVER)
SDB_GET_INT32(pRaw, dataPos, &pSchema->colId, STB_DECODE_OVER)
SDB_GET_INT32(pRaw, dataPos, &pSchema->bytes, STB_DECODE_OVER)
......@@ -176,6 +193,8 @@ static int32_t mndStbActionInsert(SSdb *pSdb, SStbObj *pStb) {
static int32_t mndStbActionDelete(SSdb *pSdb, SStbObj *pStb) {
mTrace("stb:%s, perform delete action, row:%p", pStb->name, pStb);
tfree(pStb->pColumns);
tfree(pStb->pTags);
return 0;
}
......@@ -183,13 +202,24 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
mTrace("stb:%s, perform update action, old row:%p new row:%p", pOld->name, pOld, pNew);
taosWLockLatch(&pOld->lock);
int32_t totalCols = pNew->numOfTags + pNew->numOfColumns;
int32_t totalSize = totalCols * sizeof(SSchema);
if (pOld->numOfTags + pOld->numOfColumns < totalCols) {
void *pSchema = malloc(totalSize);
if (pSchema != NULL) {
free(pOld->pSchema);
pOld->pSchema = pSchema;
if (pOld->numOfColumns < pNew->numOfColumns) {
void *pColumns = malloc(pNew->numOfColumns * sizeof(SSchema));
if (pColumns != NULL) {
free(pOld->pColumns);
pOld->pColumns = pColumns;
} else {
terrno = TSDB_CODE_OUT_OF_MEMORY;
mTrace("stb:%s, failed to perform update action since %s", pOld->name, terrstr());
taosWUnLockLatch(&pOld->lock);
}
}
if (pOld->numOfTags < pNew->numOfTags) {
void *pTags = malloc(pNew->numOfTags * sizeof(SSchema));
if (pTags != NULL) {
free(pOld->pTags);
pOld->pTags = pTags;
} else {
terrno = TSDB_CODE_OUT_OF_MEMORY;
mTrace("stb:%s, failed to perform update action since %s", pOld->name, terrstr());
......@@ -199,9 +229,11 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
pOld->updateTime = pNew->updateTime;
pOld->version = pNew->version;
pOld->nextColId = pNew->nextColId;
pOld->numOfColumns = pNew->numOfColumns;
pOld->numOfTags = pNew->numOfTags;
memcpy(pOld->pSchema, pNew->pSchema, totalSize);
memcpy(pOld->pColumns, pNew->pColumns, pOld->numOfColumns * sizeof(SSchema));
memcpy(pOld->pTags, pNew->pTags, pOld->numOfTags * sizeof(SSchema));
taosWUnLockLatch(&pOld->lock);
return 0;
}
......@@ -242,9 +274,9 @@ static void *mndBuildCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pStb
req.type = TD_SUPER_TABLE;
req.stbCfg.suid = pStb->uid;
req.stbCfg.nCols = pStb->numOfColumns;
req.stbCfg.pSchema = pStb->pSchema;
req.stbCfg.pSchema = pStb->pColumns;
req.stbCfg.nTagCols = pStb->numOfTags;
req.stbCfg.pTagSchema = pStb->pSchema + pStb->numOfColumns;
req.stbCfg.pTagSchema = pStb->pTags;
int32_t contLen = tSerializeSVCreateTbReq(NULL, &req) + sizeof(SMsgHead);
SMsgHead *pHead = malloc(contLen);
......@@ -295,7 +327,7 @@ static int32_t mndCheckCreateStbReq(SMCreateStbReq *pCreate) {
pCreate->numOfTags = htonl(pCreate->numOfTags);
int32_t totalCols = pCreate->numOfColumns + pCreate->numOfTags;
for (int32_t i = 0; i < totalCols; ++i) {
SSchema *pSchema = &pCreate->pSchema[i];
SSchema *pSchema = &pCreate->pSchemas[i];
pSchema->bytes = htonl(pSchema->bytes);
}
......@@ -316,7 +348,7 @@ static int32_t mndCheckCreateStbReq(SMCreateStbReq *pCreate) {
int32_t maxColId = (TSDB_MAX_COLUMNS + TSDB_MAX_TAGS);
for (int32_t i = 0; i < totalCols; ++i) {
SSchema *pSchema = &pCreate->pSchema[i];
SSchema *pSchema = &pCreate->pSchemas[i];
if (pSchema->type < 0) {
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
return -1;
......@@ -435,27 +467,35 @@ static int32_t mndSetCreateStbUndoActions(SMnode *pMnode, STrans *pTrans, SDbObj
static int32_t mndCreateStb(SMnode *pMnode, SMnodeMsg *pReq, SMCreateStbReq *pCreate, SDbObj *pDb) {
SStbObj stbObj = {0};
tstrncpy(stbObj.name, pCreate->name, TSDB_TABLE_FNAME_LEN);
tstrncpy(stbObj.db, pDb->name, TSDB_DB_FNAME_LEN);
memcpy(stbObj.name, pCreate->name, TSDB_TABLE_FNAME_LEN);
memcpy(stbObj.db, pDb->name, TSDB_DB_FNAME_LEN);
stbObj.createdTime = taosGetTimestampMs();
stbObj.updateTime = stbObj.createdTime;
stbObj.uid = mndGenerateUid(pCreate->name, TSDB_TABLE_FNAME_LEN);
stbObj.dbUid = pDb->uid;
stbObj.version = 1;
stbObj.nextColId = 1;
stbObj.numOfColumns = pCreate->numOfColumns;
stbObj.numOfTags = pCreate->numOfTags;
int32_t totalCols = stbObj.numOfColumns + stbObj.numOfTags;
int32_t totalSize = totalCols * sizeof(SSchema);
stbObj.pSchema = malloc(totalSize);
if (stbObj.pSchema == NULL) {
stbObj.pColumns = malloc(stbObj.numOfColumns * sizeof(SSchema));
stbObj.pTags = malloc(stbObj.numOfTags * sizeof(SSchema));
if (stbObj.pColumns == NULL || stbObj.pTags == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
memcpy(stbObj.pSchema, pCreate->pSchema, totalSize);
for (int32_t i = 0; i < totalCols; ++i) {
stbObj.pSchema[i].colId = i + 1;
memcpy(stbObj.pColumns, pCreate->pSchemas, stbObj.numOfColumns * sizeof(SSchema));
memcpy(stbObj.pTags, pCreate->pSchemas + stbObj.numOfColumns, stbObj.numOfTags * sizeof(SSchema));
for (int32_t i = 0; i < stbObj.numOfColumns; ++i) {
stbObj.pColumns[i].colId = stbObj.nextColId;
stbObj.nextColId++;
}
for (int32_t i = 0; i < stbObj.numOfTags; ++i) {
stbObj.pTags[i].colId = stbObj.nextColId;
stbObj.nextColId++;
}
int32_t code = -1;
......@@ -537,36 +577,396 @@ static int32_t mndProcessVCreateStbRsp(SMnodeMsg *pRsp) {
return 0;
}
static int32_t mndCheckAlterStbReq(SMAlterStbReq *pAlter) {
SSchema *pSchema = &pAlter->schema;
pSchema->colId = htonl(pSchema->colId);
pSchema->bytes = htonl(pSchema->bytes);
static int32_t mndCheckAlterStbReq(SMAltertbReq *pAlter) {
pAlter->numOfSchemas = htonl(pAlter->numOfSchemas);
if (pSchema->type <= 0) {
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
for (int32_t i = 0; i < pAlter->numOfSchemas; ++i) {
SSchema *pSchema = &pAlter->pSchemas[i];
pSchema->colId = htonl(pSchema->colId);
pSchema->bytes = htonl(pSchema->bytes);
if (pSchema->type <= 0) {
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
return -1;
}
if (pSchema->colId < 0 || pSchema->colId >= (TSDB_MAX_COLUMNS + TSDB_MAX_TAGS)) {
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
return -1;
}
if (pSchema->bytes <= 0) {
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
return -1;
}
if (pSchema->name[0] == 0) {
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
return -1;
}
}
return 0;
}
static int32_t mndFindSuperTableTagIndex(const SStbObj *pStb, const char *tagName) {
for (int32_t tag = 0; tag < pStb->numOfTags; tag++) {
if (strcasecmp(pStb->pTags[tag].name, tagName) == 0) {
return tag;
}
}
return -1;
}
static int32_t mndFindSuperTableColumnIndex(const SStbObj *pStb, const char *colName) {
for (int32_t col = 0; col < pStb->numOfColumns; col++) {
if (strcasecmp(pStb->pColumns[col].name, colName) == 0) {
return col;
}
}
return -1;
}
static int32_t mndAllocStbSchemas(const SStbObj *pOld, SStbObj *pNew) {
pNew->pTags = calloc(pNew->numOfTags, sizeof(SSchema));
pNew->pColumns = calloc(pNew->numOfColumns, sizeof(SSchema));
if (pNew->pTags == NULL || pNew->pColumns == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
memcpy(pNew->pColumns, pOld->pColumns, sizeof(SSchema) * pOld->numOfColumns);
memcpy(pNew->pTags, pOld->pTags, sizeof(SSchema) * pOld->numOfTags);
return 0;
}
static int32_t mndAddSuperTableTag(const SStbObj *pOld, SStbObj *pNew, const SSchema *pSchemas, int32_t ntags) {
if (pOld->numOfTags + ntags > TSDB_MAX_TAGS) {
terrno = TSDB_CODE_MND_TOO_MANY_TAGS;
return -1;
}
if (pSchema->colId < 0 || pSchema->colId >= (TSDB_MAX_COLUMNS + TSDB_MAX_TAGS)) {
if (pOld->numOfColumns + ntags + pOld->numOfTags > TSDB_MAX_COLUMNS) {
terrno = TSDB_CODE_MND_TOO_MANY_COLUMNS;
return -1;
}
for (int32_t i = 0; i < ntags; i++) {
if (mndFindSuperTableColumnIndex(pOld, pSchemas[i].name) > 0) {
terrno = TSDB_CODE_MND_TAG_ALREAY_EXIST;
return -1;
}
if (mndFindSuperTableTagIndex(pOld, pSchemas[i].name) > 0) {
terrno = TSDB_CODE_MND_COLUMN_ALREAY_EXIST;
return -1;
}
}
pNew->numOfTags = pNew->numOfTags + ntags;
if (mndAllocStbSchemas(pOld, pNew) != 0) {
return -1;
}
memcpy(pNew->pTags + pOld->numOfTags, pSchemas, sizeof(SSchema) * ntags);
for (int32_t i = pOld->numOfTags; i < pNew->numOfTags; i++) {
SSchema *pSchema = &pNew->pTags[i];
pSchema->colId = pNew->nextColId;
pNew->nextColId++;
}
pNew->version++;
mDebug("stb:%s, start to add tag %s", pNew->name, pSchemas[0].name);
return 0;
}
static int32_t mndDropSuperTableTag(const SStbObj *pOld, SStbObj *pNew, const char *tagName) {
int32_t tag = mndFindSuperTableTagIndex(pOld, tagName);
if (tag < 0) {
terrno = TSDB_CODE_MND_TAG_NOT_EXIST;
return -1;
}
if (mndAllocStbSchemas(pOld, pNew) != 0) {
return -1;
}
memmove(pNew->pTags + tag, pNew->pTags + tag + 1, sizeof(SSchema) * (pNew->numOfTags - tag - 1));
pNew->version++;
mDebug("stb:%s, start to drop tag %s", pNew->name, tagName);
return 0;
}
static int32_t mndAlterStbTagName(const SStbObj *pOld, SStbObj *pNew, const char *oldTagName, const char *newTagName) {
int32_t tag = mndFindSuperTableTagIndex(pOld, oldTagName);
if (tag < 0) {
terrno = TSDB_CODE_MND_TAG_NOT_EXIST;
return -1;
}
if (mndFindSuperTableTagIndex(pOld, newTagName) >= 0) {
terrno = TSDB_CODE_MND_TAG_ALREAY_EXIST;
return -1;
}
int32_t len = (int32_t)strlen(newTagName);
if (len >= TSDB_COL_NAME_LEN) {
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
return -1;
}
if (pSchema->bytes <= 0) {
if (mndAllocStbSchemas(pOld, pNew) != 0) {
return -1;
}
SSchema *pSchema = (SSchema *)(pNew->pTags + tag);
memcpy(pSchema->name, newTagName, TSDB_COL_NAME_LEN);
pNew->version++;
mDebug("stb:%s, start to modify tag %s to %s", pNew->name, oldTagName, newTagName);
return 0;
}
static int32_t mndAlterStbTagBytes(const SStbObj *pOld, SStbObj *pNew, const SSchema *pSchema) {
int32_t tag = mndFindSuperTableTagIndex(pOld, pSchema->name);
if (tag < 0) {
terrno = TSDB_CODE_MND_TAG_NOT_EXIST;
return -1;
}
if (!(pSchema->type == TSDB_DATA_TYPE_BINARY || pSchema->type == TSDB_DATA_TYPE_NCHAR)) {
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
return -1;
}
if (pSchema->name[0] == 0) {
if (mndAllocStbSchemas(pOld, pNew) != 0) {
return -1;
}
SSchema *pTag = pNew->pTags + tag;
if (pSchema->bytes <= pTag->bytes) {
terrno = TSDB_CODE_MND_INVALID_ROW_BYTES;
return -1;
}
pTag->bytes = pSchema->bytes;
pNew->version++;
mDebug("stb:%s, start to modify tag len %s to %d", pNew->name, pSchema->name, pSchema->bytes);
return 0;
}
static int32_t mndAddSuperTableColumn(const SStbObj *pOld, SStbObj *pNew, const SSchema *pSchemas, int32_t ncols) {
if (pOld->numOfColumns + ncols + pOld->numOfTags > TSDB_MAX_COLUMNS) {
terrno = TSDB_CODE_MND_TOO_MANY_COLUMNS;
return -1;
}
for (int32_t i = 0; i < ncols; i++) {
if (mndFindSuperTableColumnIndex(pOld, pSchemas[i].name) > 0) {
terrno = TSDB_CODE_MND_TAG_ALREAY_EXIST;
return -1;
}
if (mndFindSuperTableTagIndex(pOld, pSchemas[i].name) > 0) {
terrno = TSDB_CODE_MND_COLUMN_ALREAY_EXIST;
return -1;
}
}
pNew->numOfColumns = pNew->numOfColumns + ncols;
if (mndAllocStbSchemas(pOld, pNew) != 0) {
return -1;
}
memcpy(pNew->pColumns + pOld->numOfColumns, pSchemas, sizeof(SSchema) * ncols);
for (int32_t i = pOld->numOfColumns; i < pNew->numOfColumns; i++) {
SSchema *pSchema = &pNew->pColumns[i];
pSchema->colId = pNew->nextColId;
pNew->nextColId++;
}
pNew->version++;
mDebug("stb:%s, start to add column %s", pNew->name, pSchemas[0].name);
return 0;
}
static int32_t mndDropSuperTableColumn(const SStbObj *pOld, SStbObj *pNew, const char *colName) {
int32_t col = mndFindSuperTableColumnIndex(pOld, colName);
if (col <= 0) {
terrno = TSDB_CODE_MND_COLUMN_NOT_EXIST;
return -1;
}
if (mndAllocStbSchemas(pOld, pNew) != 0) {
return -1;
}
memmove(pNew->pColumns + col, pNew->pColumns + col + 1, sizeof(SSchema) * (pNew->numOfColumns - col - 1));
pNew->version++;
mDebug("stb:%s, start to drop col %s", pNew->name, colName);
return 0;
}
static int32_t mndAlterStbColumnBytes(const SStbObj *pOld, SStbObj *pNew, const SSchema *pSchema) {
int32_t col = mndFindSuperTableColumnIndex(pOld, pSchema->name);
if (col < 0) {
terrno = TSDB_CODE_MND_COLUMN_NOT_EXIST;
return -1;
}
if (!(pSchema->type == TSDB_DATA_TYPE_BINARY || pSchema->type == TSDB_DATA_TYPE_NCHAR)) {
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
return -1;
}
uint32_t nLen = 0;
for (int32_t i = 0; i < pOld->numOfColumns; ++i) {
nLen += (pOld->pColumns[i].colId == col) ? pSchema->bytes : pOld->pColumns[i].bytes;
}
if (nLen > TSDB_MAX_BYTES_PER_ROW) {
terrno = TSDB_CODE_MND_INVALID_ROW_BYTES;
return -1;
}
if (mndAllocStbSchemas(pOld, pNew) != 0) {
return -1;
}
SSchema *pCol = pNew->pColumns + col;
if (pSchema->bytes <= pCol->bytes) {
terrno = TSDB_CODE_MND_INVALID_ROW_BYTES;
return -1;
}
pCol->bytes = pSchema->bytes;
pNew->version++;
mDebug("stb:%s, start to modify col len %s to %d", pNew->name, pSchema->name, pSchema->bytes);
return 0;
}
static int32_t mndSetAlterStbRedoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb) {
SSdbRaw *pRedoRaw = mndStbActionEncode(pStb);
if (pRedoRaw == NULL) return -1;
if (mndTransAppendRedolog(pTrans, pRedoRaw) != 0) return -1;
if (sdbSetRawStatus(pRedoRaw, SDB_STATUS_UPDATING) != 0) return -1;
return 0;
}
static int32_t mndSetAlterStbCommitLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb) {
SSdbRaw *pCommitRaw = mndStbActionEncode(pStb);
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 mndSetAlterStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb) {
SSdb *pSdb = pMnode->pSdb;
SVgObj *pVgroup = NULL;
void *pIter = NULL;
int32_t contLen;
while (1) {
pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup);
if (pIter == NULL) break;
if (pVgroup->dbUid != pDb->uid) continue;
void *pReq = mndBuildCreateStbReq(pMnode, pVgroup, pStb, &contLen);
if (pReq == NULL) {
sdbCancelFetch(pSdb, pIter);
sdbRelease(pSdb, pVgroup);
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
STransAction action = {0};
action.epSet = mndGetVgroupEpset(pMnode, pVgroup);
action.pCont = pReq;
action.contLen = contLen;
action.msgType = TDMT_VND_ALTER_STB;
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
free(pReq);
sdbCancelFetch(pSdb, pIter);
sdbRelease(pSdb, pVgroup);
return -1;
}
sdbRelease(pSdb, pVgroup);
}
return 0;
}
static int32_t mndUpdateStb(SMnode *pMnode, SMnodeMsg *pReq, SStbObj *pOld, SStbObj *pNew) { return 0; }
static int32_t mndAlterStb(SMnode *pMnode, SMnodeMsg *pReq, const SMAltertbReq *pAlter, SDbObj *pDb, SStbObj *pOld) {
SStbObj stbObj = {0};
taosRLockLatch(&pOld->lock);
memcpy(&stbObj, pOld, sizeof(SStbObj));
stbObj.pColumns = NULL;
stbObj.pTags = NULL;
stbObj.updateTime = taosGetTimestampMs();
taosRUnLockLatch(&pOld->lock);
int32_t code = -1;
switch (pAlter->alterType) {
case TSDB_ALTER_TABLE_ADD_TAG_COLUMN:
code = mndAddSuperTableTag(pOld, &stbObj, pAlter->pSchemas, 1);
break;
case TSDB_ALTER_TABLE_DROP_TAG_COLUMN:
code = mndDropSuperTableTag(pOld, &stbObj, pAlter->pSchemas[0].name);
break;
case TSDB_ALTER_TABLE_UPDATE_TAG_NAME:
code = mndAlterStbTagName(pOld, &stbObj, pAlter->pSchemas[0].name, pAlter->pSchemas[1].name);
break;
case TSDB_ALTER_TABLE_UPDATE_TAG_BYTES:
code = mndAlterStbTagBytes(pOld, &stbObj, &pAlter->pSchemas[0]);
break;
case TSDB_ALTER_TABLE_ADD_COLUMN:
code = mndAddSuperTableColumn(pOld, &stbObj, pAlter->pSchemas, 1);
break;
case TSDB_ALTER_TABLE_DROP_COLUMN:
code = mndDropSuperTableColumn(pOld, &stbObj, pAlter->pSchemas[0].name);
break;
case TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES:
code = mndAlterStbColumnBytes(pOld, &stbObj, &pAlter->pSchemas[0]);
break;
default:
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
break;
}
if (code != 0) goto ALTER_STB_OVER;
code = -1;
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, &pReq->rpcMsg);
if (pTrans == NULL) goto ALTER_STB_OVER;
mDebug("trans:%d, used to alter stb:%s", pTrans->id, pAlter->name);
if (mndSetAlterStbRedoLogs(pMnode, pTrans, pDb, &stbObj) != 0) goto ALTER_STB_OVER;
if (mndSetAlterStbCommitLogs(pMnode, pTrans, pDb, &stbObj) != 0) goto ALTER_STB_OVER;
if (mndSetAlterStbRedoActions(pMnode, pTrans, pDb, &stbObj) != 0) goto ALTER_STB_OVER;
if (mndTransPrepare(pMnode, pTrans) != 0) goto ALTER_STB_OVER;
code = 0;
ALTER_STB_OVER:
mndTransDrop(pTrans);
tfree(stbObj.pTags);
tfree(stbObj.pColumns);
return code;
}
static int32_t mndProcessMAlterStbReq(SMnodeMsg *pReq) {
SMnode *pMnode = pReq->pMnode;
SMAlterStbReq *pAlter = pReq->rpcMsg.pCont;
SMnode *pMnode = pReq->pMnode;
SMAltertbReq *pAlter = pReq->rpcMsg.pCont;
mDebug("stb:%s, start to alter", pAlter->name);
......@@ -582,10 +982,15 @@ static int32_t mndProcessMAlterStbReq(SMnodeMsg *pReq) {
return -1;
}
SStbObj stbObj = {0};
memcpy(&stbObj, pStb, sizeof(SStbObj));
SDbObj *pDb = mndAcquireDbByStb(pMnode, pAlter->name);
if (pDb == NULL) {
mndReleaseStb(pMnode, pStb);
terrno = TSDB_CODE_MND_DB_NOT_SELECTED;
mError("stb:%s, failed to alter since %s", pAlter->name, terrstr());
return -1;
}
int32_t code = mndUpdateStb(pMnode, pReq, pStb, &stbObj);
int32_t code = mndAlterStb(pMnode, pReq, pAlter, pDb, pStb);
mndReleaseStb(pMnode, pStb);
if (code != 0) {
......@@ -770,14 +1175,24 @@ static int32_t mndProcessStbMetaReq(SMnodeMsg *pReq) {
pMeta->suid = htobe64(pStb->uid);
pMeta->tuid = htobe64(pStb->uid);
for (int32_t i = 0; i < totalCols; ++i) {
for (int32_t i = 0; i < pStb->numOfColumns; ++i) {
SSchema *pSchema = &pMeta->pSchema[i];
SSchema *pSrcSchema = &pStb->pSchema[i];
SSchema *pSrcSchema = &pStb->pColumns[i];
memcpy(pSchema->name, pSrcSchema->name, TSDB_COL_NAME_LEN);
pSchema->type = pSrcSchema->type;
pSchema->colId = htonl(pSrcSchema->colId);
pSchema->bytes = htonl(pSrcSchema->bytes);
}
for (int32_t i = 0; i < pStb->numOfTags; ++i) {
SSchema *pSchema = &pMeta->pSchema[i + pStb->numOfColumns];
SSchema *pSrcSchema = &pStb->pTags[i];
memcpy(pSchema->name, pSrcSchema->name, TSDB_COL_NAME_LEN);
pSchema->type = pSrcSchema->type;
pSchema->colId = htonl(pSrcSchema->colId);
pSchema->bytes = htonl(pSrcSchema->bytes);
}
taosRUnLockLatch(&pStb->lock);
mndReleaseDb(pMnode, pDb);
mndReleaseStb(pMnode, pStb);
......@@ -790,11 +1205,11 @@ static int32_t mndProcessStbMetaReq(SMnodeMsg *pReq) {
}
int32_t mndValidateStbInfo(SMnode *pMnode, SSTableMetaVersion *stbs, int32_t num, void **rsp, int32_t *rspLen) {
SSdb *pSdb = pMnode->pSdb;
int32_t bufSize = num * (sizeof(STableMetaRsp) + 4 * sizeof(SSchema));
void *buf = malloc(bufSize);
int32_t len = 0;
int32_t contLen = 0;
SSdb *pSdb = pMnode->pSdb;
int32_t bufSize = num * (sizeof(STableMetaRsp) + 4 * sizeof(SSchema));
void *buf = malloc(bufSize);
int32_t len = 0;
int32_t contLen = 0;
STableMetaRsp *pRsp = NULL;
for (int32_t i = 0; i < num; ++i) {
......@@ -804,7 +1219,7 @@ int32_t mndValidateStbInfo(SMnode *pMnode, SSTableMetaVersion *stbs, int32_t num
stb->tversion = ntohs(stb->tversion);
if ((contLen + sizeof(STableMetaRsp)) > bufSize) {
bufSize = contLen + (num -i) * (sizeof(STableMetaRsp) + 4 * sizeof(SSchema));
bufSize = contLen + (num - i) * (sizeof(STableMetaRsp) + 4 * sizeof(SSchema));
buf = realloc(buf, bufSize);
}
......@@ -813,9 +1228,9 @@ int32_t mndValidateStbInfo(SMnode *pMnode, SSTableMetaVersion *stbs, int32_t num
strcpy(pRsp->dbFName, stb->dbFName);
strcpy(pRsp->tbName, stb->stbName);
strcpy(pRsp->stbName, stb->stbName);
mDebug("start to retrieve meta, db:%s, stb:%s", stb->dbFName, stb->stbName);
SDbObj *pDb = mndAcquireDb(pMnode, stb->dbFName);
if (pDb == NULL) {
pRsp->numOfColumns = -1;
......@@ -827,7 +1242,7 @@ int32_t mndValidateStbInfo(SMnode *pMnode, SSTableMetaVersion *stbs, int32_t num
char tbFName[TSDB_TABLE_FNAME_LEN] = {0};
snprintf(tbFName, sizeof(tbFName), "%s.%s", stb->dbFName, stb->stbName);
SStbObj *pStb = mndAcquireStb(pMnode, tbFName);
if (pStb == NULL) {
mndReleaseDb(pMnode, pDb);
......@@ -837,7 +1252,7 @@ int32_t mndValidateStbInfo(SMnode *pMnode, SSTableMetaVersion *stbs, int32_t num
mWarn("stb:%s, failed to get meta since %s", tbFName, terrstr());
continue;
}
taosRLockLatch(&pStb->lock);
if (stb->suid == pStb->uid && stb->sversion == pStb->version) {
......@@ -846,17 +1261,17 @@ int32_t mndValidateStbInfo(SMnode *pMnode, SSTableMetaVersion *stbs, int32_t num
mndReleaseStb(pMnode, pStb);
continue;
}
int32_t totalCols = pStb->numOfColumns + pStb->numOfTags;
int32_t len = totalCols * sizeof(SSchema);
contLen += sizeof(STableMetaRsp) + len;
if (contLen > bufSize) {
bufSize = contLen + (num -i - 1) * (sizeof(STableMetaRsp) + 4 * sizeof(SSchema));
bufSize = contLen + (num - i - 1) * (sizeof(STableMetaRsp) + 4 * sizeof(SSchema));
buf = realloc(buf, bufSize);
}
pRsp->numOfTags = htonl(pStb->numOfTags);
pRsp->numOfColumns = htonl(pStb->numOfColumns);
pRsp->precision = pDb->cfg.precision;
......@@ -865,15 +1280,25 @@ int32_t mndValidateStbInfo(SMnode *pMnode, SSTableMetaVersion *stbs, int32_t num
pRsp->sversion = htonl(pStb->version);
pRsp->suid = htobe64(pStb->uid);
pRsp->tuid = htobe64(pStb->uid);
for (int32_t i = 0; i < totalCols; ++i) {
for (int32_t i = 0; i < pStb->numOfColumns; ++i) {
SSchema *pSchema = &pRsp->pSchema[i];
SSchema *pSrcSchema = &pStb->pSchema[i];
SSchema *pSrcSchema = &pStb->pColumns[i];
memcpy(pSchema->name, pSrcSchema->name, TSDB_COL_NAME_LEN);
pSchema->type = pSrcSchema->type;
pSchema->colId = htonl(pSrcSchema->colId);
pSchema->bytes = htonl(pSrcSchema->bytes);
}
for (int32_t i = 0; i < pStb->numOfTags; ++i) {
SSchema *pSchema = &pRsp->pSchema[i + pStb->numOfColumns];
SSchema *pSrcSchema = &pStb->pTags[i];
memcpy(pSchema->name, pSrcSchema->name, TSDB_COL_NAME_LEN);
pSchema->type = pSrcSchema->type;
pSchema->colId = htonl(pSrcSchema->colId);
pSchema->bytes = htonl(pSrcSchema->bytes);
}
taosRUnLockLatch(&pStb->lock);
mndReleaseDb(pMnode, pDb);
mndReleaseStb(pMnode, pStb);
......@@ -891,7 +1316,6 @@ int32_t mndValidateStbInfo(SMnode *pMnode, SSTableMetaVersion *stbs, int32_t num
return 0;
}
static int32_t mndGetNumOfStbs(SMnode *pMnode, char *dbName, int32_t *pNumOfStbs) {
SSdb *pSdb = pMnode->pSdb;
......
......@@ -21,213 +21,289 @@ class MndTestStb : public ::testing::Test {
public:
void SetUp() override {}
void TearDown() override {}
SCreateDbReq* BuildCreateDbReq(const char* dbname, int32_t* pContLen);
SMCreateStbReq* BuildCreateStbReq(const char* stbname, int32_t* pContLen);
SMAltertbReq* BuildAlterStbAddTagReq(const char* stbname, int32_t* pContLen);
};
Testbase MndTestStb::test;
TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
SCreateDbReq* MndTestStb::BuildCreateDbReq(const char* dbname, int32_t* pContLen) {
int32_t contLen = sizeof(SCreateDbReq);
SCreateDbReq* pReq = (SCreateDbReq*)rpcMallocCont(contLen);
strcpy(pReq->db, dbname);
pReq->numOfVgroups = htonl(2);
pReq->cacheBlockSize = htonl(16);
pReq->totalBlocks = htonl(10);
pReq->daysPerFile = htonl(10);
pReq->daysToKeep0 = htonl(3650);
pReq->daysToKeep1 = htonl(3650);
pReq->daysToKeep2 = htonl(3650);
pReq->minRows = htonl(100);
pReq->maxRows = htonl(4096);
pReq->commitTime = htonl(3600);
pReq->fsyncPeriod = htonl(3000);
pReq->walLevel = 1;
pReq->precision = 0;
pReq->compression = 2;
pReq->replications = 1;
pReq->quorum = 1;
pReq->update = 0;
pReq->cacheLastRow = 0;
pReq->ignoreExist = 1;
*pContLen = contLen;
return pReq;
}
SMCreateStbReq* MndTestStb::BuildCreateStbReq(const char *stbname, int32_t* pContLen) {
int32_t cols = 2;
int32_t tags = 3;
int32_t contLen = (tags + cols) * sizeof(SSchema) + sizeof(SMCreateStbReq);
SMCreateStbReq* pReq = (SMCreateStbReq*)rpcMallocCont(contLen);
strcpy(pReq->name, stbname);
pReq->numOfTags = htonl(tags);
pReq->numOfColumns = htonl(cols);
{
int32_t contLen = sizeof(SCreateDbReq);
SCreateDbReq* pReq = (SCreateDbReq*)rpcMallocCont(contLen);
strcpy(pReq->db, "1.d1");
pReq->numOfVgroups = htonl(2);
pReq->cacheBlockSize = htonl(16);
pReq->totalBlocks = htonl(10);
pReq->daysPerFile = htonl(10);
pReq->daysToKeep0 = htonl(3650);
pReq->daysToKeep1 = htonl(3650);
pReq->daysToKeep2 = htonl(3650);
pReq->minRows = htonl(100);
pReq->maxRows = htonl(4096);
pReq->commitTime = htonl(3600);
pReq->fsyncPeriod = htonl(3000);
pReq->walLevel = 1;
pReq->precision = 0;
pReq->compression = 2;
pReq->replications = 1;
pReq->quorum = 1;
pReq->update = 0;
pReq->cacheLastRow = 0;
pReq->ignoreExist = 1;
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, 0);
SSchema* pSchema = &pReq->pSchemas[0];
pSchema->bytes = htonl(8);
pSchema->type = TSDB_DATA_TYPE_TIMESTAMP;
strcpy(pSchema->name, "ts");
}
{
int32_t cols = 2;
int32_t tags = 3;
int32_t contLen = (tags + cols) * sizeof(SSchema) + sizeof(SMCreateStbReq);
SMCreateStbReq* pReq = (SMCreateStbReq*)rpcMallocCont(contLen);
strcpy(pReq->name, "1.d1.stb");
pReq->numOfTags = htonl(tags);
pReq->numOfColumns = htonl(cols);
{
SSchema* pSchema = &pReq->pSchema[0];
pSchema->bytes = htonl(8);
pSchema->type = TSDB_DATA_TYPE_TIMESTAMP;
strcpy(pSchema->name, "ts");
}
{
SSchema* pSchema = &pReq->pSchema[1];
pSchema->bytes = htonl(4);
pSchema->type = TSDB_DATA_TYPE_INT;
strcpy(pSchema->name, "col1");
}
{
SSchema* pSchema = &pReq->pSchema[2];
pSchema->bytes = htonl(2);
pSchema->type = TSDB_DATA_TYPE_TINYINT;
strcpy(pSchema->name, "tag1");
}
{
SSchema* pSchema = &pReq->pSchema[3];
pSchema->bytes = htonl(8);
pSchema->type = TSDB_DATA_TYPE_BIGINT;
strcpy(pSchema->name, "tag2");
}
{
SSchema* pSchema = &pReq->pSchema[4];
pSchema->bytes = htonl(16);
pSchema->type = TSDB_DATA_TYPE_BINARY;
strcpy(pSchema->name, "tag3");
}
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_STB, pReq, contLen);
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, 0);
SSchema* pSchema = &pReq->pSchemas[1];
pSchema->bytes = htonl(4);
pSchema->type = TSDB_DATA_TYPE_INT;
strcpy(pSchema->name, "col1");
}
test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, "1.d1");
CHECK_META("show stables", 4);
CHECK_SCHEMA(0, TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE, "name");
CHECK_SCHEMA(1, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time");
CHECK_SCHEMA(2, TSDB_DATA_TYPE_INT, 4, "columns");
CHECK_SCHEMA(3, TSDB_DATA_TYPE_INT, 4, "tags");
{
SSchema* pSchema = &pReq->pSchemas[2];
pSchema->bytes = htonl(2);
pSchema->type = TSDB_DATA_TYPE_TINYINT;
strcpy(pSchema->name, "tag1");
}
test.SendShowRetrieveReq();
EXPECT_EQ(test.GetShowRows(), 1);
CheckBinary("stb", TSDB_TABLE_NAME_LEN);
CheckTimestamp();
CheckInt32(2);
CheckInt32(3);
{
SSchema* pSchema = &pReq->pSchemas[3];
pSchema->bytes = htonl(8);
pSchema->type = TSDB_DATA_TYPE_BIGINT;
strcpy(pSchema->name, "tag2");
}
// ----- meta ------
{
int32_t contLen = sizeof(STableInfoReq);
STableInfoReq* pReq = (STableInfoReq*)rpcMallocCont(contLen);
strcpy(pReq->dbFName, "1.d1");
strcpy(pReq->tbName, "stb");
SRpcMsg* pMsg = test.SendReq(TDMT_MND_STB_META, pReq, contLen);
ASSERT_NE(pMsg, nullptr);
ASSERT_EQ(pMsg->code, 0);
STableMetaRsp* pRsp = (STableMetaRsp*)pMsg->pCont;
pRsp->numOfTags = htonl(pRsp->numOfTags);
pRsp->numOfColumns = htonl(pRsp->numOfColumns);
pRsp->sversion = htonl(pRsp->sversion);
pRsp->tversion = htonl(pRsp->tversion);
pRsp->suid = be64toh(pRsp->suid);
pRsp->tuid = be64toh(pRsp->tuid);
pRsp->vgId = be64toh(pRsp->vgId);
for (int32_t i = 0; i < pRsp->numOfTags + pRsp->numOfColumns; ++i) {
SSchema* pSchema = &pRsp->pSchema[i];
pSchema->colId = htonl(pSchema->colId);
pSchema->bytes = htonl(pSchema->bytes);
}
EXPECT_STREQ(pRsp->dbFName, "1.d1");
EXPECT_STREQ(pRsp->tbName, "stb");
EXPECT_STREQ(pRsp->stbName, "stb");
EXPECT_EQ(pRsp->numOfColumns, 2);
EXPECT_EQ(pRsp->numOfTags, 3);
EXPECT_EQ(pRsp->precision, TSDB_TIME_PRECISION_MILLI);
EXPECT_EQ(pRsp->tableType, TSDB_SUPER_TABLE);
EXPECT_EQ(pRsp->update, 0);
EXPECT_EQ(pRsp->sversion, 1);
EXPECT_EQ(pRsp->tversion, 0);
EXPECT_GT(pRsp->suid, 0);
EXPECT_GT(pRsp->tuid, 0);
EXPECT_EQ(pRsp->vgId, 0);
{
SSchema* pSchema = &pRsp->pSchema[0];
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_TIMESTAMP);
EXPECT_EQ(pSchema->colId, 1);
EXPECT_EQ(pSchema->bytes, 8);
EXPECT_STREQ(pSchema->name, "ts");
}
{
SSchema* pSchema = &pRsp->pSchema[1];
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_INT);
EXPECT_EQ(pSchema->colId, 2);
EXPECT_EQ(pSchema->bytes, 4);
EXPECT_STREQ(pSchema->name, "col1");
}
{
SSchema* pSchema = &pRsp->pSchema[2];
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_TINYINT);
EXPECT_EQ(pSchema->colId, 3);
EXPECT_EQ(pSchema->bytes, 2);
EXPECT_STREQ(pSchema->name, "tag1");
}
{
SSchema* pSchema = &pRsp->pSchema[3];
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_BIGINT);
EXPECT_EQ(pSchema->colId, 4);
EXPECT_EQ(pSchema->bytes, 8);
EXPECT_STREQ(pSchema->name, "tag2");
}
{
SSchema* pSchema = &pRsp->pSchema[4];
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_BINARY);
EXPECT_EQ(pSchema->colId, 5);
EXPECT_EQ(pSchema->bytes, 16);
EXPECT_STREQ(pSchema->name, "tag3");
}
SSchema* pSchema = &pReq->pSchemas[4];
pSchema->bytes = htonl(16);
pSchema->type = TSDB_DATA_TYPE_BINARY;
strcpy(pSchema->name, "tag3");
}
// restart
test.Restart();
*pContLen = contLen;
return pReq;
}
test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, "1.d1");
CHECK_META("show stables", 4);
test.SendShowRetrieveReq();
EXPECT_EQ(test.GetShowRows(), 1);
// TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
// const char *dbname = "1.d1";
// const char *stbname = "1.d1.stb";
// {
// int32_t contLen = 0;
// SCreateDbReq* pReq = BuildCreateDbReq(dbname, &contLen);
// SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
// ASSERT_NE(pRsp, nullptr);
// ASSERT_EQ(pRsp->code, 0);
// }
// {
// int32_t contLen = 0;
// SMCreateStbReq* pReq = BuildCreateStbReq(stbname, &contLen);
// SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_STB, pReq, contLen);
// ASSERT_NE(pRsp, nullptr);
// ASSERT_EQ(pRsp->code, 0);
// }
// {
// test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname);
// CHECK_META("show stables", 4);
// CHECK_SCHEMA(0, TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE, "name");
// CHECK_SCHEMA(1, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time");
// CHECK_SCHEMA(2, TSDB_DATA_TYPE_INT, 4, "columns");
// CHECK_SCHEMA(3, TSDB_DATA_TYPE_INT, 4, "tags");
// test.SendShowRetrieveReq();
// EXPECT_EQ(test.GetShowRows(), 1);
// CheckBinary("stb", TSDB_TABLE_NAME_LEN);
// CheckTimestamp();
// CheckInt32(2);
// CheckInt32(3);
// }
// // ----- meta ------
// {
// int32_t contLen = sizeof(STableInfoReq);
// STableInfoReq* pReq = (STableInfoReq*)rpcMallocCont(contLen);
// strcpy(pReq->dbFName, dbname);
// strcpy(pReq->tbName, "stb");
// SRpcMsg* pMsg = test.SendReq(TDMT_MND_STB_META, pReq, contLen);
// ASSERT_NE(pMsg, nullptr);
// ASSERT_EQ(pMsg->code, 0);
// STableMetaRsp* pRsp = (STableMetaRsp*)pMsg->pCont;
// pRsp->numOfTags = htonl(pRsp->numOfTags);
// pRsp->numOfColumns = htonl(pRsp->numOfColumns);
// pRsp->sversion = htonl(pRsp->sversion);
// pRsp->tversion = htonl(pRsp->tversion);
// pRsp->suid = be64toh(pRsp->suid);
// pRsp->tuid = be64toh(pRsp->tuid);
// pRsp->vgId = be64toh(pRsp->vgId);
// for (int32_t i = 0; i < pRsp->numOfTags + pRsp->numOfColumns; ++i) {
// SSchema* pSchema = &pRsp->pSchema[i];
// pSchema->colId = htonl(pSchema->colId);
// pSchema->bytes = htonl(pSchema->bytes);
// }
// EXPECT_STREQ(pRsp->dbFName, dbname);
// EXPECT_STREQ(pRsp->tbName, "stb");
// EXPECT_STREQ(pRsp->stbName, "stb");
// EXPECT_EQ(pRsp->numOfColumns, 2);
// EXPECT_EQ(pRsp->numOfTags, 3);
// EXPECT_EQ(pRsp->precision, TSDB_TIME_PRECISION_MILLI);
// EXPECT_EQ(pRsp->tableType, TSDB_SUPER_TABLE);
// EXPECT_EQ(pRsp->update, 0);
// EXPECT_EQ(pRsp->sversion, 1);
// EXPECT_EQ(pRsp->tversion, 0);
// EXPECT_GT(pRsp->suid, 0);
// EXPECT_GT(pRsp->tuid, 0);
// EXPECT_EQ(pRsp->vgId, 0);
// {
// SSchema* pSchema = &pRsp->pSchema[0];
// EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_TIMESTAMP);
// EXPECT_EQ(pSchema->colId, 1);
// EXPECT_EQ(pSchema->bytes, 8);
// EXPECT_STREQ(pSchema->name, "ts");
// }
// {
// SSchema* pSchema = &pRsp->pSchema[1];
// EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_INT);
// EXPECT_EQ(pSchema->colId, 2);
// EXPECT_EQ(pSchema->bytes, 4);
// EXPECT_STREQ(pSchema->name, "col1");
// }
// {
// SSchema* pSchema = &pRsp->pSchema[2];
// EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_TINYINT);
// EXPECT_EQ(pSchema->colId, 3);
// EXPECT_EQ(pSchema->bytes, 2);
// EXPECT_STREQ(pSchema->name, "tag1");
// }
// {
// SSchema* pSchema = &pRsp->pSchema[3];
// EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_BIGINT);
// EXPECT_EQ(pSchema->colId, 4);
// EXPECT_EQ(pSchema->bytes, 8);
// EXPECT_STREQ(pSchema->name, "tag2");
// }
// {
// SSchema* pSchema = &pRsp->pSchema[4];
// EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_BINARY);
// EXPECT_EQ(pSchema->colId, 5);
// EXPECT_EQ(pSchema->bytes, 16);
// EXPECT_STREQ(pSchema->name, "tag3");
// }
// }
// // restart
// test.Restart();
// {
// test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname);
// CHECK_META("show stables", 4);
// test.SendShowRetrieveReq();
// EXPECT_EQ(test.GetShowRows(), 1);
// CheckBinary("stb", TSDB_TABLE_NAME_LEN);
// CheckTimestamp();
// CheckInt32(2);
// CheckInt32(3);
// }
// {
// int32_t contLen = sizeof(SMDropStbReq);
// SMDropStbReq* pReq = (SMDropStbReq*)rpcMallocCont(contLen);
// strcpy(pReq->name, stbname);
// SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_STB, pReq, contLen);
// ASSERT_NE(pRsp, nullptr);
// ASSERT_EQ(pRsp->code, 0);
// }
// test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname);
// CHECK_META("show stables", 4);
// test.SendShowRetrieveReq();
// EXPECT_EQ(test.GetShowRows(), 0);
// }
SMAltertbReq* MndTestStb::BuildAlterStbAddTagReq(const char* stbname, int32_t* pContLen) {
int32_t contLen = sizeof(SMAltertbReq) + sizeof(SSchema);
SMAltertbReq* pReq = (SMAltertbReq*)rpcMallocCont(contLen);
strcpy(pReq->name, stbname);
pReq->numOfSchemas = htonl(1);
pReq->alterType = TSDB_ALTER_TABLE_ADD_TAG_COLUMN;
SSchema* pSchema = &pReq->pSchemas[0];
pSchema->bytes = htonl(4);
pSchema->type = TSDB_DATA_TYPE_INT;
strcpy(pSchema->name, "tag4");
*pContLen = contLen;
return pReq;
}
CheckBinary("stb", TSDB_TABLE_NAME_LEN);
CheckTimestamp();
CheckInt32(2);
CheckInt32(3);
TEST_F(MndTestStb, 01_Alter_Stb) {
const char *dbname = "1.d2";
const char *stbname = "1.d2.stb";
{
int32_t contLen = sizeof(SMDropStbReq);
SMDropStbReq* pReq = (SMDropStbReq*)rpcMallocCont(contLen);
strcpy(pReq->name, "1.d1.stb");
int32_t contLen = 0;
SCreateDbReq* pReq = BuildCreateDbReq(dbname, &contLen);
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, 0);
}
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_STB, pReq, contLen);
{
int32_t contLen = 0;
SMCreateStbReq* pReq = BuildCreateStbReq(stbname, &contLen);
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_STB, pReq, contLen);
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, 0);
}
test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, "1.d1");
CHECK_META("show stables", 4);
test.SendShowRetrieveReq();
EXPECT_EQ(test.GetShowRows(), 0);
{
int32_t contLen = 0;
SMAltertbReq* pReq = BuildAlterStbAddTagReq(stbname, &contLen);
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, 0);
test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname);
test.SendShowRetrieveReq();
EXPECT_EQ(test.GetShowRows(), 1);
CheckBinary("stb", TSDB_TABLE_NAME_LEN);
CheckTimestamp();
CheckInt32(2);
CheckInt32(4);
}
}
......@@ -1327,7 +1327,7 @@ static int tsdbMergeMemData(SCommitH *pCommith, SCommitIter *pIter, int bidx) {
int nBlocks = pCommith->readh.pBlkIdx->numOfBlocks;
SBlock * pBlock = pCommith->readh.pBlkInfo->blocks + bidx;
TSKEY keyLimit;
int16_t colId = 0;
int16_t colId = PRIMARYKEY_TIMESTAMP_COL_ID;
SMergeInfo mInfo;
SBlock subBlocks[TSDB_MAX_SUBBLOCKS];
SBlock block, supBlock;
......
......@@ -472,7 +472,7 @@ static int tsdbLoadBlockDataImpl(SReadH *pReadh, SBlock *pBlock, SDataCols *pDat
continue;
}
int16_t tcolId = 0;
int16_t tcolId = PRIMARYKEY_TIMESTAMP_COL_ID;
uint32_t toffset = TSDB_KEY_COL_OFFSET;
int32_t tlen = pBlock->keyLen;
......
......@@ -185,6 +185,7 @@ static void vBufPoolDestroyMA(SMemAllocatorFactory *pMAF, SMemAllocator *pMA) {
free(pMA);
if (--pVMA->_ref.val == 0) {
TD_DLIST_POP(&(pVnode->pBufPool->incycle), pVMA);
vmaReset(pVMA);
TD_DLIST_APPEND(&(pVnode->pBufPool->free), pVMA);
}
}
\ No newline at end of file
......@@ -83,7 +83,7 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
free(vCreateTbReq.name);
break;
case TDMT_VND_CREATE_TABLE:
tSVCreateTbBatchReqDeserialize(POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)), &vCreateTbBatchReq);
tDeserializeSVCreateTbBatchReq(POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)), &vCreateTbBatchReq);
for (int i = 0; i < taosArrayGetSize(vCreateTbBatchReq.pArray); i++) {
SVCreateTbReq *pCreateTbReq = taosArrayGet(vCreateTbBatchReq.pArray, i);
if (metaCreateTable(pVnode->pMeta, pCreateTbReq) < 0) {
......@@ -106,7 +106,11 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
break;
case TDMT_VND_ALTER_STB:
vTrace("vgId:%d, process drop stb req", pVnode->vgId);
vTrace("vgId:%d, process alter stb req", pVnode->vgId);
tDeserializeSVCreateTbReq(POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)), &vCreateTbReq);
free(vCreateTbReq.stbCfg.pSchema);
free(vCreateTbReq.stbCfg.pTagSchema);
free(vCreateTbReq.name);
break;
case TDMT_VND_DROP_STB:
vTrace("vgId:%d, process drop stb req", pVnode->vgId);
......
......@@ -28,7 +28,6 @@ typedef struct SAstCreateContext {
bool notSupport;
bool valid;
SNode* pRootNode;
SHashObj* pResourceHash;
} SAstCreateContext;
int32_t createAstCreateContext(SParseContext* pQueryCxt, SAstCreateContext* pCxt);
......
......@@ -13,11 +13,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "nodes.h"
#include "nodesShowStmts.h"
#include "astCreateContext.h"
#include "ttoken.h"
#ifndef _TD_AST_CREATE_FUNCS_H_
#define _TD_AST_CREATE_FUNCS_H_
......@@ -25,15 +20,26 @@
extern "C" {
#endif
#include "nodes.h"
#include "nodesShowStmts.h"
#include "astCreateContext.h"
#include "ttoken.h"
extern SToken nil_token;
typedef struct STargetExprNode {
ENodeType nodeType;
char* p;
uint32_t n;
SNode* pNode;
} STargetExprNode;
SNodeList* createNodeList(SAstCreateContext* pCxt, SNode* pNode);
SNodeList* addNodeToList(SAstCreateContext* pCxt, SNodeList* pList, SNode* pNode);
SNode* createColumnNode(SAstCreateContext* pCxt, const SToken* pTableName, const SToken* pColumnName);
SNode* createColumnNode(SAstCreateContext* pCxt, const SToken* pTableAlias, const SToken* pColumnName);
SNode* createValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken* pLiteral);
SNode* createDurationValueNode(SAstCreateContext* pCxt, const SToken* pLiteral);
SNode* addMinusSign(SAstCreateContext* pCxt, SNode* pNode);
SNode* setProjectionAlias(SAstCreateContext* pCxt, SNode* pNode, const SToken* pAlias);
SNode* createLogicConditionNode(SAstCreateContext* pCxt, ELogicConditionType type, SNode* pParam1, SNode* pParam2);
SNode* createOperatorNode(SAstCreateContext* pCxt, EOperatorType type, SNode* pLeft, SNode* pRight);
......
......@@ -187,7 +187,7 @@ table_reference(A) ::= joined_table(B).
table_primary(A) ::= table_name(B) alias_opt(C). { PARSER_TRACE; A = createRealTableNode(pCxt, NULL, &B, &C); }
table_primary(A) ::= db_name(B) NK_DOT table_name(C) alias_opt(D). { PARSER_TRACE; A = createRealTableNode(pCxt, &B, &C, &D); }
table_primary(A) ::= subquery(B) alias_opt(C). { PARSER_TRACE; A = createTempTableNode(pCxt, B, &C); }
table_primary ::= parenthesized_joined_table.
table_primary(A) ::= parenthesized_joined_table(B). { PARSER_TRACE; A = B; }
%type alias_opt { SToken }
%destructor alias_opt { PARSER_DESTRUCTOR_TRACE; }
......@@ -297,9 +297,9 @@ query_expression_body(A) ::=
query_expression_body(B) UNION ALL query_expression_body(D). { PARSER_TRACE; A = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, B, D); }
query_primary(A) ::= query_specification(B). { PARSER_TRACE; A = B; }
query_primary(A) ::=
NK_LP query_expression_body(B)
order_by_clause_opt limit_clause_opt slimit_clause_opt NK_RP. { PARSER_TRACE; A = B;}
//query_primary(A) ::=
// NK_LP query_expression_body(B)
// order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP. { PARSER_TRACE; A = B;}
%type order_by_clause_opt { SNodeList* }
%destructor order_by_clause_opt { PARSER_DESTRUCTOR_TRACE; nodesDestroyList($$); }
......@@ -317,7 +317,7 @@ limit_clause_opt(A) ::= LIMIT NK_INTEGER(B) OFFSET NK_INTEGER(C).
limit_clause_opt(A) ::= LIMIT NK_INTEGER(C) NK_COMMA NK_INTEGER(B). { PARSER_TRACE; A = createLimitNode(pCxt, &B, &C); }
/************************************************ subquery ************************************************************/
subquery(A) ::= NK_LR query_expression(B) NK_RP. { PARSER_TRACE; A = B; }
subquery(A) ::= NK_LP query_expression(B) NK_RP. { PARSER_TRACE; A = B; }
/************************************************ search_condition ****************************************************/
search_condition(A) ::= boolean_value_expression(B). { PARSER_TRACE; A = B; }
......
......@@ -28,6 +28,7 @@ typedef struct SQuery {
} SQuery;
int32_t doParse(SParseContext* pParseCxt, SQuery* pQuery);
int32_t doTranslate(SParseContext* pParseCxt, SQuery* pQuery);
#ifdef __cplusplus
}
......
......@@ -813,7 +813,7 @@ cmd ::= ALTER TABLE ids(X) cpxName(F) DROP COLUMN ids(A). {
cmd ::= ALTER TABLE ids(X) cpxName(F) MODIFY COLUMN columnlist(A). {
X.n += F.n;
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&X, A, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, -1);
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&X, A, NULL, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, -1);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
......@@ -842,7 +842,7 @@ cmd ::= ALTER TABLE ids(X) cpxName(F) CHANGE TAG ids(Y) ids(Z). {
toTSDBType(Z.type);
A = tListItemAppendToken(A, &Z, -1);
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&X, NULL, A, TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN, -1);
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&X, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, -1);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
......@@ -859,7 +859,7 @@ cmd ::= ALTER TABLE ids(X) cpxName(F) SET TAG ids(Y) EQ tagitem(Z). {
cmd ::= ALTER TABLE ids(X) cpxName(F) MODIFY TAG columnlist(A). {
X.n += F.n;
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&X, A, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, -1);
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&X, A, NULL, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, -1);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
......@@ -882,7 +882,7 @@ cmd ::= ALTER STABLE ids(X) cpxName(F) DROP COLUMN ids(A). {
cmd ::= ALTER STABLE ids(X) cpxName(F) MODIFY COLUMN columnlist(A). {
X.n += F.n;
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&X, A, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, TSDB_SUPER_TABLE);
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&X, A, NULL, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
......@@ -911,7 +911,7 @@ cmd ::= ALTER STABLE ids(X) cpxName(F) CHANGE TAG ids(Y) ids(Z). {
toTSDBType(Z.type);
A = tListItemAppendToken(A, &Z, -1);
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&X, NULL, A, TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN, TSDB_SUPER_TABLE);
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&X, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
......@@ -928,7 +928,7 @@ cmd ::= ALTER STABLE ids(X) cpxName(F) SET TAG ids(Y) EQ tagitem(Z). {
cmd ::= ALTER STABLE ids(X) cpxName(F) MODIFY TAG columnlist(A). {
X.n += F.n;
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&X, A, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, TSDB_SUPER_TABLE);
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&X, A, NULL, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
......
......@@ -60,14 +60,14 @@ SNodeList* addNodeToList(SAstCreateContext* pCxt, SNodeList* pList, SNode* pNode
return nodesListAppend(pList, pNode);
}
SNode* createColumnNode(SAstCreateContext* pCxt, const SToken* pTableName, const SToken* pColumnName) {
if (!checkTableName(pCxt, pTableName) || !checkColumnName(pCxt, pColumnName)) {
SNode* createColumnNode(SAstCreateContext* pCxt, const SToken* pTableAlias, const SToken* pColumnName) {
if (!checkTableName(pCxt, pTableAlias) || !checkColumnName(pCxt, pColumnName)) {
return NULL;
}
SColumnNode* col = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
CHECK_OUT_OF_MEM(col);
if (NULL != pTableName) {
strncpy(col->tableName, pTableName->z, pTableName->n);
if (NULL != pTableAlias) {
strncpy(col->tableAlias, pTableAlias->z, pTableAlias->n);
}
strncpy(col->colName, pColumnName->z, pColumnName->n);
return (SNode*)col;
......@@ -76,7 +76,10 @@ SNode* createColumnNode(SAstCreateContext* pCxt, const SToken* pTableName, const
SNode* createValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken* pLiteral) {
SValueNode* val = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
CHECK_OUT_OF_MEM(val);
// todo
val->literal = strndup(pLiteral->z, pLiteral->n);
CHECK_OUT_OF_MEM(val->literal);
val->node.resType.type = dataType;
val->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes;
return (SNode*)val;
}
......@@ -87,10 +90,6 @@ SNode* createDurationValueNode(SAstCreateContext* pCxt, const SToken* pLiteral)
return (SNode*)val;
}
SNode* addMinusSign(SAstCreateContext* pCxt, SNode* pNode) {
// todo
}
SNode* createLogicConditionNode(SAstCreateContext* pCxt, ELogicConditionType type, SNode* pParam1, SNode* pParam2) {
SLogicConditionNode* cond = (SLogicConditionNode*)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION);
CHECK_OUT_OF_MEM(cond);
......@@ -151,6 +150,13 @@ SNode* createRealTableNode(SAstCreateContext* pCxt, const SToken* pDbName, const
CHECK_OUT_OF_MEM(realTable);
if (NULL != pDbName) {
strncpy(realTable->table.dbName, pDbName->z, pDbName->n);
} else {
strcpy(realTable->table.dbName, pCxt->pQueryCxt->db);
}
if (NULL != pTableAlias && TK_NIL != pTableAlias->type) {
strncpy(realTable->table.tableAlias, pTableAlias->z, pTableAlias->n);
} else {
strncpy(realTable->table.tableAlias, pTableName->z, pTableName->n);
}
strncpy(realTable->table.tableName, pTableName->z, pTableName->n);
return (SNode*)realTable;
......@@ -160,6 +166,9 @@ SNode* createTempTableNode(SAstCreateContext* pCxt, SNode* pSubquery, const STok
STempTableNode* tempTable = (STempTableNode*)nodesMakeNode(QUERY_NODE_TEMP_TABLE);
CHECK_OUT_OF_MEM(tempTable);
tempTable->pSubquery = pSubquery;
if (NULL != pTableAlias && TK_NIL != pTableAlias->type) {
strncpy(tempTable->table.tableAlias, pTableAlias->z, pTableAlias->n);
}
return (SNode*)tempTable;
}
......
......@@ -610,7 +610,7 @@ SAlterTableInfo *tSetAlterTableInfo(SToken *pTableName, SArray *pCols, SArray *p
pAlterTable->type = type;
pAlterTable->tableType = tableType;
if (type == TSDB_ALTER_TABLE_ADD_COLUMN || type == TSDB_ALTER_TABLE_ADD_TAG_COLUMN || type == TSDB_ALTER_TABLE_CHANGE_COLUMN || type == TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN) {
if (type == TSDB_ALTER_TABLE_ADD_COLUMN || type == TSDB_ALTER_TABLE_ADD_TAG_COLUMN || type == TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES || type == TSDB_ALTER_TABLE_UPDATE_TAG_BYTES) {
pAlterTable->pAddColumns = pCols;
assert(pVals == NULL);
} else {
......
......@@ -310,7 +310,7 @@ SMCreateStbReq* buildCreateStbMsg(SCreateTableSql* pCreateTableSql, int32_t* len
pCreateStbMsg->numOfColumns = htonl(numOfCols);
pCreateStbMsg->numOfTags = htonl(numOfTags);
pSchema = (SSchema*)pCreateStbMsg->pSchema;
pSchema = (SSchema*)pCreateStbMsg->pSchemas;
for (int i = 0; i < numOfCols; ++i) {
SField* pField = taosArrayGet(pCreateTableSql->colInfo.pColumns, i);
pSchema->type = pField->type;
......
......@@ -598,7 +598,7 @@ static int32_t doCheckAndBuildCreateCTableReq(SCreateTableSql* pCreateTable, SPa
}
static int32_t serializeVgroupTablesBatchImpl(SVgroupTablesBatch* pTbBatch, SArray* pBufArray) {
int tlen = sizeof(SMsgHead) + tSVCreateTbBatchReqSerialize(NULL, &(pTbBatch->req));
int tlen = sizeof(SMsgHead) + tSerializeSVCreateTbBatchReq(NULL, &(pTbBatch->req));
void* buf = malloc(tlen);
if (buf == NULL) {
// TODO: handle error
......@@ -608,7 +608,7 @@ static int32_t serializeVgroupTablesBatchImpl(SVgroupTablesBatch* pTbBatch, SArr
((SMsgHead*)buf)->contLen = htonl(tlen);
void* pBuf = POINTER_SHIFT(buf, sizeof(SMsgHead));
tSVCreateTbBatchReqSerialize(&pBuf, &(pTbBatch->req));
tSerializeSVCreateTbBatchReq(&pBuf, &(pTbBatch->req));
SVgDataBlocks* pVgData = calloc(1, sizeof(SVgDataBlocks));
pVgData->vg = pTbBatch->info;
......
......@@ -109,21 +109,21 @@
#endif
/************* Begin control #defines *****************************************/
#define YYCODETYPE unsigned char
#define YYNOCODE 125
#define YYNOCODE 124
#define YYACTIONTYPE unsigned short int
#define NewParseTOKENTYPE SToken
typedef union {
int yyinit;
NewParseTOKENTYPE yy0;
EOperatorType yy40;
EFillMode yy44;
SToken yy79;
ENullOrder yy107;
EJoinType yy162;
SNodeList* yy174;
EOrder yy188;
SNode* yy212;
bool yy237;
EOrder yy10;
EFillMode yy14;
SNode* yy168;
ENullOrder yy177;
SNodeList* yy192;
bool yy209;
EOperatorType yy228;
EJoinType yy229;
SToken yy241;
} YYMINORTYPE;
#ifndef YYSTACKDEPTH
#define YYSTACKDEPTH 100
......@@ -138,17 +138,17 @@ typedef union {
#define NewParseCTX_PARAM
#define NewParseCTX_FETCH
#define NewParseCTX_STORE
#define YYNSTATE 149
#define YYNRULE 135
#define YYNTOKEN 73
#define YY_MAX_SHIFT 148
#define YY_MIN_SHIFTREDUCE 245
#define YY_MAX_SHIFTREDUCE 379
#define YY_ERROR_ACTION 380
#define YY_ACCEPT_ACTION 381
#define YY_NO_ACTION 382
#define YY_MIN_REDUCE 383
#define YY_MAX_REDUCE 517
#define YYNSTATE 143
#define YYNRULE 134
#define YYNTOKEN 72
#define YY_MAX_SHIFT 142
#define YY_MIN_SHIFTREDUCE 238
#define YY_MAX_SHIFTREDUCE 371
#define YY_ERROR_ACTION 372
#define YY_ACCEPT_ACTION 373
#define YY_NO_ACTION 374
#define YY_MIN_REDUCE 375
#define YY_MAX_REDUCE 508
/************* End control #defines *******************************************/
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
......@@ -215,199 +215,202 @@ typedef union {
** yy_default[] Default action for each state.
**
*********** Begin parsing tables **********************************************/
#define YY_ACTTAB_COUNT (656)
#define YY_ACTTAB_COUNT (705)
static const YYACTIONTYPE yy_action[] = {
/* 0 */ 392, 390, 94, 494, 20, 67, 393, 390, 27, 25,
/* 10 */ 23, 22, 21, 400, 390, 321, 52, 131, 414, 144,
/* 20 */ 492, 74, 46, 401, 266, 403, 19, 89, 98, 119,
/* 30 */ 284, 285, 286, 287, 288, 289, 290, 292, 293, 294,
/* 40 */ 27, 25, 23, 22, 21, 23, 22, 21, 346, 465,
/* 50 */ 463, 247, 248, 249, 250, 145, 253, 320, 19, 89,
/* 60 */ 98, 132, 284, 285, 286, 287, 288, 289, 290, 292,
/* 70 */ 293, 294, 26, 24, 110, 344, 345, 347, 348, 247,
/* 80 */ 248, 249, 250, 145, 253, 260, 103, 6, 400, 390,
/* 90 */ 494, 8, 143, 414, 144, 3, 317, 41, 401, 111,
/* 100 */ 403, 439, 36, 53, 70, 96, 435, 492, 400, 390,
/* 110 */ 143, 414, 143, 414, 144, 469, 114, 41, 401, 128,
/* 120 */ 403, 439, 450, 148, 54, 96, 435, 450, 143, 414,
/* 130 */ 494, 34, 63, 36, 118, 490, 400, 390, 137, 448,
/* 140 */ 143, 414, 144, 493, 447, 41, 401, 492, 403, 439,
/* 150 */ 26, 24, 322, 96, 435, 54, 17, 247, 248, 249,
/* 160 */ 250, 145, 253, 454, 103, 28, 291, 400, 390, 295,
/* 170 */ 136, 143, 414, 144, 5, 4, 41, 401, 329, 403,
/* 180 */ 439, 138, 400, 390, 438, 435, 143, 414, 144, 415,
/* 190 */ 258, 41, 401, 76, 403, 439, 120, 115, 113, 123,
/* 200 */ 435, 400, 390, 377, 378, 143, 414, 144, 78, 34,
/* 210 */ 40, 401, 42, 403, 439, 343, 400, 390, 88, 435,
/* 220 */ 131, 414, 144, 26, 24, 46, 401, 7, 403, 134,
/* 230 */ 247, 248, 249, 250, 145, 253, 112, 103, 6, 476,
/* 240 */ 27, 25, 23, 22, 21, 109, 72, 26, 24, 130,
/* 250 */ 31, 140, 104, 462, 247, 248, 249, 250, 145, 253,
/* 260 */ 450, 103, 28, 400, 390, 55, 253, 143, 414, 144,
/* 270 */ 107, 57, 41, 401, 60, 403, 439, 446, 124, 108,
/* 280 */ 281, 436, 34, 400, 390, 475, 95, 143, 414, 144,
/* 290 */ 5, 4, 47, 401, 34, 403, 141, 59, 400, 390,
/* 300 */ 374, 375, 143, 414, 144, 2, 34, 86, 401, 105,
/* 310 */ 403, 400, 390, 302, 456, 143, 414, 144, 16, 122,
/* 320 */ 86, 401, 121, 403, 27, 25, 23, 22, 21, 133,
/* 330 */ 508, 400, 390, 62, 106, 143, 414, 144, 49, 1,
/* 340 */ 86, 401, 97, 403, 400, 390, 64, 317, 143, 414,
/* 350 */ 144, 13, 29, 47, 401, 296, 403, 400, 390, 421,
/* 360 */ 257, 143, 414, 144, 44, 260, 86, 401, 102, 403,
/* 370 */ 451, 400, 390, 30, 65, 143, 414, 144, 261, 29,
/* 380 */ 83, 401, 264, 403, 400, 390, 510, 466, 143, 414,
/* 390 */ 144, 509, 139, 80, 401, 99, 403, 400, 390, 135,
/* 400 */ 142, 143, 414, 144, 258, 77, 84, 401, 397, 403,
/* 410 */ 395, 400, 390, 75, 491, 143, 414, 144, 10, 29,
/* 420 */ 81, 401, 11, 403, 400, 390, 35, 56, 143, 414,
/* 430 */ 144, 340, 58, 85, 401, 342, 403, 400, 390, 336,
/* 440 */ 48, 143, 414, 144, 61, 38, 411, 401, 335, 403,
/* 450 */ 116, 400, 390, 117, 39, 143, 414, 144, 395, 12,
/* 460 */ 410, 401, 4, 403, 400, 390, 282, 315, 143, 414,
/* 470 */ 144, 314, 32, 409, 401, 69, 403, 400, 390, 33,
/* 480 */ 394, 143, 414, 144, 51, 368, 92, 401, 14, 403,
/* 490 */ 9, 400, 390, 37, 357, 143, 414, 144, 363, 79,
/* 500 */ 91, 401, 362, 403, 400, 390, 100, 367, 143, 414,
/* 510 */ 144, 366, 101, 93, 401, 251, 403, 400, 390, 384,
/* 520 */ 383, 143, 414, 144, 15, 147, 90, 401, 382, 403,
/* 530 */ 382, 400, 390, 382, 382, 143, 414, 144, 382, 382,
/* 540 */ 82, 401, 382, 403, 400, 390, 382, 382, 143, 414,
/* 550 */ 144, 382, 382, 87, 401, 382, 403, 127, 45, 382,
/* 560 */ 382, 382, 127, 45, 382, 382, 43, 382, 382, 382,
/* 570 */ 382, 43, 382, 382, 129, 66, 444, 445, 382, 444,
/* 580 */ 68, 444, 126, 382, 125, 382, 382, 127, 45, 382,
/* 590 */ 382, 382, 127, 45, 382, 382, 43, 382, 382, 382,
/* 600 */ 382, 43, 382, 381, 146, 50, 444, 445, 382, 444,
/* 610 */ 71, 444, 445, 382, 444, 27, 25, 23, 22, 21,
/* 620 */ 27, 25, 23, 22, 21, 382, 382, 382, 382, 261,
/* 630 */ 382, 382, 18, 494, 382, 382, 266, 382, 27, 25,
/* 640 */ 23, 22, 21, 382, 382, 382, 53, 382, 73, 382,
/* 650 */ 492, 27, 25, 23, 22, 21,
/* 0 */ 384, 382, 89, 22, 64, 385, 382, 458, 29, 27,
/* 10 */ 25, 24, 23, 392, 382, 137, 406, 126, 406, 138,
/* 20 */ 71, 109, 44, 393, 259, 395, 21, 84, 93, 142,
/* 30 */ 277, 278, 279, 280, 281, 282, 283, 285, 286, 287,
/* 40 */ 29, 27, 25, 24, 23, 25, 24, 23, 125, 9,
/* 50 */ 456, 240, 241, 242, 243, 139, 246, 106, 21, 84,
/* 60 */ 93, 51, 277, 278, 279, 280, 281, 282, 283, 285,
/* 70 */ 286, 287, 127, 392, 382, 137, 406, 137, 406, 138,
/* 80 */ 315, 113, 38, 393, 114, 395, 431, 253, 28, 26,
/* 90 */ 83, 427, 487, 443, 131, 240, 241, 242, 243, 139,
/* 100 */ 246, 487, 98, 1, 340, 486, 67, 10, 51, 485,
/* 110 */ 440, 392, 382, 60, 50, 137, 406, 138, 485, 123,
/* 120 */ 39, 393, 314, 395, 431, 51, 125, 9, 91, 427,
/* 130 */ 105, 338, 339, 341, 342, 392, 382, 132, 462, 137,
/* 140 */ 406, 138, 4, 311, 39, 393, 407, 395, 431, 51,
/* 150 */ 443, 443, 91, 427, 29, 27, 25, 24, 23, 323,
/* 160 */ 392, 382, 483, 73, 137, 406, 138, 439, 438, 39,
/* 170 */ 393, 251, 395, 431, 389, 18, 387, 91, 427, 7,
/* 180 */ 6, 29, 27, 25, 24, 23, 134, 447, 127, 392,
/* 190 */ 382, 7, 6, 137, 406, 138, 28, 26, 77, 393,
/* 200 */ 8, 395, 295, 240, 241, 242, 243, 139, 246, 107,
/* 210 */ 98, 1, 28, 26, 469, 10, 104, 487, 52, 240,
/* 220 */ 241, 242, 243, 139, 246, 246, 98, 5, 102, 40,
/* 230 */ 50, 135, 337, 19, 485, 392, 382, 130, 468, 137,
/* 240 */ 406, 138, 103, 284, 39, 393, 288, 395, 431, 51,
/* 250 */ 56, 54, 430, 427, 57, 370, 371, 29, 27, 25,
/* 260 */ 24, 23, 30, 392, 382, 289, 90, 137, 406, 138,
/* 270 */ 3, 254, 39, 393, 117, 395, 431, 28, 26, 316,
/* 280 */ 118, 427, 47, 449, 240, 241, 242, 243, 139, 246,
/* 290 */ 70, 98, 5, 101, 392, 382, 129, 127, 126, 406,
/* 300 */ 138, 122, 43, 44, 393, 119, 395, 274, 30, 59,
/* 310 */ 41, 257, 2, 29, 27, 25, 24, 23, 61, 65,
/* 320 */ 436, 121, 15, 120, 69, 311, 487, 20, 413, 250,
/* 330 */ 99, 455, 42, 29, 27, 25, 24, 23, 253, 50,
/* 340 */ 28, 26, 444, 485, 31, 62, 254, 240, 241, 242,
/* 350 */ 243, 139, 246, 459, 98, 1, 392, 382, 94, 502,
/* 360 */ 137, 406, 138, 136, 484, 39, 393, 72, 395, 431,
/* 370 */ 28, 26, 367, 368, 428, 133, 251, 240, 241, 242,
/* 380 */ 243, 139, 246, 13, 98, 5, 29, 27, 25, 24,
/* 390 */ 23, 115, 110, 108, 392, 382, 12, 30, 137, 406,
/* 400 */ 138, 53, 259, 45, 393, 334, 395, 55, 34, 336,
/* 410 */ 330, 46, 58, 35, 392, 382, 373, 140, 137, 406,
/* 420 */ 138, 329, 111, 81, 393, 100, 395, 392, 382, 112,
/* 430 */ 387, 137, 406, 138, 36, 6, 81, 393, 116, 395,
/* 440 */ 128, 500, 14, 392, 382, 275, 487, 137, 406, 138,
/* 450 */ 309, 308, 81, 393, 92, 395, 392, 382, 33, 50,
/* 460 */ 137, 406, 138, 485, 66, 45, 393, 32, 395, 392,
/* 470 */ 382, 386, 49, 137, 406, 138, 361, 16, 81, 393,
/* 480 */ 97, 395, 37, 11, 356, 355, 74, 95, 360, 392,
/* 490 */ 382, 359, 96, 137, 406, 138, 244, 17, 78, 393,
/* 500 */ 376, 395, 375, 501, 374, 141, 392, 382, 374, 374,
/* 510 */ 137, 406, 138, 374, 374, 75, 393, 374, 395, 392,
/* 520 */ 382, 374, 374, 137, 406, 138, 374, 374, 79, 393,
/* 530 */ 374, 395, 392, 382, 374, 374, 137, 406, 138, 374,
/* 540 */ 374, 76, 393, 374, 395, 392, 382, 374, 374, 137,
/* 550 */ 406, 138, 374, 374, 80, 393, 374, 395, 374, 374,
/* 560 */ 374, 374, 374, 374, 392, 382, 374, 374, 137, 406,
/* 570 */ 138, 374, 374, 403, 393, 374, 395, 374, 392, 382,
/* 580 */ 374, 374, 137, 406, 138, 374, 374, 402, 393, 374,
/* 590 */ 395, 392, 382, 374, 374, 137, 406, 138, 374, 374,
/* 600 */ 401, 393, 374, 395, 392, 382, 374, 374, 137, 406,
/* 610 */ 138, 374, 374, 87, 393, 374, 395, 392, 382, 374,
/* 620 */ 374, 137, 406, 138, 374, 374, 86, 393, 374, 395,
/* 630 */ 392, 382, 374, 374, 137, 406, 138, 374, 374, 88,
/* 640 */ 393, 374, 395, 392, 382, 374, 374, 137, 406, 138,
/* 650 */ 374, 374, 85, 393, 374, 395, 374, 392, 382, 374,
/* 660 */ 374, 137, 406, 138, 374, 374, 82, 393, 374, 395,
/* 670 */ 122, 43, 374, 374, 374, 122, 43, 374, 374, 41,
/* 680 */ 374, 374, 122, 43, 41, 374, 374, 124, 63, 436,
/* 690 */ 437, 41, 441, 48, 436, 437, 374, 441, 374, 374,
/* 700 */ 68, 436, 437, 374, 441,
};
static const YYCODETYPE yy_lookahead[] = {
/* 0 */ 75, 76, 77, 103, 89, 90, 75, 76, 8, 9,
/* 10 */ 10, 11, 12, 75, 76, 4, 116, 79, 80, 81,
/* 20 */ 120, 123, 84, 85, 24, 87, 26, 27, 28, 22,
/* 0 */ 74, 75, 76, 88, 89, 74, 75, 82, 8, 9,
/* 10 */ 10, 11, 12, 74, 75, 78, 79, 78, 79, 80,
/* 20 */ 122, 84, 83, 84, 24, 86, 26, 27, 28, 13,
/* 30 */ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
/* 40 */ 8, 9, 10, 11, 12, 10, 11, 12, 29, 83,
/* 50 */ 112, 15, 16, 17, 18, 19, 20, 46, 26, 27,
/* 60 */ 28, 74, 30, 31, 32, 33, 34, 35, 36, 37,
/* 70 */ 38, 39, 8, 9, 55, 56, 57, 58, 59, 15,
/* 80 */ 16, 17, 18, 19, 20, 22, 22, 23, 75, 76,
/* 90 */ 103, 27, 79, 80, 81, 43, 44, 84, 85, 115,
/* 100 */ 87, 88, 23, 116, 41, 92, 93, 120, 75, 76,
/* 110 */ 79, 80, 79, 80, 81, 102, 85, 84, 85, 101,
/* 120 */ 87, 88, 82, 13, 45, 92, 93, 82, 79, 80,
/* 130 */ 103, 67, 108, 23, 85, 102, 75, 76, 21, 99,
/* 140 */ 79, 80, 81, 116, 99, 84, 85, 120, 87, 88,
/* 150 */ 8, 9, 10, 92, 93, 45, 26, 15, 16, 17,
/* 160 */ 18, 19, 20, 102, 22, 23, 36, 75, 76, 39,
/* 170 */ 3, 79, 80, 81, 1, 2, 84, 85, 10, 87,
/* 180 */ 88, 64, 75, 76, 92, 93, 79, 80, 81, 80,
/* 190 */ 22, 84, 85, 117, 87, 88, 50, 51, 52, 92,
/* 200 */ 93, 75, 76, 71, 72, 79, 80, 81, 117, 67,
/* 210 */ 84, 85, 21, 87, 88, 24, 75, 76, 92, 93,
/* 220 */ 79, 80, 81, 8, 9, 84, 85, 104, 87, 62,
/* 230 */ 15, 16, 17, 18, 19, 20, 54, 22, 23, 114,
/* 240 */ 8, 9, 10, 11, 12, 53, 105, 8, 9, 22,
/* 250 */ 23, 21, 111, 112, 15, 16, 17, 18, 19, 20,
/* 260 */ 82, 22, 23, 75, 76, 113, 20, 79, 80, 81,
/* 270 */ 76, 21, 84, 85, 24, 87, 88, 99, 27, 76,
/* 280 */ 29, 93, 67, 75, 76, 114, 76, 79, 80, 81,
/* 290 */ 1, 2, 84, 85, 67, 87, 66, 113, 75, 76,
/* 300 */ 68, 69, 79, 80, 81, 61, 67, 84, 85, 86,
/* 310 */ 87, 75, 76, 24, 110, 79, 80, 81, 2, 60,
/* 320 */ 84, 85, 86, 87, 8, 9, 10, 11, 12, 121,
/* 330 */ 122, 75, 76, 109, 48, 79, 80, 81, 107, 47,
/* 340 */ 84, 85, 86, 87, 75, 76, 106, 44, 79, 80,
/* 350 */ 81, 23, 21, 84, 85, 24, 87, 75, 76, 91,
/* 360 */ 22, 79, 80, 81, 79, 22, 84, 85, 86, 87,
/* 370 */ 82, 75, 76, 40, 94, 79, 80, 81, 22, 21,
/* 380 */ 84, 85, 24, 87, 75, 76, 124, 83, 79, 80,
/* 390 */ 81, 122, 63, 84, 85, 70, 87, 75, 76, 118,
/* 400 */ 65, 79, 80, 81, 22, 118, 84, 85, 23, 87,
/* 410 */ 25, 75, 76, 119, 119, 79, 80, 81, 21, 21,
/* 420 */ 84, 85, 49, 87, 75, 76, 21, 24, 79, 80,
/* 430 */ 81, 24, 23, 84, 85, 24, 87, 75, 76, 24,
/* 440 */ 23, 79, 80, 81, 23, 23, 84, 85, 24, 87,
/* 450 */ 15, 75, 76, 21, 23, 79, 80, 81, 25, 49,
/* 460 */ 84, 85, 2, 87, 75, 76, 29, 24, 79, 80,
/* 470 */ 81, 24, 42, 84, 85, 25, 87, 75, 76, 21,
/* 480 */ 25, 79, 80, 81, 25, 24, 84, 85, 21, 87,
/* 490 */ 49, 75, 76, 4, 24, 79, 80, 81, 15, 25,
/* 500 */ 84, 85, 15, 87, 75, 76, 15, 15, 79, 80,
/* 510 */ 81, 15, 15, 84, 85, 17, 87, 75, 76, 0,
/* 520 */ 0, 79, 80, 81, 23, 14, 84, 85, 125, 87,
/* 530 */ 125, 75, 76, 125, 125, 79, 80, 81, 125, 125,
/* 540 */ 84, 85, 125, 87, 75, 76, 125, 125, 79, 80,
/* 550 */ 81, 125, 125, 84, 85, 125, 87, 78, 79, 125,
/* 560 */ 125, 125, 78, 79, 125, 125, 87, 125, 125, 125,
/* 570 */ 125, 87, 125, 125, 95, 96, 97, 98, 125, 100,
/* 580 */ 96, 97, 98, 125, 100, 125, 125, 78, 79, 125,
/* 590 */ 125, 125, 78, 79, 125, 125, 87, 125, 125, 125,
/* 600 */ 125, 87, 125, 73, 74, 96, 97, 98, 125, 100,
/* 610 */ 96, 97, 98, 125, 100, 8, 9, 10, 11, 12,
/* 620 */ 8, 9, 10, 11, 12, 125, 125, 125, 125, 22,
/* 630 */ 125, 125, 2, 103, 125, 125, 24, 125, 8, 9,
/* 640 */ 10, 11, 12, 125, 125, 125, 116, 125, 41, 125,
/* 650 */ 120, 8, 9, 10, 11, 12, 125, 125, 125, 125,
/* 660 */ 125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
/* 670 */ 125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
/* 680 */ 125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
/* 690 */ 125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
/* 700 */ 125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
/* 710 */ 125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
/* 720 */ 125, 125, 125, 125, 125,
/* 40 */ 8, 9, 10, 11, 12, 10, 11, 12, 22, 23,
/* 50 */ 111, 15, 16, 17, 18, 19, 20, 114, 26, 27,
/* 60 */ 28, 45, 30, 31, 32, 33, 34, 35, 36, 37,
/* 70 */ 38, 39, 73, 74, 75, 78, 79, 78, 79, 80,
/* 80 */ 4, 84, 83, 84, 22, 86, 87, 22, 8, 9,
/* 90 */ 91, 92, 102, 81, 21, 15, 16, 17, 18, 19,
/* 100 */ 20, 102, 22, 23, 29, 115, 41, 27, 45, 119,
/* 110 */ 98, 74, 75, 107, 115, 78, 79, 80, 119, 100,
/* 120 */ 83, 84, 46, 86, 87, 45, 22, 23, 91, 92,
/* 130 */ 55, 56, 57, 58, 59, 74, 75, 64, 101, 78,
/* 140 */ 79, 80, 43, 44, 83, 84, 79, 86, 87, 45,
/* 150 */ 81, 81, 91, 92, 8, 9, 10, 11, 12, 10,
/* 160 */ 74, 75, 101, 116, 78, 79, 80, 98, 98, 83,
/* 170 */ 84, 22, 86, 87, 23, 2, 25, 91, 92, 1,
/* 180 */ 2, 8, 9, 10, 11, 12, 21, 101, 73, 74,
/* 190 */ 75, 1, 2, 78, 79, 80, 8, 9, 83, 84,
/* 200 */ 103, 86, 24, 15, 16, 17, 18, 19, 20, 54,
/* 210 */ 22, 23, 8, 9, 113, 27, 53, 102, 112, 15,
/* 220 */ 16, 17, 18, 19, 20, 20, 22, 23, 75, 21,
/* 230 */ 115, 66, 24, 26, 119, 74, 75, 3, 113, 78,
/* 240 */ 79, 80, 75, 36, 83, 84, 39, 86, 87, 45,
/* 250 */ 112, 21, 91, 92, 24, 70, 71, 8, 9, 10,
/* 260 */ 11, 12, 21, 74, 75, 24, 75, 78, 79, 80,
/* 270 */ 61, 22, 83, 84, 60, 86, 87, 8, 9, 10,
/* 280 */ 91, 92, 106, 109, 15, 16, 17, 18, 19, 20,
/* 290 */ 41, 22, 23, 48, 74, 75, 62, 73, 78, 79,
/* 300 */ 80, 77, 78, 83, 84, 27, 86, 29, 21, 108,
/* 310 */ 86, 24, 47, 8, 9, 10, 11, 12, 105, 95,
/* 320 */ 96, 97, 23, 99, 104, 44, 102, 2, 90, 22,
/* 330 */ 110, 111, 78, 8, 9, 10, 11, 12, 22, 115,
/* 340 */ 8, 9, 81, 119, 40, 93, 22, 15, 16, 17,
/* 350 */ 18, 19, 20, 82, 22, 23, 74, 75, 69, 123,
/* 360 */ 78, 79, 80, 65, 118, 83, 84, 117, 86, 87,
/* 370 */ 8, 9, 67, 68, 92, 63, 22, 15, 16, 17,
/* 380 */ 18, 19, 20, 49, 22, 23, 8, 9, 10, 11,
/* 390 */ 12, 50, 51, 52, 74, 75, 21, 21, 78, 79,
/* 400 */ 80, 24, 24, 83, 84, 24, 86, 23, 21, 24,
/* 410 */ 24, 23, 23, 23, 74, 75, 72, 73, 78, 79,
/* 420 */ 80, 24, 15, 83, 84, 85, 86, 74, 75, 21,
/* 430 */ 25, 78, 79, 80, 23, 2, 83, 84, 85, 86,
/* 440 */ 120, 121, 49, 74, 75, 29, 102, 78, 79, 80,
/* 450 */ 24, 24, 83, 84, 85, 86, 74, 75, 21, 115,
/* 460 */ 78, 79, 80, 119, 25, 83, 84, 42, 86, 74,
/* 470 */ 75, 25, 25, 78, 79, 80, 24, 21, 83, 84,
/* 480 */ 85, 86, 4, 49, 15, 15, 25, 15, 15, 74,
/* 490 */ 75, 15, 15, 78, 79, 80, 17, 23, 83, 84,
/* 500 */ 0, 86, 0, 121, 124, 14, 74, 75, 124, 124,
/* 510 */ 78, 79, 80, 124, 124, 83, 84, 124, 86, 74,
/* 520 */ 75, 124, 124, 78, 79, 80, 124, 124, 83, 84,
/* 530 */ 124, 86, 74, 75, 124, 124, 78, 79, 80, 124,
/* 540 */ 124, 83, 84, 124, 86, 74, 75, 124, 124, 78,
/* 550 */ 79, 80, 124, 124, 83, 84, 124, 86, 124, 124,
/* 560 */ 124, 124, 124, 124, 74, 75, 124, 124, 78, 79,
/* 570 */ 80, 124, 124, 83, 84, 124, 86, 124, 74, 75,
/* 580 */ 124, 124, 78, 79, 80, 124, 124, 83, 84, 124,
/* 590 */ 86, 74, 75, 124, 124, 78, 79, 80, 124, 124,
/* 600 */ 83, 84, 124, 86, 74, 75, 124, 124, 78, 79,
/* 610 */ 80, 124, 124, 83, 84, 124, 86, 74, 75, 124,
/* 620 */ 124, 78, 79, 80, 124, 124, 83, 84, 124, 86,
/* 630 */ 74, 75, 124, 124, 78, 79, 80, 124, 124, 83,
/* 640 */ 84, 124, 86, 74, 75, 124, 124, 78, 79, 80,
/* 650 */ 124, 124, 83, 84, 124, 86, 124, 74, 75, 124,
/* 660 */ 124, 78, 79, 80, 124, 124, 83, 84, 124, 86,
/* 670 */ 77, 78, 124, 124, 124, 77, 78, 124, 124, 86,
/* 680 */ 124, 124, 77, 78, 86, 124, 124, 94, 95, 96,
/* 690 */ 97, 86, 99, 95, 96, 97, 124, 99, 124, 124,
/* 700 */ 95, 96, 97, 124, 99,
};
#define YY_SHIFT_COUNT (148)
#define YY_SHIFT_COUNT (142)
#define YY_SHIFT_MIN (0)
#define YY_SHIFT_MAX (643)
#define YY_SHIFT_MAX (502)
static const unsigned short int yy_shift_ofst[] = {
/* 0 */ 110, 64, 64, 64, 64, 64, 64, 142, 215, 239,
/* 10 */ 239, 239, 239, 239, 239, 239, 239, 239, 239, 239,
/* 20 */ 239, 239, 239, 239, 239, 239, 239, 239, 239, 239,
/* 30 */ 227, 227, 227, 227, 79, 36, 79, 79, 7, 7,
/* 40 */ 0, 32, 36, 63, 63, 63, 607, 232, 19, 146,
/* 50 */ 52, 168, 167, 167, 11, 182, 192, 246, 246, 182,
/* 60 */ 192, 246, 244, 259, 286, 292, 303, 328, 303, 338,
/* 70 */ 343, 303, 333, 356, 325, 329, 335, 335, 329, 382,
/* 80 */ 316, 630, 612, 643, 643, 643, 643, 643, 289, 130,
/* 90 */ 35, 35, 35, 35, 191, 250, 173, 331, 251, 132,
/* 100 */ 117, 230, 358, 385, 397, 398, 373, 403, 407, 409,
/* 110 */ 405, 411, 417, 421, 415, 422, 424, 435, 432, 433,
/* 120 */ 431, 398, 410, 460, 437, 443, 447, 450, 430, 458,
/* 130 */ 455, 459, 461, 467, 441, 470, 489, 483, 487, 491,
/* 140 */ 492, 496, 497, 474, 501, 498, 519, 520, 511,
/* 0 */ 16, 80, 188, 188, 188, 204, 188, 188, 269, 104,
/* 10 */ 332, 362, 362, 362, 362, 362, 362, 362, 362, 362,
/* 20 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
/* 30 */ 362, 26, 26, 26, 36, 62, 62, 63, 0, 32,
/* 40 */ 36, 65, 65, 65, 249, 305, 75, 341, 99, 149,
/* 50 */ 234, 76, 155, 163, 205, 205, 155, 163, 205, 209,
/* 60 */ 214, 245, 265, 281, 299, 281, 307, 316, 281, 304,
/* 70 */ 324, 289, 298, 312, 354, 173, 325, 378, 146, 146,
/* 80 */ 146, 146, 146, 178, 207, 35, 35, 35, 35, 208,
/* 90 */ 230, 190, 241, 278, 185, 73, 165, 287, 151, 375,
/* 100 */ 376, 334, 377, 381, 384, 387, 385, 388, 389, 386,
/* 110 */ 390, 397, 407, 408, 405, 411, 376, 393, 433, 416,
/* 120 */ 426, 427, 439, 425, 437, 446, 447, 452, 456, 434,
/* 130 */ 478, 469, 470, 472, 473, 476, 477, 461, 474, 479,
/* 140 */ 500, 502, 491,
};
#define YY_REDUCE_COUNT (79)
#define YY_REDUCE_COUNT (74)
#define YY_REDUCE_MIN (-102)
#define YY_REDUCE_MAX (530)
#define YY_REDUCE_MAX (605)
static const short yy_reduce_ofst[] = {
/* 0 */ 530, 13, 33, 61, 92, 107, 126, 141, 188, 208,
/* 10 */ -62, 223, 236, 256, 269, 282, 296, 309, 322, 336,
/* 20 */ 349, 362, 376, 389, 402, 416, 429, 442, 456, 469,
/* 30 */ 479, 484, 509, 514, -13, -75, -100, 27, 31, 49,
/* 40 */ -85, -85, -69, 40, 45, 178, -34, -102, -16, 24,
/* 50 */ 18, 109, 76, 91, 123, 125, 152, 194, 203, 171,
/* 60 */ 184, 210, 204, 224, 231, 240, 18, 268, 18, 285,
/* 70 */ 288, 18, 280, 304, 262, 281, 294, 295, 287, 109,
/* 0 */ 344, -1, 37, 61, 86, 115, 161, 189, 220, 224,
/* 10 */ 282, 320, -61, 340, 353, 369, 382, 395, 415, 432,
/* 20 */ 445, 458, 471, 490, 504, 517, 530, 543, 556, 569,
/* 30 */ 583, 593, 598, 605, -74, -63, -3, -10, -85, -85,
/* 40 */ -69, 12, 69, 70, -75, -102, -57, 6, 19, 67,
/* 50 */ 47, 97, 101, 106, 153, 167, 125, 138, 191, 174,
/* 60 */ 201, 176, 213, 19, 238, 19, 254, 261, 19, 252,
/* 70 */ 271, 236, 246, 250, 67,
};
static const YYACTIONTYPE yy_default[] = {
/* 0 */ 380, 380, 380, 380, 380, 380, 380, 380, 380, 380,
/* 10 */ 380, 380, 380, 380, 380, 380, 380, 380, 380, 380,
/* 20 */ 380, 380, 380, 380, 380, 380, 380, 380, 380, 380,
/* 30 */ 380, 380, 380, 380, 380, 380, 380, 380, 380, 380,
/* 40 */ 380, 380, 380, 449, 449, 449, 464, 511, 380, 472,
/* 50 */ 380, 380, 496, 496, 457, 479, 477, 380, 380, 479,
/* 60 */ 477, 380, 489, 487, 470, 468, 442, 380, 380, 380,
/* 70 */ 380, 443, 380, 380, 514, 498, 502, 502, 498, 380,
/* 80 */ 380, 380, 380, 418, 417, 416, 412, 413, 380, 380,
/* 90 */ 407, 408, 406, 405, 380, 380, 507, 380, 380, 380,
/* 100 */ 499, 503, 380, 396, 461, 471, 380, 380, 380, 380,
/* 110 */ 380, 380, 380, 380, 380, 380, 380, 380, 380, 396,
/* 120 */ 380, 488, 380, 437, 380, 517, 445, 380, 380, 441,
/* 130 */ 395, 380, 380, 497, 380, 380, 380, 380, 380, 380,
/* 140 */ 380, 380, 380, 380, 380, 380, 380, 380, 380,
/* 0 */ 372, 372, 372, 372, 372, 372, 372, 372, 372, 372,
/* 10 */ 372, 372, 372, 372, 372, 372, 372, 372, 372, 372,
/* 20 */ 372, 372, 372, 372, 372, 372, 372, 372, 372, 372,
/* 30 */ 372, 372, 372, 372, 372, 372, 372, 372, 372, 372,
/* 40 */ 372, 442, 442, 442, 457, 503, 372, 465, 372, 372,
/* 50 */ 488, 450, 472, 470, 372, 372, 472, 470, 372, 482,
/* 60 */ 480, 463, 461, 434, 372, 372, 372, 372, 435, 372,
/* 70 */ 372, 506, 494, 490, 372, 372, 372, 372, 410, 409,
/* 80 */ 408, 404, 405, 372, 372, 399, 400, 398, 397, 372,
/* 90 */ 372, 499, 372, 372, 372, 491, 495, 372, 388, 454,
/* 100 */ 464, 372, 372, 372, 372, 372, 372, 372, 372, 372,
/* 110 */ 372, 372, 372, 372, 388, 372, 481, 372, 429, 372,
/* 120 */ 441, 437, 372, 372, 433, 387, 372, 372, 489, 372,
/* 130 */ 372, 372, 372, 372, 372, 372, 372, 372, 372, 372,
/* 140 */ 372, 372, 372,
};
/********** End of lemon-generated parsing tables *****************************/
......@@ -581,64 +584,63 @@ static const char *const yyTokenName[] = {
/* 64 */ "SOFFSET",
/* 65 */ "LIMIT",
/* 66 */ "OFFSET",
/* 67 */ "NK_LR",
/* 68 */ "ASC",
/* 69 */ "DESC",
/* 70 */ "NULLS",
/* 71 */ "FIRST",
/* 72 */ "LAST",
/* 73 */ "cmd",
/* 74 */ "query_expression",
/* 75 */ "literal",
/* 76 */ "duration_literal",
/* 77 */ "literal_list",
/* 78 */ "db_name",
/* 79 */ "table_name",
/* 80 */ "column_name",
/* 81 */ "function_name",
/* 82 */ "table_alias",
/* 83 */ "column_alias",
/* 84 */ "expression",
/* 85 */ "column_reference",
/* 86 */ "expression_list",
/* 87 */ "subquery",
/* 88 */ "predicate",
/* 89 */ "compare_op",
/* 90 */ "in_op",
/* 91 */ "in_predicate_value",
/* 92 */ "boolean_value_expression",
/* 93 */ "boolean_primary",
/* 94 */ "from_clause",
/* 95 */ "table_reference_list",
/* 96 */ "table_reference",
/* 97 */ "table_primary",
/* 98 */ "joined_table",
/* 99 */ "alias_opt",
/* 100 */ "parenthesized_joined_table",
/* 101 */ "join_type",
/* 102 */ "search_condition",
/* 103 */ "query_specification",
/* 104 */ "set_quantifier_opt",
/* 105 */ "select_list",
/* 106 */ "where_clause_opt",
/* 107 */ "partition_by_clause_opt",
/* 108 */ "twindow_clause_opt",
/* 109 */ "group_by_clause_opt",
/* 110 */ "having_clause_opt",
/* 111 */ "select_sublist",
/* 112 */ "select_item",
/* 113 */ "sliding_opt",
/* 114 */ "fill_opt",
/* 115 */ "fill_mode",
/* 116 */ "query_expression_body",
/* 117 */ "order_by_clause_opt",
/* 118 */ "slimit_clause_opt",
/* 119 */ "limit_clause_opt",
/* 120 */ "query_primary",
/* 121 */ "sort_specification_list",
/* 122 */ "sort_specification",
/* 123 */ "ordering_specification_opt",
/* 124 */ "null_ordering_opt",
/* 67 */ "ASC",
/* 68 */ "DESC",
/* 69 */ "NULLS",
/* 70 */ "FIRST",
/* 71 */ "LAST",
/* 72 */ "cmd",
/* 73 */ "query_expression",
/* 74 */ "literal",
/* 75 */ "duration_literal",
/* 76 */ "literal_list",
/* 77 */ "db_name",
/* 78 */ "table_name",
/* 79 */ "column_name",
/* 80 */ "function_name",
/* 81 */ "table_alias",
/* 82 */ "column_alias",
/* 83 */ "expression",
/* 84 */ "column_reference",
/* 85 */ "expression_list",
/* 86 */ "subquery",
/* 87 */ "predicate",
/* 88 */ "compare_op",
/* 89 */ "in_op",
/* 90 */ "in_predicate_value",
/* 91 */ "boolean_value_expression",
/* 92 */ "boolean_primary",
/* 93 */ "from_clause",
/* 94 */ "table_reference_list",
/* 95 */ "table_reference",
/* 96 */ "table_primary",
/* 97 */ "joined_table",
/* 98 */ "alias_opt",
/* 99 */ "parenthesized_joined_table",
/* 100 */ "join_type",
/* 101 */ "search_condition",
/* 102 */ "query_specification",
/* 103 */ "set_quantifier_opt",
/* 104 */ "select_list",
/* 105 */ "where_clause_opt",
/* 106 */ "partition_by_clause_opt",
/* 107 */ "twindow_clause_opt",
/* 108 */ "group_by_clause_opt",
/* 109 */ "having_clause_opt",
/* 110 */ "select_sublist",
/* 111 */ "select_item",
/* 112 */ "sliding_opt",
/* 113 */ "fill_opt",
/* 114 */ "fill_mode",
/* 115 */ "query_expression_body",
/* 116 */ "order_by_clause_opt",
/* 117 */ "slimit_clause_opt",
/* 118 */ "limit_clause_opt",
/* 119 */ "query_primary",
/* 120 */ "sort_specification_list",
/* 121 */ "sort_specification",
/* 122 */ "ordering_specification_opt",
/* 123 */ "null_ordering_opt",
};
#endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
......@@ -712,53 +714,53 @@ static const char *const yyRuleName[] = {
/* 63 */ "table_primary ::= table_name alias_opt",
/* 64 */ "table_primary ::= db_name NK_DOT table_name alias_opt",
/* 65 */ "table_primary ::= subquery alias_opt",
/* 66 */ "alias_opt ::=",
/* 67 */ "alias_opt ::= table_alias",
/* 68 */ "alias_opt ::= AS table_alias",
/* 69 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP",
/* 70 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP",
/* 71 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition",
/* 72 */ "join_type ::= INNER",
/* 73 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt",
/* 74 */ "set_quantifier_opt ::=",
/* 75 */ "set_quantifier_opt ::= DISTINCT",
/* 76 */ "set_quantifier_opt ::= ALL",
/* 77 */ "select_list ::= NK_STAR",
/* 78 */ "select_list ::= select_sublist",
/* 79 */ "select_sublist ::= select_item",
/* 80 */ "select_sublist ::= select_sublist NK_COMMA select_item",
/* 81 */ "select_item ::= expression",
/* 82 */ "select_item ::= expression column_alias",
/* 83 */ "select_item ::= expression AS column_alias",
/* 84 */ "select_item ::= table_name NK_DOT NK_STAR",
/* 85 */ "where_clause_opt ::=",
/* 86 */ "where_clause_opt ::= WHERE search_condition",
/* 87 */ "partition_by_clause_opt ::=",
/* 88 */ "partition_by_clause_opt ::= PARTITION BY expression_list",
/* 89 */ "twindow_clause_opt ::=",
/* 90 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP",
/* 91 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP",
/* 92 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt",
/* 93 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt",
/* 94 */ "sliding_opt ::=",
/* 95 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP",
/* 96 */ "fill_opt ::=",
/* 97 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP",
/* 98 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP",
/* 99 */ "fill_mode ::= NONE",
/* 100 */ "fill_mode ::= PREV",
/* 101 */ "fill_mode ::= NULL",
/* 102 */ "fill_mode ::= LINEAR",
/* 103 */ "fill_mode ::= NEXT",
/* 104 */ "group_by_clause_opt ::=",
/* 105 */ "group_by_clause_opt ::= GROUP BY expression_list",
/* 106 */ "having_clause_opt ::=",
/* 107 */ "having_clause_opt ::= HAVING search_condition",
/* 108 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt",
/* 109 */ "query_expression_body ::= query_primary",
/* 110 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body",
/* 111 */ "query_primary ::= query_specification",
/* 112 */ "query_primary ::= NK_LP query_expression_body order_by_clause_opt limit_clause_opt slimit_clause_opt NK_RP",
/* 66 */ "table_primary ::= parenthesized_joined_table",
/* 67 */ "alias_opt ::=",
/* 68 */ "alias_opt ::= table_alias",
/* 69 */ "alias_opt ::= AS table_alias",
/* 70 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP",
/* 71 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP",
/* 72 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition",
/* 73 */ "join_type ::= INNER",
/* 74 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt",
/* 75 */ "set_quantifier_opt ::=",
/* 76 */ "set_quantifier_opt ::= DISTINCT",
/* 77 */ "set_quantifier_opt ::= ALL",
/* 78 */ "select_list ::= NK_STAR",
/* 79 */ "select_list ::= select_sublist",
/* 80 */ "select_sublist ::= select_item",
/* 81 */ "select_sublist ::= select_sublist NK_COMMA select_item",
/* 82 */ "select_item ::= expression",
/* 83 */ "select_item ::= expression column_alias",
/* 84 */ "select_item ::= expression AS column_alias",
/* 85 */ "select_item ::= table_name NK_DOT NK_STAR",
/* 86 */ "where_clause_opt ::=",
/* 87 */ "where_clause_opt ::= WHERE search_condition",
/* 88 */ "partition_by_clause_opt ::=",
/* 89 */ "partition_by_clause_opt ::= PARTITION BY expression_list",
/* 90 */ "twindow_clause_opt ::=",
/* 91 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP",
/* 92 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP",
/* 93 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt",
/* 94 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt",
/* 95 */ "sliding_opt ::=",
/* 96 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP",
/* 97 */ "fill_opt ::=",
/* 98 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP",
/* 99 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP",
/* 100 */ "fill_mode ::= NONE",
/* 101 */ "fill_mode ::= PREV",
/* 102 */ "fill_mode ::= NULL",
/* 103 */ "fill_mode ::= LINEAR",
/* 104 */ "fill_mode ::= NEXT",
/* 105 */ "group_by_clause_opt ::=",
/* 106 */ "group_by_clause_opt ::= GROUP BY expression_list",
/* 107 */ "having_clause_opt ::=",
/* 108 */ "having_clause_opt ::= HAVING search_condition",
/* 109 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt",
/* 110 */ "query_expression_body ::= query_primary",
/* 111 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body",
/* 112 */ "query_primary ::= query_specification",
/* 113 */ "order_by_clause_opt ::=",
/* 114 */ "order_by_clause_opt ::= ORDER BY sort_specification_list",
/* 115 */ "slimit_clause_opt ::=",
......@@ -769,7 +771,7 @@ static const char *const yyRuleName[] = {
/* 120 */ "limit_clause_opt ::= LIMIT NK_INTEGER",
/* 121 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER",
/* 122 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER",
/* 123 */ "subquery ::= NK_LR query_expression NK_RP",
/* 123 */ "subquery ::= NK_LP query_expression NK_RP",
/* 124 */ "search_condition ::= boolean_value_expression",
/* 125 */ "sort_specification_list ::= sort_specification",
/* 126 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification",
......@@ -780,7 +782,6 @@ static const char *const yyRuleName[] = {
/* 131 */ "null_ordering_opt ::=",
/* 132 */ "null_ordering_opt ::= NULLS FIRST",
/* 133 */ "null_ordering_opt ::= NULLS LAST",
/* 134 */ "table_primary ::= parenthesized_joined_table",
};
#endif /* NDEBUG */
......@@ -907,90 +908,90 @@ static void yy_destructor(
*/
/********* Begin destructor definitions ***************************************/
/* Default NON-TERMINAL Destructor */
case 73: /* cmd */
case 74: /* query_expression */
case 75: /* literal */
case 76: /* duration_literal */
case 84: /* expression */
case 85: /* column_reference */
case 87: /* subquery */
case 88: /* predicate */
case 91: /* in_predicate_value */
case 92: /* boolean_value_expression */
case 93: /* boolean_primary */
case 94: /* from_clause */
case 95: /* table_reference_list */
case 96: /* table_reference */
case 97: /* table_primary */
case 98: /* joined_table */
case 100: /* parenthesized_joined_table */
case 102: /* search_condition */
case 103: /* query_specification */
case 106: /* where_clause_opt */
case 108: /* twindow_clause_opt */
case 110: /* having_clause_opt */
case 112: /* select_item */
case 113: /* sliding_opt */
case 114: /* fill_opt */
case 116: /* query_expression_body */
case 118: /* slimit_clause_opt */
case 119: /* limit_clause_opt */
case 120: /* query_primary */
case 122: /* sort_specification */
case 72: /* cmd */
case 73: /* query_expression */
case 74: /* literal */
case 75: /* duration_literal */
case 83: /* expression */
case 84: /* column_reference */
case 86: /* subquery */
case 87: /* predicate */
case 90: /* in_predicate_value */
case 91: /* boolean_value_expression */
case 92: /* boolean_primary */
case 93: /* from_clause */
case 94: /* table_reference_list */
case 95: /* table_reference */
case 96: /* table_primary */
case 97: /* joined_table */
case 99: /* parenthesized_joined_table */
case 101: /* search_condition */
case 102: /* query_specification */
case 105: /* where_clause_opt */
case 107: /* twindow_clause_opt */
case 109: /* having_clause_opt */
case 111: /* select_item */
case 112: /* sliding_opt */
case 113: /* fill_opt */
case 115: /* query_expression_body */
case 117: /* slimit_clause_opt */
case 118: /* limit_clause_opt */
case 119: /* query_primary */
case 121: /* sort_specification */
{
PARSER_DESTRUCTOR_TRACE; nodesDestroyNode((yypminor->yy212));
PARSER_DESTRUCTOR_TRACE; nodesDestroyNode((yypminor->yy168));
}
break;
case 77: /* literal_list */
case 86: /* expression_list */
case 105: /* select_list */
case 107: /* partition_by_clause_opt */
case 109: /* group_by_clause_opt */
case 111: /* select_sublist */
case 117: /* order_by_clause_opt */
case 121: /* sort_specification_list */
case 76: /* literal_list */
case 85: /* expression_list */
case 104: /* select_list */
case 106: /* partition_by_clause_opt */
case 108: /* group_by_clause_opt */
case 110: /* select_sublist */
case 116: /* order_by_clause_opt */
case 120: /* sort_specification_list */
{
PARSER_DESTRUCTOR_TRACE; nodesDestroyList((yypminor->yy174));
PARSER_DESTRUCTOR_TRACE; nodesDestroyList((yypminor->yy192));
}
break;
case 78: /* db_name */
case 79: /* table_name */
case 80: /* column_name */
case 81: /* function_name */
case 82: /* table_alias */
case 83: /* column_alias */
case 99: /* alias_opt */
case 77: /* db_name */
case 78: /* table_name */
case 79: /* column_name */
case 80: /* function_name */
case 81: /* table_alias */
case 82: /* column_alias */
case 98: /* alias_opt */
{
PARSER_DESTRUCTOR_TRACE;
}
break;
case 89: /* compare_op */
case 90: /* in_op */
case 88: /* compare_op */
case 89: /* in_op */
{
PARSER_DESTRUCTOR_TRACE;
}
break;
case 101: /* join_type */
case 100: /* join_type */
{
PARSER_DESTRUCTOR_TRACE;
}
break;
case 104: /* set_quantifier_opt */
case 103: /* set_quantifier_opt */
{
PARSER_DESTRUCTOR_TRACE;
}
break;
case 115: /* fill_mode */
case 114: /* fill_mode */
{
PARSER_DESTRUCTOR_TRACE;
}
break;
case 123: /* ordering_specification_opt */
case 122: /* ordering_specification_opt */
{
PARSER_DESTRUCTOR_TRACE;
}
break;
case 124: /* null_ordering_opt */
case 123: /* null_ordering_opt */
{
PARSER_DESTRUCTOR_TRACE;
}
......@@ -1289,141 +1290,140 @@ static const struct {
YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
signed char nrhs; /* Negative of the number of RHS symbols in the rule */
} yyRuleInfo[] = {
{ 73, -2 }, /* (0) cmd ::= SHOW DATABASES */
{ 73, -1 }, /* (1) cmd ::= query_expression */
{ 75, -1 }, /* (2) literal ::= NK_INTEGER */
{ 75, -1 }, /* (3) literal ::= NK_FLOAT */
{ 75, -1 }, /* (4) literal ::= NK_STRING */
{ 75, -1 }, /* (5) literal ::= NK_BOOL */
{ 75, -2 }, /* (6) literal ::= TIMESTAMP NK_STRING */
{ 75, -1 }, /* (7) literal ::= duration_literal */
{ 76, -1 }, /* (8) duration_literal ::= NK_VARIABLE */
{ 77, -1 }, /* (9) literal_list ::= literal */
{ 77, -3 }, /* (10) literal_list ::= literal_list NK_COMMA literal */
{ 78, -1 }, /* (11) db_name ::= NK_ID */
{ 79, -1 }, /* (12) table_name ::= NK_ID */
{ 80, -1 }, /* (13) column_name ::= NK_ID */
{ 81, -1 }, /* (14) function_name ::= NK_ID */
{ 82, -1 }, /* (15) table_alias ::= NK_ID */
{ 83, -1 }, /* (16) column_alias ::= NK_ID */
{ 84, -1 }, /* (17) expression ::= literal */
{ 84, -1 }, /* (18) expression ::= column_reference */
{ 84, -4 }, /* (19) expression ::= function_name NK_LP expression_list NK_RP */
{ 84, -1 }, /* (20) expression ::= subquery */
{ 84, -3 }, /* (21) expression ::= NK_LP expression NK_RP */
{ 84, -2 }, /* (22) expression ::= NK_PLUS expression */
{ 84, -2 }, /* (23) expression ::= NK_MINUS expression */
{ 84, -3 }, /* (24) expression ::= expression NK_PLUS expression */
{ 84, -3 }, /* (25) expression ::= expression NK_MINUS expression */
{ 84, -3 }, /* (26) expression ::= expression NK_STAR expression */
{ 84, -3 }, /* (27) expression ::= expression NK_SLASH expression */
{ 84, -3 }, /* (28) expression ::= expression NK_REM expression */
{ 86, -1 }, /* (29) expression_list ::= expression */
{ 86, -3 }, /* (30) expression_list ::= expression_list NK_COMMA expression */
{ 85, -1 }, /* (31) column_reference ::= column_name */
{ 85, -3 }, /* (32) column_reference ::= table_name NK_DOT column_name */
{ 88, -3 }, /* (33) predicate ::= expression compare_op expression */
{ 88, -5 }, /* (34) predicate ::= expression BETWEEN expression AND expression */
{ 88, -6 }, /* (35) predicate ::= expression NOT BETWEEN expression AND expression */
{ 88, -3 }, /* (36) predicate ::= expression IS NULL */
{ 88, -4 }, /* (37) predicate ::= expression IS NOT NULL */
{ 88, -3 }, /* (38) predicate ::= expression in_op in_predicate_value */
{ 89, -1 }, /* (39) compare_op ::= NK_LT */
{ 89, -1 }, /* (40) compare_op ::= NK_GT */
{ 89, -1 }, /* (41) compare_op ::= NK_LE */
{ 89, -1 }, /* (42) compare_op ::= NK_GE */
{ 89, -1 }, /* (43) compare_op ::= NK_NE */
{ 89, -1 }, /* (44) compare_op ::= NK_EQ */
{ 89, -1 }, /* (45) compare_op ::= LIKE */
{ 89, -2 }, /* (46) compare_op ::= NOT LIKE */
{ 89, -1 }, /* (47) compare_op ::= MATCH */
{ 89, -1 }, /* (48) compare_op ::= NMATCH */
{ 90, -1 }, /* (49) in_op ::= IN */
{ 90, -2 }, /* (50) in_op ::= NOT IN */
{ 91, -3 }, /* (51) in_predicate_value ::= NK_LP expression_list NK_RP */
{ 92, -1 }, /* (52) boolean_value_expression ::= boolean_primary */
{ 92, -2 }, /* (53) boolean_value_expression ::= NOT boolean_primary */
{ 92, -3 }, /* (54) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */
{ 92, -3 }, /* (55) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */
{ 93, -1 }, /* (56) boolean_primary ::= predicate */
{ 93, -3 }, /* (57) boolean_primary ::= NK_LP boolean_value_expression NK_RP */
{ 94, -2 }, /* (58) from_clause ::= FROM table_reference_list */
{ 95, -1 }, /* (59) table_reference_list ::= table_reference */
{ 95, -3 }, /* (60) table_reference_list ::= table_reference_list NK_COMMA table_reference */
{ 96, -1 }, /* (61) table_reference ::= table_primary */
{ 96, -1 }, /* (62) table_reference ::= joined_table */
{ 97, -2 }, /* (63) table_primary ::= table_name alias_opt */
{ 97, -4 }, /* (64) table_primary ::= db_name NK_DOT table_name alias_opt */
{ 97, -2 }, /* (65) table_primary ::= subquery alias_opt */
{ 99, 0 }, /* (66) alias_opt ::= */
{ 99, -1 }, /* (67) alias_opt ::= table_alias */
{ 99, -2 }, /* (68) alias_opt ::= AS table_alias */
{ 100, -3 }, /* (69) parenthesized_joined_table ::= NK_LP joined_table NK_RP */
{ 100, -3 }, /* (70) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */
{ 98, -6 }, /* (71) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */
{ 101, -1 }, /* (72) join_type ::= INNER */
{ 103, -9 }, /* (73) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */
{ 104, 0 }, /* (74) set_quantifier_opt ::= */
{ 104, -1 }, /* (75) set_quantifier_opt ::= DISTINCT */
{ 104, -1 }, /* (76) set_quantifier_opt ::= ALL */
{ 105, -1 }, /* (77) select_list ::= NK_STAR */
{ 105, -1 }, /* (78) select_list ::= select_sublist */
{ 111, -1 }, /* (79) select_sublist ::= select_item */
{ 111, -3 }, /* (80) select_sublist ::= select_sublist NK_COMMA select_item */
{ 112, -1 }, /* (81) select_item ::= expression */
{ 112, -2 }, /* (82) select_item ::= expression column_alias */
{ 112, -3 }, /* (83) select_item ::= expression AS column_alias */
{ 112, -3 }, /* (84) select_item ::= table_name NK_DOT NK_STAR */
{ 106, 0 }, /* (85) where_clause_opt ::= */
{ 106, -2 }, /* (86) where_clause_opt ::= WHERE search_condition */
{ 107, 0 }, /* (87) partition_by_clause_opt ::= */
{ 107, -3 }, /* (88) partition_by_clause_opt ::= PARTITION BY expression_list */
{ 108, 0 }, /* (89) twindow_clause_opt ::= */
{ 108, -6 }, /* (90) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */
{ 108, -4 }, /* (91) twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */
{ 108, -6 }, /* (92) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */
{ 108, -8 }, /* (93) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */
{ 113, 0 }, /* (94) sliding_opt ::= */
{ 113, -4 }, /* (95) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */
{ 114, 0 }, /* (96) fill_opt ::= */
{ 114, -4 }, /* (97) fill_opt ::= FILL NK_LP fill_mode NK_RP */
{ 114, -6 }, /* (98) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */
{ 115, -1 }, /* (99) fill_mode ::= NONE */
{ 115, -1 }, /* (100) fill_mode ::= PREV */
{ 115, -1 }, /* (101) fill_mode ::= NULL */
{ 115, -1 }, /* (102) fill_mode ::= LINEAR */
{ 115, -1 }, /* (103) fill_mode ::= NEXT */
{ 109, 0 }, /* (104) group_by_clause_opt ::= */
{ 109, -3 }, /* (105) group_by_clause_opt ::= GROUP BY expression_list */
{ 110, 0 }, /* (106) having_clause_opt ::= */
{ 110, -2 }, /* (107) having_clause_opt ::= HAVING search_condition */
{ 74, -4 }, /* (108) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */
{ 116, -1 }, /* (109) query_expression_body ::= query_primary */
{ 116, -4 }, /* (110) query_expression_body ::= query_expression_body UNION ALL query_expression_body */
{ 120, -1 }, /* (111) query_primary ::= query_specification */
{ 120, -6 }, /* (112) query_primary ::= NK_LP query_expression_body order_by_clause_opt limit_clause_opt slimit_clause_opt NK_RP */
{ 117, 0 }, /* (113) order_by_clause_opt ::= */
{ 117, -3 }, /* (114) order_by_clause_opt ::= ORDER BY sort_specification_list */
{ 118, 0 }, /* (115) slimit_clause_opt ::= */
{ 118, -2 }, /* (116) slimit_clause_opt ::= SLIMIT NK_INTEGER */
{ 118, -4 }, /* (117) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */
{ 118, -4 }, /* (118) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */
{ 119, 0 }, /* (119) limit_clause_opt ::= */
{ 119, -2 }, /* (120) limit_clause_opt ::= LIMIT NK_INTEGER */
{ 119, -4 }, /* (121) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */
{ 119, -4 }, /* (122) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */
{ 87, -3 }, /* (123) subquery ::= NK_LR query_expression NK_RP */
{ 102, -1 }, /* (124) search_condition ::= boolean_value_expression */
{ 121, -1 }, /* (125) sort_specification_list ::= sort_specification */
{ 121, -3 }, /* (126) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */
{ 122, -3 }, /* (127) sort_specification ::= expression ordering_specification_opt null_ordering_opt */
{ 123, 0 }, /* (128) ordering_specification_opt ::= */
{ 123, -1 }, /* (129) ordering_specification_opt ::= ASC */
{ 123, -1 }, /* (130) ordering_specification_opt ::= DESC */
{ 124, 0 }, /* (131) null_ordering_opt ::= */
{ 124, -2 }, /* (132) null_ordering_opt ::= NULLS FIRST */
{ 124, -2 }, /* (133) null_ordering_opt ::= NULLS LAST */
{ 97, -1 }, /* (134) table_primary ::= parenthesized_joined_table */
{ 72, -2 }, /* (0) cmd ::= SHOW DATABASES */
{ 72, -1 }, /* (1) cmd ::= query_expression */
{ 74, -1 }, /* (2) literal ::= NK_INTEGER */
{ 74, -1 }, /* (3) literal ::= NK_FLOAT */
{ 74, -1 }, /* (4) literal ::= NK_STRING */
{ 74, -1 }, /* (5) literal ::= NK_BOOL */
{ 74, -2 }, /* (6) literal ::= TIMESTAMP NK_STRING */
{ 74, -1 }, /* (7) literal ::= duration_literal */
{ 75, -1 }, /* (8) duration_literal ::= NK_VARIABLE */
{ 76, -1 }, /* (9) literal_list ::= literal */
{ 76, -3 }, /* (10) literal_list ::= literal_list NK_COMMA literal */
{ 77, -1 }, /* (11) db_name ::= NK_ID */
{ 78, -1 }, /* (12) table_name ::= NK_ID */
{ 79, -1 }, /* (13) column_name ::= NK_ID */
{ 80, -1 }, /* (14) function_name ::= NK_ID */
{ 81, -1 }, /* (15) table_alias ::= NK_ID */
{ 82, -1 }, /* (16) column_alias ::= NK_ID */
{ 83, -1 }, /* (17) expression ::= literal */
{ 83, -1 }, /* (18) expression ::= column_reference */
{ 83, -4 }, /* (19) expression ::= function_name NK_LP expression_list NK_RP */
{ 83, -1 }, /* (20) expression ::= subquery */
{ 83, -3 }, /* (21) expression ::= NK_LP expression NK_RP */
{ 83, -2 }, /* (22) expression ::= NK_PLUS expression */
{ 83, -2 }, /* (23) expression ::= NK_MINUS expression */
{ 83, -3 }, /* (24) expression ::= expression NK_PLUS expression */
{ 83, -3 }, /* (25) expression ::= expression NK_MINUS expression */
{ 83, -3 }, /* (26) expression ::= expression NK_STAR expression */
{ 83, -3 }, /* (27) expression ::= expression NK_SLASH expression */
{ 83, -3 }, /* (28) expression ::= expression NK_REM expression */
{ 85, -1 }, /* (29) expression_list ::= expression */
{ 85, -3 }, /* (30) expression_list ::= expression_list NK_COMMA expression */
{ 84, -1 }, /* (31) column_reference ::= column_name */
{ 84, -3 }, /* (32) column_reference ::= table_name NK_DOT column_name */
{ 87, -3 }, /* (33) predicate ::= expression compare_op expression */
{ 87, -5 }, /* (34) predicate ::= expression BETWEEN expression AND expression */
{ 87, -6 }, /* (35) predicate ::= expression NOT BETWEEN expression AND expression */
{ 87, -3 }, /* (36) predicate ::= expression IS NULL */
{ 87, -4 }, /* (37) predicate ::= expression IS NOT NULL */
{ 87, -3 }, /* (38) predicate ::= expression in_op in_predicate_value */
{ 88, -1 }, /* (39) compare_op ::= NK_LT */
{ 88, -1 }, /* (40) compare_op ::= NK_GT */
{ 88, -1 }, /* (41) compare_op ::= NK_LE */
{ 88, -1 }, /* (42) compare_op ::= NK_GE */
{ 88, -1 }, /* (43) compare_op ::= NK_NE */
{ 88, -1 }, /* (44) compare_op ::= NK_EQ */
{ 88, -1 }, /* (45) compare_op ::= LIKE */
{ 88, -2 }, /* (46) compare_op ::= NOT LIKE */
{ 88, -1 }, /* (47) compare_op ::= MATCH */
{ 88, -1 }, /* (48) compare_op ::= NMATCH */
{ 89, -1 }, /* (49) in_op ::= IN */
{ 89, -2 }, /* (50) in_op ::= NOT IN */
{ 90, -3 }, /* (51) in_predicate_value ::= NK_LP expression_list NK_RP */
{ 91, -1 }, /* (52) boolean_value_expression ::= boolean_primary */
{ 91, -2 }, /* (53) boolean_value_expression ::= NOT boolean_primary */
{ 91, -3 }, /* (54) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */
{ 91, -3 }, /* (55) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */
{ 92, -1 }, /* (56) boolean_primary ::= predicate */
{ 92, -3 }, /* (57) boolean_primary ::= NK_LP boolean_value_expression NK_RP */
{ 93, -2 }, /* (58) from_clause ::= FROM table_reference_list */
{ 94, -1 }, /* (59) table_reference_list ::= table_reference */
{ 94, -3 }, /* (60) table_reference_list ::= table_reference_list NK_COMMA table_reference */
{ 95, -1 }, /* (61) table_reference ::= table_primary */
{ 95, -1 }, /* (62) table_reference ::= joined_table */
{ 96, -2 }, /* (63) table_primary ::= table_name alias_opt */
{ 96, -4 }, /* (64) table_primary ::= db_name NK_DOT table_name alias_opt */
{ 96, -2 }, /* (65) table_primary ::= subquery alias_opt */
{ 96, -1 }, /* (66) table_primary ::= parenthesized_joined_table */
{ 98, 0 }, /* (67) alias_opt ::= */
{ 98, -1 }, /* (68) alias_opt ::= table_alias */
{ 98, -2 }, /* (69) alias_opt ::= AS table_alias */
{ 99, -3 }, /* (70) parenthesized_joined_table ::= NK_LP joined_table NK_RP */
{ 99, -3 }, /* (71) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */
{ 97, -6 }, /* (72) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */
{ 100, -1 }, /* (73) join_type ::= INNER */
{ 102, -9 }, /* (74) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */
{ 103, 0 }, /* (75) set_quantifier_opt ::= */
{ 103, -1 }, /* (76) set_quantifier_opt ::= DISTINCT */
{ 103, -1 }, /* (77) set_quantifier_opt ::= ALL */
{ 104, -1 }, /* (78) select_list ::= NK_STAR */
{ 104, -1 }, /* (79) select_list ::= select_sublist */
{ 110, -1 }, /* (80) select_sublist ::= select_item */
{ 110, -3 }, /* (81) select_sublist ::= select_sublist NK_COMMA select_item */
{ 111, -1 }, /* (82) select_item ::= expression */
{ 111, -2 }, /* (83) select_item ::= expression column_alias */
{ 111, -3 }, /* (84) select_item ::= expression AS column_alias */
{ 111, -3 }, /* (85) select_item ::= table_name NK_DOT NK_STAR */
{ 105, 0 }, /* (86) where_clause_opt ::= */
{ 105, -2 }, /* (87) where_clause_opt ::= WHERE search_condition */
{ 106, 0 }, /* (88) partition_by_clause_opt ::= */
{ 106, -3 }, /* (89) partition_by_clause_opt ::= PARTITION BY expression_list */
{ 107, 0 }, /* (90) twindow_clause_opt ::= */
{ 107, -6 }, /* (91) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */
{ 107, -4 }, /* (92) twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */
{ 107, -6 }, /* (93) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */
{ 107, -8 }, /* (94) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */
{ 112, 0 }, /* (95) sliding_opt ::= */
{ 112, -4 }, /* (96) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */
{ 113, 0 }, /* (97) fill_opt ::= */
{ 113, -4 }, /* (98) fill_opt ::= FILL NK_LP fill_mode NK_RP */
{ 113, -6 }, /* (99) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */
{ 114, -1 }, /* (100) fill_mode ::= NONE */
{ 114, -1 }, /* (101) fill_mode ::= PREV */
{ 114, -1 }, /* (102) fill_mode ::= NULL */
{ 114, -1 }, /* (103) fill_mode ::= LINEAR */
{ 114, -1 }, /* (104) fill_mode ::= NEXT */
{ 108, 0 }, /* (105) group_by_clause_opt ::= */
{ 108, -3 }, /* (106) group_by_clause_opt ::= GROUP BY expression_list */
{ 109, 0 }, /* (107) having_clause_opt ::= */
{ 109, -2 }, /* (108) having_clause_opt ::= HAVING search_condition */
{ 73, -4 }, /* (109) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */
{ 115, -1 }, /* (110) query_expression_body ::= query_primary */
{ 115, -4 }, /* (111) query_expression_body ::= query_expression_body UNION ALL query_expression_body */
{ 119, -1 }, /* (112) query_primary ::= query_specification */
{ 116, 0 }, /* (113) order_by_clause_opt ::= */
{ 116, -3 }, /* (114) order_by_clause_opt ::= ORDER BY sort_specification_list */
{ 117, 0 }, /* (115) slimit_clause_opt ::= */
{ 117, -2 }, /* (116) slimit_clause_opt ::= SLIMIT NK_INTEGER */
{ 117, -4 }, /* (117) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */
{ 117, -4 }, /* (118) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */
{ 118, 0 }, /* (119) limit_clause_opt ::= */
{ 118, -2 }, /* (120) limit_clause_opt ::= LIMIT NK_INTEGER */
{ 118, -4 }, /* (121) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */
{ 118, -4 }, /* (122) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */
{ 86, -3 }, /* (123) subquery ::= NK_LP query_expression NK_RP */
{ 101, -1 }, /* (124) search_condition ::= boolean_value_expression */
{ 120, -1 }, /* (125) sort_specification_list ::= sort_specification */
{ 120, -3 }, /* (126) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */
{ 121, -3 }, /* (127) sort_specification ::= expression ordering_specification_opt null_ordering_opt */
{ 122, 0 }, /* (128) ordering_specification_opt ::= */
{ 122, -1 }, /* (129) ordering_specification_opt ::= ASC */
{ 122, -1 }, /* (130) ordering_specification_opt ::= DESC */
{ 123, 0 }, /* (131) null_ordering_opt ::= */
{ 123, -2 }, /* (132) null_ordering_opt ::= NULLS FIRST */
{ 123, -2 }, /* (133) null_ordering_opt ::= NULLS LAST */
};
static void yy_accept(yyParser*); /* Forward Declaration */
......@@ -1514,26 +1514,26 @@ static YYACTIONTYPE yy_reduce(
{ PARSER_TRACE; createShowStmt(pCxt, SHOW_TYPE_DATABASE); }
break;
case 1: /* cmd ::= query_expression */
{ PARSER_TRACE; pCxt->pRootNode = yymsp[0].minor.yy212; }
{ PARSER_TRACE; pCxt->pRootNode = yymsp[0].minor.yy168; }
break;
case 2: /* literal ::= NK_INTEGER */
{ PARSER_TRACE; yylhsminor.yy212 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); }
yymsp[0].minor.yy212 = yylhsminor.yy212;
{ PARSER_TRACE; yylhsminor.yy168 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); }
yymsp[0].minor.yy168 = yylhsminor.yy168;
break;
case 3: /* literal ::= NK_FLOAT */
{ PARSER_TRACE; yylhsminor.yy212 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); }
yymsp[0].minor.yy212 = yylhsminor.yy212;
{ PARSER_TRACE; yylhsminor.yy168 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); }
yymsp[0].minor.yy168 = yylhsminor.yy168;
break;
case 4: /* literal ::= NK_STRING */
{ PARSER_TRACE; yylhsminor.yy212 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); }
yymsp[0].minor.yy212 = yylhsminor.yy212;
{ PARSER_TRACE; yylhsminor.yy168 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); }
yymsp[0].minor.yy168 = yylhsminor.yy168;
break;
case 5: /* literal ::= NK_BOOL */
{ PARSER_TRACE; yylhsminor.yy212 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); }
yymsp[0].minor.yy212 = yylhsminor.yy212;
{ PARSER_TRACE; yylhsminor.yy168 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); }
yymsp[0].minor.yy168 = yylhsminor.yy168;
break;
case 6: /* literal ::= TIMESTAMP NK_STRING */
{ PARSER_TRACE; yymsp[-1].minor.yy212 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); }
{ PARSER_TRACE; yymsp[-1].minor.yy168 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); }
break;
case 7: /* literal ::= duration_literal */
case 17: /* expression ::= literal */ yytestcase(yyruleno==17);
......@@ -1544,30 +1544,31 @@ static YYACTIONTYPE yy_reduce(
case 59: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==59);
case 61: /* table_reference ::= table_primary */ yytestcase(yyruleno==61);
case 62: /* table_reference ::= joined_table */ yytestcase(yyruleno==62);
case 81: /* select_item ::= expression */ yytestcase(yyruleno==81);
case 109: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==109);
case 111: /* query_primary ::= query_specification */ yytestcase(yyruleno==111);
case 66: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==66);
case 82: /* select_item ::= expression */ yytestcase(yyruleno==82);
case 110: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==110);
case 112: /* query_primary ::= query_specification */ yytestcase(yyruleno==112);
case 124: /* search_condition ::= boolean_value_expression */ yytestcase(yyruleno==124);
{ PARSER_TRACE; yylhsminor.yy212 = yymsp[0].minor.yy212; }
yymsp[0].minor.yy212 = yylhsminor.yy212;
{ PARSER_TRACE; yylhsminor.yy168 = yymsp[0].minor.yy168; }
yymsp[0].minor.yy168 = yylhsminor.yy168;
break;
case 8: /* duration_literal ::= NK_VARIABLE */
{ PARSER_TRACE; yylhsminor.yy212 = createDurationValueNode(pCxt, &yymsp[0].minor.yy0); }
yymsp[0].minor.yy212 = yylhsminor.yy212;
{ PARSER_TRACE; yylhsminor.yy168 = createDurationValueNode(pCxt, &yymsp[0].minor.yy0); }
yymsp[0].minor.yy168 = yylhsminor.yy168;
break;
case 9: /* literal_list ::= literal */
case 29: /* expression_list ::= expression */ yytestcase(yyruleno==29);
case 79: /* select_sublist ::= select_item */ yytestcase(yyruleno==79);
case 80: /* select_sublist ::= select_item */ yytestcase(yyruleno==80);
case 125: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==125);
{ PARSER_TRACE; yylhsminor.yy174 = createNodeList(pCxt, yymsp[0].minor.yy212); }
yymsp[0].minor.yy174 = yylhsminor.yy174;
{ PARSER_TRACE; yylhsminor.yy192 = createNodeList(pCxt, yymsp[0].minor.yy168); }
yymsp[0].minor.yy192 = yylhsminor.yy192;
break;
case 10: /* literal_list ::= literal_list NK_COMMA literal */
case 30: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==30);
case 80: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==80);
case 81: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==81);
case 126: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==126);
{ PARSER_TRACE; yylhsminor.yy174 = addNodeToList(pCxt, yymsp[-2].minor.yy174, yymsp[0].minor.yy212); }
yymsp[-2].minor.yy174 = yylhsminor.yy174;
{ PARSER_TRACE; yylhsminor.yy192 = addNodeToList(pCxt, yymsp[-2].minor.yy192, yymsp[0].minor.yy168); }
yymsp[-2].minor.yy192 = yylhsminor.yy192;
break;
case 11: /* db_name ::= NK_ID */
case 12: /* table_name ::= NK_ID */ yytestcase(yyruleno==12);
......@@ -1575,313 +1576,301 @@ static YYACTIONTYPE yy_reduce(
case 14: /* function_name ::= NK_ID */ yytestcase(yyruleno==14);
case 15: /* table_alias ::= NK_ID */ yytestcase(yyruleno==15);
case 16: /* column_alias ::= NK_ID */ yytestcase(yyruleno==16);
{ PARSER_TRACE; yylhsminor.yy79 = yymsp[0].minor.yy0; }
yymsp[0].minor.yy79 = yylhsminor.yy79;
{ PARSER_TRACE; yylhsminor.yy241 = yymsp[0].minor.yy0; }
yymsp[0].minor.yy241 = yylhsminor.yy241;
break;
case 19: /* expression ::= function_name NK_LP expression_list NK_RP */
{ PARSER_TRACE; yylhsminor.yy212 = createFunctionNode(pCxt, &yymsp[-3].minor.yy79, yymsp[-1].minor.yy174); }
yymsp[-3].minor.yy212 = yylhsminor.yy212;
{ PARSER_TRACE; yylhsminor.yy168 = createFunctionNode(pCxt, &yymsp[-3].minor.yy241, yymsp[-1].minor.yy192); }
yymsp[-3].minor.yy168 = yylhsminor.yy168;
break;
case 21: /* expression ::= NK_LP expression NK_RP */
case 57: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==57);
case 69: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ yytestcase(yyruleno==69);
case 70: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==70);
case 123: /* subquery ::= NK_LR query_expression NK_RP */ yytestcase(yyruleno==123);
{ PARSER_TRACE; yymsp[-2].minor.yy212 = yymsp[-1].minor.yy212; }
case 70: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ yytestcase(yyruleno==70);
case 71: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==71);
case 123: /* subquery ::= NK_LP query_expression NK_RP */ yytestcase(yyruleno==123);
{ PARSER_TRACE; yymsp[-2].minor.yy168 = yymsp[-1].minor.yy168; }
break;
case 22: /* expression ::= NK_PLUS expression */
case 58: /* from_clause ::= FROM table_reference_list */ yytestcase(yyruleno==58);
case 86: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==86);
case 107: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==107);
{ PARSER_TRACE; yymsp[-1].minor.yy212 = yymsp[0].minor.yy212; }
case 87: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==87);
case 108: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==108);
{ PARSER_TRACE; yymsp[-1].minor.yy168 = yymsp[0].minor.yy168; }
break;
case 23: /* expression ::= NK_MINUS expression */
{ PARSER_TRACE; yymsp[-1].minor.yy212 = createOperatorNode(pCxt, OP_TYPE_SUB, yymsp[0].minor.yy212, NULL); }
{ PARSER_TRACE; yymsp[-1].minor.yy168 = createOperatorNode(pCxt, OP_TYPE_SUB, yymsp[0].minor.yy168, NULL); }
break;
case 24: /* expression ::= expression NK_PLUS expression */
{ PARSER_TRACE; yylhsminor.yy212 = createOperatorNode(pCxt, OP_TYPE_ADD, yymsp[-2].minor.yy212, yymsp[0].minor.yy212); }
yymsp[-2].minor.yy212 = yylhsminor.yy212;
{ PARSER_TRACE; yylhsminor.yy168 = createOperatorNode(pCxt, OP_TYPE_ADD, yymsp[-2].minor.yy168, yymsp[0].minor.yy168); }
yymsp[-2].minor.yy168 = yylhsminor.yy168;
break;
case 25: /* expression ::= expression NK_MINUS expression */
{ PARSER_TRACE; yylhsminor.yy212 = createOperatorNode(pCxt, OP_TYPE_SUB, yymsp[-2].minor.yy212, yymsp[0].minor.yy212); }
yymsp[-2].minor.yy212 = yylhsminor.yy212;
{ PARSER_TRACE; yylhsminor.yy168 = createOperatorNode(pCxt, OP_TYPE_SUB, yymsp[-2].minor.yy168, yymsp[0].minor.yy168); }
yymsp[-2].minor.yy168 = yylhsminor.yy168;
break;
case 26: /* expression ::= expression NK_STAR expression */
{ PARSER_TRACE; yylhsminor.yy212 = createOperatorNode(pCxt, OP_TYPE_MULTI, yymsp[-2].minor.yy212, yymsp[0].minor.yy212); }
yymsp[-2].minor.yy212 = yylhsminor.yy212;
{ PARSER_TRACE; yylhsminor.yy168 = createOperatorNode(pCxt, OP_TYPE_MULTI, yymsp[-2].minor.yy168, yymsp[0].minor.yy168); }
yymsp[-2].minor.yy168 = yylhsminor.yy168;
break;
case 27: /* expression ::= expression NK_SLASH expression */
{ PARSER_TRACE; yylhsminor.yy212 = createOperatorNode(pCxt, OP_TYPE_DIV, yymsp[-2].minor.yy212, yymsp[0].minor.yy212); }
yymsp[-2].minor.yy212 = yylhsminor.yy212;
{ PARSER_TRACE; yylhsminor.yy168 = createOperatorNode(pCxt, OP_TYPE_DIV, yymsp[-2].minor.yy168, yymsp[0].minor.yy168); }
yymsp[-2].minor.yy168 = yylhsminor.yy168;
break;
case 28: /* expression ::= expression NK_REM expression */
{ PARSER_TRACE; yylhsminor.yy212 = createOperatorNode(pCxt, OP_TYPE_MOD, yymsp[-2].minor.yy212, yymsp[0].minor.yy212); }
yymsp[-2].minor.yy212 = yylhsminor.yy212;
{ PARSER_TRACE; yylhsminor.yy168 = createOperatorNode(pCxt, OP_TYPE_MOD, yymsp[-2].minor.yy168, yymsp[0].minor.yy168); }
yymsp[-2].minor.yy168 = yylhsminor.yy168;
break;
case 31: /* column_reference ::= column_name */
{ PARSER_TRACE; yylhsminor.yy212 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy79); }
yymsp[0].minor.yy212 = yylhsminor.yy212;
{ PARSER_TRACE; yylhsminor.yy168 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy241); }
yymsp[0].minor.yy168 = yylhsminor.yy168;
break;
case 32: /* column_reference ::= table_name NK_DOT column_name */
{ PARSER_TRACE; yylhsminor.yy212 = createColumnNode(pCxt, &yymsp[-2].minor.yy79, &yymsp[0].minor.yy79); }
yymsp[-2].minor.yy212 = yylhsminor.yy212;
{ PARSER_TRACE; yylhsminor.yy168 = createColumnNode(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy241); }
yymsp[-2].minor.yy168 = yylhsminor.yy168;
break;
case 33: /* predicate ::= expression compare_op expression */
case 38: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==38);
{ PARSER_TRACE; yylhsminor.yy212 = createOperatorNode(pCxt, yymsp[-1].minor.yy40, yymsp[-2].minor.yy212, yymsp[0].minor.yy212); }
yymsp[-2].minor.yy212 = yylhsminor.yy212;
{ PARSER_TRACE; yylhsminor.yy168 = createOperatorNode(pCxt, yymsp[-1].minor.yy228, yymsp[-2].minor.yy168, yymsp[0].minor.yy168); }
yymsp[-2].minor.yy168 = yylhsminor.yy168;
break;
case 34: /* predicate ::= expression BETWEEN expression AND expression */
{ PARSER_TRACE; yylhsminor.yy212 = createBetweenAnd(pCxt, yymsp[-4].minor.yy212, yymsp[-2].minor.yy212, yymsp[0].minor.yy212); }
yymsp[-4].minor.yy212 = yylhsminor.yy212;
{ PARSER_TRACE; yylhsminor.yy168 = createBetweenAnd(pCxt, yymsp[-4].minor.yy168, yymsp[-2].minor.yy168, yymsp[0].minor.yy168); }
yymsp[-4].minor.yy168 = yylhsminor.yy168;
break;
case 35: /* predicate ::= expression NOT BETWEEN expression AND expression */
{ PARSER_TRACE; yylhsminor.yy212 = createNotBetweenAnd(pCxt, yymsp[-2].minor.yy212, yymsp[-5].minor.yy212, yymsp[0].minor.yy212); }
yymsp[-5].minor.yy212 = yylhsminor.yy212;
{ PARSER_TRACE; yylhsminor.yy168 = createNotBetweenAnd(pCxt, yymsp[-2].minor.yy168, yymsp[-5].minor.yy168, yymsp[0].minor.yy168); }
yymsp[-5].minor.yy168 = yylhsminor.yy168;
break;
case 36: /* predicate ::= expression IS NULL */
{ PARSER_TRACE; yylhsminor.yy212 = createIsNullCondNode(pCxt, yymsp[-2].minor.yy212, true); }
yymsp[-2].minor.yy212 = yylhsminor.yy212;
{ PARSER_TRACE; yylhsminor.yy168 = createIsNullCondNode(pCxt, yymsp[-2].minor.yy168, true); }
yymsp[-2].minor.yy168 = yylhsminor.yy168;
break;
case 37: /* predicate ::= expression IS NOT NULL */
{ PARSER_TRACE; yylhsminor.yy212 = createIsNullCondNode(pCxt, yymsp[-3].minor.yy212, false); }
yymsp[-3].minor.yy212 = yylhsminor.yy212;
{ PARSER_TRACE; yylhsminor.yy168 = createIsNullCondNode(pCxt, yymsp[-3].minor.yy168, false); }
yymsp[-3].minor.yy168 = yylhsminor.yy168;
break;
case 39: /* compare_op ::= NK_LT */
{ PARSER_TRACE; yymsp[0].minor.yy40 = OP_TYPE_LOWER_THAN; }
{ PARSER_TRACE; yymsp[0].minor.yy228 = OP_TYPE_LOWER_THAN; }
break;
case 40: /* compare_op ::= NK_GT */
{ PARSER_TRACE; yymsp[0].minor.yy40 = OP_TYPE_GREATER_THAN; }
{ PARSER_TRACE; yymsp[0].minor.yy228 = OP_TYPE_GREATER_THAN; }
break;
case 41: /* compare_op ::= NK_LE */
{ PARSER_TRACE; yymsp[0].minor.yy40 = OP_TYPE_LOWER_EQUAL; }
{ PARSER_TRACE; yymsp[0].minor.yy228 = OP_TYPE_LOWER_EQUAL; }
break;
case 42: /* compare_op ::= NK_GE */
{ PARSER_TRACE; yymsp[0].minor.yy40 = OP_TYPE_GREATER_EQUAL; }
{ PARSER_TRACE; yymsp[0].minor.yy228 = OP_TYPE_GREATER_EQUAL; }
break;
case 43: /* compare_op ::= NK_NE */
{ PARSER_TRACE; yymsp[0].minor.yy40 = OP_TYPE_NOT_EQUAL; }
{ PARSER_TRACE; yymsp[0].minor.yy228 = OP_TYPE_NOT_EQUAL; }
break;
case 44: /* compare_op ::= NK_EQ */
{ PARSER_TRACE; yymsp[0].minor.yy40 = OP_TYPE_EQUAL; }
{ PARSER_TRACE; yymsp[0].minor.yy228 = OP_TYPE_EQUAL; }
break;
case 45: /* compare_op ::= LIKE */
{ PARSER_TRACE; yymsp[0].minor.yy40 = OP_TYPE_LIKE; }
{ PARSER_TRACE; yymsp[0].minor.yy228 = OP_TYPE_LIKE; }
break;
case 46: /* compare_op ::= NOT LIKE */
{ PARSER_TRACE; yymsp[-1].minor.yy40 = OP_TYPE_NOT_LIKE; }
{ PARSER_TRACE; yymsp[-1].minor.yy228 = OP_TYPE_NOT_LIKE; }
break;
case 47: /* compare_op ::= MATCH */
{ PARSER_TRACE; yymsp[0].minor.yy40 = OP_TYPE_MATCH; }
{ PARSER_TRACE; yymsp[0].minor.yy228 = OP_TYPE_MATCH; }
break;
case 48: /* compare_op ::= NMATCH */
{ PARSER_TRACE; yymsp[0].minor.yy40 = OP_TYPE_NMATCH; }
{ PARSER_TRACE; yymsp[0].minor.yy228 = OP_TYPE_NMATCH; }
break;
case 49: /* in_op ::= IN */
{ PARSER_TRACE; yymsp[0].minor.yy40 = OP_TYPE_IN; }
{ PARSER_TRACE; yymsp[0].minor.yy228 = OP_TYPE_IN; }
break;
case 50: /* in_op ::= NOT IN */
{ PARSER_TRACE; yymsp[-1].minor.yy40 = OP_TYPE_NOT_IN; }
{ PARSER_TRACE; yymsp[-1].minor.yy228 = OP_TYPE_NOT_IN; }
break;
case 51: /* in_predicate_value ::= NK_LP expression_list NK_RP */
{ PARSER_TRACE; yymsp[-2].minor.yy212 = createNodeListNode(pCxt, yymsp[-1].minor.yy174); }
{ PARSER_TRACE; yymsp[-2].minor.yy168 = createNodeListNode(pCxt, yymsp[-1].minor.yy192); }
break;
case 53: /* boolean_value_expression ::= NOT boolean_primary */
{ PARSER_TRACE; yymsp[-1].minor.yy212 = createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, yymsp[0].minor.yy212, NULL); }
{ PARSER_TRACE; yymsp[-1].minor.yy168 = createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, yymsp[0].minor.yy168, NULL); }
break;
case 54: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */
{ PARSER_TRACE; yylhsminor.yy212 = createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, yymsp[-2].minor.yy212, yymsp[0].minor.yy212); }
yymsp[-2].minor.yy212 = yylhsminor.yy212;
{ PARSER_TRACE; yylhsminor.yy168 = createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, yymsp[-2].minor.yy168, yymsp[0].minor.yy168); }
yymsp[-2].minor.yy168 = yylhsminor.yy168;
break;
case 55: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */
{ PARSER_TRACE; yylhsminor.yy212 = createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, yymsp[-2].minor.yy212, yymsp[0].minor.yy212); }
yymsp[-2].minor.yy212 = yylhsminor.yy212;
{ PARSER_TRACE; yylhsminor.yy168 = createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, yymsp[-2].minor.yy168, yymsp[0].minor.yy168); }
yymsp[-2].minor.yy168 = yylhsminor.yy168;
break;
case 60: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */
{ PARSER_TRACE; yylhsminor.yy212 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy212, yymsp[0].minor.yy212, NULL); }
yymsp[-2].minor.yy212 = yylhsminor.yy212;
{ PARSER_TRACE; yylhsminor.yy168 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy168, yymsp[0].minor.yy168, NULL); }
yymsp[-2].minor.yy168 = yylhsminor.yy168;
break;
case 63: /* table_primary ::= table_name alias_opt */
{ PARSER_TRACE; yylhsminor.yy212 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy79, &yymsp[0].minor.yy79); }
yymsp[-1].minor.yy212 = yylhsminor.yy212;
{ PARSER_TRACE; yylhsminor.yy168 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy241, &yymsp[0].minor.yy241); }
yymsp[-1].minor.yy168 = yylhsminor.yy168;
break;
case 64: /* table_primary ::= db_name NK_DOT table_name alias_opt */
{ PARSER_TRACE; yylhsminor.yy212 = createRealTableNode(pCxt, &yymsp[-3].minor.yy79, &yymsp[-1].minor.yy79, &yymsp[0].minor.yy79); }
yymsp[-3].minor.yy212 = yylhsminor.yy212;
{ PARSER_TRACE; yylhsminor.yy168 = createRealTableNode(pCxt, &yymsp[-3].minor.yy241, &yymsp[-1].minor.yy241, &yymsp[0].minor.yy241); }
yymsp[-3].minor.yy168 = yylhsminor.yy168;
break;
case 65: /* table_primary ::= subquery alias_opt */
{ PARSER_TRACE; yylhsminor.yy212 = createTempTableNode(pCxt, yymsp[-1].minor.yy212, &yymsp[0].minor.yy79); }
yymsp[-1].minor.yy212 = yylhsminor.yy212;
{ PARSER_TRACE; yylhsminor.yy168 = createTempTableNode(pCxt, yymsp[-1].minor.yy168, &yymsp[0].minor.yy241); }
yymsp[-1].minor.yy168 = yylhsminor.yy168;
break;
case 66: /* alias_opt ::= */
{ PARSER_TRACE; yymsp[1].minor.yy79 = nil_token; }
case 67: /* alias_opt ::= */
{ PARSER_TRACE; yymsp[1].minor.yy241 = nil_token; }
break;
case 67: /* alias_opt ::= table_alias */
{ PARSER_TRACE; yylhsminor.yy79 = yymsp[0].minor.yy79; }
yymsp[0].minor.yy79 = yylhsminor.yy79;
case 68: /* alias_opt ::= table_alias */
{ PARSER_TRACE; yylhsminor.yy241 = yymsp[0].minor.yy241; }
yymsp[0].minor.yy241 = yylhsminor.yy241;
break;
case 68: /* alias_opt ::= AS table_alias */
{ PARSER_TRACE; yymsp[-1].minor.yy79 = yymsp[0].minor.yy79; }
case 69: /* alias_opt ::= AS table_alias */
{ PARSER_TRACE; yymsp[-1].minor.yy241 = yymsp[0].minor.yy241; }
break;
case 71: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */
{ PARSER_TRACE; yylhsminor.yy212 = createJoinTableNode(pCxt, yymsp[-4].minor.yy162, yymsp[-5].minor.yy212, yymsp[-2].minor.yy212, yymsp[0].minor.yy212); }
yymsp[-5].minor.yy212 = yylhsminor.yy212;
case 72: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */
{ PARSER_TRACE; yylhsminor.yy168 = createJoinTableNode(pCxt, yymsp[-4].minor.yy229, yymsp[-5].minor.yy168, yymsp[-2].minor.yy168, yymsp[0].minor.yy168); }
yymsp[-5].minor.yy168 = yylhsminor.yy168;
break;
case 72: /* join_type ::= INNER */
{ PARSER_TRACE; yymsp[0].minor.yy162 = JOIN_TYPE_INNER; }
case 73: /* join_type ::= INNER */
{ PARSER_TRACE; yymsp[0].minor.yy229 = JOIN_TYPE_INNER; }
break;
case 73: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */
case 74: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */
{
PARSER_TRACE;
yymsp[-8].minor.yy212 = createSelectStmt(pCxt, yymsp[-7].minor.yy237, yymsp[-6].minor.yy174, yymsp[-5].minor.yy212);
yymsp[-8].minor.yy212 = addWhereClause(pCxt, yymsp[-8].minor.yy212, yymsp[-4].minor.yy212);
yymsp[-8].minor.yy212 = addPartitionByClause(pCxt, yymsp[-8].minor.yy212, yymsp[-3].minor.yy174);
yymsp[-8].minor.yy212 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy212, yymsp[-2].minor.yy212);
yymsp[-8].minor.yy212 = addGroupByClause(pCxt, yymsp[-8].minor.yy212, yymsp[-1].minor.yy174);
yymsp[-8].minor.yy212 = addHavingClause(pCxt, yymsp[-8].minor.yy212, yymsp[0].minor.yy212);
yymsp[-8].minor.yy168 = createSelectStmt(pCxt, yymsp[-7].minor.yy209, yymsp[-6].minor.yy192, yymsp[-5].minor.yy168);
yymsp[-8].minor.yy168 = addWhereClause(pCxt, yymsp[-8].minor.yy168, yymsp[-4].minor.yy168);
yymsp[-8].minor.yy168 = addPartitionByClause(pCxt, yymsp[-8].minor.yy168, yymsp[-3].minor.yy192);
yymsp[-8].minor.yy168 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy168, yymsp[-2].minor.yy168);
yymsp[-8].minor.yy168 = addGroupByClause(pCxt, yymsp[-8].minor.yy168, yymsp[-1].minor.yy192);
yymsp[-8].minor.yy168 = addHavingClause(pCxt, yymsp[-8].minor.yy168, yymsp[0].minor.yy168);
}
break;
case 74: /* set_quantifier_opt ::= */
{ PARSER_TRACE; yymsp[1].minor.yy237 = false; }
case 75: /* set_quantifier_opt ::= */
{ PARSER_TRACE; yymsp[1].minor.yy209 = false; }
break;
case 75: /* set_quantifier_opt ::= DISTINCT */
{ PARSER_TRACE; yymsp[0].minor.yy237 = true; }
case 76: /* set_quantifier_opt ::= DISTINCT */
{ PARSER_TRACE; yymsp[0].minor.yy209 = true; }
break;
case 76: /* set_quantifier_opt ::= ALL */
{ PARSER_TRACE; yymsp[0].minor.yy237 = false; }
case 77: /* set_quantifier_opt ::= ALL */
{ PARSER_TRACE; yymsp[0].minor.yy209 = false; }
break;
case 77: /* select_list ::= NK_STAR */
{ PARSER_TRACE; yymsp[0].minor.yy174 = NULL; }
case 78: /* select_list ::= NK_STAR */
{ PARSER_TRACE; yymsp[0].minor.yy192 = NULL; }
break;
case 78: /* select_list ::= select_sublist */
{ PARSER_TRACE; yylhsminor.yy174 = yymsp[0].minor.yy174; }
yymsp[0].minor.yy174 = yylhsminor.yy174;
case 79: /* select_list ::= select_sublist */
{ PARSER_TRACE; yylhsminor.yy192 = yymsp[0].minor.yy192; }
yymsp[0].minor.yy192 = yylhsminor.yy192;
break;
case 82: /* select_item ::= expression column_alias */
{ PARSER_TRACE; yylhsminor.yy212 = setProjectionAlias(pCxt, yymsp[-1].minor.yy212, &yymsp[0].minor.yy79); }
yymsp[-1].minor.yy212 = yylhsminor.yy212;
case 83: /* select_item ::= expression column_alias */
{ PARSER_TRACE; yylhsminor.yy168 = setProjectionAlias(pCxt, yymsp[-1].minor.yy168, &yymsp[0].minor.yy241); }
yymsp[-1].minor.yy168 = yylhsminor.yy168;
break;
case 83: /* select_item ::= expression AS column_alias */
{ PARSER_TRACE; yylhsminor.yy212 = setProjectionAlias(pCxt, yymsp[-2].minor.yy212, &yymsp[0].minor.yy79); }
yymsp[-2].minor.yy212 = yylhsminor.yy212;
case 84: /* select_item ::= expression AS column_alias */
{ PARSER_TRACE; yylhsminor.yy168 = setProjectionAlias(pCxt, yymsp[-2].minor.yy168, &yymsp[0].minor.yy241); }
yymsp[-2].minor.yy168 = yylhsminor.yy168;
break;
case 84: /* select_item ::= table_name NK_DOT NK_STAR */
{ PARSER_TRACE; yylhsminor.yy212 = createColumnNode(pCxt, &yymsp[-2].minor.yy79, &yymsp[0].minor.yy0); }
yymsp[-2].minor.yy212 = yylhsminor.yy212;
case 85: /* select_item ::= table_name NK_DOT NK_STAR */
{ PARSER_TRACE; yylhsminor.yy168 = createColumnNode(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy0); }
yymsp[-2].minor.yy168 = yylhsminor.yy168;
break;
case 85: /* where_clause_opt ::= */
case 89: /* twindow_clause_opt ::= */ yytestcase(yyruleno==89);
case 94: /* sliding_opt ::= */ yytestcase(yyruleno==94);
case 96: /* fill_opt ::= */ yytestcase(yyruleno==96);
case 106: /* having_clause_opt ::= */ yytestcase(yyruleno==106);
case 86: /* where_clause_opt ::= */
case 90: /* twindow_clause_opt ::= */ yytestcase(yyruleno==90);
case 95: /* sliding_opt ::= */ yytestcase(yyruleno==95);
case 97: /* fill_opt ::= */ yytestcase(yyruleno==97);
case 107: /* having_clause_opt ::= */ yytestcase(yyruleno==107);
case 115: /* slimit_clause_opt ::= */ yytestcase(yyruleno==115);
case 119: /* limit_clause_opt ::= */ yytestcase(yyruleno==119);
{ PARSER_TRACE; yymsp[1].minor.yy212 = NULL; }
{ PARSER_TRACE; yymsp[1].minor.yy168 = NULL; }
break;
case 87: /* partition_by_clause_opt ::= */
case 104: /* group_by_clause_opt ::= */ yytestcase(yyruleno==104);
case 88: /* partition_by_clause_opt ::= */
case 105: /* group_by_clause_opt ::= */ yytestcase(yyruleno==105);
case 113: /* order_by_clause_opt ::= */ yytestcase(yyruleno==113);
{ PARSER_TRACE; yymsp[1].minor.yy174 = NULL; }
{ PARSER_TRACE; yymsp[1].minor.yy192 = NULL; }
break;
case 88: /* partition_by_clause_opt ::= PARTITION BY expression_list */
case 105: /* group_by_clause_opt ::= GROUP BY expression_list */ yytestcase(yyruleno==105);
case 89: /* partition_by_clause_opt ::= PARTITION BY expression_list */
case 106: /* group_by_clause_opt ::= GROUP BY expression_list */ yytestcase(yyruleno==106);
case 114: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==114);
{ PARSER_TRACE; yymsp[-2].minor.yy174 = yymsp[0].minor.yy174; }
{ PARSER_TRACE; yymsp[-2].minor.yy192 = yymsp[0].minor.yy192; }
break;
case 90: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */
{ PARSER_TRACE; yymsp[-5].minor.yy212 = createSessionWindowNode(pCxt, yymsp[-3].minor.yy212, &yymsp[-1].minor.yy0); }
case 91: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */
{ PARSER_TRACE; yymsp[-5].minor.yy168 = createSessionWindowNode(pCxt, yymsp[-3].minor.yy168, &yymsp[-1].minor.yy0); }
break;
case 91: /* twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */
{ PARSER_TRACE; yymsp[-3].minor.yy212 = createStateWindowNode(pCxt, yymsp[-1].minor.yy212); }
case 92: /* twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */
{ PARSER_TRACE; yymsp[-3].minor.yy168 = createStateWindowNode(pCxt, yymsp[-1].minor.yy168); }
break;
case 92: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */
{ PARSER_TRACE; yymsp[-5].minor.yy212 = createIntervalWindowNode(pCxt, yymsp[-3].minor.yy212, NULL, yymsp[-1].minor.yy212, yymsp[0].minor.yy212); }
case 93: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */
{ PARSER_TRACE; yymsp[-5].minor.yy168 = createIntervalWindowNode(pCxt, yymsp[-3].minor.yy168, NULL, yymsp[-1].minor.yy168, yymsp[0].minor.yy168); }
break;
case 93: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */
{ PARSER_TRACE; yymsp[-7].minor.yy212 = createIntervalWindowNode(pCxt, yymsp[-5].minor.yy212, yymsp[-3].minor.yy212, yymsp[-1].minor.yy212, yymsp[0].minor.yy212); }
case 94: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */
{ PARSER_TRACE; yymsp[-7].minor.yy168 = createIntervalWindowNode(pCxt, yymsp[-5].minor.yy168, yymsp[-3].minor.yy168, yymsp[-1].minor.yy168, yymsp[0].minor.yy168); }
break;
case 95: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */
{ PARSER_TRACE; yymsp[-3].minor.yy212 = yymsp[-1].minor.yy212; }
case 96: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */
{ PARSER_TRACE; yymsp[-3].minor.yy168 = yymsp[-1].minor.yy168; }
break;
case 97: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */
{ PARSER_TRACE; yymsp[-3].minor.yy212 = createFillNode(pCxt, yymsp[-1].minor.yy44, NULL); }
case 98: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */
{ PARSER_TRACE; yymsp[-3].minor.yy168 = createFillNode(pCxt, yymsp[-1].minor.yy14, NULL); }
break;
case 98: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */
{ PARSER_TRACE; yymsp[-5].minor.yy212 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy174)); }
case 99: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */
{ PARSER_TRACE; yymsp[-5].minor.yy168 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy192)); }
break;
case 99: /* fill_mode ::= NONE */
{ PARSER_TRACE; yymsp[0].minor.yy44 = FILL_MODE_NONE; }
case 100: /* fill_mode ::= NONE */
{ PARSER_TRACE; yymsp[0].minor.yy14 = FILL_MODE_NONE; }
break;
case 100: /* fill_mode ::= PREV */
{ PARSER_TRACE; yymsp[0].minor.yy44 = FILL_MODE_PREV; }
case 101: /* fill_mode ::= PREV */
{ PARSER_TRACE; yymsp[0].minor.yy14 = FILL_MODE_PREV; }
break;
case 101: /* fill_mode ::= NULL */
{ PARSER_TRACE; yymsp[0].minor.yy44 = FILL_MODE_NULL; }
case 102: /* fill_mode ::= NULL */
{ PARSER_TRACE; yymsp[0].minor.yy14 = FILL_MODE_NULL; }
break;
case 102: /* fill_mode ::= LINEAR */
{ PARSER_TRACE; yymsp[0].minor.yy44 = FILL_MODE_LINEAR; }
case 103: /* fill_mode ::= LINEAR */
{ PARSER_TRACE; yymsp[0].minor.yy14 = FILL_MODE_LINEAR; }
break;
case 103: /* fill_mode ::= NEXT */
{ PARSER_TRACE; yymsp[0].minor.yy44 = FILL_MODE_NEXT; }
case 104: /* fill_mode ::= NEXT */
{ PARSER_TRACE; yymsp[0].minor.yy14 = FILL_MODE_NEXT; }
break;
case 108: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */
case 109: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */
{
PARSER_TRACE;
yylhsminor.yy212 = addOrderByClause(pCxt, yymsp[-3].minor.yy212, yymsp[-2].minor.yy174);
yylhsminor.yy212 = addSlimitClause(pCxt, yylhsminor.yy212, yymsp[-1].minor.yy212);
yylhsminor.yy212 = addLimitClause(pCxt, yylhsminor.yy212, yymsp[0].minor.yy212);
yylhsminor.yy168 = addOrderByClause(pCxt, yymsp[-3].minor.yy168, yymsp[-2].minor.yy192);
yylhsminor.yy168 = addSlimitClause(pCxt, yylhsminor.yy168, yymsp[-1].minor.yy168);
yylhsminor.yy168 = addLimitClause(pCxt, yylhsminor.yy168, yymsp[0].minor.yy168);
}
yymsp[-3].minor.yy212 = yylhsminor.yy212;
yymsp[-3].minor.yy168 = yylhsminor.yy168;
break;
case 110: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */
{ PARSER_TRACE; yylhsminor.yy212 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy212, yymsp[0].minor.yy212); }
yymsp[-3].minor.yy212 = yylhsminor.yy212;
break;
case 112: /* query_primary ::= NK_LP query_expression_body order_by_clause_opt limit_clause_opt slimit_clause_opt NK_RP */
{ PARSER_TRACE; yymsp[-5].minor.yy212 = yymsp[-4].minor.yy212;}
yy_destructor(yypParser,117,&yymsp[-3].minor);
yy_destructor(yypParser,119,&yymsp[-2].minor);
yy_destructor(yypParser,118,&yymsp[-1].minor);
case 111: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */
{ PARSER_TRACE; yylhsminor.yy168 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy168, yymsp[0].minor.yy168); }
yymsp[-3].minor.yy168 = yylhsminor.yy168;
break;
case 116: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */
case 120: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==120);
{ PARSER_TRACE; yymsp[-1].minor.yy212 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); }
{ PARSER_TRACE; yymsp[-1].minor.yy168 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); }
break;
case 117: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */
case 121: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==121);
{ PARSER_TRACE; yymsp[-3].minor.yy212 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); }
{ PARSER_TRACE; yymsp[-3].minor.yy168 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); }
break;
case 118: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */
case 122: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==122);
{ PARSER_TRACE; yymsp[-3].minor.yy212 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); }
{ PARSER_TRACE; yymsp[-3].minor.yy168 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); }
break;
case 127: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */
{ PARSER_TRACE; yylhsminor.yy212 = createOrderByExprNode(pCxt, yymsp[-2].minor.yy212, yymsp[-1].minor.yy188, yymsp[0].minor.yy107); }
yymsp[-2].minor.yy212 = yylhsminor.yy212;
{ PARSER_TRACE; yylhsminor.yy168 = createOrderByExprNode(pCxt, yymsp[-2].minor.yy168, yymsp[-1].minor.yy10, yymsp[0].minor.yy177); }
yymsp[-2].minor.yy168 = yylhsminor.yy168;
break;
case 128: /* ordering_specification_opt ::= */
{ PARSER_TRACE; yymsp[1].minor.yy188 = ORDER_ASC; }
{ PARSER_TRACE; yymsp[1].minor.yy10 = ORDER_ASC; }
break;
case 129: /* ordering_specification_opt ::= ASC */
{ PARSER_TRACE; yymsp[0].minor.yy188 = ORDER_ASC; }
{ PARSER_TRACE; yymsp[0].minor.yy10 = ORDER_ASC; }
break;
case 130: /* ordering_specification_opt ::= DESC */
{ PARSER_TRACE; yymsp[0].minor.yy188 = ORDER_DESC; }
{ PARSER_TRACE; yymsp[0].minor.yy10 = ORDER_DESC; }
break;
case 131: /* null_ordering_opt ::= */
{ PARSER_TRACE; yymsp[1].minor.yy107 = NULL_ORDER_DEFAULT; }
{ PARSER_TRACE; yymsp[1].minor.yy177 = NULL_ORDER_DEFAULT; }
break;
case 132: /* null_ordering_opt ::= NULLS FIRST */
{ PARSER_TRACE; yymsp[-1].minor.yy107 = NULL_ORDER_FIRST; }
{ PARSER_TRACE; yymsp[-1].minor.yy177 = NULL_ORDER_FIRST; }
break;
case 133: /* null_ordering_opt ::= NULLS LAST */
{ PARSER_TRACE; yymsp[-1].minor.yy107 = NULL_ORDER_LAST; }
break;
case 134: /* table_primary ::= parenthesized_joined_table */
{ yy_destructor(yypParser,100,&yymsp[0].minor);
{
}
}
{ PARSER_TRACE; yymsp[-1].minor.yy177 = NULL_ORDER_LAST; }
break;
default:
break;
......
......@@ -25,9 +25,14 @@ typedef void (*FFree)(void*);
extern void* NewParseAlloc(FMalloc);
extern void NewParse(void*, int, SToken, void*);
extern void NewParseFree(void*, FFree);
extern void NewParseTrace(FILE*, char*);
static uint32_t toNewTokenId(uint32_t tokenId) {
switch (tokenId) {
case TK_OR:
return NEW_TK_OR;
case TK_AND:
return NEW_TK_AND;
case TK_UNION:
return NEW_TK_UNION;
case TK_ALL:
......@@ -40,28 +45,104 @@ static uint32_t toNewTokenId(uint32_t tokenId) {
return NEW_TK_NK_STAR;
case TK_SLASH:
return NEW_TK_NK_SLASH;
case TK_REM:
return NEW_TK_NK_REM;
case TK_SHOW:
return NEW_TK_SHOW;
case TK_DATABASES:
return NEW_TK_DATABASES;
case TK_INTEGER:
return NEW_TK_NK_INTEGER;
case TK_FLOAT:
return NEW_TK_NK_FLOAT;
case TK_STRING:
return NEW_TK_NK_STRING;
case TK_BOOL:
return NEW_TK_NK_BOOL;
case TK_TIMESTAMP:
return NEW_TK_TIMESTAMP;
case TK_VARIABLE:
return NEW_TK_NK_VARIABLE;
case TK_COMMA:
return NEW_TK_NK_COMMA;
case TK_ID:
return NEW_TK_NK_ID;
case TK_LP:
return NEW_TK_NK_LP;
case TK_RP:
return NEW_TK_NK_RP;
case TK_COMMA:
return NEW_TK_NK_COMMA;
case TK_DOT:
return NEW_TK_NK_DOT;
case TK_BETWEEN:
return NEW_TK_BETWEEN;
case TK_NOT:
return NEW_TK_NOT;
case TK_IS:
return NEW_TK_IS;
case TK_NULL:
return NEW_TK_NULL;
case TK_LT:
return NEW_TK_NK_LT;
case TK_GT:
return NEW_TK_NK_GT;
case TK_LE:
return NEW_TK_NK_LE;
case TK_GE:
return NEW_TK_NK_GE;
case TK_NE:
return NEW_TK_NK_NE;
case TK_EQ:
return NEW_TK_NK_EQ;
case TK_LIKE:
return NEW_TK_LIKE;
case TK_MATCH:
return NEW_TK_MATCH;
case TK_NMATCH:
return NEW_TK_NMATCH;
case TK_IN:
return NEW_TK_IN;
case TK_SELECT:
return NEW_TK_SELECT;
case TK_DISTINCT:
return NEW_TK_DISTINCT;
case TK_WHERE:
return NEW_TK_WHERE;
case TK_AS:
return NEW_TK_AS;
case TK_FROM:
return NEW_TK_FROM;
case TK_JOIN:
return NEW_TK_JOIN;
// case TK_ON:
// return NEW_TK_ON;
// case TK_INNER:
// return NEW_TK_INNER;
// case TK_PARTITION:
// return NEW_TK_PARTITION;
case TK_SESSION:
return NEW_TK_SESSION;
case TK_STATE_WINDOW:
return NEW_TK_STATE_WINDOW;
case TK_INTERVAL:
return NEW_TK_INTERVAL;
case TK_SLIDING:
return NEW_TK_SLIDING;
case TK_FILL:
return NEW_TK_FILL;
// case TK_VALUE:
// return NEW_TK_VALUE;
case TK_NONE:
return NEW_TK_NONE;
case TK_PREV:
return NEW_TK_PREV;
case TK_LINEAR:
return NEW_TK_LINEAR;
// case TK_NEXT:
// return NEW_TK_NEXT;
case TK_GROUP:
return NEW_TK_GROUP;
case TK_HAVING:
return NEW_TK_HAVING;
case TK_ORDER:
return NEW_TK_ORDER;
case TK_BY:
......@@ -70,6 +151,18 @@ static uint32_t toNewTokenId(uint32_t tokenId) {
return NEW_TK_ASC;
case TK_DESC:
return NEW_TK_DESC;
case TK_SLIMIT:
return NEW_TK_SLIMIT;
case TK_SOFFSET:
return NEW_TK_SOFFSET;
case TK_LIMIT:
return NEW_TK_LIMIT;
case TK_OFFSET:
return NEW_TK_OFFSET;
case TK_SPACE:
break;
default:
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!tokenId = %d\n", tokenId);
}
return tokenId;
}
......@@ -125,6 +218,7 @@ int32_t doParse(SParseContext* pParseCxt, SQuery* pQuery) {
default:
NewParse(pParser, t0.type, t0, &cxt);
// NewParseTrace(stdout, "");
if (!cxt.valid) {
goto abort_parse;
}
......@@ -139,13 +233,10 @@ abort_parse:
return cxt.valid ? TSDB_CODE_SUCCESS : TSDB_CODE_FAILED;
}
// typedef struct SNamespace {
// int16_t level; // todo for correlated subquery
// char dbName[TSDB_DB_NAME_LEN];
// char tableAlias[TSDB_TABLE_NAME_LEN];
// SHashObj* pColHash; // key is colname, value is index of STableMeta.schema
// STableMeta* pMeta;
// } SNamespace;
typedef enum ESqlClause {
SQL_CLAUSE_FROM = 1,
SQL_CLAUSE_WHERE
} ESqlClause;
typedef struct STranslateContext {
SParseContext* pParseCxt;
......@@ -153,6 +244,7 @@ typedef struct STranslateContext {
SMsgBuf msgBuf;
SArray* pNsLevel; // element is SArray*, the element of this subarray is STableNode*
int32_t currLevel;
ESqlClause currClause;
} STranslateContext;
static int32_t translateSubquery(STranslateContext* pCxt, SNode* pNode);
......@@ -165,6 +257,8 @@ static char* getSyntaxErrFormat(int32_t errCode) {
return "Table does not exist : %s";
case TSDB_CODE_PARSER_AMBIGUOUS_COLUMN:
return "Column ambiguously defined : %s";
case TSDB_CODE_PARSER_WRONG_VALUE_TYPE:
return "Invalid value type : %s";
default:
return "Unknown error";
}
......@@ -177,19 +271,28 @@ static int32_t generateSyntaxErrMsg(STranslateContext* pCxt, int32_t errCode, co
}
static int32_t addNamespace(STranslateContext* pCxt, void* pTable) {
SArray* pTables = NULL;
if (taosArrayGetSize(pCxt->pNsLevel) > pCxt->currLevel) {
pTables = taosArrayGetP(pCxt->pNsLevel, pCxt->currLevel);
size_t currTotalLevel = taosArrayGetSize(pCxt->pNsLevel);
if (currTotalLevel > pCxt->currLevel) {
SArray* pTables = taosArrayGetP(pCxt->pNsLevel, pCxt->currLevel);
taosArrayPush(pTables, &pTable);
} else {
pTables = taosArrayInit(TARRAY_MIN_SIZE, POINTER_BYTES);
do {
SArray* pTables = taosArrayInit(TARRAY_MIN_SIZE, POINTER_BYTES);
if (pCxt->currLevel == currTotalLevel) {
taosArrayPush(pTables, &pTable);
}
taosArrayPush(pCxt->pNsLevel, &pTables);
++currTotalLevel;
} while (currTotalLevel <= pCxt->currLevel);
}
taosArrayPush(pTables, &pTable);
return TSDB_CODE_SUCCESS;
}
static SName* toName(const SRealTableNode* pRealTable, SName* pName) {
strncpy(pName->dbname, pRealTable->table.dbName, strlen(pRealTable->table.dbName));
strncpy(pName->dbname, pRealTable->table.tableName, strlen(pRealTable->table.tableName));
static SName* toName(int32_t acctId, const SRealTableNode* pRealTable, SName* pName) {
pName->type = TSDB_TABLE_NAME_T;
pName->acctId = acctId;
strcpy(pName->dbname, pRealTable->table.dbName);
strcpy(pName->tname, pRealTable->table.tableName);
return pName;
}
......@@ -213,26 +316,43 @@ static SNodeList* getProjectList(SNode* pNode) {
return NULL;
}
static void setColumnInfoBySchema(const STableNode* pTable, const SSchema* pColSchema, SColumnNode* pCol) {
strcpy(pCol->dbName, pTable->dbName);
strcpy(pCol->tableAlias, pTable->tableAlias);
strcpy(pCol->tableName, pTable->tableName);
strcpy(pCol->colName, pColSchema->name);
if ('\0' == pCol->node.aliasName[0]) {
strcpy(pCol->node.aliasName, pColSchema->name);
}
pCol->colId = pColSchema->colId;
// pCol->colType = pColSchema->type;
pCol->node.resType.type = pColSchema->type;
pCol->node.resType.bytes = pColSchema->bytes;
}
static void setColumnInfoByExpr(const STableNode* pTable, SExprNode* pExpr, SColumnNode* pCol) {
pCol->pProjectRef = (SNode*)pExpr;
pExpr->pAssociationList = nodesListAppend(pExpr->pAssociationList, (SNode*)pCol);
strcpy(pCol->tableAlias, pTable->tableAlias);
strcpy(pCol->colName, pExpr->aliasName);
pCol->node.resType = pExpr->resType;
}
static int32_t createColumnNodeByTable(const STableNode* pTable, SNodeList* pList) {
if (QUERY_NODE_REAL_TABLE == nodeType(pTable)) {
const STableMeta* pMeta = ((SRealTableNode*)pTable)->pMeta;
int32_t nums = pMeta->tableInfo.numOfTags + pMeta->tableInfo.numOfColumns;
for (int32_t i = 0; i < nums; ++i) {
SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
pCol->colId = pMeta->schema[i].colId;
pCol->colType = pMeta->schema[i].type;
pCol->node.resType.bytes = pMeta->schema[i].bytes;
setColumnInfoBySchema(pTable, pMeta->schema + i, pCol);
nodesListAppend(pList, (SNode*)pCol);
}
} else {
SNodeList* pProjectList = getProjectList(((STempTableNode*)pTable)->pSubquery);
SNode* pNode;
FOREACH(pNode, pProjectList) {
SExprNode* pExpr = (SExprNode*)pNode;
SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
pCol->pProjectRef = (SNode*)pExpr;
pExpr->pAssociationList = nodesListAppend(pExpr->pAssociationList, (SNode*)pCol);
pCol->node.resType = pExpr->resType;
setColumnInfoByExpr(pTable, (SExprNode*)pNode, pCol);
nodesListAppend(pList, (SNode*)pCol);
}
}
......@@ -245,9 +365,7 @@ static bool findAndSetColumn(SColumnNode* pCol, const STableNode* pTable) {
int32_t nums = pMeta->tableInfo.numOfTags + pMeta->tableInfo.numOfColumns;
for (int32_t i = 0; i < nums; ++i) {
if (0 == strcmp(pCol->colName, pMeta->schema[i].name)) {
pCol->colId = pMeta->schema[i].colId;
pCol->colType = pMeta->schema[i].type;
pCol->node.resType.bytes = pMeta->schema[i].bytes;
setColumnInfoBySchema(pTable, pMeta->schema + i, pCol);
found = true;
break;
}
......@@ -258,9 +376,7 @@ static bool findAndSetColumn(SColumnNode* pCol, const STableNode* pTable) {
FOREACH(pNode, pProjectList) {
SExprNode* pExpr = (SExprNode*)pNode;
if (0 == strcmp(pCol->colName, pExpr->aliasName)) {
pCol->pProjectRef = (SNode*)pExpr;
pExpr->pAssociationList = nodesListAppend(pExpr->pAssociationList, (SNode*)pCol);
pCol->node.resType = pExpr->resType;
setColumnInfoByExpr(pTable, pExpr, pCol);
found = true;
break;
}
......@@ -269,45 +385,98 @@ static bool findAndSetColumn(SColumnNode* pCol, const STableNode* pTable) {
return found;
}
static bool doTranslateExpr(SNode* pNode, void* pContext) {
STranslateContext* pCxt = (STranslateContext*)pContext;
switch (nodeType(pNode)) {
case QUERY_NODE_COLUMN: {
SColumnNode* pCol = (SColumnNode*)pNode;
SArray* pTables = taosArrayGetP(pCxt->pNsLevel, pCxt->currLevel);
size_t nums = taosArrayGetSize(pTables);
bool hasTableAlias = ('\0' != pCol->tableAlias[0]);
bool found = false;
for (size_t i = 0; i < nums; ++i) {
STableNode* pTable = taosArrayGetP(pTables, i);
if (hasTableAlias) {
if (belongTable(pCxt->pParseCxt->db, pCol, pTable)) {
if (findAndSetColumn(pCol, pTable)) {
break;
}
generateSyntaxErrMsg(pCxt, TSDB_CODE_PARSER_INVALID_COLUMN, pCol->colName);
return false;
}
} else {
if (findAndSetColumn(pCol, pTable)) {
if (found) {
generateSyntaxErrMsg(pCxt, TSDB_CODE_PARSER_AMBIGUOUS_COLUMN, pCol->colName);
return false;
}
found = true;
}
}
static bool translateColumnWithPrefix(STranslateContext* pCxt, SColumnNode* pCol) {
SArray* pTables = taosArrayGetP(pCxt->pNsLevel, pCxt->currLevel);
size_t nums = taosArrayGetSize(pTables);
for (size_t i = 0; i < nums; ++i) {
STableNode* pTable = taosArrayGetP(pTables, i);
if (belongTable(pCxt->pParseCxt->db, pCol, pTable)) {
if (findAndSetColumn(pCol, pTable)) {
break;
}
break;
generateSyntaxErrMsg(pCxt, TSDB_CODE_PARSER_INVALID_COLUMN, pCol->colName);
return false;
}
case QUERY_NODE_VALUE:
break; // todo check literal format
case QUERY_NODE_OPERATOR: {
}
return true;
}
break;
static bool translateColumnWithoutPrefix(STranslateContext* pCxt, SColumnNode* pCol) {
SArray* pTables = taosArrayGetP(pCxt->pNsLevel, pCxt->currLevel);
size_t nums = taosArrayGetSize(pTables);
bool found = false;
for (size_t i = 0; i < nums; ++i) {
STableNode* pTable = taosArrayGetP(pTables, i);
if (findAndSetColumn(pCol, pTable)) {
if (found) {
generateSyntaxErrMsg(pCxt, TSDB_CODE_PARSER_AMBIGUOUS_COLUMN, pCol->colName);
return false;
}
found = true;
}
}
if (!found) {
generateSyntaxErrMsg(pCxt, TSDB_CODE_PARSER_INVALID_COLUMN, pCol->colName);
return false;
}
return true;
}
static bool translateColumn(STranslateContext* pCxt, SColumnNode* pCol) {
if ('\0' != pCol->tableAlias[0]) {
return translateColumnWithPrefix(pCxt, pCol);
}
return translateColumnWithoutPrefix(pCxt, pCol);
}
// check literal format
static bool translateValue(STranslateContext* pCxt, SValueNode* pVal) {
return true;
}
static bool translateOperator(STranslateContext* pCxt, SOperatorNode* pOp) {
SDataType ldt = ((SExprNode*)(pOp->pLeft))->resType;
SDataType rdt = ((SExprNode*)(pOp->pRight))->resType;
if (nodesIsArithmeticOp(pOp)) {
if (TSDB_DATA_TYPE_JSON == ldt.type || TSDB_DATA_TYPE_BLOB == ldt.type ||
TSDB_DATA_TYPE_JSON == rdt.type || TSDB_DATA_TYPE_BLOB == rdt.type) {
generateSyntaxErrMsg(pCxt, TSDB_CODE_PARSER_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName);
return false;
}
pOp->node.resType.type = TSDB_DATA_TYPE_DOUBLE;
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes;
return true;
} else if (nodesIsComparisonOp(pOp)) {
if (TSDB_DATA_TYPE_JSON == ldt.type || TSDB_DATA_TYPE_BLOB == ldt.type ||
TSDB_DATA_TYPE_JSON == rdt.type || TSDB_DATA_TYPE_BLOB == rdt.type) {
generateSyntaxErrMsg(pCxt, TSDB_CODE_PARSER_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName);
return false;
}
pOp->node.resType.type = TSDB_DATA_TYPE_BOOL;
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes;
return true;
} else {
// todo json operator
return true;
}
return true;
}
static bool translateFunction(STranslateContext* pCxt, SFunctionNode* pFunc) {
return true;
}
static bool doTranslateExpr(SNode* pNode, void* pContext) {
STranslateContext* pCxt = (STranslateContext*)pContext;
switch (nodeType(pNode)) {
case QUERY_NODE_COLUMN:
return translateColumn(pCxt, (SColumnNode*)pNode);
case QUERY_NODE_VALUE:
return translateValue(pCxt, (SValueNode*)pNode);
case QUERY_NODE_OPERATOR:
return translateOperator(pCxt, (SOperatorNode*)pNode);
case QUERY_NODE_FUNCTION:
break; // todo
return translateFunction(pCxt, (SFunctionNode*)pNode);
case QUERY_NODE_TEMP_TABLE:
return translateSubquery(pCxt, ((STempTableNode*)pNode)->pSubquery);
default:
......@@ -331,15 +500,9 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
switch (nodeType(pTable)) {
case QUERY_NODE_REAL_TABLE: {
SRealTableNode* pRealTable = (SRealTableNode*)pTable;
if ('\0' == pRealTable->table.dbName[0]) {
strcpy(pRealTable->table.dbName, pCxt->pParseCxt->db);
}
if ('\0' == pRealTable->table.tableAlias[0]) {
strcpy(pRealTable->table.tableAlias, pRealTable->table.tableName);
}
SName name;
code = catalogGetTableMeta(
pCxt->pParseCxt->pCatalog, pCxt->pParseCxt->pTransporter, &(pCxt->pParseCxt->mgmtEpSet), toName(pRealTable, &name), &(pRealTable->pMeta));
code = catalogGetTableMeta(pCxt->pParseCxt->pCatalog, pCxt->pParseCxt->pTransporter, &(pCxt->pParseCxt->mgmtEpSet),
toName(pCxt->pParseCxt->acctId, pRealTable, &name), &(pRealTable->pMeta));
if (TSDB_CODE_SUCCESS != code) {
return generateSyntaxErrMsg(pCxt, TSDB_CODE_PARSER_TABLE_NOT_EXIST, pRealTable->table.tableName);
}
......@@ -371,10 +534,16 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
return code;
}
static int32_t translateFrom(STranslateContext* pCxt, SNode* pTable) {
pCxt->currClause = SQL_CLAUSE_FROM;
return translateTable(pCxt, pTable);
}
static int32_t translateStar(STranslateContext* pCxt, SSelectStmt* pSelect, bool* pIsSelectStar) {
if (NULL == pSelect->pProjectionList) { // select * ...
SArray* pTables = taosArrayGetP(pCxt->pNsLevel, pCxt->currLevel);
size_t nums = taosArrayGetSize(pTables);
pSelect->pProjectionList = nodesMakeList();
for (size_t i = 0; i < nums; ++i) {
STableNode* pTable = taosArrayGetP(pTables, i);
createColumnNodeByTable(pTable, pSelect->pProjectionList);
......@@ -383,14 +552,18 @@ static int32_t translateStar(STranslateContext* pCxt, SSelectStmt* pSelect, bool
} else {
}
return TSDB_CODE_SUCCESS;
}
static int32_t translateSelect(STranslateContext* pCxt, SSelectStmt* pSelect) {
int32_t code = TSDB_CODE_SUCCESS;
code = translateTable(pCxt, pSelect->pFromTable);
code = translateFrom(pCxt, pSelect->pFromTable);
if (TSDB_CODE_SUCCESS == code) {
code = translateExpr(pCxt, pSelect->pWhere);
}
if (TSDB_CODE_SUCCESS == code) {
code = translateExprList(pCxt, pSelect->pGroupByList);
}
bool isSelectStar = false;
if (TSDB_CODE_SUCCESS == code) {
code = translateStar(pCxt, pSelect, &isSelectStar);
......@@ -398,6 +571,7 @@ static int32_t translateSelect(STranslateContext* pCxt, SSelectStmt* pSelect) {
if (TSDB_CODE_SUCCESS == code && !isSelectStar) {
code = translateExprList(pCxt, pSelect->pProjectionList);
}
// printf("%s:%d code = %d\n", __FUNCTION__, __LINE__, code);
return code;
}
......@@ -415,12 +589,21 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
static int32_t translateSubquery(STranslateContext* pCxt, SNode* pNode) {
++(pCxt->currLevel);
ESqlClause currClause = pCxt->currClause;
int32_t code = translateQuery(pCxt, pNode);
--(pCxt->currLevel);
pCxt->currClause = currClause;
return code;
}
int32_t doTranslate(SParseContext* pParseCxt, SQuery* pQuery) {
STranslateContext cxt = { .pParseCxt = pParseCxt, .pNsLevel = taosArrayInit(TARRAY_MIN_SIZE, POINTER_BYTES), .currLevel = 0 };
STranslateContext cxt = {
.pParseCxt = pParseCxt,
.errCode = TSDB_CODE_SUCCESS,
.msgBuf = { .buf = pParseCxt->pMsg, .len = pParseCxt->msgLen },
.pNsLevel = taosArrayInit(TARRAY_MIN_SIZE, POINTER_BYTES),
.currLevel = 0,
.currClause = 0
};
return translateQuery(&cxt, pQuery->pRoot);
}
......@@ -3199,7 +3199,7 @@ static void yy_reduce(
case 285: /* cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */
{
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy165, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, -1);
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy165, NULL, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, -1);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
break;
......@@ -3231,7 +3231,7 @@ static void yy_reduce(
toTSDBType(yymsp[0].minor.yy0.type);
A = tListItemAppendToken(A, &yymsp[0].minor.yy0, -1);
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-5].minor.yy0, NULL, A, TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN, -1);
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-5].minor.yy0, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, -1);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
break;
......@@ -3250,7 +3250,7 @@ static void yy_reduce(
case 290: /* cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */
{
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy165, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, -1);
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy165, NULL, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, -1);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
break;
......@@ -3275,7 +3275,7 @@ static void yy_reduce(
case 293: /* cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */
{
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy165, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, TSDB_SUPER_TABLE);
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy165, NULL, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
break;
......@@ -3307,7 +3307,7 @@ static void yy_reduce(
toTSDBType(yymsp[0].minor.yy0.type);
A = tListItemAppendToken(A, &yymsp[0].minor.yy0, -1);
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-5].minor.yy0, NULL, A, TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN, TSDB_SUPER_TABLE);
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-5].minor.yy0, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
break;
......@@ -3326,7 +3326,7 @@ static void yy_reduce(
case 298: /* cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */
{
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy165, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, TSDB_SUPER_TABLE);
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy165, NULL, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
break;
......
......@@ -38,34 +38,214 @@ protected:
}
bool run(int32_t expectCode = TSDB_CODE_SUCCESS) {
bool run(int32_t parseCode = TSDB_CODE_SUCCESS, int32_t translateCode = TSDB_CODE_SUCCESS) {
int32_t code = doParse(&cxt_, &query_);
// cout << "doParse return " << code << endl;
if (code != TSDB_CODE_SUCCESS) {
cout << "sql:[" << cxt_.pSql << "] code:" << tstrerror(code) << ", msg:" << errMagBuf_ << endl;
return (code == expectCode);
return (TSDB_CODE_SUCCESS != parseCode);
}
if (TSDB_CODE_SUCCESS != parseCode) {
return false;
}
code = doTranslate(&cxt_, &query_);
// cout << "doTranslate return " << code << endl;
if (code != TSDB_CODE_SUCCESS) {
cout << "sql:[" << cxt_.pSql << "] code:" << tstrerror(code) << ", msg:" << errMagBuf_ << endl;
return (TSDB_CODE_SUCCESS != translateCode);
}
if (NULL != query_.pRoot && QUERY_NODE_SELECT_STMT == nodeType(query_.pRoot)) {
SSelectStmt* select = (SSelectStmt*)query_.pRoot;
string sql("SELECT ");
if (select->isDistinct) {
sql.append("DISTINCT ");
}
if (nullptr == select->pProjectionList) {
sql.append("* ");
} else {
nodeListToSql(select->pProjectionList, sql);
}
sql.append("FROM ");
tableToSql(select->pFromTable, sql);
cout << sql << endl;
cout << "input sql : [" << cxt_.pSql << "]" << endl;
// string sql;
// selectToSql(query_.pRoot, sql);
// cout << "output sql : [" << sql << "]" << endl;
string str;
selectToStr(query_.pRoot, str);
cout << "translate str : \n" << str << endl;
}
return (code == expectCode);
return (TSDB_CODE_SUCCESS == translateCode);
}
private:
static const int max_err_len = 1024;
static const int max_sql_len = 1024 * 1024;
string dataTypeToStr(const SDataType& dt) {
switch (dt.type) {
case TSDB_DATA_TYPE_NULL:
return "NULL";
case TSDB_DATA_TYPE_BOOL:
return "BOOL";
case TSDB_DATA_TYPE_TINYINT:
return "TINYINT";
case TSDB_DATA_TYPE_SMALLINT:
return "SMALLINT";
case TSDB_DATA_TYPE_INT:
return "INT";
case TSDB_DATA_TYPE_BIGINT:
return "BIGINT";
case TSDB_DATA_TYPE_FLOAT:
return "FLOAT";
case TSDB_DATA_TYPE_DOUBLE:
return "DOUBLE";
case TSDB_DATA_TYPE_BINARY:
return "BINART(" + to_string(dt.bytes) + ")";
case TSDB_DATA_TYPE_TIMESTAMP:
return "TIMESTAMP";
case TSDB_DATA_TYPE_NCHAR:
return "NCHAR(" + to_string(dt.bytes) + ")";
case TSDB_DATA_TYPE_UTINYINT:
return "UTINYINT";
case TSDB_DATA_TYPE_USMALLINT:
return "USMALLINT";
case TSDB_DATA_TYPE_UINT:
return "UINT";
case TSDB_DATA_TYPE_UBIGINT:
return "UBIGINT";
case TSDB_DATA_TYPE_VARCHAR:
return "VARCHAR(" + to_string(dt.bytes) + ")";
case TSDB_DATA_TYPE_VARBINARY:
return "VARBINARY(" + to_string(dt.bytes) + ")";
case TSDB_DATA_TYPE_JSON:
return "JSON";
case TSDB_DATA_TYPE_DECIMAL:
return "DECIMAL(" + to_string(dt.precision) + ", " + to_string(dt.scale) + ")";
case TSDB_DATA_TYPE_BLOB:
return "BLOB";
default:
break;
}
return "Unknown Data Type " + to_string(dt.type);
}
void nodeToStr(const SNode* node, string& str, bool isProject) {
if (nullptr == node) {
return;
}
switch (nodeType(node)) {
case QUERY_NODE_COLUMN: {
SColumnNode* pCol = (SColumnNode*)node;
if ('\0' != pCol->dbName[0]) {
str.append(pCol->dbName);
str.append(".");
}
if ('\0' != pCol->tableAlias[0]) {
str.append(pCol->tableAlias);
str.append(".");
}
str.append(pCol->colName);
str.append(" [" + dataTypeToStr(pCol->node.resType) + "]");
if (isProject) {
str.append(" AS " + string(pCol->node.aliasName));
}
break;
}
case QUERY_NODE_VALUE: {
SValueNode* pVal = (SValueNode*)node;
str.append(pVal->literal);
str.append(" [" + dataTypeToStr(pVal->node.resType) + "]");
if (isProject) {
str.append(" AS " + string(pVal->node.aliasName));
}
break;
}
case QUERY_NODE_OPERATOR: {
SOperatorNode* pOp = (SOperatorNode*)node;
nodeToStr(pOp->pLeft, str, false);
str.append(opTypeToStr(pOp->opType));
nodeToStr(pOp->pRight, str, false);
str.append(" [" + dataTypeToStr(pOp->node.resType) + "]");
if (isProject) {
str.append(" AS " + string(pOp->node.aliasName));
}
break;
}
default:
break;
}
}
void nodeListToStr(const SNodeList* nodelist, const string& prefix, string& str, bool isProject = false) {
SNode* node = nullptr;
FOREACH(node, nodelist) {
str.append(prefix);
nodeToStr(node, str, isProject);
str.append("\n");
}
}
void tableToStr(const SNode* node, const string& prefix, string& str) {
const STableNode* table = (const STableNode*)node;
switch (nodeType(node)) {
case QUERY_NODE_REAL_TABLE: {
SRealTableNode* realTable = (SRealTableNode*)table;
str.append(prefix);
if ('\0' != realTable->table.dbName[0]) {
str.append(realTable->table.dbName);
str.append(".");
}
str.append(realTable->table.tableName);
str.append(string(" ") + realTable->table.tableAlias);
break;
}
case QUERY_NODE_TEMP_TABLE: {
STempTableNode* tempTable = (STempTableNode*)table;
str.append(prefix + "(\n");
selectToStr(tempTable->pSubquery, str, prefix + "\t");
str.append("\n");
str.append(prefix + ") ");
str.append(tempTable->table.tableAlias);
break;
}
case QUERY_NODE_JOIN_TABLE: {
SJoinTableNode* joinTable = (SJoinTableNode*)table;
tableToStr(joinTable->pLeft, prefix, str);
str.append("\n" + prefix + "JOIN\n");
tableToStr(joinTable->pRight, prefix, str);
if (nullptr != joinTable->pOnCond) {
str.append("\n" + prefix + "\tON ");
nodeToStr(joinTable->pOnCond, str, false);
}
break;
}
default:
break;
}
}
void selectToStr(const SNode* node, string& str, const string& prefix = "") {
SSelectStmt* select = (SSelectStmt*)node;
str.append(prefix + "SELECT ");
if (select->isDistinct) {
str.append("DISTINCT");
}
str.append("\n");
nodeListToStr(select->pProjectionList, prefix + "\t", str, true);
str.append("\n" + prefix + "FROM\n");
tableToStr(select->pFromTable, prefix + "\t", str);
}
void selectToSql(const SNode* node, string& sql) {
SSelectStmt* select = (SSelectStmt*)node;
sql.append("SELECT ");
if (select->isDistinct) {
sql.append("DISTINCT ");
}
if (nullptr == select->pProjectionList) {
sql.append("* ");
} else {
nodeListToSql(select->pProjectionList, sql);
sql.append(" ");
}
sql.append("FROM ");
tableToSql(select->pFromTable, sql);
if (nullptr != select->pWhere) {
sql.append(" WHERE ");
nodeToSql(select->pWhere, sql);
}
}
void tableToSql(const SNode* node, string& sql) {
const STableNode* table = (const STableNode*)node;
switch (nodeType(node)) {
......@@ -78,6 +258,88 @@ private:
sql.append(realTable->table.tableName);
break;
}
case QUERY_NODE_TEMP_TABLE: {
STempTableNode* tempTable = (STempTableNode*)table;
sql.append("(");
selectToSql(tempTable->pSubquery, sql);
sql.append(") ");
sql.append(tempTable->table.tableAlias);
break;
}
case QUERY_NODE_JOIN_TABLE: {
SJoinTableNode* joinTable = (SJoinTableNode*)table;
tableToSql(joinTable->pLeft, sql);
sql.append(" JOIN ");
tableToSql(joinTable->pRight, sql);
if (nullptr != joinTable->pOnCond) {
sql.append(" ON ");
nodeToSql(joinTable->pOnCond, sql);
}
break;
}
default:
break;
}
}
string opTypeToStr(EOperatorType type) {
switch (type) {
case OP_TYPE_ADD:
return " + ";
case OP_TYPE_SUB:
return " - ";
case OP_TYPE_MULTI:
case OP_TYPE_DIV:
case OP_TYPE_MOD:
case OP_TYPE_GREATER_THAN:
case OP_TYPE_GREATER_EQUAL:
case OP_TYPE_LOWER_THAN:
case OP_TYPE_LOWER_EQUAL:
case OP_TYPE_EQUAL:
return " = ";
case OP_TYPE_NOT_EQUAL:
case OP_TYPE_IN:
case OP_TYPE_NOT_IN:
case OP_TYPE_LIKE:
case OP_TYPE_NOT_LIKE:
case OP_TYPE_MATCH:
case OP_TYPE_NMATCH:
case OP_TYPE_JSON_GET_VALUE:
case OP_TYPE_JSON_CONTAINS:
default:
break;
}
return " unknown operator ";
}
void nodeToSql(const SNode* node, string& sql) {
if (nullptr == node) {
return;
}
switch (nodeType(node)) {
case QUERY_NODE_COLUMN: {
SColumnNode* pCol = (SColumnNode*)node;
if ('\0' != pCol->dbName[0]) {
sql.append(pCol->dbName);
sql.append(".");
}
if ('\0' != pCol->tableAlias[0]) {
sql.append(pCol->tableAlias);
sql.append(".");
}
sql.append(pCol->colName);
break;
}
case QUERY_NODE_VALUE:
break;
case QUERY_NODE_OPERATOR: {
SOperatorNode* pOp = (SOperatorNode*)node;
nodeToSql(pOp->pLeft, sql);
sql.append(opTypeToStr(pOp->opType));
nodeToSql(pOp->pRight, sql);
break;
}
default:
break;
}
......@@ -91,13 +353,8 @@ private:
sql.append(", ");
}
firstNode = false;
switch (nodeType(node)) {
case QUERY_NODE_COLUMN:
sql.append(((SColumnNode*)node)->colName);
break;
}
nodeToSql(node, sql);
}
sql.append(" ");
}
void reset() {
......@@ -115,8 +372,7 @@ private:
SQuery query_;
};
// SELECT * FROM t1
TEST_F(NewParserTest, selectStar) {
TEST_F(NewParserTest, selectSimple) {
setDatabase("root", "test");
bind("SELECT * FROM t1");
......@@ -125,14 +381,24 @@ TEST_F(NewParserTest, selectStar) {
bind("SELECT * FROM test.t1");
ASSERT_TRUE(run());
bind("SELECT ts FROM t1");
bind("SELECT ts, c1 FROM t1");
ASSERT_TRUE(run());
bind("SELECT ts, tag1, c1 FROM t1");
bind("SELECT ts, t.c1 FROM (SELECT * FROM t1) t");
ASSERT_TRUE(run());
bind("SELECT * FROM t1 tt1, t1 tt2 WHERE tt1.c1 = tt2.c1");
ASSERT_TRUE(run());
}
TEST_F(NewParserTest, selectExpression) {
setDatabase("root", "test");
bind("SELECT c1 + 10, c2 FROM t1");
ASSERT_TRUE(run());
}
TEST_F(NewParserTest, syntaxError) {
TEST_F(NewParserTest, selectSyntaxError) {
setDatabase("root", "test");
bind("SELECTT * FROM t1");
......@@ -147,3 +413,16 @@ TEST_F(NewParserTest, syntaxError) {
bind("SELECT * FROM test.t1 t WHER");
ASSERT_TRUE(run(TSDB_CODE_FAILED));
}
TEST_F(NewParserTest, selectSemanticError) {
setDatabase("root", "test");
bind("SELECT * FROM t10");
ASSERT_TRUE(run(TSDB_CODE_SUCCESS, TSDB_CODE_FAILED));
bind("SELECT c1, c3 FROM t1");
ASSERT_TRUE(run(TSDB_CODE_SUCCESS, TSDB_CODE_FAILED));
bind("SELECT c2 FROM t1 tt1, t1 tt2 WHERE tt1.c1 = tt2.c1");
ASSERT_TRUE(run(TSDB_CODE_SUCCESS, TSDB_CODE_FAILED));
}
......@@ -561,7 +561,7 @@ int32_t qwGetResFromSink(QW_FPARAMS_DEF, SQWTaskCtx *ctx, int32_t *dataLen, void
QW_ERR_RET(qwUpdateTaskStatus(QW_FPARAMS(), JOB_TASK_STATUS_SUCCEED));
QW_ERR_RET(qwMallocFetchRsp(len, &rsp));
QW_ERR_RET(qwMallocFetchRsp(len, &rsp));
*rspMsg = rsp;
*dataLen = 0;
......@@ -573,7 +573,7 @@ int32_t qwGetResFromSink(QW_FPARAMS_DEF, SQWTaskCtx *ctx, int32_t *dataLen, void
QW_TASK_DLOG("no res data in sink, need response later, queryEnd:%d", queryEnd);
return TSDB_CODE_SUCCESS;
}
}
// Got data from sink
......
......@@ -1409,7 +1409,7 @@ int32_t schedulerAsyncExecJob(void *transport, SArray *pNodeList, SQueryDag* pDa
}
int32_t schedulerConvertDagToTaskList(SQueryDag* pDag, SArray **pTasks) {
if (NULL == pDag || pDag->numOfSubplans <= 0 || taosArrayGetSize(pDag->pSubplans) <= 0) {
if (NULL == pDag || pDag->numOfSubplans <= 0 || taosArrayGetSize(pDag->pSubplans) == 0) {
SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
}
......@@ -1454,7 +1454,6 @@ int32_t schedulerConvertDagToTaskList(SQueryDag* pDag, SArray **pTasks) {
}
SSubQueryMsg* pMsg = calloc(1, msgSize);
memcpy(pMsg->msg, msg, msgLen);
pMsg->header.vgId = tInfo.addr.nodeId;
......@@ -1464,6 +1463,7 @@ int32_t schedulerConvertDagToTaskList(SQueryDag* pDag, SArray **pTasks) {
pMsg->taskType = TASK_TYPE_PERSISTENT;
pMsg->phyLen = msgLen;
pMsg->sqlLen = 0;
memcpy(pMsg->msg, msg, msgLen);
/*memcpy(pMsg->msg, ((SSubQueryMsg*)msg)->msg, msgLen);*/
tInfo.msg = pMsg;
......
......@@ -14,17 +14,18 @@ target_link_libraries(
PUBLIC common
)
if (${BUILD_WITH_UV_TRANS})
if (${BUILD_WITH_UV})
target_include_directories(
transport
PUBLIC "${CMAKE_SOURCE_DIR}/contrib/libuv/include"
)
#LINK_DIRECTORIES("${CMAKE_SOURCE_DIR}/debug/contrib/libuv")
target_link_libraries(
transport
PUBLIC uv_a
)
add_definitions(-DUSE_UV)
endif(${BUILD_WITH_UV})
endif(${BUILD_WITH_UV_TRANS})
if (${BUILD_TEST})
......
......@@ -134,10 +134,12 @@ typedef struct {
// int16_t numOfTry; // number of try for different servers
// int8_t oldInUse; // server EP inUse passed by app
// int8_t redirect; // flag to indicate redirect
int8_t connType; // connection type
int64_t rid; // refId returned by taosAddRef
SRpcMsg* pRsp; // for synchronous API
tsem_t* pSem; // for synchronous API
int8_t connType; // connection type
int64_t rid; // refId returned by taosAddRef
SRpcMsg* pRsp; // for synchronous API
tsem_t* pSem; // for synchronous API
char* ip;
uint32_t port;
// SEpSet* pSet; // for synchronous API
......@@ -213,6 +215,12 @@ typedef struct SConnBuffer {
typedef void (*AsyncCB)(uv_async_t* handle);
typedef struct {
void* pThrd;
queue qmsg;
pthread_mutex_t mtx; // protect qmsg;
} SAsyncItem;
typedef struct {
int index;
int nAsync;
......@@ -221,7 +229,7 @@ typedef struct {
SAsyncPool* transCreateAsyncPool(uv_loop_t* loop, void* arg, AsyncCB cb);
void transDestroyAsyncPool(SAsyncPool* pool);
int transSendAsync(SAsyncPool* pool);
int transSendAsync(SAsyncPool* pool, queue* mq);
int transInitBuffer(SConnBuffer* buf);
int transClearBuffer(SConnBuffer* buf);
......
......@@ -813,8 +813,8 @@ static SRpcConn *rpcSetupConnToServer(SRpcReqContext *pContext) {
SRpcInfo *pRpc = pContext->pRpc;
SEpSet * pEpSet = &pContext->epSet;
pConn =
rpcGetConnFromCache(pRpc->pCache, pEpSet->eps[pEpSet->inUse].fqdn, pEpSet->eps[pEpSet->inUse].port, pContext->connType);
pConn = rpcGetConnFromCache(pRpc->pCache, pEpSet->eps[pEpSet->inUse].fqdn, pEpSet->eps[pEpSet->inUse].port,
pContext->connType);
if (pConn == NULL || pConn->user[0] == 0) {
pConn = rpcOpenConn(pRpc, pEpSet->eps[pEpSet->inUse].fqdn, pEpSet->eps[pEpSet->inUse].port, pContext->connType);
}
......
......@@ -63,17 +63,41 @@ void rpcFreeCont(void* cont) {
}
free((char*)cont - TRANS_MSG_OVERHEAD);
}
void* rpcReallocCont(void* ptr, int contLen) { return NULL; }
void* rpcReallocCont(void* ptr, int contLen) {
if (ptr == NULL) {
return rpcMallocCont(contLen);
}
char* st = (char*)ptr - TRANS_MSG_OVERHEAD;
int sz = contLen + TRANS_MSG_OVERHEAD;
st = realloc(st, sz);
if (st == NULL) {
return NULL;
}
return st + TRANS_MSG_OVERHEAD;
}
void rpcSendRedirectRsp(void* thandle, const SEpSet* pEpSet) {
SRpcMsg rpcMsg;
memset(&rpcMsg, 0, sizeof(rpcMsg));
rpcMsg.contLen = sizeof(SEpSet);
rpcMsg.pCont = rpcMallocCont(rpcMsg.contLen);
if (rpcMsg.pCont == NULL) return;
memcpy(rpcMsg.pCont, pEpSet, sizeof(SEpSet));
rpcMsg.code = TSDB_CODE_RPC_REDIRECT;
rpcMsg.handle = thandle;
rpcSendResponse(&rpcMsg);
}
void rpcSendRedirectRsp(void* pConn, const SEpSet* pEpSet) {}
int rpcGetConnInfo(void* thandle, SRpcConnInfo* pInfo) { return -1; }
void rpcSendRecv(void* shandle, SEpSet* pEpSet, SRpcMsg* pReq, SRpcMsg* pRsp) { return; }
int rpcReportProgress(void* pConn, char* pCont, int contLen) { return -1; }
void rpcCancelRequest(int64_t rid) { return; }
int32_t rpcInit(void) {
// impl later
return -1;
return 0;
}
void rpcCleanup(void) {
......
......@@ -123,9 +123,14 @@ static void clientHandleResp(SCliConn* conn) {
rpcMsg.code = pHead->code;
rpcMsg.msgType = pHead->msgType;
rpcMsg.ahandle = pCtx->ahandle;
tDebug("conn %p handle resp", conn);
(pRpc->cfp)(NULL, &rpcMsg, NULL);
if (pCtx->pSem == NULL) {
tDebug("conn %p handle resp", conn);
(pRpc->cfp)(NULL, &rpcMsg, NULL);
} else {
tDebug("conn %p handle resp", conn);
memcpy((char*)pCtx->pRsp, (char*)&rpcMsg, sizeof(rpcMsg));
tsem_post(pCtx->pSem);
}
conn->notifyCount += 1;
// buf's mem alread translated to rpcMsg.pCont
......@@ -159,14 +164,20 @@ static void clientHandleExcept(SCliConn* pConn) {
SRpcMsg rpcMsg = {0};
rpcMsg.ahandle = pCtx->ahandle;
rpcMsg.code = TSDB_CODE_RPC_NETWORK_UNAVAIL;
// SRpcInfo* pRpc = pMsg->ctx->pRpc;
(pCtx->pTransInst->cfp)(NULL, &rpcMsg, NULL);
pConn->notifyCount += 1;
if (pCtx->pSem == NULL) {
// SRpcInfo* pRpc = pMsg->ctx->pRpc;
(pCtx->pTransInst->cfp)(NULL, &rpcMsg, NULL);
} else {
memcpy((char*)(pCtx->pRsp), (char*)(&rpcMsg), sizeof(rpcMsg));
// SRpcMsg rpcMsg
tsem_post(pCtx->pSem);
}
destroyCmsg(pMsg);
pConn->data = NULL;
// transDestroyConnCtx(pCtx);
clientConnDestroy(pConn, true);
pConn->notifyCount += 1;
}
static void clientTimeoutCb(uv_timer_t* handle) {
......@@ -432,14 +443,15 @@ static void clientHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd) {
}
}
static void clientAsyncCb(uv_async_t* handle) {
SCliThrdObj* pThrd = handle->data;
SAsyncItem* item = handle->data;
SCliThrdObj* pThrd = item->pThrd;
SCliMsg* pMsg = NULL;
queue wq;
// batch process to avoid to lock/unlock frequently
pthread_mutex_lock(&pThrd->msgMtx);
QUEUE_MOVE(&pThrd->msg, &wq);
pthread_mutex_unlock(&pThrd->msgMtx);
pthread_mutex_lock(&item->mtx);
QUEUE_MOVE(&item->qmsg, &wq);
pthread_mutex_unlock(&item->mtx);
int count = 0;
while (!QUEUE_IS_EMPTY(&wq)) {
......@@ -462,6 +474,7 @@ static void clientAsyncCb(uv_async_t* handle) {
static void* clientThread(void* arg) {
SCliThrdObj* pThrd = (SCliThrdObj*)arg;
setThreadName("trans-client-work");
uv_run(pThrd->loop, UV_RUN_DEFAULT);
}
......@@ -548,11 +561,11 @@ static void clientSendQuit(SCliThrdObj* thrd) {
SCliMsg* msg = calloc(1, sizeof(SCliMsg));
msg->ctx = NULL; //
pthread_mutex_lock(&thrd->msgMtx);
QUEUE_PUSH(&thrd->msg, &msg->q);
pthread_mutex_unlock(&thrd->msgMtx);
// pthread_mutex_lock(&thrd->msgMtx);
// QUEUE_PUSH(&thrd->msg, &msg->q);
// pthread_mutex_unlock(&thrd->msgMtx);
transSendAsync(thrd->asyncPool);
transSendAsync(thrd->asyncPool, &msg->q);
// uv_async_send(thrd->cliAsync);
}
void taosCloseClient(void* arg) {
......@@ -567,8 +580,8 @@ void taosCloseClient(void* arg) {
}
void rpcSendRequest(void* shandle, const SEpSet* pEpSet, SRpcMsg* pMsg, int64_t* pRid) {
// impl later
char* ip = (char*)(pEpSet->fqdn[pEpSet->inUse]);
uint32_t port = pEpSet->port[pEpSet->inUse];
char* ip = (char*)(pEpSet->eps[pEpSet->inUse].fqdn);
uint32_t port = pEpSet->eps[pEpSet->inUse].port;
SRpcInfo* pRpc = (SRpcInfo*)shandle;
......@@ -598,14 +611,55 @@ void rpcSendRequest(void* shandle, const SEpSet* pEpSet, SRpcMsg* pMsg, int64_t*
SCliThrdObj* thrd = ((SClientObj*)pRpc->tcphandle)->pThreadObj[index % pRpc->numOfThreads];
pthread_mutex_lock(&thrd->msgMtx);
QUEUE_PUSH(&thrd->msg, &cliMsg->q);
pthread_mutex_unlock(&thrd->msgMtx);
// pthread_mutex_lock(&thrd->msgMtx);
// QUEUE_PUSH(&thrd->msg, &cliMsg->q);
// pthread_mutex_unlock(&thrd->msgMtx);
int start = taosGetTimestampUs();
transSendAsync(thrd->asyncPool);
// int start = taosGetTimestampUs();
transSendAsync(thrd->asyncPool, &(cliMsg->q));
// uv_async_send(thrd->cliAsync);
int end = taosGetTimestampUs() - start;
// int end = taosGetTimestampUs() - start;
// tError("client sent to rpc, time cost: %d", (int)end);
}
void rpcSendRecv(void* shandle, SEpSet* pEpSet, SRpcMsg* pReq, SRpcMsg* pRsp) {
char* ip = (char*)(pEpSet->eps[pEpSet->inUse].fqdn);
uint32_t port = pEpSet->eps[pEpSet->inUse].port;
SRpcInfo* pRpc = (SRpcInfo*)shandle;
STransConnCtx* pCtx = calloc(1, sizeof(STransConnCtx));
pCtx->pTransInst = (SRpcInfo*)shandle;
pCtx->ahandle = pReq->ahandle;
pCtx->msgType = pReq->msgType;
pCtx->ip = strdup(ip);
pCtx->port = port;
pCtx->pSem = calloc(1, sizeof(tsem_t));
pCtx->pRsp = pRsp;
tsem_init(pCtx->pSem, 0, 0);
int64_t index = pRpc->index;
if (pRpc->index++ >= pRpc->numOfThreads) {
pRpc->index = 0;
}
SCliMsg* cliMsg = malloc(sizeof(SCliMsg));
cliMsg->ctx = pCtx;
cliMsg->msg = *pReq;
cliMsg->st = taosGetTimestampUs();
SCliThrdObj* thrd = ((SClientObj*)pRpc->tcphandle)->pThreadObj[index % pRpc->numOfThreads];
// pthread_mutex_lock(&thrd->msgMtx);
// QUEUE_PUSH(&thrd->msg, &cliMsg->q);
// pthread_mutex_unlock(&thrd->msgMtx);
// int start = taosGetTimestampUs();
transSendAsync(thrd->asyncPool, &(cliMsg->q));
tsem_t* pSem = pCtx->pSem;
tsem_wait(pSem);
tsem_destroy(pSem);
free(pSem);
return;
}
#endif
......@@ -247,7 +247,7 @@ int transDestroyBuffer(SConnBuffer* buf) {
}
SAsyncPool* transCreateAsyncPool(uv_loop_t* loop, void* arg, AsyncCB cb) {
static int sz = 20;
static int sz = 10;
SAsyncPool* pool = calloc(1, sizeof(SAsyncPool));
pool->index = 0;
......@@ -257,24 +257,46 @@ SAsyncPool* transCreateAsyncPool(uv_loop_t* loop, void* arg, AsyncCB cb) {
for (int i = 0; i < pool->nAsync; i++) {
uv_async_t* async = &(pool->asyncs[i]);
uv_async_init(loop, async, cb);
async->data = arg;
SAsyncItem* item = calloc(1, sizeof(SAsyncItem));
item->pThrd = arg;
QUEUE_INIT(&item->qmsg);
pthread_mutex_init(&item->mtx, NULL);
async->data = item;
}
return pool;
}
void transDestroyAsyncPool(SAsyncPool* pool) {
for (int i = 0; i < pool->nAsync; i++) {
uv_async_t* async = &(pool->asyncs[i]);
SAsyncItem* item = async->data;
pthread_mutex_destroy(&item->mtx);
free(item);
}
free(pool->asyncs);
free(pool);
}
int transSendAsync(SAsyncPool* pool) {
int transSendAsync(SAsyncPool* pool, queue* q) {
int idx = pool->index;
idx = idx % pool->nAsync;
// no need mutex here
if (pool->index++ > pool->nAsync) {
pool->index = 0;
}
return uv_async_send(&(pool->asyncs[idx]));
uv_async_t* async = &(pool->asyncs[idx]);
SAsyncItem* item = async->data;
int64_t st = taosGetTimestampUs();
pthread_mutex_lock(&item->mtx);
QUEUE_PUSH(&item->qmsg, q);
pthread_mutex_unlock(&item->mtx);
int64_t el = taosGetTimestampUs() - st;
if (el > 50) {
// tInfo("lock and unlock cost: %d", (int)el);
}
return uv_async_send(async);
}
#endif
......@@ -33,6 +33,8 @@ typedef struct SSrvConn {
void* hostThrd;
void* pSrvMsg;
struct sockaddr peername;
// SRpcMsg sendMsg;
// del later
char secured;
......@@ -376,13 +378,15 @@ static void destroySmsg(SSrvMsg* smsg) {
free(smsg);
}
void uvWorkerAsyncCb(uv_async_t* handle) {
SWorkThrdObj* pThrd = handle->data;
SAsyncItem* item = handle->data;
SWorkThrdObj* pThrd = item->pThrd;
SSrvConn* conn = NULL;
queue wq;
// batch process to avoid to lock/unlock frequently
pthread_mutex_lock(&pThrd->msgMtx);
QUEUE_MOVE(&pThrd->msg, &wq);
pthread_mutex_unlock(&pThrd->msgMtx);
pthread_mutex_lock(&item->mtx);
QUEUE_MOVE(&item->qmsg, &wq);
pthread_mutex_unlock(&item->mtx);
// pthread_mutex_unlock(&mtx);
while (!QUEUE_IS_EMPTY(&wq)) {
queue* head = QUEUE_HEAD(&wq);
......@@ -485,7 +489,13 @@ void uvOnConnectionCb(uv_stream_t* q, ssize_t nread, const uv_buf_t* buf) {
uv_os_fd_t fd;
uv_fileno((const uv_handle_t*)pConn->pTcp, &fd);
tDebug("conn %p created, fd: %d", pConn, fd);
uv_read_start((uv_stream_t*)(pConn->pTcp), uvAllocReadBufferCb, uvOnReadCb);
int namelen = sizeof(pConn->peername);
if (0 != uv_tcp_getpeername(pConn->pTcp, &pConn->peername, &namelen)) {
tError("failed to get peer name");
destroyConn(pConn, true);
} else {
uv_read_start((uv_stream_t*)(pConn->pTcp), uvAllocReadBufferCb, uvOnReadCb);
}
} else {
tDebug("failed to create new connection");
destroyConn(pConn, true);
......@@ -494,6 +504,7 @@ void uvOnConnectionCb(uv_stream_t* q, ssize_t nread, const uv_buf_t* buf) {
void* acceptThread(void* arg) {
// opt
setThreadName("trans-accept");
SServerObj* srv = (SServerObj*)arg;
uv_run(srv->loop, UV_RUN_DEFAULT);
}
......@@ -539,13 +550,14 @@ static bool addHandleToAcceptloop(void* arg) {
tError("failed to bind: %s", uv_err_name(err));
return false;
}
if ((err = uv_listen((uv_stream_t*)&srv->server, 128, uvOnAcceptCb)) != 0) {
if ((err = uv_listen((uv_stream_t*)&srv->server, 512, uvOnAcceptCb)) != 0) {
tError("failed to listen: %s", uv_err_name(err));
return false;
}
return true;
}
void* workerThread(void* arg) {
setThreadName("trans-worker");
SWorkThrdObj* pThrd = (SWorkThrdObj*)arg;
uv_run(pThrd->loop, UV_RUN_DEFAULT);
}
......@@ -671,12 +683,12 @@ void destroyWorkThrd(SWorkThrdObj* pThrd) {
void sendQuitToWorkThrd(SWorkThrdObj* pThrd) {
SSrvMsg* srvMsg = calloc(1, sizeof(SSrvMsg));
pthread_mutex_lock(&pThrd->msgMtx);
QUEUE_PUSH(&pThrd->msg, &srvMsg->q);
pthread_mutex_unlock(&pThrd->msgMtx);
// pthread_mutex_lock(&pThrd->msgMtx);
// QUEUE_PUSH(&pThrd->msg, &srvMsg->q);
// pthread_mutex_unlock(&pThrd->msgMtx);
tDebug("send quit msg to work thread");
transSendAsync(pThrd->asyncPool);
transSendAsync(pThrd->asyncPool, &srvMsg->q);
// uv_async_send(pThrd->workerAsync);
}
......@@ -712,13 +724,25 @@ void rpcSendResponse(const SRpcMsg* pMsg) {
srvMsg->pConn = pConn;
srvMsg->msg = *pMsg;
pthread_mutex_lock(&pThrd->msgMtx);
QUEUE_PUSH(&pThrd->msg, &srvMsg->q);
pthread_mutex_unlock(&pThrd->msgMtx);
// pthread_mutex_lock(&pThrd->msgMtx);
// QUEUE_PUSH(&pThrd->msg, &srvMsg->q);
// pthread_mutex_unlock(&pThrd->msgMtx);
tDebug("conn %p start to send resp", pConn);
transSendAsync(pThrd->asyncPool);
transSendAsync(pThrd->asyncPool, &srvMsg->q);
// uv_async_send(pThrd->workerAsync);
}
int rpcGetConnInfo(void* thandle, SRpcConnInfo* pInfo) {
SSrvConn* pConn = thandle;
struct sockaddr* pPeerName = &pConn->peername;
struct sockaddr_in caddr = *(struct sockaddr_in*)(pPeerName);
pInfo->clientIp = (uint32_t)(caddr.sin_addr.s_addr);
pInfo->clientPort = ntohs(caddr.sin_port);
tstrncpy(pInfo->user, pConn->user, sizeof(pInfo->user));
return 0;
}
#endif
......@@ -2,6 +2,7 @@ add_executable(transportTest "")
add_executable(client "")
add_executable(server "")
add_executable(transUT "")
add_executable(syncClient "")
target_sources(transUT
PRIVATE
......@@ -20,6 +21,10 @@ target_sources (server
PRIVATE
"rserver.c"
)
target_sources (syncClient
PRIVATE
"syncClient.c"
)
target_include_directories(transportTest
PUBLIC
......@@ -67,7 +72,6 @@ target_include_directories(transUT
"${CMAKE_CURRENT_SOURCE_DIR}/../inc"
)
target_link_libraries (server
os
util
......@@ -75,4 +79,17 @@ target_link_libraries (server
gtest_main
transport
)
target_include_directories(syncClient
PUBLIC
"${CMAKE_SOURCE_DIR}/include/libs/transport"
"${CMAKE_CURRENT_SOURCE_DIR}/../inc"
)
target_link_libraries (syncClient
os
util
common
gtest_main
transport
)
......@@ -33,7 +33,6 @@ typedef struct {
pthread_t thread;
void * pRpc;
} SInfo;
static void processResponse(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet) {
SInfo *pInfo = (SInfo *)pMsg->ahandle;
tDebug("thread:%d, response is received, type:%d contLen:%d code:0x%x", pInfo->index, pMsg->msgType, pMsg->contLen,
......
/*
* 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 <sys/time.h>
#include <tep.h>
#include "os.h"
#include "rpcLog.h"
#include "taoserror.h"
#include "tglobal.h"
#include "trpc.h"
#include "tutil.h"
typedef struct {
int index;
SEpSet epSet;
int num;
int numOfReqs;
int msgSize;
tsem_t rspSem;
tsem_t * pOverSem;
pthread_t thread;
void * pRpc;
} SInfo;
static void processResponse(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet) {
SInfo *pInfo = (SInfo *)pMsg->ahandle;
tDebug("thread:%d, response is received, type:%d contLen:%d code:0x%x", pInfo->index, pMsg->msgType, pMsg->contLen,
pMsg->code);
if (pEpSet) pInfo->epSet = *pEpSet;
rpcFreeCont(pMsg->pCont);
// tsem_post(&pInfo->rspSem);
tsem_post(&pInfo->rspSem);
}
static int tcount = 0;
static void *sendRequest(void *param) {
SInfo * pInfo = (SInfo *)param;
SRpcMsg rpcMsg = {0};
tDebug("thread:%d, start to send request", pInfo->index);
tDebug("thread:%d, reqs: %d", pInfo->index, pInfo->numOfReqs);
int u100 = 0;
int u500 = 0;
int u1000 = 0;
int u10000 = 0;
SRpcMsg respMsg = {0};
while (pInfo->numOfReqs == 0 || pInfo->num < pInfo->numOfReqs) {
pInfo->num++;
rpcMsg.pCont = rpcMallocCont(pInfo->msgSize);
rpcMsg.contLen = pInfo->msgSize;
rpcMsg.ahandle = pInfo;
rpcMsg.msgType = 1;
// tDebug("thread:%d, send request, contLen:%d num:%d", pInfo->index, pInfo->msgSize, pInfo->num);
int64_t start = taosGetTimestampUs();
rpcSendRecv(pInfo->pRpc, &pInfo->epSet, &rpcMsg, &respMsg);
// rpcSendRequest(pInfo->pRpc, &pInfo->epSet, &rpcMsg, NULL);
if (pInfo->num % 20000 == 0) tInfo("thread:%d, %d requests have been sent", pInfo->index, pInfo->num);
// tsem_wait(&pInfo->rspSem);
// wtsem_wait(&pInfo->rspSem);
int64_t end = taosGetTimestampUs() - start;
if (end <= 100) {
u100++;
} else if (end > 100 && end <= 500) {
u500++;
} else if (end > 500 && end < 1000) {
u1000++;
} else {
u10000++;
}
tDebug("recv response succefully");
// usleep(100000000);
}
tError("send and recv sum: %d, %d, %d, %d", u100, u500, u1000, u10000);
tDebug("thread:%d, it is over", pInfo->index);
tcount++;
return NULL;
}
int main(int argc, char *argv[]) {
SRpcInit rpcInit;
SEpSet epSet = {0};
int msgSize = 128;
int numOfReqs = 0;
int appThreads = 1;
char serverIp[40] = "127.0.0.1";
char secret[20] = "mypassword";
struct timeval systemTime;
int64_t startTime, endTime;
pthread_attr_t thattr;
// server info
epSet.inUse = 0;
addEpIntoEpSet(&epSet, serverIp, 7000);
addEpIntoEpSet(&epSet, "192.168.0.1", 7000);
// client info
memset(&rpcInit, 0, sizeof(rpcInit));
rpcInit.localPort = 0;
rpcInit.label = "APP";
rpcInit.numOfThreads = 1;
rpcInit.cfp = processResponse;
rpcInit.sessions = 100;
rpcInit.idleTime = 100;
rpcInit.user = "michael";
rpcInit.secret = secret;
rpcInit.ckey = "key";
rpcInit.spi = 1;
rpcInit.connType = TAOS_CONN_CLIENT;
for (int i = 1; i < argc; ++i) {
if (strcmp(argv[i], "-p") == 0 && i < argc - 1) {
epSet.eps[0].port = atoi(argv[++i]);
} else if (strcmp(argv[i], "-i") == 0 && i < argc - 1) {
tstrncpy(epSet.eps[0].fqdn, argv[++i], sizeof(epSet.eps[0].fqdn));
} else if (strcmp(argv[i], "-t") == 0 && i < argc - 1) {
rpcInit.numOfThreads = atoi(argv[++i]);
} else if (strcmp(argv[i], "-m") == 0 && i < argc - 1) {
msgSize = atoi(argv[++i]);
} else if (strcmp(argv[i], "-s") == 0 && i < argc - 1) {
rpcInit.sessions = atoi(argv[++i]);
} else if (strcmp(argv[i], "-n") == 0 && i < argc - 1) {
numOfReqs = atoi(argv[++i]);
} else if (strcmp(argv[i], "-a") == 0 && i < argc - 1) {
appThreads = atoi(argv[++i]);
} else if (strcmp(argv[i], "-o") == 0 && i < argc - 1) {
tsCompressMsgSize = atoi(argv[++i]);
} else if (strcmp(argv[i], "-u") == 0 && i < argc - 1) {
rpcInit.user = argv[++i];
} else if (strcmp(argv[i], "-k") == 0 && i < argc - 1) {
rpcInit.secret = argv[++i];
} else if (strcmp(argv[i], "-spi") == 0 && i < argc - 1) {
rpcInit.spi = atoi(argv[++i]);
} else if (strcmp(argv[i], "-d") == 0 && i < argc - 1) {
rpcDebugFlag = atoi(argv[++i]);
} else {
printf("\nusage: %s [options] \n", argv[0]);
printf(" [-i ip]: first server IP address, default is:%s\n", serverIp);
printf(" [-p port]: server port number, default is:%d\n", epSet.eps[0].port);
printf(" [-t threads]: number of rpc threads, default is:%d\n", rpcInit.numOfThreads);
printf(" [-s sessions]: number of rpc sessions, default is:%d\n", rpcInit.sessions);
printf(" [-m msgSize]: message body size, default is:%d\n", msgSize);
printf(" [-a threads]: number of app threads, default is:%d\n", appThreads);
printf(" [-n requests]: number of requests per thread, default is:%d\n", numOfReqs);
printf(" [-o compSize]: compression message size, default is:%d\n", tsCompressMsgSize);
printf(" [-u user]: user name for the connection, default is:%s\n", rpcInit.user);
printf(" [-k secret]: password for the connection, default is:%s\n", rpcInit.secret);
printf(" [-spi SPI]: security parameter index, default is:%d\n", rpcInit.spi);
printf(" [-d debugFlag]: debug flag, default:%d\n", rpcDebugFlag);
printf(" [-h help]: print out this help\n\n");
exit(0);
}
}
taosInitLog("client.log", 100000, 10);
void *pRpc = rpcOpen(&rpcInit);
if (pRpc == NULL) {
tError("failed to initialize RPC");
return -1;
}
tInfo("client is initialized");
tInfo("threads:%d msgSize:%d requests:%d", appThreads, msgSize, numOfReqs);
gettimeofday(&systemTime, NULL);
startTime = systemTime.tv_sec * 1000000 + systemTime.tv_usec;
SInfo *pInfo = (SInfo *)calloc(1, sizeof(SInfo) * appThreads);
pthread_attr_init(&thattr);
pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_JOINABLE);
for (int i = 0; i < appThreads; ++i) {
pInfo->index = i;
pInfo->epSet = epSet;
pInfo->numOfReqs = numOfReqs;
pInfo->msgSize = msgSize;
tsem_init(&pInfo->rspSem, 0, 0);
pInfo->pRpc = pRpc;
pthread_create(&pInfo->thread, &thattr, sendRequest, pInfo);
pInfo++;
}
do {
usleep(1);
} while (tcount < appThreads);
gettimeofday(&systemTime, NULL);
endTime = systemTime.tv_sec * 1000000 + systemTime.tv_usec;
float usedTime = (endTime - startTime) / 1000.0f; // mseconds
tInfo("it takes %.3f mseconds to send %d requests to server", usedTime, numOfReqs * appThreads);
tInfo("Performance: %.3f requests per second, msgSize:%d bytes", 1000.0 * numOfReqs * appThreads / usedTime, msgSize);
int ch = getchar();
UNUSED(ch);
taosCloseLog();
return 0;
}
......@@ -15,6 +15,7 @@
#include <gtest/gtest.h>
#include <cstdio>
#include <cstring>
#include "tep.h"
#include "trpc.h"
using namespace std;
......@@ -50,6 +51,25 @@ class TransObj {
trans = rpcOpen(&rpcInit);
return trans != NULL ? true : false;
}
bool sendAndRecv() {
SEpSet epSet = {0};
epSet.inUse = 0;
addEpIntoEpSet(&epSet, "192.168.1.1", 7000);
addEpIntoEpSet(&epSet, "192.168.0.1", 7000);
if (trans == NULL) {
return false;
}
SRpcMsg rpcMsg = {0}, reqMsg = {0};
reqMsg.pCont = rpcMallocCont(10);
reqMsg.contLen = 10;
reqMsg.ahandle = NULL;
rpcSendRecv(trans, &epSet, &reqMsg, &rpcMsg);
int code = rpcMsg.code;
std::cout << tstrerror(code) << std::endl;
return true;
}
bool stop() {
rpcClose(trans);
trans = NULL;
......@@ -75,6 +95,7 @@ class TransEnv : public ::testing::Test {
};
TEST_F(TransEnv, test_start_stop) {
assert(tr->startCli());
assert(tr->sendAndRecv());
assert(tr->stop());
assert(tr->startSrv());
......
......@@ -109,7 +109,7 @@ void nodesWalkNodePostOrder(SNode* pNode, FQueryNodeWalker walker, void* pContex
}
void nodesWalkListPostOrder(SNodeList* pList, FQueryNodeWalker walker, void* pContext) {
(void)walkList(pList, TRAVERSAL_PREORDER, walker, pContext);
(void)walkList(pList, TRAVERSAL_POSTORDER, walker, pContext);
}
bool nodesWalkStmt(SNode* pNode, FQueryNodeWalker walker, void* pContext) {
......
......@@ -70,8 +70,19 @@ SNode* nodesMakeNode(ENodeType type) {
return NULL;
}
void nodesDestroyNode(SNode* pNode) {
static bool destroyNode(SNode* pNode, void* pContext) {
switch (nodeType(pNode)) {
case QUERY_NODE_VALUE:
tfree(((SValueNode*)pNode)->literal);
break;
default:
break;
}
tfree(pNode);
}
void nodesDestroyNode(SNode* pNode) {
nodesWalkNodePostOrder(pNode, destroyNode, NULL);
}
SNodeList* nodesMakeList() {
......@@ -103,13 +114,63 @@ SNodeList* nodesListAppend(SNodeList* pList, SNode* pNode) {
}
void nodesDestroyList(SNodeList* pList) {
SNode* node;
FOREACH(node, pList) {
nodesDestroyNode(node);
}
tfree(pList);
}
bool nodesIsArithmeticOp(const SOperatorNode* pOp) {
switch (pOp->opType) {
case OP_TYPE_ADD:
case OP_TYPE_SUB:
case OP_TYPE_MULTI:
case OP_TYPE_DIV:
case OP_TYPE_MOD:
return true;
default:
break;
}
return false;
}
bool nodesIsComparisonOp(const SOperatorNode* pOp) {
switch (pOp->opType) {
case OP_TYPE_GREATER_THAN:
case OP_TYPE_GREATER_EQUAL:
case OP_TYPE_LOWER_THAN:
case OP_TYPE_LOWER_EQUAL:
case OP_TYPE_EQUAL:
case OP_TYPE_NOT_EQUAL:
case OP_TYPE_IN:
case OP_TYPE_NOT_IN:
case OP_TYPE_LIKE:
case OP_TYPE_NOT_LIKE:
case OP_TYPE_MATCH:
case OP_TYPE_NMATCH:
return true;
default:
break;
}
return false;
}
bool nodesIsTimeorderQuery(const SNode* pQuery) {
bool nodesIsJsonOp(const SOperatorNode* pOp) {
switch (pOp->opType) {
case OP_TYPE_JSON_GET_VALUE:
case OP_TYPE_JSON_CONTAINS:
return true;
default:
break;
}
return false;
}
bool nodesIsTimeorderQuery(const SNode* pQuery) {
return false;
}
bool nodesIsTimelineQuery(const SNode* pQuery) {
return false;
}
\ No newline at end of file
......@@ -236,9 +236,9 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOO_MANY_TAGS, "Too many tags")
TAOS_DEFINE_ERROR(TSDB_CODE_MND_TAG_ALREAY_EXIST, "Tag already exists")
TAOS_DEFINE_ERROR(TSDB_CODE_MND_TAG_NOT_EXIST, "Tag does not exist")
TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOO_MANY_COLUMNS, "Too many columns")
TAOS_DEFINE_ERROR(TSDB_CODE_MND_COLUMN_ALREAY_EXIST, "Column already exists")
TAOS_DEFINE_ERROR(TSDB_CODE_MND_COLUMN_NOT_EXIST, "Column does not exist")
TAOS_DEFINE_ERROR(TSDB_CODE_MND_EXCEED_MAX_ROW_BYTES, "Exceed max row bytes")
TAOS_DEFINE_ERROR(TSDB_CODE_MND_COLUMN_ALREAY_EXIST, "Column already exists")
TAOS_DEFINE_ERROR(TSDB_CODE_MND_COLUMN_NOT_EXIST, "Column does not exist")
TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_ROW_BYTES, "Invalid row bytes")
// mnode-func
TAOS_DEFINE_ERROR(TSDB_CODE_MND_FUNC_ALREADY_EXIST, "Func already exists")
......
import hudson.model.Result
import hudson.model.*;
import jenkins.model.CauseOfInterruption
node {
}
def skipbuild=0
def win_stop=0
def abortPreviousBuilds() {
def currentJobName = env.JOB_NAME
def currentBuildNumber = env.BUILD_NUMBER.toInteger()
def jobs = Jenkins.instance.getItemByFullName(currentJobName)
def builds = jobs.getBuilds()
for (build in builds) {
if (!build.isBuilding()) {
continue;
}
if (currentBuildNumber == build.getNumber().toInteger()) {
continue;
}
build.doKill() //doTerm(),doKill(),doTerm()
}
}
// abort previous build
abortPreviousBuilds()
def abort_previous(){
def buildNumber = env.BUILD_NUMBER as int
if (buildNumber > 1) milestone(buildNumber - 1)
milestone(buildNumber)
}
def pre_test(){
sh'hostname'
sh '''
sudo rmtaos || echo "taosd has not installed"
'''
sh '''
killall -9 taosd ||echo "no taosd running"
killall -9 gdb || echo "no gdb running"
killall -9 python3.8 || echo "no python program running"
cd ${WKC}
'''
script {
if (env.CHANGE_TARGET == 'master') {
sh '''
cd ${WKC}
git checkout master
'''
}
else if(env.CHANGE_TARGET == '2.0'){
sh '''
cd ${WKC}
git checkout 2.0
'''
}
else if(env.CHANGE_TARGET == '3.0'){
sh '''
cd ${WKC}
git checkout 3.0
'''
}
else{
sh '''
cd ${WKC}
git checkout develop
'''
}
}
sh'''
cd ${WKC}
git pull >/dev/null
git fetch origin +refs/pull/${CHANGE_ID}/merge
git checkout -qf FETCH_HEAD
export TZ=Asia/Harbin
date
rm -rf debug
mkdir debug
cd debug
cmake .. > /dev/null
make -j4> /dev/null
'''
return 1
}
pipeline {
agent none
options { skipDefaultCheckout() }
environment{
WK = '/var/lib/jenkins/workspace/TDinternal'
WKC= '/var/lib/jenkins/workspace/TDengine'
}
stages {
stage('pre_build'){
agent{label 'slave3_0'}
options { skipDefaultCheckout() }
when {
changeRequest()
}
steps {
script{
abort_previous()
abortPreviousBuilds()
}
timeout(time: 45, unit: 'MINUTES'){
pre_test()
sh'''
cd ${WKC}/tests
./test-all.sh b1fq
'''
sh'''
cd ${WKC}/debug
ctest
'''
}
}
}
}
post {
success {
emailext (
subject: "PR-result: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' SUCCESS",
body: """<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body leftmargin="8" marginwidth="0" topmargin="8" marginheight="4" offset="0">
<table width="95%" cellpadding="0" cellspacing="0" style="font-size: 16pt; font-family: Tahoma, Arial, Helvetica, sans-serif">
<tr>
<td><br />
<b><font color="#0B610B"><font size="6">构建信息</font></font></b>
<hr size="2" width="100%" align="center" /></td>
</tr>
<tr>
<td>
<ul>
<div style="font-size:18px">
<li>构建名称>>分支:${env.BRANCH_NAME}</li>
<li>构建结果:<span style="color:green"> Successful </span></li>
<li>构建编号:${BUILD_NUMBER}</li>
<li>触发用户:${env.CHANGE_AUTHOR}</li>
<li>提交信息:${env.CHANGE_TITLE}</li>
<li>构建地址:<a href=${BUILD_URL}>${BUILD_URL}</a></li>
<li>构建日志:<a href=${BUILD_URL}console>${BUILD_URL}console</a></li>
</div>
</ul>
</td>
</tr>
</table></font>
</body>
</html>""",
to: "${env.CHANGE_AUTHOR_EMAIL}",
from: "support@taosdata.com"
)
}
failure {
emailext (
subject: "PR-result: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' FAIL",
body: """<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body leftmargin="8" marginwidth="0" topmargin="8" marginheight="4" offset="0">
<table width="95%" cellpadding="0" cellspacing="0" style="font-size: 16pt; font-family: Tahoma, Arial, Helvetica, sans-serif">
<tr>
<td><br />
<b><font color="#0B610B"><font size="6">构建信息</font></font></b>
<hr size="2" width="100%" align="center" /></td>
</tr>
<tr>
<td>
<ul>
<div style="font-size:18px">
<li>构建名称>>分支:${env.BRANCH_NAME}</li>
<li>构建结果:<span style="color:red"> Failure </span></li>
<li>构建编号:${BUILD_NUMBER}</li>
<li>触发用户:${env.CHANGE_AUTHOR}</li>
<li>提交信息:${env.CHANGE_TITLE}</li>
<li>构建地址:<a href=${BUILD_URL}>${BUILD_URL}</a></li>
<li>构建日志:<a href=${BUILD_URL}console>${BUILD_URL}console</a></li>
</div>
</ul>
</td>
</tr>
</table></font>
</body>
</html>""",
to: "${env.CHANGE_AUTHOR_EMAIL}",
from: "support@taosdata.com"
)
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册