Skip to content

Commit c1e5fef

Browse files
author
Alexander Barkov
committed
MDEV-14008 Assertion failing: `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())
1 parent 9d76b27 commit c1e5fef

File tree

6 files changed

+37
-7
lines changed

6 files changed

+37
-7
lines changed

mysql-test/suite/innodb/r/innodb-autoinc.result

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,3 +1348,15 @@ t CREATE TABLE `t` (
13481348
KEY `i` (`i`)
13491349
) ENGINE=InnoDB AUTO_INCREMENT=401 DEFAULT CHARSET=latin1
13501350
DROP TABLE t;
1351+
#
1352+
# MDEV-14008 Assertion failing: `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())
1353+
#
1354+
SET sql_mode=STRICT_ALL_TABLES;
1355+
CREATE TABLE t1 (
1356+
c1 DOUBLE NOT NULL PRIMARY KEY AUTO_INCREMENT
1357+
) ENGINE=InnoDB AUTO_INCREMENT=10000000000000000000;
1358+
INSERT INTO t1 VALUES ();
1359+
SELECT * FROM t1;
1360+
c1
1361+
1e19
1362+
DROP TABLE t1;

mysql-test/suite/innodb/t/innodb-autoinc.test

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,3 +680,15 @@ INSERT INTO t VALUES (NULL);
680680
SELECT * FROM t;
681681
SHOW CREATE TABLE t;
682682
DROP TABLE t;
683+
684+
--echo #
685+
--echo # MDEV-14008 Assertion failing: `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())
686+
--echo #
687+
688+
SET sql_mode=STRICT_ALL_TABLES;
689+
CREATE TABLE t1 (
690+
c1 DOUBLE NOT NULL PRIMARY KEY AUTO_INCREMENT
691+
) ENGINE=InnoDB AUTO_INCREMENT=10000000000000000000;
692+
INSERT INTO t1 VALUES ();
693+
SELECT * FROM t1;
694+
DROP TABLE t1;

sql/field.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4390,15 +4390,15 @@ double Field_double::val_real(void)
43904390
return j;
43914391
}
43924392

4393-
longlong Field_double::val_int(void)
4393+
longlong Field_double::val_int_from_real(bool want_unsigned_result)
43944394
{
43954395
ASSERT_COLUMN_MARKED_FOR_READ;
43964396
double j;
43974397
longlong res;
43984398
bool error;
43994399
float8get(j,ptr);
44004400

4401-
res= double_to_longlong(j, 0, &error);
4401+
res= double_to_longlong(j, want_unsigned_result, &error);
44024402
if (error)
44034403
{
44044404
ErrConvDouble err(j);

sql/field.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,10 @@ class Field
420420
enum_check_fields check_level);
421421
virtual double val_real(void)=0;
422422
virtual longlong val_int(void)=0;
423+
virtual ulonglong val_uint(void)
424+
{
425+
return (ulonglong) val_int();
426+
}
423427
virtual my_decimal *val_decimal(my_decimal *);
424428
inline String *val_str(String *str) { return val_str(str, str); }
425429
/*
@@ -1554,6 +1558,7 @@ class Field_float :public Field_real {
15541558

15551559

15561560
class Field_double :public Field_real {
1561+
longlong val_int_from_real(bool want_unsigned_result);
15571562
public:
15581563
Field_double(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
15591564
uchar null_bit_arg,
@@ -1580,7 +1585,8 @@ class Field_double :public Field_real {
15801585
int store(longlong nr, bool unsigned_val);
15811586
int reset(void) { bzero(ptr,sizeof(double)); return 0; }
15821587
double val_real(void);
1583-
longlong val_int(void);
1588+
longlong val_int(void) { return val_int_from_real(false); }
1589+
ulonglong val_uint(void) { return (ulonglong) val_int_from_real(true); }
15841590
String *val_str(String*,String *);
15851591
bool send_binary(Protocol *protocol);
15861592
int cmp(const uchar *,const uchar *);

storage/innobase/handler/ha_innodb.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7274,7 +7274,7 @@ ha_innobase::write_row(
72747274
table->next_number_field);
72757275

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

72797279
switch (error) {
72807280
case DB_DUPLICATE_KEY:
@@ -7735,7 +7735,7 @@ ha_innobase::update_row(
77357735
ulonglong auto_inc;
77367736
ulonglong col_max_value;
77377737

7738-
auto_inc = table->next_number_field->val_int();
7738+
auto_inc = table->next_number_field->val_uint();
77397739

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

storage/xtradb/handler/ha_innodb.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7988,7 +7988,7 @@ ha_innobase::write_row(
79887988
table->next_number_field);
79897989

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

79937993
switch (error) {
79947994
case DB_DUPLICATE_KEY:
@@ -8468,7 +8468,7 @@ ha_innobase::update_row(
84688468
ulonglong auto_inc;
84698469
ulonglong col_max_value;
84708470

8471-
auto_inc = table->next_number_field->val_int();
8471+
auto_inc = table->next_number_field->val_uint();
84728472

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

0 commit comments

Comments
 (0)