1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Merge bk-internal.mysql.com:/home/bk/mysql-5.1

into  bodhi.(none):/opt/local/work/mysql-5.1-27430
This commit is contained in:
kostja@bodhi.(none)
2008-05-20 11:38:17 +04:00
47 changed files with 5573 additions and 5011 deletions

View File

@ -23,6 +23,51 @@
#include "log.h"
#include "rpl_tblmap.h"
/**
An interface that is used to take an action when
the locking module notices that a table version has changed
since the last execution. "Table" here may refer to any kind of
table -- a base table, a temporary table, a view or an
information schema table.
When we open and lock tables for execution of a prepared
statement, we must verify that they did not change
since statement prepare. If some table did change, the statement
parse tree *may* be no longer valid, e.g. in case it contains
optimizations that depend on table metadata.
This class provides an interface (a method) that is
invoked when such a situation takes place.
The implementation of the method simply reports an error, but
the exact details depend on the nature of the SQL statement.
At most 1 instance of this class is active at a time, in which
case THD::m_reprepare_observer is not NULL.
@sa check_and_update_table_version() for details of the
version tracking algorithm
@sa Open_tables_state::m_reprepare_observer for the life cycle
of metadata observers.
*/
class Reprepare_observer
{
public:
/**
Check if a change of metadata is OK. In future
the signature of this method may be extended to accept the old
and the new versions, but since currently the check is very
simple, we only need the THD to report an error.
*/
bool report_error(THD *thd);
bool is_invalidated() const { return m_invalidated; }
void reset_reprepare_observer() { m_invalidated= FALSE; }
private:
bool m_invalidated;
};
class Relay_log_info;
class Query_log_event;
@ -406,6 +451,7 @@ typedef struct system_status_var
ulong filesort_scan_count;
/* Prepared statements and binary protocol */
ulong com_stmt_prepare;
ulong com_stmt_reprepare;
ulong com_stmt_execute;
ulong com_stmt_send_long_data;
ulong com_stmt_fetch;
@ -436,7 +482,7 @@ void free_tmp_table(THD *thd, TABLE *entry);
/* The following macro is to make init of Query_arena simpler */
#ifndef DBUG_OFF
#define INIT_ARENA_DBUG_INFO is_backup_arena= 0
#define INIT_ARENA_DBUG_INFO is_backup_arena= 0; is_reprepared= FALSE;
#else
#define INIT_ARENA_DBUG_INFO
#endif
@ -452,6 +498,7 @@ public:
MEM_ROOT *mem_root; // Pointer to current memroot
#ifndef DBUG_OFF
bool is_backup_arena; /* True if this arena is used for backup. */
bool is_reprepared;
#endif
/*
The states relfects three diffrent life cycles for three
@ -788,6 +835,20 @@ enum prelocked_mode_type {NON_PRELOCKED= 0, PRELOCKED= 1,
class Open_tables_state
{
public:
/**
As part of class THD, this member is set during execution
of a prepared statement. When it is set, it is used
by the locking subsystem to report a change in table metadata.
When Open_tables_state part of THD is reset to open
a system or INFORMATION_SCHEMA table, the member is cleared
to avoid spurious ER_NEED_REPREPARE errors -- system and
INFORMATION_SCHEMA tables are not subject to metadata version
tracking.
@sa check_and_update_table_version()
*/
Reprepare_observer *m_reprepare_observer;
/**
List of regular tables in use by this thread. Contains temporary and
base tables that were opened with @see open_tables().
@ -891,6 +952,7 @@ public:
extra_lock= lock= locked_tables= 0;
prelocked_mode= NON_PRELOCKED;
state_flags= 0U;
m_reprepare_observer= NULL;
}
};
@ -2812,6 +2874,20 @@ public:
#define CF_STATUS_COMMAND 4
#define CF_SHOW_TABLE_COMMAND 8
#define CF_WRITE_LOGS_COMMAND 16
/**
Must be set for SQL statements that may contain
Item expressions and/or use joins and tables.
Indicates that the parse tree of such statement may
contain rule-based optimizations that depend on metadata
(i.e. number of columns in a table), and consequently
that the statement must be re-prepared whenever
referenced metadata changes. Must not be set for
statements that themselves change metadata, e.g. RENAME,
ALTER and other DDL, since otherwise will trigger constant
reprepare. Consequently, complex item expressions and
joins are currently prohibited in these statements.
*/
#define CF_REEXECUTION_FRAGILE 32
/* Functions in sql_class.cc */