Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 0525572

Browse files
committed
Fix enum errdetail to mention bytes, not chars
The enum label length is in terms of bytes, not charactes. Author: Ian Lawrence Barwick <barwick@gmail.com> Reviewed-by: Julien Rouhaud <rjuju123@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/CAB8KJ=itZEJ7C9BacTHSYgeUysH4xx8wDiOnyppnSLyn6-g+Bw@mail.gmail.com
1 parent 9213462 commit 0525572

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/backend/catalog/pg_enum.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ EnumValuesCreate(Oid enumTypeOid, List *vals)
125125
ereport(ERROR,
126126
(errcode(ERRCODE_INVALID_NAME),
127127
errmsg("invalid enum label \"%s\"", lab),
128-
errdetail("Labels must be %d characters or less.",
128+
errdetail("Labels must be %d bytes or less.",
129129
NAMEDATALEN - 1)));
130130

131131
values[Anum_pg_enum_oid - 1] = ObjectIdGetDatum(oids[elemno]);
@@ -228,7 +228,7 @@ AddEnumLabel(Oid enumTypeOid,
228228
ereport(ERROR,
229229
(errcode(ERRCODE_INVALID_NAME),
230230
errmsg("invalid enum label \"%s\"", newVal),
231-
errdetail("Labels must be %d characters or less.",
231+
errdetail("Labels must be %d bytes or less.",
232232
NAMEDATALEN - 1)));
233233

234234
/*
@@ -523,7 +523,7 @@ RenameEnumLabel(Oid enumTypeOid,
523523
ereport(ERROR,
524524
(errcode(ERRCODE_INVALID_NAME),
525525
errmsg("invalid enum label \"%s\"", newVal),
526-
errdetail("Labels must be %d characters or less.",
526+
errdetail("Labels must be %d bytes or less.",
527527
NAMEDATALEN - 1)));
528528

529529
/*

src/test/regress/expected/enum.out

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ ORDER BY enumlabel::planets;
9292
ALTER TYPE planets ADD VALUE
9393
'plutoplutoplutoplutoplutoplutoplutoplutoplutoplutoplutoplutoplutopluto';
9494
ERROR: invalid enum label "plutoplutoplutoplutoplutoplutoplutoplutoplutoplutoplutoplutoplutopluto"
95-
DETAIL: Labels must be 63 characters or less.
95+
DETAIL: Labels must be 63 bytes or less.
9696
ALTER TYPE planets ADD VALUE 'pluto' AFTER 'zeus';
9797
ERROR: "zeus" is not an existing enum label
9898
-- if not exists tests

0 commit comments

Comments
 (0)