Skip to content

Windows compatibility fixes: Tokio macros, pgtemp gating; add DuckDB support#49

Closed
danalec wants to merge 41 commits intovrmiguel:mainfrom
danalec:main
Closed

Windows compatibility fixes: Tokio macros, pgtemp gating; add DuckDB support#49
danalec wants to merge 41 commits intovrmiguel:mainfrom
danalec:main

Conversation

@danalec
Copy link

@danalec danalec commented Dec 1, 2025

This PR improves Windows support and adds DuckDB integration.

  • Enable Tokio 1.47 features (macros, rt-multi-thread, time, sync) to fix #[tokio::test] diagnostics.

  • Implement DuckDB execution, schema introspection, and wiring in StatementManager and commands.

  • Gate pgtemp as Unix-only dev-dependency to avoid Unix APIs on Windows.

  • Clean Clippy: cargo clippy --all-targets --all-features -- -D warnings passes.

  • All tests pass on Windows.

Notes:

  • Pgtemp-based tests are behind cfg(unix).
  • Error type extended to handle duckdb::Error for proper ? conversions.

Replace unwrap() with proper error handling for mutex and rwlock operations
Add proper error propagation for poisoned locks in database operations
Improve logging by replacing println with log macros
Sanitize SQLite table names to prevent SQL injection
Set different log levels for debug and release builds
Add support for configuring query batch size through PGPAD_BATCH_SIZE environment variable in both PostgreSQL and SQLite execution modules. The default remains 50 if not specified or invalid.
Also restrict test modules to unix platform for postgres database files
Add comprehensive DuckDB integration including:
- New DuckDB module with parser, schema, execution, and row writing functionality
- Database type registration in migrations and storage
- Connection management and command handling
- Schema introspection and query execution
- Frontend type definitions and command bindings
- Error handling and type conversions
- Test coverage for all new functionality
@danalec danalec marked this pull request as draft December 1, 2025 17:21
@danalec danalec marked this pull request as ready for review December 1, 2025 17:23
…uery execution and schema inspection

This commit introduces comprehensive Oracle database support including:
- Connection management with TNS alias and wallet path support
- Query execution with proper type handling and result streaming
- Schema inspection for tables, views and materialized views
- Numeric and blob data handling with configurable formatting
- SQL parsing for Oracle-specific syntax like DESCRIBE and EXPLAIN PLAN
- Integration with existing connection monitoring and storage systems
@danalec danalec closed this Dec 1, 2025
@danalec danalec reopened this Dec 1, 2025
@danalec
Copy link
Author

danalec commented Dec 1, 2025

feat(database): enhance query execution and schema handling

  • Add cancel_query command to database operations
  • Include views and materialized views in schema queries for Postgres, DuckDB, and SQLite
  • Refactor query execution to support OracleSettings for batch size and row formatting
  • Improve row writer configuration with settings for numeric, timestamp, and blob handling
  • Add Oracle database support with connection monitoring and row writing
  • Extend DuckDB row writer to handle temporal and decimal types
  • Update SQLite row writer to support null values and blob formatting

@danalec
Copy link
Author

danalec commented Dec 1, 2025

Add Oracle database support: connection, execution, schema, settings, and keyring

Introduces Oracle support in the Tauri backend, including secure credential handling, connection monitoring, query execution (SQL and PL/SQL), EXPLAIN PLAN / DBMS_XPLAN , DESC/DESCRIBE , RETURNING INTO , OUT/IN OUT parameters, and schema introspection.

Commands and types updated to support Oracle:

  • Add/update/connect/test/submit/fetch/schema endpoints with Oracle branches: src-tauri/src/database/commands.rs:242 , src-tauri/src/database/commands.rs:555 , src-tauri/src/database/commands.rs:677
  • Per-connection Oracle settings load/save with env application: src-tauri/src/database/commands.rs:813 , src-tauri/src/database/commands.rs:875
  • Connection monitor ping for Oracle with optional auto-reconnect/backoff: src-tauri/src/database/connection_monitor.rs:73
  • Database variants and client plumbing: src-tauri/src/database/types.rs:119 , src-tauri/src/database/types.rs:236
  • Secure credential handling for Oracle (strip password from URL, store in OS keyring): src-tauri/src/credentials.rs:33
  • Storage migration adds Oracle type: src-tauri/migrations/004.sql:1

Configuration

  • New/used env vars: ORACLE_STMT_CACHE_SIZE , ORACLE_XPLAN_FORMAT , ORACLE_BLOB_STREAM , ORACLE_BLOB_CHUNK_SIZE , ORACLE_RAW_FORMAT , ORACLE_RAW_CHUNK_SIZE , ORACLE_ALLOW_DB_LINK_PING , ORACLE_RECONNECT_MAX_RETRIES , ORACLE_RECONNECT_BACKOFF_MS , plus PGPAD_* tuning ( PGPAD_BATCH_SIZE , PGPAD_NUMERIC_STRING_POLICY , etc.): src-tauri/src/database/commands.rs:813 , src-tauri/src/database/commands.rs:825
  • Per-connection OracleSettings persisted in storage with global fallback: src-tauri/src/database/commands.rs:857

Security

  • Passwords removed from connection strings and stored via OS keyring entries: src-tauri/src/credentials.rs:51

Tests

  • Parser unit tests for Oracle dialect features: src-tauri/src/database/oracle/parser.rs:66
  • Existing credential extraction tests for URL sanitization; Oracle path mirrors Postgres logic: src-tauri/src/credentials.rs:230

Migration/Compatibility

  • Run storage migration adding Oracle type ( id=4 ) so the UI can list Oracle connections: src-tauri/migrations/004.sql:1
  • No breaking changes for existing Postgres/SQLite/DuckDB flows; shared interfaces preserved.

#Limitations

  • DATE/TIMESTAMP values are serialized as strings; TIMESTAMP TZ binding not supported, handled via string parse fallback: src-tauri/src/database/oracle/execute.rs:413
  • Some error hints rely on substring matching of ORA codes: src-tauri/src/database/oracle/execute.rs:715

@danalec
Copy link
Author

danalec commented Dec 1, 2025

Oracle modules

  • Connection with statement cache size and optional wallet/TNS alias handling: src-tauri/src/database/oracle/connect.rs:3
  • Query execution, params binding, DML returning, procedure calls with OUT args, EXPLAIN PLAN fetch/format, error hinting, and column metadata caching: src-tauri/src/database/oracle/execute.rs:17 , src-tauri/src/database/oracle/execute.rs:487 , src-tauri/src/database/oracle/execute.rs:578
  • Oracle SQL parsing (DESC, EXPLAIN, PL/SQL detection) using an OracleDialect : src-tauri/src/database/oracle/parser.rs:5 , src-tauri/src/database/oracle/parser.rs:30
  • Row serialization with numeric/string policies, JSON detection, RAW/Blob preview/streaming: src-tauri/src/database/oracle/row_writer.rs:6
  • Numeric helpers for number normalization and scale padding: src-tauri/src/database/oracle/numeric.rs:1
  • Module wiring: src-tauri/src/database/oracle/mod.rs:1

Behavior

  • Connection string parsing supports tcps:// and wallet-based TNS_ADMIN + optional tns_alias fallback: src-tauri/src/database/commands.rs:248
  • EXPLAIN PLAN uses DBMS_XPLAN.DISPLAY / DISPLAY_CURSOR with configurable format: src-tauri/src/database/oracle/execute.rs:496
  • DESC/DESCRIBE tables and Oracle packages (arguments): src-tauri/src/database/oracle/execute.rs:579 , src-tauri/src/database/oracle/execute.rs:619
  • DML RETURNING INTO binds and emits returned values with type inference from all_tab_columns : src-tauri/src/database/oracle/execute.rs:123
  • OUT/IN OUT detection and bind type mapping using all_arguments : src-tauri/src/database/oracle/execute.rs:225
  • Column metadata caching with invalidation on common ORA errors: src-tauri/src/database/oracle/execute.rs:701
  • Row writer policies for numeric thresholds, JSON detection, RAW format, and Blob handling: src-tauri/src/database/oracle/row_writer.rs:247

Add handling for INT2_ARRAY type similar to existing array types to properly format PostgreSQL smallint arrays in query results.

refactor(oracle): rename raw/blob types to bytes in output

Change "Raw" and "Blob" labels to "Bytes" in Oracle output for consistency and clarity. Add total length display where available.
@danalec
Copy link
Author

danalec commented Dec 1, 2025

  • Standardized binary labels to use Bytes(len) across all backends; Oracle now matches Postgres/SQLite/DuckDB.
  • Added Postgres INT2_ARRAY JSON output for consistent array handling. Verifies existing cancellation, ping, and schema behaviors.
  • No changes to runtime behavior for cancellation beyond existing JoinHandle aborts and manager status updates. Backends’ loops already stream pages and respect termination via task abort.
  • Array JSON output remains consistent: numeric arrays as numbers, UUID/text arrays as strings, floating arrays stringify non-finite values.

- Replace seek_stream_len with seek operations for more reliable blob length calculation
- Simplify conditional logic for blob preview display
- Ensure consistent blob representation across all modes
@danalec
Copy link
Author

danalec commented Dec 1, 2025

  • Oracle RAW/BLOB: render as Bytes(len) ; full_hex outputs 0x... ; preview uses Bytes(len) preview(0..N): 0x... . Blob length computed via stable Seek and cursor reset before preview/stream.
  • Postgres arrays: added INT2_ARRAY writer; existing TEXT/INT4/INT8/FLOAT4/FLOAT8/UUID/BOOL array handling retained with non-finite floats stringified.
  • DuckDB writer: confirms support for Timestamp/Date/Time/Interval/Decimal/List/Struct/Map and aligns binary label behavior with Bytes(len) .
  • Cancel query: per-query join handles tracked and aborted; command exposed; status set to Error with message “Cancelled”.
  • SQLite/DuckDB ping: SELECT 1 checks emit end-of-connection events on failure.
  • Postgres schema: includes MATERIALIZED VIEW in discovery.

Tests

  • Updated Oracle tests to expect Bytes(...) labels for RAW/BLOB, including previews.

- Add tracing, tracing-subscriber, and tracing-log dependencies
- Implement structured logging with JSON output in release mode
- Remove env_logger and related dependencies
- Update CSP policy in tauri.conf.json
- Add blob streaming test and improve error handling in oracle row writer
The INT2_ARRAY case was redundant as it's handled by the same logic as other array types. This simplifies the code while maintaining the same functionality.
- Handle NaN/infinity values in SQLite by converting to JSON strings
- Add support for various PostgreSQL array types including string, numeric, date/time, and JSON arrays
…lite

Implement execute_query_with_params functions for both PostgreSQL and SQLite
to support parameterized queries. This allows for safer query execution by
separating SQL from parameters and prevents SQL injection vulnerabilities.
…gging for sqlite

Add new function to handle parameterized queries in DuckDB and implement query execution time logging for SQLite to improve debugging and performance monitoring.
The variable was renamed to follow Rust conventions for unused variables by prefixing with underscore. This improves code clarity and suppresses compiler warnings about unused variables.
Add support for parameterized queries in both SQLite and PostgreSQL backends. For SQLite, replace empty parameter queries with named parameter execution. For PostgreSQL, implement parameter parsing and binding logic including type conversion from JSON values to PostgreSQL parameter types. This enables safer query execution by properly handling user-provided parameters.
Add support for both positional and named parameters in DuckDB queries by:
1. Parsing SQL to identify parameter markers
2. Mapping JSON parameters to appropriate DuckDB types
3. Executing queries with parameters for both result and modification queries
- Add DuckDB icon and display logic in Connections component
- Extend connection form to handle DuckDB database type
- Add file picker and validation for DuckDB connections
- Update tabs UI to include DuckDB option
…sed code

- Replace `query_named` and `execute_named` with `query` and `execute` in SQLite
- Remove unused `Bytes` variant from Postgres param types
- Rename unused `total_rows` variables to `_total_rows` in Postgres and DuckDB
… query execution

- Implement MSSQL connection handling with TLS support
- Add schema introspection for tables, columns, and constraints
- Support query execution with parameter binding and output clauses
- Add MSSQL-specific parser for statement analysis
- Implement row writing and data type handling
- Add UI components for MSSQL connections and schema browsing
- Include comprehensive test suite for MSSQL functionality
- Add documentation and type definitions for MSSQL support
- Add multi-stage Dockerfile for building artifacts and runtime image
- Include docker-compose.yml for build and runtime profiles
- Add .dockerignore to exclude unnecessary files
- Implement runtime entrypoint script for AppImage execution
- Update README with docker usage instructions
- Add GitHub Actions workflow for container builds and releases
refactor(ui): improve form components and button bindings
style: fix indentation and formatting in multiple files
perf: optimize logging levels in Rust backend
build: update dependencies including vite and eslint plugins
@danalec
Copy link
Author

danalec commented Dec 2, 2025

  • Adds Oracle, MSSQL, and DuckDB support end-to-end (connect, schema, parse, execute, row writing, tests).
  • Introduces parameterized query execution across Postgres, SQLite, and DuckDB for safer queries.
  • Replaces env_logger with tracing for richer, structured logging.
  • Adds Docker packaging and workflow to build and run the app in containers.
  • Expands UI with settings and indexes panels for Oracle/MSSQL; updates connections and schema views.

@danalec
Copy link
Author

danalec commented Dec 2, 2025

  • Adds tests for MSSQL and Oracle: src-tauri/src/database/mssql/tests.rs , src-tauri/src/database/oracle/tests.rs .
  • Verify parameter binding and complex type handling across target engines.
  • Manual checks recommended for indexes panels and Settings interactions.

danalec and others added 4 commits December 2, 2025 14:52
This change updates all Svelte event handlers from the Svelte-specific `on:` syntax to the standard DOM `onclick` syntax for consistency and better compatibility. The functionality remains unchanged.
- Replace type assertions with proper DatabaseInfo type
- Add unique keys to #each blocks in index panels
- Remove unused imports and functions
- Clean up connection string display logic
Configure the cargo build system to use the bfd linker for the x86_64-unknown-linux-gnu target to ensure compatibility with specific Linux environments
@danalec
Copy link
Author

danalec commented Dec 2, 2025

The Ubuntu CI links with rust-lld ( -fuse-ld=lld ) and crashes inside LLVM during a very large link of GTK/WebKit/DuckDB, yielding a bus error and an LLVM stack dump. #eb4b632 matches current instability in LLD on complex version-script link jobs.

Add debuginfo=0 flag to release profile and disable debug/incremental for dev/test profiles to improve build performance and reduce binary size
…r formatting

- Add I32 variant to ParamValue enum for postgres parameter handling
- Improve float/double number formatting in duckdb to show .0 suffix for whole numbers
- Remove unused env var fallback for batch size in sqlite
- Handle utf8 strings in postgres byte array output
The default numeric precision threshold was reduced to 15 to better match common use cases and improve compatibility with standard numeric operations.
Add validation to ensure Postgres connection configuration includes at least one host. Separate SSL mode handling for 'Require' and 'Prefer' cases, with 'Prefer' now attempting fallback to NoTls on failure.
Add application_name configuration to identify pgpad connections in PostgreSQL server logs. The change is applied to all connection paths with appropriate error logging if the setting fails.
Add ability to configure Postgres session settings through environment variables:
- PGPAD_CA_CERT_PATH for custom certificate path
- PGPAD_STATEMENT_TIMEOUT_MS for statement timeout
- PGPAD_IDLE_TX_TIMEOUT_MS for idle transaction timeout
- PGPAD_SEARCH_PATH for search path configuration
Add functionality to fetch Postgres database metadata including indexes, constraints, triggers, views and foreign keys with pagination support. Each command now properly queries the database and returns structured JSON data with pagination details.
- Track Postgres backend PID when connecting to enable query cancellation
- Add new cancel_postgres command to cancel running queries by PID
Implement LISTEN/UNLISTEN functionality for Postgres connections with channel validation
…gres_routines

Add new command to terminate Postgres backend processes by PID. Implement proper pagination and data fetching for Postgres routines, returning schema, name, type, language and return type information in JSON format.
Add functionality to retrieve SQLite database metadata including indexes, index columns, views, view definitions, and foreign keys. Each command now supports pagination and returns structured JSON data with total pages information. The implementation uses rusqlite to query SQLite system tables and pragmas.
Add functionality to query SQLite database constraints (primary keys, unique, check) and triggers with pagination support. Also handle SQLite routines endpoint by returning empty payload since SQLite doesn't support stored routines.
Add support for configuring SQLite connection settings through environment variables including busy timeout, journal mode, and synchronous mode. This provides more control over SQLite behavior in different environments.
- Remove extra whitespace in connection_monitor.rs
- Format error messages and SQL statements consistently
- Improve indentation and line breaks in database commands
- Standardize match statement formatting for database operations
Add #[allow(dead_code)] attribute to several database command functions that are currently unused but may be needed in the future, to suppress compiler warnings while keeping the code available.
@danalec
Copy link
Author

danalec commented Dec 3, 2025

allow(dead_code) temporary until future SQLCipher is achieved with SQLite

@vrmiguel
Copy link
Owner

vrmiguel commented Jan 8, 2026

I'm sorry but it's not possible to review a PR this big

If you do want to merge in these features, please open small PRs that introduce them piecewise, so we can actually review them properly

@vrmiguel vrmiguel closed this Jan 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants