aboutsummaryrefslogtreecommitdiff
path: root/src/my/test_my.c
diff options
context:
space:
mode:
authorChristophe Genevey Metat <genevey.christophe@gmail.com>2016-06-06 16:11:56 +0000
committerChristophe Genevey Metat <genevey.christophe@gmail.com>2016-06-06 16:11:56 +0000
commit3b680a20ab2cbb98cfa658d85be7a44baaf95d2c (patch)
tree6217c36e0ace8a7892a0a1567f13e9985903c7d6 /src/my/test_my.c
parent67dc0efd426a379b818155ed87f3c1a76d9e352f (diff)
downloadgnunet-3b680a20ab2cbb98cfa658d85be7a44baaf95d2c.tar.gz
gnunet-3b680a20ab2cbb98cfa658d85be7a44baaf95d2c.zip
continue to fix extract result
Diffstat (limited to 'src/my/test_my.c')
-rw-r--r--src/my/test_my.c50
1 files changed, 33 insertions, 17 deletions
diff --git a/src/my/test_my.c b/src/my/test_my.c
index c9529cbaf..af15b6ab2 100644
--- a/src/my/test_my.c
+++ b/src/my/test_my.c
@@ -75,8 +75,8 @@ run_queries (struct GNUNET_MYSQL_Context *context)
75 u32 = 32; 75 u32 = 32;
76 u64 = 64; 76 u64 = 64;
77 77
78/* statements_handle_insert = GNUNET_MYSQL_statement_prepare (context, 78 statements_handle_insert = GNUNET_MYSQL_statement_prepare (context,
79 "INSERT INTO test_my (" 79 "INSERT INTO test_my2 ("
80 " pub" 80 " pub"
81 ",sig" 81 ",sig"
82 ",abs_time" 82 ",abs_time"
@@ -107,26 +107,28 @@ run_queries (struct GNUNET_MYSQL_Context *context)
107 GNUNET_MY_query_param_uint64 (&u64), 107 GNUNET_MY_query_param_uint64 (&u64),
108 GNUNET_MY_query_param_end 108 GNUNET_MY_query_param_end
109 }; 109 };
110*/ 110
111 statements_handle_insert = GNUNET_MYSQL_statement_prepare (context, 111 /* statements_handle_insert = GNUNET_MYSQL_statement_prepare (context,
112 "INSERT INTO test_my2 (" 112 "INSERT INTO test_my2 ("
113 " abs_time" 113 " abs_time"
114 ",forever" 114 ",forever"
115 ",hash"
115 ",u16" 116 ",u16"
116 ",u32" 117 ",u32"
117 ",u64" 118 ",u64"
118 ") VALUES " 119 ") VALUES "
119 "( ?, ?, ?, ?, ?)"); 120 "( ?, ?, ?, ?, ?, ?)");
120 121
121 struct GNUNET_MY_QueryParam params_insert[] = { 122 struct GNUNET_MY_QueryParam params_insert[] = {
122 GNUNET_MY_query_param_absolute_time (&abs_time), 123 GNUNET_MY_query_param_absolute_time (&abs_time),
123 GNUNET_MY_query_param_absolute_time (&forever), 124 GNUNET_MY_query_param_absolute_time (&forever),
125 GNUNET_MY_query_param_auto_from_type (&hc),
124 GNUNET_MY_query_param_uint16 (&u16), 126 GNUNET_MY_query_param_uint16 (&u16),
125 GNUNET_MY_query_param_uint32 (&u32), 127 GNUNET_MY_query_param_uint32 (&u32),
126 GNUNET_MY_query_param_uint64 (&u64), 128 GNUNET_MY_query_param_uint64 (&u64),
127 GNUNET_MY_query_param_end 129 GNUNET_MY_query_param_end
128 }; 130 };
129 131*/
130 if (GNUNET_OK != GNUNET_MY_exec_prepared(context, 132 if (GNUNET_OK != GNUNET_MY_exec_prepared(context,
131 statements_handle_insert, 133 statements_handle_insert,
132 params_insert)) 134 params_insert))
@@ -155,8 +157,12 @@ run_queries (struct GNUNET_MYSQL_Context *context)
155*/ 157*/
156 statements_handle_select = GNUNET_MYSQL_statement_prepare (context, 158 statements_handle_select = GNUNET_MYSQL_statement_prepare (context,
157 "SELECT" 159 "SELECT"
160 //" pub"
161 //" sig"
158 " abs_time" 162 " abs_time"
159 ",forever" 163 ",forever"
164 ",hash"
165 //" vsize"
160 ",u16" 166 ",u16"
161 ",u32" 167 ",u32"
162 ",u64" 168 ",u64"
@@ -195,8 +201,12 @@ run_queries (struct GNUNET_MYSQL_Context *context)
195 }; 201 };
196*/ 202*/
197 struct GNUNET_MY_ResultSpec results_select[] = { 203 struct GNUNET_MY_ResultSpec results_select[] = {
204 //GNUNET_MY_result_spec_rsa_public_key (&pub2),
205 //GNUNET_MY_result_spec_rsa_signature (&sig2),
198 GNUNET_MY_result_spec_absolute_time (&abs_time2), 206 GNUNET_MY_result_spec_absolute_time (&abs_time2),
199 GNUNET_MY_result_spec_absolute_time (&forever2), 207 GNUNET_MY_result_spec_absolute_time (&forever2),
208 GNUNET_MY_result_spec_auto_from_type (&hc2),
209 //GNUNET_MY_result_spec_variable_size (&msg2, &msg2_len),
200 GNUNET_MY_result_spec_uint16 (&u162), 210 GNUNET_MY_result_spec_uint16 (&u162),
201 GNUNET_MY_result_spec_uint32 (&u322), 211 GNUNET_MY_result_spec_uint32 (&u322),
202 GNUNET_MY_result_spec_uint64 (&u642), 212 GNUNET_MY_result_spec_uint64 (&u642),
@@ -206,8 +216,13 @@ run_queries (struct GNUNET_MYSQL_Context *context)
206 ret = GNUNET_MY_extract_result (statements_handle_select, 216 ret = GNUNET_MY_extract_result (statements_handle_select,
207 results_select); 217 results_select);
208 218
219 GNUNET_break (GNUNET_YES == ret);
209 GNUNET_break (abs_time.abs_value_us == abs_time2.abs_value_us); 220 GNUNET_break (abs_time.abs_value_us == abs_time2.abs_value_us);
210 GNUNET_break (forever.abs_value_us == forever2.abs_value_us); 221 GNUNET_break (forever.abs_value_us == forever2.abs_value_us);
222 GNUNET_break (0 ==
223 memcmp (&hc,
224 &hc2,
225 sizeof (struct GNUNET_HashCode)));
211 226
212 GNUNET_break (16 == u162); 227 GNUNET_break (16 == u162);
213 GNUNET_break (32 == u322); 228 GNUNET_break (32 == u322);
@@ -256,14 +271,14 @@ main (int argc, const char * const argv[])
256 return 77; 271 return 77;
257 } 272 }
258 273
259/* if (GNUNET_OK != GNUNET_MYSQL_statement_run (context, 274 if (GNUNET_OK != GNUNET_MYSQL_statement_run (context,
260 "CREATE TABLE test_my(" 275 "CREATE TABLE test_my2("
261 "pub INT NOT NULL" 276 "pub BLOB NOT NULL"
262 ", sig INT NOT NULL" 277 ", sig BLOB NOT NULL"
263 ", abs_time BIGINT NOT NULL" 278 ", abs_time BIGINT NOT NULL"
264 ", forever BIGINT NOT NULL" 279 ", forever BIGINT NOT NULL"
265 ", hash VARCHAR(32) NOT NULL CHECK(LENGTH(hash)=64)" 280 ", hash BLOB NOT NULL CHECK(LENGTH(hash)=64)"
266 ", vsize VARCHAR(32) NOT NULL" 281 ", vsize BLOB NOT NULL"
267 ", u16 SMALLINT NOT NULL" 282 ", u16 SMALLINT NOT NULL"
268 ", u32 INT NOT NULL" 283 ", u32 INT NOT NULL"
269 ", u64 BIGINT NOT NULL" 284 ", u64 BIGINT NOT NULL"
@@ -276,11 +291,12 @@ main (int argc, const char * const argv[])
276 291
277 return 1; 292 return 1;
278 } 293 }
279*/ 294
280 if (GNUNET_OK != GNUNET_MYSQL_statement_run (context, 295/* if (GNUNET_OK != GNUNET_MYSQL_statement_run (context,
281 "CREATE TABLE test_my2(" 296 "CREATE TABLE test_my2("
282 " abs_time BIGINT NOT NULL" 297 " abs_time BIGINT NOT NULL"
283 ", forever BIGINT NOT NULL" 298 ", forever BIGINT NOT NULL"
299 ", hash VARCHAR(32) NOT NULL CHECK(LENGTH(hash)=64)"
284 ", u16 SMALLINT NOT NULL" 300 ", u16 SMALLINT NOT NULL"
285 ", u32 INT NOT NULL" 301 ", u32 INT NOT NULL"
286 ", u64 BIGINT NOT NULL" 302 ", u64 BIGINT NOT NULL"
@@ -293,10 +309,10 @@ main (int argc, const char * const argv[])
293 309
294 return 1; 310 return 1;
295 } 311 }
296 312*/
297 ret = run_queries (context); 313 ret = run_queries (context);
298/* 314
299 if(GNUNET_OK != GNUNET_MYSQL_statement_run (context, 315/* if(GNUNET_OK != GNUNET_MYSQL_statement_run (context,
300 "DROP TABLE test_my2")) 316 "DROP TABLE test_my2"))
301 { 317 {
302 fprintf (stderr, "Failed to drop table test_my\n"); 318 fprintf (stderr, "Failed to drop table test_my\n");