Changeset 4269
- Timestamp:
- Jun 14, 2005, 5:20:04 PM (21 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 4 edited
-
dataIO/psDB.c (modified) (5 diffs)
-
dataIO/psFileUtilsErrors.dat (modified) (1 diff)
-
dataIO/psFileUtilsErrors.h (modified) (2 diffs)
-
db/psDB.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/dataIO/psDB.c
r4262 r4269 12 12 * @author Joshua Hoblitt 13 13 * 14 * @version $Revision: 1.2 3$ $Name: not supported by cvs2svn $15 * @date $Date: 2005-06-15 0 1:47:30$14 * @version $Revision: 1.24 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2005-06-15 03:20:04 $ 16 16 * 17 17 * Copyright 2005 Joshua Hoblitt, University of Hawaii … … 200 200 bool status; 201 201 202 // Verify the database object is not NULL 203 if(dbh == NULL) { 204 psError(PS_ERR_BAD_PARAMETER_NULL,true,PS_ERRORTEXT_psDB_INVALID_PSDB); 205 return false; 206 } 207 208 // Generate SQL query string 202 209 query = psDBGenerateCreateTableSQL(tableName, md); 203 210 if (!query) { 204 psError(PS_ERR_UNEXPECTED_NULL, false, "Query generation failed.");205 206 return NULL;207 } 208 211 psError(PS_ERR_UNEXPECTED_NULL, false, PS_ERRORTEXT_psDB_QUERY_GEN_FAIL); 212 return false; 213 } 214 215 // Run SQL query to create table 209 216 status = p_psDBRunQuery(dbh, query); 210 217 if (!status) { 211 psError(PS_ERR_UNKNOWN, false, "Failed to create table."); 212 } 213 218 psError(PS_ERR_UNKNOWN, false, PS_ERRORTEXT_psDB_TABLE_CREATE_FAIL); 219 } 220 221 // Free query string 214 222 psFree(query); 215 223 … … 775 783 bool p_psDBRunQuery(psDB *dbh, const char *query) 776 784 { 785 // Verify database object is not NULL 786 if(dbh == NULL) { 787 psError(PS_ERR_BAD_PARAMETER_NULL,true,PS_ERRORTEXT_psDB_INVALID_PSDB); 788 return false; 789 } 790 791 // Run query 777 792 if (mysql_real_query(dbh->mysql, query, (unsigned long)strlen(query)) !=0) { 778 psError(PS_ERR_UNKNOWN, true, "Failed to execute query. Error: %s\n", mysql_error(dbh->mysql)); 779 793 psError(PS_ERR_UNKNOWN, true, PS_ERRORTEXT_psDB_SQL_QUERY_FAIL, mysql_error(dbh->mysql)); 780 794 return false; 781 795 } … … 880 894 char *colType; // type lookup table 881 895 882 if (!table) {883 psError(PS_ERR_BAD_PARAMETER_NULL, true, "table param may not be null.");884 896 // Verify input parameters are not null 897 if ( (tableName==NULL) || (table==NULL) ) { 898 psError(PS_ERR_BAD_PARAMETER_NULL, true, PS_ERRORTEXT_psDB_TABLE_PARAM_NULL); 885 899 return NULL; 886 900 } 887 901 902 // Begin to create SQL string to create table 888 903 psStringAppend(&query, "CREATE TABLE %s (", tableName); 889 904 905 // Set list iterator at head of list 890 906 cursor = psListIteratorAlloc(table->list, 0, false); 891 907 … … 922 938 } 923 939 940 // Reset iterator to head of list 924 941 psListIteratorSet(cursor, 0); 925 942 -
trunk/psLib/src/dataIO/psFileUtilsErrors.dat
r4262 r4269 60 60 psDB_FAILED_TO_CONNECT Failed to connect to database. Error: %s 61 61 psDB_FAILED_TO_CHANGE Failed to change database. Error: %s 62 psDB_TABLE_PARAM_NULL Create table parameters may not be NULL. 63 psDB_QUERY_GEN_FAIL Query generation failed. 64 psDB_TABLE_CREATE_FAIL Failed to create table. 65 psDB_SQL_QUERY_FAIL Failed to execute SQL query. Error: %s 62 66 # 63 67 -
trunk/psLib/src/dataIO/psFileUtilsErrors.h
r4262 r4269 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1.1 6$ $Name: not supported by cvs2svn $10 * @date $Date: 2005-06-15 0 1:47:30$9 * @version $Revision: 1.17 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2005-06-15 03:20:04 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 79 79 #define PS_ERRORTEXT_psDB_FAILED_TO_CONNECT "Failed to connect to database. Error: %s" 80 80 #define PS_ERRORTEXT_psDB_FAILED_TO_CHANGE "Failed to change database. Error: %s" 81 #define PS_ERRORTEXT_psDB_TABLE_PARAM_NULL "Create table parameters may not be NULL." 82 #define PS_ERRORTEXT_psDB_QUERY_GEN_FAIL "Query generation failed." 83 #define PS_ERRORTEXT_psDB_TABLE_CREATE_FAIL "Failed to create table." 84 #define PS_ERRORTEXT_psDB_SQL_QUERY_FAIL "Failed to execute SQL query. Error: %s" 81 85 //~End 82 86 -
trunk/psLib/src/db/psDB.c
r4262 r4269 12 12 * @author Joshua Hoblitt 13 13 * 14 * @version $Revision: 1.2 3$ $Name: not supported by cvs2svn $15 * @date $Date: 2005-06-15 0 1:47:30$14 * @version $Revision: 1.24 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2005-06-15 03:20:04 $ 16 16 * 17 17 * Copyright 2005 Joshua Hoblitt, University of Hawaii … … 200 200 bool status; 201 201 202 // Verify the database object is not NULL 203 if(dbh == NULL) { 204 psError(PS_ERR_BAD_PARAMETER_NULL,true,PS_ERRORTEXT_psDB_INVALID_PSDB); 205 return false; 206 } 207 208 // Generate SQL query string 202 209 query = psDBGenerateCreateTableSQL(tableName, md); 203 210 if (!query) { 204 psError(PS_ERR_UNEXPECTED_NULL, false, "Query generation failed.");205 206 return NULL;207 } 208 211 psError(PS_ERR_UNEXPECTED_NULL, false, PS_ERRORTEXT_psDB_QUERY_GEN_FAIL); 212 return false; 213 } 214 215 // Run SQL query to create table 209 216 status = p_psDBRunQuery(dbh, query); 210 217 if (!status) { 211 psError(PS_ERR_UNKNOWN, false, "Failed to create table."); 212 } 213 218 psError(PS_ERR_UNKNOWN, false, PS_ERRORTEXT_psDB_TABLE_CREATE_FAIL); 219 } 220 221 // Free query string 214 222 psFree(query); 215 223 … … 775 783 bool p_psDBRunQuery(psDB *dbh, const char *query) 776 784 { 785 // Verify database object is not NULL 786 if(dbh == NULL) { 787 psError(PS_ERR_BAD_PARAMETER_NULL,true,PS_ERRORTEXT_psDB_INVALID_PSDB); 788 return false; 789 } 790 791 // Run query 777 792 if (mysql_real_query(dbh->mysql, query, (unsigned long)strlen(query)) !=0) { 778 psError(PS_ERR_UNKNOWN, true, "Failed to execute query. Error: %s\n", mysql_error(dbh->mysql)); 779 793 psError(PS_ERR_UNKNOWN, true, PS_ERRORTEXT_psDB_SQL_QUERY_FAIL, mysql_error(dbh->mysql)); 780 794 return false; 781 795 } … … 880 894 char *colType; // type lookup table 881 895 882 if (!table) {883 psError(PS_ERR_BAD_PARAMETER_NULL, true, "table param may not be null.");884 896 // Verify input parameters are not null 897 if ( (tableName==NULL) || (table==NULL) ) { 898 psError(PS_ERR_BAD_PARAMETER_NULL, true, PS_ERRORTEXT_psDB_TABLE_PARAM_NULL); 885 899 return NULL; 886 900 } 887 901 902 // Begin to create SQL string to create table 888 903 psStringAppend(&query, "CREATE TABLE %s (", tableName); 889 904 905 // Set list iterator at head of list 890 906 cursor = psListIteratorAlloc(table->list, 0, false); 891 907 … … 922 938 } 923 939 940 // Reset iterator to head of list 924 941 psListIteratorSet(cursor, 0); 925 942
Note:
See TracChangeset
for help on using the changeset viewer.
