Re: [PATCH] Fix memory corruption in pg_shdepend.c - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [PATCH] Fix memory corruption in pg_shdepend.c
Date
Msg-id 2420185.1634831528@sss.pgh.pa.us
Whole thread Raw
In response to Re: [PATCH] Fix memory corruption in pg_shdepend.c  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
Responses Re: [PATCH] Fix memory corruption in pg_shdepend.c
Re: [PATCH] Fix memory corruption in pg_shdepend.c
List pgsql-hackers
Alvaro Herrera <alvherre@alvh.no-ip.org> writes:
> I suppose pg_describe_object can be used on the contents of pg_shdepend
> to detect it.  I'm less sure what to do to correct it -- delete the
> bogus entries and regenerate them with some bulk query?

Seems that what copyTemplateDependencies wants to do can easily be
modeled by a SQL query, assuming you know which DB was cloned to
which other one, and that the source's shdeps didn't change since
then.  However, I'm not sure how we can get rid of existing bogus
entries, especially if we'd like to preserve not-bogus ones
(which very likely have gotten added to the destination DB since
it was created).

On the whole I'm afraid that people messing with this manually are
likely to do more harm than good.  pg_shdepend entries that don't
match any object probably won't cause a problem, and the lack of
protection against untimely dropping a role is unlikely to be much
of an issue for a role you're referencing in a template database.
So I suspect that practical issues will be rare.  We're fortunate
that cloning a nonempty template database is rare already.

BTW, I think there is an additional bug in copyTemplateDependencies:
I do not see it initializing slot->tts_isnull[] anywhere.  It
probably accidentally works (at least in devel builds) because we zero
that memory somewhere else, but surely this code shouldn't assume that?

            regards, tom lane



pgsql-hackers by date:

Previous
From: Japin Li
Date:
Subject: Re: [Bug] Logical Replication failing if the DateStyle is different in Publisher & Subscriber
Next
From: Matthias van de Meent
Date:
Subject: Re: Adding CI to our tree