Re: varchar or text - Mailing list pgsql-general

From Pascal Cohen
Subject Re: varchar or text
Date
Msg-id 4816CFFF.3020908@wimba.com
Whole thread Raw
In response to Re: varchar or text  (Guillaume Lelarge <guillaume@lelarge.info>)
Responses Re: varchar or text  (Martijn van Oosterhout <kleptog@svana.org>)
List pgsql-general
Guillaume Lelarge wrote:
> Pascal Cohen a écrit :
>> I had a look in previous posts in the forum but could not find the
>> answer I was looking for.
>> My question is should I switch from varchar to text.
>> We have "discovered" although it seems to be SQL that adding
>> something like 'text               ' to a varchar(50) just silently
>> cut the text while a text with check(length) - or also a varchar with
>> a check raised an error.
>
> Nope. If you try to add some text with more than 50 characters on a
> varchar(50) column, you will get an error. For example :
>
> test=# create table t (c varchar(5));
> CREATE TABLE
> test=# insert into t (c) values ('12345');
> INSERT 0 1
> test=# insert into t (c) values ('123456');
> ERREUR:  valeur trop longue pour le type character varying(5)
>
> (the english error message is:
> ERROR:  value too long for type character varying(5)
> ).
>
> Which release do you use ?
I am with 8.3.1 release but I mentioned that this appears with spaces at
then end not with standard chars. Of course your examples are working
fine but insert something like 'abc        ' (with several spaces and it
will work but just ignore the spaces above the 5th char.


pgsql-general by date:

Previous
From: paul rivers
Date:
Subject: Re: close database, nomount state
Next
From: valgog
Date:
Subject: Re: passing a temporary table with more than one column to a stored procedure