MVCC 同步不会区分交换的列
#!/bin/sh set -e DB=swap-poc-$(openssl rand -hex 4) turso db create "$DB" --tursodb --group test-canary 1>/dev/null turso db shell "$DB" "CREATE TABLE core (id TEXT PRIMARY KEY, a TEXT, b TEXT)" turso db shell "$DB" "INSERT INTO core VALUES ('x', 'A1', 'B1')" export TURSO_URL="" TURSO_URL="$(turso db show "$DB" --http-url)" export TURSO_TOKEN="" TURSO_TOKEN="$(turso db tokens create "$DB")" DIR=$(mktemp -d) trap 'rm -rf $DIR' EXIT mkdir "$DIR/src" cp Cargo.lock "$DIR/" cat > "$DIR/Cargo.toml" <<EOF [package] name = "swap_poc" version = "0.1.0" edition = "2021" [dependencies] turso = { path = "$PWD/bindings/Rust", features = ["sync"] } tokio = { version = "1", features = ["full"] } [workspace] EOF cat > "$DIR/src/main.rs" <<'EOF' use turso::sync::Builder; #[tokio::main] async fn main() -> turso::Result<()> { let args: Vec = std::env::args().collect(); let db = Builder::new_remote(&args[2]) .with_remote_url(std::env::var("TURSO_URL").unwrap()) .with_auth_token(std::env::var("TURSO_TOKEN").unwrap()) .build() .await?; if args[1] == "pull" { db.pull().await?; } let conn = db.connect().await?; let mut rows = conn.query("SELECT id, a, b FROM core", ()).await?; while let Some(row) = rows.next().await? { let values: Vec<_> = (0..row.column_count()) .map(|i| row.get_value(i)) .collect::<turso::Result<_>>()?; println!("{values:?}"); } Ok(()) } EOF cargo build -q --manifest-path "$DIR/Cargo.toml" echo "== after bootstrap" "$DIR"/target/debug/swap_poc bootstrap $DIR/local.db turso db shell "$DB" "BEGIN; ALTER TABLE core RENAME COLUMN a TO t; ALTER TABLE core RENAME COLUMN b TO a; ALTER TABLE core RENAME COLUMN t TO b; COMMIT;" echo "== remote after swap" turso db shell "$DB" "SELECT id, a, b FROM core" echo "== local after pull (should match remote)" …
内容来源: tursodatabase/turso