]> andersk Git - moira.git/blob - dbck/phase2.dc
always check error status of every query
[moira.git] / dbck / phase2.dc
1 /* $Header$
2  *
3  *  (c) Copyright 1988 by the Massachusetts Institute of Technology.
4  *  For copying and distribution information, please see the file
5  *  <mit-copyright.h>.
6  */
7
8 #include <mit-copyright.h>
9 #include <stdio.h>
10 #include <moira.h>
11 #include "dbck.h"
12 EXEC SQL INCLUDE sqlca;
13
14 static char phase2_qc_rcsid[] = "$Header$";
15
16
17 show_mcm_mach(id)
18 int id;
19 {
20     EXEC SQL BEGIN DECLARE SECTION; 
21     int iid = id, found = 1;
22     char name[33];
23     EXEC SQL END DECLARE SECTION; 
24
25     EXEC SQL DECLARE csr201 CURSOR FOR
26       SELECT cluster.name FROM cluster, mcmap
27         WHERE cluster.clu_id=mcmap.clu_id AND mcmap.mach_id = :iid;
28     EXEC SQL OPEN csr201;
29     while(1) {
30         EXEC SQL FETCH csr201 INTO :name;
31         if (sqlca.sqlcode != 0) {
32           ingerr(&sqlca.sqlcode);
33           break;
34         } 
35
36         strtrim(name);
37         found = 0;
38         printf("Clusqter %s, non-existant machine %d in cluster map\n", name, id);
39     }
40     EXEC SQL CLOSE csr201; 
41     return(found);
42 }
43
44 show_mcm_clu(id)
45 int id;
46 {
47     EXEC SQL BEGIN DECLARE SECTION; 
48     int iid = id, found = 1;
49     char name[33];
50     EXEC SQL END DECLARE SECTION; 
51
52     EXEC SQL DECLARE csr202 CURSOR FOR
53         SELECT machine.name FROM machine, mcmap
54             WHERE machine.mach_id=mcmap.mach_id AND mcmap.clu_id=:iid;
55     EXEC SQL OPEN csr202;
56     while(1) {
57         EXEC SQL FETCH csr202 INTO :name;
58         if (sqlca.sqlcode != 0) {
59           ingerr(&sqlca.sqlcode);
60           break;
61         } 
62
63         strtrim(name);
64         found = 0;
65         printf("Machine %s, non-existant cluster %d in cluster map\n", name, id);
66     }
67     EXEC SQL CLOSE csr202; 
68     return(found);
69 }
70
71 pobox_check(id, u, hint)
72 int id;
73 struct user *u;
74 int hint;
75 {
76     switch (u->potype) {
77     case 'P':
78         if (!hash_lookup(machines, u->pobox_id)) {
79             printf("User %s(%s) has P.O.Box on non-existant machine %d\n",
80                    u->login, u->fullname, u->pobox_id);
81             if (single_fix("Delete", 0)) {
82                 remove_pobox(u->users_id);
83                 u->potype = 'N';
84             }
85         }
86         break;
87     case 'S':
88         if (!string_check(u->pobox_id)) {
89             printf("User %s(%s) has P.O.Box with non-existant string %d\n",
90                    u->login, u->fullname, u->pobox_id);
91             if (single_fix("Delete", 0)) {
92                 remove_pobox(u->users_id);
93                 u->potype = 'N';
94             }
95         }
96         break;
97     default:
98         ;
99     }
100 }
101
102
103 remove_pobox(id)
104 int id;
105 {
106     EXEC SQL BEGIN DECLARE SECTION; 
107     int rowcount, iid = id;
108     EXEC SQL END DECLARE SECTION; 
109
110     EXEC SQL UPDATE users SET potype='NONE' WHERE users.users_id = :iid;
111     EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
112     if (rowcount > 0)
113       printf("%d entr%s removed\n", rowcount, rowcount==1?"y":"ies");
114     else
115       printf("Not removed\n");
116     modified("users");
117 }
118
119 show_svc(id)
120 int id;
121 {
122     EXEC SQL BEGIN DECLARE SECTION; 
123     int iid = id, found = 1;
124     char label[17], data[33];
125     EXEC SQL END DECLARE SECTION; 
126
127     EXEC SQL DECLARE csr203 CURSOR FOR
128         SELECT serv_label, serv_cluster FROM svc
129             WHERE clu_id = :iid;
130     EXEC SQL OPEN csr203;
131     while(1) {
132         EXEC SQL FETCH csr203 INTO :label, :data;
133         if (sqlca.sqlcode != 0) {
134           ingerr(&sqlca.sqlcode);
135           break;
136         }
137
138         strtrim(label);
139         strtrim(data);
140         found = 0;
141         printf("Cluster data [%s] %s for non-existant cluster %d\n",
142                label, data, id);
143     }
144     EXEC SQL CLOSE csr203; 
145     return(found);
146 }
147
148 list_check(id, l, hint)
149 int id;
150 struct list *l;
151 int hint;
152 {
153     switch (l->acl_type) {
154     case 'L':
155         if (!hash_lookup(lists, l->acl_id)) {
156             printf("List %s has bad LIST acl %d\n", l->name, l->acl_id);
157             if (single_fix("Patch", 1)) {
158                 fix_list_acl(l->list_id);
159             }
160         }
161         break;
162     case 'U':
163         if (!hash_lookup(users, l->acl_id)) {
164             printf("List %s has bad USER acl %d\n", l->name, l->acl_id);
165             if (single_fix("Patch", 1)) {
166                 fix_list_acl(l->list_id);
167             }
168         }
169         break;
170     }
171 }
172
173 fix_list_acl(id)
174 int id;
175 {
176     EXEC SQL BEGIN DECLARE SECTION; 
177     int rowcount, iid = id;
178     EXEC SQL END DECLARE SECTION; 
179
180     EXEC SQL UPDATE list SET acl_id = :iid, acl_type='LIST'
181         WHERE list_id = :iid;
182     EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
183     if (rowcount > 0)
184       printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
185     else
186       printf("Not fixed\n");
187     modified("list");
188 }
189
190
191 show_member_list(id)
192 int id;
193 {
194     EXEC SQL BEGIN DECLARE SECTION; 
195     int mid, iid = id, found = 1;
196     char mtype[9], *name = "";
197     EXEC SQL END DECLARE SECTION;
198
199     EXEC SQL DECLARE csr204 CURSOR FOR
200         SELECT member_type, member_id FROM imembers
201             WHERE list_id = :iid AND direct=1;
202     EXEC SQL OPEN csr204;
203     while(1) {
204         EXEC SQL FETCH csr204 INTO :mtype, :mid;
205         if (sqlca.sqlcode != 0) {
206           ingerr(&sqlca.sqlcode);
207           break;
208         } 
209
210         strtrim(mtype);
211         found = 0;
212         if (mtype[0] == 'L')
213             name = ((struct list *) hash_lookup(lists, mid))->name;
214         else if (mtype[0] == 'U')
215             name = ((struct user *) hash_lookup(users, mid))->login;
216         else if (mtype[0] == 'S' || mtype[0] == 'K')
217             name = ((struct string *) hash_lookup(strings, mid))->name;
218         printf("Non-existant list %d has member %s %s\n", iid, mtype, name);
219     }
220     EXEC SQL CLOSE csr204; 
221     return(found);
222 }
223
224 show_mem_user(id)
225 int id;
226 {
227     EXEC SQL BEGIN DECLARE SECTION; 
228     int lid, iid = id, found = 1;
229     char name[33];
230     EXEC SQL END DECLARE SECTION; 
231
232     EXEC SQL DECLARE csr205 CURSOR FOR
233       SELECT list_id FROM imembers
234         WHERE member_id = :iid AND member_type='USER' AND direct=1;
235     EXEC SQL OPEN csr205;
236     while(1) {
237         EXEC SQL FETCH csr205 INTO :lid;
238         if (sqlca.sqlcode != 0) {
239           ingerr(&sqlca.sqlcode);
240           break;
241         }       
242         
243         found = 0;
244         printf("List %s has non-existant user member, id %d\n",
245                ((struct list *)hash_lookup(lists, lid))->name, iid);
246     }
247     EXEC SQL CLOSE csr205;
248     return(found);
249 }
250
251 show_mem_list(id)
252 int id;
253 {
254     EXEC SQL BEGIN DECLARE SECTION; 
255     int lid, iid = id, found = 1;
256     char name[33];
257     EXEC SQL END DECLARE SECTION; 
258
259     EXEC SQL DECLARE csr206 CURSOR FOR
260         SELECT list_id FROM imembers
261             WHERE member_id = :iid AND member_type='LIST' AND direct=1;
262     EXEC SQL OPEN csr206;
263     while(1) {
264         EXEC SQL FETCH csr206 INTO :lid;
265         if (sqlca.sqlcode != 0) {
266           ingerr(&sqlca.sqlcode);
267           break;
268         } 
269
270         found = 0;
271         printf("List %s has non-existant list member, id %d\n",
272                ((struct list *)hash_lookup(lists, lid))->name, iid);
273     }
274     EXEC SQL CLOSE csr206; 
275     return(found);
276 }
277
278 show_mem_str(id)
279 int id;
280 {
281     EXEC SQL BEGIN DECLARE SECTION; 
282     int lid, iid = id, found = 1;
283     char name[33];
284     EXEC SQL END DECLARE SECTION; 
285
286     EXEC SQL DECLARE csr207 CURSOR FOR
287         SELECT list_id FROM imembers
288             WHERE member_id = :iid AND member_type='STRING' AND direct=1;
289     EXEC SQL OPEN csr207;
290     while(1) {
291         EXEC SQL FETCH csr207 INTO :lid;
292         if (sqlca.sqlcode != 0) {
293           ingerr(&sqlca.sqlcode);
294           break;
295         } 
296         
297         found = 0;
298         printf("List %s has non-existant string member, id %d\n",
299                ((struct list *)hash_lookup(lists, lid))->name, iid);
300     }
301     EXEC SQL CLOSE csr207; 
302     return(found);
303 }
304
305
306 show_mem_krb(id)
307 int id;
308 {
309     EXEC SQL BEGIN DECLARE SECTION; 
310     int lid, iid = id, found = 1;
311     char name[33];
312     EXEC SQL END DECLARE SECTION; 
313
314     EXEC SQL DECLARE csr208 CURSOR FOR
315         SELECT list_id FROM imembers
316             WHERE member_id = :iid AND member_type='KERBEROS' AND direct=1;
317     EXEC SQL OPEN csr208;
318     while(1) {
319         EXEC SQL FETCH csr208 INTO :lid;
320         if (sqlca.sqlcode != 0) {
321           ingerr(&sqlca.sqlcode);
322           break;
323         } 
324
325         found = 0;
326         printf("List %s has non-existant kerberos member, id %d\n",
327                ((struct list *)hash_lookup(lists, lid))->name, iid);
328     }
329     EXEC SQL CLOSE csr208; 
330     return(found);
331 }
332
333
334 del_mem_user(id)
335 EXEC SQL BEGIN DECLARE SECTION; 
336 int id;
337 EXEC SQL END DECLARE SECTION; 
338 {
339     EXEC SQL BEGIN DECLARE SECTION; 
340     int rowcount;
341     EXEC SQL END DECLARE SECTION; 
342
343     EXEC SQL DELETE FROM imembers WHERE member_type='USER' AND
344         member_id = :id AND direct = 1;
345     EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
346     if (rowcount > 0)
347       printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
348     else
349       printf("Not deleted\n");
350     modified("imembers");
351 }
352
353 del_mem_list(id)
354 EXEC SQL BEGIN DECLARE SECTION; 
355 int id;
356 EXEC SQL END DECLARE SECTION; 
357 {
358     EXEC SQL BEGIN DECLARE SECTION; 
359     int rowcount;
360     EXEC SQL END DECLARE SECTION; 
361
362     EXEC SQL DELETE FROM imembers WHERE member_type='LIST' AND
363         member_id = :id AND direct=1;
364     EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
365     if (rowcount > 0)
366       printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
367     else
368       printf("Not deleted\n");
369     modified("imembers");
370 }
371
372 del_mem_str(id)
373 EXEC SQL BEGIN DECLARE SECTION; 
374 int id;
375 EXEC SQL END DECLARE SECTION; 
376 {
377     EXEC SQL BEGIN DECLARE SECTION; 
378     int rowcount;
379     EXEC SQL END DECLARE SECTION; 
380
381     EXEC SQL DELETE FROM imembers WHERE member_type='STRING' AND
382         member_id = :id AND direct=1;
383     EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
384     if (rowcount > 0)
385       printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
386     else
387       printf("Not deleted\n");
388     modified("imembers");
389 }
390
391
392 del_mem_krb(id)
393 EXEC SQL BEGIN DECLARE SECTION; 
394 int id;
395 EXEC SQL END DECLARE SECTION; 
396 {
397     EXEC SQL BEGIN DECLARE SECTION; 
398     int rowcount;
399     EXEC SQL END DECLARE SECTION; 
400
401     EXEC SQL DELETE FROM imembers WHERE member_type='KERBEROS' AND
402         member_id = :id AND direct=1;
403     EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
404     if (rowcount > 0)
405       printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
406     else
407       printf("Not deleted\n");
408     modified("imembers");
409 }
410
411
412 show_sh(id)
413 EXEC SQL BEGIN DECLARE SECTION; 
414 int id;
415 EXEC SQL END DECLARE SECTION; 
416 {
417     EXEC SQL BEGIN DECLARE SECTION; 
418     char name[33];
419     EXEC SQL END DECLARE SECTION; 
420     int found = 1;
421
422     EXEC SQL DECLARE csr209 CURSOR FOR
423         SELECT service FROM serverhosts
424             WHERE mach_id = :id;
425     EXEC SQL OPEN csr209;
426     while(1) {
427         EXEC SQL FETCH csr209 INTO :name;
428         if (sqlca.sqlcode != 0) {
429           ingerr(&sqlca.sqlcode);
430           break;
431         } 
432
433         found = 0;
434         printf("ServerHost entry for service %s non-existant host %d\n",
435                name, id);
436     }
437     EXEC SQL CLOSE csr209; 
438     return(found);
439 }
440
441 del_sh_mach(id)
442 EXEC SQL BEGIN DECLARE SECTION; 
443 int id;
444 EXEC SQL END DECLARE SECTION; 
445 {
446     EXEC SQL BEGIN DECLARE SECTION; 
447     int rowcount;
448     EXEC SQL END DECLARE SECTION; 
449
450     EXEC SQL DELETE FROM serverhosts WHERE mach_id = :id;
451     EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
452     if (rowcount > 0)
453       printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
454     else
455       printf("Not deleted\n");
456     modified("serverhosts");
457 }
458
459
460 static int fnchecklen;
461
462 fsmatch(id, n, f)
463 int id;
464 struct nfsphys *n;
465 struct filesys *f;
466 {
467     if (n->mach_id == f->mach_id &&
468         !strncmp(f->dir, n->dir, strlen(n->dir)) &&
469         strlen(n->dir) > fnchecklen) {
470         f->phys_id = id;
471         fnchecklen = strlen(n->dir);
472     }
473 }
474
475
476 check_fs(id, f, hint)
477 EXEC SQL BEGIN DECLARE SECTION; 
478 int id;
479 EXEC SQL END DECLARE SECTION; 
480 register struct filesys *f;
481 int hint;
482 {
483     EXEC SQL BEGIN DECLARE SECTION; 
484     int id1, id2, id3, rowcount;
485     char *dir;
486     EXEC SQL END DECLARE SECTION; 
487     struct nfsphys *n;
488     struct machine *m;
489
490     if (!hash_lookup(machines, f->mach_id)) {
491         printf("Filesys %s with bad machine %d\n", f->name, f->mach_id);
492         if (single_fix("Fix", 0)) {
493             EXEC SQL UPDATE filesys SET mach_id = 0 WHERE filsys_id = :id;
494             EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
495             if (rowcount > 0)
496               printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
497             else
498               printf("Not fixed\n");
499             modified("filesys");
500             f->mach_id = 0;
501         }
502     }
503
504     if (!hash_lookup(users, f->owner)) {
505         printf("Filesys %s with bad owning user %d\n", f->name, f->owner);
506         if (single_fix("Fix", 1)) {
507             zero_fix("filesys", "owner", "filsys_id", f->filsys_id);
508             f->owner = 0;
509         }
510     }
511     if (!hash_lookup(lists, f->owners)) {
512         printf("Filesys %s with bad owning group %d\n", f->name, f->owners);
513         if (single_fix("Fix", 1)) {
514             zero_fix("filesys", "owners", "filsys_id", f->filsys_id);
515             f->owners = 0;
516         }
517     }
518
519     if (f->type == 'N') {
520         if (!hash_lookup(nfsphys, f->phys_id)) {
521             m = (struct machine *)hash_lookup(machines, f->mach_id);
522             printf("Filesys %s with bad phys_id %d\n", f->name, f->phys_id);
523             if (single_fix("Fix", 1)) {
524                 fnchecklen = 0;
525                 hash_step(nfsphys, fsmatch, f);
526                 if (fnchecklen != 0) {
527                   id1 = f->phys_id;
528                   id2 = f->filsys_id;
529                   id3 = f->mach_id;
530                   EXEC SQL UPDATE filesys SET phys_id = :id1 WHERE filsys_id = :id2;
531                   EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
532                   if (rowcount > 0)
533                     printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
534                   else
535                     printf("Not fixed\n");
536                   modified("filesys");
537                 } else {
538                     printf("No NFSphys exsits for %s:%s\n", m->name, f->dir);
539                     if (single_fix("Create", 0)) {
540                         dir = f->dir;
541                         id1 = f->phys_id;
542                         id2 = f->filsys_id;
543                         id3 = f->mach_id;
544                         if (set_next_object_id("nfsphys_id", "nfsphys") !=
545                                 MR_SUCCESS) {
546                             printf("Unable to assign unique ID\n");
547                             return;
548                         }
549                         EXEC SQL SELECT COUNT(*) INTO :rowcount FROM numvalues 
550                             WHERE name='nfsphys_id';
551                         if (rowcount != 1) {
552                             printf("Unable to retrieve unique ID\n");
553                             return;
554                         }
555                         EXEC SQL INSERT INTO mfsphys (mfsphys_id, mach_id,
556                             device, dir, status, allocated, size, modtime,
557                             modby, modwith) VALUES (:id1, :id3, '???', :dir,
558                             0, 0, 0, 'now', 0, 'dbck');
559                         EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
560                         if (rowcount > 0)
561                           printf("%d entr%s created\n", rowcount,
562                                  rowcount==1?"y":"ies");
563                         else
564                           printf("Not created\n");
565                         modified("nfsphys");
566                         n = (struct nfsphys *)malloc(sizeof(struct nfsphys));
567                         if (n == NULL)
568                           out_of_mem("storing new nfsphys");
569                         strcpy(n->dir, dir);
570                         n->mach_id = id3;
571                         n->nfsphys_id = id1;
572                         n->allocated = 0;
573                         n->count = 0;
574                         hash_store(nfsphys, id1, n);
575                         EXEC SQL UPDATE filesys SET phys_id = :id1
576                             WHERE filsys_id = :id2;
577                         EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
578                         if (rowcount > 0)
579                           printf("%d filesys entr%s fixed\n", rowcount,
580                                  rowcount==1?"y":"ies");
581                         else
582                           printf("Not fixed\n");
583                         modified("filesys");
584                     }
585                 }
586             }
587         }
588     }
589 }
590
591
592 check_nfsphys(id, n, hint)
593 int id;
594 struct nfsphys *n;
595 int hint;
596 {
597     if (!hash_lookup(machines, n->mach_id)) {
598         printf("NFSphys %d(%s) on non-existant machine %d\n",
599                id, n->dir, n->mach_id);
600         if (single_fix("Delete", 0))
601           single_delete("nfsphys", "nfsphys_id", id);
602     }
603 }
604
605 show_fsg_missing(id)
606 EXEC SQL BEGIN DECLARE SECTION; 
607 int id;
608 EXEC SQL END DECLARE SECTION; 
609 {
610     EXEC SQL BEGIN DECLARE SECTION; 
611     int id1, found = 1;
612     EXEC SQL END DECLARE SECTION; 
613     struct filesys *f;
614
615     EXEC SQL DECLARE csr210 CURSOR FOR
616         SELECT filsys_id FROM fsgroup
617             WHERE group_id = :id;
618     EXEC SQL OPEN csr210;
619     while(1) {
620         EXEC SQL FETCH csr210 INTO :id1;
621         if (sqlca.sqlcode != 0) {
622           ingerr(&sqlca.sqlcode);
623           break;
624         } 
625
626         found = 0;
627         if (f = (struct filesys *) hash_lookup(filesys, id1))
628             printf("Missing fsgroup %d has member filesystem %s\n", id, f->name);
629         else
630             printf("Missing fsgroup %d has member filesystem %d\n", id, id1);
631     }
632     EXEC SQL CLOSE csr210; 
633     return(found);
634 }
635
636 show_fsg_type(f)
637 struct filesys *f;
638 {
639     char *t;
640
641     switch (f->type) {
642     case 'N':
643         t = "NFS";
644         break;
645     case 'R':
646         t = "RVD";
647         break;
648     case 'A':
649         t = "AFS";
650         break;
651     case 'E':
652         t = "ERR";
653         break;
654     case 'F':
655         t = "FSGROUP";
656         break;
657     case 'M':
658         t = "MUL";
659         break;
660     default:
661         t = "???";
662     }
663     printf("FSGroup %s has type %s instead of FSGROUP\n", f->name, t);
664     return(0);
665 }
666
667 fix_fsg_type(f)
668 struct filesys *f;
669 {
670     EXEC SQL BEGIN DECLARE SECTION; 
671     int rowcount, id = f->filsys_id;
672     EXEC SQL END DECLARE SECTION; 
673
674     EXEC SQL UPDATE filesys SET type='FSGROUP' WHERE filsys_id = :id;
675     EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
676     if (rowcount > 0)
677       printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
678     else
679       printf("Not fixed\n");
680     modified("filesys");
681 }
682
683 show_fsg_nomember(id)
684 EXEC SQL BEGIN DECLARE SECTION; 
685 int id;
686 EXEC SQL END DECLARE SECTION; 
687 {
688     EXEC SQL BEGIN DECLARE SECTION; 
689     int id1, found = 1;
690     EXEC SQL END DECLARE SECTION; 
691     struct filesys *f;
692
693     EXEC SQL DECLARE csr211 CURSOR FOR
694         SELECT group_id FROM fsgroup
695             WHERE filsys_id = :id;
696     EXEC SQL OPEN csr211;
697     while(1) {
698         EXEC SQL FETCH csr211 INTO :id1;
699         if (sqlca.sqlcode != 0) {
700           ingerr(&sqlca.sqlcode);
701           break;
702         } 
703
704         found = 0;
705         if (f = (struct filesys *) hash_lookup(filesys, id1))
706             printf("FSGroup %s has missing member %d\n", f->name, id);
707         else
708             printf("FSGroup %d has missing member %d\n", id1, id);
709     }
710     EXEC SQL CLOSE csr211; 
711     return(found);
712 }
713
714 show_quota_nouser(id)
715 EXEC SQL BEGIN DECLARE SECTION; 
716 int id;
717 EXEC SQL END DECLARE SECTION; 
718 {
719     EXEC SQL BEGIN DECLARE SECTION; 
720     int id1, found = 1;
721     EXEC SQL END DECLARE SECTION; 
722
723     EXEC SQL DECLARE csr212 CURSOR FOR
724         SELECT filsys_id FROM quota
725             WHERE entity_id = :id AND type='USER';
726     EXEC SQL OPEN csr212;
727     while(1) {
728         EXEC SQL FETCH csr212 INTO :id1;
729         if (sqlca.sqlcode != 0) {
730           ingerr(&sqlca.sqlcode);
731           break;
732         } 
733
734         found = 0;
735         printf("Quota on fs %d for non-existant user %d\n", id1, id);
736     }
737     EXEC SQL CLOSE csr212; 
738     return(found);
739 }
740
741 show_quota_nolist(id)
742 EXEC SQL BEGIN DECLARE SECTION; 
743 int id;
744 EXEC SQL END DECLARE SECTION; 
745 {
746     EXEC SQL BEGIN DECLARE SECTION; 
747     int id1, found = 1;
748     EXEC SQL END DECLARE SECTION; 
749
750     EXEC SQL DECLARE csr213 CURSOR FOR
751         SELECT filsys_id FROM quota 
752             WHERE entity_id = :id AND type='GROUP';
753     EXEC SQL OPEN csr213;
754     while(1) {
755         EXEC SQL FETCH csr213 INTO :id1;
756         if (sqlca.sqlcode != 0) {
757           ingerr(&sqlca.sqlcode);
758           break;
759         }
760  
761         found = 0;
762         printf("Quota on fs %d for non-existant list %d\n", id1, id);
763     }
764     EXEC SQL CLOSE csr213; 
765     return(found);
766 }
767
768 fix_quota_nouser(id)
769 EXEC SQL BEGIN DECLARE SECTION; 
770 int id;
771 EXEC SQL END DECLARE SECTION; 
772 {
773     EXEC SQL BEGIN DECLARE SECTION; 
774     int rowcount, id1;
775     EXEC SQL END DECLARE SECTION; 
776
777     id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
778     EXEC SQL DELETE FROM quota 
779         WHERE entity_id = :id AND type = 'USER';
780     EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
781     if (rowcount > 0)
782       printf("%d entr%s deleted\n",rowcount, rowcount==1?"y":"ies");
783     else
784       printf("Not deleted\n");
785     modified("quota");
786 }
787
788 fix_quota_nolist(id)
789 EXEC SQL BEGIN DECLARE SECTION; 
790 int id;
791 EXEC SQL END DECLARE SECTION; 
792 {
793     EXEC SQL BEGIN DECLARE SECTION; 
794     int rowcount, id1;
795     EXEC SQL END DECLARE SECTION; 
796
797     id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
798     EXEC SQL DELETE FROM quota WHERE entity_id = :id AND type='GROUP';
799     EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
800     if (rowcount > 0)
801       printf("%d entr%s deleted\n",rowcount, rowcount==1?"y":"ies");
802     else
803       printf("Not deleted\n");
804     modified("quota");
805 }
806
807 show_quota_nofs(id)
808 EXEC SQL BEGIN DECLARE SECTION; 
809 int id;
810 EXEC SQL END DECLARE SECTION; 
811 {
812     EXEC SQL BEGIN DECLARE SECTION; 
813     int id1, found = 1;
814     char type[9];
815     EXEC SQL END DECLARE SECTION; 
816
817     EXEC SQL DECLARE csr214 CURSOR FOR
818         SELECT entity_id, type FROM quota
819             WHERE filsys_id = :id;
820     EXEC SQL OPEN csr214;
821     while(1) {
822         EXEC SQL FETCH csr214 INTO :id1, :type;
823         if (sqlca.sqlcode != 0) {
824           ingerr(&sqlca.sqlcode);
825           break;
826         } 
827         
828         found = 0;
829         printf("Quota for %s %d on non-existant filesys %d\n", type, id1, id);
830     }
831     EXEC SQL CLOSE csr214;
832     return(found);
833 }
834
835 fix_quota_nofs(id)
836 {
837     single_delete("quota", "filsys_id", id);
838 }
839
840 show_quota_wrongpid(id)
841 EXEC SQL BEGIN DECLARE SECTION; 
842 int id;
843 EXEC SQL END DECLARE SECTION; 
844 {
845     EXEC SQL BEGIN DECLARE SECTION; 
846     int id1, found = 1;
847     char type[9];
848     EXEC SQL END DECLARE SECTION; 
849     struct user *u;
850     struct filesys *f;
851
852     f = (struct filesys *)hash_lookup(filesys, id);
853     EXEC SQL DECLARE csr215 CURSOR FOR
854         SELECT entity_id, type FROM quota
855             WHERE filsys_id = :id;
856     EXEC SQL OPEN csr215;
857     while(1) {
858         EXEC SQL FETCH csr215 INTO :id1, :type;
859         if (sqlca.sqlcode != 0) {
860           ingerr(&sqlca.sqlcode);
861           break;
862         } 
863
864         found = 0;
865         printf("Quota for %s %d on filesys %s has wrong phys_id %d\n",
866                type, id1, f->name, id);
867     }
868     EXEC SQL CLOSE csr215; 
869     return(found);
870 }
871
872 fix_quota_physid(id)
873 EXEC SQL BEGIN DECLARE SECTION; 
874 int id;
875 EXEC SQL END DECLARE SECTION; 
876 {
877     EXEC SQL BEGIN DECLARE SECTION; 
878     int rowcount, id1;
879     EXEC SQL END DECLARE SECTION; 
880
881     id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
882     EXEC SQL UPDATE quota SET phys_id = :id1 
883         WHERE filsys_id = :id AND phys_id != :id1;
884     EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
885     if (rowcount > 0)
886       printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
887     else
888       printf("Not fixed\n");
889     modified("quota");
890 }
891
892 show_srv_user(id)
893 EXEC SQL BEGIN DECLARE SECTION; 
894 int id;
895 EXEC SQL END DECLARE SECTION; 
896 {
897     EXEC SQL BEGIN DECLARE SECTION; 
898     char name[33];
899     EXEC SQL END DECLARE SECTION; 
900     int found = 1;
901
902     EXEC SQL DECLARE csr216 CURSOR FOR
903         SELECT name FROM servers
904             WHERE acl_type='USER' and acl_id = :id;
905     EXEC SQL OPEN csr216;
906     while(1) {
907         EXEC SQL FETCH csr216 INTO :name;
908         if (sqlca.sqlcode != 0) {
909           ingerr(&sqlca.sqlcode);
910           break;
911         } 
912         
913         strtrim(name);
914         printf("Service %s has acl non-existant user %d\n", name, id);
915         found = 0;
916     }
917     EXEC SQL CLOSE csr216; 
918     return(found);
919 }
920
921 show_srv_list(id)
922 EXEC SQL BEGIN DECLARE SECTION; 
923 int id;
924 EXEC SQL END DECLARE SECTION; 
925 {
926     EXEC SQL BEGIN DECLARE SECTION; 
927     char name[33];
928     EXEC SQL END DECLARE SECTION; 
929     int found = 1;
930
931     EXEC SQL DECLARE csr217 CURSOR FOR
932         SELECT name FROM servers
933             WHERE acl_type='LIST' AND acl_id = :id;
934     EXEC SQL OPEN csr217;
935     while(1) {
936         EXEC SQL FETCH csr217 INTO :name;
937         if (sqlca.sqlcode != 0) {
938           ingerr(&sqlca.sqlcode);
939           break;
940         } 
941
942         strtrim(name);
943         printf("Service %s has acl non-existant list %d\n", name, id);
944         found = 0;
945     }
946     EXEC SQL CLOSE csr217; 
947     return(found);
948 }
949
950 zero_srv_user(id)
951 EXEC SQL BEGIN DECLARE SECTION; 
952 int id;
953 EXEC SQL END DECLARE SECTION; 
954 {
955     EXEC SQL BEGIN DECLARE SECTION; 
956     int rowcount;
957     EXEC SQL END DECLARE SECTION; 
958
959     EXEC SQL UPDATE servers SET acl_id=0 WHERE acl_id = :id AND
960         acl_type='USER';
961     EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
962     if (rowcount > 0)
963       printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
964     else
965       printf("Not fixed\n");
966     modified("servers");
967 }
968
969 zero_srv_list(id)
970 EXEC SQL BEGIN DECLARE SECTION; 
971 int id;
972 EXEC SQL END DECLARE SECTION; 
973 {
974     EXEC SQL BEGIN DECLARE SECTION; 
975     int rowcount;
976     EXEC SQL END DECLARE SECTION; 
977
978     EXEC SQL UPDATE servers SET acl_id=0 WHERE acl_id = :id AND
979         acl_type='LIST';
980     EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
981     if (rowcount > 0)
982       printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
983     else
984       printf("Not fixed\n");
985     modified("servers");
986 }
987
988
989 show_krb_usr(id)
990 EXEC SQL BEGIN DECLARE SECTION; 
991 int id;
992 EXEC SQL END DECLARE SECTION; 
993 {
994     EXEC SQL BEGIN DECLARE SECTION; 
995     int found = 1, id1;
996     EXEC SQL END DECLARE SECTION; 
997     struct string *s;
998     char *ss;
999
1000     EXEC SQL DECLARE csr218 CURSOR FOR
1001         SELECT string_id FROM krbmap
1002             WHERE users_id = :id ;
1003     EXEC SQL OPEN csr218;
1004     while(1) {
1005         EXEC SQL FETCH csr218 INTO :id1;
1006         if (sqlca.sqlcode != 0) {
1007           ingerr(&sqlca.sqlcode);
1008           break;
1009         } 
1010
1011         if (s = ((struct string *)hash_lookup(strings, id1)))
1012             ss = s->name;
1013         else
1014             ss = "[unknown]";
1015         found = 0;
1016         printf("Kerberos map for non-existant user %d to principal %s\n",
1017                id, s);
1018     }
1019     EXEC SQL CLOSE csr218; 
1020     return(found);
1021 }
1022
1023
1024 show_krb_str(id)
1025 EXEC SQL BEGIN DECLARE SECTION; 
1026 int id;
1027 EXEC SQL END DECLARE SECTION; 
1028 {
1029     EXEC SQL BEGIN DECLARE SECTION; 
1030     int found = 1, id1;
1031     EXEC SQL END DECLARE SECTION; 
1032     struct user *u;
1033     char *s;
1034
1035     EXEC SQL DECLARE csr219 CURSOR FOR
1036         SELECT users_id FROM krbmap
1037             WHERE string_id = :id;
1038     EXEC SQL OPEN csr219;
1039     while(1) {
1040         EXEC SQL FETCH csr219 INTO :id1;
1041         if (sqlca.sqlcode != 0) {
1042           ingerr(&sqlca.sqlcode);
1043           break;
1044         } 
1045
1046         if (u = ((struct user *)hash_lookup(users, id1)))
1047             s = u->login;
1048         else
1049             s = "[???]";
1050         found = 0;
1051         printf("Kerberos map for user %s (%d) to non-existant string %d\n",
1052                s, id1, id);
1053         }
1054     EXEC SQL CLOSE csr219; 
1055     return(found);
1056 }
1057
1058
1059 show_pdm_mach(id)
1060 EXEC SQL BEGIN DECLARE SECTION; 
1061 int id;
1062 EXEC SQL END DECLARE SECTION; 
1063 {
1064     EXEC SQL BEGIN DECLARE SECTION; 
1065     char name[33];
1066     EXEC SQL END DECLARE SECTION; 
1067     int found = 1;
1068
1069     EXEC SQL DECLARE csr220 CURSOR FOR
1070         SELECT name FROM palladium
1071             WHERE mach_id = :id;
1072     EXEC SQL OPEN csr220;
1073     while(1) {
1074         EXEC SQL FETCH csr220 INTO :name;
1075         if (sqlca.sqlcode != 0) {
1076           ingerr(&sqlca.sqlcode);
1077           break;
1078         } 
1079
1080         strtrim(name);
1081         printf("Palladium server/supervisor %s is on non-existant machine %d\n",
1082                name, id);
1083         found = 0;
1084         }
1085     EXEC SQL CLOSE csr220; 
1086     return(found);
1087 }
1088
1089
1090 phase2()
1091 {
1092     EXEC SQL BEGIN DECLARE SECTION; 
1093     int id1, id2, id3, id4, id5;
1094     char type[9], name[33];
1095     EXEC SQL END DECLARE SECTION; 
1096     struct save_queue *sq, *sq1, *sq2, *sq3, *sq4, *sq5;
1097     struct filesys *f;
1098     struct list *l;
1099     struct nfsphys *n;
1100     struct machine *m;
1101
1102     printf("Phase 2 - Checking references\n");
1103
1104     dprintf("Checking users...\n");
1105     hash_step(users, pobox_check, NULL);
1106
1107     dprintf("Checking mcmap...\n");
1108     sq1 = sq_create();
1109     sq2 = sq_create();
1110     EXEC SQL DECLARE csr221 CURSOR FOR
1111         SELECT mach_id, clu_id FROM mcmap;
1112     EXEC SQL OPEN csr221;
1113     while(1) {
1114         EXEC SQL FETCH csr221 INTO :id1, :id2;
1115         if (sqlca.sqlcode != 0) {
1116           ingerr(&sqlca.sqlcode);
1117           break;
1118         } 
1119
1120         if (!(m = (struct machine *)hash_lookup(machines, id1)))
1121             sq_save_unique_data(sq1, id1);
1122         if (!hash_lookup(clusters, id2))
1123             sq_save_unique_data(sq2, id2);
1124         if (m) m->clucount++;
1125         }
1126     EXEC SQL CLOSE csr221; 
1127     generic_delete(sq1, show_mcm_mach, "mcmap", "mach_id", 1);
1128     generic_delete(sq2, show_mcm_clu, "mcmap", "clu_id", 1);
1129
1130     dprintf("Checking service clusters...\n");
1131     sq1 = sq_create();
1132     EXEC SQL DECLARE csr222 CURSOR FOR
1133         SELECT clu_id FROM svc;
1134     EXEC SQL OPEN csr222;
1135     while(1) {
1136         EXEC SQL FETCH csr222 INTO :id1;
1137         if (sqlca.sqlcode != 0) {
1138           ingerr(&sqlca.sqlcode);
1139           break;
1140         } 
1141
1142         if (!hash_lookup(clusters, id1))
1143           sq_save_unique_data(sq1, id1);
1144     }
1145     EXEC SQL CLOSE csr222; 
1146     generic_delete(sq1, show_svc, "svc", "clu_id", 1);
1147
1148     dprintf("Checking lists...\n");
1149     hash_step(lists, list_check, NULL);
1150
1151     dprintf("Checking members...\n");
1152     sq1 = sq_create();
1153     sq2 = sq_create();
1154     sq3 = sq_create();
1155     sq4 = sq_create();
1156     sq5 = sq_create();
1157
1158     EXEC SQL DECLARE csr223 CURSOR FOR
1159         SELECT list_id, member_type, member_id, ref_count, direct 
1160         FROM imembers ORDER BY list_id;
1161     EXEC SQL OPEN csr223;
1162     while(1) {
1163         EXEC SQL FETCH csr223 INTO :id1, :type, :id2, :id3, :id4;
1164         if (sqlca.sqlcode != 0) {
1165           ingerr(&sqlca.sqlcode);
1166           break;
1167         } 
1168
1169         if ((l = (struct list *) hash_lookup(lists, id1)) == NULL)
1170           sq_save_unique_data(sq1, id1);
1171         else if (type[0] == 'U' && !hash_lookup(users, id2))
1172           sq_save_unique_data(sq2, id2);
1173         else if (type[0] == 'L' && !hash_lookup(lists, id2))
1174           sq_save_unique_data(sq3, id2);
1175         else if (type[0] == 'S' && !string_check(id2))
1176           sq_save_unique_data(sq4, id2);
1177         else if (type[0] == 'K' && !string_check(id2))
1178           sq_save_unique_data(sq5, id2);
1179         else
1180           l->members++;
1181         }
1182     EXEC SQL CLOSE csr223; 
1183     generic_delete(sq1, show_member_list, "imembers", "list_id", 1);
1184     generic_fix(sq2, show_mem_user, "Delete", del_mem_user, 1);
1185     generic_fix(sq3, show_mem_list, "Delete", del_mem_list, 1);
1186     generic_fix(sq4, show_mem_str, "Delete", del_mem_str, 1);
1187     generic_fix(sq5, show_mem_krb, "Delete", del_mem_krb, 1);
1188
1189     dprintf("Checking servers...\n");
1190     sq1 = sq_create();
1191     sq2 = sq_create();
1192     EXEC SQL DECLARE csr224 CURSOR FOR
1193         SELECT name, acl_type, acl_id FROM servers;
1194     EXEC SQL OPEN csr224;
1195     while(1) {
1196         EXEC SQL FETCH csr224 INTO :name, :type, :id1;
1197         if (sqlca.sqlcode != 0) {
1198           ingerr(&sqlca.sqlcode);
1199           break;
1200         } 
1201
1202         strtrim(type);
1203         if (!strcmp(type, "USER") && !hash_lookup(users, id1)) {
1204             sq_save_data(sq1, id1);
1205         } else if (!strcmp(type, "LIST") && !hash_lookup(lists, id1)) {
1206             sq_save_data(sq2, id1);
1207         }
1208     }
1209     EXEC SQL CLOSE csr224; 
1210     generic_fix(sq1, show_srv_user, "Fix", zero_srv_user, 1);
1211     generic_fix(sq2, show_srv_list, "Fix", zero_srv_list, 1);
1212
1213     dprintf("Checking serverhosts...\n");
1214     sq = sq_create();
1215     EXEC SQL DECLARE csr225 CURSOR FOR
1216         SELECT mach_id FROM serverhosts;
1217     EXEC SQL OPEN csr225;
1218     while(1) {
1219         EXEC SQL FETCH csr225 INTO :id1;
1220         if (sqlca.sqlcode != 0) {
1221           ingerr(&sqlca.sqlcode);
1222           break;
1223         } 
1224
1225         if (!hash_lookup(machines, id1))
1226           sq_save_data(sq, id1);
1227         }
1228     EXEC SQL CLOSE csr225; 
1229     generic_fix(sq, show_sh, "Delete", del_sh_mach, 0);
1230
1231     dprintf("Checking nfsphys...\n");
1232     hash_step(nfsphys, check_nfsphys, NULL);
1233
1234     dprintf("Checking filesys...\n");
1235     hash_step(filesys, check_fs, NULL);
1236
1237     dprintf("Checking filesystem groups...\n");
1238     sq1 = sq_create();
1239     sq2 = sq_create();
1240     sq3 = sq_create();
1241     EXEC SQL DECLARE csr226 CURSOR FOR
1242         SELECT group_id, filsys_id FROM fsgroup;
1243     EXEC SQL OPEN csr226;
1244     while(1) {
1245         EXEC SQL FETCH csr226 INTO :id1, :id2;
1246         if (sqlca.sqlcode != 0) {
1247           ingerr(&sqlca.sqlcode);
1248           break;
1249         } 
1250
1251         if (!(f = (struct filesys *) hash_lookup(filesys, id1)))
1252           sq_save_data(sq1, id1);
1253         if (!hash_lookup(filesys, id2))
1254           sq_save_data(sq3, id2);
1255     }
1256     EXEC SQL CLOSE csr226; 
1257     generic_delete(sq1, show_fsg_missing, "fsgroup", "group_id", 0);
1258     generic_delete(sq3, show_fsg_nomember, "fsgroup", "filsys_id", 1);
1259
1260     dprintf("Checking quotas...\n");
1261     sq1 = sq_create();
1262     sq2 = sq_create();
1263     sq3 = sq_create();
1264     sq4 = sq_create();
1265     EXEC SQL DECLARE csr227 CURSOR FOR
1266         SELECT entity_id, type, filsys_id, phys_id, quota FROM quota;
1267     EXEC SQL OPEN csr227;
1268     while(1) {
1269         EXEC SQL FETCH csr227 INTO :id1, :type, :id2, :id3, :id4;
1270         if (sqlca.sqlcode != 0) {
1271           ingerr(&sqlca.sqlcode);
1272           break;
1273         } 
1274
1275         if (type[0] == 'U' && id1 != 0 && !hash_lookup(users, id1))
1276           sq_save_data(sq1, id1);
1277         else if (type[0] == 'G' && !hash_lookup(lists, id1))
1278           sq_save_data(sq4, id1);
1279         else if (!(f = (struct filesys *) hash_lookup(filesys, id2)))
1280           sq_save_data(sq2, id2);
1281         else if (id3 != f->phys_id ||
1282             ((n = (struct nfsphys*) hash_lookup(nfsphys, id3)) ==
1283             (struct nfsphys *)NULL))
1284           sq_save_data(sq3, id2);
1285         else
1286           n->count += id4;
1287     }
1288     EXEC SQL CLOSE csr227; 
1289     generic_fix(sq1, show_quota_nouser, "Delete", fix_quota_nouser, 1);
1290     generic_fix(sq2, show_quota_nofs, "Delete", fix_quota_nofs, 0);
1291     generic_fix(sq3, show_quota_wrongpid, "Fix", fix_quota_physid, 1);
1292     generic_fix(sq4, show_quota_nolist, "Delete", fix_quota_nolist, 1);
1293
1294     dprintf("Not checking zephyr.\n");
1295
1296     dprintf("Checking hostaccess...\n");
1297     EXEC SQL DECLARE csr228 CURSOR FOR
1298         SELECT mach_id, acl_type, acl_id FROM hostaccess;
1299     EXEC SQL OPEN csr228;
1300     while(1) {
1301         EXEC SQL FETCH csr228 INTO :id1, :type, :id2;
1302         if (sqlca.sqlcode != 0) {
1303           ingerr(&sqlca.sqlcode);
1304           break;
1305         } 
1306
1307         strtrim(type);
1308         if (!hash_lookup(machines, id1)) {
1309             printf("Hostaccess for non-existant host %d\n", id1);
1310             printf("Not fixing this error\n");
1311         }
1312         if (!strcmp(type, "USER") && !hash_lookup(users, id2)) {
1313             printf("Hostaccess for %d is non-existant user %d\n", id1, id2);
1314             printf("Not fixing this error\n");
1315         } else if (!strcmp(type, "LIST") && !hash_lookup(lists, id2)) {
1316             printf("Hostaccess for %d is non-existant list %d\n", id1, id2);
1317             printf("Not fixing this error\n");
1318         }
1319     }
1320     EXEC SQL CLOSE csr228; 
1321
1322     dprintf("Checking palladium...\n");
1323     sq1 = sq_create();
1324     EXEC SQL DECLARE csr229 CURSOR FOR
1325         SELECT mach_id FROM palladium;
1326     EXEC SQL OPEN csr229;
1327     while(1) {
1328         EXEC SQL FETCH csr229 INTO :id1;
1329         if (sqlca.sqlcode != 0) {
1330           ingerr(&sqlca.sqlcode);
1331           break;
1332         } 
1333
1334         if (!hash_lookup(machines, id1)) {
1335             sq_save_unique_data(sq1, id1);
1336         }
1337     }
1338     EXEC SQL CLOSE csr229;
1339     generic_delete(sq1, show_pdm_mach, "palladium", "mach_id", 1);
1340
1341     dprintf("Checking krbmap...\n");
1342     sq1 = sq_create();
1343     sq2 = sq_create();
1344     EXEC SQL DECLARE csr230 CURSOR FOR
1345         SELECT users_id, string_id FROM krbmap;
1346     EXEC SQL OPEN csr230;
1347     while(1) {
1348         EXEC SQL FETCH csr230 INTO :id1, :id2;
1349         if (sqlca.sqlcode != 0) {
1350           ingerr(&sqlca.sqlcode);
1351           break;
1352         } 
1353
1354         if (!hash_lookup(users, id1))
1355           sq_save_unique_data(sq1, id1);
1356         if (!string_check(id2))
1357           sq_save_unique_data(sq2, id2);
1358         }
1359     EXEC SQL CLOSE csr230; 
1360     generic_delete(sq1, show_krb_usr, "krbmap", "users_id", 1);
1361     generic_delete(sq2, show_krb_str, "krbmap", "string_id", 1);
1362
1363     dprintf("Checking capacls...\n");
1364     EXEC SQL DECLARE csr231 CURSOR FOR
1365         SELECT list_id, tag FROM capacls;
1366     EXEC SQL OPEN csr231;
1367     while(1) {
1368         EXEC SQL FETCH csr231 INTO :id1, :name;
1369         if (sqlca.sqlcode != 0) {
1370           ingerr(&sqlca.sqlcode);
1371           break;
1372         } 
1373
1374         if (!hash_lookup(lists, id1)) {
1375             printf("Capacl for %s is non-existant list %d\n", name, id1);
1376             printf("Not fixing this error\n");
1377         }
1378     }
1379     EXEC SQL CLOSE csr231; 
1380
1381 }
1382
This page took 0.215511 seconds and 5 git commands to generate.