提交 5d7da357 authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 e2304cb7
......@@ -39,8 +39,10 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch.
<h3>Version 1.0 (Current)</h3>
<h3>Version 1.0.58 (2007-09-15)</h3><ul>
<li>Views with subqueries as tables and queries with nested subqueries as tables did not always work. Fixed.
<h3>Version 1.0.59 (2007-09-TODO)</h3><ul>
<li>When using a subquery with group by as a table, some columns could not be used in the where condition
in the outer query. Example: SELECT * FROM (SELECT ID, COUNT(*) C FROM TEST) WHERE C > 100. Fixed.
</li><li>Views with subqueries as tables and queries with nested subqueries as tables did not always work. Fixed.
</li><li>Compatibility: comparing columns with constants that are out of range does not throw an exception.
</li></ul>
......
......@@ -701,6 +701,7 @@ public class Select extends Query {
comp = comp.optimize(session);
boolean addToCondition = true;
if (isGroupQuery) {
addToCondition = false;
for (int i = 0; groupIndex != null && i < groupIndex.length; i++) {
if (groupIndex[i] == columnId) {
addToCondition = true;
......
......@@ -153,6 +153,10 @@ public class ViewIndex extends BaseIndex {
if (first != null) {
Value v = first.getValue(i);
if (v != null) {
if(paramList.size() <= idx) {
int tst;
System.out.println("stop!");
}
Parameter param = (Parameter) paramList.get(idx++);
param.setValue(v);
}
......
......@@ -112,7 +112,7 @@ public class ValueTimestamp extends Value {
// }
public int getDisplaySize() {
return "2001-01-01 23:59:59".length();
return "2001-01-01 23:59:59.000".length();
}
protected boolean isEqual(Value v) {
......
......@@ -143,6 +143,85 @@ java org.h2.test.TestAll timer
/*
DROP TABLE IF EXISTS TEST;
CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255));
INSERT INTO TEST VALUES(1, 'Hello');
INSERT INTO TEST VALUES(2, 'HelloHello');
SELECT * FROM TEST WHERE NAME REGEXP 'He';
java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:841)
at java.util.HashMap$ValueIterator.next(HashMap.java:871)
at java.util.AbstractCollection.toArray(AbstractCollection.java:176)
at org.h2.util.FileUtils.listFiles(FileUtils.java:395)
at org.h2.engine.Database.deleteOldTempFiles(Database.java:1055)
at org.h2.engine.Database.closeOpenFilesAndUnlock(Database.java:853)
at org.h2.engine.Database.close(Database.java:814)
at org.h2.engine.Database.removeSession(Database.java:755)
at org.h2.engine.Session.close(Session.java:260)
at org.h2.engine.Database.close(Database.java:783)
SCRIPT: append ; also in result set (copy paste problem)
java org.h2.tools.RunScript -url jdbc:h2:file:bug -user SA -script \temp\test\data.sql
data.sql, test.java
I have a big problem with PreparedStatements and version 2007-07-12 or above.
With 2007-04-29 or lower it works as expected.
In the test query i use a UNION ALL (i know, not well tested), but also with a simple SELECT/UPDATE/INSERT prepared statement with a where clause and parameters the problem happens, if i run the query more than once with different parameters. It always returns the result from the first executeQuery() or updates the rows return from the first query.
But the funny thing is, i cannot reproduce the bug with a simple SELECT in the test app.
If i run the test app, the output is with ver 2007-07-12:
Row Count 9
Sum 714.8621259
Row Count 9
Sum 714.8621259
Row Count 9
Sum 714.8621259
(looks like it takes every time the first result)
with ver 2007-04-29
Row Count 9
Sum 714.8621259
Row Count 7
Sum 0.0
Row Count 10
Sum 381.230477
drop table multi_pages;
drop table bib_holdings;
create table multi_pages(dir_num int, bh_id int);
insert into multi_pages values(1, 1);
insert into multi_pages values(2, 2);
insert into multi_pages values(3, 3);
create table bib_holdings(id int primary key, site varchar(255));
insert into bib_holdings values(1, 'WSTIAC');
insert into bib_holdings values(2, 'WSTIAC');
insert into bib_holdings values(3, 'WSTIAC');
select * from (select dir_num, count(*) as cnt
from multi_pages t, bib_holdings bh
where t.bh_id=bh.id and bh.site='WSTIAC' group by dir_num) as x
where cnt < 1000 order by dir_num asc;
explain select * from (select dir_num, count(*) as cnt
from multi_pages t, bib_holdings bh
where t.bh_id=bh.id and bh.site='WSTIAC' group by dir_num) as x
where cnt < 1000 order by dir_num asc;
select dir_num, count(*) as cnt
from multi_pages t, bib_holdings bh
where t.bh_id=bh.id and bh.site='WSTIAC'
group by dir_num
having count(*) < 1000
order by dir_num asc;
Sorry.... I just read the doc and it says using LOG=0 can lead to
corruption...
......
--- special grammar and test cases ---------------------------------------------------------------------------------------------
create table multi_pages(dir_num int, bh_id int);
> ok
insert into multi_pages values(1, 1), (2, 2), (3, 3);
> update count: 3
create table bib_holdings(id int primary key, site varchar(255));
> ok
insert into bib_holdings values(1, 'WSTIAC'), (2, 'WSTIAC'), (3, 'WSTIAC');
> update count: 3
select * from (select dir_num, count(*) as cnt from multi_pages t, bib_holdings bh
where t.bh_id=bh.id and bh.site='WSTIAC' group by dir_num) as x
where cnt < 1000 order by dir_num asc;
> DIR_NUM CNT
> ------- ---
> 1 1
> 2 1
> 3 1
> rows (ordered): 3
explain select * from (select dir_num, count(*) as cnt from multi_pages t, bib_holdings bh
where t.bh_id=bh.id and bh.site='WSTIAC' group by dir_num) as x
where cnt < 1000 order by dir_num asc;
> PLAN
> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> SELECT X.DIR_NUM, X.CNT FROM (select dir_num, count(*) as cnt from multi_pages t, bib_holdings bh where t.bh_id=bh.id and bh.site='WSTIAC' group by dir_num) X /* SELECT DIR_NUM, COUNT(*) AS CNT FROM PUBLIC.MULTI_PAGES T /++ PUBLIC.MULTI_PAGES_TABLE_SCAN ++/ INNER JOIN PUBLIC.BIB_HOLDINGS BH /++ PUBLIC.PRIMARY_KEY_1: ID = T.BH_ID ++/ WHERE (BH.SITE = 'WSTIAC') AND (T.BH_ID = BH.ID) GROUP BY DIR_NUM HAVING COUNT(*) <= CAST(?1 AS BIGINT): CNT < 1000 */ WHERE CNT < 1000 ORDER BY 1
> rows (ordered): 1
select dir_num, count(*) as cnt from multi_pages t, bib_holdings bh
where t.bh_id=bh.id and bh.site='WSTIAC' group by dir_num
having count(*) < 1000 order by dir_num asc;
> DIR_NUM CNT
> ------- ---
> 1 1
> 2 1
> 3 1
> rows (ordered): 3
drop table multi_pages, bib_holdings;
> ok
select * from dual where x = 1000000000000000000000;
> X
> -
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论