summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSinisa@sinisa.nasamreza.org <>2002-03-19 14:23:11 +0200
committerSinisa@sinisa.nasamreza.org <>2002-03-19 14:23:11 +0200
commitb226bad64aae0ccaba22f507a7011e7b2fee11c7 (patch)
tree2e1df94f212f8dfa95332622cf43ae67760bbbfd
parentd8b085b92bb0ef4b76eecda8604157227030144f (diff)
downloadmariadb-git-b226bad64aae0ccaba22f507a7011e7b2fee11c7.tar.gz
Some changes from 4.0.
Take a look their for details
-rw-r--r--mysql-test/r/union.result21
-rw-r--r--mysql-test/t/union.test8
-rw-r--r--sql/sql_union.cc2
-rw-r--r--sql/sql_yacc.yy14
4 files changed, 38 insertions, 7 deletions
diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result
index e842bb3b447..113f6680167 100644
--- a/mysql-test/r/union.result
+++ b/mysql-test/r/union.result
@@ -77,6 +77,8 @@ a b
(select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1);
a b
1 a
+2 b
+3 c
(select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by b desc;
a b
3 c
@@ -157,3 +159,22 @@ testtt
tsestset
1
drop table t1;
+drop table if exists t1,t2;
+create table t1 (a int);
+create table t2 (a int);
+insert into t1 values (1),(2),(3),(4),(5);
+insert into t2 values (11),(12),(13),(14),(15);
+(select * from t1 limit 2) union (select * from t2 limit 3) limit 4;
+a
+1
+2
+11
+12
+(select * from t1 limit 2) union (select * from t2 limit 3);
+a
+1
+2
+11
+12
+13
+drop table t1,t2;
diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test
index f782c61d97a..f648ebfd48c 100644
--- a/mysql-test/t/union.test
+++ b/mysql-test/t/union.test
@@ -77,3 +77,11 @@ SELECT pseudo1 FROM t1 WHERE pseudo='joce' UNION SELECT pseudo FROM t1 WHERE pse
SELECT pseudo1 FROM t1 WHERE pseudo='joce' UNION ALL SELECT pseudo FROM t1 WHERE pseudo1='joce';
SELECT pseudo1 FROM t1 WHERE pseudo='joce' UNION SELECT 1;
drop table t1;
+drop table if exists t1,t2;
+create table t1 (a int);
+create table t2 (a int);
+insert into t1 values (1),(2),(3),(4),(5);
+insert into t2 values (11),(12),(13),(14),(15);
+(select * from t1 limit 2) union (select * from t2 limit 3) limit 4;
+(select * from t1 limit 2) union (select * from t2 limit 3);
+drop table t1,t2;
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index 7d921d6e598..7532f43a663 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -184,6 +184,8 @@ int mysql_union(THD *thd, LEX *lex,select_result *result)
if (thd->select_limit == HA_POS_ERROR)
thd->options&= ~OPTION_FOUND_ROWS;
}
+ else
+ thd->select_limit= HA_POS_ERROR; // no limit
if (describe)
thd->select_limit= HA_POS_ERROR; // no limit
res=mysql_select(thd,&result_table_list,
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index d762c8784a3..3c9c005fb48 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -1441,22 +1441,22 @@ select_option_list:
select_option:
STRAIGHT_JOIN { Select->options|= SELECT_STRAIGHT_JOIN; }
- | HIGH_PRIORITY { Lex->lock_option= TL_READ_HIGH_PRIORITY; }
+ | HIGH_PRIORITY { if (Select != &Lex->select_lex) YYABORT; Lex->lock_option= TL_READ_HIGH_PRIORITY; }
| DISTINCT { Select->options|= SELECT_DISTINCT; }
| SQL_SMALL_RESULT { Select->options|= SELECT_SMALL_RESULT; }
| SQL_BIG_RESULT { Select->options|= SELECT_BIG_RESULT; }
- | SQL_BUFFER_RESULT { Select->options|= OPTION_BUFFER_RESULT; }
- | SQL_CALC_FOUND_ROWS { Select->options|= OPTION_FOUND_ROWS; }
- | SQL_NO_CACHE_SYM { current_thd->safe_to_cache_query=0; }
- | SQL_CACHE_SYM { Select->options |= OPTION_TO_QUERY_CACHE; }
+ | SQL_BUFFER_RESULT { if (Select != &Lex->select_lex) YYABORT; Select->options|= OPTION_BUFFER_RESULT; }
+ | SQL_CALC_FOUND_ROWS { if (Select != &Lex->select_lex) YYABORT; Select->options|= OPTION_FOUND_ROWS; }
+ | SQL_NO_CACHE_SYM { if (Select != &Lex->select_lex) YYABORT; current_thd->safe_to_cache_query=0; }
+ | SQL_CACHE_SYM { if (Select != &Lex->select_lex) YYABORT; Select->options |= OPTION_TO_QUERY_CACHE; }
| ALL {}
select_lock_type:
/* empty */
| FOR_SYM UPDATE_SYM
- { Lex->lock_option= TL_WRITE; current_thd->safe_to_cache_query=0; }
+ { if (Select != &Lex->select_lex) YYABORT; Lex->lock_option= TL_WRITE; current_thd->safe_to_cache_query=0; }
| LOCK_SYM IN_SYM SHARE_SYM MODE_SYM
- { Lex->lock_option= TL_READ_WITH_SHARED_LOCKS; current_thd->safe_to_cache_query=0; }
+ { if (Select != &Lex->select_lex) YYABORT; Lex->lock_option= TL_READ_WITH_SHARED_LOCKS; current_thd->safe_to_cache_query=0; }
select_item_list:
select_item_list ',' select_item