Changeset 3249
- Timestamp:
- Feb 16, 2005, 5:20:56 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/archive/psdb/psDB.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/archive/psdb/psDB.c
r3245 r3249 8 8 * @author Joshua Hoblitt 9 9 * 10 * @version $Revision: 1.3 2$ $Name: not supported by cvs2svn $11 * @date $Date: 2005-02-17 0 0:36:11$10 * @version $Revision: 1.33 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2005-02-17 03:20:56 $ 12 12 * 13 13 * Copyright 2005 Joshua Hoblitt, University of Hawaii … … 772 772 mType = psDBPTypeToMySQL(item->pType); 773 773 774 // input data length is determined by the MYSQL_TYPE_* unless it's a string775 bind[i].buffer = (char *)item->data.V;776 774 bind[i].buffer_type = mType->type; 777 775 bind[i].is_unsigned = mType->isUnsigned; … … 779 777 psFree(mType); 780 778 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 } 781 808 // 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' 802 814 ? (my_bool *)&isNull 803 815 : 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; 804 823 } 805 824 … … 830 849 } 831 850 832 // + _ + tableName + _ + (833 851 psStringAppend(&query, "CREATE TABLE %s (", tableName); 834 852
Note:
See TracChangeset
for help on using the changeset viewer.
