From: genoa Date: Wed, 15 Jul 1992 18:00:18 +0000 (+0000) Subject: Many bug-fixes. At least 30 queries work (but still no wildcards.) X-Git-Tag: release77~480 X-Git-Url: http://andersk.mit.edu/gitweb/moira.git/commitdiff_plain/45bf75734b854005f8e310d6c066a19a4bd21645 Many bug-fixes. At least 30 queries work (but still no wildcards.) --- diff --git a/server/cache.dc b/server/cache.dc index 6e621b80..346245da 100644 --- a/server/cache.dc +++ b/server/cache.dc @@ -15,6 +15,7 @@ static char *rcsid_cache_dc = "$Header$"; #include "mr_server.h" EXEC SQL INCLUDE sqlca; +EXEC SQL WHENEVER SQLERROR CALL ingerr; extern char *whoami, *strsave(); extern int ingres_errno, mr_errcode; @@ -207,7 +208,7 @@ int id; char *type; char **name; { - register struct item *i; + register struct item *i, *t; EXEC SQL BEGIN DECLARE SECTION; char iname[NAMESZ]; int j, rowcount; diff --git a/server/increment.dc b/server/increment.dc index cdf816e2..8d9d5c51 100644 --- a/server/increment.dc +++ b/server/increment.dc @@ -17,7 +17,7 @@ static char *rcsid_increment_dc = "$Header$"; #include #include "query.h" #include "mr_server.h" -EXEC SQL INCLUDE sqlca +EXEC SQL INCLUDE sqlca; extern char *whoami; char *malloc(); @@ -28,6 +28,8 @@ time_t inc_started; #define MAXARGC 15 +EXEC SQL WHENEVER SQLERROR CALL ingerr; + /* structures to save before args */ static char beforeb[MAXARGC][ARGLEN]; static char *before[MAXARGC]; @@ -109,7 +111,9 @@ incremental_init() incremental_before(table, qual, argv) char *table; +EXEC SQL BEGIN DECLARE SECTION; char *qual; +EXEC SQL END DECLARE SECTION; char **argv; { EXEC SQL BEGIN DECLARE SECTION; @@ -128,8 +132,8 @@ char **argv; * barg7 = u.mit_id, barg8 = u.mit_year) * where qual */ - EXEC SQL SELECT login, uid, shell, last, first, middle, - text(u.status), mit_id, mit_year + EXEC SQL SELECT login, CHAR(uid), shell, last, first, middle, + CHAR(status), clearid, type INTO :barg0, :barg1, :barg2, :barg3, :barg4, :barg5, :barg6, :barg7, :barg8 FROM users WHERE :qual; @@ -146,7 +150,8 @@ char **argv; * retrieve (barg0 = c.name, barg1 = c.desc, barg2 = c.location) * where qual */ - EXEC SQL SELECT name, desc, location INTO :barg0, :barg1, :barg2 + EXEC SQL SELECT name, description, location + INTO :barg0, :barg1, :barg2 FROM cluster WHERE :qual; beforec = 3; } else if (!strcmp(table, "mcmap")) { @@ -168,8 +173,8 @@ char **argv; * barg10 = fs.lockertype) * where qual */ - EXEC SQL SELECT label, type, text(mach_id), name, mount, access, - comments, text(owner), text(owners), text(createflag), lockertype + EXEC SQL SELECT label, type, CHAR(mach_id), name, mount, access, + comments, CHAR(owner), CHAR(owners), CHAR(createflag), lockertype INTO :barg0, :barg1, :barg2, :barg3, :barg4, :barg5, :barg6, :barg7, :barg8, :barg9, :barg10 FROM filesys WHERE :qual; @@ -196,9 +201,9 @@ char **argv; * barg8 = text(l.acl_id), barg9 = l.desc) * where qual */ - EXEC SQL SELECT name, text(active), text(public), text(hidden), - text(maillist), text(grouplist), text(gid), acl_type, - text(acl_id), desc + EXEC SQL SELECT name, CHAR(active), CHAR(publicflg), CHAR(hidden), + CHAR(maillist), CHAR(grouplist), CHAR(gid), acl_type, + CHAR(acl_id), description INTO :barg0, :barg1, :barg2, :barg3, :barg4, :barg5, :barg6, :barg7, :barg8, :barg9 FROM list WHERE :qual; @@ -208,7 +213,7 @@ char **argv; /* * retrieve (barg3 = text(list.group)) where list.list_id = id */ - EXEC SQL SELECT text(list.group) INTO :barg3 FROM list + EXEC SQL SELECT CHAR(grouplist) INTO :barg3 FROM list WHERE list_id = :id; name = malloc(0); id_to_name(id, "LIST", &name); @@ -245,8 +250,8 @@ incremental_clear_after() incremental_after(table, qual, argv) -EXEC SQL BEGIN DECLARE SECTION; char *table; +EXEC SQL BEGIN DECLARE SECTION; char *qual; EXEC SQL END DECLARE SECTION; char **argv; @@ -266,8 +271,8 @@ EXEC SQL END DECLARE SECTION; * aarg7 = u.mit_id, aarg8 = u.mit_year) * where qual */ - EXEC SQL SELECT login, uid, shell, last, first, middle, - text(status), mit_id, mit_year + EXEC SQL SELECT login, CHAR(uid), shell, last, first, middle, + CHAR(status), clearid, type INTO :aarg0, :aarg1, :aarg2, :aarg3, :aarg4, :aarg5, :aarg6, :aarg7, :aarg8 FROM users WHERE :qual; @@ -284,7 +289,8 @@ EXEC SQL END DECLARE SECTION; * retrieve (aarg0 = c.name, aarg1 = c.desc, aarg2 = c.location) * where qual */ - EXEC SQL SELECT name, desc, location INTO :aarg0, :aarg1, :aarg2 + EXEC SQL SELECT name, description, location + INTO :aarg0, :aarg1, :aarg2 FROM cluster WHERE :qual; afterc = 3; } else if (!strcmp(table, "mcmap")) { @@ -307,8 +313,8 @@ EXEC SQL END DECLARE SECTION; * aarg10 = fs.lockertype) * where qual */ - EXEC SQL SELECT label, type, text(mach_id), name, mount, access, - comments, text(owner), text(owners), text(createflag), lockertype + EXEC SQL SELECT label, type, CHAR(mach_id), name, mount, access, + comments, CHAR(owner), CHAR(owners), CHAR(createflag), lockertype INTO :aarg0, :aarg1, :aarg2, :aarg3, :aarg4, :aarg5, :aarg6, :aarg7, :aarg8, :aarg9, :aarg10 FROM filesys fs WHERE :qual; @@ -323,7 +329,7 @@ EXEC SQL END DECLARE SECTION; * range of q is quota * retrieve (aarg3 = text(q.quota), aarg4 = filesys.name) where qual */ - EXEC SQL SELECT text(q.quota), fs.name INTO :aarg3, :aarg4 + EXEC SQL SELECT CHAR(q.quota), fs.name INTO :aarg3, :aarg4 FROM quota q, filesys fs WHERE :qual; afterc = 5; } else if (!strcmp(table, "list")) { @@ -335,9 +341,9 @@ EXEC SQL END DECLARE SECTION; * aarg8 = text(l.acl_id), aarg9 = l.desc) * where qual */ - EXEC SQL SELECT name, text(active), text(public), text(hidden), - text(maillist), text(grouplist), text(gid), acl_type, - text(acl_id), desc + EXEC SQL SELECT name, CHAR(active), CHAR(publicflg), CHAR(hidden), + CHAR(maillist), CHAR(grouplist), CHAR(gid), acl_type, + CHAR(acl_id), description INTO :aarg0, :aarg1, :aarg2, :aarg3, :aarg4, :aarg5, :aarg6, :aarg7, :aarg8, :aarg9 FROM list WHERE :qual; @@ -347,7 +353,7 @@ EXEC SQL END DECLARE SECTION; /* * retrieve (aarg3 = text(list.group)) where list.list_id = id */ - EXEC SQL SELECT text(list.group) INTO :aarg3 FROM list + EXEC SQL SELECT CHAR(grouplist) INTO :aarg3 FROM list WHERE list_id = :id; name = malloc(0); id_to_name(id, "LIST", &name); @@ -430,7 +436,7 @@ incremental_update() if (!inited) { inited++; - EXEC SQL DECLARE inc CURSOR FOR SELECT table, service FROM incremental; + EXEC SQL DECLARE inc CURSOR FOR SELECT tablename, service FROM incremental; EXEC SQL OPEN inc; while (1) { EXEC SQL FETCH inc INTO :tab, :serv; diff --git a/server/qrtn.dc b/server/qrtn.dc index d3043948..97e8e1b6 100644 --- a/server/qrtn.dc +++ b/server/qrtn.dc @@ -42,6 +42,12 @@ extern FILE *journal; #define INGRES_BAD_DATE1 41206 #define INGRES_BAD_DATE2 40207 #define INGRES_DEADLOCK 49900 + +#define INGRES_BAD_COLUMN 30110 +#define INGRES_ASGN_ERR 40204 +#define INGRES_NO_CURSOR 30120 +#define INGRES_NO_STMT 30130 + /* #define INGRES_BAD_INT #define INGRES_TIMEOUT @@ -57,6 +63,9 @@ extern FILE *journal; void ingerr() { + EXEC SQL BEGIN DECLARE SECTION; + char err_msg[256]; + EXEC SQL END DECLARE SECTION; ingres_errno = -sqlca.sqlcode; switch (ingres_errno) { @@ -85,15 +94,36 @@ void ingerr() * com_err(whoami, 0, "INGRES missing range statement"); * break; */ +#ifdef NEVER + /* #ifdef-ing these out lets default: give me the INGRES text */ + case INGRES_BAD_COLUMN: + mr_errcode = MR_INTERNAL; + com_err(whoami, 0, "Bad column name in query table"); + break; + case INGRES_ASGN_ERR: + mr_errcode = MR_INTERNAL; + com_err(whoami, 0, "Error in SQL assignment statement"); + break; + case INGRES_NO_CURSOR: + mr_errcode = MR_INTERNAL; + com_err(whoami, 0, "Cursor not opened"); + break; + case INGRES_NO_STMT: + mr_errcode = MR_INTERNAL; + com_err(whoami, 0, "Statement not declared"); + break; +#endif default: /** Add the INGRES error_text to the alert message ??? **/ mr_errcode = MR_INGRES_ERR; - com_err(whoami, MR_INGRES_ERR, " code %d\n", sqlca.sqlcode); + com_err(whoami, MR_INGRES_ERR, " code %d\n", ingres_errno); + EXEC SQL INQUIRE_SQL(:err_msg = errortext); + com_err(whoami, 0, "SQL error text = %s", err_msg); critical_alert("MOIRA", "Moira server encountered INGRES ERROR %d", ingres_errno); } } -/* This is declarative, not executed. Applies from here on, in the file */ +/* This is declarative, not executed. Applies from here on, in this file. */ EXEC SQL WHENEVER SQLERROR CALL ingerr; int mr_open_database() @@ -301,11 +331,15 @@ mr_process_query(cl, name, argc, argv_ro, action, actarg) if (status != MR_NO_MATCH) break; } +#ifdef NEVER + /* This is now done by a valobj, which also fetches the id value */ + /* increment id number if necessary */ if (v->object_id) { status = set_next_object_id(v->object_id, q->rtable, 0); if (status != MR_SUCCESS) break; } +#endif /* build "where" clause if needed */ if (q->qual) { @@ -322,8 +356,8 @@ mr_process_query(cl, name, argc, argv_ro, action, actarg) status = do_append(q, &Argv[q->argc], pqual, action, actarg); if (status != MR_SUCCESS) break; if (v && v->object_id) { - sprintf(qual, "%s.%s = values.value and values.name = '%s'", - q->rtable, v->object_id, v->object_id); + sprintf(qual, "%s.%s = %s",q->rtable, v->object_id, + Argv[q->argc+q->vcnt]); incremental_after(q->rtable, qual, argv_ro); } else incremental_after(q->rtable, pqual, argv_ro); @@ -675,48 +709,16 @@ EXEC SQL END DECLARE SECTION; com_err(whoami, MR_NO_MEM, "setting up static argv"); exit(1); } - for (i = 0; i < QMAXARGS; i++) { + for (i = 0; i < QMAXARGS; i++) { vaddrs[i]=SQLDA->sqlvar[i].sqldata; } } -/* - * if (psort) { - * csort = psort; - * if (pqual) { - * cqual = pqual; - * retrieve unique (param (q->tlist, vaddrs)) where cqual - * sort by csort - * { - * (*action)(q->vcnt, vaddrs, actarg); - * } - * } else { - * retrieve unique (param (q->tlist, vaddrs)) - * sort by csort - * { - * (*action)(q->vcnt, vaddrs, actarg); - * } - * } - * - * } else { - * if (pqual) { - * cqual = pqual; - * retrieve unique (param (q->tlist, vaddrs)) where cqual - * { - * (*action)(q->vcnt, vaddrs, actarg); - * } - * } else { - * retrieve unique (param (q->tlist, vaddrs)) - * { - * (*action)(q->vcnt, vaddrs, actarg); - * } - * } - * } - */ - build_sql_stmt(stmt_buf,"SELECT",q->tlist,vaddrs,pqual); if(psort) { strcat(stmt_buf," ORDER BY "); strcat(stmt_buf,psort); } EXEC SQL PREPARE stmt INTO :SQLDA USING NAMES FROM :stmt_buf; + if(ingres_errno) + return(mr_errcode); if((mr_errcode=mr_check_SQLDA(SQLDA)) != MR_SUCCESS) return(mr_errcode); EXEC SQL DECLARE csr001 CURSOR FOR stmt; @@ -725,7 +727,6 @@ EXEC SQL END DECLARE SECTION; while(1) { EXEC SQL FETCH csr001 USING DESCRIPTOR :SQLDA; if(sqlca.sqlcode != 0) break; - mr_fix_nulls_in_SQLDA(SQLDA); (*action)(q->vcnt, vaddrs, actarg); rowcount++; } @@ -744,8 +745,8 @@ build_sql_stmt(result_buf,cmd,targetlist,argv,qual) { char fmt_buf[MR_STMTBUF_LEN]; char tmp_buf[16]; - char *res=result_buf, *tmp=tmp_buf, *fmt=fmt_buf; - int state; + register char *res=result_buf, *tmp=tmp_buf, *fmt=fmt_buf; + register int state; sprintf(fmt_buf,"%s %s",cmd,targetlist); if(qual) { strcat(fmt_buf," WHERE "); strcat(fmt_buf,qual); } @@ -756,7 +757,7 @@ build_sql_stmt(result_buf,cmd,targetlist,argv,qual) if(*fmt=='%') { /* formatting -> tmp */ *tmp++ = *fmt; state=1; - } else *res++ = *fmt; /* text -> res */ + } else *res++ = *fmt; /* text -> res */ break; case 1: if((*fmt=='%') && (tmp==tmp_buf+1)) { /* %% -> % */ @@ -768,7 +769,7 @@ build_sql_stmt(result_buf,cmd,targetlist,argv,qual) *tmp='\0'; tmp=tmp_buf; sprintf(res,tmp_buf,*argv++); /* print to result buffer */ - while(*res++) ; + while(*++res) ; state=0; } else *tmp++ = *fmt; /* keep copying the formatting to tmp */ break; @@ -838,43 +839,31 @@ set_next_object_id(object, table_name, limit) EXEC SQL BEGIN DECLARE SECTION; int value; EXEC SQL END DECLARE SECTION; - int rowcount=0; - + int starting_value; + EXEC SQL SELECT value INTO :value FROM numvalues WHERE name = :object; if (sqlca.sqlerrd[2] != 1) return(MR_NO_ID); -/* - * retrieve (exists = any(tbl.name where tbl.name = value)) - */ - sprintf(stmt_buf,"SELECT %s FROM %s WHERE %s=:value",object,table_name,object); /** Will this work??? */ - EXEC SQL PREPARE stmt INTO :SQLDA USING NAMES FROM :stmt_buf; - EXEC SQL DECLARE csr002 CURSOR FOR stmt; - - EXEC SQL OPEN csr002; - EXEC SQL FETCH csr002 USING DESCRIPTOR :SQLDA; - if(sqlca.sqlcode == 0) { - rowcount++; - EXEC SQL FETCH csr002 USING DESCRIPTOR :SQLDA; - if(sqlca.sqlcode == 0) rowcount++; - } - EXEC SQL CLOSE csr002; - - if (rowcount != 1) - return(MR_NO_ID); + starting_value=value; while (1) { - value++; - if (limit && value > MAX_ID_VALUE) /* Potential infinite loop */ - value = MIN_ID_VALUE; -/* - * retrieve (exists = any(tbl.name where tbl.name = value)) - */ - - /** Does the following work like I think it should ??? */ + if (limit && value > MAX_ID_VALUE) + value = MIN_ID_VALUE; + + sprintf(stmt_buf,"SELECT %s FROM %s WHERE %s=%d",object,table_name,object,value); + EXEC SQL PREPARE stmt INTO :SQLDA USING NAMES FROM :stmt_buf; + EXEC SQL DECLARE csr002 CURSOR FOR stmt; EXEC SQL OPEN csr002; - EXEC SQL FETCH csr002 USING DESCRIPTOR :SQLDA; - if(sqlca.sqlcode == 100) break; + EXEC SQL FETCH csr002 USING DESCRIPTOR :SQLDA; + if (sqlca.sqlcode < 0) return(mr_errcode); + if (sqlca.sqlcode == 100) break; + EXEC SQL CLOSE csr002; + value++; + if (limit && value == starting_value) { + com_err(whoami,0,"All id values have been used"); + return(MR_NO_ID); + } } EXEC SQL CLOSE csr002; diff --git a/server/qsupport.dc b/server/qsupport.dc index 59c5c439..6fca31de 100644 --- a/server/qsupport.dc +++ b/server/qsupport.dc @@ -30,7 +30,8 @@ extern int ingres_errno, mr_errcode; EXEC SQL BEGIN DECLARE SECTION; int idummy; -extern char *cdummy, *stmt_buf; +extern char cdummy[]; +extern char stmt_buf[]; EXEC SQL END DECLARE SECTION; /* Specialized Access Routines */ @@ -108,7 +109,7 @@ access_list(q, argv, cl) int client_id, status; list_id = *(int *)argv[0]; - EXEC SQL SELECT acl_id, acl_type, gid, public + EXEC SQL SELECT acl_id, acl_type, gid, publicflg INTO :acl_id, :acl_type, :gid, :flags FROM list WHERE list_id = :list_id; @@ -373,6 +374,9 @@ setup_ausr(q, argv, cl) sprintf(argv[0], "#%s", argv[row]); } + if((mr_errcode=prefetch_value(q,argv,cl))!=MR_SUCCESS) + return(mr_errcode); + return(MR_SUCCESS); } @@ -391,11 +395,9 @@ int setup_dusr(q, argv) id = *(int *)argv[0]; - /*? Can this get wildcarded users? What happens then?! */ - /*? How does the REPEATED keyword work? */ /* For now, only allow users to be deleted if their status is 0 */ EXEC SQL REPEATED SELECT status INTO :flag FROM users - WHERE user_id = :id; + WHERE users_id = :id; if (flag != 0 && flag != 4) return(MR_IN_USE); @@ -417,7 +419,7 @@ int setup_dusr(q, argv) if (sqlca.sqlerrd[2] > 0) return(MR_IN_USE); EXEC SQL REPEATED SELECT acl_id INTO :idummy FROM hostaccess - WHERE acl_d = :id AND acl_type = 'USER'; + WHERE acl_id = :id AND acl_type = 'USER'; if (sqlca.sqlerrd[2] > 0) return(MR_IN_USE); if (ingres_errno) @@ -557,9 +559,10 @@ int setup_dclu(q, argv) * at 6 & 7. */ -int setup_alis(q, argv) +int setup_alis(q, argv, cl) struct query *q; - char **argv; + char *argv[]; + client *cl; { EXEC SQL BEGIN DECLARE SECTION; int ngid; @@ -585,17 +588,20 @@ int setup_alis(q, argv) } } + if((mr_errcode=prefetch_value(q,argv,cl))!=MR_SUCCESS) + return(mr_errcode); + return(MR_SUCCESS); } -/* setup_dlist - verify that the list is no longer being referenced +/* setup_dlis - verify that the list is no longer being referenced * and may safely be deleted. */ int setup_dlis(q, argv) struct query *q; - char **argv; + char *argv[]; { EXEC SQL BEGIN DECLARE SECTION; int flag, id; @@ -732,9 +738,10 @@ EXEC SQL BEGIN DECLARE SECTION; static int var_phys_id; EXEC SQL END DECLARE SECTION; -setup_afil(q, argv) +setup_afil(q, argv, cl) struct query *q; char *argv[]; + client *cl; { char *type, *name; int mach_id; @@ -757,8 +764,11 @@ setup_afil(q, argv) if (!strcmp(type, "NFS")) return (check_nfs(mach_id, name, access)); - else - return(MR_SUCCESS); + + if((mr_errcode=prefetch_value(q,argv,cl))!=MR_SUCCESS) + return(mr_errcode); + + return(MR_SUCCESS); } @@ -1462,7 +1472,7 @@ followup_ausr(q, argv, cl) #ifdef GDSS EXEC SQL REPEATED UPDATE users SET modtime='now', modby=:who, modwith = :entity, - fullname = :fullname, mit_affil = mit_year, + fullname = :fullname, affiliation = type, signature = :rawsig, fmodtime='now', fmodby = :who, fmodwith = :entity, potype='NONE', pmodtime='now', pmodby = :who, pmodwith = :entity @@ -1470,7 +1480,7 @@ followup_ausr(q, argv, cl) #else /* GDSS */ EXEC SQL REPEATED UPDATE users SET modtime='now', modby=:who, modwith = :entity, - fullname = :fullname, mit_affil = mit_year, + fullname = :fullname, affiliation = type, fmodtime='now', fmodby = :who, fmodwith = :entity, potype='NONE', pmodtime='now', pmodby = :who, pmodwith = :entity WHERE login = :login; @@ -2018,9 +2028,10 @@ get_list_info(q, aargv, cl, action, actarg) * modwith =l.#modwith) * where l.list_id = :id */ - EXEC SQL REPEATED SELECT name, text(active), text(public), - text(hidden), hidden, text(maillist), text(grouplist), text(gid), - trim(acl_type), acl_id, desc, modtime, modby, modwith + /** Won't the TRIM() die a horrible INGRES death? **/ + EXEC SQL REPEATED SELECT name, CHAR(active), CHAR(publicflg), + CHAR(hidden), hidden, CHAR(maillist), CHAR(grouplist), CHAR(gid), + TRIM(acl_type), acl_id, description, CHAR(modtime), modby, modwith INTO :listname, :active, :public, :hidden, :hid, :maillist, :grouplist, :gid_str, :acl_type, :acl_id, :desc, :modtime, :modby_id, :modwith @@ -2645,8 +2656,8 @@ int get_lists_of_member(q, argv, cl, action, actarg) * m.member_type = :atype and m.member_id = :aid */ EXEC SQL DECLARE csr117a CURSOR FOR - SELECT name, text(active), text(public), text(hidden), - text(maillist), text(grouplist) + SELECT name, CHAR(active), CHAR(publicflg), CHAR(hidden), + CHAR(maillist), CHAR(grouplist) FROM list l, imembers m WHERE l.list_id = m.list_id AND m.direct = 1 AND m.member_type = :atype AND m.member_id = :aid; @@ -2661,8 +2672,8 @@ int get_lists_of_member(q, argv, cl, action, actarg) EXEC SQL CLOSE csr117a; } else { EXEC SQL DECLARE csr117b CURSOR FOR - SELECT name, text(active), text(public), text(hidden), - text(maillist), text(grouplist) + SELECT name, CHAR(active), CHAR(publicflg), CHAR(hidden), + CHAR(maillist), CHAR(grouplist) FROM list l, imembers m WHERE l.list_id = m.list_id AND m.member_type = :atype AND m.member_id = :aid; @@ -2689,7 +2700,7 @@ int get_lists_of_member(q, argv, cl, action, actarg) * where clause based on the arguments, then doing a retrieve. */ -static char *lflags[5] = { "active", "public", "hidden", "maillist", "group" }; +static char *lflags[5] = { "active", "publicflg", "hidden", "maillist", "group" }; int qualified_get_lists(q, argv, cl, action, actarg) struct query *q; @@ -2926,7 +2937,7 @@ int qualified_get(q, argv, action, actarg, start, range, field, flags) } rargv[0] = SQLDA->sqlvar[0].sqldata; - sprintf(stmt_buf,"SELECT %s.%s FROM %s WHERE %s",q->rtable,field,q->rtable,qual); + sprintf(stmt_buf,"SELECT %s.%s FROM %s %s WHERE %s",q->rtable,field,q->rtable,q->rvar,qual); EXEC SQL PREPARE stmt INTO :SQLDA USING NAMES FROM :stmt_buf; if((mr_errcode=mr_check_SQLDA(SQLDA)) != MR_SUCCESS) return(mr_errcode); @@ -2935,7 +2946,6 @@ int qualified_get(q, argv, action, actarg, start, range, field, flags) while(1) { EXEC SQL FETCH csr123 USING DESCRIPTOR :SQLDA; if(sqlca.sqlcode != 0) break; - mr_fix_nulls_in_SQLDA(SQLDA); rowcount++; (*action)(1, rargv, actarg); } @@ -3098,8 +3108,8 @@ register_user(q, argv, cl) incremental_clear_before(); EXEC SQL SELECT value INTO :gidval FROM numvalues WHERE name = 'gid'; EXEC SQL REPEATED INSERT INTO list - (name, list_id, active, public, hidden, maillist, grouplist, - gid, desc, acl_type, acl_id, + (name, list_id, active, publicflg, hidden, maillist, grouplist, + gid, description, acl_type, acl_id, modtime, modby, modwith) VALUES (:login, :list_id, 1, 0, 0, 0, 1, :gidval, 'User Group', 'USER', :users_id, @@ -3264,17 +3274,13 @@ validate_row(q, argv, v) com_err(whoami, 0, "validating row: %s", qual); /* look for the record */ -/* - * range of rvar is table - * retrieve (rowcount = count(rvar.name where qual)) - */ - sprintf(stmt_buf,"SELECT COUNT (*) FROM %s %s WHERE %s",q->rtable,q->rvar,qual); + sprintf(stmt_buf,"SELECT COUNT (*) FROM %s WHERE %s",q->rtable,qual); EXEC SQL PREPARE stmt INTO :SQLDA USING NAMES FROM :stmt_buf; EXEC SQL DECLARE csr126 CURSOR FOR stmt; EXEC SQL OPEN csr126; EXEC SQL FETCH csr126 USING DESCRIPTOR :SQLDA; EXEC SQL CLOSE csr126; - rowcount=*(int *)SQLDA->[0].sqldata; + rowcount = *(int *)SQLDA->sqlvar[0].sqldata; if (ingres_errno) return(mr_errcode); if (rowcount == 0) return(MR_NO_MATCH); @@ -3436,17 +3442,9 @@ validate_id(q, argv, vo) } if (!strcmp(namefield, "uid")) { -/* - * retrieve (id = table.idfield) where table.namefield = int4(name) - */ - sprintf(stmt_buf,"SELECT %s FROM %s WHERE %s.%s = %s",idfield,tbl,tbl,namefield,name); - if (ingres_errno) return(mr_errcode); + sprintf(stmt_buf,"SELECT %s FROM %s WHERE %s = %s",idfield,tbl,namefield,name); } else { -/* - * retrieve (id = table.idfield) where table.namefield = name - */ - sprintf(stmt_buf,"SELECT %s FROM %s WHERE %s.%s = '%s'",idfield,tbl,tbl,namefield,name); - if (ingres_errno) return(mr_errcode); + sprintf(stmt_buf,"SELECT %s FROM %s WHERE %s = '%s'",idfield,tbl,namefield,name); } EXEC SQL PREPARE stmt INTO :SQLDA USING NAMES FROM :stmt_buf; EXEC SQL DECLARE csr127 CURSOR FOR stmt; @@ -3456,12 +3454,14 @@ validate_id(q, argv, vo) if(sqlca.sqlcode == 0) { rowcount++; EXEC SQL FETCH csr127 USING DESCRIPTOR :SQLDA; - if(sqlca.sqlcode == 0) rowcount++ + if(sqlca.sqlcode == 0) rowcount++; } EXEC SQL CLOSE csr127; + if (ingres_errno) + return(mr_errcode); if (rowcount != 1) return(vo->error); - *argv[vo->index] = *SQLDA->sqlvar[0]->sqldata; + *argv[vo->index] = *SQLDA->sqlvar[0].sqldata; return(MR_EXISTS); } @@ -3483,17 +3483,13 @@ validate_name(argv, vo) if (islower(*c)) *c = toupper(*c); } -/* - * retrieve (rowcount = countu(table.namefield - * where table.namefield = name)) - */ - sprintf(stmt_buf,"SELECT COUNT (DISTINCT *) FROM %s WHERE %s.%s = '%s'", + sprintf(stmt_buf,"SELECT DISTINCT COUNT(*) FROM %s WHERE %s.%s = '%s'", tbl,tbl,namefield,name); EXEC SQL PREPARE stmt INTO :SQLDA USING NAMES FROM :stmt_buf; EXEC SQL DECLARE csr128 CURSOR FOR stmt; EXEC SQL OPEN csr128; EXEC SQL FETCH csr128 USING DESCRIPTOR :SQLDA; - rowcount=*(int *)SQLDA->sqlvar[0]->sqldata; + rowcount = *(int *)SQLDA->sqlvar[0].sqldata; EXEC SQL CLOSE csr128; if (ingres_errno) return(mr_errcode); @@ -3578,22 +3574,22 @@ validate_type(argv, vo) { EXEC SQL BEGIN DECLARE SECTION; char *typename; - char *value; + char *val; EXEC SQL END DECLARE SECTION; register char *c; typename = vo->table; - c = value = argv[vo->index]; + c = val = argv[vo->index]; while (*c) { - if (illegalchars[*c]) + if (illegalchars[*c++]) return(MR_BAD_CHAR); } /* uppercase type fields */ - for (c = value; *c; c++) if (islower(*c)) *c = toupper(*c); + for (c = val; *c; c++) if (islower(*c)) *c = toupper(*c); EXEC SQL SELECT trans INTO :cdummy FROM alias - WHERE name = :typename AND type='TYPE' AND trans = :value; + WHERE name = :typename AND type='TYPE' AND trans = :val; if (ingres_errno) return(mr_errcode); return (sqlca.sqlerrd[2] ? MR_EXISTS : vo->error); } @@ -3757,6 +3753,11 @@ mr_check_SQLDA(da) return(MR_SUCCESS); } +/* Use this after FETCH USING DESCRIPTOR one or more + * result columns may contain NULLs. This routine is + * not currently needed, since db/schema creates all + * columns with a NOT NULL WITH DEFAULT clause. + */ mr_fix_nulls_in_SQLDA(da) MR_SQLDA_T *da; { @@ -3776,6 +3777,50 @@ mr_fix_nulls_in_SQLDA(da) *intp=0; } break; - } /** I believe that these two are the only types Moira encounters */ + } } } + +/* prefetch_value(): + * This routine fetches an appropriate value from the numvalues table. + * It is a little hack to get around the fact that SQL doesn't let you + * do something like INSERT INTO table (foo) VALUES (other_table.bar). + * + * It is called from the query table as (*v->pre_rtn)(q,Argv,cl) or + * from within a setup_...() routine with the appropriate arguments. + * + * Correct functioning of this routine may depend on the assumption + * that this query is an APPEND. + */ + +prefetch_value(q,argv,cl) + struct query *q; + char **argv; + client *cl; +{ + EXEC SQL BEGIN DECLARE SECTION; + char *name = q->validate->object_id; + int value; + EXEC SQL END DECLARE SECTION; + int status, limit, argc; + + /* set next object id, limiting it if necessary */ + if(!strcmp(name, "uid") || !strcmp(name, "gid")) + limit = 1; /* So far as I know, this isn't needed. Just CMA. */ + else + limit = 0; + if((status = set_next_object_id(name, q->rtable, limit)) != MR_SUCCESS) + return(status); + + /* fetch object id */ + EXEC SQL SELECT value INTO :value FROM numvalues WHERE name=:name; + if(ingres_errno) return(mr_errcode); + if(sqlca.sqlerrd[2] != 1) return(MR_INTERNAL); + + argc = q->argc + q->vcnt; /* end of Argv for APPENDs */ + sprintf(argv[argc],"%d",value); + + return(MR_SUCCESS); +} + +/* eof:qsupport.dc */ diff --git a/server/queries2.c b/server/queries2.c index 0b9b2912..349674d7 100644 --- a/server/queries2.c +++ b/server/queries2.c @@ -25,6 +25,7 @@ int access_service(); int access_filesys(); /* Query Setup Routines */ +int prefetch_value(); int setup_ausr(); int setup_dusr(); int setup_spop(); @@ -580,11 +581,11 @@ static struct validate amac_validate = { amac_valobj, 3, NAME, - "imembers.name = uppercase('%s')", + "machine.name = uppercase('%s')", 1, MACH_ID, 0, - 0, + prefetch_value, set_uppercase_modtime, }; @@ -652,11 +653,11 @@ static struct validate aclu_validate = /* for aclu */ aclu_valobj, 2, NAME, - "clusters.name = '%s'", + "cluster.name = '%s'", 1, CLU_ID, 0, - 0, + prefetch_value, set_modtime, }; @@ -715,7 +716,7 @@ static struct validate amtc_validate = /* for amtc and dmfc */ amtc_valobj, 2, MACH_ID, - "imembers.mach_id = %d and imembers.clu_id = %d", + "mcmap.mach_id = %d and mcmap.clu_id = %d", 2, 0, 0, @@ -1235,6 +1236,18 @@ static struct valobj anfp_valobj[] = { }; static struct validate anfp_validate = { + anfp_valobj, + 2, + DIR, + "nfsphys.mach_id = %d and nfsphys.dir = '%s'", + 2, + "nfsphys_id", + 0, + prefetch_value, + set_nfsphys_modtime, +}; + +static struct validate unfp_validate = { anfp_valobj, 2, DIR, @@ -1413,7 +1426,7 @@ static struct validate dnfq_validate = { static char *glin_fields[] = { NAME, - NAME, "active", "public", "hidden", "maillist", "grouplist", "gid", + NAME, "active", "publicflg", "hidden", "maillist", "grouplist", "gid", ACE_TYPE, ACE_NAME, DESC, MOD1, MOD2, MOD3, }; @@ -1430,7 +1443,7 @@ static struct validate glin_validate = { }; static char *alis_fields[] = { - NAME, "active", "public", "hidden", "maillist", "grouplist", "gid", + NAME, "active", "publicflg", "hidden", "maillist", "grouplist", "gid", ACE_TYPE, ACE_NAME, DESC, }; @@ -1455,7 +1468,7 @@ static struct validate alis_validate = { static char *ulis_fields[] = { NAME, - "newname", "active", "public", "hidden", "maillist", "grouplist", "gid", + "newname", "active", "publicflg", "hidden", "maillist", "grouplist", "gid", ACE_TYPE, ACE_NAME, DESC, }; @@ -1555,7 +1568,7 @@ static struct validate gaus_validate = { }; static char *qgli_fields[] = { - "active", "public", "hidden", "maillist", "grouplist", + "active", "publicflg", "hidden", "maillist", "grouplist", "list", }; @@ -1598,7 +1611,7 @@ static struct validate gmol_validate = { static char *glom_fields[] = { "member_type", "member_name", - "list_name", "active", "public", "hidden", "maillist", "grouplist", + "list_name", "active", "publicflg", "hidden", "maillist", "grouplist", }; static struct valobj glom_valobj[] = { @@ -1926,7 +1939,7 @@ static char *dval_fields[] = { }; static char *gats_fields[] = { - "table_name", "retrieves", "appends", "updates", "deletes", MOD1, MOD2, MOD3, + "table_name", "appends", "updates", "deletes", MOD1, MOD2, MOD3, }; @@ -1941,7 +1954,7 @@ struct query Queries2[] = { RETRIEVE, "u", USERS, - "login, text(uid), shell, last, first, middle FROM users", + "login, CHAR(uid), shell, last, first, middle FROM users", galo_fields, 6, "users_id != 0", @@ -1956,7 +1969,7 @@ struct query Queries2[] = { RETRIEVE, "u", USERS, - "login, text(uid), shell, last, first, middle FROM users", + "login, CHAR(uid), shell, last, first, middle FROM users", galo_fields, 6, "status = 1", @@ -1971,7 +1984,7 @@ struct query Queries2[] = { RETRIEVE, "u", USERS, - "login, text(uid), shell, last, first, middle, text(status), clearid, type, modtime, text(modby), modwith FROM users", + "login, CHAR(uid), shell, last, first, middle, CHAR(status), clearid, type, CHAR(modtime), CHAR(modby), modwith FROM users", gubl_fields, 12, "login = '%s' AND users_id != 0", @@ -1986,7 +1999,7 @@ struct query Queries2[] = { RETRIEVE, "u", USERS, - "login, text(uid), shell, last, first, middle, text(status), clearid, type, modtime, text(modby), modwith FROM users", + "login, CHAR(uid), shell, last, first, middle, CHAR(status), clearid, type, CHAR(modtime), CHAR(modby), modwith FROM users", gubu_fields, 12, "uid = %s AND users_id != 0", @@ -2001,7 +2014,7 @@ struct query Queries2[] = { RETRIEVE, "u", USERS, - "login, text(uid), shell, last, first, middle, text(status), clearid, type, modtime, text(modby), modwith FROM users", + "login, CHAR(uid), shell, last, first, middle, CHAR(status), clearid, type, CHAR(modtime), CHAR(modby), modwith FROM users", gubn_fields, 12, "first = '%s' AND last = '%s' AND users_id != 0", @@ -2016,7 +2029,7 @@ struct query Queries2[] = { RETRIEVE, "u", USERS, - "login, text(uid), shell, last, first, middle, text(status), clearid, type, modtime, text(modby), modwith FROM users", + "login, CHAR(uid), shell, last, first, middle, CHAR(status), clearid, type, CHAR(modtime), CHAR(modby), modwith FROM users", gubc_fields, 12, "type = uppercase('%s') AND users_id != 0", @@ -2031,7 +2044,7 @@ struct query Queries2[] = { RETRIEVE, "u", USERS, - "login, text(uid), shell, last, first, middle, text(status), clearid, type, modtime, text(modby), modwith FROM users", + "login, CHAR(uid), shell, last, first, middle, CHAR(status), clearid, type, CHAR(modtime), CHAR(modby), modwith FROM users", gubm_fields, 12, "clearid = '%s' AND users_id != 0", @@ -2039,17 +2052,18 @@ struct query Queries2[] = { &VDsortf, }, + { - /* Q_AUSR - ADD_USER */ /** Needs subselect */ + /* Q_AUSR - ADD_USER */ /* uses prefetch_value() for users_id */ "add_user", "ausr", APPEND, "u", USERS, - "INTO users (login, users_id, uid, shell, last, first, middle, status, clearid, type) VALUES ( '%s', numvalues.value, %s, '%s', '%s', '%s', '%s', %s, '%s', '%s')", + "INTO users (login, uid, shell, last, first, middle, status, clearid, type, users_id) VALUES ( '%s', %s, '%s', '%s', '%s', '%s', %s, '%s', '%s', %s)", ausr_fields, 9, - "numvalues.name = 'users_id'", + 0, 0, &ausr_validate, }, @@ -2196,7 +2210,7 @@ struct query Queries2[] = { RETRIEVE, "u", USERS, - "login, fullname, nickname, home_addr, home_phone, office_addr, office_phone, department, affiliation, fmodtime, text(fmodby), fmodwith FROM users", + "login, fullname, nickname, home_addr, home_phone, office_addr, office_phone, department, affiliation, CHAR(fmodtime), CHAR(fmodby), fmodwith FROM users", gfbl_fields, 12, "users_id = %d", @@ -2226,7 +2240,7 @@ struct query Queries2[] = { RETRIEVE, "u", USERS, - "login, potype, text(pop_id) + ':' + text(box_id), pmodtime, text(pmodby), pmodwith FROM users", + "login, potype, CHAR(pop_id) + ':' + CHAR(box_id), CHAR(pmodtime), CHAR(pmodby), pmodwith FROM users", gpob_fields, 6, "users_id = %d", @@ -2241,7 +2255,7 @@ struct query Queries2[] = { RETRIEVE, "u", USERS, - "login, potype, text(pop_id) + ':' + text(box_id) FROM users", + "login, potype, CHAR(pop_id) + ':' + CHAR(box_id) FROM users", gpox_fields, 3, "potype != 'NONE'", @@ -2256,7 +2270,7 @@ struct query Queries2[] = { RETRIEVE, "u", USERS, - "login, potype, text(pop_id) + ':' + text(box_id) FROM users", + "login, potype, CHAR(pop_id) + ':' + CHAR(box_id) FROM users", gpox_fields, 3, "potype = 'POP'", @@ -2271,7 +2285,7 @@ struct query Queries2[] = { RETRIEVE, "u", USERS, - "login, potype, text(pop_id) + ':' + text(box_id) FROM users", + "login, potype, CHAR(pop_id) + ':' + CHAR(box_id) FROM users", gpox_fields, 3, "potype = 'SMTP'", @@ -2331,25 +2345,26 @@ struct query Queries2[] = { RETRIEVE, "m", MACHINE, - "name, type, modtime, text(modby), modwith FROM machine", + "name, type, CHAR(modtime), CHAR(modby), modwith FROM machine", gmac_fields, 5, "name = uppercase('%s') AND mach_id != 0", +/* "name LIKE '%s' ESCAPE '\\' AND mach_id != 0", */ /* Pattern matching */ 1, &VDsortf, }, { - /* Q_AMAC - ADD_MACHINE */ /** Needs subselect */ + /* Q_AMAC - ADD_MACHINE */ /* uses prefetch_value() for mach_id */ "add_machine", "amac", APPEND, "m", MACHINE, - "INTO machine (name, mach_id, type) VALUES (uppercase('%s'),numvalues.value,'%s')", + "INTO machine (name, type, mach_id) VALUES (uppercase('%s'),'%s',%s)", amac_fields, 2, - "numvalues.name = 'mach_id'", + 0, 0, &amac_validate, }, @@ -2391,7 +2406,7 @@ struct query Queries2[] = { RETRIEVE, "c", CLUSTER, - "name, desc, location, modtime, text(modby), modwith FROM cluster", + "name, description, location, CHAR(modtime), CHAR(modby), modwith FROM cluster", gclu_fields, 6, "name = '%s' AND clu_id != 0", @@ -2400,16 +2415,16 @@ struct query Queries2[] = { }, { - /* Q_ACLU - ADD_CLUSTER */ /** Needs subselect */ + /* Q_ACLU - ADD_CLUSTER */ /* uses prefetch_value() for clu_id */ "add_cluster", "aclu", APPEND, "c", CLUSTER, - "INTO cluster (name, clu_id, desc, location) VALUES ('%s',numvalues.value,'%s','%s')", + "INTO cluster (name, description, location, clu_id) VALUES ('%s','%s','%s',%s)", aclu_fields, 3, - "numvalues.name = 'clu_id'", + 0, 0, &aclu_validate, }, @@ -2421,7 +2436,7 @@ struct query Queries2[] = { UPDATE, "c", CLUSTER, - "cluster SET name = '%s', desc = '%s', location = '%s'", + "cluster SET name = '%s', description = '%s', location = '%s'", uclu_fields, 3, "clu_id = %d", @@ -2541,7 +2556,7 @@ struct query Queries2[] = { RETRIEVE, "s", "servers", - "name, text(update_int), target_file, script, text(dfgen), text(dfcheck), type, text(enable), text(inprogress), text(harderror), errmsg, acl_type, text(acl_id), modtime, text(modby), modwith FROM servers", + "name, CHAR(update_int), target_file, script, CHAR(dfgen), CHAR(dfcheck), type, CHAR(enable), CHAR(inprogress), CHAR(harderror), errmsg, acl_type, CHAR(acl_id), CHAR(modtime), CHAR(modby), modwith FROM servers", gsin_fields, 16, "name = uppercase('%s')", @@ -2646,7 +2661,7 @@ struct query Queries2[] = { RETRIEVE, "sh", "serverhosts", - "sh.service, m.name, text(sh.enable), text(sh.override), text(sh.success), text(sh.inprogress), text(sh.hosterror), sh.hosterrmsg, text(sh.ltt), text(sh.lts), text(sh.value1), text(sh.value2), sh.value3, sh.modtime, text(sh.modby), sh.modwith FROM serverhosts sh, machine m", + "sh.service, m.name, CHAR(sh.enable), CHAR(sh.override), CHAR(sh.success), CHAR(sh.inprogress), CHAR(sh.hosterror), sh.hosterrmsg, CHAR(sh.ltt), CHAR(sh.lts), CHAR(sh.value1), CHAR(sh.value2), sh.value, CHAR(sh.modtime), CHAR(sh.modby), sh.modwith FROM serverhosts sh, machine m", gshi_fields, 16, "sh.service = uppercase('%s') AND m.name = uppercase('%s') AND m.mach_id = sh.mach_id", @@ -2766,7 +2781,7 @@ struct query Queries2[] = { RETRIEVE, "ha", "hostaccess", - "m.name, ha.acl_type, text(ha.acl_id), ha.modtime, text(ha.modby), ha.modwith FROM hostaccess ha, machine m", + "m.name, ha.acl_type, CHAR(ha.acl_id), CHAR(ha.modtime), CHAR(ha.modby), ha.modwith FROM hostaccess ha, machine m", gsha_fields, 6, "m.name = uppercase('%s') AND ha.mach_id = m.mach_id", @@ -2841,7 +2856,7 @@ struct query Queries2[] = { RETRIEVE, "fs", FILESYS, - "fs.label, fs.type, m.name, fs.name, fs.mount, fs.access, fs.comments, u.login, l.name, text(fs.createflg), fs.lockertype, fs.modtime, text(fs.modby), fs.modwith FROM filesys fs, machine m, users u, list l", + "fs.label, fs.type, m.name, fs.name, fs.mount, fs.access, fs.comments, u.login, l.name, CHAR(fs.createflg), fs.lockertype, CHAR(fs.modtime), CHAR(fs.modby), fs.modwith FROM filesys fs, machine m, users u, list l", gfsl_fields, 14, "fs.label = '%s' AND fs.mach_id = m.mach_id AND fs.owner = u.users_id AND fs.owners = l.list_id", @@ -2856,7 +2871,7 @@ struct query Queries2[] = { RETRIEVE, "fs", FILESYS, - "fs.label, fs.type, m.name, fs.name, fs.mount, fs.access, fs.comments, u.login, l.name, text(fs.createflg), fs.lockertype, fs.modtime, text(fs.modby), fs.modwith FROM filesys fs, machine m, users u, list l", + "fs.label, fs.type, m.name, fs.name, fs.mount, fs.access, fs.comments, u.login, l.name, CHAR(fs.createflg), fs.lockertype, CHAR(fs.modtime), CHAR(fs.modby), fs.modwith FROM filesys fs, machine m, users u, list l", gfsm_fields, 14, "fs.mach_id = %d AND m.mach_id = fs.mach_id AND fs.owner = u.users_id AND fs.owners = l.list_id", @@ -2871,7 +2886,7 @@ struct query Queries2[] = { RETRIEVE, "fs", FILESYS, - "fs.label, fs.type, m.name, fs.name, fs.mount, fs.access, fs.comments, u.login, l.name, text(fs.createflg), fs.lockertype, fs.modtime, text(fs.modby), fs.modwith FROM filesys fs, machine m, users u, list l, nfsphys np", + "fs.label, fs.type, m.name, fs.name, fs.mount, fs.access, fs.comments, u.login, l.name, CHAR(fs.createflg), fs.lockertype, CHAR(fs.modtime), CHAR(fs.modby), fs.modwith FROM filesys fs, machine m, users u, list l, nfsphys np", gfsn_fields, 14, "fs.mach_id = %d AND m.mach_id = fs.mach_id AND fs.owner = u.users_id AND fs.owners = l.list_id AND np.nfsphys_id = fs.phys_id AND np.dir = '%s' AND fs.type = 'NFS'", @@ -2886,7 +2901,7 @@ struct query Queries2[] = { RETRIEVE, "fs", FILESYS, - "fs.label, fs.type, m.name, fs.name, fs.mount, fs.access, fs.comments, u.login, l.name, text(fs.createflg), fs.lockertype, fs.modtime, text(fs.modby), fs.modwith FROM filesys fs, machine m, users u, list l", + "fs.label, fs.type, m.name, fs.name, fs.mount, fs.access, fs.comments, u.login, l.name, CHAR(fs.createflg), fs.lockertype, CHAR(fs.modtime), CHAR(fs.modby), fs.modwith FROM filesys fs, machine m, users u, list l", gfsg_fields, 14, "fs.owners = %d AND m.mach_id = fs.mach_id AND fs.owner = u.users_id AND fs.owners = l.list_id", @@ -2895,16 +2910,16 @@ struct query Queries2[] = { }, { - /* Q_AFIL - ADD_FILESYS */ /** Need subselect */ + /* Q_AFIL - ADD_FILESYS */ /* uses prefetch_value() for filsys_id */ "add_filesys", "afil", APPEND, "fs", FILESYS, - "INTO filesys (filsys_id, label, type, mach_id, name, mount, access, comments, owner, owners, createflg, lockertype) VALUES (numvalues.value,'%s','%s',%d,'%s','%s','%s','%s',%d,%d,%s,'%s')", + "INTO filesys (label, type, mach_id, name, mount, access, comments, owner, owners, createflg, lockertype, filsys_id) VALUES ('%s','%s',%d,'%s','%s','%s','%s',%d,%d,%s,'%s',%s)", afil_fields, 11, - "numvalues.name = 'filsys_id'", + 0, 0, &afil_validate, }, @@ -2991,7 +3006,7 @@ struct query Queries2[] = { RETRIEVE, "np", "nfsphys", - "m.name, np.dir, np.device, text(np.status), text(np.allocated), text(np.size), np.modtime, text(np.modby), np.modwith FROM nfsphys np, machine m", + "m.name, np.dir, np.device, CHAR(np.status), CHAR(np.allocated), CHAR(np.size), CHAR(np.modtime), CHAR(np.modby), np.modwith FROM nfsphys np, machine m", ganf_fields, 9, "m.mach_id = np.mach_id", @@ -3006,7 +3021,7 @@ struct query Queries2[] = { RETRIEVE, "np", "nfsphys", - "m.name, np.dir, np.device, text(np.status), text(np.allocated), text(np.size), np.modtime, text(np.modby), np.modwith FROM nfsphys np, machine m", + "m.name, np.dir, np.device, CHAR(np.status), CHAR(np.allocated), CHAR(np.size), CHAR(np.modtime), CHAR(np.modby), np.modwith FROM nfsphys np, machine m", gnfp_fields, 9, "np.mach_id = %d AND np.dir = '%s' AND m.mach_id = np.mach_id", @@ -3015,16 +3030,16 @@ struct query Queries2[] = { }, { - /* Q_ANFP - ADD_NFSPHYS */ /** Needs subselect */ + /* Q_ANFP - ADD_NFSPHYS */ /* uses prefetch_value() for nfsphys_id */ "add_nfsphys", "anfp", APPEND, "np", "nfsphys", - "INTO nfsphys (nfsphys_id, mach_id, dir, device, status, allocated, size) VALUES (numvalues.value, %d, '%s', '%s', %s, %s, %s)", + "INTO nfsphys (mach_id, dir, device, status, allocated, size, nfsphys_id) VALUES (%d, '%s', '%s', %s, %s, %s, %s)", ganf_fields, 6, - "numvalues.name = 'nfsphys_id'", + 0, 0, &anfp_validate, }, @@ -3041,7 +3056,7 @@ struct query Queries2[] = { 4, "mach_id = %d AND dir = '%s'", 2, - &anfp_validate, + &unfp_validate, }, { @@ -3056,7 +3071,7 @@ struct query Queries2[] = { 1, "mach_id = %d AND dir = '%s'", 2, - &anfp_validate, + &unfp_validate, }, { @@ -3081,7 +3096,7 @@ struct query Queries2[] = { RETRIEVE, "q", QUOTA, - "fs.label, q.type, text(q.entity_id), text(q.quota), text(q.phys_id), m.name, q.modtime, text(q.modby), q.modwith FROM quota q, filesys fs, machine m", + "fs.label, q.type, CHAR(q.entity_id), CHAR(q.quota), CHAR(q.phys_id), m.name, CHAR(q.modtime), CHAR(q.modby), q.modwith FROM quota q, filesys fs, machine m", gqot_fields, 9, "fs.label = '%s' AND q.type = '%s' AND q.entity_id = %d AND fs.filsys_id = q.filsys_id AND m.mach_id = fs.mach_id", @@ -3096,7 +3111,7 @@ struct query Queries2[] = { RETRIEVE, "q", QUOTA, - "fs.label, q.type, text(q.entity_id), text(q.quota), text(q.phys_id), m.name, q.modtime, text(q.modby), q.modwith FROM quota q, filesys fs, machine m", + "fs.label, q.type, CHAR(q.entity_id), CHAR(q.quota), CHAR(q.phys_id), m.name, CHAR(q.modtime), CHAR(q.modby), q.modwith FROM quota q, filesys fs, machine m", gqbf_fields, 9, "fs.label = '%s' AND fs.filsys_id = q.filsys_id AND m.mach_id = fs.mach_id", @@ -3156,7 +3171,7 @@ struct query Queries2[] = { RETRIEVE, "q", QUOTA, - "fs.label, u.login, text(q.quota), text(q.phys_id), m.name, q.modtime, text(q.modby), q.modwith FROM quota q, filesys fs, users u, machine m", + "fs.label, u.login, CHAR(q.quota), CHAR(q.phys_id), m.name, CHAR(q.modtime), CHAR(q.modby), q.modwith FROM quota q, filesys fs, users u, machine m", gnfq_fields, 8, "fs.label = '%s' AND q.type = 'USER' AND q.entity_id = u.users_id AND fs.filsys_id = q.filsys_id AND m.mach_id = fs.mach_id AND u.login = '%s'", @@ -3171,7 +3186,7 @@ struct query Queries2[] = { RETRIEVE, "q", QUOTA, - "fs.label, u.login, text(q.quota), np.dir, m.name FROM quota q, filesys fs, users u, nfsphys np, machine m", + "fs.label, u.login, CHAR(q.quota), np.dir, m.name FROM quota q, filesys fs, users u, nfsphys np, machine m", gnqp_fields, 5, "np.mach_id = %d AND np.dir = '%s' AND q.phys_id = np.nfsphys_id AND fs.filsys_id = q.filsys_id AND q.type = 'USER' AND u.users_id = q.entity_id AND m.mach_id = np.mach_id", @@ -3255,16 +3270,16 @@ struct query Queries2[] = { }, { - /* Q_ALIS - ADD_LIST */ /** Needs numvalues subselect */ + /* Q_ALIS - ADD_LIST */ /* uses prefetch_value() for list_id */ "add_list", "alis", APPEND, "l", LIST, - "INTO list (list_id, name, active, public, hidden, maillist, grouplist, gid, acl_type, acl_id, desc) VALUES (numvalues.value,'%s',%s,%s,%s,%s,%s,%s,'%s',%d,'%s')", + "INTO list (name, active, publicflg, hidden, maillist, grouplist, gid, acl_type, acl_id, description, list_id) VALUES ('%s',%s,%s,%s,%s,%s,%s,'%s',%d,'%s',%s)", alis_fields, 10, - "numvalues.name = 'list_id'", + 0, 0, &alis_validate, }, @@ -3276,7 +3291,7 @@ struct query Queries2[] = { UPDATE, "l", LIST, - "list SET name='%s', active=%s, public=%s, hidden=%s, maillist=%s, grouplist=%s, gid=%s, acl_type='%s', acl_id=%d, desc='%s'", + "list SET name='%s', active=%s, publicflg=%s, hidden=%s, maillist=%s, grouplist=%s, gid=%s, acl_type='%s', acl_id=%d, description='%s'", ulis_fields, 10, "list.list_id = %d", @@ -3411,7 +3426,7 @@ struct query Queries2[] = { RETRIEVE, "z", "zephyr", - "class, xmt_type, text(xmt_id),sub_type, text(sub_id),iws_type, text(iws_id),iui_type, text(iui_id), modtime, text(modby), modwith FROM zephyr", + "class, xmt_type, CHAR(xmt_id),sub_type, CHAR(sub_id),iws_type, CHAR(iws_id),iui_type, CHAR(iui_id), CHAR(modtime), CHAR(modby), modwith FROM zephyr", gzcl_fields, 12, "class = '%s'", @@ -3471,7 +3486,7 @@ struct query Queries2[] = { RETRIEVE, "s", "services", - "name, protocol, text(port), desc, modtime, text(modby), modwith FROM services", + "name, protocol, CHAR(port), description, CHAR(modtime), CHAR(modby), modwith FROM services", gsvc_fields, 7, "name = '%s'", @@ -3486,7 +3501,7 @@ struct query Queries2[] = { APPEND, "s", "services", - "INTO services (name, protocol, port, desc) VALUES ('%s','%s',%s,'%s')", + "INTO services (name, protocol, port, description) VALUES ('%s','%s',%s,'%s')", asvc_fields, 4, (char *)0, @@ -3516,7 +3531,7 @@ struct query Queries2[] = { RETRIEVE, "p", "printcap", - "p.name, m.name, p.dir, p.rp, text(p.quotaserver), text(p.auth), text(p.price), p.comments, p.modtime, text(p.modby), p.modwith FROM printcap p, machine m", + "p.name, m.name, p.dir, p.rp, CHAR(p.quotaserver), CHAR(p.auth), CHAR(p.price), p.comments, CHAR(p.modtime), CHAR(p.modby), p.modwith FROM printcap p, machine m", gpce_fields, 11, "p.name = '%s' AND m.mach_id = p.mach_id", @@ -3561,7 +3576,7 @@ struct query Queries2[] = { RETRIEVE, "p", "printcap", - "p.name, m.name, p.dir, p.rp, p.comments, p.modtime, text(p.modby), p.modwith FROM printcap p, machine m", + "p.name, m.name, p.dir, p.rp, p.comments, CHAR(p.modtime), CHAR(p.modby), p.modwith FROM printcap p, machine m", gpcp_fields, 8, "p.name = '%s' AND m.mach_id = p.mach_id", @@ -3591,7 +3606,7 @@ struct query Queries2[] = { RETRIEVE, "p", "palladium", - "p.name, text(p.ident), m.name, p.modtime, text(p.modby), p.modwith FROM palladium p, machine m", + "p.name, CHAR(p.ident), m.name, CHAR(p.modtime), CHAR(p.modby), p.modwith FROM palladium p, machine m", gpdm_fields, 6, "p.name = '%s' AND m.mach_id = p.mach_id", @@ -3681,7 +3696,7 @@ struct query Queries2[] = { RETRIEVE, "v", "numvalues", - "text(value) FROM numvalues", + "CHAR(value) FROM numvalues", gval_fields, 1, "name = '%s'", @@ -3741,9 +3756,9 @@ struct query Queries2[] = { RETRIEVE, "tbs", "tblstats", - "tbs.table_name, text(tbs.retrieves), text(tbs.appends), text(tbs.updates), text(tbs.deletes), tbs.modtime FROM tblstats tbs", + "tbs.table_name, CHAR(tbs.appends), CHAR(tbs.updates), CHAR(tbs.deletes), CHAR(tbs.modtime) FROM tblstats tbs", gats_fields, - 6, + 5, (char *)0, 0, 0,