Skip to content

Commit 5dfab33

Browse files
committed
MDEV-11551 Server crashes in Field::is_real_null
sometimes table->s->stored_fields is less than table->s->null_fields
1 parent 7e2f9d0 commit 5dfab33

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

mysql-test/r/trigger_null-8605.result

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,3 +354,13 @@ show columns from t1;
354354
Field Type Null Key Default Extra
355355
a int(11) NO PRI NULL
356356
drop table t1;
357+
create table t1 (
358+
pk int primary key,
359+
i int,
360+
v1 int as (i) virtual,
361+
v2 int as (i) virtual
362+
);
363+
create trigger tr before update on t1 for each row set @a = 1;
364+
insert into t1 (pk, i) values (null, null);
365+
ERROR 23000: Column 'pk' cannot be null
366+
drop table t1;

mysql-test/t/trigger_null-8605.test

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,3 +373,17 @@ show columns from t1;
373373
insert into t1 (a) values (3);
374374
show columns from t1;
375375
drop table t1;
376+
377+
#
378+
# MDEV-11551 Server crashes in Field::is_real_null
379+
#
380+
create table t1 (
381+
pk int primary key,
382+
i int,
383+
v1 int as (i) virtual,
384+
v2 int as (i) virtual
385+
);
386+
create trigger tr before update on t1 for each row set @a = 1;
387+
--error ER_BAD_NULL_ERROR
388+
insert into t1 (pk, i) values (null, null);
389+
drop table t1;

sql/sql_trigger.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ bool Table_triggers_list::prepare_record_accessors(TABLE *table)
10821082
&& (table->s->stored_fields != table->s->null_fields))
10831083

10841084
{
1085-
int null_bytes= (table->s->stored_fields - table->s->null_fields + 7)/8;
1085+
int null_bytes= (table->s->fields - table->s->null_fields + 7)/8;
10861086
if (!(extra_null_bitmap= (uchar*)alloc_root(&table->mem_root, null_bytes)))
10871087
return 1;
10881088
if (!(record0_field= (Field **)alloc_root(&table->mem_root,

0 commit comments

Comments
 (0)