summaryrefslogtreecommitdiff
path: root/sql/handler.h
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2017-03-01 08:27:39 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2017-03-07 19:07:27 +0200
commit89d80c1b0be94639d0913dee7b6a284c32787b09 (patch)
treea08340d45a09b067df4490259f68b5a3f9d2fa03 /sql/handler.h
parentd2f5e624223fe502ddf4c6f42062c29edb988627 (diff)
downloadmariadb-git-89d80c1b0be94639d0913dee7b6a284c32787b09.tar.gz
Fix many -Wconversion warnings.
Define my_thread_id as an unsigned type, to avoid mismatch with ulonglong. Change some parameters to this type. Use size_t in a few more places. Declare many flag constants as unsigned to avoid sign mismatch when shifting bits or applying the unary ~ operator. When applying the unary ~ operator to enum constants, explictly cast the result to an unsigned type, because enum constants can be treated as signed. In InnoDB, change the source code line number parameters from ulint to unsigned type. Also, make some InnoDB functions return a narrower type (unsigned or uint32_t instead of ulint; bool instead of ibool).
Diffstat (limited to 'sql/handler.h')
-rw-r--r--sql/handler.h157
1 files changed, 79 insertions, 78 deletions
diff --git a/sql/handler.h b/sql/handler.h
index 3e04cf7f7b5..0caa5f7c181 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -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)
@@ -478,49 +478,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)
/*
@@ -614,8 +614,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
{
@@ -623,7 +622,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;
@@ -2332,12 +2332,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()
@@ -2402,29 +2403,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
/*
@@ -2433,14 +2434,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.
@@ -2451,7 +2452,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
@@ -2469,15 +2470,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.