Re: AW: Truncation of char, varchar types - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: AW: Truncation of char, varchar types
Date
Msg-id Pine.LNX.4.30.0104101802001.1403-100000@peter.localdomain
Whole thread Raw
In response to AW: Truncation of char, varchar types  (Zeugswetter Andreas SB <ZeugswetterA@wien.spardat.at>)
List pgsql-hackers
Zeugswetter Andreas SB writes:

> > Excessively long values are currently silently truncated when they are
> > inserted into char or varchar fields.  This makes the entire notion of
> > specifying a length limit for these types kind of useless, IMO.  Needless
> > to say, it's also not in compliance with SQL.
>
> To quote Tom "paragraph and verse please" :-)

SQL 1992, 9.2 GR 3 e)

"""
If the data type of T is variable-length character string and
the length in characters M of V is greater than the maximum
length in characters L of T, then,

Case:
i) If the rightmost M-L characters of V are all <space>s, then   the value of T is set to the first L characters of V
and  the length in characters of T is set to L.
 

ii) If one or more of the rightmost M-L characters of V are   not <space>s, then an exception condition is raised: data
                       ^^^^^^^^^   exception-string data, right truncation.
 
"""

Similarly in SQL 1999 and for other data types.

> > How do people feel about changing this to raise an error in this
> > situation?
>
> Can't do.

Why not?

-- 
Peter Eisentraut      peter_e@gmx.net       http://yi.org/peter-e/



pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Re: Re: "--tuning" compile and runtime option (?)
Next
From: Stephan Szabo
Date:
Subject: Re: Indexes not used in 7.1RC4: Bug?