X-Original-To: pgsql-odbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 582AF52A62 for ; Mon, 7 Mar 2005 17:44:46 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 49181-07 for ; Mon, 7 Mar 2005 17:44:36 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 4170452A88 for ; Mon, 7 Mar 2005 17:44:36 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j27HiZRE003086; Mon, 7 Mar 2005 12:44:36 -0500 (EST) To: Kelly Burkhart Cc: pgsql-odbc@postgresql.org Subject: Re: Insert SHRT_MIN fails for int2 column In-reply-to: <1110212157.3206.10.camel@krb06> References: <1110212157.3206.10.camel@krb06> Comments: In-reply-to Kelly Burkhart message dated "Mon, 07 Mar 2005 10:15:57 -0600" Date: Mon, 07 Mar 2005 12:44:35 -0500 Message-ID: <3084.1110217475@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/37 X-Sequence-Number: 5055 Kelly Burkhart writes: > The ::int2 cast is added in convert.c on line 3024 (for 08.00.0005) > preceded by a comment stating it is necessary: > /* needs cast because there is no automatic downcast from > int4 constants */ > CVT_APPEND_STR(qb, "::int2"); > Is this really necessary? On my 7.4.2 database, the following works > just fine: > create table tst ( i16 int2 ); > insert into tst ( i16 ) values ( -32768 ); In that context the down-conversion will work because it's considered an assignment coercion. However there are other cases where an explicit cast is indeed needed, for instance select foo(42::int2) where foo is declared as taking an int2 parameter. The best thing would be to leave the cast in place but add parentheses around the value being casted. regards, tom lane