mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
cleanup: remove HA_WANTS_PRIMARY_KEY as redundant
We don't have many bits left, no need to add another InnoDB-specific flag. Instead, we say that HA_REQUIRE_PRIMARY_KEY does not apply to SEQUENCE. Meaning, if the engine declares HA_CAN_TABLES_WITHOUT_ROLLBACK (required for SEQUENCE) it *must* support tables without a primary key.
This commit is contained in:
@@ -1040,10 +1040,6 @@ public:
|
|||||||
with hidden primary key)
|
with hidden primary key)
|
||||||
(No handler has this limitation currently)
|
(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:
|
HA_STATS_RECORDS_IS_EXACT:
|
||||||
Does the counter of records after the info call specify an exact
|
Does the counter of records after the info call specify an exact
|
||||||
value or not. If it does this flag is set.
|
value or not. If it does this flag is set.
|
||||||
|
@@ -115,7 +115,13 @@ enum enum_alter_inplace_result {
|
|||||||
#define HA_NO_BLOBS (1ULL << 9) /* Doesn't support blobs */
|
#define HA_NO_BLOBS (1ULL << 9) /* Doesn't support blobs */
|
||||||
#define HA_CAN_INDEX_BLOBS (1ULL << 10)
|
#define HA_CAN_INDEX_BLOBS (1ULL << 10)
|
||||||
#define HA_AUTO_PART_KEY (1ULL << 11) /* auto-increment in multi-part key */
|
#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 */
|
#define HA_STATS_RECORDS_IS_EXACT (1ULL << 13) /* stats.records is exact */
|
||||||
/*
|
/*
|
||||||
INSERT_DELAYED only works with handlers that uses MySQL internal table
|
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 */
|
/* calling cmp_ref() on the engine is expensive */
|
||||||
#define HA_CMP_REF_IS_EXPENSIVE (1ULL << 54)
|
#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 */
|
/* bits in index_flags(index_number) for what you can do with index */
|
||||||
#define HA_READ_NEXT 1 /* TODO really use this flag */
|
#define HA_READ_NEXT 1 /* TODO really use this flag */
|
||||||
|
@@ -4133,10 +4133,8 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
|
|||||||
key_info++;
|
key_info++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!unique_key && !primary_key &&
|
if (!unique_key && !primary_key && !create_info->sequence &&
|
||||||
((file->ha_table_flags() & HA_REQUIRE_PRIMARY_KEY) ||
|
(file->ha_table_flags() & HA_REQUIRE_PRIMARY_KEY))
|
||||||
((file->ha_table_flags() & HA_WANTS_PRIMARY_KEY) &&
|
|
||||||
!create_info->sequence)))
|
|
||||||
{
|
{
|
||||||
my_message(ER_REQUIRES_PRIMARY_KEY, ER_THD(thd, ER_REQUIRES_PRIMARY_KEY),
|
my_message(ER_REQUIRES_PRIMARY_KEY, ER_THD(thd, ER_REQUIRES_PRIMARY_KEY),
|
||||||
MYF(0));
|
MYF(0));
|
||||||
|
@@ -2913,7 +2913,7 @@ ha_innobase::ha_innobase(
|
|||||||
| HA_CAN_RTREEKEYS
|
| HA_CAN_RTREEKEYS
|
||||||
| HA_CAN_TABLES_WITHOUT_ROLLBACK
|
| HA_CAN_TABLES_WITHOUT_ROLLBACK
|
||||||
| HA_CONCURRENT_OPTIMIZE
|
| 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_start_of_scan(),
|
||||||
m_mysql_has_locked()
|
m_mysql_has_locked()
|
||||||
|
Reference in New Issue
Block a user