Commit f3fb9a86 authored by unknown's avatar unknown

Merge whalegate.ndb.mysql.com:/home/tomas/mysql-5.1-target-5.1.22

into  whalegate.ndb.mysql.com:/home/tomas/mysql-5.1-new-ndb


sql/log_event.cc:
  Auto merged
parents c3858a82 823c6bf6
......@@ -939,6 +939,29 @@ alter table t1 add index(a(1024));
show create table t1;
drop table t1;
#
# Bug #31001: ORDER BY DESC in InnoDB not working
#
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a), INDEX b (b)) ENGINE=InnoDB;
INSERT INTO t1(a,b) VALUES (1,1), (2,2), (3,2);
#The two queries below should produce different results, but they don't.
query_vertical EXPLAIN SELECT * FROM t1 WHERE b=2 ORDER BY a ASC;
SELECT * FROM t1 WHERE b=2 ORDER BY a ASC;
query_vertical EXPLAIN SELECT * FROM t1 WHERE b=2 ORDER BY a DESC;
SELECT * FROM t1 WHERE b=2 ORDER BY a DESC;
query_vertical EXPLAIN SELECT * FROM t1 ORDER BY b ASC, a ASC;
SELECT * FROM t1 ORDER BY b ASC, a ASC;
query_vertical EXPLAIN SELECT * FROM t1 ORDER BY b DESC, a DESC;
SELECT * FROM t1 ORDER BY b DESC, a DESC;
query_vertical EXPLAIN SELECT * FROM t1 ORDER BY b ASC, a DESC;
SELECT * FROM t1 ORDER BY b ASC, a DESC;
query_vertical EXPLAIN SELECT * FROM t1 ORDER BY b DESC, a ASC;
SELECT * FROM t1 ORDER BY b DESC, a ASC;
DROP TABLE t1;
--echo End of 5.0 tests
# Fix for BUG#19243 "wrong LAST_INSERT_ID() after ON DUPLICATE KEY
......
......@@ -1123,6 +1123,103 @@ t1 CREATE TABLE `t1` (
KEY `a` (`a`(255))
) ENGINE=InnoDB DEFAULT CHARSET=utf8
drop table t1;
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a), INDEX b (b)) ENGINE=InnoDB;
INSERT INTO t1(a,b) VALUES (1,1), (2,2), (3,2);
EXPLAIN SELECT * FROM t1 WHERE b=2 ORDER BY a ASC;
id 1
select_type SIMPLE
table t1
type ref
possible_keys b
key b
key_len 5
ref const
rows 1
Extra Using where; Using index
SELECT * FROM t1 WHERE b=2 ORDER BY a ASC;
a b
2 2
3 2
EXPLAIN SELECT * FROM t1 WHERE b=2 ORDER BY a DESC;
id 1
select_type SIMPLE
table t1
type ref
possible_keys b
key b
key_len 5
ref const
rows 1
Extra Using where; Using index
SELECT * FROM t1 WHERE b=2 ORDER BY a DESC;
a b
3 2
2 2
EXPLAIN SELECT * FROM t1 ORDER BY b ASC, a ASC;
id 1
select_type SIMPLE
table t1
type index
possible_keys NULL
key b
key_len 5
ref NULL
rows 3
Extra Using index
SELECT * FROM t1 ORDER BY b ASC, a ASC;
a b
1 1
2 2
3 2
EXPLAIN SELECT * FROM t1 ORDER BY b DESC, a DESC;
id 1
select_type SIMPLE
table t1
type index
possible_keys NULL
key b
key_len 5
ref NULL
rows 3
Extra Using index
SELECT * FROM t1 ORDER BY b DESC, a DESC;
a b
3 2
2 2
1 1
EXPLAIN SELECT * FROM t1 ORDER BY b ASC, a DESC;
id 1
select_type SIMPLE
table t1
type index
possible_keys NULL
key b
key_len 5
ref NULL
rows 3
Extra Using index; Using filesort
SELECT * FROM t1 ORDER BY b ASC, a DESC;
a b
1 1
3 2
2 2
EXPLAIN SELECT * FROM t1 ORDER BY b DESC, a ASC;
id 1
select_type SIMPLE
table t1
type index
possible_keys NULL
key b
key_len 5
ref NULL
rows 3
Extra Using index; Using filesort
SELECT * FROM t1 ORDER BY b DESC, a ASC;
a b
2 2
3 2
1 1
DROP TABLE t1;
End of 5.0 tests
CREATE TABLE `t2` (
`k` int(11) NOT NULL auto_increment,
......
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
CREATE DATABASE track;
USE track;
CREATE TABLE `visits` (
`visits_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`myid` varchar(32) NOT NULL DEFAULT '',
`src` varchar(64) NOT NULL DEFAULT '',
`ip` int(10) unsigned NOT NULL DEFAULT '0',
`cc` char(2) NOT NULL DEFAULT '',
`org` varchar(80) DEFAULT NULL,
`ref` varchar(255) NOT NULL DEFAULT '',
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`host` varchar(30) NOT NULL DEFAULT '',
`entry` varchar(255) NOT NULL DEFAULT '',
`visit_exit` varchar(255) NOT NULL DEFAULT '',
`user_id` int(11) unsigned NOT NULL DEFAULT '0',
`visit_start` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`visits_id`),
KEY `ip` (`ip`),
KEY `time` (`time`),
KEY `user_id` (`user_id`)
) ENGINE=MyISAM AUTO_INCREMENT=21293381 DEFAULT CHARSET=latin1;
CREATE TABLE `visits_events` (
`event_id` mediumint(8) unsigned NOT NULL DEFAULT '0',
`visit_id` int(11) unsigned NOT NULL DEFAULT '0',
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`src` varchar(64) NOT NULL DEFAULT '',
`data` varchar(255) NOT NULL DEFAULT '',
`visits_events_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`visits_events_id`),
KEY `event_id` (`event_id`),
KEY `visit_id` (`visit_id`),
KEY `data` (`data`)
) ENGINE=MyISAM AUTO_INCREMENT=33900731 DEFAULT CHARSET=latin1;
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
BINLOG '
Bk3vRhO0AQAAOAAAALcLyQkAAJlXFwIAAAAABXRyYWNrAA12aXNpdHNfZXZlbnRzAAYJAwcPDwM=
Bk3vRhe0AQAAWgAAABEMyQkQAJlXFwIAAAEABv/AIE4AvvVDAQZN70YAK0Rvd25sb2Fkcy9NeVNR
TC00LjEvbXlzcWwtNC4xLjEyYS13aW4zMi56aXBPaAIC
'/*!*/;
SET INSERT_ID=21231039/*!*/;
use track/*!*/;
SET TIMESTAMP=1190087942/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
SET @@session.time_zone='UTC'/*!*/;
INSERT INTO visits (myid, user_id, src, ip, cc, org, ref, time, host, entry, visit_exit, visit_start)
VALUES ('3m3l4rhs6do0sf5p1i9lr94g928a272v', '', '', INET_ATON('71.118.124.98'), '', '', 'http://dev.mysql.com/downloads/connector/j/3.0.html', NULL, 'dev.mysql.com', '/get/Downloads/Connector-J/mysql-connector-java-3.0.17-ga.zip/from/pick', '/get/Downloads/Connector-J/mysql-connector-java-3.0.17-ga.zip/from/pick', NOW())/*!*/;
Warnings:
Warning 1366 Incorrect integer value: '' for column 'user_id' at row 1
SELECT * FROM visits;
visits_id myid src ip cc org ref time host entry visit_exit user_id visit_start
21231039 3m3l4rhs6do0sf5p1i9lr94g928a272v 1198947426 http://dev.mysql.com/downloads/connector/j/3.0.html 2007-09-18 03:59:02 dev.mysql.com /get/Downloads/Connector-J/mysql-connector-java-3.0.17-ga.zip/from/pick /get/Downloads/Connector-J/mysql-connector-java-3.0.17-ga.zip/from/pick 0 2007-09-18 03:59:02
SELECT * FROM visits_events;
event_id visit_id timestamp src data visits_events_id
20000 21231038 2007-09-18 03:59:02 Downloads/MySQL-4.1/mysql-4.1.12a-win32.zip 33712207
source include/master-slave.inc;
CREATE DATABASE track;
USE track;
CREATE TABLE `visits` (
`visits_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`myid` varchar(32) NOT NULL DEFAULT '',
`src` varchar(64) NOT NULL DEFAULT '',
`ip` int(10) unsigned NOT NULL DEFAULT '0',
`cc` char(2) NOT NULL DEFAULT '',
`org` varchar(80) DEFAULT NULL,
`ref` varchar(255) NOT NULL DEFAULT '',
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`host` varchar(30) NOT NULL DEFAULT '',
`entry` varchar(255) NOT NULL DEFAULT '',
`visit_exit` varchar(255) NOT NULL DEFAULT '',
`user_id` int(11) unsigned NOT NULL DEFAULT '0',
`visit_start` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`visits_id`),
KEY `ip` (`ip`),
KEY `time` (`time`),
KEY `user_id` (`user_id`)
) ENGINE=MyISAM AUTO_INCREMENT=21293381 DEFAULT CHARSET=latin1;
CREATE TABLE `visits_events` (
`event_id` mediumint(8) unsigned NOT NULL DEFAULT '0',
`visit_id` int(11) unsigned NOT NULL DEFAULT '0',
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`src` varchar(64) NOT NULL DEFAULT '',
`data` varchar(255) NOT NULL DEFAULT '',
`visits_events_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`visits_events_id`),
KEY `event_id` (`event_id`),
KEY `visit_id` (`visit_id`),
KEY `data` (`data`)
) ENGINE=MyISAM AUTO_INCREMENT=33900731 DEFAULT CHARSET=latin1;
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
--delimiter /*!*/;
# at 164170623
# at 164170679
#7918 3:59:2 server id 436 end_log_pos 164170679
# 9c90b7f 06 4d ef 46 13 b4 01 00 00 38 00 00 00 b7 0b c9 |.M.F.....8......|
# 9c90b8f 09 00 00 99 57 17 02 00 00 00 00 05 74 72 61 63 |....W.......trac|
# 9c90b9f 6b 00 0d 76 69 |k..vi|
# Table_map: `track`.`visits_events` mapped to number 35084185
#7918 3:59:2 server id 436 end_log_pos 164170769
# 9c90bb7 06 4d ef 46 17 b4 01 00 00 5a 00 00 00 11 0c c9 |.M.F.....Z......|
# 9c90bc7 09 10 00 99 57 17 02 00 00 01 00 06 ff c0 20 4e |....W..........N|
# 9c90bd7 00 be f5 43 01 06 4d ef 46 00 2b 44 6f 77 6e 6c |...C..M.F..Downl|
# 9c90be7 6f 61 64 73 2f 4d 79 53 51 4c 2d 34 2e 31 2f 6d |oads.MySQL.4.1.m|
# 9c90bf7 79 73 71 6c 2d 34 2e |ysql.4.|
# Write_rows: table id 35084185 flags: STMT_END_F
BINLOG '
Bk3vRhO0AQAAOAAAALcLyQkAAJlXFwIAAAAABXRyYWNrAA12aXNpdHNfZXZlbnRzAAYJAwcPDwM=
Bk3vRhe0AQAAWgAAABEMyQkQAJlXFwIAAAEABv/AIE4AvvVDAQZN70YAK0Rvd25sb2Fkcy9NeVNR
TC00LjEvbXlzcWwtNC4xLjEyYS13aW4zMi56aXBPaAIC
'/*!*/;
# at 164170769
#7918 3:59:2 server id 436 end_log_pos 164170797
# 9c90c11 06 4d ef 46 05 b4 01 00 00 |.M.F.....|
# Intvar
SET INSERT_ID=21231039/*!*/;
# at 164170797
#7918 3:59:2 server id 436 end_log_pos 164171293
# 9c90c2d 06 4d ef 46 02 b4 01 00 00 f0 01 00 00 1d 0e c9 |.M.F............|
# 9c90c3d 09 10 00 28 80 af 01 00 00 00 00 05 00 00 1f 00 |................|
# 9c90c4d 00 00 40 00 00 01 00 00 00 00 00 00 00 00 06 03 |................|
# 9c90c5d 73 74 64 04 08 00 08 00 08 00 05 03 55 54 43 74 |std.........UTCt|
# 9c90c6d 72 61 63 6b 00 49 4e 53 45 52 54 20 49 4e 54 4f |rack.INSERT.INTO|
# 9c90c7d 20 76 69 73 69 74 73 20 28 6d 79 69 64 2c 20 75 |.visits..myid..u|
# 9c90c8d 73 65 72 5f 69 64 2c 20 73 72 63 2c 20 69 70 2c |ser.id..src..ip.|
# 9c90c9d 20 63 63 2c 20 6f 72 67 2c 20 72 65 66 2c 20 74 |.cc..org..ref..t|
# 9c90cad 69 6d 65 2c 20 68 6f 73 74 2c 20 65 6e 74 72 79 |ime..host..entry|
# 9c90cbd 2c 20 76 69 73 69 74 5f 65 78 69 74 2c 20 76 69 |..visit.exit..vi|
# 9c90ccd 73 69 74 5f 73 74 61 72 74 29 0a 09 09 09 56 41 |sit.start.....VA|
# 9c90cdd 4c 55 45 53 20 28 27 33 6d 33 6c 34 72 68 73 36 |LUES...3m3l4rhs6|
# 9c90ced 64 6f 30 73 66 35 70 31 69 39 6c 72 39 34 67 39 |do0sf5p1i9lr94g9|
# 9c90cfd 32 38 61 32 37 32 76 27 2c 20 27 27 2c 20 27 27 |28a272v.........|
# 9c90d0d 2c 20 49 4e 45 54 5f 41 54 4f 4e 28 27 37 31 2e |..INET.ATON..71.|
# 9c90d1d 31 31 38 2e 31 32 34 2e 39 38 27 29 2c 20 27 27 |118.124.98......|
# 9c90d2d 2c 20 27 27 2c 20 27 68 74 74 70 3a 2f 2f 64 65 |.......http...de|
# 9c90d3d 76 2e 6d 79 73 71 6c 2e 63 6f 6d 2f 64 6f 77 6e |v.mysql.com.down|
# 9c90d4d 6c 6f 61 64 73 2f 63 6f 6e 6e 65 63 74 6f 72 2f |loads.connector.|
# 9c90d5d 6a 2f 33 2e 30 2e 68 74 6d 6c 27 2c 20 4e 55 4c |j.3.0.html...NUL|
# 9c90d6d 4c 2c 20 27 64 65 76 2e 6d 79 73 71 6c 2e 63 6f |L...dev.mysql.co|
# 9c90d7d 6d 27 2c 20 27 2f 67 65 74 2f 44 6f 77 6e 6c 6f |m.....get.Downlo|
# 9c90d8d 61 64 73 2f 43 6f 6e 6e 65 63 74 6f 72 2d 4a 2f |ads.Connector.J.|
# 9c90d9d 6d 79 73 71 6c 2d 63 6f 6e 6e 65 63 74 6f 72 2d |mysql.connector.|
# 9c90dad 6a 61 76 61 2d 33 2e 30 2e 31 37 2d 67 61 2e 7a |java.3.0.17.ga.z|
# 9c90dbd 69 70 2f 66 72 6f 6d 2f 70 69 63 6b 27 2c 20 27 |ip.from.pick....|
# 9c90dcd 2f 67 65 74 2f 44 6f 77 6e 6c 6f 61 64 73 2f 43 |.get.Downloads.C|
# 9c90ddd 6f 6e 6e 65 63 74 6f 72 2d 4a 2f 6d 79 73 71 6c |onnector.J.mysql|
# 9c90ded 2d 63 6f 6e 6e 65 63 74 6f 72 2d 6a 61 76 61 2d |.connector.java.|
# 9c90dfd 33 2e 30 2e 31 37 2d 67 61 2e 7a 69 70 |3.0.17.ga.zip|
# Query thread_id=28278824 exec_time=0 error_code=0
use track/*!*/;
SET TIMESTAMP=1190087942/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
SET @@session.time_zone='UTC'/*!*/;
INSERT INTO visits (myid, user_id, src, ip, cc, org, ref, time, host, entry, visit_exit, visit_start)
VALUES ('3m3l4rhs6do0sf5p1i9lr94g928a272v', '', '', INET_ATON('71.118.124.98'), '', '', 'http://dev.mysql.com/downloads/connector/j/3.0.html', NULL, 'dev.mysql.com', '/get/Downloads/Connector-J/mysql-connector-java-3.0.17-ga.zip/from/pick', '/get/Downloads/Connector-J/mysql-connector-java-3.0.17-ga.zip/from/pick', NOW())/*!*/;
# at 164171293
--delimiter ;
SELECT * FROM visits;
SELECT * FROM visits_events;
......@@ -363,7 +363,7 @@ then
USER_OPTION="--user=$user"
fi
# Change the err log to the right user, if it is in use
if [ $syslog -eq 0 ]; then
if [ $want_syslog -eq 0 ]; then
touch $err_log
chown $user $err_log
fi
......
......@@ -6621,6 +6621,7 @@ Table_map_log_event::Table_map_log_event(THD *thd, TABLE *tbl, ulong tid,
m_tblnam(tbl->s->table_name.str),
m_tbllen(tbl->s->table_name.length),
m_colcnt(tbl->s->fields), m_field_metadata(0),
m_field_metadata_size(0), m_memory(NULL), m_meta_memory(NULL), m_data_size(0),
m_table_id(tid), m_null_bits(0), m_flags(flags)
{
DBUG_ASSERT(m_table_id != ~0UL);
......@@ -6695,8 +6696,11 @@ Table_map_log_event::Table_map_log_event(const char *buf, uint event_len,
#ifndef MYSQL_CLIENT
m_table(NULL),
#endif
m_memory(NULL),
m_field_metadata(0), m_field_metadata_size(0)
m_dbnam(NULL), m_dblen(0), m_tblnam(NULL), m_tbllen(0),
m_colcnt(0), m_coltype(0),
m_memory(NULL), m_table_id(ULONG_MAX), m_flags(0),
m_data_size(0), m_field_metadata(0), m_field_metadata_size(0),
m_null_bits(0), m_meta_memory(NULL)
{
unsigned int bytes_read= 0;
DBUG_ENTER("Table_map_log_event::Table_map_log_event(const char*,uint,...)");
......
......@@ -12306,6 +12306,12 @@ static int test_if_order_by_key(ORDER *order, TABLE *table, uint idx,
for (; const_key_parts & 1 ; const_key_parts>>= 1)
key_part++;
/*
The primary and secondary key parts were all const (i.e. there's
one row). The sorting doesn't matter.
*/
if (key_part == key_part_end && reverse == 0)
DBUG_RETURN(1);
}
else
DBUG_RETURN(0);
......@@ -12723,7 +12729,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
}
DBUG_RETURN(1);
}
if (tab->ref.key_parts < used_key_parts)
if (tab->ref.key_parts <= used_key_parts)
{
/*
SELECT * FROM t1 WHERE a=1 ORDER BY a DESC,b DESC
......
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