1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Merge acurtis@bk-internal.mysql.com:/home/bk/mysql-5.0-engines

into  xiphis.org:/home/antony/work2/engines-merge
This commit is contained in:
acurtis/antony@ltamd64.xiphis.org
2006-09-18 12:16:03 -07:00
21 changed files with 269 additions and 19 deletions

View File

@ -332,6 +332,8 @@ static int ha_init_errors(void)
SETMSG(HA_ERR_FOREIGN_DUPLICATE_KEY, "FK constraint would lead to duplicate key");
SETMSG(HA_ERR_TABLE_NEEDS_UPGRADE, ER(ER_TABLE_NEEDS_UPGRADE));
SETMSG(HA_ERR_TABLE_READONLY, ER(ER_OPEN_AS_READONLY));
SETMSG(HA_ERR_AUTOINC_READ_FAILED, ER(ER_AUTOINC_READ_FAILED));
SETMSG(HA_ERR_AUTOINC_ERANGE, ER(ER_WARN_DATA_OUT_OF_RANGE));
/* Register the error messages for use with my_error(). */
return my_error_register(errmsgs, HA_ERR_FIRST, HA_ERR_LAST);
@ -1656,7 +1658,10 @@ prev_insert_id(ulonglong nr, struct system_variables *variables)
RETURN
0 ok
1 get_auto_increment() was called and returned ~(ulonglong) 0
HA_ERR_AUTOINC_READ_FAILED
get_auto_increment() was called and returned ~(ulonglong) 0
HA_ERR_AUTOINC_ERANGE
storing value in field caused strict mode failure.
IMPLEMENTATION
@ -1725,14 +1730,13 @@ prev_insert_id(ulonglong nr, struct system_variables *variables)
#define AUTO_INC_DEFAULT_NB_MAX_BITS 16
#define AUTO_INC_DEFAULT_NB_MAX ((1 << AUTO_INC_DEFAULT_NB_MAX_BITS) - 1)
bool handler::update_auto_increment()
int handler::update_auto_increment()
{
ulonglong nr, nb_reserved_values;
bool append= FALSE;
THD *thd= table->in_use;
struct system_variables *variables= &thd->variables;
bool auto_increment_field_not_null;
bool result= 0;
DBUG_ENTER("handler::update_auto_increment");
/*
@ -1809,7 +1813,7 @@ bool handler::update_auto_increment()
nb_desired_values, &nr,
&nb_reserved_values);
if (nr == ~(ulonglong) 0)
result= 1; // Mark failure
DBUG_RETURN(HA_ERR_AUTOINC_READ_FAILED); // Mark failure
/*
That rounding below should not be needed when all engines actually
@ -1843,6 +1847,12 @@ bool handler::update_auto_increment()
if (unlikely(table->next_number_field->store((longlong) nr, TRUE)))
{
/*
first test if the query was aborted due to strict mode constraints
*/
if (thd->killed == THD::KILL_BAD_DATA)
DBUG_RETURN(HA_ERR_AUTOINC_ERANGE);
/*
field refused this value (overflow) and truncated it, use the result of
the truncation (which is going to be inserted); however we try to
@ -1865,7 +1875,6 @@ bool handler::update_auto_increment()
thd->auto_inc_intervals_in_cur_stmt_for_binlog.append(auto_inc_interval_for_cur_row.minimum(),
auto_inc_interval_for_cur_row.values(),
variables->auto_increment_increment);
}
/*
Record this autogenerated value. If the caller then
@ -1881,7 +1890,7 @@ bool handler::update_auto_increment()
*/
set_next_insert_id(compute_next_insert_id(nr, variables));
DBUG_RETURN(result);
DBUG_RETURN(result ? /* some failure occurred */ -1 : 0);
}
@ -2176,6 +2185,12 @@ void handler::print_error(int error, myf errflag)
case HA_ERR_TABLE_READONLY:
textno= ER_OPEN_AS_READONLY;
break;
case HA_ERR_AUTOINC_READ_FAILED:
textno= ER_AUTOINC_READ_FAILED;
break;
case HA_ERR_AUTOINC_ERANGE:
textno= ER_WARN_DATA_OUT_OF_RANGE;
break;
default:
{
/* The error was "unknown" to this function.