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

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.
This commit is contained in:
Alexander Nozdrin
2011-05-06 15:39:40 +04:00
parent 167d2896e5
commit 52efe3e00d
6 changed files with 21 additions and 13 deletions

View File

@@ -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 error, const char *str, myf MyFlags);
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;