diff --git a/sql/ha_partition.h b/sql/ha_partition.h index 202f27840dc..f79d71a7355 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -1040,10 +1040,6 @@ public: with hidden primary key) (No handler has this limitation currently) - HA_WANTS_PRIMARY_KEY: - Can't define a table without primary key except sequences - (Only InnoDB has this when using innodb_force_primary_key == ON) - HA_STATS_RECORDS_IS_EXACT: Does the counter of records after the info call specify an exact value or not. If it does this flag is set. diff --git a/sql/handler.h b/sql/handler.h index 6245bf7970f..f5603ad9dde 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -115,7 +115,13 @@ enum enum_alter_inplace_result { #define HA_NO_BLOBS (1ULL << 9) /* Doesn't support blobs */ #define HA_CAN_INDEX_BLOBS (1ULL << 10) #define HA_AUTO_PART_KEY (1ULL << 11) /* auto-increment in multi-part key */ -#define HA_REQUIRE_PRIMARY_KEY (1ULL << 12) /* .. and can't create a hidden one */ +/* + The engine requires every table to have a user-specified PRIMARY KEY. + Do not set the flag if the engine can generate a hidden primary key internally. + This flag is ignored if a SEQUENCE is created (which, in turn, needs + HA_CAN_TABLES_WITHOUT_ROLLBACK flag) +*/ +#define HA_REQUIRE_PRIMARY_KEY (1ULL << 12) #define HA_STATS_RECORDS_IS_EXACT (1ULL << 13) /* stats.records is exact */ /* INSERT_DELAYED only works with handlers that uses MySQL internal table @@ -301,8 +307,6 @@ enum enum_alter_inplace_result { /* calling cmp_ref() on the engine is expensive */ #define HA_CMP_REF_IS_EXPENSIVE (1ULL << 54) -/* Engine wants primary keys for everything except sequences */ -#define HA_WANTS_PRIMARY_KEY (1ULL << 55) /* bits in index_flags(index_number) for what you can do with index */ #define HA_READ_NEXT 1 /* TODO really use this flag */ diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 3e204c4945b..2fec5cd418a 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -4133,10 +4133,8 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, key_info++; } - if (!unique_key && !primary_key && - ((file->ha_table_flags() & HA_REQUIRE_PRIMARY_KEY) || - ((file->ha_table_flags() & HA_WANTS_PRIMARY_KEY) && - !create_info->sequence))) + if (!unique_key && !primary_key && !create_info->sequence && + (file->ha_table_flags() & HA_REQUIRE_PRIMARY_KEY)) { my_message(ER_REQUIRES_PRIMARY_KEY, ER_THD(thd, ER_REQUIRES_PRIMARY_KEY), MYF(0)); diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 3036522eda9..0effdc35fb2 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -2913,7 +2913,7 @@ ha_innobase::ha_innobase( | HA_CAN_RTREEKEYS | HA_CAN_TABLES_WITHOUT_ROLLBACK | HA_CONCURRENT_OPTIMIZE - | (srv_force_primary_key ? HA_WANTS_PRIMARY_KEY : 0) + | (srv_force_primary_key ? HA_REQUIRE_PRIMARY_KEY : 0) ), m_start_of_scan(), m_mysql_has_locked()