Re: [HACKERS] 8.1 substring bug?

2005-11-13 Thread Tom Lane
I wrote: Martijn van Oosterhout kleptog@svana.org 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

[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'

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

Re: [HACKERS] 8.1 substring bug?

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

Re: [HACKERS] 8.1 substring bug?

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

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 the

Re: [HACKERS] 8.1 substring bug?

2005-11-11 Thread Tom Lane
Martijn van Oosterhout kleptog@svana.org 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 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 numeric

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 in there. This

Re: [HACKERS] 8.1 substring bug?

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