From a5007d671afe5d0c42782db0670879fbc1ccbfb7 Mon Sep 17 00:00:00 2001
From: Tatsuo Ishii <ishii@postgresql.org>
Date: Sat, 21 Oct 2006 06:31:28 +0000
Subject: [PATCH] pgbench: More fix with handling default scaling factor in the
 default scenarios. With multiple clinets, only the first client got the right
 scaling factor and this gave a illusion of better performance in case of the
 scaling factor greater than 1.

---
 contrib/pgbench/README.pgbench     |  6 +++++-
 contrib/pgbench/README.pgbench_jis |  6 +++++-
 contrib/pgbench/pgbench.c          | 22 +++++++++++++++++++++-
 3 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/contrib/pgbench/README.pgbench b/contrib/pgbench/README.pgbench
index c96f0851a48..d576b594a9f 100644
--- a/contrib/pgbench/README.pgbench
+++ b/contrib/pgbench/README.pgbench
@@ -1,4 +1,4 @@
-pgbench README		2006/07/26 Tatsuo Ishii
+pgbench README		2006/10/21 Tatsuo Ishii
 
 o What is pgbench?
 
@@ -235,6 +235,10 @@ Basically it is same as BSD license. See pgbench.c for more details.
 
 o History
 
+2006/10/21
+	* more fix with handling default scaling factor in the default
+          scenarios
+
 2006/09/14
 	* change "tps" to "scale" to avoid confusion
 
diff --git a/contrib/pgbench/README.pgbench_jis b/contrib/pgbench/README.pgbench_jis
index 0faa30de68b..adb22af4051 100644
--- a/contrib/pgbench/README.pgbench_jis
+++ b/contrib/pgbench/README.pgbench_jis
@@ -1,4 +1,4 @@
-pgbench README		2006/07/26 Tatsuo Ishii
+pgbench README		2006/10/21 Tatsuo Ishii
 
 ■pgbench とは?
 
@@ -285,6 +285,10 @@ pgbench は石井 達夫によって書かれました.ライセンス条件は pgbench.c
 
 ■改定履歴
 
+2006/10/21
+	* 更にデフォルトのスケーリングファクタをbranchesから取ってこな
+          いバグを修正.
+
 2006/09/13
 	* 変数tpsは紛らわしいのでscaleに変更.デフォルトシナリオの時に,
 	  デフォルトのスケーリングファクタをbranchesから取ってこないバグを修正.
diff --git a/contrib/pgbench/pgbench.c b/contrib/pgbench/pgbench.c
index 3c15346e899..e880f638f06 100644
--- a/contrib/pgbench/pgbench.c
+++ b/contrib/pgbench/pgbench.c
@@ -1,5 +1,5 @@
 /*
- * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.57 2006/10/07 19:25:28 tgl Exp $
+ * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.58 2006/10/21 06:31:28 ishii Exp $
  *
  * pgbench: a simple benchmark program for PostgreSQL
  * written by Tatsuo Ishii
@@ -1352,6 +1352,8 @@ main(int argc, char **argv)
 
 		memset(state + 1, 0, sizeof(*state) * (nclients - 1));
 
+		snprintf(val, sizeof(val), "%d", scale);
+
 		for (i = 1; i < nclients; i++)
 		{
 			int			j;
@@ -1364,6 +1366,12 @@ main(int argc, char **argv)
 					exit(1);
 				}
 			}
+
+			if (putVariable(&state[i], "scale", val) == false)
+			{
+				fprintf(stderr, "Couldn't allocate memory for variable\n");
+				exit(1);
+			}
 		}
 	}
 
@@ -1425,6 +1433,18 @@ main(int argc, char **argv)
 			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);
+				}
+			}
+		}
 	}
 
 	if (!is_no_vacuum)
-- 
GitLab