Re: [HACKERS] Re: [GENERAL] Update of bitmask type
| От | Adriaan Joubert |
|---|---|
| Тема | Re: [HACKERS] Re: [GENERAL] Update of bitmask type |
| Дата | |
| Msg-id | 37EA5361.59EC106D@albourne.com обсуждение исходный текст |
| Ответ на | Re: [HACKERS] Re: [GENERAL] Update of bitmask type (The Hermit Hacker <scrappy@hub.org>) |
| Список | pgsql-hackers |
Thomas asked how I was going to implement bitstring comparisons.
>
> How do you handle the length and ordering issues? Is x'01' greater
> than x'1' since it is longer? And if you have a 16-bit bit column, how
> does it look internally if you assign x'01' rather than x'0001'?
I had a look in my freshly down-loaded draft standard. On page 336 it
says:
7) The comparison of two bit string values, X and Y, is
determined by comparison of their bits with the same ordinal position. If Xi and Yi are the values
ofthe i-th bits of X and Y, respectively, and if LX is the length in bits of X and LY is the length
inbits of Y, then:
a) X is equal to Y if and only if X = LY and Xi = Yi for all
i.
? I presume this should be 'LX=LY' ?? Anyway, this means that b'01' <>
b'0010'.
b) X is less than Y if and only if:
i) LX < LY and Xi = Yi for all i less than or equal to LX;
or
ii) Xi = Yi for all i < n and Xn = 0 and Yn = 1 for some n
less than or equal to the minimum of LX and LY.
b) seems to imply, rather bizarrely in my opinion, that
B'001100' < B'10'
as the second bit in B'10' is 1 and in B'001100' it is 0.
Surely I must be reading this wrong?
On the other hand, this would be a type of lexicographical ordering,
so perhaps it is not so dumb. Comments?
Adriaan
В списке pgsql-hackers по дате отправления: