Commit 1b81fbd629434df61a406b6b1016cb74a722ce92

Authored by David RENÉ
1 parent e27bdbc4

Revert a commit to SQLAPI which make SA_dtNumeric a float instead of big int. I …

…thought I already make that change but it seems not. Anyway now float from mysql are read correctly
Showing 1 changed file with 15 additions and 21 deletions   Show diff stats
anubis_dev/vm/src/dbapi_tools.cpp
... ... @@ -16,7 +16,6 @@ bool MakeDbError(int error_code, const char * error_msg, U32 * var_dst, AnubisAl
16 16 {
17 17 U32 error_seg = 0;
18 18 U32 string_seg = 0;
19   - //const char *msg = NULL;
20 19 /* get the DbError memory segment */
21 20 if ((error_seg = allocator->AllocateDataSegment(3)) == 0)
22 21 {
... ... @@ -41,6 +40,7 @@ bool MakeDbError(int error_code, const char * error_msg, U32 * var_dst, AnubisAl
41 40  
42 41 U32 MakeDbDatum(const SAField & field, AnubisAllocator *allocator)
43 42 {
  43 +
44 44 U32 result = allocator->AllocateDataSegment(3);
45 45 if(result == 0)
46 46 return 0;
... ... @@ -54,12 +54,13 @@ U32 MakeDbDatum(const SAField & field, AnubisAllocator *allocator)
54 54  
55 55 try{
56 56 U32 datum_type = field.FieldType();
  57 +
57 58 switch(datum_type)
58 59 {
59 60 case SA_dtBool:
60 61 value = field.asBool() ? 1 : 0;
61 62 alternative = 1;
62   - break;
  63 + break;
63 64  
64 65 case SA_dtShort:
65 66 case SA_dtLong:
... ... @@ -70,8 +71,8 @@ U32 MakeDbDatum(const SAField & field, AnubisAllocator *allocator)
70 71 return 0;
71 72 }
72 73 alternative = 2;
73   - break;
74   -
  74 + break;
  75 +
75 76 case SA_dtUShort:
76 77 case SA_dtULong:
77 78 value = C_int64_to_Anubis_Int(field.asULong(), allocator);
... ... @@ -81,27 +82,19 @@ U32 MakeDbDatum(const SAField & field, AnubisAllocator *allocator)
81 82 return 0;
82 83 }
83 84 alternative = 2;
84   - break;
85   -
  85 + break;
  86 +
86 87 case SA_dtDouble:
  88 + case SA_dtNumeric:
87 89 if ((value = allocator->AllocateDataSegment(3)) == 0)
88 90 {
89 91 allocator->FreeDataSegment((U32*)result);
90 92 return 0;
91 93 }
  94 +
92 95 *((double *)(((U32 *)(value))+1)) = field.asDouble();
93 96 alternative = 3;
94   - break;
95   -
96   - case SA_dtNumeric:
97   - value = C_int64_to_Anubis_Int((sa_int64_t)field.asNumeric(), allocator);
98   - if(value == 0)
99   - {
100   - allocator->FreeDataSegment((U32*)result);
101   - return 0;
102   - }
103   - alternative = 2;
104   - break;
  97 + break;
105 98  
106 99 case SA_dtDateTime:
107 100 value = SADateTime_2_DateAndTime(field.asDateTime(), allocator);
... ... @@ -111,7 +104,7 @@ U32 MakeDbDatum(const SAField & field, AnubisAllocator *allocator)
111 104 return 0;
112 105 }
113 106 alternative = 4;
114   - break;
  107 + break;
115 108  
116 109 case SA_dtString:
117 110 case SA_dtLongChar:
... ... @@ -123,9 +116,10 @@ U32 MakeDbDatum(const SAField & field, AnubisAllocator *allocator)
123 116 return 0;
124 117 }
125 118 strcpy((char *)(value+4), s);
126   - }
  119 +
127 120 alternative = 5;
128   - break;
  121 + }
  122 + break;
129 123  
130 124 case SA_dtBytes:
131 125 case SA_dtLongBinary:
... ... @@ -143,7 +137,7 @@ U32 MakeDbDatum(const SAField & field, AnubisAllocator *allocator)
143 137 memcpy((char *)(value+8), s, l);
144 138 }
145 139 alternative = 6;
146   - break;
  140 + break;
147 141  
148 142 case SA_dtInterval:
149 143 case SA_dtCursor:
... ...