TDS FDW Adaptive Server 连接失败,但消息是 "Success"

TDS FDW Adaptive Server connection failing, But message is "Success"

我能够构建 TDS_FDW 并将扩展引入 Postgresql 10。但是,我收到一条异常消息,它失败并显示消息 "Success"。

ERROR: DB-Library error: DB #: 20002, DB Msg: Adaptive Server connection failed (secsql1.secdev.local:1433), OS #: 0, OS Msg: Success, Level: 9

SQL 状态:HV00L

产生错误的代码是:

CREATE EXTENSION tds_fdw;

-- DROP SERVER mssql_acudb_server;
CREATE SERVER mssql_acudb_server
    FOREIGN DATA WRAPPER tds_fdw
    OPTIONS (servername 'wwww', port '1433', database 'AcuDB');

ALTER SERVER mssql_acudb_server
    OPTIONS (ADD msg_handler 'notice');

-- DROP USER MAPPING FOR postgres SERVER mssql_acudb_server;
CREATE USER MAPPING FOR postgres
    SERVER mssql_acudb_server
    OPTIONS (username 'xxxx\yyyy', password 'zzzz');

-- DROP FOREIGN TABLE acudb_project;
CREATE FOREIGN TABLE acudb_project (
    id BIGINT NOT NULL,
    "name" TEXT NOT NULL,
    path_prefix TEXT NOT NULL,
    "type" TEXT NOT NULL,
    sec_active_size BIGINT NULL
)
SERVER mssql_acudb_server 
    OPTIONS (query 'SELECT [id],[name],[path_prefix],[type],[sec_active_size] 
    FROM [projects]');

SELECT * FROM acudb_project

能够通过在 "CREATE SERVER" 语句中指定 freeTDS 的版本来解决此问题:

-- DROP SERVER mssql_acudb_server;
CREATE SERVER mssql_acudb_server
    FOREIGN DATA WRAPPER tds_fdw
    OPTIONS (servername 'www', port '1433', database 'AcuDB', tds_version '7.1');