Alex Pilosov <alex(at)pilosoft(dot)com> writes:
> Here's more info on the bug:
> background: function cust_name(customers) returns varchar;
> Query in question:
> SELECT
> cust_name(a)
> FROM customers AS a, addresses AS b
> WHERE
> b.cust_id=a.cust_id
> and b.oid=get_billing_record(a.cust_id)
> and cust_balance(a.cust_id)>0
I think I see the problem. Is your query being executed via a mergejoin
plan with an explicit sort on customers? Does the failure go away if
you force a nestloop join?
regards, tom lane