6 * Copyright (C) 1987 by the Massachusetts Institute of Technology
7 * For copying and distribution information, please see the file
13 static char *rcsid_qsupport_dc = "$Header$";
16 #include <mit-copyright.h>
18 #include "mr_server.h"
23 EXEC SQL INCLUDE sqlca;
24 EXEC SQL INCLUDE sqlda;
27 extern char *whoami, *strsave();
28 extern int ingres_errno, mr_errcode;
30 EXEC SQL BEGIN DECLARE SECTION;
31 extern char stmt_buf[];
32 EXEC SQL END DECLARE SECTION;
34 EXEC SQL WHENEVER SQLERROR CALL ingerr;
37 /* FOLLOWUP ROUTINES */
39 /* generic set_modtime routine. This takes the table name from the query,
40 * and will update the modtime, modby, and modwho fields in the entry in
41 * the table whose name field matches argv[0].
44 set_modtime(q, argv, cl)
49 char *name, *entity, *table;
57 sprintf(stmt_buf,"UPDATE %s SET modtime = 'now', modby = %d, modwith = '%s' WHERE %s.name = LEFT('%s',SIZE(%s.name))",table,who,entity,table,name,table);
58 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
63 /* generic set_modtime_by_id routine. This takes the table name from
64 * the query, and the id name from the validate record,
65 * and will update the modtime, modby, and modwho fields in the entry in
66 * the table whose id matches argv[0].
69 set_modtime_by_id(q, argv, cl)
74 char *entity, *table, *id_name;
80 id_name = q->validate->object_id;
83 sprintf(stmt_buf,"UPDATE %s SET modtime = 'now', modby = %d, \
84 modwith = '%s' WHERE %s.%s = %d",table,who,entity,table,id_name,id);
85 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
90 /* Sets the finger modtime on a user record. The users_id will be in argv[0].
93 set_finger_modtime(q, argv, cl)
98 EXEC SQL BEGIN DECLARE SECTION;
101 EXEC SQL END DECLARE SECTION;
105 users_id = *(int *)argv[0];
107 EXEC SQL UPDATE users SET fmodtime='now', fmodby = :who, fmodwith = :entity
108 WHERE users.users_id = :users_id;
114 /* Sets the pobox modtime on a user record. The users_id will be in argv[0].
117 set_pobox_modtime(q, argv, cl)
122 EXEC SQL BEGIN DECLARE SECTION;
125 EXEC SQL END DECLARE SECTION;
129 users_id = *(int *)argv[0];
131 EXEC SQL UPDATE users SET pmodtime='now', pmodby = :who, pmodwith = :entity
132 WHERE users.users_id = :users_id;
138 /* Like set_modtime, but uppercases the name first.
141 set_uppercase_modtime(q, argv, cl)
146 char *name, *entity, *table;
154 sprintf(stmt_buf,"UPDATE %s SET modtime = 'now', modby = %d, modwith = '%s' WHERE %s.name = UPPERCASE(LEFT('%s',SIZE(%s.name)))",table,who,entity,table,name,table);
155 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
161 /* Sets the modtime on the machine whose mach_id is in argv[0]. This routine
162 * is necessary for add_machine_to_cluster becuase the table that query
163 * operates on is "mcm", not "machine".
166 set_mach_modtime_by_id(q, argv, cl)
171 EXEC SQL BEGIN DECLARE SECTION;
174 EXEC SQL END DECLARE SECTION;
178 id = *(int *)argv[0];
179 EXEC SQL UPDATE machine SET modtime='now', modby = :who, modwith = :entity
180 WHERE machine.mach_id = :id;
186 /* Sets the modtime on the cluster whose mach_id is in argv[0]. This routine
187 * is necessary for add_cluster_data and delete_cluster_data becuase the
188 * table that query operates on is "svc", not "cluster".
191 set_cluster_modtime_by_id(q, argv, cl)
196 EXEC SQL BEGIN DECLARE SECTION;
199 EXEC SQL END DECLARE SECTION;
204 id = *(int *)argv[0];
205 EXEC SQL UPDATE cluster SET modtime='now', modby = :who, modwith = :entity
206 WHERE cluster.clu_id = :id;
211 /* sets the modtime on the serverhost where the service name is in argv[0]
212 * and the mach_id is in argv[1].
215 set_serverhost_modtime(q, argv, cl)
220 EXEC SQL BEGIN DECLARE SECTION;
223 EXEC SQL END DECLARE SECTION;
229 id = *(int *)argv[1];
230 EXEC SQL UPDATE serverhosts
231 SET modtime = 'now', modby = :who, modwith = :entity
232 WHERE service = :serv AND mach_id = :id;
237 /* sets the modtime on the nfsphys where the mach_id is in argv[0] and the
238 * directory name is in argv[1].
241 set_nfsphys_modtime(q, argv, cl)
246 EXEC SQL BEGIN DECLARE SECTION;
249 EXEC SQL END DECLARE SECTION;
254 id = *(int *)argv[0];
256 EXEC SQL UPDATE nfsphys SET modtime = 'now', modby = :who, modwith = :entity
257 WHERE dir = :dir AND mach_id = :id;
262 /* sets the modtime on a filesystem, where argv[0] contains the filesys
266 set_filesys_modtime(q, argv, cl)
271 EXEC SQL BEGIN DECLARE SECTION;
272 char *label, *entity;
274 extern int _var_phys_id;
276 EXEC SQL END DECLARE SECTION;
282 if (!strcmp(q->shortname, "ufil"))
285 EXEC SQL UPDATE filesys SET modtime = 'now', modby = :who,
286 modwith = :entity, phys_id = :_var_phys_id
287 WHERE label = LEFT(:label,SIZE(label));
292 /* sets the modtime on a zephyr class, where argv[0] contains the class
296 set_zephyr_modtime(q, argv, cl)
301 EXEC SQL BEGIN DECLARE SECTION;
302 char *class, *entity;
304 EXEC SQL END DECLARE SECTION;
311 EXEC SQL UPDATE zephyr SET modtime = 'now', modby = :who, modwith = :entity
312 WHERE class = LEFT(:class,SIZE(class));
318 /* fixes the modby field. This will be the second to last thing in the
319 * argv, the argv length is determined from the query structure. It is
320 * passed as a pointer to an integer. This will either turn it into a
321 * username, or # + the users_id.
323 followup_fix_modby(q, sq, v, action, actarg, cl)
325 register struct save_queue *sq;
327 register int (*action)();
336 while (sq_get_data(sq, &argv)) {
339 status = id_to_name(id, "USER", &argv[i]);
341 status = id_to_name(-id, "STRING", &argv[i]);
342 if (status && status != MR_NO_MATCH)
344 (*action)(q->vcnt, argv, actarg);
345 for (j = 0; j < q->vcnt; j++)
354 /* After retrieving a user account, fix the modby field and signature.
355 * The modby field is the second to last thing in the
356 * argv, the argv length is determined from the query structure. It is
357 * passed as a pointer to an integer. This will either turn it into a
358 * username, or # + the users_id. Only "gua*" queries have a signature,
359 * these are ones with U_END return values. "gub*" queries also use this
360 * routine but don't have a signature.
362 followup_guax(q, sq, v, action, actarg, cl)
364 register struct save_queue *sq;
366 register int (*action)();
373 unsigned char sigbuf[256];
376 EXEC SQL BEGIN DECLARE SECTION;
379 varchar struct { short data_size; char data_buf[257];} rsig;
380 EXEC SQL END DECLARE SECTION;
385 while (sq_get_data(sq, &argv)) {
387 com_err(whoami, 0, "argv[SIGNATURE] = \"%s\"", argv[U_SIGNATURE]);
391 status = id_to_name(id, "USER", &argv[i]);
393 status = id_to_name(-id, "STRING", &argv[i]);
394 if (status && status != MR_NO_MATCH)
397 if (q->vcnt == U_END && strlen(argv[U_SIGNATURE])) {
398 login = argv[U_NAME];
399 EXEC SQL REPEATED SELECT signature, sigdate, sigwho
400 INTO :rsig, :timestamp, :who FROM users
401 WHERE login = :login;
402 /** What about (INGRES) error handling? **/
404 status = id_to_name(who, "STRING", &kname);
405 si.timestamp = timestamp;
406 si.SigInfoVersion = 0; /* XXXXX this isn't used */
407 kname_parse(si.pname, si.pinst, si.prealm, kname);
409 rsig.data_buf[rsig.data_size] = 0;
410 si.rawsig = (unsigned char *)strsave(rsig.data_buf);
411 if (log_flags & LOG_GDSS)
412 com_err(whoami, 0, "rawsig length = %d, sig=\"%s\"", strlen(si.rawsig), si.rawsig);
413 GDSS_Recompose(&si, sigbuf);
415 free(argv[U_SIGNATURE]);
416 argv[U_SIGNATURE] = strsave(sigbuf);
417 if (log_flags & LOG_GDSS)
418 com_err(whoami, 0, "generated signature length %d", strlen(sigbuf));
421 (*action)(q->vcnt, argv, actarg);
422 for (j = 0; j < q->vcnt; j++)
432 ** followup_ausr - add finger and pobox entries, set_user_modtime
435 ** argv[0] - login (add_user)
436 ** argv[3] - last name
437 ** argv[4] - first name
438 ** argv[5] - middle name
442 followup_ausr(q, argv, cl)
447 EXEC SQL BEGIN DECLARE SECTION;
449 char *login, *entity, *src, *dst, *name;
451 EXEC SQL END DECLARE SECTION;
453 char databuf[32], *kname_unparse();
454 EXEC SQL BEGIN DECLARE SECTION;
456 int sigwho, timestamp;
457 EXEC SQL END DECLARE SECTION;
462 if (strlen(argv[4]) && strlen(argv[5]))
463 sprintf(fullname, "%s %s %s", argv[4], argv[5], argv[3]);
464 else if (strlen(argv[4]))
465 sprintf(fullname, "%s %s", argv[4], argv[3]);
467 sprintf(fullname, "%s", argv[3]);
470 if (q->vcnt == U_END && *argv[U_SIGNATURE]) {
471 /* unquote ' chars in signature */
472 for (dst = src = argv[U_SIGNATURE]; *src; ) {
478 sprintf(databuf, "%s:%s", argv[U_NAME], argv[U_MITID]);
479 /* skip bytes for timestamp & kname */
480 si.rawsig = (unsigned char *) rawsig;
481 status = GDSS_Verify(databuf, strlen(databuf), argv[U_SIGNATURE], &si);
482 if (strlen(rawsig) > mr_sig_length) {
483 com_err(whoami, 0, "GDSS signature would be truncated."); /** untested **/
487 name = kname_unparse(si.pname, si.pinst, si.prealm);
488 status = name_to_id(name, "STRING", &sigwho);
489 if (status == MR_NO_MATCH) {
490 sigwho=add_string(name);
493 timestamp = si.timestamp;
495 if (log_flags & LOG_GDSS)
496 hex_dump(argv[U_SIGNATURE]);
497 return(gdss2et(status));
510 /* create finger entry, pobox & set modtime on user */
512 EXEC SQL REPEATED UPDATE users
513 SET modtime='now', modby=:who, modwith = :entity,
514 fullname = :fullname, affiliation = type,
515 signature = :rawsig, sigdate = :timestamp, sigwho = :sigwho,
516 fmodtime='now', fmodby = :who, fmodwith = :entity,
517 potype='NONE', pmodtime='now', pmodby = :who, pmodwith = :entity
518 WHERE login = :login;
520 EXEC SQL REPEATED UPDATE users
521 SET modtime='now', modby=:who, modwith = :entity,
522 fullname = :fullname, affiliation = type,
523 fmodtime='now', fmodby = :who, fmodwith = :entity,
524 potype='NONE', pmodtime='now', pmodby = :who, pmodwith = :entity
525 WHERE login = :login;
533 ** followup_uusr - do signature, set_user_modtime
536 ** argv[0] - login (add_user)
537 ** argv[U_SIGNATURE] - sig
541 followup_uuac(q, argv, cl)
546 EXEC SQL BEGIN DECLARE SECTION;
548 char *entity, *name, *src, *dst;
549 EXEC SQL END DECLARE SECTION;
551 char databuf[32], *kname_unparse();
552 EXEC SQL BEGIN DECLARE SECTION;
555 int sigwho, timestamp;
556 EXEC SQL END DECLARE SECTION;
560 id = *(int *)argv[0];
565 if (q->vcnt == U_MODTIME && *argv[U_SIGNATURE + 1]) {
566 /* unquote ' chars in signature */
567 for (dst = src = argv[U_SIGNATURE+1]; *src; ) {
574 status = id_to_name(id, "USER", &login);
575 sprintf(databuf, "%s:%s", login, argv[U_MITID+1]);
577 /* skip bytes for timestamp & kname */
578 si.rawsig = (unsigned char *) rawsig;
580 com_err(whoami, 0, "verifying sig");
582 status = GDSS_Verify(databuf, strlen(databuf), argv[U_SIGNATURE+1], &si);
584 com_err(whoami, 0, "verified");
586 if (strlen(rawsig) > mr_sig_length) {
587 com_err(whoami, 0, "GDSS signature would be truncated."); /** untested **/
591 name = kname_unparse(si.pname, si.pinst, si.prealm);
592 status = name_to_id(name, "STRING", &sigwho);
593 if (status == MR_NO_MATCH) {
594 sigwho=add_string(name);
597 timestamp = si.timestamp;
599 if (log_flags & LOG_GDSS)
600 hex_dump(argv[U_SIGNATURE+1]);
601 return(gdss2et(status));
610 /* create finger entry, pobox & set modtime on user */
613 EXEC SQL REPEATED UPDATE users SET modtime='now', modby = :who, modwith = :entity,
614 signature = :rawsig, sigdate = :timestamp, sigwho = :sigwho
615 WHERE users_id = :id;
617 EXEC SQL REPEATED UPDATE users SET modtime='now', modby = :who, modwith = :entity
618 WHERE users_id = :id;
624 /* followup_gpob: fixes argv[2] based on the IDs currently there and the
625 * type in argv[1]. Then completes the upcall to the user.
627 * argv[2] is of the form "123:234" where the first integer is the machine
628 * ID if it is a pop box, and the second is the string ID if it is an SMTP
629 * box. argv[1] should be "POP", "SMTP", or "NONE". Boxes of type NONE
633 followup_gpob(q, sq, v, action, actarg, cl)
634 register struct query *q;
635 register struct save_queue *sq;
636 register struct validate *v;
637 register int (*action)();
643 int mid, sid, status, i;
646 while (sq_get_data(sq, &argv)) {
647 mr_trim_args(2, argv);
649 p = index(argv[2], ':');
654 if (!strcmp(ptype, "POP")) {
655 status = id_to_name(mid, "MACHINE", &argv[2]);
656 if (status == MR_NO_MATCH)
658 } else if (!strcmp(ptype, "SMTP")) {
659 status = id_to_name(sid, "STRING", &argv[2]);
660 if (status == MR_NO_MATCH)
662 } else /* ptype == "NONE" */ {
665 if (status) return(status);
667 if (!strcmp(q->shortname, "gpob")) {
670 status = id_to_name(sid, "USER", &argv[4]);
672 status = id_to_name(-sid, "STRING", &argv[4]);
674 if (status && status != MR_NO_MATCH) return(status);
676 (*action)(q->vcnt, argv, actarg);
678 /* free saved data */
679 for (i = 0; i < q->vcnt; i++)
689 /* followup_gsnt: fix the ace_name in argv[7]. argv[6] will contain the
690 * ace_type: "LIST", "USER", or "NONE". Decode the id in argv[7] into the
691 * proper name based on the type, and repace that string in the argv.
692 * Also fixes the modby field by called followup_fix_modby.
695 followup_gsnt(q, sq, v, action, actarg, cl)
696 register struct query *q;
697 register struct save_queue *sq;
698 register struct validate *v;
699 register int (*action)();
704 int id, i, idx, status;
708 while (sq_get_data(sq, &argv)) {
709 mr_trim_args(q->vcnt, argv);
711 id = atoi(argv[i = q->vcnt - 2]);
713 status = id_to_name(id, "USER", &argv[i]);
715 status = id_to_name(-id, "STRING", &argv[i]);
716 if (status && status != MR_NO_MATCH)
719 id = atoi(argv[idx]);
720 type = argv[idx - 1];
722 if (!strcmp(type, "LIST")) {
723 status = id_to_name(id, "LIST", &argv[idx]);
724 } else if (!strcmp(type, "USER")) {
725 status = id_to_name(id, "USER", &argv[idx]);
726 } else if (!strcmp(type, "KERBEROS")) {
727 status = id_to_name(id, "STRING", &argv[idx]);
728 } else if (!strcmp(type, "NONE")) {
731 argv[idx] = strsave("NONE");
735 argv[idx] = strsave("???");
737 if (status && status != MR_NO_MATCH)
741 (*action)(q->vcnt, argv, actarg);
743 /* free saved data */
744 for (i = 0; i < q->vcnt; i++)
754 /* followup_ghst: fix the ace_name in argv[12]. argv[11] will contain the
755 * ace_type: "LIST", "USER", or "NONE". Decode the id in argv[12] into the
756 * proper name based on the type, and repace that string in the argv.
757 * Also fixes the modby field by called followup_fix_modby.
760 followup_ghst(q, sq, v, action, actarg, cl)
761 register struct query *q;
762 register struct save_queue *sq;
763 register struct validate *v;
764 register int (*action)();
769 int id, i, idx, status;
771 while (sq_get_data(sq, &argv)) {
772 mr_trim_args(q->vcnt, argv);
774 id = atoi(argv[i = q->vcnt - 2]);
776 status = id_to_name(id, "USER", &argv[i]);
778 status = id_to_name(-id, "STRING", &argv[i]);
779 if (status && status != MR_NO_MATCH)
783 status = id_to_name(id, "STRING", &argv[13]);
784 if (status) return(status);
786 status = id_to_name(id, "STRING", &argv[14]);
787 if (status) return(status);
790 status = id_to_name(-id, "STRING", &argv[16]);
792 status = id_to_name(id, "USER", &argv[16]);
793 if (status && status != MR_NO_MATCH)
797 id = atoi(argv[idx]);
798 type = strtrim(argv[idx - 1]);
800 if (!strcmp(type, "LIST")) {
801 status = id_to_name(id, "LIST", &argv[idx]);
802 } else if (!strcmp(type, "USER")) {
803 status = id_to_name(id, "USER", &argv[idx]);
804 } else if (!strcmp(type, "KERBEROS")) {
805 status = id_to_name(id, "STRING", &argv[idx]);
806 } else if (!strcmp(type, "NONE")) {
809 argv[idx] = strsave("NONE");
813 argv[idx] = strsave("???");
815 if (status && status != MR_NO_MATCH)
819 (*action)(q->vcnt, argv, actarg);
821 /* free saved data */
822 for (i = 0; i < q->vcnt; i++)
832 /* followup_glin: fix the ace_name in argv[8]. argv[7] will contain the
833 * ace_type: "LIST", "USER", or "NONE". Decode the id in argv[8] into the
834 * proper name based on the type, and repace that string in the argv.
835 * Also fixes the modby field by called followup_fix_modby.
838 followup_glin(q, sq, v, action, actarg, cl)
839 register struct query *q;
840 register struct save_queue *sq;
841 register struct validate *v;
842 register int (*action)();
847 int id, i, idx, status;
850 if (!strcmp(q->shortname, "gsin"))
853 while (sq_get_data(sq, &argv)) {
854 mr_trim_args(q->vcnt, argv);
856 id = atoi(argv[i = q->vcnt - 2]);
858 status = id_to_name(id, "USER", &argv[i]);
860 status = id_to_name(-id, "STRING", &argv[i]);
861 if (status && status != MR_NO_MATCH)
864 id = atoi(argv[idx]);
865 type = argv[idx - 1];
867 if (!strcmp(type, "LIST")) {
868 status = id_to_name(id, "LIST", &argv[idx]);
869 } else if (!strcmp(type, "USER")) {
870 status = id_to_name(id, "USER", &argv[idx]);
871 } else if (!strcmp(type, "KERBEROS")) {
872 status = id_to_name(id, "STRING", &argv[idx]);
873 } else if (!strcmp(type, "NONE")) {
876 argv[idx] = strsave("NONE");
880 argv[idx] = strsave("???");
882 if (status && status != MR_NO_MATCH)
885 if (!strcmp(q->shortname, "glin") && atoi(argv[6]) == -1) {
886 argv[6] = realloc(argv[6], strlen(UNIQUE_GID) + 1);
887 strcpy(argv[6], UNIQUE_GID);
891 (*action)(q->vcnt, argv, actarg);
893 /* free saved data */
894 for (i = 0; i < q->vcnt; i++)
904 /* followup_gqot: Fix the entity name, directory name & modby fields
905 * argv[0] = filsys_id
907 * argv[2] = entity_id
908 * argv[3] = ascii(quota)
911 followup_gqot(q, sq, v, action, actarg, cl)
913 register struct save_queue *sq;
915 register int (*action)();
921 EXEC SQL BEGIN DECLARE SECTION;
924 EXEC SQL END DECLARE SECTION;
927 if (!strcmp(q->name, "get_quota") ||
928 !strcmp(q->name, "get_quota_by_filesys"))
932 while (sq_get_data(sq, &argv)) {
934 switch (argv[1][0]) {
936 status = id_to_name(atoi(argv[2]), "USER", &argv[2]);
940 status = id_to_name(atoi(argv[2]), "LIST", &argv[2]);
944 argv[2] = strsave("system:anyuser");
949 sprintf(argv[2], "%d", id);
952 id = atoi(argv[idx]);
954 argv[idx] = malloc(256);
958 EXEC SQL REPEATED SELECT name INTO :name FROM filesys
959 WHERE label = :label;
961 EXEC SQL REPEATED SELECT dir INTO :name FROM nfsphys
962 WHERE nfsphys_id = :id;
964 if (sqlca.sqlerrd[2] != 1) {
965 sprintf(argv[idx], "#%d", id);
968 id = atoi(argv[idx+3]);
970 status = id_to_name(id, "USER", &argv[idx+3]);
972 status = id_to_name(-id, "STRING", &argv[idx+3]);
973 if (status && status != MR_NO_MATCH)
975 (*action)(q->vcnt, argv, actarg);
976 for (j = 0; j < q->vcnt; j++)
985 /* followup_aqot: Add allocation to nfsphys after creating quota.
986 * argv[0] = filsys_id
987 * argv[1] = type if "add_quota" or "update_quota"
989 * argv[3 or 2] = ascii(quota)
992 followup_aqot(q, argv, cl)
997 EXEC SQL BEGIN DECLARE SECTION;
998 int quota, id, fs, who, physid;
999 char *entity, *qtype, *table_name;
1000 EXEC SQL END DECLARE SECTION;
1005 table_name=q->rtable;
1006 fs = *(int *)argv[0];
1007 EXEC SQL REPEATED SELECT phys_id INTO :physid FROM filesys
1008 WHERE filsys_id = :fs;
1012 if (!strcmp(q->shortname, "aqot") || !strcmp(q->shortname, "uqot")) {
1014 id = *(int *)argv[2];
1015 quota = atoi(argv[3]);
1016 sprintf(incr_qual,"q.filsys_id = %d",fs);
1019 id = *(int *)argv[1];
1020 quota = atoi(argv[2]);
1021 sprintf(incr_qual,"q.filsys_id=%d AND q.type='%s' AND q.entity_id=%d",
1025 /* quota case of incremental_{before|after} only looks at slot 1 */
1028 /* Follows one of many possible gross hacks to fix these particular
1029 * conflicts between what is possible in the query table and what
1030 * is possible in SQL.
1032 if(q->type==APPEND) {
1033 incremental_clear_before();
1034 EXEC SQL INSERT INTO quota
1035 (filsys_id, type, entity_id, quota, phys_id)
1036 VALUES (:fs, :qtype, :id, :quota, :physid);
1037 incremental_after(table_name, incr_qual, incr_argv);
1039 incremental_before(table_name, incr_qual, incr_argv);
1040 EXEC SQL UPDATE quota SET quota = :quota
1041 WHERE filsys_id = :fs AND type = :qtype AND entity_id = :id;
1042 status = mr_errcode;
1043 incremental_after(table_name, incr_qual, incr_argv);
1048 flush_name(argv[0], q->rtable);
1049 if(q->type==APPEND) {
1050 EXEC SQL UPDATE tblstats SET appends = appends + 1, modtime = 'now'
1051 WHERE table_name = :table_name;
1053 EXEC SQL UPDATE tblstats SET updates = updates + 1, modtime = 'now'
1054 WHERE table_name = :table_name;
1057 /* Proceed with original followup */
1058 who = cl->client_id;
1059 entity = cl->entity;
1061 EXEC SQL REPEATED UPDATE quota
1062 SET modtime = 'now', modby = :who, modwith = :entity
1063 WHERE filsys_id = :fs and type = :qtype and entity_id = :id;
1064 EXEC SQL REPEATED UPDATE nfsphys SET allocated = allocated + :quota
1065 WHERE nfsphys_id = :physid;
1066 if (ingres_errno) return(mr_errcode);
1071 /* Necessitated by the requirement of a correlation name by the incremental
1072 * routines, since query table deletes don't provide one.
1074 followup_dqot(q,argv,cl)
1082 EXEC SQL BEGIN DECLARE SECTION;
1085 EXEC SQL END DECLARE SECTION;
1087 fs = *(int *)argv[0];
1088 if (!strcmp(q->shortname, "dqot")) {
1090 id = *(int *)argv[2];
1093 id = *(int *)argv[1];
1095 sprintf(incr_qual,"q.filsys_id=%d AND q.type='%s' AND q.entity_id=%d",
1098 /* quota case of incremental_{before|after} only looks at slot 1 */
1101 incremental_before(q->rtable, incr_qual, incr_argv);
1102 EXEC SQL DELETE FROM quota q WHERE :incr_qual;
1103 incremental_clear_after();
1107 flush_name(argv[0], q->rtable);
1109 tblname = q->rtable;
1110 EXEC SQL UPDATE tblstats SET deletes = deletes + 1, modtime = 'now'
1111 WHERE table_name = :tblname;
1116 followup_gpce(q, sq, v, action, actarg, cl)
1118 register struct save_queue *sq;
1120 register int (*action)();
1121 register int actarg;
1129 while (sq_get_data(sq, &argv)) {
1130 id = atoi(argv[PCAP_QSERVER]);
1131 status = id_to_name(id, "MACHINE", &argv[PCAP_QSERVER]);
1132 if (status) return (status);
1135 status = id_to_name(id, "USER", &argv[i]);
1137 status = id_to_name(-id, "STRING", &argv[i]);
1138 if (status && status != MR_NO_MATCH)
1140 (*action)(q->vcnt, argv, actarg);
1141 for (j = 0; j < q->vcnt; j++)
1153 followup_gzcl(q, sq, v, action, actarg, cl)
1154 register struct query *q;
1155 register struct save_queue *sq;
1156 register struct validate *v;
1157 register int (*action)();
1164 while (sq_get_data(sq, &argv)) {
1165 mr_trim_args(q->vcnt, argv);
1167 id = atoi(argv[i = q->vcnt - 2]);
1169 status = id_to_name(id, "USER", &argv[i]);
1171 status = id_to_name(-id, "STRING", &argv[i]);
1172 if (status && status != MR_NO_MATCH)
1175 for (i = 1; i < 8; i+=2) {
1176 id = atoi(argv[i+1]);
1177 if (!strcmp(argv[i], "LIST")) {
1178 status = id_to_name(id, "LIST", &argv[i+1]);
1179 } else if (!strcmp(argv[i], "USER")) {
1180 status = id_to_name(id, "USER", &argv[i+1]);
1181 } else if (!strcmp(argv[i], "KERBEROS")) {
1182 status = id_to_name(id, "STRING", &argv[i+1]);
1183 } else if (!strcmp(argv[i], "NONE")) {
1186 argv[i+1] = strsave("NONE");
1190 argv[i+1] = strsave("???");
1192 if (status && status != MR_NO_MATCH)
1197 (*action)(q->vcnt, argv, actarg);
1199 /* free saved data */
1200 for (i = 0; i < q->vcnt; i++)
1212 followup_gsha(q, sq, v, action, actarg, cl)
1213 register struct query *q;
1214 register struct save_queue *sq;
1215 register struct validate *v;
1216 register int (*action)();
1223 while (sq_get_data(sq, &argv)) {
1224 mr_trim_args(q->vcnt, argv);
1228 status = id_to_name(id, "USER", &argv[4]);
1230 status = id_to_name(-id, "STRING", &argv[4]);
1231 if (status && status != MR_NO_MATCH)
1235 if (!strcmp(argv[1], "LIST")) {
1236 status = id_to_name(id, "LIST", &argv[2]);
1237 } else if (!strcmp(argv[1], "USER")) {
1238 status = id_to_name(id, "USER", &argv[2]);
1239 } else if (!strcmp(argv[1], "KERBEROS")) {
1240 status = id_to_name(id, "STRING", &argv[2]);
1241 } else if (!strcmp(argv[1], "NONE")) {
1244 argv[2] = strsave("NONE");
1248 argv[2] = strsave("???");
1250 if (status && status != MR_NO_MATCH)
1254 (*action)(q->vcnt, argv, actarg);
1256 /* free saved data */
1257 for (i = 0; i < q->vcnt; i++)
1266 int _sdl_followup(q, argv, cl)
1275 EXEC SQL set printqry;
1277 EXEC SQL set noprintqry;
1289 fprintf(stderr, "Size: %d\n", strlen(p));
1290 while (strlen(p) >= 8) {
1291 fprintf(stderr, "%02x %02x %02x %02x %02x %02x %02x %02x\n",
1292 p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
1295 switch (strlen(p)) {
1297 fprintf(stderr, "%02x %02x %02x %02x %02x %02x %02x\n",
1298 p[0], p[1], p[2], p[3], p[4], p[5], p[6]);
1301 fprintf(stderr, "%02x %02x %02x %02x %02x %02x\n",
1302 p[0], p[1], p[2], p[3], p[4], p[5]);
1305 fprintf(stderr, "%02x %02x %02x %02x %02x\n",
1306 p[0], p[1], p[2], p[3], p[4]);
1309 fprintf(stderr, "%02x %02x %02x %02x\n",
1310 p[0], p[1], p[2], p[3]);
1313 fprintf(stderr, "%02x %02x %02x\n",
1317 fprintf(stderr, "%02x %02x\n",
1321 fprintf(stderr, "%02x\n",