diff --git a/Makefile.in b/Makefile.in
index 53a70e7496c97e6345f96154b33038b5fb02f699..66e0b4264c07d642d00cda8e3899c4748d0cd805 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -46,6 +46,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -138,6 +139,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -161,6 +163,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -172,6 +175,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/aclocal.m4 b/aclocal.m4
index 04f307d16bbb6d06d63a04d040c545603aa31853..7f5c237ec4e46fed81900e2b2ddb1fc2717c1c16 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -7264,6 +7264,7 @@ m4_include([auxdir/x_ac__system_configuration.m4])
 m4_include([auxdir/x_ac_affinity.m4])
 m4_include([auxdir/x_ac_aix.m4])
 m4_include([auxdir/x_ac_bluegene.m4])
+m4_include([auxdir/x_ac_databases.m4])
 m4_include([auxdir/x_ac_debug.m4])
 m4_include([auxdir/x_ac_elan.m4])
 m4_include([auxdir/x_ac_federation.m4])
diff --git a/auxdir/Makefile.in b/auxdir/Makefile.in
index 1c0a2f38c283f1f75ef9086687b630141b152e4d..43d879f3046004ac6177a19eb26d16e77e60f205 100644
--- a/auxdir/Makefile.in
+++ b/auxdir/Makefile.in
@@ -42,6 +42,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -101,6 +102,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -124,6 +126,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -135,6 +138,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/auxdir/x_ac_databases.m4 b/auxdir/x_ac_databases.m4
new file mode 100644
index 0000000000000000000000000000000000000000..d38df310a9b8f871d0353f73c38aec658cc231aa
--- /dev/null
+++ b/auxdir/x_ac_databases.m4
@@ -0,0 +1,101 @@
+##*****************************************************************************
+## $Id: x_ac_databases.m4 5401 2005-09-22 01:56:49Z da $
+##*****************************************************************************
+#  AUTHOR:
+#    Danny Auble  <da@llnl.gov>
+#
+#  SYNOPSIS:
+#    X_AC_DATABASES
+#
+#  DESCRIPTION:
+#    Test for Different Database apis. If found define appropriate ENVs. 
+##*****************************************************************************
+
+AC_DEFUN([X_AC_DATABASES],
+[
+	#Check for MySQL
+	ac_have_mysql="no"
+	AC_CHECK_HEADERS(mysql/mysql.h,
+			 [has_mysql_header="true"],
+			 [has_mysql_header="false"])
+   	if test "$has_mysql_header" = "true"; then	
+      		AC_CHECK_LIB(mysqlclient, mysql_init, [has_mysql_lib="true"], [has_mysql_lib="false"])
+      		if test "$has_mysql_lib" = "true"; then
+               		MYSQL_LIBS=" -lmysqlclient -lz"
+        		save_LIBS="$LIBS"
+        		LIBS="$MYSQL_LIBS $save_LIBS"
+        		AC_TRY_LINK([
+          			#include <mysql/mysql.h>
+        			],[
+          			int main()
+          			{
+					MYSQL mysql;
+            				(void) mysql_init(&mysql);
+					(void) mysql_close(&mysql);
+            		        }
+        		], [ac_have_mysql="yes"], [ac_have_mysql="no"])
+			LIBS="$save_LIBS"
+        		if test "$ac_have_mysql" == "yes"; then
+            			AC_MSG_RESULT([MySQL test program built properly.])
+            			AC_SUBST(MYSQL_LIBS)
+				AC_DEFINE(HAVE_MYSQL, 1, [Define to 1 if using MySQL libaries])
+	        	else
+        			AC_MSG_WARN([*** MySQL test program execution failed.])
+			fi        	
+      		else
+        		AC_MSG_WARN(mysqlclient lib not found: mysql support not available)
+      		fi
+   	else
+      		AC_MSG_WARN(mysql/mysql.h header not found: mysql support not available)
+   	fi 
+
+	#Check for PostgreSQL
+	ac_have_pgsql="no"
+	### Check for pkg-config program
+    	AC_PATH_PROG(HAVEPGCONFIG, pg_config, no)
+	if test x$HAVEPGCONFIG = xno; then
+        	AC_MSG_WARN([*** pg_config not found. Evidently no PostgreSQL install on system.])
+	else
+		PGSQL_INCLUDEDIR=`$HAVEPGCONFIG --includedir`
+		PGSQL_LIBDIR=`$HAVEPGCONFIG --libdir`
+		PGSQL_CFLAGS="-I$PGSQL_INCLUDEDIR -L$PGSQL_LIBDIR" 
+		save_CFLAGS="$CFLAGS"
+        	CFLAGS="$PGSQL_CFLAGS $save_CFLAGS"
+                
+		AC_CHECK_HEADERS($PGSQL_INCLUDEDIR/libpq-fe.h,
+			 [has_pgsql_header="true"],
+			 [has_pgsql_header="false"])
+	   	if test "$has_pgsql_header" = "true"; then	
+			AC_CHECK_LIB(pq, PQconnectdb, [has_pgsql_lib="true"], [has_pgsql_lib="false"])
+			if test "$has_pgsql_lib" = "true"; then
+       				PGSQL_LIBS=" -lpq"
+	       			save_LIBS="$LIBS"
+        			LIBS="$PGSQL_LIBS $save_LIBS"
+       				AC_TRY_LINK([
+      					#include <libpq-fe.h>
+      					],[
+          				int main()
+       	  				{
+						PGconn     *conn;
+						conn = PQconnectdb("dbname = postgres");
+       						(void) PQfinish(conn);
+            			        }
+        			], [ac_have_pgsql="yes"], [ac_have_pgsql="no"])
+				LIBS="$save_LIBS"
+       				if test "$ac_have_pgsql" == "yes"; then
+    					AC_MSG_RESULT([PostgreSQL test program built properly.])
+            				AC_SUBST(PGSQL_LIBS)
+					AC_SUBST(PGSQL_CFLAGS)
+					AC_DEFINE(HAVE_PGSQL, 1, [Define to 1 if using PostgreSQL libaries])
+		        	else	
+       					AC_MSG_WARN([*** PostgreSQL test program execution failed.])
+				fi        	
+      			else
+        			AC_MSG_WARN(libpq not found: PostgreSQL support not available)
+			fi			
+   		else	
+			AC_MSG_WARN(libpq-fe.h header not found: PostgreSQL support not available)
+  		fi 
+		CFLAGS="$save_CFLAGS"
+       	fi
+])
diff --git a/auxdir/x_ac_gtk.m4 b/auxdir/x_ac_gtk.m4
index 827d28a13c2d3ff0a9cefd9e4fba9fc5a2a87b2e..cdd4d779885ecf03a7f8e1e473a3411e20b596cd 100644
--- a/auxdir/x_ac_gtk.m4
+++ b/auxdir/x_ac_gtk.m4
@@ -18,8 +18,8 @@ AC_DEFUN([X_AC_GTK],
     ac_have_gtk="yes"
 
 ### Check for pkg-config program
-    AC_PATH_PROG(HAVEPKGCONFIG, pkg-config, $PATH)
-    if test -z "$HAVEPKGCONFIG"; then
+    AC_PATH_PROG(HAVEPKGCONFIG, pkg-config, no)
+    if test x$HAVEPKGCONFIG = xno; then
         AC_MSG_WARN([*** pkg-config not found. Cannot probe for libglade-2.0 or gtk+-2.0.])
         ac_have_gtk="no"
     fi
diff --git a/config.h.in b/config.h.in
index f470066dff338d9754fd1066aa10cc33d68ee3c8..760131f7186f93ed1ed4263843d659c844f0bba5 100644
--- a/config.h.in
+++ b/config.h.in
@@ -98,6 +98,12 @@
 /* Define to 1 if you have the `mtrace' function. */
 #undef HAVE_MTRACE
 
+/* Define to 1 if using MySQL libaries */
+#undef HAVE_MYSQL
+
+/* Define to 1 if you have the <mysql/mysql.h> header file. */
+#undef HAVE_MYSQL_MYSQL_H
+
 /* Define to 1 if you have the <ncurses.h> header file. */
 #undef HAVE_NCURSES_H
 
@@ -113,6 +119,9 @@
 /* Define to 1 if you have the <pam/pam_appl.h> header file. */
 #undef HAVE_PAM_PAM_APPL_H
 
+/* Define to 1 if using PostgreSQL libaries */
+#undef HAVE_PGSQL
+
 /* define if plpa library installed */
 #undef HAVE_PLPA
 
diff --git a/configure b/configure
index e4fc8bcfdb4dfe6987877cfcf24f9f67bf15daa1..2e4f7671874dc995f6eb927a9db109eff4de8265 100755
--- a/configure
+++ b/configure
@@ -924,6 +924,10 @@ GTK2_CFLAGS
 GTK2_LIBS
 HAVE_GTK_TRUE
 HAVE_GTK_FALSE
+MYSQL_LIBS
+HAVEPGCONFIG
+PGSQL_LIBS
+PGSQL_CFLAGS
 DEBUG_MODULES_TRUE
 DEBUG_MODULES_FALSE
 SLURMCTLD_PORT
@@ -7085,7 +7089,7 @@ ia64-*-hpux*)
   ;;
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 7088 "configure"' > conftest.$ac_ext
+  echo '#line 7092 "configure"' > conftest.$ac_ext
   if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -8865,11 +8869,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8868: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8872: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:8872: \$? = $ac_status" >&5
+   echo "$as_me:8876: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -9133,11 +9137,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:9136: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:9140: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:9140: \$? = $ac_status" >&5
+   echo "$as_me:9144: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -9237,11 +9241,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:9240: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:9244: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:9244: \$? = $ac_status" >&5
+   echo "$as_me:9248: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -11534,7 +11538,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 11537 "configure"
+#line 11541 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11634,7 +11638,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 11637 "configure"
+#line 11641 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -13970,11 +13974,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:13973: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:13977: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:13977: \$? = $ac_status" >&5
+   echo "$as_me:13981: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -14074,11 +14078,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:14077: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:14081: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:14081: \$? = $ac_status" >&5
+   echo "$as_me:14085: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -15635,11 +15639,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:15638: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:15642: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:15642: \$? = $ac_status" >&5
+   echo "$as_me:15646: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -15739,11 +15743,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:15742: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:15746: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:15746: \$? = $ac_status" >&5
+   echo "$as_me:15750: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -17926,11 +17930,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:17929: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:17933: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:17933: \$? = $ac_status" >&5
+   echo "$as_me:17937: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -18194,11 +18198,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:18197: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:18201: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:18201: \$? = $ac_status" >&5
+   echo "$as_me:18205: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -18298,11 +18302,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:18301: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:18305: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:18305: \$? = $ac_status" >&5
+   echo "$as_me:18309: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -24516,7 +24520,7 @@ done
 done
 IFS=$as_save_IFS
 
-  test -z "$ac_cv_path_HAVEPKGCONFIG" && ac_cv_path_HAVEPKGCONFIG="$PATH"
+  test -z "$ac_cv_path_HAVEPKGCONFIG" && ac_cv_path_HAVEPKGCONFIG="no"
   ;;
 esac
 fi
@@ -24530,7 +24534,7 @@ echo "${ECHO_T}no" >&6; }
 fi
 
 
-    if test -z "$HAVEPKGCONFIG"; then
+    if test x$HAVEPKGCONFIG = xno; then
         { echo "$as_me:$LINENO: WARNING: *** pkg-config not found. Cannot probe for libglade-2.0 or gtk+-2.0." >&5
 echo "$as_me: WARNING: *** pkg-config not found. Cannot probe for libglade-2.0 or gtk+-2.0." >&2;}
         ac_have_gtk="no"
@@ -24657,6 +24661,645 @@ fi
 
 
 
+	#Check for MySQL
+	ac_have_mysql="no"
+
+for ac_header in mysql/mysql.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+ has_mysql_header="true"
+else
+  has_mysql_header="false"
+fi
+
+done
+
+   	if test "$has_mysql_header" = "true"; then
+      		{ echo "$as_me:$LINENO: checking for mysql_init in -lmysqlclient" >&5
+echo $ECHO_N "checking for mysql_init in -lmysqlclient... $ECHO_C" >&6; }
+if test "${ac_cv_lib_mysqlclient_mysql_init+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lmysqlclient  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char mysql_init ();
+int
+main ()
+{
+return mysql_init ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_lib_mysqlclient_mysql_init=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_lib_mysqlclient_mysql_init=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_mysqlclient_mysql_init" >&5
+echo "${ECHO_T}$ac_cv_lib_mysqlclient_mysql_init" >&6; }
+if test $ac_cv_lib_mysqlclient_mysql_init = yes; then
+  has_mysql_lib="true"
+else
+  has_mysql_lib="false"
+fi
+
+      		if test "$has_mysql_lib" = "true"; then
+               		MYSQL_LIBS=" -lmysqlclient -lz"
+        		save_LIBS="$LIBS"
+        		LIBS="$MYSQL_LIBS $save_LIBS"
+        		cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+          			#include <mysql/mysql.h>
+
+int
+main ()
+{
+
+          			int main()
+          			{
+					MYSQL mysql;
+            				(void) mysql_init(&mysql);
+					(void) mysql_close(&mysql);
+            		        }
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_have_mysql="yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_have_mysql="no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+			LIBS="$save_LIBS"
+        		if test "$ac_have_mysql" == "yes"; then
+            			{ echo "$as_me:$LINENO: result: MySQL test program built properly." >&5
+echo "${ECHO_T}MySQL test program built properly." >&6; }
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_MYSQL 1
+_ACEOF
+
+	        	else
+        			{ echo "$as_me:$LINENO: WARNING: *** MySQL test program execution failed." >&5
+echo "$as_me: WARNING: *** MySQL test program execution failed." >&2;}
+			fi
+      		else
+        		{ echo "$as_me:$LINENO: WARNING: mysqlclient lib not found: mysql support not available" >&5
+echo "$as_me: WARNING: mysqlclient lib not found: mysql support not available" >&2;}
+      		fi
+   	else
+      		{ echo "$as_me:$LINENO: WARNING: mysql/mysql.h header not found: mysql support not available" >&5
+echo "$as_me: WARNING: mysql/mysql.h header not found: mysql support not available" >&2;}
+   	fi
+
+	#Check for PostgreSQL
+	ac_have_pgsql="no"
+	### Check for pkg-config program
+    	# Extract the first word of "pg_config", so it can be a program name with args.
+set dummy pg_config; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_path_HAVEPGCONFIG+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $HAVEPGCONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_HAVEPGCONFIG="$HAVEPGCONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_HAVEPGCONFIG="$as_dir/$ac_word$ac_exec_ext"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+  test -z "$ac_cv_path_HAVEPGCONFIG" && ac_cv_path_HAVEPGCONFIG="no"
+  ;;
+esac
+fi
+HAVEPGCONFIG=$ac_cv_path_HAVEPGCONFIG
+if test -n "$HAVEPGCONFIG"; then
+  { echo "$as_me:$LINENO: result: $HAVEPGCONFIG" >&5
+echo "${ECHO_T}$HAVEPGCONFIG" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+	if test x$HAVEPGCONFIG = xno; then
+        	{ echo "$as_me:$LINENO: WARNING: *** pg_config not found. Evidently no PostgreSQL install on system." >&5
+echo "$as_me: WARNING: *** pg_config not found. Evidently no PostgreSQL install on system." >&2;}
+	else
+		PGSQL_INCLUDEDIR=`$HAVEPGCONFIG --includedir`
+		PGSQL_LIBDIR=`$HAVEPGCONFIG --libdir`
+		PGSQL_CFLAGS="-I$PGSQL_INCLUDEDIR -L$PGSQL_LIBDIR"
+		save_CFLAGS="$CFLAGS"
+        	CFLAGS="$PGSQL_CFLAGS $save_CFLAGS"
+
+
+for ac_header in $PGSQL_INCLUDEDIR/libpq-fe.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+ has_pgsql_header="true"
+else
+  has_pgsql_header="false"
+fi
+
+done
+
+	   	if test "$has_pgsql_header" = "true"; then
+			{ echo "$as_me:$LINENO: checking for PQconnectdb in -lpq" >&5
+echo $ECHO_N "checking for PQconnectdb in -lpq... $ECHO_C" >&6; }
+if test "${ac_cv_lib_pq_PQconnectdb+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lpq  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char PQconnectdb ();
+int
+main ()
+{
+return PQconnectdb ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_lib_pq_PQconnectdb=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_lib_pq_PQconnectdb=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_pq_PQconnectdb" >&5
+echo "${ECHO_T}$ac_cv_lib_pq_PQconnectdb" >&6; }
+if test $ac_cv_lib_pq_PQconnectdb = yes; then
+  has_pgsql_lib="true"
+else
+  has_pgsql_lib="false"
+fi
+
+			if test "$has_pgsql_lib" = "true"; then
+       				PGSQL_LIBS=" -lpq"
+	       			save_LIBS="$LIBS"
+        			LIBS="$PGSQL_LIBS $save_LIBS"
+       				cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+      					#include <libpq-fe.h>
+
+int
+main ()
+{
+
+          				int main()
+       	  				{
+						PGconn     *conn;
+						conn = PQconnectdb("dbname = postgres");
+       						(void) PQfinish(conn);
+            			        }
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_have_pgsql="yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_have_pgsql="no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+				LIBS="$save_LIBS"
+       				if test "$ac_have_pgsql" == "yes"; then
+    					{ echo "$as_me:$LINENO: result: PostgreSQL test program built properly." >&5
+echo "${ECHO_T}PostgreSQL test program built properly." >&6; }
+
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_PGSQL 1
+_ACEOF
+
+		        	else
+       					{ echo "$as_me:$LINENO: WARNING: *** PostgreSQL test program execution failed." >&5
+echo "$as_me: WARNING: *** PostgreSQL test program execution failed." >&2;}
+				fi
+      			else
+        			{ echo "$as_me:$LINENO: WARNING: libpq not found: PostgreSQL support not available" >&5
+echo "$as_me: WARNING: libpq not found: PostgreSQL support not available" >&2;}
+			fi
+   		else
+			{ echo "$as_me:$LINENO: WARNING: libpq-fe.h header not found: PostgreSQL support not available" >&5
+echo "$as_me: WARNING: libpq-fe.h header not found: PostgreSQL support not available" >&2;}
+  		fi
+		CFLAGS="$save_CFLAGS"
+       	fi
+
+
+
 
 
 
@@ -25890,7 +26533,7 @@ _ACEOF
 
 
 
-ac_config_files="$ac_config_files Makefile config.xml auxdir/Makefile src/Makefile src/api/Makefile src/common/Makefile src/sacct/Makefile src/salloc/Makefile src/sbatch/Makefile src/sattach/Makefile src/srun/Makefile src/slaunch/Makefile src/slurmd/Makefile src/slurmd/slurmd/Makefile src/slurmd/slurmstepd/Makefile src/slurmctld/Makefile src/sbcast/Makefile src/scontrol/Makefile src/scancel/Makefile src/squeue/Makefile src/sinfo/Makefile src/smap/Makefile src/strigger/Makefile src/sview/Makefile src/plugins/Makefile src/plugins/auth/Makefile src/plugins/auth/authd/Makefile src/plugins/auth/munge/Makefile src/plugins/auth/none/Makefile src/plugins/checkpoint/Makefile src/plugins/checkpoint/aix/Makefile src/plugins/checkpoint/none/Makefile src/plugins/jobacct/Makefile src/plugins/jobacct/linux/Makefile src/plugins/jobacct/aix/Makefile src/plugins/jobacct/none/Makefile src/plugins/jobcomp/Makefile src/plugins/jobcomp/filetxt/Makefile src/plugins/jobcomp/none/Makefile src/plugins/jobcomp/script/Makefile src/plugins/proctrack/Makefile src/plugins/proctrack/aix/Makefile src/plugins/proctrack/pgid/Makefile src/plugins/proctrack/linuxproc/Makefile src/plugins/proctrack/rms/Makefile src/plugins/proctrack/sgi_job/Makefile src/plugins/sched/Makefile src/plugins/sched/backfill/Makefile src/plugins/sched/builtin/Makefile src/plugins/sched/gang/Makefile src/plugins/sched/hold/Makefile src/plugins/sched/wiki/Makefile src/plugins/sched/wiki2/Makefile src/plugins/select/Makefile src/plugins/select/bluegene/Makefile src/plugins/select/bluegene/block_allocator/Makefile src/plugins/select/bluegene/plugin/Makefile src/plugins/select/linear/Makefile src/plugins/select/cons_res/Makefile src/plugins/switch/Makefile src/plugins/switch/elan/Makefile src/plugins/switch/none/Makefile src/plugins/switch/federation/Makefile src/plugins/mpi/Makefile src/plugins/mpi/mpich1_shmem/Makefile src/plugins/mpi/mpichgm/Makefile src/plugins/mpi/mvapich/Makefile src/plugins/mpi/lam/Makefile src/plugins/mpi/none/Makefile src/plugins/mpi/openmpi/Makefile src/plugins/task/Makefile src/plugins/task/affinity/Makefile src/plugins/task/none/Makefile doc/Makefile doc/man/Makefile doc/html/Makefile doc/html/configurator.html testsuite/Makefile testsuite/expect/Makefile testsuite/slurm_unit/Makefile testsuite/slurm_unit/common/Makefile testsuite/slurm_unit/slurmctld/Makefile testsuite/slurm_unit/slurmd/Makefile testsuite/slurm_unit/api/Makefile testsuite/slurm_unit/api/manual/Makefile"
+ac_config_files="$ac_config_files Makefile config.xml auxdir/Makefile src/Makefile src/api/Makefile src/common/Makefile src/sacct/Makefile src/salloc/Makefile src/sbatch/Makefile src/sattach/Makefile src/srun/Makefile src/slaunch/Makefile src/slurmd/Makefile src/slurmd/slurmd/Makefile src/slurmd/slurmstepd/Makefile src/slurmctld/Makefile src/sbcast/Makefile src/scontrol/Makefile src/scancel/Makefile src/squeue/Makefile src/sinfo/Makefile src/smap/Makefile src/strigger/Makefile src/sview/Makefile src/plugins/Makefile src/plugins/auth/Makefile src/plugins/auth/authd/Makefile src/plugins/auth/munge/Makefile src/plugins/auth/none/Makefile src/plugins/checkpoint/Makefile src/plugins/checkpoint/aix/Makefile src/plugins/checkpoint/none/Makefile src/plugins/jobacct/Makefile src/plugins/jobacct/linux/Makefile src/plugins/jobacct/aix/Makefile src/plugins/jobacct/none/Makefile src/plugins/jobcomp/Makefile src/plugins/jobcomp/filetxt/Makefile src/plugins/jobcomp/none/Makefile src/plugins/jobcomp/script/Makefile src/plugins/jobcomp/database/Makefile src/plugins/proctrack/Makefile src/plugins/proctrack/aix/Makefile src/plugins/proctrack/pgid/Makefile src/plugins/proctrack/linuxproc/Makefile src/plugins/proctrack/rms/Makefile src/plugins/proctrack/sgi_job/Makefile src/plugins/sched/Makefile src/plugins/sched/backfill/Makefile src/plugins/sched/builtin/Makefile src/plugins/sched/gang/Makefile src/plugins/sched/hold/Makefile src/plugins/sched/wiki/Makefile src/plugins/sched/wiki2/Makefile src/plugins/select/Makefile src/plugins/select/bluegene/Makefile src/plugins/select/bluegene/block_allocator/Makefile src/plugins/select/bluegene/plugin/Makefile src/plugins/select/linear/Makefile src/plugins/select/cons_res/Makefile src/plugins/switch/Makefile src/plugins/switch/elan/Makefile src/plugins/switch/none/Makefile src/plugins/switch/federation/Makefile src/plugins/mpi/Makefile src/plugins/mpi/mpich1_shmem/Makefile src/plugins/mpi/mpichgm/Makefile src/plugins/mpi/mvapich/Makefile src/plugins/mpi/lam/Makefile src/plugins/mpi/none/Makefile src/plugins/mpi/openmpi/Makefile src/plugins/task/Makefile src/plugins/task/affinity/Makefile src/plugins/task/none/Makefile src/plugins/database/Makefile src/plugins/database/flatfile/Makefile src/plugins/database/mysql/Makefile src/plugins/database/pgsql/Makefile doc/Makefile doc/man/Makefile doc/html/Makefile doc/html/configurator.html testsuite/Makefile testsuite/expect/Makefile testsuite/slurm_unit/Makefile testsuite/slurm_unit/common/Makefile testsuite/slurm_unit/slurmctld/Makefile testsuite/slurm_unit/slurmd/Makefile testsuite/slurm_unit/api/Makefile testsuite/slurm_unit/api/manual/Makefile"
 
 
 cat >confcache <<\_ACEOF
@@ -26639,6 +27282,7 @@ do
     "src/plugins/jobcomp/filetxt/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/jobcomp/filetxt/Makefile" ;;
     "src/plugins/jobcomp/none/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/jobcomp/none/Makefile" ;;
     "src/plugins/jobcomp/script/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/jobcomp/script/Makefile" ;;
+    "src/plugins/jobcomp/database/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/jobcomp/database/Makefile" ;;
     "src/plugins/proctrack/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/proctrack/Makefile" ;;
     "src/plugins/proctrack/aix/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/proctrack/aix/Makefile" ;;
     "src/plugins/proctrack/pgid/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/proctrack/pgid/Makefile" ;;
@@ -26672,6 +27316,10 @@ do
     "src/plugins/task/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/task/Makefile" ;;
     "src/plugins/task/affinity/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/task/affinity/Makefile" ;;
     "src/plugins/task/none/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/task/none/Makefile" ;;
+    "src/plugins/database/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/database/Makefile" ;;
+    "src/plugins/database/flatfile/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/database/flatfile/Makefile" ;;
+    "src/plugins/database/mysql/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/database/mysql/Makefile" ;;
+    "src/plugins/database/pgsql/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/database/pgsql/Makefile" ;;
     "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;;
     "doc/man/Makefile") CONFIG_FILES="$CONFIG_FILES doc/man/Makefile" ;;
     "doc/html/Makefile") CONFIG_FILES="$CONFIG_FILES doc/html/Makefile" ;;
@@ -26944,6 +27592,10 @@ GTK2_CFLAGS!$GTK2_CFLAGS$ac_delim
 GTK2_LIBS!$GTK2_LIBS$ac_delim
 HAVE_GTK_TRUE!$HAVE_GTK_TRUE$ac_delim
 HAVE_GTK_FALSE!$HAVE_GTK_FALSE$ac_delim
+MYSQL_LIBS!$MYSQL_LIBS$ac_delim
+HAVEPGCONFIG!$HAVEPGCONFIG$ac_delim
+PGSQL_LIBS!$PGSQL_LIBS$ac_delim
+PGSQL_CFLAGS!$PGSQL_CFLAGS$ac_delim
 DEBUG_MODULES_TRUE!$DEBUG_MODULES_TRUE$ac_delim
 DEBUG_MODULES_FALSE!$DEBUG_MODULES_FALSE$ac_delim
 SLURMCTLD_PORT!$SLURMCTLD_PORT$ac_delim
@@ -26974,7 +27626,7 @@ WITH_AUTHD_FALSE!$WITH_AUTHD_FALSE$ac_delim
 LTLIBOBJS!$LTLIBOBJS$ac_delim
 _ACEOF
 
-  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 88; then
+  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 92; then
     break
   elif $ac_last_try; then
     { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
diff --git a/configure.ac b/configure.ac
index 04d48a5c4c9c2bfeff3574ee3e7ab48ce5cf0bf8..5fde805bb864e7e3ae6a8312019a69de1286700a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -142,6 +142,8 @@ AC_SUBST(HAVE_SOME_CURSES)
 X_AC_GTK
 AM_CONDITIONAL(HAVE_GTK, test "x$ac_have_gtk" = "xyes")
 
+X_AC_DATABASES
+
 dnl checks for system services.
 dnl
 
@@ -273,6 +275,7 @@ AC_CONFIG_FILES([Makefile
 		 src/plugins/jobcomp/filetxt/Makefile
 		 src/plugins/jobcomp/none/Makefile
 		 src/plugins/jobcomp/script/Makefile
+		 src/plugins/jobcomp/database/Makefile
 		 src/plugins/proctrack/Makefile
 		 src/plugins/proctrack/aix/Makefile
 		 src/plugins/proctrack/pgid/Makefile
@@ -306,6 +309,10 @@ AC_CONFIG_FILES([Makefile
 		 src/plugins/task/Makefile
 		 src/plugins/task/affinity/Makefile
 		 src/plugins/task/none/Makefile
+		 src/plugins/database/Makefile
+		 src/plugins/database/flatfile/Makefile
+		 src/plugins/database/mysql/Makefile
+		 src/plugins/database/pgsql/Makefile
 		 doc/Makefile
 		 doc/man/Makefile
 		 doc/html/Makefile
diff --git a/doc/Makefile.in b/doc/Makefile.in
index baad136869572f252911e8801a2d37595ce3047b..f7b332c621d59fc170561f80d30ef6feef3521a2 100644
--- a/doc/Makefile.in
+++ b/doc/Makefile.in
@@ -41,6 +41,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -112,6 +113,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -135,6 +137,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -146,6 +149,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/doc/html/Makefile.am b/doc/html/Makefile.am
index e8c0ff7bc6ca3694a3c7f27993d9354ae975fbb6..d377fae47b588720a8c795ef336de180d20a255e 100644
--- a/doc/html/Makefile.am
+++ b/doc/html/Makefile.am
@@ -9,6 +9,7 @@ generated_html = \
 	checkpoint_plugins.html \
 	cons_res.html \
 	dist_plane.html \
+	databaseplugins.html \
 	documentation.html \
 	download.html \
 	faq.html \
diff --git a/doc/html/Makefile.in b/doc/html/Makefile.in
index 5fec7cc689c1c5c0da4158025fa729e703cffd13..e662ef2652cea47db60b8d2c5327537501631cd2 100644
--- a/doc/html/Makefile.in
+++ b/doc/html/Makefile.in
@@ -43,6 +43,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -111,6 +112,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -134,6 +136,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -145,6 +148,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -238,6 +243,7 @@ generated_html = \
 	checkpoint_plugins.html \
 	cons_res.html \
 	dist_plane.html \
+	databaseplugins.html \
 	documentation.html \
 	download.html \
 	faq.html \
diff --git a/doc/html/databaseplugins.shtml b/doc/html/databaseplugins.shtml
new file mode 100644
index 0000000000000000000000000000000000000000..f57e77f21f2eedfbe083220195289ecc4a247048
--- /dev/null
+++ b/doc/html/databaseplugins.shtml
@@ -0,0 +1,288 @@
+<!--#include virtual="header.txt"-->
+
+<h1><a name="top">SLURM Database Plugin API</a></h1>
+
+<h2> Overview</h2>
+<p> This document describes SLURM database plugins and the API that
+defines them. It is intended as a resource to programmers wishing to write
+their own SLURM database plugins. This is version 1 of the API.
+
+<p>SLURM database plugins must conform to the
+SLURM Plugin API with the following specifications:
+
+<p><span class="commandline">const char
+plugin_name[]="<i>full&nbsp;text&nbsp;name</i>"
+<p style="margin-left:.2in">
+A free-formatted ASCII text string that identifies the plugin.
+
+<p><span class="commandline">const char
+plugin_type[]="<i>major/minor</i>"</span><br>
+<p style="margin-left:.2in">
+The major type must be &quot;jobacct.&quot;
+The minor type can be any suitable name
+for the type of accounting package. We currently use
+<ul>
+<li><b>flatfile</b>&#151;Information written to a flat file.
+<li><b>mysql</b>&#151; Store information in a mysql database.
+<li><b>pgsql</b>&#151; Store information in a postgresql database.
+</ul>
+<p>The programmer is urged to study 
+<span class="commandline">src/plugins/database/mysql</span>
+for a sample implementation of a SLURM database plugin.
+<p> The database plugin was written to be a generic plugin interface
+to handle any future loging by different plugins or slurm proper.  As
+of version 1 we handle job accounting and job completion records.
+When adding a new service to the database plugin one should note each
+service writes to a different database inside the database server.
+<p class="footer"><a href="#top">top</a>
+
+
+<h2>API Functions</h2>
+
+The database API uses hooks in the slurmctld.
+
+<p>All of the following functions are required. Functions which are not
+implemented must be stubbed. 
+
+<h4>Functions called by the jobacct plugin</h4>
+
+<p class="commandline">int database_p_jobacct_init(char *location) 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+database_p_jobacct_init() is called to initiate a connection to the
+database server and check the state of the database table to make sure
+they are in sync with the table definitions in the plugin.  
+Put global initialization here.
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline">location</span> (input) database name or log
+file location.
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">SLURM_SUCCESS</span> on success, or<br>
+<span class="commandline">SLURM_ERROR</span> on failure.
+
+<p class="commandline">int database_p_jobacct_fini() 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+database_p_jobacct_fini() is called at the end of the program that has
+called database_p_jobacct_init this function closes the connection to
+the database or logfile.
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline">none</span>
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">SLURM_SUCCESS</span> on success, or<br>
+<span class="commandline">SLURM_ERROR</span> on failure.
+
+<p class="commandline">
+int database_p_jobacct_job_start(struct job_record *job_ptr) 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+database_p_jobacct_job_start() is called in the jobacct plugin when a
+job starts, inserting information into the database about the new job.
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline">job_ptr</span> (input) information about the job in 
+slurmctld.
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">SLURM_SUCCESS</span> on success, or<br>
+<span class="commandline">SLURM_ERROR</span> on failure.
+
+<p class="commandline">
+int database_p_jobacct_job_complete(struct job_record *job_ptr) 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+database_p_jobacct_job_complete() is called in the jobacct plugin when
+a job completes, this updates info about end of a job.
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline">job_ptr</span> (input) information about the job in 
+slurmctld.
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">SLURM_SUCCESS</span> on success, or<br>
+<span class="commandline">SLURM_ERROR</span> on failure.
+
+<p class="commandline">
+int database_p_jobacct_step_start(struct step_record *step_ptr) 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+database_p_jobacct_step_start() is called in the jobacct plugin at the
+allocation of a new step in the slurmctld, this inserts info about the
+beginning of a step.
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline">step_ptr</span> (input) information about the step in
+slurmctld.
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">SLURM_SUCCESS</span> on success, or<br>
+<span class="commandline">SLURM_ERROR</span> on failure.
+
+<p class="commandline">
+int database_p_jobacct_step_complete(struct step_record *step_ptr) 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+database_p_jobacct_step_complete() is called in the jobacct plugin at
+the end of a step in the slurmctld, this updates the ending
+information about a step.
+<p style="margin-left:.2in"><b>Arguments</b>:<br> 
+<span class="commandline">step_ptr</span> (input) information about the step in
+slurmctld.
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">SLURM_SUCCESS</span> on success, or<br>
+<span class="commandline">SLURM_ERROR</span> on failure.
+
+<p class="commandline">
+int database_p_jobacct_suspend(struct job_record *job_ptr) 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+database_p_jobacct_suspend() is called in the jobacct plugin when a
+job is suspended or resumed in the slurmctld, this updates the
+database about the suspended time of the job. 
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline">job_ptr</span> (input) information about the job in 
+slurmctld.
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">none</span>
+
+<p class="commandline">
+void database_p_jobacct_get_jobs(List job_list, List selected_steps,
+List selected_parts, void *params) 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+database_p_jobacct_get_jobs() is called to get a list of jobs from the
+database given the specific inputs. 
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline">List job_list </span> (input/output) list to
+be filled with jobacct_job_rec_t.<br>
+<span class="commandline">List selected_steps </span>
+(input) list containing type jobacct_select_step_t to query against.<br>
+<span class="commandline">List selected_parts </span>
+(input) list containing char *'s of names of partitions to query against.<br>
+<span class="commandline">void *params </span>
+(input) to be cast as sacct_parameters_t in the plugin.
+
+<p style="margin-left:.2in">jobacct_job_rec_t, jobacct_select_step_t,
+and sacct_parameters_t are
+all defined in common/slurm_jobacct.h
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">none</span> 
+
+<p class="commandline">
+void database_p_jobacct_archive(List selected_parts, void *params) 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+database_p_jobcomp_archive() used to archive old data.
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline">List selected_parts </span>
+(input) list containing char *'s of names of partitions to query against.<br>
+<span class="commandline">void *params </span>
+(input) to be cast as sacct_parameters_t in the plugin.
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">none</span> 
+
+<p class="footer"><a href="#top">top</a>
+
+<h4>Functions called by the jobcomp plugin</h4>
+
+<p class="commandline">int database_p_jobcomp_init(char *location) 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+database_p_jobcomp_init() is called from the jobcomp plugin, 
+this opens the logfile or initializes the database to be written to.  
+Put global initialization here.
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline">location</span> (input) logfile/database name.
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">SLURM_SUCCESS</span> on success, or<br>
+<span class="commandline">SLURM_ERROR</span> on failure.
+
+<p class="commandline">int database_p_jobcomp_fini() 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+database_p_jobcomp_fini() is called from the jobcomp plugin, 
+this closes the logfile/database.  
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline">none</span>
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">SLURM_SUCCESS</span> on success, or<br>
+<span class="commandline">SLURM_ERROR</span> on failure.
+
+<p class="commandline">
+int database_p_jobcomp_get_errno() 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+database_p_jobcomp_get_errno() called in the jobcomp
+plugin.  Returns the number of a job completion logger specific error.
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline">none</span>
+<p style="margin-left:.2in"><b>Returns</b>:<br>
+Error number for the last failure encountered by the job completion
+logging plugin.
+
+<p class="commandline">
+int database_p_jobcomp_log_record(struct job_record *job_ptr) 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+database_p_jobcomp_log_record() called in the jobcomp plugin.
+Note termation of a job with the specified characteristics.</p>
+<p style="margin-left:.2in"><b>Argument</b>: <br>
+<span class="commandline">job_ptr</span> (input) Pointer to job record
+as defined in <i>src/slurmctld/slurmctld.h</i></p>
+<p style="margin-left:.2in"><b>Returns</b>: 
+<span class="commandline">SLURM_SUCCESS</span> on success, or<br>
+<span class="commandline">SLURM_ERROR</span> and set the errno to an appropriate value to indicate the reason for failure.</p>
+
+<p class="commandline">
+char *database_p_jobcomp_strerror(int errnum) 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+database_p_jobcomp_jobcomp_strerror() called in the jobcomp plugin.
+Return a string description of a job completion logger specific error code.</p>
+<p style="margin-left:.2in"><b>Arguments</b>:<br>
+<span class="commandline"> errnum</span> (input) a job completion logger
+specific error code.</p>
+<p style="margin-left:.2in"><b>Returns</b>: <br>Pointer to string
+describing the error or NULL if no description found in this plugin.</p>
+
+<p class="commandline">
+void database_p_jobcomp_get_jobs(List job_list, List selected_steps,
+List selected_parts, void *params) 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+database_p_jobcomp_get_jobs() is called to get a list of jobs from the
+database given the specific inputs. 
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline">List job_list </span> (input/output) list to
+be filled with jobcomp_job_rec_t.<br>
+<span class="commandline">List selected_steps </span>
+(input) list containing type jobacct_select_step_t to query against.<br>
+<span class="commandline">List selected_parts </span>
+(input) list containing char *'s of names of partitions to query against.<br>
+<span class="commandline">void *params </span>
+(input) to be cast as sacct_parameters_t in the plugin.
+
+<p style="margin-left:.2in">jobcomp_job_rec_t is defined in common/slurm_jobcomp.h
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">none</span> 
+
+<p class="commandline">
+void database_p_jobcomp_archive(List selected_parts, void *params) 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+database_p_jobcomp_archive() used to archive old data.
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline">List selected_parts </span>
+(input) list containing char *'s of names of partitions to query against.<br>
+<span class="commandline">void *params </span>
+(input) to be cast as sacct_parameters_t in the plugin.
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">none</span> 
+
+<p class="footer"><a href="#top">top</a>
+
+<h2>Parameters</h2>
+<p>Rather than proliferate slurm.conf parameters for new or evolved
+plugins, the database API counts on three parameters:
+<dl>
+<dt><span class="commandline">DatabaseType</span>
+<dd>Specifies which plugin should be used.
+<dt><span class="commandline">DatabaseHost</span>
+<dd>Let the plugin know the host where the database is.
+<dt><span class="commandline">DatabasePort</span>
+<dd>Let the plugin know the port to connect to.
+<dt><span class="commandline">DatabaseUser</span>
+<dd>Let the plugin know the name of the user to connect to the
+database with.
+<dt><span class="commandline">DatabasePass</span>
+<dd>Let the plugin know the password of the user connecting to the database.
+</dl>
+
+<h2>Versioning</h2>
+<p> This document describes version 1 of the SLURM Database API. Future 
+releases of SLURM may revise this API. A database plugin conveys its
+ability to implement a particular API version using the mechanism outlined
+for SLURM plugins.
+<p class="footer"><a href="#top">top</a>
+
+<p style="text-align:center;">Last modified 23 May 2007</p>
+
+<!--#include virtual="footer.txt"-->
diff --git a/doc/html/documentation.shtml b/doc/html/documentation.shtml
index b3116d20cde77da896d2d730ed328ba2d873f743..73ec5d6279a0fa91d5f73a4d058f18de1fad354c 100644
--- a/doc/html/documentation.shtml
+++ b/doc/html/documentation.shtml
@@ -39,17 +39,20 @@ Jobs throuh LSF</a></li>
 <li><a href="api.shtml">Application Programmer Interface (API) Guide</a></li>
 <li><a href="plugins.shtml">Plugin Programmer Guide</a></li>
 <li><a href="authplugins.shtml">Authentication Plugin Programmer Guide</a></li>
-<li><a href="jobacctplugins.shtml">Job Accounting Plugin Programmer Guide</a></li>
 <li><a href="checkpoint_plugins.shtml">Job Checkpoint Plugin Programmer Guild</a></li>
+<li><a href="databaseplugins.shtml">Database Plugin Programmer Guide</a></li>
+<li><a href="jobacctplugins.shtml">Job Accounting Plugin Programmer Guide</a></li>
 <li><a href="jobcompplugins.shtml">Job Completion Logging Plugin Programmer Guide</a></li>
+<li><a href="mpiplugins.shtml">MPI Plugin Programmer Guide</a></li>
+</ul>
 <li><a href="proctrack_plugins.shtml">Process Tracking Plugin Programmer Guide</a></li>
-<li><a href="selectplugins.shtml">Node Selection Plugin Programmer Guide</a></li>
 <li><a href="schedplugins.shtml">Scheduler Plugin Programmer Guide</a></li>
+<li><a href="selectplugins.shtml">Node Selection Plugin Programmer Guide</a></li>
 <li><a href="switchplugins.shtml">Switch (Interconnect) Plugin Programmer Guide</a></li>
 <li><a href="taskplugins.shtml">Task Plugin Programmer Guide</a></li>
 <li><a href="mpiplugins.shtml">MPI Plugin Programmer Guide</a></li>
 </ul>
 
-<p style="text-align:center;">Last modified 9 May 2007</p>
+<p style="text-align:center;">Last modified 21 May 2007</p>
 
 <!--#include virtual="footer.txt"-->
diff --git a/doc/html/jobacctplugins.shtml b/doc/html/jobacctplugins.shtml
index fc1cdff64462b6e800c088f7b47129a6cda582ca..8efb6c70dd9ab5a63793df17102d7726ee180e58 100644
--- a/doc/html/jobacctplugins.shtml
+++ b/doc/html/jobacctplugins.shtml
@@ -48,76 +48,76 @@ implemented must be stubbed.
 <h4>Functions called by all slurmstepd processes</h4>
 
 <p class="commandline">int jobacct_p_startpoll(int frequency) 
-<p style="margin-left:.2in"><b>Description</b>:
+<p style="margin-left:.2in"><b>Description</b>:<br>
 jobacct_p_startpoll() is called at the start of the slurmstepd, 
 this starts a thread that should poll information to be queried at any time
 during throughout the end of the process.  
 Put global initialization here.
-<p style="margin-left:.2in"><b>Arguments</b>: 
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
 <span class="commandline">frequency</span> (input) poll frequency for polling
 thread.
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">SLURM_SUCCESS</span> on success, or
-<span class="commandline">SLURM_FAILURE</span> on failure.
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">SLURM_SUCCESS</span> on success, or<br>
+<span class="commandline">SLURM_ERROR</span> on failure.
 
 <p class="commandline">int jobacct_p_endpoll() 
-<p style="margin-left:.2in"><b>Description</b>:
+<p style="margin-left:.2in"><b>Description</b>:<br>
 jobacct_p_endpoll() is called when the process is finished to stop the 
 polling thread.
-<p style="margin-left:.2in"><b>Arguments</b>: 
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
 <span class="commandline">none</span>
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">SLURM_SUCCESS</span> on success, or
-<span class="commandline">SLURM_FAILURE</span> on failure.
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">SLURM_SUCCESS</span> on success, or<br>
+<span class="commandline">SLURM_ERROR</span> on failure.
 
 <p class="commandline">void jobacct_p_suspend_poll() 
-<p style="margin-left:.2in"><b>Description</b>:
+<p style="margin-left:.2in"><b>Description</b>:<br>
 jobacct_p_suspend_poll() is called when the process is suspended.
 This causes the polling thread to halt until the process is resumed.
-<p style="margin-left:.2in"><b>Arguments</b>: 
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
 <span class="commandline">none</span>
-<p style="margin-left:.2in"><b>Returns</b>: 
+<p style="margin-left:.2in"><b>Returns</b>: <br>
 <span class="commandline">none</span>
 
 <p class="commandline">void jobacct_p_resume_poll()
-<p style="margin-left:.2in"><b>Description</b>:
+<p style="margin-left:.2in"><b>Description</b>:<br>
 jobacct_p_resume_poll() is called when the process is resumed.
 This causes the polling thread to resume operation.
-<p style="margin-left:.2in"><b>Arguments</b>:
+<p style="margin-left:.2in"><b>Arguments</b>:<br>
 <span class="commandline">none</span>
-<p style="margin-left:.2in"><b>Returns</b>:
+<p style="margin-left:.2in"><b>Returns</b>:<br>
 <span class="commandline">none</span>
 
 
 <p class="commandline">int jobacct_p_add_task(pid_t pid, uint16_t tid) 
-<p style="margin-left:.2in"><b>Description</b>:
+<p style="margin-left:.2in"><b>Description</b>:<br>
 jobacct_p_add_task() used to add a task to the poller.
-<p style="margin-left:.2in"><b>Arguments</b>: 
-<span class="commandline"> pid</span> (input) Process id  
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline"> pid</span> (input) Process id <br> 
 <span class="commandline"> tid</span> (input) slurm global task id
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">SLURM_SUCCESS</span> on success, or
-<span class="commandline">SLURM_FAILURE</span> on failure.
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">SLURM_SUCCESS</span> on success, or<br>
+<span class="commandline">SLURM_ERROR</span> on failure.
 
 <p class="commandline">jobacctinfo_t *jobacct_p_stat_task(pid_t pid) 
-<p style="margin-left:.2in"><b>Description</b>:
+<p style="margin-left:.2in"><b>Description</b>:<br>
 jobacct_p_stat_task() used to get most recent information about task.
 You need to FREE the information returned by this function!
-<p style="margin-left:.2in"><b>Arguments</b>: 
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
 <span class="commandline"> pid</span> (input) Process id  
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">jobacctinfo structure pointer</span> on success, or
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">jobacctinfo structure pointer</span> on success, or<br>
 <span class="commandline">NULL</span> on failure.
 
 <p class="commandline">jobacctinfo_t *jobacct_p_remove_task(pid_t pid) 
-<p style="margin-left:.2in"><b>Description</b>:
+<p style="margin-left:.2in"><b>Description</b>:<br>
 jobacct_p_remove_task() used to remove a task from the poller.
 You need to FREE the information returned by this function!
-<p style="margin-left:.2in"><b>Arguments</b>: 
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
 <span class="commandline"> pid</span> (input) Process id  
-<p style="margin-left:.2in"><b>Returns</b>: 
+<p style="margin-left:.2in"><b>Returns</b>: <br>
 <span class="commandline">Pointer to removed jobacctinfo_t structure</span> 
-on success, or 
+on success, or <br>
 <span class="commandline">NULL</span> on failure.
 
 <p class="footer"><a href="#top">top</a>
@@ -125,86 +125,86 @@ on success, or
 <h4>Functions called by the slurmctld process</h4>
 
 <p class="commandline">int jobacct_p_init_slurmctld(char *job_acct_log) 
-<p style="margin-left:.2in"><b>Description</b>:
+<p style="margin-left:.2in"><b>Description</b>:<br>
 jobacct_p_init_slurmctld() is called at the start of the slurmctld, 
-this opens the logfile to be written to.  
+this opens the logfile or initializes the database to be written to.  
 Put global initialization here.
-<p style="margin-left:.2in"><b>Arguments</b>: 
-<span class="commandline">job_acct_log</span> (input) logfile name.
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">SLURM_SUCCESS</span> on success, or
-<span class="commandline">SLURM_FAILURE</span> on failure.
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline">job_acct_loc</span> (input) logfile/database name.
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">SLURM_SUCCESS</span> on success, or<br>
+<span class="commandline">SLURM_ERROR</span> on failure.
 
 <p class="commandline">int jobacct_p_fini_slurmctld() 
-<p style="margin-left:.2in"><b>Description</b>:
+<p style="margin-left:.2in"><b>Description</b>:<br>
 jobacct_p_fini_slurmctld() is called at the end of the slurmctld, 
-this closes the logfile.  
-<p style="margin-left:.2in"><b>Arguments</b>: 
+this closes the logfile/database.  
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
 <span class="commandline">none</span>
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">SLURM_SUCCESS</span> on success, or
-<span class="commandline">SLURM_FAILURE</span> on failure.
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">SLURM_SUCCESS</span> on success, or<br>
+<span class="commandline">SLURM_ERROR</span> on failure.
 
 <p class="commandline">
 int jobacct_p_job_start_slurmctld(struct job_record *job_ptr) 
-<p style="margin-left:.2in"><b>Description</b>:
+<p style="margin-left:.2in"><b>Description</b>:<br>
 jobacct_p_job_start_slurmctld() is called at the allocation of a new job in 
 the slurmctld, this prints out beginning information about a job.
-<p style="margin-left:.2in"><b>Arguments</b>: 
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
 <span class="commandline">job_ptr</span> (input) information about the job in 
 slurmctld.
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">SLURM_SUCCESS</span> on success, or
-<span class="commandline">SLURM_FAILURE</span> on failure.
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">SLURM_SUCCESS</span> on success, or<br>
+<span class="commandline">SLURM_ERROR</span> on failure.
 
 <p class="commandline">
 int jobacct_p_job_complete_slurmctld(struct job_record *job_ptr) 
-<p style="margin-left:.2in"><b>Description</b>:
+<p style="margin-left:.2in"><b>Description</b>:<br>
 jobacct_p_job_complete_slurmctld() is called at the end of a job in 
 the slurmctld, this prints out ending information about a job.
-<p style="margin-left:.2in"><b>Arguments</b>: 
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
 <span class="commandline">job_ptr</span> (input) information about the job in 
 slurmctld.
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">SLURM_SUCCESS</span> on success, or
-<span class="commandline">SLURM_FAILURE</span> on failure.
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">SLURM_SUCCESS</span> on success, or<br>
+<span class="commandline">SLURM_ERROR</span> on failure.
 
 <p class="commandline">
 int jobacct_p_step_start_slurmctld(struct step_record *step_ptr) 
-<p style="margin-left:.2in"><b>Description</b>:
+<p style="margin-left:.2in"><b>Description</b>:<br>
 jobacct_p_step_start_slurmctld() is called at the allocation of a new step in 
 the slurmctld, this prints out beginning information about a step.
-<p style="margin-left:.2in"><b>Arguments</b>: 
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
 <span class="commandline">step_ptr</span> (input) information about the step in
 slurmctld.
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">SLURM_SUCCESS</span> on success, or
-<span class="commandline">SLURM_FAILURE</span> on failure.
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">SLURM_SUCCESS</span> on success, or<br>
+<span class="commandline">SLURM_ERROR</span> on failure.
 
 <p class="commandline">
 int jobacct_p_step_complete_slurmctld(struct step_record *step_ptr) 
-<p style="margin-left:.2in"><b>Description</b>:
+<p style="margin-left:.2in"><b>Description</b>:<br>
 jobacct_p_step_complete_slurmctld() is called at the end of a step in 
 the slurmctld, this prints out ending information about a step.
-<p style="margin-left:.2in"><b>Arguments</b>: 
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
 <span class="commandline">step_ptr</span> (input) information about the step in
 slurmctld.
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">SLURM_SUCCESS</span> on success, or
-<span class="commandline">SLURM_FAILURE</span> on failure.
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">SLURM_SUCCESS</span> on success, or<br>
+<span class="commandline">SLURM_ERROR</span> on failure.
 
 <p class="commandline">
 int jobacct_p_suspend_slurmctld(struct job_record *job_ptr) 
-<p style="margin-left:.2in"><b>Description</b>:
+<p style="margin-left:.2in"><b>Description</b>:<br>
 jobacct_p_suspend_slurmctld() is called when a job is suspended or resumed in 
 the slurmctld, this prints out information about the suspension of the job 
-to the logfile.
-<p style="margin-left:.2in"><b>Arguments</b>: 
+to the logfile/database.
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
 <span class="commandline">job_ptr</span> (input) information about the job in 
 slurmctld.
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">SLURM_SUCCESS</span> on success, or
-<span class="commandline">SLURM_FAILURE</span> on failure.
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">SLURM_SUCCESS</span> on success, or<br>
+<span class="commandline">SLURM_ERROR</span> on failure.
 
 <p class="footer"><a href="#top">top</a>
 
@@ -212,126 +212,126 @@ slurmctld.
 
 <p class="commandline">
 int jobacct_p_init_struct(jobacctinfo_t *jobacct, uint16_t tid) 
-<p style="margin-left:.2in"><b>Description</b>:
+<p style="margin-left:.2in"><b>Description</b>:<br>
 jobacct_p_init_struct() is called to set the values of a jobacctinfo_t to
 initial values.
-<p style="margin-left:.2in"><b>Arguments</b>: 
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
 <span class="commandline">jobacct</span> 
-(input/output) structure to be altered.
+(input/output) structure to be altered.<br>
 <span class="commandline">tid</span> 
-(input) id of the task send in (uint16_t)NO_VAL if no specfic task.
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">SLURM_SUCCESS</span> on success, or
-<span class="commandline">SLURM_FAILURE</span> on failure.
+(input) id of the task send in (uint16_t)NO_VAL if no specfic task.<br>
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">SLURM_SUCCESS</span> on success, or<br>
+<span class="commandline">SLURM_ERROR</span> on failure.
 
 <p class="commandline">jobacctinfo_t *jobacct_p_alloc(uint16_t tid) 
-<p style="margin-left:.2in"><b>Description</b>:
+<p style="margin-left:.2in"><b>Description</b>:<br>
 jobacct_p_alloc() used to alloc a pointer to and initialize a 
-new jobacctinfo structure.<br>
+new jobacctinfo structure.<br><br>
 You will need to free the information returned by this function!
-<p style="margin-left:.2in"><b>Arguments</b>: 
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
 <span class="commandline">tid</span> 
 (input) id of the task send in (uint16_t)NO_VAL if no specfic task.
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">jobacctinfo structure pointer</span> on success, or
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">jobacctinfo structure pointer</span> on success, or<br>
 <span class="commandline">NULL</span> on failure.
 
 <p class="commandline">void jobacct_p_free(jobacctinfo_t *jobacct) 
-<p style="margin-left:.2in"><b>Description</b>:
+<p style="margin-left:.2in"><b>Description</b>:<br>
 jobacct_p_free() used to free the allocation made by jobacct_p_alloc().
-<p style="margin-left:.2in"><b>Arguments</b>: 
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
 <span class="commandline">jobacct</span> 
-(input) structure to be freed.
+(input) structure to be freed.<br>
 <span class="commandline">none</span>
-<p style="margin-left:.2in"><b>Returns</b>: 
+<p style="margin-left:.2in"><b>Returns</b>: <br>
 <span class="commandline">none</span>
 
 <p class="commandline">
 int jobacct_p_setinfo(jobacctinfo_t *jobacct, 
                       enum jobacct_data_type type, void *data) 
-<p style="margin-left:.2in"><b>Description</b>:
+<p style="margin-left:.2in"><b>Description</b>:<br>
 jobacct_p_setinfo() is called to set the values of a jobacctinfo_t to
 specific values based on inputs.
-<p style="margin-left:.2in"><b>Arguments</b>: 
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
 <span class="commandline">jobacct</span> 
-(input/output) structure to be altered.
+(input/output) structure to be altered.<br>
 <span class="commandline">type</span> 
-(input) enum of specific part of jobacct to alter.
+(input) enum of specific part of jobacct to alter.<br>
 <span class="commandline">data</span> 
 (input) corresponding data to set jobacct part to.
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">SLURM_SUCCESS</span> on success, or
-<span class="commandline">SLURM_FAILURE</span> on failure.
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">SLURM_SUCCESS</span> on success, or<br>
+<span class="commandline">SLURM_ERROR</span> on failure.
 
 <p class="commandline">
 int jobacct_p_getinfo(jobacctinfo_t *jobacct, 
                       enum jobacct_data_type type, void *data) 
-<p style="margin-left:.2in"><b>Description</b>:
+<p style="margin-left:.2in"><b>Description</b>:<br>
 jobacct_p_getinfo() is called to get the values of a jobacctinfo_t
 specific values based on inputs.
-<p style="margin-left:.2in"><b>Arguments</b>: 
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
 <span class="commandline">jobacct</span> 
-(input) structure to be queried.
+(input) structure to be queried.<br>
 <span class="commandline">type</span> 
-(input) enum of specific part of jobacct to get.
+(input) enum of specific part of jobacct to get.<br>
 <span class="commandline">data</span> 
 (output) corresponding data to from jobacct part.
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">SLURM_SUCCESS</span> on success, or
-<span class="commandline">SLURM_FAILURE</span> on failure.
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">SLURM_SUCCESS</span> on success, or<br>
+<span class="commandline">SLURM_ERROR</span> on failure.
 
 <p class="commandline">
 void jobacct_p_aggregate(jobacctinfo_t *dest, jobacctinfo_t *from) 
-<p style="margin-left:.2in"><b>Description</b>:
+<p style="margin-left:.2in"><b>Description</b>:<br>
 jobacct_p_aggregate() is called to aggregate and get max values from two 
 different jobacctinfo structures.
-<p style="margin-left:.2in"><b>Arguments</b>: 
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
 <span class="commandline">dest</span> 
-(input/output) initial structure to be applied to.
+(input/output) initial structure to be applied to.<br>
 <span class="commandline">from</span> 
 (input) new info to apply to dest.
-<p style="margin-left:.2in"><b>Returns</b>: 
+<p style="margin-left:.2in"><b>Returns</b>: <br>
 <span class="commandline">none</span>
 
 <p class="commandline">
 void jobacct_p_2_sacct(sacct_t *sacct, jobacctinfo_t *jobacct) 
-<p style="margin-left:.2in"><b>Description</b>:
+<p style="margin-left:.2in"><b>Description</b>:<br>
 jobacct_p_2_sacct() is called to transfer information from data structure 
 jobacct to structure sacct.
-<p style="margin-left:.2in"><b>Arguments</b>: 
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
 <span class="commandline">sacct</span> 
-(input/output) initial structure to be applied to.
+(input/output) initial structure to be applied to.<br>
 <span class="commandline">jobacct</span> 
 (input) jobacctinfo_t structure containing information to apply to sacct.
-<p style="margin-left:.2in"><b>Returns</b>: 
+<p style="margin-left:.2in"><b>Returns</b>: <br>
 <span class="commandline">none</span>
 
 <p class="commandline">
 void jobacct_p_pack(jobacctinfo_t *jobacct, Buf buffer) 
-<p style="margin-left:.2in"><b>Description</b>:
+<p style="margin-left:.2in"><b>Description</b>:<br>
 jobacct_p_pack() pack jobacctinfo_t in a buffer to send across the network.
-<p style="margin-left:.2in"><b>Arguments</b>: 
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
 <span class="commandline">jobacct</span> 
-(input) structure to pack.
+(input) structure to pack.<br>
 <span class="commandline">buffer</span> 
 (input/output) buffer to pack structure into.
-<p style="margin-left:.2in"><b>Returns</b>: 
+<p style="margin-left:.2in"><b>Returns</b>: <br>
 <span class="commandline">none</span>
 
 <p class="commandline">
 void jobacct_p_unpack(jobacctinfo_t *jobacct, Buf buffer) 
-<p style="margin-left:.2in"><b>Description</b>:
+<p style="margin-left:.2in"><b>Description</b>:<br>
 jobacct_p_unpack() unpack jobacctinfo_t from a buffer received from 
 the network.
 You will need to free the jobacctinfo_t returned by this function!
-<p style="margin-left:.2in"><b>Arguments</b>: 
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
 <span class="commandline">jobacct</span> 
-(input/output) structure to fill.
+(input/output) structure to fill.<br>
 <span class="commandline">buffer</span> 
-(input) buffer to unpack structure from.
+(input) buffer to unpack structure from.<br>
 <p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">SLURM_SUCCESS</span> on success, or
-<span class="commandline">SLURM_FAILURE</span> on failure.
+<span class="commandline">SLURM_SUCCESS</span> on success, or<br>
+<span class="commandline">SLURM_ERROR</span> on failure.
 
 <p class="footer"><a href="#top">top</a>
 
@@ -343,8 +343,8 @@ plugins, the job accounting API counts on three parameters:
 <dd>Specifies which plugin should be used.
 <dt><span class="commandline">JobAcctFrequency</span>
 <dd>Let the plugin know how long between pollings.
-<dt><span class="commandline">JobAcctLogFile</span>
-<dd>Let the plugin the name of the logfile to use.
+<dt><span class="commandline">JobAcctLoc</span>
+<dd>Let the plugin the name of the logfile/database name to use.
 </dl>
 
 <h2>Versioning</h2>
@@ -354,6 +354,6 @@ ability to implement a particular API version using the mechanism outlined
 for SLURM plugins.
 <p class="footer"><a href="#top">top</a>
 
-<p style="text-align:center;">Last modified 31 January 2007</p>
+<p style="text-align:center;">Last modified 21 May 2007</p>
 
 <!--#include virtual="footer.txt"-->
diff --git a/doc/html/jobcompplugins.shtml b/doc/html/jobcompplugins.shtml
index 93f21b5bc070e429d4f43c35431cc23f64301048..2b2e44869d39b07fead750ac224d4409679f5485 100644
--- a/doc/html/jobcompplugins.shtml
+++ b/doc/html/jobcompplugins.shtml
@@ -15,17 +15,21 @@ The major type must be &quot;jobcomp.&quot; The minor type can be any recognizab
 abbreviation for the type of scheduler. We recommend, for example:</p>
 <ul>
 <li><b>none</b>&#151;No job logging.</li>
+<li><b>database</b>&#151;Job completion is written to a database
+decided by the <a href=databaseplugins.html>Database plugin</a>.</li>
 <li><b>filetxt</b>&#151;Log job information to a text file.</li>
 <li><b>script</b>&#151;Execute a script passing in job information in environment variables.</li>
 </ul>
+The <b>sacct</b> program with option <b>-c</b> can be used to display
+gathered data from database and filetxt plugins.
 <p>The <span class="commandline">plugin_name</span> and 
 <span class="commandline">plugin_version</span> 
 symbols required by the SLURM Plugin API require no specialization for 
 job completion logging support. 
 Note carefully, however, the versioning discussion below.</p>
 <p>The programmer is urged to study 
-<span class="commandline">src/plugins/jobcomp/jobcomp_filetxt.c</span> and
-<span class="commandline">src/plugins/jobcomp/jobcomp_none.c</span> 
+<span class="commandline">src/plugins/jobcomp/filetxt/jobcomp_filetxt.c</span> and
+<span class="commandline">src/plugins/jobcomp/none/jobcomp_none.c</span> 
 for sample implementations of a SLURM job completion logging plugin.</p>
 <p class="footer"><a href="#top">top</a></p>
 
@@ -98,6 +102,6 @@ releases of SLURM may revise this API. A job completion plugin conveys its abili
 to implement a particular API version using the mechanism outlined for SLURM plugins.</p>
 <p class="footer"><a href="#top">top</a></p>
 
-<p style="text-align:center;">Last modified 10 July 2005</p>
+<p style="text-align:center;">Last modified 21 May 2007</p>
 
 <!--#include virtual="footer.txt"-->
diff --git a/doc/html/overview.shtml b/doc/html/overview.shtml
index 126fb45b10848b99b761f01a91ebfdb12422cd2d..184e66c5778c9a9f201191d4df7b921312f9e404 100644
--- a/doc/html/overview.shtml
+++ b/doc/html/overview.shtml
@@ -49,6 +49,8 @@ building block approach. These plugins presently include:
 
 <li><a href="checkpoint_plugins.html">Checkpoint</a>: AIX or none.</li>
 
+<li><a href="databaseplugins.html">Database type</a>: Flatfile, MySQL,
+or PGSQL</li>
 <li><a href="jobacctplugins.html">Job accounting</a>: AIX, Linux or none</li>
 
 <li><a href="jobcompplugins.html">Job completion logging</a>: text file, 
diff --git a/doc/html/programmer_guide.shtml b/doc/html/programmer_guide.shtml
index b1a765a2df1027abdd61db183d373c3e4284f2c1..a5316c776bbaa4027e818dc60be570db78921f39 100644
--- a/doc/html/programmer_guide.shtml
+++ b/doc/html/programmer_guide.shtml
@@ -97,6 +97,7 @@ subdirectory is used for each plugin class:<br>
 <li><b>auth</b> for user authentication,<br> 
 <li><b>checkpoint</b> for system-initiated checkpoint 
 and restart of user jobs,<br>
+<li><b>database</b> for specifing the type of database to use,<br>
 <li><b>jobacct</b> for job accounting,<br>
 <li><b>jobcomp</b> for job completion logging,<br>
 <li><b>mpi</b> for MPI support,<br>
diff --git a/doc/html/quickstart_admin.shtml b/doc/html/quickstart_admin.shtml
index 33a1e65629cf9317f42e7d5938d747cfad12f809..a92790f22d4fa59054a26f5b5c666e3f3a92bb4d 100644
--- a/doc/html/quickstart_admin.shtml
+++ b/doc/html/quickstart_admin.shtml
@@ -551,6 +551,10 @@ BackupAddr        = eadevj
 BackupController  = adevj
 ControlAddr       = eadevi
 ControlMachine    = adevi
+DatabaseType      = database/flatfile
+DatabaseHost      = (null)
+DatabasePort      = (null)
+DatabaseUser      = (null)
 Epilog            = (null)
 FastSchedule      = 1
 FirstJobId        = 1
@@ -581,7 +585,7 @@ SlurmdPort        = 7003
 SlurmdSpoolDir    = /tmp/slurmd
 SlurmdTimeout     = 300
 TreeWidth         = 50
-JobAcctLogFile    = /tmp/jobacct.log
+JobAcctLoc        = /tmp/jobacct.log
 JobAcctFrequncy   = 5
 JobAcctType       = jobacct/linux
 SLURM_CONFIG_FILE = /etc/slurm/slurm.conf
diff --git a/doc/html/review_release.html b/doc/html/review_release.html
index 84bd793370420bf6430f9d9d4630893b6de18dd1..c98e9d1cf6486b8f6b8437eb753f9369ef2e2a79 100644
--- a/doc/html/review_release.html
+++ b/doc/html/review_release.html
@@ -15,6 +15,7 @@
 <li><a href="http://cmg-rr.llnl.gov/linux/slurm/checkpoint_plugins.html">checkpoint_plugins.html</a></li>
 <li><a href="http://cmg-rr.llnl.gov/linux/slurm/configurator.html">configurator.html</a></li>
 <li><a href="http://cmg-rr.llnl.gov/linux/slurm/cons_res.html">cons_res.html</a></li>
+<li><a href="http://cmg-rr.llnl.gov/linux/slurm/databaseplugins.html">databaseplugins.html</a></li>
 <li><a href="http://cmg-rr.llnl.gov/linux/slurm/dist_plane.html">dist_plane.html</a></li>
 <li><a href="http://cmg-rr.llnl.gov/linux/slurm/documentation.html">documentation.html</a></li>
 <li><a href="http://cmg-rr.llnl.gov/linux/slurm/download.html">download.html</a></li>
diff --git a/doc/html/selectplugins.shtml b/doc/html/selectplugins.shtml
index 074620eb35a28482da6cb87e25c87f69bb77d36e..2cd4ba6b2d21a6d26558188715f30288a22b2274 100644
--- a/doc/html/selectplugins.shtml
+++ b/doc/html/selectplugins.shtml
@@ -154,9 +154,10 @@ the plugin should return SLURM_ERROR.</p>
 <p class="commandline">int select_p_pack_node_info (time_t last_query_time, Buf *buffer_ptr);</p>
 <p style="margin-left:.2in"><b>Description</b>: pack node specific information into a buffer.</p>
 <p style="margin-left:.2in"><b>Arguments</b>:
-<span class="commandline"> last_query_time</span>&nbsp;&nbsp;&nbsp;(input) time that the data
-was last saved. If it has not changed since this time, return SLURM_NO_CHANGE_IN_DATA. <br>
-<span class="commandline"> buffer_ptre</span>&nbsp;&nbsp;&nbsp;(input/output) buffer into 
+<span class="commandline">
+last_query_time</span>&nbsp;&nbsp;&nbsp;(input) time that the data was
+last saved.<br>
+<span class="commandline"> buffer_ptr</span>&nbsp;&nbsp;&nbsp;(input/output) buffer into 
 which the node data is appended.</p>
 <p style="margin-left:.2in"><b>Returns</b>: SLURM_SUCCESS if successful, 
 SLURM_NO_CHANGE_IN_DATA if data has not changed since last packed, otherwise SLURM_ERROR</p>
diff --git a/doc/man/Makefile.in b/doc/man/Makefile.in
index 764f460d14aaf087c3b833b4efae1c900ef27051..a4edae2acc42c69ed60afb5ec27cb336bcc751fa 100644
--- a/doc/man/Makefile.in
+++ b/doc/man/Makefile.in
@@ -41,6 +41,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -108,6 +109,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -131,6 +133,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -142,6 +145,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/doc/man/man5/slurm.conf.5 b/doc/man/man5/slurm.conf.5
index fe153d07056daea507db3c6a661ce385255627f2..ee08f106a82cb95a1abddaa64edabdd57b488597 100644
--- a/doc/man/man5/slurm.conf.5
+++ b/doc/man/man5/slurm.conf.5
@@ -101,6 +101,32 @@ This should be a node name without the full domain name (e.g. "lx0001").
 This value must be specified.
 See  the \fBRELOCATING CONTROLLERS\fR section if you change this.
 
+.TP
+\fBDatabaseType\fR
+Define the type of database to be used for various plugins that will
+write to the database. 
+The slurmctld daemon must be restarted for a change in DatabaseType 
+to take effect. 
+Acceptable values at present include "database/flatfile",
+"database/mysql", and "database/pgsql". 
+The default value is "database/flatfile".
+.TP
+\fBDatabaseHost\fR
+Define the Host the database server is running on.
+For database/flatfile this parameter is ignored.
+.TP
+\fBDatabasePort\fR
+Define the Port of the database server to connect to.
+For database/flatfile this parameter is ignored.
+.TP
+\fBDatabasePass\fR
+Define the Password to use to connect to the database server.
+For database/flatfile this parameter is ignored.
+.TP
+\fBDatabaseUser\fR
+Define the User to use to connect to the database server.
+For database/flatfile this parameter is ignored.
+
 .TP
 \fBEpilog\fR
 Fully qualified pathname of a script to execute as user root on every 
@@ -175,8 +201,9 @@ In order to use the \fBsacct\fR tool, "jobacct/aix" or "jobacct/linux"
 must be configured.
 
 .TP
-\fBJobAcctLogFile\fR
-Define the location where job accounting logs are to be written.
+\fBJobAcctLoc\fR
+Define the location where job accounting logs are to be written either
+a filename or a database name.
 For jobacct/none this parameter is ignored.
 For jobacct/linux this is the fully\-qualified file name for the data file.
 
@@ -189,17 +216,21 @@ For jobacct/linux the parameter is a number is seconds between polls.
 .TP
 \fBJobCompLoc\fR
 The interpretation of this value depends upon the logging mechanism 
-specified by the \fBJobCompType\fR parameter. 
+specified by the \fBJobCompType\fR parameter either a filename or a 
+database name. 
 
 .TP
 \fBJobCompType\fR
 Define the job completion logging mechanism type.
 Acceptable values at present include "jobcomp/none", "jobcomp/filetxt", 
-and "jobcomp/script".
+"jobcomp/database", and "jobcomp/script".
 The default value is "jobcomp/none", which means that upon job completion 
 the record of the job is purged from the system. 
 The value "jobcomp/filetxt" indicates that a record of the job should be 
 written to a text file specified by the \fBJobCompLoc\fR parameter.
+The value "jobcomp/database" indicates that a record of the job should be 
+written to a database specified by the \fBJobCompLoc\fR parameter, the
+database type must be set up by the \fBDatabaseType\fR parameter.
 The value "jobcomp/script" indicates that a script specified by the 
 \fBJobCompLoc\fR parameter is to be executed with environment variables 
 indicating the job information.
diff --git a/etc/slurm.conf.example b/etc/slurm.conf.example
index 9d48acbc59346500a841d5a7e1dff2634b5ff52d..000432c86466d92ef34e5d60eda1b313fafc5f51 100644
--- a/etc/slurm.conf.example
+++ b/etc/slurm.conf.example
@@ -69,8 +69,13 @@ SlurmdDebug=3
 JobCompType=jobcomp/none
 #JobCompLoc=
 JobAcctType=jobacct/none
-#JobAcctLogfile=
+#JobAcctLoc=
 #JobAcctFrequency=
+DatabaseType=database/flatfile
+#DatabaseHost=localhost
+#DatabasePort=1234
+#DatabaseUser=mysql
+#DatabasePass=mysql
 #
 # COMPUTE NODES
 NodeName=linux[1-32] Procs=1 State=UNKNOWN
diff --git a/slurm.spec b/slurm.spec
index 82b40892698fab5ea94c483164d1ef779f95676b..d6650432bfac79c6d1feb5da40ce51872d9c35e6 100644
--- a/slurm.spec
+++ b/slurm.spec
@@ -249,10 +249,15 @@ rm -rf $RPM_BUILD_ROOT
 %dir %{_sysconfdir}
 %dir %{_libdir}/slurm
 %{_libdir}/slurm/checkpoint_none.so
+%{_libdir}/slurm/database_flatfile.so
+%{_libdir}/slurm/database_mysql.so
+%{_libdir}/slurm/database_pgsql.so
+%{_libdir}/slurm/jobacct_aix.so
 %{_libdir}/slurm/jobacct_linux.so
 %{_libdir}/slurm/jobacct_none.so
 %{_libdir}/slurm/jobcomp_none.so
 %{_libdir}/slurm/jobcomp_filetxt.so
+%{_libdir}/slurm/jobcomp_database.so
 %{_libdir}/slurm/jobcomp_script.so
 %{_libdir}/slurm/proctrack_pgid.so
 %{_libdir}/slurm/proctrack_linuxproc.so
diff --git a/slurm/slurm.h.in b/slurm/slurm.h.in
index f25a82e374cdba1c77a6ea3146c15707c262aa47..6045198324d772a84f2cd8534c81beb485d3af4e 100644
--- a/slurm/slurm.h.in
+++ b/slurm/slurm.h.in
@@ -859,9 +859,14 @@ typedef struct slurm_ctl_conf {
 				 * (only check configuration file, faster) */
 	uint16_t inactive_limit;/* seconds of inactivity before a
 				 * inactive resource allocation is released */
-	char *job_acct_logfile;	/* job accounting log location */
+	char *job_acct_loc;	/* job accounting log location */
 	uint16_t job_acct_freq; /* poll frequency for job accounting plugins */
 	char *job_acct_type;	/* job accounting type */
+	char *database_type;	/* database type */
+	char *database_user;	/* database user */
+	char *database_host;	/* database host */
+	char *database_pass;	/* database password */
+	uint32_t database_port;	/* database port */
 	char *job_comp_type;	/* job completion logger type */
 	char *job_comp_loc;	/* job completion logging location */
 	uint16_t kill_wait;	/* seconds between SIGXCPU to SIGKILL 
diff --git a/src/Makefile.in b/src/Makefile.in
index e2adef7aa865a61359c91168703a95afb18d05f2..4538cfd182b2bb60906f2b4089ebac32177099b5 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -41,6 +41,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -112,6 +113,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -135,6 +137,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -146,6 +149,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/api/Makefile.in b/src/api/Makefile.in
index 1050f91280f4c2b4bd214a5a14ce8b9319d6b42d..b8dccbf58b222ad41747464ad122ab721c5e305c 100644
--- a/src/api/Makefile.in
+++ b/src/api/Makefile.in
@@ -45,6 +45,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -152,6 +153,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -175,6 +177,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -186,6 +189,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/api/config_info.c b/src/api/config_info.c
index 4575eb7a8a87fafcae322f7f4e19552b0636ab7c..4f721650ab6ccca56d31f83c7d42244fd1ea3909 100644
--- a/src/api/config_info.c
+++ b/src/api/config_info.c
@@ -130,6 +130,14 @@ void slurm_print_ctl_conf ( FILE* out,
 		slurm_ctl_conf_ptr->control_addr);
 	fprintf(out, "ControlMachine    = %s\n", 
 		slurm_ctl_conf_ptr->control_machine);
+	fprintf(out, "DatabaseType      = %s\n", 
+		slurm_ctl_conf_ptr->database_type);
+	fprintf(out, "DatabaseHost      = %s\n", 
+		slurm_ctl_conf_ptr->database_host);
+	fprintf(out, "DatabasePort      = %u\n", 
+		slurm_ctl_conf_ptr->database_port);
+	fprintf(out, "DatabaseUser      = %s\n", 
+		slurm_ctl_conf_ptr->database_user);
 	fprintf(out, "Epilog            = %s\n", 
 		slurm_ctl_conf_ptr->epilog);
 	fprintf(out, "FastSchedule      = %u\n", 
@@ -141,8 +149,8 @@ void slurm_print_ctl_conf ( FILE* out,
 #endif
 	fprintf(out, "InactiveLimit     = %u\n", 
 		slurm_ctl_conf_ptr->inactive_limit);
-	fprintf(out, "JobAcctLogFile    = %s\n", 
-		slurm_ctl_conf_ptr->job_acct_logfile);
+	fprintf(out, "JobAcctLoc    = %s\n", 
+		slurm_ctl_conf_ptr->job_acct_loc);
 	fprintf(out, "JobAcctFrequency  = %u\n",
 		slurm_ctl_conf_ptr->job_acct_freq);
 	fprintf(out, "JobAcctType       = %s\n", 
diff --git a/src/api/pmi.c b/src/api/pmi.c
index ad6a1d570f876daf9ea6e79016c1be7780b27365..0a4e2a7f100a6f7df4a24ca350f54178cbc4e7e5 100644
--- a/src/api/pmi.c
+++ b/src/api/pmi.c
@@ -60,7 +60,7 @@
  *  any later version.
  *
  *  In addition, as a special exception, the copyright holders give permission 
- *  to link the code of portions of this program with the OpenSSL library under 
+ *  to link the code of portions of this program with the OpenSSL library under
  *  certain conditions as described in each individual source file, and 
  *  distribute linked combinations including the two. You must obey the GNU 
  *  General Public License in all respects for all of the code used other than 
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index 063d1dac9817c08b3dc5fc22373df97317ae8478..a747eefa2a61c52aa93106b657607bf66d1c4392 100644
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -63,6 +63,7 @@ libcommon_la_SOURCES = 			\
 	slurm_auth.c slurm_auth.h	\
 	slurm_jobacct.c slurm_jobacct.h \
 	slurm_jobcomp.c slurm_jobcomp.h	\
+	slurm_database.c slurm_database.h \
 	switch.c switch.h		\
 	arg_desc.c arg_desc.h		\
 	macros.h			\
diff --git a/src/common/Makefile.in b/src/common/Makefile.in
index 0c7f29affd96806d7e76336d33e783a371f9156c..96ad110c7987f4e70fd085b24e494e5b00365fd1 100644
--- a/src/common/Makefile.in
+++ b/src/common/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -84,9 +85,10 @@ am__libcommon_la_SOURCES_DIST = xmalloc.c xmalloc.h xassert.c \
 	slurm_protocol_defs.h slurm_rlimits_info.h \
 	slurm_rlimits_info.c uid.c uid.h util-net.c util-net.h \
 	slurm_auth.c slurm_auth.h slurm_jobacct.c slurm_jobacct.h \
-	slurm_jobcomp.c slurm_jobcomp.h switch.c switch.h arg_desc.c \
-	arg_desc.h macros.h malloc.c malloc.h getopt.h getopt.c \
-	getopt1.c unsetenv.c unsetenv.h slurm_selecttype_info.c \
+	slurm_jobcomp.c slurm_jobcomp.h slurm_database.c \
+	slurm_database.h switch.c switch.h arg_desc.c arg_desc.h \
+	macros.h malloc.c malloc.h getopt.h getopt.c getopt1.c \
+	unsetenv.c unsetenv.h slurm_selecttype_info.c \
 	slurm_resource_info.c slurm_resource_info.h hostlist.c \
 	hostlist.h slurm_step_layout.c slurm_step_layout.h \
 	checkpoint.c checkpoint.h parse_time.c parse_time.h \
@@ -102,8 +104,8 @@ am_libcommon_la_OBJECTS = xmalloc.lo xassert.lo xstring.lo xsignal.lo \
 	slurm_protocol_util.lo slurm_protocol_socket_implementation.lo \
 	slurm_protocol_defs.lo slurm_rlimits_info.lo uid.lo \
 	util-net.lo slurm_auth.lo slurm_jobacct.lo slurm_jobcomp.lo \
-	switch.lo arg_desc.lo malloc.lo getopt.lo getopt1.lo \
-	$(am__objects_1) slurm_selecttype_info.lo \
+	slurm_database.lo switch.lo arg_desc.lo malloc.lo getopt.lo \
+	getopt1.lo $(am__objects_1) slurm_selecttype_info.lo \
 	slurm_resource_info.lo hostlist.lo slurm_step_layout.lo \
 	checkpoint.lo parse_time.lo job_options.lo global_defaults.lo \
 	timers.lo stepd_api.lo
@@ -179,6 +181,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -202,6 +205,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -213,6 +217,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -355,6 +361,7 @@ libcommon_la_SOURCES = \
 	slurm_auth.c slurm_auth.h	\
 	slurm_jobacct.c slurm_jobacct.h \
 	slurm_jobcomp.c slurm_jobcomp.h	\
+	slurm_database.c slurm_database.h \
 	switch.c switch.h		\
 	arg_desc.c arg_desc.h		\
 	macros.h			\
@@ -482,6 +489,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/safeopen.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slurm_auth.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slurm_cred.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slurm_database.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slurm_errno.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slurm_jobacct.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slurm_jobcomp.Plo@am__quote@
diff --git a/src/common/list.c b/src/common/list.c
index c55c69ce61bc98ad8177d1edf9ccc9b0e0b4e26e..84e928670e3035962905223981d05bdaadded0ba 100644
--- a/src/common/list.c
+++ b/src/common/list.c
@@ -80,7 +80,7 @@ strong_alias(list_next,		slurm_list_next);
 strong_alias(list_insert,	slurm_list_insert);
 strong_alias(list_find,		slurm_list_find);
 strong_alias(list_remove,	slurm_list_remove);
-strong_alias(list_delete,	slurm_list_delete);
+strong_alias(list_delete_item,	slurm_list_delete_item);
 strong_alias(list_install_fork_handlers, slurm_list_install_fork_handlers);
 /*********************
  *  lsd_fatal_error  *
@@ -697,7 +697,7 @@ list_remove (ListIterator i)
 
 
 int
-list_delete (ListIterator i)
+list_delete_item (ListIterator i)
 {
     void *v;
 
diff --git a/src/common/list.h b/src/common/list.h
index d9efbd693e6c2da9baf3ed1036d80ae9c36fa4fd..667b17ccd92dafd8030ed33987944acddb065921 100644
--- a/src/common/list.h
+++ b/src/common/list.h
@@ -281,7 +281,7 @@ void * list_remove (ListIterator i);
  *  Note: The client is responsible for freeing the returned data.
  */
 
-int list_delete (ListIterator i);
+int list_delete_item (ListIterator i);
 /*
  *  Removes from the list the last item returned via list iterator [i];
  *    if a deletion function was specified when the list was created,
diff --git a/src/common/parse_time.h b/src/common/parse_time.h
index 867f949759d975d7b468bf52c322bf8569e124de..b76faf67c8faf5724675e6c3fb72b97f1dd562c2 100644
--- a/src/common/parse_time.h
+++ b/src/common/parse_time.h
@@ -16,7 +16,7 @@
  *  any later version.
  *
  *  In addition, as a special exception, the copyright holders give permission 
- *  to link the code of portions of this program with the OpenSSL library under 
+ *  to link the code of portions of this program with the OpenSSL library under
  *  certain conditions as described in each individual source file, and 
  *  distribute linked combinations including the two. You must obey the GNU 
  *  General Public License in all respects for all of the code used other than 
diff --git a/src/common/read_config.c b/src/common/read_config.c
index a34e5f40b59cd4d834a3cafa3050d3a4594e3aa0..a12f419783fe5c86e59c3356df18afff3ea2bf33 100644
--- a/src/common/read_config.c
+++ b/src/common/read_config.c
@@ -143,8 +143,14 @@ s_p_options_t slurm_conf_options[] = {
 	{"HeartbeatInterval", S_P_LONG, defunct_option},
 	{"InactiveLimit", S_P_UINT16},
 	{"JobAcctLogFile", S_P_STRING},
+	{"JobAcctLoc", S_P_STRING},
 	{"JobAcctFrequency", S_P_UINT16},
 	{"JobAcctType", S_P_STRING},
+	{"DatabaseType", S_P_STRING},
+	{"DatabaseHost", S_P_STRING},
+	{"DatabaseUser", S_P_STRING},
+	{"DatabasePass", S_P_STRING},
+	{"DatabasePort", S_P_UINT32},
 	{"JobCompLoc", S_P_STRING},
 	{"JobCompType", S_P_STRING},
 	{"JobCredentialPrivateKey", S_P_STRING},
@@ -1044,8 +1050,12 @@ free_slurm_conf (slurm_ctl_conf_t *ctl_conf_ptr, bool purge_node_hash)
 	xfree (ctl_conf_ptr->control_addr);
 	xfree (ctl_conf_ptr->control_machine);
 	xfree (ctl_conf_ptr->epilog);
-	xfree (ctl_conf_ptr->job_acct_logfile);
+	xfree (ctl_conf_ptr->job_acct_loc);
 	xfree (ctl_conf_ptr->job_acct_type);
+	xfree (ctl_conf_ptr->database_type);
+	xfree (ctl_conf_ptr->database_user);
+	xfree (ctl_conf_ptr->database_host);
+	xfree (ctl_conf_ptr->database_pass);
 	xfree (ctl_conf_ptr->job_comp_loc);
 	xfree (ctl_conf_ptr->job_comp_type);
 	xfree (ctl_conf_ptr->job_credential_private_key);
@@ -1103,9 +1113,14 @@ init_slurm_conf (slurm_ctl_conf_t *ctl_conf_ptr)
 	ctl_conf_ptr->fast_schedule		= (uint16_t) NO_VAL;
 	ctl_conf_ptr->first_job_id		= (uint32_t) NO_VAL;
 	ctl_conf_ptr->inactive_limit		= (uint16_t) NO_VAL;
-	xfree (ctl_conf_ptr->job_acct_logfile);
+	xfree (ctl_conf_ptr->job_acct_loc);
 	ctl_conf_ptr->job_acct_freq             = 0;
 	xfree (ctl_conf_ptr->job_acct_type);
+	xfree (ctl_conf_ptr->database_type);
+	xfree (ctl_conf_ptr->database_user);
+	xfree (ctl_conf_ptr->database_host);
+	xfree (ctl_conf_ptr->database_pass);
+	ctl_conf_ptr->database_port             = 0;
 	xfree (ctl_conf_ptr->job_comp_loc);
 	xfree (ctl_conf_ptr->job_comp_type);
 	xfree (ctl_conf_ptr->job_credential_private_key);
@@ -1468,9 +1483,12 @@ validate_and_set_defaults(slurm_ctl_conf_t *conf, s_p_hashtbl_t *hashtbl)
 		conf->inactive_limit = DEFAULT_INACTIVE_LIMIT;
 	}
 
-	if (!s_p_get_string(&conf->job_acct_logfile, 
-			    "JobAcctLogFile", hashtbl))
-		conf->job_acct_logfile = xstrdup(DEFAULT_JOB_ACCT_LOGFILE);
+	/* Keep logfile around for backwards compatiblity */
+	if (!s_p_get_string(&conf->job_acct_loc, 
+			    "JobAcctLoc", hashtbl)
+	    || !s_p_get_string(&conf->job_acct_loc, 
+			       "JobAcctLogFile", hashtbl))
+		conf->job_acct_loc = xstrdup(DEFAULT_JOB_ACCT_LOC);
 
 	if (!s_p_get_uint16(&conf->job_acct_freq, "JobAcctFrequency", hashtbl))
 		conf->job_acct_freq = DEFAULT_JOB_ACCT_FREQ;
@@ -1478,6 +1496,17 @@ validate_and_set_defaults(slurm_ctl_conf_t *conf, s_p_hashtbl_t *hashtbl)
 	if (!s_p_get_string(&conf->job_acct_type, "JobAcctType", hashtbl))
 		conf->job_acct_type = xstrdup(DEFAULT_JOB_ACCT_TYPE);
 
+	if (!s_p_get_string(&conf->database_type, "DatabaseType", hashtbl))
+		conf->database_type = xstrdup(DEFAULT_DATABASE_TYPE);
+	if (!s_p_get_string(&conf->database_host, "DatabaseHost", hashtbl))
+		conf->database_host = xstrdup(DEFAULT_DATABASE_HOST);
+	if (!s_p_get_string(&conf->database_user, "DatabaseUser", hashtbl))
+		conf->database_user = xstrdup(DEFAULT_DATABASE_USER);
+	if (!s_p_get_string(&conf->database_pass, "DatabasePass", hashtbl))
+		conf->database_pass = xstrdup(DEFAULT_DATABASE_PASS);
+	if (!s_p_get_uint32(&conf->database_port, "DatabasePort", hashtbl))
+		conf->database_port = DEFAULT_DATABASE_PORT;
+
 	s_p_get_string(&conf->job_comp_loc, "JobCompLoc", hashtbl);
 
 	if (!s_p_get_string(&conf->job_comp_type, "JobCompType", hashtbl))
diff --git a/src/common/read_config.h b/src/common/read_config.h
index 94d4deafa2b141239622a189f0a6fe69567cffd7..cddae4a973e0bc7bf1e0da3735318d44b72ec810 100644
--- a/src/common/read_config.h
+++ b/src/common/read_config.h
@@ -16,7 +16,7 @@
  *  any later version.
  *
  *  In addition, as a special exception, the copyright holders give permission 
- *  to link the code of portions of this program with the OpenSSL library under 
+ *  to link the code of portions of this program with the OpenSSL library under
  *  certain conditions as described in each individual source file, and 
  *  distribute linked combinations including the two. You must obey the GNU 
  *  General Public License in all respects for all of the code used other than 
@@ -54,9 +54,14 @@ extern char *default_plugstack;
 #define DEFAULT_FIRST_JOB_ID        1
 /* NOTE: DEFAULT_INACTIVE_LIMIT must be 0 for Blue Gene/L systems */
 #define DEFAULT_INACTIVE_LIMIT      0
-#define DEFAULT_JOB_ACCT_LOGFILE    "/var/log/slurm_accounting.log"
+#define DEFAULT_JOB_ACCT_LOC        "/var/log/slurm_accounting.log"
 #define DEFAULT_JOB_ACCT_FREQ       30
 #define DEFAULT_JOB_ACCT_TYPE       "jobacct/none"
+#define DEFAULT_DATABASE_TYPE       "database/flatfile"
+#define DEFAULT_DATABASE_HOST       "localhost"
+#define DEFAULT_DATABASE_USER       "root"
+#define DEFAULT_DATABASE_PASS       ""
+#define DEFAULT_DATABASE_PORT       0
 #define DEFAULT_JOB_COMP_TYPE       "jobcomp/none"
 #define DEFAULT_KILL_TREE           0
 #define DEFAULT_KILL_WAIT           30
diff --git a/src/common/slurm_cred.c b/src/common/slurm_cred.c
index e46b84331e90e354484ef3698381648feec89751..26e6015f179fe46e21f1aaab14dc1a576ad8bd8e 100644
--- a/src/common/slurm_cred.c
+++ b/src/common/slurm_cred.c
@@ -1305,7 +1305,7 @@ _clear_expired_job_states(slurm_cred_ctx_t ctx)
 		        j->jobid, timestr(&j->ctime, t1, 64), t2, t3);
 
 		if (j->revoked && (now > j->expiration)) {
-			list_delete(i);
+			list_delete_item(i);
 		}
 	}
 
@@ -1324,7 +1324,7 @@ _clear_expired_credential_states(slurm_cred_ctx_t ctx)
 
 	while ((s = list_next(i))) {
 		if (now > s->expiration)
-			list_delete(i);
+			list_delete_item(i);
 	}
 
 	list_iterator_destroy(i);
diff --git a/src/common/slurm_database.c b/src/common/slurm_database.c
new file mode 100644
index 0000000000000000000000000000000000000000..73a418fb3e1a639ea64ad81de487ca77b1426e90
--- /dev/null
+++ b/src/common/slurm_database.c
@@ -0,0 +1,422 @@
+/*****************************************************************************\
+ *  slurm_database.c - database plugin wrapper.
+ *
+ *  $Id: slurm_database.c 10744 2007-01-11 20:09:18Z da $
+ *****************************************************************************
+ *  Copyright (C) 2002-2006 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Aubke <da@llnl.gov>.
+ *  UCRL-CODE-226842.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <pthread.h>
+
+#include "src/common/list.h"
+#include "src/common/slurm_database.h"
+#include "src/common/plugin.h"
+#include "src/common/plugrack.h"
+#include "src/common/slurm_protocol_api.h"
+#include "src/common/xstring.h"
+#include "src/slurmctld/slurmctld.h"
+
+/*
+ * Local data
+ */
+
+typedef struct slurm_database_ops {
+	int  (*jobacct_init)          (char *location);
+	int  (*jobacct_fini)          ();
+	int  (*jobacct_job_start)     (struct job_record *job_ptr);
+	int  (*jobacct_job_complete)  (struct job_record *job_ptr);
+	int  (*jobacct_step_start)    (struct step_record *step_ptr);
+	int  (*jobacct_step_complete) (struct step_record *step_ptr);
+	int  (*jobacct_job_suspend)   (struct job_record *job_ptr);
+	List (*jobacct_get_jobs)      (List job_list,
+				       List selected_steps,
+				       List selected_parts,
+				       void *params);	
+	void (*jobacct_archive)       (List selected_parts,
+				       void *params);
+	
+	int (*jobcomp_init)           (char * location);
+	int (*jobcomp_fini)           ();
+	int (*jobcomp_get_errno)      ();
+	int (*jobcomp_log_record)     (struct job_record *job_ptr);
+	char *(*jobcomp_strerror)     (int errnum);
+	List (*jobcomp_get_jobs)      (List job_list,
+				       List selected_steps,
+				       List selected_parts,
+				       void *params);	
+	void (*jobcomp_archive)       (List selected_parts,
+				       void *params);
+} slurm_database_ops_t;
+
+typedef struct slurm_database_context {
+	char	       	*database_type;
+	plugrack_t     	plugin_list;
+	plugin_handle_t	cur_plugin;
+	int		database_errno;
+	slurm_database_ops_t ops;
+} slurm_database_context_t;
+
+static slurm_database_context_t * g_database_context = NULL;
+static pthread_mutex_t		g_database_context_lock = 
+					PTHREAD_MUTEX_INITIALIZER;
+
+/*
+ * Local functions
+ */
+static slurm_database_ops_t *_database_get_ops(slurm_database_context_t *c);
+static slurm_database_context_t *_database_context_create(const char *database_type);
+static int _database_context_destroy(slurm_database_context_t *c);
+
+/*
+ * Locate and load the appropriate plugin
+ */
+static slurm_database_ops_t * _database_get_ops(slurm_database_context_t *c)
+{
+	/*
+	 * Must be synchronized with slurm_database_ops_t above.
+	 */
+	static const char *syms[] = {
+		"database_p_jobacct_init",
+		"database_p_jobacct_fini",
+		"database_p_jobacct_job_start",
+		"database_p_jobacct_job_complete",
+		"database_p_jobacct_step_start",
+		"database_p_jobacct_step_complete",
+		"database_p_jobacct_suspend",
+		"database_p_jobacct_get_jobs",
+		"database_p_jobacct_archive",
+		"database_p_jobcomp_init",
+		"database_p_jobcomp_fini",
+		"database_p_jobcomp_get_errno",
+		"database_p_jobcomp_log_record",
+		"database_p_jobcomp_strerror",
+		"database_p_jobcomp_get_jobs",
+		"database_p_jobcomp_archive"
+	};
+	int n_syms = sizeof( syms ) / sizeof( char * );
+
+	/* Get plugin list. */
+	if ( c->plugin_list == NULL ) {
+		char *plugin_dir;
+		c->plugin_list = plugrack_create();
+		if ( c->plugin_list == NULL ) {
+			error( "cannot create plugin manager" );
+			return NULL;
+		}
+		plugrack_set_major_type( c->plugin_list, "database" );
+		plugrack_set_paranoia( c->plugin_list,
+				       PLUGRACK_PARANOIA_NONE,
+				       0 );
+		plugin_dir = slurm_get_plugin_dir();
+		plugrack_read_dir( c->plugin_list, plugin_dir );
+		xfree(plugin_dir);
+	}
+
+	c->cur_plugin = plugrack_use_by_type( c->plugin_list, c->database_type );
+	if ( c->cur_plugin == PLUGIN_INVALID_HANDLE ) {
+		error( "cannot find database plugin for %s", 
+			c->database_type );
+		return NULL;
+	}
+
+	/* Dereference the API. */
+	if ( plugin_get_syms( c->cur_plugin,
+			      n_syms,
+			      syms,
+			      (void **) &c->ops ) < n_syms ) {
+		error( "incomplete database plugin detected" );
+		return NULL;
+	}
+
+	return &c->ops;
+}
+
+/*
+ * Create a database context
+ */
+static slurm_database_context_t *_database_context_create(const char *database_type)
+{
+	slurm_database_context_t *c;
+
+	if ( database_type == NULL ) {
+		debug3( "_database_context_create: no uler type" );
+		return NULL;
+	}
+
+	c = xmalloc( sizeof( slurm_database_context_t ) );
+	c->database_type	= xstrdup( database_type );
+	c->plugin_list	= NULL;
+	c->cur_plugin	= PLUGIN_INVALID_HANDLE;
+	c->database_errno	= SLURM_SUCCESS;
+
+	return c;
+}
+
+/*
+ * Destroy a database context
+ */
+static int _database_context_destroy( slurm_database_context_t *c )
+{
+	/*
+	 * Must check return code here because plugins might still
+	 * be loaded and active.
+	 */
+	if ( c->plugin_list ) {
+		if ( plugrack_destroy( c->plugin_list ) != SLURM_SUCCESS ) {
+			return SLURM_ERROR;
+		}
+	}
+
+	xfree( c->database_type );
+	xfree( c );
+
+	return SLURM_SUCCESS;
+}
+
+/*
+ * Initialize context for database plugin
+ */
+extern int slurm_database_init(void)
+{
+	int retval = SLURM_SUCCESS;
+	char *database_type = NULL;
+	
+	slurm_mutex_lock( &g_database_context_lock );
+
+	if ( g_database_context )
+		goto done;
+
+	database_type = slurm_get_database_type();
+	g_database_context = _database_context_create(database_type);
+	if ( g_database_context == NULL ) {
+		error( "cannot create database context for %s",
+			 database_type );
+		retval = SLURM_ERROR;
+		goto done;
+	}
+
+	if ( _database_get_ops( g_database_context ) == NULL ) {
+		error( "cannot resolve database plugin operations" );
+		_database_context_destroy( g_database_context );
+		g_database_context = NULL;
+		retval = SLURM_ERROR;
+	}
+
+ done:
+	slurm_mutex_unlock( &g_database_context_lock );
+	xfree(database_type);
+	return retval;
+}
+
+extern int slurm_database_fini(void)
+{
+	int rc;
+
+	if (!g_database_context)
+		return SLURM_SUCCESS;
+
+	(*(g_database_context->ops.jobacct_fini))();
+	rc = _database_context_destroy( g_database_context );
+	g_database_context = NULL;
+	return rc;
+}
+
+/* 
+ * Initialize the database make sure tables are created and in working
+ * order
+ */
+extern int database_g_jobacct_init (char *location)
+{
+	if (slurm_database_init() < 0)
+		return SLURM_ERROR;
+	return (*(g_database_context->ops.jobacct_init))(location);
+}
+
+/*
+ * finish up database connection
+ */
+extern int database_g_jobacct_fini ()
+{
+	if (slurm_database_init() < 0)
+		return SLURM_ERROR;
+	return (*(g_database_context->ops.jobacct_fini))();
+}
+
+/* 
+ * load into the database the start of a job
+ */
+extern int database_g_jobacct_job_start (struct job_record *job_ptr) 
+{
+	if (slurm_database_init() < 0)
+		return SLURM_ERROR;
+	return (*(g_database_context->ops.jobacct_job_start))(job_ptr);
+}
+
+/* 
+ * load into the database the end of a job
+ */
+extern int database_g_jobacct_job_complete  (struct job_record *job_ptr)
+{
+	if (slurm_database_init() < 0)
+		return SLURM_ERROR;
+	return (*(g_database_context->ops.jobacct_job_complete))(job_ptr);
+}
+
+/* 
+ * load into the database the start of a job step
+ */
+extern int database_g_jobacct_step_start (struct step_record *step_ptr)
+{
+	if (slurm_database_init() < 0)
+		return SLURM_ERROR;
+	return (*(g_database_context->ops.jobacct_step_start))(step_ptr);
+}
+
+/* 
+ * load into the database the end of a job step
+ */
+extern int database_g_jobacct_step_complete (struct step_record *step_ptr)
+{
+	if (slurm_database_init() < 0)
+		return SLURM_ERROR;
+	return (*(g_database_context->ops.jobacct_step_complete))(step_ptr);
+}
+
+/* 
+ * load into the database a suspention of a job
+ */
+extern int database_g_jobacct_job_suspend (struct job_record *job_ptr)
+{
+	if (slurm_database_init() < 0)
+		return SLURM_ERROR;
+ 	return (*(g_database_context->ops.jobacct_job_suspend))(job_ptr);
+}
+
+
+/* 
+ * get info from the database 
+ * returns List of job_rec_t *
+ * note List needs to be freed when called
+ */
+extern void database_g_jobacct_get_jobs(List job_list,
+					List selected_steps,
+					List selected_parts,
+					void *params)
+{
+	if (slurm_database_init() < 0)
+		return;
+ 	(*(g_database_context->ops.jobacct_get_jobs))(job_list,
+						      selected_steps,
+						      selected_parts,
+						      params);
+	return;
+}
+
+/* 
+ * expire old info from the database 
+ */
+extern void database_g_jobacct_archive(List selected_parts, void *params)
+{
+	if (slurm_database_init() < 0)
+		return;
+ 	(*(g_database_context->ops.jobacct_archive))(selected_parts, params);
+	return;
+}
+
+
+/* job comp */
+extern int database_g_jobcomp_init(char * location)
+{
+	if (slurm_database_init() < 0)
+		return SLURM_ERROR;
+ 	return (*(g_database_context->ops.jobcomp_init))(location);
+}
+
+extern int database_g_jobcomp_fini()
+{
+	if (slurm_database_init() < 0)
+		return SLURM_ERROR;
+ 	return (*(g_database_context->ops.jobcomp_fini))();
+}
+
+extern int database_g_jobcomp_get_errno()
+{
+	if (slurm_database_init() < 0)
+		return SLURM_ERROR;
+ 	return (*(g_database_context->ops.jobcomp_get_errno))();
+
+}
+
+extern int database_g_jobcomp_log_record(struct job_record *job_ptr)
+{
+	if (slurm_database_init() < 0)
+		return SLURM_ERROR;
+ 	return (*(g_database_context->ops.jobcomp_log_record))(job_ptr);
+}
+
+extern char *database_g_jobcomp_strerror(int errnum)
+{
+	if (slurm_database_init() < 0)
+		return NULL;
+ 	return (*(g_database_context->ops.jobcomp_strerror))(errnum);
+}
+
+extern void database_g_jobcomp_get_jobs(List job_list,
+					List selected_steps,
+					List selected_parts,
+					void *params)
+{
+	if (slurm_database_init() < 0)
+		return;
+ 	(*(g_database_context->ops.jobcomp_get_jobs))(job_list,
+						      selected_steps,
+						      selected_parts,
+						      params);
+	return;
+}
+
+/* 
+ * expire old info from the database 
+ */
+extern void database_g_jobcomp_archive(List selected_parts, void *params)
+{
+	if (slurm_database_init() < 0)
+		return;
+ 	(*(g_database_context->ops.jobcomp_archive))(selected_parts, params);
+	return;
+}
diff --git a/src/common/slurm_database.h b/src/common/slurm_database.h
new file mode 100644
index 0000000000000000000000000000000000000000..ab435bb6372535611f1ff8467207392a95c20940
--- /dev/null
+++ b/src/common/slurm_database.h
@@ -0,0 +1,115 @@
+/*****************************************************************************\
+ *  node_select.h - Define database plugin functions.
+ *
+ * $Id: node_select.h 10574 2006-12-15 23:38:29Z jette $
+ *****************************************************************************
+ *  Copyright (C) 2004-2006 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  UCRL-CODE-226842.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#ifndef _SLURM_DATABASE_H 
+#define _SLURM_DATABASE_H
+
+#include "src/common/list.h"
+#include "src/slurmctld/slurmctld.h"
+#include <slurm/slurm.h>
+#include <slurm/slurm_errno.h>
+
+/* 
+ * Initialize the database make sure tables are created and in working
+ * order
+ */
+extern int database_g_jobacct_init (char *location);
+
+/*
+ * finish up database connection
+ */
+extern int database_g_jobacct_fini ();
+
+/* 
+ * load into the database the start of a job
+ */
+extern int database_g_jobacct_job_start (struct job_record *job_ptr);
+
+/* 
+ * load into the database the end of a job
+ */
+extern int database_g_jobacct_job_complete (struct job_record *job_ptr);
+
+/* 
+ * load into the database the start of a job step
+ */
+extern int database_g_jobacct_step_start (struct step_record *step_ptr);
+
+/* 
+ * load into the database the end of a job step
+ */
+extern int database_g_jobacct_step_complete (struct step_record *step_ptr);
+
+/* 
+ * load into the database a suspention of a job
+ */
+extern int database_g_jobacct_job_suspend (struct job_record *job_ptr);
+
+/* 
+ * get info from the database 
+ * in/out job_list List of job_rec_t *
+ * note List needs to be freed when called
+ */
+extern void database_g_jobacct_get_jobs(List job_list,
+					List selected_steps,
+					List selected_parts,
+					void *params);
+
+/* 
+ * expire old info from the database 
+ */
+extern void database_g_jobacct_archive(List selected_parts, void *params);
+
+/*
+ * jobcomp functions
+ */
+extern int database_g_jobcomp_init(char * location);
+extern int database_g_jobcomp_fini();
+extern int database_g_jobcomp_get_errno();
+extern int database_g_jobcomp_log_record(struct job_record *job_ptr);
+extern char *database_g_jobcomp_strerror(int errnum);
+extern void database_g_jobcomp_get_jobs(List job_list,
+					List selected_steps,
+					List selected_parts,
+					void *params);
+extern void database_g_jobcomp_archive(List selected_parts, void *params);
+
+
+
+#endif /*_SLURM_DATABASE_H*/
diff --git a/src/common/slurm_jobacct.c b/src/common/slurm_jobacct.c
index 1f8d74d9b40ee975e3b127a91f37321574049f6f..8cd7b091ef75c052c5c10cba90b075c2a8e7433c 100644
--- a/src/common/slurm_jobacct.c
+++ b/src/common/slurm_jobacct.c
@@ -302,6 +302,96 @@ extern int jobacct_init(void)
 	return SLURM_SUCCESS;
 }
 
+extern jobacct_job_rec_t *jobacct_init_job_rec(jobacct_header_t header)
+{
+	jobacct_job_rec_t *job = xmalloc(sizeof(jobacct_job_rec_t));
+	memcpy(&job->header, &header, sizeof(jobacct_header_t));
+	memset(&job->rusage, 0, sizeof(struct rusage));
+	memset(&job->sacct, 0, sizeof(sacct_t));
+	job->sacct.min_cpu = (float)NO_VAL;
+	job->job_start_seen = 0;
+	job->job_step_seen = 0;
+	job->job_terminated_seen = 0;
+	job->jobnum_superseded = 0;
+	job->jobname = NULL;
+	job->status = JOB_PENDING;
+	job->nodes = NULL;
+	job->jobname = NULL;
+	job->exitcode = 0;
+	job->priority = 0;
+	job->ntasks = 0;
+	job->ncpus = 0;
+	job->elapsed = 0;
+	job->tot_cpu_sec = 0;
+	job->tot_cpu_usec = 0;
+	job->steps = list_create(jobacct_destroy_step);
+	job->nodes = NULL;
+	job->track_steps = 0;
+	job->account = NULL;
+	job->requid = -1;
+
+      	return job;
+}
+
+extern jobacct_step_rec_t *jobacct_init_step_rec(jobacct_header_t header)
+{
+	jobacct_step_rec_t *step = xmalloc(sizeof(jobacct_job_rec_t));
+	memcpy(&step->header, &header, sizeof(jobacct_header_t));
+	memset(&step->rusage, 0, sizeof(struct rusage));
+	memset(&step->sacct, 0, sizeof(sacct_t));
+	step->stepnum = (uint32_t)NO_VAL;
+	step->nodes = NULL;
+	step->stepname = NULL;
+	step->status = NO_VAL;
+	step->exitcode = NO_VAL;
+	step->ntasks = (uint32_t)NO_VAL;
+	step->ncpus = (uint32_t)NO_VAL;
+	step->elapsed = (uint32_t)NO_VAL;
+	step->tot_cpu_sec = (uint32_t)NO_VAL;
+	step->tot_cpu_usec = (uint32_t)NO_VAL;
+	step->account = NULL;
+	step->requid = -1;
+
+	return step;
+}
+
+extern void jobacct_destroy_header(void *object)
+{
+	jobacct_header_t *header = (jobacct_header_t *)object;
+	if(header) {
+		xfree(header->partition);
+		xfree(header->blockid);
+	}
+}
+
+extern void jobacct_destroy_job(void *object)
+{
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	if (job) {
+		if(job->steps)
+			list_destroy(job->steps);
+		jobacct_destroy_header(&job->header);
+		xfree(job->jobname);
+		xfree(job->account);
+		xfree(job->nodes);
+		xfree(job);
+	}
+}
+
+extern void jobacct_destroy_step(void *object)
+{
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
+	if (step) {
+		jobacct_destroy_header(&step->header);
+		xfree(step->stepname);
+		xfree(step->nodes);
+		xfree(step->account);
+		xfree(step);
+	}
+}
+
+
+
 extern int jobacct_g_init_struct(jobacctinfo_t *jobacct, 
 				 jobacct_id_t *jobacct_id)
 {
diff --git a/src/common/slurm_jobacct.h b/src/common/slurm_jobacct.h
index ec9ac6dace49cc2c195eb095e149551ff8775237..8293d06337358d63d213893547266c8f509282a1 100644
--- a/src/common/slurm_jobacct.h
+++ b/src/common/slurm_jobacct.h
@@ -63,7 +63,119 @@
 
 #include "src/slurmd/slurmstepd/slurmstepd_job.h"
 #include "src/slurmctld/slurmctld.h"
-#include "src/sacct/sacct_stat.h"
+
+typedef struct {
+	uint16_t taskid; /* contains which task number it was on */
+	uint32_t nodeid; /* contains which node number it was on */	
+} jobacct_id_t;
+
+typedef struct {
+	uint32_t max_vsize; 
+	jobacct_id_t max_vsize_id;
+	float ave_vsize;
+	uint32_t max_rss;
+	jobacct_id_t max_rss_id;
+	float ave_rss;
+	uint32_t max_pages;
+	jobacct_id_t max_pages_id;
+	float ave_pages;
+	float min_cpu;
+	jobacct_id_t min_cpu_id;
+	float ave_cpu;	
+} sacct_t;
+
+typedef struct {
+	int opt_completion;	/* --completion */
+	int opt_dump;		/* --dump */
+	int opt_dup;		/* --duplicates; +1 = explicitly set */
+	int opt_fdump;		/* --formattted_dump */
+	int opt_stat;		/* --stat */
+	int opt_gid;		/* --gid (-1=wildcard, 0=root) */
+	int opt_header;		/* can only be cleared */
+	int opt_help;		/* --help */
+	int opt_long;		/* --long */
+	int opt_lowmem;		/* --low_memory */
+	int opt_purge;		/* --purge */
+	int opt_total;		/* --total */
+	int opt_uid;		/* --uid (-1=wildcard, 0=root) */
+	int opt_verbose;	/* --verbose */
+	long opt_expire;		/* --expire= */ 
+	char *opt_expire_timespec; /* --expire= */
+	char *opt_field_list;	/* --fields= */
+	char *opt_filein;	/* --file */
+	char *opt_job_list;	/* --jobs */
+	char *opt_partition_list;/* --partitions */
+	char *opt_state_list;	/* --states */
+} sacct_parameters_t;
+
+typedef struct header {
+	uint32_t jobnum;
+	char	*partition;
+	char	*blockid;
+	time_t 	job_submit;
+	time_t	timestamp;
+	uint32_t uid;
+	uint32_t gid;
+	uint16_t rec_type;
+} jobacct_header_t;
+
+typedef struct {
+	uint32_t job_start_seen,		/* useful flags */
+		job_step_seen,
+		job_terminated_seen,
+		jobnum_superseded;	/* older jobnum was reused */
+	jobacct_header_t header;
+	uint16_t show_full;
+	char	*nodes;
+	char	*jobname;
+	uint16_t track_steps;
+	int32_t priority;
+	uint32_t ncpus;
+	uint32_t ntasks;
+	enum job_states	status;
+	int32_t	exitcode;
+	uint32_t elapsed;
+	time_t end;
+	uint32_t tot_cpu_sec;
+	uint32_t tot_cpu_usec;
+	struct rusage rusage;
+	sacct_t sacct;
+	List    steps;
+	char    *account;
+	uint32_t requid;
+} jobacct_job_rec_t;
+
+typedef struct {
+	jobacct_header_t   header;
+	uint32_t	stepnum;	/* job's step number */
+	char	        *nodes;
+	char	        *stepname;
+	enum job_states	status;
+	int32_t	        exitcode;
+	uint32_t	ntasks; 
+	uint32_t        ncpus;
+	uint32_t	elapsed;
+	time_t          end;
+	uint32_t	tot_cpu_sec;
+	uint32_t        tot_cpu_usec;
+	struct rusage   rusage;
+	sacct_t         sacct;
+	char            *account;
+	uint32_t requid;
+} jobacct_step_rec_t;
+
+typedef struct selected_step_t {
+	char *job;
+	char *step;
+	uint32_t jobid;
+	uint32_t stepid;
+} jobacct_selected_step_t;
+
+extern jobacct_step_rec_t *jobacct_init_step_rec(jobacct_header_t header);
+extern jobacct_job_rec_t *jobacct_init_job_rec(jobacct_header_t header);
+extern void jobacct_destroy_acct_header(void *object);
+extern void jobacct_destroy_job(void *object);
+extern void jobacct_destroy_step(void *object);
 
 /* common */
 extern int jobacct_init(void); /* load the plugin */
diff --git a/src/common/slurm_jobcomp.c b/src/common/slurm_jobcomp.c
index ce6ae16f40cda71a8eadd0125f9a1b72abb09440..72f5b69edb1e5c45b444926591c2e42a95d72b56 100644
--- a/src/common/slurm_jobcomp.c
+++ b/src/common/slurm_jobcomp.c
@@ -188,6 +188,31 @@ _slurm_jobcomp_get_ops( slurm_jobcomp_context_t c )
         return &c->ops;
 }
 
+extern void 
+jobcomp_destroy_job(void *object)
+{
+	jobcomp_job_rec_t *job = (jobcomp_job_rec_t *)object;
+	if (job) {
+		xfree(job->partition);
+		xfree(job->blockid);
+		xfree(job->start_time);
+		xfree(job->end_time);
+		xfree(job->uid_name);
+		xfree(job->gid_name);
+		xfree(job->nodelist);
+		xfree(job->jobname);
+		xfree(job->state);
+		xfree(job->timelimit);
+		xfree(job->connection);
+		xfree(job->reboot);
+		xfree(job->rotate);
+		xfree(job->geo);
+		xfree(job->bg_start_point);
+		xfree(job);
+	}
+}
+
+
 extern int
 g_slurm_jobcomp_init( char *jobcomp_loc )
 {
diff --git a/src/common/slurm_jobcomp.h b/src/common/slurm_jobcomp.h
index 0397e46b000c6be24513974b57d32230e1ee37b7..c87bf95c4b47e17de6d54ef911f01cb5b0a64250 100644
--- a/src/common/slurm_jobcomp.h
+++ b/src/common/slurm_jobcomp.h
@@ -54,8 +54,33 @@
 
 #include "src/slurmctld/slurmctld.h"
 
+typedef struct {
+	uint32_t jobid;
+	char *partition;
+	char *blockid;
+	char *start_time;
+	char *end_time;
+	uint32_t uid;
+	char *uid_name;
+	uint32_t gid;
+	char *gid_name;
+	uint32_t node_cnt;
+	char *nodelist;
+	char *jobname;
+	char *state;
+	char *timelimit;
+	char *connection;
+	char *reboot;
+	char *rotate;
+	uint32_t max_procs;
+	char *geo;
+	char *bg_start_point;
+} jobcomp_job_rec_t;
+
 typedef struct slurm_jobcomp_context * slurm_jobcomp_context_t;
 
+extern void jobcomp_destroy_job(void *object);
+
 /* initialization of job completion logging */
 extern int g_slurm_jobcomp_init(char *jobcomp_loc);
 
diff --git a/src/common/slurm_protocol_api.c b/src/common/slurm_protocol_api.c
index d7d547385565793b93dfc445dbbdb25170a20a14..b282b18bb83b15f905d770e3a3a4dcacedfb65a2 100644
--- a/src/common/slurm_protocol_api.c
+++ b/src/common/slurm_protocol_api.c
@@ -324,13 +324,13 @@ extern int slurm_set_auth_type(char *auth_type)
  */
 char *slurm_get_jobacct_loc(void)
 {
-	char *jobacct_logfile;
+	char *jobacct_loc;
 	slurm_ctl_conf_t *conf;
 
 	conf = slurm_conf_lock();
-	jobacct_logfile = xstrdup(conf->job_acct_logfile);
+	jobacct_loc = xstrdup(conf->job_acct_loc);
 	slurm_conf_unlock();
-	return jobacct_logfile;
+	return jobacct_loc;
 }
 
 /* slurm_get_jobacct_freq
@@ -363,6 +363,82 @@ char *slurm_get_jobacct_type(void)
 	return jobacct_type;
 }
 
+/* slurm_get_database_type
+ * returns the database type from slurmctld_conf object
+ * RET char *    - database type,  MUST be xfreed by caller
+ */
+char *slurm_get_database_type(void)
+{
+	char *database_type;
+	slurm_ctl_conf_t *conf;
+
+	conf = slurm_conf_lock();
+	database_type = xstrdup(conf->database_type);
+	slurm_conf_unlock();
+	return database_type;	
+}
+
+/* slurm_get_database_user
+ * returns the database user from slurmctld_conf object
+ * RET char *    - database user,  MUST be xfreed by caller
+ */
+char *slurm_get_database_user(void)
+{
+	char *database_user;
+	slurm_ctl_conf_t *conf;
+
+	conf = slurm_conf_lock();
+	database_user = xstrdup(conf->database_user);
+	slurm_conf_unlock();
+	return database_user;	
+}
+
+/* slurm_get_database_host
+ * returns the database host from slurmctld_conf object
+ * RET char *    - database host,  MUST be xfreed by caller
+ */
+char *slurm_get_database_host(void)
+{
+	char *database_host;
+	slurm_ctl_conf_t *conf;
+
+	conf = slurm_conf_lock();
+	database_host = xstrdup(conf->database_host);
+	slurm_conf_unlock();
+	return database_host;	
+}
+
+/* slurm_get_database_pass
+ * returns the database password from slurmctld_conf object
+ * RET char *    - database password,  MUST be xfreed by caller
+ */
+char *slurm_get_database_pass(void)
+{
+	char *database_pass;
+	slurm_ctl_conf_t *conf;
+
+	conf = slurm_conf_lock();
+	database_pass = xstrdup(conf->database_pass);
+	slurm_conf_unlock();
+	return database_pass;	
+}
+
+/* slurm_get_database_port
+ * returns the database port from slurmctld_conf object
+ * RET uint32_t   - database port
+ */
+uint32_t slurm_get_database_port(void)
+{
+	uint32_t database_port;
+	slurm_ctl_conf_t *conf;
+
+	conf = slurm_conf_lock();
+	database_port = conf->database_port;
+	slurm_conf_unlock();
+	return database_port;
+	
+}
+
 /* slurm_get_jobcomp_type
  * returns the job completion logger type from slurmctld_conf object
  * RET char *    - job completion type,  MUST be xfreed by caller
@@ -378,6 +454,21 @@ char *slurm_get_jobcomp_type(void)
 	return jobcomp_type;
 }
 
+/* slurm_get_jobcomp_loc
+ * returns the job completion loc from slurmctld_conf object
+ * RET char *    - job completion location,  MUST be xfreed by caller
+ */
+char *slurm_get_jobcomp_loc(void)
+{
+	char *jobcomp_loc;
+	slurm_ctl_conf_t *conf;
+
+	conf = slurm_conf_lock();
+	jobcomp_loc = xstrdup(conf->job_comp_loc);
+	slurm_conf_unlock();
+	return jobcomp_loc;	
+}
+
 /* slurm_get_proctrack_type
  * get ProctrackType from slurmctld_conf object
  * RET char *   - proctrack type, MUST be xfreed by caller
diff --git a/src/common/slurm_protocol_api.h b/src/common/slurm_protocol_api.h
index fabc62d7151bcdf862230d20fe473be1e704637b..0230d19f8a563123ee00003e093cd1f5b8696ca8 100644
--- a/src/common/slurm_protocol_api.h
+++ b/src/common/slurm_protocol_api.h
@@ -176,12 +176,48 @@ uint16_t slurm_get_jobacct_freq(void);
  */
 char *slurm_get_jobacct_type(void);
 
+/* slurm_get_database_type
+ * returns the database type from slurmctld_conf object
+ * RET char *    - database type,  MUST be xfreed by caller
+ */
+char *slurm_get_database_type(void);
+
+/* slurm_get_database_user
+ * returns the database user from slurmctld_conf object
+ * RET char *    - database user,  MUST be xfreed by caller
+ */
+char *slurm_get_database_user(void);
+
+/* slurm_get_database_host
+ * returns the database host from slurmctld_conf object
+ * RET char *    - database host,  MUST be xfreed by caller
+ */
+char *slurm_get_database_host(void);
+
+/* slurm_get_database_pass
+ * returns the database password from slurmctld_conf object
+ * RET char *    - database password,  MUST be xfreed by caller
+ */
+char *slurm_get_database_pass(void);
+
+/* slurm_get_database_port
+ * returns the database port from slurmctld_conf object
+ * RET uint32_t   - database port
+ */
+uint32_t slurm_get_database_port(void);
+
 /* slurm_get_jobcomp_type
  * returns the job completion logger type from slurmctld_conf object
  * RET char *    - job completion type,  MUST be xfreed by caller
  */
 char *slurm_get_jobcomp_type(void);
 
+/* slurm_get_jobcomp_loc
+ * returns the job completion loc from slurmctld_conf object
+ * RET char *    - job completion location,  MUST be xfreed by caller
+ */
+char *slurm_get_jobcomp_loc(void);
+
 /* slurm_get_propagate_prio_process
  * return the PropagatePrioProcess flag from slurmctld_conf object
  */
diff --git a/src/common/slurm_protocol_defs.c b/src/common/slurm_protocol_defs.c
index 0e16d428f9e5ebb1330d45f3081c31d8e1218d10..c2350f3b64d7e26d50a094ef6dc855b1c67e3b55 100644
--- a/src/common/slurm_protocol_defs.c
+++ b/src/common/slurm_protocol_defs.c
@@ -843,7 +843,7 @@ void slurm_free_ctl_conf(slurm_ctl_conf_info_msg_t * config_ptr)
 		xfree(config_ptr->control_addr);
 		xfree(config_ptr->control_machine);
 		xfree(config_ptr->epilog);
-		xfree(config_ptr->job_acct_logfile);
+		xfree(config_ptr->job_acct_loc);
 		xfree(config_ptr->job_acct_type);
 		xfree(config_ptr->job_comp_loc);
 		xfree(config_ptr->job_comp_type);
diff --git a/src/common/slurm_protocol_pack.c b/src/common/slurm_protocol_pack.c
index 03fddd965252e225ab1f96600aeb0ecb377f518a..4a51f9f9591f28690130b11a3c3a54123c4c2091 100644
--- a/src/common/slurm_protocol_pack.c
+++ b/src/common/slurm_protocol_pack.c
@@ -2090,9 +2090,14 @@ _pack_slurm_ctl_conf_msg(slurm_ctl_conf_info_msg_t * build_ptr, Buf buffer)
 	pack16(build_ptr->fast_schedule, buffer);
 	pack32(build_ptr->first_job_id, buffer);
 	pack16(build_ptr->inactive_limit, buffer);
-	packstr(build_ptr->job_acct_logfile, buffer);
+	packstr(build_ptr->job_acct_loc, buffer);
 	pack16(build_ptr->job_acct_freq, buffer);
 	packstr(build_ptr->job_acct_type, buffer);
+	packstr(build_ptr->database_type, buffer);
+	packstr(build_ptr->database_user, buffer);
+	packstr(build_ptr->database_host, buffer);
+	packstr(build_ptr->database_pass, buffer);
+	pack32((uint32_t)build_ptr->database_port, buffer);
 	packstr(build_ptr->job_comp_loc, buffer);
 	packstr(build_ptr->job_comp_type, buffer);
 	pack16(build_ptr->kill_wait, buffer);
@@ -2184,10 +2189,15 @@ _unpack_slurm_ctl_conf_msg(slurm_ctl_conf_info_msg_t **
 	safe_unpack16(&build_ptr->fast_schedule, buffer);
 	safe_unpack32(&build_ptr->first_job_id, buffer);
 	safe_unpack16(&build_ptr->inactive_limit, buffer);
-	safe_unpackstr_xmalloc(&build_ptr->job_acct_logfile, &uint16_tmp, 
+	safe_unpackstr_xmalloc(&build_ptr->job_acct_loc, &uint16_tmp, 
 			       buffer);
 	safe_unpack16(&build_ptr->job_acct_freq, buffer);
 	safe_unpackstr_xmalloc(&build_ptr->job_acct_type, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&build_ptr->database_type, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&build_ptr->database_user, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&build_ptr->database_host, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&build_ptr->database_pass, &uint16_tmp, buffer);
+	safe_unpack32(&build_ptr->database_port, buffer);
 	safe_unpackstr_xmalloc(&build_ptr->job_comp_loc, &uint16_tmp, buffer);
 	safe_unpackstr_xmalloc(&build_ptr->job_comp_type, &uint16_tmp, buffer);
 	safe_unpack16(&build_ptr->kill_wait, buffer);
@@ -2277,8 +2287,12 @@ unpack_error:
 	xfree(build_ptr->control_addr);
 	xfree(build_ptr->control_machine);
 	xfree(build_ptr->epilog);
-	xfree(build_ptr->job_acct_logfile);
+	xfree(build_ptr->job_acct_loc);
 	xfree(build_ptr->job_acct_type);
+	xfree(build_ptr->database_type);
+	xfree(build_ptr->database_user);
+	xfree(build_ptr->database_host);
+	xfree(build_ptr->database_pass);
 	xfree(build_ptr->job_comp_loc);
 	xfree(build_ptr->job_comp_type);
 	xfree(build_ptr->job_credential_private_key);
diff --git a/src/common/xstring.c b/src/common/xstring.c
index a5ee4925d4b52d00f2682729dd69f8849e98c01d..0c770f08222f0e6522d36566470b3fe2ac5fa7e5 100644
--- a/src/common/xstring.c
+++ b/src/common/xstring.c
@@ -78,6 +78,7 @@ strong_alias(_xstrftimecat,	slurm_xstrftimecat);
 strong_alias(_xstrfmtcat,	slurm_xstrfmtcat);
 strong_alias(_xmemcat,		slurm_xmemcat);
 strong_alias(xstrdup,		slurm_xstrdup);
+strong_alias(xstrdup_printf,	slurm_xstrdup_printf);
 strong_alias(xstrndup,		slurm_xstrndup);
 strong_alias(xbasename,		slurm_xbasename);
 strong_alias(_xstrsubstitute,   slurm_xstrsubstitute);
@@ -270,6 +271,38 @@ char * xstrdup(const char *str)
 	return result;
 }
 
+/*
+ * Give me a copy of the string as if it were printf.
+ *   fmt (IN)		format of string and args if any
+ *   RETURN		copy of formated string
+ */
+char *xstrdup_printf(const char *fmt, ...)
+{
+	/* Start out with a size of 100 bytes. */
+	int n, size = 100;
+	char *p = NULL;
+	va_list ap;
+	
+	if((p = xmalloc(size)) == NULL)
+		return NULL;
+	while(1) {
+		/* Try to print in the allocated space. */
+		va_start(ap, fmt);
+		n = vsnprintf(p, size, fmt, ap);
+		va_end (ap);
+		/* If that worked, return the string. */
+		if (n > -1 && n < size)
+			return p;
+		/* Else try again with more space. */
+		if (n > -1)               /* glibc 2.1 */
+			size = n + 1;           /* precisely what is needed */
+		else                      /* glibc 2.0 */
+			size *= 2;              /* twice the old size */
+		if ((p = xrealloc(p, size)) == NULL)
+			return NULL;
+	}
+}
+
 /*
  * Duplicate at most "n" characters of a string.
  *   str (IN)		string to duplicate
diff --git a/src/common/xstring.h b/src/common/xstring.h
index b29056c42a557c34032f9a0bace70a51576e29e0..e81ec97580a29e885fb29e9fe5834a14255e1abc 100644
--- a/src/common/xstring.h
+++ b/src/common/xstring.h
@@ -98,6 +98,11 @@ void _xmemcat(char **str, char *start, char *end);
 */
 char *xstrdup(const char *str);
 
+/*
+** strdup formatted which uses xmalloc routines
+*/
+char *xstrdup_printf(const char *fmt, ...);
+
 /*
 ** strndup which uses xmalloc routines
 */
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 25088e401ac43076025482b08e2ee4343f2f69da..b576f66cce48cbb8e5191be6e2406416989e4ca5 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -1,2 +1,2 @@
 
-SUBDIRS = auth checkpoint jobacct jobcomp mpi proctrack sched select switch task
+SUBDIRS = auth checkpoint database jobacct jobcomp mpi proctrack sched select switch task
diff --git a/src/plugins/Makefile.in b/src/plugins/Makefile.in
index 3b2117495fab61f44593b92e5df9926425077cb7..4b8277e0513a9f86dab1ad32ca2fbb3b20b2df86 100644
--- a/src/plugins/Makefile.in
+++ b/src/plugins/Makefile.in
@@ -41,6 +41,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -112,6 +113,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -135,6 +137,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -146,6 +149,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -231,7 +236,7 @@ target_os = @target_os@
 target_vendor = @target_vendor@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-SUBDIRS = auth checkpoint jobacct jobcomp mpi proctrack sched select switch task
+SUBDIRS = auth checkpoint database jobacct jobcomp mpi proctrack sched select switch task
 all: all-recursive
 
 .SUFFIXES:
diff --git a/src/plugins/auth/Makefile.in b/src/plugins/auth/Makefile.in
index 072efa47de9d6f6c6c8217c59ce9a1c099adfc25..a7b76c5710198dbd4dff37dc7ac4354da36407f3 100644
--- a/src/plugins/auth/Makefile.in
+++ b/src/plugins/auth/Makefile.in
@@ -43,6 +43,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -114,6 +115,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -137,6 +139,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -148,6 +151,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/auth/authd/Makefile.in b/src/plugins/auth/authd/Makefile.in
index 81a55196df32e7a74006281ee250d321078dcb0d..6fd45a3f84042f89a1f9822327137eb1e6bb78c3 100644
--- a/src/plugins/auth/authd/Makefile.in
+++ b/src/plugins/auth/authd/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -133,6 +134,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -156,6 +158,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -167,6 +170,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/auth/munge/Makefile.in b/src/plugins/auth/munge/Makefile.in
index 421fbfe1983e82db37123fac9c3e7522f552cd06..77cc9fe70010cd1eb4887a23663e9a349edc2c2d 100644
--- a/src/plugins/auth/munge/Makefile.in
+++ b/src/plugins/auth/munge/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -134,6 +135,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -157,6 +159,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -168,6 +171,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/auth/none/Makefile.in b/src/plugins/auth/none/Makefile.in
index 271277723fde3b78e97efef87347883e78d44f69..e06478349450f5a9b2e05407d1d6fd96a6ced3ad 100644
--- a/src/plugins/auth/none/Makefile.in
+++ b/src/plugins/auth/none/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -132,6 +133,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -155,6 +157,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -166,6 +169,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/checkpoint/Makefile.in b/src/plugins/checkpoint/Makefile.in
index 82f8da3051ad965af9bbdfb015fc52e168ea925a..66e79201ca13ee395d1306f1df2028c40a3b552b 100644
--- a/src/plugins/checkpoint/Makefile.in
+++ b/src/plugins/checkpoint/Makefile.in
@@ -43,6 +43,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -114,6 +115,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -137,6 +139,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -148,6 +151,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/checkpoint/aix/Makefile.in b/src/plugins/checkpoint/aix/Makefile.in
index eb99367b5981df8e21a4d944c8d17b29285b4c1b..34634d64538a763ceb273114c24f2644579b9453 100644
--- a/src/plugins/checkpoint/aix/Makefile.in
+++ b/src/plugins/checkpoint/aix/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -137,6 +138,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -160,6 +162,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -171,6 +174,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/checkpoint/aix/checkpoint_aix.c b/src/plugins/checkpoint/aix/checkpoint_aix.c
index 558de0e2fbfd9048fe4afa1aacc992338717b1ce..7322a585974edef0088efc8915fadcd3c899f723 100644
--- a/src/plugins/checkpoint/aix/checkpoint_aix.c
+++ b/src/plugins/checkpoint/aix/checkpoint_aix.c
@@ -427,7 +427,7 @@ static void *_ckpt_agent_thr(void *arg)
 			info("checkpoint timeout for %u.%u", 
 				rec->job_id, rec->step_id);
 			_ckpt_signal_step(rec);
-			list_delete(iter);
+			list_delete_item(iter);
 		}
 		slurm_mutex_unlock(&ckpt_agent_mutex);
 		list_iterator_destroy(iter);
@@ -493,7 +493,7 @@ static void _ckpt_dequeue_timeout(uint32_t job_id, uint32_t step_id,
 		||  (start_time && (rec->start_time != start_time)))
 			continue;
 		/* debug("dequeue %u.%u", job_id, step_id); */
-		list_delete(iter);
+		list_delete_item(iter);
 		break;
 	}
 	list_iterator_destroy(iter);
diff --git a/src/plugins/checkpoint/none/Makefile.in b/src/plugins/checkpoint/none/Makefile.in
index fd29dc4be0f16a6f9a9fd9aa010550bd067a3246..728790b548f9cefcf97ff22e0ca374dd15375a04 100644
--- a/src/plugins/checkpoint/none/Makefile.in
+++ b/src/plugins/checkpoint/none/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -132,6 +133,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -155,6 +157,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -166,6 +169,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/database/Makefile.am b/src/plugins/database/Makefile.am
new file mode 100644
index 0000000000000000000000000000000000000000..f946c5aa1f2641707c89048f5e957418fadaefc6
--- /dev/null
+++ b/src/plugins/database/Makefile.am
@@ -0,0 +1,3 @@
+# Makefile for database plugins
+
+SUBDIRS = flatfile mysql pgsql
diff --git a/src/plugins/database/Makefile.in b/src/plugins/database/Makefile.in
new file mode 100644
index 0000000000000000000000000000000000000000..a536a7ad87e50340fc36fe8ca4b616869d5b5d2f
--- /dev/null
+++ b/src/plugins/database/Makefile.in
@@ -0,0 +1,557 @@
+# Makefile.in generated by automake 1.10 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# Makefile for database plugins
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/plugins/database
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
+	$(top_srcdir)/auxdir/slurm.m4 \
+	$(top_srcdir)/auxdir/x_ac__system_configuration.m4 \
+	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
+	$(top_srcdir)/auxdir/x_ac_aix.m4 \
+	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
+	$(top_srcdir)/auxdir/x_ac_debug.m4 \
+	$(top_srcdir)/auxdir/x_ac_elan.m4 \
+	$(top_srcdir)/auxdir/x_ac_federation.m4 \
+	$(top_srcdir)/auxdir/x_ac_gpl_licensed.m4 \
+	$(top_srcdir)/auxdir/x_ac_gtk.m4 \
+	$(top_srcdir)/auxdir/x_ac_munge.m4 \
+	$(top_srcdir)/auxdir/x_ac_ncurses.m4 \
+	$(top_srcdir)/auxdir/x_ac_pam.m4 \
+	$(top_srcdir)/auxdir/x_ac_ptrace.m4 \
+	$(top_srcdir)/auxdir/x_ac_readline.m4 \
+	$(top_srcdir)/auxdir/x_ac_setpgrp.m4 \
+	$(top_srcdir)/auxdir/x_ac_setproctitle.m4 \
+	$(top_srcdir)/auxdir/x_ac_sgi_job.m4 \
+	$(top_srcdir)/auxdir/x_ac_slurm_ssl.m4 \
+	$(top_srcdir)/auxdir/x_ac_xcpu.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/slurm/slurm.h
+CONFIG_CLEAN_FILES =
+SOURCES =
+DIST_SOURCES =
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+	html-recursive info-recursive install-data-recursive \
+	install-dvi-recursive install-exec-recursive \
+	install-html-recursive install-info-recursive \
+	install-pdf-recursive install-ps-recursive install-recursive \
+	installcheck-recursive installdirs-recursive pdf-recursive \
+	ps-recursive uninstall-recursive
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive	\
+  distclean-recursive maintainer-clean-recursive
+ETAGS = etags
+CTAGS = ctags
+DIST_SUBDIRS = $(SUBDIRS)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTHD_CFLAGS = @AUTHD_CFLAGS@
+AUTHD_LIBS = @AUTHD_LIBS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BG_INCLUDES = @BG_INCLUDES@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CMD_LDFLAGS = @CMD_LDFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ELAN_LIBS = @ELAN_LIBS@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FEDERATION_LDFLAGS = @FEDERATION_LDFLAGS@
+FFLAGS = @FFLAGS@
+GREP = @GREP@
+GTK2_CFLAGS = @GTK2_CFLAGS@
+GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
+HAVEPKGCONFIG = @HAVEPKGCONFIG@
+HAVE_AIX = @HAVE_AIX@
+HAVE_ELAN = @HAVE_ELAN@
+HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_LDFLAGS = @LIB_LDFLAGS@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
+MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
+MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
+NCURSES = @NCURSES@
+NUMA_LIBS = @NUMA_LIBS@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PAM_LIBS = @PAM_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
+PLPA_LIBS = @PLPA_LIBS@
+PROCTRACKDIR = @PROCTRACKDIR@
+PROJECT = @PROJECT@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+RELEASE = @RELEASE@
+SEMAPHORE_LIBS = @SEMAPHORE_LIBS@
+SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMD_PORT = @SLURMD_PORT@
+SLURM_API_AGE = @SLURM_API_AGE@
+SLURM_API_CURRENT = @SLURM_API_CURRENT@
+SLURM_API_MAJOR = @SLURM_API_MAJOR@
+SLURM_API_REVISION = @SLURM_API_REVISION@
+SLURM_API_VERSION = @SLURM_API_VERSION@
+SLURM_MAJOR = @SLURM_MAJOR@
+SLURM_MICRO = @SLURM_MICRO@
+SLURM_MINOR = @SLURM_MINOR@
+SLURM_VERSION = @SLURM_VERSION@
+SO_LDFLAGS = @SO_LDFLAGS@
+SSL_CPPFLAGS = @SSL_CPPFLAGS@
+SSL_LDFLAGS = @SSL_LDFLAGS@
+SSL_LIBS = @SSL_LIBS@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+SUBDIRS = flatfile mysql pgsql
+all: all-recursive
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/plugins/database/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu  src/plugins/database/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+#     (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+	@failcom='exit 1'; \
+	for f in x $$MAKEFLAGS; do \
+	  case $$f in \
+	    *=* | --[!k]*);; \
+	    *k*) failcom='fail=yes';; \
+	  esac; \
+	done; \
+	dot_seen=no; \
+	target=`echo $@ | sed s/-recursive//`; \
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  echo "Making $$target in $$subdir"; \
+	  if test "$$subdir" = "."; then \
+	    dot_seen=yes; \
+	    local_target="$$target-am"; \
+	  else \
+	    local_target="$$target"; \
+	  fi; \
+	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	  || eval $$failcom; \
+	done; \
+	if test "$$dot_seen" = "no"; then \
+	  $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+	fi; test -z "$$fail"
+
+$(RECURSIVE_CLEAN_TARGETS):
+	@failcom='exit 1'; \
+	for f in x $$MAKEFLAGS; do \
+	  case $$f in \
+	    *=* | --[!k]*);; \
+	    *k*) failcom='fail=yes';; \
+	  esac; \
+	done; \
+	dot_seen=no; \
+	case "$@" in \
+	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+	  *) list='$(SUBDIRS)' ;; \
+	esac; \
+	rev=''; for subdir in $$list; do \
+	  if test "$$subdir" = "."; then :; else \
+	    rev="$$subdir $$rev"; \
+	  fi; \
+	done; \
+	rev="$$rev ."; \
+	target=`echo $@ | sed s/-recursive//`; \
+	for subdir in $$rev; do \
+	  echo "Making $$target in $$subdir"; \
+	  if test "$$subdir" = "."; then \
+	    local_target="$$target-am"; \
+	  else \
+	    local_target="$$target"; \
+	  fi; \
+	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	  || eval $$failcom; \
+	done && test -z "$$fail"
+tags-recursive:
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+	done
+ctags-recursive:
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+	done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+	  include_option=--etags-include; \
+	  empty_fix=.; \
+	else \
+	  include_option=--include; \
+	  empty_fix=; \
+	fi; \
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    test ! -f $$subdir/TAGS || \
+	      tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
+	  fi; \
+	done; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+	list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    test -d "$(distdir)/$$subdir" \
+	    || $(MKDIR_P) "$(distdir)/$$subdir" \
+	    || exit 1; \
+	    distdir=`$(am__cd) $(distdir) && pwd`; \
+	    top_distdir=`$(am__cd) $(top_distdir) && pwd`; \
+	    (cd $$subdir && \
+	      $(MAKE) $(AM_MAKEFLAGS) \
+	        top_distdir="$$top_distdir" \
+	        distdir="$$distdir/$$subdir" \
+		am__remove_distdir=: \
+		am__skip_length_check=: \
+	        distdir) \
+	      || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-recursive
+all-am: Makefile
+installdirs: installdirs-recursive
+installdirs-am:
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-recursive
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-recursive
+	-rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+info: info-recursive
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-recursive
+
+install-exec-am:
+
+install-html: install-html-recursive
+
+install-info: install-info-recursive
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-ps: install-ps-recursive
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \
+	install-strip
+
+.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
+	all all-am check check-am clean clean-generic clean-libtool \
+	ctags ctags-recursive distclean distclean-generic \
+	distclean-libtool distclean-tags distdir dvi dvi-am html \
+	html-am info info-am install install-am install-data \
+	install-data-am install-dvi install-dvi-am install-exec \
+	install-exec-am install-html install-html-am install-info \
+	install-info-am install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs installdirs-am maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-generic \
+	mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \
+	uninstall uninstall-am
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/plugins/database/flatfile/Makefile.am b/src/plugins/database/flatfile/Makefile.am
new file mode 100644
index 0000000000000000000000000000000000000000..ed9ea232e48ddeeea4042caa8d4069724e75a82c
--- /dev/null
+++ b/src/plugins/database/flatfile/Makefile.am
@@ -0,0 +1,19 @@
+# Makefile for database/flatfile plugin
+
+AUTOMAKE_OPTIONS = foreign
+
+PLUGIN_FLAGS = -module -avoid-version --export-dynamic 
+
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
+
+pkglib_LTLIBRARIES = database_flatfile.la
+
+# Flatfile database plugin.
+database_flatfile_la_SOURCES = database_flatfile.c \
+		flatfile_jobacct.c flatfile_jobacct.h \
+		flatfile_jobcomp.c flatfile_jobcomp.h \
+		flatfile_jobacct_process.c flatfile_jobacct_process.h \
+		flatfile_jobcomp_process.c flatfile_jobcomp_process.h
+database_flatfile_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
+database_flatfile_la_LIBADD  = $(top_builddir)/src/common/libcommon.la
+
diff --git a/src/plugins/database/flatfile/Makefile.in b/src/plugins/database/flatfile/Makefile.in
new file mode 100644
index 0000000000000000000000000000000000000000..4288e2a4e73e96a7e66013fd0d14dedc1b130a7d
--- /dev/null
+++ b/src/plugins/database/flatfile/Makefile.in
@@ -0,0 +1,560 @@
+# Makefile.in generated by automake 1.10 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# Makefile for database/flatfile plugin
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/plugins/database/flatfile
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
+	$(top_srcdir)/auxdir/slurm.m4 \
+	$(top_srcdir)/auxdir/x_ac__system_configuration.m4 \
+	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
+	$(top_srcdir)/auxdir/x_ac_aix.m4 \
+	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
+	$(top_srcdir)/auxdir/x_ac_debug.m4 \
+	$(top_srcdir)/auxdir/x_ac_elan.m4 \
+	$(top_srcdir)/auxdir/x_ac_federation.m4 \
+	$(top_srcdir)/auxdir/x_ac_gpl_licensed.m4 \
+	$(top_srcdir)/auxdir/x_ac_gtk.m4 \
+	$(top_srcdir)/auxdir/x_ac_munge.m4 \
+	$(top_srcdir)/auxdir/x_ac_ncurses.m4 \
+	$(top_srcdir)/auxdir/x_ac_pam.m4 \
+	$(top_srcdir)/auxdir/x_ac_ptrace.m4 \
+	$(top_srcdir)/auxdir/x_ac_readline.m4 \
+	$(top_srcdir)/auxdir/x_ac_setpgrp.m4 \
+	$(top_srcdir)/auxdir/x_ac_setproctitle.m4 \
+	$(top_srcdir)/auxdir/x_ac_sgi_job.m4 \
+	$(top_srcdir)/auxdir/x_ac_slurm_ssl.m4 \
+	$(top_srcdir)/auxdir/x_ac_xcpu.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/slurm/slurm.h
+CONFIG_CLEAN_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(pkglibdir)"
+pkglibLTLIBRARIES_INSTALL = $(INSTALL)
+LTLIBRARIES = $(pkglib_LTLIBRARIES)
+database_flatfile_la_DEPENDENCIES =  \
+	$(top_builddir)/src/common/libcommon.la
+am_database_flatfile_la_OBJECTS = database_flatfile.lo \
+	flatfile_jobacct.lo flatfile_jobcomp.lo \
+	flatfile_jobacct_process.lo flatfile_jobcomp_process.lo
+database_flatfile_la_OBJECTS = $(am_database_flatfile_la_OBJECTS)
+database_flatfile_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(database_flatfile_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
+SOURCES = $(database_flatfile_la_SOURCES)
+DIST_SOURCES = $(database_flatfile_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTHD_CFLAGS = @AUTHD_CFLAGS@
+AUTHD_LIBS = @AUTHD_LIBS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BG_INCLUDES = @BG_INCLUDES@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CMD_LDFLAGS = @CMD_LDFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ELAN_LIBS = @ELAN_LIBS@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FEDERATION_LDFLAGS = @FEDERATION_LDFLAGS@
+FFLAGS = @FFLAGS@
+GREP = @GREP@
+GTK2_CFLAGS = @GTK2_CFLAGS@
+GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
+HAVEPKGCONFIG = @HAVEPKGCONFIG@
+HAVE_AIX = @HAVE_AIX@
+HAVE_ELAN = @HAVE_ELAN@
+HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_LDFLAGS = @LIB_LDFLAGS@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
+MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
+MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
+NCURSES = @NCURSES@
+NUMA_LIBS = @NUMA_LIBS@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PAM_LIBS = @PAM_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
+PLPA_LIBS = @PLPA_LIBS@
+PROCTRACKDIR = @PROCTRACKDIR@
+PROJECT = @PROJECT@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+RELEASE = @RELEASE@
+SEMAPHORE_LIBS = @SEMAPHORE_LIBS@
+SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMD_PORT = @SLURMD_PORT@
+SLURM_API_AGE = @SLURM_API_AGE@
+SLURM_API_CURRENT = @SLURM_API_CURRENT@
+SLURM_API_MAJOR = @SLURM_API_MAJOR@
+SLURM_API_REVISION = @SLURM_API_REVISION@
+SLURM_API_VERSION = @SLURM_API_VERSION@
+SLURM_MAJOR = @SLURM_MAJOR@
+SLURM_MICRO = @SLURM_MICRO@
+SLURM_MINOR = @SLURM_MINOR@
+SLURM_VERSION = @SLURM_VERSION@
+SO_LDFLAGS = @SO_LDFLAGS@
+SSL_CPPFLAGS = @SSL_CPPFLAGS@
+SSL_LDFLAGS = @SSL_LDFLAGS@
+SSL_LIBS = @SSL_LIBS@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign
+PLUGIN_FLAGS = -module -avoid-version --export-dynamic 
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
+pkglib_LTLIBRARIES = database_flatfile.la
+
+# Flatfile database plugin.
+database_flatfile_la_SOURCES = database_flatfile.c \
+		flatfile_jobacct.c flatfile_jobacct.h \
+		flatfile_jobcomp.c flatfile_jobcomp.h \
+		flatfile_jobacct_process.c flatfile_jobacct_process.h \
+		flatfile_jobcomp_process.c flatfile_jobcomp_process.h
+
+database_flatfile_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
+database_flatfile_la_LIBADD = $(top_builddir)/src/common/libcommon.la
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/plugins/database/flatfile/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  src/plugins/database/flatfile/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
+	@$(NORMAL_INSTALL)
+	test -z "$(pkglibdir)" || $(MKDIR_P) "$(DESTDIR)$(pkglibdir)"
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  if test -f $$p; then \
+	    f=$(am__strip_dir) \
+	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	  else :; fi; \
+	done
+
+uninstall-pkglibLTLIBRARIES:
+	@$(NORMAL_UNINSTALL)
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  p=$(am__strip_dir) \
+	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	done
+
+clean-pkglibLTLIBRARIES:
+	-test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES)
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+database_flatfile.la: $(database_flatfile_la_OBJECTS) $(database_flatfile_la_DEPENDENCIES) 
+	$(database_flatfile_la_LINK) -rpath $(pkglibdir) $(database_flatfile_la_OBJECTS) $(database_flatfile_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/database_flatfile.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flatfile_jobacct.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flatfile_jobacct_process.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flatfile_jobcomp.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flatfile_jobcomp_process.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+	for dir in "$(DESTDIR)$(pkglibdir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-pkglibLTLIBRARIES
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pkglibLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-pkglibLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-pkglibLTLIBRARIES \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-pkglibLTLIBRARIES
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/plugins/database/flatfile/database_flatfile.c b/src/plugins/database/flatfile/database_flatfile.c
new file mode 100644
index 0000000000000000000000000000000000000000..66d032ccb6a555fdcf6a95fcdd8273ecaa268b53
--- /dev/null
+++ b/src/plugins/database/flatfile/database_flatfile.c
@@ -0,0 +1,236 @@
+/*****************************************************************************\
+ *  database_flatfile.c - Store/Get all information in a flatfile.
+ *
+ *  $Id: database_flatfile.c 10893 2007-01-29 21:53:48Z da $
+ *****************************************************************************
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#if HAVE_STDINT_H
+#  include <stdint.h>
+#endif
+#if HAVE_INTTYPES_H
+#  include <inttypes.h>
+#endif
+
+#include <stdio.h>
+#include <slurm/slurm_errno.h>
+#include "src/plugins/jobacct/common/jobacct_common.h"
+
+#include "src/slurmctld/slurmctld.h"
+#include "flatfile_jobacct.h"
+#include "flatfile_jobcomp.h"
+
+/*
+ * These variables are required by the generic plugin interface.  If they
+ * are not found in the plugin, the plugin loader will ignore it.
+ *
+ * plugin_name - a string giving a human-readable description of the
+ * plugin.  There is no maximum length, but the symbol must refer to
+ * a valid string.
+ *
+ * plugin_type - a string suggesting the type of the plugin or its
+ * applicability to a particular form of data or method of data handling.
+ * If the low-level plugin API is used, the contents of this string are
+ * unimportant and may be anything.  SLURM uses the higher-level plugin
+ * interface which requires this string to be of the form
+ *
+ *	<application>/<method>
+ *
+ * where <application> is a description of the intended application of
+ * the plugin (e.g., "jobacct" for SLURM job completion logging) and <method>
+ * is a description of how this plugin satisfies that application.  SLURM will
+ * only load job completion logging plugins if the plugin_type string has a 
+ * prefix of "jobacct/".
+ *
+ * plugin_version - an unsigned 32-bit integer giving the version number
+ * of the plugin.  If major and minor revisions are desired, the major
+ * version number may be multiplied by a suitable magnitude constant such
+ * as 100 or 1000.  Various SLURM versions will likely require a certain
+ * minimum versions for their plugins as the job accounting API 
+ * matures.
+ */
+const char plugin_name[] = "Database FLATFILE plugin";
+const char plugin_type[] = "database/flatfile";
+const uint32_t plugin_version = 100;
+
+/*
+ * init() is called when the plugin is loaded, before any other functions
+ * are called.  Put global initialization here.
+ */
+extern int init ( void )
+{
+	verbose("%s loaded", plugin_name);
+	return SLURM_SUCCESS;
+}
+
+extern int fini ( void )
+{
+	return SLURM_SUCCESS;
+}
+/* 
+ * Initialize the database make sure tables are created and in working
+ * order
+ */
+extern int database_p_jobacct_init()
+{
+	return flatfile_jobacct_init();	
+}
+
+/*
+ * finish up database connection
+ */
+extern int database_p_jobacct_fini()
+{
+	return flatfile_jobacct_fini();
+}
+
+/* 
+ * load into the database the start of a job
+ */
+extern int database_p_jobacct_job_start(struct job_record *job_ptr)
+{
+	return flatfile_jobacct_job_start(job_ptr);
+}
+
+/* 
+ * load into the database the end of a job
+ */
+extern int database_p_jobacct_job_complete(struct job_record *job_ptr)
+{
+	return flatfile_jobacct_job_complete(job_ptr);
+}
+
+/* 
+ * load into the database the start of a job step
+ */
+extern int database_p_jobacct_step_start(struct step_record *step_ptr)
+{
+	return flatfile_jobacct_step_start(step_ptr);
+}
+
+/* 
+ * load into the database the end of a job step
+ */
+extern int database_p_jobacct_step_complete(struct step_record *step_ptr)
+{
+	return flatfile_jobacct_step_complete(step_ptr);
+}
+
+/* 
+ * load into the database a suspention of a job
+ */
+extern int database_p_jobacct_suspend(struct job_record *job_ptr)
+{
+	return flatfile_jobacct_suspend(job_ptr);
+}
+
+/* 
+ * get info from the database 
+ * in/out job_list List of job_rec_t *
+ * note List needs to be freed when called
+ */
+extern void database_p_jobacct_get_jobs(List job_list, 
+					List selected_steps,
+					List selected_parts,
+					void *params)
+{
+	flatfile_jobacct_get_jobs(job_list,
+				  selected_steps, selected_parts,
+				  params);
+	return;
+}
+
+/* 
+ * expire old info from the database 
+ */
+extern void database_p_jobacct_archive(List selected_parts,
+				       void *params)
+{
+	flatfile_jobacct_archive(selected_parts, params);
+	return;
+}
+
+extern int database_p_jobcomp_init(char * location)
+{
+	return flatfile_jobcomp_init(location);
+}
+
+extern int database_p_jobcomp_fini()
+{
+	return flatfile_jobcomp_fini();
+}
+
+extern int database_p_jobcomp_log_record(struct job_record *job_ptr)
+{
+	return flatfile_jobcomp_log_record(job_ptr);
+}
+
+extern int database_p_jobcomp_get_errno(void)
+{
+	return flatfile_jobcomp_get_errno();
+}
+
+extern char *database_p_jobcomp_strerror(int errnum)
+{
+	return flatfile_jobcomp_strerror(errnum);
+}
+
+/* 
+ * get info from the database 
+ * in/out job_list List of job_rec_t *
+ * note List needs to be freed when called
+ */
+extern void database_p_jobcomp_get_jobs(List job_list, 
+					List selected_steps,
+					List selected_parts,
+					void *params)
+{
+	flatfile_jobcomp_get_jobs(job_list, 
+				  selected_steps, selected_parts,
+				  params);	
+	return;
+}
+
+/* 
+ * expire old info from the database 
+ */
+extern void database_p_jobcomp_archive(List selected_parts, void *params)
+{
+	flatfile_jobcomp_archive(selected_parts, params);
+	return;
+}
diff --git a/src/plugins/database/flatfile/flatfile_jobacct.c b/src/plugins/database/flatfile/flatfile_jobacct.c
new file mode 100644
index 0000000000000000000000000000000000000000..7e863f17d38942beb3d5b82791652750a716c9b5
--- /dev/null
+++ b/src/plugins/database/flatfile/flatfile_jobacct.c
@@ -0,0 +1,580 @@
+/*****************************************************************************\
+ *  flatfile_jobacct.c - functions the flatfile jobacct database.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+
+#include "flatfile_jobacct.h"
+#include "flatfile_jobacct_process.h"
+
+#define BUFFER_SIZE 4096
+
+static FILE *		LOGFILE;
+static int		LOGFILE_FD;
+static pthread_mutex_t  logfile_lock = PTHREAD_MUTEX_INITIALIZER;
+static int              database_init;
+/* Format of the JOB_STEP record */
+const char *_jobstep_format = 
+"%d "
+"%u "	/* stepid */
+"%d "	/* completion status */
+"%d "	/* completion code */
+"%u "	/* nprocs */
+"%u "	/* number of cpus */
+"%u "	/* elapsed seconds */
+"%u "	/* total cputime seconds */
+"%u "	/* total cputime microseconds */
+"%u "	/* user seconds */
+"%u "	/* user microseconds */
+"%u "	/* system seconds */
+"%u "	/* system microseconds */
+"%u "	/* max rss */
+"%u "	/* max ixrss */
+"%u "	/* max idrss */
+"%u "	/* max isrss */
+"%u "	/* max minflt */
+"%u "	/* max majflt */
+"%u "	/* max nswap */
+"%u "	/* total inblock */
+"%u "	/* total outblock */
+"%u "	/* total msgsnd */
+"%u "	/* total msgrcv */
+"%u "	/* total nsignals */
+"%u "	/* total nvcsw */
+"%u "	/* total nivcsw */
+"%u "	/* max vsize */
+"%u "	/* max vsize task */
+"%.2f "	/* ave vsize */
+"%u "	/* max rss */
+"%u "	/* max rss task */
+"%.2f "	/* ave rss */
+"%u "	/* max pages */
+"%u "	/* max pages task */
+"%.2f "	/* ave pages */
+"%.2f "	/* min cpu */
+"%u "	/* min cpu task */
+"%.2f "	/* ave cpu */
+"%s "	/* step process name */
+"%s "	/* step node names */
+"%u "	/* max vsize node */
+"%u "	/* max rss node */
+"%u "	/* max pages node */
+"%u "	/* min cpu node */
+"%s "   /* account */
+"%d";   /* requester user id */
+
+/*
+ * Print the record to the log file.
+ */
+
+static int _print_record(struct job_record *job_ptr, 
+			 time_t time, char *data)
+{ 
+	static int   rc=SLURM_SUCCESS;
+	char *block_id = NULL;
+	if(!job_ptr->details) {
+		error("job_acct: job=%u doesn't exist", job_ptr->job_id);
+		return SLURM_ERROR;
+	}
+	debug2("_print_record, job=%u, \"%s\"",
+	       job_ptr->job_id, data);
+#ifdef HAVE_BG
+	select_g_get_jobinfo(job_ptr->select_jobinfo, 
+			     SELECT_DATA_BLOCK_ID, 
+			     &block_id);
+		
+#endif
+	if(!block_id)
+		block_id = xstrdup("-");
+
+	slurm_mutex_lock( &logfile_lock );
+
+	if (fprintf(LOGFILE,
+		    "%u %s %u %u %d %d %s - %s\n",
+		    job_ptr->job_id, job_ptr->partition,
+		    (int)job_ptr->details->submit_time, (int)time, 
+		    job_ptr->user_id, job_ptr->group_id, block_id, data)
+	    < 0)
+		rc=SLURM_ERROR;
+#ifdef HAVE_FDATSYNC
+	fdatasync(LOGFILE_FD);
+#endif
+	slurm_mutex_unlock( &logfile_lock );
+	xfree(block_id);
+
+	return rc;
+}
+
+/* 
+ * Initialize the database make sure tables are created and in working
+ * order
+ */
+extern int flatfile_jobacct_init ()
+{
+	char *log_file = slurm_get_jobacct_loc();	
+	int 		rc = SLURM_SUCCESS;
+	mode_t		prot = 0600;
+	struct stat	statbuf;
+
+	debug2("jobacct_init() called");
+	slurm_mutex_lock( &logfile_lock );
+	if (LOGFILE)
+		fclose(LOGFILE);
+
+	if (*log_file != '/')
+		fatal("JobAcctLogfile must specify an absolute pathname");
+	if (stat(log_file, &statbuf)==0)       /* preserve current file mode */
+		prot = statbuf.st_mode;
+	LOGFILE = fopen(log_file, "a");
+	if (LOGFILE == NULL) {
+		error("open %s: %m", log_file);
+		database_init = 0;
+		xfree(log_file);
+		slurm_mutex_unlock( &logfile_lock );
+		return SLURM_ERROR;
+	} else
+		chmod(log_file, prot); 
+
+	xfree(log_file);
+
+	if (setvbuf(LOGFILE, NULL, _IOLBF, 0))
+		error("setvbuf() failed");
+	LOGFILE_FD = fileno(LOGFILE);
+	slurm_mutex_unlock( &logfile_lock );
+	database_init = 1;
+	return rc;
+}
+
+/*
+ * finish up database connection
+ */
+extern int flatfile_jobacct_fini ()
+{
+	if (LOGFILE)
+		fclose(LOGFILE);
+	return SLURM_SUCCESS;
+}
+
+/* 
+ * load into the database the start of a job
+ */
+extern int flatfile_jobacct_job_start (struct job_record *job_ptr)
+{
+	int	i,
+		ncpus=0,
+		rc=SLURM_SUCCESS,
+		tmp;
+	char	buf[BUFFER_SIZE], *jname, *account, *nodes;
+	long	priority;
+	int track_steps = 0;
+
+	if(!database_init) {
+		debug("jobacct init was not called or it failed");
+		return SLURM_ERROR;
+	}
+
+	debug2("jobacct_job_start() called");
+	for (i=0; i < job_ptr->num_cpu_groups; i++)
+		ncpus += (job_ptr->cpus_per_node[i])
+			* (job_ptr->cpu_count_reps[i]);
+	priority = (job_ptr->priority == NO_VAL) ?
+		-1L : (long) job_ptr->priority;
+
+	if ((tmp = strlen(job_ptr->name))) {
+		jname = xmalloc(++tmp);
+		for (i=0; i<tmp; i++) {
+			if (isspace(job_ptr->name[i]))
+				jname[i]='_';
+			else
+				jname[i]=job_ptr->name[i];
+		}
+	} else {
+		jname = xstrdup("allocation");
+		track_steps = 1;
+	}
+
+	if (job_ptr->account && job_ptr->account[0])
+		account = job_ptr->account;
+	else
+		account = "(null)";
+	if (job_ptr->nodes && job_ptr->nodes[0])
+		nodes = job_ptr->nodes;
+	else
+		nodes = "(null)";
+
+	if(job_ptr->batch_flag)
+		track_steps = 1;
+
+	job_ptr->requid = -1; /* force to -1 for sacct to know this
+			       * hasn't been set yet */
+
+	tmp = snprintf(buf, BUFFER_SIZE,
+		       "%d %s %d %ld %u %s %s",
+		       JOB_START, jname,
+		       track_steps, priority, job_ptr->num_procs,
+		       nodes, account);
+
+	rc = _print_record(job_ptr, job_ptr->start_time, buf);
+	
+	xfree(jname);
+	return rc;
+}
+
+/* 
+ * load into the database the end of a job
+ */
+extern int flatfile_jobacct_job_complete (struct job_record *job_ptr)
+{
+	char buf[BUFFER_SIZE];
+	if(!database_init) {
+		debug("jobacct init was not called or it failed");
+		return SLURM_ERROR;
+	}
+	
+	debug2("jobacct_job_complete() called");
+	if (job_ptr->end_time == 0) {
+		debug("jobacct: job %u never started", job_ptr->job_id);
+		return SLURM_ERROR;
+	}
+	/* leave the requid as a %d since we want to see if it is -1
+	   in sacct */
+	snprintf(buf, BUFFER_SIZE, "%d %u %d %d",
+		 JOB_TERMINATED,
+		 (int) (job_ptr->end_time - job_ptr->start_time),
+		 job_ptr->job_state & (~JOB_COMPLETING),
+		 job_ptr->requid);
+	
+	return  _print_record(job_ptr, job_ptr->end_time, buf);
+}
+
+/* 
+ * load into the database the start of a job step
+ */
+extern int flatfile_jobacct_step_start (struct step_record *step_ptr)
+{
+	char buf[BUFFER_SIZE];
+	int cpus = 0;
+	char node_list[BUFFER_SIZE];
+#ifdef HAVE_BG
+	char *ionodes = NULL;
+#endif
+	float float_tmp = 0;
+	char *account;
+	
+	if(!database_init) {
+		debug("jobacct init was not called or it failed");
+		return SLURM_ERROR;
+	}
+
+#ifdef HAVE_BG
+	cpus = step_ptr->job_ptr->num_procs;
+	select_g_get_jobinfo(step_ptr->job_ptr->select_jobinfo, 
+			     SELECT_DATA_IONODES, 
+			     &ionodes);
+	if(ionodes) {
+		snprintf(node_list, BUFFER_SIZE, 
+			 "%s[%s]", step_ptr->job_ptr->nodes, ionodes);
+		xfree(ionodes);
+	} else
+		snprintf(node_list, BUFFER_SIZE, "%s",
+			 step_ptr->job_ptr->nodes);
+	
+#else
+	if(!step_ptr->step_layout || !step_ptr->step_layout->task_cnt) {
+		cpus = step_ptr->job_ptr->num_procs;
+		snprintf(node_list, BUFFER_SIZE, "%s", step_ptr->job_ptr->nodes);
+	} else {
+		cpus = step_ptr->step_layout->task_cnt;
+		snprintf(node_list, BUFFER_SIZE, "%s", 
+			 step_ptr->step_layout->node_list);
+	}
+#endif
+	if (step_ptr->job_ptr->account && step_ptr->job_ptr->account[0])
+		account = step_ptr->job_ptr->account;
+	else
+		account = "(null)";
+
+	step_ptr->job_ptr->requid = -1; /* force to -1 for sacct to know this
+				     * hasn't been set yet  */
+
+	snprintf(buf, BUFFER_SIZE, _jobstep_format,
+		 JOB_STEP,
+		 step_ptr->step_id,	/* stepid */
+		 JOB_RUNNING,		/* completion status */
+		 0,     		/* completion code */
+		 cpus,          	/* number of tasks */
+		 cpus,                  /* number of cpus */
+		 0,	        	/* elapsed seconds */
+		 0,                    /* total cputime seconds */
+		 0,    		/* total cputime seconds */
+		 0,	/* user seconds */
+		 0,/* user microseconds */
+		 0,	/* system seconds */
+		 0,/* system microsecs */
+		 0,	/* max rss */
+		 0,	/* max ixrss */
+		 0,	/* max idrss */
+		 0,	/* max isrss */
+		 0,	/* max minflt */
+		 0,	/* max majflt */
+		 0,	/* max nswap */
+		 0,	/* total inblock */
+		 0,	/* total outblock */
+		 0,	/* total msgsnd */
+		 0,	/* total msgrcv */
+		 0,	/* total nsignals */
+		 0,	/* total nvcsw */
+		 0,	/* total nivcsw */
+		 0,	/* max vsize */
+		 0,	/* max vsize task */
+		 float_tmp,	/* ave vsize */
+		 0,	/* max rss */
+		 0,	/* max rss task */
+		 float_tmp,	/* ave rss */
+		 0,	/* max pages */
+		 0,	/* max pages task */
+		 float_tmp,	/* ave pages */
+		 float_tmp,	/* min cpu */
+		 0,	/* min cpu task */
+		 float_tmp,	/* ave cpu */
+		 step_ptr->name,    /* step exe name */
+		 node_list,     /* name of nodes step running on */
+		 0,	/* max vsize node */
+		 0,	/* max rss node */
+		 0,	/* max pages node */
+		 0,	/* min cpu node */
+		 account,
+		 step_ptr->job_ptr->requid); /* requester user id */
+		 
+	return _print_record(step_ptr->job_ptr, step_ptr->start_time, buf);
+
+}
+
+/* 
+ * load into the database the end of a job step
+ */
+extern int flatfile_jobacct_step_complete (struct step_record *step_ptr)
+{
+	char buf[BUFFER_SIZE];
+	time_t now;
+	int elapsed;
+	int comp_status;
+	int cpus = 0;
+	char node_list[BUFFER_SIZE];
+	struct jobacctinfo *jobacct = (struct jobacctinfo *)step_ptr->jobacct;
+#ifdef HAVE_BG
+	char *ionodes = NULL;
+#endif
+	float ave_vsize = 0, ave_rss = 0, ave_pages = 0;
+	float ave_cpu = 0, ave_cpu2 = 0;
+	char *account;
+
+	if(!database_init) {
+		debug("jobacct init was not called or it failed");
+		return SLURM_ERROR;
+	}
+	
+	now = time(NULL);
+	
+	if ((elapsed=now-step_ptr->start_time)<0)
+		elapsed=0;	/* For *very* short jobs, if clock is wrong */
+	if (step_ptr->exit_code)
+		comp_status = JOB_FAILED;
+	else
+		comp_status = JOB_COMPLETE;
+
+#ifdef HAVE_BG
+	cpus = step_ptr->job_ptr->num_procs;
+	select_g_get_jobinfo(step_ptr->job_ptr->select_jobinfo, 
+			     SELECT_DATA_IONODES, 
+			     &ionodes);
+	if(ionodes) {
+		snprintf(node_list, BUFFER_SIZE, 
+			 "%s[%s]", step_ptr->job_ptr->nodes, ionodes);
+		xfree(ionodes);
+	} else
+		snprintf(node_list, BUFFER_SIZE, "%s", 
+			 step_ptr->job_ptr->nodes);
+	
+#else
+	if(!step_ptr->step_layout || !step_ptr->step_layout->task_cnt) {
+		cpus = step_ptr->job_ptr->num_procs;
+		snprintf(node_list, BUFFER_SIZE, "%s", step_ptr->job_ptr->nodes);
+	
+	} else {
+		cpus = step_ptr->step_layout->task_cnt;
+		snprintf(node_list, BUFFER_SIZE, "%s", 
+			 step_ptr->step_layout->node_list);
+	}
+#endif
+	/* figure out the ave of the totals sent */
+	if(cpus > 0) {
+		ave_vsize = jobacct->tot_vsize;
+		ave_vsize /= cpus;
+		ave_rss = jobacct->tot_rss;
+		ave_rss /= cpus;
+		ave_pages = jobacct->tot_pages;
+		ave_pages /= cpus;
+		ave_cpu = jobacct->tot_cpu;
+		ave_cpu /= cpus;	
+		ave_cpu /= 100;
+	}
+ 
+	if(jobacct->min_cpu != (uint32_t)NO_VAL) {
+		ave_cpu2 = jobacct->min_cpu;
+		ave_cpu2 /= 100;
+	}
+
+	if (step_ptr->job_ptr->account && step_ptr->job_ptr->account[0])
+		account = step_ptr->job_ptr->account;
+	else
+		account = "(null)";
+
+	snprintf(buf, BUFFER_SIZE, _jobstep_format,
+		 JOB_STEP,
+		 step_ptr->step_id,	/* stepid */
+		 comp_status,		/* completion status */
+		 step_ptr->exit_code,	/* completion code */
+		 cpus,          	/* number of tasks */
+		 cpus,                  /* number of cpus */
+		 elapsed,	        /* elapsed seconds */
+		 /* total cputime seconds */
+		 jobacct->rusage.ru_utime.tv_sec	
+		 + jobacct->rusage.ru_stime.tv_sec,
+		 /* total cputime seconds */
+		 jobacct->rusage.ru_utime.tv_usec	
+		 + jobacct->rusage.ru_stime.tv_usec,
+		 jobacct->rusage.ru_utime.tv_sec,	/* user seconds */
+		 jobacct->rusage.ru_utime.tv_usec,/* user microseconds */
+		 jobacct->rusage.ru_stime.tv_sec,	/* system seconds */
+		 jobacct->rusage.ru_stime.tv_usec,/* system microsecs */
+		 jobacct->rusage.ru_maxrss,	/* max rss */
+		 jobacct->rusage.ru_ixrss,	/* max ixrss */
+		 jobacct->rusage.ru_idrss,	/* max idrss */
+		 jobacct->rusage.ru_isrss,	/* max isrss */
+		 jobacct->rusage.ru_minflt,	/* max minflt */
+		 jobacct->rusage.ru_majflt,	/* max majflt */
+		 jobacct->rusage.ru_nswap,	/* max nswap */
+		 jobacct->rusage.ru_inblock,	/* total inblock */
+		 jobacct->rusage.ru_oublock,	/* total outblock */
+		 jobacct->rusage.ru_msgsnd,	/* total msgsnd */
+		 jobacct->rusage.ru_msgrcv,	/* total msgrcv */
+		 jobacct->rusage.ru_nsignals,	/* total nsignals */
+		 jobacct->rusage.ru_nvcsw,	/* total nvcsw */
+		 jobacct->rusage.ru_nivcsw,	/* total nivcsw */
+		 jobacct->max_vsize,	/* max vsize */
+		 jobacct->max_vsize_id.taskid,	/* max vsize node */
+		 ave_vsize,	/* ave vsize */
+		 jobacct->max_rss,	/* max vsize */
+		 jobacct->max_rss_id.taskid,	/* max rss node */
+		 ave_rss,	/* ave rss */
+		 jobacct->max_pages,	/* max pages */
+		 jobacct->max_pages_id.taskid,	/* max pages node */
+		 ave_pages,	/* ave pages */
+		 ave_cpu2,	/* min cpu */
+		 jobacct->min_cpu_id.taskid,	/* min cpu node */
+		 ave_cpu,	/* ave cpu */
+		 step_ptr->name,      	/* step exe name */
+		 node_list, /* name of nodes step running on */
+		 jobacct->max_vsize_id.nodeid,	/* max vsize task */
+		 jobacct->max_rss_id.nodeid,	/* max rss task */
+		 jobacct->max_pages_id.nodeid,	/* max pages task */
+		 jobacct->min_cpu_id.nodeid,	/* min cpu task */
+		 account,
+		 step_ptr->job_ptr->requid); /* requester user id */
+		 
+	return _print_record(step_ptr->job_ptr, now, buf);	
+}
+
+/* 
+ * load into the database a suspention of a job
+ */
+extern int flatfile_jobacct_suspend (struct job_record *job_ptr)
+{
+	char buf[BUFFER_SIZE];
+	static time_t	now = 0;
+	static time_t	temp = 0;
+	int elapsed;
+	if(!database_init) {
+		debug("jobacct init was not called or it failed");
+		return SLURM_ERROR;
+	}
+	
+	/* tell what time has passed */
+	if(!now)
+		now = job_ptr->start_time;
+	temp = now;
+	now = time(NULL);
+	
+	if ((elapsed=now-temp) < 0)
+		elapsed=0;	/* For *very* short jobs, if clock is wrong */
+	
+	/* here we are really just going for a marker in time to tell when
+	 * the process was suspended or resumed (check job state), we don't 
+	 * really need to keep track of anything else */
+	snprintf(buf, BUFFER_SIZE, "%d %u %d",
+		 JOB_SUSPEND,
+		 elapsed,
+		 job_ptr->job_state & (~JOB_COMPLETING));/* job status */
+		
+	return _print_record(job_ptr, now, buf);
+}
+
+/* 
+ * get info from the database 
+ * in/out job_list List of job_rec_t *
+ * note List needs to be freed when called
+ */
+extern void flatfile_jobacct_get_jobs(List job_list, 
+				      List selected_steps, List selected_parts,
+				      void *params)
+{
+	flatfile_jobacct_process_get_jobs(job_list, 
+					  selected_steps, selected_parts,
+					  params);	
+	return;
+}
+
+/* 
+ * expire old info from the database 
+ */
+extern void flatfile_jobacct_archive(List selected_parts,
+				     void *params)
+{
+	flatfile_jobacct_process_archive(selected_parts, params);
+	return;
+}
diff --git a/src/plugins/database/flatfile/flatfile_jobacct.h b/src/plugins/database/flatfile/flatfile_jobacct.h
new file mode 100644
index 0000000000000000000000000000000000000000..31acff44d4bca80055a4fbecf4606d6f926ec9b3
--- /dev/null
+++ b/src/plugins/database/flatfile/flatfile_jobacct.h
@@ -0,0 +1,59 @@
+/*****************************************************************************\
+ *  flatfile_jobacct.h - functions the flatfile jobacct database.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+
+#ifndef _HAVE_FLATFILE_JOBACCT_H
+#define _HAVE_FLATFILE_JOBACCT_H
+
+#include "src/plugins/jobacct/common/jobacct_common.h"
+#include "src/slurmctld/slurmctld.h"
+
+extern int flatfile_jobacct_init();
+extern int flatfile_jobacct_fini();
+extern int flatfile_jobacct_job_start(struct job_record *job_ptr);
+extern int flatfile_jobacct_job_complete(struct job_record *job_ptr);
+extern int flatfile_jobacct_step_start(struct step_record *step_ptr);
+extern int flatfile_jobacct_step_complete(struct step_record *step_ptr);
+extern int flatfile_jobacct_suspend(struct job_record *job_ptr);
+extern void flatfile_jobacct_get_jobs(List job_list, 
+				      List selected_steps, List selected_parts,
+				      void *params);
+extern void flatfile_jobacct_archive(List selected_parts, void *params);
+
+#endif
diff --git a/src/plugins/database/flatfile/flatfile_jobacct_process.c b/src/plugins/database/flatfile/flatfile_jobacct_process.c
new file mode 100644
index 0000000000000000000000000000000000000000..034d97853ce2881716857ce14a9bd19337f400ae
--- /dev/null
+++ b/src/plugins/database/flatfile/flatfile_jobacct_process.c
@@ -0,0 +1,1190 @@
+/*****************************************************************************\
+ *  flatfile_jobacct_process.c - functions the processing of
+ *                               information from the flatfile jobacct
+ *                               database.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+#include <stdlib.h>
+#include <ctype.h>
+#include <sys/stat.h>
+
+#include "src/common/xstring.h"
+#include "src/common/xmalloc.h"
+#include "src/common/slurm_jobacct.h"
+/* Map field names to positions */
+
+/* slurmd uses "(uint32_t) -2" to track data for batch allocations
+ * which have no logical jobsteps. */
+#define BATCH_JOB_TIMESTAMP 0
+#define EXPIRE_READ_LENGTH 10
+#define MAX_RECORD_FIELDS 100
+#define BUFFER_SIZE 1024
+
+typedef struct expired_rec {  /* table of expired jobs */
+	uint32_t job;
+	time_t job_submit;
+	char *line;
+} expired_rec_t;
+
+/* Fields common to all records */
+enum {	F_JOB =	0,
+	F_PARTITION,	
+	F_JOB_SUBMIT,	
+	F_TIMESTAMP,	
+	F_UID,	
+	F_GID,	
+	F_BLOCKID,	
+	F_RESERVED2,	
+	F_RECTYPE,	
+	HEADER_LENGTH
+};
+
+/* JOB_START fields */
+enum {	F_JOBNAME = HEADER_LENGTH,
+	F_TRACK_STEPS,		
+	F_PRIORITY,	
+	F_NCPUS,		
+	F_NODES,
+	F_JOB_ACCOUNT,
+	JOB_START_LENGTH
+};
+
+/* JOB_STEP fields */
+enum {	F_JOBSTEP = HEADER_LENGTH,
+	F_STATUS,
+	F_EXITCODE,
+	F_NTASKS,
+	F_STEPNCPUS,
+	F_ELAPSED,
+	F_CPU_SEC,
+	F_CPU_USEC,
+	F_USER_SEC,
+	F_USER_USEC,
+	F_SYS_SEC,
+	F_SYS_USEC,
+	F_RSS,
+	F_IXRSS,
+	F_IDRSS,
+	F_ISRSS,
+	F_MINFLT,
+	F_MAJFLT,
+	F_NSWAP,
+	F_INBLOCKS,
+	F_OUBLOCKS,
+	F_MSGSND,
+	F_MSGRCV,
+	F_NSIGNALS,
+	F_NVCSW,
+	F_NIVCSW,
+	F_MAX_VSIZE,
+	F_MAX_VSIZE_TASK,
+	F_AVE_VSIZE,
+	F_MAX_RSS,
+	F_MAX_RSS_TASK,
+	F_AVE_RSS,
+	F_MAX_PAGES,
+	F_MAX_PAGES_TASK,
+	F_AVE_PAGES,
+	F_MIN_CPU,
+	F_MIN_CPU_TASK,
+	F_AVE_CPU,
+	F_STEPNAME,
+	F_STEPNODES,
+	F_MAX_VSIZE_NODE,
+	F_MAX_RSS_NODE,
+	F_MAX_PAGES_NODE,
+	F_MIN_CPU_NODE,
+	F_STEP_ACCOUNT,
+	F_STEP_REQUID,
+	JOB_STEP_LENGTH
+};
+
+/* JOB_TERM / JOB_SUSPEND fields */
+enum {	F_TOT_ELAPSED = HEADER_LENGTH,
+	F_TERM_STATUS,
+	F_JOB_REQUID,
+	JOB_TERM_LENGTH
+};
+
+static void _destroy_exp(void *object)
+{
+	expired_rec_t *exp_rec = (expired_rec_t *)object;
+	if(exp_rec) {
+		xfree(exp_rec->line);
+		xfree(exp_rec);
+	}
+}
+
+/* prefix_filename() -- insert a filename prefix into a path
+ *
+ * IN:	path = fully-qualified path+file name
+ *      prefix = the prefix to insert into the file name
+ * RETURNS: pointer to the updated path+file name
+ */
+
+static char *_prefix_filename(char *path, char *prefix) {
+	char	*out;
+	int     i,
+		plen;
+
+	plen = strlen(path);
+	out = xmalloc(plen+strlen(prefix)+1);
+	for (i=plen-1; i>=0; i--)
+		if (path[i]=='/') {
+			break;
+		}
+	i++;
+	*out = 0;
+	strncpy(out, path, i);
+	out[i] = 0;
+	strcat(out, prefix);
+	strcat(out, path+i);
+	return(out);
+}
+
+/* _open_log_file() -- find the current or specified log file, and open it
+ *
+ * IN:		Nothing
+ * RETURNS:	Nothing
+ *
+ * Side effects:
+ * 	- Sets opt_filein to the current system accounting log unless
+ * 	  the user specified another file.
+ */
+
+static FILE *_open_log_file(char *logfile)
+{
+	FILE *fd = fopen(logfile, "r");
+	if (fd == NULL) {
+		perror(logfile);
+		exit(1);
+	}
+	return fd;
+}
+
+static char *_convert_type(int rec_type)
+{
+	switch(rec_type) {
+	case JOB_START:
+		return "JOB_START";
+	case JOB_STEP:
+		return "JOB_STEP";
+	case JOB_TERMINATED:
+		return "JOB_TERMINATED";
+	default:
+		return "UNKNOWN";
+	}
+}
+
+static int _cmp_jrec(const void *a1, const void *a2) {
+	expired_rec_t *j1 = (expired_rec_t *) a1;
+	expired_rec_t *j2 = (expired_rec_t *) a2;
+
+	if (j1->job <  j2->job)
+		return -1;
+	else if (j1->job == j2->job) {
+		if(j1->job_submit == j2->job_submit)
+			return 0;
+		else 
+			return 1;
+	}
+	return 1;
+}
+
+static void _show_rec(char *f[])
+{
+	int 	i;
+	fprintf(stderr, "rec>");
+	for (i=0; f[i]; i++)
+		fprintf(stderr, " %s", f[i]);
+	fprintf(stderr, "\n");
+	return;
+}
+
+static void _do_fdump(char* f[], int lc)
+{
+	int	i=0, j=0;
+	char **type;
+	char    *header[] = {"job",       /* F_JOB */
+			     "partition", /* F_PARTITION */
+			     "job_submit", /* F_JOB_SUBMIT */
+			     "timestamp", /* F_TIMESTAMP */
+			     "uid",	 /* F_UIDGID */
+			     "gid",	 /* F_UIDGID */
+			     "BlockID",  /* F_BLOCKID */
+			     "reserved-2",/* F_RESERVED1 */
+			     "recordType",/* F_RECTYPE */
+			     NULL};
+
+	char	*start[] = {"jobName",	 /* F_JOBNAME */ 
+			    "TrackSteps", /* F_TRACK_STEPS */
+			    "priority",	 /* F_PRIORITY */
+			    "ncpus",	 /* F_NCPUS */
+			    "nodeList", /* F_NODES */
+				"account",   /* F_JOB_ACCOUNT */
+			    NULL};
+		
+	char	*step[] = {"jobStep",	 /* F_JOBSTEP */
+			   "status",	 /* F_STATUS */ 
+			   "exitcode",	 /* F_EXITCODE */
+			   "ntasks",	 /* F_NTASKS */
+			   "ncpus",	 /* F_STEPNCPUS */
+			   "elapsed",	 /* F_ELAPSED */
+			   "cpu_sec",	 /* F_CPU_SEC */
+			   "cpu_usec",	 /* F_CPU_USEC */
+			   "user_sec",	 /* F_USER_SEC */
+			   "user_usec",	 /* F_USER_USEC */
+			   "sys_sec",	 /* F_SYS_SEC */
+			   "sys_usec",	 /* F_SYS_USEC */
+			   "rss",	 /* F_RSS */
+			   "ixrss",	 /* F_IXRSS */
+			   "idrss",	 /* F_IDRSS */
+			   "isrss",	 /* F_ISRSS */
+			   "minflt",	 /* F_MINFLT */
+			   "majflt",	 /* F_MAJFLT */
+			   "nswap",	 /* F_NSWAP */
+			   "inblocks",	 /* F_INBLOCKS */
+			   "oublocks",	 /* F_OUTBLOCKS */
+			   "msgsnd",	 /* F_MSGSND */
+			   "msgrcv",	 /* F_MSGRCV */
+			   "nsignals",	 /* F_NSIGNALS */
+			   "nvcsw",	 /* F_VCSW */
+			   "nivcsw",	 /* F_NIVCSW */
+			   "max_vsize",	 /* F_MAX_VSIZE */
+			   "max_vsize_task",	 /* F_MAX_VSIZE_TASK */
+			   "ave_vsize",	 /* F_AVE_VSIZE */
+			   "max_rss",	 /* F_MAX_RSS */
+			   "max_rss_task",	 /* F_MAX_RSS_TASK */
+			   "ave_rss",	 /* F_AVE_RSS */
+			   "max_pages",	 /* F_MAX_PAGES */
+			   "max_pages_task",	 /* F_MAX_PAGES_TASK */
+			   "ave_pages",	 /* F_AVE_PAGES */
+			   "min_cputime",	 /* F_MIN_CPU */
+			   "min_cputime_task",	 /* F_MIN_CPU_TASK */
+			   "ave_cputime",	 /* F_AVE_RSS */
+			   "StepName",	 /* F_STEPNAME */
+			   "StepNodes",	 /* F_STEPNODES */
+			   "max_vsize_node",	 /* F_MAX_VSIZE_NODE */
+			   "max_rss_node",	 /* F_MAX_RSS_NODE */
+			   "max_pages_node",	 /* F_MAX_PAGES_NODE */
+			   "min_cputime_node",	 /* F_MIN_CPU_NODE */
+			   "account",    /* F_STEP_ACCOUNT */
+			   "requid",     /* F_STEP_REQUID */
+			   NULL};
+       
+	char	*suspend[] = {"Suspend/Run time", /* F_TOT_ELAPSED */
+			      "status",	 /* F_STATUS */ 
+			      NULL};	 
+
+	char	*term[] = {"totElapsed", /* F_TOT_ELAPSED */
+			   "status",	 /* F_STATUS */ 
+			   "requid",     /* F_JOB_REQUID */
+			   NULL};	 
+		
+	i = atoi(f[F_RECTYPE]);
+	printf("\n------- Line %d %s -------\n", lc, _convert_type(i));
+
+	for(j=0; j < HEADER_LENGTH; j++) 
+		printf("%12s: %s\n", header[j], f[j]);
+	switch(i) {
+	case JOB_START:
+		type = start;
+		j = JOB_START_LENGTH;
+		break;
+	case JOB_STEP:
+		type = step;
+		j = JOB_STEP_LENGTH;
+		break;
+	case JOB_SUSPEND:
+		type = suspend;
+		j = JOB_TERM_LENGTH;
+	case JOB_TERMINATED:
+		type = term;
+		j = JOB_TERM_LENGTH;
+		break;
+	default:
+		while(f[j]) {
+			printf("      Field[%02d]: %s\n", j, f[j]); 
+			j++;
+		}
+		return;
+	}
+	
+	for(i=HEADER_LENGTH; i < j; i++)
+       		printf("%12s: %s\n", type[i-HEADER_LENGTH], f[i]);	
+}
+
+static jobacct_job_rec_t *_find_job_record(List job_list, jobacct_header_t header,
+				   int type)
+{
+	jobacct_job_rec_t *job = NULL;
+	ListIterator itr = list_iterator_create(job_list);
+
+	while((job = (jobacct_job_rec_t *)list_next(itr)) != NULL) {
+		if (job->header.jobnum == header.jobnum) {
+			if(job->header.job_submit == 0 && type == JOB_START) {
+				list_remove(itr);
+				jobacct_destroy_job(job);
+				job = NULL;
+				break;
+			}
+		
+			if(job->header.job_submit == BATCH_JOB_TIMESTAMP) {
+				job->header.job_submit = header.job_submit;
+				break;
+			}
+			
+			if(job->header.job_submit == header.job_submit)
+				break;
+			else {
+				/* If we're looking for a later
+				 * record with this job number, we
+				 * know that this one is an older,
+				 * duplicate record.
+				 *   We assume that the newer record
+				 * will be created if it doesn't
+				 * already exist. */
+				job->jobnum_superseded = 1;
+			}
+		}
+	}
+	list_iterator_destroy(itr);
+	return job;
+}
+
+static int _remove_job_record(List job_list, uint32_t jobnum)
+{
+	jobacct_job_rec_t *job = NULL;
+	int rc = SLURM_ERROR;
+	ListIterator itr = list_iterator_create(job_list);
+
+	while((job = (jobacct_job_rec_t *)list_next(itr)) != NULL) {
+		if (job->header.jobnum == jobnum) {
+			list_remove(itr);
+			jobacct_destroy_job(job);
+			rc = SLURM_SUCCESS;
+		}
+	}
+	list_iterator_destroy(itr);
+	return rc;
+}
+
+static jobacct_step_rec_t *_find_step_record(jobacct_job_rec_t *job,
+					     long stepnum)
+{
+	jobacct_step_rec_t *step = NULL;
+	ListIterator itr = NULL;
+
+	if(!list_count(job->steps))
+		return step;
+	
+	itr = list_iterator_create(job->steps);
+	while((step = (jobacct_step_rec_t *)list_next(itr)) != NULL) {
+		if (step->stepnum == stepnum)
+			break;
+	}
+	list_iterator_destroy(itr);
+	return step;
+}
+
+static int _parse_header(char *f[], jobacct_header_t *header)
+{
+	header->jobnum = atoi(f[F_JOB]);
+	header->partition = xstrdup(f[F_PARTITION]);
+	header->job_submit = atoi(f[F_JOB_SUBMIT]);
+	header->timestamp = atoi(f[F_TIMESTAMP]);
+	header->uid = atoi(f[F_UID]);
+	header->gid = atoi(f[F_GID]);
+	header->blockid = xstrdup(f[F_BLOCKID]);
+	return SLURM_SUCCESS;
+}
+
+static int _parse_line(char *f[], void **data, int len)
+{
+	int i = atoi(f[F_RECTYPE]);
+	jobacct_job_rec_t **job = (jobacct_job_rec_t **)data;
+	jobacct_step_rec_t **step = (jobacct_step_rec_t **)data;
+	jobacct_header_t header;
+	_parse_header(f, &header);
+		
+	switch(i) {
+	case JOB_START:
+		*job = jobacct_init_job_rec(header);
+		(*job)->jobname = xstrdup(f[F_JOBNAME]);
+		(*job)->track_steps = atoi(f[F_TRACK_STEPS]);
+		(*job)->priority = atoi(f[F_PRIORITY]);
+		(*job)->ncpus = atoi(f[F_NCPUS]);
+		(*job)->nodes = xstrdup(f[F_NODES]);
+		for (i=0; (*job)->nodes[i]; i++) { /* discard trailing <CR> */
+			if (isspace((*job)->nodes[i]))
+				(*job)->nodes[i] = '\0';
+		}
+		if (!strcmp((*job)->nodes, "(null)")) {
+			xfree((*job)->nodes);
+			(*job)->nodes = xstrdup("(unknown)");
+		}
+		if (len > F_JOB_ACCOUNT) {
+			(*job)->account = xstrdup(f[F_JOB_ACCOUNT]);
+			for (i=0; (*job)->account[i]; i++) {
+				/* discard trailing <CR> */
+				if (isspace((*job)->account[i]))
+					(*job)->account[i] = '\0';
+			}
+		}
+		break;
+	case JOB_STEP:
+		*step = jobacct_init_step_rec(header);
+		(*step)->stepnum = atoi(f[F_JOBSTEP]);
+		(*step)->status = atoi(f[F_STATUS]);
+		(*step)->exitcode = atoi(f[F_EXITCODE]);
+		(*step)->ntasks = atoi(f[F_NTASKS]);
+		(*step)->ncpus = atoi(f[F_STEPNCPUS]);
+		(*step)->elapsed = atoi(f[F_ELAPSED]);
+		(*step)->tot_cpu_sec = atoi(f[F_CPU_SEC]);
+		(*step)->tot_cpu_usec = atoi(f[F_CPU_USEC]);
+		(*step)->rusage.ru_utime.tv_sec = atoi(f[F_USER_SEC]);
+		(*step)->rusage.ru_utime.tv_usec = atoi(f[F_USER_USEC]);
+		(*step)->rusage.ru_stime.tv_sec = atoi(f[F_SYS_SEC]);
+		(*step)->rusage.ru_stime.tv_usec = atoi(f[F_SYS_USEC]);
+		(*step)->rusage.ru_maxrss = atoi(f[F_RSS]);
+		(*step)->rusage.ru_ixrss = atoi(f[F_IXRSS]);
+		(*step)->rusage.ru_idrss = atoi(f[F_IDRSS]);
+		(*step)->rusage.ru_isrss = atoi(f[F_ISRSS]);
+		(*step)->rusage.ru_minflt = atoi(f[F_MINFLT]);
+		(*step)->rusage.ru_majflt = atoi(f[F_MAJFLT]);
+		(*step)->rusage.ru_nswap = atoi(f[F_NSWAP]);
+		(*step)->rusage.ru_inblock = atoi(f[F_INBLOCKS]);
+		(*step)->rusage.ru_oublock = atoi(f[F_OUBLOCKS]);
+		(*step)->rusage.ru_msgsnd = atoi(f[F_MSGSND]);
+		(*step)->rusage.ru_msgrcv = atoi(f[F_MSGRCV]);
+		(*step)->rusage.ru_nsignals = atoi(f[F_NSIGNALS]);
+		(*step)->rusage.ru_nvcsw = atoi(f[F_NVCSW]);
+		(*step)->rusage.ru_nivcsw = atoi(f[F_NIVCSW]);
+		(*step)->sacct.max_vsize = atoi(f[F_MAX_VSIZE]) * 1024;
+		if(len > F_STEPNODES) {
+			(*step)->sacct.max_vsize_id.taskid = 
+				atoi(f[F_MAX_VSIZE_TASK]);
+			(*step)->sacct.ave_vsize = atof(f[F_AVE_VSIZE]) * 1024;
+			(*step)->sacct.max_rss = atoi(f[F_MAX_RSS]) * 1024;
+			(*step)->sacct.max_rss_id.taskid = 
+				atoi(f[F_MAX_RSS_TASK]);
+			(*step)->sacct.ave_rss = atof(f[F_AVE_RSS]) * 1024;
+			(*step)->sacct.max_pages = atoi(f[F_MAX_PAGES]);
+			(*step)->sacct.max_pages_id.taskid = 
+				atoi(f[F_MAX_PAGES_TASK]);
+			(*step)->sacct.ave_pages = atof(f[F_AVE_PAGES]);
+			(*step)->sacct.min_cpu = atof(f[F_MIN_CPU]);
+			(*step)->sacct.min_cpu_id.taskid = 
+				atoi(f[F_MIN_CPU_TASK]);
+			(*step)->sacct.ave_cpu = atof(f[F_AVE_CPU]);
+			(*step)->stepname = xstrdup(f[F_STEPNAME]);
+			(*step)->nodes = xstrdup(f[F_STEPNODES]);
+		} else {
+			(*step)->sacct.max_vsize_id.taskid = (uint16_t)NO_VAL;
+			(*step)->sacct.ave_vsize = (float)NO_VAL;
+			(*step)->sacct.max_rss = (uint32_t)NO_VAL;
+			(*step)->sacct.max_rss_id.taskid = (uint16_t)NO_VAL;
+			(*step)->sacct.ave_rss = (float)NO_VAL;
+			(*step)->sacct.max_pages = (uint32_t)NO_VAL;
+			(*step)->sacct.max_pages_id.taskid = (uint16_t)NO_VAL;
+			(*step)->sacct.ave_pages = (float)NO_VAL;
+			(*step)->sacct.min_cpu = (uint32_t)NO_VAL;
+			(*step)->sacct.min_cpu_id.taskid = (uint16_t)NO_VAL;
+			(*step)->sacct.ave_cpu =  (float)NO_VAL;
+			(*step)->stepname = NULL;
+			(*step)->nodes = NULL;
+		}
+		if(len > F_MIN_CPU_NODE) {
+			(*step)->sacct.max_vsize_id.nodeid = 
+				atoi(f[F_MAX_VSIZE_NODE]);
+			(*step)->sacct.max_rss_id.nodeid = 
+				atoi(f[F_MAX_RSS_NODE]);
+			(*step)->sacct.max_pages_id.nodeid = 
+				atoi(f[F_MAX_PAGES_NODE]);
+			(*step)->sacct.min_cpu_id.nodeid = 
+				atoi(f[F_MIN_CPU_NODE]);
+		} else {
+			(*step)->sacct.max_vsize_id.nodeid = 
+				(uint32_t)NO_VAL;
+			(*step)->sacct.max_rss_id.nodeid = 
+				(uint32_t)NO_VAL;
+			(*step)->sacct.max_pages_id.nodeid = 
+				(uint32_t)NO_VAL;
+			(*step)->sacct.min_cpu_id.nodeid = 
+				(uint32_t)NO_VAL;
+		}
+		if(len > F_STEP_ACCOUNT)
+			(*step)->account = xstrdup(f[F_STEP_ACCOUNT]);
+		if(len > F_STEP_REQUID)
+			(*step)->requid = atoi(f[F_STEP_REQUID]);
+		break;
+	case JOB_SUSPEND:
+	case JOB_TERMINATED:
+		*job = jobacct_init_job_rec(header);
+		(*job)->elapsed = atoi(f[F_TOT_ELAPSED]);
+		(*job)->status = atoi(f[F_STATUS]);		
+		if(len > F_JOB_REQUID) 
+			(*job)->requid = atoi(f[F_JOB_REQUID]);
+		break;
+	default:
+		printf("UNKOWN TYPE %d",i);
+		break;
+	}
+	return SLURM_SUCCESS;
+}
+
+static void _process_start(List job_list, char *f[], int lc,
+			   int show_full, int len)
+{
+	jobacct_job_rec_t *job = NULL;
+	jobacct_job_rec_t *temp = NULL;
+
+	_parse_line(f, (void **)&temp, len);
+	job = _find_job_record(job_list, temp->header, JOB_START);
+	if (job) {	/* Hmmm... that's odd */
+		printf("job->header.job_submit = %d",
+		       (int)job->header.job_submit);
+		if(job->header.job_submit == 0)
+			_remove_job_record(job_list, job->header.jobnum);
+		else {
+			fprintf(stderr,
+				"Conflicting JOB_START for job %u at"
+				" line %d -- ignoring it\n",
+				job->header.jobnum, lc);
+			jobacct_destroy_job(temp);
+			return;
+		}
+	}
+	
+	job = temp;
+	job->show_full = show_full;
+	list_append(job_list, job);
+	job->job_start_seen = 1;
+	
+}
+
+static void _process_step(List job_list, char *f[], int lc,
+			  int show_full, int len,
+			  sacct_parameters_t *params)
+{
+	jobacct_job_rec_t *job = NULL;
+	
+	jobacct_step_rec_t *step = NULL;
+	jobacct_step_rec_t *temp = NULL;
+
+	_parse_line(f, (void **)&temp, len);
+
+	job = _find_job_record(job_list, temp->header, JOB_STEP);
+	
+	if (temp->stepnum == -2) {
+		jobacct_destroy_step(temp);
+		return;
+	}
+	if (!job) {	/* fake it for now */
+		job = jobacct_init_job_rec(temp->header);
+		job->jobname = xstrdup("(unknown)");
+		if (params->opt_verbose > 1) 
+			fprintf(stderr, 
+				"Note: JOB_STEP record %u.%u preceded "
+				"JOB_START record at line %d\n",
+				temp->header.jobnum, temp->stepnum, lc);
+	}
+	job->show_full = show_full;
+	
+	if ((step = _find_step_record(job, temp->stepnum))) {
+		
+		if (temp->status == JOB_RUNNING) {
+			jobacct_destroy_step(temp);
+			return;/* if "R" record preceded by F or CD; unusual */
+		}
+		if (step->status != JOB_RUNNING) { /* if not JOB_RUNNING */
+			fprintf(stderr,
+				"Conflicting JOB_STEP record for "
+				"jobstep %u.%u at line %d "
+				"-- ignoring it\n",
+				step->header.jobnum, 
+				step->stepnum, lc);
+			jobacct_destroy_step(temp);
+			return;
+		}
+		step->status = temp->status;
+		step->exitcode = temp->exitcode;
+		step->ntasks = temp->ntasks;
+		step->ncpus = temp->ncpus;
+		step->elapsed = temp->elapsed;
+		step->tot_cpu_sec = temp->tot_cpu_sec;
+		step->tot_cpu_usec = temp->tot_cpu_usec;
+		job->requid = temp->requid;
+		step->requid = temp->requid;
+		memcpy(&step->rusage, &temp->rusage, sizeof(struct rusage));
+		memcpy(&step->sacct, &temp->sacct, sizeof(sacct_t));
+		xfree(step->stepname);
+		step->stepname = xstrdup(temp->stepname);
+		step->end = temp->header.timestamp;
+		jobacct_destroy_step(temp);
+		goto got_step;
+	}
+	step = temp;
+	temp = NULL;
+	list_append(job->steps, step);
+	if(job->header.timestamp == 0)
+		job->header.timestamp = step->header.timestamp;
+	job->job_step_seen = 1;
+	job->ntasks += step->ntasks;
+	if(!job->nodes || !strcmp(job->nodes, "(unknown)")) {
+		xfree(job->nodes);
+		job->nodes = xstrdup(step->nodes);
+	}
+	
+got_step:
+	
+		
+	if (job->job_terminated_seen == 0) {	/* If the job is still running,
+						   this is the most recent
+						   status */
+		if ( job->exitcode == 0 )
+			job->exitcode = step->exitcode;
+		job->status = JOB_RUNNING;
+		job->elapsed = step->header.timestamp - job->header.timestamp;
+	}
+}
+
+static void _process_suspend(List job_list, char *f[], int lc,
+			     int show_full, int len)
+{
+	jobacct_job_rec_t *job = NULL;
+	jobacct_job_rec_t *temp = NULL;
+
+	_parse_line(f, (void **)&temp, len);
+	job = _find_job_record(job_list, temp->header, JOB_SUSPEND);
+	if (!job)  {	/* fake it for now */
+		job = jobacct_init_job_rec(temp->header);
+		job->jobname = xstrdup("(unknown)");
+	} 
+			
+	job->show_full = show_full;
+	if (job->status == JOB_SUSPENDED) 
+		job->elapsed -= temp->elapsed;
+
+	//job->header.timestamp = temp->header.timestamp;
+	job->status = temp->status;
+	jobacct_destroy_job(temp);
+}
+	
+static void _process_terminated(List job_list, char *f[], int lc,
+				int show_full, int len,
+				sacct_parameters_t *params)
+{
+	jobacct_job_rec_t *job = NULL;
+	jobacct_job_rec_t *temp = NULL;
+
+	_parse_line(f, (void **)&temp, len);
+	job = _find_job_record(job_list, temp->header, JOB_TERMINATED);
+	if (!job) {	/* fake it for now */
+		job = jobacct_init_job_rec(temp->header);
+		job->jobname = xstrdup("(unknown)");
+		if (params->opt_verbose > 1) 
+			fprintf(stderr, "Note: JOB_TERMINATED record for job "
+				"%u preceded "
+				"other job records at line %d\n",
+				temp->header.jobnum, lc);
+	} else if (job->job_terminated_seen) {
+		if (temp->status == JOB_NODE_FAIL) {
+			/* multiple node failures - extra TERMINATED records */
+			if (params->opt_verbose > 1)
+				fprintf(stderr, 
+					"Note: Duplicate JOB_TERMINATED "
+					"record (nf) for job %u at "
+					"line %d\n", 
+					temp->header.jobnum, lc);
+			/* JOB_TERMINATED/NF records may be preceded
+			 * by a JOB_TERMINATED/CA record; NF is much
+			 * more interesting.
+			 */
+			job->status = temp->status;
+			goto finished;
+		}
+		
+		fprintf(stderr,
+			"Conflicting JOB_TERMINATED record (%s) for "
+			"job %u at line %d -- ignoring it\n",
+			job_state_string(temp->status), 
+			job->header.jobnum, lc);
+		goto finished;
+	}
+	job->job_terminated_seen = 1;
+	job->elapsed = temp->elapsed;
+	job->end = temp->header.timestamp;
+	job->status = temp->status;
+	job->requid = temp->requid;
+	if(list_count(job->steps) > 1)
+		job->track_steps = 1;
+	job->show_full = show_full;
+	
+finished:
+	jobacct_destroy_job(temp);
+}
+
+extern void flatfile_jobacct_process_get_jobs(List job_list, 
+					      List selected_steps,
+					      List selected_parts,
+					      sacct_parameters_t *params)
+{
+	char line[BUFFER_SIZE];
+	char *f[MAX_RECORD_FIELDS+1];    /* End list with null entry and,
+					    possibly, more data than we
+					    expected */
+	char *fptr;
+	int i;
+	FILE *fd = NULL;
+	int lc = 0;
+	int rec_type = -1;
+	jobacct_selected_step_t *selected_step = NULL;
+	char *selected_part = NULL;
+	ListIterator itr = NULL;
+	int show_full = 0;
+
+	fd = _open_log_file(params->opt_filein);
+	
+	while (fgets(line, BUFFER_SIZE, fd)) {
+		lc++;
+		fptr = line;	/* break the record into NULL-
+				   terminated strings */
+				
+		for (i = 0; i < MAX_RECORD_FIELDS; i++) {
+			f[i] = fptr;
+			fptr = strstr(fptr, " ");
+			if (fptr == NULL) {
+				fptr = strstr(f[i], "\n");
+				if (fptr)
+					*fptr = 0;
+				break; 
+			} else
+				*fptr++ = 0;
+		}
+		f[++i] = 0;
+		
+		if(i < HEADER_LENGTH) {
+			continue;
+		}
+		
+		rec_type = atoi(f[F_RECTYPE]);
+		
+		if (list_count(selected_steps)) {
+			itr = list_iterator_create(selected_steps);
+			while((selected_step = list_next(itr))) {
+				if (strcmp(selected_step->job, f[F_JOB]))
+					continue;
+				/* job matches; does the step? */
+				if(selected_step->step == NULL) {
+					show_full = 1;
+					list_iterator_destroy(itr);
+					goto foundjob;
+				} else if (rec_type != JOB_STEP 
+					   || !strcmp(f[F_JOBSTEP], 
+						      selected_step->step)) {
+					list_iterator_destroy(itr);
+					goto foundjob;
+				} 
+			}
+			list_iterator_destroy(itr);
+			continue;	/* no match */
+		} else {
+			show_full = 1;
+		}
+	foundjob:
+		
+		if (list_count(selected_parts)) {
+			itr = list_iterator_create(selected_parts);
+			while((selected_part = list_next(itr))) 
+				if (!strcasecmp(f[F_PARTITION], 
+						selected_part)) {
+					list_iterator_destroy(itr);
+					goto foundp;
+				}
+			list_iterator_destroy(itr);
+			continue;	/* no match */
+		}
+	foundp:
+		
+		if (params->opt_fdump) {
+			_do_fdump(f, lc);
+			continue;
+		}
+		
+		/* Build suitable tables with all the data */
+		switch(rec_type) {
+		case JOB_START:
+			if(i < F_JOB_ACCOUNT) {
+				printf("Bad data on a Job Start\n");
+				_show_rec(f);
+			} else 
+				_process_start(job_list, f, lc, show_full, i);
+			break;
+		case JOB_STEP:
+			if(i < F_MAX_VSIZE) {
+				printf("Bad data on a Step entry\n");
+				_show_rec(f);
+			} else
+				_process_step(job_list, f, lc, show_full, i, 
+					      params);
+			break;
+		case JOB_SUSPEND:
+			if(i < JOB_TERM_LENGTH) {
+				printf("Bad data on a Suspend entry\n");
+				_show_rec(f);
+			} else
+				_process_suspend(job_list, f, lc,
+						 show_full, i);
+			break;
+		case JOB_TERMINATED:
+			if(i < JOB_TERM_LENGTH) {
+				printf("Bad data on a Job Term\n");
+				_show_rec(f);
+			} else
+				_process_terminated(job_list, f, lc,
+						    show_full, i, params);
+			break;
+		default:
+			if (params->opt_verbose > 1)
+				fprintf(stderr,
+					"Invalid record at line %d of "
+					"input file\n",
+					lc);
+			if (params->opt_verbose > 2)
+				_show_rec(f);
+			break;
+		}
+	}
+	
+	if (ferror(fd)) {
+		perror(params->opt_filein);
+		exit(1);
+	} 
+	fclose(fd);
+
+	return;
+}
+
+extern void flatfile_jobacct_process_archive(List selected_parts,
+					     sacct_parameters_t *params)
+{
+	char	line[BUFFER_SIZE],
+		*f[EXPIRE_READ_LENGTH],
+		*fptr = NULL,
+		*logfile_name = NULL,
+		*old_logfile_name = NULL;
+	int	file_err=0,
+		new_file,
+		i = 0;
+	expired_rec_t *exp_rec = NULL;
+	expired_rec_t *exp_rec2 = NULL;
+	List keep_list = list_create(_destroy_exp);
+	List exp_list = list_create(_destroy_exp);
+	List other_list = list_create(_destroy_exp);
+	struct	stat statbuf;
+	mode_t	prot = 0600;
+	uid_t	uid;
+	gid_t	gid;
+	FILE	*expired_logfile = NULL,
+		*new_logfile = NULL;
+	FILE *fd = NULL;
+	int lc=0;
+	int rec_type = -1;
+	ListIterator itr = NULL;
+	ListIterator itr2 = NULL;
+	char *temp = NULL;
+
+	/* Figure out our expiration date */
+	time_t		expiry;
+	expiry = time(NULL)-params->opt_expire;
+	if (params->opt_verbose)
+		fprintf(stderr, "Purging jobs completed prior to %d\n",
+			(int)expiry);
+
+	/* Open the current or specified logfile, or quit */
+	fd = _open_log_file(params->opt_filein);
+	if (stat(params->opt_filein, &statbuf)) {
+		perror("stat'ing logfile");
+		goto finished;
+	}
+	if ((statbuf.st_mode & S_IFLNK) == S_IFLNK) {
+		fprintf(stderr, "%s is a symbolic link; --expire requires "
+			"a hard-linked file name\n", params->opt_filein);
+		goto finished;
+	}
+	if (!(statbuf.st_mode & S_IFREG)) {
+		fprintf(stderr, "%s is not a regular file; --expire "
+			"only works on accounting log files\n",
+			params->opt_filein);
+		goto finished;
+	}
+	prot = statbuf.st_mode & 0777;
+	gid  = statbuf.st_gid;
+	uid  = statbuf.st_uid;
+	old_logfile_name = _prefix_filename(params->opt_filein, ".old.");
+	if (stat(old_logfile_name, &statbuf)) {
+		if (errno != ENOENT) {
+			fprintf(stderr,"Error checking for %s: ",
+				old_logfile_name);
+			perror("");
+			goto finished;
+		}
+	} else {
+		fprintf(stderr, "Warning! %s exists -- please remove "
+			"or rename it before proceeding\n",
+			old_logfile_name);
+		goto finished;
+	}
+
+	/* create our initial buffer */
+	while (fgets(line, BUFFER_SIZE, fd)) {
+		lc++;
+		fptr = line;	/* break the record into NULL-
+				   terminated strings */
+		exp_rec = xmalloc(sizeof(expired_rec_t));
+		exp_rec->line = xstrdup(line);
+	
+		for (i = 0; i < EXPIRE_READ_LENGTH; i++) {
+			f[i] = fptr;
+			fptr = strstr(fptr, " ");
+			if (fptr == NULL)
+				break; 
+			else
+				*fptr++ = 0;
+		}
+		
+		exp_rec->job = atoi(f[F_JOB]);
+		exp_rec->job_submit = atoi(f[F_JOB_SUBMIT]);
+		
+		rec_type = atoi(f[F_RECTYPE]);
+		/* Odd, but complain some other time */
+		if (rec_type == JOB_TERMINATED) {
+			if (expiry < atoi(f[F_TIMESTAMP])) {
+				list_append(keep_list, exp_rec);
+				continue;				
+			}
+			if (list_count(selected_parts)) {
+				itr = list_iterator_create(selected_parts);
+				while((temp = list_next(itr))) 
+					if(!strcasecmp(f[F_PARTITION], temp)) 
+						break;
+				list_iterator_destroy(itr);
+				if(!temp) {
+					list_append(keep_list, exp_rec);
+					continue;
+				} /* no match */
+			}
+			list_append(exp_list, exp_rec);
+			if (params->opt_verbose > 2)
+				fprintf(stderr, "Selected: %8d %d\n",
+					exp_rec->job,
+					(int)exp_rec->job_submit);
+		} else {
+			list_append(other_list, exp_rec);
+		}
+	}
+	if (!list_count(exp_list)) {
+		printf("No job records were purged.\n");
+		goto finished;
+	}
+	logfile_name = xmalloc(strlen(params->opt_filein)+sizeof(".expired"));
+	sprintf(logfile_name, "%s.expired", params->opt_filein);
+	new_file = stat(logfile_name, &statbuf);
+	if ((expired_logfile = fopen(logfile_name, "a"))==NULL) {
+		fprintf(stderr, "Error while opening %s", 
+			logfile_name);
+		perror("");
+		xfree(logfile_name);
+		goto finished;
+	}
+	
+	if (new_file) {  /* By default, the expired file looks like the log */
+		chmod(logfile_name, prot);
+		chown(logfile_name, uid, gid);
+	}
+	xfree(logfile_name);
+
+	logfile_name = _prefix_filename(params->opt_filein, ".new.");
+	if ((new_logfile = fopen(logfile_name, "w"))==NULL) {
+		fprintf(stderr, "Error while opening %s",
+			logfile_name);
+		perror("");
+		fclose(expired_logfile);
+		goto finished;
+	}
+	chmod(logfile_name, prot);     /* preserve file protection */
+	chown(logfile_name, uid, gid); /* and ownership */
+	/* Use line buffering to allow us to safely write
+	 * to the log file at the same time as slurmctld. */ 
+	if (setvbuf(new_logfile, NULL, _IOLBF, 0)) {
+		perror("setvbuf()");
+		fclose(expired_logfile);
+		goto finished2;
+	}
+
+	list_sort(exp_list, (ListCmpF) _cmp_jrec);
+	list_sort(keep_list, (ListCmpF) _cmp_jrec);
+	
+	if (params->opt_verbose > 2) {
+		fprintf(stderr, "--- contents of exp_list ---");
+		itr = list_iterator_create(exp_list);
+		while((exp_rec = list_next(itr))) {
+			if (!(i%5))
+				fprintf(stderr, "\n");
+			else
+				fprintf(stderr, "\t");
+			fprintf(stderr, "%d", exp_rec->job);
+		}
+		fprintf(stderr, "\n---- end of exp_list ---\n");
+		list_iterator_destroy(itr);
+	}
+	/* write the expired file */
+	itr = list_iterator_create(exp_list);
+	while((exp_rec = list_next(itr))) {
+		itr2 = list_iterator_create(other_list);
+		while((exp_rec2 = list_next(itr2))) {
+			if((exp_rec2->job != exp_rec->job) 
+			   || (exp_rec2->job_submit != exp_rec->job_submit))
+				continue;
+			if (fputs(exp_rec2->line, expired_logfile)<0) {
+				perror("writing expired_logfile");
+				list_iterator_destroy(itr2);
+				list_iterator_destroy(itr);
+				fclose(expired_logfile);
+				goto finished2;
+			}
+			list_remove(itr2);
+			_destroy_exp(exp_rec2);
+		}
+		list_iterator_destroy(itr2);
+		if (fputs(exp_rec->line, expired_logfile)<0) {
+			perror("writing expired_logfile");
+			list_iterator_destroy(itr);
+			fclose(expired_logfile);
+			goto finished2;
+		}		
+	}
+	list_iterator_destroy(itr);
+	fclose(expired_logfile);
+	
+	/* write the new log */
+	itr = list_iterator_create(keep_list);
+	while((exp_rec = list_next(itr))) {
+		itr2 = list_iterator_create(other_list);
+		while((exp_rec2 = list_next(itr2))) {
+			if(exp_rec2->job != exp_rec->job)
+				continue;
+			if (fputs(exp_rec2->line, new_logfile)<0) {
+				perror("writing keep_logfile");
+				list_iterator_destroy(itr2);
+				list_iterator_destroy(itr);
+				goto finished2;
+			}
+			list_remove(itr2);
+			_destroy_exp(exp_rec2);
+		}
+		list_iterator_destroy(itr2);
+		if (fputs(exp_rec->line, new_logfile)<0) {
+			perror("writing keep_logfile");
+			list_iterator_destroy(itr);
+			goto finished2;
+		}		
+	}
+	list_iterator_destroy(itr);
+	
+	if (rename(params->opt_filein, old_logfile_name)) {
+		perror("renaming logfile to .old.");
+		goto finished2;
+	}
+	if (rename(logfile_name, params->opt_filein)) {
+		perror("renaming new logfile");
+		/* undo it? */
+		if (!rename(old_logfile_name, params->opt_filein)) 
+			fprintf(stderr, "Please correct the problem "
+				"and try again");
+		else
+			fprintf(stderr, "SEVERE ERROR: Current accounting "
+				"log may have been renamed %s;\n"
+				"please rename it to \"%s\" if necessary, "
+			        "and try again\n",
+				old_logfile_name, params->opt_filein);
+		goto finished2;
+	}
+	fflush(new_logfile);	/* Flush the buffers before forking */
+	fflush(fd);
+	
+	file_err = slurm_reconfigure ();
+	
+	if (file_err) {
+		file_err = 1;
+		fprintf(stderr, "Error: Attempt to reconfigure "
+			"SLURM failed.\n");
+		if (rename(old_logfile_name, params->opt_filein)) {
+			perror("renaming logfile from .old.");
+			goto finished2;
+		}
+
+	}
+	if (fseek(fd, 0, SEEK_CUR)) {	/* clear EOF */
+		perror("looking for late-arriving records");
+		goto finished2;
+	}
+	while (fgets(line, BUFFER_SIZE, fd)) {
+		if (fputs(line, new_logfile)<0) {
+			perror("writing final records");
+			goto finished2;
+		}
+	}
+	
+	printf("%d jobs expired.\n", list_count(exp_list));
+finished2:
+	fclose(new_logfile);
+	if (!file_err) {
+		if (unlink(old_logfile_name) == -1)
+			error("Unable to unlink old logfile %s: %m",
+			      old_logfile_name);
+	}
+finished:
+	fclose(fd);
+	list_destroy(exp_list);
+	list_destroy(keep_list);
+	list_destroy(other_list);
+	xfree(old_logfile_name);
+	xfree(logfile_name);
+}
diff --git a/src/plugins/database/flatfile/flatfile_jobacct_process.h b/src/plugins/database/flatfile/flatfile_jobacct_process.h
new file mode 100644
index 0000000000000000000000000000000000000000..9530d3ebd9273c3a5380a93fc7a61c344486550c
--- /dev/null
+++ b/src/plugins/database/flatfile/flatfile_jobacct_process.h
@@ -0,0 +1,55 @@
+/*****************************************************************************\
+ *  flatfile_jobacct_process.h - functions the processing of
+ *                               information from the flatfile jobacct
+ *                               database.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+
+#ifndef _HAVE_FLATFILE_JOBACCT_PROCESS_H
+#define _HAVE_FLATFILE_JOBACCT_PROCESS_H
+
+#include "src/sacct/sacct.h"
+
+extern void flatfile_jobacct_process_get_jobs(List job_list, 
+					      List selected_steps,
+					      List selected_parts,
+					      sacct_parameters_t *params);
+extern void flatfile_jobacct_process_archive(List selected_parts,
+					     sacct_parameters_t *params);
+
+#endif
diff --git a/src/plugins/database/flatfile/flatfile_jobcomp.c b/src/plugins/database/flatfile/flatfile_jobcomp.c
new file mode 100644
index 0000000000000000000000000000000000000000..d15d1e39e6490c9b968ed837456ae23b414d644f
--- /dev/null
+++ b/src/plugins/database/flatfile/flatfile_jobcomp.c
@@ -0,0 +1,261 @@
+/*****************************************************************************\
+ *  flatfile_jobcomp.c - text file slurm job completion logging plugin.
+ *****************************************************************************
+ *  Copyright (C) 2003 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Morris Jette <jette1@llnl.gov> et. al.
+ *  UCRL-CODE-226842.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#if HAVE_CONFIG_H
+#   include "config.h"
+#endif
+
+#if HAVE_STDINT_H
+#  include <stdint.h>
+#endif
+#if HAVE_INTTYPES_H
+#  include <inttypes.h>
+#endif
+
+#include <fcntl.h>
+#include <pthread.h>
+#include <pwd.h>
+#include <slurm/slurm.h>
+#include <slurm/slurm_errno.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include "src/common/macros.h"
+#include "src/common/node_select.h"
+#include "src/common/slurm_protocol_defs.h"
+#include "src/common/slurm_jobcomp.h"
+#include "src/common/uid.h"
+#include "src/common/xmalloc.h"
+#include "src/common/xstring.h"
+#include "src/common/parse_time.h"
+
+#include "flatfile_jobcomp_process.h"
+
+#define JOB_FORMAT "JobId=%lu UserId=%s(%lu) Name=%s JobState=%s Partition=%s "\
+		"TimeLimit=%s StartTime=%s EndTime=%s NodeList=%s NodeCnt=%u %s\n"
+ 
+/* Type for error string table entries */
+typedef struct {
+	int xe_number;
+	char *xe_message;
+} slurm_errtab_t;
+
+static slurm_errtab_t slurm_errtab[] = {
+	{0, "No error"},
+	{-1, "Unspecified error"}
+};
+
+/* A plugin-global errno. */
+static int plugin_errno = SLURM_SUCCESS;
+
+/* File descriptor used for logging */
+static pthread_mutex_t  file_lock = PTHREAD_MUTEX_INITIALIZER;
+static char *           log_name  = NULL;
+static int              job_comp_fd = -1;
+
+/* get the user name for the give user_id */
+static void
+_get_user_name(uint32_t user_id, char *user_name, int buf_size)
+{
+	static uint32_t cache_uid      = 0;
+	static char     cache_name[32] = "root";
+	struct passwd * user_info      = NULL;
+
+	if (user_id == cache_uid)
+		snprintf(user_name, buf_size, "%s", cache_name);
+	else {
+		user_info = getpwuid((uid_t) user_id);
+		if (user_info && user_info->pw_name[0])
+			snprintf(cache_name, sizeof(cache_name), "%s", 
+				user_info->pw_name);
+		else
+			snprintf(cache_name, sizeof(cache_name), "Unknown");
+		cache_uid = user_id;
+		snprintf(user_name, buf_size, "%s", cache_name);
+	}
+}
+
+/* 
+ * Linear search through table of errno values and strings,
+ * returns NULL on error, string on success.
+ */
+static char *_lookup_slurm_api_errtab(int errnum)
+{
+	char *res = NULL;
+	int i;
+
+	for (i = 0; i < sizeof(slurm_errtab) / sizeof(slurm_errtab_t); i++) {
+		if (slurm_errtab[i].xe_number == errnum) {
+			res = slurm_errtab[i].xe_message;
+			break;
+		}
+	}
+	return res;
+}
+
+extern int flatfile_jobcomp_init(char *location)
+{
+	int rc = SLURM_SUCCESS;
+
+	if (location == NULL) {
+		plugin_errno = EACCES;
+		return SLURM_ERROR;
+	}
+	xfree(log_name);
+	log_name = xstrdup(location);
+
+	slurm_mutex_lock( &file_lock );
+	if (job_comp_fd >= 0)
+		close(job_comp_fd);
+	job_comp_fd = open(location, O_WRONLY | O_CREAT | O_APPEND, 0644);
+	if (job_comp_fd == -1) {
+		fatal("open %s: %m", location);
+		plugin_errno = errno;
+		rc = SLURM_ERROR;
+	} else
+		fchmod(job_comp_fd, 0644);
+	slurm_mutex_unlock( &file_lock );
+	return rc;
+}
+
+extern int flatfile_jobcomp_fini ( void )
+{
+	if (job_comp_fd >= 0)
+		close(job_comp_fd);
+	xfree(log_name);
+	return SLURM_SUCCESS;
+}
+
+extern int flatfile_jobcomp_get_errno( void )
+{
+	return plugin_errno;
+}
+
+extern int flatfile_jobcomp_log_record ( struct job_record *job_ptr )
+{
+	int rc = SLURM_SUCCESS;
+	char job_rec[512+MAX_JOBNAME_LEN];
+	char usr_str[32], start_str[32], end_str[32], lim_str[32];
+	char select_buf[128];
+	size_t offset = 0, tot_size, wrote;
+	enum job_states job_state;
+
+	if ((log_name == NULL) || (job_comp_fd < 0)) {
+		error("JobCompLoc log file %s not open", log_name);
+		return SLURM_ERROR;
+	}
+
+	slurm_mutex_lock( &file_lock );
+	_get_user_name(job_ptr->user_id, usr_str, sizeof(usr_str));
+	if (job_ptr->time_limit == INFINITE)
+		strcpy(lim_str, "UNLIMITED");
+	else
+		snprintf(lim_str, sizeof(lim_str), "%lu", 
+				(unsigned long) job_ptr->time_limit);
+
+	/* Job will typically be COMPLETING when this is called. 
+	 * We remove this flag to get the eventual completion state:
+	 * JOB_FAILED, JOB_TIMEOUT, etc. */
+	job_state = job_ptr->job_state & (~JOB_COMPLETING);
+
+	slurm_make_time_str(&(job_ptr->start_time),
+			    start_str, sizeof(start_str));
+	slurm_make_time_str(&(job_ptr->end_time), end_str, sizeof(end_str));
+
+	select_g_sprint_jobinfo(job_ptr->select_jobinfo,
+		select_buf, sizeof(select_buf), SELECT_PRINT_MIXED);
+
+	snprintf(job_rec, sizeof(job_rec), JOB_FORMAT,
+			(unsigned long) job_ptr->job_id, usr_str, 
+			(unsigned long) job_ptr->user_id, job_ptr->name, 
+			job_state_string(job_state), 
+			job_ptr->partition, lim_str, start_str, 
+			end_str, job_ptr->nodes, job_ptr->node_cnt,
+			select_buf);
+	tot_size = strlen(job_rec);
+
+	while ( offset < tot_size ) {
+		wrote = write(job_comp_fd, job_rec + offset,
+			tot_size - offset);
+		if (wrote == -1) {
+			if (errno == EAGAIN)
+				continue;
+			else {
+				plugin_errno = errno;
+				rc = SLURM_ERROR;
+				break;
+			}
+		}
+		offset += wrote;
+	}
+	slurm_mutex_unlock( &file_lock );
+	return rc;
+}
+
+extern char *flatfile_jobcomp_strerror( int errnum )
+{
+	char *res = _lookup_slurm_api_errtab(errnum);
+	return (res ? res : strerror(errnum));
+}
+
+
+/* 
+ * get info from the database 
+ * in/out job_list List of job_rec_t *
+ * note List needs to be freed when called
+ */
+extern void flatfile_jobcomp_get_jobs(List job_list, 
+				      List selected_steps, List selected_parts,
+				      void *params)
+{
+	flatfile_jobcomp_process_get_jobs(job_list, 
+					  selected_steps, selected_parts,
+					  params);	
+	return;
+}
+
+/* 
+ * expire old info from the database 
+ */
+extern void flatfile_jobcomp_archive(List selected_parts,
+				     void *params)
+{
+	flatfile_jobcomp_process_archive(selected_parts, params);
+	return;
+}
diff --git a/src/plugins/database/flatfile/flatfile_jobcomp.h b/src/plugins/database/flatfile/flatfile_jobcomp.h
new file mode 100644
index 0000000000000000000000000000000000000000..6aad6b6b1b1a67f8d419db7b3c744a7337a24a9f
--- /dev/null
+++ b/src/plugins/database/flatfile/flatfile_jobcomp.h
@@ -0,0 +1,54 @@
+/*****************************************************************************\
+ *  flatfile_jobcomp.h - text file slurm job completion logging plugin.
+ *****************************************************************************
+ *  Copyright (C) 2003 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Morris Jette <jette1@llnl.gov> et. al.
+ *  UCRL-CODE-226842.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#ifndef _FLATFILE_JOBCOMP_H_
+#define _FLATFILE_JOBCOMP_H_
+
+#include "src/slurmctld/slurmctld.h"
+
+extern int flatfile_jobcomp_init(char * location);
+extern int flatfile_jobcomp_fini();
+extern int flatfile_jobcomp_get_errno();
+extern int flatfile_jobcomp_log_record(struct job_record *job_ptr);
+extern char *flatfile_jobcomp_strerror(int errnum);
+extern void flatfile_jobcomp_get_jobs(List job_list, 
+				      List selected_steps,
+				      List selected_parts,
+				      void *params);
+extern void flatfile_jobcomp_archive(List selected_parts, void *params);
+
+#endif
diff --git a/src/plugins/database/flatfile/flatfile_jobcomp_process.c b/src/plugins/database/flatfile/flatfile_jobcomp_process.c
new file mode 100644
index 0000000000000000000000000000000000000000..032a5550af6fb24bf34baa7406fc00a7ea1541fa
--- /dev/null
+++ b/src/plugins/database/flatfile/flatfile_jobcomp_process.c
@@ -0,0 +1,299 @@
+/*****************************************************************************\
+ *  flatfile_jobcomp_process.c - functions the processing of
+ *                               information from the flatfile jobcomp
+ *                               database.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+#include <stdlib.h>
+#include <ctype.h>
+#include <sys/stat.h>
+
+#include "src/common/xstring.h"
+#include "src/common/xmalloc.h"
+#include "flatfile_jobcomp_process.h"
+/* Map field names to positions */
+
+/* slurmd uses "(uint32_t) -2" to track data for batch allocations
+ * which have no logical jobsteps. */
+
+typedef struct {
+	char *name;
+	char *val;
+} flatfile_jobcomp_info_t;
+
+
+static void _destroy_flatfile_jobcomp_info(void *object)
+{
+	flatfile_jobcomp_info_t *jobcomp_info =
+		(flatfile_jobcomp_info_t *)object;
+	if(jobcomp_info) {
+		xfree(jobcomp_info);
+	}
+}
+
+
+/* _open_log_file() -- find the current or specified log file, and open it
+ *
+ * IN:		Nothing
+ * RETURNS:	Nothing
+ *
+ * Side effects:
+ * 	- Sets opt_filein to the current system accounting log unless
+ * 	  the user specified another file.
+ */
+
+static FILE *_open_log_file(char *logfile)
+{
+	FILE *fd = fopen(logfile, "r");
+	if (fd == NULL) {
+		perror(logfile);
+		exit(1);
+	}
+	return fd;
+}
+
+static void _do_fdump(List job_info_list, int lc)
+{
+	flatfile_jobcomp_info_t *jobcomp_info = NULL;
+	ListIterator itr = list_iterator_create(job_info_list);
+
+	printf("\n------- Line %d -------\n", lc);
+	while((jobcomp_info = list_next(itr))) {
+		printf("%12s: %s\n", jobcomp_info->name, jobcomp_info->val);
+	}
+}
+
+static jobcomp_job_rec_t *_parse_line(List job_info_list)
+{
+	ListIterator itr = NULL;
+	flatfile_jobcomp_info_t *jobcomp_info = NULL;
+	jobcomp_job_rec_t *job = xmalloc(sizeof(jobcomp_job_rec_t));
+	char *temp = NULL;
+	char *temp2 = NULL;
+
+	itr = list_iterator_create(job_info_list);
+	while((jobcomp_info = list_next(itr))) {
+		if(!strcasecmp("JobID", jobcomp_info->name)) {
+			job->jobid = atoi(jobcomp_info->val);
+		} else if(!strcasecmp("Partition", jobcomp_info->name)) {
+			job->partition = xstrdup(jobcomp_info->val);
+		} else if(!strcasecmp("StartTime", jobcomp_info->name)) {
+			job->start_time = xstrdup(jobcomp_info->val);
+		} else if(!strcasecmp("EndTime", jobcomp_info->name)) {
+			job->end_time = xstrdup(jobcomp_info->val);
+		} else if(!strcasecmp("Userid", jobcomp_info->name)) {
+			temp = strstr(jobcomp_info->val, "(");
+			if(!temp) 
+				job->uid = atoi(jobcomp_info->val);
+			*temp++ = 0; 
+			temp2 = temp;
+			temp = strstr(temp, ")");
+			if(!temp) {
+				error("problem getting correct uid from %s",
+				      jobcomp_info->val);
+			} else {
+				*temp = 0;
+				job->uid = atoi(temp2);
+				job->uid_name = xstrdup(jobcomp_info->val);
+			}
+		} else if(!strcasecmp("GroupId", jobcomp_info->name)) {
+			temp = strstr(jobcomp_info->val, "(");
+			if(!temp) 
+				job->gid = atoi(jobcomp_info->val);
+			*temp++ = 0; 
+			temp2 = temp;
+			temp = strstr(temp, ")");
+			if(!temp) {
+				error("problem getting correct gid from %s",
+				      jobcomp_info->val);
+			} else {
+				*temp = 0;
+				job->gid = atoi(temp2);
+				job->gid_name = xstrdup(jobcomp_info->val);
+			}
+		} else if(!strcasecmp("Block_Id", jobcomp_info->name)) {
+			job->blockid = xstrdup(jobcomp_info->val);
+		} else if(!strcasecmp("Name", jobcomp_info->name)) {
+			job->jobname = xstrdup(jobcomp_info->val);
+		} else if(!strcasecmp("NodeList", jobcomp_info->name)) {
+			job->nodelist = xstrdup(jobcomp_info->val);
+		} else if(!strcasecmp("NodeCnt", jobcomp_info->name)) {
+			job->node_cnt = atoi(jobcomp_info->val);
+		} else if(!strcasecmp("MaxProcs", jobcomp_info->name)) {
+			job->max_procs = atoi(jobcomp_info->val);
+		} else if(!strcasecmp("JobState", jobcomp_info->name)) {
+			job->state = xstrdup(jobcomp_info->val);
+		} else if(!strcasecmp("Timelimit", jobcomp_info->name)) {
+			job->timelimit = xstrdup(jobcomp_info->val);
+		} else if(!strcasecmp("Connection", jobcomp_info->name)) {
+			job->connection = xstrdup(jobcomp_info->val);
+		} else if(!strcasecmp("reboot", jobcomp_info->name)) {
+			job->reboot = xstrdup(jobcomp_info->val);
+		} else if(!strcasecmp("rotate", jobcomp_info->name)) {
+			job->rotate = xstrdup(jobcomp_info->val);
+		} else if(!strcasecmp("geometry", jobcomp_info->name)) {
+			job->geo = xstrdup(jobcomp_info->val);
+		} else if(!strcasecmp("start", jobcomp_info->name)) {
+			job->bg_start_point = xstrdup(jobcomp_info->val);
+		} else {
+			error("Unknown type %s: %s", jobcomp_info->name,
+			      jobcomp_info->val);
+		}
+	}
+	list_iterator_destroy(itr);
+	
+	return job;
+}
+
+extern void flatfile_jobcomp_process_get_jobs(List job_list, 
+					      List selected_steps,
+					      List selected_parts,
+					      sacct_parameters_t *params)
+{
+	char line[BUFFER_SIZE];
+	char *fptr = NULL;
+	char *jobid = NULL;
+	char *partition = NULL;
+	FILE *fd = NULL;
+	int lc = 0;
+	jobcomp_job_rec_t *job = NULL;
+	jobacct_selected_step_t *selected_step = NULL;
+	char *selected_part = NULL;
+	ListIterator itr = NULL;
+	List job_info_list = NULL;
+	flatfile_jobcomp_info_t *jobcomp_info = NULL;
+
+	fd = _open_log_file(params->opt_filein);
+	
+	while (fgets(line, BUFFER_SIZE, fd)) {
+		lc++;
+		fptr = line;	/* break the record into NULL-
+				   terminated strings */
+		if(job_info_list) 
+			list_destroy(job_info_list);
+		jobid = NULL;
+		partition = NULL;
+		job_info_list = list_create(_destroy_flatfile_jobcomp_info);
+		while(fptr) {
+			jobcomp_info =
+				xmalloc(sizeof(flatfile_jobcomp_info_t));
+			list_append(job_info_list, jobcomp_info);
+			jobcomp_info->name = fptr;
+			fptr = strstr(fptr, "=");
+			*fptr++ = 0;
+			jobcomp_info->val = fptr;
+			fptr = strstr(fptr, " ");
+			if(!strcasecmp("JobId", jobcomp_info->name)) 
+				jobid = jobcomp_info->val;
+			else if(!strcasecmp("Partition",
+					    jobcomp_info->name)) 
+				partition = jobcomp_info->val;
+			
+			
+			if(!fptr) {
+				fptr = strstr(jobcomp_info->val, "\n");
+				if (fptr)
+					*fptr = 0;
+				break; 
+			} else {
+				*fptr++ = 0;
+				if(*fptr == '\n') {
+					*fptr = 0;
+					break;
+				}
+			}
+		}
+				
+		if (list_count(selected_steps)) {
+			if(!jobid) 
+				continue;
+			itr = list_iterator_create(selected_steps);
+			while((selected_step = list_next(itr))) {
+				if (strcmp(selected_step->job, jobid))
+					continue;
+				/* job matches */
+				list_iterator_destroy(itr);
+				goto foundjob;
+			}
+			list_iterator_destroy(itr);
+			continue;	/* no match */
+		}
+	foundjob:
+		
+		if (list_count(selected_parts)) {
+			if(!partition) 
+				continue;
+			itr = list_iterator_create(selected_parts);
+			while((selected_part = list_next(itr))) 
+				if (!strcasecmp(selected_part, partition)) {
+					list_iterator_destroy(itr);
+					goto foundp;
+				}
+			list_iterator_destroy(itr);
+			continue;	/* no match */
+		}
+	foundp:
+		
+		if (params->opt_fdump) {
+			_do_fdump(job_info_list, lc);
+			continue;
+		}
+		
+		
+		job = _parse_line(job_info_list);
+		
+		if(job)
+			list_append(job_list, job);
+	}
+	if(job_info_list) 
+		list_destroy(job_info_list);
+	
+	if (ferror(fd)) {
+		perror(params->opt_filein);
+		exit(1);
+	} 
+	fclose(fd);
+
+	return;
+}
+
+extern void flatfile_jobcomp_process_archive(List selected_parts,
+					     sacct_parameters_t *params)
+{
+	info("No code to archive jobcomp.");
+}
diff --git a/src/plugins/database/flatfile/flatfile_jobcomp_process.h b/src/plugins/database/flatfile/flatfile_jobcomp_process.h
new file mode 100644
index 0000000000000000000000000000000000000000..195ee3cc70d884b4459b33fb9706de85d6970fa8
--- /dev/null
+++ b/src/plugins/database/flatfile/flatfile_jobcomp_process.h
@@ -0,0 +1,55 @@
+/*****************************************************************************\
+ *  flatfile_jobcomp_process.h - functions the processing of
+ *                               information from the flatfile jobcomp
+ *                               database.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+
+#ifndef _HAVE_FLATFILE_JOBCOMP_PROCESS_H
+#define _HAVE_FLATFILE_JOBCOMP_PROCESS_H
+
+#include "src/sacct/sacct.h"
+
+extern void flatfile_jobcomp_process_get_jobs(List job_list, 
+					      List selected_steps,
+					      List selected_parts,
+					      sacct_parameters_t *params);
+extern void flatfile_jobcomp_process_archive(List selected_parts,
+					     sacct_parameters_t *params);
+
+#endif
diff --git a/src/plugins/database/mysql/Makefile.am b/src/plugins/database/mysql/Makefile.am
new file mode 100644
index 0000000000000000000000000000000000000000..f7cf2b1a3831046a2300dde68bb436839055ddac
--- /dev/null
+++ b/src/plugins/database/mysql/Makefile.am
@@ -0,0 +1,20 @@
+# Makefile for database/mysql plugin
+
+AUTOMAKE_OPTIONS = foreign
+
+PLUGIN_FLAGS = -module -avoid-version --export-dynamic $(MYSQL_LIBS)
+
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
+
+pkglib_LTLIBRARIES = database_mysql.la
+
+# Mysql database plugin.
+database_mysql_la_SOURCES = database_mysql.c \
+		mysql_common.c mysql_common.h \
+		mysql_jobacct.c mysql_jobacct.h \
+		mysql_jobcomp.c mysql_jobcomp.h \
+		mysql_jobacct_process.c mysql_jobacct_process.h \
+		mysql_jobcomp_process.c mysql_jobcomp_process.h
+database_mysql_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
+database_mysql_la_LIBADD  = $(top_builddir)/src/common/libcommon.la
+
diff --git a/src/plugins/database/mysql/Makefile.in b/src/plugins/database/mysql/Makefile.in
new file mode 100644
index 0000000000000000000000000000000000000000..98072357a77415b5d291731159dde3849a807a24
--- /dev/null
+++ b/src/plugins/database/mysql/Makefile.in
@@ -0,0 +1,562 @@
+# Makefile.in generated by automake 1.10 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# Makefile for database/mysql plugin
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/plugins/database/mysql
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
+	$(top_srcdir)/auxdir/slurm.m4 \
+	$(top_srcdir)/auxdir/x_ac__system_configuration.m4 \
+	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
+	$(top_srcdir)/auxdir/x_ac_aix.m4 \
+	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
+	$(top_srcdir)/auxdir/x_ac_debug.m4 \
+	$(top_srcdir)/auxdir/x_ac_elan.m4 \
+	$(top_srcdir)/auxdir/x_ac_federation.m4 \
+	$(top_srcdir)/auxdir/x_ac_gpl_licensed.m4 \
+	$(top_srcdir)/auxdir/x_ac_gtk.m4 \
+	$(top_srcdir)/auxdir/x_ac_munge.m4 \
+	$(top_srcdir)/auxdir/x_ac_ncurses.m4 \
+	$(top_srcdir)/auxdir/x_ac_pam.m4 \
+	$(top_srcdir)/auxdir/x_ac_ptrace.m4 \
+	$(top_srcdir)/auxdir/x_ac_readline.m4 \
+	$(top_srcdir)/auxdir/x_ac_setpgrp.m4 \
+	$(top_srcdir)/auxdir/x_ac_setproctitle.m4 \
+	$(top_srcdir)/auxdir/x_ac_sgi_job.m4 \
+	$(top_srcdir)/auxdir/x_ac_slurm_ssl.m4 \
+	$(top_srcdir)/auxdir/x_ac_xcpu.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/slurm/slurm.h
+CONFIG_CLEAN_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(pkglibdir)"
+pkglibLTLIBRARIES_INSTALL = $(INSTALL)
+LTLIBRARIES = $(pkglib_LTLIBRARIES)
+database_mysql_la_DEPENDENCIES =  \
+	$(top_builddir)/src/common/libcommon.la
+am_database_mysql_la_OBJECTS = database_mysql.lo mysql_common.lo \
+	mysql_jobacct.lo mysql_jobcomp.lo mysql_jobacct_process.lo \
+	mysql_jobcomp_process.lo
+database_mysql_la_OBJECTS = $(am_database_mysql_la_OBJECTS)
+database_mysql_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(database_mysql_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
+SOURCES = $(database_mysql_la_SOURCES)
+DIST_SOURCES = $(database_mysql_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTHD_CFLAGS = @AUTHD_CFLAGS@
+AUTHD_LIBS = @AUTHD_LIBS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BG_INCLUDES = @BG_INCLUDES@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CMD_LDFLAGS = @CMD_LDFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ELAN_LIBS = @ELAN_LIBS@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FEDERATION_LDFLAGS = @FEDERATION_LDFLAGS@
+FFLAGS = @FFLAGS@
+GREP = @GREP@
+GTK2_CFLAGS = @GTK2_CFLAGS@
+GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
+HAVEPKGCONFIG = @HAVEPKGCONFIG@
+HAVE_AIX = @HAVE_AIX@
+HAVE_ELAN = @HAVE_ELAN@
+HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_LDFLAGS = @LIB_LDFLAGS@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
+MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
+MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
+NCURSES = @NCURSES@
+NUMA_LIBS = @NUMA_LIBS@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PAM_LIBS = @PAM_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
+PLPA_LIBS = @PLPA_LIBS@
+PROCTRACKDIR = @PROCTRACKDIR@
+PROJECT = @PROJECT@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+RELEASE = @RELEASE@
+SEMAPHORE_LIBS = @SEMAPHORE_LIBS@
+SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMD_PORT = @SLURMD_PORT@
+SLURM_API_AGE = @SLURM_API_AGE@
+SLURM_API_CURRENT = @SLURM_API_CURRENT@
+SLURM_API_MAJOR = @SLURM_API_MAJOR@
+SLURM_API_REVISION = @SLURM_API_REVISION@
+SLURM_API_VERSION = @SLURM_API_VERSION@
+SLURM_MAJOR = @SLURM_MAJOR@
+SLURM_MICRO = @SLURM_MICRO@
+SLURM_MINOR = @SLURM_MINOR@
+SLURM_VERSION = @SLURM_VERSION@
+SO_LDFLAGS = @SO_LDFLAGS@
+SSL_CPPFLAGS = @SSL_CPPFLAGS@
+SSL_LDFLAGS = @SSL_LDFLAGS@
+SSL_LIBS = @SSL_LIBS@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign
+PLUGIN_FLAGS = -module -avoid-version --export-dynamic $(MYSQL_LIBS)
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
+pkglib_LTLIBRARIES = database_mysql.la
+
+# Mysql database plugin.
+database_mysql_la_SOURCES = database_mysql.c \
+		mysql_common.c mysql_common.h \
+		mysql_jobacct.c mysql_jobacct.h \
+		mysql_jobcomp.c mysql_jobcomp.h \
+		mysql_jobacct_process.c mysql_jobacct_process.h \
+		mysql_jobcomp_process.c mysql_jobcomp_process.h
+
+database_mysql_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
+database_mysql_la_LIBADD = $(top_builddir)/src/common/libcommon.la
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/plugins/database/mysql/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  src/plugins/database/mysql/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
+	@$(NORMAL_INSTALL)
+	test -z "$(pkglibdir)" || $(MKDIR_P) "$(DESTDIR)$(pkglibdir)"
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  if test -f $$p; then \
+	    f=$(am__strip_dir) \
+	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	  else :; fi; \
+	done
+
+uninstall-pkglibLTLIBRARIES:
+	@$(NORMAL_UNINSTALL)
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  p=$(am__strip_dir) \
+	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	done
+
+clean-pkglibLTLIBRARIES:
+	-test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES)
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+database_mysql.la: $(database_mysql_la_OBJECTS) $(database_mysql_la_DEPENDENCIES) 
+	$(database_mysql_la_LINK) -rpath $(pkglibdir) $(database_mysql_la_OBJECTS) $(database_mysql_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/database_mysql.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mysql_common.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mysql_jobacct.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mysql_jobacct_process.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mysql_jobcomp.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mysql_jobcomp_process.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+	for dir in "$(DESTDIR)$(pkglibdir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-pkglibLTLIBRARIES
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pkglibLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-pkglibLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-pkglibLTLIBRARIES \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-pkglibLTLIBRARIES
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/plugins/database/mysql/database_mysql.c b/src/plugins/database/mysql/database_mysql.c
new file mode 100644
index 0000000000000000000000000000000000000000..769dd1fb105cb7b8b8d81f3226471dedd597dd46
--- /dev/null
+++ b/src/plugins/database/mysql/database_mysql.c
@@ -0,0 +1,289 @@
+/*****************************************************************************\
+ *  database_mysql.c - Store/Get all information in a mysql database.
+ *
+ *  $Id: database_mysql.c 10893 2007-01-29 21:53:48Z da $
+ *****************************************************************************
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#include "mysql_jobacct.h"
+#include "mysql_jobcomp.h"
+#include "mysql_common.h"
+
+/*
+ * These variables are required by the generic plugin interface.  If they
+ * are not found in the plugin, the plugin loader will ignore it.
+ *
+ * plugin_name - a string giving a human-readable description of the
+ * plugin.  There is no maximum length, but the symbol must refer to
+ * a valid string.
+ *
+ * plugin_type - a string suggesting the type of the plugin or its
+ * applicability to a particular form of data or method of data handling.
+ * If the low-level plugin API is used, the contents of this string are
+ * unimportant and may be anything.  SLURM uses the higher-level plugin
+ * interface which requires this string to be of the form
+ *
+ *	<application>/<method>
+ *
+ * where <application> is a description of the intended application of
+ * the plugin (e.g., "jobacct" for SLURM job completion logging) and <method>
+ * is a description of how this plugin satisfies that application.  SLURM will
+ * only load job completion logging plugins if the plugin_type string has a 
+ * prefix of "jobacct/".
+ *
+ * plugin_version - an unsigned 32-bit integer giving the version number
+ * of the plugin.  If major and minor revisions are desired, the major
+ * version number may be multiplied by a suitable magnitude constant such
+ * as 100 or 1000.  Various SLURM versions will likely require a certain
+ * minimum versions for their plugins as the job accounting API 
+ * matures.
+ */
+const char plugin_name[] = "Database MYSQL plugin";
+const char plugin_type[] = "database/mysql";
+const uint32_t plugin_version = 100;
+
+
+/*
+ * init() is called when the plugin is loaded, before any other functions
+ * are called.  Put global initialization here.
+ */
+extern int init ( void )
+{
+#ifdef HAVE_MYSQL
+	if(!mysql_thread_safe()) {
+		debug2("MySQL database not treadsafe only one connection "
+		      "to the database will be allowed.");
+		thread_safe = false;
+	}
+#else
+	fatal("No MySQL database was found on the machine. "
+	      "Please check the configure ran and run again.");
+#endif
+	verbose("%s loaded", plugin_name);
+	return SLURM_SUCCESS;
+}
+
+extern int fini ( void )
+{
+	return SLURM_SUCCESS;
+}
+
+/* 
+ * Initialize the database make sure tables are created and in working
+ * order
+ */
+extern int database_p_jobacct_init(char *job_acct_log)
+{
+#ifdef HAVE_MYSQL
+	return mysql_jobacct_init(job_acct_log);	
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+/*
+ * finish up database connection
+ */
+extern int database_p_jobacct_fini()
+{
+#ifdef HAVE_MYSQL
+	return mysql_jobacct_fini();
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+/* 
+ * load into the database the start of a job
+ */
+extern int database_p_jobacct_job_start(struct job_record *job_ptr)
+{
+#ifdef HAVE_MYSQL
+	return mysql_jobacct_job_start(job_ptr);
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+/* 
+ * load into the database the end of a job
+ */
+extern int database_p_jobacct_job_complete(struct job_record *job_ptr)
+{
+#ifdef HAVE_MYSQL
+	return mysql_jobacct_job_complete(job_ptr);
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+/* 
+ * load into the database the start of a job step
+ */
+extern int database_p_jobacct_step_start(struct step_record *step_ptr)
+{
+#ifdef HAVE_MYSQL
+	return mysql_jobacct_step_start(step_ptr);
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+/* 
+ * load into the database the end of a job step
+ */
+extern int database_p_jobacct_step_complete(struct step_record *step_ptr)
+{
+#ifdef HAVE_MYSQL
+	return mysql_jobacct_step_complete(step_ptr);
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+/* 
+ * load into the database a suspention of a job
+ */
+extern int database_p_jobacct_suspend(struct job_record *job_ptr)
+{
+#ifdef HAVE_MYSQL
+	return mysql_jobacct_suspend(job_ptr);
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+/* 
+ * get info from the database 
+ * returns List of job_rec_t *
+ * note List needs to be freed when called
+ */
+extern void database_p_jobacct_get_jobs(List job_list,
+					List selected_steps,
+					List selected_parts,
+					void *params)
+{
+#ifdef HAVE_MYSQL
+	mysql_jobacct_get_jobs(job_list,
+			       selected_steps, selected_parts,
+			       params);
+#endif
+	return;
+}
+
+/* 
+ * expire old info from the database 
+ */
+extern void database_p_jobacct_archive(List selected_parts,
+				       void *params)
+{
+#ifdef HAVE_MYSQL
+	mysql_jobacct_archive(selected_parts, params);
+#endif
+	return;
+}
+
+extern int database_p_jobcomp_init(char *location)
+{
+#ifdef HAVE_MYSQL
+	return mysql_jobcomp_init(location);
+#else
+	return SLURM_ERROR;
+#endif 
+}
+
+extern int database_p_jobcomp_fini(void)
+{
+#ifdef HAVE_MYSQL
+	return mysql_jobcomp_fini();
+#else
+	return SLURM_ERROR;
+#endif 
+}
+
+extern int database_p_jobcomp_log_record(struct job_record *job_ptr)
+{
+#ifdef HAVE_MYSQL
+	return mysql_jobcomp_log_record(job_ptr);
+#else
+	return SLURM_ERROR;
+#endif 
+}
+
+extern int database_p_jobcomp_get_errno(void)
+{
+#ifdef HAVE_MYSQL
+	return mysql_jobcomp_get_errno();
+#else
+	return SLURM_ERROR;
+#endif 
+}
+
+extern char *database_p_jobcomp_strerror(int errnum)
+{
+#ifdef HAVE_MYSQL
+	return mysql_jobcomp_strerror(errnum);
+#else
+	return NULL;
+#endif 
+}
+
+/* 
+ * get info from the database 
+ * in/out job_list List of job_rec_t *
+ * note List needs to be freed when called
+ */
+extern void database_p_jobcomp_get_jobs(List job_list, 
+					List selected_steps,
+					List selected_parts,
+					void *params)
+{
+#ifdef HAVE_MYSQL
+	mysql_jobcomp_get_jobs(job_list, 
+			       selected_steps, selected_parts,
+			       params);	
+#endif 
+	return;
+}
+
+/* 
+ * expire old info from the database 
+ */
+extern void database_p_jobcomp_archive(List selected_parts, void *params)
+{
+#ifdef HAVE_MYSQL
+	mysql_jobcomp_archive(selected_parts, params);
+#endif 
+	return;
+}
diff --git a/src/plugins/database/mysql/mysql_common.c b/src/plugins/database/mysql/mysql_common.c
new file mode 100644
index 0000000000000000000000000000000000000000..a182e51e2bf5e0cc5fad62dfce6e966d0c350202
--- /dev/null
+++ b/src/plugins/database/mysql/mysql_common.c
@@ -0,0 +1,251 @@
+/*****************************************************************************\
+ *  mysql_common.c - common functions for the the mysql database plugin.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+
+#include "mysql_common.h"
+
+bool thread_safe = true;
+pthread_mutex_t mysql_lock = PTHREAD_MUTEX_INITIALIZER;
+
+#ifdef HAVE_MYSQL
+
+static int _mysql_make_table_current(MYSQL *mysql_db, int database_init, 
+				     char *table_name,
+				     database_field_t *fields)
+{
+	char *query = NULL;
+	int i = 0;
+
+	while(fields[i].name) {
+		query = xstrdup_printf("alter table %s modify %s %s",
+				       table_name, fields[i].name,
+				       fields[i].options);
+		if(mysql_db_query(mysql_db, database_init, query)) {
+			info("adding column %s after %s", fields[i].name,
+			     fields[i-1].name);
+			xfree(query);
+			query = xstrdup_printf(
+				"alter table %s add %s %s after %s",
+				table_name, fields[i].name,
+				fields[i].options,
+				fields[i-1].name);
+			if(mysql_db_query(mysql_db, database_init, query)) {
+				xfree(query);
+				return SLURM_ERROR;
+			}
+
+		}
+		xfree(query);
+		i++;
+	}
+	
+	return SLURM_SUCCESS;
+}
+
+extern mysql_db_info_t *create_mysql_db_info()
+{
+	mysql_db_info_t *db_info = xmalloc(sizeof(mysql_db_info_t));
+	db_info->port = slurm_get_database_port();
+	if(!db_info->port) 
+		db_info->port = 3306;
+	db_info->host = slurm_get_database_host();	
+	db_info->user = slurm_get_database_user();	
+	db_info->pass = slurm_get_database_pass();	
+	return db_info;
+}
+
+extern int *destroy_mysql_db_info(mysql_db_info_t *db_info)
+{
+	if(db_info) {
+		xfree(db_info->host);
+		xfree(db_info->user);
+		xfree(db_info->pass);
+		xfree(db_info);
+	}
+	return SLURM_SUCCESS;
+}
+
+extern int mysql_create_db(MYSQL *mysql_db, char *db_name,
+			   mysql_db_info_t *db_info)
+{
+	char create_line[50];
+
+	if(mysql_real_connect(mysql_db, db_info->host, db_info->user,
+			      db_info->pass, NULL, db_info->port, NULL, 0)) {
+		snprintf(create_line, sizeof(create_line),
+			 "create database %s", db_name);
+		if(mysql_query(mysql_db, create_line)) {
+			fatal("mysql_real_query failed: %d %s\n%s",
+			      mysql_errno(mysql_db),
+			      mysql_error(mysql_db), create_line);
+		}
+	} else {
+		info("Connection failed to host = %s "
+		     "user = %s pass = %s port = %u",
+		     db_info->host, db_info->user,
+		     db_info->pass, db_info->port);
+		fatal("mysql_real_connect failed: %d %s",
+		      mysql_errno(mysql_db),
+		      mysql_error(mysql_db));
+	}
+	return SLURM_SUCCESS;
+}
+
+extern int mysql_get_db_connection(MYSQL **mysql_db, char *db_name,
+				   mysql_db_info_t *db_info,
+				   int *database_init)
+{
+	int rc = SLURM_SUCCESS;
+	
+	if(!(*mysql_db = mysql_init(*mysql_db)))
+		fatal("mysql_init failed: %s", mysql_error(*mysql_db));
+	else {
+		while(!*database_init) {
+			if(!mysql_real_connect(*mysql_db, db_info->host,
+					       db_info->user, db_info->pass,
+					       db_name, db_info->port,
+					       NULL, 0)) {
+				if(mysql_errno(*mysql_db) == ER_BAD_DB_ERROR) {
+					debug("Database %s not created.  "
+					      "Creating", db_name);
+					mysql_create_db(*mysql_db, db_name,
+							db_info);
+				} else {
+					fatal("mysql_real_connect failed: "
+					      "%d %s",
+					      mysql_errno(*mysql_db),
+					      mysql_error(*mysql_db));
+				}
+			} else {
+				*database_init = true;
+			}
+		}
+	}
+	return rc;
+}
+
+extern int mysql_db_query(MYSQL *mysql_db, int database_init,  char *query)
+{
+	if(!database_init)
+		fatal("You haven't inited this database yet.");
+
+	if(mysql_query(mysql_db, query)) {
+		error("mysql_query failed: %d %s\n%s",
+		      mysql_errno(mysql_db),
+		      mysql_error(mysql_db), query);
+		return SLURM_ERROR;
+	}
+
+	return SLURM_SUCCESS;
+}
+
+extern MYSQL_RES *mysql_db_query_ret(MYSQL *mysql_db, int database_init,
+				     char *query)
+{
+	MYSQL_RES *result = NULL;
+	
+	if(mysql_db_query(mysql_db, database_init, query) != SLURM_ERROR)  {
+		result = mysql_store_result(mysql_db);
+		if(!result && mysql_field_count(mysql_db)) {
+			/* should have returned data */
+			error("We should have gotten a result: %s", 
+			      mysql_error(mysql_db));
+		}
+	}
+
+	return result;
+}
+
+extern int mysql_insert_ret_id(MYSQL *mysql_db, int database_init, char *query)
+{
+	int new_id = 0;
+	
+	if(mysql_db_query(mysql_db, database_init, query) != SLURM_ERROR)  {
+		new_id = mysql_insert_id(mysql_db);
+		if(!new_id) {
+			/* should have new id */
+			error("We should have gotten a new id: %s", 
+			      mysql_error(mysql_db));
+		}
+	}
+
+	return new_id;
+	
+}
+
+extern int mysql_db_create_table(MYSQL *mysql_db, int database_init, 
+				 char *table_name, database_field_t *fields,
+				 char *ending)
+{
+	char *query = NULL;
+	char *tmp = NULL;
+	char *next = NULL;
+	int i = 0;
+	database_field_t *first_field = fields;
+	
+	query = xstrdup_printf("create table if not exists %s (", table_name);
+	i=0;
+	while(fields && fields->name) {
+		next = xstrdup_printf(" %s %s",
+				      fields->name, 
+				      fields->options);
+		if(i) 
+			xstrcat(tmp, ",");
+		xstrcat(tmp, next);
+		xfree(next);
+		fields++;
+		i++;
+	}
+	xstrcat(query, tmp);
+	xfree(tmp);
+	xstrcat(query, ending);
+
+	if(mysql_db_query(mysql_db, database_init, query)
+	   == SLURM_ERROR) {
+		xfree(query);
+		return SLURM_ERROR;
+	}
+	xfree(query);	
+	
+	return _mysql_make_table_current(mysql_db, database_init, 
+					 table_name, first_field);
+}
+
+#endif
+
diff --git a/src/plugins/database/mysql/mysql_common.h b/src/plugins/database/mysql/mysql_common.h
new file mode 100644
index 0000000000000000000000000000000000000000..66ccbc55b81dd4f069943e15cc9feb55b12a0d4f
--- /dev/null
+++ b/src/plugins/database/mysql/mysql_common.h
@@ -0,0 +1,103 @@
+/*****************************************************************************\
+ *  mysql_common.h - common functions for the the mysql database plugin.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+#ifndef _HAVE_MYSQL_COMMON_H
+#define _HAVE_MYSQL_COMMON_H
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#if HAVE_STDINT_H
+#  include <stdint.h>
+#endif
+#if HAVE_INTTYPES_H
+#  include <inttypes.h>
+#endif
+
+#include <stdio.h>
+#include <slurm/slurm_errno.h>
+#include "src/slurmctld/slurmctld.h"
+#include "src/common/xstring.h"
+
+#ifdef HAVE_MYSQL
+#include <mysql/mysql.h>
+#include <mysql/mysqld_error.h>
+
+typedef struct {
+	uint32_t port;	
+	char *host;	
+	char *user;	
+	char *pass;	
+} mysql_db_info_t;
+
+typedef struct {
+	char *name;
+	char *options;
+} database_field_t;
+
+
+extern bool thread_safe;
+extern pthread_mutex_t mysql_lock;
+
+extern mysql_db_info_t *create_mysql_db_info();
+
+extern int *destroy_mysql_db_info(mysql_db_info_t *db_info);
+
+extern int mysql_create_db(MYSQL *mysql_db, char *db_name,
+			   mysql_db_info_t *db_info);
+
+extern int mysql_get_db_connection(MYSQL **mysql_db, char *db_name,
+				   mysql_db_info_t *db_info,
+				   int *database_init);
+extern int mysql_db_query(MYSQL *mysql_db, int database_init, char *query);
+
+extern MYSQL_RES *mysql_db_query_ret(MYSQL *mysql_db, int database_init,
+				     char *query);
+
+extern int mysql_insert_ret_id(MYSQL *mysql_db, int database_init, 
+			       char *query);
+
+extern int mysql_db_create_table(MYSQL *mysql_db, int database_init, 
+				 char *table_name, database_field_t *fields,
+				 char *ending);
+
+#endif
+
+#endif
diff --git a/src/plugins/database/mysql/mysql_jobacct.c b/src/plugins/database/mysql/mysql_jobacct.c
new file mode 100644
index 0000000000000000000000000000000000000000..458bc6b8bcf3dd2d0ab1ee3af6e136f434887d52
--- /dev/null
+++ b/src/plugins/database/mysql/mysql_jobacct.c
@@ -0,0 +1,674 @@
+/*****************************************************************************\
+ *  mysql_jobacct.c - functions the mysql jobacct database.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+
+#include "mysql_jobacct_process.h"
+
+#ifdef HAVE_MYSQL
+
+#define DEFAULT_JOBACCT_DB "slurm_jobacct_db"
+
+MYSQL *jobacct_mysql_db = NULL;
+int jobacct_db_init = 0;
+
+char *job_index = "index_table";
+char *job_table = "job_table";
+char *step_table = "step_table";
+char *rusage_table = "rusage_table";
+
+static int _mysql_jobacct_check_tables()
+{
+	database_field_t job_index_fields[] = {
+		{ "id", "int not null auto_increment" },
+		{ "jobid ", "mediumint unsigned not null" },
+		{ "partition", "tinytext not null" },
+		{ "submit", "int unsigned not null" },
+		{ "uid", "smallint unsigned not null" },
+		{ "gid", "smallint unsigned not null" },
+		{ "blockid", "tinytext" },
+		{ NULL, NULL}		
+	};
+
+	database_field_t job_table_fields[] = {
+		{ "id", "int not null" },
+		{ "start", "int unsigned default 0" },
+		{ "end", "int unsigned default 0" },
+		{ "suspended", "int unsigned default 0" },
+		{ "name", "tinytext not null" }, 
+		{ "track_steps", "tinyint not null" },
+		{ "state", "smallint not null" }, 
+		{ "priority", "int unsigned not null" },
+		{ "cpus", "mediumint unsigned not null" }, 
+		{ "nodelist", "text" },
+		{ "account", "tinytext" },
+		{ "kill_requid", "smallint" },
+		{ NULL, NULL}
+	};
+
+	database_field_t step_table_fields[] = {
+		{ "id", "int not null" },
+		{ "stepid", "smallint not null" },
+		{ "start", "int unsigned default 0" },
+		{ "end", "int unsigned default 0" },
+		{ "suspended", "int unsigned default 0" },
+		{ "name", "text not null" },
+		{ "nodelist", "text not null" },
+		{ "state", "smallint not null" },
+		{ "kill_requid", "smallint default -1" },
+		{ "comp_code", "smallint default 0" },
+		{ "cpus", "mediumint unsigned not null" },
+		{ "max_vsize", "mediumint unsigned default 0" },
+		{ "max_vsize_task", "smallint unsigned default 0" },
+		{ "max_vsize_node", "mediumint unsigned default 0" },
+		{ "ave_vsize", "float default 0.0" },
+		{ "max_rss", "mediumint unsigned default 0" },
+		{ "max_rss_task", "smallint unsigned default 0" },
+		{ "max_rss_node", "mediumint unsigned default 0" },
+		{ "ave_rss", "float default 0.0" },
+		{ "max_pages", "mediumint unsigned default 0" },
+		{ "max_pages_task", "smallint unsigned default 0" },
+		{ "max_pages_node", "mediumint unsigned default 0" },
+		{ "ave_pages", "float default 0.0" },
+		{ "min_cpu", "mediumint unsigned default 0" },
+		{ "min_cpu_task", "smallint unsigned default 0" },
+		{ "min_cpu_node", "mediumint unsigned default 0" },
+		{ "ave_cpu", "float default 0.0" },
+		{ NULL, NULL}
+	};
+
+	database_field_t step_rusage_fields[] = {
+		{ "id", "int not null" },
+		{ "stepid", "smallint not null" },
+		{ "cpu_sec", "int unsigned default 0" },
+		{ "cpu_usec", "int unsigned default 0" },
+		{ "user_sec", "int unsigned default 0" },
+		{ "user_usec", "int unsigned default 0" },
+		{ "sys_sec", "int unsigned default 0" },
+		{ "sys_usec", "int unsigned default 0" },
+		{ "max_rss", "int unsigned default 0" },
+		{ "max_ixrss", "int unsigned default 0" },
+		{ "max_idrss", "int unsigned default 0" },
+		{ "max_isrss", "int unsigned default 0" },
+		{ "max_minflt", "int unsigned default 0" },
+		{ "max_majflt", "int unsigned default 0" },
+		{ "max_nswap", "int unsigned default 0" },
+		{ "inblock", "int unsigned default 0" },
+		{ "outblock", "int unsigned default 0" },
+		{ "msgsnd", "int unsigned default 0" },
+		{ "msgrcv", "int unsigned default 0" },
+		{ "nsignals", "int unsigned default 0" },
+		{ "nvcsw", "int unsigned default 0" },
+		{ "nivcsw", "int unsigned default 0" },
+		{ NULL, NULL}
+	};
+
+	if(mysql_db_create_table(jobacct_mysql_db, jobacct_db_init, 
+				 job_index, job_index_fields,
+				 ", primary key (id))") == SLURM_ERROR)
+		return SLURM_ERROR;
+	
+	if(mysql_db_create_table(jobacct_mysql_db, jobacct_db_init, 
+				 job_table, job_table_fields,
+				 ")") == SLURM_ERROR)
+		return SLURM_ERROR;
+
+	if(mysql_db_create_table(jobacct_mysql_db, jobacct_db_init, 
+				 step_table, step_table_fields,
+				 ")") == SLURM_ERROR)
+		return SLURM_ERROR;
+
+	if(mysql_db_create_table(jobacct_mysql_db, jobacct_db_init, 
+				 rusage_table, step_rusage_fields,
+				 ")") == SLURM_ERROR)
+		return SLURM_ERROR;
+
+
+	return SLURM_SUCCESS;
+}
+
+
+extern int mysql_jobacct_init(char *location)
+{
+	mysql_db_info_t *db_info = create_mysql_db_info();
+	int rc = SLURM_SUCCESS;
+	char *db_name = NULL;
+	
+	if(jobacct_db_init) 
+		return SLURM_ERROR;
+	
+	if(!location)
+		db_name = DEFAULT_JOBACCT_DB;
+	else {
+		int i = 0;
+		while(location[i]) {
+			if(location[i] == '.' || location[i] == '/') {
+				debug("%s doesn't look like a database "
+				      "name using %s",
+				      location, DEFAULT_JOBACCT_DB);
+				break;
+			}
+			i++;
+		}
+		if(location[i]) 
+			db_name = DEFAULT_JOBACCT_DB;
+		else
+			db_name = location;
+	}
+	debug2("mysql_connect() called for db %s", db_name);
+	
+	mysql_get_db_connection(&jobacct_mysql_db, db_name, db_info,
+				&jobacct_db_init);
+
+	_mysql_jobacct_check_tables();
+
+	destroy_mysql_db_info(db_info);
+
+	debug("Jobacct database init finished");
+
+	return rc;
+}
+
+extern int mysql_jobacct_fini()
+{
+	if (jobacct_mysql_db) {
+		mysql_close(jobacct_mysql_db);
+		jobacct_mysql_db = NULL;
+	}
+	jobacct_db_init = 0;
+	return SLURM_SUCCESS;
+}
+
+extern int mysql_jobacct_job_start(struct job_record *job_ptr)
+{
+	int	i,
+		ncpus=0,
+		rc=SLURM_SUCCESS;
+	char	*jname, *account, *nodes;
+	long	priority;
+	int track_steps = 0;
+	char *block_id = NULL;
+	char query[1024];
+	int reinit = 0;
+
+	if(!jobacct_mysql_db) {
+		char *loc = slurm_get_jobacct_loc();
+		if(mysql_jobacct_init(loc) == SLURM_ERROR) {
+			xfree(loc);
+			return SLURM_ERROR;
+		}
+		xfree(loc);
+	}
+
+	debug2("mysql_jobacct_job_start() called");
+	for (i=0; i < job_ptr->num_cpu_groups; i++)
+		ncpus += (job_ptr->cpus_per_node[i])
+			* (job_ptr->cpu_count_reps[i]);
+	priority = (job_ptr->priority == NO_VAL) ?
+		-1L : (long) job_ptr->priority;
+
+	if (job_ptr->name && job_ptr->name[0]) {
+		jname = job_ptr->name;
+	} else {
+		jname = "allocation";
+		track_steps = 1;
+	}
+
+	if (job_ptr->account && job_ptr->account[0])
+		account = job_ptr->account;
+	else
+		account = "(null)";
+	if (job_ptr->nodes && job_ptr->nodes[0])
+		nodes = job_ptr->nodes;
+	else
+		nodes = "(null)";
+
+	if(job_ptr->batch_flag)
+		track_steps = 1;
+#ifdef HAVE_BG
+	select_g_get_jobinfo(job_ptr->select_jobinfo, 
+			     SELECT_DATA_BLOCK_ID, 
+			     &block_id);
+		
+#endif
+	if(!block_id)
+		block_id = xstrdup("-");
+
+	job_ptr->requid = -1; /* force to -1 for sacct to know this
+			       * hasn't been set yet */
+	snprintf(query, sizeof(query),
+		 "insert into %s (jobid, partition, submit, uid, gid, "
+		 "blockid) values (%u, '%s', %u, %d, %d, '%s')",
+		 job_index, job_ptr->job_id, job_ptr->partition,
+		 (int)job_ptr->details->submit_time, job_ptr->user_id,
+		 job_ptr->group_id, block_id);
+	xfree(block_id);
+
+try_again:
+	if((job_ptr->db_index =
+	    mysql_insert_ret_id(jobacct_mysql_db, jobacct_db_init, query))) {
+		snprintf(query, sizeof(query),
+			 "insert into %s (id, start, name, track_steps, "
+			 "state, priority, cpus, nodelist, account) "
+			 "values (%d, %u, '%s', %d, %d, %ld, %u, '%s', '%s')",
+			 job_table, job_ptr->db_index, 
+			 (int)job_ptr->start_time,
+			 jname, track_steps,
+			 job_ptr->job_state & (~JOB_COMPLETING),
+			 priority, job_ptr->num_procs,
+			 nodes, account);
+		rc = mysql_db_query(jobacct_mysql_db, jobacct_db_init, query);
+	} else if(!reinit) {
+		char *loc = slurm_get_jobacct_loc();
+		error("It looks like the database has gone "
+		      "away trying to reconnect");
+		mysql_jobacct_fini();
+		mysql_jobacct_init(loc);
+		xfree(loc);
+		reinit = 1;
+		goto try_again;
+	} else
+		rc = SLURM_ERROR;
+	
+	return rc;
+}
+
+extern int mysql_jobacct_job_complete(struct job_record *job_ptr)
+{
+	char query[1024];
+	char	*account, *nodes;
+	int rc=SLURM_SUCCESS;
+	
+	if(!jobacct_mysql_db) {
+		char *loc = slurm_get_jobacct_loc();
+		if(mysql_jobacct_init(loc) == SLURM_ERROR) {
+			xfree(loc);
+			return SLURM_ERROR;
+		}
+		xfree(loc);
+	}
+	
+	debug2("mysql_jobacct_job_complete() called");
+	if (job_ptr->end_time == 0) {
+		debug("mysql_jobacct: job %u never started", job_ptr->job_id);
+		return SLURM_ERROR;
+	}	
+	
+	if (job_ptr->account && job_ptr->account[0])
+		account = job_ptr->account;
+	else
+		account = "(null)";
+	if (job_ptr->nodes && job_ptr->nodes[0])
+		nodes = job_ptr->nodes;
+	else
+		nodes = "(null)";
+
+	if(job_ptr->db_index) {
+		snprintf(query, sizeof(query),
+			 "update %s set start=%u, end=%u, state=%d, "
+			 "nodelist='%s', account='%s', "
+			 "kill_requid=%d where id=%u",
+			 job_table, (int)job_ptr->start_time,
+			 (int)job_ptr->end_time, 
+			 job_ptr->job_state & (~JOB_COMPLETING),
+			 nodes, account,
+			 job_ptr->requid, job_ptr->db_index);
+		rc = mysql_db_query(jobacct_mysql_db, jobacct_db_init, query);
+	} else 
+		rc = SLURM_ERROR;
+
+	return  rc;
+
+}
+
+extern int mysql_jobacct_step_start(struct step_record *step_ptr)
+{
+	int cpus = 0;
+	int rc=SLURM_SUCCESS;
+	char node_list[BUFFER_SIZE];
+#ifdef HAVE_BG
+	char *ionodes = NULL;
+#endif
+	char query[1024];
+	
+	if(!jobacct_mysql_db) {
+		char *loc = slurm_get_jobacct_loc();
+		if(mysql_jobacct_init(loc) == SLURM_ERROR) {
+			xfree(loc);
+			return SLURM_ERROR;
+		}
+		xfree(loc);
+	}
+
+#ifdef HAVE_BG
+	cpus = step_ptr->job_ptr->num_procs;
+	select_g_get_jobinfo(step_ptr->job_ptr->select_jobinfo, 
+			     SELECT_DATA_IONODES, 
+			     &ionodes);
+	if(ionodes) {
+		snprintf(node_list, BUFFER_SIZE, 
+			 "%s[%s]", step_ptr->job_ptr->nodes, ionodes);
+		xfree(ionodes);
+	} else
+		snprintf(node_list, BUFFER_SIZE, "%s",
+			 step_ptr->job_ptr->nodes);
+	
+#else
+	if(!step_ptr->step_layout || !step_ptr->step_layout->task_cnt) {
+		cpus = step_ptr->job_ptr->num_procs;
+		snprintf(node_list, BUFFER_SIZE, "%s", step_ptr->job_ptr->nodes);
+	} else {
+		cpus = step_ptr->step_layout->task_cnt;
+		snprintf(node_list, BUFFER_SIZE, "%s", 
+			 step_ptr->step_layout->node_list);
+	}
+#endif
+	step_ptr->job_ptr->requid = -1; /* force to -1 for sacct to know this
+					 * hasn't been set yet  */
+
+	if(step_ptr->job_ptr->db_index) {
+		snprintf(query, sizeof(query),
+			 "insert into %s (id, stepid, start, name, state, "
+			 "cpus, nodelist, kill_requid) "
+			 "values (%d, %u, %u, '%s', %d, %u, '%s', %d)",
+			 step_table, step_ptr->job_ptr->db_index,
+			 step_ptr->step_id, 
+			 (int)step_ptr->start_time, step_ptr->name,
+			 JOB_RUNNING, cpus, node_list, 
+			 step_ptr->job_ptr->requid);
+		rc = mysql_db_query(jobacct_mysql_db, jobacct_db_init, query);
+		if(rc != SLURM_ERROR) {
+			snprintf(query, sizeof(query),
+				 "insert into %s (id, stepid) values (%d, %u)",
+				 rusage_table, step_ptr->job_ptr->db_index,
+				 step_ptr->step_id);
+			rc = mysql_db_query(jobacct_mysql_db,
+					    jobacct_db_init, query);
+		}	  
+	} else 
+		rc = SLURM_ERROR;
+		 
+	return rc;
+}
+
+extern int mysql_jobacct_step_complete(struct step_record *step_ptr)
+{
+	time_t now;
+	int elapsed;
+	int comp_status;
+	int cpus = 0;
+	struct jobacctinfo *jobacct = (struct jobacctinfo *)step_ptr->jobacct;
+#ifdef HAVE_BG
+	char *ionodes = NULL;
+#endif
+	float ave_vsize = 0, ave_rss = 0, ave_pages = 0;
+	float ave_cpu = 0, ave_cpu2 = 0;
+	char *account;
+	char query[1024];
+	int rc =SLURM_SUCCESS;
+	
+	if(!jobacct_mysql_db) {
+		char *loc = slurm_get_jobacct_loc();
+		if(mysql_jobacct_init(loc) == SLURM_ERROR) {
+			xfree(loc);
+			return SLURM_ERROR;
+		}
+		xfree(loc);
+	}
+	
+	now = time(NULL);
+	
+	if ((elapsed=now-step_ptr->start_time)<0)
+		elapsed=0;	/* For *very* short jobs, if clock is wrong */
+	if (step_ptr->exit_code)
+		comp_status = JOB_FAILED;
+	else
+		comp_status = JOB_COMPLETE;
+
+#ifdef HAVE_BG
+	cpus = step_ptr->job_ptr->num_procs;
+	
+#else
+	if(!step_ptr->step_layout || !step_ptr->step_layout->task_cnt)
+		cpus = step_ptr->job_ptr->num_procs;
+	else 
+		cpus = step_ptr->step_layout->task_cnt;
+#endif
+	/* figure out the ave of the totals sent */
+	if(cpus > 0) {
+		ave_vsize = jobacct->tot_vsize;
+		ave_vsize /= cpus;
+		ave_rss = jobacct->tot_rss;
+		ave_rss /= cpus;
+		ave_pages = jobacct->tot_pages;
+		ave_pages /= cpus;
+		ave_cpu = jobacct->tot_cpu;
+		ave_cpu /= cpus;	
+		ave_cpu /= 100;
+	}
+ 
+	if(jobacct->min_cpu != (uint32_t)NO_VAL) {
+		ave_cpu2 = jobacct->min_cpu;
+		ave_cpu2 /= 100;
+	}
+
+	if (step_ptr->job_ptr->account && step_ptr->job_ptr->account[0])
+		account = step_ptr->job_ptr->account;
+	else
+		account = "(null)";
+
+	if(step_ptr->job_ptr->db_index) {
+		snprintf(query, sizeof(query),
+			 "update %s set end=%u, state=%d, "
+			 "kill_requid=%d, "
+			 "max_vsize=%u, max_vsize_task=%u, "
+			 "max_vsize_node=%u, ave_vsize=%.2f, "
+			 "max_rss=%u, max_rss_task=%u, "
+			 "max_rss_node=%u, ave_rss=%.2f, "
+			 "max_pages=%u, max_pages_task=%u, "
+			 "max_pages_node=%u, ave_pages=%.2f, "
+			 "min_cpu=%.2f, min_cpu_task=%u, "
+			 "min_cpu_node=%u, ave_cpu=%.2f "
+			 "where id=%u and stepid=%u",
+			 step_table, (int)now,
+			 comp_status,
+			 step_ptr->job_ptr->requid, 
+			 jobacct->max_vsize,	/* max vsize */
+			 jobacct->max_vsize_id.taskid,	/* max vsize task */
+			 jobacct->max_vsize_id.nodeid,	/* max vsize node */
+			 ave_vsize,	/* ave vsize */
+			 jobacct->max_rss,	/* max vsize */
+			 jobacct->max_rss_id.taskid,	/* max rss task */
+			 jobacct->max_rss_id.nodeid,	/* max rss node */
+			 ave_rss,	/* ave rss */
+			 jobacct->max_pages,	/* max pages */
+			 jobacct->max_pages_id.taskid,	/* max pages task */
+			 jobacct->max_pages_id.nodeid,	/* max pages node */
+			 ave_pages,	/* ave pages */
+			 ave_cpu2,	/* min cpu */
+			 jobacct->min_cpu_id.taskid,	/* min cpu task */
+			 jobacct->min_cpu_id.nodeid,	/* min cpu node */
+			 ave_cpu,	/* ave cpu */
+			 step_ptr->job_ptr->db_index, step_ptr->step_id);
+		rc = mysql_db_query(jobacct_mysql_db, jobacct_db_init, query);
+		if(rc != SLURM_ERROR) {
+			snprintf(query, sizeof(query),
+				 "update %s set id=%u, stepid=%u, "
+				 "cpu_sec=%ld, cpu_usec=%ld, "
+				 "user_sec=%ld, user_usec=%ld, "
+				 "sys_sec=%ld, sys_usec=%ld, "
+				 "max_rss=%ld, max_ixrss=%ld, max_idrss=%ld, "
+				 "max_isrss=%ld, max_minflt=%ld, "
+				 "max_majflt=%ld, max_nswap=%ld, "
+				 "inblock=%ld, outblock=%ld, msgsnd=%ld, "
+				 "msgrcv=%ld, nsignals=%ld, "
+				 "nvcsw=%ld, nivcsw=%ld "
+				 "where id=%u and stepid=%u",
+				 rusage_table, step_ptr->job_ptr->db_index,
+				 step_ptr->step_id,
+				 /* total cputime seconds */
+				 jobacct->rusage.ru_utime.tv_sec	
+				 + jobacct->rusage.ru_stime.tv_sec,
+				 /* total cputime seconds */
+				 jobacct->rusage.ru_utime.tv_usec	
+				 + jobacct->rusage.ru_stime.tv_usec,
+				 /* user seconds */
+				 jobacct->rusage.ru_utime.tv_sec,	
+				 /* user microseconds */
+				 jobacct->rusage.ru_utime.tv_usec,
+				 /* system seconds */
+				 jobacct->rusage.ru_stime.tv_sec,
+				 /* system microsecs */
+				 jobacct->rusage.ru_stime.tv_usec,
+				 /* max rss */
+				 jobacct->rusage.ru_maxrss,
+				 /* max ixrss */
+				 jobacct->rusage.ru_ixrss,
+				 /* max idrss */
+				 jobacct->rusage.ru_idrss,	
+				 /* max isrss */
+				 jobacct->rusage.ru_isrss,
+				 /* max minflt */
+				 jobacct->rusage.ru_minflt,
+				 /* max majflt */
+				 jobacct->rusage.ru_majflt,
+				 /* max nswap */
+				 jobacct->rusage.ru_nswap,
+				 /* total inblock */
+				 jobacct->rusage.ru_inblock,
+				 /* total outblock */
+				 jobacct->rusage.ru_oublock,
+				 /* total msgsnd */
+				 jobacct->rusage.ru_msgsnd,
+				 /* total msgrcv */
+				 jobacct->rusage.ru_msgrcv,
+				 /* total nsignals */
+				 jobacct->rusage.ru_nsignals,
+				 /* total nvcsw */
+				 jobacct->rusage.ru_nvcsw,
+				 /* total nivcsw */
+				 jobacct->rusage.ru_nivcsw,
+				 step_ptr->job_ptr->db_index,
+				 step_ptr->step_id);
+			
+			rc = mysql_db_query(jobacct_mysql_db, jobacct_db_init,
+					    query);
+		}
+	} else
+		rc = SLURM_ERROR;
+		 
+	return rc;
+}
+
+extern int mysql_jobacct_suspend(struct job_record *job_ptr)
+{
+	char query[1024];
+	int rc = SLURM_SUCCESS;
+	
+	if(!jobacct_mysql_db) {
+		char *loc = slurm_get_jobacct_loc();
+		if(mysql_jobacct_init(loc) == SLURM_ERROR) {
+			xfree(loc);
+			return SLURM_ERROR;
+		}
+		xfree(loc);
+	}
+	
+	if(job_ptr->db_index) {
+		snprintf(query, sizeof(query),
+			 "update %s set suspended=%u-suspended, state=%d "
+			 "where id=%u",
+			 job_table, (int)job_ptr->suspend_time, 
+			 job_ptr->job_state & (~JOB_COMPLETING),
+			 job_ptr->db_index);
+		rc = mysql_db_query(jobacct_mysql_db, jobacct_db_init, query);
+		if(rc != SLURM_ERROR) {
+			snprintf(query, sizeof(query),
+				 "update %s set suspended=%u-suspended, "
+				 "state=%d where id=%u and end=0",
+				 step_table, (int)job_ptr->suspend_time, 
+				 job_ptr->job_state, job_ptr->db_index);
+			rc = mysql_db_query(jobacct_mysql_db, jobacct_db_init,
+					    query);			
+		}
+	} else
+		rc = SLURM_ERROR;
+	
+	return rc;
+}
+
+/* 
+ * get info from the database 
+ * returns List of job_rec_t *
+ * note List needs to be freed when called
+ */
+extern void mysql_jobacct_get_jobs(List job_list,
+				   List selected_steps, List selected_parts,
+				   void *params)
+{
+	if(!jobacct_mysql_db) {
+		char *loc = slurm_get_jobacct_loc();
+		if(mysql_jobacct_init(loc) == SLURM_ERROR) {
+			xfree(loc);
+			return;
+		}
+		xfree(loc);
+	}
+	mysql_jobacct_process_get_jobs(job_list,
+				       selected_steps, selected_parts,
+				       params);	
+	return;
+}
+
+/* 
+ * expire old info from the database 
+ */
+extern void mysql_jobacct_archive(List selected_parts, void *params)
+{
+	if(!jobacct_mysql_db) {
+		char *loc = slurm_get_jobacct_loc();
+		if(mysql_jobacct_init(loc) == SLURM_ERROR) {
+			xfree(loc);
+			return;
+		}
+		xfree(loc);
+	}
+	mysql_jobacct_process_archive(selected_parts, params);
+	return;
+}
+#endif
diff --git a/src/plugins/database/mysql/mysql_jobacct.h b/src/plugins/database/mysql/mysql_jobacct.h
new file mode 100644
index 0000000000000000000000000000000000000000..9d152ca346535f38dd369bed56aab260130df74c
--- /dev/null
+++ b/src/plugins/database/mysql/mysql_jobacct.h
@@ -0,0 +1,63 @@
+/*****************************************************************************\
+ *  mysql_jobacct.h - functions the mysql jobacct database.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+
+#ifndef _HAVE_MYSQL_JOBACCT_H
+#define _HAVE_MYSQL_JOBACCT_H
+
+#include "src/plugins/jobacct/common/jobacct_common.h"
+#include "src/slurmctld/slurmctld.h"
+#ifdef HAVE_MYSQL
+#include <mysql/mysql.h>
+#include <mysql/mysqld_error.h>
+
+extern int mysql_jobacct_init(char *location);
+extern int mysql_jobacct_fini();
+extern int mysql_jobacct_job_start(struct job_record *job_ptr);
+extern int mysql_jobacct_job_complete(struct job_record *job_ptr);
+extern int mysql_jobacct_step_start(struct step_record *step_ptr);
+extern int mysql_jobacct_step_complete(struct step_record *step_ptr);
+extern int mysql_jobacct_suspend(struct job_record *job_ptr);
+extern void mysql_jobacct_get_jobs(List job_list,
+				   List selected_steps, List selected_parts,
+				   void *params);
+extern void mysql_jobacct_archive(List selected_parts, void *params);
+#endif
+
+#endif
diff --git a/src/plugins/database/mysql/mysql_jobacct_process.c b/src/plugins/database/mysql/mysql_jobacct_process.c
new file mode 100644
index 0000000000000000000000000000000000000000..705936a721904b0678b9e4ad43be7aa9a2b95c38
--- /dev/null
+++ b/src/plugins/database/mysql/mysql_jobacct_process.c
@@ -0,0 +1,481 @@
+/*****************************************************************************\
+ *  mysql_jobacct_process.c - functions the processing of
+ *                               information from the mysql jobacct
+ *                               database.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+
+#include <stdlib.h>
+#include "src/common/slurm_jobacct.h"
+#include "src/common/xstring.h"
+#include "mysql_jobacct_process.h"
+
+#ifdef HAVE_MYSQL
+static void _do_fdump(List job_list)
+{
+	info("fdump option not applicable from mysql plugin");
+	return;
+}
+
+extern void mysql_jobacct_process_get_jobs(List job_list,
+					   List selected_steps,
+					   List selected_parts,
+					   sacct_parameters_t *params)
+{
+
+	char *query = NULL;	
+	char *extra = NULL;	
+	char *tmp = NULL;	
+	char *selected_part = NULL;
+	jobacct_selected_step_t *selected_step = NULL;
+	ListIterator itr = NULL;
+	int set = 0;
+	MYSQL_RES *result = NULL, *step_result = NULL;
+	MYSQL_ROW row, step_row;
+	int i;
+	jobacct_job_rec_t *job = NULL;
+	jobacct_step_rec_t *step = NULL;
+	jobacct_header_t header;
+	time_t now = time(NULL);
+
+	/* if this changes you will need to edit the corresponding 
+	 * enum below also t1 is job_index and t2 is job_table */
+	char *job_req_inx[] = {
+		"t1.id",
+		"t1.jobid",
+		"t1.partition",
+		"t1.submit",
+		"t2.start",
+		"t2.end",
+		"t2.suspended",
+		"t1.uid",
+		"t1.gid",
+		"t1.blockid",
+		"t2.name",
+		"t2.track_steps",
+		"t2.state",
+		"t2.priority",
+		"t2.cpus",
+		"t2.nodelist",
+		"t2.account",
+		"t2.kill_requid"
+	};
+
+	/* if this changes you will need to edit the corresponding 
+	 * enum below also t1 is step_table and t2 is step_rusage */
+	char *step_req_inx[] = {
+		"t1.stepid",
+		"t1.start",
+		"t1.end",
+		"t1.suspended",
+		"t1.name",
+		"t1.nodelist",
+		"t1.state",
+		"t1.kill_requid",
+		"t1.comp_code",
+		"t1.cpus",
+		"t1.max_vsize",
+		"t1.max_vsize_task",
+		"t1.max_vsize_node",
+		"t1.ave_vsize",
+		"t1.max_rss",
+		"t1.max_rss_task",
+		"t1.max_rss_node",
+		"t1.ave_rss",
+		"t1.max_pages",
+		"t1.max_pages_task",
+		"t1.max_pages_node",
+		"t1.ave_pages",
+		"t1.min_cpu",
+		"t1.min_cpu_task",
+		"t1.min_cpu_node",
+		"t1.ave_cpu",
+		"t2.cpu_sec",
+		"t2.cpu_usec",
+		"t2.user_sec",
+		"t2.user_usec",
+		"t2.sys_sec",
+		"t2.sys_usec",
+		"t2.max_rss",
+		"t2.max_ixrss",
+		"t2.max_idrss",
+		"t2.max_isrss",
+		"t2.max_minflt",
+		"t2.max_majflt",
+		"t2.max_nswap",
+		"t2.inblock",
+		"t2.outblock",
+		"t2.msgsnd",
+		"t2.msgrcv",
+		"t2.nsignals",
+		"t2.nvcsw",
+		"t2.nivcsw"
+	};
+	enum {
+		JOB_REQ_ID,
+		JOB_REQ_JOBID,
+		JOB_REQ_PARTITION,
+		JOB_REQ_SUBMIT,
+		JOB_REQ_START,
+		JOB_REQ_END,
+		JOB_REQ_SUSPENDED,
+		JOB_REQ_UID,
+		JOB_REQ_GID,
+		JOB_REQ_BLOCKID,
+		JOB_REQ_NAME,
+		JOB_REQ_TRACKSTEPS,
+		JOB_REQ_STATE,
+		JOB_REQ_PRIORITY,
+		JOB_REQ_CPUS,
+		JOB_REQ_NODELIST,
+		JOB_REQ_ACCOUNT,
+		JOB_REQ_KILL_REQUID,
+		JOB_REQ_COUNT		
+	};
+	enum {
+		STEP_REQ_STEPID,
+		STEP_REQ_START,
+		STEP_REQ_END,
+		STEP_REQ_SUSPENDED,
+		STEP_REQ_NAME,
+		STEP_REQ_NODELIST,
+		STEP_REQ_STATE,
+		STEP_REQ_KILL_REQUID,
+		STEP_REQ_COMP_CODE,
+		STEP_REQ_CPUS,
+		STEP_REQ_MAX_VSIZE,
+		STEP_REQ_MAX_VSIZE_TASK,
+		STEP_REQ_MAX_VSIZE_NODE,
+		STEP_REQ_AVE_VSIZE,
+		STEP_REQ_MAX_RSS,
+		STEP_REQ_MAX_RSS_TASK,
+		STEP_REQ_MAX_RSS_NODE,
+		STEP_REQ_AVE_RSS,
+		STEP_REQ_MAX_PAGES,
+		STEP_REQ_MAX_PAGES_TASK,
+		STEP_REQ_MAX_PAGES_NODE,
+		STEP_REQ_AVE_PAGES,
+		STEP_REQ_MIN_CPU,
+		STEP_REQ_MIN_CPU_TASK,
+		STEP_REQ_MIN_CPU_NODE,
+		STEP_REQ_AVE_CPU,
+		STEP_REQ_CPU_SEC,
+		STEP_REQ_CPU_USEC,
+		STEP_REQ_USER_SEC,
+		STEP_REQ_USER_USEC,
+		STEP_REQ_SYS_SEC,
+		STEP_REQ_SYS_USEC,
+		STEP_REQ_RSS,
+		STEP_REQ_IXRSS,
+		STEP_REQ_IDRSS,
+		STEP_REQ_ISRSS,
+		STEP_REQ_MINFLT,
+		STEP_REQ_MAJFLT,
+		STEP_REQ_NSWAP,
+		STEP_REQ_INBLOCKS,
+		STEP_REQ_OUTBLOCKS,
+		STEP_REQ_MSGSND,
+		STEP_REQ_MSGRCV,
+		STEP_REQ_NSIGNALS,
+		STEP_REQ_NVCSW,
+		STEP_REQ_NIVCSW,
+		STEP_REQ_COUNT
+	};
+
+	if(selected_steps && list_count(selected_steps)) {
+		set = 0;
+		xstrcat(extra, " && (");
+		itr = list_iterator_create(selected_steps);
+		while((selected_step = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			tmp = xstrdup_printf("t1.jobid=%d",
+					      selected_step->jobid);
+			xstrcat(extra, tmp);
+			set = 1;
+			xfree(tmp);
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+
+	if(selected_parts && list_count(selected_parts)) {
+		set = 0;
+		xstrcat(extra, " && (");
+		itr = list_iterator_create(selected_parts);
+		while((selected_part = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			tmp = xstrdup_printf("t1.partition='%s'",
+					      selected_part);
+			xstrcat(extra, tmp);
+			set = 1;
+			xfree(tmp);
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+	
+	for(i=0; i<JOB_REQ_COUNT; i++) {
+		if(i) 
+			xstrcat(tmp, ", ");
+		xstrcat(tmp, job_req_inx[i]);
+	}
+	
+	query = xstrdup_printf("select %s from %s t1, %s t2 where t1.id=t2.id",
+			       tmp, job_index, job_table);
+	xfree(tmp);
+
+	if(extra) {
+		xstrcat(query, extra);
+		xfree(extra);
+	}
+
+	//info("query = %s", query);
+	if(!(result =
+	     mysql_db_query_ret(jobacct_mysql_db, jobacct_db_init, query))) {
+		xfree(query);
+		return;
+	}
+	xfree(query);
+
+	while((row = mysql_fetch_row(result))) {
+		time_t job_suspended = atoi(row[JOB_REQ_SUSPENDED]);
+		char *id = row[JOB_REQ_ID];
+		header.jobnum = atoi(row[JOB_REQ_JOBID]);
+		header.partition = xstrdup(row[JOB_REQ_PARTITION]);
+		header.job_submit = atoi(row[JOB_REQ_SUBMIT]);
+		header.timestamp = atoi(row[JOB_REQ_START]);
+		header.uid = atoi(row[JOB_REQ_UID]);
+		header.gid = atoi(row[JOB_REQ_GID]);
+		header.blockid = xstrdup(row[JOB_REQ_BLOCKID]);
+
+		job = jobacct_init_job_rec(header);
+		job->show_full = 1;
+		job->status = atoi(row[JOB_REQ_STATE]);
+		job->jobname = xstrdup(row[JOB_REQ_NAME]);
+		job->track_steps = atoi(row[JOB_REQ_TRACKSTEPS]);
+		job->priority = atoi(row[JOB_REQ_PRIORITY]);
+		job->ncpus = atoi(row[JOB_REQ_CPUS]);
+		job->end = atoi(row[JOB_REQ_END]);
+		job->nodes = xstrdup(row[JOB_REQ_NODELIST]);
+		if (!strcmp(job->nodes, "(null)")) {
+			xfree(job->nodes);
+			job->nodes = xstrdup("(unknown)");
+		}
+		job->account = xstrdup(row[JOB_REQ_ACCOUNT]);
+		list_append(job_list, job);
+
+		if(selected_steps && list_count(selected_steps)) {
+			set = 0;
+			itr = list_iterator_create(selected_steps);
+			while((selected_step = list_next(itr))) {
+				if(selected_step->jobid != header.jobnum) {
+					continue;
+				} else if (selected_step->stepid
+					   == (uint32_t)NO_VAL) {
+					job->show_full = 1;
+					break;
+				}
+				
+				if(set) 
+					xstrcat(extra, " || ");
+				else 
+					xstrcat(extra, " && (");
+			
+				tmp = xstrdup_printf("t1.stepid=%d",
+						     selected_step->stepid);
+				xstrcat(extra, tmp);
+				set = 1;
+				xfree(tmp);
+				job->show_full = 0;
+			}
+			list_iterator_destroy(itr);
+			if(set)
+				xstrcat(extra, ")");
+		}
+		for(i=0; i<STEP_REQ_COUNT; i++) {
+			if(i) 
+				xstrcat(tmp, ", ");
+			xstrcat(tmp, step_req_inx[i]);
+		}
+		
+		query =	xstrdup_printf("select %s from %s t1, "
+				       "%s t2 where t1.id=t2.id "
+				       "&& t1.stepid=t2.stepid "
+				       "&& t1.id=%s",
+				       tmp, step_table, rusage_table, id);
+		xfree(tmp);
+		
+		if(extra) {
+			xstrcat(query, extra);
+			xfree(extra);
+		}
+		
+		//info("query = %s", query);
+		if(!(step_result = mysql_db_query_ret(
+			     jobacct_mysql_db, jobacct_db_init, query))) {
+			xfree(query);
+			return;
+		}
+		xfree(query);
+		while ((step_row = mysql_fetch_row(step_result))) {
+			time_t suspended = 0;
+			/* we need to do this here for all the memory
+			   locations so we get new memory that will be
+			   freed later.
+			*/
+			header.partition = xstrdup(row[JOB_REQ_PARTITION]);
+			header.blockid = xstrdup(row[JOB_REQ_BLOCKID]);
+			header.timestamp = atoi(step_row[STEP_REQ_START]);
+			/* set start of job if not set */
+			if(job->header.timestamp < header.timestamp) {
+				job->header.timestamp = header.timestamp;
+			}
+			step = jobacct_init_step_rec(header);
+			list_append(job->steps, step);
+			step->stepnum = atoi(step_row[STEP_REQ_STEPID]);
+			/* info("got step %u.%u", */
+/* 			     job->header.jobnum, step->stepnum); */
+			step->status = atoi(step_row[STEP_REQ_STATE]);
+			step->exitcode = atoi(step_row[STEP_REQ_COMP_CODE]);
+			step->ntasks = atoi(step_row[STEP_REQ_CPUS]);
+			step->ncpus = atoi(step_row[STEP_REQ_CPUS]);
+			step->end = atoi(step_row[STEP_REQ_END]);
+			/* figure this out by start stop */
+			suspended = atoi(step_row[STEP_REQ_SUSPENDED]);
+			if(!step->end) {
+				step->elapsed = now - step->header.timestamp;
+			} else {
+				step->elapsed =
+					step->end - step->header.timestamp;
+			}
+			step->elapsed -= suspended;
+			step->tot_cpu_sec = atoi(step_row[STEP_REQ_CPU_SEC]);
+			step->tot_cpu_usec = atoi(step_row[STEP_REQ_CPU_USEC]);
+			step->rusage.ru_utime.tv_sec = 
+				atoi(step_row[STEP_REQ_USER_SEC]);
+			step->rusage.ru_utime.tv_usec =
+				atoi(step_row[STEP_REQ_USER_USEC]);
+			step->rusage.ru_stime.tv_sec =
+				atoi(step_row[STEP_REQ_SYS_SEC]);
+			step->rusage.ru_stime.tv_usec =
+				atoi(step_row[STEP_REQ_SYS_USEC]);
+			step->rusage.ru_maxrss = atoi(step_row[STEP_REQ_RSS]);
+			step->rusage.ru_ixrss = atoi(step_row[STEP_REQ_IXRSS]);
+			step->rusage.ru_idrss = atoi(step_row[STEP_REQ_IDRSS]);
+			step->rusage.ru_isrss = atoi(step_row[STEP_REQ_ISRSS]);
+			step->rusage.ru_minflt =
+				atoi(step_row[STEP_REQ_MINFLT]);
+			step->rusage.ru_majflt =
+				atoi(step_row[STEP_REQ_MAJFLT]);
+			step->rusage.ru_nswap =
+				atoi(step_row[STEP_REQ_NSWAP]);
+			step->rusage.ru_inblock =
+				atoi(step_row[STEP_REQ_INBLOCKS]);
+			step->rusage.ru_oublock =
+				atoi(step_row[STEP_REQ_OUTBLOCKS]);
+			step->rusage.ru_msgsnd =
+				atoi(step_row[STEP_REQ_MSGSND]);
+			step->rusage.ru_msgrcv =
+				atoi(step_row[STEP_REQ_MSGRCV]);
+			step->rusage.ru_nsignals =
+				atoi(step_row[STEP_REQ_NSIGNALS]);
+			step->rusage.ru_nvcsw =
+				atoi(step_row[STEP_REQ_NVCSW]);
+			step->rusage.ru_nivcsw =
+				atoi(step_row[STEP_REQ_NIVCSW]);
+			step->sacct.max_vsize =
+				atoi(step_row[STEP_REQ_MAX_VSIZE]) * 1024;
+			step->sacct.max_vsize_id.taskid = 
+				atoi(step_row[STEP_REQ_MAX_VSIZE_TASK]);
+			step->sacct.ave_vsize = 
+				atof(step_row[STEP_REQ_AVE_VSIZE]) * 1024;
+			step->sacct.max_rss =
+				atoi(step_row[STEP_REQ_MAX_RSS]) * 1024;
+			step->sacct.max_rss_id.taskid = 
+				atoi(step_row[STEP_REQ_MAX_RSS_TASK]);
+			step->sacct.ave_rss = 
+				atof(step_row[STEP_REQ_AVE_RSS]) * 1024;
+			step->sacct.max_pages =
+				atoi(step_row[STEP_REQ_MAX_PAGES]);
+			step->sacct.max_pages_id.taskid = 
+				atoi(step_row[STEP_REQ_MAX_PAGES_TASK]);
+			step->sacct.ave_pages =
+				atof(step_row[STEP_REQ_AVE_PAGES]);
+			step->sacct.min_cpu =
+				atof(step_row[STEP_REQ_MIN_CPU]);
+			step->sacct.min_cpu_id.taskid = 
+				atoi(step_row[STEP_REQ_MIN_CPU_TASK]);
+			step->sacct.ave_cpu = atof(step_row[STEP_REQ_AVE_CPU]);
+			step->stepname = xstrdup(step_row[STEP_REQ_NAME]);
+			step->nodes = xstrdup(step_row[STEP_REQ_NODELIST]);
+			step->sacct.max_vsize_id.nodeid = 
+				atoi(step_row[STEP_REQ_MAX_VSIZE_NODE]);
+			step->sacct.max_rss_id.nodeid = 
+				atoi(step_row[STEP_REQ_MAX_RSS_NODE]);
+			step->sacct.max_pages_id.nodeid = 
+				atoi(step_row[STEP_REQ_MAX_PAGES_NODE]);
+			step->sacct.min_cpu_id.nodeid = 
+				atoi(step_row[STEP_REQ_MIN_CPU_NODE]);
+	
+			step->requid = atoi(step_row[STEP_REQ_KILL_REQUID]);
+		}
+		mysql_free_result(step_result);
+
+		if(!job->end) {
+			job->elapsed = now - job->header.timestamp;
+		} else {
+			job->elapsed = job->end - job->header.timestamp;
+		}
+		job->elapsed -= job_suspended;
+	}
+	mysql_free_result(result);
+	if (params->opt_fdump) {
+		_do_fdump(job_list);
+	}
+	return;
+}
+
+extern void mysql_jobacct_process_archive(List selected_parts,
+					  sacct_parameters_t *params)
+{
+	return;
+}
+
+#endif	
diff --git a/src/plugins/database/mysql/mysql_jobacct_process.h b/src/plugins/database/mysql/mysql_jobacct_process.h
new file mode 100644
index 0000000000000000000000000000000000000000..e2ec67d8313adae90da1dd4c46e1f1567a92119e
--- /dev/null
+++ b/src/plugins/database/mysql/mysql_jobacct_process.h
@@ -0,0 +1,68 @@
+/*****************************************************************************\
+ *  mysql_jobacct_process.h - functions the processing of
+ *                               information from the mysql jobacct
+ *                               database.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+
+#ifndef _HAVE_MYSQL_JOBACCT_PROCESS_H
+#define _HAVE_MYSQL_JOBACCT_PROCESS_H
+
+#include "mysql_common.h"
+#include "mysql_jobacct.h"
+#include "src/common/slurm_jobacct.h"
+
+#ifdef HAVE_MYSQL
+extern MYSQL *jobacct_mysql_db;
+extern int jobacct_db_init;
+
+extern char *job_index;
+extern char *job_table;
+extern char *step_table;
+extern char *rusage_table;
+
+extern void mysql_jobacct_process_get_jobs(List job_list,
+					   List selected_steps,
+					   List selected_parts,
+					   sacct_parameters_t *params);
+
+extern void mysql_jobacct_process_archive(List selected_parts,
+					  sacct_parameters_t *params);
+#endif
+
+#endif
diff --git a/src/plugins/database/mysql/mysql_jobcomp.c b/src/plugins/database/mysql/mysql_jobcomp.c
new file mode 100644
index 0000000000000000000000000000000000000000..a3e2a47dde0ff05b65b2637ebd00e0df16237843
--- /dev/null
+++ b/src/plugins/database/mysql/mysql_jobcomp.c
@@ -0,0 +1,331 @@
+/*****************************************************************************\
+ *  mysql_jobcomp.c - text file slurm job completion logging plugin.
+ *****************************************************************************
+ *  Copyright (C) 2003 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Morris Jette <jette1@llnl.gov> et. al.
+ *  UCRL-CODE-226842.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#if HAVE_CONFIG_H
+#   include "config.h"
+#endif
+
+#if HAVE_STDINT_H
+#  include <stdint.h>
+#endif
+#if HAVE_INTTYPES_H
+#  include <inttypes.h>
+#endif
+
+#include "mysql_common.h"
+#include "mysql_jobcomp_process.h"
+#include <pwd.h>
+#include <sys/types.h>
+#include "src/common/parse_time.h"
+
+#ifdef HAVE_MYSQL
+
+#define DEFAULT_JOBCOMP_DB "slurm_jobcomp_db"
+
+MYSQL *jobcomp_mysql_db = NULL;
+int jobcomp_db_init = 0;
+
+char *jobcomp_table = "jobcomp_table";
+database_field_t jobcomp_table_fields[] = {
+	{ "jobid", "int not null" },
+	{ "uid", "smallint unsigned not null" },
+	{ "user_name", "tinytext not null" },
+	{ "gid", "smallint unsigned not null" },
+	{ "group_name", "tinytext not null" },
+	{ "name", "tinytext not null" },
+	{ "state", "smallint not null" },
+	{ "partition", "tinytext not null" }, 
+	{ "timelimit", "tinytext not null" },
+	{ "starttime", "int unsigned default 0" }, 
+	{ "endtime", "int unsigned default 0" },
+	{ "nodelist", "text" }, 
+	{ "nodecnt", "mediumint unsigned not null" },
+	{ "connection", "tinytext" },
+	{ "reboot", "tinytext" },
+	{ "rotate", "tinytext" },
+	{ "maxprocs", "mediumint unsigned default 0" },
+	{ "geometry", "tinytext" },
+	{ "start", "tinytext" },
+	{ "blockid", "tinytext" },
+	{ NULL, NULL}
+};
+
+
+/* Type for error string table entries */
+typedef struct {
+	int xe_number;
+	char *xe_message;
+} slurm_errtab_t;
+
+static slurm_errtab_t slurm_errtab[] = {
+	{0, "No error"},
+	{-1, "Unspecified error"}
+};
+
+/* A plugin-global errno. */
+static int plugin_errno = SLURM_SUCCESS;
+
+/* File descriptor used for logging */
+static pthread_mutex_t  jobcomp_lock = PTHREAD_MUTEX_INITIALIZER;
+
+
+static int _mysql_jobcomp_check_tables()
+{
+	if(mysql_db_create_table(jobcomp_mysql_db, jobcomp_db_init, 
+				 jobcomp_table, jobcomp_table_fields,
+				 ")") == SLURM_ERROR)
+		return SLURM_ERROR;
+
+	return SLURM_SUCCESS;
+}
+
+
+/* get the user name for the give user_id */
+static char *_get_user_name(uint32_t user_id)
+{
+	static uint32_t cache_uid      = 0;
+	static char     cache_name[32] = "root";
+	struct passwd * user_info      = NULL;
+	char *ret_name = NULL;
+
+	slurm_mutex_lock(&jobcomp_lock);
+	if (user_id != cache_uid) {
+		user_info = getpwuid((uid_t) user_id);
+		if (user_info && user_info->pw_name[0])
+			snprintf(cache_name, sizeof(cache_name), "%s", 
+				user_info->pw_name);
+		else
+			snprintf(cache_name, sizeof(cache_name), "Unknown");
+		cache_uid = user_id;
+	}
+	ret_name = xstrdup(cache_name);
+	slurm_mutex_unlock(&jobcomp_lock);
+
+	return ret_name;
+}
+
+/* 
+ * Linear search through table of errno values and strings,
+ * returns NULL on error, string on success.
+ */
+static char *_lookup_slurm_api_errtab(int errnum)
+{
+	char *res = NULL;
+	int i;
+
+	for (i = 0; i < sizeof(slurm_errtab) / sizeof(slurm_errtab_t); i++) {
+		if (slurm_errtab[i].xe_number == errnum) {
+			res = slurm_errtab[i].xe_message;
+			break;
+		}
+	}
+	return res;
+}
+
+extern int mysql_jobcomp_init(char *location)
+{
+	mysql_db_info_t *db_info = create_mysql_db_info();
+	int rc = SLURM_SUCCESS;
+	char *db_name = NULL;
+	int i = 0;
+	
+	if(jobcomp_db_init) 
+		return SLURM_ERROR;
+	
+	if(!location)
+		db_name = DEFAULT_JOBCOMP_DB;
+	else {
+		while(location[i]) {
+			if(location[i] == '.' || location[i] == '/') {
+				debug("%s doesn't look like a database "
+				      "name using %s",
+				      location, DEFAULT_JOBCOMP_DB);
+				break;
+			}
+			i++;
+		}
+		if(location[i]) 
+			db_name = DEFAULT_JOBCOMP_DB;
+		else
+			db_name = location;
+	}
+		
+	debug2("mysql_connect() called for db %s", db_name);
+	
+	mysql_get_db_connection(&jobcomp_mysql_db, db_name, db_info,
+				&jobcomp_db_init);
+	
+	rc = _mysql_jobcomp_check_tables();
+
+	destroy_mysql_db_info(db_info);
+
+	if(rc == SLURM_SUCCESS) 
+		debug("Jobcomp database init finished");
+	else
+		debug("Jobcomp database init failed");
+	return rc;
+}
+
+extern int mysql_jobcomp_fini()
+{
+	if (jobcomp_mysql_db) {
+		mysql_close(jobcomp_mysql_db);
+		jobcomp_mysql_db = NULL;
+	}
+	jobcomp_db_init = 0;
+	return SLURM_SUCCESS;
+}
+
+extern int mysql_jobcomp_get_errno()
+{
+	return plugin_errno;
+}
+
+extern int mysql_jobcomp_log_record(struct job_record *job_ptr)
+{
+	int rc = SLURM_SUCCESS;
+	char *usr_str = NULL, lim_str[32];
+#ifdef HAVE_BG
+	char connection[128];
+	char reboot[4];
+	char rotate[4];
+	char maxprocs[20];
+	char geometry[20];
+	char start[20];
+	char blockid[128];
+#endif
+	enum job_states job_state;
+	char query[1024];
+
+	if(!jobcomp_mysql_db) {
+		char *loc = slurm_get_jobcomp_loc();
+		if(mysql_jobcomp_init(loc) == SLURM_ERROR) {
+			xfree(loc);
+			return SLURM_ERROR;
+		}
+		xfree(loc);
+	}
+
+	usr_str = _get_user_name(job_ptr->user_id);
+	if (job_ptr->time_limit == INFINITE)
+		strcpy(lim_str, "UNLIMITED");
+	else
+		snprintf(lim_str, sizeof(lim_str), "%lu", 
+				(unsigned long) job_ptr->time_limit);
+
+	/* Job will typically be COMPLETING when this is called. 
+	 * We remove this flag to get the eventual completion state:
+	 * JOB_FAILED, JOB_TIMEOUT, etc. */
+	job_state = job_ptr->job_state & (~JOB_COMPLETING);
+
+#ifdef HAVE_BG
+	select_g_sprint_jobinfo(job_ptr->select_jobinfo,
+		connection, sizeof(connection), SELECT_PRINT_CONNECTION);
+	select_g_sprint_jobinfo(job_ptr->select_jobinfo,
+		reboot, sizeof(reboot), SELECT_PRINT_REBOOT);
+	select_g_sprint_jobinfo(job_ptr->select_jobinfo,
+		rotate, sizeof(rotate), SELECT_PRINT_ROTATE);
+	select_g_sprint_jobinfo(job_ptr->select_jobinfo,
+		maxprocs, sizeof(maxprocs), SELECT_PRINT_MAX_PROCS);
+	select_g_sprint_jobinfo(job_ptr->select_jobinfo,
+		geometry, sizeof(geometry), SELECT_PRINT_GEOMETRY);
+	select_g_sprint_jobinfo(job_ptr->select_jobinfo,
+		start, sizeof(start), SELECT_PRINT_START);
+	select_g_sprint_jobinfo(job_ptr->select_jobinfo,
+		blockid, sizeof(blockid), SELECT_PRINT_BG_ID);
+#endif
+	snprintf(query, sizeof(query),
+		 "insert into %s (jobid, uid, user_name, name, state, "
+		 "partition, timelimit, starttime, endtime, nodelist, nodecnt"
+#ifdef HAVE_BG
+		 ", connection, reboot, rotate, maxprocs, geometry, "
+		 "start, blockid"
+#endif
+		 ") values (%u, %u, '%s', '%s', %d, '%s', '%s', %u, %u, "
+		 "'%s', %u"
+#ifdef HAVE_BG
+		 ", '%s', '%s', '%s', %s, '%s', '%s', '%s'"
+#endif
+		 ")",
+		 jobcomp_table, job_ptr->job_id, job_ptr->user_id, usr_str,
+		 job_ptr->name, job_state, job_ptr->partition, lim_str,
+		 (int)job_ptr->start_time, (int)job_ptr->end_time,
+		 job_ptr->nodes, job_ptr->node_cnt
+#ifdef HAVE_BG
+		 , connection, reboot, rotate, maxprocs, geometry,
+		 start, blockid
+#endif
+		 );
+	info("query = %s", query);
+	rc = mysql_db_query(jobcomp_mysql_db, jobcomp_db_init, query);
+	xfree(usr_str);
+
+	return rc;
+}
+
+extern char *mysql_jobcomp_strerror( int errnum )
+{
+	char *res = _lookup_slurm_api_errtab(errnum);
+	return (res ? res : strerror(errnum));
+}
+
+/* 
+ * get info from the database 
+ * in/out job_list List of job_rec_t *
+ * note List needs to be freed when called
+ */
+extern void mysql_jobcomp_get_jobs(List job_list, 
+				   List selected_steps, List selected_parts,
+				   void *params)
+{
+	mysql_jobcomp_process_get_jobs(job_list, 
+				       selected_steps, selected_parts,
+				       params);	
+	return;
+}
+
+/* 
+ * expire old info from the database 
+ */
+extern void mysql_jobcomp_archive(List selected_parts,
+				     void *params)
+{
+	mysql_jobcomp_process_archive(selected_parts, params);
+	return;
+}
+
+#endif
diff --git a/src/sacct/sacct_stat.h b/src/plugins/database/mysql/mysql_jobcomp.h
similarity index 70%
rename from src/sacct/sacct_stat.h
rename to src/plugins/database/mysql/mysql_jobcomp.h
index af3d6794fef13d9cedd9ecc235b6c1d31b0abf8b..730b897a614ee80ee57926634de1780a5fcaa36f 100644
--- a/src/sacct/sacct_stat.h
+++ b/src/plugins/database/mysql/mysql_jobcomp.h
@@ -1,11 +1,9 @@
 /*****************************************************************************\
- *  sacct_stat.h - header file for sacct
- *
- *  $Id: sacct.h 7541 2006-03-18 01:44:58Z da $
+ *  mysql_jobcomp.h - mysql database slurm job completion logging plugin.
  *****************************************************************************
- *  Copyright (C) 2006 The Regents of the University of California.
+ *  Copyright (C) 2003 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Danny Auble <da@llnl.gov>.
+ *  Written by Morris Jette <jette1@llnl.gov> et. al.
  *  UCRL-CODE-226842.
  *  
  *  This file is part of SLURM, a resource management program.
@@ -17,7 +15,7 @@
  *  any later version.
  *
  *  In addition, as a special exception, the copyright holders give permission 
- *  to link the code of portions of this program with the OpenSSL library under 
+ *  to link the code of portions of this program with the OpenSSL library under
  *  certain conditions as described in each individual source file, and 
  *  distribute linked combinations including the two. You must obey the GNU 
  *  General Public License in all respects for all of the code used other than 
@@ -36,31 +34,21 @@
  *  with SLURM; if not, write to the Free Software Foundation, Inc.,
  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
 \*****************************************************************************/
-#ifndef _SACCT_STAT_H
-#define _SACCT_STAT_H
-
-#include "src/common/slurm_protocol_api.h"
 
-typedef struct {
-	uint16_t taskid; /* contains which task number it was on */
-	uint32_t nodeid; /* contains which node number it was on */	
-} jobacct_id_t;
+#ifndef _MYSQL_JOBCOMP_H_
+#define _MYSQL_JOBCOMP_H_
 
-typedef struct sacct_struct {
-	uint32_t max_vsize; 
-	jobacct_id_t max_vsize_id;
-	float ave_vsize;
-	uint32_t max_rss;
-	jobacct_id_t max_rss_id;
-	float ave_rss;
-	uint32_t max_pages;
-	jobacct_id_t max_pages_id;
-	float ave_pages;
-	float min_cpu;
-	jobacct_id_t min_cpu_id;
-	float ave_cpu;	
-} sacct_t;
+#include "src/slurmctld/slurmctld.h"
 
-extern int sacct_stat(uint32_t jobid, uint32_t stepid);
+extern int mysql_jobcomp_init(char *location);
+extern int mysql_jobcomp_fini();
+extern int mysql_jobcomp_get_errno();
+extern int mysql_jobcomp_log_record(struct job_record *job_ptr);
+extern char *mysql_jobcomp_strerror(int errnum);
+extern void mysql_jobcomp_get_jobs(List job_list, 
+				   List selected_steps,
+				   List selected_parts,
+				   void *params);
+extern void mysql_jobcomp_archive(List selected_parts, void *params);
 
 #endif
diff --git a/src/plugins/database/mysql/mysql_jobcomp_process.c b/src/plugins/database/mysql/mysql_jobcomp_process.c
new file mode 100644
index 0000000000000000000000000000000000000000..fb9bc83ac301764ac241c512d86bf72f9f287875
--- /dev/null
+++ b/src/plugins/database/mysql/mysql_jobcomp_process.c
@@ -0,0 +1,191 @@
+/*****************************************************************************\
+ *  mysql_jobcomp_process.c - functions the processing of
+ *                               information from the mysql jobcomp
+ *                               database.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+
+#include <stdlib.h>
+#include "src/common/xstring.h"
+#include "mysql_jobcomp_process.h"
+
+#ifdef HAVE_MYSQL
+static void _do_fdump(MYSQL_ROW row, int lc)
+{	
+	int i = 0;
+	printf("\n------- Line %d -------\n", lc);	
+	while(jobcomp_table_fields[i].name) {
+		printf("%12s: %s\n",  jobcomp_table_fields[i].name, row[i]);
+		i++;
+	}
+
+	return;
+}
+
+extern void mysql_jobcomp_process_get_jobs(List job_list,
+					   List selected_steps,
+					   List selected_parts,
+					   sacct_parameters_t *params)
+{
+
+	char *query = NULL;	
+	char *extra = NULL;	
+	char *tmp = NULL;	
+	char *selected_part = NULL;
+	jobacct_selected_step_t *selected_step = NULL;
+	ListIterator itr = NULL;
+	int set = 0;
+	MYSQL_RES *result = NULL;
+	MYSQL_ROW row;
+	int i;
+	int lc = 0;
+	jobcomp_job_rec_t *job = NULL;
+
+	if(selected_steps && list_count(selected_steps)) {
+		set = 0;
+		xstrcat(extra, " where (");
+		itr = list_iterator_create(selected_steps);
+		while((selected_step = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			tmp = xstrdup_printf("jobid=%d",
+					      selected_step->jobid);
+			xstrcat(extra, tmp);
+			set = 1;
+			xfree(tmp);
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+
+	if(selected_parts && list_count(selected_parts)) {
+		set = 0;
+		if(extra)
+			xstrcat(extra, " && (");
+		else
+			xstrcat(extra, " where (");
+		
+		itr = list_iterator_create(selected_parts);
+		while((selected_part = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			tmp = xstrdup_printf("partition='%s'",
+					      selected_part);
+			xstrcat(extra, tmp);
+			set = 1;
+			xfree(tmp);
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+
+	i = 0;
+	while(jobcomp_table_fields[i].name) {
+		if(i) 
+			xstrcat(tmp, ", ");
+		xstrcat(tmp, jobcomp_table_fields[i].name);
+		i++;
+	}
+	
+	query = xstrdup_printf("select %s from %s", tmp, jobcomp_table);
+	xfree(tmp);
+
+	if(extra) {
+		xstrcat(query, extra);
+		xfree(extra);
+	}
+
+	//info("query = %s", query);
+	if(!(result =
+	     mysql_db_query_ret(jobcomp_mysql_db, jobcomp_db_init, query))) {
+		xfree(query);
+		return;
+	}
+	xfree(query);
+
+	while((row = mysql_fetch_row(result))) {
+		lc++;
+
+		if (params->opt_fdump) {
+			_do_fdump(row, lc);
+			continue;
+		}
+		job = xmalloc(sizeof(jobcomp_job_rec_t));
+		if(row[JOBCOMP_REQ_JOBID])
+			job->jobid = atoi(row[JOBCOMP_REQ_JOBID]);
+		job->partition = xstrdup(row[JOBCOMP_REQ_PARTITION]);
+		job->start_time = xstrdup(row[JOBCOMP_REQ_STARTTIME]);
+		job->end_time = xstrdup(row[JOBCOMP_REQ_ENDTIME]);
+		if(row[JOBCOMP_REQ_UID])
+			job->uid = atoi(row[JOBCOMP_REQ_UID]);
+		job->uid_name = xstrdup(row[JOBCOMP_REQ_USER_NAME]);
+		if(row[JOBCOMP_REQ_GID])
+			job->gid = atoi(row[JOBCOMP_REQ_GID]);
+		job->gid_name = xstrdup(row[JOBCOMP_REQ_GROUP_NAME]);
+		job->blockid = xstrdup(row[JOBCOMP_REQ_BLOCKID]);
+		job->jobname = xstrdup(row[JOBCOMP_REQ_NAME]);
+		job->nodelist = xstrdup(row[JOBCOMP_REQ_NODELIST]);
+		if(row[JOBCOMP_REQ_NODECNT])
+			job->node_cnt = atoi(row[JOBCOMP_REQ_NODECNT]);
+		if(row[JOBCOMP_REQ_MAXPROCS])
+			job->max_procs = atoi(row[JOBCOMP_REQ_MAXPROCS]);
+		if(row[JOBCOMP_REQ_STATE]) {
+			i = atoi(row[JOBCOMP_REQ_STATE]);
+			job->state = xstrdup(job_state_string(i));
+		}
+		job->timelimit = xstrdup(row[JOBCOMP_REQ_TIMELIMIT]);
+		job->connection = xstrdup(row[JOBCOMP_REQ_CONNECTION]);
+		job->reboot = xstrdup(row[JOBCOMP_REQ_REBOOT]);
+		job->rotate = xstrdup(row[JOBCOMP_REQ_ROTATE]);
+		job->geo = xstrdup(row[JOBCOMP_REQ_GEOMETRY]);
+		job->bg_start_point = xstrdup(row[JOBCOMP_REQ_START]);
+		list_append(job_list, job);
+	}
+		
+	mysql_free_result(result);
+	
+	return;
+}
+
+extern void mysql_jobcomp_process_archive(List selected_parts,
+					  sacct_parameters_t *params)
+{
+	return;
+}
+
+#endif	
diff --git a/src/plugins/database/mysql/mysql_jobcomp_process.h b/src/plugins/database/mysql/mysql_jobcomp_process.h
new file mode 100644
index 0000000000000000000000000000000000000000..ff533cb0f77be0b0970838bebac7532be0a031f7
--- /dev/null
+++ b/src/plugins/database/mysql/mysql_jobcomp_process.h
@@ -0,0 +1,94 @@
+/*****************************************************************************\
+ *  mysql_jobcomp_process.h - functions the processing of
+ *                               information from the mysql jobcomp
+ *                               database.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+
+#ifndef _HAVE_MYSQL_JOBCOMP_PROCESS_H
+#define _HAVE_MYSQL_JOBCOMP_PROCESS_H
+
+#include "mysql_common.h"
+#include "mysql_jobcomp.h"
+#include "src/common/slurm_jobacct.h"
+#include "src/common/slurm_jobcomp.h"
+
+#ifdef HAVE_MYSQL
+extern MYSQL *jobcomp_mysql_db;
+extern int jobcomp_db_init;
+
+extern char *jobcomp_table;
+/* This variable and the following enum are related so if you change
+   the jobcomp_table_fields defined in mysql_jobcomp.c you must update
+   this enum accordingly.
+*/
+extern database_field_t jobcomp_table_fields[];
+enum {
+	JOBCOMP_REQ_JOBID,
+	JOBCOMP_REQ_UID,
+	JOBCOMP_REQ_USER_NAME,
+	JOBCOMP_REQ_GID,
+	JOBCOMP_REQ_GROUP_NAME,
+	JOBCOMP_REQ_NAME,
+	JOBCOMP_REQ_STATE,
+	JOBCOMP_REQ_PARTITION,
+	JOBCOMP_REQ_TIMELIMIT,
+	JOBCOMP_REQ_STARTTIME,
+	JOBCOMP_REQ_ENDTIME,
+	JOBCOMP_REQ_NODELIST,
+	JOBCOMP_REQ_NODECNT,
+	JOBCOMP_REQ_CONNECTION,
+	JOBCOMP_REQ_REBOOT,
+	JOBCOMP_REQ_ROTATE,
+	JOBCOMP_REQ_MAXPROCS,
+	JOBCOMP_REQ_GEOMETRY,
+	JOBCOMP_REQ_START,
+	JOBCOMP_REQ_BLOCKID,
+	JOBCOMP_REQ_COUNT		
+};
+
+extern void mysql_jobcomp_process_get_jobs(List job_list,
+					   List selected_steps,
+					   List selected_parts,
+					   sacct_parameters_t *params);
+
+extern void mysql_jobcomp_process_archive(List selected_parts,
+					  sacct_parameters_t *params);
+#endif
+
+#endif
diff --git a/src/plugins/database/pgsql/Makefile.am b/src/plugins/database/pgsql/Makefile.am
new file mode 100644
index 0000000000000000000000000000000000000000..cc9c1a72d21b88369fe49f2a1e4f2ba94b9d98ff
--- /dev/null
+++ b/src/plugins/database/pgsql/Makefile.am
@@ -0,0 +1,21 @@
+# Makefile for database/pgsql plugin
+
+CPPFLAGS = $(PGSQL_CFLAGS)
+AUTOMAKE_OPTIONS = foreign
+
+PLUGIN_FLAGS = -module -avoid-version --export-dynamic $(PGSQL_LIBS)
+
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
+
+pkglib_LTLIBRARIES = database_pgsql.la
+
+# Pgsql database plugin.
+database_pgsql_la_SOURCES = database_pgsql.c \
+		pgsql_common.c pgsql_common.h \
+		pgsql_jobacct.c pgsql_jobacct.h \
+		pgsql_jobcomp.c pgsql_jobcomp.h \
+		pgsql_jobacct_process.c pgsql_jobacct_process.h \
+		pgsql_jobcomp_process.c pgsql_jobcomp_process.h
+database_pgsql_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
+database_pgsql_la_LIBADD  = $(top_builddir)/src/common/libcommon.la
+
diff --git a/src/plugins/database/pgsql/Makefile.in b/src/plugins/database/pgsql/Makefile.in
new file mode 100644
index 0000000000000000000000000000000000000000..bfa77dd25e6aaddf2d58f32f8e3c7afe8a222d9d
--- /dev/null
+++ b/src/plugins/database/pgsql/Makefile.in
@@ -0,0 +1,562 @@
+# Makefile.in generated by automake 1.10 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# Makefile for database/pgsql plugin
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/plugins/database/pgsql
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
+	$(top_srcdir)/auxdir/slurm.m4 \
+	$(top_srcdir)/auxdir/x_ac__system_configuration.m4 \
+	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
+	$(top_srcdir)/auxdir/x_ac_aix.m4 \
+	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
+	$(top_srcdir)/auxdir/x_ac_debug.m4 \
+	$(top_srcdir)/auxdir/x_ac_elan.m4 \
+	$(top_srcdir)/auxdir/x_ac_federation.m4 \
+	$(top_srcdir)/auxdir/x_ac_gpl_licensed.m4 \
+	$(top_srcdir)/auxdir/x_ac_gtk.m4 \
+	$(top_srcdir)/auxdir/x_ac_munge.m4 \
+	$(top_srcdir)/auxdir/x_ac_ncurses.m4 \
+	$(top_srcdir)/auxdir/x_ac_pam.m4 \
+	$(top_srcdir)/auxdir/x_ac_ptrace.m4 \
+	$(top_srcdir)/auxdir/x_ac_readline.m4 \
+	$(top_srcdir)/auxdir/x_ac_setpgrp.m4 \
+	$(top_srcdir)/auxdir/x_ac_setproctitle.m4 \
+	$(top_srcdir)/auxdir/x_ac_sgi_job.m4 \
+	$(top_srcdir)/auxdir/x_ac_slurm_ssl.m4 \
+	$(top_srcdir)/auxdir/x_ac_xcpu.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/slurm/slurm.h
+CONFIG_CLEAN_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(pkglibdir)"
+pkglibLTLIBRARIES_INSTALL = $(INSTALL)
+LTLIBRARIES = $(pkglib_LTLIBRARIES)
+database_pgsql_la_DEPENDENCIES =  \
+	$(top_builddir)/src/common/libcommon.la
+am_database_pgsql_la_OBJECTS = database_pgsql.lo pgsql_common.lo \
+	pgsql_jobacct.lo pgsql_jobcomp.lo pgsql_jobacct_process.lo \
+	pgsql_jobcomp_process.lo
+database_pgsql_la_OBJECTS = $(am_database_pgsql_la_OBJECTS)
+database_pgsql_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(database_pgsql_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
+SOURCES = $(database_pgsql_la_SOURCES)
+DIST_SOURCES = $(database_pgsql_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTHD_CFLAGS = @AUTHD_CFLAGS@
+AUTHD_LIBS = @AUTHD_LIBS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BG_INCLUDES = @BG_INCLUDES@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CMD_LDFLAGS = @CMD_LDFLAGS@
+CPP = @CPP@
+CPPFLAGS = $(PGSQL_CFLAGS)
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ELAN_LIBS = @ELAN_LIBS@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FEDERATION_LDFLAGS = @FEDERATION_LDFLAGS@
+FFLAGS = @FFLAGS@
+GREP = @GREP@
+GTK2_CFLAGS = @GTK2_CFLAGS@
+GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
+HAVEPKGCONFIG = @HAVEPKGCONFIG@
+HAVE_AIX = @HAVE_AIX@
+HAVE_ELAN = @HAVE_ELAN@
+HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_LDFLAGS = @LIB_LDFLAGS@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
+MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
+MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
+NCURSES = @NCURSES@
+NUMA_LIBS = @NUMA_LIBS@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PAM_LIBS = @PAM_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
+PLPA_LIBS = @PLPA_LIBS@
+PROCTRACKDIR = @PROCTRACKDIR@
+PROJECT = @PROJECT@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+RELEASE = @RELEASE@
+SEMAPHORE_LIBS = @SEMAPHORE_LIBS@
+SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMD_PORT = @SLURMD_PORT@
+SLURM_API_AGE = @SLURM_API_AGE@
+SLURM_API_CURRENT = @SLURM_API_CURRENT@
+SLURM_API_MAJOR = @SLURM_API_MAJOR@
+SLURM_API_REVISION = @SLURM_API_REVISION@
+SLURM_API_VERSION = @SLURM_API_VERSION@
+SLURM_MAJOR = @SLURM_MAJOR@
+SLURM_MICRO = @SLURM_MICRO@
+SLURM_MINOR = @SLURM_MINOR@
+SLURM_VERSION = @SLURM_VERSION@
+SO_LDFLAGS = @SO_LDFLAGS@
+SSL_CPPFLAGS = @SSL_CPPFLAGS@
+SSL_LDFLAGS = @SSL_LDFLAGS@
+SSL_LIBS = @SSL_LIBS@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign
+PLUGIN_FLAGS = -module -avoid-version --export-dynamic $(PGSQL_LIBS)
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
+pkglib_LTLIBRARIES = database_pgsql.la
+
+# Pgsql database plugin.
+database_pgsql_la_SOURCES = database_pgsql.c \
+		pgsql_common.c pgsql_common.h \
+		pgsql_jobacct.c pgsql_jobacct.h \
+		pgsql_jobcomp.c pgsql_jobcomp.h \
+		pgsql_jobacct_process.c pgsql_jobacct_process.h \
+		pgsql_jobcomp_process.c pgsql_jobcomp_process.h
+
+database_pgsql_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
+database_pgsql_la_LIBADD = $(top_builddir)/src/common/libcommon.la
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/plugins/database/pgsql/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  src/plugins/database/pgsql/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
+	@$(NORMAL_INSTALL)
+	test -z "$(pkglibdir)" || $(MKDIR_P) "$(DESTDIR)$(pkglibdir)"
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  if test -f $$p; then \
+	    f=$(am__strip_dir) \
+	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	  else :; fi; \
+	done
+
+uninstall-pkglibLTLIBRARIES:
+	@$(NORMAL_UNINSTALL)
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  p=$(am__strip_dir) \
+	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	done
+
+clean-pkglibLTLIBRARIES:
+	-test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES)
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+database_pgsql.la: $(database_pgsql_la_OBJECTS) $(database_pgsql_la_DEPENDENCIES) 
+	$(database_pgsql_la_LINK) -rpath $(pkglibdir) $(database_pgsql_la_OBJECTS) $(database_pgsql_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/database_pgsql.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pgsql_common.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pgsql_jobacct.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pgsql_jobacct_process.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pgsql_jobcomp.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pgsql_jobcomp_process.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+	for dir in "$(DESTDIR)$(pkglibdir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-pkglibLTLIBRARIES
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pkglibLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-pkglibLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-pkglibLTLIBRARIES \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-pkglibLTLIBRARIES
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/plugins/database/pgsql/database_pgsql.c b/src/plugins/database/pgsql/database_pgsql.c
new file mode 100644
index 0000000000000000000000000000000000000000..fe549ba8562cf2de2f4595a3c4807c533e9f46e9
--- /dev/null
+++ b/src/plugins/database/pgsql/database_pgsql.c
@@ -0,0 +1,277 @@
+/*****************************************************************************\
+ *  database_pgsql.c - Store/Get all information in a postgresql database.
+ *
+ *  $Id: database_pgsql.c 10893 2007-01-29 21:53:48Z da $
+ *****************************************************************************
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#include "pgsql_jobacct.h"
+#include "pgsql_jobcomp.h"
+#include "pgsql_common.h"
+
+/*
+ * These variables are required by the generic plugin interface.  If they
+ * are not found in the plugin, the plugin loader will ignore it.
+ *
+ * plugin_name - a string giving a human-readable description of the
+ * plugin.  There is no maximum length, but the symbol must refer to
+ * a valid string.
+ *
+ * plugin_type - a string suggesting the type of the plugin or its
+ * applicability to a particular form of data or method of data handling.
+ * If the low-level plugin API is used, the contents of this string are
+ * unimportant and may be anything.  SLURM uses the higher-level plugin
+ * interface which requires this string to be of the form
+ *
+ *	<application>/<method>
+ *
+ * where <application> is a description of the intended application of
+ * the plugin (e.g., "jobacct" for SLURM job completion logging) and <method>
+ * is a description of how this plugin satisfies that application.  SLURM will
+ * only load job completion logging plugins if the plugin_type string has a 
+ * prefix of "jobacct/".
+ *
+ * plugin_version - an unsigned 32-bit integer giving the version number
+ * of the plugin.  If major and minor revisions are desired, the major
+ * version number may be multiplied by a suitable magnitude constant such
+ * as 100 or 1000.  Various SLURM versions will likely require a certain
+ * minimum versions for their plugins as the job accounting API 
+ * matures.
+ */
+const char plugin_name[] = "Database POSTGRESQL plugin";
+const char plugin_type[] = "database/pgsql";
+const uint32_t plugin_version = 100;
+
+/*
+ * init() is called when the plugin is loaded, before any other functions
+ * are called.  Put global initialization here.
+ */
+extern int init ( void )
+{
+	verbose("%s loaded", plugin_name);
+	return SLURM_SUCCESS;
+}
+
+extern int fini ( void )
+{
+	return SLURM_SUCCESS;
+}
+/* 
+ * Initialize the database make sure tables are created and in working
+ * order
+ */
+extern int database_p_jobacct_init(char *location)
+{
+#ifdef HAVE_PGSQL
+	return pgsql_jobacct_init(location);	
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+/*
+ * finish up database connection
+ */
+extern int database_p_jobacct_fini()
+{
+#ifdef HAVE_PGSQL
+	return pgsql_jobacct_fini();
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+/* 
+ * load into the database the start of a job
+ */
+extern int database_p_jobacct_job_start(struct job_record *job_ptr)
+{
+#ifdef HAVE_PGSQL
+	return pgsql_jobacct_job_start(job_ptr);
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+/* 
+ * load into the database the end of a job
+ */
+extern int database_p_jobacct_job_complete(struct job_record *job_ptr)
+{
+#ifdef HAVE_PGSQL
+	return pgsql_jobacct_job_complete(job_ptr);
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+/* 
+ * load into the database the start of a job step
+ */
+extern int database_p_jobacct_step_start(struct step_record *step_ptr)
+{
+#ifdef HAVE_PGSQL
+	return pgsql_jobacct_step_start(step_ptr);
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+/* 
+ * load into the database the end of a job step
+ */
+extern int database_p_jobacct_step_complete(struct step_record *step_ptr)
+{
+#ifdef HAVE_PGSQL
+	return pgsql_jobacct_step_complete(step_ptr);
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+/* 
+ * load into the database a suspention of a job
+ */
+extern int database_p_jobacct_suspend(struct job_record *job_ptr)
+{
+#ifdef HAVE_PGSQL
+	return pgsql_jobacct_suspend(job_ptr);
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+/* 
+ * get info from the database 
+ * returns List of job_rec_t *
+ * note List needs to be freed when called
+ */
+extern void database_p_jobacct_get_jobs(List job_list,
+					List selected_steps,
+					List selected_parts,
+					void *params)
+{
+#ifdef HAVE_PGSQL
+	pgsql_jobacct_get_jobs(job_list,
+			       selected_steps, selected_parts,
+			       params);
+#endif
+	return;
+}
+
+/* 
+ * expire old info from the database 
+ */
+extern void database_p_jobacct_archive(List selected_parts,
+				       void *params)
+{
+#ifdef HAVE_PGSQL
+	pgsql_jobacct_archive(selected_parts, params);
+#endif
+	return;
+}
+
+extern int database_p_jobcomp_init(char *location)
+{
+#ifdef HAVE_PGSQL
+	return pgsql_jobcomp_init(location);
+#else
+	return SLURM_ERROR;
+#endif 
+}
+
+extern int database_p_jobcomp_fini()
+{
+#ifdef HAVE_PGSQL
+	return pgsql_jobcomp_fini();
+#else
+	return SLURM_ERROR;
+#endif 
+}
+
+extern int database_p_jobcomp_log_record(struct job_record *job_ptr)
+{
+#ifdef HAVE_PGSQL
+	return pgsql_jobcomp_log_record(job_ptr);
+#else
+	return SLURM_ERROR;
+#endif 
+}
+
+extern int database_p_jobcomp_get_errno()
+{
+#ifdef HAVE_PGSQL
+	return pgsql_jobcomp_get_errno();
+#else
+	return SLURM_ERROR;
+#endif 
+}
+
+extern char *database_p_jobcomp_strerror(int errnum)
+{
+#ifdef HAVE_PGSQL
+	return pgsql_jobcomp_strerror(errnum);
+#else
+	return NULL;
+#endif 
+}
+
+/* 
+ * get info from the database 
+ * in/out job_list List of job_rec_t *
+ * note List needs to be freed when called
+ */
+extern void database_p_jobcomp_get_jobs(List job_list, 
+					List selected_steps,
+					List selected_parts,
+					void *params)
+{
+#ifdef HAVE_PGSQL
+	pgsql_jobcomp_get_jobs(job_list, 
+			       selected_steps, selected_parts,
+			       params);	
+#endif 
+	return;
+}
+
+/* 
+ * expire old info from the database 
+ */
+extern void database_p_jobcomp_archive(List selected_parts, void *params)
+{
+#ifdef HAVE_PGSQL
+	pgsql_jobcomp_archive(selected_parts, params);
+#endif 
+	return;
+}
diff --git a/src/plugins/database/pgsql/pgsql_common.c b/src/plugins/database/pgsql/pgsql_common.c
new file mode 100644
index 0000000000000000000000000000000000000000..c879e9c0de2208e26c37a838fbc318420cd3be9a
--- /dev/null
+++ b/src/plugins/database/pgsql/pgsql_common.c
@@ -0,0 +1,249 @@
+/*****************************************************************************\
+ *  pgsql_common.c - common functions for the the pgsql database plugin.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+
+#include "pgsql_common.h"
+#include <stdlib.h>
+
+bool thread_safe = true;
+pthread_mutex_t pgsql_lock = PTHREAD_MUTEX_INITIALIZER;
+
+#ifdef HAVE_PGSQL
+extern pgsql_db_info_t *create_pgsql_db_info()
+{
+	pgsql_db_info_t *db_info = xmalloc(sizeof(pgsql_db_info_t));
+	db_info->port = slurm_get_database_port();
+	/* it turns out it is better if using defaults to let postgres
+	   handle them on it's own terms */
+	if(!db_info->port)
+		db_info->port = 5432;
+	db_info->host = slurm_get_database_host();
+	db_info->user = slurm_get_database_user();	
+	db_info->pass = slurm_get_database_pass();	
+	return db_info;
+}
+
+extern int *destroy_pgsql_db_info(pgsql_db_info_t *db_info)
+{
+	if(db_info) {
+		xfree(db_info->host);
+		xfree(db_info->user);
+		xfree(db_info->pass);
+		xfree(db_info);
+	}
+	return SLURM_SUCCESS;
+}
+
+extern int pgsql_create_db(PGconn *pgsql_db, char *db_name,
+			   pgsql_db_info_t *db_info)
+{
+	char create_line[50];
+	char *connect_line = xstrdup_printf("dbname = 'postgres'"
+					    " host = '%s'"
+					    " port = '%u'"
+					    " user = '%s'"
+					    " password = '%s'",
+					    db_info->host,
+					    db_info->port,
+					    db_info->user,
+					    db_info->pass);
+
+	pgsql_db = PQconnectdb(connect_line);
+
+	if (PQstatus(pgsql_db) == CONNECTION_OK) {
+		PGresult *result = NULL;
+		snprintf(create_line, sizeof(create_line),
+			 "create database %s", db_name);
+		result = PQexec(pgsql_db, create_line);
+		if (PQresultStatus(result) != PGRES_COMMAND_OK) {
+			fatal("PQexec failed: %d %s\n%s",
+			     PQresultStatus(result), PQerrorMessage(pgsql_db), create_line);
+		}
+		PQclear(result);
+	} else {
+		info("Connection failed to %s", connect_line);
+		fatal("Status was: %d %s",
+		      PQstatus(pgsql_db), PQerrorMessage(pgsql_db));
+	}
+	xfree(connect_line);
+	return SLURM_SUCCESS;
+}
+
+extern int pgsql_get_db_connection(PGconn **pgsql_db, char *db_name,
+				   pgsql_db_info_t *db_info,
+				   int *database_init)
+{
+	int rc = SLURM_SUCCESS;
+	char *connect_line = xstrdup_printf("dbname = '%s'"
+					    " host = '%s'"
+					    " port = '%u'"
+					    " user = '%s'"
+					    " password = '%s'",
+					    db_name,
+					    db_info->host,
+					    db_info->port,
+					    db_info->user,
+					    db_info->pass);
+
+	while(!*database_init) {
+		*pgsql_db = PQconnectdb(connect_line);
+		
+		if(PQstatus(*pgsql_db) != CONNECTION_OK) {
+			if(!strcmp(PQerrorMessage(*pgsql_db),
+				   PQnoPasswordSupplied)) {
+				PQfinish(*pgsql_db);
+				fatal("This Postgres connection needs "
+				      "a password.  It doesn't appear to "
+				      "like blank ones");
+			} 
+			
+			info("Database %s not created. Creating %d", db_name);
+			PQfinish(*pgsql_db);
+			pgsql_create_db(*pgsql_db, db_name, db_info);
+			
+		} else {
+			*database_init = true;
+			debug2("connected to %s", db_name);
+		} 
+	}
+	xfree(connect_line);
+	return rc;
+}
+
+extern int pgsql_db_query(PGconn *pgsql_db, int database_init, char *query)
+{
+	PGresult *result = NULL;
+	
+	if(!database_init)
+		fatal("You haven't inited this database yet.");
+	
+	if(!(result = pgsql_db_query_ret(pgsql_db, database_init, query))) 
+		return SLURM_ERROR;
+	
+	PQclear(result);
+	return SLURM_SUCCESS;
+}
+
+extern PGresult *pgsql_db_query_ret(PGconn *pgsql_db, int database_init,
+				    char *query)
+{
+	PGresult *result = NULL;
+	
+	if(!database_init)
+		fatal("You haven't inited this database yet.");
+
+	result = PQexec(pgsql_db, query);
+
+	if(PQresultStatus(result) != PGRES_COMMAND_OK
+	   && PQresultStatus(result) != PGRES_TUPLES_OK) {
+		error("PQexec failed: %d %s", PQresultStatus(result), 
+		      PQerrorMessage(pgsql_db));
+		info("query was %s", query);
+		PQclear(result);
+		return NULL;
+	}
+	return result;
+}
+
+extern int pgsql_insert_ret_id(PGconn *pgsql_db, int database_init,
+			       char *sequence_name, char *query)
+{
+	int new_id = 0;
+	PGresult *result = NULL;
+
+	slurm_mutex_lock(&pgsql_lock);
+	if(pgsql_db_query(pgsql_db, database_init, query) != SLURM_ERROR)  {
+		char *new_query = xstrdup_printf(
+			"select last_value from %s", sequence_name);
+		
+		if((result = pgsql_db_query_ret(pgsql_db,
+						database_init, new_query))) {
+			new_id = atoi(PQgetvalue(result, 0, 0));
+			PQclear(result);		
+		}
+		xfree(new_query);
+		if(!new_id) {
+			/* should have new id */
+			error("We should have gotten a new id: %s", 
+			      PQerrorMessage(pgsql_db));
+		}
+	}
+	slurm_mutex_unlock(&pgsql_lock);
+	
+	return new_id;
+	
+}
+
+extern int pgsql_db_create_table(PGconn *pgsql_db, int database_init, 
+				 char *table_name, database_field_t *fields,
+				 char *ending)
+{
+	char *query = NULL;
+	char *tmp = NULL;
+	char *next = NULL;
+	int i = 0;
+
+	query = xstrdup_printf("create table %s (", table_name);
+	i=0;
+	while(fields && fields->name) {
+		next = xstrdup_printf(" %s %s",
+				      fields->name, 
+				      fields->options);
+		if(i) 
+			xstrcat(tmp, ",");
+		xstrcat(tmp, next);
+		xfree(next);
+		fields++;
+		i++;
+	}
+	xstrcat(query, tmp);
+	xfree(tmp);
+	xstrcat(query, ending);
+
+	if(pgsql_db_query(pgsql_db, database_init, query) == SLURM_ERROR) {
+		xfree(query);
+		return SLURM_ERROR;
+	}
+	xfree(query);
+
+	return SLURM_SUCCESS;
+}
+
+#endif
+
diff --git a/src/plugins/database/pgsql/pgsql_common.h b/src/plugins/database/pgsql/pgsql_common.h
new file mode 100644
index 0000000000000000000000000000000000000000..a657ca28e5c40731cf83d2658dfcc0dc09d7c138
--- /dev/null
+++ b/src/plugins/database/pgsql/pgsql_common.h
@@ -0,0 +1,103 @@
+/*****************************************************************************\
+ *  pgsql_common.h - common functions for the the pgsql database plugin.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+#ifndef _HAVE_PGSQL_COMMON_H
+#define _HAVE_PGSQL_COMMON_H
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#if HAVE_STDINT_H
+#  include <stdint.h>
+#endif
+#if HAVE_INTTYPES_H
+#  include <inttypes.h>
+#endif
+
+#include <stdio.h>
+#include <slurm/slurm_errno.h>
+#include "src/slurmctld/slurmctld.h"
+#include "src/common/xstring.h"
+
+#ifdef HAVE_PGSQL
+#include <libpq-fe.h>
+
+typedef struct {
+	uint32_t port;	
+	char *host;	
+	char *user;	
+	char *pass;	
+} pgsql_db_info_t;
+
+typedef struct {
+	char *name;
+	char *options;
+} database_field_t;
+
+
+extern bool thread_safe;
+extern pthread_mutex_t pgsql_lock;
+
+extern pgsql_db_info_t *create_pgsql_db_info();
+
+extern int *destroy_pgsql_db_info(pgsql_db_info_t *db_info);
+
+extern int pgsql_create_db(PGconn *pgsql_db, char *db_name,
+			   pgsql_db_info_t *db_info);
+
+extern int pgsql_get_db_connection(PGconn **pgsql_db, char *db_name,
+				   pgsql_db_info_t *db_info,
+				   int *database_init);
+
+extern int pgsql_db_query(PGconn *pgsql_db, int database_init, char *query);
+
+extern PGresult *pgsql_db_query_ret(PGconn *pgsql_db, int database_init,
+				     char *query);
+
+extern int pgsql_insert_ret_id(PGconn *pgsql_db, int database_init, 
+			       char *sequence_name, char *query);
+
+extern int pgsql_db_create_table(PGconn *pgsql_db, int database_init, 
+				 char *table_name, database_field_t *fields,
+				 char *ending);
+
+#endif
+
+#endif
diff --git a/src/plugins/database/pgsql/pgsql_jobacct.c b/src/plugins/database/pgsql/pgsql_jobacct.c
new file mode 100644
index 0000000000000000000000000000000000000000..6925fdc043d59767c3f89cedada0e3a2efc51b66
--- /dev/null
+++ b/src/plugins/database/pgsql/pgsql_jobacct.c
@@ -0,0 +1,713 @@
+/*****************************************************************************\
+ *  pgsql_jobacct.c - functions the pgsql jobacct database.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+
+#include "pgsql_jobacct_process.h"
+
+#ifdef HAVE_PGSQL
+
+#define DEFAULT_JOBACCT_DB "slurm_jobacct_db"
+
+PGconn *jobacct_pgsql_db = NULL;
+int jobacct_db_init = 0;
+
+char *index_table = "index_table";
+char *job_table = "job_table";
+char *step_table = "step_table";
+char *rusage_table = "rusage_table";
+
+static int _pgsql_jobacct_check_tables(char *user)
+{
+	database_field_t index_table_fields[] = {
+		{ "id", "serial" },
+		{ "jobid ", "integer not null" },
+		{ "partition", "text not null" },
+		{ "submit", "bigint not null" },
+		{ "uid", "smallint not null" },
+		{ "gid", "smallint not null" },
+		{ "blockid", "text" },
+		{ NULL, NULL}		
+	};
+
+	database_field_t job_table_fields[] = {
+		{ "id", "int not null" },
+		{ "start", "bigint default 0" },
+		{ "endtime", "bigint default 0" },
+		{ "suspended", "bigint default 0" },
+		{ "name", "text not null" }, 
+		{ "track_steps", "smallint not null" },
+		{ "state", "smallint not null" }, 
+		{ "priority", "bigint not null" },
+		{ "cpus", "integer not null" }, 
+		{ "nodelist", "text" },
+		{ "account", "text" },
+		{ "kill_requid", "smallint" },
+		{ NULL, NULL}
+	};
+
+	database_field_t step_table_fields[] = {
+		{ "id", "int not null" },
+		{ "stepid", "smallint not null" },
+		{ "start", "bigint default 0" },
+		{ "endtime", "bigint default 0" },
+		{ "suspended", "bigint default 0" },
+		{ "name", "text not null" },
+		{ "nodelist", "text not null" },
+		{ "state", "smallint not null" },
+		{ "kill_requid", "smallint default -1" },
+		{ "comp_code", "smallint default 0" },
+		{ "cpus", "int not null" },
+		{ "max_vsize", "integer default 0" },
+		{ "max_vsize_task", "smallint default 0" },
+		{ "max_vsize_node", "integer default 0" },
+		{ "ave_vsize", "float default 0.0" },
+		{ "max_rss", "integer default 0" },
+		{ "max_rss_task", "smallint default 0" },
+		{ "max_rss_node", "integer default 0" },
+		{ "ave_rss", "float default 0.0" },
+		{ "max_pages", "integer default 0" },
+		{ "max_pages_task", "smallint default 0" },
+		{ "max_pages_node", "integer default 0" },
+		{ "ave_pages", "float default 0.0" },
+		{ "min_cpu", "integer default 0" },
+		{ "min_cpu_task", "smallint default 0" },
+		{ "min_cpu_node", "integer default 0" },
+		{ "ave_cpu", "float default 0.0" },
+		{ NULL, NULL}
+	};
+
+	database_field_t step_rusage_fields[] = {
+		{ "id", "int not null" },
+		{ "stepid", "smallint not null" },
+		{ "cpu_sec", "bigint default 0" },
+		{ "cpu_usec", "bigint default 0" },
+		{ "user_sec", "bigint default 0" },
+		{ "user_usec", "bigint default 0" },
+		{ "sys_sec", "bigint default 0" },
+		{ "sys_usec", "bigint default 0" },
+		{ "max_rss", "bigint default 0" },
+		{ "max_ixrss", "bigint default 0" },
+		{ "max_idrss", "bigint default 0" },
+		{ "max_isrss", "bigint default 0" },
+		{ "max_minflt", "bigint default 0" },
+		{ "max_majflt", "bigint default 0" },
+		{ "max_nswap", "bigint default 0" },
+		{ "inblock", "bigint default 0" },
+		{ "outblock", "bigint default 0" },
+		{ "msgsnd", "bigint default 0" },
+		{ "msgrcv", "bigint default 0" },
+		{ "nsignals", "bigint default 0" },
+		{ "nvcsw", "bigint default 0" },
+		{ "nivcsw", "bigint default 0" },
+		{ NULL, NULL}
+	};
+
+	int i = 0, index_found = 0, job_found = 0;
+	int step_found = 0, rusage_found = 0;
+	PGresult *result = NULL;
+	char *query = xstrdup_printf("select tablename from pg_tables "
+				     "where tableowner='%s' "
+				     "and tablename !~ '^pg_+'", user);
+
+	if(!(result =
+	     pgsql_db_query_ret(jobacct_pgsql_db, jobacct_db_init, query))) {
+		xfree(query);
+		return SLURM_ERROR;
+	}
+	xfree(query);
+
+	for (i = 0; i < PQntuples(result); i++) {
+		if(!index_found && 
+		   !strcmp(index_table, PQgetvalue(result, i, 0))) 
+			index_found = 1;
+		else if(!job_found &&
+			!strcmp(job_table, PQgetvalue(result, i, 0))) 
+			job_found = 1;
+		else if(!step_found &&
+			!strcmp(step_table, PQgetvalue(result, i, 0))) 
+			step_found = 1;
+		else if(!rusage_found &&
+			!strcmp(rusage_table, PQgetvalue(result, i, 0))) 
+			rusage_found = 1;
+	}
+	PQclear(result);
+
+	if(!index_found)
+		if(pgsql_db_create_table(jobacct_pgsql_db, jobacct_db_init, 
+					 index_table, index_table_fields,
+					 ", primary key (id))") == SLURM_ERROR)
+			return SLURM_ERROR;
+	
+	if(!job_found)
+		if(pgsql_db_create_table(jobacct_pgsql_db, jobacct_db_init, 
+					 job_table, job_table_fields,
+					 ")") == SLURM_ERROR)
+			return SLURM_ERROR;
+
+	if(!step_found)
+		if(pgsql_db_create_table(jobacct_pgsql_db, jobacct_db_init, 
+					 step_table, step_table_fields,
+					 ")") == SLURM_ERROR)
+			return SLURM_ERROR;
+
+	if(!rusage_found)
+		if(pgsql_db_create_table(jobacct_pgsql_db, jobacct_db_init, 
+					 rusage_table, step_rusage_fields,
+					 ")") == SLURM_ERROR)
+			return SLURM_ERROR;
+
+
+	return SLURM_SUCCESS;
+}
+
+
+extern int pgsql_jobacct_init(char *location)
+{
+	pgsql_db_info_t *db_info = create_pgsql_db_info();
+	int rc = SLURM_SUCCESS;
+	char *db_name = NULL;
+
+	if(jobacct_db_init) 
+		return SLURM_ERROR;
+	
+	if(!location)
+		db_name = DEFAULT_JOBACCT_DB;
+	else {
+		int i = 0;
+		while(location[i]) {
+			if(location[i] == '.' || location[i] == '/') {
+				debug("%s doesn't look like a database "
+				      "name using %s",
+				      location, DEFAULT_JOBACCT_DB);
+				break;
+			}
+			i++;
+		}
+		if(location[i]) 
+			db_name = DEFAULT_JOBACCT_DB;
+		else
+			db_name = location;
+	}
+	debug2("pgsql_connect() called for db %s", db_name);
+	
+	pgsql_get_db_connection(&jobacct_pgsql_db, db_name, db_info,
+				&jobacct_db_init);
+
+	rc = _pgsql_jobacct_check_tables(db_info->user);
+
+	destroy_pgsql_db_info(db_info);
+
+	if(rc == SLURM_SUCCESS)
+		debug("Database init finished");
+	else
+		error("Database init failed");
+	return rc;
+}
+
+extern int pgsql_jobacct_fini()
+{
+	if (jobacct_pgsql_db) {
+		PQfinish(jobacct_pgsql_db);
+		jobacct_pgsql_db = NULL;
+	}
+	jobacct_db_init = 0;
+	return SLURM_SUCCESS;
+}
+
+extern int pgsql_jobacct_job_start(struct job_record *job_ptr)
+{
+	int	i,
+		ncpus=0,
+		rc=SLURM_SUCCESS;
+	char	*jname, *account, *nodes;
+	long	priority;
+	int track_steps = 0;
+	char *block_id = NULL;
+	char query[1024];
+	int reinit = 0;
+
+	if(!jobacct_pgsql_db) {
+		char *loc = slurm_get_jobacct_loc();
+		if(pgsql_jobacct_init(loc) == SLURM_ERROR) {
+			xfree(loc);
+			return SLURM_ERROR;
+		}
+		xfree(loc);
+	}
+
+	debug2("pgsql_jobacct_job_start() called");
+	for (i=0; i < job_ptr->num_cpu_groups; i++)
+		ncpus += (job_ptr->cpus_per_node[i])
+			* (job_ptr->cpu_count_reps[i]);
+	priority = (job_ptr->priority == NO_VAL) ?
+		-1L : (long) job_ptr->priority;
+
+	if (job_ptr->name && job_ptr->name[0]) {
+		jname = job_ptr->name;
+	} else {
+		jname = "allocation";
+		track_steps = 1;
+	}
+
+	if (job_ptr->account && job_ptr->account[0])
+		account = job_ptr->account;
+	else
+		account = "(null)";
+	if (job_ptr->nodes && job_ptr->nodes[0])
+		nodes = job_ptr->nodes;
+	else
+		nodes = "(null)";
+
+	if(job_ptr->batch_flag)
+		track_steps = 1;
+#ifdef HAVE_BG
+	select_g_get_jobinfo(job_ptr->select_jobinfo, 
+			     SELECT_DATA_BLOCK_ID, 
+			     &block_id);
+		
+#endif
+	if(!block_id)
+		block_id = xstrdup("-");
+
+	job_ptr->requid = -1; /* force to -1 for sacct to know this
+			       * hasn't been set yet */
+	snprintf(query, sizeof(query),
+		 "insert into %s (jobid, partition, submit, uid, gid, "
+		 "blockid) values (%u, '%s', %u, %d, %d, '%s')",
+		 index_table, job_ptr->job_id, job_ptr->partition,
+		 (int)job_ptr->details->submit_time, job_ptr->user_id,
+		 job_ptr->group_id, block_id);
+	xfree(block_id);
+
+try_again:
+	if((job_ptr->db_index = pgsql_insert_ret_id(
+		    jobacct_pgsql_db, jobacct_db_init, 
+		    "index_table_id_seq", query))) {
+		snprintf(query, sizeof(query),
+			 "insert into %s (id, start, name, track_steps, "
+			 "state, priority, cpus, nodelist, account) "
+			 "values (%d, %u, '%s', %d, %d, %ld, %u, '%s', '%s')",
+			 job_table, job_ptr->db_index, 
+			 (int)job_ptr->start_time,
+			 jname, track_steps,
+			 job_ptr->job_state & (~JOB_COMPLETING),
+			 priority, job_ptr->num_procs,
+			 nodes, account);
+		rc = pgsql_db_query(jobacct_pgsql_db, jobacct_db_init, query);
+	} else if(!reinit) {
+		char *loc = slurm_get_jobacct_loc();
+		error("It looks like the database has gone "
+		      "away trying to reconnect");
+		pgsql_jobacct_fini();
+		pgsql_jobacct_init(loc);
+		xfree(loc);
+		reinit = 1;
+		goto try_again;
+	} else
+		rc = SLURM_ERROR;
+	
+	return rc;
+}
+
+extern int pgsql_jobacct_job_complete(struct job_record *job_ptr)
+{
+	char query[1024];
+	char	*account, *nodes;
+	int rc=SLURM_SUCCESS;
+	
+	if(!jobacct_pgsql_db) {
+		char *loc = slurm_get_jobacct_loc();
+		if(pgsql_jobacct_init(loc) == SLURM_ERROR) {
+			xfree(loc);
+			return SLURM_ERROR;
+		}
+		xfree(loc);
+	}
+	
+	debug2("pgsql_jobacct_job_complete() called");
+	if (job_ptr->end_time == 0) {
+		debug("pgsql_jobacct: job %u never started", job_ptr->job_id);
+		return SLURM_ERROR;
+	}	
+	
+	if (job_ptr->account && job_ptr->account[0])
+		account = job_ptr->account;
+	else
+		account = "(null)";
+	if (job_ptr->nodes && job_ptr->nodes[0])
+		nodes = job_ptr->nodes;
+	else
+		nodes = "(null)";
+
+	if(job_ptr->db_index) {
+		snprintf(query, sizeof(query),
+			 "update %s set start=%u, endtime=%u, state=%d, "
+			 "nodelist='%s', account='%s', "
+			 "kill_requid=%d where id=%u",
+			 job_table, (int)job_ptr->start_time,
+			 (int)job_ptr->end_time, 
+			 job_ptr->job_state & (~JOB_COMPLETING),
+			 nodes, account,
+			 job_ptr->requid, job_ptr->db_index);
+		rc = pgsql_db_query(jobacct_pgsql_db, jobacct_db_init, query);
+	} else 
+		rc = SLURM_ERROR;
+
+	return  rc;
+
+}
+
+extern int pgsql_jobacct_step_start(struct step_record *step_ptr)
+{
+	int cpus = 0;
+	int rc=SLURM_SUCCESS;
+	char node_list[BUFFER_SIZE];
+#ifdef HAVE_BG
+	char *ionodes = NULL;
+#endif
+	char query[1024];
+	
+	if(!jobacct_pgsql_db) {
+		char *loc = slurm_get_jobacct_loc();
+		if(pgsql_jobacct_init(loc) == SLURM_ERROR) {
+			xfree(loc);
+			return SLURM_ERROR;
+		}
+		xfree(loc);
+	}
+
+#ifdef HAVE_BG
+	cpus = step_ptr->job_ptr->num_procs;
+	select_g_get_jobinfo(step_ptr->job_ptr->select_jobinfo, 
+			     SELECT_DATA_IONODES, 
+			     &ionodes);
+	if(ionodes) {
+		snprintf(node_list, BUFFER_SIZE, 
+			 "%s[%s]", step_ptr->job_ptr->nodes, ionodes);
+		xfree(ionodes);
+	} else
+		snprintf(node_list, BUFFER_SIZE, "%s",
+			 step_ptr->job_ptr->nodes);
+	
+#else
+	if(!step_ptr->step_layout || !step_ptr->step_layout->task_cnt) {
+		cpus = step_ptr->job_ptr->num_procs;
+		snprintf(node_list, BUFFER_SIZE, "%s", step_ptr->job_ptr->nodes);
+	} else {
+		cpus = step_ptr->step_layout->task_cnt;
+		snprintf(node_list, BUFFER_SIZE, "%s", 
+			 step_ptr->step_layout->node_list);
+	}
+#endif
+	step_ptr->job_ptr->requid = -1; /* force to -1 for sacct to know this
+					 * hasn't been set yet  */
+
+	if(step_ptr->job_ptr->db_index) {
+		snprintf(query, sizeof(query),
+			 "insert into %s (id, stepid, start, name, state, "
+			 "cpus, nodelist, kill_requid) "
+			 "values (%d, %u, %u, '%s', %d, %u, '%s', %d)",
+			 step_table, step_ptr->job_ptr->db_index,
+			 step_ptr->step_id, 
+			 (int)step_ptr->start_time, step_ptr->name,
+			 JOB_RUNNING, cpus, node_list, 
+			 step_ptr->job_ptr->requid);
+		rc = pgsql_db_query(jobacct_pgsql_db, jobacct_db_init, query);
+		if(rc != SLURM_ERROR) {
+			snprintf(query, sizeof(query),
+				 "insert into %s (id, stepid) values (%d, %u)",
+				 rusage_table, step_ptr->job_ptr->db_index,
+				 step_ptr->step_id);
+			rc = pgsql_db_query(jobacct_pgsql_db,
+					    jobacct_db_init, query);
+		}	  
+	} else 
+		rc = SLURM_ERROR;
+		 
+	return rc;
+}
+
+extern int pgsql_jobacct_step_complete(struct step_record *step_ptr)
+{
+	time_t now;
+	int elapsed;
+	int comp_status;
+	int cpus = 0;
+	struct jobacctinfo *jobacct = (struct jobacctinfo *)step_ptr->jobacct;
+#ifdef HAVE_BG
+	char *ionodes = NULL;
+#endif
+	float ave_vsize = 0, ave_rss = 0, ave_pages = 0;
+	float ave_cpu = 0, ave_cpu2 = 0;
+	char *account;
+	char query[1024];
+	int rc =SLURM_SUCCESS;
+	
+	if(!jobacct_pgsql_db) {
+		char *loc = slurm_get_jobacct_loc();
+		if(pgsql_jobacct_init(loc) == SLURM_ERROR) {
+			xfree(loc);
+			return SLURM_ERROR;
+		}
+		xfree(loc);
+	}
+	
+	now = time(NULL);
+	
+	if ((elapsed=now-step_ptr->start_time)<0)
+		elapsed=0;	/* For *very* short jobs, if clock is wrong */
+	if (step_ptr->exit_code)
+		comp_status = JOB_FAILED;
+	else
+		comp_status = JOB_COMPLETE;
+
+#ifdef HAVE_BG
+	cpus = step_ptr->job_ptr->num_procs;
+	
+#else
+	if(!step_ptr->step_layout || !step_ptr->step_layout->task_cnt)
+		cpus = step_ptr->job_ptr->num_procs;
+	else 
+		cpus = step_ptr->step_layout->task_cnt;
+#endif
+	/* figure out the ave of the totals sent */
+	if(cpus > 0) {
+		ave_vsize = jobacct->tot_vsize;
+		ave_vsize /= cpus;
+		ave_rss = jobacct->tot_rss;
+		ave_rss /= cpus;
+		ave_pages = jobacct->tot_pages;
+		ave_pages /= cpus;
+		ave_cpu = jobacct->tot_cpu;
+		ave_cpu /= cpus;	
+		ave_cpu /= 100;
+	}
+ 
+	if(jobacct->min_cpu != (uint32_t)NO_VAL) {
+		ave_cpu2 = jobacct->min_cpu;
+		ave_cpu2 /= 100;
+	}
+
+	if (step_ptr->job_ptr->account && step_ptr->job_ptr->account[0])
+		account = step_ptr->job_ptr->account;
+	else
+		account = "(null)";
+
+	if(step_ptr->job_ptr->db_index) {
+		snprintf(query, sizeof(query),
+			 "update %s set endtime=%u, state=%d, "
+			 "kill_requid=%d, "
+			 "max_vsize=%u, max_vsize_task=%u, "
+			 "max_vsize_node=%u, ave_vsize=%.2f, "
+			 "max_rss=%u, max_rss_task=%u, "
+			 "max_rss_node=%u, ave_rss=%.2f, "
+			 "max_pages=%u, max_pages_task=%u, "
+			 "max_pages_node=%u, ave_pages=%.2f, "
+			 "min_cpu=%.2f, min_cpu_task=%u, "
+			 "min_cpu_node=%u, ave_cpu=%.2f "
+			 "where id=%u and stepid=%u",
+			 step_table, (int)now,
+			 comp_status,
+			 step_ptr->job_ptr->requid, 
+			 jobacct->max_vsize,	/* max vsize */
+			 jobacct->max_vsize_id.taskid,	/* max vsize task */
+			 jobacct->max_vsize_id.nodeid,	/* max vsize node */
+			 ave_vsize,	/* ave vsize */
+			 jobacct->max_rss,	/* max vsize */
+			 jobacct->max_rss_id.taskid,	/* max rss task */
+			 jobacct->max_rss_id.nodeid,	/* max rss node */
+			 ave_rss,	/* ave rss */
+			 jobacct->max_pages,	/* max pages */
+			 jobacct->max_pages_id.taskid,	/* max pages task */
+			 jobacct->max_pages_id.nodeid,	/* max pages node */
+			 ave_pages,	/* ave pages */
+			 ave_cpu2,	/* min cpu */
+			 jobacct->min_cpu_id.taskid,	/* min cpu task */
+			 jobacct->min_cpu_id.nodeid,	/* min cpu node */
+			 ave_cpu,	/* ave cpu */
+			 step_ptr->job_ptr->db_index, step_ptr->step_id);
+		rc = pgsql_db_query(jobacct_pgsql_db, jobacct_db_init, query);
+		if(rc != SLURM_ERROR) {
+			snprintf(query, sizeof(query),
+				 "update %s set id=%u, stepid=%u, "
+				 "cpu_sec=%ld, cpu_usec=%ld, "
+				 "user_sec=%ld, user_usec=%ld, "
+				 "sys_sec=%ld, sys_usec=%ld, "
+				 "max_rss=%ld, max_ixrss=%ld, max_idrss=%ld, "
+				 "max_isrss=%ld, max_minflt=%ld, "
+				 "max_majflt=%ld, max_nswap=%ld, "
+				 "inblock=%ld, outblock=%ld, msgsnd=%ld, "
+				 "msgrcv=%ld, nsignals=%ld, "
+				 "nvcsw=%ld, nivcsw=%ld "
+				 "where id=%u and stepid=%u",
+				 rusage_table, step_ptr->job_ptr->db_index,
+				 step_ptr->step_id,
+				 /* total cputime seconds */
+				 jobacct->rusage.ru_utime.tv_sec	
+				 + jobacct->rusage.ru_stime.tv_sec,
+				 /* total cputime seconds */
+				 jobacct->rusage.ru_utime.tv_usec	
+				 + jobacct->rusage.ru_stime.tv_usec,
+				 /* user seconds */
+				 jobacct->rusage.ru_utime.tv_sec,	
+				 /* user microseconds */
+				 jobacct->rusage.ru_utime.tv_usec,
+				 /* system seconds */
+				 jobacct->rusage.ru_stime.tv_sec,
+				 /* system microsecs */
+				 jobacct->rusage.ru_stime.tv_usec,
+				 /* max rss */
+				 jobacct->rusage.ru_maxrss,
+				 /* max ixrss */
+				 jobacct->rusage.ru_ixrss,
+				 /* max idrss */
+				 jobacct->rusage.ru_idrss,	
+				 /* max isrss */
+				 jobacct->rusage.ru_isrss,
+				 /* max minflt */
+				 jobacct->rusage.ru_minflt,
+				 /* max majflt */
+				 jobacct->rusage.ru_majflt,
+				 /* max nswap */
+				 jobacct->rusage.ru_nswap,
+				 /* total inblock */
+				 jobacct->rusage.ru_inblock,
+				 /* total outblock */
+				 jobacct->rusage.ru_oublock,
+				 /* total msgsnd */
+				 jobacct->rusage.ru_msgsnd,
+				 /* total msgrcv */
+				 jobacct->rusage.ru_msgrcv,
+				 /* total nsignals */
+				 jobacct->rusage.ru_nsignals,
+				 /* total nvcsw */
+				 jobacct->rusage.ru_nvcsw,
+				 /* total nivcsw */
+				 jobacct->rusage.ru_nivcsw,
+				 step_ptr->job_ptr->db_index,
+				 step_ptr->step_id);
+			
+			rc = pgsql_db_query(jobacct_pgsql_db, jobacct_db_init,
+					    query);
+		}
+	} else
+		rc = SLURM_ERROR;
+		 
+	return rc;
+}
+
+extern int pgsql_jobacct_suspend(struct job_record *job_ptr)
+{
+	char query[1024];
+	int rc = SLURM_SUCCESS;
+	
+	if(!jobacct_pgsql_db) {
+		char *loc = slurm_get_jobacct_loc();
+		if(pgsql_jobacct_init(loc) == SLURM_ERROR) {
+			xfree(loc);
+			return SLURM_ERROR;
+		}
+		xfree(loc);
+	}
+	
+	if(job_ptr->db_index) {
+		snprintf(query, sizeof(query),
+			 "update %s set suspended=%u-suspended, state=%d "
+			 "where id=%u",
+			 job_table, (int)job_ptr->suspend_time, 
+			 job_ptr->job_state & (~JOB_COMPLETING),
+			 job_ptr->db_index);
+		rc = pgsql_db_query(jobacct_pgsql_db, jobacct_db_init, query);
+		if(rc != SLURM_ERROR) {
+			snprintf(query, sizeof(query),
+				 "update %s set suspended=%u-suspended, "
+				 "state=%d where id=%u and endtime=0",
+				 step_table, (int)job_ptr->suspend_time, 
+				 job_ptr->job_state, job_ptr->db_index);
+			rc = pgsql_db_query(jobacct_pgsql_db, jobacct_db_init,
+					    query);			
+		}
+	} else
+		rc = SLURM_ERROR;
+	
+	return rc;
+}
+
+/* 
+ * get info from the database 
+ * returns List of job_rec_t *
+ * note List needs to be freed when called
+ */
+extern void pgsql_jobacct_get_jobs(List job_list,
+				   List selected_steps, List selected_parts,
+				   void *params)
+{
+	if(!jobacct_pgsql_db) {
+		char *loc = slurm_get_jobacct_loc();
+		if(pgsql_jobacct_init(loc) == SLURM_ERROR) {
+			xfree(loc);
+			return;
+		}
+		xfree(loc);
+	}
+
+	pgsql_jobacct_process_get_jobs(job_list,
+				       selected_steps, selected_parts,
+				       params);	
+	return;
+}
+
+/* 
+ * expire old info from the database 
+ */
+extern void pgsql_jobacct_archive(List selected_parts, void *params)
+{
+	if(!jobacct_pgsql_db) {
+		char *loc = slurm_get_jobacct_loc();
+		if(pgsql_jobacct_init(loc) == SLURM_ERROR) {
+			xfree(loc);
+			return;
+		}
+		xfree(loc);
+	}
+
+	pgsql_jobacct_process_archive(selected_parts, params);
+	return;
+}
+#endif
diff --git a/src/plugins/database/pgsql/pgsql_jobacct.h b/src/plugins/database/pgsql/pgsql_jobacct.h
new file mode 100644
index 0000000000000000000000000000000000000000..21a3dd1c0b21a65478588db3932a32029f8c52eb
--- /dev/null
+++ b/src/plugins/database/pgsql/pgsql_jobacct.h
@@ -0,0 +1,62 @@
+/*****************************************************************************\
+ *  pgsql_jobacct.h - functions the pgsql jobacct database.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+
+#ifndef _HAVE_PGSQL_JOBACCT_H
+#define _HAVE_PGSQL_JOBACCT_H
+
+#include "src/plugins/jobacct/common/jobacct_common.h"
+#include "src/slurmctld/slurmctld.h"
+#ifdef HAVE_PGSQL
+#include <libpq-fe.h>
+
+extern int pgsql_jobacct_init(char *location);
+extern int pgsql_jobacct_fini();
+extern int pgsql_jobacct_job_start(struct job_record *job_ptr);
+extern int pgsql_jobacct_job_complete(struct job_record *job_ptr);
+extern int pgsql_jobacct_step_start(struct step_record *step_ptr);
+extern int pgsql_jobacct_step_complete(struct step_record *step_ptr);
+extern int pgsql_jobacct_suspend(struct job_record *job_ptr);
+extern void pgsql_jobacct_get_jobs(List job_list,
+				   List selected_steps, List selected_parts,
+				   void *params);
+extern void pgsql_jobacct_archive(List selected_parts, void *params);
+#endif
+
+#endif
diff --git a/src/plugins/database/pgsql/pgsql_jobacct_process.c b/src/plugins/database/pgsql/pgsql_jobacct_process.c
new file mode 100644
index 0000000000000000000000000000000000000000..27706bd45d3289d90c300d7b20e9b3bdd9098cae
--- /dev/null
+++ b/src/plugins/database/pgsql/pgsql_jobacct_process.c
@@ -0,0 +1,523 @@
+/*****************************************************************************\
+ *  pgsql_jobacct_process.c - functions the processing of
+ *                               information from the pgsql jobacct
+ *                               database.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+
+#include <stdlib.h>
+#include "src/common/slurm_jobacct.h"
+#include "src/common/xstring.h"
+#include "pgsql_jobacct_process.h"
+
+#ifdef HAVE_PGSQL
+static void _do_fdump(List job_list)
+{
+	info("fdump option not applicable from pgsql plugin");
+	return;
+}
+
+extern void pgsql_jobacct_process_get_jobs(List job_list,
+					   List selected_steps,
+					   List selected_parts,
+					   sacct_parameters_t *params)
+{
+
+	char *query = NULL;	
+	char *extra = NULL;	
+	char *tmp = NULL;	
+	char *selected_part = NULL;
+	jobacct_selected_step_t *selected_step = NULL;
+	ListIterator itr = NULL;
+	int set = 0;
+	PGresult *result = NULL, *step_result = NULL;
+	int i, j;
+	jobacct_job_rec_t *job = NULL;
+	jobacct_step_rec_t *step = NULL;
+	jobacct_header_t header;
+	time_t now = time(NULL);
+
+	/* if this changes you will need to edit the corresponding 
+	 * enum below also t1 is index_table and t2 is job_table */
+	char *job_req_inx[] = {
+		"t1.id",
+		"t1.jobid",
+		"t1.partition",
+		"t1.submit",
+		"t2.start",
+		"t2.endtime",
+		"t2.suspended",
+		"t1.uid",
+		"t1.gid",
+		"t1.blockid",
+		"t2.name",
+		"t2.track_steps",
+		"t2.state",
+		"t2.priority",
+		"t2.cpus",
+		"t2.nodelist",
+		"t2.account",
+		"t2.kill_requid"
+	};
+
+	/* if this changes you will need to edit the corresponding 
+	 * enum below also t1 is step_table and t2 is step_rusage */
+	char *step_req_inx[] = {
+		"t1.stepid",
+		"t1.start",
+		"t1.endtime",
+		"t1.suspended",
+		"t1.name",
+		"t1.nodelist",
+		"t1.state",
+		"t1.kill_requid",
+		"t1.comp_code",
+		"t1.cpus",
+		"t1.max_vsize",
+		"t1.max_vsize_task",
+		"t1.max_vsize_node",
+		"t1.ave_vsize",
+		"t1.max_rss",
+		"t1.max_rss_task",
+		"t1.max_rss_node",
+		"t1.ave_rss",
+		"t1.max_pages",
+		"t1.max_pages_task",
+		"t1.max_pages_node",
+		"t1.ave_pages",
+		"t1.min_cpu",
+		"t1.min_cpu_task",
+		"t1.min_cpu_node",
+		"t1.ave_cpu",
+		"t2.cpu_sec",
+		"t2.cpu_usec",
+		"t2.user_sec",
+		"t2.user_usec",
+		"t2.sys_sec",
+		"t2.sys_usec",
+		"t2.max_rss",
+		"t2.max_ixrss",
+		"t2.max_idrss",
+		"t2.max_isrss",
+		"t2.max_minflt",
+		"t2.max_majflt",
+		"t2.max_nswap",
+		"t2.inblock",
+		"t2.outblock",
+		"t2.msgsnd",
+		"t2.msgrcv",
+		"t2.nsignals",
+		"t2.nvcsw",
+		"t2.nivcsw"
+	};
+	enum {
+		JOB_REQ_ID,
+		JOB_REQ_JOBID,
+		JOB_REQ_PARTITION,
+		JOB_REQ_SUBMIT,
+		JOB_REQ_START,
+		JOB_REQ_END,
+		JOB_REQ_SUSPENDED,
+		JOB_REQ_UID,
+		JOB_REQ_GID,
+		JOB_REQ_BLOCKID,
+		JOB_REQ_NAME,
+		JOB_REQ_TRACKSTEPS,
+		JOB_REQ_STATE,
+		JOB_REQ_PRIORITY,
+		JOB_REQ_CPUS,
+		JOB_REQ_NODELIST,
+		JOB_REQ_ACCOUNT,
+		JOB_REQ_KILL_REQUID,
+		JOB_REQ_COUNT		
+	};
+	enum {
+		STEP_REQ_STEPID,
+		STEP_REQ_START,
+		STEP_REQ_END,
+		STEP_REQ_SUSPENDED,
+		STEP_REQ_NAME,
+		STEP_REQ_NODELIST,
+		STEP_REQ_STATE,
+		STEP_REQ_KILL_REQUID,
+		STEP_REQ_COMP_CODE,
+		STEP_REQ_CPUS,
+		STEP_REQ_MAX_VSIZE,
+		STEP_REQ_MAX_VSIZE_TASK,
+		STEP_REQ_MAX_VSIZE_NODE,
+		STEP_REQ_AVE_VSIZE,
+		STEP_REQ_MAX_RSS,
+		STEP_REQ_MAX_RSS_TASK,
+		STEP_REQ_MAX_RSS_NODE,
+		STEP_REQ_AVE_RSS,
+		STEP_REQ_MAX_PAGES,
+		STEP_REQ_MAX_PAGES_TASK,
+		STEP_REQ_MAX_PAGES_NODE,
+		STEP_REQ_AVE_PAGES,
+		STEP_REQ_MIN_CPU,
+		STEP_REQ_MIN_CPU_TASK,
+		STEP_REQ_MIN_CPU_NODE,
+		STEP_REQ_AVE_CPU,
+		STEP_REQ_CPU_SEC,
+		STEP_REQ_CPU_USEC,
+		STEP_REQ_USER_SEC,
+		STEP_REQ_USER_USEC,
+		STEP_REQ_SYS_SEC,
+		STEP_REQ_SYS_USEC,
+		STEP_REQ_RSS,
+		STEP_REQ_IXRSS,
+		STEP_REQ_IDRSS,
+		STEP_REQ_ISRSS,
+		STEP_REQ_MINFLT,
+		STEP_REQ_MAJFLT,
+		STEP_REQ_NSWAP,
+		STEP_REQ_INBLOCKS,
+		STEP_REQ_OUTBLOCKS,
+		STEP_REQ_MSGSND,
+		STEP_REQ_MSGRCV,
+		STEP_REQ_NSIGNALS,
+		STEP_REQ_NVCSW,
+		STEP_REQ_NIVCSW,
+		STEP_REQ_COUNT
+	};
+
+	if(selected_steps && list_count(selected_steps)) {
+		set = 0;
+		xstrcat(extra, " and (");
+		itr = list_iterator_create(selected_steps);
+		while((selected_step = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " or ");
+			tmp = xstrdup_printf("t1.jobid=%d",
+					      selected_step->jobid);
+			xstrcat(extra, tmp);
+			set = 1;
+			xfree(tmp);
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+
+	if(selected_parts && list_count(selected_parts)) {
+		set = 0;
+		xstrcat(extra, " and (");
+		itr = list_iterator_create(selected_parts);
+		while((selected_part = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " or ");
+			tmp = xstrdup_printf("t1.partition='%s'",
+					      selected_part);
+			xstrcat(extra, tmp);
+			set = 1;
+			xfree(tmp);
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+	
+	for(i=0; i<JOB_REQ_COUNT; i++) {
+		if(i) 
+			xstrcat(tmp, ", ");
+		xstrcat(tmp, job_req_inx[i]);
+	}
+	
+	query = xstrdup_printf("select %s from %s t1, %s t2 where t1.id=t2.id",
+			       tmp, index_table, job_table);
+	xfree(tmp);
+
+	if(extra) {
+		xstrcat(query, extra);
+		xfree(extra);
+	}
+
+	//info("query = %s", query);
+	if(!(result =
+	     pgsql_db_query_ret(jobacct_pgsql_db, jobacct_db_init, query))) {
+		xfree(query);
+		return;
+	}
+	xfree(query);
+
+	for (i = 0; i < PQntuples(result); i++) {
+		time_t job_suspended = atoi(PQgetvalue(result, i,
+						       JOB_REQ_SUSPENDED));
+		char *id = PQgetvalue(result, i, JOB_REQ_ID);
+		header.jobnum = atoi(PQgetvalue(result, i, JOB_REQ_JOBID));
+		header.partition = xstrdup(PQgetvalue(result, i,
+						      JOB_REQ_PARTITION));
+		header.job_submit = atoi(PQgetvalue(result, i,
+						    JOB_REQ_SUBMIT));
+		header.timestamp = atoi(PQgetvalue(result, i, JOB_REQ_START));
+		header.uid = atoi(PQgetvalue(result, i, JOB_REQ_UID));
+		header.gid = atoi(PQgetvalue(result, i, JOB_REQ_GID));
+		header.blockid = xstrdup(PQgetvalue(result, i,
+						    JOB_REQ_BLOCKID));
+
+		job = jobacct_init_job_rec(header);
+		job->show_full = 1;
+		job->status = atoi(PQgetvalue(result, i, JOB_REQ_STATE));
+		job->jobname = xstrdup(PQgetvalue(result, i, JOB_REQ_NAME));
+		job->track_steps = atoi(PQgetvalue(result, i,
+						   JOB_REQ_TRACKSTEPS));
+		job->priority = atoi(PQgetvalue(result, i, JOB_REQ_PRIORITY));
+		job->ncpus = atoi(PQgetvalue(result, i, JOB_REQ_CPUS));
+		job->end = atoi(PQgetvalue(result, i, JOB_REQ_END));
+		job->nodes = xstrdup(PQgetvalue(result, i, JOB_REQ_NODELIST));
+		if (!strcmp(job->nodes, "(null)")) {
+			xfree(job->nodes);
+			job->nodes = xstrdup("(unknown)");
+		}
+		job->account = xstrdup(PQgetvalue(result, i, JOB_REQ_ACCOUNT));
+		list_append(job_list, job);
+
+		if(selected_steps && list_count(selected_steps)) {
+			set = 0;
+			itr = list_iterator_create(selected_steps);
+			while((selected_step = list_next(itr))) {
+				if(selected_step->jobid != header.jobnum) {
+					continue;
+				} else if (selected_step->stepid
+					   == (uint32_t)NO_VAL) {
+					job->show_full = 1;
+					break;
+				}
+				
+				if(set) 
+					xstrcat(extra, " or ");
+				else 
+					xstrcat(extra, " and (");
+			
+				tmp = xstrdup_printf("t1.stepid=%d",
+						     selected_step->stepid);
+				xstrcat(extra, tmp);
+				set = 1;
+				xfree(tmp);
+				job->show_full = 0;
+			}
+			list_iterator_destroy(itr);
+			if(set)
+				xstrcat(extra, ")");
+		}
+		for(j=0; j<STEP_REQ_COUNT; j++) {
+			if(j) 
+				xstrcat(tmp, ", ");
+			xstrcat(tmp, step_req_inx[j]);
+		}
+		
+		query =	xstrdup_printf("select %s from %s t1, "
+				       "%s t2 where t1.id=t2.id "
+				       "and t1.stepid=t2.stepid "
+				       "and t1.id=%s",
+				       tmp, step_table, rusage_table, id);
+		xfree(tmp);
+		
+		if(extra) {
+			xstrcat(query, extra);
+			xfree(extra);
+		}
+		
+		//info("query = %s", query);
+		if(!(step_result = pgsql_db_query_ret(
+			     jobacct_pgsql_db, jobacct_db_init, query))) {
+			xfree(query);
+			return;
+		}
+		xfree(query);
+		for(j = 0; j < PQntuples(step_result); j++) {
+			time_t suspended = 0;
+			/* we need to do this here for all the memory
+			   locations so we get new memory that will be
+			   freed later.
+			*/
+			header.partition = xstrdup(
+				PQgetvalue(result, j, JOB_REQ_PARTITION));
+			header.blockid = xstrdup(
+				PQgetvalue(result, j, JOB_REQ_BLOCKID));
+			header.timestamp = atoi(
+				PQgetvalue(step_result, j, STEP_REQ_START));
+			/* set start of job if not set */
+			if(job->header.timestamp < header.timestamp) {
+				job->header.timestamp = header.timestamp;
+			}
+			step = jobacct_init_step_rec(header);
+			list_append(job->steps, step);
+			step->stepnum = atoi(
+				PQgetvalue(step_result, j, STEP_REQ_STEPID));
+			/* info("got step %u.%u", */
+/* 			     job->header.jobnum, step->stepnum); */
+			step->status = atoi(
+				PQgetvalue(step_result, j, STEP_REQ_STATE));
+			step->exitcode = atoi(
+				PQgetvalue(step_result, j,
+					   STEP_REQ_COMP_CODE));
+			step->ntasks = atoi(
+				PQgetvalue(step_result, j, STEP_REQ_CPUS));
+			step->ncpus = atoi(
+				PQgetvalue(step_result, j, STEP_REQ_CPUS));
+			step->end = atoi(
+				PQgetvalue(step_result, j, STEP_REQ_END));
+			/* figure this out by start stop */
+			suspended = atoi(
+				PQgetvalue(step_result, j,
+					   STEP_REQ_SUSPENDED));
+			if(!step->end) {
+				step->elapsed = now - step->header.timestamp;
+			} else {
+				step->elapsed =
+					step->end - step->header.timestamp;
+			}
+			step->elapsed -= suspended;
+			step->tot_cpu_sec = atoi(
+				PQgetvalue(step_result, j, STEP_REQ_CPU_SEC));
+			step->tot_cpu_usec = atoi(
+				PQgetvalue(step_result, j, STEP_REQ_CPU_USEC));
+			step->rusage.ru_utime.tv_sec = atoi(
+				PQgetvalue(step_result, j, STEP_REQ_USER_SEC));
+			step->rusage.ru_utime.tv_usec = atoi(
+				PQgetvalue(step_result, j,
+					   STEP_REQ_USER_USEC));
+			step->rusage.ru_stime.tv_sec = atoi(
+				PQgetvalue(step_result, j, STEP_REQ_SYS_SEC));
+			step->rusage.ru_stime.tv_usec = atoi(
+				PQgetvalue(step_result, j, STEP_REQ_SYS_USEC));
+			step->rusage.ru_maxrss = atoi(
+				PQgetvalue(step_result, j, STEP_REQ_RSS));
+			step->rusage.ru_ixrss = atoi(
+				PQgetvalue(step_result, j, STEP_REQ_IXRSS));
+			step->rusage.ru_idrss = atoi(
+				PQgetvalue(step_result, j, STEP_REQ_IDRSS));
+			step->rusage.ru_isrss = atoi(
+				PQgetvalue(step_result, j, STEP_REQ_ISRSS));
+			step->rusage.ru_minflt = atoi(
+				PQgetvalue(step_result, j, STEP_REQ_MINFLT));
+			step->rusage.ru_majflt = atoi(
+				PQgetvalue(step_result, j, STEP_REQ_MAJFLT));
+			step->rusage.ru_nswap = atoi(
+				PQgetvalue(step_result, j, STEP_REQ_NSWAP));
+			step->rusage.ru_inblock = atoi(
+				PQgetvalue(step_result, j, STEP_REQ_INBLOCKS));
+			step->rusage.ru_oublock = atoi(
+				PQgetvalue(step_result, j,
+					   STEP_REQ_OUTBLOCKS));
+			step->rusage.ru_msgsnd = atoi(
+				PQgetvalue(step_result, j, STEP_REQ_MSGSND));
+			step->rusage.ru_msgrcv = atoi(
+				PQgetvalue(step_result, j, STEP_REQ_MSGRCV));
+			step->rusage.ru_nsignals = atoi(
+				PQgetvalue(step_result, j, STEP_REQ_NSIGNALS));
+			step->rusage.ru_nvcsw =	atoi(
+				PQgetvalue(step_result, j, STEP_REQ_NVCSW));
+			step->rusage.ru_nivcsw = atoi(
+				PQgetvalue(step_result, j, STEP_REQ_NIVCSW));
+			step->sacct.max_vsize =	atoi(
+				PQgetvalue(step_result, j,
+					   STEP_REQ_MAX_VSIZE)) * 1024;
+			step->sacct.max_vsize_id.taskid = atoi(
+				PQgetvalue(step_result, j,
+					   STEP_REQ_MAX_VSIZE_TASK));
+			step->sacct.ave_vsize =	atof(
+				PQgetvalue(step_result, j,
+					   STEP_REQ_AVE_VSIZE)) * 1024;
+			step->sacct.max_rss = atoi(
+				PQgetvalue(step_result, j,
+					   STEP_REQ_MAX_RSS)) * 1024;
+			step->sacct.max_rss_id.taskid =	atoi(
+				PQgetvalue(step_result, j,
+					   STEP_REQ_MAX_RSS_TASK));
+			step->sacct.ave_rss = atof(
+				PQgetvalue(step_result, j,
+					   STEP_REQ_AVE_RSS)) * 1024;
+			step->sacct.max_pages = atoi(
+				PQgetvalue(step_result, j,
+					   STEP_REQ_MAX_PAGES));
+			step->sacct.max_pages_id.taskid = atoi(
+				PQgetvalue(step_result, j,
+					   STEP_REQ_MAX_PAGES_TASK));
+			step->sacct.ave_pages = atof(
+				PQgetvalue(step_result, j,
+					   STEP_REQ_AVE_PAGES));
+			step->sacct.min_cpu = atof(
+				PQgetvalue(step_result, j, STEP_REQ_MIN_CPU));
+			step->sacct.min_cpu_id.taskid =	atoi(
+				PQgetvalue(step_result, j,
+					   STEP_REQ_MIN_CPU_TASK));
+			step->sacct.ave_cpu = atof(
+				PQgetvalue(step_result, j, STEP_REQ_AVE_CPU));
+			step->stepname = xstrdup(
+				PQgetvalue(step_result, j, STEP_REQ_NAME));
+			step->nodes = xstrdup(
+				PQgetvalue(step_result, j, STEP_REQ_NODELIST));
+			step->sacct.max_vsize_id.nodeid = atoi(
+				PQgetvalue(step_result, j,
+					   STEP_REQ_MAX_VSIZE_NODE));
+			step->sacct.max_rss_id.nodeid =	atoi(
+				PQgetvalue(step_result, j,
+					   STEP_REQ_MAX_RSS_NODE));
+			step->sacct.max_pages_id.nodeid = atoi(
+				PQgetvalue(step_result, j,
+					   STEP_REQ_MAX_PAGES_NODE));
+			step->sacct.min_cpu_id.nodeid =	atoi(
+				PQgetvalue(step_result, j,
+					   STEP_REQ_MIN_CPU_NODE));
+	
+			step->requid = atoi(PQgetvalue(step_result, j,
+						       STEP_REQ_KILL_REQUID));
+		}
+		PQclear(step_result);
+
+		if(!job->end) {
+			job->elapsed = now - job->header.timestamp;
+		} else {
+			job->elapsed = job->end - job->header.timestamp;
+		}
+		job->elapsed -= job_suspended;
+	}
+	PQclear(result);
+	if (params->opt_fdump) {
+		_do_fdump(job_list);
+	}
+	return;
+}
+
+extern void pgsql_jobacct_process_archive(List selected_parts,
+					  sacct_parameters_t *params)
+{
+	return;
+}
+
+#endif	
diff --git a/src/plugins/database/pgsql/pgsql_jobacct_process.h b/src/plugins/database/pgsql/pgsql_jobacct_process.h
new file mode 100644
index 0000000000000000000000000000000000000000..9f80fb0ad929efb02704493ed8b97dba69d56b53
--- /dev/null
+++ b/src/plugins/database/pgsql/pgsql_jobacct_process.h
@@ -0,0 +1,68 @@
+/*****************************************************************************\
+ *  pgsql_jobacct_process.h - functions the processing of
+ *                               information from the pgsql jobacct
+ *                               database.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+
+#ifndef _HAVE_PGSQL_JOBACCT_PROCESS_H
+#define _HAVE_PGSQL_JOBACCT_PROCESS_H
+
+#include "pgsql_common.h"
+#include "pgsql_jobacct.h"
+#include "src/common/slurm_jobacct.h"
+
+#ifdef HAVE_PGSQL
+extern PGconn *jobacct_pgsql_db;
+extern int jobacct_db_init;
+
+extern char *index_table;
+extern char *job_table;
+extern char *step_table;
+extern char *rusage_table;
+
+extern void pgsql_jobacct_process_get_jobs(List job_list,
+					   List selected_steps,
+					   List selected_parts,
+					   sacct_parameters_t *params);
+
+extern void pgsql_jobacct_process_archive(List selected_parts,
+					  sacct_parameters_t *params);
+#endif
+
+#endif
diff --git a/src/plugins/database/pgsql/pgsql_jobcomp.c b/src/plugins/database/pgsql/pgsql_jobcomp.c
new file mode 100644
index 0000000000000000000000000000000000000000..1702946a84111907ba3a3461e3babbc5ccd34e4e
--- /dev/null
+++ b/src/plugins/database/pgsql/pgsql_jobcomp.c
@@ -0,0 +1,351 @@
+/*****************************************************************************\
+ *  pgsql_jobcomp.c - text file slurm job completion logging plugin.
+ *****************************************************************************
+ *  Copyright (C) 2003 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Morris Jette <jette1@llnl.gov> et. al.
+ *  UCRL-CODE-226842.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#if HAVE_CONFIG_H
+#   include "config.h"
+#endif
+
+#if HAVE_STDINT_H
+#  include <stdint.h>
+#endif
+#if HAVE_INTTYPES_H
+#  include <inttypes.h>
+#endif
+
+#include "pgsql_common.h"
+#include "pgsql_jobcomp_process.h"
+#include <pwd.h>
+#include <sys/types.h>
+#include "src/common/parse_time.h"
+
+#ifdef HAVE_PGSQL
+
+#define DEFAULT_JOBCOMP_DB "slurm_jobcomp_db"
+
+PGconn *jobcomp_pgsql_db = NULL;
+int jobcomp_db_init = 0;
+
+char *jobcomp_table = "jobcomp_table";
+database_field_t jobcomp_table_fields[] = {
+	{ "jobid", "integer not null" },
+	{ "uid", "smallint not null" },
+	{ "user_name", "text not null" },
+	{ "gid", "smallint not null" },
+	{ "group_name", "text not null" },
+	{ "name", "text not null" },
+	{ "state", "smallint not null" },
+	{ "partition", "text not null" }, 
+	{ "timelimit", "text not null" },
+	{ "starttime", "bigint default 0" }, 
+	{ "endtime", "bigint default 0" },
+	{ "nodelist", "text" }, 
+	{ "nodecnt", "integer not null" },
+	{ "connection", "text" },
+	{ "reboot", "text" },
+	{ "rotate", "text" },
+	{ "maxprocs", "integer default 0" },
+	{ "geometry", "text" },
+	{ "start", "text" },
+	{ "blockid", "text" },
+	{ NULL, NULL}
+};
+
+/* Type for error string table entries */
+typedef struct {
+	int xe_number;
+	char *xe_message;
+} slurm_errtab_t;
+
+static slurm_errtab_t slurm_errtab[] = {
+	{0, "No error"},
+	{-1, "Unspecified error"}
+};
+
+/* A plugin-global errno. */
+static int plugin_errno = SLURM_SUCCESS;
+
+/* File descriptor used for logging */
+static pthread_mutex_t  jobcomp_lock = PTHREAD_MUTEX_INITIALIZER;
+
+
+static int _pgsql_jobcomp_check_tables(char *user)
+{
+
+	int i = 0, job_found = 0;
+	PGresult *result = NULL;
+	char *query = xstrdup_printf("select tablename from pg_tables "
+				     "where tableowner='%s' "
+				     "and tablename !~ '^pg_+'", user);
+
+	if(!(result =
+	     pgsql_db_query_ret(jobcomp_pgsql_db, jobcomp_db_init, query))) {
+		xfree(query);
+		return SLURM_ERROR;
+	}
+	xfree(query);
+
+	for (i = 0; i < PQntuples(result); i++) {
+		if(!job_found 
+		   && !strcmp(jobcomp_table, PQgetvalue(result, i, 0))) 
+			job_found = 1;
+	}
+	PQclear(result);
+
+	if(!job_found)
+		if(pgsql_db_create_table(jobcomp_pgsql_db, jobcomp_db_init, 
+					 jobcomp_table, jobcomp_table_fields,
+					 ")") == SLURM_ERROR)
+			return SLURM_ERROR;
+
+	return SLURM_SUCCESS;
+}
+
+
+/* get the user name for the give user_id */
+static char *_get_user_name(uint32_t user_id)
+{
+	static uint32_t cache_uid      = 0;
+	static char     cache_name[32] = "root";
+	struct passwd * user_info      = NULL;
+	char *ret_name = NULL;
+
+	slurm_mutex_lock(&jobcomp_lock);
+	if (user_id != cache_uid) {
+		user_info = getpwuid((uid_t) user_id);
+		if (user_info && user_info->pw_name[0])
+			snprintf(cache_name, sizeof(cache_name), "%s", 
+				user_info->pw_name);
+		else
+			snprintf(cache_name, sizeof(cache_name), "Unknown");
+		cache_uid = user_id;
+	}
+	ret_name = xstrdup(cache_name);
+	slurm_mutex_unlock(&jobcomp_lock);
+
+	return ret_name;
+}
+
+/* 
+ * Linear search through table of errno values and strings,
+ * returns NULL on error, string on success.
+ */
+static char *_lookup_slurm_api_errtab(int errnum)
+{
+	char *res = NULL;
+	int i;
+
+	for (i = 0; i < sizeof(slurm_errtab) / sizeof(slurm_errtab_t); i++) {
+		if (slurm_errtab[i].xe_number == errnum) {
+			res = slurm_errtab[i].xe_message;
+			break;
+		}
+	}
+	return res;
+}
+
+extern int pgsql_jobcomp_init(char *location)
+{
+	pgsql_db_info_t *db_info = create_pgsql_db_info();
+	int rc = SLURM_SUCCESS;
+	char *db_name = NULL;
+	int i = 0;
+	
+	if(jobcomp_db_init) 
+		return SLURM_ERROR;
+	
+	if(!location)
+		db_name = DEFAULT_JOBCOMP_DB;
+	else {
+		while(location[i]) {
+			if(location[i] == '.' || location[i] == '/') {
+				debug("%s doesn't look like a database "
+				      "name using %s",
+				      location, DEFAULT_JOBCOMP_DB);
+				break;
+			}
+			i++;
+		}
+		if(location[i]) 
+			db_name = DEFAULT_JOBCOMP_DB;
+		else
+			db_name = location;
+	}
+		
+	debug2("pgsql_connect() called for db %s", db_name);
+	
+	pgsql_get_db_connection(&jobcomp_pgsql_db, db_name, db_info,
+				&jobcomp_db_init);
+	
+	rc = _pgsql_jobcomp_check_tables(db_info->user);
+
+	destroy_pgsql_db_info(db_info);
+
+	if(rc == SLURM_SUCCESS) 
+		debug("Jobcomp database init finished");
+	else
+		debug("Jobcomp database init failed");
+	return rc;
+}
+
+extern int pgsql_jobcomp_fini()
+{
+	if (jobcomp_pgsql_db) {
+		PQfinish(jobcomp_pgsql_db);
+		jobcomp_pgsql_db = NULL;
+	}
+	jobcomp_db_init = 0;
+	return SLURM_SUCCESS;
+}
+
+extern int pgsql_jobcomp_get_errno()
+{
+	return plugin_errno;
+}
+
+extern int pgsql_jobcomp_log_record(struct job_record *job_ptr)
+{
+	int rc = SLURM_SUCCESS;
+	char *usr_str = NULL, lim_str[32];
+#ifdef HAVE_BG
+	char connection[128];
+	char reboot[4];
+	char rotate[4];
+	char maxprocs[20];
+	char geometry[20];
+	char start[20];
+	char blockid[128];
+#endif
+	enum job_states job_state;
+	char query[1024];
+
+	if(!jobcomp_pgsql_db) {
+		char *loc = slurm_get_jobcomp_loc();
+		if(pgsql_jobcomp_init(loc) == SLURM_ERROR) {
+			xfree(loc);
+			return SLURM_ERROR;
+		}
+		xfree(loc);
+	}
+
+	usr_str = _get_user_name(job_ptr->user_id);
+	if (job_ptr->time_limit == INFINITE)
+		strcpy(lim_str, "UNLIMITED");
+	else
+		snprintf(lim_str, sizeof(lim_str), "%lu", 
+				(unsigned long) job_ptr->time_limit);
+
+	/* Job will typically be COMPLETING when this is called. 
+	 * We remove this flag to get the eventual completion state:
+	 * JOB_FAILED, JOB_TIMEOUT, etc. */
+	job_state = job_ptr->job_state & (~JOB_COMPLETING);
+
+#ifdef HAVE_BG
+	select_g_sprint_jobinfo(job_ptr->select_jobinfo,
+		connection, sizeof(connection), SELECT_PRINT_CONNECTION);
+	select_g_sprint_jobinfo(job_ptr->select_jobinfo,
+		reboot, sizeof(reboot), SELECT_PRINT_REBOOT);
+	select_g_sprint_jobinfo(job_ptr->select_jobinfo,
+		rotate, sizeof(rotate), SELECT_PRINT_ROTATE);
+	select_g_sprint_jobinfo(job_ptr->select_jobinfo,
+		maxprocs, sizeof(maxprocs), SELECT_PRINT_MAX_PROCS);
+	select_g_sprint_jobinfo(job_ptr->select_jobinfo,
+		geometry, sizeof(geometry), SELECT_PRINT_GEOMETRY);
+	select_g_sprint_jobinfo(job_ptr->select_jobinfo,
+		start, sizeof(start), SELECT_PRINT_START);
+	select_g_sprint_jobinfo(job_ptr->select_jobinfo,
+		blockid, sizeof(blockid), SELECT_PRINT_BG_ID);
+#endif
+	snprintf(query, sizeof(query),
+		 "insert into %s (jobid, uid, user_name, name, state, "
+		 "partition, timelimit, starttime, endtime, nodelist, nodecnt"
+#ifdef HAVE_BG
+		 ", connection, reboot, rotate, maxprocs, geometry, "
+		 "start, blockid"
+#endif
+		 ") values (%u, %u, '%s', '%s', %d, '%s', '%s', %u, %u, "
+		 "'%s', %u"
+#ifdef HAVE_BG
+		 ", '%s', '%s', '%s', %s, '%s', '%s', '%s'"
+#endif
+		 ")",
+		 jobcomp_table, job_ptr->job_id, job_ptr->user_id, usr_str,
+		 job_ptr->name, job_state, job_ptr->partition, lim_str,
+		 (int)job_ptr->start_time, (int)job_ptr->end_time,
+		 job_ptr->nodes, job_ptr->node_cnt
+#ifdef HAVE_BG
+		 , connection, reboot, rotate, maxprocs, geometry,
+		 start, blockid
+#endif
+		 );
+	rc = pgsql_db_query(jobcomp_pgsql_db, jobcomp_db_init, query);
+	xfree(usr_str);
+
+	return rc;
+}
+
+extern char *pgsql_jobcomp_strerror( int errnum )
+{
+	char *res = _lookup_slurm_api_errtab(errnum);
+	return (res ? res : strerror(errnum));
+}
+
+/* 
+ * get info from the database 
+ * in/out job_list List of job_rec_t *
+ * note List needs to be freed when called
+ */
+extern void pgsql_jobcomp_get_jobs(List job_list, 
+				   List selected_steps, List selected_parts,
+				   void *params)
+{
+	pgsql_jobcomp_process_get_jobs(job_list, 
+				       selected_steps, selected_parts,
+				       params);	
+	return;
+}
+
+/* 
+ * expire old info from the database 
+ */
+extern void pgsql_jobcomp_archive(List selected_parts,
+				     void *params)
+{
+	pgsql_jobcomp_process_archive(selected_parts, params);
+	return;
+}
+
+#endif
diff --git a/src/plugins/database/pgsql/pgsql_jobcomp.h b/src/plugins/database/pgsql/pgsql_jobcomp.h
new file mode 100644
index 0000000000000000000000000000000000000000..c81a9aa40ea5cd98d92b26233398c974f5e2eb91
--- /dev/null
+++ b/src/plugins/database/pgsql/pgsql_jobcomp.h
@@ -0,0 +1,54 @@
+/*****************************************************************************\
+ *  pgsql_jobcomp.h - pgsql database slurm job completion logging plugin.
+ *****************************************************************************
+ *  Copyright (C) 2003 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Morris Jette <jette1@llnl.gov> et. al.
+ *  UCRL-CODE-226842.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#ifndef _PGSQL_JOBCOMP_H_
+#define _PGSQL_JOBCOMP_H_
+
+#include "src/slurmctld/slurmctld.h"
+
+extern int pgsql_jobcomp_init(char * location);
+extern int pgsql_jobcomp_fini();
+extern int pgsql_jobcomp_get_errno();
+extern int pgsql_jobcomp_log_record(struct job_record *job_ptr);
+extern char *pgsql_jobcomp_strerror(int errnum);
+extern void pgsql_jobcomp_get_jobs(List job_list, 
+				   List selected_steps,
+				   List selected_parts,
+				   void *params);
+extern void pgsql_jobcomp_archive(List selected_parts, void *params);
+
+#endif
diff --git a/src/plugins/database/pgsql/pgsql_jobcomp_process.c b/src/plugins/database/pgsql/pgsql_jobcomp_process.c
new file mode 100644
index 0000000000000000000000000000000000000000..200fd322a94c9fe94367be5dc3944c737068d0a8
--- /dev/null
+++ b/src/plugins/database/pgsql/pgsql_jobcomp_process.c
@@ -0,0 +1,207 @@
+/*****************************************************************************\
+ *  pgsql_jobcomp_process.c - functions the processing of
+ *                               information from the pgsql jobcomp
+ *                               database.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+
+#include <stdlib.h>
+#include "src/common/xstring.h"
+#include "pgsql_jobcomp_process.h"
+
+#ifdef HAVE_PGSQL
+static void _do_fdump(PGresult *result, int lc)
+{
+	int i = 0;
+	printf("\n------- Line %d -------\n", lc);	
+	while(jobcomp_table_fields[i].name) {
+		printf("%12s: %s\n",  jobcomp_table_fields[i].name, 
+		       PQgetvalue(result, lc, i));
+		i++;
+	}
+
+	return;
+}
+
+extern void pgsql_jobcomp_process_get_jobs(List job_list,
+					   List selected_steps,
+					   List selected_parts,
+					   sacct_parameters_t *params)
+{
+
+	char *query = NULL;	
+	char *extra = NULL;	
+	char *tmp = NULL;	
+	char *selected_part = NULL;
+	jobacct_selected_step_t *selected_step = NULL;
+	ListIterator itr = NULL;
+	int set = 0;
+	PGresult *result = NULL;
+	int i;
+	jobcomp_job_rec_t *job = NULL;
+
+	if(selected_steps && list_count(selected_steps)) {
+		set = 0;
+		xstrcat(extra, " where (");
+		itr = list_iterator_create(selected_steps);
+		while((selected_step = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			tmp = xstrdup_printf("jobid=%d",
+					      selected_step->jobid);
+			xstrcat(extra, tmp);
+			set = 1;
+			xfree(tmp);
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+
+	if(selected_parts && list_count(selected_parts)) {
+		set = 0;
+		if(extra)
+			xstrcat(extra, " && (");
+		else
+			xstrcat(extra, " where (");
+		
+		itr = list_iterator_create(selected_parts);
+		while((selected_part = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			tmp = xstrdup_printf("partition='%s'",
+					      selected_part);
+			xstrcat(extra, tmp);
+			set = 1;
+			xfree(tmp);
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+
+	i = 0;
+	while(jobcomp_table_fields[i].name) {
+		if(i) 
+			xstrcat(tmp, ", ");
+		xstrcat(tmp, jobcomp_table_fields[i].name);
+		i++;
+	}
+	
+	query = xstrdup_printf("select %s from %s", tmp, jobcomp_table);
+	xfree(tmp);
+
+	if(extra) {
+		xstrcat(query, extra);
+		xfree(extra);
+	}
+
+	//info("query = %s", query);
+	if(!(result =
+	     pgsql_db_query_ret(jobcomp_pgsql_db, jobcomp_db_init, query))) {
+		xfree(query);
+		return;
+	}
+	xfree(query);
+
+	for (i = 0; i < PQntuples(result); i++) {		
+		if (params->opt_fdump) {
+			_do_fdump(result, i);
+			continue;
+		}
+		job = xmalloc(sizeof(jobcomp_job_rec_t));
+		if(PQgetvalue(result, i, JOBCOMP_REQ_JOBID))
+			job->jobid = 
+				atoi(PQgetvalue(result, i, JOBCOMP_REQ_JOBID));
+		job->partition =
+			xstrdup(PQgetvalue(result, i, JOBCOMP_REQ_PARTITION));
+		job->start_time =
+			xstrdup(PQgetvalue(result, i, JOBCOMP_REQ_STARTTIME));
+		job->end_time =
+			xstrdup(PQgetvalue(result, i, JOBCOMP_REQ_ENDTIME));
+		if(PQgetvalue(result, i, JOBCOMP_REQ_UID))
+			job->uid =
+				atoi(PQgetvalue(result, i, JOBCOMP_REQ_UID));
+		job->uid_name =
+			xstrdup(PQgetvalue(result, i, JOBCOMP_REQ_USER_NAME));
+		if(PQgetvalue(result, i, JOBCOMP_REQ_GID))
+			job->gid =
+				atoi(PQgetvalue(result, i, JOBCOMP_REQ_GID));
+		job->gid_name = 
+			xstrdup(PQgetvalue(result, i, JOBCOMP_REQ_GROUP_NAME));
+		job->blockid =
+			xstrdup(PQgetvalue(result, i, JOBCOMP_REQ_BLOCKID));
+		job->jobname =
+			xstrdup(PQgetvalue(result, i, JOBCOMP_REQ_NAME));
+		job->nodelist =
+			xstrdup(PQgetvalue(result, i, JOBCOMP_REQ_NODELIST));
+		if(PQgetvalue(result, i, JOBCOMP_REQ_NODECNT))
+			job->node_cnt =
+				atoi(PQgetvalue(result, i, JOBCOMP_REQ_NODECNT));
+		if(PQgetvalue(result, i, JOBCOMP_REQ_MAXPROCS))
+			job->max_procs =
+				atoi(PQgetvalue(result, i, 
+						JOBCOMP_REQ_MAXPROCS));
+		if(PQgetvalue(result, i, JOBCOMP_REQ_STATE)) {
+			i = atoi(PQgetvalue(result, i, JOBCOMP_REQ_STATE));
+			job->state = xstrdup(job_state_string(i));
+		}
+		job->timelimit =
+			xstrdup(PQgetvalue(result, i, JOBCOMP_REQ_TIMELIMIT));
+		job->connection =
+			xstrdup(PQgetvalue(result, i, JOBCOMP_REQ_CONNECTION));
+		job->reboot =
+			xstrdup(PQgetvalue(result, i, JOBCOMP_REQ_REBOOT));
+		job->rotate =
+			xstrdup(PQgetvalue(result, i, JOBCOMP_REQ_ROTATE));
+		job->geo = 
+			xstrdup(PQgetvalue(result, i, JOBCOMP_REQ_GEOMETRY));
+		job->bg_start_point =
+			xstrdup(PQgetvalue(result, i, JOBCOMP_REQ_START));
+		list_append(job_list, job);
+
+	}
+	PQclear(result);
+	return;
+}
+
+extern void pgsql_jobcomp_process_archive(List selected_parts,
+					  sacct_parameters_t *params)
+{
+	return;
+}
+
+#endif	
diff --git a/src/plugins/database/pgsql/pgsql_jobcomp_process.h b/src/plugins/database/pgsql/pgsql_jobcomp_process.h
new file mode 100644
index 0000000000000000000000000000000000000000..139da2815b971e9dc2b8f84bea4f7f9793dcab63
--- /dev/null
+++ b/src/plugins/database/pgsql/pgsql_jobcomp_process.h
@@ -0,0 +1,94 @@
+/*****************************************************************************\
+ *  pgsql_jobcomp_process.h - functions the processing of
+ *                               information from the pgsql jobcomp
+ *                               database.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+
+#ifndef _HAVE_PGSQL_JOBCOMP_PROCESS_H
+#define _HAVE_PGSQL_JOBCOMP_PROCESS_H
+
+#include "pgsql_common.h"
+#include "pgsql_jobcomp.h"
+#include "src/common/slurm_jobacct.h"
+#include "src/common/slurm_jobcomp.h"
+
+#ifdef HAVE_PGSQL
+extern PGconn *jobcomp_pgsql_db;
+extern int jobcomp_db_init;
+
+extern char *jobcomp_table;
+/* This variable and the following enum are related so if you change
+   the jobcomp_table_fields defined in mysql_jobcomp.c you must update
+   this enum accordingly.
+*/
+extern database_field_t jobcomp_table_fields[];
+enum {
+	JOBCOMP_REQ_JOBID,
+	JOBCOMP_REQ_UID,
+	JOBCOMP_REQ_USER_NAME,
+	JOBCOMP_REQ_GID,
+	JOBCOMP_REQ_GROUP_NAME,
+	JOBCOMP_REQ_NAME,
+	JOBCOMP_REQ_STATE,
+	JOBCOMP_REQ_PARTITION,
+	JOBCOMP_REQ_TIMELIMIT,
+	JOBCOMP_REQ_STARTTIME,
+	JOBCOMP_REQ_ENDTIME,
+	JOBCOMP_REQ_NODELIST,
+	JOBCOMP_REQ_NODECNT,
+	JOBCOMP_REQ_CONNECTION,
+	JOBCOMP_REQ_REBOOT,
+	JOBCOMP_REQ_ROTATE,
+	JOBCOMP_REQ_MAXPROCS,
+	JOBCOMP_REQ_GEOMETRY,
+	JOBCOMP_REQ_START,
+	JOBCOMP_REQ_BLOCKID,
+	JOBCOMP_REQ_COUNT		
+};
+
+extern void pgsql_jobcomp_process_get_jobs(List job_list,
+					   List selected_steps,
+					   List selected_parts,
+					   sacct_parameters_t *params);
+
+extern void pgsql_jobcomp_process_archive(List selected_parts,
+					  sacct_parameters_t *params);
+#endif
+
+#endif
diff --git a/src/plugins/jobacct/Makefile.in b/src/plugins/jobacct/Makefile.in
index a2a82460e54d7535e70d28c717c5f0c8f5d31df9..3c7b554aa37e39405c2b730f1efba1db4217e648 100644
--- a/src/plugins/jobacct/Makefile.in
+++ b/src/plugins/jobacct/Makefile.in
@@ -43,6 +43,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -114,6 +115,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -137,6 +139,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -148,6 +151,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/jobacct/aix/Makefile.am b/src/plugins/jobacct/aix/Makefile.am
index 0c59144ddc68b4b871af9edd02e500e865eff601..464699ba5e5b7325531aa526b047bed2e1eaab40 100644
--- a/src/plugins/jobacct/aix/Makefile.am
+++ b/src/plugins/jobacct/aix/Makefile.am
@@ -17,3 +17,5 @@ jobacct_aix_la_SOURCES = jobacct_aix.c \
 	$(top_builddir)/src/slurmd/common/proctrack.h 
 
 jobacct_aix_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
+jobacct_aix_la_LIBADD  =  \
+	$(top_builddir)/src/common/libcommon.la -lpthread 
diff --git a/src/plugins/jobacct/aix/Makefile.in b/src/plugins/jobacct/aix/Makefile.in
index 6ff4b504815319a250809a5f27e099273ff9e3ba..c659a3aeb0c8aaa5e2a61ad402ff169c87cd8c1e 100644
--- a/src/plugins/jobacct/aix/Makefile.in
+++ b/src/plugins/jobacct/aix/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -73,7 +74,7 @@ am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
 am__installdirs = "$(DESTDIR)$(pkglibdir)"
 pkglibLTLIBRARIES_INSTALL = $(INSTALL)
 LTLIBRARIES = $(pkglib_LTLIBRARIES)
-jobacct_aix_la_LIBADD =
+jobacct_aix_la_DEPENDENCIES = $(top_builddir)/src/common/libcommon.la
 am_jobacct_aix_la_OBJECTS = jobacct_aix.lo jobacct_common.lo \
 	common_slurmctld.lo common_slurmstepd.lo proctrack.lo
 jobacct_aix_la_OBJECTS = $(am_jobacct_aix_la_OBJECTS)
@@ -133,6 +134,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -156,6 +158,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -167,6 +170,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -266,6 +271,9 @@ jobacct_aix_la_SOURCES = jobacct_aix.c \
 	$(top_builddir)/src/slurmd/common/proctrack.h 
 
 jobacct_aix_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
+jobacct_aix_la_LIBADD = \
+	$(top_builddir)/src/common/libcommon.la -lpthread 
+
 all: all-am
 
 .SUFFIXES:
diff --git a/src/plugins/jobacct/aix/jobacct_aix.c b/src/plugins/jobacct/aix/jobacct_aix.c
index 4d2d7ac8c57706fd14900ef680424b1123f3a08f..d8e3640c2550c83106923a7e1fc54c4cf928cbb0 100644
--- a/src/plugins/jobacct/aix/jobacct_aix.c
+++ b/src/plugins/jobacct/aix/jobacct_aix.c
@@ -191,38 +191,39 @@ int jobacct_p_unpack(struct jobacctinfo **jobacct, Buf buffer)
 
 int jobacct_p_init_slurmctld(char *job_acct_log)
 {
-	return common_init_slurmctld(job_acct_log);
+	return database_g_jobacct_init(job_acct_log);
 }
 
 int jobacct_p_fini_slurmctld()
 {
-	return common_fini_slurmctld();
+	return database_g_jobacct_fini();
 }
 
 int jobacct_p_job_start_slurmctld(struct job_record *job_ptr)
 {
-	return common_job_start_slurmctld(job_ptr);
+	return database_g_jobacct_job_start(job_ptr);
 }
 
 int jobacct_p_job_complete_slurmctld(struct job_record *job_ptr) 
 {
-	return  common_job_complete_slurmctld(job_ptr);
+	return database_g_jobacct_job_complete(job_ptr);
 }
 
 int jobacct_p_step_start_slurmctld(struct step_record *step)
 {
-	return common_step_start_slurmctld(step);	
+	return database_g_jobacct_step_start(step);	
 }
 
 int jobacct_p_step_complete_slurmctld(struct step_record *step)
 {
-	return common_step_complete_slurmctld(step);	
+	return database_g_jobacct_step_complete(step);	
 }
 
 int jobacct_p_suspend_slurmctld(struct job_record *job_ptr)
 {
-	return common_suspend_slurmctld(job_ptr);
+	return database_g_jobacct_job_suspend(job_ptr);
 }
+
 /*
  * jobacct_startpoll() is called when the plugin is loaded by
  * slurmd, before any other functions are called.  Put global
diff --git a/src/plugins/jobacct/common/common_slurmctld.c b/src/plugins/jobacct/common/common_slurmctld.c
index 22a442d0f056cc83d850b3e15f2018c2917b72bd..56006050294e709cffb8d2c91591215d405f88f6 100644
--- a/src/plugins/jobacct/common/common_slurmctld.c
+++ b/src/plugins/jobacct/common/common_slurmctld.c
@@ -365,7 +365,7 @@ extern int common_step_start_slurmctld(struct step_record *step)
 
 extern int common_step_complete_slurmctld(struct step_record *step)
 {
-		char buf[BUFFER_SIZE];
+	char buf[BUFFER_SIZE];
 	time_t now;
 	int elapsed;
 	int comp_status;
diff --git a/src/plugins/jobacct/common/jobacct_common.c b/src/plugins/jobacct/common/jobacct_common.c
index afa63b949d397a0fc9dc1130d9c8a874183501b8..70fa191cfeb27c0411339fecbc2f2bcf9a640faa 100644
--- a/src/plugins/jobacct/common/jobacct_common.c
+++ b/src/plugins/jobacct/common/jobacct_common.c
@@ -15,7 +15,7 @@
  *  any later version.
  *
  *  In addition, as a special exception, the copyright holders give permission 
- *  to link the code of portions of this program with the OpenSSL library under 
+ *  to link the code of portions of this program with the OpenSSL library under
  *  certain conditions as described in each individual source file, and 
  *  distribute linked combinations including the two. You must obey the GNU 
  *  General Public License in all respects for all of the code used other than 
diff --git a/src/plugins/jobacct/common/jobacct_common.h b/src/plugins/jobacct/common/jobacct_common.h
index 47fc72ee1620e44eb0f4b4f8f42f1bc7053e0ff0..1ec5ee614a62f7fd473926e06eb7c365c24e83bd 100644
--- a/src/plugins/jobacct/common/jobacct_common.h
+++ b/src/plugins/jobacct/common/jobacct_common.h
@@ -56,6 +56,7 @@
 #include <sys/stat.h>
 
 #include "src/common/slurm_jobacct.h"
+#include "src/common/slurm_database.h"
 #include "src/common/xmalloc.h"
 #include "src/common/list.h"
 #include "src/common/xstring.h"
diff --git a/src/plugins/jobacct/linux/Makefile.am b/src/plugins/jobacct/linux/Makefile.am
index abf998966aed3800df8479acc255b4a0334ecb0f..fa5d8bfaf0d2e063b34fd93e29574c7a02645dda 100644
--- a/src/plugins/jobacct/linux/Makefile.am
+++ b/src/plugins/jobacct/linux/Makefile.am
@@ -17,3 +17,5 @@ jobacct_linux_la_SOURCES = jobacct_linux.c \
 	$(top_builddir)/src/slurmd/common/proctrack.h 
 
 jobacct_linux_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
+jobacct_linux_la_LIBADD  =  \
+	$(top_builddir)/src/common/libcommon.la -lpthread 
diff --git a/src/plugins/jobacct/linux/Makefile.in b/src/plugins/jobacct/linux/Makefile.in
index f2ef24897aee1e90cf5041845de3dc336e168898..6888d111a6943a28c56993016003963c27085401 100644
--- a/src/plugins/jobacct/linux/Makefile.in
+++ b/src/plugins/jobacct/linux/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -73,7 +74,8 @@ am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
 am__installdirs = "$(DESTDIR)$(pkglibdir)"
 pkglibLTLIBRARIES_INSTALL = $(INSTALL)
 LTLIBRARIES = $(pkglib_LTLIBRARIES)
-jobacct_linux_la_LIBADD =
+jobacct_linux_la_DEPENDENCIES =  \
+	$(top_builddir)/src/common/libcommon.la
 am_jobacct_linux_la_OBJECTS = jobacct_linux.lo jobacct_common.lo \
 	common_slurmctld.lo common_slurmstepd.lo proctrack.lo
 jobacct_linux_la_OBJECTS = $(am_jobacct_linux_la_OBJECTS)
@@ -133,6 +135,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -156,6 +159,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -167,6 +171,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -266,6 +272,9 @@ jobacct_linux_la_SOURCES = jobacct_linux.c \
 	$(top_builddir)/src/slurmd/common/proctrack.h 
 
 jobacct_linux_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
+jobacct_linux_la_LIBADD = \
+	$(top_builddir)/src/common/libcommon.la -lpthread 
+
 all: all-am
 
 .SUFFIXES:
diff --git a/src/plugins/jobacct/linux/jobacct_linux.c b/src/plugins/jobacct/linux/jobacct_linux.c
index 461157c43fbc18f3f3a8127122ce2772c032c94e..b9029783612e46221e2c85ebd821e04592e10a04 100644
--- a/src/plugins/jobacct/linux/jobacct_linux.c
+++ b/src/plugins/jobacct/linux/jobacct_linux.c
@@ -178,37 +178,37 @@ int jobacct_p_unpack(struct jobacctinfo **jobacct, Buf buffer)
 
 int jobacct_p_init_slurmctld(char *job_acct_log)
 {
-	return common_init_slurmctld(job_acct_log);
+	return database_g_jobacct_init(job_acct_log);
 }
 
 int jobacct_p_fini_slurmctld()
 {
-	return common_fini_slurmctld();
+	return database_g_jobacct_fini();
 }
 
 int jobacct_p_job_start_slurmctld(struct job_record *job_ptr)
 {
-	return common_job_start_slurmctld(job_ptr);
+	return database_g_jobacct_job_start(job_ptr);
 }
 
 int jobacct_p_job_complete_slurmctld(struct job_record *job_ptr) 
 {
-	return  common_job_complete_slurmctld(job_ptr);
+	return database_g_jobacct_job_complete(job_ptr);
 }
 
 int jobacct_p_step_start_slurmctld(struct step_record *step)
 {
-	return common_step_start_slurmctld(step);	
+	return database_g_jobacct_step_start(step);	
 }
 
 int jobacct_p_step_complete_slurmctld(struct step_record *step)
 {
-	return common_step_complete_slurmctld(step);	
+	return database_g_jobacct_step_complete(step);	
 }
 
 int jobacct_p_suspend_slurmctld(struct job_record *job_ptr)
 {
-	return common_suspend_slurmctld(job_ptr);
+	return database_g_jobacct_job_suspend(job_ptr);
 }
 
 /*
diff --git a/src/plugins/jobacct/none/Makefile.in b/src/plugins/jobacct/none/Makefile.in
index acd2728a6f80d622155edcecd69a98fad41b0705..f033ad5d075282940c3758b8bf722723b68202d5 100644
--- a/src/plugins/jobacct/none/Makefile.in
+++ b/src/plugins/jobacct/none/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -132,6 +133,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -155,6 +157,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -166,6 +169,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/jobcomp/Makefile.am b/src/plugins/jobcomp/Makefile.am
index 49d7c632bef5d37b5a62c36ebc2170c3e26768b3..ff14f783fdf37796e6e14a0ae40d580623074fc7 100644
--- a/src/plugins/jobcomp/Makefile.am
+++ b/src/plugins/jobcomp/Makefile.am
@@ -1,3 +1,3 @@
 # Makefile for jobcomp plugins
 
-SUBDIRS = filetxt none script
+SUBDIRS = filetxt none script database
diff --git a/src/plugins/jobcomp/Makefile.in b/src/plugins/jobcomp/Makefile.in
index 0d5c5b51feca6e3b7e1319882d64212a4a632237..3f0c2468bc71400c42a240be2afa90bf6170bb95 100644
--- a/src/plugins/jobcomp/Makefile.in
+++ b/src/plugins/jobcomp/Makefile.in
@@ -43,6 +43,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -114,6 +115,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -137,6 +139,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -148,6 +151,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -233,7 +238,7 @@ target_os = @target_os@
 target_vendor = @target_vendor@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-SUBDIRS = filetxt none script
+SUBDIRS = filetxt none script database
 all: all-recursive
 
 .SUFFIXES:
diff --git a/src/plugins/jobcomp/database/Makefile.am b/src/plugins/jobcomp/database/Makefile.am
new file mode 100644
index 0000000000000000000000000000000000000000..b56efc2be0a6d5ac1f6f5965b8f4366532a538e3
--- /dev/null
+++ b/src/plugins/jobcomp/database/Makefile.am
@@ -0,0 +1,18 @@
+# Makefile for jobcomp/database plugin
+
+AUTOMAKE_OPTIONS = foreign
+
+PLUGIN_FLAGS = -module -avoid-version --export-dynamic 
+
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
+
+pkglib_LTLIBRARIES = jobcomp_database.la
+
+# Database job completion logging plugin.
+jobcomp_database_la_SOURCES = jobcomp_database.c
+jobcomp_database_la_LIBADD  =  \
+	$(top_builddir)/src/common/libcommon.la -lpthread
+
+jobcomp_database_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
+jobcomp_database_la_DEPENDENCIES  = \
+	$(top_builddir)/src/common/libcommon.la
diff --git a/src/plugins/jobcomp/database/Makefile.in b/src/plugins/jobcomp/database/Makefile.in
new file mode 100644
index 0000000000000000000000000000000000000000..4a8a0da57fe4756e669f828966c7aa81c8f6bd0e
--- /dev/null
+++ b/src/plugins/jobcomp/database/Makefile.in
@@ -0,0 +1,552 @@
+# Makefile.in generated by automake 1.10 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# Makefile for jobcomp/database plugin
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/plugins/jobcomp/database
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
+	$(top_srcdir)/auxdir/slurm.m4 \
+	$(top_srcdir)/auxdir/x_ac__system_configuration.m4 \
+	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
+	$(top_srcdir)/auxdir/x_ac_aix.m4 \
+	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
+	$(top_srcdir)/auxdir/x_ac_debug.m4 \
+	$(top_srcdir)/auxdir/x_ac_elan.m4 \
+	$(top_srcdir)/auxdir/x_ac_federation.m4 \
+	$(top_srcdir)/auxdir/x_ac_gpl_licensed.m4 \
+	$(top_srcdir)/auxdir/x_ac_gtk.m4 \
+	$(top_srcdir)/auxdir/x_ac_munge.m4 \
+	$(top_srcdir)/auxdir/x_ac_ncurses.m4 \
+	$(top_srcdir)/auxdir/x_ac_pam.m4 \
+	$(top_srcdir)/auxdir/x_ac_ptrace.m4 \
+	$(top_srcdir)/auxdir/x_ac_readline.m4 \
+	$(top_srcdir)/auxdir/x_ac_setpgrp.m4 \
+	$(top_srcdir)/auxdir/x_ac_setproctitle.m4 \
+	$(top_srcdir)/auxdir/x_ac_sgi_job.m4 \
+	$(top_srcdir)/auxdir/x_ac_slurm_ssl.m4 \
+	$(top_srcdir)/auxdir/x_ac_xcpu.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/slurm/slurm.h
+CONFIG_CLEAN_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(pkglibdir)"
+pkglibLTLIBRARIES_INSTALL = $(INSTALL)
+LTLIBRARIES = $(pkglib_LTLIBRARIES)
+am_jobcomp_database_la_OBJECTS = jobcomp_database.lo
+jobcomp_database_la_OBJECTS = $(am_jobcomp_database_la_OBJECTS)
+jobcomp_database_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(jobcomp_database_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
+SOURCES = $(jobcomp_database_la_SOURCES)
+DIST_SOURCES = $(jobcomp_database_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTHD_CFLAGS = @AUTHD_CFLAGS@
+AUTHD_LIBS = @AUTHD_LIBS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BG_INCLUDES = @BG_INCLUDES@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CMD_LDFLAGS = @CMD_LDFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ELAN_LIBS = @ELAN_LIBS@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FEDERATION_LDFLAGS = @FEDERATION_LDFLAGS@
+FFLAGS = @FFLAGS@
+GREP = @GREP@
+GTK2_CFLAGS = @GTK2_CFLAGS@
+GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
+HAVEPKGCONFIG = @HAVEPKGCONFIG@
+HAVE_AIX = @HAVE_AIX@
+HAVE_ELAN = @HAVE_ELAN@
+HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_LDFLAGS = @LIB_LDFLAGS@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
+MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
+MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
+NCURSES = @NCURSES@
+NUMA_LIBS = @NUMA_LIBS@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PAM_LIBS = @PAM_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
+PLPA_LIBS = @PLPA_LIBS@
+PROCTRACKDIR = @PROCTRACKDIR@
+PROJECT = @PROJECT@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+RELEASE = @RELEASE@
+SEMAPHORE_LIBS = @SEMAPHORE_LIBS@
+SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMD_PORT = @SLURMD_PORT@
+SLURM_API_AGE = @SLURM_API_AGE@
+SLURM_API_CURRENT = @SLURM_API_CURRENT@
+SLURM_API_MAJOR = @SLURM_API_MAJOR@
+SLURM_API_REVISION = @SLURM_API_REVISION@
+SLURM_API_VERSION = @SLURM_API_VERSION@
+SLURM_MAJOR = @SLURM_MAJOR@
+SLURM_MICRO = @SLURM_MICRO@
+SLURM_MINOR = @SLURM_MINOR@
+SLURM_VERSION = @SLURM_VERSION@
+SO_LDFLAGS = @SO_LDFLAGS@
+SSL_CPPFLAGS = @SSL_CPPFLAGS@
+SSL_LDFLAGS = @SSL_LDFLAGS@
+SSL_LIBS = @SSL_LIBS@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign
+PLUGIN_FLAGS = -module -avoid-version --export-dynamic 
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
+pkglib_LTLIBRARIES = jobcomp_database.la
+
+# Database job completion logging plugin.
+jobcomp_database_la_SOURCES = jobcomp_database.c
+jobcomp_database_la_LIBADD = \
+	$(top_builddir)/src/common/libcommon.la -lpthread
+
+jobcomp_database_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
+jobcomp_database_la_DEPENDENCIES = \
+	$(top_builddir)/src/common/libcommon.la
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/plugins/jobcomp/database/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  src/plugins/jobcomp/database/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
+	@$(NORMAL_INSTALL)
+	test -z "$(pkglibdir)" || $(MKDIR_P) "$(DESTDIR)$(pkglibdir)"
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  if test -f $$p; then \
+	    f=$(am__strip_dir) \
+	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	  else :; fi; \
+	done
+
+uninstall-pkglibLTLIBRARIES:
+	@$(NORMAL_UNINSTALL)
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  p=$(am__strip_dir) \
+	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	done
+
+clean-pkglibLTLIBRARIES:
+	-test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES)
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+jobcomp_database.la: $(jobcomp_database_la_OBJECTS) $(jobcomp_database_la_DEPENDENCIES) 
+	$(jobcomp_database_la_LINK) -rpath $(pkglibdir) $(jobcomp_database_la_OBJECTS) $(jobcomp_database_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jobcomp_database.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+	for dir in "$(DESTDIR)$(pkglibdir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-pkglibLTLIBRARIES
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pkglibLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-pkglibLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-pkglibLTLIBRARIES \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-pkglibLTLIBRARIES
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/plugins/jobcomp/database/jobcomp_database.c b/src/plugins/jobcomp/database/jobcomp_database.c
new file mode 100644
index 0000000000000000000000000000000000000000..21fbbc01fc1e595aef2ea79c3e1ac392e204e9fc
--- /dev/null
+++ b/src/plugins/jobcomp/database/jobcomp_database.c
@@ -0,0 +1,123 @@
+/*****************************************************************************\
+ *  jobcomp_database.c - text file slurm job completion logging plugin.
+ *****************************************************************************
+ *  Copyright (C) 2003 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Morris Jette <jette1@llnl.gov> et. al.
+ *  UCRL-CODE-226842.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#if HAVE_CONFIG_H
+#   include "config.h"
+#endif
+
+#if HAVE_STDINT_H
+#  include <stdint.h>
+#endif
+#if HAVE_INTTYPES_H
+#  include <inttypes.h>
+#endif
+
+#include "src/slurmctld/slurmctld.h"
+#include "src/common/slurm_database.h"
+
+/*
+ * These variables are required by the generic plugin interface.  If they
+ * are not found in the plugin, the plugin loader will ignore it.
+ *
+ * plugin_name - a string giving a human-readable description of the
+ * plugin.  There is no maximum length, but the symbol must refer to
+ * a valid string.
+ *
+ * plugin_type - a string suggesting the type of the plugin or its
+ * applicability to a particular form of data or method of data handling.
+ * If the low-level plugin API is used, the contents of this string are
+ * unimportant and may be anything.  SLURM uses the higher-level plugin
+ * interface which requires this string to be of the form
+ *
+ *	<application>/<method>
+ *
+ * where <application> is a description of the intended application of
+ * the plugin (e.g., "jobcomp" for SLURM job completion logging) and <method>
+ * is a description of how this plugin satisfies that application.  SLURM will
+ * only load job completion logging plugins if the plugin_type string has a 
+ * prefix of "jobcomp/".
+ *
+ * plugin_version - an unsigned 32-bit integer giving the version number
+ * of the plugin.  If major and minor revisions are desired, the major
+ * version number may be multiplied by a suitable magnitude constant such
+ * as 100 or 1000.  Various SLURM versions will likely require a certain
+ * minimum versions for their plugins as the job completion logging API 
+ * matures.
+ */
+const char plugin_name[]       	= "Job completion database logging plugin";
+const char plugin_type[]       	= "jobcomp/database";
+const uint32_t plugin_version	= 10;
+
+/*
+ * init() is called when the plugin is loaded, before any other functions
+ * are called.  Put global initialization here.
+ */
+int init ( void )
+{
+	return SLURM_SUCCESS;
+}
+
+int fini ( void )
+{
+	return database_g_jobcomp_fini();
+}
+
+/*
+ * The remainder of this file implements the standard SLURM job completion
+ * logging API.
+ */
+
+extern int slurm_jobcomp_set_location ( char * location )
+{
+	return database_g_jobcomp_init(location);
+}
+
+extern int slurm_jobcomp_log_record ( struct job_record *job_ptr )
+{
+	return database_g_jobcomp_log_record(job_ptr);
+}
+
+extern int slurm_jobcomp_get_errno( void )
+{
+	return database_g_jobcomp_get_errno();
+}
+
+extern char *slurm_jobcomp_strerror( int errnum )
+{
+	return database_g_jobcomp_strerror(errnum);
+}
+
diff --git a/src/plugins/jobcomp/filetxt/Makefile.am b/src/plugins/jobcomp/filetxt/Makefile.am
index 0c48f13ec11aa6a0692325d297cc9a1c6a800bb4..9b0b8fba149dcffe45de42bd1c54ce5434f5def4 100644
--- a/src/plugins/jobcomp/filetxt/Makefile.am
+++ b/src/plugins/jobcomp/filetxt/Makefile.am
@@ -9,5 +9,8 @@ INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
 pkglib_LTLIBRARIES = jobcomp_filetxt.la
 
 # Text file job completion logging plugin.
-jobcomp_filetxt_la_SOURCES = jobcomp_filetxt.c
+jobcomp_filetxt_la_SOURCES = jobcomp_filetxt.c \
+	$(top_builddir)/src/plugins/database/flatfile/flatfile_jobcomp.c \
+	$(top_builddir)/src/plugins/database/flatfile/flatfile_jobcomp.h
+
 jobcomp_filetxt_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
diff --git a/src/plugins/jobcomp/filetxt/Makefile.in b/src/plugins/jobcomp/filetxt/Makefile.in
index 8ba74cad64c0b9aba490047cec805e9f06a2f408..715dda7ca9fcc9c119960689e70215e2d773f319 100644
--- a/src/plugins/jobcomp/filetxt/Makefile.in
+++ b/src/plugins/jobcomp/filetxt/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -74,7 +75,7 @@ am__installdirs = "$(DESTDIR)$(pkglibdir)"
 pkglibLTLIBRARIES_INSTALL = $(INSTALL)
 LTLIBRARIES = $(pkglib_LTLIBRARIES)
 jobcomp_filetxt_la_LIBADD =
-am_jobcomp_filetxt_la_OBJECTS = jobcomp_filetxt.lo
+am_jobcomp_filetxt_la_OBJECTS = jobcomp_filetxt.lo flatfile_jobcomp.lo
 jobcomp_filetxt_la_OBJECTS = $(am_jobcomp_filetxt_la_OBJECTS)
 jobcomp_filetxt_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
@@ -132,6 +133,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -155,6 +157,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -166,6 +169,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -257,7 +262,10 @@ INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
 pkglib_LTLIBRARIES = jobcomp_filetxt.la
 
 # Text file job completion logging plugin.
-jobcomp_filetxt_la_SOURCES = jobcomp_filetxt.c
+jobcomp_filetxt_la_SOURCES = jobcomp_filetxt.c \
+	$(top_builddir)/src/plugins/database/flatfile/flatfile_jobcomp.c \
+	$(top_builddir)/src/plugins/database/flatfile/flatfile_jobcomp.h
+
 jobcomp_filetxt_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
 all: all-am
 
@@ -328,6 +336,7 @@ mostlyclean-compile:
 distclean-compile:
 	-rm -f *.tab.c
 
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flatfile_jobcomp.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jobcomp_filetxt.Plo@am__quote@
 
 .c.o:
@@ -351,6 +360,13 @@ distclean-compile:
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
 
+flatfile_jobcomp.lo: $(top_builddir)/src/plugins/database/flatfile/flatfile_jobcomp.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT flatfile_jobcomp.lo -MD -MP -MF $(DEPDIR)/flatfile_jobcomp.Tpo -c -o flatfile_jobcomp.lo `test -f '$(top_builddir)/src/plugins/database/flatfile/flatfile_jobcomp.c' || echo '$(srcdir)/'`$(top_builddir)/src/plugins/database/flatfile/flatfile_jobcomp.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/flatfile_jobcomp.Tpo $(DEPDIR)/flatfile_jobcomp.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$(top_builddir)/src/plugins/database/flatfile/flatfile_jobcomp.c' object='flatfile_jobcomp.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o flatfile_jobcomp.lo `test -f '$(top_builddir)/src/plugins/database/flatfile/flatfile_jobcomp.c' || echo '$(srcdir)/'`$(top_builddir)/src/plugins/database/flatfile/flatfile_jobcomp.c
+
 mostlyclean-libtool:
 	-rm -f *.lo
 
diff --git a/src/plugins/jobcomp/filetxt/jobcomp_filetxt.c b/src/plugins/jobcomp/filetxt/jobcomp_filetxt.c
index ebff6cafda052f266f1710dd85684cf1ad48672a..f35ac72067d0370c02be50f09d23288d3d77c7e6 100644
--- a/src/plugins/jobcomp/filetxt/jobcomp_filetxt.c
+++ b/src/plugins/jobcomp/filetxt/jobcomp_filetxt.c
@@ -15,7 +15,7 @@
  *  any later version.
  *
  *  In addition, as a special exception, the copyright holders give permission 
- *  to link the code of portions of this program with the OpenSSL library under 
+ *  to link the code of portions of this program with the OpenSSL library under
  *  certain conditions as described in each individual source file, and 
  *  distribute linked combinations including the two. You must obey the GNU 
  *  General Public License in all respects for all of the code used other than 
@@ -46,38 +46,7 @@
 #  include <inttypes.h>
 #endif
 
-#include <fcntl.h>
-#include <pthread.h>
-#include <pwd.h>
-#include <slurm/slurm.h>
-#include <slurm/slurm_errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
-#include "src/common/macros.h"
-#include "src/common/node_select.h"
-#include "src/common/slurm_protocol_defs.h"
-#include "src/common/slurm_jobcomp.h"
-#include "src/common/uid.h"
-#include "src/common/xmalloc.h"
-#include "src/common/xstring.h"
-#include "src/slurmctld/slurmctld.h"
-
-#define JOB_FORMAT "JobId=%lu UserId=%s(%lu) Name=%s JobState=%s Partition=%s "\
-		"TimeLimit=%s StartTime=%s EndTime=%s NodeList=%s NodeCnt=%u %s\n"
- 
-/* Type for error string table entries */
-typedef struct {
-	int xe_number;
-	char *xe_message;
-} slurm_errtab_t;
-
-static slurm_errtab_t slurm_errtab[] = {
-	{0, "No error"},
-	{-1, "Unspecified error"}
-};
+#include "src/plugins/database/flatfile/flatfile_jobcomp.h"
 
 /*
  * These variables are required by the generic plugin interface.  If they
@@ -112,13 +81,6 @@ const char plugin_name[]       	= "Job completion text file logging plugin";
 const char plugin_type[]       	= "jobcomp/filetxt";
 const uint32_t plugin_version	= 90;
 
-/* A plugin-global errno. */
-static int plugin_errno = SLURM_SUCCESS;
-
-/* File descriptor used for logging */
-static pthread_mutex_t  file_lock = PTHREAD_MUTEX_INITIALIZER;
-static char *           log_name  = NULL;
-static int              job_comp_fd = -1;
 /*
  * init() is called when the plugin is loaded, before any other functions
  * are called.  Put global initialization here.
@@ -128,169 +90,33 @@ int init ( void )
 	return SLURM_SUCCESS;
 }
 
-/*
- * The remainder of this file implements the standard SLURM job completion
- * logging API.
- */
-
-int slurm_jobcomp_set_location ( char * location )
-{
-	int rc = SLURM_SUCCESS;
-
-	if (location == NULL) {
-		plugin_errno = EACCES;
-		return SLURM_ERROR;
-	}
-	xfree(log_name);
-	log_name = xstrdup(location);
-
-	slurm_mutex_lock( &file_lock );
-	if (job_comp_fd >= 0)
-		close(job_comp_fd);
-	job_comp_fd = open(location, O_WRONLY | O_CREAT | O_APPEND, 0644);
-	if (job_comp_fd == -1) {
-		fatal("open %s: %m", location);
-		plugin_errno = errno;
-		rc = SLURM_ERROR;
-	} else
-		fchmod(job_comp_fd, 0644);
-	slurm_mutex_unlock( &file_lock );
-	return rc;
-}
-
-/* get the user name for the give user_id */
-static void
-_get_user_name(uint32_t user_id, char *user_name, int buf_size)
+int fini ( void )
 {
-	static uint32_t cache_uid      = 0;
-	static char     cache_name[32] = "root";
-	struct passwd * user_info      = NULL;
-
-	if (user_id == cache_uid)
-		snprintf(user_name, buf_size, "%s", cache_name);
-	else {
-		user_info = getpwuid((uid_t) user_id);
-		if (user_info && user_info->pw_name[0])
-			snprintf(cache_name, sizeof(cache_name), "%s", 
-				user_info->pw_name);
-		else
-			snprintf(cache_name, sizeof(cache_name), "Unknown");
-		cache_uid = user_id;
-		snprintf(user_name, buf_size, "%s", cache_name);
-	}
+	return flatfile_jobcomp_fini();
 }
 
 /*
- * make_time_str - convert time_t to string with "YYYY-MM-DDTHH:MM:SS"
- *                 Note this is the ISO8601 standard format 
- * IN time     - a time stamp
- * IN str_size - size of string buffer
- * OUT string  - pointer user defined buffer
+ * The remainder of this file implements the standard SLURM job completion
+ * logging API.
  */
-static void
-_make_time_str (time_t *time, char *string, int str_size)
-{
-	struct tm time_tm;
-
-	localtime_r (time, &time_tm);
-	snprintf ( string, str_size, "%4.4u-%2.2u-%2.2uT%2.2u:%2.2u:%2.2u",
-		(time_tm.tm_year + 1900), (time_tm.tm_mon+1), time_tm.tm_mday,
-		time_tm.tm_hour, time_tm.tm_min, time_tm.tm_sec);
-}
 
-int slurm_jobcomp_log_record ( struct job_record *job_ptr )
+extern int slurm_jobcomp_set_location ( char * location )
 {
-	int rc = SLURM_SUCCESS;
-	char job_rec[512+MAX_JOBNAME_LEN];
-	char usr_str[32], start_str[32], end_str[32], lim_str[32];
-	char select_buf[128];
-	size_t offset = 0, tot_size, wrote;
-	enum job_states job_state;
-
-	if ((log_name == NULL) || (job_comp_fd < 0)) {
-		error("JobCompLoc log file %s not open", log_name);
-		return SLURM_ERROR;
-	}
-
-	slurm_mutex_lock( &file_lock );
-	_get_user_name(job_ptr->user_id, usr_str, sizeof(usr_str));
-	if (job_ptr->time_limit == INFINITE)
-		strcpy(lim_str, "UNLIMITED");
-	else
-		snprintf(lim_str, sizeof(lim_str), "%lu", 
-				(unsigned long) job_ptr->time_limit);
-
-	/* Job will typically be COMPLETING when this is called. 
-	 * We remove this flag to get the eventual completion state:
-	 * JOB_FAILED, JOB_TIMEOUT, etc. */
-	job_state = job_ptr->job_state & (~JOB_COMPLETING);
-
-	_make_time_str(&(job_ptr->start_time), start_str, sizeof(start_str));
-	_make_time_str(&(job_ptr->end_time),   end_str,   sizeof(end_str));
-
-	select_g_sprint_jobinfo(job_ptr->select_jobinfo,
-		select_buf, sizeof(select_buf), SELECT_PRINT_MIXED);
-
-	snprintf(job_rec, sizeof(job_rec), JOB_FORMAT,
-			(unsigned long) job_ptr->job_id, usr_str, 
-			(unsigned long) job_ptr->user_id, job_ptr->name, 
-			job_state_string(job_state), 
-			job_ptr->partition, lim_str, start_str, 
-			end_str, job_ptr->nodes, job_ptr->node_cnt,
-			select_buf);
-	tot_size = strlen(job_rec);
-
-	while ( offset < tot_size ) {
-		wrote = write(job_comp_fd, job_rec + offset,
-			tot_size - offset);
-		if (wrote == -1) {
-			if (errno == EAGAIN)
-				continue;
-			else {
-				plugin_errno = errno;
-				rc = SLURM_ERROR;
-				break;
-			}
-		}
-		offset += wrote;
-	}
-	slurm_mutex_unlock( &file_lock );
-	return rc;
+	return flatfile_jobcomp_init(location);
 }
 
-extern int slurm_jobcomp_get_errno( void )
+extern int slurm_jobcomp_log_record ( struct job_record *job_ptr )
 {
-	return plugin_errno;
+	return flatfile_jobcomp_log_record(job_ptr);
 }
 
-/* 
- * Linear search through table of errno values and strings,
- * returns NULL on error, string on success.
- */
-static char *_lookup_slurm_api_errtab(int errnum)
+extern int slurm_jobcomp_get_errno( void )
 {
-	char *res = NULL;
-	int i;
-
-	for (i = 0; i < sizeof(slurm_errtab) / sizeof(slurm_errtab_t); i++) {
-		if (slurm_errtab[i].xe_number == errnum) {
-			res = slurm_errtab[i].xe_message;
-			break;
-		}
-	}
-	return res;
+	return flatfile_jobcomp_get_errno();
 }
 
 extern char *slurm_jobcomp_strerror( int errnum )
 {
-	char *res = _lookup_slurm_api_errtab(errnum);
-	return (res ? res : strerror(errnum));
+	return flatfile_jobcomp_strerror(errnum);
 }
 
-int fini ( void )
-{
-	if (job_comp_fd >= 0)
-		close(job_comp_fd);
-	xfree(log_name);
-	return SLURM_SUCCESS;
-}
diff --git a/src/plugins/jobcomp/none/Makefile.in b/src/plugins/jobcomp/none/Makefile.in
index 2f555f0b98cb58adbcad9f1db279be55ee837b72..29427817da51464147d42a0fa37874538e66a531 100644
--- a/src/plugins/jobcomp/none/Makefile.in
+++ b/src/plugins/jobcomp/none/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -132,6 +133,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -155,6 +157,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -166,6 +169,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/jobcomp/script/Makefile.in b/src/plugins/jobcomp/script/Makefile.in
index 8547bcea849b1f25669ae830f40e377a8ec84d59..160a215439c0bab38da99242aedf858d58c5425c 100644
--- a/src/plugins/jobcomp/script/Makefile.in
+++ b/src/plugins/jobcomp/script/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -132,6 +133,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -155,6 +157,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -166,6 +169,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/mpi/Makefile.in b/src/plugins/mpi/Makefile.in
index cbf8384bbcb9fbbd3f80f847bf183a949a264e94..4823c2e971f9db4fc8fdb721f014e7f1db0a2dfc 100644
--- a/src/plugins/mpi/Makefile.in
+++ b/src/plugins/mpi/Makefile.in
@@ -43,6 +43,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -114,6 +115,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -137,6 +139,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -148,6 +151,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/mpi/lam/Makefile.in b/src/plugins/mpi/lam/Makefile.in
index 3d347a991aa62043c2784ef14b7c95b3d71b9e61..fbe4e9d9bcc1ca6fee496681e51fc0b468949b62 100644
--- a/src/plugins/mpi/lam/Makefile.in
+++ b/src/plugins/mpi/lam/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -132,6 +133,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -155,6 +157,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -166,6 +169,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/mpi/mpich1_shmem/Makefile.in b/src/plugins/mpi/mpich1_shmem/Makefile.in
index 751920cb5f9f7095b9d63d4dd2b9883a50782970..8e70105adefa58a32c8f01bf06d6f14c7f3952d0 100644
--- a/src/plugins/mpi/mpich1_shmem/Makefile.in
+++ b/src/plugins/mpi/mpich1_shmem/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -132,6 +133,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -155,6 +157,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -166,6 +169,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/mpi/mpichgm/Makefile.in b/src/plugins/mpi/mpichgm/Makefile.in
index a91d7bdc3a78a79005fa5845f6f44238d6b2c6ae..7959df142ab255e06eac37e909aa9759ee5cd9f2 100644
--- a/src/plugins/mpi/mpichgm/Makefile.in
+++ b/src/plugins/mpi/mpichgm/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -132,6 +133,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -155,6 +157,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -166,6 +169,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/mpi/mvapich/Makefile.in b/src/plugins/mpi/mvapich/Makefile.in
index fb80b75b7bb9b5de9c2f3aeedd03b5c03d8ad408..3243b4d2de3e4e0b24ded6ee588299f964ae2ea4 100644
--- a/src/plugins/mpi/mvapich/Makefile.in
+++ b/src/plugins/mpi/mvapich/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -132,6 +133,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -155,6 +157,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -166,6 +169,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/mpi/none/Makefile.in b/src/plugins/mpi/none/Makefile.in
index 3c481a3393e8e669c0037ffd67c9443e931865be..bdc81de71e016fd0d67fa3b67ecf2af9c922eae0 100644
--- a/src/plugins/mpi/none/Makefile.in
+++ b/src/plugins/mpi/none/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -132,6 +133,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -155,6 +157,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -166,6 +169,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/mpi/openmpi/Makefile.in b/src/plugins/mpi/openmpi/Makefile.in
index 19640c32e6f8db5b5d2b1bb56c06407f5f807e74..cb60d3e7e38d78648c0c8c65207ebb3bcd4c4f6e 100644
--- a/src/plugins/mpi/openmpi/Makefile.in
+++ b/src/plugins/mpi/openmpi/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -132,6 +133,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -155,6 +157,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -166,6 +169,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/proctrack/Makefile.in b/src/plugins/proctrack/Makefile.in
index d3c317f41fd03cf0f87080d235ff5819150352d9..053fcd5e5b926687026d4ebacb57280825f32210 100644
--- a/src/plugins/proctrack/Makefile.in
+++ b/src/plugins/proctrack/Makefile.in
@@ -43,6 +43,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -114,6 +115,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -137,6 +139,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -148,6 +151,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/proctrack/aix/Makefile.in b/src/plugins/proctrack/aix/Makefile.in
index 561b0bc629581f34a71c47698b2b84f7f760ddbf..b28be8b3f22ade979dc26474b9832f0d798eacb7 100644
--- a/src/plugins/proctrack/aix/Makefile.in
+++ b/src/plugins/proctrack/aix/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -132,6 +133,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -155,6 +157,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -166,6 +169,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/proctrack/linuxproc/Makefile.in b/src/plugins/proctrack/linuxproc/Makefile.in
index 92ede117feb091264d0590654eda4606291f1a32..26786537b269f55faac91179e99d8349cffe08e2 100644
--- a/src/plugins/proctrack/linuxproc/Makefile.in
+++ b/src/plugins/proctrack/linuxproc/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -133,6 +134,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -156,6 +158,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -167,6 +170,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/proctrack/pgid/Makefile.in b/src/plugins/proctrack/pgid/Makefile.in
index e60afafebd129ef1c8a8ef9ef16665ab63a0ca1f..bce33403589cb77779fa441671bd86e9aaa5a74a 100644
--- a/src/plugins/proctrack/pgid/Makefile.in
+++ b/src/plugins/proctrack/pgid/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -132,6 +133,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -155,6 +157,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -166,6 +169,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/proctrack/rms/Makefile.in b/src/plugins/proctrack/rms/Makefile.in
index bf8f7c191553dfc9fff237b6e9ec9c69109dbbef..45d56fae04dbdbbaf89d9fc17c1ba4a89e4abc61 100644
--- a/src/plugins/proctrack/rms/Makefile.in
+++ b/src/plugins/proctrack/rms/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -133,6 +134,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -156,6 +158,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -167,6 +170,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/proctrack/sgi_job/Makefile.in b/src/plugins/proctrack/sgi_job/Makefile.in
index e957f7657b8e2f7b23ed2ed964bbf35fcd404577..1dc496c3039af087842e82635b835556f46c8d8e 100644
--- a/src/plugins/proctrack/sgi_job/Makefile.in
+++ b/src/plugins/proctrack/sgi_job/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -132,6 +133,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -155,6 +157,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -166,6 +169,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/sched/Makefile.in b/src/plugins/sched/Makefile.in
index 1be6962ee0363f967d5dab02fbc78414c08b72a3..b08e6408283fc0e748b16dcb74c3f58974149d82 100644
--- a/src/plugins/sched/Makefile.in
+++ b/src/plugins/sched/Makefile.in
@@ -43,6 +43,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -114,6 +115,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -137,6 +139,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -148,6 +151,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/sched/backfill/Makefile.in b/src/plugins/sched/backfill/Makefile.in
index 4fe64da1bcc783bd90bd9a5a3a8e5d18ecd86b01..845df32cc6981e4e280b27e51f05f91b973f93f2 100644
--- a/src/plugins/sched/backfill/Makefile.in
+++ b/src/plugins/sched/backfill/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -132,6 +133,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -155,6 +157,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -166,6 +169,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/sched/builtin/Makefile.in b/src/plugins/sched/builtin/Makefile.in
index 1f449de883fa1d357650de74dc7bb7a376463ba4..fd6134a22b7a926d66d1151efff6f49b919c4244 100644
--- a/src/plugins/sched/builtin/Makefile.in
+++ b/src/plugins/sched/builtin/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -132,6 +133,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -155,6 +157,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -166,6 +169,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/sched/gang/Makefile.in b/src/plugins/sched/gang/Makefile.in
index e7afa7d66e1699cdd6a612f0f7e0489a7a9c5c1a..a4675b83034a2c760d65f4edce1b78ac6939beb8 100644
--- a/src/plugins/sched/gang/Makefile.in
+++ b/src/plugins/sched/gang/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -132,6 +133,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -155,6 +157,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -166,6 +169,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/sched/hold/Makefile.in b/src/plugins/sched/hold/Makefile.in
index 1e350713edf469a63b0fbc47f09f6b8a9be5f705..ecfcce7e6609dbfea4fd7a8ea3e27dba97d4a894 100644
--- a/src/plugins/sched/hold/Makefile.in
+++ b/src/plugins/sched/hold/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -132,6 +133,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -155,6 +157,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -166,6 +169,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/sched/wiki/Makefile.in b/src/plugins/sched/wiki/Makefile.in
index a856187130d40042dcdf0ce0ba9a867219790941..87729c9eaa2678f06555702ea0f6a46bbc3cf27f 100644
--- a/src/plugins/sched/wiki/Makefile.in
+++ b/src/plugins/sched/wiki/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -133,6 +134,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -156,6 +158,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -167,6 +170,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/sched/wiki2/Makefile.in b/src/plugins/sched/wiki2/Makefile.in
index babf723b70a2663600edfd93f7af222f275aed9d..a2a139a837e13870769861e5d3b2d5e0c32d476c 100644
--- a/src/plugins/sched/wiki2/Makefile.in
+++ b/src/plugins/sched/wiki2/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -136,6 +137,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -159,6 +161,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -170,6 +173,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/select/Makefile.in b/src/plugins/select/Makefile.in
index f950a6649c909340edde7910756d2a0ec61b959a..ea67c641d385c9a2eba7b21d13914215f15300b1 100644
--- a/src/plugins/select/Makefile.in
+++ b/src/plugins/select/Makefile.in
@@ -43,6 +43,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -114,6 +115,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -137,6 +139,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -148,6 +151,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/select/bluegene/Makefile.in b/src/plugins/select/bluegene/Makefile.in
index 6a1f93f37234fddab0380036383fb4ffa653e6fd..2d05d0b00974a5467880a6256f7cb5748590e7a1 100644
--- a/src/plugins/select/bluegene/Makefile.in
+++ b/src/plugins/select/bluegene/Makefile.in
@@ -43,6 +43,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -114,6 +115,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -137,6 +139,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -148,6 +151,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/select/bluegene/block_allocator/Makefile.am b/src/plugins/select/bluegene/block_allocator/Makefile.am
index a6d5d6151a660ef701fa44cd6fc7c8032e253bec..43f9b59049132a414315bb9723a1f36145b56ac8 100644
--- a/src/plugins/select/bluegene/block_allocator/Makefile.am
+++ b/src/plugins/select/bluegene/block_allocator/Makefile.am
@@ -26,8 +26,7 @@ libbluegene_block_allocator_la_SOURCES =    \
 	block_allocator.c bridge_linker.c block_allocator.h bridge_linker.h
 
 libbluegene_block_allocator_la_LIBADD  =  \
-	$(top_builddir)/src/common/libcommon.la -lpthread \
-	$(top_builddir)/src/api/libslurm.la
+	$(top_builddir)/src/common/libcommon.la -lpthread
 
 libbluegene_block_allocator_la_LDFLAGS        = \
 	$(LIB_LDFLAGS) -lm    
diff --git a/src/plugins/select/bluegene/block_allocator/Makefile.in b/src/plugins/select/bluegene/block_allocator/Makefile.in
index 97637d185032f2fe5f4482d75eb8bfb3bae5e31d..ef6c00222a35cb8ba770adebcfe3e6bc3f485776 100644
--- a/src/plugins/select/bluegene/block_allocator/Makefile.in
+++ b/src/plugins/select/bluegene/block_allocator/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -126,6 +127,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -149,6 +151,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -160,6 +163,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -269,8 +274,7 @@ libbluegene_block_allocator_la_SOURCES = \
 	block_allocator.c bridge_linker.c block_allocator.h bridge_linker.h
 
 libbluegene_block_allocator_la_LIBADD = \
-	$(top_builddir)/src/common/libcommon.la -lpthread \
-	$(top_builddir)/src/api/libslurm.la
+	$(top_builddir)/src/common/libcommon.la -lpthread
 
 libbluegene_block_allocator_la_LDFLAGS = \
 	$(LIB_LDFLAGS) -lm    
diff --git a/src/plugins/select/bluegene/plugin/Makefile.in b/src/plugins/select/bluegene/plugin/Makefile.in
index da1d608c878d0db806ba6b91f8a95c60f33bbf52..58f3bf597c4d1dc3f99c38927818600e498bebce 100644
--- a/src/plugins/select/bluegene/plugin/Makefile.in
+++ b/src/plugins/select/bluegene/plugin/Makefile.in
@@ -47,6 +47,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -172,6 +173,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -195,6 +197,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -206,6 +209,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/select/bluegene/plugin/bg_job_run.c b/src/plugins/select/bluegene/plugin/bg_job_run.c
index 8b5a743e597616eb92737508657f745df47c5e28..de73f6c408c5e1794f1f6afc0dec0a073e970af5 100644
--- a/src/plugins/select/bluegene/plugin/bg_job_run.c
+++ b/src/plugins/select/bluegene/plugin/bg_job_run.c
@@ -788,7 +788,7 @@ static int _excise_block(List block_list, pm_partition_id_t bg_block_id,
 			
 			/* exact match of name and node list */
 			debug("synced Block %s", bg_block_id);
-			list_delete(iter);
+			list_delete_item(iter);
 			rc = SLURM_SUCCESS;
 			break;
 		}		
diff --git a/src/plugins/select/cons_res/Makefile.in b/src/plugins/select/cons_res/Makefile.in
index 7e9e15b08b3098ece45e7cd8ffafc83d45d1b511..30cdb482def16952532580427dc49ec88e618f38 100644
--- a/src/plugins/select/cons_res/Makefile.in
+++ b/src/plugins/select/cons_res/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -133,6 +134,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -156,6 +158,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -167,6 +170,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/select/linear/Makefile.in b/src/plugins/select/linear/Makefile.in
index e02e9e22ae4ba282600f07825764c44428742e0a..2f8fb49ebae2559daa9cd43aa24014f1b30ba8b9 100644
--- a/src/plugins/select/linear/Makefile.in
+++ b/src/plugins/select/linear/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -133,6 +134,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -156,6 +158,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -167,6 +170,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/switch/Makefile.in b/src/plugins/switch/Makefile.in
index 33e59fac3944c9e61c853ed0970c78a92b366598..b20356e7282affdc9881119d83d42f464b34bc35 100644
--- a/src/plugins/switch/Makefile.in
+++ b/src/plugins/switch/Makefile.in
@@ -43,6 +43,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -114,6 +115,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -137,6 +139,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -148,6 +151,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/switch/elan/Makefile.in b/src/plugins/switch/elan/Makefile.in
index 04b2358e661b83c0d00e7c4de213d87941ff8dfe..b16017d44a49883dcc278393bddc373fe69be10f 100644
--- a/src/plugins/switch/elan/Makefile.in
+++ b/src/plugins/switch/elan/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -138,6 +139,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -161,6 +163,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -172,6 +175,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/switch/elan/qsw.c b/src/plugins/switch/elan/qsw.c
index 550e621b00a0373291e687855b1007b23404be81..3f7aaf8f1f1da7b701b4ea3fc873fb5a6cfc0efe 100644
--- a/src/plugins/switch/elan/qsw.c
+++ b/src/plugins/switch/elan/qsw.c
@@ -747,7 +747,7 @@ _free_hwcontext(uint32_t prog_num)
 			if (prog_num != step_ctx_p->st_prognum)
 				continue;
 			_dump_step_ctx("_free_hwcontext", step_ctx_p);
-			list_delete(iter);
+			list_delete_item(iter);
 			break;
 		}
 		if (!step_ctx_p) {
diff --git a/src/plugins/switch/federation/Makefile.in b/src/plugins/switch/federation/Makefile.in
index df3f9ea03a2e38cd838b002d9ddc5ad6eebf8ef9..8515cf31b0c925bf31c93cbbe742d845a5736a0f 100644
--- a/src/plugins/switch/federation/Makefile.in
+++ b/src/plugins/switch/federation/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -142,6 +143,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -165,6 +167,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -176,6 +179,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/switch/none/Makefile.in b/src/plugins/switch/none/Makefile.in
index 1f39eb4d82a571e1b19f6b488f87e1f2125a0f9b..75214f0b8deb152f7c1bbee517789b45fac0bedd 100644
--- a/src/plugins/switch/none/Makefile.in
+++ b/src/plugins/switch/none/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -133,6 +134,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -156,6 +158,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -167,6 +170,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/task/Makefile.in b/src/plugins/task/Makefile.in
index 24758482d3d4bf40500c89b954cbdc7eb357208a..90d1dceea340693efcc162ba69f44b4a30a2a7a7 100644
--- a/src/plugins/task/Makefile.in
+++ b/src/plugins/task/Makefile.in
@@ -43,6 +43,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -114,6 +115,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -137,6 +139,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -148,6 +151,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/task/affinity/Makefile.in b/src/plugins/task/affinity/Makefile.in
index 8b1786c02fc3e90f976c0e03e82651f9938a4e87..52b497c532cae5d986299255d07b099023f411d4 100644
--- a/src/plugins/task/affinity/Makefile.in
+++ b/src/plugins/task/affinity/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -144,6 +145,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -167,6 +169,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -178,6 +181,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/plugins/task/affinity/dist_tasks.c b/src/plugins/task/affinity/dist_tasks.c
index abe3c3a3f0ed1f796bbee01b8064b0f44b6baa44..931810b53f973a64d72c201a490ae74182e27854 100644
--- a/src/plugins/task/affinity/dist_tasks.c
+++ b/src/plugins/task/affinity/dist_tasks.c
@@ -1148,7 +1148,7 @@ _remove_lllp_job_state(uint32_t jobid)
         i = list_iterator_create(lllp_ctx->job_list);
         while ((j = list_next(i)) && (j->jobid != jobid)) {;}
 	if (j) {
-	    	list_delete(i);
+	    	list_delete_item(i);
 	}
         list_iterator_destroy(i);
 }
@@ -1673,7 +1673,7 @@ void cr_release_lllp(uint32_t job_id)
 					cpu_bind_type, cpu_bind, numtasks);
 
 			/* done with saved state, remove entry */
-			list_delete(i);
+			list_delete_item(i);
 		}
 	}
 	list_iterator_destroy(i);
diff --git a/src/plugins/task/none/Makefile.in b/src/plugins/task/none/Makefile.in
index a51b031718986c972adc74660415a9792f57f61e..d20986fc862e123df6d95fba88015362bd1ae969 100644
--- a/src/plugins/task/none/Makefile.in
+++ b/src/plugins/task/none/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -133,6 +134,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -156,6 +158,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -167,6 +170,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/sacct/Makefile.in b/src/sacct/Makefile.in
index f84d6fdb223e3b511281afb8cc8acfc26b68cafb..3ec3a5a665dd14be2a90f6248ddf62a3aa41c67d 100644
--- a/src/sacct/Makefile.in
+++ b/src/sacct/Makefile.in
@@ -47,6 +47,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -131,6 +132,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -154,6 +156,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -165,6 +168,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/sacct/options.c b/src/sacct/options.c
index e00036b4436fafab2dec5e6f207b7bc9832c80d8..4290f79bb0a9307dc398b177205ecd8dcb064df1 100644
--- a/src/sacct/options.c
+++ b/src/sacct/options.c
@@ -38,27 +38,17 @@
 \*****************************************************************************/
 
 #include "src/common/read_config.h"
+#include "src/common/slurm_database.h"
 #include "sacct.h"
 #include <time.h>
 
-typedef struct expired_rec {  /* table of expired jobs */
-	uint32_t job;
-	time_t job_submit;
-	char *line;
-} expired_rec_t;
-
 void _destroy_parts(void *object);
 void _destroy_steps(void *object);
-void _destroy_exp(void *object);
-char *_convert_type(int rec_type);
-int _cmp_jrec(const void *a1, const void *a2);
-void _dump_header(acct_header_t header);
-FILE *_open_log_file(void);
+void _dump_header(jobacct_header_t header);
 void _help_fields_msg(void);
 void _help_msg(void);
 void _usage(void);
 void _init_params();
-char *_prefix_filename(char *path, char *prefix);
 
 int selected_status[STATUS_COUNT];
 List selected_parts = NULL;
@@ -72,35 +62,13 @@ void _destroy_parts(void *object)
 
 void _destroy_steps(void *object)
 {
-	selected_step_t *step = (selected_step_t *)object;
+	jobacct_selected_step_t *step = (jobacct_selected_step_t *)object;
 	if(step) {
 		xfree(step->job);
 		xfree(step->step);
 		xfree(step);
 	}
 }
-void _destroy_exp(void *object)
-{
-	expired_rec_t *exp_rec = (expired_rec_t *)object;
-	if(exp_rec) {
-		xfree(exp_rec->line);
-		xfree(exp_rec);
-	}
-}
-
-char *_convert_type(int rec_type)
-{
-	switch(rec_type) {
-	case JOB_START:
-		return "JOB_START";
-	case JOB_STEP:
-		return "JOB_STEP";
-	case JOB_TERMINATED:
-		return "JOB_TERMINATED";
-	default:
-		return "UNKNOWN";
-	}
-}
 
 void _show_rec(char *f[])
 {
@@ -112,27 +80,12 @@ void _show_rec(char *f[])
 	return;
 }
 
-int _cmp_jrec(const void *a1, const void *a2) {
-	expired_rec_t *j1 = (expired_rec_t *) a1;
-	expired_rec_t *j2 = (expired_rec_t *) a2;
-
-	if (j1->job <  j2->job)
-		return -1;
-	else if (j1->job == j2->job) {
-		if(j1->job_submit == j2->job_submit)
-			return 0;
-		else 
-			return 1;
-	}
-	return 1;
-}
-
 /* _dump_header() -- dump the common fields of a record
  *
  * In:	Index into the jobs table
  * Out: Nothing.
  */
-void _dump_header(acct_header_t header)
+void _dump_header(jobacct_header_t header)
 {
 	struct tm ts;
 	gmtime_r(&header.timestamp, &ts);
@@ -149,25 +102,6 @@ void _dump_header(acct_header_t header)
 	       header.blockid,	/* block id */
 	       "-");	/* reserved 1 */
 }
-/* _open_log_file() -- find the current or specified log file, and open it
- *
- * IN:		Nothing
- * RETURNS:	Nothing
- *
- * Side effects:
- * 	- Sets opt_filein to the current system accounting log unless
- * 	  the user specified another file.
- */
-
-FILE *_open_log_file(void)
-{
-	FILE *fd = fopen(params.opt_filein, "r");
-	if (fd == NULL) {
-		perror(params.opt_filein);
-		exit(1);
-	}
-	return fd;
-}
 
 void _help_fields_msg(void)
 {
@@ -212,6 +146,8 @@ void _help_msg(void)
 	       "-b, --brief\n"
 	       "    Equivalent to \"--fields=jobstep,status,error\". This option\n"
 	       "    has no effect if --dump is specified.\n"
+	       "-c, --completion\n"
+	       "    Use job completion instead of accounting data.\n"
 	       "-d, --dump\n"
 	       "    Dump the raw data records\n"
 	       "--duplicates\n"
@@ -307,6 +243,7 @@ void _usage(void)
 
 void _init_params()
 {
+	params.opt_completion = 0;	/* --completion */
 	params.opt_dump = 0;		/* --dump */
 	params.opt_dup = -1;		/* --duplicates; +1 = explicitly set */
 	params.opt_fdump = 0;		/* --formattted_dump */
@@ -328,33 +265,6 @@ void _init_params()
 	params.opt_state_list = NULL;	/* --states */
 }
 
-/* prefix_filename() -- insert a filename prefix into a path
- *
- * IN:	path = fully-qualified path+file name
- *      prefix = the prefix to insert into the file name
- * RETURNS: pointer to the updated path+file name
- */
-
-char *_prefix_filename(char *path, char *prefix) {
-	char	*out;
-	int     i,
-		plen;
-
-	plen = strlen(path);
-	out = xmalloc(plen+strlen(prefix)+1);
-	for (i=plen-1; i>=0; i--)
-		if (path[i]=='/') {
-			break;
-		}
-	i++;
-	*out = 0;
-	strncpy(out, path, i);
-	out[i] = 0;
-	strcat(out, prefix);
-	strcat(out, path+i);
-	return(out);
-}
-
 int decode_status_char(char *status)
 {
 	if (!strcasecmp(status, "p"))
@@ -377,188 +287,85 @@ int decode_status_char(char *status)
 		return -1; // unknown
 } 
 
-char *decode_status_int(int status)
-{
-	switch(status & ~JOB_COMPLETING) {
-	case JOB_PENDING:
-		return "PENDING"; 	/* we should never see this */
-	case JOB_RUNNING:
-		return "RUNNING";
-	case JOB_SUSPENDED:
-		return "SUSPENDED";
-	case JOB_COMPLETE:
-		return "COMPLETED";
-	case JOB_CANCELLED:
-		return "CANCELLED";
-	case JOB_FAILED:
-		return "FAILED";
-	case JOB_TIMEOUT:
-		return "TIMEOUT";
-	case JOB_NODE_FAIL:
-		return "NODE_FAILED";
-	default:
-		return "UNKNOWN";
-	}
-}
-
-char *decode_status_int_abbrev(int status)
-{
-	switch(status & ~JOB_COMPLETING) {
-	case JOB_PENDING:
-		return "PD"; 	/* we should never see this */
-	case JOB_RUNNING:
-		return "R";
-	case JOB_SUSPENDED:
-		return "S";
-	case JOB_COMPLETE:
-		return "CD";
-	case JOB_CANCELLED:
-		return "CA";
-	case JOB_FAILED:
-		return "F";
-	case JOB_TIMEOUT:
-		return "TO";
-	case JOB_NODE_FAIL:
-		return "NF";
-	case JOB_END:
-		return "JOB_END";
-	default:
-		return "UNKNOWN";
-	}
-}
-
 int get_data(void)
 {
-	char line[BUFFER_SIZE];
-	char *f[MAX_RECORD_FIELDS+1];    /* End list with null entry and,
-					    possibly, more data than we
-					    expected */
-	char *fptr;
-	int i;
-	FILE *fd = NULL;
-	int lc = 0;
-	int rec_type = -1;
-	selected_step_t *selected_step = NULL;
-	char *selected_part = NULL;
+	jobacct_job_rec_t *job = NULL;
+	jobacct_step_rec_t *step = NULL;
+
 	ListIterator itr = NULL;
-	int show_full = 0;
+	ListIterator itr_step = NULL;
 
-	fd = _open_log_file();
+	if(params.opt_completion) {
+		jobs = list_create(jobcomp_destroy_job);
+		database_g_jobcomp_get_jobs(jobs, selected_steps,
+					    selected_parts, &params);
+		return SLURM_SUCCESS;
+	} else {
+		jobs = list_create(jobacct_destroy_job);
+		database_g_jobacct_get_jobs(jobs, selected_steps,
+					    selected_parts, &params);
+	}
+
+	if (params.opt_fdump) {
+		return SLURM_SUCCESS;
+	}
 	
-	while (fgets(line, BUFFER_SIZE, fd)) {
-		lc++;
-		fptr = line;	/* break the record into NULL-
-				   terminated strings */
-				
-		for (i = 0; i < MAX_RECORD_FIELDS; i++) {
-			f[i] = fptr;
-			fptr = strstr(fptr, " ");
-			if (fptr == NULL) {
-				fptr = strstr(f[i], "\n");
-				if (fptr)
-					*fptr = 0;
-				break; 
-			} else
-				*fptr++ = 0;
-		}
-		f[++i] = 0;
-		
-		if(i < HEADER_LENGTH) {
+	itr = list_iterator_create(jobs);
+	while((job = list_next(itr))) {
+		if(!list_count(job->steps)) 
 			continue;
-		}
 		
-		rec_type = atoi(f[F_RECTYPE]);
-		
-		if (list_count(selected_steps)) {
-			itr = list_iterator_create(selected_steps);
-			while((selected_step = list_next(itr))) {
-				if (strcmp(selected_step->job, f[F_JOB]))
-					continue;
-				/* job matches; does the step? */
-				if(selected_step->step == NULL) {
-					show_full = 1;
-					list_iterator_destroy(itr);
-					goto foundjob;
-				} else if (rec_type != JOB_STEP 
-					   || !strcmp(f[F_JOBSTEP], 
-						      selected_step->step)) {
-					list_iterator_destroy(itr);
-					goto foundjob;
-				} 
+		itr_step = list_iterator_create(job->steps);
+		while((step = list_next(itr_step)) != NULL) {
+			/* now aggregate the aggregatable */
+			job->ncpus = MAX(job->ncpus, step->ncpus);
+			if (step->status == JOB_RUNNING &&
+			    job->job_terminated_seen) {
+				step->status = JOB_FAILED;
+				step->exitcode=1;
 			}
-			list_iterator_destroy(itr);
-			continue;	/* no match */
-		} else {
-			show_full = 1;
-		}
-	foundjob:
-		
-		if (list_count(selected_parts)) {
-			itr = list_iterator_create(selected_parts);
-			while((selected_part = list_next(itr))) 
-				if (!strcasecmp(f[F_PARTITION], 
-						selected_part)) {
-					list_iterator_destroy(itr);
-					goto foundp;
-				}
-			list_iterator_destroy(itr);
-			continue;	/* no match */
-		}
-	foundp:
-		
-		if (params.opt_fdump) {
-			do_fdump(f, lc);
-			continue;
-		}
-		
-		/* Build suitable tables with all the data */
-		switch(rec_type) {
-		case JOB_START:
-			if(i < F_JOB_ACCOUNT) {
-				printf("Bad data on a Job Start\n");
-				_show_rec(f);
-			} else 
-				process_start(f, lc, show_full, i);
-			break;
-		case JOB_STEP:
-			if(i < F_MAX_VSIZE) {
-				printf("Bad data on a Step entry\n");
-				_show_rec(f);
-			} else
-				process_step(f, lc, show_full, i);
-			break;
-		case JOB_SUSPEND:
-			if(i < JOB_TERM_LENGTH) {
-				printf("Bad data on a Suspend entry\n");
-				_show_rec(f);
-			} else
-				process_suspend(f, lc, show_full, i);
-			break;
-		case JOB_TERMINATED:
-			if(i < JOB_TERM_LENGTH) {
-				printf("Bad data on a Job Term\n");
-				_show_rec(f);
-			} else
-				process_terminated(f, lc, show_full, i);
-			break;
-		default:
-			if (params.opt_verbose > 1)
-				fprintf(stderr,
-					"Invalid record at line %d of "
-					"input file\n",
-					lc);
-			if (params.opt_verbose > 2)
-				_show_rec(f);
-			input_error++;
-			break;
+
+			if(step->status < JOB_COMPLETE)
+				continue;
+			job->tot_cpu_sec += step->tot_cpu_sec;
+			job->tot_cpu_usec += step->tot_cpu_usec;
+			job->rusage.ru_utime.tv_sec +=
+				step->rusage.ru_utime.tv_sec;
+			job->rusage.ru_utime.tv_usec +=
+				step->rusage.ru_utime.tv_usec;
+			job->rusage.ru_stime.tv_sec +=
+				step->rusage.ru_stime.tv_sec;
+			job->rusage.ru_stime.tv_usec +=
+				step->rusage.ru_stime.tv_usec;
+			job->rusage.ru_inblock += step->rusage.ru_inblock;
+			job->rusage.ru_oublock += step->rusage.ru_oublock;
+			job->rusage.ru_msgsnd += step->rusage.ru_msgsnd;
+			job->rusage.ru_msgrcv += step->rusage.ru_msgrcv;
+			job->rusage.ru_nsignals += step->rusage.ru_nsignals;
+			job->rusage.ru_nvcsw += step->rusage.ru_nvcsw;
+			job->rusage.ru_nivcsw += step->rusage.ru_nivcsw;
+			
+			/* and finally the maximums for any process */
+			job->rusage.ru_maxrss = MAX(job->rusage.ru_maxrss,
+						    step->rusage.ru_maxrss);
+			job->rusage.ru_ixrss = MAX(job->rusage.ru_ixrss,
+						   step->rusage.ru_ixrss);
+			job->rusage.ru_idrss = MAX(job->rusage.ru_idrss,
+						   step->rusage.ru_idrss);
+			job->rusage.ru_isrss = MAX(job->rusage.ru_isrss,
+						   step->rusage.ru_isrss);
+			job->rusage.ru_minflt = MAX(job->rusage.ru_minflt,
+						    step->rusage.ru_minflt);
+			job->rusage.ru_majflt = MAX(job->rusage.ru_majflt,
+						    step->rusage.ru_majflt);
+			job->rusage.ru_nswap = MAX(job->rusage.ru_nswap,
+						   step->rusage.ru_nswap);
+			/* get the max for all the sacct_t struct */
+			aggregate_sacct(&job->sacct, &step->sacct);
 		}
+		list_iterator_destroy(itr_step);
 	}
-	
-	if (ferror(fd)) {
-		perror(params.opt_filein);
-		exit(1);
-	} 
-	fclose(fd);
+	list_iterator_destroy(itr);
 
 	return SLURM_SUCCESS;
 } 
@@ -568,14 +375,16 @@ void parse_command_line(int argc, char **argv)
 	extern int optind;
 	int c, i, optionIndex = 0;
 	char *end = NULL, *start = NULL, *acct_type = NULL;
-	selected_step_t *selected_step = NULL;
+	jobacct_selected_step_t *selected_step = NULL;
 	ListIterator itr = NULL;
 	struct stat stat_buf;
 	char *dot = NULL;
+	bool brief_output = FALSE, long_output = FALSE;
 
 	static struct option long_options[] = {
 		{"all", 0,0, 'a'},
 		{"brief", 0, 0, 'b'},
+		{"completion", 0, &params.opt_completion, 'c'},
 		{"duplicates", 0, &params.opt_dup, 1},
 		{"dump", 0, 0, 'd'},
 		{"expire", 1, 0, 'e'},
@@ -611,7 +420,7 @@ void parse_command_line(int argc, char **argv)
 	opterr = 1;		/* Let getopt report problems to the user */
 
 	while (1) {		/* now cycle through the command line */
-		c = getopt_long(argc, argv, "abde:F:f:g:hj:J:lOPp:s:StUu:Vv",
+		c = getopt_long(argc, argv, "abcde:F:f:g:hj:J:lOPp:s:StUu:Vv",
 				long_options, &optionIndex);
 		if (c == -1)
 			break;
@@ -620,13 +429,10 @@ void parse_command_line(int argc, char **argv)
 			params.opt_uid = -1;
 			break;
 		case 'b':
-			params.opt_field_list =
-				xrealloc(params.opt_field_list,
-					 (params.opt_field_list==NULL? 0 :
-					  sizeof(params.opt_field_list)) +
-					 sizeof(BRIEF_FIELDS)+1);
-			strcat(params.opt_field_list, BRIEF_FIELDS);
-			strcat(params.opt_field_list, ",");
+			brief_output = true;
+			break;
+		case 'c':
+			params.opt_completion = 1;
 			break;
 
 		case 'd':
@@ -736,13 +542,7 @@ void parse_command_line(int argc, char **argv)
 			break;
 
 		case 'l':
-			params.opt_field_list =
-				xrealloc(params.opt_field_list,
-					 (params.opt_field_list==NULL? 0 :
-					  strlen(params.opt_field_list)) +
-					 sizeof(LONG_FIELDS)+1);
-			strcat(params.opt_field_list, LONG_FIELDS);
-			strcat(params.opt_field_list, ",");
+			long_output = true;
 			break;
 
 		case 'O':
@@ -845,6 +645,7 @@ void parse_command_line(int argc, char **argv)
 
 	if (params.opt_verbose) {
 		fprintf(stderr, "Options selected:\n"
+			"\topt_completion=%d\n"
 			"\topt_dump=%d\n"
 			"\topt_dup=%d\n"
 			"\topt_expire=%s (%lu seconds)\n"
@@ -863,6 +664,7 @@ void parse_command_line(int argc, char **argv)
 			"\topt_total=%d\n"
 			"\topt_uid=%d\n"
 			"\topt_verbose=%d\n",
+			params.opt_completion,
 			params.opt_dump,
 			params.opt_dup,
 			params.opt_expire_timespec, params.opt_expire,
@@ -884,15 +686,34 @@ void parse_command_line(int argc, char **argv)
 	}
 
 	/* check if we have accounting data to view */
-	if (params.opt_filein == NULL)
-		params.opt_filein = slurm_get_jobacct_loc();
-	acct_type = slurm_get_jobacct_type();
-	if ((strcmp(acct_type, "jobacct/none") == 0)
-	    &&  (stat(params.opt_filein, &stat_buf) != 0)) {
-		fprintf(stderr, "SLURM accounting is disabled\n");
-		exit(1);
+	if (params.opt_filein == NULL) {
+		if(params.opt_completion) 
+			params.opt_filein = slurm_get_jobcomp_loc();
+		else
+			params.opt_filein = slurm_get_jobacct_loc();	
+	}
+
+	if(params.opt_completion) {
+		database_g_jobcomp_init(params.opt_filein);
+
+		acct_type = slurm_get_jobcomp_type();
+		if ((strcmp(acct_type, "jobcomp/none") == 0)
+		    &&  (stat(params.opt_filein, &stat_buf) != 0)) {
+			fprintf(stderr, "SLURM job completion is disabled\n");
+			exit(1);
+		}
+		xfree(acct_type);
+	} else {
+		database_g_jobacct_init(params.opt_filein);
+		
+		acct_type = slurm_get_jobacct_type();
+		if ((strcmp(acct_type, "jobacct/none") == 0)
+		    &&  (stat(params.opt_filein, &stat_buf) != 0)) {
+			fprintf(stderr, "SLURM accounting is disabled\n");
+			exit(1);
+		}
+		xfree(acct_type);
 	}
-	xfree(acct_type);
 
 	/* specific partitions requested? */
 	if (params.opt_partition_list) {
@@ -926,18 +747,21 @@ void parse_command_line(int argc, char **argv)
 				start++;	/* discard whitespace */
 			if(!(int)*start)
 				continue;
-			selected_step = xmalloc(sizeof(selected_step_t));
+			selected_step = xmalloc(sizeof(jobacct_selected_step_t));
 			list_append(selected_steps, selected_step);
 			
 			dot = strstr(start, ".");
 			if (dot == NULL) {
 				debug2("No jobstep requested");
 				selected_step->step = NULL;
+				selected_step->stepid = (uint32_t)NO_VAL;
 			} else {
 				*dot++ = 0;
 				selected_step->step = xstrdup(dot);
+				selected_step->stepid = atoi(dot);
 			}
 			selected_step->job = xstrdup(start);
+			selected_step->jobid = atoi(start);
 			start = end + 1;
 		}
 		if (params.opt_verbose) {
@@ -977,7 +801,7 @@ void parse_command_line(int argc, char **argv)
 			for(i=0; i< STATUS_COUNT; i++) {
 				if(selected_status[i]) {
 					fprintf(stderr, "\t: %s\n", 
-						decode_status_int(i));
+						job_state_string(i));
 					break;
 				}
 			}
@@ -985,13 +809,48 @@ void parse_command_line(int argc, char **argv)
 	}
 
 	/* select the output fields */
+	if(brief_output) {
+		if(params.opt_completion)
+			dot = BRIEF_COMP_FIELDS;
+		else
+			dot = BRIEF_FIELDS;
+		
+		params.opt_field_list =
+			xrealloc(params.opt_field_list,
+				 (params.opt_field_list==NULL? 0 :
+				  sizeof(params.opt_field_list)) +
+				 strlen(dot)+1);
+		strcat(params.opt_field_list, dot);
+		strcat(params.opt_field_list, ",");
+	} 
+
+	if(long_output) {
+		if(params.opt_completion)
+			dot = LONG_COMP_FIELDS;
+		else
+			dot = LONG_FIELDS;
+		
+		params.opt_field_list =
+			xrealloc(params.opt_field_list,
+				 (params.opt_field_list==NULL? 0 :
+				  strlen(params.opt_field_list)) +
+				 strlen(dot)+1);
+		strcat(params.opt_field_list, dot);
+		strcat(params.opt_field_list, ",");
+	} 
+	
 	if (params.opt_field_list==NULL) {
 		if (params.opt_dump || params.opt_expire)
 			goto endopt;
-		params.opt_field_list = xmalloc(sizeof(DEFAULT_FIELDS)+1);
-		strcpy(params.opt_field_list, DEFAULT_FIELDS); 
+		if(params.opt_completion)
+			dot = DEFAULT_COMP_FIELDS;
+		else
+			dot = DEFAULT_FIELDS;
+		params.opt_field_list = xmalloc(strlen(dot)+1);
+		strcpy(params.opt_field_list, dot); 
 		strcat(params.opt_field_list, ",");
 	}
+
 	start = params.opt_field_list;
 	while ((end = strstr(start, ","))) {
 		*end = 0;
@@ -1049,8 +908,8 @@ void do_dump(void)
 {
 	ListIterator itr = NULL;
 	ListIterator itr_step = NULL;
-	job_rec_t *job = NULL;
-	step_rec_t *step = NULL;
+	jobacct_job_rec_t *job = NULL;
+	jobacct_step_rec_t *step = NULL;
 	struct tm ts;
 	
 	itr = list_iterator_create(jobs);
@@ -1102,11 +961,6 @@ void do_dump(void)
 		/* JOB_STEP */
 		itr_step = list_iterator_create(job->steps);
 		while((step = list_next(itr_step))) {
-			if (step->status == JOB_RUNNING &&
-			    job->job_terminated_seen) {
-				step->status = JOB_FAILED;
-				step->exitcode=1;
-			}
 			_dump_header(step->header);
 			if(step->end == 0)
 				step->end = job->end;
@@ -1117,7 +971,7 @@ void do_dump(void)
 			       1900+(ts.tm_year), 1+(ts.tm_mon), ts.tm_mday,
 			            ts.tm_hour, ts.tm_min, ts.tm_sec);
 			printf("%s %d %d %d %d ",
-			       decode_status_int_abbrev(step->status),
+			       job_state_string_compact(step->status),
 			       step->exitcode,
 			       step->ntasks,
 			       step->ncpus,
@@ -1179,7 +1033,7 @@ void do_dump(void)
 			1900+(ts.tm_year), 1+(ts.tm_mon), ts.tm_mday,
 			      ts.tm_hour, ts.tm_min, ts.tm_sec); 
 			printf("%s %d %d %d %d ",
-			       decode_status_int_abbrev(job->status),
+			       job_state_string_compact(job->status),
 			       job->exitcode,
 			       job->ntasks,
 			       job->ncpus,
@@ -1235,429 +1089,38 @@ void do_dump(void)
 	list_iterator_destroy(itr);		
 }
 
-/* do_expire() -- purge expired data from the accounting log file
- *
- * What we're doing:
- *  1. Open logfile.orig
- *  2. stat logfile.orig
- *     - confirm that it's not a sym link
- *     - capture the ownership and permissions
- *  3. scan logfile.orig for JOB_TERMINATED records with F_TIMESTAMP dates
- *     that precede the specified expiration date. Build exp_table as
- *     a list of expired jobs.
- *  4. Open logfile.expired for append
- *  5. Create logfile.new as ".new.<logfile>" (output with line buffering)
- *  6. Re-scan logfile.orig, writing
- *     - Expired job records to logfile.expired
- *     - Other job records to logfile.new
- *  7. Rename logfile.orig as ".old.<logfile>"
- *  8. Rename logfile.new as "<logfile>"
- *  9. Execute "scontrol reconfigure" which will cause slurmctld to
- *     start writing to logfile.new
- * 10. fseek(ftell(logfile.orig)) to clear EOF
- * 11. Copy any new records from logfile.orig to logfile.new
- * 12. Close logfile.expired, logfile.new
- * 13. Unlink .old.<logfile>
- */
-
-void do_expire(void)
+void do_dump_completion(void)
 {
-	char	line[BUFFER_SIZE],
-		*f[EXPIRE_READ_LENGTH],
-		*fptr = NULL,
-		*logfile_name = NULL,
-		*old_logfile_name = NULL;
-	int	file_err=0,
-		new_file,
-		i = 0;
-	expired_rec_t *exp_rec = NULL;
-	expired_rec_t *exp_rec2 = NULL;
-	List keep_list = list_create(_destroy_exp);
-	List exp_list = list_create(_destroy_exp);
-	List other_list = list_create(_destroy_exp);
-	struct	stat statbuf;
-	mode_t	prot = 0600;
-	uid_t	uid;
-	gid_t	gid;
-	FILE	*expired_logfile = NULL,
-		*new_logfile = NULL;
-	FILE *fd = NULL;
-	int lc=0;
-	int rec_type = -1;
 	ListIterator itr = NULL;
-	ListIterator itr2 = NULL;
-	char *temp = NULL;
-
-	/* Figure out our expiration date */
-	time_t		expiry;
-	expiry = time(NULL)-params.opt_expire;
-	if (params.opt_verbose)
-		fprintf(stderr, "Purging jobs completed prior to %d\n",
-			(int)expiry);
-
-	/* Open the current or specified logfile, or quit */
-	fd = _open_log_file();
-	if (stat(params.opt_filein, &statbuf)) {
-		perror("stat'ing logfile");
-		goto finished;
-	}
-	if ((statbuf.st_mode & S_IFLNK) == S_IFLNK) {
-		fprintf(stderr, "%s is a symbolic link; --expire requires "
-			"a hard-linked file name\n", params.opt_filein);
-		goto finished;
-	}
-	if (!(statbuf.st_mode & S_IFREG)) {
-		fprintf(stderr, "%s is not a regular file; --expire "
-			"only works on accounting log files\n",
-			params.opt_filein);
-		goto finished;
-	}
-	prot = statbuf.st_mode & 0777;
-	gid  = statbuf.st_gid;
-	uid  = statbuf.st_uid;
-	old_logfile_name = _prefix_filename(params.opt_filein, ".old.");
-	if (stat(old_logfile_name, &statbuf)) {
-		if (errno != ENOENT) {
-			fprintf(stderr,"Error checking for %s: ",
-				old_logfile_name);
-			perror("");
-			goto finished;
-		}
-	} else {
-		fprintf(stderr, "Warning! %s exists -- please remove "
-			"or rename it before proceeding\n",
-			old_logfile_name);
-		goto finished;
-	}
-
-	/* create our initial buffer */
-	while (fgets(line, BUFFER_SIZE, fd)) {
-		lc++;
-		fptr = line;	/* break the record into NULL-
-				   terminated strings */
-		exp_rec = xmalloc(sizeof(expired_rec_t));
-		exp_rec->line = xstrdup(line);
-	
-		for (i = 0; i < EXPIRE_READ_LENGTH; i++) {
-			f[i] = fptr;
-			fptr = strstr(fptr, " ");
-			if (fptr == NULL)
-				break; 
-			else
-				*fptr++ = 0;
-		}
-		
-		exp_rec->job = atoi(f[F_JOB]);
-		exp_rec->job_submit = atoi(f[F_JOB_SUBMIT]);
+	jobcomp_job_rec_t *job = NULL;
 		
-		rec_type = atoi(f[F_RECTYPE]);
-		/* Odd, but complain some other time */
-		if (rec_type == JOB_TERMINATED) {
-			if (expiry < atoi(f[F_TIMESTAMP])) {
-				list_append(keep_list, exp_rec);
-				continue;				
-			}
-			if (list_count(selected_parts)) {
-				itr = list_iterator_create(selected_parts);
-				while((temp = list_next(itr))) 
-					if(!strcasecmp(f[F_PARTITION], temp)) 
-						break;
-				list_iterator_destroy(itr);
-				if(!temp) {
-					list_append(keep_list, exp_rec);
-					continue;
-				} /* no match */
-			}
-			list_append(exp_list, exp_rec);
-			if (params.opt_verbose > 2)
-				fprintf(stderr, "Selected: %8d %d\n",
-					exp_rec->job,
-					(int)exp_rec->job_submit);
-		} else {
-			list_append(other_list, exp_rec);
-		}
-	}
-	if (!list_count(exp_list)) {
-		printf("No job records were purged.\n");
-		goto finished;
-	}
-	logfile_name = xmalloc(strlen(params.opt_filein)+sizeof(".expired"));
-	sprintf(logfile_name, "%s.expired", params.opt_filein);
-	new_file = stat(logfile_name, &statbuf);
-	if ((expired_logfile = fopen(logfile_name, "a"))==NULL) {
-		fprintf(stderr, "Error while opening %s", 
-			logfile_name);
-		perror("");
-		xfree(logfile_name);
-		goto finished;
-	}
-
-	if (new_file) {  /* By default, the expired file looks like the log */
-		chmod(logfile_name, prot);
-		chown(logfile_name, uid, gid);
-	}
-	xfree(logfile_name);
-
-	logfile_name = _prefix_filename(params.opt_filein, ".new.");
-	if ((new_logfile = fopen(logfile_name, "w"))==NULL) {
-		fprintf(stderr, "Error while opening %s",
-			logfile_name);
-		perror("");
-		fclose(expired_logfile);
-		goto finished;
-	}
-	chmod(logfile_name, prot);     /* preserve file protection */
-	chown(logfile_name, uid, gid); /* and ownership */
-	/* Use line buffering to allow us to safely write
-	 * to the log file at the same time as slurmctld. */ 
-	if (setvbuf(new_logfile, NULL, _IOLBF, 0)) {
-		perror("setvbuf()");
-		fclose(expired_logfile);
-		goto finished2;
-	}
-
-	list_sort(exp_list, (ListCmpF) _cmp_jrec);
-	list_sort(keep_list, (ListCmpF) _cmp_jrec);
-	
-	if (params.opt_verbose > 2) {
-		fprintf(stderr, "--- contents of exp_list ---");
-		itr = list_iterator_create(exp_list);
-		while((exp_rec = list_next(itr))) {
-			if (!(i%5))
-				fprintf(stderr, "\n");
-			else
-				fprintf(stderr, "\t");
-			fprintf(stderr, "%d", exp_rec->job);
-		}
-		fprintf(stderr, "\n---- end of exp_list ---\n");
-		list_iterator_destroy(itr);
-	}
-	/* write the expired file */
-	itr = list_iterator_create(exp_list);
-	while((exp_rec = list_next(itr))) {
-		itr2 = list_iterator_create(other_list);
-		while((exp_rec2 = list_next(itr2))) {
-			if((exp_rec2->job != exp_rec->job) 
-			   || (exp_rec2->job_submit != exp_rec->job_submit))
-				continue;
-			if (fputs(exp_rec2->line, expired_logfile)<0) {
-				perror("writing expired_logfile");
-				list_iterator_destroy(itr2);
-				list_iterator_destroy(itr);
-				fclose(expired_logfile);
-				goto finished2;
-			}
-			list_remove(itr2);
-			_destroy_exp(exp_rec2);
-		}
-		list_iterator_destroy(itr2);
-		if (fputs(exp_rec->line, expired_logfile)<0) {
-			perror("writing expired_logfile");
-			list_iterator_destroy(itr);
-			fclose(expired_logfile);
-			goto finished2;
-		}		
-	}
-	list_iterator_destroy(itr);
-	fclose(expired_logfile);
-	
-	/* write the new log */
-	itr = list_iterator_create(keep_list);
-	while((exp_rec = list_next(itr))) {
-		itr2 = list_iterator_create(other_list);
-		while((exp_rec2 = list_next(itr2))) {
-			if(exp_rec2->job != exp_rec->job)
-				continue;
-			if (fputs(exp_rec2->line, new_logfile)<0) {
-				perror("writing keep_logfile");
-				list_iterator_destroy(itr2);
-				list_iterator_destroy(itr);
-				goto finished2;
-			}
-			list_remove(itr2);
-			_destroy_exp(exp_rec2);
-		}
-		list_iterator_destroy(itr2);
-		if (fputs(exp_rec->line, new_logfile)<0) {
-			perror("writing keep_logfile");
-			list_iterator_destroy(itr);
-			goto finished2;
-		}		
+	itr = list_iterator_create(jobs);
+	while((job = list_next(itr))) {
+		printf("JOB %u %s %s %s %s(%u) %u(%s) %u %s %s %s %s",
+		       job->jobid, job->partition, job->start_time,
+		       job->end_time, job->uid_name, job->uid, job->gid,
+		       job->gid_name, job->node_cnt, job->nodelist, 
+		       job->jobname, job->state,
+		       job->timelimit);
+		if(job->blockid)
+			printf(" %s %s %s %s %u %s %s",
+			       job->blockid, job->connection, job->reboot,
+			       job->rotate, job->max_procs, job->geo,
+			       job->bg_start_point);
+		printf("\n");
 	}
 	list_iterator_destroy(itr);
-	
-	if (rename(params.opt_filein, old_logfile_name)) {
-		perror("renaming logfile to .old.");
-		goto finished2;
-	}
-	if (rename(logfile_name, params.opt_filein)) {
-		perror("renaming new logfile");
-		/* undo it? */
-		if (!rename(old_logfile_name, params.opt_filein)) 
-			fprintf(stderr, "Please correct the problem "
-				"and try again");
-		else
-			fprintf(stderr, "SEVERE ERROR: Current accounting "
-				"log may have been renamed %s;\n"
-				"please rename it to \"%s\" if necessary, "
-			        "and try again\n",
-				old_logfile_name, params.opt_filein);
-		goto finished2;
-	}
-	fflush(new_logfile);	/* Flush the buffers before forking */
-	fflush(fd);
-	
-	file_err = slurm_reconfigure ();
-	
-	if (file_err) {
-		file_err = 1;
-		fprintf(stderr, "Error: Attempt to reconfigure "
-			"SLURM failed.\n");
-		if (rename(old_logfile_name, params.opt_filein)) {
-			perror("renaming logfile from .old.");
-			goto finished2;
-		}
-
-	}
-	if (fseek(fd, 0, SEEK_CUR)) {	/* clear EOF */
-		perror("looking for late-arriving records");
-		goto finished2;
-	}
-	while (fgets(line, BUFFER_SIZE, fd)) {
-		if (fputs(line, new_logfile)<0) {
-			perror("writing final records");
-			goto finished2;
-		}
-	}
-	
-	printf("%d jobs expired.\n", list_count(exp_list));
-finished2:
-	fclose(new_logfile);
-	if (!file_err) {
-		if (unlink(old_logfile_name) == -1)
-			error("Unable to unlink old logfile %s: %m",
-			      old_logfile_name);
-	}
-finished:
-	fclose(fd);
-	list_destroy(exp_list);
-	list_destroy(keep_list);
-	list_destroy(other_list);
-	xfree(old_logfile_name);
-	xfree(logfile_name);
 }
 
-void do_fdump(char* f[], int lc)
+/* do_expire() -- purge expired data from the accounting log file
+ */
+
+void do_expire(void)
 {
-	int	i=0, j=0;
-	char **type;
-	char    *header[] = {"job",       /* F_JOB */
-			     "partition", /* F_PARTITION */
-			     "job_submit", /* F_JOB_SUBMIT */
-			     "timestamp", /* F_TIMESTAMP */
-			     "uid",	 /* F_UIDGID */
-			     "gid",	 /* F_UIDGID */
-			     "BlockID",  /* F_BLOCKID */
-			     "reserved-2",/* F_RESERVED1 */
-			     "recordType",/* F_RECTYPE */
-			     NULL};
-
-	char	*start[] = {"jobName",	 /* F_JOBNAME */ 
-			    "TrackSteps", /* F_TRACK_STEPS */
-			    "priority",	 /* F_PRIORITY */
-			    "ncpus",	 /* F_NCPUS */
-			    "nodeList", /* F_NODES */
-				"account",   /* F_JOB_ACCOUNT */
-			    NULL};
-		
-	char	*step[] = {"jobStep",	 /* F_JOBSTEP */
-			   "status",	 /* F_STATUS */ 
-			   "exitcode",	 /* F_EXITCODE */
-			   "ntasks",	 /* F_NTASKS */
-			   "ncpus",	 /* F_STEPNCPUS */
-			   "elapsed",	 /* F_ELAPSED */
-			   "cpu_sec",	 /* F_CPU_SEC */
-			   "cpu_usec",	 /* F_CPU_USEC */
-			   "user_sec",	 /* F_USER_SEC */
-			   "user_usec",	 /* F_USER_USEC */
-			   "sys_sec",	 /* F_SYS_SEC */
-			   "sys_usec",	 /* F_SYS_USEC */
-			   "rss",	 /* F_RSS */
-			   "ixrss",	 /* F_IXRSS */
-			   "idrss",	 /* F_IDRSS */
-			   "isrss",	 /* F_ISRSS */
-			   "minflt",	 /* F_MINFLT */
-			   "majflt",	 /* F_MAJFLT */
-			   "nswap",	 /* F_NSWAP */
-			   "inblocks",	 /* F_INBLOCKS */
-			   "oublocks",	 /* F_OUTBLOCKS */
-			   "msgsnd",	 /* F_MSGSND */
-			   "msgrcv",	 /* F_MSGRCV */
-			   "nsignals",	 /* F_NSIGNALS */
-			   "nvcsw",	 /* F_VCSW */
-			   "nivcsw",	 /* F_NIVCSW */
-			   "max_vsize",	 /* F_MAX_VSIZE */
-			   "max_vsize_task",	 /* F_MAX_VSIZE_TASK */
-			   "ave_vsize",	 /* F_AVE_VSIZE */
-			   "max_rss",	 /* F_MAX_RSS */
-			   "max_rss_task",	 /* F_MAX_RSS_TASK */
-			   "ave_rss",	 /* F_AVE_RSS */
-			   "max_pages",	 /* F_MAX_PAGES */
-			   "max_pages_task",	 /* F_MAX_PAGES_TASK */
-			   "ave_pages",	 /* F_AVE_PAGES */
-			   "min_cputime",	 /* F_MIN_CPU */
-			   "min_cputime_task",	 /* F_MIN_CPU_TASK */
-			   "ave_cputime",	 /* F_AVE_RSS */
-			   "StepName",	 /* F_STEPNAME */
-			   "StepNodes",	 /* F_STEPNODES */
-			   "max_vsize_node",	 /* F_MAX_VSIZE_NODE */
-			   "max_rss_node",	 /* F_MAX_RSS_NODE */
-			   "max_pages_node",	 /* F_MAX_PAGES_NODE */
-			   "min_cputime_node",	 /* F_MIN_CPU_NODE */
-			   "account",    /* F_STEP_ACCOUNT */
-			   "requid",     /* F_STEP_REQUID */
-			   NULL};
-       
-	char	*suspend[] = {"Suspend/Run time", /* F_TOT_ELAPSED */
-			      "status",	 /* F_STATUS */ 
-			      NULL};	 
-
-	char	*term[] = {"totElapsed", /* F_TOT_ELAPSED */
-			   "status",	 /* F_STATUS */ 
-			   "requid",     /* F_JOB_REQUID */
-			   NULL};	 
-		
-	i = atoi(f[F_RECTYPE]);
-	printf("\n------- Line %d %s -------\n", lc, _convert_type(i));
-
-	for(j=0; j < HEADER_LENGTH; j++) 
-		printf("%12s: %s\n", header[j], f[j]);
-	switch(i) {
-	case JOB_START:
-		type = start;
-		j = JOB_START_LENGTH;
-		break;
-	case JOB_STEP:
-		type = step;
-		j = JOB_STEP_LENGTH;
-		break;
-	case JOB_SUSPEND:
-		type = suspend;
-		j = JOB_TERM_LENGTH;
-	case JOB_TERMINATED:
-		type = term;
-		j = JOB_TERM_LENGTH;
-		break;
-	default:
-		while(f[j]) {
-			printf("      Field[%02d]: %s\n", j, f[j]); 
-			j++;
-		}
-		return;
-	}
-	
-	for(i=HEADER_LENGTH; i < j; i++)
-       		printf("%12s: %s\n", type[i-HEADER_LENGTH], f[i]);	
+	if(params.opt_completion) 
+		database_g_jobcomp_archive(selected_parts, &params);
+	else
+		database_g_jobacct_archive(selected_parts, &params);
 }
 
 void do_help(void)
@@ -1693,12 +1156,12 @@ void do_list(void)
 	
 	ListIterator itr = NULL;
 	ListIterator itr_step = NULL;
-	job_rec_t *job = NULL;
-	step_rec_t *step = NULL;
+	jobacct_job_rec_t *job = NULL;
+	jobacct_step_rec_t *step = NULL;
 	
 	if (params.opt_total)
 		do_jobsteps = 0;
-	
+
 	itr = list_iterator_create(jobs);
 	while((job = list_next(itr))) {
 		if (!params.opt_dup)
@@ -1762,10 +1225,6 @@ void do_list(void)
 		if (do_jobsteps && (job->track_steps || !job->show_full)) {
 			itr_step = list_iterator_create(job->steps);
 			while((step = list_next(itr_step))) {
-				if (step->status == JOB_RUNNING 
-				    && job->job_terminated_seen) {
-					step->status = JOB_FAILED;
-				}
 				if (params.opt_state_list) {
 					if(!selected_status[step->status])
 						continue;
@@ -1780,12 +1239,36 @@ void do_list(void)
 	list_iterator_destroy(itr);
 }
 
+/* do_list_completion() -- List the assembled data
+ *
+ * In:	Nothing explicit.
+ * Out:	void.
+ *
+ * At this point, we have already selected the desired data,
+ * so we just need to print it for the user.
+ */
+void do_list_completion(void)
+{
+	ListIterator itr = NULL;
+	jobcomp_job_rec_t *job = NULL;
+	
+	itr = list_iterator_create(jobs);
+	while((job = list_next(itr))) {
+		if (params.opt_uid >= 0 && (job->uid != params.opt_uid))
+			continue;
+		if (params.opt_gid >= 0 && (job->gid != params.opt_gid))
+			continue;
+		print_fields(JOBCOMP, job);
+	}
+	list_iterator_destroy(itr);
+}
+
 void do_stat()
 {
 	ListIterator itr = NULL;
 	uint32_t jobid = 0;
 	uint32_t stepid = 0;
-	selected_step_t *selected_step = NULL;
+	jobacct_selected_step_t *selected_step = NULL;
 	
 	itr = list_iterator_create(selected_steps);
 	while((selected_step = list_next(itr))) {
@@ -1801,7 +1284,6 @@ void do_stat()
 void sacct_init()
 {
 	int i=0;
-	jobs = list_create(destroy_job);
 	selected_parts = list_create(_destroy_parts);
 	selected_steps = list_create(_destroy_steps);
 	for(i=0; i<STATUS_COUNT; i++)
@@ -1810,7 +1292,12 @@ void sacct_init()
 
 void sacct_fini()
 {
-	list_destroy(jobs);
+	if(jobs)
+		list_destroy(jobs);
 	list_destroy(selected_parts);
 	list_destroy(selected_steps);
+	if(params.opt_completion)
+		database_g_jobcomp_fini();
+	else
+		database_g_jobacct_fini();
 }
diff --git a/src/sacct/print.c b/src/sacct/print.c
index 3de3f88d2e9e110a20bd3a6bcc7b285d97fc62cb..1b7e872023dada0053257e16ce8dff17e83fd050 100644
--- a/src/sacct/print.c
+++ b/src/sacct/print.c
@@ -97,98 +97,115 @@ void print_fields(type_t type, void *object)
 
 void print_cpu(type_t type, void *object)
 {
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 	char str[FORMAT_STRING_SIZE];
 	
 	switch(type) {
 	case HEADLINE:
-		printf("%15s", "Cpu");
+		printf("%-15s", "Cpu");
 		break;
 	case UNDERSCORE:
-		printf("%15s", "---------------");
+		printf("%-15s", "---------------");
 		break;
 	case JOB:
 		_elapsed_time(job->tot_cpu_sec, job->tot_cpu_usec, str);
-		printf("%15s", str);
+		printf("%-15s", str);
 		break;
 	case JOBSTEP:
 		_elapsed_time(step->tot_cpu_sec, step->tot_cpu_usec, str);
-		printf("%15s", str);
+		printf("%-15s", str);
+		break;
+	default:
+		printf("%-15s", "n/a");
 		break;
 	} 
 }
 
 void print_elapsed(type_t type, void *object)
 {
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 	char str[FORMAT_STRING_SIZE];
 
 	switch(type) {
 	case HEADLINE:
-		printf("%15s", "Elapsed");
+		printf("%-15s", "Elapsed");
 		break;
 	case UNDERSCORE:
-		printf("%15s", "---------------");
+		printf("%-15s", "---------------");
 		break;
 	case JOB:
 		_elapsed_time(job->elapsed, 0, str);
-		printf("%15s", str);
+		printf("%-15s", str);
 		break;
 	case JOBSTEP:
 		_elapsed_time(step->elapsed, 0, str);
-		printf("%15s", str);
+		printf("%-15s", str);
+		break;
+	default:
+		printf("%-15s", "n/a");
 		break;
 	} 
 }
 
 void print_exitcode(type_t type, void *object)
 {
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 
 	switch(type) {
 	case HEADLINE:
-		printf("%8s", "ExitCode");
+		printf("%-8s", "ExitCode");
 		break;
 	case UNDERSCORE:
-		printf("%8s", "--------");
+		printf("%-8s", "--------");
 		break;
 	case JOB:
-		printf("%8d", job->exitcode);
+		printf("%-8u", job->exitcode);
 		break;
 	case JOBSTEP:
-		printf("%8d", step->exitcode);
+		printf("%-8u", step->exitcode);
+		break;
+	default:
+		printf("%-8s", "n/a");
 		break;
 	} 
 }
 
 void print_gid(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 
 	switch(type) {
 	case HEADLINE:
-		printf("%5s", "Gid");
+		printf("%-5s", "Gid");
 		break;
 	case UNDERSCORE:
-		printf("%5s", "-----");
+		printf("%-5s", "-----");
 		break;
 	case JOB:
-		printf("%5d", job->header.gid);
+		printf("%-5u", job->header.gid);
+		break;
+	case JOBCOMP:
+		printf("%-5u", jobcomp->gid);
 		break;
 	case JOBSTEP:
-		printf("s%5d", step->header.gid);
+		printf("%-5u", step->header.gid);
+		break;
+	default:
+		printf("%-5s", "n/a");
 		break;
 	} 
 }
 
 void print_group(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 	int gid = -1;
 	char	*tmp="(unknown)";
 	struct	group *gr = NULL;
@@ -203,9 +220,15 @@ void print_group(type_t type, void *object)
 	case JOB:
 		gid = job->header.gid;
 		break;
+	case JOBCOMP:
+		printf("%-9s", jobcomp->gid_name);
+		break;
 	case JOBSTEP:
 		gid = step->header.gid;
 		break;
+	default:
+		printf("%-9s", "n/a");
+		break;
 	}
 	if(gid != -1) {
 		if ((gr=getgrgid(gid)))
@@ -216,19 +239,19 @@ void print_group(type_t type, void *object)
 
 void print_idrss(type_t type, void *object)
 {
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 	struct rusage rusage;
 	char outbuf[FORMAT_STRING_SIZE];
-	rusage.ru_idrss = 0;
+	rusage.ru_idrss = -1;
 	
 	switch(type) {
 	case HEADLINE:
-		printf("%8s", "Idrss");
+		printf("%-8s", "Idrss");
 		return;
 		break;
 	case UNDERSCORE:
-		printf("%8s", "------");
+		printf("%-8s", "------");
 		return;
 		break;
 	case JOB:
@@ -237,49 +260,60 @@ void print_idrss(type_t type, void *object)
 	case JOBSTEP:
 		rusage = step->rusage;
 		break;
+	default:
+		printf("%-8s", "n/a");
+		break;
 	} 
-	convert_num_unit((float)rusage.ru_idrss, outbuf, UNIT_NONE);
-	printf("%8s", outbuf);
+	if(rusage.ru_idrss != -1) {
+		convert_num_unit((float)rusage.ru_idrss, outbuf, UNIT_NONE);
+		printf("%8s", outbuf);
+	}
 }
 
 void print_inblocks(type_t type, void *object)
 {
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 
 	switch(type) {
 	case HEADLINE:
-		printf("%9s", "Inblocks");
+		printf("%-9s", "Inblocks");
 		break;
 	case UNDERSCORE:
-		printf("%9s", "---------");
+		printf("%-9s", "---------");
 		break;
 	case JOB:
-		printf("%9ld", job->rusage.ru_inblock);
+		printf("%-9ld", job->rusage.ru_inblock);
 		break;
 	case JOBSTEP:
-		printf("%9ld", step->rusage.ru_inblock);
+		printf("%-9ld", step->rusage.ru_inblock);
+		break;
+	default:
+		printf("%-9s", "n/a");
 		break;
 	} 
 }
 
 void print_isrss(type_t type, void *object)
 {
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 
 	switch(type) {
 	case HEADLINE:
-		printf("%8s", "Isrss");
+		printf("%-8s", "Isrss");
 		break;
 	case UNDERSCORE:
-		printf("%8s", "------");
+		printf("%-8s", "------");
 		break;
 	case JOB:
-		printf("%8ld", job->rusage.ru_isrss);
+		printf("%-8ld", job->rusage.ru_isrss);
 		break;
 	case JOBSTEP:
-		printf("%8ld", step->rusage.ru_isrss);
+		printf("%-8ld", step->rusage.ru_isrss);
+		break;
+	default:
+		printf("%-8s", "n/a");
 		break;
 	} 
 
@@ -287,21 +321,24 @@ void print_isrss(type_t type, void *object)
 
 void print_ixrss(type_t type, void *object)
 {
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 
 	switch(type) {
 	case HEADLINE:
-		printf("%8s", "Ixrss");
+		printf("%-8s", "Ixrss");
 		break;
 	case UNDERSCORE:
-		printf("%8s", "------");
+		printf("%-8s", "------");
 		break;
 	case JOB:
-		printf("%8ld", job->rusage.ru_ixrss);
+		printf("%-8ld", job->rusage.ru_ixrss);
 		break;
 	case JOBSTEP:
-		printf("%8ld", step->rusage.ru_ixrss);
+		printf("%-8ld", step->rusage.ru_ixrss);
+		break;
+	default:
+		printf("%-8s", "n/a");
 		break;
 	} 
 
@@ -309,29 +346,33 @@ void print_ixrss(type_t type, void *object)
 
 void print_job(type_t type, void *object)
 {
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 
 	switch(type) {
 	case HEADLINE:
-		printf("%8s", "Job");
+		printf("%-8s", "Job");
 		break;
 	case UNDERSCORE:
-		printf("%8s", "--------");
+		printf("%-8s", "--------");
 		break;
 	case JOB:
-		printf("%8d", job->header.jobnum);
+		printf("%-8u", job->header.jobnum);
 		break;
 	case JOBSTEP:
-		printf("%8d", step->header.jobnum);
+		printf("%-8u", step->header.jobnum);
+		break;
+	default:
+		printf("%-8s", "n/a");
 		break;
 	} 
 }
 
 void print_name(type_t type, void *object)
 {
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 
 	switch(type) {
 	case HEADLINE:
@@ -348,6 +389,15 @@ void print_name(type_t type, void *object)
 		else
 			printf("%-15.15s...", job->jobname);
 			
+		break;
+	case JOBCOMP:
+		if(!jobcomp->jobname)
+			printf("%-18s", "unknown");			     
+		else if(strlen(jobcomp->jobname)<19)
+			printf("%-18s", jobcomp->jobname);
+		else
+			printf("%-15.15s...", jobcomp->jobname);
+			
 		break;
 	case JOBSTEP:
 		if(!step->stepname)
@@ -357,13 +407,17 @@ void print_name(type_t type, void *object)
 		else
 			printf("%-15.15s...", step->stepname);
 		break;
+	default:
+		printf("%-18s", "n/a");
+		break;
 	} 
 }
 
 void print_jobid(type_t type, void *object)
 {
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 	char outbuf[10];
 
 	switch(type) {
@@ -374,7 +428,10 @@ void print_jobid(type_t type, void *object)
 		printf("%-10s", "----------");
 		break;
 	case JOB:
-		printf("%-10d", job->header.jobnum);
+		printf("%-10u", job->header.jobnum);
+		break;
+	case JOBCOMP:
+		printf("%-10u", jobcomp->jobid);
 		break;
 	case JOBSTEP:
 		snprintf(outbuf, sizeof(outbuf), "%u.%u",
@@ -382,14 +439,17 @@ void print_jobid(type_t type, void *object)
 			 step->stepnum);
 		printf("%-10s", outbuf);
 		break;
+	default:
+		printf("%-10s", "n/a");
+		break;
 	} 
 
 }
 
 void print_majflt(type_t type, void *object)
 {
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 
 	switch(type) {
 	case HEADLINE:
@@ -399,109 +459,124 @@ void print_majflt(type_t type, void *object)
 		printf("%8s", "------");
 		break;
 	case JOB:
-		printf("%8ld", job->rusage.ru_majflt);
+		printf("%-8ld", job->rusage.ru_majflt);
 		break;
 	case JOBSTEP:
-		printf("%8ld", step->rusage.ru_majflt);
+		printf("%-8ld", step->rusage.ru_majflt);
+		break;
+	default:
+		printf("%-8s", "n/a");
 		break;
 	} 
 }
 
 void print_minflt(type_t type, void *object)
 {
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 
 	switch(type) {
 	case HEADLINE:
-		printf("%8s", "Minflt");
+		printf("%-8s", "Minflt");
 		break;
 	case UNDERSCORE:
-		printf("%8s", "------");
+		printf("%-8s", "------");
 		break;
 	case JOB:
-		printf("%8ld", job->rusage.ru_minflt);
+		printf("%-8ld", job->rusage.ru_minflt);
 		break;
 	case JOBSTEP:
-		printf("%8ld", step->rusage.ru_minflt);
+		printf("%-8ld", step->rusage.ru_minflt);
+		break;
+	default:
+		printf("%-8s", "n/a");
 		break;
 	} 
 }
 
 void print_msgrcv(type_t type, void *object)
 {
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 
 	switch(type) {
 	case HEADLINE:
-		printf("%9s", "Msgrcv");
+		printf("%-9s", "Msgrcv");
 		break;
 	case UNDERSCORE:
-		printf("%9s", "---------");
+		printf("%-9s", "---------");
 		break;
 	case JOB:
-		printf("%9ld", job->rusage.ru_msgrcv);
+		printf("%-9ld", job->rusage.ru_msgrcv);
 		break;
 	case JOBSTEP:
-		printf("%9ld", step->rusage.ru_msgrcv);
+		printf("%-9ld", step->rusage.ru_msgrcv);
+		break;
+	default:
+		printf("%-9s", "n/a");
 		break;
 	} 
 }
 
 void print_msgsnd(type_t type, void *object)
 {
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 
 	switch(type) {
 	case HEADLINE:
-		printf("%9s", "Msgsnd");
+		printf("%-9s", "Msgsnd");
 		break;
 	case UNDERSCORE:
-		printf("%9s", "---------");
+		printf("%-9s", "---------");
 		break;
 	case JOB:
-		printf("%9ld", job->rusage.ru_msgsnd);
+		printf("%-9ld", job->rusage.ru_msgsnd);
 		break;
 	case JOBSTEP:
-		printf("%9ld", step->rusage.ru_msgsnd);
+		printf("%-9ld", step->rusage.ru_msgsnd);
+		break;
+	default:
+		printf("%-9s", "n/a");
 		break;
 	} 
 }
 
 void print_ncpus(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 
 	switch(type) {
 	case HEADLINE:
-		printf("%7s", "Ncpus");
+		printf("%-7s", "Ncpus");
 		break;
 	case UNDERSCORE:
-		printf("%7s", "-------");
+		printf("%-7s", "-------");
 		break;
 	case JOB:
-		printf("%7d", job->ncpus);
+		printf("%-7u", job->ncpus);
 		break;
 	case JOBSTEP:
-		printf("%7d", step->ncpus);
+		printf("%-7u", step->ncpus);
+		break;
+	default:
+		printf("%-7s", "n/a");
 		break;
 	} 
 }
 
 void print_nivcsw(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 
 	switch(type) {
 	case HEADLINE:
-		printf("%9s", "Nivcsw");
+		printf("%-9s", "Nivcsw");
 		break;
 	case UNDERSCORE:
-		printf("%9s", "---------");
+		printf("%-9s", "---------");
 		break;
 	case JOB:
 		printf("%9ld", job->rusage.ru_nivcsw);
@@ -509,13 +584,18 @@ void print_nivcsw(type_t type, void *object)
 	case JOBSTEP:
 		printf("%9ld", step->rusage.ru_nivcsw);
 		break;
+	default:
+		printf("%-9s", "n/a");
+		break;
 	} 
 }
 
 void print_nodes(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
+	
 	switch(type) {
 	case HEADLINE:
 		printf("%-30s", "Nodes");
@@ -526,121 +606,165 @@ void print_nodes(type_t type, void *object)
 	case JOB:
 		printf("%-30s", job->nodes);
 		break;
+	case JOBCOMP:
+		printf("%-30s", jobcomp->nodelist);
+		break;
 	case JOBSTEP:
-		printf("%-30s", "                              ");
+		printf("%-30s", step->nodes);
+		break;
+	default:
+		printf("%-30s", "n/a");
+		break;
+	} 
+}
+
+void print_nnodes(type_t type, void *object)
+{ 
+	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
+	char temp[FORMAT_STRING_SIZE];
+
+	switch(type) {
+	case HEADLINE:
+		printf("%-8s", "Node Cnt");
+		break;
+	case UNDERSCORE:
+		printf("%-8s", "--------");
+		break;
+	case JOBCOMP:
+		convert_num_unit((float)jobcomp->node_cnt, temp, UNIT_NONE);
+		printf("%-8s", temp);
+		break;
+	default:
+		printf("%-8s", "n/a");
 		break;
 	} 
 }
 
 void print_nsignals(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 
 	switch(type) {
 	case HEADLINE:
-		printf("%9s", "Nsignals");
+		printf("%-9s", "Nsignals");
 		break;
 	case UNDERSCORE:
-		printf("%9s", "---------");
+		printf("%-9s", "---------");
 		break;
 	case JOB:
-		printf("%9ld", job->rusage.ru_nsignals);
+		printf("%-9ld", job->rusage.ru_nsignals);
 		break;
 	case JOBSTEP:
-		printf("%9ld", step->rusage.ru_nsignals);
+		printf("%-9ld", step->rusage.ru_nsignals);
+		break;
+	default:
+		printf("%-9s", "n/a");
 		break;
 	} 
 }
 
 void print_nswap(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 
 	switch(type) {
 	case HEADLINE:
-		printf("%8s", "Nswap");
+		printf("%-8s", "Nswap");
 		break;
 	case UNDERSCORE:
-		printf("%8s", "------");
+		printf("%-8s", "------");
 		break;
 	case JOB:
-		printf("%8ld", job->rusage.ru_nswap);
+		printf("%-8ld", job->rusage.ru_nswap);
 		break;
 	case JOBSTEP:
-		printf("%8ld", step->rusage.ru_nswap);
+		printf("%-8ld", step->rusage.ru_nswap);
+		break;
+	default:
+		printf("%-8s", "n/a");
 		break;
 	} 
 }
 
 void print_ntasks(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 
 	switch(type) {
 	case HEADLINE:
-		printf("%7s", "Ntasks");
+		printf("%-7s", "Ntasks");
 		break;
 	case UNDERSCORE:
-		printf("%7s", "-------");
+		printf("%-7s", "-------");
 		break;
 	case JOB:
-		printf("%7d", job->ntasks);
+		printf("%-7u", job->ntasks);
 		break;
 	case JOBSTEP:
-		printf("%7d", step->ntasks);
+		printf("%-7u", step->ntasks);
+		break;
+	default:
+		printf("%-7s", "n/a");
 		break;
 	} 
 }
 
 void print_nvcsw(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 
 	switch(type) {
 	case HEADLINE:
-		printf("%9s", "Nvcsw");
+		printf("%-9s", "Nvcsw");
 		break;
 	case UNDERSCORE:
-		printf("%9s", "---------");
+		printf("%-9s", "---------");
 		break;
 	case JOB:
-		printf("%9ld", job->rusage.ru_nvcsw);
+		printf("%-9ld", job->rusage.ru_nvcsw);
 		break;
 	case JOBSTEP:
-		printf("%9ld", step->rusage.ru_nvcsw);
+		printf("%-9ld", step->rusage.ru_nvcsw);
+		break;
+	default:
+		printf("%-9s", "n/a");
 		break;
 	} 
 }
 
 void print_outblocks(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 
 	switch(type) {
 	case HEADLINE:
-		printf("%9s", "Outblocks");
+		printf("%-9s", "Outblocks");
 		break;
 	case UNDERSCORE:
-		printf("%9s", "---------");
+		printf("%-9s", "---------");
 		break;
 	case JOB:
-		printf("%9ld", job->rusage.ru_oublock);
+		printf("%-9ld", job->rusage.ru_oublock);
 		break;
 	case JOBSTEP:
-		printf("%9ld", step->rusage.ru_oublock);
+		printf("%-9ld", step->rusage.ru_oublock);
+		break;
+	default:
+		printf("%-9s", "n/a");
 		break;
 	} 
 }
 
 void print_partition(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 
 	switch(type) {
 	case HEADLINE:
@@ -657,6 +781,15 @@ void print_partition(type_t type, void *object)
 		else
 			printf("%-7.7s...", job->header.partition);
 		
+		break;
+	case JOBCOMP:
+		if(!jobcomp->partition)
+			printf("%-10s", "unknown");			     
+		else if(strlen(jobcomp->partition)<11)
+			printf("%-10s", jobcomp->partition);
+		else
+			printf("%-7.7s...", jobcomp->partition);
+		
 		break;
 	case JOBSTEP:
 		if(!step->header.partition)
@@ -667,13 +800,17 @@ void print_partition(type_t type, void *object)
 			printf("%-7.7s...", step->header.partition);
 	
 		break;
+	default:
+		printf("%-10s", "n/a");
+		break;
 	} 
 }
 
 void print_blockid(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 
 	switch(type) {
 	case HEADLINE:
@@ -690,6 +827,15 @@ void print_blockid(type_t type, void *object)
 		else
 			printf("%-13.13s...", job->header.blockid);
 		
+		break;
+	case JOBCOMP:
+		if(!jobcomp->blockid)
+			printf("%-16s", "unknown");			     
+		else if(strlen(jobcomp->blockid)<17)
+			printf("%-16s", jobcomp->blockid);
+		else
+			printf("%-13.13s...", jobcomp->blockid);
+		
 		break;
 	case JOBSTEP:
 		if(!step->header.blockid)
@@ -700,13 +846,16 @@ void print_blockid(type_t type, void *object)
 			printf("%-13.13s...", step->header.blockid);
 	
 		break;
+	default:
+		printf("%-16s", "n/a");
+		break;
 	} 
 }
 
 void print_pages(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 	char outbuf[FORMAT_STRING_SIZE];
 	char buf1[FORMAT_STRING_SIZE];
 	char buf2[FORMAT_STRING_SIZE];
@@ -756,13 +905,16 @@ void print_pages(type_t type, void *object)
 			 buf2);
 		printf("%-50s", outbuf);
 		break;
+	default:
+		printf("%-50s", "n/a");
+		break;
 	} 
 }
 
 void print_rss(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 	char outbuf[FORMAT_STRING_SIZE];
 	char buf1[FORMAT_STRING_SIZE];
 	char buf2[FORMAT_STRING_SIZE];
@@ -812,13 +964,17 @@ void print_rss(type_t type, void *object)
 			 buf2);
 		printf("%-50s", outbuf);
 		break;
+	default:
+		printf("%-50s", "n/a");
+		break;
 	} 
 }
 
 void print_status(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 
 	switch(type) {
 	case HEADLINE:
@@ -830,28 +986,34 @@ void print_status(type_t type, void *object)
 	case JOB:
 		if ( job->status == JOB_CANCELLED) {
 			printf ("%-10s by %6d",
-				decode_status_int(job->status), job->requid);
+				job_state_string(job->status), job->requid);
 		}
 		else {
-			printf("%-20s", decode_status_int(job->status));
+			printf("%-20s", job_state_string(job->status));
 		}
 		break;
+	case JOBCOMP:
+		printf("%-20s", jobcomp->state);
+		break;
 	case JOBSTEP:
 		if ( step->status == JOB_CANCELLED) {
 			printf ("%-10s by %6d",
-				decode_status_int(step->status), step->requid);
+				job_state_string(step->status), step->requid);
 		}
 		else {
-			printf("%-20s", decode_status_int(step->status));
+			printf("%-20s", job_state_string(step->status));
 		}
 		break;
+	default:
+		printf("%-20s", "n/a");
+		break;
 	} 
 }
 
 void print_submit(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 	char time_str[32];
 		
 	switch(type) {
@@ -873,117 +1035,161 @@ void print_submit(type_t type, void *object)
 				    sizeof(time_str));
 		printf("%-14s", time_str);
 		break;
+	default:
+		printf("%-14s", "n/a");
+		break;
 	} 
 }
 
 void print_start(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 	char time_str[32];
 	
 	switch(type) {
 	case HEADLINE:
-		printf("%-14s", "Start Time");
+		printf("%-19s", "Start Time");
 		break;
 	case UNDERSCORE:
-		printf("%-14s", "--------------");
+		printf("%-19s", "--------------------");
 		break;
 	case JOB:
 		slurm_make_time_str(&job->header.timestamp, 
 				    time_str, 
 				    sizeof(time_str));
-		printf("%-14s", time_str);
+		printf("%-19s", time_str);
+		break;
+	case JOBCOMP:
+		printf("%-19s", jobcomp->start_time);
 		break;
 	case JOBSTEP:
 		slurm_make_time_str(&step->header.timestamp, 
 				    time_str, 
 				    sizeof(time_str));
-		printf("%-14s", time_str);
+		printf("%-19s", time_str);
+		break;
+	default:
+		printf("%-19s", "n/a");
+		break;
+	} 
+}
+
+void print_timelimit(type_t type, void *object)
+{ 
+	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
+	
+	switch(type) {
+	case HEADLINE:
+		printf("%-10s", "Time Limit");
+		break;
+	case UNDERSCORE:
+		printf("%-10s", "----------");
+		break;
+	case JOBCOMP:
+		printf("%-10s", jobcomp->timelimit);
+		break;
+	default:
+		printf("%-10s", "n/a");
 		break;
 	} 
 }
 
 void print_end(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 	char time_str[32];
 	
 	switch(type) {
 	case HEADLINE:
-		printf("%-14s", "End Time");
+		printf("%-19s", "End Time");
 		break;
 	case UNDERSCORE:
-		printf("%-14s", "--------------");
+		printf("%-19s", "--------------------");
 		break;
 	case JOB:
 		slurm_make_time_str(&job->end, 
 				    time_str, 
 				    sizeof(time_str));
-		printf("%-14s", time_str);
+		printf("%-19s", time_str);
+		break;
+	case JOBCOMP:
+		printf("%-19s", jobcomp->end_time);
 		break;
 	case JOBSTEP:
 		slurm_make_time_str(&step->end, 
 				    time_str, 
 				    sizeof(time_str));
-		printf("%-14s", time_str);
+		printf("%-19s", time_str);
+		break;
+	default:
+		printf("%-19s", "n/a");
 		break;
 	} 
 }
 
 void print_systemcpu(type_t type, void *object)
 {
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 	char str[FORMAT_STRING_SIZE];
 
 	switch(type) {
 	case HEADLINE:
-		printf("%15s", "SystemCpu");
+		printf("%-15s", "SystemCpu");
 		break;
 	case UNDERSCORE:
-		printf("%15s", "---------------");
+		printf("%-15s", "---------------");
 		break;
 	case JOB:
 		_elapsed_time(job->rusage.ru_stime.tv_sec,
 			      job->rusage.ru_stime.tv_usec, str);
-		printf("%15s", str);
+		printf("%-15s", str);
 		break;
 	case JOBSTEP:
 		_elapsed_time(step->rusage.ru_stime.tv_sec,
 			      step->rusage.ru_stime.tv_usec, str);
-		printf("%15s", str);
+		printf("%-15s", str);
+		break;
+	default:
+		printf("%-15s", "n/a");
 		break;
 	} 
-
 }
 
 void print_uid(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 	
 	switch(type) {
 	case HEADLINE:
-		printf("%5s", "Uid");
+		printf("%-5s", "Uid");
 		break;
 	case UNDERSCORE:
-		printf("%5s", "-----");
+		printf("%-5s", "-----");
 		break;
 	case JOB:
-		printf("%5d", job->header.uid);
+		printf("%-5u", job->header.uid);
+		break;
+	case JOBCOMP:
+		printf("%-5u", jobcomp->uid);
 		break;
 	case JOBSTEP:
-		printf("%5d", step->header.uid);
+		printf("%-5u", step->header.uid);
 		break;
 	} 
 }
 
 void print_user(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 	int uid = -1;
 	char	*tmp="(unknown)";
 	struct	passwd *pw = NULL;
@@ -998,9 +1204,15 @@ void print_user(type_t type, void *object)
 	case JOB:
 		uid = job->header.uid;
 		break;
+	case JOBCOMP:
+		printf("%-9s", jobcomp->uid_name);
+		break;
 	case JOBSTEP:
 		uid = step->header.uid;
 		break;
+	default:
+		printf("%-9s", "n/a");
+		break;
 	} 
 	if(uid != -1) {
 		if ((pw=getpwuid(uid)))
@@ -1011,26 +1223,29 @@ void print_user(type_t type, void *object)
 
 void print_usercpu(type_t type, void *object)
 {
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 	char str[FORMAT_STRING_SIZE];
 	
 	switch(type) {
 	case HEADLINE:
-		printf("%15s", "UserCpu");
+		printf("%-15s", "UserCpu");
 		break;
 	case UNDERSCORE:
-		printf("%15s", "---------------");
+		printf("%-15s", "---------------");
 		break;
 	case JOB:
 		_elapsed_time(job->rusage.ru_utime.tv_sec,
 			      job->rusage.ru_utime.tv_usec, str);
-		printf("%15s", str);
+		printf("%-15s", str);
 		break;
 	case JOBSTEP:
 		_elapsed_time(step->rusage.ru_utime.tv_sec,
 			      step->rusage.ru_utime.tv_usec, str);
-		printf("%15s", str);
+		printf("%-15s", str);
+		break;
+	default:
+		printf("%-15s", "n/a");
 		break;
 	} 
 
@@ -1038,8 +1253,8 @@ void print_usercpu(type_t type, void *object)
 
 void print_vsize(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 	char outbuf[FORMAT_STRING_SIZE];
 	char buf1[FORMAT_STRING_SIZE];
 	char buf2[FORMAT_STRING_SIZE];
@@ -1088,13 +1303,16 @@ void print_vsize(type_t type, void *object)
 			 buf2);
 		printf("%-50s", outbuf);
 		break;
+	default:
+		printf("%-50s", "n/a");
+		break;
 	} 
 }
 
 void print_cputime(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 	char outbuf[FORMAT_STRING_SIZE];
 	char buf1[FORMAT_STRING_SIZE];
 	char buf2[FORMAT_STRING_SIZE];
@@ -1145,13 +1363,16 @@ void print_cputime(type_t type, void *object)
 			 buf2);
 		printf("%-50s", outbuf);
 		break;
+	default:
+		printf("%-50s", "n/a");
+		break;
 	} 
 }
 
 void print_account(type_t type, void *object)
 {
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 
 	switch(type) {
 	case HEADLINE:
@@ -1175,7 +1396,128 @@ void print_account(type_t type, void *object)
 			printf("%-16s", step->account);
 		else
 			printf("%-13.13s...", step->account);
+	default:
+		printf("%-16s", "n/a");
+		break;
+		break;
+	}
+}
+
+
+#ifdef HAVE_BG
+void print_connection(type_t type, void *object)
+{
+	jobcomp_job_rec_t *job = (jobcomp_job_rec_t *)object;
+
+	switch(type) {
+	case HEADLINE:
+		printf("%-10s", "Connection");
+		break;
+	case UNDERSCORE:
+		printf("%-10s", "----------");
+		break;
+	case JOBCOMP:
+		printf("%-10s", job->connection);
+		break;
+	default:
+		printf("%-10s", "n/a");
+		break;
+	}
+}
+void print_geo(type_t type, void *object)
+{
+	jobcomp_job_rec_t *job = (jobcomp_job_rec_t *)object;
+
+	switch(type) {
+	case HEADLINE:
+		printf("%-8s", "Geometry");
+		break;
+	case UNDERSCORE:
+		printf("%-8s", "--------");
+		break;
+	case JOBCOMP:
+		printf("%-8s", job->geo);
+		break;
+	default:
+		printf("%-8s", "n/a");
+		break;
+	}
+}
+void print_max_procs(type_t type, void *object)
+{
+	jobcomp_job_rec_t *job = (jobcomp_job_rec_t *)object;
+
+	switch(type) {
+	case HEADLINE:
+		printf("%-9s", "Max Procs");
+		break;
+	case UNDERSCORE:
+		printf("%-9s", "---------");
+		break;
+	case JOBCOMP:
+		printf("%-9s", job->max_procs);
+		break;
+	default:
+		printf("%-9s", "n/a");
+		break;
+	}
+}
+void print_reboot(type_t type, void *object)
+{
+	jobcomp_job_rec_t *job = (jobcomp_job_rec_t *)object;
+
+	switch(type) {
+	case HEADLINE:
+		printf("%-6s", "Reboot");
+		break;
+	case UNDERSCORE:
+		printf("%-6s", "------");
+		break;
+	case JOBCOMP:
+		printf("%-6s", job->reboot);
+		break;
+	default:
+		printf("%-6s", "n/a");
+		break;
+	}
+}
+void print_rotate(type_t type, void *object)
+{
+	jobcomp_job_rec_t *job = (jobcomp_job_rec_t *)object;
+
+	switch(type) {
+	case HEADLINE:
+		printf("%-6s", "Rotate");
+		break;
+	case UNDERSCORE:
+		printf("%-6s", "------");
+		break;
+	case JOBCOMP:
+		printf("%-6s", job->rotate);
+		break;
+	default:
+		printf("%-6s", "n/a");
+		break;
+	}
+}
+void print_bg_start_point(type_t type, void *object)
+{
+	jobcomp_job_rec_t *job = (jobcomp_job_rec_t *)object;
+
+	switch(type) {
+	case HEADLINE:
+		printf("%-14s", "BG Start Point");
+		break;
+	case UNDERSCORE:
+		printf("%-14s", "--------------");
+		break;
+	case JOBCOMP:
+		printf("%-14s", job->bg_start_point);
+		break;
+	default:
+		printf("%-14s", "n/a");
 		break;
 	}
 }
+#endif
 
diff --git a/src/sacct/process.c b/src/sacct/process.c
index 45032cae7bd07f441a0cb2c6d93edd6cf7eb1f63..a18e646c0c8c0918fa70d891bd5f13580efe9e1a 100644
--- a/src/sacct/process.c
+++ b/src/sacct/process.c
@@ -39,503 +39,6 @@
 
 #include "sacct.h"
 
-job_rec_t *_find_job_record(acct_header_t header, int type);
-int _remove_job_record(uint32_t jobnum);
-step_rec_t *_find_step_record(job_rec_t *job, long jobstep);
-job_rec_t *_init_job_rec(acct_header_t header);
-step_rec_t *_init_step_rec(acct_header_t header);
-int _parse_line(char *f[], void **data, int len);
-
-job_rec_t *_find_job_record(acct_header_t header, int type)
-{
-	job_rec_t *job = NULL;
-	ListIterator itr = list_iterator_create(jobs);
-
-	while((job = (job_rec_t *)list_next(itr)) != NULL) {
-		if (job->header.jobnum == header.jobnum) {
-			if(job->header.job_submit == 0 && type == JOB_START) {
-				list_remove(itr);
-				destroy_job(job);
-				job = NULL;
-				break;
-			}
-		
-			if(job->header.job_submit == BATCH_JOB_TIMESTAMP) {
-				job->header.job_submit = header.job_submit;
-				break;
-			}
-			
-			if(job->header.job_submit == header.job_submit)
-				break;
-			else {
-				/* If we're looking for a later
-				 * record with this job number, we
-				 * know that this one is an older,
-				 * duplicate record.
-				 *   We assume that the newer record
-				 * will be created if it doesn't
-				 * already exist. */
-				job->jobnum_superseded = 1;
-			}
-		}
-	}
-	list_iterator_destroy(itr);
-	return job;
-}
-
-int _remove_job_record(uint32_t jobnum)
-{
-	job_rec_t *job = NULL;
-	int rc = SLURM_ERROR;
-	ListIterator itr = list_iterator_create(jobs);
-
-	while((job = (job_rec_t *)list_next(itr)) != NULL) {
-		if (job->header.jobnum == jobnum) {
-			list_remove(itr);
-			destroy_job(job);
-			rc = SLURM_SUCCESS;
-		}
-	}
-	list_iterator_destroy(itr);
-	return rc;
-}
-
-step_rec_t *_find_step_record(job_rec_t *job, long stepnum)
-{
-	step_rec_t *step = NULL;
-	ListIterator itr = NULL;
-
-	if(!list_count(job->steps))
-		return step;
-	
-	itr = list_iterator_create(job->steps);
-	while((step = (step_rec_t *)list_next(itr)) != NULL) {
-		if (step->stepnum == stepnum)
-			break;
-	}
-	list_iterator_destroy(itr);
-	return step;
-}
-
-job_rec_t *_init_job_rec(acct_header_t header)
-{
-	job_rec_t *job = xmalloc(sizeof(job_rec_t));
-	memcpy(&job->header, &header, sizeof(acct_header_t));
-	memset(&job->rusage, 0, sizeof(struct rusage));
-	memset(&job->sacct, 0, sizeof(sacct_t));
-	job->sacct.min_cpu = (float)NO_VAL;
-	job->job_start_seen = 0;
-	job->job_step_seen = 0;
-	job->job_terminated_seen = 0;
-	job->jobnum_superseded = 0;
-	job->jobname = xstrdup("(unknown)");
-	job->status = JOB_PENDING;
-	job->nodes = NULL;
-	job->jobname = NULL;
-	job->exitcode = 0;
-	job->priority = 0;
-	job->ntasks = 0;
-	job->ncpus = 0;
-	job->elapsed = 0;
-	job->tot_cpu_sec = 0;
-	job->tot_cpu_usec = 0;
-	job->steps = list_create(destroy_step);
-	job->nodes = NULL;
-	job->track_steps = 0;
-	job->account = NULL;
-	job->requid = -1;
-
-      	return job;
-}
-
-step_rec_t *_init_step_rec(acct_header_t header)
-{
-	step_rec_t *step = xmalloc(sizeof(job_rec_t));
-	memcpy(&step->header, &header, sizeof(acct_header_t));
-	memset(&step->rusage, 0, sizeof(struct rusage));
-	memset(&step->sacct, 0, sizeof(sacct_t));
-	step->stepnum = (uint32_t)NO_VAL;
-	step->nodes = NULL;
-	step->stepname = NULL;
-	step->status = NO_VAL;
-	step->exitcode = NO_VAL;
-	step->ntasks = (uint32_t)NO_VAL;
-	step->ncpus = (uint32_t)NO_VAL;
-	step->elapsed = (uint32_t)NO_VAL;
-	step->tot_cpu_sec = (uint32_t)NO_VAL;
-	step->tot_cpu_usec = (uint32_t)NO_VAL;
-	step->account = NULL;
-	step->requid = -1;
-
-	return step;
-}
-
-int _parse_header(char *f[], acct_header_t *header)
-{
-	header->jobnum = atoi(f[F_JOB]);
-	header->partition = xstrdup(f[F_PARTITION]);
-	header->job_submit = atoi(f[F_JOB_SUBMIT]);
-	header->timestamp = atoi(f[F_TIMESTAMP]);
-	header->uid = atoi(f[F_UID]);
-	header->gid = atoi(f[F_GID]);
-	header->blockid = xstrdup(f[F_BLOCKID]);
-	return SLURM_SUCCESS;
-}
-
-int _parse_line(char *f[], void **data, int len)
-{
-	int i = atoi(f[F_RECTYPE]);
-	job_rec_t **job = (job_rec_t **)data;
-	step_rec_t **step = (step_rec_t **)data;
-	acct_header_t header;
-	_parse_header(f, &header);
-		
-	switch(i) {
-	case JOB_START:
-		*job = _init_job_rec(header);
-		(*job)->jobname = xstrdup(f[F_JOBNAME]);
-		(*job)->track_steps = atoi(f[F_TRACK_STEPS]);
-		(*job)->priority = atoi(f[F_PRIORITY]);
-		(*job)->ncpus = atoi(f[F_NCPUS]);
-		(*job)->nodes = xstrdup(f[F_NODES]);
-		for (i=0; (*job)->nodes[i]; i++) { /* discard trailing <CR> */
-			if (isspace((*job)->nodes[i]))
-				(*job)->nodes[i] = '\0';
-		}
-		if (!strcmp((*job)->nodes, "(null)")) {
-			xfree((*job)->nodes);
-			(*job)->nodes = xstrdup("(unknown)");
-		}
-		if (len > F_JOB_ACCOUNT) {
-			(*job)->account = xstrdup(f[F_JOB_ACCOUNT]);
-			for (i=0; (*job)->account[i]; i++) {
-				/* discard trailing <CR> */
-				if (isspace((*job)->account[i]))
-					(*job)->account[i] = '\0';
-			}
-		}
-		break;
-	case JOB_STEP:
-		*step = _init_step_rec(header);
-		(*step)->stepnum = atoi(f[F_JOBSTEP]);
-		(*step)->status = atoi(f[F_STATUS]);
-		(*step)->exitcode = atoi(f[F_EXITCODE]);
-		(*step)->ntasks = atoi(f[F_NTASKS]);
-		(*step)->ncpus = atoi(f[F_STEPNCPUS]);
-		(*step)->elapsed = atoi(f[F_ELAPSED]);
-		(*step)->tot_cpu_sec = atoi(f[F_CPU_SEC]);
-		(*step)->tot_cpu_usec = atoi(f[F_CPU_USEC]);
-		(*step)->rusage.ru_utime.tv_sec = atoi(f[F_USER_SEC]);
-		(*step)->rusage.ru_utime.tv_usec = atoi(f[F_USER_USEC]);
-		(*step)->rusage.ru_stime.tv_sec = atoi(f[F_SYS_SEC]);
-		(*step)->rusage.ru_stime.tv_usec = atoi(f[F_SYS_USEC]);
-		(*step)->rusage.ru_maxrss = atoi(f[F_RSS]);
-		(*step)->rusage.ru_ixrss = atoi(f[F_IXRSS]);
-		(*step)->rusage.ru_idrss = atoi(f[F_IDRSS]);
-		(*step)->rusage.ru_isrss = atoi(f[F_ISRSS]);
-		(*step)->rusage.ru_minflt = atoi(f[F_MINFLT]);
-		(*step)->rusage.ru_majflt = atoi(f[F_MAJFLT]);
-		(*step)->rusage.ru_nswap = atoi(f[F_NSWAP]);
-		(*step)->rusage.ru_inblock = atoi(f[F_INBLOCKS]);
-		(*step)->rusage.ru_oublock = atoi(f[F_OUBLOCKS]);
-		(*step)->rusage.ru_msgsnd = atoi(f[F_MSGSND]);
-		(*step)->rusage.ru_msgrcv = atoi(f[F_MSGRCV]);
-		(*step)->rusage.ru_nsignals = atoi(f[F_NSIGNALS]);
-		(*step)->rusage.ru_nvcsw = atoi(f[F_NVCSW]);
-		(*step)->rusage.ru_nivcsw = atoi(f[F_NIVCSW]);
-		(*step)->sacct.max_vsize = atoi(f[F_MAX_VSIZE]) * 1024;
-		if(len > F_STEPNODES) {
-			(*step)->sacct.max_vsize_id.taskid = 
-				atoi(f[F_MAX_VSIZE_TASK]);
-			(*step)->sacct.ave_vsize = atof(f[F_AVE_VSIZE]) * 1024;
-			(*step)->sacct.max_rss = atoi(f[F_MAX_RSS]) * 1024;
-			(*step)->sacct.max_rss_id.taskid = 
-				atoi(f[F_MAX_RSS_TASK]);
-			(*step)->sacct.ave_rss = atof(f[F_AVE_RSS]) * 1024;
-			(*step)->sacct.max_pages = atoi(f[F_MAX_PAGES]);
-			(*step)->sacct.max_pages_id.taskid = 
-				atoi(f[F_MAX_PAGES_TASK]);
-			(*step)->sacct.ave_pages = atof(f[F_AVE_PAGES]);
-			(*step)->sacct.min_cpu = atof(f[F_MIN_CPU]);
-			(*step)->sacct.min_cpu_id.taskid = 
-				atoi(f[F_MIN_CPU_TASK]);
-			(*step)->sacct.ave_cpu = atof(f[F_AVE_CPU]);
-			(*step)->stepname = xstrdup(f[F_STEPNAME]);
-			(*step)->nodes = xstrdup(f[F_STEPNODES]);
-		} else {
-			(*step)->sacct.max_vsize_id.taskid = (uint16_t)NO_VAL;
-			(*step)->sacct.ave_vsize = (float)NO_VAL;
-			(*step)->sacct.max_rss = (uint32_t)NO_VAL;
-			(*step)->sacct.max_rss_id.taskid = (uint16_t)NO_VAL;
-			(*step)->sacct.ave_rss = (float)NO_VAL;
-			(*step)->sacct.max_pages = (uint32_t)NO_VAL;
-			(*step)->sacct.max_pages_id.taskid = (uint16_t)NO_VAL;
-			(*step)->sacct.ave_pages = (float)NO_VAL;
-			(*step)->sacct.min_cpu = (uint32_t)NO_VAL;
-			(*step)->sacct.min_cpu_id.taskid = (uint16_t)NO_VAL;
-			(*step)->sacct.ave_cpu =  (float)NO_VAL;
-			(*step)->stepname = NULL;
-			(*step)->nodes = NULL;
-		}
-		if(len > F_MIN_CPU_NODE) {
-			(*step)->sacct.max_vsize_id.nodeid = 
-				atoi(f[F_MAX_VSIZE_NODE]);
-			(*step)->sacct.max_rss_id.nodeid = 
-				atoi(f[F_MAX_RSS_NODE]);
-			(*step)->sacct.max_pages_id.nodeid = 
-				atoi(f[F_MAX_PAGES_NODE]);
-			(*step)->sacct.min_cpu_id.nodeid = 
-				atoi(f[F_MIN_CPU_NODE]);
-		} else {
-			(*step)->sacct.max_vsize_id.nodeid = 
-				(uint32_t)NO_VAL;
-			(*step)->sacct.max_rss_id.nodeid = 
-				(uint32_t)NO_VAL;
-			(*step)->sacct.max_pages_id.nodeid = 
-				(uint32_t)NO_VAL;
-			(*step)->sacct.min_cpu_id.nodeid = 
-				(uint32_t)NO_VAL;
-		}
-		if(len > F_STEP_ACCOUNT)
-			(*step)->account = xstrdup(f[F_STEP_ACCOUNT]);
-		if(len > F_STEP_REQUID)
-			(*step)->requid = atoi(f[F_STEP_REQUID]);
-		break;
-	case JOB_SUSPEND:
-	case JOB_TERMINATED:
-		*job = _init_job_rec(header);
-		(*job)->elapsed = atoi(f[F_TOT_ELAPSED]);
-		(*job)->status = atoi(f[F_STATUS]);		
-		if(len > F_JOB_REQUID) 
-			(*job)->requid = atoi(f[F_JOB_REQUID]);
-		break;
-	default:
-		printf("UNKOWN TYPE %d",i);
-		break;
-	}
-	return SLURM_SUCCESS;
-}
-
-void process_start(char *f[], int lc, int show_full, int len)
-{
-	job_rec_t *job = NULL;
-	job_rec_t *temp = NULL;
-
-	_parse_line(f, (void **)&temp, len);
-	job = _find_job_record(temp->header, JOB_START);
-	if (job) {	/* Hmmm... that's odd */
-		printf("job->header.job_submit = %d", (int)job->header.job_submit);
-		if(job->header.job_submit == 0)
-			_remove_job_record(job->header.jobnum);
-		else {
-			fprintf(stderr,
-				"Conflicting JOB_START for job %u at"
-				" line %d -- ignoring it\n",
-				job->header.jobnum, lc);
-			input_error++;
-			destroy_job(temp);
-			return;
-		}
-	}
-	
-	job = temp;
-	job->show_full = show_full;
-	list_append(jobs, job);
-	job->job_start_seen = 1;
-	
-}
-
-void process_step(char *f[], int lc, int show_full, int len)
-{
-	job_rec_t *job = NULL;
-	
-	step_rec_t *step = NULL;
-	step_rec_t *temp = NULL;
-
-	_parse_line(f, (void **)&temp, len);
-
-	job = _find_job_record(temp->header, JOB_STEP);
-	
-	if (temp->stepnum == -2) {
-		destroy_step(temp);
-		return;
-	}
-	if (!job) {	/* fake it for now */
-		job = _init_job_rec(temp->header);
-		if (params.opt_verbose > 1) 
-			fprintf(stderr, 
-				"Note: JOB_STEP record %u.%u preceded "
-				"JOB_START record at line %d\n",
-				temp->header.jobnum, temp->stepnum, lc);
-	}
-	job->show_full = show_full;
-	
-	if ((step = _find_step_record(job, temp->stepnum))) {
-		
-		if (temp->status == JOB_RUNNING) {
-			destroy_step(temp);
-			return;/* if "R" record preceded by F or CD; unusual */
-		}
-		if (step->status != JOB_RUNNING) { /* if not JOB_RUNNING */
-			fprintf(stderr,
-				"Conflicting JOB_STEP record for "
-				"jobstep %u.%u at line %d "
-				"-- ignoring it\n",
-				step->header.jobnum, 
-				step->stepnum, lc);
-			input_error++;
-			
-			destroy_step(temp);
-			return;
-		}
-		step->status = temp->status;
-		step->exitcode = temp->exitcode;
-		step->ntasks = temp->ntasks;
-		step->ncpus = temp->ncpus;
-		step->elapsed = temp->elapsed;
-		step->tot_cpu_sec = temp->tot_cpu_sec;
-		step->tot_cpu_usec = temp->tot_cpu_usec;
-		job->requid = temp->requid;
-		step->requid = temp->requid;
-		memcpy(&step->rusage, &temp->rusage, sizeof(struct rusage));
-		memcpy(&step->sacct, &temp->sacct, sizeof(sacct_t));
-		xfree(step->stepname);
-		step->stepname = xstrdup(temp->stepname);
-		step->end = temp->header.timestamp;
-		destroy_step(temp);
-		goto got_step;
-	}
-	step = temp;
-	temp = NULL;
-	list_append(job->steps, step);
-	if(job->header.timestamp == 0)
-		job->header.timestamp = step->header.timestamp;
-	job->job_step_seen = 1;
-	job->ntasks += step->ntasks;
-	if(!job->nodes || !strcmp(job->nodes, "(unknown)")) {
-		xfree(job->nodes);
-		job->nodes = xstrdup(step->nodes);
-	}
-	
-got_step:
-	
-		
-	if (job->job_terminated_seen == 0) {	/* If the job is still running,
-						   this is the most recent
-						   status */
-		if ( job->exitcode == 0 )
-			job->exitcode = step->exitcode;
-		job->status = JOB_RUNNING;
-		job->elapsed = step->header.timestamp - job->header.timestamp;
-	}
-	/* now aggregate the aggregatable */
-	job->ncpus = MAX(job->ncpus, step->ncpus);
-	if(step->status < JOB_COMPLETE)
-		return;
-	job->tot_cpu_sec += step->tot_cpu_sec;
-	job->tot_cpu_usec += step->tot_cpu_usec;
-	job->rusage.ru_utime.tv_sec += step->rusage.ru_utime.tv_sec;
-	job->rusage.ru_utime.tv_usec += step->rusage.ru_utime.tv_usec;
-	job->rusage.ru_stime.tv_sec += step->rusage.ru_stime.tv_sec;
-	job->rusage.ru_stime.tv_usec += step->rusage.ru_stime.tv_usec;
-	job->rusage.ru_inblock += step->rusage.ru_inblock;
-	job->rusage.ru_oublock += step->rusage.ru_oublock;
-	job->rusage.ru_msgsnd += step->rusage.ru_msgsnd;
-	job->rusage.ru_msgrcv += step->rusage.ru_msgrcv;
-	job->rusage.ru_nsignals += step->rusage.ru_nsignals;
-	job->rusage.ru_nvcsw += step->rusage.ru_nvcsw;
-	job->rusage.ru_nivcsw += step->rusage.ru_nivcsw;
-		
-	/* and finally the maximums for any process */
-	job->rusage.ru_maxrss = MAX(job->rusage.ru_maxrss, 
-				    step->rusage.ru_maxrss);
-	job->rusage.ru_ixrss = MAX(job->rusage.ru_ixrss,
-				   step->rusage.ru_ixrss);
-	job->rusage.ru_idrss = MAX(job->rusage.ru_idrss,
-				   step->rusage.ru_idrss);
-	job->rusage.ru_isrss = MAX(job->rusage.ru_isrss,
-				   step->rusage.ru_isrss);
-	job->rusage.ru_minflt = MAX(job->rusage.ru_minflt,
-				    step->rusage.ru_minflt);
-	job->rusage.ru_majflt = MAX(job->rusage.ru_majflt,
-				    step->rusage.ru_majflt);
-	job->rusage.ru_nswap = MAX(job->rusage.ru_nswap,
-				   step->rusage.ru_nswap);
-
-	/* get the max for all the sacct_t struct */
-	aggregate_sacct(&job->sacct, &step->sacct);
-}
-
-void process_suspend(char *f[], int lc, int show_full, int len)
-{
-	job_rec_t *job = NULL;
-	job_rec_t *temp = NULL;
-
-	_parse_line(f, (void **)&temp, len);
-	job = _find_job_record(temp->header, JOB_SUSPEND);
-	if (!job)    
-		job = _init_job_rec(temp->header);
-	
-	job->show_full = show_full;
-	if (job->status == JOB_SUSPENDED) 
-		job->elapsed -= temp->elapsed;
-
-	//job->header.timestamp = temp->header.timestamp;
-	job->status = temp->status;
-	destroy_job(temp);
-}
-	
-void process_terminated(char *f[], int lc, int show_full, int len)
-{
-	job_rec_t *job = NULL;
-	job_rec_t *temp = NULL;
-
-	_parse_line(f, (void **)&temp, len);
-	job = _find_job_record(temp->header, JOB_TERMINATED);
-	if (!job) {	/* fake it for now */
-		job = _init_job_rec(temp->header);
-		if (params.opt_verbose > 1) 
-			fprintf(stderr, "Note: JOB_TERMINATED record for job "
-				"%u preceded "
-				"other job records at line %d\n",
-				temp->header.jobnum, lc);
-	} else if (job->job_terminated_seen) {
-		if (temp->status == JOB_NODE_FAIL) {
-			/* multiple node failures - extra TERMINATED records */
-			if (params.opt_verbose > 1)
-				fprintf(stderr, 
-					"Note: Duplicate JOB_TERMINATED "
-					"record (nf) for job %u at "
-					"line %d\n", 
-					temp->header.jobnum, lc);
-			/* JOB_TERMINATED/NF records may be preceded
-			 * by a JOB_TERMINATED/CA record; NF is much
-			 * more interesting.
-			 */
-			job->status = temp->status;
-			goto finished;
-		}
-		
-		fprintf(stderr,
-			"Conflicting JOB_TERMINATED record (%s) for "
-			"job %u at line %d -- ignoring it\n",
-			decode_status_int(temp->status), 
-			job->header.jobnum, lc);
-		input_error++;
-		goto finished;
-	}
-	job->job_terminated_seen = 1;
-	job->elapsed = temp->elapsed;
-	job->end = temp->header.timestamp;
-	job->status = temp->status;
-	job->requid = temp->requid;
-	if(list_count(job->steps) > 1)
-		job->track_steps = 1;
-	job->show_full = show_full;
-	
-finished:
-	destroy_job(temp);
-}
 
 void find_hostname(uint32_t pos, char *hosts, char *host)
 {
@@ -584,35 +87,3 @@ void aggregate_sacct(sacct_t *dest, sacct_t *from)
 	}
 	dest->ave_cpu += from->ave_cpu;
 }
-
-void destroy_acct_header(void *object)
-{
-	acct_header_t *header = (acct_header_t *)object;
-	if(header) {
-		xfree(header->partition);
-		xfree(header->blockid);
-	}
-}
-void destroy_job(void *object)
-{
-	job_rec_t *job = (job_rec_t *)object;
-	if (job) {
-		if(job->steps)
-			list_destroy(job->steps);
-		destroy_acct_header(&job->header);
-		xfree(job->jobname);
-		xfree(job->nodes);
-		xfree(job);
-	}
-}
-
-void destroy_step(void *object)
-{
-	step_rec_t *step = (step_rec_t *)object;
-	if (step) {
-		destroy_acct_header(&step->header);
-		xfree(step->stepname);
-		xfree(step->nodes);
-		xfree(step);
-	}
-}
diff --git a/src/sacct/sacct.c b/src/sacct/sacct.c
index 02b2fdb58b9100bfd010e131956ea5d74e4cef14..8807c20a4c097dfe4f7b405852855af8fbb266e9 100644
--- a/src/sacct/sacct.c
+++ b/src/sacct/sacct.c
@@ -145,7 +145,6 @@
 
 #include "sacct.h"
 
-
 void invalidSwitchCombo(char *good, char *bad);
 void _print_header(void);
 
@@ -177,6 +176,7 @@ fields_t fields[] = {{"account", print_account},
 		     {"ncpus", print_ncpus}, 
 		     {"nivcsw", print_nivcsw}, 
 		     {"nodes", print_nodes}, 
+		     {"nnodes", print_nnodes}, 
 		     {"nprocs", print_ntasks},
 		     {"nsignals", print_nsignals},
 		     {"nswap", print_nswap}, 
@@ -189,16 +189,24 @@ fields_t fields[] = {{"account", print_account},
 		     {"start", print_start}, 
 		     {"status", print_status}, 
 		     {"submit", print_submit}, 
+		     {"timelimit", print_timelimit}, 
 		     {"submitted", print_submit},	/* Defunct name */
 		     {"systemcpu", print_systemcpu}, 
 		     {"uid", print_uid}, 
 		     {"user", print_user}, 
 		     {"usercpu", print_usercpu}, 
 		     {"vsize", print_vsize}, 
+#ifdef HAVE_BG
+		     {"blockid", print_blockid}, 
+		     {"connection", print_connection}, 
+		     {"geo", print_geo}, 
+		     {"max_procs", print_max_procs}, 
+		     {"reboot", print_reboot}, 
+		     {"rotate", print_rotate}, 
+		     {"bg_start_point", print_bg_start_point}, 		     
+#endif
 		     {NULL, NULL}};
 
-long input_error = 0;		/* Muddle through bad data, but complain! */
-
 List jobs = NULL;
 
 int printfields[MAX_PRINTFIELDS],	/* Indexed into fields[] */
@@ -286,7 +294,10 @@ int main(int argc, char **argv)
 	switch (op) {
 	case DUMP:
 		get_data();
-		do_dump();
+		if(params.opt_completion) 
+			do_dump_completion();
+		else 
+			do_dump();
 		break;
 	case EXPIRE:
 		do_expire();
@@ -298,7 +309,10 @@ int main(int argc, char **argv)
 		if (params.opt_header) 	/* give them something to look */
 			_print_header();/* at while we think...        */
 		get_data();
-		do_list();
+		if(params.opt_completion) 
+			do_list_completion();
+		else 
+			do_list();
 		break;
 	case STAT:
 		if (params.opt_header) 	/* give them something to look */
diff --git a/src/sacct/sacct.h b/src/sacct/sacct.h
index 056d42b07bc53cd99790ce52d865469fab2e2f7c..cbbfc6033b1a09db6c44004c32d76adb29061a03 100644
--- a/src/sacct/sacct.h
+++ b/src/sacct/sacct.h
@@ -57,243 +57,59 @@
 #include "src/common/xstring.h"
 #include "src/common/list.h"
 #include "src/common/hostlist.h"
-
-#include "src/sacct/sacct_stat.h"
+#include "src/common/slurm_jobacct.h"
+#include "src/common/slurm_jobcomp.h"
 
 #define ERROR 2
 
-/* slurmd uses "(uint32_t) -2" to track data for batch allocations
- * which have no logical jobsteps. */
-#define BATCH_JOB_TIMESTAMP 0
-
 #define BRIEF_FIELDS "jobid,status,exitcode"
+#define BRIEF_COMP_FIELDS "jobid,uid,status"
 #define DEFAULT_FIELDS "jobid,jobname,partition,ncpus,status,exitcode"
+#define DEFAULT_COMP_FIELDS "jobid,uid,jobname,partition,nnodes,nodes,status,end"
 #define STAT_FIELDS "jobid,vsize,rss,pages,cputime,ntasks,status"
 #define LONG_FIELDS "jobid,jobname,partition,vsize,rss,pages,cputime,ntasks,ncpus,elapsed,status,exitcode"
 
+#ifdef HAVE_BG
+#define LONG_COMP_FIELDS "jobid,uid,jobname,partition,blockid,nnodes,nodes,status,start,end,timelimit,connection,reboot,rotate,max_procs,geo,bg_start_point"
+#else
+#define LONG_COMP_FIELDS "jobid,uid,jobname,partition,nnodes,nodes,status,start,end,timelimit"
+#endif
+
 #define BUFFER_SIZE 4096
 #define STATUS_COUNT 10
 
 #define MAX_PRINTFIELDS 100
-#define EXPIRE_READ_LENGTH 10
-#define MAX_RECORD_FIELDS 100
 
 #define SECONDS_IN_MINUTE 60
 #define SECONDS_IN_HOUR (60*SECONDS_IN_MINUTE)
 #define SECONDS_IN_DAY (24*SECONDS_IN_HOUR)
 
-#define TIMESTAMP_LENGTH 15
-
-/* Map field names to positions */
-
-/* Fields common to all records */
-enum {	F_JOB =	0,
-	F_PARTITION,	
-	F_JOB_SUBMIT,	
-	F_TIMESTAMP,	
-	F_UID,	
-	F_GID,	
-	F_BLOCKID,	
-	F_RESERVED2,	
-	F_RECTYPE,	
-	HEADER_LENGTH
-};
-
-/* JOB_START fields */
-enum {	F_JOBNAME = HEADER_LENGTH,
-	F_TRACK_STEPS,		
-	F_PRIORITY,	
-	F_NCPUS,		
-	F_NODES,
-	F_JOB_ACCOUNT,
-	JOB_START_LENGTH
-};
-
-/* JOB_STEP fields */
-enum {	F_JOBSTEP = HEADER_LENGTH,
-	F_STATUS,
-	F_EXITCODE,
-	F_NTASKS,
-	F_STEPNCPUS,
-	F_ELAPSED,
-	F_CPU_SEC,
-	F_CPU_USEC,
-	F_USER_SEC,
-	F_USER_USEC,
-	F_SYS_SEC,
-	F_SYS_USEC,
-	F_RSS,
-	F_IXRSS,
-	F_IDRSS,
-	F_ISRSS,
-	F_MINFLT,
-	F_MAJFLT,
-	F_NSWAP,
-	F_INBLOCKS,
-	F_OUBLOCKS,
-	F_MSGSND,
-	F_MSGRCV,
-	F_NSIGNALS,
-	F_NVCSW,
-	F_NIVCSW,
-	F_MAX_VSIZE,
-	F_MAX_VSIZE_TASK,
-	F_AVE_VSIZE,
-	F_MAX_RSS,
-	F_MAX_RSS_TASK,
-	F_AVE_RSS,
-	F_MAX_PAGES,
-	F_MAX_PAGES_TASK,
-	F_AVE_PAGES,
-	F_MIN_CPU,
-	F_MIN_CPU_TASK,
-	F_AVE_CPU,
-	F_STEPNAME,
-	F_STEPNODES,
-	F_MAX_VSIZE_NODE,
-	F_MAX_RSS_NODE,
-	F_MAX_PAGES_NODE,
-	F_MIN_CPU_NODE,
-	F_STEP_ACCOUNT,
-	F_STEP_REQUID,
-	JOB_STEP_LENGTH
-};
-
-/* JOB_TERM / JOB_SUSPEND fields */
-enum {	F_TOT_ELAPSED = HEADER_LENGTH,
-	F_TERM_STATUS,
-	F_JOB_REQUID,
-	JOB_TERM_LENGTH
-};
-
 /* On output, use fields 12-37 from JOB_STEP */
 
 typedef enum {	HEADLINE,
 		UNDERSCORE,
 		JOB,
-		JOBSTEP
+		JOBSTEP,
+		JOBCOMP
 } type_t;
 
-enum {	CANCELLED,
-	COMPLETED,
-	COMPLETING,
-	FAILED,
-	NODEFAILED,
-	PENDING,
-	RUNNING,
-	TIMEDOUT
-};
-
-typedef struct header {
-	uint32_t jobnum;
-	char	*partition;
-	char	*blockid;
-	time_t 	job_submit;
-	time_t	timestamp;
-	uint32_t uid;
-	uint32_t gid;
-	uint16_t rec_type;
-} acct_header_t;
-
-typedef struct job_rec {
-	uint32_t	job_start_seen,		/* useful flags */
-		job_step_seen,
-		job_terminated_seen,
-		jobnum_superseded;	/* older jobnum was reused */
-	acct_header_t header;
-	uint16_t show_full;
-	char	*nodes;
-	char	*jobname;
-	uint16_t track_steps;
-	int32_t priority;
-	uint32_t ncpus;
-	uint32_t ntasks;
-	int32_t	status;
-	int32_t	exitcode;
-	uint32_t elapsed;
-	time_t end;
-	uint32_t tot_cpu_sec;
-	uint32_t tot_cpu_usec;
-	struct rusage rusage;
-	sacct_t sacct;
-	List    steps;
-	char    *account;
-	uint32_t requid;
-} job_rec_t;
-
-typedef struct step_rec {
-	acct_header_t   header;
-	uint32_t	stepnum;	/* job's step number */
-	char	        *nodes;
-	char	        *stepname;
-	int32_t	        status;
-	int32_t	        exitcode;
-	uint32_t	ntasks; 
-	uint32_t        ncpus;
-	uint32_t	elapsed;
-	time_t          end;
-	uint32_t	tot_cpu_sec;
-	uint32_t        tot_cpu_usec;
-	struct rusage   rusage;
-	sacct_t         sacct;
-	char            *account;
-	uint32_t requid;
-} step_rec_t;
-
-typedef struct selected_step_t {
-	char *job;
-	char *step;
-} selected_step_t;
 
 typedef struct fields {
 	char *name;		/* Specified in --fields= */
 	void (*print_routine) ();	/* Who gets to print it? */
 } fields_t;
 
-/* Input parameters */
-typedef struct sacct_parameters {
-	int opt_dump;		/* --dump */
-	int opt_dup;		/* --duplicates; +1 = explicitly set */
-	int opt_fdump;		/* --formattted_dump */
-	int opt_stat;		/* --stat */
-	int opt_gid;		/* --gid (-1=wildcard, 0=root) */
-	int opt_header;		/* can only be cleared */
-	int opt_help;		/* --help */
-	int opt_long;		/* --long */
-	int opt_lowmem;		/* --low_memory */
-	int opt_purge;		/* --purge */
-	int opt_total;		/* --total */
-	int opt_uid;		/* --uid (-1=wildcard, 0=root) */
-	int opt_verbose;	/* --verbose */
-	long opt_expire;		/* --expire= */ 
-	char *opt_expire_timespec; /* --expire= */
-	char *opt_field_list;	/* --fields= */
-	char *opt_filein;	/* --file */
-	char *opt_job_list;	/* --jobs */
-	char *opt_partition_list;/* --partitions */
-	char *opt_state_list;	/* --states */
-} sacct_parameters_t;
-
 extern fields_t fields[];
 extern sacct_parameters_t params;
 
-extern long input_error;	/* Muddle through bad data, but complain! */
-
 extern List jobs;
 
 extern int printfields[MAX_PRINTFIELDS],	/* Indexed into fields[] */
 	nprintfields;
 
 /* process.c */
-void process_start(char *f[], int lc, int show_full, int len);
-void process_step(char *f[], int lc, int show_full, int len);
-void process_suspend(char *f[], int lc, int show_full, int len);
-void process_terminated(char *f[], int lc, int show_full, int len);
 void find_hostname(uint32_t pos, char *hosts, char *host);
 void aggregate_sacct(sacct_t *dest, sacct_t *from);
-void destroy_acct_header(void *object);
-void destroy_job(void *object);
-void destroy_step(void *object);
 
 /* print.c */
 void print_fields(type_t type, void *object);
@@ -316,6 +132,7 @@ void print_msgsnd(type_t type, void *object);
 void print_ncpus(type_t type, void *object);
 void print_nivcsw(type_t type, void *object);
 void print_nodes(type_t type, void *object);
+void print_nnodes(type_t type, void *object);
 void print_nsignals(type_t type, void *object);
 void print_nswap(type_t type, void *object);
 void print_ntasks(type_t type, void *object);
@@ -330,6 +147,7 @@ void print_submit(type_t type, void *object);
 void print_start(type_t type, void *object);
 void print_end(type_t type, void *object);
 void print_systemcpu(type_t type, void *object);
+void print_timelimit(type_t type, void *object);
 void print_uid(type_t type, void *object);
 void print_user(type_t type, void *object);
 void print_usercpu(type_t type, void *object);
@@ -337,18 +155,31 @@ void print_vsize(type_t type, void *object);
 void print_cputime(type_t type, void *object);
 void print_account(type_t type, void *object);
 
+#ifdef HAVE_BG
+void print_connection(type_t type, void *object);
+void print_geo(type_t type, void *object);
+void print_max_procs(type_t type, void *object);
+void print_reboot(type_t type, void *object);
+void print_rotate(type_t type, void *object);
+void print_bg_start_point(type_t type, void *object);
+#endif
+
 /* options.c */
 int decode_status_char(char *status);
 char *decode_status_int(int status);
 int get_data(void);
 void parse_command_line(int argc, char **argv);
 void do_dump(void);
+void do_dump_completion(void);
 void do_expire(void);
-void do_fdump(char* fields[], int lc);
 void do_help(void);
 void do_list(void);
+void do_list_completion(void);
 void do_stat(void);
 void sacct_init();
 void sacct_fini();
 
+/* sacct_stat.c */
+extern int sacct_stat(uint32_t jobid, uint32_t stepid);
+
 #endif /* !_SACCT_H */
diff --git a/src/sacct/sacct_stat.c b/src/sacct/sacct_stat.c
index 5c4b298122fd1b06c55497b957452b955ef08a16..bc487ab1e59c61a942a1abc3bacbd4816559f00f 100644
--- a/src/sacct/sacct_stat.c
+++ b/src/sacct/sacct_stat.c
@@ -17,7 +17,7 @@
  *  any later version.
  *
  *  In addition, as a special exception, the copyright holders give permission 
- *  to link the code of portions of this program with the OpenSSL library under 
+ *  to link the code of portions of this program with the OpenSSL library under
  *  certain conditions as described in each individual source file, and 
  *  distribute linked combinations including the two. You must obey the GNU 
  *  General Public License in all respects for all of the code used other than 
@@ -43,7 +43,7 @@
 #include "src/common/forward.h"
 #include "src/common/slurm_auth.h"
 
-step_rec_t step;
+jobacct_step_rec_t step;
 	
 int thr_finished = 0;
 	
diff --git a/src/salloc/Makefile.in b/src/salloc/Makefile.in
index 202ab6ba31b487a9c95c91143716d96f99fda071..aec781044a9d88745bb46519d26b0a7a0f7c861c 100644
--- a/src/salloc/Makefile.in
+++ b/src/salloc/Makefile.in
@@ -45,6 +45,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -127,6 +128,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -150,6 +152,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -161,6 +164,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/sattach/Makefile.in b/src/sattach/Makefile.in
index 064f774c651b812a0ea20e08d2b1e1adf2347912..54b39401ecc7a4584385f85292e8259933820588 100644
--- a/src/sattach/Makefile.in
+++ b/src/sattach/Makefile.in
@@ -45,6 +45,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -128,6 +129,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -151,6 +153,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -162,6 +165,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/sbatch/Makefile.in b/src/sbatch/Makefile.in
index a13da5355adb2b31d8b305e713ef9ec7985f1696..7f61ff3df282c7d8bfd81d9f17adb83f9eb2b9e0 100644
--- a/src/sbatch/Makefile.in
+++ b/src/sbatch/Makefile.in
@@ -45,6 +45,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -127,6 +128,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -150,6 +152,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -161,6 +164,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/sbcast/Makefile.in b/src/sbcast/Makefile.in
index 1703fd8971d7da79428a85aed5f5e44ffaa9eaf5..0de31ccc01bec85c70ad514f24792b9e91284a1d 100644
--- a/src/sbcast/Makefile.in
+++ b/src/sbcast/Makefile.in
@@ -48,6 +48,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -131,6 +132,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -154,6 +156,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -165,6 +168,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/scancel/Makefile.in b/src/scancel/Makefile.in
index 9c5d57630eccec8ae2675e79408a6f3219ed775e..3d2d7a5f6bfaabbaf32ea18c01f18a945638e1d1 100644
--- a/src/scancel/Makefile.in
+++ b/src/scancel/Makefile.in
@@ -47,6 +47,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -130,6 +131,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -153,6 +155,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -164,6 +167,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/scontrol/Makefile.in b/src/scontrol/Makefile.in
index e15995b7706c5f6316f4d6cae92869e9531ab2e3..1b5308cc2af1d48b41f97dca4ceaa46d5617dc25 100644
--- a/src/scontrol/Makefile.in
+++ b/src/scontrol/Makefile.in
@@ -45,6 +45,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -130,6 +131,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -153,6 +155,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -164,6 +167,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/sinfo/Makefile.in b/src/sinfo/Makefile.in
index 9738d03b2ed13079bab44517c3d37ceaf4b89512..91fa06c33761b23852b299f06ff592910af01d66 100644
--- a/src/sinfo/Makefile.in
+++ b/src/sinfo/Makefile.in
@@ -48,6 +48,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -132,6 +133,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -155,6 +157,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -166,6 +169,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/slaunch/Makefile.in b/src/slaunch/Makefile.in
index f2311fd9d42dd4a7e44543029f3f33769df519e5..c0f4f7ffab00f3d34e78a480fa859c9a5e6b54ac 100644
--- a/src/slaunch/Makefile.in
+++ b/src/slaunch/Makefile.in
@@ -45,6 +45,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -130,6 +131,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -153,6 +155,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -164,6 +167,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/slurmctld/Makefile.in b/src/slurmctld/Makefile.in
index 6ff64f5daa92ae5a01c05eaad6b8767cf300e1c3..8c6f6c2161d30f494fb9aa4e321011c09af37d1c 100644
--- a/src/slurmctld/Makefile.in
+++ b/src/slurmctld/Makefile.in
@@ -46,6 +46,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -135,6 +136,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -158,6 +160,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -169,6 +172,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/slurmctld/job_mgr.c b/src/slurmctld/job_mgr.c
index f16e211462684e4449cec63b69d7c4a158ee7ab4..a85923f13c2d5081da1be5d9923b4a96d7ad9a58 100644
--- a/src/slurmctld/job_mgr.c
+++ b/src/slurmctld/job_mgr.c
@@ -87,7 +87,7 @@
 #define JOB_HASH_INX(_job_id)	(_job_id % hash_table_size)
 
 /* Change JOB_STATE_VERSION value when changing the state save format */
-#define JOB_STATE_VERSION      "VER005"
+#define JOB_STATE_VERSION      "VER006"
 
 /* Global variables */
 List   job_list = NULL;		/* job_record list */
@@ -483,6 +483,7 @@ static void _dump_job_state(struct job_record *dump_job_ptr, Buf buffer)
 	pack32(dump_job_ptr->dependency, buffer);
 	pack32(dump_job_ptr->num_procs, buffer);
 	pack32(dump_job_ptr->exit_code, buffer);
+	pack32(dump_job_ptr->db_index, buffer);
 
 	pack_time(dump_job_ptr->start_time, buffer);
 	pack_time(dump_job_ptr->end_time, buffer);
@@ -545,7 +546,7 @@ static void _dump_job_state(struct job_record *dump_job_ptr, Buf buffer)
 static int _load_job_state(Buf buffer)
 {
 	uint32_t job_id, user_id, group_id, time_limit, priority, alloc_sid;
-	uint32_t dependency, exit_code, num_procs;
+	uint32_t dependency, exit_code, num_procs, db_index;
 	time_t start_time, end_time, suspend_time, pre_sus_time;
 	uint16_t job_state, next_step_id, details, batch_flag, step_flag;
 	uint16_t kill_on_node_fail, kill_on_step_done, name_len;
@@ -567,6 +568,7 @@ static int _load_job_state(Buf buffer)
 	safe_unpack32(&dependency, buffer);
 	safe_unpack32(&num_procs, buffer);
 	safe_unpack32(&exit_code, buffer);
+	safe_unpack32(&db_index, buffer);
 
 	safe_unpack_time(&start_time, buffer);
 	safe_unpack_time(&end_time, buffer);
@@ -674,6 +676,7 @@ static int _load_job_state(Buf buffer)
 	job_ptr->exit_code    = exit_code;
 	job_ptr->state_reason = state_reason;
 	job_ptr->num_procs    = num_procs;
+	job_ptr->db_index     = db_index;
 	job_ptr->time_last_active = time(NULL);
 	strncpy(job_ptr->name, name, MAX_JOBNAME_LEN);
 	xfree(name);
@@ -1338,6 +1341,7 @@ extern int job_allocate(job_desc_msg_t * job_specs, int immediate,
 			job_ptr->exit_code = 1;
 			job_ptr->state_reason = FAIL_BAD_CONSTRAINTS;
 			job_ptr->start_time = job_ptr->end_time = time(NULL);
+			jobacct_g_job_start_slurmctld(job_ptr);
 			job_completion_logger(job_ptr);
 		}
 		return error_code;
@@ -1370,6 +1374,7 @@ extern int job_allocate(job_desc_msg_t * job_specs, int immediate,
 		job_ptr->exit_code  = 1;
 		job_ptr->state_reason = FAIL_BAD_CONSTRAINTS;
 		job_ptr->start_time = job_ptr->end_time = time(NULL);
+		jobacct_g_job_start_slurmctld(job_ptr);
 		job_completion_logger(job_ptr);
 		if (!independent)
 			return ESLURM_DEPENDENCY;
@@ -1384,6 +1389,7 @@ extern int job_allocate(job_desc_msg_t * job_specs, int immediate,
 	no_alloc = test_only || too_fragmented || 
 		(!top_prio) || (!independent);
 	error_code = select_nodes(job_ptr, no_alloc, NULL);
+	jobacct_g_job_start_slurmctld(job_ptr);
 	if (!test_only) {
 		last_job_update = time(NULL);
 		slurm_sched_schedule();	/* work for external scheduler */
@@ -1963,7 +1969,6 @@ static int _job_create(job_desc_msg_t * job_desc, int allocate, int will_run,
 		job_ptr->priority = 1;      /* Move to end of queue */
 		job_ptr->state_reason = fail_reason;
 	}
-	jobacct_g_job_start_slurmctld(job_ptr);
 	
 cleanup:
 	FREE_NULL_BITMAP(req_bitmap);
diff --git a/src/slurmctld/proc_req.c b/src/slurmctld/proc_req.c
index c62c1debb7908583c5b2431938f90c10e5389d6b..222cfbca100d022f16a735d49aee2e5846d0cb19 100644
--- a/src/slurmctld/proc_req.c
+++ b/src/slurmctld/proc_req.c
@@ -313,7 +313,12 @@ void _fill_ctld_conf(slurm_ctl_conf_t * conf_ptr)
 	conf_ptr->fast_schedule       = conf->fast_schedule;
 	conf_ptr->first_job_id        = conf->first_job_id;
 	conf_ptr->inactive_limit      = conf->inactive_limit;
-	conf_ptr->job_acct_logfile    = xstrdup(conf->job_acct_logfile);
+	conf_ptr->job_acct_loc        = xstrdup(conf->job_acct_loc);
+	conf_ptr->database_type       = xstrdup(conf->database_type);
+	conf_ptr->database_user       = xstrdup(conf->database_user);
+	conf_ptr->database_host       = xstrdup(conf->database_host);
+	conf_ptr->database_pass       = xstrdup(conf->database_pass);
+	conf_ptr->database_port       = conf->database_port;
 	conf_ptr->job_acct_freq       = conf->job_acct_freq;
 	conf_ptr->job_acct_type       = xstrdup(conf->job_acct_type);
 	conf_ptr->job_comp_loc        = xstrdup(conf->job_comp_loc);
diff --git a/src/slurmctld/read_config.c b/src/slurmctld/read_config.c
index f9d007c69964ff024e110b1f0c4f3b5786310d02..813f7448b851d19207f7e5daf200ee963fe29b13 100644
--- a/src/slurmctld/read_config.c
+++ b/src/slurmctld/read_config.c
@@ -728,7 +728,7 @@ int read_slurm_conf(int recover)
 	slurm_conf_unlock();
 
 	update_logging();
-	jobacct_g_init_slurmctld(slurmctld_conf.job_acct_logfile);
+	jobacct_g_init_slurmctld(slurmctld_conf.job_acct_loc);
 	g_slurm_jobcomp_init(slurmctld_conf.job_comp_loc);
 	slurm_sched_init();
 	if (switch_init() < 0)
diff --git a/src/slurmctld/slurmctld.h b/src/slurmctld/slurmctld.h
index fe5c31a410b427997411b30ec24f4a78598306af..f6a576d2faac11e3680abe12fad94507779f1188 100644
--- a/src/slurmctld/slurmctld.h
+++ b/src/slurmctld/slurmctld.h
@@ -387,6 +387,8 @@ struct job_record {
 					 * wait call) */
 	uint16_t state_reason;		/* reason job still pending or failed
 					 * see slurm.h:enum job_wait_reason */
+	uint32_t db_index;              /* used only for database
+					   plugins */
 };
 
 struct 	step_record {
diff --git a/src/slurmctld/trigger_mgr.c b/src/slurmctld/trigger_mgr.c
index 7b30f9c97c5ce5dd3792cada362216a93829eec6..a337b3bd3a72d1d0c676bb50471d4af950bff840 100644
--- a/src/slurmctld/trigger_mgr.c
+++ b/src/slurmctld/trigger_mgr.c
@@ -218,7 +218,7 @@ extern int trigger_clear(uid_t uid, trigger_info_msg_t *msg)
 			continue;
 		if (trig_test->state == 2)	/* wait for proc termination */
 			continue;
-		list_delete(trig_iter);
+		list_delete_item(trig_iter);
 		rc = SLURM_SUCCESS;
 	}
 	list_iterator_destroy(trig_iter);
@@ -978,7 +978,7 @@ extern void trigger_process(void)
 #if _DEBUG
 				info("purging trigger[%u]", trig_in->trig_id);
 #endif
-				list_delete(trig_iter);
+				list_delete_item(trig_iter);
 				state_change = true;
 			}
 		} else if (trig_in->state == 2) {
diff --git a/src/slurmd/Makefile.in b/src/slurmd/Makefile.in
index 91a856806aceef3e36d3ca7a7d68ef779b633e6f..cea8a8932922841ff0cb9fe1c44fc5c8bb9f96b6 100644
--- a/src/slurmd/Makefile.in
+++ b/src/slurmd/Makefile.in
@@ -41,6 +41,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -112,6 +113,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -135,6 +137,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -146,6 +149,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/slurmd/slurmd/Makefile.in b/src/slurmd/slurmd/Makefile.in
index 44b7d81811c9643b12b4a1bc97c42081b8a08ffa..8ca8b7756297aadc4032e342d34b4e9b913b56d0 100644
--- a/src/slurmd/slurmd/Makefile.in
+++ b/src/slurmd/slurmd/Makefile.in
@@ -47,6 +47,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -148,6 +149,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -171,6 +173,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -182,6 +185,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/slurmd/slurmstepd/Makefile.in b/src/slurmd/slurmstepd/Makefile.in
index ab23fb678fad013bb605eaa3feeb5a27ef8ac119..1444c50b8149efa462bfef52390f0b7fa1530074 100644
--- a/src/slurmd/slurmstepd/Makefile.in
+++ b/src/slurmd/slurmstepd/Makefile.in
@@ -46,6 +46,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -139,6 +140,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -162,6 +164,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -173,6 +176,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/smap/Makefile.am b/src/smap/Makefile.am
index 32f7aff2b19a50375bc5e083e5750cfcf2efd9b5..0f549c895f00c9396d9405eaff9b5f26b059055c 100644
--- a/src/smap/Makefile.am
+++ b/src/smap/Makefile.am
@@ -14,7 +14,8 @@ if HAVE_SOME_CURSES
 bin_PROGRAMS = smap
 
 smap_LDADD = \
-	$(top_builddir)/src/plugins/select/bluegene/block_allocator/libbluegene_block_allocator.la 
+	$(top_builddir)/src/plugins/select/bluegene/block_allocator/libbluegene_block_allocator.la \
+	$(top_builddir)/src/api/libslurm.la
 
 noinst_HEADERS = smap.h 
 smap_SOURCES = smap.c \
diff --git a/src/smap/Makefile.in b/src/smap/Makefile.in
index cfa4ce55d8829a27b30d87f0132913a5ca864c01..100fd8eadd16cac94d6c58b04c134f459d042279 100644
--- a/src/smap/Makefile.in
+++ b/src/smap/Makefile.in
@@ -51,6 +51,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -85,7 +86,8 @@ am__EXTRA_smap_SOURCES_DIST = smap.h smap.c job_functions.c \
 	partition_functions.c configure_functions.c grid_functions.c \
 	opts.c
 smap_OBJECTS = $(am_smap_OBJECTS)
-@HAVE_SOME_CURSES_TRUE@smap_DEPENDENCIES = $(top_builddir)/src/plugins/select/bluegene/block_allocator/libbluegene_block_allocator.la
+@HAVE_SOME_CURSES_TRUE@smap_DEPENDENCIES = $(top_builddir)/src/plugins/select/bluegene/block_allocator/libbluegene_block_allocator.la \
+@HAVE_SOME_CURSES_TRUE@	$(top_builddir)/src/api/libslurm.la
 smap_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(smap_LDFLAGS) \
 	$(LDFLAGS) -o $@
@@ -144,6 +146,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -167,6 +170,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -178,6 +182,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -266,7 +272,8 @@ top_srcdir = @top_srcdir@
 AUTOMAKE_OPTIONS = foreign
 INCLUDES = -I$(top_srcdir) $(BG_INCLUDES) 
 @HAVE_SOME_CURSES_TRUE@smap_LDADD = \
-@HAVE_SOME_CURSES_TRUE@	$(top_builddir)/src/plugins/select/bluegene/block_allocator/libbluegene_block_allocator.la 
+@HAVE_SOME_CURSES_TRUE@	$(top_builddir)/src/plugins/select/bluegene/block_allocator/libbluegene_block_allocator.la \
+@HAVE_SOME_CURSES_TRUE@	$(top_builddir)/src/api/libslurm.la
 
 @HAVE_SOME_CURSES_TRUE@noinst_HEADERS = smap.h 
 @HAVE_SOME_CURSES_TRUE@smap_SOURCES = smap.c \
diff --git a/src/squeue/Makefile.in b/src/squeue/Makefile.in
index 5eb2fe4e8b895e7619b7567c21a7b0c4d9003cd6..4d3b58a7626e33294a9803feba2ee2a1ce54a662 100644
--- a/src/squeue/Makefile.in
+++ b/src/squeue/Makefile.in
@@ -48,6 +48,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -132,6 +133,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -155,6 +157,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -166,6 +169,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/srun/Makefile.in b/src/srun/Makefile.in
index cbb2a13dad188eebbca6744c0f54067ea76c4f1d..ae6d1f78c9a4158158e7414ed5c00f93c4a05673 100644
--- a/src/srun/Makefile.in
+++ b/src/srun/Makefile.in
@@ -45,6 +45,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -131,6 +132,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -154,6 +156,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -165,6 +168,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/strigger/Makefile.in b/src/strigger/Makefile.in
index 4c8ca10abbf723b3835543b6e45682f88ac14999..7e75419f78cbdec9d774b36f69bfae1376d9f8f8 100644
--- a/src/strigger/Makefile.in
+++ b/src/strigger/Makefile.in
@@ -48,6 +48,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -131,6 +132,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -154,6 +156,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -165,6 +168,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/src/sview/Makefile.am b/src/sview/Makefile.am
index 7d534584433894c665d7d4422c648c120369a7a7..757bccb5e0704484e10d8c35cf3ceb73dbcbc05c 100644
--- a/src/sview/Makefile.am
+++ b/src/sview/Makefile.am
@@ -10,7 +10,8 @@ if HAVE_GTK
 bin_PROGRAMS = sview
 
 sview_LDADD =					  \
-	$(top_builddir)/src/plugins/select/bluegene/block_allocator/libbluegene_block_allocator.la 
+	$(top_builddir)/src/plugins/select/bluegene/block_allocator/libbluegene_block_allocator.la  \
+	$(top_builddir)/src/api/libslurm.la
 
 noinst_HEADERS = sview.h
 sview_SOURCES = sview.c popups.c grid.c part_info.c job_info.c \
diff --git a/src/sview/Makefile.in b/src/sview/Makefile.in
index 230584364d85511d995997c412981f235b268264..697cb2bf3f864c6a77bd39406fb4d5d2bece270f 100644
--- a/src/sview/Makefile.in
+++ b/src/sview/Makefile.in
@@ -49,6 +49,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -88,7 +89,8 @@ am__EXTRA_sview_SOURCES_DIST = sview.h sview.c popups.c grid.c \
 	part_info.c job_info.c block_info.c node_info.c submit_info.c \
 	admin_info.c common.c
 sview_OBJECTS = $(am_sview_OBJECTS)
-@HAVE_GTK_TRUE@sview_DEPENDENCIES = $(top_builddir)/src/plugins/select/bluegene/block_allocator/libbluegene_block_allocator.la
+@HAVE_GTK_TRUE@sview_DEPENDENCIES = $(top_builddir)/src/plugins/select/bluegene/block_allocator/libbluegene_block_allocator.la \
+@HAVE_GTK_TRUE@	$(top_builddir)/src/api/libslurm.la
 sview_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=link $(CCLD) $(sview_CFLAGS) $(CFLAGS) $(sview_LDFLAGS) \
 	$(LDFLAGS) -o $@
@@ -148,6 +150,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -171,6 +174,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -182,6 +186,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -270,7 +276,8 @@ top_srcdir = @top_srcdir@
 AUTOMAKE_OPTIONS = foreign
 INCLUDES = -I$(top_srcdir) $(BG_INCLUDES)
 @HAVE_GTK_TRUE@sview_LDADD = \
-@HAVE_GTK_TRUE@	$(top_builddir)/src/plugins/select/bluegene/block_allocator/libbluegene_block_allocator.la 
+@HAVE_GTK_TRUE@	$(top_builddir)/src/plugins/select/bluegene/block_allocator/libbluegene_block_allocator.la  \
+@HAVE_GTK_TRUE@	$(top_builddir)/src/api/libslurm.la
 
 @HAVE_GTK_TRUE@noinst_HEADERS = sview.h
 @HAVE_GTK_TRUE@sview_SOURCES = sview.c popups.c grid.c part_info.c job_info.c \
diff --git a/src/sview/popups.c b/src/sview/popups.c
index a2f1cefb689db4a31c18ec1282e0446faf053c42..a920a624025e3a324f7e17191411d2a5cbc8f634 100644
--- a/src/sview/popups.c
+++ b/src/sview/popups.c
@@ -222,235 +222,251 @@ static void _layout_ctl_conf(GtkTreeStore *treestore,
 	slurm_make_time_str((time_t *)&slurm_ctl_conf_ptr->last_update, 
 			    temp_str, sizeof(temp_str));
 	add_display_treestore_line(update, treestore, &iter, 
-			    "Configuration data as of", temp_str);
+				   "Configuration data as of", temp_str);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "AuthType",	slurm_ctl_conf_ptr->authtype);
+				   "AuthType", slurm_ctl_conf_ptr->authtype);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "BackupAddr", slurm_ctl_conf_ptr->backup_addr);
+				   "BackupAddr",
+				   slurm_ctl_conf_ptr->backup_addr);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "BackupController", 
-			    slurm_ctl_conf_ptr->backup_controller);
+				   "BackupController", 
+				   slurm_ctl_conf_ptr->backup_controller);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->cache_groups);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "CacheGroups", temp_str); 
+				   "CacheGroups", temp_str); 
 	add_display_treestore_line(update, treestore, &iter, 
-			    "CheckpointType",
-			    slurm_ctl_conf_ptr->checkpoint_type);
+				   "CheckpointType",
+				   slurm_ctl_conf_ptr->checkpoint_type);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "ControlAddr", 
-			    slurm_ctl_conf_ptr->control_addr);
+				   "ControlAddr", 
+				   slurm_ctl_conf_ptr->control_addr);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "ControlMachine", 
-			    slurm_ctl_conf_ptr->control_machine);
+				   "ControlMachine", 
+				   slurm_ctl_conf_ptr->control_machine);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "Epilog", 
-			    slurm_ctl_conf_ptr->epilog);
+				   "DatabaseType", 
+				   slurm_ctl_conf_ptr->database_type);
+	add_display_treestore_line(update, treestore, &iter, 
+				   "DatabaseHost", 
+				   slurm_ctl_conf_ptr->database_host);
+	snprintf(temp_str, sizeof(temp_str), "%u", 
+		 slurm_ctl_conf_ptr->database_port);
+	add_display_treestore_line(update, treestore, &iter, 
+				   "DatabasePort", 
+				   temp_str);
+	add_display_treestore_line(update, treestore, &iter, 
+				   "DatabaseUser", 
+				   slurm_ctl_conf_ptr->database_user);
+	add_display_treestore_line(update, treestore, &iter, 
+				   "Epilog", 
+				   slurm_ctl_conf_ptr->epilog);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->fast_schedule);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "FastSchedule", 
-			    temp_str);
+				   "FastSchedule", 
+				   temp_str);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->first_job_id);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "FirstJobId", 
-			    temp_str);
+				   "FirstJobId", 
+				   temp_str);
 #ifdef HAVE_XCPU
 	add_display_treestore_line(update, treestore, &iter, 
-			    "HAVE_XCPU", "1");
+				   "HAVE_XCPU", "1");
 #endif
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->inactive_limit);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "InactiveLimit", 
-			    temp_str);
+				   "InactiveLimit", 
+				   temp_str);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "JobAcctLogFile", 
-			    slurm_ctl_conf_ptr->job_acct_logfile);
+				   "JobAcctLoc", 
+				   slurm_ctl_conf_ptr->job_acct_loc);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->job_acct_freq);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "JobAcctFrequency",
-			    temp_str);
+				   "JobAcctFrequency",
+				   temp_str);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "JobAcctType", 
-			    slurm_ctl_conf_ptr->job_acct_type);
+				   "JobAcctType", 
+				   slurm_ctl_conf_ptr->job_acct_type);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "JobCompLoc", 
-			    slurm_ctl_conf_ptr->job_comp_loc);
+				   "JobCompLoc", 
+				   slurm_ctl_conf_ptr->job_comp_loc);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "JobCompType", 
-			    slurm_ctl_conf_ptr->job_comp_type);
+				   "JobCompType", 
+				   slurm_ctl_conf_ptr->job_comp_type);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "JobCredentialPrivateKey", 
-			    slurm_ctl_conf_ptr->job_credential_private_key);
+				   "JobCredentialPrivateKey", 
+				   slurm_ctl_conf_ptr->job_credential_private_key);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "JobCredentialPublicCertificate", 
-			    slurm_ctl_conf_ptr->
-			    job_credential_public_certificate);
+				   "JobCredentialPublicCertificate", 
+				   slurm_ctl_conf_ptr->
+				   job_credential_public_certificate);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->kill_wait);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "KillWait", 
-			    temp_str);
+				   "KillWait", 
+				   temp_str);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "MailProg",
-			    slurm_ctl_conf_ptr->mail_prog);
+				   "MailProg",
+				   slurm_ctl_conf_ptr->mail_prog);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->max_job_cnt);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "MaxJobCount", 
-			    temp_str);
+				   "MaxJobCount", 
+				   temp_str);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->msg_timeout);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "MessageTimeout",
-			    temp_str);
+				   "MessageTimeout",
+				   temp_str);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->min_job_age);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "MinJobAge", 
-			    temp_str);
+				   "MinJobAge", 
+				   temp_str);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "MpiDefault",
-			    slurm_ctl_conf_ptr->mpi_default);
+				   "MpiDefault",
+				   slurm_ctl_conf_ptr->mpi_default);
 #ifdef MULTIPLE_SLURMD
 	add_display_treestore_line(update, treestore, &iter, 
-			    "MULTIPLE_SLURMD", "1");
+				   "MULTIPLE_SLURMD", "1");
 #endif
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->next_job_id);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "NEXT_JOB_ID",
-			    temp_str);
+				   "NEXT_JOB_ID",
+				   temp_str);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "PluginDir", 
-			    slurm_ctl_conf_ptr->plugindir);
+				   "PluginDir", 
+				   slurm_ctl_conf_ptr->plugindir);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "PlugStackConfig",
-			    slurm_ctl_conf_ptr->plugstack);
+				   "PlugStackConfig",
+				   slurm_ctl_conf_ptr->plugstack);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "ProctrackType",
-			    slurm_ctl_conf_ptr->proctrack_type);
+				   "ProctrackType",
+				   slurm_ctl_conf_ptr->proctrack_type);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "Prolog", 
-			    slurm_ctl_conf_ptr->prolog);
+				   "Prolog", 
+				   slurm_ctl_conf_ptr->prolog);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->propagate_prio_process);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "PropagatePrioProcess", temp_str);
+				   "PropagatePrioProcess", temp_str);
         add_display_treestore_line(update, treestore, &iter, 
-			    "PropagateResourceLimits",
-			    slurm_ctl_conf_ptr->propagate_rlimits);
+				   "PropagateResourceLimits",
+				   slurm_ctl_conf_ptr->propagate_rlimits);
         add_display_treestore_line(update, treestore, &iter, 
-			    "PropagateResourceLimitsExcept", 
-			    slurm_ctl_conf_ptr->propagate_rlimits_except);
+				   "PropagateResourceLimitsExcept", 
+				   slurm_ctl_conf_ptr->
+				   propagate_rlimits_except);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->ret2service);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "ReturnToService", temp_str);
+				   "ReturnToService", temp_str);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->schedport);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SchedulerPort", temp_str);
+				   "SchedulerPort", temp_str);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->schedrootfltr);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SchedulerRootFilter", temp_str);
+				   "SchedulerRootFilter", temp_str);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SchedulerType",
-			    slurm_ctl_conf_ptr->schedtype);
+				   "SchedulerType",
+				   slurm_ctl_conf_ptr->schedtype);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SelectType",
-			    slurm_ctl_conf_ptr->select_type);
+				   "SelectType",
+				   slurm_ctl_conf_ptr->select_type);
 	snprintf(temp_str, sizeof(temp_str), "%s(%u)", 
 		 slurm_ctl_conf_ptr->slurm_user_name,
 		 slurm_ctl_conf_ptr->slurm_user_id);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SlurmUser", temp_str);
+				   "SlurmUser", temp_str);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->slurmctld_debug);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SlurmctldDebug", temp_str);
+				   "SlurmctldDebug", temp_str);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SlurmctldLogFile", 
-			    slurm_ctl_conf_ptr->slurmctld_logfile);
+				   "SlurmctldLogFile", 
+				   slurm_ctl_conf_ptr->slurmctld_logfile);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SlurmctldPidFile", 
-			    slurm_ctl_conf_ptr->slurmctld_pidfile);
+				   "SlurmctldPidFile", 
+				   slurm_ctl_conf_ptr->slurmctld_pidfile);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->slurmctld_port);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SlurmctldPort", temp_str);
+				   "SlurmctldPort", temp_str);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->slurmctld_timeout);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SlurmctldTimeout", temp_str);
+				   "SlurmctldTimeout", temp_str);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->slurmd_debug);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SlurmdDebug", temp_str);
+				   "SlurmdDebug", temp_str);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SlurmdLogFile", 
-			    slurm_ctl_conf_ptr->slurmd_logfile);
+				   "SlurmdLogFile", 
+				   slurm_ctl_conf_ptr->slurmd_logfile);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SlurmdPidFile", 
-			    slurm_ctl_conf_ptr->slurmd_pidfile);
+				   "SlurmdPidFile", 
+				   slurm_ctl_conf_ptr->slurmd_pidfile);
 #ifndef MULTIPLE_SLURMD
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->slurmd_port);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SlurmdPort", temp_str);
+				   "SlurmdPort", temp_str);
 #endif
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SlurmdSpoolDir", 
-			    slurm_ctl_conf_ptr->slurmd_spooldir);
+				   "SlurmdSpoolDir", 
+				   slurm_ctl_conf_ptr->slurmd_spooldir);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->slurmd_timeout);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SlurmdTimeout", temp_str);
+				   "SlurmdTimeout", temp_str);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SLURM_CONFIG_FILE", 
-			    slurm_ctl_conf_ptr->slurm_conf);
+				   "SLURM_CONFIG_FILE", 
+				   slurm_ctl_conf_ptr->slurm_conf);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SLURM_VERSION", SLURM_VERSION);
+				   "SLURM_VERSION", SLURM_VERSION);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SrunProlog",
-			    slurm_ctl_conf_ptr->srun_prolog);
+				   "SrunProlog",
+				   slurm_ctl_conf_ptr->srun_prolog);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SrunEpilog",
-			    slurm_ctl_conf_ptr->srun_epilog);
+				   "SrunEpilog",
+				   slurm_ctl_conf_ptr->srun_epilog);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "StateSaveLocation", 
-			    slurm_ctl_conf_ptr->state_save_location);
+				   "StateSaveLocation", 
+				   slurm_ctl_conf_ptr->state_save_location);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SwitchType",
-			    slurm_ctl_conf_ptr->switch_type);
+				   "SwitchType",
+				   slurm_ctl_conf_ptr->switch_type);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "TaskEpilog",
-			    slurm_ctl_conf_ptr->task_epilog);
+				   "TaskEpilog",
+				   slurm_ctl_conf_ptr->task_epilog);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "TaskPlugin",
-			    slurm_ctl_conf_ptr->task_plugin);
+				   "TaskPlugin",
+				   slurm_ctl_conf_ptr->task_plugin);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "TaskProlog",
-			    slurm_ctl_conf_ptr->task_prolog);
+				   "TaskProlog",
+				   slurm_ctl_conf_ptr->task_prolog);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "TmpFS", 
-			    slurm_ctl_conf_ptr->tmp_fs);
+				   "TmpFS", 
+				   slurm_ctl_conf_ptr->tmp_fs);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->tree_width);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "TreeWidth", temp_str);
+				   "TreeWidth", temp_str);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->use_pam);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "UsePam", temp_str);
+				   "UsePam", temp_str);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->wait_time);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "WaitTime", temp_str);
+				   "WaitTime", temp_str);
 }
 
 extern void create_config_popup(GtkAction *action, gpointer user_data)
diff --git a/testsuite/Makefile.in b/testsuite/Makefile.in
index 5bcde55a10c4c1a1d4ce5e3977fccbcd6e0880ee..e05f141c2443a7e4a2ea7409df5258973884a3d7 100644
--- a/testsuite/Makefile.in
+++ b/testsuite/Makefile.in
@@ -43,6 +43,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -119,6 +120,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -142,6 +144,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -153,6 +156,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/testsuite/expect/Makefile.in b/testsuite/expect/Makefile.in
index e8f883b57e72033bb063103d515c55fd0d875ea4..619309f619a9495bed961cc9a4e53711abe0025f 100644
--- a/testsuite/expect/Makefile.in
+++ b/testsuite/expect/Makefile.in
@@ -41,6 +41,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -100,6 +101,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -123,6 +125,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -134,6 +137,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/testsuite/slurm_unit/Makefile.in b/testsuite/slurm_unit/Makefile.in
index 3ce0d148117921f1b64c69a14c0a73a760dfcb75..c171748382e0c976dc3d07c920a328364f39e4a6 100644
--- a/testsuite/slurm_unit/Makefile.in
+++ b/testsuite/slurm_unit/Makefile.in
@@ -41,6 +41,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -112,6 +113,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -135,6 +137,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -146,6 +149,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/testsuite/slurm_unit/api/Makefile.in b/testsuite/slurm_unit/api/Makefile.in
index 0e3708419d6acc0a109826f474b084431d5c1b7a..299d05d4b3be53976c282bae126b2c2e6d51e0a4 100644
--- a/testsuite/slurm_unit/api/Makefile.in
+++ b/testsuite/slurm_unit/api/Makefile.in
@@ -43,6 +43,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -132,6 +133,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -155,6 +157,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -166,6 +169,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/testsuite/slurm_unit/api/manual/Makefile.in b/testsuite/slurm_unit/api/manual/Makefile.in
index 621d8d7b25422ca226910457bda39eb5bca59364..8d8602b2aa75ccb35ad1f2cb66096e10f1ab1c5a 100644
--- a/testsuite/slurm_unit/api/manual/Makefile.in
+++ b/testsuite/slurm_unit/api/manual/Makefile.in
@@ -45,6 +45,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -154,6 +155,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -177,6 +179,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -188,6 +191,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/testsuite/slurm_unit/common/Makefile.in b/testsuite/slurm_unit/common/Makefile.in
index 1c9ca76d255869540abdff6447fe759ef760a010..e87462272bda363bcc73721e51b4f526ab680d38 100644
--- a/testsuite/slurm_unit/common/Makefile.in
+++ b/testsuite/slurm_unit/common/Makefile.in
@@ -43,6 +43,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -140,6 +141,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -163,6 +165,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -174,6 +177,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/testsuite/slurm_unit/slurmctld/Makefile.in b/testsuite/slurm_unit/slurmctld/Makefile.in
index 67c7ed29965147841b0603b745061f9fd3806d11..581094c00c66fd04a6952c3215cb8641c3dc266b 100644
--- a/testsuite/slurm_unit/slurmctld/Makefile.in
+++ b/testsuite/slurm_unit/slurmctld/Makefile.in
@@ -43,6 +43,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -103,6 +104,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -126,6 +128,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -137,6 +140,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
diff --git a/testsuite/slurm_unit/slurmd/Makefile.in b/testsuite/slurm_unit/slurmd/Makefile.in
index 040f69df521281ed9a6a743a117f693bc624090d..8c4cd85dcd366ddff60221171cdfc9590a4e69f8 100644
--- a/testsuite/slurm_unit/slurmd/Makefile.in
+++ b/testsuite/slurm_unit/slurmd/Makefile.in
@@ -43,6 +43,7 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -103,6 +104,7 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
@@ -126,6 +128,7 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
@@ -137,6 +140,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@