diff options
author | Christophe Genevey Metat <genevey.christophe@gmail.com> | 2016-05-30 15:54:38 +0000 |
---|---|---|
committer | Christophe Genevey Metat <genevey.christophe@gmail.com> | 2016-05-30 15:54:38 +0000 |
commit | 295a7ab56564369098a12e2cc39fac0d5225c465 (patch) | |
tree | 7b42713d62e56b60c070f8db13a67c38bacb0122 /src/my | |
parent | b5454a701bde16ebc577fbb87d09f5dc1ead587e (diff) | |
download | gnunet-295a7ab56564369098a12e2cc39fac0d5225c465.tar.gz gnunet-295a7ab56564369098a12e2cc39fac0d5225c465.zip |
create table for test case fixed
Diffstat (limited to 'src/my')
-rw-r--r-- | src/my/Makefile.am | 1 | ||||
-rw-r--r-- | src/my/test_my.c | 473 |
2 files changed, 122 insertions, 352 deletions
diff --git a/src/my/Makefile.am b/src/my/Makefile.am index 7c0bc404e..9103be38e 100644 --- a/src/my/Makefile.am +++ b/src/my/Makefile.am | |||
@@ -35,6 +35,7 @@ test_my_SOURCES = \ | |||
35 | test_my.c | 35 | test_my.c |
36 | test_my_LDADD = \ | 36 | test_my_LDADD = \ |
37 | libgnunetmy.la \ | 37 | libgnunetmy.la \ |
38 | $(top_builddir)/src/mysql/libgnunetmysql.la \ | ||
38 | $(top_builddir)/src/util/libgnunetutil.la \ | 39 | $(top_builddir)/src/util/libgnunetutil.la \ |
39 | -lmysqlclient $(XLIB) | 40 | -lmysqlclient $(XLIB) |
40 | 41 | ||
diff --git a/src/my/test_my.c b/src/my/test_my.c index b20dbdc3a..8c088d807 100644 --- a/src/my/test_my.c +++ b/src/my/test_my.c | |||
@@ -25,417 +25,186 @@ | |||
25 | #include "platform.h" | 25 | #include "platform.h" |
26 | #include <mysql/mysql.h> | 26 | #include <mysql/mysql.h> |
27 | #include "gnunet_my_lib.h" | 27 | #include "gnunet_my_lib.h" |
28 | 28 | #include "gnunet_mysql_lib.h" | |
29 | /** | 29 | #include "gnunet_util_lib.h" |
30 | * Setup prepared statements. | ||
31 | * | ||
32 | * @param mysql connection handle to initialize | ||
33 | * @return | ||
34 | #GNUNET_OK on success | ||
35 | #GNUNET_SYSERR on failure | ||
36 | */ | ||
37 | |||
38 | /** OK **/ | ||
39 | static int | ||
40 | mysql_prepare (MYSQL * mysql) | ||
41 | { | ||
42 | MYSQL_STMT *stmt; | ||
43 | stmt = mysql_stmt_init (mysql); | ||
44 | #define PREPARE(name, sql, size) \ | ||
45 | do { \ | ||
46 | int ret = mysql_stmt_prepare (stmt, sql, size); \ | ||
47 | if (ret ) \ | ||
48 | { \ | ||
49 | GNUNET_break (0); \ | ||
50 | mysql_stmt_free_result (stmt); \ | ||
51 | return GNUNET_SYSERR; \ | ||
52 | } \ | ||
53 | mysql_stmt_free_result (stmt); \ | ||
54 | } while (0); | ||
55 | |||
56 | char *query1 = "INSERT INTO test_my (" | ||
57 | "pub" | ||
58 | ",sig" | ||
59 | ",abs_time" | ||
60 | ",forever" | ||
61 | ",hash" | ||
62 | ",vsize" | ||
63 | ",u16" | ||
64 | ",u32" | ||
65 | ",u64" | ||
66 | ") VALUES " | ||
67 | "(1, 2, 3, 4, 5, 6," | ||
68 | "7, 8, 9);"; | ||
69 | PREPARE("test_insert", | ||
70 | query1, | ||
71 | strlen (query1)); | ||
72 | |||
73 | char *query2 = "SELECT" | ||
74 | "pub" | ||
75 | ",sig" | ||
76 | ",abs_time" | ||
77 | ",forever" | ||
78 | ",hash" | ||
79 | ",vsize" | ||
80 | ",u16" | ||
81 | ",u32" | ||
82 | ",u64" | ||
83 | " FROM test_my" | ||
84 | " ORDER BY abs_time DESC" | ||
85 | " LIMIT 1;"; | ||
86 | |||
87 | PREPARE("test_select", | ||
88 | query2, | ||
89 | strlen (query2)); | ||
90 | |||
91 | return GNUNET_OK; | ||
92 | #undef PREPARE | ||
93 | } | ||
94 | 30 | ||
95 | /** | 31 | /** |
96 | * Run actual test queries. | 32 | * Run actual test queries. |
97 | * | 33 | * |
98 | * @param mysql coonection handle to initialize | 34 | * @param contexte the current context of mysql |
99 | * @return 0 on succes | 35 | * @return 0 on succes |
100 | */ | 36 | */ |
101 | |||
102 | /*** FIXE THIS FUNCTION ***/ | ||
103 | static int | 37 | static int |
104 | run_queries (MYSQL * mysql) | 38 | run_queries (struct GNUNET_MYSQL_Context *context) |
105 | { | 39 | { |
106 | struct GNUNET_CRYPTO_RsaPublicKey *pub; | 40 | const struct GNUNET_CRYPTO_RsaPublicKey *pub; |
107 | // struct GNUNET_CRYPTO_RsaPublicKey *pub2 = NULL; | ||
108 | struct GNUNET_CRYPTO_RsaSignature *sig; | 41 | struct GNUNET_CRYPTO_RsaSignature *sig; |
109 | // struct GNUNET_CRYPTO_RsaSignature *sig2 = NULL; | 42 | struct GNUNET_TIME_Absolute abs_time = GNUNET_TIME_absolute_get (); |
110 | struct GNUNET_TIME_Absolute abs_time = GNUNET_TIME_absolute_get () ; | ||
111 | // struct GNUNET_TIME_Absolute abs_time2; | ||
112 | struct GNUNET_TIME_Absolute forever = GNUNET_TIME_UNIT_FOREVER_ABS; | 43 | struct GNUNET_TIME_Absolute forever = GNUNET_TIME_UNIT_FOREVER_ABS; |
113 | // struct GNUNET_TIME_Absolute forever2; | ||
114 | struct GNUNET_HashCode hc; | 44 | struct GNUNET_HashCode hc; |
115 | // struct GNUNET_HashCode hc2; | ||
116 | // MYSQL_RES * result; | ||
117 | // int ret; | ||
118 | struct GNUNET_CRYPTO_RsaPrivateKey *priv; | ||
119 | const char msg[] = "hello"; | 45 | const char msg[] = "hello"; |
120 | // void *msg2; | ||
121 | struct GNUNET_HashCode hmsg; | ||
122 | // size_t msg2_len; | ||
123 | uint16_t u16; | 46 | uint16_t u16; |
124 | // uint16_t u162; | ||
125 | uint32_t u32; | 47 | uint32_t u32; |
126 | // uint32_t u322; | ||
127 | uint64_t u64; | 48 | uint64_t u64; |
128 | // uint64_t u642; | 49 | |
50 | struct GNUNET_MYSQL_StatementHandle *statements_handle_insert; | ||
51 | // struct GNUNET_MYSQL_StatementHandle *statements_handle_select; | ||
52 | |||
53 | struct GNUNET_CRYPTO_RsaPrivateKey *priv; | ||
54 | struct GNUNET_HashCode hmsg; | ||
129 | 55 | ||
130 | priv = GNUNET_CRYPTO_rsa_private_key_create (1024); | 56 | priv = GNUNET_CRYPTO_rsa_private_key_create (1024); |
131 | pub = GNUNET_CRYPTO_rsa_private_key_get_public (priv); | 57 | pub = GNUNET_CRYPTO_rsa_private_key_get_public (priv); |
132 | memset (&hmsg, 42, sizeof (hmsg)); | 58 | memset (&hmsg, 42, sizeof(hmsg)); |
133 | sig = GNUNET_CRYPTO_rsa_sign_fdh (priv, | 59 | sig = GNUNET_CRYPTO_rsa_sign_fdh (priv, |
134 | &hmsg); | 60 | &hmsg); |
135 | u16 = 16; | 61 | u16 = 16; |
136 | u32 = 32; | 62 | u32 = 32; |
137 | u64 = 64; | 63 | u64 = 64; |
138 | 64 | ||
139 | // struct GNUNET_CONFIGURATION_Handle * configuration_handle = NULL; | 65 | statements_handle_insert = GNUNET_MYSQL_statement_prepare (context, |
140 | // configuration_handle = GNUNET_CONFIGURATION_create(); | 66 | "INSERT INTO test_my (" |
141 | 67 | " pub" | |
142 | /* char *query1 = "INSERT INTO test_my (" | 68 | ",sig" |
143 | "pub" | 69 | ",abs_time" |
144 | ",sig" | 70 | ",forever" |
145 | ",abs_time" | 71 | ",hash" |
146 | ",forever" | 72 | ",vsize" |
147 | ",hash" | 73 | ",u16" |
148 | ",vsize" | 74 | ",u32" |
149 | ",u16" | 75 | ",u64" |
150 | ",u32" | 76 | ") VALUES " |
151 | ",u64" | 77 | "($1, $2, $3, $4, $5, $6," |
152 | ") VALUES " | 78 | "$7, $8, $9)"); |
153 | "(1, 2, 3, 4, 5, 6," | 79 | |
154 | "7, 8, 9);"; | 80 | if (NULL == statements_handle_insert) |
155 | */ | 81 | { |
156 | /* char *query2 = "SELECT" | 82 | fprintf(stderr, "Failed to prepared statement INSERT\n"); |
157 | "pub" | 83 | return 1; |
158 | ",sig" | 84 | } |
159 | ",abs_time" | ||
160 | ",forever" | ||
161 | ",hash" | ||
162 | ",vsize" | ||
163 | ",u16" | ||
164 | ",u32" | ||
165 | ",u64" | ||
166 | " FROM test_my" | ||
167 | " ORDER BY abs_time DESC" | ||
168 | " LIMIT 1;"; | ||
169 | */ | ||
170 | struct GNUNET_MYSQL_Context *context_insert = NULL; | ||
171 | // context_insert = GNUNET_MYSQL_context_create (configuration_handle, | ||
172 | // NULL); | ||
173 | |||
174 | struct GNUNET_MYSQL_StatementHandle *statements_handle = NULL; | ||
175 | // statements_handle = GNUNET_MYSQL_statement_prepare(context_insert, query1); | ||
176 | |||
177 | |||
178 | // { | ||
179 | struct GNUNET_MY_QueryParam params_insert[] = { | ||
180 | GNUNET_MY_query_param_rsa_public_key (pub), | ||
181 | GNUNET_MY_query_param_rsa_signature (sig), | ||
182 | GNUNET_MY_query_param_absolute_time (&abs_time), | ||
183 | GNUNET_MY_query_param_absolute_time (&forever), | ||
184 | GNUNET_MY_query_param_auto_from_type (&hc), | ||
185 | GNUNET_MY_query_param_fixed_size (msg, strlen (msg)), | ||
186 | GNUNET_MY_query_param_uint16 (&u16), | ||
187 | GNUNET_MY_query_param_uint32 (&u32), | ||
188 | GNUNET_MY_query_param_uint64 (&u64), | ||
189 | GNUNET_MY_query_param_end | ||
190 | }; | ||
191 | |||
192 | /* struct GNUNET_MY_QueryParam params_select[] = { | ||
193 | GNUNET_MY_query_param_end | ||
194 | }; | ||
195 | |||
196 | struct GNUNET_MY_Context *context_insert[] = { | ||
197 | |||
198 | }; | ||
199 | |||
200 | struct GNUNET_MY_StatementHandle *statement_insert[] = { | ||
201 | |||
202 | }; | ||
203 | */ | ||
204 | /* struct GNUNET_MY_ResultSpec results_select[] = { | ||
205 | GNUNET_MY_result_spec_rsa_public_key (&pub2), | ||
206 | GNUNET_MY_result_spec_rsa_signature (&sig2), | ||
207 | GNUNET_MY_result_spec_absolute_time (&abs_time2), | ||
208 | GNUNET_MY_result_spec_absolute_time (&forever2), | ||
209 | GNUNET_MY_result_spec_auto_from_type (&hc2), | ||
210 | GNUNET_MY_result_spec_variable_size (&msg2, &msg2_len), | ||
211 | GNUNET_MY_result_spec_uint16 (&u162), | ||
212 | GNUNET_MY_result_spec_uint32 (&u322), | ||
213 | GNUNET_MY_result_spec_uint64 (&u642), | ||
214 | GNUNET_MY_result_spec_end | ||
215 | }; | ||
216 | */ | ||
217 | if(GNUNET_MY_exec_prepared ( context_insert, | ||
218 | statements_handle, | ||
219 | params_insert)); | ||
220 | { | ||
221 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
222 | "Database failure: \n"); | ||
223 | |||
224 | //free result | ||
225 | |||
226 | GNUNET_CRYPTO_rsa_signature_free (sig); | ||
227 | GNUNET_CRYPTO_rsa_private_key_free (priv); | ||
228 | GNUNET_CRYPTO_rsa_public_key_free (pub); | ||
229 | return 1; | ||
230 | } | ||
231 | |||
232 | //free result | ||
233 | |||
234 | /* result = GNUNET_MY_exec_prepared (mysql, "test_select", params_select); | ||
235 | if(1 != mysql_fetch_length (result)) | ||
236 | { | ||
237 | GNUNET_break (0); | ||
238 | GNUNET_CRYPTO_rsa_signature_free (sig); | ||
239 | GNUNET_CRYPTO_rsa_private_key_free (priv); | ||
240 | GNUNET_CRYPTO_rsa_public_key_free (pub); | ||
241 | |||
242 | return 1; | ||
243 | } | ||
244 | |||
245 | if (GNUNET_MY_exec_prepared (mysql | ||
246 | , "test_select" | ||
247 | , params_select)) | ||
248 | { | ||
249 | GNUNET_break (0); | ||
250 | GNUNET_CRYPTO_rsa_signature_free (sig); | ||
251 | GNUNET_CRYPTO_rsa_private_key_free (priv); | ||
252 | GNUNET_CRYPTO_rsa_public_key_free (pub); | ||
253 | 85 | ||
254 | return 1; | 86 | struct GNUNET_MY_QueryParam params_insert[] = { |
255 | } | 87 | GNUNET_MY_query_param_rsa_public_key (pub), |
88 | GNUNET_MY_query_param_rsa_signature (sig), | ||
89 | GNUNET_MY_query_param_absolute_time (&abs_time), | ||
90 | GNUNET_MY_query_param_absolute_time (&forever), | ||
91 | GNUNET_MY_query_param_auto_from_type (&hc), | ||
92 | GNUNET_MY_query_param_fixed_size (msg, strlen (msg)), | ||
93 | GNUNET_MY_query_param_uint16 (&u16), | ||
94 | GNUNET_MY_query_param_uint32 (&u32), | ||
95 | GNUNET_MY_query_param_uint64 (&u64), | ||
96 | GNUNET_MY_query_param_end | ||
97 | }; | ||
98 | |||
99 | //FAIL HERE | ||
100 | if (GNUNET_OK != GNUNET_MY_exec_prepared (context, | ||
101 | statements_handle_insert, | ||
102 | params_insert)) | ||
103 | { | ||
104 | fprintf (stderr, "Failed to execute prepared statement\n"); | ||
105 | return 22; | ||
106 | } | ||
107 | /* statements_handle_select = GNUNET_MYSQL_statement_prepare (context, | ||
108 | "SELECT" | ||
109 | " pub" | ||
110 | ",sig" | ||
111 | ",abs_time" | ||
112 | ",forever" | ||
113 | ",hash" | ||
114 | ",vsize" | ||
115 | ",u16" | ||
116 | ",u32" | ||
117 | ",u64" | ||
118 | " FROM test_my" | ||
119 | " ORDER BY abs_time DESC " | ||
120 | " LIMIT 1;"); | ||
121 | |||
122 | if (NULL == statements_handle_select) | ||
123 | { | ||
124 | fprintf(stderr, "Failed to prepared statement SELECT\n"); | ||
125 | return 1; | ||
126 | } | ||
256 | 127 | ||
128 | struct GNUNET_MY_QueryParam params_select[] = { | ||
129 | GNUNET_MY_query_param_end | ||
130 | }; | ||
257 | 131 | ||
258 | ret = GNUNET_MY_extract_result (result, | 132 | if (GNUNET_OK != GNUNET_MY_exec_prepared (context, |
259 | results_select, | 133 | statements_handle_select, |
260 | 0); | 134 | params_select)) |
261 | GNUNET_break (GNUNET_YES == ret); | 135 | { |
262 | GNUNET_break (abs_time.abs_value_us == abs_time2.abs_value_us); | 136 | fprintf (stderr, "Failed to execute prepared statement\n"); |
263 | GNUNET_break (forever.abs_value_us == forever2.abs_value_us); | 137 | return 22; |
264 | GNUNET_break (0 == | ||
265 | memcmp (&hc, | ||
266 | &hc2, | ||
267 | sizeof (struct GNUNET_HashCode))); | ||
268 | GNUNET_break (0 == | ||
269 | GNUNET_CRYPTO_rsa_signature_cmp (sig, | ||
270 | sig2)); | ||
271 | GNUNET_break (0 == | ||
272 | GNUNET_CRYPTO_rsa_public_key_cmp (pub, | ||
273 | pub2)); | ||
274 | GNUNET_break (strlen (msg) == msg2_len); | ||
275 | GNUNET_break (0 == | ||
276 | strncmp (msg, | ||
277 | msg2, | ||
278 | msg2_len)); | ||
279 | GNUNET_break (16 == u162); | ||
280 | GNUNET_break (32 == u322); | ||
281 | GNUNET_break (64 == u642); | ||
282 | } | 138 | } |
283 | 139 | */ | |
284 | GNUNET_CRYPTO_rsa_signature_free (sig); | 140 | return 0; |
285 | GNUNET_CRYPTO_rsa_private_key_free (priv); | ||
286 | GNUNET_CRYPTO_rsa_public_key_free (pub); | ||
287 | |||
288 | if (GNUNET_OK != ret) | ||
289 | return 1; | ||
290 | */ return 0; | ||
291 | } | 141 | } |
292 | 142 | ||
293 | 143 | ||
294 | /** REWRITTEN THIS FUNCTION **/ | ||
295 | int | 144 | int |
296 | main (int argc, const char * const argv[]) | 145 | main (int argc, const char * const argv[]) |
297 | { | 146 | { |
298 | //CREATE A CONTEXTE | 147 | struct GNUNET_CONFIGURATION_Handle *config; |
299 | struct GNUNET_DATASTORE_PluginEnvironment *env; | ||
300 | struct GNUNET_MYSQL_Context *context; | 148 | struct GNUNET_MYSQL_Context *context; |
301 | 149 | ||
150 | int ret; | ||
151 | |||
302 | GNUNET_log_setup ( "test-my", | 152 | GNUNET_log_setup ( "test-my", |
303 | "WARNING", | 153 | "WARNING", |
304 | NULL); | 154 | NULL); |
305 | 155 | ||
306 | context = GNUNET_MYSQL_context_create (NULL /* TO FIXE ***/, | 156 | config = GNUNET_CONFIGURATION_create (); |
307 | "datastore-mysql"); | 157 | if (NULL == config) |
308 | |||
309 | struct GNUNET_MYSQL_StatementHandle *statements_handle; | ||
310 | |||
311 | statements_handle = GNUNET_MYSQL_statement_prepare (context, | ||
312 | "CREATE TABLE test_my(" | ||
313 | "pub INT" | ||
314 | ", sig INT" | ||
315 | ", abs_time BIGINT" | ||
316 | ", forever BIGINT" | ||
317 | ", hash INT" | ||
318 | ", vsize VARCHAR" | ||
319 | ", u16 SMALLINT" | ||
320 | ", u32 INT" | ||
321 | ", u64 BIGINT" | ||
322 | ")"); | ||
323 | |||
324 | //USE GNUNET_MY_exec_prepared | ||
325 | GNUNET_MY_exec_prepared(context, | ||
326 | statements_handle, | ||
327 | NULL); | ||
328 | |||
329 | if (GNUNET_OK != GNUNET_MYSQL_context_destroy (context)) | ||
330 | { | ||
331 | //ERROR | ||
332 | } | ||
333 | |||
334 | return GNUNET_OK; | ||
335 | |||
336 | /* NEW VERSION TO FIXE if (GNUNET_OK != | ||
337 | mysql_prepare (&mysql)) | ||
338 | { | 158 | { |
339 | GNUNET_break (0) ; | 159 | fprintf (stderr, "Failed to create a configuration\n"); |
340 | mysql_close (&mysql); | ||
341 | return 1; | 160 | return 1; |
342 | } | 161 | } |
343 | 162 | ||
344 | int ret; | 163 | if (GNUNET_OK != GNUNET_CONFIGURATION_parse (config, "test_my.conf")) |
345 | ret = run_queries (&mysql); | ||
346 | |||
347 | |||
348 | if (mysql_query (&mysql, | ||
349 | "DROP TABLE test_my;")) | ||
350 | { | 164 | { |
351 | fprintf (stderr, "Failed to drop table : %s\n", | 165 | fprintf (stderr, "Failed to parse configuaration\n"); |
352 | mysql_error (&mysql)); | ||
353 | mysql_close (&mysql); | ||
354 | return 1; | 166 | return 1; |
355 | } | 167 | } |
356 | 168 | ||
357 | */ | 169 | context = GNUNET_MYSQL_context_create (config, |
358 | /* OLD VERSION (use SQL basic function) | 170 | "datastore-mysql"); |
359 | 171 | if (NULL == context) | |
360 | ret = run_queries (); | ||
361 | |||
362 | MYSQL mysql ; | ||
363 | MYSQL_RES *result; | ||
364 | |||
365 | int ret; | ||
366 | |||
367 | char *hote = ""; | ||
368 | char *pseudo = ""; | ||
369 | char *mdp = ""; | ||
370 | char *database = ""; | ||
371 | |||
372 | mysql_init (&mysql); | ||
373 | |||
374 | mysql_options (&mysql, | ||
375 | MYSQL_READ_DEFAULT_GROUP, | ||
376 | NULL); | ||
377 | |||
378 | GNUNET_log_setup ( "test-my", | ||
379 | "WARNING", | ||
380 | NULL); | ||
381 | |||
382 | if ( mysql_real_connect (&mysql | ||
383 | ,hote | ||
384 | ,pseudo | ||
385 | ,mdp,database | ||
386 | ,0 | ||
387 | ,NULL | ||
388 | ,0 | ||
389 | )) | ||
390 | { | 172 | { |
391 | fprintf( stderr, | 173 | fprintf(stderr, "Failed to connect to database\n"); |
392 | "Cannot run test, database connection failed : %s\n", | 174 | return 77; |
393 | mysql_error (&mysql)); | ||
394 | GNUNET_break (0); | ||
395 | return 0; | ||
396 | } | 175 | } |
397 | 176 | ||
398 | if (mysql_query (&mysql, "CREATE TABLE test_my(" | 177 | if (GNUNET_OK != GNUNET_MYSQL_statement_run (context, |
399 | "pub INT" | 178 | "CREATE TABLE test_my(" |
400 | ", sig INT" | 179 | "pub INT NOT NULL" |
401 | ", abs_time BIGINT" | 180 | ", sig INT NOT NULL" |
402 | ", forever BIGINT" | 181 | ", abs_time BIGINT NOT NULL" |
403 | ", hash INT" | 182 | ", forever BIGINT NOT NULL" |
404 | ", vsize VARCHAR" | 183 | ", hash INT NOT NULL CHECK(LENGTH(hash)=64)" |
405 | ", u16 SMALLINT" | 184 | ", vsize VARCHAR(32) NOT NULL" |
406 | ", u32 INT" | 185 | ", u16 SMALLINT NOT NULL" |
407 | ", u64 BIGINT" | 186 | ", u32 INT NOT NULL" |
408 | ")")) | 187 | ", u64 BIGINT NOT NULL" |
188 | ")")) | ||
409 | { | 189 | { |
410 | fprintf (stderr, | 190 | fprintf (stderr, |
411 | "Failed to create table : %s\n", | 191 | "Failed to create table \n"); |
412 | mysql_error (&mysql)); | 192 | GNUNET_MYSQL_statements_invalidate (context); |
413 | 193 | GNUNET_MYSQL_context_destroy (context); | |
414 | mysql_close (&mysql); | 194 | |
415 | return 1; | ||
416 | } | ||
417 | |||
418 | if (GNUNET_OK != | ||
419 | mysql_prepare (&mysql)) | ||
420 | { | ||
421 | GNUNET_break (0) ; | ||
422 | mysql_close (&mysql); | ||
423 | return 1; | 195 | return 1; |
424 | } | 196 | } |
425 | 197 | ||
426 | ret = run_queries (&mysql); | 198 | ret = run_queries (context); |
427 | 199 | ||
428 | if (mysql_query (&mysql, | 200 | if(GNUNET_OK != GNUNET_MYSQL_statement_run (context, |
429 | "DROP TABLE test_my;")) | 201 | "DROP TABLE test_my")) |
430 | { | 202 | { |
431 | fprintf (stderr, "Failed to drop table : %s\n", | 203 | fprintf (stderr, "Failed to drop table test_my\n"); |
432 | mysql_error (&mysql)); | 204 | GNUNET_MYSQL_statements_invalidate (context); |
433 | mysql_close (&mysql); | ||
434 | return 1; | ||
435 | } | 205 | } |
436 | 206 | ||
437 | mysql_close (&mysql); | 207 | GNUNET_MYSQL_context_destroy (context); |
438 | 208 | ||
439 | return ret; | 209 | return ret; |
440 | */ | ||
441 | } | 210 | } |