SQLite is the default and the contract every other dialect must match. This document records what changes on a server backend, what was measured, and which choices narrow behaviour on purpose.
Status: measured 2026-11-10 against PostgreSQL 16 and MySQL 8.4 in local Docker containers, plus the default SQLite. Re-verified 2026-11-11 for the Kinesis and Step Functions schemas on all three backends. Extended through the 2026-11-20/21/24 matrices and Track D1 (2026-11-29), which took the verified set to 12 RDBMS backends — SQLite, PostgreSQL, MySQL, MariaDB, MSSQL, Oracle, Firebird, CockroachDB, Dolt, DuckDB, IBM Db2 12.1.6 and SAP HANA 2.0 SPS08 (see §15 for Db2/HANA).
1. Choosing a backend
--state-file accepts a SQLAlchemy URL as well as a path:
python start.py --persist --state-file sqlite:///./state.db
python start.py --persist \
--state-file postgresql+psycopg://user:pass@127.0.0.1:5432/offstack
python start.py --persist \
--state-file mysql+pymysql://user:pass@127.0.0.1:3306/offstack
A bare path (state.db) is still interpreted as SQLite; url_from_path() does that translation so every existing caller keeps working.
One Database hosts several schemas: each service passes its own MetaData to create_all, so a single server database carries the DynamoDB, CloudWatch, Cognito, SNS, SQS, IAM, Lambda, Secrets Manager, Events, Streams, Kinesis and Step Functions tables side by side.
2. What is verified
| Check | SQLite | PostgreSQL | MySQL |
|---|---|---|---|
| Every service boots | yes | yes | yes |
| 42 tables created from all MetaDatas | yes | yes | yes |
| DynamoDB round-trip (create/put/get/query/delete) | yes | yes | yes |
| One round-trip per service (SQS, Logs, Cognito, SNS, IAM, Secrets, Lambda, Streams, Kinesis, Step Functions) | yes | yes | yes |
| Keys are case-sensitive | yes | yes | yes |
| Declared indexes actually exist on the server | yes | yes | yes |
| Whole differential suite vs moto | 854 passed, 13 skipped | 854 passed, 13 skipped | 864 passed, 13 skipped |
The last row is the real gate and it is new as of 2026-11-10: the suite had never actually executed on a server backend. See the note below, which is a correction rather than a caveat.
Correction (2026-11-10). An earlier six-leg matrix reported PostgreSQL and MySQL as passing, and it was wrong.
tests/conftest.pyreadOFFSTACK_TEST_SIM_DATABASE_URLinsideif self.persist:, and every fixture buildsSimulatorHandle()with the defaultpersist=False. The URL was never applied, so all six legs ran on:memory:. Proof: the full SQS suite run with the URL set to a live MySQL database left that database with zero tables. Before the fix only DynamoDB's 3 tables ever landed there, from a different path. The URL read now sits outside that branch and implies--persist(without itstart.pyreturns":memory:"regardless of--state-file).tests/test_harness_backend_override.pypins the built argv and fails on the old code. Every server leg below was confirmed by counting the tables the run actually created in that database.
Reproduce the schema half without a server:
python -m pytest tests/test_mysql_schema_compat.py -q
and the live half with servers:
OFFSTACK_TEST_DATABASE_URLS="sqlite://,postgresql+psycopg://u:p@h/db,mysql+pymysql://u:p@h/db" \
python -m pytest tests/test_storage_backends.py -q
2a. Existing state files evolve, they are not recreated
create_all only creates ABSENT tables, so a state file written by an older build keeps its old column set. Database._add_missing_columns ALTERs in the columns newer code needs (additive only: no type changes, no drops). Adding a column to a table means adding it to that map too -- otherwise the simulator starts, then fails on the first statement that names it.
Three renames/relaxations the additive map cannot express live in their owning stores (WP-1.1 rework, 2026-11-22): SchemasStore._migrate_key_column (sch_schemas.key -> schema_key, MySQL reserved word), sts migrate_session_keys_nullable (NOT NULL -> nullable, older builds wrote ""), and Route53's _migrate_legacy_name_columns (legacy CLOB name columns -> VARCHAR2 on Oracle, where create_all also cannot narrow the type and direct CLOB->VARCHAR2 MODIFY is refused). Same rule as the map: probe-first, per-dialect ALTER, best-effort, loud on write.
python -m pytest tests/test_state_file_migration.py -q
proves the repair path against a deliberately old-schema database, including that opening the same file twice is a no-op.
3. The five MySQL-specific changes
MySQL is the strictest of the three and forced changes the other two did not. Each is recorded with the failure that motivated it.
3.1 Key columns are sized, never TEXT
MySQL cannot index a TEXT/BLOB column without a prefix length:
(1170) BLOB/TEXT column 'pk' used in key specification without a key length
DynamoDB's key columns, and every ARN used as a primary key, are therefore String(n) rather than sa.Text. Any new table whose primary key is text needs an explicit width. The same rule removes server_default from those columns: MySQL refuses a default on a TEXT column (1101), so a size change and a default change travel together.
3.2 Index width is measured in BYTES, not characters
This is the one that stopped the simulator from booting at all:
(1071) Specified key was too long; max key length is 3072 bytes
Under the server default utf8mb4 a character costs up to 4 bytes, so InnoDB's 3072-byte index limit is 768 characters. SQLite and PostgreSQL measure characters and accepted the same schema, so the default suite could not see it.
Consequences, all measured:
_KEY_LEN = 255for DynamoDB keys — fits a composite key._GSI_KEY_LEN = 64forgsi_index's four key columns. They share the budget
with two 255-char name columns: 255 + 255 + 4*64 = 766. This is a real narrowing on MySQL: DynamoDB caps a key at 2048 bytes, so a GSI key longer than 64 characters fails. It fails loudly at CREATE TABLE, never by truncating a key.
- CloudWatch's
LogGroupNamecolumns declareCHARACTER SET asciivia
ascii_name_column(). AWS's own contract is ASCII — LogGroupName: max=512, pattern='[\.\-_/#A-Za-z0-9]+' in botocore's service model — so 1 byte per character is exact rather than a narrowing, and cw_log_streams's PRIMARY KEY (group_name, name) fits at 512 + 2048.
sm_secret_versions.created_tsisString(32)rather thanTEXT, because it
is indexed. See §3.4.
tests/test_mysql_schema_compat.py sums every index's declared width and fails above 3072 bytes, so this cannot silently regress. It covers every service MetaData including the five WP-1.1 additions (2026-11-22): SSM names use ascii_name_column(1011) (hierarchical paths, ASCII by contract, still 1011 bytes), API Gateway account names are capped at 736 chars (32 + 736 as 128 + 2944 bytes), Schemas registry names are ASCII 255 and the registry+NUL+schema composite key 511 (255 + 1 + 255), so no new table can push a composite key over the budget.
3.3 String comparison is case-sensitive
MySQL's default collation (utf8mb4_0900_ai_ci) folds case and trailing spaces. DynamoDB keys do not. Measured before the fix, on items:
sqlite get(pk='foo') after put(pk='Foo') -> not found
postgresql get(pk='foo') after put(pk='Foo') -> not found
mysql get(pk='foo') after put(pk='Foo') -> FOUND
mysql put(pk='foo') as a NEW key -> REJECTED as duplicate
That is a wrong answer, not a cosmetic difference. Every service MetaData is therefore registered with mark_binary_collation(), and a before_create hook sets mysql_collate="utf8mb4_bin" for MySQL. The hook is used rather than a mysql_collate argument on ~75 individual columns: the declarative tables stay readable, and no MySQL-specific type is repeated across the storage modules the way ascii_name_column() already has to be.
Note CHARACTER SET ascii alone is not enough: the charset's default collation ascii_general_ci is also case-insensitive. Both halves are needed.
3.4 An index over a TEXT column is silently dropped
The worst failure mode of the five, because it does not raise:
$ CREATE TABLE sm_secret_versions (... created_ts TEXT NOT NULL, PRIMARY KEY (version_id))
Query OK
$ CREATE INDEX idx_sm_versions_by_secret ON sm_secret_versions (secret_name, created_ts)
ERROR 1170 ... used in key specification without a key length
The table exists, the index does not, and nothing in a passing test suite notices. test_declared_indexes_actually_exist_on_the_server asks the server what it built and compares that to what the schema declared.
4. Placeholder binding
The engine keeps its historical ? placeholder style. _to_driver() rewrites ? to the DBAPI's own positional marker — ? for qmark (SQLite), %s for pyformat (psycopg, pymysql) — and the statement runs through exec_driver_sql with a plain tuple.
The obvious alternative, binding :p0 names through sa.text(), works everywhere but measured 106 µs per statement against 28 µs (2026-11-10, 3000 statements). Caching the TextClause did not help (54 µs), so the cost is in SQLAlchemy compiling a statement object per call. On SQLite that was enough to push test_query_constant_time_at_scale from passing to 110.9 ms against a 100 ms bound.
Rewriting to the driver's marker is safe for the SQL this project emits: no statement contains a literal %, and quoted literals are skipped by the scanner. That "no literal %" claim was wrong: LIKE 'org_feature:%' and LIKE 'policy:%' prefixes are literal percents in iam and xray queries, and on 2026-11-21 they drew not enough arguments for format string on Dolt/MySQL-family (pyformat treats % as a marker). _to_driver now doubles every literal % on pyformat/format backends (existing %s markers pass through unchanged), so LIKE-prefix queries run unmodified everywhere. The invariant is: SQL text may contain literal %; the rewriter owns making it driver-safe.
tests/test_storage_backends.py::test_placeholder_rewrite_is_quote_aware covers that scanner on the pyformat marker, test_to_driver_emits_the_dialects_marker on both.
5. Upserts
Database.upsert_sql(table) emits the dialect's native form — ON CONFLICT ... DO UPDATE on SQLite and PostgreSQL, ON DUPLICATE KEY UPDATE ... VALUES(col) on MySQL/MariaDB/Dolt, ON DUPLICATE KEY UPDATE on Firebird via sqlalchemy-firebird 2.x. upsert(db, table, values) is the portable entry point and falls back to update-then-insert on engines with no single-statement upsert (Oracle, SQL Server, CockroachDB).
Hand-written ON CONFLICT in a storage module is a portability bug. Two were found and replaced with upsert() during this work — SNS CreateTopic and Events PutRule. Both returned a syntax error on MySQL while passing on the other two backends. The same class struck again on 2026-11-21: four raw INSERT OR REPLACE sites (X-Ray segments/groups/sampling-rules/resource-tags, Timestream tags) passed on SQLite and failed on every MySQL-family backend with error 1105 near 'OR'. All five now go through upsert(); the rule is no raw INSERT OR ... anywhere — upsert_sql/upsert() own every dialect spelling in one place.
5a. Literals that only some dialects accept
Two defects found on 2026-11-10 by running the whole differential suite on a server backend. Both were invisible on SQLite and passed on at least one other dialect, which is why the storage-level tests did not catch them.
| Written | Backend that rejects it | Fix |
|---|---|---|
VALUES (..., 0) / SET revoked = 1 on a sa.Boolean column | PostgreSQL: column "revoked" is of type boolean but expression is of type integer | bind False/True as a parameter |
1 if enabled else 0 bound for a sa.Boolean column | PostgreSQL: column "enabled" is of type boolean but expression is of type smallint (psycopg sends a Python int as smallint) | bind the bool itself |
ORDER BY CASE ... ELSE CAST(version AS INTEGER) END | MySQL: error 1064, no INTEGER cast target | sort in Python |
The general rule: bind typed values, do not inline their spelling. SQLite's 0/1 for a boolean is a storage detail, not a portable SQL literal. Where a dialect genuinely has no portable expression, move the work into Python — the row counts involved (refresh tokens per user, versions per function) are small.
list_versions_by_function is the sort-in-Python case. test_global_sign_out_revokes_the_refresh_token covers the boolean case; it was added because GlobalSignOut had no test at all, so its broken UPDATE would have stayed hidden indefinitely.
5b. Type widths that silently cap the data
The same run found a third defect, this one about capacity rather than syntax:
| Declared | Renders on MySQL as | Ceiling | What broke |
|---|---|---|---|
sa.LargeBinary | BLOB | 65,535 bytes | CreateFunction with a ~460 KB TypeScript bundle: (1406, "Data too long for column 'code_zip'") |
code_zip now uses package_binary(), which is LONGBLOB on MySQL (MEDIUMBLOB is 16 MB; AWS allows a 50 MB zipped package, so LONGBLOB is the type that matches the contract). SQLite and PostgreSQL keep LargeBinary.
This one is worth dwelling on because no SQLite or PostgreSQL run could ever reveal it. SQLite's BLOB and PostgreSQL's bytea are effectively unbounded, so the code is correct on both and the ceiling appears only on the backend with a size cap. Any new binary column needs a package_binary()-style variant.
tests/test_mysql_schema_compat.py::test_no_binary_column_renders_as_plain_blob compiles each binary column's TYPE for MySQL and fails on a bare BLOB. It compiles the type rather than string-matching the table DDL: the DDL form is quoting-dependent, and a DDL-based matcher written during this work matched nothing and passed against the broken code.
6. Timestamps
Epoch-millisecond columns (~1.79 × 10¹²) do not fit PostgreSQL's INTEGER (32-bit). All 22 *_ms columns are BigInteger. A new timestamp column must be too.
7. What still differs
- MySQL is the only backend with a narrowed GSI key width (§3.2).
- PostgreSQL's default collation is locale-dependent. The container used
here (en_US.utf8) ordered identically to byte order for the inputs tested, but a database created with a different locale could order differently. Only MySQL was measurably wrong.
- Oracle is tested; SQL Server and Databricks are not. Oracle Free
(gvenzl/oracle-free, service-name URL oracle+oracledb://SYSTEM:...@127.0.0.1:1521/?service_name=FREEPDB1 -- note: the pdb name is a SERVICE, not a SID, so the bare .../FREEPDB1 form fails with DPY-6003) runs the same differential legs as the other backends (§10). upsert_sql still raises NotImplementedError for Oracle/SQL Server/Databricks and upsert() takes the portable update-then-insert path, but only Oracle has run against a live server.
8. Backend lessons from the 2026-11-20 matrix
A second full-matrix run (whole differential suite per backend, plus kill-and-reboot persistence per backend) found four more defects. Each is recorded with the measurement that motivated it.
8.1 Server backends need NullPool, not the driver default
~35 services each open their own Database against the same server URL at boot. The SQLAlchemy default (5 pool + 10 overflow) times 35 is ~500 connections against a default-sized server (MySQL 151, PG 100). Measured on MySQL: 110 sleeping root connections from two boots, then Too many connections; measured on PG: 53 idle backends, then too many clients already. The first fix (pool_size 1 per Database) deadlocked boot instead: boot's create_all/_add_missing_columns check out the ENGINE while self._conn is held open, and with one slot the DDL checkout waits forever (measured: PG boot stalled at ~25 of 38 services).
The fix is NullPool on server backends: no pooled connections are held between statements, so an idle simulator keeps zero server backends and boot peaks at one connection per service instead of fifteen. SQLite keeps its existing pooling (StaticPool for :memory:, default otherwise). Every statement runs under self._lock on self._conn, so the reconnect path in _ensure_conn (used after close()) never races.
8.2 Boot DDL must batch: one inspection round trip, one ALTER transaction
_add_missing_columns originally looped has_table + get_columns per entry: 2 round trips x ~20 tables x ~35 services = ~1400 sequential queries per boot. Against a local server that was ~2 s per service and pushed the whole boot to ~55 s -- past the harness's 20 s readiness probe (measured: RDS ... did not become ready within 20s on both MySQL and a healthy PG).
The loop now reads get_table_names once, get_columns once per wanted table on one connection, and applies all missing columns in a single transaction. The readiness probe in tests/conftest.py was also raised to 120 s per service: ~2 s per service on a server backend is normal, and a generous per-service timeout only slows a genuinely dead service, never a healthy boot.
8.3 Server-backup probes must run against live servers: --strict-rds
OFFSTACK_TEST_RDS_SERVER_URL / OFFSTACK_TEST_RDS_MYSQL_SERVER_URL gate the rds_backed tests, which are the ONLY verification that an RDS endpoint serves its database and the Data API runs real SQL. Unset, those tests skip and the suite reads green with that behaviour unverified. CI passes --strict-rds, which fails the run unless both URLs answer SELECT 1 at collection.
8.4 Session state persists on server backends: wipe once at session start
:memory: starts empty per suite; a server backend keeps yesterday's rows. An exact-count assertion then passes on :memory: and fails on a reused backend for reasons unrelated to the backend (measured: the KMS retirable test saw 5 grants on MySQL, 4 on PG, 1 on :memory: -- same code). The simulator fixture therefore calls Database.wipe_all_tables() once at session start when OFFSTACK_TEST_SIM_DATABASE_URL is set (226 tables in 0.3 s on MySQL, 0.6 s on PG), so every backend leg runs from the same empty state. Tests that need isolation within a run use unique names, not the wipe.
8.5 Kill-and-reboot persistence is covered per backend
tests/test_restart_persistence.py boots a real start.py with --persist on the backend under test, writes one object per DB-backed service family (DynamoDB row, SQS queue+message, SNS topic, second DynamoDB row, second queue, Secrets Manager secret, KMS key+alias, Logs group+stream, S3 bucket+object, SSM parameter, CloudFormation stack, API Gateway REST + HTTP APIs, EventBridge Schemas registry+schema, STS session key), kills the process, reboots on the SAME backend, and reads every object back. Parametrized by OFFSTACK_TEST_SIM_DATABASE_URLS (default: one SQLite file). WP-1.1 (2026-11-22) moved SSM, CloudFormation, API Gateway v1/v2, EventBridge Schemas, and STS sessions onto SQLAlchemy, so every family in the list now persists; no service family is excluded.
9. Stores that do not persist by design
Not every service writes to the state backend. These keep process-local state and lose it on restart on every backend, SQLite included:
- S3 object bytes live in
--s3-data-diron the filesystem, not in the
database. The bucket listing reads that directory, so a reboot with a different data dir loses the objects even though the DB rows survive.
- ACM's local CA key lives in
<state dir>/acm-ca/on the filesystem
(or a per-process temp dir when the state is a server URL, which has no directory -- see acm/local_ca.py::ca_paths). A server backend therefore gets a fresh CA per process; certificates issued before the kill do not chain to the post-reboot CA.
10. Oracle lessons from the 2026-11-20 matrix
The DynamoDB/KMS/SNS/SQS/Streams/StepFunctions/Kinesis/CloudWatch/Events/ IAM/SES/SecretsManager differential legs run green on Oracle Free 23.26. Seven defects, each invisible on every other backend:
10.1 "" is NULL: the absent-sort-key sentinel
Oracle folds empty strings to NULL, and a NULL violates the NOT NULL primary-key columns holding sort text. A DynamoDB table with no sort key stores "" for sk (and gsi_sk); on Oracle that marker must be a value that is non-NULL, equality-stable, and sorts before every real key -- the position "" holds elsewhere. Sixteen NUL chars satisfy all three on VARCHAR2 (measured: equality, ORDER BY, range, LIKE, LENGTH 16). Only "" maps; every real sort text passes through byte-identical (dynamodb/storage_engine.py::_db_key, applied in _extract_key_values, _evaluate_key_condition, and _build_sk_sql_condition). The sentinel is safe because _validate_item_keys rejects empty key attributes -- "" can only ever come from the absent sort key.
10.2 Sequences must be consumed explicitly
sa.Sequence defaults render DDL the other backends accept, but a raw INSERT naming every column except the id fails with ORA-01400: nothing fills the PK. Database.seq_nextval(name) returns name.NEXTVAL on Oracle and None elsewhere, so the INSERT names the column only there (ds_stream_log, cw_log_events, cw_metric_datapoints; the kinesis settings row passes its id literally and needed nothing).
10.3 No LIMIT, no bound LIMIT, no OFFSET without FETCH
Raw LIMIT n fails with ORA-03049 and a bound LIMIT ? fails too -- Oracle rejects placeholders in the row-limit clause entirely. Every site now goes through Database.limit_clause, which gained an offset parameter: two token-paginated listings need OFFSET n ROWS FETCH NEXT m ROWS ONLY, which MSSQL shares (its TOP rewrite handles limit-only).
10.4 CLOB comparison: size every =-compared column
Oracle rejects = (and DISTINCT, and ORDER BY) on CLOBs with ORA-22848. Every column compared with = -- arn on ~35 tables, event_source_arn, retiring_principal, topic_arn, endpoint, dimensions_json -- is now a sized VARCHAR2 (widths cover the worst-case ARN per family; secrets need 640). Payload columns never compared stay TEXT. The SELECT DISTINCT ... dimensions_json / ORDER BY dimensions_json in CloudWatch list_metrics became a plain SELECT with Python-side dedupe.
10.5 RESOURCE is reserved: quote it
DELETE/SELECT ... WHERE resource = ? on the shared tags table fails with ORA-00936 unquoted. The DynamoDB engine now splices self.db.q("resource") (quotes on Oracle, passthrough elsewhere) instead of quoting the table once: q() quotes per the live dialect, so a static rename would misquote the backends that accept the bare word.
11. SQL Server lessons from the 2026-11-20 matrix
The DynamoDB/KMS/SNS/SQS/Streams/StepFunctions/Kinesis/CloudWatch/Events/ IAM/SES/SecretsManager/Lambda differential legs run green on SQL Server 2022 Express (MSSQL_PID=Express, dedicated offstack database with READ_COMMITTED_SNAPSHOT ON -- RCSI cannot be enabled on master, error 5058, and the default READ_COMMITTED makes locking reads block writers, which flaked Kinesis under the bridge worker thread). Eight defects, each invisible on every other backend:
11.1 Eager fetch: no open result may span two statements
FreeTDS/pymssql keeps server-side cursor state alive until the rows are consumed. Database.execute used to return a lazy Result over the open CursorResult, and callers fetch outside the lock -- so a bridge-thread SELECT could land between another thread's SELECT and its fetch, and the connection wedged with (0, b'Unknown error') on every later statement (measured: Kinesis put_record's _require SELECT died after a few create/put/delete cycles, only with the bridge wired, only on MSSQL). Result now buffers fetchall() at construction, captures rowcount before the close, and closes the cursor inside the lock. rowcount and lastrowid keep their shapes (rowcount from the capture, lastrowid still unused) so the KMS/Scheduler/SES rowcount == 0 checks and the RDS Data API numberOfRecordsUpdated need no edit.
11.2 ADD, not ADD COLUMN; LEN, not LENGTH; quote rule
T-SQL rejects ALTER TABLE ... ADD COLUMN (error 156), has no LENGTH (LEN), and reserves rule. Database emits bare ADD on mssql, the DynamoDB engine picks LEN per dialect, and the Events store quotes its rule column through self.db.q("rule").
11.3 Bytes bind as varchar: CONVERT(VARBINARY(MAX), ?)
pymssql binds bytes as varchar, which VARBINARY(MAX) refuses (error 257) -- every KMS write failed. Database.binary_param() wraps the marker in CONVERT on mssql (server-side typing, so b"" lands too) and passes it through elsewhere. Bytearray still mistypes, so the CONVERT approach stays rather than a client-side cast.
11.4 Explicit ids need IDENTITY_INSERT, not a plain INSERT
sa.Sequence(optional=True) renders IDENTITY on mssql and stays inert elsewhere (plain Sequence renders no IDENTITY; Identity+Sequence is forbidden; the deprecated mssql_identity_start is ignored). Singleton rows that pass their id literally (kin_account_settings id 1) draw error 544 on the plain INSERT; the store wraps it in SET IDENTITY_INSERT ... ON/OFF on mssql only.
11.5 TOP, and OFFSET needs ORDER BY
MSSQL has no LIMIT; Database.limit_clause rewrites to SELECT TOP n for limit-only queries and OFFSET n ROWS FETCH NEXT m ROWS ONLY (which needs an ORDER BY -- every offset call site has one) otherwise.
11.6 The 2026-11-21 rerun: three more MSSQL-only defects
The full sweep (3,908 collected over 272 files) left 30 MSSQL-only failures, none pre-existing on SQLite. Three code defects and one sweep-hygiene lesson:
identityis reserved in T-SQL (error 156).ses_identities.identity
gained quote=True at DDL and q("identity", force=True) at the three raw-SQL sites (status lookup, delete, ordered list) -- the same fix the value/position columns in this store already carry.
binary_param()was wrapping the wrong placeholder in ElastiCache's
snapshot INSERT: CONVERT landed on the created_ms integer (a no-op that left the real bytes bind bare) instead of on payload. One-word fix, invisible everywhere but MSSQL because only that dialect types the bind server-side.
- Timestream has no MSSQL branch yet:
json_extractis not a T-SQL
function and CAST(x AS DOUBLE) is a syntax error (102). The dimension filter uses JSON_VALUE(dimensions_json, ?) with the path bound (T-SQL accepts a bound path, measured on the live Express container), the aggregate casts to FLOAT, and the tail cap goes through Database.limit_clause (TOP n) instead of a hand-rendered LIMIT. _where now returns (clauses, params, order, limit) so the caller can compose ORDER BY + TOP.
- The 30th failure was not a product defect. The
own_simulatorprobes in
test_reference_app_gate.py boot on :memory: regardless of OFFSTACK_TEST_SIM_DATABASE_URL, but the simulator process still opens the state backend URL when one is set -- and the session-start wipe only runs in the shared simulator fixture, not in a bare SimulatorHandle. A HelloWorldStateMachine row left by the earlier half-1 run survived into the lambda probe and drew a correct StateMachineAlreadyExists. Deleting the two stale rows fixed it; a rerun leg must start from an empty offstack database (or wipe first).
11.7 The 2026-11-21 MariaDB hang: a 26-year-old client split, not a limit
The heston gate (test_serverless_toolkit_gate.py) deploys the unmodified Node.js handler with its node_modules bundled -- a 37,793,430-byte (~36 MiB) zip, which crosses the wire base64-encoded as a ~50.4 MB HTTP body into POST /2015-03-31/functions. On MariaDB 11.4 (port 33308) the call hung past the 60 s boto timeout while the same blob flew through on every other backend. The database side was innocent: the INSERT never fired, because the HTTP server never finished reading the body. max_allowed_packet is 64 MiB globally and per session, and innodb_log_file_size is 96 MB -- none of it reachable while the request is still being received.
The threshold was measured directly with raw PyMySQL inserts of b'x' blobs into a temporary LONGBLOB: 31 MiB passes in 0.7 s, 32 MiB stalls. Not with the server's 1153, but with the client's -- PyMySQL 2.2.8's own max_allowed_packet connection argument defaults to 16,777,216 and is enforced client-side before a byte is sent: oversize payloads are silently never transmitted, so the server logs nothing and the caller sees a hang (or a bare InterfaceError(0, '')), never the packet error. (Careful reading that probe: escape_bytes renders _binary X'...' hex, so the wire bytes are ~2x the blob; the true client-payload threshold is what the 31/32 MiB numbers bracket, not the nominal blob size.)
The number is a fossil: the 16 MiB default dates to MySQL 3.23 (2001), when the server's default was 16 MB. The server default has since quadrupled to 64 MB, but the driver default never followed -- so any blob between 16 and 64 MiB stalls on stock settings while both ends report a 64 MB limit. The earlier SET GLOBAL max_allowed_packet=64M "fix" changed nothing for exactly this reason: it raised a limit that was never the binding one.
Two ceilings bind this path, and the fix must clear both. First the driver: Database now passes connect_args={"max_allowed_packet": 1 << 26} for +pymysql URLs, matching the 64 MiB both fixture servers report, so the client's ceiling is the server's. Per-connection, not per-statement: the simulator holds one persistent connection per service and a GLOBAL set after boot never reaches it. Second the wire: the deployment JSON carries the zip base64-encoded, so the HTTP body's limit is what the zip measures against, not the blob -- and the gate's body reads the full length up front (lambda_service/server.py MAX_BODY = 60 MiB absorbs it; the base64 of the 36 MiB bundle is ~50.4 MB).
11.8 The 2026-11-21 peer-handoff rerun: the case-sensitivity migration
The peer's width suite added test_case_sensitivity_and_distinct_keys to the MSSQL leg, and it failed: GetItem(pk="foo") matched pk="Foo". The BIN2 story from B11 was half done -- new tables get Latin1_General_BIN2 at CREATE time via the before_create hook, but create_all skips tables that already exist and its hooks never fire for them (measured: zero tables seen on the rerun leg, because all 228 already existed). Every old table kept the case-insensitive database default. Database therefore runs _ensure_mssql_binary_collation() at boot: a per-table rebuild (create under a temp name with BIN2 on every string column, PK re-declared, rows copied, old table dropped, rename), gated so repeat boots are read-only (all string columns BIN2 at the right widths AND every declared index present).
The rebuild surfaced four MSSQL DDL truths, each measured on the live Express container:
- A column-level ALTER is refused on PK/FK/index members (error 5074),
and a second ALTER on one pymssql transaction aborts the commit (error 3902) -- hence one transaction per table, not per column.
sp_renamerenames the table, but the new name is invisible to later
statements on the same pymssql connection (error 1088) -- so the index build runs on a FRESH connection after the copy commits, and a CREATE TABLE + CREATE INDEX in one transaction also aborts (3902), so each index gets its own transaction.
- TEXT/MAX columns are not index-buildable (error 1919), and index keys
are capped at 900 bytes (error 1911): 512-char BIN2 is single-byte per char, so the 512+512 stream PK was 1024. The secondary-index check therefore rebuilds through an indexable spelling (TEXT members as VARCHAR(450), skipping members that still exceed the budget -- the engine never reads through the index, so skipping is safe).
LEN()refuses the TEXT type (error 8116):describe_tablecasts
first (LEN(CAST(item_data AS VARCHAR(MAX)))).
One schema change fell out of the 900-byte budget: cw_log_streams/cw_log_events name widths went 512 -> 400 (400+400 = 800 fits). The _BINARY_COLLATION_METADATAS registry also changed from WeakSet to a strong set: storage modules imported only by the test were garbage-collected and the registry held 1 of 26, silently skipping every other service's tables.
11.9 The rework pass: Part B on MSSQL and Oracle (2026-11-21)
Antigravity's independent re-verification (task-942) found two Part B blockers behind the green Part A legs, both fixed in this pass:
- Oracle
r53_records.set_id(ORA-01400). A plain record carries no
SetIdentifier, so the store writes "" into the NOT NULL PK column; Oracle folds it to NULL. Fixed with the same absent-sort sentinel the DynamoDB engine uses (_db_set_id/_wire_set_id, sixteen NUL chars) at the three write sites plus the readback. The same fold then surfaced one table per leg: r53_changes.comment, then MemoryDB, ElastiCache, RDS and IAM description columns -- all now covered by _relax_oracle_empty_string_nullability(), a boot migration that issues MODIFY ... NULL (with "comment" quoted -- ORA-03050 otherwise) only for columns that are still NOT NULL.
- MSSQL Part B boot timeout.
Database.__init__ran
_ensure_mssql_binary_collation() per Database, each re-inspecting all ~228 tables (get_columns + get_indexes per table x ~28 services = minutes; start.py stalled at service #21 Pipes, past the 120 s probe). Now one process-wide sys.columns/sys.indexes snapshot (2 round trips TOTAL) plus a single INFORMATION_SCHEMA collation query (~1 s for all 1,000 columns) replaces ~456 per-table inspector calls; repeat boots are read-only through the same gate.
- Timestream JSON_VALUE on MSSQL + Oracle. Both have JSON_VALUE but
the PATH must be a literal: MSSQL rejects a bound path (same class as Oracle's ORA-40454) and Oracle likewise, so the path is inlined from the regex-validated key (same derivation as PG). MSSQL additionally refuses the TEXT type outright (error 8116, same class as LEN in describe_table), so its column is cast to NVARCHAR(MAX) first.
12. New backends from the 2026-11-21 matrix: CockroachDB, Firebird, Dolt
Three more free RDBMS, each picked for a new bug class rather than novelty. CockroachDB is distributed SQL on PG-wire; Firebird is the only lineage outside MySQL/PG/MSSQL/Oracle; Dolt is MySQL-protocol with versioned tables. Status: differential Kinesis/DynamoDB/Streams/SQS/KMS/SNS/Lambda/Events/ StepFunctions/Secrets/IAM/Cognito/CloudWatch legs green on all three.
12.1 CockroachDB: retry 40001, quote what PG leaves bare
cockroachdb+psycopg://root@127.0.0.1:26257/defaultdb?sslmode=disable (single-node --insecure, sqlalchemy-cockroachdb dialect; the dialect name normalises to postgresql in Database, with _raw_dialect preserved for behaviour Cockroach does not share). Two defects, both invisible on PG:
Retry 40001. CockroachDB aborts serializable transactions under contention and documents client-side retry as the contract. Every statement here runs in its own implicit transaction, so Database.execute retries the one statement up to 3 times on 40001/restart transaction (Cockroach only, other backends keep single-attempt). A persistent 40001 is a real deadlock, not contention, so the bound stays.
family is reserved. rds_parameter_groups.family, ec_parameter_groups.family and mdb parameter groups.family drew SyntaxError at or near "64" on CREATE TABLE -- reserved in CockroachDB, unreserved in PG/MySQL. The three columns carry quote=True at DDL (each dialect's own quotes). Raw DML must match: Database.q gained force=True (via quoted_name, rendering "family" on PG/Cockroach and ` family on MySQL), because the preparer only quotes words its own reserved list contains and family is not in PG's list, which CockroachDB reuses. The full-sweep failures were the three raw INSERT ... family ... sites in parameter-group creation -- fixed to q('family', force=True). _upsert_sql_cached and the upsert() fallback honor each column's quote=True` flag the same way, so generated upserts quote too.
Boot is slower than PG (~60 s for the full stack vs ~45 s): per-service DDL plus a serializable handshake per Database, not slow DML (measured: 20 inserts 0.16 s). The harness 120 s per-service probe covers it.
Extras. CockroachDB rides pip install offstack[cockroachdb] (sqlalchemy-cockroachdb + psycopg[binary]); Dolt rides the mysql extra (plain pymysql); Firebird rides offstack[firebird] (sqlalchemy-firebird
firebird-driver). The Firebird client DLL is deliberately NOT a pip
concern: fbclient.dll/ib_util.dll live in git-ignored .db-clients/firebird/ and Database preloads them with importlib (importlib, not a top-level import — the driver is an optional extra loaded through SQLAlchemy's dialect entry point like every other backend driver, and a direct import trips the packaging census that requires every AST-visible third-party import to be a core dependency).
12.2 Firebird: 16K pages, ROWS limits, no TEXT domain
firebird://sysdba:offstack_pw123@127.0.0.1:3050/offstack16k.fdb (jacobalberty/firebird:4.0, sqlalchemy-firebird + firebird-driver). Client library: the host needs fbclient.dll + ib_util.dll, staged at .db-clients/firebird/ (git-ignored, from the Firebird 4.0.5 release zip); Database preloads it via firebird.driver.load_api before create_engine, so no host install or PATH entry is required. Eight defects, each invisible elsewhere:
Index budget. The default 8K page caps a key at ~2K bytes: a lone VARCHAR(512) PK and the composite items/gsi_index keys all fail with key size exceeds implementation restriction. The fixture database is created PAGE_SIZE 16384 (one isql line at container setup); on 16K pages every key shape in the schema passes (VARCHAR(1000) probed OK). The stock offstack.fdb alias keeps 8K pages and cannot host the schema.
Limits are ROWS. Firebird rejects LIMIT/FETCH FIRST (-104); the limit-only rewrite is SELECT ... ROWS n, skip-take is ROWS m TO n. Bound parameters are not allowed in the ROWS clause, so the ints are inlined after int() (same trust as the existing TOP/OFFSET inlining).
ADD, not ADD COLUMN. T-SQL and PSQL share this: bare ADD on both, ADD COLUMN elsewhere (measured -104 on Firebird).
No TEXT domain. ALTER TABLE ... ADD TEXT fails (-607, domain does not exist); the migration spells unbounded text BLOB SUB_TYPE TEXT. DDL from the dialect already renders sa.Text that way at CREATE TABLE.
Length is CHAR_LENGTH. Firebird has neither LENGTH nor LEN (-104); describe_table picks per dialect (mssql -> LEN, firebird -> CHAR_LENGTH, else LENGTH).
No server JSON functions. Firebird 4 has none at all: JSON_QUERY, JSON_VALUE, JSON_EXISTS each draw -804 ("Function unknown") -- those are Firebird 6+. Timestream's dimension filter matches the canonical '"key": "value"' JSON substring instead: POSITION(? IN dimensions_json) > 0 with the needle json.dumps-built from the regex-validated key and bound as one parameter. DOUBLE PRECISION is the float type (bare DOUBLE is -104), and a query-tail LIMIT n renders as trailing ROWS n (same -104 for LIMIT).
More reserved words: VALUE, POSITION. Probed directly against the engine (SELECT <word> FROM RDB$DATABASE: "Token unknown"/"Illegal use" means reserved, "Column unknown" means a usable identifier): value and position are reserved, while action, type, password, role, source, status, message, family all parse fine. (No filter, count or plan column exists.) Three value columns (iam_account_ preferences, ses_account_state, sn_sms_attributes) and one position column (ses_receipt_rules) gained quote=True at DDL plus force-quoted raw DML. The upsert() fallback had two latent bugs the GSI leg exposed: the all-PK branch emitted MySQL's ON DUPLICATE KEY for every non-sqlite/ postgres dialect (now guarded to mysql/mariadb, NotImplementedError elsewhere), and the fallback built UPDATE t SET WHERE ... with an empty SET list for all-PK tables (now insert-if-absent via SELECT 1).
Fixture DBs go stale. Quoted DDL is case-sensitive in Firebird ("family" != FAMILY), and MariaDB never backfills AUTO_INCREMENT onto existing tables -- so a fixture database created before a DDL change silently disagrees with current code. Both bit during the 11-21 sweeps (MariaDB offstack from 11-20 lacked autoincrement; Firebird offstack16k.fdb had unquoted FAMILY). Fix is recreation, not migration: DROP/CREATE DATABASE (MariaDB) or delete + CREATE DATABASE ... PAGE_SIZE 16384 (Firebird). Recreate the fixture DB whenever DDL changes, before blaming the backend.
BLOB reads return bytes through the normal _mapping path (no Oracle LOB locator special-casing needed); parametrized BLOB binds land as-is.
12.3 Dolt: the full sweep is green (minus pre-existing failures)
mysql+pymysql://root:offstack_pw123@127.0.0.1:23306/offstack (dolthub/dolt-sql-server, MySQL protocol on 3306, plain pymysql + mysql dialect). One setup step: root@localhost exists but no remote root, so CREATE USER 'root'@'%' + GRANT once after first boot, then CREATE DATABASE offstack. The full 279-file suite ran 2026-11-21: everything passes except failures that reproduce identically on the default SQLite backend (forecast unknown_resource_billed split — elasticache DescribeCacheClusters now prices free/0.0, not unknown — since fixed by swapping the probe operation to a genuinely unmapped one; packaging census before the new extras landed; test_start_readiness timing; sweep_g event-source validation ordering). The RDS PITR/backtrack/tenant surface named here is implemented since 2026-11-21 (rds_cluster_backtracks + rds_tenant_databases tables, restore-origin columns on instances/clusters). No Dolt-specific defect: expected, since Dolt intentionally tracks MySQL semantics; it stays in the matrix as the canary for MySQL-protocol drift, not as a bug source. Dolt's sweep is what caught the two latent MySQL-family bugs above (literal % in LIKE, raw INSERT OR REPLACE) — both fail on plain MySQL too, so every MySQL-family backend inherits the fixes.
13. WP-1.1 persistence additions (2026-11-22)
Five more families moved onto SQLAlchemy behind the same portability rules:
- SSM (
ssm/storage.py):ssm_parameters/ssm_parameter_labels/
ssm_parameter_tags. Names use ascii_name_column(1011) -- SSM names match [a-zA-Z0-9_.-/], so 1 byte/char is exact, and a 2048-char utf8mb4 name would cost 8192 of the 3072-byte MySQL key budget. Sibling stores (documents, baselines, windows, commands, associations, ops items, activations, sessions, previews, inventory, compliance, automation, ops metadata, syncs, settings, resource policies) persist whole-record JSON in the generic ssm_state table (kind, name, record_json), re-saved whole after every public method -- the mem layer mutates records in place (_settle on read, accounts.add, nested targets[wid][tid] = ...), which no __setitem__ ever sees. Only stateless PatchInventory / ManagedInstanceStore stay in RAM. Map keys are str or tuples (inventory pairs, compliance triples, command invocations), tagged-encoded to the string column and decoded on load; SessionStore stays a list in one row (_DbStateList); sweeps run under the Database lock (R1: tuple bind crash, list/dict mismatch, unlocked sweep).
- CloudFormation (
cloudformation/storage.py):cfn_stacks(+ events,
policies, change sets). Stack names stay String(255); no composite key approaches the budget.
- API Gateway v1/v2 (
apigateway/storage.py,apigatewayv2/storage.py):
one row per API, account maps on (kind, name) with name capped at 736 chars (32 + 736 as 128 + 2944 bytes).
- EventBridge Schemas (
event_schemas/storage.py):sch_registries,
sch_schemas (column schema_key -- bare key is a reserved word on MySQL, ERROR 1064 on every write; a _migrate_key_column renames the column on pre-existing databases at boot), sch_account. Registry names are ASCII(255); the registry+NUL+schema composite key is ASCII(511).
- STS sessions (
sts/server.py):sts_session_keysvia the lazy
sts.server._metadata() (no module-level MetaData, so laziness is deliberate -- the matrix census and the compat suite import it explicitly). access_key_id is String(32); Oracle compares it with =, so it is sized, not TEXT (ORA-22848). role_arn AND session_token are nullable with a migrate_session_keys_nullable boot migration (older builds created both NOT NULL and wrote ""; the root seed carries no token and Oracle folds "" to NULL -- ORA-01400 on boot, masked by a swallowed seed exception until R2 logged it). WP-1.2 (2026-11-22) adds a nullable session_policy TEXT column (the AssumeRole caller Policy, intersected at enforcement time; NULL = none passed) with a migrate_session_keys_policy_column boot migration -- TEXT is never compared, so it is portable on all 10 dialects with no index-budget impact.
Coverage: tests/test_mysql_schema_compat.py registers all five (32 MetaDatas total with STS) and sums every index against the 3072-byte budget; tests/test_width_rdbms_matrix.py census is 32 and its kill-and-reboot leg is 25 services (the original 20 plus SSM parameter, CloudFormation stack, REST API, HTTP API, and Schemas registry+schema). §9's "does not persist" list drops SSM accordingly; tests/test_restart_persistence.py now covers every family in the list with no exclusions.
14. Wave 11.1 full-sweep traps (2026-11-24)
tests/test_stage11_10rdbms_sweep.py runs all 23 Stage 7-10 stores through Create -> Read/Describe -> Update/List -> Delete on all 10 engines. Four new traps, each fixed at the root cause in source:
- MSSQL has no BOOLEAN. Hand-written boot-migration DDL
(_add_missing_columns) emitted bare BOOLEAN for kms_keys.multi_region (error 2715 on ALTER). create_all translates sa.Boolean to BIT on its own -- only the hand-written strings needed the fix (BOOLEAN -> BIT for the mssql dialect, next to the existing oracle/firebird rewrites).
- Raw
LIMIT 1is not portable. Five string literals in
organizations/storage.py plus one in sso_admin/storage.py broke Firebird (-104), Oracle (ORA-03047) and MSSQL alike. The repo convention is db.limit_clause("SELECT ...", 1) -- inherited through ScopedDatabase -- and now covers all six sites.
- Firebird reserves
VALUE.sq_quotas.valuegainedquote=Trueat
DDL plus force-quoted raw DML (db.q("value", force=True)), the same shape as the ses value/position precedent. The stale fixture column (unquoted VALUE vs quoted "value", distinct identifiers on Firebird) needed a DROP + rebuild; the MariaDB/Oracle/PG fixtures were unaffected.
- Firebird -303 on OR dual-lookups. `pca_authorities WHERE arn = ? OR
ca_id = ? binds the 93-char ARN against ca_id VARCHAR(64) -- a truncation error, not a no-match. Split into two single-column lookups (arn first, then id), the same shape as batch _resolve_jobdef`.
13. Multi-Cloud x 10-RDBMS Matrix & MariaDB Chunked Resolution (2026-11-27)
- MariaDB 11.4 38 MiB Lambda resolution.
lambda_service/storage.pychunks
zip payloads above _CHUNK_THRESHOLD (2 MiB) into code_chunks_table rows (_CHUNK_SIZE = 2 MiB). Verified against live mariadb:11.4 (:33308) with @@max_allowed_packet = 16777216: a 28.00 MiB zip / 37.33 MiB JSON POST returned HTTP 201 (CodeSize=29360413) in 1.21 s, with exact readback via get_function_code and code_for_invocation.
- Multi-Cloud x 10-RDBMS restart durability (
tests/test_stage28_multicloud_rdbms_matrix.py).
start.py forwards URL-form --state-file values directly to AzureGatewayServer and OCIGatewayServer; OCIControlStore now delegates engine/pool/Firebird setup to Database(url_from_path(...)), omits SERIAL DDL via autoincrement=False plus monotonic PK assignment on oci_stream_messages, and makes empty-capable text columns nullable ("" coalesced on read) for Oracle. azure_arm.py narrows azure_resources.resource_id, azure_deployments.id, and azure_role_assignments.{id,scope} to sa.String(767) (3068 UTF8MB4 bytes <= MariaDB's 3072-byte index ceiling). Verified end-to-end across SQLite, DuckDB, PostgreSQL 16, MySQL 8.4, MariaDB 11.4, Dolt, CockroachDB, MSSQL 2022, Oracle Free 23, and Firebird 4.0 (11 passed incl. MariaDB large-body Lambda test).
15. IBM Db2 and SAP HANA (Track D1, 2026-11-29)
Two more verified server backends, bringing the total to twelve. Both are Pro/Enterprise only; the Free edition keeps its memory-only SQLite.
15.1 Connecting
python start.py --persist \
--state-file 'db2+ibm_db://db2inst1:pass@127.0.0.1:50000/OFFSTACK?AUTHENTICATION=SERVER'
python start.py --persist \
--state-file 'hana+hdbcli://SYSTEM:pass@127.0.0.1:39041'
Drivers (installed as local dev extras, reported here for reproducibility): ibm_db 3.3.0, ibm_db_sa 0.5.0, sqlalchemy-hana 5.0.0, hdbcli 2.30.32 on SQLAlchemy 2.0.49. Servers measured: IBM Db2 Community 12.1.6.0 (DBMS_VER 12.01.0600, 4096-byte pages, UTF-8) and SAP HANA 2.0 SPS08 (server_version_info (2, 0, 88, 0, …)).
Db2 needs AUTHENTICATION=SERVER in the URL. Db2 CLI documents it as the default, but the ibm_db 3.3.0 wheel does not apply it: every login omitting it fails immediately with SQL1042C An unexpected system error occurred (SQLSTATE 58004), which names neither the keyword nor the cause. Adding that one keyword makes the identical connection succeed. The backend seam appends it to every engine it builds (_db2_connect_args), but some components — container_runtime.ecs_bridge, lb_proxy — build their own create_engine straight from the state URL and bypass the seam, so the URL passed to start.py should carry the keyword.
15.2 Dialect names
ibm_db_sa registers itself under the driver name, not a backend name, so engine.dialect.name is "ibm_db_sa". _db_backend.normalize_dialect maps ibm_db/ibm_db_sa/db2 to db2, which every branch in the tree matches. HANA reports hana and needs no rewrite.
15.3 What is verified
| Check | Db2 12.1.6 | HANA 2.0 SPS08 |
|---|---|---|
| All 87 storage MetaDatas create (730 tables) | yes | yes |
| DynamoDB round-trip + in-place upsert | yes | yes |
Case-sensitive keys (Foo ≠ foo) | yes | yes |
| 120 KB binary payload round-trip | yes | yes |
limit_clause limit+offset | yes | yes |
| Connection recovery after an error | yes | yes |
Restart persistence (start.py --persist twice) | passes | passes |
The trap matrix (tests/test_width_rdbms_matrix.py) runs the same nine dialect traps on both new backends alongside SQLite and DuckDB: 45 passed on all four legs.
15.4 Db2 specifics
- Identifier folding. Both fold unquoted identifiers to UPPER case, like
Oracle, and sa.inspect().get_table_names() reflects them upper-case. The shared _uppercase_folding_table_names helper reads SYSCAT.TABLES WHERE TABSCHEMA = CURRENT SCHEMA for Db2 exactly as it reads user_tables for Oracle, and lower-cases both sides for comparison.
- LIMIT / OFFSET. Db2 12.1.6 accepts
LIMIT nand the standard
OFFSET n ROWS FETCH NEXT n ROWS ONLY; the bridge emits the standard form because it needs no version gate.
- No single-statement upsert. Db2 takes the existing update-then-insert
fallback in upsert().
ADD COLUMN. Db2 wants a bareADD; HANA wantsADD (col type).
add_column_sql spells all three forms (standard / bare / parenthesised).
- BOOLEAN and BIGINT both exist on Db2 11.1+ and were confirmed on this
12.1.6 server; TEXT is rewritten to CLOB in migrations.
- Key-size limit — the Db2-specific constraint. Db2 counts a key in
BYTES and reserves a key header. Measured on this server: a composite key of 1020 bytes creates, 1021 raises SQL0613N. The budget by page size, read at boot from SYSCAT.TABLESPACES (USERSPACE1) rather than hardcoded, is 4096→1020, 8192→2044, 16384→4092, 32768→8188. The page size cannot be raised on an existing database (CREATE TABLESPACE … PAGESIZE 32K fails with SQL1582N), so a schema that overruns the budget is refused before any DDL with a message naming every offending table and the CREATE DATABASE … PAGESIZE 32768 fix (_db_backend.check_key_size_limits).
- Four tables overran 1020 bytes (their natural composite keys were
512+512 and 1011+128/255 chars). They now key on a 64-character key_hash = SHA-256("\x00".join(natural parts)) surrogate: the natural columns stay NOT NULL and unindexed, so every WHERE read is unchanged, and the row is addressable by its real values. This is the same C.3 pattern the cloud adapters already use. The tables: cw_metric_filters, cw_subscription_filters, ssm_parameter_tags, ssm_parameter_labels.
15.5 HANA specifics
- Native upsert.
UPSERT <t> (cols) VALUES (…) WITH PRIMARY KEY— used
by upsert_sql_template, and it accepts the key-only table too.
LIMIT/OFFSET. Quirk: HANA hasLIMIT n [OFFSET n]but NOT
FETCH FIRST (syntax error near FIRST, measured). limit_clause emits LIMIT/OFFSET for HANA.
ADD (col type). HANA rejects bothADD COLUMNand bareADD;
only ADD (col type) works (measured).
- NVARCHAR ceiling 5000 per column, so no key in the tree overruns it;
sa.Text renders as NCLOB, sa.LargeBinary as BLOB (no size needed).
- Empty string ≠ NULL. Unlike Oracle,
""round-trips as""(LENGTH 0,
CASE WHEN v IS NULL false), so no empty-string sentinel is needed.
- JSON_VALUE with a literal path is available (used by Timestream
dimension filtering); it returned the expected value on both Db2 and HANA.
FROM DUMMYis HANA'sSELECT 1idiom; the probe uses it, notSELECT 1.
15.6 Edge modifiers
VARCHAR(n)is sized in CHARACTERS on both; ASCII values cost 1 byte and
non-ASCII up to 4, so a key column declared near the byte budget is safe for ASCII (every key column here is an AWS-validated ASCII name) and narrower for multibyte values — the value ceiling, not the key, is what rejects them.
Want a live walkthrough or evaluation setup for Offstack? Message George Vranjesevic or reach out at george@developmentsnapshot.com.