From af01cc6d419b7525bfb7a629464c6859bfa8a7f6 Mon Sep 17 00:00:00 2001
From: unknown <tomas@poseidon.mysql.com>
Date: Wed, 21 Feb 2007 11:41:22 +0700
Subject: [PATCH] Bug #26490 duplicate cluster error code - fixed error code -
 added test program run in mysql-test-run bk version

mysql-test/ndb/ndbcluster.sh:
  Bug #26490 duplicate cluster error code
  - added check for duplicate error in mysql-test run
storage/ndb/include/kernel/signaldata/CreateFilegroup.hpp:
  Bug #26490 duplicate cluster error code
  - fixed error code
storage/ndb/src/ndbapi/Makefile.am:
  Bug #26490 duplicate cluster error code
  - added test program for duplicate error messages
storage/ndb/src/ndbapi/ndberror.c:
  Bug #26490 duplicate cluster error code
  - fixed error code
storage/ndb/src/ndbapi/ndberror_check.c:
  New BitKeeper file ``storage/ndb/src/ndbapi/ndberror_check.c''
---
 mysql-test/ndb/ndbcluster.sh                  | 11 +++++-
 .../kernel/signaldata/CreateFilegroup.hpp     |  2 +-
 storage/ndb/src/ndbapi/Makefile.am            |  9 +++++
 storage/ndb/src/ndbapi/ndberror.c             |  2 +-
 storage/ndb/src/ndbapi/ndberror_check.c       | 38 +++++++++++++++++++
 5 files changed, 59 insertions(+), 3 deletions(-)
 create mode 100644 storage/ndb/src/ndbapi/ndberror_check.c

diff --git a/mysql-test/ndb/ndbcluster.sh b/mysql-test/ndb/ndbcluster.sh
index e7fbf1ca8c2..1e25cd8047e 100644
--- a/mysql-test/ndb/ndbcluster.sh
+++ b/mysql-test/ndb/ndbcluster.sh
@@ -35,7 +35,8 @@ if [ -d ../sql ] ; then
    exec_mgmtsrvr=$ndbtop/src/mgmsrv/ndb_mgmd
    exec_waiter=$ndbtop/tools/ndb_waiter
    exec_test=$ndbtop/tools/ndb_test_platform
-   exec_mgmtclient=$ndbtop/src/mgmclient/ndb_mgm
+   exec_test_ndberror=
+   exec_test_ndberror=$ndbtop/src/ndbapi/ndberror_check
 else
    BINARY_DIST=1
    if test -x "$BASEDIR/libexec/ndbd"
@@ -48,6 +49,7 @@ else
    fi
    exec_waiter=$BASEDIR/bin/ndb_waiter
    exec_test=$BASEDIR/bin/ndb_test_platform
+   exec_test_ndberror=
    exec_mgmtclient=$BASEDIR/bin/ndb_mgm
 fi
 
@@ -56,6 +58,13 @@ if $exec_test ; then :; else
   exit 1
 fi
 
+if [ $exec_test_ndberror ] ; then
+if $exec_test_ndberror ; then :; else
+  echo "please fix in ndberror.c"
+  exit 1
+fi
+fi
+
 pidfile=ndbcluster.pid
 cfgfile=Ndb.cfg
 test_ndb=
diff --git a/storage/ndb/include/kernel/signaldata/CreateFilegroup.hpp b/storage/ndb/include/kernel/signaldata/CreateFilegroup.hpp
index d40f3f7d8cb..b1261431a4e 100644
--- a/storage/ndb/include/kernel/signaldata/CreateFilegroup.hpp
+++ b/storage/ndb/include/kernel/signaldata/CreateFilegroup.hpp
@@ -64,7 +64,7 @@ struct CreateFilegroupRef {
     InvalidFormat = 740,
     OutOfFilegroupRecords = 765,
     InvalidExtentSize = 764,
-    InvalidUndoBufferSize = 763,
+    InvalidUndoBufferSize = 779,
     NoSuchLogfileGroup = 767,
     InvalidFilegroupVersion = 768
   };
diff --git a/storage/ndb/src/ndbapi/Makefile.am b/storage/ndb/src/ndbapi/Makefile.am
index 90e61b5b188..8469110fddb 100644
--- a/storage/ndb/src/ndbapi/Makefile.am
+++ b/storage/ndb/src/ndbapi/Makefile.am
@@ -15,6 +15,10 @@
 
 #SUBDIRS = signal-sender
 
+noinst_PROGRAMS = ndberror_check
+
+ndberror_check_SOURCES = ndberror_check.c
+
 noinst_LTLIBRARIES = libndbapi.la
 
 libndbapi_la_SOURCES = \
@@ -61,6 +65,11 @@ NDB_CXXFLAGS_RELEASE_LOC = -O2
 include $(top_srcdir)/storage/ndb/config/common.mk.am
 include $(top_srcdir)/storage/ndb/config/type_ndbapi.mk.am
 
+ndberror_check_LDFLAGS = \
+         $(top_builddir)/dbug/libdbug.a \
+         $(top_builddir)/mysys/libmysys.a \
+         $(top_builddir)/strings/libmystrings.a
+
 # Don't update the files from bitkeeper
 %::SCCS/s.%
 
diff --git a/storage/ndb/src/ndbapi/ndberror.c b/storage/ndb/src/ndbapi/ndberror.c
index 24c79ce1e2c..8e70f5ee250 100644
--- a/storage/ndb/src/ndbapi/ndberror.c
+++ b/storage/ndb/src/ndbapi/ndberror.c
@@ -367,7 +367,7 @@ ErrorBundle ErrorCodes[] = {
   { 771,  HA_WRONG_CREATE_OPTION, AE, "Given NODEGROUP doesn't exist in this cluster" },
   { 772,  HA_WRONG_CREATE_OPTION, IE, "Given fragmentType doesn't exist" },
   { 749,  HA_WRONG_CREATE_OPTION, IE, "Primary Table in wrong state" },
-  { 763,  HA_WRONG_CREATE_OPTION, SE, "Invalid undo buffer size" },
+  { 779,  HA_WRONG_CREATE_OPTION, SE, "Invalid undo buffer size" },
   { 764,  HA_WRONG_CREATE_OPTION, SE, "Invalid extent size" },
   { 765,  DMEC, SE, "Out of filegroup records" },
   { 750,  IE, SE, "Invalid file type" },
diff --git a/storage/ndb/src/ndbapi/ndberror_check.c b/storage/ndb/src/ndbapi/ndberror_check.c
new file mode 100644
index 00000000000..49eb781883a
--- /dev/null
+++ b/storage/ndb/src/ndbapi/ndberror_check.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 2007 MySQL AB
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+#include <stdio.h>
+#include "ndberror.c"
+
+int main()
+{
+  int i, j, error = 0;
+
+  // check for duplicate error codes
+  for(i = 0; i < NbErrorCodes; i++)
+  {
+    for(j = i + 1; j < NbErrorCodes; j++)
+    {
+      if (ErrorCodes[i].code == ErrorCodes[j].code)
+      {
+        fprintf(stderr, "Duplicate error code %u\n", ErrorCodes[i].code);
+        error = 1;
+      }
+    }
+  }
+  if (error)
+    return -1;
+  return 0;
+}
-- 
2.30.9