Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mipearson/2495661 to your computer and use it in GitHub Desktop.
Save mipearson/2495661 to your computer and use it in GitHub Desktop.
Example of MySQL default being harmful
Mirrored from http://flooble.net/~pete/fuck-you-mysql-you-fucking-fuck-of-a-fuckstick.txt
mysql> create table fuckyou ( id integer primary key auto_increment, name varchar(20) not null );
Query OK, 0 rows affected (0.00 sec)
mysql> insert into fuckyou (name) values (null);
ERROR 1048 (23000): Column 'name' cannot be null
mysql> insert into fuckyou (name) values ('pete');
Query OK, 1 row affected (0.00 sec)
mysql> select * from fuckyou;
+----+------+
| id | name |
+----+------+
| 1 | pete |
+----+------+
1 row in set (0.00 sec)
mysql> update fuckyou set name = null;
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> select * from fuckyou where name is null;
Empty set (0.00 sec)
mysql> select * from fuckyou where name = '';
+----+------+
| id | name |
+----+------+
| 1 | |
+----+------+
1 row in set (0.00 sec)
mysql> select version(), current_date();
+-------------------+----------------+
| version() | current_date() |
+-------------------+----------------+
| 5.1.49-1ubuntu8.1 | 2012-04-26 |
+-------------------+----------------+
1 row in set (0.04 sec)
mysql>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment