Merge pull request #10675 from taosdata/feature/3.0_query_integrate_wxy
TD-13747 file name organize
This commit is contained in:
commit
5b5ac34d5c
|
@ -173,6 +173,7 @@ int32_t execDdlQuery(SRequestObj* pRequest, SQuery* pQuery) {
|
||||||
SCmdMsgInfo* pMsgInfo = pQuery->pCmdMsg;
|
SCmdMsgInfo* pMsgInfo = pQuery->pCmdMsg;
|
||||||
pRequest->type = pMsgInfo->msgType;
|
pRequest->type = pMsgInfo->msgType;
|
||||||
pRequest->body.requestMsg = (SDataBuf){.pData = pMsgInfo->pMsg, .len = pMsgInfo->msgLen, .handle = NULL};
|
pRequest->body.requestMsg = (SDataBuf){.pData = pMsgInfo->pMsg, .len = pMsgInfo->msgLen, .handle = NULL};
|
||||||
|
pMsgInfo->pMsg = NULL; // pMsg transferred to SMsgSendInfo management
|
||||||
|
|
||||||
STscObj* pTscObj = pRequest->pTscObj;
|
STscObj* pTscObj = pRequest->pTscObj;
|
||||||
SMsgSendInfo* pSendMsg = buildMsgInfoImpl(pRequest);
|
SMsgSendInfo* pSendMsg = buildMsgInfoImpl(pRequest);
|
||||||
|
@ -248,7 +249,7 @@ TAOS_RES* taos_query_l(TAOS* taos, const char* sql, int sqlLen) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SRequestObj* pRequest = NULL;
|
SRequestObj* pRequest = NULL;
|
||||||
SQuery* pQuery;
|
SQuery* pQuery = NULL;
|
||||||
SArray* pNodeList = taosArrayInit(4, sizeof(struct SQueryNodeAddr));
|
SArray* pNodeList = taosArrayInit(4, sizeof(struct SQueryNodeAddr));
|
||||||
|
|
||||||
terrno = TSDB_CODE_SUCCESS;
|
terrno = TSDB_CODE_SUCCESS;
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nodesint.h"
|
#include "nodesUtil.h"
|
||||||
#include "plannodes.h"
|
#include "plannodes.h"
|
||||||
#include "querynodes.h"
|
#include "querynodes.h"
|
||||||
#include "taos.h"
|
#include "taos.h"
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nodesint.h"
|
#include "nodesUtil.h"
|
||||||
#include "plannodes.h"
|
#include "plannodes.h"
|
||||||
#include "querynodes.h"
|
#include "querynodes.h"
|
||||||
#include "query.h"
|
#include "query.h"
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "cmdnodes.h"
|
#include "cmdnodes.h"
|
||||||
#include "nodesint.h"
|
#include "nodesUtil.h"
|
||||||
#include "plannodes.h"
|
#include "plannodes.h"
|
||||||
#include "querynodes.h"
|
#include "querynodes.h"
|
||||||
#include "taos.h"
|
#include "taos.h"
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can use, redistribute, and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License, version 3
|
|
||||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef TDENGINE_INSERTPARSER_H
|
|
||||||
#define TDENGINE_INSERTPARSER_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "parser.h"
|
|
||||||
|
|
||||||
int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // TDENGINE_INSERTPARSER_H
|
|
|
@ -1,557 +0,0 @@
|
||||||
//lemon parser file to generate sql parse by using finite-state-machine code used to parse sql
|
|
||||||
//usage: lemon sql.y
|
|
||||||
|
|
||||||
%name NewParse
|
|
||||||
|
|
||||||
%token_prefix TK_
|
|
||||||
%token_type { SToken }
|
|
||||||
%default_type { SNode* }
|
|
||||||
%default_destructor { nodesDestroyNode($$); }
|
|
||||||
|
|
||||||
%extra_argument { SAstCreateContext* pCxt }
|
|
||||||
|
|
||||||
%include {
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
#include "nodes.h"
|
|
||||||
#include "ttoken.h"
|
|
||||||
#include "ttokendef.h"
|
|
||||||
#include "astCreateFuncs.h"
|
|
||||||
}
|
|
||||||
|
|
||||||
%syntax_error {
|
|
||||||
if(TOKEN.z) {
|
|
||||||
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, TOKEN.z);
|
|
||||||
} else {
|
|
||||||
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INCOMPLETE_SQL);
|
|
||||||
}
|
|
||||||
pCxt->valid = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
%left OR.
|
|
||||||
%left AND.
|
|
||||||
//%right NOT.
|
|
||||||
%left UNION ALL MINUS EXCEPT INTERSECT.
|
|
||||||
%left NK_BITAND NK_BITOR NK_LSHIFT NK_RSHIFT.
|
|
||||||
%left NK_PLUS NK_MINUS.
|
|
||||||
//%left DIVIDE TIMES.
|
|
||||||
%left NK_STAR NK_SLASH NK_REM.
|
|
||||||
%left NK_CONCAT.
|
|
||||||
//%right NK_BITNOT.
|
|
||||||
|
|
||||||
/************************************************ create/alter/drop/show user *****************************************/
|
|
||||||
cmd ::= CREATE USER user_name(A) PASS NK_STRING(B). { pCxt->pRootNode = createCreateUserStmt(pCxt, &A, &B);}
|
|
||||||
cmd ::= ALTER USER user_name(A) PASS NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PASSWD, &B);}
|
|
||||||
cmd ::= ALTER USER user_name(A) PRIVILEGE NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PRIVILEGES, &B);}
|
|
||||||
cmd ::= DROP USER user_name(A). { pCxt->pRootNode = createDropUserStmt(pCxt, &A); }
|
|
||||||
cmd ::= SHOW USERS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT, NULL); }
|
|
||||||
|
|
||||||
/************************************************ create/drop/show dnode **********************************************/
|
|
||||||
cmd ::= CREATE DNODE dnode_endpoint(A). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, NULL);}
|
|
||||||
cmd ::= CREATE DNODE dnode_host_name(A) PORT NK_INTEGER(B). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, &B);}
|
|
||||||
cmd ::= DROP DNODE NK_INTEGER(A). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A);}
|
|
||||||
cmd ::= DROP DNODE dnode_endpoint(A). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A);}
|
|
||||||
cmd ::= SHOW DNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT, NULL); }
|
|
||||||
|
|
||||||
%type dnode_endpoint { SToken }
|
|
||||||
%destructor dnode_endpoint { }
|
|
||||||
dnode_endpoint(A) ::= NK_STRING(B). { A = B; }
|
|
||||||
|
|
||||||
%type dnode_host_name { SToken }
|
|
||||||
%destructor dnode_host_name { }
|
|
||||||
dnode_host_name(A) ::= NK_ID(B). { A = B; }
|
|
||||||
dnode_host_name(A) ::= NK_IPTOKEN(B). { A = B; }
|
|
||||||
|
|
||||||
/************************************************ create/drop/show/use database ***************************************/
|
|
||||||
cmd ::= CREATE DATABASE not_exists_opt(A) db_name(B) db_options(C). { pCxt->pRootNode = createCreateDatabaseStmt(pCxt, A, &B, C);}
|
|
||||||
cmd ::= DROP DATABASE exists_opt(A) db_name(B). { pCxt->pRootNode = createDropDatabaseStmt(pCxt, A, &B); }
|
|
||||||
cmd ::= SHOW DATABASES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT, NULL); }
|
|
||||||
cmd ::= USE db_name(A). { pCxt->pRootNode = createUseDatabaseStmt(pCxt, &A);}
|
|
||||||
|
|
||||||
%type not_exists_opt { bool }
|
|
||||||
%destructor not_exists_opt { }
|
|
||||||
not_exists_opt(A) ::= IF NOT EXISTS. { A = true; }
|
|
||||||
not_exists_opt(A) ::= . { A = false; }
|
|
||||||
|
|
||||||
%type exists_opt { bool }
|
|
||||||
%destructor exists_opt { }
|
|
||||||
exists_opt(A) ::= IF EXISTS. { A = true; }
|
|
||||||
exists_opt(A) ::= . { A = false; }
|
|
||||||
|
|
||||||
%type db_options { SDatabaseOptions* }
|
|
||||||
%destructor db_options { tfree($$); }
|
|
||||||
db_options(A) ::= . { A = createDefaultDatabaseOptions(pCxt); }
|
|
||||||
db_options(A) ::= db_options(B) BLOCKS NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_BLOCKS, &C); }
|
|
||||||
db_options(A) ::= db_options(B) CACHE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_CACHE, &C); }
|
|
||||||
db_options(A) ::= db_options(B) CACHELAST NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_CACHELAST, &C); }
|
|
||||||
db_options(A) ::= db_options(B) COMP NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_COMP, &C); }
|
|
||||||
db_options(A) ::= db_options(B) DAYS NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_DAYS, &C); }
|
|
||||||
db_options(A) ::= db_options(B) FSYNC NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_FSYNC, &C); }
|
|
||||||
db_options(A) ::= db_options(B) MAXROWS NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_MAXROWS, &C); }
|
|
||||||
db_options(A) ::= db_options(B) MINROWS NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_MINROWS, &C); }
|
|
||||||
db_options(A) ::= db_options(B) KEEP NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_KEEP, &C); }
|
|
||||||
db_options(A) ::= db_options(B) PRECISION NK_STRING(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_PRECISION, &C); }
|
|
||||||
db_options(A) ::= db_options(B) QUORUM NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_QUORUM, &C); }
|
|
||||||
db_options(A) ::= db_options(B) REPLICA NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_REPLICA, &C); }
|
|
||||||
db_options(A) ::= db_options(B) TTL NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_TTL, &C); }
|
|
||||||
db_options(A) ::= db_options(B) WAL NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_WAL, &C); }
|
|
||||||
db_options(A) ::= db_options(B) VGROUPS NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_VGROUPS, &C); }
|
|
||||||
db_options(A) ::= db_options(B) SINGLE_STABLE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_SINGLESTABLE, &C); }
|
|
||||||
db_options(A) ::= db_options(B) STREAM_MODE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_STREAMMODE, &C); }
|
|
||||||
|
|
||||||
/************************************************ create/drop/show table/stable ***************************************/
|
|
||||||
cmd ::= CREATE TABLE not_exists_opt(A) full_table_name(B)
|
|
||||||
NK_LP column_def_list(C) NK_RP tags_def_opt(D) table_options(E). { pCxt->pRootNode = createCreateTableStmt(pCxt, A, B, C, D, E);}
|
|
||||||
cmd ::= CREATE TABLE multi_create_clause(A). { pCxt->pRootNode = createCreateMultiTableStmt(pCxt, A);}
|
|
||||||
cmd ::= CREATE STABLE not_exists_opt(A) full_table_name(B)
|
|
||||||
NK_LP column_def_list(C) NK_RP tags_def(D) table_options(E). { pCxt->pRootNode = createCreateTableStmt(pCxt, A, B, C, D, E);}
|
|
||||||
cmd ::= DROP TABLE multi_drop_clause(A). { pCxt->pRootNode = createDropTableStmt(pCxt, A); }
|
|
||||||
cmd ::= DROP STABLE exists_opt(A) full_table_name(B). { pCxt->pRootNode = createDropSuperTableStmt(pCxt, A, B); }
|
|
||||||
cmd ::= SHOW TABLES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT, NULL); }
|
|
||||||
cmd ::= SHOW STABLES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STABLES_STMT, NULL); }
|
|
||||||
|
|
||||||
%type multi_create_clause { SNodeList* }
|
|
||||||
%destructor multi_create_clause { nodesDestroyList($$); }
|
|
||||||
multi_create_clause(A) ::= create_subtable_clause(B). { A = createNodeList(pCxt, B); }
|
|
||||||
multi_create_clause(A) ::= multi_create_clause(B) create_subtable_clause(C). { A = addNodeToList(pCxt, B, C); }
|
|
||||||
|
|
||||||
create_subtable_clause(A) ::=
|
|
||||||
not_exists_opt(B) full_table_name(C) USING full_table_name(D)
|
|
||||||
specific_tags_opt(E) TAGS NK_LP literal_list(F) NK_RP. { A = createCreateSubTableClause(pCxt, B, C, D, E, F); }
|
|
||||||
|
|
||||||
%type multi_drop_clause { SNodeList* }
|
|
||||||
%destructor multi_drop_clause { nodesDestroyList($$); }
|
|
||||||
multi_drop_clause(A) ::= drop_table_clause(B). { A = createNodeList(pCxt, B); }
|
|
||||||
multi_drop_clause(A) ::= multi_drop_clause(B) drop_table_clause(C). { A = addNodeToList(pCxt, B, C); }
|
|
||||||
|
|
||||||
drop_table_clause(A) ::= exists_opt(B) full_table_name(C). { A = createDropTableClause(pCxt, B, C); }
|
|
||||||
|
|
||||||
%type specific_tags_opt { SNodeList* }
|
|
||||||
%destructor specific_tags_opt { nodesDestroyList($$); }
|
|
||||||
specific_tags_opt(A) ::= . { A = NULL; }
|
|
||||||
specific_tags_opt(A) ::= NK_LP col_name_list(B) NK_RP. { A = B; }
|
|
||||||
|
|
||||||
full_table_name(A) ::= table_name(B). { A = createRealTableNode(pCxt, NULL, &B, NULL); }
|
|
||||||
full_table_name(A) ::= db_name(B) NK_DOT table_name(C). { A = createRealTableNode(pCxt, &B, &C, NULL); }
|
|
||||||
|
|
||||||
%type column_def_list { SNodeList* }
|
|
||||||
%destructor column_def_list { nodesDestroyList($$); }
|
|
||||||
column_def_list(A) ::= column_def(B). { A = createNodeList(pCxt, B); }
|
|
||||||
column_def_list(A) ::= column_def_list(B) NK_COMMA column_def(C). { A = addNodeToList(pCxt, B, C); }
|
|
||||||
|
|
||||||
column_def(A) ::= column_name(B) type_name(C). { A = createColumnDefNode(pCxt, &B, C, NULL); }
|
|
||||||
column_def(A) ::= column_name(B) type_name(C) COMMENT NK_STRING(D). { A = createColumnDefNode(pCxt, &B, C, &D); }
|
|
||||||
|
|
||||||
%type type_name { SDataType }
|
|
||||||
%destructor type_name { }
|
|
||||||
type_name(A) ::= BOOL. { A = createDataType(TSDB_DATA_TYPE_BOOL); }
|
|
||||||
type_name(A) ::= TINYINT. { A = createDataType(TSDB_DATA_TYPE_TINYINT); }
|
|
||||||
type_name(A) ::= SMALLINT. { A = createDataType(TSDB_DATA_TYPE_SMALLINT); }
|
|
||||||
type_name(A) ::= INT. { A = createDataType(TSDB_DATA_TYPE_INT); }
|
|
||||||
type_name(A) ::= INTEGER. { A = createDataType(TSDB_DATA_TYPE_INT); }
|
|
||||||
type_name(A) ::= BIGINT. { A = createDataType(TSDB_DATA_TYPE_BIGINT); }
|
|
||||||
type_name(A) ::= FLOAT. { A = createDataType(TSDB_DATA_TYPE_FLOAT); }
|
|
||||||
type_name(A) ::= DOUBLE. { A = createDataType(TSDB_DATA_TYPE_DOUBLE); }
|
|
||||||
type_name(A) ::= BINARY NK_LP NK_INTEGER(B) NK_RP. { A = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &B); }
|
|
||||||
type_name(A) ::= TIMESTAMP. { A = createDataType(TSDB_DATA_TYPE_TIMESTAMP); }
|
|
||||||
type_name(A) ::= NCHAR NK_LP NK_INTEGER(B) NK_RP. { A = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &B); }
|
|
||||||
type_name(A) ::= TINYINT UNSIGNED. { A = createDataType(TSDB_DATA_TYPE_UTINYINT); }
|
|
||||||
type_name(A) ::= SMALLINT UNSIGNED. { A = createDataType(TSDB_DATA_TYPE_USMALLINT); }
|
|
||||||
type_name(A) ::= INT UNSIGNED. { A = createDataType(TSDB_DATA_TYPE_UINT); }
|
|
||||||
type_name(A) ::= BIGINT UNSIGNED. { A = createDataType(TSDB_DATA_TYPE_UBIGINT); }
|
|
||||||
type_name(A) ::= JSON. { A = createDataType(TSDB_DATA_TYPE_JSON); }
|
|
||||||
type_name(A) ::= VARCHAR NK_LP NK_INTEGER(B) NK_RP. { A = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &B); }
|
|
||||||
type_name(A) ::= MEDIUMBLOB. { A = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); }
|
|
||||||
type_name(A) ::= BLOB. { A = createDataType(TSDB_DATA_TYPE_BLOB); }
|
|
||||||
type_name(A) ::= VARBINARY NK_LP NK_INTEGER(B) NK_RP. { A = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &B); }
|
|
||||||
type_name(A) ::= DECIMAL. { A = createDataType(TSDB_DATA_TYPE_DECIMAL); }
|
|
||||||
type_name(A) ::= DECIMAL NK_LP NK_INTEGER NK_RP. { A = createDataType(TSDB_DATA_TYPE_DECIMAL); }
|
|
||||||
type_name(A) ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP. { A = createDataType(TSDB_DATA_TYPE_DECIMAL); }
|
|
||||||
|
|
||||||
%type tags_def_opt { SNodeList* }
|
|
||||||
%destructor tags_def_opt { nodesDestroyList($$); }
|
|
||||||
tags_def_opt(A) ::= . { A = NULL; }
|
|
||||||
tags_def_opt(A) ::= tags_def(B). { A = B; }
|
|
||||||
|
|
||||||
%type tags_def { SNodeList* }
|
|
||||||
%destructor tags_def { nodesDestroyList($$); }
|
|
||||||
tags_def(A) ::= TAGS NK_LP column_def_list(B) NK_RP. { A = B; }
|
|
||||||
|
|
||||||
%type table_options { STableOptions* }
|
|
||||||
%destructor table_options { tfree($$); }
|
|
||||||
table_options(A) ::= . { A = createDefaultTableOptions(pCxt);}
|
|
||||||
table_options(A) ::= table_options(B) COMMENT NK_STRING(C). { A = setTableOption(pCxt, B, TABLE_OPTION_COMMENT, &C); }
|
|
||||||
table_options(A) ::= table_options(B) KEEP NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_KEEP, &C); }
|
|
||||||
table_options(A) ::= table_options(B) TTL NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_TTL, &C); }
|
|
||||||
table_options(A) ::= table_options(B) SMA NK_LP col_name_list(C) NK_RP. { A = setTableSmaOption(pCxt, B, C); }
|
|
||||||
|
|
||||||
%type col_name_list { SNodeList* }
|
|
||||||
%destructor col_name_list { nodesDestroyList($$); }
|
|
||||||
col_name_list(A) ::= col_name(B). { A = createNodeList(pCxt, B); }
|
|
||||||
col_name_list(A) ::= col_name_list(B) NK_COMMA col_name(C). { A = addNodeToList(pCxt, B, C); }
|
|
||||||
|
|
||||||
col_name(A) ::= column_name(B). { A = createColumnNode(pCxt, NULL, &B); }
|
|
||||||
|
|
||||||
/************************************************ show vgroups ********************************************************/
|
|
||||||
cmd ::= SHOW VGROUPS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, NULL); }
|
|
||||||
cmd ::= SHOW db_name(B) NK_DOT VGROUPS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, &B); }
|
|
||||||
|
|
||||||
/************************************************ select **************************************************************/
|
|
||||||
cmd ::= query_expression(A). { pCxt->pRootNode = A; }
|
|
||||||
|
|
||||||
/************************************************ literal *************************************************************/
|
|
||||||
literal(A) ::= NK_INTEGER(B). { A = createRawExprNode(pCxt, &B, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &B)); }
|
|
||||||
literal(A) ::= NK_FLOAT(B). { A = createRawExprNode(pCxt, &B, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &B)); }
|
|
||||||
literal(A) ::= NK_STRING(B). { A = createRawExprNode(pCxt, &B, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B)); }
|
|
||||||
literal(A) ::= NK_BOOL(B). { A = createRawExprNode(pCxt, &B, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &B)); }
|
|
||||||
literal(A) ::= TIMESTAMP(B) NK_STRING(C). { A = createRawExprNodeExt(pCxt, &B, &C, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &C)); }
|
|
||||||
literal(A) ::= duration_literal(B). { A = B; }
|
|
||||||
|
|
||||||
duration_literal(A) ::= NK_VARIABLE(B). { A = createRawExprNode(pCxt, &B, createDurationValueNode(pCxt, &B)); }
|
|
||||||
|
|
||||||
%type literal_list { SNodeList* }
|
|
||||||
%destructor literal_list { nodesDestroyList($$); }
|
|
||||||
literal_list(A) ::= literal(B). { A = createNodeList(pCxt, releaseRawExprNode(pCxt, B)); }
|
|
||||||
literal_list(A) ::= literal_list(B) NK_COMMA literal(C). { A = addNodeToList(pCxt, B, releaseRawExprNode(pCxt, C)); }
|
|
||||||
|
|
||||||
/************************************************ names and identifiers ***********************************************/
|
|
||||||
%type db_name { SToken }
|
|
||||||
%destructor db_name { }
|
|
||||||
db_name(A) ::= NK_ID(B). { A = B; }
|
|
||||||
|
|
||||||
%type table_name { SToken }
|
|
||||||
%destructor table_name { }
|
|
||||||
table_name(A) ::= NK_ID(B). { A = B; }
|
|
||||||
|
|
||||||
%type column_name { SToken }
|
|
||||||
%destructor column_name { }
|
|
||||||
column_name(A) ::= NK_ID(B). { A = B; }
|
|
||||||
|
|
||||||
%type function_name { SToken }
|
|
||||||
%destructor function_name { }
|
|
||||||
function_name(A) ::= NK_ID(B). { A = B; }
|
|
||||||
|
|
||||||
%type table_alias { SToken }
|
|
||||||
%destructor table_alias { }
|
|
||||||
table_alias(A) ::= NK_ID(B). { A = B; }
|
|
||||||
|
|
||||||
%type column_alias { SToken }
|
|
||||||
%destructor column_alias { }
|
|
||||||
column_alias(A) ::= NK_ID(B). { A = B; }
|
|
||||||
|
|
||||||
%type user_name { SToken }
|
|
||||||
%destructor user_name { }
|
|
||||||
user_name(A) ::= NK_ID(B). { A = B; }
|
|
||||||
|
|
||||||
/************************************************ expression **********************************************************/
|
|
||||||
expression(A) ::= literal(B). { A = B; }
|
|
||||||
//expression(A) ::= NK_QUESTION(B). { A = B; }
|
|
||||||
//expression(A) ::= pseudo_column(B). { A = B; }
|
|
||||||
expression(A) ::= column_reference(B). { A = B; }
|
|
||||||
expression(A) ::= function_name(B) NK_LP expression_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); }
|
|
||||||
expression(A) ::= function_name(B) NK_LP NK_STAR(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, createNodeList(pCxt, createColumnNode(pCxt, NULL, &C)))); }
|
|
||||||
//expression(A) ::= cast_expression(B). { A = B; }
|
|
||||||
//expression(A) ::= case_expression(B). { A = B; }
|
|
||||||
expression(A) ::= subquery(B). { A = B; }
|
|
||||||
expression(A) ::= NK_LP(B) expression(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, releaseRawExprNode(pCxt, C)); }
|
|
||||||
expression(A) ::= NK_PLUS(B) expression(C). {
|
|
||||||
SToken t = getTokenFromRawExprNode(pCxt, C);
|
|
||||||
A = createRawExprNodeExt(pCxt, &B, &t, releaseRawExprNode(pCxt, C));
|
|
||||||
}
|
|
||||||
expression(A) ::= NK_MINUS(B) expression(C). {
|
|
||||||
SToken t = getTokenFromRawExprNode(pCxt, C);
|
|
||||||
A = createRawExprNodeExt(pCxt, &B, &t, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, C), NULL));
|
|
||||||
}
|
|
||||||
expression(A) ::= expression(B) NK_PLUS expression(C). {
|
|
||||||
SToken s = getTokenFromRawExprNode(pCxt, B);
|
|
||||||
SToken e = getTokenFromRawExprNode(pCxt, C);
|
|
||||||
A = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C)));
|
|
||||||
}
|
|
||||||
expression(A) ::= expression(B) NK_MINUS expression(C). {
|
|
||||||
SToken s = getTokenFromRawExprNode(pCxt, B);
|
|
||||||
SToken e = getTokenFromRawExprNode(pCxt, C);
|
|
||||||
A = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C)));
|
|
||||||
}
|
|
||||||
expression(A) ::= expression(B) NK_STAR expression(C). {
|
|
||||||
SToken s = getTokenFromRawExprNode(pCxt, B);
|
|
||||||
SToken e = getTokenFromRawExprNode(pCxt, C);
|
|
||||||
A = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C)));
|
|
||||||
}
|
|
||||||
expression(A) ::= expression(B) NK_SLASH expression(C). {
|
|
||||||
SToken s = getTokenFromRawExprNode(pCxt, B);
|
|
||||||
SToken e = getTokenFromRawExprNode(pCxt, C);
|
|
||||||
A = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C)));
|
|
||||||
}
|
|
||||||
expression(A) ::= expression(B) NK_REM expression(C). {
|
|
||||||
SToken s = getTokenFromRawExprNode(pCxt, B);
|
|
||||||
SToken e = getTokenFromRawExprNode(pCxt, C);
|
|
||||||
A = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C)));
|
|
||||||
}
|
|
||||||
|
|
||||||
%type expression_list { SNodeList* }
|
|
||||||
%destructor expression_list { nodesDestroyList($$); }
|
|
||||||
expression_list(A) ::= expression(B). { A = createNodeList(pCxt, releaseRawExprNode(pCxt, B)); }
|
|
||||||
expression_list(A) ::= expression_list(B) NK_COMMA expression(C). { A = addNodeToList(pCxt, B, releaseRawExprNode(pCxt, C)); }
|
|
||||||
|
|
||||||
column_reference(A) ::= column_name(B). { A = createRawExprNode(pCxt, &B, createColumnNode(pCxt, NULL, &B)); }
|
|
||||||
column_reference(A) ::= table_name(B) NK_DOT column_name(C). { A = createRawExprNodeExt(pCxt, &B, &C, createColumnNode(pCxt, &B, &C)); }
|
|
||||||
|
|
||||||
//pseudo_column(A) ::= NK_NOW. { A = createFunctionNode(pCxt, NULL, NULL); }
|
|
||||||
|
|
||||||
/************************************************ predicate ***********************************************************/
|
|
||||||
predicate(A) ::= expression(B) compare_op(C) expression(D). {
|
|
||||||
SToken s = getTokenFromRawExprNode(pCxt, B);
|
|
||||||
SToken e = getTokenFromRawExprNode(pCxt, D);
|
|
||||||
A = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, C, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, D)));
|
|
||||||
}
|
|
||||||
//predicate(A) ::= expression(B) compare_op sub_type expression(B).
|
|
||||||
predicate(A) ::= expression(B) BETWEEN expression(C) AND expression(D). {
|
|
||||||
SToken s = getTokenFromRawExprNode(pCxt, B);
|
|
||||||
SToken e = getTokenFromRawExprNode(pCxt, D);
|
|
||||||
A = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C), releaseRawExprNode(pCxt, D)));
|
|
||||||
}
|
|
||||||
predicate(A) ::= expression(B) NOT BETWEEN expression(C) AND expression(D). {
|
|
||||||
SToken s = getTokenFromRawExprNode(pCxt, B);
|
|
||||||
SToken e = getTokenFromRawExprNode(pCxt, D);
|
|
||||||
A = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, C), releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, D)));
|
|
||||||
}
|
|
||||||
predicate(A) ::= expression(B) IS NULL(C). {
|
|
||||||
SToken s = getTokenFromRawExprNode(pCxt, B);
|
|
||||||
A = createRawExprNodeExt(pCxt, &s, &C, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, B), NULL));
|
|
||||||
}
|
|
||||||
predicate(A) ::= expression(B) IS NOT NULL(C). {
|
|
||||||
SToken s = getTokenFromRawExprNode(pCxt, B);
|
|
||||||
A = createRawExprNodeExt(pCxt, &s, &C, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, B), NULL));
|
|
||||||
}
|
|
||||||
predicate(A) ::= expression(B) in_op(C) in_predicate_value(D). {
|
|
||||||
SToken s = getTokenFromRawExprNode(pCxt, B);
|
|
||||||
SToken e = getTokenFromRawExprNode(pCxt, D);
|
|
||||||
A = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, C, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, D)));
|
|
||||||
}
|
|
||||||
|
|
||||||
%type compare_op { EOperatorType }
|
|
||||||
%destructor compare_op { }
|
|
||||||
compare_op(A) ::= NK_LT. { A = OP_TYPE_LOWER_THAN; }
|
|
||||||
compare_op(A) ::= NK_GT. { A = OP_TYPE_GREATER_THAN; }
|
|
||||||
compare_op(A) ::= NK_LE. { A = OP_TYPE_LOWER_EQUAL; }
|
|
||||||
compare_op(A) ::= NK_GE. { A = OP_TYPE_GREATER_EQUAL; }
|
|
||||||
compare_op(A) ::= NK_NE. { A = OP_TYPE_NOT_EQUAL; }
|
|
||||||
compare_op(A) ::= NK_EQ. { A = OP_TYPE_EQUAL; }
|
|
||||||
compare_op(A) ::= LIKE. { A = OP_TYPE_LIKE; }
|
|
||||||
compare_op(A) ::= NOT LIKE. { A = OP_TYPE_NOT_LIKE; }
|
|
||||||
compare_op(A) ::= MATCH. { A = OP_TYPE_MATCH; }
|
|
||||||
compare_op(A) ::= NMATCH. { A = OP_TYPE_NMATCH; }
|
|
||||||
|
|
||||||
%type in_op { EOperatorType }
|
|
||||||
%destructor in_op { }
|
|
||||||
in_op(A) ::= IN. { A = OP_TYPE_IN; }
|
|
||||||
in_op(A) ::= NOT IN. { A = OP_TYPE_NOT_IN; }
|
|
||||||
|
|
||||||
in_predicate_value(A) ::= NK_LP(C) expression_list(B) NK_RP(D). { A = createRawExprNodeExt(pCxt, &C, &D, createNodeListNode(pCxt, B)); }
|
|
||||||
|
|
||||||
/************************************************ boolean_value_expression ********************************************/
|
|
||||||
boolean_value_expression(A) ::= boolean_primary(B). { A = B; }
|
|
||||||
boolean_value_expression(A) ::= NOT(C) boolean_primary(B). {
|
|
||||||
SToken e = getTokenFromRawExprNode(pCxt, B);
|
|
||||||
A = createRawExprNodeExt(pCxt, &C, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, B), NULL));
|
|
||||||
}
|
|
||||||
boolean_value_expression(A) ::=
|
|
||||||
boolean_value_expression(B) OR boolean_value_expression(C). {
|
|
||||||
SToken s = getTokenFromRawExprNode(pCxt, B);
|
|
||||||
SToken e = getTokenFromRawExprNode(pCxt, C);
|
|
||||||
A = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C)));
|
|
||||||
}
|
|
||||||
boolean_value_expression(A) ::=
|
|
||||||
boolean_value_expression(B) AND boolean_value_expression(C). {
|
|
||||||
SToken s = getTokenFromRawExprNode(pCxt, B);
|
|
||||||
SToken e = getTokenFromRawExprNode(pCxt, C);
|
|
||||||
A = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C)));
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean_primary(A) ::= predicate(B). { A = B; }
|
|
||||||
boolean_primary(A) ::= NK_LP(C) boolean_value_expression(B) NK_RP(D). { A = createRawExprNodeExt(pCxt, &C, &D, releaseRawExprNode(pCxt, B)); }
|
|
||||||
|
|
||||||
/************************************************ common_expression ********************************************/
|
|
||||||
common_expression(A) ::= expression(B). { A = B; }
|
|
||||||
common_expression(A) ::= boolean_value_expression(B). { A = B; }
|
|
||||||
|
|
||||||
/************************************************ from_clause *********************************************************/
|
|
||||||
from_clause(A) ::= FROM table_reference_list(B). { A = B; }
|
|
||||||
|
|
||||||
table_reference_list(A) ::= table_reference(B). { A = B; }
|
|
||||||
table_reference_list(A) ::= table_reference_list(B) NK_COMMA table_reference(C). { A = createJoinTableNode(pCxt, JOIN_TYPE_INNER, B, C, NULL); }
|
|
||||||
|
|
||||||
/************************************************ table_reference *****************************************************/
|
|
||||||
table_reference(A) ::= table_primary(B). { A = B; }
|
|
||||||
table_reference(A) ::= joined_table(B). { A = B; }
|
|
||||||
|
|
||||||
table_primary(A) ::= table_name(B) alias_opt(C). { A = createRealTableNode(pCxt, NULL, &B, &C); }
|
|
||||||
table_primary(A) ::= db_name(B) NK_DOT table_name(C) alias_opt(D). { A = createRealTableNode(pCxt, &B, &C, &D); }
|
|
||||||
table_primary(A) ::= subquery(B) alias_opt(C). { A = createTempTableNode(pCxt, releaseRawExprNode(pCxt, B), &C); }
|
|
||||||
table_primary(A) ::= parenthesized_joined_table(B). { A = B; }
|
|
||||||
|
|
||||||
%type alias_opt { SToken }
|
|
||||||
%destructor alias_opt { }
|
|
||||||
alias_opt(A) ::= . { A = nil_token; }
|
|
||||||
alias_opt(A) ::= table_alias(B). { A = B; }
|
|
||||||
alias_opt(A) ::= AS table_alias(B). { A = B; }
|
|
||||||
|
|
||||||
parenthesized_joined_table(A) ::= NK_LP joined_table(B) NK_RP. { A = B; }
|
|
||||||
parenthesized_joined_table(A) ::= NK_LP parenthesized_joined_table(B) NK_RP. { A = B; }
|
|
||||||
|
|
||||||
/************************************************ joined_table ********************************************************/
|
|
||||||
joined_table(A) ::=
|
|
||||||
table_reference(B) join_type(C) JOIN table_reference(D) ON search_condition(E). { A = createJoinTableNode(pCxt, C, B, D, E); }
|
|
||||||
|
|
||||||
%type join_type { EJoinType }
|
|
||||||
%destructor join_type { }
|
|
||||||
join_type(A) ::= . { A = JOIN_TYPE_INNER; }
|
|
||||||
join_type(A) ::= INNER. { A = JOIN_TYPE_INNER; }
|
|
||||||
|
|
||||||
/************************************************ query_specification *************************************************/
|
|
||||||
query_specification(A) ::=
|
|
||||||
SELECT set_quantifier_opt(B) select_list(C) from_clause(D) where_clause_opt(E)
|
|
||||||
partition_by_clause_opt(F) twindow_clause_opt(G)
|
|
||||||
group_by_clause_opt(H) having_clause_opt(I). {
|
|
||||||
A = createSelectStmt(pCxt, B, C, D);
|
|
||||||
A = addWhereClause(pCxt, A, E);
|
|
||||||
A = addPartitionByClause(pCxt, A, F);
|
|
||||||
A = addWindowClauseClause(pCxt, A, G);
|
|
||||||
A = addGroupByClause(pCxt, A, H);
|
|
||||||
A = addHavingClause(pCxt, A, I);
|
|
||||||
}
|
|
||||||
|
|
||||||
%type set_quantifier_opt { bool }
|
|
||||||
%destructor set_quantifier_opt { }
|
|
||||||
set_quantifier_opt(A) ::= . { A = false; }
|
|
||||||
set_quantifier_opt(A) ::= DISTINCT. { A = true; }
|
|
||||||
set_quantifier_opt(A) ::= ALL. { A = false; }
|
|
||||||
|
|
||||||
%type select_list { SNodeList* }
|
|
||||||
%destructor select_list { nodesDestroyList($$); }
|
|
||||||
select_list(A) ::= NK_STAR. { A = NULL; }
|
|
||||||
select_list(A) ::= select_sublist(B). { A = B; }
|
|
||||||
|
|
||||||
%type select_sublist { SNodeList* }
|
|
||||||
%destructor select_sublist { nodesDestroyList($$); }
|
|
||||||
select_sublist(A) ::= select_item(B). { A = createNodeList(pCxt, B); }
|
|
||||||
select_sublist(A) ::= select_sublist(B) NK_COMMA select_item(C). { A = addNodeToList(pCxt, B, C); }
|
|
||||||
|
|
||||||
select_item(A) ::= common_expression(B). {
|
|
||||||
SToken t = getTokenFromRawExprNode(pCxt, B);
|
|
||||||
A = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, B), &t);
|
|
||||||
}
|
|
||||||
select_item(A) ::= common_expression(B) column_alias(C). { A = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, B), &C); }
|
|
||||||
select_item(A) ::= common_expression(B) AS column_alias(C). { A = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, B), &C); }
|
|
||||||
select_item(A) ::= table_name(B) NK_DOT NK_STAR(C). { A = createColumnNode(pCxt, &B, &C); }
|
|
||||||
|
|
||||||
where_clause_opt(A) ::= . { A = NULL; }
|
|
||||||
where_clause_opt(A) ::= WHERE search_condition(B). { A = B; }
|
|
||||||
|
|
||||||
%type partition_by_clause_opt { SNodeList* }
|
|
||||||
%destructor partition_by_clause_opt { nodesDestroyList($$); }
|
|
||||||
partition_by_clause_opt(A) ::= . { A = NULL; }
|
|
||||||
partition_by_clause_opt(A) ::= PARTITION BY expression_list(B). { A = B; }
|
|
||||||
|
|
||||||
twindow_clause_opt(A) ::= . { A = NULL; }
|
|
||||||
twindow_clause_opt(A) ::=
|
|
||||||
SESSION NK_LP column_reference(B) NK_COMMA NK_INTEGER(C) NK_RP. { A = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, B), &C); }
|
|
||||||
twindow_clause_opt(A) ::= STATE_WINDOW NK_LP column_reference(B) NK_RP. { A = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, B)); }
|
|
||||||
twindow_clause_opt(A) ::=
|
|
||||||
INTERVAL NK_LP duration_literal(B) NK_RP sliding_opt(C) fill_opt(D). { A = createIntervalWindowNode(pCxt, B, NULL, C, D); }
|
|
||||||
twindow_clause_opt(A) ::=
|
|
||||||
INTERVAL NK_LP duration_literal(B) NK_COMMA duration_literal(C) NK_RP
|
|
||||||
sliding_opt(D) fill_opt(E). { A = createIntervalWindowNode(pCxt, B, C, D, E); }
|
|
||||||
|
|
||||||
sliding_opt(A) ::= . { A = NULL; }
|
|
||||||
sliding_opt(A) ::= SLIDING NK_LP duration_literal(B) NK_RP. { A = B; }
|
|
||||||
|
|
||||||
fill_opt(A) ::= . { A = NULL; }
|
|
||||||
fill_opt(A) ::= FILL NK_LP fill_mode(B) NK_RP. { A = createFillNode(pCxt, B, NULL); }
|
|
||||||
fill_opt(A) ::= FILL NK_LP VALUE NK_COMMA literal_list(B) NK_RP. { A = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, B)); }
|
|
||||||
|
|
||||||
%type fill_mode { EFillMode }
|
|
||||||
%destructor fill_mode { }
|
|
||||||
fill_mode(A) ::= NONE. { A = FILL_MODE_NONE; }
|
|
||||||
fill_mode(A) ::= PREV. { A = FILL_MODE_PREV; }
|
|
||||||
fill_mode(A) ::= NULL. { A = FILL_MODE_NULL; }
|
|
||||||
fill_mode(A) ::= LINEAR. { A = FILL_MODE_LINEAR; }
|
|
||||||
fill_mode(A) ::= NEXT. { A = FILL_MODE_NEXT; }
|
|
||||||
|
|
||||||
%type group_by_clause_opt { SNodeList* }
|
|
||||||
%destructor group_by_clause_opt { nodesDestroyList($$); }
|
|
||||||
group_by_clause_opt(A) ::= . { A = NULL; }
|
|
||||||
group_by_clause_opt(A) ::= GROUP BY group_by_list(B). { A = B; }
|
|
||||||
|
|
||||||
%type group_by_list { SNodeList* }
|
|
||||||
%destructor group_by_list { nodesDestroyList($$); }
|
|
||||||
group_by_list(A) ::= expression(B). { A = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, B))); }
|
|
||||||
group_by_list(A) ::= group_by_list(B) NK_COMMA expression(C). { A = addNodeToList(pCxt, B, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, C))); }
|
|
||||||
|
|
||||||
having_clause_opt(A) ::= . { A = NULL; }
|
|
||||||
having_clause_opt(A) ::= HAVING search_condition(B). { A = B; }
|
|
||||||
|
|
||||||
/************************************************ query_expression ****************************************************/
|
|
||||||
query_expression(A) ::=
|
|
||||||
query_expression_body(B)
|
|
||||||
order_by_clause_opt(C) slimit_clause_opt(D) limit_clause_opt(E). {
|
|
||||||
A = addOrderByClause(pCxt, B, C);
|
|
||||||
A = addSlimitClause(pCxt, A, D);
|
|
||||||
A = addLimitClause(pCxt, A, E);
|
|
||||||
}
|
|
||||||
|
|
||||||
query_expression_body(A) ::= query_primary(B). { A = B; }
|
|
||||||
query_expression_body(A) ::=
|
|
||||||
query_expression_body(B) UNION ALL query_expression_body(D). { A = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, B, D); }
|
|
||||||
|
|
||||||
query_primary(A) ::= query_specification(B). { A = B; }
|
|
||||||
//query_primary(A) ::=
|
|
||||||
// NK_LP query_expression_body(B)
|
|
||||||
// order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP. { A = B;}
|
|
||||||
|
|
||||||
%type order_by_clause_opt { SNodeList* }
|
|
||||||
%destructor order_by_clause_opt { nodesDestroyList($$); }
|
|
||||||
order_by_clause_opt(A) ::= . { A = NULL; }
|
|
||||||
order_by_clause_opt(A) ::= ORDER BY sort_specification_list(B). { A = B; }
|
|
||||||
|
|
||||||
slimit_clause_opt(A) ::= . { A = NULL; }
|
|
||||||
slimit_clause_opt(A) ::= SLIMIT NK_INTEGER(B). { A = createLimitNode(pCxt, &B, NULL); }
|
|
||||||
slimit_clause_opt(A) ::= SLIMIT NK_INTEGER(B) SOFFSET NK_INTEGER(C). { A = createLimitNode(pCxt, &B, &C); }
|
|
||||||
slimit_clause_opt(A) ::= SLIMIT NK_INTEGER(C) NK_COMMA NK_INTEGER(B). { A = createLimitNode(pCxt, &B, &C); }
|
|
||||||
|
|
||||||
limit_clause_opt(A) ::= . { A = NULL; }
|
|
||||||
limit_clause_opt(A) ::= LIMIT NK_INTEGER(B). { A = createLimitNode(pCxt, &B, NULL); }
|
|
||||||
limit_clause_opt(A) ::= LIMIT NK_INTEGER(B) OFFSET NK_INTEGER(C). { A = createLimitNode(pCxt, &B, &C); }
|
|
||||||
limit_clause_opt(A) ::= LIMIT NK_INTEGER(C) NK_COMMA NK_INTEGER(B). { A = createLimitNode(pCxt, &B, &C); }
|
|
||||||
|
|
||||||
/************************************************ subquery ************************************************************/
|
|
||||||
subquery(A) ::= NK_LP(B) query_expression(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, C); }
|
|
||||||
|
|
||||||
/************************************************ search_condition ****************************************************/
|
|
||||||
search_condition(A) ::= common_expression(B). { A = releaseRawExprNode(pCxt, B); }
|
|
||||||
|
|
||||||
/************************************************ sort_specification_list *********************************************/
|
|
||||||
%type sort_specification_list { SNodeList* }
|
|
||||||
%destructor sort_specification_list { nodesDestroyList($$); }
|
|
||||||
sort_specification_list(A) ::= sort_specification(B). { A = createNodeList(pCxt, B); }
|
|
||||||
sort_specification_list(A) ::=
|
|
||||||
sort_specification_list(B) NK_COMMA sort_specification(C). { A = addNodeToList(pCxt, B, C); }
|
|
||||||
|
|
||||||
sort_specification(A) ::=
|
|
||||||
expression(B) ordering_specification_opt(C) null_ordering_opt(D). { A = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, B), C, D); }
|
|
||||||
|
|
||||||
%type ordering_specification_opt EOrder
|
|
||||||
%destructor ordering_specification_opt { }
|
|
||||||
ordering_specification_opt(A) ::= . { A = ORDER_ASC; }
|
|
||||||
ordering_specification_opt(A) ::= ASC. { A = ORDER_ASC; }
|
|
||||||
ordering_specification_opt(A) ::= DESC. { A = ORDER_DESC; }
|
|
||||||
|
|
||||||
%type null_ordering_opt ENullOrder
|
|
||||||
%destructor null_ordering_opt { }
|
|
||||||
null_ordering_opt(A) ::= . { A = NULL_ORDER_DEFAULT; }
|
|
||||||
null_ordering_opt(A) ::= NULLS FIRST. { A = NULL_ORDER_FIRST; }
|
|
||||||
null_ordering_opt(A) ::= NULLS LAST. { A = NULL_ORDER_LAST; }
|
|
|
@ -22,9 +22,9 @@ extern "C" {
|
||||||
|
|
||||||
#include "cmdnodes.h"
|
#include "cmdnodes.h"
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
#include "parserUtil.h"
|
#include "parToken.h"
|
||||||
|
#include "parUtil.h"
|
||||||
#include "querynodes.h"
|
#include "querynodes.h"
|
||||||
#include "ttoken.h"
|
|
||||||
|
|
||||||
typedef struct SAstCreateContext {
|
typedef struct SAstCreateContext {
|
||||||
SParseContext* pQueryCxt;
|
SParseContext* pQueryCxt;
|
|
@ -22,6 +22,7 @@ extern "C" {
|
||||||
|
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
|
|
||||||
|
int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery);
|
||||||
int32_t doParse(SParseContext* pParseCxt, SQuery** pQuery);
|
int32_t doParse(SParseContext* pParseCxt, SQuery** pQuery);
|
||||||
int32_t doTranslate(SParseContext* pParseCxt, SQuery* pQuery);
|
int32_t doTranslate(SParseContext* pParseCxt, SQuery* pQuery);
|
||||||
|
|
|
@ -22,7 +22,6 @@ extern "C" {
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "query.h"
|
#include "query.h"
|
||||||
#include "ttoken.h"
|
|
||||||
|
|
||||||
typedef struct SMsgBuf {
|
typedef struct SMsgBuf {
|
||||||
int32_t len;
|
int32_t len;
|
File diff suppressed because it is too large
Load Diff
|
@ -14,8 +14,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "astCreateFuncs.h"
|
#include "parAst.h"
|
||||||
#include "parserUtil.h"
|
#include "parUtil.h"
|
||||||
|
|
||||||
#define CHECK_OUT_OF_MEM(p) \
|
#define CHECK_OUT_OF_MEM(p) \
|
||||||
do { \
|
do { \
|
|
@ -13,28 +13,28 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "parserInt.h"
|
#include "parInt.h"
|
||||||
|
|
||||||
#include "astCreateFuncs.h"
|
#include "parAst.h"
|
||||||
#include "ttoken.h"
|
#include "parToken.h"
|
||||||
|
|
||||||
typedef void* (*FMalloc)(size_t);
|
typedef void* (*FMalloc)(size_t);
|
||||||
typedef void (*FFree)(void*);
|
typedef void (*FFree)(void*);
|
||||||
|
|
||||||
extern void* NewParseAlloc(FMalloc);
|
extern void* ParseAlloc(FMalloc);
|
||||||
extern void NewParse(void*, int, SToken, void*);
|
extern void Parse(void*, int, SToken, void*);
|
||||||
extern void NewParseFree(void*, FFree);
|
extern void ParseFree(void*, FFree);
|
||||||
extern void NewParseTrace(FILE*, char*);
|
extern void ParseTrace(FILE*, char*);
|
||||||
|
|
||||||
int32_t doParse(SParseContext* pParseCxt, SQuery** pQuery) {
|
int32_t doParse(SParseContext* pParseCxt, SQuery** pQuery) {
|
||||||
SAstCreateContext cxt;
|
SAstCreateContext cxt;
|
||||||
initAstCreateContext(pParseCxt, &cxt);
|
initAstCreateContext(pParseCxt, &cxt);
|
||||||
void *pParser = NewParseAlloc(malloc);
|
void *pParser = ParseAlloc(malloc);
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
SToken t0 = {0};
|
SToken t0 = {0};
|
||||||
if (cxt.pQueryCxt->pSql[i] == 0) {
|
if (cxt.pQueryCxt->pSql[i] == 0) {
|
||||||
NewParse(pParser, 0, t0, &cxt);
|
Parse(pParser, 0, t0, &cxt);
|
||||||
goto abort_parse;
|
goto abort_parse;
|
||||||
}
|
}
|
||||||
t0.n = tGetToken((char *)&cxt.pQueryCxt->pSql[i], &t0.type);
|
t0.n = tGetToken((char *)&cxt.pQueryCxt->pSql[i], &t0.type);
|
||||||
|
@ -47,7 +47,7 @@ int32_t doParse(SParseContext* pParseCxt, SQuery** pQuery) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TK_NK_SEMI: {
|
case TK_NK_SEMI: {
|
||||||
NewParse(pParser, 0, t0, &cxt);
|
Parse(pParser, 0, t0, &cxt);
|
||||||
goto abort_parse;
|
goto abort_parse;
|
||||||
}
|
}
|
||||||
case TK_NK_QUESTION:
|
case TK_NK_QUESTION:
|
||||||
|
@ -64,8 +64,8 @@ int32_t doParse(SParseContext* pParseCxt, SQuery** pQuery) {
|
||||||
goto abort_parse;
|
goto abort_parse;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
NewParse(pParser, t0.type, t0, &cxt);
|
Parse(pParser, t0.type, t0, &cxt);
|
||||||
// NewParseTrace(stdout, "");
|
// ParseTrace(stdout, "");
|
||||||
if (!cxt.valid) {
|
if (!cxt.valid) {
|
||||||
goto abort_parse;
|
goto abort_parse;
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ int32_t doParse(SParseContext* pParseCxt, SQuery** pQuery) {
|
||||||
}
|
}
|
||||||
|
|
||||||
abort_parse:
|
abort_parse:
|
||||||
NewParseFree(pParser, free);
|
ParseFree(pParser, free);
|
||||||
if (cxt.valid) {
|
if (cxt.valid) {
|
||||||
*pQuery = calloc(1, sizeof(SQuery));
|
*pQuery = calloc(1, sizeof(SQuery));
|
||||||
if (NULL == *pQuery) {
|
if (NULL == *pQuery) {
|
|
@ -13,13 +13,12 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "insertParser.h"
|
#include "parInsertData.h"
|
||||||
|
#include "parInt.h"
|
||||||
#include "dataBlockMgt.h"
|
#include "parUtil.h"
|
||||||
#include "parserUtil.h"
|
#include "parToken.h"
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
#include "ttime.h"
|
#include "ttime.h"
|
||||||
#include "ttoken.h"
|
|
||||||
#include "ttypes.h"
|
#include "ttypes.h"
|
||||||
|
|
||||||
#define NEXT_TOKEN(pSql, sToken) \
|
#define NEXT_TOKEN(pSql, sToken) \
|
|
@ -13,10 +13,10 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "dataBlockMgt.h"
|
#include "parInsertData.h"
|
||||||
|
|
||||||
#include "catalog.h"
|
#include "catalog.h"
|
||||||
#include "parserUtil.h"
|
#include "parUtil.h"
|
||||||
#include "querynodes.h"
|
#include "querynodes.h"
|
||||||
|
|
||||||
#define IS_RAW_PAYLOAD(t) \
|
#define IS_RAW_PAYLOAD(t) \
|
|
@ -14,10 +14,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
#include "parToken.h"
|
||||||
#include "thash.h"
|
#include "thash.h"
|
||||||
#include "taosdef.h"
|
#include "taosdef.h"
|
||||||
#include "ttoken.h"
|
|
||||||
#include "ttokendef.h"
|
#include "ttokendef.h"
|
||||||
|
|
||||||
// All the keywords of the SQL language are stored in a hash table
|
// All the keywords of the SQL language are stored in a hash table
|
|
@ -13,12 +13,12 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "parserInt.h"
|
#include "parInt.h"
|
||||||
|
|
||||||
#include "catalog.h"
|
#include "catalog.h"
|
||||||
#include "cmdnodes.h"
|
#include "cmdnodes.h"
|
||||||
#include "functionMgt.h"
|
#include "functionMgt.h"
|
||||||
#include "parserUtil.h"
|
#include "parUtil.h"
|
||||||
#include "ttime.h"
|
#include "ttime.h"
|
||||||
|
|
||||||
static bool afterGroupBy(ESqlClause clause) {
|
static bool afterGroupBy(ESqlClause clause) {
|
|
@ -13,7 +13,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "parserUtil.h"
|
#include "parUtil.h"
|
||||||
|
|
||||||
static char* getSyntaxErrFormat(int32_t errCode) {
|
static char* getSyntaxErrFormat(int32_t errCode) {
|
||||||
switch (errCode) {
|
switch (errCode) {
|
|
@ -15,9 +15,8 @@
|
||||||
|
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
|
|
||||||
#include "insertParser.h"
|
#include "parInt.h"
|
||||||
#include "parserInt.h"
|
#include "parToken.h"
|
||||||
#include "ttoken.h"
|
|
||||||
|
|
||||||
static bool isInsertSql(const char* pStr, size_t length) {
|
static bool isInsertSql(const char* pStr, size_t length) {
|
||||||
int32_t index = 0;
|
int32_t index = 0;
|
||||||
|
@ -47,5 +46,14 @@ int32_t qParseQuerySql(SParseContext* pCxt, SQuery** pQuery) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void qDestroyQuery(SQuery* pQueryNode) {
|
void qDestroyQuery(SQuery* pQueryNode) {
|
||||||
// todo
|
if (NULL == pQueryNode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
nodesDestroyNode(pQueryNode->pRoot);
|
||||||
|
tfree(pQueryNode->pResSchema);
|
||||||
|
if (NULL != pQueryNode->pCmdMsg) {
|
||||||
|
tfree(pQueryNode->pCmdMsg->pMsg);
|
||||||
|
tfree(pQueryNode->pCmdMsg);
|
||||||
|
}
|
||||||
|
tfree(pQueryNode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,9 +33,9 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "nodes.h"
|
#include "nodes.h"
|
||||||
#include "ttoken.h"
|
#include "parToken.h"
|
||||||
#include "ttokendef.h"
|
#include "ttokendef.h"
|
||||||
#include "astCreateFuncs.h"
|
#include "parAst.h"
|
||||||
/**************** End of %include directives **********************************/
|
/**************** End of %include directives **********************************/
|
||||||
/* These constants specify the various numeric values for terminal symbols
|
/* These constants specify the various numeric values for terminal symbols
|
||||||
** in a format understandable to "makeheaders". This section is blank unless
|
** in a format understandable to "makeheaders". This section is blank unless
|
||||||
|
@ -59,7 +59,7 @@
|
||||||
** YYACTIONTYPE is the data type used for "action codes" - numbers
|
** YYACTIONTYPE is the data type used for "action codes" - numbers
|
||||||
** that indicate what to do in response to the next
|
** that indicate what to do in response to the next
|
||||||
** token.
|
** token.
|
||||||
** NewParseTOKENTYPE is the data type used for minor type for terminal
|
** ParseTOKENTYPE is the data type used for minor type for terminal
|
||||||
** symbols. Background: A "minor type" is a semantic
|
** symbols. Background: A "minor type" is a semantic
|
||||||
** value associated with a terminal or non-terminal
|
** value associated with a terminal or non-terminal
|
||||||
** symbols. For example, for an "ID" terminal symbol,
|
** symbols. For example, for an "ID" terminal symbol,
|
||||||
|
@ -70,16 +70,16 @@
|
||||||
** symbols.
|
** symbols.
|
||||||
** YYMINORTYPE is the data type used for all minor types.
|
** YYMINORTYPE is the data type used for all minor types.
|
||||||
** This is typically a union of many types, one of
|
** This is typically a union of many types, one of
|
||||||
** which is NewParseTOKENTYPE. The entry in the union
|
** which is ParseTOKENTYPE. The entry in the union
|
||||||
** for terminal symbols is called "yy0".
|
** for terminal symbols is called "yy0".
|
||||||
** YYSTACKDEPTH is the maximum depth of the parser's stack. If
|
** YYSTACKDEPTH is the maximum depth of the parser's stack. If
|
||||||
** zero the stack is dynamically sized using realloc()
|
** zero the stack is dynamically sized using realloc()
|
||||||
** NewParseARG_SDECL A static variable declaration for the %extra_argument
|
** ParseARG_SDECL A static variable declaration for the %extra_argument
|
||||||
** NewParseARG_PDECL A parameter declaration for the %extra_argument
|
** ParseARG_PDECL A parameter declaration for the %extra_argument
|
||||||
** NewParseARG_PARAM Code to pass %extra_argument as a subroutine parameter
|
** ParseARG_PARAM Code to pass %extra_argument as a subroutine parameter
|
||||||
** NewParseARG_STORE Code to store %extra_argument into yypParser
|
** ParseARG_STORE Code to store %extra_argument into yypParser
|
||||||
** NewParseARG_FETCH Code to extract %extra_argument from yypParser
|
** ParseARG_FETCH Code to extract %extra_argument from yypParser
|
||||||
** NewParseCTX_* As NewParseARG_ except for %extra_context
|
** ParseCTX_* As ParseARG_ except for %extra_context
|
||||||
** YYERRORSYMBOL is the code number of the error symbol. If not
|
** YYERRORSYMBOL is the code number of the error symbol. If not
|
||||||
** defined, then do no error processing.
|
** defined, then do no error processing.
|
||||||
** YYNSTATE the combined number of states.
|
** YYNSTATE the combined number of states.
|
||||||
|
@ -101,10 +101,10 @@
|
||||||
#define YYCODETYPE unsigned char
|
#define YYCODETYPE unsigned char
|
||||||
#define YYNOCODE 208
|
#define YYNOCODE 208
|
||||||
#define YYACTIONTYPE unsigned short int
|
#define YYACTIONTYPE unsigned short int
|
||||||
#define NewParseTOKENTYPE SToken
|
#define ParseTOKENTYPE SToken
|
||||||
typedef union {
|
typedef union {
|
||||||
int yyinit;
|
int yyinit;
|
||||||
NewParseTOKENTYPE yy0;
|
ParseTOKENTYPE yy0;
|
||||||
ENullOrder yy9;
|
ENullOrder yy9;
|
||||||
SDatabaseOptions* yy103;
|
SDatabaseOptions* yy103;
|
||||||
SToken yy161;
|
SToken yy161;
|
||||||
|
@ -121,16 +121,16 @@ typedef union {
|
||||||
#ifndef YYSTACKDEPTH
|
#ifndef YYSTACKDEPTH
|
||||||
#define YYSTACKDEPTH 100
|
#define YYSTACKDEPTH 100
|
||||||
#endif
|
#endif
|
||||||
#define NewParseARG_SDECL SAstCreateContext* pCxt ;
|
#define ParseARG_SDECL SAstCreateContext* pCxt ;
|
||||||
#define NewParseARG_PDECL , SAstCreateContext* pCxt
|
#define ParseARG_PDECL , SAstCreateContext* pCxt
|
||||||
#define NewParseARG_PARAM ,pCxt
|
#define ParseARG_PARAM ,pCxt
|
||||||
#define NewParseARG_FETCH SAstCreateContext* pCxt =yypParser->pCxt ;
|
#define ParseARG_FETCH SAstCreateContext* pCxt =yypParser->pCxt ;
|
||||||
#define NewParseARG_STORE yypParser->pCxt =pCxt ;
|
#define ParseARG_STORE yypParser->pCxt =pCxt ;
|
||||||
#define NewParseCTX_SDECL
|
#define ParseCTX_SDECL
|
||||||
#define NewParseCTX_PDECL
|
#define ParseCTX_PDECL
|
||||||
#define NewParseCTX_PARAM
|
#define ParseCTX_PARAM
|
||||||
#define NewParseCTX_FETCH
|
#define ParseCTX_FETCH
|
||||||
#define NewParseCTX_STORE
|
#define ParseCTX_STORE
|
||||||
#define YYNSTATE 278
|
#define YYNSTATE 278
|
||||||
#define YYNRULE 236
|
#define YYNRULE 236
|
||||||
#define YYNTOKEN 134
|
#define YYNTOKEN 134
|
||||||
|
@ -544,8 +544,8 @@ struct yyParser {
|
||||||
#ifndef YYNOERRORRECOVERY
|
#ifndef YYNOERRORRECOVERY
|
||||||
int yyerrcnt; /* Shifts left before out of the error */
|
int yyerrcnt; /* Shifts left before out of the error */
|
||||||
#endif
|
#endif
|
||||||
NewParseARG_SDECL /* A place to hold %extra_argument */
|
ParseARG_SDECL /* A place to hold %extra_argument */
|
||||||
NewParseCTX_SDECL /* A place to hold %extra_context */
|
ParseCTX_SDECL /* A place to hold %extra_context */
|
||||||
#if YYSTACKDEPTH<=0
|
#if YYSTACKDEPTH<=0
|
||||||
int yystksz; /* Current side of the stack */
|
int yystksz; /* Current side of the stack */
|
||||||
yyStackEntry *yystack; /* The parser's stack */
|
yyStackEntry *yystack; /* The parser's stack */
|
||||||
|
@ -581,7 +581,7 @@ static char *yyTracePrompt = 0;
|
||||||
** Outputs:
|
** Outputs:
|
||||||
** None.
|
** None.
|
||||||
*/
|
*/
|
||||||
void NewParseTrace(FILE *TraceFILE, char *zTracePrompt){
|
void ParseTrace(FILE *TraceFILE, char *zTracePrompt){
|
||||||
yyTraceFILE = TraceFILE;
|
yyTraceFILE = TraceFILE;
|
||||||
yyTracePrompt = zTracePrompt;
|
yyTracePrompt = zTracePrompt;
|
||||||
if( yyTraceFILE==0 ) yyTracePrompt = 0;
|
if( yyTraceFILE==0 ) yyTracePrompt = 0;
|
||||||
|
@ -1082,7 +1082,7 @@ static int yyGrowStack(yyParser *p){
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Datatype of the argument to the memory allocated passed as the
|
/* Datatype of the argument to the memory allocated passed as the
|
||||||
** second argument to NewParseAlloc() below. This can be changed by
|
** second argument to ParseAlloc() below. This can be changed by
|
||||||
** putting an appropriate #define in the %include section of the input
|
** putting an appropriate #define in the %include section of the input
|
||||||
** grammar.
|
** grammar.
|
||||||
*/
|
*/
|
||||||
|
@ -1092,9 +1092,9 @@ static int yyGrowStack(yyParser *p){
|
||||||
|
|
||||||
/* Initialize a new parser that has already been allocated.
|
/* Initialize a new parser that has already been allocated.
|
||||||
*/
|
*/
|
||||||
void NewParseInit(void *yypRawParser NewParseCTX_PDECL){
|
void ParseInit(void *yypRawParser ParseCTX_PDECL){
|
||||||
yyParser *yypParser = (yyParser*)yypRawParser;
|
yyParser *yypParser = (yyParser*)yypRawParser;
|
||||||
NewParseCTX_STORE
|
ParseCTX_STORE
|
||||||
#ifdef YYTRACKMAXSTACKDEPTH
|
#ifdef YYTRACKMAXSTACKDEPTH
|
||||||
yypParser->yyhwm = 0;
|
yypParser->yyhwm = 0;
|
||||||
#endif
|
#endif
|
||||||
|
@ -1118,7 +1118,7 @@ void NewParseInit(void *yypRawParser NewParseCTX_PDECL){
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NewParse_ENGINEALWAYSONSTACK
|
#ifndef Parse_ENGINEALWAYSONSTACK
|
||||||
/*
|
/*
|
||||||
** This function allocates a new parser.
|
** This function allocates a new parser.
|
||||||
** The only argument is a pointer to a function which works like
|
** The only argument is a pointer to a function which works like
|
||||||
|
@ -1129,18 +1129,18 @@ void NewParseInit(void *yypRawParser NewParseCTX_PDECL){
|
||||||
**
|
**
|
||||||
** Outputs:
|
** Outputs:
|
||||||
** A pointer to a parser. This pointer is used in subsequent calls
|
** A pointer to a parser. This pointer is used in subsequent calls
|
||||||
** to NewParse and NewParseFree.
|
** to Parse and ParseFree.
|
||||||
*/
|
*/
|
||||||
void *NewParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE) NewParseCTX_PDECL){
|
void *ParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE) ParseCTX_PDECL){
|
||||||
yyParser *yypParser;
|
yyParser *yypParser;
|
||||||
yypParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
|
yypParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
|
||||||
if( yypParser ){
|
if( yypParser ){
|
||||||
NewParseCTX_STORE
|
ParseCTX_STORE
|
||||||
NewParseInit(yypParser NewParseCTX_PARAM);
|
ParseInit(yypParser ParseCTX_PARAM);
|
||||||
}
|
}
|
||||||
return (void*)yypParser;
|
return (void*)yypParser;
|
||||||
}
|
}
|
||||||
#endif /* NewParse_ENGINEALWAYSONSTACK */
|
#endif /* Parse_ENGINEALWAYSONSTACK */
|
||||||
|
|
||||||
|
|
||||||
/* The following function deletes the "minor type" or semantic value
|
/* The following function deletes the "minor type" or semantic value
|
||||||
|
@ -1155,8 +1155,8 @@ static void yy_destructor(
|
||||||
YYCODETYPE yymajor, /* Type code for object to destroy */
|
YYCODETYPE yymajor, /* Type code for object to destroy */
|
||||||
YYMINORTYPE *yypminor /* The object to be destroyed */
|
YYMINORTYPE *yypminor /* The object to be destroyed */
|
||||||
){
|
){
|
||||||
NewParseARG_FETCH
|
ParseARG_FETCH
|
||||||
NewParseCTX_FETCH
|
ParseCTX_FETCH
|
||||||
switch( yymajor ){
|
switch( yymajor ){
|
||||||
/* Here is inserted the actions which take place when a
|
/* Here is inserted the actions which take place when a
|
||||||
** terminal or non-terminal is destroyed. This can happen
|
** terminal or non-terminal is destroyed. This can happen
|
||||||
|
@ -1321,7 +1321,7 @@ static void yy_pop_parser_stack(yyParser *pParser){
|
||||||
/*
|
/*
|
||||||
** Clear all secondary memory allocations from the parser
|
** Clear all secondary memory allocations from the parser
|
||||||
*/
|
*/
|
||||||
void NewParseFinalize(void *p){
|
void ParseFinalize(void *p){
|
||||||
yyParser *pParser = (yyParser*)p;
|
yyParser *pParser = (yyParser*)p;
|
||||||
while( pParser->yytos>pParser->yystack ) yy_pop_parser_stack(pParser);
|
while( pParser->yytos>pParser->yystack ) yy_pop_parser_stack(pParser);
|
||||||
#if YYSTACKDEPTH<=0
|
#if YYSTACKDEPTH<=0
|
||||||
|
@ -1329,7 +1329,7 @@ void NewParseFinalize(void *p){
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NewParse_ENGINEALWAYSONSTACK
|
#ifndef Parse_ENGINEALWAYSONSTACK
|
||||||
/*
|
/*
|
||||||
** Deallocate and destroy a parser. Destructors are called for
|
** Deallocate and destroy a parser. Destructors are called for
|
||||||
** all stack elements before shutting the parser down.
|
** all stack elements before shutting the parser down.
|
||||||
|
@ -1338,23 +1338,23 @@ void NewParseFinalize(void *p){
|
||||||
** is defined in a %include section of the input grammar) then it is
|
** is defined in a %include section of the input grammar) then it is
|
||||||
** assumed that the input pointer is never NULL.
|
** assumed that the input pointer is never NULL.
|
||||||
*/
|
*/
|
||||||
void NewParseFree(
|
void ParseFree(
|
||||||
void *p, /* The parser to be deleted */
|
void *p, /* The parser to be deleted */
|
||||||
void (*freeProc)(void*) /* Function used to reclaim memory */
|
void (*freeProc)(void*) /* Function used to reclaim memory */
|
||||||
){
|
){
|
||||||
#ifndef YYPARSEFREENEVERNULL
|
#ifndef YYPARSEFREENEVERNULL
|
||||||
if( p==0 ) return;
|
if( p==0 ) return;
|
||||||
#endif
|
#endif
|
||||||
NewParseFinalize(p);
|
ParseFinalize(p);
|
||||||
(*freeProc)(p);
|
(*freeProc)(p);
|
||||||
}
|
}
|
||||||
#endif /* NewParse_ENGINEALWAYSONSTACK */
|
#endif /* Parse_ENGINEALWAYSONSTACK */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Return the peak depth of the stack for a parser.
|
** Return the peak depth of the stack for a parser.
|
||||||
*/
|
*/
|
||||||
#ifdef YYTRACKMAXSTACKDEPTH
|
#ifdef YYTRACKMAXSTACKDEPTH
|
||||||
int NewParseStackPeak(void *p){
|
int ParseStackPeak(void *p){
|
||||||
yyParser *pParser = (yyParser*)p;
|
yyParser *pParser = (yyParser*)p;
|
||||||
return pParser->yyhwm;
|
return pParser->yyhwm;
|
||||||
}
|
}
|
||||||
|
@ -1378,7 +1378,7 @@ static unsigned char yycoverage[YYNSTATE][YYNTOKEN];
|
||||||
** Return the number of missed state/lookahead combinations.
|
** Return the number of missed state/lookahead combinations.
|
||||||
*/
|
*/
|
||||||
#if defined(YYCOVERAGE)
|
#if defined(YYCOVERAGE)
|
||||||
int NewParseCoverage(FILE *out){
|
int ParseCoverage(FILE *out){
|
||||||
int stateno, iLookAhead, i;
|
int stateno, iLookAhead, i;
|
||||||
int nMissed = 0;
|
int nMissed = 0;
|
||||||
for(stateno=0; stateno<YYNSTATE; stateno++){
|
for(stateno=0; stateno<YYNSTATE; stateno++){
|
||||||
|
@ -1500,8 +1500,8 @@ static YYACTIONTYPE yy_find_reduce_action(
|
||||||
** The following routine is called if the stack overflows.
|
** The following routine is called if the stack overflows.
|
||||||
*/
|
*/
|
||||||
static void yyStackOverflow(yyParser *yypParser){
|
static void yyStackOverflow(yyParser *yypParser){
|
||||||
NewParseARG_FETCH
|
ParseARG_FETCH
|
||||||
NewParseCTX_FETCH
|
ParseCTX_FETCH
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if( yyTraceFILE ){
|
if( yyTraceFILE ){
|
||||||
fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
|
fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
|
||||||
|
@ -1512,8 +1512,8 @@ static void yyStackOverflow(yyParser *yypParser){
|
||||||
** stack every overflows */
|
** stack every overflows */
|
||||||
/******** Begin %stack_overflow code ******************************************/
|
/******** Begin %stack_overflow code ******************************************/
|
||||||
/******** End %stack_overflow code ********************************************/
|
/******** End %stack_overflow code ********************************************/
|
||||||
NewParseARG_STORE /* Suppress warning about unused %extra_argument var */
|
ParseARG_STORE /* Suppress warning about unused %extra_argument var */
|
||||||
NewParseCTX_STORE
|
ParseCTX_STORE
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1544,7 +1544,7 @@ static void yy_shift(
|
||||||
yyParser *yypParser, /* The parser to be shifted */
|
yyParser *yypParser, /* The parser to be shifted */
|
||||||
YYACTIONTYPE yyNewState, /* The new state to shift in */
|
YYACTIONTYPE yyNewState, /* The new state to shift in */
|
||||||
YYCODETYPE yyMajor, /* The major token to shift in */
|
YYCODETYPE yyMajor, /* The major token to shift in */
|
||||||
NewParseTOKENTYPE yyMinor /* The minor token to shift in */
|
ParseTOKENTYPE yyMinor /* The minor token to shift in */
|
||||||
){
|
){
|
||||||
yyStackEntry *yytos;
|
yyStackEntry *yytos;
|
||||||
yypParser->yytos++;
|
yypParser->yytos++;
|
||||||
|
@ -1840,14 +1840,14 @@ static YYACTIONTYPE yy_reduce(
|
||||||
yyParser *yypParser, /* The parser */
|
yyParser *yypParser, /* The parser */
|
||||||
unsigned int yyruleno, /* Number of the rule by which to reduce */
|
unsigned int yyruleno, /* Number of the rule by which to reduce */
|
||||||
int yyLookahead, /* Lookahead token, or YYNOCODE if none */
|
int yyLookahead, /* Lookahead token, or YYNOCODE if none */
|
||||||
NewParseTOKENTYPE yyLookaheadToken /* Value of the lookahead token */
|
ParseTOKENTYPE yyLookaheadToken /* Value of the lookahead token */
|
||||||
NewParseCTX_PDECL /* %extra_context */
|
ParseCTX_PDECL /* %extra_context */
|
||||||
){
|
){
|
||||||
int yygoto; /* The next state */
|
int yygoto; /* The next state */
|
||||||
YYACTIONTYPE yyact; /* The next action */
|
YYACTIONTYPE yyact; /* The next action */
|
||||||
yyStackEntry *yymsp; /* The top of the parser's stack */
|
yyStackEntry *yymsp; /* The top of the parser's stack */
|
||||||
int yysize; /* Amount to pop the stack */
|
int yysize; /* Amount to pop the stack */
|
||||||
NewParseARG_FETCH
|
ParseARG_FETCH
|
||||||
(void)yyLookahead;
|
(void)yyLookahead;
|
||||||
(void)yyLookaheadToken;
|
(void)yyLookaheadToken;
|
||||||
yymsp = yypParser->yytos;
|
yymsp = yypParser->yytos;
|
||||||
|
@ -2680,8 +2680,8 @@ static YYACTIONTYPE yy_reduce(
|
||||||
static void yy_parse_failed(
|
static void yy_parse_failed(
|
||||||
yyParser *yypParser /* The parser */
|
yyParser *yypParser /* The parser */
|
||||||
){
|
){
|
||||||
NewParseARG_FETCH
|
ParseARG_FETCH
|
||||||
NewParseCTX_FETCH
|
ParseCTX_FETCH
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if( yyTraceFILE ){
|
if( yyTraceFILE ){
|
||||||
fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
|
fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
|
||||||
|
@ -2692,8 +2692,8 @@ static void yy_parse_failed(
|
||||||
** parser fails */
|
** parser fails */
|
||||||
/************ Begin %parse_failure code ***************************************/
|
/************ Begin %parse_failure code ***************************************/
|
||||||
/************ End %parse_failure code *****************************************/
|
/************ End %parse_failure code *****************************************/
|
||||||
NewParseARG_STORE /* Suppress warning about unused %extra_argument variable */
|
ParseARG_STORE /* Suppress warning about unused %extra_argument variable */
|
||||||
NewParseCTX_STORE
|
ParseCTX_STORE
|
||||||
}
|
}
|
||||||
#endif /* YYNOERRORRECOVERY */
|
#endif /* YYNOERRORRECOVERY */
|
||||||
|
|
||||||
|
@ -2703,10 +2703,10 @@ static void yy_parse_failed(
|
||||||
static void yy_syntax_error(
|
static void yy_syntax_error(
|
||||||
yyParser *yypParser, /* The parser */
|
yyParser *yypParser, /* The parser */
|
||||||
int yymajor, /* The major type of the error token */
|
int yymajor, /* The major type of the error token */
|
||||||
NewParseTOKENTYPE yyminor /* The minor type of the error token */
|
ParseTOKENTYPE yyminor /* The minor type of the error token */
|
||||||
){
|
){
|
||||||
NewParseARG_FETCH
|
ParseARG_FETCH
|
||||||
NewParseCTX_FETCH
|
ParseCTX_FETCH
|
||||||
#define TOKEN yyminor
|
#define TOKEN yyminor
|
||||||
/************ Begin %syntax_error code ****************************************/
|
/************ Begin %syntax_error code ****************************************/
|
||||||
|
|
||||||
|
@ -2717,8 +2717,8 @@ static void yy_syntax_error(
|
||||||
}
|
}
|
||||||
pCxt->valid = false;
|
pCxt->valid = false;
|
||||||
/************ End %syntax_error code ******************************************/
|
/************ End %syntax_error code ******************************************/
|
||||||
NewParseARG_STORE /* Suppress warning about unused %extra_argument variable */
|
ParseARG_STORE /* Suppress warning about unused %extra_argument variable */
|
||||||
NewParseCTX_STORE
|
ParseCTX_STORE
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2727,8 +2727,8 @@ static void yy_syntax_error(
|
||||||
static void yy_accept(
|
static void yy_accept(
|
||||||
yyParser *yypParser /* The parser */
|
yyParser *yypParser /* The parser */
|
||||||
){
|
){
|
||||||
NewParseARG_FETCH
|
ParseARG_FETCH
|
||||||
NewParseCTX_FETCH
|
ParseCTX_FETCH
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if( yyTraceFILE ){
|
if( yyTraceFILE ){
|
||||||
fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
|
fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
|
||||||
|
@ -2742,13 +2742,13 @@ static void yy_accept(
|
||||||
** parser accepts */
|
** parser accepts */
|
||||||
/*********** Begin %parse_accept code *****************************************/
|
/*********** Begin %parse_accept code *****************************************/
|
||||||
/*********** End %parse_accept code *******************************************/
|
/*********** End %parse_accept code *******************************************/
|
||||||
NewParseARG_STORE /* Suppress warning about unused %extra_argument variable */
|
ParseARG_STORE /* Suppress warning about unused %extra_argument variable */
|
||||||
NewParseCTX_STORE
|
ParseCTX_STORE
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The main parser program.
|
/* The main parser program.
|
||||||
** The first argument is a pointer to a structure obtained from
|
** The first argument is a pointer to a structure obtained from
|
||||||
** "NewParseAlloc" which describes the current state of the parser.
|
** "ParseAlloc" which describes the current state of the parser.
|
||||||
** The second argument is the major token number. The third is
|
** The second argument is the major token number. The third is
|
||||||
** the minor token. The fourth optional argument is whatever the
|
** the minor token. The fourth optional argument is whatever the
|
||||||
** user wants (and specified in the grammar) and is available for
|
** user wants (and specified in the grammar) and is available for
|
||||||
|
@ -2765,11 +2765,11 @@ static void yy_accept(
|
||||||
** Outputs:
|
** Outputs:
|
||||||
** None.
|
** None.
|
||||||
*/
|
*/
|
||||||
void NewParse(
|
void Parse(
|
||||||
void *yyp, /* The parser */
|
void *yyp, /* The parser */
|
||||||
int yymajor, /* The major token code number */
|
int yymajor, /* The major token code number */
|
||||||
NewParseTOKENTYPE yyminor /* The value for the token */
|
ParseTOKENTYPE yyminor /* The value for the token */
|
||||||
NewParseARG_PDECL /* Optional %extra_argument parameter */
|
ParseARG_PDECL /* Optional %extra_argument parameter */
|
||||||
){
|
){
|
||||||
YYMINORTYPE yyminorunion;
|
YYMINORTYPE yyminorunion;
|
||||||
YYACTIONTYPE yyact; /* The parser action. */
|
YYACTIONTYPE yyact; /* The parser action. */
|
||||||
|
@ -2780,8 +2780,8 @@ void NewParse(
|
||||||
int yyerrorhit = 0; /* True if yymajor has invoked an error */
|
int yyerrorhit = 0; /* True if yymajor has invoked an error */
|
||||||
#endif
|
#endif
|
||||||
yyParser *yypParser = (yyParser*)yyp; /* The parser */
|
yyParser *yypParser = (yyParser*)yyp; /* The parser */
|
||||||
NewParseCTX_FETCH
|
ParseCTX_FETCH
|
||||||
NewParseARG_STORE
|
ParseARG_STORE
|
||||||
|
|
||||||
assert( yypParser->yytos!=0 );
|
assert( yypParser->yytos!=0 );
|
||||||
#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
|
#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
|
||||||
|
@ -2806,7 +2806,7 @@ void NewParse(
|
||||||
yyact = yy_find_shift_action((YYCODETYPE)yymajor,yyact);
|
yyact = yy_find_shift_action((YYCODETYPE)yymajor,yyact);
|
||||||
if( yyact >= YY_MIN_REDUCE ){
|
if( yyact >= YY_MIN_REDUCE ){
|
||||||
yyact = yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor,
|
yyact = yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor,
|
||||||
yyminor NewParseCTX_PARAM);
|
yyminor ParseCTX_PARAM);
|
||||||
}else if( yyact <= YY_MAX_SHIFTREDUCE ){
|
}else if( yyact <= YY_MAX_SHIFTREDUCE ){
|
||||||
yy_shift(yypParser,yyact,(YYCODETYPE)yymajor,yyminor);
|
yy_shift(yypParser,yyact,(YYCODETYPE)yymajor,yyminor);
|
||||||
#ifndef YYNOERRORRECOVERY
|
#ifndef YYNOERRORRECOVERY
|
||||||
|
@ -2939,7 +2939,7 @@ void NewParse(
|
||||||
** Return the fallback token corresponding to canonical token iToken, or
|
** Return the fallback token corresponding to canonical token iToken, or
|
||||||
** 0 if iToken has no fallback.
|
** 0 if iToken has no fallback.
|
||||||
*/
|
*/
|
||||||
int NewParseFallback(int iToken){
|
int ParseFallback(int iToken){
|
||||||
#ifdef YYFALLBACK
|
#ifdef YYFALLBACK
|
||||||
if( iToken<(int)(sizeof(yyFallback)/sizeof(yyFallback[0])) ){
|
if( iToken<(int)(sizeof(yyFallback)/sizeof(yyFallback[0])) ){
|
||||||
return yyFallback[iToken];
|
return yyFallback[iToken];
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "parserInt.h"
|
#include "parInt.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace testing;
|
using namespace testing;
|
|
@ -15,8 +15,7 @@
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "insertParser.h"
|
#include "parInt.h"
|
||||||
// #include "mockCatalog.h"
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace testing;
|
using namespace testing;
|
|
@ -1,730 +0,0 @@
|
||||||
#if 0
|
|
||||||
|
|
||||||
#include <gtest/gtest.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 "os.h"
|
|
||||||
|
|
||||||
#include "taos.h"
|
|
||||||
#include "tvariant.h"
|
|
||||||
#include "tdef.h"
|
|
||||||
#include "ttoken.h"
|
|
||||||
#include "astGenerator.h"
|
|
||||||
#include "parserUtil.h"
|
|
||||||
#include "parserInt.h"
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
int32_t testValidateName(char* name) {
|
|
||||||
SToken token = {0};
|
|
||||||
token.z = name;
|
|
||||||
token.n = strlen(name);
|
|
||||||
token.type = 0;
|
|
||||||
|
|
||||||
tGetToken(name, &token.type);
|
|
||||||
return parserValidateIdToken(&token);
|
|
||||||
}
|
|
||||||
|
|
||||||
SToken createToken(char* s) {
|
|
||||||
SToken t = {0};
|
|
||||||
|
|
||||||
t.type = TK_STRING;
|
|
||||||
t.z = s;
|
|
||||||
t.n = strlen(s);
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
static void _init_tvariant_bool(SVariant* t) {
|
|
||||||
t->i = TSDB_FALSE;
|
|
||||||
t->nType = TSDB_DATA_TYPE_BOOL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void _init_tvariant_tinyint(SVariant* t) {
|
|
||||||
t->i = -27;
|
|
||||||
t->nType = TSDB_DATA_TYPE_TINYINT;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void _init_tvariant_int(SVariant* t) {
|
|
||||||
t->i = -23997659;
|
|
||||||
t->nType = TSDB_DATA_TYPE_INT;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void _init_tvariant_bigint(SVariant* t) {
|
|
||||||
t->i = -3333333333333;
|
|
||||||
t->nType = TSDB_DATA_TYPE_BIGINT;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void _init_tvariant_float(SVariant* t) {
|
|
||||||
t->d = -8991212199.8987878776;
|
|
||||||
t->nType = TSDB_DATA_TYPE_FLOAT;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void _init_tvariant_binary(SVariant* t) {
|
|
||||||
taosVariantDestroy(t);
|
|
||||||
|
|
||||||
t->pz = (char*)calloc(1, 20); //"2e3");
|
|
||||||
t->nType = TSDB_DATA_TYPE_BINARY;
|
|
||||||
strcpy(t->pz, "2e5");
|
|
||||||
t->nLen = strlen(t->pz);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void _init_tvariant_nchar(SVariant* t) {
|
|
||||||
taosVariantDestroy(t);
|
|
||||||
|
|
||||||
t->wpz = (wchar_t*)calloc(1, 20 * TSDB_NCHAR_SIZE);
|
|
||||||
t->nType = TSDB_DATA_TYPE_NCHAR;
|
|
||||||
wcscpy(t->wpz, L"-2000000.8765");
|
|
||||||
t->nLen = twcslen(t->wpz);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(testCase, validateToken_test) {
|
|
||||||
char t01[] = "abc";
|
|
||||||
EXPECT_EQ(testValidateName(t01), TSDB_CODE_SUCCESS);
|
|
||||||
|
|
||||||
char t110[] = "`1233abc.911`";
|
|
||||||
EXPECT_EQ(testValidateName(t110), TSDB_CODE_SUCCESS);
|
|
||||||
|
|
||||||
char t02[] = "'abc'";
|
|
||||||
EXPECT_EQ(testValidateName(t02), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t1[] = "abc.def";
|
|
||||||
EXPECT_EQ(testValidateName(t1), TSDB_CODE_SUCCESS);
|
|
||||||
printf("%s\n", t1);
|
|
||||||
|
|
||||||
char t98[] = "abc.DeF";
|
|
||||||
EXPECT_EQ(testValidateName(t98), TSDB_CODE_SUCCESS);
|
|
||||||
EXPECT_STREQ(t98, "abc.def");
|
|
||||||
printf("%s\n", t98);
|
|
||||||
|
|
||||||
char t97[] = "257.abc";
|
|
||||||
EXPECT_EQ(testValidateName(t97), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
printf("%s\n", t97);
|
|
||||||
|
|
||||||
char t96[] = "_257.aBc";
|
|
||||||
EXPECT_EQ(testValidateName(t96), TSDB_CODE_SUCCESS);
|
|
||||||
EXPECT_STREQ(t96, "_257.abc");
|
|
||||||
printf("%s\n", t96);
|
|
||||||
|
|
||||||
char t99[] = "abc . def";
|
|
||||||
EXPECT_EQ(testValidateName(t99), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
printf("%s\n", t99);
|
|
||||||
|
|
||||||
char t2[] = "'abc.def'";
|
|
||||||
EXPECT_EQ(testValidateName(t2), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
printf("%s\n", t2);
|
|
||||||
|
|
||||||
char t3[] = "'abc'.def";
|
|
||||||
EXPECT_EQ(testValidateName(t3), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
printf("%s\n", t3);
|
|
||||||
|
|
||||||
char t4[] = "'abc'.'def'";
|
|
||||||
EXPECT_EQ(testValidateName(t4), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t5[] = "table.'def'";
|
|
||||||
EXPECT_EQ(testValidateName(t5), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t6[] = "'table'.'def'";
|
|
||||||
EXPECT_EQ(testValidateName(t6), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t7[] = "'_ab1234'.'def'";
|
|
||||||
EXPECT_EQ(testValidateName(t7), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
printf("%s\n", t7);
|
|
||||||
|
|
||||||
char t8[] = "'_ab&^%1234'.'def'";
|
|
||||||
EXPECT_EQ(testValidateName(t8), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t9[] = "'_123'.'gtest中文'";
|
|
||||||
EXPECT_EQ(testValidateName(t9), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t10[] = "abc.'gtest中文'";
|
|
||||||
EXPECT_EQ(testValidateName(t10), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t10_1[] = "abc.'中文gtest'";
|
|
||||||
EXPECT_EQ(testValidateName(t10_1), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t11[] = "'192.168.0.1'.abc";
|
|
||||||
EXPECT_EQ(testValidateName(t11), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t12[] = "192.168.0.1.abc";
|
|
||||||
EXPECT_EQ(testValidateName(t12), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t13[] = "abc.";
|
|
||||||
EXPECT_EQ(testValidateName(t13), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t14[] = ".abc";
|
|
||||||
EXPECT_EQ(testValidateName(t14), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t15[] = ".'abc'";
|
|
||||||
EXPECT_EQ(testValidateName(t15), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t16[] = ".abc'";
|
|
||||||
EXPECT_EQ(testValidateName(t16), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t17[] = "123a.\"abc\"";
|
|
||||||
EXPECT_EQ(testValidateName(t17), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
printf("%s\n", t17);
|
|
||||||
|
|
||||||
char t18[] = "a.\"abc\"";
|
|
||||||
EXPECT_EQ(testValidateName(t18), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
printf("%s\n", t18);
|
|
||||||
|
|
||||||
char t19[] = "'_ab1234'.'def'.'ab123'";
|
|
||||||
EXPECT_EQ(testValidateName(t19), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t20[] = "'_ab1234*&^'";
|
|
||||||
EXPECT_EQ(testValidateName(t20), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t21[] = "'1234_abc'";
|
|
||||||
EXPECT_EQ(testValidateName(t21), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
// =======Containing capital letters=================
|
|
||||||
char t30[] = "ABC";
|
|
||||||
EXPECT_EQ(testValidateName(t30), TSDB_CODE_SUCCESS);
|
|
||||||
|
|
||||||
char t31[] = "'ABC'";
|
|
||||||
EXPECT_EQ(testValidateName(t31), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t32[] = "ABC.def";
|
|
||||||
EXPECT_EQ(testValidateName(t32), TSDB_CODE_SUCCESS);
|
|
||||||
|
|
||||||
char t33[] = "'ABC.def";
|
|
||||||
EXPECT_EQ(testValidateName(t33), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t33_0[] = "abc.DEF'";
|
|
||||||
EXPECT_EQ(testValidateName(t33_0), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t34[] = "'ABC.def'";
|
|
||||||
// int32_t tmp0 = testValidateName(t34);
|
|
||||||
EXPECT_EQ(testValidateName(t34), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t35[] = "'ABC'.def";
|
|
||||||
EXPECT_EQ(testValidateName(t35), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t36[] = "ABC.DEF";
|
|
||||||
EXPECT_EQ(testValidateName(t36), TSDB_CODE_SUCCESS);
|
|
||||||
|
|
||||||
char t37[] = "abc.DEF";
|
|
||||||
EXPECT_EQ(testValidateName(t37), TSDB_CODE_SUCCESS);
|
|
||||||
|
|
||||||
char t37_1[] = "abc._123DEF";
|
|
||||||
EXPECT_EQ(testValidateName(t37_1), TSDB_CODE_SUCCESS);
|
|
||||||
|
|
||||||
char t38[] = "'abc'.\"DEF\"";
|
|
||||||
EXPECT_EQ(testValidateName(t38), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
// do not use key words
|
|
||||||
char t39[] = "table.'DEF'";
|
|
||||||
EXPECT_EQ(testValidateName(t39), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t40[] = "'table'.'DEF'";
|
|
||||||
EXPECT_EQ(testValidateName(t40), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t41[] = "'_abXYZ1234'.'deFF'";
|
|
||||||
EXPECT_EQ(testValidateName(t41), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t42[] = "'_abDEF&^%1234'.'DIef'";
|
|
||||||
EXPECT_EQ(testValidateName(t42), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t43[] = "'_123'.'Gtest中文'";
|
|
||||||
EXPECT_EQ(testValidateName(t43), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t44[] = "'aABC'.'Gtest中文'";
|
|
||||||
EXPECT_EQ(testValidateName(t44), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t45[] = "'ABC'.";
|
|
||||||
EXPECT_EQ(testValidateName(t45), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t46[] = ".'ABC'";
|
|
||||||
EXPECT_EQ(testValidateName(t46), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t47[] = "a.\"aTWc\"";
|
|
||||||
EXPECT_EQ(testValidateName(t47), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
// ================has space =================
|
|
||||||
char t60[] = " ABC ";
|
|
||||||
EXPECT_EQ(testValidateName(t60), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t60_1[] = " ABC ";
|
|
||||||
EXPECT_EQ(testValidateName(t60_1), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t61[] = "' ABC '";
|
|
||||||
EXPECT_EQ(testValidateName(t61), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t61_1[] = "' ABC '";
|
|
||||||
EXPECT_EQ(testValidateName(t61_1), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t62[] = " ABC . def ";
|
|
||||||
EXPECT_EQ(testValidateName(t62), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t63[] = "' ABC . def ";
|
|
||||||
EXPECT_EQ(testValidateName(t63), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t63_0[] = " abc . DEF ' ";
|
|
||||||
EXPECT_EQ(testValidateName(t63_0), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t64[] = " ' ABC . def ' ";
|
|
||||||
// int32_t tmp1 = testValidateName(t64);
|
|
||||||
EXPECT_EQ(testValidateName(t64), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t65[] = " ' ABC '. def ";
|
|
||||||
EXPECT_EQ(testValidateName(t65), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t66[] = "' ABC '.' DEF '";
|
|
||||||
EXPECT_EQ(testValidateName(t66), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t67[] = "abc . ' DEF '";
|
|
||||||
EXPECT_EQ(testValidateName(t67), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t68[] = "' abc '.' DEF '";
|
|
||||||
EXPECT_EQ(testValidateName(t68), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
// do not use key words
|
|
||||||
char t69[] = "table.'DEF'";
|
|
||||||
EXPECT_EQ(testValidateName(t69), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t70[] = "'table'.'DEF'";
|
|
||||||
EXPECT_EQ(testValidateName(t70), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t71[] = "'_abXYZ1234 '.' deFF '";
|
|
||||||
EXPECT_EQ(testValidateName(t71), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t72[] = "'_abDEF&^%1234'.' DIef'";
|
|
||||||
EXPECT_EQ(testValidateName(t72), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t73[] = "'_123'.' Gtest中文'";
|
|
||||||
EXPECT_EQ(testValidateName(t73), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t74[] = "' aABC'.'Gtest中文'";
|
|
||||||
EXPECT_EQ(testValidateName(t74), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t75[] = "' ABC '.";
|
|
||||||
EXPECT_EQ(testValidateName(t75), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t76[] = ".' ABC'";
|
|
||||||
EXPECT_EQ(testValidateName(t76), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t77[] = " a . \"aTWc\" ";
|
|
||||||
EXPECT_EQ(testValidateName(t77), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t78[] = " a.\"aTWc \"";
|
|
||||||
EXPECT_EQ(testValidateName(t78), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
// ===============muti string by space ===================
|
|
||||||
// There's no such case.
|
|
||||||
// char t160[] = "A BC";
|
|
||||||
// EXPECT_EQ(testValidateName(t160), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
// printf("end:%s\n", t160);
|
|
||||||
|
|
||||||
// There's no such case.
|
|
||||||
// char t161[] = "' A BC '";
|
|
||||||
// EXPECT_EQ(testValidateName(t161), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t162[] = " AB C . de f ";
|
|
||||||
EXPECT_EQ(testValidateName(t162), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t163[] = "' AB C . de f ";
|
|
||||||
EXPECT_EQ(testValidateName(t163), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t163_0[] = " ab c . DE F ' ";
|
|
||||||
EXPECT_EQ(testValidateName(t163_0), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t164[] = " ' AB C . de f ' ";
|
|
||||||
// int32_t tmp2 = testValidateName(t164);
|
|
||||||
EXPECT_EQ(testValidateName(t164), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t165[] = " ' A BC '. de f ";
|
|
||||||
EXPECT_EQ(testValidateName(t165), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t166[] = "' AB C '.' DE F '";
|
|
||||||
EXPECT_EQ(testValidateName(t166), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t167[] = "ab c . ' D EF '";
|
|
||||||
EXPECT_EQ(testValidateName(t167), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
|
|
||||||
char t168[] = "' a bc '.' DE F '";
|
|
||||||
EXPECT_EQ(testValidateName(t168), TSDB_CODE_TSC_INVALID_OPERATION);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
TEST(testCase, tvariant_convert) {
|
|
||||||
// 1. bool data to all other data types
|
|
||||||
SVariant t = {0};
|
|
||||||
_init_tvariant_bool(&t);
|
|
||||||
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BOOL), 0);
|
|
||||||
EXPECT_EQ(t.i, 0);
|
|
||||||
|
|
||||||
_init_tvariant_bool(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_TINYINT), 0);
|
|
||||||
EXPECT_EQ(t.i, 0);
|
|
||||||
|
|
||||||
_init_tvariant_bool(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_SMALLINT), 0);
|
|
||||||
EXPECT_EQ(t.i, 0);
|
|
||||||
|
|
||||||
_init_tvariant_bool(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BIGINT), 0);
|
|
||||||
EXPECT_EQ(t.i, 0);
|
|
||||||
|
|
||||||
_init_tvariant_bool(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_FLOAT), 0);
|
|
||||||
EXPECT_EQ(t.d, 0);
|
|
||||||
|
|
||||||
_init_tvariant_bool(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_DOUBLE), 0);
|
|
||||||
EXPECT_EQ(t.d, 0);
|
|
||||||
|
|
||||||
_init_tvariant_bool(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BINARY), 0);
|
|
||||||
EXPECT_STREQ(t.pz, "FALSE");
|
|
||||||
taosVariantDestroy(&t);
|
|
||||||
|
|
||||||
_init_tvariant_bool(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_NCHAR), 0);
|
|
||||||
EXPECT_STREQ(t.wpz, L"FALSE");
|
|
||||||
taosVariantDestroy(&t);
|
|
||||||
|
|
||||||
// 2. tinyint to other data types
|
|
||||||
_init_tvariant_tinyint(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BOOL), 0);
|
|
||||||
EXPECT_EQ(t.i, 1);
|
|
||||||
|
|
||||||
_init_tvariant_tinyint(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_TINYINT), 0);
|
|
||||||
EXPECT_EQ(t.i, -27);
|
|
||||||
|
|
||||||
_init_tvariant_tinyint(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_SMALLINT), 0);
|
|
||||||
EXPECT_EQ(t.i, -27);
|
|
||||||
|
|
||||||
_init_tvariant_tinyint(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_INT), 0);
|
|
||||||
EXPECT_EQ(t.i, -27);
|
|
||||||
|
|
||||||
_init_tvariant_tinyint(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BIGINT), 0);
|
|
||||||
EXPECT_EQ(t.i, -27);
|
|
||||||
|
|
||||||
_init_tvariant_tinyint(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_FLOAT), 0);
|
|
||||||
EXPECT_EQ(t.d, -27);
|
|
||||||
|
|
||||||
_init_tvariant_tinyint(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_DOUBLE), 0);
|
|
||||||
EXPECT_EQ(t.d, -27);
|
|
||||||
|
|
||||||
_init_tvariant_tinyint(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BINARY), 0);
|
|
||||||
EXPECT_STREQ(t.pz, "-27");
|
|
||||||
taosVariantDestroy(&t);
|
|
||||||
|
|
||||||
_init_tvariant_tinyint(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_NCHAR), 0);
|
|
||||||
EXPECT_STREQ(t.wpz, L"-27");
|
|
||||||
taosVariantDestroy(&t);
|
|
||||||
|
|
||||||
// 3. int to other data
|
|
||||||
// types//////////////////////////////////////////////////////////////////
|
|
||||||
_init_tvariant_int(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BOOL), 0);
|
|
||||||
EXPECT_EQ(t.i, 1);
|
|
||||||
|
|
||||||
_init_tvariant_int(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_TINYINT), 0);
|
|
||||||
|
|
||||||
_init_tvariant_int(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_SMALLINT), 0);
|
|
||||||
|
|
||||||
_init_tvariant_int(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_INT), 0);
|
|
||||||
EXPECT_EQ(t.i, -23997659);
|
|
||||||
|
|
||||||
_init_tvariant_int(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BIGINT), 0);
|
|
||||||
EXPECT_EQ(t.i, -23997659);
|
|
||||||
|
|
||||||
_init_tvariant_int(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_FLOAT), 0);
|
|
||||||
EXPECT_EQ(t.d, -23997659);
|
|
||||||
|
|
||||||
_init_tvariant_int(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_DOUBLE), 0);
|
|
||||||
EXPECT_EQ(t.d, -23997659);
|
|
||||||
|
|
||||||
_init_tvariant_int(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BINARY), 0);
|
|
||||||
EXPECT_STREQ(t.pz, "-23997659");
|
|
||||||
taosVariantDestroy(&t);
|
|
||||||
|
|
||||||
_init_tvariant_int(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_NCHAR), 0);
|
|
||||||
EXPECT_STREQ(t.wpz, L"-23997659");
|
|
||||||
taosVariantDestroy(&t);
|
|
||||||
|
|
||||||
// 4. bigint to other data
|
|
||||||
// type//////////////////////////////////////////////////////////////////////////////
|
|
||||||
_init_tvariant_bigint(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BOOL), 0);
|
|
||||||
EXPECT_EQ(t.i, 1);
|
|
||||||
|
|
||||||
_init_tvariant_bigint(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_TINYINT), 0);
|
|
||||||
|
|
||||||
_init_tvariant_bigint(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_SMALLINT), 0);
|
|
||||||
|
|
||||||
_init_tvariant_bigint(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_INT), 0);
|
|
||||||
|
|
||||||
_init_tvariant_bigint(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BIGINT), 0);
|
|
||||||
EXPECT_EQ(t.i, -3333333333333);
|
|
||||||
|
|
||||||
_init_tvariant_bigint(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_FLOAT), 0);
|
|
||||||
EXPECT_EQ(t.d, -3333333333333);
|
|
||||||
|
|
||||||
_init_tvariant_bigint(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_DOUBLE), 0);
|
|
||||||
EXPECT_EQ(t.d, -3333333333333);
|
|
||||||
|
|
||||||
_init_tvariant_bigint(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BINARY), 0);
|
|
||||||
EXPECT_STREQ(t.pz, "-3333333333333");
|
|
||||||
taosVariantDestroy(&t);
|
|
||||||
|
|
||||||
_init_tvariant_bigint(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_NCHAR), 0);
|
|
||||||
EXPECT_STREQ(t.wpz, L"-3333333333333");
|
|
||||||
taosVariantDestroy(&t);
|
|
||||||
|
|
||||||
// 5. float to other data
|
|
||||||
// types////////////////////////////////////////////////////////////////////////
|
|
||||||
_init_tvariant_float(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BOOL), 0);
|
|
||||||
EXPECT_EQ(t.i, 1);
|
|
||||||
|
|
||||||
_init_tvariant_float(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BIGINT), 0);
|
|
||||||
EXPECT_EQ(t.i, -8991212199);
|
|
||||||
|
|
||||||
_init_tvariant_float(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_FLOAT), 0);
|
|
||||||
EXPECT_DOUBLE_EQ(t.d, -8991212199.8987885);
|
|
||||||
|
|
||||||
_init_tvariant_float(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_DOUBLE), 0);
|
|
||||||
EXPECT_DOUBLE_EQ(t.d, -8991212199.8987885);
|
|
||||||
|
|
||||||
_init_tvariant_float(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BINARY), 0);
|
|
||||||
EXPECT_STREQ(t.pz, "-8991212199.898788");
|
|
||||||
taosVariantDestroy(&t);
|
|
||||||
|
|
||||||
_init_tvariant_float(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_NCHAR), 0);
|
|
||||||
EXPECT_STREQ(t.wpz, L"-8991212199.898788");
|
|
||||||
taosVariantDestroy(&t);
|
|
||||||
|
|
||||||
// 6. binary to other data types
|
|
||||||
// //////////////////////////////////////////////////////////////////
|
|
||||||
t.pz = "true";
|
|
||||||
t.nLen = strlen(t.pz);
|
|
||||||
t.nType = TSDB_DATA_TYPE_BINARY;
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BOOL), 0);
|
|
||||||
EXPECT_EQ(t.i, 1);
|
|
||||||
|
|
||||||
_init_tvariant_binary(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BOOL), -1);
|
|
||||||
|
|
||||||
_init_tvariant_binary(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BIGINT), 0);
|
|
||||||
EXPECT_EQ(t.i, 200000);
|
|
||||||
|
|
||||||
_init_tvariant_binary(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_FLOAT), 0);
|
|
||||||
EXPECT_DOUBLE_EQ(t.d, 200000);
|
|
||||||
|
|
||||||
_init_tvariant_binary(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_DOUBLE), 0);
|
|
||||||
EXPECT_DOUBLE_EQ(t.d, 200000);
|
|
||||||
|
|
||||||
_init_tvariant_binary(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BINARY), 0);
|
|
||||||
EXPECT_STREQ(t.pz, "2e5");
|
|
||||||
taosVariantDestroy(&t);
|
|
||||||
|
|
||||||
_init_tvariant_binary(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_NCHAR), 0);
|
|
||||||
EXPECT_STREQ(t.wpz, L"2e5");
|
|
||||||
taosVariantDestroy(&t);
|
|
||||||
|
|
||||||
// 7. nchar to other data types
|
|
||||||
// //////////////////////////////////////////////////////////////////
|
|
||||||
t.wpz = L"FALSE";
|
|
||||||
t.nLen = wcslen(t.wpz);
|
|
||||||
t.nType = TSDB_DATA_TYPE_NCHAR;
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BOOL), 0);
|
|
||||||
EXPECT_EQ(t.i, 0);
|
|
||||||
|
|
||||||
_init_tvariant_nchar(&t);
|
|
||||||
EXPECT_LE(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BOOL), 0);
|
|
||||||
|
|
||||||
_init_tvariant_nchar(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BIGINT), 0);
|
|
||||||
EXPECT_EQ(t.i, -2000000);
|
|
||||||
|
|
||||||
_init_tvariant_nchar(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_FLOAT), 0);
|
|
||||||
EXPECT_DOUBLE_EQ(t.d, -2000000.8765);
|
|
||||||
|
|
||||||
_init_tvariant_nchar(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_DOUBLE), 0);
|
|
||||||
EXPECT_DOUBLE_EQ(t.d, -2000000.8765);
|
|
||||||
|
|
||||||
_init_tvariant_nchar(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BINARY), 0);
|
|
||||||
EXPECT_STREQ(t.pz, "-2000000.8765");
|
|
||||||
taosVariantDestroy(&t);
|
|
||||||
|
|
||||||
_init_tvariant_nchar(&t);
|
|
||||||
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_NCHAR), 0);
|
|
||||||
EXPECT_STREQ(t.wpz, L"-2000000.8765");
|
|
||||||
taosVariantDestroy(&t);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
TEST(testCase, tGetToken_Test) {
|
|
||||||
char* s = ".123 ";
|
|
||||||
uint32_t type = 0;
|
|
||||||
|
|
||||||
int32_t len = tGetToken(s, &type);
|
|
||||||
EXPECT_EQ(type, TK_FLOAT);
|
|
||||||
EXPECT_EQ(len, strlen(s) - 1);
|
|
||||||
|
|
||||||
char s1[] = "1.123e10 ";
|
|
||||||
len = tGetToken(s1, &type);
|
|
||||||
EXPECT_EQ(type, TK_FLOAT);
|
|
||||||
EXPECT_EQ(len, strlen(s1) - 1);
|
|
||||||
|
|
||||||
char s4[] = "0xff ";
|
|
||||||
len = tGetToken(s4, &type);
|
|
||||||
EXPECT_EQ(type, TK_HEX);
|
|
||||||
EXPECT_EQ(len, strlen(s4) - 1);
|
|
||||||
|
|
||||||
// invalid data type
|
|
||||||
char s2[] = "e10 ";
|
|
||||||
len = tGetToken(s2, &type);
|
|
||||||
EXPECT_FALSE(type == TK_FLOAT);
|
|
||||||
|
|
||||||
char s3[] = "1.1.1.1";
|
|
||||||
len = tGetToken(s3, &type);
|
|
||||||
EXPECT_EQ(type, TK_IPTOKEN);
|
|
||||||
EXPECT_EQ(len, strlen(s3));
|
|
||||||
|
|
||||||
char s5[] = "0x ";
|
|
||||||
len = tGetToken(s5, &type);
|
|
||||||
EXPECT_FALSE(type == TK_HEX);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(testCase, isValidNumber_test) {
|
|
||||||
SToken t1 = createToken("123abc");
|
|
||||||
|
|
||||||
EXPECT_EQ(tGetNumericStringType(&t1), TK_ILLEGAL);
|
|
||||||
|
|
||||||
t1 = createToken("0xabc");
|
|
||||||
EXPECT_EQ(tGetNumericStringType(&t1), TK_HEX);
|
|
||||||
|
|
||||||
t1 = createToken("0b11101");
|
|
||||||
EXPECT_EQ(tGetNumericStringType(&t1), TK_BIN);
|
|
||||||
|
|
||||||
t1 = createToken(".134abc");
|
|
||||||
EXPECT_EQ(tGetNumericStringType(&t1), TK_ILLEGAL);
|
|
||||||
|
|
||||||
t1 = createToken("1e1 ");
|
|
||||||
EXPECT_EQ(tGetNumericStringType(&t1), TK_ILLEGAL);
|
|
||||||
|
|
||||||
t1 = createToken("1+2");
|
|
||||||
EXPECT_EQ(tGetNumericStringType(&t1), TK_ILLEGAL);
|
|
||||||
|
|
||||||
t1 = createToken("-0x123");
|
|
||||||
EXPECT_EQ(tGetNumericStringType(&t1), TK_HEX);
|
|
||||||
|
|
||||||
t1 = createToken("-1");
|
|
||||||
EXPECT_EQ(tGetNumericStringType(&t1), TK_INTEGER);
|
|
||||||
|
|
||||||
t1 = createToken("-0b1110");
|
|
||||||
EXPECT_EQ(tGetNumericStringType(&t1), TK_BIN);
|
|
||||||
|
|
||||||
t1 = createToken("-.234");
|
|
||||||
EXPECT_EQ(tGetNumericStringType(&t1), TK_FLOAT);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(testCase, generateAST_test) {
|
|
||||||
SSqlInfo info = doGenerateAST("select * from t1 where ts < now");
|
|
||||||
ASSERT_EQ(info.valid, true);
|
|
||||||
|
|
||||||
SSqlInfo info1 = doGenerateAST("select * from `t.1abc` where ts<now+2h and col < 20+99");
|
|
||||||
ASSERT_EQ(info1.valid, true);
|
|
||||||
|
|
||||||
char msg[128] = {0};
|
|
||||||
|
|
||||||
SMsgBuf msgBuf = {0};
|
|
||||||
msgBuf.buf = msg;
|
|
||||||
msgBuf.len = 128;
|
|
||||||
|
|
||||||
SSqlNode* pNode = (SSqlNode*) taosArrayGetP(((SArray*)info1.sub.node), 0);
|
|
||||||
int32_t code = evaluateSqlNode(pNode, TSDB_TIME_PRECISION_NANO, &msgBuf);
|
|
||||||
ASSERT_EQ(code, 0);
|
|
||||||
|
|
||||||
SSqlInfo info2 = doGenerateAST("select * from abc where ts<now+2");
|
|
||||||
SSqlNode* pNode2 = (SSqlNode*) taosArrayGetP(((SArray*)info2.sub.node), 0);
|
|
||||||
code = evaluateSqlNode(pNode2, TSDB_TIME_PRECISION_MILLI, &msgBuf);
|
|
||||||
ASSERT_NE(code, 0);
|
|
||||||
|
|
||||||
destroySqlInfo(&info);
|
|
||||||
destroySqlInfo(&info1);
|
|
||||||
destroySqlInfo(&info2);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(testCase, evaluateAST_test) {
|
|
||||||
SSqlInfo info1 = doGenerateAST("select a, b+22 from `t.1abc` where ts<now+2h and `col` < 20 + 99");
|
|
||||||
ASSERT_EQ(info1.valid, true);
|
|
||||||
|
|
||||||
char msg[128] = {0};
|
|
||||||
SMsgBuf msgBuf = {0};
|
|
||||||
msgBuf.buf = msg;
|
|
||||||
msgBuf.len = 128;
|
|
||||||
|
|
||||||
SSqlNode* pNode = (SSqlNode*) taosArrayGetP(((SArray*)info1.sub.node), 0);
|
|
||||||
int32_t code = evaluateSqlNode(pNode, TSDB_TIME_PRECISION_NANO, &msgBuf);
|
|
||||||
ASSERT_EQ(code, 0);
|
|
||||||
destroySqlInfo(&info1);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(testCase, extractMeta_test) {
|
|
||||||
SSqlInfo info1 = doGenerateAST("select a, b+22 from `t.1abc` where ts<now+2h and `col` < 20 + 99");
|
|
||||||
ASSERT_EQ(info1.valid, true);
|
|
||||||
|
|
||||||
char msg[128] = {0};
|
|
||||||
SCatalogReq req = {0};
|
|
||||||
|
|
||||||
SParseContext ctx = {0};
|
|
||||||
ctx.db = "db1";
|
|
||||||
ctx.acctId = 1;
|
|
||||||
int32_t ret = qParserExtractRequestedMetaInfo(&info1, &req, &ctx, msg, 128);
|
|
||||||
ASSERT_EQ(ret, 0);
|
|
||||||
ASSERT_EQ(taosArrayGetSize(req.pTableName), 1);
|
|
||||||
|
|
||||||
qParserCleanupMetaRequestInfo(&req);
|
|
||||||
destroySqlInfo(&info1);
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -13,7 +13,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "plannerInt.h"
|
#include "planInt.h"
|
||||||
|
|
||||||
#include "functionMgt.h"
|
#include "functionMgt.h"
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "plannerInt.h"
|
#include "planInt.h"
|
||||||
|
|
||||||
#include "functionMgt.h"
|
#include "functionMgt.h"
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "plannerInt.h"
|
#include "planInt.h"
|
||||||
|
|
||||||
#define SPLIT_FLAG_MASK(n) (1 << n)
|
#define SPLIT_FLAG_MASK(n) (1 << n)
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
#include "planner.h"
|
#include "planner.h"
|
||||||
|
|
||||||
#include "plannerInt.h"
|
#include "planInt.h"
|
||||||
|
|
||||||
int32_t optimize(SPlanContext* pCxt, SLogicNode* pLogicNode) {
|
int32_t optimize(SPlanContext* pCxt, SLogicNode* pLogicNode) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
#include "plannerInt.h"
|
#include "planInt.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace testing;
|
using namespace testing;
|
||||||
|
|
Loading…
Reference in New Issue