← Back to Pull requests

Scope table and index lookups to the connection catalog on MySQL (fixes #489) #559

Closed
unknown closed this pull request without merging on Nov 19, 2026 13:39 UTC
View on GitHub
unknown unknown commented on Nov 04, 2026 13:42 UTC
Author

Scope table and index lookups to the connection catalog on MySQL (fixes #489)

Problem

The engine's "does this table exist?" and "does this index exist?" checks call DatabaseMetaData with a null catalog. On MySQL, Connector/J then searches every database the login can see, not just the one in the URL. When one login has rights on more than one OIE database on the same server, an engine finds another database's tables or indexes and skips creating or repairing its own:

  • First startup fails. ServerMigrator.initDatabase calls DatabaseUtil.tableExists(conn, "CONFIGURATION"), finds the other database's CONFIGURATION, skips mysql-database.sql, and getCurrentVersion then fails on the missing SCHEMA_INFO.

  • Per-channel message tables aren't recreated. JdbcDao.checkAndCreateChannelTables lists tables across all visible databases, so a missing D_MC<n> looks present when another database has a table of that name. Messages then fail with Table 'oie_b.D_MC1' doesn't exist.

  • Missing indexes aren't offered for repair. DatabaseUtil.indexExists finds another database's index of the same name (for example D_MM1_INDEX3), so the "Add Metadata Index" database task never appears.
  • Fix

    Only MySQL (and MariaDB) changes behaviour. Every other database keeps the existing null-catalog lookup.

  • Server side (DatabaseUtil). A new lookupCatalog returns connection.getCatalog() when the database product is MySQL or MariaDB, and null otherwise. tableExists and indexExists both use it, for their upper- and lower-case lookups.

  • Donkey side (JdbcDao). There is no MySQL-specific DAO class, so this follows the existing setQuoteChar pattern. JdbcDao gets setScopeTablesToCatalog(boolean), off by default, which MysqlDaoFactory turns on. checkAndCreateChannelTables and tableExists pass the catalog only when it is enabled.
  • This has the same effect as the reporter's ?nullDatabaseMeansCurrent=true URL workaround, applied in code.

    Tests

  • DatabaseUtilTest (4 tests):

  • - On MySQL, tableExists and indexExists pass the connection's catalog ("oie_b").
    - On PostgreSQL, both keep a null catalog and never call getCatalog().
    - The MySQL indexExists test fails without the latest commit.
  • JdbcDaoTest:

  • - testTableLookupUnscopedByDefault
    - testTableLookupScopedToCatalogWhenEnabled

    gradle :server:test --tests "DatabaseUtilTest": 4 tests, 0 failures.

    End-to-end on MySQL 8.4 with Connector/J 8.4.0, two engines on one login: @pacmano1 confirmed in review that the startup and message-table cases are fixed and that engine D with ?nullDatabaseMeansCurrent=true still works.

    Release Note

    MySQL/MariaDB: table and index checks now stay in the configured database (https://github.com/OpenIntegrationEngine/engine/issues/489)

    When one database login could see more than one OIE database on the same server, the engine could find another database's tables or indexes and skip creating its own. That caused a failed first startup, missing D_MC<n> message tables, and a missing "Add Metadata Index" task. Lookups are now scoped to the database named in the connection URL. Other database types are unchanged. If you added ?nullDatabaseMeansCurrent=true to your MySQL URL as a workaround, you no longer need it, and leaving it in is harmless.

    Diff: 419 lines (+314 / -105) across 5 files Reviewer: pacmano1 Review duration: 21597m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 419 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.361
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #559"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45.0% (MEDIUM) · Higher = larger blast radius
    45.0%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.8% · Safe to merge
    17.8%