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 1wDBec-002gpZ-29 for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Apr 2026 01:36:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wDBeb-0037e2-1L for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Apr 2026 01:36:25 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wDBeb-0037du-0O for pgsql-hackers@lists.postgresql.org; Thu, 16 Apr 2026 01:36:25 +0000 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wDBeX-00000001KGq-2led for pgsql-hackers@lists.postgresql.org; Thu, 16 Apr 2026 01:36:23 +0000 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-82cebbdbdccso74133b3a.1 for ; Wed, 15 Apr 2026 18:36:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776303379; x=1776908179; darn=lists.postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=1KRDImH4RQN0la12YEFJLEzwi4z2Ib5YRflpBul+7Ic=; b=UldkJo4mk+7iW3MYUVJJJGmOTpezU+ucsDyhZ+xMlKrcp4Gnh4DLUe6orVr8XfdNXf l1nxOjReUeIxcmFwAu0qFmSZM3JYaI+SGEQHrC6/vbADedBC0uO2yJOLRTGYJ37pmA+a GwRFZcEQE2e3obyzvmYwpmH/CMssvQO1oEtf2lWyC0xnWkadh02gxqaKWDVycpHsFAtf OT1qp4PTKctgePHRhN6zf3zI7o5JiLNTb5No0TkolBm1ze0nNiggp11jvXgE+F0vIywg FFWYrzPCnDDx0x+pYfMhLsZn2/eQ43OETACvm2h4hEjXzTmbsOURMbRm7d09j4gRbk9s YCJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776303379; x=1776908179; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=1KRDImH4RQN0la12YEFJLEzwi4z2Ib5YRflpBul+7Ic=; b=tVRH60/cWR5rNose/C80Rfmj58/mCyoo0DUWvFmNIYtb6RUK6p0mRNoi8hN+EEXbZc HUVZy1CNaXwuoaBmk2FZkN05SCqjehU4D64Utu4f0FY5jEP1Ye23MNa7VuxvhkPxJR0l FEVkTE0T4D+9DGA5AeWrfibOTmYQYed2CwV208wO0pYUx4U2WsdOh5kUg9NsybApWvJk 5eyquifumFDOTaMNoQ82xp4WAnLqHSuNU13v7rd3R+08C849bPTsGOwYAtLikLxYGSCB ud+yd5NYxpDqNpjn+GcR0KvGzZpLxdqj55sXpdNTZYc2YcYkHyieCU8AlYaPCz7JReHl Kjfg== X-Forwarded-Encrypted: i=1; AFNElJ+tO2hP8XZwoZPkF3nPjRInVrLgc6nRjRUe22JiakK7GhOr1+9RmHoZBH5bLjhnvuPtVsnN7moEC4PsKn33@lists.postgresql.org X-Gm-Message-State: AOJu0YzLdM6XrerHYlqBu4C+Dxs5LFk1ndAc5CL6Sw3XZDv2++ZZHVy8 +lrpGTvbqug9gGmkTCZ7frwD0QMb/JhRpsxMaZ7yQ0DzIWjP+E+KqPSc X-Gm-Gg: AeBDieta1xNjq2QiShY8L8I/WRDxNghqICvR+TjpRbWC+BCv0+L5PdSfDFldpPIopmy XvFB3khALpvrW16yT6tjtmTFkFEywQZgEcE8/h93reF3ZlbmF0Um+6QSjl5IW42jWGNlKEFi62a GDtA3neJCsN+Nrs1ht+B2tlPGqfupuiV947Zkr9qEeUutCA9EuFiUfKb1UJ4ZLdsvlNB2C3Qy1m KyYcgVIKQMUGFGGT/OAOr+p2bYFCkr+K12Fb6nT/rvweIpOndloxU9Lx7wspK2KpLo5IRgy0Yr3 Lnys+YfAXbbw3T5Luvtnp1E3cedqMOixzpC4WkT+fXPyXD7R0HsULlINr0ZhgV40eHlPcm0Jx2D f1FDJRaPviJFd1m9Ji6o/NFRw5BlSvpQ0B2iqM7tY8nza3N2g0LANwVWUBN+t2ZRenym6v6rpJv WQ7mHS7g1+FecABlJuN1MijXXSjQ1Hlqo= X-Received: by 2002:a05:6a00:14c8:b0:81f:544b:3998 with SMTP id d2e1a72fcca58-82f7652a47cmr1233520b3a.26.1776303379085; Wed, 15 Apr 2026 18:36:19 -0700 (PDT) Received: from smtpclient.apple ([45.32.121.103]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82f673e1711sm4174830b3a.28.2026.04.15.18.36.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Apr 2026 18:36:18 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.400.21\)) Subject: Re: Fix a server crash problem from pg_get_database_ddl From: Chao Li In-Reply-To: Date: Thu, 16 Apr 2026 09:35:39 +0800 Cc: Jack Bonatakis , pgsql-hackers@lists.postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: <634F4A5D-9D38-4F9D-BC1C-70815CBB5089@gmail.com> References: <573E45C1-31A4-4885-A00C-1A2171159A2A@gmail.com> <28b82ab2-5721-4e7c-bf71-979c3f198a2e@app.fastmail.com> To: Japin Li X-Mailer: Apple Mail (2.3864.400.21) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Apr 16, 2026, at 09:23, Japin Li wrote: >=20 > On Wed, 15 Apr 2026 at 20:44, "Jack Bonatakis" = wrote: >> I have reproduced this error against the current master: >>=20 >> ``` >> CREATE TABLESPACE ts1 LOCATION '/workspace/tablespaces/pg_bug_ts1'; >> CREATE DATABASE db1 TABLESPACE ts1; >> DELETE FROM pg_tablespace WHERE spcname =3D 'ts1'; >> SELECT * FROM pg_get_database_ddl('db1'::regdatabase); >>=20 >> 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: >>=20 >> ``` >> [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: >>=20 >> ``` >> 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: >>=20 >> ``` >> [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. >>=20 >> 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.=20 >>=20 >> Jack >=20 > This seems similar to [1]. Could you please confirm? >=20 > [1] = https://www.postgresql.org/message-id/CAJTYsWXcd324VELk%3D9KdsfTsua9So3Yex= qv7N3B23h9zAUD40g%40mail.gmail.com. >=20 > --=20 > Regards, > Japin Li > ChengDu WenWu Information Technology Co., Ltd. >=20 >=20 Thanks for printing out that. Yes, they are similar. I agree with what Tom said in [2]: ``` This is not a bug. This is a superuser intentionally breaking the system by corrupting the catalogs. There are any number of ways to cause trouble with ill-advised manual updates to a catalog table. Try, eg, "DELETE FROM pg_proc" (... but not in a database you care about). ``` So, let me take back this patch. [2] = https://www.postgresql.org/message-id/1538113.1768921841@sss.pgh.pa.us Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/