From 15cd57a9672fa65ff749f2748b9d299a3ed82617 Mon Sep 17 00:00:00 2001
From: Danny Auble <da@llnl.gov>
Date: Thu, 5 Mar 2009 18:35:05 +0000
Subject: [PATCH] svn merge -r16781:16784
 https://eris.llnl.gov/svn/slurm/branches/slurm-1.3

---
 NEWS                                                     | 2 ++
 .../accounting_storage/mysql/mysql_jobacct_process.c     | 2 ++
 src/sacct/options.c                                      | 9 +++++++--
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index 947f2c95241..eb348e542b7 100644
--- a/NEWS
+++ b/NEWS
@@ -212,6 +212,8 @@ documents those changes that are of interest to users and admins.
       If multiple hostslists are given on stdin they are combined to a
       union hostlist before being used in the way requested by the
       options.
+ -- when using -j option in sacct no user restriction will applied unless
+    specified with the -u option.
 
 * Changes in SLURM 1.3.13
 =========================
diff --git a/src/plugins/accounting_storage/mysql/mysql_jobacct_process.c b/src/plugins/accounting_storage/mysql/mysql_jobacct_process.c
index 006bdc16868..82f5f0af85b 100644
--- a/src/plugins/accounting_storage/mysql/mysql_jobacct_process.c
+++ b/src/plugins/accounting_storage/mysql/mysql_jobacct_process.c
@@ -794,6 +794,8 @@ extern List mysql_jobacct_process_get_jobs(mysql_conn_t *mysql_conn, uid_t uid,
 	*/
 	if(job_cond && !job_cond->duplicates) 
 		xstrcat(query, " order by t1.cluster, jobid, submit desc");
+	else
+		xstrcat(query, " order by t1.cluster, submit desc");
 
 	debug3("%d(%d) query\n%s", mysql_conn->conn, __LINE__, query);
 	if(!(result = mysql_db_query_ret(mysql_conn->db_conn, query, 0))) {
diff --git a/src/sacct/options.c b/src/sacct/options.c
index fabffc30ca2..7ece979b0ba 100644
--- a/src/sacct/options.c
+++ b/src/sacct/options.c
@@ -697,7 +697,6 @@ void parse_command_line(int argc, char **argv)
 				job_cond->step_list = list_create(
 					destroy_jobacct_selected_step);
 			_addto_step_list(job_cond->step_list, optarg);
-			all_users = 1;
 			break;
 		case 'L':
 			all_clusters = 1;
@@ -721,7 +720,6 @@ void parse_command_line(int argc, char **argv)
 				break;
 			}
 			job_cond->used_nodes = xstrdup(optarg);
-			all_users = 1;
 			break;
 		case 'p':
 			print_fields_parsable_print = 
@@ -864,6 +862,13 @@ void parse_command_line(int argc, char **argv)
 		}
 	}
 
+	/* if any jobs or nodes are specified set to look for all users if none
+	   are set */
+	if(!job_cond->userid_list || !list_count(job_cond->userid_list)) 
+		if((job_cond->step_list && list_count(job_cond->step_list)) 
+		   || job_cond->used_nodes)
+			all_users=1;      
+
 	if(all_users) {
 		if(job_cond->userid_list && list_count(job_cond->userid_list)) {
 			list_destroy(job_cond->userid_list);
-- 
GitLab