added frame for join statements
This commit is contained in:
parent
bb1ec42022
commit
e177b8cef7
|
@ -275,7 +275,7 @@ table_ref_atomic:
|
|||
}
|
||||
| '(' select_statement ')' {
|
||||
auto tbl = new TableRef(kTableSelect);
|
||||
tbl->stmt = $2;
|
||||
tbl->select = $2;
|
||||
$$ = tbl;
|
||||
}
|
||||
;
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
typedef enum {
|
||||
kStmtSelect,
|
||||
kStmtJoin,
|
||||
kStmtDelete,
|
||||
kStmtInsert,
|
||||
kStmtCreate
|
||||
|
@ -34,6 +35,14 @@ struct OrderDescription {
|
|||
};
|
||||
|
||||
|
||||
typedef enum {
|
||||
kJoinInner,
|
||||
kJoinOuter,
|
||||
kJoinLeft,
|
||||
kJoinRight
|
||||
} JoinType;
|
||||
|
||||
|
||||
struct Statement {
|
||||
Statement(StatementType type) : type(type) {};
|
||||
StatementType type;
|
||||
|
@ -56,6 +65,16 @@ struct SelectStatement : Statement {
|
|||
};
|
||||
|
||||
|
||||
struct JoinStatement : Statement {
|
||||
JoinStatement() : Statement(kStmtJoin) {};
|
||||
|
||||
TableRef* table1;
|
||||
TableRef* table2;
|
||||
JoinType join_type;
|
||||
Expr* join_condition;
|
||||
};
|
||||
|
||||
|
||||
struct DeleteStatement : Statement {
|
||||
// TODO
|
||||
};
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#ifndef __TABLEREF_H_
|
||||
#define __TABLEREF_H_
|
||||
#ifndef __TABLEREF_H__
|
||||
#define __TABLEREF_H__
|
||||
|
||||
class SelectStatement;
|
||||
class JoinStatement;
|
||||
|
||||
/**
|
||||
* TableRef
|
||||
|
@ -10,6 +11,7 @@ class SelectStatement;
|
|||
typedef enum {
|
||||
kTableName,
|
||||
kTableSelect,
|
||||
kTableJoin,
|
||||
kTableCrossProduct
|
||||
} TableRefType;
|
||||
|
||||
|
@ -21,7 +23,8 @@ struct TableRef {
|
|||
TableRefType type;
|
||||
|
||||
char* name;
|
||||
SelectStatement* stmt;
|
||||
SelectStatement* select;
|
||||
JoinStatement* join;
|
||||
List<TableRef*>* list;
|
||||
};
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ void printTableRefInfo(TableRef* table, uint num_indent) {
|
|||
inprint(table->name, num_indent);
|
||||
break;
|
||||
case kTableSelect:
|
||||
printSelectStatementInfo(table->stmt, num_indent);
|
||||
printSelectStatementInfo(table->select, num_indent);
|
||||
break;
|
||||
case kTableCrossProduct:
|
||||
for (TableRef* tbl : table->list->_vector) printTableRefInfo(tbl, num_indent);
|
||||
|
|
Loading…
Reference in New Issue