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

From Alvaro Herrera
Subject Re: [PATCH] Fix memory corruption in pg_shdepend.c
Date
Msg-id 202110201219.e7xgpipp4tve@alvherre.pgsql
Whole thread Raw
In response to Re: [PATCH] Fix memory corruption in pg_shdepend.c  (Michael Paquier <michael@paquier.xyz>)
Responses Re: [PATCH] Fix memory corruption in pg_shdepend.c  (Michael Paquier <michael@paquier.xyz>)
Re: [PATCH] Fix memory corruption in pg_shdepend.c  (Peter Geoghegan <pg@bowt.ie>)
List pgsql-hackers
On 2021-Oct-20, Michael Paquier wrote:

> On Wed, Oct 20, 2021 at 01:01:31PM +0300, Aleksander Alekseev wrote:
> > I checked the rest of the PostgreSQL code and apparently, it should
> > have been tts_values[Anum_pg_shdepend_FOO - 1].
> > 
> > The patch is attached. The problem was first reported offlist by Sven
> > Klemm. Investigated and fixed by me.
> 
> Yes, that's indeed a one-off bug when copying shared dependencies of a
> template database to the new one.  This is new as of e3931d0, so I'll
> take care of that and double-check the area while on.

Ouch ... this means that pg_shdepends contents are broken for databases
created with 14.0?  hmm ... yes.

alvherre=# create role rol;
CREATE ROLE
alvherre=# create table blarg() ;
CREATE TABLE
alvherre=# alter table blarg owner to rol;
ALTER TABLE
alvherre=# create database bar template alvherre;
CREATE DATABASE
alvherre=# \c bar
Ahora está conectado a la base de datos «bar» con el usuario «alvherre».
bar=# select * from pg_shdepend;
 dbid  | classid | objid | objsubid | refclassid | refobjid | deptype 
-------+---------+-------+----------+------------+----------+---------
     0 |       0 |     0 |        0 |       1260 |       10 | p
     0 |       0 |     0 |        0 |       1260 |     6171 | p
     0 |       0 |     0 |        0 |       1260 |     6181 | p
     0 |       0 |     0 |        0 |       1260 |     6182 | p
     0 |       0 |     0 |        0 |       1260 |     3373 | p
     0 |       0 |     0 |        0 |       1260 |     3374 | p
     0 |       0 |     0 |        0 |       1260 |     3375 | p
     0 |       0 |     0 |        0 |       1260 |     3377 | p
     0 |       0 |     0 |        0 |       1260 |     4569 | p
     0 |       0 |     0 |        0 |       1260 |     4570 | p
     0 |       0 |     0 |        0 |       1260 |     4571 | p
     0 |       0 |     0 |        0 |       1260 |     4200 | p
 12975 |    1259 | 37686 |        0 |       1260 |    37685 | o
       |   37689 |  1259 |    37686 |          0 |     1260 | 5
(14 filas)

bar=# select 37689::regclass;
 regclass 
----------
 37689
(1 fila)


-- 
Álvaro Herrera         PostgreSQL Developer  —  https://www.EnterpriseDB.com/



pgsql-hackers by date:

Previous
From: Daniel Gustafsson
Date:
Subject: Re: [PATCH] Prefer getenv("HOME") to find the UNIX home directory
Next
From: Stephen Frost
Date:
Subject: Re: XTS cipher mode for cluster file encryption