Re: bit strings - anyone working on them?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Philip Warner <pjw(at)rhyme(dot)com(dot)au>
Cc: "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au>, "PostgreSQL Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: bit strings - anyone working on them?
Date: 2003-04-23 14:36:24
Message-ID: 26406.1051108584@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Philip Warner <pjw(at)rhyme(dot)com(dot)au> writes:
> At 12:14 AM 23/04/2003 -0400, Tom Lane wrote:
>> Is there a way out of this? I'm not sure.

> The problem will be avoiding breaking existing apps that have adapted to
> current functionality. I have no preference to endianness, but taking the
> current LSB-on-left approach, I would like to see:

> Cast(8 as bit(10)) => '0001000000'
> Cast(8 as bit(4)) => '0001'

That part we could do, I think, if you are willing to abandon the
assumption that the result of casting int to bit(n) and then to bit(m)
should agree with the result of casting int directly to bit(m). While
it seems a little weird, I doubt that many existing apps would actually
be affected. Casting to bit(32) (or bit(64) for int8) is really the
only case with useful behavior at the moment, so it's the only one
anyone will be using.

> B'1' # Cast(1 as bit(32)) => '00000000000000000000000000000000'

Eh? What is the # operator supposed to be doing here?

A more general point: while automatic padding of the narrower input
is clearly sensible for varbit, I'm not convinced that it's per-spec
for bit. You're effectively treating bit the same as varbit if you are
willing to change the length at the drop of a hat. Perhaps these
operators should only exist for varbit, or should demand inputs already
the same length for bit.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Philip Warner 2003-04-23 14:50:44 Re: bit strings - anyone working on them?
Previous Message Peter Eisentraut 2003-04-23 14:24:46 EXECUTE INTO