Add tests for object size limits of injection points

Started by Michael Paquier5 months ago9 messageshackers
Jump to latest
#1Michael Paquier
michael@paquier.xyz

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

Attachments:

0001-injection_points-Add-tests-for-name-limits.patchtext/x-diff; charset=us-asciiDownload+15-1
#2Chao Li
li.evan.chao@gmail.com
In reply to: Michael Paquier (#1)
Re: Add tests for object size limits of injection points

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 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?

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

#3Michael Paquier
michael@paquier.xyz
In reply to: Chao Li (#2)
Re: Add tests for object size limits of injection points

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

#4Xuneng Zhou
xunengzhou@gmail.com
In reply to: Michael Paquier (#3)
Re: Add tests for object size limits of injection points

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

Attachments:

v2-0001-injection_points-Report-actual-character-limits-i.patchapplication/octet-stream; name=v2-0001-injection_points-Report-actual-character-limits-i.patchDownload+8-12
v2-0002-injection_points-Add-tests-for-name-limits.patchapplication/octet-stream; name=v2-0002-injection_points-Add-tests-for-name-limits.patchDownload+15-1
#5Daniel Gustafsson
daniel@yesql.se
In reply to: Michael Paquier (#1)
Re: Add tests for object size limits of injection points

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

#6Michael Paquier
michael@paquier.xyz
In reply to: Xuneng Zhou (#4)
Re: Add tests for object size limits of injection points

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

#7Michael Paquier
michael@paquier.xyz
In reply to: Xuneng Zhou (#4)
Re: Add tests for object size limits of injection points

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

#8Xuneng Zhou
xunengzhou@gmail.com
In reply to: Michael Paquier (#7)
Re: Add tests for object size limits of injection points

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

#9Chao Li
li.evan.chao@gmail.com
In reply to: Xuneng Zhou (#4)
Re: Add tests for object size limits of injection points

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/