Philip Warner <pjw@rhyme.com.au> writes:
> At 11:51 AM 23/04/2003 -0400, Tom Lane wrote:
>> The only way to get the same answer both ways would be to legislate that
>> int-to-bitstring conversion puts the integer's LSB at the left

> That's what I think we need to do. Alternatively, we put the LSB on the 
> right, change the way substring works on varbit, and pad them on the left. 
> I suspect this will also break existing apps.

I doubt that we can change the padding rule without violating spec.

How about leaving the cast alone (okay, we can add the cast-directly-to-
a-different-width cases), so as not to break existing apps, and instead
add a separate function that maps an integer to an LSB-first bitstring?

			regards, tom lane


Wed, 23 Apr 2003 12:02:33 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: bit strings - anyone working on them? 
At 12:02 PM 23/04/2003 -0400, Tom Lane wrote:
>and instead
>add a separate function that maps an integer to an LSB-first bitstring?

This would work, but it's not going to be very friendly without automatic 
cast support. Does the spec mention LSB and/or numeric conversions? Also, I 
just noticed that B'0' is not equal to B'00', which also seems unfortunate.

Perhaps we could also add an LSB-last function, and output some kind of 
warning when using numeric casts to the effect that the application should 
use the LSB-last function because the casts will start using LSB-first in a 
future version.

Alternatively, we could consider creating a new type that works as one 
would expect:

  - Automatic casting (sizes and numeric)
  - Automatic padding
  - numeric & text conversion
  - extract_bits using LSB as position 1.

and one of:
  - LSB on right
  - pad on left
or
  - LSB on left
  - pad on right

Another option: can we use some aspect of the type definition to specify 
the LSB position to store in attyypmod?



----------------------------------------------------------------
Philip Warner                    |     __---_____
Albatross Consulting Pty. Ltd.   |----/       -  \
(A.B.N. 75 008 659 498)          |          /(@)   ______---_
Tel: (+61) 0500 83 82 81         |                 _________  \
Fax: (+61) 03 5330 3172          |                 ___________ |
Http://www.rhyme.com.au          |                /           \|
                                  |    --________--
PGP key available upon request,  |  /
and from pgp5.ai.mit.edu:11371   |/


Thu, 24 Apr 2003 02:38:34 +1000
Philip Warner <pjw@rhyme.com.au>
Re: bit strings - anyone working on them? 
Philip Warner kirjutas K, 23.04.2003 kell 19:38:
> At 12:02 PM 23/04/2003 -0400, Tom Lane wrote:
> >and instead
> >add a separate function that maps an integer to an LSB-first bitstring?
> 
> This would work, but it's not going to be very friendly without automatic 
> cast support. Does the spec mention LSB and/or numeric conversions? Also, I 
> just noticed that B'0' is not equal to B'00', which also seems unfortunate.

The same is true for real strings: '0' != '00' .

-----------------
Hannu


24 Apr 2003 00:04:51 +0300
Hannu Krosing <hannu@tm.ee>
Re: bit strings - anyone working on them?