]> granicus.if.org Git - postgresql/blob - contrib/citext/expected/citext_1.out
Add record_image_ops opclass for matview concurrent refresh.
[postgresql] / contrib / citext / expected / citext_1.out
1 --
2 --  Test citext datatype
3 --
4 CREATE EXTENSION citext;
5 -- Test the operators and indexing functions
6 -- Test = and <>.
7 SELECT 'a'::citext = 'a'::citext AS t;
8  t 
9 ---
10  t
11 (1 row)
12
13 SELECT 'a'::citext = 'A'::citext AS t;
14  t 
15 ---
16  t
17 (1 row)
18
19 SELECT 'a'::citext = 'A'::text AS f;        -- text wins the discussion
20  f 
21 ---
22  f
23 (1 row)
24
25 SELECT 'a'::citext = 'b'::citext AS f;
26  f 
27 ---
28  f
29 (1 row)
30
31 SELECT 'a'::citext = 'ab'::citext AS f;
32  f 
33 ---
34  f
35 (1 row)
36
37 SELECT 'a'::citext <> 'ab'::citext AS t;
38  t 
39 ---
40  t
41 (1 row)
42
43 -- Multibyte sanity tests. Uncomment to run.
44 -- SELECT 'À'::citext =  'À'::citext AS t;
45 -- SELECT 'À'::citext =  'à'::citext AS t;
46 -- SELECT 'À'::text   =  'à'::text   AS f; -- text wins.
47 -- SELECT 'À'::citext <> 'B'::citext AS t;
48 -- Test combining characters making up canonically equivalent strings.
49 -- SELECT 'Ä'::text   <> 'Ä'::text   AS t;
50 -- SELECT 'Ä'::citext <> 'Ä'::citext AS t;
51 -- Test the Turkish dotted I. The lowercase is a single byte while the
52 -- uppercase is multibyte. This is why the comparison code can't be optimized
53 -- to compare string lengths.
54 -- SELECT 'i'::citext = 'İ'::citext AS t;
55 -- Regression.
56 -- SELECT 'láska'::citext <> 'laská'::citext AS t;
57 -- SELECT 'Ask Bjørn Hansen'::citext = 'Ask Bjørn Hansen'::citext AS t;
58 -- SELECT 'Ask Bjørn Hansen'::citext = 'ASK BJØRN HANSEN'::citext AS t;
59 -- SELECT 'Ask Bjørn Hansen'::citext <> 'Ask Bjorn Hansen'::citext AS t;
60 -- SELECT 'Ask Bjørn Hansen'::citext <> 'ASK BJORN HANSEN'::citext AS t;
61 -- SELECT citext_cmp('Ask Bjørn Hansen'::citext, 'Ask Bjørn Hansen'::citext) AS zero;
62 -- SELECT citext_cmp('Ask Bjørn Hansen'::citext, 'ask bjørn hansen'::citext) AS zero;
63 -- SELECT citext_cmp('Ask Bjørn Hansen'::citext, 'ASK BJØRN HANSEN'::citext) AS zero;
64 -- SELECT citext_cmp('Ask Bjørn Hansen'::citext, 'Ask Bjorn Hansen'::citext) AS positive;
65 -- SELECT citext_cmp('Ask Bjorn Hansen'::citext, 'Ask Bjørn Hansen'::citext) AS negative;
66 -- Test > and >=
67 SELECT 'B'::citext > 'a'::citext AS t;
68  t 
69 ---
70  t
71 (1 row)
72
73 SELECT 'b'::citext >  'A'::citext AS t;
74  t 
75 ---
76  t
77 (1 row)
78
79 SELECT 'B'::citext >  'b'::citext AS f;
80  f 
81 ---
82  f
83 (1 row)
84
85 SELECT 'B'::citext >= 'b'::citext AS t;
86  t 
87 ---
88  t
89 (1 row)
90
91 -- Test < and <=
92 SELECT 'a'::citext <  'B'::citext AS t;
93  t 
94 ---
95  t
96 (1 row)
97
98 SELECT 'a'::citext <= 'B'::citext AS t;
99  t 
100 ---
101  t
102 (1 row)
103
104 -- Test implicit casting. citext casts to text, but not vice-versa.
105 SELECT 'a'::citext = 'a'::text   AS t;
106  t 
107 ---
108  t
109 (1 row)
110
111 SELECT 'A'::text  <> 'a'::citext AS t;
112  t 
113 ---
114  t
115 (1 row)
116
117 SELECT 'B'::citext <  'a'::text AS t;  -- text wins.
118  t 
119 ---
120  f
121 (1 row)
122
123 SELECT 'B'::citext <= 'a'::text AS t;  -- text wins.
124  t 
125 ---
126  f
127 (1 row)
128
129 SELECT 'a'::citext >  'B'::text AS t;  -- text wins.
130  t 
131 ---
132  f
133 (1 row)
134
135 SELECT 'a'::citext >= 'B'::text AS t;  -- text wins.
136  t 
137 ---
138  f
139 (1 row)
140
141 -- Test implicit casting. citext casts to varchar, but not vice-versa.
142 SELECT 'a'::citext = 'a'::varchar   AS t;
143  t 
144 ---
145  t
146 (1 row)
147
148 SELECT 'A'::varchar  <> 'a'::citext AS t;
149  t 
150 ---
151  t
152 (1 row)
153
154 SELECT 'B'::citext <  'a'::varchar AS t;  -- varchar wins.
155  t 
156 ---
157  f
158 (1 row)
159
160 SELECT 'B'::citext <= 'a'::varchar AS t;  -- varchar wins.
161  t 
162 ---
163  f
164 (1 row)
165
166 SELECT 'a'::citext >  'B'::varchar AS t;  -- varchar wins.
167  t 
168 ---
169  f
170 (1 row)
171
172 SELECT 'a'::citext >= 'B'::varchar AS t;  -- varchar wins.
173  t 
174 ---
175  f
176 (1 row)
177
178 -- A couple of longer examlpes to ensure that we don't get any issues with bad
179 -- conversions to char[] in the c code. Yes, I did do this.
180 SELECT 'aardvark'::citext = 'aardvark'::citext AS t;
181  t 
182 ---
183  t
184 (1 row)
185
186 SELECT 'aardvark'::citext = 'aardVark'::citext AS t;
187  t 
188 ---
189  t
190 (1 row)
191
192 -- Check the citext_cmp() function explicitly.
193 SELECT citext_cmp('aardvark'::citext, 'aardvark'::citext) AS zero;
194  zero 
195 ------
196     0
197 (1 row)
198
199 SELECT citext_cmp('aardvark'::citext, 'aardVark'::citext) AS zero;
200  zero 
201 ------
202     0
203 (1 row)
204
205 SELECT citext_cmp('AARDVARK'::citext, 'AARDVARK'::citext) AS zero;
206  zero 
207 ------
208     0
209 (1 row)
210
211 SELECT citext_cmp('B'::citext, 'a'::citext) > 0 AS true;
212  true 
213 ------
214  t
215 (1 row)
216
217 -- Do some tests using a table and index.
218 CREATE TEMP TABLE try (
219    name citext PRIMARY KEY
220 );
221 INSERT INTO try (name)
222 VALUES ('a'), ('ab'), ('â'), ('aba'), ('b'), ('ba'), ('bab'), ('AZ');
223 SELECT name, 'a' = name AS eq_a   FROM try WHERE name <> 'â';
224  name | eq_a 
225 ------+------
226  a    | t
227  ab   | f
228  aba  | f
229  b    | f
230  ba   | f
231  bab  | f
232  AZ   | f
233 (7 rows)
234
235 SELECT name, 'a' = name AS t      FROM try where name = 'a';
236  name | t 
237 ------+---
238  a    | t
239 (1 row)
240
241 SELECT name, 'A' = name AS "eq_A" FROM try WHERE name <> 'â';
242  name | eq_A 
243 ------+------
244  a    | t
245  ab   | f
246  aba  | f
247  b    | f
248  ba   | f
249  bab  | f
250  AZ   | f
251 (7 rows)
252
253 SELECT name, 'A' = name AS t      FROM try where name = 'A';
254  name | t 
255 ------+---
256  a    | t
257 (1 row)
258
259 SELECT name, 'A' = name AS t      FROM try where name = 'A';
260  name | t 
261 ------+---
262  a    | t
263 (1 row)
264
265 -- expected failures on duplicate key
266 INSERT INTO try (name) VALUES ('a');
267 ERROR:  duplicate key value violates unique constraint "try_pkey"
268 DETAIL:  Key (name)=(a) already exists.
269 INSERT INTO try (name) VALUES ('A');
270 ERROR:  duplicate key value violates unique constraint "try_pkey"
271 DETAIL:  Key (name)=(A) already exists.
272 INSERT INTO try (name) VALUES ('aB');
273 ERROR:  duplicate key value violates unique constraint "try_pkey"
274 DETAIL:  Key (name)=(aB) already exists.
275 -- Make sure that citext_smaller() and citext_lager() work properly.
276 SELECT citext_smaller( 'aa'::citext, 'ab'::citext ) = 'aa' AS t;
277  t 
278 ---
279  t
280 (1 row)
281
282 SELECT citext_smaller( 'AAAA'::citext, 'bbbb'::citext ) = 'AAAA' AS t;
283  t 
284 ---
285  t
286 (1 row)
287
288 SELECT citext_smaller( 'aardvark'::citext, 'Aaba'::citext ) = 'Aaba' AS t;
289  t 
290 ---
291  t
292 (1 row)
293
294 SELECT citext_smaller( 'aardvark'::citext, 'AARDVARK'::citext ) = 'AARDVARK' AS t;
295  t 
296 ---
297  t
298 (1 row)
299
300 SELECT citext_larger( 'aa'::citext, 'ab'::citext ) = 'ab' AS t;
301  t 
302 ---
303  t
304 (1 row)
305
306 SELECT citext_larger( 'AAAA'::citext, 'bbbb'::citext ) = 'bbbb' AS t;
307  t 
308 ---
309  t
310 (1 row)
311
312 SELECT citext_larger( 'aardvark'::citext, 'Aaba'::citext ) = 'aardvark' AS t;
313  t 
314 ---
315  t
316 (1 row)
317
318 -- Test aggregate functions and sort ordering
319 CREATE TEMP TABLE srt (
320    name CITEXT
321 );
322 INSERT INTO srt (name)
323 VALUES ('aardvark'),
324        ('AAA'),
325        ('aba'),
326        ('ABC'),
327        ('abd');
328 CREATE INDEX srt_name ON srt (name);
329 -- Check the min() and max() aggregates, with and without index.
330 set enable_seqscan = off;
331 SELECT MIN(name) AS "AAA" FROM srt;
332  AAA 
333 -----
334  AAA
335 (1 row)
336
337 SELECT MAX(name) AS abd FROM srt;
338  abd 
339 -----
340  abd
341 (1 row)
342
343 reset enable_seqscan;
344 set enable_indexscan = off;
345 SELECT MIN(name) AS "AAA" FROM srt;
346  AAA 
347 -----
348  AAA
349 (1 row)
350
351 SELECT MAX(name) AS abd FROM srt;
352  abd 
353 -----
354  abd
355 (1 row)
356
357 reset enable_indexscan;
358 -- Check sorting likewise
359 set enable_seqscan = off;
360 SELECT name FROM srt ORDER BY name;
361    name   
362 ----------
363  AAA
364  aardvark
365  aba
366  ABC
367  abd
368 (5 rows)
369
370 reset enable_seqscan;
371 set enable_indexscan = off;
372 SELECT name FROM srt ORDER BY name;
373    name   
374 ----------
375  AAA
376  aardvark
377  aba
378  ABC
379  abd
380 (5 rows)
381
382 reset enable_indexscan;
383 -- Test assignment casts.
384 SELECT LOWER(name) as aaa FROM srt WHERE name = 'AAA'::text;
385  aaa 
386 -----
387  aaa
388 (1 row)
389
390 SELECT LOWER(name) as aaa FROM srt WHERE name = 'AAA'::varchar;
391  aaa 
392 -----
393  aaa
394 (1 row)
395
396 SELECT LOWER(name) as aaa FROM srt WHERE name = 'AAA'::bpchar;
397  aaa 
398 -----
399  aaa
400 (1 row)
401
402 SELECT LOWER(name) as aaa FROM srt WHERE name = 'AAA';
403  aaa 
404 -----
405  aaa
406 (1 row)
407
408 SELECT LOWER(name) as aaa FROM srt WHERE name = 'AAA'::citext;
409  aaa 
410 -----
411  aaa
412 (1 row)
413
414 -- LIKE should be case-insensitive
415 SELECT name FROM srt WHERE name     LIKE '%a%' ORDER BY name;
416    name   
417 ----------
418  AAA
419  aardvark
420  aba
421  ABC
422  abd
423 (5 rows)
424
425 SELECT name FROM srt WHERE name NOT LIKE '%b%' ORDER BY name;
426    name   
427 ----------
428  AAA
429  aardvark
430 (2 rows)
431
432 SELECT name FROM srt WHERE name     LIKE '%A%' ORDER BY name;
433    name   
434 ----------
435  AAA
436  aardvark
437  aba
438  ABC
439  abd
440 (5 rows)
441
442 SELECT name FROM srt WHERE name NOT LIKE '%B%' ORDER BY name;
443    name   
444 ----------
445  AAA
446  aardvark
447 (2 rows)
448
449 -- ~~ should be case-insensitive
450 SELECT name FROM srt WHERE name ~~  '%a%' ORDER BY name;
451    name   
452 ----------
453  AAA
454  aardvark
455  aba
456  ABC
457  abd
458 (5 rows)
459
460 SELECT name FROM srt WHERE name !~~ '%b%' ORDER BY name;
461    name   
462 ----------
463  AAA
464  aardvark
465 (2 rows)
466
467 SELECT name FROM srt WHERE name ~~  '%A%' ORDER BY name;
468    name   
469 ----------
470  AAA
471  aardvark
472  aba
473  ABC
474  abd
475 (5 rows)
476
477 SELECT name FROM srt WHERE name !~~ '%B%' ORDER BY name;
478    name   
479 ----------
480  AAA
481  aardvark
482 (2 rows)
483
484 -- ~ should be case-insensitive
485 SELECT name FROM srt WHERE name ~  '^a' ORDER BY name;
486    name   
487 ----------
488  AAA
489  aardvark
490  aba
491  ABC
492  abd
493 (5 rows)
494
495 SELECT name FROM srt WHERE name !~ 'a$' ORDER BY name;
496    name   
497 ----------
498  aardvark
499  ABC
500  abd
501 (3 rows)
502
503 SELECT name FROM srt WHERE name ~  '^A' ORDER BY name;
504    name   
505 ----------
506  AAA
507  aardvark
508  aba
509  ABC
510  abd
511 (5 rows)
512
513 SELECT name FROM srt WHERE name !~ 'A$' ORDER BY name;
514    name   
515 ----------
516  aardvark
517  ABC
518  abd
519 (3 rows)
520
521 -- SIMILAR TO should be case-insensitive.
522 SELECT name FROM srt WHERE name SIMILAR TO '%a.*';
523  name 
524 ------
525  AAA
526  aba
527 (2 rows)
528
529 SELECT name FROM srt WHERE name SIMILAR TO '%A.*';
530  name 
531 ------
532  AAA
533  aba
534 (2 rows)
535
536 -- Explicit casts.
537 SELECT true::citext = 'true' AS t;
538  t 
539 ---
540  t
541 (1 row)
542
543 SELECT 'true'::citext::boolean = true AS t;
544  t 
545 ---
546  t
547 (1 row)
548
549 SELECT 4::citext = '4' AS t;
550  t 
551 ---
552  t
553 (1 row)
554
555 SELECT 4::int4::citext = '4' AS t;
556  t 
557 ---
558  t
559 (1 row)
560
561 SELECT '4'::citext::int4 = 4 AS t;
562  t 
563 ---
564  t
565 (1 row)
566
567 SELECT 4::integer::citext = '4' AS t;
568  t 
569 ---
570  t
571 (1 row)
572
573 SELECT '4'::citext::integer = 4 AS t;
574  t 
575 ---
576  t
577 (1 row)
578
579 SELECT 4::int8::citext = '4' AS t;
580  t 
581 ---
582  t
583 (1 row)
584
585 SELECT '4'::citext::int8 = 4 AS t;
586  t 
587 ---
588  t
589 (1 row)
590
591 SELECT 4::bigint::citext = '4' AS t;
592  t 
593 ---
594  t
595 (1 row)
596
597 SELECT '4'::citext::bigint = 4 AS t;
598  t 
599 ---
600  t
601 (1 row)
602
603 SELECT 4::int2::citext = '4' AS t;
604  t 
605 ---
606  t
607 (1 row)
608
609 SELECT '4'::citext::int2 = 4 AS t;
610  t 
611 ---
612  t
613 (1 row)
614
615 SELECT 4::smallint::citext = '4' AS t;
616  t 
617 ---
618  t
619 (1 row)
620
621 SELECT '4'::citext::smallint = 4 AS t;
622  t 
623 ---
624  t
625 (1 row)
626
627 SELECT 4.0::numeric = '4.0' AS t;
628  t 
629 ---
630  t
631 (1 row)
632
633 SELECT '4.0'::citext::numeric = 4.0 AS t;
634  t 
635 ---
636  t
637 (1 row)
638
639 SELECT 4.0::decimal = '4.0' AS t;
640  t 
641 ---
642  t
643 (1 row)
644
645 SELECT '4.0'::citext::decimal = 4.0 AS t;
646  t 
647 ---
648  t
649 (1 row)
650
651 SELECT 4.0::real = '4.0' AS t;
652  t 
653 ---
654  t
655 (1 row)
656
657 SELECT '4.0'::citext::real = 4.0 AS t;
658  t 
659 ---
660  t
661 (1 row)
662
663 SELECT 4.0::float4 = '4.0' AS t;
664  t 
665 ---
666  t
667 (1 row)
668
669 SELECT '4.0'::citext::float4 = 4.0 AS t;
670  t 
671 ---
672  t
673 (1 row)
674
675 SELECT 4.0::double precision = '4.0' AS t;
676  t 
677 ---
678  t
679 (1 row)
680
681 SELECT '4.0'::citext::double precision = 4.0 AS t;
682  t 
683 ---
684  t
685 (1 row)
686
687 SELECT 4.0::float8 = '4.0' AS t;
688  t 
689 ---
690  t
691 (1 row)
692
693 SELECT '4.0'::citext::float8 = 4.0 AS t;
694  t 
695 ---
696  t
697 (1 row)
698
699 SELECT 'foo'::name::citext = 'foo' AS t;
700  t 
701 ---
702  t
703 (1 row)
704
705 SELECT 'foo'::citext::name = 'foo'::name AS t;
706  t 
707 ---
708  t
709 (1 row)
710
711 SELECT 'f'::char::citext = 'f' AS t;
712  t 
713 ---
714  t
715 (1 row)
716
717 SELECT 'f'::citext::char = 'f'::char AS t;
718  t 
719 ---
720  t
721 (1 row)
722
723 SELECT 'f'::"char"::citext = 'f' AS t;
724  t 
725 ---
726  t
727 (1 row)
728
729 SELECT 'f'::citext::"char" = 'f'::"char" AS t;
730  t 
731 ---
732  t
733 (1 row)
734
735 SELECT '100'::money::citext = '$100.00' AS t;
736  t 
737 ---
738  t
739 (1 row)
740
741 SELECT '100'::citext::money = '100'::money AS t;
742  t 
743 ---
744  t
745 (1 row)
746
747 SELECT 'a'::char::citext = 'a' AS t;
748  t 
749 ---
750  t
751 (1 row)
752
753 SELECT 'a'::citext::char = 'a'::char AS t;
754  t 
755 ---
756  t
757 (1 row)
758
759 SELECT 'foo'::varchar::citext = 'foo' AS t;
760  t 
761 ---
762  t
763 (1 row)
764
765 SELECT 'foo'::citext::varchar = 'foo'::varchar AS t;
766  t 
767 ---
768  t
769 (1 row)
770
771 SELECT 'foo'::text::citext = 'foo' AS t;
772  t 
773 ---
774  t
775 (1 row)
776
777 SELECT 'foo'::citext::text = 'foo'::text AS t;
778  t 
779 ---
780  t
781 (1 row)
782
783 SELECT '192.168.100.128/25'::cidr::citext = '192.168.100.128/25' AS t;
784  t 
785 ---
786  t
787 (1 row)
788
789 SELECT '192.168.100.128/25'::citext::cidr = '192.168.100.128/25'::cidr AS t;
790  t 
791 ---
792  t
793 (1 row)
794
795 SELECT '192.168.100.128'::inet::citext = '192.168.100.128/32' AS t;
796  t 
797 ---
798  t
799 (1 row)
800
801 SELECT '192.168.100.128'::citext::inet = '192.168.100.128'::inet AS t;
802  t 
803 ---
804  t
805 (1 row)
806
807 SELECT '08:00:2b:01:02:03'::macaddr::citext = '08:00:2b:01:02:03' AS t;
808  t 
809 ---
810  t
811 (1 row)
812
813 SELECT '08:00:2b:01:02:03'::citext::macaddr = '08:00:2b:01:02:03'::macaddr AS t;
814  t 
815 ---
816  t
817 (1 row)
818
819 SELECT '1999-01-08 04:05:06'::timestamp::citext = '1999-01-08 04:05:06'::timestamp::text AS t;
820  t 
821 ---
822  t
823 (1 row)
824
825 SELECT '1999-01-08 04:05:06'::citext::timestamp = '1999-01-08 04:05:06'::timestamp AS t;
826  t 
827 ---
828  t
829 (1 row)
830
831 SELECT '1999-01-08 04:05:06'::timestamptz::citext = '1999-01-08 04:05:06'::timestamptz::text AS t;
832  t 
833 ---
834  t
835 (1 row)
836
837 SELECT '1999-01-08 04:05:06'::citext::timestamptz = '1999-01-08 04:05:06'::timestamptz AS t;
838  t 
839 ---
840  t
841 (1 row)
842
843 SELECT '1 hour'::interval::citext = '1 hour'::interval::text AS t;
844  t 
845 ---
846  t
847 (1 row)
848
849 SELECT '1 hour'::citext::interval = '1 hour'::interval AS t;
850  t 
851 ---
852  t
853 (1 row)
854
855 SELECT '1999-01-08'::date::citext = '1999-01-08'::date::text AS t;
856  t 
857 ---
858  t
859 (1 row)
860
861 SELECT '1999-01-08'::citext::date = '1999-01-08'::date AS t;
862  t 
863 ---
864  t
865 (1 row)
866
867 SELECT '04:05:06'::time::citext = '04:05:06' AS t;
868  t 
869 ---
870  t
871 (1 row)
872
873 SELECT '04:05:06'::citext::time = '04:05:06'::time AS t;
874  t 
875 ---
876  t
877 (1 row)
878
879 SELECT '04:05:06'::timetz::citext = '04:05:06'::timetz::text AS t;
880  t 
881 ---
882  t
883 (1 row)
884
885 SELECT '04:05:06'::citext::timetz = '04:05:06'::timetz AS t;
886  t 
887 ---
888  t
889 (1 row)
890
891 SELECT '( 1 , 1)'::point::citext = '(1,1)' AS t;
892  t 
893 ---
894  t
895 (1 row)
896
897 SELECT '( 1 , 1)'::citext::point ~= '(1,1)'::point AS t;
898  t 
899 ---
900  t
901 (1 row)
902
903 SELECT '( 1 , 1 ) , ( 2 , 2 )'::lseg::citext = '[(1,1),(2,2)]' AS t;
904  t 
905 ---
906  t
907 (1 row)
908
909 SELECT '( 1 , 1 ) , ( 2 , 2 )'::citext::lseg = '[(1,1),(2,2)]'::lseg AS t;
910  t 
911 ---
912  t
913 (1 row)
914
915 SELECT '( 0 , 0 ) , ( 1 , 1 )'::box::citext = '(0,0),(1,1)'::box::text AS t;
916  t 
917 ---
918  t
919 (1 row)
920
921 SELECT '( 0 , 0 ) , ( 1 , 1 )'::citext::box ~= '(0,0),(1,1)'::text::box AS t;
922  t 
923 ---
924  t
925 (1 row)
926
927 SELECT '((0,0),(1,1),(2,0))'::path::citext = '((0,0),(1,1),(2,0))' AS t;
928  t 
929 ---
930  t
931 (1 row)
932
933 SELECT '((0,0),(1,1),(2,0))'::citext::path = '((0,0),(1,1),(2,0))'::path AS t;
934  t 
935 ---
936  t
937 (1 row)
938
939 SELECT '((0,0),(1,1))'::polygon::citext = '((0,0),(1,1))' AS t;
940  t 
941 ---
942  t
943 (1 row)
944
945 SELECT '((0,0),(1,1))'::citext::polygon ~= '((0,0),(1,1))'::polygon AS t;
946  t 
947 ---
948  t
949 (1 row)
950
951 SELECT '((0,0),2)'::circle::citext = '((0,0),2)'::circle::text AS t;
952  t 
953 ---
954  t
955 (1 row)
956
957 SELECT '((0,0),2)'::citext::circle ~= '((0,0),2)'::text::circle AS t;
958  t 
959 ---
960  t
961 (1 row)
962
963 SELECT '101'::bit::citext = '101'::bit::text AS t;
964  t 
965 ---
966  t
967 (1 row)
968
969 SELECT '101'::citext::bit = '101'::text::bit AS t;
970  t 
971 ---
972  t
973 (1 row)
974
975 SELECT '101'::bit varying::citext = '101'::bit varying::text AS t;
976  t 
977 ---
978  t
979 (1 row)
980
981 SELECT '101'::citext::bit varying = '101'::text::bit varying AS t;
982  t 
983 ---
984  t
985 (1 row)
986
987 SELECT 'a fat cat'::tsvector::citext = '''a'' ''cat'' ''fat''' AS t;
988  t 
989 ---
990  t
991 (1 row)
992
993 SELECT 'a fat cat'::citext::tsvector = 'a fat cat'::tsvector AS t;
994  t 
995 ---
996  t
997 (1 row)
998
999 SELECT 'fat & rat'::tsquery::citext = '''fat'' & ''rat''' AS t;
1000  t 
1001 ---
1002  t
1003 (1 row)
1004
1005 SELECT 'fat & rat'::citext::tsquery = 'fat & rat'::tsquery AS t;
1006  t 
1007 ---
1008  t
1009 (1 row)
1010
1011 SELECT 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'::uuid::citext = 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11' AS t;
1012  t 
1013 ---
1014  t
1015 (1 row)
1016
1017 SELECT 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'::citext::uuid = 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'::uuid AS t;
1018  t 
1019 ---
1020  t
1021 (1 row)
1022
1023 CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy');
1024 SELECT 'sad'::mood::citext = 'sad' AS t;
1025  t 
1026 ---
1027  t
1028 (1 row)
1029
1030 SELECT 'sad'::citext::mood = 'sad'::mood AS t;
1031  t 
1032 ---
1033  t
1034 (1 row)
1035
1036 -- Assignment casts.
1037 CREATE TABLE caster (
1038     citext      citext,
1039     text        text,
1040     varchar     varchar,
1041     bpchar      bpchar,
1042     char        char,
1043     chr         "char",
1044     name        name,
1045     bytea       bytea,
1046     boolean     boolean,
1047     float4      float4,
1048     float8      float8,
1049     numeric     numeric,
1050     int8        int8,
1051     int4        int4,
1052     int2        int2,
1053     cidr        cidr,
1054     inet        inet,
1055     macaddr     macaddr,
1056     money       money,
1057     timestamp   timestamp,
1058     timestamptz timestamptz,
1059     interval    interval,
1060     date        date,
1061     time        time,
1062     timetz      timetz,
1063     point       point,
1064     lseg        lseg,
1065     box         box,
1066     path        path,
1067     polygon     polygon,
1068     circle      circle,
1069     bit         bit,
1070     bitv        bit varying,
1071     tsvector    tsvector,
1072     tsquery     tsquery,
1073     uuid        uuid
1074 );
1075 INSERT INTO caster (text)          VALUES ('foo'::citext);
1076 INSERT INTO caster (citext)        VALUES ('foo'::text);
1077 INSERT INTO caster (varchar)       VALUES ('foo'::text);
1078 INSERT INTO caster (text)          VALUES ('foo'::varchar);
1079 INSERT INTO caster (varchar)       VALUES ('foo'::citext);
1080 INSERT INTO caster (citext)        VALUES ('foo'::varchar);
1081 INSERT INTO caster (bpchar)        VALUES ('foo'::text);
1082 INSERT INTO caster (text)          VALUES ('foo'::bpchar);
1083 INSERT INTO caster (bpchar)        VALUES ('foo'::citext);
1084 INSERT INTO caster (citext)        VALUES ('foo'::bpchar);
1085 INSERT INTO caster (char)          VALUES ('f'::text);
1086 INSERT INTO caster (text)          VALUES ('f'::char);
1087 INSERT INTO caster (char)          VALUES ('f'::citext);
1088 INSERT INTO caster (citext)        VALUES ('f'::char);
1089 INSERT INTO caster (chr)           VALUES ('f'::text);
1090 INSERT INTO caster (text)          VALUES ('f'::"char");
1091 INSERT INTO caster (chr)           VALUES ('f'::citext);
1092 INSERT INTO caster (citext)        VALUES ('f'::"char");
1093 INSERT INTO caster (name)          VALUES ('foo'::text);
1094 INSERT INTO caster (text)          VALUES ('foo'::name);
1095 INSERT INTO caster (name)          VALUES ('foo'::citext);
1096 INSERT INTO caster (citext)        VALUES ('foo'::name);
1097 -- Cannot cast to bytea on assignment.
1098 INSERT INTO caster (bytea)         VALUES ('foo'::text);
1099 ERROR:  column "bytea" is of type bytea but expression is of type text
1100 LINE 1: INSERT INTO caster (bytea)         VALUES ('foo'::text);
1101                                                    ^
1102 HINT:  You will need to rewrite or cast the expression.
1103 INSERT INTO caster (text)          VALUES ('foo'::bytea);
1104 INSERT INTO caster (bytea)         VALUES ('foo'::citext);
1105 ERROR:  column "bytea" is of type bytea but expression is of type citext
1106 LINE 1: INSERT INTO caster (bytea)         VALUES ('foo'::citext);
1107                                                    ^
1108 HINT:  You will need to rewrite or cast the expression.
1109 INSERT INTO caster (citext)        VALUES ('foo'::bytea);
1110 -- Cannot cast to boolean on assignment.
1111 INSERT INTO caster (boolean)       VALUES ('t'::text);
1112 ERROR:  column "boolean" is of type boolean but expression is of type text
1113 LINE 1: INSERT INTO caster (boolean)       VALUES ('t'::text);
1114                                                    ^
1115 HINT:  You will need to rewrite or cast the expression.
1116 INSERT INTO caster (text)          VALUES ('t'::boolean);
1117 INSERT INTO caster (boolean)       VALUES ('t'::citext);
1118 ERROR:  column "boolean" is of type boolean but expression is of type citext
1119 LINE 1: INSERT INTO caster (boolean)       VALUES ('t'::citext);
1120                                                    ^
1121 HINT:  You will need to rewrite or cast the expression.
1122 INSERT INTO caster (citext)        VALUES ('t'::boolean);
1123 -- Cannot cast to float8 on assignment.
1124 INSERT INTO caster (float8)        VALUES ('12.42'::text);
1125 ERROR:  column "float8" is of type double precision but expression is of type text
1126 LINE 1: INSERT INTO caster (float8)        VALUES ('12.42'::text);
1127                                                    ^
1128 HINT:  You will need to rewrite or cast the expression.
1129 INSERT INTO caster (text)          VALUES ('12.42'::float8);
1130 INSERT INTO caster (float8)        VALUES ('12.42'::citext);
1131 ERROR:  column "float8" is of type double precision but expression is of type citext
1132 LINE 1: INSERT INTO caster (float8)        VALUES ('12.42'::citext);
1133                                                    ^
1134 HINT:  You will need to rewrite or cast the expression.
1135 INSERT INTO caster (citext)        VALUES ('12.42'::float8);
1136 -- Cannot cast to float4 on assignment.
1137 INSERT INTO caster (float4)        VALUES ('12.42'::text);
1138 ERROR:  column "float4" is of type real but expression is of type text
1139 LINE 1: INSERT INTO caster (float4)        VALUES ('12.42'::text);
1140                                                    ^
1141 HINT:  You will need to rewrite or cast the expression.
1142 INSERT INTO caster (text)          VALUES ('12.42'::float4);
1143 INSERT INTO caster (float4)        VALUES ('12.42'::citext);
1144 ERROR:  column "float4" is of type real but expression is of type citext
1145 LINE 1: INSERT INTO caster (float4)        VALUES ('12.42'::citext);
1146                                                    ^
1147 HINT:  You will need to rewrite or cast the expression.
1148 INSERT INTO caster (citext)        VALUES ('12.42'::float4);
1149 -- Cannot cast to numeric on assignment.
1150 INSERT INTO caster (numeric)       VALUES ('12.42'::text);
1151 ERROR:  column "numeric" is of type numeric but expression is of type text
1152 LINE 1: INSERT INTO caster (numeric)       VALUES ('12.42'::text);
1153                                                    ^
1154 HINT:  You will need to rewrite or cast the expression.
1155 INSERT INTO caster (text)          VALUES ('12.42'::numeric);
1156 INSERT INTO caster (numeric)       VALUES ('12.42'::citext);
1157 ERROR:  column "numeric" is of type numeric but expression is of type citext
1158 LINE 1: INSERT INTO caster (numeric)       VALUES ('12.42'::citext);
1159                                                    ^
1160 HINT:  You will need to rewrite or cast the expression.
1161 INSERT INTO caster (citext)        VALUES ('12.42'::numeric);
1162 -- Cannot cast to int8 on assignment.
1163 INSERT INTO caster (int8)          VALUES ('12'::text);
1164 ERROR:  column "int8" is of type bigint but expression is of type text
1165 LINE 1: INSERT INTO caster (int8)          VALUES ('12'::text);
1166                                                    ^
1167 HINT:  You will need to rewrite or cast the expression.
1168 INSERT INTO caster (text)          VALUES ('12'::int8);
1169 INSERT INTO caster (int8)          VALUES ('12'::citext);
1170 ERROR:  column "int8" is of type bigint but expression is of type citext
1171 LINE 1: INSERT INTO caster (int8)          VALUES ('12'::citext);
1172                                                    ^
1173 HINT:  You will need to rewrite or cast the expression.
1174 INSERT INTO caster (citext)        VALUES ('12'::int8);
1175 -- Cannot cast to int4 on assignment.
1176 INSERT INTO caster (int4)          VALUES ('12'::text);
1177 ERROR:  column "int4" is of type integer but expression is of type text
1178 LINE 1: INSERT INTO caster (int4)          VALUES ('12'::text);
1179                                                    ^
1180 HINT:  You will need to rewrite or cast the expression.
1181 INSERT INTO caster (text)          VALUES ('12'::int4);
1182 INSERT INTO caster (int4)          VALUES ('12'::citext);
1183 ERROR:  column "int4" is of type integer but expression is of type citext
1184 LINE 1: INSERT INTO caster (int4)          VALUES ('12'::citext);
1185                                                    ^
1186 HINT:  You will need to rewrite or cast the expression.
1187 INSERT INTO caster (citext)        VALUES ('12'::int4);
1188 -- Cannot cast to int2 on assignment.
1189 INSERT INTO caster (int2)          VALUES ('12'::text);
1190 ERROR:  column "int2" is of type smallint but expression is of type text
1191 LINE 1: INSERT INTO caster (int2)          VALUES ('12'::text);
1192                                                    ^
1193 HINT:  You will need to rewrite or cast the expression.
1194 INSERT INTO caster (text)          VALUES ('12'::int2);
1195 INSERT INTO caster (int2)          VALUES ('12'::citext);
1196 ERROR:  column "int2" is of type smallint but expression is of type citext
1197 LINE 1: INSERT INTO caster (int2)          VALUES ('12'::citext);
1198                                                    ^
1199 HINT:  You will need to rewrite or cast the expression.
1200 INSERT INTO caster (citext)        VALUES ('12'::int2);
1201 -- Cannot cast to cidr on assignment.
1202 INSERT INTO caster (cidr)          VALUES ('192.168.100.128/25'::text);
1203 ERROR:  column "cidr" is of type cidr but expression is of type text
1204 LINE 1: INSERT INTO caster (cidr)          VALUES ('192.168.100.128/...
1205                                                    ^
1206 HINT:  You will need to rewrite or cast the expression.
1207 INSERT INTO caster (text)          VALUES ('192.168.100.128/25'::cidr);
1208 INSERT INTO caster (cidr)          VALUES ('192.168.100.128/25'::citext);
1209 ERROR:  column "cidr" is of type cidr but expression is of type citext
1210 LINE 1: INSERT INTO caster (cidr)          VALUES ('192.168.100.128/...
1211                                                    ^
1212 HINT:  You will need to rewrite or cast the expression.
1213 INSERT INTO caster (citext)        VALUES ('192.168.100.128/25'::cidr);
1214 -- Cannot cast to inet on assignment.
1215 INSERT INTO caster (inet)          VALUES ('192.168.100.128'::text);
1216 ERROR:  column "inet" is of type inet but expression is of type text
1217 LINE 1: INSERT INTO caster (inet)          VALUES ('192.168.100.128'...
1218                                                    ^
1219 HINT:  You will need to rewrite or cast the expression.
1220 INSERT INTO caster (text)          VALUES ('192.168.100.128'::inet);
1221 INSERT INTO caster (inet)          VALUES ('192.168.100.128'::citext);
1222 ERROR:  column "inet" is of type inet but expression is of type citext
1223 LINE 1: INSERT INTO caster (inet)          VALUES ('192.168.100.128'...
1224                                                    ^
1225 HINT:  You will need to rewrite or cast the expression.
1226 INSERT INTO caster (citext)        VALUES ('192.168.100.128'::inet);
1227 -- Cannot cast to macaddr on assignment.
1228 INSERT INTO caster (macaddr)       VALUES ('08:00:2b:01:02:03'::text);
1229 ERROR:  column "macaddr" is of type macaddr but expression is of type text
1230 LINE 1: INSERT INTO caster (macaddr)       VALUES ('08:00:2b:01:02:0...
1231                                                    ^
1232 HINT:  You will need to rewrite or cast the expression.
1233 INSERT INTO caster (text)          VALUES ('08:00:2b:01:02:03'::macaddr);
1234 INSERT INTO caster (macaddr)       VALUES ('08:00:2b:01:02:03'::citext);
1235 ERROR:  column "macaddr" is of type macaddr but expression is of type citext
1236 LINE 1: INSERT INTO caster (macaddr)       VALUES ('08:00:2b:01:02:0...
1237                                                    ^
1238 HINT:  You will need to rewrite or cast the expression.
1239 INSERT INTO caster (citext)        VALUES ('08:00:2b:01:02:03'::macaddr);
1240 -- Cannot cast to money on assignment.
1241 INSERT INTO caster (money)         VALUES ('12'::text);
1242 ERROR:  column "money" is of type money but expression is of type text
1243 LINE 1: INSERT INTO caster (money)         VALUES ('12'::text);
1244                                                    ^
1245 HINT:  You will need to rewrite or cast the expression.
1246 INSERT INTO caster (text)          VALUES ('12'::money);
1247 INSERT INTO caster (money)         VALUES ('12'::citext);
1248 ERROR:  column "money" is of type money but expression is of type citext
1249 LINE 1: INSERT INTO caster (money)         VALUES ('12'::citext);
1250                                                    ^
1251 HINT:  You will need to rewrite or cast the expression.
1252 INSERT INTO caster (citext)        VALUES ('12'::money);
1253 -- Cannot cast to timestamp on assignment.
1254 INSERT INTO caster (timestamp)     VALUES ('1999-01-08 04:05:06'::text);
1255 ERROR:  column "timestamp" is of type timestamp without time zone but expression is of type text
1256 LINE 1: INSERT INTO caster (timestamp)     VALUES ('1999-01-08 04:05...
1257                                                    ^
1258 HINT:  You will need to rewrite or cast the expression.
1259 INSERT INTO caster (text)          VALUES ('1999-01-08 04:05:06'::timestamp);
1260 INSERT INTO caster (timestamp)     VALUES ('1999-01-08 04:05:06'::citext);
1261 ERROR:  column "timestamp" is of type timestamp without time zone but expression is of type citext
1262 LINE 1: INSERT INTO caster (timestamp)     VALUES ('1999-01-08 04:05...
1263                                                    ^
1264 HINT:  You will need to rewrite or cast the expression.
1265 INSERT INTO caster (citext)        VALUES ('1999-01-08 04:05:06'::timestamp);
1266 -- Cannot cast to timestamptz on assignment.
1267 INSERT INTO caster (timestamptz)   VALUES ('1999-01-08 04:05:06'::text);
1268 ERROR:  column "timestamptz" is of type timestamp with time zone but expression is of type text
1269 LINE 1: INSERT INTO caster (timestamptz)   VALUES ('1999-01-08 04:05...
1270                                                    ^
1271 HINT:  You will need to rewrite or cast the expression.
1272 INSERT INTO caster (text)          VALUES ('1999-01-08 04:05:06'::timestamptz);
1273 INSERT INTO caster (timestamptz)   VALUES ('1999-01-08 04:05:06'::citext);
1274 ERROR:  column "timestamptz" is of type timestamp with time zone but expression is of type citext
1275 LINE 1: INSERT INTO caster (timestamptz)   VALUES ('1999-01-08 04:05...
1276                                                    ^
1277 HINT:  You will need to rewrite or cast the expression.
1278 INSERT INTO caster (citext)        VALUES ('1999-01-08 04:05:06'::timestamptz);
1279 -- Cannot cast to interval on assignment.
1280 INSERT INTO caster (interval)      VALUES ('1 hour'::text);
1281 ERROR:  column "interval" is of type interval but expression is of type text
1282 LINE 1: INSERT INTO caster (interval)      VALUES ('1 hour'::text);
1283                                                    ^
1284 HINT:  You will need to rewrite or cast the expression.
1285 INSERT INTO caster (text)          VALUES ('1 hour'::interval);
1286 INSERT INTO caster (interval)      VALUES ('1 hour'::citext);
1287 ERROR:  column "interval" is of type interval but expression is of type citext
1288 LINE 1: INSERT INTO caster (interval)      VALUES ('1 hour'::citext)...
1289                                                    ^
1290 HINT:  You will need to rewrite or cast the expression.
1291 INSERT INTO caster (citext)        VALUES ('1 hour'::interval);
1292 -- Cannot cast to date on assignment.
1293 INSERT INTO caster (date)          VALUES ('1999-01-08'::text);
1294 ERROR:  column "date" is of type date but expression is of type text
1295 LINE 1: INSERT INTO caster (date)          VALUES ('1999-01-08'::tex...
1296                                                    ^
1297 HINT:  You will need to rewrite or cast the expression.
1298 INSERT INTO caster (text)          VALUES ('1999-01-08'::date);
1299 INSERT INTO caster (date)          VALUES ('1999-01-08'::citext);
1300 ERROR:  column "date" is of type date but expression is of type citext
1301 LINE 1: INSERT INTO caster (date)          VALUES ('1999-01-08'::cit...
1302                                                    ^
1303 HINT:  You will need to rewrite or cast the expression.
1304 INSERT INTO caster (citext)        VALUES ('1999-01-08'::date);
1305 -- Cannot cast to time on assignment.
1306 INSERT INTO caster (time)          VALUES ('04:05:06'::text);
1307 ERROR:  column "time" is of type time without time zone but expression is of type text
1308 LINE 1: INSERT INTO caster (time)          VALUES ('04:05:06'::text)...
1309                                                    ^
1310 HINT:  You will need to rewrite or cast the expression.
1311 INSERT INTO caster (text)          VALUES ('04:05:06'::time);
1312 INSERT INTO caster (time)          VALUES ('04:05:06'::citext);
1313 ERROR:  column "time" is of type time without time zone but expression is of type citext
1314 LINE 1: INSERT INTO caster (time)          VALUES ('04:05:06'::citex...
1315                                                    ^
1316 HINT:  You will need to rewrite or cast the expression.
1317 INSERT INTO caster (citext)        VALUES ('04:05:06'::time);
1318 -- Cannot cast to timetz on assignment.
1319 INSERT INTO caster (timetz)        VALUES ('04:05:06'::text);
1320 ERROR:  column "timetz" is of type time with time zone but expression is of type text
1321 LINE 1: INSERT INTO caster (timetz)        VALUES ('04:05:06'::text)...
1322                                                    ^
1323 HINT:  You will need to rewrite or cast the expression.
1324 INSERT INTO caster (text)          VALUES ('04:05:06'::timetz);
1325 INSERT INTO caster (timetz)        VALUES ('04:05:06'::citext);
1326 ERROR:  column "timetz" is of type time with time zone but expression is of type citext
1327 LINE 1: INSERT INTO caster (timetz)        VALUES ('04:05:06'::citex...
1328                                                    ^
1329 HINT:  You will need to rewrite or cast the expression.
1330 INSERT INTO caster (citext)        VALUES ('04:05:06'::timetz);
1331 -- Cannot cast to point on assignment.
1332 INSERT INTO caster (point)         VALUES ('( 1 , 1)'::text);
1333 ERROR:  column "point" is of type point but expression is of type text
1334 LINE 1: INSERT INTO caster (point)         VALUES ('( 1 , 1)'::text)...
1335                                                    ^
1336 HINT:  You will need to rewrite or cast the expression.
1337 INSERT INTO caster (text)          VALUES ('( 1 , 1)'::point);
1338 INSERT INTO caster (point)         VALUES ('( 1 , 1)'::citext);
1339 ERROR:  column "point" is of type point but expression is of type citext
1340 LINE 1: INSERT INTO caster (point)         VALUES ('( 1 , 1)'::citex...
1341                                                    ^
1342 HINT:  You will need to rewrite or cast the expression.
1343 INSERT INTO caster (citext)        VALUES ('( 1 , 1)'::point);
1344 -- Cannot cast to lseg on assignment.
1345 INSERT INTO caster (lseg)          VALUES ('( 1 , 1 ) , ( 2 , 2 )'::text);
1346 ERROR:  column "lseg" is of type lseg but expression is of type text
1347 LINE 1: INSERT INTO caster (lseg)          VALUES ('( 1 , 1 ) , ( 2 ...
1348                                                    ^
1349 HINT:  You will need to rewrite or cast the expression.
1350 INSERT INTO caster (text)          VALUES ('( 1 , 1 ) , ( 2 , 2 )'::lseg);
1351 INSERT INTO caster (lseg)          VALUES ('( 1 , 1 ) , ( 2 , 2 )'::citext);
1352 ERROR:  column "lseg" is of type lseg but expression is of type citext
1353 LINE 1: INSERT INTO caster (lseg)          VALUES ('( 1 , 1 ) , ( 2 ...
1354                                                    ^
1355 HINT:  You will need to rewrite or cast the expression.
1356 INSERT INTO caster (citext)        VALUES ('( 1 , 1 ) , ( 2 , 2 )'::lseg);
1357 -- Cannot cast to box on assignment.
1358 INSERT INTO caster (box)           VALUES ('(0,0),(1,1)'::text);
1359 ERROR:  column "box" is of type box but expression is of type text
1360 LINE 1: INSERT INTO caster (box)           VALUES ('(0,0),(1,1)'::te...
1361                                                    ^
1362 HINT:  You will need to rewrite or cast the expression.
1363 INSERT INTO caster (text)          VALUES ('(0,0),(1,1)'::box);
1364 INSERT INTO caster (box)           VALUES ('(0,0),(1,1)'::citext);
1365 ERROR:  column "box" is of type box but expression is of type citext
1366 LINE 1: INSERT INTO caster (box)           VALUES ('(0,0),(1,1)'::ci...
1367                                                    ^
1368 HINT:  You will need to rewrite or cast the expression.
1369 INSERT INTO caster (citext)        VALUES ('(0,0),(1,1)'::box);
1370 -- Cannot cast to path on assignment.
1371 INSERT INTO caster (path)          VALUES ('((0,0),(1,1),(2,0))'::text);
1372 ERROR:  column "path" is of type path but expression is of type text
1373 LINE 1: INSERT INTO caster (path)          VALUES ('((0,0),(1,1),(2,...
1374                                                    ^
1375 HINT:  You will need to rewrite or cast the expression.
1376 INSERT INTO caster (text)          VALUES ('((0,0),(1,1),(2,0))'::path);
1377 INSERT INTO caster (path)          VALUES ('((0,0),(1,1),(2,0))'::citext);
1378 ERROR:  column "path" is of type path but expression is of type citext
1379 LINE 1: INSERT INTO caster (path)          VALUES ('((0,0),(1,1),(2,...
1380                                                    ^
1381 HINT:  You will need to rewrite or cast the expression.
1382 INSERT INTO caster (citext)        VALUES ('((0,0),(1,1),(2,0))'::path);
1383 -- Cannot cast to polygon on assignment.
1384 INSERT INTO caster (polygon)       VALUES ('((0,0),(1,1))'::text);
1385 ERROR:  column "polygon" is of type polygon but expression is of type text
1386 LINE 1: INSERT INTO caster (polygon)       VALUES ('((0,0),(1,1))'::...
1387                                                    ^
1388 HINT:  You will need to rewrite or cast the expression.
1389 INSERT INTO caster (text)          VALUES ('((0,0),(1,1))'::polygon);
1390 INSERT INTO caster (polygon)       VALUES ('((0,0),(1,1))'::citext);
1391 ERROR:  column "polygon" is of type polygon but expression is of type citext
1392 LINE 1: INSERT INTO caster (polygon)       VALUES ('((0,0),(1,1))'::...
1393                                                    ^
1394 HINT:  You will need to rewrite or cast the expression.
1395 INSERT INTO caster (citext)        VALUES ('((0,0),(1,1))'::polygon);
1396 -- Cannot cast to circle on assignment.
1397 INSERT INTO caster (circle)        VALUES ('((0,0),2)'::text);
1398 ERROR:  column "circle" is of type circle but expression is of type text
1399 LINE 1: INSERT INTO caster (circle)        VALUES ('((0,0),2)'::text...
1400                                                    ^
1401 HINT:  You will need to rewrite or cast the expression.
1402 INSERT INTO caster (text)          VALUES ('((0,0),2)'::circle);
1403 INSERT INTO caster (circle)        VALUES ('((0,0),2)'::citext);
1404 ERROR:  column "circle" is of type circle but expression is of type citext
1405 LINE 1: INSERT INTO caster (circle)        VALUES ('((0,0),2)'::cite...
1406                                                    ^
1407 HINT:  You will need to rewrite or cast the expression.
1408 INSERT INTO caster (citext)        VALUES ('((0,0),2)'::circle);
1409 -- Cannot cast to bit on assignment.
1410 INSERT INTO caster (bit)           VALUES ('101'::text);
1411 ERROR:  column "bit" is of type bit but expression is of type text
1412 LINE 1: INSERT INTO caster (bit)           VALUES ('101'::text);
1413                                                    ^
1414 HINT:  You will need to rewrite or cast the expression.
1415 INSERT INTO caster (text)          VALUES ('101'::bit);
1416 INSERT INTO caster (bit)           VALUES ('101'::citext);
1417 ERROR:  column "bit" is of type bit but expression is of type citext
1418 LINE 1: INSERT INTO caster (bit)           VALUES ('101'::citext);
1419                                                    ^
1420 HINT:  You will need to rewrite or cast the expression.
1421 INSERT INTO caster (citext)        VALUES ('101'::bit);
1422 -- Cannot cast to bit varying on assignment.
1423 INSERT INTO caster (bitv)          VALUES ('101'::text);
1424 ERROR:  column "bitv" is of type bit varying but expression is of type text
1425 LINE 1: INSERT INTO caster (bitv)          VALUES ('101'::text);
1426                                                    ^
1427 HINT:  You will need to rewrite or cast the expression.
1428 INSERT INTO caster (text)          VALUES ('101'::bit varying);
1429 INSERT INTO caster (bitv)          VALUES ('101'::citext);
1430 ERROR:  column "bitv" is of type bit varying but expression is of type citext
1431 LINE 1: INSERT INTO caster (bitv)          VALUES ('101'::citext);
1432                                                    ^
1433 HINT:  You will need to rewrite or cast the expression.
1434 INSERT INTO caster (citext)        VALUES ('101'::bit varying);
1435 -- Cannot cast to tsvector on assignment.
1436 INSERT INTO caster (tsvector)      VALUES ('the fat cat'::text);
1437 ERROR:  column "tsvector" is of type tsvector but expression is of type text
1438 LINE 1: INSERT INTO caster (tsvector)      VALUES ('the fat cat'::te...
1439                                                    ^
1440 HINT:  You will need to rewrite or cast the expression.
1441 INSERT INTO caster (text)          VALUES ('the fat cat'::tsvector);
1442 INSERT INTO caster (tsvector)      VALUES ('the fat cat'::citext);
1443 ERROR:  column "tsvector" is of type tsvector but expression is of type citext
1444 LINE 1: INSERT INTO caster (tsvector)      VALUES ('the fat cat'::ci...
1445                                                    ^
1446 HINT:  You will need to rewrite or cast the expression.
1447 INSERT INTO caster (citext)        VALUES ('the fat cat'::tsvector);
1448 -- Cannot cast to tsquery on assignment.
1449 INSERT INTO caster (tsquery)       VALUES ('fat & rat'::text);
1450 ERROR:  column "tsquery" is of type tsquery but expression is of type text
1451 LINE 1: INSERT INTO caster (tsquery)       VALUES ('fat & rat'::text...
1452                                                    ^
1453 HINT:  You will need to rewrite or cast the expression.
1454 INSERT INTO caster (text)          VALUES ('fat & rat'::tsquery);
1455 INSERT INTO caster (tsquery)       VALUES ('fat & rat'::citext);
1456 ERROR:  column "tsquery" is of type tsquery but expression is of type citext
1457 LINE 1: INSERT INTO caster (tsquery)       VALUES ('fat & rat'::cite...
1458                                                    ^
1459 HINT:  You will need to rewrite or cast the expression.
1460 INSERT INTO caster (citext)        VALUES ('fat & rat'::tsquery);
1461 -- Cannot cast to uuid on assignment.
1462 INSERT INTO caster (uuid)          VALUES ('a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'::text);
1463 ERROR:  column "uuid" is of type uuid but expression is of type text
1464 LINE 1: INSERT INTO caster (uuid)          VALUES ('a0eebc99-9c0b-4e...
1465                                                    ^
1466 HINT:  You will need to rewrite or cast the expression.
1467 INSERT INTO caster (text)          VALUES ('a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'::uuid);
1468 INSERT INTO caster (uuid)          VALUES ('a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'::citext);
1469 ERROR:  column "uuid" is of type uuid but expression is of type citext
1470 LINE 1: INSERT INTO caster (uuid)          VALUES ('a0eebc99-9c0b-4e...
1471                                                    ^
1472 HINT:  You will need to rewrite or cast the expression.
1473 INSERT INTO caster (citext)        VALUES ('a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'::uuid);
1474 -- Table 9-5. SQL String Functions and Operators
1475 SELECT 'D'::citext || 'avid'::citext = 'David'::citext AS citext_concat;
1476  citext_concat 
1477 ---------------
1478  t
1479 (1 row)
1480
1481 SELECT 'Value: '::citext || 42 = 'Value: 42' AS text_concat;
1482  text_concat 
1483 -------------
1484  t
1485 (1 row)
1486
1487 SELECT  42 || ': value'::citext ='42: value' AS int_concat;
1488  int_concat 
1489 ------------
1490  t
1491 (1 row)
1492
1493 SELECT bit_length('jose'::citext) = 32 AS t;
1494  t 
1495 ---
1496  t
1497 (1 row)
1498
1499 SELECT bit_length( name ) = bit_length( name::text ) AS t FROM srt;
1500  t 
1501 ---
1502  t
1503  t
1504  t
1505  t
1506  t
1507 (5 rows)
1508
1509 SELECT textlen( name ) = textlen( name::text ) AS t FROM srt;
1510  t 
1511 ---
1512  t
1513  t
1514  t
1515  t
1516  t
1517 (5 rows)
1518
1519 SELECT char_length( name ) = char_length( name::text ) AS t FROM srt;
1520  t 
1521 ---
1522  t
1523  t
1524  t
1525  t
1526  t
1527 (5 rows)
1528
1529 SELECT lower( name ) = lower( name::text ) AS t FROM srt;
1530  t 
1531 ---
1532  t
1533  t
1534  t
1535  t
1536  t
1537 (5 rows)
1538
1539 SELECT octet_length( name ) = octet_length( name::text ) AS t FROM srt;
1540  t 
1541 ---
1542  t
1543  t
1544  t
1545  t
1546  t
1547 (5 rows)
1548
1549 SELECT overlay( name placing 'hom' from 2 for 4) = overlay( name::text placing 'hom' from 2 for 4) AS t FROM srt;
1550  t 
1551 ---
1552  t
1553  t
1554  t
1555  t
1556  t
1557 (5 rows)
1558
1559 SELECT position( 'a' IN name ) = position( 'a' IN name::text ) AS t FROM srt;
1560  t 
1561 ---
1562  t
1563  t
1564  t
1565  t
1566  t
1567 (5 rows)
1568
1569 SELECT substr('alphabet'::citext, 3)       = 'phabet' AS t;
1570  t 
1571 ---
1572  t
1573 (1 row)
1574
1575 SELECT substr('alphabet'::citext, 3, 2)    = 'ph' AS t;
1576  t 
1577 ---
1578  t
1579 (1 row)
1580
1581 SELECT substring('alphabet'::citext, 3)    = 'phabet' AS t;
1582  t 
1583 ---
1584  t
1585 (1 row)
1586
1587 SELECT substring('alphabet'::citext, 3, 2) = 'ph' AS t;
1588  t 
1589 ---
1590  t
1591 (1 row)
1592
1593 SELECT substring('Thomas'::citext from 2 for 3) = 'hom' AS t;
1594  t 
1595 ---
1596  t
1597 (1 row)
1598
1599 SELECT substring('Thomas'::citext from 2) = 'homas' AS t;
1600  t 
1601 ---
1602  t
1603 (1 row)
1604
1605 SELECT substring('Thomas'::citext from '...$') = 'mas' AS t;
1606  t 
1607 ---
1608  t
1609 (1 row)
1610
1611 SELECT substring('Thomas'::citext from '%#"o_a#"_' for '#') = 'oma' AS t;
1612  t 
1613 ---
1614  t
1615 (1 row)
1616
1617 SELECT trim('    trim    '::citext)               = 'trim' AS t;
1618  t 
1619 ---
1620  t
1621 (1 row)
1622
1623 SELECT trim('xxxxxtrimxxxx'::citext, 'x'::citext) = 'trim' AS t;
1624  t 
1625 ---
1626  t
1627 (1 row)
1628
1629 SELECT trim('xxxxxxtrimxxxx'::text,  'x'::citext) = 'trim' AS t;
1630  t 
1631 ---
1632  t
1633 (1 row)
1634
1635 SELECT trim('xxxxxtrimxxxx'::text,   'x'::citext) = 'trim' AS t;
1636  t 
1637 ---
1638  t
1639 (1 row)
1640
1641 SELECT upper( name ) = upper( name::text ) AS t FROM srt;
1642  t 
1643 ---
1644  t
1645  t
1646  t
1647  t
1648  t
1649 (5 rows)
1650
1651 -- Table 9-6. Other String Functions.
1652 SELECT ascii( name ) = ascii( name::text ) AS t FROM srt;
1653  t 
1654 ---
1655  t
1656  t
1657  t
1658  t
1659  t
1660 (5 rows)
1661
1662 SELECT btrim('    trim'::citext                   ) = 'trim' AS t;
1663  t 
1664 ---
1665  t
1666 (1 row)
1667
1668 SELECT btrim('xxxxxtrimxxxx'::citext, 'x'::citext ) = 'trim' AS t;
1669  t 
1670 ---
1671  t
1672 (1 row)
1673
1674 SELECT btrim('xyxtrimyyx'::citext,    'xy'::citext) = 'trim' AS t;
1675  t 
1676 ---
1677  t
1678 (1 row)
1679
1680 SELECT btrim('xyxtrimyyx'::text,      'xy'::citext) = 'trim' AS t;
1681  t 
1682 ---
1683  t
1684 (1 row)
1685
1686 SELECT btrim('xyxtrimyyx'::citext,    'xy'::text  ) = 'trim' AS t;
1687  t 
1688 ---
1689  t
1690 (1 row)
1691
1692 -- chr() takes an int and returns text.
1693 -- convert() and convert_from take bytea and return text.
1694 SELECT convert_to( name, 'ISO-8859-1' ) = convert_to( name::text, 'ISO-8859-1' ) AS t FROM srt;
1695  t 
1696 ---
1697  t
1698  t
1699  t
1700  t
1701  t
1702 (5 rows)
1703
1704 SELECT decode('MTIzAAE='::citext, 'base64') = decode('MTIzAAE='::text, 'base64') AS t;
1705  t 
1706 ---
1707  t
1708 (1 row)
1709
1710 -- encode() takes bytea and returns text.
1711 SELECT initcap('hi THOMAS'::citext) = initcap('hi THOMAS'::text) AS t;
1712  t 
1713 ---
1714  t
1715 (1 row)
1716
1717 SELECT length( name ) = length( name::text ) AS t FROM srt;
1718  t 
1719 ---
1720  t
1721  t
1722  t
1723  t
1724  t
1725 (5 rows)
1726
1727 SELECT lpad('hi'::citext, 5              ) = '   hi' AS t;
1728  t 
1729 ---
1730  t
1731 (1 row)
1732
1733 SELECT lpad('hi'::citext, 5, 'xy'::citext) = 'xyxhi' AS t;
1734  t 
1735 ---
1736  t
1737 (1 row)
1738
1739 SELECT lpad('hi'::text,   5, 'xy'::citext) = 'xyxhi' AS t;
1740  t 
1741 ---
1742  t
1743 (1 row)
1744
1745 SELECT lpad('hi'::citext, 5, 'xy'::text  ) = 'xyxhi' AS t;
1746  t 
1747 ---
1748  t
1749 (1 row)
1750
1751 SELECT ltrim('    trim'::citext               ) = 'trim' AS t;
1752  t 
1753 ---
1754  t
1755 (1 row)
1756
1757 SELECT ltrim('zzzytrim'::citext, 'xyz'::citext) = 'trim' AS t;
1758  t 
1759 ---
1760  t
1761 (1 row)
1762
1763 SELECT ltrim('zzzytrim'::text,   'xyz'::citext) = 'trim' AS t;
1764  t 
1765 ---
1766  t
1767 (1 row)
1768
1769 SELECT ltrim('zzzytrim'::citext, 'xyz'::text  ) = 'trim' AS t;
1770  t 
1771 ---
1772  t
1773 (1 row)
1774
1775 SELECT md5( name ) = md5( name::text ) AS t FROM srt;
1776  t 
1777 ---
1778  t
1779  t
1780  t
1781  t
1782  t
1783 (5 rows)
1784
1785 -- pg_client_encoding() takes no args and returns name.
1786 SELECT quote_ident( name ) = quote_ident( name::text ) AS t FROM srt;
1787  t 
1788 ---
1789  t
1790  t
1791  t
1792  t
1793  t
1794 (5 rows)
1795
1796 SELECT quote_literal( name ) = quote_literal( name::text ) AS t FROM srt;
1797  t 
1798 ---
1799  t
1800  t
1801  t
1802  t
1803  t
1804 (5 rows)
1805
1806 SELECT regexp_matches('foobarbequebaz'::citext, '(bar)(beque)') = ARRAY[ 'bar', 'beque' ] AS t;
1807  t 
1808 ---
1809  t
1810 (1 row)
1811
1812 SELECT regexp_matches('foobarbequebaz'::citext, '(BAR)(BEQUE)') = ARRAY[ 'bar', 'beque' ] AS t;
1813  t 
1814 ---
1815  t
1816 (1 row)
1817
1818 SELECT regexp_matches('foobarbequebaz'::citext, '(BAR)(BEQUE)'::citext) = ARRAY[ 'bar', 'beque' ] AS t;
1819  t 
1820 ---
1821  t
1822 (1 row)
1823
1824 SELECT regexp_matches('foobarbequebaz'::citext, '(BAR)(BEQUE)'::citext, '') = ARRAY[ 'bar', 'beque' ] AS t;
1825  t 
1826 ---
1827  t
1828 (1 row)
1829
1830 SELECT regexp_matches('foobarbequebaz'::citext, '(BAR)(BEQUE)', '') = ARRAY[ 'bar', 'beque' ] AS t;
1831  t 
1832 ---
1833  t
1834 (1 row)
1835
1836 SELECT regexp_matches('foobarbequebaz', '(BAR)(BEQUE)'::citext, '') = ARRAY[ 'bar', 'beque' ] AS t;
1837  t 
1838 ---
1839  t
1840 (1 row)
1841
1842 SELECT regexp_matches('foobarbequebaz'::citext, '(BAR)(BEQUE)'::citext, ''::citext) = ARRAY[ 'bar', 'beque' ] AS t;
1843  t 
1844 ---
1845  t
1846 (1 row)
1847
1848 -- c forces case-sensitive
1849 SELECT regexp_matches('foobarbequebaz'::citext, '(BAR)(BEQUE)'::citext, 'c'::citext) = ARRAY[ 'bar', 'beque' ] AS "null";
1850  null 
1851 ------
1852  
1853 (1 row)
1854
1855 SELECT regexp_replace('Thomas'::citext, '.[mN]a.',         'M') = 'ThM' AS t;
1856  t 
1857 ---
1858  t
1859 (1 row)
1860
1861 SELECT regexp_replace('Thomas'::citext, '.[MN]A.',         'M') = 'ThM' AS t;
1862  t 
1863 ---
1864  t
1865 (1 row)
1866
1867 SELECT regexp_replace('Thomas',         '.[MN]A.'::citext, 'M') = 'ThM' AS t;
1868  t 
1869 ---
1870  t
1871 (1 row)
1872
1873 SELECT regexp_replace('Thomas'::citext, '.[MN]A.'::citext, 'M') = 'ThM' AS t;
1874  t 
1875 ---
1876  t
1877 (1 row)
1878
1879 -- c forces case-sensitive
1880 SELECT regexp_replace('Thomas'::citext, '.[MN]A.'::citext, 'M', 'c') = 'Thomas' AS t;
1881  t 
1882 ---
1883  t
1884 (1 row)
1885
1886 SELECT regexp_split_to_array('hello world'::citext, E'\\s+') = ARRAY[ 'hello', 'world' ] AS t;
1887  t 
1888 ---
1889  t
1890 (1 row)
1891
1892 SELECT regexp_split_to_array('helloTworld'::citext, 't') = ARRAY[ 'hello', 'world' ] AS t;
1893  t 
1894 ---
1895  t
1896 (1 row)
1897
1898 SELECT regexp_split_to_array('helloTworld', 't'::citext) = ARRAY[ 'hello', 'world' ] AS t;
1899  t 
1900 ---
1901  t
1902 (1 row)
1903
1904 SELECT regexp_split_to_array('helloTworld'::citext, 't'::citext) = ARRAY[ 'hello', 'world' ] AS t;
1905  t 
1906 ---
1907  t
1908 (1 row)
1909
1910 SELECT regexp_split_to_array('helloTworld'::citext, 't', 's') = ARRAY[ 'hello', 'world' ] AS t;
1911  t 
1912 ---
1913  t
1914 (1 row)
1915
1916 SELECT regexp_split_to_array('helloTworld', 't'::citext, 's') = ARRAY[ 'hello', 'world' ] AS t;
1917  t 
1918 ---
1919  t
1920 (1 row)
1921
1922 SELECT regexp_split_to_array('helloTworld'::citext, 't'::citext, 's') = ARRAY[ 'hello', 'world' ] AS t;
1923  t 
1924 ---
1925  t
1926 (1 row)
1927
1928 -- c forces case-sensitive
1929 SELECT regexp_split_to_array('helloTworld'::citext, 't'::citext, 'c') = ARRAY[ 'helloTworld' ] AS t;
1930  t 
1931 ---
1932  t
1933 (1 row)
1934
1935 SELECT regexp_split_to_table('hello world'::citext, E'\\s+') AS words;
1936  words 
1937 -------
1938  hello
1939  world
1940 (2 rows)
1941
1942 SELECT regexp_split_to_table('helloTworld'::citext, 't') AS words;
1943  words 
1944 -------
1945  hello
1946  world
1947 (2 rows)
1948
1949 SELECT regexp_split_to_table('helloTworld',         't'::citext) AS words;
1950  words 
1951 -------
1952  hello
1953  world
1954 (2 rows)
1955
1956 SELECT regexp_split_to_table('helloTworld'::citext, 't'::citext) AS words;
1957  words 
1958 -------
1959  hello
1960  world
1961 (2 rows)
1962
1963 -- c forces case-sensitive
1964 SELECT regexp_split_to_table('helloTworld'::citext, 't'::citext, 'c') AS word;
1965     word     
1966 -------------
1967  helloTworld
1968 (1 row)
1969
1970 SELECT repeat('Pg'::citext, 4) = 'PgPgPgPg' AS t;
1971  t 
1972 ---
1973  t
1974 (1 row)
1975
1976 SELECT replace('abcdefabcdef'::citext, 'cd', 'XX') = 'abXXefabXXef' AS t;
1977  t 
1978 ---
1979  t
1980 (1 row)
1981
1982 SELECT replace('abcdefabcdef'::citext, 'CD', 'XX') = 'abXXefabXXef' AS t;
1983  t 
1984 ---
1985  t
1986 (1 row)
1987
1988 SELECT replace('ab^is$abcdef'::citext, '^is$', 'XX') = 'abXXabcdef' AS t;
1989  t 
1990 ---
1991  t
1992 (1 row)
1993
1994 SELECT replace('abcdefabcdef', 'cd'::citext, 'XX') = 'abXXefabXXef' AS t;
1995  t 
1996 ---
1997  t
1998 (1 row)
1999
2000 SELECT replace('abcdefabcdef', 'CD'::citext, 'XX') = 'abXXefabXXef' AS t;
2001  t 
2002 ---
2003  t
2004 (1 row)
2005
2006 SELECT replace('ab^is$abcdef', '^is$'::citext, 'XX') = 'abXXabcdef' AS t;
2007  t 
2008 ---
2009  t
2010 (1 row)
2011
2012 SELECT replace('abcdefabcdef'::citext, 'cd'::citext, 'XX') = 'abXXefabXXef' AS t;
2013  t 
2014 ---
2015  t
2016 (1 row)
2017
2018 SELECT replace('abcdefabcdef'::citext, 'CD'::citext, 'XX') = 'abXXefabXXef' AS t;
2019  t 
2020 ---
2021  t
2022 (1 row)
2023
2024 SELECT replace('ab^is$abcdef'::citext, '^is$'::citext, 'XX') = 'abXXabcdef' AS t;
2025  t 
2026 ---
2027  t
2028 (1 row)
2029
2030 SELECT rpad('hi'::citext, 5              ) = 'hi   ' AS t;
2031  t 
2032 ---
2033  t
2034 (1 row)
2035
2036 SELECT rpad('hi'::citext, 5, 'xy'::citext) = 'hixyx' AS t;
2037  t 
2038 ---
2039  t
2040 (1 row)
2041
2042 SELECT rpad('hi'::text,   5, 'xy'::citext) = 'hixyx' AS t;
2043  t 
2044 ---
2045  t
2046 (1 row)
2047
2048 SELECT rpad('hi'::citext, 5, 'xy'::text  ) = 'hixyx' AS t;
2049  t 
2050 ---
2051  t
2052 (1 row)
2053
2054 SELECT rtrim('trim    '::citext             ) = 'trim' AS t;
2055  t 
2056 ---
2057  t
2058 (1 row)
2059
2060 SELECT rtrim('trimxxxx'::citext, 'x'::citext) = 'trim' AS t;
2061  t 
2062 ---
2063  t
2064 (1 row)
2065
2066 SELECT rtrim('trimxxxx'::text,   'x'::citext) = 'trim' AS t;
2067  t 
2068 ---
2069  t
2070 (1 row)
2071
2072 SELECT rtrim('trimxxxx'::text,   'x'::text  ) = 'trim' AS t;
2073  t 
2074 ---
2075  t
2076 (1 row)
2077
2078 SELECT split_part('abc~@~def~@~ghi'::citext, '~@~', 2) = 'def' AS t;
2079  t 
2080 ---
2081  t
2082 (1 row)
2083
2084 SELECT split_part('abcTdefTghi'::citext, 't', 2) = 'def' AS t;
2085  t 
2086 ---
2087  t
2088 (1 row)
2089
2090 SELECT split_part('abcTdefTghi'::citext, 't'::citext, 2) = 'def' AS t;
2091  t 
2092 ---
2093  t
2094 (1 row)
2095
2096 SELECT split_part('abcTdefTghi', 't'::citext, 2) = 'def' AS t;
2097  t 
2098 ---
2099  t
2100 (1 row)
2101
2102 SELECT strpos('high'::citext, 'ig'        ) = 2 AS t;
2103  t 
2104 ---
2105  t
2106 (1 row)
2107
2108 SELECT strpos('high',         'ig'::citext) = 2 AS t;
2109  t 
2110 ---
2111  t
2112 (1 row)
2113
2114 SELECT strpos('high'::citext, 'ig'::citext) = 2 AS t;
2115  t 
2116 ---
2117  t
2118 (1 row)
2119
2120 SELECT strpos('high'::citext, 'IG'        ) = 2 AS t;
2121  t 
2122 ---
2123  t
2124 (1 row)
2125
2126 SELECT strpos('high',         'IG'::citext) = 2 AS t;
2127  t 
2128 ---
2129  t
2130 (1 row)
2131
2132 SELECT strpos('high'::citext, 'IG'::citext) = 2 AS t;
2133  t 
2134 ---
2135  t
2136 (1 row)
2137
2138 -- to_ascii() does not support UTF-8.
2139 -- to_hex() takes a numeric argument.
2140 SELECT substr('alphabet', 3, 2) = 'ph' AS t;
2141  t 
2142 ---
2143  t
2144 (1 row)
2145
2146 SELECT translate('abcdefabcdef'::citext, 'cd',         'XX') = 'abXXefabXXef' AS t;
2147  t 
2148 ---
2149  t
2150 (1 row)
2151
2152 SELECT translate('abcdefabcdef'::citext, 'CD',         'XX') = 'abXXefabXXef' AS t;
2153  t 
2154 ---
2155  t
2156 (1 row)
2157
2158 SELECT translate('abcdefabcdef'::citext, 'CD'::citext, 'XX') = 'abXXefabXXef' AS t;
2159  t 
2160 ---
2161  t
2162 (1 row)
2163
2164 SELECT translate('abcdefabcdef',         'CD'::citext, 'XX') = 'abXXefabXXef' AS t;
2165  t 
2166 ---
2167  t
2168 (1 row)
2169
2170 -- Table 9-20. Formatting Functions
2171 SELECT to_date('05 Dec 2000'::citext, 'DD Mon YYYY'::citext)
2172      = to_date('05 Dec 2000',         'DD Mon YYYY') AS t;
2173  t 
2174 ---
2175  t
2176 (1 row)
2177
2178 SELECT to_date('05 Dec 2000'::citext, 'DD Mon YYYY')
2179      = to_date('05 Dec 2000',         'DD Mon YYYY') AS t;
2180  t 
2181 ---
2182  t
2183 (1 row)
2184
2185 SELECT to_date('05 Dec 2000',         'DD Mon YYYY'::citext)
2186      = to_date('05 Dec 2000',         'DD Mon YYYY') AS t;
2187  t 
2188 ---
2189  t
2190 (1 row)
2191
2192 SELECT to_number('12,454.8-'::citext, '99G999D9S'::citext)
2193      = to_number('12,454.8-',         '99G999D9S') AS t;
2194  t 
2195 ---
2196  t
2197 (1 row)
2198
2199 SELECT to_number('12,454.8-'::citext, '99G999D9S')
2200      = to_number('12,454.8-',         '99G999D9S') AS t;
2201  t 
2202 ---
2203  t
2204 (1 row)
2205
2206 SELECT to_number('12,454.8-',         '99G999D9S'::citext)
2207      = to_number('12,454.8-',         '99G999D9S') AS t;
2208  t 
2209 ---
2210  t
2211 (1 row)
2212
2213 SELECT to_timestamp('05 Dec 2000'::citext, 'DD Mon YYYY'::citext)
2214      = to_timestamp('05 Dec 2000',         'DD Mon YYYY') AS t;
2215  t 
2216 ---
2217  t
2218 (1 row)
2219
2220 SELECT to_timestamp('05 Dec 2000'::citext, 'DD Mon YYYY')
2221      = to_timestamp('05 Dec 2000',         'DD Mon YYYY') AS t;
2222  t 
2223 ---
2224  t
2225 (1 row)
2226
2227 SELECT to_timestamp('05 Dec 2000',         'DD Mon YYYY'::citext)
2228      = to_timestamp('05 Dec 2000',         'DD Mon YYYY') AS t;
2229  t 
2230 ---
2231  t
2232 (1 row)
2233
2234 -- Try assigning function results to a column.
2235 SELECT COUNT(*) = 8::bigint AS t FROM try;
2236  t 
2237 ---
2238  t
2239 (1 row)
2240
2241 INSERT INTO try
2242 VALUES ( to_char(  now()::timestamp,          'HH12:MI:SS') ),
2243        ( to_char(  now() + '1 sec'::interval, 'HH12:MI:SS') ), -- timetamptz
2244        ( to_char(  '15h 2m 12s'::interval,    'HH24:MI:SS') ),
2245        ( to_char(  current_date,              '999') ),
2246        ( to_char(  125::int,                  '999') ),
2247        ( to_char(  127::int4,                 '999') ),
2248        ( to_char(  126::int8,                 '999') ),
2249        ( to_char(  128.8::real,               '999D9') ),
2250        ( to_char(  125.7::float4,             '999D9') ),
2251        ( to_char(  125.9::float8,             '999D9') ),
2252        ( to_char( -125.8::numeric,            '999D99S') );
2253 SELECT COUNT(*) = 19::bigint AS t FROM try;
2254  t 
2255 ---
2256  t
2257 (1 row)
2258
2259 SELECT like_escape( name, '' ) = like_escape( name::text, '' ) AS t FROM srt;
2260  t 
2261 ---
2262  t
2263  t
2264  t
2265  t
2266  t
2267 (5 rows)
2268
2269 SELECT like_escape( name::text, ''::citext ) = like_escape( name::text, '' ) AS t FROM srt;
2270  t 
2271 ---
2272  t
2273  t
2274  t
2275  t
2276  t
2277 (5 rows)
2278
2279 -- Ensure correct behavior for citext with materialized views.
2280 CREATE TABLE citext_table (
2281   id serial primary key,
2282   name citext
2283 );
2284 INSERT INTO citext_table (name)
2285   VALUES ('one'), ('two'), ('three'), (NULL), (NULL);
2286 CREATE MATERIALIZED VIEW citext_matview AS
2287   SELECT * FROM citext_table;
2288 CREATE UNIQUE INDEX citext_matview_id
2289   ON citext_matview (id);
2290 SELECT *
2291   FROM citext_matview m
2292   FULL JOIN citext_table t ON (t.id = m.id AND t *= m)
2293   WHERE t.id IS NULL OR m.id IS NULL;
2294  id | name | id | name 
2295 ----+------+----+------
2296 (0 rows)
2297
2298 UPDATE citext_table SET name = 'Two' WHERE name = 'TWO';
2299 SELECT *
2300   FROM citext_matview m
2301   FULL JOIN citext_table t ON (t.id = m.id AND t *= m)
2302   WHERE t.id IS NULL OR m.id IS NULL;
2303  id | name | id | name 
2304 ----+------+----+------
2305     |      |  2 | Two
2306   2 | two  |    | 
2307 (2 rows)
2308
2309 REFRESH MATERIALIZED VIEW CONCURRENTLY citext_matview;
2310 SELECT * FROM citext_matview ORDER BY id;
2311  id | name  
2312 ----+-------
2313   1 | one
2314   2 | Two
2315   3 | three
2316   4 | 
2317   5 | 
2318 (5 rows)
2319