Bug #11833 | Cursor doesn't use snapshot of data after mysql_stmt_execute | ||
---|---|---|---|
Submitted: | 9 Jul 2005 11:29 | Modified: | 12 Jul 2005 17:13 |
Reporter: | Georg Richter | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server | Severity: | S1 (Critical) |
Version: | 5.0.10-beta (cs: 1.901) | OS: | Linux (Linux) |
Assigned to: | Konstantin Osipov | CPU Architecture: | Any |
[9 Jul 2005 11:29]
Georg Richter
[9 Jul 2005 14:05]
MySQL Verification Team
miguel@hegel:/share/dbs/5.0/bin$ ./bug11833 4 Rows fetched from cursor
[11 Jul 2005 11:20]
Heikki Tuuri
Georg, is there some compelling reason why it SHOULD use the snapshot from the first ...execute()? What happens is that InnoDB assigns the snapshot at the first fetch. On line 3457 of row0sel.c: if (!prebuilt->sql_stat_start) { /* No need to set an intention lock or assign a read view */ if (trx->read_view == NULL && prebuilt->select_lock_type == LOCK_NONE) { fputs( "InnoDB: Error: MySQL is trying to perform a consistent read\n" "InnoDB: but the read view is not assigned!\n", stderr); trx_print(stderr, trx); fputc('\n', stderr); ut_a(0); } } else if (prebuilt->select_lock_type == LOCK_NONE) { /* This is a consistent read */ /* Assign a read view for the query */ trx_assign_read_view(trx); prebuilt->sql_stat_start = FALSE; } else { We could, of course, call trx_assign_read_view() earlier. The problem for InnoDB is to know if MySQL is going to call row_search_for_mysql() with prebuilt->select_lock_type == LOCK_NONE. Hmm... SELECT, and various subqueries when innodb_locks_unsafe_for_binlog is set, will use a consistent read. Regards, Heikki
[12 Jul 2005 17:13]
Georg Richter
Heikki, Konstantin, According to PeterG there is no definition at which point in time a snapshot has to be used. SQL Server for example also does it during fetch, not during execute. Changed status to "Not a bug"
[17 Jan 2014 10:58]
Marko Mäkelä
For what it is worth, there is START TRANSACTION WITH CONSISTENT SNAPSHOT that will create the read view at the time the transaction is started, not at the time of the first fetch of a record.