---------------------
PatchSet 251
Date: 2005/05/16 21:57:14
Author: jhoblitt
Branch: HEAD
Tag: (none)
Log:
rename psDBRunQuery -> p_psDBRunQuery and make the symbol public
Members:
src/dataIO/psDB.c:1.1->1.2
src/dataIO/psDB.h:1.1->1.2
diff -u pslib/src/dataIO/psDB.c:1.1 pslib/src/dataIO/psDB.c:1.2
|
old
|
new
|
|
| 11 | 11 | * @author Aaron Culliney |
| 12 | 12 | * @author Joshua Hoblitt |
| 13 | 13 | * |
| 14 | | * @version $Revision: 1.1 $ $Name: $ |
| 15 | | * @date $Date: 2005/05/06 18:15:25 $ |
| | 14 | * @version $Revision: 1.2 $ $Name: $ |
| | 15 | * @date $Date: 2005/05/16 21:57:14 $ |
| 16 | 16 | * |
| 17 | 17 | * Copyright 2005 Joshua Hoblitt, University of Hawaii |
| 18 | 18 | */ |
| … |
… |
|
| 42 | 42 | mysqlType; |
| 43 | 43 | |
| 44 | 44 | // database utility functions |
| 45 | | static bool psDBRunQuery(psDB *dbh, const char *query); |
| 46 | 45 | static inline bool psDBPackRow(MYSQL_BIND *bind, psMetadata *values, psU32 paramCount); |
| 47 | 46 | |
| 48 | 47 | // SQL generation functions |
| … |
… |
|
| 135 | 134 | psStringAppend(&query, "CREATE DATABASE %s", dbname); |
| 136 | 135 | |
| 137 | 136 | // the MySQL C API notes that mysql_create_db() is deprecated |
| 138 | | status = psDBRunQuery(dbh, query); |
| | 137 | status = p_psDBRunQuery(dbh, query); |
| 139 | 138 | if (!status) { |
| 140 | 139 | psError(PS_ERR_UNKNOWN, false, "Failed to create new database."); |
| 141 | 140 | } |
| … |
… |
|
| 164 | 163 | psStringAppend(&query, "DROP DATABASE %s", dbname); |
| 165 | 164 | |
| 166 | 165 | // the MySQL C API notes that mysql_drop_db() is deprecated |
| 167 | | status = psDBRunQuery(dbh, query); |
| | 166 | status = p_psDBRunQuery(dbh, query); |
| 168 | 167 | if (!status) { |
| 169 | 168 | psError(PS_ERR_UNKNOWN, false, "Failed to drop database."); |
| 170 | 169 | } |
| … |
… |
|
| 186 | 185 | return NULL; |
| 187 | 186 | } |
| 188 | 187 | |
| 189 | | status = psDBRunQuery(dbh, query); |
| | 188 | status = p_psDBRunQuery(dbh, query); |
| 190 | 189 | if (!status) { |
| 191 | 190 | psError(PS_ERR_UNKNOWN, false, "Failed to create table."); |
| 192 | 191 | } |
| … |
… |
|
| 203 | 202 | |
| 204 | 203 | psStringAppend(&query, "DROP TABLE %s", tableName); |
| 205 | 204 | |
| 206 | | status = psDBRunQuery(dbh, query); |
| | 205 | status = p_psDBRunQuery(dbh, query); |
| 207 | 206 | if (!status) { |
| 208 | 207 | psError(PS_ERR_UNKNOWN, false, "Failed to drop table."); |
| 209 | 208 | } |
| … |
… |
|
| 230 | 229 | return NULL; |
| 231 | 230 | } |
| 232 | 231 | |
| 233 | | if (!psDBRunQuery(dbh, query)) { |
| | 232 | if (!p_psDBRunQuery(dbh, query)) { |
| 234 | 233 | psError(PS_ERR_UNKNOWN, false, "Query execution failed."); |
| 235 | 234 | psFree(query); |
| 236 | 235 | return NULL; |
| … |
… |
|
| 387 | 386 | return NULL; |
| 388 | 387 | } |
| 389 | 388 | |
| 390 | | if (!psDBRunQuery(dbh, query)) { |
| | 389 | if (!p_psDBRunQuery(dbh, query)) { |
| 391 | 390 | psError(PS_ERR_UNKNOWN, false, "Query execution failed."); |
| 392 | 391 | |
| 393 | 392 | psFree(query); |
| … |
… |
|
| 723 | 722 | return -1; |
| 724 | 723 | } |
| 725 | 724 | |
| 726 | | if (!psDBRunQuery(dbh, query)) { |
| | 725 | if (!p_psDBRunQuery(dbh, query)) { |
| 727 | 726 | psError(PS_ERR_UNKNOWN, false, "Delete failed."); |
| 728 | 727 | |
| 729 | 728 | mysql_rollback(dbh->mysql); |
| … |
… |
|
| 749 | 748 | // database utility functions |
| 750 | 749 | /*****************************************************************************/ |
| 751 | 750 | |
| 752 | | static bool psDBRunQuery(psDB *dbh, const char *query) |
| | 751 | bool p_psDBRunQuery(psDB *dbh, const char *query) |
| 753 | 752 | { |
| 754 | 753 | if (mysql_real_query(dbh->mysql, query, (unsigned long)strlen(query)) !=0) { |
| 755 | 754 | psError(PS_ERR_UNKNOWN, true, "Failed to execute query. Error: %s\n", mysql_error(dbh->mysql)); |
diff -u pslib/src/dataIO/psDB.h:1.1 pslib/src/dataIO/psDB.h:1.2
|
old
|
new
|
|
| 9 | 9 | * |
| 10 | 10 | * @author Joshua Hoblitt |
| 11 | 11 | * |
| 12 | | * @version $Revision: 1.1 $ $Name: $ |
| 13 | | * @date $Date: 2005/03/31 23:01:46 $ |
| | 12 | * @version $Revision: 1.2 $ $Name: $ |
| | 13 | * @date $Date: 2005/05/16 21:57:14 $ |
| 14 | 14 | * |
| 15 | 15 | * Copyright 2005 Joshua Hoblitt, University of Hawaii |
| 16 | 16 | */ |
| … |
… |
|
| 82 | 82 | const char *dbname ///< Database namespace |
| 83 | 83 | ); |
| 84 | 84 | |
| | 85 | /** Executes a SQL query |
| | 86 | * |
| | 87 | * This function will execute a string as a raw SQL query. No additional |
| | 88 | * processing of the string or abstraction of the underlying database's SQL |
| | 89 | * dialect is provided. Caveat emptor. |
| | 90 | * |
| | 91 | * @return true on success |
| | 92 | */ |
| | 93 | bool p_psDBRunQuery( |
| | 94 | psDB *dbh, ///< Database handle |
| | 95 | const char *query ///< SQL string to execute |
| | 96 | ); |
| | 97 | |
| 85 | 98 | /** Creates a new database table |
| 86 | 99 | * |
| 87 | 100 | * This function generates and executes the SQL needed to create a table named |