X-Git-Url: http://andersk.mit.edu/gitweb/moira.git/blobdiff_plain/0966656e7439f81230c81a295e9dbe562817bd95..dcfa270ac1d2f55eb793c4da4bbd555903a88b09:/gen/stats.dc diff --git a/gen/stats.dc b/gen/stats.dc index 4e8dd9a5..0933aba1 100644 --- a/gen/stats.dc +++ b/gen/stats.dc @@ -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);