mirror of
https://github.com/MariaDB/server.git
synced 2025-01-20 14:02:32 +01:00
ef15a335b3
---------------------------------------------------------- revno: 2630.4.38 committer: Konstantin Osipov <konstantin@mysql.com> branch nick: mysql-6.0-4144 timestamp: Wed 2008-06-25 22:07:06 +0400 message: WL#4144 - Lock MERGE engine children. Committing a version of the patch merged with WL#3726 on behalf of Ingo. Step #1: Move locking from parent to children. MERGE children are now left in the query list of tables after inserted there in open_tables(). So they are locked by lock_tables() as all other tables are. The MERGE parent does not store locks any more. It appears in a MYSQL_LOCK with zero lock data. This is kind of a "dummy" lock. All other lock handling is also done directly on the children. To protect against parent or child modifications during LOCK TABLES, the children are detached after every statement and attached before every statement, even under LOCK TABLES. The children table list is removed from the query list of tables on every detach and on close of the parent. Step #2: Move MERGE specific functionality from SQL layer into table handler. Functionality moved from SQL layer (mainly sql_base.cc) to the table handler (ha_myisammrg.cc). Unnecessary code is removed from the SQL layer. Step #3: Moved all MERGE specific members from TABLE to ha_myisammrg. Moved members from TABLE to ha_myisammrg. Renamed some mebers. Fixed comments. Step #4: Valgrind and coverage testing Valgrind did not uncover new problems. Added purecov comments. Added a new test for DATA/INDEX DIRECTORY options. Changed handling of ::reset() for non-attached children. Fixed the merge-big test. Step #5: Fixed crashes detected during review Changed detection when to attach/detach. Added new tests. Backport also the fix for Bug#44040 "MySQL allows creating a MERGE table upon VIEWs but crashes when using it"
96 lines
2.5 KiB
C
96 lines
2.5 KiB
C
/* Copyright (C) 2000-2003 MySQL AB
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; version 2 of the License.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
/*
|
|
Extra functions we want to do with a database
|
|
- All flags, exept record-cache-flags, are set in all used databases
|
|
record-cache-flags are set in myrg_rrnd when we are changing database.
|
|
*/
|
|
|
|
#include "myrg_def.h"
|
|
|
|
int myrg_extra(MYRG_INFO *info,enum ha_extra_function function,
|
|
void *extra_arg)
|
|
{
|
|
int error,save_error=0;
|
|
MYRG_TABLE *file;
|
|
DBUG_ENTER("myrg_extra");
|
|
DBUG_PRINT("info",("function: %lu", (ulong) function));
|
|
|
|
if (!info->children_attached)
|
|
DBUG_RETURN(1);
|
|
if (function == HA_EXTRA_CACHE)
|
|
{
|
|
info->cache_in_use=1;
|
|
info->cache_size= (extra_arg ? *(ulong*) extra_arg :
|
|
my_default_record_cache_size);
|
|
}
|
|
else
|
|
{
|
|
if (function == HA_EXTRA_NO_CACHE ||
|
|
function == HA_EXTRA_PREPARE_FOR_UPDATE)
|
|
info->cache_in_use=0;
|
|
if (function == HA_EXTRA_RESET_STATE)
|
|
{
|
|
info->current_table=0;
|
|
info->last_used_table=info->open_tables;
|
|
}
|
|
for (file=info->open_tables ; file != info->end_table ; file++)
|
|
{
|
|
if ((error=mi_extra(file->table, function, extra_arg)))
|
|
save_error=error;
|
|
}
|
|
}
|
|
DBUG_RETURN(save_error);
|
|
}
|
|
|
|
|
|
void myrg_extrafunc(MYRG_INFO *info, invalidator_by_filename inv)
|
|
{
|
|
MYRG_TABLE *file;
|
|
DBUG_ENTER("myrg_extrafunc");
|
|
|
|
for (file=info->open_tables ; file != info->end_table ; file++)
|
|
file->table->s->invalidator = inv;
|
|
|
|
DBUG_VOID_RETURN;
|
|
}
|
|
|
|
|
|
int myrg_reset(MYRG_INFO *info)
|
|
{
|
|
int save_error= 0;
|
|
MYRG_TABLE *file;
|
|
DBUG_ENTER("myrg_reset");
|
|
|
|
info->cache_in_use=0;
|
|
info->current_table=0;
|
|
info->last_used_table= info->open_tables;
|
|
|
|
/*
|
|
This is normally called with detached children.
|
|
Return OK as this is the normal case.
|
|
*/
|
|
if (!info->children_attached)
|
|
DBUG_RETURN(0);
|
|
|
|
for (file=info->open_tables ; file != info->end_table ; file++)
|
|
{
|
|
int error;
|
|
if ((error= mi_reset(file->table)))
|
|
save_error=error;
|
|
}
|
|
DBUG_RETURN(save_error);
|
|
}
|