IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 4262


Ignore:
Timestamp:
Jun 14, 2005, 3:47:30 PM (21 years ago)
Author:
evanalst
Message:

Update psDBChange to handle invalid arguments.

Location:
trunk/psLib/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/dataIO/psDB.c

    r4256 r4262  
    1212 *  @author Joshua Hoblitt
    1313 *
    14  *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2005-06-15 01:01:08 $
     14 *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2005-06-15 01:47:30 $
    1616 *
    1717 *  Copyright 2005 Joshua Hoblitt, University of Hawaii
     
    159159bool psDBChange(psDB *dbh, const char *dbname)
    160160{
     161    // Verify database object is valid
     162    if(dbh == NULL) {
     163        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
     164                PS_ERRORTEXT_psDB_INVALID_PSDB);
     165        return false;
     166    }
     167
     168    // Attempt to select new database
    161169    if (mysql_select_db(dbh->mysql, dbname) != 0) {
    162         psError(PS_ERR_UNKNOWN, true, "Failed to change database.  Error: %s", mysql_error(dbh->mysql));
     170        psError(PS_ERR_UNKNOWN, true, PS_ERRORTEXT_psDB_FAILED_TO_CHANGE,
     171                mysql_error(dbh->mysql));
    163172
    164173        return false;
  • trunk/psLib/src/dataIO/psFileUtilsErrors.dat

    r4256 r4262  
    5959psDB_INVALID_PSDB                      Invalid psDB has been specified.
    6060psDB_FAILED_TO_CONNECT                 Failed to connect to database.  Error: %s
     61psDB_FAILED_TO_CHANGE                  Failed to change database.  Error: %s
    6162#
    6263
  • trunk/psLib/src/dataIO/psFileUtilsErrors.h

    r4256 r4262  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-06-15 01:01:08 $
     9 *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-06-15 01:47:30 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    7878#define PS_ERRORTEXT_psDB_INVALID_PSDB "Invalid psDB has been specified."
    7979#define PS_ERRORTEXT_psDB_FAILED_TO_CONNECT "Failed to connect to database.  Error: %s"
     80#define PS_ERRORTEXT_psDB_FAILED_TO_CHANGE "Failed to change database.  Error: %s"
    8081//~End
    8182
  • trunk/psLib/src/db/psDB.c

    r4256 r4262  
    1212 *  @author Joshua Hoblitt
    1313 *
    14  *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2005-06-15 01:01:08 $
     14 *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2005-06-15 01:47:30 $
    1616 *
    1717 *  Copyright 2005 Joshua Hoblitt, University of Hawaii
     
    159159bool psDBChange(psDB *dbh, const char *dbname)
    160160{
     161    // Verify database object is valid
     162    if(dbh == NULL) {
     163        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
     164                PS_ERRORTEXT_psDB_INVALID_PSDB);
     165        return false;
     166    }
     167
     168    // Attempt to select new database
    161169    if (mysql_select_db(dbh->mysql, dbname) != 0) {
    162         psError(PS_ERR_UNKNOWN, true, "Failed to change database.  Error: %s", mysql_error(dbh->mysql));
     170        psError(PS_ERR_UNKNOWN, true, PS_ERRORTEXT_psDB_FAILED_TO_CHANGE,
     171                mysql_error(dbh->mysql));
    163172
    164173        return false;
Note: See TracChangeset for help on using the changeset viewer.