No FROM required (#94)
This commit is contained in:
parent
c7e8309363
commit
82e73f66d2
File diff suppressed because it is too large
Load Diff
|
@ -193,7 +193,7 @@ int yyerror(YYLTYPE* llocp, SQLParserResult* result, yyscan_t scanner, const cha
|
|||
%type <sval> file_path prepare_target_query
|
||||
%type <bval> opt_not_exists opt_exists opt_distinct
|
||||
%type <uval> import_file_type opt_join_type column_type
|
||||
%type <table> from_clause table_ref table_ref_atomic table_ref_name nonjoin_table_ref_atomic
|
||||
%type <table> opt_from_clause from_clause table_ref table_ref_atomic table_ref_name nonjoin_table_ref_atomic
|
||||
%type <table> join_clause table_ref_name_no_alias
|
||||
%type <expr> expr operand scalar_expr unary_expr binary_expr logic_expr exists_expr
|
||||
%type <expr> function_expr between_expr expr_alias param_expr
|
||||
|
@ -640,7 +640,7 @@ opt_all:
|
|||
;
|
||||
|
||||
select_clause:
|
||||
SELECT opt_top opt_distinct select_list from_clause opt_where opt_group {
|
||||
SELECT opt_top opt_distinct select_list opt_from_clause opt_where opt_group {
|
||||
$$ = new SelectStatement();
|
||||
$$->limit = $2;
|
||||
$$->selectDistinct = $3;
|
||||
|
@ -660,6 +660,10 @@ select_list:
|
|||
expr_list
|
||||
;
|
||||
|
||||
opt_from_clause:
|
||||
from_clause { $$ = $1; }
|
||||
| /* empty */ { $$ = nullptr; }
|
||||
|
||||
from_clause:
|
||||
FROM table_ref { $$ = $2; }
|
||||
;
|
||||
|
|
|
@ -4,10 +4,9 @@
|
|||
!
|
||||
!1
|
||||
!gibberish;
|
||||
!SELECT abc;
|
||||
!CREATE TABLE "table" FROM TBL FILE 'students.tbl';SELECT 1
|
||||
!CREATE TABLE "table" FROM TBL FILE 'students.tbl';gibberish
|
||||
!CREATE TABLE "table" FROM TBL FILE 'students.tbl';1
|
||||
!INSERT INTO test_table VALUESd (1, 2, 'test');
|
||||
!SELECT * FROM t WHERE a = ? AND b = ?;SELECT 1;
|
||||
!SELECT * FROM t WHERE a = ? AND b = ?;gibberish;
|
||||
!SHOW COLUMNS;
|
||||
!select a + 2 as b(spam, eggs) from B;
|
||||
|
|
|
@ -542,3 +542,22 @@ TEST(SetLimitOffset) {
|
|||
ASSERT_EQ(stmt->limit->offset, kNoOffset);
|
||||
}
|
||||
|
||||
TEST(NoFromClause) {
|
||||
TEST_PARSE_SINGLE_SQL(
|
||||
"SELECT 1 + 2;",
|
||||
kStmtSelect,
|
||||
SelectStatement,
|
||||
result,
|
||||
stmt);
|
||||
|
||||
ASSERT_TRUE(stmt->selectList);
|
||||
ASSERT_FALSE(stmt->fromTable);
|
||||
ASSERT_FALSE(stmt->whereClause);
|
||||
ASSERT_FALSE(stmt->groupBy);
|
||||
|
||||
ASSERT_EQ(stmt->selectList->size(), 1u);
|
||||
ASSERT_EQ(stmt->selectList->at(0)->type, kExprOperator);
|
||||
ASSERT_EQ(stmt->selectList->at(0)->expr->type, kExprLiteralInt);
|
||||
ASSERT_EQ(stmt->selectList->at(0)->expr2->type, kExprLiteralInt);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue