Re: 8.1 substring bug?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: Harald Fuchs <hf0923x(at)protecting(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: 8.1 substring bug?
Date: 2005-11-11 15:06:51
Message-ID: 18635.1131721611@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Martijn van Oosterhout <kleptog(at)svana(dot)org> writes:
> It's even sillier than that:

> test=# SELECT substring ('1234567890' FOR 4::bigint);
> substring
> -----------
>
> (1 row)

> test=# SELECT substring ('1234567890' FOR 4::int);
> substring
> -----------
> 1234
> (1 row)

This has been complained of before. The problem is that there is no
implicit cast from bigint to int, but there is one from bigint to text,
so the only acceptable mapping the parser can find is to convert bigint
to text and apply the pattern-match version of substring(). (There are
some other things happening here because of the weird SQL99 syntax, but
that's the bottom line.)

I have opined before that implicit cross-category casts to text are
evil. Unfortunately, we'll probably break a lot of people's
applications if we remove them...

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2005-11-11 15:36:21 Re: generic builtin functions
Previous Message Matteo Beccati 2005-11-11 15:00:54 Re: Does EXPLAIN ANALYZE show a wrong plan for MIN/MAX?