Received: from sss2.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2]) by hub.org (8.9.3/8.9.3) with ESMTP id VAA35428 for ; Mon, 31 Jan 2000 21:13:42 -0500 (EST) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss2.sss.pgh.pa.us (8.9.3/8.9.3) with ESMTP id VAA12192; Mon, 31 Jan 2000 21:13:38 -0500 (EST) To: "Ross J. Reedstrom" cc: Marc Tardif , pgsql-sql@postgreSQL.org Subject: Re: [SQL] now() returning int4 In-reply-to: <20000131162840.A5157@rice.edu> References: <20000131162840.A5157@rice.edu> Comments: In-reply-to "Ross J. Reedstrom" message dated "Mon, 31 Jan 2000 16:28:40 -0600" Date: Mon, 31 Jan 2000 21:13:37 -0500 Message-ID: <12189.949371217@sss.pgh.pa.us> From: Tom Lane "Ross J. Reedstrom" 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