IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 6, 2006, 5:30:45 PM (20 years ago)
Author:
Paul Price
Message:

Patch from Josh to correctly handle the insertion of NULL strings.

File:
1 edited

Legend:

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

    r7305 r7383  
    1212 *  @author Joshua Hoblitt
    1313 *
    14  *  @version $Revision: 1.54 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2006-06-02 23:22:17 $
     14 *  @version $Revision: 1.55 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2006-06-07 03:30:45 $
    1616 *
    1717 *  Copyright 2005 Joshua Hoblitt, University of Hawaii
     
    10601060            // convert NaNs to NULL and set the buffer_length for strings
    10611061
    1062             bind[i].buffer_length = (unsigned long)strlen((char *)item->data.V);
    1063             bind[i].length  = &bind[i].buffer_length;
    1064             bind[i].buffer  = item->data.V;
    1065             bind[i].is_null = *(char *)item->data.V == '\0'
    1066                               ? (my_bool *)&isNull
    1067                               : NULL;
     1062            if ((char *)item->data.V) {
     1063                // will handle the case of "" as a NULL database value
     1064                bind[i].buffer_length = (unsigned long)strlen((char *)item->data.V);
     1065                bind[i].length  = &bind[i].buffer_length;
     1066                bind[i].buffer  = item->data.V;
     1067                bind[i].is_null = *(char *)item->data.V == '\0'
     1068                                  ? (my_bool *)&isNull
     1069                                  : NULL;
     1070            } else {
     1071                // handles the case of NULL as a NULL database value
     1072                bind[i].buffer_length = 0;
     1073                bind[i].length  = &bind[i].buffer_length;
     1074                bind[i].buffer  = NULL;
     1075                bind[i].is_null = (my_bool *)&isNull;
     1076            }
    10681077        } else {
    10691078            psError(PS_ERR_BAD_PARAMETER_TYPE , true,
Note: See TracChangeset for help on using the changeset viewer.