1

I set up several tds_fdw foreign tables on a Postgres 13 server accessing a MSSQL 2014 server. Everything has worked just fine, until I had a need to select from a table with a large column (nvarchar(max) on MSSQL side, text on Postgres side).

If the text length is <= 2048 chars, then I get all the text, and if the text is longer, then it gets truncated to 2048 cahrs.

I tried to select the large text occurrences with tsql (the FreeTDS test utility), and it does return all the text, even with 14825 chars, for example.

I found an old post on tds_fdw GitHub issues which had to deal with a problem that "long strings and long byte arrays are truncated to 64512 chars/bytes" (https://github.com/tds-fdw/tds_fdw/issues/40). Now, if I could fetch 64512 chars, that would be enough and a spare in my case.

Any ideas of what is restricting the text size?

  • PostgreSQL version: 13.4-4.pgdg110+1 (Debian);
  • postgresql-13-tds-fdw: 2.0.2-2.pgdg110+1;
  • libsybdb5: 1.2.3-1;
  • freetds-common: 1.2.3-1.

/etc/freetds/freetds.conf has all the defaults:

[global]
        # TDS protocol version
        tds version = auto

        # Whether to write a TDSDUMP file for diagnostic purposes
        # (setting this to /tmp is insecure on a multi-user system)
;       dump file = /tmp/freetds.log
;       debug flags = 0xffff

        # Command and connection timeouts
;       timeout = 10
;       connect timeout = 10

        # To reduce data sent from server for BLOBs (like TEXT or
        # IMAGE) try setting 'text size' to a reasonable limit
;       text size = 64512

        # If you experience TLS handshake errors and are using openssl,
        # try adjusting the cipher list (don't surround in double or single quotes)
        # openssl ciphers = HIGH:!SSLv2:!aNULL:-DH

# A typical Sybase server
[egServer50]
        host = symachine.domain.com
        port = 5000
        tds version = 5.0

# A typical Microsoft server
[egServer73]
        host = ntmachine.domain.com
        port = 1433
        tds version = 7.3

Your Answer

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

Browse other questions tagged or ask your own question.