X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id E2A439DC810 for ; Wed, 28 Dec 2005 17:23:04 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 44304-08 for ; Wed, 28 Dec 2005 17:23:04 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from alvh.no-ip.org (201-220-123-7.bk10-dsl.surnet.cl [201.220.123.7]) by postgresql.org (Postfix) with ESMTP id 5F15F9DC836 for ; Wed, 28 Dec 2005 17:23:01 -0400 (AST) Received: by alvh.no-ip.org (Postfix, from userid 1000) id A143EC2DC71; Wed, 28 Dec 2005 18:24:02 -0300 (CLST) Date: Wed, 28 Dec 2005 18:24:02 -0300 From: Alvaro Herrera To: George Pavlov Cc: pgsql-sql@postgresql.org Subject: Re: DISTINCT with NULLs and INT fields Message-ID: <20051228212402.GC5231@surnet.cl> Mail-Followup-To: George Pavlov , pgsql-sql@postgresql.org References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.11 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=1.74 required=5 tests=[AWL=-0.179, DNS_FROM_RFC_ABUSE=0.479, DNS_FROM_RFC_POST=1.44] X-Spam-Score: 1.74 X-Spam-Level: * X-Archive-Number: 200512/229 X-Sequence-Number: 23771 George Pavlov wrote: > test=# insert into foo values (4::int,4::int); > INSERT 0 1 > test=# insert into foo values (4::text,4::text); > ERROR: column "b" is of type integer but expression is of type text > HINT: You will need to rewrite or cast the expression. > test=# insert into foo values (cast(4 as int),cast(4 as int)); > INSERT 0 1 > test=# insert into foo values (cast(4 as text),cast(4 as text)); > ERROR: column "b" is of type integer but expression is of type text > HINT: You will need to rewrite or cast the expression. The last sentence (and the second one as well -- they are exactly equivalent) exemplifies that there isn't an implicit typecase from text to integer. If you use single quotes instead of an explicit cast, the literal is assumed to be of type "unknown", which _can_ be casted automatically to integer. -- Alvaro Herrera http://www.CommandPrompt.com/ PostgreSQL Replication, Consulting, Custom Development, 24x7 support