Re: I: TODO: Allow substring/replace() to get/set bit values

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Leonardo F <m_lists(at)yahoo(dot)it>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: I: TODO: Allow substring/replace() to get/set bit values
Date: 2010-01-05 15:14:44
Message-ID: 603c8f071001050714w13390b8ao1d101098d4b52a67@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jan 5, 2010 at 3:58 AM, Leonardo F <m_lists(at)yahoo(dot)it> wrote:
>> You might want to search the archives (or the wiki history, or the CVS
>> history if it's been there since before we moved the TODO list to the
>> wiki) for discussion of why that item was added to the TODO in the
>> first place.
>
> I read the thread:
>
> http://archives.postgresql.org/pgsql-hackers/2004-02/msg00478.php
>
> 1) it is true that "getbit sounds a lot like what substring() does", but the same could be said for binary string substring/get_byte; so IMHO get/set_bit should be present for bit string
> 2) it is not very clear to me how "setbit could actually be handled by replace()" (maybe "overlay" style?)
> 3) since I'm looking at byte string get/set_bit to understand how that works, I'm having a hard time understanding why the bit indexes in get/set_bit are low-first based:
>
> select get_bit(E'\\376\\376'::bytea, s) as b,s from generate_series(0,15,1) as s
> b s
> 0 0
> 1 1
> 1 2
> 1 3
> 1 4
> 1 5
> 1 6
> 1 7
> 0 8
> 1 9
> 1 10
> 1 11
> 1 12
> 1 13
> 1 14
> 1 15
>
>
> I understand this is the internal representation, but still: if someone asked me what the 8th bit in 1111111011111110 is, I would have said 1, not 0 (assuming the first bit has index '0'). Actually, David Helgason's patch (http://archives.postgresql.org/pgsql-hackers/2004-01/msg00498.php) goes in this direction: note the
>
> bitNo = 7 - (n % 8);
>
> part. Using that algorithm would mean get/set_bit in bit string would behave differently from what they do in binary string (IMHO it's the binary string implementation that is "wrong").

Well, I'm not really clear on what you're trying to accomplish here.
As you say, there's really no point in changing the internal
representation, and if you don't find replace() useful either, then
why are you even working on this at all? Since the latest discussion
of this is more than five years old, it's unclear that anyone even
cares any more. It seems to me that making replace overlay a
substring of bits could be a reasonable thing to do, but if nobody
actually wants it, then the simplest thing to do is remove this from
the TODO and call it good.

...Robert

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2010-01-05 15:15:08 Re: libpq naming on Win64
Previous Message Robert Haas 2010-01-05 15:08:20 Re: Thoughts on statistics for continuously advancing columns