-
Magnus Blåudd authored
Faulty error message is returned when CREATE TABLE fails to create the table or other object in NDB. For example the error "Table 'x' dosen't exist" may be returned. This patch changes the implementation to return the NDB error as a warning and then setting a "Can't create table 'x'" error in most cases. Thus it should be possible for the user to figure out what went wrong by using SHOW WARNINGS after a failed CREATE TABLE. The problem is caused by the generic mapping tables inside the NdbApi which are used by ndb_to_mysql_error(). It's not possible to fix the problem by changing the mapping tables since how to map an error code depends on the context which the function failed. For example a "No such table" error may make sense for an INSERT but not for a CREATE TABLE. The error handling in ha_ndbcluster::create() is extracted into a helper class in order to eliminate duplicated boiler plate code as well as allowing some automatic verification of the behavior when an error is returned. The default behavior is that at least one warning should be pushed together with the error, but for a few cases where the error is descriptive enough, it's allowed to be returned without any prior warning. When an error occurs this is the steps that should normally be done: 1) Push the NDB error or other description of the actual error that occurred as a warning. 2) Report the error "Can't create table '<table_name>'" or "Can't create destination table for copying alter table" if the table is created as part of copying ALTER TABLE. Exceptions to the above steps are done for errors which occur due to illegal or missing create options detected, which have error coded that are specific enough to be set without any preceeding warning. But, it's allowed (and possible) to push more descriptive warnings also for those errors. The end goal should be that it's easy for the user to figure out the cause of the error by using SHOW WARNINGS. Change-Id: I980b7bed234f2fc3acf8c39545f0e68f87e628a9
Magnus Blåudd authoredFaulty error message is returned when CREATE TABLE fails to create the table or other object in NDB. For example the error "Table 'x' dosen't exist" may be returned. This patch changes the implementation to return the NDB error as a warning and then setting a "Can't create table 'x'" error in most cases. Thus it should be possible for the user to figure out what went wrong by using SHOW WARNINGS after a failed CREATE TABLE. The problem is caused by the generic mapping tables inside the NdbApi which are used by ndb_to_mysql_error(). It's not possible to fix the problem by changing the mapping tables since how to map an error code depends on the context which the function failed. For example a "No such table" error may make sense for an INSERT but not for a CREATE TABLE. The error handling in ha_ndbcluster::create() is extracted into a helper class in order to eliminate duplicated boiler plate code as well as allowing some automatic verification of the behavior when an error is returned. The default behavior is that at least one warning should be pushed together with the error, but for a few cases where the error is descriptive enough, it's allowed to be returned without any prior warning. When an error occurs this is the steps that should normally be done: 1) Push the NDB error or other description of the actual error that occurred as a warning. 2) Report the error "Can't create table '<table_name>'" or "Can't create destination table for copying alter table" if the table is created as part of copying ALTER TABLE. Exceptions to the above steps are done for errors which occur due to illegal or missing create options detected, which have error coded that are specific enough to be set without any preceeding warning. But, it's allowed (and possible) to push more descriptive warnings also for those errors. The end goal should be that it's easy for the user to figure out the cause of the error by using SHOW WARNINGS. Change-Id: I980b7bed234f2fc3acf8c39545f0e68f87e628a9
Loading