Bug #21033 Error 0 in readAutoIncrementValue()
Submitted: 13 Jul 2006 12:01 Modified: 26 Feb 2007 2:03
Reporter: Hartmut Holzgraefe Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S3 (Non-critical)
Version:5.0.30-BK, 5.1 OS:
Assigned to: Guangbao Ni CPU Architecture:Any

[13 Jul 2006 12:01] Hartmut Holzgraefe
Description:
"Error 0 in readAutoIncrementValue(): no Error"

is written to the error log whenever SHOW TABLE STATUS 
is performed on a cluster table *without* an auto_increment
field. The code in ha_ndbcluster.cc handling this looks like

  if (flag & HA_STATUS_AUTO)
  {
    DBUG_PRINT("info", ("HA_STATUS_AUTO"));
    if (m_table)
    {
      Ndb *ndb= get_ndb();

      Uint64 auto_increment_value64;
      if (ndb->readAutoIncrementValue((const NDBTAB *) m_table,
                                      auto_increment_value64) == -1)
      {
        const NdbError err= ndb->getNdbError();
        sql_print_error("Error %lu in readAutoIncrementValue(): %s",
                        (ulong) err.code, err.message);
        auto_increment_value= ~(Uint64)0; 
      }
      else
        auto_increment_value= (ulonglong)auto_increment_value64;
    }
  }

so it does not take into account that readAutoIncrementValue can 
return -1 for the simple reason that there is no auto_increment
value on the table to read at all as none is defined.

How to repeat:
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (i int auto_increment primary key) ENGINE=ndb;
SHOW CREATE TABLE LIKE 't1';
DROP TABLE t1;

Suggested fix:
Maybe it's already sufficient to only print the error message
if err.code != 0?
[31 Aug 2006 10:30] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/11156

ChangeSet@1.2279, 2006-08-31 18:29:23+08:00, gni@dev3-127.(none) +1 -0
  BUG#21033  The error log of mysqld shows useless information, and hides the real error.
[10 Oct 2006 18:36] Jonas Oreland
pushed into 5.1.12
[11 Oct 2006 10:15] Jon Stephens
Thank you for your bug report. This issue has been committed to our source repository of that product and will be incorporated into the next release.

If necessary, you can access the source repository and build the latest available version, including the bug fix. More information about accessing the source trees is available at

    http://dev.mysql.com/doc/en/installing-source.html

Documented bugfix in 5.1.12 changelog.
[10 Nov 2006 8:56] Valeriy Kravchuk
Re-opened because version 5.0.x still has the same code:

if (flag & HA_STATUS_AUTO)
{
  DBUG_PRINT("info", ("HA_STATUS_AUTO"));
  if (m_table)
  {
    Ndb *ndb= get_ndb();

    Uint64 auto_increment_value64;
    if (ndb->readAutoIncrementValue((const NDBTAB *) m_table,
                                    auto_increment_value64) == -1)
    {
      const NdbError err= ndb->getNdbError();
      sql_print_error("Error %lu in readAutoIncrementValue(): %s",
                      (ulong) err.code, err.message);
      auto_increment_value= ~(Uint64)0;
    }
    else
      auto_increment_value= (ulonglong)auto_increment_value64;
  }
}

So, it should be also fixed. See also bug #24162 that will be marked as a duplicate of this one.
[29 Nov 2006 9:27] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/16073

ChangeSet@1.2259, 2006-11-29 16:45:18+08:00, gni@dev3-127.(none) +1 -0
  BUG#21033  The error log of mysqld shows useless information, and hides the real error.
[14 Dec 2006 11:18] Guangbao Ni
Approved by pekka, now push mysql-5.0-ndb-bj tree
[14 Dec 2006 11:22] Guangbao Ni
Approved by pekka, now push mysql-5.0-ndb-bj tree
[14 Feb 2007 8:43] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/19845
[21 Feb 2007 15:01] Tomas Ulin
5.0.37,5.1.16,ndb-6.1.3
[26 Feb 2007 2:03] Jon Stephens
Thank you for your bug report. This issue has been committed to our source repository of that product and will be incorporated into the next release.

If necessary, you can access the source repository and build the latest available version, including the bug fix. More information about accessing the source trees is available at

    http://dev.mysql.com/doc/en/installing-source.html

Documented fix in 5.0.38, 5.1.16, and ndb-6.1.3 changelogs.

Noted in 5.1.16 and ndb-6.1.3 changelog entries that this patch supersedes the 5.1.12 fix.