Commit graph

563 commits

Author SHA1 Message Date
vasil
2ee633f8eb Revert r1850 as MySQL did not approve the addition.
log for r1850:

Implement this feature request:
http://bugs.mysql.com/30706

* Add a function that returns the number of microseconds since
  epoch - ut_time_us().

* Add (innodb|innobase|srv)_replication_delay MySQL config parameter.

* Add UT_WAIT_FOR() macro that waits for a specified condition to occur
  until a timeout elapses.

* Using all of the above, handle the replication thread specially in
  srv_conc_enter_innodb().
2007-09-20 14:37:03 +00:00
vasil
6a0f6df938 Add ut_snprintf() function. On Windows this needs to be implemented
using auxiliary functions because there is no snprintf-variant on
Windows that behaves exactly as specified in the standard:

* Always return the number of characters that would have been printed
  if the size were unlimited (not including the final `\0').
* Always '\0'-terminate the result
* Do not touch the buffer if size=0, only return the number of characters
  that would have been printed. Can be used to estimate the size needed
  and to allocate it dynamically.

See http://www.freebsd.org/cgi/query-pr.cgi?pr=87260 for the reason why
2 ap variables are used.

Approved by:	Heikki
2007-09-19 17:13:46 +00:00
vasil
8785af49a3 Implement this feature request:
http://bugs.mysql.com/30706

* Add a function that returns the number of microseconds since
  epoch - ut_time_us().

* Add (innodb|innobase|srv)_replication_delay MySQL config parameter.

* Add UT_WAIT_FOR() macro that waits for a specified condition to occur
  until a timeout elapses.

* Using all of the above, handle the replication thread specially in
  srv_conc_enter_innodb().

Approved by:	Heikki
2007-09-17 18:15:44 +00:00
vasil
ac6d4693c0 Add config option innodb_use_adaptive_hash_indexes to enable/disable
adaptive hash indexes. It is enabled by default (no change in default
behavior).

Approved by:	Marko
2007-09-14 08:19:48 +00:00
marko
fb246c3d88 Remove the prototypes of some functions inside #if 0.
The function definitions were removed in r1746.
2007-09-13 09:08:58 +00:00
sunny
58cc12cea5 Add test for Bug# 21409, the actual bug was fixed in r1334. 2007-09-12 23:24:49 +00:00
sunny
18e0aaa3a4 Add /*== ... === */ decoration that was missing around some auto-inc functions.
Add a missing comment, fix the length of a decoration.  Initialize the *value
out parameter in ha_innobase::innobase_get_auto_increment().
2007-09-10 20:26:01 +00:00
marko
10ca4727a8 Improve memory debugging. This is follow-up to r1819.
mem_heap_validate(): Compile this function also if UNIV_MEM_DEBUG is
defined.  Previously, this function was only compiled with UNIV_DEBUG.

mem_heap_free_heap_top(): Flag the memory allocated, not freed, for
Valgrind.  Otherwise, Valgrind would complain on the second call of
mem_heap_empty().

UNIV_MEM_ASSERT_RW(), UNIV_MEM_ASSERT_W(): Display additional diagnostics
for failed Valgrind checks.
2007-09-10 08:44:51 +00:00
sunny
4678dfac36 Add assertion to enforce check of an implicit invariant and add comment about
retry of autoinc read semantics. We always reread the table's autoinc counter
after attempting to initialize it i.e., we want to guarantee that a read of
autoinc valus that is returned to the caller is always covered by the
AUTOINC locking mechanism.
2007-09-09 22:41:42 +00:00
sunny
73fd262210 Fix two bugs:
Bug# 30907: We don't rely on *first_value to be 0 when checking whether
get_auto_increment() has been invoked for the first time in a multi-row
INSERT. We instead use trx_t::n_autoinc_rows. Initialize trx::n_autoinc_rows
inside ha_innobase::start_stmt() too.

Bug# 30888: While adding code for the low level read of the AUTOINC value
from the index, the case for MEDIUM ints which are 3 bytes was missed
triggering an assertion.
2007-09-08 20:40:10 +00:00
marko
023cc0a24f Merge r1826 from branches/zip: UNIV_MEM_ASSERT_AND_FREE():
Use UNIV_MEM_ASSERT_W() instead of UNIV_MEM_ASSERT_RW().
The memory area need not be initialized.
This mistake was made in r1815.
2007-09-07 12:41:42 +00:00
sunny
02d91af9e7 Merge a change from MySQL AB:
ChangeSet@1.2536.50.1  2007-08-02 12:45:56-07:00  igor@mysql.com

Fixed bug#28404.
This patch adds cost estimation for the queries with ORDER BY / GROUP BY
and LIMIT.
If there was a ref/range access to the table whose rows were required
to be ordered in the result set the optimizer always employed this access
though a scan by a different index that was compatible with the required
order could be cheaper to produce the first L rows of the result set.
Now for such queries the optimizer makes a choice between the cheapest
ref/range accesses not compatible with the given order and index scans
compatible with it.

innodb.result: Adjusted results for test cases affected fy the fix for
bug #28404.
2007-09-07 00:04:10 +00:00
sunny
aaf0c55719 Use the clustered index and not the one selected by the optimizer in the plan,
when building a previous version of the row. This bug is triggered when
running queries via InnoDB's internal SQL parser; when InnoDB's optimizer
selects a secondary index for the plan.
2007-09-06 23:50:26 +00:00
marko
d71dd22e97 Merge r1815:1817 from branches/zip: Improve Valgrind instrumentation.
UNIV_MEM_ASSERT_RW(): New macro, to check that the contents of a memory
area is defined.

UNIV_MEM_ASSERT_W(): New macro, to check that a memory area is writable.

UNIV_MEM_ASSERT_AND_FREE(): New macro, to check that the memory is
writable before declaring it free (unwritable).  This replaces UNIV_MEM_FREE()
in many places.

mem_init_buf(): Check that the memory is writable, and declare it undefined.

mem_erase_buf(): Check that the memory is writable, and declare it freed.
2007-09-06 12:46:50 +00:00
marko
520d554ba5 ha_innobase::external_lock(): Update prebuilt->mysql_has_locked and
trx->n_mysql_tables_in_use only after row_lock_table_for_mysql()
returns DB_SUCCESS.  A timeout on LOCK TABLES would lead to an
inconsistent state, which would cause trx_free() to print a warning.

This was later reported as Bug #31444.
2007-09-05 13:02:36 +00:00
marko
e29b7172b7 innodb.result: Revert r1655, which should have been reverted as part of r1781. 2007-09-03 08:32:32 +00:00
marko
853458d486 row_drop_table_for_mysql(): Before calling
dict_table_remove_from_cache(table) and thus freeing the memory
allocated for the table, copy the table name.  This avoids reading
freed memory when name == table->name.

Approved by Sunny.
2007-09-01 17:52:03 +00:00
marko
d9288383a9 ut_print_namel(): Do not assume that all '/' are separators between
database and table names.

Approved by Heikki.
2007-09-01 17:28:31 +00:00
marko
b1663422e2 Move the prototype of innobase_print_identifier() from ut0ut.c to
ha_prototypes.h.  Enclose the definitions in ha_prototypes.h in
#ifndef UNIV_HOTBACKUP.
2007-08-31 06:39:46 +00:00
marko
a8ef257d9c row_create_table_for_mysql(), row_truncate_table_for_mysql(),
row_drop_table_for_mysql(): Do not mention innodb_force_recovery
when newraw is set.
2007-08-30 14:27:47 +00:00
marko
a9ce592307 Merge a change from MySQL AB:
ChangeSet@1.2536.10.2  2007-07-25 10:44:45+02:00  jperkin@mysql.com

Fix for bug#29641 - $CC on Open Server is set to contain arguments
for enabling threads.  However, duplicate AC_PROG_* macros in the
innobase plug.in file were resetting $CC and causing link errors.

As AC_PROG_* macros are already used in the main configure.in file
there should be no need for them to be duplicated here too.

plug.in:

Remove AC_PROG_* macros
2007-08-30 12:28:23 +00:00
marko
fb7cec6380 Correct the function comments of row_create_table_for_mysql() and
row_drop_table_for_mysql().
2007-08-30 09:01:24 +00:00
sunny
055b323cb1 Add comment that the variable dest should be word aligned. After discussion
on IM with Heikki.
2007-08-30 08:08:04 +00:00
sunny
ff83c218a1 Fix a test case that was broken after Bug#16979 fix. See r1645 and r1735.
The variable used in the tests below was introduced in r1735.
2007-08-30 07:06:27 +00:00
sunny
a3c2aa960e Fix a bug that handles the case where the host specific byte order matches
the InnoDB storage byte order, which is big-endian.
2007-08-30 05:46:21 +00:00
marko
6eb200a476 Enclose rw_lock_validate() in #ifdef UNIV_DEBUG. It is only called by
debug assertions.
2007-08-23 09:24:38 +00:00
marko
20d531455d rw_lock_s_lock_func(): Correct a typo in a comment. 2007-08-23 06:39:41 +00:00
sunny
028c933bb8 We check whether the AUTOINC sub-system has been initialized (first) by
holding the AUTOINC mutex and if initialization is required then we
initialize using our normal procedure. This change is related to Bug#27950.
2007-08-23 03:40:42 +00:00
sunny
d1d15b3e1e Add a table level counter that tracks the number of AUTOINC locks that are
pending and/or granted on a table. We peek at this value to determine whether
a transaction doing a simple INSERT in innodb_autoinc_lock_mode = 1, needs to
acquire the AUTOINC lock or not. This change is related to Bug# 16979.
2007-08-23 03:37:37 +00:00
marko
43194eba00 Correct an outdated comment about dict_table_t:col_names that should have
been adjusted in r1719, or r1264 in branches/zip.
2007-08-22 18:28:26 +00:00
marko
4ca60264a7 Remove some code from ha_innodb.cc that was already enclosed in #if 0.
The code was related to replication and group commit, and it was
unreachable already as of MySQL 5.0.

Approved by Heikki
2007-08-22 11:36:55 +00:00
marko
26ce6c65e5 Merge r1739 from branches/zip:
mem_heap_free_heap_top(): Declare the memory freed with UNIV_MEM_FREE().
Before this change, the memory freed by mem_heap_empty() was not completely
flagged free in UNIV_DEBUG_VALGRIND builds.  After this change, Valgrind
will hopefully catch all errors caught by UNIV_MEM_DEBUG.
2007-08-22 08:19:06 +00:00
marko
af29e7690b trx_sys_print_mysql_binlog_offset_from_page(): Enclose the definition
in #ifdef UNIV_HOTBACKUP, to match the function declaration.
2007-08-22 06:50:16 +00:00
marko
d26d6a9d0a Remove some unused fields of trx_t: mysql_master_log_file_name,
mysql_master_log_pos, repl_wait_binlog_name, repl_wait_binlog_pos.

Approved by Heikki.
2007-08-22 06:49:07 +00:00
sunny
2a9014d545 Add variable "innodb_autoinc_lock_mode" to control the behavior of the
AUTOINC locking. There are three modes, 0 for backward compatibility, 1 for the
new style locking (default, safe for statement-based replication) and
2 for no AUTOINC locking (unsafe for statement-based replication).
2007-08-20 21:48:16 +00:00
marko
487677d01b Merge r1264 from branches/zip: Avoid memory fragmentation when
adding column definitions to tables.

dict_mem_table_add_col(): Add the parameter "heap" for temporary memory
allocation.  Allow it and "name" to be NULL.  These parameters are NULL
when creating dummy indexes.

dict_add_col_name(): Remove calls to ut_malloc() and ut_free().

dict_table_get_col_name(): Allow table->col_names to be NULL.

dict_table_add_system_columns(), dict_table_add_to_cache():
Add the parameter "heap".
---
Additional changes that had to be merged from branches/zip:

dict_table_add_system_columns(): New function, factored out from
dict_table_add_to_cache().

mlog_parse_index(): Add some consistency checks, and make use of
dict_table_add_system_columns().
2007-08-15 12:41:46 +00:00
marko
f3a8c1a641 Replace mysql_byte with uchar and remove the #define mysql_byte from
ha_innodb.cc.  This cleanup was made possible as of r1550:

Merge changes from MySQL AB:

ChangeSet@2007-05-10 12:59:39+03:00, monty@mysql.com 
  WL#3817: Simplify string / memory area types and make things more consistent
  (first part)
  
  The following type conversions was done:
  
  - Changed byte to uchar
...
2007-08-15 12:29:46 +00:00
marko
5e267bd9fd ibuf0ibuf.c: Remove the unused prototype for dict_index_print_low()
that was inadvertently added in r832.
2007-08-15 06:06:52 +00:00
vasil
4df8f3bbd9 Fix typo in comment. 2007-08-14 08:32:12 +00:00
marko
b44eab8eea lock_number_of_rows_locked(): Fix a typo in comment, and make the comments
in lock0lock.c and lock0lock.h identical.  The typo was incorrectly fixed in
r1623.
2007-08-01 10:35:06 +00:00
marko
1646ac7555 check_trx_exists(): Remove a redundant function call and assignment that
was added by someone at MySQL.
2007-07-31 18:46:55 +00:00
marko
f51a14a1ab recv_init_crash_recovery(): remove trailing white space 2007-07-31 07:55:06 +00:00
marko
645f111017 Merge a change from MySQL AB:
ChangeSet@1.1810.3176.1  2007-07-20 14:17:15+03:00  gkodinov@magare.gmz

Bug #29644: alter table hangs if records locked in share mode 
by long running transaction

On Windows opened files can't be deleted. There was a special
upgraded lock mode (TL_WRITE instead of TL_WRITE_ALLOW_READ) 
in ALTER TABLE to make sure nobody has the table opened
when deleting the old table in ALTER TABLE. This special mode
was causing ALTER TABLE to hang waiting on a lock inside InnoDB.
This special lock is no longer necessary as the server is 
closing the tables it needs to delete in ALTER TABLE.
Fixed by removing the special lock.
Note that this also reverses the fix for bug 17264 that deals with
another consequence of this special lock mode being used.

ha_innodb.cc@1.202.46.1  2007-07-20 14:17:14+03:00  gkodinov@magare.gmz

Bug #29644: reverse the (now excessive) fix
for bug 17264 (but leave the test case).
2007-07-31 06:45:39 +00:00
marko
31ed35c017 Fix the innodb.test failure mentioned in r1654. 2007-07-31 06:24:44 +00:00
marko
e4d8de77af Merge changes from MySQL AB, as of the following changeset:
ChangeSet@1.2567, 2007-07-27 14:44:31+05:00, svoj@june.mysql.com +3 -0
  Merge mysql.com:/home/svoj/devel/mysql/BUG29957/mysql-5.0-engines
  into  mysql.com:/home/svoj/devel/mysql/BUG29957/mysql-5.1-engines
  MERGE: 1.1810.2871.44

One test case in innodb.test fails because of auto-increment
changes in r1562:1653:

$diff innodb.result innodb.reject
504c504
< 3	test2		this will work
---
> 4	test2		this will work
2007-07-31 05:56:17 +00:00
marko
e711ed4fc0 lock_queue_iterator_get_prev(): Remove the unused local variable bit_no. 2007-07-30 18:51:59 +00:00
vasil
1a49f127c3 * Use START_REV instead of $(($1 + 1)) and END_REV instead of $2
* Use standard while-loop instead of the seq command
2007-07-24 06:45:26 +00:00
sunny
08a1857151 Fix for bug# 16979, this is a major change in InnoDB auto-inc handling. There
is one test that fails as of this commit. The updated test case should be
part of the snapshot from MySQL shortly.

Fix for bug# 27950 - Init AUTOINC from delete_row().

Fix for bug# 28781 - Use value specified by MySQL, in update_row().

Summary of structural changes:
==============================
InnoDB needs to hold a table level lock for AUTOINC allocations to overcome
the non-determinism inherent in MySQL SBR for INSERT ... SELECT. In this fix 
for simple INSERT statements (including multi-value inserts), we try and avoid
acquiring the special AUTOINC table level lock unless another transaction has
already reserved the AUTOINC table level lock, in which case we fall back
to the old behavior of acquiring the AUTOINC table level lock.

The max AUTOINC value is now read directly using the low level interface
of InnoDB.
2007-07-24 01:42:16 +00:00
vasil
c5025f7adc Introduce a lock queue iterator for easy (and opaque) traversing of lock
queues. Supports table and record lock queues via the same interface.

There is only "get previous" method because currently there is no need
for "get next" - it would be unused. Feel free to add one if needed.

Approved by:	Heikki
2007-07-17 15:08:04 +00:00
vasil
8e563df08b Convert date to an unambiguous format. 2007-07-17 13:58:16 +00:00