Re: varchar truncation from 7.1 to 7.2

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: ljb <lbayuk(at)mindspring(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: varchar truncation from 7.1 to 7.2
Date: 2002-08-03 04:01:30
Message-ID: 524.1028347290@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

ljb <lbayuk(at)mindspring(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2002-08-03 04:26:19 Re: very slow updates
Previous Message Thomas Lockhart 2002-08-03 02:42:25 Re: varchar truncation from 7.1 to 7.2