From d765d3f37b961e8a83e0c56365de27303d3a986b Mon Sep 17 00:00:00 2001
From: unknown <bell@sanja.is.com.ua>
Date: Wed, 25 Dec 2002 12:03:08 +0200
Subject: [PATCH] check of LIMIT in row IN subquery (SCRUM related)

mysql-test/r/subselect.result:
  test of LIMIT in row IN subquery
mysql-test/t/subselect.test:
  test of LIMIT in row IN subquery
sql/item_subselect.cc:
  check of LIMIT in row IN subquery
---
 mysql-test/r/subselect.result |  2 ++
 mysql-test/t/subselect.test   |  2 ++
 sql/item_subselect.cc         | 14 ++++++++++++++
 3 files changed, 18 insertions(+)

diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index 6411bf2a3b..ec0de79cbe 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -809,4 +809,6 @@ NULL
 select ROW(1, 1, 'a') IN (select b,a,c from t where c='b' or c='a');
 ROW(1, 1, 'a') IN (select b,a,c from t where c='b' or c='a')
 1
+select ROW(1, 1, 'a') IN (select b,a,c from t limit 2);
+This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
 drop table if exists t;
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
index cd4baacdac..c77fc33f0e 100644
--- a/mysql-test/t/subselect.test
+++ b/mysql-test/t/subselect.test
@@ -454,4 +454,6 @@ select ROW(1, 1, 'a') IN (select b,a,c from t where a is not null);
 select ROW(1, 1, 'a') IN (select a,b,c from t where c='b' or c='a');
 select ROW(1, 2, 'a') IN (select a,b,c from t where c='b' or c='a');
 select ROW(1, 1, 'a') IN (select b,a,c from t where c='b' or c='a');
+-- error 1235
+select ROW(1, 1, 'a') IN (select b,a,c from t limit 2);
 drop table if exists t;
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 74824fc775..6bcb78134a 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -517,6 +517,13 @@ void Item_in_subselect::row_value_transformer(st_select_lex *select_lex,
 					      Item *left_expr)
 {
   DBUG_ENTER("Item_in_subselect::row_value_transformer");
+  if (select_lex->master_unit()->global_parameters->select_limit != 
+      HA_POS_ERROR)
+  {
+    my_error(ER_NOT_SUPPORTED_YET, MYF(0),
+	     "LIMIT & IN/ALL/ANY/SOME subquery");
+    DBUG_VOID_RETURN;
+  }
   Item_in_optimizer *optimizer;
   substitution= optimizer= new Item_in_optimizer(left_expr, this);
   if (!optimizer)
@@ -530,6 +537,13 @@ void Item_in_subselect::row_value_transformer(st_select_lex *select_lex,
     DBUG_VOID_RETURN;
   for (SELECT_LEX * sl= select_lex; sl; sl= sl->next_select())
   {
+    if (select_lex->select_limit != HA_POS_ERROR)
+    {
+      my_error(ER_NOT_SUPPORTED_YET, MYF(0),
+	       "LIMIT & IN/ALL/ANY/SOME subquery");
+      DBUG_VOID_RETURN;
+    }
+
     select_lex->dependent= 1;
 
     Item *item= 0;
-- 
2.30.9