]> andersk Git - moira.git/blobdiff - gen/stats.dc
Initial revision
[moira.git] / gen / stats.dc
index 4e8dd9a58665bc07bbc7ca06748b083d0a13faa5..0933aba1cd6d95b9ce69890d4c2ccbfcc261cde2 100644 (file)
@@ -37,10 +37,11 @@ char **argv;
     EXEC SQL END DECLARE SECTION;
 
 #ifsql INGRES
-    EXEC SQL CONNECT sms;
+    EXEC SQL CONNECT moira;
+    EXEC SQL SET LOCKMODE SESSION WHERE LEVEL=TABLE, READLOCK=SHARED;
 #endsql
 #ifsql INFORMIX
-    EXEC SQL DATABASE sms;
+    EXEC SQL DATABASE moira;
 #endsql
 
     if (argc == 2) {
@@ -67,6 +68,10 @@ char **argv;
        outf = NULL;
     }
 
+    /* The following is declarative, not executed,
+     * and so is dependent on where it is in the file,
+     * not in the order of execution of statements.
+     */
     EXEC SQL WHENEVER SQLERROR GOTO sqlerr;
 
     machines = create_hash(1000);
@@ -85,13 +90,13 @@ char **argv;
     EXEC SQL DECLARE x CURSOR FOR
       SELECT DISTINCT f.mach_id, count(f.filsys_id)
       FROM filesys f
-       WHERE f.type="NFS"
+       WHERE f.type='NFS'
       GROUP BY f.mach_id;
     EXEC SQL OPEN x;
     while (1) {
        EXEC SQL FETCH x INTO :id, :n;
        if (sqlca.sqlcode != 0) break;
-       fprintf(out, "%s %d\n", hash_lookup(machines, id), n);
+       fprintf(out, "%-32s %d\n", hash_lookup(machines, id), n);
     }
     EXEC SQL CLOSE x;
 
@@ -112,6 +117,10 @@ char **argv;
 
  sqlerr:
     com_err(whoami, MR_INGRES_ERR, " code %d\n", sqlca.sqlcode);
+#ifsql INGRES
+    if (sqlca.sqlcode == 17700 || sqlca.sqlcode == -37000)
+      exit(MR_DEADLOCK);
+#endsql
     critical_alert("DCM", "Central America build encountered INGRES ERROR %d",
                   sqlca.sqlcode);
     exit(MR_INGRES_ERR);
This page took 0.034639 seconds and 4 git commands to generate.