1
0
mirror of https://github.com/MariaDB/server.git synced 2026-01-06 05:22:24 +03:00

Merge branch '5.5' into 10.0

This commit is contained in:
Sergei Golubchik
2016-04-26 23:05:26 +02:00
109 changed files with 1309 additions and 319 deletions

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2000, 2015 Oracle and/or its affiliates.
/* Copyright (c) 2000, 2016 Oracle and/or its affiliates.
Copyright (c) 2009, 2016 MariaDB
This program is free software; you can redistribute it and/or modify
@@ -15437,6 +15437,14 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table,
Field *new_field;
LINT_INIT(new_field);
/*
To preserve type or DATE/TIME and GEOMETRY fields,
they need to be handled separately.
*/
if (item->cmp_type() == TIME_RESULT ||
item->field_type() == MYSQL_TYPE_GEOMETRY)
new_field= item->tmp_table_field_from_field_type(table, 1);
else
switch (item->result_type()) {
case REAL_RESULT:
new_field= new Field_double(item->max_length, maybe_null,
@@ -15459,18 +15467,11 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table,
case STRING_RESULT:
DBUG_ASSERT(item->collation.collation);
/*
DATE/TIME and GEOMETRY fields have STRING_RESULT result type.
To preserve type they needed to be handled separately.
*/
if (item->cmp_type() == TIME_RESULT ||
item->field_type() == MYSQL_TYPE_GEOMETRY)
new_field= item->tmp_table_field_from_field_type(table, 1);
/*
Make sure that the blob fits into a Field_varstring which has
2-byte lenght.
*/
else if (item->max_length/item->collation.collation->mbmaxlen > 255 &&
if (item->max_length/item->collation.collation->mbmaxlen > 255 &&
convert_blob_length <= Field_varstring::MAX_SIZE &&
convert_blob_length)
new_field= new Field_varstring(convert_blob_length, maybe_null,
@@ -24182,33 +24183,53 @@ static void print_join(THD *thd,
/* List is reversed => we should reverse it before using */
List_iterator_fast<TABLE_LIST> ti(*tables);
TABLE_LIST **table;
uint non_const_tables= 0;
DBUG_ENTER("print_join");
/*
If the QT_NO_DATA_EXPANSION flag is specified, we print the
original table list, including constant tables that have been
optimized away, as the constant tables may be referenced in the
expression printed by Item_field::print() when this flag is given.
Otherwise, only non-const tables are printed.
Example:
Original SQL:
select * from (select 1) t
Printed without QT_NO_DATA_EXPANSION:
select '1' AS `1` from dual
Printed with QT_NO_DATA_EXPANSION:
select `t`.`1` from (select 1 AS `1`) `t`
*/
const bool print_const_tables= (query_type & QT_NO_DATA_EXPANSION);
size_t tables_to_print= 0;
for (TABLE_LIST *t= ti++; t ; t= ti++)
{
/*
See comment in print_table_array() about the second part of the
condition
*/
if (!t->optimized_away && !is_eliminated_table(eliminated_tables, t))
non_const_tables++;
/* See comment in print_table_array() about the second condition */
if (print_const_tables || !t->optimized_away)
if (!is_eliminated_table(eliminated_tables, t))
tables_to_print++;
}
if (!non_const_tables)
if (tables_to_print == 0)
{
str->append(STRING_WITH_LEN("dual"));
DBUG_VOID_RETURN; // all tables were optimized away
}
ti.rewind();
if (!(table= (TABLE_LIST **)thd->alloc(sizeof(TABLE_LIST*) *
non_const_tables)))
if (!(table= static_cast<TABLE_LIST **>(thd->alloc(sizeof(TABLE_LIST*) *
tables_to_print))))
DBUG_VOID_RETURN; // out of memory
TABLE_LIST *tmp, **t= table + (non_const_tables - 1);
TABLE_LIST *tmp, **t= table + (tables_to_print - 1);
while ((tmp= ti++))
{
if (tmp->optimized_away || is_eliminated_table(eliminated_tables, tmp))
if (tmp->optimized_away && !print_const_tables)
continue;
if (is_eliminated_table(eliminated_tables, tmp))
continue;
*t--= tmp;
}
@@ -24228,7 +24249,7 @@ static void print_join(THD *thd,
*/
if ((*table)->sj_inner_tables)
{
TABLE_LIST **end= table + non_const_tables;
TABLE_LIST **end= table + tables_to_print;
for (TABLE_LIST **t2= table; t2!=end; t2++)
{
if (!(*t2)->sj_inner_tables)
@@ -24241,7 +24262,7 @@ static void print_join(THD *thd,
}
}
print_table_array(thd, eliminated_tables, str, table,
table + non_const_tables, query_type);
table + tables_to_print, query_type);
DBUG_VOID_RETURN;
}