From beb6c14f4ed248542d0d11a3d0306f23454741e4 Mon Sep 17 00:00:00 2001
From: Danny Auble <da@llnl.gov>
Date: Thu, 12 Mar 2009 17:27:37 +0000
Subject: [PATCH] svn merge -r16863:16869
 https://eris.llnl.gov/svn/slurm/branches/slurm-1.3

---
 .../mysql/accounting_storage_mysql.c          | 28 ++++++++++++++-----
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c b/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c
index c6b7db0fd91..47f8b48c37e 100644
--- a/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c
+++ b/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c
@@ -9407,11 +9407,7 @@ extern int acct_storage_p_get_usage(mysql_conn_t *mysql_conn, uid_t uid,
 	List *my_list;
 	uint32_t id = NO_VAL;
 
-	char *usage_req_inx[] = {
-		"t1.id",
-		"t1.period_start",
-		"t1.alloc_cpu_secs",
-	};
+	char **usage_req_inx = NULL;
 	
 	enum {
 		USAGE_ID,
@@ -9422,17 +9418,35 @@ extern int acct_storage_p_get_usage(mysql_conn_t *mysql_conn, uid_t uid,
 
 	switch (type) {
 	case DBD_GET_ASSOC_USAGE:
+	{
+		char *temp_usage[] = {
+			"t3.id",
+			"t1.period_start",
+			"t1.alloc_cpu_secs"
+		};
+		usage_req_inx = temp_usage;
+
 		id = acct_assoc->id;
 		username = acct_assoc->user;
 		my_list = &acct_assoc->accounting_list;
 		my_usage_table = assoc_day_table;
 		break;
+	}
 	case DBD_GET_WCKEY_USAGE:
+	{
+		char *temp_usage[] = {
+			"id",
+			"period_start",
+			"alloc_cpu_secs"
+		};
+		usage_req_inx = temp_usage;
+
 		id = acct_wckey->id;
 		username = acct_wckey->user;
 		my_list = &acct_wckey->accounting_list;
 		my_usage_table = wckey_day_table;
 		break;
+	}
 	default:
 		error("Unknown usage type %d", type);
 		return SLURM_ERROR;
@@ -9532,13 +9546,13 @@ is_user:
 			"where (t1.period_start < %d && t1.period_start >= %d) "
 			"&& t1.id=t2.id && t3.id=%d && "
 			"t2.lft between t3.lft and t3.rgt "
-			"order by t1.id, period_start;",
+			"order by t3.id, period_start;",
 			tmp, my_usage_table, assoc_table, assoc_table,
 			end, start, id);
 		break;
 	case DBD_GET_WCKEY_USAGE:
 		query = xstrdup_printf(
-			"select %s from %s as t1 "
+			"select %s from %s "
 			"where (period_start < %d && period_start >= %d) "
 			"&& id=%d order by id, period_start;",
 			tmp, my_usage_table, end, start, id);
-- 
GitLab