summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2019-06-05 20:57:09 +0200
committerOleksandr Byelkin <sanja@mariadb.com>2019-06-07 11:44:56 +0200
commit490dcfd5d74ce45cbdd6105e4295116f6a944e2b (patch)
treefce311808a422180e528f05638fe80bd3ffd7027
parentf7579518e2c32936442a1e20e391f60660c94b3c (diff)
downloadmariadb-git-490dcfd5d74ce45cbdd6105e4295116f6a944e2b.tar.gz
MDEV-19698: Cleanup READ_RECORD::record
https://github.com/MariaDB/server/pull/777#issuecomment-496469366
-rw-r--r--sql/item_subselect.cc2
-rw-r--r--sql/records.cc18
-rw-r--r--sql/records.h5
-rw-r--r--sql/sql_select.cc8
-rw-r--r--sql/sql_window.cc2
5 files changed, 15 insertions, 20 deletions
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 538b2c218de..4603a85aa87 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -3877,7 +3877,6 @@ int subselect_single_select_engine::exec()
tab->save_read_record= tab->read_record.read_record_func;
tab->read_record.read_record_func= 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;
tab->read_record.unlock_row= rr_unlock_row;
@@ -3895,7 +3894,6 @@ int subselect_single_select_engine::exec()
for (JOIN_TAB **ptab= changed_tabs; ptab != last_changed_tab; ptab++)
{
JOIN_TAB *tab= *ptab;
- tab->read_record.record= 0;
tab->read_record.ref_length= 0;
tab->read_first_record= tab->save_read_first_record;
tab->read_record.read_record_func= tab->save_read_record;
diff --git a/sql/records.cc b/sql/records.cc
index c2db29c4912..5dd4318b105 100644
--- a/sql/records.cc
+++ b/sql/records.cc
@@ -77,7 +77,6 @@ bool init_read_record_idx(READ_RECORD *info, THD *thd, TABLE *table,
bzero((char*) info,sizeof(*info));
info->thd= thd;
info->table= table;
- info->record= table->record[0];
info->print_error= print_error;
info->unlock_row= rr_unlock_row;
@@ -210,7 +209,6 @@ bool init_read_record(READ_RECORD *info,THD *thd, TABLE *table,
else
{
empty_record(table);
- info->record= table->record[0];
info->ref_length= (uint)table->file->ref_length;
}
info->select=select;
@@ -393,7 +391,7 @@ static int rr_index_first(READ_RECORD *info)
return tmp;
}
- tmp= info->table->file->ha_index_first(info->record);
+ tmp= info->table->file->ha_index_first(info->record());
info->read_record_func= rr_index;
if (tmp)
tmp= rr_handle_error(info, tmp);
@@ -416,7 +414,7 @@ static int rr_index_first(READ_RECORD *info)
static int rr_index_last(READ_RECORD *info)
{
- int tmp= info->table->file->ha_index_last(info->record);
+ int tmp= info->table->file->ha_index_last(info->record());
info->read_record_func= rr_index_desc;
if (tmp)
tmp= rr_handle_error(info, tmp);
@@ -442,7 +440,7 @@ static int rr_index_last(READ_RECORD *info)
static int rr_index(READ_RECORD *info)
{
- int tmp= info->table->file->ha_index_next(info->record);
+ int tmp= info->table->file->ha_index_next(info->record());
if (tmp)
tmp= rr_handle_error(info, tmp);
return tmp;
@@ -467,7 +465,7 @@ static int rr_index(READ_RECORD *info)
static int rr_index_desc(READ_RECORD *info)
{
- int tmp= info->table->file->ha_index_prev(info->record);
+ int tmp= info->table->file->ha_index_prev(info->record());
if (tmp)
tmp= rr_handle_error(info, tmp);
return tmp;
@@ -477,7 +475,7 @@ static int rr_index_desc(READ_RECORD *info)
int rr_sequential(READ_RECORD *info)
{
int tmp;
- while ((tmp= info->table->file->ha_rnd_next(info->record)))
+ while ((tmp= info->table->file->ha_rnd_next(info->record())))
{
tmp= rr_handle_error(info, tmp);
break;
@@ -493,7 +491,7 @@ static int rr_from_tempfile(READ_RECORD *info)
{
if (my_b_read(info->io_cache,info->ref_pos,info->ref_length))
return -1; /* End of file */
- if (!(tmp= info->table->file->ha_rnd_pos(info->record,info->ref_pos)))
+ if (!(tmp= info->table->file->ha_rnd_pos(info->record(), info->ref_pos)))
break;
/* The following is extremely unlikely to happen */
if (tmp == HA_ERR_KEY_NOT_FOUND)
@@ -543,7 +541,7 @@ int rr_from_pointers(READ_RECORD *info)
cache_pos= info->cache_pos;
info->cache_pos+= info->ref_length;
- if (!(tmp= info->table->file->ha_rnd_pos(info->record,cache_pos)))
+ if (!(tmp= info->table->file->ha_rnd_pos(info->record(), cache_pos)))
break;
/* The following is extremely unlikely to happen */
@@ -638,7 +636,7 @@ static int rr_from_cache(READ_RECORD *info)
else
{
error=0;
- memcpy(info->record,info->cache_pos,
+ memcpy(info->record(), info->cache_pos,
(size_t) info->table->s->reclength);
}
info->cache_pos+=info->reclength;
diff --git a/sql/records.h b/sql/records.h
index e97f6b273cc..faf0d13c9a9 100644
--- a/sql/records.h
+++ b/sql/records.h
@@ -19,9 +19,10 @@
#pragma interface /* gcc class implementation */
#endif
+#include "table.h"
+
struct st_join_table;
class handler;
-struct TABLE;
class THD;
class SQL_SELECT;
class Copy_field;
@@ -58,7 +59,6 @@ struct READ_RECORD
SQL_SELECT *select;
uint ref_length, reclength, rec_cache_size, error_offset;
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_sort_addon_field *addon_field; /* Pointer to the fields info */
@@ -67,6 +67,7 @@ struct READ_RECORD
void (*unpack)(struct st_sort_addon_field *, uchar *, uchar *);
int read_record() { return read_record_func(this); }
+ uchar *record() const { return table->record[0]; }
/*
SJ-Materialization runtime may need to read fields from the materialized
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 13a5cd88c93..8919da0a460 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -20439,7 +20439,6 @@ join_read_first(JOIN_TAB *tab)
tab->table->status=0;
tab->read_record.read_record_func= join_read_next;
tab->read_record.table=table;
- tab->read_record.record=table->record[0];
if (!table->file->inited)
error= table->file->ha_index_init(tab->index, tab->sorted);
if (likely(!error))
@@ -20459,7 +20458,7 @@ static int
join_read_next(READ_RECORD *info)
{
int error;
- if (unlikely((error= info->table->file->ha_index_next(info->record))))
+ if (unlikely((error= info->table->file->ha_index_next(info->record()))))
return report_error(info->table, error);
return 0;
@@ -20479,7 +20478,6 @@ join_read_last(JOIN_TAB *tab)
tab->table->status=0;
tab->read_record.read_record_func= join_read_prev;
tab->read_record.table=table;
- tab->read_record.record=table->record[0];
if (!table->file->inited)
error= table->file->ha_index_init(tab->index, 1);
if (likely(!error))
@@ -20496,7 +20494,7 @@ static int
join_read_prev(READ_RECORD *info)
{
int error;
- if (unlikely((error= info->table->file->ha_index_prev(info->record))))
+ if (unlikely((error= info->table->file->ha_index_prev(info->record()))))
return report_error(info->table, error);
return 0;
}
@@ -20526,7 +20524,7 @@ static int
join_ft_read_next(READ_RECORD *info)
{
int error;
- if (unlikely((error= info->table->file->ha_ft_read(info->table->record[0]))))
+ if (unlikely((error= info->table->file->ha_ft_read(info->record()))))
return report_error(info->table, error);
return 0;
}
diff --git a/sql/sql_window.cc b/sql/sql_window.cc
index 487242933d4..a6c9dd3fea7 100644
--- a/sql/sql_window.cc
+++ b/sql/sql_window.cc
@@ -898,7 +898,7 @@ public:
{
Rowid_seq_cursor::init(info);
table= info->table;
- record= info->record;
+ record= info->record();
}
virtual int fetch()