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;
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 */
int get_lists_of_member();
int register_user();
int _sdl_followup();
+int get_hostalias();
\f
0,
access_ahal,
0,
- 0,
+ get_hostalias,
};
static struct valobj ahal_valobj[] = {
"get_hostalias",
"ghal",
RETRIEVE,
- "a",
+ 0,
"hostalias",
"CHAR(a.name), CHAR(m.name) FROM hostalias a, machine m",
ghal_fields,