Public Member Functions | Private Member Functions | Private Attributes | Friends

rm_DB Class Reference
[Resource Manager Database Library]

#include <rmdb.h>

List of all members.

Public Member Functions

void Connect (rm_String &username, rm_String &password)
void Disconnect ()

Private Member Functions

bool Init ()
bool Drop ()
void DefineExtFunctions ()
void ExistExtFunctions ()
void Check ()
 rm_DB ()
 ~rm_DB ()

Private Attributes

bool connected
 log_CLASSID_m

Friends

class rm_Operator

Detailed Description

Definition at line 784 of file rmdb.h.


Constructor & Destructor Documentation

rm_DB::rm_DB (  )  [private]

Definition at line 298 of file librmdb.exx.

References FB_shutdownCallback(), and log_FUNC_m.

              { 
    log_FUNC_m(rm_DB);

#if TGT_OS_linux

    ISC_STATUS_ARRAY status;
    if (fb_shutdown_callback(status, FB_shutdownCallback, fb_shut_preproviders, 0)) {
        isc_print_status(status);
    }
#endif
    
} //rm_DB::rm_DB ()

Here is the call graph for this function:

rm_DB::~rm_DB (  )  [private]

Definition at line 313 of file librmdb.exx.

References g_ShutdownPermitted, log_FUNC_m, and cmn_Semaphore::Post().

               {
    log_FUNC_m(~rm_DB);
    g_ShutdownPermitted.Post();
} //rm_DB::~rm_DB ()

Here is the call graph for this function:


Member Function Documentation

void rm_DB::Check (  )  [private]

Definition at line 365 of file librmdb.exx.

References dbg_NORM, log_DBG_m, log_FUNC_m, and TableExists().

Referenced by Connect().

                  {
    log_FUNC_m(Check);

    //ExistExtFunctions();
    TableExists("LIBRARY");
    TableExists("DRIVE");
    TableExists("DRIVEHOST");
    TableExists("DISKSUBSYS");
    TableExists("MEDIAPOOL");
    TableExists("SLOT");
    TableExists("MEDIA");
    TableExists("MEDIAVOL");
    TableExists("PARTITION");
    TableExists("JOBID");

    log_DBG_m(dbg_NORM,"Check Tables success");
/* user check NYI
    Int32_t userCount = 0;
    char userName[100];
    strcpy( userName, g_cmn.si.m_userName.c_str());

    unsigned int i = 0;
    while ( userName[i] != '\0' ){
        userName[i] = toupper(userName[i]);
        i++;
    }

    EXEC SQL
        SELECT COUNT (*)
        INTO :userCount
        FROM RDB$USER_PRIVILEGES
        WHERE RDB$USER = :userName;

    if ( userCount == 0 ) {
        ostringstream str;
        str << "No grant permission for user " << userName;
        log_DBG_m(dbg_LOW, str.str() << " count:" << userCount);
        throw ivd_Error(ie_RMDB_ERROR, str.str());
    }
*/
}

Here is the call graph for this function:

Here is the caller graph for this function:

void rm_DB::Connect ( rm_String username,
rm_String password 
)

Definition at line 250 of file librmdb.exx.

References Check(), rm_String::cvalue_p, dbg_LOW, errorDesc(), evt_ERROR, g_dbName(), log_DBG_m, log_FUNC_m, log_WriteEvent(), and SQL_NOERROR.

Referenced by rm_DBThread::Resume(), and rm_Operator::rm_Operator().

                                                            {
    log_FUNC_m(Connect);

    log_DBG_m(dbg_LOW, "g_dbName:" << g_dbName);

    EXEC SQL
        CONNECT DB USER :username.cvalue_p PASSWORD :password.cvalue_p;

    if (SQLCODE != SQL_NOERROR) {
        string sqlErrDesc = errorDesc(SQLCODE,"Can not Connect DB");
        log_WriteEvent(evt_ERROR, "Database can't be accessed. Is DB Server running?");
        throw ivd_DBException( SQLCODE ,sqlErrDesc, true);

        //throw ivd_Error( ie_RMDB_CONNECTPROBLEM ,"Can not connect to DB", true);
    };
    log_DBG_m(dbg_LOW, "CONNECTED");
    Check();


}//rm_DB::Connect()

Here is the call graph for this function:

Here is the caller graph for this function:

void rm_DB::DefineExtFunctions (  )  [private]

Definition at line 425 of file librmdb.exx.

References dbg_NORM, errorDesc(), ExistExtFunctions(), log_DBG_m, log_FUNC_m, and SQL_CHECK_M.

                               {
    log_FUNC_m(DefineExtFunctions);

    try {
        ExistExtFunctions();
        log_DBG_m(dbg_NORM,"External function exists");
    } catch (ivd_Error) {
        EXEC SQL DECLARE EXTERNAL FUNCTION bin_and
                    INTEGER, INTEGER
                    RETURNS INTEGER BY VALUE
                    ENTRY_POINT 'IB_UDF_bin_and' MODULE_NAME 'ib_udf';

        string sqlErrDesc = errorDesc(SQLCODE, "define external function bin_and");
        SQL_CHECK_M( sqlErrDesc );
    };
} //rm_DB::DefineExtFunctions

Here is the call graph for this function:

void rm_DB::Disconnect (  ) 

Definition at line 273 of file librmdb.exx.

References connected, dbg_LOW, errorDesc(), ie_RMDB_CONNECTPROBLEM, ivd_Error, log_DBG_m, log_FUNC_m, and SQL_NOERROR.

Referenced by rm_DBThread::Suspend(), and rm_Operator::~rm_Operator().

                       {
    log_FUNC_m(Disconnect);

   if (DB) {           /* Is the Database. connected?*/

       EXEC SQL
            DISCONNECT DB;

       if (SQLCODE != SQL_NOERROR) {

           string sqlErrDesc = errorDesc(SQLCODE,"Can not disconnect DB");
           throw ivd_DBException( SQLCODE ,sqlErrDesc, true);

           //throw ivd_Error( ie_RMDB_CONNECTPROBLEM ,"Can not disconnect DB", true);
       };
       connected = false;
       log_DBG_m(dbg_LOW, "DISCONNECT");
   }
   else {
       throw ivd_Error( ie_RMDB_CONNECTPROBLEM ,"Database NOT Connected. Cannot disconnect", true);
   }
}//rm_DB::Disconnect()

Here is the call graph for this function:

Here is the caller graph for this function:

bool rm_DB::Drop (  )  [private]
void rm_DB::ExistExtFunctions (  )  [private]

Definition at line 410 of file librmdb.exx.

References dbg_LOW, ie_RMDB_ERROR, ivd_Error, log_DBG_m, log_FUNC_m, and SQL_NOERROR.

Referenced by DefineExtFunctions().

                              {

    log_FUNC_m(ExistExtFunctions);
    EXEC SQL SELECT RDB$FUNCTION_NAME FROM RDB$FUNCTIONS WHERE RDB$FUNCTION_NAME = 'BIN_AND';

    if (SQLCODE != SQL_NOERROR) {
        throw ivd_Error(ie_RMDB_ERROR, "Missing External Function BIN_AND:" + SQLCODE);
    }
    else {
        log_DBG_m(dbg_LOW, "Found External Function BIN_AND");
    };
} //rm_DB::ExistExtFunctions()

Here is the caller graph for this function:

bool rm_DB::Init (  )  [private]

Friends And Related Function Documentation

friend class rm_Operator [friend]

Definition at line 785 of file rmdb.h.


Member Data Documentation

bool rm_DB::connected [private]

Definition at line 792 of file rmdb.h.

Referenced by Disconnect().

Definition at line 846 of file rmdb.h.


The documentation for this class was generated from the following files: