| From: | Haibo Yan <tristan(dot)yim(at)gmail(dot)com> |
|---|---|
| To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | [PATCH] ecpg: use memcpy in a few length-based copies |
| Date: | 2026-07-08 19:24:22 |
| Message-ID: | CABXr29HdcPfU+wC7Va9Z5WXh+Kai_63J4J-e3d-_w=EuBNFKLw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi hackers,
I noticed a few places in ecpg that use strncpy() even though the code already
knows how many bytes to copy.
For example, some paths copy N bytes into a temporary buffer and then add the
terminating NUL explicitly. There is also one small substring copy in
pgtypeslib/datetime.c. memcpy() seems a better fit for those cases.
I did not try to replace all strncpy() calls in ecpg. Some of them still need
the usual strncpy() behavior when the source string may be shorter than the
destination.
The patch also adds a small regression test for fixed-size char[] and VARCHAR
output around the exact-fit/truncation boundary.
Thanks,
Haibo
| Attachment | Content-Type | Size |
|---|---|---|
| 0001-ecpg-use-memcpy-for-selected-length-based-buffer-cop.patch | application/octet-stream | 14.4 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Peter Eisentraut | 2026-07-08 19:24:51 | Re: Add bms_offset_members() function for bitshifting Bitmapsets |
| Previous Message | Jeff Davis | 2026-07-08 19:20:45 | Re: Bug in ALTER SUBSCRIPTION ... SERVER / ... CONNECTION with broken old server |