Below is the list of changes that have just been committed into a local
4.1 repository of Sinisa. When Sinisa does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://www.mysql.com/doc/I/n/Installing_source_tree.html
ChangeSet
1.1576 03/08/23 21:21:02 Sinisa@stripped +4 -0
union.result:
same as above
sql_lex.h:
same as above
sql_union.cc:
same as aobve
sql_select.cc:
Fixing that SQL_CALC_FOUND_ROWS work properly in UNION's in 4.1
Plus updating some fields in THD in the proper places
plus fixing a wrong result
mysql-test/r/union.result
1.43 03/08/23 21:20:38 Sinisa@stripped +1 -1
same as above
sql/sql_lex.h
1.131 03/08/23 21:20:34 Sinisa@stripped +2 -2
same as above
sql/sql_union.cc
1.87 03/08/23 21:20:22 Sinisa@stripped +24 -15
same as aobve
sql/sql_select.cc
1.241 03/08/23 21:19:09 Sinisa@stripped +3 -2
Fixing that SQL_CALC_FOUND_ROWS work properly in UNION's in 4.1
Plus updating some fields in THD in the proper places
plus fixing a wrong result
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: Sinisa
# Host: sinisa.nasamreza.org
# Root: /mnt/work/mysql-4.1
--- 1.130/sql/sql_lex.h Tue Aug 19 00:08:02 2003
+++ 1.131/sql/sql_lex.h Sat Aug 23 21:20:34 2003
@@ -290,8 +290,8 @@
select_result *result;
int res;
- bool describe, found_rows_for_union,
- prepared, // prepare phase already performed for UNION (unit)
+ ulong describe, found_rows_for_union;
+ bool prepared, // prepare phase already performed for UNION (unit)
optimized, // optimize phase already performed for UNION (unit)
executed, // already executed
t_and_f; // used for transferring tables_and_fields_initied UNIT:: methods
--- 1.240/sql/sql_select.cc Tue Aug 19 00:08:57 2003
+++ 1.241/sql/sql_select.cc Sat Aug 23 21:19:09 2003
@@ -941,6 +941,7 @@
DBUG_ENTER("JOIN::exec");
error= 0;
+ thd->limit_found_rows= thd->examined_row_count= 0;
if (procedure)
{
if (procedure->change_columns(fields_list) ||
@@ -1323,6 +1324,8 @@
thd->proc_info="Sending data";
error= thd->net.report_error ||
do_select(curr_join, curr_fields_list, NULL, procedure);
+ thd->limit_found_rows= curr_join->send_records;
+ thd->examined_row_count= curr_join->examined_rows;
DBUG_VOID_RETURN;
}
@@ -1434,8 +1437,6 @@
(join->tmp_join->error=join->error,join->tmp_join):
join);
- thd->limit_found_rows= curr_join->send_records;
- thd->examined_row_count= curr_join->examined_rows;
thd->proc_info="end";
err= join->cleanup();
if (thd->net.report_error)
--- 1.42/mysql-test/r/union.result Tue Aug 19 00:08:01 2003
+++ 1.43/mysql-test/r/union.result Sat Aug 23 21:20:38 2003
@@ -103,7 +103,7 @@
2 b
select found_rows();
found_rows()
-6
+8
explain select a,b from t1 union all select a,b from t2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
--- 1.86/sql/sql_union.cc Wed Aug 20 13:56:24 2003
+++ 1.87/sql/sql_union.cc Sat Aug 23 21:20:22 2003
@@ -204,7 +204,7 @@
select_limit_cnt= sl->select_limit+sl->offset_limit;
if (select_limit_cnt < sl->select_limit)
select_limit_cnt= HA_POS_ERROR; // no limit
- if (select_limit_cnt == HA_POS_ERROR && !sl->braces)
+ if (select_limit_cnt == HA_POS_ERROR || sl->braces)
sl->options&= ~OPTION_FOUND_ROWS;
res= join->prepare(&sl->ref_pointer_array,
@@ -249,7 +249,7 @@
{
SELECT_LEX_NODE *lex_select_save= thd->lex.current_select;
SELECT_LEX *select_cursor=first_select_in_union();
- unsigned int add_rows=0;
+ ulonglong add_rows=0;
DBUG_ENTER("st_select_lex_unit::exec");
if (executed && !(dependent || uncacheable))
@@ -266,7 +266,7 @@
}
for (SELECT_LEX *sl= select_cursor; sl; sl= sl->next_select())
{
- unsigned int rows;
+ ha_rows records_at_start;
if (optimized)
res= sl->join->reinit();
else
@@ -279,12 +279,15 @@
select_limit_cnt= sl->select_limit+sl->offset_limit;
if (select_limit_cnt < sl->select_limit)
select_limit_cnt= HA_POS_ERROR; // no limit
- if (select_limit_cnt == HA_POS_ERROR)
+ if (select_limit_cnt == HA_POS_ERROR || sl->braces)
sl->options&= ~OPTION_FOUND_ROWS;
- else if (found_rows_for_union)
+ else
{
- rows= thd->select_limit;
- sl->options|= OPTION_FOUND_ROWS;
+ /*
+ We are doing an union without braces. In this case
+ SQL_CALC_FOUND_ROWS should be done on all sub parts
+ */
+ sl->options|= found_rows_for_union;
}
res= join->prepare(&sl->ref_pointer_array,
@@ -308,6 +311,7 @@
}
if (!res)
{
+ records_at_start= table->file->records;
sl->join->exec();
res= sl->join->error;
if (!res && union_result->flush())
@@ -321,8 +325,17 @@
thd->lex.current_select= lex_select_save;
DBUG_RETURN(res);
}
- if (found_rows_for_union && !sl->braces && sl->options & OPTION_FOUND_ROWS)
- add_rows+= (thd->limit_found_rows > rows) ? thd->limit_found_rows - rows : 0;
+ if (found_rows_for_union & sl->options)
+ {
+ /*
+ This is a union without braces. Remember the number of rows that could
+ also have been part of the result set.
+ We get this from the difference of between total number of possible
+ rows and actual rows added to the temporary table.
+ */
+ add_rows+= (ulonglong) (thd->limit_found_rows - (table->file->records -
+ records_at_start));
+ }
}
}
optimized= 1;
@@ -360,12 +373,8 @@
(ORDER*) NULL, NULL, (ORDER*) NULL,
thd->options | SELECT_NO_UNLOCK,
result, this, fake_select, 0);
- if (found_rows_for_union && !res)
- {
- thd->limit_found_rows= table->file->records;
- if (!select_cursor->braces)
- thd->limit_found_rows+= add_rows;
- }
+ if (!res)
+ thd->limit_found_rows = (ulonglong)table->file->records + add_rows;
fake_select->exclude();
delete fake_select;
/*
| Thread |
|---|
| • bk commit into 4.1 tree (1.1576) | sinisa | 23 Aug |