Skip to content

Commit 84e8265

Browse files
committed
Report better object limits in error messages for injection points
Previously, error messages for oversized injection point names, libraries, and functions showed buffer sizes (64, 128, 128) instead of the usable character limits (63, 127, 127) as it did not count for the zero-terminated byte, which was confusing. These messages are adjusted to show better the reality. The limit enforced for the private area was also too strict by one byte, as specifying a zone worth exactly INJ_PRIVATE_MAXLEN should be able to work because three is no zero-terminated byte in this case. This is a stylistic change (well, mostly, a private_area size of exactly 1024 bytes can be defined with this change, something that nobody seem to care about based on the lack of complaints). However, this is a testing facility let's keep the logic consistent across all the branches where this code exists, as there is an argument in favor of out-of-core extensions that use injection points. Author: Xuneng Zhou <xunengzhou@gmail.com> Co-authored-by: Michael Paquier <michael@paquier.xyz> Discussion: https://postgr.es/m/CABPTF7VxYp4Hny1h+7ejURY-P4O5-K8WZg79Q3GUx13cQ6B2kg@mail.gmail.com Backpatch-through: 17
1 parent 434b605 commit 84e8265

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/backend/utils/misc/injection_point.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -283,16 +283,16 @@ InjectionPointAttach(const char *name,
283283
int free_idx;
284284

285285
if (strlen(name) >= INJ_NAME_MAXLEN)
286-
elog(ERROR, "injection point name %s too long (maximum of %u)",
287-
name, INJ_NAME_MAXLEN);
286+
elog(ERROR, "injection point name %s too long (maximum of %u characters)",
287+
name, INJ_NAME_MAXLEN - 1);
288288
if (strlen(library) >= INJ_LIB_MAXLEN)
289-
elog(ERROR, "injection point library %s too long (maximum of %u)",
290-
library, INJ_LIB_MAXLEN);
289+
elog(ERROR, "injection point library %s too long (maximum of %u characters)",
290+
library, INJ_LIB_MAXLEN - 1);
291291
if (strlen(function) >= INJ_FUNC_MAXLEN)
292-
elog(ERROR, "injection point function %s too long (maximum of %u)",
293-
function, INJ_FUNC_MAXLEN);
294-
if (private_data_size >= INJ_PRIVATE_MAXLEN)
295-
elog(ERROR, "injection point data too long (maximum of %u)",
292+
elog(ERROR, "injection point function %s too long (maximum of %u characters)",
293+
function, INJ_FUNC_MAXLEN - 1);
294+
if (private_data_size > INJ_PRIVATE_MAXLEN)
295+
elog(ERROR, "injection point data too long (maximum of %u bytes)",
296296
INJ_PRIVATE_MAXLEN);
297297

298298
/*

0 commit comments

Comments
 (0)