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 1pEwLX-0006BF-2P for pgsql-hackers@arkaria.postgresql.org; Mon, 09 Jan 2023 17:54:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pEwLV-0006wr-B8 for pgsql-hackers@arkaria.postgresql.org; Mon, 09 Jan 2023 17:54:05 +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 1pEwLU-0006wP-WB for pgsql-hackers@lists.postgresql.org; Mon, 09 Jan 2023 17:54:05 +0000 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pEwLS-0003or-8l for pgsql-hackers@postgresql.org; Mon, 09 Jan 2023 17:54:04 +0000 Received: by mail-pl1-x635.google.com with SMTP id w3so10351781ply.3 for ; Mon, 09 Jan 2023 09:54:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=9ipPZRCWDqZNAWOc3BwfDoLGjL6YWNdmvcXOY0n41LA=; b=p59FJXn0Ta8c8IcTgi14hYVGDu0PJP9QC15G1KPiXjCDSOhDDmE4ioa/Ox29wowozf LGUmMfWnV9VD9uZF7o6o1JMzt1uPJhc9pnP72RmOx/a8s0GiT8bMiJKrLuT+JspQyaSB wHtyTvdhlvnNFaiorY0LmhP1LWM2nbexb0G7PR1+EsGUywtzsTzlF66nKdGahhvA7AOl 1WuBY36+EieJltzwHRlopKr3ay3cTRU3+9FfiyN9T3yEwK8qrJyy24NQOu5pp2npIitl CDqoBVNXmNonTHHEa0kkvCd8G+VjLjU2QCGNtkb1583jUdNJrO07MJ/OF6KOSDULO99Q VmlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=9ipPZRCWDqZNAWOc3BwfDoLGjL6YWNdmvcXOY0n41LA=; b=PYLfAkGA7HwzH3G9paZnnCMp9eSIApnB+TU/7givBRafexe1R+cL7wYSt68FqwCWoW pkjnpoJ0pZ0+JMBGWxZ3wptrMGYzWZplJyCd9O/aH6Y64nmngI9r2z2WQXsyUjwVdufY q8SwMO49SukPD5mW1kd03cf8LbiSfh53yHB/4WGxIibRm5TohOZVX93DOgk+q9C6wbhG 9NupECTKsCFRRtgCvPkilXymyspStr9JJaz/9kmTfCPfQrZx7FLzXegCA1WzWqj4g1Wk pFxipwJS8gOsVP9QVPauv0V8LMA+IJlacsB84dmB1TnTj1THkq2wMw0e3J1jQgFcqTYs sUIQ== X-Gm-Message-State: AFqh2kroZ+LnGqOn9dTeRN13uP7eE+19P8AfIuk7/hHmlXOV7UbKPnM0 KhwD5GPIo+6n5o+4sO/48hW2bDn2jNc= X-Google-Smtp-Source: AMrXdXuer+UQzWBPVbil8NLVIRP/2X8HO8CSxTr2/Y5rojoLdd8hEjTPAS2VYcc/xg/H26IHG3bsPg== X-Received: by 2002:a17:90a:730a:b0:225:a132:f193 with SMTP id m10-20020a17090a730a00b00225a132f193mr66311630pjk.6.1673286840121; Mon, 09 Jan 2023 09:54:00 -0800 (PST) Received: from nathanxps13 ([50.47.162.83]) by smtp.gmail.com with ESMTPSA id 14-20020a630c4e000000b00478f87eaa44sm5312003pgm.35.2023.01.09.09.53.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jan 2023 09:53:59 -0800 (PST) Date: Mon, 9 Jan 2023 09:53:57 -0800 From: Nathan Bossart To: Peter Eisentraut Cc: Alvaro Herrera , Justin Pryzby , pgsql-hackers@postgresql.org Subject: Re: Common function for percent placeholder replacement Message-ID: <20230109175357.GB1112921@nathanxps13> References: <20221219095114.m4nlp4fb3owmsu65@alvherre.pgsql> <8228593d-1ebc-e061-2c61-3815bb364385@enterprisedb.com> <20230104003700.GB289060@nathanxps13> <1c2204c9-a38e-3075-56dc-eef9a103a645@enterprisedb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1c2204c9-a38e-3075-56dc-eef9a103a645@enterprisedb.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Jan 09, 2023 at 09:36:12AM +0100, Peter Eisentraut wrote: > On 04.01.23 01:37, Nathan Bossart wrote: >> On Tue, Dec 20, 2022 at 06:30:40AM +0100, Peter Eisentraut wrote: >> > + * A value may be NULL. If the corresponding placeholder is found in the >> > + * input string, the whole function returns NULL. >> >> This appears to be carried over from BuildRestoreCommand(), and AFAICT it >> is only necessary because pg_rewind doesn't support %r in restore_command. >> IMHO this behavior is counterintuitive and possibly error-prone and should >> result in an ERROR instead. Since pg_rewind is the only special case, it >> could independently check for %r before building the command. > > Yeah, this annoyed me, too. I have now changed it so that a NULL "value" is > the same as an unsupported placeholder. This preserves the existing > behavior. > > (Having pg_rewind check for %r itself would probably require replicating > most of the string processing logic (consider something like "%%r"), so it > didn't seem appealing.) Sounds good to me. > + nativePath = pstrdup(path); > + make_native_path(nativePath); > + nativePath = pstrdup(xlogpath); > + make_native_path(nativePath); Should these be freed? -- Nathan Bossart Amazon Web Services: https://aws.amazon.com