Skip to content

[pull] main from tursodatabase:main #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 20, 2025
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
12 changes: 6 additions & 6 deletions Cargo.lock

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

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ exclude = [
]

[workspace.package]
version = "0.9.7"
version = "0.9.8"
authors = ["the libSQL authors"]
edition = "2021"
license = "MIT"
repository = "https://github.com/tursodatabase/libsql"

[workspace.dependencies]
libsql-ffi = { path = "libsql-ffi", version = "0.9.7" }
libsql-sys = { path = "libsql-sys", version = "0.9.7", default-features = false }
libsql-hrana = { path = "libsql-hrana", version = "0.9.7" }
libsql_replication = { path = "libsql-replication", version = "0.9.7" }
rusqlite = { package = "libsql-rusqlite", path = "vendored/rusqlite", version = "0.9.7", default-features = false, features = [
libsql-ffi = { path = "libsql-ffi", version = "0.9.8" }
libsql-sys = { path = "libsql-sys", version = "0.9.8", default-features = false }
libsql-hrana = { path = "libsql-hrana", version = "0.9.8" }
libsql_replication = { path = "libsql-replication", version = "0.9.8" }
rusqlite = { package = "libsql-rusqlite", path = "vendored/rusqlite", version = "0.9.8", default-features = false, features = [
"libsql-experimental",
"column_decltype",
"load_extension",
Expand Down
16 changes: 11 additions & 5 deletions libsql/src/database/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ cfg_core! {
use crate::EncryptionConfig;
}

use crate::{Database, Result};

use super::DbType;
use crate::{Database, Result};

/// A builder for [`Database`]. This struct can be used to build
/// all variants of [`Database`]. These variants include:
Expand Down Expand Up @@ -644,11 +643,18 @@ cfg_sync! {
}

let mut bg_abort: Option<std::sync::Arc<crate::sync::DropAbort>> = None;
let conn = db.connect()?;

let sync_ctx = db.sync_ctx.as_ref().unwrap().clone();

if let Some(sync_interval) = sync_interval {
let sync_ctx = db.sync_ctx.as_ref().unwrap().clone();
{
let mut ctx = sync_ctx.lock().await;
crate::sync::bootstrap_db(&mut ctx).await?;
}

// db.connect creates a local db file, so it is important that we always call
// `bootstrap_db` (for synced dbs) before calling connect. Otherwise, the sync
// protocol skips calling `export` endpoint causing slowdown in initial bootstrap.
let conn = db.connect()?;
let jh = tokio::spawn(
async move {
loop {
Expand Down
4 changes: 4 additions & 0 deletions libsql/src/hrana/hyper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,10 @@ impl crate::statement::Stmt for crate::hrana::Statement<HttpSender> {
Some(&named_param.name)
}

fn column_count(&self) -> usize {
self.cols.len()
}

fn columns(&self) -> Vec<crate::Column> {
//FIXME: there are several blockers here:
// 1. We cannot know the column types before sending a query, so this method will never return results right
Expand Down
4 changes: 4 additions & 0 deletions libsql/src/local/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ impl Stmt for LibsqlStmt {
self.0.parameter_name(idx)
}

fn column_count(&self) -> usize {
self.0.column_count()
}

fn columns(&self) -> Vec<Column> {
self.0.columns()
}
Expand Down
10 changes: 10 additions & 0 deletions libsql/src/replication/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,16 @@ impl Stmt for RemoteStatement {
}
}

fn column_count(&self) -> usize {
if let Some(stmt) = self.local_statement.as_ref() {
return stmt.column_count();
}
match self.metas.first() {
Some(meta) => meta.columns.len(),
None => 0,
}
}

fn columns(&self) -> Vec<Column> {
if let Some(stmt) = self.local_statement.as_ref() {
return stmt.columns();
Expand Down
7 changes: 7 additions & 0 deletions libsql/src/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ pub(crate) trait Stmt {

fn parameter_name(&self, idx: i32) -> Option<&str>;

fn column_count(&self) -> usize;

fn columns(&self) -> Vec<Column>;
}

Expand Down Expand Up @@ -95,6 +97,11 @@ impl Statement {
self.inner.parameter_name(idx)
}

/// Fetch the number of columns for the prepared statement.
pub fn column_count(&self) -> usize {
self.inner.column_count()
}

/// Fetch the list of columns for the prepared statement.
pub fn columns(&self) -> Vec<Column> {
self.inner.columns()
Expand Down
4 changes: 4 additions & 0 deletions libsql/src/sync/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ impl Stmt for SyncedStatement {
self.inner.parameter_name(idx)
}

fn column_count(&self) -> usize {
self.inner.column_count()
}

fn columns(&self) -> Vec<Column> {
self.inner.columns()
}
Expand Down
2 changes: 1 addition & 1 deletion vendored/rusqlite/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "libsql-rusqlite"
# Note: Update version in README.md when you change this.
version = "0.9.7"
version = "0.9.8"
authors = ["The rusqlite developers"]
edition = "2018"
description = "Ergonomic wrapper for SQLite (libsql fork)"
Expand Down