Skip to content

Commit 4c3f5fc

Browse files
authored
allow reindex statement in libsql (#1598)
1 parent 537a309 commit 4c3f5fc

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

libsql-server/src/query_analysis.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ impl StmtKind {
139139
))
140140
}
141141
Cmd::Stmt(Stmt::Detach(_)) => Some(Self::Detach),
142+
Cmd::Stmt(Stmt::Reindex { .. }) => Some(Self::Write),
142143
_ => None,
143144
}
144145
}

libsql-server/tests/hrana/batch.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,3 +355,27 @@ fn stream() {
355355

356356
sim.run().unwrap();
357357
}
358+
359+
#[test]
360+
fn reindex_statement() {
361+
let mut sim = turmoil::Builder::new()
362+
.simulation_duration(Duration::from_secs(1000))
363+
.build();
364+
sim.host("primary", super::make_standalone_server);
365+
sim.client("client", async {
366+
let db = Database::open_remote_with_connector("http://primary:8080", "", TurmoilConnector)?;
367+
let conn = db.connect()?;
368+
369+
conn.execute("create table t(x text)", ()).await?;
370+
conn.execute("create index t_idx on t(x)", ()).await?;
371+
conn.execute("insert into t(x) values(?)", params!["hello"])
372+
.await?;
373+
conn.execute("insert into t(x) values(?)", params!["hello"])
374+
.await?;
375+
conn.execute("reindex t_idx", ()).await?;
376+
377+
Ok(())
378+
});
379+
380+
sim.run().unwrap();
381+
}

libsql/src/parser.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ impl StmtKind {
120120
}) => Some(Self::Release),
121121
Cmd::Stmt(Stmt::Attach { .. }) => Some(Self::Attach),
122122
Cmd::Stmt(Stmt::Detach(_)) => Some(Self::Detach),
123+
Cmd::Stmt(Stmt::Reindex { .. }) => Some(Self::Write),
123124
_ => None,
124125
}
125126
}

0 commit comments

Comments
 (0)