From: Mark Kirkwood on
On 04/05/10 18:47, Srinivas Naik wrote:
> Hi,
> Can any one tell me whats the effect of the below Query
> SELECT substring(B'1111000000000001' from 5 for -2);
> SELECT substring(B'1111000000000001' from 4 for -3);
> its observed that there's an Error "invalid memory alloc request size
> 4244635647"
> What will actually happen to the Postgresql database.
> I am using Postgresql 8.4.3 on Ubuntu 8.04


I can reproduce this with 8.4.*2* on Ubuntu 10.04 32-bit (postgres built
from src) but *not* with 8.4.*3*. Can you double check it is 8.4.3 you
are using? and if so tell us whether you are using 32 or 64 bit Ubuntu!

Cheers

Mark


From: Srinivas Naik on
Hi Mark,

Please find the below details:

postgresql-8.3

and UBUNTU-8.10 with linux-image-2.6.27.18-standard_810_i386.deb

and its an 32bit Ubuntu.



On Tue, May 4, 2010 at 9:02 AM, Mark Kirkwood <mark.kirkwood(a)catalyst.net.nz
> wrote:

> On 04/05/10 18:47, Srinivas Naik wrote:
>
> Hi,
>
> Can any one tell me whats the effect of the below Query
>
> SELECT substring(B'1111000000000001' from 5 for -2);
> SELECT substring(B'1111000000000001' from 4 for -3);
>
> its observed that there's an Error "invalid memory alloc request size
> 4244635647"
>
> What will actually happen to the Postgresql database.
>
> I am using Postgresql 8.4.3 on Ubuntu 8.04
>
>
>
>
> I can reproduce this with 8.4.*2* on Ubuntu 10.04 32-bit (postgres built
> from src) but *not* with 8.4.*3*. Can you double check it is 8.4.3 you are
> using? and if so tell us whether you are using 32 or 64 bit Ubuntu!
>
> Cheers
>
> Mark
>
>
>
From: Robert Haas on
On Tue, May 4, 2010 at 7:46 AM, Srinivas Naik <naik.srinu(a)gmail.com> wrote:
> Hi Mark,
>
>     Please find the below details:
>
> postgresql-8.3
>
> and UBUNTU-8.10 with linux-image-2.6.27.18-standard_810_i386.deb
>
> and its an 32bit Ubuntu.

Err, before you said 8.4.3. Now you're saying 8.3. Those are totally
different. Can we get the exact identifier of the package you have
installed, plus the output from

SELECT version();

Thanks,

....Robert

--
Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

From: "Erik Rijkers" on
On Tue, May 4, 2010 15:40, Robert Haas wrote:
> On Tue, May 4, 2010 at 7:46 AM, Srinivas Naik <naik.srinu(a)gmail.com> wrote:
>> Hi Mark,
>>
>> ��� Please find the below details:
>>
>> postgresql-8.3
>>
>> and UBUNTU-8.10 with linux-image-2.6.27.18-standard_810_i386.deb
>>
>> and its an 32bit Ubuntu.
>
> Err, before you said 8.4.3. Now you're saying 8.3. Those are totally
> different. Can we get the exact identifier of the package you have
> installed, plus the output from
>
> SELECT version();
>
fwiw, results for all current postgres versions:

-- to be executed:
SELECT substring(B'1111000000000001' from 5 for -2); SELECT substring(B'1111000000000001' from 4
for -3);

-- postgres 9.0beta1
ERROR: negative substring length not allowed
ERROR: negative substring length not allowed
-- postgres 8.4.3
000000000001
1000000000001
-- postgres 8.3.10
000000000001
1000000000001
-- postgres 8.2.16
000000000001
1000000000001
-- postgres 8.1.20
000000000001
1000000000001
-- postgres 8.0.24
000000000001
1000000000001
-- postgres 7.4.28
000000000001
1000000000001



--
Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

From: Robert Haas on
On Tue, May 4, 2010 at 10:08 AM, Erik Rijkers <er(a)xs4all.nl> wrote:
> fwiw, results for all current postgres versions:
> [ only 9.0beta1 is different ]

It looks like the relevant commits are:

commit 822f2ac5a2ec7c6f10634f62a0b2dc6cc9929759
Author: Tom Lane <tgl(a)sss.pgh.pa.us>
Date: Mon Jan 25 20:55:32 2010 +0000

Add get_bit/set_bit functions for bit strings, paralleling those for bytea,
and implement OVERLAY() for bit strings and bytea.

In passing also convert text OVERLAY() to a true built-in, instead of
relying on a SQL function.

Leonardo F, reviewed by Kevin Grittner

commit 75dea10196c31d98d98c0bafeeb576ae99c09b12
Author: Tom Lane <tgl(a)sss.pgh.pa.us>
Date: Thu Jan 7 19:53:11 2010 +0000

Make bit/varbit substring() treat any negative length as meaning "all the re
of the string". The previous coding treated only -1 that way, and would
produce an invalid result value for other negative values.

We ought to fix it so that 2-parameter bit substring() is a different C
function and the 3-parameter form throws error for negative length, but
that takes a pg_proc change which is impractical in the back branches;
and in any case somebody might be relying on -1 working this way.
So just do this as a back-patchable fix.

I think the OP is probably running a version that doesn't include the
Jan 7 commit, which was effectively undone by the Jan 25 commit for
CVS HEAD. It looks like this was intentional based on spec behavior
of overlay(), but should we consider maintaining the historical
behavior instead?

....Robert

--
Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers