Re: pgbench stats per script & other stuff - Mailing list pgsql-hackers

From Fabien COELHO
Subject Re: pgbench stats per script & other stuff
Date
Msg-id alpine.DEB.2.10.1602011704430.13459@sto
Whole thread Raw
In response to Re: pgbench stats per script & other stuff  (Michael Paquier <michael.paquier@gmail.com>)
Responses Re: pgbench stats per script & other stuff  (Alvaro Herrera <alvherre@2ndquadrant.com>)
List pgsql-hackers
Hello Michaël,

Two rebase attached.

>>  - 15-e: prefix selection for -b

> -               if (strncmp(builtin_script[i].name, name,
> -                                       strlen(builtin_script[i].name)) == 0)
> +               if (strncmp(builtin_script[i].name, name, len) == 0)
>
> I agree with Alvaro here: this should remain unchanged. It seems to be
> a rebase mistake.

I do not understand. I tested it and it works as expected. If I put the 
above strlen instead the suffix detection does not work:

 fabien@sto:bin/pgbench> git diff diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c index
783cbf9..0c33012100644 --- a/src/bin/pgbench/pgbench.c +++ b/src/bin/pgbench/pgbench.c @@ -2684,7 +2684,7 @@
findBuiltin(constchar *name, char **desc)
 
         for (i = 0; i < N_BUILTIN; i++)         { -               if (strncmp(builtin_script[i].name, name, len) == 0)
+              if (strncmp(builtin_script[i].name, name, strlen(builtin_script[i].name)) == 0)                 {
                *desc = builtin_script[i].desc;                         commands = builtin_script[i].commands;
 

 ./pgbench -b t no builtin script found for name "t" Available builtin scripts:         tpcb-like         simple-update
       select-only
 

Indeed, then it can only match if the provided "name" is as long as the 
recorded len. The point of the "suffix" selection is to align to the short 
supplied string.

-- 
Fabien.

pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: proposal: PL/Pythonu - function ereport
Next
From: Artur Zakirov
Date:
Subject: Re: Fuzzy substring searching with the pg_trgm extension