Re: Strict-typing benefits/costs - Mailing list pgsql-general

From Michael Glaesemann
Subject Re: Strict-typing benefits/costs
Date
Msg-id 3B329809-551E-47DA-8FE9-BC7CFC88A2EC@seespotcode.net
Whole thread Raw
In response to Re: Strict-typing benefits/costs  (Ken Johanson <pg-user@kensystem.com>)
Responses Re: Strict-typing benefits/costs
Re: Strict-typing benefits/costs
List pgsql-general
On Feb 15, 2008, at 18:11 , Ken Johanson wrote:

> Tom, is it accurate to assume that newer PG versions will further
> tighten type-strictness (say, '2008-01-01' presently being
> comparable to a datetime)? Also, do you know of any other vendors
> that are heading in this direction (removing by default the
> autocasts)?

'2008-01-01' does not indicate some kind of string: it's just an
untyped literal. Postgres will determine its type in context. For
example:

test=# select 'today is ' || '2008-02-16';
       ?column?
---------------------
  today is 2008-02-16
(1 row)

|| is a string concatenation operator, so '2008-02-16' is treated as
a string: it's not cast from date to text: from Postgres' eyes, it
never was a date.

test=# select '2008-02-15' > CURRENT_DATE;
  ?column?
----------
  f
(1 row)

Here, we're comparing against a date type, so Postgres treats
'2008-02-15' as a date.

Michael Glaesemann
grzm seespotcode net



pgsql-general by date:

Previous
From: "Phoenix Kiula"
Date:
Subject: Timestamp indexes (why ">" or "between" does not use index?)
Next
From: "Phoenix Kiula"
Date:
Subject: Re: Timestamp indexes (why ">" or "between" does not use index?)