summaryrefslogtreecommitdiff
path: root/sql/sql_union.cc
diff options
context:
space:
mode:
authormithun <mithun.c.y@oracle.com>2014-05-08 14:49:53 +0530
committermithun <mithun.c.y@oracle.com>2014-05-08 14:49:53 +0530
commitee3c555ad9abd0f98434910ce7892819607c06a3 (patch)
treef4850420e2ee2b793d1dc87100218d1e719ed37b /sql/sql_union.cc
parent858e5626c5cdee3b0359e906fb04bdbbb6d38190 (diff)
downloadmariadb-git-ee3c555ad9abd0f98434910ce7892819607c06a3.tar.gz
Bug #17059925: UNIONS COMPUTES ROWS_EXAMINED INCORRECTLY
ISSUE: ------ For UNION of selects, rows examined by the query will be sum of rows examined by individual select operations and rows examined for union operation. The value of session level global counter that is used to count the rows examined by a select statement should be accumulated and reset before it is used for next select statement. But we have missed to reset the same. Because of this examined row count of a select query is accounted more than once. SOLUTION: --------- In union reset the session level global counter used to accumulate count of examined rows after its value is saved. mysql-test/r/union.result: Expected output of testcase added. mysql-test/t/union.test: Test to verify examined row count of Union operations. sql/sql_union.cc: Reset the value of thd->examined_row_count after accumulating the value.
Diffstat (limited to 'sql/sql_union.cc')
-rw-r--r--sql/sql_union.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index d0660e8f117..d230b903d2c 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -557,7 +557,13 @@ bool st_select_lex_unit::exec()
0);
if (!saved_error)
{
+ /*
+ Save the current examined row count locally and clear the global
+ counter, so that we can accumulate the number of evaluated rows for
+ the current query block.
+ */
examined_rows+= thd->examined_row_count;
+ thd->examined_row_count= 0;
if (union_result->flush())
{
thd->lex->current_select= lex_select_save;