duplicated partial-column assigns allowed by checkInsertTargets

Started by Alvaro Herreraabout 11 years ago2 messages
#1Alvaro Herrera
alvherre@2ndquadrant.com

While perusing checkInsertTargets I noticed that it allows duplicated
assignments to the same member of a composite:

alvherre=# create type f as (a int, b int);
CREATE TYPE
alvherre=# create table t (col f);
CREATE TABLE
alvherre=# insert into t (col.a, col.b, col.a) values (42, 43, 44);
INSERT 0 1
alvherre=# select * from t;
col
---------
(44,43)
(1 fila)

If you instead try a duplicate "col", it is rightfully rejected:

alvherre=# insert into t (col, col) values ((42, 43), (44, 43));
ERROR: column "col" specified more than once
L�NEA 1: insert into t (col, col) values ((42, 43), (44, 43));
^

Isn't this a bit odd?

--
�lvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

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

#2Jim Nasby
Jim.Nasby@BlueTreble.com
In reply to: Alvaro Herrera (#1)
Re: duplicated partial-column assigns allowed by checkInsertTargets

On 12/4/14, 2:23 PM, Alvaro Herrera wrote:

While perusing checkInsertTargets I noticed that it allows duplicated
assignments to the same member of a composite:

alvherre=# create type f as (a int, b int);
CREATE TYPE
alvherre=# create table t (col f);
CREATE TABLE
alvherre=# insert into t (col.a, col.b, col.a) values (42, 43, 44);
INSERT 0 1
alvherre=# select * from t;
col
---------
(44,43)
(1 fila)

If you instead try a duplicate "col", it is rightfully rejected:

alvherre=# insert into t (col, col) values ((42, 43), (44, 43));
ERROR: column "col" specified more than once
L�NEA 1: insert into t (col, col) values ((42, 43), (44, 43));
^

Isn't this a bit odd?

Yes, and sounds like a good way to create bugs... my vote would be to fix this.
--
Jim Nasby, Data Architect, Blue Treble Consulting
Data in Trouble? Get it in Treble! http://BlueTreble.com

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