mirror of
https://github.com/MariaDB/server.git
synced 2026-05-09 16:44:29 +02:00
Merge gleb.loc:/home/uchum/work/bk/5.1
into gleb.loc:/home/uchum/work/bk/5.1-opt mysql-test/r/sp.result: Auto merged mysql-test/t/create.test: Auto merged sql/field.cc: Auto merged sql/sql_base.cc: Auto merged sql/sql_lex.cc: Auto merged sql/sql_lex.h: Auto merged sql/table.cc: Auto merged mysql-test/r/create.result: Merge with 5.1 (main).
This commit is contained in:
commit
217a35d64f
24 changed files with 648 additions and 49 deletions
|
|
@ -7901,8 +7901,11 @@ int Field_enum::store(longlong nr, bool unsigned_val)
|
|||
if ((ulonglong) nr > typelib->count || nr == 0)
|
||||
{
|
||||
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1);
|
||||
nr=0;
|
||||
error=1;
|
||||
if (nr != 0 || table->in_use->count_cuted_fields)
|
||||
{
|
||||
nr= 0;
|
||||
error= 1;
|
||||
}
|
||||
}
|
||||
store_type((ulonglong) (uint) nr);
|
||||
return error;
|
||||
|
|
|
|||
|
|
@ -5599,10 +5599,20 @@ Item_func_sp::fix_fields(THD *thd, Item **ref)
|
|||
|
||||
#endif /* ! NO_EMBEDDED_ACCESS_CHECKS */
|
||||
}
|
||||
if (!m_sp->m_chistics->detistic)
|
||||
used_tables_cache |= RAND_TABLE_BIT;
|
||||
DBUG_RETURN(res);
|
||||
}
|
||||
|
||||
|
||||
void Item_func_sp::update_used_tables()
|
||||
{
|
||||
Item_func::update_used_tables();
|
||||
if (!m_sp->m_chistics->detistic)
|
||||
used_tables_cache |= RAND_TABLE_BIT;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
uuid_short handling.
|
||||
|
||||
|
|
|
|||
|
|
@ -1472,7 +1472,7 @@ public:
|
|||
virtual ~Item_func_sp()
|
||||
{}
|
||||
|
||||
table_map used_tables() const { return RAND_TABLE_BIT; }
|
||||
void update_used_tables();
|
||||
|
||||
void cleanup();
|
||||
|
||||
|
|
|
|||
|
|
@ -3797,13 +3797,6 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type)
|
|||
|
||||
if (table)
|
||||
{
|
||||
#if defined( __WIN__)
|
||||
/* Win32 can't drop a file that is open */
|
||||
if (lock_type == TL_WRITE_ALLOW_READ)
|
||||
{
|
||||
lock_type= TL_WRITE;
|
||||
}
|
||||
#endif /* __WIN__ */
|
||||
table_list->lock_type= lock_type;
|
||||
table_list->table= table;
|
||||
table->grant= table_list->grant;
|
||||
|
|
|
|||
|
|
@ -1770,7 +1770,7 @@ TABLE_LIST *st_select_lex_node::add_table_to_list (THD *thd, Table_ident *table,
|
|||
LEX_STRING *alias,
|
||||
ulong table_join_options,
|
||||
thr_lock_type flags,
|
||||
List<index_hint> *hints,
|
||||
List<Index_hint> *hints,
|
||||
LEX_STRING *option)
|
||||
{
|
||||
return 0;
|
||||
|
|
@ -2723,7 +2723,7 @@ void st_select_lex::set_index_hint_type(enum index_hint_type type,
|
|||
|
||||
void st_select_lex::alloc_index_hints (THD *thd)
|
||||
{
|
||||
index_hints= new (thd->mem_root) List<index_hint>();
|
||||
index_hints= new (thd->mem_root) List<Index_hint>();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -2744,7 +2744,7 @@ void st_select_lex::alloc_index_hints (THD *thd)
|
|||
bool st_select_lex::add_index_hint (THD *thd, char *str, uint length)
|
||||
{
|
||||
return index_hints->push_front (new (thd->mem_root)
|
||||
index_hint(current_index_hint_type,
|
||||
Index_hint(current_index_hint_type,
|
||||
current_index_hint_clause,
|
||||
str, length));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ typedef uchar index_clause_map;
|
|||
INDEX_HINT_MASK_ORDER)
|
||||
|
||||
/* Single element of an USE/FORCE/IGNORE INDEX list specified as a SQL hint */
|
||||
class index_hint : public Sql_alloc
|
||||
class Index_hint : public Sql_alloc
|
||||
{
|
||||
public:
|
||||
/* The type of the hint : USE/FORCE/IGNORE */
|
||||
|
|
@ -249,7 +249,7 @@ public:
|
|||
*/
|
||||
LEX_STRING key_name;
|
||||
|
||||
index_hint (enum index_hint_type type_arg, index_clause_map clause_arg,
|
||||
Index_hint (enum index_hint_type type_arg, index_clause_map clause_arg,
|
||||
char *str, uint length) :
|
||||
type(type_arg), clause(clause_arg)
|
||||
{
|
||||
|
|
@ -441,7 +441,7 @@ public:
|
|||
LEX_STRING *alias,
|
||||
ulong table_options,
|
||||
thr_lock_type flags= TL_UNLOCK,
|
||||
List<index_hint> *hints= 0,
|
||||
List<Index_hint> *hints= 0,
|
||||
LEX_STRING *option= 0);
|
||||
virtual void set_lock_for_tables(thr_lock_type lock_type) {}
|
||||
|
||||
|
|
@ -719,7 +719,7 @@ public:
|
|||
LEX_STRING *alias,
|
||||
ulong table_options,
|
||||
thr_lock_type flags= TL_UNLOCK,
|
||||
List<index_hint> *hints= 0,
|
||||
List<Index_hint> *hints= 0,
|
||||
LEX_STRING *option= 0);
|
||||
TABLE_LIST* get_table_list();
|
||||
bool init_nested_join(THD *thd);
|
||||
|
|
@ -779,9 +779,9 @@ public:
|
|||
/* make a list to hold index hints */
|
||||
void alloc_index_hints (THD *thd);
|
||||
/* read and clear the index hints */
|
||||
List<index_hint>* pop_index_hints(void)
|
||||
List<Index_hint>* pop_index_hints(void)
|
||||
{
|
||||
List<index_hint> *hints= index_hints;
|
||||
List<Index_hint> *hints= index_hints;
|
||||
index_hints= NULL;
|
||||
return hints;
|
||||
}
|
||||
|
|
@ -793,7 +793,7 @@ private:
|
|||
enum index_hint_type current_index_hint_type;
|
||||
index_clause_map current_index_hint_clause;
|
||||
/* a list of USE/FORCE/IGNORE INDEX */
|
||||
List<index_hint> *index_hints;
|
||||
List<Index_hint> *index_hints;
|
||||
};
|
||||
typedef class st_select_lex SELECT_LEX;
|
||||
|
||||
|
|
|
|||
|
|
@ -5636,7 +5636,7 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
|
|||
LEX_STRING *alias,
|
||||
ulong table_options,
|
||||
thr_lock_type lock_type,
|
||||
List<index_hint> *index_hints_arg,
|
||||
List<Index_hint> *index_hints_arg,
|
||||
LEX_STRING *option)
|
||||
{
|
||||
register TABLE_LIST *ptr;
|
||||
|
|
|
|||
|
|
@ -12289,6 +12289,7 @@ static int test_if_order_by_key(ORDER *order, TABLE *table, uint idx,
|
|||
key_part_end=key_part+table->key_info[idx].key_parts;
|
||||
key_part_map const_key_parts=table->const_key_parts[idx];
|
||||
int reverse=0;
|
||||
my_bool on_primary_key= FALSE;
|
||||
DBUG_ENTER("test_if_order_by_key");
|
||||
|
||||
for (; order ; order=order->next, const_key_parts>>=1)
|
||||
|
|
@ -12303,7 +12304,31 @@ static int test_if_order_by_key(ORDER *order, TABLE *table, uint idx,
|
|||
for (; const_key_parts & 1 ; const_key_parts>>= 1)
|
||||
key_part++;
|
||||
|
||||
if (key_part == key_part_end || key_part->field != field)
|
||||
if (key_part == key_part_end)
|
||||
{
|
||||
/*
|
||||
We are at the end of the key. Check if the engine has the primary
|
||||
key as a suffix to the secondary keys. If it has continue to check
|
||||
the primary key as a suffix.
|
||||
*/
|
||||
if (!on_primary_key &&
|
||||
(table->file->ha_table_flags() & HA_PRIMARY_KEY_IN_READ_INDEX) &&
|
||||
ha_legacy_type(table->s->db_type()) == DB_TYPE_INNODB &&
|
||||
table->s->primary_key != MAX_KEY)
|
||||
{
|
||||
on_primary_key= TRUE;
|
||||
key_part= table->key_info[table->s->primary_key].key_part;
|
||||
key_part_end=key_part+table->key_info[table->s->primary_key].key_parts;
|
||||
const_key_parts=table->const_key_parts[table->s->primary_key];
|
||||
|
||||
for (; const_key_parts & 1 ; const_key_parts>>= 1)
|
||||
key_part++;
|
||||
}
|
||||
else
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
if (key_part->field != field)
|
||||
DBUG_RETURN(0);
|
||||
|
||||
/* set flag to 1 if we can use read-next on key, else to -1 */
|
||||
|
|
@ -12314,7 +12339,8 @@ static int test_if_order_by_key(ORDER *order, TABLE *table, uint idx,
|
|||
reverse=flag; // Remember if reverse
|
||||
key_part++;
|
||||
}
|
||||
*used_key_parts= (uint) (key_part - table->key_info[idx].key_part);
|
||||
*used_key_parts= on_primary_key ? table->key_info[idx].key_parts :
|
||||
(uint) (key_part - table->key_info[idx].key_part);
|
||||
if (reverse == -1 && !(table->file->index_flags(idx, *used_key_parts-1, 1) &
|
||||
HA_READ_PREV))
|
||||
reverse= 0; // Index can't be used
|
||||
|
|
@ -13030,7 +13056,7 @@ remove_duplicates(JOIN *join, TABLE *entry,List<Item> &fields, Item *having)
|
|||
field_count++;
|
||||
}
|
||||
|
||||
if (!field_count && !(join->select_options & OPTION_FOUND_ROWS))
|
||||
if (!field_count && !(join->select_options & OPTION_FOUND_ROWS) && !having)
|
||||
{ // only const items with no OPTION_FOUND_ROWS
|
||||
join->unit->select_limit_cnt= 1; // Only send first row
|
||||
DBUG_RETURN(0);
|
||||
|
|
|
|||
|
|
@ -1349,7 +1349,12 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
|
|||
the primary key, then we can use any key to find this column
|
||||
*/
|
||||
if (ha_option & HA_PRIMARY_KEY_IN_READ_INDEX)
|
||||
{
|
||||
field->part_of_key= share->keys_in_use;
|
||||
if (ha_legacy_type(share->db_type()) == DB_TYPE_INNODB &&
|
||||
field->part_of_sortkey.is_set(key))
|
||||
field->part_of_sortkey= share->keys_in_use;
|
||||
}
|
||||
}
|
||||
if (field->key_length() != key_part->length)
|
||||
{
|
||||
|
|
@ -4642,11 +4647,11 @@ bool TABLE_LIST::process_index_hints(TABLE *table)
|
|||
key_map index_join[INDEX_HINT_FORCE + 1];
|
||||
key_map index_order[INDEX_HINT_FORCE + 1];
|
||||
key_map index_group[INDEX_HINT_FORCE + 1];
|
||||
index_hint *hint;
|
||||
Index_hint *hint;
|
||||
int type;
|
||||
bool have_empty_use_join= FALSE, have_empty_use_order= FALSE,
|
||||
have_empty_use_group= FALSE;
|
||||
List_iterator <index_hint> iter(*index_hints);
|
||||
List_iterator <Index_hint> iter(*index_hints);
|
||||
|
||||
/* initialize temporary variables used to collect hints of each kind */
|
||||
for (type= INDEX_HINT_IGNORE; type <= INDEX_HINT_FORCE; type++)
|
||||
|
|
|
|||
|
|
@ -754,7 +754,7 @@ public:
|
|||
(TABLE_LIST::join_using_fields != NULL)
|
||||
*/
|
||||
|
||||
class index_hint;
|
||||
class Index_hint;
|
||||
struct TABLE_LIST
|
||||
{
|
||||
TABLE_LIST() {} /* Remove gcc warning */
|
||||
|
|
@ -826,7 +826,7 @@ struct TABLE_LIST
|
|||
*/
|
||||
TABLE_LIST *next_name_resolution_table;
|
||||
/* Index names in a "... JOIN ... USE/IGNORE INDEX ..." clause. */
|
||||
List<index_hint> *index_hints;
|
||||
List<Index_hint> *index_hints;
|
||||
TABLE *table; /* opened table */
|
||||
uint table_id; /* table id (from binlog) for opened table */
|
||||
/*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue