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.94.2) (envelope-from ) id 1uI7Q9-00G42R-Dl for pgsql-hackers@arkaria.postgresql.org; Thu, 22 May 2025 15:01:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uI7Q7-003jyx-Qy for pgsql-hackers@arkaria.postgresql.org; Thu, 22 May 2025 15:01:19 +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.94.2) (envelope-from ) id 1uI7Q7-003jyp-Hd for pgsql-hackers@lists.postgresql.org; Thu, 22 May 2025 15:01:19 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uI7Q4-000MKe-1L for pgsql-hackers@lists.postgresql.org; Thu, 22 May 2025 15:01:18 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 54MF0g7s1516165; Thu, 22 May 2025 11:00:42 -0400 From: Tom Lane To: Jim Jones cc: Peter Smith , Peter Eisentraut , Nikolay Samokhvalov , PostgreSQL Hackers , Andrey Borodin Subject: Re: [PATCH] Add pretty-printed XML output option In-reply-to: <29ec1b21-1113-403c-bd00-b5009d9c4fdb@uni-muenster.de> References: <2f5df461-dad8-6d7d-4568-08e10608a69b@uni-muenster.de> <6cb296fe-4b49-3691-633e-2e2366997b04@uni-muenster.de> <3baf8f25-3bd7-7db5-0b31-e4c92b6269ba@enterprisedb.com> <1cbe1087-6acb-2b0a-dc9b-0a2d5b99e466@uni-muenster.de> <532259.1678393296@sss.pgh.pa.us> <906cfd1d-63a0-3cf5-7291-2dadb2e! 149ff@uni-muenster.de> <803304.1678458776@sss.pgh.pa.us> <2752578.1678815625@sss.pgh.pa.us> <3057762.1678836321@sss.pgh.pa.us> <3622266.1678914816@sss.pgh.pa.us> <1c7cf9f0-14c3-0341-6894! -8ca577bf325e@uni-muenster.de> <1358967.1747858817@sss.pgh.pa.us> <1418827.1747871285@sss.pgh.pa.us> <29ec1b21-1113-403c-bd00-b5009d9c! 4fdb@uni-muenster.de> Comments: In-reply-to Jim Jones message dated "Thu, 22 May 2025 10:42:46 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1516163.1747926042.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 22 May 2025 11:00:42 -0400 Message-ID: <1516164.1747926042@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Jim Jones writes: > On 22.05.25 01:48, Tom Lane wrote: >> ... I considered adding an assertion that that call returns >> NULL, but concluded that it wasn't worth the notational hassle. >> I'm not strongly set on that conclusion, though, if you think >> differently. > I see. In that case I believe that at least a different comment > explaining this decision would avoid confusion. Something like Yeah, after sleeping on it I fear that leaving xml_parse entirely alone will just be a recipe for future copy-and-paste errors. The Assert solution seems like the way to go, approximately xmlNodePtr root; + xmlNodePtr oldroot PG_USED_FOR_ASSERTS_ONLY; ... /* This attaches root to doc, so we need not free it separatel= y. */ - xmlDocSetRootElement(doc, root); + oldroot =3D xmlDocSetRootElement(doc, root); + /* ... and there can't yet be any old root to clean up. */ + Assert(oldroot =3D=3D NULL); I'll make it so. regards, tom lane