int mode = MODE_ASK;
int fast = 0;
int warn = 1;
-int abort = 0;
+int abort_p = 0;
struct hash *users, *machines, *clusters, *lists, *filesys, *nfsphys;
-struct hash *strings, *members;
-##int dcmenable;
+struct hash *strings, *members, *subnets;
+EXEC SQL BEGIN DECLARE SECTION;
+int dcmenable;
+EXEC SQL END DECLARE SECTION;
struct save_queue *modtables, *sq_create();
int interrupt();
char **argv;
{
char **arg = argv;
-## char *database;
+EXEC SQL BEGIN DECLARE SECTION;
+ char *database;
+EXEC SQL END DECLARE SECTION;
int ingerr();
int countonly = 0;
- database = "sms";
+ database = "moira";
while (++arg - argv < argc) {
if (**arg == '-')
IIseterr(ingerr);
printf("Opening database %s...", database);
fflush(stdout);
-## ingres database
+ EXEC SQL CONNECT :database;
printf("done\n");
-## retrieve (dcmenable = values.value) where values.name = "dcm_enable"
+ EXEC SQL SELECT value INTO :dcmenable FROM numvalues
+ WHERE name='dcm_enable';
dprintf("DCM disabled (was %d)\n", dcmenable);
-## replace values (value = 0) where values.name = "dcm_enable"
+ EXEC SQL UPDATE numvalues SET value=0 WHERE name='dcm_enable';
-## begin transaction
+ /* Begin transaction here. */
if (!countonly) {
phase1();
+ EXEC SQL COMMIT WORK;
phase2();
+ EXEC SQL COMMIT WORK;
phase3();
+ EXEC SQL COMMIT WORK;
} else {
count_only_setup();
+ EXEC SQL COMMIT WORK;
}
phase4();
-## end transaction
+ EXEC SQL COMMIT WORK;
+
cleanup();
printf("Done.\n");
exit(0);
ingerr(num)
int *num;
{
+ if (*num == 100) return;
printf("An ingres error occuurred, code %d\n", *num);
printf("Aborting...\n");
- if (!abort) {
- abort++;
-## abort
+ if (!abort_p) {
+ abort_p++;
+ EXEC SQL ROLLBACK WORK;
}
exit(1);
}
int interrupt()
-##{
+{
printf("Signal caught\n");
if (prompt("Save database changes")) {
/* break out of a retrieve loop */
IIbreak();
-## end transaction
+
+ EXEC SQL COMMIT WORK;
cleanup();
exit(0);
}
printf("Aborting transaction\n");
- if (!abort) {
- abort++;
+ if (!abort_p) {
+ abort_p++;
/* break out of a retrieve loop */
IIbreak();
-## abort
+ EXEC SQL ROLLBACK WORK;
}
-## replace values (value = dcmenable) where values.name = "dcm_enable"
-## exit
+
+ EXEC SQL UPDATE numvalues SET value=:dcmenable
+ WHERE name='dcm_enable';
+
exit(0);
-##}
+}
modified(table)
}
cleanup()
-##{
-## char *tab;
+{
+ EXEC SQL BEGIN DECLARE SECTION;
+ char *tab;
+ EXEC SQL END DECLARE SECTION;
while (sq_get_data(modtables, &tab)) {
-## replace tblstats (modtime = "now") where tblstats.table = tab
+ EXEC SQL REPEATED UPDATE tblstats SET modtime='now'
+ WHERE table_name = :tab;
}
-## replace values (value = dcmenable) where values.name = "dcm_enable"
-## exit
-##}
+ EXEC SQL UPDATE numvalues SET value = :dcmenable
+ WHERE name='dcm_enable';
+}
out_of_mem(msg)
char *msg;
{
fprintf(stderr, "Out of memory while %s\n", msg);
-## end transaction
- cleanup();
+ if (prompt("Save database changes")) {
+ /* break out of a retrieve loop */
+ IIbreak();
+
+ EXEC SQL COMMIT WORK;
+ cleanup();
+ exit(1);
+ }
+ printf("Aborting transaction\n");
+ IIbreak();
+ EXEC SQL ROLLBACK WORK;
exit(1);
}