mirror of
https://github.com/MariaDB/server.git
synced 2025-01-20 05:52:27 +01:00
19bbb7cc85
Optimised version of ADD/DROP/REORGANIZE partitions for non-NDB storage engines. New syntax to handle REBUILD/OPTIMIZE/ANALYZE/CHECK/REPAIR partitions Quite a few bug fixes include/thr_lock.h: New method to downgrade locks from TL_WRITE_ONLY Possibility to upgrade lock while aborting locks mysql-test/r/ndb_autodiscover.result: Fix for lowercase and that all NDB tables are now partitioned mysql-test/r/ndb_bitfield.result: Fix for lowercase and that all NDB tables are now partitioned mysql-test/r/ndb_gis.result: Fix for lowercase and that all NDB tables are now partitioned mysql-test/r/ndb_partition_key.result: New test case mysql-test/r/partition.result: New test case mysql-test/r/partition_error.result: New test case mysql-test/r/partition_mgm_err.result: Fix of test case results mysql-test/t/disabled.def: partition_03ndb still has bug mysql-test/t/ndb_partition_key.test: New test cases for new functionality and bugs mysql-test/t/partition.test: New test cases for new functionality and bugs mysql-test/t/partition_error.test: New test cases for new functionality and bugs mysql-test/t/partition_mgm_err.test: New test cases for new functionality and bugs mysys/thr_lock.c: New method to downgrade TL_WRITE_ONLY locks Possibility to specify if locks are to be upgraded at abort locks sql/ha_archive.cc: New handlerton methods sql/ha_berkeley.cc: New handlerton methods sql/ha_blackhole.cc: New handlerton methods sql/ha_federated.cc: New handlerton methods sql/ha_heap.cc: New handlerton methods sql/ha_innodb.cc: New handlerton methods sql/ha_myisam.cc: New handlerton methods sql/ha_myisammrg.cc: New handlerton methods sql/ha_ndbcluster.cc: New handlerton methods Moved out packfrm and unpackfrm methods Adapted many parts to use table_share instead of table->s Ensured that .ndb file uses filename and not tablename according to new encoding of names (WL 1324) All NDB tables are partitioned and set up partition info Fixed such that tablenames use tablenames and not filenames in NDB NDB uses auto partitioning for ENGINE=NDB tables Warning for very large tables Set RANGE data Set LIST data New method to set-up partition info Set Default number of partitions flag Set linear hash flag Set node group array Set number of fragments Set max rows Set tablespace names New method to get number of partitions of table to use at open table sql/ha_ndbcluster.h: Removed partition_flags and alter_table_flags from handler class A couple of new and changed method headers sql/ha_ndbcluster_binlog.cc: Use new method headers sql/ha_partition.cc: New handlerton methods Lots of new function headers Use #P# as separator between table name and partition name and #SP# as separator between partition name and subpartition name Use filename encoding for files both of table name part and of partition name parts New method to drop partitions based on partition state New method to rename partitions based on partition state New methods to optimize, analyze, check and repair partitions New methods to optimize, analyze, check and repair table Helper method to create new partition, open it and external lock it, not needed to lock it internally since no one else knows about it yet. Cleanup method at error for new partitions New methods to perform bulk of work at ADD/REORGANIZE partitions (change_partitions, copy_partitions) sql/ha_partition.h: New methods and variables A few dropped ones and a few changed ones sql/handler.cc: Handlerton interface changes New flag to open_table_from_share sql/handler.h: New alter_table_flags New partition flags New partition states More states for default handling Lots of new, dropped and changed interfaces sql/lex.h: Added REBUILD and changed name of REORGANISE to REORGANIZE sql/lock.cc: Method to downgrade locks Able to specify if locks upgraded on abort locks sql/log.cc: New handlerton methods sql/mysql_priv.h: Lots of new interfaces sql/share/errmsg.txt: Lots of new, dropped and changed error messages sql/sql_base.cc: Adapted to new method headers New method to abort and upgrade lock New method to close open tables and downgrade lock New method to wait for completed table sql/sql_lex.h: New flags sql/sql_partition.cc: Return int instead of bool in get_partition_id More defaults handling Make use of new mem_alloc_error method More work on function headers Changes to generate partition syntax to cater for intermediate partition states Lots of new code with large comments describing new features for Partition Management: ADD/DROP/REORGANIZE/OPTIMIZE/ANALYZE/CHECK/REPAIR partitions sql/sql_show.cc: Minors sql/sql_table.cc: Moved a couple of methods New methods to copy create lists and key lists for use with mysql_prepare_table New method to write frm file New handling of handlers with auto partitioning Fix CREATE TABLE LIKE Moved code for ADD/DROP/REORGANIZE partitions Use handlerton method for alter_table_flags sql/sql_yacc.yy: More memory alloc error checks New syntax for REBUILD, ANALYZE, CHECK, OPTIMIZE, REPAIR partitions sql/table.cc: Fix length of extra part to be 4 bytes Partition state introduced in frm file sql/table.h: Partition state introduced sql/unireg.cc: Partition state introduced Default partition storage/csv/ha_tina.cc: New handlerton methods storage/example/ha_example.cc: New handlerton methods storage/ndb/include/kernel/ndb_limits.h: RANGE DATA storage/ndb/include/kernel/signaldata/AlterTable.hpp: New interfaces in ALTER TABLE towards NDB kernel storage/ndb/include/kernel/signaldata/DiAddTab.hpp: New section storage/ndb/include/kernel/signaldata/DictTabInfo.hpp: Lots of new parts of table description storage/ndb/include/kernel/signaldata/LqhFrag.hpp: tablespace id specified in LQHFRAGREQ storage/ndb/include/ndbapi/NdbDictionary.hpp: Lots of new methods in NDB dictionary storage/ndb/src/common/debugger/signaldata/DictTabInfo.cpp: Lots of new variables in table description storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp: Lots of new variables in table description storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp: Lots of new variables in table description storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: New error insertion storage/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp: a few extra jam's storage/ndb/src/ndbapi/NdbBlob.cpp: Changes to definition of blob tables storage/ndb/src/ndbapi/NdbDictionary.cpp: Lots of new stuff in NDB dictionary storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp: Lots of new stuff in NDB dictionary storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp: Lots of new stuff in NDB dictionary storage/ndb/test/ndbapi/test_event.cpp: removed use of methods no longer in existence storage/ndb/tools/restore/Restore.cpp: Renamed variable
156 lines
5 KiB
C
156 lines
5 KiB
C
/* Copyright (C) 2000 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; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
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 */
|
|
|
|
/* For use with thr_lock:s */
|
|
|
|
#ifndef _thr_lock_h
|
|
#define _thr_lock_h
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include <my_pthread.h>
|
|
#include <my_list.h>
|
|
|
|
struct st_thr_lock;
|
|
extern ulong locks_immediate,locks_waited ;
|
|
|
|
enum thr_lock_type { TL_IGNORE=-1,
|
|
TL_UNLOCK, /* UNLOCK ANY LOCK */
|
|
TL_READ, /* Read lock */
|
|
TL_READ_WITH_SHARED_LOCKS,
|
|
/* High prior. than TL_WRITE. Allow concurrent insert */
|
|
TL_READ_HIGH_PRIORITY,
|
|
/* READ, Don't allow concurrent insert */
|
|
TL_READ_NO_INSERT,
|
|
/*
|
|
Write lock, but allow other threads to read / write.
|
|
Used by BDB tables in MySQL to mark that someone is
|
|
reading/writing to the table.
|
|
*/
|
|
TL_WRITE_ALLOW_WRITE,
|
|
/*
|
|
Write lock, but allow other threads to read.
|
|
Used by ALTER TABLE in MySQL to allow readers
|
|
to use the table until ALTER TABLE is finished.
|
|
*/
|
|
TL_WRITE_ALLOW_READ,
|
|
/*
|
|
WRITE lock used by concurrent insert. Will allow
|
|
READ, if one could use concurrent insert on table.
|
|
*/
|
|
TL_WRITE_CONCURRENT_INSERT,
|
|
/* Write used by INSERT DELAYED. Allows READ locks */
|
|
TL_WRITE_DELAYED,
|
|
/* WRITE lock that has lower priority than TL_READ */
|
|
TL_WRITE_LOW_PRIORITY,
|
|
/* Normal WRITE lock */
|
|
TL_WRITE,
|
|
/* Abort new lock request with an error */
|
|
TL_WRITE_ONLY};
|
|
|
|
enum enum_thr_lock_result { THR_LOCK_SUCCESS= 0, THR_LOCK_ABORTED= 1,
|
|
THR_LOCK_WAIT_TIMEOUT= 2, THR_LOCK_DEADLOCK= 3 };
|
|
|
|
|
|
extern ulong max_write_lock_count;
|
|
extern ulong table_lock_wait_timeout;
|
|
extern my_bool thr_lock_inited;
|
|
extern enum thr_lock_type thr_upgraded_concurrent_insert_lock;
|
|
|
|
/*
|
|
A description of the thread which owns the lock. The address
|
|
of an instance of this structure is used to uniquely identify the thread.
|
|
*/
|
|
|
|
typedef struct st_thr_lock_info
|
|
{
|
|
pthread_t thread;
|
|
ulong thread_id;
|
|
ulong n_cursors;
|
|
} THR_LOCK_INFO;
|
|
|
|
/*
|
|
Lock owner identifier. Globally identifies the lock owner within the
|
|
thread and among all the threads. The address of an instance of this
|
|
structure is used as id.
|
|
*/
|
|
|
|
typedef struct st_thr_lock_owner
|
|
{
|
|
THR_LOCK_INFO *info;
|
|
} THR_LOCK_OWNER;
|
|
|
|
|
|
typedef struct st_thr_lock_data {
|
|
THR_LOCK_OWNER *owner;
|
|
struct st_thr_lock_data *next,**prev;
|
|
struct st_thr_lock *lock;
|
|
pthread_cond_t *cond;
|
|
enum thr_lock_type type;
|
|
void *status_param; /* Param to status functions */
|
|
void *debug_print_param;
|
|
} THR_LOCK_DATA;
|
|
|
|
struct st_lock_list {
|
|
THR_LOCK_DATA *data,**last;
|
|
};
|
|
|
|
typedef struct st_thr_lock {
|
|
LIST list;
|
|
pthread_mutex_t mutex;
|
|
struct st_lock_list read_wait;
|
|
struct st_lock_list read;
|
|
struct st_lock_list write_wait;
|
|
struct st_lock_list write;
|
|
/* write_lock_count is incremented for write locks and reset on read locks */
|
|
ulong write_lock_count;
|
|
uint read_no_write_count;
|
|
void (*get_status)(void*, int); /* When one gets a lock */
|
|
void (*copy_status)(void*,void*);
|
|
void (*update_status)(void*); /* Before release of write */
|
|
my_bool (*check_status)(void *);
|
|
} THR_LOCK;
|
|
|
|
|
|
extern LIST *thr_lock_thread_list;
|
|
extern pthread_mutex_t THR_LOCK_lock;
|
|
|
|
my_bool init_thr_lock(void); /* Must be called once/thread */
|
|
#define thr_lock_owner_init(owner, info_arg) (owner)->info= (info_arg)
|
|
void thr_lock_info_init(THR_LOCK_INFO *info);
|
|
void thr_lock_init(THR_LOCK *lock);
|
|
void thr_lock_delete(THR_LOCK *lock);
|
|
void thr_lock_data_init(THR_LOCK *lock,THR_LOCK_DATA *data,
|
|
void *status_param);
|
|
enum enum_thr_lock_result thr_lock(THR_LOCK_DATA *data,
|
|
THR_LOCK_OWNER *owner,
|
|
enum thr_lock_type lock_type);
|
|
void thr_unlock(THR_LOCK_DATA *data);
|
|
enum enum_thr_lock_result thr_multi_lock(THR_LOCK_DATA **data,
|
|
uint count, THR_LOCK_OWNER *owner);
|
|
void thr_multi_unlock(THR_LOCK_DATA **data,uint count);
|
|
void thr_abort_locks(THR_LOCK *lock, bool upgrade_lock);
|
|
my_bool thr_abort_locks_for_thread(THR_LOCK *lock, pthread_t thread);
|
|
void thr_print_locks(void); /* For debugging */
|
|
my_bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data);
|
|
void thr_downgrade_write_lock(THR_LOCK_DATA *data,
|
|
enum thr_lock_type new_lock_type);
|
|
my_bool thr_reschedule_write_lock(THR_LOCK_DATA *data);
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif /* _thr_lock_h */
|