summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.bzrignore1
-rw-r--r--mysql-test/r/bdb_notembedded.result35
-rw-r--r--mysql-test/r/maria.result31
-rw-r--r--mysql-test/t/bdb_notembedded.test38
-rw-r--r--mysql-test/t/maria.test17
-rw-r--r--sql/sql_table.cc4
-rw-r--r--storage/maria/ma_create.c2
-rw-r--r--storage/maria/ma_pagecrc.c4
8 files changed, 129 insertions, 3 deletions
diff --git a/.bzrignore b/.bzrignore
index 135d0a66fbf..3b65e8d24e4 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -3072,3 +3072,4 @@ libmysqld/sql_profile.cc
*.exp
comments
maria-win.patch
+storage/maria/maria_dump_log
diff --git a/mysql-test/r/bdb_notembedded.result b/mysql-test/r/bdb_notembedded.result
new file mode 100644
index 00000000000..14cb5fad915
--- /dev/null
+++ b/mysql-test/r/bdb_notembedded.result
@@ -0,0 +1,35 @@
+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
diff --git a/mysql-test/r/maria.result b/mysql-test/r/maria.result
index 8eb226d57ac..a5613678110 100644
--- a/mysql-test/r/maria.result
+++ b/mysql-test/r/maria.result
@@ -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;
diff --git a/mysql-test/t/bdb_notembedded.test b/mysql-test/t/bdb_notembedded.test
new file mode 100644
index 00000000000..24e64ebbfb2
--- /dev/null
+++ b/mysql-test/t/bdb_notembedded.test
@@ -0,0 +1,38 @@
+-- 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
diff --git a/mysql-test/t/maria.test b/mysql-test/t/maria.test
index 120f5178a4c..c262270a619 100644
--- a/mysql-test/t/maria.test
+++ b/mysql-test/t/maria.test
@@ -1316,6 +1316,23 @@ show variables like 'maria%';
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
#
set global maria_page_checksum=1;
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 69969a582c6..3edce4ea861 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -2899,10 +2899,10 @@ 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);
+ DBUG_RETURN(TRUE);
}
if (length > file->max_key_part_length() && key->type != Key::FULLTEXT)
{
diff --git a/storage/maria/ma_create.c b/storage/maria/ma_create.c
index d6fe9840aec..3b43f6ec2a5 100644
--- a/storage/maria/ma_create.c
+++ b/storage/maria/ma_create.c
@@ -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);
}
diff --git a/storage/maria/ma_pagecrc.c b/storage/maria/ma_pagecrc.c
index 357527c6faa..07ffc106074 100644
--- a/storage/maria/ma_pagecrc.c
+++ b/storage/maria/ma_pagecrc.c
@@ -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;
}