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 C6FCE56139 for ; Mon, 7 Mar 2005 18:42: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 67150-04 for ; Mon, 7 Mar 2005 18:42:37 +0000 (GMT) Received: from tbmail.tradebot.com (mail.tradebotsystems.com [209.83.219.42]) by svr1.postgresql.org (Postfix) with ESMTP id 107B456002 for ; Mon, 7 Mar 2005 18:42:34 +0000 (GMT) Received: from 192.168.200.29 ([192.168.200.29]) by tbmail.tradebot.com ([192.168.1.50]) with Microsoft Exchange Server HTTP-DAV ; Mon, 7 Mar 2005 18:42:34 +0000 Received: from krb06 by tbmail; 07 Mar 2005 12:42:34 -0600 Subject: Re: Insert SHRT_MIN fails for int2 column From: Kelly Burkhart To: pgsql-odbc@postgresql.org In-Reply-To: <3084.1110217475@sss.pgh.pa.us> References: <1110212157.3206.10.camel@krb06> <3084.1110217475@sss.pgh.pa.us> Content-Type: multipart/mixed; boundary="=-lFU9A6njJLhHBgPGgN4k" Organization: Tradebot Systems, Inc. Message-Id: <1110220954.3206.20.camel@krb06> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Mon, 07 Mar 2005 12:42:34 -0600 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200503/39 X-Sequence-Number: 5057 --=-lFU9A6njJLhHBgPGgN4k Content-Type: text/plain Content-Transfer-Encoding: 7bit On Mon, 2005-03-07 at 11:44, Tom Lane wrote: > 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. Attached is a patch to resolve this. BTW, is it appropriate for me to send pgsqlodbc patches to this list? Or should I send all patches to psql-patches? -K --=-lFU9A6njJLhHBgPGgN4k Content-Disposition: attachment; filename=psqlodbc_castshort.patch Content-Type: text/x-patch; name=psqlodbc_castshort.patch; charset=ISO-8859-1 Content-Transfer-Encoding: base64 LS0tIHBzcWxvZGJjLTA4LjAwLjAxMDEvY29udmVydC5jCTIwMDUtMDEtMTcgMDQ6MTI6NTIuMDAw MDAwMDAwIC0wNjAwDQorKysgcHNxbG9kYmMtMDguMDAuMDEwMS5wYXRjaC9jb252ZXJ0LmMJMjAw NS0wMy0wNyAxMjoxNDoxOC42NTMwODAyODUgLTA2MDANCkBAIC0yOTg5LDYgKzI5ODksMTEgQEAN CiAJCQlpZiAocGFyYW1fc3FsdHlwZSA9PSBTUUxfQklUKQ0KIAkJCQlDVlRfQVBQRU5EX0NIQVIo cWIsICdcJycpOwkJLyogT3BlbiBRdW90ZSAqLw0KIA0KKwkJCWlmIChwYXJhbV9zcWx0eXBlID09 IFNRTF9TTUFMTElOVCkNCisJCQl7DQorCQkJCUNWVF9BUFBFTkRfU1RSKHFiLCAiKCIpOw0KKwkJ CX0NCisNCiAJCQlpZiAoYnVmKQ0KIAkJCXsNCiAJCQkJc3dpdGNoICh1c2VkKQ0KQEAgLTMwMDgs NyArMzAxMyw3IEBADQogCQkJaWYgKHBhcmFtX3NxbHR5cGUgPT0gU1FMX1NNQUxMSU5UKQ0KIAkJ CXsNCiAJCQkJLyogbmVlZHMgY2FzdCBiZWNhdXNlIHRoZXJlIGlzIG5vIGF1dG9tYXRpYyBkb3du Y2FzdCBmcm9tIGludDQgY29uc3RhbnRzICovDQotCQkJCUNWVF9BUFBFTkRfU1RSKHFiLCAiOjpp bnQyIik7DQorCQkJCUNWVF9BUFBFTkRfU1RSKHFiLCAiKTo6aW50MiIpOw0KIAkJCX0NCiANCiAJ CQlpZiAocGFyYW1fc3FsdHlwZSA9PSBTUUxfQklUKQ0K --=-lFU9A6njJLhHBgPGgN4k--