Reject invalid databases in pg_get_database_ddl()

From: Lakshmi N <lakshmin(dot)jhs(at)gmail(dot)com>
To: "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: andrew(at)dunslane(dot)net
Subject: Reject invalid databases in pg_get_database_ddl()
Date: 2026-04-16 08:19:44
Message-ID: CA+3i_M8m1k2gFch+tU0JmAQh9FRV+pFrfTXDrJo+BqmwsTmOhg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

pg_get_database_ddl() is not checking for databases in an invalid state
before producing ddl statements. This caused the function to emit
CONNECTION_LIMIT = -2, which is invalid SQL that Postgres rejects.
A database row can be in this inconsistent state longer, for example
server crashed during a drop database.

Attached patch to fix this issue by doing a database_is_invalid_form()
check early in pg_get_database_ddl_internal().

Regards,
Lakshmi

Attachment Content-Type Size
0001-Reject-pg_get_database_ddl-for-invalid-databases.patch application/octet-stream 929 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jakub Wartak 2026-04-16 08:34:58 Re: Add errdetail() with PID and UID about source of termination signal
Previous Message Peter Eisentraut 2026-04-16 08:07:35 Re: Make copyObject work in C++