Update of /cvsroot/monetdb/sql/src/test/bugs/Tests
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv5915/src/test/bugs/Tests

Added Files:
        rangejoin_optimize_bug.sql 
Log Message:
propagated changes of Thursday Jul 10 2008 - Monday Jul 14 2008
from the SQL_2-24 branch to the development trunk

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2008/07/10 - nielsnes: src/test/bugs/Tests/rangejoin_optimize_bug.sql,1.1.2.1
test for a bug in the rangejoin 2 select rewriting.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


--- NEW FILE: rangejoin_optimize_bug.sql ---
create table inputStat ( "type" int, "time" int, "carid" int, "speed" int, 
"xway" int, "lane" int, "dir" int, "seg" int, "pos" int, "qid" int, "m_init" 
int, "m_end" int, "dow" int, "tod" int, "day2" int);

COPY 89 RECORDS INTO inputStat from STDIN USING DELIMITERS ',','\n';
0,0,110,27,0,0,1,11,62914,-1,-1,-1,-1,-1,-1
0,0,119,23,0,0,1,5,31306,-1,-1,-1,-1,-1,-1
0,1,123,23,0,0,1,87,464260,-1,-1,-1,-1,-1,-1
0,1,127,25,0,0,1,27,147439,-1,-1,-1,-1,-1,-1
0,2,132,28,0,0,1,37,200156,-1,-1,-1,-1,-1,-1
0,2,141,34,0,0,1,30,163105,-1,-1,-1,-1,-1,-1
0,3,157,18,0,0,1,92,490761,-1,-1,-1,-1,-1,-1
0,3,151,26,0,0,1,88,469480,-1,-1,-1,-1,-1,-1
4,3,151,-1,0,-1,-1,-1,-1,0,0,0,0,0,-1
0,3,124,21,0,0,1,87,464282,-1,-1,-1,-1,-1,-1
0,3,158,32,0,0,1,80,427144,-1,-1,-1,-1,-1,-1
0,3,154,20,0,0,1,77,411507,-1,-1,-1,-1,-1,-1
0,3,150,29,0,0,1,76,406064,-1,-1,-1,-1,-1,-1
0,3,156,32,0,0,1,75,400745,-1,-1,-1,-1,-1,-1
0,3,153,26,0,0,1,44,237160,-1,-1,-1,-1,-1,-1
0,4,177,29,0,0,1,89,474718,-1,-1,-1,-1,-1,-1
0,4,176,23,0,0,1,88,469539,-1,-1,-1,-1,-1,-1
0,5,182,28,0,0,1,96,511676,-1,-1,-1,-1,-1,-1
0,5,186,27,0,0,1,32,173782,-1,-1,-1,-1,-1,-1
0,6,187,20,0,0,1,96,511828,-1,-1,-1,-1,-1,-1
0,6,208,34,0,0,1,56,300401,-1,-1,-1,-1,-1,-1
0,6,199,20,0,0,1,47,253105,-1,-1,-1,-1,-1,-1
0,7,198,18,0,0,1,92,490737,-1,-1,-1,-1,-1,-1
0,7,227,20,0,0,1,88,469594,-1,-1,-1,-1,-1,-1
0,7,212,27,0,0,1,80,427233,-1,-1,-1,-1,-1,-1
0,7,214,23,0,0,1,72,385056,-1,-1,-1,-1,-1,-1
0,8,238,32,0,0,1,99,527464,-1,-1,-1,-1,-1,-1
0,8,235,32,0,0,1,97,516895,-1,-1,-1,-1,-1,-1
0,8,249,20,0,0,1,96,511849,-1,-1,-1,-1,-1,-1
0,8,223,17,0,0,1,92,490766,-1,-1,-1,-1,-1,-1
0,8,241,27,0,0,1,83,443077,-1,-1,-1,-1,-1,-1
0,8,219,23,0,0,1,80,427305,-1,-1,-1,-1,-1,-1
0,8,247,20,0,0,1,76,406244,-1,-1,-1,-1,-1,-1
0,8,243,22,0,0,1,72,385093,-1,-1,-1,-1,-1,-1
0,8,237,30,0,0,1,69,369089,-1,-1,-1,-1,-1,-1
0,8,240,23,0,0,1,60,321704,-1,-1,-1,-1,-1,-1
0,8,216,18,0,0,1,47,253139,-1,-1,-1,-1,-1,-1
0,8,239,34,0,0,1,26,141985,-1,-1,-1,-1,-1,-1
2,8,239,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1
0,8,232,20,0,0,1,19,105258,-1,-1,-1,-1,-1,-1
0,9,252,32,0,0,1,97,516902,-1,-1,-1,-1,-1,-1
0,9,257,27,0,0,1,94,501160,-1,-1,-1,-1,-1,-1
0,9,230,19,0,0,1,88,469614,-1,-1,-1,-1,-1,-1
0,9,256,21,0,0,1,87,464302,-1,-1,-1,-1,-1,-1
0,9,242,23,0,0,1,69,369231,-1,-1,-1,-1,-1,-1
0,9,251,27,0,0,1,68,363863,-1,-1,-1,-1,-1,-1
0,10,255,19,0,0,1,88,469616,-1,-1,-1,-1,-1,-1
0,10,264,28,0,0,1,86,458902,-1,-1,-1,-1,-1,-1
0,10,258,27,0,0,1,83,443065,-1,-1,-1,-1,-1,-1
0,10,260,22,0,0,1,80,427303,-1,-1,-1,-1,-1,-1
0,10,246,22,0,0,1,60,321707,-1,-1,-1,-1,-1,-1
0,10,265,26,0,0,1,31,168538,-1,-1,-1,-1,-1,-1
0,10,266,26,0,0,1,11,62944,-1,-1,-1,-1,-1,-1
0,11,278,21,0,0,1,96,511825,-1,-1,-1,-1,-1,-1
0,11,271,24,0,0,1,83,443124,-1,-1,-1,-1,-1,-1
0,11,267,32,0,0,1,40,215929,-1,-1,-1,-1,-1,-1
0,11,273,28,0,0,1,39,210729,-1,-1,-1,-1,-1,-1
2,12,280,-1,-1,-1,-1,-1,-1,2,-1,-1,-1,-1,-1
0,12,287,20,0,0,1,99,527668,-1,-1,-1,-1,-1,-1
0,12,284,29,0,0,1,70,374397,-1,-1,-1,-1,-1,-1
0,12,279,30,0,0,1,66,353234,-1,-1,-1,-1,-1,-1
0,12,286,26,0,0,1,58,311075,-1,-1,-1,-1,-1,-1
0,12,283,25,0,0,1,56,300543,-1,-1,-1,-1,-1,-1
0,12,282,34,0,0,1,55,295097,-1,-1,-1,-1,-1,-1
0,13,303,30,0,0,1,95,506383,-1,-1,-1,-1,-1,-1
0,13,298,29,0,0,1,91,485268,-1,-1,-1,-1,-1,-1
0,13,304,25,0,0,1,78,416720,-1,-1,-1,-1,-1,-1
0,13,306,20,0,0,1,56,300641,-1,-1,-1,-1,-1,-1
0,13,294,30,0,0,1,42,226516,-1,-1,-1,-1,-1,-1
0,13,295,32,0,0,1,36,194810,-1,-1,-1,-1,-1,-1
0,13,307,33,0,0,1,32,173703,-1,-1,-1,-1,-1,-1
0,13,302,34,0,0,1,25,136705,-1,-1,-1,-1,-1,-1
0,14,312,18,0,0,1,96,511855,-1,-1,-1,-1,-1,-1
0,14,313,20,0,0,1,95,506554,-1,-1,-1,-1,-1,-1
0,14,316,27,0,0,1,74,395560,-1,-1,-1,-1,-1,-1
0,14,309,25,0,0,1,12,68217,-1,-1,-1,-1,-1,-1
0,15,336,24,0,0,1,99,527622,-1,-1,-1,-1,-1,-1
0,15,332,19,0,0,1,96,511860,-1,-1,-1,-1,-1,-1
0,15,334,27,0,0,1,82,437807,-1,-1,-1,-1,-1,-1
0,15,326,20,0,0,1,80,427347,-1,-1,-1,-1,-1,-1
0,15,330,25,0,0,1,79,421994,-1,-1,-1,-1,-1,-1
0,15,322,30,0,0,1,71,379635,-1,-1,-1,-1,-1,-1
0,15,331,30,0,0,1,26,142070,-1,-1,-1,-1,-1,-1
0,16,344,25,0,0,1,98,522313,-1,-1,-1,-1,-1,-1
0,16,338,24,0,0,1,78,416715,-1,-1,-1,-1,-1,-1
0,16,345,29,0,0,1,70,374405,-1,-1,-1,-1,-1,-1
0,16,337,25,0,0,1,58,311088,-1,-1,-1,-1,-1,-1
0,16,339,27,0,0,1,57,305782,-1,-1,-1,-1,-1,-1
0,16,340,27,0,0,1,44,237142,-1,-1,-1,-1,-1,-1

CREATE TABLE statistics(dir  int,seg  int,time_minute int,numvehicles int,lav   
float,toll  int,accident int,accidentSeg int);

INSERT INTO  statistics 
(dir,seg,time_minute,numvehicles,lav,toll,accident,accidentSeg) Select dir, 
seg, tme+1, null,null,null,null,null from (select dir as dir , seg as seg, 
(time/60) as tme from inputStat where type = 0) AS tmpT Group by dir,seg,tme;

select count(*) from statistics;
select count(*) from statistics where lav is null;

CREATE TABLE preLav( dir  int,seg  int,time_minute3 int,lav  float);

INSERT INTO prelav(dir, seg, time_minute3, lav )
SELECT dir, seg,  tme, speed
FROM  ( SELECT dir, seg,  tme, avg(speed) as speed
        FROM (  SELECT dir,seg,carid,tme,avg(speed) as speed
FROM    (SELECT  dir AS dir, seg AS seg, carid as carid, (time/60)+1 AS tme,  
speed AS speed FROM inputStat WHERE type=0) AS temp_A
                GROUP BY dir,seg,carid,tme ) AS temp_B
        GROUP BY dir,seg,tme) AS temp_C;

UPDATE statistics SET lav = (SELECT floor(avg(prelav.lav)) FROM   prelav WHERE  
statistics.dir = prelav.dir AND statistics.seg = prelav.seg AND 
prelav.time_minute3 <= statistics.time_minute - 1);

select count(*) from statistics where lav is null;

UPDATE statistics SET lav = (SELECT floor(avg(prelav.lav)) FROM   prelav WHERE  
statistics.dir = prelav.dir AND statistics.seg = prelav.seg AND 
prelav.time_minute3  >= statistics.time_minute - 5);

select count(*) from statistics where lav is null;

UPDATE statistics SET lav = (SELECT floor(avg(prelav.lav)) FROM   prelav WHERE  
statistics.dir = prelav.dir AND statistics.seg = prelav.seg AND 
prelav.time_minute3 <= statistics.time_minute - 1 AND prelav.time_minute3 >= 
statistics.time_minute - 5);

select count(*) from statistics;
select count(*) from statistics where lav is null;

drop table inputStat;
drop table statistics;
drop table preLav;


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to