IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 27, 2005, 3:01:32 PM (21 years ago)
Author:
asc
Message:

fixes for bug #419

File:
1 edited

Legend:

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

    r3961 r4043  
    1212 *  @author Joshua Hoblitt
    1313 *
    14  *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2005-05-18 23:19:46 $
     14 *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2005-05-28 01:01:32 $
    1616 *
    1717 *  Copyright 2005 Joshua Hoblitt, University of Hawaii
     
    356356    case PS_TYPE_BOOL:
    357357        // valid for psVector?
     358        PS_STR_ARRAY_TO_PTYPE(column->data.U8, stringColumn, atoi, psU8, PS_TYPE_U8);
    358359        break;
    359360    }
     
    450451            } else if (pType == PS_META_F64) {
    451452                psMetadataAddF64(md, 0, field[i].name, "", atof(data));
     453            } else if (pType == PS_META_BOOL) {
     454                psMetadataAdd(md, 0, field[i].name, pType, "", atoi(data));
    452455            } else {
    453456                // XXX: assume binary string ...
     
    803806                              ? (my_bool *)&isNull
    804807                              : NULL;
     808        } else if (item->type == PS_TYPE_BOOL) {
     809            bind[i].length  = 0;
     810            bind[i].buffer  = &item->data.B;
     811            bind[i].is_null = psDBIsPTypeNaN(item->type, &item->data.B)
     812                              ? (my_bool *)&isNull
     813                              : NULL;
     814        } else if (item->type == PS_META_STR) {
    805815            // convert NaNs to NULL and set the buffer_length for strings
    806             //} else if ((item->type == PS_META_STR) && (item->pType == PS_TYPE_PTR)) {
    807         } else if (item->type == PS_META_STR) {
    808816
    809817            bind[i].buffer_length = (unsigned long)strlen((char *)item->data.V);
     
    817825                    "FIXME: Only type of PS_TYPE_S32 (PS_META_S32), "
    818826                    "PS_TYPE_F32 (PS_META_F32), PS_TYPE_F64 (PS_META_F64), "
     827                    "PS_TYPE_BOOL (PS_META_BOOL), "
    819828                    "and PS_META_STR are supported.");
    820829
     
    856865    // find column name and type
    857866    while ((item = psListGetAndIncrement(cursor))) {
    858         if ((item->type == PS_META_S32) || (item->type == PS_META_F32) || (item->type == PS_META_F64) ||
    859                 (item->type == PS_TYPE_S32) || (item->type == PS_TYPE_F32) || (item->type == PS_TYPE_F64)) {
     867        if ((item->type == PS_META_S32)  || (item->type == PS_META_F32) || (item->type == PS_META_F64) ||
     868                (item->type == PS_TYPE_S32)  || (item->type == PS_TYPE_F32) || (item->type == PS_TYPE_F64) ||
     869                (item->type == PS_TYPE_BOOL) || (item->type == PS_META_BOOL)) {
    860870            // + column name + _ + column type
    861871            colType = psDBPTypeToSQL(item->type);
     
    867877        } else {
    868878            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    869                     "FIXME: Only type of PS_META_S32, PS_META_F32, PS_META_F64, "
     879                    "FIXME: Only type of PS_META_S32, PS_META_F32, PS_META_F64, PS_META_BOOL, "
    870880                    "and PS_META_STR are supported, (not %d).", item->type);
    871881
     
    10721082        } else if ((item->type == PS_META_F64) || (item->type == PS_TYPE_F64)) {
    10731083            psStringAppend(&query, "%s=%g", item->name, (double)(item->data.F64));
     1084        } else if ((item->type == PS_META_BOOL) || (item->type == PS_TYPE_BOOL)) {
     1085            psStringAppend(&query, "%s=%d", item->name, (int)(item->data.B));
    10741086        } else if (item->type == PS_META_STR) {
    10751087            // + column name + _ + like + _ + ' + value + '
     
    10851097        } else {
    10861098            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    1087                     "Only types PS_META_S32, PS_META_F32, PS_META_F64, PS_META_STR is supported");
     1099                    "Only types PS_META_S32, PS_META_F32, PS_META_F64, PS_META_BOOL, PS_META_STR are supported");
    10881100
    10891101            psFree(cursor);
     
    12591271        psDBAddToLookupTable(lookupTable, PS_TYPE_C32, "PS_TYPE_C32 is not supported");
    12601272        psDBAddToLookupTable(lookupTable, PS_TYPE_C64, "PS_TYPE_C64 is not supported");
    1261         psDBAddToLookupTable(lookupTable, PS_TYPE_BOOL,"BOOLEAN");
     1273        psDBAddToLookupTable(lookupTable, PS_TYPE_BOOL,"TINYINT");
    12621274        psDBAddToLookupTable(lookupTable, PS_META_STR, "VARCHAR");
    12631275    }
     
    15221534        break;
    15231535    case PS_TYPE_BOOL:
    1524         // what is NaN for a bool?
     1536        // XXX: what is NaN for a bool?
     1537        PS_NAN_ALLOC(myNaN, psU8, PS_MAX_U8);
    15251538        break;
    15261539    }
     
    15751588        break;
    15761589    case PS_TYPE_BOOL:
    1577         // what is NaN for a bool?
     1590        // XXX: what is NaN for a bool?
     1591        isNaN = PS_IS_NAN(psU8, data, PS_MAX_U8);
    15781592        break;
    15791593    }
Note: See TracChangeset for help on using the changeset viewer.