Re: [HACKERS] pgbench more operators & functions

From: Teodor Sigaev <teodor(at)sigaev(dot)ru>
To: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
Cc: Raúl Marín Rodríguez <rmrodriguez(at)carto(dot)com>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] pgbench more operators & functions
Date: 2017-12-15 13:47:41
Message-ID: 60091c09-0fcb-8e7a-2f40-5e952ed193cf@sigaev.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>> 2) In makeVariableValue():
>> if (pg_strcasecmp(var->svalue, "null") == 0)
>> ...
>> else if (pg_strncasecmp(var->svalue, "true", slen)
>>
>> mixing of pg_strcasecmp and pg_strNcasecmp. And, IMHO, result of
>> pg_strncasecmp("tru", "true", 1) will  be 0.
>
> Yep, but it cannot be called like that because slen == strlen(var->svalue).
sorry, mistyped
pg_strncasecmp("tru", "true", 3) will be 0.

>
>> It may be good for 't' of 'f' but it seems too free grammar to accept 'tr' or
>> 'fa' or even 'o' which actually not known to be on or off.
>
> Yes, it really works like that. I tried to make something clearer than
> "src/bin/psql/variable.c". Maybe I did not succeed.
Ok, I see. Current coding accepts truexxx, falsexxx, yesxx, noxxx but doesn't
accept offxxx and onxxx. Not so consistent as it could be. Also it doesn't
accept 1 and 0 as psql does, but it's obviously why.

> I used "PGBT_NO_VALUE" which seemed clearer otherwise a variable may be set and
> its value would not "not set" which would look strange.
Agree

Sorry, but I found more notices:
1) '~' and unary '-' should be commented, it's not so easy to guess about how
they actually implemented (-1 XOR value, remember that -1 is 0xfffff....)

2)
- | expr '%' expr { $$ = make_op(yyscanner, "%", $1, $3); }
+ | expr '%' expr { $$ = make_op(yyscanner, "mod", $1, $3); }

why is MOD operation renamed? Do I miss something in thread?

Looking to psql and pgbench scripting implementation, isn't it better to
integrate lua in psql & pgbench?

--
Teodor Sigaev E-mail: teodor(at)sigaev(dot)ru
WWW: http://www.sigaev.ru/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Aleksander Alekseev 2017-12-15 13:52:18 Re: GSoC 2018
Previous Message Andrew Dunstan 2017-12-15 13:33:50 Re: pearltidy source code has been removed (pgindent)