From: | Gavin Sherry <swm(at)linuxworld(dot)com(dot)au> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Make length(char(n)) return 'true' length |
Date: | 2004-01-27 07:21:34 |
Message-ID: | Pine.LNX.4.58.0401271806250.22203@linuxworld.com.au |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
The attached patch changes the existing behaviour of length(char(n)).
Currently, this is what happens:
template1=# select length('blah'::char(10));
length
--------
10
(1 row)
With this patch:
template1=# select length('blah'::char(10));
length
--------
4
(1 row)
This behaviour was proposed by Tom back in November last year. (I have
tried to handle multibyte correctly but probably haven't -- hence my email
hackers instead of patches).
The spec doesn't give us any insight (as far as I can tell) as to how we
should do it length(char(n)), but the above seems consistent with other
parts of the code (eg, comparison functions, concatenation).
SQL200X has these choice paragraphs for those who are interested:
<length expression> returns the length of a given character string,
as an exact numeric value, in characters or octets according to the
choice of function.
And:
the result is the number of explicit or implicit
<char length units> in <char length expression>, counted in
accordance with the definition of those units in the relevant
normatively referenced document.
I have no idea what the 'normatively referenced document' is, but grep-ing
through all of SQL200X, 99 and 92 didn't reveal anything too interesting.
Gavin
Attachment | Content-Type | Size |
---|---|---|
bpcharlen.patch | text/plain | 1.1 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | ohp | 2004-01-27 12:33:44 | Most urgent |
Previous Message | Shridhar Daithankar | 2004-01-27 07:10:51 | Re: Extending SET SESSION AUTHORIZATION |