Hi All, I have the following code:
141 if ( 0 != iXmlArrDim ) { 142 Datum *pXmlData = NULL; 143 bool *pXmlDataNulls = NULL; 144 uint32_t iXmlCount = 0; 145 bool bFirstTime = true; 146 147 Assert( XMLOID == ARR_ELEMENTS( pXmlDataArr ) ); 148 149 deconstruct_array( pXmlDataArr, 150 XMLOID, 151 -1, 152 false, 153 'i', 154 &pXmlData, 155 &pXmlDataNulls, 156 (int32_t*)&iXmlCount ); 157 158 initStringInfo( &xmlStr ); 159 160 for ( size_t ix = 0; ix < iXmlCount; ++ix ) { 161 xmltype *pX = DatumGetXmlP( pXmlData[ix] ); 162 char *pData = VARDATA( pX ); 163 uint32_t iData = VARSIZE( pX ) - VARHDRSZ; 164 165 if ( !bFirstTime ) 166 appendStringInfoString( &xmlStr, ", " ); 167 else 168 bFirstTime = false; 169 170 appendStringInfoString( &xmlStr, 171 (const char*)lzXmlCharStrndup( pData, 172 iData ) ); 173 } 174 175 pfree( pXmlData ); 176 pfree( pXmlDataNulls ); 177 } I am trying to pass an array into a new function I am creating called lzxmlexists via the following statement: wdbs=# SELECT "XT"."ROWKEY" , "XT"."XMLT1C1" FROM "LZQAAS"."T642_XML_T1" "XT" WHERE "ROWKEY"=64201 AND lzxmlexists( ' $XTX//DeptName[ . = $Dn ]', '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 = 0; ix < iXmlCount; ++ix ) { (gdb) 163 xmltype *pX = DatumGetXmlP( pXmlData[ix] ); (gdb) Program received signal SIGSEGV, Segmentation fault. 0x00000000008b3514 in pg_detoast_datum () Obviously, I’ve done something wrong, or I am misunderstanding something. BTW, if I change the array input to something like this ARRAY[‘something-variable’::xml] it works no problem, but it seems as though getting the input from the column results in garbage that traps. Any suggestion/help would be greatly appreciated. Regards, Garfield