"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