@ -1423,17 +1423,25 @@ plperl_ref_from_pg_array(Datum arg, Oid typid)
info - > ndims = ARR_NDIM ( ar ) ;
info - > ndims = ARR_NDIM ( ar ) ;
dims = ARR_DIMS ( ar ) ;
dims = ARR_DIMS ( ar ) ;
deconstruct_array ( ar , elementtype , typlen , typbyval ,
/* No dimensions? Return an empty array */
typalign , & info - > elements , & info - > nulls ,
if ( info - > ndims = = 0 )
& nitems ) ;
{
av = newRV_noinc ( ( SV * ) newAV ( ) ) ;
}
else
{
deconstruct_array ( ar , elementtype , typlen , typbyval ,
typalign , & info - > elements , & info - > nulls ,
& nitems ) ;
/* Get total number of elements in each dimension */
/* Get total number of elements in each dimension */
info - > nelems = palloc ( sizeof ( int ) * info - > ndims ) ;
info - > nelems = palloc ( sizeof ( int ) * info - > ndims ) ;
info - > nelems [ 0 ] = nitems ;
info - > nelems [ 0 ] = nitems ;
for ( i = 1 ; i < info - > ndims ; i + + )
for ( i = 1 ; i < info - > ndims ; i + + )
info - > nelems [ i ] = info - > nelems [ i - 1 ] / dims [ i - 1 ] ;
info - > nelems [ i ] = info - > nelems [ i - 1 ] / dims [ i - 1 ] ;
av = split_array ( info , 0 , nitems , 0 ) ;
av = split_array ( info , 0 , nitems , 0 ) ;
}
hv = newHV ( ) ;
hv = newHV ( ) ;
( void ) hv_store ( hv , " array " , 5 , av , 0 ) ;
( void ) hv_store ( hv , " array " , 5 , av , 0 ) ;
@ -1452,6 +1460,9 @@ split_array(plperl_array_info *info, int first, int last, int nest)
int i ;
int i ;
AV * result ;
AV * result ;
/* we should only be called when we have something to split */
Assert ( info - > ndims > 0 ) ;
/* since this function recurses, it could be driven to stack overflow */
/* since this function recurses, it could be driven to stack overflow */
check_stack_depth ( ) ;
check_stack_depth ( ) ;