Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wDAqx-002g44-17 for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Apr 2026 00:45:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wDAqv-002xes-0G for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Apr 2026 00:45:05 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wDAqu-002xej-0l for pgsql-hackers@lists.postgresql.org; Thu, 16 Apr 2026 00:45:04 +0000 Received: from fout-a7-smtp.messagingengine.com ([103.168.172.150]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wDAqq-00000001EV8-2biw for pgsql-hackers@lists.postgresql.org; Thu, 16 Apr 2026 00:45:02 +0000 Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfout.phl.internal (Postfix) with ESMTP id 9DD80EC00BF for ; Wed, 15 Apr 2026 20:44:58 -0400 (EDT) Received: from phl-imap-17 ([10.202.2.105]) by phl-compute-03.internal (MEProxy); Wed, 15 Apr 2026 20:44:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bonatak.is; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1776300298; x=1776386698; bh=hSk8ecQ8Bo jkk85NR9yrVZ5tEWfZ7cPnp8KrV0L+G74=; b=KpyyITkB2AsdMDrjYaByeOoltg 5W6+JcumLrbiBT+Cjev5wAqDfxpgehBpjN7TC7fgYSTq8mj5skIOXrSE71T3l2L7 udkyQyE887repuc5seDLH8+G0hRNj+qoIxZd3OAtOn9Jep8zw9Al++yAMC5V+H4i wGkLGGyr8hjZOpHasJs9MTMt436fEmeb8qWVCuWKYa71YlQ87mrZFtdcoDX6pUOz TcschAGZ0ri+C/EIPyUkLWcn+B1i7YqAxelxcY3ujQDqBIsZHT0ejbaXHIDuHr/6 MlG12sZ6ybnnQFgF5vElyfFHgHb1+Wa9CAynYrXtGNMJMdERlLIP+tXiGZdg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1776300298; x=1776386698; bh=hSk8ecQ8Bojkk85NR9yrVZ5tEWfZ7cPnp8K rV0L+G74=; b=Wvr+fpA7yvQcsc6Wlz4bn0k+3n00ArS088xRhPJdc7vrCImE/mu VWZkm3cuGSFDvusJ0ZR3sPpjfbp1VFsaQoSGvcuTk1gyHEHJSlNhtsGI7bhs0ZT+ JM5hJnmLNOAQmPun9mC4mCMFKbTJeU8srLVg7MLYg05GARZR0Msry9+eC8s7dV5n LPJ/8JgdtE9Cy2jIOclqPDtKRujtGgWZJXeqcwjn3puLj1dV/kjg+ulQoPDXoXTZ /uvddF6YLyslOTsdEGBTmdAUOJ8DZKvSUBRKU6LQPf9r2HVI/T9xLRF+5hJ5ON7G OKmuNQh0xs42+tgcuk6GRjt7Mju/nCbyEyQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdegheehkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhepofggfffhvffkjghfufgtsegrtderreertd dtnecuhfhrohhmpedflfgrtghkuceuohhnrghtrghkihhsfdcuoehjrggtkhessghonhgr thgrkhdrihhsqeenucggtffrrghtthgvrhhnpeetgeefieeiffehgedtgfdufedtgfethe eludetudelgeeifeetleefffejveejvdenucevlhhushhtvghrufhiiigvpedtnecurfgr rhgrmhepmhgrihhlfhhrohhmpehjrggtkhessghonhgrthgrkhdrihhspdhnsggprhgtph htthhopedupdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehpghhsqhhlqdhhrggt khgvrhhssehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: iecce486f:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 3F556C40077; Wed, 15 Apr 2026 20:44:58 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface MIME-Version: 1.0 X-ThreadId: A-hOiqNJyDGc Date: Wed, 15 Apr 2026 20:44:38 -0400 From: "Jack Bonatakis" To: pgsql-hackers@lists.postgresql.org Message-Id: <28b82ab2-5721-4e7c-bf71-979c3f198a2e@app.fastmail.com> In-Reply-To: <573E45C1-31A4-4885-A00C-1A2171159A2A@gmail.com> References: <573E45C1-31A4-4885-A00C-1A2171159A2A@gmail.com> Subject: Re: Fix a server crash problem from pg_get_database_ddl Content-Type: multipart/alternative; boundary=bf67c97b0ae7b25bc7d0be880e97593e4efb553a List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --bf67c97b0ae7b25bc7d0be880e97593e4efb553a Content-Type: text/plain Content-Transfer-Encoding: 7bit I have reproduced this error against the current master: ``` CREATE TABLESPACE ts1 LOCATION '/workspace/tablespaces/pg_bug_ts1'; CREATE DATABASE db1 TABLESPACE ts1; DELETE FROM pg_tablespace WHERE spcname = 'ts1'; SELECT * FROM pg_get_database_ddl('db1'::regdatabase); server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. The connection to the server was lost. Attempting reset: Failed. ``` Backend logs show: ``` [1] LOG: client backend (PID 15420) was terminated by signal 11: Segmentation fault [1] DETAIL: Failed process was running: SELECT * FROM pg_get_database_ddl('db1'::regdatabase); [1] LOG: terminating any other active server processes ``` After applying the patch: ``` SELECT * FROM pg_get_database_ddl('db1'::regdatabase); ERROR: tablespace with OID 16393 does not exist HINT: To recover, try ALTER DATABASE ... SET TABLESPACE ... to a valid tablespace. ``` and backend logs show: ``` [56] ERROR: tablespace with OID 16393 does not exist [56] HINT: To recover, try ALTER DATABASE ... SET TABLESPACE ... to a valid tablespace. [56] STATEMENT: SELECT * FROM pg_get_database_ddl('db1'::regdatabase); ``` All tests pass. The only note I'd have on the code change is that there is no accompanying test. It seems like a TAP test would be reasonable, but I am quite new and will defer to whether you think that's the right call or even necessary. Jack --bf67c97b0ae7b25bc7d0be880e97593e4efb553a Content-Type: text/html Content-Transfer-Encoding: quoted-printable
I have repro= duced this error against the current master:

``= `
CREATE TABLESPACE ts1 LOCATION '/workspace/tablespaces/pg_bu= g_ts1';
CREATE DATABASE db1 TABLESPACE ts1;
= DELETE FROM pg_tablespace WHERE spcname =3D 'ts1';
SELECT = * FROM pg_get_database_ddl('db1'::regdatabase);

server closed the connection unexpectedly
This probably means= the server terminated abnormally
before or while processing t= he request.
The connection to the server was lost. Attempting = reset: Failed.
```
Backend logs show:
=
```
[1] LOG:  client backend (PID 15420) w= as terminated by signal 11: Segmentation fault
[1] DETAIL:=   Failed process was running: SELECT * FROM pg_get_database_ddl('db= 1'::regdatabase);
[1] LOG:  terminating any other act= ive server processes
```
After applying the patc= h:

```
SELECT * FROM pg_get_database_= ddl('db1'::regdatabase);
ERROR:  tablespace with OID 1639= 3 does not exist
HINT:  To recover, try ALTER DATABASE ..= . SET TABLESPACE ... to a valid tablespace.
```
and = backend logs show:

```
[56] ERROR:&nb= sp; tablespace with OID 16393 does not exist
[56] HINT:  = To recover, try ALTER DATABASE ... SET TABLESPACE ... to a valid tablesp= ace.
[56] STATEMENT:  SELECT * FROM pg_get_database_ddl('= db1'::regdatabase);
```
All tests pass.

The only note I'd have on the code change is that there= is no accompanying test. It seems like a TAP test would be reasonable, = but I am quite new and will defer to whether you think that's the right = call or even necessary. 

Jack
= --bf67c97b0ae7b25bc7d0be880e97593e4efb553a--