2000-01-04 17:19:34 +01:00
|
|
|
--
|
|
|
|
-- TEXT
|
|
|
|
--
|
|
|
|
SELECT text 'this is a text string' = text 'this is a text string' AS true;
|
|
|
|
true
|
|
|
|
------
|
|
|
|
t
|
1997-04-05 13:24:54 +02:00
|
|
|
(1 row)
|
|
|
|
|
2000-01-04 17:19:34 +01:00
|
|
|
SELECT text 'this is a text string' = text 'this is a text strin' AS false;
|
|
|
|
false
|
|
|
|
-------
|
|
|
|
f
|
1997-04-05 13:24:54 +02:00
|
|
|
(1 row)
|
|
|
|
|
2000-01-04 17:19:34 +01:00
|
|
|
CREATE TABLE TEXT_TBL (f1 text);
|
|
|
|
INSERT INTO TEXT_TBL VALUES ('doh!');
|
|
|
|
INSERT INTO TEXT_TBL VALUES ('hi de ho neighbor');
|
|
|
|
SELECT '' AS two, * FROM TEXT_TBL;
|
|
|
|
two | f1
|
|
|
|
-----+-------------------
|
|
|
|
| doh!
|
|
|
|
| hi de ho neighbor
|
1997-12-01 03:44:53 +01:00
|
|
|
(2 rows)
|
|
|
|
|
2007-06-07 01:00:50 +02:00
|
|
|
-- As of 8.3 we have removed most implicit casts to text, so that for example
|
|
|
|
-- this no longer works:
|
|
|
|
select length(42);
|
|
|
|
ERROR: function length(integer) does not exist
|
|
|
|
LINE 1: select length(42);
|
|
|
|
^
|
|
|
|
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
|
|
|
-- But as a special exception for usability's sake, we still allow implicit
|
|
|
|
-- casting to text in concatenations, so long as the other input is text or
|
|
|
|
-- an unknown literal. So these work:
|
|
|
|
select 'four: '::text || 2+2;
|
|
|
|
?column?
|
|
|
|
----------
|
|
|
|
four: 4
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
select 'four: ' || 2+2;
|
|
|
|
?column?
|
|
|
|
----------
|
|
|
|
four: 4
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
-- but not this:
|
|
|
|
select 3 || 4.0;
|
|
|
|
ERROR: operator does not exist: integer || numeric
|
|
|
|
LINE 1: select 3 || 4.0;
|
|
|
|
^
|
|
|
|
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
|