This is the multi-page printable view of this section.
SQL Server
- 1: Install and initialize
- 2: First TDS connection
- 3: Databases, schemas and roles
- 4: T-SQL and client compatibility
- 5: Create encrypted permanent tables over TDS
- 6: Temporary tables, table variables and plaintext on disk
- 7: Migration and operations
- 8: Known limits and troubleshooting
Mimus 19.0.1 implements SQL Server compatibility with Babelfish for PostgreSQL. SQL Server clients connect to a PostgreSQL backend over Tabular Data Stream (TDS, default TCP port 1433) and submit T-SQL. The DBA uses a native PostgreSQL connection (default 5432) to initialize Babelfish, inspect the physical tables and back up the cluster.
Start with one table
On Rocky Linux 10.3 x86-64, FreeTDS 1.5.18 logged in to master, inserted two rows and read back a sum of 42. A PostgreSQL connection saw the same rows in wire.master_dbo (database and schema). Deploy TDS on its own Mimus instance if the application also uses MySQL. Follow installation and initialization and your first TDS connection to repeat the check.
| What you need to decide | Where to look |
|---|---|
| Which logical database, schema and login should an application use? | Database, schema and role mapping |
| Will my driver, stored procedures and transactions work? | T-SQL and client compatibility |
| How do I move data, back it up and verify recovery? | Migration and operations |
| How do I create an encrypted table over TDS and verify its indexes and large values? | Create encrypted permanent tables over TDS |
| My procedure uses both encrypted and temporary tables. What can reach disk in plaintext? | Temporary tables, table variables and plaintext on disk |
| How do I diagnose a failed login, import or restore? | Known limits and troubleshooting |
What the version identifies
Mimus is based on PostgreSQL REL_19_0. Patch 400 imports the Babelfish kernel changes. Patch 401 ports them to PG19 and integrates the protocol handlers. The frozen nine-patch baseline has kernel tree e94b1957f077 and Babelfish extension tree 7ae1f519a130. The earlier connection and source-build examples in this manual used kernel tree 98c4dca860f0. The encrypted-table and temporary-object guides use candidate image a3b80a5a99a1 with additional patches. Check the kernel and extension trees together when identifying a build. Candidate build manifest
Upstream credit
Babelfish for PostgreSQL comes from Amazon Web Services and the Babelfish and PostgreSQL contributors. Its extensions are available under Apache-2.0 or the PostgreSQL License. The monetary type derives from EDB / 2ndQuadrant’s fixeddecimal. The modified PostgreSQL kernel carries the PostgreSQL License. Upstream extensions and notices · Upstream kernel
For additional T-SQL and migration reference, consult the PG.CENTER Babelfish manual.
1 - Install and initialize
Check the installation
Use a Linux installation of the matching Mimus kernel and extensions. The PostgreSQL 19 version string alone cannot identify the patched ABI. If building from source, compile the complete kernel with ICU, OpenSSL, libxml2 and libuuid support, install its contrib/uuid-ossp, then build the four Babelfish modules against that installation’s pg_config and its matching PG_SRC. The T-SQL parser uses Java, CMake and the ANTLR 4.13.2 C++ runtime. The isolated upstream port and the Mimus build use different TDS interfaces. Upstream build dependencies
| Extension | SQL version | What it installs or provides |
|---|---|---|
babelfishpg_common | 7.0.0 | SQL Server types, casts and collations in sys. Its control file declares no extension dependencies, but its monetary functions load the money shared library. |
babelfishpg_tsql | 7.0.0 | T-SQL parser, procedural language, functions, system catalogs and initialization. Requires babelfishpg_common and uuid-ossp. |
babelfishpg_tds | 1.0.0 | TDS listener, login and packets. Preload the library at startup, then create the SQL extension in the target database. Requires babelfishpg_tsql. |
babelfishpg_money | 1.1.0 | Standalone fixed-decimal monetary extension. The tested installation creates it explicitly, outside the TDS dependency chain. |
Start an empty instance
These commands assume a fresh, isolated Linux host or container with ports 5432 and 1433 available. In the shell, run as the OS account postgres. Put the Mimus bin directory first in PATH. Keep this shell for the rest of the guide so PGHOST selects the private Unix socket. The final command should report server started.
Configure the target through psql
Connect to the PostgreSQL endpoint as cluster superuser postgres. In the listing below, the first line opens interactive psql. Run the SQL and backslash commands at its prompt. Enter a new password twice at \password and keep it for the TDS login.
Expect ALTER SYSTEM, CREATE ROLE, CREATE DATABASE and ALTER DATABASE. The bbf_admin login owns the physical database and becomes the initial T-SQL administrator. The example ran with rolsuper = false. Give applications their own logins and database users. The preload list here is for an empty instance. On a configured cluster, retain its existing required libraries when adding babelfishpg_tds.
As the OS account postgres, put this entry before the general host rules in $PGDATA/pg_hba.conf. The database field is the physical database wire. This password-only, loopback rule is for the local exercise. For a remote client use TLS with certificate validation.
Restart this instance as its OS owner. Restart loads the TDS library and binds the ports. A reload alone cannot apply either change. A fresh connection to wire also picks up its database-level migration mode. Choose the mode before initialization. Mapping in each mode
Initialize the physical database once
In the new psql session as PG superuser postgres in wire, run the following commands. The three settings should read babelfishpg_tds, wire and single-db. The installation setting applies only to this session. CASCADE installs the three declared dependencies. The final query should list the four versions above plus uuid-ossp 1.1.
CALL creates cluster roles and the built-in logical databases master, tempdb and msdb. Its argument must name the physical database owner. Once it succeeds, connect using bbf_admin on the TDS port. First TDS connection · Upstream initialization procedure
Build from paired source checkouts
The two tree checks here reproduce the earlier connection example. For the TDS encryption guides, use the paired sources with the kernel, Babelfish and pg_tde increments. Identify the four-change candidate
If the server and modules are already installed, start at the empty instance. Otherwise run this in a build-user shell with writable, clean checkouts of the indicated trees and a fresh install prefix. Replace all three paths. Install the development dependencies above plus GNU make, a C/C++17 toolchain, Bison, Flex and the ANTLR runtime under /usr/local first. The tree checks exit silently on a match. At the end, the prefix contains the server, PGXS and extension files. Make that prefix and the runtime libraries accessible to the server OS account.
2 - First TDS connection
Log in and write two rows
After initialization, run this in the local client shell. FreeTDS tsql prompts for bbf_admin’s password. -H and -p select the TCP endpoint. -D master selects a logical database at login. The 1> prompt means the client accepts a new batch.
Enter the following at the tsql prompt in the fresh example database. GO on its own line sends the batch. exit returns to the shell. Expect master, followed by n = 2 and total = 42. Use an application database for real tables. Here master makes the example reproducible immediately after initialization.
From the same shell as the OS account postgres, check the rows through native psql. Expect wire | 2 | 42. The TDS session wrote to dbo in logical master. PostgreSQL sees the table in physical schema master_dbo.
Address, authentication and client settings
| Parameter | Behavior in this build |
|---|---|
| Server address and port | The TDS bind code reads PostgreSQL listen_addresses. Although babelfishpg_tds.listen_addresses is registered, setting it alone does not restrict this listener. babelfishpg_tds.port defaults to 1433. Restart for a binding change. |
| Database and user | HBA matches the physical babelfishpg_tsql.database_name, source address and login. The driver sends the logical database (JDBC databaseName). HBA uses the first matching rule. Reload changes and reconnect. Check both IPv4 and IPv6 when using hostnames. |
| Password login | The password and md5 HBA branches verify the password from LOGIN7 against the PG role’s stored verifier, including SCRAM verifiers. A scram-sha-256 HBA method is rejected. trust skips verification. Use TLS for network password logins. |
| Integrated login | The gss path needs a GSS-enabled build and working Kerberos credentials. NTLMSSP is rejected. SSPI as an HBA method, peer, ident, LDAP, PAM, BSD and certificate login are unsupported in the TDS handler. OAuth login returns an authentication error. The exercised login used a password. |
| Wire version and packets | The server default babelfishpg_tds.tds_default_protocol_version = DEFAULT follows the client. The configured choices run through TDS 7.4. The walkthrough uses 7.4. Default packet size is 4096 bytes. A nonzero client request must be 512–32767 bytes and sizes are rounded down to a multiple of four. The server answers the MARS option with zero. Use separate connections for overlapping active results. |
Upstream TDS listener · Login and PRELOGIN handling · TDS settings
Verify TLS on the actual session
Use an OpenSSL-enabled Mimus build. As the server OS owner, install the server certificate and private key, readable by PostgreSQL with the usual private-key permissions. The certificate must cover the hostname the client uses. For this example it covers localhost. Configure the server in postgresql.conf as follows.
The TDS minimum and maximum default to TLSv1 and TLSv1.2. TLS 1.3 is outside the TDS version selector. The TLS and encryption parameters are registered for reload, but the extension builds its TLS context at server startup. Restart after configuring the certificate, key or protocol bounds and establish a new session. With server SSL active, tds_ssl_encrypt = on requires full-session encryption in PRELOGIN. With the default off, a client can request full encryption, login-only encryption or no encryption according to its capabilities. The switch alone cannot supply a missing TLS context.
Replace the local exercise’s HBA line with hostssl wire bbf_admin 127.0.0.1/32 password for this IPv4-only endpoint. For remote operation, scope it to the actual client address, bind the service to the intended interface and exclude plaintext fallback rules for that login. On the client, put this profile in freetds.conf and substitute the path to the issuing CA.
Connect as bbf_admin. In the example the server is bound to 127.0.0.1. The client reaches it as localhost and checks that hostname against its certificate.
At the tsql prompt run this query. The verified FreeTDS 1.5.18 session returned 1 | TLSv1.2. With Microsoft JDBC the corresponding client settings for full encryption and certificate validation are encrypt=true and trustServerCertificate=false, with a trusted issuing CA and matching hostname. The JDBC bulk-write test used a separate loopback configuration.
3 - Databases, schemas and roles
Choose the mapping before initialization
One PostgreSQL cluster hosts one initialized Babelfish physical database, selected by babelfishpg_tsql.database_name. All TDS connections enter that database. The login packet and T-SQL USE select a logical database inside it. Thus the HBA entry and psql -d name wire, while the driver names master or a user database such as sales.
| At the TDS endpoint | Native PG schema in single-db | Native PG schema in multi-db |
|---|---|---|
master.dbo | master_dbo | master_dbo |
tempdb.dbo / msdb.dbo | tempdb_dbo / msdb_dbo | tempdb_dbo / msdb_dbo |
sales.dbo | dbo | sales_dbo |
sales.billing | billing | sales_billing |
single-db admits one user database in addition to the built-ins. Choose multi-db when several user databases need separate namespaces in one physical database. Each mode above was initialized in a fresh instance. FreeTDS created sales.dbo.orders and read one row in both. Changing the parameter after initialization would leave existing names and metadata in the old layout. To change layouts, provision a fresh target and migrate the application objects and data.
Look up a name from PostgreSQL
At the TDS endpoint, dbo.mimus_probe is a two-part name relative to the current database. master.dbo.mimus_probe specifies all three parts. At the native endpoint, connect to wire and qualify the physical schema. Shared schemas have special rules (for example, T-SQL INFORMATION_SCHEMA maps to information_schema_tsql). Long physical identifiers can be shortened with a hash. Read the mapping catalog when writing native reports or grants. Upstream schema and user mapping
In native psql, connected as postgres to the initialized wire, this query returns master | dbo | master_dbo. Change the filter to inspect a user schema.
Separate logins from database users
A server login authenticates the connection. A logical database user supplies the identity for grants in that database. Use the TDS endpoint for CREATE LOGIN, CREATE USER … FOR LOGIN, role membership, and ALTER LOGIN or DROP LOGIN. Grant the application’s database user access to the specific schema and objects it needs. Use sys.server_principals and sys.database_principals to inspect the two scopes. Use native PG tools for native roles.
The initializer checks the physical owner and reserves cluster-wide roles, including sysadmin, bbf_role_admin and the built-in databases’ guest roles. On an earlier integrated PG19 build with this same TDS extension, native superusers could be managed before and after initialization, in both the initialized physical database and the ordinary postgres database. A real TDS login remained protected against a native DROP ROLE in both databases. Mimus distinguishes actual guest-role membership from the implicit privileges of a PG superuser. Create a separate PG database for an unrelated application if needed. The roles still belong to the cluster. Upstream ownership catalogs
4 - T-SQL and client compatibility
Which client operation was tested?
| Client or API | Observed result | What to check for an application |
|---|---|---|
FreeTDS 1.5.18 tsql, TDS 7.4 | On the matching Rocky x86-64 build, password login, logical database selection, table DDL, two-row DML, a procedure call and TLS 1.2 worked. | Run the actual result sets and parameter types through the driver used in production. |
Microsoft JDBC 8.2.2.jre8 SQLServerBulkCopy | On a preceding integrated PG19 build with the same Babelfish extension tree, two integers reached an encrypted table. PG read 2 and 40. The bulk test used databaseName=master;encrypt=false on loopback. | Check server-side row counts and values. Re-test with the deployed JDBC version, TLS settings and real column types. |
FreeTDS 1.3.17 freebcp | On the standalone PG19 port and upstream beta, the utility reported two rows copied. The server rejected the bulk packet and stored zero. | Reconcile counts on the target. Use the exercised JDBC bulk path or parameterized inserts after testing them with the application. |
sqlcmd, SSMS, .NET SqlClient, ODBC and Python drivers | Upstream documents SQL Server clients. There is no complete application or driver-suite result for these tools on this Mimus build. | Check prepared RPCs, output parameters, result-set metadata, connection pooling and reset, cancellation and reconnect with the exact client version. |
Procedures and batches
In FreeTDS tsql as bbf_admin in master, after the two-row example, submit the definition and invocation as separate batches. The integer parameter 1 returned amount = 40 and return status 0. This exercises a T-SQL call sent as a SQL batch. Driver RPC calls, output parameters and multiple results take additional client paths.
For procedures using temporary objects, inventory each @table and #temp, including those in nested procedures. Compare success, error and rollback paths with the source application. Use a separate batch for each procedure definition and let the client consume GO. Drivers executing SQL strings generally need the caller to split batches.
The default escape hatches for index clustering and storage options are ignore. A migrated PRIMARY KEY CLUSTERED or filegroup clause can parse without reproducing SQL Server’s physical layout. Check the resulting indexes and query plans. Procedures that rely on equivalent locking or placement need a separate design. Upstream T-SQL settings
Types, text comparison and views
| Case | Observed behavior | Migration decision |
|---|---|---|
| Fractional time | On the earlier four-component tree, the nanosecond part of CAST('2000-01-01T12:34:56.1234567' AS datetime2(7)) was 123457000. SQL Server’s type can represent 100 ns. | If the seventh digit orders events or distinguishes keys, retain the source ticks in an integer or exact numeric column. |
ISNULL in a persisted view | On an earlier integrated build, with a nullable varchar(3) column and a varchar(6) replacement, the ISNULL view column kept the first input’s type modifier. COALESCE had no length modifier. A concatenated TDS query returned abcdef/abcdef for the NULL row. SQL Server documents possible truncation to the first argument’s type. | Specify the required result width explicitly. Check the returned value and the metadata through the application driver. |
| Collations and trailing spaces | The default server collation is sql_latin1_general_cp1_ci_as. In a PG19 comparison, native text under sys.bbf_unicode_cp1_ci_as and sys.bbf_unicode_cp1_cs_as agreed with matching ICU controls. Case differed between CI and CS. Both distinguished a trailing space. T-SQL varchar equality ignored the trailing space. | Replay joins, unique keys and orderings with case, accents, composed characters and trailing spaces. Carry the intended type and collation into native queries. |
| Numeric, monetary, binary and identifier types | The extensions supply SQL Server types and conversions, including money, uniqueidentifier, datetimeoffset and sql_variant. The integer bulk-copy result covers none of their wire encodings. | Round-trip decimal scale, Unicode, raw bytes, offsets, NULLs and the base type of variant values through the intended import path. |
TOP … PERCENT views | Four earlier PG19 TDS view cases returned 5, 7, 4 and 3 rows. They covered plain selection, unions and values. | Compare your view’s ordering and ties on real rows before relying on the selected subset. |
SQL Server datetime2 · SQL Server ISNULL · Upstream Babelfish data types
Transactions and temporary objects
In the PG19 integrated heap tests, each object started with 7. An explicit transaction added 4 and rolled back. The batch-local @table retained both rows (sum 11). A local #temp, SELECT INTO #temp and a persistent table each returned 7. A new batch also ends a table variable’s scope. Code that needs data in subsequent batches should choose its object and connection lifetime accordingly. The default encrypted access method changes whether these objects can be created. T-SQL temporary-object settings and storage
In a PG19 three-protocol concurrency test at READ COMMITTED, a TDS update waited on a locked integer primary key. An in-place change committed by the lock holder yielded one updated row. A committed delete and reinsert with the same key yielded zero for the waiting TDS update, even though the replacement row existed. The result held on heap and tde_heap. Compare @@ROWCOUNT and retry logic under the SQL Server application’s actual isolation settings. The concurrency run had no SQL Server reference instance. PostgreSQL transaction isolation
5 - Create encrypted permanent tables over TDS
A SQL Server client can create an encrypted permanent table on Mimus with an ordinary CREATE TABLE. The DBA supplies the key and the creation default. Applications then use their usual INSERT, UPDATE and SELECT. A migration can also select encryption for a single transaction. This guide covers the 19.0.1 candidate with the four accepted changes, tested over TDS 7.4 on Debian 13 x86-64 image a3b80a5a99a1. Identify the build and patches
Prepare the key in the physical database
Start with an initialized Babelfish instance. The PG administrator uses psql to connect to physical database mimus on port 5432. The TDS client connects to logical database vault on port 1433. The example assumes deployment login lab_deploy maps to a user with permission to create tables in vault. Preload pg_tde and babelfishpg_tds, and install the pg_tde extension in public in the physical database. Instance initialization · Login and schema mapping
For a new test database, run the following on PG. First create /var/lib/mimus-keys outside PGDATA on the server, owned by the database service account with mode 0700. A database with a principal key already configured can use its existing key. Both the production and recovery systems need access to the same keys. Key providers and recovery
Create encrypted tables by default with ordinary T-SQL
If the application uses temporary tables, the PG administrator can give runtime connections the heap default and require encryption on the deployment login with tde_heap. These settings take effect on new physical connections. Recycle the affected connections in any pool.
Reconnect to vault as lab_deploy and send the following TDS batch. The first query shows the logical database and the login’s effective default. An application login granted DML privileges on the resulting table can read and write it with its own default set to heap.
Expect vault, tde_heap and a final value of paid. To require every application table to go through encrypted deployment, reserve permanent DDL privileges for the deployment login and grant the runtime login only the DML privileges it needs. A login with permission to create tables can override the AM default when enforcement is off.
For a physical database dedicated to encrypted tables, the PG administrator can apply both settings at database scope. New tables default to encryption and requests for heap are rejected. The settings apply across the logical databases mapped into that physical database. Existing plaintext tables require a separate rewrite. Use the mixed configuration above for connections that need T-SQL temporary objects. Convert an existing table · Settings for temporary objects
Select one table in a mixed database
On a deployment connection with default heap and enforcement off, create dbo.chosen in a dedicated transaction. Turn implicit transactions off, finish any open transaction, and send the complete script as one TDS batch. The same file is installed in the image at /usr/mimus-19/share/mimus/examples/tds-encrypted-table.sql. Download the tested deployment script
After BEGIN TRANSACTION, the script calls this PostgreSQL configuration function over TDS. The 'true' argument limits the setting to the transaction. Other tables created in that transaction inherit the same setting. Commit or rollback restores the connection’s previous default.
The script locates the table through sys.tables and sys.schemas. It commits once the table, primary-key index, unique index, TOAST table and TOAST index are all present and encrypted. An open transaction or implicit transactions turned on yields error 50000 at entry, leaving the caller in control of its transaction. A missing or plaintext member rolls back the deployment with error 51001. Adapt both the table name and the expected indexes when using the script for another schema.
Verify the physical storage from PG
After deployment, run this query as the PG administrator in mimus. In the example’s single-db mapping, vault.dbo maps to PG schema dbo. Substitute dbo.invoice for dbo.chosen to check the role-default example. For another mapping, look up the physical schema first. Look up a schema
Both sample tables should return five rows, all with encrypted true. The table and TOAST table use tde_heap. The three indexes use btree. During acceptance a 32,018-byte varchar(max) value in dbo.chosen occupied 17 TOAST chunks. After a restart, a new TDS connection read the same digest and committed an update visible to the next connection.
Migrate SQL Server TDE scripts
SQL Server protects its database encryption key (DEK) with a certificate or asymmetric key and enables TDE with ALTER DATABASE … SET ENCRYPTION ON. On Mimus, manage the provider and principal key through PG, check each physical relation, and configure WAL encryption separately. A TDS CREATE TABLE with WITH (ENCRYPTION=ON) or OFF fails before creating the table. SQL Server certificate and DEK commands and sys.dm_database_encryption_keys cannot manage or verify pg_tde storage. Microsoft’s TDE reference · WAL encryption on Mimus
6 - Temporary tables, table variables and plaintext on disk
A runtime login with heap and enforcement off can read and write encrypted permanent tables and use table variables, # tables and SELECT INTO # on the same TDS connection. The Mimus 19.0.1 candidate with the four accepted changes allows these temporary objects to reach disk in plaintext. Copying a row from an encrypted permanent table to a temporary table can put a plaintext copy in a file. Deploy encrypted permanent tables
Choose settings for the runtime login
The PG administrator can set these values for the runtime login in physical database mimus. Reconnect over TDS to logical database vault. A runtime login that already inherits heap/off needs no override. The deployment login can use tde_heap and enforcement independently.
Check the effective values on the actual TDS connection, especially when using a pool.
| Effective table AM at creation | Enforcement | All three T-SQL temporary objects |
|---|---|---|
heap | off | Creation succeeds. Temporary relations use ordinary heap storage. |
tde_heap | off or on | Creation fails with Unexpected catalog OID 2601 referenced in ENR. The Babelfish private temporary catalog cannot record the dependency on pg_am. There is no automatic fallback to heap. |
heap | on | pg_tde enforcement rejects creation of plaintext relations. |
Under the mixed configuration a login with permanent DDL privileges can create plaintext application tables. To require encryption for every permanent table, reserve permanent DDL for the encrypted deployment login and grant the runtime login only its application DML privileges. Deployment and runtime privileges
What survives a rollback?
On a fresh heap/off connection, send the table-variable example below as one batch. Insert 7, add 4 inside a transaction, then roll back. The sum is 11. The equivalent operation on each of the two other temporary objects returns 7.
| Object | Opening statements in a separate batch | Sum after rollback |
|---|---|---|
| Table variable | DECLARE @t TABLE(id int); INSERT INTO @t VALUES (7); | 11. Both rows are visible for the rest of the batch. |
| Local temporary table | CREATE TABLE #t(id int); INSERT INTO #t VALUES (7); | 7. The second insert rolled back. |
Temporary SELECT INTO | SELECT CAST(7 AS int) AS id INTO #s; | 7. The second insert rolled back. |
The release and assertion builds of the four-change candidate passed these cases. The same connection could execute the next statement after a constraint error handled with TRY/CATCH. A cursor still holding an inner # table could read its original rows after the procedure returned, while a new table with the same name held the caller’s own data. Scope and reference handling
Where temporary data reaches disk
| Destination | What a file can contain |
|---|---|
Heap relations for @t, #t and SELECT INTO #t | All three can contain plaintext row data. In a separate storage test, each object received 20,000 rows. Each of the three relation files on the mounted filesystem contained its own test value. |
| Query work files | A PG sort of an encrypted permanent table produced a 4,710,400-byte spill file containing the plaintext test value. The table’s pg_tde key does not cover this file. |
The product accepts these plaintext writes. Supporting tde_heap for the temporary relations would require protecting their access method across rollback, scope exit and final file cleanup. Executor spills such as sorts have a separate write path. These costs and the limited coverage are why temporary objects use heap in this build. pg_tde encryption limits
If the deployment must protect offline media, a tested setup placed all of PGDATA on a LUKS2 volume, used the default temporary tablespace and disabled swap for the service container. The markers were absent from the underlying volume. Readers with filesystem access could see plaintext on the unlocked mount. Cover the actual volumes for temporary relations and query spills when extra tablespaces are in use, and account for swap. This build cannot satisfy a requirement that these files themselves remain encrypted on the mounted filesystem. SQL Server automatically encrypts tempdb when a user database uses TDE, so check that expectation when migrating. Microsoft’s TDE and tempdb reference
7 - Migration and operations
Move a SQL Server application
- For a source supplied as a SQL Server .bak file, restore it in SQL Server first. Export the application DDL, including procedures, triggers, logins, users and grants. Inventory SQL generated by the driver as well. Babelfish Compass can flag constructs for review. Validate the flagged paths and the application’s own queries on the matching Mimus build. Babelfish migration guide
- Choose the mapping mode and collation for the target. Create the user database and its principals through TDS. Replay the DDL in dependency order. For a procedure, check the result sets, types and return status the caller consumes. Review ignored or rewritten clauses individually before accepting a successful import.
- Copy a representative batch with the intended driver. Compare counts by primary-key range, NULL counts, totals and values that can round or truncate. Check identity/sequence state for the next insert. Compare rows through TDS and native PG using the physical schema mapping.
- Rehearse cutover at a consistent point. Stop source writes or capture and apply outstanding changes. Run the application under its normal login, check transactions and reconcile both sides before redirecting writers. Retain the source and record how to reconcile any writes accepted after cutover.
Choose the instance boundary
Run TDS alongside native PostgreSQL. Give MySQL a separate instance and data directory, including when the two applications use different logical databases. Each instance shares preloads, roles and startup requirements across its databases. Connection architecture
An earlier two-node research run loaded both dialects, TDE and Spock on Rocky x86-64. FreeTDS and PyMySQL exchanged rows in a predefined encrypted table. Use that result as evidence for the tested storage and replication path. Choose each deployment’s listener independently. Database mapping · Spock replication
Back up the cluster and prove it can restart
Record the kernel tree, extension versions, shared_preload_libraries and SHOW mimus_required_features with the backup. Installing a Babelfish component records a cluster dependency. Restore with the matching kernel and babelfishpg_tds available at startup. When using TDE, preserve the original key providers and all keys needed for the backup and WAL.
On an earlier integrated PG19 build, JDBC wrote values 2 and 40 into a persistent encrypted table. VACUUM FULL rewrote its file. With plaintext WAL throughout, a streaming physical backup passed verification. With the source stopped and the original keys available, the restored instance served both rows over PG and TDS (sum 42) and PG confirmed encryption. When WAL is or may have been encrypted, use the matching Percona streaming backup tool in encrypted mode (pg_tde_basebackup -E -Fp -X stream). Recover to a separate data directory and read the committed rows through both endpoints. PG TDE manual · Percona backup and restore
Logical archives and upgrades
With the two-row example in place, run the Mimus client tools in the OS postgres shell, on the same PG socket. Use a new directory for the archive. pg_dump connects to the physical database. pg_restore -l reads the local archive. In the recorded pre-header-fix run the listing contained BABELFISHCHECKS and TABLE DATA master_dbo mimus_probe.
For a logical database selection, the Mimus tools recognize --bbf-database-name. One logical database dump omits server logins. Inventory globals, database users, their mappings and grants separately. The tested archive listing proves export. Independent restoration of a complete Babelfish logical database, including principals, ownership, procedures and correct TDS reads, still awaits acceptance on the final artifacts. Treat an archive as recoverable only after restoring and reconciling it on a separate instance. Upstream dump selection and checks
The dump embeds checks for equal PostgreSQL server_version_num and equal Babelfish migration mode on restore. A different minor version can therefore fail as well. There is no validated in-place cross-major Babelfish upgrade for this release. The bundled pg_upgrade also refuses a TDE-marked source or destination, including its precheck. For a version or layout change, build a new target, recreate compatible application DDL and principals, and move application data through a verified export/import path. Reconcile it before retiring the original. A same-PG19 binary change or a physical backup restored with its original binaries has different prerequisites.
8 - Known limits and troubleshooting
The PG port works, but the TDS client cannot log in
| Symptom | What to check | Action |
|---|---|---|
| Connection refused, or the client sees a protocol error immediately | psql speaks PG. tsql speaks TDS. The sockets use different ports. | In native psql as the DBA, inspect SHOW shared_preload_libraries, SHOW listen_addresses and SHOW babelfishpg_tds.port. Check the startup log for a bind failure. After changing the listener, restart and connect to the TDS port explicitly. |
unsupported TDS authentication | A broader HBA entry may select scram-sha-256. localhost can resolve to ::1 and miss an IPv4-only rule. | Inspect the server-reported database, role and source address. Match the physical database and the correct subnet with a supported HBA method. Put that rule first, reload and reconnect. |
| Login succeeds only with certificate validation disabled | The CA may be missing, or the client may use a name absent from the certificate. A stricter driver may also request an unsupported protocol version. | Install the issuing CA on the client, use the certificate hostname and verify the negotiated TLS version on the same session. Tested TLS settings |
| Initialization reports a reserved role or says the supplied login is not the owner | Initialization creates cluster roles and checks the physical database owner. The same cluster may already host an initialized Babelfish database. | Inspect the owner and existing roles in PG. Connect to the intended physical database. Use the existing mapping or start a fresh cluster when an independent mapping is needed. Preserve roles already in use. |
| The application connects but cannot find a table | The driver may have selected master, or a native query may be using a logical schema name. | Check DB_NAME() on TDS and current_database() on PG. Look up the catalog mapping and check the database user’s grants. Name lookup |
Permanent tables work, temporary objects fail
With an effective default of tde_heap, all three T-SQL temporary objects fail at creation. The 2601 in Unexpected catalog OID 2601 referenced in ENR identifies pg_am. On the actual TDS connection, check both default_table_access_method and pg_tde.enforce_encryption. Use heap/off for a runtime login that needs temporary objects and recycle its physical pool connections. All three objects then work, and their data can reach disk in plaintext. Runtime settings and rollback results
A deployment login can create encrypted permanent tables over TDS, or select tde_heap in a dedicated transaction and verify the resulting storage. The runtime login can then read and write them with ordinary T-SQL. Deploy and verify encrypted permanent tables
A session disappears during inspection or a mixed batch
Earlier assertion builds recorded a backend exit during storage inspection of a live T-SQL temporary object, including a table-variable case with default heap. Other connections were interrupted during server reinitialization. Ordinary heap DML and rollback have separate successful results. Keep storage diagnostics on persistent relations. After such a disconnect, inspect the server log and restart history, reconnect and verify the last committed transaction before replaying work.
The four-change candidate corrects statement and cursor reference release and the cleanup of a private scope still in use. Its release and assertion builds passed the transaction, error-handling and cursor cases. The historical records still lack direct evidence of the first incorrect release. Fix scope and build identity
In a separate isolated 19.0.1 FreeTDS run, an additional batch sequence involving a nullable string view and temporary objects ended with a client write error. The output did not establish the failing statement or a server crash. Check client messages and server logs together. Qualify the exact result-set shape and transaction used by the application. Covered procedure and type cases
An import reports success but rows are missing
One freebcp version counted client-side rows while the server reported a bulk-packet length error. SQL batch clients can also report success at process exit after a server error. Inspect server diagnostics, then query target counts and stable key/value totals from a new connection. Reconcile what was committed before retrying a partially applied batch. Driver versions and bulk results
A login cannot be dropped, or the restored server refuses to start
A native PG session is expected to refuse removal of a genuine Babelfish login. Manage that login through TDS. If an ordinary native superuser is misclassified, check that the deployed TDS module matches the 19.0.1 extension tree.
If startup reports a missing Babelfish requirement, restore the matching kernel, module files and preload configuration. Keep the feature marker and any TDE keys with the cluster. A logical archive rejected for a different PG version or migration mode needs a compatible target or an application-level migration. Backup and upgrade conditions