Re: bit type external representation

Поиск
Список
Период
Сортировка
От Joe Conway
Тема Re: bit type external representation
Дата
Msg-id 3D339EEF.1030104@joeconway.com
обсуждение исходный текст
Ответ на bit type external representation  (Thomas Lockhart <lockhart@fourpalms.org>)
Список pgsql-hackers
Thomas Lockhart wrote:
> 1) the SQL standard says what hex values should be translated to in
> binary, which implies that all values may be *output* in binary format.
> Should we do this, or should we preserve the info on what units were
> used for input in the internal storage? Anyone interpret the standard
> differently from this??

SQL99, Section "5.3 <literal>":
11) The declared type of a <bit string literal> is fixed-length    bit string. The length of a <bit string literal> is
thenumber    of bits that it contains.
 
12) The declared type of a <hex string literal> is fixed-length bit    string. Each <hexit> appearing in the literal is
equivalentto    a quartet of bits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E,    and F are interpreted as 0000, 0001,
0010,0011, 0100, 0101,    0110, 0111, 1000, 1001, 1010, 1011, 1100, 1101, 1110, and 1111,    respectively. The <hexit>s
a,b, c, d, e, and f have respectively    the same values as the <hexit>s A, B, C, D, E, and F.
 

So the standard says both represent a fixed-length bit string data type. 
ISTM that we should not try to preserve any information on the units 
used for input, and that both should be output in the same way.

> 
> 2) we would need to be able to determine the format style when a string
> is output to be able to reconstruct the SQL shorthand representation (if
> preserving binary or hex is to be done). So a column or value should
> have a corresponding is_hex() function call. Any other suggestions??
> 

Based on above comment, I'd say no. We might want to be able to specify 
that the output format should be hex using a formatting function though. 
But I guess hex output format would have to be reserved for bit strings 
that are integer multiples of 4 bits in length.

Joe



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: DROP COLUMN
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: DROP COLUMN