{"id":763,"date":"2013-07-26T17:30:48","date_gmt":"2013-07-26T15:30:48","guid":{"rendered":"\/\/www.mcgill.org.za\/stuff\/?p=763"},"modified":"2013-07-26T17:46:58","modified_gmt":"2013-07-26T15:46:58","slug":"error-1305-42000-function-eval-does-not-exist","status":"publish","type":"post","link":"https:\/\/www.mcgill.org.za\/stuff\/archives\/763","title":{"rendered":"ERROR 1305 (42000): FUNCTION eval does not exist"},"content":{"rendered":"<p>MySQL cluster &#8211; a wonderful idea.\u00a0 It&#8217;s really nice: you have a front end, and multiple redundant back ends, and all the data is loaded into memory, so things go very fast, even queries that inefficiently scan vast squabs of data, all executing in parallel with failsafe redundancy.\u00a0 Not only this, but you get to use words like &#8220;cluster&#8221; and &#8220;database&#8221; in one sentence, and it&#8217;s all very cool until you hit a limit:<\/p>\n<ul>\n<li>You run out of space.<\/li>\n<li>You have too many rows.<\/li>\n<li>You have too many columns.<\/li>\n<li>Too many concurrent queries &#8211; but they don&#8217;t block, they die.<\/li>\n<li>Old operations that interfere with new operations.<\/li>\n<li>Your query is too big.<\/li>\n<li>Your back end dies and you didn&#8217;t monitor it, and then they all die.<\/li>\n<li>You find that one of the weird restrictions actually matters &#8211; like you can&#8217;t address both ndbcluster and myisam tables in a trigger, or you can&#8217;t do certain types of query that, um, well, are bigly big or something.<\/li>\n<\/ul>\n<p>So, in the shorter term, you migrate archive data away from the <em><\/em><em>ndbcluster<\/em> tables and into <em>MyISAM <\/em>tables.\u00a0 (Why not innodb?\u00a0 Because you need to make copies of these things, and tying up your front end to suck out innodb tables is not much fun.)<\/p>\n<p>So today, for the longer term, we&#8217;re migrating back to plain InnoDB on some fair to amazing hardware.\u00a0 This means setting up a slave of a live system, and bringing it into sync &#8211; 150Gb of data.\u00a0 This has proved interesting:<\/p>\n<ul>\n<li>Row level replication doesn&#8217;t work quite right with triggers and clusters from version <em>5.1.51-ndb-7.1.10-cluster-gpl-log<\/em> to <em>5.6.11 MySQL Community Server (GPL)<\/em>.\u00a0 Some things simply do not happen &#8212; certain <em>UPDATE<\/em> statements don&#8217;t get replicated.\u00a0 Switching to <em>STATEMENT<\/em> replication seems to make the replication happen, but of course, it doesn&#8217;t really make the two copies the same unless the databases happen to be in sync.<\/li>\n<li>The <em>mysqldump<\/em><em><\/em> of one of the tables made on the cluster could not be loaded, because of multiple entries sharing the same unique key.\u00a0 It was a less than unique unique key.\u00a0 I suppose I did run mysqldump with <em>&#8211;skip-lock-tables<\/em> so maybe I deserved this.<\/li>\n<\/ul>\n<p>Anyhow, this brought us to reducing the size of the tables so that we could actually work with them.\u00a0 That has been fun, and this is where we ran into problems with a mass <em>DELETE\u00a0<\/em>statement with some odd error that means &#8220;I&#8217;m busy with the stuff you said, so I can&#8217;t do more right now, sorry.&#8221;<\/p>\n<p>So there was this idea:<\/p>\n<blockquote><p>Why don&#8217;t we generate the SQL statements using SQL!<\/p><\/blockquote>\n<p>Now this is truly the daftest idea that was had all day.\u00a0 And fortunately, MySQL seemed to agree:<\/p>\n<pre>mysql&gt; <b>select eval('select 1');<\/b>\r\nERROR 1305 (42000): FUNCTION eval does not exist<\/pre>\n<p>What a relief! Sanity prevailed! A language which had the foresight not to implement that one thing that makes script languages eval.<\/p>\n<p>Or so we thought, until this gem, which is eval for mysql:<\/p>\n<pre>mysql&gt; <b>set @string='select 1'; prepare eval from @string; execute eval;<\/b>\r\nQuery OK, 0 rows affected (0.00 sec)\r\n\r\nQuery OK, 0 rows affected (0.01 sec)\r\nStatement prepared\r\n\r\n+---+\r\n| 1 |\r\n+---+\r\n| 1 |\r\n+---+\r\n1 row in set (0.00 sec)<\/pre>\n<p>So that&#8217;s eval for mysql. It was ugly. Fortunately, nobody did this. Equally fortunate is that it takes two statements to do this, which seriously limits the opportunities for SQL injection from applications.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MySQL cluster &#8211; a wonderful idea.\u00a0 It&#8217;s really nice: you have a front end, and multiple redundant back ends, and all the data is loaded into memory, so things go very fast, even queries that inefficiently scan vast squabs of &hellip; <a href=\"https:\/\/www.mcgill.org.za\/stuff\/archives\/763\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[20,190,11],"class_list":["post-763","post","type-post","status-publish","format-standard","hentry","category-stuff","tag-mysql","tag-stuff","tag-stupidity"],"_links":{"self":[{"href":"https:\/\/www.mcgill.org.za\/stuff\/wp-json\/wp\/v2\/posts\/763","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mcgill.org.za\/stuff\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mcgill.org.za\/stuff\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mcgill.org.za\/stuff\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mcgill.org.za\/stuff\/wp-json\/wp\/v2\/comments?post=763"}],"version-history":[{"count":9,"href":"https:\/\/www.mcgill.org.za\/stuff\/wp-json\/wp\/v2\/posts\/763\/revisions"}],"predecessor-version":[{"id":766,"href":"https:\/\/www.mcgill.org.za\/stuff\/wp-json\/wp\/v2\/posts\/763\/revisions\/766"}],"wp:attachment":[{"href":"https:\/\/www.mcgill.org.za\/stuff\/wp-json\/wp\/v2\/media?parent=763"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mcgill.org.za\/stuff\/wp-json\/wp\/v2\/categories?post=763"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mcgill.org.za\/stuff\/wp-json\/wp\/v2\/tags?post=763"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}