IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 4589 for trunk/psLib/src/db


Ignore:
Timestamp:
Jul 20, 2005, 3:40:10 PM (21 years ago)
Author:
drobbin
Message:

made minor changes in accordance with newest api-delta doc

Location:
trunk/psLib/src/db
Files:
2 edited

Legend:

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

    r4556 r4589  
    1212 *  @author Joshua Hoblitt
    1313 *
    14  *  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2005-07-15 02:33:52 $
     14 *  @version $Revision: 1.40 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2005-07-21 01:40:10 $
    1616 *
    1717 *  Copyright 2005 Joshua Hoblitt, University of Hawaii
     
    4949// SQL generation functions
    5050static char    *psDBGenerateCreateTableSQL(const char *tableName, const psMetadata *where);
    51 static char    *psDBGenerateSelectRowSQL(const char *tableName, const char *col, const psMetadata *where, psU64 limit);
     51static char    *psDBGenerateSelectRowSQL(const char *tableName, const char *col,
     52        const psMetadata *where, psU64 limit);
    5253static char    *psDBGenerateInsertRowSQL(const char *tableName, const psMetadata *row);
    53 static char    *psDBGenerateUpdateRowSQL(const char *tableName, const psMetadata *where, const psMetadata *values);
    54 static char    *psDBGenerateDeleteRowSQL(const char *tableName, const psMetadata *where, unsigned long long limit);
     54static char    *psDBGenerateUpdateRowSQL(const char *tableName, const psMetadata *where,
     55        const psMetadata *values);
     56static char    *psDBGenerateDeleteRowSQL(const char *tableName, const psMetadata *where,
     57        unsigned long long limit);
    5558static char    *psDBGenerateWhereSQL(const psMetadata *where);
    5659static char    *psDBGenerateSetSQL(const psMetadata *set
     
    8992/*****************************************************************************/
    9093
    91 psDB *psDBInit(const char *host, const char *user, const char *passwd, const char *dbname)
     94psDB *psDBInit(const char *host,
     95               const char *user,
     96               const char *passwd,
     97               const char *dbname)
    9298{
    9399    MYSQL           *mysql;
     
    139145}
    140146
    141 bool psDBCreate(psDB *dbh, const char *dbname)
     147bool psDBCreate(psDB *dbh,
     148                const char *dbname)
    142149{
    143150    char            *query = NULL;
     
    157164}
    158165
    159 bool psDBChange(psDB *dbh, const char *dbname)
     166bool psDBChange(psDB *dbh,
     167                const char *dbname)
    160168{
    161169    // Verify database object is valid
     
    177185}
    178186
    179 bool psDBDrop(psDB *dbh, const char *dbname)
     187bool psDBDrop(psDB *dbh,
     188              const char *dbname)
    180189{
    181190    char            *query = NULL;
     
    195204}
    196205
    197 bool psDBCreateTable(psDB *dbh, const char *tableName, const psMetadata *md)
     206bool psDBCreateTable(psDB *dbh,
     207                     const char *tableName,
     208                     const psMetadata *md)
    198209{
    199210    char            *query;
     
    225236}
    226237
    227 bool psDBDropTable(psDB *dbh, const char *tableName)
     238bool psDBDropTable(psDB *dbh,
     239                   const char *tableName)
    228240{
    229241    char            *query = NULL;
     
    244256}
    245257
    246 psArray *psDBSelectColumn(psDB *dbh, const char *tableName, const char *col, unsigned long long limit)
     258psArray *psDBSelectColumn(psDB *dbh,
     259                          const char *tableName,
     260                          const char *col,
     261                          unsigned long long limit)
    247262{
    248263    MYSQL_RES       *result;            // complete db result set
     
    339354}
    340355
    341 psVector *psDBSelectColumnNum(psDB *dbh, const char *tableName, const char *col, psElemType type, unsigned long long limit)
     356psVector *psDBSelectColumnNum(psDB *dbh,
     357                              const char *tableName,
     358                              const char *col,
     359                              psElemType type,
     360                              unsigned long long limit)
    342361{
    343362    psArray         *stringColumn;      // source psArray
     
    403422}
    404423
    405 psArray *psDBSelectRows(psDB *dbh, const char *tableName, const psMetadata *where, unsigned long long limit)
     424psArray *psDBSelectRows(psDB *dbh,
     425                        const char *tableName,
     426                        const psMetadata *where,
     427                        unsigned long long limit)
    406428{
    407429    MYSQL_RES       *result;            // complete db result set
     
    507529}
    508530
    509 bool psDBInsertOneRow(psDB *dbh, const char *tableName, const psMetadata *row)
     531bool psDBInsertOneRow(psDB *dbh,
     532                      const char *tableName,
     533                      const psMetadata *row)
    510534{
    511535    psArray         *rowSet;           // psArray of row to insert
     
    534558}
    535559
    536 bool psDBInsertRows(psDB *dbh, const char *tableName, const psArray *rowSet)
     560bool psDBInsertRows(psDB *dbh,
     561                    const char *tableName,
     562                    const psArray *rowSet)
    537563{
    538564    psMetadata      *row;               // row of data
     
    635661}
    636662
    637 psArray *psDBDumpRows(psDB *dbh, const char *tableName)
     663psArray *psDBDumpRows(psDB *dbh,
     664                      const char *tableName)
    638665{
    639666    return psDBSelectRows(dbh, tableName, NULL, 0);
    640667}
    641668
    642 psMetadata *psDBDumpCols(psDB *dbh, const char *tableName)
     669psMetadata *psDBDumpCols(psDB *dbh,
     670                         const char *tableName)
    643671{
    644672    MYSQL_RES       *result;
     
    698726}
    699727
    700 psS64 psDBUpdateRows(psDB *dbh, const char *tableName, const psMetadata *where, const psMetadata *values)
     728long psDBUpdateRows(psDB *dbh,
     729                    const char *tableName,
     730                    const psMetadata *where,
     731                    const psMetadata *values)
    701732{
    702733    char            *query;
     
    779810}
    780811
    781 psS64 psDBDeleteRows(psDB *dbh, const char *tableName, const psMetadata *where, unsigned long long limit)
     812long psDBDeleteRows(psDB *dbh,
     813                    const char *tableName,
     814                    const psMetadata *where,
     815                    unsigned long long limit)
    782816{
    783817    char            *query;
     
    818852/*****************************************************************************/
    819853
    820 bool p_psDBRunQuery(psDB *dbh, const char *format)
     854bool p_psDBRunQuery(psDB *dbh,
     855                    const char *format)
    821856{
    822857    // Verify database object is not NULL
     
    835870}
    836871
    837 static inline bool psDBPackRow(MYSQL_BIND *bind, const psMetadata *values, psU32 paramCount)
     872static inline bool psDBPackRow(MYSQL_BIND *bind,
     873                               const psMetadata *values,
     874                               psU32 paramCount)
    838875{
    839876    psListIterator  *cursor;            // row iterator
     
    928965/*****************************************************************************/
    929966
    930 static char *psDBGenerateCreateTableSQL(const char *tableName, const psMetadata *table)
     967static char *psDBGenerateCreateTableSQL(const char *tableName,
     968                                        const psMetadata *table)
    931969{
    932970    char            *query = NULL;      // complete query
     
    10041042}
    10051043
    1006 static char *psDBGenerateSelectRowSQL(const char *tableName, const char *col, const psMetadata *where, psU64 limit)
     1044static char *psDBGenerateSelectRowSQL(const char *tableName,
     1045                                      const char *col,
     1046                                      const psMetadata *where,
     1047                                      psU64 limit)
    10071048{
    10081049    char            *query = NULL;
     
    10411082}
    10421083
    1043 static char *psDBGenerateInsertRowSQL(const char *tableName, const psMetadata *row)
     1084static char *psDBGenerateInsertRowSQL(const char *tableName,
     1085                                      const psMetadata *row)
    10441086{
    10451087    char            *query = NULL;
     
    10971139}
    10981140
    1099 static char *psDBGenerateUpdateRowSQL(const char *tableName, const psMetadata *where, const psMetadata *values)
     1141static char *psDBGenerateUpdateRowSQL(const char *tableName,
     1142                                      const psMetadata *where,
     1143                                      const psMetadata *values)
    11001144{
    11011145    char            *query = NULL;
     
    11311175}
    11321176
    1133 static char *psDBGenerateDeleteRowSQL(const char *tableName, const psMetadata *where, unsigned long long limit)
     1177static char *psDBGenerateDeleteRowSQL(const char *tableName,
     1178                                      const psMetadata *where,
     1179                                      unsigned long long limit)
    11341180{
    11351181    char            *query = NULL;
     
    12611307/*****************************************************************************/
    12621308
    1263 static psElemType psDBMySQLToPType(enum enum_field_types type, unsigned int flags)
     1309static psElemType psDBMySQLToPType(enum enum_field_types type,
     1310                                   unsigned int flags)
    12641311{
    12651312    psHash          *mysqlToSQLTable;   // type lookup table
     
    15501597}
    15511598
    1552 static psPtr psDBMySQLTypeAlloc(enum enum_field_types type, bool isUnsigned)
     1599static psPtr psDBMySQLTypeAlloc(enum enum_field_types type,
     1600                                bool isUnsigned)
    15531601{
    15541602    mysqlType       *mType;
     
    15611609}
    15621610
    1563 static void psDBAddToLookupTable(psHash *lookupTable, psU32 type, const char *string)
     1611static void psDBAddToLookupTable(psHash *lookupTable,
     1612                                 psU32 type,
     1613                                 const char *string)
    15641614{
    15651615    char            *key;
     
    15751625}
    15761626
    1577 static void psDBAddVoidToLookupTable(psHash *lookupTable, psU32 type, psPtr value)
     1627static void psDBAddVoidToLookupTable(psHash *lookupTable,
     1628                                     psU32 type,
     1629                                     psPtr value)
    15781630{
    15791631    char            *key;
     
    16501702#define PS_IS_NAN(type, data, nan) *(type *)data == nan
    16511703
    1652 static bool psDBIsPTypeNaN(psElemType pType, psPtr data)
     1704static bool psDBIsPTypeNaN(psElemType pType,
     1705                           psPtr data)
    16531706{
    16541707    bool    isNaN;
  • trunk/psLib/src/db/psDB.h

    r4540 r4589  
    1010 *  @author Joshua Hoblitt
    1111 *
    12  *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2005-07-12 19:12:00 $
     12 *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2005-07-21 01:40:10 $
    1414 *
    1515 *  Copyright 2005 Joshua Hoblitt, University of Hawaii
     
    4040/** Opens a new database connection
    4141 *
    42  *  @return A new psDB object if the database connection is successful or NULL on
     42 *  @return psDB*:      A new psDB object if the database connection is successful or NULL on
    4343 *  failure.
    4444 */
     
    5050);
    5151
    52 /** Closes a database connection
    53  */
     52/** Closes a database connection  */
    5453void psDBCleanup(
    5554    psDB *dbh                          ///< Database handle
     
    5857/** Creates a new database namespace
    5958 *
    60  * @return true on success
     59 * @return bool:    true on success
    6160 */
    6261bool psDBCreate(
     
    6766/** Changes the current database namespace
    6867 *
    69  * @return true on success
     68 * @return bool:    true on success
    7069 */
    7170bool psDBChange(
     
    7675/** Drops a database namespace
    7776 *
    78  * @return true on success
     77 * @return bool:    true on success
    7978 */
    8079bool psDBDrop(
     
    8988 * dialect is provided.  Caveat emptor.
    9089 *
    91  * @return true on success
     90 * @return bool:    true on success
    9291 */
    9392bool p_psDBRunQuery(
     
    114113 * Key" or "Key".  Comments are otherwise ignored.
    115114 *
    116  * @return true on success
     115 * @return bool:    true on success
    117116 */
    118117bool psDBCreateTable(
     
    124123/** Deletes a database table
    125124 *
    126  * @return true on success
     125 * @return bool:    true on success
    127126*/
    128127bool psDBDropTable(
     
    137136 * entire range is returned.
    138137 *
    139  * @return A psArray of strings or NULL on failure
     138 * @return psArray*:    A psArray of strings or NULL on failure
    140139 */
    141140psArray *psDBSelectColumn(
     
    152151 * entire range is returned.  The data in the column is cast to to "pType".
    153152 *
    154  * @return A psVector or NULL on failure
     153 * @return psVector*:   A psVector or NULL on failure
    155154 */
    156155psVector *psDBSelectColumnNum(
     
    174173 * string, e.g. "", to match NULL field values.
    175174 *
    176  * @return A psArray of psMetadata or NULL on failure
     175 * @return psArray*:    A psArray of psMetadata or NULL on failure
    177176 */
    178177psArray *psDBSelectRows(
     
    192191 * specified in "row" that do not exist in "tableName", the insert will fail.
    193192 *
    194  * @return true on success
     193 * @return bool:    true on success
    195194 */
    196195bool psDBInsertOneRow(
     
    207206 * those used in psDBInsertOneRow().
    208207 *
    209  * @return true on success
     208 * @return bool:    true on success
    210209 */
    211210bool psDBInsertRows(
     
    220219 * the same psMetadata format as used in psDBInsertOneRow() & psDBInsertRows().
    221220 *
    222  * @return A psArray of psMetadata or NULL on failure
     221 * @return psArray*:    A psArray of psMetadata or NULL on failure
    223222 */
    224223psArray *psDBDumpRows(
     
    233232 * psMetadata structure where psMetadataItem.name contains the column's name.
    234233 *
    235  * @return A psMetadata containing either a psArrays or psVector per column
     234 * @return psMetadata*:     A psMetadata containing either a psArrays or psVector per column
    236235 */
    237236psMetadata *psDBDumpCols(
     
    249248 * used in psDBInsertOneRow(), etc.
    250249 *
    251  * @return The number of rows modified or a negative value on error
    252  */
    253 psS64 psDBUpdateRows(
     250 * @return long:    The number of rows modified or a negative value on error
     251 */
     252long psDBUpdateRows(
    254253    psDB *dbh,                         ///< Database handle
    255254    const char *tableName,             ///< Table name
     
    266265 * the number of rows that were dropped, only 1 will be returned on success.
    267266 *
    268  * @return The number of rows removed or a negative value on error
    269  */
    270 psS64 psDBDeleteRows(
     267 * @return long:    The number of rows removed or a negative value on error
     268 */
     269long psDBDeleteRows(
    271270    psDB *dbh,                         ///< Database handle
    272271    const char *tableName,             ///< Table name
Note: See TracChangeset for help on using the changeset viewer.