Changeset 11320
- Timestamp:
- Jan 26, 2007, 12:24:37 PM (19 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 2 edited
-
db/psDB.c (modified) (9 diffs)
-
psErrorCodes_en.dat (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/db/psDB.c
r10999 r11320 12 12 * @author Joshua Hoblitt 13 13 * 14 * @version $Revision: 1.13 1$ $Name: not supported by cvs2svn $15 * @date $Date: 2007-01- 09 22:38:52$14 * @version $Revision: 1.132 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2007-01-26 22:24:37 $ 16 16 * 17 17 * Copyright (C) 2005-2006 Joshua Hoblitt, University of Hawaii … … 121 121 static void psDBAddToLookupTable(psHash *lookupTable, psU32 type, const char *string); 122 122 static void psDBAddVoidToLookupTable(psHash *lookupTable, psU32 type, psPtr value); 123 static psErrorCode mysqlTopsErr(MYSQL *mysql); 123 124 124 125 // pType utility functions … … 148 149 // Connect to host and mySql server with specified database 149 150 if (!mysql_real_connect(mysql, host, user, passwd, dbname, port, NULL, 0)) { 150 psError( PS_ERR_BAD_PARAMETER_TYPE, true,151 psError(mysqlTopsErr(dbh->mysql), true, 151 152 _("Failed to connect to database. Error: %s"),mysql_error(mysql)); 152 153 … … 162 163 // explicit transactions default to false 163 164 if (!psDBExplicitTrans(dbh, false)) { 164 psError( PS_ERR_UNKNOWN, true,165 psError(mysqlTopsErr(dbh->mysql), true, 165 166 "failed to set transaction type. Error: %s", mysql_error(mysql)); 166 167 … … 263 264 // Attempt to select new database 264 265 if (mysql_select_db(dbh->mysql, dbname) != 0) { 265 psError( PS_ERR_UNKNOWN, true, _("Failed to change database. Error: %s"),266 psError(mysqlTopsErr(dbh->mysql), true, _("Failed to change database. Error: %s"), 266 267 mysql_error(dbh->mysql)); 267 268 … … 389 390 // then something bad has happened. 390 391 if (fieldCount != 0) { 391 psError( PS_ERR_UNEXPECTED_NULL, true, _("Query returned no data. Error: %s"),392 psError(mysqlTopsErr(dbh->mysql), true, _("Query returned no data. Error: %s"), 392 393 mysql_error(dbh->mysql)); 393 394 return NULL; … … 823 824 824 825 if (mysql_real_query(dbh->mysql, query, (unsigned long)strlen(query)) !=0) { 825 //The following if statement was added to standardize outputs between platforms for testing purposes. 826 char mysqlTemp[165]; 827 strncpy(mysqlTemp, 828 "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'null) WHERE' at line 1", 165); 829 if ( !strncmp(mysql_error(dbh->mysql), mysqlTemp, 145) ) { 830 psError(PS_ERR_UNKNOWN, true, _("Failed to execute SQL query. Error: %s"), mysqlTemp); 831 } else { 832 psError(PS_ERR_UNKNOWN, true, _("Failed to execute SQL query. Error: %s"), mysql_error(dbh->mysql)); 833 } 826 psError(mysqlTopsErr(dbh->mysql), true, _("Failed to execute SQL query. Error: %s"), mysql_error(dbh->mysql)); 834 827 psFree(query); 835 828 return false; … … 951 944 // it's non-zero then something bad has happened. 952 945 if (fieldCount != 0) { 953 psError( PS_ERR_UNEXPECTED_NULL, true, "Query returned no data. Error: %s", mysql_error(dbh->mysql));946 psError(mysqlTopsErr(dbh->mysql), true, "Query returned no data. Error: %s", mysql_error(dbh->mysql)); 954 947 955 948 return NULL; … … 2414 2407 } 2415 2408 2409 static psErrorCode mysqlTopsErr(MYSQL *mysql) 2410 { 2411 unsigned int myerrno = mysql_errno(mysql); 2412 if ((myerrno >= 1000) && (myerrno < 2000)) { 2413 return PS_ERR_DB_SERVER; 2414 } else if ((myerrno >= 2000) && (myerrno < 3000)) { 2415 return PS_ERR_DB_CLIENT; 2416 } 2417 2418 return PS_ERR_UNKNOWN; 2419 } 2420 2416 2421 2417 2422 // pType utility functions -
trunk/psLib/src/psErrorCodes_en.dat
r10376 r11320 20 20 BAD_FITS file doesn't obey FITS standard 21 21 IEEE a NaN or Inf was detected 22 DB_CLIENT Database error originated in the client library 23 DB_SERVER Database error generated by the server
Note:
See TracChangeset
for help on using the changeset viewer.
