[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r37224 - in gnunet/src: include my
From: |
gnunet |
Subject: |
[GNUnet-SVN] r37224 - in gnunet/src: include my |
Date: |
Wed, 1 Jun 2016 19:13:39 +0200 |
Author: christophe.genevey
Date: 2016-06-01 19:13:39 +0200 (Wed, 01 Jun 2016)
New Revision: 37224
Modified:
gnunet/src/include/gnunet_my_lib.h
gnunet/src/my/my.c
gnunet/src/my/my_query_helper.c
gnunet/src/my/test_my.c
Log:
fixing insert query
Modified: gnunet/src/include/gnunet_my_lib.h
===================================================================
--- gnunet/src/include/gnunet_my_lib.h 2016-06-01 17:08:49 UTC (rev 37223)
+++ gnunet/src/include/gnunet_my_lib.h 2016-06-01 17:13:39 UTC (rev 37224)
@@ -99,7 +99,6 @@
};
-
/**
* End of query parameter specification.
*
Modified: gnunet/src/my/my.c
===================================================================
--- gnunet/src/my/my.c 2016-06-01 17:08:49 UTC (rev 37223)
+++ gnunet/src/my/my.c 2016-06-01 17:13:39 UTC (rev 37224)
@@ -81,6 +81,7 @@
GNUNET_MYSQL_statements_invalidate (mc);
return GNUNET_SYSERR;
}
+
}
if (mysql_stmt_execute (stmt))
{
@@ -91,6 +92,7 @@
GNUNET_MYSQL_statements_invalidate (mc);
return GNUNET_SYSERR;
}
+
return GNUNET_OK;
}
Modified: gnunet/src/my/my_query_helper.c
===================================================================
--- gnunet/src/my/my_query_helper.c 2016-06-01 17:08:49 UTC (rev 37223)
+++ gnunet/src/my/my_query_helper.c 2016-06-01 17:13:39 UTC (rev 37224)
@@ -43,9 +43,8 @@
qbind->buffer = (void *) qp->data;
qbind->buffer_length = qp->data_len;
- qbind->buffer_type = 1;
+ qbind->buffer_type = MYSQL_TYPE_BLOB;
- //return 0;
return 1;
}
@@ -100,18 +99,18 @@
const uint16_t *u_hbo = qp->data;
uint16_t *u_nbo;
- fprintf(stderr, "input data : %u\n", (unsigned)u_hbo);
-
GNUNET_assert (1 == qp->num_params);
u_nbo = GNUNET_new (uint16_t);
+ if (NULL == u_nbo)
+ return -1;
+
*u_nbo = htons (*u_hbo);
- fprintf(stderr, "output data : %u\n", (unsigned)u_nbo);
qbind->buffer = (void *) u_nbo;
qbind->buffer_length = sizeof(uint16_t);
- qbind->buffer_type = 1;
+ qbind->buffer_type = MYSQL_TYPE_SHORT;
return 1;
}
@@ -158,7 +157,7 @@
qbind->buffer = (void *) u_nbo;
qbind->buffer_length = sizeof(uint32_t);
- qbind->buffer_type = 1;
+ qbind->buffer_type = MYSQL_TYPE_LONG;
return 1;
}
@@ -205,7 +204,7 @@
qbind->buffer = (void *) u_nbo;
qbind->buffer_length = sizeof (uint64_t);
- qbind->buffer_type = 1;
+ qbind->buffer_type = MYSQL_TYPE_LONGLONG;
return 1;
}
@@ -252,7 +251,7 @@
qbind->buffer = (void *)buf;
qbind->buffer_length = buf_size - 1;
- qbind->buffer_type = 1;
+ qbind->buffer_type = MYSQL_TYPE_LONG;
return 1;
}
@@ -302,7 +301,7 @@
qbind->buffer = (void *)buf;
qbind->buffer_length = buf_size - 1;
- qbind->buffer_type = 1;
+ qbind->buffer_type = MYSQL_TYPE_LONG;
return 1;
}
Modified: gnunet/src/my/test_my.c
===================================================================
--- gnunet/src/my/test_my.c 2016-06-01 17:08:49 UTC (rev 37223)
+++ gnunet/src/my/test_my.c 2016-06-01 17:13:39 UTC (rev 37224)
@@ -37,17 +37,34 @@
static int
run_queries (struct GNUNET_MYSQL_Context *context)
{
- const struct GNUNET_CRYPTO_RsaPublicKey *pub;
+ struct GNUNET_CRYPTO_RsaPublicKey *pub;
+// struct GNUNET_CRYPTO_RsaPublicKey *pub2 = NULL;
struct GNUNET_CRYPTO_RsaSignature *sig;
+// struct GNUNET_CRYPTO_RsaSignature *sig2 = NULL;
struct GNUNET_TIME_Absolute abs_time = GNUNET_TIME_absolute_get ();
+// struct GNUNET_TIME_Absolute abs_time2;
struct GNUNET_TIME_Absolute forever = GNUNET_TIME_UNIT_FOREVER_ABS;
+// struct GNUNET_TIME_Absolute forever2;
struct GNUNET_HashCode hc;
+// struct GNUNET_HashCode hc2;
const char msg[] = "hello";
+// void *msg2;
+ size_t msg_len;
+// size_t msg2_len;
+
uint16_t u16;
+// uint16_t u162;
uint32_t u32;
+// uint32_t u322;
uint64_t u64;
+// uint64_t u642;
+ msg_len = sizeof(msg);
+
+// int ret;
+
struct GNUNET_MYSQL_StatementHandle *statements_handle_insert;
+
// struct GNUNET_MYSQL_StatementHandle *statements_handle_select;
struct GNUNET_CRYPTO_RsaPrivateKey *priv;
@@ -62,7 +79,6 @@
u32 = 32;
u64 = 64;
-// FIXE THE INSERT QUERY
statements_handle_insert = GNUNET_MYSQL_statement_prepare (context,
"INSERT INTO test_my ("
" pub"
@@ -75,8 +91,7 @@
",u32"
",u64"
") VALUES "
- "(?, ?, ?, ?, ?, ?,"
- "?, ?, ?)");
+ "( ?, ?, ?, ?, ?, ?, ?, ?, ?)");
if (NULL == statements_handle_insert)
{
@@ -84,7 +99,6 @@
return 1;
}
- //ERROR WITH MSG
struct GNUNET_MY_QueryParam params_insert[] = {
GNUNET_MY_query_param_rsa_public_key (pub),
GNUNET_MY_query_param_rsa_signature (sig),
@@ -98,21 +112,17 @@
GNUNET_MY_query_param_end
};
- fprintf(stderr, " u16 : %u\n", (unsigned)params_insert[6].data);
- fprintf(stderr, " &u16 : %u\n", (unsigned)&u16);
-
- //FAIL HERE
- if (GNUNET_OK != GNUNET_MY_exec_prepared (context,
+ if (GNUNET_OK != GNUNET_MY_exec_prepared(context,
statements_handle_insert,
params_insert))
{
- fprintf (stderr,
- "Failed to execute prepared statement\n");
- return 22;
+ fprintf (stderr, "Failed to execute prepared statement INSERT\n");
+ return 1;
}
-/* NOT THE GOOD FUNCTION -> TO FIXE
- statements_handle_select = GNUNET_MYSQL_statement_prepare (context,
+
+
+/* statements_handle_select = GNUNET_MYSQL_statement_prepare (context,
"SELECT"
" pub"
",sig"
@@ -141,9 +151,33 @@
statements_handle_select,
params_select))
{
- fprintf (stderr, "Failed to execute prepared statement\n");
- return 22;
+ fprintf (stderr, "Failed to execute prepared statement SELECT\n");
+ return 1;
}
+
+
+ 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),
+ GNUNET_MY_result_spec_end
+ };
+
+ ret = GNUNET_MY_extract_result (statements_handle_select,
+ NULL,
+ results_select,
+ 0);
+ if (GNUNET_OK != ret)
+ {
+ fprintf(stderr, "Failed to extract result\n");
+ return 1;
+ }
*/
return 0;
}
@@ -188,7 +222,7 @@
", sig INT NOT NULL"
", abs_time BIGINT NOT NULL"
", forever BIGINT NOT NULL"
- ", hash INT NOT NULL
CHECK(LENGTH(hash)=64)"
+ ", hash VARCHAR(32) NOT NULL
CHECK(LENGTH(hash)=64)"
", vsize VARCHAR(32) NOT
NULL"
", u16 SMALLINT NOT NULL"
", u32 INT NOT NULL"
@@ -205,13 +239,13 @@
ret = run_queries (context);
- if(GNUNET_OK != GNUNET_MYSQL_statement_run (context,
+/* if(GNUNET_OK != GNUNET_MYSQL_statement_run (context,
"DROP TABLE test_my"))
{
fprintf (stderr, "Failed to drop table test_my\n");
GNUNET_MYSQL_statements_invalidate (context);
}
-
+*/
GNUNET_MYSQL_context_destroy (context);
return ret;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r37224 - in gnunet/src: include my,
gnunet <=