Re: varchar truncation from 7.1 to 7.2

From: Jeff Davis <list-pgsql-general(at)empires(dot)org>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: varchar truncation from 7.1 to 7.2
Date: 2002-08-02 02:55:50
Message-ID: 200208011955.50062.list-pgsql-general@empires.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Oh, I see. It's good to be standard.

As a related question, I tried making the trigger per Jan's suggestion that
would truncate the value before the insert. However, it appears that the
check is done prior to calling the trigger. I put a notice in the trigger and
it's not even displayed if the string is larger than the allowed value
(therefore, the trigger isn't even called before the insert is rejected).

Regards,
Jeff

On Thursday 01 August 2002 07:22 pm, Bruce Momjian wrote:
> The SQL standard required the change.
>
> ---------------------------------------------------------------------------
>
> Jeff Davis wrote:
> > I know that 7.2 started raising an error when a string is too long for a
> > varchar, whereas 7.1 silently truncated it.
> >
> > My question is: why?
> >
> > I read some previous posts about it, and the solution seemed to be a
> > per-table trigger to truncate the new value first (Thanks Jan).
> >
> > Now, I don't think it's a problem if the behavior was always that way. If
> > every other database threw an error, that would also make sense (I am
> > pretty sure that db2 silently truncates).
> >
> > However, it does seem to be a problem (albeit very minor) because it's
> > (a) a change from previous releases and (b) not always helpful.
> >
> > If you send a query, and there is an obvious, sane, safe, predictable
> > way to make it work, I think that's the correct course of action.
> > Moreover, there really isn't a way for you to know that you've made an
> > application programming error until it's in production anyway (with the
> > current behavior or prior behavior), so I don't see how it helps you
> > debug anything.
> >
> > Am I missing a strong gain here? Again, this is a really minor issue.
> > Overall I'm really happy with 7.2.1 (which I just put on my production
> > systems, in case you're curious what prompted this question).
> >
> > Thanks,
> > Jeff
> >
> >
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 6: Have you searched our list archives?
> >
> > http://archives.postgresql.org

In response to

Browse pgsql-general by date

  From Date Subject
Next Message C. Miller 2002-08-02 03:28:57 Import from MS SQL Server?
Previous Message Bruce Momjian 2002-08-02 02:22:50 Re: varchar truncation from 7.1 to 7.2