提交 01744231 authored 作者: Thomas Mueller's avatar Thomas Mueller

In version 1.4.184, "group by" ignored the table name, and could pick a select…

In version 1.4.184, "group by" ignored the table name, and could pick a select column by mistake. Example: select 0 as x from system_range(1, 2) d group by d.x;
上级 2fd7815c
...@@ -17,7 +17,10 @@ Change Log ...@@ -17,7 +17,10 @@ Change Log
<h1>Change Log</h1> <h1>Change Log</h1>
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul><li>New connection setting "REUSE_SPACE" (default: true). If disabled, <ul><li>In version 1.4.184, "group by" ignored the table name,
and could pick a select column by mistake.
Example: select 0 as x from system_range(1, 2) d group by d.x;
</li><li>New connection setting "REUSE_SPACE" (default: true). If disabled,
all changes are appended to the database file, and existing content is never overwritten. all changes are appended to the database file, and existing content is never overwritten.
This allows to rollback to a previous state of the database by truncating This allows to rollback to a previous state of the database by truncating
the database file. the database file.
...@@ -28,7 +31,7 @@ Change Log ...@@ -28,7 +31,7 @@ Change Log
</li><li>Fix bug in PageStore#commit method - when the ignoreBigLog flag was set, </li><li>Fix bug in PageStore#commit method - when the ignoreBigLog flag was set,
the logic that cleared the flag could never be reached, resulting in performance degradation. the logic that cleared the flag could never be reached, resulting in performance degradation.
Reported by Alexander Nesterov. Reported by Alexander Nesterov.
</li><li>Issue 552: Implement BIT_AND and BIT_OR aggregate functions </li><li>Issue 552: Implement BIT_AND and BIT_OR aggregate functions.
</li></ul> </li></ul>
<h2>Version 1.4.184 Beta (2014-12-19)</h2> <h2>Version 1.4.184 Beta (2014-12-19)</h2>
......
...@@ -249,7 +249,13 @@ public class ExpressionColumn extends Expression { ...@@ -249,7 +249,13 @@ public class ExpressionColumn extends Expression {
@Override @Override
public String getAlias() { public String getAlias() {
return column == null ? columnName : column.getName(); if (column != null) {
return column.getName();
}
if (tableAlias != null) {
return tableAlias + "." + columnName;
}
return columnName;
} }
@Override @Override
......
...@@ -3,6 +3,13 @@ ...@@ -3,6 +3,13 @@
-- Initial Developer: H2 Group -- Initial Developer: H2 Group
-- --
--- special grammar and test cases --------------------------------------------------------------------------------------------- --- special grammar and test cases ---------------------------------------------------------------------------------------------
select 0 as x from system_range(1, 2) d group by d.x;
> X
> -
> 0
> 0
> rows: 2
select 1 "a", count(*) from dual group by "a" order by "a"; select 1 "a", count(*) from dual group by "a" order by "a";
> a COUNT(*) > a COUNT(*)
> - -------- > - --------
...@@ -6418,8 +6425,8 @@ EXPLAIN SELECT * FROM TEST WHERE (ID>=1 AND ID<=2) OR (ID>0 AND ID<3) AND (ID<> ...@@ -6418,8 +6425,8 @@ EXPLAIN SELECT * FROM TEST WHERE (ID>=1 AND ID<=2) OR (ID>0 AND ID<3) AND (ID<>
EXPLAIN SELECT * FROM TEST WHERE ID=1 GROUP BY NAME, ID; EXPLAIN SELECT * FROM TEST WHERE ID=1 GROUP BY NAME, ID;
> PLAN > PLAN
> ---------------------------------------------------------------------------------------------------------------------- > ------------------------------------------------------------------------------------------------------------
> SELECT TEST.ID, TEST.NAME FROM PUBLIC.TEST /* PUBLIC.PRIMARY_KEY_2: ID = 1 */ WHERE ID = 1 GROUP BY TEST.NAME, TEST.ID > SELECT TEST.ID, TEST.NAME FROM PUBLIC.TEST /* PUBLIC.PRIMARY_KEY_2: ID = 1 */ WHERE ID = 1 GROUP BY NAME, ID
> rows: 1 > rows: 1
EXPLAIN PLAN FOR UPDATE TEST SET NAME='Hello', ID=1 WHERE NAME LIKE 'T%' ESCAPE 'x'; EXPLAIN PLAN FOR UPDATE TEST SET NAME='Hello', ID=1 WHERE NAME LIKE 'T%' ESCAPE 'x';
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论