Search Postgresql Archives

Re: Strict-typing benefits/costs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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



---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux