Commit 1ec93c96 authored by unknown's avatar unknown

WL #1729 Handler: error text for NDB errors

- New solution after discussions with Sergei, no handler specific code or error messages should be in sql layer.
next_result, only check for error if check is -1
Improved index_read 


include/mysqld_error.h:
  New error codes ER_GET_ERRMSG and ER_GET_TEMPORARY_ERRMSG, update number to 298.
  Removed prevoius ER_NDB_ERROR, handler specific error should not be here.
sql/ha_ndbcluster.cc:
  Removed print_error from ha_ndbcluster, added code to handler::print_error to ask  handler::get_error_message for message for an error.
  Fix bug in next_result, only check for error if -1 is returned.
  Make index_read easier, special case where pk_read or unique_index_read is detected and as default do ordered_index_scan
sql/ha_ndbcluster.h:
  Remplace print_error with get_error_message
sql/handler.cc:
  Add new function get_error_message usedc to ask handler for a message for an error.
  Call get_error_message from print_error if error code is not known.
sql/handler.h:
  Add new function get_error_message
sql/share/czech/errmsg.txt:
  Error message for ER_GET_ERRMSG and ER_GET_TEMPORARY_ERRMSG
sql/share/danish/errmsg.txt:
  Error message for ER_GET_ERRMSG and ER_GET_TEMPORARY_ERRMSG
sql/share/dutch/errmsg.txt:
  Error message for ER_GET_ERRMSG and ER_GET_TEMPORARY_ERRMSG
sql/share/english/errmsg.txt:
  Error message for ER_GET_ERRMSG and ER_GET_TEMPORARY_ERRMSG
sql/share/estonian/errmsg.txt:
  Error message for ER_GET_ERRMSG and ER_GET_TEMPORARY_ERRMSG
sql/share/french/errmsg.txt:
  Error message for ER_GET_ERRMSG and ER_GET_TEMPORARY_ERRMSG
sql/share/german/errmsg.txt:
  Error message for ER_GET_ERRMSG and ER_GET_TEMPORARY_ERRMSG
sql/share/greek/errmsg.txt:
  Error message for ER_GET_ERRMSG and ER_GET_TEMPORARY_ERRMSG
sql/share/hungarian/errmsg.txt:
  Error message for ER_GET_ERRMSG and ER_GET_TEMPORARY_ERRMSG
sql/share/italian/errmsg.txt:
  Error message for ER_GET_ERRMSG and ER_GET_TEMPORARY_ERRMSG
sql/share/korean/errmsg.txt:
  Error message for ER_GET_ERRMSG and ER_GET_TEMPORARY_ERRMSG
sql/share/norwegian-ny/errmsg.txt:
  Error message for ER_GET_ERRMSG and ER_GET_TEMPORARY_ERRMSG
sql/share/norwegian/errmsg.txt:
  Error message for ER_GET_ERRMSG and ER_GET_TEMPORARY_ERRMSG
sql/share/polish/errmsg.txt:
  Error message for ER_GET_ERRMSG and ER_GET_TEMPORARY_ERRMSG
sql/share/portuguese/errmsg.txt:
  Error message for ER_GET_ERRMSG and ER_GET_TEMPORARY_ERRMSG
sql/share/romanian/errmsg.txt:
  Error message for ER_GET_ERRMSG and ER_GET_TEMPORARY_ERRMSG
sql/share/russian/errmsg.txt:
  Error message for ER_GET_ERRMSG and ER_GET_TEMPORARY_ERRMSG
sql/share/serbian/errmsg.txt:
  Error message for ER_GET_ERRMSG and ER_GET_TEMPORARY_ERRMSG
sql/share/slovak/errmsg.txt:
  Error message for ER_GET_ERRMSG and ER_GET_TEMPORARY_ERRMSG
sql/share/spanish/errmsg.txt:
  Error message for ER_GET_ERRMSG and ER_GET_TEMPORARY_ERRMSG
sql/share/swedish/errmsg.txt:
  Error message for ER_GET_ERRMSG and ER_GET_TEMPORARY_ERRMSG
sql/share/ukrainian/errmsg.txt:
  Error message for ER_GET_ERRMSG and ER_GET_TEMPORARY_ERRMSG
parent 571ea58b
......@@ -312,6 +312,6 @@
#define ER_TOO_MUCH_AUTO_TIMESTAMP_COLS 1293
#define ER_INVALID_ON_UPDATE 1294
#define ER_UNSUPPORTED_PS 1295
#define ER_NDB_ERROR 1296
#define ER_NDB_TEMPORARY_ERROR 1297
#define ER_ERROR_MESSAGES 296
#define ER_GET_ERRMSG 1296
#define ER_GET_TEMPORARY_ERRMSG 1297
#define ER_ERROR_MESSAGES 298
......@@ -41,6 +41,14 @@
static const int parallelism= 240;
#define NDB_HIDDEN_PRIMARY_KEY_LENGTH 8
/*
All error messages returned from ha_ndbcluster that are
not mapped to the corresponding handler(HA_ERR_*) error code
have NDB_ERR_CODE_OFFSET added to it so that it does not clash with
the handler error codes. The error number is then "restored"
to the original error number when get_error_message is called.
*/
#define NDB_ERR_CODE_OFFSET 30000
#define ERR_PRINT(err) \
......@@ -161,27 +169,28 @@ int ha_ndbcluster::ndb_err(NdbConnection *trans)
/*
Override the default print_error in order to add the
Override the default get_error_message in order to add the
error message of NDB
*/
void ha_ndbcluster::print_error(int error, myf errflag)
const char* ha_ndbcluster::get_error_message(int *org_error,
bool *temporary)
{
DBUG_ENTER("ha_ndbcluster::print_error");
DBUG_PRINT("enter", ("error: %d, errflag: %d", error, errflag));
DBUG_ENTER("ha_ndbcluster::get_error_message");
DBUG_PRINT("enter", ("error: %d", *org_error));
if (error >= NDB_ERR_CODE_OFFSET)
{
error-= NDB_ERR_CODE_OFFSET;
const NdbError err= g_ndb->getNdbError(error);
int textno= (err.status==NdbError::TemporaryError) ?
ER_NDB_TEMPORARY_ERROR : ER_NDB_ERROR;
my_error(textno,MYF(0),error,err.message);
DBUG_VOID_RETURN;
}
handler::print_error(error, errflag);
DBUG_VOID_RETURN;
int error= *org_error;
if (error < NDB_ERR_CODE_OFFSET)
DBUG_RETURN(NULL);
error-= NDB_ERR_CODE_OFFSET;
DBUG_ASSERT(m_ndb); // What should be done if not m_ndb is available?
const NdbError err= m_ndb->getNdbError(error);
*temporary= (err.status==NdbError::TemporaryError);
*org_error= error;
DBUG_PRINT("exit", ("error: %d, msg: %s", error, err.message));
DBUG_RETURN(err.message);
}
......@@ -756,8 +765,8 @@ inline int ha_ndbcluster::next_result(byte *buf)
} while (check == 2);
table->status= STATUS_NOT_FOUND;
if (ndb_err(trans))
ERR_RETURN(trans->getNdbError());
if (check == -1)
DBUG_RETURN(ndb_err(trans));
// No more records
DBUG_PRINT("info", ("No more records"));
......@@ -1499,28 +1508,26 @@ int ha_ndbcluster::index_read(byte *buf,
switch (get_index_type(active_index)){
case PRIMARY_KEY_INDEX:
#ifdef USE_EXTRA_ORDERED_INDEX
key_info= table->key_info + active_index;
if (key_len < key_info->key_length ||
find_flag != HA_READ_KEY_EXACT)
if (key_len == key_info->key_length &&
find_flag == HA_READ_KEY_EXACT)
error= pk_read(key, key_len, buf);
else
{
key_range start_key;
start_key.key= key;
start_key.length= key_len;
start_key.flag= find_flag;
error= ordered_index_scan(&start_key, 0, false, buf);
break;
error= ordered_index_scan(&start_key, 0, false, buf);
}
#endif
error= pk_read(key, key_len, buf);
break;
case UNIQUE_INDEX:
#ifdef USE_EXTRA_ORDERED_INDEX
key_info= table->key_info + active_index;
if (key_len < key_info->key_length ||
find_flag != HA_READ_KEY_EXACT)
if (key_len == key_info->key_length &&
find_flag == HA_READ_KEY_EXACT)
error= unique_index_read(key, key_len, buf);
else
{
key_range start_key;
start_key.key= key;
......@@ -1529,8 +1536,6 @@ int ha_ndbcluster::index_read(byte *buf,
error= ordered_index_scan(&start_key, 0, false, buf);
break;
}
#endif
error= unique_index_read(key, key_len, buf);
break;
case ORDERED_INDEX:
......@@ -3105,6 +3110,13 @@ ha_ndbcluster::records_in_range(int inx,
I.e. the ordered index are used instead of the hash indexes for
these queries.
*/
NDB_INDEX_TYPE idx_type= get_index_type(inx);
if ((idx_type == UNIQUE_INDEX || idx_type == PRIMARY_KEY_INDEX) &&
start_key_len == key_length)
{
// this is a "const" table which returns only one record!
records= 1;
}
#endif
DBUG_RETURN(records);
}
......
......@@ -81,7 +81,7 @@ class ha_ndbcluster: public handler
bool sorted);
int read_range_next(bool eq_range);
void print_error(int error, myf errflag);
const char* get_error_message(int *error, bool *temporary);
void info(uint);
int extra(enum ha_extra_function operation);
int extra_opt(enum ha_extra_function operation, ulong cache_size);
......
......@@ -1120,7 +1120,20 @@ void handler::print_error(int error, myf errflag)
break;
default:
{
my_error(ER_GET_ERRNO,errflag,error);
/* The error was "unknown" to this function.
Ask handler if it has got a message for this error */
bool temporary= FALSE;
const char* msg= get_error_message(&error, &temporary);
if (msg)
{
const char* engine= ha_get_storage_engine(table->db_type);
if (temporary)
my_error(ER_GET_TEMPORARY_ERRMSG,error,msg,engine);
else
my_error(ER_GET_ERRMSG,error,msg,engine);
}
else
my_error(ER_GET_ERRNO,errflag,error);
DBUG_VOID_RETURN;
}
}
......@@ -1129,6 +1142,22 @@ void handler::print_error(int error, myf errflag)
}
/*
Return an error message specific to this handler
SYNOPSIS
error [in/out] error code previously returned by handler
temporary [out] temporary error, transaction should be retried if true
The returned pointer to error message should not be freed.
*/
const char* handler::get_error_message(int *error, bool *temporary)
{
return NULL;
}
/* Return key if error because of duplicated keys */
uint handler::get_dup_key(int error)
......
......@@ -295,6 +295,7 @@ class handler :public Sql_alloc
void update_timestamp(byte *record);
void update_auto_increment();
virtual void print_error(int error, myf errflag);
virtual const char* get_error_message(int *error, bool *temporary);
uint get_dup_key(int error);
void change_table_ptr(TABLE *table_arg) { table=table_arg; }
virtual double scan_time()
......
......@@ -310,3 +310,5 @@ character-set=latin2
"This command is not supported in the prepared statement protocol yet",
"Got NDB error %d '%-.100s'",
"Got temporary NDB error %d '%-.100s'",
"Got error %d '%-.100s' from %s",
"Got temporary error %d '%-.100s' from %s",
......@@ -302,5 +302,5 @@ character-set=latin1
"Incorrect table definition; There can only be one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause"
"Invalid ON UPDATE clause for '%-.64s' field",
"This command is not supported in the prepared statement protocol yet",
"Got NDB error %d '%-.100s'",
"Got temporary NDB error %d '%-.100s'",
"Modtog fejl %d '%-.100s' fra %s",
"Modtog temporary fejl %d '%-.100s' fra %s",
......@@ -310,5 +310,5 @@ character-set=latin1
"Incorrect table definition; There can only be one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause"
"Invalid ON UPDATE clause for '%-.64s' field",
"This command is not supported in the prepared statement protocol yet",
"Got NDB error %d '%-.100s'",
"Got temporary NDB error %d '%-.100s'",
"Got error %d '%-.100s' from %s",
"Got temporary error %d '%-.100s' from %s",
......@@ -299,5 +299,5 @@ character-set=latin1
"Incorrect table definition; There can only be one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause"
"Invalid ON UPDATE clause for '%-.64s' field",
"This command is not supported in the prepared statement protocol yet",
"Got NDB error %d '%-.100s'",
"Got temporary NDB error %d '%-.100s'",
"Got error %d '%-.100s' from %s",
"Got temporary error %d '%-.100s' from %s",
......@@ -304,5 +304,5 @@ character-set=latin7
"Incorrect table definition; There can only be one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause"
"Invalid ON UPDATE clause for '%-.64s' field",
"This command is not supported in the prepared statement protocol yet",
"Got NDB error %d '%-.100s'",
"Got temporary NDB error %d '%-.100s'",
"Got error %d '%-.100s' from %s",
"Got temporary error %d '%-.100s' from %s",
......@@ -299,5 +299,5 @@ character-set=latin1
"Incorrect table definition; There can only be one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause"
"Invalid ON UPDATE clause for '%-.64s' field",
"This command is not supported in the prepared statement protocol yet",
"Got NDB error %d '%-.100s'",
"Got temporary NDB error %d '%-.100s'",
"Got error %d '%-.100s' from %s",
"Got temporary error %d '%-.100s' from %s",
......@@ -311,5 +311,5 @@ character-set=latin1
"Incorrect table definition; There can only be one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause"
"Invalid ON UPDATE clause for '%-.64s' field",
"This command is not supported in the prepared statement protocol yet",
"Got NDB error %d '%-.100s'",
"Got temporary NDB error %d '%-.100s'",
"Got error %d '%-.100s' from %s",
"Got temporary error %d '%-.100s' from %s",
......@@ -299,5 +299,5 @@ character-set=greek
"Incorrect table definition; There can only be one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause"
"Invalid ON UPDATE clause for '%-.64s' field",
"This command is not supported in the prepared statement protocol yet",
"Got NDB error %d '%-.100s'",
"Got temporary NDB error %d '%-.100s'",
"Got error %d '%-.100s' from %s",
"Got temporary error %d '%-.100s' from %s",
......@@ -301,5 +301,5 @@ character-set=latin2
"Incorrect table definition; There can only be one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause"
"Invalid ON UPDATE clause for '%-.64s' field",
"This command is not supported in the prepared statement protocol yet",
"Got NDB error %d '%-.100s'",
"Got temporary NDB error %d '%-.100s'",
"Got error %d '%-.100s' from %s",
"Got temporary error %d '%-.100s' from %s",
......@@ -299,5 +299,5 @@ character-set=latin1
"Incorrect table definition; There can only be one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause"
"Invalid ON UPDATE clause for '%-.64s' field",
"This command is not supported in the prepared statement protocol yet",
"Got NDB error %d '%-.100s'",
"Got temporary NDB error %d '%-.100s'",
"Got error %d '%-.100s' from %s",
"Got temporary error %d '%-.100s' from %s",
......@@ -299,5 +299,5 @@ character-set=euckr
"Incorrect table definition; There can only be one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause"
"Invalid ON UPDATE clause for '%-.64s' field",
"This command is not supported in the prepared statement protocol yet",
"Got NDB error %d '%-.100s'",
"Got temporary NDB error %d '%-.100s'",
"Got error %d '%-.100s' from %s",
"Got temporary error %d '%-.100s' from %s",
......@@ -301,5 +301,5 @@ character-set=latin1
"Incorrect table definition; There can only be one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause"
"Invalid ON UPDATE clause for '%-.64s' field",
"This command is not supported in the prepared statement protocol yet",
"Got NDB error %d '%-.100s'",
"Got temporary NDB error %d '%-.100s'",
"Mottok feil %d '%-.100s' fra %s",
"Mottok temporary feil %d '%-.100s' fra %s",
......@@ -301,5 +301,5 @@ character-set=latin1
"Incorrect table definition; There can only be one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause"
"Invalid ON UPDATE clause for '%-.64s' field",
"This command is not supported in the prepared statement protocol yet",
"Got NDB error %d '%-.100s'",
"Got temporary NDB error %d '%-.100s'",
"Mottok feil %d '%-.100s' fa %s",
"Mottok temporary feil %d '%-.100s' fra %s",
......@@ -303,5 +303,5 @@ character-set=latin2
"Incorrect table definition; There can only be one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause"
"Invalid ON UPDATE clause for '%-.64s' field",
"This command is not supported in the prepared statement protocol yet",
"Got NDB error %d '%-.100s'",
"Got temporary NDB error %d '%-.100s'",
"Got error %d '%-.100s' from %s",
"Got temporary error %d '%-.100s' from %s",
......@@ -300,5 +300,5 @@ character-set=latin1
"Incorreta definição de tabela; Pode ter somente uma coluna TIMESTAMP com CURRENT_TIMESTAMP em DEFAULT ou ON UPDATE cláusula"
"Inválida cláusula ON UPDATE para campo '%-.64s'",
"This command is not supported in the prepared statement protocol yet",
"Got NDB error %d '%-.100s'",
"Got temporary NDB error %d '%-.100s'",
"Got error %d '%-.100s' from %s",
"Got temporary error %d '%-.100s' from %s",
......@@ -303,5 +303,5 @@ character-set=latin2
"Incorrect table definition; There can only be one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause"
"Invalid ON UPDATE clause for '%-.64s' field",
"This command is not supported in the prepared statement protocol yet",
"Got NDB error %d '%-.100s'",
"Got temporary NDB error %d '%-.100s'",
"Got error %d '%-.100s' from %s",
"Got temporary error %d '%-.100s' from %s",
......@@ -301,5 +301,5 @@ character-set=koi8r
"Incorrect table definition; There can only be one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause"
"Invalid ON UPDATE clause for '%-.64s' field",
"This command is not supported in the prepared statement protocol yet",
"Got NDB error %d '%-.100s'",
"Got temporary NDB error %d '%-.100s'",
"Got error %d '%-.100s' from %s",
"Got temporary error %d '%-.100s' from %s",
......@@ -293,5 +293,5 @@ character-set=cp1250
"Incorrect table definition; There can only be one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause"
"Invalid ON UPDATE clause for '%-.64s' field",
"This command is not supported in the prepared statement protocol yet",
"Got NDB error %d '%-.100s'",
"Got temporary NDB error %d '%-.100s'",
"Got error %d '%-.100s' from %s",
"Got temporary error %d '%-.100s' from %s",
......@@ -307,5 +307,5 @@ character-set=latin2
"Incorrect table definition; There can only be one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause"
"Invalid ON UPDATE clause for '%-.64s' field",
"This command is not supported in the prepared statement protocol yet",
"Got NDB error %d '%-.100s'",
"Got temporary NDB error %d '%-.100s'",
"Got error %d '%-.100s' from %s",
"Got temporary error %d '%-.100s' from %s",
......@@ -301,5 +301,5 @@ character-set=latin1
"Incorrecta definición de tabla; Solamente debe haber una columna TIMESTAMP con CURRENT_TIMESTAMP en DEFAULT o ON UPDATE cláusula"
"Inválido ON UPDATE cláusula para campo '%-.64s'",
"This command is not supported in the prepared statement protocol yet",
"Got NDB error %d '%-.100s'",
"Got temporary NDB error %d '%-.100s'",
"Got error %d '%-.100s' from %s",
"Got temporary error %d '%-.100s' from %s",
......@@ -299,5 +299,5 @@ character-set=latin1
"Incorrect table definition; There can only be one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause"
"Invalid ON UPDATE clause for '%-.64s' field",
"This command is not supported in the prepared statement protocol yet",
"Fick NDB felkod %d '%-.100s'",
"Fick tilfällig NDB felkod %d '%-.100s'",
"Fick felkod %d '%-.100s' från %s",
"Fick tilfällig felkod %d '%-.100s' från %s",
......@@ -304,5 +304,5 @@ character-set=koi8u
"Incorrect table definition; There can only be one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause"
"Invalid ON UPDATE clause for '%-.64s' field",
"This command is not supported in the prepared statement protocol yet",
"Got NDB error %d '%-.100s'",
"Got temporary NDB error %d '%-.100s'",
"Got error %d '%-.100s' from %s",
"Got temporary error %d '%-.100s' from %s",
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment