diff options
author | Gabor X Toth <*@tg-x.net> | 2016-10-12 19:31:44 +0000 |
---|---|---|
committer | Gabor X Toth <*@tg-x.net> | 2016-10-12 19:31:44 +0000 |
commit | cb1ae526f2eb09e18f403cf1a91d9776aa5b4d51 (patch) | |
tree | 6a7d56da18a4d564937c73d1a794f42cb6a1bc00 /src/psycstore | |
parent | a0efe1077eb5e38f1f637c46492602349c74fdbd (diff) | |
download | gnunet-cb1ae526f2eb09e18f403cf1a91d9776aa5b4d51.tar.gz gnunet-cb1ae526f2eb09e18f403cf1a91d9776aa5b4d51.zip |
psycstore: postgres fixes
Diffstat (limited to 'src/psycstore')
-rw-r--r-- | src/psycstore/plugin_psycstore_mysql.c | 4 | ||||
-rw-r--r-- | src/psycstore/plugin_psycstore_postgres.c | 66 |
2 files changed, 36 insertions, 34 deletions
diff --git a/src/psycstore/plugin_psycstore_mysql.c b/src/psycstore/plugin_psycstore_mysql.c index 778bc8a08..71f2eb5b8 100644 --- a/src/psycstore/plugin_psycstore_mysql.c +++ b/src/psycstore/plugin_psycstore_mysql.c | |||
@@ -1590,8 +1590,8 @@ state_sync_assign (void *cls, | |||
1590 | const char *name, const void *value, size_t value_size) | 1590 | const char *name, const void *value, size_t value_size) |
1591 | { | 1591 | { |
1592 | struct Plugin *plugin = cls; | 1592 | struct Plugin *plugin = cls; |
1593 | return state_assign (cls, plugin->insert_state_sync, channel_key, | 1593 | return state_assign (cls, plugin->insert_state_sync, |
1594 | name, value, value_size); | 1594 | channel_key, name, value, value_size); |
1595 | } | 1595 | } |
1596 | 1596 | ||
1597 | 1597 | ||
diff --git a/src/psycstore/plugin_psycstore_postgres.c b/src/psycstore/plugin_psycstore_postgres.c index 244b582a8..147e70bd6 100644 --- a/src/psycstore/plugin_psycstore_postgres.c +++ b/src/psycstore/plugin_psycstore_postgres.c | |||
@@ -101,8 +101,8 @@ database_setup (struct Plugin *plugin) | |||
101 | "CREATE TABLE IF NOT EXISTS channels (\n" | 101 | "CREATE TABLE IF NOT EXISTS channels (\n" |
102 | " id SERIAL,\n" | 102 | " id SERIAL,\n" |
103 | " pub_key BYTEA,\n" | 103 | " pub_key BYTEA,\n" |
104 | " max_state_message_id INT,\n" | 104 | " max_state_message_id BIGINT,\n" |
105 | " state_hash_message_id INT,\n" | 105 | " state_hash_message_id BIGINT,\n" |
106 | " PRIMARY KEY(id)\n" | 106 | " PRIMARY KEY(id)\n" |
107 | ")" "WITH OIDS")) || | 107 | ")" "WITH OIDS")) || |
108 | 108 | ||
@@ -141,9 +141,9 @@ database_setup (struct Plugin *plugin) | |||
141 | (GNUNET_OK != | 141 | (GNUNET_OK != |
142 | GNUNET_POSTGRES_exec(plugin->dbh, | 142 | GNUNET_POSTGRES_exec(plugin->dbh, |
143 | "CREATE TABLE IF NOT EXISTS membership (\n" | 143 | "CREATE TABLE IF NOT EXISTS membership (\n" |
144 | " channel_id INT NOT NULL REFERENCES channels(id),\n" | 144 | " channel_id BIGINT NOT NULL REFERENCES channels(id),\n" |
145 | " slave_id INT NOT NULL REFERENCES slaves(id),\n" | 145 | " slave_id BIGINT NOT NULL REFERENCES slaves(id),\n" |
146 | " did_join INT NOT NULL,\n" | 146 | " did_join BIGINT NOT NULL,\n" |
147 | " announced_at BIGINT NOT NULL,\n" | 147 | " announced_at BIGINT NOT NULL,\n" |
148 | " effective_since BIGINT NOT NULL,\n" | 148 | " effective_since BIGINT NOT NULL,\n" |
149 | " group_generation BIGINT NOT NULL\n" | 149 | " group_generation BIGINT NOT NULL\n" |
@@ -158,7 +158,7 @@ database_setup (struct Plugin *plugin) | |||
158 | (GNUNET_OK != | 158 | (GNUNET_OK != |
159 | GNUNET_POSTGRES_exec(plugin->dbh, | 159 | GNUNET_POSTGRES_exec(plugin->dbh, |
160 | "CREATE TABLE IF NOT EXISTS messages (\n" | 160 | "CREATE TABLE IF NOT EXISTS messages (\n" |
161 | " channel_id INT NOT NULL REFERENCES channels(id),\n" | 161 | " channel_id BIGINT NOT NULL REFERENCES channels(id),\n" |
162 | " hop_counter BIGINT NOT NULL,\n" | 162 | " hop_counter BIGINT NOT NULL,\n" |
163 | " signature BYTEA,\n" | 163 | " signature BYTEA,\n" |
164 | " purpose BYTEA,\n" | 164 | " purpose BYTEA,\n" |
@@ -176,7 +176,7 @@ database_setup (struct Plugin *plugin) | |||
176 | (GNUNET_OK != | 176 | (GNUNET_OK != |
177 | GNUNET_POSTGRES_exec(plugin->dbh, | 177 | GNUNET_POSTGRES_exec(plugin->dbh, |
178 | "CREATE TABLE IF NOT EXISTS state (\n" | 178 | "CREATE TABLE IF NOT EXISTS state (\n" |
179 | " channel_id INT NOT NULL REFERENCES channels(id),\n" | 179 | " channel_id BIGINT NOT NULL REFERENCES channels(id),\n" |
180 | " name TEXT NOT NULL,\n" | 180 | " name TEXT NOT NULL,\n" |
181 | " value_current BYTEA,\n" | 181 | " value_current BYTEA,\n" |
182 | " value_signed BYTEA\n" | 182 | " value_signed BYTEA\n" |
@@ -191,7 +191,7 @@ database_setup (struct Plugin *plugin) | |||
191 | (GNUNET_OK != | 191 | (GNUNET_OK != |
192 | GNUNET_POSTGRES_exec(plugin->dbh, | 192 | GNUNET_POSTGRES_exec(plugin->dbh, |
193 | "CREATE TABLE IF NOT EXISTS state_sync (\n" | 193 | "CREATE TABLE IF NOT EXISTS state_sync (\n" |
194 | " channel_id INT NOT NULL REFERENCES channels(id),\n" | 194 | " channel_id BIGINT NOT NULL REFERENCES channels(id),\n" |
195 | " name TEXT NOT NULL,\n" | 195 | " name TEXT NOT NULL,\n" |
196 | " value BYTEA,\n" | 196 | " value BYTEA,\n" |
197 | " PRIMARY KEY (channel_id)\n" | 197 | " PRIMARY KEY (channel_id)\n" |
@@ -724,11 +724,12 @@ membership_test (void *cls, | |||
724 | GNUNET_PQ_result_spec_end | 724 | GNUNET_PQ_result_spec_end |
725 | }; | 725 | }; |
726 | 726 | ||
727 | switch(GNUNET_PQ_extract_result (res, results_select, 0)) | 727 | switch (GNUNET_PQ_extract_result (res, results_select, 0)) |
728 | { | 728 | { |
729 | case GNUNET_OK: | 729 | case GNUNET_OK: |
730 | ret = GNUNET_YES; | 730 | ret = GNUNET_YES; |
731 | break; | 731 | break; |
732 | |||
732 | default: | 733 | default: |
733 | ret = GNUNET_NO; | 734 | ret = GNUNET_NO; |
734 | break; | 735 | break; |
@@ -1255,7 +1256,7 @@ state_assign (struct Plugin *plugin, const char *stmt, | |||
1255 | struct GNUNET_PQ_QueryParam params[] = { | 1256 | struct GNUNET_PQ_QueryParam params[] = { |
1256 | GNUNET_PQ_query_param_auto_from_type (channel_key), | 1257 | GNUNET_PQ_query_param_auto_from_type (channel_key), |
1257 | GNUNET_PQ_query_param_string (name), | 1258 | GNUNET_PQ_query_param_string (name), |
1258 | GNUNET_PQ_query_param_auto_from_type (value), | 1259 | GNUNET_PQ_query_param_fixed_size (value, value_size), |
1259 | GNUNET_PQ_query_param_end | 1260 | GNUNET_PQ_query_param_end |
1260 | }; | 1261 | }; |
1261 | 1262 | ||
@@ -1328,6 +1329,7 @@ state_modify_begin (void *cls, | |||
1328 | case GNUNET_NO: // no state yet | 1329 | case GNUNET_NO: // no state yet |
1329 | ret = GNUNET_OK; | 1330 | ret = GNUNET_OK; |
1330 | break; | 1331 | break; |
1332 | |||
1331 | default: | 1333 | default: |
1332 | return ret; | 1334 | return ret; |
1333 | } | 1335 | } |
@@ -1366,8 +1368,8 @@ state_modify_op (void *cls, | |||
1366 | switch (op) | 1368 | switch (op) |
1367 | { | 1369 | { |
1368 | case GNUNET_PSYC_OP_ASSIGN: | 1370 | case GNUNET_PSYC_OP_ASSIGN: |
1369 | return state_assign (plugin, "insert_state_current", channel_key, | 1371 | return state_assign (plugin, "insert_state_current", |
1370 | name, value, value_size); | 1372 | channel_key, name, value, value_size); |
1371 | 1373 | ||
1372 | default: /** @todo implement more state operations */ | 1374 | default: /** @todo implement more state operations */ |
1373 | GNUNET_break (0); | 1375 | GNUNET_break (0); |
@@ -1422,8 +1424,8 @@ state_sync_assign (void *cls, | |||
1422 | const char *name, const void *value, size_t value_size) | 1424 | const char *name, const void *value, size_t value_size) |
1423 | { | 1425 | { |
1424 | struct Plugin *plugin = cls; | 1426 | struct Plugin *plugin = cls; |
1425 | return state_assign (plugin, "insert_state_sync", channel_key, | 1427 | return state_assign (plugin, "insert_state_sync", |
1426 | name, value, value_size); | 1428 | channel_key, name, value, value_size); |
1427 | } | 1429 | } |
1428 | 1430 | ||
1429 | 1431 | ||
@@ -1599,17 +1601,17 @@ state_get_prefix (void *cls, const struct GNUNET_CRYPTO_EddsaPublicKey *channel_ | |||
1599 | GNUNET_PQ_result_spec_end | 1601 | GNUNET_PQ_result_spec_end |
1600 | }; | 1602 | }; |
1601 | 1603 | ||
1602 | do | 1604 | res = GNUNET_PQ_exec_prepared (plugin->dbh, stmt, params_select); |
1605 | if (GNUNET_OK != GNUNET_POSTGRES_check_result (plugin->dbh, | ||
1606 | res, | ||
1607 | PGRES_TUPLES_OK, | ||
1608 | "PQexecPrepared", stmt)) | ||
1603 | { | 1609 | { |
1604 | res = GNUNET_PQ_exec_prepared (plugin->dbh, stmt, params_select); | 1610 | return GNUNET_SYSERR; |
1605 | if (GNUNET_OK != GNUNET_POSTGRES_check_result (plugin->dbh, | 1611 | } |
1606 | res, | ||
1607 | PGRES_TUPLES_OK, | ||
1608 | "PQexecPrepared", stmt)) | ||
1609 | { | ||
1610 | break; | ||
1611 | } | ||
1612 | 1612 | ||
1613 | do | ||
1614 | { | ||
1613 | if (PQntuples (res) == 0) | 1615 | if (PQntuples (res) == 0) |
1614 | { | 1616 | { |
1615 | PQclear (res); | 1617 | PQclear (res); |
@@ -1669,17 +1671,17 @@ state_get_signed (void *cls, | |||
1669 | GNUNET_PQ_result_spec_end | 1671 | GNUNET_PQ_result_spec_end |
1670 | }; | 1672 | }; |
1671 | 1673 | ||
1672 | do | 1674 | res = GNUNET_PQ_exec_prepared (plugin->dbh, stmt, params_select); |
1675 | if (GNUNET_OK != GNUNET_POSTGRES_check_result (plugin->dbh, | ||
1676 | res, | ||
1677 | PGRES_TUPLES_OK, | ||
1678 | "PQexecPrepared", stmt)) | ||
1673 | { | 1679 | { |
1674 | res = GNUNET_PQ_exec_prepared (plugin->dbh, stmt, params_select); | 1680 | return GNUNET_SYSERR; |
1675 | if (GNUNET_OK != GNUNET_POSTGRES_check_result (plugin->dbh, | 1681 | } |
1676 | res, | ||
1677 | PGRES_TUPLES_OK, | ||
1678 | "PQexecPrepared", stmt)) | ||
1679 | { | ||
1680 | break; | ||
1681 | } | ||
1682 | 1682 | ||
1683 | do | ||
1684 | { | ||
1683 | if (PQntuples (res) == 0) | 1685 | if (PQntuples (res) == 0) |
1684 | { | 1686 | { |
1685 | PQclear (res); | 1687 | PQclear (res); |