我能够构建TDS_FDW并将扩展引入Postgresql 10。但是,我收到一条不寻常的消息,即它失败并显示"成功"消息。
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 'xxxxyyyy', 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
通过在"创建服务器"语句中指定 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');