pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: lukas.eder@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #19063: Heavily nesting trivial ROW projections produces out of memory error
Date: Wed, 24 Sep 2025 14:43:29 -0400
Message-ID: <3455128.1758739409@sss.pgh.pa.us> (raw)
In-Reply-To: <19063-c1ba39b11b9d43b7@postgresql.org>
References: <19063-c1ba39b11b9d43b7@postgresql.org>

PG Bug reporting form <noreply@postgresql.org> writes:
> I don't understand how such excessive memory consumption is produced by such
> a "simple" query.

Compare

regression=# select row(row(1));
   row   
---------
 ("(1)")
(1 row)


regression=# select row(row(row(1)));
      row      
---------------
 ("(""(1)"")")
(1 row)

regression=# select row(row(row(row(1))));
           row           
-------------------------
 ("(""(""""(1)"""")"")")
(1 row)

Each layer of ROW() has to quote the string representing the next
lower layer, so it doubles all the double-quotes per the quoting
rules at

https://www.postgresql.org/docs/current/rowtypes.html#ROWTYPES-IO-SYNTAX

So the output length nearly doubles for each layer of ROW(), and yes
it doesn't take that many layers to get to something excessive.

Maybe we could redefine the quoting rules in a way that's friendlier
to this sort of thing, but it would surely make them a lot more
complicated, which would likely introduce enough client-side bugs
to make the change unattractive.  Not to mention the whole backwards
compatibility question.

On the whole I can't get excited about this, since I see no very
good reason to use such a data structure.

			regards, tom lane





view thread (3+ messages)  latest in thread

Message-ID: <3455128.1758739409@sss.pgh.pa.us>
Permalink:  ../3455128.1758739409@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3455128.1758739409@sss.pgh.pa.us

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, lukas.eder@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #19063: Heavily nesting trivial ROW projections produces out of memory error
  In-Reply-To: <3455128.1758739409@sss.pgh.pa.us>

* 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