3792 Mattias Jonsson 2012-01-26
Bug#13511529: EXAMPLE ENGINE DOES NOT SUPPORT RND_INIT(),
BUT SUPPORTS RND_NEXT()
After checking return value from rnd_init() the example engine
failed even on selects, where it previously succeeded.
Problem was that ha_example::rnd_init always returned
HA_ERR_WRONG_COMMAND, so that it would never try
rnd_next.
Fixed by always return 0 in rnd_init, so it would try
rnd_next.
Also added a couple of tests to show the lack of features in
the example engine.
Updated test after review.
modified:
mysql-test/r/plugin.result
mysql-test/t/plugin.test
storage/example/ha_example.cc
3791 Tor Didriksen 2012-01-26 [merge]
merge 5.5 => trunk
modified:
mysql-test/r/mysqld--help-win.result
=== modified file 'mysql-test/r/plugin.result'
--- a/mysql-test/r/plugin.result revid:tor.didriksen@stripped
+++ b/mysql-test/r/plugin.result revid:mattias.jonsson@stripped
@@ -9,9 +9,31 @@ ERROR HY000: Function 'EXAMPLE' already
UNINSTALL PLUGIN example;
INSTALL PLUGIN example SONAME 'ha_example.so';
CREATE TABLE t1(a int) ENGINE=EXAMPLE;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=EXAMPLE DEFAULT CHARSET=latin1
+# Let's do some advanced ops with the example engine :)
+INSERT INTO t1 VALUES (0);
+# Only supports table scans (and does always return zero rows :)
SELECT * FROM t1;
+a
+SELECT * FROM t1 WHERE a = 0;
+a
+# Since there are no rows found, it will never do update_row.
+UPDATE t1 SET a = 1 WHERE a = 0;
+# Since there are no rows found, it will never do delete_row.
+DELETE FROM t1 WHERE a = 0;
+# No support for SQL HANDLER statement
+HANDLER t1 OPEN;
ERROR HY000: Table storage engine for 't1' doesn't have this option
DROP TABLE t1;
+# Example engine does not support indexes
+CREATE TABLE t1 (a int PRIMARY KEY) ENGINE=EXAMPLE;
+ERROR 42000: Too many key parts specified; max 0 parts allowed
+CREATE TABLE t1 (a int, KEY (a)) ENGINE=EXAMPLE;
+ERROR 42000: Too many key parts specified; max 0 parts allowed
set global example_ulong_var=500;
set global example_enum_var= e1;
show status like 'example%';
=== modified file 'mysql-test/t/plugin.test'
--- a/mysql-test/t/plugin.test revid:tor.didriksen@stripped
+++ b/mysql-test/t/plugin.test revid:mattias.jonsson@stripped
@@ -17,11 +17,33 @@ eval INSTALL PLUGIN example SONAME '$EXA
CREATE TABLE t1(a int) ENGINE=EXAMPLE;
---error ER_ILLEGAL_HA
+SHOW CREATE TABLE t1;
+
+--echo # Let's do some advanced ops with the example engine :)
+INSERT INTO t1 VALUES (0);
+
+--echo # Only supports table scans (and does always return zero rows :)
SELECT * FROM t1;
+SELECT * FROM t1 WHERE a = 0;
+
+--echo # Since there are no rows found, it will never do update_row.
+UPDATE t1 SET a = 1 WHERE a = 0;
+
+--echo # Since there are no rows found, it will never do delete_row.
+DELETE FROM t1 WHERE a = 0;
+
+--echo # No support for SQL HANDLER statement
+--error ER_ILLEGAL_HA
+HANDLER t1 OPEN;
DROP TABLE t1;
+--echo # Example engine does not support indexes
+--error ER_TOO_MANY_KEY_PARTS
+CREATE TABLE t1 (a int PRIMARY KEY) ENGINE=EXAMPLE;
+--error ER_TOO_MANY_KEY_PARTS
+CREATE TABLE t1 (a int, KEY (a)) ENGINE=EXAMPLE;
+
# a couple of tests for variables
set global example_ulong_var=500;
set global example_enum_var= e1;
=== modified file 'storage/example/ha_example.cc'
--- a/storage/example/ha_example.cc revid:tor.didriksen@stripped
+++ b/storage/example/ha_example.cc revid:mattias.jonsson@stripped
@@ -554,7 +554,7 @@ int ha_example::index_last(uchar *buf)
int ha_example::rnd_init(bool scan)
{
DBUG_ENTER("ha_example::rnd_init");
- DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+ DBUG_RETURN(0);
}
int ha_example::rnd_end()
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-trunk branch (mattias.jonsson:3791 to 3792) Bug#13511529 | Mattias Jonsson | 30 Jan |