Subject | Re: [SPAM 4] Re: [firebird-support] Unique index that allows difference in trailing whitespace? |
---|---|
Author | Kjell Rilbe |
Post date | 2013-10-16T04:43:30Z |
Ann Harrison skriver:
different sizes even before varchar was introduced. Either way, I think
it was a mistake to apply this logic to varchars, because when varchar
was introduced, you should use char only when all values are equal in
length, e.g. fixed width code fields. For all other purposes a varchar
should be used. So, once we have varchar, the trailing whitespace really
has no use, but it does cause a lot of confusion and "special handling"
when you need to avoid it.
I can think of a couple of cases where the trailing whitespace logic
might be relevant, but I would argue that all of them are examples of
incorrect type usage:
1. Comparing char to a literal of a different length. If you need to do
that, you really should have used varchar and not char.
2. Comparing a char value to a varchar value. If you need to do that,
again you should really have used varchar in both places, or explicitly
cast the char to a varchar.
To sum it all up, I feel those who agreed on the current logic in the
SQL standard made a huge (well...) mistake, trying to solve a legacy
problem but in the process introduced a lot of permanent future problems.
Regards,
Kjell
--
------------------------------
Kjell Rilbe
DataDIA AB
E-post: kjell.rilbe@...
Telefon: 08-761 06 55
Mobil: 0733-44 24 64
> On Sun, Oct 13, 2013 at 2:56 PM, Kjell Rilbe <kjell.rilbe@...Might be, but might also be to enable comparison between char values of
> <mailto:kjell.rilbe@...>> wrote:
>
> I wish the trailing whitespace semantics would never have been made
> applicable to varchar data. I really don't see the point. In fact,
> since
> the varchar type was introduced, I don't see why it would be useful at
> all - assuming char is used only for fixed-width data (why else
> use char
> and not varchar?).
>
>
> The problem being addressed, I think was comparing varchars to chars
> or literals.
different sizes even before varchar was introduced. Either way, I think
it was a mistake to apply this logic to varchars, because when varchar
was introduced, you should use char only when all values are equal in
length, e.g. fixed width code fields. For all other purposes a varchar
should be used. So, once we have varchar, the trailing whitespace really
has no use, but it does cause a lot of confusion and "special handling"
when you need to avoid it.
I can think of a couple of cases where the trailing whitespace logic
might be relevant, but I would argue that all of them are examples of
incorrect type usage:
1. Comparing char to a literal of a different length. If you need to do
that, you really should have used varchar and not char.
2. Comparing a char value to a varchar value. If you need to do that,
again you should really have used varchar in both places, or explicitly
cast the char to a varchar.
To sum it all up, I feel those who agreed on the current logic in the
SQL standard made a huge (well...) mistake, trying to solve a legacy
problem but in the process introduced a lot of permanent future problems.
> The reason octets work is that a space is just another binaryI understand.
> value.
Regards,
Kjell
--
------------------------------
Kjell Rilbe
DataDIA AB
E-post: kjell.rilbe@...
Telefon: 08-761 06 55
Mobil: 0733-44 24 64