Re: Add null termination to string received in parallel apply worker

2023-10-25 Thread David Rowley
On Wed, 11 Oct 2023 at 19:54, Zhijie Hou (Fujitsu) wrote: > The parallel apply worker didn't add null termination to the string received > from the leader apply worker via the shared memory queue. This action doesn't > bring bugs as it's binary data but violates the rule established in > StringIn

RE: Add null termination to string received in parallel apply worker

2023-10-11 Thread Zhijie Hou (Fujitsu)
On Thursday, October 12, 2023 12:04 AM Tom Lane wrote: Hi, > > Alvaro Herrera writes: > > I was thinking about this when skimming the other StringInfo thread a > > couple of days ago. I wondered if it wouldn't be more convenient to > > change the convention that all StringInfos are null-termi

Re: Add null termination to string received in parallel apply worker

2023-10-11 Thread David Rowley
On Thu, 12 Oct 2023 at 05:04, Tom Lane wrote: > > Alvaro Herrera writes: > > I was thinking about this when skimming the other StringInfo thread a > > couple of days ago. I wondered if it wouldn't be more convenient to > > change the convention that all StringInfos are null-terminated: what is >

Re: Add null termination to string received in parallel apply worker

2023-10-11 Thread Tom Lane
Alvaro Herrera writes: > I was thinking about this when skimming the other StringInfo thread a > couple of days ago. I wondered if it wouldn't be more convenient to > change the convention that all StringInfos are null-terminated: what is > really the reason to have them all be like that? It mak

Re: Add null termination to string received in parallel apply worker

2023-10-11 Thread Alvaro Herrera
On 2023-Oct-11, Amit Kapila wrote: > Yeah, it may not be a good idea to modify the buffer pointing to > shared memory without any lock as we haven't reserved that part of > memory. So, we can't follow the trick used in exec_bind_message() to > maintain the convention that StringInfos have a traili

Re: Add null termination to string received in parallel apply worker

2023-10-11 Thread Amit Kapila
On Wed, Oct 11, 2023 at 12:18 PM Zhijie Hou (Fujitsu) wrote: > > The parallel apply worker didn't add null termination to the string received > from the leader apply worker via the shared memory queue. This action doesn't > bring bugs as it's binary data but violates the rule established in > Str

Re: Add null termination to string received in parallel apply worker

2023-10-11 Thread Peter Smith
Hi Hou-san. + /* + * Note that the data received via the shared memory queue is not + * null-terminated. So we use the StringInfo API to store the + * string so as to maintain the convention that StringInfos has a + * trailing null. + */ "... that StringInfos has a trailing null." Probably shoul