Re: pgsql: Set random seed for pgbench.

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Teodor Sigaev <teodor(at)sigaev(dot)ru>, pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: Re: pgsql: Set random seed for pgbench.
Date: 2018-03-31 07:00:02
Message-ID: alpine.DEB.2.20.1803310828100.23311@lancre
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers


Hello Tom,

>> Set random seed for pgbench.
>
> So this patch has ignored the possibility of not having pg_strong_random.

I assumed that pg_strong_random is always available, but may fail with an
error if a strong random source is not available, in which case the error
message should be enough for the user to figure out that they cannot use
the 'rand' value and must rely on 'time' or an integer.

The error message can be improved in this case.

> That's moving the portability goalposts in a way that I do not find
> acceptable for such a marginal feature. What behavior do you think we
> should have for platforms without that --- accept the seed=rand option
> but then error out, or not recognize the option at all?

The first option is currently implemented and documented, and seems fine.

> BTW, I also note that the patch is constructing error messages from
> sentence fragments, which is verboten per translatability policy.
> While that's perhaps not too important as long as we don't have message
> translations for pgbench, it still seems like something to fix now not
> later.

The elements of the structure could be translatable independently: one
part says there is an error, the other provides the context in which this
error was triggered. This could be made a little clearer by using
parentheses for instance. Otherwise to comply with translability policy
the function can be made to return a bool and then the caller show the
context.

In the attached, I improved the error message on 'rand' error and printed
the error context outside of the function.

Thanks for the review.

--
Fabien.

Attachment Content-Type Size
pgbench-seed-fix-1.patch text/plain 3.3 KB

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2018-03-31 15:32:01 Re: pgsql: Add documentation for the JIT feature.
Previous Message Tom Lane 2018-03-31 05:15:28 Re: pgsql: Transforms for jsonb to PL/Python