Browse code

- initial support for BIGINT database in DB core and SQL based database modules, closes patch #2101659 - some tests for mysql were done, but more testing, especially for the postgres and unixodbc would be appreciated - Todo: fix other DB modules, at the moment some warnings are printed during compilation because of the unhandled BIGINT state

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@4928 689a6050-402a-0410-94f2-e92a70836424

Henning Westerholt authored on 16/09/2008 16:44:10
Showing 2 changed files
... ...
@@ -90,12 +90,16 @@ int db_mysql_get_columns(const db_con_t* _h, db_res_t* _r)
90 90
 			case MYSQL_TYPE_SHORT:
91 91
 			case MYSQL_TYPE_LONG:
92 92
 			case MYSQL_TYPE_INT24:
93
-			case MYSQL_TYPE_LONGLONG:
94 93
 			case MYSQL_TYPE_TIMESTAMP:
95 94
 				LM_DBG("use DB_INT result type\n");
96 95
 				RES_TYPES(_r)[col] = DB_INT;
97 96
 				break;
98 97
 
98
+			case MYSQL_TYPE_LONGLONG:
99
+				LM_DBG("use DB_BIGINT result type\n");
100
+				RES_TYPES(_r)[col] = DB_BIGINT;
101
+				break;
102
+
99 103
 			case MYSQL_TYPE_FLOAT:
100 104
 			case MYSQL_TYPE_DOUBLE:
101 105
 				LM_DBG("use DB_DOUBLE result type\n");
... ...
@@ -75,11 +75,22 @@ int db_mysql_str2val(const db_type_t _t, db_val_t* _v, const char* _s, const int
75 75
 		}
76 76
 		break;
77 77
 
78
+	case DB_BIGINT:
79
+		LM_DBG("converting BIGINT [%s]\n", _s);
80
+		if (db_str2longlong(_s, &VAL_BIGINT(_v)) < 0) {
81
+			LM_ERR("error while converting big integer value from string\n");
82
+			return -3;
83
+		} else {
84
+			VAL_TYPE(_v) = DB_BIGINT;
85
+			return 0;
86
+		}
87
+		break;
88
+
78 89
 	case DB_BITMAP:
79 90
 		LM_DBG("converting BITMAP [%s]\n", _s);
80 91
 		if (db_str2int(_s, &VAL_INT(_v)) < 0) {
81 92
 			LM_ERR("error while converting bitmap value from string\n");
82
-			return -3;
93
+			return -4;
83 94
 		} else {
84 95
 			VAL_TYPE(_v) = DB_BITMAP;
85 96
 			return 0;
... ...
@@ -90,7 +101,7 @@ int db_mysql_str2val(const db_type_t _t, db_val_t* _v, const char* _s, const int
90 101
 		LM_DBG("converting DOUBLE [%s]\n", _s);
91 102
 		if (db_str2double(_s, &VAL_DOUBLE(_v)) < 0) {
92 103
 			LM_ERR("error while converting double value from string\n");
93
-			return -4;
104
+			return -5;
94 105
 		} else {
95 106
 			VAL_TYPE(_v) = DB_DOUBLE;
96 107
 			return 0;
... ...
@@ -114,7 +125,7 @@ int db_mysql_str2val(const db_type_t _t, db_val_t* _v, const char* _s, const int
114 125
 		LM_DBG("converting DATETIME [%s]\n", _s);
115 126
 		if (db_str2time(_s, &VAL_TIME(_v)) < 0) {
116 127
 			LM_ERR("error while converting datetime value from string\n");
117
-			return -5;
128
+			return -6;
118 129
 		} else {
119 130
 			VAL_TYPE(_v) = DB_DATETIME;
120 131
 			return 0;
... ...
@@ -128,7 +139,7 @@ int db_mysql_str2val(const db_type_t _t, db_val_t* _v, const char* _s, const int
128 139
 		VAL_TYPE(_v) = DB_BLOB;
129 140
 		return 0;
130 141
 	}
131
-	return -6;
142
+	return -7;
132 143
 }
133 144
 
134 145
 
... ...
@@ -164,10 +175,19 @@ int db_mysql_val2str(const db_con_t* _c, const db_val_t* _v, char* _s, int* _len
164 175
 		}
165 176
 		break;
166 177
 
178
+	case DB_BIGINT:
179
+		if (db_longlong2str(VAL_BIGINT(_v), _s, _len) < 0) {
180
+			LM_ERR("error while converting string to big int\n");
181
+			return -3;
182
+		} else {
183
+			return 0;
184
+		}
185
+		break;
186
+
167 187
 	case DB_BITMAP:
168 188
 		if (db_int2str(VAL_BITMAP(_v), _s, _len) < 0) {
169 189
 			LM_ERR("error while converting string to int\n");
170
-			return -3;
190
+			return -4;
171 191
 		} else {
172 192
 			return 0;
173 193
 		}
... ...
@@ -176,7 +196,7 @@ int db_mysql_val2str(const db_con_t* _c, const db_val_t* _v, char* _s, int* _len
176 196
 	case DB_DOUBLE:
177 197
 		if (db_double2str(VAL_DOUBLE(_v), _s, _len) < 0) {
178 198
 			LM_ERR("error while converting string to double\n");
179
-			return -4;
199
+			return -5;
180 200
 		} else {
181 201
 			return 0;
182 202
 		}
... ...
@@ -186,7 +206,7 @@ int db_mysql_val2str(const db_con_t* _c, const db_val_t* _v, char* _s, int* _len
186 206
 		l = strlen(VAL_STRING(_v));
187 207
 		if (*_len < (l * 2 + 3)) {
188 208
 			LM_ERR("destination buffer too short\n");
189
-			return -5;
209
+			return -6;
190 210
 		} else {
191 211
 			old_s = _s;
192 212
 			*_s++ = '\'';
... ...
@@ -201,7 +221,7 @@ int db_mysql_val2str(const db_con_t* _c, const db_val_t* _v, char* _s, int* _len
201 221
 	case DB_STR:
202 222
 		if (*_len < (VAL_STR(_v).len * 2 + 3)) {
203 223
 			LM_ERR("destination buffer too short\n");
204
-			return -6;
224
+			return -7;
205 225
 		} else {
206 226
 			old_s = _s;
207 227
 			*_s++ = '\'';
... ...
@@ -216,7 +236,7 @@ int db_mysql_val2str(const db_con_t* _c, const db_val_t* _v, char* _s, int* _len
216 236
 	case DB_DATETIME:
217 237
 		if (db_time2str(VAL_TIME(_v), _s, _len) < 0) {
218 238
 			LM_ERR("error while converting string to time_t\n");
219
-			return -7;
239
+			return -8;
220 240
 		} else {
221 241
 			return 0;
222 242
 		}
... ...
@@ -226,7 +246,7 @@ int db_mysql_val2str(const db_con_t* _c, const db_val_t* _v, char* _s, int* _len
226 246
 		l = VAL_BLOB(_v).len;
227 247
 		if (*_len < (l * 2 + 3)) {
228 248
 			LM_ERR("destination buffer too short\n");
229
-			return -8;
249
+			return -9;
230 250
 		} else {
231 251
 			old_s = _s;
232 252
 			*_s++ = '\'';
... ...
@@ -240,7 +260,7 @@ int db_mysql_val2str(const db_con_t* _c, const db_val_t* _v, char* _s, int* _len
240 260
 
241 261
 	default:
242 262
 		LM_DBG("unknown data type\n");
243
-		return -9;
263
+		return -10;
244 264
 	}
245 265
 	/*return -8; --not reached*/
246 266
 }