Mysql Update: Null + 1 is Null! Thu, Feb 12. 2009
You can't add to Null
Here's something about mysql create table definitions that can easily catch you if you aren't careful. Consider this table definition:
- CREATE TABLE screenshots (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, votes INT);
mysql> CREATE TABLE screenshots (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, votes INT);
Query OK, 0 rows affected (0.09 sec)
What the user wanted was a simple table to keep track of user submitted screen shots. Of course the real table had a submission date, and name column but I've omitted those in order to focus on what can happen when you allow a numeric column to have NULL values.
In the application in question, when a user votes for the screen shot they like, the system should "count" the vote, by increasing the values in the "votes" column by one. Initially the developer working on this application was trying to read the value from the database, and in a PHP web script, they would increment this value and take the result and set "votes" to be equal to it in an UPDATE statement. I explained that this could cause lost votes, because if two or more users were voting at nearly the same time, each would overwrite the value of the "vote" column. In fact there are scenarios far worse than that --- a user with a cached page could vote and set the vote count back days or weeks. I didn't bother to mention the possibility that someone might recognize what was going on in the web form, and start tampering with it, since it was plainly evident that the form was passing the current number of votes.
One of the many benefits of using a relational database is built in concurrency. In an UPDATE statement, you can add to the value of the column without having to know what its original value is, just as computer languages allow assignment to a variable that references the variable's current value (ie. $a = $a + 1, $a++).
- UPDATE screenshots SET votes = votes + 1 WHERE id =
All that's needed is to have the serverside language provide a value for a particular "id" and the votes will be tallied and updated correctly. Even more importantly, mysql will serialize the updates, insuring that no votes are lost.
However, given the original Mysql CREATE TABLE statement , what will happen if our code embeds the UPDATE statement provided?
Heathers Wed, Jan 7. 2009
For some time now I've felt like an honorary citizen of Ireland, having married a girl from Dublin and been blessed with two children upon which my wife and I have bestowed the most Irish of names. I've visited the country numerous times over the last 15 years and find myself becoming more intrigued with its history, culture and music with each visit. I've witnessed first hand Ireland's rapid evolution under the influence of unprecedented economic growth and the tidal wave of change brought by the European union. Any such metamorphosis brings with it changes that are both good and bad. The skies of Ireland's major cities have in recent years become thick with giant construction cranes, and its citizens have seen real estate prices hit astronomical highs. Ireland's youth no longer are confronted with the economic necessity of emigration, and expatriates have begun to return home in increasing numbers. The country now faces ironic and unforeseen challenges in the wake of its stunning reversal of fortune.
Lampsig 2008 Presentation on Subversion for Lamp Developers Mon, Oct 13. 2008

Here are the slides for the presentation on subversion I gave at the September 2008 LampSIG meeting. I hope some may find them useful, however they were meant only to provide a skeleton for the talk, and aren't a complete tutorial by any means. The following links to other sites were mentioned in the talk:
The Red bean book, aka Subversion manual
The svnmerge python script
Subversion tips Article
Subversion Cheat Card
Linux shell scripting: bad interpreter: No such file or directory Mon, Sep 15. 2008
This error pops up for a couple of reasons. At the top of the script there will probably be a line that looks like this:
This is telling Linux that this script should be interpreted using the /bin/sh program. So your first step is to verify that program exists. I tend to use:
This will typically come back with a response like this:
This is telling us that the path to the sh program is in fact /bin/sh, matching the path specified at the top of the script. Ok, so what gives? Well, it's possible that this script was made on an operating system that has line ending characters different than linux. This could have been on on a Mac or PC, or the file could have been converted when it was packaged. In this case, you get the relatively misleading bad interpreter: No such file or directory message, which is really trying to look for sh, although you don't get any indication of the fact.
So, how to fix? Read on.
#!/bin/sh
This is telling Linux that this script should be interpreted using the /bin/sh program. So your first step is to verify that program exists. I tend to use:
which sh
This will typically come back with a response like this:
/bin/sh
This is telling us that the path to the sh program is in fact /bin/sh, matching the path specified at the top of the script. Ok, so what gives? Well, it's possible that this script was made on an operating system that has line ending characters different than linux. This could have been on on a Mac or PC, or the file could have been converted when it was packaged. In this case, you get the relatively misleading bad interpreter: No such file or directory message, which is really trying to look for sh
So, how to fix? Read on.
Continue reading "Linux shell scripting: bad interpreter: No such file or directory" »
EA's Spore DRM fiasco Sat, Sep 13. 2008
EA's big fall PC gaming release is the long awaited "Spore" from Maxis, beloved studio responsible for all things Sim. Spore has been in some form of development since 2000, and finally hit stores on Sept. 7th, 2008, accompanied by predictions of the title living up to its hype and transcending it from EA brass.I took a look at the Amazon user ratings for the game, and was shocked to see that it has been absolutely shellacked -- currently 2300+ reviews and only 1.5 stars. The primary reason for the low ratings? Customer outrage over EA's employment of the Sony SecuROM copy protection system, that allows someone purchasing the game, to activate it 3 times. As was pointed out in an amazon review:
Then there's the DRM. Let me just clarify what people are saying by adding, it not only counts installations, but changes to your hardware ! Upgrade a system component (memory, CPU, vid card) and you are out an installation....Basically I just paid $50 for a coaster.
When will companies learn that treating their customers like thieves is never a good business practice?
New Lula/Lampsig Coop Server Thu, Jul 24. 2008
So the UML Coop has finally after 3 years of talking about it, acquired a new server from Silicon Mechanics. Read the rest of the article for the complete specifications. We will be moving off User Mode Linux (UML) and on to OpenVZ. This change will allow us to accept some new members to the coop, so if you're interested drop me a line.

« previous page
(Page 2 of 15, totaling 90 entries)
next page »



