pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: In transformRowExpr(), check for too many columns in the row.
Date: Fri, 29 Jul 2022 17:31:31 +0000
Message-ID: <E1oHTpi-001oLB-Kz@gemulon.postgresql.org> (raw)

In transformRowExpr(), check for too many columns in the row.

A RowExpr with more than MaxTupleAttributeNumber columns would fail at
execution anyway, since we cannot form a tuple datum with more than that
many columns.  While heap_form_tuple() has a check for too many columns,
it emerges that there are some intermediate bits of code that don't
check and can be driven to failure with sufficiently many columns.
Checking this at parse time seems like the most appropriate place to
install a defense, since we already check SELECT list length there.

While at it, make the SELECT-list-length error use the same errcode
(TOO_MANY_COLUMNS) as heap_form_tuple does, rather than the generic
PROGRAM_LIMIT_EXCEEDED.

Per bug #17561 from Egor Chindyaskin.  The given test case crashes
in all supported branches (and probably a lot further back),
so patch all.

Discussion: https://postgr.es/m/17561-80350151b9ad2ad4@postgresql.org

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/e6a48014df39dcddbbcadb9479c3bcba9d049f44

Modified Files
--------------
src/backend/parser/parse_expr.c | 9 +++++++++
src/backend/parser/parse_node.c | 2 +-
2 files changed, 10 insertions(+), 1 deletion(-)



view thread (7+ messages)  latest in thread

Message-ID: <E1oHTpi-001oLB-Kz@gemulon.postgresql.org>
Permalink:  ../E1oHTpi-001oLB-Kz@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1oHTpi-001oLB-Kz@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: In transformRowExpr(), check for too many columns in the row.
  In-Reply-To: <E1oHTpi-001oLB-Kz@gemulon.postgresql.org>
  References: <E1oHTpi-001oLB-Kz@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox