Thread

Commits

  1. Fix incorrect assertion on number of array dimensions.

  2. Support multi-dimensional arrays in PL/python.

  1. Assertion failure with 6-dimensional array in PL/python

    Heikki Linnakangas <hlinnaka@iki.fi> — 2020-09-30T21:06:07Z

    create extension plpythonu;
    
    -- from 'plpython_types' regression test
    CREATE FUNCTION test_type_conversion_array_int4(x int4[]) RETURNS int4[] 
    AS $$
    plpy.info(x, type(x))
    return x
    $$ LANGUAGE plpythonu;
    
    postgres=# SELECT * FROM test_type_conversion_array_int4(ARRAY [[[[[[ 1 
    ]]]]]]);
    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.
    !?>
    
    TRAP: FailedAssertion("!(ndim < 6)", File: "plpy_typeio.c", Line: 686)
    
    The assertion looks like this:
    
    	if (ARR_NDIM(array) == 0)
    		return PyList_New(0);
    
    	/* Array dimensions and left bounds */
    	ndim = ARR_NDIM(array);
    	dims = ARR_DIMS(array);
    	Assert(ndim < MAXDIM);     <-----
    
    I believe that's wrong, it should be "ndim <= MAXDIM". Looks like I 
    introduced this in commit 94aceed317, in v10.
    
    I'll go fix that...
    
    - Heikki