mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-08 02:34:20 +01:00
move our dbsp-based views to materialized views
We will implement normal SQLite-style view-as-an-alias for compatibility, and will call our incremental views materialized views.
This commit is contained in:
@@ -391,6 +391,29 @@ impl ToTokens for Stmt {
|
||||
s.append(TK_AS, None)?;
|
||||
select.to_tokens_with_context(s, context)
|
||||
}
|
||||
Self::CreateMaterializedView {
|
||||
if_not_exists,
|
||||
view_name,
|
||||
columns,
|
||||
select,
|
||||
} => {
|
||||
s.append(TK_CREATE, None)?;
|
||||
s.append(TK_MATERIALIZED, None)?;
|
||||
s.append(TK_VIEW, None)?;
|
||||
if *if_not_exists {
|
||||
s.append(TK_IF, None)?;
|
||||
s.append(TK_NOT, None)?;
|
||||
s.append(TK_EXISTS, None)?;
|
||||
}
|
||||
view_name.to_tokens_with_context(s, context)?;
|
||||
if let Some(columns) = columns {
|
||||
s.append(TK_LP, None)?;
|
||||
comma(columns, s, context)?;
|
||||
s.append(TK_RP, None)?;
|
||||
}
|
||||
s.append(TK_AS, None)?;
|
||||
select.to_tokens_with_context(s, context)
|
||||
}
|
||||
Self::CreateVirtualTable(create_virtual_table) => {
|
||||
let CreateVirtualTable {
|
||||
if_not_exists,
|
||||
|
||||
@@ -130,6 +130,17 @@ pub enum Stmt {
|
||||
/// query
|
||||
select: Box<Select>,
|
||||
},
|
||||
/// `CREATE MATERIALIZED VIEW`
|
||||
CreateMaterializedView {
|
||||
/// `IF NOT EXISTS`
|
||||
if_not_exists: bool,
|
||||
/// view name
|
||||
view_name: QualifiedName,
|
||||
/// columns
|
||||
columns: Option<Vec<IndexedColumn>>,
|
||||
/// query
|
||||
select: Box<Select>,
|
||||
},
|
||||
/// `CREATE VIRTUAL TABLE`
|
||||
CreateVirtualTable(Box<CreateVirtualTable>),
|
||||
/// `DELETE`
|
||||
|
||||
@@ -478,6 +478,11 @@ cmd ::= createkw temp(T) VIEW ifnotexists(E) fullname(Y) eidlist_opt(C)
|
||||
self.ctx.stmt = Some(Stmt::CreateView{ temporary: T, if_not_exists: E, view_name: Y, columns: C,
|
||||
select: Box::new(S) });
|
||||
}
|
||||
cmd ::= createkw MATERIALIZED VIEW ifnotexists(E) fullname(Y) eidlist_opt(C)
|
||||
AS select(S). {
|
||||
self.ctx.stmt = Some(Stmt::CreateMaterializedView{ if_not_exists: E, view_name: Y, columns: C,
|
||||
select: Box::new(S) });
|
||||
}
|
||||
cmd ::= DROP VIEW ifexists(E) fullname(X). {
|
||||
self.ctx.stmt = Some(Stmt::DropView{ if_exists: E, view_name: X });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user