Re: 8.1 substring bug? - Mailing list pgsql-hackers

From Harald Fuchs
Subject Re: 8.1 substring bug?
Date
Msg-id 87veyz44gs.fsf@srv.protecting.net
Whole thread Raw
In response to 8.1 substring bug?  (Harald Fuchs <hf0923x@protecting.net>)
List pgsql-hackers
In article <20051111141232.GH13177@svana.org>,
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)

> Looking at the explain verbose make it look like it's using the wrong
> version of substring. It's using the oid 2074 one:

> test=# select oid,  oid::regprocedure from pg_proc where proname =
> 'substring';
>   oid  |                 oid                 
> -------+-------------------------------------
>    936 | "substring"(text,integer,integer)
>    937 | "substring"(text,integer)
>   1680 | "substring"(bit,integer,integer)
>   1699 | "substring"(bit,integer)
>   2012 | "substring"(bytea,integer,integer)
>   2013 | "substring"(bytea,integer)
>   2073 | "substring"(text,text)
>   2074 | "substring"(text,text,text)           <----
>  16579 | "substring"(citext,integer,integer)
>  16580 | "substring"(citext,integer)
> (10 rows)

> That substring is for regular expressions. Nasty, not sure how to deal
> with that one...

Ah, so it's using "substring (STRING from PATTERN for ESCAPE)"?
Yes, that explains the NULL.  Looks like we're in the INT/BIGINT
confusion again...

> Have a nice day,

It's a nice day since I have a nice workaround for this misfeature :-)



pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: MERGE vs REPLACE
Next
From: Matt Newell
Date:
Subject: Re: Multi-table-unique-constraint