<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Christian Riesen &#187; FreeTDS</title>
	<atom:link href="http://christianriesen.com/tag/freetds/feed/" rel="self" type="application/rss+xml" />
	<link>http://christianriesen.com</link>
	<description>Life and work in the information and communication age</description>
	<lastBuildDate>Thu, 29 Dec 2011 17:52:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>MS SQL Blob truncated</title>
		<link>http://christianriesen.com/2010/07/ms-sql-blob-truncated/</link>
		<comments>http://christianriesen.com/2010/07/ms-sql-blob-truncated/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 10:39:53 +0000</pubDate>
		<dc:creator>Christian Riesen</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Blob]]></category>
		<category><![CDATA[FreeTDS]]></category>
		<category><![CDATA[Images]]></category>
		<category><![CDATA[MS SQL]]></category>

		<guid isPermaLink="false">http://christianriesen.com/?p=212</guid>
		<description><![CDATA[There are times when I wish I had a third hand, just so I could to a triple face palm. This is one of those times.

I'm accessing a blob in a MS SQL database that is pretty much nothing more than a JPG dumped straight into the field. I read them and echo them ...]]></description>
			<content:encoded><![CDATA[<p>There are times when I wish I had a third hand, just so I could to a triple face palm. This is one of those times.</p>
<p>I&#8217;m accessing a blob in a MS SQL database that is pretty much nothing more than a JPG dumped straight into the field. I read them and echo them with a jpg header in PHP. All is well. The script runs and parses all the images, doing some caching magic with them. The result is that about a third of the images are broken, seemingly random. Mostly they just &#8220;stop&#8221; at a random spot over the whole set, but in one image it always stops at the same spot.</p>
<p>I suspected data corruption on input and a refresh on what inserts them in the first place worked, sometimes at least.</p>
<p>Digging down, I saw that the result I get back for the broken images is always 64512 bytes, exactly. That&#8217;s 2 to the power of 16. Can&#8217;t be a coincidence. Turns out, it isn&#8217;t.</p>
<p>I&#8217;m using freetds to access the database and there is an entry in freetds.conf that reads something like this:<br />
text size = 64512</p>
<p>Upping that number (and restarting the webserver, apache or IIS) did the trick. The images stored in the database were all around that point, so it looked like a random bug, but thankfully it wasn&#8217;t random.</p>
<p>If you don&#8217;t use freetds but the mssql extension instead, then this line would be of interest:<br />
mssql.textsize = 4096</p>
<p>Yes the default is only 4 kilobytes.</p>
<p>Maybe the desk will work as a third hand for the triple face palm.</p>
<p class="wp-flattr-button"></p> <p><a href="http://christianriesen.com/?flattrss_redirect&amp;id=212&amp;md5=542976ad1acaf4ac41050fcc69085fa7" title="Flattr" target="_blank"><img src="http://christianriesen.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://christianriesen.com/2010/07/ms-sql-blob-truncated/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

