Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w2ZV8-000PJo-2o for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Mar 2026 18:50:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w2ZV7-004DuV-25 for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Mar 2026 18:50:45 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w2ZV7-004DuN-15 for pgsql-hackers@lists.postgresql.org; Tue, 17 Mar 2026 18:50:45 +0000 Received: from mail-dy1-x132b.google.com ([2607:f8b0:4864:20::132b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w2ZV4-00000000eYM-3aUi for pgsql-hackers@postgresql.org; Tue, 17 Mar 2026 18:50:45 +0000 Received: by mail-dy1-x132b.google.com with SMTP id 5a478bee46e88-2bd9a485bd6so651501eec.1 for ; Tue, 17 Mar 2026 11:50:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773773441; x=1774378241; darn=postgresql.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=iv2wWnJFuHBSc/Awd0xywku7ECT9kMSiCLL0wXuMx9k=; b=hDC0zbTpW3mUed12Vl200h/9OOsbTXaG9NDNa5qtrmtXbgtjPvmZR7ty5a2XRIdoN4 TXHTDjG00Q64pkuMECSL7KJRdw/KmGnhZ8JBKJYG9TdBzga1IXUb9zi4lc9ICRhEy6mM r8/SROhxbTyQQj+5lwAkhYw3kf1kcQ0wczzGzjq1S9Z7A427u4wRc3mFiGEckt+TSTM1 LG8UE9LOtoGXgw2Yv4ZxQW85qNMseg3GNOAXuezyp6399BHRIg+mLPCt35zMjXFXBQpQ 40FFaZ0FQUXg77L46OtZy2ESQcc8iaXrRCJiOvFymDQa1x7p4ffzDEaeXdI+F+XJA9Kf CVRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773773441; x=1774378241; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=iv2wWnJFuHBSc/Awd0xywku7ECT9kMSiCLL0wXuMx9k=; b=LeU6M4WQkbQmaJHeY4VA1UETLET22VPkmZppNiBtCQ65PJMrlv5ORafmQEo936UERQ 8uyW1Ncs/x85weyLxXec2qLWeXHW+ufdpW8iee1Zkc2TTFn8dQOswITVva+8XAexqb91 wDMWXDf71DQF8TQxBeMOYpl8V/PTbxOHHrs25xe7vtuvSQRoB1T03fik940iXiZyWETp R5UdacyiCUWuIiF3tqnCxFj5LKMjSMXCwUS0lW21aFxB5U2hYgF/hJjUCjfKazvumuHa uIFXQPW2SFSvXdBLqm0k9He86qxM6eW96cevHrH2DUa8i3y9mXW1ABryLtxGzZYEH934 okmQ== X-Forwarded-Encrypted: i=1; AJvYcCWV6xhs3Zkdz7diEggXhrkoO3AtPkglo+nMYYalVY6V4v6LzD3vtzKZJ9IG24omCtxfljWHvVlvTS7+BSyi@postgresql.org X-Gm-Message-State: AOJu0YzDPVWo5XWdW49z4Zb9EIjqR6dbCZelPO2nmuA5Iqm1ZlVj1TLJ 8zC3n8r3W6VMkXcPm55HYa/LcUnQZH9HHeAOSe5jWPpzx+OBwYXwAthJcfNvAlYV X-Gm-Gg: ATEYQzwnM/H2fz/eXZhxSSGzPlT29j4fA0dDdOpzTGd3QGaQ9aNQQUH53XWvVq/Mk/o cTkJekVG8ueHDAGavUQrH+GtgNGGH4qBTK7o9ddb+rH2JaSgYidYRXzNy3F7NOeLNn/1NKwiAhK UZ9bGKLa72yIDWyh6V05NGlKc5Ikiih6/e7PMhHIfmIrrYIJugS3vegGRan9JuOro4oltudCGIg Hz4QsPGOMSMOytZME7fcYxnGZ7UgzgUALE65X0kssTd1L9exObtoJP8PyZZDgCqWBzH4qk/NS6e kkrBGt7hk6APlByZCMSdLLTiVPzRDeUmOyhVBlh4vNflDKBBSDurSRYquvnOFNq9Wj8We4DLwzF SSth3X/ELhaxKKSbNNnKoxyp7FSZG4vVnFM1G6FgWOeD7B/+AClgulvh/1ZHQ2ZxB6DP7kBH9d7 nJwJYtBJ5Q3pHMlH9lNgVCq1HNU21ujITzWzJdMkr6Hf89nMJ0ZMkxYgi0l+LF3EupmfoBhPvDr V7n+A== X-Received: by 2002:a05:7301:1285:b0:2c0:bfe8:6830 with SMTP id 5a478bee46e88-2c0e5020afdmr275018eec.20.1773773441058; Tue, 17 Mar 2026 11:50:41 -0700 (PDT) Received: from smtpclient.apple ([17.236.29.81]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2c0e560fb5fsm476304eec.31.2026.03.17.11.50.40 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Mar 2026 11:50:40 -0700 (PDT) From: Haibo Yan X-Google-Original-From: Haibo Yan Message-Id: <7F7B289B-F94F-42C2-9E54-6A689C0D64BB@gmail.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_5FEC83E2-5B7D-4582-9E25-9706B8E1489E" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.400.21\)) Subject: Re: Return pg_control from pg_backup_stop(). Date: Tue, 17 Mar 2026 11:50:29 -0700 In-Reply-To: Cc: Michael Paquier , Pg Hackers To: David Steele References: <83f5295e-082d-432c-92a4-365707bd2296@pgbackrest.org> <1248c005-b693-494a-8d7a-68bc7d482679@pgbackrest.org> <8b8aa673-fcef-4e14-a05d-0885283ef1b8@pgbackrest.org> <17DC1346-0CDE-4E39-B110-3D6FB0797AC6@gmail.com> X-Mailer: Apple Mail (2.3864.400.21) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_5FEC83E2-5B7D-4582-9E25-9706B8E1489E Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Hi David, Thank you for the clarification. I have now read the code, and overall = it looks good to me. I only had one very small comment. You currently have: ``` memset(controlFile + sizeof(ControlFileData), 0, PG_CONTROL_FILE_SIZE - sizeof(ControlFileData)); memcpy(controlFile, ControlFile, sizeof(ControlFileData)); ```=20 This is correct, since only the trailing bytes need to be zeroed before = the copy. I was just wondering whether the following might be slightly clearer: ``` memset(controlFile, 0, PG_CONTROL_FILE_SIZE); memcpy(controlFile, ControlFile, sizeof(ControlFileData)); ``` I do not think this is a real issue, though. Thanks Haibo > On Mar 17, 2026, at 12:05=E2=80=AFAM, David Steele = wrote: >=20 > On 3/17/26 12:16, Haibo Yan wrote: >=20 >> I have not read the code yet, so this may already be answered there, = but I had a question about the proposal itself. This patch protects = against a missing backup_label, but what about a wrong one? If a user = restores a backup_label file from a different backup, the existence = check alone would not detect that. Do we need some consistency check = between the returned pg_control copy and the backup_label contents, or = is the intended scope here limited to the =E2=80=9Cmissing file=E2=80=9D = case only? >=20 > Thank you for having a look! >=20 > The goal here is only to check for a missing backup_label. The general = problem is that PostgreSQL suggests that removing backup_label might be = a good idea so the user does it: >=20 > If you are not restoring from a backup, try removing the file = \"%s/backup_label\" >=20 > The user *could* copy a backup_label from another backup and there are = ways we could detect that but I feel that should be material for a = separate patch. >=20 > Regards, > -David >=20 >=20 --Apple-Mail=_5FEC83E2-5B7D-4582-9E25-9706B8E1489E Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
Hi = David,

Thank you for the clarification. I have now read the = code, and overall it looks good to me. I only had one very small = comment.

You currently have:
```
memset(controlFile + sizeof(ControlFileData), = 0,
      =  PG_CONTROL_FILE_SIZE - = sizeof(ControlFileData));
memcpy(controlFile, ControlFile, = sizeof(ControlFileData));
``` 
This is = correct, since only the trailing bytes need to be zeroed before the = copy.

I was just wondering whether the following might be = slightly clearer:
```
memset(controlFile, 0, = PG_CONTROL_FILE_SIZE);
memcpy(controlFile, ControlFile, = sizeof(ControlFileData));
```

I do not think = this is a real issue, though.

Thanks
Haibo

On Mar 17, 2026, at 12:05=E2=80=AFAM, David Steele = <david@pgbackrest.org> wrote:

On 3/17/26 12:16, Haibo = Yan wrote:

I have not read the code = yet, so this may already be answered there, but I had a question about = the proposal itself. This patch protects against a missing backup_label, = but what about a wrong one? If a user restores a backup_label file from = a different backup, the existence check alone would not detect that. Do = we need some consistency check between the returned pg_control copy and = the backup_label contents, or is the intended scope here limited to the = =E2=80=9Cmissing file=E2=80=9D case only?

Thank you = for having a look!

The goal here is only to check for a missing = backup_label. The general problem is that PostgreSQL suggests that = removing backup_label might be a good idea so the user does = it:

If you are not restoring from a backup, try removing the file = \"%s/backup_label\"

The user *could* copy a backup_label from = another backup and there are ways we could detect that but I feel that = should be material for a separate = patch.

Regards,
-David



= --Apple-Mail=_5FEC83E2-5B7D-4582-9E25-9706B8E1489E--