]> andersk Git - moira.git/blobdiff - dbck/dbck.dc
dbck fixes by kcr, dkk, and myself from the end of the summer.
[moira.git] / dbck / dbck.dc
index 12a214b33a66b7fdaced6192a919f2a6e8ad9cd6..1639cd3cd5b20bd41b4699abd5e0efdf73e16bd0 100644 (file)
@@ -12,6 +12,7 @@
 #include <strings.h>
 #include <signal.h>
 #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);
 }
This page took 0.037727 seconds and 4 git commands to generate.