IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 9, 2007, 3:24:40 PM (19 years ago)
Author:
jhoblitt
Message:

change psDBSelectColumn() to return NULL instead of "" for NULL database fields

File:
1 edited

Legend:

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

    r12223 r12394  
    1212 *  @author Joshua Hoblitt
    1313 *
    14  *  @version $Revision: 1.138 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2007-03-05 21:17:34 $
     14 *  @version $Revision: 1.139 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2007-03-10 01:24:40 $
    1616 *
    1717 *  Copyright (C) 2005-2006  Joshua Hoblitt, University of Hawaii
     
    416416        dataSize = *(mysql_fetch_lengths(result));
    417417
    418         // represent NULL as an empty string
     418        // represent NULL as a NULL string
    419419        if (row[0] == NULL) {
    420             data = psStringCopy("");
    421         } else {
    422             data = psAlloc(dataSize+1);
    423             memcpy(data, row[0], dataSize);
    424             ((char*)data)[dataSize] = '\0';
    425         }
     420            psArrayAdd(column, 0, NULL);
     421            continue;
     422        }
     423
     424        // make a copy of the data
     425        data = psAlloc(dataSize+1);
     426        memcpy(data, row[0], dataSize);
     427        ((char*)data)[dataSize] = '\0';
    426428
    427429        // add field to return array
     
    441443{ \
    442444    psPtr           myNaN; \
    443     int             i; \
    444445    \
    445     for (i = 0; i < source->n; i++) { \
    446         if (strlen(source->data[i])) { \
     446    for (long i = 0; i < source->n; i++) { \
     447        if (source->data[i]) { \
    447448            dest[i] = (type)conv(source->data[i]); \
    448449        } else { \
Note: See TracChangeset for help on using the changeset viewer.