Re: help: now() + N is now failing! - Mailing list pgsql-novice

From Stephan Szabo
Subject Re: help: now() + N is now failing!
Date
Msg-id 20030729163859.T3591-100000@megazone.bigpanda.com
Whole thread Raw
In response to Re: help: now() + N is now failing!  (Dmitry Tkach <dmitry@openratings.com>)
List pgsql-novice
On Tue, 29 Jul 2003, Dmitry Tkach wrote:

> Stephan Szabo wrote:
>
> >I don't mind an explicit conversion as much because at least you know
> >that you're getting it.  Implicit conversions mean that a user has no
> >reason to know (apart from name in this case) that the query should fail
> >if you put 'T' in the column whereas a query like textcol::date is a
> >pretty big hint.
> >
> Whatever... I have my reservations regarding how much of a hit this
> really is (I mean a person who tries to compare a text column to a date,
> and expects it to just magically always work, hardly deserves to be
> expected to see anything behind that '::date' thing other then a weird
> syntax construct :-)
>
> But, as I said, I don't really have an opinion on this one - whether
> parsing a text string into a date should be called a 'cast' or not...
>
> My point is that if you do call certain type conversions 'a cast', and
> you do allow implicit conversions in *some* cases (e.g. select * from
> table where textcol < 3),

> then it is actually *more* confusing to the user when you "hand-pick"
> some of the type combinations and disallow those conversions, then it
> would be, if you just had some simple (and commonly accepted) rule -
> like allow any unambigous single-step conversions for example...
> Or, for that matter - just never do any implicit conversions at all -
> this would not be, of course something I'd like to happen :-), but, at
> least, it would not make me wonder 'is this  going to work or not' every
> time I type something into psql...

You have to anyway - see my notes on your queries from below.

> But the way it is now, just seems very confusing, because *sometimes* it
> does work, and sometimes it doesn't, and I really fail to see any
> difference at all -
> why, for example
> select * from mytable where timestampcol < 3
> .. works, but

In 7.3 this does a conversion to text. In 7.2 it does a conversion to
abstime.

> select * from mytable where timestampcol + 1 < 4
> does *not*?

On my 7.2 machine this does end up using text comparison.  That's probably
not what you meant to compare. ;)



pgsql-novice by date:

Previous
From: Godshall Michael
Date:
Subject: Re: switch statement in plpgsql
Next
From: "Mendola Gaetano"
Date:
Subject: Re: help: now() + N is now failing!