1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Merge branch '10.2' of github.com:MariaDB/server into bb-10.2-mariarocks

This commit is contained in:
Sergei Petrunia
2017-03-11 20:12:15 +00:00
1755 changed files with 63733 additions and 53790 deletions

View File

@ -2,7 +2,7 @@
#define HANDLER_INCLUDED
/*
Copyright (c) 2000, 2016, Oracle and/or its affiliates.
Copyright (c) 2009, 2016, MariaDB
Copyright (c) 2009, 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@ -236,12 +236,12 @@ enum enum_alter_inplace_result {
@note This optimization in combination with batching may be used to
remove even more roundtrips.
*/
#define HA_READ_BEFORE_WRITE_REMOVAL (1LL << 43)
#define HA_READ_BEFORE_WRITE_REMOVAL (1ULL << 43)
/*
Engine supports extended fulltext API
*/
#define HA_CAN_FULLTEXT_EXT (1LL << 44)
#define HA_CAN_FULLTEXT_EXT (1ULL << 44)
/*
Storage engine supports table export using the
@ -249,7 +249,7 @@ enum enum_alter_inplace_result {
(meaning, after this statement one can copy table files out of the
datadir and later "import" (somehow) in another MariaDB instance)
*/
#define HA_CAN_EXPORT (1LL << 45)
#define HA_CAN_EXPORT (1ULL << 45)
/*
Storage engine does not require an exclusive metadata lock
@ -259,7 +259,7 @@ enum enum_alter_inplace_result {
read or modify the table - this is defined by THR locks and the
::store_lock() method).
*/
#define HA_CONCURRENT_OPTIMIZE (1LL << 46)
#define HA_CONCURRENT_OPTIMIZE (1ULL << 46)
/*
Set of all binlog flags. Currently only contain the capabilities
@ -298,24 +298,24 @@ enum enum_alter_inplace_result {
Partitioning needs both ADD and DROP to be supported by its underlying
handlers, due to error handling, see bug#57778.
*/
#define HA_INPLACE_ADD_INDEX_NO_READ_WRITE (1L << 0)
#define HA_INPLACE_DROP_INDEX_NO_READ_WRITE (1L << 1)
#define HA_INPLACE_ADD_UNIQUE_INDEX_NO_READ_WRITE (1L << 2)
#define HA_INPLACE_DROP_UNIQUE_INDEX_NO_READ_WRITE (1L << 3)
#define HA_INPLACE_ADD_PK_INDEX_NO_READ_WRITE (1L << 4)
#define HA_INPLACE_DROP_PK_INDEX_NO_READ_WRITE (1L << 5)
#define HA_INPLACE_ADD_INDEX_NO_READ_WRITE (1UL << 0)
#define HA_INPLACE_DROP_INDEX_NO_READ_WRITE (1UL << 1)
#define HA_INPLACE_ADD_UNIQUE_INDEX_NO_READ_WRITE (1UL << 2)
#define HA_INPLACE_DROP_UNIQUE_INDEX_NO_READ_WRITE (1UL << 3)
#define HA_INPLACE_ADD_PK_INDEX_NO_READ_WRITE (1UL << 4)
#define HA_INPLACE_DROP_PK_INDEX_NO_READ_WRITE (1UL << 5)
/*
These are set if different kinds of indexes can be created or dropped
in-place while still allowing concurrent reads (but not writes) of table
data. If a handler is capable of one or more of these, it should also set
the corresponding *_NO_READ_WRITE bit(s).
*/
#define HA_INPLACE_ADD_INDEX_NO_WRITE (1L << 6)
#define HA_INPLACE_DROP_INDEX_NO_WRITE (1L << 7)
#define HA_INPLACE_ADD_UNIQUE_INDEX_NO_WRITE (1L << 8)
#define HA_INPLACE_DROP_UNIQUE_INDEX_NO_WRITE (1L << 9)
#define HA_INPLACE_ADD_PK_INDEX_NO_WRITE (1L << 10)
#define HA_INPLACE_DROP_PK_INDEX_NO_WRITE (1L << 11)
#define HA_INPLACE_ADD_INDEX_NO_WRITE (1UL << 6)
#define HA_INPLACE_DROP_INDEX_NO_WRITE (1UL << 7)
#define HA_INPLACE_ADD_UNIQUE_INDEX_NO_WRITE (1UL << 8)
#define HA_INPLACE_DROP_UNIQUE_INDEX_NO_WRITE (1UL << 9)
#define HA_INPLACE_ADD_PK_INDEX_NO_WRITE (1UL << 10)
#define HA_INPLACE_DROP_PK_INDEX_NO_WRITE (1UL << 11)
/*
HA_PARTITION_FUNCTION_SUPPORTED indicates that the function is
supported at all.
@ -341,9 +341,9 @@ enum enum_alter_inplace_result {
the storage engine. A typical engine to support this is NDB (through
WL #2498).
*/
#define HA_PARTITION_FUNCTION_SUPPORTED (1L << 12)
#define HA_FAST_CHANGE_PARTITION (1L << 13)
#define HA_PARTITION_ONE_PHASE (1L << 14)
#define HA_PARTITION_FUNCTION_SUPPORTED (1UL << 12)
#define HA_FAST_CHANGE_PARTITION (1UL << 13)
#define HA_PARTITION_ONE_PHASE (1UL << 14)
/* operations for disable/enable indexes */
#define HA_KEY_SWITCH_NONUNIQ 0
@ -369,25 +369,25 @@ enum enum_alter_inplace_result {
HA_GET_INFO does an implicit HA_ABORT_IF_LOCKED
*/
#define HA_OPEN_KEYFILE 1
#define HA_READ_ONLY 16 /* File opened as readonly */
#define HA_OPEN_KEYFILE 1U
#define HA_READ_ONLY 16U /* File opened as readonly */
/* Try readonly if can't open with read and write */
#define HA_TRY_READ_ONLY 32
#define HA_TRY_READ_ONLY 32U
/* Some key definitions */
#define HA_KEY_NULL_LENGTH 1
#define HA_KEY_BLOB_LENGTH 2
#define HA_LEX_CREATE_TMP_TABLE 1
#define HA_CREATE_TMP_ALTER 8
#define HA_LEX_CREATE_TMP_TABLE 1U
#define HA_CREATE_TMP_ALTER 8U
#define HA_MAX_REC_LENGTH 65535
/* Table caching type */
#define HA_CACHE_TBL_NONTRANSACT 0
#define HA_CACHE_TBL_NOCACHE 1
#define HA_CACHE_TBL_ASKTRANSACT 2
#define HA_CACHE_TBL_TRANSACT 4
#define HA_CACHE_TBL_NOCACHE 1U
#define HA_CACHE_TBL_ASKTRANSACT 2U
#define HA_CACHE_TBL_TRANSACT 4U
/**
Options for the START TRANSACTION statement.
@ -409,9 +409,9 @@ static const uint MYSQL_START_TRANS_OPT_READ_ONLY = 2;
static const uint MYSQL_START_TRANS_OPT_READ_WRITE = 4;
/* Flags for method is_fatal_error */
#define HA_CHECK_DUP_KEY 1
#define HA_CHECK_DUP_UNIQUE 2
#define HA_CHECK_FK_ERROR 4
#define HA_CHECK_DUP_KEY 1U
#define HA_CHECK_DUP_UNIQUE 2U
#define HA_CHECK_FK_ERROR 4U
#define HA_CHECK_DUP (HA_CHECK_DUP_KEY + HA_CHECK_DUP_UNIQUE)
#define HA_CHECK_ALL (~0U)
@ -479,49 +479,49 @@ enum enum_binlog_command {
/* struct to hold information about the table that should be created */
/* Bits in used_fields */
#define HA_CREATE_USED_AUTO (1L << 0)
#define HA_CREATE_USED_RAID (1L << 1) //RAID is no longer availble
#define HA_CREATE_USED_UNION (1L << 2)
#define HA_CREATE_USED_INSERT_METHOD (1L << 3)
#define HA_CREATE_USED_MIN_ROWS (1L << 4)
#define HA_CREATE_USED_MAX_ROWS (1L << 5)
#define HA_CREATE_USED_AVG_ROW_LENGTH (1L << 6)
#define HA_CREATE_USED_PACK_KEYS (1L << 7)
#define HA_CREATE_USED_CHARSET (1L << 8)
#define HA_CREATE_USED_DEFAULT_CHARSET (1L << 9)
#define HA_CREATE_USED_DATADIR (1L << 10)
#define HA_CREATE_USED_INDEXDIR (1L << 11)
#define HA_CREATE_USED_ENGINE (1L << 12)
#define HA_CREATE_USED_CHECKSUM (1L << 13)
#define HA_CREATE_USED_DELAY_KEY_WRITE (1L << 14)
#define HA_CREATE_USED_ROW_FORMAT (1L << 15)
#define HA_CREATE_USED_COMMENT (1L << 16)
#define HA_CREATE_USED_PASSWORD (1L << 17)
#define HA_CREATE_USED_CONNECTION (1L << 18)
#define HA_CREATE_USED_KEY_BLOCK_SIZE (1L << 19)
#define HA_CREATE_USED_AUTO (1UL << 0)
#define HA_CREATE_USED_RAID (1UL << 1) //RAID is no longer availble
#define HA_CREATE_USED_UNION (1UL << 2)
#define HA_CREATE_USED_INSERT_METHOD (1UL << 3)
#define HA_CREATE_USED_MIN_ROWS (1UL << 4)
#define HA_CREATE_USED_MAX_ROWS (1UL << 5)
#define HA_CREATE_USED_AVG_ROW_LENGTH (1UL << 6)
#define HA_CREATE_USED_PACK_KEYS (1UL << 7)
#define HA_CREATE_USED_CHARSET (1UL << 8)
#define HA_CREATE_USED_DEFAULT_CHARSET (1UL << 9)
#define HA_CREATE_USED_DATADIR (1UL << 10)
#define HA_CREATE_USED_INDEXDIR (1UL << 11)
#define HA_CREATE_USED_ENGINE (1UL << 12)
#define HA_CREATE_USED_CHECKSUM (1UL << 13)
#define HA_CREATE_USED_DELAY_KEY_WRITE (1UL << 14)
#define HA_CREATE_USED_ROW_FORMAT (1UL << 15)
#define HA_CREATE_USED_COMMENT (1UL << 16)
#define HA_CREATE_USED_PASSWORD (1UL << 17)
#define HA_CREATE_USED_CONNECTION (1UL << 18)
#define HA_CREATE_USED_KEY_BLOCK_SIZE (1UL << 19)
/* The following two are used by Maria engine: */
#define HA_CREATE_USED_TRANSACTIONAL (1L << 20)
#define HA_CREATE_USED_PAGE_CHECKSUM (1L << 21)
#define HA_CREATE_USED_TRANSACTIONAL (1UL << 20)
#define HA_CREATE_USED_PAGE_CHECKSUM (1UL << 21)
/** This is set whenever STATS_PERSISTENT=0|1|default has been
specified in CREATE/ALTER TABLE. See also HA_OPTION_STATS_PERSISTENT in
include/my_base.h. It is possible to distinguish whether
STATS_PERSISTENT=default has been specified or no STATS_PERSISTENT= is
given at all. */
#define HA_CREATE_USED_STATS_PERSISTENT (1L << 22)
#define HA_CREATE_USED_STATS_PERSISTENT (1UL << 22)
/**
This is set whenever STATS_AUTO_RECALC=0|1|default has been
specified in CREATE/ALTER TABLE. See enum_stats_auto_recalc.
It is possible to distinguish whether STATS_AUTO_RECALC=default
has been specified or no STATS_AUTO_RECALC= is given at all.
*/
#define HA_CREATE_USED_STATS_AUTO_RECALC (1L << 23)
#define HA_CREATE_USED_STATS_AUTO_RECALC (1UL << 23)
/**
This is set whenever STATS_SAMPLE_PAGES=N|default has been
specified in CREATE/ALTER TABLE. It is possible to distinguish whether
STATS_SAMPLE_PAGES=default has been specified or no STATS_SAMPLE_PAGES= is
given at all.
*/
#define HA_CREATE_USED_STATS_SAMPLE_PAGES (1L << 24)
#define HA_CREATE_USED_STATS_SAMPLE_PAGES (1UL << 24)
/*
@ -615,8 +615,7 @@ struct xid_t {
}
uint length()
{
return sizeof(formatID)+sizeof(gtrid_length)+sizeof(bqual_length)+
gtrid_length+bqual_length;
return static_cast<uint>(sizeof(formatID)) + key_length();
}
uchar *key() const
{
@ -624,7 +623,8 @@ struct xid_t {
}
uint key_length() const
{
return sizeof(gtrid_length)+sizeof(bqual_length)+gtrid_length+bqual_length;
return static_cast<uint>(sizeof(gtrid_length)+sizeof(bqual_length)+
gtrid_length+bqual_length);
}
};
typedef struct xid_t XID;
@ -2333,12 +2333,13 @@ public:
/**
Whether or not all costs in the object are zero
@return true if all costs are zero, false otherwise
*/
bool is_zero() const
{
return !(io_count || cpu_cost || import_cost || mem_cost);
{
return io_count == 0.0 && cpu_cost == 0.0 &&
import_cost == 0.0 && mem_cost == 0.0;
}
void reset()
@ -2403,29 +2404,29 @@ void get_sweep_read_cost(TABLE *table, ha_rows nrows, bool interrupted,
The ranges may not use the full key but all of them will use the same number
of key parts.
*/
#define HA_MRR_SINGLE_POINT 1
#define HA_MRR_FIXED_KEY 2
#define HA_MRR_SINGLE_POINT 1U
#define HA_MRR_FIXED_KEY 2U
/*
Indicates that RANGE_SEQ_IF::next(&range) doesn't need to fill in the
'range' parameter.
*/
#define HA_MRR_NO_ASSOCIATION 4
#define HA_MRR_NO_ASSOCIATION 4U
/*
The MRR user will provide ranges in key order, and MRR implementation
must return rows in key order.
*/
#define HA_MRR_SORTED 8
#define HA_MRR_SORTED 8U
/* MRR implementation doesn't have to retrieve full records */
#define HA_MRR_INDEX_ONLY 16
#define HA_MRR_INDEX_ONLY 16U
/*
The passed memory buffer is of maximum possible size, the caller can't
assume larger buffer.
*/
#define HA_MRR_LIMITS 32
#define HA_MRR_LIMITS 32U
/*
@ -2434,14 +2435,14 @@ void get_sweep_read_cost(TABLE *table, ha_rows nrows, bool interrupted,
flag. SQL layer remembers the flag value and then passes it to
multi_read_range_init().
*/
#define HA_MRR_USE_DEFAULT_IMPL 64
#define HA_MRR_USE_DEFAULT_IMPL 64U
/*
Used only as parameter to multi_range_read_info():
Flag set <=> the caller guarantees that the bounds of the scanned ranges
will not have NULL values.
*/
#define HA_MRR_NO_NULL_ENDPOINTS 128
#define HA_MRR_NO_NULL_ENDPOINTS 128U
/*
The MRR user has materialized range keys somewhere in the user's buffer.
@ -2452,7 +2453,7 @@ void get_sweep_read_cost(TABLE *table, ha_rows nrows, bool interrupted,
pointer in range->start_key.key will point to a key value that will remain
there until the end of the MRR scan.
*/
#define HA_MRR_MATERIALIZED_KEYS 256
#define HA_MRR_MATERIALIZED_KEYS 256U
/*
The following bits are reserved for use by MRR implementation. The intended
@ -2470,15 +2471,15 @@ void get_sweep_read_cost(TABLE *table, ha_rows nrows, bool interrupted,
handler->multi_range_read_explain_info(mrr_mode) to get a text description
of the picked MRR scan; the description will be a part of EXPLAIN output.
*/
#define HA_MRR_IMPLEMENTATION_FLAG1 512
#define HA_MRR_IMPLEMENTATION_FLAG2 1024
#define HA_MRR_IMPLEMENTATION_FLAG3 2048
#define HA_MRR_IMPLEMENTATION_FLAG4 4096
#define HA_MRR_IMPLEMENTATION_FLAG5 8192
#define HA_MRR_IMPLEMENTATION_FLAG6 16384
#define HA_MRR_IMPLEMENTATION_FLAG1 512U
#define HA_MRR_IMPLEMENTATION_FLAG2 1024U
#define HA_MRR_IMPLEMENTATION_FLAG3 2048U
#define HA_MRR_IMPLEMENTATION_FLAG4 4096U
#define HA_MRR_IMPLEMENTATION_FLAG5 8192U
#define HA_MRR_IMPLEMENTATION_FLAG6 16384U
#define HA_MRR_IMPLEMENTATION_FLAGS \
(512 | 1024 | 2048 | 4096 | 8192 | 16384)
(512U | 1024U | 2048U | 4096U | 8192U | 16384U)
/*
This is a buffer area that the handler can use to store rows.
@ -2654,7 +2655,7 @@ public:
uint errkey; /* Last dup key */
uint key_used_on_scan;
uint active_index;
uint active_index, keyread;
/** Length of ref (1-8 or the clustered key length) */
uint ref_length;
@ -2696,7 +2697,6 @@ private:
public:
void set_time_tracker(Exec_time_tracker *tracker_arg) { tracker=tracker_arg;}
Item *pushed_idx_cond;
uint pushed_idx_cond_keyno; /* The index which the above condition is for */
@ -2751,7 +2751,7 @@ public:
check_table_binlog_row_based_result(0),
in_range_check_pushed_down(FALSE),
key_used_on_scan(MAX_KEY),
active_index(MAX_KEY),
active_index(MAX_KEY), keyread(MAX_KEY),
ref_length(sizeof(my_off_t)),
ft_handler(0), inited(NONE),
pushed_cond(0), next_insert_id(0), insert_id_for_cur_row(0),
@ -2856,6 +2856,22 @@ public:
int ha_delete_row(const uchar * buf);
void ha_release_auto_increment();
bool keyread_enabled() { return keyread < MAX_KEY; }
int ha_start_keyread(uint idx)
{
if (keyread_enabled())
return 0;
keyread= idx;
return extra(HA_EXTRA_KEYREAD);
}
int ha_end_keyread()
{
if (!keyread_enabled())
return 0;
keyread= MAX_KEY;
return extra(HA_EXTRA_NO_KEYREAD);
}
int check_collation_compatibility();
int ha_check_for_upgrade(HA_CHECK_OPT *check_opt);
/** to be actually called to get 'check()' functionality*/