Re: [PATCH] Fix NULL dereference in pg_get_database_ddl()

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCH] Fix NULL dereference in pg_get_database_ddl()
Date: 2026-04-13 09:32:32
Message-ID: CAApHDvrJEM-qSm2rRJdowYtpss9xbmfRPRfOrEG0j01y1CkSNg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, 11 Apr 2026 at 01:58, Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com> wrote:
> Deterministic reproduction:
>
> CREATE DATABASE regression_testdb;
> SET allow_system_table_mods = on;
> UPDATE pg_database
> SET dattablespace = 99999
> WHERE datname = 'regression_testdb';
> RESET allow_system_table_mods;
>
> SELECT * FROM pg_get_database_ddl('regression_testdb');
>
> The attached patch fixes this by checking for NULL before calling
> pg_strcasecmp(). In that case, pg_get_database_ddl() simply omits the
> TABLESPACE clause.

Can you explain why this method of self-inflicted catalogue corruption
is any more important than any of the just-about-infinite other ways
there are of causing issues by manually updating the catalogue tables?

The typical response to this sort of thing can be seen in the thread
in [1], in particular, the response in [2].

David

[1] https://www.postgresql.org/message-id/19383-e6b60ec2a4fce5b0@postgresql.org
[2] https://www.postgresql.org/message-id/1538113.1768921841%40sss.pgh.pa.us

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2026-04-13 09:41:02 Re: Reduce build times of pg_trgm GIN indexes
Previous Message Chao Li 2026-04-13 09:28:51 Re: quoteOneName() inconsistency with quote_all_identifiers — replacement API proposed