Skip to content

Commit e9b731c

Browse files
authored
Merge pull request #3895 from manticoresoftware/having_tests
Added tests for PR #3792 and #3828
2 parents e4afc8b + 954505f commit e9b731c

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

test/test_475/model.bin

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
a:1:{i:0;a:10:{i:0;a:2:{s:8:"sphinxql";s:31:"CREATE TABLE t (grp INT, v INT)";s:14:"total_affected";i:0;}i:1;a:2:{s:8:"sphinxql";s:65:"INSERT INTO t VALUES (1,1,10),(2,1,20),(3,2,5),(4,2,5),(5,3,100)";s:14:"total_affected";i:5;}i:2;a:3:{s:8:"sphinxql";s:43:"SELECT grp, SUM(v) AS s FROM t GROUP BY grp";s:10:"total_rows";i:3;s:4:"rows";a:3:{i:0;a:2:{s:3:"grp";s:1:"1";s:1:"s";s:2:"30";}i:1;a:2:{s:3:"grp";s:1:"2";s:1:"s";s:2:"10";}i:2;a:2:{s:3:"grp";s:1:"3";s:1:"s";s:3:"100";}}}i:3;a:3:{s:8:"sphinxql";s:57:"SELECT grp, SUM(v) AS s FROM t GROUP BY grp HAVING s > 20";s:10:"total_rows";i:2;s:4:"rows";a:2:{i:0;a:2:{s:3:"grp";s:1:"1";s:1:"s";s:2:"30";}i:1;a:2:{s:3:"grp";s:1:"3";s:1:"s";s:3:"100";}}}i:4;a:3:{s:8:"sphinxql";s:9:"SHOW META";s:10:"total_rows";i:4;s:4:"rows";a:3:{i:0;a:2:{s:13:"Variable_name";s:5:"total";s:5:"Value";s:1:"2";}i:1;a:2:{s:13:"Variable_name";s:11:"total_found";s:5:"Value";s:1:"2";}i:2;a:2:{s:13:"Variable_name";s:14:"total_relation";s:5:"Value";s:2:"eq";}}}i:5;a:2:{s:8:"sphinxql";s:12:"DROP TABLE t";s:14:"total_affected";i:0;}i:6;a:2:{s:8:"sphinxql";s:28:"create table t(a int, b int)";s:14:"total_affected";i:0;}i:7;a:2:{s:8:"sphinxql";s:27:"insert into t values(0,1,2)";s:14:"total_affected";i:1;}i:8;a:3:{s:8:"sphinxql";s:73:"select a, count(*) from t where a=1 or b=2 group by a having count(*) = 1";s:10:"total_rows";i:1;s:4:"rows";a:1:{i:0;a:2:{s:1:"a";s:1:"1";s:8:"count(*)";s:1:"1";}}}i:9;a:2:{s:8:"sphinxql";s:12:"drop table t";s:14:"total_affected";i:0;}}}

test/test_475/test.xml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<test>
3+
4+
<name>HAVING vs total_found</name>
5+
6+
<requires>
7+
<force-rt/>
8+
</requires>
9+
10+
<skip_indexer/>
11+
12+
<config>
13+
searchd
14+
{
15+
<searchd_Settings/>
16+
data_dir = <data_path path="data0"/>
17+
}
18+
</config>
19+
20+
<queries>
21+
<sphinxql>
22+
CREATE TABLE t (grp INT, v INT);
23+
INSERT INTO t VALUES (1,1,10),(2,1,20),(3,2,5),(4,2,5),(5,3,100);
24+
SELECT grp, SUM(v) AS s FROM t GROUP BY grp;
25+
SELECT grp, SUM(v) AS s FROM t GROUP BY grp HAVING s > 20;
26+
SHOW META;
27+
DROP TABLE t;
28+
29+
<!-- regression for 'filter with empty name' -->
30+
create table t(a int, b int);
31+
insert into t values(0,1,2);
32+
select a, count(*) from t where a=1 or b=2 group by a having count(*) = 1;
33+
drop table t;
34+
</sphinxql>
35+
</queries>
36+
37+
</test>

0 commit comments

Comments
 (0)