Re: extend pgbench expressions with functions

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: extend pgbench expressions with functions
Date: 2016-02-11 17:41:53
Message-ID: alpine.DEB.2.10.1602111835540.6591@sto
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Hello Michaël,

> + /* the argument list has been built in reverse order, it is fixed here */
> + expr->u.function.args = reverse_elist(args);
> Hm. I may be missing something, but why is that necessary? This is
> basically doing a double-reversion to put all the arguments in the
> correct order when parsing the function arguments.

This is because the expression list is parsed left to right and the list
is built as a stack to avoid looking for the last argument to append the
next expression, but then the list is in reverse order at the end of
parsing, so it is reversed once to make it right. This way the complexity
is kept as O(n).

If this is too much I can switch to O(n**2) by appending each expression
at the end of the list.

--
Fabien.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2016-02-11 17:44:22 Re: pl/pgsql exported functions
Previous Message Robert Haas 2016-02-11 17:36:58 Re: GinPageIs* don't actually return a boolean