diff options
author | Sergei Golubchik <sergii@pisem.net> | 2014-02-22 22:51:20 +0100 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2014-02-22 22:51:20 +0100 |
commit | ff2e82f4a175b7b023cd167b2fa6e6fcd1bd192e (patch) | |
tree | 63150adc067c1bb6cb476eef00094083e1a53865 /sql | |
parent | 004642525d8c4ed02686719395faf477e94cd618 (diff) | |
parent | 3e03c9eae9089cd2cae0f378bd81ff29367f41eb (diff) | |
download | mariadb-git-ff2e82f4a175b7b023cd167b2fa6e6fcd1bd192e.tar.gz |
5.3 merge
Diffstat (limited to 'sql')
-rw-r--r-- | sql/filesort.cc | 79 | ||||
-rw-r--r-- | sql/item.h | 1 | ||||
-rw-r--r-- | sql/item_geofunc.cc | 6 | ||||
-rw-r--r-- | sql/opt_subselect.cc | 1 | ||||
-rw-r--r-- | sql/spatial.cc | 3 | ||||
-rw-r--r-- | sql/sql_lifo_buffer.h | 3 | ||||
-rw-r--r-- | sql/sql_select.cc | 5 | ||||
-rw-r--r-- | sql/sql_select.h | 3 |
8 files changed, 94 insertions, 7 deletions
diff --git a/sql/filesort.cc b/sql/filesort.cc index 0c91e42d426..4183c28f05b 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -424,6 +424,84 @@ static uchar *read_buffpek_from_file(IO_CACHE *buffpek_pointers, uint count, } #ifndef DBUG_OFF + +/* Buffer where record is returned */ +char dbug_print_row_buff[512]; + +/* Temporary buffer for printing a column */ +char dbug_print_row_buff_tmp[512]; + +/* + Print table's current row into a buffer and return a pointer to it. + + This is intended to be used from gdb: + + (gdb) p dbug_print_table_row(table) + $33 = "SUBQUERY2_t1(col_int_key,col_varchar_nokey)=(7,c)" + (gdb) + + Only columns in table->read_set are printed +*/ + +const char* dbug_print_table_row(TABLE *table) +{ + Field **pfield; + String tmp(dbug_print_row_buff_tmp, + sizeof(dbug_print_row_buff_tmp),&my_charset_bin); + + String output(dbug_print_row_buff, sizeof(dbug_print_row_buff), + &my_charset_bin); + + output.length(0); + output.append(table->alias); + output.append("("); + bool first= true; + + for (pfield= table->field; *pfield ; pfield++) + { + if (table->read_set && !bitmap_is_set(table->read_set, (*pfield)->field_index)) + continue; + + if (first) + first= false; + else + output.append(","); + + output.append((*pfield)->field_name? (*pfield)->field_name: "NULL"); + } + + output.append(")=("); + + first= true; + for (pfield= table->field; *pfield ; pfield++) + { + Field *field= *pfield; + + if (table->read_set && !bitmap_is_set(table->read_set, (*pfield)->field_index)) + continue; + + if (first) + first= false; + else + output.append(","); + + if (field->is_null()) + output.append("NULL"); + else + { + if (field->type() == MYSQL_TYPE_BIT) + (void) field->val_int_as_str(&tmp, 1); + else + field->val_str(&tmp); + output.append(tmp.ptr(), tmp.length()); + } + } + output.append(")"); + + return output.c_ptr_safe(); +} + + /* Print a text, SQL-like record representation into dbug trace. @@ -472,6 +550,7 @@ static void dbug_print_record(TABLE *table, bool print_rowid) fprintf(DBUG_FILE, "\n"); DBUG_UNLOCK_FILE; } + #endif /** diff --git a/sql/item.h b/sql/item.h index ec69f5316a6..0714ea835f8 100644 --- a/sql/item.h +++ b/sql/item.h @@ -3406,6 +3406,7 @@ public: void cleanup() { null_ref_table= NULL; + item_equal= NULL; Item_direct_ref::cleanup(); } }; diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc index b5289c9b3cc..a38e9d416a7 100644 --- a/sql/item_geofunc.cc +++ b/sql/item_geofunc.cc @@ -859,7 +859,7 @@ String *Item_func_spatial_operation::val_str(String *str_value) str_value->length(0); str_value->q_append(srid); - if (!Geometry::create_from_opresult(&buffer1, str_value, res_receiver)) + if (Geometry::create_from_opresult(&buffer1, str_value, res_receiver)) goto exit; exit: @@ -1116,6 +1116,8 @@ int Item_func_buffer::Transporter::start_line() { if (buffer_op == Gcalc_function::op_difference) { + if (m_fn->reserve_op_buffer(1)) + return 1; m_fn->add_operation(Gcalc_function::op_false, 0); skip_line= TRUE; return 0; @@ -1317,7 +1319,7 @@ String *Item_func_buffer::val_str(String *str_value) str_value->length(0); str_value->q_append(srid); - if (!Geometry::create_from_opresult(&buffer, str_value, res_receiver)) + if (Geometry::create_from_opresult(&buffer, str_value, res_receiver)) goto mem_error; null_value= 0; diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index 8135fe9dba1..794b4f9b750 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -5276,6 +5276,7 @@ bool setup_jtbm_semi_joins(JOIN *join, List<TABLE_LIST> *join_list, if (!(*join_where)->fixed) (*join_where)->fix_fields(join->thd, join_where); } + table->table->maybe_null= test(join->mixed_implicit_grouping); } if ((nested_join= table->nested_join)) diff --git a/sql/spatial.cc b/sql/spatial.cc index b82e6977f8a..34d2417f632 100644 --- a/sql/spatial.cc +++ b/sql/spatial.cc @@ -302,7 +302,8 @@ int Geometry::create_from_opresult(Geometry_buffer *g_buf, res->q_append((char) wkb_ndr); res->q_append(geom_type); - return obj->init_from_opresult(res, rr.result(), rr.length()); + return obj->init_from_opresult(res, rr.result(), rr.length()) == 0 && + rr.length(); } diff --git a/sql/sql_lifo_buffer.h b/sql/sql_lifo_buffer.h index 5b7ddf35474..feec4aeb4c2 100644 --- a/sql/sql_lifo_buffer.h +++ b/sql/sql_lifo_buffer.h @@ -83,7 +83,8 @@ public: { start= start_arg; end= end_arg; - TRASH(start, end - start); + if (end != start) + TRASH(start, end - start); reset(); } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 84ccd51004e..35267e6617c 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -663,7 +663,7 @@ JOIN::prepare(Item ***rref_pointer_array, aggregate functions in the SELECT list is a MySQL exptenstion that is allowed only if the ONLY_FULL_GROUP_BY sql mode is not set. */ - bool mixed_implicit_grouping= false; + mixed_implicit_grouping= false; if ((~thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY) && select_lex->with_sum_func && !group_list) { @@ -702,7 +702,7 @@ JOIN::prepare(Item ***rref_pointer_array, Note: this loop doesn't touch tables inside merged semi-joins, because subquery-to-semijoin conversion has not been done yet. This is intended. */ - if (mixed_implicit_grouping) + if (mixed_implicit_grouping && tbl->table) tbl->table->maybe_null= 1; } @@ -3603,6 +3603,7 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list, join->impossible_where= false; if (conds && const_count) { + conds->update_used_tables(); conds= remove_eq_conds(join->thd, conds, &join->cond_value); join->select_lex->where= conds; if (join->cond_value == Item::COND_FALSE) diff --git a/sql/sql_select.h b/sql/sql_select.h index 0d7ea6d9121..30d2f4abe56 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -1129,7 +1129,8 @@ public: */ JOIN *tmp_join; ROLLUP rollup; ///< Used with rollup - + + bool mixed_implicit_grouping; bool select_distinct; ///< Set if SELECT DISTINCT /** If we have the GROUP BY statement in the query, |