Re: BUG #5225: create table: cast necessary for constant?? - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #5225: create table: cast necessary for constant??
Date
Msg-id 14532.1259771701@sss.pgh.pa.us
Whole thread Raw
In response to BUG #5225: create table: cast necessary for constant??  ("Kurt wagner" <kurt.wagnerextern@leoni.com>)
Responses Re: BUG #5225: create table: cast necessary for constant??
List pgsql-bugs
"Kurt wagner" <kurt.wagnerextern@leoni.com> writes:
> During migration from Informix to Postgres I came across following issue:
> create temp table temp1 as
>    SELECT  firmnr,
>            werknr,
>            'I' as invper,
>            invnum
>    from .... ;

You really ought to cast the 'I' to some specific type.  The above code
is illegal per SQL standard.  You can get away with it in certain
contexts in Postgres, but when you are creating a table or view and
don't know exactly what might be done with the column, it's much better
to ensure it's of the intended type.  We aren't going to make it default
to text or whatever because it's not always clear that that's what's
intended --- consider

    '1.2' as invper,
    '2009-11-23' as invper,

Most likely text was not what the writer had in mind in such cases.

            regards, tom lane

pgsql-bugs by date:

Previous
From: Sriram Gopalan
Date:
Subject: Re: BUG #5224: After upgrading from vista to windows 7, postgres services are missing
Next
From: Craig Ringer
Date:
Subject: Re: BUG #5226: Limit operator slows down