Skip site navigation (1) Skip section navigation (2)

Re: Range type adaptation implemented

From: Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)net>
To: psycopg(at)postgresql(dot)org
Subject: Re: Range type adaptation implemented
Date: 2012-09-24 09:45:42
Message-ID: 20120924094541.GA3823@hermes.hilbert.loc (view raw or flat)
Thread:
Lists: psycopg
On Mon, Sep 24, 2012 at 09:56:14AM +0100, Daniele Varrazzo wrote:

> The funniest surprise I've had during the development
> was an error creating the object TextRange('#', '$') in the database.
> It should be possible as
> 
>     >>> ord('#'), ord('$')
>     (35, 36)
> 
> but PG insisted that "range lower bound must be less than or equal to
> range upper bound". Well, turns out that:
> 
>     postgres=# select ascii('#') < ascii('$'), '#' < '$';
>      ?column? | ?column?
>     ----------+----------
>      t        | f
>     (1 row)

This does not seem intuitive but is probably quite logical:

While

	ascii('#') < ascii('$')

eventually compares numerical values (35 and 36) the comparison

	'#' < '$'

operates on characters the sorting order (<) of which
depends on the lcoale in use.

Karsten
-- 
GPG key ID E4071346 @ gpg-keyserver.de
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346


In response to

Responses

psycopg by date

Next:From: Karsten HilbertDate: 2012-09-24 09:50:45
Subject: Re: Range type adaptation implemented
Previous:From: Daniele VarrazzoDate: 2012-09-24 08:56:14
Subject: Range type adaptation implemented

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group