Commit 5cca615c authored by unknown's avatar unknown

Allow index on 'CHAR(0) NULL' columns

Fixed error in Maria when using table with only CHAR(0) fields
Fixed valgrind warning


BitKeeper/etc/ignore:
  added storage/maria/maria_dump_log
mysql-test/r/maria.result:
  Testing of table with char(0)
mysql-test/t/maria.test:
  Testing of table with char(0)
sql/sql_table.cc:
  Allow index on 'CHAR(0) NULL' columns
storage/maria/ma_create.c:
  Allow creation of table with 0 record data (for example CHAR(0))
storage/maria/ma_pagecrc.c:
  Fixed valgrind warning
parent 5b18f810
......@@ -3072,3 +3072,4 @@ libmysqld/sql_profile.cc
*.exp
comments
maria-win.patch
storage/maria/maria_dump_log
set autocommit=1;
reset master;
create table bug16206 (a int);
insert into bug16206 values(1);
start transaction;
insert into bug16206 values(2);
commit;
show binlog events;
Log_name Pos Event_type Server_id End_log_pos Info
f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4
f n Query 1 n use `test`; create table bug16206 (a int)
f n Query 1 n use `test`; insert into bug16206 values(1)
f n Query 1 n use `test`; insert into bug16206 values(2)
drop table bug16206;
reset master;
create table bug16206 (a int) engine= bdb;
insert into bug16206 values(0);
insert into bug16206 values(1);
start transaction;
insert into bug16206 values(2);
commit;
insert into bug16206 values(3);
show binlog events;
Log_name Pos Event_type Server_id End_log_pos Info
f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4
f n Query 1 n use `test`; create table bug16206 (a int) engine= bdb
f n Query 1 n use `test`; insert into bug16206 values(0)
f n Query 1 n use `test`; insert into bug16206 values(1)
f n Query 1 n use `test`; BEGIN
f n Query 1 n use `test`; insert into bug16206 values(2)
f n Query 1 n use `test`; COMMIT
f n Query 1 n use `test`; insert into bug16206 values(3)
drop table bug16206;
set autocommit=0;
End of 5.0 tests
......@@ -2071,6 +2071,37 @@ Maria_pagecache_read_requests #
Maria_pagecache_reads #
Maria_pagecache_write_requests #
Maria_pagecache_writes #
create table t1 (b char(0));
insert into t1 values(NULL),("");
select length(b) from t1;
length(b)
NULL
0
alter table t1 add column c char(0), add key (c);
insert into t1 values("",""),("",NULL);
select length(b),length(c) from t1;
length(b) length(c)
NULL NULL
0 NULL
0 0
0 NULL
select length(b),length(c) from t1 where c is null;
length(b) length(c)
NULL NULL
0 NULL
0 NULL
select length(b),length(c) from t1 where c is not null;
length(b) length(c)
0 0
select length(b),length(c) from t1 order by c;
length(b) length(c)
NULL NULL
0 NULL
0 NULL
0 0
alter table t1 add column d char(0) not null, add key (d);
ERROR 42000: The used storage engine can't index column 'd'
drop table t1;
set global maria_page_checksum=1;
create table t1 (a int);
show create table t1;
......
-- source include/not_embedded.inc
-- source include/have_bdb.inc
#
# Bug #16206: Superfluous COMMIT event in binlog when updating BDB in autocommit mode
#
set autocommit=1;
let $VERSION=`select version()`;
reset master;
create table bug16206 (a int);
insert into bug16206 values(1);
start transaction;
insert into bug16206 values(2);
commit;
--replace_result $VERSION VERSION
--replace_column 1 f 2 n 5 n
show binlog events;
drop table bug16206;
reset master;
create table bug16206 (a int) engine= bdb;
insert into bug16206 values(0);
insert into bug16206 values(1);
start transaction;
insert into bug16206 values(2);
commit;
insert into bug16206 values(3);
--replace_result $VERSION VERSION
--replace_column 1 f 2 n 5 n
show binlog events;
drop table bug16206;
set autocommit=0;
--echo End of 5.0 tests
......@@ -1315,6 +1315,23 @@ show variables like 'maria%';
--replace_column 2 #
show status like 'maria%';
#
# Test creating table with no field data and index on zero length columns
#
create table t1 (b char(0));
insert into t1 values(NULL),("");
select length(b) from t1;
alter table t1 add column c char(0), add key (c);
insert into t1 values("",""),("",NULL);
select length(b),length(c) from t1;
select length(b),length(c) from t1 where c is null;
select length(b),length(c) from t1 where c is not null;
select length(b),length(c) from t1 order by c;
--error 1167
alter table t1 add column d char(0) not null, add key (d);
drop table t1;
#
# Show that page_checksum is remembered
#
......
......@@ -2899,7 +2899,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
else if (!(file->ha_table_flags() & HA_NO_PREFIX_CHAR_KEYS))
length=column->length;
}
else if (length == 0)
else if (length == 0 && (sql_field->flags & NOT_NULL_FLAG))
{
my_error(ER_WRONG_KEY_COLUMN, MYF(0), column->field_name);
DBUG_RETURN(TRUE);
......
......@@ -85,7 +85,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
ci=&tmp_create_info;
}
if (keys + uniques > MARIA_MAX_KEY || columns == 0)
if (keys + uniques > MARIA_MAX_KEY)
{
DBUG_RETURN(my_errno=HA_WRONG_CREATE_OPTION);
}
......
......@@ -305,6 +305,10 @@ my_bool maria_page_filler_set_none(uchar *page __attribute__((unused)),
__attribute__((unused)),
uchar *data_ptr __attribute__((unused)))
{
#ifdef HAVE_purify
int4store_aligned(page + ((MARIA_SHARE *)data_ptr)->block_size - CRC_SIZE,
0);
#endif
return 0;
}
......
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