Re: add modulo (%) operator to pgbench

Поиск
Список
Период
Сортировка
От Fabien COELHO
Тема Re: add modulo (%) operator to pgbench
Дата
Msg-id alpine.DEB.2.10.1409091649010.24628@sto
обсуждение исходный текст
Ответ на Re: add modulo (%) operator to pgbench  (Robert Haas <robertmhaas@gmail.com>)
Ответы Re: add modulo (%) operator to pgbench  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-hackers
Hello Robert,

> Writing a simple expression parser for pgbench using flex and bison 
> would not be an inordinately difficult problem.

Sure. Note that there is not only the parsing but also the evaluating to 
think of, which mean a data structure to represent the expressions which 
would be more complex than the current one. Although it is not difficult 
as such, it would mean breaking pgbench heavily, which would mean 
more time and energy than I have available.

> And it would let you add abs() and ?: and thereby avoid the need to 
> hard-code multiple versions of the modulo operator in the patch.

It would also mean to *implement* abs and ?: in the "execution" code to 
compute the parsed expression.

> The fact that you're agonizing about which modulo to add is a sign that 
> the language is too impoverished to let you do anything non-trivial.

I'm not agonizing about which modulo to use:-) I know I do not want the 
C/SQL version which is never really useful if you have signed data. I 
overlooked this detail when submitting the first patch, and produced a 
stupid patch with all 3 possible modulos, before going to the sane 
solution which is to use the floored division Knuth version. If I had 
thought a bit, I would have sent v3 as v1 directly.

> That's why C only has one modulo operator: as the patch demonstrates, 
> the differences between the version can be patched over with a very 
> short C expression. If we had real expressions in pgbench, you could do 
> the same thing there.

Sure. I agree that pgbench is limited and that real expressions would have 
helped, but it is also quite useful and easy to extend "as is". Maybe the 
"add an expression parser to pgbench" could be added in the postgresql 
todo wiki?

-- 
Fabien.



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

Предыдущее
От: Stephen Frost
Дата:
Сообщение: Re: ALTER TABLESPACE MOVE command tag tweak
Следующее
От: Pavel Stehule
Дата:
Сообщение: Re: WIP Patch for GROUPING SETS phase 1