Re: bit type external representation

From: Joe Conway <mail(at)joeconway(dot)com>
To: Thomas Lockhart <lockhart(at)fourpalms(dot)org>
Cc: PostgreSQL Hackers List <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: bit type external representation
Date: 2002-07-16 04:19:59
Message-ID: 3D339EEF.1030104@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 the number
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 equivalent to
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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hannu Krosing 2002-07-16 04:36:53 Re: Unused system table columns
Previous Message Tom Lane 2002-07-16 04:09:11 Re: DROP COLUMN