irods  4.2.8
About: iRODS (the integrated Rule Oriented Data System) is a distributed data-management system for creating data grids, digital libraries, persistent archives, and real-time data systems.
  Fossies Dox: irods-4.2.8.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

general_query.cpp File Reference
#include "rodsClient.h"
#include "icatHighLevelRoutines.hpp"
#include "mid_level.hpp"
#include "low_level.hpp"
#include "irods_virtual_path.hpp"
#include <boost/algorithm/string.hpp>
#include <string>
#include <algorithm>
Include dependency graph for general_query.cpp:

Go to the source code of this file.

Classes

struct  tlinks
 
struct  tTables
 
struct  tColumns
 

Macros

#define MINIMUM_COL_SIZE   50
 
#define MAX_LINKS_TABLES_OR_COLUMNS   500
 
#define MAX_TSQL   110
 
#define MAX_SQL_SIZE_GQ   MAX_SQL_SIZE_GENERAL_QUERY
 

Functions

void icatGeneralQuerySetup ()
 
int insertWhere (char *condition, int option)
 
int fkFindName (const char *tableName)
 
int sFklink (const char *table1, const char *table2, const char *connectingSQL)
 
int sTableInit ()
 
int sTable (const char *tableName, const char *tableAlias, int cycler)
 
int sColumn (int defineVal, const char *tableName, const char *columnName)
 
int sGetColumnInfo (int defineVal, char **tableName, char **columnName)
 
int tablePresent (char *table, char *sqlText)
 
int tScan (int table, int link)
 
int sTest (int i1, int i2)
 
int sTest2 (int i1, int i2, int i3)
 
int tCycleChk (int table, int link, int thisTreeNum)
 
int findCycles (int startTable)
 
int setTable (int column, int sel, int selectOption, int castOption)
 
void handleMultiDataAVUConditions (int nConditions)
 
void handleMultiCollAVUConditions (int nConditions)
 
int compoundConditionSpecified (char *condition)
 
int handleCompoundCondition (char *condition, int prevWhereLen)
 
void setOrderBy (genQueryInp_t genQueryInp, int column)
 
void setOrderByUser (genQueryInp_t genQueryInp)
 
int setBlank (char *string, int count)
 
int checkCondition (char *condition)
 
int addInClauseToWhereForParentOf (char *inArg)
 
int addInClauseToWhereForIn (char *inArg, int option)
 
int addBetweenClauseToWhere (char *inArg)
 
int genqAppendAccessCheck ()
 
int specialQueryIx (int ix)
 
int generateSpecialQuery (genQueryInp_t genQueryInp, char *resultingSQL)
 
int generateSQL (genQueryInp_t genQueryInp, char *resultingSQL, char *resultingCountSQL)
 
int checkCondInputAccess (genQueryInp_t genQueryInp, int statementNum, icatSessionStruct *icss, int continueFlag)
 
int chl_gen_query_access_control_setup_impl (const char *user, const char *zone, const char *host, int priv, int controlFlag)
 
int chl_gen_query_ticket_setup_impl (const char *ticket, const char *clientAddr)
 
int chl_gen_query_impl (genQueryInp_t genQueryInp, genQueryOut_t *result)
 
int chlDebugGenQuery (int mode)
 

Variables

int logSQLGenQuery
 
int firstCall = 1
 
char selectSQL [16000]
 
int selectSQLInitFlag
 
int doUpperCase
 
char fromSQL [16000]
 
char whereSQL [16000]
 
char orderBySQL [16000]
 
char groupBySQL [16000]
 
int mightNeedGroupBy
 
int fromCount
 
char accessControlUserName [(1024+64)]
 
char accessControlZone [(1024+64)]
 
int accessControlPriv
 
int accessControlControlFlag = 0
 
char sessionTicket [(1024+64)] = ""
 
char sessionClientAddr [(1024+64)] = ""
 
struct tlinks Links [500]
 
int nLinks
 
struct tTables Tables [500]
 
int nTables
 
struct tColumns Columns [500]
 
int nColumns
 
int nToFind
 
char tableAbbrevs
 
int debug = 0
 
int debug2 = 0
 

Macro Definition Documentation

◆ MAX_LINKS_TABLES_OR_COLUMNS

#define MAX_LINKS_TABLES_OR_COLUMNS   500

Definition at line 46 of file general_query.cpp.

◆ MAX_SQL_SIZE_GQ

#define MAX_SQL_SIZE_GQ   MAX_SQL_SIZE_GENERAL_QUERY

Definition at line 50 of file general_query.cpp.

◆ MAX_TSQL

#define MAX_TSQL   110

Definition at line 48 of file general_query.cpp.

◆ MINIMUM_COL_SIZE

#define MINIMUM_COL_SIZE   50

Definition at line 44 of file general_query.cpp.

Function Documentation

◆ addBetweenClauseToWhere()

int addBetweenClauseToWhere ( char *  inArg)

Definition at line 1404 of file general_query.cpp.

References CAT_BIND_VARIABLE_LIMIT_EXCEEDED, CAT_INVALID_ARGUMENT, cllBindVarCount, cllBindVars, MAX_BIND_VARS, MAX_SQL_SIZE_GQ, rstrcat(), rstrcpy(), rstrncat(), USER_STRLEN_TOOLONG, and whereSQL.

Referenced by insertWhere().

Here is the call graph for this function:

◆ addInClauseToWhereForIn()

int addInClauseToWhereForIn ( char *  inArg,
int  option 
)

Definition at line 1341 of file general_query.cpp.

References CAT_BIND_VARIABLE_LIMIT_EXCEEDED, CAT_INVALID_ARGUMENT, cllBindVarCount, cllBindVars, MAX_BIND_VARS, MAX_SQL_SIZE_GQ, rstrcat(), rstrcpy(), rstrncat(), USER_STRLEN_TOOLONG, and whereSQL.

Referenced by insertWhere().

Here is the call graph for this function:

◆ addInClauseToWhereForParentOf()

int addInClauseToWhereForParentOf ( char *  inArg)

Definition at line 1231 of file general_query.cpp.

References BAD_FUNCTION_CALL, CAT_BIND_VARIABLE_LIMIT_EXCEEDED, cllBindVarCount, cllBindVars, irods.pyparsing::empty, irods::get_virtual_path_separator(), LOG_ERROR, MAX_BIND_VARS, MAX_SQL_SIZE_GQ, rodsLog(), rstrcat(), USER_STRLEN_TOOLONG, and whereSQL.

Referenced by insertWhere().

Here is the call graph for this function:

◆ checkCondInputAccess()

◆ checkCondition()

int checkCondition ( char *  condition)

Definition at line 1157 of file general_query.cpp.

References CAT_INVALID_ARGUMENT, NULL, rstrcpy(), setBlank(), and USER_STRLEN_TOOLONG.

Referenced by insertWhere().

Here is the call graph for this function:

◆ chl_gen_query_access_control_setup_impl()

int chl_gen_query_access_control_setup_impl ( const char *  user,
const char *  zone,
const char *  host,
int  priv,
int  controlFlag 
)

Definition at line 2243 of file general_query.cpp.

References accessControlControlFlag, accessControlPriv, accessControlUserName, accessControlZone, MAX_NAME_LEN, NULL, rstrcpy(), and USER_STRLEN_TOOLONG.

Here is the call graph for this function:

◆ chl_gen_query_impl()

◆ chl_gen_query_ticket_setup_impl()

int chl_gen_query_ticket_setup_impl ( const char *  ticket,
const char *  clientAddr 
)

Definition at line 2278 of file general_query.cpp.

References LOG_NOTICE, rodsLog(), rstrcpy(), sessionClientAddr, sessionTicket, and USER_STRLEN_TOOLONG.

Here is the call graph for this function:

◆ chlDebugGenQuery()

int chlDebugGenQuery ( int  mode)

Definition at line 2576 of file general_query.cpp.

References logSQLGenQuery, and mode.

◆ compoundConditionSpecified()

int compoundConditionSpecified ( char *  condition)

Definition at line 922 of file general_query.cpp.

References MAX_NAME_LEN, and NULL.

Referenced by generateSQL().

◆ findCycles()

int findCycles ( int  startTable)

Definition at line 589 of file general_query.cpp.

References CAT_INVALID_ARGUMENT, debug, firstCall, tTables::flag, icatGeneralQuerySetup(), nTables, irods.pypyodbc::status, Tables, and tCycleChk().

Here is the call graph for this function:

◆ fkFindName()

int fkFindName ( const char *  tableName)

Definition at line 140 of file general_query.cpp.

References LOG_ERROR, nTables, rodsLog(), irods.pyparsing::tableName, and Tables.

Referenced by sFklink().

Here is the call graph for this function:

◆ generateSpecialQuery()

int generateSpecialQuery ( genQueryInp_t  genQueryInp,
char *  resultingSQL 
)

Definition at line 1749 of file general_query.cpp.

References CAT_INVALID_ARGUMENT, chlGetLocalZone(), cllBindVarCount, cllBindVars, COL_R_RESC_NAME, COL_USER_NAME, InxValPair::inx, InxValPair::len, LOG_DEBUG, LOG_ERROR, LONG_NAME_LEN, MAX_SQL_SIZE_GQ, NAME_LEN, parseUserName(), rodsLog(), GenQueryInp::sqlCondInp, irods.pypyodbc::status, and InxValPair::value.

Referenced by chl_gen_query_impl().

Here is the call graph for this function:

◆ generateSQL()

int generateSQL ( genQueryInp_t  genQueryInp,
char *  resultingSQL,
char *  resultingCountSQL 
)

◆ genqAppendAccessCheck()

int genqAppendAccessCheck ( )

Definition at line 1615 of file general_query.cpp.

References accessControlControlFlag, accessControlPriv, accessControlUserName, accessControlZone, ANONYMOUS_USER, CAT_BIND_VARIABLE_LIMIT_EXCEEDED, cllBindVarCount, cllBindVars, LOCAL_PRIV_USER_AUTH, MAX_BIND_VARS, MAX_NAME_LEN, MAX_SQL_SIZE_GQ, NULL, rstrcat(), selectSQL, sessionTicket, USER_STRLEN_TOOLONG, and whereSQL.

Referenced by generateSQL().

Here is the call graph for this function:

◆ handleCompoundCondition()

int handleCompoundCondition ( char *  condition,
int  prevWhereLen 
)

Definition at line 963 of file general_query.cpp.

References insertWhere(), MAX_NAME_LEN, MAX_SQL_SIZE_GQ, NULL, rstrcat(), rstrcpy(), irods.pypyodbc::status, type, USER_STRLEN_TOOLONG, and whereSQL.

Referenced by generateSQL().

Here is the call graph for this function:

◆ handleMultiCollAVUConditions()

void handleMultiCollAVUConditions ( int  nConditions)

Definition at line 844 of file general_query.cpp.

References fromSQL, MAX_SQL_SIZE_GQ, NULL, rstrcat(), and whereSQL.

Referenced by generateSQL().

Here is the call graph for this function:

◆ handleMultiDataAVUConditions()

void handleMultiDataAVUConditions ( int  nConditions)

Definition at line 771 of file general_query.cpp.

References fromSQL, MAX_SQL_SIZE_GQ, NULL, rstrcat(), and whereSQL.

Referenced by generateSQL().

Here is the call graph for this function:

◆ icatGeneralQuerySetup()

void icatGeneralQuerySetup ( )

Definition at line 35 of file general_query_setup.cpp.

Referenced by findCycles(), generateSQL(), sTest(), and sTest2().

◆ insertWhere()

int insertWhere ( char *  condition,
int  option 
)

Definition at line 1461 of file general_query.cpp.

References addBetweenClauseToWhere(), addInClauseToWhereForIn(), addInClauseToWhereForParentOf(), CAT_BIND_VARIABLE_LIMIT_EXCEEDED, CAT_INVALID_ARGUMENT, checkCondition(), cllBindVarCount, cllBindVars, MAX_BIND_VARS, MAX_SQL_SIZE_GQ, NULL, rstrcat(), rstrcpy(), irods.pypyodbc::status, USER_STRLEN_TOOLONG, and whereSQL.

Referenced by generateSQL(), and handleCompoundCondition().

Here is the call graph for this function:

◆ sColumn()

int sColumn ( int  defineVal,
const char *  tableName,
const char *  columnName 
)

Definition at line 218 of file general_query.cpp.

References CAT_TOO_MANY_TABLES, irods.pyparsing::columnName, Columns, debug, tColumns::defineValue, LOG_ERROR, MAX_LINKS_TABLES_OR_COLUMNS, nColumns, rodsLog(), and irods.pyparsing::tableName.

Referenced by icatGeneralQuerySetup().

Here is the call graph for this function:

◆ setBlank()

int setBlank ( char *  string,
int  count 
)

Definition at line 1144 of file general_query.cpp.

Referenced by checkCondition().

◆ setOrderBy()

void setOrderBy ( genQueryInp_t  genQueryInp,
int  column 
)

Definition at line 1076 of file general_query.cpp.

References irods.pyparsing::columnName, Columns, InxIvalPair::inx, InxIvalPair::len, MAX_SQL_SIZE_GQ, nColumns, orderBySQL, rstrcat(), SELECT_AVG, SELECT_COUNT, SELECT_MAX, SELECT_MIN, SELECT_SUM, GenQueryInp::selectInp, irods.pyparsing::tableName, and InxIvalPair::value.

Referenced by generateSQL().

Here is the call graph for this function:

◆ setOrderByUser()

void setOrderByUser ( genQueryInp_t  genQueryInp)

Definition at line 1119 of file general_query.cpp.

References irods.pyparsing::columnName, Columns, InxIvalPair::inx, InxIvalPair::len, MAX_SQL_SIZE_GQ, nColumns, ORDER_BY, ORDER_BY_DESC, orderBySQL, rstrcat(), GenQueryInp::selectInp, irods.pyparsing::tableName, and InxIvalPair::value.

Referenced by generateSQL().

Here is the call graph for this function:

◆ setTable()

int setTable ( int  column,
int  sel,
int  selectOption,
int  castOption 
)

Definition at line 640 of file general_query.cpp.

References CAT_UNKNOWN_TABLE, irods.pyparsing::columnName, Columns, debug, doUpperCase, tTables::flag, fromCount, fromSQL, groupBySQL, MAX_SQL_SIZE_GQ, mightNeedGroupBy, nColumns, nTables, nToFind, rstrcat(), SELECT_AVG, SELECT_COUNT, SELECT_MAX, SELECT_MIN, SELECT_SUM, selectSQL, selectSQLInitFlag, tTables::tableAbbrev, tableAbbrevs, irods.pyparsing::tableName, tablePresent(), Tables, USER_STRLEN_TOOLONG, and whereSQL.

Referenced by generateSQL().

Here is the call graph for this function:

◆ sFklink()

int sFklink ( const char *  table1,
const char *  table2,
const char *  connectingSQL 
)

Definition at line 157 of file general_query.cpp.

References CAT_TOO_MANY_TABLES, debug, debug2, fkFindName(), Links, LOG_ERROR, MAX_LINKS_TABLES_OR_COLUMNS, nLinks, rodsLog(), tlinks::table1, and tlinks::table2.

Referenced by icatGeneralQuerySetup().

Here is the call graph for this function:

◆ sGetColumnInfo()

int sGetColumnInfo ( int  defineVal,
char **  tableName,
char **  columnName 
)

◆ specialQueryIx()

int specialQueryIx ( int  ix)

◆ sTable()

int sTable ( const char *  tableName,
const char *  tableAlias,
int  cycler 
)

Definition at line 202 of file general_query.cpp.

References CAT_TOO_MANY_TABLES, tTables::cycler, debug, LOG_ERROR, MAX_LINKS_TABLES_OR_COLUMNS, nTables, rodsLog(), irods.pyparsing::tableName, and Tables.

Referenced by icatGeneralQuerySetup().

Here is the call graph for this function:

◆ sTableInit()

int sTableInit ( )

Definition at line 179 of file general_query.cpp.

References Columns, Links, nColumns, nLinks, nTables, and Tables.

Referenced by icatGeneralQuerySetup().

◆ sTest()

int sTest ( int  i1,
int  i2 
)

Definition at line 462 of file general_query.cpp.

References firstCall, tTables::flag, icatGeneralQuerySetup(), nTables, nToFind, Tables, and tScan().

Here is the call graph for this function:

◆ sTest2()

int sTest2 ( int  i1,
int  i2,
int  i3 
)

Definition at line 488 of file general_query.cpp.

References firstCall, tTables::flag, icatGeneralQuerySetup(), nTables, nToFind, Tables, and tScan().

Here is the call graph for this function:

◆ tablePresent()

int tablePresent ( char *  table,
char *  sqlText 
)

Definition at line 255 of file general_query.cpp.

References debug, and NULL.

Referenced by setTable(), and tScan().

◆ tCycleChk()

int tCycleChk ( int  table,
int  link,
int  thisTreeNum 
)

Definition at line 519 of file general_query.cpp.

References debug, tTables::flag, Links, nLinks, and Tables.

Referenced by findCycles().

◆ tScan()

int tScan ( int  table,
int  link 
)

Definition at line 332 of file general_query.cpp.

References debug, tTables::flag, fromSQL, Links, MAX_SQL_SIZE_GQ, nLinks, nToFind, rstrcat(), tablePresent(), Tables, USER_STRLEN_TOOLONG, and whereSQL.

Referenced by generateSQL(), sTest(), and sTest2().

Here is the call graph for this function:

Variable Documentation

◆ accessControlControlFlag

int accessControlControlFlag = 0

◆ accessControlPriv

int accessControlPriv

◆ accessControlUserName

char accessControlUserName[(1024+64)]

◆ accessControlZone

char accessControlZone[(1024+64)]

◆ Columns

◆ debug

◆ debug2

int debug2 = 0

Definition at line 101 of file general_query.cpp.

Referenced by sFklink().

◆ doUpperCase

int doUpperCase

Definition at line 55 of file general_query.cpp.

Referenced by generateSQL(), and setTable().

◆ firstCall

int firstCall = 1

Definition at line 51 of file general_query.cpp.

Referenced by chl_general_update_impl(), findCycles(), generateSQL(), sTest(), and sTest2().

◆ fromCount

int fromCount

Definition at line 61 of file general_query.cpp.

Referenced by generateSQL(), and setTable().

◆ fromSQL

char fromSQL[ 16000]

◆ groupBySQL

char groupBySQL[ 16000]

Definition at line 59 of file general_query.cpp.

Referenced by generateSQL(), and setTable().

◆ Links

struct tlinks Links[ 500 ]

Referenced by sFklink(), sTableInit(), tCycleChk(), and tScan().

◆ logSQLGenQuery

int logSQLGenQuery

Definition at line 39 of file icatHighLevelRoutines.cpp.

Referenced by chl_gen_query_impl(), chlDebug(), and chlDebugGenQuery().

◆ mightNeedGroupBy

int mightNeedGroupBy

Definition at line 60 of file general_query.cpp.

Referenced by generateSQL(), and setTable().

◆ nColumns

◆ nLinks

int nLinks

Definition at line 76 of file general_query.cpp.

Referenced by sFklink(), sTableInit(), tCycleChk(), and tScan().

◆ nTables

int nTables

◆ nToFind

int nToFind

Definition at line 96 of file general_query.cpp.

Referenced by generateSQL(), setTable(), sTest(), sTest2(), and tScan().

◆ orderBySQL

char orderBySQL[ 16000]

Definition at line 58 of file general_query.cpp.

Referenced by generateSQL(), setOrderBy(), and setOrderByUser().

◆ selectSQL

char selectSQL[ 16000]

Definition at line 53 of file general_query.cpp.

Referenced by generateSQL(), genqAppendAccessCheck(), and setTable().

◆ selectSQLInitFlag

int selectSQLInitFlag

Definition at line 54 of file general_query.cpp.

Referenced by generateSQL(), and setTable().

◆ sessionClientAddr

char sessionClientAddr[(1024+64)] = ""

Definition at line 67 of file general_query.cpp.

Referenced by checkCondInputAccess(), and chl_gen_query_ticket_setup_impl().

◆ sessionTicket

char sessionTicket[(1024+64)] = ""

◆ tableAbbrevs

char tableAbbrevs

Definition at line 98 of file general_query.cpp.

Referenced by generateSQL(), and setTable().

◆ Tables

◆ whereSQL