begin to rewritten test case
authorChristophe Genevey Metat <genevey.christophe@gmail.com>
Fri, 27 May 2016 13:51:30 +0000 (13:51 +0000)
committerChristophe Genevey Metat <genevey.christophe@gmail.com>
Fri, 27 May 2016 13:51:30 +0000 (13:51 +0000)
src/include/gnunet_my_lib.h
src/my/test_my.c

index dbd9f87f51648691805e5a0bdaeee2af85b6f890..43c66e751568dd121e39a20375e01d3491d74dfe 100644 (file)
@@ -140,6 +140,12 @@ GNUNET_MY_exec_prepared (struct GNUNET_MYSQL_Context *mc,
  */
 struct GNUNET_MY_ResultParam;
 
+/**
+ * Information we pass to #GNUNET_MY_extract_result() to
+ * initialize the arguments of the prepared statement.
+ */
+struct GNUNET_MY_ResultSpec;
+
 /**
  * Function called to convert input argument into SQL parameters.
  *
index 29c60f68da6fc87156715203781446b2b1913b6f..b20dbdc3a354c7c95d3c4dfb1dabfa05c296253e 100644 (file)
@@ -136,7 +136,7 @@ run_queries (MYSQL * mysql)
      u32 = 32;
      u64 = 64;
 
-     struct GNUNET_CONFIGURATION_Handle * configuration_handle = NULL;
+//     struct GNUNET_CONFIGURATION_Handle * configuration_handle = NULL;
 //     configuration_handle = GNUNET_CONFIGURATION_create();
 
 /*     char *query1 =  "INSERT INTO test_my ("
@@ -291,15 +291,78 @@ run_queries (MYSQL * mysql)
 }
 
 
-/** OK **/
+/** REWRITTEN THIS FUNCTION **/
 int 
 main (int argc, const char * const argv[])
 {
-     return GNUNET_OK;     
-//     MYSQL mysql ;
-//     MYSQL_RES *result;
+     //CREATE A CONTEXTE 
+     struct GNUNET_DATASTORE_PluginEnvironment *env;
+     struct GNUNET_MYSQL_Context *context;
+
+     GNUNET_log_setup (  "test-my",
+                         "WARNING",
+                         NULL);
+
+     context = GNUNET_MYSQL_context_create (NULL /* TO FIXE ***/, 
+                                             "datastore-mysql");
+
+     struct GNUNET_MYSQL_StatementHandle *statements_handle;
+     
+     statements_handle = GNUNET_MYSQL_statement_prepare (context,
+                                        "CREATE TABLE test_my("
+                                        "pub INT"
+                                        ", sig INT"
+                                        ", abs_time BIGINT"
+                                        ", forever BIGINT"
+                                        ", hash INT"
+                                        ", vsize VARCHAR"
+                                        ", u16 SMALLINT"
+                                        ", u32 INT"
+                                        ", u64 BIGINT"
+                                        ")");
+
+     //USE GNUNET_MY_exec_prepared
+     GNUNET_MY_exec_prepared(context,
+                              statements_handle,
+                              NULL);
+
+     if (GNUNET_OK != GNUNET_MYSQL_context_destroy (context))
+     {
+          //ERROR
+     }
+
+     return GNUNET_OK;
+
+/*  NEW VERSION TO FIXE   if (GNUNET_OK != 
+          mysql_prepare (&mysql))
+     {
+          GNUNET_break (0) ;
+          mysql_close (&mysql);
+          return 1;
+     }
+
+     int ret;
+     ret = run_queries (&mysql);
+
+     
+     if (mysql_query (&mysql, 
+                    "DROP TABLE test_my;"))
+     {
+          fprintf (stderr, "Failed to drop table : %s\n",
+                         mysql_error (&mysql));
+          mysql_close (&mysql);
+          return 1;
+     }
+
+*/
+/*  OLD VERSION (use SQL basic function)
+
+     ret = run_queries ();
+     
+     MYSQL mysql ;
+     MYSQL_RES *result;
 
-/*     int ret;
+     int ret;
 
      char *hote = "";
      char *pseudo = "";
@@ -375,6 +438,4 @@ main (int argc, const char * const argv[])
 
      return ret;
 */
-//     mysql_close (&mysql);
-//    return GNUNET_OK;
 }