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