Re: [PERFORM] typoed column name, but postgres didn't grump

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Merlin Moncure" <mmoncure(at)gmail(dot)com>, "Robert Haas" <robertmhaas(at)gmail(dot)com>, "Jon Nelson" <jnelson+pgsql(at)jamponi(dot)net>, <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: [PERFORM] typoed column name, but postgres didn't grump
Date: 2010-11-04 16:49:28
Message-ID: 4CD29DC802000025000372A4@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-performance

Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2010-11-04 16:56:20 Re: [PERFORM] typoed column name, but postgres didn't grump
Previous Message Merlin Moncure 2010-11-04 16:48:08 Re: [PERFORM] typoed column name, but postgres didn't grump

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2010-11-04 16:56:20 Re: [PERFORM] typoed column name, but postgres didn't grump
Previous Message Merlin Moncure 2010-11-04 16:48:08 Re: [PERFORM] typoed column name, but postgres didn't grump