Below is the list of changes that have just been committed into a local
5.0 repository of igor. When igor 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://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.2093 06/04/21 00:36:20 igor@stripped +8 -0
Merge rurik.mysql.com:/home/igor/dev/mysql-4.1-0
into rurik.mysql.com:/home/igor/dev/mysql-5.0-0
sql/sql_union.cc
1.131 06/04/21 00:36:14 igor@stripped +1 -2
Manual merge
sql/sql_parse.cc
1.539 06/04/21 00:36:14 igor@stripped +13 -12
Manual merge
sql/sql_lex.h
1.215 06/04/21 00:36:14 igor@stripped +0 -0
Manual merge
mysql-test/t/order_by.test
1.36 06/04/21 00:36:14 igor@stripped +14 -14
Manual merge
mysql-test/t/func_gconcat.test
1.44 06/04/21 00:36:14 igor@stripped +10 -0
Manual merge
sql/sql_yacc.yy
1.465 06/04/20 23:28:57 igor@stripped +0 -0
Auto merged
sql/sql_select.cc
1.407 06/04/20 23:28:57 igor@stripped +0 -0
Auto merged
mysql-test/r/order_by.result
1.51 06/04/20 23:28:57 igor@stripped +0 -0
Auto merged
# 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: igor
# Host: rurik.mysql.com
# Root: /home/igor/dev/mysql-5.0-0/RESYNC
--- 1.214/sql/sql_lex.h 2006-03-09 16:44:01 -08:00
+++ 1.215/sql/sql_lex.h 2006-04-21 00:36:14 -07:00
@@ -454,6 +454,7 @@
void print(String *str);
+ bool add_fake_select_lex(THD *thd);
void init_prepare_fake_select_lex(THD *thd);
inline bool is_prepared() { return prepared; }
bool change_result(select_subselect *result, select_subselect *old_result);
--- 1.538/sql/sql_parse.cc 2006-04-13 13:05:40 -07:00
+++ 1.539/sql/sql_parse.cc 2006-04-21 00:36:14 -07:00
@@ -5544,48 +5544,17 @@
}
else
{
- Name_resolution_context *outer_context;
if (lex->current_select->order_list.first && !lex->current_select->braces)
{
my_error(ER_WRONG_USAGE, MYF(0), "UNION", "ORDER BY");
DBUG_RETURN(1);
}
select_lex->include_neighbour(lex->current_select);
- /*
- we are not sure that we have one level of SELECTs above, so we take
- outer_context address from first select of unit
- */
- outer_context=
- select_lex->master_unit()->first_select()->context.outer_context;
- SELECT_LEX_UNIT *unit= select_lex->master_unit();
- SELECT_LEX *fake= unit->fake_select_lex;
- if (!fake)
- {
- /*
- as far as we included SELECT_LEX for UNION unit should have
- fake SELECT_LEX for UNION processing
- */
- if (!(fake= unit->fake_select_lex= new (thd->mem_root) SELECT_LEX()))
- DBUG_RETURN(1);
- fake->include_standalone(unit,
- (SELECT_LEX_NODE**)&unit->fake_select_lex);
- fake->select_number= INT_MAX;
- fake->parent_lex= lex; /* Used in init_query. */
- fake->make_empty_select();
- fake->linkage= GLOBAL_OPTIONS_TYPE;
- fake->select_limit= 0;
-
- fake->context.outer_context= outer_context;
- /* allow item list resolving in fake select for ORDER BY */
- fake->context.resolve_in_select_list= TRUE;
- fake->context.select_lex= fake;
- /*
- Remove the name resolution context of the fake select from the
- context stack.
- */
- lex->pop_context();
- }
- select_lex->context.outer_context= outer_context;
+ SELECT_LEX_UNIT *unit= select_lex->master_unit();
+ if (!unit->fake_select_lex && unit->add_fake_select_lex(lex->thd))
+ DBUG_RETURN(1);
+ select_lex->context.outer_context=
+ unit->first_select()->context.outer_context;
}
select_lex->master_unit()->global_parameters= select_lex;
@@ -6354,6 +6323,67 @@
tables->updating= for_update;
}
DBUG_VOID_RETURN;
+}
+
+
+/*
+ Create a fake SELECT_LEX for a unit
+
+ SYNOPSIS:
+ add_fake_select_lex()
+ thd thread handle
+
+ DESCRIPTION
+ The method create a fake SELECT_LEX object for a unit.
+ This object is created for any union construct containing a union
+ operation and also for any single select union construct of the form
+ (SELECT ... ORDER BY order_list [LIMIT n]) ORDER BY ...
+ or of the form
+ (SELECT ... ORDER BY LIMIT n) ORDER BY ...
+
+ NOTES
+ The object is used to retrieve rows from the temporary table
+ where the result on the union is obtained.
+
+ RETURN VALUES
+ 1 on failure to create the object
+ 0 on success
+*/
+
+bool st_select_lex_unit::add_fake_select_lex(THD *thd)
+{
+ SELECT_LEX *first_sl= first_select();
+ DBUG_ENTER("add_fake_select_lex");
+ DBUG_ASSERT(!fake_select_lex);
+
+ if (!(fake_select_lex= new (thd->mem_root) SELECT_LEX()))
+ DBUG_RETURN(1);
+ fake_select_lex->include_standalone(this,
+ (SELECT_LEX_NODE**)&fake_select_lex);
+ fake_select_lex->select_number= INT_MAX;
+ fake_select_lex->make_empty_select();
+ fake_select_lex->linkage= GLOBAL_OPTIONS_TYPE;
+ fake_select_lex->select_limit= 0;
+
+ fake_select_lex->context.outer_context= first_sl->context.outer_context;
+ /* allow item list resolving in fake select for ORDER BY */
+ fake_select_lex->context.resolve_in_select_list= TRUE;
+ fake_select_lex->context.select_lex= fake_select_lex;
+
+ if (!first_sl->next_select())
+ {
+ /*
+ This works only for
+ (SELECT ... ORDER BY list [LIMIT n]) ORDER BY order_list [LIMIT m],
+ (SELECT ... LIMIT n) ORDER BY order_list [LIMIT m]
+ just before the parser starts processing order_list
+ */
+ global_parameters= fake_select_lex;
+ fake_select_lex->no_table_names_allowed= 1;
+ thd->lex->current_select= fake_select_lex;
+ }
+ thd->lex->pop_context();
+ DBUG_RETURN(0);
}
--- 1.406/sql/sql_select.cc 2006-04-20 00:42:06 -07:00
+++ 1.407/sql/sql_select.cc 2006-04-20 23:28:57 -07:00
@@ -224,7 +224,7 @@
register SELECT_LEX *select_lex = &lex->select_lex;
DBUG_ENTER("handle_select");
- if (select_lex->next_select())
+ if (select_lex->next_select() || select_lex->master_unit()->fake_select_lex)
res= mysql_union(thd, lex, result, &lex->unit, setup_tables_done_option);
else
{
--- 1.464/sql/sql_yacc.yy 2006-04-13 15:38:31 -07:00
+++ 1.465/sql/sql_yacc.yy 2006-04-20 23:28:57 -07:00
@@ -5697,14 +5697,32 @@
ORDER_SYM BY
{
LEX *lex=Lex;
- if (lex->current_select->linkage != GLOBAL_OPTIONS_TYPE &&
- lex->current_select->olap !=
- UNSPECIFIED_OLAP_TYPE)
+ SELECT_LEX *sel= lex->current_select;
+ SELECT_LEX_UNIT *unit= sel-> master_unit();
+ if (sel->linkage != GLOBAL_OPTIONS_TYPE &&
+ sel->olap != UNSPECIFIED_OLAP_TYPE)
{
my_error(ER_WRONG_USAGE, MYF(0),
"CUBE/ROLLUP", "ORDER BY");
YYABORT;
}
+ if (lex->sql_command != SQLCOM_ALTER_TABLE && !unit->fake_select_lex)
+ {
+ /*
+ A query of the of the form (SELECT ...) ORDER BY order_list is
+ executed in the same way as the query
+ SELECT ... ORDER BY order_list
+ unless the SELECT construct contains ORDER BY or LIMIT clauses.
+ Otherwise we create a fake SELECT_LEX if it has not been created
+ yet.
+ */
+ SELECT_LEX *first_sl= unit->first_select();
+ if (!first_sl->next_select() &&
+ (first_sl->order_list.elements ||
+ first_sl->select_limit != HA_POS_ERROR) &&
+ unit->add_fake_select_lex(lex->thd))
+ YYABORT;
+ }
} order_list;
order_list:
--- 1.130/sql/sql_union.cc 2005-10-13 00:52:53 -07:00
+++ 1.131/sql/sql_union.cc 2006-04-21 00:36:14 -07:00
@@ -202,7 +202,7 @@
thd_arg->lex->current_select= sl= first_sl;
found_rows_for_union= first_sl->options & OPTION_FOUND_ROWS;
- is_union= test(first_sl->next_select());
+ is_union= test(first_select->next_select() || fake_select_lex);
/* Global option */
--- 1.50/mysql-test/r/order_by.result 2005-08-23 08:08:00 -07:00
+++ 1.51/mysql-test/r/order_by.result 2006-04-20 23:28:57 -07:00
@@ -820,3 +820,35 @@
2
2
DROP TABLE t1;
+CREATE TABLE t1 (a int, b int);
+INSERT INTO t1 VALUES (1,30), (2,20), (1,10), (2,30), (1,20), (2,10);
+(SELECT b,a FROM t1 ORDER BY a,b) ORDER BY b,a;
+b a
+10 1
+10 2
+20 1
+20 2
+30 1
+30 2
+(SELECT b FROM t1 ORDER BY b DESC) ORDER BY b ASC;
+b
+10
+10
+20
+20
+30
+30
+(SELECT b,a FROM t1 ORDER BY b,a) ORDER BY a,b;
+b a
+10 1
+20 1
+30 1
+10 2
+20 2
+30 2
+(SELECT b,a FROM t1 ORDER by b,a LIMIT 3) ORDER by a,b;
+b a
+10 1
+20 1
+10 2
+DROP TABLE t1;
--- 1.35/mysql-test/t/order_by.test 2005-08-23 08:08:01 -07:00
+++ 1.36/mysql-test/t/order_by.test 2006-04-21 00:36:14 -07:00
@@ -563,4 +563,18 @@
(SELECT a FROM t1) ORDER BY a;
DROP TABLE t1;
+#
+# Bug #18767: global ORDER BY applied to a SELECT with ORDER BY either was
+# ignored or 'concatened' to the latter.
+
+CREATE TABLE t1 (a int, b int);
+INSERT INTO t1 VALUES (1,30), (2,20), (1,10), (2,30), (1,20), (2,10);
+
+(SELECT b,a FROM t1 ORDER BY a,b) ORDER BY b,a;
+(SELECT b FROM t1 ORDER BY b DESC) ORDER BY b ASC;
+(SELECT b,a FROM t1 ORDER BY b,a) ORDER BY a,b;
+(SELECT b,a FROM t1 ORDER by b,a LIMIT 3) ORDER by a,b;
+
+DROP TABLE t1;
+
# End of 4.1 tests
--- 1.43/mysql-test/t/func_gconcat.test 2006-04-20 02:33:03 -07:00
+++ 1.44/mysql-test/t/func_gconcat.test 2006-04-21 00:36:14 -07:00
@@ -398,6 +398,16 @@
select count(distinct (f1+1)) from t1 group by f1 with rollup;
drop table t1;
+#
+# Bug#14169 type of group_concat() result changed to blob if tmp_table was used
+#
+create table t1 (f1 int unsigned, f2 varchar(255));
+insert into t1 values (1,repeat('a',255)),(2,repeat('b',255));
+--enable_metadata
+select f2,group_concat(f1) from t1 group by f2;
+--disable_metadata
+drop table t1;
+
# End of 4.1 tests
#
| Thread |
|---|
| • bk commit into 5.0 tree (igor:1.2093) | igor | 21 Apr |