Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nIDdS-00017I-AX for pgsql-general@arkaria.postgresql.org; Thu, 10 Feb 2022 17:53:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nIDdR-0004hF-7p for pgsql-general@arkaria.postgresql.org; Thu, 10 Feb 2022 17:53:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nIDdQ-0004h6-Tb for pgsql-general@lists.postgresql.org; Thu, 10 Feb 2022 17:53:36 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nIDdO-0005xU-I4 for pgsql-general@postgresql.org; Thu, 10 Feb 2022 17:53:36 +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 21AHrRWC1693387; Thu, 10 Feb 2022 12:53:27 -0500 From: Tom Lane To: Garfield Lewis cc: PostgreSQL mailing lists Subject: Re: Passing XML column in an array In-reply-to: <247353C7-F577-46D7-9EB6-FA4CB8452D5F@lzlabs.com> References: <247353C7-F577-46D7-9EB6-FA4CB8452D5F@lzlabs.com> Comments: In-reply-to Garfield Lewis message dated "Thu, 10 Feb 2022 17:14:09 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1693385.1644515607.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 10 Feb 2022 12:53:27 -0500 Message-ID: <1693386.1644515607@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Garfield Lewis writes: > I am trying to pass an array into a new function I am creating called lz= xmlexists via the following statement: > wdbs=3D# SELECT "XT"."ROWKEY" , "XT"."XMLT1C1" FROM "LZQAAS"."T642_XML_T= 1" "XT" WHERE "ROWKEY"=3D64201 AND lzxmlexists( ' $XTX//DeptName[ . =3D $D= n ]', 'DEFAULT', ARRAY["XT"."XMLT1C1"] ) ORDER BY "ROWKEY"; > The column XT.XMLT1C1 exists because I can do a simple select to see the= contents. The problem is that in the code above I hit the following error= at line 161. > 160 for ( size_t ix =3D 0; ix < iXmlCount; ++ix ) { > (gdb) > 163 xmltype *pX =3D DatumGetXmlP( pXmlData[ix] ); > (gdb) > Program received signal SIGSEGV, Segmentation fault. > 0x00000000008b3514 in pg_detoast_datum () The most obvious theory is that there are some nulls in the XT.XMLT1C1 column. Since your code isn't bothering to check pXmlDataNulls[ix], it would hit a null-pointer dereference when accessing pXmlData[ix]. regards, tom lane