freetdssqsh

sqsh gives "dsp_desc_bind: Memory allocation failure for column #1"


On Ubuntu 18.04 with freetds 1.00.82-2 and sqsh 2.1.7-4build1, I get the following when trying to SELECT foo FROM bar where foo is an nvarchar column:

dsp_desc_bind: Memory allocation failure for column #1

Why does this happen? I see some ancient bug reports, but I can't see any solutions there; this error message is quite ungooglable.


Solution

  • I tried downgrading freetds to 0.91.6, which I had working on Ubuntu 17.10, and then got the more understandable error message

    Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier.

    which led me to the solution:

    Edit /etc/freetds/freetds.conf and add a section

    [YourDbHostname]
          host = localhost
          port = 1433
          tds version = 8.0
    

    Now it works :)

    EDIT: Seems like sqsh-2.5.16.1 ignores this file now? Another solution is to just use the -G argument, e.g. sqsh -G 8.0 -i foo.sql