plugins/database/src/general_query.cpp
int findCycles( int startTable ) {
    int i, status;
    int treeNum;

    if ( firstCall ) {
        icatGeneralQuerySetup(); /* initialize */
    }
    firstCall = 0;

    for ( i = 0; i < nTables; i++ ) {
        Tables[i].flag = 0;
    }
    treeNum = 0;

    if ( startTable != 0 ) {
        if ( startTable > nTables ) {
            return CAT_INVALID_ARGUMENT;
        }
        treeNum++;
        status = tCycleChk( startTable, -1, treeNum );
        if ( debug > 1 ) {
            printf( "tree %d status %d\n", treeNum, status );
        }
        if ( status ) {
            return status;
        }
    }

    for ( i = 0; i < nTables; i++ ) {
        if ( Tables[i].flag == 0 ) {
            treeNum++;
            status = tCycleChk( i, -1, treeNum );
            if ( debug > 1 ) {
                printf( "tree %d status %d\n", treeNum, status );
            }
            if ( status ) {
                return status;
            }
        }
    }
    return 0;
}
/*
 This routine goes thru the tables and links looking for cycles.  If
 there are any cycles, it is a problem as that would mean that there
 are multiple paths between nodes.  So this needs to be run when
 tables or links are changed, but once confirmed that all is OK does
 not need to be run again.
*/
This routine goes thru the tables and links looking for cycles.  If
there are any cycles, it is a problem as that would mean that there
are multiple paths between nodes.  So this needs to be run when
tables or links are changed, but once confirmed that all is OK does
not need to be run again.
This routine goes thru the tables and links looking for cycles . If there are any cycles it is a problem as that would mean that there are multiple paths between nodes . So this needs to be run when tables or links are changed but once confirmed that all is OK does not need to be run again .
int findCycles( int startTable ) {
    int i, status;
    int treeNum;
    if ( firstCall ) {
        icatGeneralQuerySetup(); 
    }
    firstCall = 0;
    for ( i = 0; i < nTables; i++ ) {
        Tables[i].flag = 0;
    }
    treeNum = 0;
    if ( startTable != 0 ) {
        if ( startTable > nTables ) {
            return CAT_INVALID_ARGUMENT;
        }
        treeNum++;
        status = tCycleChk( startTable, -1, treeNum );
        if ( debug > 1 ) {
            printf( "tree %d status %d\n", treeNum, status );
        }
        if ( status ) {
            return status;
        }
    }
    for ( i = 0; i < nTables; i++ ) {
        if ( Tables[i].flag == 0 ) {
            treeNum++;
            status = tCycleChk( i, -1, treeNum );
            if ( debug > 1 ) {
                printf( "tree %d status %d\n", treeNum, status );
            }
            if ( status ) {
                return status;
            }
        }
    }
    return 0;
}
int findCycles ( int startTable ) { int i , status ; int treeNum ; if ( firstCall ) { icatGeneralQuerySetup ( ) ; } firstCall = 0 ; for ( i = 0 ; i < nTables ; i ++ ) { Tables [ i ] . flag = 0 ; } treeNum = 0 ; if ( startTable != 0 ) { if ( startTable > nTables ) { return CAT_INVALID_ARGUMENT ; } treeNum ++ ; status = tCycleChk ( startTable , -1 , treeNum ) ; if ( debug > 1 ) { printf ( " \n " , treeNum , status ) ; } if ( status ) { return status ; } } for ( i = 0 ; i < nTables ; i ++ ) { if ( Tables [ i ] . flag == 0 ) { treeNum ++ ; status = tCycleChk ( i , -1 , treeNum ) ; if ( debug > 1 ) { printf ( " \n " , treeNum , status ) ; } if ( status ) { return status ; } } } return 0 ; }
This routine goes thru the tables and links looking for cycles.
This routine goes thru the tables and links looking for cycles .
/* initialize */