ptrdom opened a new pull request, #532:
URL: https://github.com/apache/pekko-persistence-r2dbc/pull/532
### Motivation
Oracle Database support was requested in #94 and is tracked in #531. The
licensing question there is settled: the Oracle driver can be used as long as
the plugin doesn't require it or ship it, so it is a test-only dependency here.
The minimum version is 23ai, as proposed in #531.
### Modification
- A new `oracle` dialect (`Dialect.Oracle`) with Oracle DAOs for the
journal, query, snapshot and durable state, following the MySQL dialect.
- It requires `use-app-timestamp` and `db-timestamp-monotonic-increasing`,
because Oracle has no transaction timestamp and no SQL `RETURNING` clause.
- Snapshot upserts use `MERGE`. Tags are stored as a JSON array in a
`CLOB`, reusing the MySQL JSON helpers.
- `Sql` rewrites a trailing `LIMIT` to `FETCH FIRST … ROWS ONLY` for Oracle,
so the shared base DAO queries don't need Oracle copies.
- `OracleConnections`, a connection factory decorator.
`ConnectionFactoryProvider` applies it when the driver is `oracle`. It covers
driver behaviour found while testing against Oracle 23ai Free:
- The driver can't bind or read `java.time.Instant`, so `Instant` values
are converted to and from UTC `LocalDateTime` for the `TIMESTAMP(6)` columns.
- Byte arrays bound in the `SELECT` of a `MERGE` are limited to the `RAW`
size and fail for large snapshots (`ORA-01461`), so byte arrays are bound as
R2DBC `Blob`s.
- Oracle stores empty strings and empty byte arrays as `NULL`. The entity
type, manifest, writer and payload columns are therefore nullable in the DDL,
and the decorator reads `NULL` back as `""` or an empty array for those columns.
- DDL scripts `ddl-scripts/create_tables_oracle.sql` and
`drop_tables_oracle.sql`, `docker/docker-compose-oracle.yml`
(`gvenzl/oracle-free:23-slim-faststart`), and a `test-oracle` CI job.
- Oracle has a schema per user, so the CI job creates
`database1`/`database2` as users, and `RuntimePluginConfigSpec` connects as
those users when running on Oracle.
- `com.oracle.database.r2dbc:oracle-r2dbc` 1.3.0 is added as a **test-only**
dependency. It is dual-licensed under UPL 1.0 or Apache 2.0, but depends on
`ojdbc11`, which is under the Oracle Free Use Terms and Conditions. Users add
the driver themselves, as discussed in #531.
- Docs:
- `getting-started.md` has a new Oracle section covering the driver
dependency, a licence note, settings, Docker setup and DDL.
- `config.md`, `overview.md` and `migration.md` mention Oracle; the
migration tool doesn't support Oracle as a target, like MySQL and H2.
- Tests:
- `OracleDialectSpec` checks: an empty manifest round-trips;
`db_timestamp` is read back as an `Instant` with microsecond precision; a large
snapshot is inserted and then updated through `MERGE`; and a durable state
delete works when the empty payload is stored as `NULL`.
- `OracleUtilsSpec` checks dialect parsing, the required settings and
driver detection.
- `SqlSpec` has cases for the `LIMIT` rewrite.
- Five existing specs with MySQL- or Postgres-only SQL or DDL get Oracle
branches.
No code was copied from external projects. The license headers of the new
SQL, YAML and `.conf` files are taken from the matching MySQL files in this
repository, because sbt doesn't manage headers for those file types.
### Result
The plugin can use Oracle Database 23ai or later as its journal, snapshot
store and durable state store.
### Tests
- `sbt -Dpekko.persistence.r2dbc.dialect=oracle core/test` against
`gvenzl/oracle-free:23-slim-faststart`: 319 succeeded, 0 failed, 90 pending.
The pending tests are the batched journal (Postgres/Yugabyte only),
`R2dbcExecutorSpec` (uses `pg_sleep`), H2-only specs and the optional snapshot
TCK tests.
- `sbt -Dpekko.persistence.r2dbc.dialect=h2 core/test`: 318 succeeded, 0
failed, 91 pending
- `sbt scala3 Test/compile`: passed
- `sbt headerCheckAll core/javafmtCheckAll +mimaReportBinaryIssues`: passed
- `sbt docs/paradox`: passed
- `scalafmt --mode diff-ref=upstream/main`: applied
- Postgres, Yugabyte and MySQL: not run locally; covered by CI
### References
Fixes #531
Refs #94
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]