<?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>Rusty Razor Blade &#187; rant</title>
	<atom:link href="http://www.rustyrazorblade.com/category/rant/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rustyrazorblade.com</link>
	<description>Tech Thoughts, Mostly on LAMP - by Jon Haddad</description>
	<lastBuildDate>Wed, 21 Jul 2010 20:42:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The Lack of Flexibility of Stored Procedures in MySQL</title>
		<link>http://www.rustyrazorblade.com/2010/01/the-lack-of-flexibility-of-stored-procedures-in-mysql/</link>
		<comments>http://www.rustyrazorblade.com/2010/01/the-lack-of-flexibility-of-stored-procedures-in-mysql/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 23:22:21 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[rant]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/?p=968</guid>
		<description><![CDATA[Over three years ago I wrote about how you cannot use a stored procedure in a subquery.  Well, it&#8217;s 2010, and I&#8217;m still annoyed by this and a handful of other things.
I was just working today on a report consisting of a series of queries, taking about a minute to generate.  Some of [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.rustyrazorblade.com/wp-content/uploads/2009/12/sakila.png" alt="sakila.png" hspace=10 vspace = 4 border="0" width="121" height="79" align="left" />Over three years ago <a href="http://www.rustyrazorblade.com/2006/09/can-you-use-a-stored-procedure-in-a-subquery-i-dont-think-so-mysql/">I wrote about how you cannot use a stored procedure in a subquery</a>.  Well, it&#8217;s 2010, and I&#8217;m still annoyed by this and a handful of other things.</p>
<p>I was just working today on a report consisting of a series of queries, taking about a minute to generate.  Some of the data would be created in a temporary table and queried against multiple times for performance reasons, and ultimately spit out into a CSV file for someone to examine later.  I also would like to be able to return the result set, and perform queries on it, which is much faster than querying a view.</p>
<p>Fortunately, MySQL&#8217;s awesome <a href="http://dev.mysql.com/doc/refman/5.0/en/select.html">SELECT &#8230; INTO OUTFILE</a> can easily write CSV files to disk, so I&#8217;m covered there.  </p>
<p>So when I started working on this, I was thinking this would be a great opportunity to demonstrate the flexibility and usefulness of stored procedures &#8211; after all, we will likely be needing this report again.  However, there&#8217;s an issue.  You can&#8217;t return a result set from a stored proc that you can actually do anything with.  Everything gets spit directly back to the client.  So, what are the alternatives?  </p>
<p><span id="more-968"></span><br />
Perhaps generate the data into a new table and swap with the old via a <a href="http://dev.mysql.com/doc/refman/5.0/en/rename-table.html">RENAME TABLE</a> (if it exists)?   Maybe not a bad solution.  It works (<a href="#example1">see example 1 below</a>), but now we&#8217;ve coupled the dataset to a global copy of the table, and any references we have to it are now hard coded, rather than passing back a workable dataset we can do anything we want with.  Furthermore, if we want to make any changes to the dataset (UPDATE/DELETE) we are unable to &#8211; we must make a copy of the table and work from that, unless we don&#8217;t mind messing with someone work.  </p>
<p><del datetime="2010-01-07T02:16:19+00:00">Temporary tables created in a stored procedure for the rest of the connection, so they can&#8217;t be used either (<a href="#example2">example 2</a>), which is somewhat contrary to the manual.</del></p>
<p>Temporary tables are available past the execution of a stored procedure, contrary to what I wrote earlier.  (<a href="#example2">example 2</a>)</p>
<blockquote><p>You can use the TEMPORARY keyword when creating a table. A TEMPORARY table is visible only to the current connection, and is dropped automatically when the connection is closed. This means that two different connections can use the same temporary table name without conflicting with each other or with an existing non-TEMPORARY table of the same name. (The existing table is hidden until the temporary table is dropped.) To create temporary tables, you must have the CREATE TEMPORARY TABLES privilege.</p></blockquote>
<p><del datetime="2010-01-07T02:18:18+00:00">Bummer.  I&#8217;m assuming the stored procedure runs on its&#8217; own isolated connection, which does make sense from a garbage collection point of view.</del></p>
<p>What about returning the data through the useful OUT parameter?  Nope.  Since I can&#8217;t store more than 1 row in a variable, that&#8217;s not happening either (<a href="#example3">example 3</a>)</p>
<p>You also can&#8217;t generate the data in a new table and pass back the table name in an OUT variable. (<a href="#example4">example 4</a>)</p>
<p>In conclusion: of the above methods, it seems the most likely route I&#8217;ll follow in the future will be to store the results in some permanent table, and run the proc off hours to regenerate the table, hoping that no one&#8217;s using it.  It would need to be read only &#8211; and working with it would require creating your own copy of the table.  It has the advantage of being easily understood &#8211; you can quickly DESCRIBE the columns and know what you&#8217;re getting back &#8211; so I suppose it&#8217;s going to have to be good enough.  But what I really wanted was </p>
<pre>
mysql> call some_proc() into outfile "/tmp/myfile.txt";
</pre>
<p>For more information on stored procedures, check out the <a href="http://dev.mysql.com/doc/refman/5.0/en/create-procedure.html">Stored procedure syntax</a>.</p>
<p><strong><a name="#example1">Example 1</a>: Swapping tables within a stored procedure</strong></p>
<pre >drop procedure test_proc;
delimiter //

CREATE procedure test_proc ()
begin
create table jon_new LIKE jon;
rename table jon to jon_old, jon_new to jon;
drop table jon_old;
end;
//
delimiter ;

mysql> show tables;
+------------------+
| Tables_in_test   |
+------------------+
| jon              |
+------------------+
4 rows in set (0.00 sec)

mysql> insert into jon values (1);
Query OK, 1 row affected (0.04 sec)

mysql> select * from jon;
+----+
| id |
+----+
|  1 |
+----+
1 row in set (0.00 sec)

mysql> call test_proc();
Query OK, 0 rows affected (1.53 sec)

mysql> select * from jon;
Empty set (0.00 sec)</pre>
<p><strong><a name="example2">Example 2</a>: Trying to create a temporary table in a stored procedure (updated)</strong></p>
<pre>
mysql> delimiter //
mysql> create procedure test_proc3()
    -> begin
    -> CREATE TEMPORARY TABLE my_table (id serial);
    -> end
    -> //
Query OK, 0 rows affected (0.00 sec)

mysql> delimiter ;
mysql>
mysql> call test_proc3();
Query OK, 0 rows affected (0.08 sec)

mysql>
mysql> select * from my_table;
Empty set (0.00 sec)
t</pre>
<p><strong><a name="example3">Example 3</a>: Trying to store multiple rows in a variable</strong></p>
<pre>
mysql> create table my_table (id int primary key);
Query OK, 0 rows affected (1.46 sec)

mysql> set @v = (select * from my_table);
Query OK, 0 rows affected (0.01 sec)

mysql> insert into my_table values (1),(2),(3);
Query OK, 3 rows affected (0.03 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql> set @v = (select * from my_table);
ERROR 1242 (21000): Subquery returns more than 1 row
</pre>
<p><strong><a name="example4">Example 4</a>: Trying to select from a table where the name was defined in a variable</strong></p>
<pre>
mysql> set @tab = "my_table";
Query OK, 0 rows affected (0.00 sec)

mysql> select @tab;
+----------+
| @tab     |
+----------+
| my_table |
+----------+
1 row in set (0.00 sec)

mysql> select * from @tab;
ERROR 1064 (42000): You have an error in your SQL syntax;
check the manual that corresponds to your
MySQL server version for the right syntax to use near '@tab' at line 1
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2010/01/the-lack-of-flexibility-of-stored-procedures-in-mysql/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Bad Web Developers Don&#8217;t Scale</title>
		<link>http://www.rustyrazorblade.com/2009/09/bad-web-developers-dont-scale/</link>
		<comments>http://www.rustyrazorblade.com/2009/09/bad-web-developers-dont-scale/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 23:30:38 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[rant]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/?p=833</guid>
		<description><![CDATA[Over the last 5 years, I&#8217;ve read so many articles about how X doesn&#8217;t scale.  PHP, MySQL, SQL Server, Apache, you name it &#8211; everything gets a bad rap.  Everyone has a different idea of scale and size, and sadly most people think their site with 1 million page views a month can&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>Over the last 5 years, I&#8217;ve read so many articles about how X doesn&#8217;t scale.  PHP, MySQL, SQL Server, Apache, you name it &#8211; everything gets a bad rap.  Everyone has a different idea of scale and size, and sadly most people think their site with 1 million page views a month can&#8217;t handle the load because whatever technology they chose to use supposedly doesn&#8217;t scale.</p>
<p>Guess what folks &#8211; the problem probably isn&#8217;t the language you chose, or the database you&#8217;re using.  Unless you&#8217;re actually big (many millions of pageviews per day), you can usually run just fine with a straight up LAMP stack on a few servers.  The real issue is that your dev team has no idea how to write software or use the tools they have available.  </p>
<p>At this point, I wonder &#8211; what is everyone&#8217;s expectation?  At what point does someone say &#8220;oh, X scales great! One box is handling my web server, data storage, video conversion, at 20 million page views a day, all running on 1 nice little application!&#8221;  Folks &#8211; pick the right tool for the job, and put someone qualified in charge of it.  Don&#8217;t use MySQL if you really need in memory graph tree traversal (friends list).  </p>
<p>Oh, and don&#8217;t even bother explaining to me the definition of scale.  This isn&#8217;t an opportunity for you to point out what it really means &#8211; I get that you should be able to add hardware and get a proportional amount out extra output.  Writing software that scales to a massive level is hard.  That&#8217;s why there aren&#8217;t many companies that do it well. </p>
<p>/rant</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2009/09/bad-web-developers-dont-scale/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Unsubscribing from ebay emails is insane</title>
		<link>http://www.rustyrazorblade.com/2008/01/unsubscribing-from-ebay-emails-is-insane/</link>
		<comments>http://www.rustyrazorblade.com/2008/01/unsubscribing-from-ebay-emails-is-insane/#comments</comments>
		<pubDate>Thu, 24 Jan 2008 06:22:24 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[ebay]]></category>
		<category><![CDATA[rant]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/2008/01/23/unsubscribing-from-ebay-emails-is-insane/</guid>
		<description><![CDATA[Ebay deserves a lot of credit for building a massive system that never seems to be down.  Great.  But you know what?  That doesn&#8217;t excuse them for creating some really stupid interfaces or being complete assholes.
At the bottom of an email they sent, I saw this gem next to unsubscribe:
Please note that [...]]]></description>
			<content:encoded><![CDATA[<p>Ebay deserves a lot of credit for building a massive system that never seems to be down.  Great.  But you know what?  That doesn&#8217;t excuse them for creating some really stupid interfaces or being complete assholes.</p>
<p>At the bottom of an email they sent, I saw this gem next to unsubscribe:</p>
<blockquote><p>Please note that it may take up to 10 days to process your request. </p></blockquote>
<p>Ten days.  Ten days?  Wow.</p>
<p>Now lets move onto the actual unsubscribe process.  What a nightmare.  Email preferences are grouped into sections, and only sections can be edited.  All the options are hidden, so you must first expand them to see what you&#8217;re getting.</p>
<p>Seriously, check this thing out.  I never use thumbnails either, so you know I&#8217;m pissed.</p>
<p><a href='http://www.rustyrazorblade.com/wp-content/uploads/2008/01/picture-1.png' title='picture-1.png'><img src='http://www.rustyrazorblade.com/wp-content/uploads/2008/01/picture-1.thumbnail.png' alt='picture-1.png' /></a></p>
<p>This process makes me really start to hate these guys.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2008/01/unsubscribing-from-ebay-emails-is-insane/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Stop Trying to be Clever</title>
		<link>http://www.rustyrazorblade.com/2007/10/stop-trying-to-be-clever/</link>
		<comments>http://www.rustyrazorblade.com/2007/10/stop-trying-to-be-clever/#comments</comments>
		<pubDate>Tue, 02 Oct 2007 20:24:26 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[rant]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/index.php/2007/10/02/stop-trying-to-be-clever/</guid>
		<description><![CDATA[I&#8217;ll keep this short.  Please, stop trying to be clever.  I&#8217;m talking to you, mediocre developer.  I realized you think it&#8217;s awesome to use a different file extension, like .awesome.  It&#8217;s not.  You&#8217;re really not accomplishing anything.  If your excuse if that you don&#8217;t want people to realize you&#8217;re [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ll keep this short.  Please, stop trying to be clever.  I&#8217;m talking to you, mediocre developer.  I realized you think it&#8217;s awesome to use a different file extension, like .awesome.  It&#8217;s not.  You&#8217;re really not accomplishing anything.  If your excuse if that you don&#8217;t want people to realize you&#8217;re using PHP, have the sense to disable the server signature in apache, because anyone that&#8217;s actually trying to hack your machine is going to check that.  </p>
<p>Why are you mixing if statement styles?  Within the same file?  </p>
<p><code><br />
if( $whatever )<br />
{<br />
  if($somethingelse) :<br />
   $random = 3;<br />
  endif;<br />
  $random++;<br />
}</code></p>
<p>Not clever.  At all.  </p>
<p>Pick an indentation style and stick with it.  Tabs or spaces.  One or the other.  Not both.  Not 2 spaces in the first half and 6 spaces in the last half.  </p>
<p>Calling undocumented functions within PHP, such as mysql().  At first, I felt dumb for not knowing what this was, then I realized I have absolutely no obligation to ever know (or use) that function.  I&#8217;ve combed through years of the PHP manual, and I still haven&#8217;t found it.  Guess what &#8211; it&#8217;s not cool, it&#8217;s not impressive, and I don&#8217;t think you&#8217;re awesome.  I think you&#8217;re a jackass that just risked breaking functionality with every single upgrade of PHP.  Thanks for nothing.</p>
<p>/rant</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2007/10/stop-trying-to-be-clever/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Experts Exchange should be removed from Google search results</title>
		<link>http://www.rustyrazorblade.com/2007/07/experts-exchange-should-be-removed-from-google-search-results/</link>
		<comments>http://www.rustyrazorblade.com/2007/07/experts-exchange-should-be-removed-from-google-search-results/#comments</comments>
		<pubDate>Tue, 31 Jul 2007 04:01:42 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[google]]></category>
		<category><![CDATA[rant]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/index.php/2007/07/30/experts-exchange-should-be-removed-from-google-search-results/</guid>
		<description><![CDATA[I was trying to figure out how to extend my wireless network down a few floors a few days ago, and one of my queries brought me to experts exchange.  The question looked useful: Using Linksys WAP54G as Wireless Repeater.  This is exactly what I wanted to do.  However, once I actually [...]]]></description>
			<content:encoded><![CDATA[<p>I was trying to figure out how to extend my wireless network down a few floors a few days ago, and one of my queries brought me to experts exchange.  The question looked useful: Using Linksys WAP54G as Wireless Repeater.  This is exactly what I wanted to do.  However, once I actually scrolled down to view the answers, I saw this</p>
<p><img id="image59" src="http://www.rustyrazorblade.com/wp-content/uploads/2007/07/Picture%2011.png" alt="Experts exchange" height="258" width="420"/></p>
<p>I thought this was pretty weird, since I was pretty sure in the snippet I saw on Google&#8217;s results they had part of the solution I was looking for.  Now I&#8217;m curious, so I hit sign up to view solution, and saw the signup page requires credit card payment.</p>
<p><img id="image61" src="http://www.rustyrazorblade.com/wp-content/uploads/2007/07/Picture%202.png" alt="experts exchange credit cards" /></p>
<p><a href="http://www.experts-exchange.com/Networking/Q_21660493.html">Page in question.</a></p>
<p>I checked out the <a href="http://www.google.com/support/webmasters/bin/answer.py?answer=35769">Google webmaster guidelines</a>, and this is in direct violation.  Under &#8220;Quality guidelines &#8211; basic principles&#8221;, it says </p>
<blockquote><p># Make pages for users, not for search engines. Don&#8217;t deceive your users or present different content to search engines than you display to users, which is commonly referred to as &#8220;cloaking.&#8221;<br />
# Avoid tricks intended to improve search engine rankings. A good rule of thumb is whether you&#8217;d feel comfortable explaining what you&#8217;ve done to a website that competes with you. Another useful test is to ask, &#8220;Does this help my users? Would I do this if search engines didn&#8217;t exist?&#8221;</p></blockquote>
<p><a href="http://72.14.253.104/search?q=cache:vFas7zvJG4wJ:www.experts-exchange.com/Networking/Q_21660493.html+Using+Linksys+WAP54G+as+Wireless+Repeater&#038;hl=en&#038;ct=clnk&#038;cd=1&#038;gl=us&#038;client=firefox-a">Hitting the Google cache</a> of this page shows they&#8217;re serving up a different version of the site to search engines.  To me, letting them rank high for this paid for content is a clear violation of the Google TOS.</p>
<p>I am filing experts exchange to <a href="http://www.google.com/intl/en/contact/spamreport.html">Google&#8217;s spam directory</a>.  I encourage you all to do the same.</p>
<p>Edit, search term was: Using Linksys WAP54G as Wireless Repeater</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2007/07/experts-exchange-should-be-removed-from-google-search-results/feed/</wfw:commentRss>
		<slash:comments>232</slash:comments>
		</item>
		<item>
		<title>My beef with the Wikipedia</title>
		<link>http://www.rustyrazorblade.com/2006/08/my-beef-with-the-wikipedia/</link>
		<comments>http://www.rustyrazorblade.com/2006/08/my-beef-with-the-wikipedia/#comments</comments>
		<pubDate>Wed, 16 Aug 2006 00:28:30 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[rant]]></category>
		<category><![CDATA[wikipedia]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/?p=5</guid>
		<description><![CDATA[I used to think the wikipedia was pretty cool.  The idea of being able to collaborate on a topic and create an article together sounds wonderful.
Today, I say, it sucks.  Want to know why?  I edited an article, updating it with correct information, and my edit was rejected within 5 minutes.
 00:01, [...]]]></description>
			<content:encoded><![CDATA[<p>I used to think the wikipedia was pretty cool.  The idea of being able to collaborate on a topic and create an article together sounds wonderful.</p>
<p>Today, I say, it sucks.  Want to know why?  I edited an article, updating it with correct information, and my edit was rejected within 5 minutes.</p>
<p><strong> 00:01, 16 August 2006 (<a title="Answerbag" href="http://en.wikipedia.org/w/index.php?title=Answerbag&#038;action=history">hist</a>) (<a title="Answerbag" href="http://en.wikipedia.org/w/index.php?title=Answerbag&#038;diff=prev&#038;oldid=69915309">diff</a>)  <a title="Answerbag" href="http://en.wikipedia.org/wiki/Answerbag">Answerbag</a>  <span class="comment">(rv &#8211; Vandalism.  Jonathan Haddad is not listed on the site under staff.)</span> <strong> (top)</strong></strong></p>
<p>Unfortunately, none of the current staff is actually listed under there.  I am the lead programmer for answerbag.  I make all the architectural decisions, all code goes through me.  Yet, some jackass, who has no clue what he&#8217;s talking about, gets to make the decision on what&#8217;s true or not.<br />
By the way, the dude that pulled me off Answerbag <a target="_blank" title="Fopkins" href="http://en.wikipedia.org/wiki/User:Fopkins">has his own Wikipedia entry</a>.  Seems completely legit to me.<br />
Check out his other edits, which include deleting letsgetnuts.com and deleting Jonathan Haddad.</p>
<p>I could make many more points, but they are made on <a title="Joel Down's Blog" href="http://joeldowns.com/2006/08/08/wikipedia-and-why-it-just-isnt-that-important/">Joel Down&#8217;s Blog</a>.</p>
<p>Hey Fopkins, go fuck yourself.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2006/08/my-beef-with-the-wikipedia/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
