Skip to content

Keep stored procedure parameters for the life of the JDBC ODA connection - #2512

Merged
merks merged 1 commit into
eclipse-birt:masterfrom
raoulduke98:fix/sp-parameter-metadata-cache
Nov 24, 2026
Merged

merks merged 1 commit into
eclipse-birt:masterfrom
raoulduke98:fix/sp-parameter-metadata-cache

Conversation

@raoulduke98

Copy link
Copy Markdown
Contributor

Fixes #2511

What this changes

CallStatement looked up the parameters of a procedure call with DatabaseMetaData.getProcedureColumns every time a statement was prepared and dropped them again in prepare(). A stored procedure data set that runs once per row of a table repeated the dictionary lookup for every row.

The ODA Connection now owns a small cache (SPParameterCache) and hands it to the CallStatements it creates, including BidiCallStatement. The key holds the current schema (Connection.getSchema(), null for drivers that cannot tell), catalog, schema pattern and procedure name pattern.

Behaviour worth reviewing

  • Only non-empty results of a lookup that completed are kept. A procedure that is not found, or a lookup that fails halfway, is looked up again at the next prepare, so a procedure deployed while the report runs is still found. A procedure without parameters is therefore not cached.
  • Callers get copies of the list. The ParameterDefn objects are shared and only read.
  • The cache is cleared when the connection is opened or closed.

Measurements (Oracle, ojdbc11 21.11, report from the issue, 100 rows, two runs each)

  • dictionary statements: 500 before, 5 after
  • time spent in the lookups: about 26 to 29 s before, about 0.5 s after
  • report time: 20 to 24 s before, 3.6 to 4.1 s after; output identical

Tests

CallStatementParameterCacheTest, 14 tests on a stubbed JDBC connection (no database): reuse on one connection, statements open at the same time, another connection, close and reopen, reopen with another JDBC connection, close without closing the JDBC connection, changed schema, drivers without getSchema (SQLException, RuntimeException, AbstractMethodError), no schema, different procedures, empty result not kept, partial result after a failed lookup not kept, package.procedure retry, Bidi statements. 10 of the 14 fail without the change.

Not covered

No change to the order or the content of the lookups themselves.

CallStatement looked up the parameters of a procedure call with
DatabaseMetaData.getProcedureColumns every time a statement was prepared and
dropped them again in prepare(). A stored procedure data set that runs once
per row of a table therefore repeated the dictionary lookup for every row.

On Oracle, a report with 100 such rows ran 500 dictionary statements; with
this change it runs 5, and the report time drops from about 20 s to 4 s.

The ODA Connection now owns the lookups and hands them to the CallStatements
it creates. The key holds the current schema, catalog, schema pattern and
procedure name pattern. Only non-empty results from a lookup that completed
are kept, so a procedure deployed later is still found, and callers get
copies. The cache is cleared when the connection is opened or closed.

Fixes eclipse-birt#2511

@hvbtup hvbtup left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea to cache this metadata.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the connection-scoped stored procedure parameter caching change.

No open issues 🎉

What changed in this PR

Addresses #2511 by retaining stored procedure parameter definitions for the lifetime of an ODA connection, reducing repeated JDBC dictionary lookups for datasets executed once per table row.

Changes:

  • Shares a schema-aware parameter cache across regular and bidirectional call statements, clearing it when the connection opens or closes.
  • Caches only non-empty, completed lookups and returns list copies, allowing empty or failed lookups to retry.
  • Adds 14 stub-based tests covering reuse, connection lifecycle, schema changes, lookup failures, and package fallback.
File Description
data/​org.eclipse.birt.report.data.oda.jdbc/​src/​org/​eclipse/​birt/​report/​data/​oda/​jdbc/​SPParameterCache.java Adds the shared cache with defensive list copies.
data/​org.eclipse.birt.report.data.oda.jdbc/​src/​org/​eclipse/​birt/​report/​data/​oda/​jdbc/​Connection.java Owns the cache, supplies it to call statements, and clears it on open and close.
data/​org.eclipse.birt.report.data.oda.jdbc/​src/​org/​eclipse/​birt/​report/​data/​oda/​jdbc/​CallStatement.java Reuses cached definitions and stores successful lookups using schema-aware keys.
data/​org.eclipse.birt.report.data.oda.jdbc.tests/​test/​org/​eclipse/​birt/​report/​data/​oda/​jdbc/​CallStatementParameterCacheTest.java Adds database-independent regression coverage for caching behavior.

Review effort: Balanced

@merks merks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I hear otherwise, I think it will be good to merge this very soon.

@merks
merks merged commit 2c1a97e into eclipse-birt:master Nov 24, 2026
6 of 7 checks passed
@wimjongman wimjongman added this to the 4.26 milestone Nov 30, 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.

Stored procedure parameters are looked up in the database dictionary again for every row

5 participants