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 1wVWUQ-0021Li-1t for pgsql-bugs@arkaria.postgresql.org; Fri, 05 Jun 2026 15:29:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wVWUP-00D96q-1N for pgsql-bugs@arkaria.postgresql.org; Fri, 05 Jun 2026 15:29:41 +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 1wVWUO-00D96i-2u for pgsql-bugs@lists.postgresql.org; Fri, 05 Jun 2026 15:29:41 +0000 Received: from mail-dl1-x122d.google.com ([2607:f8b0:4864:20::122d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wVWUN-00000001G3w-0ows for pgsql-bugs@lists.postgresql.org; Fri, 05 Jun 2026 15:29:39 +0000 Received: by mail-dl1-x122d.google.com with SMTP id a92af1059eb24-137eed84fc6so5580000c88.0 for ; Fri, 05 Jun 2026 08:29:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1780673378; cv=none; d=google.com; s=arc-20240605; b=BrfwwMlmEByNxSc/kiotStOrLVjSNmVK+NK4665t7oJKAVxLmQyYGV8+rLzycEeFvI qm1iKxd9CaQOLbibFUrPwOpKD7D+yqUhhIziOgWWdGpcsI2/hILK1b3KAICi/aVlbhEz vNG6uPa24S3iDSZxzcrePWGIpt8QoEpvPIGW6IVttApr2b8EYjfHK8gw/3D9Mis8y/tS rNotDh9kgZWJ+GaZwoYeaOy2PGpokwjRW3qNOmx1suz9EusZRbs+JCeiQOTUWI2Dhipw +uHPnsBfKRDaV7lOCFy46/nGi8msVXD1EVxljcxuOCZsBsLATntvVxPfmoKXnbPqMBMQ qj5g== 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=GA7j6K6kK3QnvNqxWusS6ZLnL2ksnWEuXfnwDh8sYn8=; fh=fcy2HgOB7LqrVVI6XNUZjDQ9glxizThply+Y8+i25BQ=; b=V+2IpPsUPkDn372wumOXA2qHD+RfNksNGxDc/DsD8w56tjPfA7i05n2V/ns9YBmJyM yWrDPAnAAUbIcVQ1cC4GMNaErBZLjrfEOXKBG+0fNV6p/GeHOId+Y/Iv/vrV4AcRRIob KMlQ8VMhRbie9KsaDoT+k/IYvjFzmt5KHdN8+pAoFYSb78IYlJDwzSaIbhFfpiKF9w40 Aq9frHWP4ikcDSdHvohTPzclTUAFwIbzE54RO2FlpyRMcM624L3qkmUKTje5RldnAaJJ AvFj3UKR5RUGEcQyCmR9xar3TMXY0EEUdkslXNpCcE9YRSXqO7GiJeVPE+pvgzZQ8of5 r2rA==; 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=1780673378; x=1781278178; 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=GA7j6K6kK3QnvNqxWusS6ZLnL2ksnWEuXfnwDh8sYn8=; b=edvkXKV7aLwiTgq1PWTO1LjOr4MkbdsJ6rqKkZERVoQP7T/Tjh1u4rHHW0pNQM/9bA PeigpYbyYrgLOoUM2Bk6BkYsY9KcSscrKsbMUzEC8Bc+YIBtJ1boR4BjFB/Y8dD2kOlD XCfcMAWkCxWdXQi0LGtXmmAWU7kzP72J8SyncZI5HfrgBKVoYKtTDrG0yHSEr0qN0wEy kGQH0lwWnDCadan+V2TNn2kuBvnikAxDmSygOASFz87fO+5/ftYVI2huYeFp/SGIwnqF hvO7uyes8MZ5jgAIdUzdkm2Q0C9ZPR+bHPZRbZpzqq5V/2BgoaKO8iFIR8y6Z+E8FGw+ oxzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780673378; x=1781278178; 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=GA7j6K6kK3QnvNqxWusS6ZLnL2ksnWEuXfnwDh8sYn8=; b=oC/uaj61/oA5PPV4R6VinlRx1SJ1RdOGijTu2Q8xjx1PtxYN2pyRpaZ5vLfKY+o1Le 0uOQdkDTTr8r1OFX7LD5Y5lbCZnve0+3gsySyZZ6BK7fte+Z0vLBfy5MYfjENZns/NFB f2xLjy1KXXFyuvtLNpCbiPgRc7q1wVgNjfVagagSX9gZcErKLvi8UnICN8mBycyCg7oG lxbDZzgUUBruwX075Etm79aWcZC/7loFSEsSkyr8iKol0yuTyXdKqEvOFzMc9NYUMgMV OxxvRB0b5oB/ghuUvWunitR4c3wDGsknLo9K5BbjUZu/opBWVlrNiC0//BZ+5IYqoRzL cI1g== X-Forwarded-Encrypted: i=1; AFNElJ+8wagmUiRfyitt9wE0GqG9JSc3/8I5620mCJg6Ci91TgSNUCG0PgVCSSRIAUOGdA98du9Q4H2+VsNM@lists.postgresql.org X-Gm-Message-State: AOJu0Yy+QTEzk2JNkny7wgIG9ncmNBfwH3TBf61RsK6TXyXBfG97WF6D MPZmjYxnhl6L+ddwhWuMCKN18gYuvFAWZL8pY9l2u4hUPixFlkr/cE77Na9l8ef/7yTf20iAZlw wLbk0rI/iqhvDZ5h4+FRQ21GCPEWFNOU= X-Gm-Gg: Acq92OFNbXr01f4OMY/CXkvX7DL6DdM5lUDbJ5T7sJQg/T88ge5Jf4bCbJxphIcALv3 ruoRALPNqkxO1K39Xh+2M2xgbKRVZZCUAdUVrOqVCDwKrpLd76RytFe+7bY/qxdxyjXaRwNJWLh QNYqixEE7uHrqSD27lr3M5ldsD09wjmWNaujkVmaFW/nBsfwy/vN9PQTOXKmpsAC+BisCkpwdrS R35kd3Iy1gYYTuvZPiFZRdrk+8vPN2oU8W20hUi6h1OFxYDxaDcp5BMbG4Gt6EwiyiPnR2I4KgL qBqidUMZKl4txPq+0dAwp9A/DiGM/5HLC25nwLnomnZTxi6dM3Q= X-Received: by 2002:a05:7022:390:b0:137:ec47:8ff2 with SMTP id a92af1059eb24-138065c92e9mr1760460c88.0.1780673378073; Fri, 05 Jun 2026 08:29:38 -0700 (PDT) MIME-Version: 1.0 References: <19508-e5f188183279219b@postgresql.org> In-Reply-To: From: Ashutosh Sharma Date: Fri, 5 Jun 2026 20:59:23 +0530 X-Gm-Features: AVHnY4IRd9TT6SJxA50RJ9XPeoB64S90RrsvJNrvcHd6uRRC478dZ6J_A2X09Fk Message-ID: Subject: Re: BUG #19508: pg_buffercache_pages() crashes the backend with an incompatible caller-supplied record definition To: Fujii Masao Cc: n.kalinin@postgrespro.ru, pgsql-bugs@lists.postgresql.org 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 Hi Fujii-san, On Fri, Jun 5, 2026 at 8:49=E2=80=AFAM Fujii Masao = wrote: > > On Fri, Jun 5, 2026 at 12:49=E2=80=AFAM PG Bug reporting form > wrote: > > > > The following bug has been logged on the website: > > > > Bug reference: 19508 > > Logged by: Nikita Kalinin > > Email address: n.kalinin@postgrespro.ru > > PostgreSQL version: 19beta1 > > Operating system: Fedora 44 > > Description: > > > > Hello, > > > > It appears that pg_buffercache_pages() trusts a caller-supplied record > > descriptor without verifying that the declared column types match the a= ctual > > values returned by the function. > > > > The crash is reproducible on the current master branch with a fresh clu= ster > > after installing the extension: > > Thanks for the report! I could reproduce this as well. > > > > git blame points to the following commit: > > > > commit 257c8231bf97a77378f6fedb826b1243f0a41612 (HEAD) > > Author: Heikki Linnakangas > > Date: Tue Apr 7 16:04:48 2026 +0300 > > > > Modernize and optimize pg_buffercache_pages() > > Commit 257c8231bf9 changed pg_buffercache_pages() to materialize rows dir= ectly > into a tuplestore. As a result, the function started using the caller-sup= plied > RECORD descriptor as rsinfo->setDesc, so a mismatched column definition l= ist > could cause tuplestore_putvalues() to interpret returned Datums with inco= rrect > types. > > Before that change, pg_buffercache_pages() exposed its actual tuple descr= iptor > to the executor, allowing the executor's existing rowtype checks to rejec= t > incompatible definitions with a normal error. > > The attached patch restores that behavior while keeping the materialized-= SRF > implementation. Thoughts? > pg_buffercache_pages uses RETURNS SETOF RECORD whereas other extensions like pgstattuple define explicit IN/OUT parameters at the SQL level. Is there a specific reason this pattern was kept, or is it simply a legacy design that hasn't been modernized? Had we followed the IN/OUT parameter style, this sort of issue could have been avoided, no? -- With Regards, Ashutosh Sharma.