From 9a514bfb0dd7b656d9c4eb14aa196102c1e3593b Mon Sep 17 00:00:00 2001 From: Christophe Genevey Metat Date: Tue, 28 Jun 2016 09:47:01 +0000 Subject: delete mysql function --- src/include/gnunet_mysql_lib.h | 63 ----------- src/mysql/mysql.c | 240 ----------------------------------------- 2 files changed, 303 deletions(-) (limited to 'src') diff --git a/src/include/gnunet_mysql_lib.h b/src/include/gnunet_mysql_lib.h index fc0bfdfac..fc6f42f86 100644 --- a/src/include/gnunet_mysql_lib.h +++ b/src/include/gnunet_mysql_lib.h @@ -137,69 +137,6 @@ GNUNET_MYSQL_statement_run (struct GNUNET_MYSQL_Context *mc, const char *sql); -/** - * Run a prepared SELECT statement. - * - * @param sh handle to SELECT statment - * @param result_size number of elements in results array - * @param results pointer to already initialized MYSQL_BIND - * array (of sufficient size) for passing results - * @param processor function to call on each result - * @param processor_cls extra argument to processor - * @param ... pairs and triplets of "MYSQL_TYPE_XXX" keys and their respective - * values (size + buffer-reference for pointers); terminated - * with "-1" - * @return GNUNET_SYSERR on error, otherwise - * the number of successfully affected (or queried) rows - */ -int -GNUNET_MYSQL_statement_run_prepared_select (struct GNUNET_MYSQL_StatementHandle *sh, - unsigned int result_size, MYSQL_BIND * results, - GNUNET_MYSQL_DataProcessor processor, - void *processor_cls, ...); - - -/** - * Run a prepared SELECT statement. - * - * @param s statement to run - * @param result_size number of elements in results array - * @param results pointer to already initialized MYSQL_BIND - * array (of sufficient size) for passing results - * @param processor function to call on each result - * @param processor_cls extra argument to processor - * @param ap pairs and triplets of "MYSQL_TYPE_XXX" keys and their respective - * values (size + buffer-reference for pointers); terminated - * with "-1" - * @return GNUNET_SYSERR on error, otherwise - * the number of successfully affected (or queried) rows - */ -int -GNUNET_MYSQL_statement_run_prepared_select_va (struct GNUNET_MYSQL_StatementHandle *s, - unsigned int result_size, - MYSQL_BIND * results, - GNUNET_MYSQL_DataProcessor processor, - void *processor_cls, - va_list ap); - - -/** - * Run a prepared statement that does NOT produce results. - * - * @param sh handle to statment - * @param insert_id NULL or address where to store the row ID of whatever - * was inserted (only for INSERT statements!) - * @param ... pairs and triplets of "MYSQL_TYPE_XXX" keys and their respective - * values (size + buffer-reference for pointers); terminated - * with "-1" - * @return GNUNET_SYSERR on error, otherwise - * the number of successfully affected rows - */ -int -GNUNET_MYSQL_statement_run_prepared (struct GNUNET_MYSQL_StatementHandle *sh, - unsigned long long *insert_id, ...); - - #if 0 /* keep Emacsens' auto-indent happy */ { #endif diff --git a/src/mysql/mysql.c b/src/mysql/mysql.c index 7042d662e..acd54a288 100644 --- a/src/mysql/mysql.c +++ b/src/mysql/mysql.c @@ -453,244 +453,4 @@ GNUNET_MYSQL_statement_get_stmt (struct GNUNET_MYSQL_StatementHandle *sh) } -/** - * Bind the parameters for the given MySQL statement - * and run it. - * - * @param sh statement to bind and run - * @param ap arguments for the binding - * @return GNUNET_SYSERR on error, GNUNET_OK on success - */ -static int -init_params (struct GNUNET_MYSQL_StatementHandle *sh, va_list ap) -{ - struct GNUNET_MYSQL_Context *mc = sh->mc; - MYSQL_BIND qbind[MAX_PARAM]; - unsigned int pc; - unsigned int off; - enum enum_field_types ft; - - pc = mysql_stmt_param_count (sh->statement); - if (pc > MAX_PARAM) - { - /* increase internal constant! */ - GNUNET_break (0); - return GNUNET_SYSERR; - } - memset (qbind, 0, sizeof (qbind)); - off = 0; - ft = 0; - while ((pc > 0) && (-1 != (int) (ft = va_arg (ap, enum enum_field_types)))) - { - qbind[off].buffer_type = ft; - switch (ft) - { - case MYSQL_TYPE_FLOAT: - qbind[off].buffer = va_arg (ap, float *); - - break; - case MYSQL_TYPE_LONGLONG: - qbind[off].buffer = va_arg (ap, unsigned long long *); - qbind[off].is_unsigned = va_arg (ap, int); - - break; - case MYSQL_TYPE_LONG: - qbind[off].buffer = va_arg (ap, unsigned int *); - qbind[off].is_unsigned = va_arg (ap, int); - - break; - case MYSQL_TYPE_VAR_STRING: - case MYSQL_TYPE_STRING: - case MYSQL_TYPE_BLOB: - qbind[off].buffer = va_arg (ap, void *); - qbind[off].buffer_length = va_arg (ap, unsigned long); - qbind[off].length = va_arg (ap, unsigned long *); - - break; - default: - /* unsupported type */ - GNUNET_break (0); - return GNUNET_SYSERR; - } - pc--; - off++; - } - if (!((pc == 0) && (-1 != (int) ft) && (va_arg (ap, int) == -1))) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - if (mysql_stmt_bind_param (sh->statement, qbind)) - { - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "mysql", - _("`%s' failed at %s:%d with error: %s\n"), - "mysql_stmt_bind_param", __FILE__, __LINE__, - mysql_stmt_error (sh->statement)); - GNUNET_MYSQL_statements_invalidate (mc); - return GNUNET_SYSERR; - } - if (mysql_stmt_execute (sh->statement)) - { - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "mysql", - _("`%s' failed at %s:%d with error: %s\n"), - "mysql_stmt_execute", __FILE__, __LINE__, - mysql_stmt_error (sh->statement)); - GNUNET_MYSQL_statements_invalidate (mc); - return GNUNET_SYSERR; - } - return GNUNET_OK; -} - - - -/** - * Run a prepared SELECT statement. - * - * @param s statement to run - * @param result_size number of elements in results array - * @param results pointer to already initialized MYSQL_BIND - * array (of sufficient size) for passing results - * @param processor function to call on each result - * @param processor_cls extra argument to processor - * @param ap pairs and triplets of "MYSQL_TYPE_XXX" keys and their respective - * values (size + buffer-reference for pointers); terminated - * with "-1" - * @return GNUNET_SYSERR on error, otherwise - * the number of successfully affected (or queried) rows - */ -int -GNUNET_MYSQL_statement_run_prepared_select_va (struct - GNUNET_MYSQL_StatementHandle *s, - unsigned int result_size, - MYSQL_BIND * results, - GNUNET_MYSQL_DataProcessor - processor, void *processor_cls, - va_list ap) -{ - int ret; - unsigned int rsize; - int total; - - if (GNUNET_OK != prepare_statement (s)) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - if (GNUNET_OK != init_params (s, ap)) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - rsize = mysql_stmt_field_count (s->statement); - if (rsize > result_size) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - if (mysql_stmt_bind_result (s->statement, results)) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("`%s' failed at %s:%d with error: %s\n"), - "mysql_stmt_bind_result", __FILE__, __LINE__, - mysql_stmt_error (s->statement)); - GNUNET_MYSQL_statements_invalidate (s->mc); - return GNUNET_SYSERR; - } - - total = 0; - while (1) - { - ret = mysql_stmt_fetch (s->statement); - if (ret == MYSQL_NO_DATA) - break; - if (ret != 0) - { - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "mysql", - _("`%s' failed at %s:%d with error: %s\n"), - "mysql_stmt_fetch", __FILE__, __LINE__, - mysql_stmt_error (s->statement)); - GNUNET_MYSQL_statements_invalidate (s->mc); - return GNUNET_SYSERR; - } - total++; - if ((NULL == processor) || - (GNUNET_OK != processor (processor_cls, rsize, results))) - break; - } - mysql_stmt_reset (s->statement); - return total; -} - - -/** - * Run a prepared SELECT statement. - * - * @param sh handle to SELECT statment - * @param result_size number of elements in results array - * @param results pointer to already initialized MYSQL_BIND - * array (of sufficient size) for passing results - * @param processor function to call on each result - * @param processor_cls extra argument to processor - * @param ... pairs and triplets of "MYSQL_TYPE_XXX" keys and their respective - * values (size + buffer-reference for pointers); terminated - * with "-1" - * @return GNUNET_SYSERR on error, otherwise - * the number of successfully affected (or queried) rows - */ -int -GNUNET_MYSQL_statement_run_prepared_select (struct GNUNET_MYSQL_StatementHandle - *sh, unsigned int result_size, - MYSQL_BIND * results, - GNUNET_MYSQL_DataProcessor - processor, void *processor_cls, ...) -{ - va_list ap; - int ret; - - va_start (ap, processor_cls); - ret = - GNUNET_MYSQL_statement_run_prepared_select_va (sh, result_size, - results, processor, - processor_cls, ap); - va_end (ap); - return ret; -} - - -/** - * Run a prepared statement that does NOT produce results. - * - * @param sh handle to statment - * @param insert_id NULL or address where to store the row ID of whatever - * was inserted (only for INSERT statements!) - * @param ... pairs and triplets of "MYSQL_TYPE_XXX" keys and their respective - * values (size + buffer-reference for pointers); terminated - * with "-1" - * @return GNUNET_SYSERR on error, otherwise - * the number of successfully affected rows - */ -int -GNUNET_MYSQL_statement_run_prepared (struct GNUNET_MYSQL_StatementHandle *sh, - unsigned long long *insert_id, ...) -{ - va_list ap; - int affected; - - if (GNUNET_OK != prepare_statement (sh)) - return GNUNET_SYSERR; - va_start (ap, insert_id); - if (GNUNET_OK != init_params (sh, ap)) - { - va_end (ap); - return GNUNET_SYSERR; - } - va_end (ap); - affected = mysql_stmt_affected_rows (sh->statement); - if (NULL != insert_id) - *insert_id = (unsigned long long) mysql_stmt_insert_id (sh->statement); - mysql_stmt_reset (sh->statement); - return affected; -} - - /* end of mysql.c */ -- cgit v1.2.3