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 1wGXhY-006KFl-2Q for pgsql-hackers@arkaria.postgresql.org; Sat, 25 Apr 2026 07:45:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wGXgX-008Ssb-04 for pgsql-hackers@arkaria.postgresql.org; Sat, 25 Apr 2026 07:44:17 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wGXgW-008SsP-1T for pgsql-hackers@lists.postgresql.org; Sat, 25 Apr 2026 07:44:16 +0000 Received: from mail-vs1-xe2c.google.com ([2607:f8b0:4864:20::e2c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wGXgU-00000002hHJ-1GDk for pgsql-hackers@lists.postgresql.org; Sat, 25 Apr 2026 07:44:15 +0000 Received: by mail-vs1-xe2c.google.com with SMTP id ada2fe7eead31-610e2e8f57dso3092474137.0 for ; Sat, 25 Apr 2026 00:44:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1777103053; cv=none; d=google.com; s=arc-20240605; b=OFRqFNRTzXM5kOg8vvyuHKyc1vxD/jrTOgn37ggzFdEuakJE9dLFtbPzkvLlvkyuLd u0aPxxGZtMduEVQr75YoC0S5GUeJmh/ZN99HE/HluNXnNezhBZbZwmcQzwJcX9iO/KfP xziobp6BbYEQgOYBXjNgERAhs/v9BV1OEKEJj9YLCrIcFJJ8oQFs0+kPmvHW6HKhYyAU Mz31jujLtEyuJw1wnzxso/qm8o5VLBsbDHLaFOsGSrlp5OriFw9vkFoRO8rfcxh7JZLK EoHihPVCrI0GpCiwyUBvdyUTF7R4FY01dHra2BQXR91KvOo2IWmePHajNcdQ8q4ogUvT 3fBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=to:subject:message-id:date:from:mime-version:dkim-signature; bh=HqtCStu8X45ozzDKhvHR8R7yy2NKEws+yIXStmYodCE=; fh=dxJXJbLzq9Nah1LUdsj4QTuQ3JoDScd0wp1YHY64NXM=; b=OmrHespWDzY6qVlTooO5OeAKAIqe5Z3xsD3xIeUBG4PhO25rJU/3mZG1xiXEX13ytL j2YIkrScedw84Mo/giYIqYp1h1eTdySmSgQCK8EyMakZ1JOhP5FmbnAmasVUvs91xE2N 4J3fkOuO3M97cFEArYeV/QZtNzdjODjNZVWQIv0wWG70YVg1dGVCgIiTNgKECF8OeWDP 68IMeogRClLW3cN9Z3Xy/LwtnPbljbO8ygotL7ykOBNzCrYasCtaFIX00yaGTY6GGTF5 v+YUjFz0GTNMdyvr5PVZvOKt20l/d7TyYne0Irmek0uPKdPA/RTKE9Ltk/IOM8RI5iI3 utng==; 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=1777103053; x=1777707853; darn=lists.postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=HqtCStu8X45ozzDKhvHR8R7yy2NKEws+yIXStmYodCE=; b=KviA7dpAcp7ivxu+q5cNe86p/MWk7SN3UzX1o54R50MiWqcWpRhJdQNjlhDP7SeERY XYgLuEEALPv+KZ3n1wyE2DqjDsYO7G+TeSEos1v40a+wMZSwyj6Jph2Pdub2xgJeAGj5 LbP3+3JBr1HDKe1+wmrNw6zJ6+hfVumfZtfxaEuiB3wkm6HW8De0clIdIJmo3k3i5mdk PgV+wJjTqIvNMsxsywgL3+rJCutwaWDMiSobQHyoJbqt/Ve08Dy9yLYol4vwKkd11K6B sCY3CkQZ6lwxCrEiGyVR70GGPvHII7IqEUsFYyWDrV6FydgK6qMiiuXs/hbbogoCYrBS 3Kmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777103053; x=1777707853; h=to:subject:message-id:date:from:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=HqtCStu8X45ozzDKhvHR8R7yy2NKEws+yIXStmYodCE=; b=Y2SO75dPKWUi4VHMgobmFa7xuvHiZYjH/G/NOQQfy8P3vTpmTblxnZgKKakIbvujLX a2/pjQeUx3N+zKYoCd37exEZhZrV1qM4l19+xGQW9lx57cpxkUZiu3ejxPwC7MrnwViu KSCeNuCcxpZ32LP0y20WruLoTd2KHl8KDutAM0WNDWKSnGE7MQSicOj49jo786i2ms2o kY7S4v1SssME/yIlUfhqY82yq4nJwjPkxAkglXS9TegRs9zaFoAOCVVi0LcYrdD0if08 vbYyqyeTAWMGsn2M5KmsorfhLApXMCHV5zY3S2jGZLZhz3Mvp2OVAfPL4Q2C/4Hd8qlS RAtQ== X-Gm-Message-State: AOJu0YwKuwJCbLJul3QQqhePXPaIpuqprcay6PHoLSkRbOU2giOotv6Q 3MCqzGI1MV/avT2PF7CcZO+LaxVojDuAuyXOPKKbYx8UggdHi6jUuompMkdXB8W8O8Q2ibungLh vKmn0MTfTwTEQ1GqgGS4UGYScgq5RPoVdUQ2+ X-Gm-Gg: AeBDietG01vKtnKpuSHCIYXKzsU0URWSulko1IiNXvL6yRd40VoM7fn4UgcxMy/1Bbs igWVwJE5f/R+qLczbejT5cm5tiPF4AXY+WK4SnXMUqhOr0paP/De3uc8riJGCZwx0v3As+iIi3F axlJFiRm5axxND+m7Hac510woE1VbV9j6bEy9JEIVGEGXwTQqBgicWmlnDLzk5B3YYIjY0ZXXjR 98hz2KIl+FfORi2AerY6SzIJpg9qlHitpx4ociLwJgcs1G5jxVbwyqIsXfwKXFASNLnxiwRpYvo NUuPbsAjCi2eIPIodsEcwBB55P8K X-Received: by 2002:a05:6102:c93:b0:5ff:efdc:e225 with SMTP id ada2fe7eead31-616f53a7d34mr16860927137.3.1777103052920; Sat, 25 Apr 2026 00:44:12 -0700 (PDT) MIME-Version: 1.0 From: SATYANARAYANA NARLAPURAM Date: Sat, 25 Apr 2026 00:44:01 -0700 X-Gm-Features: AQROBzASk_eIN3QsZBZ1wvMl6gBRAd83NC1KnyfZySaRDZMKtZDbyZ9sDNXioFU Message-ID: Subject: Discarded adjust_relid_set() return values in remove_self_join_rel To: PostgreSQL Hackers Content-Type: multipart/mixed; boundary="00000000000032fff70650440c42" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000032fff70650440c42 Content-Type: multipart/alternative; boundary="00000000000032fff50650440c40" --00000000000032fff50650440c40 Content-Type: text/plain; charset="UTF-8" Hi hackers, I found that remove_self_join_rel() in analyzejoins.c discards the return values of two adjust_relid_set() calls when updating root->all_result_relids and root->leaf_result_relids: adjust_relid_set(root->all_result_relids, toRemove->relid, toKeep->relid); adjust_relid_set(root->leaf_result_relids, toRemove->relid, toKeep->relid); adjust_relid_set() does not modify its input in-place. When it finds the old relid in the set, it calls bms_copy() to create a new Bitmapset, performs the substitution on the copy, and returns the new pointer. Without capturing the return value, the original sets are never updated. Every other call site in the file analyzejoins.c correctly assigns the return value. I am not able to craft a query to show it as a problem. For the current release, these two lines appears to be a no-op? Attached a patch to assign the returned values. Thanks, Satya --00000000000032fff50650440c40 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi hackers,

I found that remove_self_join_rel() in = analyzejoins.c discards the
return values of two adjust_relid_set() call= s when updating
root->all_result_relids and root->leaf_result_reli= ds:

=C2=A0 =C2=A0 adjust_relid_set(root->all_result_relids, toRem= ove->relid, toKeep->relid);
=C2=A0 =C2=A0 adjust_relid_set(root-&g= t;leaf_result_relids, toRemove->relid, toKeep->relid);

adjust_= relid_set() does not modify its input in-place.=C2=A0 When it finds
the = old relid in the set, it calls bms_copy() to create a new
Bitmapset, per= forms the substitution on the copy, and returns the new
pointer.=C2=A0 W= ithout capturing the return value, the original sets are
never updated. = Every other call site in the file =C2=A0analyzejoins.c correctly
assigns= the return value.

I am not able to craft a query to show it as a pr= oblem.
For the current release, these two lines appears to be a no-op?
Attached a patch to assign the returned values.

Thanks,
Sat= ya
--00000000000032fff50650440c40-- --00000000000032fff70650440c42 Content-Type: application/octet-stream; name="0001-Fix-discarded-adjust_relid_set-return-values-in-SJE.patch" Content-Disposition: attachment; filename="0001-Fix-discarded-adjust_relid_set-return-values-in-SJE.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_moe18h5e0 RnJvbSAyMTFjYWY0ZDYwNDhjMzMyYjYxMzAyMmNiOTY4Y2RjZDA1ZjVjNTAzIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBTYXR5YSBOYXJsYXB1cmFtIDxzYXR5YW5hcmxhcHVyYW1AZ21h aWwuY29tPgpEYXRlOiBTYXQsIDI1IEFwciAyMDI2IDA3OjMwOjEzICswMDAwClN1YmplY3Q6IFtQ QVRDSF0gRml4IGRpc2NhcmRlZCBhZGp1c3RfcmVsaWRfc2V0KCkgcmV0dXJuIHZhbHVlcyBpbiBT SkUKCnJlbW92ZV9zZWxmX2pvaW5fcmVsKCkgY2FsbHMgYWRqdXN0X3JlbGlkX3NldCgpIHRvIHVw ZGF0ZQpyb290LT5hbGxfcmVzdWx0X3JlbGlkcyBhbmQgcm9vdC0+bGVhZl9yZXN1bHRfcmVsaWRz IGFmdGVyCmVsaW1pbmF0aW5nIGEgc2VsZi1qb2luZWQgcmVsYXRpb24sIGJ1dCBkaXNjYXJkcyB0 aGUgcmV0dXJuIHZhbHVlcy4KCmFkanVzdF9yZWxpZF9zZXQoKSBhbGxvY2F0ZXMgYSBuZXcgQml0 bWFwc2V0IHZpYSBibXNfY29weSgpIHdoZW4KaXQgZmluZHMgdGhlIG9sZC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