Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k1ghd-0000eu-Tk for pgsql-hackers@arkaria.postgresql.org; Sat, 01 Aug 2020 01:52:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k1gh5-00085U-54 for pgsql-hackers@arkaria.postgresql.org; Sat, 01 Aug 2020 01:52:15 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k1gh4-00085N-QN for pgsql-hackers@lists.postgresql.org; Sat, 01 Aug 2020 01:52:14 +0000 Received: from mail-qk1-x741.google.com ([2607:f8b0:4864:20::741]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1k1ggw-0006XI-Nu for pgsql-hackers@lists.postgresql.org; Sat, 01 Aug 2020 01:52:13 +0000 Received: by mail-qk1-x741.google.com with SMTP id d14so30606040qke.13 for ; Fri, 31 Jul 2020 18:52:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=2RSaFfTthxHJkSwL/Gpzdmnr+SJxHtYIsKXdRnvAMVw=; b=nfjYhuMAT6jiLIPsCq9uhkHI3H7LeT0tf6cEKl1rQIRxgfKpYyG1NHIvSIIBP9pgno lcot4waaqVRqemoSgz0M0a1fTfh5rpYDYKZlAhWAwx3YW4vYw9/SrCMa05J+zGvgpUKr D1HGdLWssH/cw8sos2jB1uIzEbAcZsil2Rb1wXbk8ype5CAgc4aGpZHje+JofZs1rdmv Dujz8AF7MPe7I/CQv0fVL8TaEKTo2/8V0koPwy7BEAgrY55RQCgGWcTjUTO3AJtuh8gu 78dgsZDHyuj7lcIwXg1XWXByS3u9kV76gqbmMzzvnApZhXgyQhrg9/mZWa0Uy6O2KXDV TO7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=2RSaFfTthxHJkSwL/Gpzdmnr+SJxHtYIsKXdRnvAMVw=; b=svTWqHtGpcowM2vgaldeYBFNqs+33Gbu2q5KPPQXReHWGtQPopWniR9m6VPmbl9ZBn QgYO1aBi9jtwv31xB6k6/wJnU28Z/GrSf2DleihZOarrFyQbQvuEPXtruqAU6nOsevIf wiV1kfxOGzTZYk8jVb6LaVhBJcn+IEQhlMyH5lzf2L7ytAmnMyaehetvRjZjuJVHAivu xdhBMs+fuS4XaKjKxW5b23Skbcj9saUfRBZDh+oCkHHvcMfRsHIJHxvsrHzP4aGGKCAw 61utgVQOfBdU78W9XFgqFDiqmn9UGxwhe3eHJMaQFGQnALKAx/8/QF5R3AK6gMem21RE o2AQ== X-Gm-Message-State: AOAM533XMgKD9foXIE2DOAsRmfRWajwfQ0fu01Et4pEXmLHFXPBDRKPM 3H10gmEKLubqK02YbBUFv/vUlrOBgwC0UPgmBL01tbynOqD380onACEDVTUzETalrmcO7aDE7/k y3r6iucicYYVstm9ysVjolTX+TriKXkw4Gj3zu7ve4E1ZzlYF2umbiX40FZxOesfX4VWiB8xYbj LaiQTGi+SpHTasFf/m X-Google-Smtp-Source: ABdhPJwAOx3vlpCBTpOg2ghwQCUm0ZPhYGZjYdPCNkQsylEgvW4J2LH81wrJu0xMFA7tp8ALKsxiIg== X-Received: by 2002:a05:620a:1257:: with SMTP id a23mr6684995qkl.207.1596246724765; Fri, 31 Jul 2020 18:52:04 -0700 (PDT) Received: from perhan.alvh.no-ip.org ([190.95.19.47]) by smtp.gmail.com with ESMTPSA id t93sm11478601qtd.97.2020.07.31.18.52.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 18:52:04 -0700 (PDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 227A52A1D7E; Fri, 31 Jul 2020 21:52:02 -0400 (-04) Date: Fri, 31 Jul 2020 21:52:02 -0400 From: Alvaro Herrera To: Georgios Cc: "pasim@vmware.com" , PostgreSQL Hackers Subject: Re: [PATCH] - Provide robust alternatives for replace_string Message-ID: <20200801015202.GA17318@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk What happens if a replacement string happens to be split in the middle by the fgets buffering? I think it'll fail to be replaced. This applies to both versions. In the stringinfo version it seemed to me that using pnstrdup is possible to avoid copying trailing bytes. If you're asking for opinion, mine is that StringInfo looks to be the better approach, and also you don't need to keep API compatibility. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services