Commit 2286913e authored by unknown's avatar unknown

Bug #10838 CREATE TABLE produces strange DEFAULT value

parent cfb54ed5
drop table if exists t1,t2,t3,t4,t5,t6;
drop database if exists mysqltest;
CREATE TABLE t1 (a varchar(30) binary NOT NULL DEFAULT ' ',
b varchar(1) binary NOT NULL DEFAULT ' ',
c varchar(4) binary NOT NULL DEFAULT '0000',
d tinyblob NULL,
e tinyblob NULL,
f tinyblob NULL,
g tinyblob NULL,
h tinyblob NULL,
i tinyblob NULL,
j tinyblob NULL,
k tinyblob NULL,
l tinyblob NULL,
m tinyblob NULL,
n tinyblob NULL,
o tinyblob NULL,
p tinyblob NULL,
q varchar(30) binary NOT NULL DEFAULT ' ',
r varchar(30) binary NOT NULL DEFAULT ' ',
s tinyblob NULL,
t varchar(4) binary NOT NULL DEFAULT ' ',
u varchar(1) binary NOT NULL DEFAULT ' ',
v varchar(30) binary NOT NULL DEFAULT ' ',
w varchar(30) binary NOT NULL DEFAULT ' ',
x tinyblob NULL,
y varchar(5) binary NOT NULL DEFAULT ' ',
z varchar(20) binary NOT NULL DEFAULT ' ',
a1 varchar(30) binary NOT NULL DEFAULT ' ',
b1 tinyblob NULL)
ENGINE=InnoDB DEFAULT CHARACTER SET = latin1 COLLATE latin1_bin;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varchar(30) collate latin1_bin NOT NULL default ' ',
`b` varchar(1) collate latin1_bin NOT NULL default ' ',
`c` varchar(4) collate latin1_bin NOT NULL default '0000',
`d` tinyblob,
`e` tinyblob,
`f` tinyblob,
`g` tinyblob,
`h` tinyblob,
`i` tinyblob,
`j` tinyblob,
`k` tinyblob,
`l` tinyblob,
`m` tinyblob,
`n` tinyblob,
`o` tinyblob,
`p` tinyblob,
`q` varchar(30) collate latin1_bin NOT NULL default ' ',
`r` varchar(30) collate latin1_bin NOT NULL default ' ',
`s` tinyblob,
`t` varchar(4) collate latin1_bin NOT NULL default ' ',
`u` varchar(1) collate latin1_bin NOT NULL default ' ',
`v` varchar(30) collate latin1_bin NOT NULL default ' ',
`w` varchar(30) collate latin1_bin NOT NULL default ' ',
`x` tinyblob,
`y` varchar(5) collate latin1_bin NOT NULL default ' ',
`z` varchar(20) collate latin1_bin NOT NULL default ' ',
`a1` varchar(30) collate latin1_bin NOT NULL default ' ',
`b1` tinyblob
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin
INSERT into t1 (b) values ('1');
SHOW WARNINGS;
Level Code Message
SELECT * from t1;
a b c d e f g h i j k l m n o p q r s t u v w x y z a1 b1
1 0000 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
CREATE TABLE t2 (a varchar(30) binary NOT NULL DEFAULT ' ',
b varchar(1) binary NOT NULL DEFAULT ' ',
c varchar(4) binary NOT NULL DEFAULT '0000',
d tinyblob NULL,
e tinyblob NULL,
f tinyblob NULL,
g tinyblob NULL,
h tinyblob NULL,
i tinyblob NULL,
j tinyblob NULL,
k tinyblob NULL,
l tinyblob NULL,
m tinyblob NULL,
n tinyblob NULL,
o tinyblob NULL,
p tinyblob NULL,
q varchar(30) binary NOT NULL DEFAULT ' ',
r varchar(30) binary NOT NULL DEFAULT ' ',
s tinyblob NULL,
t varchar(4) binary NOT NULL DEFAULT ' ',
u varchar(1) binary NOT NULL DEFAULT ' ',
v varchar(30) binary NOT NULL DEFAULT ' ',
w varchar(30) binary NOT NULL DEFAULT ' ',
x tinyblob NULL,
y varchar(5) binary NOT NULL DEFAULT ' ',
z varchar(20) binary NOT NULL DEFAULT ' ',
a1 varchar(30) binary NOT NULL DEFAULT ' ',
b1 tinyblob NULL)
ENGINE=MyISAM DEFAULT CHARACTER SET = latin1 COLLATE latin1_bin;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`a` varchar(30) collate latin1_bin NOT NULL default ' ',
`b` varchar(1) collate latin1_bin NOT NULL default ' ',
`c` varchar(4) collate latin1_bin NOT NULL default '0000',
`d` tinyblob,
`e` tinyblob,
`f` tinyblob,
`g` tinyblob,
`h` tinyblob,
`i` tinyblob,
`j` tinyblob,
`k` tinyblob,
`l` tinyblob,
`m` tinyblob,
`n` tinyblob,
`o` tinyblob,
`p` tinyblob,
`q` varchar(30) collate latin1_bin NOT NULL default ' ',
`r` varchar(30) collate latin1_bin NOT NULL default ' ',
`s` tinyblob,
`t` varchar(4) collate latin1_bin NOT NULL default ' ',
`u` varchar(1) collate latin1_bin NOT NULL default ' ',
`v` varchar(30) collate latin1_bin NOT NULL default ' ',
`w` varchar(30) collate latin1_bin NOT NULL default ' ',
`x` tinyblob,
`y` varchar(5) collate latin1_bin NOT NULL default ' ',
`z` varchar(20) collate latin1_bin NOT NULL default ' ',
`a1` varchar(30) collate latin1_bin NOT NULL default ' ',
`b1` tinyblob
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_bin
INSERT into t2 (b) values ('1');
SHOW WARNINGS;
Level Code Message
SELECT * from t2;
a b c d e f g h i j k l m n o p q r s t u v w x y z a1 b1
1 0000 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
drop table t1;
drop table t2;
#
# test of already fixed bugs
#
--disable_warnings
drop table if exists t1,t2,t3,t4,t5,t6;
drop database if exists mysqltest;
--enable_warnings
#
# Bug 10838
# Insert causes warnings for no default values and corrupts tables
#
CREATE TABLE t1 (a varchar(30) binary NOT NULL DEFAULT ' ',
b varchar(1) binary NOT NULL DEFAULT ' ',
c varchar(4) binary NOT NULL DEFAULT '0000',
d tinyblob NULL,
e tinyblob NULL,
f tinyblob NULL,
g tinyblob NULL,
h tinyblob NULL,
i tinyblob NULL,
j tinyblob NULL,
k tinyblob NULL,
l tinyblob NULL,
m tinyblob NULL,
n tinyblob NULL,
o tinyblob NULL,
p tinyblob NULL,
q varchar(30) binary NOT NULL DEFAULT ' ',
r varchar(30) binary NOT NULL DEFAULT ' ',
s tinyblob NULL,
t varchar(4) binary NOT NULL DEFAULT ' ',
u varchar(1) binary NOT NULL DEFAULT ' ',
v varchar(30) binary NOT NULL DEFAULT ' ',
w varchar(30) binary NOT NULL DEFAULT ' ',
x tinyblob NULL,
y varchar(5) binary NOT NULL DEFAULT ' ',
z varchar(20) binary NOT NULL DEFAULT ' ',
a1 varchar(30) binary NOT NULL DEFAULT ' ',
b1 tinyblob NULL)
ENGINE=InnoDB DEFAULT CHARACTER SET = latin1 COLLATE latin1_bin;
SHOW CREATE TABLE t1;
INSERT into t1 (b) values ('1');
SHOW WARNINGS;
SELECT * from t1;
CREATE TABLE t2 (a varchar(30) binary NOT NULL DEFAULT ' ',
b varchar(1) binary NOT NULL DEFAULT ' ',
c varchar(4) binary NOT NULL DEFAULT '0000',
d tinyblob NULL,
e tinyblob NULL,
f tinyblob NULL,
g tinyblob NULL,
h tinyblob NULL,
i tinyblob NULL,
j tinyblob NULL,
k tinyblob NULL,
l tinyblob NULL,
m tinyblob NULL,
n tinyblob NULL,
o tinyblob NULL,
p tinyblob NULL,
q varchar(30) binary NOT NULL DEFAULT ' ',
r varchar(30) binary NOT NULL DEFAULT ' ',
s tinyblob NULL,
t varchar(4) binary NOT NULL DEFAULT ' ',
u varchar(1) binary NOT NULL DEFAULT ' ',
v varchar(30) binary NOT NULL DEFAULT ' ',
w varchar(30) binary NOT NULL DEFAULT ' ',
x tinyblob NULL,
y varchar(5) binary NOT NULL DEFAULT ' ',
z varchar(20) binary NOT NULL DEFAULT ' ',
a1 varchar(30) binary NOT NULL DEFAULT ' ',
b1 tinyblob NULL)
ENGINE=MyISAM DEFAULT CHARACTER SET = latin1 COLLATE latin1_bin;
SHOW CREATE TABLE t2;
INSERT into t2 (b) values ('1');
SHOW WARNINGS;
SELECT * from t2;
drop table t1;
drop table t2;
...@@ -755,8 +755,11 @@ static bool make_empty_rec(THD *thd, File file,enum db_type table_type, ...@@ -755,8 +755,11 @@ static bool make_empty_rec(THD *thd, File file,enum db_type table_type,
} }
DBUG_ASSERT(data_offset == ((null_count + 7) / 8)); DBUG_ASSERT(data_offset == ((null_count + 7) / 8));
/* Fill not used startpos */ /*
if (null_count) We need to set the unused bits to 1. If the number of bits is a multiple
of 8 there are no unused bits.
*/
if (null_count & 7)
*(null_pos + null_count / 8)|= ~(((uchar) 1 << (null_count & 7)) - 1); *(null_pos + null_count / 8)|= ~(((uchar) 1 << (null_count & 7)) - 1);
error=(int) my_write(file,(byte*) buff, (uint) reclength,MYF_RW); error=(int) my_write(file,(byte*) buff, (uint) reclength,MYF_RW);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment