]> andersk Git - moira.git/commitdiff
Oracle and Solaris/POSIX changes
authordanw <danw>
Mon, 20 Jan 1997 18:20:06 +0000 (18:20 +0000)
committerdanw <danw>
Mon, 20 Jan 1997 18:20:06 +0000 (18:20 +0000)
Source tree should only have Imakefiles, not Makefiles
Use EXEC SQL WHENEVER to report SQL errors in more places

dbck/Imakefile
dbck/Makefile [deleted file]
dbck/dbck.dc
dbck/dbck.h
dbck/fix.dc
dbck/nhash.c
dbck/phase1.dc
dbck/phase2.dc
dbck/phase3.dc
dbck/phase4.dc

index 098afdd0e6c262b0546bf0adc7551ae4c404bf42..dc9939eef34d466c488051de3f2441bee8a1605b 100644 (file)
@@ -8,9 +8,9 @@
 # Imakefile for server directory.
 #
 
-SRCS = dbck.c fix.c phase1.c phase2.c phase3.c phase4.c nhash.c
+SRCS = dbck.h dbck.c fix.c phase1.c phase2.c phase3.c phase4.c nhash.c
 OBJS = dbck.o fix.o phase1.o phase2.o phase3.o phase4.o nhash.o
-CODE = dbck.dc fix.dc phase1.dc phase2.dc phase3.dc phase4.dc dbck.h nhash.c
+CODE = dbck.h dbck.dc fix.dc phase1.dc phase2.dc phase3.dc phase4.dc nhash.c
 SRCDIR=$(SRCTOP)/dbck
 sqlrule()
 
diff --git a/dbck/Makefile b/dbck/Makefile
deleted file mode 100644 (file)
index 1164d35..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-# $Header$
-# Database consistency checker
-#
-# (c) Copyright 1988 by the Massachusetts Institute of Technology.
-# For copying and distribution information, please see the file
-# <mit-copyright.h>.
-
-
-.SUFFIXES:
-.SUFFIXES: .o .c .dc .sc
-CFLAGS= -I/usr/athena/include -I/u3/kcr/moira/include -I/u3/kcr/moira/lib -O
-CC=cc
-
-AWK=awk
-
-SRCS = dbck.c fix.c phase1.c phase2.c phase3.c phase4.c members.c nhash.c
-OBJS = dbck.o fix.o phase1.o phase2.o phase3.o phase4.o nhash.o
-
-EQLIBS = /u3/kcr/moira/lib/libmoira.a /u3/kcr/moira/server/libmrglue.a /usr/ingres/lib/libingres.a -lm
-
-.dc.sc:
-       $(AWK) -f /mit/moiradev/src/util/imake.includes/ingres.awk < $< > $*.sc
-
-.sc.c:
-       /usr/ingres/bin/esqlc -p $*.sc
-
-all: dbck members
-
-dbck: ${OBJS}
-       cc -o $@ ${CFLAGS} ${OBJS} ${EQLIBS}
-
-dbck.c: dbck.sc
-dbck.o: dbck.h dbck.c
-fix.o: fix.c dbck.h
-fix.c: fix.sc
-phase1.o: phase1.c dbck.h
-phase1.c: phase1.sc
-phase2.o: phase2.c dbck.h
-phase2.c: phase2.sc
-phase3.o: phase3.c dbck.h
-phase3.c: phase3.sc
-phase4.o: phase4.c dbck.h
-phase4.c: phase4.sc
-members.c: members.sc
-members.o: members.c
-nhash.o: nhash.c
-
-members: members.o
-       cc -o members members.o ${EQLIBS}
-
-clean:
-       rm -f *.o 
-       rm -f dbck.sc fix.sc phase1.sc phase2.sc phase3.sc phase4.sc 
-       rm -f dbck.c fix.c phase1.c phase2.c phase3.c phase4.c dbck
-       rm -f members.sc members.c members
-       rm -f core *~
-
-install: dbck
-       install -c dbck /u3/kcr/moira/bin/dbck
-
-depend: ${SRCS}
-       makedepend ${CFLAGS} ${SRCS}
-
-
index 1639cd3cd5b20bd41b4699abd5e0efdf73e16bd0..4c644ef336c8e55fab284337cd36d3987386a712 100644 (file)
@@ -13,7 +13,7 @@
 #include <signal.h>
 #include "dbck.h"
 EXEC SQL INCLUDE sqlca;
-
+EXEC SQL INCLUDE sqlda;
 
 static char dbck_qc_rcsid[] = "$Header$";
 
@@ -29,7 +29,8 @@ EXEC SQL BEGIN DECLARE SECTION;
 int dcmenable;
 EXEC SQL END DECLARE SECTION; 
 struct save_queue *modtables, *sq_create();
-int interrupt();
+void interrupt();
+SQLDA *mr_sqlda;
 
 
 main(argc, argv)
@@ -44,6 +45,7 @@ EXEC SQL END DECLARE SECTION;
     int countonly = 0;
 
     database = "moira";
+    setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
 
     while (++arg - argv < argc) {
        if  (**arg == '-')
@@ -93,17 +95,17 @@ EXEC SQL END DECLARE SECTION;
     if (debug)
       printf("Debug level is %d\n", debug);
 
-    setlinebuf(stdout);
-
     signal(SIGHUP, interrupt);
     signal(SIGQUIT, interrupt);
     signal(SIGINT, interrupt);
+
     modtables = sq_create();
+    mr_sqlda = sqlald(1, 255, 0);
 
-    IIseterr(ingerr);
+    EXEC SQL WHENEVER SQLERROR DO dbmserr();
     printf("Opening database %s...", database);
     fflush(stdout);
-    EXEC SQL CONNECT :database;
+    EXEC SQL CONNECT :database IDENTIFIED BY :database;
     printf("done\n");
     EXEC SQL SELECT value INTO :dcmenable FROM numvalues 
        WHERE name='dcm_enable'; 
@@ -131,16 +133,17 @@ EXEC SQL END DECLARE SECTION;
     exit(0);
 }
 
-ingerr(num)
-int    *num;
+dbmserr()
 {
 EXEC SQL BEGIN DECLARE SECTION;
     char buf[512];
 EXEC SQL END DECLARE SECTION;
+    int bufsize=256, msglength=0;
 
-    if (*num == 100) return;
-    printf("An ingres error occurred, code %d\n", *num);
-    EXEC SQL INQUIRE_SQL(:buf = errortext);
+    if (sqlca.sqlcode==1403) return;
+    printf("A DBMS error occurred, code %d\n", sqlca.sqlcode);
+    sqlglm(buf, &bufsize, &msglength);
+    buf[msglength]=0;
     printf("%s\n", buf);
     printf("Aborting...\n");
     if (!abort_p) {
@@ -151,13 +154,10 @@ EXEC SQL END DECLARE SECTION;
 }
 
 
-int interrupt()
+void interrupt()
 {
     printf("Signal caught\n");
     if (prompt("Save database changes")) {
-       /* break out of a retrieve loop */
-       IIbreak();
-
        EXEC SQL COMMIT WORK;
        cleanup();
        exit(0);
@@ -165,8 +165,6 @@ int interrupt()
     printf("Aborting transaction\n");
     if (!abort_p) {
        abort_p++;
-       /* break out of a retrieve loop */
-       IIbreak();
        EXEC SQL ROLLBACK WORK;
     }
 
@@ -190,7 +188,7 @@ cleanup()
     EXEC SQL END DECLARE SECTION; 
 
     while (sq_get_data(modtables, &tab)) {
-       EXEC SQL REPEATED UPDATE tblstats SET modtime='now'
+       EXEC SQL UPDATE tblstats SET modtime=SYSDATE
            WHERE table_name = :tab;
     }
     EXEC SQL UPDATE numvalues SET value = :dcmenable
@@ -203,15 +201,11 @@ char *msg;
 {
     fprintf(stderr, "Out of memory while %s\n", msg);
     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);
 }
index 1876e1e9096f07340c522ee2b59098dc9f944832..252fbccfc21264f75a2cdeec5d74a800e8f4b488 100644 (file)
@@ -83,7 +83,7 @@ struct string {
 
 struct filesys {
     char name[33];
-    char dir[33];
+    char dir[81];
     char type;
     int filsys_id;
     int mach_id;
index fb9995dd69634f473a532f5d3ef04cf8ae622c49..4c134eee818bc83630074b97540b0df698c200c7 100644 (file)
 EXEC SQL INCLUDE sqlca;  /* SQL Communications Area */
 EXEC SQL INCLUDE sqlda;  /* SQL Descriptor Area */
 
-#define SQLDA_RETVALS
-typedef IISQLDA_TYPE(DBCK_SQLDA,DBCK_SQLDA_T,SQLDA_RETVALS);
-DBCK_SQLDA_T SQLDA;
-
 static char fix_qc_rcsid[] = "$Header$";
 
 EXEC SQL BEGIN DECLARE SECTION; 
@@ -27,6 +23,8 @@ char *_idfield;
 char stmt_buf[500];
 EXEC SQL END DECLARE SECTION; 
 
+extern SQLDA *mr_sqlda;
+
 generic_ffunc(id)
 EXEC SQL BEGIN DECLARE SECTION; 
 int id;
@@ -36,12 +34,10 @@ EXEC SQL END DECLARE SECTION;
     int rowcount;
     EXEC SQL END DECLARE SECTION; 
 
-/*  delete _table where _table._idfield = id */
     sprintf(stmt_buf,"DELETE FROM %s WHERE %s.%s = %d",
            _table,_table,_idfield,id);
     EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
-/*  inquire_equel(rowcount = "rowcount") */
-    EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
+    rowcount = sqlca.sqlerrd[2];
     if (rowcount > 0)
       printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
     else
@@ -82,12 +78,10 @@ EXEC SQL END DECLARE SECTION;
     int rowcount;
     EXEC SQL END DECLARE SECTION; 
 
-/*  replace tbl (zrfield = 0) where table.idfield = id */
     sprintf(stmt_buf,"UPDATE %s SET %s = 0 WHERE %s.%s = %d",
            tbl,zrfield,tbl,idfield,id);
     EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
-/*  inquire_equel(rowcount = "rowcount") */
-    EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
+    rowcount = sqlca.sqlerrd[2];
     if (rowcount > 0)
       printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
     else
@@ -152,19 +146,13 @@ char *msg;
        if (buf[0] == 'Q' || buf[0] == 'q') {
            if (prompt("Are you sure you want to quit")) {
                if (prompt("Save database changes")) {
-/*                 end transaction */
                    EXEC SQL COMMIT WORK;
                    cleanup();
                    exit(0);
                } else {
-/*                 abort */
                    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(1);
                }
            }
@@ -185,60 +173,52 @@ char *msg;
  **/
 
 int set_next_object_id(object, tablename)
+EXEC SQL BEGIN DECLARE SECTION;
     char *object;
+EXEC SQL END DECLARE SECTION;
     char *tablename;
 {
     EXEC SQL BEGIN DECLARE SECTION; 
-    char *name, *tbl;
-    int rowcount, existence, value;
+    int value;
+    char stmt_buf[256], out_buf[256];
     EXEC SQL END DECLARE SECTION; 
+    int starting_value, errcode=0;
 
-    name = object;
-    tbl = tablename;
-/*  range of v is values
- *  repeat retrieve (value = v.#value) where v.#name = @name */
-    EXEC SQL REPEATED SELECT value INTO :value FROM numvalues
-       WHERE name = :name;
-    EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
-    if (rowcount != 1)
+    EXEC SQL SELECT value INTO :value FROM numvalues WHERE name = :object;
+    if (sqlca.sqlerrd[2] != 1)
        return(MR_NO_ID);
 
-/*  retrieve (existence = any(tbl.name where tbl.name = value)) */
-    SQLDA.sqlvar[0].sqldata=(void *)&rowcount;
-    sprintf(stmt_buf,"SELECT COUNT (*) FROM %s WHERE %s=%d",tbl,name,value);
-    EXEC SQL PREPARE stmt INTO :&SQLDA USING NAMES FROM :stmt_buf; 
-    if(sqlca.sqlcode)
-       return(MR_INTERNAL);
-    EXEC SQL DECLARE foo CURSOR FOR stmt;
-    EXEC SQL OPEN foo;
-    EXEC SQL FETCH foo USING DESCRIPTOR :&SQLDA;
-    if (sqlca.sqlcode < 0) return(MR_INTERNAL);
-    if (sqlca.sqlcode == 100) existence=0; else existence=1;
-    EXEC SQL CLOSE foo;
-
-    if (rowcount != 1)
-       return(MR_NO_ID);
-    while (existence) {
+    starting_value=value;
+    while(1) {
+        if (value > MAX_ID_VALUE) value = MIN_ID_VALUE;
+
+       sprintf(stmt_buf, "SELECT %s FROM %s WHERE %s=%d",
+               object, tablename, object, value);
+       EXEC SQL PREPARE inc_stmt FROM :stmt_buf;
+       EXEC SQL DECLARE inc_crs CURSOR FOR inc_stmt;
+       EXEC SQL OPEN inc_crs;
+       mr_sqlda->N = 1;
+       EXEC SQL DESCRIBE SELECT LIST FOR inc_stmt INTO mr_sqlda;
+       mr_sqlda->N = mr_sqlda->F;
+       mr_sqlda->V[0]=out_buf;
+       mr_sqlda->T[0]=97;
+       mr_sqlda->L[0]=255;
+       EXEC SQL FETCH inc_crs USING DESCRIPTOR mr_sqlda;
+
+       /* if we got an error from the FETCH, we have to preserve it or the
+          close will reset it and the caller with think nothing happened */
+       if(sqlca.sqlcode) errcode=sqlca.sqlcode;
+
+       EXEC SQL CLOSE inc_crs;
+       if (errcode < 0) return(MR_DBMS_ERR);
+       if (errcode == 1403) break;
+
        value++;
-       if (value > MAX_ID_VALUE)
-           value = MIN_ID_VALUE;
-/*     retrieve (existence = any(tbl.name where tbl.name = value)) */
-       sprintf(stmt_buf,"SELECT %s FROM %s WHERE %s=%d",name,tbl,name,value);
-       EXEC SQL PREPARE stmt INTO :&SQLDA USING NAMES FROM :stmt_buf; 
-       if(sqlca.sqlcode)
-           return(MR_INTERNAL);
-       EXEC SQL DECLARE bar CURSOR FOR stmt;
-       EXEC SQL OPEN bar;
-       EXEC SQL FETCH bar USING DESCRIPTOR :&SQLDA;
-       if (sqlca.sqlcode != 0) break;
-       EXEC SQL CLOSE bar;
+       if (value == starting_value) return (MR_NO_ID);
     }
-    EXEC SQL CLOSE bar; 
 
-    printf("setting ID %s to %d\n", name, value);
-/*  repeat replace v (#value = @value) where v.#name = @name */
-    EXEC SQL REPEATED UPDATE numvalues SET value = :value
-       WHERE name = :name;
+    printf("setting ID %s to %d\n", object, value);
+    EXEC SQL UPDATE numvalues SET value = :value WHERE name = :object;
     modified("values");
     return(MR_SUCCESS);
 }
@@ -254,22 +234,16 @@ generic_fix_id(tbl, idfield, txtfield, oldid, name)
     EXEC SQL END DECLARE SECTION; 
 {
     EXEC SQL BEGIN DECLARE SECTION; 
-    int rowcount, id, temp;
+    int rowcount, id;
     EXEC SQL END DECLARE SECTION; 
 
     set_next_object_id(tbl, idfield);
-/*  retrieve (id = values.value) where values.#name = idfield */
     EXEC SQL SELECT value INTO :id FROM numvalues
        WHERE name = :idfield;
-/*  replace tbl (idfield = values.value) where values.#name = idfield and
- *     tbl.idfield = oldid and tbl.txtfield = name
- */
-    EXEC SQL SELECT value INTO :temp FROM numvalues 
-       WHERE name = :idfield;
     sprintf(stmt_buf,"UPDATE %s SET %s = %d WHERE %s=%d AND %s='%s'",
-           tbl,idfield,temp,idfield,oldid,txtfield,name);
+           tbl,idfield,id,idfield,oldid,txtfield,name);
     EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
-    EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
+    rowcount = sqlca.sqlerrd[2];
     if (rowcount == 1)
       printf("Fixed\n");
     else
@@ -277,22 +251,3 @@ generic_fix_id(tbl, idfield, txtfield, oldid, name)
     modified(tbl);
     return(id);
 }
-
-de_dup( tbl, idfield, id, dupfield, correct_val )
-EXEC SQL BEGIN DECLARE SECTION; 
-char *tbl, *idfield, *dupfield;
-int id, correct_val;
-EXEC SQL END DECLARE SECTION; 
-{
-    int size, i;
-    EXEC SQL BEGIN DECLARE SECTION; 
-    int rowcount;
-    EXEC SQL END DECLARE SECTION; 
-
-/*  replace tbl.dupfield with correct_val where tbl.idfield = id */
-    sprintf( stmt_buf,"UPDATE %s SET %d = %d WHERE %s = %d",
-            tbl, dupfield, correct_val, idfield, id );
-    size = strlen( stmt_buf );
-    for( i=0; i!=NULL && i<500; i++ ) { ; }  /* Move to an unused string. */
-    
-}
index e7a6c878fb46fed5704992b43ae12cece661abba..b315116cdcf3f5fac2135211f1e1fa781d961dc3 100644 (file)
@@ -42,7 +42,7 @@ int size;
        free(h);
        return((struct int_hash *) NULL);
     }
-    bzero(h->data, size * sizeof(char *));
+    memset(h->data, 0, size * sizeof(char *));
     return(h);
 }
 
index 41a7e93c6147eaf44732fc0a7b95f20c3681fd1d..c69488bb96e6094549190571cabcc2d8ed924140 100644 (file)
@@ -11,9 +11,9 @@
 #include "dbck.h"
 EXEC SQL INCLUDE sqlca;
 
-
 static char phase1_qc_rcsid[] = "$Header$";
 
+EXEC SQL WHENEVER SQLERROR DO dbmserr();
 
 show_user_id(u)
 struct user *u;
@@ -50,9 +50,9 @@ struct save_queue *sq;
                int id = uu->users_id, rowcount;
                EXEC SQL END DECLARE SECTION; 
 
-               EXEC SQL UPDATE users SET login = '#'+CHAR(users.uid),
+               EXEC SQL UPDATE users SET login = '#' || CHAR(users.unix_uid),
                    status=0 WHERE users_id = :id;
-               EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
+               rowcount = sqlca.sqlerrd[2];
                if (rowcount > 0)
                  printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
                else
@@ -226,7 +226,6 @@ phase1()
       SELECT s1.string_id, s2.string_id FROM strings s1, strings s2
        where s1.string = s2.string and s1.string_id < s2.string_id;
     EXEC SQL OPEN csr116;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     /*  The SELECT gives us two columns, both with non-negative integers.
      *  The number in the left column is always the smaller of the two,
      *  and each row includes string IDs for identical strings.  We use
@@ -236,10 +235,7 @@ phase1()
     q=0;
     while(1) {
        EXEC SQL FETCH csr116 INTO :id1, :id2;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       }
+       if (sqlca.sqlcode != 0) break;
        q++;
        /*  If id2 is already stored, skip this row. */
        i = int_hash_lookup( string_dups, id2 );
@@ -263,16 +259,12 @@ phase1()
     if(!sq || !strings) out_of_mem("loading strings");
 
     EXEC SQL DECLARE csr101 CURSOR FOR
-      SELECT string_id, string, tid FROM strings ORDER BY string_id;
+      SELECT string_id, string FROM strings ORDER BY string_id;
     EXEC SQL OPEN csr101;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     q=0;
     while(1) {
-       EXEC SQL FETCH csr101 INTO :id, :buf, :id1;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       }
+       EXEC SQL FETCH csr101 INTO :id, :buf;
+       if (sqlca.sqlcode != 0) break;
        q++;
        s = (struct string *) malloc(sizeof(struct string));
        if (s == NULL)
@@ -303,17 +295,13 @@ phase1()
 
     EXEC SQL DECLARE csr102 CURSOR FOR 
       SELECT users_id, login, last, first, status, potype, pop_id, box_id,
-         modby, fmodby, pmodby, comment, sigwho FROM users
+         modby, fmodby, pmodby, comments, sigwho FROM users
        ORDER BY users_id;
     EXEC SQL OPEN csr102;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     while(1) {
        EXEC SQL FETCH csr102 INTO :id, :name, :last, :first, :status,
             :buf, :id2, :id3, :sid, :sid2, :sid3, :sid4, :sid5;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       }
+       if (sqlca.sqlcode != 0) break;
 
        u = (struct user *) malloc(sizeof(struct user));
        if (u == NULL)
@@ -358,15 +346,11 @@ phase1()
 
        EXEC SQL DECLARE csr103 CURSOR FOR 
            SELECT u1.users_id FROM users u1, users u2
-           WHERE u1.login = u2.login and u1.tid != u2.tid;
+           WHERE u1.login = u2.login and u1.rowid != u2.rowid;
        EXEC SQL OPEN csr103;
-       if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
        while(1) {
            EXEC SQL FETCH csr103 INTO :id;
-           if (sqlca.sqlcode != 0) {
-               ingerr(&sqlca.sqlcode);
-               break;
-           }
+           if (sqlca.sqlcode != 0) break;
            sq_save_data(sq, hash_lookup(users, id));
        }
        EXEC SQL CLOSE csr103; 
@@ -378,15 +362,11 @@ phase1()
 
        EXEC SQL DECLARE csr113 CURSOR FOR
            SELECT k1.users_id FROM krbmap k1, krbmap k2
-               WHERE k1.users_id = k2.users_id AND k1.tid != k2.tid;
+               WHERE k1.users_id = k2.users_id AND k1.rowid != k2.rowid;
        EXEC SQL OPEN csr113;
-       if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
        while(1) {
            EXEC SQL FETCH csr113 INTO :id;
-           if (sqlca.sqlcode != 0) {
-               ingerr(&sqlca.sqlcode);
-               break;
-           } 
+           if (sqlca.sqlcode != 0) break;
 
            printf("User %d is in the krbmap more than once!\n", id);
            printf("Not fixing this error\n");
@@ -395,15 +375,11 @@ phase1()
 
        EXEC SQL DECLARE csr114 CURSOR FOR
            SELECT k1.string_id FROM krbmap k1, krbmap k2
-               WHERE k1.string_id = k2.string_id AND k1.tid != k2.tid;
+               WHERE k1.string_id = k2.string_id AND k1.rowid != k2.rowid;
        EXEC SQL OPEN csr114;
-       if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
        while(1) {
            EXEC SQL FETCH csr114 INTO :id;
-           if (sqlca.sqlcode != 0) {
-               ingerr(&sqlca.sqlcode);
-               break;
-           } 
+           if (sqlca.sqlcode != 0) break; 
 
            printf("Principal %d is in the krbmap more than once!\n", id);
            printf("Not fixing this error\n");
@@ -421,14 +397,10 @@ phase1()
                acomment, ocomment, creator, modby
        FROM machine ORDER BY mach_id;
     EXEC SQL OPEN csr104;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     while(1) {
        EXEC SQL FETCH csr104 INTO :id, :name, :id2, :buf, :id3, :sid2,
                :sid3, :sid4, :sid;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break; 
 
        m = (struct machine *) malloc(sizeof(struct machine));
        if (m == NULL)
@@ -460,15 +432,11 @@ phase1()
 
        EXEC SQL DECLARE csr105 CURSOR FOR
            SELECT m1.mach_id FROM machine m1, machine m2
-               WHERE m1.name = m2.name AND m1.tid != m2.tid;
+               WHERE m1.name = m2.name AND m1.rowid != m2.rowid;
        EXEC SQL OPEN csr105;
-       if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
        while(1) {
            EXEC SQL FETCH csr105 INTO :id;
-           if (sqlca.sqlcode != 0) {
-               ingerr(&sqlca.sqlcode);
-               break;
-           } 
+           if (sqlca.sqlcode != 0) break; 
 
            sq_save_data(sq, hash_lookup(machines, id));
        }
@@ -481,13 +449,9 @@ phase1()
          WHERE h1.name=h2.name AND h1.mach_id!=h2.mach_id
          AND m1.mach_id=h1.mach_id AND m2.mach_id=h2.mach_id;
        EXEC SQL OPEN csr_hal1;
-       if(sqlca.sqlcode!=0) ingerr(&sqlca.sqlcode);
        while(1) {
          EXEC SQL FETCH csr_hal1 INTO :name, :id1, :id2;
-         if(sqlca.sqlcode!=0) {
-           ingerr(&sqlca.sqlcode);
-           break;
-         }
+         if(sqlca.sqlcode!=0) break;
          printf("Aliases for machines %d and %d have duplicate name %s\n",
                 id1, id2, strtrim(name));
          cant_fix();
@@ -499,13 +463,9 @@ phase1()
          FROM hostalias h1, machine m1, machine m2
          WHERE h1.name=m1.name AND h1.mach_id=m2.mach_id;
        EXEC SQL OPEN csr_hal2;
-       if(sqlca.sqlcode!=0) ingerr(&sqlca.sqlcode);
        while(1) {
          EXEC SQL FETCH csr_hal2 INTO :name, :id1, :id2;
-         if(sqlca.sqlcode!=0) {
-           ingerr(&sqlca.sqlcode);
-           break;
-         }
+         if(sqlca.sqlcode!=0) break;
          printf("Machine %d has alias `%s' that conflicts with machine %d\n",
                 id2, strtrim(name), id1);
          cant_fix();
@@ -520,13 +480,9 @@ phase1()
     EXEC SQL DECLARE csr115 CURSOR FOR
       SELECT snet_id, name, owner_type, owner_id, modby from subnet;
     EXEC SQL OPEN csr115;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     while(1) {
        EXEC SQL FETCH csr115 INTO :id, :name, :buf, :id2, :sid;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       }
+       if (sqlca.sqlcode != 0) break;
 
        sn = (struct subnet *) malloc(sizeof(struct machine));
        if (sn == NULL)
@@ -552,15 +508,11 @@ phase1()
     if(!sq || !clusters) out_of_mem("loading clusters");
 
     EXEC SQL DECLARE csr106 CURSOR FOR
-       SELECT clu_id, name, modby FROM cluster;
+       SELECT clu_id, name, modby FROM clusters;
     EXEC SQL OPEN csr106;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     while(1) {
        EXEC SQL FETCH csr106 INTO :id, :name, :sid;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break; 
 
        c = (struct cluster *) malloc(sizeof(struct cluster));
        if (c == NULL)
@@ -584,16 +536,12 @@ phase1()
        if(!sq) out_of_mem("looking for duplicate cluster names");
 
        EXEC SQL DECLARE csr107 CURSOR FOR
-           SELECT c1.clu_id FROM cluster c1, cluster c2
-               WHERE c1.name=c2.name AND c1.tid != c2.tid;
+           SELECT c1.clu_id FROM clusters c1, clusters c2
+               WHERE c1.name=c2.name AND c1.rowid != c2.rowid;
        EXEC SQL OPEN csr107;
-       if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
        while(1) {
            EXEC SQL FETCH csr107 INTO :id;
-           if (sqlca.sqlcode != 0) {
-               ingerr(&sqlca.sqlcode);
-               break;
-           } 
+           if (sqlca.sqlcode != 0) break; 
 
            sq_save_data(sq, hash_lookup(clusters, id));
        }
@@ -610,13 +558,9 @@ phase1()
        SELECT list_id, name, acl_id, acl_type, modby  FROM list 
        ORDER BY list_id;
     EXEC SQL OPEN csr108;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     while(1) {
        EXEC SQL FETCH csr108 INTO :id, :name, :aid, :buf, :sid;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       }
+       if (sqlca.sqlcode != 0) break;
        l = (struct list *) malloc(sizeof(struct list));
        if (l == NULL)
          out_of_mem("storing lists");
@@ -642,15 +586,11 @@ phase1()
 
        EXEC SQL DECLARE csr109 CURSOR FOR
            SELECT l1.list_id FROM list l1, list l2
-               WHERE l1.name=l2.name AND l1.tid != l2.tid;
+               WHERE l1.name=l2.name AND l1.rowid != l2.rowid;
        EXEC SQL OPEN csr109;
-       if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
        while(1) {
            EXEC SQL FETCH csr109 INTO :id;
-           if (sqlca.sqlcode != 0) {
-               ingerr(&sqlca.sqlcode);
-               break;
-           } 
+           if (sqlca.sqlcode != 0) break; 
            
            sq_save_data(sq, hash_lookup(lists, id));
        }
@@ -667,14 +607,10 @@ phase1()
        SELECT filsys_id, label, owner, owners, phys_id, mach_id,
                type, name, modby FROM filesys ORDER BY filsys_id;
     EXEC SQL OPEN csr110;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     while(1) {
        EXEC SQL FETCH csr110 INTO :id, :name, :aid, :aid2, :id2, :id3, 
            :buf, :name1, :sid;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       }
+       if (sqlca.sqlcode != 0) break;
 
        f = (struct filesys *) malloc(sizeof(struct filesys));
        if (f == NULL)
@@ -707,13 +643,9 @@ phase1()
     EXEC SQL DECLARE csr111 CURSOR FOR
        SELECT nfsphys_id, dir, mach_id, allocated, modby FROM nfsphys;
     EXEC SQL OPEN csr111;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     while(1) {
        EXEC SQL FETCH csr111 INTO :id, :name, :id2, :id3, :sid;
-       if (sqlca.sqlcode != 0) {
-           ingerr(&sqlca.sqlcode);
-           break;
-       } 
+       if (sqlca.sqlcode != 0) break; 
 
        n = (struct nfsphys *) malloc(sizeof(struct nfsphys));
        if (n == NULL)
index 77f69486a03b0cc1673a9b1bbb8defd0df8ca287..f63fc56284958975366d102be5d5e1b3ab6a851d 100644 (file)
@@ -13,6 +13,7 @@ EXEC SQL INCLUDE sqlca;
 
 static char phase2_qc_rcsid[] = "$Header$";
 
+EXEC SQL WHENEVER SQLERROR DO dbmserr();
 
 show_mcm_mach(id)
 int id;
@@ -23,16 +24,12 @@ int id;
     EXEC SQL END DECLARE SECTION; 
 
     EXEC SQL DECLARE csr201 CURSOR FOR
-      SELECT cluster.name FROM cluster, mcmap
-        WHERE cluster.clu_id=mcmap.clu_id AND mcmap.mach_id = :iid;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
+      SELECT clusters.name FROM clusters, mcmap
+        WHERE clusters.clu_id=mcmap.clu_id AND mcmap.mach_id = :iid;
     EXEC SQL OPEN csr201;
     while(1) {
        EXEC SQL FETCH csr201 INTO :name;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break; 
 
        strtrim(name);
        found = 0;
@@ -50,20 +47,13 @@ int id;
     char name[33];
     EXEC SQL END DECLARE SECTION; 
 
-    EXEC SQL DECLARE csr202 CURSOR
-
-
-      FOR
-       SELECT machine.name FROM machine, mcmap
-           WHERE machine.mach_id=mcmap.mach_id AND mcmap.clu_id=:iid;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
+    EXEC SQL DECLARE csr202 CURSOR FOR
+        SELECT machine.name FROM machine, mcmap
+        WHERE machine.mach_id=mcmap.mach_id AND mcmap.clu_id=:iid;
     EXEC SQL OPEN csr202;
     while(1) {
        EXEC SQL FETCH csr202 INTO :name;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break; 
 
        strtrim(name);
 
@@ -84,14 +74,10 @@ int id;
 
     EXEC SQL DECLARE csr234 CURSOR FOR
       SELECT name FROM hostalias WHERE mach_id=:iid;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     EXEC SQL OPEN csr234;
     while(1) {
        EXEC SQL FETCH csr234 INTO :name;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break; 
 
        strtrim(name);
 
@@ -112,14 +98,10 @@ int id;
 
     EXEC SQL DECLARE csr235 CURSOR FOR
       SELECT name FROM printcap WHERE mach_id=:iid;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     EXEC SQL OPEN csr235;
     while(1) {
        EXEC SQL FETCH csr235 INTO :name;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break; 
 
        strtrim(name);
 
@@ -140,14 +122,10 @@ int id;
 
     EXEC SQL DECLARE csr236 CURSOR FOR
       SELECT name FROM printcap WHERE quotaserver=:iid;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     EXEC SQL OPEN csr236;
     while(1) {
        EXEC SQL FETCH csr236 INTO :name;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break; 
 
        strtrim(name);
 
@@ -164,7 +142,7 @@ user_check(id, u, hint)
      int hint;
 {
   u->comment=maybe_fixup_unref_string(u->comment, id, u->login, "users",
-                                     "comment", "users_id");
+                                     "comments", "users_id");
 
   u->modby=maybe_fixup_modby(u->modby, id, u->login, "users",
                             "modby", "users_id");
@@ -213,7 +191,7 @@ maybe_fixup_unref_string(sid, oid, oname, table, field, idfield)
     sprintf(stmt_buf, "UPDATE %s SET %s = %d WHERE %s = %d",
            table, field, (sid<0)?-ret:ret, idfield, oid);
     EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
-    EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
+    rowcount = sqlca.sqlerrd[2];
     if (rowcount == 1)
       printf("Fixed\n");
     else
@@ -245,7 +223,7 @@ maybe_fixup_modby(sid, oid, oname, table, field, idfield)
        sprintf(stmt_buf, "UPDATE %s SET %s = %d WHERE %s=%d",
                table, field, 0, idfield, oid);
        EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
-       EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
+       rowcount = sqlca.sqlerrd[2];
        if (rowcount == 1)
          printf("Fixed\n");
        else
@@ -289,7 +267,7 @@ maybe_fixup_unref_string2(table, field, cursor, sid)
     sprintf(stmt_buf, "UPDATE %s SET %s = %d WHERE CURRENT OF %s",
            table, field, (sid<0)?-ret:ret, cursor);
     EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
-    EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
+    rowcount = sqlca.sqlerrd[2];
     if (rowcount == 1)
       printf("Fixed\n");
     else
@@ -315,7 +293,7 @@ maybe_fixup_modby2(table, field, cursor, id)
        sprintf(stmt_buf, "UPDATE %s SET %s = %d WHERE CURRENT OF %s",
                table, field, 0, cursor);
        EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
-       EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
+       rowcount = sqlca.sqlerrd[2];
        if (rowcount == 1)
          printf("Fixed\n");
        else
@@ -379,7 +357,7 @@ int id;
     EXEC SQL END DECLARE SECTION; 
 
     EXEC SQL UPDATE users SET potype='NONE' WHERE users.users_id = :iid;
-    EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
+    rowcount = sqlca.sqlerrd[2];
     if (rowcount > 0)
       printf("%d entr%s removed\n", rowcount, rowcount==1?"y":"ies");
     else
@@ -395,7 +373,7 @@ int id, sid;
     EXEC SQL END DECLARE SECTION; 
 
     EXEC SQL UPDATE users SET box_id=:isid WHERE users.users_id = :iid;
-    EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
+    rowcount = sqlca.sqlerrd[2];
     if (rowcount > 0)
       printf("%d entr%s updated\n", rowcount, rowcount==1?"y":"ies");
     else
@@ -417,7 +395,7 @@ int hint;
            EXEC SQL END DECLARE SECTION; 
 
            EXEC SQL UPDATE machine SET snet_id=0 WHERE mach_id = :iid;
-           EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
+           rowcount = sqlca.sqlerrd[2];
            if (rowcount > 0)
              printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
            else
@@ -514,7 +492,7 @@ struct subnet *s;
 
     EXEC SQL UPDATE subnet SET owner_type='NONE', owner_id=0
       WHERE snet_id = :id;
-    EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
+    rowcount = sqlca.sqlerrd[2];
     if (rowcount > 0)
       printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
     else
@@ -531,7 +509,7 @@ struct machine *m;
 
     EXEC SQL UPDATE machine SET owner_type='NONE', owner_id=0
       WHERE mach_id = :id;
-    EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
+    rowcount = sqlca.sqlerrd[2];
     if (rowcount > 0)
       printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
     else
@@ -544,7 +522,7 @@ int id;
 struct cluster *c;
 int hint;
 {
-    c->modby=maybe_fixup_modby(c->modby, id, c->name, "cluster",
+    c->modby=maybe_fixup_modby(c->modby, id, c->name, "clusters",
                               "modby", "clu_id");
 }
 
@@ -561,14 +539,10 @@ int id;
     EXEC SQL DECLARE csr203 CURSOR FOR
        SELECT serv_label, serv_cluster FROM svc
            WHERE clu_id = :iid;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     EXEC SQL OPEN csr203;
     while(1) {
        EXEC SQL FETCH csr203 INTO :label, :data;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       }
+       if (sqlca.sqlcode != 0) break;
 
        strtrim(label);
        strtrim(data);
@@ -624,7 +598,7 @@ int id;
 
     EXEC SQL UPDATE list SET acl_id = :iid, acl_type='LIST'
        WHERE list_id = :iid;
-    EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
+    rowcount = sqlca.sqlerrd[2];
     if (rowcount > 0)
       printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
     else
@@ -644,14 +618,10 @@ int id;
     EXEC SQL DECLARE csr204 CURSOR FOR
        SELECT member_type, member_id FROM imembers
            WHERE list_id = :iid AND direct=1;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     EXEC SQL OPEN csr204;
     while(1) {
        EXEC SQL FETCH csr204 INTO :mtype, :mid;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break; 
 
        strtrim(mtype);
        found = 0;
@@ -678,14 +648,10 @@ int id;
     EXEC SQL DECLARE csr205 CURSOR FOR
       SELECT list_id FROM imembers
        WHERE member_id = :iid AND member_type='USER' AND direct=1;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     EXEC SQL OPEN csr205;
     while(1) {
        EXEC SQL FETCH csr205 INTO :lid;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       }       
+       if (sqlca.sqlcode != 0) break;  
        
        found = 0;
        printf("List %s has non-existant user member, id %d\n",
@@ -706,14 +672,10 @@ int id;
     EXEC SQL DECLARE csr206 CURSOR FOR
        SELECT list_id FROM imembers
            WHERE member_id = :iid AND member_type='LIST' AND direct=1;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     EXEC SQL OPEN csr206;
     while(1) {
        EXEC SQL FETCH csr206 INTO :lid;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break; 
 
        found = 0;
        printf("List %s has non-existant list member, id %d\n",
@@ -734,14 +696,10 @@ int id;
     EXEC SQL DECLARE csr207 CURSOR FOR
        SELECT list_id FROM imembers
            WHERE member_id = :iid AND member_type='STRING' AND direct=1;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     EXEC SQL OPEN csr207;
     while(1) {
        EXEC SQL FETCH csr207 INTO :lid;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break; 
        
        found = 0;
        printf("List %s has non-existant string member, id %d\n",
@@ -763,14 +721,10 @@ int id;
     EXEC SQL DECLARE csr208 CURSOR FOR
        SELECT list_id FROM imembers
            WHERE member_id = :iid AND member_type='KERBEROS' AND direct=1;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     EXEC SQL OPEN csr208;
     while(1) {
        EXEC SQL FETCH csr208 INTO :lid;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break; 
 
        found = 0;
        printf("List %s has non-existant kerberos member, id %d\n",
@@ -792,7 +746,7 @@ EXEC SQL END DECLARE SECTION;
 
     EXEC SQL DELETE FROM imembers WHERE member_type='USER' AND
        member_id = :id AND direct = 1;
-    EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
+    rowcount = sqlca.sqlerrd[2];
     if (rowcount > 0)
       printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
     else
@@ -811,7 +765,7 @@ EXEC SQL END DECLARE SECTION;
 
     EXEC SQL DELETE FROM imembers WHERE member_type='LIST' AND
        member_id = :id AND direct=1;
-    EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
+    rowcount = sqlca.sqlerrd[2];
     if (rowcount > 0)
       printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
     else
@@ -830,7 +784,7 @@ EXEC SQL END DECLARE SECTION;
 
     EXEC SQL DELETE FROM imembers WHERE member_type='STRING' AND
        member_id = :id AND direct=1;
-    EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
+    rowcount = sqlca.sqlerrd[2];
     if (rowcount > 0)
       printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
     else
@@ -850,7 +804,7 @@ EXEC SQL END DECLARE SECTION;
 
     EXEC SQL DELETE FROM imembers WHERE member_type='KERBEROS' AND
        member_id = :id AND direct=1;
-    EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
+    rowcount = sqlca.sqlerrd[2];
     if (rowcount > 0)
       printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
     else
@@ -872,14 +826,10 @@ EXEC SQL END DECLARE SECTION;
     EXEC SQL DECLARE csr209 CURSOR FOR
        SELECT service FROM serverhosts
            WHERE mach_id = :id;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     EXEC SQL OPEN csr209;
     while(1) {
        EXEC SQL FETCH csr209 INTO :name;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break; 
 
        found = 0;
        printf("ServerHost entry for service %s non-existant host %d\n",
@@ -899,7 +849,7 @@ EXEC SQL END DECLARE SECTION;
     EXEC SQL END DECLARE SECTION; 
 
     EXEC SQL DELETE FROM serverhosts WHERE mach_id = :id;
-    EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
+    rowcount = sqlca.sqlerrd[2];
     if (rowcount > 0)
       printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
     else
@@ -942,7 +892,7 @@ int hint;
        printf("Filesys %s with bad machine %d\n", f->name, f->mach_id);
        if (single_fix("Fix", 0)) {
            EXEC SQL UPDATE filesys SET mach_id = 0 WHERE filsys_id = :id;
-           EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
+           rowcount = sqlca.sqlerrd[2];
            if (rowcount > 0)
              printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
            else
@@ -979,7 +929,7 @@ int hint;
                  id2 = f->filsys_id;
                  id3 = f->mach_id;
                  EXEC SQL UPDATE filesys SET phys_id = :id1 WHERE filsys_id = :id2;
-                 EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
+                 rowcount = sqlca.sqlerrd[2];
                  if (rowcount > 0)
                    printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
                  else
@@ -1005,9 +955,9 @@ int hint;
                        }
                        EXEC SQL INSERT INTO mfsphys (mfsphys_id, mach_id,
                            device, dir, status, allocated, size, modtime,
-                           modby, modwith) VALUES (:id1, :id3, '???', :dir,
-                           0, 0, 0, 'now', 0, 'dbck');
-                       EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
+                           modby, modwith) VALUES (:id1, :id3, '\?\?\?', :dir,
+                           0, 0, 0, SYSDATE, 0, 'dbck');
+                       rowcount = sqlca.sqlerrd[2];
                        if (rowcount > 0)
                          printf("%d entr%s created\n", rowcount,
                                 rowcount==1?"y":"ies");
@@ -1027,7 +977,7 @@ int hint;
                        }
                        EXEC SQL UPDATE filesys SET phys_id = :id1
                            WHERE filsys_id = :id2;
-                       EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
+                       rowcount = sqlca.sqlerrd[2];
                        if (rowcount > 0)
                          printf("%d filesys entr%s fixed\n", rowcount,
                                 rowcount==1?"y":"ies");
@@ -1068,14 +1018,10 @@ EXEC SQL END DECLARE SECTION;
     EXEC SQL DECLARE csr210 CURSOR FOR
        SELECT filsys_id FROM fsgroup
            WHERE group_id = :id;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     EXEC SQL OPEN csr210;
     while(1) {
        EXEC SQL FETCH csr210 INTO :id1;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break; 
 
        found = 0;
        if (f = (struct filesys *) hash_lookup(filesys, id1))
@@ -1112,7 +1058,7 @@ struct filesys *f;
        t = "MUL";
        break;
     default:
-       t = "???";
+       t = "\?\?\?";
     }
     printf("FSGroup %s has type %s instead of FSGROUP\n", f->name, t);
     return(0);
@@ -1126,7 +1072,7 @@ struct filesys *f;
     EXEC SQL END DECLARE SECTION; 
 
     EXEC SQL UPDATE filesys SET type='FSGROUP' WHERE filsys_id = :id;
-    EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
+    rowcount = sqlca.sqlerrd[2];
     if (rowcount > 0)
       printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
     else
@@ -1147,14 +1093,10 @@ EXEC SQL END DECLARE SECTION;
     EXEC SQL DECLARE csr211 CURSOR FOR
        SELECT group_id FROM fsgroup
            WHERE filsys_id = :id;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     EXEC SQL OPEN csr211;
     while(1) {
        EXEC SQL FETCH csr211 INTO :id1;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break; 
 
        found = 0;
        if (f = (struct filesys *) hash_lookup(filesys, id1))
@@ -1178,14 +1120,10 @@ EXEC SQL END DECLARE SECTION;
     EXEC SQL DECLARE csr212 CURSOR FOR
        SELECT filsys_id FROM quota
            WHERE entity_id = :id AND type='USER';
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     EXEC SQL OPEN csr212;
     while(1) {
        EXEC SQL FETCH csr212 INTO :id1;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break; 
 
        found = 0;
        printf("Quota on fs %d for non-existant user %d\n", id1, id);
@@ -1206,14 +1144,10 @@ EXEC SQL END DECLARE SECTION;
     EXEC SQL DECLARE csr213 CURSOR FOR
        SELECT filsys_id FROM quota 
            WHERE entity_id = :id AND type='GROUP';
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     EXEC SQL OPEN csr213;
     while(1) {
        EXEC SQL FETCH csr213 INTO :id1;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       }
+       if (sqlca.sqlcode != 0) break;
  
        found = 0;
        printf("Quota on fs %d for non-existant list %d\n", id1, id);
@@ -1234,7 +1168,7 @@ EXEC SQL END DECLARE SECTION;
     id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
     EXEC SQL DELETE FROM quota 
        WHERE entity_id = :id AND type = 'USER';
-    EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
+    rowcount = sqlca.sqlerrd[2];
     if (rowcount > 0)
       printf("%d entr%s deleted\n",rowcount, rowcount==1?"y":"ies");
     else
@@ -1253,7 +1187,7 @@ EXEC SQL END DECLARE SECTION;
 
     id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
     EXEC SQL DELETE FROM quota WHERE entity_id = :id AND type='GROUP';
-    EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
+    rowcount = sqlca.sqlerrd[2];
     if (rowcount > 0)
       printf("%d entr%s deleted\n",rowcount, rowcount==1?"y":"ies");
     else
@@ -1274,14 +1208,10 @@ EXEC SQL END DECLARE SECTION;
     EXEC SQL DECLARE csr214 CURSOR FOR
        SELECT entity_id, type FROM quota
            WHERE filsys_id = :id;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     EXEC SQL OPEN csr214;
     while(1) {
        EXEC SQL FETCH csr214 INTO :id1, :type;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break; 
        
        found = 0;
        printf("Quota for %s %d on non-existant filesys %d\n", type, id1, id);
@@ -1311,14 +1241,10 @@ EXEC SQL END DECLARE SECTION;
     EXEC SQL DECLARE csr215 CURSOR FOR
        SELECT entity_id, type FROM quota
            WHERE filsys_id = :id;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     EXEC SQL OPEN csr215;
     while(1) {
        EXEC SQL FETCH csr215 INTO :id1, :type;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break; 
 
        found = 0;
        printf("Quota for %s %d on filesys %s has wrong phys_id %d\n",
@@ -1340,7 +1266,7 @@ EXEC SQL END DECLARE SECTION;
     id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
     EXEC SQL UPDATE quota SET phys_id = :id1 
        WHERE filsys_id = :id AND phys_id != :id1;
-    EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
+    rowcount = sqlca.sqlerrd[2];
     if (rowcount > 0)
       printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
     else
@@ -1361,14 +1287,10 @@ EXEC SQL END DECLARE SECTION;
     EXEC SQL DECLARE csr216 CURSOR FOR
        SELECT name FROM servers
            WHERE acl_type='USER' and acl_id = :id;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     EXEC SQL OPEN csr216;
     while(1) {
        EXEC SQL FETCH csr216 INTO :name;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break; 
        
        strtrim(name);
        printf("Service %s has acl non-existant user %d\n", name, id);
@@ -1391,14 +1313,10 @@ EXEC SQL END DECLARE SECTION;
     EXEC SQL DECLARE csr217 CURSOR FOR
        SELECT name FROM servers
            WHERE acl_type='LIST' AND acl_id = :id;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     EXEC SQL OPEN csr217;
     while(1) {
        EXEC SQL FETCH csr217 INTO :name;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break; 
 
        strtrim(name);
        printf("Service %s has acl non-existant list %d\n", name, id);
@@ -1419,7 +1337,7 @@ EXEC SQL END DECLARE SECTION;
 
     EXEC SQL UPDATE servers SET acl_id=0 WHERE acl_id = :id AND
        acl_type='USER';
-    EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
+    rowcount = sqlca.sqlerrd[2];
     if (rowcount > 0)
       printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
     else
@@ -1438,7 +1356,7 @@ EXEC SQL END DECLARE SECTION;
 
     EXEC SQL UPDATE servers SET acl_id=0 WHERE acl_id = :id AND
        acl_type='LIST';
-    EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
+    rowcount = sqlca.sqlerrd[2];
     if (rowcount > 0)
       printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
     else
@@ -1461,14 +1379,10 @@ EXEC SQL END DECLARE SECTION;
     EXEC SQL DECLARE csr218 CURSOR FOR
        SELECT string_id FROM krbmap
            WHERE users_id = :id ;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     EXEC SQL OPEN csr218;
     while(1) {
        EXEC SQL FETCH csr218 INTO :id1;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break; 
 
        if (s = ((struct string *)hash_lookup(strings, id1)))
            ss = s->name;
@@ -1497,19 +1411,15 @@ EXEC SQL END DECLARE SECTION;
     EXEC SQL DECLARE csr219 CURSOR FOR
        SELECT users_id FROM krbmap
            WHERE string_id = :id;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     EXEC SQL OPEN csr219;
     while(1) {
        EXEC SQL FETCH csr219 INTO :id1;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break; 
 
        if (u = ((struct user *)hash_lookup(users, id1)))
            s = u->login;
        else
-           s = "[???]";
+           s = "[\?\?\?]";
        found = 0;
        printf("Kerberos map for user %s (%d) to non-existant string %d\n",
               s, id1, id);
@@ -1532,14 +1442,10 @@ EXEC SQL END DECLARE SECTION;
     EXEC SQL DECLARE csr220 CURSOR FOR
        SELECT name FROM palladium
            WHERE mach_id = :id;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     EXEC SQL OPEN csr220;
     while(1) {
        EXEC SQL FETCH csr220 INTO :name;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break; 
 
        strtrim(name);
         printf("Palladium server/supervisor %s is on non-existant machine %d\n",
@@ -1582,15 +1488,10 @@ phase2()
     sq2 = sq_create();
     EXEC SQL DECLARE csr221 CURSOR FOR
       SELECT mach_id, clu_id FROM mcmap;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     EXEC SQL OPEN csr221;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     while(1) {
        EXEC SQL FETCH csr221 INTO :id1, :id2;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break; 
 
        if (!(m = (struct machine *)hash_lookup(machines, id1)))
            sq_save_unique_data(sq1, id1);
@@ -1606,14 +1507,10 @@ phase2()
     sq1 = sq_create();
     EXEC SQL DECLARE csr222 CURSOR FOR
       SELECT clu_id FROM svc;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     EXEC SQL OPEN csr222;
     while(1) {
        EXEC SQL FETCH csr222 INTO :id1;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break; 
 
        if (!hash_lookup(clusters, id1))
          sq_save_unique_data(sq1, id1);
@@ -1633,15 +1530,11 @@ phase2()
 
     EXEC SQL DECLARE csr223 CURSOR FOR
       SELECT list_id, member_type, member_id, ref_count, direct
-      FROM imembers FOR DEFERRED UPDATE OF member_id;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
+      FROM imembers FOR UPDATE OF member_id;
     EXEC SQL OPEN csr223;
     while(1) {
        EXEC SQL FETCH csr223 INTO :id1, :type, :id2, :id3, :id4;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break; 
 
        if ((l = (struct list *) hash_lookup(lists, id1)) == NULL)
          sq_save_unique_data(sq1, id1);
@@ -1668,15 +1561,11 @@ phase2()
     sq2 = sq_create();
     EXEC SQL DECLARE csr224 CURSOR FOR
       SELECT name, acl_type, acl_id, modby FROM servers
-      FOR DEFERRED UPDATE of modby;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
+      FOR UPDATE of modby;
     EXEC SQL OPEN csr224;
     while(1) {
        EXEC SQL FETCH csr224 INTO :name, :type, :id1, :id2;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break; 
 
        maybe_fixup_modby2("servers","modby","csr224",id2);
        strtrim(type);
@@ -1694,15 +1583,11 @@ phase2()
     sq = sq_create();
     EXEC SQL DECLARE csr225 CURSOR FOR
       SELECT mach_id, modby FROM serverhosts
-      FOR DEFERRED UPDATE OF modby;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
+      FOR UPDATE OF modby;
     EXEC SQL OPEN csr225;
     while(1) {
        EXEC SQL FETCH csr225 INTO :id1, :id2;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break; 
 
        maybe_fixup_modby2("serverhosts", "modby", "csr225", id2);
        if (!hash_lookup(machines, id1))
@@ -1723,14 +1608,10 @@ phase2()
     sq3 = sq_create();
     EXEC SQL DECLARE csr226 CURSOR FOR
       SELECT group_id, filsys_id FROM fsgroup;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     EXEC SQL OPEN csr226;
     while(1) {
        EXEC SQL FETCH csr226 INTO :id1, :id2;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break; 
 
        if (!(f = (struct filesys *) hash_lookup(filesys, id1)))
          sq_save_data(sq1, id1);
@@ -1748,15 +1629,11 @@ phase2()
     sq4 = sq_create();
     EXEC SQL DECLARE csr227 CURSOR FOR
       SELECT entity_id, type, filsys_id, phys_id, quota, modby
-      FROM quota FOR DEFERRED UPDATE OF modby;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
+      FROM quota FOR UPDATE OF modby;
     EXEC SQL OPEN csr227;
     while(1) {
        EXEC SQL FETCH csr227 INTO :id1, :type, :id2, :id3, :id4, :id5;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break; 
 
        maybe_fixup_modby2("quota", "modby", "csr227", id5);
        if (type[0] == 'U' && id1 != 0 && !hash_lookup(users, id1))
@@ -1783,15 +1660,11 @@ phase2()
     dprintf("Checking hostaccess...\n");
     EXEC SQL DECLARE csr228 CURSOR FOR
       SELECT mach_id, acl_type, acl_id, modby FROM hostaccess
-      FOR DEFERRED UPDATE OF modby;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
+      FOR UPDATE OF modby;
     EXEC SQL OPEN csr228;
     while(1) {
        EXEC SQL FETCH csr228 INTO :id1, :type, :id2, :id3;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break; 
 
        maybe_fixup_modby2("hostaccess", "modby", "csr228", id3);
        strtrim(type);
@@ -1813,15 +1686,11 @@ phase2()
     sq1 = sq_create();
     EXEC SQL DECLARE csr229 CURSOR FOR
       SELECT mach_id, modby FROM palladium
-      FOR DEFERRED UPDATE OF modby;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
+      FOR UPDATE OF modby;
     EXEC SQL OPEN csr229;
     while(1) {
        EXEC SQL FETCH csr229 INTO :id1, :id2;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break; 
 
        maybe_fixup_modby2("palladium", "modby", "csr229", id2);
        if (!hash_lookup(machines, id1)) {
@@ -1836,15 +1705,11 @@ phase2()
     sq2 = sq_create();
     EXEC SQL DECLARE csr230 CURSOR FOR
       SELECT users_id, string_id FROM krbmap
-      FOR DEFERRED UPDATE OF string_id;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
+      FOR UPDATE OF string_id;
     EXEC SQL OPEN csr230;
     while(1) {
        EXEC SQL FETCH csr230 INTO :id1, :id2;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break; 
 
        if (!hash_lookup(users, id1))
          sq_save_unique_data(sq1, id1);
@@ -1858,14 +1723,10 @@ phase2()
     dprintf("Checking capacls...\n");
     EXEC SQL DECLARE csr231 CURSOR FOR
       SELECT list_id, tag FROM capacls;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     EXEC SQL OPEN csr231;
     while(1) {
        EXEC SQL FETCH csr231 INTO :id1, :name;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break; 
 
        if (!hash_lookup(lists, id1)) {
            printf("Capacl for %s is non-existant list %d\n", name, id1);
@@ -1878,14 +1739,10 @@ phase2()
     sq1 = sq_create();
     EXEC SQL DECLARE csr232 CURSOR FOR
       SELECT mach_id FROM hostalias;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     EXEC SQL OPEN csr232;
     while(1) {
        EXEC SQL FETCH csr232 INTO :id1;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break; 
 
        if (!hash_lookup(machines, id1))
          sq_save_unique_data(sq1, id1);
@@ -1898,14 +1755,10 @@ phase2()
     sq2 = sq_create();
     EXEC SQL DECLARE csr233 CURSOR FOR
       SELECT mach_id, quotaserver, modby FROM printcap;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     EXEC SQL OPEN csr233;
     while(1) {
        EXEC SQL FETCH csr233 INTO :id1, :id2, :id3;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break; 
 
        maybe_fixup_modby2("printcap", "modby", "csr233", id3);
        if (!hash_lookup(machines, id1))
index 78b6a7e5c442697ca89fa1f78a63b79c55c5c000..e91199ad4fb1c8ba1efcf06d4a0d2b2228698e33 100644 (file)
@@ -78,10 +78,7 @@ phase3()
        hash_step(lists, empty_list_check, NULL);
     }
 
-    EXEC SQL SET autocommit on;
     dprintf("Checking strings...\n");
     hash_step(strings, unref_string_check, NULL);
-    EXEC SQL SET autocommit off;
-
 }
 
index 011cc126ee64cce2a85d2a203ec65a86c4fd3aa9..b236853f03d1cd7a3b1c8f1f47d923969fe05fa0 100644 (file)
@@ -12,6 +12,7 @@ EXEC SQL INCLUDE sqlca;
 
 static char phase4_qc_rcsid[] = "$Header$";
 
+EXEC SQL WHENEVER SQLERROR DO dbmserr();
 
 count_boxes(id, u, boxes)
 int id;
@@ -53,7 +54,7 @@ struct hash *counts;
        if (single_fix("Update", 1)) {
            EXEC SQL UPDATE serverhosts SET value1 = :cnt
                WHERE service='POP' AND mach_id = :id;
-           EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
+           rowcount = sqlca.sqlerrd[2];
            if (rowcount > 0)
              printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
            else
@@ -82,7 +83,7 @@ struct nfsphys *n;
        if (single_fix("Update", 1)) {
            EXEC SQL UPDATE nfsphys SET allocated = :val 
                WHERE nfsphys_id = :id;
-           EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
+           rowcount = sqlca.sqlerrd[2];
            if (rowcount > 0)
              printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
            else
@@ -108,14 +109,10 @@ phase4()
     EXEC SQL DECLARE csr401 CURSOR FOR
        SELECT mach_id, value1 FROM serverhosts
            WHERE service='POP';
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     EXEC SQL OPEN csr401;
     while(1) {
        EXEC SQL FETCH csr401 INTO :id, :cnt;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break;
        
        if( hash_store(boxes, id, 1) == -1 ) {
            out_of_mem("storing poboxes");
@@ -150,15 +147,11 @@ count_only_setup()
        SELECT users_id, login, last, first, status, 
               potype, pop_id, box_id FROM users
            WHERE potype='POP';
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     EXEC SQL OPEN csr402;
     while(1) {
        EXEC SQL FETCH csr402 INTO :id, :name, :last, :first, :status, 
            :buf, :id2, :id3;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break;
 
        u = (struct user *) malloc(sizeof(struct user));
        if (u == NULL)
@@ -189,14 +182,10 @@ count_only_setup()
     machines = create_hash(20000);
     EXEC SQL DECLARE csr403 CURSOR FOR
        SELECT mach_id, name FROM machine;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     EXEC SQL OPEN csr403;
     while(1) {
        EXEC SQL FETCH csr403 INTO :id, :name;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break;
 
        m = (struct machine *) malloc(sizeof(struct machine));
        if (m == NULL)
@@ -213,14 +202,10 @@ count_only_setup()
     nfsphys = create_hash(500);
     EXEC SQL DECLARE csr404 CURSOR FOR
        SELECT nfsphys_id, dir, mach_id, allocated FROM nfsphys;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     EXEC SQL OPEN csr404;
     while(1) {
        EXEC SQL FETCH csr404 INTO :id, :name, :id2, :id3;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break;
 
        n = (struct nfsphys *) malloc(sizeof(struct nfsphys));
        if (n == NULL)
@@ -239,14 +224,10 @@ count_only_setup()
     dprintf("Counting quotas...\n");
     EXEC SQL DECLARE csr405 CURSOR FOR
        SELECT phys_id, quota FROM quota;
-    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     EXEC SQL OPEN csr405;
     while(1) {
        EXEC SQL FETCH csr405 INTO :id, :id2;
-       if (sqlca.sqlcode != 0) {
-         ingerr(&sqlca.sqlcode);
-         break;
-       } 
+       if (sqlca.sqlcode != 0) break;
        
         if (n = (struct nfsphys  *) hash_lookup(nfsphys, id)) {
            n->count += id2;
This page took 0.139895 seconds and 5 git commands to generate.