Re: Bad behavior from plpython 'return []' - Mailing list pgsql-hackers

From Jim Nasby
Subject Re: Bad behavior from plpython 'return []'
Date
Msg-id 6449df87-e606-e6a4-e25d-42ce6ffb78d9@BlueTreble.com
Whole thread Raw
In response to Re: Bad behavior from plpython 'return []'  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On 7/1/16 2:52 PM, Tom Lane wrote:
> +    /* if caller tries to specify zero-length array, make it empty */
> +    if (nelems <= 0)
> +        return construct_empty_array(elmtype);
> +
>     /* compute required space */
>     nbytes = 0;
>     hasnulls = false;
>
> But that might introduce new problems too, if any callers expect the
> array dimensions to be exactly what they asked for.

You mean ndims? What if instead of an empty array it returned an array 
where *dims was just all zeros (and correctly set *lbs)? array_eq would 
still need to account for that, but I think we don't have a choice about 
that unless we expressly forbid arrays where any of the elements of 
*dims were 0 (which I suspect we should probably do anyway... I don't 
see how you can do anything with a 2x0x3 array...)
-- 
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com
855-TREBLE2 (855-873-2532)   mobile: 512-569-9461



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Bad behavior from plpython 'return []'
Next
From: Jim Nasby
Date:
Subject: Re: Reviewing freeze map code