Re: What is happening with mySQL?
Posted by:
Er Abbott
Date: June 24, 2005 02:12AM
Look at this. I've installed the latest mySQL version on my Win2K machine - so I don't have to be an unfair guy who is just screaming here.
This script I've ran was generated by FabForce's DB Designer.
mysql> CREATE TABLE usuarios (
-> usri_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
-> login VARCHAR(50) NULL,
-> PRIMARY KEY(usri_id)
-> )
-> TYPE=InnoDB;
Query OK, 0 rows affected, 1 warning (0.07 sec)
mysql> CREATE TABLE mylog (
-> log_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
-> usuarios_usri_id INTEGER UNSIGNED NOT NULL,
-> operacao VARCHAR(100) NULL,
-> PRIMARY KEY(log_id),
-> INDEX mylog_FKIndex1(usuarios_usri_id)
-> )
-> TYPE=InnoDB;
Query OK, 0 rows affected, 1 warning (0.09 sec)
So, then I've ran this and all worked fine:
mysql> insert into usuarios values (1, 'galvao');
Query OK, 1 row affected (0.04 sec)
mysql> insert into mylog values (1, 8, 'teste');
Query OK, 1 row affected (0.03 sec)
Then I've realized that DB Designer doesn't use the default syntax (REFERENCES table(column)), so I've dropped the mylog table and recreated it - again, I don't want to be unfair:
mysql> CREATE TABLE mylog (
-> log_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
-> usuarios_usri_id INTEGER UNSIGNED NOT NULL REFERENCES usuarios(id),
-> operacao VARCHAR(100) NULL,
-> PRIMARY KEY(log_id),
-> INDEX mylog_FKIndex1(usuarios_usri_id)
-> )
-> TYPE=InnoDB;
Query OK, 0 rows affected, 1 warning (0.07 sec)
Notice the warning. I have a warning, but mySQL doesn't tell me what is wrong (cool, huh?).
So here I go again: look what a shame that is:
mysql> insert into mylog values (1, 8, 'teste');
Query OK, 1 row affected (0.05 sec)
This is really, REALLY wrong.
Sorry, folks, but there is no excuse for this.