Re: [GENERAL] pgbench not setting scale size correctly?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Greg Smith <gsmith(at)gregsmith(dot)com>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [GENERAL] pgbench not setting scale size correctly?
Date: 2008-05-09 15:55:04
Message-ID: 14939.1210348504@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-patches

Greg Smith <gsmith(at)gregsmith(dot)com> writes:
> Turns out it wasn't so contorted. Updated patch attached that only warns
> in the exact cases where the setting is ignored, and the warning says how
> it's actually setting the scale. I tested all the run types and it
> correctly complains only when warranted, samples:

Actually that didn't work, because scale defaults to 1, so it would
*always* warn ... I applied the attached instead.

regards, tom lane

Index: pgbench.c
===================================================================
RCS file: /cvsroot/pgsql/contrib/pgbench/pgbench.c,v
retrieving revision 1.79
diff -c -r1.79 pgbench.c
*** pgbench.c 19 Mar 2008 03:33:21 -0000 1.79
--- pgbench.c 9 May 2008 15:49:47 -0000
***************
*** 1449,1454 ****
--- 1449,1455 ----
int ttype = 0; /* transaction type. 0: TPC-B, 1: SELECT only,
* 2: skip update of branches and tellers */
char *filename = NULL;
+ bool scale_given = false;

CState *state; /* status of clients */

***************
*** 1552,1557 ****
--- 1553,1559 ----
is_connect = 1;
break;
case 's':
+ scale_given = true;
scale = atoi(optarg);
if (scale <= 0)
{
***************
*** 1647,1662 ****

remains = nclients;

- if (getVariable(&state[0], "scale") == NULL)
- {
- snprintf(val, sizeof(val), "%d", scale);
- if (putVariable(&state[0], "scale", val) == false)
- {
- fprintf(stderr, "Couldn't allocate memory for variable\n");
- exit(1);
- }
- }
-
if (nclients > 1)
{
state = (CState *) realloc(state, sizeof(CState) * nclients);
--- 1649,1654 ----
***************
*** 1668,1675 ****

memset(state + 1, 0, sizeof(*state) * (nclients - 1));

! snprintf(val, sizeof(val), "%d", scale);
!
for (i = 1; i < nclients; i++)
{
int j;
--- 1660,1666 ----

memset(state + 1, 0, sizeof(*state) * (nclients - 1));

! /* copy any -D switch values to all clients */
for (i = 1; i < nclients; i++)
{
int j;
***************
*** 1682,1693 ****
exit(1);
}
}
-
- if (putVariable(&state[i], "scale", val) == false)
- {
- fprintf(stderr, "Couldn't allocate memory for variable\n");
- exit(1);
- }
}
}

--- 1673,1678 ----
***************
*** 1743,1764 ****
}
PQclear(res);

! snprintf(val, sizeof(val), "%d", scale);
! if (putVariable(&state[0], "scale", val) == false)
! {
! fprintf(stderr, "Couldn't allocate memory for variable\n");
! exit(1);
! }

! if (nclients > 1)
{
! for (i = 1; i < nclients; i++)
{
! if (putVariable(&state[i], "scale", val) == false)
! {
! fprintf(stderr, "Couldn't allocate memory for variable\n");
! exit(1);
! }
}
}
}
--- 1728,1753 ----
}
PQclear(res);

! /* warn if we override user-given -s switch */
! if (scale_given)
! fprintf(stderr,
! "Scale option ignored, using branches table count = %d\n",
! scale);
! }

! /*
! * :scale variables normally get -s or database scale, but don't override
! * an explicit -D switch
! */
! if (getVariable(&state[0], "scale") == NULL)
! {
! snprintf(val, sizeof(val), "%d", scale);
! for (i = 0; i < nclients; i++)
{
! if (putVariable(&state[i], "scale", val) == false)
{
! fprintf(stderr, "Couldn't allocate memory for variable\n");
! exit(1);
}
}
}

In response to

Browse pgsql-general by date

  From Date Subject
Next Message tekwiz 2008-05-09 19:05:26 dynamic procedure call
Previous Message Tom Lane 2008-05-09 14:48:35 Re: [GENERAL] pgbench not setting scale size correctly?

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2008-05-09 15:59:33 Re: [HACKERS] [NOVICE] encoding problems
Previous Message Bruce Momjian 2008-05-09 15:40:03 Re: [HACKERS] [NOVICE] encoding problems