aboutsummaryrefslogtreecommitdiff
path: root/src/my/test_my.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/my/test_my.c')
-rw-r--r--src/my/test_my.c81
1 files changed, 71 insertions, 10 deletions
diff --git a/src/my/test_my.c b/src/my/test_my.c
index c63a069bf..c9529cbaf 100644
--- a/src/my/test_my.c
+++ b/src/my/test_my.c
@@ -75,7 +75,7 @@ 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_my ("
80 " pub" 80 " pub"
81 ",sig" 81 ",sig"
@@ -107,6 +107,25 @@ 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*/
111 statements_handle_insert = GNUNET_MYSQL_statement_prepare (context,
112 "INSERT INTO test_my2 ("
113 " abs_time"
114 ",forever"
115 ",u16"
116 ",u32"
117 ",u64"
118 ") VALUES "
119 "( ?, ?, ?, ?, ?)");
120
121 struct GNUNET_MY_QueryParam params_insert[] = {
122 GNUNET_MY_query_param_absolute_time (&abs_time),
123 GNUNET_MY_query_param_absolute_time (&forever),
124 GNUNET_MY_query_param_uint16 (&u16),
125 GNUNET_MY_query_param_uint32 (&u32),
126 GNUNET_MY_query_param_uint64 (&u64),
127 GNUNET_MY_query_param_end
128 };
110 129
111 if (GNUNET_OK != GNUNET_MY_exec_prepared(context, 130 if (GNUNET_OK != GNUNET_MY_exec_prepared(context,
112 statements_handle_insert, 131 statements_handle_insert,
@@ -118,7 +137,7 @@ run_queries (struct GNUNET_MYSQL_Context *context)
118 137
119 138
120 139
121 statements_handle_select = GNUNET_MYSQL_statement_prepare (context, 140/* statements_handle_select = GNUNET_MYSQL_statement_prepare (context,
122 "SELECT" 141 "SELECT"
123 " pub" 142 " pub"
124 ",sig" 143 ",sig"
@@ -133,6 +152,16 @@ run_queries (struct GNUNET_MYSQL_Context *context)
133 " ORDER BY abs_time DESC " 152 " ORDER BY abs_time DESC "
134 " LIMIT 1;"); 153 " LIMIT 1;");
135 154
155*/
156 statements_handle_select = GNUNET_MYSQL_statement_prepare (context,
157 "SELECT"
158 " abs_time"
159 ",forever"
160 ",u16"
161 ",u32"
162 ",u64"
163 " FROM test_my2");
164
136 if (NULL == statements_handle_select) 165 if (NULL == statements_handle_select)
137 { 166 {
138 fprintf(stderr, "Failed to prepared statement SELECT\n"); 167 fprintf(stderr, "Failed to prepared statement SELECT\n");
@@ -151,7 +180,7 @@ run_queries (struct GNUNET_MYSQL_Context *context)
151 return 1; 180 return 1;
152 } 181 }
153 182
154 183/*
155 struct GNUNET_MY_ResultSpec results_select[] = { 184 struct GNUNET_MY_ResultSpec results_select[] = {
156 GNUNET_MY_result_spec_rsa_public_key (&pub2), 185 GNUNET_MY_result_spec_rsa_public_key (&pub2),
157 GNUNET_MY_result_spec_rsa_signature (&sig2), 186 GNUNET_MY_result_spec_rsa_signature (&sig2),
@@ -164,11 +193,26 @@ run_queries (struct GNUNET_MYSQL_Context *context)
164 GNUNET_MY_result_spec_uint64 (&u642), 193 GNUNET_MY_result_spec_uint64 (&u642),
165 GNUNET_MY_result_spec_end 194 GNUNET_MY_result_spec_end
166 }; 195 };
196*/
197 struct GNUNET_MY_ResultSpec results_select[] = {
198 GNUNET_MY_result_spec_absolute_time (&abs_time2),
199 GNUNET_MY_result_spec_absolute_time (&forever2),
200 GNUNET_MY_result_spec_uint16 (&u162),
201 GNUNET_MY_result_spec_uint32 (&u322),
202 GNUNET_MY_result_spec_uint64 (&u642),
203 GNUNET_MY_result_spec_end
204 };
167 205
168 ret = GNUNET_MY_extract_result (statements_handle_select, 206 ret = GNUNET_MY_extract_result (statements_handle_select,
169 NULL, 207 results_select);
170 results_select, 208
171 0); 209 GNUNET_break (abs_time.abs_value_us == abs_time2.abs_value_us);
210 GNUNET_break (forever.abs_value_us == forever2.abs_value_us);
211
212 GNUNET_break (16 == u162);
213 GNUNET_break (32 == u322);
214 GNUNET_break (64 == u642);
215
172 if (GNUNET_OK != ret) 216 if (GNUNET_OK != ret)
173 { 217 {
174 fprintf(stderr, "Failed to extract result\n"); 218 fprintf(stderr, "Failed to extract result\n");
@@ -212,7 +256,7 @@ main (int argc, const char * const argv[])
212 return 77; 256 return 77;
213 } 257 }
214 258
215 if (GNUNET_OK != GNUNET_MYSQL_statement_run (context, 259/* if (GNUNET_OK != GNUNET_MYSQL_statement_run (context,
216 "CREATE TABLE test_my(" 260 "CREATE TABLE test_my("
217 "pub INT NOT NULL" 261 "pub INT NOT NULL"
218 ", sig INT NOT NULL" 262 ", sig INT NOT NULL"
@@ -232,11 +276,28 @@ main (int argc, const char * const argv[])
232 276
233 return 1; 277 return 1;
234 } 278 }
279*/
280 if (GNUNET_OK != GNUNET_MYSQL_statement_run (context,
281 "CREATE TABLE test_my2("
282 " abs_time BIGINT NOT NULL"
283 ", forever BIGINT NOT NULL"
284 ", u16 SMALLINT NOT NULL"
285 ", u32 INT NOT NULL"
286 ", u64 BIGINT NOT NULL"
287 ")"))
288 {
289 fprintf (stderr,
290 "Failed to create table \n");
291 GNUNET_MYSQL_statements_invalidate (context);
292 GNUNET_MYSQL_context_destroy (context);
293
294 return 1;
295 }
235 296
236 ret = run_queries (context); 297 ret = run_queries (context);
237 298/*
238/* if(GNUNET_OK != GNUNET_MYSQL_statement_run (context, 299 if(GNUNET_OK != GNUNET_MYSQL_statement_run (context,
239 "DROP TABLE test_my")) 300 "DROP TABLE test_my2"))
240 { 301 {
241 fprintf (stderr, "Failed to drop table test_my\n"); 302 fprintf (stderr, "Failed to drop table test_my\n");
242 GNUNET_MYSQL_statements_invalidate (context); 303 GNUNET_MYSQL_statements_invalidate (context);