{"id":249,"date":"2011-06-05T12:28:41","date_gmt":"2011-06-05T12:28:41","guid":{"rendered":"http:\/\/www.sitekickr.com\/blog\/?p=249"},"modified":"2011-06-05T12:28:55","modified_gmt":"2011-06-05T12:28:55","slug":"mysql-astext-returns-blob","status":"publish","type":"post","link":"https:\/\/www.sitekickr.com\/blog\/mysql-astext-returns-blob\/","title":{"rendered":"MySQL AsText returns BLOB"},"content":{"rendered":"<p>I&#39;ve seen many posts regarding this issue, but most point to a bug in MySQL 5.0, resolved in 5.1. This may be true, although I&#39;m running 5.1 find that <em><strong>AsText<\/strong><\/em> returns a BLOB. When I had this issue with group_concat, I found it was related to a mysql directive in my.conf, called <a href=\"http:\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/server-system-variables.html#sysvar_group_concat_max_len\">group_concat_max_len<\/a>, but I couldn&#39;t find any related directive for this issue.<\/p>\n<p>My resolve was to simply <em><strong>cast<\/strong><\/em> the result as a <strong>CHAR<\/strong>.<\/p>\n<p><code>Select Cast( AsText( Envelope( the_polygon ) ) AS char ) as the_polygon<\/code><\/p>\n<p>Result:<\/p>\n<p>POLYGON((0 0,200 0,200 200,0 200,0 0))<\/p>\n<p>&nbsp;<\/p>\n<p>This may be a little off topic, but I&#39;m assuming that most folks using <em><strong>AsText<\/strong><\/em> are interested in MySQL&#39;s spatial extensions. I have yet to find a built-in function to return a given point in a <em><strong>Polygon<\/strong><\/em>. While <em><strong>pointN()<\/strong><\/em> will work for <em><strong>LineString<\/strong><\/em>, there doesn&#39;t seem to be a <em><strong>Polygon<\/strong><\/em> equivalent.<\/p>\n<p>Using a pseudo-code example, I suppose the best method for doing these would be in your scripting language:<\/p>\n<p><code><kbd>the_polygon.split(&#39;POLYGON((&#39;)[1].replace(&#39;))&#39;).split(&#39;,&#39;)[the_point_number]<br \/>\n\t<\/kbd><\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#39;ve seen many posts regarding this issue, but most point to a bug in MySQL 5.0, resolved in 5.1. This may be true, although I&#39;m&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"amp_status":""},"categories":[77,13],"tags":[91],"_links":{"self":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts\/249"}],"collection":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/comments?post=249"}],"version-history":[{"count":2,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts\/249\/revisions"}],"predecessor-version":[{"id":251,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts\/249\/revisions\/251"}],"wp:attachment":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/media?parent=249"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/categories?post=249"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/tags?post=249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}