-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RLS: Adding a new filter! macro (#1849)
Signed-off-by: Mario Montoya <mamcx@elmalabarista.com> Co-authored-by: joshua-spacetime <josh@clockworklabs.io>
- Loading branch information
1 parent
0a86b46
commit 637d6d7
Showing
16 changed files
with
269 additions
and
22 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pub mod ast; | ||
pub mod compiler; | ||
pub mod execute; | ||
pub mod parser; | ||
mod type_check; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use crate::db::datastore::locking_tx_datastore::MutTxId; | ||
use crate::db::relational_db::RelationalDB; | ||
use crate::sql::ast::SchemaViewer; | ||
use spacetimedb_expr::check::parse_and_type_sub; | ||
use spacetimedb_expr::errors::TypingError; | ||
use spacetimedb_expr::expr::RelExpr; | ||
use spacetimedb_expr::ty::TyCtx; | ||
use spacetimedb_lib::db::raw_def::v9::RawRowLevelSecurityDefV9; | ||
use spacetimedb_lib::identity::AuthCtx; | ||
use spacetimedb_schema::schema::RowLevelSecuritySchema; | ||
|
||
pub struct RowLevelExpr { | ||
pub sql: RelExpr, | ||
pub def: RowLevelSecuritySchema, | ||
} | ||
|
||
impl RowLevelExpr { | ||
pub fn build_row_level_expr( | ||
stdb: &RelationalDB, | ||
tx: &mut MutTxId, | ||
auth_ctx: &AuthCtx, | ||
rls: &RawRowLevelSecurityDefV9, | ||
) -> Result<Self, TypingError> { | ||
let mut ctx = TyCtx::default(); | ||
let sql = parse_and_type_sub(&mut ctx, &rls.sql, &SchemaViewer::new(stdb, tx, auth_ctx))?; | ||
|
||
Ok(Self { | ||
def: RowLevelSecuritySchema { | ||
table_id: sql.table_id(&mut ctx)?, | ||
sql: rls.sql.clone(), | ||
}, | ||
sql, | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
637d6d7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Criterion benchmark results
Criterion benchmark report
YOU SHOULD PROBABLY IGNORE THESE RESULTS.
Criterion is a wall time based benchmarking system that is extremely noisy when run on CI. We collect these results for longitudinal analysis, but they are not reliable for comparing individual PRs.
Go look at the callgrind report instead.
empty
insert_1
insert_bulk
iterate
find_unique
filter
serialize
stdb_module_large_arguments
stdb_module_print_bulk
remaining
637d6d7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Callgrind benchmark results
Callgrind Benchmark Report
These benchmarks were run using callgrind,
an instruction-level profiler. They allow comparisons between sqlite (
sqlite
), SpacetimeDB running through a module (stdb_module
), and the underlying SpacetimeDB data storage engine (stdb_raw
). Callgrind emulates a CPU to collect the below estimates.Measurement changes larger than five percent are in bold.
In-memory benchmarks
callgrind: empty transaction
callgrind: filter
callgrind: insert bulk
callgrind: iterate
callgrind: serialize_product_value
callgrind: update bulk
On-disk benchmarks
callgrind: empty transaction
callgrind: filter
callgrind: insert bulk
callgrind: iterate
callgrind: serialize_product_value
callgrind: update bulk