pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: jian he <jian.universality@gmail.com>
Cc: Pg Hackers <pgsql-hackers@lists.postgresql.org>
Cc: Tender Wang <tndrwang@gmail.com>
Subject: Re: not null constraints, again
Date: Tue, 12 Nov 2024 11:43:38 +0100
Message-ID: <202411121043.kselx23nuhri@alvherre.pgsql> (raw)
In-Reply-To: <202411091229.k6wy32lley63@alvherre.pgsql>

On 2024-Nov-09, Alvaro Herrera wrote:

> I notice I cargo-culted a "free de-toasted copy", but I think it's
> impossible to end up with a toasted datum here, because the column is
> guaranteed to have only one element, so not a candidate for toasting.
> But also, if we don't free it (in case somebody does an UPDATE to the
> catalog with a large array), nothing happens, because memory is going to
> be released soon anyway, by the error that results by conkey not being
> one element long.

I found out that my claim that it's impossible to have a detoasted datum
was false: because the value is so small, we end up with a short
varlena, which does use a separate palloc().  I decided to remove the
pfree() anyway, because that makes it easier to return the value we want
without having to first assign it away from the chunk we'd pfree.
The DDL code mostly doesn't worry too much about memory leaks anyway,
and this one is very small.

-- 
Álvaro Herrera         PostgreSQL Developer  —  https://www.EnterpriseDB.com/
“Cuando no hay humildad las personas se degradan” (A. Christie)





view thread (89+ messages)  latest in thread

Message-ID: <202411121043.kselx23nuhri@alvherre.pgsql>
Permalink:  ../202411121043.kselx23nuhri@alvherre.pgsql/
Also on:    postgresql.org/message-id/202411121043.kselx23nuhri@alvherre.pgsql

 · 

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-hackers@postgresql.org
  Cc: alvherre@alvh.no-ip.org, tgl@sss.pgh.pa.us, jian.universality@gmail.com, pgsql-hackers@lists.postgresql.org, tndrwang@gmail.com
  Subject: Re: not null constraints, again
  In-Reply-To: <202411121043.kselx23nuhri@alvherre.pgsql>

* 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