Re: Possible bug on insert

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Rick Gigger <rgigger(at)leadership-solutions(dot)net>
Cc: Vivek Khera <khera(at)kcilink(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Possible bug on insert
Date: 2003-10-08 16:41:40
Message-ID: 20031008093058.E90693@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 7 Oct 2003, Rick Gigger wrote:

> I am also still confused as to what the rules are that I am breaking. For
> instance:
>
> The following will all execute successfully:
>
> CREATE TABLE bugtest ( a int2 );
> select '1' union select '2';
> insert into bugtest values('1');
> insert into bugtest values('2');

Technically speaking, I believe the above inserts would be errors in plain
SQL92 (I don't believe character(1) is assignable to an exact numeric
type). In part because of the flexible type system, we try to treat such
things as the type being assigned to when possible.

> insert into bugtest (a) select '1' union select '2';
>
> Where exactly is the illegal type conversion taking place in the last
> statement that is different from the above statements.

The union requires us to figure out what type it is before we get to
actually doing the insert. It might be possible in union all to avoid
that, but for union, you need to know what rules to use to determine
duplicates, so I really don't think there's any choice there (imagine that
the values were say '1.1' and '1.2'... Are those two distinct values or
not?)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message John Wells 2003-10-08 16:47:38 Re: Humor me: Postgresql vs. MySql (esp. licensing)
Previous Message Christopher Browne 2003-10-08 16:39:33 Re: Humor me: Postgresql vs. MySql (esp. licensing)