Query the Babelfish version running on your ApsaraDB RDS for PostgreSQL instance using either the Tabular Data Stream (TDS) port or the PostgreSQL port.
Prerequisites
Before you begin, ensure that you have:
An ApsaraDB RDS for PostgreSQL instance with Babelfish enabled. For more information, see Enable Babelfish for an ApsaraDB RDS for PostgreSQL instance.
A Babelfish account. For more information, see Create a Babelfish account to connect to an ApsaraDB RDS for PostgreSQL instance with Babelfish enabled.
An IP address whitelist configured to allow your client to access the RDS instance. For more information, see Configure an IP address whitelist for an ApsaraDB RDS for PostgreSQL instance.
The endpoints and TDS port of your RDS instance. For more information, see View the endpoints and TDS port.
sqlcmd and psql installed on your client.
Query over the TDS port
Use sqlcmd to connect over the TDS port (1433) and run three queries: one to confirm the connection is a Babelfish connection, one to get the Babelfish version number, and one to get full version details.
Connect to the RDS instance over the TDS port.
sqlcmd -S pgm-****.pg.rds.aliyuncs.com,1433 -U babelfish_userConfirm that you are connected to a Babelfish instance, not a native SQL Server instance.
SELECT CAST(serverproperty('babelfish') AS BIT) AS is_run_on_babelfish; GOExpected output:
is_run_on_babelfish ------------------- 1 (1 rows affected)Get the Babelfish version number.
SELECT CAST(serverproperty('babelfishversion') AS VARCHAR(5)) as babelfish_version; GOExpected output:
babelfish_version ----------------- 1.2.0 (1 rows affected)Get full version details, including the PostgreSQL version and the SQL Server compatibility level.
SELECT @@version as version; GOExpected output:
version ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Babelfish for PostgreSQL with SQL Server Compatibility - 12.0.2000.8 PostgreSQL 13.6 (1 rows affected)
Query over the PostgreSQL port
Use psql to connect over the PostgreSQL port (5432) and retrieve the Babelfish version, PostgreSQL version, and SQL Server compatibility level in a single query.
Connect to the RDS instance over the PostgreSQL port.
psql -h pgm-****.pg.rds.aliyuncs.com -p 5432 -U babelfish_user -d babelfish_dbQuery all three version dimensions at once.
SELECT version() as postgresql_version, sys.version() as babelfish_compatibility, sys.SERVERPROPERTY('BabelfishVersion') as babelfish_Version;Expected output:
postgresql_version | babelfish_compatibility | babelfish_version --------------------+----------------------------------------------------------------------+------------------- PostgreSQL 13.6 | Babelfish for PostgreSQL with SQL Server Compatibility - 12.0.2000.8+| 1.2.0 | PostgreSQL 13.6 | (1 row)