From 4872dc73f13a2944bd6f7fac2c7335a2c891072b Mon Sep 17 00:00:00 2001 From: danw Date: Sun, 29 Sep 1996 20:24:42 +0000 Subject: [PATCH 1/1] Kludge around Ingres brokenness in two places: * 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 | 9 +++++++++ server/qsupport.dc | 39 +++++++++++++++++++++++++++++++++++++++ server/queries2.c | 5 +++-- 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/server/qaccess.dc b/server/qaccess.dc index 8e0dd440..d710e5e0 100644 --- a/server/qaccess.dc +++ b/server/qaccess.dc @@ -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; diff --git a/server/qsupport.dc b/server/qsupport.dc index 80717696..038e92a3 100644 --- a/server/qsupport.dc +++ b/server/qsupport.dc @@ -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 */ diff --git a/server/queries2.c b/server/queries2.c index e13efc72..cf0dcb14 100644 --- a/server/queries2.c +++ b/server/queries2.c @@ -97,6 +97,7 @@ int count_members_of_list(); int get_lists_of_member(); int register_user(); int _sdl_followup(); +int get_hostalias(); @@ -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, -- 2.45.2