Re: extend pgbench expressions with functions

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема Re: extend pgbench expressions with functions
Дата
Msg-id CAB7nPqQvZucKFXspw0YBbjVx4Esa8JRYDJz-FPWXad4625WvmQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: extend pgbench expressions with functions  (Fabien COELHO <coelho@cri.ensmp.fr>)
Ответы Re: extend pgbench expressions with functions  (Fabien COELHO <coelho@cri.ensmp.fr>)
Список pgsql-hackers
On Fri, Feb 12, 2016 at 2:41 AM, Fabien COELHO <coelho@cri.ensmp.fr> wrote:
>
> 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.

(this one has been mentioned by Alvaro offlist)
Using a pointer to the tail of the list would make the code simple,
and save a couple of lines.

Another thing that could be considered is also to move list.c and
pg_list.h into src/common and reuse that. There are other frontend
utilities that emulate the same kind of facilities, have a look for
example at the other copycats in pg_dump and pg_basebackup.
--
Michael



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Michael Paquier
Дата:
Сообщение: Re: NextXID format change (was Re: exposing pg_controldata and pg_config as functions)
Следующее
От: Vitaly Burovoy
Дата:
Сообщение: Re: custom function for converting human readable sizes to bytes