mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-08-04 18:18:03 +00:00
Merge 'bindings/javascript: Add pragma() support' from Anton Harniakou
Some checks failed
Build and push limbo-sim image / deploy (push) Waiting to run
Go Tests / test (push) Waiting to run
Java Tests / test (push) Waiting to run
JavaScript / stable - aarch64-apple-darwin - node@20 (push) Waiting to run
JavaScript / stable - x86_64-apple-darwin - node@20 (push) Waiting to run
JavaScript / stable - x86_64-pc-windows-msvc - node@20 (push) Waiting to run
JavaScript / stable - x86_64-unknown-linux-gnu - node@20 (push) Waiting to run
JavaScript / Test bindings on x86_64-apple-darwin - node@18 (push) Blocked by required conditions
JavaScript / Test bindings on x86_64-apple-darwin - node@20 (push) Blocked by required conditions
JavaScript / Test bindings on Linux-x64-gnu - node@18 (push) Blocked by required conditions
JavaScript / Test bindings on Linux-x64-gnu - node@20 (push) Blocked by required conditions
JavaScript / Build universal macOS binary (push) Blocked by required conditions
JavaScript / Publish (push) Blocked by required conditions
Python / check-requirements (push) Waiting to run
Python / configure-strategy (push) Waiting to run
Python / test (push) Blocked by required conditions
Python / lint (push) Waiting to run
Python / linux (x86_64) (push) Waiting to run
Python / macos-x86_64 (x86_64) (push) Waiting to run
Python / macos-arm64 (aarch64) (push) Waiting to run
Python / sdist (push) Waiting to run
Python / Release (push) Blocked by required conditions
Rust / cargo-fmt-check (push) Waiting to run
Rust / build-native (blacksmith-4vcpu-ubuntu-2404) (push) Waiting to run
Rust / build-native (macos-latest) (push) Waiting to run
Rust / build-native (windows-latest) (push) Waiting to run
Rust / clippy (push) Waiting to run
Rust / build-wasm (push) Waiting to run
Rust / test-limbo (push) Waiting to run
Rust / test-sqlite (push) Waiting to run
Rust Benchmarks+Nyrkiö / tpc-h (push) Waiting to run
Rust Benchmarks+Nyrkiö / bench (push) Waiting to run
Rust Benchmarks+Nyrkiö / clickbench (push) Waiting to run
Rust Benchmarks+Nyrkiö / tpc-h-criterion (push) Waiting to run
Run long fuzz tests on Btree / run-long-tests (push) Has been cancelled
Run long fuzz tests on Btree / simple-stress-test (push) Has been cancelled
Some checks failed
Build and push limbo-sim image / deploy (push) Waiting to run
Go Tests / test (push) Waiting to run
Java Tests / test (push) Waiting to run
JavaScript / stable - aarch64-apple-darwin - node@20 (push) Waiting to run
JavaScript / stable - x86_64-apple-darwin - node@20 (push) Waiting to run
JavaScript / stable - x86_64-pc-windows-msvc - node@20 (push) Waiting to run
JavaScript / stable - x86_64-unknown-linux-gnu - node@20 (push) Waiting to run
JavaScript / Test bindings on x86_64-apple-darwin - node@18 (push) Blocked by required conditions
JavaScript / Test bindings on x86_64-apple-darwin - node@20 (push) Blocked by required conditions
JavaScript / Test bindings on Linux-x64-gnu - node@18 (push) Blocked by required conditions
JavaScript / Test bindings on Linux-x64-gnu - node@20 (push) Blocked by required conditions
JavaScript / Build universal macOS binary (push) Blocked by required conditions
JavaScript / Publish (push) Blocked by required conditions
Python / check-requirements (push) Waiting to run
Python / configure-strategy (push) Waiting to run
Python / test (push) Blocked by required conditions
Python / lint (push) Waiting to run
Python / linux (x86_64) (push) Waiting to run
Python / macos-x86_64 (x86_64) (push) Waiting to run
Python / macos-arm64 (aarch64) (push) Waiting to run
Python / sdist (push) Waiting to run
Python / Release (push) Blocked by required conditions
Rust / cargo-fmt-check (push) Waiting to run
Rust / build-native (blacksmith-4vcpu-ubuntu-2404) (push) Waiting to run
Rust / build-native (macos-latest) (push) Waiting to run
Rust / build-native (windows-latest) (push) Waiting to run
Rust / clippy (push) Waiting to run
Rust / build-wasm (push) Waiting to run
Rust / test-limbo (push) Waiting to run
Rust / test-sqlite (push) Waiting to run
Rust Benchmarks+Nyrkiö / tpc-h (push) Waiting to run
Rust Benchmarks+Nyrkiö / bench (push) Waiting to run
Rust Benchmarks+Nyrkiö / clickbench (push) Waiting to run
Rust Benchmarks+Nyrkiö / tpc-h-criterion (push) Waiting to run
Run long fuzz tests on Btree / run-long-tests (push) Has been cancelled
Run long fuzz tests on Btree / simple-stress-test (push) Has been cancelled
This PR adds column names to the ouput of js pragma function. Reviewed-by: Diego Reis (@el-yawd) Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com> Closes #1608
This commit is contained in:
commit
72058da9dc
7 changed files with 118 additions and 44 deletions
|
@ -789,7 +789,7 @@ impl Statement {
|
|||
}
|
||||
|
||||
pub fn get_column_name(&self, idx: usize) -> Cow<str> {
|
||||
let column = &self.program.result_columns[idx];
|
||||
let column = &self.program.result_columns.get(idx).expect("No column");
|
||||
match column.name(&self.program.table_references) {
|
||||
Some(name) => Cow::Borrowed(name),
|
||||
None => Cow::Owned(column.expr.to_string()),
|
||||
|
|
|
@ -23,7 +23,7 @@ fn list_pragmas(program: &mut ProgramBuilder) {
|
|||
let register = program.emit_string8_new_reg(x.to_string());
|
||||
program.emit_result_row(register, 1);
|
||||
}
|
||||
|
||||
program.add_pragma_result_column("pragma_list".into());
|
||||
program.epilogue(crate::translate::emitter::TransactionMode::None);
|
||||
}
|
||||
|
||||
|
@ -279,10 +279,12 @@ fn query_pragma(
|
|||
register,
|
||||
);
|
||||
program.emit_result_row(register, 1);
|
||||
program.add_pragma_result_column(pragma.to_string());
|
||||
}
|
||||
PragmaName::JournalMode => {
|
||||
program.emit_string8("wal".into(), register);
|
||||
program.emit_result_row(register, 1);
|
||||
program.add_pragma_result_column(pragma.to_string());
|
||||
}
|
||||
PragmaName::LegacyFileFormat => {}
|
||||
PragmaName::WalCheckpoint => {
|
||||
|
@ -303,6 +305,7 @@ fn query_pragma(
|
|||
dest: register,
|
||||
});
|
||||
program.emit_result_row(register, 1);
|
||||
program.add_pragma_result_column(pragma.to_string());
|
||||
}
|
||||
PragmaName::TableInfo => {
|
||||
let table = match value {
|
||||
|
@ -348,6 +351,10 @@ fn query_pragma(
|
|||
program.emit_result_row(base_reg, 6);
|
||||
}
|
||||
}
|
||||
let col_names = ["cid", "name", "type", "notnull", "dflt_value", "pk"];
|
||||
for name in col_names {
|
||||
program.add_pragma_result_column(name.into());
|
||||
}
|
||||
}
|
||||
PragmaName::UserVersion => {
|
||||
program.emit_insn(Insn::ReadCookie {
|
||||
|
@ -355,6 +362,7 @@ fn query_pragma(
|
|||
dest: register,
|
||||
cookie: Cookie::UserVersion,
|
||||
});
|
||||
program.add_pragma_result_column(pragma.to_string());
|
||||
program.emit_result_row(register, 1);
|
||||
}
|
||||
PragmaName::SchemaVersion => {
|
||||
|
@ -363,11 +371,13 @@ fn query_pragma(
|
|||
dest: register,
|
||||
cookie: Cookie::SchemaVersion,
|
||||
});
|
||||
program.add_pragma_result_column(pragma.to_string());
|
||||
program.emit_result_row(register, 1);
|
||||
}
|
||||
PragmaName::PageSize => {
|
||||
program.emit_int(database_header.lock().get_page_size().into(), register);
|
||||
program.emit_result_row(register, 1);
|
||||
program.add_pragma_result_column(pragma.to_string());
|
||||
}
|
||||
PragmaName::AutoVacuum => {
|
||||
let auto_vacuum_mode = pager.get_auto_vacuum_mode();
|
||||
|
|
|
@ -285,6 +285,17 @@ impl ProgramBuilder {
|
|||
cursor
|
||||
}
|
||||
|
||||
pub fn add_pragma_result_column(&mut self, col_name: String) {
|
||||
// TODO figure out a better type definition for ResultSetColumn
|
||||
// or invent another way to set pragma result columns
|
||||
let expr = ast::Expr::Id(ast::Id("".to_string()));
|
||||
self.result_columns.push(ResultSetColumn {
|
||||
expr,
|
||||
alias: Some(col_name),
|
||||
contains_aggregates: false,
|
||||
});
|
||||
}
|
||||
|
||||
#[instrument(skip(self), level = Level::TRACE)]
|
||||
pub fn emit_insn(&mut self, insn: Insn) {
|
||||
let function = insn.to_function();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue