From c456eff069b65827c22bd4512d910629ce6fb16b Mon Sep 17 00:00:00 2001 From: pedrocarlo Date: Mon, 11 Aug 2025 18:23:25 -0300 Subject: [PATCH] Add `test_schema_reprepare_write` --- tests/integration/common.rs | 2 +- .../query_processing/test_multi_thread.rs | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/tests/integration/common.rs b/tests/integration/common.rs index 058d44787..83e38429a 100644 --- a/tests/integration/common.rs +++ b/tests/integration/common.rs @@ -153,7 +153,7 @@ pub fn maybe_setup_tracing() { let _ = tracing_subscriber::registry() .with( tracing_subscriber::fmt::layer() - .with_ansi(false) + .with_ansi(true) .with_line_number(true) .with_thread_ids(true), ) diff --git a/tests/integration/query_processing/test_multi_thread.rs b/tests/integration/query_processing/test_multi_thread.rs index c509fe0da..4450e5d2a 100644 --- a/tests/integration/query_processing/test_multi_thread.rs +++ b/tests/integration/query_processing/test_multi_thread.rs @@ -196,3 +196,41 @@ fn test_reader_writer() -> anyhow::Result<()> { } Ok(()) } + +#[test] +fn test_schema_reprepare_write() { + maybe_setup_tracing(); + let tmp_db = TempDatabase::new_empty(false); + let conn1 = tmp_db.connect_limbo(); + conn1.execute("CREATE TABLE t(x, y, z)").unwrap(); + let conn2 = tmp_db.connect_limbo(); + let mut stmt = conn2.prepare("INSERT INTO t(y, z) VALUES (1, 2)").unwrap(); + let mut stmt2 = conn2.prepare("INSERT INTO t(y, z) VALUES (3, 4)").unwrap(); + conn1.execute("ALTER TABLE t DROP COLUMN x").unwrap(); + + tracing::info!("Executing Stmt 1"); + loop { + match stmt.step().unwrap() { + turso_core::StepResult::Done => { + break; + } + turso_core::StepResult::IO => { + stmt.run_once().unwrap(); + } + step => panic!("unexpected step result {step:?}"), + } + } + + tracing::info!("Executing Stmt 2"); + loop { + match stmt2.step().unwrap() { + turso_core::StepResult::Done => { + break; + } + turso_core::StepResult::IO => { + stmt2.run_once().unwrap(); + } + step => panic!("unexpected step result {step:?}"), + } + } +}