X-Git-Url: http://andersk.mit.edu/gitweb/moira.git/blobdiff_plain/208a4f4a61a6dc37a4b912feb6a13ecf155f21c7..ab05f33a0f59714921815569d658e356a071cf19:/dbck/dbck.dc diff --git a/dbck/dbck.dc b/dbck/dbck.dc index 12a214b3..1639cd3c 100644 --- a/dbck/dbck.dc +++ b/dbck/dbck.dc @@ -12,6 +12,7 @@ #include #include #include "dbck.h" +EXEC SQL INCLUDE sqlca; static char dbck_qc_rcsid[] = "$Header$"; @@ -23,7 +24,7 @@ int fast = 0; int warn = 1; int abort_p = 0; struct hash *users, *machines, *clusters, *lists, *filesys, *nfsphys; -struct hash *strings, *members; +struct hash *strings, *members, *subnets, *string_dups; EXEC SQL BEGIN DECLARE SECTION; int dcmenable; EXEC SQL END DECLARE SECTION; @@ -102,27 +103,27 @@ EXEC SQL END DECLARE SECTION; IIseterr(ingerr); printf("Opening database %s...", database); fflush(stdout); -/* ingres database */ EXEC SQL CONNECT :database; printf("done\n"); -/* retrieve (dcmenable = values.value) where values.name = "dcm_enable" */ EXEC SQL SELECT value INTO :dcmenable FROM numvalues WHERE name='dcm_enable'; dprintf("DCM disabled (was %d)\n", dcmenable); -/* replace values (value = 0) where values.name = "dcm_enable" */ EXEC SQL UPDATE numvalues SET value=0 WHERE name='dcm_enable'; /* Begin transaction here. */ if (!countonly) { phase1(); + EXEC SQL COMMIT WORK; phase2(); + EXEC SQL COMMIT WORK; phase3(); + EXEC SQL COMMIT WORK; } else { count_only_setup(); + EXEC SQL COMMIT WORK; } phase4(); - EXEC SQL COMMIT WORK; cleanup(); @@ -133,7 +134,14 @@ EXEC SQL END DECLARE SECTION; ingerr(num) int *num; { - printf("An ingres error occuurred, code %d\n", *num); +EXEC SQL BEGIN DECLARE SECTION; + char buf[512]; +EXEC SQL END DECLARE SECTION; + + if (*num == 100) return; + printf("An ingres error occurred, code %d\n", *num); + EXEC SQL INQUIRE_SQL(:buf = errortext); + printf("%s\n", buf); printf("Aborting...\n"); if (!abort_p) { abort_p++; @@ -162,12 +170,9 @@ int interrupt() EXEC SQL ROLLBACK WORK; } -/* replace values (value = dcmenable) where values.name = "dcm_enable" */ EXEC SQL UPDATE numvalues SET value=:dcmenable WHERE name='dcm_enable'; -/* exit */ - /* No equivalent (?) */ exit(0); } @@ -185,15 +190,11 @@ cleanup() EXEC SQL END DECLARE SECTION; while (sq_get_data(modtables, &tab)) { -/* replace tblstats (modtime = "now") where tblstats.table = tab */ EXEC SQL REPEATED UPDATE tblstats SET modtime='now' WHERE table_name = :tab; } -/* replace values (value = dcmenable) where values.name = "dcm_enable" */ EXEC SQL UPDATE numvalues SET value = :dcmenable WHERE name='dcm_enable'; -/* exit */ - /* No equivalent (?) */ } @@ -201,8 +202,16 @@ out_of_mem(msg) char *msg; { fprintf(stderr, "Out of memory while %s\n", msg); -/* end transaction */ - EXEC SQL COMMIT WORK; - cleanup(); + if (prompt("Save database changes")) { + /* break out of a retrieve loop */ + IIbreak(); + + EXEC SQL COMMIT WORK; + cleanup(); + exit(1); + } + printf("Aborting transaction\n"); + IIbreak(); + EXEC SQL ROLLBACK WORK; exit(1); }