diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-08-26 12:24:20 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-08-26 12:24:20 +0000 |
commit | 34a6eef6a3e9c85b40c1f472886d18c1b7b95ce1 (patch) | |
tree | 19e5fe13cc2d6515eee1006324c89adcd7309168 /src/datastore | |
parent | bf99b4a4df68b7fc2de68ee09a0526cf72fe66d0 (diff) | |
download | gnunet-34a6eef6a3e9c85b40c1f472886d18c1b7b95ce1.tar.gz gnunet-34a6eef6a3e9c85b40c1f472886d18c1b7b95ce1.zip |
do not store size
Diffstat (limited to 'src/datastore')
-rw-r--r-- | src/datastore/plugin_datastore_postgres.c | 109 |
1 files changed, 52 insertions, 57 deletions
diff --git a/src/datastore/plugin_datastore_postgres.c b/src/datastore/plugin_datastore_postgres.c index 9473bbbed..99be51022 100644 --- a/src/datastore/plugin_datastore_postgres.c +++ b/src/datastore/plugin_datastore_postgres.c | |||
@@ -30,40 +30,40 @@ | |||
30 | 30 | ||
31 | #define DEBUG_POSTGRES GNUNET_NO | 31 | #define DEBUG_POSTGRES GNUNET_NO |
32 | 32 | ||
33 | #define SELECT_IT_LOW_PRIORITY "(SELECT size, type, prio, anonLevel, expire, hash, value, oid FROM gn080 "\ | 33 | #define SELECT_IT_LOW_PRIORITY "(SELECT type, prio, anonLevel, expire, hash, value, oid FROM gn090 "\ |
34 | "WHERE (prio = $1 AND oid > $2) " \ | 34 | "WHERE (prio = $1 AND oid > $2) " \ |
35 | "ORDER BY prio ASC,oid ASC LIMIT 1) "\ | 35 | "ORDER BY prio ASC,oid ASC LIMIT 1) "\ |
36 | "UNION "\ | 36 | "UNION "\ |
37 | "(SELECT size, type, prio, anonLevel, expire, hash, value, oid FROM gn080 "\ | 37 | "(SELECT type, prio, anonLevel, expire, hash, value, oid FROM gn090 "\ |
38 | "WHERE (prio > $1 AND oid != $2)"\ | 38 | "WHERE (prio > $1 AND oid != $2)"\ |
39 | "ORDER BY prio ASC,oid ASC LIMIT 1)"\ | 39 | "ORDER BY prio ASC,oid ASC LIMIT 1)"\ |
40 | "ORDER BY prio ASC,oid ASC LIMIT 1" | 40 | "ORDER BY prio ASC,oid ASC LIMIT 1" |
41 | 41 | ||
42 | #define SELECT_IT_NON_ANONYMOUS "(SELECT size, type, prio, anonLevel, expire, hash, value, oid FROM gn080 "\ | 42 | #define SELECT_IT_NON_ANONYMOUS "(SELECT type, prio, anonLevel, expire, hash, value, oid FROM gn090 "\ |
43 | "WHERE (prio = $1 AND oid < $2)"\ | 43 | "WHERE (prio = $1 AND oid < $2)"\ |
44 | " AND anonLevel=0 ORDER BY prio DESC,oid DESC LIMIT 1) "\ | 44 | " AND anonLevel=0 ORDER BY prio DESC,oid DESC LIMIT 1) "\ |
45 | "UNION "\ | 45 | "UNION "\ |
46 | "(SELECT size, type, prio, anonLevel, expire, hash, value, oid FROM gn080 "\ | 46 | "(SELECT type, prio, anonLevel, expire, hash, value, oid FROM gn090 "\ |
47 | "WHERE (prio < $1 AND oid != $2)"\ | 47 | "WHERE (prio < $1 AND oid != $2)"\ |
48 | " AND anonLevel=0 ORDER BY prio DESC,oid DESC LIMIT 1) "\ | 48 | " AND anonLevel=0 ORDER BY prio DESC,oid DESC LIMIT 1) "\ |
49 | "ORDER BY prio DESC,oid DESC LIMIT 1" | 49 | "ORDER BY prio DESC,oid DESC LIMIT 1" |
50 | 50 | ||
51 | #define SELECT_IT_EXPIRATION_TIME "(SELECT size, type, prio, anonLevel, expire, hash, value, oid FROM gn080 "\ | 51 | #define SELECT_IT_EXPIRATION_TIME "(SELECT type, prio, anonLevel, expire, hash, value, oid FROM gn090 "\ |
52 | "WHERE (expire = $1 AND oid > $2) "\ | 52 | "WHERE (expire = $1 AND oid > $2) "\ |
53 | "ORDER BY expire ASC,oid ASC LIMIT 1) "\ | 53 | "ORDER BY expire ASC,oid ASC LIMIT 1) "\ |
54 | "UNION "\ | 54 | "UNION "\ |
55 | "(SELECT size, type, prio, anonLevel, expire, hash, value, oid FROM gn080 "\ | 55 | "(SELECT type, prio, anonLevel, expire, hash, value, oid FROM gn090 "\ |
56 | "WHERE (expire > $1 AND oid != $2) " \ | 56 | "WHERE (expire > $1 AND oid != $2) " \ |
57 | "ORDER BY expire ASC,oid ASC LIMIT 1)"\ | 57 | "ORDER BY expire ASC,oid ASC LIMIT 1)"\ |
58 | "ORDER BY expire ASC,oid ASC LIMIT 1" | 58 | "ORDER BY expire ASC,oid ASC LIMIT 1" |
59 | 59 | ||
60 | 60 | ||
61 | #define SELECT_IT_MIGRATION_ORDER "(SELECT size, type, prio, anonLevel, expire, hash, value, oid FROM gn080 "\ | 61 | #define SELECT_IT_MIGRATION_ORDER "(SELECT type, prio, anonLevel, expire, hash, value, oid FROM gn090 "\ |
62 | "WHERE (expire = $1 AND oid < $2)"\ | 62 | "WHERE (expire = $1 AND oid < $2)"\ |
63 | " AND expire > $3 AND type!=3"\ | 63 | " AND expire > $3 AND type!=3"\ |
64 | " ORDER BY expire DESC,oid DESC LIMIT 1) "\ | 64 | " ORDER BY expire DESC,oid DESC LIMIT 1) "\ |
65 | "UNION "\ | 65 | "UNION "\ |
66 | "(SELECT size, type, prio, anonLevel, expire, hash, value, oid FROM gn080 "\ | 66 | "(SELECT type, prio, anonLevel, expire, hash, value, oid FROM gn090 "\ |
67 | "WHERE (expire < $1 AND oid != $2)" \ | 67 | "WHERE (expire < $1 AND oid != $2)" \ |
68 | " AND expire > $3 AND type!=3"\ | 68 | " AND expire > $3 AND type!=3"\ |
69 | " ORDER BY expire DESC,oid DESC LIMIT 1)"\ | 69 | " ORDER BY expire DESC,oid DESC LIMIT 1)"\ |
@@ -239,8 +239,7 @@ init_connection (struct Plugin *plugin) | |||
239 | return GNUNET_SYSERR; | 239 | return GNUNET_SYSERR; |
240 | } | 240 | } |
241 | ret = PQexec (plugin->dbh, | 241 | ret = PQexec (plugin->dbh, |
242 | "CREATE TABLE gn080 (" | 242 | "CREATE TABLE gn090 (" |
243 | " size INTEGER NOT NULL DEFAULT 0," | ||
244 | " type INTEGER NOT NULL DEFAULT 0," | 243 | " type INTEGER NOT NULL DEFAULT 0," |
245 | " prio INTEGER NOT NULL DEFAULT 0," | 244 | " prio INTEGER NOT NULL DEFAULT 0," |
246 | " anonLevel INTEGER NOT NULL DEFAULT 0," | 245 | " anonLevel INTEGER NOT NULL DEFAULT 0," |
@@ -256,7 +255,7 @@ init_connection (struct Plugin *plugin) | |||
256 | PG_DIAG_SQLSTATE))))) | 255 | PG_DIAG_SQLSTATE))))) |
257 | { | 256 | { |
258 | check_result (plugin, | 257 | check_result (plugin, |
259 | ret, PGRES_COMMAND_OK, "CREATE TABLE", "gn080", __LINE__); | 258 | ret, PGRES_COMMAND_OK, "CREATE TABLE", "gn090", __LINE__); |
260 | PQfinish (plugin->dbh); | 259 | PQfinish (plugin->dbh); |
261 | plugin->dbh = NULL; | 260 | plugin->dbh = NULL; |
262 | return GNUNET_SYSERR; | 261 | return GNUNET_SYSERR; |
@@ -264,23 +263,23 @@ init_connection (struct Plugin *plugin) | |||
264 | if (PQresultStatus (ret) == PGRES_COMMAND_OK) | 263 | if (PQresultStatus (ret) == PGRES_COMMAND_OK) |
265 | { | 264 | { |
266 | if ((GNUNET_OK != | 265 | if ((GNUNET_OK != |
267 | pq_exec (plugin, "CREATE INDEX idx_hash ON gn080 (hash)", __LINE__)) || | 266 | pq_exec (plugin, "CREATE INDEX idx_hash ON gn090 (hash)", __LINE__)) || |
268 | (GNUNET_OK != | 267 | (GNUNET_OK != |
269 | pq_exec (plugin, "CREATE INDEX idx_hash_vhash ON gn080 (hash,vhash)", | 268 | pq_exec (plugin, "CREATE INDEX idx_hash_vhash ON gn090 (hash,vhash)", |
270 | __LINE__)) | 269 | __LINE__)) |
271 | || (GNUNET_OK != | 270 | || (GNUNET_OK != |
272 | pq_exec (plugin, "CREATE INDEX idx_prio ON gn080 (prio)", __LINE__)) | 271 | pq_exec (plugin, "CREATE INDEX idx_prio ON gn090 (prio)", __LINE__)) |
273 | || (GNUNET_OK != | 272 | || (GNUNET_OK != |
274 | pq_exec (plugin, "CREATE INDEX idx_expire ON gn080 (expire)", __LINE__)) | 273 | pq_exec (plugin, "CREATE INDEX idx_expire ON gn090 (expire)", __LINE__)) |
275 | || (GNUNET_OK != | 274 | || (GNUNET_OK != |
276 | pq_exec (plugin, "CREATE INDEX idx_comb3 ON gn080 (prio,anonLevel)", | 275 | pq_exec (plugin, "CREATE INDEX idx_comb3 ON gn090 (prio,anonLevel)", |
277 | __LINE__)) | 276 | __LINE__)) |
278 | || (GNUNET_OK != | 277 | || (GNUNET_OK != |
279 | pq_exec | 278 | pq_exec |
280 | (plugin, "CREATE INDEX idx_comb4 ON gn080 (prio,hash,anonLevel)", | 279 | (plugin, "CREATE INDEX idx_comb4 ON gn090 (prio,hash,anonLevel)", |
281 | __LINE__)) | 280 | __LINE__)) |
282 | || (GNUNET_OK != | 281 | || (GNUNET_OK != |
283 | pq_exec (plugin, "CREATE INDEX idx_comb7 ON gn080 (expire,hash)", | 282 | pq_exec (plugin, "CREATE INDEX idx_comb7 ON gn090 (expire,hash)", |
284 | __LINE__))) | 283 | __LINE__))) |
285 | { | 284 | { |
286 | PQclear (ret); | 285 | PQclear (ret); |
@@ -292,11 +291,11 @@ init_connection (struct Plugin *plugin) | |||
292 | PQclear (ret); | 291 | PQclear (ret); |
293 | #if 1 | 292 | #if 1 |
294 | ret = PQexec (plugin->dbh, | 293 | ret = PQexec (plugin->dbh, |
295 | "ALTER TABLE gn080 ALTER value SET STORAGE EXTERNAL"); | 294 | "ALTER TABLE gn090 ALTER value SET STORAGE EXTERNAL"); |
296 | if (GNUNET_OK != | 295 | if (GNUNET_OK != |
297 | check_result (plugin, | 296 | check_result (plugin, |
298 | ret, PGRES_COMMAND_OK, | 297 | ret, PGRES_COMMAND_OK, |
299 | "ALTER TABLE", "gn080", __LINE__)) | 298 | "ALTER TABLE", "gn090", __LINE__)) |
300 | { | 299 | { |
301 | PQfinish (plugin->dbh); | 300 | PQfinish (plugin->dbh); |
302 | plugin->dbh = NULL; | 301 | plugin->dbh = NULL; |
@@ -304,11 +303,11 @@ init_connection (struct Plugin *plugin) | |||
304 | } | 303 | } |
305 | PQclear (ret); | 304 | PQclear (ret); |
306 | ret = PQexec (plugin->dbh, | 305 | ret = PQexec (plugin->dbh, |
307 | "ALTER TABLE gn080 ALTER hash SET STORAGE PLAIN"); | 306 | "ALTER TABLE gn090 ALTER hash SET STORAGE PLAIN"); |
308 | if (GNUNET_OK != | 307 | if (GNUNET_OK != |
309 | check_result (plugin, | 308 | check_result (plugin, |
310 | ret, PGRES_COMMAND_OK, | 309 | ret, PGRES_COMMAND_OK, |
311 | "ALTER TABLE", "gn080", __LINE__)) | 310 | "ALTER TABLE", "gn090", __LINE__)) |
312 | { | 311 | { |
313 | PQfinish (plugin->dbh); | 312 | PQfinish (plugin->dbh); |
314 | plugin->dbh = NULL; | 313 | plugin->dbh = NULL; |
@@ -316,10 +315,10 @@ init_connection (struct Plugin *plugin) | |||
316 | } | 315 | } |
317 | PQclear (ret); | 316 | PQclear (ret); |
318 | ret = PQexec (plugin->dbh, | 317 | ret = PQexec (plugin->dbh, |
319 | "ALTER TABLE gn080 ALTER vhash SET STORAGE PLAIN"); | 318 | "ALTER TABLE gn090 ALTER vhash SET STORAGE PLAIN"); |
320 | if (GNUNET_OK != | 319 | if (GNUNET_OK != |
321 | check_result (plugin, | 320 | check_result (plugin, |
322 | ret, PGRES_COMMAND_OK, "ALTER TABLE", "gn080", __LINE__)) | 321 | ret, PGRES_COMMAND_OK, "ALTER TABLE", "gn090", __LINE__)) |
323 | { | 322 | { |
324 | PQfinish (plugin->dbh); | 323 | PQfinish (plugin->dbh); |
325 | plugin->dbh = NULL; | 324 | plugin->dbh = NULL; |
@@ -330,7 +329,7 @@ init_connection (struct Plugin *plugin) | |||
330 | if ((GNUNET_OK != | 329 | if ((GNUNET_OK != |
331 | pq_prepare (plugin, | 330 | pq_prepare (plugin, |
332 | "getvt", | 331 | "getvt", |
333 | "SELECT size, type, prio, anonLevel, expire, hash, value, oid FROM gn080 " | 332 | "SELECT type, prio, anonLevel, expire, hash, value, oid FROM gn090 " |
334 | "WHERE hash=$1 AND vhash=$2 AND type=$3 " | 333 | "WHERE hash=$1 AND vhash=$2 AND type=$3 " |
335 | "AND oid > $4 ORDER BY oid ASC LIMIT 1 OFFSET $5", | 334 | "AND oid > $4 ORDER BY oid ASC LIMIT 1 OFFSET $5", |
336 | 5, | 335 | 5, |
@@ -338,7 +337,7 @@ init_connection (struct Plugin *plugin) | |||
338 | (GNUNET_OK != | 337 | (GNUNET_OK != |
339 | pq_prepare (plugin, | 338 | pq_prepare (plugin, |
340 | "gett", | 339 | "gett", |
341 | "SELECT size, type, prio, anonLevel, expire, hash, value, oid FROM gn080 " | 340 | "SELECT type, prio, anonLevel, expire, hash, value, oid FROM gn090 " |
342 | "WHERE hash=$1 AND type=$2" | 341 | "WHERE hash=$1 AND type=$2" |
343 | "AND oid > $3 ORDER BY oid ASC LIMIT 1 OFFSET $4", | 342 | "AND oid > $3 ORDER BY oid ASC LIMIT 1 OFFSET $4", |
344 | 4, | 343 | 4, |
@@ -346,7 +345,7 @@ init_connection (struct Plugin *plugin) | |||
346 | (GNUNET_OK != | 345 | (GNUNET_OK != |
347 | pq_prepare (plugin, | 346 | pq_prepare (plugin, |
348 | "getv", | 347 | "getv", |
349 | "SELECT size, type, prio, anonLevel, expire, hash, value, oid FROM gn080 " | 348 | "SELECT type, prio, anonLevel, expire, hash, value, oid FROM gn090 " |
350 | "WHERE hash=$1 AND vhash=$2" | 349 | "WHERE hash=$1 AND vhash=$2" |
351 | "AND oid > $3 ORDER BY oid ASC LIMIT 1 OFFSET $4", | 350 | "AND oid > $3 ORDER BY oid ASC LIMIT 1 OFFSET $4", |
352 | 4, | 351 | 4, |
@@ -354,7 +353,7 @@ init_connection (struct Plugin *plugin) | |||
354 | (GNUNET_OK != | 353 | (GNUNET_OK != |
355 | pq_prepare (plugin, | 354 | pq_prepare (plugin, |
356 | "get", | 355 | "get", |
357 | "SELECT size, type, prio, anonLevel, expire, hash, value, oid FROM gn080 " | 356 | "SELECT type, prio, anonLevel, expire, hash, value, oid FROM gn090 " |
358 | "WHERE hash=$1" | 357 | "WHERE hash=$1" |
359 | "AND oid > $2 ORDER BY oid ASC LIMIT 1 OFFSET $3", | 358 | "AND oid > $2 ORDER BY oid ASC LIMIT 1 OFFSET $3", |
360 | 3, | 359 | 3, |
@@ -362,14 +361,14 @@ init_connection (struct Plugin *plugin) | |||
362 | (GNUNET_OK != | 361 | (GNUNET_OK != |
363 | pq_prepare (plugin, | 362 | pq_prepare (plugin, |
364 | "put", | 363 | "put", |
365 | "INSERT INTO gn080 (size, type, prio, anonLevel, expire, hash, vhash, value) " | 364 | "INSERT INTO gn090 (type, prio, anonLevel, expire, hash, vhash, value) " |
366 | "VALUES ($1, $2, $3, $4, $5, $6, $7, $8)", | 365 | "VALUES ($1, $2, $3, $4, $5, $6, $7)", |
367 | 8, | 366 | 8, |
368 | __LINE__)) || | 367 | __LINE__)) || |
369 | (GNUNET_OK != | 368 | (GNUNET_OK != |
370 | pq_prepare (plugin, | 369 | pq_prepare (plugin, |
371 | "update", | 370 | "update", |
372 | "UPDATE gn080 SET prio = prio + $1, expire = CASE WHEN expire < $2 THEN $2 ELSE expire END " | 371 | "UPDATE gn090 SET prio = prio + $1, expire = CASE WHEN expire < $2 THEN $2 ELSE expire END " |
373 | "WHERE oid = $3", | 372 | "WHERE oid = $3", |
374 | 3, | 373 | 3, |
375 | __LINE__)) || | 374 | __LINE__)) || |
@@ -400,7 +399,7 @@ init_connection (struct Plugin *plugin) | |||
400 | (GNUNET_OK != | 399 | (GNUNET_OK != |
401 | pq_prepare (plugin, | 400 | pq_prepare (plugin, |
402 | "delrow", | 401 | "delrow", |
403 | "DELETE FROM gn080 " "WHERE oid=$1", 1, __LINE__))) | 402 | "DELETE FROM gn090 " "WHERE oid=$1", 1, __LINE__))) |
404 | { | 403 | { |
405 | PQfinish (plugin->dbh); | 404 | PQfinish (plugin->dbh); |
406 | plugin->dbh = NULL; | 405 | plugin->dbh = NULL; |
@@ -487,13 +486,11 @@ postgres_plugin_put (void *cls, | |||
487 | struct Plugin *plugin = cls; | 486 | struct Plugin *plugin = cls; |
488 | GNUNET_HashCode vhash; | 487 | GNUNET_HashCode vhash; |
489 | PGresult *ret; | 488 | PGresult *ret; |
490 | uint32_t bsize = htonl (size); | ||
491 | uint32_t btype = htonl (type); | 489 | uint32_t btype = htonl (type); |
492 | uint32_t bprio = htonl (priority); | 490 | uint32_t bprio = htonl (priority); |
493 | uint32_t banon = htonl (anonymity); | 491 | uint32_t banon = htonl (anonymity); |
494 | uint64_t bexpi = GNUNET_TIME_absolute_hton (expiration).value__; | 492 | uint64_t bexpi = GNUNET_TIME_absolute_hton (expiration).value__; |
495 | const char *paramValues[] = { | 493 | const char *paramValues[] = { |
496 | (const char *) &bsize, | ||
497 | (const char *) &btype, | 494 | (const char *) &btype, |
498 | (const char *) &bprio, | 495 | (const char *) &bprio, |
499 | (const char *) &banon, | 496 | (const char *) &banon, |
@@ -503,7 +500,6 @@ postgres_plugin_put (void *cls, | |||
503 | (const char *) data | 500 | (const char *) data |
504 | }; | 501 | }; |
505 | int paramLengths[] = { | 502 | int paramLengths[] = { |
506 | sizeof (bsize), | ||
507 | sizeof (btype), | 503 | sizeof (btype), |
508 | sizeof (bprio), | 504 | sizeof (bprio), |
509 | sizeof (banon), | 505 | sizeof (banon), |
@@ -512,11 +508,11 @@ postgres_plugin_put (void *cls, | |||
512 | sizeof (GNUNET_HashCode), | 508 | sizeof (GNUNET_HashCode), |
513 | size | 509 | size |
514 | }; | 510 | }; |
515 | const int paramFormats[] = { 1, 1, 1, 1, 1, 1, 1, 1 }; | 511 | const int paramFormats[] = { 1, 1, 1, 1, 1, 1, 1 }; |
516 | 512 | ||
517 | GNUNET_CRYPTO_hash (data, size, &vhash); | 513 | GNUNET_CRYPTO_hash (data, size, &vhash); |
518 | ret = PQexecPrepared (plugin->dbh, | 514 | ret = PQexecPrepared (plugin->dbh, |
519 | "put", 8, paramValues, paramLengths, paramFormats, 1); | 515 | "put", 7, paramValues, paramLengths, paramFormats, 1); |
520 | if (GNUNET_OK != check_result (plugin, ret, | 516 | if (GNUNET_OK != check_result (plugin, ret, |
521 | PGRES_COMMAND_OK, | 517 | PGRES_COMMAND_OK, |
522 | "PQexecPrepared", "put", __LINE__)) | 518 | "PQexecPrepared", "put", __LINE__)) |
@@ -624,7 +620,7 @@ postgres_next_request_cont (void *next_cls, | |||
624 | return; | 620 | return; |
625 | } | 621 | } |
626 | if ((1 != PQntuples (res)) || | 622 | if ((1 != PQntuples (res)) || |
627 | (8 != PQnfields (res)) || | 623 | (7 != PQnfields (res)) || |
628 | (sizeof (uint32_t) != PQfsize (res, 0)) || | 624 | (sizeof (uint32_t) != PQfsize (res, 0)) || |
629 | (sizeof (uint32_t) != PQfsize (res, 7))) | 625 | (sizeof (uint32_t) != PQfsize (res, 7))) |
630 | { | 626 | { |
@@ -636,14 +632,13 @@ postgres_next_request_cont (void *next_cls, | |||
636 | GNUNET_free (nrc); | 632 | GNUNET_free (nrc); |
637 | return; | 633 | return; |
638 | } | 634 | } |
639 | rowid = ntohl (*(uint32_t *) PQgetvalue (res, 0, 7)); | 635 | rowid = ntohl (*(uint32_t *) PQgetvalue (res, 0, 6)); |
640 | size = ntohl (*(uint32_t *) PQgetvalue (res, 0, 0)); | 636 | if ((sizeof (uint32_t) != PQfsize (res, 0)) || |
641 | if ((sizeof (uint32_t) != PQfsize (res, 1)) || | 637 | (sizeof (uint32_t) != PQfsize (res, 1)) || |
642 | (sizeof (uint32_t) != PQfsize (res, 2)) || | 638 | (sizeof (uint32_t) != PQfsize (res, 2)) || |
643 | (sizeof (uint32_t) != PQfsize (res, 3)) || | 639 | (sizeof (uint64_t) != PQfsize (res, 3)) || |
644 | (sizeof (uint64_t) != PQfsize (res, 4)) || | 640 | (sizeof (GNUNET_HashCode) != PQgetlength (res, 0, 4)) || |
645 | (sizeof (GNUNET_HashCode) != PQgetlength (res, 0, 5)) || | 641 | (size != PQgetlength (res, 0, 5))) |
646 | (size != PQgetlength (res, 0, 6))) | ||
647 | { | 642 | { |
648 | GNUNET_break (0); | 643 | GNUNET_break (0); |
649 | PQclear (res); | 644 | PQclear (res); |
@@ -655,12 +650,12 @@ postgres_next_request_cont (void *next_cls, | |||
655 | return; | 650 | return; |
656 | } | 651 | } |
657 | 652 | ||
658 | type = ntohl (*(uint32_t *) PQgetvalue (res, 0, 1)); | 653 | type = ntohl (*(uint32_t *) PQgetvalue (res, 0, 0)); |
659 | priority = ntohl (*(uint32_t *) PQgetvalue (res, 0, 2)); | 654 | priority = ntohl (*(uint32_t *) PQgetvalue (res, 0, 1)); |
660 | anonymity = ntohl ( *(uint32_t *) PQgetvalue (res, 0, 3)); | 655 | anonymity = ntohl ( *(uint32_t *) PQgetvalue (res, 0, 2)); |
661 | expiration_time.value = GNUNET_ntohll (*(uint64_t *) PQgetvalue (res, 0, 4)); | 656 | expiration_time.value = GNUNET_ntohll (*(uint64_t *) PQgetvalue (res, 0, 3)); |
662 | size = PQgetlength (res, 0, 6); | 657 | memcpy (&key, PQgetvalue (res, 0, 4), sizeof (GNUNET_HashCode)); |
663 | memcpy (&key, PQgetvalue (res, 0, 5), sizeof (GNUNET_HashCode)); | 658 | size = PQgetlength (res, 0, 5); |
664 | 659 | ||
665 | nrc->blast_prio = htonl (priority); | 660 | nrc->blast_prio = htonl (priority); |
666 | nrc->blast_expire = GNUNET_htonll (expiration_time.value); | 661 | nrc->blast_expire = GNUNET_htonll (expiration_time.value); |
@@ -678,7 +673,7 @@ postgres_next_request_cont (void *next_cls, | |||
678 | nrc, | 673 | nrc, |
679 | &key, | 674 | &key, |
680 | size, | 675 | size, |
681 | PQgetvalue (res, 0, 6), | 676 | PQgetvalue (res, 0, 5), |
682 | (enum GNUNET_BLOCK_Type) type, | 677 | (enum GNUNET_BLOCK_Type) type, |
683 | priority, | 678 | priority, |
684 | anonymity, | 679 | anonymity, |
@@ -977,7 +972,7 @@ postgres_plugin_get (void *cls, | |||
977 | nrc->nparams = 5; | 972 | nrc->nparams = 5; |
978 | nrc->pname = "getvt"; | 973 | nrc->pname = "getvt"; |
979 | ret = PQexecParams (plugin->dbh, | 974 | ret = PQexecParams (plugin->dbh, |
980 | "SELECT count(*) FROM gn080 WHERE hash=$1 AND vhash=$2 AND type=$3", | 975 | "SELECT count(*) FROM gn090 WHERE hash=$1 AND vhash=$2 AND type=$3", |
981 | 3, | 976 | 3, |
982 | NULL, | 977 | NULL, |
983 | nrc->paramValues, | 978 | nrc->paramValues, |
@@ -995,7 +990,7 @@ postgres_plugin_get (void *cls, | |||
995 | nrc->nparams = 4; | 990 | nrc->nparams = 4; |
996 | nrc->pname = "gett"; | 991 | nrc->pname = "gett"; |
997 | ret = PQexecParams (plugin->dbh, | 992 | ret = PQexecParams (plugin->dbh, |
998 | "SELECT count(*) FROM gn080 WHERE hash=$1 AND type=$2", | 993 | "SELECT count(*) FROM gn090 WHERE hash=$1 AND type=$2", |
999 | 2, | 994 | 2, |
1000 | NULL, | 995 | NULL, |
1001 | nrc->paramValues, | 996 | nrc->paramValues, |
@@ -1016,7 +1011,7 @@ postgres_plugin_get (void *cls, | |||
1016 | nrc->nparams = 4; | 1011 | nrc->nparams = 4; |
1017 | nrc->pname = "getv"; | 1012 | nrc->pname = "getv"; |
1018 | ret = PQexecParams (plugin->dbh, | 1013 | ret = PQexecParams (plugin->dbh, |
1019 | "SELECT count(*) FROM gn080 WHERE hash=$1 AND vhash=$2", | 1014 | "SELECT count(*) FROM gn090 WHERE hash=$1 AND vhash=$2", |
1020 | 2, | 1015 | 2, |
1021 | NULL, | 1016 | NULL, |
1022 | nrc->paramValues, | 1017 | nrc->paramValues, |
@@ -1032,7 +1027,7 @@ postgres_plugin_get (void *cls, | |||
1032 | nrc->nparams = 3; | 1027 | nrc->nparams = 3; |
1033 | nrc->pname = "get"; | 1028 | nrc->pname = "get"; |
1034 | ret = PQexecParams (plugin->dbh, | 1029 | ret = PQexecParams (plugin->dbh, |
1035 | "SELECT count(*) FROM gn080 WHERE hash=$1", | 1030 | "SELECT count(*) FROM gn090 WHERE hash=$1", |
1036 | 1, | 1031 | 1, |
1037 | NULL, | 1032 | NULL, |
1038 | nrc->paramValues, | 1033 | nrc->paramValues, |
@@ -1187,7 +1182,7 @@ postgres_plugin_drop (void *cls) | |||
1187 | { | 1182 | { |
1188 | struct Plugin *plugin = cls; | 1183 | struct Plugin *plugin = cls; |
1189 | 1184 | ||
1190 | pq_exec (plugin, "DROP TABLE gn080", __LINE__); | 1185 | pq_exec (plugin, "DROP TABLE gn090", __LINE__); |
1191 | } | 1186 | } |
1192 | 1187 | ||
1193 | 1188 | ||