mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-18 17:14:20 +01:00
use virtual root page for sqlite_schema
This commit is contained in:
@@ -40,40 +40,18 @@ impl<'a> ImportFile<'a> {
|
||||
args.table
|
||||
);
|
||||
|
||||
let mut table_exists = false;
|
||||
if self.conn.is_db_initialized() {
|
||||
table_exists = 'check: {
|
||||
match self.conn.query(table_check_query) {
|
||||
Ok(rows) => {
|
||||
if let Some(mut rows) = rows {
|
||||
loop {
|
||||
match rows.step() {
|
||||
Ok(turso_core::StepResult::Row) => {
|
||||
break 'check true;
|
||||
}
|
||||
Ok(turso_core::StepResult::Done) => break 'check false,
|
||||
Ok(turso_core::StepResult::IO) => {
|
||||
if let Err(e) = rows.run_once() {
|
||||
let _ = self.writer.write_all(
|
||||
format!("Error checking table existence: {e:?}\n")
|
||||
.as_bytes(),
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Ok(
|
||||
turso_core::StepResult::Interrupt
|
||||
| turso_core::StepResult::Busy,
|
||||
) => {
|
||||
if let Err(e) = rows.run_once() {
|
||||
let _ = self.writer.write_all(
|
||||
format!("Error checking table existence: {e:?}\n")
|
||||
.as_bytes(),
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
let table_exists = 'check: {
|
||||
match self.conn.query(table_check_query) {
|
||||
Ok(rows) => {
|
||||
if let Some(mut rows) = rows {
|
||||
loop {
|
||||
match rows.step() {
|
||||
Ok(turso_core::StepResult::Row) => {
|
||||
break 'check true;
|
||||
}
|
||||
Ok(turso_core::StepResult::Done) => break 'check false,
|
||||
Ok(turso_core::StepResult::IO) => {
|
||||
if let Err(e) = rows.run_once() {
|
||||
let _ = self.writer.write_all(
|
||||
format!("Error checking table existence: {e:?}\n")
|
||||
.as_bytes(),
|
||||
@@ -81,19 +59,38 @@ impl<'a> ImportFile<'a> {
|
||||
return;
|
||||
}
|
||||
}
|
||||
Ok(
|
||||
turso_core::StepResult::Interrupt
|
||||
| turso_core::StepResult::Busy,
|
||||
) => {
|
||||
if let Err(e) = rows.run_once() {
|
||||
let _ = self.writer.write_all(
|
||||
format!("Error checking table existence: {e:?}\n")
|
||||
.as_bytes(),
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
let _ = self.writer.write_all(
|
||||
format!("Error checking table existence: {e:?}\n")
|
||||
.as_bytes(),
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
Err(e) => {
|
||||
let _ = self.writer.write_all(
|
||||
format!("Error checking table existence: {e:?}\n").as_bytes(),
|
||||
);
|
||||
return;
|
||||
}
|
||||
false
|
||||
}
|
||||
};
|
||||
}
|
||||
Err(e) => {
|
||||
let _ = self
|
||||
.writer
|
||||
.write_all(format!("Error checking table existence: {e:?}\n").as_bytes());
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
let file = match File::open(args.file) {
|
||||
Ok(file) => file,
|
||||
Err(e) => {
|
||||
|
||||
Reference in New Issue
Block a user