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

Commit13fdd0e

Browse files
committed
Add some more citext test cases, per David Wheeler. Also remove the
citext-to-and-from-xml tests, since those caused variation betweeninstallations with or without libxml without really proving much. Insteadrepurpose citext_1.out as the expected results in glibc en_US (and probablyother) locales.
1 parent399ad77 commit13fdd0e

File tree

3 files changed

+94
-80
lines changed

3 files changed

+94
-80
lines changed

‎contrib/citext/expected/citext.out

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,30 @@ SELECT 'foo'::citext::name = 'foo'::name AS t;
710710
t
711711
(1 row)
712712

713+
SELECT 'f'::char::citext = 'f' AS t;
714+
t
715+
---
716+
t
717+
(1 row)
718+
719+
SELECT 'f'::citext::char = 'f'::char AS t;
720+
t
721+
---
722+
t
723+
(1 row)
724+
725+
SELECT 'f'::"char"::citext = 'f' AS t;
726+
t
727+
---
728+
t
729+
(1 row)
730+
731+
SELECT 'f'::citext::"char" = 'f'::"char" AS t;
732+
t
733+
---
734+
t
735+
(1 row)
736+
713737
SELECT 'foo'::bytea::citext = 'foo' AS t;
714738
t
715739
---
@@ -806,18 +830,6 @@ SELECT '08:00:2b:01:02:03'::citext::macaddr = '08:00:2b:01:02:03'::macaddr AS t;
806830
t
807831
(1 row)
808832

809-
SELECT '<p>foo</p>'::xml::citext = '<p>foo</p>' AS t;
810-
t
811-
---
812-
t
813-
(1 row)
814-
815-
SELECT '<p>foo</p>'::citext::xml::text = '<p>foo</p>'::xml::text AS t;
816-
t
817-
---
818-
t
819-
(1 row)
820-
821833
SELECT '1999-01-08 04:05:06'::timestamp::citext = '1999-01-08 04:05:06'::timestamp::text AS t;
822834
t
823835
---
@@ -1041,6 +1053,8 @@ CREATE TABLE caster (
10411053
text text,
10421054
varchar varchar,
10431055
bpchar bpchar,
1056+
char char,
1057+
chr "char",
10441058
name name,
10451059
bytea bytea,
10461060
boolean boolean,
@@ -1053,7 +1067,6 @@ CREATE TABLE caster (
10531067
cidr cidr,
10541068
inet inet,
10551069
macaddr macaddr,
1056-
xml xml,
10571070
money money,
10581071
timestamp timestamp,
10591072
timestamptz timestamptz,
@@ -1083,6 +1096,14 @@ INSERT INTO caster (bpchar) VALUES ('foo'::text);
10831096
INSERT INTO caster (text) VALUES ('foo'::bpchar);
10841097
INSERT INTO caster (bpchar) VALUES ('foo'::citext);
10851098
INSERT INTO caster (citext) VALUES ('foo'::bpchar);
1099+
INSERT INTO caster (char) VALUES ('f'::text);
1100+
INSERT INTO caster (text) VALUES ('f'::char);
1101+
INSERT INTO caster (char) VALUES ('f'::citext);
1102+
INSERT INTO caster (citext) VALUES ('f'::char);
1103+
INSERT INTO caster (chr) VALUES ('f'::text);
1104+
INSERT INTO caster (text) VALUES ('f'::"char");
1105+
INSERT INTO caster (chr) VALUES ('f'::citext);
1106+
INSERT INTO caster (citext) VALUES ('f'::"char");
10861107
INSERT INTO caster (name) VALUES ('foo'::text);
10871108
INSERT INTO caster (text) VALUES ('foo'::name);
10881109
INSERT INTO caster (name) VALUES ('foo'::citext);
@@ -1230,19 +1251,6 @@ LINE 1: INSERT INTO caster (macaddr) VALUES ('08:00:2b:01:02:0...
12301251
^
12311252
HINT: You will need to rewrite or cast the expression.
12321253
INSERT INTO caster (citext) VALUES ('08:00:2b:01:02:03'::macaddr);
1233-
-- Cannot cast to xml on assignment.
1234-
INSERT INTO caster (xml) VALUES ('<p>foo</p>'::text);
1235-
ERROR: column "xml" is of type xml but expression is of type text
1236-
LINE 1: INSERT INTO caster (xml) VALUES ('<p>foo</p>'::tex...
1237-
^
1238-
HINT: You will need to rewrite or cast the expression.
1239-
INSERT INTO caster (text) VALUES ('<p>foo</p>'::xml);
1240-
INSERT INTO caster (xml) VALUES ('<p>foo</p>'::citext);
1241-
ERROR: column "xml" is of type xml but expression is of type citext
1242-
LINE 1: INSERT INTO caster (xml) VALUES ('<p>foo</p>'::cit...
1243-
^
1244-
HINT: You will need to rewrite or cast the expression.
1245-
INSERT INTO caster (citext) VALUES ('<p>foo</p>'::xml);
12461254
-- Cannot cast to money on assignment.
12471255
INSERT INTO caster (money) VALUES ('12'::text);
12481256
ERROR: column "money" is of type money but expression is of type text

‎contrib/citext/expected/citext_1.out

Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -122,25 +122,25 @@ SELECT 'A'::text <> 'a'::citext AS t;
122122
SELECT 'B'::citext < 'a'::text AS t; -- text wins.
123123
t
124124
---
125-
t
125+
f
126126
(1 row)
127127

128128
SELECT 'B'::citext <= 'a'::text AS t; -- text wins.
129129
t
130130
---
131-
t
131+
f
132132
(1 row)
133133

134134
SELECT 'a'::citext > 'B'::text AS t; -- text wins.
135135
t
136136
---
137-
t
137+
f
138138
(1 row)
139139

140140
SELECT 'a'::citext >= 'B'::text AS t; -- text wins.
141141
t
142142
---
143-
t
143+
f
144144
(1 row)
145145

146146
-- Test implicit casting. citext casts to varchar, but not vice-versa.
@@ -159,25 +159,25 @@ SELECT 'A'::varchar <> 'a'::citext AS t;
159159
SELECT 'B'::citext < 'a'::varchar AS t; -- varchar wins.
160160
t
161161
---
162-
t
162+
f
163163
(1 row)
164164

165165
SELECT 'B'::citext <= 'a'::varchar AS t; -- varchar wins.
166166
t
167167
---
168-
t
168+
f
169169
(1 row)
170170

171171
SELECT 'a'::citext > 'B'::varchar AS t; -- varchar wins.
172172
t
173173
---
174-
t
174+
f
175175
(1 row)
176176

177177
SELECT 'a'::citext >= 'B'::varchar AS t; -- varchar wins.
178178
t
179179
---
180-
t
180+
f
181181
(1 row)
182182

183183
-- A couple of longer examlpes to ensure that we don't get any issues with bad
@@ -710,6 +710,30 @@ SELECT 'foo'::citext::name = 'foo'::name AS t;
710710
t
711711
(1 row)
712712

713+
SELECT 'f'::char::citext = 'f' AS t;
714+
t
715+
---
716+
t
717+
(1 row)
718+
719+
SELECT 'f'::citext::char = 'f'::char AS t;
720+
t
721+
---
722+
t
723+
(1 row)
724+
725+
SELECT 'f'::"char"::citext = 'f' AS t;
726+
t
727+
---
728+
t
729+
(1 row)
730+
731+
SELECT 'f'::citext::"char" = 'f'::"char" AS t;
732+
t
733+
---
734+
t
735+
(1 row)
736+
713737
SELECT 'foo'::bytea::citext = 'foo' AS t;
714738
t
715739
---
@@ -806,18 +830,6 @@ SELECT '08:00:2b:01:02:03'::citext::macaddr = '08:00:2b:01:02:03'::macaddr AS t;
806830
t
807831
(1 row)
808832

809-
SELECT '<p>foo</p>'::xml::citext = '<p>foo</p>' AS t;
810-
ERROR: unsupported XML feature
811-
LINE 1: SELECT '<p>foo</p>'::xml::citext = '<p>foo</p>' AS t;
812-
^
813-
DETAIL: This functionality requires the server to be built with libxml support.
814-
HINT: You need to rebuild PostgreSQL using --with-libxml.
815-
SELECT '<p>foo</p>'::citext::xml::text = '<p>foo</p>'::xml::text AS t;
816-
ERROR: unsupported XML feature
817-
LINE 1: SELECT '<p>foo</p>'::citext::xml::text = '<p>foo</p>'::xml::...
818-
^
819-
DETAIL: This functionality requires the server to be built with libxml support.
820-
HINT: You need to rebuild PostgreSQL using --with-libxml.
821833
SELECT '1999-01-08 04:05:06'::timestamp::citext = '1999-01-08 04:05:06'::timestamp::text AS t;
822834
t
823835
---
@@ -1041,6 +1053,8 @@ CREATE TABLE caster (
10411053
text text,
10421054
varchar varchar,
10431055
bpchar bpchar,
1056+
char char,
1057+
chr "char",
10441058
name name,
10451059
bytea bytea,
10461060
boolean boolean,
@@ -1053,7 +1067,6 @@ CREATE TABLE caster (
10531067
cidr cidr,
10541068
inet inet,
10551069
macaddr macaddr,
1056-
xml xml,
10571070
money money,
10581071
timestamp timestamp,
10591072
timestamptz timestamptz,
@@ -1083,6 +1096,14 @@ INSERT INTO caster (bpchar) VALUES ('foo'::text);
10831096
INSERT INTO caster (text) VALUES ('foo'::bpchar);
10841097
INSERT INTO caster (bpchar) VALUES ('foo'::citext);
10851098
INSERT INTO caster (citext) VALUES ('foo'::bpchar);
1099+
INSERT INTO caster (char) VALUES ('f'::text);
1100+
INSERT INTO caster (text) VALUES ('f'::char);
1101+
INSERT INTO caster (char) VALUES ('f'::citext);
1102+
INSERT INTO caster (citext) VALUES ('f'::char);
1103+
INSERT INTO caster (chr) VALUES ('f'::text);
1104+
INSERT INTO caster (text) VALUES ('f'::"char");
1105+
INSERT INTO caster (chr) VALUES ('f'::citext);
1106+
INSERT INTO caster (citext) VALUES ('f'::"char");
10861107
INSERT INTO caster (name) VALUES ('foo'::text);
10871108
INSERT INTO caster (text) VALUES ('foo'::name);
10881109
INSERT INTO caster (name) VALUES ('foo'::citext);
@@ -1230,29 +1251,6 @@ LINE 1: INSERT INTO caster (macaddr) VALUES ('08:00:2b:01:02:0...
12301251
^
12311252
HINT: You will need to rewrite or cast the expression.
12321253
INSERT INTO caster (citext) VALUES ('08:00:2b:01:02:03'::macaddr);
1233-
-- Cannot cast to xml on assignment.
1234-
INSERT INTO caster (xml) VALUES ('<p>foo</p>'::text);
1235-
ERROR: column "xml" is of type xml but expression is of type text
1236-
LINE 1: INSERT INTO caster (xml) VALUES ('<p>foo</p>'::tex...
1237-
^
1238-
HINT: You will need to rewrite or cast the expression.
1239-
INSERT INTO caster (text) VALUES ('<p>foo</p>'::xml);
1240-
ERROR: unsupported XML feature
1241-
LINE 1: INSERT INTO caster (text) VALUES ('<p>foo</p>'::xml...
1242-
^
1243-
DETAIL: This functionality requires the server to be built with libxml support.
1244-
HINT: You need to rebuild PostgreSQL using --with-libxml.
1245-
INSERT INTO caster (xml) VALUES ('<p>foo</p>'::citext);
1246-
ERROR: column "xml" is of type xml but expression is of type citext
1247-
LINE 1: INSERT INTO caster (xml) VALUES ('<p>foo</p>'::cit...
1248-
^
1249-
HINT: You will need to rewrite or cast the expression.
1250-
INSERT INTO caster (citext) VALUES ('<p>foo</p>'::xml);
1251-
ERROR: unsupported XML feature
1252-
LINE 1: INSERT INTO caster (citext) VALUES ('<p>foo</p>'::xml...
1253-
^
1254-
DETAIL: This functionality requires the server to be built with libxml support.
1255-
HINT: You need to rebuild PostgreSQL using --with-libxml.
12561254
-- Cannot cast to money on assignment.
12571255
INSERT INTO caster (money) VALUES ('12'::text);
12581256
ERROR: column "money" is of type money but expression is of type text

‎contrib/citext/sql/citext.sql

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,12 @@ SELECT '4.0'::citext::float8 = 4.0 AS t;
220220
SELECT'foo'::name::citext='foo'AS t;
221221
SELECT'foo'::citext::name='foo'::nameAS t;
222222

223+
SELECT'f'::char::citext='f'AS t;
224+
SELECT'f'::citext::char='f'::charAS t;
225+
226+
SELECT'f'::"char"::citext='f'AS t;
227+
SELECT'f'::citext::"char"='f'::"char"AS t;
228+
223229
SELECT'foo'::bytea::citext='foo'AS t;
224230
SELECT'foo'::citext::bytea='foo'::byteaAS t;
225231

@@ -244,9 +250,6 @@ SELECT '192.168.100.128'::citext::inet = '192.168.100.128'::inet AS t;
244250
SELECT'08:00:2b:01:02:03'::macaddr::citext='08:00:2b:01:02:03'AS t;
245251
SELECT'08:00:2b:01:02:03'::citext::macaddr='08:00:2b:01:02:03'::macaddrAS t;
246252

247-
SELECT'<p>foo</p>'::xml::citext='<p>foo</p>'AS t;
248-
SELECT'<p>foo</p>'::citext::xml::text='<p>foo</p>'::xml::textAS t;
249-
250253
SELECT'1999-01-08 04:05:06'::timestamp::citext='1999-01-08 04:05:06'::timestamp::textAS t;
251254
SELECT'1999-01-08 04:05:06'::citext::timestamp='1999-01-08 04:05:06'::timestampAS t;
252255
SELECT'1999-01-08 04:05:06'::timestamptz::citext='1999-01-08 04:05:06'::timestamptz::textAS t;
@@ -300,6 +303,8 @@ CREATE TABLE caster (
300303
texttext,
301304
varcharvarchar,
302305
bpchar bpchar,
306+
charchar,
307+
chr"char",
303308
name name,
304309
byteabytea,
305310
booleanboolean,
@@ -312,7 +317,6 @@ CREATE TABLE caster (
312317
cidrcidr,
313318
inetinet,
314319
macaddrmacaddr,
315-
xml xml,
316320
moneymoney,
317321
timestamptimestamp,
318322
timestamptztimestamptz,
@@ -346,6 +350,16 @@ INSERT INTO caster (text) VALUES ('foo'::bpchar);
346350
INSERT INTO caster (bpchar)VALUES ('foo'::citext);
347351
INSERT INTO caster (citext)VALUES ('foo'::bpchar);
348352

353+
INSERT INTO caster (char)VALUES ('f'::text);
354+
INSERT INTO caster (text)VALUES ('f'::char);
355+
INSERT INTO caster (char)VALUES ('f'::citext);
356+
INSERT INTO caster (citext)VALUES ('f'::char);
357+
358+
INSERT INTO caster (chr)VALUES ('f'::text);
359+
INSERT INTO caster (text)VALUES ('f'::"char");
360+
INSERT INTO caster (chr)VALUES ('f'::citext);
361+
INSERT INTO caster (citext)VALUES ('f'::"char");
362+
349363
INSERT INTO caster (name)VALUES ('foo'::text);
350364
INSERT INTO caster (text)VALUES ('foo'::name);
351365
INSERT INTO caster (name)VALUES ('foo'::citext);
@@ -417,12 +431,6 @@ INSERT INTO caster (text) VALUES ('08:00:2b:01:02:03'::macaddr);
417431
INSERT INTO caster (macaddr)VALUES ('08:00:2b:01:02:03'::citext);
418432
INSERT INTO caster (citext)VALUES ('08:00:2b:01:02:03'::macaddr);
419433

420-
-- Cannot cast to xml on assignment.
421-
INSERT INTO caster (xml)VALUES ('<p>foo</p>'::text);
422-
INSERT INTO caster (text)VALUES ('<p>foo</p>'::xml);
423-
INSERT INTO caster (xml)VALUES ('<p>foo</p>'::citext);
424-
INSERT INTO caster (citext)VALUES ('<p>foo</p>'::xml);
425-
426434
-- Cannot cast to money on assignment.
427435
INSERT INTO caster (money)VALUES ('12'::text);
428436
INSERT INTO caster (text)VALUES ('12'::money);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp