added grammar rules for prepare and execute

This commit is contained in:
Pedro 2014-12-15 15:01:01 +01:00
parent 98c84abcba
commit 6f1a2821b2
3 changed files with 16 additions and 4 deletions

View File

@ -16,6 +16,7 @@ typedef enum {
kExprLiteralString,
kExprLiteralInt,
kExprStar,
kExprPlaceholder,
kExprColumnRef,
kExprFunctionRef,
kExprOperator

View File

@ -153,7 +153,8 @@ typedef void* yyscan_t;
** Non-Terminal types (http://www.gnu.org/software/bison/manual/html_node/Type-Decl.html)
*********************************/
%type <stmt_list> statement_list
%type <statement> statement preparable_statement prepare_statement
%type <statement> statement preparable_statement
%type <statement> prepare_statement execute_statement
%type <select_stmt> select_statement select_with_paren select_no_paren select_clause
%type <import_stmt> import_statement
%type <create_stmt> create_statement
@ -166,7 +167,7 @@ typedef void* yyscan_t;
%type <uval> import_file_type opt_join_type column_type
%type <table> from_clause table_ref table_ref_atomic table_ref_name
%type <table> join_clause join_table table_ref_name_no_alias
%type <expr> expr scalar_expr unary_expr binary_expr function_expr star_expr expr_alias
%type <expr> expr scalar_expr unary_expr binary_expr function_expr star_expr expr_alias placeholder_expr
%type <expr> column_name literal int_literal num_literal string_literal
%type <expr> comp_expr opt_where join_condition
%type <expr_list> expr_list opt_group select_list literal_list
@ -234,6 +235,7 @@ preparable_statement:
| truncate_statement { $$ = $1; }
| update_statement { $$ = $1; }
| drop_statement { $$ = $1; }
| execute_statement { $$ = $1; }
;
@ -244,6 +246,9 @@ prepare_statement:
PREPARE IDENTIFIER ':' preparable_statement { $$ = NULL; }
;
execute_statement:
EXECUTE IDENTIFIER '(' literal_list ')' { $$ = NULL; }
;
/******************************
@ -558,6 +563,7 @@ column_name:
literal:
string_literal
| num_literal
| placeholder_expr
;
string_literal:
@ -578,6 +584,11 @@ star_expr:
'*' { $$ = new Expr(kExprStar); }
;
/* TODO: keep list of placeholders */
placeholder_expr:
'?' { $$ = new Expr(kExprPlaceholder); }
;
/******************************
* Table

View File

@ -4,7 +4,7 @@ SELECT a FROM foo WHERE a > 12 OR b > 3 AND NOT c LIMIT 10
SELECT col1 AS myname, col2, 'test' FROM "table", foo AS t WHERE age > 12 AND zipcode = 12345 GROUP BY col1;
SELECT * from "table" JOIN table2 ON a = b WHERE (b OR NOT a) AND a = 12.5
(SELECT a FROM foo WHERE a > 12 OR b > 3 AND c NOT LIKE 's%' LIMIT 10);
SELECT * FROM "table" LIMIT 10 OFFSET 10;
SELECT * FROM "table" LIMIT 10 OFFSET 10; SELECT * FROM second;
SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY col1;
# SELECT * FROM t1 UNION (SELECT * FROM t2 UNION SELECT * FROM t3) ORDER BY col1;
# JOIN