Re: [GENERAL] Some issues about data type convert

2010-01-05 Thread Sam Mason
On Mon, Jan 04, 2010 at 12:45:00PM -0500, Tom Lane wrote: > Sam Mason writes: > > Um, I think the OP is right. Notice he does: ... > > showing that PG is auto-magically inserting a cast from BIGINT to OID. > > Yes, as a quick look into pg_cast will show you, bigint -> oid is an > implicit cast:

Re: [GENERAL] Some issues about data type convert

2010-01-04 Thread donniehan
>> Um, I think the OP is right. Notice he does: ... >> showing that PG is auto-magically inserting a cast from BIGINT to OID. >>I think the OP is either expecting the CREATE VIEW to fail saying types >>are invalid, or to result in "c1" being cast to BIGINT Yes, that's what i mean. Is that more r

Re: [GENERAL] Some issues about data type convert

2010-01-04 Thread Tom Lane
Sam Mason writes: > Um, I think the OP is right. Notice he does: ... > showing that PG is auto-magically inserting a cast from BIGINT to OID. Yes, as a quick look into pg_cast will show you, bigint -> oid is an implicit cast: regression=# \dC+ oid List of casts Sour

Re: [GENERAL] Some issues about data type convert

2010-01-04 Thread Sam Mason
On Mon, Jan 04, 2010 at 03:55:15PM +0100, Albe Laurenz wrote: > donniehan wrote: > > postgres=# create table test1(c1 OID, c2 BIGINT); > > postgres=# create view v1 as select coalesce(c1,c2) from test1; > > postgres=# \d v1 > > SELECT COALESCE(test1.c1, test1.c2::oid) AS "coalesce" > >FROM tes

Re: [GENERAL] Some issues about data type convert

2010-01-04 Thread Albe Laurenz
donniehan wrote: > I have a question about pg_cast--- data type convert. > Pg provide more data types than sql spec, such as OID. > Internal OID type is unsigned int32 and INT8 is int64. > > Why pg can convert INT8 into OID implicitly while can not > convert OID into INT8 implicitly?

[GENERAL] Some issues about data type convert

2010-01-04 Thread donniehan
Hi guys, I have a question about pg_cast--- data type convert. Pg provide more data types than sql spec, such as OID. Internal OID type is unsigned int32 and INT8 is int64. Why pg can convert INT8 into OID implicitly while can not convert OID into INT8 implicitly? There may be some pr