]> andersk Git - moira.git/blobdiff - server/qvalidate.dc
Added index for machine(address) and machine(location)
[moira.git] / server / qvalidate.dc
index 902233416de536d698ca75dc70abf5fe8076986e..188d4ffb88a36748698e69cb5960b9e71795dcce 100644 (file)
@@ -31,6 +31,12 @@ EXEC SQL END DECLARE SECTION;
 
 EXEC SQL WHENEVER SQLERROR CALL ingerr;
 
+#ifdef _DEBUG_MALLOC_INC
+#undef index
+#define dbg_index(str1,c)             DBindex(__FILE__, __LINE__, str1, c)
+#else
+#define dbg_index index
+#endif
 
 /* Validation Routines */
 
@@ -396,7 +402,6 @@ validate_typedata(q, argv, vo)
     int id;
     EXEC SQL END DECLARE SECTION;
     int status;
-    char *index();
     register char *c;
 
     /* get named object */
@@ -412,11 +417,11 @@ validate_typedata(q, argv, vo)
     if (sqlca.sqlerrd[2] != 1) return(MR_TYPE);
 
     /* now retrieve the record id corresponding to the named object */
-    if (index(data_type, ' '))
-       *index(data_type, ' ') = 0;
+    if (dbg_index(data_type, ' '))
+       *dbg_index(data_type, ' ') = 0;
     if (!strcmp(data_type, "user")) {
        /* USER */
-       if (index(name, '@'))
+       if (dbg_index(name, '@'))
          return(MR_USER);
        status = name_to_id(name, data_type, &id);
        if (status && (status == MR_NO_MATCH || status == MR_NOT_UNIQUE))
@@ -514,7 +519,7 @@ MR_SQLDA_T *mr_alloc_SQLDA()
     }
 
     for(j=0; j<QMAXARGS; j++) {
-       if((it->sqlvar[j].sqldata=malloc(sizeof(short)+ARGLEN))==NULL) {
+       if((it->sqlvar[j].sqldata=(char *)malloc(sizeof(short)+ARGLEN))==NULL) {
            com_err(whoami, MR_NO_MEM, "setting up SQLDA variables");
            exit(1);
        }
@@ -558,78 +563,6 @@ mr_fix_nulls_in_SQLDA(da)
     }
 }
 
-/* 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);  /** Could save this step by changing tlist from %s to %d **/
-
-    return(MR_SUCCESS);
-}
-
-/* prefetch_filesys():
- * Fetches the phys_id from filesys based on the filsys_id in argv[0].
- * Appends the filsys_id and the phys_id to the argv so they can be
- * referenced in an INSERT into a table other than filesys.  Also
- * see comments at prefetch_value().
- *
- * Assumes the existence of a row where filsys_id = argv[0], since a
- * filesys label has already been resolved to a filsys_id.
- */
-prefetch_filesys(q,argv,cl)
-    struct query *q;
-    char **argv;
-    client *cl;
-{
-    EXEC SQL BEGIN DECLARE SECTION;
-    int fid,phid;
-    EXEC SQL END DECLARE SECTION;
-    int argc;
-
-    fid = *(int *)argv[0];
-    EXEC SQL SELECT phys_id INTO :phid FROM filesys WHERE filsys_id = :fid;
-    if(ingres_errno) return(mr_errcode);
-
-    argc=q->argc+q->vcnt;
-    sprintf(argv[argc++],"%d",phid);
-    sprintf(argv[argc],"%d",fid);
-
-    return(MR_SUCCESS);
-}
-
 /* Convert normal Unix-style wildcards to SQL voodoo */
 convert_wildcards(arg)
     char *arg;
This page took 0.037513 seconds and 4 git commands to generate.