Re: Optimize duplicate code and fix memory leak in function fetch_remote_table_info()

2024-01-19 Thread Yongtao Huang
Hi, > So whatever it leaks will be released at the transaction end. I learned it. thank you very much for your explanation. Regards, Yongtao Huang Tom Lane 于2024年1月20日周六 12:34写道: > Yongtao Huang writes: > > (1) I think *pfree(pub_names.data)* is necessary. > > Really? > > It looks to me li

Re: Optimize duplicate code and fix memory leak in function fetch_remote_table_info()

2024-01-19 Thread Tom Lane
Yongtao Huang writes: > (1) I think *pfree(pub_names.data)* is necessary. Really? It looks to me like copy_table, and thence fetch_remote_table_info, is called once within a transaction. So whatever it leaks will be released at transaction end. This is a good thing, because it's messy enough

Re: Optimize duplicate code and fix memory leak in function fetch_remote_table_info()

2024-01-19 Thread Yongtao Huang
Thanks for your review. (1) I think *pfree(pub_names.data)* is necessary. (2) Agree with you. Considering that the new function is only called twice, not encapsulating it into a function is not a huge problem. Best wishes Yongtao Huang Michael Paquier 于2024年1月20日周六 11:13写道: > On Fri, Jan 19

Re: Optimize duplicate code and fix memory leak in function fetch_remote_table_info()

2024-01-19 Thread Michael Paquier
On Fri, Jan 19, 2024 at 10:42:46PM +0800, Yongtao Huang wrote: > This patch fixes two things in the function fetch_remote_table_info(). > > (1) *pfree(pub_names.data)* to avoid potential memory leaks. True that this code puts some effort in cleaning up the memory used locally. > (2) 2 pieces of

Optimize duplicate code and fix memory leak in function fetch_remote_table_info()

2024-01-19 Thread Yongtao Huang
This patch fixes two things in the function fetch_remote_table_info(). (1) *pfree(pub_names.data)* to avoid potential memory leaks. (2) 2 pieces of code can do the same work, ``` C foreach(lc, MySubscription->publications) { if (foreach_current_index(lc) > 0) appendStringInfoString(&p