Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5c4e5aa

Browse files
committed
Make regression tests locale-proof by setting some locale categories
to C at run-time, and providing alternative output files for differentsort orders.
1 parentcd61650 commit5c4e5aa

File tree

8 files changed

+1910
-25
lines changed

8 files changed

+1910
-25
lines changed

‎doc/src/sgml/regress.sgml

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/regress.sgml,v 1.26 2002/04/08 04:37:36 tgl Exp $ -->
1+
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/regress.sgml,v 1.27 2002/05/14 13:05:42 petere Exp $ -->
22

33
<chapter id="regress">
44
<title id="regress-title">Regression Tests</title>
@@ -177,22 +177,32 @@
177177
<title>Locale differences</title>
178178

179179
<para>
180-
The tests expect to run in plain <quote>C</quote> locale. This
181-
should not cause any problems when you run the tests against a
182-
temporary installation, since the regression test driver takes care
183-
to start the server in C locale. However, if you run the tests
184-
against an already-installed server that is using non-C locale settings,
185-
you may see differences caused by varying rules for string sort order,
186-
formatting of numeric and monetary values, and so forth.
180+
If you run the tests against an already-installed server that was
181+
initialized with a collation order locale different than C then
182+
there may be differences due to sort order and follow-up
183+
failures. The regression test suite is set up to handle this
184+
problem by providing alternative result files that together are
185+
known to handle a large number of locales. For example, for the
186+
<quote>char</quote> test, the expected file
187+
<filename>char.out</filename> handles the C and POSIX locales,
188+
and the file <filename>char_1.out</filename> handles many other
189+
locales. The regression test driver will automatically pick the
190+
best file to match against when checking for success and for
191+
computing failure differences. (This means that the regression
192+
tests cannot detect whether the results are appropriate for the
193+
configured locale. The tests will simply pick the one result
194+
file that works best.)
187195
</para>
188196

189197
<para>
190-
In some locales the resulting differences are small and easily checked by
191-
inspection. However, in a locale that changes the rules for formatting
192-
of numeric values (typically by swapping the usage of commas and
193-
decimal points), entry of some data values will fail, resulting in
194-
extensive differences later in the tests where the missing data values
195-
are supposed to be used.
198+
If for some reason the existing expected files do not cover some
199+
locale, you can add a new file. The naming scheme is
200+
<literal><replaceable>testname</>_<replaceable>digit</>.out</>.
201+
The actual digit is not significant. Remember that the
202+
regression test driver will consider all such files to be equally
203+
valid test results. If the test results are platform-dependent,
204+
the technique described in <xref linkend="regress-platform">
205+
should be used instead.
196206
</para>
197207
</sect2>
198208

‎src/backend/utils/misc/guc.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Support for grand unified configuration scheme, including SET
55
* command, configuration file, and command line options.
66
*
7-
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.66 2002/04/21 00:22:52 ishii Exp $
7+
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.67 2002/05/14 13:05:43 petere Exp $
88
*
99
* Copyright 2000 by PostgreSQL Global Development Group
1010
* Written by Peter Eisentraut <peter_e@gmx.net>.
@@ -587,22 +587,22 @@ static struct config_string
587587
},
588588

589589
{
590-
"lc_messages",PGC_POSTMASTER,PGC_S_DEFAULT,&locale_messages,
590+
"lc_messages",PGC_SUSET,PGC_S_DEFAULT,&locale_messages,
591591
"",locale_messages_check,locale_messages_assign
592592
},
593593

594594
{
595-
"lc_monetary",PGC_POSTMASTER,PGC_S_DEFAULT,&locale_monetary,
595+
"lc_monetary",PGC_USERSET,PGC_S_DEFAULT,&locale_monetary,
596596
"",locale_monetary_check,locale_monetary_assign
597597
},
598598

599599
{
600-
"lc_numeric",PGC_POSTMASTER,PGC_S_DEFAULT,&locale_numeric,
600+
"lc_numeric",PGC_USERSET,PGC_S_DEFAULT,&locale_numeric,
601601
"",locale_numeric_check,locale_numeric_assign
602602
},
603603

604604
{
605-
"lc_time",PGC_POSTMASTER,PGC_S_DEFAULT,&locale_time,
605+
"lc_time",PGC_USERSET,PGC_S_DEFAULT,&locale_time,
606606
"",locale_time_check,locale_time_assign
607607
},
608608

‎src/test/regress/expected/char_1.out

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
--
2+
-- CHAR
3+
--
4+
-- fixed-length by value
5+
-- internally passed by value if <= 4 bytes in storage
6+
SELECT char 'c' = char 'c' AS true;
7+
true
8+
------
9+
t
10+
(1 row)
11+
12+
--
13+
-- Build a table for testing
14+
--
15+
CREATE TABLE CHAR_TBL(f1 char);
16+
INSERT INTO CHAR_TBL (f1) VALUES ('a');
17+
INSERT INTO CHAR_TBL (f1) VALUES ('A');
18+
-- any of the following three input formats are acceptable
19+
INSERT INTO CHAR_TBL (f1) VALUES ('1');
20+
INSERT INTO CHAR_TBL (f1) VALUES (2);
21+
INSERT INTO CHAR_TBL (f1) VALUES ('3');
22+
-- zero-length char
23+
INSERT INTO CHAR_TBL (f1) VALUES ('');
24+
-- try char's of greater than 1 length
25+
INSERT INTO CHAR_TBL (f1) VALUES ('cd');
26+
ERROR: value too long for type character(1)
27+
INSERT INTO CHAR_TBL (f1) VALUES ('c ');
28+
SELECT '' AS seven, CHAR_TBL.*;
29+
seven | f1
30+
-------+----
31+
| a
32+
| A
33+
| 1
34+
| 2
35+
| 3
36+
|
37+
| c
38+
(7 rows)
39+
40+
SELECT '' AS six, c.*
41+
FROM CHAR_TBL c
42+
WHERE c.f1 <> 'a';
43+
six | f1
44+
-----+----
45+
| A
46+
| 1
47+
| 2
48+
| 3
49+
|
50+
| c
51+
(6 rows)
52+
53+
SELECT '' AS one, c.*
54+
FROM CHAR_TBL c
55+
WHERE c.f1 = 'a';
56+
one | f1
57+
-----+----
58+
| a
59+
(1 row)
60+
61+
SELECT '' AS five, c.*
62+
FROM CHAR_TBL c
63+
WHERE c.f1 < 'a';
64+
five | f1
65+
------+----
66+
| 1
67+
| 2
68+
| 3
69+
|
70+
(4 rows)
71+
72+
SELECT '' AS six, c.*
73+
FROM CHAR_TBL c
74+
WHERE c.f1 <= 'a';
75+
six | f1
76+
-----+----
77+
| a
78+
| 1
79+
| 2
80+
| 3
81+
|
82+
(5 rows)
83+
84+
SELECT '' AS one, c.*
85+
FROM CHAR_TBL c
86+
WHERE c.f1 > 'a';
87+
one | f1
88+
-----+----
89+
| A
90+
| c
91+
(2 rows)
92+
93+
SELECT '' AS two, c.*
94+
FROM CHAR_TBL c
95+
WHERE c.f1 >= 'a';
96+
two | f1
97+
-----+----
98+
| a
99+
| A
100+
| c
101+
(3 rows)
102+
103+
DROP TABLE CHAR_TBL;
104+
--
105+
-- Now test longer arrays of char
106+
--
107+
CREATE TABLE CHAR_TBL(f1 char(4));
108+
INSERT INTO CHAR_TBL (f1) VALUES ('a');
109+
INSERT INTO CHAR_TBL (f1) VALUES ('ab');
110+
INSERT INTO CHAR_TBL (f1) VALUES ('abcd');
111+
INSERT INTO CHAR_TBL (f1) VALUES ('abcde');
112+
ERROR: value too long for type character(4)
113+
INSERT INTO CHAR_TBL (f1) VALUES ('abcd ');
114+
SELECT '' AS four, CHAR_TBL.*;
115+
four | f1
116+
------+------
117+
| a
118+
| ab
119+
| abcd
120+
| abcd
121+
(4 rows)
122+
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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;
18+
b | c
19+
---+----------
20+
1 | XXXX
21+
3 | bbbb
22+
(2 rows)
23+
24+
SELECT lower(c), count(c) FROM test_having
25+
GROUP BY lower(c) HAVING count(*) > 2 OR min(a) = max(a);
26+
lower | count
27+
----------+-------
28+
bbbb | 3
29+
cccc | 4
30+
xxxx | 1
31+
(3 rows)
32+
33+
SELECT c, max(a) FROM test_having
34+
GROUP BY c HAVING count(*) > 2 OR min(a) = max(a);
35+
c | max
36+
----------+-----
37+
bbbb | 5
38+
XXXX | 0
39+
(2 rows)
40+
41+
DROP TABLE test_having;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp