From ac9016df919a42aa77a6a9db42cd17b3674a3bce Mon Sep 17 00:00:00 2001 From: "magnus@neptunus.(none)" <> Date: Thu, 7 Oct 2004 11:57:48 +0200 Subject: [PATCH] Initialise "sorted" variable in constructor of QUICK_SELECT. The variable is set to 1 in test_if_skip_sort_order if we decide to optimize "order by" by uinsg index_read. --- mysql-test/r/ndb_index_ordered.result | 10 ++++++++++ mysql-test/t/ndb_index_ordered.test | 2 ++ sql/ha_ndbcluster.cc | 3 +++ sql/opt_range.cc | 2 +- 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/ndb_index_ordered.result b/mysql-test/r/ndb_index_ordered.result index e0c486ee2c5..2910161eb74 100644 --- a/mysql-test/r/ndb_index_ordered.result +++ b/mysql-test/r/ndb_index_ordered.result @@ -45,6 +45,16 @@ a b c 2 3 5 3 4 6 4 5 8 +select a, b, c from t1 where a!=2 and c=6; +a b c +3 4 6 +select a, b, c from t1 where a!=2 order by a; +a b c +1 2 3 +3 4 6 +4 5 8 +5 6 2 +6 7 2 update t1 set c = 3 where b = 3; select * from t1 order by a; a b c diff --git a/mysql-test/t/ndb_index_ordered.test b/mysql-test/t/ndb_index_ordered.test index e1766f6e624..67c42e29e0c 100644 --- a/mysql-test/t/ndb_index_ordered.test +++ b/mysql-test/t/ndb_index_ordered.test @@ -25,6 +25,8 @@ select * from t1 where b <= 4 order by b; # Test of reset_bounds select tt1.* from t1 as tt1, t1 as tt2 use index(b) where tt1.b = tt2.b order by tt1.c; +select a, b, c from t1 where a!=2 and c=6; +select a, b, c from t1 where a!=2 order by a; # # Here we should add some "explain select" to verify that the ordered index is diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 7747fb685fc..218b615b60d 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -1350,6 +1350,9 @@ int ha_ndbcluster::ordered_index_scan(const key_range *start_key, DBUG_EXECUTE("enter", print_key(start_key, "start_key");); DBUG_EXECUTE("enter", print_key(end_key, "end_key");); + + // Check that sorted seems to be initialised + DBUG_ASSERT(sorted == 0 || sorted == 1); if(m_active_cursor == 0) { diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 9c5b0235767..541acc69ec7 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -393,7 +393,7 @@ SQL_SELECT::~SQL_SELECT() #undef index // Fix for Unixware 7 QUICK_SELECT::QUICK_SELECT(THD *thd, TABLE *table, uint key_nr, bool no_alloc) - :dont_free(0),error(0),index(key_nr),max_used_key_length(0), + :dont_free(0),sorted(0),error(0),index(key_nr),max_used_key_length(0), used_key_parts(0), head(table), it(ranges),range(0) { if (!no_alloc)