parsing mysql error messages

parsing mysql error messages

am 25.08.2005 14:05:28 von Dave Howorth

I'd like to do some processing of MySQL database errors, either to try
to recover from the condition or to display a more meaningful message to
a user.

But the detailed information, which users want and which my attempt at
automatic recovery needs, is buried in the MySQL mysql_error string,
AFAIK. So it seems like I need to parse that and I can't believe I'm the
first to want to do it :)

I haven't looked into this topic before so I wondered what the prior art
is and whether there are any CPAN modules that might help with this? I'd
be grateful for any pointers.

Thanks, Dave


--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org

Re: parsing mysql error messages

am 25.08.2005 14:22:31 von Jochen Wiedmann

Dave Howorth wrote:

> But the detailed information, which users want and which my attempt at
> automatic recovery needs, is buried in the MySQL mysql_error string,
> AFAIK. So it seems like I need to parse that and I can't believe I'm the
> first to want to do it :)

Nonsense, check $dbh->err or $dbh->state (same for $sth). They should
contain the error code as a number.


Jochen

--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org

Re: parsing mysql error messages

am 25.08.2005 14:27:42 von Dave Howorth

Jochen Wiedmann wrote:
> Dave Howorth wrote:
>
>> But the detailed information, which users want and which my attempt at
>> automatic recovery needs, is buried in the MySQL mysql_error string,
>> AFAIK. So it seems like I need to parse that and I can't believe I'm
>> the first to want to do it :)
>
> Nonsense, check $dbh->err or $dbh->state (same for $sth). They should
> contain the error code as a number.

It's not the error code I'm looking for. It's details such as which
field(s) failed a UNIQUE constraint, for example.

Thanks, Dave


--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org

Re: parsing mysql error messages

am 25.08.2005 14:40:43 von Jan Kratochvil

Hi,

On Thu, 25 Aug 2005 21:27:42 +0900, Dave Howorth wrote:
....
> It's not the error code I'm looking for. It's details such as which
> field(s) failed a UNIQUE constraint, for example.

In such case you just want to check it before by SELECT, all properly enclosed
by the transactions. In such case the UNIQUE violation error SHOULD NOT HAPPEN
(OK, you should generally check any errore but you should not be able to invoke
such error yourself).


Regards,
Lace

--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org

Re: parsing mysql error messages

am 25.08.2005 14:45:10 von Jochen Wiedmann

Dave Howorth wrote:

> It's not the error code I'm looking for. It's details such as which
> field(s) failed a UNIQUE constraint, for example.

That's, of course, something that can very well change with any database
upgrade, so I would never attempt to automize it. Never heard of any
attempts, so you seem to be on your own.


Jochen

--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org