Re: VARCHAR truncation

From: "David Wall" <d(dot)wall(at)computer(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: VARCHAR truncation
Date: 2002-11-19 03:45:39
Message-ID: arcc53$1vdd$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

From the docs, I read:

+++

SQL defines two primary character types: character(n) and character
varying(n), where n is a positive integer. Both of these types can store
strings up to n characters in length. An attempt to store a longer string
into a column of these types will result in an error, unless the excess
characters are all spaces, in which case the string will be truncated to the
maximum length. (This somewhat bizarre exception is required by the SQL
standard.) If the string to be stored is shorter than the declared length,
values of type character will be space-padded; values of type character
varying will simply store the shorter string.

Note: Prior to PostgreSQL 7.2, strings that were too long were silently
truncated, no error was raised.

+++

This is the "problem" that I've run into since we recently moved from 7.1 to
7.2. Is there any way to get the non-standard behavior back?

David

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-11-19 04:05:01 Re: get_bit etc.
Previous Message Brian Minton 2002-11-19 03:36:24 get_bit etc.