未验证 提交 b33cdb1f 编写于 作者: X xiao-yu-wang 提交者: GitHub

Merge pull request #10089 from taosdata/feature/3.0_wxy

TD-13197 SELECT statement syntax definition
......@@ -209,48 +209,76 @@
#define NEW_TK_OR 1
#define NEW_TK_AND 2
#define NEW_TK_NOT 3
#define NEW_TK_UNION 4
#define NEW_TK_ALL 5
#define NEW_TK_MINUS 6
#define NEW_TK_EXCEPT 7
#define NEW_TK_INTERSECT 8
#define NEW_TK_NK_PLUS 9
#define NEW_TK_NK_MINUS 10
#define NEW_TK_NK_STAR 11
#define NEW_TK_NK_SLASH 12
#define NEW_TK_UNION 3
#define NEW_TK_ALL 4
#define NEW_TK_MINUS 5
#define NEW_TK_EXCEPT 6
#define NEW_TK_INTERSECT 7
#define NEW_TK_NK_PLUS 8
#define NEW_TK_NK_MINUS 9
#define NEW_TK_NK_STAR 10
#define NEW_TK_NK_SLASH 11
#define NEW_TK_NK_REM 12
#define NEW_TK_SHOW 13
#define NEW_TK_DATABASES 14
#define NEW_TK_NK_INTEGER 15
#define NEW_TK_NK_FLOAT 16
#define NEW_TK_NK_STRING 17
#define NEW_TK_NK_BOOL 18
#define NEW_TK_NK_NOW 19
#define NEW_TK_NK_ID 20
#define NEW_TK_NK_QUESTION 21
#define NEW_TK_NK_LP 22
#define NEW_TK_NK_RP 23
#define NEW_TK_NK_DOT 24
#define NEW_TK_FROM 25
#define NEW_TK_NK_COMMA 26
#define NEW_TK_AS 27
#define NEW_TK_JOIN 28
#define NEW_TK_ON 29
#define NEW_TK_INNER 30
#define NEW_TK_SELECT 31
#define NEW_TK_DISTINCT 32
#define NEW_TK_ORDER 33
#define NEW_TK_BY 34
#define NEW_TK_SLIMIT 35
#define NEW_TK_SOFFSET 36
#define NEW_TK_LIMIT 37
#define NEW_TK_OFFSET 38
#define NEW_TK_NK_LR 39
#define NEW_TK_ASC 40
#define NEW_TK_DESC 41
#define NEW_TK_NULLS 42
#define NEW_TK_FIRST 43
#define NEW_TK_LAST 44
#define NEW_TK_TIMESTAMP 19
#define NEW_TK_NK_VARIABLE 20
#define NEW_TK_NK_COMMA 21
#define NEW_TK_NK_ID 22
#define NEW_TK_NK_LP 23
#define NEW_TK_NK_RP 24
#define NEW_TK_NK_DOT 25
#define NEW_TK_BETWEEN 26
#define NEW_TK_NOT 27
#define NEW_TK_IS 28
#define NEW_TK_NULL 29
#define NEW_TK_NK_LT 30
#define NEW_TK_NK_GT 31
#define NEW_TK_NK_LE 32
#define NEW_TK_NK_GE 33
#define NEW_TK_NK_NE 34
#define NEW_TK_NK_EQ 35
#define NEW_TK_LIKE 36
#define NEW_TK_MATCH 37
#define NEW_TK_NMATCH 38
#define NEW_TK_IN 39
#define NEW_TK_FROM 40
#define NEW_TK_AS 41
#define NEW_TK_JOIN 42
#define NEW_TK_ON 43
#define NEW_TK_INNER 44
#define NEW_TK_SELECT 45
#define NEW_TK_DISTINCT 46
#define NEW_TK_WHERE 47
#define NEW_TK_PARTITION 48
#define NEW_TK_BY 49
#define NEW_TK_SESSION 50
#define NEW_TK_STATE_WINDOW 51
#define NEW_TK_INTERVAL 52
#define NEW_TK_SLIDING 53
#define NEW_TK_FILL 54
#define NEW_TK_VALUE 55
#define NEW_TK_NONE 56
#define NEW_TK_PREV 57
#define NEW_TK_LINEAR 58
#define NEW_TK_NEXT 59
#define NEW_TK_GROUP 60
#define NEW_TK_HAVING 61
#define NEW_TK_ORDER 62
#define NEW_TK_SLIMIT 63
#define NEW_TK_SOFFSET 64
#define NEW_TK_LIMIT 65
#define NEW_TK_OFFSET 66
#define NEW_TK_NK_LR 67
#define NEW_TK_ASC 68
#define NEW_TK_DESC 69
#define NEW_TK_NULLS 70
#define NEW_TK_FIRST 71
#define NEW_TK_LAST 72
#define TK_SPACE 300
#define TK_COMMENT 301
......
......@@ -51,6 +51,8 @@ typedef enum ENodeType {
QUERY_NODE_STATE_WINDOW,
QUERY_NODE_SESSION_WINDOW,
QUERY_NODE_INTERVAL_WINDOW,
QUERY_NODE_NODE_LIST,
QUERY_NODE_FILL,
QUERY_NODE_SET_OPERATOR,
QUERY_NODE_SELECT_STMT,
......@@ -157,14 +159,19 @@ typedef struct SLogicConditionNode {
typedef struct SIsNullCondNode {
ENodeType type; // QUERY_NODE_IS_NULL_CONDITION
SNode* pExpr;
bool isNot;
bool isNull;
} SIsNullCondNode;
typedef struct SNodeListNode {
ENodeType type; // QUERY_NODE_NODE_LIST
SNodeList* pNodeList;
} SNodeListNode;
typedef struct SFunctionNode {
SExprNode type; // QUERY_NODE_FUNCTION
char functionName[TSDB_FUNC_NAME_LEN];
int32_t funcId;
SNodeList* pParameterList; // SNode
SNodeList* pParameterList;
} SFunctionNode;
typedef struct STableNode {
......@@ -242,11 +249,27 @@ typedef struct SSessionWindowNode {
typedef struct SIntervalWindowNode {
ENodeType type; // QUERY_NODE_INTERVAL_WINDOW
int64_t interval;
int64_t sliding;
int64_t offset;
SNode* pInterval; // SValueNode
SNode* pOffset; // SValueNode
SNode* pSliding; // SValueNode
SNode* pFill;
} SIntervalWindowNode;
typedef enum EFillMode {
FILL_MODE_NONE = 1,
FILL_MODE_VALUE,
FILL_MODE_PREV,
FILL_MODE_NULL,
FILL_MODE_LINEAR,
FILL_MODE_NEXT
} EFillMode;
typedef struct SFillNode {
ENodeType type; // QUERY_NODE_FILL
EFillMode mode;
SNode* pValues; // SNodeListNode
} SFillNode;
typedef struct SSelectStmt {
ENodeType type; // QUERY_NODE_SELECT_STMT
bool isDistinct;
......@@ -259,8 +282,8 @@ typedef struct SSelectStmt {
SNodeList* pGroupByList; // SGroupingSetNode
SNode* pHaving;
SNodeList* pOrderByList; // SOrderByExprNode
SLimitNode* pLimit;
SLimitNode* pSlimit;
SNode* pLimit;
SNode* pSlimit;
} SSelectStmt;
typedef enum ESetOperatorType {
......
......@@ -23,11 +23,6 @@ extern "C" {
#include "nodes.h"
#include "parser.h"
typedef enum EResourceType {
AST_CXT_RESOURCE_NODE = 1,
AST_CXT_RESOURCE_NODE_LIST
} EResourceType;
typedef struct SAstCreateContext {
SParseContext* pQueryCxt;
bool notSupport;
......@@ -39,9 +34,6 @@ typedef struct SAstCreateContext {
int32_t createAstCreateContext(SParseContext* pQueryCxt, SAstCreateContext* pCxt);
int32_t destroyAstCreateContext(SAstCreateContext* pCxt);
void* acquireRaii(SAstCreateContext* pCxt, EResourceType type, void* p);
void* releaseRaii(SAstCreateContext* pCxt, void* p);
#ifdef __cplusplus
}
#endif
......
......@@ -32,14 +32,25 @@ SNodeList* addNodeToList(SAstCreateContext* pCxt, SNodeList* pList, SNode* pNode
SNode* createColumnNode(SAstCreateContext* pCxt, const SToken* pTableName, const SToken* pColumnName);
SNode* createValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken* pLiteral);
SNode* createDurationValueNode(SAstCreateContext* pCxt, const SToken* pLiteral);
SNode* addMinusSign(SAstCreateContext* pCxt, SNode* pNode);
SNode* setProjectionAlias(SAstCreateContext* pCxt, SNode* pNode, const SToken* pAlias);
SNode* createLogicConditionNode(SAstCreateContext* pCxt, ELogicConditionType type, SNode* pParam1, SNode* pParam2);
SNode* createOperatorNode(SAstCreateContext* pCxt, EOperatorType type, SNode* pLeft, SNode* pRight);
SNode* createBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, SNode* pRight);
SNode* createNotBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, SNode* pRight);
SNode* createIsNullCondNode(SAstCreateContext* pCxt, SNode* pExpr, bool isNull);
SNode* createFunctionNode(SAstCreateContext* pCxt, const SToken* pFuncName, SNodeList* pParameterList);
SNode* createNodeListNode(SAstCreateContext* pCxt, SNodeList* pList);
SNode* createRealTableNode(SAstCreateContext* pCxt, const SToken* pDbName, const SToken* pTableName, const SToken* pTableAlias);
SNode* createTempTableNode(SAstCreateContext* pCxt, SNode* pSubquery, const SToken* pTableAlias);
SNode* createJoinTableNode(SAstCreateContext* pCxt, EJoinType type, SNode* pLeft, SNode* pRight, SNode* pJoinCond);
SNode* createLimitNode(SAstCreateContext* pCxt, SNode* pLimit, SNode* pOffset);
SNode* createLimitNode(SAstCreateContext* pCxt, const SToken* pLimit, const SToken* pOffset);
SNode* createOrderByExprNode(SAstCreateContext* pCxt, SNode* pExpr, EOrder order, ENullOrder nullOrder);
SNode* createSessionWindowNode(SAstCreateContext* pCxt, SNode* pCol, const SToken* pVal);
SNode* createStateWindowNode(SAstCreateContext* pCxt, SNode* pCol);
SNode* createIntervalWindowNode(SAstCreateContext* pCxt, SNode* pInterval, SNode* pOffset, SNode* pSliding, SNode* pFill);
SNode* createFillNode(SAstCreateContext* pCxt, EFillMode mode, SNode* pValues);
SNode* addWhereClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pWhere);
SNode* addPartitionByClause(SAstCreateContext* pCxt, SNode* pStmt, SNodeList* pPartitionByList);
......
......@@ -22,8 +22,15 @@
#include "ttokendef.h"
#include "astCreateFuncs.h"
#if 0
#define PARSER_TRACE printf("lemon rule = %s\n", yyRuleName[yyruleno])
#define PARSER_DESTRUCTOR_TRACE printf("lemon destroy token = %s\n", yyTokenName[yymajor])
#define PARSER_COMPLETE printf("parsing complete!\n" )
#else
#define PARSER_TRACE
#define PARSER_DESTRUCTOR_TRACE
#define PARSER_COMPLETE
#endif
}
%syntax_error {
......@@ -44,43 +51,37 @@
pCxt->valid = false;
}
%parse_accept { printf("parsing complete!\n" );}
%parse_accept { PARSER_COMPLETE; }
%left OR.
%left AND.
%right NOT.
%left UNION ALL MINUS EXCEPT INTERSECT.
//%left EQ NE ISNULL NOTNULL IS LIKE MATCH NMATCH GLOB BETWEEN IN.
//%left GT GE LT LE.
//%left BITAND BITOR LSHIFT RSHIFT.
%left NK_PLUS NK_MINUS.
//%left DIVIDE TIMES.
%left NK_STAR NK_SLASH. //REM.
%left NK_STAR NK_SLASH NK_REM.
//%left CONCAT.
//%right UMINUS UPLUS BITNOT.
cmd ::= SHOW DATABASES. { PARSER_TRACE; createShowStmt(pCxt, SHOW_TYPE_DATABASE); }
cmd ::= query_expression(A). { PARSER_TRACE; pCxt->pRootNode = A; }
/*5.4*********************************************** literal *********************************************************/
unsigned_integer(A) ::= NK_INTEGER(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &B); }
unsigned_approximate_numeric(A) ::= NK_FLOAT(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &B); }
/************************************************ literal *************************************************************/
literal(A) ::= NK_INTEGER(B). { PARSER_TRACE; A = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &B); }
literal(A) ::= NK_FLOAT(B). { PARSER_TRACE; A = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &B); }
literal(A) ::= NK_STRING(B). { PARSER_TRACE; A = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B); }
literal(A) ::= NK_BOOL(B). { PARSER_TRACE; A = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &B); }
literal(A) ::= TIMESTAMP NK_STRING(B). { PARSER_TRACE; A = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &B); }
literal(A) ::= duration_literal(B). { PARSER_TRACE; A = B; }
signed_integer(A) ::= unsigned_integer(B). { A = B; }
signed_integer(A) ::= NK_PLUS unsigned_integer(B). { A = B; }
signed_integer(A) ::= NK_MINUS unsigned_integer(B). { A = addMinusSign(pCxt, B);}
duration_literal(A) ::= NK_VARIABLE(B). { PARSER_TRACE; A = createDurationValueNode(pCxt, &B); }
unsigned_literal ::= unsigned_numeric_literal.
unsigned_literal ::= general_literal.
%type literal_list { SNodeList* }
%destructor literal_list { PARSER_DESTRUCTOR_TRACE; nodesDestroyList($$); }
literal_list(A) ::= literal(B). { PARSER_TRACE; A = createNodeList(pCxt, B); }
literal_list(A) ::= literal_list(B) NK_COMMA literal(C). { PARSER_TRACE; A = addNodeToList(pCxt, B, C); }
unsigned_numeric_literal ::= unsigned_integer.
unsigned_numeric_literal ::= unsigned_approximate_numeric.
general_literal ::= NK_STRING.
general_literal ::= NK_BOOL.
general_literal ::= NK_NOW.
/*5.4*********************************************** names and identifiers *********************************************************/
/************************************************ names and identifiers ***********************************************/
%type db_name { SToken }
%destructor db_name { PARSER_DESTRUCTOR_TRACE; }
db_name(A) ::= NK_ID(B). { PARSER_TRACE; A = B; }
......@@ -93,29 +94,76 @@ table_name(A) ::= NK_ID(B).
%destructor column_name { PARSER_DESTRUCTOR_TRACE; }
column_name(A) ::= NK_ID(B). { PARSER_TRACE; A = B; }
%type function_name { SToken }
%destructor function_name { PARSER_DESTRUCTOR_TRACE; }
function_name(A) ::= NK_ID(B). { PARSER_TRACE; A = B; }
%type table_alias { SToken }
%destructor table_alias { PARSER_DESTRUCTOR_TRACE; }
table_alias(A) ::= NK_ID(B). { PARSER_TRACE; A = B; }
/*6.4*********************************************** value_specification *********************************************************/
unsigned_value_specification ::= unsigned_literal.
unsigned_value_specification ::= NK_QUESTION.
/*6.35 todo *********************************************** value_expression_primary *********************************************************/
value_expression_primary ::= NK_LP value_expression NK_RP.
value_expression_primary ::= nonparenthesized_value_expression_primary.
nonparenthesized_value_expression_primary ::= unsigned_value_specification.
nonparenthesized_value_expression_primary ::= column_reference.
//nonparenthesized_value_expression_primary ::= agg_function.
nonparenthesized_value_expression_primary ::= subquery.
//nonparenthesized_value_expression_primary ::= case_expression. // todo
//nonparenthesized_value_expression_primary ::= cast_specification. // todo
%type column_alias { SToken }
%destructor column_alias { PARSER_DESTRUCTOR_TRACE; }
column_alias(A) ::= NK_ID(B). { PARSER_TRACE; A = B; }
/************************************************ expression **********************************************************/
expression(A) ::= literal(B). { PARSER_TRACE; A = B; }
//expression(A) ::= NK_QUESTION(B). { PARSER_TRACE; A = B; }
//expression(A) ::= pseudo_column(B). { PARSER_TRACE; A = B; }
expression(A) ::= column_reference(B). { PARSER_TRACE; A = B; }
expression(A) ::= function_name(B) NK_LP expression_list(C) NK_RP. { PARSER_TRACE; A = createFunctionNode(pCxt, &B, C); }
//expression(A) ::= cast_expression(B). { PARSER_TRACE; A = B; }
//expression(A) ::= case_expression(B). { PARSER_TRACE; A = B; }
expression(A) ::= subquery(B). { PARSER_TRACE; A = B; }
expression(A) ::= NK_LP expression(B) NK_RP. { PARSER_TRACE; A = B; }
expression(A) ::= NK_PLUS expression(B). { PARSER_TRACE; A = B; }
expression(A) ::= NK_MINUS expression(B). { PARSER_TRACE; A = createOperatorNode(pCxt, OP_TYPE_SUB, B, NULL); }
expression(A) ::= expression(B) NK_PLUS expression(C). { PARSER_TRACE; A = createOperatorNode(pCxt, OP_TYPE_ADD, B, C); }
expression(A) ::= expression(B) NK_MINUS expression(C). { PARSER_TRACE; A = createOperatorNode(pCxt, OP_TYPE_SUB, B, C); }
expression(A) ::= expression(B) NK_STAR expression(C). { PARSER_TRACE; A = createOperatorNode(pCxt, OP_TYPE_MULTI, B, C); }
expression(A) ::= expression(B) NK_SLASH expression(C). { PARSER_TRACE; A = createOperatorNode(pCxt, OP_TYPE_DIV, B, C); }
expression(A) ::= expression(B) NK_REM expression(C). { PARSER_TRACE; A = createOperatorNode(pCxt, OP_TYPE_MOD, B, C); }
%type expression_list { SNodeList* }
%destructor expression_list { PARSER_DESTRUCTOR_TRACE; nodesDestroyList($$); }
expression_list(A) ::= expression(B). { PARSER_TRACE; A = createNodeList(pCxt, B); }
expression_list(A) ::= expression_list(B) NK_COMMA expression(C). { PARSER_TRACE; A = addNodeToList(pCxt, B, C); }
column_reference(A) ::= column_name(B). { PARSER_TRACE; A = createColumnNode(pCxt, NULL, &B); }
column_reference(A) ::= table_name(B) NK_DOT column_name(C). { PARSER_TRACE; A = createColumnNode(pCxt, &B, &C); }
/*6.35*********************************************** boolean_value_expression *********************************************************/
//pseudo_column(A) ::= NK_NOW. { PARSER_TRACE; A = createFunctionNode(pCxt, NULL, NULL); }
/************************************************ predicate ***********************************************************/
predicate(A) ::= expression(B) compare_op(C) expression(D). { PARSER_TRACE; A = createOperatorNode(pCxt, C, B, D); }
//predicate(A) ::= expression(B) compare_op sub_type expression(B).
predicate(A) ::= expression(B) BETWEEN expression(C) AND expression(D). { PARSER_TRACE; A = createBetweenAnd(pCxt, B, C, D); }
predicate(A) ::= expression(B) NOT BETWEEN expression(C) AND expression(D). { PARSER_TRACE; A = createNotBetweenAnd(pCxt, C, B, D); }
predicate(A) ::= expression(B) IS NULL. { PARSER_TRACE; A = createIsNullCondNode(pCxt, B, true); }
predicate(A) ::= expression(B) IS NOT NULL. { PARSER_TRACE; A = createIsNullCondNode(pCxt, B, false); }
predicate(A) ::= expression(B) in_op(C) in_predicate_value(D). { PARSER_TRACE; A = createOperatorNode(pCxt, C, B, D); }
%type compare_op { EOperatorType }
%destructor compare_op { PARSER_DESTRUCTOR_TRACE; }
compare_op(A) ::= NK_LT. { PARSER_TRACE; A = OP_TYPE_LOWER_THAN; }
compare_op(A) ::= NK_GT. { PARSER_TRACE; A = OP_TYPE_GREATER_THAN; }
compare_op(A) ::= NK_LE. { PARSER_TRACE; A = OP_TYPE_LOWER_EQUAL; }
compare_op(A) ::= NK_GE. { PARSER_TRACE; A = OP_TYPE_GREATER_EQUAL; }
compare_op(A) ::= NK_NE. { PARSER_TRACE; A = OP_TYPE_NOT_EQUAL; }
compare_op(A) ::= NK_EQ. { PARSER_TRACE; A = OP_TYPE_EQUAL; }
compare_op(A) ::= LIKE. { PARSER_TRACE; A = OP_TYPE_LIKE; }
compare_op(A) ::= NOT LIKE. { PARSER_TRACE; A = OP_TYPE_NOT_LIKE; }
compare_op(A) ::= MATCH. { PARSER_TRACE; A = OP_TYPE_MATCH; }
compare_op(A) ::= NMATCH. { PARSER_TRACE; A = OP_TYPE_NMATCH; }
%type in_op { EOperatorType }
%destructor in_op { PARSER_DESTRUCTOR_TRACE; }
in_op(A) ::= IN. { PARSER_TRACE; A = OP_TYPE_IN; }
in_op(A) ::= NOT IN. { PARSER_TRACE; A = OP_TYPE_NOT_IN; }
in_predicate_value(A) ::= NK_LP expression_list(B) NK_RP. { PARSER_TRACE; A = createNodeListNode(pCxt, B); }
/************************************************ boolean_value_expression ********************************************/
boolean_value_expression(A) ::= boolean_primary(B). { PARSER_TRACE; A = B; }
boolean_value_expression(A) ::= NOT boolean_primary(B). { PARSER_TRACE; A = createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, B, NULL); }
boolean_value_expression(A) ::=
......@@ -126,32 +174,31 @@ boolean_value_expression(A) ::=
boolean_primary(A) ::= predicate(B). { PARSER_TRACE; A = B; }
boolean_primary(A) ::= NK_LP boolean_value_expression(B) NK_RP. { PARSER_TRACE; A = B; }
/*7.5*********************************************** from_clause *********************************************************/
/************************************************ from_clause *********************************************************/
from_clause(A) ::= FROM table_reference_list(B). { PARSER_TRACE; A = B; }
table_reference_list(A) ::= table_reference(B). { PARSER_TRACE; A = B; }
table_reference_list(A) ::= table_reference_list(B) NK_COMMA table_reference(C). { PARSER_TRACE; A = createJoinTableNode(pCxt, JOIN_TYPE_INNER, B, C, NULL); }
/*7.6*********************************************** table_reference *****************************************************/
/************************************************ table_reference *****************************************************/
table_reference(A) ::= table_primary(B). { PARSER_TRACE; A = B; }
table_reference(A) ::= joined_table(B). { PARSER_TRACE; A = B; }
table_primary(A) ::= table_name(B) correlation_or_recognition_opt(C). { PARSER_TRACE; A = createRealTableNode(pCxt, NULL, &B, &C); }
table_primary(A) ::=
db_name(B) NK_DOT table_name(C) correlation_or_recognition_opt(D). { PARSER_TRACE; A = createRealTableNode(pCxt, &B, &C, &D); }
table_primary(A) ::= subquery(B) correlation_or_recognition_opt(C). { PARSER_TRACE; A = createTempTableNode(pCxt, B, &C); }
table_primary(A) ::= table_name(B) alias_opt(C). { PARSER_TRACE; A = createRealTableNode(pCxt, NULL, &B, &C); }
table_primary(A) ::= db_name(B) NK_DOT table_name(C) alias_opt(D). { PARSER_TRACE; A = createRealTableNode(pCxt, &B, &C, &D); }
table_primary(A) ::= subquery(B) alias_opt(C). { PARSER_TRACE; A = createTempTableNode(pCxt, B, &C); }
table_primary ::= parenthesized_joined_table.
%type correlation_or_recognition_opt { SToken }
%destructor correlation_or_recognition_opt { PARSER_DESTRUCTOR_TRACE; }
correlation_or_recognition_opt(A) ::= . { PARSER_TRACE; A = nil_token; }
correlation_or_recognition_opt(A) ::= table_alias(B). { PARSER_TRACE; A = B; }
correlation_or_recognition_opt(A) ::= AS table_alias(B). { PARSER_TRACE; A = B; }
%type alias_opt { SToken }
%destructor alias_opt { PARSER_DESTRUCTOR_TRACE; }
alias_opt(A) ::= . { PARSER_TRACE; A = nil_token; }
alias_opt(A) ::= table_alias(B). { PARSER_TRACE; A = B; }
alias_opt(A) ::= AS table_alias(B). { PARSER_TRACE; A = B; }
parenthesized_joined_table(A) ::= NK_LP joined_table(B) NK_RP. { PARSER_TRACE; A = B; }
parenthesized_joined_table(A) ::= NK_LP parenthesized_joined_table(B) NK_RP. { PARSER_TRACE; A = B; }
/*7.10*********************************************** joined_table ************************************************************/
/************************************************ joined_table ********************************************************/
joined_table(A) ::=
table_reference(B) join_type(C) JOIN table_reference(D) ON search_condition(E). { PARSER_TRACE; A = createJoinTableNode(pCxt, C, B, D, E); }
......@@ -159,7 +206,7 @@ joined_table(A) ::=
%destructor join_type { PARSER_DESTRUCTOR_TRACE; }
join_type(A) ::= INNER. { PARSER_TRACE; A = JOIN_TYPE_INNER; }
/*7.15*********************************************** query_specification *************************************************/
/************************************************ 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)
......@@ -189,12 +236,53 @@ select_list(A) ::= select_sublist(B).
select_sublist(A) ::= select_item(B). { PARSER_TRACE; A = createNodeList(pCxt, B); }
select_sublist(A) ::= select_sublist(B) NK_COMMA select_item(C). { PARSER_TRACE; A = addNodeToList(pCxt, B, C); }
select_item(A) ::= value_expression(B). { PARSER_TRACE; A = B; }
select_item(A) ::= value_expression(B) NK_ID(C). { PARSER_TRACE; A = setProjectionAlias(pCxt, B, &C); }
select_item(A) ::= value_expression(B) AS NK_ID(C). { PARSER_TRACE; A = setProjectionAlias(pCxt, B, &C); }
select_item(A) ::= expression(B). { PARSER_TRACE; A = B; }
select_item(A) ::= expression(B) column_alias(C). { PARSER_TRACE; A = setProjectionAlias(pCxt, B, &C); }
select_item(A) ::= expression(B) AS column_alias(C). { PARSER_TRACE; A = setProjectionAlias(pCxt, B, &C); }
select_item(A) ::= table_name(B) NK_DOT NK_STAR(C). { PARSER_TRACE; A = createColumnNode(pCxt, &B, &C); }
/*7.16*********************************************** query_expression ****************************************************/
where_clause_opt(A) ::= . { PARSER_TRACE; A = NULL; }
where_clause_opt(A) ::= WHERE search_condition(B). { PARSER_TRACE; A = B; }
%type partition_by_clause_opt { SNodeList* }
%destructor partition_by_clause_opt { PARSER_DESTRUCTOR_TRACE; nodesDestroyList($$); }
partition_by_clause_opt(A) ::= . { PARSER_TRACE; A = NULL; }
partition_by_clause_opt(A) ::= PARTITION BY expression_list(B). { PARSER_TRACE; A = B; }
twindow_clause_opt(A) ::= . { PARSER_TRACE; A = NULL; }
twindow_clause_opt(A) ::=
SESSION NK_LP column_reference(B) NK_COMMA NK_INTEGER(C) NK_RP. { PARSER_TRACE; A = createSessionWindowNode(pCxt, B, &C); }
twindow_clause_opt(A) ::= STATE_WINDOW NK_LP column_reference(B) NK_RP. { PARSER_TRACE; A = createStateWindowNode(pCxt, B); }
twindow_clause_opt(A) ::=
INTERVAL NK_LP duration_literal(B) NK_RP sliding_opt(C) fill_opt(D). { PARSER_TRACE; 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). { PARSER_TRACE; A = createIntervalWindowNode(pCxt, B, C, D, E); }
sliding_opt(A) ::= . { PARSER_TRACE; A = NULL; }
sliding_opt(A) ::= SLIDING NK_LP duration_literal(B) NK_RP. { PARSER_TRACE; A = B; }
fill_opt(A) ::= . { PARSER_TRACE; A = NULL; }
fill_opt(A) ::= FILL NK_LP fill_mode(B) NK_RP. { PARSER_TRACE; A = createFillNode(pCxt, B, NULL); }
fill_opt(A) ::= FILL NK_LP VALUE NK_COMMA literal_list(B) NK_RP. { PARSER_TRACE; A = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, B)); }
%type fill_mode { EFillMode }
%destructor fill_mode { PARSER_DESTRUCTOR_TRACE; }
fill_mode(A) ::= NONE. { PARSER_TRACE; A = FILL_MODE_NONE; }
fill_mode(A) ::= PREV. { PARSER_TRACE; A = FILL_MODE_PREV; }
fill_mode(A) ::= NULL. { PARSER_TRACE; A = FILL_MODE_NULL; }
fill_mode(A) ::= LINEAR. { PARSER_TRACE; A = FILL_MODE_LINEAR; }
fill_mode(A) ::= NEXT. { PARSER_TRACE; A = FILL_MODE_NEXT; }
%type group_by_clause_opt { SNodeList* }
%destructor group_by_clause_opt { PARSER_DESTRUCTOR_TRACE; nodesDestroyList($$); }
group_by_clause_opt(A) ::= . { PARSER_TRACE; A = NULL; }
group_by_clause_opt(A) ::= GROUP BY expression_list(B). { PARSER_TRACE; A = B; }
having_clause_opt(A) ::= . { PARSER_TRACE; A = NULL; }
having_clause_opt(A) ::= HAVING search_condition(B). { PARSER_TRACE; A = B; }
/************************************************ query_expression ****************************************************/
query_expression(A) ::=
query_expression_body(B)
order_by_clause_opt(C) slimit_clause_opt(D) limit_clause_opt(E). {
......@@ -219,25 +307,22 @@ order_by_clause_opt(A) ::= .
order_by_clause_opt(A) ::= ORDER BY sort_specification_list(B). { PARSER_TRACE; A = B; }
slimit_clause_opt(A) ::= . { PARSER_TRACE; A = NULL; }
slimit_clause_opt(A) ::= SLIMIT signed_integer(B). { PARSER_TRACE; A = createLimitNode(pCxt, B, 0); }
slimit_clause_opt(A) ::= SLIMIT signed_integer(B) SOFFSET signed_integer(C). { PARSER_TRACE; A = createLimitNode(pCxt, B, C); }
slimit_clause_opt(A) ::= SLIMIT signed_integer(C) NK_COMMA signed_integer(B). { PARSER_TRACE; A = createLimitNode(pCxt, B, C); }
slimit_clause_opt(A) ::= SLIMIT NK_INTEGER(B). { PARSER_TRACE; A = createLimitNode(pCxt, &B, NULL); }
slimit_clause_opt(A) ::= SLIMIT NK_INTEGER(B) SOFFSET NK_INTEGER(C). { PARSER_TRACE; A = createLimitNode(pCxt, &B, &C); }
slimit_clause_opt(A) ::= SLIMIT NK_INTEGER(C) NK_COMMA NK_INTEGER(B). { PARSER_TRACE; A = createLimitNode(pCxt, &B, &C); }
limit_clause_opt(A) ::= . { PARSER_TRACE; A = NULL; }
limit_clause_opt(A) ::= LIMIT signed_integer(B). { PARSER_TRACE; A = createLimitNode(pCxt, B, 0); }
limit_clause_opt(A) ::= LIMIT signed_integer(B) OFFSET signed_integer(C). { PARSER_TRACE; A = createLimitNode(pCxt, B, C); }
limit_clause_opt(A) ::= LIMIT signed_integer(C) NK_COMMA signed_integer(B). { PARSER_TRACE; A = createLimitNode(pCxt, B, C); }
limit_clause_opt(A) ::= LIMIT NK_INTEGER(B). { PARSER_TRACE; A = createLimitNode(pCxt, &B, NULL); }
limit_clause_opt(A) ::= LIMIT NK_INTEGER(B) OFFSET NK_INTEGER(C). { PARSER_TRACE; A = createLimitNode(pCxt, &B, &C); }
limit_clause_opt(A) ::= LIMIT NK_INTEGER(C) NK_COMMA NK_INTEGER(B). { PARSER_TRACE; A = createLimitNode(pCxt, &B, &C); }
/*7.18*********************************************** subquery ************************************************************/
/************************************************ subquery ************************************************************/
subquery(A) ::= NK_LR query_expression(B) NK_RP. { PARSER_TRACE; A = B; }
/*8.1*********************************************** predicate ************************************************************/
predicate ::= .
/*8.21 todo *********************************************** search_condition ************************************************************/
/************************************************ search_condition ****************************************************/
search_condition(A) ::= boolean_value_expression(B). { PARSER_TRACE; A = B; }
/*10.10*********************************************** sort_specification_list ************************************************************/
/************************************************ sort_specification_list *********************************************/
%type sort_specification_list { SNodeList* }
%destructor sort_specification_list { PARSER_DESTRUCTOR_TRACE; nodesDestroyList($$); }
sort_specification_list(A) ::= sort_specification(B). { PARSER_TRACE; A = createNodeList(pCxt, B); }
......@@ -245,7 +330,7 @@ sort_specification_list(A) ::=
sort_specification_list(B) NK_COMMA sort_specification(C). { PARSER_TRACE; A = addNodeToList(pCxt, B, C); }
sort_specification(A) ::=
value_expression(B) ordering_specification_opt(C) null_ordering_opt(D). { PARSER_TRACE; A = createOrderByExprNode(pCxt, B, C, D); }
expression(B) ordering_specification_opt(C) null_ordering_opt(D). { PARSER_TRACE; A = createOrderByExprNode(pCxt, B, C, D); }
%type ordering_specification_opt EOrder
%destructor ordering_specification_opt { PARSER_DESTRUCTOR_TRACE; }
......@@ -258,39 +343,3 @@ ordering_specification_opt(A) ::= DESC.
null_ordering_opt(A) ::= . { PARSER_TRACE; A = NULL_ORDER_DEFAULT; }
null_ordering_opt(A) ::= NULLS FIRST. { PARSER_TRACE; A = NULL_ORDER_FIRST; }
null_ordering_opt(A) ::= NULLS LAST. { PARSER_TRACE; A = NULL_ORDER_LAST; }
/************************************************ todo ************************************************************/
where_clause_opt ::= .
%type partition_by_clause_opt { SNodeList* }
%destructor partition_by_clause_opt { PARSER_DESTRUCTOR_TRACE; nodesDestroyList($$); }
partition_by_clause_opt ::=.
twindow_clause_opt ::= .
%type group_by_clause_opt { SNodeList* }
%destructor group_by_clause_opt { PARSER_DESTRUCTOR_TRACE; nodesDestroyList($$); }
group_by_clause_opt ::= .
having_clause_opt ::= .
//////////////////////// value_function /////////////////////////////////
value_function ::= NK_ID NK_LP value_expression NK_RP.
value_function ::= NK_ID NK_LP value_expression NK_COMMA value_expression NK_RP.
//////////////////////// value_expression /////////////////////////////////
value_expression ::= common_value_expression.
common_value_expression ::= numeric_value_expression.
numeric_value_expression ::= numeric_primary.
numeric_value_expression ::= NK_PLUS numeric_primary.
numeric_value_expression ::= NK_MINUS numeric_primary.
numeric_value_expression ::= numeric_value_expression NK_PLUS numeric_value_expression.
numeric_value_expression ::= numeric_value_expression NK_MINUS numeric_value_expression.
numeric_value_expression ::= numeric_value_expression NK_STAR numeric_value_expression.
numeric_value_expression ::= numeric_value_expression NK_SLASH numeric_value_expression.
numeric_primary ::= value_expression_primary.
numeric_primary ::= value_function.
\ No newline at end of file
......@@ -16,53 +16,14 @@
#include "ttoken.h"
#include "astCreateContext.h"
typedef struct SResourceEntry {
EResourceType type;
void* res;
} SResourceEntry;
int32_t createAstCreateContext(SParseContext* pQueryCxt, SAstCreateContext* pCxt) {
pCxt->pQueryCxt = pQueryCxt;
pCxt->notSupport = false;
pCxt->valid = true;
pCxt->pRootNode = NULL;
pCxt->pResourceHash = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, false);
if (NULL == pCxt->pResourceHash) {
return TSDB_CODE_TSC_OUT_OF_MEMORY;
}
return TSDB_CODE_SUCCESS;
}
int32_t destroyAstCreateContext(SAstCreateContext* pCxt) {
SResourceEntry* item = taosHashIterate(pCxt->pResourceHash, NULL);
while (item) {
switch (item->type) {
case AST_CXT_RESOURCE_NODE:
nodesDestroyNode(item->res);
break;
case AST_CXT_RESOURCE_NODE_LIST:
nodesDestroyList(item->res);
break;
default:
tfree(item->res);
}
item = taosHashIterate(pCxt->pResourceHash, item);
}
}
void* acquireRaii(SAstCreateContext* pCxt, EResourceType type, void* p) {
if (NULL == p) {
return NULL;
}
SResourceEntry entry = { .type = type, .res = p };
taosHashPut(pCxt->pResourceHash, &p, POINTER_BYTES, &entry, sizeof(SResourceEntry));
return p;
}
void* releaseRaii(SAstCreateContext* pCxt, void* p) {
if (NULL == p) {
return NULL;
}
taosHashRemove(pCxt->pResourceHash, &p, POINTER_BYTES);
return p;
return TSDB_CODE_SUCCESS;
}
......@@ -53,11 +53,11 @@ static bool checkColumnName(SAstCreateContext* pCxt, const SToken* pColumnName)
SNodeList* createNodeList(SAstCreateContext* pCxt, SNode* pNode) {
SNodeList* list = nodesMakeList();
CHECK_OUT_OF_MEM(list);
return acquireRaii(pCxt, AST_CXT_RESOURCE_NODE_LIST, nodesListAppend(list, releaseRaii(pCxt, pNode)));
return nodesListAppend(list, pNode);
}
SNodeList* addNodeToList(SAstCreateContext* pCxt, SNodeList* pList, SNode* pNode) {
return nodesListAppend(pList, releaseRaii(pCxt, pNode));
return nodesListAppend(pList, pNode);
}
SNode* createColumnNode(SAstCreateContext* pCxt, const SToken* pTableName, const SToken* pColumnName) {
......@@ -70,14 +70,21 @@ SNode* createColumnNode(SAstCreateContext* pCxt, const SToken* pTableName, const
strncpy(col->tableName, pTableName->z, pTableName->n);
}
strncpy(col->colName, pColumnName->z, pColumnName->n);
return acquireRaii(pCxt, AST_CXT_RESOURCE_NODE, col);
return (SNode*)col;
}
SNode* createValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken* pLiteral) {
SValueNode* val = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
CHECK_OUT_OF_MEM(val);
// strncpy(col->colName, pColumnName->z, pColumnName->n);
return acquireRaii(pCxt, AST_CXT_RESOURCE_NODE, val);
// todo
return (SNode*)val;
}
SNode* createDurationValueNode(SAstCreateContext* pCxt, const SToken* pLiteral) {
SValueNode* val = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
CHECK_OUT_OF_MEM(val);
// todo
return (SNode*)val;
}
SNode* addMinusSign(SAstCreateContext* pCxt, SNode* pNode) {
......@@ -89,9 +96,51 @@ SNode* createLogicConditionNode(SAstCreateContext* pCxt, ELogicConditionType typ
CHECK_OUT_OF_MEM(cond);
cond->condType = type;
cond->pParameterList = nodesMakeList();
nodesListAppend(cond->pParameterList, releaseRaii(pCxt, pParam1));
nodesListAppend(cond->pParameterList, releaseRaii(pCxt, pParam2));
return acquireRaii(pCxt, AST_CXT_RESOURCE_NODE, cond);
nodesListAppend(cond->pParameterList, pParam1);
nodesListAppend(cond->pParameterList, pParam2);
return (SNode*)cond;
}
SNode* createOperatorNode(SAstCreateContext* pCxt, EOperatorType type, SNode* pLeft, SNode* pRight) {
SOperatorNode* op = (SOperatorNode*)nodesMakeNode(QUERY_NODE_OPERATOR);
CHECK_OUT_OF_MEM(op);
op->opType = type;
op->pLeft = pLeft;
op->pRight = pRight;
return (SNode*)op;
}
SNode* createBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, SNode* pRight) {
return createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND,
createOperatorNode(pCxt, OP_TYPE_GREATER_EQUAL, pExpr, pLeft), createOperatorNode(pCxt, OP_TYPE_LOWER_EQUAL, pExpr, pRight));
}
SNode* createNotBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, SNode* pRight) {
return createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR,
createOperatorNode(pCxt, OP_TYPE_LOWER_THAN, pExpr, pLeft), createOperatorNode(pCxt, OP_TYPE_GREATER_THAN, pExpr, pRight));
}
SNode* createIsNullCondNode(SAstCreateContext* pCxt, SNode* pExpr, bool isNull) {
SIsNullCondNode* cond = (SIsNullCondNode*)nodesMakeNode(QUERY_NODE_IS_NULL_CONDITION);
CHECK_OUT_OF_MEM(cond);
cond->pExpr = pExpr;
cond->isNull = isNull;
return (SNode*)cond;
}
SNode* createFunctionNode(SAstCreateContext* pCxt, const SToken* pFuncName, SNodeList* pParameterList) {
SFunctionNode* func = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
CHECK_OUT_OF_MEM(func);
strncpy(func->functionName, pFuncName->z, pFuncName->n);
func->pParameterList = pParameterList;
return (SNode*)func;
}
SNode* createNodeListNode(SAstCreateContext* pCxt, SNodeList* pList) {
SNodeListNode* list = (SNodeListNode*)nodesMakeNode(QUERY_NODE_NODE_LIST);
CHECK_OUT_OF_MEM(list);
list->pNodeList = pList;
return (SNode*)list;
}
SNode* createRealTableNode(SAstCreateContext* pCxt, const SToken* pDbName, const SToken* pTableName, const SToken* pTableAlias) {
......@@ -104,41 +153,74 @@ SNode* createRealTableNode(SAstCreateContext* pCxt, const SToken* pDbName, const
strncpy(realTable->dbName, pDbName->z, pDbName->n);
}
strncpy(realTable->table.tableName, pTableName->z, pTableName->n);
return acquireRaii(pCxt, AST_CXT_RESOURCE_NODE, realTable);
return (SNode*)realTable;
}
SNode* createTempTableNode(SAstCreateContext* pCxt, SNode* pSubquery, const SToken* pTableAlias) {
STempTableNode* tempTable = (STempTableNode*)nodesMakeNode(QUERY_NODE_TEMP_TABLE);
CHECK_OUT_OF_MEM(tempTable);
tempTable->pSubquery = pSubquery;
return acquireRaii(pCxt, AST_CXT_RESOURCE_NODE, tempTable);
return (SNode*)tempTable;
}
SNode* createJoinTableNode(SAstCreateContext* pCxt, EJoinType type, SNode* pLeft, SNode* pRight, SNode* pJoinCond) {
SJoinTableNode* joinTable = (SJoinTableNode*)nodesMakeNode(QUERY_NODE_JOIN_TABLE);
CHECK_OUT_OF_MEM(joinTable);
joinTable->joinType = type;
joinTable->pLeft = releaseRaii(pCxt, pLeft);
joinTable->pRight = releaseRaii(pCxt, pRight);
joinTable->pLeft = pLeft;
joinTable->pRight = pRight;
joinTable->pOnCond = pJoinCond;
return acquireRaii(pCxt, AST_CXT_RESOURCE_NODE, joinTable);
return (SNode*)joinTable;
}
SNode* createLimitNode(SAstCreateContext* pCxt, SNode* pLimit, SNode* pOffset) {
SNode* createLimitNode(SAstCreateContext* pCxt, const SToken* pLimit, const SToken* pOffset) {
SLimitNode* limitNode = (SLimitNode*)nodesMakeNode(QUERY_NODE_LIMIT);
CHECK_OUT_OF_MEM(limitNode);
// limitNode->limit = limit;
// limitNode->offset = offset;
return acquireRaii(pCxt, AST_CXT_RESOURCE_NODE, limitNode);
return (SNode*)limitNode;
}
SNode* createOrderByExprNode(SAstCreateContext* pCxt, SNode* pExpr, EOrder order, ENullOrder nullOrder) {
SOrderByExprNode* orderByExpr = (SOrderByExprNode*)nodesMakeNode(QUERY_NODE_ORDER_BY_EXPR);
CHECK_OUT_OF_MEM(orderByExpr);
orderByExpr->pExpr = releaseRaii(pCxt, pExpr);
orderByExpr->pExpr = pExpr;
orderByExpr->order = order;
orderByExpr->nullOrder = nullOrder;
return acquireRaii(pCxt, AST_CXT_RESOURCE_NODE, orderByExpr);
return (SNode*)orderByExpr;
}
SNode* createSessionWindowNode(SAstCreateContext* pCxt, SNode* pCol, const SToken* pVal) {
SSessionWindowNode* session = (SSessionWindowNode*)nodesMakeNode(QUERY_NODE_SESSION_WINDOW);
CHECK_OUT_OF_MEM(session);
session->pCol = pCol;
// session->gap = getInteger(pVal);
return (SNode*)session;
}
SNode* createStateWindowNode(SAstCreateContext* pCxt, SNode* pCol) {
SStateWindowNode* state = (SStateWindowNode*)nodesMakeNode(QUERY_NODE_STATE_WINDOW);
CHECK_OUT_OF_MEM(state);
state->pCol = pCol;
return (SNode*)state;
}
SNode* createIntervalWindowNode(SAstCreateContext* pCxt, SNode* pInterval, SNode* pOffset, SNode* pSliding, SNode* pFill) {
SIntervalWindowNode* interval = (SIntervalWindowNode*)nodesMakeNode(QUERY_NODE_INTERVAL_WINDOW);
CHECK_OUT_OF_MEM(interval);
interval->pInterval = pInterval;
interval->pOffset = pOffset;
interval->pSliding = pSliding;
interval->pFill = pFill;
return (SNode*)interval;
}
SNode* createFillNode(SAstCreateContext* pCxt, EFillMode mode, SNode* pValues) {
SFillNode* fill = (SFillNode*)nodesMakeNode(QUERY_NODE_FILL);
CHECK_OUT_OF_MEM(fill);
fill->mode = mode;
fill->pValues = pValues;
return (SNode*)fill;
}
SNode* setProjectionAlias(SAstCreateContext* pCxt, SNode* pNode, const SToken* pAlias) {
......@@ -148,56 +230,56 @@ SNode* setProjectionAlias(SAstCreateContext* pCxt, SNode* pNode, const SToken* p
SNode* addWhereClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pWhere) {
if (QUERY_NODE_SELECT_STMT == nodeType(pStmt)) {
((SSelectStmt*)pStmt)->pWhere = releaseRaii(pCxt, pWhere);
((SSelectStmt*)pStmt)->pWhere = pWhere;
}
return pStmt;
}
SNode* addPartitionByClause(SAstCreateContext* pCxt, SNode* pStmt, SNodeList* pPartitionByList) {
if (QUERY_NODE_SELECT_STMT == nodeType(pStmt)) {
((SSelectStmt*)pStmt)->pPartitionByList = releaseRaii(pCxt, pPartitionByList);
((SSelectStmt*)pStmt)->pPartitionByList = pPartitionByList;
}
return pStmt;
}
SNode* addWindowClauseClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pWindow) {
if (QUERY_NODE_SELECT_STMT == nodeType(pStmt)) {
((SSelectStmt*)pStmt)->pWindow = releaseRaii(pCxt, pWindow);
((SSelectStmt*)pStmt)->pWindow = pWindow;
}
return pStmt;
}
SNode* addGroupByClause(SAstCreateContext* pCxt, SNode* pStmt, SNodeList* pGroupByList) {
if (QUERY_NODE_SELECT_STMT == nodeType(pStmt)) {
((SSelectStmt*)pStmt)->pGroupByList = releaseRaii(pCxt, pGroupByList);
((SSelectStmt*)pStmt)->pGroupByList = pGroupByList;
}
return pStmt;
}
SNode* addHavingClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pHaving) {
if (QUERY_NODE_SELECT_STMT == nodeType(pStmt)) {
((SSelectStmt*)pStmt)->pHaving = releaseRaii(pCxt, pHaving);
((SSelectStmt*)pStmt)->pHaving = pHaving;
}
return pStmt;
}
SNode* addOrderByClause(SAstCreateContext* pCxt, SNode* pStmt, SNodeList* pOrderByList) {
if (QUERY_NODE_SELECT_STMT == nodeType(pStmt)) {
((SSelectStmt*)pStmt)->pOrderByList = releaseRaii(pCxt, pOrderByList);
((SSelectStmt*)pStmt)->pOrderByList = pOrderByList;
}
return pStmt;
}
SNode* addSlimitClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pSlimit) {
if (QUERY_NODE_SELECT_STMT == nodeType(pStmt)) {
((SSelectStmt*)pStmt)->pSlimit = releaseRaii(pCxt, pSlimit);
((SSelectStmt*)pStmt)->pSlimit = pSlimit;
}
return pStmt;
}
SNode* addLimitClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pLimit) {
if (QUERY_NODE_SELECT_STMT == nodeType(pStmt)) {
((SSelectStmt*)pStmt)->pLimit = releaseRaii(pCxt, pLimit);
((SSelectStmt*)pStmt)->pLimit = pLimit;
}
return pStmt;
}
......@@ -209,23 +291,23 @@ SNode* createSelectStmt(SAstCreateContext* pCxt, bool isDistinct, SNodeList* pPr
if (NULL == pProjectionList) {
select->isStar = true;
}
select->pProjectionList = releaseRaii(pCxt, pProjectionList);
select->pFromTable = releaseRaii(pCxt, pTable);
return acquireRaii(pCxt, AST_CXT_RESOURCE_NODE, select);
select->pProjectionList = pProjectionList;
select->pFromTable = pTable;
return (SNode*)select;
}
SNode* createSetOperator(SAstCreateContext* pCxt, ESetOperatorType type, SNode* pLeft, SNode* pRight) {
SSetOperator* setOp = (SSetOperator*)nodesMakeNode(QUERY_NODE_SET_OPERATOR);
CHECK_OUT_OF_MEM(setOp);
setOp->opType = type;
setOp->pLeft = releaseRaii(pCxt, pLeft);
setOp->pRight = releaseRaii(pCxt, pRight);
return acquireRaii(pCxt, AST_CXT_RESOURCE_NODE, setOp);
setOp->pLeft = pLeft;
setOp->pRight = pRight;
return (SNode*)setOp;
}
SNode* createShowStmt(SAstCreateContext* pCxt, EShowStmtType type) {
SShowStmt* show = (SShowStmt*)nodesMakeNode(QUERY_NODE_SHOW_STMT);
CHECK_OUT_OF_MEM(show);
show->showType = type;
return acquireRaii(pCxt, AST_CXT_RESOURCE_NODE, show);
return (SNode*)show;
}
......@@ -37,8 +37,15 @@
#include "ttokendef.h"
#include "astCreateFuncs.h"
#if 0
#define PARSER_TRACE printf("lemon rule = %s\n", yyRuleName[yyruleno])
#define PARSER_DESTRUCTOR_TRACE printf("lemon destroy token = %s\n", yyTokenName[yymajor])
#define PARSER_COMPLETE printf("parsing complete!\n" )
#else
#define PARSER_TRACE
#define PARSER_DESTRUCTOR_TRACE
#define PARSER_COMPLETE
#endif
/**************** End of %include directives **********************************/
/* These constants specify the various numeric values for terminal symbols
** in a format understandable to "makeheaders". This section is blank unless
......@@ -102,19 +109,21 @@
#endif
/************* Begin control #defines *****************************************/
#define YYCODETYPE unsigned char
#define YYNOCODE 98
#define YYNOCODE 125
#define YYACTIONTYPE unsigned short int
#define NewParseTOKENTYPE SToken
typedef union {
int yyinit;
NewParseTOKENTYPE yy0;
SNodeList* yy40;
EOrder yy106;
EJoinType yy148;
SNode* yy168;
SToken yy169;
bool yy173;
ENullOrder yy193;
EOperatorType yy40;
EFillMode yy44;
SToken yy79;
ENullOrder yy107;
EJoinType yy162;
SNodeList* yy174;
EOrder yy188;
SNode* yy212;
bool yy237;
} YYMINORTYPE;
#ifndef YYSTACKDEPTH
#define YYSTACKDEPTH 100
......@@ -129,17 +138,17 @@ typedef union {
#define NewParseCTX_PARAM
#define NewParseCTX_FETCH
#define NewParseCTX_STORE
#define YYNSTATE 92
#define YYNRULE 106
#define YYNTOKEN 45
#define YY_MAX_SHIFT 91
#define YY_MIN_SHIFTREDUCE 169
#define YY_MAX_SHIFTREDUCE 274
#define YY_ERROR_ACTION 275
#define YY_ACCEPT_ACTION 276
#define YY_NO_ACTION 277
#define YY_MIN_REDUCE 278
#define YY_MAX_REDUCE 383
#define YYNSTATE 149
#define YYNRULE 135
#define YYNTOKEN 73
#define YY_MAX_SHIFT 148
#define YY_MIN_SHIFTREDUCE 245
#define YY_MAX_SHIFTREDUCE 379
#define YY_ERROR_ACTION 380
#define YY_ACCEPT_ACTION 381
#define YY_NO_ACTION 382
#define YY_MIN_REDUCE 383
#define YY_MAX_REDUCE 517
/************* End control #defines *******************************************/
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
......@@ -206,142 +215,199 @@ typedef union {
** yy_default[] Default action for each state.
**
*********** Begin parsing tables **********************************************/
#define YY_ACTTAB_COUNT (464)
#define YY_ACTTAB_COUNT (656)
static const YYACTIONTYPE yy_action[] = {
/* 0 */ 60, 60, 77, 60, 60, 60, 290, 80, 289, 47,
/* 10 */ 60, 60, 62, 60, 60, 60, 171, 172, 245, 246,
/* 20 */ 247, 70, 249, 6, 21, 20, 76, 33, 292, 295,
/* 30 */ 46, 11, 10, 9, 8, 31, 72, 318, 34, 22,
/* 40 */ 19, 42, 300, 75, 49, 74, 187, 60, 62, 60,
/* 50 */ 60, 60, 60, 179, 60, 60, 60, 22, 87, 289,
/* 60 */ 44, 60, 60, 37, 60, 60, 60, 18, 202, 63,
/* 70 */ 291, 295, 294, 291, 295, 73, 291, 295, 60, 60,
/* 80 */ 310, 60, 60, 60, 262, 80, 289, 5, 60, 60,
/* 90 */ 62, 60, 60, 60, 83, 341, 51, 50, 60, 37,
/* 100 */ 60, 60, 171, 79, 53, 15, 60, 60, 306, 60,
/* 110 */ 60, 60, 1, 87, 289, 319, 60, 60, 37, 60,
/* 120 */ 60, 60, 19, 304, 206, 60, 62, 60, 60, 60,
/* 130 */ 60, 306, 60, 60, 60, 202, 87, 289, 212, 60,
/* 140 */ 60, 81, 60, 60, 60, 71, 303, 61, 291, 295,
/* 150 */ 342, 205, 177, 60, 37, 60, 60, 60, 60, 306,
/* 160 */ 60, 60, 60, 32, 87, 289, 23, 60, 60, 88,
/* 170 */ 60, 60, 60, 214, 302, 40, 60, 81, 60, 60,
/* 180 */ 60, 60, 178, 60, 60, 60, 327, 87, 289, 327,
/* 190 */ 60, 60, 64, 60, 60, 60, 38, 236, 237, 326,
/* 200 */ 325, 9, 8, 325, 60, 88, 60, 60, 381, 381,
/* 210 */ 307, 381, 381, 381, 179, 87, 289, 14, 381, 381,
/* 220 */ 67, 381, 381, 381, 282, 28, 334, 60, 64, 60,
/* 230 */ 60, 380, 380, 59, 380, 380, 380, 29, 87, 289,
/* 240 */ 343, 380, 380, 91, 380, 380, 380, 282, 282, 333,
/* 250 */ 68, 282, 23, 338, 282, 381, 337, 381, 381, 65,
/* 260 */ 65, 40, 65, 65, 65, 86, 87, 289, 27, 65,
/* 270 */ 65, 30, 65, 65, 65, 282, 85, 69, 380, 48,
/* 280 */ 380, 380, 66, 66, 171, 66, 66, 66, 284, 87,
/* 290 */ 289, 283, 66, 66, 84, 66, 66, 66, 21, 20,
/* 300 */ 239, 240, 25, 7, 324, 286, 65, 52, 65, 65,
/* 310 */ 377, 377, 26, 377, 377, 377, 178, 87, 289, 312,
/* 320 */ 377, 377, 56, 377, 377, 377, 55, 57, 58, 66,
/* 330 */ 213, 66, 66, 376, 376, 3, 376, 376, 376, 20,
/* 340 */ 87, 289, 200, 376, 376, 199, 376, 376, 376, 43,
/* 350 */ 17, 16, 285, 36, 263, 230, 24, 377, 13, 12,
/* 360 */ 377, 4, 219, 250, 171, 172, 245, 246, 247, 70,
/* 370 */ 249, 6, 2, 279, 54, 276, 89, 278, 90, 82,
/* 380 */ 376, 277, 277, 376, 277, 277, 277, 277, 19, 277,
/* 390 */ 13, 12, 207, 277, 277, 277, 171, 172, 245, 246,
/* 400 */ 247, 70, 249, 6, 277, 327, 277, 277, 327, 277,
/* 410 */ 277, 277, 76, 33, 277, 39, 277, 277, 39, 325,
/* 420 */ 19, 31, 325, 76, 33, 277, 78, 41, 300, 301,
/* 430 */ 277, 300, 31, 277, 277, 277, 277, 277, 35, 300,
/* 440 */ 301, 277, 300, 277, 76, 33, 277, 277, 277, 277,
/* 450 */ 277, 277, 277, 31, 277, 277, 277, 277, 277, 45,
/* 460 */ 300, 301, 277, 300,
/* 0 */ 392, 390, 94, 494, 20, 67, 393, 390, 27, 25,
/* 10 */ 23, 22, 21, 400, 390, 321, 52, 131, 414, 144,
/* 20 */ 492, 74, 46, 401, 266, 403, 19, 89, 98, 119,
/* 30 */ 284, 285, 286, 287, 288, 289, 290, 292, 293, 294,
/* 40 */ 27, 25, 23, 22, 21, 23, 22, 21, 346, 465,
/* 50 */ 463, 247, 248, 249, 250, 145, 253, 320, 19, 89,
/* 60 */ 98, 132, 284, 285, 286, 287, 288, 289, 290, 292,
/* 70 */ 293, 294, 26, 24, 110, 344, 345, 347, 348, 247,
/* 80 */ 248, 249, 250, 145, 253, 260, 103, 6, 400, 390,
/* 90 */ 494, 8, 143, 414, 144, 3, 317, 41, 401, 111,
/* 100 */ 403, 439, 36, 53, 70, 96, 435, 492, 400, 390,
/* 110 */ 143, 414, 143, 414, 144, 469, 114, 41, 401, 128,
/* 120 */ 403, 439, 450, 148, 54, 96, 435, 450, 143, 414,
/* 130 */ 494, 34, 63, 36, 118, 490, 400, 390, 137, 448,
/* 140 */ 143, 414, 144, 493, 447, 41, 401, 492, 403, 439,
/* 150 */ 26, 24, 322, 96, 435, 54, 17, 247, 248, 249,
/* 160 */ 250, 145, 253, 454, 103, 28, 291, 400, 390, 295,
/* 170 */ 136, 143, 414, 144, 5, 4, 41, 401, 329, 403,
/* 180 */ 439, 138, 400, 390, 438, 435, 143, 414, 144, 415,
/* 190 */ 258, 41, 401, 76, 403, 439, 120, 115, 113, 123,
/* 200 */ 435, 400, 390, 377, 378, 143, 414, 144, 78, 34,
/* 210 */ 40, 401, 42, 403, 439, 343, 400, 390, 88, 435,
/* 220 */ 131, 414, 144, 26, 24, 46, 401, 7, 403, 134,
/* 230 */ 247, 248, 249, 250, 145, 253, 112, 103, 6, 476,
/* 240 */ 27, 25, 23, 22, 21, 109, 72, 26, 24, 130,
/* 250 */ 31, 140, 104, 462, 247, 248, 249, 250, 145, 253,
/* 260 */ 450, 103, 28, 400, 390, 55, 253, 143, 414, 144,
/* 270 */ 107, 57, 41, 401, 60, 403, 439, 446, 124, 108,
/* 280 */ 281, 436, 34, 400, 390, 475, 95, 143, 414, 144,
/* 290 */ 5, 4, 47, 401, 34, 403, 141, 59, 400, 390,
/* 300 */ 374, 375, 143, 414, 144, 2, 34, 86, 401, 105,
/* 310 */ 403, 400, 390, 302, 456, 143, 414, 144, 16, 122,
/* 320 */ 86, 401, 121, 403, 27, 25, 23, 22, 21, 133,
/* 330 */ 508, 400, 390, 62, 106, 143, 414, 144, 49, 1,
/* 340 */ 86, 401, 97, 403, 400, 390, 64, 317, 143, 414,
/* 350 */ 144, 13, 29, 47, 401, 296, 403, 400, 390, 421,
/* 360 */ 257, 143, 414, 144, 44, 260, 86, 401, 102, 403,
/* 370 */ 451, 400, 390, 30, 65, 143, 414, 144, 261, 29,
/* 380 */ 83, 401, 264, 403, 400, 390, 510, 466, 143, 414,
/* 390 */ 144, 509, 139, 80, 401, 99, 403, 400, 390, 135,
/* 400 */ 142, 143, 414, 144, 258, 77, 84, 401, 397, 403,
/* 410 */ 395, 400, 390, 75, 491, 143, 414, 144, 10, 29,
/* 420 */ 81, 401, 11, 403, 400, 390, 35, 56, 143, 414,
/* 430 */ 144, 340, 58, 85, 401, 342, 403, 400, 390, 336,
/* 440 */ 48, 143, 414, 144, 61, 38, 411, 401, 335, 403,
/* 450 */ 116, 400, 390, 117, 39, 143, 414, 144, 395, 12,
/* 460 */ 410, 401, 4, 403, 400, 390, 282, 315, 143, 414,
/* 470 */ 144, 314, 32, 409, 401, 69, 403, 400, 390, 33,
/* 480 */ 394, 143, 414, 144, 51, 368, 92, 401, 14, 403,
/* 490 */ 9, 400, 390, 37, 357, 143, 414, 144, 363, 79,
/* 500 */ 91, 401, 362, 403, 400, 390, 100, 367, 143, 414,
/* 510 */ 144, 366, 101, 93, 401, 251, 403, 400, 390, 384,
/* 520 */ 383, 143, 414, 144, 15, 147, 90, 401, 382, 403,
/* 530 */ 382, 400, 390, 382, 382, 143, 414, 144, 382, 382,
/* 540 */ 82, 401, 382, 403, 400, 390, 382, 382, 143, 414,
/* 550 */ 144, 382, 382, 87, 401, 382, 403, 127, 45, 382,
/* 560 */ 382, 382, 127, 45, 382, 382, 43, 382, 382, 382,
/* 570 */ 382, 43, 382, 382, 129, 66, 444, 445, 382, 444,
/* 580 */ 68, 444, 126, 382, 125, 382, 382, 127, 45, 382,
/* 590 */ 382, 382, 127, 45, 382, 382, 43, 382, 382, 382,
/* 600 */ 382, 43, 382, 381, 146, 50, 444, 445, 382, 444,
/* 610 */ 71, 444, 445, 382, 444, 27, 25, 23, 22, 21,
/* 620 */ 27, 25, 23, 22, 21, 382, 382, 382, 382, 261,
/* 630 */ 382, 382, 18, 494, 382, 382, 266, 382, 27, 25,
/* 640 */ 23, 22, 21, 382, 382, 382, 53, 382, 73, 382,
/* 650 */ 492, 27, 25, 23, 22, 21,
};
static const YYCODETYPE yy_lookahead[] = {
/* 0 */ 47, 48, 73, 50, 51, 52, 55, 54, 55, 92,
/* 10 */ 57, 58, 59, 60, 61, 62, 15, 16, 17, 18,
/* 20 */ 19, 20, 21, 22, 1, 2, 53, 54, 64, 65,
/* 30 */ 77, 9, 10, 11, 12, 62, 83, 84, 3, 22,
/* 40 */ 39, 68, 69, 70, 86, 72, 23, 94, 95, 96,
/* 50 */ 97, 47, 48, 20, 50, 51, 52, 22, 54, 55,
/* 60 */ 27, 57, 58, 59, 60, 61, 62, 29, 30, 63,
/* 70 */ 64, 65, 63, 64, 65, 63, 64, 65, 47, 48,
/* 80 */ 74, 50, 51, 52, 23, 54, 55, 26, 57, 58,
/* 90 */ 59, 60, 61, 62, 90, 91, 9, 10, 94, 95,
/* 100 */ 96, 97, 15, 20, 86, 22, 47, 48, 56, 50,
/* 110 */ 51, 52, 76, 54, 55, 84, 57, 58, 59, 60,
/* 120 */ 61, 62, 39, 71, 5, 94, 95, 96, 97, 47,
/* 130 */ 48, 56, 50, 51, 52, 30, 54, 55, 20, 57,
/* 140 */ 58, 59, 60, 61, 62, 27, 71, 63, 64, 65,
/* 150 */ 91, 32, 20, 94, 95, 96, 97, 47, 48, 56,
/* 160 */ 50, 51, 52, 54, 54, 55, 22, 57, 58, 59,
/* 170 */ 60, 61, 62, 11, 71, 31, 94, 95, 96, 97,
/* 180 */ 47, 48, 20, 50, 51, 52, 75, 54, 55, 75,
/* 190 */ 57, 58, 59, 60, 61, 62, 85, 40, 41, 85,
/* 200 */ 89, 11, 12, 89, 94, 95, 96, 97, 47, 48,
/* 210 */ 56, 50, 51, 52, 20, 54, 55, 25, 57, 58,
/* 220 */ 42, 60, 61, 62, 47, 26, 49, 94, 95, 96,
/* 230 */ 97, 47, 48, 66, 50, 51, 52, 38, 54, 55,
/* 240 */ 93, 57, 58, 13, 60, 61, 62, 47, 47, 49,
/* 250 */ 49, 47, 22, 49, 47, 94, 49, 96, 97, 47,
/* 260 */ 48, 31, 50, 51, 52, 4, 54, 55, 35, 57,
/* 270 */ 58, 37, 60, 61, 62, 47, 87, 49, 94, 88,
/* 280 */ 96, 97, 47, 48, 15, 50, 51, 52, 47, 54,
/* 290 */ 55, 47, 57, 58, 33, 60, 61, 62, 1, 2,
/* 300 */ 43, 44, 26, 22, 88, 24, 94, 87, 96, 97,
/* 310 */ 47, 48, 36, 50, 51, 52, 20, 54, 55, 82,
/* 320 */ 57, 58, 80, 60, 61, 62, 81, 79, 78, 94,
/* 330 */ 20, 96, 97, 47, 48, 26, 50, 51, 52, 2,
/* 340 */ 54, 55, 23, 57, 58, 23, 60, 61, 62, 24,
/* 350 */ 26, 28, 24, 24, 23, 23, 5, 94, 9, 10,
/* 360 */ 97, 26, 23, 23, 15, 16, 17, 18, 19, 20,
/* 370 */ 21, 22, 34, 0, 24, 45, 46, 0, 14, 46,
/* 380 */ 94, 98, 98, 97, 98, 98, 98, 98, 39, 98,
/* 390 */ 9, 10, 11, 98, 98, 98, 15, 16, 17, 18,
/* 400 */ 19, 20, 21, 22, 98, 75, 98, 98, 75, 98,
/* 410 */ 98, 98, 53, 54, 98, 85, 98, 98, 85, 89,
/* 420 */ 39, 62, 89, 53, 54, 98, 67, 68, 69, 70,
/* 430 */ 98, 72, 62, 98, 98, 98, 98, 98, 68, 69,
/* 440 */ 70, 98, 72, 98, 53, 54, 98, 98, 98, 98,
/* 450 */ 98, 98, 98, 62, 98, 98, 98, 98, 98, 68,
/* 460 */ 69, 70, 98, 72,
/* 0 */ 75, 76, 77, 103, 89, 90, 75, 76, 8, 9,
/* 10 */ 10, 11, 12, 75, 76, 4, 116, 79, 80, 81,
/* 20 */ 120, 123, 84, 85, 24, 87, 26, 27, 28, 22,
/* 30 */ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
/* 40 */ 8, 9, 10, 11, 12, 10, 11, 12, 29, 83,
/* 50 */ 112, 15, 16, 17, 18, 19, 20, 46, 26, 27,
/* 60 */ 28, 74, 30, 31, 32, 33, 34, 35, 36, 37,
/* 70 */ 38, 39, 8, 9, 55, 56, 57, 58, 59, 15,
/* 80 */ 16, 17, 18, 19, 20, 22, 22, 23, 75, 76,
/* 90 */ 103, 27, 79, 80, 81, 43, 44, 84, 85, 115,
/* 100 */ 87, 88, 23, 116, 41, 92, 93, 120, 75, 76,
/* 110 */ 79, 80, 79, 80, 81, 102, 85, 84, 85, 101,
/* 120 */ 87, 88, 82, 13, 45, 92, 93, 82, 79, 80,
/* 130 */ 103, 67, 108, 23, 85, 102, 75, 76, 21, 99,
/* 140 */ 79, 80, 81, 116, 99, 84, 85, 120, 87, 88,
/* 150 */ 8, 9, 10, 92, 93, 45, 26, 15, 16, 17,
/* 160 */ 18, 19, 20, 102, 22, 23, 36, 75, 76, 39,
/* 170 */ 3, 79, 80, 81, 1, 2, 84, 85, 10, 87,
/* 180 */ 88, 64, 75, 76, 92, 93, 79, 80, 81, 80,
/* 190 */ 22, 84, 85, 117, 87, 88, 50, 51, 52, 92,
/* 200 */ 93, 75, 76, 71, 72, 79, 80, 81, 117, 67,
/* 210 */ 84, 85, 21, 87, 88, 24, 75, 76, 92, 93,
/* 220 */ 79, 80, 81, 8, 9, 84, 85, 104, 87, 62,
/* 230 */ 15, 16, 17, 18, 19, 20, 54, 22, 23, 114,
/* 240 */ 8, 9, 10, 11, 12, 53, 105, 8, 9, 22,
/* 250 */ 23, 21, 111, 112, 15, 16, 17, 18, 19, 20,
/* 260 */ 82, 22, 23, 75, 76, 113, 20, 79, 80, 81,
/* 270 */ 76, 21, 84, 85, 24, 87, 88, 99, 27, 76,
/* 280 */ 29, 93, 67, 75, 76, 114, 76, 79, 80, 81,
/* 290 */ 1, 2, 84, 85, 67, 87, 66, 113, 75, 76,
/* 300 */ 68, 69, 79, 80, 81, 61, 67, 84, 85, 86,
/* 310 */ 87, 75, 76, 24, 110, 79, 80, 81, 2, 60,
/* 320 */ 84, 85, 86, 87, 8, 9, 10, 11, 12, 121,
/* 330 */ 122, 75, 76, 109, 48, 79, 80, 81, 107, 47,
/* 340 */ 84, 85, 86, 87, 75, 76, 106, 44, 79, 80,
/* 350 */ 81, 23, 21, 84, 85, 24, 87, 75, 76, 91,
/* 360 */ 22, 79, 80, 81, 79, 22, 84, 85, 86, 87,
/* 370 */ 82, 75, 76, 40, 94, 79, 80, 81, 22, 21,
/* 380 */ 84, 85, 24, 87, 75, 76, 124, 83, 79, 80,
/* 390 */ 81, 122, 63, 84, 85, 70, 87, 75, 76, 118,
/* 400 */ 65, 79, 80, 81, 22, 118, 84, 85, 23, 87,
/* 410 */ 25, 75, 76, 119, 119, 79, 80, 81, 21, 21,
/* 420 */ 84, 85, 49, 87, 75, 76, 21, 24, 79, 80,
/* 430 */ 81, 24, 23, 84, 85, 24, 87, 75, 76, 24,
/* 440 */ 23, 79, 80, 81, 23, 23, 84, 85, 24, 87,
/* 450 */ 15, 75, 76, 21, 23, 79, 80, 81, 25, 49,
/* 460 */ 84, 85, 2, 87, 75, 76, 29, 24, 79, 80,
/* 470 */ 81, 24, 42, 84, 85, 25, 87, 75, 76, 21,
/* 480 */ 25, 79, 80, 81, 25, 24, 84, 85, 21, 87,
/* 490 */ 49, 75, 76, 4, 24, 79, 80, 81, 15, 25,
/* 500 */ 84, 85, 15, 87, 75, 76, 15, 15, 79, 80,
/* 510 */ 81, 15, 15, 84, 85, 17, 87, 75, 76, 0,
/* 520 */ 0, 79, 80, 81, 23, 14, 84, 85, 125, 87,
/* 530 */ 125, 75, 76, 125, 125, 79, 80, 81, 125, 125,
/* 540 */ 84, 85, 125, 87, 75, 76, 125, 125, 79, 80,
/* 550 */ 81, 125, 125, 84, 85, 125, 87, 78, 79, 125,
/* 560 */ 125, 125, 78, 79, 125, 125, 87, 125, 125, 125,
/* 570 */ 125, 87, 125, 125, 95, 96, 97, 98, 125, 100,
/* 580 */ 96, 97, 98, 125, 100, 125, 125, 78, 79, 125,
/* 590 */ 125, 125, 78, 79, 125, 125, 87, 125, 125, 125,
/* 600 */ 125, 87, 125, 73, 74, 96, 97, 98, 125, 100,
/* 610 */ 96, 97, 98, 125, 100, 8, 9, 10, 11, 12,
/* 620 */ 8, 9, 10, 11, 12, 125, 125, 125, 125, 22,
/* 630 */ 125, 125, 2, 103, 125, 125, 24, 125, 8, 9,
/* 640 */ 10, 11, 12, 125, 125, 125, 116, 125, 41, 125,
/* 650 */ 120, 8, 9, 10, 11, 12, 125, 125, 125, 125,
/* 660 */ 125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
/* 670 */ 125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
/* 680 */ 125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
/* 690 */ 125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
/* 700 */ 125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
/* 710 */ 125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
/* 720 */ 125, 125, 125, 125, 125,
};
#define YY_SHIFT_COUNT (91)
#define YY_SHIFT_COUNT (148)
#define YY_SHIFT_MIN (0)
#define YY_SHIFT_MAX (381)
#define YY_SHIFT_MAX (643)
static const unsigned short int yy_shift_ofst[] = {
/* 0 */ 230, 381, 349, 349, 349, 349, 349, 349, 349, 349,
/* 10 */ 349, 349, 1, 1, 83, 83, 83, 83, 35, 144,
/* 20 */ 35, 35, 35, 144, 144, 87, 87, 87, 87, 87,
/* 30 */ 87, 33, 33, 33, 17, 38, 162, 157, 261, 261,
/* 40 */ 119, 105, 105, 132, 194, 105, 192, 178, 233, 234,
/* 50 */ 269, 269, 234, 233, 296, 464, 464, 464, 464, 464,
/* 60 */ 22, 23, 118, 297, 61, 190, 190, 257, 276, 199,
/* 70 */ 281, 310, 309, 337, 319, 322, 325, 323, 324, 328,
/* 80 */ 329, 331, 332, 335, 338, 339, 351, 350, 340, 373,
/* 90 */ 377, 364,
/* 0 */ 110, 64, 64, 64, 64, 64, 64, 142, 215, 239,
/* 10 */ 239, 239, 239, 239, 239, 239, 239, 239, 239, 239,
/* 20 */ 239, 239, 239, 239, 239, 239, 239, 239, 239, 239,
/* 30 */ 227, 227, 227, 227, 79, 36, 79, 79, 7, 7,
/* 40 */ 0, 32, 36, 63, 63, 63, 607, 232, 19, 146,
/* 50 */ 52, 168, 167, 167, 11, 182, 192, 246, 246, 182,
/* 60 */ 192, 246, 244, 259, 286, 292, 303, 328, 303, 338,
/* 70 */ 343, 303, 333, 356, 325, 329, 335, 335, 329, 382,
/* 80 */ 316, 630, 612, 643, 643, 643, 643, 643, 289, 130,
/* 90 */ 35, 35, 35, 35, 191, 250, 173, 331, 251, 132,
/* 100 */ 117, 230, 358, 385, 397, 398, 373, 403, 407, 409,
/* 110 */ 405, 411, 417, 421, 415, 422, 424, 435, 432, 433,
/* 120 */ 431, 398, 410, 460, 437, 443, 447, 450, 430, 458,
/* 130 */ 455, 459, 461, 467, 441, 470, 489, 483, 487, 491,
/* 140 */ 492, 496, 497, 474, 501, 498, 519, 520, 511,
};
#define YY_REDUCE_COUNT (59)
#define YY_REDUCE_MIN (-83)
#define YY_REDUCE_MAX (391)
#define YY_REDUCE_COUNT (79)
#define YY_REDUCE_MIN (-102)
#define YY_REDUCE_MAX (530)
static const short yy_reduce_ofst[] = {
/* 0 */ 330, -47, 4, 31, 59, 82, 110, 133, 161, 184,
/* 10 */ 212, 235, 263, 286, 359, -27, 370, 391, 6, 333,
/* 20 */ 9, 12, 84, 111, 114, 177, 200, 201, 204, 207,
/* 30 */ 228, 52, 75, 103, -36, -71, -49, -83, -42, 18,
/* 40 */ 36, -71, -71, 109, 154, -71, 167, 147, 189, 191,
/* 50 */ 241, 244, 216, 220, -49, 237, 245, 242, 248, 250,
/* 0 */ 530, 13, 33, 61, 92, 107, 126, 141, 188, 208,
/* 10 */ -62, 223, 236, 256, 269, 282, 296, 309, 322, 336,
/* 20 */ 349, 362, 376, 389, 402, 416, 429, 442, 456, 469,
/* 30 */ 479, 484, 509, 514, -13, -75, -100, 27, 31, 49,
/* 40 */ -85, -85, -69, 40, 45, 178, -34, -102, -16, 24,
/* 50 */ 18, 109, 76, 91, 123, 125, 152, 194, 203, 171,
/* 60 */ 184, 210, 204, 224, 231, 240, 18, 268, 18, 285,
/* 70 */ 288, 18, 280, 304, 262, 281, 294, 295, 287, 109,
};
static const YYACTIONTYPE yy_default[] = {
/* 0 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275,
/* 10 */ 275, 275, 275, 275, 275, 275, 275, 275, 365, 275,
/* 20 */ 365, 365, 365, 275, 275, 275, 275, 275, 275, 275,
/* 30 */ 275, 305, 305, 305, 365, 275, 275, 344, 329, 329,
/* 40 */ 313, 298, 275, 275, 275, 299, 275, 347, 331, 335,
/* 50 */ 275, 275, 335, 331, 275, 370, 369, 368, 367, 366,
/* 60 */ 374, 275, 320, 340, 275, 379, 378, 275, 332, 336,
/* 70 */ 287, 275, 317, 293, 364, 301, 275, 275, 297, 286,
/* 80 */ 275, 275, 275, 330, 275, 275, 275, 275, 275, 275,
/* 90 */ 275, 275,
/* 0 */ 380, 380, 380, 380, 380, 380, 380, 380, 380, 380,
/* 10 */ 380, 380, 380, 380, 380, 380, 380, 380, 380, 380,
/* 20 */ 380, 380, 380, 380, 380, 380, 380, 380, 380, 380,
/* 30 */ 380, 380, 380, 380, 380, 380, 380, 380, 380, 380,
/* 40 */ 380, 380, 380, 449, 449, 449, 464, 511, 380, 472,
/* 50 */ 380, 380, 496, 496, 457, 479, 477, 380, 380, 479,
/* 60 */ 477, 380, 489, 487, 470, 468, 442, 380, 380, 380,
/* 70 */ 380, 443, 380, 380, 514, 498, 502, 502, 498, 380,
/* 80 */ 380, 380, 380, 418, 417, 416, 412, 413, 380, 380,
/* 90 */ 407, 408, 406, 405, 380, 380, 507, 380, 380, 380,
/* 100 */ 499, 503, 380, 396, 461, 471, 380, 380, 380, 380,
/* 110 */ 380, 380, 380, 380, 380, 380, 380, 380, 380, 396,
/* 120 */ 380, 488, 380, 437, 380, 517, 445, 380, 380, 441,
/* 130 */ 395, 380, 380, 497, 380, 380, 380, 380, 380, 380,
/* 140 */ 380, 380, 380, 380, 380, 380, 380, 380, 380,
};
/********** End of lemon-generated parsing tables *****************************/
......@@ -451,101 +517,128 @@ static const char *const yyTokenName[] = {
/* 0 */ "$",
/* 1 */ "OR",
/* 2 */ "AND",
/* 3 */ "NOT",
/* 4 */ "UNION",
/* 5 */ "ALL",
/* 6 */ "MINUS",
/* 7 */ "EXCEPT",
/* 8 */ "INTERSECT",
/* 9 */ "NK_PLUS",
/* 10 */ "NK_MINUS",
/* 11 */ "NK_STAR",
/* 12 */ "NK_SLASH",
/* 3 */ "UNION",
/* 4 */ "ALL",
/* 5 */ "MINUS",
/* 6 */ "EXCEPT",
/* 7 */ "INTERSECT",
/* 8 */ "NK_PLUS",
/* 9 */ "NK_MINUS",
/* 10 */ "NK_STAR",
/* 11 */ "NK_SLASH",
/* 12 */ "NK_REM",
/* 13 */ "SHOW",
/* 14 */ "DATABASES",
/* 15 */ "NK_INTEGER",
/* 16 */ "NK_FLOAT",
/* 17 */ "NK_STRING",
/* 18 */ "NK_BOOL",
/* 19 */ "NK_NOW",
/* 20 */ "NK_ID",
/* 21 */ "NK_QUESTION",
/* 22 */ "NK_LP",
/* 23 */ "NK_RP",
/* 24 */ "NK_DOT",
/* 25 */ "FROM",
/* 26 */ "NK_COMMA",
/* 27 */ "AS",
/* 28 */ "JOIN",
/* 29 */ "ON",
/* 30 */ "INNER",
/* 31 */ "SELECT",
/* 32 */ "DISTINCT",
/* 33 */ "ORDER",
/* 34 */ "BY",
/* 35 */ "SLIMIT",
/* 36 */ "SOFFSET",
/* 37 */ "LIMIT",
/* 38 */ "OFFSET",
/* 39 */ "NK_LR",
/* 40 */ "ASC",
/* 41 */ "DESC",
/* 42 */ "NULLS",
/* 43 */ "FIRST",
/* 44 */ "LAST",
/* 45 */ "cmd",
/* 46 */ "query_expression",
/* 47 */ "unsigned_integer",
/* 48 */ "unsigned_approximate_numeric",
/* 49 */ "signed_integer",
/* 50 */ "unsigned_literal",
/* 51 */ "unsigned_numeric_literal",
/* 52 */ "general_literal",
/* 53 */ "db_name",
/* 54 */ "table_name",
/* 55 */ "column_name",
/* 56 */ "table_alias",
/* 57 */ "unsigned_value_specification",
/* 58 */ "value_expression_primary",
/* 59 */ "value_expression",
/* 60 */ "nonparenthesized_value_expression_primary",
/* 61 */ "column_reference",
/* 62 */ "subquery",
/* 63 */ "boolean_value_expression",
/* 64 */ "boolean_primary",
/* 65 */ "predicate",
/* 66 */ "from_clause",
/* 67 */ "table_reference_list",
/* 68 */ "table_reference",
/* 69 */ "table_primary",
/* 70 */ "joined_table",
/* 71 */ "correlation_or_recognition_opt",
/* 72 */ "parenthesized_joined_table",
/* 73 */ "join_type",
/* 74 */ "search_condition",
/* 75 */ "query_specification",
/* 76 */ "set_quantifier_opt",
/* 77 */ "select_list",
/* 78 */ "where_clause_opt",
/* 79 */ "partition_by_clause_opt",
/* 80 */ "twindow_clause_opt",
/* 81 */ "group_by_clause_opt",
/* 82 */ "having_clause_opt",
/* 83 */ "select_sublist",
/* 84 */ "select_item",
/* 85 */ "query_expression_body",
/* 86 */ "order_by_clause_opt",
/* 87 */ "slimit_clause_opt",
/* 88 */ "limit_clause_opt",
/* 89 */ "query_primary",
/* 90 */ "sort_specification_list",
/* 91 */ "sort_specification",
/* 92 */ "ordering_specification_opt",
/* 93 */ "null_ordering_opt",
/* 94 */ "value_function",
/* 95 */ "common_value_expression",
/* 96 */ "numeric_value_expression",
/* 97 */ "numeric_primary",
/* 19 */ "TIMESTAMP",
/* 20 */ "NK_VARIABLE",
/* 21 */ "NK_COMMA",
/* 22 */ "NK_ID",
/* 23 */ "NK_LP",
/* 24 */ "NK_RP",
/* 25 */ "NK_DOT",
/* 26 */ "BETWEEN",
/* 27 */ "NOT",
/* 28 */ "IS",
/* 29 */ "NULL",
/* 30 */ "NK_LT",
/* 31 */ "NK_GT",
/* 32 */ "NK_LE",
/* 33 */ "NK_GE",
/* 34 */ "NK_NE",
/* 35 */ "NK_EQ",
/* 36 */ "LIKE",
/* 37 */ "MATCH",
/* 38 */ "NMATCH",
/* 39 */ "IN",
/* 40 */ "FROM",
/* 41 */ "AS",
/* 42 */ "JOIN",
/* 43 */ "ON",
/* 44 */ "INNER",
/* 45 */ "SELECT",
/* 46 */ "DISTINCT",
/* 47 */ "WHERE",
/* 48 */ "PARTITION",
/* 49 */ "BY",
/* 50 */ "SESSION",
/* 51 */ "STATE_WINDOW",
/* 52 */ "INTERVAL",
/* 53 */ "SLIDING",
/* 54 */ "FILL",
/* 55 */ "VALUE",
/* 56 */ "NONE",
/* 57 */ "PREV",
/* 58 */ "LINEAR",
/* 59 */ "NEXT",
/* 60 */ "GROUP",
/* 61 */ "HAVING",
/* 62 */ "ORDER",
/* 63 */ "SLIMIT",
/* 64 */ "SOFFSET",
/* 65 */ "LIMIT",
/* 66 */ "OFFSET",
/* 67 */ "NK_LR",
/* 68 */ "ASC",
/* 69 */ "DESC",
/* 70 */ "NULLS",
/* 71 */ "FIRST",
/* 72 */ "LAST",
/* 73 */ "cmd",
/* 74 */ "query_expression",
/* 75 */ "literal",
/* 76 */ "duration_literal",
/* 77 */ "literal_list",
/* 78 */ "db_name",
/* 79 */ "table_name",
/* 80 */ "column_name",
/* 81 */ "function_name",
/* 82 */ "table_alias",
/* 83 */ "column_alias",
/* 84 */ "expression",
/* 85 */ "column_reference",
/* 86 */ "expression_list",
/* 87 */ "subquery",
/* 88 */ "predicate",
/* 89 */ "compare_op",
/* 90 */ "in_op",
/* 91 */ "in_predicate_value",
/* 92 */ "boolean_value_expression",
/* 93 */ "boolean_primary",
/* 94 */ "from_clause",
/* 95 */ "table_reference_list",
/* 96 */ "table_reference",
/* 97 */ "table_primary",
/* 98 */ "joined_table",
/* 99 */ "alias_opt",
/* 100 */ "parenthesized_joined_table",
/* 101 */ "join_type",
/* 102 */ "search_condition",
/* 103 */ "query_specification",
/* 104 */ "set_quantifier_opt",
/* 105 */ "select_list",
/* 106 */ "where_clause_opt",
/* 107 */ "partition_by_clause_opt",
/* 108 */ "twindow_clause_opt",
/* 109 */ "group_by_clause_opt",
/* 110 */ "having_clause_opt",
/* 111 */ "select_sublist",
/* 112 */ "select_item",
/* 113 */ "sliding_opt",
/* 114 */ "fill_opt",
/* 115 */ "fill_mode",
/* 116 */ "query_expression_body",
/* 117 */ "order_by_clause_opt",
/* 118 */ "slimit_clause_opt",
/* 119 */ "limit_clause_opt",
/* 120 */ "query_primary",
/* 121 */ "sort_specification_list",
/* 122 */ "sort_specification",
/* 123 */ "ordering_specification_opt",
/* 124 */ "null_ordering_opt",
};
#endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
......@@ -555,110 +648,139 @@ static const char *const yyTokenName[] = {
static const char *const yyRuleName[] = {
/* 0 */ "cmd ::= SHOW DATABASES",
/* 1 */ "cmd ::= query_expression",
/* 2 */ "unsigned_integer ::= NK_INTEGER",
/* 3 */ "unsigned_approximate_numeric ::= NK_FLOAT",
/* 4 */ "signed_integer ::= unsigned_integer",
/* 5 */ "signed_integer ::= NK_PLUS unsigned_integer",
/* 6 */ "signed_integer ::= NK_MINUS unsigned_integer",
/* 7 */ "db_name ::= NK_ID",
/* 8 */ "table_name ::= NK_ID",
/* 9 */ "column_name ::= NK_ID",
/* 10 */ "table_alias ::= NK_ID",
/* 11 */ "column_reference ::= column_name",
/* 12 */ "column_reference ::= table_name NK_DOT column_name",
/* 13 */ "boolean_value_expression ::= boolean_primary",
/* 14 */ "boolean_value_expression ::= NOT boolean_primary",
/* 15 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression",
/* 16 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression",
/* 17 */ "boolean_primary ::= predicate",
/* 18 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP",
/* 19 */ "from_clause ::= FROM table_reference_list",
/* 20 */ "table_reference_list ::= table_reference",
/* 21 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference",
/* 22 */ "table_reference ::= table_primary",
/* 23 */ "table_reference ::= joined_table",
/* 24 */ "table_primary ::= table_name correlation_or_recognition_opt",
/* 25 */ "table_primary ::= db_name NK_DOT table_name correlation_or_recognition_opt",
/* 26 */ "table_primary ::= subquery correlation_or_recognition_opt",
/* 27 */ "correlation_or_recognition_opt ::=",
/* 28 */ "correlation_or_recognition_opt ::= table_alias",
/* 29 */ "correlation_or_recognition_opt ::= AS table_alias",
/* 30 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP",
/* 31 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP",
/* 32 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition",
/* 33 */ "join_type ::= INNER",
/* 34 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt",
/* 35 */ "set_quantifier_opt ::=",
/* 36 */ "set_quantifier_opt ::= DISTINCT",
/* 37 */ "set_quantifier_opt ::= ALL",
/* 38 */ "select_list ::= NK_STAR",
/* 39 */ "select_list ::= select_sublist",
/* 40 */ "select_sublist ::= select_item",
/* 41 */ "select_sublist ::= select_sublist NK_COMMA select_item",
/* 42 */ "select_item ::= value_expression",
/* 43 */ "select_item ::= value_expression NK_ID",
/* 44 */ "select_item ::= value_expression AS NK_ID",
/* 45 */ "select_item ::= table_name NK_DOT NK_STAR",
/* 46 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt",
/* 47 */ "query_expression_body ::= query_primary",
/* 48 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body",
/* 49 */ "query_primary ::= query_specification",
/* 50 */ "query_primary ::= NK_LP query_expression_body order_by_clause_opt limit_clause_opt slimit_clause_opt NK_RP",
/* 51 */ "order_by_clause_opt ::=",
/* 52 */ "order_by_clause_opt ::= ORDER BY sort_specification_list",
/* 53 */ "slimit_clause_opt ::=",
/* 54 */ "slimit_clause_opt ::= SLIMIT signed_integer",
/* 55 */ "slimit_clause_opt ::= SLIMIT signed_integer SOFFSET signed_integer",
/* 56 */ "slimit_clause_opt ::= SLIMIT signed_integer NK_COMMA signed_integer",
/* 57 */ "limit_clause_opt ::=",
/* 58 */ "limit_clause_opt ::= LIMIT signed_integer",
/* 59 */ "limit_clause_opt ::= LIMIT signed_integer OFFSET signed_integer",
/* 60 */ "limit_clause_opt ::= LIMIT signed_integer NK_COMMA signed_integer",
/* 61 */ "subquery ::= NK_LR query_expression NK_RP",
/* 62 */ "search_condition ::= boolean_value_expression",
/* 63 */ "sort_specification_list ::= sort_specification",
/* 64 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification",
/* 65 */ "sort_specification ::= value_expression ordering_specification_opt null_ordering_opt",
/* 66 */ "ordering_specification_opt ::=",
/* 67 */ "ordering_specification_opt ::= ASC",
/* 68 */ "ordering_specification_opt ::= DESC",
/* 69 */ "null_ordering_opt ::=",
/* 70 */ "null_ordering_opt ::= NULLS FIRST",
/* 71 */ "null_ordering_opt ::= NULLS LAST",
/* 72 */ "unsigned_literal ::= unsigned_numeric_literal",
/* 73 */ "unsigned_literal ::= general_literal",
/* 74 */ "unsigned_numeric_literal ::= unsigned_integer",
/* 75 */ "unsigned_numeric_literal ::= unsigned_approximate_numeric",
/* 76 */ "general_literal ::= NK_STRING",
/* 77 */ "general_literal ::= NK_BOOL",
/* 78 */ "general_literal ::= NK_NOW",
/* 79 */ "unsigned_value_specification ::= unsigned_literal",
/* 80 */ "unsigned_value_specification ::= NK_QUESTION",
/* 81 */ "value_expression_primary ::= NK_LP value_expression NK_RP",
/* 82 */ "value_expression_primary ::= nonparenthesized_value_expression_primary",
/* 83 */ "nonparenthesized_value_expression_primary ::= unsigned_value_specification",
/* 84 */ "nonparenthesized_value_expression_primary ::= column_reference",
/* 85 */ "nonparenthesized_value_expression_primary ::= subquery",
/* 86 */ "table_primary ::= parenthesized_joined_table",
/* 87 */ "predicate ::=",
/* 88 */ "where_clause_opt ::=",
/* 89 */ "partition_by_clause_opt ::=",
/* 90 */ "twindow_clause_opt ::=",
/* 91 */ "group_by_clause_opt ::=",
/* 92 */ "having_clause_opt ::=",
/* 93 */ "value_function ::= NK_ID NK_LP value_expression NK_RP",
/* 94 */ "value_function ::= NK_ID NK_LP value_expression NK_COMMA value_expression NK_RP",
/* 95 */ "value_expression ::= common_value_expression",
/* 96 */ "common_value_expression ::= numeric_value_expression",
/* 97 */ "numeric_value_expression ::= numeric_primary",
/* 98 */ "numeric_value_expression ::= NK_PLUS numeric_primary",
/* 99 */ "numeric_value_expression ::= NK_MINUS numeric_primary",
/* 100 */ "numeric_value_expression ::= numeric_value_expression NK_PLUS numeric_value_expression",
/* 101 */ "numeric_value_expression ::= numeric_value_expression NK_MINUS numeric_value_expression",
/* 102 */ "numeric_value_expression ::= numeric_value_expression NK_STAR numeric_value_expression",
/* 103 */ "numeric_value_expression ::= numeric_value_expression NK_SLASH numeric_value_expression",
/* 104 */ "numeric_primary ::= value_expression_primary",
/* 105 */ "numeric_primary ::= value_function",
/* 2 */ "literal ::= NK_INTEGER",
/* 3 */ "literal ::= NK_FLOAT",
/* 4 */ "literal ::= NK_STRING",
/* 5 */ "literal ::= NK_BOOL",
/* 6 */ "literal ::= TIMESTAMP NK_STRING",
/* 7 */ "literal ::= duration_literal",
/* 8 */ "duration_literal ::= NK_VARIABLE",
/* 9 */ "literal_list ::= literal",
/* 10 */ "literal_list ::= literal_list NK_COMMA literal",
/* 11 */ "db_name ::= NK_ID",
/* 12 */ "table_name ::= NK_ID",
/* 13 */ "column_name ::= NK_ID",
/* 14 */ "function_name ::= NK_ID",
/* 15 */ "table_alias ::= NK_ID",
/* 16 */ "column_alias ::= NK_ID",
/* 17 */ "expression ::= literal",
/* 18 */ "expression ::= column_reference",
/* 19 */ "expression ::= function_name NK_LP expression_list NK_RP",
/* 20 */ "expression ::= subquery",
/* 21 */ "expression ::= NK_LP expression NK_RP",
/* 22 */ "expression ::= NK_PLUS expression",
/* 23 */ "expression ::= NK_MINUS expression",
/* 24 */ "expression ::= expression NK_PLUS expression",
/* 25 */ "expression ::= expression NK_MINUS expression",
/* 26 */ "expression ::= expression NK_STAR expression",
/* 27 */ "expression ::= expression NK_SLASH expression",
/* 28 */ "expression ::= expression NK_REM expression",
/* 29 */ "expression_list ::= expression",
/* 30 */ "expression_list ::= expression_list NK_COMMA expression",
/* 31 */ "column_reference ::= column_name",
/* 32 */ "column_reference ::= table_name NK_DOT column_name",
/* 33 */ "predicate ::= expression compare_op expression",
/* 34 */ "predicate ::= expression BETWEEN expression AND expression",
/* 35 */ "predicate ::= expression NOT BETWEEN expression AND expression",
/* 36 */ "predicate ::= expression IS NULL",
/* 37 */ "predicate ::= expression IS NOT NULL",
/* 38 */ "predicate ::= expression in_op in_predicate_value",
/* 39 */ "compare_op ::= NK_LT",
/* 40 */ "compare_op ::= NK_GT",
/* 41 */ "compare_op ::= NK_LE",
/* 42 */ "compare_op ::= NK_GE",
/* 43 */ "compare_op ::= NK_NE",
/* 44 */ "compare_op ::= NK_EQ",
/* 45 */ "compare_op ::= LIKE",
/* 46 */ "compare_op ::= NOT LIKE",
/* 47 */ "compare_op ::= MATCH",
/* 48 */ "compare_op ::= NMATCH",
/* 49 */ "in_op ::= IN",
/* 50 */ "in_op ::= NOT IN",
/* 51 */ "in_predicate_value ::= NK_LP expression_list NK_RP",
/* 52 */ "boolean_value_expression ::= boolean_primary",
/* 53 */ "boolean_value_expression ::= NOT boolean_primary",
/* 54 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression",
/* 55 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression",
/* 56 */ "boolean_primary ::= predicate",
/* 57 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP",
/* 58 */ "from_clause ::= FROM table_reference_list",
/* 59 */ "table_reference_list ::= table_reference",
/* 60 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference",
/* 61 */ "table_reference ::= table_primary",
/* 62 */ "table_reference ::= joined_table",
/* 63 */ "table_primary ::= table_name alias_opt",
/* 64 */ "table_primary ::= db_name NK_DOT table_name alias_opt",
/* 65 */ "table_primary ::= subquery alias_opt",
/* 66 */ "alias_opt ::=",
/* 67 */ "alias_opt ::= table_alias",
/* 68 */ "alias_opt ::= AS table_alias",
/* 69 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP",
/* 70 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP",
/* 71 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition",
/* 72 */ "join_type ::= INNER",
/* 73 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt",
/* 74 */ "set_quantifier_opt ::=",
/* 75 */ "set_quantifier_opt ::= DISTINCT",
/* 76 */ "set_quantifier_opt ::= ALL",
/* 77 */ "select_list ::= NK_STAR",
/* 78 */ "select_list ::= select_sublist",
/* 79 */ "select_sublist ::= select_item",
/* 80 */ "select_sublist ::= select_sublist NK_COMMA select_item",
/* 81 */ "select_item ::= expression",
/* 82 */ "select_item ::= expression column_alias",
/* 83 */ "select_item ::= expression AS column_alias",
/* 84 */ "select_item ::= table_name NK_DOT NK_STAR",
/* 85 */ "where_clause_opt ::=",
/* 86 */ "where_clause_opt ::= WHERE search_condition",
/* 87 */ "partition_by_clause_opt ::=",
/* 88 */ "partition_by_clause_opt ::= PARTITION BY expression_list",
/* 89 */ "twindow_clause_opt ::=",
/* 90 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP",
/* 91 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP",
/* 92 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt",
/* 93 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt",
/* 94 */ "sliding_opt ::=",
/* 95 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP",
/* 96 */ "fill_opt ::=",
/* 97 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP",
/* 98 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP",
/* 99 */ "fill_mode ::= NONE",
/* 100 */ "fill_mode ::= PREV",
/* 101 */ "fill_mode ::= NULL",
/* 102 */ "fill_mode ::= LINEAR",
/* 103 */ "fill_mode ::= NEXT",
/* 104 */ "group_by_clause_opt ::=",
/* 105 */ "group_by_clause_opt ::= GROUP BY expression_list",
/* 106 */ "having_clause_opt ::=",
/* 107 */ "having_clause_opt ::= HAVING search_condition",
/* 108 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt",
/* 109 */ "query_expression_body ::= query_primary",
/* 110 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body",
/* 111 */ "query_primary ::= query_specification",
/* 112 */ "query_primary ::= NK_LP query_expression_body order_by_clause_opt limit_clause_opt slimit_clause_opt NK_RP",
/* 113 */ "order_by_clause_opt ::=",
/* 114 */ "order_by_clause_opt ::= ORDER BY sort_specification_list",
/* 115 */ "slimit_clause_opt ::=",
/* 116 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER",
/* 117 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER",
/* 118 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER",
/* 119 */ "limit_clause_opt ::=",
/* 120 */ "limit_clause_opt ::= LIMIT NK_INTEGER",
/* 121 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER",
/* 122 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER",
/* 123 */ "subquery ::= NK_LR query_expression NK_RP",
/* 124 */ "search_condition ::= boolean_value_expression",
/* 125 */ "sort_specification_list ::= sort_specification",
/* 126 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification",
/* 127 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt",
/* 128 */ "ordering_specification_opt ::=",
/* 129 */ "ordering_specification_opt ::= ASC",
/* 130 */ "ordering_specification_opt ::= DESC",
/* 131 */ "null_ordering_opt ::=",
/* 132 */ "null_ordering_opt ::= NULLS FIRST",
/* 133 */ "null_ordering_opt ::= NULLS LAST",
/* 134 */ "table_primary ::= parenthesized_joined_table",
};
#endif /* NDEBUG */
......@@ -785,83 +907,90 @@ static void yy_destructor(
*/
/********* Begin destructor definitions ***************************************/
/* Default NON-TERMINAL Destructor */
case 45: /* cmd */
case 46: /* query_expression */
case 47: /* unsigned_integer */
case 48: /* unsigned_approximate_numeric */
case 49: /* signed_integer */
case 50: /* unsigned_literal */
case 51: /* unsigned_numeric_literal */
case 52: /* general_literal */
case 57: /* unsigned_value_specification */
case 58: /* value_expression_primary */
case 59: /* value_expression */
case 60: /* nonparenthesized_value_expression_primary */
case 61: /* column_reference */
case 62: /* subquery */
case 63: /* boolean_value_expression */
case 64: /* boolean_primary */
case 65: /* predicate */
case 66: /* from_clause */
case 67: /* table_reference_list */
case 68: /* table_reference */
case 69: /* table_primary */
case 70: /* joined_table */
case 72: /* parenthesized_joined_table */
case 74: /* search_condition */
case 75: /* query_specification */
case 78: /* where_clause_opt */
case 80: /* twindow_clause_opt */
case 82: /* having_clause_opt */
case 84: /* select_item */
case 85: /* query_expression_body */
case 87: /* slimit_clause_opt */
case 88: /* limit_clause_opt */
case 89: /* query_primary */
case 91: /* sort_specification */
case 94: /* value_function */
case 95: /* common_value_expression */
case 96: /* numeric_value_expression */
case 97: /* numeric_primary */
case 73: /* cmd */
case 74: /* query_expression */
case 75: /* literal */
case 76: /* duration_literal */
case 84: /* expression */
case 85: /* column_reference */
case 87: /* subquery */
case 88: /* predicate */
case 91: /* in_predicate_value */
case 92: /* boolean_value_expression */
case 93: /* boolean_primary */
case 94: /* from_clause */
case 95: /* table_reference_list */
case 96: /* table_reference */
case 97: /* table_primary */
case 98: /* joined_table */
case 100: /* parenthesized_joined_table */
case 102: /* search_condition */
case 103: /* query_specification */
case 106: /* where_clause_opt */
case 108: /* twindow_clause_opt */
case 110: /* having_clause_opt */
case 112: /* select_item */
case 113: /* sliding_opt */
case 114: /* fill_opt */
case 116: /* query_expression_body */
case 118: /* slimit_clause_opt */
case 119: /* limit_clause_opt */
case 120: /* query_primary */
case 122: /* sort_specification */
{
PARSER_DESTRUCTOR_TRACE; nodesDestroyNode((yypminor->yy212));
}
break;
case 77: /* literal_list */
case 86: /* expression_list */
case 105: /* select_list */
case 107: /* partition_by_clause_opt */
case 109: /* group_by_clause_opt */
case 111: /* select_sublist */
case 117: /* order_by_clause_opt */
case 121: /* sort_specification_list */
{
PARSER_DESTRUCTOR_TRACE; nodesDestroyNode((yypminor->yy168));
PARSER_DESTRUCTOR_TRACE; nodesDestroyList((yypminor->yy174));
}
break;
case 53: /* db_name */
case 54: /* table_name */
case 55: /* column_name */
case 56: /* table_alias */
case 71: /* correlation_or_recognition_opt */
case 78: /* db_name */
case 79: /* table_name */
case 80: /* column_name */
case 81: /* function_name */
case 82: /* table_alias */
case 83: /* column_alias */
case 99: /* alias_opt */
{
PARSER_DESTRUCTOR_TRACE;
}
break;
case 73: /* join_type */
case 89: /* compare_op */
case 90: /* in_op */
{
PARSER_DESTRUCTOR_TRACE;
}
break;
case 76: /* set_quantifier_opt */
case 101: /* join_type */
{
PARSER_DESTRUCTOR_TRACE;
}
break;
case 77: /* select_list */
case 79: /* partition_by_clause_opt */
case 81: /* group_by_clause_opt */
case 83: /* select_sublist */
case 86: /* order_by_clause_opt */
case 90: /* sort_specification_list */
case 104: /* set_quantifier_opt */
{
PARSER_DESTRUCTOR_TRACE; nodesDestroyList((yypminor->yy40));
PARSER_DESTRUCTOR_TRACE;
}
break;
case 92: /* ordering_specification_opt */
case 115: /* fill_mode */
{
PARSER_DESTRUCTOR_TRACE;
}
break;
case 93: /* null_ordering_opt */
case 123: /* ordering_specification_opt */
{
PARSER_DESTRUCTOR_TRACE;
}
break;
case 124: /* null_ordering_opt */
{
PARSER_DESTRUCTOR_TRACE;
}
......@@ -1160,112 +1289,141 @@ static const struct {
YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
signed char nrhs; /* Negative of the number of RHS symbols in the rule */
} yyRuleInfo[] = {
{ 45, -2 }, /* (0) cmd ::= SHOW DATABASES */
{ 45, -1 }, /* (1) cmd ::= query_expression */
{ 47, -1 }, /* (2) unsigned_integer ::= NK_INTEGER */
{ 48, -1 }, /* (3) unsigned_approximate_numeric ::= NK_FLOAT */
{ 49, -1 }, /* (4) signed_integer ::= unsigned_integer */
{ 49, -2 }, /* (5) signed_integer ::= NK_PLUS unsigned_integer */
{ 49, -2 }, /* (6) signed_integer ::= NK_MINUS unsigned_integer */
{ 53, -1 }, /* (7) db_name ::= NK_ID */
{ 54, -1 }, /* (8) table_name ::= NK_ID */
{ 55, -1 }, /* (9) column_name ::= NK_ID */
{ 56, -1 }, /* (10) table_alias ::= NK_ID */
{ 61, -1 }, /* (11) column_reference ::= column_name */
{ 61, -3 }, /* (12) column_reference ::= table_name NK_DOT column_name */
{ 63, -1 }, /* (13) boolean_value_expression ::= boolean_primary */
{ 63, -2 }, /* (14) boolean_value_expression ::= NOT boolean_primary */
{ 63, -3 }, /* (15) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */
{ 63, -3 }, /* (16) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */
{ 64, -1 }, /* (17) boolean_primary ::= predicate */
{ 64, -3 }, /* (18) boolean_primary ::= NK_LP boolean_value_expression NK_RP */
{ 66, -2 }, /* (19) from_clause ::= FROM table_reference_list */
{ 67, -1 }, /* (20) table_reference_list ::= table_reference */
{ 67, -3 }, /* (21) table_reference_list ::= table_reference_list NK_COMMA table_reference */
{ 68, -1 }, /* (22) table_reference ::= table_primary */
{ 68, -1 }, /* (23) table_reference ::= joined_table */
{ 69, -2 }, /* (24) table_primary ::= table_name correlation_or_recognition_opt */
{ 69, -4 }, /* (25) table_primary ::= db_name NK_DOT table_name correlation_or_recognition_opt */
{ 69, -2 }, /* (26) table_primary ::= subquery correlation_or_recognition_opt */
{ 71, 0 }, /* (27) correlation_or_recognition_opt ::= */
{ 71, -1 }, /* (28) correlation_or_recognition_opt ::= table_alias */
{ 71, -2 }, /* (29) correlation_or_recognition_opt ::= AS table_alias */
{ 72, -3 }, /* (30) parenthesized_joined_table ::= NK_LP joined_table NK_RP */
{ 72, -3 }, /* (31) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */
{ 70, -6 }, /* (32) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */
{ 73, -1 }, /* (33) join_type ::= INNER */
{ 75, -9 }, /* (34) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */
{ 76, 0 }, /* (35) set_quantifier_opt ::= */
{ 76, -1 }, /* (36) set_quantifier_opt ::= DISTINCT */
{ 76, -1 }, /* (37) set_quantifier_opt ::= ALL */
{ 77, -1 }, /* (38) select_list ::= NK_STAR */
{ 77, -1 }, /* (39) select_list ::= select_sublist */
{ 83, -1 }, /* (40) select_sublist ::= select_item */
{ 83, -3 }, /* (41) select_sublist ::= select_sublist NK_COMMA select_item */
{ 84, -1 }, /* (42) select_item ::= value_expression */
{ 84, -2 }, /* (43) select_item ::= value_expression NK_ID */
{ 84, -3 }, /* (44) select_item ::= value_expression AS NK_ID */
{ 84, -3 }, /* (45) select_item ::= table_name NK_DOT NK_STAR */
{ 46, -4 }, /* (46) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */
{ 85, -1 }, /* (47) query_expression_body ::= query_primary */
{ 85, -4 }, /* (48) query_expression_body ::= query_expression_body UNION ALL query_expression_body */
{ 89, -1 }, /* (49) query_primary ::= query_specification */
{ 89, -6 }, /* (50) query_primary ::= NK_LP query_expression_body order_by_clause_opt limit_clause_opt slimit_clause_opt NK_RP */
{ 86, 0 }, /* (51) order_by_clause_opt ::= */
{ 86, -3 }, /* (52) order_by_clause_opt ::= ORDER BY sort_specification_list */
{ 87, 0 }, /* (53) slimit_clause_opt ::= */
{ 87, -2 }, /* (54) slimit_clause_opt ::= SLIMIT signed_integer */
{ 87, -4 }, /* (55) slimit_clause_opt ::= SLIMIT signed_integer SOFFSET signed_integer */
{ 87, -4 }, /* (56) slimit_clause_opt ::= SLIMIT signed_integer NK_COMMA signed_integer */
{ 88, 0 }, /* (57) limit_clause_opt ::= */
{ 88, -2 }, /* (58) limit_clause_opt ::= LIMIT signed_integer */
{ 88, -4 }, /* (59) limit_clause_opt ::= LIMIT signed_integer OFFSET signed_integer */
{ 88, -4 }, /* (60) limit_clause_opt ::= LIMIT signed_integer NK_COMMA signed_integer */
{ 62, -3 }, /* (61) subquery ::= NK_LR query_expression NK_RP */
{ 74, -1 }, /* (62) search_condition ::= boolean_value_expression */
{ 90, -1 }, /* (63) sort_specification_list ::= sort_specification */
{ 90, -3 }, /* (64) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */
{ 91, -3 }, /* (65) sort_specification ::= value_expression ordering_specification_opt null_ordering_opt */
{ 92, 0 }, /* (66) ordering_specification_opt ::= */
{ 92, -1 }, /* (67) ordering_specification_opt ::= ASC */
{ 92, -1 }, /* (68) ordering_specification_opt ::= DESC */
{ 93, 0 }, /* (69) null_ordering_opt ::= */
{ 93, -2 }, /* (70) null_ordering_opt ::= NULLS FIRST */
{ 93, -2 }, /* (71) null_ordering_opt ::= NULLS LAST */
{ 50, -1 }, /* (72) unsigned_literal ::= unsigned_numeric_literal */
{ 50, -1 }, /* (73) unsigned_literal ::= general_literal */
{ 51, -1 }, /* (74) unsigned_numeric_literal ::= unsigned_integer */
{ 51, -1 }, /* (75) unsigned_numeric_literal ::= unsigned_approximate_numeric */
{ 52, -1 }, /* (76) general_literal ::= NK_STRING */
{ 52, -1 }, /* (77) general_literal ::= NK_BOOL */
{ 52, -1 }, /* (78) general_literal ::= NK_NOW */
{ 57, -1 }, /* (79) unsigned_value_specification ::= unsigned_literal */
{ 57, -1 }, /* (80) unsigned_value_specification ::= NK_QUESTION */
{ 58, -3 }, /* (81) value_expression_primary ::= NK_LP value_expression NK_RP */
{ 58, -1 }, /* (82) value_expression_primary ::= nonparenthesized_value_expression_primary */
{ 60, -1 }, /* (83) nonparenthesized_value_expression_primary ::= unsigned_value_specification */
{ 60, -1 }, /* (84) nonparenthesized_value_expression_primary ::= column_reference */
{ 60, -1 }, /* (85) nonparenthesized_value_expression_primary ::= subquery */
{ 69, -1 }, /* (86) table_primary ::= parenthesized_joined_table */
{ 65, 0 }, /* (87) predicate ::= */
{ 78, 0 }, /* (88) where_clause_opt ::= */
{ 79, 0 }, /* (89) partition_by_clause_opt ::= */
{ 80, 0 }, /* (90) twindow_clause_opt ::= */
{ 81, 0 }, /* (91) group_by_clause_opt ::= */
{ 82, 0 }, /* (92) having_clause_opt ::= */
{ 94, -4 }, /* (93) value_function ::= NK_ID NK_LP value_expression NK_RP */
{ 94, -6 }, /* (94) value_function ::= NK_ID NK_LP value_expression NK_COMMA value_expression NK_RP */
{ 59, -1 }, /* (95) value_expression ::= common_value_expression */
{ 95, -1 }, /* (96) common_value_expression ::= numeric_value_expression */
{ 96, -1 }, /* (97) numeric_value_expression ::= numeric_primary */
{ 96, -2 }, /* (98) numeric_value_expression ::= NK_PLUS numeric_primary */
{ 96, -2 }, /* (99) numeric_value_expression ::= NK_MINUS numeric_primary */
{ 96, -3 }, /* (100) numeric_value_expression ::= numeric_value_expression NK_PLUS numeric_value_expression */
{ 96, -3 }, /* (101) numeric_value_expression ::= numeric_value_expression NK_MINUS numeric_value_expression */
{ 96, -3 }, /* (102) numeric_value_expression ::= numeric_value_expression NK_STAR numeric_value_expression */
{ 96, -3 }, /* (103) numeric_value_expression ::= numeric_value_expression NK_SLASH numeric_value_expression */
{ 97, -1 }, /* (104) numeric_primary ::= value_expression_primary */
{ 97, -1 }, /* (105) numeric_primary ::= value_function */
{ 73, -2 }, /* (0) cmd ::= SHOW DATABASES */
{ 73, -1 }, /* (1) cmd ::= query_expression */
{ 75, -1 }, /* (2) literal ::= NK_INTEGER */
{ 75, -1 }, /* (3) literal ::= NK_FLOAT */
{ 75, -1 }, /* (4) literal ::= NK_STRING */
{ 75, -1 }, /* (5) literal ::= NK_BOOL */
{ 75, -2 }, /* (6) literal ::= TIMESTAMP NK_STRING */
{ 75, -1 }, /* (7) literal ::= duration_literal */
{ 76, -1 }, /* (8) duration_literal ::= NK_VARIABLE */
{ 77, -1 }, /* (9) literal_list ::= literal */
{ 77, -3 }, /* (10) literal_list ::= literal_list NK_COMMA literal */
{ 78, -1 }, /* (11) db_name ::= NK_ID */
{ 79, -1 }, /* (12) table_name ::= NK_ID */
{ 80, -1 }, /* (13) column_name ::= NK_ID */
{ 81, -1 }, /* (14) function_name ::= NK_ID */
{ 82, -1 }, /* (15) table_alias ::= NK_ID */
{ 83, -1 }, /* (16) column_alias ::= NK_ID */
{ 84, -1 }, /* (17) expression ::= literal */
{ 84, -1 }, /* (18) expression ::= column_reference */
{ 84, -4 }, /* (19) expression ::= function_name NK_LP expression_list NK_RP */
{ 84, -1 }, /* (20) expression ::= subquery */
{ 84, -3 }, /* (21) expression ::= NK_LP expression NK_RP */
{ 84, -2 }, /* (22) expression ::= NK_PLUS expression */
{ 84, -2 }, /* (23) expression ::= NK_MINUS expression */
{ 84, -3 }, /* (24) expression ::= expression NK_PLUS expression */
{ 84, -3 }, /* (25) expression ::= expression NK_MINUS expression */
{ 84, -3 }, /* (26) expression ::= expression NK_STAR expression */
{ 84, -3 }, /* (27) expression ::= expression NK_SLASH expression */
{ 84, -3 }, /* (28) expression ::= expression NK_REM expression */
{ 86, -1 }, /* (29) expression_list ::= expression */
{ 86, -3 }, /* (30) expression_list ::= expression_list NK_COMMA expression */
{ 85, -1 }, /* (31) column_reference ::= column_name */
{ 85, -3 }, /* (32) column_reference ::= table_name NK_DOT column_name */
{ 88, -3 }, /* (33) predicate ::= expression compare_op expression */
{ 88, -5 }, /* (34) predicate ::= expression BETWEEN expression AND expression */
{ 88, -6 }, /* (35) predicate ::= expression NOT BETWEEN expression AND expression */
{ 88, -3 }, /* (36) predicate ::= expression IS NULL */
{ 88, -4 }, /* (37) predicate ::= expression IS NOT NULL */
{ 88, -3 }, /* (38) predicate ::= expression in_op in_predicate_value */
{ 89, -1 }, /* (39) compare_op ::= NK_LT */
{ 89, -1 }, /* (40) compare_op ::= NK_GT */
{ 89, -1 }, /* (41) compare_op ::= NK_LE */
{ 89, -1 }, /* (42) compare_op ::= NK_GE */
{ 89, -1 }, /* (43) compare_op ::= NK_NE */
{ 89, -1 }, /* (44) compare_op ::= NK_EQ */
{ 89, -1 }, /* (45) compare_op ::= LIKE */
{ 89, -2 }, /* (46) compare_op ::= NOT LIKE */
{ 89, -1 }, /* (47) compare_op ::= MATCH */
{ 89, -1 }, /* (48) compare_op ::= NMATCH */
{ 90, -1 }, /* (49) in_op ::= IN */
{ 90, -2 }, /* (50) in_op ::= NOT IN */
{ 91, -3 }, /* (51) in_predicate_value ::= NK_LP expression_list NK_RP */
{ 92, -1 }, /* (52) boolean_value_expression ::= boolean_primary */
{ 92, -2 }, /* (53) boolean_value_expression ::= NOT boolean_primary */
{ 92, -3 }, /* (54) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */
{ 92, -3 }, /* (55) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */
{ 93, -1 }, /* (56) boolean_primary ::= predicate */
{ 93, -3 }, /* (57) boolean_primary ::= NK_LP boolean_value_expression NK_RP */
{ 94, -2 }, /* (58) from_clause ::= FROM table_reference_list */
{ 95, -1 }, /* (59) table_reference_list ::= table_reference */
{ 95, -3 }, /* (60) table_reference_list ::= table_reference_list NK_COMMA table_reference */
{ 96, -1 }, /* (61) table_reference ::= table_primary */
{ 96, -1 }, /* (62) table_reference ::= joined_table */
{ 97, -2 }, /* (63) table_primary ::= table_name alias_opt */
{ 97, -4 }, /* (64) table_primary ::= db_name NK_DOT table_name alias_opt */
{ 97, -2 }, /* (65) table_primary ::= subquery alias_opt */
{ 99, 0 }, /* (66) alias_opt ::= */
{ 99, -1 }, /* (67) alias_opt ::= table_alias */
{ 99, -2 }, /* (68) alias_opt ::= AS table_alias */
{ 100, -3 }, /* (69) parenthesized_joined_table ::= NK_LP joined_table NK_RP */
{ 100, -3 }, /* (70) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */
{ 98, -6 }, /* (71) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */
{ 101, -1 }, /* (72) join_type ::= INNER */
{ 103, -9 }, /* (73) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */
{ 104, 0 }, /* (74) set_quantifier_opt ::= */
{ 104, -1 }, /* (75) set_quantifier_opt ::= DISTINCT */
{ 104, -1 }, /* (76) set_quantifier_opt ::= ALL */
{ 105, -1 }, /* (77) select_list ::= NK_STAR */
{ 105, -1 }, /* (78) select_list ::= select_sublist */
{ 111, -1 }, /* (79) select_sublist ::= select_item */
{ 111, -3 }, /* (80) select_sublist ::= select_sublist NK_COMMA select_item */
{ 112, -1 }, /* (81) select_item ::= expression */
{ 112, -2 }, /* (82) select_item ::= expression column_alias */
{ 112, -3 }, /* (83) select_item ::= expression AS column_alias */
{ 112, -3 }, /* (84) select_item ::= table_name NK_DOT NK_STAR */
{ 106, 0 }, /* (85) where_clause_opt ::= */
{ 106, -2 }, /* (86) where_clause_opt ::= WHERE search_condition */
{ 107, 0 }, /* (87) partition_by_clause_opt ::= */
{ 107, -3 }, /* (88) partition_by_clause_opt ::= PARTITION BY expression_list */
{ 108, 0 }, /* (89) twindow_clause_opt ::= */
{ 108, -6 }, /* (90) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */
{ 108, -4 }, /* (91) twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */
{ 108, -6 }, /* (92) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */
{ 108, -8 }, /* (93) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */
{ 113, 0 }, /* (94) sliding_opt ::= */
{ 113, -4 }, /* (95) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */
{ 114, 0 }, /* (96) fill_opt ::= */
{ 114, -4 }, /* (97) fill_opt ::= FILL NK_LP fill_mode NK_RP */
{ 114, -6 }, /* (98) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */
{ 115, -1 }, /* (99) fill_mode ::= NONE */
{ 115, -1 }, /* (100) fill_mode ::= PREV */
{ 115, -1 }, /* (101) fill_mode ::= NULL */
{ 115, -1 }, /* (102) fill_mode ::= LINEAR */
{ 115, -1 }, /* (103) fill_mode ::= NEXT */
{ 109, 0 }, /* (104) group_by_clause_opt ::= */
{ 109, -3 }, /* (105) group_by_clause_opt ::= GROUP BY expression_list */
{ 110, 0 }, /* (106) having_clause_opt ::= */
{ 110, -2 }, /* (107) having_clause_opt ::= HAVING search_condition */
{ 74, -4 }, /* (108) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */
{ 116, -1 }, /* (109) query_expression_body ::= query_primary */
{ 116, -4 }, /* (110) query_expression_body ::= query_expression_body UNION ALL query_expression_body */
{ 120, -1 }, /* (111) query_primary ::= query_specification */
{ 120, -6 }, /* (112) query_primary ::= NK_LP query_expression_body order_by_clause_opt limit_clause_opt slimit_clause_opt NK_RP */
{ 117, 0 }, /* (113) order_by_clause_opt ::= */
{ 117, -3 }, /* (114) order_by_clause_opt ::= ORDER BY sort_specification_list */
{ 118, 0 }, /* (115) slimit_clause_opt ::= */
{ 118, -2 }, /* (116) slimit_clause_opt ::= SLIMIT NK_INTEGER */
{ 118, -4 }, /* (117) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */
{ 118, -4 }, /* (118) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */
{ 119, 0 }, /* (119) limit_clause_opt ::= */
{ 119, -2 }, /* (120) limit_clause_opt ::= LIMIT NK_INTEGER */
{ 119, -4 }, /* (121) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */
{ 119, -4 }, /* (122) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */
{ 87, -3 }, /* (123) subquery ::= NK_LR query_expression NK_RP */
{ 102, -1 }, /* (124) search_condition ::= boolean_value_expression */
{ 121, -1 }, /* (125) sort_specification_list ::= sort_specification */
{ 121, -3 }, /* (126) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */
{ 122, -3 }, /* (127) sort_specification ::= expression ordering_specification_opt null_ordering_opt */
{ 123, 0 }, /* (128) ordering_specification_opt ::= */
{ 123, -1 }, /* (129) ordering_specification_opt ::= ASC */
{ 123, -1 }, /* (130) ordering_specification_opt ::= DESC */
{ 124, 0 }, /* (131) null_ordering_opt ::= */
{ 124, -2 }, /* (132) null_ordering_opt ::= NULLS FIRST */
{ 124, -2 }, /* (133) null_ordering_opt ::= NULLS LAST */
{ 97, -1 }, /* (134) table_primary ::= parenthesized_joined_table */
};
static void yy_accept(yyParser*); /* Forward Declaration */
......@@ -1356,347 +1514,376 @@ static YYACTIONTYPE yy_reduce(
{ PARSER_TRACE; createShowStmt(pCxt, SHOW_TYPE_DATABASE); }
break;
case 1: /* cmd ::= query_expression */
{ PARSER_TRACE; pCxt->pRootNode = yymsp[0].minor.yy168; }
break;
case 2: /* unsigned_integer ::= NK_INTEGER */
{ yylhsminor.yy168 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); }
yymsp[0].minor.yy168 = yylhsminor.yy168;
break;
case 3: /* unsigned_approximate_numeric ::= NK_FLOAT */
{ yylhsminor.yy168 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); }
yymsp[0].minor.yy168 = yylhsminor.yy168;
break;
case 4: /* signed_integer ::= unsigned_integer */
{ yylhsminor.yy168 = yymsp[0].minor.yy168; }
yymsp[0].minor.yy168 = yylhsminor.yy168;
break;
case 5: /* signed_integer ::= NK_PLUS unsigned_integer */
{ yymsp[-1].minor.yy168 = yymsp[0].minor.yy168; }
break;
case 6: /* signed_integer ::= NK_MINUS unsigned_integer */
{ yymsp[-1].minor.yy168 = addMinusSign(pCxt, yymsp[0].minor.yy168);}
break;
case 7: /* db_name ::= NK_ID */
case 8: /* table_name ::= NK_ID */ yytestcase(yyruleno==8);
case 9: /* column_name ::= NK_ID */ yytestcase(yyruleno==9);
case 10: /* table_alias ::= NK_ID */ yytestcase(yyruleno==10);
{ PARSER_TRACE; yylhsminor.yy169 = yymsp[0].minor.yy0; }
yymsp[0].minor.yy169 = yylhsminor.yy169;
break;
case 11: /* column_reference ::= column_name */
{ PARSER_TRACE; yylhsminor.yy168 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy169); }
yymsp[0].minor.yy168 = yylhsminor.yy168;
break;
case 12: /* column_reference ::= table_name NK_DOT column_name */
{ PARSER_TRACE; yylhsminor.yy168 = createColumnNode(pCxt, &yymsp[-2].minor.yy169, &yymsp[0].minor.yy169); }
yymsp[-2].minor.yy168 = yylhsminor.yy168;
break;
case 13: /* boolean_value_expression ::= boolean_primary */
case 17: /* boolean_primary ::= predicate */ yytestcase(yyruleno==17);
case 20: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==20);
case 22: /* table_reference ::= table_primary */ yytestcase(yyruleno==22);
case 23: /* table_reference ::= joined_table */ yytestcase(yyruleno==23);
case 42: /* select_item ::= value_expression */ yytestcase(yyruleno==42);
case 47: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==47);
case 49: /* query_primary ::= query_specification */ yytestcase(yyruleno==49);
case 62: /* search_condition ::= boolean_value_expression */ yytestcase(yyruleno==62);
{ PARSER_TRACE; yylhsminor.yy168 = yymsp[0].minor.yy168; }
yymsp[0].minor.yy168 = yylhsminor.yy168;
break;
case 14: /* boolean_value_expression ::= NOT boolean_primary */
{ PARSER_TRACE; yymsp[-1].minor.yy168 = createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, yymsp[0].minor.yy168, NULL); }
break;
case 15: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */
{ PARSER_TRACE; yylhsminor.yy168 = createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, yymsp[-2].minor.yy168, yymsp[0].minor.yy168); }
yymsp[-2].minor.yy168 = yylhsminor.yy168;
break;
case 16: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */
{ PARSER_TRACE; yylhsminor.yy168 = createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, yymsp[-2].minor.yy168, yymsp[0].minor.yy168); }
yymsp[-2].minor.yy168 = yylhsminor.yy168;
break;
case 18: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */
case 30: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ yytestcase(yyruleno==30);
case 31: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==31);
case 61: /* subquery ::= NK_LR query_expression NK_RP */ yytestcase(yyruleno==61);
{ PARSER_TRACE; yymsp[-2].minor.yy168 = yymsp[-1].minor.yy168; }
break;
case 19: /* from_clause ::= FROM table_reference_list */
{ PARSER_TRACE; yymsp[-1].minor.yy168 = yymsp[0].minor.yy168; }
break;
case 21: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */
{ PARSER_TRACE; yylhsminor.yy168 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy168, yymsp[0].minor.yy168, NULL); }
yymsp[-2].minor.yy168 = yylhsminor.yy168;
break;
case 24: /* table_primary ::= table_name correlation_or_recognition_opt */
{ PARSER_TRACE; yylhsminor.yy168 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy169, &yymsp[0].minor.yy169); }
yymsp[-1].minor.yy168 = yylhsminor.yy168;
break;
case 25: /* table_primary ::= db_name NK_DOT table_name correlation_or_recognition_opt */
{ PARSER_TRACE; yylhsminor.yy168 = createRealTableNode(pCxt, &yymsp[-3].minor.yy169, &yymsp[-1].minor.yy169, &yymsp[0].minor.yy169); }
yymsp[-3].minor.yy168 = yylhsminor.yy168;
break;
case 26: /* table_primary ::= subquery correlation_or_recognition_opt */
{ PARSER_TRACE; yylhsminor.yy168 = createTempTableNode(pCxt, yymsp[-1].minor.yy168, &yymsp[0].minor.yy169); }
yymsp[-1].minor.yy168 = yylhsminor.yy168;
break;
case 27: /* correlation_or_recognition_opt ::= */
{ PARSER_TRACE; yymsp[1].minor.yy169 = nil_token; }
break;
case 28: /* correlation_or_recognition_opt ::= table_alias */
{ PARSER_TRACE; yylhsminor.yy169 = yymsp[0].minor.yy169; }
yymsp[0].minor.yy169 = yylhsminor.yy169;
break;
case 29: /* correlation_or_recognition_opt ::= AS table_alias */
{ PARSER_TRACE; yymsp[-1].minor.yy169 = yymsp[0].minor.yy169; }
break;
case 32: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */
{ PARSER_TRACE; yylhsminor.yy168 = createJoinTableNode(pCxt, yymsp[-4].minor.yy148, yymsp[-5].minor.yy168, yymsp[-2].minor.yy168, yymsp[0].minor.yy168); }
yymsp[-5].minor.yy168 = yylhsminor.yy168;
break;
case 33: /* join_type ::= INNER */
{ PARSER_TRACE; yymsp[0].minor.yy148 = JOIN_TYPE_INNER; }
break;
case 34: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */
{
PARSER_TRACE;
yymsp[-8].minor.yy168 = createSelectStmt(pCxt, yymsp[-7].minor.yy173, yymsp[-6].minor.yy40, yymsp[-5].minor.yy168);
yymsp[-8].minor.yy168 = addWhereClause(pCxt, yymsp[-8].minor.yy168, yymsp[-4].minor.yy168);
yymsp[-8].minor.yy168 = addPartitionByClause(pCxt, yymsp[-8].minor.yy168, yymsp[-3].minor.yy40);
yymsp[-8].minor.yy168 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy168, yymsp[-2].minor.yy168);
yymsp[-8].minor.yy168 = addGroupByClause(pCxt, yymsp[-8].minor.yy168, yymsp[-1].minor.yy40);
yymsp[-8].minor.yy168 = addHavingClause(pCxt, yymsp[-8].minor.yy168, yymsp[0].minor.yy168);
}
{ PARSER_TRACE; pCxt->pRootNode = yymsp[0].minor.yy212; }
break;
case 2: /* literal ::= NK_INTEGER */
{ PARSER_TRACE; yylhsminor.yy212 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); }
yymsp[0].minor.yy212 = yylhsminor.yy212;
break;
case 3: /* literal ::= NK_FLOAT */
{ PARSER_TRACE; yylhsminor.yy212 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); }
yymsp[0].minor.yy212 = yylhsminor.yy212;
break;
case 4: /* literal ::= NK_STRING */
{ PARSER_TRACE; yylhsminor.yy212 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); }
yymsp[0].minor.yy212 = yylhsminor.yy212;
break;
case 5: /* literal ::= NK_BOOL */
{ PARSER_TRACE; yylhsminor.yy212 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); }
yymsp[0].minor.yy212 = yylhsminor.yy212;
break;
case 6: /* literal ::= TIMESTAMP NK_STRING */
{ PARSER_TRACE; yymsp[-1].minor.yy212 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); }
break;
case 7: /* literal ::= duration_literal */
case 17: /* expression ::= literal */ yytestcase(yyruleno==17);
case 18: /* expression ::= column_reference */ yytestcase(yyruleno==18);
case 20: /* expression ::= subquery */ yytestcase(yyruleno==20);
case 52: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==52);
case 56: /* boolean_primary ::= predicate */ yytestcase(yyruleno==56);
case 59: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==59);
case 61: /* table_reference ::= table_primary */ yytestcase(yyruleno==61);
case 62: /* table_reference ::= joined_table */ yytestcase(yyruleno==62);
case 81: /* select_item ::= expression */ yytestcase(yyruleno==81);
case 109: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==109);
case 111: /* query_primary ::= query_specification */ yytestcase(yyruleno==111);
case 124: /* search_condition ::= boolean_value_expression */ yytestcase(yyruleno==124);
{ PARSER_TRACE; yylhsminor.yy212 = yymsp[0].minor.yy212; }
yymsp[0].minor.yy212 = yylhsminor.yy212;
break;
case 8: /* duration_literal ::= NK_VARIABLE */
{ PARSER_TRACE; yylhsminor.yy212 = createDurationValueNode(pCxt, &yymsp[0].minor.yy0); }
yymsp[0].minor.yy212 = yylhsminor.yy212;
break;
case 9: /* literal_list ::= literal */
case 29: /* expression_list ::= expression */ yytestcase(yyruleno==29);
case 79: /* select_sublist ::= select_item */ yytestcase(yyruleno==79);
case 125: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==125);
{ PARSER_TRACE; yylhsminor.yy174 = createNodeList(pCxt, yymsp[0].minor.yy212); }
yymsp[0].minor.yy174 = yylhsminor.yy174;
break;
case 10: /* literal_list ::= literal_list NK_COMMA literal */
case 30: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==30);
case 80: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==80);
case 126: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==126);
{ PARSER_TRACE; yylhsminor.yy174 = addNodeToList(pCxt, yymsp[-2].minor.yy174, yymsp[0].minor.yy212); }
yymsp[-2].minor.yy174 = yylhsminor.yy174;
break;
case 11: /* db_name ::= NK_ID */
case 12: /* table_name ::= NK_ID */ yytestcase(yyruleno==12);
case 13: /* column_name ::= NK_ID */ yytestcase(yyruleno==13);
case 14: /* function_name ::= NK_ID */ yytestcase(yyruleno==14);
case 15: /* table_alias ::= NK_ID */ yytestcase(yyruleno==15);
case 16: /* column_alias ::= NK_ID */ yytestcase(yyruleno==16);
{ PARSER_TRACE; yylhsminor.yy79 = yymsp[0].minor.yy0; }
yymsp[0].minor.yy79 = yylhsminor.yy79;
break;
case 19: /* expression ::= function_name NK_LP expression_list NK_RP */
{ PARSER_TRACE; yylhsminor.yy212 = createFunctionNode(pCxt, &yymsp[-3].minor.yy79, yymsp[-1].minor.yy174); }
yymsp[-3].minor.yy212 = yylhsminor.yy212;
break;
case 21: /* expression ::= NK_LP expression NK_RP */
case 57: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==57);
case 69: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ yytestcase(yyruleno==69);
case 70: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==70);
case 123: /* subquery ::= NK_LR query_expression NK_RP */ yytestcase(yyruleno==123);
{ PARSER_TRACE; yymsp[-2].minor.yy212 = yymsp[-1].minor.yy212; }
break;
case 22: /* expression ::= NK_PLUS expression */
case 58: /* from_clause ::= FROM table_reference_list */ yytestcase(yyruleno==58);
case 86: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==86);
case 107: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==107);
{ PARSER_TRACE; yymsp[-1].minor.yy212 = yymsp[0].minor.yy212; }
break;
case 23: /* expression ::= NK_MINUS expression */
{ PARSER_TRACE; yymsp[-1].minor.yy212 = createOperatorNode(pCxt, OP_TYPE_SUB, yymsp[0].minor.yy212, NULL); }
break;
case 24: /* expression ::= expression NK_PLUS expression */
{ PARSER_TRACE; yylhsminor.yy212 = createOperatorNode(pCxt, OP_TYPE_ADD, yymsp[-2].minor.yy212, yymsp[0].minor.yy212); }
yymsp[-2].minor.yy212 = yylhsminor.yy212;
break;
case 25: /* expression ::= expression NK_MINUS expression */
{ PARSER_TRACE; yylhsminor.yy212 = createOperatorNode(pCxt, OP_TYPE_SUB, yymsp[-2].minor.yy212, yymsp[0].minor.yy212); }
yymsp[-2].minor.yy212 = yylhsminor.yy212;
break;
case 26: /* expression ::= expression NK_STAR expression */
{ PARSER_TRACE; yylhsminor.yy212 = createOperatorNode(pCxt, OP_TYPE_MULTI, yymsp[-2].minor.yy212, yymsp[0].minor.yy212); }
yymsp[-2].minor.yy212 = yylhsminor.yy212;
break;
case 27: /* expression ::= expression NK_SLASH expression */
{ PARSER_TRACE; yylhsminor.yy212 = createOperatorNode(pCxt, OP_TYPE_DIV, yymsp[-2].minor.yy212, yymsp[0].minor.yy212); }
yymsp[-2].minor.yy212 = yylhsminor.yy212;
break;
case 28: /* expression ::= expression NK_REM expression */
{ PARSER_TRACE; yylhsminor.yy212 = createOperatorNode(pCxt, OP_TYPE_MOD, yymsp[-2].minor.yy212, yymsp[0].minor.yy212); }
yymsp[-2].minor.yy212 = yylhsminor.yy212;
break;
case 31: /* column_reference ::= column_name */
{ PARSER_TRACE; yylhsminor.yy212 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy79); }
yymsp[0].minor.yy212 = yylhsminor.yy212;
break;
case 32: /* column_reference ::= table_name NK_DOT column_name */
{ PARSER_TRACE; yylhsminor.yy212 = createColumnNode(pCxt, &yymsp[-2].minor.yy79, &yymsp[0].minor.yy79); }
yymsp[-2].minor.yy212 = yylhsminor.yy212;
break;
case 33: /* predicate ::= expression compare_op expression */
case 38: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==38);
{ PARSER_TRACE; yylhsminor.yy212 = createOperatorNode(pCxt, yymsp[-1].minor.yy40, yymsp[-2].minor.yy212, yymsp[0].minor.yy212); }
yymsp[-2].minor.yy212 = yylhsminor.yy212;
break;
case 34: /* predicate ::= expression BETWEEN expression AND expression */
{ PARSER_TRACE; yylhsminor.yy212 = createBetweenAnd(pCxt, yymsp[-4].minor.yy212, yymsp[-2].minor.yy212, yymsp[0].minor.yy212); }
yymsp[-4].minor.yy212 = yylhsminor.yy212;
break;
case 35: /* predicate ::= expression NOT BETWEEN expression AND expression */
{ PARSER_TRACE; yylhsminor.yy212 = createNotBetweenAnd(pCxt, yymsp[-2].minor.yy212, yymsp[-5].minor.yy212, yymsp[0].minor.yy212); }
yymsp[-5].minor.yy212 = yylhsminor.yy212;
break;
case 36: /* predicate ::= expression IS NULL */
{ PARSER_TRACE; yylhsminor.yy212 = createIsNullCondNode(pCxt, yymsp[-2].minor.yy212, true); }
yymsp[-2].minor.yy212 = yylhsminor.yy212;
break;
case 37: /* predicate ::= expression IS NOT NULL */
{ PARSER_TRACE; yylhsminor.yy212 = createIsNullCondNode(pCxt, yymsp[-3].minor.yy212, false); }
yymsp[-3].minor.yy212 = yylhsminor.yy212;
break;
case 39: /* compare_op ::= NK_LT */
{ PARSER_TRACE; yymsp[0].minor.yy40 = OP_TYPE_LOWER_THAN; }
break;
case 40: /* compare_op ::= NK_GT */
{ PARSER_TRACE; yymsp[0].minor.yy40 = OP_TYPE_GREATER_THAN; }
break;
case 41: /* compare_op ::= NK_LE */
{ PARSER_TRACE; yymsp[0].minor.yy40 = OP_TYPE_LOWER_EQUAL; }
break;
case 42: /* compare_op ::= NK_GE */
{ PARSER_TRACE; yymsp[0].minor.yy40 = OP_TYPE_GREATER_EQUAL; }
break;
case 43: /* compare_op ::= NK_NE */
{ PARSER_TRACE; yymsp[0].minor.yy40 = OP_TYPE_NOT_EQUAL; }
break;
case 44: /* compare_op ::= NK_EQ */
{ PARSER_TRACE; yymsp[0].minor.yy40 = OP_TYPE_EQUAL; }
break;
case 45: /* compare_op ::= LIKE */
{ PARSER_TRACE; yymsp[0].minor.yy40 = OP_TYPE_LIKE; }
break;
case 46: /* compare_op ::= NOT LIKE */
{ PARSER_TRACE; yymsp[-1].minor.yy40 = OP_TYPE_NOT_LIKE; }
break;
case 47: /* compare_op ::= MATCH */
{ PARSER_TRACE; yymsp[0].minor.yy40 = OP_TYPE_MATCH; }
break;
case 35: /* set_quantifier_opt ::= */
{ PARSER_TRACE; yymsp[1].minor.yy173 = false; }
case 48: /* compare_op ::= NMATCH */
{ PARSER_TRACE; yymsp[0].minor.yy40 = OP_TYPE_NMATCH; }
break;
case 36: /* set_quantifier_opt ::= DISTINCT */
{ PARSER_TRACE; yymsp[0].minor.yy173 = true; }
case 49: /* in_op ::= IN */
{ PARSER_TRACE; yymsp[0].minor.yy40 = OP_TYPE_IN; }
break;
case 37: /* set_quantifier_opt ::= ALL */
{ PARSER_TRACE; yymsp[0].minor.yy173 = false; }
case 50: /* in_op ::= NOT IN */
{ PARSER_TRACE; yymsp[-1].minor.yy40 = OP_TYPE_NOT_IN; }
break;
case 38: /* select_list ::= NK_STAR */
{ PARSER_TRACE; yymsp[0].minor.yy40 = NULL; }
case 51: /* in_predicate_value ::= NK_LP expression_list NK_RP */
{ PARSER_TRACE; yymsp[-2].minor.yy212 = createNodeListNode(pCxt, yymsp[-1].minor.yy174); }
break;
case 39: /* select_list ::= select_sublist */
{ PARSER_TRACE; yylhsminor.yy40 = yymsp[0].minor.yy40; }
yymsp[0].minor.yy40 = yylhsminor.yy40;
case 53: /* boolean_value_expression ::= NOT boolean_primary */
{ PARSER_TRACE; yymsp[-1].minor.yy212 = createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, yymsp[0].minor.yy212, NULL); }
break;
case 40: /* select_sublist ::= select_item */
case 63: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==63);
{ PARSER_TRACE; yylhsminor.yy40 = createNodeList(pCxt, yymsp[0].minor.yy168); }
yymsp[0].minor.yy40 = yylhsminor.yy40;
case 54: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */
{ PARSER_TRACE; yylhsminor.yy212 = createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, yymsp[-2].minor.yy212, yymsp[0].minor.yy212); }
yymsp[-2].minor.yy212 = yylhsminor.yy212;
break;
case 41: /* select_sublist ::= select_sublist NK_COMMA select_item */
case 64: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==64);
{ PARSER_TRACE; yylhsminor.yy40 = addNodeToList(pCxt, yymsp[-2].minor.yy40, yymsp[0].minor.yy168); }
yymsp[-2].minor.yy40 = yylhsminor.yy40;
case 55: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */
{ PARSER_TRACE; yylhsminor.yy212 = createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, yymsp[-2].minor.yy212, yymsp[0].minor.yy212); }
yymsp[-2].minor.yy212 = yylhsminor.yy212;
break;
case 43: /* select_item ::= value_expression NK_ID */
{ PARSER_TRACE; yylhsminor.yy168 = setProjectionAlias(pCxt, yymsp[-1].minor.yy168, &yymsp[0].minor.yy0); }
yymsp[-1].minor.yy168 = yylhsminor.yy168;
case 60: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */
{ PARSER_TRACE; yylhsminor.yy212 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy212, yymsp[0].minor.yy212, NULL); }
yymsp[-2].minor.yy212 = yylhsminor.yy212;
break;
case 44: /* select_item ::= value_expression AS NK_ID */
{ PARSER_TRACE; yylhsminor.yy168 = setProjectionAlias(pCxt, yymsp[-2].minor.yy168, &yymsp[0].minor.yy0); }
yymsp[-2].minor.yy168 = yylhsminor.yy168;
case 63: /* table_primary ::= table_name alias_opt */
{ PARSER_TRACE; yylhsminor.yy212 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy79, &yymsp[0].minor.yy79); }
yymsp[-1].minor.yy212 = yylhsminor.yy212;
break;
case 45: /* select_item ::= table_name NK_DOT NK_STAR */
{ PARSER_TRACE; yylhsminor.yy168 = createColumnNode(pCxt, &yymsp[-2].minor.yy169, &yymsp[0].minor.yy0); }
yymsp[-2].minor.yy168 = yylhsminor.yy168;
case 64: /* table_primary ::= db_name NK_DOT table_name alias_opt */
{ PARSER_TRACE; yylhsminor.yy212 = createRealTableNode(pCxt, &yymsp[-3].minor.yy79, &yymsp[-1].minor.yy79, &yymsp[0].minor.yy79); }
yymsp[-3].minor.yy212 = yylhsminor.yy212;
break;
case 46: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */
case 65: /* table_primary ::= subquery alias_opt */
{ PARSER_TRACE; yylhsminor.yy212 = createTempTableNode(pCxt, yymsp[-1].minor.yy212, &yymsp[0].minor.yy79); }
yymsp[-1].minor.yy212 = yylhsminor.yy212;
break;
case 66: /* alias_opt ::= */
{ PARSER_TRACE; yymsp[1].minor.yy79 = nil_token; }
break;
case 67: /* alias_opt ::= table_alias */
{ PARSER_TRACE; yylhsminor.yy79 = yymsp[0].minor.yy79; }
yymsp[0].minor.yy79 = yylhsminor.yy79;
break;
case 68: /* alias_opt ::= AS table_alias */
{ PARSER_TRACE; yymsp[-1].minor.yy79 = yymsp[0].minor.yy79; }
break;
case 71: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */
{ PARSER_TRACE; yylhsminor.yy212 = createJoinTableNode(pCxt, yymsp[-4].minor.yy162, yymsp[-5].minor.yy212, yymsp[-2].minor.yy212, yymsp[0].minor.yy212); }
yymsp[-5].minor.yy212 = yylhsminor.yy212;
break;
case 72: /* join_type ::= INNER */
{ PARSER_TRACE; yymsp[0].minor.yy162 = JOIN_TYPE_INNER; }
break;
case 73: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */
{
PARSER_TRACE;
yylhsminor.yy168 = addOrderByClause(pCxt, yymsp[-3].minor.yy168, yymsp[-2].minor.yy40);
yylhsminor.yy168 = addSlimitClause(pCxt, yylhsminor.yy168, yymsp[-1].minor.yy168);
yylhsminor.yy168 = addLimitClause(pCxt, yylhsminor.yy168, yymsp[0].minor.yy168);
yymsp[-8].minor.yy212 = createSelectStmt(pCxt, yymsp[-7].minor.yy237, yymsp[-6].minor.yy174, yymsp[-5].minor.yy212);
yymsp[-8].minor.yy212 = addWhereClause(pCxt, yymsp[-8].minor.yy212, yymsp[-4].minor.yy212);
yymsp[-8].minor.yy212 = addPartitionByClause(pCxt, yymsp[-8].minor.yy212, yymsp[-3].minor.yy174);
yymsp[-8].minor.yy212 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy212, yymsp[-2].minor.yy212);
yymsp[-8].minor.yy212 = addGroupByClause(pCxt, yymsp[-8].minor.yy212, yymsp[-1].minor.yy174);
yymsp[-8].minor.yy212 = addHavingClause(pCxt, yymsp[-8].minor.yy212, yymsp[0].minor.yy212);
}
yymsp[-3].minor.yy168 = yylhsminor.yy168;
break;
case 48: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */
{ PARSER_TRACE; yylhsminor.yy168 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy168, yymsp[0].minor.yy168); }
yymsp[-3].minor.yy168 = yylhsminor.yy168;
case 74: /* set_quantifier_opt ::= */
{ PARSER_TRACE; yymsp[1].minor.yy237 = false; }
break;
case 50: /* query_primary ::= NK_LP query_expression_body order_by_clause_opt limit_clause_opt slimit_clause_opt NK_RP */
{ PARSER_TRACE; yymsp[-5].minor.yy168 = yymsp[-4].minor.yy168;}
yy_destructor(yypParser,86,&yymsp[-3].minor);
yy_destructor(yypParser,88,&yymsp[-2].minor);
yy_destructor(yypParser,87,&yymsp[-1].minor);
case 75: /* set_quantifier_opt ::= DISTINCT */
{ PARSER_TRACE; yymsp[0].minor.yy237 = true; }
break;
case 51: /* order_by_clause_opt ::= */
{ PARSER_TRACE; yymsp[1].minor.yy40 = NULL; }
case 76: /* set_quantifier_opt ::= ALL */
{ PARSER_TRACE; yymsp[0].minor.yy237 = false; }
break;
case 52: /* order_by_clause_opt ::= ORDER BY sort_specification_list */
{ PARSER_TRACE; yymsp[-2].minor.yy40 = yymsp[0].minor.yy40; }
case 77: /* select_list ::= NK_STAR */
{ PARSER_TRACE; yymsp[0].minor.yy174 = NULL; }
break;
case 53: /* slimit_clause_opt ::= */
case 57: /* limit_clause_opt ::= */ yytestcase(yyruleno==57);
{ PARSER_TRACE; yymsp[1].minor.yy168 = NULL; }
case 78: /* select_list ::= select_sublist */
{ PARSER_TRACE; yylhsminor.yy174 = yymsp[0].minor.yy174; }
yymsp[0].minor.yy174 = yylhsminor.yy174;
break;
case 54: /* slimit_clause_opt ::= SLIMIT signed_integer */
case 58: /* limit_clause_opt ::= LIMIT signed_integer */ yytestcase(yyruleno==58);
{ PARSER_TRACE; yymsp[-1].minor.yy168 = createLimitNode(pCxt, yymsp[0].minor.yy168, 0); }
case 82: /* select_item ::= expression column_alias */
{ PARSER_TRACE; yylhsminor.yy212 = setProjectionAlias(pCxt, yymsp[-1].minor.yy212, &yymsp[0].minor.yy79); }
yymsp[-1].minor.yy212 = yylhsminor.yy212;
break;
case 55: /* slimit_clause_opt ::= SLIMIT signed_integer SOFFSET signed_integer */
case 59: /* limit_clause_opt ::= LIMIT signed_integer OFFSET signed_integer */ yytestcase(yyruleno==59);
{ PARSER_TRACE; yymsp[-3].minor.yy168 = createLimitNode(pCxt, yymsp[-2].minor.yy168, yymsp[0].minor.yy168); }
case 83: /* select_item ::= expression AS column_alias */
{ PARSER_TRACE; yylhsminor.yy212 = setProjectionAlias(pCxt, yymsp[-2].minor.yy212, &yymsp[0].minor.yy79); }
yymsp[-2].minor.yy212 = yylhsminor.yy212;
break;
case 56: /* slimit_clause_opt ::= SLIMIT signed_integer NK_COMMA signed_integer */
case 60: /* limit_clause_opt ::= LIMIT signed_integer NK_COMMA signed_integer */ yytestcase(yyruleno==60);
{ PARSER_TRACE; yymsp[-3].minor.yy168 = createLimitNode(pCxt, yymsp[0].minor.yy168, yymsp[-2].minor.yy168); }
case 84: /* select_item ::= table_name NK_DOT NK_STAR */
{ PARSER_TRACE; yylhsminor.yy212 = createColumnNode(pCxt, &yymsp[-2].minor.yy79, &yymsp[0].minor.yy0); }
yymsp[-2].minor.yy212 = yylhsminor.yy212;
break;
case 65: /* sort_specification ::= value_expression ordering_specification_opt null_ordering_opt */
{ PARSER_TRACE; yylhsminor.yy168 = createOrderByExprNode(pCxt, yymsp[-2].minor.yy168, yymsp[-1].minor.yy106, yymsp[0].minor.yy193); }
yymsp[-2].minor.yy168 = yylhsminor.yy168;
case 85: /* where_clause_opt ::= */
case 89: /* twindow_clause_opt ::= */ yytestcase(yyruleno==89);
case 94: /* sliding_opt ::= */ yytestcase(yyruleno==94);
case 96: /* fill_opt ::= */ yytestcase(yyruleno==96);
case 106: /* having_clause_opt ::= */ yytestcase(yyruleno==106);
case 115: /* slimit_clause_opt ::= */ yytestcase(yyruleno==115);
case 119: /* limit_clause_opt ::= */ yytestcase(yyruleno==119);
{ PARSER_TRACE; yymsp[1].minor.yy212 = NULL; }
break;
case 66: /* ordering_specification_opt ::= */
{ PARSER_TRACE; yymsp[1].minor.yy106 = ORDER_ASC; }
case 87: /* partition_by_clause_opt ::= */
case 104: /* group_by_clause_opt ::= */ yytestcase(yyruleno==104);
case 113: /* order_by_clause_opt ::= */ yytestcase(yyruleno==113);
{ PARSER_TRACE; yymsp[1].minor.yy174 = NULL; }
break;
case 67: /* ordering_specification_opt ::= ASC */
{ PARSER_TRACE; yymsp[0].minor.yy106 = ORDER_ASC; }
case 88: /* partition_by_clause_opt ::= PARTITION BY expression_list */
case 105: /* group_by_clause_opt ::= GROUP BY expression_list */ yytestcase(yyruleno==105);
case 114: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==114);
{ PARSER_TRACE; yymsp[-2].minor.yy174 = yymsp[0].minor.yy174; }
break;
case 68: /* ordering_specification_opt ::= DESC */
{ PARSER_TRACE; yymsp[0].minor.yy106 = ORDER_DESC; }
case 90: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */
{ PARSER_TRACE; yymsp[-5].minor.yy212 = createSessionWindowNode(pCxt, yymsp[-3].minor.yy212, &yymsp[-1].minor.yy0); }
break;
case 69: /* null_ordering_opt ::= */
{ PARSER_TRACE; yymsp[1].minor.yy193 = NULL_ORDER_DEFAULT; }
case 91: /* twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */
{ PARSER_TRACE; yymsp[-3].minor.yy212 = createStateWindowNode(pCxt, yymsp[-1].minor.yy212); }
break;
case 70: /* null_ordering_opt ::= NULLS FIRST */
{ PARSER_TRACE; yymsp[-1].minor.yy193 = NULL_ORDER_FIRST; }
case 92: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */
{ PARSER_TRACE; yymsp[-5].minor.yy212 = createIntervalWindowNode(pCxt, yymsp[-3].minor.yy212, NULL, yymsp[-1].minor.yy212, yymsp[0].minor.yy212); }
break;
case 71: /* null_ordering_opt ::= NULLS LAST */
{ PARSER_TRACE; yymsp[-1].minor.yy193 = NULL_ORDER_LAST; }
case 93: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */
{ PARSER_TRACE; yymsp[-7].minor.yy212 = createIntervalWindowNode(pCxt, yymsp[-5].minor.yy212, yymsp[-3].minor.yy212, yymsp[-1].minor.yy212, yymsp[0].minor.yy212); }
break;
case 72: /* unsigned_literal ::= unsigned_numeric_literal */
{ yy_destructor(yypParser,51,&yymsp[0].minor);
{
}
}
case 95: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */
{ PARSER_TRACE; yymsp[-3].minor.yy212 = yymsp[-1].minor.yy212; }
break;
case 73: /* unsigned_literal ::= general_literal */
{ yy_destructor(yypParser,52,&yymsp[0].minor);
{
}
}
case 97: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */
{ PARSER_TRACE; yymsp[-3].minor.yy212 = createFillNode(pCxt, yymsp[-1].minor.yy44, NULL); }
break;
case 74: /* unsigned_numeric_literal ::= unsigned_integer */
{ yy_destructor(yypParser,47,&yymsp[0].minor);
{
}
}
case 98: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */
{ PARSER_TRACE; yymsp[-5].minor.yy212 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy174)); }
break;
case 75: /* unsigned_numeric_literal ::= unsigned_approximate_numeric */
{ yy_destructor(yypParser,48,&yymsp[0].minor);
{
}
}
case 99: /* fill_mode ::= NONE */
{ PARSER_TRACE; yymsp[0].minor.yy44 = FILL_MODE_NONE; }
break;
case 79: /* unsigned_value_specification ::= unsigned_literal */
{ yy_destructor(yypParser,50,&yymsp[0].minor);
{
}
}
case 100: /* fill_mode ::= PREV */
{ PARSER_TRACE; yymsp[0].minor.yy44 = FILL_MODE_PREV; }
break;
case 81: /* value_expression_primary ::= NK_LP value_expression NK_RP */
case 93: /* value_function ::= NK_ID NK_LP value_expression NK_RP */ yytestcase(yyruleno==93);
{
}
yy_destructor(yypParser,59,&yymsp[-1].minor);
case 101: /* fill_mode ::= NULL */
{ PARSER_TRACE; yymsp[0].minor.yy44 = FILL_MODE_NULL; }
break;
case 82: /* value_expression_primary ::= nonparenthesized_value_expression_primary */
{ yy_destructor(yypParser,60,&yymsp[0].minor);
{
}
}
case 102: /* fill_mode ::= LINEAR */
{ PARSER_TRACE; yymsp[0].minor.yy44 = FILL_MODE_LINEAR; }
break;
case 83: /* nonparenthesized_value_expression_primary ::= unsigned_value_specification */
{ yy_destructor(yypParser,57,&yymsp[0].minor);
{
}
}
case 103: /* fill_mode ::= NEXT */
{ PARSER_TRACE; yymsp[0].minor.yy44 = FILL_MODE_NEXT; }
break;
case 84: /* nonparenthesized_value_expression_primary ::= column_reference */
{ yy_destructor(yypParser,61,&yymsp[0].minor);
{
}
}
case 108: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */
{
PARSER_TRACE;
yylhsminor.yy212 = addOrderByClause(pCxt, yymsp[-3].minor.yy212, yymsp[-2].minor.yy174);
yylhsminor.yy212 = addSlimitClause(pCxt, yylhsminor.yy212, yymsp[-1].minor.yy212);
yylhsminor.yy212 = addLimitClause(pCxt, yylhsminor.yy212, yymsp[0].minor.yy212);
}
yymsp[-3].minor.yy212 = yylhsminor.yy212;
break;
case 85: /* nonparenthesized_value_expression_primary ::= subquery */
{ yy_destructor(yypParser,62,&yymsp[0].minor);
{
}
}
case 110: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */
{ PARSER_TRACE; yylhsminor.yy212 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy212, yymsp[0].minor.yy212); }
yymsp[-3].minor.yy212 = yylhsminor.yy212;
break;
case 86: /* table_primary ::= parenthesized_joined_table */
{ yy_destructor(yypParser,72,&yymsp[0].minor);
{
}
}
case 112: /* query_primary ::= NK_LP query_expression_body order_by_clause_opt limit_clause_opt slimit_clause_opt NK_RP */
{ PARSER_TRACE; yymsp[-5].minor.yy212 = yymsp[-4].minor.yy212;}
yy_destructor(yypParser,117,&yymsp[-3].minor);
yy_destructor(yypParser,119,&yymsp[-2].minor);
yy_destructor(yypParser,118,&yymsp[-1].minor);
break;
case 94: /* value_function ::= NK_ID NK_LP value_expression NK_COMMA value_expression NK_RP */
{
}
yy_destructor(yypParser,59,&yymsp[-3].minor);
yy_destructor(yypParser,59,&yymsp[-1].minor);
case 116: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */
case 120: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==120);
{ PARSER_TRACE; yymsp[-1].minor.yy212 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); }
break;
case 95: /* value_expression ::= common_value_expression */
{ yy_destructor(yypParser,95,&yymsp[0].minor);
{
}
}
case 117: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */
case 121: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==121);
{ PARSER_TRACE; yymsp[-3].minor.yy212 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); }
break;
case 96: /* common_value_expression ::= numeric_value_expression */
{ yy_destructor(yypParser,96,&yymsp[0].minor);
{
}
}
case 118: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */
case 122: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==122);
{ PARSER_TRACE; yymsp[-3].minor.yy212 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); }
break;
case 97: /* numeric_value_expression ::= numeric_primary */
{ yy_destructor(yypParser,97,&yymsp[0].minor);
{
}
}
case 127: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */
{ PARSER_TRACE; yylhsminor.yy212 = createOrderByExprNode(pCxt, yymsp[-2].minor.yy212, yymsp[-1].minor.yy188, yymsp[0].minor.yy107); }
yymsp[-2].minor.yy212 = yylhsminor.yy212;
break;
case 98: /* numeric_value_expression ::= NK_PLUS numeric_primary */
case 99: /* numeric_value_expression ::= NK_MINUS numeric_primary */ yytestcase(yyruleno==99);
{
}
yy_destructor(yypParser,97,&yymsp[0].minor);
case 128: /* ordering_specification_opt ::= */
{ PARSER_TRACE; yymsp[1].minor.yy188 = ORDER_ASC; }
break;
case 100: /* numeric_value_expression ::= numeric_value_expression NK_PLUS numeric_value_expression */
case 101: /* numeric_value_expression ::= numeric_value_expression NK_MINUS numeric_value_expression */ yytestcase(yyruleno==101);
case 102: /* numeric_value_expression ::= numeric_value_expression NK_STAR numeric_value_expression */ yytestcase(yyruleno==102);
case 103: /* numeric_value_expression ::= numeric_value_expression NK_SLASH numeric_value_expression */ yytestcase(yyruleno==103);
{ yy_destructor(yypParser,96,&yymsp[-2].minor);
{
}
yy_destructor(yypParser,96,&yymsp[0].minor);
}
case 129: /* ordering_specification_opt ::= ASC */
{ PARSER_TRACE; yymsp[0].minor.yy188 = ORDER_ASC; }
break;
case 104: /* numeric_primary ::= value_expression_primary */
{ yy_destructor(yypParser,58,&yymsp[0].minor);
{
}
}
case 130: /* ordering_specification_opt ::= DESC */
{ PARSER_TRACE; yymsp[0].minor.yy188 = ORDER_DESC; }
break;
case 131: /* null_ordering_opt ::= */
{ PARSER_TRACE; yymsp[1].minor.yy107 = NULL_ORDER_DEFAULT; }
break;
case 132: /* null_ordering_opt ::= NULLS FIRST */
{ PARSER_TRACE; yymsp[-1].minor.yy107 = NULL_ORDER_FIRST; }
break;
case 133: /* null_ordering_opt ::= NULLS LAST */
{ PARSER_TRACE; yymsp[-1].minor.yy107 = NULL_ORDER_LAST; }
break;
case 105: /* numeric_primary ::= value_function */
{ yy_destructor(yypParser,94,&yymsp[0].minor);
case 134: /* table_primary ::= parenthesized_joined_table */
{ yy_destructor(yypParser,100,&yymsp[0].minor);
{
}
}
break;
default:
/* (76) general_literal ::= NK_STRING */ yytestcase(yyruleno==76);
/* (77) general_literal ::= NK_BOOL */ yytestcase(yyruleno==77);
/* (78) general_literal ::= NK_NOW */ yytestcase(yyruleno==78);
/* (80) unsigned_value_specification ::= NK_QUESTION */ yytestcase(yyruleno==80);
/* (87) predicate ::= */ yytestcase(yyruleno==87);
/* (88) where_clause_opt ::= */ yytestcase(yyruleno==88);
/* (89) partition_by_clause_opt ::= */ yytestcase(yyruleno==89);
/* (90) twindow_clause_opt ::= */ yytestcase(yyruleno==90);
/* (91) group_by_clause_opt ::= */ yytestcase(yyruleno==91);
/* (92) having_clause_opt ::= */ yytestcase(yyruleno==92);
break;
/********** End reduce actions ************************************************/
};
......@@ -1797,7 +1984,7 @@ static void yy_accept(
/* Here code is inserted which will be executed whenever the
** parser accepts */
/*********** Begin %parse_accept code *****************************************/
printf("parsing complete!\n" );
PARSER_COMPLETE;
/*********** End %parse_accept code *******************************************/
NewParseARG_STORE /* Suppress warning about unused %extra_argument variable */
NewParseCTX_STORE
......
......@@ -86,15 +86,15 @@ int32_t doParse(SParseContext* pParseCxt, SQuery* pQuery) {
int32_t i = 0;
while (1) {
SToken t0 = {0};
printf("===========================\n");
// printf("===========================\n");
if (cxt.pQueryCxt->pSql[i] == 0) {
NewParse(pParser, 0, t0, &cxt);
goto abort_parse;
}
printf("input: [%s]\n", cxt.pQueryCxt->pSql + i);
// printf("input: [%s]\n", cxt.pQueryCxt->pSql + i);
t0.n = getToken((char *)&cxt.pQueryCxt->pSql[i], &t0.type);
t0.z = (char *)(cxt.pQueryCxt->pSql + i);
printf("token : %d %d [%s]\n", t0.type, t0.n, t0.z);
// printf("token : %d %d [%s]\n", t0.type, t0.n, t0.z);
i += t0.n;
switch (t0.type) {
......@@ -131,7 +131,7 @@ int32_t doParse(SParseContext* pParseCxt, SQuery* pQuery) {
}
abort_parse:
printf("doParse completed.\n");
// printf("doParse completed.\n");
NewParseFree(pParser, free);
destroyAstCreateContext(&cxt);
pQuery->pRoot = cxt.pRootNode;
......
......@@ -41,19 +41,10 @@ protected:
bool run(int32_t expectCode = TSDB_CODE_SUCCESS) {
int32_t code = doParse(&cxt_, &query_);
if (code != TSDB_CODE_SUCCESS) {
cout << "code:" << tstrerror(code) << ", msg:" << errMagBuf_ << endl;
cout << "sql:[" << cxt_.pSql << "] code:" << tstrerror(code) << ", msg:" << errMagBuf_ << endl;
return (code == expectCode);
}
cout << nodeType(query_.pRoot) << endl;
if (NULL != query_.pRoot && QUERY_NODE_SELECT_STMT == nodeType(query_.pRoot)) {
// SNode* pWhereCond;
// SNodeList* pPartitionByList; // SNode
// SNode* pWindowClause;
// SNodeList* pGroupByList; // SGroupingSetNode
// SNodeList* pOrderByList; // SOrderByExprNode
// SLimitNode limit;
// SLimitNode slimit;
SSelectStmt* select = (SSelectStmt*)query_.pRoot;
string sql("SELECT ");
if (select->isDistinct) {
......@@ -68,14 +59,6 @@ protected:
tableToSql(select->pFromTable, sql);
cout << sql << endl;
}
// char* pStr = NULL;
// int32_t len = 0;
// code = nodesNodeToString(query_.pRoot, &pStr, &len);
// if (code != TSDB_CODE_SUCCESS) {
// cout << "code:" << tstrerror(code) << ", msg:" << errMagBuf_ << endl;
// return code;
// }
// cout << "node tree:\n" << pStr << endl;
return (code == expectCode);
}
......@@ -85,7 +68,6 @@ private:
void tableToSql(const SNode* node, string& sql) {
const STableNode* table = (const STableNode*)node;
cout << "node : " << nodeType(node) << endl;
switch (nodeType(node)) {
case QUERY_NODE_REAL_TABLE: {
SRealTableNode* realTable = (SRealTableNode*)table;
......@@ -108,12 +90,14 @@ private:
if (!firstNode) {
sql.append(", ");
}
firstNode = false;
switch (nodeType(node)) {
case QUERY_NODE_COLUMN:
sql.append(((SColumnNode*)node)->colName);
break;
}
}
sql.append(" ");
}
void reset() {
......@@ -140,6 +124,12 @@ TEST_F(NewParserTest, selectStar) {
bind("SELECT * FROM test.t1");
ASSERT_TRUE(run());
bind("SELECT ts FROM t1");
ASSERT_TRUE(run());
bind("SELECT ts, tag1, c1 FROM t1");
ASSERT_TRUE(run());
}
TEST_F(NewParserTest, syntaxError) {
......
......@@ -91,7 +91,7 @@ static bool logicConditionNodeEqual(const SLogicConditionNode* a, const SLogicCo
static bool isNullConditionNodeEqual(const SIsNullCondNode* a, const SIsNullCondNode* b) {
COMPARE_NODE_FIELD(pExpr);
COMPARE_SCALAR_FIELD(isNot);
COMPARE_SCALAR_FIELD(isNull);
return true;
}
......
......@@ -92,7 +92,12 @@ SNodeList* nodesListAppend(SNodeList* pList, SNode* pNode) {
return pList;
}
p->pNode = pNode;
pList->pTail->pNext = p;
if (NULL == pList->pHead) {
pList->pHead = p;
}
if (NULL != pList->pTail) {
pList->pTail->pNext = p;
}
pList->pTail = p;
return pList;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册