Commit 7fb3b348 authored by Sergei Petrunia's avatar Sergei Petrunia

MariaRocks port: Remove handler::init_with_fields

- It turns out, ha_rocksdb::table_flags() can return
  HA_PRIMARY_KEY_IN_READ_INDEX for all kinds of tables (as its meaning
  is "if there is a PK, PK columns contribute to the secondary index
  tuple". There is no assumption that a certain PK column can be decoded
  from the secondary index.
  (Should probably be fixed in the upstream, too, but I was unable to
   construct a testcase showing this is necessary).

- Following the above, we can undo the init_with_fields() changes in
  table.cc. MyRocks calls init_with_fields() from ha_rocksdb::open()
  which sets index-only read capabilities properly.
parent 2d789dd9
......@@ -421,22 +421,6 @@ ha_partition::~ha_partition()
}
bool ha_partition::init_with_fields()
{
/* Pass the call to each partition */
for (uint i= 0; i < m_tot_parts; i++)
{
if (m_file[i]->init_with_fields())
return true;
}
/* Re-read table flags in case init_with_fields caused it to change */
cached_table_flags= (m_file[0]->ha_table_flags() &
~(PARTITION_DISABLED_TABLE_FLAGS)) |
PARTITION_ENABLED_TABLE_FLAGS;
return false;
}
/*
Initialize partition handler object
......
......@@ -307,8 +307,6 @@ class ha_partition :public handler
ha_partition *clone_arg,
MEM_ROOT *clone_mem_root_arg);
~ha_partition();
bool init_with_fields();
/*
A partition handler has no characteristics in itself. It only inherits
those from the underlying handlers. Here we set-up those constants to
......
......@@ -2777,8 +2777,6 @@ class handler :public Sql_alloc
{
cached_table_flags= table_flags();
}
virtual bool init_with_fields() { return false; }
/* ha_ methods: pubilc wrappers for private virtual API */
int ha_open(TABLE *table, const char *name, int mode, uint test_if_locked);
......
......@@ -2230,6 +2230,18 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
if (key == primary_key)
{
field->flags|= PRI_KEY_FLAG;
/*
If this field is part of the primary key and all keys contains
the primary key, then we can use any key to find this column
*/
if (ha_option & HA_PRIMARY_KEY_IN_READ_INDEX)
{
if (field->key_length() == key_part->length &&
!(field->flags & BLOB_FLAG))
field->part_of_key= share->keys_in_use;
if (field->part_of_sortkey.is_set(key))
field->part_of_sortkey= share->keys_in_use;
}
}
if (field->key_length() != key_part->length)
{
......@@ -2289,38 +2301,6 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
(ha_option & HA_ANY_INDEX_MAY_BE_UNIQUE))
set_if_bigger(share->max_unique_length,keyinfo->key_length);
}
/*
The next call is here for MyRocks/MariaRocks: Now, we have filled in
field and key definitions, give the storage engine a chance to adjust
its properties.
MyRocks may (and typically does) adjust HA_PRIMARY_KEY_IN_READ_INDEX
flag in this call.
*/
if (handler_file->init_with_fields())
goto err;
if (primary_key < MAX_KEY && (handler_file->ha_table_flags() &
HA_PRIMARY_KEY_IN_READ_INDEX))
{
keyinfo= &share->key_info[primary_key];
key_part= keyinfo->key_part;
for (i=0 ; i < keyinfo->user_defined_key_parts ; key_part++,i++)
{
Field *field= key_part->field;
/*
If this field is part of the primary key and all keys contains
the primary key, then we can use any key to find this column
*/
if (field->key_length() == key_part->length &&
!(field->flags & BLOB_FLAG))
field->part_of_key= share->keys_in_use;
if (field->part_of_sortkey.is_set(primary_key))
field->part_of_sortkey= share->keys_in_use;
}
}
if (primary_key < MAX_KEY &&
(share->keys_in_use.is_set(primary_key)))
{
......
......@@ -640,18 +640,24 @@ class ha_rocksdb: public my_core::handler
HA_REC_NOT_IN_SEQ
If we don't set it, filesort crashes, because it assumes rowids are
1..8 byte numbers
HA_PRIMARY_KEY_IN_READ_INDEX
This flag is always set, even for tables that:
- have no PK
- have some (or all) of PK that can't be decoded from the secondary
index.
*/
return HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE |
HA_REC_NOT_IN_SEQ | HA_CAN_INDEX_BLOBS |
(m_pk_can_be_decoded? HA_PRIMARY_KEY_IN_READ_INDEX : 0) |
HA_PRIMARY_KEY_IN_READ_INDEX |
HA_PRIMARY_KEY_REQUIRED_FOR_POSITION |
HA_NULL_IN_KEY |
HA_PARTIAL_COLUMN_READ |
HA_TABLE_SCAN_ON_INDEX;
}
//#ifdef MARIAROCKS_NOT_YET
bool init_with_fields() override;
//#endif
private:
bool init_with_fields(); /* no 'override' in MariaDB */
public:
/** @brief
This is a bitmap of flags that indicates how the storage engine
implements indexes. The current index flags are documented in
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment