summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2004-05-10 13:29:02 +0300
committerunknown <bell@sanja.is.com.ua>2004-05-10 13:29:02 +0300
commitf71f59731beaa2c911bdb3efc3b26fc6dcd19b1b (patch)
tree30c96c955664acef9b9170b5099c684cdee484fc
parentc6bc3cfb8457332b4519efcd10339c2632626acb (diff)
downloadmariadb-git-f71f59731beaa2c911bdb3efc3b26fc6dcd19b1b.tar.gz
treat parameter as constant in ORDER BY check of fields in SELECT list(Bug #3686)
sql/sql_select.cc: treat parameter as constant in ORDER BY check of fields in SELECT list tests/client_test.c: test of using parameters in SELECT list with ORDER BY
-rw-r--r--sql/sql_select.cc3
-rw-r--r--tests/client_test.c48
2 files changed, 49 insertions, 2 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 5db4a0042ea..6a64665b4cc 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -367,7 +367,8 @@ JOIN::prepare(Item ***rref_pointer_array,
{
if (item->with_sum_func)
flag|=1;
- else if (!(flag & 2) && !item->const_item())
+ else if (!(flag & 2) &&
+ test(item->used_tables() & ~PARAM_TABLE_BIT))
flag|=2;
}
if (flag == 3)
diff --git a/tests/client_test.c b/tests/client_test.c
index d382377fe49..ba70bcd7fa7 100644
--- a/tests/client_test.c
+++ b/tests/client_test.c
@@ -9453,7 +9453,6 @@ select col1 FROM t1 where col1=2");
myquery(rc);
}
-
/*
This tests for various mysql_send_long_data bugs described in #1664
*/
@@ -9595,6 +9594,51 @@ static void test_bug1664()
myquery(rc);
}
+
+static void test_order_param()
+{
+ MYSQL_STMT *stmt;
+ int rc;
+
+ myheader("test_order_param");
+
+ rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
+ myquery(rc);
+
+ rc= mysql_query(mysql,"CREATE TABLE t1(a INT, b char(10))");
+ myquery(rc);
+
+ stmt= mysql_simple_prepare(mysql,
+ "select sum(a) + 200, 1 from t1 \
+union distinct \
+select sum(a) + 200, 1 from t1 \
+group by b ");
+ check_stmt(stmt);
+
+ mysql_stmt_close(stmt);
+
+ stmt= mysql_simple_prepare(mysql,
+ "select sum(a) + 200, ? from t1 \
+group by b \
+union distinct \
+select sum(a) + 200, 1 from t1 \
+group by b ");
+ check_stmt(stmt);
+
+ stmt= mysql_simple_prepare(mysql,
+ "select sum(a) + 200, ? from t1 \
+union distinct \
+select sum(a) + 200, 1 from t1 \
+group by b ");
+ check_stmt(stmt);
+
+ mysql_stmt_close(stmt);
+
+ rc= mysql_query(mysql, "DROP TABLE t1");
+ myquery(rc);
+}
+
+
/*
Read and parse arguments and MySQL options from my.cnf
*/
@@ -9877,6 +9921,8 @@ int main(int argc, char **argv)
test_union2(); /* repeatable execution of union (Bug #3577) */
test_bug1664(); /* test for bugs in mysql_stmt_send_long_data()
call (Bug #1664) */
+ test_order_param(); /* ORDER BY with parameters in select list
+ (Bug #3686 */
end_time= time((time_t *)0);
total_time+= difftime(end_time, start_time);