diff options
Diffstat (limited to 'src/datastore/plugin_datastore_postgres.c')
-rw-r--r-- | src/datastore/plugin_datastore_postgres.c | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/src/datastore/plugin_datastore_postgres.c b/src/datastore/plugin_datastore_postgres.c index fd1a533bb..d5b1f70bd 100644 --- a/src/datastore/plugin_datastore_postgres.c +++ b/src/datastore/plugin_datastore_postgres.c | |||
@@ -2,20 +2,18 @@ | |||
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2009-2017 GNUnet e.V. | 3 | Copyright (C) 2009-2017 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | 18 | ||
21 | /** | 19 | /** |
@@ -101,23 +99,23 @@ init_connection (struct Plugin *plugin) | |||
101 | #define RESULT_COLUMNS "repl, type, prio, anonLevel, expire, hash, value, oid" | 99 | #define RESULT_COLUMNS "repl, type, prio, anonLevel, expire, hash, value, oid" |
102 | struct GNUNET_PQ_PreparedStatement ps[] = { | 100 | struct GNUNET_PQ_PreparedStatement ps[] = { |
103 | GNUNET_PQ_make_prepare ("get", | 101 | GNUNET_PQ_make_prepare ("get", |
104 | "SELECT " RESULT_COLUMNS " FROM gn090 " | 102 | "SELECT " RESULT_COLUMNS " FROM gn090" |
105 | "WHERE oid >= $1::bigint AND " | 103 | " WHERE oid >= $1::bigint AND" |
106 | "(rvalue >= $2 OR 0 = $3::smallint) AND " | 104 | " (rvalue >= $2 OR 0 = $3::smallint) AND" |
107 | "(hash = $4 OR 0 = $5::smallint) AND " | 105 | " (hash = $4 OR 0 = $5::smallint) AND" |
108 | "(type = $6 OR 0 = $7::smallint) " | 106 | " (type = $6 OR 0 = $7::smallint)" |
109 | "ORDER BY oid ASC LIMIT 1", | 107 | " ORDER BY oid ASC LIMIT 1", |
110 | 7), | 108 | 7), |
111 | GNUNET_PQ_make_prepare ("put", | 109 | GNUNET_PQ_make_prepare ("put", |
112 | "INSERT INTO gn090 (repl, type, prio, anonLevel, expire, rvalue, hash, vhash, value) " | 110 | "INSERT INTO gn090 (repl, type, prio, anonLevel, expire, rvalue, hash, vhash, value) " |
113 | "VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)", | 111 | "VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)", |
114 | 9), | 112 | 9), |
115 | GNUNET_PQ_make_prepare ("update", | 113 | GNUNET_PQ_make_prepare ("update", |
116 | "UPDATE gn090 " | 114 | "UPDATE gn090" |
117 | "SET prio = prio + $1, " | 115 | " SET prio = prio + $1," |
118 | "repl = repl + $2, " | 116 | " repl = repl + $2," |
119 | "expire = GREATEST(expire, $3) " | 117 | " expire = GREATEST(expire, $3)" |
120 | "WHERE hash = $4 AND vhash = $5", | 118 | " WHERE hash = $4 AND vhash = $5", |
121 | 5), | 119 | 5), |
122 | GNUNET_PQ_make_prepare ("decrepl", | 120 | GNUNET_PQ_make_prepare ("decrepl", |
123 | "UPDATE gn090 SET repl = GREATEST (repl - 1, 0) " | 121 | "UPDATE gn090 SET repl = GREATEST (repl - 1, 0) " |
@@ -141,11 +139,13 @@ init_connection (struct Plugin *plugin) | |||
141 | "ORDER BY repl DESC,RANDOM() LIMIT 1", | 139 | "ORDER BY repl DESC,RANDOM() LIMIT 1", |
142 | 0), | 140 | 0), |
143 | GNUNET_PQ_make_prepare ("delrow", | 141 | GNUNET_PQ_make_prepare ("delrow", |
144 | "DELETE FROM gn090 " "WHERE oid=$1", | 142 | "DELETE FROM gn090 " |
143 | "WHERE oid=$1", | ||
145 | 1), | 144 | 1), |
146 | GNUNET_PQ_make_prepare ("remove", "DELETE FROM gn090 " | 145 | GNUNET_PQ_make_prepare ("remove", |
147 | "WHERE hash = $1 AND " | 146 | "DELETE FROM gn090" |
148 | "value = $2", | 147 | " WHERE hash = $1 AND" |
148 | " value = $2", | ||
149 | 2), | 149 | 2), |
150 | GNUNET_PQ_make_prepare ("get_keys", | 150 | GNUNET_PQ_make_prepare ("get_keys", |
151 | "SELECT hash FROM gn090", | 151 | "SELECT hash FROM gn090", |