Re: Re: Allowing postgresql to accept 0xff syntax for data types that it makes sense for?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Thomas Kellerer <spam_eater(at)gmx(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Re: Allowing postgresql to accept 0xff syntax for data types that it makes sense for?
Date: 2015-05-23 15:20:50
Message-ID: 5920.1432394450@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thomas Kellerer <spam_eater(at)gmx(dot)net> writes:
> The SQL standard already specifies the format for "binary strings":

> <binary string literal> ::=
> X <quote> [ <space>... ] [ { <hexit> [ <space>... ] <hexit> [ <space>... ] }... ] <quote>
> [ { <separator> <quote> [ <space>... ] [ { <hexit> [ <space>... ]
> <hexit> [ <space>... ] }... ] <quote> }... ]

Yeah, and we do honor that:

regression=# select x'1234abcdf';
?column?
--------------------------------------
000100100011010010101011110011011111
(1 row)

... although I notice we don't allow spaces in the input, which seems
like something to fix. (On further investigation, it looks like the
optional spaces are new since SQL99, which probably explains why we
have not got 'em.)

> The data type for such a literal is somewhat "undefined":

> It is implementation-defined whether the declared type of a <binary string literal>
> is a fixed-length binary string type, a variable-length binary string type,
> or a binary large object string type

Hm, we think it's bit(N):

regression=# select pg_typeof(x'1234abcdf');
pg_typeof
-----------
bit
(1 row)

which is what the SQL standard *used* to say, before they unceremoniously
threw the bit types under the bus and replaced them with "binary strings".

I wonder how painful it would be to update that stuff to be compatible
with more recent versions of the standard. Or whether anyone really
cares --- people doing this in PG seem to be happy enough with bytea.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message twoflower 2015-05-23 15:23:51 Re: Server tries to read a different config file than it is supposed to
Previous Message Tom Lane 2015-05-23 15:06:45 Re: Server tries to read a different config file than it is supposed to