core: Kill value type

We currently have two value types, `Value` and `OwnedValue`. The
original thinking was that `Value` is external type and `OwnedValue` is
internal type. However, this just results in unnecessary transformation
between the types as data crosses the Limbo library boundary.

Let's just follow SQLite here and consolidate on a single value type
(where `sqlite3_value` is just an alias for the internal `Mem` type).
The way this will eventually work is that we can have bunch of
pre-allocated `OwnedValue` objects in `ProgramState` and basically
return a reference to them all the way to the application itself, which
extracts the actual value.
This commit is contained in:
Pekka Enberg
2025-02-26 09:41:22 +02:00
parent fe440b7b34
commit 936ae307b7
16 changed files with 220 additions and 243 deletions

View File

@@ -302,12 +302,13 @@ fn row_to_py(py: Python, row: &limbo_core::Row) -> PyObject {
let py_values: Vec<PyObject> = row
.get_values()
.iter()
.map(|value| match value.to_value() {
limbo_core::Value::Null => py.None(),
limbo_core::Value::Integer(i) => i.to_object(py),
limbo_core::Value::Float(f) => f.to_object(py),
limbo_core::Value::Text(s) => s.to_object(py),
limbo_core::Value::Blob(b) => b.to_object(py),
.map(|value| match value {
limbo_core::OwnedValue::Null => py.None(),
limbo_core::OwnedValue::Integer(i) => i.to_object(py),
limbo_core::OwnedValue::Float(f) => f.to_object(py),
limbo_core::OwnedValue::Text(s) => s.as_str().to_object(py),
limbo_core::OwnedValue::Blob(b) => b.to_object(py),
_ => unreachable!(),
})
.collect();