Mirmo Dynamics

Si tu kiffes pas reunoi, t'écoutes pas et puis c'est tout.

To content | To menu | To search

Keyword - mysql

Entries feed - Comments feed

Thursday 2 April 2009

SQLSTATE[HY000]: General error: 1005 Can't create table '*' (errno: 150)

You may or may have not already stumbled upon this rather obscure error message (no, I'm not starting a serie on obscures error messages). Well the first thing to think when you encounter this is your foreign keys. This message generally denotes a failure in foreign keys creation, for example when the two columns you are trying to link are not of the exact same type (that is, you can't link an integer(4) to an integer(11)).

Now what if you are absolutely certain that your two columns are of the same type ? I just had the problem with this piece of doctrine schema (simplified for example purpose):

Media:
  columns:
    image:           { type: string(255), notnull: true, unique: true }

ExplorationMission:
  columns:
    probe_image:         { type: integer, notnull: true }
  relations:
    ProbeImage:          { class: Media, local: probe_image, foreign: id, onDelete: 'SET NULL' }

Can you spot the problem ?

It's rather obvious when you know it, but I spent rather some time cursing mysql in vain. The point is that there is a major logic error in this schema. it declares the probe_image as NOT NULL while it gently asks the FK to set it null on delete. See ?

Hope it saves some frustration :-)

Monday 1 October 2007

PDO not throwing an exception when it should

Today I ran into an issue that I already ran into a few weeks ago when I did not have time to dig up, but today I had this time (this plus it's a really annoying issue as you'll see). The main symptom is that PDO does not throws exceptions when you'd expect it to. It's very annoying. The reason, in my case, seems to be that I am querying an old mysql (3.23.x in my case but any 4.x will do according to this bug report). I was not able to find any info from google, so I'm posting this here so that people know :-)

Tuesday 28 November 2006

dotdeb et PDO_Mysql

Pour ceux:

  1. qui utilisent le repository dotdeb
  2. qui se demandent pourquoi php5-pdo-mysql a disparu
  3. qui ne lisent pas les news de dotdeb

Sachez que php5-pdo-mysql a été renommé/fusionné en php5-mysql.

C'était l'info utile (ou pas) du jour.