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 1wgbdM-006HpB-0l for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Jul 2026 05:12:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wgbdL-00EzOK-03 for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Jul 2026 05:12:43 +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 1wgbdK-00EzO9-2F for pgsql-hackers@lists.postgresql.org; Mon, 06 Jul 2026 05:12:42 +0000 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wgbdI-00000001zeu-1ewD for pgsql-hackers@lists.postgresql.org; Mon, 06 Jul 2026 05:12:42 +0000 Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-c96b08cdd1cso1854547a12.0 for ; Sun, 05 Jul 2026 22:12:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1783314757; cv=none; d=google.com; s=arc-20260327; b=IuTFmGNkyCb467gD93cCyT7Unu49TS9ksBPvhOoKa3B8xpLyxNCCmileyJDrY3oQ8u jh0KV3SqR7JS8dYAjfilK/iJfI5quNCstC/rLkG4J2BNXaLVU2vOsKAe62HZ3+i9Xth3 mNgjIFcqZUhpZQJYzqCDhCucxyqSxnTDqeK4BXIsYMZ+1j0QrbypC6bsScNvMzdcUh3Q A7zYt/BFWXo6pl6Y4o8L/2FdhaRbRhcyNxzRv63gTilq2Ncu/KbX+rfu1HQ0CR2I5RIs OzynQ22Cdl0MIN4kQIVSikoD1Q3SsG7fRrvqVY0sVcY0ISN9+Oi6LRMdjn+q0AI0YbCu q3Hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=5gHdMJRlpy1SrYX+rxXpZ3FwaqZslkzmSzWr0rAU7B0=; fh=7kHrjfL6OqKwG7IZHvThdZLYpXwutWeYQKiTX7ZaQJI=; b=GVzA75ywcwiYadxqnUg1aCXPXZGrQvXmvLSAZ+0RBVkesYm+JpdInpVUs+v1vGa4eF oNU0C8aX0TUWCKChkqnYWsJxKT8zXCU6UBg3/jKXeoStTw7qWbr3Ak7kawTfiC9nNgy0 A9uDKpIwLyeEei+nvhjoTot4EWwoiRhs/AY/JDXVrt63O64h+LI/x+27fLUGKI81F152 lkWlS8NiyGEJxwTAsbls7MbmGQ7zpdMY0QxSd/C73QN12YA8PiF5lSfZ0I+1vsHuwMFU Bmm+0TLIdOx7hb/SZeHlHetnwaHh2o7SH1XPujnTaBX5GHqFNikdzyrOFXqMON8KVLNp xFlg==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783314757; x=1783919557; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=5gHdMJRlpy1SrYX+rxXpZ3FwaqZslkzmSzWr0rAU7B0=; b=BKe9nF0Bko6v13mNJJ7nbLDodD61CQa4plVOVlbE/0OZDtpZDZTpqwBR2ekynfam6L BFCHYQ20/2pyxhe4LvMfuBbcrbF+r7FhF+EKn+LnIQlNoIasWbGgtXKphNl92Fy1uSwe V9vV0YcTJRax52LozC7OqhwME1sl5gbeiRb2F/45feBwQ0W2cGB5Ojd6zkVOq9/gOrXk ewNCMKk/PNB1oFOhie7ufp/cOZ4PJaH5p7+OF5Ir6UMw0azBojNnqrGkl+D9KckALDwY /p3RolaVIVNaqyMvLIvcBPCHzAKeajRn0V1KsC9VIYsNQdyqnHOf3IvIP/0OEwl5RJ9C rlGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783314757; x=1783919557; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=5gHdMJRlpy1SrYX+rxXpZ3FwaqZslkzmSzWr0rAU7B0=; b=R4W4ZbAWFsE7bOdrwrG7U4WfBRuHPTFr/6DQwvYIE3/PneP216sM8h5YtTyUmGnS+d sRlu1cTJ8ljvsK5/cymNTosPhCUojTyOQqfhxBR0qqsGjvhfT0wTfkk4sQzQDyT25VWr FA9BuAChsNpV5SbECNNWDEpl2QK3d0jOt8U+Ny5SrTIpQtH4/1yhFmQ7KhTyENpK1+qA iyOa+M4ZEfPhb6/4rip9D7AoeU9kYg/Bl6IKoIz9/GkCXU5uuXn2VJrlhQZk0Wv6hcge q5UizXmsRQDgj3o4lCNYUro5HdMdrVNwQRjpkEkryIuisWgQACbugs6dx9sdKKdvBXsn dnUA== X-Forwarded-Encrypted: i=1; AHgh+RpBJwf1pUUjdRXdqQQC3pO/TaYI+9XIBXxqysOqX0ZKvhnlI25UUETCYBSeZE5xyY4GwPFUfinEmwuHB2tV@lists.postgresql.org X-Gm-Message-State: AOJu0YyPlGwS6CirMBZKd17BGz6fnNOWKkvar8LVM95Chf/IedvsC9H/ 9h5XUHmct80s29bDY4BPQKYyAps6JbRFz9xMzyOZc70KvVWpN/3pS8FqH1ZgX1HJlREHKGUBzVp /09Sma3mKDdVuQwCb7e98lCprgGGZd2k= X-Gm-Gg: AfdE7clbXRXTGmIWKJxvECKCzlxWyrB8XynH+pv+QPf1m0wK2nnnO8UatjGp2XdvGy5 TT7+UdLBid/yYELg7og0wgqMOlFld+2GE4E4DCgATx2oaKhndvwS6d3VzssAczd2T5gwjrYBclp 6YPEM+KMBXrjmHhyNHRLKOvDhCnm2/y4EyhBAroVp3N3hyZ9AGB+smdB8+puyM0oMSU4SpcRmgW Mn+3tFmEdFYzXf+hbXknrOzHgvth/Z8p/WJBrMGtLoRdwlCxf4c4gI8PKPXx2uUqCUQbMWvnt7s AnLXekYPyVx/TgtoSgBjbWmwT5t8DAA5r6Ho5/Eor9Mbjkd40eYYPryQw0rsZi3fSv7TiFgZSVY = X-Received: by 2002:a05:6a21:1b85:b0:3bf:b1f4:747b with SMTP id adf61e73a8af0-3c03e1a27a2mr9526824637.12.1783314756928; Sun, 05 Jul 2026 22:12:36 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: shveta malik Date: Mon, 6 Jul 2026 10:42:24 +0530 X-Gm-Features: AVVi8CdJ_W2RbQJ8jQ3ADsKHjWwlfcqFORAUmUPYkniBIHKcnU7D5j5eoOsFrdQ Message-ID: Subject: Re: [PATCH] Preserve replication origin OIDs in pg_upgrade To: Ajin Cherian Cc: Zsolt Parragi , pgsql-hackers@lists.postgresql.org, shveta malik Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Jul 1, 2026 at 8:20=E2=80=AFAM Ajin Cherian wro= te: > > All the above changes are updated in patch v10. > Thanks for the patch. I have not reviewed completely yet, but please find comments so far: 1) + * In binary-upgrade mode, skip origin creation here. This is required to + * preserve the roident from the old cluster for this subscription's origi= n. Shall we slightly tweak it to: /* * In binary-upgrade mode, skip origin creation here. It will be * created separately so that the origin ID (roident) from the * old cluster can be preserved for this subscription. */ dumpReplicationOrigins: 2) + appendPQExpBufferStr(buf, + "SELECT o.*, os.remote_lsn " It will be better to be more specific here to make it more future proof: SELECT o.roident, o.roname, os.remote_lsn 3) + if (PQntuples(res) > 0) + fprintf(OPF, "--\n-- Replication Origins \n--\n\n"); + + for (int i =3D 0; i < PQntuples(res); i++) Instead of fetching it in loop, we can fetch it once and use it: ntups =3D PQntuples(res) 4) + appendPQExpBufferStr(buf, "\n-- For binary upgrade, must preserve replication origin roident and remote_lsn\n"); Seeing the pattern of other such comments in file, we can change 'origin' to be more specific 'pg_replication_origin' 5) get_replication_origin_info: + res =3D executeQueryOrDie(conn, "SELECT count(*) AS norigins " + "FROM pg_catalog.pg_replication_origin"); I don't see alias 'norigins' being sued anywhere. We can get rid of it if not needed. 6) get_subscription_info: I think a bug is introduced with the new change. Earlier query was below which will always return a row even if there is no subscription entry: postgres=3D# SELECT count(*) AS nsub, 'f' AS retain_dead_tuples FROM pg_catalog.pg_subscription; nsub | retain_dead_tuples ------+-------------------- 0 | f Now, this will not even return a result if there are no subscription entrie= s: postgres=3D# SELECT 'f' AS retain_dead_tuples FROM pg_catalog.pg_subscription; retain_dead_tuples -------------------- (0 rows) So this line of code will access a non existing result: i_retain_dead_tuples =3D PQfnumber(res, "retain_dead_tuples"); Should we simply do: res =3D executeQueryOrDie(conn, "SELECT false AS retain_dead_tuples"); (false/'f' anything is fine) instead of: res =3D executeQueryOrDie(conn, "SELECT 'f' AS retain_dead_tuples " "FROM pg_catalog.pg_subscription"); thanks Shveta