Changeset: 3d5b55f4aebd for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3d5b55f4aebd Modified Files: sql/src/server/rel_optimizer.mx sql/src/server/rel_select.mx sql/src/server/sql_parser.mx sql/src/test/BugTracker-2010/Tests/ORDER_BY_over_UNION_EXCEPT_INTERSECT.Bug-2606.stable.out sql/src/test/BugTracker-2010/Tests/connectto.Bug-2548.stable.err Branch: Jun2010 Log Message:
Automaticaly add select * around select x union select y order by xx, solves ORdER BY over UNION etc. diffs (157 lines): diff -r a8356722170d -r 3d5b55f4aebd sql/src/server/rel_optimizer.mx --- a/sql/src/server/rel_optimizer.mx Thu Jul 29 14:47:57 2010 +0200 +++ b/sql/src/server/rel_optimizer.mx Thu Jul 29 23:11:41 2010 +0200 @@ -1141,7 +1141,7 @@ sql_exp *e = n->data; /* aggr func in project ! */ - if (e->type == e_func && e->card == 1) + if (e->type == e_func && e->card == CARD_AGGR) return 1; } return 0; diff -r a8356722170d -r 3d5b55f4aebd sql/src/server/rel_select.mx --- a/sql/src/server/rel_select.mx Thu Jul 29 14:47:57 2010 +0200 +++ b/sql/src/server/rel_select.mx Thu Jul 29 23:11:41 2010 +0200 @@ -1500,8 +1500,10 @@ sql_exp *e = m->data; exp_setname(e, tname, c->base.name); +/* if (e->card == CARD_AGGR) e->card = CARD_MULTI; +*/ } } return rel; diff -r a8356722170d -r 3d5b55f4aebd sql/src/server/sql_parser.mx --- a/sql/src/server/sql_parser.mx Thu Jul 29 14:47:57 2010 +0200 +++ b/sql/src/server/sql_parser.mx Thu Jul 29 23:11:41 2010 +0200 @@ -2927,11 +2927,18 @@ $1->token == SQL_UNION || $1->token == SQL_EXCEPT || $1->token == SQL_INTERSECT)) { - SelectNode *s = (SelectNode*)$1; + if ($1->token == SQL_SELECT) { + SelectNode *s = (SelectNode*)$1; - s -> orderby = $2; - s -> limit = $3; - s -> offset = $4; + s -> orderby = $2; + s -> limit = $3; + s -> offset = $4; + } else { /* Add extra select * from .. in case of UNION, EXCEPT, INTERSECT */ + $$ = newSelectNode( + SA, 0, + append_symbol(L(), _symbol_create_list(SQL_TABLE, append_string(append_string(L(),NULL),NULL))), NULL, + _symbol_create_list( SQL_FROM, append_symbol(L(), $1)), NULL, NULL, NULL, $2, _symbol_create_list(SQL_NAME, append_list(append_string(L(),"inner"),NULL)), $3, $4); + } } else { yyerror("ORDER BY: missing select operator"); YYABORT; diff -r a8356722170d -r 3d5b55f4aebd sql/src/test/BugTracker-2010/Tests/ORDER_BY_over_UNION_EXCEPT_INTERSECT.Bug-2606.stable.out --- a/sql/src/test/BugTracker-2010/Tests/ORDER_BY_over_UNION_EXCEPT_INTERSECT.Bug-2606.stable.out Thu Jul 29 14:47:57 2010 +0200 +++ b/sql/src/test/BugTracker-2010/Tests/ORDER_BY_over_UNION_EXCEPT_INTERSECT.Bug-2606.stable.out Thu Jul 29 23:11:41 2010 +0200 @@ -62,7 +62,7 @@ % .plan # table_name % rel # name % clob # type -% 56 # length +% 58 # length project ( | distinct union ( | | distinct project ( @@ -91,7 +91,7 @@ % .plan # table_name % rel # name % clob # type -% 56 # length +% 58 # length project ( | distinct union ( | | distinct project ( @@ -120,7 +120,7 @@ % .plan # table_name % rel # name % clob # type -% 56 # length +% 58 # length project ( | distinct union ( | | distinct project ( @@ -149,7 +149,7 @@ % .plan # table_name % rel # name % clob # type -% 56 # length +% 58 # length project ( | except ( | | distinct project ( @@ -172,7 +172,7 @@ % .plan # table_name % rel # name % clob # type -% 56 # length +% 58 # length project ( | except ( | | distinct project ( @@ -195,7 +195,7 @@ % .plan # table_name % rel # name % clob # type -% 56 # length +% 58 # length project ( | except ( | | distinct project ( @@ -218,7 +218,7 @@ % .plan # table_name % rel # name % clob # type -% 56 # length +% 58 # length project ( | intersect ( | | distinct project ( @@ -241,7 +241,7 @@ % .plan # table_name % rel # name % clob # type -% 56 # length +% 58 # length project ( | intersect ( | | distinct project ( @@ -264,7 +264,7 @@ % .plan # table_name % rel # name % clob # type -% 56 # length +% 58 # length project ( | intersect ( | | distinct project ( diff -r a8356722170d -r 3d5b55f4aebd sql/src/test/BugTracker-2010/Tests/connectto.Bug-2548.stable.err --- a/sql/src/test/BugTracker-2010/Tests/connectto.Bug-2548.stable.err Thu Jul 29 14:47:57 2010 +0200 +++ b/sql/src/test/BugTracker-2010/Tests/connectto.Bug-2548.stable.err Thu Jul 29 23:11:41 2010 +0200 @@ -71,13 +71,13 @@ # 13:12:55 > mclient -lsql -ftest -i -e --host=rig --port=39884 # 13:12:55 > -MAPI = mone...@alviss:31044 +MAPI = mone...@alf:30038 QUERY = connect to default; ERROR = !CONNECT TO: DEFAULT is not supported! -MAPI = mone...@alviss:31044 +MAPI = mone...@alf:30038 QUERY = connect to 'whatever' port 50001 database 'nonexisting' USER 'monetdb' PASSWORD 'monetdb' LANGUAGE 'mal'; -ERROR = !IOException:mapi.connect:Could not connect: getaddrinfo failed: Name or service not known -MAPI = mone...@alviss:31044 +ERROR = !IOException:mapi.connect:Could not connect: gethostbyname failed: Unknown host +MAPI = mone...@alf:30038 QUERY = disconnect 'whatever'; ERROR = !DISCONNECT CATALOG: no such db_alias 'whatever' _______________________________________________ Checkin-list mailing list Checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list