Skip to content

Commit

Permalink
Merge pull request #80 from gwenn/boxed_select
Browse files Browse the repository at this point in the history
Boxed Select
  • Loading branch information
gwenn authored Jan 4, 2025
2 parents 6f46367 + 12a6688 commit 6ec9c97
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions src/parser/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ pub enum Stmt {
/// columns
columns: Option<Vec<IndexedColumn>>,
/// query
select: Select,
select: Box<Select>,
},
/// `CREATE VIRTUAL TABLE`
CreateVirtualTable {
Expand Down Expand Up @@ -238,7 +238,7 @@ pub enum Stmt {
/// `SAVEPOINT`: savepoint name
Savepoint(Name),
/// `SELECT`
Select(Select),
Select(Box<Select>),
/// `UPDATE`
Update {
/// CTE
Expand Down Expand Up @@ -859,7 +859,7 @@ pub enum SelectTable {
/// table function call
TableCall(QualifiedName, Option<Vec<Expr>>, Option<As>),
/// `SELECT` subquery
Select(Select, Option<As>),
Select(Box<Select>, Option<As>),
/// subquery
Sub(FromClause, Option<As>),
}
Expand Down Expand Up @@ -1193,7 +1193,7 @@ pub enum CreateTableBody {
options: TableOptions,
},
/// `AS` select
AsSelect(Select),
AsSelect(Box<Select>),
}

impl CreateTableBody {
Expand Down Expand Up @@ -1520,7 +1520,7 @@ pub struct Limit {
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum InsertBody {
/// `SELECT` or `VALUES`
Select(Select, Option<Upsert>),
Select(Box<Select>, Option<Upsert>),
/// `DEFAULT VALUES`
DefaultValues,
}
Expand Down Expand Up @@ -1599,7 +1599,7 @@ pub enum TriggerCmd {
/// `COLUMNS`
col_names: Option<DistinctNames>,
/// `SELECT` or `VALUES`
select: Select,
select: Box<Select>,
/// `ON CONLICT` clause
upsert: Option<Upsert>,
/// `RETURNING`
Expand All @@ -1613,7 +1613,7 @@ pub enum TriggerCmd {
where_clause: Option<Expr>,
},
/// `SELECT`
Select(Select),
Select(Box<Select>),
}

/// Conflict resolution types
Expand Down Expand Up @@ -1664,7 +1664,7 @@ pub struct CommonTableExpr {
/// `MATERIALIZED`
pub materialized: Materialized,
/// query
pub select: Select,
pub select: Box<Select>,
}

impl CommonTableExpr {
Expand Down
16 changes: 8 additions & 8 deletions src/parser/parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ create_table_args(A) ::= LP columnlist(C) conslist_opt(X) RP table_option_set(F)
A = CreateTableBody::columns_and_constraints(C, X, F)?;
}
create_table_args(A) ::= AS select(S). {
A = CreateTableBody::AsSelect(S);
A = CreateTableBody::AsSelect(Box::new(S));
}
%type table_option_set {TableOptions}
%type table_option {TableOptions}
Expand Down Expand Up @@ -476,7 +476,7 @@ ifexists(A) ::= . {A = false;}
cmd ::= createkw temp(T) VIEW ifnotexists(E) fullname(Y) eidlist_opt(C)
AS select(S). {
self.ctx.stmt = Some(Stmt::CreateView{ temporary: T, if_not_exists: E, view_name: Y, columns: C,
select: S });
select: Box::new(S) });
}
cmd ::= DROP VIEW ifexists(E) fullname(X). {
self.ctx.stmt = Some(Stmt::DropView{ if_exists: E, view_name: X });
Expand All @@ -486,7 +486,7 @@ cmd ::= DROP VIEW ifexists(E) fullname(X). {
//////////////////////// The SELECT statement /////////////////////////////////
//
cmd ::= select(X). {
self.ctx.stmt = Some(Stmt::Select(X));
self.ctx.stmt = Some(Stmt::Select(Box::new(X)));
}

%type select {Select}
Expand Down Expand Up @@ -621,7 +621,7 @@ seltablist(A) ::= stl_prefix(A) fullname(Y) LP exprlist(E) RP as(Z)
%ifndef SQLITE_OMIT_SUBQUERY
seltablist(A) ::= stl_prefix(A) LP select(S) RP
as(Z) on_using(N). {
let st = SelectTable::Select(S, Z);
let st = SelectTable::Select(Box::new(S), Z);
let jc = N;
A.push(st, jc)?;
}
Expand Down Expand Up @@ -826,7 +826,7 @@ setlist(A) ::= LP idlist(X) RP EQ expr(Y). {
cmd ::= with(W) insert_cmd(R) INTO xfullname(X) idlist_opt(F) select(S)
upsert(U). {
let (upsert, returning) = U;
let body = InsertBody::Select(S, upsert);
let body = InsertBody::Select(Box::new(S), upsert);
self.ctx.stmt = Some(Stmt::Insert{ with: W, or_conflict: R, tbl_name: X, columns: F,
body, returning });
}
Expand Down Expand Up @@ -1241,15 +1241,15 @@ trigger_cmd(A) ::=
trigger_cmd(A) ::= insert_cmd(R) INTO
trnm(X) idlist_opt(F) select(S) upsert(U). {
let (upsert, returning) = U;
A = TriggerCmd::Insert{ or_conflict: R, tbl_name: X, col_names: F, select: S, upsert, returning };/*A-overwrites-R*/
A = TriggerCmd::Insert{ or_conflict: R, tbl_name: X, col_names: F, select: Box::new(S), upsert, returning };/*A-overwrites-R*/
}
// DELETE
trigger_cmd(A) ::= DELETE FROM trnm(X) tridxby where_opt(Y).
{A = TriggerCmd::Delete{ tbl_name: X, where_clause: Y };}

// SELECT
trigger_cmd(A) ::= select(X).
{A = TriggerCmd::Select(X); /*A-overwrites-X*/}
{A = TriggerCmd::Select(Box::new(X)); /*A-overwrites-X*/}

// The special RAISE expression that may occur in trigger programs
expr(A) ::= RAISE LP IGNORE RP. {
Expand Down Expand Up @@ -1368,7 +1368,7 @@ wqas(A) ::= AS. {A = Materialized::Any;}
wqas(A) ::= AS MATERIALIZED. {A = Materialized::Yes;}
wqas(A) ::= AS NOT MATERIALIZED. {A = Materialized::No;}
wqitem(A) ::= nm(X) eidlist_opt(Y) wqas(M) LP select(Z) RP. {
A = CommonTableExpr{ tbl_name: X, columns: Y, materialized: M, select: Z }; /*A-overwrites-X*/
A = CommonTableExpr{ tbl_name: X, columns: Y, materialized: M, select: Box::new(Z) }; /*A-overwrites-X*/
}
wqlist(A) ::= wqitem(X). {
A = vec![X]; /*A-overwrites-X*/
Expand Down

0 comments on commit 6ec9c97

Please sign in to comment.