Re: varchar truncation from 7.1 to 7.2 - Mailing list pgsql-general

From Tom Lane
Subject Re: varchar truncation from 7.1 to 7.2
Date
Msg-id 524.1028347290@sss.pgh.pa.us
Whole thread Raw
In response to Re: varchar truncation from 7.1 to 7.2  (ljb <lbayuk@mindspring.com>)
List pgsql-general
ljb <lbayuk@mindspring.com> writes:
>> The SQL standard required the change.

> Can you be more specific?

SQL92 section 9.2 "Store assignment" says (concerning assigning value V
to object column T):

            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.

Similar statements are made in other contexts such as casting a value to
varchar.

Elsewhere "exception condition" is defined:

         3.3.4  Use of terms

         3.3.4.1  Exceptions

         The phrase "an exception condition is raised:", followed by the
         name of a condition, is used in General Rules and elsewhere to
         indicate that the execution of a statement is unsuccessful, ap-
         plication of General Rules, other than those of Subclause 12.3,
         "<procedure>", and Subclause 20.1, "<direct SQL statement>", may
         be terminated, diagnostic information is to be made available,
         and execution of the statement is to have no effect on SQL-data or
         schemas.

Looks pretty black-and-white to me.  I don't much care for it either :-(
but the spec is not ambiguous.

            regards, tom lane

pgsql-general by date:

Previous
From: Thomas Lockhart
Date:
Subject: Re: varchar truncation from 7.1 to 7.2
Next
From: Martijn van Oosterhout
Date:
Subject: Re: very slow updates