pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Ross J. Reedstrom <reedstrm@wallace.ece.rice.edu>
Cc: Marc Tardif <admin@wtbwts.com>
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] now() returning int4
Date: Mon, 31 Jan 2000 21:13:37 -0500
Message-ID: <12189.949371217@sss.pgh.pa.us> (raw)
In-Reply-To: <20000131162840.A5157@rice.edu>
References: <Pine.BSF.4.10.10001311649310.63602-100000@server.b0x.com>
	<20000131162840.A5157@rice.edu>

"Ross J. Reedstrom" <reedstrm@wallace.ece.rice.edu> writes:
>> db=> SELECT * FROM test WHERE date < now()::int4;

> SELECT * FROM test WHERE date < int(now());
> Works here.

I believe this is a bug in the typecasting code --- when you try to
cast a value to another type that the system considers bit-compatible
with the original type, the parser knows that no actual type conversion
work is required.  But it then decides it doesn't have to do *anything*,
and effectively drops the cast entirely.  It should be marking the
expression result as being of the destination type so that subsequent
processing works as the user intends.

Related example:

regression=# select now()::int4;
        ?column?
------------------------
 2000-01-31 21:07:36-05
(1 row)

regression=# select int(now());
    int
-----------
 949370865
(1 row)

Both of these should yield int-formatted output, IMHO.

I have this on my to-fix list for 7.0.

			regards, tom lane



view thread (3+ messages)

Message-ID: <12189.949371217@sss.pgh.pa.us>
Permalink:  ../12189.949371217@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/12189.949371217@sss.pgh.pa.us

 · 

reply

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-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, reedstrm@wallace.ece.rice.edu, admin@wtbwts.com
  Subject: Re: [SQL] now() returning int4
  In-Reply-To: <12189.949371217@sss.pgh.pa.us>
  References: <Pine.BSF.4.10.10001311649310.63602-100000@server.b0x.com> <20000131162840.A5157@rice.edu> <12189.949371217@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