Обсуждение: Add tests for object size limits of injection points

Поиск
Список
Период
Сортировка

Add tests for object size limits of injection points

От
Michael Paquier
Дата:
Hi all,

While looking at a recent patch for injection points that has resulted
in 16a2f706951e, I have been reminded that the point name, library
name and function name have hardcoded limits, and it is now possible
to have them tested by SQL.

Attached is a patch to do so.  Thoughts?
--
Michael

Вложения

Re: Add tests for object size limits of injection points

От
Chao Li
Дата:

> On Nov 10, 2025, at 09:11, Michael Paquier <michael@paquier.xyz> wrote:
>
> Hi all,
>
> While looking at a recent patch for injection points that has resulted
> in 16a2f706951e, I have been reminded that the point name, library
> name and function name have hardcoded limits, and it is now possible
> to have them tested by SQL.
>
> Attached is a patch to do so.  Thoughts?
> --
> Michael
> <0001-injection_points-Add-tests-for-name-limits.patch>

Maybe not a problem of this patch, but

```
+SELECT injection_points_attach(repeat('a', 64), 'injection_notice',
+  'TestInjectionNoticeFunc', NULL);
+ERROR:  injection point name aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa too long (maximum of 64)
```

Is really confused. The error message says “maximum of 64”, but the test right uses a name of length 64. I know that
thetricky is the ‘\0’ terminator, but should SQL writer have to keep mind about the ‘\0’ terminator? Should they just
considermaximum length as 63? 

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/







Re: Add tests for object size limits of injection points

От
Michael Paquier
Дата:
On Mon, Nov 10, 2025 at 10:30:31AM +0800, Chao Li wrote:
> Is really confused. The error message says “maximum of 64”, but the
> test right uses a name of length 64. I know that the tricky is the
> ‘\0’ terminator, but should SQL writer have to keep mind about the
> ‘\0’ terminator? Should they just consider maximum length as 63?

Right.  We could add a "- 1" to the error message printed.
--
Michael

Вложения

Re: Add tests for object size limits of injection points

От
Xuneng Zhou
Дата:
Hi Michael, Chao,

On Mon, Nov 10, 2025 at 11:32 AM Michael Paquier <michael@paquier.xyz> wrote:
>
> On Mon, Nov 10, 2025 at 10:30:31AM +0800, Chao Li wrote:
> > Is really confused. The error message says “maximum of 64”, but the
> > test right uses a name of length 64. I know that the tricky is the
> > ‘\0’ terminator, but should SQL writer have to keep mind about the
> > ‘\0’ terminator? Should they just consider maximum length as 63?
>
> Right.  We could add a "- 1" to the error message printed.

Thanks for the patch. I also agree with Chao's suggestion that the
error message better reflects the actual character limits. I
implemented a patch for that and updated the test patch as well.
Please check.

Best,
Xuneng

Вложения

Re: Add tests for object size limits of injection points

От
Daniel Gustafsson
Дата:
> On 10 Nov 2025, at 02:11, Michael Paquier <michael@paquier.xyz> wrote:

> While looking at a recent patch for injection points that has resulted
> in 16a2f706951e, I have been reminded that the point name, library
> name and function name have hardcoded limits, and it is now possible
> to have them tested by SQL.

While they do increase code coverage, which is a good thing, it seems somewhat
unlikely that they will catch bugs given the nature of of the code being
tested.  That being said they come at a low cost so no objections to add.

--
Daniel Gustafsson




Re: Add tests for object size limits of injection points

От
Michael Paquier
Дата:
On Mon, Nov 10, 2025 at 06:27:41PM +0800, Xuneng Zhou wrote:
> Thanks for the patch. I also agree with Chao's suggestion that the
> error message better reflects the actual character limits. I
> implemented a patch for that and updated the test patch as well.
> Please check.

Yes, that works here.
--
Michael

Вложения

Re: Add tests for object size limits of injection points

От
Michael Paquier
Дата:
On Mon, Nov 10, 2025 at 06:27:41PM +0800, Xuneng Zhou wrote:
> Thanks for the patch. I also agree with Chao's suggestion that the
> error message better reflects the actual character limits. I
> implemented a patch for that and updated the test patch as well.
> Please check.

The restriction related to the private area can be enlarged by 1 byte,
because we don't care about the null-termination in this case.

Done that, and adjusted the whole down to 17 where this has been
introduced.  It's far from being critical, but consistency could
matter for future changes, including things outside of core.  And it's
nice to keep the same rules across the board if we can do so for
testing facilities.
--
Michael

Вложения

Re: Add tests for object size limits of injection points

От
Xuneng Zhou
Дата:
Hi,

On Wed, Nov 12, 2025 at 9:37 AM Michael Paquier <michael@paquier.xyz> wrote:
>
> On Mon, Nov 10, 2025 at 06:27:41PM +0800, Xuneng Zhou wrote:
> > Thanks for the patch. I also agree with Chao's suggestion that the
> > error message better reflects the actual character limits. I
> > implemented a patch for that and updated the test patch as well.
> > Please check.
>
> The restriction related to the private area can be enlarged by 1 byte,
> because we don't care about the null-termination in this case.

Makes sense to me.

> Done that, and adjusted the whole down to 17 where this has been
> introduced.  It's far from being critical, but consistency could
> matter for future changes, including things outside of core.  And it's
> nice to keep the same rules across the board if we can do so for
> testing facilities.
> --
> Michael

Thanks.

--
Best,
Xuneng



Re: Add tests for object size limits of injection points

От
Chao Li
Дата:

> On Nov 10, 2025, at 18:27, Xuneng Zhou <xunengzhou@gmail.com> wrote:
>
> Hi Michael, Chao,
>
> On Mon, Nov 10, 2025 at 11:32 AM Michael Paquier <michael@paquier.xyz> wrote:
>>
>> On Mon, Nov 10, 2025 at 10:30:31AM +0800, Chao Li wrote:
>>> Is really confused. The error message says “maximum of 64”, but the
>>> test right uses a name of length 64. I know that the tricky is the
>>> ‘\0’ terminator, but should SQL writer have to keep mind about the
>>> ‘\0’ terminator? Should they just consider maximum length as 63?
>>
>> Right.  We could add a "- 1" to the error message printed.
>
> Thanks for the patch. I also agree with Chao's suggestion that the
> error message better reflects the actual character limits. I
> implemented a patch for that and updated the test patch as well.
> Please check.
>
> Best,
> Xuneng
>
<v2-0001-injection_points-Report-actual-character-limits-i.patch><v2-0002-injection_points-Add-tests-for-name-limits.patch>

The patch looks good to me.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/