now supporting * in select list
This commit is contained in:
parent
5dfcce1b7d
commit
200402bab2
|
@ -93,7 +93,7 @@ typedef void* yyscan_t;
|
|||
%type <expr> expr column_name scalar_exp literal
|
||||
%type <expr> comparison_predicate predicate search_condition where_clause
|
||||
%type <slist> table_ref_commalist
|
||||
%type <explist> expr_list group_clause
|
||||
%type <explist> expr_list group_clause select_list
|
||||
|
||||
|
||||
|
||||
|
@ -125,7 +125,7 @@ statement:
|
|||
// TODO: limit
|
||||
// TODO: order by
|
||||
select_statement:
|
||||
SELECT expr_list from_clause where_clause group_clause
|
||||
SELECT select_list from_clause where_clause group_clause
|
||||
{
|
||||
SelectStatement* s = new SelectStatement();
|
||||
s->select_list = $2;
|
||||
|
@ -137,6 +137,10 @@ select_statement:
|
|||
;
|
||||
|
||||
|
||||
select_list:
|
||||
'*' { $$ = new List<Expr*>(makeColumnRef("*")); }
|
||||
| expr_list;
|
||||
|
||||
|
||||
from_clause:
|
||||
FROM table_exp { $$ = $2; }
|
||||
|
|
|
@ -50,17 +50,15 @@ void SelectTest2() {
|
|||
printf("Test: SelectTest2... ");
|
||||
fflush(stdout);
|
||||
|
||||
const char* sql = "SELECT age, name, address FROM (SELECT age FROM table, table2);";
|
||||
const char* sql = "SELECT * FROM (SELECT age FROM table, table2);";
|
||||
Statement* stmt = SQLParser::parseSQL(sql);
|
||||
ASSERT(stmt != NULL);
|
||||
ASSERT(stmt->type == eSelect);
|
||||
|
||||
SelectStatement* select = (SelectStatement*) stmt;
|
||||
|
||||
ASSERT(select->select_list->size() == 3);
|
||||
ASSERT_STR(select->select_list->at(0)->name, "age");
|
||||
ASSERT_STR(select->select_list->at(1)->name, "name");
|
||||
ASSERT_STR(select->select_list->at(2)->name, "address");
|
||||
ASSERT(select->select_list->size() == 1);
|
||||
ASSERT_STR(select->select_list->at(0)->name, "*");
|
||||
|
||||
ASSERT(select->from_table != NULL);
|
||||
ASSERT(select->from_table->type == eTableSelect);
|
||||
|
|
Loading…
Reference in New Issue