Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ derive_more = "0.99"
dialoguer = { version = "0.11", default-features = false }
dirs = "5.0.1"
duct = "0.13.5"
ecow = "0.2.6"
either = "1.9"
email_address = "0.2.4"
enum-as-inner = "0.6"
Expand Down Expand Up @@ -220,6 +219,7 @@ jsonwebtoken = { package = "spacetimedb-jsonwebtoken", version = "9.3.0" }
junction = "1"
jwks = { package = "spacetimedb-jwks", version = "0.1.3" }
lazy_static = "1.4.0"
lean_string = "0.5.1"
log = "0.4.17"
memchr = "2"
mimalloc = "0.1.39"
Expand Down
2 changes: 1 addition & 1 deletion crates/bench/benches/special.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ fn serialize_benchmarks<
});

let mut table_schema = TableSchema::from_product_type(T::product_type());
table_schema.table_name = TableName::new_from_str(name);
table_schema.table_name = TableName::for_test(name);
let mut table = spacetimedb_table::table::Table::new(
Arc::new(table_schema),
spacetimedb_table::indexes::SquashedOffset::COMMITTED_STATE,
Expand Down
2 changes: 1 addition & 1 deletion crates/bench/benches/subscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn create_table_footprint(db: &RelationalDB) -> Result<TableId, DBError> {
fn insert_op(table_id: TableId, table_name: &str, row: ProductValue) -> DatabaseTableUpdate {
DatabaseTableUpdate {
table_id,
table_name: TableName::new_from_str(table_name),
table_name: TableName::for_test(table_name),
inserts: [row].into(),
deletes: [].into(),
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bench/src/schemas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ pub fn table_name<T: BenchTable>(style: IndexStrategy) -> TableName {
let prefix = style.name();
let name = T::name();

TableName::new_from_str(&format!("{prefix}_{name}"))
TableName::for_test(&format!("{prefix}_{name}"))
}

// ---------- data synthesis ----------
Expand Down
2 changes: 1 addition & 1 deletion crates/bench/src/spacetime_raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl BenchDatabase for SpacetimeRaw {
let mut table_schema = TableSchema::from_product_type(T::product_type());
table_schema.table_name = name.clone();
let table_id = self.db.create_table(tx, table_schema)?;
self.db.rename_table(tx, table_id, &name)?;
self.db.rename_table(tx, table_id, name)?;
match index_strategy {
IndexStrategy::Unique0 => {
self.db.create_index(
Expand Down
2 changes: 1 addition & 1 deletion crates/bench/src/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ impl BenchDatabase for SQLite {
value: AlgebraicValue,
) -> ResultBench<()> {
let statement = memo_query(BenchName::Filter, table_id, || {
let column: Box<str> = T::product_type().elements[col_id.into().idx()].name.take().unwrap();
let column = T::product_type().elements[col_id.into().idx()].name.clone().unwrap();
format!("SELECT * FROM {table_id} WHERE {column} = ?")
});

Expand Down
2 changes: 1 addition & 1 deletion crates/bindings/src/rt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ pub fn register_table<T: Table>() {
for &col in T::UNIQUE_COLUMNS {
table = table.with_unique_constraint(col);
}
for &index in T::INDEXES {
for index in T::INDEXES {
table = table.with_index(index.algo.into(), index.accessor_name);
}
if let Some(primary_key) = T::PRIMARY_KEY {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
source: crates/bindings/tests/deps.rs
expression: "cargo tree -p spacetimedb -e no-dev --color never --target wasm32-unknown-unknown -f {lib}"
---
total crates: 70
total crates: 73
spacetimedb
├── anyhow
├── bytemuck
Expand Down Expand Up @@ -106,6 +106,11 @@ spacetimedb
│ │ │ └── serde_core
│ │ ├── hex
│ │ ├── itertools (*)
│ │ ├── lean_string
│ │ │ ├── castaway
│ │ │ │ └── rustversion
│ │ │ ├── itoa
│ │ │ └── ryu
│ │ ├── second_stack
│ │ ├── sha3
│ │ │ ├── digest
Expand Down
3 changes: 2 additions & 1 deletion crates/cli/src/subcommands/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::util::UNSTABLE_WARNING;
use anyhow::{bail, Context, Error};
use clap::{Arg, ArgMatches};
use convert_case::{Case, Casing};
use core::ops::Deref;
use itertools::Itertools;
use spacetimedb_lib::sats::{self, AlgebraicType, Typespace};
use spacetimedb_lib::{Identity, ProductTypeElement};
Expand Down Expand Up @@ -198,7 +199,7 @@ impl std::fmt::Display for CallSignature<'_> {
}
comma = true;
if let Some(name) = arg.name() {
write!(f, "{}: ", name.to_case(Case::Snake))?;
write!(f, "{}: ", name.deref().to_case(Case::Snake))?;
}
write_type::write_type(typespace, f, &arg.algebraic_type)?;
}
Expand Down
13 changes: 6 additions & 7 deletions crates/cli/src/subcommands/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,12 @@ fn build_table<E>(
rows: impl Iterator<Item = Result<ProductValue, E>>,
) -> Result<tabled::Table, E> {
let mut builder = tabled::builder::Builder::default();
builder.set_header(
schema
.elements
.iter()
.enumerate()
.map(|(i, e)| e.name.clone().unwrap_or_else(|| format!("column {i}").into())),
);
builder.set_header(schema.elements.iter().enumerate().map(|(i, e)| {
e.name
.as_ref()
.map(|n| n.to_string())
.unwrap_or_else(|| format!("column {i}"))
}));

let ty = Typespace::EMPTY.with_type(schema);
for row in rows {
Expand Down
1 change: 1 addition & 0 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ spacetimedb-lib = { path = "../lib", features = ["proptest", "test"] }
spacetimedb-sats = { path = "../sats", features = ["proptest"] }
spacetimedb-commitlog = { path = "../commitlog", features = ["test"] }
spacetimedb-datastore = { path = "../datastore/", features = ["test"] }
spacetimedb-vm = { workspace = true, features = ["test"]}

criterion.workspace = true
# Also as dev-dependencies for use in _this_ crate's tests.
Expand Down
13 changes: 12 additions & 1 deletion crates/core/src/client/message_handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ use spacetimedb_datastore::execution_context::WorkloadType;
use spacetimedb_lib::de::serde::DeserializeWrapper;
use spacetimedb_lib::identity::RequestId;
use spacetimedb_lib::{bsatn, ConnectionId, Timestamp};
use spacetimedb_sats::raw_identifier::RawIdentifier;
use spacetimedb_schema::identifier::Identifier;
use spacetimedb_schema::reducer_name::ReducerName;
use std::borrow::Cow;
use std::sync::Arc;
Expand Down Expand Up @@ -174,12 +176,21 @@ pub struct MessageExecutionError {

impl MessageExecutionError {
fn into_event(self) -> ModuleEvent {
let reducer = self
.reducer
.as_deref()
.map(RawIdentifier::new)
.map(Identifier::new)
.transpose()
.unwrap()
.map(ReducerName::new);

ModuleEvent {
timestamp: Timestamp::now(),
caller_identity: self.caller_identity,
caller_connection_id: self.caller_connection_id,
function_call: ModuleFunctionCall {
reducer: ReducerName::new_from_str(&self.reducer.unwrap_or_else(|| "<none>".into())),
reducer,
reducer_id: self.reducer_id.unwrap_or(u32::MAX.into()),
args: Default::default(),
},
Expand Down
8 changes: 6 additions & 2 deletions crates/core/src/client/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use crate::subscription::row_list_builder_pool::BsatnRowListBuilderPool;
use crate::subscription::websocket_building::{brotli_compress, decide_compression, gzip_compress};
use bytes::{BufMut, Bytes, BytesMut};
use bytestring::ByteString;
use core::ops::Deref;
use derive_more::From;
use spacetimedb_client_api_messages::websocket::{
BsatnFormat, Compression, FormatSwitch, JsonFormat, OneOffTable, RowListLen, WebsocketFormat,
Expand Down Expand Up @@ -283,7 +282,12 @@ impl ToProtocol for TransactionUpdateMessage {
status,
caller_identity: event.caller_identity,
reducer_call: ws::ReducerCallInfo {
reducer_name: event.function_call.reducer.deref().into(),
reducer_name: event
.function_call
.reducer
.as_ref()
.map(|r| (&**r).into())
.unwrap_or_default(),
reducer_id: event.function_call.reducer_id.into(),
args,
request_id,
Expand Down
4 changes: 2 additions & 2 deletions crates/core/src/db/durability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ impl DurabilityWorkerActor {

pub fn do_durability(durability: &Durability, reducer_context: Option<ReducerContext>, tx_data: &TxData) {
if tx_data.tx_offset().is_none() {
let name = reducer_context.as_ref().map(|rcx| &*rcx.name);
let name = reducer_context.as_ref().map(|rcx| &rcx.name);
debug_assert!(
!tx_data.has_rows_or_connect_disconnect(name),
"tx_data has no rows but has connect/disconnect: `{name:?}`"
Expand Down Expand Up @@ -318,7 +318,7 @@ mod tests {
let mut txdata = TxData::default();
txdata.set_tx_offset(i);
// Ensure the transaction is non-empty.
txdata.set_inserts_for_table(4000.into(), &TableName::new_from_str("foo"), [product![42u8]].into());
txdata.set_inserts_for_table(4000.into(), &TableName::for_test("foo"), [product![42u8]].into());

worker.request_durability(None, &Arc::new(txdata));
}
Expand Down
8 changes: 4 additions & 4 deletions crates/core/src/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub struct Config {
/// We use a separate task to record metrics to avoid blocking transactions.
pub struct MetricsMessage {
/// The reducer the produced these metrics.
reducer: ReducerName,
reducer: Option<ReducerName>,
/// Metrics from a mutable transaction.
metrics_for_writer: Option<TxMetrics>,
/// Metrics from a read-only transaction.
Expand All @@ -61,7 +61,7 @@ pub struct MetricsRecorderQueue {
impl MetricsRecorderQueue {
pub fn send_metrics(
&self,
reducer: ReducerName,
reducer: Option<ReducerName>,
metrics_for_writer: Option<TxMetrics>,
metrics_for_reader: Option<TxMetrics>,
tx_data: Option<Arc<TxData>>,
Expand Down Expand Up @@ -97,7 +97,7 @@ pub fn spawn_tx_metrics_recorder() -> (MetricsRecorderQueue, tokio::task::AbortH
// If row updates are present,
// they will always belong to the writer transaction.
tx_data.as_deref(),
&reducer,
reducer.as_ref(),
|wl| &counters[wl],
);
}
Expand All @@ -107,7 +107,7 @@ pub fn spawn_tx_metrics_recorder() -> (MetricsRecorderQueue, tokio::task::AbortH
// they will never belong to the reader transaction.
// Passing row updates here will most likely panic.
None,
&reducer,
reducer.as_ref(),
|wl| &counters[wl],
);
}
Expand Down
Loading
Loading