diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/create_options.cc | 4 | ||||
-rw-r--r-- | sql/field.h | 56 | ||||
-rw-r--r-- | sql/handler.h | 157 | ||||
-rw-r--r-- | sql/item.h | 21 | ||||
-rw-r--r-- | sql/item_sum.cc | 2 | ||||
-rw-r--r-- | sql/log.cc | 21 | ||||
-rw-r--r-- | sql/log.h | 16 | ||||
-rw-r--r-- | sql/log_event.cc | 4 | ||||
-rw-r--r-- | sql/log_event.h | 8 | ||||
-rw-r--r-- | sql/log_slow.h | 31 | ||||
-rw-r--r-- | sql/mysqld.cc | 2 | ||||
-rw-r--r-- | sql/mysqld.h | 24 | ||||
-rw-r--r-- | sql/session_tracker.h | 4 | ||||
-rw-r--r-- | sql/sql_acl.h | 61 | ||||
-rw-r--r-- | sql/sql_audit.h | 3 | ||||
-rw-r--r-- | sql/sql_base.cc | 6 | ||||
-rw-r--r-- | sql/sql_class.h | 9 | ||||
-rw-r--r-- | sql/sql_cte.cc | 2 | ||||
-rw-r--r-- | sql/sql_error.h | 3 | ||||
-rw-r--r-- | sql/sql_lex.h | 6 | ||||
-rw-r--r-- | sql/sql_plugin.h | 20 | ||||
-rw-r--r-- | sql/sql_select.h | 16 | ||||
-rw-r--r-- | sql/sql_string.h | 10 | ||||
-rw-r--r-- | sql/sql_table.cc | 4 | ||||
-rw-r--r-- | sql/sql_table.h | 3 | ||||
-rw-r--r-- | sql/sql_trigger.h | 5 | ||||
-rw-r--r-- | sql/structs.h | 37 | ||||
-rw-r--r-- | sql/sys_vars.cc | 2 | ||||
-rw-r--r-- | sql/table.h | 56 |
29 files changed, 310 insertions, 283 deletions
diff --git a/sql/create_options.cc b/sql/create_options.cc index 40382c7887e..7edc2cb95f2 100644 --- a/sql/create_options.cc +++ b/sql/create_options.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2010 Monty Program Ab +/* Copyright (C) 2010, 2017, MariaDB Corporation 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 @@ -23,7 +23,7 @@ #include <my_getopt.h> #include "set_var.h" -#define FRM_QUOTED_VALUE 0x8000 +#define FRM_QUOTED_VALUE 0x8000U /** Links this item to the given list end diff --git a/sql/field.h b/sql/field.h index 77556416465..63f7d1fa57d 100644 --- a/sql/field.h +++ b/sql/field.h @@ -1,7 +1,7 @@ #ifndef FIELD_INCLUDED #define FIELD_INCLUDED /* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2008, 2015, MariaDB + Copyright (c) 2008, 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 as published by @@ -1019,7 +1019,7 @@ public: virtual int cmp_max(const uchar *a, const uchar *b, uint max_len) { return cmp(a, b); } virtual int cmp(const uchar *,const uchar *)=0; - virtual int cmp_binary(const uchar *a,const uchar *b, uint32 max_length=~0L) + virtual int cmp_binary(const uchar *a,const uchar *b, uint32 max_length=~0U) { return memcmp(a,b,pack_length()); } virtual int cmp_offset(uint row_offset) { return cmp(ptr,ptr+row_offset); } @@ -1370,7 +1370,8 @@ public: void set_storage_type(ha_storage_media storage_type_arg) { DBUG_ASSERT(field_storage_type() == HA_SM_DEFAULT); - flags |= (storage_type_arg << FIELD_FLAGS_STORAGE_MEDIA); + flags |= static_cast<uint32>(storage_type_arg) << + FIELD_FLAGS_STORAGE_MEDIA; } column_format_type column_format() const @@ -1382,7 +1383,8 @@ public: void set_column_format(column_format_type column_format_arg) { DBUG_ASSERT(column_format() == COLUMN_FORMAT_TYPE_DEFAULT); - flags |= (column_format_arg << FIELD_FLAGS_COLUMN_FORMAT); + flags |= static_cast<uint32>(column_format_arg) << + FIELD_FLAGS_COLUMN_FORMAT; } /* @@ -3131,7 +3133,7 @@ public: int cmp_max(const uchar *, const uchar *, uint max_length); int cmp(const uchar *a,const uchar *b) { - return cmp_max(a, b, ~0L); + return cmp_max(a, b, ~0U); } void sort_string(uchar *buff,uint length); uint get_key_image(uchar *buff,uint length, imagetype type); @@ -3140,7 +3142,7 @@ public: virtual uchar *pack(uchar *to, const uchar *from, uint max_length); virtual const uchar *unpack(uchar* to, const uchar *from, const uchar *from_end, uint param_data); - int cmp_binary(const uchar *a,const uchar *b, uint32 max_length=~0L); + int cmp_binary(const uchar *a,const uchar *b, uint32 max_length=~0U); int key_cmp(const uchar *,const uchar*); int key_cmp(const uchar *str, uint length); uint packed_col_length(const uchar *to, uint length); @@ -3250,9 +3252,9 @@ public: my_decimal *val_decimal(my_decimal *); int cmp_max(const uchar *, const uchar *, uint max_length); int cmp(const uchar *a,const uchar *b) - { return cmp_max(a, b, ~0L); } + { return cmp_max(a, b, ~0U); } int cmp(const uchar *a, uint32 a_length, const uchar *b, uint32 b_length); - int cmp_binary(const uchar *a,const uchar *b, uint32 max_length=~0L); + int cmp_binary(const uchar *a,const uchar *b, uint32 max_length=~0U); int key_cmp(const uchar *,const uchar*); int key_cmp(const uchar *str, uint length); /* Never update the value of min_val for a blob field */ @@ -3878,7 +3880,7 @@ public: bool sp_prepare_create_field(THD *thd, MEM_ROOT *mem_root); - bool prepare_create_field(uint *blob_columns, longlong table_flags); + bool prepare_create_field(uint *blob_columns, ulonglong table_flags); bool check(THD *thd); @@ -4028,26 +4030,26 @@ bool check_expression(Virtual_column_info *vcol, const char *name, The following are for the interface with the .frm file */ -#define FIELDFLAG_DECIMAL 1 -#define FIELDFLAG_BINARY 1 // Shares same flag -#define FIELDFLAG_NUMBER 2 -#define FIELDFLAG_ZEROFILL 4 -#define FIELDFLAG_PACK 120 // Bits used for packing -#define FIELDFLAG_INTERVAL 256 // mangled with decimals! -#define FIELDFLAG_BITFIELD 512 // mangled with decimals! -#define FIELDFLAG_BLOB 1024 // mangled with decimals! -#define FIELDFLAG_GEOM 2048 // mangled with decimals! - -#define FIELDFLAG_TREAT_BIT_AS_CHAR 4096 /* use Field_bit_as_char */ -#define FIELDFLAG_LONG_DECIMAL 8192 -#define FIELDFLAG_NO_DEFAULT 16384 /* sql */ -#define FIELDFLAG_MAYBE_NULL ((uint) 32768)// sql -#define FIELDFLAG_HEX_ESCAPE ((uint) 0x10000) +#define FIELDFLAG_DECIMAL 1U +#define FIELDFLAG_BINARY 1U // Shares same flag +#define FIELDFLAG_NUMBER 2U +#define FIELDFLAG_ZEROFILL 4U +#define FIELDFLAG_PACK 120U // Bits used for packing +#define FIELDFLAG_INTERVAL 256U // mangled with decimals! +#define FIELDFLAG_BITFIELD 512U // mangled with decimals! +#define FIELDFLAG_BLOB 1024U // mangled with decimals! +#define FIELDFLAG_GEOM 2048U // mangled with decimals! + +#define FIELDFLAG_TREAT_BIT_AS_CHAR 4096U /* use Field_bit_as_char */ +#define FIELDFLAG_LONG_DECIMAL 8192U +#define FIELDFLAG_NO_DEFAULT 16384U /* sql */ +#define FIELDFLAG_MAYBE_NULL 32768U // sql +#define FIELDFLAG_HEX_ESCAPE 0x10000U #define FIELDFLAG_PACK_SHIFT 3 #define FIELDFLAG_DEC_SHIFT 8 -#define FIELDFLAG_MAX_DEC 63 +#define FIELDFLAG_MAX_DEC 63U -#define MTYP_TYPENR(type) (type & 127) /* Remove bits from type */ +#define MTYP_TYPENR(type) (type & 127U) /* Remove bits from type */ #define f_is_dec(x) ((x) & FIELDFLAG_DECIMAL) #define f_is_num(x) ((x) & FIELDFLAG_NUMBER) @@ -4061,7 +4063,7 @@ bool check_expression(Virtual_column_info *vcol, const char *name, #define f_is_bitfield(x) (((x) & (FIELDFLAG_BITFIELD | FIELDFLAG_NUMBER)) == FIELDFLAG_BITFIELD) #define f_is_blob(x) (((x) & (FIELDFLAG_BLOB | FIELDFLAG_NUMBER)) == FIELDFLAG_BLOB) #define f_is_geom(x) (((x) & (FIELDFLAG_GEOM | FIELDFLAG_NUMBER)) == FIELDFLAG_GEOM) -#define f_settype(x) (((int) (x)) << FIELDFLAG_PACK_SHIFT) +#define f_settype(x) (((uint) (x)) << FIELDFLAG_PACK_SHIFT) #define f_maybe_null(x) ((x) & FIELDFLAG_MAYBE_NULL) #define f_no_default(x) ((x) & FIELDFLAG_NO_DEFAULT) #define f_bit_as_char(x) ((x) & FIELDFLAG_TREAT_BIT_AS_CHAR) 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. diff --git a/sql/item.h b/sql/item.h index 3908fe20aa1..1c8c5e99426 100644 --- a/sql/item.h +++ b/sql/item.h @@ -2,7 +2,7 @@ #define SQL_ITEM_INCLUDED /* Copyright (c) 2000, 2015, 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 as published by @@ -96,6 +96,13 @@ enum precedence { typedef Bounds_checked_array<Item*> Ref_ptr_array; +static inline uint32 +char_to_byte_length_safe(size_t char_length_arg, uint32 mbmaxlen_arg) +{ + ulonglong tmp= ((ulonglong) char_length_arg) * mbmaxlen_arg; + return tmp > UINT_MAX32 ? UINT_MAX32 : static_cast<uint32>(tmp); +} + bool mark_unsupported_function(const char *where, void *store, uint result); /* convenience helper for mark_unsupported_function() above */ @@ -403,7 +410,7 @@ class Copy_query_with_rewrite bool copy_up_to(size_t bytes) { DBUG_ASSERT(bytes >= from); - return dst->append(src + from, bytes - from); + return dst->append(src + from, uint32(bytes - from)); } public: @@ -1694,6 +1701,16 @@ public: bool eq_by_collation(Item *item, bool binary_cmp, CHARSET_INFO *cs); bool too_big_for_varchar() const { return max_char_length() > CONVERT_IF_BIGGER_TO_BLOB; } + void fix_length_and_charset(uint32 max_char_length_arg, CHARSET_INFO *cs) + { + max_length= char_to_byte_length_safe(max_char_length_arg, cs->mbmaxlen); + collation.collation= cs; + } + void fix_char_length(size_t max_char_length_arg) + { + max_length= char_to_byte_length_safe(max_char_length_arg, + collation.collation->mbmaxlen); + } /* Return TRUE if the item points to a column of an outer-joined table. */ diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 07755d6b434..81bafaf6faf 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -3462,7 +3462,7 @@ Item_func_group_concat::fix_fields(THD *thd, Item **ref) args[i]->fix_fields(thd, args + i)) || args[i]->check_cols(1)) return TRUE; - with_subselect|= args[i]->with_subselect; + with_subselect|= args[i]->with_subselect; } /* skip charset aggregation for order columns */ diff --git a/sql/log.cc b/sql/log.cc index 23326532388..7ad9790bb13 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1,5 +1,5 @@ /* 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 as published by @@ -646,7 +646,7 @@ void Log_to_csv_event_handler::cleanup() bool Log_to_csv_event_handler:: log_general(THD *thd, my_hrtime_t event_time, const char *user_host, - uint user_host_len, int thread_id_arg, + uint user_host_len, my_thread_id thread_id_arg, const char *command_type, uint command_type_len, const char *sql_text, uint sql_text_len, CHARSET_INFO *client_cs) @@ -1056,7 +1056,7 @@ bool Log_to_file_event_handler:: bool Log_to_file_event_handler:: log_general(THD *thd, my_hrtime_t event_time, const char *user_host, - uint user_host_len, int thread_id_arg, + uint user_host_len, my_thread_id thread_id_arg, const char *command_type, uint command_type_len, const char *sql_text, uint sql_text_len, CHARSET_INFO *client_cs) @@ -2850,12 +2850,11 @@ void MYSQL_QUERY_LOG::reopen_file() */ bool MYSQL_QUERY_LOG::write(time_t event_time, const char *user_host, - uint user_host_len, int thread_id_arg, + uint user_host_len, my_thread_id thread_id_arg, const char *command_type, uint command_type_len, const char *sql_text, uint sql_text_len) { char buff[32]; - uint length= 0; char local_time_buff[MAX_TIME_SIZE]; struct tm start; uint time_buff_len= 0; @@ -2889,7 +2888,7 @@ bool MYSQL_QUERY_LOG::write(time_t event_time, const char *user_host, goto err; /* command_type, thread_id */ - length= my_snprintf(buff, 32, "%5ld ", (long) thread_id_arg); + size_t length= my_snprintf(buff, 32, "%5llu ", thread_id_arg); if (my_b_write(&log_file, (uchar*) buff, length)) goto err; @@ -2973,7 +2972,7 @@ bool MYSQL_QUERY_LOG::write(THD *thd, time_t current_time, int tmp_errno= 0; char buff[80], *end; char query_time_buff[22+7], lock_time_buff[22+7]; - uint buff_len; + size_t buff_len; end= buff; if (!(specialflag & SPECIAL_SHORT_LOG_FORMAT)) @@ -10244,8 +10243,8 @@ IO_CACHE * get_trans_log(THD * thd) if (cache_mngr) return cache_mngr->get_binlog_cache_log(true); - WSREP_DEBUG("binlog cache not initialized, conn: %lld", - (longlong) thd->thread_id); + WSREP_DEBUG("binlog cache not initialized, conn: %llu", + thd->thread_id); return NULL; } @@ -10283,8 +10282,8 @@ void thd_binlog_trx_reset(THD * thd) void thd_binlog_rollback_stmt(THD * thd) { - WSREP_DEBUG("thd_binlog_rollback_stmt connection: %lld", - (longlong) thd->thread_id); + WSREP_DEBUG("thd_binlog_rollback_stmt connection: %llu", + thd->thread_id); binlog_cache_mngr *const cache_mngr= (binlog_cache_mngr*) thd_get_ha_data(thd, binlog_hton); if (cache_mngr) diff --git a/sql/log.h b/sql/log.h index 8ddf8641cfa..f1a025edfb9 100644 --- a/sql/log.h +++ b/sql/log.h @@ -1,5 +1,5 @@ /* Copyright (c) 2005, 2016, Oracle and/or its affiliates. - Copyright (c) 2009, 2016, Monty Program Ab + 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 as published by @@ -287,9 +287,9 @@ typedef struct st_log_info #define MAX_LOG_HANDLERS_NUM 3 /* log event handler flags */ -#define LOG_NONE 1 -#define LOG_FILE 2 -#define LOG_TABLE 4 +#define LOG_NONE 1U +#define LOG_FILE 2U +#define LOG_TABLE 4U class Log_event; class Rows_log_event; @@ -355,7 +355,7 @@ public: MYSQL_QUERY_LOG() : last_time(0) {} void reopen_file(); bool write(time_t event_time, const char *user_host, - uint user_host_len, int thread_id, + uint user_host_len, my_thread_id thread_id, const char *command_type, uint command_type_len, const char *sql_text, uint sql_text_len); bool write(THD *thd, time_t current_time, @@ -907,7 +907,7 @@ public: virtual bool log_error(enum loglevel level, const char *format, va_list args)= 0; virtual bool log_general(THD *thd, my_hrtime_t event_time, const char *user_host, - uint user_host_len, int thread_id, + uint user_host_len, my_thread_id thread_id, const char *command_type, uint command_type_len, const char *sql_text, uint sql_text_len, CHARSET_INFO *client_cs)= 0; @@ -936,7 +936,7 @@ public: virtual bool log_error(enum loglevel level, const char *format, va_list args); virtual bool log_general(THD *thd, my_hrtime_t event_time, const char *user_host, - uint user_host_len, int thread_id, + uint user_host_len, my_thread_id thread_id, const char *command_type, uint command_type_len, const char *sql_text, uint sql_text_len, CHARSET_INFO *client_cs); @@ -968,7 +968,7 @@ public: virtual bool log_error(enum loglevel level, const char *format, va_list args); virtual bool log_general(THD *thd, my_hrtime_t event_time, const char *user_host, - uint user_host_len, int thread_id, + uint user_host_len, my_thread_id thread_id, const char *command_type, uint command_type_len, const char *sql_text, uint sql_text_len, CHARSET_INFO *client_cs); diff --git a/sql/log_event.cc b/sql/log_event.cc index 291b550353d..69d0f52d211 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -2894,8 +2894,8 @@ log_event_print_value(IO_CACHE *file, const uchar *ptr, case 2: { strmake(typestr, "ENUM(2 bytes)", typestr_length); - if (!ptr) - goto return_null; + if (!ptr) + goto return_null; int32 i32= uint2korr(ptr); my_b_printf(file, "%d", i32); diff --git a/sql/log_event.h b/sql/log_event.h index c2829a9bb10..5689d36aea8 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2014, Oracle and/or its affiliates. - Copyright (c) 2009, 2014, Monty Program Ab. + 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 as published by @@ -828,7 +828,7 @@ typedef struct st_print_event_info char time_zone_str[MAX_TIME_ZONE_NAME_LENGTH]; uint lc_time_names_number; uint charset_database_number; - uint thread_id; + my_thread_id thread_id; bool thread_id_printed; uint32 server_id; bool server_id_printed; @@ -2008,7 +2008,7 @@ public: uint32 q_len; uint32 db_len; uint16 error_code; - ulong thread_id; + my_thread_id thread_id; /* For events created by Query_log_event::do_apply_event (and Load_log_event::do_apply_event()) we need the *original* thread @@ -2435,7 +2435,7 @@ public: void print_query(THD *thd, bool need_db, const char *cs, String *buf, my_off_t *fn_start, my_off_t *fn_end, const char *qualify_db); - ulong thread_id; + my_thread_id thread_id; ulong slave_proxy_id; uint32 table_name_len; /* diff --git a/sql/log_slow.h b/sql/log_slow.h index 3ae2060cc27..c641d2be87d 100644 --- a/sql/log_slow.h +++ b/sql/log_slow.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2009 Monty Program Ab +/* 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 as published by @@ -16,23 +16,22 @@ /* Defining what to log to slow log */ #define LOG_SLOW_VERBOSITY_INIT 0 -#define LOG_SLOW_VERBOSITY_INNODB (1 << 0) -#define LOG_SLOW_VERBOSITY_QUERY_PLAN (1 << 1) -#define LOG_SLOW_VERBOSITY_EXPLAIN (1 << 2) +#define LOG_SLOW_VERBOSITY_INNODB (1U << 0) +#define LOG_SLOW_VERBOSITY_QUERY_PLAN (1U << 1) +#define LOG_SLOW_VERBOSITY_EXPLAIN (1U << 2) #define QPLAN_INIT QPLAN_QC_NO -#define QPLAN_ADMIN (1 << 0) -#define QPLAN_FILESORT (1 << 1) -#define QPLAN_FILESORT_DISK (1 << 2) -#define QPLAN_FULL_JOIN (1 << 3) -#define QPLAN_FULL_SCAN (1 << 4) -#define QPLAN_QC (1 << 5) -#define QPLAN_QC_NO (1 << 6) -#define QPLAN_TMP_DISK (1 << 7) -#define QPLAN_TMP_TABLE (1 << 8) -#define QPLAN_FILESORT_PRIORITY_QUEUE (1 << 9) +#define QPLAN_ADMIN (1U << 0) +#define QPLAN_FILESORT (1U << 1) +#define QPLAN_FILESORT_DISK (1U << 2) +#define QPLAN_FULL_JOIN (1U << 3) +#define QPLAN_FULL_SCAN (1U << 4) +#define QPLAN_QC (1U << 5) +#define QPLAN_QC_NO (1U << 6) +#define QPLAN_TMP_DISK (1U << 7) +#define QPLAN_TMP_TABLE (1U << 8) +#define QPLAN_FILESORT_PRIORITY_QUEUE (1U << 9) /* ... */ -#define QPLAN_MAX (((ulong) 1) << 31) /* reserved as placeholder */ - +#define QPLAN_MAX (1UL << 31) /* reserved as placeholder */ diff --git a/sql/mysqld.cc b/sql/mysqld.cc index f639a357880..8fb2cb04b92 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -8762,7 +8762,7 @@ static int mysql_init_variables(void) mysql_home_ptr= mysql_home; log_error_file_ptr= log_error_file; protocol_version= PROTOCOL_VERSION; - what_to_log= ~ (1L << (uint) COM_TIME); + what_to_log= ~(1UL << COM_TIME); denied_connections= 0; executed_events= 0; global_query_id= 1; diff --git a/sql/mysqld.h b/sql/mysqld.h index 9022b8cef03..8f74194181a 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -1,5 +1,5 @@ /* Copyright (c) 2006, 2016, Oracle and/or its affiliates. - Copyright (c) 2010, 2016, MariaDB + Copyright (c) 2010, 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 as published by @@ -49,16 +49,16 @@ typedef Bitmap<((MAX_INDEXES+7)/8*8)> key_map; /* Used for finding keys */ #endif /* Bits from testflag */ -#define TEST_PRINT_CACHED_TABLES 1 -#define TEST_NO_KEY_GROUP 2 -#define TEST_MIT_THREAD 4 -#define TEST_BLOCKING 8 -#define TEST_KEEP_TMP_TABLES 16 -#define TEST_READCHECK 64 /**< Force use of readcheck */ -#define TEST_NO_EXTRA 128 -#define TEST_CORE_ON_SIGNAL 256 /**< Give core if signal */ -#define TEST_SIGINT 1024 /**< Allow sigint on threads */ -#define TEST_SYNCHRONIZATION 2048 /**< get server to do sleep in +#define TEST_PRINT_CACHED_TABLES 1U +#define TEST_NO_KEY_GROUP 2U +#define TEST_MIT_THREAD 4U +#define TEST_BLOCKING 8U +#define TEST_KEEP_TMP_TABLES 16U +#define TEST_READCHECK 64U /**< Force use of readcheck */ +#define TEST_NO_EXTRA 128U +#define TEST_CORE_ON_SIGNAL 256U /**< Give core if signal */ +#define TEST_SIGINT 1024U /**< Allow sigint on threads */ +#define TEST_SYNCHRONIZATION 2048U /**< get server to do sleep in some places */ /* Keep things compatible */ @@ -721,7 +721,7 @@ inline query_id_t get_query_id() /* increment global_thread_id and return it. */ inline __attribute__((warn_unused_result)) my_thread_id next_thread_id() { - return my_atomic_add64_explicit(&global_thread_id, 1, MY_MEMORY_ORDER_RELAXED); + return my_atomic_add64_explicit((int64*) &global_thread_id, 1, MY_MEMORY_ORDER_RELAXED); } #if defined(MYSQL_DYNAMIC_PLUGIN) && defined(_WIN32) diff --git a/sql/session_tracker.h b/sql/session_tracker.h index 3f73b5dc705..684692aae0c 100644 --- a/sql/session_tracker.h +++ b/sql/session_tracker.h @@ -2,7 +2,7 @@ #define SESSION_TRACKER_INCLUDED /* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - Copyright (c) 2016, MariaDB + Copyright (c) 2016, 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 as published by @@ -280,7 +280,7 @@ private: inline void update_change_flags(THD *thd) { - tx_changed &= ~TX_CHG_STATE; + tx_changed &= uint(~TX_CHG_STATE); tx_changed |= (tx_curr_state != tx_reported_state) ? TX_CHG_STATE : 0; if (tx_changed != TX_CHG_NONE) mark_as_changed(thd, NULL); diff --git a/sql/sql_acl.h b/sql/sql_acl.h index be206b1f86f..daa36f6c32a 100644 --- a/sql/sql_acl.h +++ b/sql/sql_acl.h @@ -2,6 +2,7 @@ #define SQL_ACL_INCLUDED /* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 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 as published by @@ -20,35 +21,35 @@ #include "violite.h" /* SSL_type */ #include "sql_class.h" /* LEX_COLUMN */ -#define SELECT_ACL (1L << 0) -#define INSERT_ACL (1L << 1) -#define UPDATE_ACL (1L << 2) -#define DELETE_ACL (1L << 3) -#define CREATE_ACL (1L << 4) -#define DROP_ACL (1L << 5) -#define RELOAD_ACL (1L << 6) -#define SHUTDOWN_ACL (1L << 7) -#define PROCESS_ACL (1L << 8) -#define FILE_ACL (1L << 9) -#define GRANT_ACL (1L << 10) -#define REFERENCES_ACL (1L << 11) -#define INDEX_ACL (1L << 12) -#define ALTER_ACL (1L << 13) -#define SHOW_DB_ACL (1L << 14) -#define SUPER_ACL (1L << 15) -#define CREATE_TMP_ACL (1L << 16) -#define LOCK_TABLES_ACL (1L << 17) -#define EXECUTE_ACL (1L << 18) -#define REPL_SLAVE_ACL (1L << 19) -#define REPL_CLIENT_ACL (1L << 20) -#define CREATE_VIEW_ACL (1L << 21) -#define SHOW_VIEW_ACL (1L << 22) -#define CREATE_PROC_ACL (1L << 23) -#define ALTER_PROC_ACL (1L << 24) -#define CREATE_USER_ACL (1L << 25) -#define EVENT_ACL (1L << 26) -#define TRIGGER_ACL (1L << 27) -#define CREATE_TABLESPACE_ACL (1L << 28) +#define SELECT_ACL (1UL << 0) +#define INSERT_ACL (1UL << 1) +#define UPDATE_ACL (1UL << 2) +#define DELETE_ACL (1UL << 3) +#define CREATE_ACL (1UL << 4) +#define DROP_ACL (1UL << 5) +#define RELOAD_ACL (1UL << 6) +#define SHUTDOWN_ACL (1UL << 7) +#define PROCESS_ACL (1UL << 8) +#define FILE_ACL (1UL << 9) +#define GRANT_ACL (1UL << 10) +#define REFERENCES_ACL (1UL << 11) +#define INDEX_ACL (1UL << 12) +#define ALTER_ACL (1UL << 13) +#define SHOW_DB_ACL (1UL << 14) +#define SUPER_ACL (1UL << 15) +#define CREATE_TMP_ACL (1UL << 16) +#define LOCK_TABLES_ACL (1UL << 17) +#define EXECUTE_ACL (1UL << 18) +#define REPL_SLAVE_ACL (1UL << 19) +#define REPL_CLIENT_ACL (1UL << 20) +#define CREATE_VIEW_ACL (1UL << 21) +#define SHOW_VIEW_ACL (1UL << 22) +#define CREATE_PROC_ACL (1UL << 23) +#define ALTER_PROC_ACL (1UL << 24) +#define CREATE_USER_ACL (1UL << 25) +#define EVENT_ACL (1UL << 26) +#define TRIGGER_ACL (1UL << 27) +#define CREATE_TABLESPACE_ACL (1UL << 28) /* don't forget to update 1. static struct show_privileges_st sys_privileges[] @@ -57,7 +58,7 @@ 4. acl_init() or whatever - to define behaviour for old privilege tables 5. sql_yacc.yy - for GRANT/REVOKE to work */ -#define NO_ACCESS (1L << 30) +#define NO_ACCESS (1UL << 30) #define DB_ACLS \ (UPDATE_ACL | SELECT_ACL | INSERT_ACL | DELETE_ACL | CREATE_ACL | DROP_ACL | \ GRANT_ACL | REFERENCES_ACL | INDEX_ACL | ALTER_ACL | CREATE_TMP_ACL | \ diff --git a/sql/sql_audit.h b/sql/sql_audit.h index d6f670538cd..5f530c676c3 100644 --- a/sql/sql_audit.h +++ b/sql/sql_audit.h @@ -2,6 +2,7 @@ #define SQL_AUDIT_INCLUDED /* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 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 as published by @@ -160,7 +161,7 @@ void mysql_audit_general(THD *thd, uint event_subtype, event.general_user_length= make_user_name(thd, user_buff); event.general_thread_id= (unsigned long)thd->thread_id; event.general_query= thd->query_string.str(); - event.general_query_length= thd->query_string.length(); + event.general_query_length= (unsigned) thd->query_string.length(); event.general_charset= thd->query_string.charset(); event.general_rows= thd->get_stmt_da()->current_row_for_warning(); event.database= thd->db; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 99c67186dbd..4f87d498300 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -4823,9 +4823,9 @@ static bool fix_all_session_vcol_exprs(THD *thd, TABLE_LIST *tables) fix_session_vcol_expr(thd, (*df)->default_value)) goto err; - for (Virtual_column_info **cc= t->check_constraints; cc && *cc; cc++) - if (fix_session_vcol_expr(thd, (*cc))) - goto err; + for (Virtual_column_info **cc= t->check_constraints; cc && *cc; cc++) + if (fix_session_vcol_expr(thd, (*cc))) + goto err; thd->security_ctx= save_security_ctx; } diff --git a/sql/sql_class.h b/sql/sql_class.h index ffdd63f1f4c..22895d7a2d8 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1,6 +1,6 @@ /* 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 as published by @@ -179,7 +179,7 @@ public: } inline char *str() const { return string.str; } - inline uint32 length() const { return string.length; } + inline size_t length() const { return string.length; } CHARSET_INFO *charset() const { return cs; } friend LEX_STRING * thd_query_string (MYSQL_THD thd); @@ -1068,7 +1068,10 @@ public: inline char *query() const { return query_string.str(); } - inline uint32 query_length() const { return query_string.length(); } + inline uint32 query_length() const + { + return static_cast<uint32>(query_string.length()); + } CHARSET_INFO *query_charset() const { return query_string.charset(); } void set_query_inner(const CSET_STRING &string_arg) { diff --git a/sql/sql_cte.cc b/sql/sql_cte.cc index d8cd92ed10b..3011b510761 100644 --- a/sql/sql_cte.cc +++ b/sql/sql_cte.cc @@ -1259,9 +1259,9 @@ void With_clause::print(String *str, enum_query_type query_type) with_elem; with_elem= with_elem->next) { - with_elem->print(str, query_type); if (with_elem != with_list.first) str->append(", "); + with_elem->print(str, query_type); } } diff --git a/sql/sql_error.h b/sql/sql_error.h index aa8e6c6b0f3..3aef5d38368 100644 --- a/sql/sql_error.h +++ b/sql/sql_error.h @@ -1,4 +1,5 @@ /* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 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 as published by @@ -50,7 +51,7 @@ public: Convert a bitmask consisting of MYSQL_TIME_{NOTE|WARN}_XXX bits to WARN_LEVEL_XXX */ - static enum_warning_level time_warn_level(int warnings) + static enum_warning_level time_warn_level(uint warnings) { return MYSQL_TIME_WARN_HAVE_WARNINGS(warnings) ? WARN_LEVEL_WARN : WARN_LEVEL_NOTE; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index b5a272a056d..671e00fb36d 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2010, 2016, MariaDB + Copyright (c) 2010, 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 as published by @@ -1498,8 +1498,8 @@ public: This has all flags from 0 (inclusive) to BINLOG_STMT_FLAG_COUNT (exclusive) set. */ - static const int BINLOG_STMT_UNSAFE_ALL_FLAGS= - ((1 << BINLOG_STMT_UNSAFE_COUNT) - 1); + static const uint32 BINLOG_STMT_UNSAFE_ALL_FLAGS= + ((1U << BINLOG_STMT_UNSAFE_COUNT) - 1); /** Maps elements of enum_binlog_stmt_unsafe to error codes. diff --git a/sql/sql_plugin.h b/sql/sql_plugin.h index 9a0acea1d18..7b89246a9f9 100644 --- a/sql/sql_plugin.h +++ b/sql/sql_plugin.h @@ -1,5 +1,5 @@ /* Copyright (c) 2005, 2012, Oracle and/or its affiliates. - Copyright (c) 2009, 2012, Monty Program Ab + 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 as published by @@ -53,9 +53,9 @@ extern ulong dlopen_count; /* the following flags are valid for plugin_init() */ -#define PLUGIN_INIT_SKIP_DYNAMIC_LOADING 1 -#define PLUGIN_INIT_SKIP_PLUGIN_TABLE 2 -#define PLUGIN_INIT_SKIP_INITIALIZATION 4 +#define PLUGIN_INIT_SKIP_DYNAMIC_LOADING 1U +#define PLUGIN_INIT_SKIP_PLUGIN_TABLE 2U +#define PLUGIN_INIT_SKIP_INITIALIZATION 4U #define INITIAL_LEX_PLUGIN_LIST_SIZE 16 @@ -71,12 +71,12 @@ typedef struct st_mysql_show_var SHOW_VAR; It's a bitmap, because it makes it easier to test "whether the state is one of those..." */ -#define PLUGIN_IS_FREED 1 -#define PLUGIN_IS_DELETED 2 -#define PLUGIN_IS_UNINITIALIZED 4 -#define PLUGIN_IS_READY 8 -#define PLUGIN_IS_DYING 16 -#define PLUGIN_IS_DISABLED 32 +#define PLUGIN_IS_FREED 1U +#define PLUGIN_IS_DELETED 2U +#define PLUGIN_IS_UNINITIALIZED 4U +#define PLUGIN_IS_READY 8U +#define PLUGIN_IS_DYING 16U +#define PLUGIN_IS_DISABLED 32U struct st_ptr_backup { void **ptr; diff --git a/sql/sql_select.h b/sql/sql_select.h index 76cded43128..0d4570fbe47 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -2,7 +2,7 @@ #define SQL_SELECT_INCLUDED /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. - Copyright (c) 2008, 2015, MariaDB + Copyright (c) 2008, 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 as published by @@ -36,9 +36,9 @@ typedef struct st_join_table JOIN_TAB; /* Values in optimize */ -#define KEY_OPTIMIZE_EXISTS 1 -#define KEY_OPTIMIZE_REF_OR_NULL 2 -#define KEY_OPTIMIZE_EQ 4 +#define KEY_OPTIMIZE_EXISTS 1U +#define KEY_OPTIMIZE_REF_OR_NULL 2U +#define KEY_OPTIMIZE_EQ 4U inline uint get_hash_join_key_no() { return MAX_KEY; } @@ -178,10 +178,10 @@ enum sj_strategy_enum }; /* Values for JOIN_TAB::packed_info */ -#define TAB_INFO_HAVE_VALUE 1 -#define TAB_INFO_USING_INDEX 2 -#define TAB_INFO_USING_WHERE 4 -#define TAB_INFO_FULL_SCAN_ON_NULL 8 +#define TAB_INFO_HAVE_VALUE 1U +#define TAB_INFO_USING_INDEX 2U +#define TAB_INFO_USING_WHERE 4U +#define TAB_INFO_FULL_SCAN_ON_NULL 8U typedef enum_nested_loop_state (*Next_select_func)(JOIN *, struct st_join_table *, bool); diff --git a/sql/sql_string.h b/sql/sql_string.h index 8062e2d465d..0a930554d8a 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -3,7 +3,7 @@ /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. - Copyright (c) 2008, 2013, Monty Program Ab. + Copyright (c) 2008, 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 as published by @@ -97,9 +97,9 @@ public: Convert a string between character sets. "dstcs" and "srccs" cannot be &my_charset_bin. */ - uint convert_fix(CHARSET_INFO *dstcs, char *dst, uint dst_length, - CHARSET_INFO *srccs, const char *src, uint src_length, - uint nchars) + size_t convert_fix(CHARSET_INFO *dstcs, char *dst, uint dst_length, + CHARSET_INFO *srccs, const char *src, uint src_length, + uint nchars) { return my_convert_fix(dstcs, dst, dst_length, srccs, src, src_length, nchars, this, this); @@ -677,7 +677,7 @@ public: { DBUG_ASSERT(Alloced_length >= (str_length + net_length_size(length))); char *pos= (char *) net_store_length((uchar *)(Ptr + str_length), length); - str_length= pos - Ptr; + str_length= uint32(pos - Ptr); } void q_net_store_data(const uchar *from, size_t length) { diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 4834e10da3d..7c06ff96c32 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2016, Oracle and/or its affiliates. - Copyright (c) 2010, 2016, MariaDB + Copyright (c) 2010, 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 as published by @@ -2845,7 +2845,7 @@ bool check_duplicates_in_interval(const char *set_or_name, */ bool Column_definition::prepare_create_field(uint *blob_columns, - longlong table_flags) + ulonglong table_flags) { uint dup_val_count; uint decimals_orig= decimals; diff --git a/sql/sql_table.h b/sql/sql_table.h index 1750def3a84..5b2c9f32443 100644 --- a/sql/sql_table.h +++ b/sql/sql_table.h @@ -1,5 +1,5 @@ /* Copyright (c) 2006, 2014, Oracle and/or its affiliates. - Copyright (c) 2011, 2014, Monty Program Ab. + Copyright (c) 2011, 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 as published by @@ -251,6 +251,7 @@ bool quick_rm_table(THD *thd, handlerton *base, const char *db, const char *table_name, uint flags, const char *table_path=0); void close_cached_table(THD *thd, TABLE *table); +void sp_prepare_create_field(THD *thd, Column_definition *sql_field); CHARSET_INFO* get_sql_field_charset(Create_field *sql_field, HA_CREATE_INFO *create_info); bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags); diff --git a/sql/sql_trigger.h b/sql/sql_trigger.h index afe47fb36f4..9d1c79cc7cf 100644 --- a/sql/sql_trigger.h +++ b/sql/sql_trigger.h @@ -3,6 +3,7 @@ /* Copyright (c) 2004, 2011, Oracle and/or its affiliates. + Copyright (c) 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 as published by @@ -273,8 +274,8 @@ public: Field **nullable_fields() { return record0_field; } void reset_extra_null_bitmap() { - int null_bytes= (trigger_table->s->stored_fields - - trigger_table->s->null_fields + 7)/8; + size_t null_bytes= (trigger_table->s->stored_fields - + trigger_table->s->null_fields + 7)/8; bzero(extra_null_bitmap, null_bytes); } diff --git a/sql/structs.h b/sql/structs.h index ea47d6255de..98eb0f2585d 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -2,6 +2,7 @@ #define STRUCTS_INCLUDED /* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 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 as published by @@ -331,26 +332,26 @@ typedef struct st_index_stats /* Bits in form->update */ -#define REG_MAKE_DUPP 1 /* Make a copy of record when read */ -#define REG_NEW_RECORD 2 /* Write a new record if not found */ -#define REG_UPDATE 4 /* Uppdate record */ -#define REG_DELETE 8 /* Delete found record */ -#define REG_PROG 16 /* User is updating database */ -#define REG_CLEAR_AFTER_WRITE 32 -#define REG_MAY_BE_UPDATED 64 -#define REG_AUTO_UPDATE 64 /* Used in D-forms for scroll-tables */ -#define REG_OVERWRITE 128 -#define REG_SKIP_DUP 256 +#define REG_MAKE_DUPP 1U /* Make a copy of record when read */ +#define REG_NEW_RECORD 2U /* Write a new record if not found */ +#define REG_UPDATE 4U /* Uppdate record */ +#define REG_DELETE 8U /* Delete found record */ +#define REG_PROG 16U /* User is updating database */ +#define REG_CLEAR_AFTER_WRITE 32U +#define REG_MAY_BE_UPDATED 64U +#define REG_AUTO_UPDATE 64U /* Used in D-forms for scroll-tables */ +#define REG_OVERWRITE 128U +#define REG_SKIP_DUP 256U /* Bits in form->status */ -#define STATUS_NO_RECORD (1+2) /* Record isn't usably */ -#define STATUS_GARBAGE 1 -#define STATUS_NOT_FOUND 2 /* No record in database when needed */ -#define STATUS_NO_PARENT 4 /* Parent record wasn't found */ -#define STATUS_NOT_READ 8 /* Record isn't read */ -#define STATUS_UPDATED 16 /* Record is updated by formula */ -#define STATUS_NULL_ROW 32 /* table->null_row is set */ -#define STATUS_DELETED 64 +#define STATUS_NO_RECORD (1U+2U) /* Record isn't usable */ +#define STATUS_GARBAGE 1U +#define STATUS_NOT_FOUND 2U /* No record in database when needed */ +#define STATUS_NO_PARENT 4U /* Parent record wasn't found */ +#define STATUS_NOT_READ 8U /* Record isn't read */ +#define STATUS_UPDATED 16U /* Record is updated by formula */ +#define STATUS_NULL_ROW 32U /* table->null_row is set */ +#define STATUS_DELETED 64U /* Such interval is "discrete": it is the set of diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 40cdd84a292..9a9e920c6dd 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -2465,7 +2465,7 @@ static Sys_var_uint Sys_protocol_version( "protocol_version", "The version of the client/server protocol used by the MySQL server", READ_ONLY GLOBAL_VAR(protocol_version), CMD_LINE_HELP_ONLY, - VALID_RANGE(0, ~0), DEFAULT(PROTOCOL_VERSION), BLOCK_SIZE(1)); + VALID_RANGE(0, ~0U), DEFAULT(PROTOCOL_VERSION), BLOCK_SIZE(1)); static Sys_var_proxy_user Sys_proxy_user( "proxy_user", "The proxy user account name used when logging in", diff --git a/sql/table.h b/sql/table.h index c4b2ba2945d..c1f2c5feebe 100644 --- a/sql/table.h +++ b/sql/table.h @@ -2,7 +2,7 @@ #define TABLE_INCLUDED /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. Copyright (c) 2009, 2014, SkySQL Ab. - Copyright (c) 2016, MariaDB Corporation + Copyright (c) 2016, 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 as published by @@ -1500,13 +1500,13 @@ typedef struct st_foreign_key_info LEX_CSTRING *fk_option_name(enum_fk_option opt); -#define MY_I_S_MAYBE_NULL 1 -#define MY_I_S_UNSIGNED 2 +#define MY_I_S_MAYBE_NULL 1U +#define MY_I_S_UNSIGNED 2U -#define SKIP_OPEN_TABLE 0 // do not open table -#define OPEN_FRM_ONLY 1 // open FRM file only -#define OPEN_FULL_TABLE 2 // open FRM,MYD, MYI files +#define SKIP_OPEN_TABLE 0U // do not open table +#define OPEN_FRM_ONLY 1U // open FRM file only +#define OPEN_FULL_TABLE 2U // open FRM,MYD, MYI files typedef struct st_field_info { @@ -1570,27 +1570,27 @@ class IS_table_read_plan; Types of derived tables. The ending part is a bitmap of phases that are applicable to a derived table of the type. */ -#define DTYPE_ALGORITHM_UNDEFINED 0 -#define DTYPE_VIEW 1 -#define DTYPE_TABLE 2 -#define DTYPE_MERGE 4 -#define DTYPE_MATERIALIZE 8 -#define DTYPE_MULTITABLE 16 -#define DTYPE_MASK 19 +#define DTYPE_ALGORITHM_UNDEFINED 0U +#define DTYPE_VIEW 1U +#define DTYPE_TABLE 2U +#define DTYPE_MERGE 4U +#define DTYPE_MATERIALIZE 8U +#define DTYPE_MULTITABLE 16U +#define DTYPE_MASK (DTYPE_VIEW|DTYPE_TABLE|DTYPE_MULTITABLE) /* Phases of derived tables/views handling, see sql_derived.cc Values are used as parts of a bitmap attached to derived table types. */ -#define DT_INIT 1 -#define DT_PREPARE 2 -#define DT_OPTIMIZE 4 -#define DT_MERGE 8 -#define DT_MERGE_FOR_INSERT 16 -#define DT_CREATE 32 -#define DT_FILL 64 -#define DT_REINIT 128 -#define DT_PHASES 8 +#define DT_INIT 1U +#define DT_PREPARE 2U +#define DT_OPTIMIZE 4U +#define DT_MERGE 8U +#define DT_MERGE_FOR_INSERT 16U +#define DT_CREATE 32U +#define DT_FILL 64U +#define DT_REINIT 128U +#define DT_PHASES 8U /* Phases that are applicable to all derived tables. */ #define DT_COMMON (DT_INIT + DT_PREPARE + DT_REINIT + DT_OPTIMIZE) /* Phases that are applicable only to materialized derived tables. */ @@ -1610,13 +1610,13 @@ class IS_table_read_plan; representation for backward compatibility. */ -#define VIEW_ALGORITHM_UNDEFINED_FRM 0 -#define VIEW_ALGORITHM_MERGE_FRM 1 -#define VIEW_ALGORITHM_TMPTABLE_FRM 2 +#define VIEW_ALGORITHM_UNDEFINED_FRM 0U +#define VIEW_ALGORITHM_MERGE_FRM 1U +#define VIEW_ALGORITHM_TMPTABLE_FRM 2U -#define JOIN_TYPE_LEFT 1 -#define JOIN_TYPE_RIGHT 2 -#define JOIN_TYPE_OUTER 4 /* Marker that this is an outer join */ +#define JOIN_TYPE_LEFT 1U +#define JOIN_TYPE_RIGHT 2U +#define JOIN_TYPE_OUTER 4U /* Marker that this is an outer join */ #define VIEW_SUID_INVOKER 0 #define VIEW_SUID_DEFINER 1 |