Re: Bad behavior from plpython 'return []'

From: Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Bad behavior from plpython 'return []'
Date: 2016-07-01 20:34:58
Message-ID: 6449df87-e606-e6a4-e25d-42ce6ffb78d9@BlueTreble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jim Nasby 2016-07-01 20:42:22 Re: Reviewing freeze map code
Previous Message Tom Lane 2016-07-01 19:52:12 Re: Bad behavior from plpython 'return []'