summaryrefslogtreecommitdiff
path: root/sql/unireg.cc
diff options
context:
space:
mode:
authorunknown <ramil@ram-book.(none)>2005-05-05 17:17:55 +0500
committerunknown <ramil@ram-book.(none)>2005-05-05 17:17:55 +0500
commit936c84989e9fb4307983ce6fa94e23d5cf29dab9 (patch)
treed5974982cafbc0f2c511e9ef17c65ddabb5ec52d /sql/unireg.cc
parenta406c034b901be103bf7c2d129856a981340177b (diff)
downloadmariadb-git-936c84989e9fb4307983ce6fa94e23d5cf29dab9.tar.gz
A fix (bug #10179: error in default value setting).
include/my_handler.h: A fix (bug #10179: error in default value setting). Proper masks added: we should not touch extra bits. sql/key.cc: A fix (bug #10179: error in default value setting). Unnecessary code removed. sql/unireg.cc: A fix (bug #10179: error in default value setting). 1. we should take into account uneven bits (for bit fields) stored among NULL bits. 2. changed code which sets NULL bits for fields. 3. changed code which sets unused bits after NULL bits. 4. unused variables removed. BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted
Diffstat (limited to 'sql/unireg.cc')
-rw-r--r--sql/unireg.cc21
1 files changed, 12 insertions, 9 deletions
diff --git a/sql/unireg.cc b/sql/unireg.cc
index 95a383e0f01..e29b97a3f03 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -647,7 +647,7 @@ static bool make_empty_rec(THD *thd, File file,enum db_type table_type,
{
int error;
Field::utype type;
- uint firstpos,null_count,null_length;
+ uint null_count;
uchar *buff,*null_pos;
TABLE table;
create_field *field;
@@ -671,15 +671,14 @@ static bool make_empty_rec(THD *thd, File file,enum db_type table_type,
table.s->db_low_byte_first= handler->low_byte_first();
table.s->blob_ptr_size= portable_sizeof_char_ptr;
- firstpos=reclength;
null_count=0;
if (!(table_options & HA_OPTION_PACK_RECORD))
{
null_fields++; // Need one bit for delete mark
null_count++;
+ *buff|= 1;
}
- bfill(buff,(null_length=(null_fields+7)/8),255);
- null_pos= buff + null_count / 8;
+ null_pos= buff;
List_iterator<create_field> it(create_fields);
thd->count_cuted_fields= CHECK_FIELD_WARN; // To find wrong default values
@@ -689,7 +688,7 @@ static bool make_empty_rec(THD *thd, File file,enum db_type table_type,
regfield don't have to be deleted as it's allocated with sql_alloc()
*/
Field *regfield=make_field((char*) buff+field->offset,field->length,
- null_pos,
+ null_pos + null_count / 8,
null_count & 7,
field->pack_flag,
field->sql_type,
@@ -703,11 +702,13 @@ static bool make_empty_rec(THD *thd, File file,enum db_type table_type,
goto err; // End of memory
if (!(field->flags & NOT_NULL_FLAG))
+ {
+ *regfield->null_ptr|= regfield->null_bit;
null_count++;
+ }
- if ((uint) field->offset < firstpos &&
- regfield->type() != FIELD_TYPE_NULL)
- firstpos= field->offset;
+ if (field->sql_type == FIELD_TYPE_BIT && !f_bit_as_char(field->pack_flag))
+ null_count+= field->length & 7;
type= (Field::utype) MTYP_TYPENR(field->unireg_check);
@@ -737,7 +738,9 @@ static bool make_empty_rec(THD *thd, File file,enum db_type table_type,
}
/* Fill not used startpos */
- bfill((byte*) buff+null_length,firstpos-null_length,255);
+ if (null_count)
+ *(null_pos + null_count / 8)|= ~(((uchar) 1 << (null_count & 7)) - 1);
+
error=(int) my_write(file,(byte*) buff,(uint) reclength,MYF_RW);
err: