Reject invalid databases in pg_get_database_ddl()

Lakshmi N <lakshmin.jhs@gmail.com>

From: Lakshmi N <lakshmin.jhs@gmail.com>
To: "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>
Cc: andrew@dunslane.net
Date: 2026-04-16T08:19:44Z
Lists: pgsql-hackers

Attachments

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

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Reject invalid databases in pg_get_database_ddl()