Re: Strict-typing benefits/costs

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ken Johanson <pg-user(at)kensystem(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Strict-typing benefits/costs
Date: 2008-02-16 16:47:20
Message-ID: 20588.1203180440@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ken Johanson <pg-user(at)kensystem(dot)com> writes:
> select 5<'6' -> true
> select 5>'6' -> false
> select 15<'60' -> true
> select 15>'60' -> false

These examples miss the point, because they'd give the same answer
whether you think the values are text or integer. Consider instead
these cases:

regression=# select 7 > '60'; -- int > int
?column?
----------
f
(1 row)

regression=# select '7' > '60'; -- text > text
?column?
----------
t
(1 row)

regression=# select 7 > '08'; -- int > int
?column?
----------
f
(1 row)

regression=# select '7' > '08'; -- text > text
?column?
----------
t
(1 row)

All of a sudden it seems much more important to be clear about
what data type is involved, no?

> Numbers and datetime in sql have exactly prescribed standard char
> representations (even if others dbs don't use them for datetimes).

See the datestyle parameter before you maintain that Postgres
should assume that.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ken Johanson 2008-02-16 17:04:36 Re: Strict-typing benefits/costs
Previous Message jerry.evans@chordia 2008-02-16 16:30:30 Analogue to SQL Server UniqueIdentifier?