#At file:///data0/martin/bzrroot/lisjoin/n-mr-o-t-read_state/ based on revid:jorgen.loland@stripped
3279 Martin Hansson 2011-01-27
Mystery with missing vtable.
added:
sql/read_state.cc
sql/read_state.h
modified:
sql/CMakeLists.txt
sql/opt_range.cc
sql/opt_range.h
=== modified file 'sql/CMakeLists.txt'
--- a/sql/CMakeLists.txt 2011-01-03 13:12:01 +0000
+++ b/sql/CMakeLists.txt 2011-01-27 13:40:19 +0000
@@ -50,6 +50,7 @@ SET (SQL_SOURCE
message.h mf_iocache.cc my_decimal.cc ../sql-common/my_time.c
mysqld.cc net_serv.cc keycaches.cc
../sql-common/client_plugin.c
+ read_state.cc read_state.h
opt_range.cc opt_range.h opt_sum.cc
../sql-common/pack.c parse_file.cc password.c procedure.cc
protocol.cc records.cc set_var.cc
=== modified file 'sql/opt_range.cc'
--- a/sql/opt_range.cc 2010-12-29 00:38:59 +0000
+++ b/sql/opt_range.cc 2011-01-27 13:40:19 +0000
@@ -10665,7 +10665,12 @@ QUICK_GROUP_MIN_MAX_SELECT(TABLE *table,
seen_first_key(FALSE), min_max_arg_part(min_max_arg_part_arg),
key_infix(key_infix_arg), key_infix_len(key_infix_len_arg),
min_functions_it(NULL), max_functions_it(NULL),
- is_index_scan(is_index_scan_arg)
+ is_index_scan(is_index_scan_arg),
+ min_read_state(*this),
+ max_read_state(*this),
+ prefix_read_state(*this),
+ read_state(NULL)
+
{
head= table;
index= use_index;
=== modified file 'sql/opt_range.h'
--- a/sql/opt_range.h 2010-12-17 12:58:04 +0000
+++ b/sql/opt_range.h 2011-01-27 13:40:19 +0000
@@ -23,6 +23,7 @@
#pragma interface /* gcc class implementation */
#endif
+#include "read_state.h"
#include "thr_malloc.h" /* sql_memdup */
#include "records.h" /* READ_RECORD */
#include "queues.h" /* QUEUE */
@@ -845,6 +846,13 @@ private:
int next_max();
void update_min_result();
void update_max_result();
+
+ Min_read_state min_read_state;
+ Max_read_state max_read_state;
+ Prefix_read_state prefix_read_state;
+
+ Read_state *read_state;
+
public:
QUICK_GROUP_MIN_MAX_SELECT(TABLE *table, JOIN *join, bool have_min,
bool have_max, bool have_agg_distinct,
@@ -876,6 +884,10 @@ public:
if (is_index_scan)
str->append(STRING_WITH_LEN(" (scanning)"));
}
+ friend class Read_state;
+ friend class Min_read_state;
+ friend class Max_read_state;
+ friend class Prefix_read_state;
};
=== added file 'sql/read_state.cc'
--- a/sql/read_state.cc 1970-01-01 00:00:00 +0000
+++ b/sql/read_state.cc 2011-01-27 13:40:19 +0000
@@ -0,0 +1,25 @@
+#include "read_state.h"
+#include "opt_range.h"
+
+Min_read_state::Min_read_state(QUICK_GROUP_MIN_MAX_SELECT &owner) :
+ Read_state(owner) {}
+
+Max_read_state::Max_read_state(QUICK_GROUP_MIN_MAX_SELECT &owner) :
+ Read_state(owner) {}
+
+Prefix_read_state::Prefix_read_state(QUICK_GROUP_MIN_MAX_SELECT &owner) :
+ Read_state(owner) {}
+
+int Min_read_state::read() { return m_owner.next_min(); }
+int Max_read_state::read() { return m_owner.next_max(); }
+
+/**
+ If this is just a GROUP BY or DISTINCT without MIN or MAX and there
+ are equality predicates for the key parts after the group, find the
+ first sub-group with the extended prefix.
+*/
+int Prefix_read_state::read() {
+ return m_owner.file->ha_index_read_map(m_owner.record, m_owner.group_prefix,
+ make_prev_keypart_map(m_owner.real_key_parts),
+ HA_READ_KEY_EXACT);
+}
=== added file 'sql/read_state.h'
--- a/sql/read_state.h 1970-01-01 00:00:00 +0000
+++ b/sql/read_state.h 2011-01-27 13:40:19 +0000
@@ -0,0 +1,33 @@
+#ifndef READ_STATE_H
+#define READ_STATE_H
+
+class QUICK_GROUP_MIN_MAX_SELECT;
+
+class Read_state {
+protected:
+ QUICK_GROUP_MIN_MAX_SELECT &m_owner;
+public:
+ Read_state(QUICK_GROUP_MIN_MAX_SELECT &owner) : m_owner(owner) {}
+ virtual int read() =0;
+ virtual ~Read_state() {};
+};
+
+class Min_read_state : public Read_state {
+public:
+ Min_read_state(QUICK_GROUP_MIN_MAX_SELECT &owner);
+ int read();
+};
+
+class Max_read_state : public Read_state {
+public:
+ Max_read_state(QUICK_GROUP_MIN_MAX_SELECT &owner);
+ int read();
+};
+
+class Prefix_read_state : public Read_state {
+public:
+ Prefix_read_state(QUICK_GROUP_MIN_MAX_SELECT &owner);
+ int read();
+};
+
+#endif // READ_STATE_H
Attachment: [text/bzr-bundle] bzr/martin.hansson@oracle.com-20110127134019-40ba2w6pek62idb6.bundle
| Thread |
|---|
| • bzr commit into mysql-trunk branch (martin.hansson:3279) | Martin Hansson | 27 Jan |