Re: no implicit cast error in 9.2?

From: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>
To: AI Rumman <rummandba(at)gmail(dot)com>
Cc: pgsql-general General <pgsql-general(at)postgresql(dot)org>
Subject: Re: no implicit cast error in 9.2?
Date: 2013-02-08 21:20:39
Message-ID: 51156C27.9080108@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 02/08/2013 12:23 PM, AI Rumman wrote:
> Hi,
>
> I am using
> PostgreSQL 9.2.3 on x86_64-unknown-linux-gnu, compiled by gcc (GCC)
> 4.4.6 20120305 (Red Hat 4.4.6-4), 64-bit.
>
> I got a bit confused after installing this version. So far I used to
> know that from Postgresql 8.3 implicit casting has been removed and the
> following should not work at 8.3 :
> create table testtab ( id varchar, id1 int)
> insert into testtab values (1,1);
>
> Where it was good to work at 8.1
>
> http://osdir.com/ml/pgsql-general/2011-02/msg00055.html
>
> I also faced the problem earlier.
>
> But in 9.2 it is working perfectly.
> Am I missing any release notes?
>
> Please share your opinion. It will be appreciated.

As I remember implicit casting was not entirely removed and the
text <--> int combination was kept.

To extend your example, you can see it works both ways::

test=# create table testtab ( id varchar, id1 int);
CREATE TABLE
test=# insert into testtab values (1,1);
INSERT 0 1
test=# insert into testtab values (1,'1');
INSERT 0 1
test=# SELECT * from testtab ;
id | id1
----+-----
1 | 1
1 | 1
(2 rows)

Unless of course you use a non-integer string:

test=# insert into testtab values (1,'one');
ERROR: invalid input syntax for integer: "one"
LINE 1: insert into testtab values (1,'one');

>
> Thanks.

--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Kevin Grittner 2013-02-08 21:50:05 Re: no implicit cast error in 9.2?
Previous Message Jay McGaffigan 2013-02-08 20:43:21 Restoring a database dump from 9.0 to 9.2