Re: varchar truncation from 7.1 to 7.2

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: ljb <lbayuk@mindspring.com>
Cc: pgsql-general@postgresql.org
Date: 2002-08-03T04:01:30Z
Lists: 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