diff options
Diffstat (limited to 'src/pq/pq_result_helper.c')
-rw-r--r-- | src/pq/pq_result_helper.c | 371 |
1 files changed, 218 insertions, 153 deletions
diff --git a/src/pq/pq_result_helper.c b/src/pq/pq_result_helper.c index 808445b3b..f230826cb 100644 --- a/src/pq/pq_result_helper.c +++ b/src/pq/pq_result_helper.c | |||
@@ -21,10 +21,11 @@ | |||
21 | * @file pq/pq_result_helper.c | 21 | * @file pq/pq_result_helper.c |
22 | * @brief functions to extract result values | 22 | * @brief functions to extract result values |
23 | * @author Christian Grothoff | 23 | * @author Christian Grothoff |
24 | * @author Özgür Kesim | ||
24 | */ | 25 | */ |
25 | #include "gnunet_common.h" | ||
26 | #include "gnunet_time_lib.h" | ||
27 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_time_lib.h" | ||
28 | #include "gnunet_common.h" | ||
28 | #include "gnunet_util_lib.h" | 29 | #include "gnunet_util_lib.h" |
29 | #include "gnunet_pq_lib.h" | 30 | #include "gnunet_pq_lib.h" |
30 | #include "pq.h" | 31 | #include "pq.h" |
@@ -1179,13 +1180,13 @@ extract_array_generic ( | |||
1179 | *((void **) dst) = NULL; | 1180 | *((void **) dst) = NULL; |
1180 | 1181 | ||
1181 | #define FAIL_IF(cond) \ | 1182 | #define FAIL_IF(cond) \ |
1182 | do { \ | 1183 | do { \ |
1183 | if ((cond)) \ | 1184 | if ((cond)) \ |
1184 | { \ | 1185 | { \ |
1185 | GNUNET_break (! (cond)); \ | 1186 | GNUNET_break (! (cond)); \ |
1186 | goto FAIL; \ | 1187 | goto FAIL; \ |
1187 | } \ | 1188 | } \ |
1188 | } while(0) | 1189 | } while (0) |
1189 | 1190 | ||
1190 | col_num = PQfnumber (result, fname); | 1191 | col_num = PQfnumber (result, fname); |
1191 | FAIL_IF (0 > col_num); | 1192 | FAIL_IF (0 > col_num); |
@@ -1208,156 +1209,190 @@ extract_array_generic ( | |||
1208 | header.lbound = ntohl (h->lbound); | 1209 | header.lbound = ntohl (h->lbound); |
1209 | 1210 | ||
1210 | FAIL_IF (1 != header.ndim); | 1211 | FAIL_IF (1 != header.ndim); |
1211 | FAIL_IF ((0 > header.dim) || (INT_MAX == header.dim)); | 1212 | FAIL_IF (INT_MAX <= header.dim); |
1212 | FAIL_IF (0 != header.has_null); | 1213 | FAIL_IF (0 != header.has_null); |
1213 | FAIL_IF (1 != header.lbound); | 1214 | FAIL_IF (1 != header.lbound); |
1214 | FAIL_IF (info->oid != header.oid); | 1215 | FAIL_IF (info->oid != header.oid); |
1215 | } | 1216 | } |
1216 | 1217 | ||
1217 | *info->num = header.dim; | 1218 | if (NULL != info->num) |
1218 | switch (info->typ) | 1219 | *info->num = header.dim; |
1219 | { | ||
1220 | case array_of_bool: | ||
1221 | if (NULL != dst_size) | ||
1222 | *dst_size = sizeof(bool) * (*info->num); | ||
1223 | out = GNUNET_new_array (*info->num, bool); | ||
1224 | break; | ||
1225 | case array_of_uint16: | ||
1226 | if (NULL != dst_size) | ||
1227 | *dst_size = sizeof(uint16_t) * (*info->num); | ||
1228 | out = GNUNET_new_array (*info->num, uint16_t); | ||
1229 | break; | ||
1230 | case array_of_uint32: | ||
1231 | if (NULL != dst_size) | ||
1232 | *dst_size = sizeof(uint32_t) * (*info->num); | ||
1233 | out = GNUNET_new_array (*info->num, uint32_t); | ||
1234 | break; | ||
1235 | case array_of_uint64: | ||
1236 | if (NULL != dst_size) | ||
1237 | *dst_size = sizeof(uint64_t) * (*info->num); | ||
1238 | out = GNUNET_new_array (*info->num, uint64_t); | ||
1239 | break; | ||
1240 | case array_of_abs_time: | ||
1241 | if (NULL != dst_size) | ||
1242 | *dst_size = sizeof(struct GNUNET_TIME_Absolute) * (*info->num); | ||
1243 | out = GNUNET_new_array (*info->num, struct GNUNET_TIME_Absolute); | ||
1244 | break; | ||
1245 | case array_of_rel_time: | ||
1246 | if (NULL != dst_size) | ||
1247 | *dst_size = sizeof(struct GNUNET_TIME_Relative) * (*info->num); | ||
1248 | out = GNUNET_new_array (*info->num, struct GNUNET_TIME_Relative); | ||
1249 | break; | ||
1250 | case array_of_timestamp: | ||
1251 | if (NULL != dst_size) | ||
1252 | *dst_size = sizeof(struct GNUNET_TIME_Timestamp) * (*info->num); | ||
1253 | out = GNUNET_new_array (*info->num, struct GNUNET_TIME_Timestamp); | ||
1254 | break; | ||
1255 | case array_of_byte: | ||
1256 | if (0 == info->same_size) | ||
1257 | *info->sizes = GNUNET_new_array (header.dim, size_t); | ||
1258 | /* fallthrough */ | ||
1259 | case array_of_string: | ||
1260 | { | ||
1261 | size_t total = 0; | ||
1262 | bool is_string = (array_of_string == info->typ); | ||
1263 | |||
1264 | /* first, calculate total size required for allocation */ | ||
1265 | { | ||
1266 | char *ptr = data + sizeof(header); | ||
1267 | for (uint32_t i = 0; i < header.dim; i++) | ||
1268 | { | ||
1269 | uint32_t sz; | ||
1270 | |||
1271 | sz = ntohl (*(uint32_t *) ptr); | ||
1272 | sz += is_string ? 1 : 0; | ||
1273 | total += sz; | ||
1274 | ptr += sizeof(uint32_t); | ||
1275 | ptr += sz; | ||
1276 | 1220 | ||
1277 | if ((! is_string) && | ||
1278 | (0 == info->same_size)) | ||
1279 | (*info->sizes)[i] = sz; | ||
1280 | |||
1281 | FAIL_IF ((0 != info->same_size) && | ||
1282 | (sz != info->same_size)); | ||
1283 | FAIL_IF (total < sz); | ||
1284 | } | ||
1285 | } | ||
1286 | |||
1287 | if (NULL != dst_size) | ||
1288 | *dst_size = total; | ||
1289 | |||
1290 | if (0 < total) | ||
1291 | out = GNUNET_malloc (total); | ||
1292 | |||
1293 | break; | ||
1294 | } | ||
1295 | default: | ||
1296 | FAIL_IF (1 != 0); | ||
1297 | } | ||
1298 | |||
1299 | *((void **) dst) = out; | ||
1300 | |||
1301 | /* copy data */ | ||
1302 | { | 1221 | { |
1303 | char *in = data + sizeof(header); | 1222 | char *in = data + sizeof(header); |
1304 | 1223 | ||
1305 | for (uint32_t i = 0; i < header.dim; i++) | 1224 | switch (info->typ) |
1306 | { | 1225 | { |
1307 | size_t sz = ntohl (*(uint32_t *) in); | 1226 | case array_of_bool: |
1308 | in += sizeof(uint32_t); | 1227 | if (NULL != dst_size) |
1309 | 1228 | *dst_size = sizeof(bool) * (header.dim); | |
1310 | switch (info->typ) | 1229 | out = GNUNET_new_array (header.dim, bool); |
1230 | *((void **) dst) = out; | ||
1231 | for (uint32_t i = 0; i < header.dim; i++) | ||
1311 | { | 1232 | { |
1312 | case array_of_bool: | 1233 | size_t sz = ntohl (*(uint32_t *) in); |
1313 | FAIL_IF (sz != sizeof(bool)); | 1234 | FAIL_IF (sz != sizeof(bool)); |
1235 | in += sizeof(uint32_t); | ||
1314 | *(bool *) out = *(bool *) in; | 1236 | *(bool *) out = *(bool *) in; |
1315 | break; | 1237 | in += sz; |
1316 | case array_of_uint16: | 1238 | out += sz; |
1239 | } | ||
1240 | break; | ||
1241 | |||
1242 | case array_of_uint16: | ||
1243 | if (NULL != dst_size) | ||
1244 | *dst_size = sizeof(uint16_t) * (header.dim); | ||
1245 | out = GNUNET_new_array (header.dim, uint16_t); | ||
1246 | *((void **) dst) = out; | ||
1247 | for (uint32_t i = 0; i < header.dim; i++) | ||
1248 | { | ||
1249 | size_t sz = ntohl (*(uint32_t *) in); | ||
1317 | FAIL_IF (sz != sizeof(uint16_t)); | 1250 | FAIL_IF (sz != sizeof(uint16_t)); |
1251 | in += sizeof(uint32_t); | ||
1318 | *(uint16_t *) out = ntohs (*(uint16_t *) in); | 1252 | *(uint16_t *) out = ntohs (*(uint16_t *) in); |
1319 | break; | 1253 | in += sz; |
1320 | case array_of_uint32: | 1254 | out += sz; |
1255 | } | ||
1256 | break; | ||
1257 | |||
1258 | case array_of_uint32: | ||
1259 | if (NULL != dst_size) | ||
1260 | *dst_size = sizeof(uint32_t) * (header.dim); | ||
1261 | out = GNUNET_new_array (header.dim, uint32_t); | ||
1262 | *((void **) dst) = out; | ||
1263 | for (uint32_t i = 0; i < header.dim; i++) | ||
1264 | { | ||
1265 | size_t sz = ntohl (*(uint32_t *) in); | ||
1321 | FAIL_IF (sz != sizeof(uint32_t)); | 1266 | FAIL_IF (sz != sizeof(uint32_t)); |
1267 | in += sizeof(uint32_t); | ||
1322 | *(uint32_t *) out = ntohl (*(uint32_t *) in); | 1268 | *(uint32_t *) out = ntohl (*(uint32_t *) in); |
1323 | break; | 1269 | in += sz; |
1324 | case array_of_uint64: | 1270 | out += sz; |
1271 | } | ||
1272 | break; | ||
1273 | |||
1274 | case array_of_uint64: | ||
1275 | if (NULL != dst_size) | ||
1276 | *dst_size = sizeof(uint64_t) * (header.dim); | ||
1277 | out = GNUNET_new_array (header.dim, uint64_t); | ||
1278 | *((void **) dst) = out; | ||
1279 | for (uint32_t i = 0; i < header.dim; i++) | ||
1280 | { | ||
1281 | size_t sz = ntohl (*(uint32_t *) in); | ||
1325 | FAIL_IF (sz != sizeof(uint64_t)); | 1282 | FAIL_IF (sz != sizeof(uint64_t)); |
1283 | in += sizeof(uint32_t); | ||
1326 | *(uint64_t *) out = GNUNET_ntohll (*(uint64_t *) in); | 1284 | *(uint64_t *) out = GNUNET_ntohll (*(uint64_t *) in); |
1327 | break; | 1285 | in += sz; |
1328 | case array_of_abs_time: | 1286 | out += sz; |
1329 | case array_of_rel_time: | 1287 | } |
1330 | case array_of_timestamp: | 1288 | break; |
1289 | |||
1290 | case array_of_abs_time: | ||
1291 | if (NULL != dst_size) | ||
1292 | *dst_size = sizeof(struct GNUNET_TIME_Absolute) * (header.dim); | ||
1293 | out = GNUNET_new_array (header.dim, struct GNUNET_TIME_Absolute); | ||
1294 | *((void **) dst) = out; | ||
1295 | for (uint32_t i = 0; i < header.dim; i++) | ||
1296 | { | ||
1297 | size_t sz = ntohl (*(uint32_t *) in); | ||
1298 | FAIL_IF (sz != sizeof(uint64_t)); | ||
1299 | in += sizeof(uint32_t); | ||
1300 | ((struct GNUNET_TIME_Absolute *) out)->abs_value_us = | ||
1301 | GNUNET_ntohll (*(uint64_t *) in); | ||
1302 | in += sz; | ||
1303 | out += sz; | ||
1304 | } | ||
1305 | break; | ||
1306 | |||
1307 | case array_of_rel_time: | ||
1308 | if (NULL != dst_size) | ||
1309 | *dst_size = sizeof(struct GNUNET_TIME_Relative) * (header.dim); | ||
1310 | out = GNUNET_new_array (header.dim, struct GNUNET_TIME_Relative); | ||
1311 | *((void **) dst) = out; | ||
1312 | for (uint32_t i = 0; i < header.dim; i++) | ||
1313 | { | ||
1314 | size_t sz = ntohl (*(uint32_t *) in); | ||
1315 | FAIL_IF (sz != sizeof(uint64_t)); | ||
1316 | in += sizeof(uint32_t); | ||
1317 | ((struct GNUNET_TIME_Relative *) out)->rel_value_us = | ||
1318 | GNUNET_ntohll (*(uint64_t *) in); | ||
1319 | in += sz; | ||
1320 | out += sz; | ||
1321 | } | ||
1322 | break; | ||
1323 | |||
1324 | case array_of_timestamp: | ||
1325 | if (NULL != dst_size) | ||
1326 | *dst_size = sizeof(struct GNUNET_TIME_Timestamp) * (header.dim); | ||
1327 | out = GNUNET_new_array (header.dim, struct GNUNET_TIME_Timestamp); | ||
1328 | *((void **) dst) = out; | ||
1329 | for (uint32_t i = 0; i < header.dim; i++) | ||
1330 | { | ||
1331 | size_t sz = ntohl (*(uint32_t *) in); | ||
1331 | FAIL_IF (sz != sizeof(uint64_t)); | 1332 | FAIL_IF (sz != sizeof(uint64_t)); |
1333 | in += sizeof(uint32_t); | ||
1334 | ((struct GNUNET_TIME_Timestamp *) out)->abs_time.abs_value_us = | ||
1335 | GNUNET_ntohll (*(uint64_t *) in); | ||
1336 | in += sz; | ||
1337 | out += sz; | ||
1338 | } | ||
1339 | break; | ||
1340 | |||
1341 | case array_of_byte: | ||
1342 | if (0 == info->same_size) | ||
1343 | *info->sizes = GNUNET_new_array (header.dim, size_t); | ||
1344 | /* fallthrough */ | ||
1345 | case array_of_string: | ||
1346 | { | ||
1347 | size_t total = 0; | ||
1348 | bool is_string = (array_of_string == info->typ); | ||
1349 | |||
1350 | /* first, calculate total size required for allocation */ | ||
1332 | { | 1351 | { |
1333 | uint64_t val = GNUNET_ntohll (*(uint64_t *) in); | 1352 | char *ptr = data + sizeof(header); |
1334 | switch (info->typ) | 1353 | for (uint32_t i = 0; i < header.dim; i++) |
1335 | { | 1354 | { |
1336 | case array_of_abs_time: | 1355 | uint32_t sz; |
1337 | ((struct GNUNET_TIME_Absolute *) out)->abs_value_us = val; | 1356 | |
1338 | break; | 1357 | sz = ntohl (*(uint32_t *) ptr); |
1339 | case array_of_rel_time: | 1358 | sz += is_string ? 1 : 0; |
1340 | ((struct GNUNET_TIME_Relative *) out)->rel_value_us = val; | 1359 | total += sz; |
1341 | break; | 1360 | ptr += sizeof(uint32_t); |
1342 | case array_of_timestamp: | 1361 | ptr += sz; |
1343 | ((struct GNUNET_TIME_Timestamp *) out)->abs_time.abs_value_us = val; | 1362 | |
1344 | break; | 1363 | if ((! is_string) && |
1345 | default: | 1364 | (0 == info->same_size)) |
1346 | FAIL_IF (1 != 0); | 1365 | (*info->sizes)[i] = sz; |
1366 | |||
1367 | FAIL_IF ((0 != info->same_size) && | ||
1368 | (sz != info->same_size)); | ||
1369 | FAIL_IF (total < sz); | ||
1347 | } | 1370 | } |
1348 | } | 1371 | } |
1372 | |||
1373 | if (NULL != dst_size) | ||
1374 | *dst_size = total; | ||
1375 | |||
1376 | FAIL_IF (0 == total); | ||
1377 | out = GNUNET_malloc (total); | ||
1378 | |||
1379 | *((void **) dst) = out; | ||
1380 | |||
1381 | /* copy data */ | ||
1382 | for (uint32_t i = 0; i < header.dim; i++) | ||
1383 | { | ||
1384 | size_t sz = ntohl (*(uint32_t *) in); | ||
1385 | in += sizeof(uint32_t); | ||
1386 | GNUNET_memcpy (out, in, sz); | ||
1387 | |||
1388 | in += sz; | ||
1389 | out += sz; | ||
1390 | out += (array_of_string == info->typ) ? 1 : 0; | ||
1391 | } | ||
1349 | break; | 1392 | break; |
1350 | case array_of_byte: | ||
1351 | case array_of_string: | ||
1352 | GNUNET_memcpy (out, in, sz); | ||
1353 | break; | ||
1354 | default: | ||
1355 | FAIL_IF (1 != 0); | ||
1356 | } | 1393 | } |
1357 | 1394 | default: | |
1358 | in += sz; | 1395 | FAIL_IF (1 != 0); |
1359 | out += sz; | ||
1360 | out += (array_of_string == info->typ) ? 1 : 0; | ||
1361 | } | 1396 | } |
1362 | } | 1397 | } |
1363 | 1398 | ||
@@ -1394,7 +1429,7 @@ array_cleanup (void *cls, | |||
1394 | 1429 | ||
1395 | struct GNUNET_PQ_ResultSpec | 1430 | struct GNUNET_PQ_ResultSpec |
1396 | GNUNET_PQ_result_spec_array_bool ( | 1431 | GNUNET_PQ_result_spec_array_bool ( |
1397 | const struct GNUNET_PQ_Context *db, | 1432 | struct GNUNET_PQ_Context *db, |
1398 | const char *name, | 1433 | const char *name, |
1399 | size_t *num, | 1434 | size_t *num, |
1400 | bool **dst) | 1435 | bool **dst) |
@@ -1404,7 +1439,10 @@ GNUNET_PQ_result_spec_array_bool ( | |||
1404 | 1439 | ||
1405 | info->num = num; | 1440 | info->num = num; |
1406 | info->typ = array_of_bool; | 1441 | info->typ = array_of_bool; |
1407 | info->oid = db->oids[GNUNET_PQ_DATATYPE_BOOL]; | 1442 | GNUNET_assert (GNUNET_OK == |
1443 | GNUNET_PQ_get_oid_by_name (db, | ||
1444 | "bool", | ||
1445 | &info->oid)); | ||
1408 | 1446 | ||
1409 | struct GNUNET_PQ_ResultSpec res = { | 1447 | struct GNUNET_PQ_ResultSpec res = { |
1410 | .conv = extract_array_generic, | 1448 | .conv = extract_array_generic, |
@@ -1419,7 +1457,7 @@ GNUNET_PQ_result_spec_array_bool ( | |||
1419 | 1457 | ||
1420 | struct GNUNET_PQ_ResultSpec | 1458 | struct GNUNET_PQ_ResultSpec |
1421 | GNUNET_PQ_result_spec_array_uint16 ( | 1459 | GNUNET_PQ_result_spec_array_uint16 ( |
1422 | const struct GNUNET_PQ_Context *db, | 1460 | struct GNUNET_PQ_Context *db, |
1423 | const char *name, | 1461 | const char *name, |
1424 | size_t *num, | 1462 | size_t *num, |
1425 | uint16_t **dst) | 1463 | uint16_t **dst) |
@@ -1429,7 +1467,10 @@ GNUNET_PQ_result_spec_array_uint16 ( | |||
1429 | 1467 | ||
1430 | info->num = num; | 1468 | info->num = num; |
1431 | info->typ = array_of_uint16; | 1469 | info->typ = array_of_uint16; |
1432 | info->oid = db->oids[GNUNET_PQ_DATATYPE_INT2]; | 1470 | GNUNET_assert (GNUNET_OK == |
1471 | GNUNET_PQ_get_oid_by_name (db, | ||
1472 | "int2", | ||
1473 | &info->oid)); | ||
1433 | 1474 | ||
1434 | struct GNUNET_PQ_ResultSpec res = { | 1475 | struct GNUNET_PQ_ResultSpec res = { |
1435 | .conv = extract_array_generic, | 1476 | .conv = extract_array_generic, |
@@ -1444,7 +1485,7 @@ GNUNET_PQ_result_spec_array_uint16 ( | |||
1444 | 1485 | ||
1445 | struct GNUNET_PQ_ResultSpec | 1486 | struct GNUNET_PQ_ResultSpec |
1446 | GNUNET_PQ_result_spec_array_uint32 ( | 1487 | GNUNET_PQ_result_spec_array_uint32 ( |
1447 | const struct GNUNET_PQ_Context *db, | 1488 | struct GNUNET_PQ_Context *db, |
1448 | const char *name, | 1489 | const char *name, |
1449 | size_t *num, | 1490 | size_t *num, |
1450 | uint32_t **dst) | 1491 | uint32_t **dst) |
@@ -1454,7 +1495,10 @@ GNUNET_PQ_result_spec_array_uint32 ( | |||
1454 | 1495 | ||
1455 | info->num = num; | 1496 | info->num = num; |
1456 | info->typ = array_of_uint32; | 1497 | info->typ = array_of_uint32; |
1457 | info->oid = db->oids[GNUNET_PQ_DATATYPE_INT4]; | 1498 | GNUNET_assert (GNUNET_OK == |
1499 | GNUNET_PQ_get_oid_by_name (db, | ||
1500 | "int4", | ||
1501 | &info->oid)); | ||
1458 | 1502 | ||
1459 | struct GNUNET_PQ_ResultSpec res = { | 1503 | struct GNUNET_PQ_ResultSpec res = { |
1460 | .conv = extract_array_generic, | 1504 | .conv = extract_array_generic, |
@@ -1469,7 +1513,7 @@ GNUNET_PQ_result_spec_array_uint32 ( | |||
1469 | 1513 | ||
1470 | struct GNUNET_PQ_ResultSpec | 1514 | struct GNUNET_PQ_ResultSpec |
1471 | GNUNET_PQ_result_spec_array_uint64 ( | 1515 | GNUNET_PQ_result_spec_array_uint64 ( |
1472 | const struct GNUNET_PQ_Context *db, | 1516 | struct GNUNET_PQ_Context *db, |
1473 | const char *name, | 1517 | const char *name, |
1474 | size_t *num, | 1518 | size_t *num, |
1475 | uint64_t **dst) | 1519 | uint64_t **dst) |
@@ -1479,7 +1523,10 @@ GNUNET_PQ_result_spec_array_uint64 ( | |||
1479 | 1523 | ||
1480 | info->num = num; | 1524 | info->num = num; |
1481 | info->typ = array_of_uint64; | 1525 | info->typ = array_of_uint64; |
1482 | info->oid = db->oids[GNUNET_PQ_DATATYPE_INT8]; | 1526 | GNUNET_assert (GNUNET_OK == |
1527 | GNUNET_PQ_get_oid_by_name (db, | ||
1528 | "int8", | ||
1529 | &info->oid)); | ||
1483 | 1530 | ||
1484 | struct GNUNET_PQ_ResultSpec res = { | 1531 | struct GNUNET_PQ_ResultSpec res = { |
1485 | .conv = extract_array_generic, | 1532 | .conv = extract_array_generic, |
@@ -1494,7 +1541,7 @@ GNUNET_PQ_result_spec_array_uint64 ( | |||
1494 | 1541 | ||
1495 | struct GNUNET_PQ_ResultSpec | 1542 | struct GNUNET_PQ_ResultSpec |
1496 | GNUNET_PQ_result_spec_array_abs_time ( | 1543 | GNUNET_PQ_result_spec_array_abs_time ( |
1497 | const struct GNUNET_PQ_Context *db, | 1544 | struct GNUNET_PQ_Context *db, |
1498 | const char *name, | 1545 | const char *name, |
1499 | size_t *num, | 1546 | size_t *num, |
1500 | struct GNUNET_TIME_Absolute **dst) | 1547 | struct GNUNET_TIME_Absolute **dst) |
@@ -1504,7 +1551,10 @@ GNUNET_PQ_result_spec_array_abs_time ( | |||
1504 | 1551 | ||
1505 | info->num = num; | 1552 | info->num = num; |
1506 | info->typ = array_of_abs_time; | 1553 | info->typ = array_of_abs_time; |
1507 | info->oid = db->oids[GNUNET_PQ_DATATYPE_INT8]; | 1554 | GNUNET_assert (GNUNET_OK == |
1555 | GNUNET_PQ_get_oid_by_name (db, | ||
1556 | "int8", | ||
1557 | &info->oid)); | ||
1508 | 1558 | ||
1509 | struct GNUNET_PQ_ResultSpec res = { | 1559 | struct GNUNET_PQ_ResultSpec res = { |
1510 | .conv = extract_array_generic, | 1560 | .conv = extract_array_generic, |
@@ -1519,7 +1569,7 @@ GNUNET_PQ_result_spec_array_abs_time ( | |||
1519 | 1569 | ||
1520 | struct GNUNET_PQ_ResultSpec | 1570 | struct GNUNET_PQ_ResultSpec |
1521 | GNUNET_PQ_result_spec_array_rel_time ( | 1571 | GNUNET_PQ_result_spec_array_rel_time ( |
1522 | const struct GNUNET_PQ_Context *db, | 1572 | struct GNUNET_PQ_Context *db, |
1523 | const char *name, | 1573 | const char *name, |
1524 | size_t *num, | 1574 | size_t *num, |
1525 | struct GNUNET_TIME_Relative **dst) | 1575 | struct GNUNET_TIME_Relative **dst) |
@@ -1529,7 +1579,10 @@ GNUNET_PQ_result_spec_array_rel_time ( | |||
1529 | 1579 | ||
1530 | info->num = num; | 1580 | info->num = num; |
1531 | info->typ = array_of_rel_time; | 1581 | info->typ = array_of_rel_time; |
1532 | info->oid = db->oids[GNUNET_PQ_DATATYPE_INT8]; | 1582 | GNUNET_assert (GNUNET_OK == |
1583 | GNUNET_PQ_get_oid_by_name (db, | ||
1584 | "int8", | ||
1585 | &info->oid)); | ||
1533 | 1586 | ||
1534 | struct GNUNET_PQ_ResultSpec res = { | 1587 | struct GNUNET_PQ_ResultSpec res = { |
1535 | .conv = extract_array_generic, | 1588 | .conv = extract_array_generic, |
@@ -1544,7 +1597,7 @@ GNUNET_PQ_result_spec_array_rel_time ( | |||
1544 | 1597 | ||
1545 | struct GNUNET_PQ_ResultSpec | 1598 | struct GNUNET_PQ_ResultSpec |
1546 | GNUNET_PQ_result_spec_array_timestamp ( | 1599 | GNUNET_PQ_result_spec_array_timestamp ( |
1547 | const struct GNUNET_PQ_Context *db, | 1600 | struct GNUNET_PQ_Context *db, |
1548 | const char *name, | 1601 | const char *name, |
1549 | size_t *num, | 1602 | size_t *num, |
1550 | struct GNUNET_TIME_Timestamp **dst) | 1603 | struct GNUNET_TIME_Timestamp **dst) |
@@ -1554,7 +1607,10 @@ GNUNET_PQ_result_spec_array_timestamp ( | |||
1554 | 1607 | ||
1555 | info->num = num; | 1608 | info->num = num; |
1556 | info->typ = array_of_timestamp; | 1609 | info->typ = array_of_timestamp; |
1557 | info->oid = db->oids[GNUNET_PQ_DATATYPE_INT8]; | 1610 | GNUNET_assert (GNUNET_OK == |
1611 | GNUNET_PQ_get_oid_by_name (db, | ||
1612 | "int8", | ||
1613 | &info->oid)); | ||
1558 | 1614 | ||
1559 | struct GNUNET_PQ_ResultSpec res = { | 1615 | struct GNUNET_PQ_ResultSpec res = { |
1560 | .conv = extract_array_generic, | 1616 | .conv = extract_array_generic, |
@@ -1569,7 +1625,7 @@ GNUNET_PQ_result_spec_array_timestamp ( | |||
1569 | 1625 | ||
1570 | struct GNUNET_PQ_ResultSpec | 1626 | struct GNUNET_PQ_ResultSpec |
1571 | GNUNET_PQ_result_spec_array_variable_size ( | 1627 | GNUNET_PQ_result_spec_array_variable_size ( |
1572 | const struct GNUNET_PQ_Context *db, | 1628 | struct GNUNET_PQ_Context *db, |
1573 | const char *name, | 1629 | const char *name, |
1574 | size_t *num, | 1630 | size_t *num, |
1575 | size_t **sizes, | 1631 | size_t **sizes, |
@@ -1581,7 +1637,10 @@ GNUNET_PQ_result_spec_array_variable_size ( | |||
1581 | info->num = num; | 1637 | info->num = num; |
1582 | info->sizes = sizes; | 1638 | info->sizes = sizes; |
1583 | info->typ = array_of_byte; | 1639 | info->typ = array_of_byte; |
1584 | info->oid = db->oids[GNUNET_PQ_DATATYPE_BYTEA]; | 1640 | GNUNET_assert (GNUNET_OK == |
1641 | GNUNET_PQ_get_oid_by_name (db, | ||
1642 | "bytea", | ||
1643 | &info->oid)); | ||
1585 | 1644 | ||
1586 | struct GNUNET_PQ_ResultSpec res = { | 1645 | struct GNUNET_PQ_ResultSpec res = { |
1587 | .conv = extract_array_generic, | 1646 | .conv = extract_array_generic, |
@@ -1596,7 +1655,7 @@ GNUNET_PQ_result_spec_array_variable_size ( | |||
1596 | 1655 | ||
1597 | struct GNUNET_PQ_ResultSpec | 1656 | struct GNUNET_PQ_ResultSpec |
1598 | GNUNET_PQ_result_spec_array_fixed_size ( | 1657 | GNUNET_PQ_result_spec_array_fixed_size ( |
1599 | const struct GNUNET_PQ_Context *db, | 1658 | struct GNUNET_PQ_Context *db, |
1600 | const char *name, | 1659 | const char *name, |
1601 | size_t size, | 1660 | size_t size, |
1602 | size_t *num, | 1661 | size_t *num, |
@@ -1608,7 +1667,10 @@ GNUNET_PQ_result_spec_array_fixed_size ( | |||
1608 | info->num = num; | 1667 | info->num = num; |
1609 | info->same_size = size; | 1668 | info->same_size = size; |
1610 | info->typ = array_of_byte; | 1669 | info->typ = array_of_byte; |
1611 | info->oid = db->oids[GNUNET_PQ_DATATYPE_BYTEA]; | 1670 | GNUNET_assert (GNUNET_OK == |
1671 | GNUNET_PQ_get_oid_by_name (db, | ||
1672 | "bytea", | ||
1673 | &info->oid)); | ||
1612 | 1674 | ||
1613 | struct GNUNET_PQ_ResultSpec res = { | 1675 | struct GNUNET_PQ_ResultSpec res = { |
1614 | .conv = extract_array_generic, | 1676 | .conv = extract_array_generic, |
@@ -1623,7 +1685,7 @@ GNUNET_PQ_result_spec_array_fixed_size ( | |||
1623 | 1685 | ||
1624 | struct GNUNET_PQ_ResultSpec | 1686 | struct GNUNET_PQ_ResultSpec |
1625 | GNUNET_PQ_result_spec_array_string ( | 1687 | GNUNET_PQ_result_spec_array_string ( |
1626 | const struct GNUNET_PQ_Context *db, | 1688 | struct GNUNET_PQ_Context *db, |
1627 | const char *name, | 1689 | const char *name, |
1628 | size_t *num, | 1690 | size_t *num, |
1629 | char **dst) | 1691 | char **dst) |
@@ -1633,7 +1695,10 @@ GNUNET_PQ_result_spec_array_string ( | |||
1633 | 1695 | ||
1634 | info->num = num; | 1696 | info->num = num; |
1635 | info->typ = array_of_string; | 1697 | info->typ = array_of_string; |
1636 | info->oid = db->oids[GNUNET_PQ_DATATYPE_VARCHAR]; | 1698 | GNUNET_assert (GNUNET_OK == |
1699 | GNUNET_PQ_get_oid_by_name (db, | ||
1700 | "text", | ||
1701 | &info->oid)); | ||
1637 | 1702 | ||
1638 | struct GNUNET_PQ_ResultSpec res = { | 1703 | struct GNUNET_PQ_ResultSpec res = { |
1639 | .conv = extract_array_generic, | 1704 | .conv = extract_array_generic, |