db2 driver updates

This commit is contained in:
Mark Gregory
2026-11-11 13:18:47 +00:00
parent 76037ff72b
commit e85ab1da7b
46 changed files with 100 additions and 6663 deletions
@@ -0,0 +1,29 @@
# Db2 LUW query compatibility
Phase 6 uses the live `db2_local` connection to verify scalar and IN subqueries,
ordered UNION ALL with offset and limit, EXISTS, random ordering, LIKE and
NOT LIKE, and Eloquent datetime hydration for the security settings passkey list.
Regular single-table result reads use the PDO_ODBC NULL workaround. Embedded
queries retain their declared projection and native SQL NULL semantics.
Nullable TIMESTAMP results handled by the workaround use a Carbon-compatible
format with six fractional digits. SQL NULL and empty strings remain distinct.
## Limits
- The NULL workaround covers eligible single-table reads through `get()` and
helpers such as `first()` and `pluck()`. It does not cover raw SQL, cursors,
joins, unions, or arbitrary expressions in the projection. In these cases
PDO_ODBC's native result handling applies.
- Case-insensitive LIKE uses Db2's UPPER function on both operands and follows
the database's string and collation rules.
- Pessimistic locks, joined writes, JSON predicates and seeded random ordering
were outside this phase's verification.
## Run the tests
```sh
APP_ENV=testing php artisan test --do-not-cache-result tests/Feature/Db2/QueryCompatibilityTest.php
APP_ENV=testing php artisan test --do-not-cache-result tests/Feature/Db2
APP_ENV=testing php artisan test --do-not-cache-result
```
@@ -0,0 +1,31 @@
# Db2 driver release verification
Verified 11 November 2026 with Laravel 13.25.0, PHP 8.5.11, PDO_ODBC on
macOS, and Db2 LUW 12.1.5.0 (fix pack 0).
| Run | Passed | Assertions |
| --- | ---: | ---: |
| Release smoke test | 1 | 8 |
| Db2 integration suite | 45 | 139 |
| Full Laravel suite | 78 | 220 |
The smoke test creates a random Db2 schema, runs all five application migration
files, and uses an authenticated Laravel HTTP test to render the security
settings page with a Db2-backed passkey. It verifies the `failed_jobs.failed_at`
default, rolls back the migration batch, checks that the migration history is
empty, and drops the disposable schema. The Db2 account needs CREATE SCHEMA
and permissions to manage objects in that schema. The full suite uses SQLite
for the general Laravel feature tests and Db2 for its integration tests.
```sh
composer validate --no-check-publish --no-interaction
APP_ENV=testing php artisan test --do-not-cache-result tests/Feature/Db2/ReleaseCompatibilityTest.php
APP_ENV=testing php artisan test --do-not-cache-result tests/Feature/Db2
APP_ENV=testing php artisan test --do-not-cache-result
```
A skipped Db2 test does not verify compatibility. This matrix covers one
Db2 LUW and Laravel combination. It does not certify other releases, Db2 for
i or z/OS, or browser-based WebAuthn enrolment and authentication. See the
[schema compatibility notes](DB2-SCHEMA-COMPATIBILITY.md) and
[query compatibility notes](DB2-QUERY-COMPATIBILITY.md) for supported cases and limits.
@@ -0,0 +1,67 @@
# Db2 LUW schema and migrations
The Stage 5 tests use the configured `db2_local` connection. They create randomly named
tables and a separate migration history table, then remove them. A skipped test means
the connection was unavailable and provides no Db2 verification.
```sh
APP_ENV=testing php artisan test --do-not-cache-result tests/Feature/Db2/SchemaTest.php
APP_ENV=testing php artisan test --do-not-cache-result tests/Feature/Db2
APP_ENV=testing php artisan test --do-not-cache-result
```
The tests cover table creation, same-schema rename, conditional drop, adding and
dropping columns, widening VARCHAR, catalog defaults and identity metadata, composite
ordinary and unique index metadata and removal, foreign-key metadata and removal,
and Laravel migration registration and rollback.
## Limits
- Db2 applies its own rules to type conversions and dependent objects. Table
renames require the source and target to be in the same schema. Tables with
certain dependencies, including referential constraints, cannot be renamed.
- Dropping columns and some type or nullability changes can leave a table in
REORG-pending state. The driver does not run administrative utilities. Arrange
for a Db2 administrator to run REORG before subsequent operations that require it.
- Changing an identity column through Laravel's `change()` is unsupported.
Unsigned types, column positioning, expression indexes, full-text indexes
and spatial indexes are outside this implementation.
- Laravel `unique()` creates a Db2 unique index. Db2 foreign keys require a
referenced primary key or unique constraint. A standalone unique index does
not establish that constraint. Foreign-key actions must be supported by Db2
for the chosen operation.
- Column defaults are returned as SQL expressions from the catalog. Catalog
output does not reconstruct generated expressions or every Db2 type attribute.
- Laravel migration rollback runs `down()` and removes its history entry.
The driver does not advertise transactional schema migrations.
- Migration batch lookup casts query-builder `max('batch')` results to text so
Laravel can perform numeric arithmetic through PDO_ODBC. This applies to custom
migration history table names as well.
## Phase 7 data types and indexes
- `char(length)` creates a fixed-width Db2 character column. `uuid()` uses
`CHAR(36)` and leaves UUID validation and generation to the application.
- `time()` uses Db2 TIME at whole-second precision. Fractional TIME precision
raises an exception. Timestamp and datetime definitions accept Db2
fractional-second precision, and the catalog reports it for TIMESTAMP.
- `renameIndex()` uses Db2's same-schema rename for an application-created
index. It preserves key order and uniqueness. Db2 requires the target name
to be available in that schema.
- Time-zone-aware column types, binary UUID storage, expression indexes,
and automatic REORG remain outside the verified scope.
Run the focused live tests with:
```sh
APP_ENV=testing php artisan test --do-not-cache-result tests/Feature/Db2/SchemaTypesAndIndexesTest.php
```
## Selecting the default schema
Set `DB2_SCHEMA` to use a specific schema on the database selected by
`DB2_DSN`. If omitted or blank, the connector retains the DSN or server
default and reads `CURRENT SCHEMA` for Laravel catalog lookups. Set
`DB2_SCHEMA=AAMEDIUK` explicitly to retain the former default.