00001
00002
00003
00004
00005
00006 #include "specificQuery.h"
00007 #include "icatHighLevelRoutines.h"
00008 #include "miscUtil.h"
00009
00010
00011
00012 int
00013 rsSpecificQuery (rsComm_t *rsComm, specificQueryInp_t *specificQueryInp,
00014 genQueryOut_t **genQueryOut)
00015 {
00016 rodsServerHost_t *rodsServerHost;
00017 int status;
00018 char *zoneHint="";
00019
00020
00021
00022 status = getAndConnRcatHost(rsComm, SLAVE_RCAT, zoneHint,
00023 &rodsServerHost);
00024 if (status < 0) {
00025 return(status);
00026 }
00027
00028 if (rodsServerHost->localFlag == LOCAL_HOST) {
00029 #ifdef RODS_CAT
00030 status = _rsSpecificQuery (rsComm, specificQueryInp, genQueryOut);
00031 #else
00032 rodsLog(LOG_NOTICE,
00033 "rsSpecificQuery error. RCAT is not configured on this host");
00034 return (SYS_NO_RCAT_SERVER_ERR);
00035 #endif
00036 } else {
00037 status = rcSpecificQuery(rodsServerHost->conn,
00038 specificQueryInp, genQueryOut);
00039 }
00040 if (status < 0 && status != CAT_NO_ROWS_FOUND) {
00041 rodsLog (LOG_NOTICE,
00042 "rsSpecificQuery: rcSpecificQuery failed, status = %d", status);
00043 }
00044 return (status);
00045 }
00046
00047 #ifdef RODS_CAT
00048 int
00049 _rsSpecificQuery (rsComm_t *rsComm, specificQueryInp_t *specificQueryInp,
00050 genQueryOut_t **genQueryOut)
00051 {
00052 int status;
00053
00054 *genQueryOut = (genQueryOut_t*)malloc(sizeof(genQueryOut_t));
00055 memset((char *)*genQueryOut, 0, sizeof(genQueryOut_t));
00056
00057 status = chlSpecificQuery(*specificQueryInp, *genQueryOut);
00058
00059 if (status == CAT_UNKNOWN_SPECIFIC_QUERY) {
00060 int i;
00061 i = addRErrorMsg (&rsComm->rError, 0, "The SQL is not pre-defined.\n See 'iadmin h asq' (add specific query)");
00062 }
00063
00064 if (status < 0) {
00065 clearGenQueryOut (*genQueryOut);
00066 free (*genQueryOut);
00067 *genQueryOut = NULL;
00068 if (status != CAT_NO_ROWS_FOUND) {
00069 rodsLog (LOG_NOTICE,
00070 "_rsSpecificQuery: specificQuery status = %d", status);
00071 }
00072 return (status);
00073 }
00074 return (status);
00075 }
00076 #endif