Commit 13fdd0e4 authored by Tom Lane's avatar Tom Lane

Add some more citext test cases, per David Wheeler. Also remove the

citext-to-and-from-xml tests, since those caused variation between
installations with or without libxml without really proving much.  Instead
repurpose citext_1.out as the expected results in glibc en_US (and probably
other) locales.
parent 399ad77c
...@@ -710,6 +710,30 @@ SELECT 'foo'::citext::name = 'foo'::name AS t; ...@@ -710,6 +710,30 @@ SELECT 'foo'::citext::name = 'foo'::name AS t;
t t
(1 row) (1 row)
SELECT 'f'::char::citext = 'f' AS t;
t
---
t
(1 row)
SELECT 'f'::citext::char = 'f'::char AS t;
t
---
t
(1 row)
SELECT 'f'::"char"::citext = 'f' AS t;
t
---
t
(1 row)
SELECT 'f'::citext::"char" = 'f'::"char" AS t;
t
---
t
(1 row)
SELECT 'foo'::bytea::citext = 'foo' AS t; SELECT 'foo'::bytea::citext = 'foo' AS t;
t t
--- ---
...@@ -806,18 +830,6 @@ SELECT '08:00:2b:01:02:03'::citext::macaddr = '08:00:2b:01:02:03'::macaddr AS t; ...@@ -806,18 +830,6 @@ SELECT '08:00:2b:01:02:03'::citext::macaddr = '08:00:2b:01:02:03'::macaddr AS t;
t t
(1 row) (1 row)
SELECT '<p>foo</p>'::xml::citext = '<p>foo</p>' AS t;
t
---
t
(1 row)
SELECT '<p>foo</p>'::citext::xml::text = '<p>foo</p>'::xml::text AS t;
t
---
t
(1 row)
SELECT '1999-01-08 04:05:06'::timestamp::citext = '1999-01-08 04:05:06'::timestamp::text AS t; SELECT '1999-01-08 04:05:06'::timestamp::citext = '1999-01-08 04:05:06'::timestamp::text AS t;
t t
--- ---
...@@ -1041,6 +1053,8 @@ CREATE TABLE caster ( ...@@ -1041,6 +1053,8 @@ CREATE TABLE caster (
text text, text text,
varchar varchar, varchar varchar,
bpchar bpchar, bpchar bpchar,
char char,
chr "char",
name name, name name,
bytea bytea, bytea bytea,
boolean boolean, boolean boolean,
...@@ -1053,7 +1067,6 @@ CREATE TABLE caster ( ...@@ -1053,7 +1067,6 @@ CREATE TABLE caster (
cidr cidr, cidr cidr,
inet inet, inet inet,
macaddr macaddr, macaddr macaddr,
xml xml,
money money, money money,
timestamp timestamp, timestamp timestamp,
timestamptz timestamptz, timestamptz timestamptz,
...@@ -1083,6 +1096,14 @@ INSERT INTO caster (bpchar) VALUES ('foo'::text); ...@@ -1083,6 +1096,14 @@ INSERT INTO caster (bpchar) VALUES ('foo'::text);
INSERT INTO caster (text) VALUES ('foo'::bpchar); INSERT INTO caster (text) VALUES ('foo'::bpchar);
INSERT INTO caster (bpchar) VALUES ('foo'::citext); INSERT INTO caster (bpchar) VALUES ('foo'::citext);
INSERT INTO caster (citext) VALUES ('foo'::bpchar); INSERT INTO caster (citext) VALUES ('foo'::bpchar);
INSERT INTO caster (char) VALUES ('f'::text);
INSERT INTO caster (text) VALUES ('f'::char);
INSERT INTO caster (char) VALUES ('f'::citext);
INSERT INTO caster (citext) VALUES ('f'::char);
INSERT INTO caster (chr) VALUES ('f'::text);
INSERT INTO caster (text) VALUES ('f'::"char");
INSERT INTO caster (chr) VALUES ('f'::citext);
INSERT INTO caster (citext) VALUES ('f'::"char");
INSERT INTO caster (name) VALUES ('foo'::text); INSERT INTO caster (name) VALUES ('foo'::text);
INSERT INTO caster (text) VALUES ('foo'::name); INSERT INTO caster (text) VALUES ('foo'::name);
INSERT INTO caster (name) VALUES ('foo'::citext); INSERT INTO caster (name) VALUES ('foo'::citext);
...@@ -1230,19 +1251,6 @@ LINE 1: INSERT INTO caster (macaddr) VALUES ('08:00:2b:01:02:0... ...@@ -1230,19 +1251,6 @@ LINE 1: INSERT INTO caster (macaddr) VALUES ('08:00:2b:01:02:0...
^ ^
HINT: You will need to rewrite or cast the expression. HINT: You will need to rewrite or cast the expression.
INSERT INTO caster (citext) VALUES ('08:00:2b:01:02:03'::macaddr); INSERT INTO caster (citext) VALUES ('08:00:2b:01:02:03'::macaddr);
-- Cannot cast to xml on assignment.
INSERT INTO caster (xml) VALUES ('<p>foo</p>'::text);
ERROR: column "xml" is of type xml but expression is of type text
LINE 1: INSERT INTO caster (xml) VALUES ('<p>foo</p>'::tex...
^
HINT: You will need to rewrite or cast the expression.
INSERT INTO caster (text) VALUES ('<p>foo</p>'::xml);
INSERT INTO caster (xml) VALUES ('<p>foo</p>'::citext);
ERROR: column "xml" is of type xml but expression is of type citext
LINE 1: INSERT INTO caster (xml) VALUES ('<p>foo</p>'::cit...
^
HINT: You will need to rewrite or cast the expression.
INSERT INTO caster (citext) VALUES ('<p>foo</p>'::xml);
-- Cannot cast to money on assignment. -- Cannot cast to money on assignment.
INSERT INTO caster (money) VALUES ('12'::text); INSERT INTO caster (money) VALUES ('12'::text);
ERROR: column "money" is of type money but expression is of type text ERROR: column "money" is of type money but expression is of type text
......
...@@ -122,25 +122,25 @@ SELECT 'A'::text <> 'a'::citext AS t; ...@@ -122,25 +122,25 @@ SELECT 'A'::text <> 'a'::citext AS t;
SELECT 'B'::citext < 'a'::text AS t; -- text wins. SELECT 'B'::citext < 'a'::text AS t; -- text wins.
t t
--- ---
t f
(1 row) (1 row)
SELECT 'B'::citext <= 'a'::text AS t; -- text wins. SELECT 'B'::citext <= 'a'::text AS t; -- text wins.
t t
--- ---
t f
(1 row) (1 row)
SELECT 'a'::citext > 'B'::text AS t; -- text wins. SELECT 'a'::citext > 'B'::text AS t; -- text wins.
t t
--- ---
t f
(1 row) (1 row)
SELECT 'a'::citext >= 'B'::text AS t; -- text wins. SELECT 'a'::citext >= 'B'::text AS t; -- text wins.
t t
--- ---
t f
(1 row) (1 row)
-- Test implicit casting. citext casts to varchar, but not vice-versa. -- Test implicit casting. citext casts to varchar, but not vice-versa.
...@@ -159,25 +159,25 @@ SELECT 'A'::varchar <> 'a'::citext AS t; ...@@ -159,25 +159,25 @@ SELECT 'A'::varchar <> 'a'::citext AS t;
SELECT 'B'::citext < 'a'::varchar AS t; -- varchar wins. SELECT 'B'::citext < 'a'::varchar AS t; -- varchar wins.
t t
--- ---
t f
(1 row) (1 row)
SELECT 'B'::citext <= 'a'::varchar AS t; -- varchar wins. SELECT 'B'::citext <= 'a'::varchar AS t; -- varchar wins.
t t
--- ---
t f
(1 row) (1 row)
SELECT 'a'::citext > 'B'::varchar AS t; -- varchar wins. SELECT 'a'::citext > 'B'::varchar AS t; -- varchar wins.
t t
--- ---
t f
(1 row) (1 row)
SELECT 'a'::citext >= 'B'::varchar AS t; -- varchar wins. SELECT 'a'::citext >= 'B'::varchar AS t; -- varchar wins.
t t
--- ---
t f
(1 row) (1 row)
-- A couple of longer examlpes to ensure that we don't get any issues with bad -- 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; ...@@ -710,6 +710,30 @@ SELECT 'foo'::citext::name = 'foo'::name AS t;
t t
(1 row) (1 row)
SELECT 'f'::char::citext = 'f' AS t;
t
---
t
(1 row)
SELECT 'f'::citext::char = 'f'::char AS t;
t
---
t
(1 row)
SELECT 'f'::"char"::citext = 'f' AS t;
t
---
t
(1 row)
SELECT 'f'::citext::"char" = 'f'::"char" AS t;
t
---
t
(1 row)
SELECT 'foo'::bytea::citext = 'foo' AS t; SELECT 'foo'::bytea::citext = 'foo' AS t;
t t
--- ---
...@@ -806,18 +830,6 @@ SELECT '08:00:2b:01:02:03'::citext::macaddr = '08:00:2b:01:02:03'::macaddr AS t; ...@@ -806,18 +830,6 @@ SELECT '08:00:2b:01:02:03'::citext::macaddr = '08:00:2b:01:02:03'::macaddr AS t;
t t
(1 row) (1 row)
SELECT '<p>foo</p>'::xml::citext = '<p>foo</p>' AS t;
ERROR: unsupported XML feature
LINE 1: SELECT '<p>foo</p>'::xml::citext = '<p>foo</p>' AS t;
^
DETAIL: This functionality requires the server to be built with libxml support.
HINT: You need to rebuild PostgreSQL using --with-libxml.
SELECT '<p>foo</p>'::citext::xml::text = '<p>foo</p>'::xml::text AS t;
ERROR: unsupported XML feature
LINE 1: SELECT '<p>foo</p>'::citext::xml::text = '<p>foo</p>'::xml::...
^
DETAIL: This functionality requires the server to be built with libxml support.
HINT: You need to rebuild PostgreSQL using --with-libxml.
SELECT '1999-01-08 04:05:06'::timestamp::citext = '1999-01-08 04:05:06'::timestamp::text AS t; SELECT '1999-01-08 04:05:06'::timestamp::citext = '1999-01-08 04:05:06'::timestamp::text AS t;
t t
--- ---
...@@ -1041,6 +1053,8 @@ CREATE TABLE caster ( ...@@ -1041,6 +1053,8 @@ CREATE TABLE caster (
text text, text text,
varchar varchar, varchar varchar,
bpchar bpchar, bpchar bpchar,
char char,
chr "char",
name name, name name,
bytea bytea, bytea bytea,
boolean boolean, boolean boolean,
...@@ -1053,7 +1067,6 @@ CREATE TABLE caster ( ...@@ -1053,7 +1067,6 @@ CREATE TABLE caster (
cidr cidr, cidr cidr,
inet inet, inet inet,
macaddr macaddr, macaddr macaddr,
xml xml,
money money, money money,
timestamp timestamp, timestamp timestamp,
timestamptz timestamptz, timestamptz timestamptz,
...@@ -1083,6 +1096,14 @@ INSERT INTO caster (bpchar) VALUES ('foo'::text); ...@@ -1083,6 +1096,14 @@ INSERT INTO caster (bpchar) VALUES ('foo'::text);
INSERT INTO caster (text) VALUES ('foo'::bpchar); INSERT INTO caster (text) VALUES ('foo'::bpchar);
INSERT INTO caster (bpchar) VALUES ('foo'::citext); INSERT INTO caster (bpchar) VALUES ('foo'::citext);
INSERT INTO caster (citext) VALUES ('foo'::bpchar); INSERT INTO caster (citext) VALUES ('foo'::bpchar);
INSERT INTO caster (char) VALUES ('f'::text);
INSERT INTO caster (text) VALUES ('f'::char);
INSERT INTO caster (char) VALUES ('f'::citext);
INSERT INTO caster (citext) VALUES ('f'::char);
INSERT INTO caster (chr) VALUES ('f'::text);
INSERT INTO caster (text) VALUES ('f'::"char");
INSERT INTO caster (chr) VALUES ('f'::citext);
INSERT INTO caster (citext) VALUES ('f'::"char");
INSERT INTO caster (name) VALUES ('foo'::text); INSERT INTO caster (name) VALUES ('foo'::text);
INSERT INTO caster (text) VALUES ('foo'::name); INSERT INTO caster (text) VALUES ('foo'::name);
INSERT INTO caster (name) VALUES ('foo'::citext); INSERT INTO caster (name) VALUES ('foo'::citext);
...@@ -1230,29 +1251,6 @@ LINE 1: INSERT INTO caster (macaddr) VALUES ('08:00:2b:01:02:0... ...@@ -1230,29 +1251,6 @@ LINE 1: INSERT INTO caster (macaddr) VALUES ('08:00:2b:01:02:0...
^ ^
HINT: You will need to rewrite or cast the expression. HINT: You will need to rewrite or cast the expression.
INSERT INTO caster (citext) VALUES ('08:00:2b:01:02:03'::macaddr); INSERT INTO caster (citext) VALUES ('08:00:2b:01:02:03'::macaddr);
-- Cannot cast to xml on assignment.
INSERT INTO caster (xml) VALUES ('<p>foo</p>'::text);
ERROR: column "xml" is of type xml but expression is of type text
LINE 1: INSERT INTO caster (xml) VALUES ('<p>foo</p>'::tex...
^
HINT: You will need to rewrite or cast the expression.
INSERT INTO caster (text) VALUES ('<p>foo</p>'::xml);
ERROR: unsupported XML feature
LINE 1: INSERT INTO caster (text) VALUES ('<p>foo</p>'::xml...
^
DETAIL: This functionality requires the server to be built with libxml support.
HINT: You need to rebuild PostgreSQL using --with-libxml.
INSERT INTO caster (xml) VALUES ('<p>foo</p>'::citext);
ERROR: column "xml" is of type xml but expression is of type citext
LINE 1: INSERT INTO caster (xml) VALUES ('<p>foo</p>'::cit...
^
HINT: You will need to rewrite or cast the expression.
INSERT INTO caster (citext) VALUES ('<p>foo</p>'::xml);
ERROR: unsupported XML feature
LINE 1: INSERT INTO caster (citext) VALUES ('<p>foo</p>'::xml...
^
DETAIL: This functionality requires the server to be built with libxml support.
HINT: You need to rebuild PostgreSQL using --with-libxml.
-- Cannot cast to money on assignment. -- Cannot cast to money on assignment.
INSERT INTO caster (money) VALUES ('12'::text); INSERT INTO caster (money) VALUES ('12'::text);
ERROR: column "money" is of type money but expression is of type text ERROR: column "money" is of type money but expression is of type text
......
...@@ -220,6 +220,12 @@ SELECT '4.0'::citext::float8 = 4.0 AS t; ...@@ -220,6 +220,12 @@ SELECT '4.0'::citext::float8 = 4.0 AS t;
SELECT 'foo'::name::citext = 'foo' AS t; SELECT 'foo'::name::citext = 'foo' AS t;
SELECT 'foo'::citext::name = 'foo'::name AS t; SELECT 'foo'::citext::name = 'foo'::name AS t;
SELECT 'f'::char::citext = 'f' AS t;
SELECT 'f'::citext::char = 'f'::char AS t;
SELECT 'f'::"char"::citext = 'f' AS t;
SELECT 'f'::citext::"char" = 'f'::"char" AS t;
SELECT 'foo'::bytea::citext = 'foo' AS t; SELECT 'foo'::bytea::citext = 'foo' AS t;
SELECT 'foo'::citext::bytea = 'foo'::bytea AS t; SELECT 'foo'::citext::bytea = 'foo'::bytea AS t;
...@@ -244,9 +250,6 @@ SELECT '192.168.100.128'::citext::inet = '192.168.100.128'::inet AS t; ...@@ -244,9 +250,6 @@ SELECT '192.168.100.128'::citext::inet = '192.168.100.128'::inet AS t;
SELECT '08:00:2b:01:02:03'::macaddr::citext = '08:00:2b:01:02:03' AS t; SELECT '08:00:2b:01:02:03'::macaddr::citext = '08:00:2b:01:02:03' AS t;
SELECT '08:00:2b:01:02:03'::citext::macaddr = '08:00:2b:01:02:03'::macaddr AS t; SELECT '08:00:2b:01:02:03'::citext::macaddr = '08:00:2b:01:02:03'::macaddr AS t;
SELECT '<p>foo</p>'::xml::citext = '<p>foo</p>' AS t;
SELECT '<p>foo</p>'::citext::xml::text = '<p>foo</p>'::xml::text AS t;
SELECT '1999-01-08 04:05:06'::timestamp::citext = '1999-01-08 04:05:06'::timestamp::text AS t; SELECT '1999-01-08 04:05:06'::timestamp::citext = '1999-01-08 04:05:06'::timestamp::text AS t;
SELECT '1999-01-08 04:05:06'::citext::timestamp = '1999-01-08 04:05:06'::timestamp AS t; SELECT '1999-01-08 04:05:06'::citext::timestamp = '1999-01-08 04:05:06'::timestamp AS t;
SELECT '1999-01-08 04:05:06'::timestamptz::citext = '1999-01-08 04:05:06'::timestamptz::text AS t; SELECT '1999-01-08 04:05:06'::timestamptz::citext = '1999-01-08 04:05:06'::timestamptz::text AS t;
...@@ -300,6 +303,8 @@ CREATE TABLE caster ( ...@@ -300,6 +303,8 @@ CREATE TABLE caster (
text text, text text,
varchar varchar, varchar varchar,
bpchar bpchar, bpchar bpchar,
char char,
chr "char",
name name, name name,
bytea bytea, bytea bytea,
boolean boolean, boolean boolean,
...@@ -312,7 +317,6 @@ CREATE TABLE caster ( ...@@ -312,7 +317,6 @@ CREATE TABLE caster (
cidr cidr, cidr cidr,
inet inet, inet inet,
macaddr macaddr, macaddr macaddr,
xml xml,
money money, money money,
timestamp timestamp, timestamp timestamp,
timestamptz timestamptz, timestamptz timestamptz,
...@@ -346,6 +350,16 @@ INSERT INTO caster (text) VALUES ('foo'::bpchar); ...@@ -346,6 +350,16 @@ INSERT INTO caster (text) VALUES ('foo'::bpchar);
INSERT INTO caster (bpchar) VALUES ('foo'::citext); INSERT INTO caster (bpchar) VALUES ('foo'::citext);
INSERT INTO caster (citext) VALUES ('foo'::bpchar); INSERT INTO caster (citext) VALUES ('foo'::bpchar);
INSERT INTO caster (char) VALUES ('f'::text);
INSERT INTO caster (text) VALUES ('f'::char);
INSERT INTO caster (char) VALUES ('f'::citext);
INSERT INTO caster (citext) VALUES ('f'::char);
INSERT INTO caster (chr) VALUES ('f'::text);
INSERT INTO caster (text) VALUES ('f'::"char");
INSERT INTO caster (chr) VALUES ('f'::citext);
INSERT INTO caster (citext) VALUES ('f'::"char");
INSERT INTO caster (name) VALUES ('foo'::text); INSERT INTO caster (name) VALUES ('foo'::text);
INSERT INTO caster (text) VALUES ('foo'::name); INSERT INTO caster (text) VALUES ('foo'::name);
INSERT INTO caster (name) VALUES ('foo'::citext); INSERT INTO caster (name) VALUES ('foo'::citext);
...@@ -417,12 +431,6 @@ INSERT INTO caster (text) VALUES ('08:00:2b:01:02:03'::macaddr); ...@@ -417,12 +431,6 @@ INSERT INTO caster (text) VALUES ('08:00:2b:01:02:03'::macaddr);
INSERT INTO caster (macaddr) VALUES ('08:00:2b:01:02:03'::citext); INSERT INTO caster (macaddr) VALUES ('08:00:2b:01:02:03'::citext);
INSERT INTO caster (citext) VALUES ('08:00:2b:01:02:03'::macaddr); INSERT INTO caster (citext) VALUES ('08:00:2b:01:02:03'::macaddr);
-- Cannot cast to xml on assignment.
INSERT INTO caster (xml) VALUES ('<p>foo</p>'::text);
INSERT INTO caster (text) VALUES ('<p>foo</p>'::xml);
INSERT INTO caster (xml) VALUES ('<p>foo</p>'::citext);
INSERT INTO caster (citext) VALUES ('<p>foo</p>'::xml);
-- Cannot cast to money on assignment. -- Cannot cast to money on assignment.
INSERT INTO caster (money) VALUES ('12'::text); INSERT INTO caster (money) VALUES ('12'::text);
INSERT INTO caster (text) VALUES ('12'::money); INSERT INTO caster (text) VALUES ('12'::money);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment