mirror of
https://github.com/postgres/postgres.git
synced 2025-04-20 00:42:27 +03:00
Make contrib regression tests safe for Danish locale.
In btree_gin and citext, avoid some not-particularly-interesting dependencies on the sorting of 'aa'. In tsearch2, use COLLATE "C" to remove an uninteresting dependency on locale sort order (and thereby allow removal of a variant expected-file). Also, in citext, avoid assuming that lower('I') = 'i'. This isn't relevant to Danish but it does fail in Turkish.
This commit is contained in:
parent
0060638c87
commit
e15e7886e6
@ -4,13 +4,13 @@ SET bytea_output TO escape;
|
|||||||
CREATE TABLE test_bytea (
|
CREATE TABLE test_bytea (
|
||||||
i bytea
|
i bytea
|
||||||
);
|
);
|
||||||
INSERT INTO test_bytea VALUES ('aaa'),('a'),('abc'),('abb'),('axy'),('xyz');
|
INSERT INTO test_bytea VALUES ('a'),('ab'),('abc'),('abb'),('axy'),('xyz');
|
||||||
CREATE INDEX idx_bytea ON test_bytea USING gin (i);
|
CREATE INDEX idx_bytea ON test_bytea USING gin (i);
|
||||||
SELECT * FROM test_bytea WHERE i<'abc'::bytea ORDER BY i;
|
SELECT * FROM test_bytea WHERE i<'abc'::bytea ORDER BY i;
|
||||||
i
|
i
|
||||||
-----
|
-----
|
||||||
a
|
a
|
||||||
aaa
|
ab
|
||||||
abb
|
abb
|
||||||
(3 rows)
|
(3 rows)
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ SELECT * FROM test_bytea WHERE i<='abc'::bytea ORDER BY i;
|
|||||||
i
|
i
|
||||||
-----
|
-----
|
||||||
a
|
a
|
||||||
aaa
|
ab
|
||||||
abb
|
abb
|
||||||
abc
|
abc
|
||||||
(4 rows)
|
(4 rows)
|
||||||
|
@ -2,13 +2,13 @@ set enable_seqscan=off;
|
|||||||
CREATE TABLE test_text (
|
CREATE TABLE test_text (
|
||||||
i text
|
i text
|
||||||
);
|
);
|
||||||
INSERT INTO test_text VALUES ('aaa'),('a'),('abc'),('abb'),('axy'),('xyz');
|
INSERT INTO test_text VALUES ('a'),('ab'),('abc'),('abb'),('axy'),('xyz');
|
||||||
CREATE INDEX idx_text ON test_text USING gin (i);
|
CREATE INDEX idx_text ON test_text USING gin (i);
|
||||||
SELECT * FROM test_text WHERE i<'abc' ORDER BY i;
|
SELECT * FROM test_text WHERE i<'abc' ORDER BY i;
|
||||||
i
|
i
|
||||||
-----
|
-----
|
||||||
a
|
a
|
||||||
aaa
|
ab
|
||||||
abb
|
abb
|
||||||
(3 rows)
|
(3 rows)
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ SELECT * FROM test_text WHERE i<='abc' ORDER BY i;
|
|||||||
i
|
i
|
||||||
-----
|
-----
|
||||||
a
|
a
|
||||||
aaa
|
ab
|
||||||
abb
|
abb
|
||||||
abc
|
abc
|
||||||
(4 rows)
|
(4 rows)
|
||||||
|
@ -2,13 +2,13 @@ set enable_seqscan=off;
|
|||||||
CREATE TABLE test_varchar (
|
CREATE TABLE test_varchar (
|
||||||
i varchar
|
i varchar
|
||||||
);
|
);
|
||||||
INSERT INTO test_varchar VALUES ('aaa'),('a'),('abc'),('abb'),('axy'),('xyz');
|
INSERT INTO test_varchar VALUES ('a'),('ab'),('abc'),('abb'),('axy'),('xyz');
|
||||||
CREATE INDEX idx_varchar ON test_varchar USING gin (i);
|
CREATE INDEX idx_varchar ON test_varchar USING gin (i);
|
||||||
SELECT * FROM test_varchar WHERE i<'abc'::varchar ORDER BY i;
|
SELECT * FROM test_varchar WHERE i<'abc'::varchar ORDER BY i;
|
||||||
i
|
i
|
||||||
-----
|
-----
|
||||||
a
|
a
|
||||||
aaa
|
ab
|
||||||
abb
|
abb
|
||||||
(3 rows)
|
(3 rows)
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ SELECT * FROM test_varchar WHERE i<='abc'::varchar ORDER BY i;
|
|||||||
i
|
i
|
||||||
-----
|
-----
|
||||||
a
|
a
|
||||||
aaa
|
ab
|
||||||
abb
|
abb
|
||||||
abc
|
abc
|
||||||
(4 rows)
|
(4 rows)
|
||||||
|
@ -6,7 +6,7 @@ CREATE TABLE test_bytea (
|
|||||||
i bytea
|
i bytea
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO test_bytea VALUES ('aaa'),('a'),('abc'),('abb'),('axy'),('xyz');
|
INSERT INTO test_bytea VALUES ('a'),('ab'),('abc'),('abb'),('axy'),('xyz');
|
||||||
|
|
||||||
CREATE INDEX idx_bytea ON test_bytea USING gin (i);
|
CREATE INDEX idx_bytea ON test_bytea USING gin (i);
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ CREATE TABLE test_text (
|
|||||||
i text
|
i text
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO test_text VALUES ('aaa'),('a'),('abc'),('abb'),('axy'),('xyz');
|
INSERT INTO test_text VALUES ('a'),('ab'),('abc'),('abb'),('axy'),('xyz');
|
||||||
|
|
||||||
CREATE INDEX idx_text ON test_text USING gin (i);
|
CREATE INDEX idx_text ON test_text USING gin (i);
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ CREATE TABLE test_varchar (
|
|||||||
i varchar
|
i varchar
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO test_varchar VALUES ('aaa'),('a'),('abc'),('abb'),('axy'),('xyz');
|
INSERT INTO test_varchar VALUES ('a'),('ab'),('abc'),('abb'),('axy'),('xyz');
|
||||||
|
|
||||||
CREATE INDEX idx_varchar ON test_varchar USING gin (i);
|
CREATE INDEX idx_varchar ON test_varchar USING gin (i);
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ SELECT 'a'::citext >= 'B'::varchar AS t; -- varchar wins.
|
|||||||
t
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- A couple of longer examlpes to ensure that we don't get any issues with bad
|
-- A couple of longer examples to ensure that we don't get any issues with bad
|
||||||
-- conversions to char[] in the c code. Yes, I did do this.
|
-- conversions to char[] in the c code. Yes, I did do this.
|
||||||
SELECT 'aardvark'::citext = 'aardvark'::citext AS t;
|
SELECT 'aardvark'::citext = 'aardvark'::citext AS t;
|
||||||
t
|
t
|
||||||
@ -272,14 +272,14 @@ DETAIL: Key (name)=(A) already exists.
|
|||||||
INSERT INTO try (name) VALUES ('aB');
|
INSERT INTO try (name) VALUES ('aB');
|
||||||
ERROR: duplicate key value violates unique constraint "try_pkey"
|
ERROR: duplicate key value violates unique constraint "try_pkey"
|
||||||
DETAIL: Key (name)=(aB) already exists.
|
DETAIL: Key (name)=(aB) already exists.
|
||||||
-- Make sure that citext_smaller() and citext_lager() work properly.
|
-- Make sure that citext_smaller() and citext_larger() work properly.
|
||||||
SELECT citext_smaller( 'aa'::citext, 'ab'::citext ) = 'aa' AS t;
|
SELECT citext_smaller( 'ab'::citext, 'ac'::citext ) = 'ab' AS t;
|
||||||
t
|
t
|
||||||
---
|
---
|
||||||
t
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT citext_smaller( 'AAAA'::citext, 'bbbb'::citext ) = 'AAAA' AS t;
|
SELECT citext_smaller( 'ABC'::citext, 'bbbb'::citext ) = 'ABC' AS t;
|
||||||
t
|
t
|
||||||
---
|
---
|
||||||
t
|
t
|
||||||
@ -297,13 +297,13 @@ SELECT citext_smaller( 'aardvark'::citext, 'AARDVARK'::citext ) = 'AARDVARK' AS
|
|||||||
t
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT citext_larger( 'aa'::citext, 'ab'::citext ) = 'ab' AS t;
|
SELECT citext_larger( 'ab'::citext, 'ac'::citext ) = 'ac' AS t;
|
||||||
t
|
t
|
||||||
---
|
---
|
||||||
t
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT citext_larger( 'AAAA'::citext, 'bbbb'::citext ) = 'bbbb' AS t;
|
SELECT citext_larger( 'ABC'::citext, 'bbbb'::citext ) = 'bbbb' AS t;
|
||||||
t
|
t
|
||||||
---
|
---
|
||||||
t
|
t
|
||||||
@ -320,17 +320,16 @@ CREATE TEMP TABLE srt (
|
|||||||
name CITEXT
|
name CITEXT
|
||||||
);
|
);
|
||||||
INSERT INTO srt (name)
|
INSERT INTO srt (name)
|
||||||
VALUES ('aardvark'),
|
VALUES ('abb'),
|
||||||
('AAA'),
|
('ABA'),
|
||||||
('aba'),
|
|
||||||
('ABC'),
|
('ABC'),
|
||||||
('abd');
|
('abd');
|
||||||
-- Check the min() and max() aggregates, with and without index.
|
-- Check the min() and max() aggregates, with and without index.
|
||||||
set enable_seqscan = off;
|
set enable_seqscan = off;
|
||||||
SELECT MIN(name) AS "AAA" FROM srt;
|
SELECT MIN(name) AS "ABA" FROM srt;
|
||||||
AAA
|
ABA
|
||||||
-----
|
-----
|
||||||
AAA
|
ABA
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT MAX(name) AS abd FROM srt;
|
SELECT MAX(name) AS abd FROM srt;
|
||||||
@ -341,10 +340,10 @@ SELECT MAX(name) AS abd FROM srt;
|
|||||||
|
|
||||||
reset enable_seqscan;
|
reset enable_seqscan;
|
||||||
set enable_indexscan = off;
|
set enable_indexscan = off;
|
||||||
SELECT MIN(name) AS "AAA" FROM srt;
|
SELECT MIN(name) AS "ABA" FROM srt;
|
||||||
AAA
|
ABA
|
||||||
-----
|
-----
|
||||||
AAA
|
ABA
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT MAX(name) AS abd FROM srt;
|
SELECT MAX(name) AS abd FROM srt;
|
||||||
@ -358,161 +357,145 @@ reset enable_indexscan;
|
|||||||
set enable_seqscan = off;
|
set enable_seqscan = off;
|
||||||
SELECT name FROM srt ORDER BY name;
|
SELECT name FROM srt ORDER BY name;
|
||||||
name
|
name
|
||||||
----------
|
------
|
||||||
AAA
|
ABA
|
||||||
aardvark
|
abb
|
||||||
aba
|
|
||||||
ABC
|
ABC
|
||||||
abd
|
abd
|
||||||
(5 rows)
|
(4 rows)
|
||||||
|
|
||||||
reset enable_seqscan;
|
reset enable_seqscan;
|
||||||
set enable_indexscan = off;
|
set enable_indexscan = off;
|
||||||
SELECT name FROM srt ORDER BY name;
|
SELECT name FROM srt ORDER BY name;
|
||||||
name
|
name
|
||||||
----------
|
------
|
||||||
AAA
|
ABA
|
||||||
aardvark
|
abb
|
||||||
aba
|
|
||||||
ABC
|
ABC
|
||||||
abd
|
abd
|
||||||
(5 rows)
|
(4 rows)
|
||||||
|
|
||||||
reset enable_indexscan;
|
reset enable_indexscan;
|
||||||
-- Test assignment casts.
|
-- Test assignment casts.
|
||||||
SELECT LOWER(name) as aaa FROM srt WHERE name = 'AAA'::text;
|
SELECT LOWER(name) as aba FROM srt WHERE name = 'ABA'::text;
|
||||||
aaa
|
aba
|
||||||
-----
|
-----
|
||||||
aaa
|
aba
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT LOWER(name) as aaa FROM srt WHERE name = 'AAA'::varchar;
|
SELECT LOWER(name) as aba FROM srt WHERE name = 'ABA'::varchar;
|
||||||
aaa
|
aba
|
||||||
-----
|
-----
|
||||||
aaa
|
aba
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT LOWER(name) as aaa FROM srt WHERE name = 'AAA'::bpchar;
|
SELECT LOWER(name) as aba FROM srt WHERE name = 'ABA'::bpchar;
|
||||||
aaa
|
aba
|
||||||
-----
|
-----
|
||||||
aaa
|
aba
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT LOWER(name) as aaa FROM srt WHERE name = 'AAA';
|
SELECT LOWER(name) as aba FROM srt WHERE name = 'ABA';
|
||||||
aaa
|
aba
|
||||||
-----
|
-----
|
||||||
aaa
|
aba
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT LOWER(name) as aaa FROM srt WHERE name = 'AAA'::citext;
|
SELECT LOWER(name) as aba FROM srt WHERE name = 'ABA'::citext;
|
||||||
aaa
|
aba
|
||||||
-----
|
-----
|
||||||
aaa
|
aba
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- LIKE should be case-insensitive
|
-- LIKE should be case-insensitive
|
||||||
SELECT name FROM srt WHERE name LIKE '%a%' ORDER BY name;
|
SELECT name FROM srt WHERE name LIKE '%a%' ORDER BY name;
|
||||||
name
|
name
|
||||||
----------
|
------
|
||||||
AAA
|
ABA
|
||||||
aardvark
|
abb
|
||||||
aba
|
|
||||||
ABC
|
ABC
|
||||||
abd
|
abd
|
||||||
(5 rows)
|
(4 rows)
|
||||||
|
|
||||||
SELECT name FROM srt WHERE name NOT LIKE '%b%' ORDER BY name;
|
SELECT name FROM srt WHERE name NOT LIKE '%b%' ORDER BY name;
|
||||||
name
|
name
|
||||||
----------
|
------
|
||||||
AAA
|
(0 rows)
|
||||||
aardvark
|
|
||||||
(2 rows)
|
|
||||||
|
|
||||||
SELECT name FROM srt WHERE name LIKE '%A%' ORDER BY name;
|
SELECT name FROM srt WHERE name LIKE '%A%' ORDER BY name;
|
||||||
name
|
name
|
||||||
----------
|
------
|
||||||
AAA
|
ABA
|
||||||
aardvark
|
abb
|
||||||
aba
|
|
||||||
ABC
|
ABC
|
||||||
abd
|
abd
|
||||||
(5 rows)
|
(4 rows)
|
||||||
|
|
||||||
SELECT name FROM srt WHERE name NOT LIKE '%B%' ORDER BY name;
|
SELECT name FROM srt WHERE name NOT LIKE '%B%' ORDER BY name;
|
||||||
name
|
name
|
||||||
----------
|
------
|
||||||
AAA
|
(0 rows)
|
||||||
aardvark
|
|
||||||
(2 rows)
|
|
||||||
|
|
||||||
-- ~~ should be case-insensitive
|
-- ~~ should be case-insensitive
|
||||||
SELECT name FROM srt WHERE name ~~ '%a%' ORDER BY name;
|
SELECT name FROM srt WHERE name ~~ '%a%' ORDER BY name;
|
||||||
name
|
name
|
||||||
----------
|
------
|
||||||
AAA
|
ABA
|
||||||
aardvark
|
abb
|
||||||
aba
|
|
||||||
ABC
|
ABC
|
||||||
abd
|
abd
|
||||||
(5 rows)
|
(4 rows)
|
||||||
|
|
||||||
SELECT name FROM srt WHERE name !~~ '%b%' ORDER BY name;
|
SELECT name FROM srt WHERE name !~~ '%b%' ORDER BY name;
|
||||||
name
|
name
|
||||||
----------
|
------
|
||||||
AAA
|
(0 rows)
|
||||||
aardvark
|
|
||||||
(2 rows)
|
|
||||||
|
|
||||||
SELECT name FROM srt WHERE name ~~ '%A%' ORDER BY name;
|
SELECT name FROM srt WHERE name ~~ '%A%' ORDER BY name;
|
||||||
name
|
name
|
||||||
----------
|
------
|
||||||
AAA
|
ABA
|
||||||
aardvark
|
abb
|
||||||
aba
|
|
||||||
ABC
|
ABC
|
||||||
abd
|
abd
|
||||||
(5 rows)
|
(4 rows)
|
||||||
|
|
||||||
SELECT name FROM srt WHERE name !~~ '%B%' ORDER BY name;
|
SELECT name FROM srt WHERE name !~~ '%B%' ORDER BY name;
|
||||||
name
|
name
|
||||||
----------
|
------
|
||||||
AAA
|
(0 rows)
|
||||||
aardvark
|
|
||||||
(2 rows)
|
|
||||||
|
|
||||||
-- ~ should be case-insensitive
|
-- ~ should be case-insensitive
|
||||||
SELECT name FROM srt WHERE name ~ '^a' ORDER BY name;
|
SELECT name FROM srt WHERE name ~ '^a' ORDER BY name;
|
||||||
name
|
name
|
||||||
----------
|
------
|
||||||
AAA
|
ABA
|
||||||
aardvark
|
abb
|
||||||
aba
|
|
||||||
ABC
|
ABC
|
||||||
abd
|
abd
|
||||||
(5 rows)
|
(4 rows)
|
||||||
|
|
||||||
SELECT name FROM srt WHERE name !~ 'a$' ORDER BY name;
|
SELECT name FROM srt WHERE name !~ 'a$' ORDER BY name;
|
||||||
name
|
name
|
||||||
----------
|
------
|
||||||
aardvark
|
abb
|
||||||
ABC
|
ABC
|
||||||
abd
|
abd
|
||||||
(3 rows)
|
(3 rows)
|
||||||
|
|
||||||
SELECT name FROM srt WHERE name ~ '^A' ORDER BY name;
|
SELECT name FROM srt WHERE name ~ '^A' ORDER BY name;
|
||||||
name
|
name
|
||||||
----------
|
------
|
||||||
AAA
|
ABA
|
||||||
aardvark
|
abb
|
||||||
aba
|
|
||||||
ABC
|
ABC
|
||||||
abd
|
abd
|
||||||
(5 rows)
|
(4 rows)
|
||||||
|
|
||||||
SELECT name FROM srt WHERE name !~ 'A$' ORDER BY name;
|
SELECT name FROM srt WHERE name !~ 'A$' ORDER BY name;
|
||||||
name
|
name
|
||||||
----------
|
------
|
||||||
aardvark
|
abb
|
||||||
ABC
|
ABC
|
||||||
abd
|
abd
|
||||||
(3 rows)
|
(3 rows)
|
||||||
@ -521,16 +504,14 @@ SELECT name FROM srt WHERE name !~ 'A$' ORDER BY name;
|
|||||||
SELECT name FROM srt WHERE name SIMILAR TO '%a.*';
|
SELECT name FROM srt WHERE name SIMILAR TO '%a.*';
|
||||||
name
|
name
|
||||||
------
|
------
|
||||||
AAA
|
ABA
|
||||||
aba
|
(1 row)
|
||||||
(2 rows)
|
|
||||||
|
|
||||||
SELECT name FROM srt WHERE name SIMILAR TO '%A.*';
|
SELECT name FROM srt WHERE name SIMILAR TO '%A.*';
|
||||||
name
|
name
|
||||||
------
|
------
|
||||||
AAA
|
ABA
|
||||||
aba
|
(1 row)
|
||||||
(2 rows)
|
|
||||||
|
|
||||||
-- Explicit casts.
|
-- Explicit casts.
|
||||||
SELECT true::citext = 'true' AS t;
|
SELECT true::citext = 'true' AS t;
|
||||||
@ -1502,8 +1483,7 @@ SELECT bit_length( name ) = bit_length( name::text ) AS t FROM srt;
|
|||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
(4 rows)
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
SELECT textlen( name ) = textlen( name::text ) AS t FROM srt;
|
SELECT textlen( name ) = textlen( name::text ) AS t FROM srt;
|
||||||
t
|
t
|
||||||
@ -1512,8 +1492,7 @@ SELECT textlen( name ) = textlen( name::text ) AS t FROM srt;
|
|||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
(4 rows)
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
SELECT char_length( name ) = char_length( name::text ) AS t FROM srt;
|
SELECT char_length( name ) = char_length( name::text ) AS t FROM srt;
|
||||||
t
|
t
|
||||||
@ -1522,8 +1501,7 @@ SELECT char_length( name ) = char_length( name::text ) AS t FROM srt;
|
|||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
(4 rows)
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
SELECT lower( name ) = lower( name::text ) AS t FROM srt;
|
SELECT lower( name ) = lower( name::text ) AS t FROM srt;
|
||||||
t
|
t
|
||||||
@ -1532,8 +1510,7 @@ SELECT lower( name ) = lower( name::text ) AS t FROM srt;
|
|||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
(4 rows)
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
SELECT octet_length( name ) = octet_length( name::text ) AS t FROM srt;
|
SELECT octet_length( name ) = octet_length( name::text ) AS t FROM srt;
|
||||||
t
|
t
|
||||||
@ -1542,8 +1519,7 @@ SELECT octet_length( name ) = octet_length( name::text ) AS t FROM srt;
|
|||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
(4 rows)
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
SELECT overlay( name placing 'hom' from 2 for 4) = overlay( name::text placing 'hom' from 2 for 4) AS t FROM srt;
|
SELECT overlay( name placing 'hom' from 2 for 4) = overlay( name::text placing 'hom' from 2 for 4) AS t FROM srt;
|
||||||
t
|
t
|
||||||
@ -1552,8 +1528,7 @@ SELECT overlay( name placing 'hom' from 2 for 4) = overlay( name::text placing '
|
|||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
(4 rows)
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
SELECT position( 'a' IN name ) = position( 'a' IN name::text ) AS t FROM srt;
|
SELECT position( 'a' IN name ) = position( 'a' IN name::text ) AS t FROM srt;
|
||||||
t
|
t
|
||||||
@ -1562,8 +1537,7 @@ SELECT position( 'a' IN name ) = position( 'a' IN name::text ) AS t FROM srt;
|
|||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
(4 rows)
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
SELECT substr('alphabet'::citext, 3) = 'phabet' AS t;
|
SELECT substr('alphabet'::citext, 3) = 'phabet' AS t;
|
||||||
t
|
t
|
||||||
@ -1644,8 +1618,7 @@ SELECT upper( name ) = upper( name::text ) AS t FROM srt;
|
|||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
(4 rows)
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
-- Table 9-6. Other String Functions.
|
-- Table 9-6. Other String Functions.
|
||||||
SELECT ascii( name ) = ascii( name::text ) AS t FROM srt;
|
SELECT ascii( name ) = ascii( name::text ) AS t FROM srt;
|
||||||
@ -1655,8 +1628,7 @@ SELECT ascii( name ) = ascii( name::text ) AS t FROM srt;
|
|||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
(4 rows)
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
SELECT btrim(' trim'::citext ) = 'trim' AS t;
|
SELECT btrim(' trim'::citext ) = 'trim' AS t;
|
||||||
t
|
t
|
||||||
@ -1697,8 +1669,7 @@ SELECT convert_to( name, 'ISO-8859-1' ) = convert_to( name::text, 'ISO-8859-1' )
|
|||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
(4 rows)
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
SELECT decode('MTIzAAE='::citext, 'base64') = decode('MTIzAAE='::text, 'base64') AS t;
|
SELECT decode('MTIzAAE='::citext, 'base64') = decode('MTIzAAE='::text, 'base64') AS t;
|
||||||
t
|
t
|
||||||
@ -1720,8 +1691,7 @@ SELECT length( name ) = length( name::text ) AS t FROM srt;
|
|||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
(4 rows)
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
SELECT lpad('hi'::citext, 5 ) = ' hi' AS t;
|
SELECT lpad('hi'::citext, 5 ) = ' hi' AS t;
|
||||||
t
|
t
|
||||||
@ -1778,8 +1748,7 @@ SELECT md5( name ) = md5( name::text ) AS t FROM srt;
|
|||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
(4 rows)
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
-- pg_client_encoding() takes no args and returns name.
|
-- pg_client_encoding() takes no args and returns name.
|
||||||
SELECT quote_ident( name ) = quote_ident( name::text ) AS t FROM srt;
|
SELECT quote_ident( name ) = quote_ident( name::text ) AS t FROM srt;
|
||||||
@ -1789,8 +1758,7 @@ SELECT quote_ident( name ) = quote_ident( name::text ) AS t FROM srt;
|
|||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
(4 rows)
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
SELECT quote_literal( name ) = quote_literal( name::text ) AS t FROM srt;
|
SELECT quote_literal( name ) = quote_literal( name::text ) AS t FROM srt;
|
||||||
t
|
t
|
||||||
@ -1799,8 +1767,7 @@ SELECT quote_literal( name ) = quote_literal( name::text ) AS t FROM srt;
|
|||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
(4 rows)
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
SELECT regexp_matches('foobarbequebaz'::citext, '(bar)(beque)') = ARRAY[ 'bar', 'beque' ] AS t;
|
SELECT regexp_matches('foobarbequebaz'::citext, '(bar)(beque)') = ARRAY[ 'bar', 'beque' ] AS t;
|
||||||
t
|
t
|
||||||
@ -2098,37 +2065,37 @@ SELECT split_part('abcTdefTghi', 't'::citext, 2) = 'def' AS t;
|
|||||||
t
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT strpos('high'::citext, 'ig' ) = 2 AS t;
|
SELECT strpos('high'::citext, 'gh' ) = 3 AS t;
|
||||||
t
|
t
|
||||||
---
|
---
|
||||||
t
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT strpos('high', 'ig'::citext) = 2 AS t;
|
SELECT strpos('high', 'gh'::citext) = 3 AS t;
|
||||||
t
|
t
|
||||||
---
|
---
|
||||||
t
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT strpos('high'::citext, 'ig'::citext) = 2 AS t;
|
SELECT strpos('high'::citext, 'gh'::citext) = 3 AS t;
|
||||||
t
|
t
|
||||||
---
|
---
|
||||||
t
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT strpos('high'::citext, 'IG' ) = 2 AS t;
|
SELECT strpos('high'::citext, 'GH' ) = 3 AS t;
|
||||||
t
|
t
|
||||||
---
|
---
|
||||||
t
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT strpos('high', 'IG'::citext) = 2 AS t;
|
SELECT strpos('high', 'GH'::citext) = 3 AS t;
|
||||||
t
|
t
|
||||||
---
|
---
|
||||||
t
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT strpos('high'::citext, 'IG'::citext) = 2 AS t;
|
SELECT strpos('high'::citext, 'GH'::citext) = 3 AS t;
|
||||||
t
|
t
|
||||||
---
|
---
|
||||||
t
|
t
|
||||||
@ -2262,8 +2229,7 @@ SELECT like_escape( name, '' ) = like_escape( name::text, '' ) AS t FROM srt;
|
|||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
(4 rows)
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
SELECT like_escape( name::text, ''::citext ) = like_escape( name::text, '' ) AS t FROM srt;
|
SELECT like_escape( name::text, ''::citext ) = like_escape( name::text, '' ) AS t FROM srt;
|
||||||
t
|
t
|
||||||
@ -2272,6 +2238,5 @@ SELECT like_escape( name::text, ''::citext ) = like_escape( name::text, '' ) AS
|
|||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
(4 rows)
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ SELECT 'a'::citext >= 'B'::varchar AS t; -- varchar wins.
|
|||||||
f
|
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 examples to ensure that we don't get any issues with bad
|
||||||
-- conversions to char[] in the c code. Yes, I did do this.
|
-- conversions to char[] in the c code. Yes, I did do this.
|
||||||
SELECT 'aardvark'::citext = 'aardvark'::citext AS t;
|
SELECT 'aardvark'::citext = 'aardvark'::citext AS t;
|
||||||
t
|
t
|
||||||
@ -272,14 +272,14 @@ DETAIL: Key (name)=(A) already exists.
|
|||||||
INSERT INTO try (name) VALUES ('aB');
|
INSERT INTO try (name) VALUES ('aB');
|
||||||
ERROR: duplicate key value violates unique constraint "try_pkey"
|
ERROR: duplicate key value violates unique constraint "try_pkey"
|
||||||
DETAIL: Key (name)=(aB) already exists.
|
DETAIL: Key (name)=(aB) already exists.
|
||||||
-- Make sure that citext_smaller() and citext_lager() work properly.
|
-- Make sure that citext_smaller() and citext_larger() work properly.
|
||||||
SELECT citext_smaller( 'aa'::citext, 'ab'::citext ) = 'aa' AS t;
|
SELECT citext_smaller( 'ab'::citext, 'ac'::citext ) = 'ab' AS t;
|
||||||
t
|
t
|
||||||
---
|
---
|
||||||
t
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT citext_smaller( 'AAAA'::citext, 'bbbb'::citext ) = 'AAAA' AS t;
|
SELECT citext_smaller( 'ABC'::citext, 'bbbb'::citext ) = 'ABC' AS t;
|
||||||
t
|
t
|
||||||
---
|
---
|
||||||
t
|
t
|
||||||
@ -297,13 +297,13 @@ SELECT citext_smaller( 'aardvark'::citext, 'AARDVARK'::citext ) = 'AARDVARK' AS
|
|||||||
t
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT citext_larger( 'aa'::citext, 'ab'::citext ) = 'ab' AS t;
|
SELECT citext_larger( 'ab'::citext, 'ac'::citext ) = 'ac' AS t;
|
||||||
t
|
t
|
||||||
---
|
---
|
||||||
t
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT citext_larger( 'AAAA'::citext, 'bbbb'::citext ) = 'bbbb' AS t;
|
SELECT citext_larger( 'ABC'::citext, 'bbbb'::citext ) = 'bbbb' AS t;
|
||||||
t
|
t
|
||||||
---
|
---
|
||||||
t
|
t
|
||||||
@ -320,17 +320,16 @@ CREATE TEMP TABLE srt (
|
|||||||
name CITEXT
|
name CITEXT
|
||||||
);
|
);
|
||||||
INSERT INTO srt (name)
|
INSERT INTO srt (name)
|
||||||
VALUES ('aardvark'),
|
VALUES ('abb'),
|
||||||
('AAA'),
|
('ABA'),
|
||||||
('aba'),
|
|
||||||
('ABC'),
|
('ABC'),
|
||||||
('abd');
|
('abd');
|
||||||
-- Check the min() and max() aggregates, with and without index.
|
-- Check the min() and max() aggregates, with and without index.
|
||||||
set enable_seqscan = off;
|
set enable_seqscan = off;
|
||||||
SELECT MIN(name) AS "AAA" FROM srt;
|
SELECT MIN(name) AS "ABA" FROM srt;
|
||||||
AAA
|
ABA
|
||||||
-----
|
-----
|
||||||
AAA
|
ABA
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT MAX(name) AS abd FROM srt;
|
SELECT MAX(name) AS abd FROM srt;
|
||||||
@ -341,10 +340,10 @@ SELECT MAX(name) AS abd FROM srt;
|
|||||||
|
|
||||||
reset enable_seqscan;
|
reset enable_seqscan;
|
||||||
set enable_indexscan = off;
|
set enable_indexscan = off;
|
||||||
SELECT MIN(name) AS "AAA" FROM srt;
|
SELECT MIN(name) AS "ABA" FROM srt;
|
||||||
AAA
|
ABA
|
||||||
-----
|
-----
|
||||||
AAA
|
ABA
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT MAX(name) AS abd FROM srt;
|
SELECT MAX(name) AS abd FROM srt;
|
||||||
@ -358,161 +357,145 @@ reset enable_indexscan;
|
|||||||
set enable_seqscan = off;
|
set enable_seqscan = off;
|
||||||
SELECT name FROM srt ORDER BY name;
|
SELECT name FROM srt ORDER BY name;
|
||||||
name
|
name
|
||||||
----------
|
------
|
||||||
AAA
|
ABA
|
||||||
aardvark
|
abb
|
||||||
aba
|
|
||||||
ABC
|
ABC
|
||||||
abd
|
abd
|
||||||
(5 rows)
|
(4 rows)
|
||||||
|
|
||||||
reset enable_seqscan;
|
reset enable_seqscan;
|
||||||
set enable_indexscan = off;
|
set enable_indexscan = off;
|
||||||
SELECT name FROM srt ORDER BY name;
|
SELECT name FROM srt ORDER BY name;
|
||||||
name
|
name
|
||||||
----------
|
------
|
||||||
AAA
|
ABA
|
||||||
aardvark
|
abb
|
||||||
aba
|
|
||||||
ABC
|
ABC
|
||||||
abd
|
abd
|
||||||
(5 rows)
|
(4 rows)
|
||||||
|
|
||||||
reset enable_indexscan;
|
reset enable_indexscan;
|
||||||
-- Test assignment casts.
|
-- Test assignment casts.
|
||||||
SELECT LOWER(name) as aaa FROM srt WHERE name = 'AAA'::text;
|
SELECT LOWER(name) as aba FROM srt WHERE name = 'ABA'::text;
|
||||||
aaa
|
aba
|
||||||
-----
|
-----
|
||||||
aaa
|
aba
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT LOWER(name) as aaa FROM srt WHERE name = 'AAA'::varchar;
|
SELECT LOWER(name) as aba FROM srt WHERE name = 'ABA'::varchar;
|
||||||
aaa
|
aba
|
||||||
-----
|
-----
|
||||||
aaa
|
aba
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT LOWER(name) as aaa FROM srt WHERE name = 'AAA'::bpchar;
|
SELECT LOWER(name) as aba FROM srt WHERE name = 'ABA'::bpchar;
|
||||||
aaa
|
aba
|
||||||
-----
|
-----
|
||||||
aaa
|
aba
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT LOWER(name) as aaa FROM srt WHERE name = 'AAA';
|
SELECT LOWER(name) as aba FROM srt WHERE name = 'ABA';
|
||||||
aaa
|
aba
|
||||||
-----
|
-----
|
||||||
aaa
|
aba
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT LOWER(name) as aaa FROM srt WHERE name = 'AAA'::citext;
|
SELECT LOWER(name) as aba FROM srt WHERE name = 'ABA'::citext;
|
||||||
aaa
|
aba
|
||||||
-----
|
-----
|
||||||
aaa
|
aba
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- LIKE should be case-insensitive
|
-- LIKE should be case-insensitive
|
||||||
SELECT name FROM srt WHERE name LIKE '%a%' ORDER BY name;
|
SELECT name FROM srt WHERE name LIKE '%a%' ORDER BY name;
|
||||||
name
|
name
|
||||||
----------
|
------
|
||||||
AAA
|
ABA
|
||||||
aardvark
|
abb
|
||||||
aba
|
|
||||||
ABC
|
ABC
|
||||||
abd
|
abd
|
||||||
(5 rows)
|
(4 rows)
|
||||||
|
|
||||||
SELECT name FROM srt WHERE name NOT LIKE '%b%' ORDER BY name;
|
SELECT name FROM srt WHERE name NOT LIKE '%b%' ORDER BY name;
|
||||||
name
|
name
|
||||||
----------
|
------
|
||||||
AAA
|
(0 rows)
|
||||||
aardvark
|
|
||||||
(2 rows)
|
|
||||||
|
|
||||||
SELECT name FROM srt WHERE name LIKE '%A%' ORDER BY name;
|
SELECT name FROM srt WHERE name LIKE '%A%' ORDER BY name;
|
||||||
name
|
name
|
||||||
----------
|
------
|
||||||
AAA
|
ABA
|
||||||
aardvark
|
abb
|
||||||
aba
|
|
||||||
ABC
|
ABC
|
||||||
abd
|
abd
|
||||||
(5 rows)
|
(4 rows)
|
||||||
|
|
||||||
SELECT name FROM srt WHERE name NOT LIKE '%B%' ORDER BY name;
|
SELECT name FROM srt WHERE name NOT LIKE '%B%' ORDER BY name;
|
||||||
name
|
name
|
||||||
----------
|
------
|
||||||
AAA
|
(0 rows)
|
||||||
aardvark
|
|
||||||
(2 rows)
|
|
||||||
|
|
||||||
-- ~~ should be case-insensitive
|
-- ~~ should be case-insensitive
|
||||||
SELECT name FROM srt WHERE name ~~ '%a%' ORDER BY name;
|
SELECT name FROM srt WHERE name ~~ '%a%' ORDER BY name;
|
||||||
name
|
name
|
||||||
----------
|
------
|
||||||
AAA
|
ABA
|
||||||
aardvark
|
abb
|
||||||
aba
|
|
||||||
ABC
|
ABC
|
||||||
abd
|
abd
|
||||||
(5 rows)
|
(4 rows)
|
||||||
|
|
||||||
SELECT name FROM srt WHERE name !~~ '%b%' ORDER BY name;
|
SELECT name FROM srt WHERE name !~~ '%b%' ORDER BY name;
|
||||||
name
|
name
|
||||||
----------
|
------
|
||||||
AAA
|
(0 rows)
|
||||||
aardvark
|
|
||||||
(2 rows)
|
|
||||||
|
|
||||||
SELECT name FROM srt WHERE name ~~ '%A%' ORDER BY name;
|
SELECT name FROM srt WHERE name ~~ '%A%' ORDER BY name;
|
||||||
name
|
name
|
||||||
----------
|
------
|
||||||
AAA
|
ABA
|
||||||
aardvark
|
abb
|
||||||
aba
|
|
||||||
ABC
|
ABC
|
||||||
abd
|
abd
|
||||||
(5 rows)
|
(4 rows)
|
||||||
|
|
||||||
SELECT name FROM srt WHERE name !~~ '%B%' ORDER BY name;
|
SELECT name FROM srt WHERE name !~~ '%B%' ORDER BY name;
|
||||||
name
|
name
|
||||||
----------
|
------
|
||||||
AAA
|
(0 rows)
|
||||||
aardvark
|
|
||||||
(2 rows)
|
|
||||||
|
|
||||||
-- ~ should be case-insensitive
|
-- ~ should be case-insensitive
|
||||||
SELECT name FROM srt WHERE name ~ '^a' ORDER BY name;
|
SELECT name FROM srt WHERE name ~ '^a' ORDER BY name;
|
||||||
name
|
name
|
||||||
----------
|
------
|
||||||
AAA
|
ABA
|
||||||
aardvark
|
abb
|
||||||
aba
|
|
||||||
ABC
|
ABC
|
||||||
abd
|
abd
|
||||||
(5 rows)
|
(4 rows)
|
||||||
|
|
||||||
SELECT name FROM srt WHERE name !~ 'a$' ORDER BY name;
|
SELECT name FROM srt WHERE name !~ 'a$' ORDER BY name;
|
||||||
name
|
name
|
||||||
----------
|
------
|
||||||
aardvark
|
abb
|
||||||
ABC
|
ABC
|
||||||
abd
|
abd
|
||||||
(3 rows)
|
(3 rows)
|
||||||
|
|
||||||
SELECT name FROM srt WHERE name ~ '^A' ORDER BY name;
|
SELECT name FROM srt WHERE name ~ '^A' ORDER BY name;
|
||||||
name
|
name
|
||||||
----------
|
------
|
||||||
AAA
|
ABA
|
||||||
aardvark
|
abb
|
||||||
aba
|
|
||||||
ABC
|
ABC
|
||||||
abd
|
abd
|
||||||
(5 rows)
|
(4 rows)
|
||||||
|
|
||||||
SELECT name FROM srt WHERE name !~ 'A$' ORDER BY name;
|
SELECT name FROM srt WHERE name !~ 'A$' ORDER BY name;
|
||||||
name
|
name
|
||||||
----------
|
------
|
||||||
aardvark
|
abb
|
||||||
ABC
|
ABC
|
||||||
abd
|
abd
|
||||||
(3 rows)
|
(3 rows)
|
||||||
@ -521,16 +504,14 @@ SELECT name FROM srt WHERE name !~ 'A$' ORDER BY name;
|
|||||||
SELECT name FROM srt WHERE name SIMILAR TO '%a.*';
|
SELECT name FROM srt WHERE name SIMILAR TO '%a.*';
|
||||||
name
|
name
|
||||||
------
|
------
|
||||||
AAA
|
ABA
|
||||||
aba
|
(1 row)
|
||||||
(2 rows)
|
|
||||||
|
|
||||||
SELECT name FROM srt WHERE name SIMILAR TO '%A.*';
|
SELECT name FROM srt WHERE name SIMILAR TO '%A.*';
|
||||||
name
|
name
|
||||||
------
|
------
|
||||||
AAA
|
ABA
|
||||||
aba
|
(1 row)
|
||||||
(2 rows)
|
|
||||||
|
|
||||||
-- Explicit casts.
|
-- Explicit casts.
|
||||||
SELECT true::citext = 'true' AS t;
|
SELECT true::citext = 'true' AS t;
|
||||||
@ -1502,8 +1483,7 @@ SELECT bit_length( name ) = bit_length( name::text ) AS t FROM srt;
|
|||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
(4 rows)
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
SELECT textlen( name ) = textlen( name::text ) AS t FROM srt;
|
SELECT textlen( name ) = textlen( name::text ) AS t FROM srt;
|
||||||
t
|
t
|
||||||
@ -1512,8 +1492,7 @@ SELECT textlen( name ) = textlen( name::text ) AS t FROM srt;
|
|||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
(4 rows)
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
SELECT char_length( name ) = char_length( name::text ) AS t FROM srt;
|
SELECT char_length( name ) = char_length( name::text ) AS t FROM srt;
|
||||||
t
|
t
|
||||||
@ -1522,8 +1501,7 @@ SELECT char_length( name ) = char_length( name::text ) AS t FROM srt;
|
|||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
(4 rows)
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
SELECT lower( name ) = lower( name::text ) AS t FROM srt;
|
SELECT lower( name ) = lower( name::text ) AS t FROM srt;
|
||||||
t
|
t
|
||||||
@ -1532,8 +1510,7 @@ SELECT lower( name ) = lower( name::text ) AS t FROM srt;
|
|||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
(4 rows)
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
SELECT octet_length( name ) = octet_length( name::text ) AS t FROM srt;
|
SELECT octet_length( name ) = octet_length( name::text ) AS t FROM srt;
|
||||||
t
|
t
|
||||||
@ -1542,8 +1519,7 @@ SELECT octet_length( name ) = octet_length( name::text ) AS t FROM srt;
|
|||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
(4 rows)
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
SELECT overlay( name placing 'hom' from 2 for 4) = overlay( name::text placing 'hom' from 2 for 4) AS t FROM srt;
|
SELECT overlay( name placing 'hom' from 2 for 4) = overlay( name::text placing 'hom' from 2 for 4) AS t FROM srt;
|
||||||
t
|
t
|
||||||
@ -1552,8 +1528,7 @@ SELECT overlay( name placing 'hom' from 2 for 4) = overlay( name::text placing '
|
|||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
(4 rows)
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
SELECT position( 'a' IN name ) = position( 'a' IN name::text ) AS t FROM srt;
|
SELECT position( 'a' IN name ) = position( 'a' IN name::text ) AS t FROM srt;
|
||||||
t
|
t
|
||||||
@ -1562,8 +1537,7 @@ SELECT position( 'a' IN name ) = position( 'a' IN name::text ) AS t FROM srt;
|
|||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
(4 rows)
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
SELECT substr('alphabet'::citext, 3) = 'phabet' AS t;
|
SELECT substr('alphabet'::citext, 3) = 'phabet' AS t;
|
||||||
t
|
t
|
||||||
@ -1644,8 +1618,7 @@ SELECT upper( name ) = upper( name::text ) AS t FROM srt;
|
|||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
(4 rows)
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
-- Table 9-6. Other String Functions.
|
-- Table 9-6. Other String Functions.
|
||||||
SELECT ascii( name ) = ascii( name::text ) AS t FROM srt;
|
SELECT ascii( name ) = ascii( name::text ) AS t FROM srt;
|
||||||
@ -1655,8 +1628,7 @@ SELECT ascii( name ) = ascii( name::text ) AS t FROM srt;
|
|||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
(4 rows)
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
SELECT btrim(' trim'::citext ) = 'trim' AS t;
|
SELECT btrim(' trim'::citext ) = 'trim' AS t;
|
||||||
t
|
t
|
||||||
@ -1697,8 +1669,7 @@ SELECT convert_to( name, 'ISO-8859-1' ) = convert_to( name::text, 'ISO-8859-1' )
|
|||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
(4 rows)
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
SELECT decode('MTIzAAE='::citext, 'base64') = decode('MTIzAAE='::text, 'base64') AS t;
|
SELECT decode('MTIzAAE='::citext, 'base64') = decode('MTIzAAE='::text, 'base64') AS t;
|
||||||
t
|
t
|
||||||
@ -1720,8 +1691,7 @@ SELECT length( name ) = length( name::text ) AS t FROM srt;
|
|||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
(4 rows)
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
SELECT lpad('hi'::citext, 5 ) = ' hi' AS t;
|
SELECT lpad('hi'::citext, 5 ) = ' hi' AS t;
|
||||||
t
|
t
|
||||||
@ -1778,8 +1748,7 @@ SELECT md5( name ) = md5( name::text ) AS t FROM srt;
|
|||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
(4 rows)
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
-- pg_client_encoding() takes no args and returns name.
|
-- pg_client_encoding() takes no args and returns name.
|
||||||
SELECT quote_ident( name ) = quote_ident( name::text ) AS t FROM srt;
|
SELECT quote_ident( name ) = quote_ident( name::text ) AS t FROM srt;
|
||||||
@ -1789,8 +1758,7 @@ SELECT quote_ident( name ) = quote_ident( name::text ) AS t FROM srt;
|
|||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
(4 rows)
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
SELECT quote_literal( name ) = quote_literal( name::text ) AS t FROM srt;
|
SELECT quote_literal( name ) = quote_literal( name::text ) AS t FROM srt;
|
||||||
t
|
t
|
||||||
@ -1799,8 +1767,7 @@ SELECT quote_literal( name ) = quote_literal( name::text ) AS t FROM srt;
|
|||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
(4 rows)
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
SELECT regexp_matches('foobarbequebaz'::citext, '(bar)(beque)') = ARRAY[ 'bar', 'beque' ] AS t;
|
SELECT regexp_matches('foobarbequebaz'::citext, '(bar)(beque)') = ARRAY[ 'bar', 'beque' ] AS t;
|
||||||
t
|
t
|
||||||
@ -2098,37 +2065,37 @@ SELECT split_part('abcTdefTghi', 't'::citext, 2) = 'def' AS t;
|
|||||||
t
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT strpos('high'::citext, 'ig' ) = 2 AS t;
|
SELECT strpos('high'::citext, 'gh' ) = 3 AS t;
|
||||||
t
|
t
|
||||||
---
|
---
|
||||||
t
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT strpos('high', 'ig'::citext) = 2 AS t;
|
SELECT strpos('high', 'gh'::citext) = 3 AS t;
|
||||||
t
|
t
|
||||||
---
|
---
|
||||||
t
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT strpos('high'::citext, 'ig'::citext) = 2 AS t;
|
SELECT strpos('high'::citext, 'gh'::citext) = 3 AS t;
|
||||||
t
|
t
|
||||||
---
|
---
|
||||||
t
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT strpos('high'::citext, 'IG' ) = 2 AS t;
|
SELECT strpos('high'::citext, 'GH' ) = 3 AS t;
|
||||||
t
|
t
|
||||||
---
|
---
|
||||||
t
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT strpos('high', 'IG'::citext) = 2 AS t;
|
SELECT strpos('high', 'GH'::citext) = 3 AS t;
|
||||||
t
|
t
|
||||||
---
|
---
|
||||||
t
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT strpos('high'::citext, 'IG'::citext) = 2 AS t;
|
SELECT strpos('high'::citext, 'GH'::citext) = 3 AS t;
|
||||||
t
|
t
|
||||||
---
|
---
|
||||||
t
|
t
|
||||||
@ -2262,8 +2229,7 @@ SELECT like_escape( name, '' ) = like_escape( name::text, '' ) AS t FROM srt;
|
|||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
(4 rows)
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
SELECT like_escape( name::text, ''::citext ) = like_escape( name::text, '' ) AS t FROM srt;
|
SELECT like_escape( name::text, ''::citext ) = like_escape( name::text, '' ) AS t FROM srt;
|
||||||
t
|
t
|
||||||
@ -2272,6 +2238,5 @@ SELECT like_escape( name::text, ''::citext ) = like_escape( name::text, '' ) AS
|
|||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
t
|
||||||
t
|
(4 rows)
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ SELECT 'B'::citext <= 'a'::varchar AS t; -- varchar wins.
|
|||||||
SELECT 'a'::citext > 'B'::varchar AS t; -- varchar wins.
|
SELECT 'a'::citext > 'B'::varchar AS t; -- varchar wins.
|
||||||
SELECT 'a'::citext >= 'B'::varchar AS t; -- varchar wins.
|
SELECT 'a'::citext >= 'B'::varchar AS t; -- varchar wins.
|
||||||
|
|
||||||
-- A couple of longer examlpes to ensure that we don't get any issues with bad
|
-- A couple of longer examples to ensure that we don't get any issues with bad
|
||||||
-- conversions to char[] in the c code. Yes, I did do this.
|
-- conversions to char[] in the c code. Yes, I did do this.
|
||||||
|
|
||||||
SELECT 'aardvark'::citext = 'aardvark'::citext AS t;
|
SELECT 'aardvark'::citext = 'aardvark'::citext AS t;
|
||||||
@ -104,14 +104,14 @@ INSERT INTO try (name) VALUES ('a');
|
|||||||
INSERT INTO try (name) VALUES ('A');
|
INSERT INTO try (name) VALUES ('A');
|
||||||
INSERT INTO try (name) VALUES ('aB');
|
INSERT INTO try (name) VALUES ('aB');
|
||||||
|
|
||||||
-- Make sure that citext_smaller() and citext_lager() work properly.
|
-- Make sure that citext_smaller() and citext_larger() work properly.
|
||||||
SELECT citext_smaller( 'aa'::citext, 'ab'::citext ) = 'aa' AS t;
|
SELECT citext_smaller( 'ab'::citext, 'ac'::citext ) = 'ab' AS t;
|
||||||
SELECT citext_smaller( 'AAAA'::citext, 'bbbb'::citext ) = 'AAAA' AS t;
|
SELECT citext_smaller( 'ABC'::citext, 'bbbb'::citext ) = 'ABC' AS t;
|
||||||
SELECT citext_smaller( 'aardvark'::citext, 'Aaba'::citext ) = 'Aaba' AS t;
|
SELECT citext_smaller( 'aardvark'::citext, 'Aaba'::citext ) = 'Aaba' AS t;
|
||||||
SELECT citext_smaller( 'aardvark'::citext, 'AARDVARK'::citext ) = 'AARDVARK' AS t;
|
SELECT citext_smaller( 'aardvark'::citext, 'AARDVARK'::citext ) = 'AARDVARK' AS t;
|
||||||
|
|
||||||
SELECT citext_larger( 'aa'::citext, 'ab'::citext ) = 'ab' AS t;
|
SELECT citext_larger( 'ab'::citext, 'ac'::citext ) = 'ac' AS t;
|
||||||
SELECT citext_larger( 'AAAA'::citext, 'bbbb'::citext ) = 'bbbb' AS t;
|
SELECT citext_larger( 'ABC'::citext, 'bbbb'::citext ) = 'bbbb' AS t;
|
||||||
SELECT citext_larger( 'aardvark'::citext, 'Aaba'::citext ) = 'aardvark' AS t;
|
SELECT citext_larger( 'aardvark'::citext, 'Aaba'::citext ) = 'aardvark' AS t;
|
||||||
|
|
||||||
-- Test aggregate functions and sort ordering
|
-- Test aggregate functions and sort ordering
|
||||||
@ -121,19 +121,18 @@ CREATE TEMP TABLE srt (
|
|||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO srt (name)
|
INSERT INTO srt (name)
|
||||||
VALUES ('aardvark'),
|
VALUES ('abb'),
|
||||||
('AAA'),
|
('ABA'),
|
||||||
('aba'),
|
|
||||||
('ABC'),
|
('ABC'),
|
||||||
('abd');
|
('abd');
|
||||||
|
|
||||||
-- Check the min() and max() aggregates, with and without index.
|
-- Check the min() and max() aggregates, with and without index.
|
||||||
set enable_seqscan = off;
|
set enable_seqscan = off;
|
||||||
SELECT MIN(name) AS "AAA" FROM srt;
|
SELECT MIN(name) AS "ABA" FROM srt;
|
||||||
SELECT MAX(name) AS abd FROM srt;
|
SELECT MAX(name) AS abd FROM srt;
|
||||||
reset enable_seqscan;
|
reset enable_seqscan;
|
||||||
set enable_indexscan = off;
|
set enable_indexscan = off;
|
||||||
SELECT MIN(name) AS "AAA" FROM srt;
|
SELECT MIN(name) AS "ABA" FROM srt;
|
||||||
SELECT MAX(name) AS abd FROM srt;
|
SELECT MAX(name) AS abd FROM srt;
|
||||||
reset enable_indexscan;
|
reset enable_indexscan;
|
||||||
|
|
||||||
@ -146,11 +145,11 @@ SELECT name FROM srt ORDER BY name;
|
|||||||
reset enable_indexscan;
|
reset enable_indexscan;
|
||||||
|
|
||||||
-- Test assignment casts.
|
-- Test assignment casts.
|
||||||
SELECT LOWER(name) as aaa FROM srt WHERE name = 'AAA'::text;
|
SELECT LOWER(name) as aba FROM srt WHERE name = 'ABA'::text;
|
||||||
SELECT LOWER(name) as aaa FROM srt WHERE name = 'AAA'::varchar;
|
SELECT LOWER(name) as aba FROM srt WHERE name = 'ABA'::varchar;
|
||||||
SELECT LOWER(name) as aaa FROM srt WHERE name = 'AAA'::bpchar;
|
SELECT LOWER(name) as aba FROM srt WHERE name = 'ABA'::bpchar;
|
||||||
SELECT LOWER(name) as aaa FROM srt WHERE name = 'AAA';
|
SELECT LOWER(name) as aba FROM srt WHERE name = 'ABA';
|
||||||
SELECT LOWER(name) as aaa FROM srt WHERE name = 'AAA'::citext;
|
SELECT LOWER(name) as aba FROM srt WHERE name = 'ABA'::citext;
|
||||||
|
|
||||||
-- LIKE should be case-insensitive
|
-- LIKE should be case-insensitive
|
||||||
SELECT name FROM srt WHERE name LIKE '%a%' ORDER BY name;
|
SELECT name FROM srt WHERE name LIKE '%a%' ORDER BY name;
|
||||||
@ -653,12 +652,12 @@ SELECT split_part('abcTdefTghi'::citext, 't', 2) = 'def' AS t;
|
|||||||
SELECT split_part('abcTdefTghi'::citext, 't'::citext, 2) = 'def' AS t;
|
SELECT split_part('abcTdefTghi'::citext, 't'::citext, 2) = 'def' AS t;
|
||||||
SELECT split_part('abcTdefTghi', 't'::citext, 2) = 'def' AS t;
|
SELECT split_part('abcTdefTghi', 't'::citext, 2) = 'def' AS t;
|
||||||
|
|
||||||
SELECT strpos('high'::citext, 'ig' ) = 2 AS t;
|
SELECT strpos('high'::citext, 'gh' ) = 3 AS t;
|
||||||
SELECT strpos('high', 'ig'::citext) = 2 AS t;
|
SELECT strpos('high', 'gh'::citext) = 3 AS t;
|
||||||
SELECT strpos('high'::citext, 'ig'::citext) = 2 AS t;
|
SELECT strpos('high'::citext, 'gh'::citext) = 3 AS t;
|
||||||
SELECT strpos('high'::citext, 'IG' ) = 2 AS t;
|
SELECT strpos('high'::citext, 'GH' ) = 3 AS t;
|
||||||
SELECT strpos('high', 'IG'::citext) = 2 AS t;
|
SELECT strpos('high', 'GH'::citext) = 3 AS t;
|
||||||
SELECT strpos('high'::citext, 'IG'::citext) = 2 AS t;
|
SELECT strpos('high'::citext, 'GH'::citext) = 3 AS t;
|
||||||
|
|
||||||
-- to_ascii() does not support UTF-8.
|
-- to_ascii() does not support UTF-8.
|
||||||
-- to_hex() takes a numeric argument.
|
-- to_hex() takes a numeric argument.
|
||||||
|
@ -1067,7 +1067,7 @@ select rank(' a:1 s:2 d g'::tsvector, 'a & s');
|
|||||||
|
|
||||||
insert into test_tsvector (t) values ('foo bar foo the over foo qq bar');
|
insert into test_tsvector (t) values ('foo bar foo the over foo qq bar');
|
||||||
drop trigger tsvectorupdate on test_tsvector;
|
drop trigger tsvectorupdate on test_tsvector;
|
||||||
select * from stat('select a from test_tsvector') order by ndoc desc, nentry desc, word;
|
select * from stat('select a from test_tsvector') order by ndoc desc, nentry desc, word collate "C";
|
||||||
word | ndoc | nentry
|
word | ndoc | nentry
|
||||||
-----------+------+--------
|
-----------+------+--------
|
||||||
qq | 109 | 109
|
qq | 109 | 109
|
||||||
@ -2220,28 +2220,28 @@ select * from stat('select a from test_tsvector') order by ndoc desc, nentry des
|
|||||||
|
|
||||||
insert into test_tsvector values ('1', 'a:1a,2,3b b:5a,6a,7c,8');
|
insert into test_tsvector values ('1', 'a:1a,2,3b b:5a,6a,7c,8');
|
||||||
insert into test_tsvector values ('1', 'a:1a,2,3c b:5a,6b,7c,8b');
|
insert into test_tsvector values ('1', 'a:1a,2,3c b:5a,6b,7c,8b');
|
||||||
select * from stat('select a from test_tsvector','a') order by ndoc desc, nentry desc, word;
|
select * from stat('select a from test_tsvector','a') order by ndoc desc, nentry desc, word collate "C";
|
||||||
word | ndoc | nentry
|
word | ndoc | nentry
|
||||||
------+------+--------
|
------+------+--------
|
||||||
b | 2 | 3
|
b | 2 | 3
|
||||||
a | 2 | 2
|
a | 2 | 2
|
||||||
(2 rows)
|
(2 rows)
|
||||||
|
|
||||||
select * from stat('select a from test_tsvector','b') order by ndoc desc, nentry desc, word;
|
select * from stat('select a from test_tsvector','b') order by ndoc desc, nentry desc, word collate "C";
|
||||||
word | ndoc | nentry
|
word | ndoc | nentry
|
||||||
------+------+--------
|
------+------+--------
|
||||||
b | 1 | 2
|
b | 1 | 2
|
||||||
a | 1 | 1
|
a | 1 | 1
|
||||||
(2 rows)
|
(2 rows)
|
||||||
|
|
||||||
select * from stat('select a from test_tsvector','c') order by ndoc desc, nentry desc, word;
|
select * from stat('select a from test_tsvector','c') order by ndoc desc, nentry desc, word collate "C";
|
||||||
word | ndoc | nentry
|
word | ndoc | nentry
|
||||||
------+------+--------
|
------+------+--------
|
||||||
b | 2 | 2
|
b | 2 | 2
|
||||||
a | 1 | 1
|
a | 1 | 1
|
||||||
(2 rows)
|
(2 rows)
|
||||||
|
|
||||||
select * from stat('select a from test_tsvector','d') order by ndoc desc, nentry desc, word;
|
select * from stat('select a from test_tsvector','d') order by ndoc desc, nentry desc, word collate "C";
|
||||||
word | ndoc | nentry
|
word | ndoc | nentry
|
||||||
-----------+------+--------
|
-----------+------+--------
|
||||||
a | 2 | 2
|
a | 2 | 2
|
||||||
@ -2254,7 +2254,7 @@ select * from stat('select a from test_tsvector','d') order by ndoc desc, nentry
|
|||||||
qwerti | 1 | 1
|
qwerti | 1 | 1
|
||||||
(8 rows)
|
(8 rows)
|
||||||
|
|
||||||
select * from stat('select a from test_tsvector','ad') order by ndoc desc, nentry desc, word;
|
select * from stat('select a from test_tsvector','ad') order by ndoc desc, nentry desc, word collate "C";
|
||||||
word | ndoc | nentry
|
word | ndoc | nentry
|
||||||
-----------+------+--------
|
-----------+------+--------
|
||||||
a | 2 | 4
|
a | 2 | 4
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -230,14 +230,14 @@ select rank(' a:1 s:2 d g'::tsvector, 'a & s');
|
|||||||
|
|
||||||
insert into test_tsvector (t) values ('foo bar foo the over foo qq bar');
|
insert into test_tsvector (t) values ('foo bar foo the over foo qq bar');
|
||||||
drop trigger tsvectorupdate on test_tsvector;
|
drop trigger tsvectorupdate on test_tsvector;
|
||||||
select * from stat('select a from test_tsvector') order by ndoc desc, nentry desc, word;
|
select * from stat('select a from test_tsvector') order by ndoc desc, nentry desc, word collate "C";
|
||||||
insert into test_tsvector values ('1', 'a:1a,2,3b b:5a,6a,7c,8');
|
insert into test_tsvector values ('1', 'a:1a,2,3b b:5a,6a,7c,8');
|
||||||
insert into test_tsvector values ('1', 'a:1a,2,3c b:5a,6b,7c,8b');
|
insert into test_tsvector values ('1', 'a:1a,2,3c b:5a,6b,7c,8b');
|
||||||
select * from stat('select a from test_tsvector','a') order by ndoc desc, nentry desc, word;
|
select * from stat('select a from test_tsvector','a') order by ndoc desc, nentry desc, word collate "C";
|
||||||
select * from stat('select a from test_tsvector','b') order by ndoc desc, nentry desc, word;
|
select * from stat('select a from test_tsvector','b') order by ndoc desc, nentry desc, word collate "C";
|
||||||
select * from stat('select a from test_tsvector','c') order by ndoc desc, nentry desc, word;
|
select * from stat('select a from test_tsvector','c') order by ndoc desc, nentry desc, word collate "C";
|
||||||
select * from stat('select a from test_tsvector','d') order by ndoc desc, nentry desc, word;
|
select * from stat('select a from test_tsvector','d') order by ndoc desc, nentry desc, word collate "C";
|
||||||
select * from stat('select a from test_tsvector','ad') order by ndoc desc, nentry desc, word;
|
select * from stat('select a from test_tsvector','ad') order by ndoc desc, nentry desc, word collate "C";
|
||||||
|
|
||||||
select to_tsquery('english', 'skies & books');
|
select to_tsquery('english', 'skies & books');
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user