diff options
Diffstat (limited to 'sql/sql_base.cc')
| -rw-r--r-- | sql/sql_base.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 335d3a9dfce..1e8b3ad3369 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -8953,6 +8953,29 @@ void switch_to_nullable_trigger_fields(List<Item> &items, TABLE *table) while ((item= it++)) item->walk(&Item::switch_to_nullable_fields_processor, 1, (uchar*)field); + uint16 cnt=0; + uchar *nptr; + nptr= (uchar*)alloc_root(&table->mem_root, (table->s->fields - table->s->null_fields + 7)/8); + // First find null_ptr for NULL field in case of mixed NULL and NOT NULL fields + for (Field **f=field; *f; f++) + { + if (table->field[cnt]->null_ptr) + { + nptr= table->field[cnt]->null_ptr; + break; + } + } + for (Field **f=field; *f; f++) + { + if (!table->field[cnt]->null_ptr) + { + (*f)->null_bit=1<<(cnt+1);; + (*f)->flags&=~(NOT_NULL_FLAG); + (*f)->null_ptr=nptr; + } + cnt++; + } + bzero(nptr, (table->s->fields - table->s->null_fields + 7)/8); table->triggers->reset_extra_null_bitmap(); } } |
