This is the multi-page printable view of this section.
Blog
- 1: One kernel, many protocols
- 2: Merging four PostgreSQL forks into one kernel
- 3: MySQL compatibility as a PostgreSQL 18 extension
- 4: The kernel patches pg_tde needs and their upstream prospects
These articles cover the versions under study when they were written, including the earlier PG18 and OrioleDB experiments. For the current kernel, extensions and release status, see Mimus 19.0.1 verification .
1 - One kernel, many protocols
Several PostgreSQL forks each teach PostgreSQL one foreign language: openHalo speaks MySQL, Babelfish speaks SQL Server, IvorySQL speaks Oracle. Each is a separate kernel with its own release cycle, its own extension builds and its own users. Mimus asks a simpler question: can one PostgreSQL kernel carry these languages as loadable parts, on the same data, without becoming another fork that nothing else runs on?
In the first week of November 2026 we tried it.
MySQL no longer needs a fork
openHalo 1.0 implemented MySQL compatibility by changing about 320 files of PostgreSQL 14. Porting it to
PostgreSQL 18, we moved everything MySQL-specific into one extension, aux_mysql, and kept a small generic kernel
patch: 12 files that let an extension listen on another port and drive a regular backend. The patch knows nothing
about MySQL. It changes no catalog, no parse node and no function signature, and stock PGDG builds of PostGIS,
pgvector, Citus, TimescaleDB and pg_cron load unchanged. The same patch applied to PostgreSQL 19rc1 with one
conflict.
That result became OpenHalo 18 . An adversarial review then found real defects in the ported code, so it is a development preview, not a release. The architecture held up; the details need work.
Not every protocol belongs in the kernel
MySQL and SQL Server are session protocols: one connection, one session, one backend process. Redis, etcd and S3 are different. Their clients open thousands of connections and keep watches and subscriptions open. PostgreSQL’s process-per-connection model is the wrong place to terminate them. pgredis, pgetcd and pgsilo therefore put the data model in an extension or schema and terminate the protocol in a gateway that multiplexes connections. They run on stock PostgreSQL, and they join Mimus through packaging, configuration and shared operations, not kernel changes.
So the kernel opens exactly one door, for session protocols. See Architecture .
The hard part is ABI, not code
We merged Percona’s storage patches, OrioleDB and Babelfish onto one PostgreSQL 18.6 tree and loaded MySQL, TDS,
OrioleDB and pg_tde in one instance. Every suite passed. Running is not the problem.
Binary compatibility is. Babelfish changes parse-node layouts and renumbers node tags; OrioleDB reorders the table access method interface. With either in the kernel, stock extension packages crash or fail, and every extension has to be rebuilt for Mimus. That turns Mimus into a separate major version in every build matrix.
Hence the plan in the roadmap :
- Mimus 1 keeps PostgreSQL’s ABI: the protocol hook plus Percona’s storage patches. MySQL, Redis, etcd and S3, with the existing extension packages.
- Mimus 2 adds SQL Server and accepts its own ABI and build matrix.
- OrioleDB stays a separate flavor until upstream PostgreSQL offers the interfaces it needs.
What we have not proven
The promise of Mimus is that a MySQL or SQL Server client can use what PostgreSQL extensions provide: PostGIS geometry, pgvector search, Citus distribution. Nobody has tested that yet. Unified authentication across five credential schemes, behaviour during failover, and the cost of the protocol hook are open too. Verification status keeps the list.
This site collects what exists and marks what does not. Each protocol section says where its source project stands.
2 - Merging four PostgreSQL forks into one kernel
Several PostgreSQL forks add major server capabilities: Percona Server for PostgreSQL adds storage hooks for pg_tde encryption, OrioleDB adds an index-organized storage engine with undo MVCC, Babelfish adds SQL Server wire and T-SQL support, OpenHalo 18 adds MySQL compatibility, and IvorySQL adds Oracle compatibility. Maintaining a separate kernel binary and extension matrix for each fork multiplies packaging and operational work.
On 2026-11-07, we tested a direct question on PostgreSQL 18.6 (REL_18_6, commit 724edf9b, EL9 aarch64, --enable-debug --enable-cassert): can one PG 18.6 kernel carry all of these patches at once, behave like stock PostgreSQL when nothing is preloaded, and load any combination of extensions on demand?
The experiment gave a sharp answer: getting four of the five forks to compile and run together in one instance was straightforward; keeping binary compatibility (ABI) with the PostgreSQL extension ecosystem was not. That distinction between “it runs” and “it preserves the ABI” is why Mimus ships in two tiers (Unified base research , ABI compatibility ).
Which forks fit into a shared kernel, and why IvorySQL does not
We first profiled each fork’s non-test src/ diff against PG 18.6 (REL_18_6, 2026-08-11):
| Fork / patch set | Revision on PG 18.6 | Non-test src/ diff | New hooks | Structs | Signatures¹ | Catalog / format | Gated² |
|---|---|---|---|---|---|---|---|
| Protocol hook | c4b3cbe | 12 files, +357/−18 | 0 (registry) | 1 (ClientSocket) | 0 | None | 88% |
Percona (pg_tde 2.2.1) | release-18.6.1 (19c3033d) | 41 files, +689/−268 | 0 (registries) | 1 (SMgrRelationData) | 2 (mdcreate, heap_create) | None (WAL encrypted when on) | 76% |
OrioleDB (1.10.2 / b4f9683) | patches18 (cc8c1483) | 212 files, +5,901/−1,504 | 31 | 23 | 25 | 24-byte xl_running_xacts tail; new TOAST vartag | 60% |
| Babelfish 6.2 | BABEL_6_2_STABLE__PG_18_6 (6ba0d062) | 268 files, +14,000/−721 | 143 | 31 | 10 | None (2 kernel GUCs) | 78% |
| IvorySQL 5.6 | IvorySQL_5.6 (74c405c9) | 672 files, +122,216/−3,438 | 11 | 49 + catalogs | 1+ | Alters pg_attribute, pg_class, pg_proc, pg_control; 3 tables; 22 GUCs | 38% |
¹ Parameter-count changes across headers and .c definitions. ² Upper-bound share of added hunks guarded by a hook pointer or dialect switch.
The first four forks keep their bulk in loadable extensions (orioledb ~139k lines, babelfish_extensions ~218k lines, pg_tde ~12k lines, aux_mysql ~83k lines of C/SQL) and do not change catversion or system catalog layouts.
IvorySQL 5.6 is a true kernel fork: it adds columns to pg_attribute (attisinvisible), pg_class (relhasrowid) and pg_proc (3 columns), adds three system tables (pg_package, pg_package_body, pg_force_view), alters pg_control (dbmode, casemode), compiles PL/iSQL (47,750 lines) into the core tree, and scatters 314 compatible_mode / DB_ORACLE branches across 67 kernel files (428 existing files modified). Merging IvorySQL onto the unified tree produced 71 text conflicts across 45 files and would force every cluster into IvorySQL’s catalog format. Mimus keeps IvorySQL as a separate flavor (our 12-file protocol hook applies with 2 context conflicts) and uses orafce for Oracle functions.
Merging the code: 23 text conflicts vs 11 hidden runtime conflicts
Three-way text merge
Merging Percona release-18.6.1, OrioleDB patches18 and Babelfish 6.2 onto PG 18.6 (git merge-tree --merge-base=REL_18_6) produced 23 conflict blocks across 22 files:
- 10 adjacent additions: independent hooks, declarations or struct fields at the same line (
heapam_visibility.c,xact.c,elog.c,transam.h). - 7 expression merges: e.g., OrioleDB passing
bufferby value inheapam.cwhile Babelfish addedrelationtoHeapTupleSatisfiesUpdate(); Percona callingRelationCreateStoragePercona()while Babelfish passed!IsTsqlTableVariable(rel). - 2 constant collisions: OrioleDB’s
PERFORM_DELETION_OF_RELATIONand Babelfish’sPERFORM_DELETION_SKIP_ENRboth used0x0040independency.h(Babelfish moved to0x0080). - 2 AIO registration blocks (
aio.h,aio_callback.c): Percona’s dynamic callback allocator starts at OrioleDB’s first reserved slot.
For MySQL, aux_mysql compiled against Babelfish’s ProtocolExtensionConfig plus a 2-file (+36/−5) delta adding fn_parse_query and PROTOCOL_EXTENSION_FALLTHROUGH, avoiding the 6-file overlap with our 12-file hook.
The 11 compile-time and runtime conflicts git did not see
Running one mode per instance does not avoid cross-fork bugs: all kernel patches stay active in postgres. Static analysis, compilation (--enable-debug --enable-cassert) and runtime tests found 11 hidden conflicts (+30/−10 lines in the kernel, +22/−11 in OrioleDB, +17/−10 in Babelfish’s extensions):
| ID | Stage | Symptom | Root cause and fix |
|---|---|---|---|
H1 | Static scan | trigger.c:6836 compile error | OrioleDB changed afterTriggerAddEvent() from 3 to 5 args; Babelfish passed 3 (NULL, NULL added) |
C1 | Kernel build | 4 -Wint-conversion in trigger.c (GCC ≥ 14 error) | OrioleDB changed trigger tupleid to Datum; Babelfish’s ExecIR*TriggersTSQL passed ItemPointer (updated to Datum) |
C2 | Extension build | Babelfish forjson.c fails (-Werror) | OrioleDB defined TABLE_SIZE in tableam.h, colliding with forjson.c (renamed in Babelfish) |
R1 | Runtime (pg_tde + OrioleDB) | OrioleDB CREATE TABLE fails with pg_tde | pg_tde disables RelationCreateStorage(); updated 3 OrioleDB calls to RelationCreateStoragePercona() |
R2 | Runtime (OrioleDB + Babelfish) | T-SQL CREATE TABLE on orioledb fails (SI ID: -7) | Babelfish’s SIMessageIsForTempTable() errored on OrioleDB (-7) and PG 18 (-6) invalidation IDs (return false) |
R3 | Runtime (OrioleDB alone) | Every OrioleDB DROP TABLE fails (missing entries in o_indices), even without Babelfish | Babelfish’s RemoveRelations() called InvokeObjectDropHook early whenever object_access_hook was set, making OrioleDB delete index entries twice. Added pre_drop_relation_hook |
R4 | Runtime (OrioleDB + Babelfish) | T-SQL error cleanup hits Assert("DoLocalLockExist(&locktag)") | Babelfish skips locks on ENR tables; OrioleDB’s drop hook asserted a lock on every relation (scoped to OrioleDB tables) |
R5 | Runtime (Babelfish + non-heap) | T-SQL @table and #temp fail (OID 2601 in ENR) on tde_heap or orioledb | Babelfish’s ENR catalog requires heap (unfixed; keep default_table_access_method = heap in Babelfish DBs) |
R6 | Configuration | CREATE EXTENSION pg_tde in Babelfish DB uses information_schema_tsql | First schema on Babelfish’s search_path (specify SCHEMA public) |
R7 | Runtime (aux_mysql + pg_tde) | MySQL ALTER TABLE … ENCRYPTION='Y' wrote plaintext tde_heap | aux_mysql used PROCESS_UTILITY_SUBCOMMAND, skipping pg_tde’s ddl_command_start trigger (switched to PROCESS_UTILITY_QUERY) |
R8 | Configuration (TDS + MySQL) | TDS login fails on scram-sha-256 HBA rules | Babelfish TDS requires md5 or password HBA rules |
R3 shows why static hook-chaining checks are not enough: all four extensions chained ProcessUtility_hook, shmem_request_hook, shmem_startup_hook and object_access_hook properly, yet Babelfish changed when object_access_hook fired inside RemoveRelations(), breaking OrioleDB even without Babelfish loaded.
All four capabilities running in one instance
With those fixes applied on 2026-11-07 (EL9 aarch64, --enable-debug --enable-cassert), one instance preloading orioledb, pg_tde, babelfishpg_tds, aux_mysql listened on ports 5432, 1433 and 3306 simultaneously:
- Regression suites: core PG passed 233/233 and isolation 123/123;
pg_tdepassed 14/14; OrioleDB passed 42/52 (matching the unpatched OrioleDB baseline); T-SQLAFTERandINSTEAD OFtriggers passed onheap,tde_heapandorioledb; andaux_mysqlpassed in full. - Cross-feature DDL and queries: from MySQL on port 3306,
CREATE TABLE ... ENGINE=OrioleDBcreated an OrioleDB table, andCREATE TABLE ... ENCRYPTION='Y'created an encryptedtde_heaptable verified free of plaintext on disk. One SQL query joinedorioledb,tde_heapandheaptables. - Encryption boundary (
pg_tde× OrioleDB):pg_tde.wal_encrypt = onencrypted WAL records for bothtde_heapandorioledbtables inpg_wal/and recovered 6,000 rows per table after an immediate stop. Because OrioleDB bypassessmgr(o_buffers/FileWrite), files underorioledb_data/remained in cleartext.
Why “it runs” is not enough: ABI and extension packages
Building the server and four extensions from source proves source coexistence, not binary compatibility with existing packages.
On 2026-11-07, we ran libabigail’s abidiff against stock PG 18.6 / 18.4 builds with identical configure flags, and tested precompiled PGDG and Pigsty PG 18 packages in each variant (ABI compatibility
, Extension matrix
):
| Kernel variant | abidiff structs | abidiff signatures | NodeTag | Stock PGDG / Pigsty PG 18 packages | Source rebuild against headers |
|---|---|---|---|---|---|
| Protocol hook | 1 (ClientSocket) | 0 | 479 | All 11 C/Rust packages pass ✅ | Not needed |
| Percona 18.4.2 | 1 (SMgrRelationData) | 2 (heap_create, mdcreate) | 479 | All pass ✅ (TimescaleDB 18.4/18.6 diff) | Rebuilds cleanly ✅ |
OrioleDB (patches18) | 23 | 11 changed, 1 removed | 479 | pgvector, VectorChord, vchord_bm25, pg_search, Citus, TimescaleDB crash 💥 | pgvector passes ✅; Citus 14.3, TimescaleDB 2.31, VectorChord fail ❌ |
| Babelfish 6.2 | 31 (FuncExpr, SelectStmt, Port) | 5 | 479 → 480 | Citus crashes 💥; pg_search fails ❌ | Citus, VectorChord (pgrx 0.19.3) rebuild and pass ✅ |
| Merged base | 55 | 31 changed, 1 removed | 479 → 480 | Inherits all crashes and errors 💥 | Fails to compile Citus, TimescaleDB, VectorChord ❌ |
Two mechanisms explain the failures:
- Babelfish shifts parse-node numbers and
Portoffsets: PostgreSQL pins$last_nodetag_no = 479ingen_node_support.plto preserve the stable-branch ABI. Babelfish bumps it to480, shiftingT_OidListfrom472to473. Precompiled C and Rust extensions that check node tags fail at runtime: Citus crashes onlist->type == T_List, andpg_searchfails withPgList does not contain oids. Babelfish also insertsprotocol_configintoPort(shifting 30 fields) and enlargesFuncExpr(+3fields) andSelectStmt(+8fields). Preloadingbabelfishpg_tdsalso alters 2 upstream role regression tests (9 when initialized). - OrioleDB alters access-method structs and signatures: OrioleDB keeps
$last_nodetag_no = 479, but inserts 5 callbacks intoIndexAmRoutine, 6 intoTableAmRoutine, andlastCommittedCSNintoPGPROC. Stock index extensions allocate a smallerIndexAmRoutineand crash onamoptions != NULL. Worse, OrioleDB removestuple_insert_speculative, alterstable_tuple_deleteand changesindex_fetch_tuplefromItemPointertoDatum tupleidplusis_rowid—breaking compilation for Citus columnar, TimescaleDB compression and VectorChord.
Compatibility levels A and B, and the Mimus roadmap
Our ABI study defined two coexistence targets:
- Level B (source compatible): extensions compile without source edits (existing functions and callbacks keep signatures; new features use
*_extfunctions and sidecar tables). - Level A (binary compatible): precompiled PGDG and Pigsty packages load unchanged (all of Level B, plus zero layout changes to public structs: append fields only to kernel-private structs, move new
PGPROC/ReplicationSlotfields into sidecar shared-memory arrays, and keep$last_nodetag_no = 479).
Rewriting OrioleDB’s 23 struct and 11 signature changes to follow the add-only rule was roughly estimated at 2–4 person-weeks for Level B and 2–3 person-months for Level A (rough estimates for an engineer familiar with OrioleDB internals, not commitments, and not yet prototyped; see OrioleDB ). Carrying that rewrite would create a permanent fork unless upstream OrioleDB merged it.
Release cadence reinforces the split. After PG 18.6 shipped on 2026-08-11, Percona rebased in +1 day (2026-08-12), OrioleDB and IvorySQL in +22 days (2026-09-02), and Babelfish in +48 days (2026-09-28). On PG 19rc1, the protocol hook and Percona patches are already rebased, while Babelfish, OrioleDB and IvorySQL have no PG 19 branch yet (PostgreSQL 19
).
Mimus therefore splits its kernel roadmap along the ABI boundary:
- Mimus 1 (Level A, binary compatible): PG 18.x + the 12-file protocol hook + Percona storage patches (with add-only wrappers). It runs MySQL (
aux_mysql),pg_tde, and the Redis, etcd and S3 gateways, loads stock PGDG / Pigsty packages unchanged, and ships with upstream PostgreSQL (~1–2 person-days per minor release). - Mimus 2 (adds SQL Server, independent ABI): adds Babelfish (using Babelfish’s protocol API + the 2-file MySQL delta) and rebuilds its extension matrix against Mimus 2 headers (~3–5 person-days per minor release after Babelfish rebases).
- OrioleDB and IvorySQL: remain separate flavors until upstream PostgreSQL adopts the storage and catalog interfaces they require.
3 - MySQL compatibility as a PostgreSQL 18 extension
openHalo 1.0 taught PostgreSQL 14 to speak the MySQL wire protocol and SQL dialect by modifying roughly 320 files inside the PostgreSQL kernel. When we brought MySQL compatibility to PostgreSQL 18.6, we took a different route: keep a small, protocol-agnostic hook in the kernel and move every line of MySQL wire handling, grammar, parse-tree rewriting and runtime semantics into a loadable extension (aux_mysql).
This note records the design and findings from the 2026-11-07 porting study and the adversarial review of OpenHalo 18
(v18.6, commit 60e7a225). For the current state of fixes and open issues, see MySQL status
.
Why openHalo 1.0 could not simply rebase to PostgreSQL 18
An audit of the openHalo 1.0 tree (v1.0-pg14, commit f9aedb8, closest to upstream REL_14_13 and later merged with REL_14_18) showed why a direct rebase across four major PostgreSQL releases was impractical:
| Area | openHalo 1.0 (v1.0-pg14) | Impact on porting and maintenance |
|---|---|---|
| Kernel diff | ~320 modified files (~12,000 lines changed) plus ~110,000 added lines in src/ | Forked copies of the PG 14 analyzer and executor (mys_gram.y ~24k lines, mys_tablecmds.c ~17k lines) had to be re-forked on every major upgrade |
| Extension ABI | Altered DestReceiver signatures, added a column to pg_proc, set N_ACL_RIGHTS = 14 | Broke binary compatibility with stock PostgreSQL 14 extensions |
| Built-in types | Hardcoded MySQL protocol branches inside bool, float, numeric, varlena and like | Mixed foreign dialect rules into core execution paths |
| Native parser | Modified the core PG parser to accept backticks, "..." strings, \' escapes and DATE(text) | contrib/aux_mysql (~35k lines of SQL + mysm C library) could not install on an unmodified PG parser |
| Legacy remnants | Trimmed from commercial Halo; kept Oracle fields (proaccess), backported MERGE and TDS tags | Extra surface area to untangle against native PG 15–18 features |
Between PostgreSQL 14 and 18, MERGE landed natively, Value nodes became A_Const unions, returningList became ReturningClause, GrantRoleStmt and PartitionStrategy changed, varatt.h split out, and dozens of analyzer and executor signatures shifted. Rebasing 320 scattered kernel files would have produced another isolated fork that could not load PGDG extension packages, and the same cost would recur on PostgreSQL 19. See From openHalo 1.0
.
A 12-file protocol hook and the aux_mysql extension
OpenHalo 18 splits the system into two layers: a generic kernel patch that knows nothing about MySQL, and the aux_mysql extension (contrib/aux_mysql, named halo_mysql in the prototype) that carries all MySQL behavior.
The kernel protocol hook
The protocol hook
(pg18-protocol-hooks.patch, commit c4b3cbe on PostgreSQL 18.6) modifies 12 files (+357/−18 lines, including 181 lines in the new protocol_extension.c and protocol_extension.h). It intercepts only the boundary where a backend talks to its client:
- Listener registration (
postmaster.c,protocol_extension.c):RegisterProtocolExtension()andListenServerPortForProtocol()bind port 3306 in_PG_initand passClientSocket.protocol_idto forked backends. - Startup and authentication (
backend_startup.c,postinit.c):startperforms the foreign handshake and setsMyBackendType = B_BACKEND;authenticatereplacesClientAuthentication()once shared catalogs are readable. - Command loop and client-only parser (
postgres.c):read_commandandprocess_commandrouteCOM_QUERYthroughexec_simple_query()and handle otherCOM_*packets in the extension.parse_queryinsidepg_parse_client_query()replaces the parser only for top-level client queries—SQL function bodies,SPIand extension scripts still usepg_parse_query(). - Output and error reporting (
dest.c,elog.c,guc.c):create_dest_receiver,end_command,null_commandandsend_ready_for_queryencode MySQL result sets andOK/EOFpackets;send_messagemapsSQLSTATEto MySQL error numbers;report_param_statussuppresses libpqParameterStatuspackets.
Because every MySQL connection is a standard PostgreSQL backend, max_connections, pg_stat_activity, pg_hba.conf, query cancellation and secure_open_server() TLS (ssl_*, hostssl, pg_stat_ssl) work out of the box. Native libpq connections pay only a MyProtocolExtension == NULL check.
Moving MySQL semantics out of the kernel
To leave PostgreSQL’s analyzer, planner, executor and system catalogs untouched, aux_mysql combines four mechanisms (How it works
):
- Scripted grammar and SQL porting:
tools/port_grammar.pyrewrites openHalo’s ~29,500-linemys_gram.yandmys_scan.lto emit PG 18 parse nodes.tools/port_aux_sql.pytranslates openHalo’s 35,000-lineaux_mysqlSQL catalog (~1,800 functions, ~500 operators, ~180 tables/views, ~70 types) into standard PostgreSQL syntax. - Raw parse-tree rewriting (
mys_rewrite.c): the grammar emits out-of-core enum tags (AT_ModifyColumn,CONSTR_AUTOINC,ONCONFLICT_REPLACE). Beforepg_analyze_and_rewrite(),mys_rewrite.ctranslates them into identity columns,ON CONFLICTclauses,@user/@@systemfunction calls andCOLLATE mysql.case_insensitiveclauses. - DDL utility hook (
mys_utility.c):ProcessUtility_hookhandles MySQLALTER TABLE ... MODIFY / CHANGE / ADD INDEX / DROP PRIMARY KEY,SHOW,USE <schema>andENGINE=/ENCRYPTION='Y'access-method mapping. - Authentication, prepared statements and transactions (
mys_auth.c,mys_stmt.c,mys_txn.c): ~3,400 lines of new C code implement MySQL 8’s defaultcaching_sha2_password(shared-memory fast-auth cache plus TLS or RSA-OAEP full auth verified againstpg_authid.rolpasswordSCRAM/MD5 verifiers),COM_STMT_*binary prepared statements, autocommit, implicit DDL commits and savepoint-based statement rollback—without changing a line of the 12-file kernel patch.
ABI preservation and cross-kernel portability
Keeping dialect semantics out of the kernel preserves binary compatibility with existing extensions. On 2026-11-07 (EL9 aarch64, --enable-debug --enable-cassert), abidiff compared the protocol hook against other multi-dialect PG 18 forks:
| Kernel | Non-test src/ diff | abidiff changes | NodeTag | Stock PG 18 packages |
|---|---|---|---|---|
Protocol hook (pg18-protocol-hooks) | 12 files, +357/−18 | 1 internal struct (ClientSocket +8B), 0 signatures | 479 | All 11 C/Rust packages pass |
| Babelfish 6.2 (PG 18.6) | 277 files, +14,057/−734 | 31 structs (FuncExpr, SelectStmt, Port), 5 signatures | 479 → 480 | Citus crashes; pg_search fails |
| IvorySQL 5.6 (PG 18.6) | 2,782 files, +887,695/−5,188 | 49 structs + pg_attribute, pg_class, pg_proc columns | Changed | Incompatible without rebuild |
| openHalo 1.0 (PG 14) | ~320 files + ~110k added lines | DestReceiver, pg_proc, N_ACL_RIGHTS | — | Incompatible with stock PG 14 |
The protocol hook changes no parse node, no catalog table and no exported function signature. Its only structure change appends int protocol_id to ClientSocket in src/include/libpq/libpq-be.h (sizeof(ClientSocket) grows from 144 to 152 bytes), a structure passed only between postmaster.c, launch_backend.c and backend_startup.c. Stock PGDG and Pigsty PG 18 packages—PostGIS 3.6, pgvector 0.8, Citus 14.3, TimescaleDB 2.31, pg_cron, orafce, VectorChord, vchord_bm25, pg_search, pg_graphql and pgs3—loaded and passed smoke tests unchanged (ABI compatibility
, Extension matrix
).
On 2026-11-07 (EL9 aarch64, --enable-debug --enable-cassert), the hook and extension also ported across five other PostgreSQL trees (On other kernels
, PostgreSQL 19
):
- OrioleDB (
patches18_4on PG 18.6) and Percona Server for PG 18.4.2: 0 conflicts. MappingENGINE=OrioleDBtoorioledbandENCRYPTION='Y'topg_tde’stde_heapexposed a cross-extension bug:pg_tdedecides whether a new file is encrypted in addl_command_startevent trigger, whereasaux_mysqlran decomposedALTER TABLEcommands withPROCESS_UTILITY_SUBCOMMAND, skipping event triggers and writingALTER TABLE ... ENCRYPTION='Y'files in cleartext. Switchingmys_utility.ctoPROCESS_UTILITY_QUERYfixed the bypass. - IvorySQL 5.6 (PG 18.6): 2 context conflicts. After dropping
aux_mysql’s unusedsysschema, keeping existingvarchar → bigintcasts and combiningshared_preload_libraries, one instance served Oracle (1521), MySQL (3317) and PostgreSQL (5443). - Babelfish 6.2 (PG 18.6): adapted to Babelfish’s
ProtocolExtensionConfigwith a 2-file (+36/−5) delta (fn_parse_query,PROTOCOL_EXTENSION_FALLTHROUGH). - PostgreSQL
19rc1: 1 conflict inbackend_startup.c(ProcessStartupPacket()dropped two arguments); the19rc1kernel passed 239/239 regression tests, whileaux_mysqlhad 47 compile errors from PG 19 API changes.
What the adversarial review found in v18.6
On 2026-11-07, an adversarial review evaluated OpenHalo 18 tag v18.6 (60e7a225, OpenHalo layer c380da3) against stock PG 18.6 and openHalo 1.0 (v1.0-pg14 / f9aedb8) on EL9.8 aarch64 (--enable-debug --enable-cassert --with-openssl --with-icu).
While core PG make check (231/231), isolation (122/122) and the check-world SQL subset (688/688) passed and standard drivers (Connector/J 8.4.0, go-sql-driver v1.9.3, PyMySQL v1.1.1, mysql CLI, sysbench 1.0.20) connected, the review rejected v18.6 as a stable release baseline, identifying 11 Category A product blockers and 3 verification/documentation gates:
| ID | Finding in v18.6 (60e7a225) | Origin vs 1.0 (f9aedb8) |
|---|---|---|
F01 | ALTER TABLE ... AUTO_INCREMENT on a partitioned parent table triggers SIGSEGV in table_is_empty and resets all sessions | 18 crash regression (1.0 did not crash, though start value had no effect) |
F02 | AUTO_INCREMENT high-water mark moves backwards when is_called=false or via UPDATE-only mysql.setval() | 18 regression (1.0 generated 100 and kept last_value = 100) |
F03 | Concurrent nextval + explicit ID inserts deadlock (1213) when sequence_advance upgrades to ExclusiveLock | 18 regression (1.0 committed both transactions) |
F04a | Default aux_mysql setup worker races with pg_dump restores and perturbs pg_visibility TAP tests | 18 new integration defect (1.0 installed manually) |
F05 | CREATE TABLE ... LIKE omits the AUTO_INCREMENT sync trigger, causing duplicate keys after explicit inserts | 18 regression |
F06a | SHOW CREATE TABLE emits literal \n and omits AUTO_INCREMENT (SHOW COLUMNS omits Extra) | 18 regression |
F07 | UNSIGNED AUTO_INCREMENT drops the unsigned domain without a non-negative CHECK, accepting -1 | 18 regression (1.0 rejected -1) |
F09a | ALTER TABLE ... ADD COLUMN without COLLATE forces table_ci = true on binary tables | 18 regression |
F11 | BLOB / VARBINARY binary parameters (0x00, 0x80, 0xff) fail UTF-8 validation | 18 regression |
F13 | COM_STMT_EXECUTE reports decimals = 0 for DATETIME(3) and DATETIME(6), truncating fractional seconds | 18 new protocol defect (1.0 failed during Prepare) |
N01 | COM_RESET_CONNECTION returns OK without rolling back open transactions or clearing @user variables | 18 regression on rollback and user variables |
G01–G03 | tests/run.sh ignores errors in m1–m4 and sysbench; docs overstate “zero ABI change” (ClientSocket 144 → 152B); check-world times out (RC=124) | 18 verification and doc gates |
Comparison against openHalo 1.0 also separated Category B findings: 18 regressions in single-statement ALTER auto-increment start values (F08), missing ENUM/SET (F10), CHAR(n) trailing spaces (F12), negative TIME (N02), FLOAT wire type 5 (N03) and missing SHOW WARNINGS (N04); new 18 integration gaps in Meson builds (F14) and mysql.max_allowed_packet (F16a); and issues inherited from 1.0 (NO_BACKSLASH_ESCAPES status bit F15, SHOW CREATE omitting ON UPDATE F06b, and 1.0.14.18 version string blocking pg_upgrade N05).
In external suites on v18.6, go-sql-driver v1.9.3 passed 49/72 server tests (21 failed, 2 skipped), PyMySQL v1.1.1 passed 123/175 (39 failed, 12 skipped, 1 xfail), and sysbench 1.0.20 ignored 42 and 264 errors in read-write and write-only runs. Clearing the Category A blockers and gates was roughly estimated at 20–35 person-days (rough estimate, not a commitment).
Takeaways
The 2026-11-07 study and review established two conclusions:
- The architectural boundary holds. MySQL compatibility does not need a 320-file kernel fork; a 12-file protocol hook runs the MySQL protocol, parser and runtime inside an extension while keeping PostgreSQL 18’s extension ABI intact.
- OpenHalo 18
v18.6is a development preview. Replacing forked kernel code with parse-tree rewrites, triggers and new wire protocol routines introduced defects in sequence monotonicity, DDL round-trips, binary parameters and connection reset.
Local commits have since addressed the Category A blockers and several Category B gaps. Follow the current status in MySQL status and MySQL compatibility .
4 - The kernel patches pg_tde needs and their upstream prospects
Percona’s pg_tde extension implements transparent data encryption (TDE) for PostgreSQL heap tables, indexes and WAL. An early community mode (tde_heap_basic, which left indexes in cleartext) was deprecated in March 2025 and removed from pg_tde 2.2.x. Running pg_tde on PostgreSQL 18 therefore requires the kernel patch set in Percona Server for PostgreSQL (PSP_REL_18_STABLE).
On 2026-11-07, we audited that patch set against stock PG 18.4, PG 19rc1 and PG 20 master, and traced every related thread on pgsql-hackers and the Commitfest. This post records our findings and conclusions for Mimus (Storage patches for pg_tde
).
Statements below are sourced facts (with commit hashes or links) unless labeled Inference. Items searched for in archives and Commitfests without finding a primary source are labeled Not found.
The 650-line patch set in four parts
Comparing Percona Server for PostgreSQL release-18.4.2 (commit be009d6) against stock PG 18.4—and cross-checking the 20 Percona commits on PSP_REL_18_STABLE
(release-18.6.1, commit 19c3033d) and PSP_REL_19_STABLE
(rebased onto 19rc1 on 2026-10-14)—shows that the kernel changes under src/ touch 35 files (+650/−252 lines), plus build files, 6 contrib modules and test outputs. (src/include/libpq/libpq-be.h is not touched by Percona; that 1-line change belongs to the Mimus protocol hook
.)
| Part | Kernel changes in src/ | How pg_tde 2.2.2 uses it | Stock ABI effect (abidiff) | Percona commits (PSP_REL_18_STABLE) |
|---|---|---|---|---|
1. Extensible smgr registry | Moves f_smgr to storage/smgr.h with name; replaces static smgrsw[] with smgr_register(const f_smgr *, Size); adds SMgrId (uint8) and storage_manager_id; moves md_num_open_segs and md_seg_fds from SMgrRelationData into MdSMgrRelationData; calls register_builtin_dynamic_managers() | Registers tde (RegisterStorageMgr) and overrides storage_manager_id globally, wrapping md in extend, writev, readv, startreadv, create and unlink. Singleton only (FATAL if another custom smgr exists) | 1 struct layout change: SMgrRelationData drops trailing md fields and narrows smgr_which to uint8 (pincount and node shift; earlier fields keep offsets) | 6469142723, c8317c82a1, 937fca1f3c, b476c8b8af |
| 2. Encryption context on create | Adds old_rlocator to mdcreate(), f_smgr.smgr_create and heap_create(); adds smgrcreate_percona(), RelationCreateStoragePercona() and index_create_percona(); updates ~20 callers; guards RelationCreateStorage(), smgrcreate() and index_create() with percona_allow_upstream_smgr_api | tde_mdcreate() sets ENCRYPT or PLAIN inside DDL captured by pg_tde’s ProcessUtility_hook and ddl_command_start event trigger, or RETAIN (inheriting from old_rlocator) during VACUUM FULL, CLUSTER, TRUNCATE, SET TABLESPACE and REINDEX CONCURRENTLY. Sets percona_allow_upstream_smgr_api = false | 2 signature changes: heap_create() and mdcreate(). Runtime behavior: when pg_tde is loaded, legacy wrapper callers fail with ERROR (TimescaleDB, Citus columnar, unpatched OrioleDB) | c204e46359, 9bd71a588a, 9c0ac6d6cf (PERCONA_API_VERSION = 3) |
| 3. Extensible AIO callbacks | Makes aio_handle_cbs[] writable with PGAIO_HCB_MAX = 15 (4 built-in, 11 extension); adds pgaio_io_register_callback_entry(); drops const from aio_md_readv_cb; exports md_readv_complete() | PG 18 routes most reads through AIO (smgr_startreadv). tde_mdstartreadv() stores the key by I/O handle and registers PGAIO_HCB_TDE_READV; tde_readv_complete() decrypts pages between md and bufmgr callbacks | Zero struct or signature changes (aio_md_readv_cb drops const) | 2324a66872, 2a839c1a45 |
4. WAL segment I/O (XLogSmgr) | Adds access/xlog_smgr.h (XLogSmgr { seg_read, seg_write }, xlog_smgr, SetXLogSmgr()); routes XLogWrite, XLogFileCopy, WALRead, XLogPageRead and XLogWalRcvWrite through xlog_smgr | pg_tde_xlog_smgr.c calls SetXLogSmgr() to encrypt/decrypt WAL segments page by page (plus archive/restore helpers). Key-event WAL records use PG 15’s standard RegisterCustomRmgr() (5c279a6d35), needing no patch | Pure addition | 9f59910142 |
5. Version guard and contrib | Adds PERCONA_API_VERSION and check_percona_api_version(); updates 6 contrib modules (amcheck, pageinspect, pg_surgery, pgrowlocks, pgstattuple) to check rd_tableam == GetHeapamTableAmRoutine() | Refuses mismatched kernels and lets diagnostic tools inspect tde_heap tables | Pure addition | 6a7608d7ca, e10d4168c6, 85dbb5d11d, 03d9d932f7, 1d44de57fe, 19c3033dc4 |
How Percona’s branch relates to Commitfest #5616
Upstream Commitfest #5616: Extensible storage manager API
(v6 posted on 2026-02-04
by Percona’s Zsolt Parragi) contains 6 patches: 0001 (f_smgr exposure and global override), 0002 (checkpoint_create_hook), 0003 (fsync_checker test module), 0004 (mdcreate old RelFileLocator), 0005 (smgr_chain GUC) and 0006 (extensible AIO callbacks).
Inference (from matching patch filenames and commit subjects, without a line-by-line diff of v6): parts 1, 3 and the mdcreate portion of part 2 share the same origin as CF #5616, whereas the ~20-caller heap_create / index_create plumbing, PERCONA_API_VERSION = 3 wrappers and XLogSmgr exist only in Percona’s repository and have never been submitted upstream. Conversely, v6’s smgr_chain GUC and checkpoint_create_hook are not in Percona’s branch.
Ten years of upstream TDE and extensible smgr discussions
Upstream PostgreSQL has debated two approaches to encryption: building TDE into core, or opening storage hooks for extensions.
In-core TDE attempts (2016–2025)
- 2016–2019: Ants Aasma (Cybertec) posted the first cluster-level AES-XTS patch in 2016 (thread ). Moon Insung (NTT) and Masahiko Sawada proposed table-level TDE and KMS in May 2018 (thread ), followed in 2019 by buffer-encryption prototypes from Sawada and Antonin Houska (patch , wiki ).
- December 2020 KMS commit and revert: Bruce Momjian committed internal KMS on 2020-12-25 (
978f869b99) and reverted it two days later (3187ef7c46) after Tom Lane and Michael Paquier reported issues and missing tests (thread ). In January 2021, Momjian noted the lack of consensus and stopped work (thread ); onlyRelationIsPermanent()landed in PG 14 (95d77149c5). - 2021–2025: Robert Haas proposed storing a page nonce in May 2021 (thread
). David Christensen (Crunchy Data) and Stephen Frost revived the KMS/TDE series in October 2022 (thread
): CF #3985
was returned with feedback in February 2024 after Andres Freund asked to split the heap-encryption patch, and post-special page storage (CF #3986
) stalled in
Waiting on Authorin January 2025.
Extensible smgr proposals (2021–2026)
- 2021–2024: Anastasia Lubennikova proposed
smgrhooks in June 2021 (CF #3216 , thread ), closed in March 2022 after 6 months of inactivity. In June 2023, Matthias van de Meent (Neon) posted “SMGR hook Redux” (CF #4428 , thread ), which closed in October 2024 after six Commitfests. - 2025–2026 (CF #5616
): Andreas Karlsson (Percona) posted v3 and v4 in February–March 2025, and Zsolt Parragi posted v5 and v6 in January–February 2026 (v6 email
), adding extensible AIO callbacks and
pg_smgrstat. As of 2026-11-07, #5616 remains in the closedPG19-FinalCommitfest inNeeds review, with no committer, CFBot red since 2026-03-09, and not moved into any PG 20 Commitfest.
The late-2025 and 2026 shift toward unified in-core TDE
- December 2025 I/O hooks RFC: When Henson Choi proposed five I/O hooks and 5 reserved
pd_flagsbits (thread ), Zsolt Parragi replied on 2025-12-30 that Neon, Nile and Percona had run thesmgrpatch in production since 2023, while Percona had held back its WAL hook because it was unsure the design belonged in core. - May 2026 PGConf.dev: Percona, EDB and Cybertec held a joint session (“Stop Debating, Start Implementing: Unifying TDE Efforts for Postgres”; Highgo recap , IvorySQL recap ) on authenticated encryption, WAL design, key management and LSN-as-IV concerns.
- July 2026 WAL encryption benchmarks: On 2026-07-16
(follow-up 2026-07-20
), Zsolt Parragi showed that AES-CTR-256 page-level WAL encryption inside the WAL write lock critical section was up to ~20% slower on write-heavy workloads (plus ~20% higher recovery CPU), whereas record-level encryption matched
master. He announced plans to submit an in-core record-level TDE proposal within weeks. Not found: as of 2026-11-07, no such proposal appeared onpgsql-hackersor inPG20-3/PG20-4.
Inference: Percona’s upstream strategy shifted in mid-2026 from purely seeking extension hooks to co-designing in-core TDE (at least for WAL). If in-core WAL encryption succeeds, pg_tde’s XLogSmgr hook will be superseded by a core feature rather than merged as an extension API.
Committer feedback and upstream preconditions
Across all threads examined on 2026-11-07, direct committer feedback on extensible storage and TDE includes:
- Andres Freund: Gave the only direct committer review on the
smgrregistration thread on 2023-07-01 : register inBaseInit()rather thanPostmasterMain(); avoid extra indirection onsmgrsw[]by using a fixed-limit static table; questionpg_compiler_barrier(); and explain whysmgrrelation_sizewas stored per entry. In the PG 18 AIO commits (da7226993f,50cb7505b3), he noted inaio.hthat extensible callback IDs work if every process re-registers callbacks in the same order underEXEC_BACKEND, and that completion callbacks must not allocate memory or start new I/O. - Tomas Vondra: On 2025-12-28 and 12-30
, opposed reserving
pd_flagsbits for extensions, questioned ad-hoc I/O hooks that must be maintained forever, and argued thatsmgritself should be improved if needed. - Bruce Momjian, Tom Lane and Robert Haas: Momjian noted in April 2026
that
pg_tderequires a patched fork. Not found: any direct messages from Heikki Linnakangas, Robert Haas or Tom Lane on the two extensiblesmgrthreads, or primary verification of a 2020 export-control remark attributed to Tom Lane in pgEdge’s May 2026 article .
Inference: For extensible smgr (#5616
) to land upstream, six preconditions must align: (1) a storage/AIO committer claiming the patch; (2) addressing Freund’s fixed-size table and BaseInit() points; (3) a clean redo story (v6 sidesteps per-relation lookup during recovery via global override / smgr_chain); (4) multiple consumers beyond TDE (Neon, Nile, Percona, pg_smgrstat); (5) strict compliance with the AIO + EXEC_BACKEND contract; and (6) an active rebase with green CI.
Outlook for PostgreSQL 19, 20 and 21+, and what Mimus will do
Upstream outlook by release
- PostgreSQL 19 (fact: absent):
19rc1shipped on 2026-10-15 andPG19-Finalclosed in April 2026. In19rc1,smgr.h,md.h,catalog/storage.h,catalog/heap.handstorage/aio.hdiffer from 18.4 only in copyright years,smgrsw[]is stillstatic const,xlog.cstill callspg_pwrite()directly, andrelease-19.sgmlcontains only two AIO tuning commits (a9ee668817,d1c01b79d4). See PostgreSQL 19 . - PostgreSQL 20 (inference: low overall likelihood before the April 2027 freeze): As of 2026-11-04,
masterhas no extensiblesmgror AIO callback commits, and neitherPG20-3norPG20-4lists ansmgror TDE entry (only the adjacent CF #6689: Extensible sync handler registration insync.c).
| Component | PG 20 likelihood (Inference) | Basis |
|---|---|---|
1. smgr registration (#5616
0001) | Low | Unmerged after 5 years and 3 CF entries; no committer; CFBot red for 7+ months; not in PG 20 CF |
3. AIO callback registration (v6-0006) | Low to medium | Small (~20 lines) and anticipated in aio.h, but tied to part 1 |
2. Old RelFileLocator on create (v6-0004 + #156) | Low | TDE-specific rewrite context; touches heap_create / index_create |
4. XLogSmgr WAL segment hook | Very low | Never submitted; Percona’s July 2026 benchmark favors in-core record-level WAL encryption |
| In-core TDE | Very low (for PG 20) | No patch posted as of 2026-11-07; multi-vendor consensus takes multiple cycles |
- PostgreSQL 21+ (inference): Either the community pursues in-core TDE (replacing
XLogSmgrwith core record-level WAL encryption and requiring data migration frompg_tde) or it merges extensible storage points (#5616 , shrinking Mimus’s patch set). Neither path will settle before 2027.
How Mimus carries the patches
Carrying Percona’s ~650-line patch set costs a rough estimate of 1–2 person-days per minor release (rough estimate, not a commitment) and merges with the Mimus protocol hook with 0 conflicts. Mimus 1 therefore includes the storage patches in PostgreSQL 18 and 19, split into four patch files (smgr-registry, smgr-create-context, aio-callback-registry, wal-io-hook) so each piece can be retired independently.
Based on source analysis on 2026-11-07 (Inference / design judgment, not yet prototyped), Mimus 1 can also rewrite Percona’s 3 abidiff changes into zero ABI changes so precompiled PGDG packages stay 100% binary-compatible (Storage patches for pg_tde
, ABI compatibility
):
SMgrRelationData: keep themdfields andint smgr_whichin place and append customsmgrprivate fields at the end.mdcreate()andheap_create(): restore stockmdcreate()andheap_create()signatures as wrappers and addmdcreate_ext()andheap_create_ext()withold_rlocator(matchingindex_create_percona()).*_perconasymbols and version guard: keepRelationCreateStoragePercona,smgrcreate_percona,index_create_perconaandpercona_api_versionexported forpg_tde, and document the runtime guard (percona_allow_upstream_smgr_api) whenpg_tdeis loaded.