Commit graph

760 commits

Author SHA1 Message Date
anozdrin/alik@quad.
bdc83bf2cb Merge quad.:/mnt/raid/alik/MySQL/devel/5.1
into  quad.:/mnt/raid/alik/MySQL/devel/5.1-rt-merged
2008-02-26 19:34:02 +03:00
mkindahl@dl145h.mysql.com
a71f298f2a Merge dl145h.mysql.com:/data0/mkindahl/mysql-5.1
into  dl145h.mysql.com:/data0/mkindahl/mysql-5.1-rpl
2008-02-20 19:27:06 +01:00
kostja@dipika.(none)
72495c968b Rename send_eof() to my_eof() for consistency with my_ok() and my_error() 2008-02-19 15:58:08 +03:00
kostja@dipika.(none)
acf9b1f346 A fix and a test case for Bug#12713 "Error in a stored function called from
a SELECT doesn't cause ROLLBACK of statem".

The idea of the fix is to ensure that we always commit the current
statement at the end of dispatch_command(). In order to not issue
redundant disc syncs, an optimization of the two-phase commit
protocol is implemented to bypass the two phase commit if
the transaction is read-only.
2008-02-19 14:43:01 +03:00
kaa@kaamos.(none)
5647dee192 Merge kaamos.(none):/data/src/mysql-5.1
into  kaamos.(none):/data/src/opt/mysql-5.1-opt
2008-02-17 14:57:01 +03:00
mats@kindahl-laptop.dnsalias.net
89e2fe8c05 Bug #34458 Extreneous use of templates in server code
Patch to remove white-space left over after removing anonymous
namespace.
2008-02-15 13:06:28 +01:00
mats@kindahl-laptop.dnsalias.net
25dc9eb10b Bug #34458 Extreneous use of templates in server code
Replacing a template function with a normal static function.
The template parameter, which previously was the class to
find a binlogging function in, is now passed as a pointer to
the actual binlogging function instead.

The patch requires change of indention, but that is submitted
as a separate patch.
2008-02-15 12:56:44 +01:00
joerg@trift2.
51f81b0209 Merge trift2.:/MySQL/M51/clone-5.1
into  trift2.:/MySQL/M51/push-5.1
2008-02-13 13:40:53 +01:00
kaa@kaamos.(none)
9f194149b8 Merge kaamos.(none):/data/src/opt/mysql-5.0-opt
into  kaamos.(none):/data/src/opt/mysql-5.1-opt
2008-02-13 12:12:00 +03:00
jani@a88-113-38-195.elisa-laajakaista.fi
4f98f3e683 Merge a88-113-38-195.elisa-laajakaista.fi:/home/my/bk/mysql-5.1-main
into  a88-113-38-195.elisa-laajakaista.fi:/home/my/bk/mysql-5.1-marvel
2008-02-08 12:13:33 +01:00
sergefp@mysql.com
954a16c6d3 BUG#27732 "Possible memory leak with index_merge"
The bug was that handler::clone/handler::ha_open() call caused allocation of 
cloned_copy->ref on the handler->table->mem_root. The allocated memory could not 
be reclaimed until the table is flushed, so it was possible to exhaust memory by 
repeatedly running index_merge queries without doing table flushes.  

The fix:
- make handler::clone() allocate new_handler->ref on the passed mem_root 
- make handler::ha_open() not allocate this->ref if it has already been allocated
There is no testcase as it is not possible to check small leaks from testsuite.
2008-02-07 05:10:04 +03:00
tomas@whalegate.ndb.mysql.com
07fafa2b61 Merge whalegate.ndb.mysql.com:/home/tomas/mysql-5.1
into  whalegate.ndb.mysql.com:/home/tomas/mysql-5.1-new-ndb-merge
2008-01-30 16:08:25 +01:00
tsmith@ramayana.hindu.god
3906cc27d7 Merge ramayana.hindu.god:/home/tsmith/m/bk/51
into  ramayana.hindu.god:/home/tsmith/m/bk/maint/51
2008-01-25 10:37:29 -07:00
msvensson@pilot.mysql.com
ea0cecc5f0 Bug#33375 all_set corrupted on table object
- make sure to reset the read and write sets


handler.cc, log_event.cc:
  - make sure to reset the read and write sets
2008-01-15 17:01:58 +01:00
kostja@bodhi.(none)
dfe685e6fc A pre-requisite for the fix for Bug#12713 "Error in a stored function
called from a SELECT doesn't cause ROLLBACK of state"
Make private all class handler methods (PSEA API) that may modify
data. Introduce and deploy public ha_* wrappers for these methods in 
all sql/.
This necessary to keep track of all data modifications in sql/,
which is in turn necessary to be able to optimize two-phase
commit of those transactions that do not modify data.
2007-12-20 21:16:55 +03:00
tomas@whalegate.ndb.mysql.com
c9ecf31242 Bug #33375 all_set corrupted on table object
- make sure to reset the read and write sets
2007-12-19 18:42:49 +01:00
cmiller@zippy.cornsilk.net
c940d64a69 Merge bk-internal.mysql.com:/home/bk/mysql-5.1-maint
into  zippy.cornsilk.net:/home/cmiller/work/mysql/mysql-5.1-maint
2007-12-14 10:52:10 -05:00
jani@a88-113-38-195.elisa-laajakaista.fi
0d63a0d63f Merge a88-113-38-195.elisa-laajakaista.fi:/home/my/bk/mysql-5.1-main
into  a88-113-38-195.elisa-laajakaista.fi:/home/my/bk/mysql-5.1-marvel
2007-12-07 22:27:48 +02:00
gluh@mysql.com/eagle.(none)
f4c2eff997 Bug#30294 blackhole engine causes 100% with 2 alter table statements running
Implement neccessary shared lock structure for table locks.
This is the backport of bug26241 fix.
2007-11-16 14:46:36 +04:00
istruewing@stella.local
0605274155 Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
corrupts a MERGE table
Bug 26867 - LOCK TABLES + REPAIR + merge table result in
            memory/cpu hogging
Bug 26377 - Deadlock with MERGE and FLUSH TABLE
Bug 25038 - Waiting TRUNCATE
Bug 25700 - merge base tables get corrupted by
            optimize/analyze/repair table
Bug 30275 - Merge tables: flush tables or unlock tables
            causes server to crash
Bug 19627 - temporary merge table locking
Bug 27660 - Falcon: merge table possible
Bug 30273 - merge tables: Can't lock file (errno: 155)

The problems were:

Bug 26379 - Combination of FLUSH TABLE and REPAIR TABLE
                corrupts a MERGE table

  1. A thread trying to lock a MERGE table performs busy waiting while
     REPAIR TABLE or a similar table administration task is ongoing on
     one or more of its MyISAM tables.
  
  2. A thread trying to lock a MERGE table performs busy waiting until all
     threads that did REPAIR TABLE or similar table administration tasks
     on one or more of its MyISAM tables in LOCK TABLES segments do UNLOCK
     TABLES. The difference against problem #1 is that the busy waiting
     takes place *after* the administration task. It is terminated by
     UNLOCK TABLES only.
  
  3. Two FLUSH TABLES within a LOCK TABLES segment can invalidate the
     lock. This does *not* require a MERGE table. The first FLUSH TABLES
     can be replaced by any statement that requires other threads to
     reopen the table. In 5.0 and 5.1 a single FLUSH TABLES can provoke
     the problem.

Bug 26867 - LOCK TABLES + REPAIR + merge table result in
            memory/cpu hogging

  Trying DML on a MERGE table, which has a child locked and
  repaired by another thread, made an infinite loop in the server.

Bug 26377 - Deadlock with MERGE and FLUSH TABLE

  Locking a MERGE table and its children in parent-child order
  and flushing the child deadlocked the server.

Bug 25038 - Waiting TRUNCATE

  Truncating a MERGE child, while the MERGE table was in use,
  let the truncate fail instead of waiting for the table to
  become free.

Bug 25700 - merge base tables get corrupted by
            optimize/analyze/repair table

  Repairing a child of an open MERGE table corrupted the child.
  It was necessary to FLUSH the child first.

Bug 30275 - Merge tables: flush tables or unlock tables
            causes server to crash

  Flushing and optimizing locked MERGE children crashed the server.

Bug 19627 - temporary merge table locking

  Use of a temporary MERGE table with non-temporary children
  could corrupt the children.

  Temporary tables are never locked. So we do now prohibit
  non-temporary chidlren of a temporary MERGE table.

Bug 27660 - Falcon: merge table possible

  It was possible to create a MERGE table with non-MyISAM children.

Bug 30273 - merge tables: Can't lock file (errno: 155)

  This was a Windows-only bug. Table administration statements
  sometimes failed with "Can't lock file (errno: 155)".

These bugs are fixed by a new implementation of MERGE table open.

When opening a MERGE table in open_tables() we do now add the
child tables to the list of tables to be opened by open_tables()
(the "query_list"). The children are not opened in the handler at
this stage.

After opening the parent, open_tables() opens each child from the
now extended query_list. When the last child is opened, we remove
the children from the query_list again and attach the children to
the parent. This behaves similar to the old open. However it does
not open the MyISAM tables directly, but grabs them from the already
open children.

When closing a MERGE table in close_thread_table() we detach the
children only. Closing of the children is done implicitly because
they are in thd->open_tables.

For more detail see the comment at the top of ha_myisammrg.cc.

Changed from open_ltable() to open_and_lock_tables() in all places
that can be relevant for MERGE tables. The latter can handle tables
added to the list on the fly. When open_ltable() was used in a loop
over a list of tables, the list must be temporarily terminated
after every table for open_and_lock_tables().
table_list->required_type is set to FRMTYPE_TABLE to avoid open of
special tables. Handling of derived tables is suppressed.
These details are handled by the new function
open_n_lock_single_table(), which has nearly the same signature as
open_ltable() and can replace it in most cases.

In reopen_tables() some of the tables open by a thread can be
closed and reopened. When a MERGE child is affected, the parent
must be closed and reopened too. Closing of the parent is forced
before the first child is closed. Reopen happens in the order of
thd->open_tables. MERGE parents do not attach their children
automatically at open. This is done after all tables are reopened.
So all children are open when attaching them.

Special lock handling like mysql_lock_abort() or mysql_lock_remove()
needs to be suppressed for MERGE children or forwarded to the parent.
This depends on the situation. In loops over all open tables one
suppresses child lock handling. When a single table is touched,
forwarding is done.

Behavioral changes:
===================

This patch changes the behavior of temporary MERGE tables.
Temporary MERGE must have temporary children.
The old behavior was wrong. A temporary table is not locked. Hence
even non-temporary children were not locked. See
Bug 19627 - temporary merge table locking.

You cannot change the union list of a non-temporary MERGE table
when LOCK TABLES is in effect. The following does *not* work:
CREATE TABLE m1 ... ENGINE=MRG_MYISAM ...;
LOCK TABLES t1 WRITE, t2 WRITE, m1 WRITE;
ALTER TABLE m1 ... UNION=(t1,t2) ...;
However, you can do this with a temporary MERGE table.

You cannot create a MERGE table with CREATE ... SELECT, neither
as a temporary MERGE table, nor as a non-temporary MERGE table.
CREATE TABLE m1 ... ENGINE=MRG_MYISAM ... SELECT ...;
Gives error message: table is not BASE TABLE.
2007-11-15 20:25:43 +01:00
jani@hynda.mysql.fi
88bcde7661 Merge hynda.mysql.fi:/home/my/mysql-5.1-main
into  hynda.mysql.fi:/home/my/mysql-5.1-marvel
2007-11-14 16:32:03 +02:00
mattiasj@mattiasj-laptop.(none)
32d7dd8679 Merge mattiasj-laptop.(none):/home/mattiasj/clones/mysql-5.1-main
into  mattiasj-laptop.(none):/home/mattiasj/clones/mysql-5.1-last_with_main
2007-11-12 21:09:48 +01:00
istruewing@stella.local
ceb444fa09 Merge bk-internal.mysql.com:/home/bk/mysql-5.1-engines
into  stella.local:/home2/mydev/mysql-5.1-bug22351
2007-11-09 09:19:27 +01:00
jani@hynda.mysql.fi
e8d8102a93 Merge hynda.mysql.fi:/home/my/mysql-5.1-main
into  hynda.mysql.fi:/home/my/mysql-5.1-marvel
2007-11-08 13:23:08 +02:00
istruewing@stella.local
9de5a2424f Bug#22351 - handler::index_next_same() call to key_cmp_if_same() uses
the wrong buffer

handler::index_next_same() did not take into account that the
internally called function key_cmp_if_same() uses the fixed
buffer table->record[0] for key comparison instead of the
buffer provided by the caller of handler::index_next_same().

Added code to temporarily redirect table->record[0] and the fields
used for the key to the record buffer provided by the caller of
handler::index_next_same().

The test case is in partition.test already.
2007-11-07 09:30:41 +01:00
malff@lambda.hsd1.co.comcast.net.
f0f63f8ff9 Merge lambda.hsd1.co.comcast.net.:/home/malff/TREE/mysql-5.1-base
into  lambda.hsd1.co.comcast.net.:/home/malff/TREE/mysql-5.1-rt-merge
2007-11-05 10:20:20 -07:00
kostja@bodhi.(none)
230604f33c In ha_delete_table, use a standard mechanism to intercept the error message
and convert it to a warning instead of direct manipulation with the
thread error stack.
Fix a bug in handler::print_erorr when a garbled message was
printed for HA_ERR_NO_SUCH_TABLE.
This is a pre-requisite patch for the fix for Bug#12713 Error in a stored
function called from a SELECT doesn't cause ROLLBACK of statem
2007-10-30 22:35:14 +03:00
tomas@whalegate.ndb.mysql.com
a214b1b9ba Merge whalegate.ndb.mysql.com:/home/tomas/cge-5.1
into  whalegate.ndb.mysql.com:/home/tomas/mysql-5.1-new-ndb-merge
2007-10-30 11:28:19 +01:00
malff@lambda.weblab
0909d1f8cb Merge lambda.weblab:/home/malff/TREE/mysql-5.1-base
into  lambda.weblab:/home/malff/TREE/mysql-5.1-rt-merge
2007-10-29 08:07:27 -06:00
kostja@bodhi.(none)
7c00f8a3b4 Rename: query_error -> is_slave_error.
Add comments.
2007-10-20 01:20:38 +04:00
cmiller@zippy.cornsilk.net
91b5c11922 Doxygenization of comments. 2007-10-11 13:29:09 -04:00
monty@mysql.com/narttu.mysql.fi
7887babe69 Moved a lot of old bug fixes and safe cleanups from Maria 5.1 tree to 5.1
- Reserver namespace and place in frm for TABLE_CHECKSUM and PAGE_CHECKSUM create options
- Added syncing of directory when creating .frm files
- Portability fixes
- Added missing cast that could cause bugs
- Code cleanups
- Made some bit functions inline
- Moved things out of myisam.h to my_handler.h to make them more accessable
- Renamed some myisam variables and defines to make them more globaly usable (as they are used outside of MyISAM)
- Fixed bugs in error conditions
- Use compiler time asserts instead of run time
- Fixed indentation
HA_EXTRA_PREPARE_FOR_DELETE -> HA_EXTRA_PREPARE_FOR_DROP as the old name was wrong
(Added a define for old value to ensure we don't break any old code)
Added HA_EXTRA_PREPARE_FOR_RENAME as a signal for rename (before we used a DROP signal which is wrong)
- Initialize error messages early to get better errors when mysqld or an engine fails to start
- Fix windows bug that query_performance_frequency was not initialized if registry code failed
- thread_stack -> my_thread_stack_size
2007-10-11 18:07:40 +03:00
tomas@whalegate.ndb.mysql.com
7453382acf Bug #31470 ndb table with special characters in name are not discovered correctly 2007-10-09 09:39:39 +02:00
gshchepa/uchum@gleb.loc
09f6306ac3 Fixed bug #31310.
Locked rows of the InnoDB storage was silently skipped in the read-committed
isolation level.

QUICK_RANGE_SELECT for unique ranges lacks second (blocking) read
of the record that was read semi-consistently and just skip it.

The handler::read_multi_range_next method has been modified
to retry previous unique range if the previous read was
semi-consistent.
2007-10-09 01:07:15 +05:00
monty@narttu.mysql.fi
5dcb64882d Merge bk-internal.mysql.com:/home/bk/mysql-5.1
into  mysql.com:/home/my/mysql-5.1
2007-10-01 15:33:21 +03:00
monty@mysql.com/narttu.mysql.fi
315acca125 Removed extra spaces
Added extra debug
2007-10-01 15:32:07 +03:00
kostja@bodhi.(none)
467de3981b Merge bk-internal.mysql.com:/home/bk/mysql-5.1-runtime
into  bodhi.(none):/opt/local/work/mysql-5.1-12713-new
2007-08-31 10:58:02 +04:00
kostja@bodhi.(none)
8d1af60da0 Never access thd->ha_data directly, use getters/setters from the plugin
API instead.
This is a pre-requisite of the fix for Bug 12713, which changes the
data type of thd->ha_data from void * to struct Ha_data.
2007-08-31 10:19:52 +04:00
jani@a88-113-38-195.elisa-laajakaista.fi
b25dacbdee Merge a88-113-38-195.elisa-laajakaista.fi:/home/my/bk/mysql-5.1-main
into  a88-113-38-195.elisa-laajakaista.fi:/home/my/bk/mysql-5.1-marvel
2007-08-24 15:25:02 +03:00
mhansson@dl145s.mysql.com
68048e4266 Merge mhansson@bk-internal.mysql.com:/home/bk/mysql-5.1-opt
into  dl145s.mysql.com:/data0/mhansson/my51-bug28570
2007-08-15 12:42:39 +02:00
mhansson/martin@linux-st28.site
eb35a8764f Merge linux-st28.site:/home/martin/mysql/src/bug28570/my50-bug28570
into  linux-st28.site:/home/martin/mysql/src/bug28570/my51-bug28570
2007-08-15 12:03:11 +02:00
mhansson/martin@linux-st28.site
1da8451d4d bug#28570: handler::index_read() is called with different find_flag when
ORDER BY is used

The range analysis module did not correctly signal to the 
handler that a range represents a ref (EQ_RANGE flag). This causes 
non-range queries like 
SELECT ... FROM ... WHERE keypart_1=const, ..., keypart_n=const 
ORDER BY ... FOR UPDATE
to wait for a lock unneccesarily if another running transaction uses
SELECT ... FOR UPDATE on the same table.

Fixed by setting EQ_RANGE for all range accesses that represent 
an equality predicate.
2007-08-15 09:23:44 +02:00
monty@narttu.mysql.fi
9d609a59fd Merge bk-internal.mysql.com:/home/bk/mysql-5.1
into  mysql.com:/home/my/mysql-5.1
2007-08-14 00:22:34 +03:00
monty@mysql.com/nosik.monty.fi
e53a73e26c Fixed a lot of compiler warnings and errors detected by Forte C++ on Solaris
Faster thr_alarm()
Added 'Opened_files' status variable to track calls to my_open()
Don't give warnings when running mysql_install_db
Added option --source-install to mysql_install_db

I had to do the following renames() as used polymorphism didn't work with Forte compiler on 64 bit systems
index_read()      -> index_read_map()
index_read_idx()  -> index_read_idx_map()
index_read_last() -> index_read_last_map()
2007-08-13 16:11:25 +03:00
df@pippilotta.erinye.com
493634e4c7 Merge bk-internal:/home/bk/mysql-5.1-marvel
into  pippilotta.erinye.com:/shared/home/df/mysql/build/mysql-5.1-build-marvel-engines
2007-08-03 17:15:23 +02:00
monty@mysql.com/nosik.monty.fi
237d586700 Simplify logging code a bit (to make code smaller and faster)
Moved duplicated code to inline function store_timestamp()
Save thd->time_zone_used when logging to table as CSV internally cases it to be changed
Added MYSQL_LOCK_IGNORE_FLUSH to log tables to avoid deadlock in case of flush tables.
Mark log tables with TIMESTAMP_NO_AUTO_SET to avoid automatic timestamping
Set TABLE->no_replicate on open
2007-08-03 01:14:27 +03:00
gluh@mysql.com/eagle.(none)
27ab885525 WL#3732 Information schema optimization 2007-08-03 03:14:05 +05:00
tsmith@ramayana.hindu.god
b13de9343f Merge 50 -> 51 (-opt changesets) 2007-08-01 18:59:41 -06:00
tsmith@ramayana.hindu.god
a52a078f75 Merge tsmith@bk-internal.mysql.com:/home/bk/mysql-5.1-opt
into  ramayana.hindu.god:/home/tsmith/m/bk/maint/51
2007-08-01 18:40:02 -06:00
kostja@bodhi.(none)
6238763281 Merge bk-internal.mysql.com:/home/bk/mysql-5.1
into  bodhi.(none):/opt/local/work/mysql-5.1-runtime
2007-07-31 23:47:38 +04:00
gkodinov/kgeorge@magare.gmz
daa5c20360 Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  magare.gmz:/home/kgeorge/mysql/autopush/B27417-5.0-opt
2007-07-31 15:23:25 +03:00
serg@janus.mylan
f451ac1f96 handler::ha_write_row_no_binlog() hack removed,
existing table->no_replicate code is used instead
2007-07-30 19:56:02 +02:00
gkodinov/kgeorge@magare.gmz
cfbfb8bae8 (Pushing for Andrei)
Merge magare.gmz:/home/kgeorge/mysql/work/B27417-5.0-opt
into  magare.gmz:/home/kgeorge/mysql/work/B27417-5.1-opt
2007-07-30 19:02:21 +03:00
gkodinov/kgeorge@magare.gmz
9a0e6ec6d2 (pushing for Andrei)
Bug #27417 thd->no_trans_update.stmt lost value inside of SF-exec-stack
  
Once had been set the flag might later got reset inside of a stored routine 
execution stack.
The reason was in that there was no check if a new statement started at time 
of resetting.
The artifact affects most of binlogable DML queries. Notice, that multi-update 
is wrapped up within
  bug@27716 fix, multi-delete bug@29136.
  
Fixed with saving parent's statement flag of whether the statement modified 
non-transactional table, and unioning (merging) the value with that was gained 
in mysql_execute_command.
  
Resettling thd->no_trans_update members into thd->transaction.`member`;
Asserting code;
Effectively the following properties are held.
  
1. At the end of a substatement thd->transaction.stmt.modified_non_trans_table
   reflects the fact if such a table got modified by the substatement.
   That also respects THD::really_abort_on_warnin() requirements.
2. Eventually thd->transaction.stmt.modified_non_trans_table will be computed as
   the union of the values of all invoked sub-statements.
   That fixes this bug#27417;

Computing of thd->transaction.all.modified_non_trans_table is refined to base to 
the stmt's value for all the case including insert .. select statement which 
before the patch had an extra issue bug@28960.
Minor issues are covered with mysql_load, mysql_delete, and binloggin of insert in
to temp_table select. 
  
The supplied test verifies limitely, mostly asserts. The ultimate testing is defered
for bug@13270, bug@23333.
2007-07-30 18:27:36 +03:00
evgen@moonbone.local
002696b648 Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  moonbone.local:/mnt/gentoo64/work/24989-bug-5.0-opt-mysql
2007-07-30 18:10:34 +04:00
evgen@moonbone.local
8de5603d1d Bug#24989: The DEADLOCK error is improperly handled by InnoDB.
When innodb detects a deadlock it calls ha_rollback_trans() to rollback the 
main transaction. But such action isn't allowed from inside of triggers and
functions. When it happen the 'Explicit or implicit commit' error is thrown
even if there is no commit/rollback statements in the trigger/function. This
leads to the user confusion.

Now the convert_error_code_to_mysql() function doesn't call the 
ha_rollback_trans() function directly but rather calls the
mark_transaction_to_rollback function and returns an error.
The sp_rcontext::find_handler() now doesn't allow errors to be caught by the
trigger/function error handlers when the thd->is_fatal_sub_stmt_error flag
is set. Procedures are still allowed to catch such errors.
The sp_rcontext::find_handler function now accepts a THD handle as a parameter.
The transaction_rollback_request and the is_fatal_sub_stmt_error flags are 
added to the THD class. The are initialized by the THD class constructor.
Now the ha_autocommit_or_rollback function rolls back main transaction
when not in a sub statement and the thd->transaction_rollback_request
is set.
The THD::restore_sub_statement_state function now resets the 
thd->is_fatal_sub_stmt_error flag on exit from a sub-statement.
2007-07-30 17:14:34 +04:00
malff/marcsql@weblab.(none)
ac7b17eac4 Code review changes 2007-07-27 12:19:36 -06:00
malff/marcsql@weblab.(none)
c7bbd8917c WL#3984 (Revise locking of mysql.general_log and mysql.slow_log)
Bug#25422 (Hang with log tables)
Bug 17876 (Truncating mysql.slow_log in a SP after using cursor locks the
          thread)
Bug 23044 (Warnings on flush of a log table)
Bug 29129 (Resetting general_log while the GLOBAL READ LOCK is set causes
           a deadlock)

Prior to this fix, the server would hang when performing concurrent
ALTER TABLE or TRUNCATE TABLE statements against the LOG TABLES,
which are mysql.general_log and mysql.slow_log.

The root cause traces to the following code:
in sql_base.cc, open_table()
  if (table->in_use != thd)
  {
    /* wait_for_condition will unlock LOCK_open for us */
    wait_for_condition(thd, &LOCK_open, &COND_refresh);
  }
The problem with this code is that the current implementation of the
LOGGER creates 'fake' THD objects, like
- Log_to_csv_event_handler::general_log_thd
- Log_to_csv_event_handler::slow_log_thd
which are not associated to a real thread running in the server,
so that waiting for these non-existing threads to release table locks
cause the dead lock.

In general, the design of Log_to_csv_event_handler does not fit into the
general architecture of the server, so that the concept of general_log_thd
and slow_log_thd has to be abandoned:
- this implementation does not work with table locking
- it will not work with commands like SHOW PROCESSLIST
- having the log tables always opened does not integrate well with DDL
operations / FLUSH TABLES / SET GLOBAL READ_ONLY

With this patch, the fundamental design of the LOGGER has been changed to:
- always open and close a log table when writing a log
- remove totally the usage of fake THD objects
- clarify how locking of log tables is implemented in general.

See WL#3984 for details related to the new locking design.

Additional changes (misc bugs exposed and fixed):

1)

mysqldump which would ignore some tables in dump_all_tables_in_db(),
 but forget to ignore the same in dump_all_views_in_db().

2)

mysqldump would also issue an empty "LOCK TABLE" command when all the tables
to lock are to be ignored (numrows == 0), instead of not issuing the query.

3)

Internal errors handlers could intercept errors but not warnings
(see sql_error.cc).

4)

Implementing a nested call to open tables, for the performance schema tables,
exposed an existing bug in remove_table_from_cache(), which would perform:
  in_use->some_tables_deleted=1;
against another thread, without any consideration about thread locking.
This call inside remove_table_from_cache() was not required anyway,
since calling mysql_lock_abort() takes care of aborting -- cleanly -- threads
that might hold a lock on a table.
This line (in_use->some_tables_deleted=1) has been removed.
2007-07-27 00:31:06 -06:00
svoj@june.mysql.com
39f7a95589 Merge mysql.com:/home/svoj/devel/mysql/BUG26325/mysql-5.0-engines
into  mysql.com:/home/svoj/devel/mysql/BUG26325/mysql-5.1-engines
2007-07-19 15:54:31 +05:00
svoj@mysql.com/june.mysql.com
5d4a134f8f BUG#26325 - TEMPORARY TABLE "corrupt" after first read, according
to CHECK TABLE

CHECK/REPAIR TABLE reports "File not found" error when issued
against temporary table.

Fixed by disabling a brunch of code (in case it gets temporary table)
that is responsible for updating frm version as it is not needed
for temporary tables.
2007-07-19 13:51:31 +05:00
kostja@bodhi.(none)
7ce3cada45 Merge bodhi.(none):/opt/local/work/mysql-5.0-runtime
into  bodhi.(none):/opt/local/work/mysql-5.1-runtime
2007-07-02 01:55:01 +04:00
lars/lthalmann@dl145k.mysql.com
5c667b6fa5 Merge mysql.com:/nfsdisk1/lars/bk/mysql-5.1
into  mysql.com:/nfsdisk1/lars/bk/mysql-5.1-new-rpl
2007-06-21 17:13:02 +02:00
anozdrin/alik@ibm.opbmk
c5baa61fe4 Merge bk-internal.mysql.com:/home/bk/mysql-5.0-runtime
into  ibm.opbmk:/home/alik/Documents/MySQL/devel/5.0-rt-build
2007-06-20 12:46:15 +04:00
kostja@bodhi.(none)
68632318dc Manual merge. 2007-06-19 15:02:08 +04:00
anozdrin/alik@ibm.
8c8ab0488e Fix typo in the patch for BUG#25411 on 24-Apr-2007. 2007-06-19 01:54:35 +04:00
lars/lthalmann@dl145j.mysql.com
ae52876fd0 Merge mysql.com:/nfsdisk1/lars/bkroot/mysql-5.1-new-rpl
into  mysql.com:/nfsdisk1/lars/MERGE/mysql-5.1-merge
2007-06-18 09:42:22 +02:00
malff/marcsql@weblab.(none)
7e36d37eb0 Merge weblab.(none):/home/marcsql/TREE/mysql-5.1-base
into  weblab.(none):/home/marcsql/TREE/mysql-5.1-rt-merge
2007-06-15 11:36:31 -06:00
tsmith@quadxeon.mysql.com
918090030b Merge tsmith@bk-internal.mysql.com:/home/bk/mysql-5.1-build
into  quadxeon.mysql.com:/benchmarks/ext3/TOSAVE/tsmith/bk/maint/jun14/51
2007-06-15 01:57:33 +02:00
anozdrin/alik@ibm.
62e3e46275 This the 4-th patch in scope of CS patch (BUG#11986).
The patch contains the following changes:
  - Introduce auxilary functions to convenient work with character sets:
    - resolve_charset();
    - resolve_collation();
    - get_default_db_collation();
  - Introduce lex_string_set();
  - Refactor Table_trigger_list::process_triggers() &
    sp_head::execute_trigger() to be consistent with other code;
  - Move reusable code from add_table_for_trigger() into
    build_trn_path(), check_trn_exists() and load_table_name_for_trigger()
    to be used in the following patch.
  - Rename triggers_file_ext and trigname_file_ext into TRN_EXT and
    TRG_EXT respectively.
2007-06-14 19:23:55 +04:00
mats@kindahl-laptop.dnsalias.net
143a895b4f Merge kindahl-laptop.dnsalias.net:/home/bkroot/mysql-5.1-rpl
into  kindahl-laptop.dnsalias.net:/home/bk/b23051-mysql-5.1-rpl
2007-06-12 22:14:54 +02:00
mats@kindahl-laptop.dnsalias.net
ec58bfb28a Merge kindahl-laptop.dnsalias.net:/home/bkroot/mysql-5.1-rpl
into  kindahl-laptop.dnsalias.net:/home/bk/b23051-mysql-5.1-rpl
2007-06-12 22:02:46 +02:00
holyfoot/hf@mysql.com/hfmain.(none)
6ee83df5ff bug #28309 First insert violates UNIQUE constraint - was "memory" table empty?
If we have lower_case_table_names == 2 (usually on case insensitive file
systems) we sometimes make 'homedir' part of the path sent to the
handler into lowercase. So in this case HEAP engine couldn't properly
find and remove HP_SHARE, what caused the bug.
2007-06-07 14:03:43 +05:00
jimw@rama.(none)
3c93323d28 Bug #28842 Different 'duplicate key' error code between 5.0 and 5.1
The patch for WL 1563 added a new duplicate key error message so that the
  key name could be provided instead of the key number. But the error code
  for the new message was used even though that did not need to change.

  This could cause unnecessary problems for applications that used the old
  ER_DUP_ENTRY error code to detect duplicate key errors.
2007-06-06 10:57:07 -07:00
kostja@bodhi.(none)
16633169e4 Merge bk-internal.mysql.com:/home/bk/mysql-5.1
into  bodhi.(none):/opt/local/work/mysql-5.1-runtime
2007-06-01 12:12:06 +04:00
mats@kindahl-laptop.dnsalias.net
a979a6c51d WL#3303 (RBR: Engine-controlled logging format):
Moving code to check storage engine capabilities to after tables
are locked.  Moving code to cache table flags so that table flags
are read from the storage engine at the beginning of the statement
in addition to when the storage engine is opened.

To handle CREATE-SELECT, the decision function is called after the
table is created and it is called with all tables that are in the select
part of the statement as well as the newly created table.
2007-05-29 17:13:17 +02:00
mskold/marty@mysql.com/linux.site
43f80e9875 Merge mskold@bk-internal.mysql.com:/home/bk/mysql-5.0-ndb
into  mysql.com:/windows/Linux_space/MySQL/mysql-5.0-ndb
2007-05-28 15:23:28 +02:00
kostja@vajra.(none)
0162745cff Merge bk-internal.mysql.com:/home/bk/mysql-5.1
into  vajra.(none):/opt/local/work/mysql-5.1-runtime
2007-05-24 19:34:14 +04:00
jani@linux-th5m.site
f1807e1f25 Merge jamppa@bk-internal.mysql.com:/home/bk/mysql-5.1
into  linux-th5m.site:/home/my/mysql-5.1-marvel
2007-05-24 15:26:10 +03:00
jani@a88-113-38-195.elisa-laajakaista.fi
fc3b3a0a86 Merge jamppa@bk-internal.mysql.com:/home/bk/mysql-5.1
into  a88-113-38-195.elisa-laajakaista.fi:/home/my/bk/mysql-5.1-marvel
2007-05-24 13:24:36 +03:00
svoj@june.mysql.com
442969fd16 Merge mysql.com:/home/svoj/devel/bk/mysql-5.1
into  mysql.com:/home/svoj/devel/mysql/merge/mysql-5.1-engines
2007-05-23 12:41:30 +05:00
malff/marcsql@weblab.(none)
782096dbcc Bug#21554 (sp_cache.cc: violates C++ aliasing rules)
The problem reported is a compile bug,
reported by the development GCC team with GCC 4.2.

The original issue can no longer be reproduced in MySQL 5.1,
since the configure script no longer define HAVE_ATOMIC_ADD,
which caused the Linux atomic functions to be used (and cause a problem
with an invalid cast).

This patch implements some code cleanup for 5.1 only, which was identified
during the investigation of this issue.

With this patch, statistics maintained in THD::status_var are by definition
owned by the running thread, and do not need to be protected against race
conditions. These statistics are maintained by the status_var_* helpers,
which do not require any lock.
2007-05-22 13:41:40 -06:00
istruewing@chilla.local
e2fa2becfc Merge bk-internal.mysql.com:/home/bk/mysql-5.1-engines
into  chilla.local:/home/mydev/mysql-5.1-bug17332
2007-05-10 17:30:50 +02:00
monty@mysql.com/narttu.mysql.fi
088e2395f1 WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:

- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t

Removed declaration of byte, gptr, my_string, my_size_t and size_s. 

Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
  instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
  as this requires fewer casts in the code and is more in line with how the
  standard functions work.
- Added extra length argument to dirname_part() to return the length of the
  created string.
- Changed (at least) following functions to take uchar* as argument:
  - db_dump()
  - my_net_write()
  - net_write_command()
  - net_store_data()
  - DBUG_DUMP()
  - decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
  argument to my_uncompress() from a pointer to a value as we only return
  one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
  the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
  casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.

Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
  needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
  explicitely as this conflict was often hided by casting the function to
  hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
  get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
  size_t. This was needed to properly detect errors (which are
  returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
  (portability fix)
- Removed windows specific code to restore cursor position as this
  causes slowdown on windows and we should not mix read() and pread()
  calls anyway as this is not thread safe. Updated function comment to
  reflect this. Changed function that depended on original behavior of
  my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
  m_size is the number of elements in the array, not a string/memory
  length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
  Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
  - Replaced some calls to alloc_root + memcpy to use
    strmake_root()/strdup_root().
  - Changed some calls from memdup() to strmake() (Safety fix)
  - Simpler loops in client-simple.c
2007-05-10 12:59:39 +03:00
tomas@whalegate.ndb.mysql.com
19a2814f47 Merge whalegate.ndb.mysql.com:/home/tomas/mysql-5.1-opt
into  whalegate.ndb.mysql.com:/home/tomas/mysql-5.1-single-user
2007-05-10 08:06:09 +02:00
mskold/marty@mysql.com/linux.site
c5f1503493 Bug#26342 auto_increment_increment AND auto_increment_offset REALLY REALLY anger NDB cluster, implemented support for auto_increment_offset and auto_increment_increment for Ndb 2007-05-09 14:14:27 +02:00
gni@dev3-221.dev.cn.tlan
305d0eaf02 Merge dev3-221.dev.cn.tlan:/home/ngb/mysql/mysql-5.1/mysql-5.1-new-ndb-bj
into  dev3-221.dev.cn.tlan:/home/ngb/mysql/mysql-5.1/mysql-5.1-new-ndb
2007-05-08 09:52:27 +08:00
gshchepa/uchum@gleb.loc
eb1f21f8b6 Fixed bug #27954.
This bug affects multi-row INSERT ... ON DUPLICATE into table
with PRIMARY KEY of AUTO_INCREMENT field and some additional UNIQUE indices.
If the first row in multi-row INSERT contains duplicated values of UNIQUE
indices, then following rows of multi-row INSERT (with either duplicated or
unique key field values) may me applied to _arbitrary_ records of table as
updates.
This bug was introduced in 5.0. Related code was widely rewritten in 5.1, and
5.1 is already free of this problem. 4.1 was not affected too.

When updating the row during INSERT ON DUPLICATE KEY UPDATE, we called
restore_auto_increment(), which set next_insert_id back to 0, but we
forgot to set clear_next_insert_id back to 0.
restore_auto_increment() function has been fixed.
2007-05-08 00:24:25 +05:00
istruewing@chilla.local
e327818c28 Merge bk-internal.mysql.com:/home/bk/mysql-5.1-engines
into  chilla.local:/home/mydev/mysql-5.1-wl2936-two
2007-04-27 19:09:39 +02:00
gni@dev3-221.dev.cn.tlan
1869b2c4d0 Merge dev3-221.dev.cn.tlan:/home/ngb/mysql/mysql-5.1/mysql-5.1-new-ndb-bj
into  dev3-221.dev.cn.tlan:/home/ngb/mysql/mysql-5.1/bug18676
2007-04-24 17:34:36 +08:00
istruewing@chilla.local
3a0d2806df WL#2936 - Falcon & MySQL plugin interface: server variables
Fixed a compiler dependent expression to be more portable.
Initialized 'dummy' in construct_help_options() so that loaded
plugin show themselves as TRUE in the help output.
2007-04-18 14:37:57 +02:00
serg@sergbook.mysql.com
6bc9bc92df Merge bk-internal.mysql.com:/home/bk/mysql-5.1
into  sergbook.mysql.com:/usr/home/serg/Abk/mysql-5.1-wl2936
2007-04-16 10:37:50 +02:00
gni/root@dev3-221.dev.cn.tlan
648b03aa14 BUG#18676 In order to coincide with 5.0 mysqld error code after bug#18676, Map the 4009 ndb error code to 157 mysql error code 2007-04-16 15:15:47 +08:00
serg@sergbook.mysql.com
c53037af36 more wl#2936 fixes: removed implicit ha_thd() calls (too error-prone),
fixed an assert crash
2007-04-15 15:47:27 +02:00
serg@janus.mylan
3ecbb5a443 wl#2936 - fixing problems 2007-04-13 19:23:02 +02:00
jani@ua141d10.elisa.omakaista.fi
335153121b Merge jamppa@bk-internal.mysql.com:/home/bk/mysql-5.0
into  ua141d10.elisa.omakaista.fi:/home/my/bk/mysql-5.0-marvel
2007-04-12 12:50:02 +03:00
Justin.He/justin.he@dev3-240.dev.cn.tlan
c7da27b5b2 Merge dev3-240.dev.cn.tlan:/home/justin.he/mysql/mysql-5.0/mysql-5.0-ndb
into  dev3-240.dev.cn.tlan:/home/justin.he/mysql/mysql-5.0/mysql-5.0-ndb-bj.merge
2007-04-05 11:30:19 +08:00
gni/root@dev3-221.dev.cn.tlan
888fcd6f7e recovery from 5.0 merge for bug18676 2007-04-04 15:22:37 +08:00
gni/root@dev3-221.dev.cn.tlan
99895eb6c3 Merge dev3-221.dev.cn.tlan:/home/ngb/mysql/mysql-5.0/bug18676
into  dev3-221.dev.cn.tlan:/home/ngb/mysql/mysql-5.1/bug18676
2007-04-04 14:30:12 +08:00
jamppa@bk-internal.mysql.com
cbfd66e754 Merge bk-internal.mysql.com:/data0/bk/mysql-5.0
into  bk-internal.mysql.com:/data0/bk/mysql-5.0-marvel
2007-04-03 13:55:20 +02:00
jani@ua141d10.elisa.omakaista.fi
e4fde44948 Merge jamppa@bk-internal.mysql.com:/home/bk/mysql-5.1-marvel
into  ua141d10.elisa.omakaista.fi:/home/my/bk/mysql-5.1-marvel
2007-04-03 14:51:32 +03:00