From: Mayank Prasad Date: February 6 2012 5:18pm Subject: bzr push into mysql-trunk-wl5767 branch (mayank.prasad:3432 to 3433) WL#5767 List-Archive: http://lists.mysql.com/commits/142771 Message-Id: <201202061718.q16HIQw0005170@acsmt356.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3433 Mayank Prasad 2012-02-06 [merge] WL#5767: Merge : mysql-trunk->mysql-trunk-wl5767 added: mysql-test/suite/innodb/r/innodb_bug11754376.result mysql-test/suite/innodb/t/innodb_bug11754376.test modified: mysql-test/r/group_by.result mysql-test/r/join_outer.result mysql-test/r/join_outer_bka.result mysql-test/r/join_outer_bka_nixbnl.result mysql-test/t/join_outer.test sql/item.h sql/sql_optimizer.cc storage/innobase/handler/ha_innodb.cc 3432 Mayank Prasad 2012-02-06 WL#5767 : Performance Schema, Statements Digest Details: - Added new flag m_full in PFS_digest_storage. - Modified code to make sure not to overflow digest_text buffer while generating digest text. modified: mysql-test/suite/perfschema/r/statements_digest_long_query.result storage/perfschema/pfs_digest.cc storage/perfschema/pfs_digest.h storage/perfschema/table_events_statements.cc storage/perfschema/table_helper.cc === modified file 'mysql-test/r/group_by.result' --- a/mysql-test/r/group_by.result 2012-01-30 13:57:08 +0000 +++ b/mysql-test/r/group_by.result 2012-02-06 12:47:30 +0000 @@ -2110,6 +2110,7 @@ SELECT v1.pk FROM t1 LEFT JOIN v1 ON t1.i = v1.pk GROUP BY v1.pk; pk +NULL DROP VIEW v1; DROP TABLE t1,t2; # End of Bug#12798270 === modified file 'mysql-test/r/join_outer.result' --- a/mysql-test/r/join_outer.result 2012-01-03 11:04:14 +0000 +++ b/mysql-test/r/join_outer.result 2012-02-06 12:47:30 +0000 @@ -1996,3 +1996,19 @@ id select_type table type possible_keys 1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop) 1 SIMPLE t6b ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop) drop table t1,t2,t3,t4,t5,t6; +# +# Bug#13464334 SAME QUERY PRODUCES DIFFERENT RESULTS WHEN USED WITH AND +# WITHOUT UNION ALL +# +CREATE TABLE t1 (p1 INT PRIMARY KEY, a CHAR(1)); +CREATE TABLE t2 (p2 INT PRIMARY KEY, b CHAR(1)); +INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c'); +INSERT INTO t2 VALUES (1,'h'),(2,'i'),(3,'j'),(4,'k'); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE VIEW v2 AS SELECT * FROM t2; +(SELECT p1 FROM v2 LEFT JOIN v1 ON b = a WHERE p2 = 1 GROUP BY p1 ORDER BY p1) +UNION (SELECT NULL LIMIT 0); +p1 +NULL +DROP VIEW v1, v2; +DROP TABLE t1, t2; === modified file 'mysql-test/r/join_outer_bka.result' --- a/mysql-test/r/join_outer_bka.result 2012-01-03 11:04:14 +0000 +++ b/mysql-test/r/join_outer_bka.result 2012-02-06 12:47:30 +0000 @@ -1997,4 +1997,20 @@ id select_type table type possible_keys 1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop) 1 SIMPLE t6b ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop) drop table t1,t2,t3,t4,t5,t6; +# +# Bug#13464334 SAME QUERY PRODUCES DIFFERENT RESULTS WHEN USED WITH AND +# WITHOUT UNION ALL +# +CREATE TABLE t1 (p1 INT PRIMARY KEY, a CHAR(1)); +CREATE TABLE t2 (p2 INT PRIMARY KEY, b CHAR(1)); +INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c'); +INSERT INTO t2 VALUES (1,'h'),(2,'i'),(3,'j'),(4,'k'); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE VIEW v2 AS SELECT * FROM t2; +(SELECT p1 FROM v2 LEFT JOIN v1 ON b = a WHERE p2 = 1 GROUP BY p1 ORDER BY p1) +UNION (SELECT NULL LIMIT 0); +p1 +NULL +DROP VIEW v1, v2; +DROP TABLE t1, t2; set optimizer_switch=default; === modified file 'mysql-test/r/join_outer_bka_nixbnl.result' --- a/mysql-test/r/join_outer_bka_nixbnl.result 2012-01-03 11:04:14 +0000 +++ b/mysql-test/r/join_outer_bka_nixbnl.result 2012-02-06 12:47:30 +0000 @@ -1997,4 +1997,20 @@ id select_type table type possible_keys 1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where 1 SIMPLE t6b ALL NULL NULL NULL NULL 1 Using where drop table t1,t2,t3,t4,t5,t6; +# +# Bug#13464334 SAME QUERY PRODUCES DIFFERENT RESULTS WHEN USED WITH AND +# WITHOUT UNION ALL +# +CREATE TABLE t1 (p1 INT PRIMARY KEY, a CHAR(1)); +CREATE TABLE t2 (p2 INT PRIMARY KEY, b CHAR(1)); +INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c'); +INSERT INTO t2 VALUES (1,'h'),(2,'i'),(3,'j'),(4,'k'); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE VIEW v2 AS SELECT * FROM t2; +(SELECT p1 FROM v2 LEFT JOIN v1 ON b = a WHERE p2 = 1 GROUP BY p1 ORDER BY p1) +UNION (SELECT NULL LIMIT 0); +p1 +NULL +DROP VIEW v1, v2; +DROP TABLE t1, t2; set optimizer_switch=default; === added file 'mysql-test/suite/innodb/r/innodb_bug11754376.result' --- a/mysql-test/suite/innodb/r/innodb_bug11754376.result 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/innodb/r/innodb_bug11754376.result 2012-02-06 11:00:41 +0000 @@ -0,0 +1,4 @@ +CREATE TABLE bug11754376 (c INT) ENGINE=INNODB; +SET SESSION DEBUG='+d,test_normalize_table_name_low'; +DROP TABLE bug11754376; +SET SESSION DEBUG='-d,test_normalize_table_name_low'; === added file 'mysql-test/suite/innodb/t/innodb_bug11754376.test' --- a/mysql-test/suite/innodb/t/innodb_bug11754376.test 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/innodb/t/innodb_bug11754376.test 2012-02-06 11:00:41 +0000 @@ -0,0 +1,16 @@ +# +# Bug#11754376 45976: INNODB LOST FILES FOR TEMPORARY TABLES ON GRACEFUL SHUTDOWN +# + +-- source include/have_debug.inc +-- source include/have_innodb.inc + +CREATE TABLE bug11754376 (c INT) ENGINE=INNODB; + +# This will invoke test_normalize_table_name_low() in debug builds + +SET SESSION DEBUG='+d,test_normalize_table_name_low'; + +DROP TABLE bug11754376; + +SET SESSION DEBUG='-d,test_normalize_table_name_low'; === modified file 'mysql-test/t/join_outer.test' --- a/mysql-test/t/join_outer.test 2012-01-03 11:04:14 +0000 +++ b/mysql-test/t/join_outer.test 2012-02-06 12:47:30 +0000 @@ -1489,3 +1489,19 @@ eval SELECT $rest_of_query; eval EXPLAIN SELECT $rest_of_query; drop table t1,t2,t3,t4,t5,t6; + +--echo # +--echo # Bug#13464334 SAME QUERY PRODUCES DIFFERENT RESULTS WHEN USED WITH AND +--echo # WITHOUT UNION ALL +--echo # + +CREATE TABLE t1 (p1 INT PRIMARY KEY, a CHAR(1)); +CREATE TABLE t2 (p2 INT PRIMARY KEY, b CHAR(1)); +INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c'); +INSERT INTO t2 VALUES (1,'h'),(2,'i'),(3,'j'),(4,'k'); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE VIEW v2 AS SELECT * FROM t2; +(SELECT p1 FROM v2 LEFT JOIN v1 ON b = a WHERE p2 = 1 GROUP BY p1 ORDER BY p1) +UNION (SELECT NULL LIMIT 0); +DROP VIEW v1, v2; +DROP TABLE t1, t2; === modified file 'sql/item.h' --- a/sql/item.h 2012-01-31 15:16:16 +0000 +++ b/sql/item.h 2012-02-06 12:47:30 +0000 @@ -2034,7 +2034,8 @@ public: bool is_outer_field() const { DBUG_ASSERT(fixed); - return field->table->pos_in_table_list->outer_join; + return field->table->pos_in_table_list->outer_join || + field->table->pos_in_table_list->in_outer_join_nest(); } Field::geometry_type get_geometry_type() const { === modified file 'sql/sql_optimizer.cc' --- a/sql/sql_optimizer.cc 2012-01-27 14:22:35 +0000 +++ b/sql/sql_optimizer.cc 2012-02-06 12:47:30 +0000 @@ -55,7 +55,7 @@ static Item *optimize_cond(JOIN *join, I List *join_list, bool build_equalities, Item::cond_result *cond_value); -static bool list_contains_unique_index(TABLE *table, +static bool list_contains_unique_index(JOIN_TAB *tab, bool (*find_func) (Field *, void *), void *data); static bool find_field_in_item_list (Field *field, void *data); static bool find_field_in_order_list (Field *field, void *data); @@ -522,7 +522,7 @@ JOIN::optimize() QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX)) { if (group_list && rollup.state == ROLLUP::STATE_NONE && - list_contains_unique_index(join_tab[const_tables].table, + list_contains_unique_index(&join_tab[const_tables], find_field_in_order_list, (void *) group_list)) { @@ -560,7 +560,7 @@ JOIN::optimize() group= 0; } if (select_distinct && - list_contains_unique_index(join_tab[const_tables].table, + list_contains_unique_index(&join_tab[const_tables], find_field_in_item_list, (void *) &fields_list)) { @@ -8069,7 +8069,7 @@ internal_remove_eq_conds(THD *thd, Item if (!eq_cond) return cond; - if (field->table->pos_in_table_list->outer_join) + if (args[0]->is_outer_field()) { // outer join: transform "col IS NULL" to "col IS NULL or col=0" Item *or_cond= new(thd->mem_root) Item_cond_or(eq_cond, cond); @@ -8223,7 +8223,7 @@ remove_eq_conds(THD *thd, Item *cond, It can safely remove the GROUP BY/DISTINCT, as no result set can be more distinct than an unique key. - @param table The table to operate on. + @param tab The join table to operate on. @param find_func function to iterate over the list and search for a field @@ -8231,13 +8231,19 @@ remove_eq_conds(THD *thd, Item *cond, It 1 found @retval 0 not found. + + @note + The function assumes that make_outerjoin_info() has been called in + order for the check for outer tables to work. */ static bool -list_contains_unique_index(TABLE *table, +list_contains_unique_index(JOIN_TAB *tab, bool (*find_func) (Field *, void *), void *data) { - if (table->pos_in_table_list->outer_join) + TABLE *table= tab->table; + + if (tab->is_inner_table_of_outer_join()) return 0; for (uint keynr= 0; keynr < table->s->keys; keynr++) { === modified file 'storage/innobase/handler/ha_innodb.cc' --- a/storage/innobase/handler/ha_innodb.cc 2012-02-02 12:00:50 +0000 +++ b/storage/innobase/handler/ha_innodb.cc 2012-02-06 11:04:33 +0000 @@ -3810,37 +3810,114 @@ normalize_table_name_low( { char* name_ptr; char* db_ptr; + ulint db_len; char* ptr; /* Scan name from the end */ - ptr = strend(name)-1; + ptr = strend(name) - 1; + /* seek to the last path separator */ while (ptr >= name && *ptr != '\\' && *ptr != '/') { ptr--; } name_ptr = ptr + 1; - DBUG_ASSERT(ptr > name); + /* skip any number of path separators */ + while (ptr >= name && (*ptr == '\\' || *ptr == '/')) { + ptr--; + } - ptr--; + DBUG_ASSERT(ptr >= name); + /* seek to the last but one path separator or one char before + the beginning of name */ + db_len = 0; while (ptr >= name && *ptr != '\\' && *ptr != '/') { ptr--; + db_len++; } db_ptr = ptr + 1; - memcpy(norm_name, db_ptr, strlen(name) + 1 - (db_ptr - name)); + memcpy(norm_name, db_ptr, db_len); - norm_name[name_ptr - db_ptr - 1] = '/'; + norm_name[db_len] = '/'; + + memcpy(norm_name + db_len + 1, name_ptr, strlen(name_ptr) + 1); if (set_lower_case) { innobase_casedn_str(norm_name); } } +#if !defined(DBUG_OFF) +/********************************************************************* +Test normalize_table_name_low(). */ +static +void +test_normalize_table_name_low() +/*===========================*/ +{ + char norm_name[128]; + const char* test_data[][2] = { + /* input, expected result */ + {"./mysqltest/t1", "mysqltest/t1"}, + {"./test/#sql-842b_2", "test/#sql-842b_2"}, + {"./test/#sql-85a3_10", "test/#sql-85a3_10"}, + {"./test/#sql2-842b-2", "test/#sql2-842b-2"}, + {"./test/bug29807", "test/bug29807"}, + {"./test/foo", "test/foo"}, + {"./test/innodb_bug52663", "test/innodb_bug52663"}, + {"./test/t", "test/t"}, + {"./test/t1", "test/t1"}, + {"./test/t10", "test/t10"}, + {"/a/b/db/table", "db/table"}, + {"/a/b/db///////table", "db/table"}, + {"/a/b////db///////table", "db/table"}, + {"/var/tmp/mysqld.1/#sql842b_2_10", "mysqld.1/#sql842b_2_10"}, + {"db/table", "db/table"}, + {"ddd/t", "ddd/t"}, + {"d/ttt", "d/ttt"}, + {"d/t", "d/t"}, + {".\\mysqltest\\t1", "mysqltest/t1"}, + {".\\test\\#sql-842b_2", "test/#sql-842b_2"}, + {".\\test\\#sql-85a3_10", "test/#sql-85a3_10"}, + {".\\test\\#sql2-842b-2", "test/#sql2-842b-2"}, + {".\\test\\bug29807", "test/bug29807"}, + {".\\test\\foo", "test/foo"}, + {".\\test\\innodb_bug52663", "test/innodb_bug52663"}, + {".\\test\\t", "test/t"}, + {".\\test\\t1", "test/t1"}, + {".\\test\\t10", "test/t10"}, + {"C:\\a\\b\\db\\table", "db/table"}, + {"C:\\a\\b\\db\\\\\\\\\\\\\\table", "db/table"}, + {"C:\\a\\b\\\\\\\\db\\\\\\\\\\\\\\table", "db/table"}, + {"C:\\var\\tmp\\mysqld.1\\#sql842b_2_10", "mysqld.1/#sql842b_2_10"}, + {"db\\table", "db/table"}, + {"ddd\\t", "ddd/t"}, + {"d\\ttt", "d/ttt"}, + {"d\\t", "d/t"}, + }; + + for (size_t i = 0; i < UT_ARR_SIZE(test_data); i++) { + printf("test_normalize_table_name_low(): " + "testing \"%s\", expected \"%s\"... ", + test_data[i][0], test_data[i][1]); + + normalize_table_name_low(norm_name, test_data[i][0], FALSE); + + if (strcmp(norm_name, test_data[i][1]) == 0) { + printf("ok\n"); + } else { + printf("got \"%s\"\n", norm_name); + ut_error; + } + } +} +#endif /* !DBUG_OFF */ + /********************************************************************//** Get the upper limit of the MySQL integral and floating-point type. @return maximum allowed value for the field */ @@ -9084,6 +9161,11 @@ ha_innobase::delete_table( DBUG_ENTER("ha_innobase::delete_table"); + DBUG_EXECUTE_IF( + "test_normalize_table_name_low", + test_normalize_table_name_low(); + ); + /* Strangely, MySQL passes the table name without the '.frm' extension, in contrast to ::create */ normalize_table_name(norm_name, name); No bundle (reason: useless for push emails).