Re: help: now() + N is now failing!

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Dmitry Tkach <dmitry(at)openratings(dot)com>
Cc: <pgsql-novice(at)postgresql(dot)org>
Subject: Re: help: now() + N is now failing!
Date: 2003-07-29 23:48:54
Message-ID: 20030729163859.T3591-100000@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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. ;)

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Mendola Gaetano 2003-07-30 00:32:33 Re: help: now() + N is now failing!
Previous Message Godshall Michael 2003-07-29 22:47:36 Re: switch statement in plpgsql