Skip to content

Commit 5ea214b

Browse files
committed
It seems some case-insensitive locales sort upper case before lower
(BBBB before bbbb) and others the other way around. Provide comparison files that cater to both approaches.
1 parent 157e17e commit 5ea214b

File tree

3 files changed

+381
-5
lines changed

3 files changed

+381
-5
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
--
2+
-- SELECT_HAVING
3+
--
4+
-- load test data
5+
CREATE TABLE test_having (a int, b int, c char(8), d char);
6+
INSERT INTO test_having VALUES (0, 1, 'XXXX', 'A');
7+
INSERT INTO test_having VALUES (1, 2, 'AAAA', 'b');
8+
INSERT INTO test_having VALUES (2, 2, 'AAAA', 'c');
9+
INSERT INTO test_having VALUES (3, 3, 'BBBB', 'D');
10+
INSERT INTO test_having VALUES (4, 3, 'BBBB', 'e');
11+
INSERT INTO test_having VALUES (5, 3, 'bbbb', 'F');
12+
INSERT INTO test_having VALUES (6, 4, 'cccc', 'g');
13+
INSERT INTO test_having VALUES (7, 4, 'cccc', 'h');
14+
INSERT INTO test_having VALUES (8, 4, 'CCCC', 'I');
15+
INSERT INTO test_having VALUES (9, 4, 'CCCC', 'j');
16+
SELECT b, c FROM test_having
17+
GROUP BY b, c HAVING count(*) = 1 ORDER BY b, c;
18+
b | c
19+
---+----------
20+
1 | XXXX
21+
3 | bbbb
22+
(2 rows)
23+
24+
-- HAVING is equivalent to WHERE in this case
25+
SELECT b, c FROM test_having
26+
GROUP BY b, c HAVING b = 3 ORDER BY b, c;
27+
b | c
28+
---+----------
29+
3 | bbbb
30+
3 | BBBB
31+
(2 rows)
32+
33+
SELECT lower(c), count(c) FROM test_having
34+
GROUP BY lower(c) HAVING count(*) > 2 OR min(a) = max(a)
35+
ORDER BY lower(c);
36+
lower | count
37+
-------+-------
38+
bbbb | 3
39+
cccc | 4
40+
xxxx | 1
41+
(3 rows)
42+
43+
SELECT c, max(a) FROM test_having
44+
GROUP BY c HAVING count(*) > 2 OR min(a) = max(a)
45+
ORDER BY c;
46+
c | max
47+
----------+-----
48+
bbbb | 5
49+
XXXX | 0
50+
(2 rows)
51+
52+
DROP TABLE test_having;

src/test/regress/expected/select_implicit_1.out

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ SELECT c, count(*) FROM test_missing_target GROUP BY test_missing_target.c ORDER
2222
c | count
2323
----------+-------
2424
AAAA | 2
25-
bbbb | 1
2625
BBBB | 2
27-
cccc | 2
26+
bbbb | 1
2827
CCCC | 2
28+
cccc | 2
2929
XXXX | 1
3030
(6 rows)
3131

@@ -34,8 +34,8 @@ SELECT count(*) FROM test_missing_target GROUP BY test_missing_target.c ORDER BY
3434
count
3535
-------
3636
2
37-
1
3837
2
38+
1
3939
2
4040
2
4141
1
@@ -104,10 +104,10 @@ SELECT c, count(*) FROM test_missing_target GROUP BY 1 ORDER BY 1;
104104
c | count
105105
----------+-------
106106
AAAA | 2
107-
bbbb | 1
108107
BBBB | 2
109-
cccc | 2
108+
bbbb | 1
110109
CCCC | 2
110+
cccc | 2
111111
XXXX | 1
112112
(6 rows)
113113

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy