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

--no commit message

--no commit message
上级 8f83bfd0
......@@ -1718,7 +1718,13 @@ public class Parser {
r = new Aggregate(database, Aggregate.COUNT_ALL, null, currentSelect, false);
} else {
boolean distinct = readIf("DISTINCT");
r = new Aggregate(database, Aggregate.COUNT, readExpression(), currentSelect, distinct);
Expression on = readExpression();
if (on instanceof Wildcard && !distinct) {
// PostgreSQL compatibility: count(t.*)
r = new Aggregate(database, Aggregate.COUNT_ALL, null, currentSelect, false);
} else {
r = new Aggregate(database, Aggregate.COUNT, on, currentSelect, distinct);
}
}
} else if (aggregateType == Aggregate.GROUP_CONCAT) {
boolean distinct = readIf("DISTINCT");
......
......@@ -11,6 +11,7 @@ import org.h2.engine.Session;
import org.h2.message.Message;
import org.h2.table.ColumnResolver;
import org.h2.table.TableFilter;
import org.h2.util.StringUtils;
import org.h2.value.Value;
/**
......@@ -76,7 +77,11 @@ public class Wildcard extends Expression {
}
public String getSQL() {
throw Message.getInternalError();
if (table == null) {
return "*";
} else {
return StringUtils.quoteIdentifier(table) + ".*";
}
}
public void updateAggregate(Session session) {
......
select count(d.*) from dual d group by d.x;
> 1;
create table test(id int);
select count(*) from (select * from ((select * from test) union (select * from test)) a) b where id = 0;
> 0;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论