gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r37242 - gnunet/src/my


From: gnunet
Subject: [GNUnet-SVN] r37242 - gnunet/src/my
Date: Mon, 6 Jun 2016 18:11:57 +0200

Author: christophe.genevey
Date: 2016-06-06 18:11:56 +0200 (Mon, 06 Jun 2016)
New Revision: 37242

Modified:
   gnunet/src/my/my.c
   gnunet/src/my/my_query_helper.c
   gnunet/src/my/my_result_helper.c
   gnunet/src/my/test_my.c
Log:
continue to fix extract result

Modified: gnunet/src/my/my.c
===================================================================
--- gnunet/src/my/my.c  2016-06-03 16:08:23 UTC (rev 37241)
+++ gnunet/src/my/my.c  2016-06-06 16:11:56 UTC (rev 37242)
@@ -173,7 +173,16 @@
                        mysql_stmt_error (stmt));
       return GNUNET_SYSERR;
     }
+
     ret = mysql_stmt_fetch (stmt);
+
+    if (MYSQL_DATA_TRUNCATED == ret)
+    {
+       fprintf(stderr, "Data truncated with error %d \n", ret);
+       fprintf(stderr, "nontruncated length of the parameter values : %d\n", 
rs[0].mysql_bind_output_length);
+       return GNUNET_SYSERR;
+    }
+    
     if (MYSQL_NO_DATA == ret)
       return GNUNET_NO;
     if (0 != ret)

Modified: gnunet/src/my/my_query_helper.c
===================================================================
--- gnunet/src/my/my_query_helper.c     2016-06-03 16:08:23 UTC (rev 37241)
+++ gnunet/src/my/my_query_helper.c     2016-06-06 16:11:56 UTC (rev 37242)
@@ -61,11 +61,11 @@
                                  size_t ptr_size)
 {
   struct GNUNET_MY_QueryParam qp = {
-    &my_conv_fixed_size,
-    NULL,
-    1,
-    ptr,
-    (unsigned long) ptr_size
+    .conv = &my_conv_fixed_size,
+    .conv_cls = NULL,
+    .num_params = 1,
+    .data = ptr,
+    .data_len = (unsigned long) ptr_size
   };
   return qp;
 }
@@ -125,11 +125,11 @@
 GNUNET_MY_query_param_uint16 (const uint16_t *x)
 {
   struct GNUNET_MY_QueryParam res = { 
-      &my_conv_uint16,
-      NULL,
-      1,
-      x,
-      sizeof (*x)
+      .conv = &my_conv_uint16,
+      .conv_cls = NULL,
+      .num_params = 1,
+      .data = x,
+      .data_len = sizeof (*x)
     };
 
   return res;
@@ -173,11 +173,11 @@
 GNUNET_MY_query_param_uint32 (const uint32_t *x)
 {
   struct GNUNET_MY_QueryParam res = {
-    &my_conv_uint32,
-    NULL,
-    1,
-    x, 
-    sizeof (*x)
+    .conv = &my_conv_uint32,
+    .conv_cls = NULL,
+    .num_params = 1,
+    .data = x, 
+    .data_len = sizeof (*x)
   };
   
   return res;
@@ -221,11 +221,11 @@
 GNUNET_MY_query_param_uint64 (const uint64_t *x)
 {
   struct GNUNET_MY_QueryParam res = {
-    &my_conv_uint64,
-    NULL,
-    1,
-    x,
-    sizeof(*x)
+    .conv = &my_conv_uint64,
+    .conv_cls = NULL,
+    .num_params = 1,
+    .data = x,
+    .data_len = sizeof(*x)
   };
 
   return res;
@@ -253,8 +253,8 @@
     buf_size = GNUNET_CRYPTO_rsa_public_key_encode (rsa, &buf);
 
     qbind->buffer = (void *)buf;
-    qbind->buffer_length = buf_size - 1;
-    qbind->buffer_type = MYSQL_TYPE_LONG;
+    qbind->buffer_length = buf_size-1;
+    qbind->buffer_type = MYSQL_TYPE_BLOB;
 
     return 1;
   }
@@ -270,11 +270,11 @@
 GNUNET_MY_query_param_rsa_public_key (const struct GNUNET_CRYPTO_RsaPublicKey 
*x)
 {
   struct GNUNET_MY_QueryParam res = {
-    &my_conv_rsa_public_key,
-    NULL,
-    1,
-    x,
-    0
+    .conv = &my_conv_rsa_public_key,
+    .conv_cls = NULL,
+    .num_params = 1,
+    .data = x,
+    .data_len = 0
   };
 
   return res;
@@ -303,8 +303,8 @@
                                                 &buf);
 
   qbind->buffer = (void *)buf;
-  qbind->buffer_length = buf_size - 1;
-  qbind->buffer_type = MYSQL_TYPE_LONG;
+  qbind->buffer_length = buf_size-1;
+  qbind->buffer_type = MYSQL_TYPE_BLOB;
 
   return 1;
 }
@@ -320,11 +320,11 @@
 GNUNET_MY_query_param_rsa_signature (const struct GNUNET_CRYPTO_RsaSignature 
*x)
 {
   struct GNUNET_MY_QueryParam res = {
-    &my_conv_rsa_signature,
-    NULL,
-    1,
-    (x),
-    0
+    .conv = &my_conv_rsa_signature,
+    .conv_cls = NULL,
+    .num_params = 1,
+    .data = (x),
+    .data_len = 0
   };
   return res;
 }

Modified: gnunet/src/my/my_result_helper.c
===================================================================
--- gnunet/src/my/my_result_helper.c    2016-06-03 16:08:23 UTC (rev 37241)
+++ gnunet/src/my/my_result_helper.c    2016-06-06 16:11:56 UTC (rev 37242)
@@ -37,9 +37,10 @@
                           unsigned int column,
                           MYSQL_BIND *results)
 {
-  results[0].buffer = 0;
+  results[0].buffer = NULL;
   results[0].buffer_length = 0;
   results[0].length = &rs->mysql_bind_output_length;
+  results[0].buffer_type = MYSQL_TYPE_BLOB;
 
   return GNUNET_OK;
 }
@@ -73,6 +74,7 @@
   buf = GNUNET_malloc (size);
   results[0].buffer = buf;
   results[0].buffer_length = size;
+
   if (0 !=
       mysql_stmt_fetch_column (stmt,
                                results,
@@ -235,10 +237,10 @@
                         MYSQL_BIND *results)
 
 {
-  results[0].buffer = 0;
+  results[0].buffer = NULL;
   results[0].buffer_length = 0;
-  results[0].length = rs->mysql_bind_output_length;
-  results[0].buffer_type = MYSQL_TYPE_LONG;
+  results[0].length = &rs->mysql_bind_output_length;
+  results[0].buffer_type = MYSQL_TYPE_BLOB;
 
   return GNUNET_OK;
 }
@@ -292,9 +294,6 @@
     return GNUNET_SYSERR;
   }
 
-  if (rs->dst_size != rs->mysql_bind_output_length)
-    return GNUNET_SYSERR;
-
   return GNUNET_OK;
 }
 
@@ -366,7 +365,7 @@
   results[0].buffer = 0;
   results[0].buffer_length = 0;
   results[0].length = &rs->mysql_bind_output_length;
-  results[0].buffer_type = MYSQL_TYPE_LONG;
+  results[0].buffer_type = MYSQL_TYPE_BLOB;
 
   return GNUNET_OK;
 }
@@ -391,8 +390,8 @@
                       MYSQL_BIND *results)
 {
   struct GNUNET_CRYPTO_RsaSignature **sig = rs->dst;
-  size_t size;
-  const char *res;
+  size_t size = 0 ;
+  char *res = NULL;
 
   results[0].buffer = res;
   results[0].buffer_length = size;

Modified: gnunet/src/my/test_my.c
===================================================================
--- gnunet/src/my/test_my.c     2016-06-03 16:08:23 UTC (rev 37241)
+++ gnunet/src/my/test_my.c     2016-06-06 16:11:56 UTC (rev 37242)
@@ -75,8 +75,8 @@
      u32 = 32;
      u64 = 64;
 
-/*     statements_handle_insert = GNUNET_MYSQL_statement_prepare (context,
-                                        "INSERT INTO test_my ("
+     statements_handle_insert = GNUNET_MYSQL_statement_prepare (context,
+                                        "INSERT INTO test_my2 ("
                                         " pub"
                                         ",sig"
                                         ",abs_time"
@@ -107,26 +107,28 @@
           GNUNET_MY_query_param_uint64 (&u64),
           GNUNET_MY_query_param_end
      };
-*/
-     statements_handle_insert = GNUNET_MYSQL_statement_prepare (context,
+
+ /*    statements_handle_insert = GNUNET_MYSQL_statement_prepare (context,
                                         "INSERT INTO test_my2 ("
                                         " abs_time"
                                         ",forever"
+                                        ",hash"
                                         ",u16"
                                         ",u32"
                                         ",u64"
                                         ") VALUES "
-                                        "( ?, ?, ?, ?, ?)");
+                                        "( ?, ?, ?, ?, ?, ?)");
 
       struct GNUNET_MY_QueryParam params_insert[] = {
           GNUNET_MY_query_param_absolute_time (&abs_time),
           GNUNET_MY_query_param_absolute_time (&forever),
+          GNUNET_MY_query_param_auto_from_type (&hc),
           GNUNET_MY_query_param_uint16 (&u16),
           GNUNET_MY_query_param_uint32 (&u32),
           GNUNET_MY_query_param_uint64 (&u64),
           GNUNET_MY_query_param_end
      };
-
+*/
      if (GNUNET_OK != GNUNET_MY_exec_prepared(context,
                                              statements_handle_insert,
                                              params_insert))
@@ -155,8 +157,12 @@
 */ 
      statements_handle_select = GNUNET_MYSQL_statement_prepare (context,
                                                                  "SELECT"
+                                                                 //" pub"
+                                                                 //" sig"
                                                                  " abs_time"
                                                                  ",forever"
+                                                                 ",hash"
+                                                                 //" vsize"
                                                                  ",u16"
                                                                  ",u32"
                                                                  ",u64"
@@ -195,8 +201,12 @@
      };
 */
      struct GNUNET_MY_ResultSpec results_select[] = {
+          //GNUNET_MY_result_spec_rsa_public_key (&pub2),
+          //GNUNET_MY_result_spec_rsa_signature (&sig2),
           GNUNET_MY_result_spec_absolute_time (&abs_time2),
           GNUNET_MY_result_spec_absolute_time (&forever2),
+          GNUNET_MY_result_spec_auto_from_type (&hc2),
+          //GNUNET_MY_result_spec_variable_size (&msg2, &msg2_len),
           GNUNET_MY_result_spec_uint16 (&u162),
           GNUNET_MY_result_spec_uint32 (&u322),
           GNUNET_MY_result_spec_uint64 (&u642),
@@ -206,8 +216,13 @@
      ret = GNUNET_MY_extract_result (statements_handle_select,
                                      results_select);
 
+     GNUNET_break (GNUNET_YES == ret);
      GNUNET_break (abs_time.abs_value_us == abs_time2.abs_value_us);
      GNUNET_break (forever.abs_value_us == forever2.abs_value_us);
+     GNUNET_break (0 ==
+                    memcmp (&hc,
+                            &hc2,
+                            sizeof (struct GNUNET_HashCode)));
 
      GNUNET_break (16 == u162);
      GNUNET_break (32 == u322);
@@ -256,14 +271,14 @@
           return 77;
      }
 
-/*     if (GNUNET_OK != GNUNET_MYSQL_statement_run (context,
-                                                  "CREATE TABLE test_my("
-                                                  "pub INT NOT NULL"
-                                                  ", sig INT NOT NULL"
+     if (GNUNET_OK != GNUNET_MYSQL_statement_run (context,
+                                                  "CREATE TABLE test_my2("
+                                                  "pub BLOB NOT NULL"
+                                                  ", sig BLOB NOT NULL"
                                                   ", abs_time BIGINT NOT NULL"
                                                   ", forever BIGINT NOT NULL"
-                                                  ", hash VARCHAR(32) NOT NULL 
CHECK(LENGTH(hash)=64)"
-                                                  ", vsize VARCHAR(32) NOT 
NULL"
+                                                  ", hash BLOB NOT NULL 
CHECK(LENGTH(hash)=64)"
+                                                  ", vsize BLOB NOT NULL"
                                                   ", u16 SMALLINT NOT NULL"
                                                   ", u32 INT NOT NULL"
                                                   ", u64 BIGINT NOT NULL"
@@ -276,11 +291,12 @@
           
           return 1;
      }
-*/
-     if (GNUNET_OK != GNUNET_MYSQL_statement_run (context,
+
+/*     if (GNUNET_OK != GNUNET_MYSQL_statement_run (context,
                                                   "CREATE TABLE test_my2("
                                                   " abs_time BIGINT NOT NULL"
                                                   ", forever BIGINT NOT NULL"
+                                                  ", hash VARCHAR(32) NOT NULL 
CHECK(LENGTH(hash)=64)"
                                                   ", u16 SMALLINT NOT NULL"
                                                   ", u32 INT NOT NULL"
                                                   ", u64 BIGINT NOT NULL"
@@ -293,10 +309,10 @@
           
           return 1;
      }
+*/
+     ret = run_queries (context);
 
-     ret = run_queries (context);
-/*
-     if(GNUNET_OK != GNUNET_MYSQL_statement_run (context,
+/*     if(GNUNET_OK != GNUNET_MYSQL_statement_run (context,
                                                   "DROP TABLE test_my2"))
      {
           fprintf (stderr, "Failed to drop table test_my\n");




reply via email to

[Prev in Thread] Current Thread [Next in Thread]