summaryrefslogtreecommitdiff
path: root/sql/sql_union.cc
diff options
context:
space:
mode:
authorunknown <Sinisa@sinisa.nasamreza.org>2004-05-03 19:15:26 +0300
committerunknown <Sinisa@sinisa.nasamreza.org>2004-05-03 19:15:26 +0300
commit19c91b79203ebaa1f5ac557bf3684d1f48c0a90e (patch)
treefe523909dc9847c894ba088b73e2c731d8a7ae18 /sql/sql_union.cc
parent4bde9b834af10823f5d13f2c22c571e318474277 (diff)
downloadmariadb-git-19c91b79203ebaa1f5ac557bf3684d1f48c0a90e.tar.gz
Fix for a bug involving UNION's and SET SQL_SELECT_LIMIT
mysql-test/r/union.result: Results for a test case for bug involving UNION's and SET SQL_SELECT_LIMIT mysql-test/t/union.test: Test case for bug involving UNION's and SET SQL_SELECT_LIMIT sql/sql_union.cc: Patch for a bug involving UNION's and SET SQL_SELECT_LIMIT
Diffstat (limited to 'sql/sql_union.cc')
-rw-r--r--sql/sql_union.cc15
1 files changed, 12 insertions, 3 deletions
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index 468bdab9119..df20f04a67e 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -377,12 +377,21 @@ int st_select_lex_unit::exec()
if (!thd->is_fatal_error) // Check if EOM
{
ulong options_tmp= thd->options;
+ /*
+ We have to take into the account a case when:
+ SET SQL_SELECT_LIMIT was set.
+ In mysql_new_select() function this value was copied to
+ the fake_select_lex node of the top-level unit.
+ Here below, we just take this value if global LIMIT was not applied
+ to the entire UNION.
+ */
+ ha_rows select_limit= ((global_parameters->select_limit != HA_POS_ERROR) ?
+ global_parameters->select_limit : fake_select_lex->select_limit);
thd->lex->current_select= fake_select_lex;
offset_limit_cnt= global_parameters->offset_limit;
- select_limit_cnt= global_parameters->select_limit +
- global_parameters->offset_limit;
+ select_limit_cnt= select_limit + global_parameters->offset_limit;
- if (select_limit_cnt < global_parameters->select_limit)
+ if (select_limit_cnt < select_limit)
select_limit_cnt= HA_POS_ERROR; // no limit
if (select_limit_cnt == HA_POS_ERROR)
options_tmp&= ~OPTION_FOUND_ROWS;