Changeset 4043
- Timestamp:
- May 27, 2005, 3:01:32 PM (21 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 2 edited
-
dataIO/psDB.c (modified) (12 diffs)
-
db/psDB.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/dataIO/psDB.c
r3961 r4043 12 12 * @author Joshua Hoblitt 13 13 * 14 * @version $Revision: 1.1 8$ $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 $ 16 16 * 17 17 * Copyright 2005 Joshua Hoblitt, University of Hawaii … … 356 356 case PS_TYPE_BOOL: 357 357 // valid for psVector? 358 PS_STR_ARRAY_TO_PTYPE(column->data.U8, stringColumn, atoi, psU8, PS_TYPE_U8); 358 359 break; 359 360 } … … 450 451 } else if (pType == PS_META_F64) { 451 452 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)); 452 455 } else { 453 456 // XXX: assume binary string ... … … 803 806 ? (my_bool *)&isNull 804 807 : 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) { 805 815 // 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) {808 816 809 817 bind[i].buffer_length = (unsigned long)strlen((char *)item->data.V); … … 817 825 "FIXME: Only type of PS_TYPE_S32 (PS_META_S32), " 818 826 "PS_TYPE_F32 (PS_META_F32), PS_TYPE_F64 (PS_META_F64), " 827 "PS_TYPE_BOOL (PS_META_BOOL), " 819 828 "and PS_META_STR are supported."); 820 829 … … 856 865 // find column name and type 857 866 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)) { 860 870 // + column name + _ + column type 861 871 colType = psDBPTypeToSQL(item->type); … … 867 877 } else { 868 878 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, " 870 880 "and PS_META_STR are supported, (not %d).", item->type); 871 881 … … 1072 1082 } else if ((item->type == PS_META_F64) || (item->type == PS_TYPE_F64)) { 1073 1083 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)); 1074 1086 } else if (item->type == PS_META_STR) { 1075 1087 // + column name + _ + like + _ + ' + value + ' … … 1085 1097 } else { 1086 1098 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1087 "Only types PS_META_S32, PS_META_F32, PS_META_F64, PS_META_ STR issupported");1099 "Only types PS_META_S32, PS_META_F32, PS_META_F64, PS_META_BOOL, PS_META_STR are supported"); 1088 1100 1089 1101 psFree(cursor); … … 1259 1271 psDBAddToLookupTable(lookupTable, PS_TYPE_C32, "PS_TYPE_C32 is not supported"); 1260 1272 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"); 1262 1274 psDBAddToLookupTable(lookupTable, PS_META_STR, "VARCHAR"); 1263 1275 } … … 1522 1534 break; 1523 1535 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); 1525 1538 break; 1526 1539 } … … 1575 1588 break; 1576 1589 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); 1578 1592 break; 1579 1593 } -
trunk/psLib/src/db/psDB.c
r3961 r4043 12 12 * @author Joshua Hoblitt 13 13 * 14 * @version $Revision: 1.1 8$ $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 $ 16 16 * 17 17 * Copyright 2005 Joshua Hoblitt, University of Hawaii … … 356 356 case PS_TYPE_BOOL: 357 357 // valid for psVector? 358 PS_STR_ARRAY_TO_PTYPE(column->data.U8, stringColumn, atoi, psU8, PS_TYPE_U8); 358 359 break; 359 360 } … … 450 451 } else if (pType == PS_META_F64) { 451 452 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)); 452 455 } else { 453 456 // XXX: assume binary string ... … … 803 806 ? (my_bool *)&isNull 804 807 : 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) { 805 815 // 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) {808 816 809 817 bind[i].buffer_length = (unsigned long)strlen((char *)item->data.V); … … 817 825 "FIXME: Only type of PS_TYPE_S32 (PS_META_S32), " 818 826 "PS_TYPE_F32 (PS_META_F32), PS_TYPE_F64 (PS_META_F64), " 827 "PS_TYPE_BOOL (PS_META_BOOL), " 819 828 "and PS_META_STR are supported."); 820 829 … … 856 865 // find column name and type 857 866 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)) { 860 870 // + column name + _ + column type 861 871 colType = psDBPTypeToSQL(item->type); … … 867 877 } else { 868 878 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, " 870 880 "and PS_META_STR are supported, (not %d).", item->type); 871 881 … … 1072 1082 } else if ((item->type == PS_META_F64) || (item->type == PS_TYPE_F64)) { 1073 1083 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)); 1074 1086 } else if (item->type == PS_META_STR) { 1075 1087 // + column name + _ + like + _ + ' + value + ' … … 1085 1097 } else { 1086 1098 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1087 "Only types PS_META_S32, PS_META_F32, PS_META_F64, PS_META_ STR issupported");1099 "Only types PS_META_S32, PS_META_F32, PS_META_F64, PS_META_BOOL, PS_META_STR are supported"); 1088 1100 1089 1101 psFree(cursor); … … 1259 1271 psDBAddToLookupTable(lookupTable, PS_TYPE_C32, "PS_TYPE_C32 is not supported"); 1260 1272 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"); 1262 1274 psDBAddToLookupTable(lookupTable, PS_META_STR, "VARCHAR"); 1263 1275 } … … 1522 1534 break; 1523 1535 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); 1525 1538 break; 1526 1539 } … … 1575 1588 break; 1576 1589 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); 1578 1592 break; 1579 1593 }
Note:
See TracChangeset
for help on using the changeset viewer.
