summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2003-03-11 18:34:00 +0200
committerunknown <bell@sanja.is.com.ua>2003-03-11 18:34:00 +0200
commite5fdb09dd08b4af81b733631ab435bb1ca568761 (patch)
treec902e984493a96b4fcf9e15fe78e68944787b9f3
parentb8ab0ce91b326f536c364b3964ba9dfdfef51849 (diff)
downloadmariadb-git-e5fdb09dd08b4af81b733631ab435bb1ca568761.tar.gz
fixed bug of unchecked random part of WHERE clause (bug #142)
mysql-test/r/select.result: test of random WHERE clause mysql-test/t/select.test: test of random WHERE clause sql/sql_select.cc: fixed bug of unchecked random part of WHERE clause
-rw-r--r--mysql-test/r/select.result1
-rw-r--r--mysql-test/t/select.test17
-rw-r--r--sql/sql_select.cc2
3 files changed, 19 insertions, 1 deletions
diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result
index 5ac5de05f97..dcb796b8e00 100644
--- a/mysql-test/r/select.result
+++ b/mysql-test/r/select.result
@@ -1793,3 +1793,4 @@ Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_par
t2 0 PRIMARY 1 auto A 1199 NULL NULL
t2 0 fld1 1 fld1 A 1199 NULL NULL
t2 1 fld3 1 fld3 A NULL NULL NULL
+1
diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test
index cdb6ee57e0f..2caadd99dbb 100644
--- a/mysql-test/t/select.test
+++ b/mysql-test/t/select.test
@@ -1713,7 +1713,22 @@ show full columns from t2 from test like 's%';
show keys from t2;
#
+# random in WHERE clause
+#
+
+drop table t1;
+CREATE TABLE t1 (
+ id mediumint(8) unsigned NOT NULL auto_increment,
+ pseudo varchar(35) NOT NULL default '',
+ PRIMARY KEY (id),
+ UNIQUE KEY pseudo (pseudo)
+);
+INSERT INTO t1 (pseudo) VALUES ('test');
+INSERT INTO t1 (pseudo) VALUES ('test1');
+SELECT 1 from t1 where rand() > 2;
+
+#
# Drop the test tables
#
-drop table t4, t3,t2, t1;
+drop table t4, t3, t2, t1;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 8444a451965..bae64969fcd 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -2257,6 +2257,8 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
{
JOIN_TAB *tab=join->join_tab+i;
table_map current_map= tab->table->map;
+ if (i == join->tables-1)
+ current_map|= RAND_TABLE_BIT;
bool use_quick_range=0;
used_tables|=current_map;