Re: VARCHAR truncation - Mailing list pgsql-general

From David Wall
Subject Re: VARCHAR truncation
Date
Msg-id arcc53$1vdd$1@news.hub.org
Whole thread Raw
In response to VARCHAR truncation  ("David Wall" <d.wall@computer.org>)
Responses Re: VARCHAR truncation  (Andrew Sullivan <andrew@libertyrms.info>)
List 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



pgsql-general by date:

Previous
From: "David Wall"
Date:
Subject: VARCHAR truncation
Next
From: Benjamin Stewart
Date:
Subject: Stored Procedures