{"id":1863,"date":"2010-03-17T18:33:15","date_gmt":"2010-03-17T08:33:15","guid":{"rendered":"http:\/\/www.flamingspork.com\/blog\/?p=1863"},"modified":"2010-03-17T18:34:25","modified_gmt":"2010-03-17T08:34:25","slug":"one-last-bit-of-evil","status":"publish","type":"post","link":"https:\/\/www.flamingspork.com\/blog\/2010\/03\/17\/one-last-bit-of-evil\/","title":{"rendered":"One last bit of evil&#8230;."},"content":{"rendered":"<div id=\"_mcePaste\">You can store things for later!<\/div>\n<div><code>drizzle&gt; select libtcc(\"#include &lt;string.h&gt;\\n#include &lt;stdlib.h&gt;\\nint foo(char* s) { <strong>char *a= malloc(1000);<\/strong> return snprintf(s, 100, \\\"%p\\\", a); }\") as RESULT;<\/code><\/div>\n<pre>+-----------+\r\n| RESULT    |\r\n+-----------+\r\n| 0x199c610 |\r\n+-----------+\r\n1 row in set (0 sec)<\/pre>\n<div>\n<div><code>drizzle&gt; select libtcc(\"#include &lt;string.h&gt;\\n#include &lt;stdlib.h&gt;\\nint foo(char* s) { char *a= 0x199c610; <strong>strcpy(a, \\\"Hello World!\\\");<\/strong> strcpy(s,\\\"done\\\"); return strlen(s); }\") as result;<\/code><\/div>\n<\/div>\n<pre>+--------+\r\n| result |\r\n+--------+\r\n| done   |\r\n+--------+\r\n1 row in set (0.01 sec)<\/pre>\n<div><code>drizzle&gt; select libtcc(\"#include &lt;string.h&gt;\\n#include &lt;stdlib.h&gt;\\nint foo(char* s) { char *a= 0x199c610; <strong>strcpy(s, a)<\/strong>; return strlen(s); }\") as result;<\/code><\/div>\n<pre>+--------------+\r\n| result       |\r\n+--------------+\r\n| Hello World! |\r\n+--------------+\r\n1 row in set (0.01 sec)<\/pre>\n<div>And then&#8230; i can disconnect, reconnect, or whatever (as for any of the above really) before cleaning up my memory:<\/div>\n<div>\n<div><code>drizzle&gt; select libtcc(\"#include &lt;string.h&gt;\\n#include &lt;stdlib.h&gt;\\nint foo(char* s) { char *a= 0x19a9bc0;<strong> free(a);<\/strong> strcpy(s,\\\"done\\\"); return strlen(s); }\") as result;<\/code><\/div>\n<\/div>\n<pre>+--------+\r\n| result |\r\n+--------+\r\n| done   |\r\n+--------+\r\n1 row in set (0 sec)<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>You can store things for later! drizzle&gt; select libtcc(&#8220;#include &lt;string.h&gt;\\n#include &lt;stdlib.h&gt;\\nint foo(char* s) { char *a= malloc(1000); return snprintf(s, 100, \\&#8221;%p\\&#8221;, a); }&#8221;) as RESULT; +&#8212;&#8212;&#8212;&#8211;+ | RESULT | +&#8212;&#8212;&#8212;&#8211;+ | 0x199c610 | +&#8212;&#8212;&#8212;&#8211;+ 1 row in set (0 sec) &hellip; <a href=\"https:\/\/www.flamingspork.com\/blog\/2010\/03\/17\/one-last-bit-of-evil\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[76,75],"tags":[138,70,262,267,261,263],"class_list":["post-1863","post","type-post","status-publish","format-standard","hentry","category-code","category-drizzle-work-et-al","tag-c","tag-drizzle","tag-evil","tag-malloc","tag-stored-procedure","tag-tcc"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5a6n8-u3","jetpack-related-posts":[{"id":1860,"url":"https:\/\/www.flamingspork.com\/blog\/2010\/03\/17\/a-md5-stored-procedure-for-drizzle-in-c\/","url_meta":{"origin":1863,"position":0},"title":"A MD5 stored procedure for Drizzle&#8230; in C","author":"Stewart Smith","date":"2010-03-17","format":false,"excerpt":"So, just in case that wasn't evil enough for you... perhaps you have something you want to know the MD5 checksum of. So, you could just do this: drizzle> select md5('Hello World!'); +----------------------------------+ | md5('Hello World!') | +----------------------------------+ | ed076287532e86365e841e92bfc50d8c | +----------------------------------+ 1 row in set (0 sec) But that\u2026","rel":"","context":"In &quot;code&quot;","block_context":{"text":"code","link":"https:\/\/www.flamingspork.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1855,"url":"https:\/\/www.flamingspork.com\/blog\/2010\/03\/17\/stored-proceduresfunctions-for-drizzle\/","url_meta":{"origin":1863,"position":1},"title":"Stored Procedures\/Functions for Drizzle","author":"Stewart Smith","date":"2010-03-17","format":false,"excerpt":"Previously, in \"Thoughts on Thoughts on Drizzle\" I theorized that one of the major reasons why we did not see lots of people jumping at stored procedures in MySQL was that it wasn't in their native language (for lack of a better term). We've seen External Language Stored Procedures for\u2026","rel":"","context":"In &quot;code&quot;","block_context":{"text":"code","link":"https:\/\/www.flamingspork.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1383,"url":"https:\/\/www.flamingspork.com\/blog\/2009\/02\/02\/row-id-in-mysql-and-drizzle-and-the-engines\/","url_meta":{"origin":1863,"position":2},"title":"row id in MySQL and Drizzle (and the engines)","author":"Stewart Smith","date":"2009-02-02","format":false,"excerpt":"Some database engines have a fundamental concept of a row id. The row id is everything you need to know to locate a row. Common uses include secondary indexes (key is what's indexed, value is rowid which you then use to lookup the row). One design is the InnoDB method\u2026","rel":"","context":"In &quot;drizzle&quot;","block_context":{"text":"drizzle","link":"https:\/\/www.flamingspork.com\/blog\/category\/work-et-al\/drizzle-work-et-al\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3745,"url":"https:\/\/www.flamingspork.com\/blog\/2014\/05\/26\/efficiently-writing-to-a-log-file-from-multiple-threads\/","url_meta":{"origin":1863,"position":3},"title":"Efficiently writing to a log file from multiple threads","author":"Stewart Smith","date":"2014-05-26","format":false,"excerpt":"There's a pattern I keep seeing in threaded programs (or indeed multiple processes) writing to a common log file. This is more of an antipattern than a pattern, and is often found in code that has existed for years. Basically, it's having a mutex to control concurrent writing to the\u2026","rel":"","context":"In &quot;code&quot;","block_context":{"text":"code","link":"https:\/\/www.flamingspork.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1262,"url":"https:\/\/www.flamingspork.com\/blog\/2008\/11\/22\/drop-table-fail-on-the-road-to-removing-the-frm\/","url_meta":{"origin":1863,"position":4},"title":"drop table fail (on the road to removing the FRM)","author":"Stewart Smith","date":"2008-11-22","format":false,"excerpt":"So... in removing the FRM file in Drizzle, I found a bit of a nugget on how drop table works (currently in the MySQL server and now \"did\" in Drizzle). If you DROP TABLE t1; this is what happens open the .frm file read first 10bytes (oh, and if you\u2026","rel":"","context":"In &quot;drizzle&quot;","block_context":{"text":"drizzle","link":"https:\/\/www.flamingspork.com\/blog\/category\/work-et-al\/drizzle-work-et-al\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1813,"url":"https:\/\/www.flamingspork.com\/blog\/2010\/03\/12\/writing-a-storage-engine-for-drizzle-part-2-create-table\/","url_meta":{"origin":1863,"position":5},"title":"Writing A Storage Engine for Drizzle, Part 2: CREATE TABLE","author":"Stewart Smith","date":"2010-03-12","format":false,"excerpt":"The DDL code paths for Drizzle are increasingly different from MySQL. For example, the embedded_innodb StorageEngine CREATE TABLE code path is completely different than what it would have to be for MySQL. This is because of a number of reasons, the primary one being that Drizzle uses a protobuf message\u2026","rel":"","context":"In &quot;drizzle&quot;","block_context":{"text":"drizzle","link":"https:\/\/www.flamingspork.com\/blog\/category\/work-et-al\/drizzle-work-et-al\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/posts\/1863","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/comments?post=1863"}],"version-history":[{"count":2,"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/posts\/1863\/revisions"}],"predecessor-version":[{"id":1865,"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/posts\/1863\/revisions\/1865"}],"wp:attachment":[{"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/media?parent=1863"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/categories?post=1863"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/tags?post=1863"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}