diff --git a/Cargo.lock b/Cargo.lock index 6767e837b..c65ad569a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1636,6 +1636,7 @@ dependencies = [ "limbo_percentile", "limbo_regexp", "limbo_series", + "limbo_sqlite3_parser", "limbo_time", "limbo_uuid", "miette", @@ -1656,7 +1657,6 @@ dependencies = [ "rustix", "ryu", "serde", - "sqlite3-parser", "strum", "tempfile", "thiserror 1.0.69", @@ -1749,6 +1749,26 @@ dependencies = [ "log", ] +[[package]] +name = "limbo_sqlite3_parser" +version = "0.0.14" +dependencies = [ + "bitflags 2.8.0", + "cc", + "env_logger 0.11.6", + "fallible-iterator 0.3.0", + "indexmap", + "log", + "memchr", + "miette", + "phf", + "phf_codegen", + "phf_shared", + "strum", + "strum_macros", + "uncased", +] + [[package]] name = "limbo_time" version = "0.0.14" @@ -2803,26 +2823,6 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -[[package]] -name = "sqlite3-parser" -version = "0.13.0" -dependencies = [ - "bitflags 2.8.0", - "cc", - "env_logger 0.11.6", - "fallible-iterator 0.3.0", - "indexmap", - "log", - "memchr", - "miette", - "phf", - "phf_codegen", - "phf_shared", - "strum", - "strum_macros", - "uncased", -] - [[package]] name = "stable_deref_trait" version = "1.2.0" diff --git a/Cargo.toml b/Cargo.toml index a986e894a..c9a12eed3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,6 +33,15 @@ repository = "https://github.com/tursodatabase/limbo" [workspace.dependencies] limbo_core = { path = "core", version = "0.0.14" } +limbo_crypto = { path = "extensions/crypto", version = "0.0.14" } +limbo_ext = { path = "extensions/core", version = "0.0.14" } +limbo_macros = { path = "macros", version = "0.0.14" } +limbo_percentile = { path = "extensions/percentile", version = "0.0.14" } +limbo_regexp = { path = "extensions/regexp", version = "0.0.14" } +limbo_series = { path = "extensions/series", version = "0.0.14" } +limbo_time = { path = "extensions/time", version = "0.0.14" } +limbo_uuid = { path = "extensions/uuid", version = "0.0.14" } +limbo_sqlite3_parser = { path = "vendored/sqlite3-parser", version = "0.0.14" } # Config for 'cargo dist' [workspace.metadata.dist] diff --git a/bindings/go/Cargo.toml b/bindings/go/Cargo.toml index e268d0a27..0c0d3c6d5 100644 --- a/bindings/go/Cargo.toml +++ b/bindings/go/Cargo.toml @@ -17,7 +17,7 @@ io_uring = ["limbo_core/io_uring"] [dependencies] -limbo_core = { path = "../../core" } +limbo_core = { workspace = true } [target.'cfg(target_os = "linux")'.dependencies] -limbo_core = { path = "../../core", features = ["io_uring"] } +limbo_core = { workspace = true, features = ["io_uring"] } diff --git a/core/Cargo.toml b/core/Cargo.toml index a4e6ed288..9889009b8 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -37,12 +37,12 @@ mimalloc = { version = "*", default-features = false } libloading = "0.8.6" [dependencies] -limbo_ext = { path = "../extensions/core" } +limbo_ext = { workspace = true } cfg_block = "0.1.1" fallible-iterator = "0.3.0" hex = "0.4.3" libc = { version = "0.2.155", optional = true } -sqlite3-parser = { path = "../vendored/sqlite3-parser" } +limbo_sqlite3_parser = { workspace = true } thiserror = "1.0.61" getrandom = { version = "0.2.15" } regex = "1.11.1" @@ -55,13 +55,13 @@ serde = { version = "1.0", features = ["derive"], optional = true } pest = { version = "2.0", optional = true } pest_derive = { version = "2.0", optional = true } rand = "0.8.5" -limbo_macros = { path = "../macros" } -limbo_uuid = { path = "../extensions/uuid", optional = true, features = ["static"] } -limbo_regexp = { path = "../extensions/regexp", optional = true, features = ["static"] } -limbo_percentile = { path = "../extensions/percentile", optional = true, features = ["static"] } -limbo_time = { path = "../extensions/time", optional = true, features = ["static"] } -limbo_crypto = { path = "../extensions/crypto", optional = true, features = ["static"] } -limbo_series = { path = "../extensions/series", optional = true, features = ["static"] } +limbo_macros = { workspace = true } +limbo_uuid = { workspace = true, optional = true, features = ["static"] } +limbo_regexp = { workspace = true, optional = true, features = ["static"] } +limbo_percentile = { workspace = true, optional = true, features = ["static"] } +limbo_time = { workspace = true, optional = true, features = ["static"] } +limbo_crypto = { workspace = true, optional = true, features = ["static"] } +limbo_series = { workspace = true, optional = true, features = ["static"] } miette = "7.4.0" strum = "0.26" parking_lot = "0.12.3" diff --git a/core/error.rs b/core/error.rs index cfe1a827d..d0a34ca8a 100644 --- a/core/error.rs +++ b/core/error.rs @@ -14,7 +14,7 @@ pub enum LimboError { ParseError(String), #[error(transparent)] #[diagnostic(transparent)] - LexerError(#[from] sqlite3_parser::lexer::sql::Error), + LexerError(#[from] limbo_sqlite3_parser::lexer::sql::Error), #[error("Conversion error: {0}")] ConversionError(String), #[error("Env variable error: {0}")] diff --git a/core/ext/mod.rs b/core/ext/mod.rs index 8ac0bdcc2..a4f5d6cc3 100644 --- a/core/ext/mod.rs +++ b/core/ext/mod.rs @@ -2,7 +2,7 @@ use crate::{function::ExternalFunc, util::columns_from_create_table_body, Databa use fallible_iterator::FallibleIterator; use limbo_ext::{ExtensionApi, InitAggFunction, ResultCode, ScalarFunction, VTabModuleImpl}; pub use limbo_ext::{FinalizeFunction, StepFunction, Value as ExtValue, ValueType as ExtValueType}; -use sqlite3_parser::{ +use limbo_sqlite3_parser::{ ast::{Cmd, Stmt}, lexer::sql::Parser, }; diff --git a/core/lib.rs b/core/lib.rs index dbeb04906..b4d892612 100644 --- a/core/lib.rs +++ b/core/lib.rs @@ -28,9 +28,9 @@ use libloading::{Library, Symbol}; #[cfg(not(target_family = "wasm"))] use limbo_ext::{ExtensionApi, ExtensionEntryPoint}; use limbo_ext::{ResultCode, VTabModuleImpl, Value as ExtValue}; +use limbo_sqlite3_parser::{ast, ast::Cmd, lexer::sql::Parser}; use parking_lot::RwLock; use schema::{Column, Schema}; -use sqlite3_parser::{ast, ast::Cmd, lexer::sql::Parser}; use std::borrow::Cow; use std::cell::Cell; use std::collections::HashMap; diff --git a/core/schema.rs b/core/schema.rs index a453bf730..0395b2c28 100644 --- a/core/schema.rs +++ b/core/schema.rs @@ -2,8 +2,8 @@ use crate::VirtualTable; use crate::{util::normalize_ident, Result}; use core::fmt; use fallible_iterator::FallibleIterator; -use sqlite3_parser::ast::{Expr, Literal, TableOptions}; -use sqlite3_parser::{ +use limbo_sqlite3_parser::ast::{Expr, Literal, TableOptions}; +use limbo_sqlite3_parser::{ ast::{Cmd, CreateTableBody, QualifiedName, ResultColumn, Stmt}, lexer::sql::Parser, }; @@ -233,8 +233,9 @@ fn create_table( } => { if let Some(constraints) = constraints { for c in constraints { - if let sqlite3_parser::ast::TableConstraint::PrimaryKey { columns, .. } = - c.constraint + if let limbo_sqlite3_parser::ast::TableConstraint::PrimaryKey { + columns, .. + } = c.constraint { for column in columns { primary_key_column_names.push(match column.expr { @@ -304,13 +305,13 @@ fn create_table( let mut notnull = false; for c_def in &col_def.constraints { match &c_def.constraint { - sqlite3_parser::ast::ColumnConstraint::PrimaryKey { .. } => { + limbo_sqlite3_parser::ast::ColumnConstraint::PrimaryKey { .. } => { primary_key = true; } - sqlite3_parser::ast::ColumnConstraint::NotNull { .. } => { + limbo_sqlite3_parser::ast::ColumnConstraint::NotNull { .. } => { notnull = true; } - sqlite3_parser::ast::ColumnConstraint::Default(expr) => { + limbo_sqlite3_parser::ast::ColumnConstraint::Default(expr) => { default = Some(expr.clone()) } _ => {} @@ -506,8 +507,8 @@ impl Index { .map(|col| IndexColumn { name: normalize_ident(&col.expr.to_string()), order: match col.order { - Some(sqlite3_parser::ast::SortOrder::Asc) => Order::Ascending, - Some(sqlite3_parser::ast::SortOrder::Desc) => Order::Descending, + Some(limbo_sqlite3_parser::ast::SortOrder::Asc) => Order::Ascending, + Some(limbo_sqlite3_parser::ast::SortOrder::Desc) => Order::Descending, None => Order::Ascending, }, }) diff --git a/core/translate/aggregation.rs b/core/translate/aggregation.rs index 7eec4531f..69eb94e80 100644 --- a/core/translate/aggregation.rs +++ b/core/translate/aggregation.rs @@ -1,4 +1,4 @@ -use sqlite3_parser::ast; +use limbo_sqlite3_parser::ast; use crate::{ function::AggFunc, diff --git a/core/translate/delete.rs b/core/translate/delete.rs index b5ce85fdc..6a55bfc03 100644 --- a/core/translate/delete.rs +++ b/core/translate/delete.rs @@ -5,7 +5,7 @@ use crate::translate::plan::{DeletePlan, Operation, Plan}; use crate::translate::planner::{parse_limit, parse_where}; use crate::vdbe::builder::{ProgramBuilder, ProgramBuilderOpts, QueryMode}; use crate::{schema::Schema, Result, SymbolTable}; -use sqlite3_parser::ast::{Expr, Limit, QualifiedName}; +use limbo_sqlite3_parser::ast::{Expr, Limit, QualifiedName}; use super::plan::TableReference; diff --git a/core/translate/emitter.rs b/core/translate/emitter.rs index db4455c88..7786c90a9 100644 --- a/core/translate/emitter.rs +++ b/core/translate/emitter.rs @@ -1,7 +1,7 @@ // This module contains code for emitting bytecode instructions for SQL query execution. // It handles translating high-level SQL operations into low-level bytecode that can be executed by the virtual machine. -use sqlite3_parser::ast::{self}; +use limbo_sqlite3_parser::ast::{self}; use crate::function::Func; use crate::translate::plan::{DeletePlan, Plan, Search}; diff --git a/core/translate/expr.rs b/core/translate/expr.rs index a3a71e2c5..9bfcc4a8f 100644 --- a/core/translate/expr.rs +++ b/core/translate/expr.rs @@ -1,4 +1,4 @@ -use sqlite3_parser::ast::{self, UnaryOperator}; +use limbo_sqlite3_parser::ast::{self, UnaryOperator}; #[cfg(feature = "json")] use crate::function::JsonFunc; diff --git a/core/translate/group_by.rs b/core/translate/group_by.rs index 0e521ccef..b5dd72878 100644 --- a/core/translate/group_by.rs +++ b/core/translate/group_by.rs @@ -1,6 +1,6 @@ use std::rc::Rc; -use sqlite3_parser::ast; +use limbo_sqlite3_parser::ast; use crate::{ function::AggFunc, diff --git a/core/translate/insert.rs b/core/translate/insert.rs index f10718a56..eb36b7e75 100644 --- a/core/translate/insert.rs +++ b/core/translate/insert.rs @@ -1,6 +1,6 @@ use std::ops::Deref; -use sqlite3_parser::ast::{ +use limbo_sqlite3_parser::ast::{ DistinctNames, Expr, InsertBody, QualifiedName, ResolveType, ResultColumn, With, }; @@ -71,7 +71,7 @@ pub fn translate_insert( let root_page = table.root_page; let values = match body { InsertBody::Select(select, None) => match &select.body.select.deref() { - sqlite3_parser::ast::OneSelect::Values(values) => values, + limbo_sqlite3_parser::ast::OneSelect::Values(values) => values, _ => todo!(), }, _ => todo!(), diff --git a/core/translate/main_loop.rs b/core/translate/main_loop.rs index 32c2a2d2d..a9fa9a158 100644 --- a/core/translate/main_loop.rs +++ b/core/translate/main_loop.rs @@ -1,4 +1,4 @@ -use sqlite3_parser::ast; +use limbo_sqlite3_parser::ast; use crate::{ schema::Table, diff --git a/core/translate/mod.rs b/core/translate/mod.rs index 5f9e19866..5dd4a9dd7 100644 --- a/core/translate/mod.rs +++ b/core/translate/mod.rs @@ -32,9 +32,9 @@ use crate::vdbe::builder::{CursorType, ProgramBuilderOpts, QueryMode}; use crate::vdbe::{builder::ProgramBuilder, insn::Insn, Program}; use crate::{bail_parse_error, Connection, LimboError, Result, SymbolTable}; use insert::translate_insert; +use limbo_sqlite3_parser::ast::{self, fmt::ToTokens}; +use limbo_sqlite3_parser::ast::{Delete, Insert}; use select::translate_select; -use sqlite3_parser::ast::{self, fmt::ToTokens}; -use sqlite3_parser::ast::{Delete, Insert}; use std::cell::RefCell; use std::fmt::Display; use std::rc::{Rc, Weak}; diff --git a/core/translate/optimizer.rs b/core/translate/optimizer.rs index 99de57398..971e7e790 100644 --- a/core/translate/optimizer.rs +++ b/core/translate/optimizer.rs @@ -1,6 +1,6 @@ use std::{collections::HashMap, rc::Rc}; -use sqlite3_parser::ast; +use limbo_sqlite3_parser::ast; use crate::{ schema::{Index, Schema}, diff --git a/core/translate/order_by.rs b/core/translate/order_by.rs index 091d6dd58..1276fa468 100644 --- a/core/translate/order_by.rs +++ b/core/translate/order_by.rs @@ -1,6 +1,6 @@ use std::rc::Rc; -use sqlite3_parser::ast; +use limbo_sqlite3_parser::ast; use crate::{ schema::{Column, PseudoTable}, diff --git a/core/translate/plan.rs b/core/translate/plan.rs index 8195aea13..fcc9e474d 100644 --- a/core/translate/plan.rs +++ b/core/translate/plan.rs @@ -1,5 +1,5 @@ use core::fmt; -use sqlite3_parser::ast; +use limbo_sqlite3_parser::ast; use std::{ fmt::{Display, Formatter}, rc::Rc, diff --git a/core/translate/planner.rs b/core/translate/planner.rs index 5d09bbadd..0680cea49 100644 --- a/core/translate/planner.rs +++ b/core/translate/planner.rs @@ -13,7 +13,7 @@ use crate::{ vdbe::BranchOffset, Result, VirtualTable, }; -use sqlite3_parser::ast::{ +use limbo_sqlite3_parser::ast::{ self, Expr, FromClause, JoinType, Limit, Materialized, UnaryOperator, With, }; diff --git a/core/translate/pragma.rs b/core/translate/pragma.rs index e31e732ce..2b142a5a9 100644 --- a/core/translate/pragma.rs +++ b/core/translate/pragma.rs @@ -1,8 +1,8 @@ //! VDBE bytecode generation for pragma statements. //! More info: https://www.sqlite.org/pragma.html. -use sqlite3_parser::ast; -use sqlite3_parser::ast::PragmaName; +use limbo_sqlite3_parser::ast; +use limbo_sqlite3_parser::ast::PragmaName; use std::cell::RefCell; use std::rc::Rc; diff --git a/core/translate/select.rs b/core/translate/select.rs index 5b212cdd7..9401f4f0b 100644 --- a/core/translate/select.rs +++ b/core/translate/select.rs @@ -12,8 +12,8 @@ use crate::util::normalize_ident; use crate::vdbe::builder::{ProgramBuilderOpts, QueryMode}; use crate::SymbolTable; use crate::{schema::Schema, vdbe::builder::ProgramBuilder, Result}; -use sqlite3_parser::ast::{self}; -use sqlite3_parser::ast::{ResultColumn, SelectInner}; +use limbo_sqlite3_parser::ast::{self}; +use limbo_sqlite3_parser::ast::{ResultColumn, SelectInner}; pub fn translate_select( query_mode: QueryMode, diff --git a/core/util.rs b/core/util.rs index 0d16f7794..2ee09189d 100644 --- a/core/util.rs +++ b/core/util.rs @@ -1,4 +1,4 @@ -use sqlite3_parser::ast::{self, CreateTableBody, Expr, FunctionTail, Literal}; +use limbo_sqlite3_parser::ast::{self, CreateTableBody, Expr, FunctionTail, Literal}; use std::{rc::Rc, sync::Arc}; use crate::{ @@ -351,13 +351,15 @@ pub fn columns_from_create_table_body(body: ast::CreateTableBody) -> Result Some(val.clone()), + limbo_sqlite3_parser::ast::ColumnConstraint::Default(val) => { + Some(val.clone()) + } _ => None, }), notnull: column_def.constraints.iter().any(|c| { matches!( c.constraint, - sqlite3_parser::ast::ColumnConstraint::NotNull { .. } + limbo_sqlite3_parser::ast::ColumnConstraint::NotNull { .. } ) }), ty_str: column_def @@ -368,7 +370,7 @@ pub fn columns_from_create_table_body(body: ast::CreateTableBody) -> Result Result