Greg Smith <[EMAIL PROTECTED]> 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);
                        }
                }
        }

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

Reply via email to