]> andersk Git - moira.git/commitdiff
Kludge around Ingres brokenness in two places:
authordanw <danw>
Sun, 29 Sep 1996 20:24:42 +0000 (20:24 +0000)
committerdanw <danw>
Sun, 29 Sep 1996 20:24:42 +0000 (20:24 +0000)
  * get_hostalias - If the machine name has no wildcards, look up
    its mach_id and then do the query indexed by that instead of
    by the machine name. This takes less than a second, vs. up to a
    minute or so the other way. (This speeds up the `show machine
    info' command in moira, which is used a lot by the RCCs this time
    of year.)

  * get_user_account_by_login - the sipb-athena moira client was
    built from an older source tree that didn't have the patch
    to never call gual with a string longer than 8 characters.
    I hacked access_login to notice this and return an error.
    (Because otherwise, it takes the server several minutes to
    return `permission denied' when a user tries to use the `create
    mailing list' command.)

Neither of these will be propagated to the Oracle server since it
doesn't have a problem with either of those queries.

server/qaccess.dc
server/qsupport.dc
server/queries2.c

index 8e0dd44051f209db4031db320905d168911a5a39..d710e5e08e76f06e59de954708353b4a21c334f7 100644 (file)
@@ -67,6 +67,15 @@ access_login(q, argv, cl)
     char qual[256];
     EXEC SQL END DECLARE SECTION;
 
+    /* BEGIN KLUDGE
+       Ingres will lose horribly if you try to look up a user with
+       a username > 8 chars (which some old versions of the moira client
+       still sometimes do). This routine is only called by gubl/gual and
+       gubu/guau, so we know argv[0] must be <=8 chars in a correct
+       query, so verify that first */
+    if(strlen(argv[0])>8) return MR_ARG_TOO_LONG;
+    /* END KLUDGE */
+
     build_qual(q->qual, q->argc, argv, qual);
     if (!strncmp(q->name,"get_user_account",strlen("get_user_account"))) {
        EXEC SQL SELECT users_id INTO :id FROM users u, strings str WHERE :qual;
index 80717696b981324e8ddf489986e9a12a182e7988..038e92a32cfebbb7783356a4bb44499ac4b71842 100644 (file)
@@ -1461,3 +1461,42 @@ int set_pop_usage(id, cnt)
     return(MR_SUCCESS);
 }
 
+
+/* BEGIN KLUDGE
+   special-case `ghal "*" "name"' since Ingres does it slowly */
+
+int get_hostalias(q, argv, cl, action, actarg)
+    struct query *q;
+    char *argv[];
+    client *cl;
+    int (*action)();
+    int actarg;
+{
+    EXEC SQL BEGIN DECLARE SECTION;
+    char *alias=argv[0], *machine=argv[1], qual[BUFSIZ], *p;
+    int id;
+    EXEC SQL END DECLARE SECTION;
+
+    for(p=machine; *p; p++) {
+      if(*p=='%' || *p=='_') break;
+      if(*p=='*') {
+      p++;
+      if(*p=='%') p++;
+      }
+    }
+    if(!*p) {
+      /* machine has no wildcards, so we can do it the fast way */
+      EXEC SQL REPEATED SELECT mach_id INTO :id FROM machine
+      WHERE name=:machine;
+      if(ingres_errno) return(mr_errcode);
+      
+      sprintf(qual, "a.mach_id = %d AND m.mach_id = %d AND a.name LIKE '%s' ESCAPE '*'", id, id, alias);
+      return do_retrieve(q, qual, 0, action, actarg);
+    }
+
+    /* not the special case... do the normal query */
+    build_qual(q->qual, q->argc, argv, qual); 
+    return do_retrieve(q, qual, 0, action, actarg);
+}
+
+/* END KLUDGE */
index e13efc729bdf355ad64eb55cf556a3438c47d8ba..cf0dcb14a730714d212c7f8e14cb250f17deaf30 100644 (file)
@@ -97,6 +97,7 @@ int count_members_of_list();
 int get_lists_of_member();
 int register_user();
 int _sdl_followup();
+int get_hostalias();
 
 
 \f
@@ -898,7 +899,7 @@ static struct validate ghal_validate = {
   0,
   access_ahal,
   0,
-  0,
+  get_hostalias,
 };
 
 static struct valobj ahal_valobj[] = {
@@ -3049,7 +3050,7 @@ struct query Queries2[] = {
     "get_hostalias",
     "ghal",
     RETRIEVE,
-    "a",
+    0,
     "hostalias",
     "CHAR(a.name), CHAR(m.name) FROM hostalias a, machine m",
     ghal_fields,
This page took 0.055375 seconds and 5 git commands to generate.