From: Tom Lane <tgl@sss.pgh.pa.us>
To: Kelly Burkhart <kelly@tradebotsystems.com>
Cc: pgsql-odbc@postgresql.org
Subject: Re: Insert SHRT_MIN fails for int2 column
Date: Mon, 07 Mar 2005 12:44:35 -0500
Message-ID: <3084.1110217475@sss.pgh.pa.us> (raw)
In-Reply-To: <1110212157.3206.10.camel@krb06>
References: <1110212157.3206.10.camel@krb06>
Kelly Burkhart <kelly@tradebotsystems.com> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-odbc@postgresql.org
Cc: tgl@sss.pgh.pa.us, kelly@tradebotsystems.com
Subject: Re: Insert SHRT_MIN fails for int2 column
In-Reply-To: <3084.1110217475@sss.pgh.pa.us>
References: <1110212157.3206.10.camel@krb06> <3084.1110217475@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox