3915 Pekka Nousiainen 2012-09-18
wl#6244 errcode2.diff
create_fks handler error 150 and push warnings
modified:
sql/ha_ndb_ddl_fk.cc
3914 Pekka Nousiainen 2012-09-18
wl#6244 errcode1.diff
add FK error codes for NDB kernel
modified:
mysql-test/suite/ndb/r/ndb_fk_bugs.result
mysql-test/suite/ndb/r/ndb_fk_create_drop.result
mysql-test/suite/ndb/t/ndb_fk_bugs.test
mysql-test/suite/ndb/t/ndb_fk_create_drop.test
storage/ndb/include/kernel/signaldata/BuildFK.hpp
storage/ndb/include/kernel/signaldata/BuildFKImpl.hpp
storage/ndb/include/kernel/signaldata/CreateFK.hpp
storage/ndb/include/kernel/signaldata/CreateFKImpl.hpp
storage/ndb/include/kernel/signaldata/DropFK.hpp
storage/ndb/include/kernel/signaldata/DropFKImpl.hpp
storage/ndb/src/ndbapi/NdbDictionary.cpp
storage/ndb/src/ndbapi/ndberror.c
3913 Pekka Nousiainen 2012-08-30
wl#6244 cleanup-x1
remove find_ndb_fk_tools.inc and enable windows
modified:
mysql-test/suite/ndb/t/ndb_fk_cascade_delete_multi.test
=== modified file 'mysql-test/suite/ndb/r/ndb_fk_bugs.result'
--- a/mysql-test/suite/ndb/r/ndb_fk_bugs.result 2012-05-29 16:39:13 +0000
+++ b/mysql-test/suite/ndb/r/ndb_fk_bugs.result 2012-09-18 09:47:07 +0000
@@ -33,6 +33,10 @@ alter table t2
add constraint fk1 foreign key (b) references t1 (a)
on delete cascade on update cascade;
ERROR HY000: Cannot add foreign key constraint
+show warnings;
+Level Code Message
+Warning 1296 Got error 21000 'Create foreign key failed - parent key is primary key and on-update-cascade is not allowed' from NDB
+Error 150 Cannot add foreign key constraint
alter table t2
add constraint fk1 foreign key (b) references t1 (a)
on delete cascade on update restrict;
=== modified file 'mysql-test/suite/ndb/r/ndb_fk_create_drop.result'
--- a/mysql-test/suite/ndb/r/ndb_fk_create_drop.result 2012-05-16 09:50:51 +0000
+++ b/mysql-test/suite/ndb/r/ndb_fk_create_drop.result 2012-09-18 09:47:07 +0000
@@ -49,11 +49,23 @@ alter offline table child add constraint
alter offline table child add constraint fk8 foreign key (a) references parent(c);
alter offline table child add constraint fk9 foreign key (a) references parent(c);
alter online table child add constraint fk7 foreign key (a) references parent(c);
-ERROR HY000: Unknown error 700
+ERROR HY000: Cannot add foreign key constraint
+show warnings;
+Level Code Message
+Warning 1296 Got error 21026 'Create foreign key failed in NDB - parent index is not unique index' from NDB
+Error 150 Cannot add foreign key constraint
alter online table child add constraint fk8 foreign key (a) references parent(c);
-ERROR HY000: Unknown error 700
+ERROR HY000: Cannot add foreign key constraint
+show warnings;
+Level Code Message
+Warning 1296 Got error 21026 'Create foreign key failed in NDB - parent index is not unique index' from NDB
+Error 150 Cannot add foreign key constraint
alter online table child add constraint fk9 foreign key (a) references parent(c);
-ERROR HY000: Unknown error 700
+ERROR HY000: Cannot add foreign key constraint
+show warnings;
+Level Code Message
+Warning 1296 Got error 21026 'Create foreign key failed in NDB - parent index is not unique index' from NDB
+Error 150 Cannot add foreign key constraint
drop table parent, child;
create table parent (
a int primary key,
=== modified file 'mysql-test/suite/ndb/t/ndb_fk_bugs.test'
--- a/mysql-test/suite/ndb/t/ndb_fk_bugs.test 2012-07-13 11:05:01 +0000
+++ b/mysql-test/suite/ndb/t/ndb_fk_bugs.test 2012-09-18 09:47:07 +0000
@@ -49,6 +49,7 @@ create table t2 (
alter table t2
add constraint fk1 foreign key (b) references t1 (a)
on delete cascade on update cascade;
+show warnings;
alter table t2
add constraint fk1 foreign key (b) references t1 (a)
=== modified file 'mysql-test/suite/ndb/t/ndb_fk_create_drop.test'
--- a/mysql-test/suite/ndb/t/ndb_fk_create_drop.test 2012-07-13 11:05:01 +0000
+++ b/mysql-test/suite/ndb/t/ndb_fk_create_drop.test 2012-09-18 09:47:07 +0000
@@ -51,12 +51,15 @@ alter offline table child add constraint
--enable_result_log
---error 700
+--error 150
alter online table child add constraint fk7 foreign key (a) references parent(c);
---error 700
+show warnings;
+--error 150
alter online table child add constraint fk8 foreign key (a) references parent(c);
---error 700
+show warnings;
+--error 150
alter online table child add constraint fk9 foreign key (a) references parent(c);
+show warnings;
drop table parent, child;
=== modified file 'sql/ha_ndb_ddl_fk.cc'
--- a/sql/ha_ndb_ddl_fk.cc 2012-08-30 12:55:24 +0000
+++ b/sql/ha_ndb_ddl_fk.cc 2012-09-18 09:47:44 +0000
@@ -224,7 +224,7 @@ ha_ndbcluster::create_fks(THD *thd, Ndb
DBUG_ENTER("ha_ndbcluster::create_fks");
// return real mysql error to avoid total randomness..
- const int er_default= ER_CANNOT_ADD_FOREIGN;
+ const int err_default= HA_ERR_CANNOT_ADD_FOREIGN;
char tmpbuf[FN_REFLEN];
assert(thd->lex != 0);
@@ -264,7 +264,11 @@ ha_ndbcluster::create_fks(THD *thd, Ndb
tmpbuf, sizeof(tmpbuf)));
if (ndbcol == 0)
{
- DBUG_RETURN(er_default); // TODO suitable error code
+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
+ ER_CANNOT_ADD_FOREIGN,
+ "Child table %s has no column %s in NDB",
+ child_tab.get_table()->getName(), tmpbuf);
+ DBUG_RETURN(err_default);
}
childcols[pos++]= ndbcol;
}
@@ -279,7 +283,11 @@ ha_ndbcluster::create_fks(THD *thd, Ndb
if (!child_primary_key && child_index == 0)
{
- DBUG_RETURN(er_default); // TODO suitable error code
+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
+ ER_CANNOT_ADD_FOREIGN,
+ "Child table %s foreign key columns match no index in NDB",
+ child_tab.get_table()->getName());
+ DBUG_RETURN(err_default);
}
Ndb_db_guard db_guard(ndb); // save db
@@ -325,7 +333,11 @@ ha_ndbcluster::create_fks(THD *thd, Ndb
tmpbuf, sizeof(tmpbuf)));
if (ndbcol == 0)
{
- DBUG_RETURN(er_default); // TODO suitable error code
+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
+ ER_CANNOT_ADD_FOREIGN,
+ "Parent table %s has no column %s in NDB",
+ parent_tab.get_table()->getName(), tmpbuf);
+ DBUG_RETURN(err_default);
}
parentcols[pos++]= ndbcol;
}
@@ -342,7 +354,11 @@ ha_ndbcluster::create_fks(THD *thd, Ndb
if (!parent_primary_key && parent_index == 0)
{
- DBUG_RETURN(er_default); // TODO suitable error code
+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
+ ER_CANNOT_ADD_FOREIGN,
+ "Parent table %s foreign key columns match no index in NDB",
+ parent_tab.get_table()->getName());
+ DBUG_RETURN(err_default);
}
NdbDictionary::ForeignKey ndbfk;
=== modified file 'storage/ndb/include/kernel/signaldata/BuildFK.hpp'
--- a/storage/ndb/include/kernel/signaldata/BuildFK.hpp 2012-05-16 09:49:18 +0000
+++ b/storage/ndb/include/kernel/signaldata/BuildFK.hpp 2012-09-18 09:47:07 +0000
@@ -66,8 +66,8 @@ struct BuildFKRef
enum ErrorCode {
NoError = 0,
- FKNotFound = 700,
- InvalidFKVersion = 700
+ FKNotFound = 21060,
+ InvalidFKVersion = 21061
};
Uint32 senderData;
=== modified file 'storage/ndb/include/kernel/signaldata/BuildFKImpl.hpp'
--- a/storage/ndb/include/kernel/signaldata/BuildFKImpl.hpp 2012-05-16 09:49:18 +0000
+++ b/storage/ndb/include/kernel/signaldata/BuildFKImpl.hpp 2012-09-18 09:47:07 +0000
@@ -69,6 +69,10 @@ struct BuildFKImplRef
STATIC_CONST( SignalLength = 3 );
+ enum ErrorCode {
+ NoError = 0
+ };
+
Uint32 senderData;
Uint32 senderRef;
Uint32 errorCode;
=== modified file 'storage/ndb/include/kernel/signaldata/CreateFK.hpp'
--- a/storage/ndb/include/kernel/signaldata/CreateFK.hpp 2012-05-16 09:00:24 +0000
+++ b/storage/ndb/include/kernel/signaldata/CreateFK.hpp 2012-09-18 09:47:07 +0000
@@ -72,16 +72,16 @@ struct CreateFKRef
NoError = 0,
Busy = 701,
NotMaster = 702,
- NoMoreObjectRecords = 710,
- InvalidFormat = 740,
- ParentTableIsNotATable = 700,
- InvalidParentTableVersion = 700,
- ChildTableIsNotATable = 700,
- InvalidChildTableVersion = 700,
- ParentIndexIsNotAnUniqueIndex = 700,
- InvalidParentIndexVersion = 700,
- ChildIndexIsNotAnIndex = 700,
- InvalidChildIndexVersion = 700,
+ NoMoreObjectRecords = 21020,
+ InvalidFormat = 21021,
+ ParentTableIsNotATable = 21022,
+ InvalidParentTableVersion = 21023,
+ ChildTableIsNotATable = 21024,
+ InvalidChildTableVersion = 21025,
+ ParentIndexIsNotAnUniqueIndex = 21026,
+ InvalidParentIndexVersion = 21027,
+ ChildIndexIsNotAnIndex = 21028,
+ InvalidChildIndexVersion = 21029,
NoMoreTableRecords = 707,
ObjectAlreadyExist = 721,
OutOfStringBuffer = 773
=== modified file 'storage/ndb/include/kernel/signaldata/CreateFKImpl.hpp'
--- a/storage/ndb/include/kernel/signaldata/CreateFKImpl.hpp 2012-05-16 09:57:31 +0000
+++ b/storage/ndb/include/kernel/signaldata/CreateFKImpl.hpp 2012-09-18 09:47:07 +0000
@@ -117,9 +117,9 @@ struct CreateFKImplRef
enum ErrCode
{
- ObjectAlreadyExist = 700,
- NoMoreObjectRecords = 700,
- InvalidFormat = 700
+ ObjectAlreadyExist = 21030,
+ NoMoreObjectRecords = 21031,
+ InvalidFormat = 21032
};
};
=== modified file 'storage/ndb/include/kernel/signaldata/DropFK.hpp'
--- a/storage/ndb/include/kernel/signaldata/DropFK.hpp 2012-05-16 09:26:36 +0000
+++ b/storage/ndb/include/kernel/signaldata/DropFK.hpp 2012-09-18 09:47:07 +0000
@@ -74,10 +74,8 @@ struct DropFKRef
NoError = 0,
Busy = 701,
NotMaster = 702,
- NoMoreObjectRecords = 710,
- InvalidFormat = 740,
- FKNotFound = 709,
- InvalidFKVersion = 241
+ FKNotFound = 21040,
+ InvalidFKVersion = 21041
};
Uint32 senderData;
=== modified file 'storage/ndb/include/kernel/signaldata/DropFKImpl.hpp'
--- a/storage/ndb/include/kernel/signaldata/DropFKImpl.hpp 2012-05-16 09:52:00 +0000
+++ b/storage/ndb/include/kernel/signaldata/DropFKImpl.hpp 2012-09-18 09:47:07 +0000
@@ -70,7 +70,7 @@ struct DropFKImplRef
enum ErrCode
{
- NoSuchObject = 700
+ NoSuchObject = 21042
};
};
=== modified file 'storage/ndb/src/ndbapi/NdbDictionary.cpp'
--- a/storage/ndb/src/ndbapi/NdbDictionary.cpp 2012-07-09 12:22:46 +0000
+++ b/storage/ndb/src/ndbapi/NdbDictionary.cpp 2012-09-18 09:47:07 +0000
@@ -3923,7 +3923,7 @@ NdbDictionary::Dictionary::createForeign
if (fk.getParentIndex() == 0 // primary key
&& fk.getOnUpdateAction() == NdbDictionary::ForeignKey::Cascade)
{
- m_impl.m_error.code = 21001;
+ m_impl.m_error.code = 21000;
return -1;
}
=== modified file 'storage/ndb/src/ndbapi/ndberror.c'
--- a/storage/ndb/src/ndbapi/ndberror.c 2012-07-13 11:12:25 +0000
+++ b/storage/ndb/src/ndbapi/ndberror.c 2012-09-18 09:47:07 +0000
@@ -172,8 +172,28 @@ ErrorBundle ErrorCodes[] = {
/**
* DICT FK kernel and ndbapi error codes
*/
- { 21001, HA_ERR_CANNOT_ADD_FOREIGN, AE, "Foreign key create failed: parent key is primary key: on-update-cascade is currently not allowed" },
-
+ { 21000, HA_ERR_CANNOT_ADD_FOREIGN, AE, "Create foreign key failed - parent key is primary key and on-update-cascade is not allowed" },
+ /* CreateFKRef + CreateFKImplRef */
+ { 21020, DMEC, TR, "Create foreign key failed in NDB - no more object records" },
+ { 21021, DMEC, IE, "Create foreign key failed in NDB - invalid request" },
+ { 21022, DMEC, SE, "Create foreign key failed in NDB - parent table is not table" },
+ { 21023, DMEC, SE, "Create foreign key failed in NDB - invalid parent table version" },
+ { 21024, DMEC, SE, "Create foreign key failed in NDB - child table is not table" },
+ { 21025, DMEC, SE, "Create foreign key failed in NDB - invalid child table version" },
+ { 21026, HA_ERR_CANNOT_ADD_FOREIGN, AE, "Create foreign key failed in NDB - parent index is not unique index" },
+ { 21027, DMEC, SE, "Create foreign key failed in NDB - invalid parent index version" },
+ { 21028, DMEC, SE, "Create foreign key failed in NDB - child index is not index" },
+ { 21029, DMEC, SE, "Create foreign key failed in NDB - invalid child index version" },
+ { 21030, DMEC, IE, "Create foreign key failed in NDB - object already exists in TC" },
+ { 21031, DMEC, IE, "Create foreign key failed in NDB - no more object records in TC" },
+ { 21032, DMEC, IE, "Create foreign key failed in NDB - invalid request to TC" },
+ /* DropFKRef + DropFKImplRef */
+ { 21040, DMEC, AE, "Drop foreign key failed in NDB - foreign key not found" },
+ { 21041, DMEC, SE, "Drop foreign key failed in NDB - invalid foreign key version" },
+ { 21042, DMEC, SE, "Drop foreign key failed in NDB - foreign key not found in TC" },
+ /* BuildFKRef + BuildFKImplRef */
+ { 21060, DMEC, AE, "Build foreign key failed in NDB - foreign key not found" },
+ { 21061, DMEC, SE, "Build foreign key failed in NDB - invalid foreign key version" },
/**
* Node shutdown
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-5.5-cluster-7.3-fk branch (pekka.nousiainen:3913 to3915) WL#6244 | Pekka Nousiainen | 19 Sep |