Re: Current enums patch

From: Tom Dunstan <pgsql(at)tomd(dot)cc>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Heikki Linnakangas <heikki(at)enterprisedb(dot)com>, pgsql-patches(at)postgresql(dot)org
Subject: Re: Current enums patch
Date: 2007-04-02 18:39:52
Message-ID: 46114DF8.6030600@tomd.cc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

>> Hm, I suppose we should apply truncate_identifier rather than letting
>> the strings be blindly truncated (perhaps in mid-character). Should we
>> have it throw the truncation NOTICE, or not? First thought is to do so
>> during CREATE TYPE but not during plain enum_in().
>>
>
> I don't see much point in truncating.
>
> The patch I have so far gives the regression output shown below (yes, I
> should make the messages more consistent).
>
> In fact the truncation and associated NOTICE just strike me as confusing.

[snip]

> + ERROR: input value too long (74) for enum:
> "abcdefghijklmnopqrsatuvwxyz012345 etc etc

I was about to suggest that we just truncate the value in the input
function and look it up on the basis that if it's too long, the lookup
will fail and we can just tell the user that it wasn't a valid value.
But if there's a valid value that has the same 63 bytes as the first 63
of the too-long input string, we'll end up looking up the valid one
wrongly. So we do need to test for length and die at that point. Can we
just fail with the same error message as trying to input a smaller, but
similarly invalid string?

At create time, we should definitely throw an error... if we just
truncate the value at byte 64 (with a notice or not) we might truncate
in the middle of a multi-byte character. Yuk.

Cheers

Tom

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2007-04-02 18:45:06 Re: Current enums patch
Previous Message Gregory Stark 2007-04-02 18:31:43 Re: Blocked post