From 1077c85fe3450b2a3ae73f7f01cdaf097417f998 Mon Sep 17 00:00:00 2001 From: Ramil Kalimullin Date: Mon, 21 Mar 2011 09:21:14 +0300 Subject: Fix for bug#51875/#11759554 backported from mysql-5.1. --- mysql-test/r/gis.result | 7 +++++++ mysql-test/t/gis.test | 10 ++++++++++ sql/spatial.cc | 6 ++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result index 158fdb69c10..a3b4e8a1783 100644 --- a/mysql-test/r/gis.result +++ b/mysql-test/r/gis.result @@ -996,4 +996,11 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp ALTER TABLE t2 ADD SPATIAL INDEX USING BTREE (col1); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USING BTREE (col1)' at line 1 DROP TABLE t2; +# +# BUG#51875: crash when loading data into geometry function polyfromwkb +# +SET @a=0x00000000030000000100000000000000000000000000144000000000000014400000000000001840000000000000184000000000000014400000000000001440; +SET @a=POLYFROMWKB(@a); +SET @a=0x00000000030000000000000000000000000000000000144000000000000014400000000000001840000000000000184000000000000014400000000000001440; +SET @a=POLYFROMWKB(@a); End of 5.0 tests diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test index d2bfe7d90d4..8abd2fc2da9 100644 --- a/mysql-test/t/gis.test +++ b/mysql-test/t/gis.test @@ -685,4 +685,14 @@ ALTER TABLE t2 ADD SPATIAL INDEX USING BTREE (col1); DROP TABLE t2; + +--echo # +--echo # BUG#51875: crash when loading data into geometry function polyfromwkb +--echo # +SET @a=0x00000000030000000100000000000000000000000000144000000000000014400000000000001840000000000000184000000000000014400000000000001440; +SET @a=POLYFROMWKB(@a); +SET @a=0x00000000030000000000000000000000000000000000144000000000000014400000000000001840000000000000184000000000000014400000000000001440; +SET @a=POLYFROMWKB(@a); + + --echo End of 5.0 tests diff --git a/sql/spatial.cc b/sql/spatial.cc index 6e1da589527..b0963206271 100644 --- a/sql/spatial.cc +++ b/sql/spatial.cc @@ -519,7 +519,7 @@ uint Gis_line_string::init_from_wkb(const char *wkb, uint len, n_points= wkb_get_uint(wkb, bo); proper_length= 4 + n_points * POINT_DATA_SIZE; - if (len < proper_length || res->reserve(proper_length)) + if (!n_points || len < proper_length || res->reserve(proper_length)) return 0; res->q_append(n_points); @@ -737,7 +737,9 @@ uint Gis_polygon::init_from_wkb(const char *wkb, uint len, wkbByteOrder bo, if (len < 4) return 0; - n_linear_rings= wkb_get_uint(wkb, bo); + if (!(n_linear_rings= wkb_get_uint(wkb, bo))) + return 0; + if (res->reserve(4, 512)) return 0; wkb+= 4; -- cgit v1.2.1 From c8b724b2aa6dd0ccc5af1a2b7eb5b92271556ccb Mon Sep 17 00:00:00 2001 From: Mayank Prasad Date: Mon, 21 Mar 2011 21:32:47 +0530 Subject: Bug #11751148 : show events shows events in other schema Issue: ------ Due to prefix match, database like 'k' was matching with 'ka' and events of 'ka' we getting displayed for 'show event' of 'k'. Resolution: ----------- Scan for listing of events in a schema is made to be done on exact match of database (schema) name instead of just prefix. mysql-test/r/events_bugs.result: modified expected file with the expected results. mysql-test/t/events_bugs.test: added a test case to reproduce the scenario. sql/event_db_repository.cc: Scan for schema name is made to be done on exact db name match. --- mysql-test/r/events_bugs.result | 9 +++++++++ mysql-test/t/events_bugs.test | 15 +++++++++++++++ sql/event_db_repository.cc | 2 +- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/events_bugs.result b/mysql-test/r/events_bugs.result index 50bfa97c59f..ab1e9884efd 100644 --- a/mysql-test/r/events_bugs.result +++ b/mysql-test/r/events_bugs.result @@ -747,6 +747,15 @@ event_name originator ev1 4294967295 DROP EVENT ev1; SET GLOBAL server_id = @old_server_id; +CREATE DATABASE event_test1; +USE event_test1; +CREATE EVENT ev1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; +CREATE DATABASE event_test2; +USE event_test2; +SHOW EVENTS; +Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation +DROP DATABASE event_test1; +DROP DATABASE event_test2; DROP DATABASE events_test; SET GLOBAL event_scheduler= 'ON'; SET @@global.concurrent_insert= @concurrent_insert; diff --git a/mysql-test/t/events_bugs.test b/mysql-test/t/events_bugs.test index 81397b333f9..83e37cdccdb 100644 --- a/mysql-test/t/events_bugs.test +++ b/mysql-test/t/events_bugs.test @@ -1221,6 +1221,21 @@ SELECT event_name, originator FROM INFORMATION_SCHEMA.EVENTS; DROP EVENT ev1; SET GLOBAL server_id = @old_server_id; +# +# Bug#11751148: show events shows events in other schema +# + +CREATE DATABASE event_test1; +USE event_test1; +CREATE EVENT ev1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; +CREATE DATABASE event_test2; +USE event_test2; +# Following show events should not show ev1 +SHOW EVENTS; +DROP DATABASE event_test1; +DROP DATABASE event_test2; + + ########################################################################### # # End of tests diff --git a/sql/event_db_repository.cc b/sql/event_db_repository.cc index 753e9d21b65..7473cf47188 100644 --- a/sql/event_db_repository.cc +++ b/sql/event_db_repository.cc @@ -424,7 +424,7 @@ Event_db_repository::index_read_for_db_for_i_s(THD *thd, TABLE *schema_table, key_copy(key_buf, event_table->record[0], key_info, key_len); if (!(ret= event_table->file->index_read_map(event_table->record[0], key_buf, (key_part_map)1, - HA_READ_PREFIX))) + HA_READ_KEY_EXACT))) { DBUG_PRINT("info",("Found rows. Let's retrieve them. ret=%d", ret)); do -- cgit v1.2.1