summaryrefslogtreecommitdiff
path: root/sql/handler.h
diff options
context:
space:
mode:
Diffstat (limited to 'sql/handler.h')
-rw-r--r--sql/handler.h413
1 files changed, 243 insertions, 170 deletions
diff --git a/sql/handler.h b/sql/handler.h
index 057a0e84125..a0a43daf144 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -25,7 +25,9 @@
#pragma interface /* gcc class implementation */
#endif
+#include <my_global.h> /* For handlers */
#include "sql_const.h"
+#include "sql_basic_types.h"
#include "mysqld.h" /* server_id */
#include "sql_plugin.h" /* plugin_ref, st_plugin_int, plugin */
#include "thr_lock.h" /* thr_lock_type, THR_LOCK_DATA */
@@ -42,6 +44,7 @@
#include <mysql/psi/mysql_table.h>
class Alter_info;
+class Virtual_column_info;
// the following is for checking tables
@@ -192,7 +195,7 @@ enum enum_alter_inplace_result {
#define HA_HAS_NEW_CHECKSUM (1ULL << 38)
#define HA_CAN_VIRTUAL_COLUMNS (1ULL << 39)
#define HA_MRR_CANT_SORT (1ULL << 40)
-#define HA_RECORD_MUST_BE_CLEAN_ON_WRITE (1ULL << 41)
+#define HA_RECORD_MUST_BE_CLEAN_ON_WRITE (1ULL << 41) /* unused */
/*
This storage engine supports condition pushdown
@@ -233,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
@@ -246,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
@@ -256,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
@@ -295,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.
@@ -338,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
@@ -366,17 +369,10 @@ enum enum_alter_inplace_result {
HA_GET_INFO does an implicit HA_ABORT_IF_LOCKED
*/
-#define HA_OPEN_KEYFILE 1
-#define HA_OPEN_RNDFILE 2
-#define HA_GET_INDEX 4
-#define HA_GET_INFO 8 /* do a ha_info() after open */
-#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_WAIT_IF_LOCKED 64 /* Wait if locked on open */
-#define HA_ABORT_IF_LOCKED 128 /* skip if locked on open.*/
-#define HA_BLOCK_LOCK 256 /* unlock when reading some records */
-#define HA_OPEN_TEMPORARY 512
+#define HA_TRY_READ_ONLY 32U
/* Some key definitions */
#define HA_KEY_NULL_LENGTH 1
@@ -388,16 +384,16 @@ enum enum_alter_inplace_result {
+(MAX_REF_PARTS \
*(HA_KEY_NULL_LENGTH + HA_KEY_BLOB_LENGTH)))
-#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.
@@ -419,9 +415,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)
@@ -488,49 +484,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)
/*
@@ -578,11 +574,11 @@ struct xid_t {
long bqual_length;
char data[XIDDATASIZE]; // not \0-terminated !
- xid_t() {} /* Remove gcc warning */
- bool eq(struct xid_t *xid)
- { return eq(xid->gtrid_length, xid->bqual_length, xid->data); }
- bool eq(long g, long b, const char *d)
- { return g == gtrid_length && b == bqual_length && !memcmp(d, data, g+b); }
+ xid_t() {} /* Remove gcc warning */
+ bool eq(struct xid_t *xid) const
+ { return !xid->is_null() && eq(xid->gtrid_length, xid->bqual_length, xid->data); }
+ bool eq(long g, long b, const char *d) const
+ { return !is_null() && g == gtrid_length && b == bqual_length && !memcmp(d, data, g+b); }
void set(struct xid_t *xid)
{ memcpy(this, xid, xid->length()); }
void set(long f, const char *g, long gl, const char *b, long bl)
@@ -624,8 +620,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
{
@@ -633,7 +628,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;
@@ -731,6 +727,7 @@ enum enum_schema_tables
SCH_ALL_PLUGINS,
SCH_APPLICABLE_ROLES,
SCH_CHARSETS,
+ SCH_CHECK_CONSTRAINTS,
SCH_COLLATIONS,
SCH_COLLATION_CHARACTER_SET_APPLICABILITY,
SCH_COLUMNS,
@@ -776,11 +773,11 @@ struct TABLE_SHARE;
struct HA_CREATE_INFO;
struct st_foreign_key_info;
typedef struct st_foreign_key_info FOREIGN_KEY_INFO;
-typedef bool (stat_print_fn)(THD *thd, const char *type, uint type_len,
- const char *file, uint file_len,
- const char *status, uint status_len);
+typedef bool (stat_print_fn)(THD *thd, const char *type, size_t type_len,
+ const char *file, size_t file_len,
+ const char *status, size_t status_len);
enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
-extern st_plugin_int *hton2plugin[MAX_HA];
+extern MYSQL_PLUGIN_IMPORT st_plugin_int *hton2plugin[MAX_HA];
/* Transaction log maintains type definitions */
enum log_status
@@ -1221,7 +1218,6 @@ struct handlerton
enum_binlog_command binlog_command,
const char *query, uint query_length,
const char *db, const char *table_name);
- int (*release_temporary_latches)(handlerton *hton, THD *thd);
/*
Get log status.
@@ -1663,6 +1659,7 @@ struct Schema_specification_st
- LIKE another_table_name ... // Copy structure from another table
- [AS] SELECT ... // Copy structure from a subquery
*/
+
struct Table_scope_and_contents_source_st
{
CHARSET_INFO *table_charset;
@@ -1678,6 +1675,8 @@ struct Table_scope_and_contents_source_st
ulong avg_row_length;
ulong used_fields;
ulong key_block_size;
+ ulong expression_length;
+ ulong field_check_constraints;
/*
number of pages to sample during
stats estimation, if used, otherwise 0.
@@ -1705,6 +1704,8 @@ struct Table_scope_and_contents_source_st
enum_stats_auto_recalc stats_auto_recalc;
bool varchar; ///< 1 if table has a VARCHAR
+ List<Virtual_column_info> *check_constraint_list;
+
/* the following three are only for ALTER TABLE, check_if_incompatible_data() */
ha_table_option_struct *option_struct; ///< structure with parsed table options
ha_field_option_struct **fields_option_struct; ///< array of field option structures
@@ -1862,37 +1863,49 @@ public:
attribute has really changed we might choose to set flag
pessimistically, for example, relying on parser output only.
*/
- typedef ulong HA_ALTER_FLAGS;
+ typedef ulonglong HA_ALTER_FLAGS;
// Add non-unique, non-primary index
- static const HA_ALTER_FLAGS ADD_INDEX = 1L << 0;
+ static const HA_ALTER_FLAGS ADD_INDEX = 1ULL << 0;
// Drop non-unique, non-primary index
- static const HA_ALTER_FLAGS DROP_INDEX = 1L << 1;
+ static const HA_ALTER_FLAGS DROP_INDEX = 1ULL << 1;
// Add unique, non-primary index
- static const HA_ALTER_FLAGS ADD_UNIQUE_INDEX = 1L << 2;
+ static const HA_ALTER_FLAGS ADD_UNIQUE_INDEX = 1ULL << 2;
// Drop unique, non-primary index
- static const HA_ALTER_FLAGS DROP_UNIQUE_INDEX = 1L << 3;
+ static const HA_ALTER_FLAGS DROP_UNIQUE_INDEX = 1ULL << 3;
// Add primary index
- static const HA_ALTER_FLAGS ADD_PK_INDEX = 1L << 4;
+ static const HA_ALTER_FLAGS ADD_PK_INDEX = 1ULL << 4;
// Drop primary index
- static const HA_ALTER_FLAGS DROP_PK_INDEX = 1L << 5;
-
- // Add column
- static const HA_ALTER_FLAGS ADD_COLUMN = 1L << 6;
+ static const HA_ALTER_FLAGS DROP_PK_INDEX = 1ULL << 5;
+
+ // Virtual generated column
+ static const HA_ALTER_FLAGS ADD_VIRTUAL_COLUMN = 1ULL << 6;
+ // Stored base (non-generated) column
+ static const HA_ALTER_FLAGS ADD_STORED_BASE_COLUMN = 1ULL << 7;
+ // Stored generated column
+ static const HA_ALTER_FLAGS ADD_STORED_GENERATED_COLUMN= 1ULL << 8;
+ // Add generic column (convience constant).
+ static const HA_ALTER_FLAGS ADD_COLUMN= ADD_VIRTUAL_COLUMN |
+ ADD_STORED_BASE_COLUMN |
+ ADD_STORED_GENERATED_COLUMN;
// Drop column
- static const HA_ALTER_FLAGS DROP_COLUMN = 1L << 7;
+ static const HA_ALTER_FLAGS DROP_VIRTUAL_COLUMN = 1ULL << 9;
+ static const HA_ALTER_FLAGS DROP_STORED_COLUMN = 1ULL << 10;
+ static const HA_ALTER_FLAGS DROP_COLUMN= DROP_VIRTUAL_COLUMN |
+ DROP_STORED_COLUMN;
// Rename column
- static const HA_ALTER_FLAGS ALTER_COLUMN_NAME = 1L << 8;
+ static const HA_ALTER_FLAGS ALTER_COLUMN_NAME = 1ULL << 11;
// Change column datatype
- static const HA_ALTER_FLAGS ALTER_COLUMN_TYPE = 1L << 9;
+ static const HA_ALTER_FLAGS ALTER_VIRTUAL_COLUMN_TYPE = 1ULL << 12;
+ static const HA_ALTER_FLAGS ALTER_STORED_COLUMN_TYPE = 1ULL << 13;
/**
Change column datatype in such way that new type has compatible
@@ -1900,79 +1913,99 @@ public:
possible to perform change by only updating data dictionary
without changing table rows.
*/
- static const HA_ALTER_FLAGS ALTER_COLUMN_EQUAL_PACK_LENGTH = 1L << 10;
+ static const HA_ALTER_FLAGS ALTER_COLUMN_EQUAL_PACK_LENGTH = 1ULL << 14;
+
+ // Reorder column
+ static const HA_ALTER_FLAGS ALTER_STORED_COLUMN_ORDER = 1ULL << 15;
// Reorder column
- static const HA_ALTER_FLAGS ALTER_COLUMN_ORDER = 1L << 11;
+ static const HA_ALTER_FLAGS ALTER_VIRTUAL_COLUMN_ORDER = 1ULL << 16;
// Change column from NOT NULL to NULL
- static const HA_ALTER_FLAGS ALTER_COLUMN_NULLABLE = 1L << 12;
+ static const HA_ALTER_FLAGS ALTER_COLUMN_NULLABLE = 1ULL << 17;
// Change column from NULL to NOT NULL
- static const HA_ALTER_FLAGS ALTER_COLUMN_NOT_NULLABLE = 1L << 13;
+ static const HA_ALTER_FLAGS ALTER_COLUMN_NOT_NULLABLE = 1ULL << 18;
// Set or remove default column value
- static const HA_ALTER_FLAGS ALTER_COLUMN_DEFAULT = 1L << 14;
+ static const HA_ALTER_FLAGS ALTER_COLUMN_DEFAULT = 1ULL << 19;
+ // Change column generation expression
+ static const HA_ALTER_FLAGS ALTER_VIRTUAL_GCOL_EXPR = 1ULL << 20;
+ static const HA_ALTER_FLAGS ALTER_STORED_GCOL_EXPR = 1ULL << 21;
+ //
// Add foreign key
- static const HA_ALTER_FLAGS ADD_FOREIGN_KEY = 1L << 15;
+ static const HA_ALTER_FLAGS ADD_FOREIGN_KEY = 1ULL << 22;
// Drop foreign key
- static const HA_ALTER_FLAGS DROP_FOREIGN_KEY = 1L << 16;
+ static const HA_ALTER_FLAGS DROP_FOREIGN_KEY = 1ULL << 23;
// table_options changed, see HA_CREATE_INFO::used_fields for details.
- static const HA_ALTER_FLAGS CHANGE_CREATE_OPTION = 1L << 17;
+ static const HA_ALTER_FLAGS CHANGE_CREATE_OPTION = 1ULL << 24;
// Table is renamed
- static const HA_ALTER_FLAGS ALTER_RENAME = 1L << 18;
+ static const HA_ALTER_FLAGS ALTER_RENAME = 1ULL << 25;
// column's engine options changed, something in field->option_struct
- static const HA_ALTER_FLAGS ALTER_COLUMN_OPTION = 1L << 19;
+ static const HA_ALTER_FLAGS ALTER_COLUMN_OPTION = 1ULL << 26;
// MySQL alias for the same thing:
- static const HA_ALTER_FLAGS ALTER_COLUMN_STORAGE_TYPE = 1L << 19;
+ static const HA_ALTER_FLAGS ALTER_COLUMN_STORAGE_TYPE = 1ULL << 26;
// Change the column format of column
- static const HA_ALTER_FLAGS ALTER_COLUMN_COLUMN_FORMAT = 1L << 20;
+ static const HA_ALTER_FLAGS ALTER_COLUMN_COLUMN_FORMAT = 1ULL << 27;
// Add partition
- static const HA_ALTER_FLAGS ADD_PARTITION = 1L << 21;
+ static const HA_ALTER_FLAGS ADD_PARTITION = 1ULL << 28;
// Drop partition
- static const HA_ALTER_FLAGS DROP_PARTITION = 1L << 22;
+ static const HA_ALTER_FLAGS DROP_PARTITION = 1ULL << 29;
// Changing partition options
- static const HA_ALTER_FLAGS ALTER_PARTITION = 1L << 23;
+ static const HA_ALTER_FLAGS ALTER_PARTITION = 1ULL << 30;
// Coalesce partition
- static const HA_ALTER_FLAGS COALESCE_PARTITION = 1L << 24;
+ static const HA_ALTER_FLAGS COALESCE_PARTITION = 1ULL << 31;
// Reorganize partition ... into
- static const HA_ALTER_FLAGS REORGANIZE_PARTITION = 1L << 25;
+ static const HA_ALTER_FLAGS REORGANIZE_PARTITION = 1ULL << 32;
// Reorganize partition
- static const HA_ALTER_FLAGS ALTER_TABLE_REORG = 1L << 26;
+ static const HA_ALTER_FLAGS ALTER_TABLE_REORG = 1ULL << 33;
// Remove partitioning
- static const HA_ALTER_FLAGS ALTER_REMOVE_PARTITIONING = 1L << 27;
+ static const HA_ALTER_FLAGS ALTER_REMOVE_PARTITIONING = 1ULL << 34;
// Partition operation with ALL keyword
- static const HA_ALTER_FLAGS ALTER_ALL_PARTITION = 1L << 28;
+ static const HA_ALTER_FLAGS ALTER_ALL_PARTITION = 1ULL << 35;
/**
Recreate the table for ALTER TABLE FORCE, ALTER TABLE ENGINE
and OPTIMIZE TABLE operations.
*/
- static const HA_ALTER_FLAGS RECREATE_TABLE = 1L << 29;
+ static const HA_ALTER_FLAGS RECREATE_TABLE = 1ULL << 36;
- // Virtual columns changed
- static const HA_ALTER_FLAGS ALTER_COLUMN_VCOL = 1L << 30;
+ /**
+ Changes in generated columns that affect storage,
+ for example, when a vcol type or expression changes
+ and this vcol is indexed or used in a partitioning expression
+ */
+ static const HA_ALTER_FLAGS ALTER_COLUMN_VCOL = 1ULL << 37;
/**
ALTER TABLE for a partitioned table. The engine needs to commit
online alter of all partitions atomically (using group_commit_ctx)
*/
- static const HA_ALTER_FLAGS ALTER_PARTITIONED = 1L << 31;
+ static const HA_ALTER_FLAGS ALTER_PARTITIONED = 1ULL << 38;
+
+ static const HA_ALTER_FLAGS ALTER_ADD_CHECK_CONSTRAINT = 1ULL << 39;
+
+ static const HA_ALTER_FLAGS ALTER_DROP_CHECK_CONSTRAINT= 1ULL << 40;
+
+ /**
+ Change in index length such that it doesn't require index rebuild.
+ */
+ static const HA_ALTER_FLAGS ALTER_COLUMN_INDEX_LENGTH= 1ULL << 41;
/**
Create options (like MAX_ROWS) for the new version of table.
@@ -2328,12 +2361,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()
@@ -2398,29 +2432,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
/*
@@ -2429,14 +2463,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.
@@ -2447,7 +2481,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
@@ -2465,15 +2499,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.
@@ -2623,11 +2657,6 @@ public:
RANGE_SEQ_IF mrr_funcs; /* Range sequence traversal functions */
HANDLER_BUFFER *multi_range_buffer; /* MRR buffer info */
uint ranges_in_seq; /* Total number of ranges in the traversed sequence */
- /* TRUE <=> source MRR ranges and the output are ordered */
- bool mrr_is_output_sorted;
-
- /** TRUE <=> we're currently traversing a range in mrr_cur_range. */
- bool mrr_have_range;
/** Current range (the one we're now returning rows from) */
KEY_MULTI_RANGE mrr_cur_range;
@@ -2635,23 +2664,32 @@ public:
key_range save_end_range, *end_range;
KEY_PART_INFO *range_key_part;
int key_compare_result_on_equal;
- bool eq_range;
- bool internal_tmp_table; /* If internal tmp table */
- uint errkey; /* Last dup key */
- uint key_used_on_scan;
- uint active_index;
+ /* TRUE <=> source MRR ranges and the output are ordered */
+ bool mrr_is_output_sorted;
+ /** TRUE <=> we're currently traversing a range in mrr_cur_range. */
+ bool mrr_have_range;
+ bool eq_range;
+ bool internal_tmp_table; /* If internal tmp table */
+ bool implicit_emptied; /* Can be !=0 only if HEAP */
+ bool mark_trx_read_write_done; /* mark_trx_read_write was called */
+ bool check_table_binlog_row_based_done; /* check_table_binlog.. was called */
+ bool check_table_binlog_row_based_result; /* cached check_table_binlog... */
/*
TRUE <=> the engine guarantees that returned records are within the range
being scanned.
*/
bool in_range_check_pushed_down;
+ uint errkey; /* Last dup key */
+ uint key_used_on_scan;
+ uint active_index, keyread;
+
/** Length of ref (1-8 or the clustered key length) */
uint ref_length;
FT_INFO *ft_handler;
enum {NONE=0, INDEX, RND} inited;
- bool implicit_emptied; /* Can be !=0 only if HEAP */
+
const COND *pushed_cond;
/**
next_insert_id is the next value which should be inserted into the
@@ -2687,7 +2725,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 */
@@ -2735,11 +2772,16 @@ public:
handler(handlerton *ht_arg, TABLE_SHARE *share_arg)
:table_share(share_arg), table(0),
estimation_rows_to_insert(0), ht(ht_arg),
- ref(0), end_range(NULL), key_used_on_scan(MAX_KEY), active_index(MAX_KEY),
+ ref(0), end_range(NULL),
+ implicit_emptied(0),
+ mark_trx_read_write_done(0),
+ check_table_binlog_row_based_done(0),
+ check_table_binlog_row_based_result(0),
in_range_check_pushed_down(FALSE),
+ key_used_on_scan(MAX_KEY),
+ active_index(MAX_KEY), keyread(MAX_KEY),
ref_length(sizeof(my_off_t)),
ft_handler(0), inited(NONE),
- implicit_emptied(0),
pushed_cond(0), next_insert_id(0), insert_id_for_cur_row(0),
tracker(NULL),
pushed_idx_cond(NULL),
@@ -2842,6 +2884,21 @@ 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)
+ {
+ int res= keyread_enabled() ? 0 : extra_opt(HA_EXTRA_KEYREAD, idx);
+ keyread= idx;
+ return res;
+ }
+ 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*/
@@ -2958,7 +3015,6 @@ public:
virtual const key_map *keys_to_use_for_scanning() { return &key_map_empty; }
bool has_transactions()
{ return (ha_table_flags() & HA_NO_TRANSACTIONS) == 0; }
- virtual uint extra_rec_buf_length() const { return 0; }
/**
This method is used to analyse the error to see whether the error
@@ -3171,7 +3227,7 @@ public:
virtual int read_range_next();
void set_end_range(const key_range *end_key);
int compare_key(key_range *range);
- int compare_key2(key_range *range);
+ int compare_key2(key_range *range) const;
virtual int ft_init() { return HA_ERR_WRONG_COMMAND; }
void ft_end() { ft_handler=NULL; }
virtual FT_INFO *ft_init_ext(uint flags, uint inx,String *key)
@@ -3235,7 +3291,7 @@ public:
uint part_id);
virtual int extra(enum ha_extra_function operation)
{ return 0; }
- virtual int extra_opt(enum ha_extra_function operation, ulong cache_size)
+ virtual int extra_opt(enum ha_extra_function operation, ulong arg)
{ return extra(operation); }
/**
@@ -3886,25 +3942,10 @@ public:
}
LEX_STRING *engine_name() { return hton_name(ht); }
-
- /*
- @brief
- Check whether the engine supports virtual columns
-
- @retval
- FALSE if the engine does not support virtual columns
- @retval
- TRUE if the engine supports virtual columns
- */
-
- virtual bool check_if_supported_virtual_columns(void) { return FALSE;}
TABLE* get_table() { return table; }
TABLE_SHARE* get_table_share() { return table_share; }
protected:
- /* deprecated, don't use in new engines */
- inline void ha_statistic_increment(ulong SSV::*offset) const { }
-
/* Service methods for use by storage engines. */
void **ha_data(THD *) const;
THD *ha_thd(void) const;
@@ -3929,13 +3970,36 @@ protected:
*/
virtual int delete_table(const char *name);
+public:
+ inline bool check_table_binlog_row_based(bool binlog_row);
+ inline void clear_cached_table_binlog_row_based_flag()
+ {
+ check_table_binlog_row_based_done= 0;
+ check_table_binlog_row_based_result= 0;
+ }
private:
- /* Private helpers */
- inline void mark_trx_read_write();
-private:
+ /* Cache result to avoid extra calls */
+ inline void mark_trx_read_write()
+ {
+ if (unlikely(!mark_trx_read_write_done))
+ {
+ mark_trx_read_write_done= 1;
+ mark_trx_read_write_internal();
+ }
+ }
+ void mark_trx_read_write_internal();
+ bool check_table_binlog_row_based_internal(bool binlog_row);
+
+protected:
+ /*
+ These are intended to be used only by handler::ha_xxxx() functions
+ However, engines that implement read_range_XXX() (like MariaRocks)
+ or embed other engines (like ha_partition) may need to call these also
+ */
inline void increment_statistics(ulong SSV::*offset) const;
inline void decrement_statistics(ulong SSV::*offset) const;
+private:
/*
Low-level primitives for storage engines. These should be
overridden by the storage engine class. To call these methods, use
@@ -4260,9 +4324,6 @@ int ha_change_key_cache_param(KEY_CACHE *key_cache);
int ha_repartition_key_cache(KEY_CACHE *key_cache);
int ha_change_key_cache(KEY_CACHE *old_key_cache, KEY_CACHE *new_key_cache);
-/* report to InnoDB that control passes to the client */
-int ha_release_temporary_latches(THD *thd);
-
/* transactions: interface to handlerton functions */
int ha_start_consistent_snapshot(THD *thd);
int ha_commit_or_rollback_by_xid(XID *xid, bool commit);
@@ -4326,4 +4387,16 @@ void print_keydup_error(TABLE *table, KEY *key, myf errflag);
int del_global_index_stat(THD *thd, TABLE* table, KEY* key_info);
int del_global_table_stat(THD *thd, LEX_STRING *db, LEX_STRING *table);
+#ifndef DBUG_OFF
+/** Converts XID to string.
+
+@param[out] buf output buffer
+@param[in] xid XID to convert
+
+@return pointer to converted string
+
+@note This does not need to be multi-byte safe or anything */
+char *xid_to_str(char *buf, const XID &xid);
+#endif // !DBUG_OFF
+
#endif /* HANDLER_INCLUDED */