add support for LIMIT clause in SQL engine

This commit is contained in:
Brian Bruns
2016-08-30 08:43:34 -04:00
parent 2355aec912
commit 23bab7c2d6
5 changed files with 37 additions and 11 deletions

View File

@@ -42,7 +42,7 @@ static MdbSQL *g_sql;
%token <name> IDENT NAME PATH STRING NUMBER
%token SELECT FROM WHERE CONNECT DISCONNECT TO LIST TABLES AND OR NOT
%token SELECT FROM WHERE CONNECT DISCONNECT TO LIST TABLES AND OR NOT LIMIT
%token DESCRIBE TABLE
%token LTEQ GTEQ LIKE IS NUL
@@ -60,7 +60,7 @@ stmt:
;
query:
SELECT column_list FROM table where_clause {
SELECT column_list FROM table where_clause limit_clause {
mdb_sql_select(_mdb_sql(NULL));
}
| CONNECT TO database {
@@ -82,6 +82,11 @@ where_clause:
| WHERE sarg_list
;
limit_clause:
/* empty */
| LIMIT NUMBER { mdb_sql_add_limit(_mdb_sql(NULL), $2); free($2); }
;
sarg_list:
sarg
| '(' sarg_list ')'