List:General Discussion« Previous MessageNext Message »
From:Jigal van Hemert Date:May 5 2005 10:02am
Subject:Re: stability of mysql error strings
View as plain text  
----- Original Message -----
From: "Scott Haneda"
> on 5/4/05 7:22 PM, Paul DuBois at paul@stripped wrote:
> > Error strings do change format sometimes.
> > And they won't necessarily be in English. :-)
>
> I had a feeling, what is the general method most use to deal with the
above
> scenario?  I really don't want to test error strings every time I update
> mysql, I suppose the safe road is to hand select ahead of time?
Or use:
INSERT new record with username
retrieve record id (if it is an autoincrement field)
UPDATE record with email

You can now handle the 1062 errors of the insert and update seperately.

The scenario with select, insert requires transactions (other processes
could insert a matching record between your select and insert), which are
currently only supported by InnoDB (and BDB) tables.
http://dev.mysql.com/doc/mysql/en/ansi-diff-transactions.html

Another approach would be to do an insert with username and email and in
case of an error do one or two selects to check which field caused the
duplicate error (most of the time there won't be an error, so it would save
you some queries).

Regards, Jigal.

Thread
stability of mysql error stringsScott Haneda5 May
  • Re: stability of mysql error stringsPaul DuBois5 May
    • Re: stability of mysql error stringsScott Haneda5 May
      • Re: stability of mysql error stringsJigal van Hemert5 May