diff options
author | unknown <Sinisa@sinisa.nasamreza.org> | 2002-03-19 14:07:52 +0200 |
---|---|---|
committer | unknown <Sinisa@sinisa.nasamreza.org> | 2002-03-19 14:07:52 +0200 |
commit | 7fc36355bc9b3678109b53209b84fe718da498ce (patch) | |
tree | 767475bf73bc5e960912ea2923dda9f65b5cebf6 | |
parent | ef38d5c3a9b393abe5276a64e5137a5be025264a (diff) | |
download | mariadb-git-7fc36355bc9b3678109b53209b84fe718da498ce.tar.gz |
fix for the limit bug in UNION's and some additional syntax
checkings
mysql-test/r/union.result:
fix for the limit bug in UNION's
mysql-test/t/union.test:
fix for the limit bug in UNION's
sql/sql_union.cc:
fix for the limit bug in UNION's
sql/sql_yacc.yy:
Syntax checking for options that should appear in main select only.
-rw-r--r-- | mysql-test/r/union.result | 21 | ||||
-rw-r--r-- | mysql-test/t/union.test | 8 | ||||
-rw-r--r-- | sql/sql_union.cc | 2 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 14 |
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 82a88633b69..0aca2668941 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -185,6 +185,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 83a21b03ac4..5b1a168ae34 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1430,22 +1430,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 |