]> andersk Git - moira.git/blobdiff - server/qsupport.dc
Kludge around Ingres brokenness in two places:
[moira.git] / server / qsupport.dc
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 */
This page took 0.038789 seconds and 4 git commands to generate.