>From 6549005c3c762bbad2e89be0816b6852579dae77 Mon Sep 17 00:00:00 2001
From: Andres Freund <andres@anarazel.de>
Date: Thu, 3 Apr 2014 17:09:43 +0200
Subject: [PATCH 3/3] Make pgbench more C89 compliant in a slightly ugly way.

C89 requires that compound literals are constant, but pgbench had them
dependant on the passed in scale.

Also cleanup confusion of function level usage of static vs. const.
---
 contrib/pgbench/pgbench.c | 45 ++++++++++++++++++++++++++++++++++-----------
 1 file changed, 34 insertions(+), 11 deletions(-)

diff --git a/contrib/pgbench/pgbench.c b/contrib/pgbench/pgbench.c
index 7c1e59e..406160d 100644
--- a/contrib/pgbench/pgbench.c
+++ b/contrib/pgbench/pgbench.c
@@ -1566,12 +1566,10 @@ init(bool is_no_vacuum)
 		char	   *cols;
 		int			declare_fillfactor;
 	};
-	struct ddlinfo DDLs[] = {
+	const struct ddlinfo DDLs_int[] = {
 		{
 			"pgbench_history",
-			scale >= SCALE_32BIT_THRESHOLD
-			? "tid int,bid int,aid bigint,delta int,mtime timestamp,filler char(22)"
-			: "tid int,bid int,aid    int,delta int,mtime timestamp,filler char(22)",
+			"tid int,bid int,aid    int,delta int,mtime timestamp,filler char(22)",
 			0
 		},
 		{
@@ -1581,9 +1579,7 @@ init(bool is_no_vacuum)
 		},
 		{
 			"pgbench_accounts",
-			scale >= SCALE_32BIT_THRESHOLD
-			? "aid bigint not null,bid int,abalance int,filler char(84)"
-			: "aid    int not null,bid int,abalance int,filler char(84)",
+			"aid    int not null,bid int,abalance int,filler char(84)",
 			1
 		},
 		{
@@ -1592,12 +1588,34 @@ init(bool is_no_vacuum)
 			1
 		}
 	};
-	static char *DDLAFTERs[] = {
+	const struct ddlinfo DDLs_bigint[] = {
+		{
+			"pgbench_history",
+			"tid int,bid int,aid bigint,delta int,mtime timestamp,filler char(22)",
+			0
+		},
+		{
+			"pgbench_tellers",
+			"tid int not null,bid int,tbalance int,filler char(84)",
+			1
+		},
+		{
+			"pgbench_accounts",
+			"aid bigint not null,bid int,abalance int,filler char(84)",
+			1
+		},
+		{
+			"pgbench_branches",
+			"bid int not null,bbalance int,filler char(88)",
+			1
+		}
+	};
+	const char * const DDLAFTERs[] = {
 		"alter table pgbench_branches add primary key (bid)",
 		"alter table pgbench_tellers add primary key (tid)",
 		"alter table pgbench_accounts add primary key (aid)"
 	};
-	static char *DDLKEYs[] = {
+	const char * const DDLKEYs[] = {
 		"alter table pgbench_tellers add foreign key (bid) references pgbench_branches",
 		"alter table pgbench_accounts add foreign key (bid) references pgbench_branches",
 		"alter table pgbench_history add foreign key (bid) references pgbench_branches",
@@ -1621,11 +1639,16 @@ init(bool is_no_vacuum)
 	if ((con = doConnect()) == NULL)
 		exit(1);
 
-	for (i = 0; i < lengthof(DDLs); i++)
+	for (i = 0; i < lengthof(DDLs_bigint); i++)
 	{
 		char		opts[256];
 		char		buffer[256];
-		struct ddlinfo *ddl = &DDLs[i];
+		const struct ddlinfo *ddl;
+
+		if (scale >= SCALE_32BIT_THRESHOLD)
+			ddl = &DDLs_bigint[i];
+		else
+			ddl = &DDLs_int[i];
 
 		/* Remove old table, if it exists. */
 		snprintf(buffer, 256, "drop table if exists %s", ddl->table);
-- 
1.8.5.rc2.dirty

