Re: [HACKERS] 8.1 substring bug?

2005-11-13 Thread Tom Lane
I wrote: > Martijn van Oosterhout writes: >> In this particular case the syntax makes it unclear that the substring >> is the problem. Perhaps here the solution would be to put a cast in the >> grammer, like so: > ... > But I think we could do this in substr_list in the case where we have > just "

Re: [HACKERS] 8.1 substring bug?

2005-11-11 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, Martijn van Oosterhout 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) > Look

Re: [HACKERS] 8.1 substring bug?

2005-11-11 Thread Tom Lane
Stephan Szabo <[EMAIL PROTECTED]> writes: > On Fri, 11 Nov 2005, Tom Lane wrote: >> I was toying with the idea of making it translate instead to >> >> pg_catalog.substring(foo, 1, (bar)::int4) >> >> since AFAICS there isn't any other reasonable mapping once you have >> committed to having the "1"

Re: [HACKERS] 8.1 substring bug?

2005-11-11 Thread Stephan Szabo
On Fri, 11 Nov 2005, Tom Lane wrote: > Stephan Szabo <[EMAIL PROTECTED]> writes: > > It looks to me like we should be supporting any exact numeric with scale 0 > > there (at least AFAICS from SQL92 and SQL03), so I don't think the current > > behavior is compliant. It doesn't look like adding a nu

Re: [HACKERS] 8.1 substring bug?

2005-11-11 Thread Tom Lane
Martijn van Oosterhout writes: > In this particular case the syntax makes it unclear that the substring > is the problem. Perhaps here the solution would be to put a cast in the > grammer, like so: > substr_for: FOR a_expr { $$ =3D > makeTypeCast($2,"int4"); } >

Re: [HACKERS] 8.1 substring bug?

2005-11-11 Thread Tom Lane
Stephan Szabo <[EMAIL PROTECTED]> writes: > It looks to me like we should be supporting any exact numeric with scale 0 > there (at least AFAICS from SQL92 and SQL03), so I don't think the current > behavior is compliant. It doesn't look like adding a numeric overload > of the function works, and th

Re: [HACKERS] 8.1 substring bug?

2005-11-11 Thread Martijn van Oosterhout
On Fri, Nov 11, 2005 at 07:47:12AM -0800, Stephan Szabo wrote: > > On Fri, 11 Nov 2005, Tom Lane wrote: > > 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

Re: [HACKERS] 8.1 substring bug?

2005-11-11 Thread Stephan Szabo
On Fri, 11 Nov 2005, Tom Lane wrote: > Martijn van Oosterhout 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 > > --

Re: [HACKERS] 8.1 substring bug?

2005-11-11 Thread Tom Lane
Martijn van Oosterhout 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.

Re: [HACKERS] 8.1 substring bug?

2005-11-11 Thread Martijn van Oosterhout
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) Looking at the explain verbose make it look like it's using the wrong version of substring

[HACKERS] 8.1 substring bug?

2005-11-11 Thread Harald Fuchs
Consider the following: CREATE TEMP TABLE tbl ( id SERIAL NOT NULL, PRIMARY KEY (id) ); COPY tbl (id) FROM stdin; 1 2 3 4 \. SELECT substring ('1234567890' FOR (SELECT count (*) FROM tbl)::int); This returns '1234', as expected. But SELECT substring ('1234567890' F