Tom Lane <t...@sss.pgh.pa.us> wrote:
 
> What would be affected is something like
> 
>       select text((1,2));
> 
> which you'd now be forced to write as
> 
>       select (1,2)::text;
> 
> (or you could use CAST notation; but not text(row) or row.text).
 
Right.  As far as I'm aware, there are currently four ways to spell
"cast record to text":
 
select cast((1,2) as text);
select (1,2)::text;
select text((1,2));
select ((1,2)).text;
 
We would be disallowing the last two spellings.  They aren't that
reliable as casts anyway, since whether they are taken as a cast
depends on the field names of the record.
 
test=# create type x as (a int, b int, c text);
CREATE TYPE
test=# select cast((1,2,'three')::x as text);
     row
-------------
 (1,2,three)
(1 row)

test=# select (1,2,'three')::x::text;
     row
-------------
 (1,2,three)
(1 row)

test=# select text((1,2,'three')::x);
    text
-------------
 (1,2,three)
(1 row)

test=# select ((1,2,'three')::x).text;
    text
-------------
 (1,2,three)
(1 row)

test=# drop type x;
DROP TYPE
test=# create type x as (a int, b int, text text);
CREATE TYPE
test=# select cast((1,2,'three')::x as text);
     row
-------------
 (1,2,three)
(1 row)

test=# select (1,2,'three')::x::text;
     row
-------------
 (1,2,three)
(1 row)

test=# select text((1,2,'three')::x);
 text
-------
 three
(1 row)

test=# select ((1,2,'three')::x).text;
 text
-------
 three
(1 row)
 
So we would only be keeping cast syntax which can be counted on to
retain cast semantics in the face of a column name change.
 
-Kevin

-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Reply via email to