Skip to content

Commit

Permalink
MDEV-14008 Assertion failing: `!is_set() || (m_status == DA_OK_BULK &…
Browse files Browse the repository at this point in the history
…& is_bulk_op())
  • Loading branch information
Alexander Barkov committed Dec 18, 2017
1 parent 9d76b27 commit c1e5fef
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 7 deletions.
12 changes: 12 additions & 0 deletions mysql-test/suite/innodb/r/innodb-autoinc.result
Original file line number Diff line number Diff line change
Expand Up @@ -1348,3 +1348,15 @@ t CREATE TABLE `t` (
KEY `i` (`i`)
) ENGINE=InnoDB AUTO_INCREMENT=401 DEFAULT CHARSET=latin1
DROP TABLE t;
#
# MDEV-14008 Assertion failing: `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())
#
SET sql_mode=STRICT_ALL_TABLES;
CREATE TABLE t1 (
c1 DOUBLE NOT NULL PRIMARY KEY AUTO_INCREMENT
) ENGINE=InnoDB AUTO_INCREMENT=10000000000000000000;
INSERT INTO t1 VALUES ();
SELECT * FROM t1;
c1
1e19
DROP TABLE t1;
12 changes: 12 additions & 0 deletions mysql-test/suite/innodb/t/innodb-autoinc.test
Original file line number Diff line number Diff line change
Expand Up @@ -680,3 +680,15 @@ INSERT INTO t VALUES (NULL);
SELECT * FROM t;
SHOW CREATE TABLE t;
DROP TABLE t;

--echo #
--echo # MDEV-14008 Assertion failing: `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())
--echo #

SET sql_mode=STRICT_ALL_TABLES;
CREATE TABLE t1 (
c1 DOUBLE NOT NULL PRIMARY KEY AUTO_INCREMENT
) ENGINE=InnoDB AUTO_INCREMENT=10000000000000000000;
INSERT INTO t1 VALUES ();
SELECT * FROM t1;
DROP TABLE t1;
4 changes: 2 additions & 2 deletions sql/field.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4390,15 +4390,15 @@ double Field_double::val_real(void)
return j;
}

longlong Field_double::val_int(void)
longlong Field_double::val_int_from_real(bool want_unsigned_result)
{
ASSERT_COLUMN_MARKED_FOR_READ;
double j;
longlong res;
bool error;
float8get(j,ptr);

res= double_to_longlong(j, 0, &error);
res= double_to_longlong(j, want_unsigned_result, &error);
if (error)
{
ErrConvDouble err(j);
Expand Down
8 changes: 7 additions & 1 deletion sql/field.h
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,10 @@ class Field
enum_check_fields check_level);
virtual double val_real(void)=0;
virtual longlong val_int(void)=0;
virtual ulonglong val_uint(void)
{
return (ulonglong) val_int();
}
virtual my_decimal *val_decimal(my_decimal *);
inline String *val_str(String *str) { return val_str(str, str); }
/*
Expand Down Expand Up @@ -1554,6 +1558,7 @@ class Field_float :public Field_real {


class Field_double :public Field_real {
longlong val_int_from_real(bool want_unsigned_result);
public:
Field_double(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg,
Expand All @@ -1580,7 +1585,8 @@ class Field_double :public Field_real {
int store(longlong nr, bool unsigned_val);
int reset(void) { bzero(ptr,sizeof(double)); return 0; }
double val_real(void);
longlong val_int(void);
longlong val_int(void) { return val_int_from_real(false); }
ulonglong val_uint(void) { return (ulonglong) val_int_from_real(true); }
String *val_str(String*,String *);
bool send_binary(Protocol *protocol);
int cmp(const uchar *,const uchar *);
Expand Down
4 changes: 2 additions & 2 deletions storage/innobase/handler/ha_innodb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7274,7 +7274,7 @@ ha_innobase::write_row(
table->next_number_field);

/* Get the value that MySQL attempted to store in the table.*/
auto_inc = table->next_number_field->val_int();
auto_inc = table->next_number_field->val_uint();

switch (error) {
case DB_DUPLICATE_KEY:
Expand Down Expand Up @@ -7735,7 +7735,7 @@ ha_innobase::update_row(
ulonglong auto_inc;
ulonglong col_max_value;

auto_inc = table->next_number_field->val_int();
auto_inc = table->next_number_field->val_uint();

/* We need the upper limit of the col type to check for
whether we update the table autoinc counter or not. */
Expand Down
4 changes: 2 additions & 2 deletions storage/xtradb/handler/ha_innodb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7988,7 +7988,7 @@ ha_innobase::write_row(
table->next_number_field);

/* Get the value that MySQL attempted to store in the table.*/
auto_inc = table->next_number_field->val_int();
auto_inc = table->next_number_field->val_uint();

switch (error) {
case DB_DUPLICATE_KEY:
Expand Down Expand Up @@ -8468,7 +8468,7 @@ ha_innobase::update_row(
ulonglong auto_inc;
ulonglong col_max_value;

auto_inc = table->next_number_field->val_int();
auto_inc = table->next_number_field->val_uint();

/* We need the upper limit of the col type to check for
whether we update the table autoinc counter or not. */
Expand Down

0 comments on commit c1e5fef

Please sign in to comment.