dbTalk Databases Forums  

[BUGS] BUG #1437: converting column from text to int4 requires USING

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] BUG #1437: converting column from text to int4 requires USING in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Kim Hansen
 
Posts: n/a

Default [BUGS] BUG #1437: converting column from text to int4 requires USING - 01-24-2005 , 01:06 AM







The following bug has been logged online:

Bug reference: 1437
Logged by: Kim Hansen
Email address: k (AT) oek (DOT) dk
PostgreSQL version: 8.0.0
Operating system: Windows
Description: converting column from text to int4 requires USING
Details:

When running the input below the 3rd line gives an error but the 4th line
works. I would expect that a::int4 was applyed by default and because of
that the USING shouldn't be nessesary.

== Input ==
CREATE TABLE test ( a text );
INSERT INTO test VALUES ( '1' );
ALTER TABLE test ALTER COLUMN a TYPE int4;
ALTER TABLE test ALTER COLUMN a TYPE int4 USING (a::int4);
DROP TABLE test;

== Output==
public=> \i bug.txt
CREATE TABLE
INSERT 25508 1
psql:bug.txt:3: ERROR: column "a" cannot be cast to type "int4"
ALTER TABLE
DROP TABLE
public=>

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Reply With Quote
  #2  
Old   
Kim Hansen
 
Posts: n/a

Default Re: [BUGS] BUG #1437: converting column from text to int4 requires USING - 01-24-2005 , 01:08 AM






Quote:
From: "Kim Hansen" <k (AT) oek (DOT) dk
To: pgsql-bugs (AT) postgresql (DOT) org
Date: Mon, 24 Jan 2005 00:41:10 GMT
Subject: BUG #1437: converting column from text to int4 requires USING
=20
The following bug has been logged online:
=20
Bug reference: 1437
Logged by: Kim Hansen
Email address: k (AT) oek (DOT) dk
PostgreSQL version: 8.0.0
Operating system: Windows
Description: converting column from text to int4 requires USING
Details:
I have just found out that this isn't a bug. I just didn't know that
there was a difference between 'assignment cast' and 'implicit cast'.

I think that the error message from line 3 is misleading as line 4
casts column a into int4. Perhaps a HINT: could be added that an
explicit typecast might be needed.

Regards,
--=20
Kim Hansen
Vadg=E5rdsvej 3, 2.tv
2860 S=F8borg
Tlf: 39 56 24 37

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.