Re: not null constraints, again - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: not null constraints, again
Date
Msg-id 202411121043.kselx23nuhri@alvherre.pgsql
Whole thread Raw
In response to Re: not null constraints, again  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
Responses Re: not null constraints, again
List pgsql-hackers
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)



pgsql-hackers by date:

Previous
From: Ashutosh Bapat
Date:
Subject: Re: Add html-serve target to autotools and meson
Next
From: Ashutosh Bapat
Date:
Subject: Re: explain plans for foreign servers