[patch] ENUM errdetail should mention bytes, not chars

Started by Ian Lawrence Barwickover 5 years ago4 messageshackers
Jump to latest
#1Ian Lawrence Barwick
barwick@gmail.com

Hi

The errdetail emitted when creating/modifying an ENUM value is misleading:

postgres=# CREATE TYPE enum_valtest AS ENUM (
'foo',
'ああああああああああああああああああああああ'
);
ERROR: invalid enum label "ああああああああああああああああああああああ"
DETAIL: Labels must be 63 characters or less.

Attached trivial patch changes the message to:

DETAIL: Labels must be 63 bytes or less.

This matches the documentation, which states:

The length of an enum value's textual label is limited by the NAMEDATALEN
setting compiled into PostgreSQL; in standard builds this means at most
63 bytes.

https://www.postgresql.org/docs/current/datatype-enum.html

I don't see any particular need to backpatch this.

Regards

Ian Barwick

--
EnterpriseDB: https://www.enterprisedb.com

Attachments:

enum-errdetail-fix.v1.patchtext/x-patch; charset=UTF-8; name=enum-errdetail-fix.v1.patchDownload+16-16
#2Julien Rouhaud
rjuju123@gmail.com
In reply to: Ian Lawrence Barwick (#1)
Re: [patch] ENUM errdetail should mention bytes, not chars

On Mon, Oct 19, 2020 at 12:18 PM Ian Lawrence Barwick <barwick@gmail.com> wrote:

Hi

The errdetail emitted when creating/modifying an ENUM value is misleading:

postgres=# CREATE TYPE enum_valtest AS ENUM (
'foo',
'ああああああああああああああああああああああ'
);
ERROR: invalid enum label "ああああああああああああああああああああああ"
DETAIL: Labels must be 63 characters or less.

Attached trivial patch changes the message to:

DETAIL: Labels must be 63 bytes or less.

This matches the documentation, which states:

The length of an enum value's textual label is limited by the NAMEDATALEN
setting compiled into PostgreSQL; in standard builds this means at most
63 bytes.

https://www.postgresql.org/docs/current/datatype-enum.html

I don't see any particular need to backpatch this.

Indeed the message is wrong, and patch LGTM.

#3Peter Eisentraut
peter_e@gmx.net
In reply to: Julien Rouhaud (#2)
Re: [patch] ENUM errdetail should mention bytes, not chars

On 2020-10-19 06:34, Julien Rouhaud wrote:

ERROR: invalid enum label "ああああああああああああああああああああああ"
DETAIL: Labels must be 63 characters or less.

Attached trivial patch changes the message to:

DETAIL: Labels must be 63 bytes or less.

This matches the documentation, which states:

The length of an enum value's textual label is limited by the NAMEDATALEN
setting compiled into PostgreSQL; in standard builds this means at most
63 bytes.

https://www.postgresql.org/docs/current/datatype-enum.html

I don't see any particular need to backpatch this.

Indeed the message is wrong, and patch LGTM.

Committed. Btw., the patch didn't update the regression test output.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

#4Ian Lawrence Barwick
barwick@gmail.com
In reply to: Peter Eisentraut (#3)
Re: [patch] ENUM errdetail should mention bytes, not chars

2020年10月27日(火) 20:00 Peter Eisentraut <peter.eisentraut@2ndquadrant.com>:

On 2020-10-19 06:34, Julien Rouhaud wrote:

ERROR: invalid enum label "ああああああああああああああああああああああ"
DETAIL: Labels must be 63 characters or less.

Attached trivial patch changes the message to:

DETAIL: Labels must be 63 bytes or less.

This matches the documentation, which states:

The length of an enum value's textual label is limited by the NAMEDATALEN
setting compiled into PostgreSQL; in standard builds this means at most
63 bytes.

https://www.postgresql.org/docs/current/datatype-enum.html

I don't see any particular need to backpatch this.

Indeed the message is wrong, and patch LGTM.

Committed.

Thanks!

Btw., the patch didn't update the regression test output.

Whoops... /me hangs head in shame and slinks away...

Regards

Ian Barwick

--
EnterpriseDB: https://www.enterprisedb.com