Backport of:
---------------------------------------------------------- revno: 2630.22.11 committer: Konstantin Osipov <konstantin@mysql.com> branch nick: mysql-6.0-records timestamp: Mon 2008-08-11 16:40:09 +0400 message: Move read_record related functions to a new header - records.h sql/Makefile.am: Introduce records.h sql/handler.h: Forward-declare class handler (an unnecessary forward declaration was removed from mysql_priv.h). sql/item_subselect.cc: Make read_record function naming more consistent. Assign read_record function at once, no need to defer till read_first_record invocation. sql/mysql_priv.h: Include records.h, previously part of structs.h sql/records.cc: Use records.h sql/sql_select.h: Update to use new declarations. sql/structs.h: Move declarations of READ_RECORD and related functions to records.h
This commit is contained in:
parent
abb5e74df6
commit
f0ccd917cc
@ -110,7 +110,7 @@ noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \
|
||||
sql_plugin.h authors.h event_parse_data.h \
|
||||
event_data_objects.h event_scheduler.h \
|
||||
sql_partition.h partition_info.h partition_element.h \
|
||||
contributors.h sql_servers.h sql_signal.h
|
||||
contributors.h sql_servers.h sql_signal.h records.h
|
||||
|
||||
mysqld_SOURCES = sql_lex.cc sql_handler.cc sql_partition.cc \
|
||||
item.cc item_sum.cc item_buff.cc item_func.cc \
|
||||
|
@ -581,6 +581,7 @@ struct handler_iterator {
|
||||
void *buffer;
|
||||
};
|
||||
|
||||
class handler;
|
||||
/*
|
||||
handlerton is a singleton structure - one instance per storage engine -
|
||||
to provide access to storage engine functionality that works on the
|
||||
|
@ -1863,7 +1863,8 @@ void subselect_uniquesubquery_engine::fix_length_and_dec(Item_cache **row)
|
||||
DBUG_ASSERT(0);
|
||||
}
|
||||
|
||||
int init_read_record_seq(JOIN_TAB *tab);
|
||||
int read_first_record_seq(JOIN_TAB *tab);
|
||||
int rr_sequential(READ_RECORD *info);
|
||||
int join_read_always_key_or_null(JOIN_TAB *tab);
|
||||
int join_read_next_same_or_null(READ_RECORD *info);
|
||||
|
||||
@ -1945,7 +1946,8 @@ int subselect_single_select_engine::exec()
|
||||
/* Change the access method to full table scan */
|
||||
tab->save_read_first_record= tab->read_first_record;
|
||||
tab->save_read_record= tab->read_record.read_record;
|
||||
tab->read_first_record= init_read_record_seq;
|
||||
tab->read_record.read_record= rr_sequential;
|
||||
tab->read_first_record= read_first_record_seq;
|
||||
tab->read_record.record= tab->table->record[0];
|
||||
tab->read_record.thd= join->thd;
|
||||
tab->read_record.ref_length= tab->table->file->ref_length;
|
||||
|
@ -878,6 +878,7 @@ bool general_log_write(THD *thd, enum enum_server_command command,
|
||||
#include "tztime.h"
|
||||
#ifdef MYSQL_SERVER
|
||||
#include "sql_servers.h"
|
||||
#include "records.h"
|
||||
#include "opt_range.h"
|
||||
|
||||
#ifdef HAVE_QUERY_CACHE
|
||||
@ -2235,12 +2236,6 @@ longlong get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
|
||||
|
||||
int test_if_number(char *str,int *res,bool allow_wildcards);
|
||||
void change_byte(uchar *,uint,char,char);
|
||||
void init_read_record(READ_RECORD *info, THD *thd, TABLE *reg_form,
|
||||
SQL_SELECT *select, int use_record_cache,
|
||||
bool print_errors, bool disable_rr_cache);
|
||||
void init_read_record_idx(READ_RECORD *info, THD *thd, TABLE *table,
|
||||
bool print_error, uint idx);
|
||||
void end_read_record(READ_RECORD *info);
|
||||
ha_rows filesort(THD *thd, TABLE *form,struct st_sort_field *sortorder,
|
||||
uint s_length, SQL_SELECT *select,
|
||||
ha_rows max_rows, bool sort_positions,
|
||||
|
@ -13,6 +13,9 @@
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#ifdef USE_PRAGMA_INTERFACE
|
||||
#pragma implementation /* gcc class implementation */
|
||||
#endif
|
||||
|
||||
/**
|
||||
@file
|
||||
@ -21,8 +24,10 @@
|
||||
Functions for easy reading of records, possible through a cache
|
||||
*/
|
||||
|
||||
#include "records.h"
|
||||
#include "mysql_priv.h"
|
||||
|
||||
|
||||
static int rr_quick(READ_RECORD *info);
|
||||
int rr_sequential(READ_RECORD *info);
|
||||
static int rr_from_tempfile(READ_RECORD *info);
|
||||
|
75
sql/records.h
Normal file
75
sql/records.h
Normal file
@ -0,0 +1,75 @@
|
||||
#ifndef SQL_RECORDS_H
|
||||
#define SQL_RECORDS_H
|
||||
/* Copyright (C) 2008 Sun/MySQL
|
||||
|
||||
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
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#ifdef USE_PRAGMA_INTERFACE
|
||||
#pragma interface /* gcc class implementation */
|
||||
#endif
|
||||
#include <my_global.h> /* for uint typedefs */
|
||||
|
||||
struct st_join_table;
|
||||
class handler;
|
||||
struct TABLE;
|
||||
class THD;
|
||||
class SQL_SELECT;
|
||||
|
||||
/**
|
||||
A context for reading through a single table using a chosen access method:
|
||||
index read, scan, etc, use of cache, etc.
|
||||
|
||||
Use by:
|
||||
READ_RECORD read_record;
|
||||
init_read_record(&read_record, ...);
|
||||
while (read_record.read_record())
|
||||
{
|
||||
...
|
||||
}
|
||||
end_read_record();
|
||||
*/
|
||||
|
||||
struct READ_RECORD
|
||||
{
|
||||
typedef int (*Read_func)(READ_RECORD*);
|
||||
typedef int (*Setup_func)(struct st_join_table*);
|
||||
|
||||
TABLE *table; /* Head-form */
|
||||
handler *file;
|
||||
TABLE **forms; /* head and ref forms */
|
||||
Read_func read_record;
|
||||
THD *thd;
|
||||
SQL_SELECT *select;
|
||||
uint cache_records;
|
||||
uint ref_length,struct_length,reclength,rec_cache_size,error_offset;
|
||||
uint index;
|
||||
uchar *ref_pos; /* pointer to form->refpos */
|
||||
uchar *record;
|
||||
uchar *rec_buf; /* to read field values after filesort */
|
||||
uchar *cache,*cache_pos,*cache_end,*read_positions;
|
||||
struct st_io_cache *io_cache;
|
||||
bool print_error, ignore_not_found_rows;
|
||||
|
||||
public:
|
||||
READ_RECORD() {}
|
||||
};
|
||||
|
||||
void init_read_record(READ_RECORD *info, THD *thd, TABLE *reg_form,
|
||||
SQL_SELECT *select, int use_record_cache,
|
||||
bool print_errors, bool disable_rr_cache);
|
||||
void init_read_record_idx(READ_RECORD *info, THD *thd, TABLE *table,
|
||||
bool print_error, uint idx);
|
||||
void end_read_record(READ_RECORD *info);
|
||||
|
||||
#endif /* SQL_RECORDS_H */
|
@ -11881,10 +11881,8 @@ join_init_quick_read_record(JOIN_TAB *tab)
|
||||
}
|
||||
|
||||
|
||||
int rr_sequential(READ_RECORD *info);
|
||||
int init_read_record_seq(JOIN_TAB *tab)
|
||||
int read_first_record_seq(JOIN_TAB *tab)
|
||||
{
|
||||
tab->read_record.read_record= rr_sequential;
|
||||
if (tab->read_record.file->ha_rnd_init(1))
|
||||
return 1;
|
||||
return (*tab->read_record.read_record)(&tab->read_record);
|
||||
|
@ -134,7 +134,6 @@ enum enum_nested_loop_state
|
||||
|
||||
typedef enum_nested_loop_state
|
||||
(*Next_select_func)(JOIN *, struct st_join_table *, bool);
|
||||
typedef int (*Read_record_func)(struct st_join_table *tab);
|
||||
Next_select_func setup_end_select_func(JOIN *join);
|
||||
|
||||
|
||||
@ -162,7 +161,7 @@ typedef struct st_join_table {
|
||||
*/
|
||||
uint packed_info;
|
||||
|
||||
Read_record_func read_first_record;
|
||||
READ_RECORD::Setup_func read_first_record;
|
||||
Next_select_func next_select;
|
||||
READ_RECORD read_record;
|
||||
/*
|
||||
@ -170,8 +169,8 @@ typedef struct st_join_table {
|
||||
if it is executed by an alternative full table scan when the left operand of
|
||||
the subquery predicate is evaluated to NULL.
|
||||
*/
|
||||
Read_record_func save_read_first_record;/* to save read_first_record */
|
||||
int (*save_read_record) (READ_RECORD *);/* to save read_record.read_record */
|
||||
READ_RECORD::Setup_func save_read_first_record;/* to save read_first_record */
|
||||
READ_RECORD::Read_func save_read_record;/* to save read_record.read_record */
|
||||
double worst_seeks;
|
||||
key_map const_keys; /**< Keys with constant part */
|
||||
key_map checked_keys; /**< Keys checked in find_best */
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
struct TABLE;
|
||||
class Field;
|
||||
class THD;
|
||||
|
||||
typedef struct st_date_time_format {
|
||||
uchar positions[8];
|
||||
@ -115,30 +116,6 @@ typedef struct st_reginfo { /* Extra info about reg */
|
||||
} REGINFO;
|
||||
|
||||
|
||||
struct st_read_record; /* For referense later */
|
||||
class SQL_SELECT;
|
||||
class THD;
|
||||
class handler;
|
||||
|
||||
typedef struct st_read_record { /* Parameter to read_record */
|
||||
TABLE *table; /* Head-form */
|
||||
handler *file;
|
||||
TABLE **forms; /* head and ref forms */
|
||||
int (*read_record)(struct st_read_record *);
|
||||
THD *thd;
|
||||
SQL_SELECT *select;
|
||||
uint cache_records;
|
||||
uint ref_length,struct_length,reclength,rec_cache_size,error_offset;
|
||||
uint index;
|
||||
uchar *ref_pos; /* pointer to form->refpos */
|
||||
uchar *record;
|
||||
uchar *rec_buf; /* to read field values after filesort */
|
||||
uchar *cache,*cache_pos,*cache_end,*read_positions;
|
||||
IO_CACHE *io_cache;
|
||||
bool print_error, ignore_not_found_rows;
|
||||
} READ_RECORD;
|
||||
|
||||
|
||||
/*
|
||||
Originally MySQL used MYSQL_TIME structure inside server only, but since
|
||||
4.1 it's exported to user in the new client API. Define aliases for
|
||||
|
Loading…
x
Reference in New Issue
Block a user