Re: [PATCH] - Provide robust alternatives for replace_string

From: Georgios <gkokolatos(at)protonmail(dot)com>
To: Asim Praveen <pasim(at)vmware(dot)com>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATCH] - Provide robust alternatives for replace_string
Date: 2020-08-19 08:07:16
Message-ID: 7gnV0BaCXVoHGNDdPElp6n81haF-OjFRfN7du682DYyqGJP6YOg-WTyKcglM0UZgpEPmWxbV_SD6CLIDDPv4F07xziOGmGcOfcyoZ6z6Rao=@protonmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Friday, 7 August 2020 09:02, Asim Praveen <pasim(at)vmware(dot)com> wrote:

> > On 05-Aug-2020, at 7:01 PM, Alvaro Herrera alvherre(at)2ndquadrant(dot)com wrote:
> > On 2020-Aug-05, Asim Praveen wrote:
> >
> > > Please find attached a StringInfo based solution to this problem. It
> > > uses fgetln instead of fgets such that a line is read in full, without
> > > ever splitting it.
> >
> > never heard of fgetln, my system doesn't have a manpage for it, and we
> > don't use it anywhere AFAICS. Are you planning to add something to
> > src/common for it?
>
> Indeed! I noticed fgetln on the man page of fgets and used it without checking. And this happened on a MacOS system.
>
> Please find a revised version that uses fgetc instead.

Although not an issue in the current branch, fgetc might become a bit slow
in large files. Please find v3 which simply continues reading the line if
fgets fills the buffer and there is still data to read.

Also this version, implements Alvaro's suggestion to break API compatibility.

To that extent, ecpg regress has been slightly modified to use the new version
of replace_string() where needed, or remove it all together where possible.

//Georgios

>
> Asim

Attachment Content-Type Size
v3-0001-Use-a-stringInfo-instead-of-a-char-for-replace_st.patch application/octet-stream 8.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message torikoshia 2020-08-19 08:40:00 Re: Creating a function for exposing memory usage of backend process
Previous Message Dilip Kumar 2020-08-19 08:05:39 Re: PATCH: logical_work_mem and logical streaming of large in-progress transactions