pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: pgbench: Support double constants and functions.
5+ messages / 4 participants
[nested] [flat]

* pgsql: pgbench: Support double constants and functions.
@ 2016-03-29 00:52  Robert Haas <rhaas@postgresql.org>
  0 siblings, 1 reply; 5+ messages in thread

From: Robert Haas @ 2016-03-29 00:52 UTC (permalink / raw)
  To: pgsql-committers

pgbench: Support double constants and functions.

The new functions are pi(), random(), random_exponential(),
random_gaussian(), and sqrt().  I was worried that this would be
slower than before, but, if anything, it actually turns out to be
slightly faster, because we now express the built-in pgbench scripts
using fewer lines; each \setrandom can be merged into a subsequent
\set.

Fabien Coelho

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/86c43f4e22c0771fd0cc6bce2799802c894ee2ec

Modified Files
--------------
doc/src/sgml/ref/pgbench.sgml | 283 +++++++++++++++++---------
src/bin/pgbench/exprparse.y   |  43 +++-
src/bin/pgbench/exprscan.l    |   5 +
src/bin/pgbench/pgbench.c     | 450 ++++++++++++++++++++++++++++++++++--------
src/bin/pgbench/pgbench.h     |  35 +++-
5 files changed, 624 insertions(+), 192 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: [COMMITTERS] pgsql: pgbench: Support double constants and functions.
@ 2016-03-29 04:25  Michael Paquier <michael.paquier@gmail.com>
  parent: Robert Haas <rhaas@postgresql.org>
  0 siblings, 1 reply; 5+ messages in thread

From: Michael Paquier @ 2016-03-29 04:25 UTC (permalink / raw)
  To: Robert Haas <rhaas@postgresql.org>; +Cc: PostgreSQL mailing lists <pgsql-hackers@postgresql.org>

On Tue, Mar 29, 2016 at 9:52 AM, Robert Haas <rhaas@postgresql.org> wrote:
> pgbench: Support double constants and functions.
>
> The new functions are pi(), random(), random_exponential(),
> random_gaussian(), and sqrt().  I was worried that this would be
> slower than before, but, if anything, it actually turns out to be
> slightly faster, because we now express the built-in pgbench scripts
> using fewer lines; each \setrandom can be merged into a subsequent
> \set.

Buildfarm is complaining about a couple of things here:
  src/bin/pgbench/exprparse.c(139): error C2365: 'DOUBLE' :
redefinition; previous definition was 'typedef'
[C:\buildfarm\buildenv\HEAD\pgsql.build\pgbench.vcxproj]
  src/bin/pgbench/pgbench.c(1046): error C2065: 'INT64_MIN' :
undeclared identifier
[C:\buildfarm\buildenv\HEAD\pgsql.build\pgbench.vcxproj]
  src/bin/pgbench/exprparse.c(139): error C2086: 'yytokentype DOUBLE'
: redefinition [C:\buildfarm\buildenv\HEAD\pgsql.build\pgbench.vcxproj]
  src/bin/pgbench/pgbench.c(1046): error C2065: 'INT64_MAX' :
undeclared identifier
[C:\buildfarm\buildenv\HEAD\pgsql.build\pgbench.vcxproj]
  src/bin/pgbench/exprscan.l(131): error C2275: 'DOUBLE' : illegal use
of this type as an expression (src/bin/pgbench/exprparse.c)
[C:\buildfarm\buildenv\HEAD\pgsql.build\pgbench.vcxproj]

Instead of INT64_MIN and INT64_MAX, I think that it would be better to
use PG_INT64_MIN and PG_INT64_MAX. Note as well that DOUBLE is an
existing variable type in VS (while INTEGER is not), and it is true
that it is not directly documented:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms221627%28v=vs.85%29.aspx
A way to fix compilation here is to rename those tokens to something
that will never conflict, like in the attached to DOUBLE_VAR and
INTEGER_VAR, both exprparse.y and exprparse.l need an update.
-- 
Michael

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Attachments:

pgbench-fix-vs.patch (binary/octet-stream, 2.1K) download diff --git a/src/bin/pgbench/exprparse.y b/src/bin/pgbench/exprparse.y index 8772448..04f2529 100644 --- a/src/bin/pgbench/exprparse.y +++ b/src/bin/pgbench/exprparse.y @@ -47,11 +47,11 @@ static PgBenchExpr *make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList * %type <elist> elist %type <expr> expr -%type <ival> INTEGER function -%type <dval> DOUBLE +%type <ival> INTEGER_VAR function +%type <dval> DOUBLE_VAR %type <str> VARIABLE FUNCTION -%token INTEGER DOUBLE VARIABLE FUNCTION +%token INTEGER_VAR DOUBLE_VAR VARIABLE FUNCTION /* Precedence: lowest to highest */ %left '+' '-' @@ -76,8 +76,8 @@ expr: '(' expr ')' { $$ = $2; } | expr '*' expr { $$ = make_op(yyscanner, "*", $1, $3); } | expr '/' expr { $$ = make_op(yyscanner, "/", $1, $3); } | expr '%' expr { $$ = make_op(yyscanner, "%", $1, $3); } - | INTEGER { $$ = make_integer_constant($1); } - | DOUBLE { $$ = make_double_constant($1); } + | INTEGER_VAR { $$ = make_integer_constant($1); } + | DOUBLE_VAR { $$ = make_double_constant($1); } | VARIABLE { $$ = make_variable($1); } | function '(' elist ')' { $$ = make_func(yyscanner, $1, $3); } ; diff --git a/src/bin/pgbench/exprscan.l b/src/bin/pgbench/exprscan.l index d8b706a..e954608 100644 --- a/src/bin/pgbench/exprscan.l +++ b/src/bin/pgbench/exprscan.l @@ -123,12 +123,12 @@ newline [\n] } {digit}+ { yylval->ival = strtoint64(yytext); - return INTEGER; + return INTEGER_VAR; } {digit}+(\.{digit}*)?([eE][-+]?{digit}+)? { yycolumn += yyleng; yylval->dval = atof(yytext); - return DOUBLE; + return DOUBLE_VAR; } {alpha}{alnum}* { yylval->str = pg_strdup(yytext); diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c index a2df4df..4cd5513 100644 --- a/src/bin/pgbench/pgbench.c +++ b/src/bin/pgbench/pgbench.c @@ -1043,7 +1043,7 @@ coerceToInt(PgBenchValue *pval, int64 *ival) { double dval = pval->u.dval; Assert(pval->type == PGBT_DOUBLE); - if (dval < INT64_MIN || INT64_MAX < dval) + if (dval < PG_INT64_MIN || PG_INT64_MAX < dval) { fprintf(stderr, "double to int overflow for %f\n", dval); return false;
^ permalink raw reply [nested|flat] 5+ messages in thread

* Re: [COMMITTERS] pgsql: pgbench: Support double constants and functions.
@ 2016-03-29 04:56  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Michael Paquier <michael.paquier@gmail.com>
  0 siblings, 2 replies; 5+ messages in thread

From: Tom Lane @ 2016-03-29 04:56 UTC (permalink / raw)
  To: Michael Paquier <michael.paquier@gmail.com>; +Cc: Robert Haas <rhaas@postgresql.org>; PostgreSQL mailing lists <pgsql-hackers@postgresql.org>

Michael Paquier <michael.paquier@gmail.com> writes:
> On Tue, Mar 29, 2016 at 9:52 AM, Robert Haas <rhaas@postgresql.org> wrote:
>> pgbench: Support double constants and functions.

> Instead of INT64_MIN and INT64_MAX, I think that it would be better to
> use PG_INT64_MIN and PG_INT64_MAX.

Indeed.

> Note as well that DOUBLE is an
> existing variable type in VS (while INTEGER is not),

Ooops; that one was harder to foresee.

> A way to fix compilation here is to rename those tokens to something
> that will never conflict, like in the attached to DOUBLE_VAR and
> INTEGER_VAR, both exprparse.y and exprparse.l need an update.

Agreed, but these symbols represent constants not variables, so
I used DOUBLE_CONST and INTEGER_CONST instead.  Pushed with those
corrections, so that we can get back to looking at my own bugs :-(

			regards, tom lane


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: [COMMITTERS] pgsql: pgbench: Support double constants and functions.
@ 2016-03-29 05:00  Michael Paquier <michael.paquier@gmail.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 0 replies; 5+ messages in thread

From: Michael Paquier @ 2016-03-29 05:00 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Robert Haas <rhaas@postgresql.org>; PostgreSQL mailing lists <pgsql-hackers@postgresql.org>

On Tue, Mar 29, 2016 at 1:56 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Michael Paquier <michael.paquier@gmail.com> writes:
>> On Tue, Mar 29, 2016 at 9:52 AM, Robert Haas <rhaas@postgresql.org> wrote:
>>> pgbench: Support double constants and functions.
>
>> Instead of INT64_MIN and INT64_MAX, I think that it would be better to
>> use PG_INT64_MIN and PG_INT64_MAX.
>
> Indeed.
>
>> Note as well that DOUBLE is an
>> existing variable type in VS (while INTEGER is not),
>
> Ooops; that one was harder to foresee.

Thanks for the push.

>> A way to fix compilation here is to rename those tokens to something
>> that will never conflict, like in the attached to DOUBLE_VAR and
>> INTEGER_VAR, both exprparse.y and exprparse.l need an update.
>
> Agreed, but these symbols represent constants not variables, so
> I used DOUBLE_CONST and INTEGER_CONST instead.  Pushed with those
> corrections, so that we can get back to looking at my own bugs :-(

I think I know what's going on here...
-- 
Michael


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: [COMMITTERS] pgsql: pgbench: Support double constants and functions.
@ 2016-03-29 10:32  Robert Haas <robertmhaas@gmail.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 0 replies; 5+ messages in thread

From: Robert Haas @ 2016-03-29 10:32 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Michael Paquier <michael.paquier@gmail.com>; PostgreSQL mailing lists <pgsql-hackers@postgresql.org>

On Tue, Mar 29, 2016 at 12:56 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Michael Paquier <michael.paquier@gmail.com> writes:
>> On Tue, Mar 29, 2016 at 9:52 AM, Robert Haas <rhaas@postgresql.org> wrote:
>>> pgbench: Support double constants and functions.
>
>> Instead of INT64_MIN and INT64_MAX, I think that it would be better to
>> use PG_INT64_MIN and PG_INT64_MAX.
>
> Indeed.
>
>> Note as well that DOUBLE is an
>> existing variable type in VS (while INTEGER is not),
>
> Ooops; that one was harder to foresee.
>
>> A way to fix compilation here is to rename those tokens to something
>> that will never conflict, like in the attached to DOUBLE_VAR and
>> INTEGER_VAR, both exprparse.y and exprparse.l need an update.
>
> Agreed, but these symbols represent constants not variables, so
> I used DOUBLE_CONST and INTEGER_CONST instead.  Pushed with those
> corrections, so that we can get back to looking at my own bugs :-(

Oops.  Thanks for cleaning up my mess.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2016-03-29 10:32 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-03-29 00:52 pgsql: pgbench: Support double constants and functions. Robert Haas <rhaas@postgresql.org>
2016-03-29 04:25 ` Michael Paquier <michael.paquier@gmail.com>
2016-03-29 04:56   ` Tom Lane <tgl@sss.pgh.pa.us>
2016-03-29 05:00     ` Michael Paquier <michael.paquier@gmail.com>
2016-03-29 10:32     ` Robert Haas <robertmhaas@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox