Re: ERROR: value too long for type character

From: Doug Fields <dfields-pg-general(at)pexicom(dot)com>
To: Neil Conway <nconway(at)klamath(dot)dyndns(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: ERROR: value too long for type character
Date: 2002-05-21 20:54:10
Message-ID: 5.1.0.14.2.20020521165042.01ed2b50@mail.pexicom.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


> > Do you know how I can tell it to "silently truncate" the data as I believe
> > it used to?
>
>Is there a reason you can't just use TEXT? It will be stored the same
>internally...

The only reason being that I don't want to waste space storing arbitrarily
long pieces of information.

I was not aware that TEXT is just as (in)efficient as VARCHAR, though. If
that is truly the case, I will consider using TEXT in some places, but only
when I am very careful in the INSERT and UPDATE clauses so as not to store
too long things.

>But the most obvious way I can think of to do what you're asking is
>to define a rule to replace the value inserted with a call to
>substring().

So, basically:

1) There's absolutely no way to get back the 7.1.3 "silent truncation"
behavior (which is, IMO, stupid, I like the non-standard truncation behavior)
2) You have to truncate on INSERT/UPDATE and continue using VARCHAR(x)
3) Instead of 2, you can use TEXT

Several others have asked this question since 7.2 appeared but none
received a response to #1.

Thanks,

Doug

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gaston Micheri 2002-05-21 21:24:38 Graphical Tool
Previous Message Neil Conway 2002-05-21 20:24:34 Re: ERROR: value too long for type character varying(255)