0

I have created this foreign SQL Server using tds_fdw foreign data wrapper:

CREATE SERVER servprod_sqlprod_mydb
FOREIGN DATA WRAPPER tds_fdw 
OPTIONS (servername 'XX.XX.XX.XX', port '1501',msg_handler 'notice', database 'WHATEVER');

CREATE USER MAPPING FOR postgres
    SERVER servprod_sqlprod_mydb
    OPTIONS (username 'xxx', password 'xxxxxxxxxx');



CREATE FOREIGN TABLE tds_test (
    caclamun character varying,
    caclacal character varying,
    catipvia character varying,
    cadescri character varying,
    caidenti character varying,
    cafechal character varying,
    cafechba character varying)
    SERVER servprod_sqlprod_mydb
    OPTIONS (table_name 'dbo.MYSQL TABLE');

When opening the table I am getting:

'utf-8' codec can't decode byte 0xd1 in position 4: invalid continuation byte

I think it is a postgresql issue and not tds_fdw's, but I am not sure.

  • the error message suggests that the source is not returning UTF-8 data, maybe delete rows from the table (or use a copy of the table) until the problem goes away. – Jasen Jun 17 at 3:07
  • @Jasen I tried with different tables and it works...I don't know how to bypass this issue.. – Egidi Jun 17 at 13:30
0

I fixed the problem adding character_set 'UTF-8' when creating foreign server. Example:

CREATE SERVER myserver 
FOREIGN DATA WRAPPER tds_fdw 
OPTIONS (servername 'localhost', port '1501',msg_handler 'notice', database 'mydb', character_set 'UTF-8');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.