mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
76de7d788c
innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Fixes: - Bug #21409: Incorrect result returned when in READ-COMMITTED with query_cache ON At low transaction isolation levels we let each consistent read set its own snapshot. - Bug #23666: strange Innodb_row_lock_time_% values in show status; also millisecs wrong On Windows ut_usectime returns secs and usecs relative to the UNIX epoch (which is Jan, 1 1970). - Bug #25494: LATEST DEADLOCK INFORMATION is not always cleared lock_deadlock_recursive(): When the search depth or length is exceeded, rewind lock_latest_err_file and display the two transactions at the point of aborting the search. - Bug #25927: Foreign key with ON DELETE SET NULL on NOT NULL can crash server Prevent ALTER TABLE ... MODIFY ... NOT NULL on columns for which there is a foreign key constraint ON ... SET NULL. - Bug #26835: Repeatable corruption of utf8-enabled tables inside InnoDB The bug could be reproduced as follows: Define a table so that the first column of the clustered index is a VARCHAR or a UTF-8 CHAR in a collation where sequences of bytes of differing length are considered equivalent. Insert and delete a record. Before the delete-marked record is purged, insert another record whose first column is of different length but equivalent to the first record. Under certain conditions, the insertion can be incorrectly performed as update-in-place. Likewise, an operation that could be done as update-in-place can unnecessarily be performed as delete and insert, but that would not cause corruption but merely degraded performance. mysql-test/r/innodb.result: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1284: Merge changes from MySQL AB: ChangeSet 2007/01/24 14:49:36+04:00 holyfoot@mysql.com bug 22682 Test fails --without-geometry geometry dependent parts moved to proper .test files mysql-test/r/innodb.result 2007/01/24 14:49:34+04:00 holyfoot@mysql.com +0 -2 result fixed mysql-test/r/innodb_gis.result 2007/01/24 14:49:34+04:00 holyfoot@mysql.com +2 -0 result fixed mysql-test/t/innodb.test 2007/01/24 14:49:34+04:00 holyfoot@mysql.com +0 -6 HAVE_GEOMETRY dependent part moved to innodb_gis.test mysql-test/t/innodb_gis.test 2007/01/24 14:49:35+04:00 holyfoot@mysql.com +6 -0 HAVE_GEOMETRY dependent part moved here from innodb.test Revision r1186: dict_load_foreign(): Use a local variable instead of the 10-bit field foreign->n_fields in order to preserve ON UPDATE CASCADE and ON DELETE CASCADE flags. For some reason, gcc does not warn about shifting a 10-bit field to right by 24 bits. (Bug 24741) This bug was introduced while reducing the memory footprint of the InnoDB data dictionary (Bug 20877). innodb.test, innodb.result: Add a test case. Revision r1318: Add a test case for r1316 (Bug #25927). Revision r1340: innodb.test, innodb.result: Add test case for Bug #26835. The bug could be reproduced as follows: Define a table so that the first column of the clustered index is a VARCHAR or a UTF-8 CHAR in a collation where sequences of bytes of differing length are considered equivalent. Insert and delete a record. Before the delete-marked record is purged, insert another record whose first column is of different length but equivalent to the first record. Under certain conditions, the insertion can be incorrectly performed as update-in-place. Likewise, an operation that could be done as update-in-place can unnecessarily be performed as delete and insert, but that would not cause corruption but merely degraded performance. mysql-test/t/innodb.test: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1284: Merge changes from MySQL AB: ChangeSet 2007/01/24 14:49:36+04:00 holyfoot@mysql.com bug 22682 Test fails --without-geometry geometry dependent parts moved to proper .test files mysql-test/r/innodb.result 2007/01/24 14:49:34+04:00 holyfoot@mysql.com +0 -2 result fixed mysql-test/r/innodb_gis.result 2007/01/24 14:49:34+04:00 holyfoot@mysql.com +2 -0 result fixed mysql-test/t/innodb.test 2007/01/24 14:49:34+04:00 holyfoot@mysql.com +0 -6 HAVE_GEOMETRY dependent part moved to innodb_gis.test mysql-test/t/innodb_gis.test 2007/01/24 14:49:35+04:00 holyfoot@mysql.com +6 -0 HAVE_GEOMETRY dependent part moved here from innodb.test Revision r1283: Merge changes from MySQL AB: ChangeSet 2007/01/22 18:42:52+02:00 monty@mysql.com Give warnings for unused objects Changed error message to be compatible with old error file Added new error message for new DUP_ENTRY syntax mysql-test/t/innodb.test 2007/01/22 18:42:49+02:00 monty@mysql.com +14 -14 Changed to use new error message Revision r1186: dict_load_foreign(): Use a local variable instead of the 10-bit field foreign->n_fields in order to preserve ON UPDATE CASCADE and ON DELETE CASCADE flags. For some reason, gcc does not warn about shifting a 10-bit field to right by 24 bits. (Bug 24741) This bug was introduced while reducing the memory footprint of the InnoDB data dictionary (Bug 20877). innodb.test, innodb.result: Add a test case. Revision r1318: Add a test case for r1316 (Bug #25927). Revision r1329: Merge changes from MySQL AB to mysql-test directives. The results are not affected. Revision r1340: innodb.test, innodb.result: Add test case for Bug #26835. The bug could be reproduced as follows: Define a table so that the first column of the clustered index is a VARCHAR or a UTF-8 CHAR in a collation where sequences of bytes of differing length are considered equivalent. Insert and delete a record. Before the delete-marked record is purged, insert another record whose first column is of different length but equivalent to the first record. Under certain conditions, the insertion can be incorrectly performed as update-in-place. Likewise, an operation that could be done as update-in-place can unnecessarily be performed as delete and insert, but that would not cause corruption but merely degraded performance. storage/innobase/buf/buf0buf.c: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. storage/innobase/buf/buf0flu.c: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. storage/innobase/buf/buf0lru.c: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. storage/innobase/dict/dict0boot.c: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. storage/innobase/dict/dict0crea.c: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. Revision r1324: Merge changes from MySQL AB: ChangeSet@1.2452, 2007-02-23 13:13:55+02:00, monty@mysql.com +177 -0 Fixed compiler warnings ... Fixed compiler warnings detected on windows64 storage/innobase/dict/dict0dict.c: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. Revision r1316: Prevent ALTER TABLE ... MODIFY ... NOT NULL on columns for which there is a foreign key constraint ON ... SET NULL. (Bug #25927) dict_foreign_find_index(): Add paramettter check_null. dict_foreign_add_to_cache(): Do not allow ON DELETE SET NULL or ON UPDATE SET NULL if any of the referencing columns are declared NOT NULL. Revision r1324: Merge changes from MySQL AB: ChangeSet@1.2452, 2007-02-23 13:13:55+02:00, monty@mysql.com +177 -0 Fixed compiler warnings ... Fixed compiler warnings detected on windows64 storage/innobase/dict/dict0load.c: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1186: dict_load_foreign(): Use a local variable instead of the 10-bit field foreign->n_fields in order to preserve ON UPDATE CASCADE and ON DELETE CASCADE flags. For some reason, gcc does not warn about shifting a 10-bit field to right by 24 bits. (Bug 24741) This bug was introduced while reducing the memory footprint of the InnoDB data dictionary (Bug 20877). innodb.test, innodb.result: Add a test case. Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. Revision r1324: Merge changes from MySQL AB: ChangeSet@1.2452, 2007-02-23 13:13:55+02:00, monty@mysql.com +177 -0 Fixed compiler warnings ... Fixed compiler warnings detected on windows64 storage/innobase/fil/fil0fil.c: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. storage/innobase/fsp/fsp0fsp.c: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. storage/innobase/ha/ha0ha.c: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. storage/innobase/handler/ha_innodb.cc: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1204: Change this in ha_innobase: void* innobase_prebuilt; to this: row_prebuilt_t* prebuilt; by introducing the typedef in ha_innodb.h, and remove all the now needless local variables and casts in ha_innodb.cc. Revision r1298: ha_innodb.cc: Remove all references to thd->ha_data[hton->slot]. thd_to_trx(thd, hton): Accessor for getting the InnoDB trx object of a MySQL thread object and an InnoDB handlerton. Revision r1292: Remove the declarations of some global functions in ha_innodb.h and declare them static in ha_innodb.cc. These functions are invoked via function pointers in handlerton. Revision r1300: ha_innodb.cc: Replace thd->tablespace_op with thd_tablespace_op(thd). Plugins must treat class THD as an opaque type. Revision r1198: Merge a change from MySQL AB: ChangeSet@1.2372, 2006-12-31 02:29:11+01:00, kent@mysql.com +79 -0 Many files: Removed "MySQL Finland AB & TCX DataKonsult AB" from copyright header Adjusted year(s) in copyright header Added GPL copyright text Revision r1271: Merge changes from MySQL AB: Rename some FIELD_TYPE_ constants to MYSQL_TYPE_. Change the scope of a type cast of two dividends. Revision r1299: ha_innodb.cc: Replace thd->in_lock_tables with thd_in_lock_tables(thd). Plugins must treat class THD as an opaque type. Revision r1201: Apply patch from MySQL: ChangeSet@1.2353, 2006-12-19 16:57:51-07:00, tsmith@siva.hindu.god +13 -0 Added innodb_rollback_on_timeout option to restore the 4.1 InnoDB timeout behavior (Bug 24200) Revision r1322: ha_innodb.cc: Remove the unused innobase_repl_ variables. Revision r1324: Merge changes from MySQL AB: ChangeSet@1.2452, 2007-02-23 13:13:55+02:00, monty@mysql.com +177 -0 Fixed compiler warnings ... Fixed compiler warnings detected on windows64 Revision r1334: Fix for Bug# 21409. At low transaction isolation levels we let each consistent read set its own snapshot storage/innobase/handler/ha_innodb.h: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1204: Change this in ha_innobase: void* innobase_prebuilt; to this: row_prebuilt_t* prebuilt; by introducing the typedef in ha_innodb.h, and remove all the now needless local variables and casts in ha_innodb.cc. Revision r1292: Remove the declarations of some global functions in ha_innodb.h and declare them static in ha_innodb.cc. These functions are invoked via function pointers in handlerton. Revision r1198: Merge a change from MySQL AB: ChangeSet@1.2372, 2006-12-31 02:29:11+01:00, kent@mysql.com +79 -0 Many files: Removed "MySQL Finland AB & TCX DataKonsult AB" from copyright header Adjusted year(s) in copyright header Added GPL copyright text Revision r1201: Apply patch from MySQL: ChangeSet@1.2353, 2006-12-19 16:57:51-07:00, tsmith@siva.hindu.god +13 -0 Added innodb_rollback_on_timeout option to restore the 4.1 InnoDB timeout behavior (Bug 24200) storage/innobase/ibuf/ibuf0ibuf.c: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. storage/innobase/include/buf0buf.ic: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. storage/innobase/include/buf0flu.ic: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. storage/innobase/include/dict0dict.ic: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. storage/innobase/include/ha0ha.ic: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. storage/innobase/include/lock0lock.ic: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. storage/innobase/include/log0log.ic: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. storage/innobase/include/mem0mem.h: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1241: Remove the unused function mem_strdupq(). storage/innobase/include/mem0mem.ic: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1241: Remove the unused function mem_strdupq(). storage/innobase/include/rem0rec.ic: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1338: rec_offs_nth_size(): Treat n==0 as a special case. (Bug #26835) storage/innobase/include/sync0rw.ic: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. storage/innobase/include/sync0sync.h: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. Revision r1247: Rename mutex_enter_nowait to mutex_enter_nowait_func and add macro mutex_enter_nowait that supplies the default __FILE__ and __LINE__ arguments. Adjust callers. storage/innobase/include/sync0sync.ic: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1294: Fixed inline asm code, it didn't work with GCC > ver 3.x. Revision r1244: Add ut_ad() debug assertions. UT_LIST_ADD_FIRST(), UT_LIST_ADD_LAST(), UT_LIST_INSERT_AFTER(): Assert against some trivial cases of cyclic lists. mutex_enter_func(): Assert that the current thread is not holding the mutex. Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. storage/innobase/include/trx0sys.ic: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. storage/innobase/include/univ.i: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1285: Merge a change from MySQL AB: ChangeSet 2006/10/26 15:41:47-04:00 iggy@amd64. Post Merge Cleanup storage/innobase/include/univ.i 2006/10/26 15:38:50-04:00 iggy@amd64. +9 -0 Post Merge Cleanup storage/innobase/include/ut0lst.h: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1244: Add ut_ad() debug assertions. UT_LIST_ADD_FIRST(), UT_LIST_ADD_LAST(), UT_LIST_INSERT_AFTER(): Assert against some trivial cases of cyclic lists. mutex_enter_func(): Assert that the current thread is not holding the mutex. storage/innobase/lock/lock0lock.c: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. Revision r1330: lock_deadlock_recursive(): When the search depth or length is exceeded, rewind lock_latest_err_file and display the two transactions at the point of aborting the search. (Bug #25494) Revision r1332: lock_deadlock_recursive(): When aborting the search, display a note regardless of start->undo_no. Otherwise, aborted searches may show up as genuine deadlocks. This mistake was made in r1330. storage/innobase/log/log0log.c: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. Revision r1247: Rename mutex_enter_nowait to mutex_enter_nowait_func and add macro mutex_enter_nowait that supplies the default __FILE__ and __LINE__ arguments. Adjust callers. storage/innobase/log/log0recv.c: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. storage/innobase/mem/mem0pool.c: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. storage/innobase/pars/pars0pars.c: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. storage/innobase/que/que0que.c: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. storage/innobase/read/read0read.c: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. storage/innobase/row/row0mysql.c: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. Revision r1201: Apply patch from MySQL: ChangeSet@1.2353, 2006-12-19 16:57:51-07:00, tsmith@siva.hindu.god +13 -0 Added innodb_rollback_on_timeout option to restore the 4.1 InnoDB timeout behavior (Bug 24200) Revision r1324: Merge changes from MySQL AB: ChangeSet@1.2452, 2007-02-23 13:13:55+02:00, monty@mysql.com +177 -0 Fixed compiler warnings ... Fixed compiler warnings detected on windows64 storage/innobase/row/row0vers.c: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. storage/innobase/srv/srv0que.c: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. storage/innobase/srv/srv0srv.c: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1262: Fix for Bug# 23666. On Windows ut_usectime returns secs and usecs relative to the UNIX epoch (which is Jan, 1 1970). Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. storage/innobase/sync/sync0rw.c: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. Revision r1247: Rename mutex_enter_nowait to mutex_enter_nowait_func and add macro mutex_enter_nowait that supplies the default __FILE__ and __LINE__ arguments. Adjust callers. Revision r1324: Merge changes from MySQL AB: ChangeSet@1.2452, 2007-02-23 13:13:55+02:00, monty@mysql.com +177 -0 Fixed compiler warnings ... Fixed compiler warnings detected on windows64 storage/innobase/sync/sync0sync.c: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. Revision r1247: Rename mutex_enter_nowait to mutex_enter_nowait_func and add macro mutex_enter_nowait that supplies the default __FILE__ and __LINE__ arguments. Adjust callers. storage/innobase/thr/thr0loc.c: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. storage/innobase/trx/trx0purge.c: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. storage/innobase/trx/trx0roll.c: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. storage/innobase/trx/trx0rseg.c: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. storage/innobase/trx/trx0sys.c: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. storage/innobase/trx/trx0trx.c: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. Revision r1324: Merge changes from MySQL AB: ChangeSet@1.2452, 2007-02-23 13:13:55+02:00, monty@mysql.com +177 -0 Fixed compiler warnings ... Fixed compiler warnings detected on windows64 storage/innobase/trx/trx0undo.c: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. storage/innobase/usr/usr0sess.c: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1242: Merge r1239 from branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. storage/innobase/ut/ut0ut.c: Apply the following InnoDB snapshots: innodb-5.1-ss1318 innodb-5.1-ss1330 innodb-5.1-ss1332 innodb-5.1-ss1340 Revision r1262: Fix for Bug# 23666. On Windows ut_usectime returns secs and usecs relative to the UNIX epoch (which is Jan, 1 1970).
665 lines
19 KiB
C
665 lines
19 KiB
C
/******************************************************
|
|
Row versions
|
|
|
|
(c) 1997 Innobase Oy
|
|
|
|
Created 2/6/1997 Heikki Tuuri
|
|
*******************************************************/
|
|
|
|
#include "row0vers.h"
|
|
|
|
#ifdef UNIV_NONINL
|
|
#include "row0vers.ic"
|
|
#endif
|
|
|
|
#include "dict0dict.h"
|
|
#include "dict0boot.h"
|
|
#include "btr0btr.h"
|
|
#include "mach0data.h"
|
|
#include "trx0rseg.h"
|
|
#include "trx0trx.h"
|
|
#include "trx0roll.h"
|
|
#include "trx0undo.h"
|
|
#include "trx0purge.h"
|
|
#include "trx0rec.h"
|
|
#include "que0que.h"
|
|
#include "row0row.h"
|
|
#include "row0upd.h"
|
|
#include "rem0cmp.h"
|
|
#include "read0read.h"
|
|
#include "lock0lock.h"
|
|
|
|
/*********************************************************************
|
|
Finds out if an active transaction has inserted or modified a secondary
|
|
index record. NOTE: the kernel mutex is temporarily released in this
|
|
function! */
|
|
|
|
trx_t*
|
|
row_vers_impl_x_locked_off_kernel(
|
|
/*==============================*/
|
|
/* out: NULL if committed, else the active
|
|
transaction; NOTE that the kernel mutex is
|
|
temporarily released! */
|
|
rec_t* rec, /* in: record in a secondary index */
|
|
dict_index_t* index, /* in: the secondary index */
|
|
const ulint* offsets)/* in: rec_get_offsets(rec, index) */
|
|
{
|
|
dict_index_t* clust_index;
|
|
rec_t* clust_rec;
|
|
ulint* clust_offsets;
|
|
rec_t* version;
|
|
rec_t* prev_version;
|
|
dulint trx_id;
|
|
dulint prev_trx_id;
|
|
mem_heap_t* heap;
|
|
mem_heap_t* heap2;
|
|
dtuple_t* row;
|
|
dtuple_t* entry = NULL; /* assignment to eliminate compiler
|
|
warning */
|
|
trx_t* trx;
|
|
ulint vers_del;
|
|
ulint rec_del;
|
|
ulint err;
|
|
mtr_t mtr;
|
|
ulint comp;
|
|
|
|
ut_ad(mutex_own(&kernel_mutex));
|
|
#ifdef UNIV_SYNC_DEBUG
|
|
ut_ad(!rw_lock_own(&(purge_sys->latch), RW_LOCK_SHARED));
|
|
#endif /* UNIV_SYNC_DEBUG */
|
|
|
|
mutex_exit(&kernel_mutex);
|
|
|
|
mtr_start(&mtr);
|
|
|
|
/* Search for the clustered index record: this is a time-consuming
|
|
operation: therefore we release the kernel mutex; also, the release
|
|
is required by the latching order convention. The latch on the
|
|
clustered index locks the top of the stack of versions. We also
|
|
reserve purge_latch to lock the bottom of the version stack. */
|
|
|
|
clust_rec = row_get_clust_rec(BTR_SEARCH_LEAF, rec, index,
|
|
&clust_index, &mtr);
|
|
if (!clust_rec) {
|
|
/* In a rare case it is possible that no clust rec is found
|
|
for a secondary index record: if in row0umod.c
|
|
row_undo_mod_remove_clust_low() we have already removed the
|
|
clust rec, while purge is still cleaning and removing
|
|
secondary index records associated with earlier versions of
|
|
the clustered index record. In that case there cannot be
|
|
any implicit lock on the secondary index record, because
|
|
an active transaction which has modified the secondary index
|
|
record has also modified the clustered index record. And in
|
|
a rollback we always undo the modifications to secondary index
|
|
records before the clustered index record. */
|
|
|
|
mutex_enter(&kernel_mutex);
|
|
mtr_commit(&mtr);
|
|
|
|
return(NULL);
|
|
}
|
|
|
|
heap = mem_heap_create(1024);
|
|
clust_offsets = rec_get_offsets(clust_rec, clust_index, NULL,
|
|
ULINT_UNDEFINED, &heap);
|
|
trx_id = row_get_rec_trx_id(clust_rec, clust_index, clust_offsets);
|
|
|
|
mtr_s_lock(&(purge_sys->latch), &mtr);
|
|
|
|
mutex_enter(&kernel_mutex);
|
|
|
|
trx = NULL;
|
|
if (!trx_is_active(trx_id)) {
|
|
/* The transaction that modified or inserted clust_rec is no
|
|
longer active: no implicit lock on rec */
|
|
goto exit_func;
|
|
}
|
|
|
|
if (!lock_check_trx_id_sanity(trx_id, clust_rec, clust_index,
|
|
clust_offsets, TRUE)) {
|
|
/* Corruption noticed: try to avoid a crash by returning */
|
|
goto exit_func;
|
|
}
|
|
|
|
comp = page_rec_is_comp(rec);
|
|
ut_ad(index->table == clust_index->table);
|
|
ut_ad(!!comp == dict_table_is_comp(index->table));
|
|
ut_ad(!comp == !page_rec_is_comp(clust_rec));
|
|
|
|
/* We look up if some earlier version, which was modified by the trx_id
|
|
transaction, of the clustered index record would require rec to be in
|
|
a different state (delete marked or unmarked, or have different field
|
|
values, or not existing). If there is such a version, then rec was
|
|
modified by the trx_id transaction, and it has an implicit x-lock on
|
|
rec. Note that if clust_rec itself would require rec to be in a
|
|
different state, then the trx_id transaction has not yet had time to
|
|
modify rec, and does not necessarily have an implicit x-lock on rec. */
|
|
|
|
rec_del = rec_get_deleted_flag(rec, comp);
|
|
trx = NULL;
|
|
|
|
version = clust_rec;
|
|
|
|
for (;;) {
|
|
mutex_exit(&kernel_mutex);
|
|
|
|
/* While we retrieve an earlier version of clust_rec, we
|
|
release the kernel mutex, because it may take time to access
|
|
the disk. After the release, we have to check if the trx_id
|
|
transaction is still active. We keep the semaphore in mtr on
|
|
the clust_rec page, so that no other transaction can update
|
|
it and get an implicit x-lock on rec. */
|
|
|
|
heap2 = heap;
|
|
heap = mem_heap_create(1024);
|
|
err = trx_undo_prev_version_build(clust_rec, &mtr, version,
|
|
clust_index, clust_offsets,
|
|
heap, &prev_version);
|
|
mem_heap_free(heap2); /* free version and clust_offsets */
|
|
|
|
if (prev_version) {
|
|
clust_offsets = rec_get_offsets(
|
|
prev_version, clust_index, NULL,
|
|
ULINT_UNDEFINED, &heap);
|
|
row = row_build(ROW_COPY_POINTERS, clust_index,
|
|
prev_version, clust_offsets, heap);
|
|
entry = row_build_index_entry(row, index, heap);
|
|
}
|
|
|
|
mutex_enter(&kernel_mutex);
|
|
|
|
if (!trx_is_active(trx_id)) {
|
|
/* Transaction no longer active: no implicit x-lock */
|
|
|
|
break;
|
|
}
|
|
|
|
/* If the transaction is still active, the previous version
|
|
of clust_rec must be accessible if not a fresh insert; we
|
|
may assert the following: */
|
|
|
|
ut_ad(err == DB_SUCCESS);
|
|
|
|
if (prev_version == NULL) {
|
|
/* It was a freshly inserted version: there is an
|
|
implicit x-lock on rec */
|
|
|
|
trx = trx_get_on_id(trx_id);
|
|
|
|
break;
|
|
}
|
|
|
|
/* If we get here, we know that the trx_id transaction is
|
|
still active and it has modified prev_version. Let us check
|
|
if prev_version would require rec to be in a different
|
|
state. */
|
|
|
|
vers_del = rec_get_deleted_flag(prev_version, comp);
|
|
|
|
/* We check if entry and rec are identified in the alphabetical
|
|
ordering */
|
|
if (0 == cmp_dtuple_rec(entry, rec, offsets)) {
|
|
/* The delete marks of rec and prev_version should be
|
|
equal for rec to be in the state required by
|
|
prev_version */
|
|
|
|
if (rec_del != vers_del) {
|
|
trx = trx_get_on_id(trx_id);
|
|
|
|
break;
|
|
}
|
|
|
|
/* It is possible that the row was updated so that the
|
|
secondary index record remained the same in
|
|
alphabetical ordering, but the field values changed
|
|
still. For example, 'abc' -> 'ABC'. Check also that. */
|
|
|
|
dtuple_set_types_binary(entry,
|
|
dtuple_get_n_fields(entry));
|
|
if (0 != cmp_dtuple_rec(entry, rec, offsets)) {
|
|
|
|
trx = trx_get_on_id(trx_id);
|
|
|
|
break;
|
|
}
|
|
} else if (!rec_del) {
|
|
/* The delete mark should be set in rec for it to be
|
|
in the state required by prev_version */
|
|
|
|
trx = trx_get_on_id(trx_id);
|
|
|
|
break;
|
|
}
|
|
|
|
prev_trx_id = row_get_rec_trx_id(prev_version, clust_index,
|
|
clust_offsets);
|
|
|
|
if (0 != ut_dulint_cmp(trx_id, prev_trx_id)) {
|
|
/* The versions modified by the trx_id transaction end
|
|
to prev_version: no implicit x-lock */
|
|
|
|
break;
|
|
}
|
|
|
|
version = prev_version;
|
|
}/* for (;;) */
|
|
|
|
exit_func:
|
|
mtr_commit(&mtr);
|
|
mem_heap_free(heap);
|
|
|
|
return(trx);
|
|
}
|
|
|
|
/*********************************************************************
|
|
Finds out if we must preserve a delete marked earlier version of a clustered
|
|
index record, because it is >= the purge view. */
|
|
|
|
ibool
|
|
row_vers_must_preserve_del_marked(
|
|
/*==============================*/
|
|
/* out: TRUE if earlier version should be preserved */
|
|
dulint trx_id, /* in: transaction id in the version */
|
|
mtr_t* mtr) /* in: mtr holding the latch on the clustered index
|
|
record; it will also hold the latch on purge_view */
|
|
{
|
|
#ifdef UNIV_SYNC_DEBUG
|
|
ut_ad(!rw_lock_own(&(purge_sys->latch), RW_LOCK_SHARED));
|
|
#endif /* UNIV_SYNC_DEBUG */
|
|
|
|
mtr_s_lock(&(purge_sys->latch), mtr);
|
|
|
|
if (trx_purge_update_undo_must_exist(trx_id)) {
|
|
|
|
/* A purge operation is not yet allowed to remove this
|
|
delete marked record */
|
|
|
|
return(TRUE);
|
|
}
|
|
|
|
return(FALSE);
|
|
}
|
|
|
|
/*********************************************************************
|
|
Finds out if a version of the record, where the version >= the current
|
|
purge view, should have ientry as its secondary index entry. We check
|
|
if there is any not delete marked version of the record where the trx
|
|
id >= purge view, and the secondary index entry and ientry are identified in
|
|
the alphabetical ordering; exactly in this case we return TRUE. */
|
|
|
|
ibool
|
|
row_vers_old_has_index_entry(
|
|
/*=========================*/
|
|
/* out: TRUE if earlier version should have */
|
|
ibool also_curr,/* in: TRUE if also rec is included in the
|
|
versions to search; otherwise only versions
|
|
prior to it are searched */
|
|
rec_t* rec, /* in: record in the clustered index; the
|
|
caller must have a latch on the page */
|
|
mtr_t* mtr, /* in: mtr holding the latch on rec; it will
|
|
also hold the latch on purge_view */
|
|
dict_index_t* index, /* in: the secondary index */
|
|
dtuple_t* ientry) /* in: the secondary index entry */
|
|
{
|
|
rec_t* version;
|
|
rec_t* prev_version;
|
|
dict_index_t* clust_index;
|
|
ulint* clust_offsets;
|
|
mem_heap_t* heap;
|
|
mem_heap_t* heap2;
|
|
dtuple_t* row;
|
|
dtuple_t* entry;
|
|
ulint err;
|
|
ulint comp;
|
|
|
|
ut_ad(mtr_memo_contains(mtr, buf_block_align(rec), MTR_MEMO_PAGE_X_FIX)
|
|
|| mtr_memo_contains(mtr, buf_block_align(rec),
|
|
MTR_MEMO_PAGE_S_FIX));
|
|
#ifdef UNIV_SYNC_DEBUG
|
|
ut_ad(!rw_lock_own(&(purge_sys->latch), RW_LOCK_SHARED));
|
|
#endif /* UNIV_SYNC_DEBUG */
|
|
mtr_s_lock(&(purge_sys->latch), mtr);
|
|
|
|
clust_index = dict_table_get_first_index(index->table);
|
|
|
|
comp = page_rec_is_comp(rec);
|
|
ut_ad(!dict_table_is_comp(index->table) == !comp);
|
|
heap = mem_heap_create(1024);
|
|
clust_offsets = rec_get_offsets(rec, clust_index, NULL,
|
|
ULINT_UNDEFINED, &heap);
|
|
|
|
if (also_curr && !rec_get_deleted_flag(rec, comp)) {
|
|
row = row_build(ROW_COPY_POINTERS, clust_index,
|
|
rec, clust_offsets, heap);
|
|
entry = row_build_index_entry(row, index, heap);
|
|
|
|
/* NOTE that we cannot do the comparison as binary
|
|
fields because the row is maybe being modified so that
|
|
the clustered index record has already been updated
|
|
to a different binary value in a char field, but the
|
|
collation identifies the old and new value anyway! */
|
|
|
|
if (dtuple_datas_are_ordering_equal(ientry, entry)) {
|
|
|
|
mem_heap_free(heap);
|
|
|
|
return(TRUE);
|
|
}
|
|
}
|
|
|
|
version = rec;
|
|
|
|
for (;;) {
|
|
heap2 = heap;
|
|
heap = mem_heap_create(1024);
|
|
err = trx_undo_prev_version_build(rec, mtr, version,
|
|
clust_index, clust_offsets,
|
|
heap, &prev_version);
|
|
mem_heap_free(heap2); /* free version and clust_offsets */
|
|
|
|
if (err != DB_SUCCESS || !prev_version) {
|
|
/* Versions end here */
|
|
|
|
mem_heap_free(heap);
|
|
|
|
return(FALSE);
|
|
}
|
|
|
|
clust_offsets = rec_get_offsets(prev_version, clust_index,
|
|
NULL, ULINT_UNDEFINED, &heap);
|
|
|
|
if (!rec_get_deleted_flag(prev_version, comp)) {
|
|
row = row_build(ROW_COPY_POINTERS, clust_index,
|
|
prev_version, clust_offsets, heap);
|
|
entry = row_build_index_entry(row, index, heap);
|
|
|
|
/* NOTE that we cannot do the comparison as binary
|
|
fields because maybe the secondary index record has
|
|
already been updated to a different binary value in
|
|
a char field, but the collation identifies the old
|
|
and new value anyway! */
|
|
|
|
if (dtuple_datas_are_ordering_equal(ientry, entry)) {
|
|
|
|
mem_heap_free(heap);
|
|
|
|
return(TRUE);
|
|
}
|
|
}
|
|
|
|
version = prev_version;
|
|
}
|
|
}
|
|
|
|
/*********************************************************************
|
|
Constructs the version of a clustered index record which a consistent
|
|
read should see. We assume that the trx id stored in rec is such that
|
|
the consistent read should not see rec in its present version. */
|
|
|
|
ulint
|
|
row_vers_build_for_consistent_read(
|
|
/*===============================*/
|
|
/* out: DB_SUCCESS or DB_MISSING_HISTORY */
|
|
rec_t* rec, /* in: record in a clustered index; the
|
|
caller must have a latch on the page; this
|
|
latch locks the top of the stack of versions
|
|
of this records */
|
|
mtr_t* mtr, /* in: mtr holding the latch on rec */
|
|
dict_index_t* index, /* in: the clustered index */
|
|
ulint** offsets,/* in/out: offsets returned by
|
|
rec_get_offsets(rec, index) */
|
|
read_view_t* view, /* in: the consistent read view */
|
|
mem_heap_t** offset_heap,/* in/out: memory heap from which
|
|
the offsets are allocated */
|
|
mem_heap_t* in_heap,/* in: memory heap from which the memory for
|
|
old_vers is allocated; memory for possible
|
|
intermediate versions is allocated and freed
|
|
locally within the function */
|
|
rec_t** old_vers)/* out, own: old version, or NULL if the
|
|
record does not exist in the view, that is,
|
|
it was freshly inserted afterwards */
|
|
{
|
|
rec_t* version;
|
|
rec_t* prev_version;
|
|
dulint trx_id;
|
|
mem_heap_t* heap = NULL;
|
|
byte* buf;
|
|
ulint err;
|
|
|
|
ut_ad(index->type & DICT_CLUSTERED);
|
|
ut_ad(mtr_memo_contains(mtr, buf_block_align(rec), MTR_MEMO_PAGE_X_FIX)
|
|
|| mtr_memo_contains(mtr, buf_block_align(rec),
|
|
MTR_MEMO_PAGE_S_FIX));
|
|
#ifdef UNIV_SYNC_DEBUG
|
|
ut_ad(!rw_lock_own(&(purge_sys->latch), RW_LOCK_SHARED));
|
|
#endif /* UNIV_SYNC_DEBUG */
|
|
|
|
ut_ad(rec_offs_validate(rec, index, *offsets));
|
|
|
|
trx_id = row_get_rec_trx_id(rec, index, *offsets);
|
|
|
|
ut_ad(!read_view_sees_trx_id(view, trx_id));
|
|
|
|
rw_lock_s_lock(&(purge_sys->latch));
|
|
version = rec;
|
|
|
|
for (;;) {
|
|
mem_heap_t* heap2 = heap;
|
|
trx_undo_rec_t* undo_rec;
|
|
dulint roll_ptr;
|
|
dulint undo_no;
|
|
heap = mem_heap_create(1024);
|
|
|
|
/* If we have high-granularity consistent read view and
|
|
creating transaction of the view is the same as trx_id in
|
|
the record we see this record only in the case when
|
|
undo_no of the record is < undo_no in the view. */
|
|
|
|
if (view->type == VIEW_HIGH_GRANULARITY
|
|
&& ut_dulint_cmp(view->creator_trx_id, trx_id) == 0) {
|
|
|
|
roll_ptr = row_get_rec_roll_ptr(version, index,
|
|
*offsets);
|
|
undo_rec = trx_undo_get_undo_rec_low(roll_ptr, heap);
|
|
undo_no = trx_undo_rec_get_undo_no(undo_rec);
|
|
mem_heap_empty(heap);
|
|
|
|
if (ut_dulint_cmp(view->undo_no, undo_no) > 0) {
|
|
/* The view already sees this version: we can
|
|
copy it to in_heap and return */
|
|
|
|
buf = mem_heap_alloc(in_heap,
|
|
rec_offs_size(*offsets));
|
|
*old_vers = rec_copy(buf, version, *offsets);
|
|
rec_offs_make_valid(*old_vers, index,
|
|
*offsets);
|
|
err = DB_SUCCESS;
|
|
|
|
break;
|
|
}
|
|
}
|
|
|
|
err = trx_undo_prev_version_build(rec, mtr, version, index,
|
|
*offsets, heap,
|
|
&prev_version);
|
|
if (heap2) {
|
|
mem_heap_free(heap2); /* free version */
|
|
}
|
|
|
|
if (err != DB_SUCCESS) {
|
|
break;
|
|
}
|
|
|
|
if (prev_version == NULL) {
|
|
/* It was a freshly inserted version */
|
|
*old_vers = NULL;
|
|
err = DB_SUCCESS;
|
|
|
|
break;
|
|
}
|
|
|
|
*offsets = rec_get_offsets(prev_version, index, *offsets,
|
|
ULINT_UNDEFINED, offset_heap);
|
|
|
|
trx_id = row_get_rec_trx_id(prev_version, index, *offsets);
|
|
|
|
if (read_view_sees_trx_id(view, trx_id)) {
|
|
|
|
/* The view already sees this version: we can copy
|
|
it to in_heap and return */
|
|
|
|
buf = mem_heap_alloc(in_heap, rec_offs_size(*offsets));
|
|
*old_vers = rec_copy(buf, prev_version, *offsets);
|
|
rec_offs_make_valid(*old_vers, index, *offsets);
|
|
err = DB_SUCCESS;
|
|
|
|
break;
|
|
}
|
|
|
|
version = prev_version;
|
|
}/* for (;;) */
|
|
|
|
mem_heap_free(heap);
|
|
rw_lock_s_unlock(&(purge_sys->latch));
|
|
|
|
return(err);
|
|
}
|
|
|
|
/*********************************************************************
|
|
Constructs the last committed version of a clustered index record,
|
|
which should be seen by a semi-consistent read. */
|
|
|
|
ulint
|
|
row_vers_build_for_semi_consistent_read(
|
|
/*====================================*/
|
|
/* out: DB_SUCCESS or DB_MISSING_HISTORY */
|
|
rec_t* rec, /* in: record in a clustered index; the
|
|
caller must have a latch on the page; this
|
|
latch locks the top of the stack of versions
|
|
of this records */
|
|
mtr_t* mtr, /* in: mtr holding the latch on rec */
|
|
dict_index_t* index, /* in: the clustered index */
|
|
ulint** offsets,/* in/out: offsets returned by
|
|
rec_get_offsets(rec, index) */
|
|
mem_heap_t** offset_heap,/* in/out: memory heap from which
|
|
the offsets are allocated */
|
|
mem_heap_t* in_heap,/* in: memory heap from which the memory for
|
|
old_vers is allocated; memory for possible
|
|
intermediate versions is allocated and freed
|
|
locally within the function */
|
|
rec_t** old_vers)/* out, own: rec, old version, or NULL if the
|
|
record does not exist in the view, that is,
|
|
it was freshly inserted afterwards */
|
|
{
|
|
rec_t* version;
|
|
mem_heap_t* heap = NULL;
|
|
byte* buf;
|
|
ulint err;
|
|
dulint rec_trx_id = ut_dulint_create(0, 0);
|
|
|
|
ut_ad(index->type & DICT_CLUSTERED);
|
|
ut_ad(mtr_memo_contains(mtr, buf_block_align(rec), MTR_MEMO_PAGE_X_FIX)
|
|
|| mtr_memo_contains(mtr, buf_block_align(rec),
|
|
MTR_MEMO_PAGE_S_FIX));
|
|
#ifdef UNIV_SYNC_DEBUG
|
|
ut_ad(!rw_lock_own(&(purge_sys->latch), RW_LOCK_SHARED));
|
|
#endif /* UNIV_SYNC_DEBUG */
|
|
|
|
ut_ad(rec_offs_validate(rec, index, *offsets));
|
|
|
|
rw_lock_s_lock(&(purge_sys->latch));
|
|
/* The S-latch on purge_sys prevents the purge view from
|
|
changing. Thus, if we have an uncommitted transaction at
|
|
this point, then purge cannot remove its undo log even if
|
|
the transaction could commit now. */
|
|
|
|
version = rec;
|
|
|
|
for (;;) {
|
|
trx_t* version_trx;
|
|
mem_heap_t* heap2;
|
|
rec_t* prev_version;
|
|
dulint version_trx_id;
|
|
|
|
version_trx_id = row_get_rec_trx_id(version, index, *offsets);
|
|
if (rec == version) {
|
|
rec_trx_id = version_trx_id;
|
|
}
|
|
|
|
mutex_enter(&kernel_mutex);
|
|
version_trx = trx_get_on_id(version_trx_id);
|
|
mutex_exit(&kernel_mutex);
|
|
|
|
if (!version_trx
|
|
|| version_trx->conc_state == TRX_NOT_STARTED
|
|
|| version_trx->conc_state == TRX_COMMITTED_IN_MEMORY) {
|
|
|
|
/* We found a version that belongs to a
|
|
committed transaction: return it. */
|
|
|
|
if (rec == version) {
|
|
*old_vers = rec;
|
|
err = DB_SUCCESS;
|
|
break;
|
|
}
|
|
|
|
/* We assume that a rolled-back transaction stays in
|
|
TRX_ACTIVE state until all the changes have been
|
|
rolled back and the transaction is removed from
|
|
the global list of transactions. */
|
|
|
|
if (!ut_dulint_cmp(rec_trx_id, version_trx_id)) {
|
|
/* The transaction was committed while
|
|
we searched for earlier versions.
|
|
Return the current version as a
|
|
semi-consistent read. */
|
|
|
|
version = rec;
|
|
*offsets = rec_get_offsets(version,
|
|
index, *offsets,
|
|
ULINT_UNDEFINED,
|
|
offset_heap);
|
|
}
|
|
|
|
buf = mem_heap_alloc(in_heap, rec_offs_size(*offsets));
|
|
*old_vers = rec_copy(buf, version, *offsets);
|
|
rec_offs_make_valid(*old_vers, index, *offsets);
|
|
err = DB_SUCCESS;
|
|
|
|
break;
|
|
}
|
|
|
|
heap2 = heap;
|
|
heap = mem_heap_create(1024);
|
|
|
|
err = trx_undo_prev_version_build(rec, mtr, version, index,
|
|
*offsets, heap,
|
|
&prev_version);
|
|
if (heap2) {
|
|
mem_heap_free(heap2); /* free version */
|
|
}
|
|
|
|
if (UNIV_UNLIKELY(err != DB_SUCCESS)) {
|
|
break;
|
|
}
|
|
|
|
if (prev_version == NULL) {
|
|
/* It was a freshly inserted version */
|
|
*old_vers = NULL;
|
|
err = DB_SUCCESS;
|
|
|
|
break;
|
|
}
|
|
|
|
version = prev_version;
|
|
*offsets = rec_get_offsets(version, index, *offsets,
|
|
ULINT_UNDEFINED, offset_heap);
|
|
}/* for (;;) */
|
|
|
|
if (heap) {
|
|
mem_heap_free(heap);
|
|
}
|
|
rw_lock_s_unlock(&(purge_sys->latch));
|
|
|
|
return(err);
|
|
}
|