mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
MariaRocks port: Return correct value of HA_PRIMARY_KEY_IN_READ_INDEX flag
This cset just re-uses the approach from facebook/mysql-5.6 (Perhaps we will have something different for MariaDB in the end). For now this is: Port this fix dd7eeae69503cb8ab6ddc8fd9e2fef451cc31a32 Issue#250: MyRocks/Innodb different output from query with order by on table with index and decimal type Summary: Make open_binary_frm() set TABLE_SHARE::primary_key before it computes Also add the patch for https://github.com/facebook/mysql-5.6/issues/376
This commit is contained in:
@ -421,6 +421,22 @@ 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,6 +307,8 @@ public:
|
||||
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
|
||||
|
@ -2757,6 +2757,8 @@ public:
|
||||
{
|
||||
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);
|
||||
|
44
sql/table.cc
44
sql/table.cc
@ -2061,18 +2061,6 @@ 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)
|
||||
{
|
||||
@ -2132,6 +2120,38 @@ 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)))
|
||||
{
|
||||
|
@ -4075,7 +4075,7 @@ bool ha_rocksdb::same_table(const ha_rocksdb& other) const
|
||||
return m_tbl_def->base_tablename() == other.m_tbl_def->base_tablename();
|
||||
}
|
||||
|
||||
#ifdef MARIAROCKS_NOT_YET
|
||||
|
||||
bool ha_rocksdb::init_with_fields()
|
||||
{
|
||||
uint pk= table_share->primary_key;
|
||||
@ -4090,7 +4090,7 @@ bool ha_rocksdb::init_with_fields()
|
||||
cached_table_flags= table_flags();
|
||||
return false; /* Ok */
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
Convert record from table->record[0] form into a form that can be written
|
||||
@ -4884,6 +4884,7 @@ int ha_rocksdb::open(const char *name, int mode, uint test_if_locked)
|
||||
DBUG_RETURN(err);
|
||||
}
|
||||
|
||||
init_with_fields();
|
||||
setup_field_converters();
|
||||
|
||||
info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST);
|
||||
|
@ -592,9 +592,9 @@ public:
|
||||
HA_PARTIAL_COLUMN_READ |
|
||||
HA_TABLE_SCAN_ON_INDEX;
|
||||
}
|
||||
#ifdef MARIAROCKS_NOT_YET
|
||||
//#ifdef MARIAROCKS_NOT_YET
|
||||
bool init_with_fields() override;
|
||||
#endif
|
||||
//#endif
|
||||
/** @brief
|
||||
This is a bitmap of flags that indicates how the storage engine
|
||||
implements indexes. The current index flags are documented in
|
||||
|
Reference in New Issue
Block a user