Re: [PATCH] Fix NULL dereference in pg_get_database_ddl() - Mailing list pgsql-hackers

From David Rowley
Subject Re: [PATCH] Fix NULL dereference in pg_get_database_ddl()
Date
Msg-id CAApHDvrJEM-qSm2rRJdowYtpss9xbmfRPRfOrEG0j01y1CkSNg@mail.gmail.com
Whole thread Raw
In response to [PATCH] Fix NULL dereference in pg_get_database_ddl()  (Ayush Tiwari <ayushtiwari.slg01@gmail.com>)
Responses Re: [PATCH] Fix NULL dereference in pg_get_database_ddl()
List pgsql-hackers
On Sat, 11 Apr 2026 at 01:58, Ayush Tiwari <ayushtiwari.slg01@gmail.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



pgsql-hackers by date:

Previous
From: Chao Li
Date:
Subject: Re: quoteOneName() inconsistency with quote_all_identifiers — replacement API proposed
Next
From: Peter Eisentraut
Date:
Subject: Re: Reduce build times of pg_trgm GIN indexes