diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-03-14 22:40:04 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-03-14 22:40:04 +0000 |
commit | 4c1791f13283df27338cd877e2087d519aaab05e (patch) | |
tree | b852de95aa307225befc78c54624811f3a79e344 /src/datastore | |
parent | 165f050555ce4f06380cc26c1dc09235c7b135e6 (diff) | |
download | gnunet-4c1791f13283df27338cd877e2087d519aaab05e.tar.gz gnunet-4c1791f13283df27338cd877e2087d519aaab05e.zip |
-bugfix, adding comments, fixing indent
Diffstat (limited to 'src/datastore')
-rw-r--r-- | src/datastore/gnunet-service-datastore.c | 141 | ||||
-rw-r--r-- | src/datastore/plugin_datastore_postgres.c | 204 | ||||
-rw-r--r-- | src/datastore/test_datastore_api.c | 22 |
3 files changed, 205 insertions, 162 deletions
diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c index ba8baf719..4979f4482 100644 --- a/src/datastore/gnunet-service-datastore.c +++ b/src/datastore/gnunet-service-datastore.c | |||
@@ -681,7 +681,8 @@ handle_reserve (void *cls, struct GNUNET_SERVER_Client *client, | |||
681 | uint64_t amount; | 681 | uint64_t amount; |
682 | uint32_t entries; | 682 | uint32_t entries; |
683 | 683 | ||
684 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' request\n", "RESERVE"); | 684 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
685 | "Processing RESERVE request\n"); | ||
685 | amount = GNUNET_ntohll (msg->amount); | 686 | amount = GNUNET_ntohll (msg->amount); |
686 | entries = ntohl (msg->entries); | 687 | entries = ntohl (msg->entries); |
687 | used = payload + reserved; | 688 | used = payload + reserved; |
@@ -757,8 +758,7 @@ handle_release_reserve (void *cls, | |||
757 | unsigned long long rem; | 758 | unsigned long long rem; |
758 | 759 | ||
759 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 760 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
760 | "Processing `%s' request\n", | 761 | "Processing RELEASE_RESERVE request\n"); |
761 | "RELEASE_RESERVE"); | ||
762 | next = reservations; | 762 | next = reservations; |
763 | prev = NULL; | 763 | prev = NULL; |
764 | while (NULL != (pos = next)) | 764 | while (NULL != (pos = next)) |
@@ -905,6 +905,12 @@ execute_put (struct PutContext *pc) | |||
905 | } | 905 | } |
906 | 906 | ||
907 | 907 | ||
908 | /** | ||
909 | * | ||
910 | * @param cls closure | ||
911 | * @param status #GNUNET_OK or #GNUNET_SYSERR | ||
912 | * @param msg error message on error | ||
913 | */ | ||
908 | static void | 914 | static void |
909 | check_present_continuation (void *cls, | 915 | check_present_continuation (void *cls, |
910 | int status, | 916 | int status, |
@@ -954,10 +960,10 @@ check_present (void *cls, | |||
954 | execute_put (pc); | 960 | execute_put (pc); |
955 | return GNUNET_OK; | 961 | return GNUNET_OK; |
956 | } | 962 | } |
957 | if ((GNUNET_BLOCK_TYPE_FS_DBLOCK == type) || | 963 | if ( (GNUNET_BLOCK_TYPE_FS_DBLOCK == type) || |
958 | (GNUNET_BLOCK_TYPE_FS_IBLOCK == type) || ((size == ntohl (dm->size)) && | 964 | (GNUNET_BLOCK_TYPE_FS_IBLOCK == type) || |
959 | (0 == | 965 | ( (size == ntohl (dm->size)) && |
960 | memcmp (&dm[1], data, size)))) | 966 | (0 == memcmp (&dm[1], data, size)) ) ) |
961 | { | 967 | { |
962 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 968 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
963 | "Result already present in datastore\n"); | 969 | "Result already present in datastore\n"); |
@@ -994,7 +1000,8 @@ check_present (void *cls, | |||
994 | * @param message the actual message | 1000 | * @param message the actual message |
995 | */ | 1001 | */ |
996 | static void | 1002 | static void |
997 | handle_put (void *cls, struct GNUNET_SERVER_Client *client, | 1003 | handle_put (void *cls, |
1004 | struct GNUNET_SERVER_Client *client, | ||
998 | const struct GNUNET_MessageHeader *message) | 1005 | const struct GNUNET_MessageHeader *message) |
999 | { | 1006 | { |
1000 | const struct DataMessage *dm = check_data (message); | 1007 | const struct DataMessage *dm = check_data (message); |
@@ -1011,8 +1018,9 @@ handle_put (void *cls, struct GNUNET_SERVER_Client *client, | |||
1011 | return; | 1018 | return; |
1012 | } | 1019 | } |
1013 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1020 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1014 | "Processing `%s' request for `%s' of type %u\n", "PUT", | 1021 | "Processing PUT request for `%s' of type %u\n", |
1015 | GNUNET_h2s (&dm->key), ntohl (dm->type)); | 1022 | GNUNET_h2s (&dm->key), |
1023 | ntohl (dm->type)); | ||
1016 | rid = ntohl (dm->rid); | 1024 | rid = ntohl (dm->rid); |
1017 | size = ntohl (dm->size); | 1025 | size = ntohl (dm->size); |
1018 | if (rid > 0) | 1026 | if (rid > 0) |
@@ -1063,7 +1071,8 @@ handle_put (void *cls, struct GNUNET_SERVER_Client *client, | |||
1063 | * @param message the actual message | 1071 | * @param message the actual message |
1064 | */ | 1072 | */ |
1065 | static void | 1073 | static void |
1066 | handle_get (void *cls, struct GNUNET_SERVER_Client *client, | 1074 | handle_get (void *cls, |
1075 | struct GNUNET_SERVER_Client *client, | ||
1067 | const struct GNUNET_MessageHeader *message) | 1076 | const struct GNUNET_MessageHeader *message) |
1068 | { | 1077 | { |
1069 | const struct GetMessage *msg; | 1078 | const struct GetMessage *msg; |
@@ -1079,20 +1088,21 @@ handle_get (void *cls, struct GNUNET_SERVER_Client *client, | |||
1079 | } | 1088 | } |
1080 | msg = (const struct GetMessage *) message; | 1089 | msg = (const struct GetMessage *) message; |
1081 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1090 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1082 | "Processing `%s' request for `%s' of type %u\n", "GET", | 1091 | "Processing GET request for `%s' of type %u\n", |
1083 | GNUNET_h2s (&msg->key), ntohl (msg->type)); | 1092 | GNUNET_h2s (&msg->key), |
1093 | ntohl (msg->type)); | ||
1084 | GNUNET_STATISTICS_update (stats, | 1094 | GNUNET_STATISTICS_update (stats, |
1085 | gettext_noop ("# GET requests received"), | 1095 | gettext_noop ("# GET requests received"), |
1086 | 1, | 1096 | 1, |
1087 | GNUNET_NO); | 1097 | GNUNET_NO); |
1088 | GNUNET_SERVER_client_keep (client); | 1098 | GNUNET_SERVER_client_keep (client); |
1089 | if ((size == sizeof (struct GetMessage)) && | 1099 | if ( (size == sizeof (struct GetMessage)) && |
1090 | (GNUNET_YES != GNUNET_CONTAINER_bloomfilter_test (filter, &msg->key))) | 1100 | (GNUNET_YES != GNUNET_CONTAINER_bloomfilter_test (filter, &msg->key)) ) |
1091 | { | 1101 | { |
1092 | /* don't bother database... */ | 1102 | /* don't bother database... */ |
1093 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1103 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1094 | "Empty result set for `%s' request for `%s' (bloomfilter).\n", | 1104 | "Empty result set for GET request for `%s' (bloomfilter).\n", |
1095 | "GET", GNUNET_h2s (&msg->key)); | 1105 | GNUNET_h2s (&msg->key)); |
1096 | GNUNET_STATISTICS_update (stats, | 1106 | GNUNET_STATISTICS_update (stats, |
1097 | gettext_noop | 1107 | gettext_noop |
1098 | ("# requests filtered by bloomfilter"), | 1108 | ("# requests filtered by bloomfilter"), |
@@ -1109,6 +1119,13 @@ handle_get (void *cls, struct GNUNET_SERVER_Client *client, | |||
1109 | } | 1119 | } |
1110 | 1120 | ||
1111 | 1121 | ||
1122 | /** | ||
1123 | * Function called with the result of an update operation. | ||
1124 | * | ||
1125 | * @param cls closure | ||
1126 | * @param status #GNUNET_OK or #GNUNET_SYSERR | ||
1127 | * @param msg error message on error | ||
1128 | */ | ||
1112 | static void | 1129 | static void |
1113 | update_continuation (void *cls, | 1130 | update_continuation (void *cls, |
1114 | int status, | 1131 | int status, |
@@ -1129,7 +1146,8 @@ update_continuation (void *cls, | |||
1129 | * @param message the actual message | 1146 | * @param message the actual message |
1130 | */ | 1147 | */ |
1131 | static void | 1148 | static void |
1132 | handle_update (void *cls, struct GNUNET_SERVER_Client *client, | 1149 | handle_update (void *cls, |
1150 | struct GNUNET_SERVER_Client *client, | ||
1133 | const struct GNUNET_MessageHeader *message) | 1151 | const struct GNUNET_MessageHeader *message) |
1134 | { | 1152 | { |
1135 | const struct UpdateMessage *msg; | 1153 | const struct UpdateMessage *msg; |
@@ -1139,13 +1157,15 @@ handle_update (void *cls, struct GNUNET_SERVER_Client *client, | |||
1139 | 1, | 1157 | 1, |
1140 | GNUNET_NO); | 1158 | GNUNET_NO); |
1141 | msg = (const struct UpdateMessage *) message; | 1159 | msg = (const struct UpdateMessage *) message; |
1142 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' request for %llu\n", | 1160 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1143 | "UPDATE", (unsigned long long) GNUNET_ntohll (msg->uid)); | 1161 | "Processing UPDATE request for %llu\n", |
1162 | (unsigned long long) GNUNET_ntohll (msg->uid)); | ||
1144 | GNUNET_SERVER_client_keep (client); | 1163 | GNUNET_SERVER_client_keep (client); |
1145 | plugin->api->update (plugin->api->cls, GNUNET_ntohll (msg->uid), | 1164 | plugin->api->update (plugin->api->cls, |
1165 | GNUNET_ntohll (msg->uid), | ||
1146 | (int32_t) ntohl (msg->priority), | 1166 | (int32_t) ntohl (msg->priority), |
1147 | GNUNET_TIME_absolute_ntoh (msg->expiration), | 1167 | GNUNET_TIME_absolute_ntoh (msg->expiration), |
1148 | update_continuation, client); | 1168 | &update_continuation, client); |
1149 | } | 1169 | } |
1150 | 1170 | ||
1151 | 1171 | ||
@@ -1157,7 +1177,8 @@ handle_update (void *cls, struct GNUNET_SERVER_Client *client, | |||
1157 | * @param message the actual message | 1177 | * @param message the actual message |
1158 | */ | 1178 | */ |
1159 | static void | 1179 | static void |
1160 | handle_get_replication (void *cls, struct GNUNET_SERVER_Client *client, | 1180 | handle_get_replication (void *cls, |
1181 | struct GNUNET_SERVER_Client *client, | ||
1161 | const struct GNUNET_MessageHeader *message) | 1182 | const struct GNUNET_MessageHeader *message) |
1162 | { | 1183 | { |
1163 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1184 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1168,7 +1189,8 @@ handle_get_replication (void *cls, struct GNUNET_SERVER_Client *client, | |||
1168 | 1, | 1189 | 1, |
1169 | GNUNET_NO); | 1190 | GNUNET_NO); |
1170 | GNUNET_SERVER_client_keep (client); | 1191 | GNUNET_SERVER_client_keep (client); |
1171 | plugin->api->get_replication (plugin->api->cls, &transmit_item, client); | 1192 | plugin->api->get_replication (plugin->api->cls, |
1193 | &transmit_item, client); | ||
1172 | } | 1194 | } |
1173 | 1195 | ||
1174 | 1196 | ||
@@ -1180,7 +1202,8 @@ handle_get_replication (void *cls, struct GNUNET_SERVER_Client *client, | |||
1180 | * @param message the actual message | 1202 | * @param message the actual message |
1181 | */ | 1203 | */ |
1182 | static void | 1204 | static void |
1183 | handle_get_zero_anonymity (void *cls, struct GNUNET_SERVER_Client *client, | 1205 | handle_get_zero_anonymity (void *cls, |
1206 | struct GNUNET_SERVER_Client *client, | ||
1184 | const struct GNUNET_MessageHeader *message) | 1207 | const struct GNUNET_MessageHeader *message) |
1185 | { | 1208 | { |
1186 | const struct GetZeroAnonymityMessage *msg = | 1209 | const struct GetZeroAnonymityMessage *msg = |
@@ -1203,28 +1226,45 @@ handle_get_zero_anonymity (void *cls, struct GNUNET_SERVER_Client *client, | |||
1203 | GNUNET_NO); | 1226 | GNUNET_NO); |
1204 | GNUNET_SERVER_client_keep (client); | 1227 | GNUNET_SERVER_client_keep (client); |
1205 | plugin->api->get_zero_anonymity (plugin->api->cls, | 1228 | plugin->api->get_zero_anonymity (plugin->api->cls, |
1206 | GNUNET_ntohll (msg->offset), type, | 1229 | GNUNET_ntohll (msg->offset), |
1230 | type, | ||
1207 | &transmit_item, client); | 1231 | &transmit_item, client); |
1208 | } | 1232 | } |
1209 | 1233 | ||
1210 | 1234 | ||
1211 | /** | 1235 | /** |
1212 | * Callback function that will cause the item that is passed | 1236 | * Callback function that will cause the item that is passed |
1213 | * in to be deleted (by returning GNUNET_NO). | 1237 | * in to be deleted (by returning #GNUNET_NO). |
1238 | * | ||
1239 | * @param cls closure | ||
1240 | * @param key key for the content | ||
1241 | * @param size number of bytes in data | ||
1242 | * @param data content stored | ||
1243 | * @param type type of the content | ||
1244 | * @param priority priority of the content | ||
1245 | * @param anonymity anonymity-level for the content | ||
1246 | * @param expiration expiration time for the content | ||
1247 | * @param uid unique identifier for the datum | ||
1248 | * @return #GNUNET_OK to keep the item | ||
1249 | * #GNUNET_NO to delete the item | ||
1214 | */ | 1250 | */ |
1215 | static int | 1251 | static int |
1216 | remove_callback (void *cls, const struct GNUNET_HashCode * key, uint32_t size, | 1252 | remove_callback (void *cls, |
1217 | const void *data, enum GNUNET_BLOCK_Type type, | 1253 | const struct GNUNET_HashCode *key, |
1218 | uint32_t priority, uint32_t anonymity, | 1254 | uint32_t size, |
1219 | struct GNUNET_TIME_Absolute expiration, uint64_t uid) | 1255 | const void *data, |
1256 | enum GNUNET_BLOCK_Type type, | ||
1257 | uint32_t priority, | ||
1258 | uint32_t anonymity, | ||
1259 | struct GNUNET_TIME_Absolute expiration, | ||
1260 | uint64_t uid) | ||
1220 | { | 1261 | { |
1221 | struct GNUNET_SERVER_Client *client = cls; | 1262 | struct GNUNET_SERVER_Client *client = cls; |
1222 | 1263 | ||
1223 | if (key == NULL) | 1264 | if (NULL == key) |
1224 | { | 1265 | { |
1225 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1266 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1226 | "No further matches for `%s' request.\n", | 1267 | "No further matches for REMOVE request.\n"); |
1227 | "REMOVE"); | ||
1228 | transmit_status (client, | 1268 | transmit_status (client, |
1229 | GNUNET_NO, | 1269 | GNUNET_NO, |
1230 | _("Content not found")); | 1270 | _("Content not found")); |
@@ -1232,9 +1272,8 @@ remove_callback (void *cls, const struct GNUNET_HashCode * key, uint32_t size, | |||
1232 | return GNUNET_OK; /* last item */ | 1272 | return GNUNET_OK; /* last item */ |
1233 | } | 1273 | } |
1234 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1274 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1235 | "Item %llu matches `%s' request for key `%s' and type %u.\n", | 1275 | "Item %llu matches REMOVE request for key `%s' and type %u.\n", |
1236 | (unsigned long long) uid, | 1276 | (unsigned long long) uid, |
1237 | "REMOVE", | ||
1238 | GNUNET_h2s (key), | 1277 | GNUNET_h2s (key), |
1239 | type); | 1278 | type); |
1240 | GNUNET_STATISTICS_update (stats, | 1279 | GNUNET_STATISTICS_update (stats, |
@@ -1256,26 +1295,34 @@ remove_callback (void *cls, const struct GNUNET_HashCode * key, uint32_t size, | |||
1256 | * @param message the actual message | 1295 | * @param message the actual message |
1257 | */ | 1296 | */ |
1258 | static void | 1297 | static void |
1259 | handle_remove (void *cls, struct GNUNET_SERVER_Client *client, | 1298 | handle_remove (void *cls, |
1299 | struct GNUNET_SERVER_Client *client, | ||
1260 | const struct GNUNET_MessageHeader *message) | 1300 | const struct GNUNET_MessageHeader *message) |
1261 | { | 1301 | { |
1262 | const struct DataMessage *dm = check_data (message); | 1302 | const struct DataMessage *dm = check_data (message); |
1263 | struct GNUNET_HashCode vhash; | 1303 | struct GNUNET_HashCode vhash; |
1264 | 1304 | ||
1265 | if (dm == NULL) | 1305 | if (NULL == dm) |
1266 | { | 1306 | { |
1267 | GNUNET_break (0); | 1307 | GNUNET_break (0); |
1268 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1308 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
1269 | return; | 1309 | return; |
1270 | } | 1310 | } |
1271 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1311 | GNUNET_STATISTICS_update (stats, |
1272 | "Processing `%s' request for `%s' of type %u\n", "REMOVE", | 1312 | gettext_noop ("# REMOVE requests received"), |
1273 | GNUNET_h2s (&dm->key), ntohl (dm->type)); | ||
1274 | GNUNET_STATISTICS_update (stats, gettext_noop ("# REMOVE requests received"), | ||
1275 | 1, GNUNET_NO); | 1313 | 1, GNUNET_NO); |
1276 | GNUNET_SERVER_client_keep (client); | 1314 | GNUNET_SERVER_client_keep (client); |
1277 | GNUNET_CRYPTO_hash (&dm[1], ntohl (dm->size), &vhash); | 1315 | GNUNET_CRYPTO_hash (&dm[1], |
1278 | plugin->api->get_key (plugin->api->cls, 0, &dm->key, &vhash, | 1316 | ntohl (dm->size), |
1317 | &vhash); | ||
1318 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1319 | "Processing REMOVE request for `%s' of type %u\n", | ||
1320 | GNUNET_h2s (&dm->key), | ||
1321 | ntohl (dm->type)); | ||
1322 | plugin->api->get_key (plugin->api->cls, | ||
1323 | 0, | ||
1324 | &dm->key, | ||
1325 | &vhash, | ||
1279 | (enum GNUNET_BLOCK_Type) ntohl (dm->type), | 1326 | (enum GNUNET_BLOCK_Type) ntohl (dm->type), |
1280 | &remove_callback, client); | 1327 | &remove_callback, client); |
1281 | } | 1328 | } |
@@ -1289,12 +1336,12 @@ handle_remove (void *cls, struct GNUNET_SERVER_Client *client, | |||
1289 | * @param message the actual message | 1336 | * @param message the actual message |
1290 | */ | 1337 | */ |
1291 | static void | 1338 | static void |
1292 | handle_drop (void *cls, struct GNUNET_SERVER_Client *client, | 1339 | handle_drop (void *cls, |
1340 | struct GNUNET_SERVER_Client *client, | ||
1293 | const struct GNUNET_MessageHeader *message) | 1341 | const struct GNUNET_MessageHeader *message) |
1294 | { | 1342 | { |
1295 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1343 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1296 | "Processing `%s' request\n", | 1344 | "Processing DROP request\n"); |
1297 | "DROP"); | ||
1298 | do_drop = GNUNET_YES; | 1345 | do_drop = GNUNET_YES; |
1299 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1346 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
1300 | } | 1347 | } |
diff --git a/src/datastore/plugin_datastore_postgres.c b/src/datastore/plugin_datastore_postgres.c index 0c51e8b7d..faf988517 100644 --- a/src/datastore/plugin_datastore_postgres.c +++ b/src/datastore/plugin_datastore_postgres.c | |||
@@ -78,7 +78,7 @@ init_connection (struct Plugin *plugin) | |||
78 | 78 | ||
79 | ret = | 79 | ret = |
80 | PQexec (plugin->dbh, | 80 | PQexec (plugin->dbh, |
81 | "CREATE TABLE gn090 (" | 81 | "CREATE TABLE gn090 (" |
82 | " repl INTEGER NOT NULL DEFAULT 0," | 82 | " repl INTEGER NOT NULL DEFAULT 0," |
83 | " type INTEGER NOT NULL DEFAULT 0," | 83 | " type INTEGER NOT NULL DEFAULT 0," |
84 | " prio INTEGER NOT NULL DEFAULT 0," | 84 | " prio INTEGER NOT NULL DEFAULT 0," |
@@ -87,7 +87,7 @@ init_connection (struct Plugin *plugin) | |||
87 | " rvalue BIGINT NOT NULL DEFAULT 0," | 87 | " rvalue BIGINT NOT NULL DEFAULT 0," |
88 | " hash BYTEA NOT NULL DEFAULT ''," | 88 | " hash BYTEA NOT NULL DEFAULT ''," |
89 | " vhash BYTEA NOT NULL DEFAULT ''," | 89 | " vhash BYTEA NOT NULL DEFAULT ''," |
90 | " value BYTEA NOT NULL DEFAULT '')" | 90 | " value BYTEA NOT NULL DEFAULT '')" |
91 | "WITH OIDS"); | 91 | "WITH OIDS"); |
92 | if ( (NULL == ret) || | 92 | if ( (NULL == ret) || |
93 | ((PQresultStatus (ret) != PGRES_COMMAND_OK) && | 93 | ((PQresultStatus (ret) != PGRES_COMMAND_OK) && |
@@ -257,10 +257,10 @@ postgres_plugin_estimate_size (void *cls, unsigned long long *estimate) | |||
257 | "SELECT SUM(LENGTH(value))+256*COUNT(*) FROM gn090", 0, | 257 | "SELECT SUM(LENGTH(value))+256*COUNT(*) FROM gn090", 0, |
258 | NULL, NULL, NULL, NULL, 1); | 258 | NULL, NULL, NULL, NULL, 1); |
259 | if (GNUNET_OK != | 259 | if (GNUNET_OK != |
260 | GNUNET_POSTGRES_check_result (plugin->dbh, | 260 | GNUNET_POSTGRES_check_result (plugin->dbh, |
261 | ret, | 261 | ret, |
262 | PGRES_TUPLES_OK, | 262 | PGRES_TUPLES_OK, |
263 | "PQexecParams", | 263 | "PQexecParams", |
264 | "get_size")) | 264 | "get_size")) |
265 | { | 265 | { |
266 | *estimate = 0; | 266 | *estimate = 0; |
@@ -302,15 +302,15 @@ postgres_plugin_estimate_size (void *cls, unsigned long long *estimate) | |||
302 | * @param cont_cls continuation closure | 302 | * @param cont_cls continuation closure |
303 | */ | 303 | */ |
304 | static void | 304 | static void |
305 | postgres_plugin_put (void *cls, | 305 | postgres_plugin_put (void *cls, |
306 | const struct GNUNET_HashCode *key, | 306 | const struct GNUNET_HashCode *key, |
307 | uint32_t size, | 307 | uint32_t size, |
308 | const void *data, | 308 | const void *data, |
309 | enum GNUNET_BLOCK_Type type, | 309 | enum GNUNET_BLOCK_Type type, |
310 | uint32_t priority, | 310 | uint32_t priority, |
311 | uint32_t anonymity, | 311 | uint32_t anonymity, |
312 | uint32_t replication, | 312 | uint32_t replication, |
313 | struct GNUNET_TIME_Absolute expiration, | 313 | struct GNUNET_TIME_Absolute expiration, |
314 | PluginPutCont cont, | 314 | PluginPutCont cont, |
315 | void *cont_cls) | 315 | void *cont_cls) |
316 | { | 316 | { |
@@ -335,22 +335,22 @@ postgres_plugin_put (void *cls, | |||
335 | "put", | 335 | "put", |
336 | params); | 336 | params); |
337 | if (GNUNET_OK != | 337 | if (GNUNET_OK != |
338 | GNUNET_POSTGRES_check_result (plugin->dbh, | 338 | GNUNET_POSTGRES_check_result (plugin->dbh, |
339 | ret, | 339 | ret, |
340 | PGRES_COMMAND_OK, | 340 | PGRES_COMMAND_OK, |
341 | "PQexecPrepared", "put")) | 341 | "PQexecPrepared", "put")) |
342 | { | 342 | { |
343 | cont (cont_cls, key, size, | 343 | cont (cont_cls, key, size, |
344 | GNUNET_SYSERR, | 344 | GNUNET_SYSERR, |
345 | _("Postgress exec failure")); | 345 | _("Postgress exec failure")); |
346 | return; | 346 | return; |
347 | } | 347 | } |
348 | PQclear (ret); | 348 | PQclear (ret); |
349 | plugin->env->duc (plugin->env->cls, | 349 | plugin->env->duc (plugin->env->cls, |
350 | size + GNUNET_DATASTORE_ENTRY_OVERHEAD); | 350 | size + GNUNET_DATASTORE_ENTRY_OVERHEAD); |
351 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | 351 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, |
352 | "datastore-postgres", | 352 | "datastore-postgres", |
353 | "Stored %u bytes in database\n", | 353 | "Stored %u bytes in database\n", |
354 | (unsigned int) size); | 354 | (unsigned int) size); |
355 | cont (cont_cls, key, size, GNUNET_OK, NULL); | 355 | cont (cont_cls, key, size, GNUNET_OK, NULL); |
356 | } | 356 | } |
@@ -367,7 +367,7 @@ postgres_plugin_put (void *cls, | |||
367 | * @param line line number for error messages | 367 | * @param line line number for error messages |
368 | */ | 368 | */ |
369 | static void | 369 | static void |
370 | process_result (struct Plugin *plugin, | 370 | process_result (struct Plugin *plugin, |
371 | PluginDatumProcessor proc, | 371 | PluginDatumProcessor proc, |
372 | void *proc_cls, | 372 | void *proc_cls, |
373 | PGresult * res, | 373 | PGresult * res, |
@@ -394,9 +394,9 @@ process_result (struct Plugin *plugin, | |||
394 | }; | 394 | }; |
395 | 395 | ||
396 | if (GNUNET_OK != | 396 | if (GNUNET_OK != |
397 | GNUNET_POSTGRES_check_result_ (plugin->dbh, | 397 | GNUNET_POSTGRES_check_result_ (plugin->dbh, |
398 | res, | 398 | res, |
399 | PGRES_TUPLES_OK, | 399 | PGRES_TUPLES_OK, |
400 | "PQexecPrepared", | 400 | "PQexecPrepared", |
401 | "select", | 401 | "select", |
402 | filename, line)) | 402 | filename, line)) |
@@ -404,7 +404,7 @@ process_result (struct Plugin *plugin, | |||
404 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | 404 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, |
405 | "datastore-postgres", | 405 | "datastore-postgres", |
406 | "Ending iteration (postgres error)\n"); | 406 | "Ending iteration (postgres error)\n"); |
407 | proc (proc_cls, NULL, 0, NULL, 0, 0, 0, | 407 | proc (proc_cls, NULL, 0, NULL, 0, 0, 0, |
408 | GNUNET_TIME_UNIT_ZERO_ABS, 0); | 408 | GNUNET_TIME_UNIT_ZERO_ABS, 0); |
409 | return; | 409 | return; |
410 | } | 410 | } |
@@ -412,15 +412,15 @@ process_result (struct Plugin *plugin, | |||
412 | if (0 == PQntuples (res)) | 412 | if (0 == PQntuples (res)) |
413 | { | 413 | { |
414 | /* no result */ | 414 | /* no result */ |
415 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | 415 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, |
416 | "datastore-postgres", | 416 | "datastore-postgres", |
417 | "Ending iteration (no more results)\n"); | 417 | "Ending iteration (no more results)\n"); |
418 | proc (proc_cls, NULL, 0, NULL, 0, 0, 0, | 418 | proc (proc_cls, NULL, 0, NULL, 0, 0, 0, |
419 | GNUNET_TIME_UNIT_ZERO_ABS, 0); | 419 | GNUNET_TIME_UNIT_ZERO_ABS, 0); |
420 | PQclear (res); | 420 | PQclear (res); |
421 | return; | 421 | return; |
422 | } | 422 | } |
423 | if (1 != PQntuples (res)) | 423 | if (1 != PQntuples (res)) |
424 | { | 424 | { |
425 | GNUNET_break (0); | 425 | GNUNET_break (0); |
426 | proc (proc_cls, NULL, 0, NULL, 0, 0, 0, | 426 | proc (proc_cls, NULL, 0, NULL, 0, 0, 0, |
@@ -436,23 +436,23 @@ process_result (struct Plugin *plugin, | |||
436 | GNUNET_break (0); | 436 | GNUNET_break (0); |
437 | PQclear (res); | 437 | PQclear (res); |
438 | GNUNET_POSTGRES_delete_by_rowid (plugin->dbh, | 438 | GNUNET_POSTGRES_delete_by_rowid (plugin->dbh, |
439 | "delrow", | 439 | "delrow", |
440 | rowid); | 440 | rowid); |
441 | proc (proc_cls, NULL, 0, NULL, 0, 0, 0, | 441 | proc (proc_cls, NULL, 0, NULL, 0, 0, 0, |
442 | GNUNET_TIME_UNIT_ZERO_ABS, 0); | 442 | GNUNET_TIME_UNIT_ZERO_ABS, 0); |
443 | return; | 443 | return; |
444 | } | 444 | } |
445 | 445 | ||
446 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | 446 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, |
447 | "datastore-postgres", | 447 | "datastore-postgres", |
448 | "Found result of size %u bytes and type %u in database\n", | 448 | "Found result of size %u bytes and type %u in database\n", |
449 | (unsigned int) size, | 449 | (unsigned int) size, |
450 | (unsigned int) utype); | 450 | (unsigned int) utype); |
451 | iret = proc (proc_cls, | 451 | iret = proc (proc_cls, |
452 | &key, | 452 | &key, |
453 | size, | 453 | size, |
454 | data, | 454 | data, |
455 | (enum GNUNET_BLOCK_Type) utype, | 455 | (enum GNUNET_BLOCK_Type) utype, |
456 | priority, | 456 | priority, |
457 | anonymity, | 457 | anonymity, |
458 | expiration_time, | 458 | expiration_time, |
@@ -461,20 +461,20 @@ process_result (struct Plugin *plugin, | |||
461 | if (iret == GNUNET_NO) | 461 | if (iret == GNUNET_NO) |
462 | { | 462 | { |
463 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 463 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
464 | "Processor asked for item %u to be removed.\n", | 464 | "Processor asked for item %u to be removed.\n", |
465 | (unsigned int) rowid); | 465 | (unsigned int) rowid); |
466 | if (GNUNET_OK == | 466 | if (GNUNET_OK == |
467 | GNUNET_POSTGRES_delete_by_rowid (plugin->dbh, | 467 | GNUNET_POSTGRES_delete_by_rowid (plugin->dbh, |
468 | "delrow", | 468 | "delrow", |
469 | rowid)) | 469 | rowid)) |
470 | { | 470 | { |
471 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | 471 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, |
472 | "datastore-postgres", | 472 | "datastore-postgres", |
473 | "Deleting %u bytes from database\n", | 473 | "Deleting %u bytes from database\n", |
474 | (unsigned int) size); | 474 | (unsigned int) size); |
475 | plugin->env->duc (plugin->env->cls, | 475 | plugin->env->duc (plugin->env->cls, |
476 | - (size + GNUNET_DATASTORE_ENTRY_OVERHEAD)); | 476 | - (size + GNUNET_DATASTORE_ENTRY_OVERHEAD)); |
477 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | 477 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, |
478 | "datastore-postgres", | 478 | "datastore-postgres", |
479 | "Deleted %u bytes from database\n", | 479 | "Deleted %u bytes from database\n", |
480 | (unsigned int) size); | 480 | (unsigned int) size); |
@@ -503,7 +503,7 @@ process_result (struct Plugin *plugin, | |||
503 | * @param proc_cls closure for iter | 503 | * @param proc_cls closure for iter |
504 | */ | 504 | */ |
505 | static void | 505 | static void |
506 | postgres_plugin_get_key (void *cls, | 506 | postgres_plugin_get_key (void *cls, |
507 | uint64_t offset, | 507 | uint64_t offset, |
508 | const struct GNUNET_HashCode *key, | 508 | const struct GNUNET_HashCode *key, |
509 | const struct GNUNET_HashCode *vhash, | 509 | const struct GNUNET_HashCode *vhash, |
@@ -521,7 +521,7 @@ postgres_plugin_get_key (void *cls, | |||
521 | { | 521 | { |
522 | if (NULL != vhash) | 522 | if (NULL != vhash) |
523 | { | 523 | { |
524 | struct GNUNET_PQ_QueryParam params[] = { | 524 | struct GNUNET_PQ_QueryParam params[] = { |
525 | GNUNET_PQ_query_param_auto_from_type (key), | 525 | GNUNET_PQ_query_param_auto_from_type (key), |
526 | GNUNET_PQ_query_param_auto_from_type (vhash), | 526 | GNUNET_PQ_query_param_auto_from_type (vhash), |
527 | GNUNET_PQ_query_param_uint32 (&utype), | 527 | GNUNET_PQ_query_param_uint32 (&utype), |
@@ -533,7 +533,7 @@ postgres_plugin_get_key (void *cls, | |||
533 | } | 533 | } |
534 | else | 534 | else |
535 | { | 535 | { |
536 | struct GNUNET_PQ_QueryParam params[] = { | 536 | struct GNUNET_PQ_QueryParam params[] = { |
537 | GNUNET_PQ_query_param_auto_from_type (key), | 537 | GNUNET_PQ_query_param_auto_from_type (key), |
538 | GNUNET_PQ_query_param_uint32 (&utype), | 538 | GNUNET_PQ_query_param_uint32 (&utype), |
539 | GNUNET_PQ_query_param_end | 539 | GNUNET_PQ_query_param_end |
@@ -547,7 +547,7 @@ postgres_plugin_get_key (void *cls, | |||
547 | { | 547 | { |
548 | if (NULL != vhash) | 548 | if (NULL != vhash) |
549 | { | 549 | { |
550 | struct GNUNET_PQ_QueryParam params[] = { | 550 | struct GNUNET_PQ_QueryParam params[] = { |
551 | GNUNET_PQ_query_param_auto_from_type (key), | 551 | GNUNET_PQ_query_param_auto_from_type (key), |
552 | GNUNET_PQ_query_param_auto_from_type (vhash), | 552 | GNUNET_PQ_query_param_auto_from_type (vhash), |
553 | GNUNET_PQ_query_param_end | 553 | GNUNET_PQ_query_param_end |
@@ -558,7 +558,7 @@ postgres_plugin_get_key (void *cls, | |||
558 | } | 558 | } |
559 | else | 559 | else |
560 | { | 560 | { |
561 | struct GNUNET_PQ_QueryParam params[] = { | 561 | struct GNUNET_PQ_QueryParam params[] = { |
562 | GNUNET_PQ_query_param_auto_from_type (key), | 562 | GNUNET_PQ_query_param_auto_from_type (key), |
563 | GNUNET_PQ_query_param_end | 563 | GNUNET_PQ_query_param_end |
564 | }; | 564 | }; |
@@ -569,23 +569,23 @@ postgres_plugin_get_key (void *cls, | |||
569 | } | 569 | } |
570 | 570 | ||
571 | if (GNUNET_OK != | 571 | if (GNUNET_OK != |
572 | GNUNET_POSTGRES_check_result (plugin->dbh, | 572 | GNUNET_POSTGRES_check_result (plugin->dbh, |
573 | ret, | 573 | ret, |
574 | PGRES_TUPLES_OK, | 574 | PGRES_TUPLES_OK, |
575 | "PQexecParams", | 575 | "PQexecParams", |
576 | "count")) | 576 | "count")) |
577 | { | 577 | { |
578 | proc (proc_cls, NULL, 0, NULL, 0, 0, 0, | 578 | proc (proc_cls, NULL, 0, NULL, 0, 0, 0, |
579 | GNUNET_TIME_UNIT_ZERO_ABS, 0); | 579 | GNUNET_TIME_UNIT_ZERO_ABS, 0); |
580 | return; | 580 | return; |
581 | } | 581 | } |
582 | if ( (PQntuples (ret) != 1) || | 582 | if ( (PQntuples (ret) != 1) || |
583 | (PQnfields (ret) != 1) || | 583 | (PQnfields (ret) != 1) || |
584 | (PQgetlength (ret, 0, 0) != sizeof (uint64_t))) | 584 | (PQgetlength (ret, 0, 0) != sizeof (uint64_t))) |
585 | { | 585 | { |
586 | GNUNET_break (0); | 586 | GNUNET_break (0); |
587 | PQclear (ret); | 587 | PQclear (ret); |
588 | proc (proc_cls, NULL, 0, NULL, 0, 0, 0, | 588 | proc (proc_cls, NULL, 0, NULL, 0, 0, 0, |
589 | GNUNET_TIME_UNIT_ZERO_ABS, 0); | 589 | GNUNET_TIME_UNIT_ZERO_ABS, 0); |
590 | return; | 590 | return; |
591 | } | 591 | } |
@@ -593,7 +593,7 @@ postgres_plugin_get_key (void *cls, | |||
593 | PQclear (ret); | 593 | PQclear (ret); |
594 | if (0 == total) | 594 | if (0 == total) |
595 | { | 595 | { |
596 | proc (proc_cls, NULL, 0, NULL, 0, 0, 0, | 596 | proc (proc_cls, NULL, 0, NULL, 0, 0, 0, |
597 | GNUNET_TIME_UNIT_ZERO_ABS, 0); | 597 | GNUNET_TIME_UNIT_ZERO_ABS, 0); |
598 | return; | 598 | return; |
599 | } | 599 | } |
@@ -603,9 +603,9 @@ postgres_plugin_get_key (void *cls, | |||
603 | { | 603 | { |
604 | if (NULL != vhash) | 604 | if (NULL != vhash) |
605 | { | 605 | { |
606 | struct GNUNET_PQ_QueryParam params[] = { | 606 | struct GNUNET_PQ_QueryParam params[] = { |
607 | GNUNET_PQ_query_param_auto_from_type (key), | 607 | GNUNET_PQ_query_param_auto_from_type (key), |
608 | GNUNET_PQ_query_param_auto_from_type (&vhash), | 608 | GNUNET_PQ_query_param_auto_from_type (vhash), |
609 | GNUNET_PQ_query_param_uint32 (&utype), | 609 | GNUNET_PQ_query_param_uint32 (&utype), |
610 | GNUNET_PQ_query_param_uint64 (&limit_off), | 610 | GNUNET_PQ_query_param_uint64 (&limit_off), |
611 | GNUNET_PQ_query_param_end | 611 | GNUNET_PQ_query_param_end |
@@ -616,7 +616,7 @@ postgres_plugin_get_key (void *cls, | |||
616 | } | 616 | } |
617 | else | 617 | else |
618 | { | 618 | { |
619 | struct GNUNET_PQ_QueryParam params[] = { | 619 | struct GNUNET_PQ_QueryParam params[] = { |
620 | GNUNET_PQ_query_param_auto_from_type (key), | 620 | GNUNET_PQ_query_param_auto_from_type (key), |
621 | GNUNET_PQ_query_param_uint32 (&utype), | 621 | GNUNET_PQ_query_param_uint32 (&utype), |
622 | GNUNET_PQ_query_param_uint64 (&limit_off), | 622 | GNUNET_PQ_query_param_uint64 (&limit_off), |
@@ -631,9 +631,9 @@ postgres_plugin_get_key (void *cls, | |||
631 | { | 631 | { |
632 | if (NULL != vhash) | 632 | if (NULL != vhash) |
633 | { | 633 | { |
634 | struct GNUNET_PQ_QueryParam params[] = { | 634 | struct GNUNET_PQ_QueryParam params[] = { |
635 | GNUNET_PQ_query_param_auto_from_type (key), | 635 | GNUNET_PQ_query_param_auto_from_type (key), |
636 | GNUNET_PQ_query_param_auto_from_type (&vhash), | 636 | GNUNET_PQ_query_param_auto_from_type (vhash), |
637 | GNUNET_PQ_query_param_uint64 (&limit_off), | 637 | GNUNET_PQ_query_param_uint64 (&limit_off), |
638 | GNUNET_PQ_query_param_end | 638 | GNUNET_PQ_query_param_end |
639 | }; | 639 | }; |
@@ -643,7 +643,7 @@ postgres_plugin_get_key (void *cls, | |||
643 | } | 643 | } |
644 | else | 644 | else |
645 | { | 645 | { |
646 | struct GNUNET_PQ_QueryParam params[] = { | 646 | struct GNUNET_PQ_QueryParam params[] = { |
647 | GNUNET_PQ_query_param_auto_from_type (key), | 647 | GNUNET_PQ_query_param_auto_from_type (key), |
648 | GNUNET_PQ_query_param_uint64 (&limit_off), | 648 | GNUNET_PQ_query_param_uint64 (&limit_off), |
649 | GNUNET_PQ_query_param_end | 649 | GNUNET_PQ_query_param_end |
@@ -655,8 +655,8 @@ postgres_plugin_get_key (void *cls, | |||
655 | } | 655 | } |
656 | process_result (plugin, | 656 | process_result (plugin, |
657 | proc, | 657 | proc, |
658 | proc_cls, | 658 | proc_cls, |
659 | ret, | 659 | ret, |
660 | __FILE__, __LINE__); | 660 | __FILE__, __LINE__); |
661 | } | 661 | } |
662 | 662 | ||
@@ -675,15 +675,15 @@ postgres_plugin_get_key (void *cls, | |||
675 | * @param proc_cls closure for @a proc | 675 | * @param proc_cls closure for @a proc |
676 | */ | 676 | */ |
677 | static void | 677 | static void |
678 | postgres_plugin_get_zero_anonymity (void *cls, | 678 | postgres_plugin_get_zero_anonymity (void *cls, |
679 | uint64_t offset, | 679 | uint64_t offset, |
680 | enum GNUNET_BLOCK_Type type, | 680 | enum GNUNET_BLOCK_Type type, |
681 | PluginDatumProcessor proc, | 681 | PluginDatumProcessor proc, |
682 | void *proc_cls) | 682 | void *proc_cls) |
683 | { | 683 | { |
684 | struct Plugin *plugin = cls; | 684 | struct Plugin *plugin = cls; |
685 | uint32_t utype = type; | 685 | uint32_t utype = type; |
686 | struct GNUNET_PQ_QueryParam params[] = { | 686 | struct GNUNET_PQ_QueryParam params[] = { |
687 | GNUNET_PQ_query_param_uint32 (&utype), | 687 | GNUNET_PQ_query_param_uint32 (&utype), |
688 | GNUNET_PQ_query_param_uint64 (&offset), | 688 | GNUNET_PQ_query_param_uint64 (&offset), |
689 | GNUNET_PQ_query_param_end | 689 | GNUNET_PQ_query_param_end |
@@ -694,7 +694,7 @@ postgres_plugin_get_zero_anonymity (void *cls, | |||
694 | "select_non_anonymous", | 694 | "select_non_anonymous", |
695 | params); | 695 | params); |
696 | 696 | ||
697 | process_result (plugin, | 697 | process_result (plugin, |
698 | proc, proc_cls, | 698 | proc, proc_cls, |
699 | ret, | 699 | ret, |
700 | __FILE__, __LINE__); | 700 | __FILE__, __LINE__); |
@@ -739,7 +739,7 @@ struct ReplCtx | |||
739 | * @param expiration expiration time for the content | 739 | * @param expiration expiration time for the content |
740 | * @param uid unique identifier for the datum; | 740 | * @param uid unique identifier for the datum; |
741 | * maybe 0 if no unique identifier is available | 741 | * maybe 0 if no unique identifier is available |
742 | * @return #GNUNET_SYSERR to abort the iteration, | 742 | * @return #GNUNET_SYSERR to abort the iteration, |
743 | * #GNUNET_OK to continue | 743 | * #GNUNET_OK to continue |
744 | * (continue on call to "next", of course), | 744 | * (continue on call to "next", of course), |
745 | * #GNUNET_NO to delete the item and continue (if supported) | 745 | * #GNUNET_NO to delete the item and continue (if supported) |
@@ -749,9 +749,9 @@ repl_proc (void *cls, | |||
749 | const struct GNUNET_HashCode *key, | 749 | const struct GNUNET_HashCode *key, |
750 | uint32_t size, | 750 | uint32_t size, |
751 | const void *data, | 751 | const void *data, |
752 | enum GNUNET_BLOCK_Type type, | 752 | enum GNUNET_BLOCK_Type type, |
753 | uint32_t priority, | 753 | uint32_t priority, |
754 | uint32_t anonymity, | 754 | uint32_t anonymity, |
755 | struct GNUNET_TIME_Absolute expiration, | 755 | struct GNUNET_TIME_Absolute expiration, |
756 | uint64_t uid) | 756 | uint64_t uid) |
757 | { | 757 | { |
@@ -759,17 +759,17 @@ repl_proc (void *cls, | |||
759 | struct Plugin *plugin = rc->plugin; | 759 | struct Plugin *plugin = rc->plugin; |
760 | int ret; | 760 | int ret; |
761 | uint32_t oid = (uint32_t) uid; | 761 | uint32_t oid = (uint32_t) uid; |
762 | struct GNUNET_PQ_QueryParam params[] = { | 762 | struct GNUNET_PQ_QueryParam params[] = { |
763 | GNUNET_PQ_query_param_uint32 (&oid), | 763 | GNUNET_PQ_query_param_uint32 (&oid), |
764 | GNUNET_PQ_query_param_end | 764 | GNUNET_PQ_query_param_end |
765 | }; | 765 | }; |
766 | PGresult *qret; | 766 | PGresult *qret; |
767 | 767 | ||
768 | ret = rc->proc (rc->proc_cls, | 768 | ret = rc->proc (rc->proc_cls, |
769 | key, | 769 | key, |
770 | size, data, | 770 | size, data, |
771 | type, | 771 | type, |
772 | priority, | 772 | priority, |
773 | anonymity, | 773 | anonymity, |
774 | expiration, uid); | 774 | expiration, uid); |
775 | if (NULL == key) | 775 | if (NULL == key) |
@@ -778,9 +778,9 @@ repl_proc (void *cls, | |||
778 | "decrepl", | 778 | "decrepl", |
779 | params); | 779 | params); |
780 | if (GNUNET_OK != | 780 | if (GNUNET_OK != |
781 | GNUNET_POSTGRES_check_result (plugin->dbh, | 781 | GNUNET_POSTGRES_check_result (plugin->dbh, |
782 | qret, | 782 | qret, |
783 | PGRES_COMMAND_OK, | 783 | PGRES_COMMAND_OK, |
784 | "PQexecPrepared", | 784 | "PQexecPrepared", |
785 | "decrepl")) | 785 | "decrepl")) |
786 | return GNUNET_SYSERR; | 786 | return GNUNET_SYSERR; |
@@ -801,7 +801,7 @@ repl_proc (void *cls, | |||
801 | * @param proc_cls closure for @a proc | 801 | * @param proc_cls closure for @a proc |
802 | */ | 802 | */ |
803 | static void | 803 | static void |
804 | postgres_plugin_get_replication (void *cls, | 804 | postgres_plugin_get_replication (void *cls, |
805 | PluginDatumProcessor proc, | 805 | PluginDatumProcessor proc, |
806 | void *proc_cls) | 806 | void *proc_cls) |
807 | { | 807 | { |
@@ -812,13 +812,13 @@ postgres_plugin_get_replication (void *cls, | |||
812 | rc.plugin = plugin; | 812 | rc.plugin = plugin; |
813 | rc.proc = proc; | 813 | rc.proc = proc; |
814 | rc.proc_cls = proc_cls; | 814 | rc.proc_cls = proc_cls; |
815 | ret = PQexecPrepared (plugin->dbh, | 815 | ret = PQexecPrepared (plugin->dbh, |
816 | "select_replication_order", 0, NULL, NULL, | 816 | "select_replication_order", 0, NULL, NULL, |
817 | NULL, 1); | 817 | NULL, 1); |
818 | process_result (plugin, | 818 | process_result (plugin, |
819 | &repl_proc, | 819 | &repl_proc, |
820 | &rc, | 820 | &rc, |
821 | ret, | 821 | ret, |
822 | __FILE__, __LINE__); | 822 | __FILE__, __LINE__); |
823 | } | 823 | } |
824 | 824 | ||
@@ -832,13 +832,13 @@ postgres_plugin_get_replication (void *cls, | |||
832 | * @param proc_cls closure for @a proc | 832 | * @param proc_cls closure for @a proc |
833 | */ | 833 | */ |
834 | static void | 834 | static void |
835 | postgres_plugin_get_expiration (void *cls, | 835 | postgres_plugin_get_expiration (void *cls, |
836 | PluginDatumProcessor proc, | 836 | PluginDatumProcessor proc, |
837 | void *proc_cls) | 837 | void *proc_cls) |
838 | { | 838 | { |
839 | struct Plugin *plugin = cls; | 839 | struct Plugin *plugin = cls; |
840 | struct GNUNET_TIME_Absolute now; | 840 | struct GNUNET_TIME_Absolute now; |
841 | struct GNUNET_PQ_QueryParam params[] = { | 841 | struct GNUNET_PQ_QueryParam params[] = { |
842 | GNUNET_PQ_query_param_absolute_time (&now), | 842 | GNUNET_PQ_query_param_absolute_time (&now), |
843 | GNUNET_PQ_query_param_end | 843 | GNUNET_PQ_query_param_end |
844 | }; | 844 | }; |
@@ -879,8 +879,8 @@ postgres_plugin_get_expiration (void *cls, | |||
879 | * @param cons_cls continuation closure | 879 | * @param cons_cls continuation closure |
880 | */ | 880 | */ |
881 | static void | 881 | static void |
882 | postgres_plugin_update (void *cls, | 882 | postgres_plugin_update (void *cls, |
883 | uint64_t uid, | 883 | uint64_t uid, |
884 | int delta, | 884 | int delta, |
885 | struct GNUNET_TIME_Absolute expire, | 885 | struct GNUNET_TIME_Absolute expire, |
886 | PluginUpdateCont cont, | 886 | PluginUpdateCont cont, |
@@ -889,7 +889,7 @@ postgres_plugin_update (void *cls, | |||
889 | struct Plugin *plugin = cls; | 889 | struct Plugin *plugin = cls; |
890 | uint32_t idelta = delta; | 890 | uint32_t idelta = delta; |
891 | uint32_t oid = (uint32_t) uid; | 891 | uint32_t oid = (uint32_t) uid; |
892 | struct GNUNET_PQ_QueryParam params[] = { | 892 | struct GNUNET_PQ_QueryParam params[] = { |
893 | GNUNET_PQ_query_param_uint32 (&idelta), | 893 | GNUNET_PQ_query_param_uint32 (&idelta), |
894 | GNUNET_PQ_query_param_absolute_time (&expire), | 894 | GNUNET_PQ_query_param_absolute_time (&expire), |
895 | GNUNET_PQ_query_param_uint32 (&oid), | 895 | GNUNET_PQ_query_param_uint32 (&oid), |
@@ -902,24 +902,23 @@ postgres_plugin_update (void *cls, | |||
902 | params); | 902 | params); |
903 | if (GNUNET_OK != | 903 | if (GNUNET_OK != |
904 | GNUNET_POSTGRES_check_result (plugin->dbh, | 904 | GNUNET_POSTGRES_check_result (plugin->dbh, |
905 | ret, | 905 | ret, |
906 | PGRES_COMMAND_OK, | 906 | PGRES_COMMAND_OK, |
907 | "PQexecPrepared", | 907 | "PQexecPrepared", |
908 | "update")) | 908 | "update")) |
909 | { | 909 | { |
910 | cont (cont_cls, | 910 | cont (cont_cls, |
911 | GNUNET_SYSERR, | 911 | GNUNET_SYSERR, |
912 | NULL); | 912 | NULL); |
913 | return; | 913 | return; |
914 | } | 914 | } |
915 | PQclear (ret); | 915 | PQclear (ret); |
916 | cont (cont_cls, | 916 | cont (cont_cls, |
917 | GNUNET_OK, | 917 | GNUNET_OK, |
918 | NULL); | 918 | NULL); |
919 | } | 919 | } |
920 | 920 | ||
921 | 921 | ||
922 | |||
923 | /** | 922 | /** |
924 | * Get all of the keys in the datastore. | 923 | * Get all of the keys in the datastore. |
925 | * | 924 | * |
@@ -938,17 +937,17 @@ postgres_plugin_get_keys (void *cls, | |||
938 | struct GNUNET_HashCode key; | 937 | struct GNUNET_HashCode key; |
939 | PGresult * res; | 938 | PGresult * res; |
940 | 939 | ||
941 | res = PQexecPrepared (plugin->dbh, | 940 | res = PQexecPrepared (plugin->dbh, |
942 | "get_keys", | 941 | "get_keys", |
943 | 0, NULL, NULL, NULL, 1); | 942 | 0, NULL, NULL, NULL, 1); |
944 | ret = PQntuples (res); | 943 | ret = PQntuples (res); |
945 | for (i=0;i<ret;i++) | 944 | for (i=0;i<ret;i++) |
946 | { | 945 | { |
947 | if (sizeof (struct GNUNET_HashCode) != | 946 | if (sizeof (struct GNUNET_HashCode) != |
948 | PQgetlength (res, i, 0)) | 947 | PQgetlength (res, i, 0)) |
949 | { | 948 | { |
950 | memcpy (&key, | 949 | memcpy (&key, |
951 | PQgetvalue (res, i, 0), | 950 | PQgetvalue (res, i, 0), |
952 | sizeof (struct GNUNET_HashCode)); | 951 | sizeof (struct GNUNET_HashCode)); |
953 | proc (proc_cls, &key, 1); | 952 | proc (proc_cls, &key, 1); |
954 | } | 953 | } |
@@ -958,7 +957,6 @@ postgres_plugin_get_keys (void *cls, | |||
958 | } | 957 | } |
959 | 958 | ||
960 | 959 | ||
961 | |||
962 | /** | 960 | /** |
963 | * Drop database. | 961 | * Drop database. |
964 | * | 962 | * |
@@ -969,10 +967,11 @@ postgres_plugin_drop (void *cls) | |||
969 | { | 967 | { |
970 | struct Plugin *plugin = cls; | 968 | struct Plugin *plugin = cls; |
971 | 969 | ||
972 | if (GNUNET_OK != | 970 | if (GNUNET_OK != |
973 | GNUNET_POSTGRES_exec (plugin->dbh, "DROP TABLE gn090")) | 971 | GNUNET_POSTGRES_exec (plugin->dbh, |
974 | GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, | 972 | "DROP TABLE gn090")) |
975 | "postgres", | 973 | GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, |
974 | "postgres", | ||
976 | _("Failed to drop table from database.\n")); | 975 | _("Failed to drop table from database.\n")); |
977 | } | 976 | } |
978 | 977 | ||
@@ -1008,7 +1007,8 @@ libgnunet_plugin_datastore_postgres_init (void *cls) | |||
1008 | api->get_zero_anonymity = &postgres_plugin_get_zero_anonymity; | 1007 | api->get_zero_anonymity = &postgres_plugin_get_zero_anonymity; |
1009 | api->get_keys = &postgres_plugin_get_keys; | 1008 | api->get_keys = &postgres_plugin_get_keys; |
1010 | api->drop = &postgres_plugin_drop; | 1009 | api->drop = &postgres_plugin_drop; |
1011 | GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "datastore-postgres", | 1010 | GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, |
1011 | "datastore-postgres", | ||
1012 | _("Postgres database running\n")); | 1012 | _("Postgres database running\n")); |
1013 | return api; | 1013 | return api; |
1014 | } | 1014 | } |
diff --git a/src/datastore/test_datastore_api.c b/src/datastore/test_datastore_api.c index c50543210..12f2ef762 100644 --- a/src/datastore/test_datastore_api.c +++ b/src/datastore/test_datastore_api.c | |||
@@ -197,7 +197,7 @@ check_success (void *cls, | |||
197 | if (GNUNET_OK != success) | 197 | if (GNUNET_OK != success) |
198 | { | 198 | { |
199 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 199 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
200 | "Operation %d/%d not successfull: `%s'\n", | 200 | "Operation %d/%d not successful: `%s'\n", |
201 | crc->phase, | 201 | crc->phase, |
202 | crc->i, | 202 | crc->i, |
203 | msg); | 203 | msg); |
@@ -410,8 +410,7 @@ run_continuation (void *cls, | |||
410 | { | 410 | { |
411 | case RP_PUT: | 411 | case RP_PUT: |
412 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 412 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
413 | "Executing `%s' number %u\n", | 413 | "Executing PUT number %u\n", |
414 | "PUT", | ||
415 | crc->i); | 414 | crc->i); |
416 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); | 415 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); |
417 | GNUNET_DATASTORE_put (datastore, 0, &crc->key, get_size (crc->i), | 416 | GNUNET_DATASTORE_put (datastore, 0, &crc->key, get_size (crc->i), |
@@ -426,19 +425,17 @@ run_continuation (void *cls, | |||
426 | case RP_GET: | 425 | case RP_GET: |
427 | crc->i--; | 426 | crc->i--; |
428 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 427 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
429 | "Executing `%s' number %u\n", | 428 | "Executing GET number %u\n", |
430 | "GET", | ||
431 | crc->i); | 429 | crc->i); |
432 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); | 430 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); |
433 | GNUNET_DATASTORE_get_key (datastore, crc->offset, &crc->key, | 431 | GNUNET_DATASTORE_get_key (datastore, crc->offset, &crc->key, |
434 | get_type (crc->i), 1, 1, TIMEOUT, &check_value, | 432 | get_type (crc->i), 1, 1, TIMEOUT, |
435 | crc); | 433 | &check_value, crc); |
436 | break; | 434 | break; |
437 | case RP_DEL: | 435 | case RP_DEL: |
438 | crc->i--; | 436 | crc->i--; |
439 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 437 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
440 | "Executing `%s' number %u\n", | 438 | "Executing DEL number %u\n", |
441 | "DEL", | ||
442 | crc->i); | 439 | crc->i); |
443 | crc->data = NULL; | 440 | crc->data = NULL; |
444 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); | 441 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); |
@@ -449,8 +446,7 @@ run_continuation (void *cls, | |||
449 | break; | 446 | break; |
450 | case RP_DO_DEL: | 447 | case RP_DO_DEL: |
451 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 448 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
452 | "Executing `%s' number %u\n", | 449 | "Executing DO_DEL number %u\n", |
453 | "DO_DEL", | ||
454 | crc->i); | 450 | crc->i); |
455 | if (crc->i == 0) | 451 | if (crc->i == 0) |
456 | { | 452 | { |
@@ -469,8 +465,8 @@ run_continuation (void *cls, | |||
469 | case RP_DELVALIDATE: | 465 | case RP_DELVALIDATE: |
470 | crc->i--; | 466 | crc->i--; |
471 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 467 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
472 | "Executing `%s' number %u\n", | 468 | "Executing DELVALIDATE number %u\n", |
473 | "DEL-VALIDATE", crc->i); | 469 | crc->i); |
474 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); | 470 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); |
475 | GNUNET_assert (NULL != | 471 | GNUNET_assert (NULL != |
476 | GNUNET_DATASTORE_get_key (datastore, crc->offset, &crc->key, | 472 | GNUNET_DATASTORE_get_key (datastore, crc->offset, &crc->key, |