mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Merged 5.1 with maria 5.1
This commit is contained in:
137
sql/sql_class.h
137
sql/sql_class.h
@ -22,6 +22,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;
|
||||
};
|
||||
|
||||
#include <waiting_threads.h>
|
||||
|
||||
class Relay_log_info;
|
||||
@ -32,6 +77,7 @@ class Slave_log_event;
|
||||
class sp_rcontext;
|
||||
class sp_cache;
|
||||
class Lex_input_stream;
|
||||
class Parser_state;
|
||||
class Rows_log_event;
|
||||
|
||||
enum enum_enable_or_disable { LEAVE_AS_IS, ENABLE, DISABLE };
|
||||
@ -410,6 +456,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;
|
||||
@ -440,7 +487,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
|
||||
@ -456,6 +503,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
|
||||
@ -792,6 +840,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().
|
||||
@ -895,6 +957,7 @@ public:
|
||||
extra_lock= lock= locked_tables= 0;
|
||||
prelocked_mode= NON_PRELOCKED;
|
||||
state_flags= 0U;
|
||||
m_reprepare_observer= NULL;
|
||||
}
|
||||
};
|
||||
|
||||
@ -1303,9 +1366,14 @@ public:
|
||||
Rows_log_event* binlog_get_pending_rows_event() const;
|
||||
void binlog_set_pending_rows_event(Rows_log_event* ev);
|
||||
int binlog_flush_pending_rows_event(bool stmt_end);
|
||||
int binlog_remove_pending_rows_event(bool clear_maps);
|
||||
|
||||
private:
|
||||
uint binlog_table_maps; // Number of table maps currently in the binlog
|
||||
/*
|
||||
Number of outstanding table maps, i.e., table maps in the
|
||||
transaction cache.
|
||||
*/
|
||||
uint binlog_table_maps;
|
||||
|
||||
enum enum_binlog_flag {
|
||||
BINLOG_FLAG_UNSAFE_STMT_PRINTED,
|
||||
@ -1389,6 +1457,13 @@ public:
|
||||
Note: in the parser, stmt_arena == thd, even for PS/SP.
|
||||
*/
|
||||
Query_arena *stmt_arena;
|
||||
|
||||
/*
|
||||
map for tables that will be updated for a multi-table update query
|
||||
statement, for other query statements, this will be zero.
|
||||
*/
|
||||
table_map table_map_for_update;
|
||||
|
||||
/* Tells if LAST_INSERT_ID(#) was called for the current statement */
|
||||
bool arg_of_last_insert_id_function;
|
||||
/*
|
||||
@ -1714,13 +1789,11 @@ public:
|
||||
} binlog_evt_union;
|
||||
|
||||
/**
|
||||
Character input stream consumed by the lexical analyser,
|
||||
used during parsing.
|
||||
Note that since the parser is not re-entrant, we keep only one input
|
||||
stream here. This member is valid only when executing code during parsing,
|
||||
and may point to invalid memory after that.
|
||||
Internal parser state.
|
||||
Note that since the parser is not re-entrant, we keep only one parser
|
||||
state here. This member is valid only when executing code during parsing.
|
||||
*/
|
||||
Lex_input_stream *m_lip;
|
||||
Parser_state *m_parser_state;
|
||||
|
||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||
partition_info *work_part_info;
|
||||
@ -2198,6 +2271,7 @@ class select_result :public Sql_alloc {
|
||||
protected:
|
||||
THD *thd;
|
||||
SELECT_LEX_UNIT *unit;
|
||||
uint nest_level;
|
||||
public:
|
||||
select_result();
|
||||
virtual ~select_result() {};
|
||||
@ -2234,6 +2308,12 @@ public:
|
||||
*/
|
||||
virtual void cleanup();
|
||||
void set_thd(THD *thd_arg) { thd= thd_arg; }
|
||||
/**
|
||||
The nest level, if supported.
|
||||
@return
|
||||
-1 if nest level is undefined, otherwise a positive integer.
|
||||
*/
|
||||
int get_nest_level() { return nest_level; }
|
||||
#ifdef EMBEDDED_LIBRARY
|
||||
virtual void begin_dataset() {}
|
||||
#else
|
||||
@ -2327,6 +2407,14 @@ class select_export :public select_to_file {
|
||||
bool fixed_row_size;
|
||||
public:
|
||||
select_export(sql_exchange *ex) :select_to_file(ex) {}
|
||||
/**
|
||||
Creates a select_export to represent INTO OUTFILE <filename> with a
|
||||
defined level of subquery nesting.
|
||||
*/
|
||||
select_export(sql_exchange *ex, uint nest_level_arg) :select_to_file(ex)
|
||||
{
|
||||
nest_level= nest_level_arg;
|
||||
}
|
||||
~select_export();
|
||||
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
|
||||
bool send_data(List<Item> &items);
|
||||
@ -2336,6 +2424,15 @@ public:
|
||||
class select_dump :public select_to_file {
|
||||
public:
|
||||
select_dump(sql_exchange *ex) :select_to_file(ex) {}
|
||||
/**
|
||||
Creates a select_export to represent INTO DUMPFILE <filename> with a
|
||||
defined level of subquery nesting.
|
||||
*/
|
||||
select_dump(sql_exchange *ex, uint nest_level_arg) :
|
||||
select_to_file(ex)
|
||||
{
|
||||
nest_level= nest_level_arg;
|
||||
}
|
||||
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
|
||||
bool send_data(List<Item> &items);
|
||||
};
|
||||
@ -2775,6 +2872,16 @@ class select_dumpvar :public select_result_interceptor {
|
||||
public:
|
||||
List<my_var> var_list;
|
||||
select_dumpvar() { var_list.empty(); row_count= 0;}
|
||||
/**
|
||||
Creates a select_dumpvar to represent INTO <variable> with a defined
|
||||
level of subquery nesting.
|
||||
*/
|
||||
select_dumpvar(uint nest_level_arg)
|
||||
{
|
||||
var_list.empty();
|
||||
row_count= 0;
|
||||
nest_level= nest_level_arg;
|
||||
}
|
||||
~select_dumpvar() {}
|
||||
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
|
||||
bool send_data(List<Item> &items);
|
||||
@ -2790,6 +2897,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 */
|
||||
|
||||
|
Reference in New Issue
Block a user