FreeTDS tweak for truncated responses

I use the FreeTDS drivers so that my Rails app can talk to SqlServer. I’ve been running into strange problems where I’m expecting a large XML response from a service to be saved in my database. Although the save operation completes successfully, the XML response is truncated.

The reason for this can be found in the /etc/freetds/freetds.conf file. If you simply appended your own DSN details to the default config file, you will see the following near the top of the file:

..
..
# If you get out-of-memory errors, it may mean that your client
# is trying to allocate a huge buffer for a TEXT field.
# Try setting 'text size' to a more reasonable limit
text size = 64512
..
..

The important line is the text size. This setting imposes a size limit on database text fields the driver sends and receives between your database and your app. I’m getting XML responses far bigger than 64K so simply commenting out that line solves my truncation issue.

Make you config file look like this:

..
..
# If you get out-of-memory errors, it may mean that your client
# is trying to allocate a huge buffer for a TEXT field.
# Try setting 'text size' to a more reasonable limit
# text size = 64512
..
..

Simples.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s