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 zoneHint = getValByKey (&specificQueryInp->condInput, ZONE_KW);
00022
00023 status = getAndConnRcatHost(rsComm, SLAVE_RCAT, zoneHint,
00024 &rodsServerHost);
00025 if (status < 0) {
00026 return(status);
00027 }
00028
00029 if (rodsServerHost->localFlag == LOCAL_HOST) {
00030 #ifdef RODS_CAT
00031 status = _rsSpecificQuery (rsComm, specificQueryInp, genQueryOut);
00032 #else
00033 rodsLog(LOG_NOTICE,
00034 "rsSpecificQuery error. RCAT is not configured on this host");
00035 return (SYS_NO_RCAT_SERVER_ERR);
00036 #endif
00037 } else {
00038 status = rcSpecificQuery(rodsServerHost->conn,
00039 specificQueryInp, genQueryOut);
00040 }
00041 if (status < 0 && status != CAT_NO_ROWS_FOUND) {
00042 rodsLog (LOG_NOTICE,
00043 "rsSpecificQuery: rcSpecificQuery failed, status = %d", status);
00044 }
00045 return (status);
00046 }
00047
00048 #ifdef RODS_CAT
00049 int
00050 _rsSpecificQuery (rsComm_t *rsComm, specificQueryInp_t *specificQueryInp,
00051 genQueryOut_t **genQueryOut)
00052 {
00053 int status;
00054
00055 *genQueryOut = (genQueryOut_t*)malloc(sizeof(genQueryOut_t));
00056 memset((char *)*genQueryOut, 0, sizeof(genQueryOut_t));
00057
00058 status = chlSpecificQuery(*specificQueryInp, *genQueryOut);
00059
00060 if (status == CAT_UNKNOWN_SPECIFIC_QUERY) {
00061 int i;
00062 i = addRErrorMsg (&rsComm->rError, 0, "The SQL is not pre-defined.\n See 'iadmin h asq' (add specific query)");
00063 if (i < 0)
00064 {
00065 eirods::log ( i, "addErrorMsg failed");
00066 }
00067 }
00068
00069 if (status < 0) {
00070 clearGenQueryOut (*genQueryOut);
00071 free (*genQueryOut);
00072 *genQueryOut = NULL;
00073 if (status != CAT_NO_ROWS_FOUND) {
00074 rodsLog (LOG_NOTICE,
00075 "_rsSpecificQuery: specificQuery status = %d", status);
00076 }
00077 return (status);
00078 }
00079 return (status);
00080 }
00081 #endif