Commit graph

595 commits

Author SHA1 Message Date
marko
6bdab319ad branches/zip: Always check for "row too large" when executing SQL to create
an index or table.  We have to skip this check when loading table definitions
from the data dictionary, because we could otherwise refuse to load old
tables (even uncompressed ones).  This addresses Issue #119.

The first "row too large" check was implemented in MySQL 5.0.3
to address MySQL Bug #5682.  In the InnoDB Plugin 1.0.2, a more
accurate check was implemented in innodb_strict_mode.  We now
make the check unconditional.

dict_create_index_step(): Pass strict=TRUE to dict_index_add_to_cache().

trx_is_strict(), thd_is_strict(): Remove.

innodb-zip.test: Test in innodb_strict_mode=OFF.

innodb_bug36169.test: Ensure that none of the tables can be created.

rb://56 approved by Sunny Bains.
2008-11-20 10:22:40 +00:00
marko
d26ba07df0 branches/zip: buf_LRU_free_block(): Clarify the function comment. 2008-11-19 14:39:55 +00:00
michael
337c4d9561 branches/zip: rb://53
Final version of rb://53, fixes the styling of a comment, makes
the definition and the declaration of thd_supports_xa() identical commentwise.
2008-11-17 14:02:01 +00:00
michael
c6227f3766 branches/zip:
rb://53

Improve innodb_supports_xa system variable handling and 
reduces the number of retrievals of the value from MySQL.

Approved by: Marko, over IM
2008-11-17 12:56:56 +00:00
marko
ede49be9fc branches/zip: Revert the unintended change to univ.i that was made in r2943. 2008-10-31 08:18:47 +00:00
vasil
729ff1ad34 branches/zip:
Revert our temporary fix for "Bug#40360 Binlog related errors with binlog off"
(r2935, r2936) and deploy MySQL's one, but put the function
mysql_bin_log_is_engaged() inside mysql_addons.cc instead of in mysql's log.cc
and use a different name for it so there is no collision when MySQL adds this
function in log.cc.

[note from the future: the windows part of this patch went into r2947]

Approved by:	Marko (https://svn.innodb.com/rb/r/41/)
2008-10-31 07:44:16 +00:00
sunny
7fed1c703e branches/zip:
1. We add a vector of locks to trx_t. This array contains the autoinc
  locks granted to a transaction. There is one per table.

  2. We enforce releasing of these locks in the reverse order from the
  one in which they are acquired. The assumption is that since the
  AUTOINC locks are statement level locks. Nested statements introduced
  by triggers are stacked it should hold.

There was some cleanup done to the vector code too by adding const and
some new functions. Rename dict_table_t::auto_inc_lock to autoinc_lock.

Fix Bug#26316 Triggers create duplicate entries on auto-increment columns
rb://22
2008-10-31 07:40:29 +00:00
vasil
eb1b8095ff branches/zip:
Increment the InnoDB Plugin version from 1.0.1 to 1.0.2.
2008-10-30 17:34:27 +00:00
marko
bd3514db33 branches/zip: Merge revisions 2854:2929 from branches/5.1,
except r2924, which was merged from branches/zip r2866 to branches/5.1
and except r2879 which was merged separately by Calvin:

  ------------------------------------------------------------------------
  r2902 | vasil | 2008-10-28 12:10:25 +0200 (Tue, 28 Oct 2008) | 10 lines

  branches/5.1:

  Fix Bug#38189 innodb_stats_on_metadata missing

  Make the variable innodb_stats_on_metadata visible to the users and
  also settable at runtime. Previously it was only "visible" as a command
  line startup option to mysqld.

  Approved by:    Marko (https://svn.innodb.com/rb/r/36)
  ------------------------------------------------------------------------
  r2929 | marko | 2008-10-29 21:26:14 +0200 (Wed, 29 Oct 2008) | 13 lines

  branches/5.1: dtype_get_sql_null_size(): return the correct storage
  size of a SQL NULL column. (Bug #40369)

  When MySQL Bug #20877 was fixed in r834, this function was
  accidentally modified to return 0 or 1. Apparently, the only impact of
  this bug is that fixed-length columns cannot be updated in-place from
  or to SQL NULL, even in ROW_FORMAT=REDUNDANT.  After this fix,
  fixed-length columns in ROW_FORMAT=REDUNDANT will have a constant
  storage size as they should, no matter if NULL or non-NULL.  The bug
  caused fixed-length NULL columns to occupy 1 byte.

  rb://37 approved by Heikki over IM.
  ------------------------------------------------------------------------
2008-10-29 19:39:24 +00:00
michael
a81e8ca892 Remove unnecessary assert
Approved by: Heikki, over IM
2008-10-29 17:20:10 +00:00
marko
f3f2de1614 branches/zip: dict_str_starts_with_keyword(): Removed this unused function.
Spotted by Sunny.
2008-10-28 06:36:39 +00:00
marko
d8fd1aec8d branches/zip: Clean up the file format stamping.
trx_sys_file_format_max_upgrade(): Rename from
trx_sys_file_format_max_update().  Improve the documentation.  Add a
const qualifier to the parameter "name".  Replace the parameter
"flags" with "format_id", because this function should deal with file
format identifiers, not with table flags.

trx_sys_file_format_max_write(), trx_sys_file_format_max_set(): Add a
const qualifier to the parameter "name".

ha_innodb.cc: Correct the spelling in some comments: "side effect".
Remove redundant prototypes for some static callback functions.

innodb_file_format_name_update(), innodb_file_format_check_update():
Correct the function signature.  Use appropriate pointer type conversions.

MYSQL_SYSVAR_STR(file_format), MYSQL_SYSVAR_STR(file_format_check):
Remove the type conversions from the callback function pointers.  When
the function signatures match, no type conversion is needed.  The type
conversions would only prevent compilation warnings for any mismatch.

Approved by Sunny in rb://25.
2008-10-23 08:27:15 +00:00
sunny
119142d2d1 branches/zip:
Merge revisions 2852:2854 from branches/5.1:

  ------------------------------------------------------------------------
  r2854 | sunny | 2008-10-23 08:30:32 +0300 (Thu, 23 Oct 2008) | 13 lines
  Changed paths:
     M /branches/5.1/dict/dict0dict.c
     M /branches/5.1/dict/dict0mem.c
     M /branches/5.1/handler/ha_innodb.cc
     M /branches/5.1/handler/ha_innodb.h
     M /branches/5.1/include/dict0dict.h
     M /branches/5.1/include/dict0mem.h
     M /branches/5.1/row/row0mysql.c
  
  branches/5.1: Backport changes from branches/zip r2725
  
  Simplify the autoinc initialization code. This removes the
  non-determinism related to reading the table's autoinc value for the first
  time. This change has also reduced the sizeof dict_table_t by sizeof(ibool)
  bytes because we don't need the dict_table_t::autoinc_inited field anymore.
  
  Bug#39830 Table autoinc value not updated on first insert.
  Bug#35498 Cannot get table test/table1 auto-inccounter value in ::info
  Bug#36411 Failed to read auto-increment value from storage engine" in 5.1.24 auto-inc
  rb://16
  
  
  ------------------------------------------------------------------------
2008-10-23 06:24:33 +00:00
sunny
f9c42d81e7 branches/zip:
Merge revisions 2837:2852 from branches/5.1:

  ------------------------------------------------------------------------
  r2849 | sunny | 2008-10-22 12:01:18 +0300 (Wed, 22 Oct 2008) | 8 lines
  Changed paths:
     M /branches/5.1/handler/ha_innodb.cc
     M /branches/5.1/include/row0mysql.h
     M /branches/5.1/row/row0mysql.c
  
  branches/5.1: Return the actual error code encountered when allocating
  a new autoinc value. The change in behavior (bug) was introduced in 5.1.22
  when we introduced the new AUTOINC locking model.
  
  rb://31
  
  Bug#40224 New AUTOINC changes mask reporting of deadlock/timeout errors
  
  ------------------------------------------------------------------------
  r2852 | sunny | 2008-10-23 01:42:24 +0300 (Thu, 23 Oct 2008) | 9 lines
  Changed paths:
     M /branches/5.1/handler/ha_innodb.cc
     M /branches/5.1/handler/ha_innodb.h
  
  branches/5.1: Backport r2724 from branches/zip
  
  Check column value against the col max value before updating the table's
  global autoinc counter value. This is part of simplifying the AUTOINC
  sub-system. We extract the type info from MySQL data structures at runtime.
  
  This fixes Bug#37788 InnoDB Plugin: AUTO_INCREMENT wrong for compressed tables
  
  
  ------------------------------------------------------------------------
2008-10-23 05:29:46 +00:00
marko
b8c51944b9 branches/zip: page_zip_rec_needs_ext(): Fix a bug that was introduced
in the fix of Mantis issue #73.  With key_block_size=16, we will also
have to check the available space on the uncompressed page.
Otherwise, the clustered index record can be almost 16 kilobytes in
size, and the undo log record will not fit.
2008-10-22 06:07:37 +00:00
marko
8ec95fc761 branches/zip: When the server crashes while freeing an externally stored
column of a compressed table, the BTR_EXTERN_LEN field in the BLOB pointer
will be written as 0.  Tolerate this in the functions that deal with
externally stored columns.  This fixes Issue #80 and was posted at rb://26.

Note that the clustered index record is always deleted or purged last,
after any secondary index records referring to it have been deleted.

btr_free_externally_stored_field(): On an uncompressed table, zero out
the BTR_EXTERN_LEN, so that half-deleted BLOBs can be detected after
crash recovery.

btr_copy_externally_stored_field_prefix(): Return 0 if the BLOB has been
half-deleted.

row_upd_ext_fetch(): Assert that the externally stored column exists.

row_ext_cache_fill(): Allow btr_copy_externally_stored_field_prefix()
to return 0.

row_sel_sec_rec_is_for_blob(): Return FALSE if the BLOB has been half-deleted.
This is correct, because the clustered index record would have been deleted
or purged last, after any secondary index records referring to it had been
deleted.
2008-10-15 10:27:42 +00:00
marko
f644f6af5e branches/zip: Introduce UNIV_ZIP_COPY for invoking page_zip_copy_recs()
more often in B-tree operations.
2008-10-15 09:21:54 +00:00
marko
05c33d6d3f branches/zip: When invoking page_zip_copy_recs(), update the lock table
and the adaptive hash index.  This should fix Issue #95 and Issue #87.

page_zip_copy_recs(): Copy PAGE_MAX_TRX_ID as well, to have similar behavior
to page_copy_rec_list_start() and page_copy_rec_list_end().

btr_root_raise_and_insert(), btr_page_split_and_insert(), btr_lift_page_up():
Update the lock table and the adaptive hash index.
2008-10-15 06:32:40 +00:00
marko
344481d597 branches/zip: row_create_table_for_mysql(), row_create_index_for_mysql():
Note that the dictionary object will be freed.
2008-10-15 06:00:06 +00:00
calvin
e197d7dcf7 branches/zip: fix Mantis issue #96 Problem compiling ha_innodb.cc
on 64-bit Windows

Change the definition of srv_replication_delay from ulint to ulong.
ulint is 64-bit on Win64.

Approved by:	Heikki (on IM)
2008-10-14 15:14:47 +00:00
marko
41953325b9 branches/zip: Fix some locking issues, mainly in fast index creation.
This should hopefully address Issue #85.

ha_innobase::add_index(): Lock the data dictionary before invoking
row_merge_rename_indexes() or row_merge_drop_indexes(), because neither
function will commit the transaction.

ha_innobase::final_drop_index(): Commit the transactions before
unlocking the data dictionary.

row_merge_drop_index(), row_merge_drop_indexes(), row_merge_rename_tables(),
row_merge_rename_indexes(): Note and assert that the data dictionary must
have been exclusively locked by the caller, because the transaction will
not be committed.

row_drop_database_for_mysql(): Commit the transaction immediately after
dropping each table.  When MySQL is holding open handles to some tables,
it can otherwise occur than the data dictionary is unlocked while the
transaction has not been committed.  This bug was introduced in r2739,
which changed the semantics of row_drop_table_for_mysql().

row_drop_database_for_mysql(): Postpone mem_free(table_name), so that
an error printout will not dereference freed memory.
2008-10-10 11:44:27 +00:00
marko
a9a21fb983 branches/zip: Do not release the data dictionary latch while holding locks
to the data dictionary records.  This should fix Issue #83.

row_drop_table_for_mysql_no_commit(): Rename back to
row_drop_table_for_mysql().  Commit the transaction if the data
dictionary was not locked when the function was called.  Otherwise,
neither commit the transaction nor unlock the data dictionary.

row_merge_drop_table(): Let row_drop_table_for_mysql() take care of
locking the data dictionary.

dict_create_or_check_foreign_constraint_tables(),
trx_rollback_active(), row_create_table_for_mysql(),
row_create_index_for_mysql(), row_table_add_foreign_constraints():
Explicitly commit the transaction, because row_drop_table_for_mysql()
would no longer commit it, given that the data dictionary will be
locked during the calls.

Approved by Sunny (over IM). rb://23
2008-10-08 08:54:16 +00:00
marko
5f3fbb7b84 branches/zip: Relax the page_zip_validate() check during crash recovery:
ignore intermittent differences in the "predefined minimum record" flag.

page_zip_validate_low(): Renamed from page_zip_validate(), with an
additional parameter: ibool sloppy.  Ignore REC_INFO_MIN_REC_FLAG when
sloppy == TRUE.

page_zip_validate(): Wrapper for page_zip_validate_low().  Pass
sloppy = recv_recovery_is_on().

recv_recover_page(): After applying the changes from the redo log to a
compressed B-tree page, invoke page_zip_validate_low() in strict mode.
2008-10-06 07:13:52 +00:00
sunny
0eff3d3ca6 branches/zip: Simplify the autoinc initialization code. This removes the
non-determinism related to reading the table's autoinc value for the first
time. This change has also reduced the sizeof dict_table_t by sizeof(ibool)
bytes because we don't need the dict_table_t::autoinc_inited field anymore.

This also fixes Bug#39830 Table autoinc value not updated on first insert.
rb://16
2008-10-04 06:24:56 +00:00
sunny
cb0cacc2d8 branches/zip: Merge revisions 2702:2722 from branches/5.1:
------------------------------------------------------------------------
  r2702 | sunny | 2008-09-30 11:41:56 +0300 (Tue, 30 Sep 2008) | 13 lines
  Changed paths:
     M /branches/5.1/handler/ha_innodb.cc
  
  branches/5.1: Since handler::get_auto_increment() doesn't allow us
  to return the cause of failure we have to inform MySQL using the
  sql_print_warning() function to return the cause for autoinc failure.
  Previously we simply printed the error code, this patch prints the
  text string representing the following two error codes:
  
  DB_LOCK_WAIT_TIMEOUT
  DB_DEADLOCK.
  
  Bug#35498 Cannot get table test/table1 auto-inccounter value in ::info
  
  Approved by Marko.
  
  ------------------------------------------------------------------------
  r2709 | vasil | 2008-10-01 10:13:13 +0300 (Wed, 01 Oct 2008) | 10 lines
  Changed paths:
     M /branches/5.1/include/lock0lock.h
     M /branches/5.1/lock/lock0lock.c
     A /branches/5.1/mysql-test/innodb_bug38231.result
     A /branches/5.1/mysql-test/innodb_bug38231.test
     M /branches/5.1/row/row0mysql.c
  
  branches/5.1:
  
  Fix Bug#38231 Innodb crash in lock_reset_all_on_table() on TRUNCATE + LOCK / UNLOCK
  
  In TRUNCATE TABLE and discard tablespace: do not remove table-level S
  and X locks and do not assert on such locks not being wait locks.
  Leave such locks alone.
  
  Approved by:	Heikki (rb://14)
  
  ------------------------------------------------------------------------
  r2710 | vasil | 2008-10-01 14:13:58 +0300 (Wed, 01 Oct 2008) | 6 lines
  Changed paths:
     M /branches/5.1/include/sync0sync.ic
  
  branches/5.1:
  
  Silence a compilation warning in UNIV_DEBUG.
  
  Approved by:	Marko (via IM)
  
  ------------------------------------------------------------------------
  r2719 | vasil | 2008-10-03 18:17:28 +0300 (Fri, 03 Oct 2008) | 49 lines
  Changed paths:
     M /branches/5.1/handler/ha_innodb.cc
     A /branches/5.1/mysql-test/innodb_bug39438-master.opt
     A /branches/5.1/mysql-test/innodb_bug39438.result
     A /branches/5.1/mysql-test/innodb_bug39438.test
  
  branches/5.1:
  
  Fix Bug#39438 Testcase for Bug#39436 crashes on 5.1 in fil_space_get_latch
  
  In ha_innobase::info() - do not try to get the free space for a tablespace
  which has been discarded with ALTER TABLE ... DISCARD TABLESPACE or if the
  .ibd file is missing for some other reason.
  
  ibd_file_missing and tablespace_discarded are manipulated only in
  row_discard_tablespace_for_mysql() and in row_import_tablespace_for_mysql()
  and the manipulation is protected/surrounded by
  row_mysql_lock_data_dictionary()/row_mysql_unlock_data_dictionary() thus we
  do the same in ha_innobase::info() when checking the values of those members
  to avoid race conditions. I have tested the code-path with UNIV_DEBUG and
  UNIV_SYNC_DEBUG.
  
  Looks like it is not possible to avoid mysqld printing warnings in the
  mysql-test case and thus this test innodb_bug39438 must be added to the
  list of exceptional test cases that are allowed to print warnings. For this,
  the following patch must be applied to the mysql source tree:
  
    --- cut ---
    === modified file 'mysql-test/lib/mtr_report.pl'
    --- mysql-test/lib/mtr_report.pl	2008-08-12 10:26:23 +0000
    +++ mysql-test/lib/mtr_report.pl	2008-10-01 11:57:41 +0000
    @@ -412,7 +412,10 @@
     
                     # When trying to set lower_case_table_names = 2
                     # on a case sensitive file system. Bug#37402.
    -                /lower_case_table_names was set to 2, even though your the file system '.*' is case sensitive.  Now setting lower_case_table_names to 0 to avoid future problems./
    +                /lower_case_table_names was set to 2, even though your the file system '.*' is case sensitive.  Now setting lower_case_table_names to 0 to avoid future problems./ or
    +
    +                # this test is expected to print warnings
    +                ($testname eq 'main.innodb_bug39438')
     		)
                 {
                   next;                       # Skip these lines
    
    --- cut ---
  
  The mysql-test is currently somewhat disabled (see inside
  innodb_bug39438.test), after the above patch has been applied to the mysql
  source tree, the test can be enabled.
  
  rb://20
  
  Reviewed by:	Inaam, Calvin
  Approved by:	Heikki
  
  ------------------------------------------------------------------------
  r2720 | vasil | 2008-10-03 19:52:39 +0300 (Fri, 03 Oct 2008) | 8 lines
  Changed paths:
     M /branches/5.1/handler/ha_innodb.cc
  
  branches/5.1:
  
  Print a warning if an attempt is made to get the free space for a table
  whose .ibd file is missing or the tablespace has been discarded. This is a
  followup to r2719.
  
  Suggested by:	Inaam
  
  ------------------------------------------------------------------------
  r2721 | sunny | 2008-10-04 02:08:23 +0300 (Sat, 04 Oct 2008) | 6 lines
  Changed paths:
     M /branches/5.1/handler/ha_innodb.cc
  
  branches/5.1: We need to send the messages to the client because
  handler::get_auto_increment() doesn't allow a way to return the
  specific error for why it failed.
  
  rb://18
  
  ------------------------------------------------------------------------
  r2722 | sunny | 2008-10-04 02:48:04 +0300 (Sat, 04 Oct 2008) | 18 lines
  Changed paths:
     M /branches/5.1/dict/dict0mem.c
     M /branches/5.1/handler/ha_innodb.cc
     M /branches/5.1/include/dict0mem.h
     M /branches/5.1/include/row0mysql.h
     M /branches/5.1/mysql-test/innodb-autoinc.result
     M /branches/5.1/mysql-test/innodb-autoinc.test
     M /branches/5.1/row/row0mysql.c
  
  branches/5.1: This bug has always existed but was masked by other errors. The
  fix for bug# 38839 triggered this bug. When the offset and increment are > 1
  we need to calculate the next value taking into consideration the two
  variables. Previously we simply assumed they were 1 particularly offset was
  never used. MySQL does its own calculation and that's probably why it seemed
  to work in the past. We would return what we thought was the correct next
  value and then MySQL would recalculate the actual value from that and return
  it to the caller (e.g., handler::write_row()). Several new tests have been
  added that try and catch some edge cases. The tests exposed a wrap around
  error in MySQL next value calculation which was filed as bug#39828. The tests
  will need to be updated once MySQL fix that bug.
  
  One good side effect of this fix is that dict_table_t size has been
  reduced by 8 bytes because we have moved the autoinc_increment field to
  the row_prebuilt_t structure. See review-board for a detailed discussion.
  
  rb://3
  
  ------------------------------------------------------------------------
2008-10-04 03:22:36 +00:00
marko
be56c64772 branches/zip: Make innodb_lock_wait_timeout a settable session variable
(Bug #36285, rb://9).

innodb-index.test, innodb-index.result: Set innodb_lock_wait_timeout as
a session variable instead of relying on the global value.

innodb-index-master.opt: Remove.

innodb-timeout.test: Test that setting the innodb_lock_wait_timeout
works as advertised.

thd_lock_wait_timeout(): New function, to retrieve the lock wait timeout
for a given MySQL client connection (thd), or the global value (thd==NULL).

srv_lock_wait_timeout, innobase_lock_wait_timeout: Remove.

Replace MYSQL_SYSVAR_LONG(lock_wait_timeout)
with MYSQL_THDVAR_ULONG(lock_wait_timeout).
2008-10-03 09:24:23 +00:00
marko
ac51cfb4d2 branches/zip: page_mem_free(): Remove the obsolete remark that there
should be space left in the modification log of the compressed page.
Record deletion does not require any space in the modification log.
2008-10-01 19:04:44 +00:00
marko
482595ad8e branches/zip: btr_cur_optimistic_insert(): Correct an error that was made
in r2631.  Include the node pointer field in the size calculation.

rec_get_converted_size_comp_prefix(): New function, to compute the storage
size of the prefix of an ordinary record in COMPACT format.

rec_get_converted_size_comp(): Use rec_get_converted_size_comp_prefix().
2008-09-29 07:40:02 +00:00
marko
e24dfa77b8 branches/zip: Non-functional change:
page_zip_copy_recs(): Rename from page_zip_copy().
Update the function comment.
2008-09-25 12:17:52 +00:00
marko
d9317eb699 branches/zip: Non-functional change:
buf_block_dbg_add_level(block, level): Define as an empty macro when
UNIV_SYNC_DEBUG is not defined.  Remove #ifdef UNIV_SYNC_DEBUG around
all invocations.
2008-09-22 06:59:58 +00:00
marko
75fe6fa6a4 branches/zip: When creating an index in innodb_strict_mode, check that
the maximum record size will never exceed the B-tree page size limit.
For uncompressed tables, there should always be enough space for two
records in an empty B-tree page.  For compressed tables, there should
be enough space for storing two node pointer records or one data
record in an empty page in uncompressed format.

dict_build_table_def_step(): Remove the inaccurate check for table row
size.

dict_index_too_big_for_tree(): New function: check if the index
records would be too big for a B-tree page.

dict_index_add_to_cache(): Add the parameter "strict".  Invoke
dict_index_too_big_for_tree() if it is set.

trx_is_strict(), thd_is_strict(): New functions, for determining if
innodb_strict_mode is enabled for the current transaction.

dict_create_index_step(): Pass the new parameter strict of
dict_index_add_to_cache() as trx_is_strict(trx).  All other callers
pass it as FALSE.

innodb.test: Enable innodb_strict_mode before attempting to create a
table with a too big record size.

innodb-zip.test: Remove the test of inserting random data.  Add tests
for checking that the maximum record lengths are enforced at table
creation time.
2008-09-18 12:31:17 +00:00
marko
00e68e25b1 branches/zip: btr_cur_del_unmark_for_ibuf(): Correct the function comment. 2008-09-18 06:10:49 +00:00
marko
c1cc5b1316 branches/zip: innobase_convert_from_id(), innobase_convert_from_table_id():
Add the parameter struct charset_info_st* cs, so that the call
thd_charset(current_thd) can be avoided.  The macro current_thd has no
defined value in the Windows plugin.
2008-09-17 10:07:36 +00:00
marko
5dc842cf08 branches/zip: Non-functional change: Move the declarations of the
functions innobase_convert_from_table_id(), innobase_convert_from_id(),
innobase_casedn_str(), and innobase_get_charset() to ha_prototypes.h.
2008-09-17 10:03:43 +00:00
marko
9971b1d080 branches/zip: HASH_INSERT: Add a type conversion that is needed to keep
the Microsoft Visual C compiler happy.  This fix was from Calvin.
2008-09-17 09:50:28 +00:00
marko
6378cae6bb branches/zip: Prevent infinite B-tree page splits by ensuring that
there will always be enough space for two node pointer records in an
empty B-tree page.  This was reported as Mantis issue #73.

page_zip_rec_needs_ext(): Add the parameter n_fields, for accurate
estimation of the compressed size of the data dictionary information.
Given that this function is only invoked for records on leaf pages,
require that there be enough space for one record in the compressed
page.  We check elsewhere that there will be enough room for two node
pointer records on higher-level pages.

btr_cur_optimistic_insert(): Ensure that there will be enough room for
two node pointer records on an empty non-leaf page.  The rule for
leaf-page records will be enforced by the callers of
page_zip_rec_needs_ext().

btr_cur_pessimistic_insert(): Remove the insufficient check that the
leaf page record should be compressible by itself.  Instead, now we
require that two node pointer records fit on a non-leaf page, and one
record will fit in uncompressed form on the leaf page.

page_zip_write_header(), page_zip_write_rec(): Re-enable the debug
assertions that were violated by the insufficient check in
btr_cur_pessimistic_insert().

innodb_bug36172.test: Use a larger compressed page size.
2008-09-17 06:23:52 +00:00
marko
222b221da2 branches/zip: Minor cleanup.
btr_search_drop_page_hash_index(): Add const qualifiers to the local
variables page, rec, and index, to ensure that they are not modified
by this function.

page_get_infimum_offset(), page_get_supremum_offset(): New functions.

page_get_infimum_rec(), page_get_supremum_rec(): Replaced by
const-preserving macros that invoke the accessor functions.
2008-09-16 13:16:36 +00:00
marko
f19cbe507d branches/zip: ha_innobase::prepare_drop_index(): When there is a
foreign key constraint, find a truly equivalent index for it.
If none is available, refuse to drop the index.  MySQL can drop
an index when creating a "stronger" index.

This was reported as Mantis issue #70 and MySQL Bug #38786.

innodb-index.test: Add a test case.

dict_foreign_find_equiv_index(): New function, to replace the
incorrectly written function dict_table_find_equivalent_index().

dict_table_replace_index_in_foreign_list(): Simplify the implementation.
2008-09-09 11:05:56 +00:00
marko
97be6faaa4 branches/zip: Write clarifying comments about the insert buffer and the
"free" bits in the insert buffer bitmap in particular.
2008-09-04 07:47:49 +00:00
vasil
22ecced647 branches/zip:
Merge 2537:2605 from branches/5.1:

  ------------------------------------------------------------------------
  r2545 | vasil | 2008-07-25 17:24:23 +0300 (Fri, 25 Jul 2008) | 37 lines
  Changed paths:
     M /branches/5.1/handler/ha_innodb.cc
  
  branches/5.1:
  
  Fix Bug#38185 ha_innobase::info can hold locks even when called with HA_STATUS_NO_LOCK
  
  The fix is to call fsp_get_available_space_in_free_extents() from
  ha_innobase::info() only if HA_STATUS_NO_LOCK is not present in the flag
  *AND*
  change get_schema_tables_record() in MySQL's sql/sql_show.cc to call
  ::info() *without* HA_STATUS_NO_LOCK whenever a user issues SELECT FROM
  information_schema.tables;
  
  Without the change to sql/sql_show.cc this patch would lead to Bug#32440
  resurfacing. I.e. delete_length would never be updated in ::info() and
  will remain 0 forever, resulting in the free space not being shown
  anywhere.
  
  This is the change to sql/sql_show.cc for reference, it needs to be
  committed to the MySQL repo before or at the same time with this change
  to ha_innodb.cc:
  
   --- patch begins here ---
   --- sql/sql_show.cc.orig	2008-07-23 09:32:14.000000000 +0300
   +++ sql/sql_show.cc	2008-07-23 09:32:19.000000000 +0300
   @@ -3549,8 +3549,7 @@ static int get_schema_tables_record(THD 
    
        if(file)
        {
   -      file->info(HA_STATUS_VARIABLE | HA_STATUS_TIME | HA_STATUS_AUTO |
   -                 HA_STATUS_NO_LOCK);
   +      file->info(HA_STATUS_VARIABLE | HA_STATUS_TIME | HA_STATUS_AUTO);
          enum row_type row_type = file->get_row_type();
          switch (row_type) {
          case ROW_TYPE_NOT_USED:
   --- patch ends here ---
  
  Approved by:	Heikki
  
  ------------------------------------------------------------------------
  r2603 | marko | 2008-08-21 16:25:05 +0300 (Thu, 21 Aug 2008) | 10 lines
  Changed paths:
     M /branches/5.1/handler/ha_innodb.cc
     M /branches/5.1/include/ha_prototypes.h
     M /branches/5.1/row/row0sel.c
  
  branches/5.1: Identify SELECT statements by thd_sql_command() == SQLCOM_SELECT
  instead of parsing the query string.  This fixes MySQL Bug #37885 without
  us having to implement lexical analysis of SQL comments in yet another place.
  
  thd_is_select(): A new predicate.
  
  row_search_for_mysql(): Use thd_is_select().
  
  Approved by Heikki.
  
  ------------------------------------------------------------------------
2008-08-21 14:23:46 +00:00
marko
f4f8113488 branches/zip: Minor cleanup.
dict_table_get_referenced_constraint(), dict_table_get_foreign_constraint():
Simplify the iteration loop.

dict_table_find_equivalent_index(): Correct the function comment.
2008-08-21 10:56:01 +00:00
marko
0d0e36741f branches/zip: Cleanup: make dict_scan_to() a static function. 2008-08-20 11:53:11 +00:00
marko
0d8f5237dd branches/zip: Introduce UNIV_LRU_DEBUG for debugging the LRU buffer pool
cache, especially buf_pool->LRU_old and bpage->old.

buf_LRU_old_adjust_len(), buf_LRU_remove_block(): Check that blocks in
buf_pool->LRU_old have the "old" flag set and the blocks preceding
buf_pool->LRU_old have the "old" flag clear.

buf_LRU_add_block_low(), buf_relocate(): Check that buf_pool->LRU_old
is the first block in the LRU list whose "old" flag is set.

buf_LRU_free_block(): When replacing a control block in the LRU list
with a control block for a compressed page, assert that the "old"
flags in the neighboring LRU list entries grow monotonically.

buf_page_set_old(): Assert that the "old" flags in the neighboring LRU
list entries grow monotonically.
2008-08-18 18:28:20 +00:00
marko
aebc0edf5a branches/zip: buf_page_set_old(): Add the assertion ut_ad(bpage->in_LRU_list).
Adjust the callers where necessary:
buf_LRU_add_block_to_end_low() and buf_LRU_add_block_low().
2008-08-18 18:06:33 +00:00
marko
0a07814087 branches/zip: flst_write_addr(), flst_read_addr(): Assert that no
file list link is written or read below FIL_PAGE_DATA.  This has
helped diagnose issue#63.
2008-08-18 06:56:52 +00:00
marko
7d69d45534 branches/zip: buf_LRU_free_block(): When buf_page_is_old(b), we incremented
buf_pool->LRU_old_len.  However, we forgot to check if buf_pool->LRU_old
happens to point to b's successor in the LRU list.  If it does, we must
assign buf_pool->LRU_old = b.  The following invariants hold:

In the LRU list, the "old" flag should grow monotonically, i.e., it is 0
for the first few items and 1 from thereafter.

If buf_pool->LRU_old != NULL, it must point to the first item with old=1
in the LRU list, and there must be buf_pool->LRU_old_len old items in the list.

This should fix Mantis issue#50 and issue#68.
2008-08-08 13:01:02 +00:00
vasil
9bbd5454db branches/zip:
The cardinality of every index (the number of different key values) is
calculated when the table is opened, at SHOW TABLE STATUS,
ANALYZE TABLE and on other circumstances (like when the table has
changed too much). Note that if the mysql client is running with the
auto-rehash setting turned on (default) this causes all tables to be
opened when it starts.

Previously InnoDB sampled 8 random pages from the index to get an
estimate of the cardinality. Now the number of sampled pages can be
changed via the global parameter innodb_stats_sample_pages which can
be tuned at runtime. The default value for this parameter is 8.

If the value of this parameter is changed, there may be serious problems:

- small values (say, 1) can cause an error in table stats;
- values much larger than 8 (say, 100), can cause a big slowdown in
  table opening time, SHOW TABLE status, etc.
- query plans may be different from the old ones.

Approved by:	Heikki
2008-08-07 13:47:44 +00:00
marko
9c0d868a8d branches/zip: Correct some typos in comments. 2008-08-06 12:45:35 +00:00
marko
9fb4f7ab7c branches/zip: Fix terminology that was introduced in r2569:
replace rbmode and "rollback mode"
with rb_ctx and "rollback context".
Suggested by Sunny.
2008-08-06 08:59:28 +00:00
marko
ba78ee0d47 branches/zip: In the rollback of incomplete transactions after crash
recovery, tolerate clustered index records whose externally stored
columns have not been written.  This should remove the assertion failures
that were reported as Mantis issue#58, issue#62, issue#64.

trx_is_recv(): New function: TRUE if this transaction is rolling back
an incomplete transaction in crash recovery.

enum trx_rbmode: Rollback modes: no rollback, normal rollback, crash recovery.

btr_cur_pessimistic_delete(), btr_free_externally_stored_field(),
btr_rec_free_externally_stored_fields():
Replace the ibool parameter with enum trx_rbmode.

btr_free_externally_stored_field(): If field_ref is zero, return
but assert ut_a(rbmode == RB_RECOVERY).  Unless InnoDB has crashed
while inserting a clustered index record, field_ref should not be zero.

btr_rec_free_updated_extern_fields(): Add the parameter enum trx_rbmode.

btr_cur_pessimistic_update(): Pass the rbmode parameter to
btr_rec_free_updated_extern_fields().

row_undo_ins(), row_undo_mod_upd_del_sec(): If row_build_index_entry()
fails, assert trx_is_recv() and skip this secondary index.

row_undo_mod_upd_del_sec(): Empty the heap at the end of each loop
iteration in order to conserve memory and to reduce the number of
low-level memory allocations.
2008-08-06 08:48:34 +00:00