Below is the list of changes that have just been committed into a local
5.0 repository of kostja. When kostja 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.1960 05/07/20 20:02:36 konstantin@stripped +15 -0
Implement MySQL framework to support consistent read views in
cursors. This should fix Bug#11813 when InnoDB part is in
(tested with a draft patch).
The idea of the patch is that if a storage engine supports
consistent read views, we open one when open a cursor,
set is as the active view when fetch from the cursor, and close
together with cursor close.
tests/mysql_client_test.c
1.146 05/07/20 20:02:26 konstantin@stripped +2 -0
Disable an assert that will be no longer valid when consistent
read views in InnoDB are used.
sql/sql_select.h
1.94 05/07/20 20:02:26 konstantin@stripped +6 -0
- add Cursor::ht_info to remember read views used in a cursor.
sql/sql_select.cc
1.343 05/07/20 20:02:26 konstantin@stripped +23 -7
- create a consistent read view when we open a cursor,
set it for a fetch, and free when we closing the cursor.
sql/handler.h
1.146 05/07/20 20:02:26 konstantin@stripped +7 -2
- extend handlerton with cursors methods
sql/ha_ndbcluster.cc
1.195 05/07/20 20:02:26 konstantin@stripped +3 -0
- extend handlerton with cursors methods
sql/ha_myisammrg.cc
1.71 05/07/20 20:02:26 konstantin@stripped +13 -10
- extend handlerton with cursors methods; fix coding style
sql/ha_myisam.cc
1.156 05/07/20 20:02:25 konstantin@stripped +13 -10
- extend handlerton with cursors methods; fix coding style
sql/ha_innodb.cc
1.228 05/07/20 20:02:25 konstantin@stripped +3 -6
- extend handlerton with cursors methods
sql/ha_heap.cc
1.71 05/07/20 20:02:25 konstantin@stripped +13 -10
- extend handlerton with cursors methods; fix coding style
sql/ha_federated.cc
1.36 05/07/20 20:02:25 konstantin@stripped +13 -10
- extend handlerton with cursors methods; fix coding style
sql/ha_blackhole.cc
1.14 05/07/20 20:02:25 konstantin@stripped +13 -10
- extend handlerton with cursors methods; fix coding style
sql/ha_berkeley.cc
1.153 05/07/20 20:02:25 konstantin@stripped +3 -0
- extend handlerton with cursors methods
sql/examples/ha_tina.cc
1.12 05/07/20 20:02:25 konstantin@stripped +13 -10
- extend handlerton with cursors methods; fix coding style
sql/examples/ha_example.cc
1.15 05/07/20 20:02:25 konstantin@stripped +13 -10
- extend handlerton with cursors methods; fix coding style
sql/examples/ha_archive.cc
1.47 05/07/20 20:02:25 konstantin@stripped +13 -10
- extend handlerton with cursors methods; fix coding style
# 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: konstantin
# Host: oak.local
# Root: /home/kostja/mysql/mysql-5.0-11813
--- 1.152/sql/ha_berkeley.cc 2005-07-19 22:21:01 +04:00
+++ 1.153/sql/ha_berkeley.cc 2005-07-20 20:02:25 +04:00
@@ -121,6 +121,9 @@
NULL, /* recover */
NULL, /* commit_by_xid */
NULL, /* rollback_by_xid */
+ NULL, /* create_cursor_read_view */
+ NULL, /* set_cursor_read_view */
+ NULL, /* close_cursor_read_view */
HTON_CLOSE_CURSORS_AT_COMMIT
};
--- 1.70/sql/ha_heap.cc 2005-07-19 22:21:01 +04:00
+++ 1.71/sql/ha_heap.cc 2005-07-20 20:02:25 +04:00
@@ -27,16 +27,19 @@
"MEMORY",
0, /* slot */
0, /* savepoint size. */
- 0, /* close_connection */
- 0, /* savepoint */
- 0, /* rollback to savepoint */
- 0, /* release savepoint */
- 0, /* commit */
- 0, /* rollback */
- 0, /* prepare */
- 0, /* recover */
- 0, /* commit_by_xid */
- 0, /* rollback_by_xid */
+ NULL, /* close_connection */
+ NULL, /* savepoint */
+ NULL, /* rollback to savepoint */
+ NULL, /* release savepoint */
+ NULL, /* commit */
+ NULL, /* rollback */
+ NULL, /* prepare */
+ NULL, /* recover */
+ NULL, /* commit_by_xid */
+ NULL, /* rollback_by_xid */
+ NULL, /* create_cursor_read_view */
+ NULL, /* set_cursor_read_view */
+ NULL, /* close_cursor_read_view */
HTON_NO_FLAGS
};
--- 1.155/sql/ha_myisam.cc 2005-07-19 22:21:01 +04:00
+++ 1.156/sql/ha_myisam.cc 2005-07-20 20:02:25 +04:00
@@ -50,16 +50,19 @@
"MyISAM",
0, /* slot */
0, /* savepoint size. */
- 0, /* close_connection */
- 0, /* savepoint */
- 0, /* rollback to savepoint */
- 0, /* release savepoint */
- 0, /* commit */
- 0, /* rollback */
- 0, /* prepare */
- 0, /* recover */
- 0, /* commit_by_xid */
- 0, /* rollback_by_xid */
+ NULL, /* close_connection */
+ NULL, /* savepoint */
+ NULL, /* rollback to savepoint */
+ NULL, /* release savepoint */
+ NULL, /* commit */
+ NULL, /* rollback */
+ NULL, /* prepare */
+ NULL, /* recover */
+ NULL, /* commit_by_xid */
+ NULL, /* rollback_by_xid */
+ NULL, /* create_cursor_read_view */
+ NULL, /* set_cursor_read_view */
+ NULL, /* close_cursor_read_view */
/*
MyISAM doesn't support transactions and doesn't have
transaction-dependent context: cursors can survive a commit.
--- 1.70/sql/ha_myisammrg.cc 2005-07-19 22:21:01 +04:00
+++ 1.71/sql/ha_myisammrg.cc 2005-07-20 20:02:26 +04:00
@@ -38,16 +38,19 @@
"MRG_MyISAM",
0, /* slot */
0, /* savepoint size. */
- 0, /* close_connection */
- 0, /* savepoint */
- 0, /* rollback to savepoint */
- 0, /* release savepoint */
- 0, /* commit */
- 0, /* rollback */
- 0, /* prepare */
- 0, /* recover */
- 0, /* commit_by_xid */
- 0, /* rollback_by_xid */
+ NULL, /* close_connection */
+ NULL, /* savepoint */
+ NULL, /* rollback to savepoint */
+ NULL, /* release savepoint */
+ NULL, /* commit */
+ NULL, /* rollback */
+ NULL, /* prepare */
+ NULL, /* recover */
+ NULL, /* commit_by_xid */
+ NULL, /* rollback_by_xid */
+ NULL, /* create_cursor_read_view */
+ NULL, /* set_cursor_read_view */
+ NULL, /* close_cursor_read_view */
HTON_NO_FLAGS
};
--- 1.145/sql/handler.h 2005-07-19 22:21:02 +04:00
+++ 1.146/sql/handler.h 2005-07-20 20:02:26 +04:00
@@ -106,9 +106,11 @@
/*
Note: the following includes binlog and closing 0.
- so: innodb+bdb+ndb+binlog+0
+ so: innodb + bdb + ndb + binlog + myisam + myisammrg + archive +
+ example + csv + heap + blackhole + federated + 0
+ (yes, the sum is deliberately inaccurate)
*/
-#define MAX_HA 6
+#define MAX_HA 14
/*
Bits in index_ddl_flags(KEY *wanted_index)
@@ -349,6 +351,9 @@
int (*recover)(XID *xid_list, uint len);
int (*commit_by_xid)(XID *xid);
int (*rollback_by_xid)(XID *xid);
+ void *(*create_cursor_read_view)();
+ void (*set_cursor_read_view)(void *);
+ void (*close_cursor_read_view)(void *);
uint32 flags; /* global handler flags */
} handlerton;
--- 1.342/sql/sql_select.cc 2005-07-20 03:33:19 +04:00
+++ 1.343/sql/sql_select.cc 2005-07-20 20:02:26 +04:00
@@ -1712,12 +1712,14 @@
/* We will overwrite it at open anyway. */
init_sql_alloc(&main_mem_root, ALLOC_ROOT_MIN_BLOCK_SIZE, 0);
thr_lock_owner_init(&lock_id, &thd->lock_info);
+ bzero((void*) ht_info, sizeof(ht_info));
}
void
Cursor::init_from_thd(THD *thd)
{
+ Engine_info *info;
/*
We need to save and reset thd->mem_root, otherwise it'll be freed
later in mysql_parse.
@@ -1749,15 +1751,16 @@
thd->lock_info.n_cursors++;
close_at_commit= FALSE; /* reset in case we're reusing the cursor */
- for (TABLE *table= open_tables; table; table= table->next)
+ info= &ht_info[0];
+ for (handlerton **pht= thd->transaction.stmt.ht; *pht; pht++)
{
- const handlerton *ht= table->file->ht;
- if (ht)
- close_at_commit|= (ht->flags & HTON_CLOSE_CURSORS_AT_COMMIT);
- else
+ const handlerton *ht= *pht;
+ close_at_commit|= (ht->flags & HTON_CLOSE_CURSORS_AT_COMMIT);
+ if (ht->create_cursor_read_view)
{
- close_at_commit= TRUE; /* handler status is unknown */
- break;
+ info->ht= ht;
+ info->read_view= (ht->create_cursor_read_view)();
+ ++info;
}
}
/*
@@ -1853,6 +1856,9 @@
/* save references to memory, allocated during fetch */
thd->set_n_backup_item_arena(this, &backup_arena);
+ for (Engine_info *info= ht_info; info->read_view ; info++)
+ (info->ht->set_cursor_read_view)(info->read_view);
+
join->fetch_limit+= num_rows;
error= sub_select(join, join_tab, 0);
@@ -1869,6 +1875,9 @@
/* Grab free_list here to correctly free it in close */
thd->restore_backup_item_arena(this, &backup_arena);
+ for (Engine_info *info= ht_info; info->read_view; info++)
+ (info->ht->set_cursor_read_view)(0);
+
if (error == NESTED_LOOP_CURSOR_LIMIT)
{
/* Fetch limit worked, possibly more rows are there */
@@ -1908,6 +1917,13 @@
(void) unit->cleanup();
else
(void) join->select_lex->cleanup();
+
+ for (Engine_info *info= ht_info; info->read_view; info++)
+ {
+ (info->ht->close_cursor_read_view)(info->read_view);
+ info->read_view= 0;
+ info->ht= 0;
+ }
if (is_active)
close_thread_tables(thd);
--- 1.93/sql/sql_select.h 2005-07-19 22:21:02 +04:00
+++ 1.94/sql/sql_select.h 2005-07-20 20:02:26 +04:00
@@ -389,6 +389,12 @@
TABLE *derived_tables;
/* List of items created during execution */
query_id_t query_id;
+ struct Engine_info
+ {
+ const handlerton *ht;
+ void *read_view;
+ };
+ Engine_info ht_info[MAX_HA];
public:
Item_change_list change_list;
select_send result;
--- 1.46/sql/examples/ha_archive.cc 2005-07-19 22:21:01 +04:00
+++ 1.47/sql/examples/ha_archive.cc 2005-07-20 20:02:25 +04:00
@@ -140,16 +140,19 @@
"archive",
0, /* slot */
0, /* savepoint size. */
- 0, /* close_connection */
- 0, /* savepoint */
- 0, /* rollback to savepoint */
- 0, /* releas savepoint */
- 0, /* commit */
- 0, /* rollback */
- 0, /* prepare */
- 0, /* recover */
- 0, /* commit_by_xid */
- 0, /* rollback_by_xid */
+ NULL, /* close_connection */
+ NULL, /* savepoint */
+ NULL, /* rollback to savepoint */
+ NULL, /* releas savepoint */
+ NULL, /* commit */
+ NULL, /* rollback */
+ NULL, /* prepare */
+ NULL, /* recover */
+ NULL, /* commit_by_xid */
+ NULL, /* rollback_by_xid */
+ NULL, /* create_cursor_read_view */
+ NULL, /* set_cursor_read_view */
+ NULL, /* close_cursor_read_view */
HTON_NO_FLAGS
};
--- 1.11/sql/examples/ha_tina.cc 2005-07-19 22:21:01 +04:00
+++ 1.12/sql/examples/ha_tina.cc 2005-07-20 20:02:25 +04:00
@@ -58,16 +58,19 @@
"CSV",
0, /* slot */
0, /* savepoint size. */
- 0, /* close_connection */
- 0, /* savepoint */
- 0, /* rollback to savepoint */
- 0, /* release savepoint */
- 0, /* commit */
- 0, /* rollback */
- 0, /* prepare */
- 0, /* recover */
- 0, /* commit_by_xid */
- 0, /* rollback_by_xid */
+ NULL, /* close_connection */
+ NULL, /* savepoint */
+ NULL, /* rollback to savepoint */
+ NULL, /* release savepoint */
+ NULL, /* commit */
+ NULL, /* rollback */
+ NULL, /* prepare */
+ NULL, /* recover */
+ NULL, /* commit_by_xid */
+ NULL, /* rollback_by_xid */
+ NULL, /* create_cursor_read_view */
+ NULL, /* set_cursor_read_view */
+ NULL, /* close_cursor_read_view */
HTON_NO_FLAGS
};
--- 1.14/sql/examples/ha_example.cc 2005-07-19 22:21:01 +04:00
+++ 1.15/sql/examples/ha_example.cc 2005-07-20 20:02:25 +04:00
@@ -77,16 +77,19 @@
"CSV",
0, /* slot */
0, /* savepoint size. */
- 0, /* close_connection */
- 0, /* savepoint */
- 0, /* rollback to savepoint */
- 0, /* release savepoint */
- 0, /* commit */
- 0, /* rollback */
- 0, /* prepare */
- 0, /* recover */
- 0, /* commit_by_xid */
- 0, /* rollback_by_xid */
+ NULL, /* close_connection */
+ NULL, /* savepoint */
+ NULL, /* rollback to savepoint */
+ NULL, /* release savepoint */
+ NULL, /* commit */
+ NULL, /* rollback */
+ NULL, /* prepare */
+ NULL, /* recover */
+ NULL, /* commit_by_xid */
+ NULL, /* rollback_by_xid */
+ NULL, /* create_cursor_read_view */
+ NULL, /* set_cursor_read_view */
+ NULL, /* close_cursor_read_view */
HTON_NO_FLAGS
};
--- 1.13/sql/ha_blackhole.cc 2005-07-20 01:17:11 +04:00
+++ 1.14/sql/ha_blackhole.cc 2005-07-20 20:02:25 +04:00
@@ -30,16 +30,19 @@
"BLACKHOLE",
0, /* slot */
0, /* savepoint size. */
- 0, /* close_connection */
- 0, /* savepoint */
- 0, /* rollback to savepoint */
- 0, /* release savepoint */
- 0, /* commit */
- 0, /* rollback */
- 0, /* prepare */
- 0, /* recover */
- 0, /* commit_by_xid */
- 0, /* rollback_by_xid */
+ NULL, /* close_connection */
+ NULL, /* savepoint */
+ NULL, /* rollback to savepoint */
+ NULL, /* release savepoint */
+ NULL, /* commit */
+ NULL, /* rollback */
+ NULL, /* prepare */
+ NULL, /* recover */
+ NULL, /* commit_by_xid */
+ NULL, /* rollback_by_xid */
+ NULL, /* create_cursor_read_view */
+ NULL, /* set_cursor_read_view */
+ NULL, /* close_cursor_read_view */
HTON_NO_FLAGS
};
--- 1.194/sql/ha_ndbcluster.cc 2005-07-20 00:01:25 +04:00
+++ 1.195/sql/ha_ndbcluster.cc 2005-07-20 20:02:26 +04:00
@@ -63,6 +63,9 @@
NULL, /* recover */
NULL, /* commit_by_xid */
NULL, /* rollback_by_xid */
+ NULL, /* create_cursor_read_view */
+ NULL, /* set_cursor_read_view */
+ NULL, /* close_cursor_read_view */
HTON_NO_FLAGS
};
--- 1.227/sql/ha_innodb.cc 2005-07-19 22:21:01 +04:00
+++ 1.228/sql/ha_innodb.cc 2005-07-20 20:02:25 +04:00
@@ -216,12 +216,9 @@
innobase_xa_recover, /* recover */
innobase_commit_by_xid, /* commit_by_xid */
innobase_rollback_by_xid, /* rollback_by_xid */
- /*
- For now when one opens a cursor, MySQL does not create an own
- InnoDB consistent read view for it, and uses the view of the
- currently active transaction. Therefore, cursors can not
- survive COMMIT or ROLLBACK statements, which free this view.
- */
+ NULL,
+ NULL,
+ NULL,
HTON_CLOSE_CURSORS_AT_COMMIT
};
--- 1.35/sql/ha_federated.cc 2005-07-19 22:21:01 +04:00
+++ 1.36/sql/ha_federated.cc 2005-07-20 20:02:25 +04:00
@@ -685,16 +685,19 @@
"FEDERATED",
0, /* slot */
0, /* savepoint size. */
- 0, /* close_connection */
- 0, /* savepoint */
- 0, /* rollback to savepoint */
- 0, /* release savepoint */
- 0, /* commit */
- 0, /* rollback */
- 0, /* prepare */
- 0, /* recover */
- 0, /* commit_by_xid */
- 0, /* rollback_by_xid */
+ NULL, /* close_connection */
+ NULL, /* savepoint */
+ NULL, /* rollback to savepoint */
+ NULL, /* release savepoint */
+ NULL, /* commit */
+ NULL, /* rollback */
+ NULL, /* prepare */
+ NULL, /* recover */
+ NULL, /* commit_by_xid */
+ NULL, /* rollback_by_xid */
+ NULL, /* create_cursor_read_view */
+ NULL, /* set_cursor_read_view */
+ NULL, /* close_cursor_read_view */
HTON_NO_FLAGS
};
--- 1.145/tests/mysql_client_test.c 2005-07-20 03:33:19 +04:00
+++ 1.146/tests/mysql_client_test.c 2005-07-20 20:02:26 +04:00
@@ -13874,10 +13874,12 @@
printf("Fetched row %s\n", id_buf);
rc= mysql_rollback(mysql); /* should close the cursor */
myquery(rc);
+#if 0
rc= mysql_stmt_fetch(stmt);
DIE_UNLESS(rc);
if (!opt_silent)
printf("Got error (as expected): %s\n", mysql_error(mysql));
+#endif
}
mysql_stmt_close(stmt);
| Thread |
|---|
| • bk commit into 5.0 tree (konstantin:1.1960) BUG#11813 | Konstantin Osipov | 20 Jul |