Commit graph

155 commits

Author SHA1 Message Date
vasil
ff9ef52294 branches/zip:
Change the format of TRX_IDs in INFORMATION_SCHEMA tables from DEC to
HEX.

The current TRX_IDs are hard to remember and track down: 426355, 428466,
428566, etc.

In HEX:
* there are less "digits", the strings are shorter;
* since there are 16 instead of 10 "digits", the chance of having
  repeating ones are smaller.

The above look like 68173, 689B2, 68A16 in HEX.

Discussed with:	Ken
Approved by:	Heikki (via IM)
2007-12-20 14:24:57 +00:00
marko
e3d19b0f76 branches/zip: Fast index creation: Lock the data dictionary only after
acquiring the table lock.  The data dictionary should not be locked for
long periods.  Before this change, in the worst case, the dictionary
would be locked until the expiration of innodb_lock_wait_timeout.

Virtually, transaction-level locks (locks on database objects, such
as records and tables) have a latching order level of SYNC_USER_TRX_LOCK,
which is above any InnoDB rw-locks or mutexes.  However, the latching
order of SYNC_USER_TRX_LOCK is never checked, not even by UNIV_SYNC_DEBUG.

ha_innobase::add_index(), ha_innobase::final_drop_index(): Invoke
row_mysql_lock_data_dictionary(trx) only after row_merge_lock_table().
2007-12-19 14:26:01 +00:00
vasil
204f29acd8 branches/zip:
Non-functional change:
Do not include the terminating '\0' in TRX_I_S_LOCK_ID_MAX_LEN.
2007-12-18 09:44:03 +00:00
marko
6690972b6c branches/zip: Fast index creation: Clarify why lock waits may occur in
row_merge_lock_table().

ha_innobase::final_drop_index(): Set the dictionary operation mode to
TRX_DICT_OP_INDEX_MAY_WAIT for the duration of the row_merge_lock_table()
call.
2007-12-17 23:00:55 +00:00
marko
d0d9299177 branches/zip: Fast index creation: Remove the ROW_PREBUILT_OBSOLETE nonsense.
Active transactions must not switch table or index definitions on the fly,
for several reasons, including the following:

 * copied indexes do not carry any history or locking information;
   that is, rollbacks, read views, and record locking would be broken

 * huge potential for race conditions, inconsistent reads and writes,
   loss of data, and corruption

Instead of trying to track down if the table was changed during a transaction,
acquire appropriate locks that protect the creation and dropping of indexes.

innodb-index.test: Test the locking of CREATE INDEX and DROP INDEX.  Test
that consistent reads work across dropped indexes.

lock_rec_insert_check_and_lock(): Relax the lock_table_has() assertion.
When inserting a record into an index, the table must be at least IX-locked.
However, when an index is being created, an IS-lock on the table is
sufficient.

row_merge_lock_table(): Add the parameter enum lock_mode mode, which must
be LOCK_X or LOCK_S.

row_merge_drop_table(): Assert that n_mysql_handles_opened == 0.
Unconditionally drop the table.

ha_innobase::add_index(): Acquire an X or S lock on the table, as appropriate.
After acquiring an X lock, assert that n_mysql_handles_opened == 1.
Remove the comments about dropping tables in the background.

ha_innobase::final_drop_index(): Acquire an X lock on the table.

dict_table_t: Remove version_number, to_be_dropped, and prebuilts.
ins_node_t: Remove table_version_number.

enum lock_mode: Move the definition from lock0lock.h to lock0types.h.

ROW_PREBUILT_OBSOLETE, row_update_prebuilt(), row_prebuilt_table_obsolete():
Remove.

row_prebuilt_t: Remove the declaration from row0types.h.

row_drop_table_for_mysql_no_commit(): Always print a warning if a table
was added to the background drop queue.
2007-12-17 15:49:59 +00:00
marko
ca75e7797d branches/zip: innobase_mysql_end_print_arbitrary_thd(): Note that
kernel_mutex must be released before calling this function.

innobase_mysql_end_print_arbitrary_thd(),
innobase_mysql_prepare_print_arbitrary_thd(): Assert that the
kernel_mutex is not being held by the current thread.
2007-12-17 14:06:59 +00:00
vasil
0845bd2d23 branches/zip:
Non-functional change:
 
Move the prototypes of
innobase_mysql_prepare_print_arbitrary_thd() and
innobase_mysql_end_print_arbitrary_thd() from lock0lock.c to
ha_prototypes.h

Suggested by:	Marko
Approved by:	Marko
2007-12-16 16:13:53 +00:00
marko
690566c36a branches/zip: Merge 2116:2146 from trunk. 2007-11-30 12:30:21 +00:00
vasil
a3417d902d branches/zip:
* Change terminology:
  wait lock -> requested lock
  waited lock -> blocking lock
  new: requesting transaction (the trx what owns the requested lock)
  new: blocking transaction (the trx that owns the blocking lock)

* Add transaction ids to INFORMATION_SCHEMA.INNODB_LOCK_WAITS. This is
  somewhat redundant because transaction ids can be found in INNODB_LOCKS
  (which can be joined with INNODB_LOCK_WAITS) but would help users to
  write shorter joins (one table less) in some cases where they want to
  find which transaction is blocking which.

Suggested by:	Ken
Approved by:	Heikki
2007-11-29 13:47:09 +00:00
marko
d5c04aae8e branches/zip: ha_innobase::final_drop_index(): Allocate a separate transaction
for dropping the index trees, and set the dictionary operation flag, similar
to what ha_innobase::add_index() does.  This should ensure correct crash
recovery.
2007-11-29 10:34:55 +00:00
vasil
69a8cc07a9 branches/zip:
Add the transaction's weight to information_schema.innodb_trx table.

Suggested by:	Ken
Approved by:	Heikki
2007-11-28 07:07:23 +00:00
vasil
860bc11276 branches/zip:
Fix the size of the static buffer for lock_table and lock_index.
I was not realizing that NAME_LEN contains the mbmaxlen multiplier and thus
a quote, when converted to 2 quotes, will take 2 bytes while there are 3
bytes reserved.

Spotted by:	Marko
Pointyhat to:	Vasil
2007-11-21 17:15:27 +00:00
vasil
193d01e327 branches/zip:
Add C test for innobase_convert_name() in addition to the mysql-test one.
2007-11-21 17:02:46 +00:00
vasil
28383dde67 branches/zip:
Fix a bug where the static buffer for innodb_locks.lock_table may not
have enough space.

Pointyhat to:	Marko
2007-11-21 12:11:04 +00:00
vasil
84979e4341 branches/zip:
Bugfix1: Set innodb_locks.lock_index to NOT NULL.
If a column in INFORMATION_SCHEMA table has the flag
MY_I_S_MAYBE_NULL and it is not explicitly marked as NOT NULL
with the method ::set_notnull() then it is always rendered as
NULL by MySQL.

Bugfix2: Avoid crashes if lock_index is NULL. It is NULL for table
level locks.

Pointyhat to:	Marko
2007-11-21 12:01:36 +00:00
vasil
f268295c2b branches/zip:
Non-functional change:
Fix consistency of the sizeof() operator with the rest of i_s.cc

Pointyhat to:	Marko
2007-11-21 11:44:36 +00:00
marko
afccd4afd2 branches/zip: INFORMATION_SCHEMA.INNODB_LOCKS: Quote lock_table, lock_index.
innodb_information_schema.test. Add tests that display most columns from
INFORMATION_SCHEMA.INNODB_LOCKS.  Test that quoting of table names works
and respects SQL_MODE='ANSI_QUOTES'.

innobase_print_identifier(): Remove.

innobase_convert_identifier(): New function,
based on innobase_print_identifier().

innobase_convert_name(): New function, similar to ut_print_namel(), but
using a memory buffer.

ut_print_namel(): Use innobase_convert_name().

fill_innodb_locks_from_cache(): Convert lock_table and lock_index by
calling innobase_convert_name().
2007-11-21 08:46:11 +00:00
vasil
bda6490d67 branches/zip:
Convert INFORMATION_SCHEMA tables' names to upper case so that they are
consistent with other INFORMATION_SCHEMA tables.

 mysql> show tables;
 +---------------------------------------+
 | Tables_in_information_schema          |
 +---------------------------------------+
 | CHARACTER_SETS                        | 
 | COLLATIONS                            | 
 | COLLATION_CHARACTER_SET_APPLICABILITY | 
 | COLUMNS                               | 
 | COLUMN_PRIVILEGES                     | 
 | ENGINES                               | 
 | EVENTS                                | 
 | FILES                                 | 
 | GLOBAL_STATUS                         | 
 | GLOBAL_VARIABLES                      | 
 | KEY_COLUMN_USAGE                      | 
 | PARTITIONS                            | 
 | PLUGINS                               | 
 | PROCESSLIST                           | 
 | REFERENTIAL_CONSTRAINTS               | 
 | ROUTINES                              | 
 | SCHEMATA                              | 
 | SCHEMA_PRIVILEGES                     | 
 | SESSION_STATUS                        | 
 | SESSION_VARIABLES                     | 
 | STATISTICS                            | 
 | TABLES                                | 
 | TABLE_CONSTRAINTS                     | 
 | TABLE_PRIVILEGES                      | 
 | TRIGGERS                              | 
 | USER_PRIVILEGES                       | 
 | VIEWS                                 | 
 | innodb_zip_reset                      | 
 | innodb_trx                            | 
 | innodb_locks                          | 
 | innodb_lock_waits                     | 
 | innodb_zip                            | 
 +---------------------------------------+
2007-11-21 07:38:56 +00:00
marko
a7344bc8e1 branches/zip: Merge 2015:2093 from trunk. 2007-11-16 13:57:27 +00:00
vasil
f72d0e66d8 branches/zip:
Implement a limit on the memory used by the INNODB_TRX, INNODB_LOCKS and
INNODB_LOCK_WAITS tables. The maximum allowed memory is defined with the
macro TRX_I_S_MEM_LIMIT.

Approved by:	Marko (via IM)
2007-11-16 13:12:13 +00:00
vasil
bae2063ac0 branches/zip:
Add the query in information_schema.innodb_trx.trx_query. Add it even
though it is available in information_schema.processlist.info to make
inconsistencies between those two tables obvious.

It is rather confusting to see a transaction shown in innodb_trx and
innodb_locks that holds a lock on one table and the corresponding query
in processlist executing INSERT on another table. We do not want users
to contact us asking to explain that. It is caused by the fact that the
data for innodb_* tables and processlist is fetched at different time.

Approved by:	Marko
2007-11-07 20:38:07 +00:00
vasil
83f470987f branches/zip:
Introduce a generic soultion to the common problem that MySQL do not add
functions needed by us in a reasonable time.

Start with a function that retrieves THD::thread_id, this is needed for
the information_schema.innodb_trx.mysql_thread_id column.

Approved by:	Marko
2007-11-07 14:14:33 +00:00
marko
fe48c3662a branches/zip: Return a meaningful error message when refusing to create
a compressed table in the system tablespace.

db0err.h: Introduce the error code DB_TABLE_ZIP_NO_IBD.  Replace the
#define directives with an enum, to ease future code merges.  These
error codes are never written out to files or displayed to the user.
Thus they need not remain constant.

dict_build_table_def_step(): Return DB_TABLE_ZIP_NO_IBD instead of DB_ERROR.

create_table_def(): Report ER_ILLEGAL_HA_CREATE_OPTION "KEY_BLOCK_SIZE"
when the table creation fails with DB_TABLE_ZIP_NO_IBD.
2007-11-07 11:03:13 +00:00
marko
789165e2c7 branches/zip: Deny non-superuser access to the INFORMATION_SCHEMA
tables INNODB_ZIP and INNODB_ZIP_RESET.
2007-11-07 08:44:07 +00:00
vasil
c48c0f89bb branches/zip:
Deny access to TRX INFORMATION_SCHEMA tables to non-superusers.

Approved by:	Marko
2007-11-05 14:17:07 +00:00
marko
17fc32fb51 branches/zip: Allow the symbols in the dynamic InnoDB plugin to be
redefined so that the dynamic plugin can replace the builtin InnoDB
in MySQL 5.1.

ha_innodb.cc, handler0alter.cc: #include "univ.i" before any other InnoDB
header files or before defining any symbols

innodb_redefine.h: New file, to contain a mapping of symbols.  The idea
is that this file will be replaced in the build process; because this
is a large file that can be generated automatically, it does not make sense
to keep it under version control.

univ.i: #include "innodb_redefine.h" and #define ha_innobase ha_innodb

Makefile.am (ha_innodb_la_CXXFLAGS): Remove -Dha_innobase=ha_innodb

NOTE: there are still some issues in the source code.  One known issue is
the #undef mutex_free in sync0sync.h, which will cause the plugin to call the
function mutex_free in the builtin InnoDB.  The preprocessor symbols defined
in innodb_redefine.h must not be undefined or redefined anywhere in the code.
2007-11-01 15:00:44 +00:00
marko
3037cca095 branches/zip: Remove the parameter innodb_dynamic, and always call the
plugin "InnoDB", not "InnoDBzip".

We can disable the builtin InnoDB by mysqld --skip-innodb.  If the
builtin InnoDB is not disabled, installing the InnoDB plugin by the same
name will not work.

innodb_plugin_init(): Ignore differences in the PLUGIN_VAR_READONLY flag.
2007-11-01 13:25:48 +00:00
marko
2dbf0fdacb branches/zip: Remove warnings for BUILD/compile-... --warning-mode=pedantic.
ha_innobase::write_row(): The printf format %p expects const void*.

STRUCT_FLD: Do not use the GCC extension when __STRICT_ANSI__ is defined.

row_merge_read_clustered_index(): Compound initializers must not contain
variables.  Assign to struct fields instead.
2007-11-01 11:44:49 +00:00
vasil
e8de094a3f branches/zip:
Add innodb_locks.lock_data column and some relevant tests.
For record locks this column represents the ordering fields of the
locked row in a human readable, SQL-valid, format.

Approved by:	Marko
2007-10-29 13:03:53 +00:00
vasil
976c562f81 branches/zip:
Make lock_get_type_str() to also indicate if it is a gap lock.
 
Suggested by:	Heikki
Approved by:	Marko
2007-10-25 11:21:11 +00:00
marko
c661970d75 branches/zip: Merge 1937:2015 from trunk. 2007-10-24 10:59:54 +00:00
marko
8bed4c4c3f branches/zip: Do not access the fields of dfield_t directly.
dfield_dup(): New function for duplicating the data pointed to by dfield_t.

dfield_set_len(), dfield_set_data(): Add Valgrind instrumentation.
2007-10-23 06:46:12 +00:00
marko
1561b414e1 branches/zip: Introduce two new dictionary operation modes for transactions.
enum trx_dict_op: dictionary operation modes

trx_get_dict_operation(), trx_set_dict_operation(): Accessors for
trx->dict_operation.

lock_table_enqueue_waiting(), lock_rec_enqueue_waiting(): Do not complain
about lock waits if the dictionary mode is TRX_DICT_OP_INDEX_MAY_WAIT.

row_merge_lock_table(): Remove the work-around for avoiding the warning
in lock_table_enqueue_waiting().

trx_undo_mark_as_dict_operation(): Do not write trx->table_id to the
undo log unless the dict_operation is TRX_DICT_OP_TABLE.

ha_innobase::add_index(): Set the dict_operation mode initially to
TRX_DICT_OP_INDEX_MAY_WAIT, then lock the table exclusively, and set the
mode to TRX_DICT_OP_INDEX, and optionally to TRX_DICT_OP_TABLE when
creating a temporary table.
2007-10-19 10:52:25 +00:00
marko
99f97f8c1d branches/zip: ha_innobase::add_index(): Lock the table before creating
any indexes.  Before this fix, other transactions could see the empty indexes
before we acquired the table lock.
2007-10-18 12:46:14 +00:00
marko
7c68ba2e9d branches/zip: Allow a dynamically loaded InnoDB storage engine plugin
to replace a built-in instance of InnoDB in mysqld.  This is work in
progress, with several limitations:

* Other plugins defined in the builtin InnoDB are not disabled.
  However, InnoDB in MySQL 5.1 only defines the storage engine plugin,
  no INFORMATION_SCHEMA plugins.

* The global C symbols in ha_innodb.so except innodb_hton_ptr and
  builtin_innobase_plugin will have to be redefined, e.g., by objcopy.

* The storage engine cannot be called "InnoDB" to avoid a conflict with
  the builtin name.  Here we call it InnoDBzip.

innobase_hton_name[]: Rename to "InnoDBzip" when building a dynamic plugin.

innodb_plugin_init(): New function for the dynamic plugin, to copy
and redirect configuration parameters from the builtin InnoDB.

innodb_dynamic: New configuration parameter.  This has to be added
to the builtin InnoDB in MySQL 5.1.  Also, innodb_hton_ptr must be made
global there.

innobase_init(): Interpret the parameter innodb_dynamic.

Makefile.am: Redefine class ha_innobase to ha_innodb by a preprocessor
define.  Apparently, C++ classes cannot be easily renamed by objcopy.
2007-10-15 11:05:40 +00:00
vasil
9dbf703da8 branches/zip:
Non-functional change to improve readability.
2007-10-11 10:45:57 +00:00
marko
8e4c946d11 branches/zip: i_s.cc: Add missing #include "buf0buf.h" that should have
been added in r1943.  This is needed for building a noninlined version.
2007-10-05 10:59:34 +00:00
marko
1b166ea268 branches/zip: Add DBUG_ASSERT(hton == innodb_hton_ptr) to various functions. 2007-10-04 08:33:25 +00:00
marko
a298d8ba0a branches/zip: Move the implementation of the INFORMATION_SCHEMA tables
INNODB_ZIP and INNODB_ZIP_RESET from ha_innodb.cc to i_s.cc.

plugin_author, END_OF_ST_FIELD_INFO, i_s_info: New common constants.

trx_i_s_common_deinit(): Renamed to i_s_common_deinit().
2007-10-03 14:00:54 +00:00
marko
354a9fc077 branches/zip: Initialize also the newly added field open_method
in ST_FIELD_INFO.
2007-10-03 13:48:17 +00:00
marko
3b99f0d17c branches/zip: Fix some link errors.
ha_innobase::update_thd(void): New function, to call the inline function
ha_innobase::update_thd(THD*).

check_trx_exists(): Make static.  handler0alter.cc does not need to call
this function.
2007-09-28 10:44:20 +00:00
marko
c7e26ddf2e branches/zip: innobase_col_to_mysql(): Replace the undefined variable "templ"
with "col" in two debug assertions.  This mistake was made in r1910.
2007-09-27 18:16:39 +00:00
marko
23f80a6f54 branches/zip: Merge 1862:1894 from trunk, except 1866. 2007-09-27 11:17:45 +00:00
marko
20008e0e24 branches/zip: Correctly convert InnoDB records to MySQL table->record[0].
innobase_col_to_mysql(): New function, adapted from
row_sel_field_store_in_mysql_format().

innobase_rec_to_mysql(): Correct the function comment, which was still
saying "clustered index record", although we can convert any record.
Make use of innobase_col_to_mysql().  Always call field->reset(),
so that innobase_col_to_mysql() will not have to pad anything.
2007-09-27 11:03:36 +00:00
marko
8cfc17324e branches/zip: innobase_rec_to_mysql(): Allow "index" to be any index,
clustered or secondary.  Remove the rec_offs_validate() assertion, because
the function may be passed a mrec_t* that would fail the check.
2007-09-27 08:19:38 +00:00
marko
6b3579a87f branches/zip: Clean up some non-inlined functions.
dtuple_create_for_mysql(), dtuple_free_for_mysql(): Remove.

ha_innobase::records_in_range(): Use mem_heap_create(), mem_heap_free(),
and dtuple_create() instead of the removed functions above.  Since r1587,
InnoDB C++ functions can invoke inlined C functions.
2007-09-26 12:07:07 +00:00
marko
03a7cb220a branches/zip: Implement the reporting of duplicate key values to MySQL.
innobase_rec_to_mysql(): New function, for converting an InnoDB clustered
index record to MySQL table->record[0].  TODO: convert integer fields.
Currently, integer fields are in big-endian byte order instead of
host byte order, and signed integer fields are offset by 0x80000000.

innobase_rec_reset(): New function, for resetting table->record[0].

row_merge_build_indexes(): Add the parameter TABLE* table (the MySQL table
handle) for reporting duplicate key values.

dtuple_from_fields(): New function, to convert an array of dfield_t* to
dtuple_t.

dtuple_get_n_ext(): New function, to compute the number of externally stored
fields.

row_merge_dup_t: Structure for counting and reporting duplicate records.

row_merge_dup_report(): Function for counting and reporting duplicate records.

row_merge_tuple_cmp(), row_merge_tuple_sort(): Replace the ulint* n_dup
parameter with row_merge_dup_t* dup.

row_merge_buf_sort(): Add the parameter row_merge_dup_t* dup, which is
NULL when sorting a non-unique index.

row_merge_buf_write(), row_merge_heap_create(), row_merge_read_rec(),
row_merge_cmp(), row_merge_read_clustered_index(), row_merge_blocks(),
row_merge(), row_merge_sort(): Add const qualifiers.

row_merge_read_clustered_index(): Use a common error handling branch err_exit.
Invoke row_merge_buf_sort() differently on unique indexes.

row_merge_blocks(): note TODO: We could invoke innobase_rec_to_mysql()
to report duplicate key values when creating a clustered index.
2007-09-26 11:56:26 +00:00
vasil
b9982ac9ec Implement INFORMATION_SCHEMA tables innodb_trx, innodb_locks,
innodb_lock_waits. See
https://svn.innodb.com/innobase/InformationSchema/TransactionsAndLocks
for design notes.

Things that need to be resolved before this goes live:
* MySQL must add thd_get_thread_id() function to their code
  http://bugs.mysql.com/30930
* Allocate memory from mem_heap instead of using mem_alloc()
* Copy table name and index name into the cache because they may be
  freed later which will result in referencing freed memory

Approved by:	Marko
2007-09-20 11:23:44 +00:00
marko
f5e4a4c3ed branches/zip: Merge 1830:1862 from trunk. 2007-09-20 08:36:22 +00:00
marko
685f665b06 branches/zip: ha_innobase::add_index(): Translate DB_TOO_BIG_RECORD
via my_error().  Add a test case to innodb-index.test.
2007-09-17 10:43:51 +00:00