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 1w7NcL-005FZO-2H for pgsql-hackers@arkaria.postgresql.org; Tue, 31 Mar 2026 01:10:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w7NcJ-007UjM-2t for pgsql-hackers@arkaria.postgresql.org; Tue, 31 Mar 2026 01:10:04 +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 1w7NcJ-007UjE-1y for pgsql-hackers@lists.postgresql.org; Tue, 31 Mar 2026 01:10:04 +0000 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w7NcI-00000001tRO-1OHg for pgsql-hackers@lists.postgresql.org; Tue, 31 Mar 2026 01:10:03 +0000 Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-66ad907833dso8901774a12.3 for ; Mon, 30 Mar 2026 18:10:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1774919400; cv=none; d=google.com; s=arc-20240605; b=jlKjNoEo4MwU64VK4yFYVs878FIjJ+dL4gEPTZwJrOysV1nhgs0FwJA00gVbBo0zEV GmdvCO3hRHglxllMSw//+GpYkdctENmaDgvwgjQIzi1e/eX5Pi9eCX9JmpRB92eqZQIW lYAwnVlTD9F3C1RD+jVeD2Wk7vq5HX0MkNW2dK5KvAmIbxYqYdlxMoKldap4lupW2T0s WQWecbY7/u/PPUanQOgMgjlK2lqaJtjBQipKpPYH790wsfwlO5//yvfsi5kTCrwIpDWO utnfC5yWa7Wg+aJJe2HVyHsYXiTSrTLVBpZf62k1PY2Foqh1p1Lh5f4mBlAF9tgCFqcu gWxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=DNLPStMsfsb7JwZR+32L6lZCgThofYF1G63sV/KftN4=; fh=W5mc2JOAGCvt13BJ0us3SdyyTqlnx5XZuh300oYiJds=; b=L/qo+9npQ99LC8Ahvdqd01u1vd8VjYrQ48vEYR6zF7QANeIJ9uad9EPf3VpbiJ5dG/ Cnhyu+gdkG91s+DkeZ3OFQAbXVOh+8arx8UztLQdSCsHgmh58ouaiV1vaGMuwatI0Nrf Vo8EMVbTV/OZHP95E11C4RUF9XDJsL+FCDPs/Uw/CHmkdx+sV0posBox5yuJrM5eROJ2 eFp6MXNnyAu1f9H0/SJBwKwHlb6K1NQJbK0VjeNdMJo8GSDGy9H7MRrV/1FOP0fXTtkS 1YE2P3ZdZMtiiux/6DCe1PcwxnWi182hZBxbLoAAGfcW/iFCY93TpBEfwWZe8CboOejf WUSw==; 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=1774919400; x=1775524200; 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=DNLPStMsfsb7JwZR+32L6lZCgThofYF1G63sV/KftN4=; b=jfnFUH8YDnl2OLbatPmIizljWEHyTRJ/8LZ8Hor5aWohS8NfcikFhMHDjJAsRuWF+q Bwh8ErmNPmwBWwmdxtNOLk6kEKylliQAbDyrkncyUEpEbSRFm38v5oGdhcgyhk4IBwuD XQTYNJlzOPwYjUGEqo3gxGZOmIaXBYR7gqdEnA3MH53UuGNUT/d5W1PSkguutITCQeoD EK07zUDBVTQoY2uG+WUwMc8mPQOgUPbd27djzqtyvqclySVwtjX7yermoVjx5zbSIl3h AfTPfUK7VicBuM6XI7rQXBx7CRIDbBecON+FvizdWGyhdDO22PRH3uQg3HgApVvcevKN KJEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774919400; x=1775524200; 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=DNLPStMsfsb7JwZR+32L6lZCgThofYF1G63sV/KftN4=; b=hN2E/bmH8n2LYf2Lk8rc+ONzHtux9UbMTkd5aoeyHNHdTG9PFXMvVqZavmaZfpCGZO ZRxo/G5GHmvHshCWxhzdepJvy5EFdPs/NlBCZTHUpmbFyiUmPgPEIqSJDz3k2WtxlFTT tBXX46JfLTQkJ+HG1BZL3sWTRq0Tr2yLzSSdLRRgGkNon6+te1pQrAZu9ATICkfaqLnd 09WgKxdyNdk/5zt1GHZjd87G8B7ILzqLqGFIR8zS9ceSrTWw9l1baWZD/NEAg8mqg0P2 mYmBU/c3m4/HyXNySsqIMSvnoGRP65/TCUu2nIpcfkrifXNnSn0BTwTPR73/O7kvuloW xJ3A== X-Forwarded-Encrypted: i=1; AJvYcCUqfN4ew8NQSzqMC/rGbicknk3vJngO4Po1uwRvJ+CT8S201HvU1bV4vx61ZsOxumzKBjIRDDW3iMibgn38@lists.postgresql.org X-Gm-Message-State: AOJu0YyH7J9yDXYukXhoR5/SuXVnMUcOz/0a1K+YZ/9ubeAxz7PTd3xg QE07IhJt7F6YWSSojInbyF+pLFxtW6HA3buRsvkwFXqL7IGuyqRbJGnDC0lcYgMfI8BdHT/NAxk uNshrVINjj8sfTlTkoUFQH5cM09jI6oQ= X-Gm-Gg: ATEYQzzHwImKrvqIZb9c2w/TftDbWgMPPbosJkXQCdBzAny0lRuTevEYUcQV3Q7ANyO 39nPP6OZPLeM8pK3ZRszinvXIYygTsRPgbxNX7elCK7pWQJTBvi3JZ5fSdoCWAoJvIDWGRzbNaE 2TUTdO/Fsy9rT1ldpzrEP6sANX1uqSA/y1dwJaiws9FvLoPWoA3zL/0KQ1QbSAtBSxdli385VBK SiOtvSkHwO4WsKtiGfmTI/syIKgZ+5RVKcvojZVRL382T5pBmVvnTJUS2JhQ9mt0m7+N3j0wlm5 pavjwM780YktsEvfyxDl3QjjsZKmY809oUIVNGVeE6TwqsO8/sqZ/zci3yeXcz+//sFD9sgSwqY GIEpuYkc0 X-Received: by 2002:a05:6402:51c6:b0:66c:9d2:b208 with SMTP id 4fb4d7f45d1cf-66c09d2b3f6mr1910100a12.25.1774919399428; Mon, 30 Mar 2026 18:09:59 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Xuneng Zhou Date: Tue, 31 Mar 2026 09:09:47 +0800 X-Gm-Features: AQROBzAXjxzJJN9wRxVAmfjIWFFzrDEK73OrEaxeyqhYDm1qc_tmJPAXqusaCtk Message-ID: Subject: Re: heapam_tuple_complete_speculative : remove unnecessary tuple fetch To: Japin Li Cc: Chao Li , PostgreSQL Hackers 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 Tue, Mar 24, 2026 at 8:16=E2=80=AFPM Japin Li wrot= e: > > > > =E5=9C=A8 2026=E5=B9=B43=E6=9C=8824=E6=97=A5=EF=BC=8C14:57=EF=BC=8CChao= Li =E5=86=99=E9=81=93=EF=BC=9A > > > > =EF=BB=BFHi, > > > > While reviewing another patch, I noticed this: > > ``` > > static void > > heapam_tuple_complete_speculative(Relation relation, TupleTableSlot *sl= ot, > > uint32 specToken, bool succeeded) > > { > > bool shouldFree =3D true; > > HeapTuple tuple =3D ExecFetchSlotHeapTuple(slot, true, &shouldFre= e); // <=3D=3D tuple is not used > > > > /* adjust the tuple's state accordingly */ > > if (succeeded) > > heap_finish_speculative(relation, &slot->tts_tid); > > else > > heap_abort_speculative(relation, &slot->tts_tid); > > > > if (shouldFree) > > pfree(tuple); > > } > > ``` > > > > In this function, tuple is not used at all, so there seems to be no nee= d to fetch it, and shouldFree is thus not needed either. > > > > This appears to have been there since 5db6df0c011, where the function w= as introduced. It looks like a copy-pasto from the previous function, heapa= m_tuple_insert_speculative(), which does need to fetch and possibly free th= e tuple. > > > > I tried simply removing ExecFetchSlotHeapTuple(), and "make check" stil= l passes. But I may be missing something, so I=E2=80=99d like to confirm. > > > > The attached patch just removes the unused tuple and shouldFree from th= is function. As touching the file, I also fixed a typo in the file header c= omment. > > Makes sense! All test cases passed with make check-world. > +1, looks like a simple copy-pasto and the patch LGTM. --=20 Best, Xuneng