List:Internals« Previous MessageNext Message »
From:Mats Kindahl Date:April 8 2005 9:54am
Subject:bk commit into 5.1 tree (mats:1.1801)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of mats. When mats does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.1801 05/04/08 11:54:39 mats@stripped +10 -0
  WL#1012: Adding table flag to indicate that engine can provide random
  access to records in table.

  mysql-test/t/rpl_row_basic_innodb.test
    1.1 05/04/08 11:54:31 mats@stripped +104 -0

  mysql-test/t/rpl_row_basic_innodb-slave.opt
    1.1 05/04/08 11:54:31 mats@stripped +2 -0

  mysql-test/t/rpl_row_basic_innodb-master.opt
    1.1 05/04/08 11:54:31 mats@stripped +1 -0

  mysql-test/t/rpl_row_basic_innodb.test
    1.0 05/04/08 11:54:31 mats@stripped +0 -0
    BitKeeper file /home/bk/w1012-mysql-5.1/mysql-test/t/rpl_row_basic_innodb.test

  mysql-test/t/rpl_row_basic_innodb-slave.opt
    1.0 05/04/08 11:54:31 mats@stripped +0 -0
    BitKeeper file /home/bk/w1012-mysql-5.1/mysql-test/t/rpl_row_basic_innodb-slave.opt

  mysql-test/t/rpl_row_basic_innodb-master.opt
    1.0 05/04/08 11:54:31 mats@stripped +0 -0
    BitKeeper file /home/bk/w1012-mysql-5.1/mysql-test/t/rpl_row_basic_innodb-master.opt

  mysql-test/r/rpl_row_basic_innodb.result
    1.1 05/04/08 11:54:30 mats@stripped +214 -0

  sql/log_event.cc
    1.170 05/04/08 11:54:30 mats@stripped +92 -97
    Extending with table flag to tell that storage engine allow random
    access of tables with primary keys.

  sql/handler.h
    1.133 05/04/08 11:54:30 mats@stripped +6 -1
    Extending with table flag to tell that storage engine allow random
    access of tables with primary keys.

  mysql-test/r/rpl_row_basic_innodb.result
    1.0 05/04/08 11:54:30 mats@stripped +0 -0
    BitKeeper file /home/bk/w1012-mysql-5.1/mysql-test/r/rpl_row_basic_innodb.result

  sql/ha_ndbcluster.cc
    1.166 05/04/08 11:54:29 mats@stripped +1 -0
    InnoDB allows random access.

  sql/ha_innodb.h
    1.89 05/04/08 11:54:29 mats@stripped +1 -0
    InnoDB allows random access.

  mysql-test/t/rpl_row_basic_myisam.test
    1.5 05/04/08 11:54:29 mats@stripped +9 -9
    Introducing basic tests for several engines.

  mysql-test/r/rpl_row_basic_myisam.result
    1.5 05/04/08 11:54:29 mats@stripped +14 -14
    Introducing basic tests for several engines.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	mats
# Host:	romeo.kindahl.net
# Root:	/home/bk/w1012-mysql-5.1

--- 1.132/sql/handler.h	2005-04-01 13:25:13 +02:00
+++ 1.133/sql/handler.h	2005-04-08 11:54:30 +02:00
@@ -66,6 +66,12 @@
                                             need no special code to support
                                             INSERT DELAYED */
 #define HA_PRIMARY_KEY_IN_READ_INDEX (1 << 15)
+/* 
+   The position of an arbitrary record can be retrieved using position() when
+   the table has a primary key, effectively allowing random access on the
+   table based on a given record.
+*/ 
+#define HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS (1 << 16) 
 #define HA_NOT_DELETE_WITH_CACHE (1 << 18)
 #define HA_NO_PREFIX_CHAR_KEYS (1 << 20)
 #define HA_CAN_FULLTEXT        (1 << 21)
@@ -77,7 +83,6 @@
 #define HA_NO_VARCHAR	       (1 << 27)
 #define HA_CAN_BIT_FIELD       (1 << 28) /* supports bit fields */
 #define HA_NEED_READ_RANGE_BUFFER (1 << 29) /* for read_multi_range */
-
 
 /* bits in index_flags(index_number) for what you can do with index */
 #define HA_READ_NEXT            1       /* TODO really use this flag */

--- 1.169/sql/log_event.cc	2005-04-01 13:25:13 +02:00
+++ 1.170/sql/log_event.cc	2005-04-08 11:54:30 +02:00
@@ -4906,9 +4906,10 @@
     DBUG_PRINT("info", ("row_start = %p, m_rows_end = %p", 
 			row_start, m_rows_end));
     char const* row_end = do_prepare_row(thd, table, row_start);
-    DBUG_ASSERT(row_end != NULL);
     DBUG_PRINT("info", ("row_start = %p, row_end = %p, (length %u)", 
 			row_start, row_end, row_end - row_start));
+    DBUG_ASSERT(row_end != NULL);
+    DBUG_ASSERT(row_end <= m_rows_end);
     error = do_exec_row(table, rli);
     DBUG_PRINT("info", ("error = %d", error));
     row_start = row_end;
@@ -5281,6 +5282,86 @@
   }
   return 0;
 }
+
+
+/*
+  Find the row given by 'key', if the table has keys, or else use a table scan
+  to find (and fetch) the row.  If the engine allows random access of the
+  records, a combination of position() and rnd_pos() will be used.
+
+  The 'record_buf' will be used as buffer for records while locating the
+  correct row.
+ */
+static int find_and_fetch_row(TABLE* table, byte* key, byte* record_buf) 
+{
+  if ((table->file->table_flags() & HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS)
+      && table->s->primary_key < MAX_KEY)
+  {
+    // Use a more efficient method to fetch the record given by
+    // table->record[0] if the engine allows it.
+
+    DBUG_PRINT("info", ("Fetching row using random access methods"));
+    table->file->position(table->record[0]);
+    table->file->rnd_pos(table->record[0], table->file->ref);
+    return 0;
+  }
+
+  if (table->s->keys > 0) 
+  {
+    DBUG_PRINT("info", ("Fetching row using index"));
+    if (int error = table->file->index_read(record_buf, key, 
+					    table->key_info->key_length, 
+					    HA_READ_KEY_EXACT))
+    {
+      return error;
+    }
+
+    while (record_compare(table, table->record[0], record_buf) != 0)
+    {
+      if (int error = table->file->index_next(record_buf))
+      {
+	return error;
+      }
+    }
+  }
+  else
+  {
+    DBUG_PRINT("info", ("Fetching row by scanning table"));
+
+#if 0    // Save the position
+    table->file->position(record_buf);
+    byte* const last_rowid = table->file->ref;
+#endif
+
+    // Continue until we find the right record or have made a full loop
+    do
+    {
+      if (int const error = table->file->rnd_next(record_buf))
+      {
+	switch (error) 
+	{
+	case HA_ERR_END_OF_FILE:
+	  table->file->ha_rnd_init(1);
+	  continue;
+	case HA_ERR_RECORD_DELETED:
+	  continue;
+	default:
+	  return error;
+	}
+      }    
+
+#if 0
+      // Check if we've scanned the entire table.
+      table->file->position(record_buf);
+      if (table->file->cmp_ref(last_rowid, table->file->ref) == 0)
+	return HA_ERR_END_OF_FILE;
+#endif
+    }
+    while (record_compare(table, table->record[0], record_buf) != 0);
+  }
+  
+  return 0;
+}
 #endif
 
 /*
@@ -5397,57 +5478,13 @@
   DBUG_ENTER("Delete_rows_log_event::do_exec_row(TABLE*,...)");
   DBUG_ASSERT(table != NULL);
  
-  if (table->s->keys > 0) {
-    if (int error = table->file->index_read(m_search_record, m_key, 
-					    table->key_info->key_length, 
-					    HA_READ_KEY_EXACT))
-    {
-      DBUG_PRINT("return", ("error = %d", error));
-      DBUG_RETURN(error);
-    }
-
-    while (record_compare(table, table->record[0], m_search_record) != 0)
-    {
-      if (int error = table->file->index_next(m_search_record))
-      {
-	DBUG_PRINT("return", ("error = %d", error));
-	DBUG_RETURN(error);
-      }
-    }
-  }
-  else
+  if (int error = find_and_fetch_row(table, m_key, m_search_record))
   {
-    if (int const error = table->file->rnd_next(m_search_record))
-    {
-      DBUG_PRINT("return", ("error = %d", error));
-      DBUG_RETURN(error);
-    }
-
-    // Save the position
-    table->file->position(m_search_record);
-    byte* const last_rowid = table->file->ref;
-
-    // Continue until we find the right record or have made a full loop
-    while (record_compare(table, table->record[0], m_search_record) != 0)
-    {
-      if (int const error = table->file->rnd_next(m_search_record))
-      {
-	switch (error) {
-	case HA_ERR_END_OF_FILE:
-	  table->file->ha_rnd_init(1);
-	  continue;
-	case HA_ERR_RECORD_DELETED:
-	  continue;
-	default:
-	  DBUG_PRINT("return", ("error = %d", error));
-	  DBUG_RETURN(error);
-	}
-      }    
-    }
+    DBUG_PRINT("return", ("error = %d", error));
+    DBUG_RETURN(error);
   }
-
+    
   // Now we should have the right row to delete
-
   int const error = table->file->ha_delete_row(m_search_record);
 
   DBUG_PRINT("return", ("error = %d", error));
@@ -5506,6 +5543,7 @@
 		      NULL);
   if (!m_memory)
     DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+
   if (table->s->keys > 0) 
   {
     // We have a key: search the table using the index
@@ -5568,57 +5606,14 @@
 {
   DBUG_ENTER("Update_rows_log_event::do_exec_row(TABLE*,...)");
   DBUG_ASSERT(table != NULL);
-  if (table->s->keys > 0) {
-    if (int error = table->file
-	->index_read(m_search_record, m_key, 
-		     table->key_info->key_length, 
-		     HA_READ_KEY_EXACT))
-    {
-      DBUG_PRINT("return", ("error = %d", error));
-      DBUG_RETURN(error);
-    }
 
-    while (record_compare(table, table->record[0], m_search_record) != 0)
-    {
-      if (int error = table->file->index_next(m_search_record))
-      {
-	DBUG_PRINT("return", ("error = %d", error));
-	DBUG_RETURN(error);
-      }
-    }
-  }
-  else
+  if (int error = find_and_fetch_row(table, m_key, m_search_record))
   {
-    if (int const error = table->file->rnd_next(m_search_record))
-    {
-      DBUG_PRINT("return", ("error = %d", error));
-      DBUG_RETURN(error);
-    }
-
-    // Save the position
-    table->file->position(m_search_record);
-    byte* const last_rowid = table->file->ref;
-
-    // Continue until we find the right record or have made a full loop
-    while (record_compare(table, table->record[0], m_search_record) != 0)
-    {
-      if (int const error = table->file->rnd_next(m_search_record))
-      {
-	switch (error) {
-	case HA_ERR_END_OF_FILE:
-	  table->file->ha_rnd_init(1);
-	  continue;
-	case HA_ERR_RECORD_DELETED:
-	  continue;
-	default:
-	  DBUG_PRINT("return", ("error = %d", error));
-	  DBUG_RETURN(error);
-	}
-      }    
-    }
+    DBUG_PRINT("return", ("error = %d", error));
+    DBUG_RETURN(error);
   }
-
-  // Now we should have the right row to delete
+    
+  // Now we should have the right row to update
   int const error = table->file->ha_update_row(table->record[0], 
 					       table->record[1]);
 

--- 1.165/sql/ha_ndbcluster.cc	2005-03-15 15:22:36 +01:00
+++ 1.166/sql/ha_ndbcluster.cc	2005-04-08 11:54:29 +02:00
@@ -4098,6 +4098,7 @@
                 HA_AUTO_PART_KEY |
                 HA_NO_PREFIX_CHAR_KEYS |
                 HA_NEED_READ_RANGE_BUFFER |
+                HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS |
                 HA_CAN_BIT_FIELD),
   m_share(0),
   m_use_write(FALSE),

--- 1.4/mysql-test/r/rpl_row_basic_myisam.result	2005-04-04 16:29:34 +02:00
+++ 1.5/mysql-test/r/rpl_row_basic_myisam.result	2005-04-08 11:54:29 +02:00
@@ -4,23 +4,23 @@
 reset slave;
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
 start slave;
-CREATE TABLE t1 (C1 CHAR(1), C2 CHAR(1), INDEX (C1));
+CREATE TABLE t1 (C1 CHAR(1), C2 CHAR(1), INDEX (C1)) engine=myisam;
 SHOW BINLOG EVENTS;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-<binlog>	<pos>	Format_desc	1	<end_log_pos>	Server ver: 5.1.0-alpha-debug-log, Binlog ver: 4
-<binlog>	<pos>	Query	1	<end_log_pos>	use `test`; CREATE TABLE t1 (C1 CHAR(1), C2 CHAR(1), INDEX (C1))
+<binlog>	4	Format_desc	1	<end_log_pos>	Server ver: 5.1.0-alpha-debug-log, Binlog ver: 4
+<binlog>	102	Query	1	<end_log_pos>	use `test`; CREATE TABLE t1 (C1 CHAR(1), C2 CHAR(1), INDEX (C1)) engine=myisam
 SELECT * FROM t1;
 C1	C2
 SELECT * FROM t1;
 C1	C2
 INSERT INTO t1 VALUES ('A','B'), ('X','Y'), ('X','X');
 INSERT INTO t1 VALUES ('A','C'), ('X', 'Z'), ('A', 'A');
-SHOW BINLOG EVENTS FROM 218;
+SHOW BINLOG EVENTS FROM 232;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-<binlog>	<pos>	Table_map	1	<end_log_pos>	
-<binlog>	<pos>	Write_rows	1	<end_log_pos>	
-<binlog>	<pos>	Table_map	1	<end_log_pos>	
-<binlog>	<pos>	Write_rows	1	<end_log_pos>	
+<binlog>	232	Table_map	1	<end_log_pos>	
+<binlog>	268	Write_rows	1	<end_log_pos>	
+<binlog>	310	Table_map	1	<end_log_pos>	
+<binlog>	346	Write_rows	1	<end_log_pos>	
 SELECT * FROM t1;
 C1	C2
 A	B
@@ -38,10 +38,10 @@
 X	Z
 A	A
 DELETE FROM t1 WHERE C1 = C2;
-SHOW BINLOG EVENTS FROM 374;
+SHOW BINLOG EVENTS FROM 388;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-<binlog>	<pos>	Table_map	1	<end_log_pos>	
-<binlog>	<pos>	Delete_rows	1	<end_log_pos>	
+<binlog>	388	Table_map	1	<end_log_pos>	
+<binlog>	424	Delete_rows	1	<end_log_pos>	
 SELECT * FROM t1;
 C1	C2
 A	B
@@ -55,7 +55,7 @@
 A	C
 X	Z
 UPDATE t1 SET C2 = 'I' WHERE C1 = 'A' AND C2 = 'C';
-SHOW BINLOG EVENTS FROM 447;
+SHOW BINLOG EVENTS FROM 461;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 <binlog>	<pos>	Table_map	1	<end_log_pos>	
 <binlog>	<pos>	Update_rows	1	<end_log_pos>	
@@ -71,7 +71,7 @@
 X	Y
 A	I
 X	Z
-CREATE TABLE t2 (c1 INT, c2 INT, PRIMARY KEY (c1));
+CREATE TABLE t2 (c1 INT, c2 INT, PRIMARY KEY (c1)) engine=myisam;
 INSERT INTO t2 
 VALUES (1,2),  (2,4),  (3,9),  (4,15), (5,25), 
 (6,35), (7,50), (8,64), (9,81);
@@ -153,7 +153,7 @@
 6	36
 7	49
 9	81
-CREATE TABLE t3 (C1 CHAR(1), C2 CHAR(1));
+CREATE TABLE t3 (C1 CHAR(1), C2 CHAR(1)) engine=myisam;
 SELECT * FROM t3;
 C1	C2
 SELECT * FROM t3;
--- New file ---
+++ mysql-test/r/rpl_row_basic_innodb.result	05/04/08 11:54:30
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 TABLE t1 (C1 CHAR(1), C2 CHAR(1), INDEX (C1)) engine=innodb;
SHOW BINLOG EVENTS;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
<binlog>	4	Format_desc	1	<end_log_pos>	Server ver: 5.1.0-alpha-debug-log, Binlog ver: 4
<binlog>	102	Query	1	<end_log_pos>	use `test`; CREATE TABLE t1 (C1 CHAR(1), C2 CHAR(1), INDEX (C1)) engine=innodb
SELECT * FROM t1;
C1	C2
SELECT * FROM t1;
C1	C2
INSERT INTO t1 VALUES ('A','B'), ('X','Y'), ('X','X');
INSERT INTO t1 VALUES ('A','C'), ('X', 'Z'), ('A', 'A');
SHOW BINLOG EVENTS FROM 232;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
<binlog>	232	Table_map	1	<end_log_pos>	
<binlog>	268	Write_rows	1	<end_log_pos>	
<binlog>	310	Xid	1	<end_log_pos>	COMMIT /* xid=13 */
<binlog>	337	Table_map	1	<end_log_pos>	
<binlog>	373	Write_rows	1	<end_log_pos>	
<binlog>	415	Xid	1	<end_log_pos>	COMMIT /* xid=14 */
SELECT * FROM t1;
C1	C2
A	B
X	Y
X	X
A	C
X	Z
A	A
SELECT * FROM t1;
C1	C2
A	B
X	Y
X	X
A	C
X	Z
A	A
DELETE FROM t1 WHERE C1 = C2;
SHOW BINLOG EVENTS FROM 442;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
<binlog>	442	Table_map	1	<end_log_pos>	
<binlog>	478	Delete_rows	1	<end_log_pos>	
<binlog>	515	Xid	1	<end_log_pos>	COMMIT /* xid=18 */
SELECT * FROM t1;
C1	C2
A	B
X	Y
A	C
X	Z
SELECT * FROM t1;
C1	C2
A	B
X	Y
A	C
X	Z
UPDATE t1 SET C2 = 'I' WHERE C1 = 'A' AND C2 = 'C';
SHOW BINLOG EVENTS FROM 542;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
<binlog>	<pos>	Table_map	1	<end_log_pos>	
<binlog>	<pos>	Update_rows	1	<end_log_pos>	
<binlog>	<pos>	Xid	1	<end_log_pos>	COMMIT /* xid=22 */
SELECT * FROM t1;
C1	C2
A	B
X	Y
A	I
X	Z
SELECT * FROM t1;
C1	C2
A	B
X	Y
A	I
X	Z
CREATE TABLE t2 (c1 INT, c2 INT, PRIMARY KEY (c1)) engine=innodb;
INSERT INTO t2 
VALUES (1,2),  (2,4),  (3,9),  (4,15), (5,25), 
(6,35), (7,50), (8,64), (9,81);
SELECT * FROM t2;
c1	c2
1	2
2	4
3	9
4	15
5	25
6	35
7	50
8	64
9	81
SELECT * FROM t2 WHERE c2 = c1 * c1;
c1	c2
2	4
3	9
5	25
8	64
9	81
SELECT * FROM t2;
c1	c2
1	2
2	4
3	9
4	15
5	25
6	35
7	50
8	64
9	81
SELECT * FROM t2 WHERE c2 = c1 * c1;
c1	c2
2	4
3	9
5	25
8	64
9	81
UPDATE t2 SET c2 = c1*c1 WHERE c2 != c1*c1;
SELECT * FROM t2 WHERE c2 = c1 * c1;
c1	c2
1	1
2	4
3	9
4	16
5	25
6	36
7	49
8	64
9	81
SELECT * FROM t2 WHERE c2 = c1 * c1;
c1	c2
1	1
2	4
3	9
4	16
5	25
6	36
7	49
8	64
9	81
DELETE FROM t2 WHERE c1 % 4 = 0;
SELECT * FROM t2;
c1	c2
1	1
2	4
3	9
5	25
6	36
7	49
9	81
SELECT * FROM t2;
c1	c2
1	1
2	4
3	9
5	25
6	36
7	49
9	81
CREATE TABLE t3 (C1 CHAR(1), C2 CHAR(1)) engine=innodb;
SELECT * FROM t3;
C1	C2
SELECT * FROM t3;
C1	C2
INSERT INTO t3 VALUES ('A','B'), ('X','Y'), ('X','X');
INSERT INTO t3 VALUES ('A','C'), ('X', 'Z'), ('A', 'A');
SELECT * FROM t3;
C1	C2
A	B
X	Y
X	X
A	C
X	Z
A	A
SELECT * FROM t3;
C1	C2
A	B
X	Y
X	X
A	C
X	Z
A	A
DELETE FROM t3 WHERE C1 = C2;
SELECT * FROM t3;
C1	C2
A	B
X	Y
A	C
X	Z
SELECT * FROM t3;
C1	C2
A	B
X	Y
A	C
X	Z
SELECT * FROM t3;
C1	C2
A	B
X	Y
A	C
X	Z
UPDATE t3 SET C2 = 'I' WHERE C1 = 'A' AND C2 = 'C';
SELECT * FROM t3;
C1	C2
A	B
X	Y
A	I
X	Z
SELECT * FROM t3;
C1	C2
A	B
X	Y
A	I
X	Z


--- 1.4/mysql-test/t/rpl_row_basic_myisam.test	2005-04-04 16:28:35 +02:00
+++ 1.5/mysql-test/t/rpl_row_basic_myisam.test	2005-04-08 11:54:29 +02:00
@@ -4,8 +4,8 @@
 # Basic tests of row-level logging
 #
 
-CREATE TABLE t1 (C1 CHAR(1), C2 CHAR(1), INDEX (C1));
---replace_column 1 <binlog> 2 <pos> 5 <end_log_pos>
+CREATE TABLE t1 (C1 CHAR(1), C2 CHAR(1), INDEX (C1)) engine=myisam;
+--replace_column 1 <binlog> 5 <end_log_pos>
 SHOW BINLOG EVENTS;
 SELECT * FROM t1;
 sync_slave_with_master;
@@ -15,8 +15,8 @@
 connection master;
 INSERT INTO t1 VALUES ('A','B'), ('X','Y'), ('X','X');
 INSERT INTO t1 VALUES ('A','C'), ('X', 'Z'), ('A', 'A');
---replace_column 1 <binlog> 2 <pos> 5 <end_log_pos>
-SHOW BINLOG EVENTS FROM 218;
+--replace_column 1 <binlog> 5 <end_log_pos>
+SHOW BINLOG EVENTS FROM 232;
 SELECT * FROM t1;
 sync_slave_with_master;
 SELECT * FROM t1;
@@ -26,8 +26,8 @@
 # should be deleted.
 connection master;
 DELETE FROM t1 WHERE C1 = C2;
---replace_column 1 <binlog> 2 <pos> 5 <end_log_pos>
-SHOW BINLOG EVENTS FROM 374;
+--replace_column 1 <binlog> 5 <end_log_pos>
+SHOW BINLOG EVENTS FROM 388;
 SELECT * FROM t1;
 sync_slave_with_master;
 SELECT * FROM t1;
@@ -40,7 +40,7 @@
 connection master;
 UPDATE t1 SET C2 = 'I' WHERE C1 = 'A' AND C2 = 'C';
 --replace_column 1 <binlog> 2 <pos> 5 <end_log_pos>
-SHOW BINLOG EVENTS FROM 447;
+SHOW BINLOG EVENTS FROM 461;
 SELECT * FROM t1;
 sync_slave_with_master;
 SELECT * FROM t1;
@@ -49,7 +49,7 @@
 # Testing table with primary key
 #
 connection master;
-CREATE TABLE t2 (c1 INT, c2 INT, PRIMARY KEY (c1));
+CREATE TABLE t2 (c1 INT, c2 INT, PRIMARY KEY (c1)) engine=myisam;
 INSERT INTO t2 
   VALUES (1,2),  (2,4),  (3,9),  (4,15), (5,25), 
          (6,35), (7,50), (8,64), (9,81);
@@ -77,7 +77,7 @@
 # earlier.
 #
 connection master;
-CREATE TABLE t3 (C1 CHAR(1), C2 CHAR(1));
+CREATE TABLE t3 (C1 CHAR(1), C2 CHAR(1)) engine=myisam;
 SELECT * FROM t3;
 sync_slave_with_master;
 SELECT * FROM t3;
--- New file ---
+++ mysql-test/t/rpl_row_basic_innodb-master.opt	05/04/08 11:54:31
--innodb --binlog-format=row

--- New file ---
+++ mysql-test/t/rpl_row_basic_innodb-slave.opt	05/04/08 11:54:31
--innodb


--- New file ---
+++ mysql-test/t/rpl_row_basic_innodb.test	05/04/08 11:54:31
source include/master-slave.inc

#
# Basic tests of row-level logging
#

CREATE TABLE t1 (C1 CHAR(1), C2 CHAR(1), INDEX (C1)) engine=innodb;
--replace_column 1 <binlog> 5 <end_log_pos>
SHOW BINLOG EVENTS;
SELECT * FROM t1;
sync_slave_with_master;
SELECT * FROM t1;

# Testing insert
connection master;
INSERT INTO t1 VALUES ('A','B'), ('X','Y'), ('X','X');
INSERT INTO t1 VALUES ('A','C'), ('X', 'Z'), ('A', 'A');
--replace_column 1 <binlog> 5 <end_log_pos>
SHOW BINLOG EVENTS FROM 232;
SELECT * FROM t1;
sync_slave_with_master;
SELECT * FROM t1;
 
# Testing delete
# Observe that are several rows having the value for the index but only one
# should be deleted.
connection master;
DELETE FROM t1 WHERE C1 = C2;
--replace_column 1 <binlog> 5 <end_log_pos>
SHOW BINLOG EVENTS FROM 442;
SELECT * FROM t1;
sync_slave_with_master;
SELECT * FROM t1;

#
# Testing update.
# Note that we have a condition on a column that is not part of the index for
# the table. The right row should be updated nevertheless.
#
connection master;
UPDATE t1 SET C2 = 'I' WHERE C1 = 'A' AND C2 = 'C';
--replace_column 1 <binlog> 2 <pos> 5 <end_log_pos>
SHOW BINLOG EVENTS FROM 542;
SELECT * FROM t1;
sync_slave_with_master;
SELECT * FROM t1;

#
# Testing table with primary key
#
connection master;
CREATE TABLE t2 (c1 INT, c2 INT, PRIMARY KEY (c1)) engine=innodb;
INSERT INTO t2 
  VALUES (1,2),  (2,4),  (3,9),  (4,15), (5,25), 
         (6,35), (7,50), (8,64), (9,81);
SELECT * FROM t2;
SELECT * FROM t2 WHERE c2 = c1 * c1;
sync_slave_with_master;
SELECT * FROM t2;
SELECT * FROM t2 WHERE c2 = c1 * c1;

connection master;
UPDATE t2 SET c2 = c1*c1 WHERE c2 != c1*c1;
SELECT * FROM t2 WHERE c2 = c1 * c1;
sync_slave_with_master;
SELECT * FROM t2 WHERE c2 = c1 * c1;

connection master;
DELETE FROM t2 WHERE c1 % 4 = 0;
SELECT * FROM t2;
sync_slave_with_master;
SELECT * FROM t2;

#
# Testing table without index or primary key
# We don't bother about the binlog events here: they have been verified
# earlier.
#
connection master;
CREATE TABLE t3 (C1 CHAR(1), C2 CHAR(1)) engine=innodb;
SELECT * FROM t3;
sync_slave_with_master;
SELECT * FROM t3;

connection master;
INSERT INTO t3 VALUES ('A','B'), ('X','Y'), ('X','X');
INSERT INTO t3 VALUES ('A','C'), ('X', 'Z'), ('A', 'A');
SELECT * FROM t3;
sync_slave_with_master;
SELECT * FROM t3;

connection master;
DELETE FROM t3 WHERE C1 = C2;
SELECT * FROM t3;
sync_slave_with_master;
SELECT * FROM t3;

connection master;
SELECT * FROM t3;
UPDATE t3 SET C2 = 'I' WHERE C1 = 'A' AND C2 = 'C';
SELECT * FROM t3;
sync_slave_with_master;
SELECT * FROM t3;



--- 1.88/sql/ha_innodb.h	2005-03-15 22:59:43 +01:00
+++ 1.89/sql/ha_innodb.h	2005-04-08 11:54:29 +02:00
@@ -90,6 +90,7 @@
 			  HA_CAN_SQL_HANDLER |
 			  HA_NOT_EXACT_COUNT |
 			  HA_PRIMARY_KEY_IN_READ_INDEX |
+			  HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS |
 			  HA_TABLE_SCAN_ON_INDEX),
 	  last_dup_key((uint) -1),
 	  start_of_scan(0),
Thread
bk commit into 5.1 tree (mats:1.1801)Mats Kindahl8 Apr