boxed select and selectbody (by gwenn and jussisaurio)

This commit is contained in:
Jussi Saurio
2025-01-05 13:50:32 +02:00
parent d35eadb22c
commit f5540e9602
2 changed files with 19 additions and 19 deletions

View File

@@ -144,7 +144,7 @@ pub enum Stmt {
/// columns
columns: Option<Vec<IndexedColumn>>,
/// query
select: Select,
select: Box<Select>,
},
/// `CREATE VIRTUAL TABLE`
CreateVirtualTable {
@@ -238,7 +238,7 @@ pub enum Stmt {
/// `SAVEPOINT`: savepoint name
Savepoint(Name),
/// `SELECT`
Select(Select),
Select(Box<Select>),
/// `UPDATE`
Update {
/// CTE
@@ -707,7 +707,7 @@ pub struct Select {
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct SelectBody {
/// first select
pub select: OneSelect,
pub select: Box<OneSelect>,
/// compounds
pub compounds: Option<Vec<CompoundSelect>>,
}
@@ -888,7 +888,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>),
}
@@ -1222,7 +1222,7 @@ pub enum CreateTableBody {
options: TableOptions,
},
/// `AS` select
AsSelect(Select),
AsSelect(Box<Select>),
}
impl CreateTableBody {
@@ -1549,7 +1549,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,
}
@@ -1649,7 +1649,7 @@ pub enum TriggerCmd {
/// `COLUMNS`
col_names: Option<DistinctNames>,
/// `SELECT` or `VALUES`
select: Select,
select: Box<Select>,
/// `ON CONLICT` clause
upsert: Option<Upsert>,
/// `RETURNING`
@@ -1663,7 +1663,7 @@ pub enum TriggerCmd {
where_clause: Option<Expr>,
},
/// `SELECT`
Select(Select),
Select(Box<Select>),
}
/// Conflict resolution types
@@ -1714,7 +1714,7 @@ pub struct CommonTableExpr {
/// `MATERIALIZED`
pub materialized: Materialized,
/// query
pub select: Select,
pub select: Box<Select>,
}
impl CommonTableExpr {

View File

@@ -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}
@@ -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 });
@@ -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}
@@ -509,11 +509,11 @@ select(A) ::= selectnowith(X) orderby_opt(Z) limit_opt(L). {
}
selectnowith(A) ::= oneselect(X). {
A = SelectBody{ select: X, compounds: None };
A = SelectBody{ select: Box::new(X), compounds: None };
}
%ifndef SQLITE_OMIT_COMPOUND_SELECT
selectnowith(A) ::= selectnowith(A) multiselect_op(Y) oneselect(Z). {
let cs = CompoundSelect{ operator: Y, select: Z };
let cs = CompoundSelect{ operator: Y, select: Box::new(Z) };
A.push(cs)?;
}
%type multiselect_op {CompoundOperator}
@@ -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)?;
}
@@ -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 });
}
@@ -1241,7 +1241,7 @@ 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).
@@ -1249,7 +1249,7 @@ trigger_cmd(A) ::= DELETE FROM trnm(X) tridxby where_opt(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. {
@@ -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*/