#At file:///home/alik/MySQL/bzr/00/bug60025/mysql-5.5-bug60025/ based on revid:magnus.blaudd@stripped
3496 Alexander Nozdrin 2011-05-06
Preliminary patch for Bug#11848763 / 60025
(SUBSTRING inside a stored function works too slow).
Background:
- THD classes derives from Query_arena, thus inherits the 'state'
attribute and related operations (is_stmt_prepare() & co).
- Although these operations are available in THD, they must not
be used. THD has its own attribute to point to the active
Query_arena -- stmt_arena.
- So, instead of using thd->is_stmt_prepare(),
thd->stmt_arena->is_stmt_prepare() must be used. This was the root
cause of Bug 60025.
This patch enforces the proper way of calling those operations.
is_stmt_prepare() & co are declared as private operations
in THD (thus, they are hidden from being called on THD instance).
The patch tries to minimize changes in 5.5.
modified:
sql/item.cc
sql/item_cmpfunc.cc
sql/item_func.cc
sql/item_row.cc
sql/item_strfunc.cc
sql/sql_class.h
=== modified file 'sql/item.cc'
--- a/sql/item.cc 2011-04-08 13:15:23 +0000
+++ b/sql/item.cc 2011-05-06 11:39:40 +0000
@@ -581,7 +581,7 @@ void Item::rename(char *new_name)
Item* Item::transform(Item_transformer transformer, uchar *arg)
{
- DBUG_ASSERT(!current_thd->is_stmt_prepare());
+ DBUG_ASSERT(!current_thd->stmt_arena->is_stmt_prepare());
return (this->*transformer)(arg);
}
@@ -1845,7 +1845,7 @@ bool agg_item_set_converter(DTCollation
been created in prepare. In this case register the change for
rollback.
*/
- if (thd->is_stmt_prepare())
+ if (thd->stmt_arena->is_stmt_prepare())
*arg= conv;
else
thd->change_item_tree(arg, conv);
@@ -6965,7 +6965,7 @@ int Item_default_value::save_in_field(Fi
Item *Item_default_value::transform(Item_transformer transformer, uchar *args)
{
- DBUG_ASSERT(!current_thd->is_stmt_prepare());
+ DBUG_ASSERT(!current_thd->stmt_arena->is_stmt_prepare());
/*
If the value of arg is NULL, then this object represents a constant,
=== modified file 'sql/item_cmpfunc.cc'
--- a/sql/item_cmpfunc.cc 2011-05-06 08:27:04 +0000
+++ b/sql/item_cmpfunc.cc 2011-05-06 11:39:40 +0000
@@ -4345,7 +4345,7 @@ bool Item_cond::walk(Item_processor proc
Item *Item_cond::transform(Item_transformer transformer, uchar *arg)
{
- DBUG_ASSERT(!current_thd->is_stmt_prepare());
+ DBUG_ASSERT(!current_thd->stmt_arena->is_stmt_prepare());
List_iterator<Item> li(list);
Item *item;
@@ -5718,7 +5718,7 @@ bool Item_equal::walk(Item_processor pro
Item *Item_equal::transform(Item_transformer transformer, uchar *arg)
{
- DBUG_ASSERT(!current_thd->is_stmt_prepare());
+ DBUG_ASSERT(!current_thd->stmt_arena->is_stmt_prepare());
List_iterator<Item_field> it(fields);
Item *item;
=== modified file 'sql/item_func.cc'
--- a/sql/item_func.cc 2011-05-06 08:27:04 +0000
+++ b/sql/item_func.cc 2011-05-06 11:39:40 +0000
@@ -293,7 +293,7 @@ void Item_func::traverse_cond(Cond_trave
Item *Item_func::transform(Item_transformer transformer, uchar *argument)
{
- DBUG_ASSERT(!current_thd->is_stmt_prepare());
+ DBUG_ASSERT(!current_thd->stmt_arena->is_stmt_prepare());
if (arg_count)
{
=== modified file 'sql/item_row.cc'
--- a/sql/item_row.cc 2011-03-08 17:39:25 +0000
+++ b/sql/item_row.cc 2011-05-06 11:39:40 +0000
@@ -170,7 +170,7 @@ bool Item_row::walk(Item_processor proce
Item *Item_row::transform(Item_transformer transformer, uchar *arg)
{
- DBUG_ASSERT(!current_thd->is_stmt_prepare());
+ DBUG_ASSERT(!current_thd->stmt_arena->is_stmt_prepare());
for (uint i= 0; i < arg_count; i++)
{
=== modified file 'sql/item_strfunc.cc'
--- a/sql/item_strfunc.cc 2011-04-08 13:15:23 +0000
+++ b/sql/item_strfunc.cc 2011-05-06 11:39:40 +0000
@@ -2536,7 +2536,7 @@ String *Item_func_make_set::val_str(Stri
Item *Item_func_make_set::transform(Item_transformer transformer, uchar *arg)
{
- DBUG_ASSERT(!current_thd->is_stmt_prepare());
+ DBUG_ASSERT(!current_thd->stmt_arena->is_stmt_prepare());
Item *new_item= item->transform(transformer, arg);
if (!new_item)
=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h 2011-04-15 12:02:22 +0000
+++ b/sql/sql_class.h 2011-05-06 11:39:40 +0000
@@ -655,15 +655,10 @@ public:
virtual ~Query_arena() {};
inline bool is_stmt_prepare() const { return state == INITIALIZED; }
- inline bool is_first_sp_execute() const
- { return state == INITIALIZED_FOR_SP; }
inline bool is_stmt_prepare_or_first_sp_execute() const
{ return (int)state < (int)PREPARED; }
inline bool is_stmt_prepare_or_first_stmt_execute() const
{ return (int)state <= (int)PREPARED; }
- inline bool is_first_stmt_execute() const { return state == PREPARED; }
- inline bool is_stmt_execute() const
- { return state == PREPARED || state == EXECUTED; }
inline bool is_conventional() const
{ return state == CONVENTIONAL_EXECUTION; }
@@ -1434,6 +1429,19 @@ extern "C" void my_message_sql(uint erro
class THD :public Statement,
public Open_tables_state
{
+private:
+ inline bool is_stmt_prepare() const
+ { DBUG_ASSERT(0); return Statement::is_stmt_prepare(); }
+
+ inline bool is_stmt_prepare_or_first_sp_execute() const
+ { DBUG_ASSERT(0); return Statement::is_stmt_prepare_or_first_sp_execute(); }
+
+ inline bool is_stmt_prepare_or_first_stmt_execute() const
+ { DBUG_ASSERT(0); return Statement::is_stmt_prepare_or_first_stmt_execute(); }
+
+ inline bool is_conventional() const
+ { DBUG_ASSERT(0); return Statement::is_conventional(); }
+
public:
MDL_context mdl_context;
Attachment: [text/bzr-bundle] bzr/alexander.nozdrin@oracle.com-20110506113940-vi12q2mulw2cr768.bundle
| Thread |
|---|
| • bzr commit into mysql-5.5 branch (alexander.nozdrin:3496) Bug#11848763 | Alexander Nozdrin | 6 May |