IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 3249


Ignore:
Timestamp:
Feb 16, 2005, 5:20:56 PM (21 years ago)
Author:
jhoblitt
Message:

fix PS_META_PRIMITIVE handling in psDBPackRow()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/archive/psdb/psDB.c

    r3245 r3249  
    88 *  @author Joshua Hoblitt
    99 *
    10  *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2005-02-17 00:36:11 $
     10 *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2005-02-17 03:20:56 $
    1212 *
    1313 *  Copyright 2005 Joshua Hoblitt, University of Hawaii
     
    772772        mType = psDBPTypeToMySQL(item->pType);
    773773
    774         // input data length is determined by the MYSQL_TYPE_* unless it's a string
    775         bind[i].buffer  = (char *)item->data.V;
    776774        bind[i].buffer_type = mType->type;
    777775        bind[i].is_unsigned = mType->isUnsigned;
     
    779777        psFree(mType);
    780778
     779        // input data length is determined by the MYSQL_TYPE_* unless it's a string
     780        if (item->type == PS_META_PRIMITIVE) {
     781            switch (item->pType) {
     782                case PS_TYPE_S32:
     783                    bind[i].length  = 0;
     784                    bind[i].buffer  = &item->data.S32;
     785                    bind[i].is_null = psDBIsPTypeNaN(item->pType, &item->data.S32)
     786                                    ? (my_bool *)&isNull
     787                                    : NULL;
     788                    break;
     789                case PS_TYPE_F32:
     790                    bind[i].length  = 0;
     791                    bind[i].buffer  = &item->data.F32;
     792                    bind[i].is_null = psDBIsPTypeNaN(item->pType, &item->data.F32)
     793                                    ? (my_bool *)&isNull
     794                                    : NULL;
     795                    break;
     796                case PS_TYPE_F64:
     797                    bind[i].length  = 0;
     798                    bind[i].buffer  = &item->data.F64;
     799                    bind[i].is_null = psDBIsPTypeNaN(item->pType, &item->data.F64)
     800                                    ? (my_bool *)&isNull
     801                                    : NULL;
     802                    break;
     803                default:
     804                    psError(PS_ERR_BAD_PARAMETER_TYPE , true,
     805            "FIXME: Only PS_META_PRIMITIVE values of PS_TYPE_S32, PS_TYPE_F32, and PS_TYPE_F64 supported.");
     806                    break;
     807            }
    781808        // convert NaNs to NULL and set the buffer_length for strings
    782         if (item->pType == PS_TYPE_PTR) {
    783             if (item->type == PS_META_STR) {
    784                 if (*(char *)item->data.V == '\0') {
    785                     bind[i].is_null = (my_bool *)&isNull;
    786                 } else {
    787                     bind[i].buffer_length = (unsigned long)strlen((char *)item->data.V);
    788                     bind[i].is_null = NULL;
    789                 }
    790             } else {
    791                 // error, not a pointer to a string
    792                 psError(PS_ERR_BAD_PARAMETER_TYPE , true,
    793                     "Only types of PS_META_PRIMITIVE and PS_META_STR are supported.");
    794 
    795                 psFree(cursor);
    796 
    797                 return false;
    798             }
    799         } else {
    800             // for all primitive types
    801             bind[i].is_null = psDBIsPTypeNaN(item->pType, item->data.V)
     809        } else if ((item->type == PS_META_STR) && (item->pType == PS_TYPE_PTR)) {
     810            bind[i].buffer_length = (unsigned long)strlen((char *)item->data.V);
     811            bind[i].length  = &bind[i].buffer_length;
     812            bind[i].buffer  = item->data.V;
     813            bind[i].is_null = *(char *)item->data.V == '\0'
    802814                            ? (my_bool *)&isNull
    803815                            : NULL;
     816        } else {
     817            psError(PS_ERR_BAD_PARAMETER_TYPE , true,
     818                "Only types of PS_META_PRIMITIVE and PS_META_STR are supported.");
     819
     820            psFree(cursor);
     821
     822            return false;
    804823        }
    805824
     
    830849    }
    831850
    832     // + _ + tableName + _ + (
    833851    psStringAppend(&query, "CREATE TABLE %s (", tableName);
    834852
Note: See TracChangeset for help on using the changeset viewer.