List:Internals« Previous MessageNext Message »
From:Michael Widenius Date:October 4 2008 8:22am
Subject:re: mysql_warning_count() always returns 0
View as plain text  
Hi!

>>>>> "Sunny" == Sunny Bains <Sunny.Bains@stripped> writes:

Sunny> Hi,
Sunny> I'm using push_warning() in the auto-inc code to send an error
Sunny> message that describes the cause of the failure to generate
Sunny> the next auto-inc value like so:


Sunny> +                       push_warning(
Sunny> +                               thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
Sunny> +                               ER_LOCK_DEADLOCK,
Sunny> +                               "InnoDB: Deadlock in "
Sunny>                                 "innobase_get_auto_increment()");

Sunny> In my test program I have something like this:


Sunny>         if (mysql_query(dbc,sql) != 0) {

Sunny>                 printf("query failed '%s' : %d (%s), warn: %d\n",
Sunny>                         sql,
Sunny>                         mysql_errno(dbc),
Sunny>                         mysql_error(dbc),
Sunny>                         mysql_warning_count(dbc));
Sunny>        }

Sunny> But the function mysql_warning_count() always returns 0. If I print
Sunny> the result of "SHOW WARNINGS" however, it prints the above error
Sunny> message that was pushed by InnoDB along with the error message
Sunny> that was pushed by the MySQL layer.

Sunny> e.g.,

Sunny> query failed 'insert into `qa05` (`d`) values ('30')' : 1467 (Failed to 
Sunny> read auto-increment value from storage engine), warn: 0
Sunny> Level   Code    Message
Sunny> ------------------------------------
Sunny> Error   1213    InnoDB: Deadlock in innobase_get_auto_increment()
Sunny> Error   1467    Failed to read auto-increment value from storage engine

Sunny> Is this a known bug ? What am I doing wrong ?

The problem is that mysql_warning_count() is not set in case of errors.

Regards,
Monty
Thread
mysql_warning_count() always returns 0Sunny Bains2 Oct
  • re: mysql_warning_count() always returns 0Michael Widenius4 Oct
    • Re: mysql_warning_count() always returns 0Sunny Bains4 Oct
      • Re: mysql_warning_count() always returns 0Antony T Curtis4 Oct
        • Re: mysql_warning_count() always returns 0Sunny Bains5 Oct
    • Re: mysql_warning_count() always returns 0Sunny Bains6 Oct
  • push_warning() strange effect? [Re: mysql_warning_count() alwaysreturns 0]Vasil Dimov20 Oct
    • Re: push_warning() strange effect? [Re: mysql_warning_count() alwaysreturns 0]Davi Arnaut20 Oct
    • Re: push_warning() strange effect? [Re: mysql_warning_count() alwaysreturns 0]Davi Arnaut20 Oct
      • Re: push_warning() strange effect? [Re: mysql_warning_count()always returns 0]Vasil Dimov21 Oct