Commit d0c69399 authored by unknown's avatar unknown

misc fixes for compile-time errors


sql/item_sum.cc:
  "unused variable" warning
sql/item_timefunc.cc:
  "unused variable" warning
sql/log_event.h:
  const bool is_valid() -> bool is_valid() const
sql/opt_range.cc:
  cast log's argument to double (otherwise an error on some compilers)
sql/opt_range.h:
  get_quick_select_for_ref should be declared in the global scope to be visible.
parent 362ce6a8
...@@ -2088,7 +2088,7 @@ Item_func_group_concat::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) ...@@ -2088,7 +2088,7 @@ Item_func_group_concat::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
result_field= 0; result_field= 0;
null_value= 1; null_value= 1;
max_length= group_concat_max_len; max_length= group_concat_max_len;
thd->allow_sum_func= 1; thd->allow_sum_func= 1;
if (!(tmp_table_param= new TMP_TABLE_PARAM)) if (!(tmp_table_param= new TMP_TABLE_PARAM))
return 1; return 1;
tables_list= tables; tables_list= tables;
...@@ -2102,7 +2102,6 @@ bool Item_func_group_concat::setup(THD *thd) ...@@ -2102,7 +2102,6 @@ bool Item_func_group_concat::setup(THD *thd)
List<Item> list; List<Item> list;
SELECT_LEX *select_lex= thd->lex->current_select; SELECT_LEX *select_lex= thd->lex->current_select;
uint const_fields; uint const_fields;
byte *record;
qsort_cmp2 compare_key; qsort_cmp2 compare_key;
DBUG_ENTER("Item_func_group_concat::setup"); DBUG_ENTER("Item_func_group_concat::setup");
...@@ -2111,7 +2110,7 @@ bool Item_func_group_concat::setup(THD *thd) ...@@ -2111,7 +2110,7 @@ bool Item_func_group_concat::setup(THD *thd)
/* /*
push all not constant fields to list and create temp table push all not constant fields to list and create temp table
*/ */
const_fields= 0; const_fields= 0;
always_null= 0; always_null= 0;
for (uint i= 0; i < arg_count_field; i++) for (uint i= 0; i < arg_count_field; i++)
...@@ -2129,15 +2128,15 @@ bool Item_func_group_concat::setup(THD *thd) ...@@ -2129,15 +2128,15 @@ bool Item_func_group_concat::setup(THD *thd)
} }
if (always_null) if (always_null)
DBUG_RETURN(0); DBUG_RETURN(0);
List<Item> all_fields(list); List<Item> all_fields(list);
if (arg_count_order) if (arg_count_order)
{ {
bool hidden_group_fields; bool hidden_group_fields;
setup_group(thd, args, tables_list, list, all_fields, *order, setup_group(thd, args, tables_list, list, all_fields, *order,
&hidden_group_fields); &hidden_group_fields);
} }
count_field_types(tmp_table_param,all_fields,0); count_field_types(tmp_table_param,all_fields,0);
if (table) if (table)
{ {
...@@ -2163,7 +2162,6 @@ bool Item_func_group_concat::setup(THD *thd) ...@@ -2163,7 +2162,6 @@ bool Item_func_group_concat::setup(THD *thd)
table->no_rows= 1; table->no_rows= 1;
key_length= table->reclength; key_length= table->reclength;
record= table->record[0];
/* Offset to first result field in table */ /* Offset to first result field in table */
field_list_offset= table->fields - (list.elements - const_fields); field_list_offset= table->fields - (list.elements - const_fields);
......
...@@ -2519,7 +2519,6 @@ longlong Item_func_timestamp_diff::val_int() ...@@ -2519,7 +2519,6 @@ longlong Item_func_timestamp_diff::val_int()
uint year; uint year;
uint year_beg, year_end, month_beg, month_end; uint year_beg, year_end, month_beg, month_end;
uint diff_days= (uint) (seconds/86400L); uint diff_days= (uint) (seconds/86400L);
uint diff_months= 0;
uint diff_years= 0; uint diff_years= 0;
if (neg == -1) if (neg == -1)
{ {
......
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
...@@ -34,8 +34,8 @@ ...@@ -34,8 +34,8 @@
#define LOG_READ_TOO_LARGE -7 #define LOG_READ_TOO_LARGE -7
#define LOG_EVENT_OFFSET 4 #define LOG_EVENT_OFFSET 4
/* /*
3 is MySQL 4.x; 4 is MySQL 5.0.0. 3 is MySQL 4.x; 4 is MySQL 5.0.0.
Compared to version 3, version 4 has: Compared to version 3, version 4 has:
- a different Start_log_event, which includes info about the binary log - a different Start_log_event, which includes info about the binary log
...@@ -58,12 +58,12 @@ ...@@ -58,12 +58,12 @@
timestamp_when_the_master_started (4 bytes), a counter (a sequence number timestamp_when_the_master_started (4 bytes), a counter (a sequence number
which increments every time we write an event to the binlog) (3 bytes). which increments every time we write an event to the binlog) (3 bytes).
Q: how do we handle when the counter is overflowed and restarts from 0 ? Q: how do we handle when the counter is overflowed and restarts from 0 ?
- Query and Load (Create or Execute) events may have a more precise timestamp - Query and Load (Create or Execute) events may have a more precise timestamp
(with microseconds), number of matched/affected/warnings rows (with microseconds), number of matched/affected/warnings rows
and fields of session variables: SQL_MODE, and fields of session variables: SQL_MODE,
FOREIGN_KEY_CHECKS, UNIQUE_CHECKS, SQL_AUTO_IS_NULL, the collations and FOREIGN_KEY_CHECKS, UNIQUE_CHECKS, SQL_AUTO_IS_NULL, the collations and
charsets, the PASSWORD() version (old/new/...). charsets, the PASSWORD() version (old/new/...).
*/ */
#define BINLOG_VERSION 4 #define BINLOG_VERSION 4
...@@ -128,11 +128,11 @@ struct sql_ex_info ...@@ -128,11 +128,11 @@ struct sql_ex_info
char* escaped; char* escaped;
int cached_new_format; int cached_new_format;
uint8 field_term_len,enclosed_len,line_term_len,line_start_len, escaped_len; uint8 field_term_len,enclosed_len,line_term_len,line_start_len, escaped_len;
char opt_flags; char opt_flags;
char empty_flags; char empty_flags;
// store in new format even if old is possible // store in new format even if old is possible
void force_new_format() { cached_new_format = 1;} void force_new_format() { cached_new_format = 1;}
int data_size() int data_size()
{ {
return (new_format() ? return (new_format() ?
...@@ -172,20 +172,20 @@ struct sql_ex_info ...@@ -172,20 +172,20 @@ struct sql_ex_info
#define LOG_EVENT_HEADER_LEN 19 /* the fixed header length */ #define LOG_EVENT_HEADER_LEN 19 /* the fixed header length */
#define OLD_HEADER_LEN 13 /* the fixed header length in 3.23 */ #define OLD_HEADER_LEN 13 /* the fixed header length in 3.23 */
/* /*
Fixed header length, where 4.x and 5.0 agree. That is, 5.0 may have a longer Fixed header length, where 4.x and 5.0 agree. That is, 5.0 may have a longer
header (it will for sure when we have the unique event's ID), but at least header (it will for sure when we have the unique event's ID), but at least
the first 19 bytes are the same in 4.x and 5.0. So when we have the unique the first 19 bytes are the same in 4.x and 5.0. So when we have the unique
event's ID, LOG_EVENT_HEADER_LEN will be something like 26, but event's ID, LOG_EVENT_HEADER_LEN will be something like 26, but
LOG_EVENT_MINIMAL_HEADER_LEN will remain 19. LOG_EVENT_MINIMAL_HEADER_LEN will remain 19.
*/ */
#define LOG_EVENT_MINIMAL_HEADER_LEN 19 #define LOG_EVENT_MINIMAL_HEADER_LEN 19
/* event-specific post-header sizes */ /* event-specific post-header sizes */
// where 3.23, 4.x and 5.0 agree // where 3.23, 4.x and 5.0 agree
#define QUERY_HEADER_MINIMAL_LEN (4 + 4 + 1 + 2) #define QUERY_HEADER_MINIMAL_LEN (4 + 4 + 1 + 2)
// where 5.0 differs: 2 for len of N-bytes vars. // where 5.0 differs: 2 for len of N-bytes vars.
#define QUERY_HEADER_LEN (QUERY_HEADER_MINIMAL_LEN + 2) #define QUERY_HEADER_LEN (QUERY_HEADER_MINIMAL_LEN + 2)
#define LOAD_HEADER_LEN (4 + 4 + 4 + 1 +1 + 4) #define LOAD_HEADER_LEN (4 + 4 + 4 + 1 +1 + 4)
#define START_V3_HEADER_LEN (2 + ST_SERVER_VER_LEN + 4) #define START_V3_HEADER_LEN (2 + ST_SERVER_VER_LEN + 4)
#define ROTATE_HEADER_LEN 8 // this is FROZEN (the Rotate post-header is frozen) #define ROTATE_HEADER_LEN 8 // this is FROZEN (the Rotate post-header is frozen)
...@@ -195,8 +195,8 @@ struct sql_ex_info ...@@ -195,8 +195,8 @@ struct sql_ex_info
#define DELETE_FILE_HEADER_LEN 4 #define DELETE_FILE_HEADER_LEN 4
#define FORMAT_DESCRIPTION_HEADER_LEN (START_V3_HEADER_LEN+1+LOG_EVENT_TYPES) #define FORMAT_DESCRIPTION_HEADER_LEN (START_V3_HEADER_LEN+1+LOG_EVENT_TYPES)
/* /*
Event header offsets; Event header offsets;
these point to places inside the fixed header. these point to places inside the fixed header.
*/ */
...@@ -294,22 +294,22 @@ struct sql_ex_info ...@@ -294,22 +294,22 @@ struct sql_ex_info
So they are now removed and their place may later be reused for other So they are now removed and their place may later be reused for other
flags. Then one must remember that Rotate events in 4.x have flags. Then one must remember that Rotate events in 4.x have
LOG_EVENT_FORCED_ROTATE_F set, so one should not rely on the value of the LOG_EVENT_FORCED_ROTATE_F set, so one should not rely on the value of the
replacing flag when reading a Rotate event. replacing flag when reading a Rotate event.
I keep the defines here just to remember what they were. I keep the defines here just to remember what they were.
*/ */
#ifdef TO_BE_REMOVED #ifdef TO_BE_REMOVED
#define LOG_EVENT_TIME_F 0x1 #define LOG_EVENT_TIME_F 0x1
#define LOG_EVENT_FORCED_ROTATE_F 0x2 #define LOG_EVENT_FORCED_ROTATE_F 0x2
#endif #endif
/* /*
If the query depends on the thread (for example: TEMPORARY TABLE). If the query depends on the thread (for example: TEMPORARY TABLE).
Currently this is used by mysqlbinlog to know it must print Currently this is used by mysqlbinlog to know it must print
SET @@PSEUDO_THREAD_ID=xx; before the query (it would not hurt to print it SET @@PSEUDO_THREAD_ID=xx; before the query (it would not hurt to print it
for every query but this would be slow). for every query but this would be slow).
*/ */
#define LOG_EVENT_THREAD_SPECIFIC_F 0x4 #define LOG_EVENT_THREAD_SPECIFIC_F 0x4
/* /*
OPTIONS_WRITTEN_TO_BIN_LOG are the bits of thd->options which must be written OPTIONS_WRITTEN_TO_BIN_LOG are the bits of thd->options which must be written
to the binlog. OPTIONS_WRITTEN_TO_BINLOG could be written into the to the binlog. OPTIONS_WRITTEN_TO_BINLOG could be written into the
Format_description_log_event, so that if later we don't want to replicate a Format_description_log_event, so that if later we don't want to replicate a
...@@ -317,7 +317,7 @@ struct sql_ex_info ...@@ -317,7 +317,7 @@ struct sql_ex_info
too hard to decide once for all of what we replicate and what we don't, among too hard to decide once for all of what we replicate and what we don't, among
the fixed 32 bits of thd->options. the fixed 32 bits of thd->options.
I (Guilhem) have read through every option's usage, and it looks like I (Guilhem) have read through every option's usage, and it looks like
OPTION_AUTO_IS_NULL and OPTION_NO_FOREIGN_KEYS are the only ones which alter OPTION_AUTO_IS_NULL and OPTION_NO_FOREIGN_KEYS are the only ones which alter
how the query modifies the table. It's good to replicate how the query modifies the table. It's good to replicate
OPTION_RELAXED_UNIQUE_CHECKS too because otherwise, the slave may insert data OPTION_RELAXED_UNIQUE_CHECKS too because otherwise, the slave may insert data
slower than the master, in InnoDB. slower than the master, in InnoDB.
...@@ -325,7 +325,7 @@ struct sql_ex_info ...@@ -325,7 +325,7 @@ struct sql_ex_info
max_join_size=HA_POS_ERROR) and OPTION_BIG_TABLES is not needed either, as max_join_size=HA_POS_ERROR) and OPTION_BIG_TABLES is not needed either, as
the manual says (because a too big in-memory temp table is automatically the manual says (because a too big in-memory temp table is automatically
written to disk). written to disk).
*/ */
#define OPTIONS_WRITTEN_TO_BIN_LOG (OPTION_AUTO_IS_NULL | \ #define OPTIONS_WRITTEN_TO_BIN_LOG (OPTION_AUTO_IS_NULL | \
OPTION_NO_FOREIGN_KEY_CHECKS | OPTION_RELAXED_UNIQUE_CHECKS) OPTION_NO_FOREIGN_KEY_CHECKS | OPTION_RELAXED_UNIQUE_CHECKS)
...@@ -344,13 +344,13 @@ enum Log_event_type ...@@ -344,13 +344,13 @@ enum Log_event_type
allowing multibyte TERMINATED BY etc; both types share the same class allowing multibyte TERMINATED BY etc; both types share the same class
(Load_log_event) (Load_log_event)
*/ */
NEW_LOAD_EVENT, NEW_LOAD_EVENT,
RAND_EVENT, USER_VAR_EVENT, RAND_EVENT, USER_VAR_EVENT,
FORMAT_DESCRIPTION_EVENT, FORMAT_DESCRIPTION_EVENT,
ENUM_END_EVENT /* end marker */ ENUM_END_EVENT /* end marker */
}; };
/* /*
The number of types we handle in Format_description_log_event (UNKNOWN_EVENT The number of types we handle in Format_description_log_event (UNKNOWN_EVENT
is not to be handled, it does not exist in binlogs, it does not have a is not to be handled, it does not exist in binlogs, it does not have a
format). format).
...@@ -388,7 +388,7 @@ typedef struct st_last_event_info ...@@ -388,7 +388,7 @@ typedef struct st_last_event_info
bool sql_mode_inited; bool sql_mode_inited;
ulong sql_mode; /* must be same as THD.variables.sql_mode */ ulong sql_mode; /* must be same as THD.variables.sql_mode */
st_last_event_info() st_last_event_info()
: flags2_inited(0), flags2(0), sql_mode_inited(0), sql_mode(0) : flags2_inited(0), flags2(0), sql_mode_inited(0), sql_mode(0)
{ {
db[0]= 0; /* initially, the db is unknown */ db[0]= 0; /* initially, the db is unknown */
} }
...@@ -406,7 +406,7 @@ typedef struct st_last_event_info ...@@ -406,7 +406,7 @@ typedef struct st_last_event_info
class Log_event class Log_event
{ {
public: public:
/* /*
The offset in the log where this event originally appeared (it is preserved The offset in the log where this event originally appeared (it is preserved
in relay logs, making SHOW SLAVE STATUS able to print coordinates of the in relay logs, making SHOW SLAVE STATUS able to print coordinates of the
event in the master's binlog). Note: when a transaction is written by the event in the master's binlog). Note: when a transaction is written by the
...@@ -416,13 +416,13 @@ class Log_event ...@@ -416,13 +416,13 @@ class Log_event
may occur), except the COMMIT query which has its real offset. may occur), except the COMMIT query which has its real offset.
*/ */
my_off_t log_pos; my_off_t log_pos;
/* /*
A temp buffer for read_log_event; it is later analysed according to the A temp buffer for read_log_event; it is later analysed according to the
event's type, and its content is distributed in the event-specific fields. event's type, and its content is distributed in the event-specific fields.
*/ */
char *temp_buf; char *temp_buf;
/* /*
Timestamp on the master(for debugging and replication of NOW()/TIMESTAMP). Timestamp on the master(for debugging and replication of NOW()/TIMESTAMP).
It is important for queries and LOAD DATA INFILE. This is set at the event's It is important for queries and LOAD DATA INFILE. This is set at the event's
creation time, except for Query and Load (et al.) events where this is set creation time, except for Query and Load (et al.) events where this is set
at the query's execution time, which guarantees good replication (otherwise, at the query's execution time, which guarantees good replication (otherwise,
...@@ -431,9 +431,9 @@ class Log_event ...@@ -431,9 +431,9 @@ class Log_event
time_t when; time_t when;
/* The number of seconds the query took to run on the master. */ /* The number of seconds the query took to run on the master. */
ulong exec_time; ulong exec_time;
/* /*
The master's server id (is preserved in the relay log; used to prevent from The master's server id (is preserved in the relay log; used to prevent from
infinite loops in circular replication). infinite loops in circular replication).
*/ */
uint32 server_id; uint32 server_id;
uint cached_event_len; uint cached_event_len;
...@@ -501,7 +501,7 @@ class Log_event ...@@ -501,7 +501,7 @@ class Log_event
virtual void print(FILE* file, bool short_form = 0, LAST_EVENT_INFO* last_event_info= 0) = 0; virtual void print(FILE* file, bool short_form = 0, LAST_EVENT_INFO* last_event_info= 0) = 0;
void print_timestamp(FILE* file, time_t *ts = 0); void print_timestamp(FILE* file, time_t *ts = 0);
void print_header(FILE* file); void print_header(FILE* file);
#endif #endif
static void *operator new(size_t size) static void *operator new(size_t size)
{ {
...@@ -511,7 +511,7 @@ class Log_event ...@@ -511,7 +511,7 @@ class Log_event
{ {
my_free((gptr) ptr, MYF(MY_WME|MY_ALLOW_ZERO_PTR)); my_free((gptr) ptr, MYF(MY_WME|MY_ALLOW_ZERO_PTR));
} }
int write(IO_CACHE* file); int write(IO_CACHE* file);
int write_header(IO_CACHE* file); int write_header(IO_CACHE* file);
virtual int write_data(IO_CACHE* file) virtual int write_data(IO_CACHE* file)
...@@ -521,7 +521,7 @@ class Log_event ...@@ -521,7 +521,7 @@ class Log_event
virtual int write_data_body(IO_CACHE* file __attribute__((unused))) virtual int write_data_body(IO_CACHE* file __attribute__((unused)))
{ return 0; } { return 0; }
virtual Log_event_type get_type_code() = 0; virtual Log_event_type get_type_code() = 0;
virtual const bool is_valid() = 0; virtual bool is_valid() const = 0;
inline bool get_cache_stmt() { return cache_stmt; } inline bool get_cache_stmt() { return cache_stmt; }
Log_event(const char* buf, const Format_description_log_event* description_event); Log_event(const char* buf, const Format_description_log_event* description_event);
virtual ~Log_event() { free_temp_buf();} virtual ~Log_event() { free_temp_buf();}
...@@ -549,12 +549,12 @@ class Log_event ...@@ -549,12 +549,12 @@ class Log_event
static Log_event* read_log_event(const char* buf, uint event_len, static Log_event* read_log_event(const char* buf, uint event_len,
const char **error, const char **error,
const Format_description_log_event const Format_description_log_event
*description_event); *description_event);
/* returns the human readable name of the event's type */ /* returns the human readable name of the event's type */
const char* get_type_str(); const char* get_type_str();
}; };
/* /*
One class for each type of event. One class for each type of event.
Two constructors for each class: Two constructors for each class:
- one to create the event for logging (when the server acts as a master), - one to create the event for logging (when the server acts as a master),
...@@ -591,21 +591,21 @@ class Query_log_event: public Log_event ...@@ -591,21 +591,21 @@ class Query_log_event: public Log_event
uint32 db_len; uint32 db_len;
uint16 error_code; uint16 error_code;
ulong thread_id; ulong thread_id;
/* /*
For events created by Query_log_event::exec_event (and For events created by Query_log_event::exec_event (and
Load_log_event::exec_event()) we need the *original* thread id, to be able Load_log_event::exec_event()) we need the *original* thread id, to be able
to log the event with the original (=master's) thread id (fix for to log the event with the original (=master's) thread id (fix for
BUG#1686). BUG#1686).
*/ */
ulong slave_proxy_id; ulong slave_proxy_id;
/* /*
Binlog format 3 and 4 start to differ (as far as class members are Binlog format 3 and 4 start to differ (as far as class members are
concerned) from here. concerned) from here.
*/ */
uint catalog_len; /* <= 255 char */ uint catalog_len; /* <= 255 char */
/* /*
We want to be able to store a variable number of N-bit status vars: We want to be able to store a variable number of N-bit status vars:
(generally N=32; but N=64 for SQL_MODE) a user may want to log the number of (generally N=32; but N=64 for SQL_MODE) a user may want to log the number of
...@@ -627,7 +627,7 @@ class Query_log_event: public Log_event ...@@ -627,7 +627,7 @@ class Query_log_event: public Log_event
status variables in Query_log_event. status variables in Query_log_event.
*/ */
uint16 status_vars_len; uint16 status_vars_len;
/* /*
'flags2' is a second set of flags (on top of those in Log_event), for 'flags2' is a second set of flags (on top of those in Log_event), for
session variables. These are thd->options which is & against a mask session variables. These are thd->options which is & against a mask
...@@ -637,13 +637,13 @@ class Query_log_event: public Log_event ...@@ -637,13 +637,13 @@ class Query_log_event: public Log_event
flags2==0 (5.0 master, we know this has a meaning of flags all down which flags2==0 (5.0 master, we know this has a meaning of flags all down which
must influence the query). must influence the query).
*/ */
bool flags2_inited; bool flags2_inited;
bool sql_mode_inited; bool sql_mode_inited;
uint32 flags2; uint32 flags2;
/* In connections sql_mode is 32 bits now but will be 64 bits soon */ /* In connections sql_mode is 32 bits now but will be 64 bits soon */
ulong sql_mode; ulong sql_mode;
#ifndef MYSQL_CLIENT #ifndef MYSQL_CLIENT
Query_log_event(THD* thd_arg, const char* query_arg, ulong query_length, Query_log_event(THD* thd_arg, const char* query_arg, ulong query_length,
...@@ -669,11 +669,11 @@ class Query_log_event: public Log_event ...@@ -669,11 +669,11 @@ class Query_log_event: public Log_event
Log_event_type get_type_code() { return QUERY_EVENT; } Log_event_type get_type_code() { return QUERY_EVENT; }
int write(IO_CACHE* file); int write(IO_CACHE* file);
int write_data(IO_CACHE* file); // returns 0 on success, -1 on error int write_data(IO_CACHE* file); // returns 0 on success, -1 on error
const bool is_valid() { return query != 0; } bool is_valid() const { return query != 0; }
int get_data_size() int get_data_size()
{ {
/* Note that the "1" below is the db's length. */ /* Note that the "1" below is the db's length. */
return (q_len + db_len + 1 + status_vars_len + QUERY_HEADER_LEN); return (q_len + db_len + 1 + status_vars_len + QUERY_HEADER_LEN);
} }
}; };
...@@ -700,18 +700,18 @@ class Slave_log_event: public Log_event ...@@ -700,18 +700,18 @@ class Slave_log_event: public Log_event
int master_log_len; int master_log_len;
uint16 master_port; uint16 master_port;
#ifndef MYSQL_CLIENT #ifndef MYSQL_CLIENT
Slave_log_event(THD* thd_arg, struct st_relay_log_info* rli); Slave_log_event(THD* thd_arg, struct st_relay_log_info* rli);
void pack_info(Protocol* protocol); void pack_info(Protocol* protocol);
int exec_event(struct st_relay_log_info* rli); int exec_event(struct st_relay_log_info* rli);
#else #else
void print(FILE* file, bool short_form = 0, LAST_EVENT_INFO* last_event_info= 0); void print(FILE* file, bool short_form = 0, LAST_EVENT_INFO* last_event_info= 0);
#endif #endif
Slave_log_event(const char* buf, uint event_len); Slave_log_event(const char* buf, uint event_len);
~Slave_log_event(); ~Slave_log_event();
int get_data_size(); int get_data_size();
const bool is_valid() { return master_host != 0; } bool is_valid() const { return master_host != 0; }
Log_event_type get_type_code() { return SLAVE_EVENT; } Log_event_type get_type_code() { return SLAVE_EVENT; }
int write_data(IO_CACHE* file ); int write_data(IO_CACHE* file );
}; };
...@@ -727,7 +727,7 @@ class Slave_log_event: public Log_event ...@@ -727,7 +727,7 @@ class Slave_log_event: public Log_event
class Load_log_event: public Log_event class Load_log_event: public Log_event
{ {
protected: protected:
int copy_log_event(const char *buf, ulong event_len, int copy_log_event(const char *buf, ulong event_len,
int body_offset, const Format_description_log_event* description_event); int body_offset, const Format_description_log_event* description_event);
public: public:
...@@ -769,7 +769,7 @@ class Load_log_event: public Log_event ...@@ -769,7 +769,7 @@ class Load_log_event: public Log_event
#ifndef MYSQL_CLIENT #ifndef MYSQL_CLIENT
String field_lens_buf; String field_lens_buf;
String fields_buf; String fields_buf;
Load_log_event(THD* thd, sql_exchange* ex, const char* db_arg, Load_log_event(THD* thd, sql_exchange* ex, const char* db_arg,
const char* table_name_arg, const char* table_name_arg,
List<Item>& fields_arg, enum enum_duplicates handle_dup, List<Item>& fields_arg, enum enum_duplicates handle_dup,
...@@ -782,7 +782,7 @@ class Load_log_event: public Log_event ...@@ -782,7 +782,7 @@ class Load_log_event: public Log_event
{ {
return exec_event(thd->slave_net,rli,0); return exec_event(thd->slave_net,rli,0);
} }
int exec_event(NET* net, struct st_relay_log_info* rli, int exec_event(NET* net, struct st_relay_log_info* rli,
bool use_rli_only_for_errors); bool use_rli_only_for_errors);
#endif /* HAVE_REPLICATION */ #endif /* HAVE_REPLICATION */
#else #else
...@@ -797,16 +797,16 @@ class Load_log_event: public Log_event ...@@ -797,16 +797,16 @@ class Load_log_event: public Log_event
for the common_header_len (post_header_len will not be changed). for the common_header_len (post_header_len will not be changed).
*/ */
Load_log_event(const char* buf, uint event_len, Load_log_event(const char* buf, uint event_len,
const Format_description_log_event* description_event); const Format_description_log_event* description_event);
~Load_log_event() ~Load_log_event()
{} {}
Log_event_type get_type_code() Log_event_type get_type_code()
{ {
return sql_ex.new_format() ? NEW_LOAD_EVENT: LOAD_EVENT; return sql_ex.new_format() ? NEW_LOAD_EVENT: LOAD_EVENT;
} }
int write_data_header(IO_CACHE* file); int write_data_header(IO_CACHE* file);
int write_data_body(IO_CACHE* file); int write_data_body(IO_CACHE* file);
const bool is_valid() { return table_name != 0; } bool is_valid() const { return table_name != 0; }
int get_data_size() int get_data_size()
{ {
return (table_name_len + db_len + 2 + fname_len return (table_name_len + db_len + 2 + fname_len
...@@ -828,22 +828,22 @@ extern char server_version[SERVER_VERSION_LENGTH]; ...@@ -828,22 +828,22 @@ extern char server_version[SERVER_VERSION_LENGTH];
describes the other events' header/postheader lengths. This event is sent by describes the other events' header/postheader lengths. This event is sent by
MySQL 5.0 whenever it starts sending a new binlog if the requested position MySQL 5.0 whenever it starts sending a new binlog if the requested position
is >4 (otherwise if ==4 the event will be sent naturally). is >4 (otherwise if ==4 the event will be sent naturally).
****************************************************************************/ ****************************************************************************/
class Start_log_event_v3: public Log_event class Start_log_event_v3: public Log_event
{ {
public: public:
/* /*
If this event is at the start of the first binary log since server startup If this event is at the start of the first binary log since server startup
'created' should be the timestamp when the event (and the binary log) was 'created' should be the timestamp when the event (and the binary log) was
created. created.
In the other case (i.e. this event is at the start of a binary log created In the other case (i.e. this event is at the start of a binary log created
by FLUSH LOGS or automatic rotation), 'created' should be 0. by FLUSH LOGS or automatic rotation), 'created' should be 0.
This "trick" is used by MySQL >=4.0.14 slaves to know if they must drop the This "trick" is used by MySQL >=4.0.14 slaves to know if they must drop the
stale temporary tables or not. stale temporary tables or not.
Note that when 'created'!=0, it is always equal to the event's timestamp; Note that when 'created'!=0, it is always equal to the event's timestamp;
indeed Start_log_event is written only in log.cc where the first indeed Start_log_event is written only in log.cc where the first
constructor below is called, in which 'created' is set to 'when'. constructor below is called, in which 'created' is set to 'when'.
So in fact 'created' is a useless variable. When it is 0 So in fact 'created' is a useless variable. When it is 0
we can read the actual value from timestamp ('when') and when it is we can read the actual value from timestamp ('when') and when it is
non-zero we can read the same value from timestamp ('when'). Conclusion: non-zero we can read the same value from timestamp ('when'). Conclusion:
...@@ -866,21 +866,21 @@ class Start_log_event_v3: public Log_event ...@@ -866,21 +866,21 @@ class Start_log_event_v3: public Log_event
#else #else
Start_log_event_v3() {} Start_log_event_v3() {}
void print(FILE* file, bool short_form = 0, LAST_EVENT_INFO* last_event_info= 0); void print(FILE* file, bool short_form = 0, LAST_EVENT_INFO* last_event_info= 0);
#endif #endif
Start_log_event_v3(const char* buf, Start_log_event_v3(const char* buf,
const Format_description_log_event* description_event); const Format_description_log_event* description_event);
~Start_log_event_v3() {} ~Start_log_event_v3() {}
Log_event_type get_type_code() { return START_EVENT_V3;} Log_event_type get_type_code() { return START_EVENT_V3;}
int write_data(IO_CACHE* file); int write_data(IO_CACHE* file);
const bool is_valid() { return 1; } bool is_valid() const { return 1; }
int get_data_size() int get_data_size()
{ {
return START_V3_HEADER_LEN; //no variable-sized part return START_V3_HEADER_LEN; //no variable-sized part
} }
}; };
/* /*
For binlog version 4. For binlog version 4.
This event is saved by threads which read it, as they need it for future This event is saved by threads which read it, as they need it for future
use (to decode the ordinary events). use (to decode the ordinary events).
...@@ -889,7 +889,7 @@ class Start_log_event_v3: public Log_event ...@@ -889,7 +889,7 @@ class Start_log_event_v3: public Log_event
class Format_description_log_event: public Start_log_event_v3 class Format_description_log_event: public Start_log_event_v3
{ {
public: public:
/* /*
The size of the fixed header which _all_ events have The size of the fixed header which _all_ events have
(for binlogs written by this version, this is equal to (for binlogs written by this version, this is equal to
LOG_EVENT_HEADER_LEN), except FORMAT_DESCRIPTION_EVENT and ROTATE_EVENT LOG_EVENT_HEADER_LEN), except FORMAT_DESCRIPTION_EVENT and ROTATE_EVENT
...@@ -906,18 +906,18 @@ class Format_description_log_event: public Start_log_event_v3 ...@@ -906,18 +906,18 @@ class Format_description_log_event: public Start_log_event_v3
#ifdef HAVE_REPLICATION #ifdef HAVE_REPLICATION
int exec_event(struct st_relay_log_info* rli); int exec_event(struct st_relay_log_info* rli);
#endif /* HAVE_REPLICATION */ #endif /* HAVE_REPLICATION */
#endif #endif
Format_description_log_event(const char* buf, uint event_len, Format_description_log_event(const char* buf, uint event_len,
const Format_description_log_event* description_event); const Format_description_log_event* description_event);
~Format_description_log_event() { my_free((gptr)post_header_len, MYF(0)); } ~Format_description_log_event() { my_free((gptr)post_header_len, MYF(0)); }
Log_event_type get_type_code() { return FORMAT_DESCRIPTION_EVENT;} Log_event_type get_type_code() { return FORMAT_DESCRIPTION_EVENT;}
int write_data(IO_CACHE* file); int write_data(IO_CACHE* file);
const bool is_valid() bool is_valid() const
{ {
return ((common_header_len >= ((binlog_version==1) ? OLD_HEADER_LEN : return ((common_header_len >= ((binlog_version==1) ? OLD_HEADER_LEN :
LOG_EVENT_MINIMAL_HEADER_LEN)) && LOG_EVENT_MINIMAL_HEADER_LEN)) &&
(post_header_len != NULL)); (post_header_len != NULL));
} }
int get_event_len() int get_event_len()
{ {
...@@ -950,7 +950,7 @@ class Intvar_log_event: public Log_event ...@@ -950,7 +950,7 @@ class Intvar_log_event: public Log_event
ulonglong val; ulonglong val;
uchar type; uchar type;
#ifndef MYSQL_CLIENT #ifndef MYSQL_CLIENT
Intvar_log_event(THD* thd_arg,uchar type_arg, ulonglong val_arg) Intvar_log_event(THD* thd_arg,uchar type_arg, ulonglong val_arg)
:Log_event(thd_arg,0,0),val(val_arg),type(type_arg) :Log_event(thd_arg,0,0),val(val_arg),type(type_arg)
{} {}
...@@ -960,7 +960,7 @@ class Intvar_log_event: public Log_event ...@@ -960,7 +960,7 @@ class Intvar_log_event: public Log_event
#endif /* HAVE_REPLICATION */ #endif /* HAVE_REPLICATION */
#else #else
void print(FILE* file, bool short_form = 0, LAST_EVENT_INFO* last_event_info= 0); void print(FILE* file, bool short_form = 0, LAST_EVENT_INFO* last_event_info= 0);
#endif #endif
Intvar_log_event(const char* buf, const Format_description_log_event* description_event); Intvar_log_event(const char* buf, const Format_description_log_event* description_event);
~Intvar_log_event() {} ~Intvar_log_event() {}
...@@ -968,14 +968,14 @@ class Intvar_log_event: public Log_event ...@@ -968,14 +968,14 @@ class Intvar_log_event: public Log_event
const char* get_var_type_name(); const char* get_var_type_name();
int get_data_size() { return 9; /* sizeof(type) + sizeof(val) */;} int get_data_size() { return 9; /* sizeof(type) + sizeof(val) */;}
int write_data(IO_CACHE* file); int write_data(IO_CACHE* file);
const bool is_valid() { return 1; } bool is_valid() const { return 1; }
}; };
/***************************************************************************** /*****************************************************************************
Rand Log Event class Rand Log Event class
Logs random seed used by the next RAND(), and by PASSWORD() in 4.1.0. Logs random seed used by the next RAND(), and by PASSWORD() in 4.1.0.
4.1.1 does not need it (it's repeatable again) so this event needn't be 4.1.1 does not need it (it's repeatable again) so this event needn't be
written in 4.1.1 for PASSWORD() (but the fact that it is written is just a written in 4.1.1 for PASSWORD() (but the fact that it is written is just a
waste, it does not cause bugs). waste, it does not cause bugs).
...@@ -1004,7 +1004,7 @@ class Rand_log_event: public Log_event ...@@ -1004,7 +1004,7 @@ class Rand_log_event: public Log_event
Log_event_type get_type_code() { return RAND_EVENT;} Log_event_type get_type_code() { return RAND_EVENT;}
int get_data_size() { return 16; /* sizeof(ulonglong) * 2*/ } int get_data_size() { return 16; /* sizeof(ulonglong) * 2*/ }
int write_data(IO_CACHE* file); int write_data(IO_CACHE* file);
const bool is_valid() { return 1; } bool is_valid() const { return 1; }
}; };
/***************************************************************************** /*****************************************************************************
...@@ -1051,7 +1051,7 @@ class User_var_log_event: public Log_event ...@@ -1051,7 +1051,7 @@ class User_var_log_event: public Log_event
UV_CHARSET_NUMBER_SIZE + UV_VAL_LEN_SIZE + val_len); UV_CHARSET_NUMBER_SIZE + UV_VAL_LEN_SIZE + val_len);
} }
int write_data(IO_CACHE* file); int write_data(IO_CACHE* file);
const bool is_valid() { return 1; } bool is_valid() const { return 1; }
}; };
/***************************************************************************** /*****************************************************************************
...@@ -1070,14 +1070,14 @@ class Stop_log_event: public Log_event ...@@ -1070,14 +1070,14 @@ class Stop_log_event: public Log_event
int exec_event(struct st_relay_log_info* rli); int exec_event(struct st_relay_log_info* rli);
#else #else
void print(FILE* file, bool short_form = 0, LAST_EVENT_INFO* last_event_info= 0); void print(FILE* file, bool short_form = 0, LAST_EVENT_INFO* last_event_info= 0);
#endif #endif
Stop_log_event(const char* buf, const Format_description_log_event* description_event): Stop_log_event(const char* buf, const Format_description_log_event* description_event):
Log_event(buf, description_event) Log_event(buf, description_event)
{} {}
~Stop_log_event() {} ~Stop_log_event() {}
Log_event_type get_type_code() { return STOP_EVENT;} Log_event_type get_type_code() { return STOP_EVENT;}
const bool is_valid() { return 1; } bool is_valid() const { return 1; }
}; };
#endif /* HAVE_REPLICATION */ #endif /* HAVE_REPLICATION */
...@@ -1097,7 +1097,7 @@ class Rotate_log_event: public Log_event ...@@ -1097,7 +1097,7 @@ class Rotate_log_event: public Log_event
ulonglong pos; ulonglong pos;
uint ident_len; uint ident_len;
bool alloced; bool alloced;
#ifndef MYSQL_CLIENT #ifndef MYSQL_CLIENT
Rotate_log_event(THD* thd_arg, const char* new_log_ident_arg, Rotate_log_event(THD* thd_arg, const char* new_log_ident_arg,
uint ident_len_arg = 0, uint ident_len_arg = 0,
ulonglong pos_arg = LOG_EVENT_OFFSET) ulonglong pos_arg = LOG_EVENT_OFFSET)
...@@ -1126,7 +1126,7 @@ class Rotate_log_event: public Log_event ...@@ -1126,7 +1126,7 @@ class Rotate_log_event: public Log_event
return (LOG_EVENT_MINIMAL_HEADER_LEN + get_data_size()); return (LOG_EVENT_MINIMAL_HEADER_LEN + get_data_size());
} }
int get_data_size() { return ident_len + ROTATE_HEADER_LEN;} int get_data_size() { return ident_len + ROTATE_HEADER_LEN;}
const bool is_valid() { return new_log_ident != 0; } bool is_valid() const { return new_log_ident != 0; }
int write_data(IO_CACHE* file); int write_data(IO_CACHE* file);
}; };
...@@ -1145,7 +1145,7 @@ class Create_file_log_event: public Load_log_event ...@@ -1145,7 +1145,7 @@ class Create_file_log_event: public Load_log_event
our Load part - used on the slave when writing event out to our Load part - used on the slave when writing event out to
SQL_LOAD-*.info file SQL_LOAD-*.info file
*/ */
bool fake_base; bool fake_base;
public: public:
char* block; char* block;
const char *event_buf; const char *event_buf;
...@@ -1167,8 +1167,8 @@ class Create_file_log_event: public Load_log_event ...@@ -1167,8 +1167,8 @@ class Create_file_log_event: public Load_log_event
#else #else
void print(FILE* file, bool short_form = 0, LAST_EVENT_INFO* last_event_info= 0); void print(FILE* file, bool short_form = 0, LAST_EVENT_INFO* last_event_info= 0);
void print(FILE* file, bool short_form, LAST_EVENT_INFO* last_event_info, bool enable_local); void print(FILE* file, bool short_form, LAST_EVENT_INFO* last_event_info, bool enable_local);
#endif #endif
Create_file_log_event(const char* buf, uint event_len, Create_file_log_event(const char* buf, uint event_len,
const Format_description_log_event* description_event); const Format_description_log_event* description_event);
~Create_file_log_event() ~Create_file_log_event()
...@@ -1186,7 +1186,7 @@ class Create_file_log_event: public Load_log_event ...@@ -1186,7 +1186,7 @@ class Create_file_log_event: public Load_log_event
Load_log_event::get_data_size() + Load_log_event::get_data_size() +
4 + 1 + block_len); 4 + 1 + block_len);
} }
const bool is_valid() { return inited_from_old || block != 0; } bool is_valid() const { return inited_from_old || block != 0; }
int write_data_header(IO_CACHE* file); int write_data_header(IO_CACHE* file);
int write_data_body(IO_CACHE* file); int write_data_body(IO_CACHE* file);
/* /*
...@@ -1230,13 +1230,13 @@ class Append_block_log_event: public Log_event ...@@ -1230,13 +1230,13 @@ class Append_block_log_event: public Log_event
#else #else
void print(FILE* file, bool short_form = 0, LAST_EVENT_INFO* last_event_info= 0); void print(FILE* file, bool short_form = 0, LAST_EVENT_INFO* last_event_info= 0);
#endif #endif
Append_block_log_event(const char* buf, uint event_len, Append_block_log_event(const char* buf, uint event_len,
const Format_description_log_event* description_event); const Format_description_log_event* description_event);
~Append_block_log_event() {} ~Append_block_log_event() {}
Log_event_type get_type_code() { return APPEND_BLOCK_EVENT;} Log_event_type get_type_code() { return APPEND_BLOCK_EVENT;}
int get_data_size() { return block_len + APPEND_BLOCK_HEADER_LEN ;} int get_data_size() { return block_len + APPEND_BLOCK_HEADER_LEN ;}
const bool is_valid() { return block != 0; } bool is_valid() const { return block != 0; }
int write_data(IO_CACHE* file); int write_data(IO_CACHE* file);
const char* get_db() { return db; } const char* get_db() { return db; }
}; };
...@@ -1251,7 +1251,7 @@ class Delete_file_log_event: public Log_event ...@@ -1251,7 +1251,7 @@ class Delete_file_log_event: public Log_event
public: public:
uint file_id; uint file_id;
const char* db; /* see comment in Append_block_log_event */ const char* db; /* see comment in Append_block_log_event */
#ifndef MYSQL_CLIENT #ifndef MYSQL_CLIENT
Delete_file_log_event(THD* thd, const char* db_arg, bool using_trans); Delete_file_log_event(THD* thd, const char* db_arg, bool using_trans);
#ifdef HAVE_REPLICATION #ifdef HAVE_REPLICATION
...@@ -1261,14 +1261,14 @@ class Delete_file_log_event: public Log_event ...@@ -1261,14 +1261,14 @@ class Delete_file_log_event: public Log_event
#else #else
void print(FILE* file, bool short_form = 0, LAST_EVENT_INFO* last_event_info= 0); void print(FILE* file, bool short_form = 0, LAST_EVENT_INFO* last_event_info= 0);
void print(FILE* file, bool short_form, LAST_EVENT_INFO* last_event_info, bool enable_local); void print(FILE* file, bool short_form, LAST_EVENT_INFO* last_event_info, bool enable_local);
#endif #endif
Delete_file_log_event(const char* buf, uint event_len, Delete_file_log_event(const char* buf, uint event_len,
const Format_description_log_event* description_event); const Format_description_log_event* description_event);
~Delete_file_log_event() {} ~Delete_file_log_event() {}
Log_event_type get_type_code() { return DELETE_FILE_EVENT;} Log_event_type get_type_code() { return DELETE_FILE_EVENT;}
int get_data_size() { return DELETE_FILE_HEADER_LEN ;} int get_data_size() { return DELETE_FILE_HEADER_LEN ;}
const bool is_valid() { return file_id != 0; } bool is_valid() const { return file_id != 0; }
int write_data(IO_CACHE* file); int write_data(IO_CACHE* file);
const char* get_db() { return db; } const char* get_db() { return db; }
}; };
...@@ -1282,7 +1282,7 @@ class Execute_load_log_event: public Log_event ...@@ -1282,7 +1282,7 @@ class Execute_load_log_event: public Log_event
{ {
public: public:
uint file_id; uint file_id;
const char* db; /* see comment in Append_block_log_event */ const char* db; /* see comment in Append_block_log_event */
#ifndef MYSQL_CLIENT #ifndef MYSQL_CLIENT
Execute_load_log_event(THD* thd, const char* db_arg, bool using_trans); Execute_load_log_event(THD* thd, const char* db_arg, bool using_trans);
...@@ -1292,14 +1292,14 @@ class Execute_load_log_event: public Log_event ...@@ -1292,14 +1292,14 @@ class Execute_load_log_event: public Log_event
#endif /* HAVE_REPLICATION */ #endif /* HAVE_REPLICATION */
#else #else
void print(FILE* file, bool short_form = 0, LAST_EVENT_INFO* last_event_info= 0); void print(FILE* file, bool short_form = 0, LAST_EVENT_INFO* last_event_info= 0);
#endif #endif
Execute_load_log_event(const char* buf, uint event_len, Execute_load_log_event(const char* buf, uint event_len,
const Format_description_log_event* description_event); const Format_description_log_event* description_event);
~Execute_load_log_event() {} ~Execute_load_log_event() {}
Log_event_type get_type_code() { return EXEC_LOAD_EVENT;} Log_event_type get_type_code() { return EXEC_LOAD_EVENT;}
int get_data_size() { return EXEC_LOAD_HEADER_LEN ;} int get_data_size() { return EXEC_LOAD_HEADER_LEN ;}
const bool is_valid() { return file_id != 0; } bool is_valid() const { return file_id != 0; }
int write_data(IO_CACHE* file); int write_data(IO_CACHE* file);
const char* get_db() { return db; } const char* get_db() { return db; }
}; };
...@@ -1319,8 +1319,8 @@ class Unknown_log_event: public Log_event ...@@ -1319,8 +1319,8 @@ class Unknown_log_event: public Log_event
~Unknown_log_event() {} ~Unknown_log_event() {}
void print(FILE* file, bool short_form= 0, LAST_EVENT_INFO* last_event_info= 0); void print(FILE* file, bool short_form= 0, LAST_EVENT_INFO* last_event_info= 0);
Log_event_type get_type_code() { return UNKNOWN_EVENT;} Log_event_type get_type_code() { return UNKNOWN_EVENT;}
const bool is_valid() { return 1; } bool is_valid() const { return 1; }
}; };
#endif #endif
#endif /* _log_event_h */ #endif /* _log_event_h */
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -67,7 +67,7 @@ class QUICK_RANGE :public Sql_alloc { ...@@ -67,7 +67,7 @@ class QUICK_RANGE :public Sql_alloc {
/* /*
Quick select interface. Quick select interface.
This class is a parent for all QUICK_*_SELECT and FT_SELECT classes. This class is a parent for all QUICK_*_SELECT and FT_SELECT classes.
*/ */
...@@ -79,7 +79,7 @@ class QUICK_SELECT_I ...@@ -79,7 +79,7 @@ class QUICK_SELECT_I
double read_time; /* time to perform this retrieval */ double read_time; /* time to perform this retrieval */
TABLE *head; TABLE *head;
/* /*
Index this quick select uses, or MAX_KEY for quick selects Index this quick select uses, or MAX_KEY for quick selects
that use several indexes that use several indexes
*/ */
uint index; uint index;
...@@ -99,35 +99,35 @@ class QUICK_SELECT_I ...@@ -99,35 +99,35 @@ class QUICK_SELECT_I
QUICK_SELECT_I(); QUICK_SELECT_I();
virtual ~QUICK_SELECT_I(){}; virtual ~QUICK_SELECT_I(){};
/* /*
Do post-constructor initialization. Do post-constructor initialization.
SYNOPSIS SYNOPSIS
init() init()
init() performs initializations that should have been in constructor if init() performs initializations that should have been in constructor if
it was possible to return errors from constructors. The join optimizer may it was possible to return errors from constructors. The join optimizer may
create and then delete quick selects without retrieving any rows so init() create and then delete quick selects without retrieving any rows so init()
must not contain any IO or CPU intensive code. must not contain any IO or CPU intensive code.
If init() call fails the only valid action is to delete this quick select, If init() call fails the only valid action is to delete this quick select,
reset() and get_next() must not be called. reset() and get_next() must not be called.
RETURN RETURN
0 OK 0 OK
other Error code other Error code
*/ */
virtual int init() = 0; virtual int init() = 0;
/* /*
Initialize quick select for row retrieval. Initialize quick select for row retrieval.
SYNOPSIS SYNOPSIS
reset() reset()
reset() should be called when it is certain that row retrieval will be reset() should be called when it is certain that row retrieval will be
necessary. This call may do heavyweight initialization like buffering first necessary. This call may do heavyweight initialization like buffering first
N records etc. If reset() call fails get_next() must not be called. N records etc. If reset() call fails get_next() must not be called.
RETURN RETURN
0 OK 0 OK
other Error code other Error code
...@@ -140,7 +140,7 @@ class QUICK_SELECT_I ...@@ -140,7 +140,7 @@ class QUICK_SELECT_I
virtual bool reverse_sorted() = 0; virtual bool reverse_sorted() = 0;
virtual bool unique_key_range() { return false; } virtual bool unique_key_range() { return false; }
enum { enum {
QS_TYPE_RANGE = 0, QS_TYPE_RANGE = 0,
QS_TYPE_INDEX_MERGE = 1, QS_TYPE_INDEX_MERGE = 1,
QS_TYPE_RANGE_DESC = 2, QS_TYPE_RANGE_DESC = 2,
...@@ -154,7 +154,7 @@ class QUICK_SELECT_I ...@@ -154,7 +154,7 @@ class QUICK_SELECT_I
/* /*
Initialize this quick select as a merged scan inside a ROR-union or a ROR- Initialize this quick select as a merged scan inside a ROR-union or a ROR-
intersection scan. The caller must not additionally call init() if this intersection scan. The caller must not additionally call init() if this
function is called. function is called.
SYNOPSIS SYNOPSIS
init_ror_merged_scan() init_ror_merged_scan()
...@@ -162,55 +162,55 @@ class QUICK_SELECT_I ...@@ -162,55 +162,55 @@ class QUICK_SELECT_I
it must create and use a separate handler object. it must create and use a separate handler object.
RETURN RETURN
0 Ok 0 Ok
other Error other Error
*/ */
virtual int init_ror_merged_scan(bool reuse_handler) virtual int init_ror_merged_scan(bool reuse_handler)
{ DBUG_ASSERT(0); return 1; } { DBUG_ASSERT(0); return 1; }
/* /*
Save ROWID of last retrieved row in file->ref. This used in ROR-merging. Save ROWID of last retrieved row in file->ref. This used in ROR-merging.
*/ */
virtual void save_last_pos(){}; virtual void save_last_pos(){};
/* /*
Append comma-separated list of keys this quick select uses to key_names; Append comma-separated list of keys this quick select uses to key_names;
append comma-separated list of corresponding used lengths to used_lengths. append comma-separated list of corresponding used lengths to used_lengths.
This is used by select_describe. This is used by select_describe.
*/ */
virtual void add_keys_and_lengths(String *key_names, virtual void add_keys_and_lengths(String *key_names,
String *used_lengths)=0; String *used_lengths)=0;
/* /*
Append text representation of quick select structure (what and how is Append text representation of quick select structure (what and how is
merged) to str. The result is added to "Extra" field in EXPLAIN output. merged) to str. The result is added to "Extra" field in EXPLAIN output.
This function is implemented only by quick selects that merge other quick This function is implemented only by quick selects that merge other quick
selects output and/or can produce output suitable for merging. selects output and/or can produce output suitable for merging.
*/ */
virtual void add_info_string(String *str) {}; virtual void add_info_string(String *str) {};
/* /*
Return 1 if any index used by this quick select Return 1 if any index used by this quick select
a) uses field that is listed in passed field list or a) uses field that is listed in passed field list or
b) is automatically updated (like a timestamp) b) is automatically updated (like a timestamp)
*/ */
virtual bool check_if_keys_used(List<Item> *fields); virtual bool check_if_keys_used(List<Item> *fields);
/* /*
rowid of last row retrieved by this quick select. This is used only when rowid of last row retrieved by this quick select. This is used only when
doing ROR-index_merge selects doing ROR-index_merge selects
*/ */
byte *last_rowid; byte *last_rowid;
/* /*
Table record buffer used by this quick select. Table record buffer used by this quick select.
*/ */
byte *record; byte *record;
#ifndef DBUG_OFF #ifndef DBUG_OFF
/* /*
Print quick select information to DBUG_FILE. Caller is responsible Print quick select information to DBUG_FILE. Caller is responsible
for locking DBUG_FILE before this call and unlocking it afterwards. for locking DBUG_FILE before this call and unlocking it afterwards.
*/ */
virtual void dbug_dump(int indent, bool verbose)= 0; virtual void dbug_dump(int indent, bool verbose)= 0;
#endif #endif
}; };
...@@ -218,7 +218,7 @@ struct st_qsel_param; ...@@ -218,7 +218,7 @@ struct st_qsel_param;
class SEL_ARG; class SEL_ARG;
/* /*
Quick select that does a range scan on a single key. The records are Quick select that does a range scan on a single key. The records are
returned in key order. returned in key order.
*/ */
class QUICK_RANGE_SELECT : public QUICK_SELECT_I class QUICK_RANGE_SELECT : public QUICK_SELECT_I
...@@ -237,7 +237,7 @@ class QUICK_RANGE_SELECT : public QUICK_SELECT_I ...@@ -237,7 +237,7 @@ class QUICK_RANGE_SELECT : public QUICK_SELECT_I
protected: protected:
friend friend
QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table, QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table,
struct st_table_ref *ref); struct st_table_ref *ref);
friend bool get_quick_keys(struct st_qsel_param *param, friend bool get_quick_keys(struct st_qsel_param *param,
QUICK_RANGE_SELECT *quick,KEY_PART *key, QUICK_RANGE_SELECT *quick,KEY_PART *key,
...@@ -255,7 +255,7 @@ class QUICK_RANGE_SELECT : public QUICK_SELECT_I ...@@ -255,7 +255,7 @@ class QUICK_RANGE_SELECT : public QUICK_SELECT_I
QUICK_RANGE **cur_range; /* current element in ranges */ QUICK_RANGE **cur_range; /* current element in ranges */
QUICK_RANGE *range; QUICK_RANGE *range;
KEY_PART *key_parts; KEY_PART *key_parts;
KEY_PART_INFO *key_part_info; KEY_PART_INFO *key_part_info;
int cmp_next(QUICK_RANGE *range); int cmp_next(QUICK_RANGE *range);
int cmp_prev(QUICK_RANGE *range); int cmp_prev(QUICK_RANGE *range);
...@@ -266,11 +266,11 @@ class QUICK_RANGE_SELECT : public QUICK_SELECT_I ...@@ -266,11 +266,11 @@ class QUICK_RANGE_SELECT : public QUICK_SELECT_I
QUICK_RANGE_SELECT(THD *thd, TABLE *table,uint index_arg,bool no_alloc=0, QUICK_RANGE_SELECT(THD *thd, TABLE *table,uint index_arg,bool no_alloc=0,
MEM_ROOT *parent_alloc=NULL); MEM_ROOT *parent_alloc=NULL);
~QUICK_RANGE_SELECT(); ~QUICK_RANGE_SELECT();
int reset(void) int reset(void)
{ {
next=0; next=0;
range= NULL; range= NULL;
cur_range= NULL; cur_range= NULL;
return 0; return 0;
} }
...@@ -308,29 +308,29 @@ class QUICK_RANGE_SELECT_GEOM: public QUICK_RANGE_SELECT ...@@ -308,29 +308,29 @@ class QUICK_RANGE_SELECT_GEOM: public QUICK_RANGE_SELECT
/* /*
QUICK_INDEX_MERGE_SELECT - index_merge access method quick select. QUICK_INDEX_MERGE_SELECT - index_merge access method quick select.
QUICK_INDEX_MERGE_SELECT uses QUICK_INDEX_MERGE_SELECT uses
* QUICK_RANGE_SELECTs to get rows * QUICK_RANGE_SELECTs to get rows
* Unique class to remove duplicate rows * Unique class to remove duplicate rows
INDEX MERGE OPTIMIZER INDEX MERGE OPTIMIZER
Current implementation doesn't detect all cases where index_merge could Current implementation doesn't detect all cases where index_merge could
be used, in particular: be used, in particular:
* index_merge will never be used if range scan is possible (even if * index_merge will never be used if range scan is possible (even if
range scan is more expensive) range scan is more expensive)
* index_merge+'using index' is not supported (this the consequence of * index_merge+'using index' is not supported (this the consequence of
the above restriction) the above restriction)
* If WHERE part contains complex nested AND and OR conditions, some ways * If WHERE part contains complex nested AND and OR conditions, some ways
to retrieve rows using index_merge will not be considered. The choice to retrieve rows using index_merge will not be considered. The choice
of read plan may depend on the order of conjuncts/disjuncts in WHERE of read plan may depend on the order of conjuncts/disjuncts in WHERE
part of the query, see comments near imerge_list_or_list and part of the query, see comments near imerge_list_or_list and
SEL_IMERGE::or_sel_tree_with_checks functions for details. SEL_IMERGE::or_sel_tree_with_checks functions for details.
* There is no "index_merge_ref" method (but index_merge on non-first * There is no "index_merge_ref" method (but index_merge on non-first
table in join is possible with 'range checked for each record'). table in join is possible with 'range checked for each record').
See comments around SEL_IMERGE class and test_quick_select for more See comments around SEL_IMERGE class and test_quick_select for more
details. details.
ROW RETRIEVAL ALGORITHM ROW RETRIEVAL ALGORITHM
...@@ -352,7 +352,7 @@ class QUICK_RANGE_SELECT_GEOM: public QUICK_RANGE_SELECT ...@@ -352,7 +352,7 @@ class QUICK_RANGE_SELECT_GEOM: public QUICK_RANGE_SELECT
} }
deactivate 'index only'; deactivate 'index only';
} }
Phase 2 (implemented as sequence of QUICK_INDEX_MERGE_SELECT::get_next Phase 2 (implemented as sequence of QUICK_INDEX_MERGE_SELECT::get_next
calls): calls):
...@@ -364,7 +364,7 @@ class QUICK_RANGE_SELECT_GEOM: public QUICK_RANGE_SELECT ...@@ -364,7 +364,7 @@ class QUICK_RANGE_SELECT_GEOM: public QUICK_RANGE_SELECT
} }
*/ */
class QUICK_INDEX_MERGE_SELECT : public QUICK_SELECT_I class QUICK_INDEX_MERGE_SELECT : public QUICK_SELECT_I
{ {
public: public:
QUICK_INDEX_MERGE_SELECT(THD *thd, TABLE *table); QUICK_INDEX_MERGE_SELECT(THD *thd, TABLE *table);
...@@ -387,23 +387,23 @@ class QUICK_INDEX_MERGE_SELECT : public QUICK_SELECT_I ...@@ -387,23 +387,23 @@ class QUICK_INDEX_MERGE_SELECT : public QUICK_SELECT_I
/* range quick selects this index_merge read consists of */ /* range quick selects this index_merge read consists of */
List<QUICK_RANGE_SELECT> quick_selects; List<QUICK_RANGE_SELECT> quick_selects;
/* quick select which is currently used for rows retrieval */ /* quick select which is currently used for rows retrieval */
List_iterator_fast<QUICK_RANGE_SELECT> cur_quick_it; List_iterator_fast<QUICK_RANGE_SELECT> cur_quick_it;
QUICK_RANGE_SELECT* cur_quick_select; QUICK_RANGE_SELECT* cur_quick_select;
/* quick select that uses clustered primary key (NULL if none) */ /* quick select that uses clustered primary key (NULL if none) */
QUICK_RANGE_SELECT* pk_quick_select; QUICK_RANGE_SELECT* pk_quick_select;
/* true if this select is currently doing a clustered PK scan */ /* true if this select is currently doing a clustered PK scan */
bool doing_pk_scan; bool doing_pk_scan;
Unique *unique; Unique *unique;
MEM_ROOT alloc; MEM_ROOT alloc;
THD *thd; THD *thd;
int prepare_unique(); int prepare_unique();
/* used to get rows collected in Unique */ /* used to get rows collected in Unique */
READ_RECORD read_record; READ_RECORD read_record;
}; };
...@@ -411,26 +411,26 @@ class QUICK_INDEX_MERGE_SELECT : public QUICK_SELECT_I ...@@ -411,26 +411,26 @@ class QUICK_INDEX_MERGE_SELECT : public QUICK_SELECT_I
/* /*
Rowid-Ordered Retrieval (ROR) index intersection quick select. Rowid-Ordered Retrieval (ROR) index intersection quick select.
This quick select produces intersection of row sequences returned This quick select produces intersection of row sequences returned
by several QUICK_RANGE_SELECTs it "merges". by several QUICK_RANGE_SELECTs it "merges".
All merged QUICK_RANGE_SELECTs must return rowids in rowid order. All merged QUICK_RANGE_SELECTs must return rowids in rowid order.
QUICK_ROR_INTERSECT_SELECT will return rows in rowid order, too. QUICK_ROR_INTERSECT_SELECT will return rows in rowid order, too.
All merged quick selects retrieve {rowid, covered_fields} tuples (not full All merged quick selects retrieve {rowid, covered_fields} tuples (not full
table records). table records).
QUICK_ROR_INTERSECT_SELECT retrieves full records if it is not being used QUICK_ROR_INTERSECT_SELECT retrieves full records if it is not being used
by QUICK_ROR_INTERSECT_SELECT and all merged quick selects together don't by QUICK_ROR_INTERSECT_SELECT and all merged quick selects together don't
cover needed all fields. cover needed all fields.
If one of the merged quick selects is a Clustered PK range scan, it is If one of the merged quick selects is a Clustered PK range scan, it is
used only to filter rowid sequence produced by other merged quick selects. used only to filter rowid sequence produced by other merged quick selects.
*/ */
class QUICK_ROR_INTERSECT_SELECT : public QUICK_SELECT_I class QUICK_ROR_INTERSECT_SELECT : public QUICK_SELECT_I
{ {
public: public:
QUICK_ROR_INTERSECT_SELECT(THD *thd, TABLE *table, QUICK_ROR_INTERSECT_SELECT(THD *thd, TABLE *table,
bool retrieve_full_rows, bool retrieve_full_rows,
MEM_ROOT *parent_alloc); MEM_ROOT *parent_alloc);
~QUICK_ROR_INTERSECT_SELECT(); ~QUICK_ROR_INTERSECT_SELECT();
...@@ -450,14 +450,14 @@ class QUICK_ROR_INTERSECT_SELECT : public QUICK_SELECT_I ...@@ -450,14 +450,14 @@ class QUICK_ROR_INTERSECT_SELECT : public QUICK_SELECT_I
int init_ror_merged_scan(bool reuse_handler); int init_ror_merged_scan(bool reuse_handler);
bool push_quick_back(QUICK_RANGE_SELECT *quick_sel_range); bool push_quick_back(QUICK_RANGE_SELECT *quick_sel_range);
/* /*
Range quick selects this intersection consists of, not including Range quick selects this intersection consists of, not including
cpk_quick. cpk_quick.
*/ */
List<QUICK_RANGE_SELECT> quick_selects; List<QUICK_RANGE_SELECT> quick_selects;
/* /*
Merged quick select that uses Clustered PK, if there is one. This quick Merged quick select that uses Clustered PK, if there is one. This quick
select is not used for row retrieval, it is used for row retrieval. select is not used for row retrieval, it is used for row retrieval.
*/ */
QUICK_RANGE_SELECT *cpk_quick; QUICK_RANGE_SELECT *cpk_quick;
...@@ -473,15 +473,15 @@ class QUICK_ROR_INTERSECT_SELECT : public QUICK_SELECT_I ...@@ -473,15 +473,15 @@ class QUICK_ROR_INTERSECT_SELECT : public QUICK_SELECT_I
This quick select produces union of row sequences returned by several This quick select produces union of row sequences returned by several
quick select it "merges". quick select it "merges".
All merged quick selects must return rowids in rowid order. All merged quick selects must return rowids in rowid order.
QUICK_ROR_UNION_SELECT will return rows in rowid order, too. QUICK_ROR_UNION_SELECT will return rows in rowid order, too.
All merged quick selects are set not to retrieve full table records. All merged quick selects are set not to retrieve full table records.
ROR-union quick select always retrieves full records. ROR-union quick select always retrieves full records.
*/ */
class QUICK_ROR_UNION_SELECT : public QUICK_SELECT_I class QUICK_ROR_UNION_SELECT : public QUICK_SELECT_I
{ {
public: public:
QUICK_ROR_UNION_SELECT(THD *thd, TABLE *table); QUICK_ROR_UNION_SELECT(THD *thd, TABLE *table);
...@@ -503,7 +503,7 @@ class QUICK_ROR_UNION_SELECT : public QUICK_SELECT_I ...@@ -503,7 +503,7 @@ class QUICK_ROR_UNION_SELECT : public QUICK_SELECT_I
bool push_quick_back(QUICK_SELECT_I *quick_sel_range); bool push_quick_back(QUICK_SELECT_I *quick_sel_range);
List<QUICK_SELECT_I> quick_selects; /* Merged quick selects */ List<QUICK_SELECT_I> quick_selects; /* Merged quick selects */
QUEUE queue; /* Priority queue for merge operation */ QUEUE queue; /* Priority queue for merge operation */
MEM_ROOT alloc; /* Memory pool for this and merged quick selects data. */ MEM_ROOT alloc; /* Memory pool for this and merged quick selects data. */
...@@ -511,7 +511,7 @@ class QUICK_ROR_UNION_SELECT : public QUICK_SELECT_I ...@@ -511,7 +511,7 @@ class QUICK_ROR_UNION_SELECT : public QUICK_SELECT_I
byte *cur_rowid; /* buffer used in get_next() */ byte *cur_rowid; /* buffer used in get_next() */
byte *prev_rowid; /* rowid of last row returned by get_next() */ byte *prev_rowid; /* rowid of last row returned by get_next() */
bool have_prev_rowid; /* true if prev_rowid has valid data */ bool have_prev_rowid; /* true if prev_rowid has valid data */
uint rowid_length; /* table rowid length */ uint rowid_length; /* table rowid length */
private: private:
static int queue_cmp(void *arg, byte *val1, byte *val2); static int queue_cmp(void *arg, byte *val1, byte *val2);
}; };
...@@ -569,4 +569,6 @@ class FT_SELECT: public QUICK_RANGE_SELECT { ...@@ -569,4 +569,6 @@ class FT_SELECT: public QUICK_RANGE_SELECT {
int get_type() { return QS_TYPE_FULLTEXT; } int get_type() { return QS_TYPE_FULLTEXT; }
}; };
QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table,
struct st_table_ref *ref);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment