Ann Harrison skriver:
> On Sun, Oct 13, 2013 at 2:56 PM, Kjell Rilbe <[email protected] 
> <mailto:[email protected]>> 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.

Might be, but might also be to enable comparison between char values of 
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 binary
> value.

I understand.

Regards,
Kjell

-- 
------------------------------
Kjell Rilbe
DataDIA AB
E-post: [email protected]
Telefon: 08-761 06 55
Mobil: 0733-44 24 64



------------------------------------

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Visit http://www.firebirdsql.org and click the Resources item
on the main (top) menu.  Try Knowledgebase and FAQ links !

Also search the knowledgebases at http://www.ibphoenix.com 

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/firebird-support/join
    (Yahoo! ID required)

<*> To change settings via email:
    [email protected] 
    [email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://info.yahoo.com/legal/us/yahoo/utos/terms/

Reply via email to