summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Widenius <monty@mariadb.org>2017-04-16 17:14:41 +0300
committerMonty <monty@mariadb.org>2017-04-18 12:23:40 +0300
commitd82ac8eaafd89a6a74436747b660ef02c69eaac3 (patch)
treeb166cd3450d894407d4e269d1ea1c834d75c67dc
parent00946f43310f528003251c7f3934966eff2a8089 (diff)
downloadmariadb-git-d82ac8eaafd89a6a74436747b660ef02c69eaac3.tar.gz
Change "static int" to enum in classes
This was done when static int where used as bit fields or enums
-rw-r--r--sql/handler.h12
-rw-r--r--sql/item_sum.h2
-rw-r--r--sql/log_event.h11
-rw-r--r--sql/rpl_gtid.h8
-rw-r--r--sql/rpl_parallel.h38
-rw-r--r--sql/sql_alter.h149
6 files changed, 105 insertions, 115 deletions
diff --git a/sql/handler.h b/sql/handler.h
index 236e39f5dde..7f8dd687bda 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -1483,13 +1483,15 @@ struct THD_TRANS
unsigned int m_unsafe_rollback_flags;
/*
- Define the type of statemens which cannot be rolled back safely.
+ Define the type of statements which cannot be rolled back safely.
Each type occupies one bit in m_unsafe_rollback_flags.
*/
- static unsigned int const MODIFIED_NON_TRANS_TABLE= 0x01;
- static unsigned int const CREATED_TEMP_TABLE= 0x02;
- static unsigned int const DROPPED_TEMP_TABLE= 0x04;
- static unsigned int const DID_WAIT= 0x08;
+ enum unsafe_statement_types
+ {
+ CREATED_TEMP_TABLE= 2,
+ DROPPED_TEMP_TABLE= 4,
+ DID_WAIT= 8
+ };
void mark_created_temp_table()
{
diff --git a/sql/item_sum.h b/sql/item_sum.h
index ee1c10f9fbe..98b027de41d 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -1153,7 +1153,7 @@ public:
}
protected:
- static const int NUM_BIT_COUNTERS= 64;
+ enum bit_counters { NUM_BIT_COUNTERS= 64 };
ulonglong reset_bits,bits;
/*
Marks whether the function is to be computed as a window function.
diff --git a/sql/log_event.h b/sql/log_event.h
index ccbc0527bd2..57692803b5b 100644
--- a/sql/log_event.h
+++ b/sql/log_event.h
@@ -3459,7 +3459,7 @@ public:
The three elements in the body repeat COUNT times to form the GTID list.
- At the time of writing, only one flag bit is in use.
+ At the time of writing, only two flag bit are in use.
Bit 28 of `count' is used for flag FLAG_UNTIL_REACHED, which is sent in a
Gtid_list event from the master to the slave to indicate that the START
@@ -3477,9 +3477,12 @@ public:
uint64 *sub_id_list;
static const uint element_size= 4+4+8;
- static const uint32 FLAG_UNTIL_REACHED= (1<<28);
- static const uint32 FLAG_IGN_GTIDS= (1<<29);
-
+ /* Upper bits stored in 'count'. See comment above */
+ enum gtid_flags
+ {
+ FLAG_UNTIL_REACHED= (1<<28),
+ FLAG_IGN_GTIDS= (1<<29),
+ };
#ifdef MYSQL_SERVER
Gtid_list_log_event(rpl_binlog_state *gtid_set, uint32 gl_flags);
Gtid_list_log_event(slave_connection_state *gtid_set, uint32 gl_flags);
diff --git a/sql/rpl_gtid.h b/sql/rpl_gtid.h
index f638a084e38..f8a13d7bf3f 100644
--- a/sql/rpl_gtid.h
+++ b/sql/rpl_gtid.h
@@ -270,8 +270,12 @@ struct slave_connection_state
rpl_gtid gtid;
uint32 flags;
};
- static const uint32 START_OWN_SLAVE_POS= 0x1;
- static const uint32 START_ON_EMPTY_DOMAIN= 0x2;
+ /* Bits for 'flags' */
+ enum start_flags
+ {
+ START_OWN_SLAVE_POS= 0x1,
+ START_ON_EMPTY_DOMAIN= 0x2
+ };
/* Mapping from domain_id to the entry with GTID requested for that domain. */
HASH hash;
diff --git a/sql/rpl_parallel.h b/sql/rpl_parallel.h
index a0faeae815c..4579d0da9bc 100644
--- a/sql/rpl_parallel.h
+++ b/sql/rpl_parallel.h
@@ -68,23 +68,27 @@ struct group_commit_orderer {
*/
bool installed;
- /*
- This flag is set for a GCO in which we have event groups with multiple
- different commit_id values from the master. This happens when we
- optimistically try to execute in parallel transactions not known to be
- conflict-free.
-
- When this flag is set, in case of DDL we need to start a new GCO regardless
- of current commit_id, as DDL is not safe to speculatively apply in parallel
- with prior event groups.
- */
- static const uint8 MULTI_BATCH = 0x01;
- /*
- This flag is set for a GCO that contains DDL. If set, it forces a switch to
- a new GCO upon seeing a new commit_id, as DDL is not safe to speculatively
- replicate in parallel with subsequent transactions.
- */
- static const uint8 FORCE_SWITCH = 0x02;
+ enum force_switch_bits
+ {
+ /*
+ This flag is set for a GCO in which we have event groups with multiple
+ different commit_id values from the master. This happens when we
+ optimistically try to execute in parallel transactions not known to be
+ conflict-free.
+
+ When this flag is set, in case of DDL we need to start a new GCO
+ regardless of current commit_id, as DDL is not safe to
+ speculatively apply in parallel with prior event groups.
+ */
+ MULTI_BATCH= 1,
+ /*
+ This flag is set for a GCO that contains DDL. If set, it forces
+ a switch to a new GCO upon seeing a new commit_id, as DDL is not
+ safe to speculatively replicate in parallel with subsequent
+ transactions.
+ */
+ FORCE_SWITCH= 2
+ };
uint8 flags;
};
diff --git a/sql/sql_alter.h b/sql/sql_alter.h
index 5668a0f52be..4650e2b6a25 100644
--- a/sql/sql_alter.h
+++ b/sql/sql_alter.h
@@ -38,91 +38,65 @@ public:
type of index to be added/dropped.
*/
- // Set for ADD [COLUMN]
- static const uint ALTER_ADD_COLUMN = 1L << 0;
-
- // Set for DROP [COLUMN]
- static const uint ALTER_DROP_COLUMN = 1L << 1;
-
- // Set for CHANGE [COLUMN] | MODIFY [CHANGE]
- // Set by mysql_recreate_table()
- static const uint ALTER_CHANGE_COLUMN = 1L << 2;
-
- // Set for ADD INDEX | ADD KEY | ADD PRIMARY KEY | ADD UNIQUE KEY |
- // ADD UNIQUE INDEX | ALTER ADD [COLUMN]
- static const uint ALTER_ADD_INDEX = 1L << 3;
-
- // Set for DROP PRIMARY KEY | DROP FOREIGN KEY | DROP KEY | DROP INDEX
- static const uint ALTER_DROP_INDEX = 1L << 4;
-
- // Set for RENAME [TO]
- static const uint ALTER_RENAME = 1L << 5;
-
- // Set for ORDER BY
- static const uint ALTER_ORDER = 1L << 6;
-
- // Set for table_options
- static const uint ALTER_OPTIONS = 1L << 7;
-
- // Set for ALTER [COLUMN] ... SET DEFAULT ... | DROP DEFAULT
- static const uint ALTER_CHANGE_COLUMN_DEFAULT = 1L << 8;
-
- // Set for DISABLE KEYS | ENABLE KEYS
- static const uint ALTER_KEYS_ONOFF = 1L << 9;
-
- // Set for FORCE
- // Set for ENGINE(same engine)
- // Set by mysql_recreate_table()
- static const uint ALTER_RECREATE = 1L << 10;
-
- // Set for ADD PARTITION
- static const uint ALTER_ADD_PARTITION = 1L << 11;
-
- // Set for DROP PARTITION
- static const uint ALTER_DROP_PARTITION = 1L << 12;
-
- // Set for COALESCE PARTITION
- static const uint ALTER_COALESCE_PARTITION = 1L << 13;
-
- // Set for REORGANIZE PARTITION ... INTO
- static const uint ALTER_REORGANIZE_PARTITION = 1L << 14;
-
- // Set for partition_options
- static const uint ALTER_PARTITION = 1L << 15;
-
- // Set for LOAD INDEX INTO CACHE ... PARTITION
- // Set for CACHE INDEX ... PARTITION
- static const uint ALTER_ADMIN_PARTITION = 1L << 16;
-
- // Set for REORGANIZE PARTITION
- static const uint ALTER_TABLE_REORG = 1L << 17;
-
- // Set for REBUILD PARTITION
- static const uint ALTER_REBUILD_PARTITION = 1L << 18;
-
- // Set for partitioning operations specifying ALL keyword
- static const uint ALTER_ALL_PARTITION = 1L << 19;
-
- // Set for REMOVE PARTITIONING
- static const uint ALTER_REMOVE_PARTITIONING = 1L << 20;
-
- // Set for ADD FOREIGN KEY
- static const uint ADD_FOREIGN_KEY = 1L << 21;
-
- // Set for DROP FOREIGN KEY
- static const uint DROP_FOREIGN_KEY = 1L << 22;
-
- // Set for EXCHANGE PARITION
- static const uint ALTER_EXCHANGE_PARTITION = 1L << 23;
-
- // Set by Sql_cmd_alter_table_truncate_partition::execute()
- static const uint ALTER_TRUNCATE_PARTITION = 1L << 24;
-
- // Set for ADD [COLUMN] FIRST | AFTER
- static const uint ALTER_COLUMN_ORDER = 1L << 25;
-
- static const uint ALTER_ADD_CHECK_CONSTRAINT = 1L << 27;
- static const uint ALTER_DROP_CHECK_CONSTRAINT = 1L << 28;
+ enum operations_used_flags
+ {
+ // Set for ADD [COLUMN]
+ ALTER_ADD_COLUMN = 1L << 0,
+ // Set for DROP [COLUMN]
+ ALTER_DROP_COLUMN = 1L << 1,
+ // Set for CHANGE [COLUMN] | MODIFY [CHANGE] & mysql_recreate_table
+ ALTER_CHANGE_COLUMN = 1L << 2,
+ // Set for ADD INDEX | ADD KEY | ADD PRIMARY KEY | ADD UNIQUE KEY |
+ // ADD UNIQUE INDEX | ALTER ADD [COLUMN]
+ ALTER_ADD_INDEX = 1L << 3,
+ // Set for DROP PRIMARY KEY | DROP FOREIGN KEY | DROP KEY | DROP INDEX
+ ALTER_DROP_INDEX = 1L << 4,
+ // Set for RENAME [TO]
+ ALTER_RENAME = 1L << 5,
+ // Set for ORDER BY
+ ALTER_ORDER = 1L << 6,
+ // Set for table_options
+ ALTER_OPTIONS = 1L << 7,
+ // Set for ALTER [COLUMN] ... SET DEFAULT ... | DROP DEFAULT
+ ALTER_CHANGE_COLUMN_DEFAULT = 1L << 8,
+ // Set for DISABLE KEYS | ENABLE KEYS
+ ALTER_KEYS_ONOFF = 1L << 9,
+ // Set for FORCE, ENGINE(same engine), by mysql_recreate_table()
+ ALTER_RECREATE = 1L << 10,
+ // Set for ADD PARTITION
+ ALTER_ADD_PARTITION = 1L << 11,
+ // Set for DROP PARTITION
+ ALTER_DROP_PARTITION = 1L << 12,
+ // Set for COALESCE PARTITION
+ ALTER_COALESCE_PARTITION = 1L << 13,
+ // Set for REORGANIZE PARTITION ... INTO
+ ALTER_REORGANIZE_PARTITION = 1L << 14,
+ // Set for partition_options
+ ALTER_PARTITION = 1L << 15,
+ // Set for LOAD INDEX INTO CACHE ... PARTITION
+ // Set for CACHE INDEX ... PARTITION
+ ALTER_ADMIN_PARTITION = 1L << 16,
+ // Set for REORGANIZE PARTITION
+ ALTER_TABLE_REORG = 1L << 17,
+ // Set for REBUILD PARTITION
+ ALTER_REBUILD_PARTITION = 1L << 18,
+ // Set for partitioning operations specifying ALL keyword
+ ALTER_ALL_PARTITION = 1L << 19,
+ // Set for REMOVE PARTITIONING
+ ALTER_REMOVE_PARTITIONING = 1L << 20,
+ // Set for ADD FOREIGN KEY
+ ADD_FOREIGN_KEY = 1L << 21,
+ // Set for DROP FOREIGN KEY
+ DROP_FOREIGN_KEY = 1L << 22,
+ // Set for EXCHANGE PARITION
+ ALTER_EXCHANGE_PARTITION = 1L << 23,
+ // Set by Sql_cmd_alter_table_truncate_partition::execute()
+ ALTER_TRUNCATE_PARTITION = 1L << 24,
+ // Set for ADD [COLUMN] FIRST | AFTER
+ ALTER_COLUMN_ORDER = 1L << 25,
+ ALTER_ADD_CHECK_CONSTRAINT = 1L << 27,
+ ALTER_DROP_CHECK_CONSTRAINT = 1L << 28
+ };
enum enum_enable_or_disable { LEAVE_AS_IS, ENABLE, DISABLE };
@@ -172,7 +146,10 @@ public:
// List of columns, used by both CREATE and ALTER TABLE.
List<Create_field> create_list;
- static const uint CHECK_CONSTRAINT_IF_NOT_EXISTS= 1;
+ enum flags_bits
+ {
+ CHECK_CONSTRAINT_IF_NOT_EXISTS= 1
+ };
List<Virtual_column_info> check_constraint_list;
// Type of ALTER TABLE operation.
uint flags;