diff --git a/mx_mysql.c b/mx_mysql.c index cb20f841..4fce8ac5 100644 --- a/mx_mysql.c +++ b/mx_mysql.c @@ -230,45 +230,6 @@ static int mx__mysql_ping(struct mx_mysql *mysql) return -(errno=EBADE); } -static int mx__mysql_real_query(struct mx_mysql *mysql, const char *stmt_str, unsigned long length) -{ - mx_assert_return_minus_errno(mysql, EINVAL); - mx_assert_return_minus_errno(stmt_str, EINVAL); - mx_assert_return_minus_errno(*stmt_str, EINVAL); - - mx_assert_return_minus_errno(mysql->mysql, EBADF); - - int res; - - if (!length) - length = strlen(stmt_str); - - mysql->func = "mysql_real_query"; - res = mysql_real_query(mysql->mysql, stmt_str, length); - - if (res == 0) - return 0; - - mx__mysql_log_warning(mysql); - - switch (mx__mysql_errno(mysql)) { - case CR_COMMANDS_OUT_OF_SYNC: - mx__mysql_log_emerg(mysql); - return -(errno=EPROTO); - - case CR_SERVER_GONE_ERROR: - case CR_SERVER_LOST: - return -(errno=EAGAIN); - - case CR_UNKNOWN_ERROR: - return -(errno=EIO); - } - - mx__mysql_log_emerg(mysql); - mx_log_emerg("ERROR: mysql_real_query() returned undefined error number: %d", mx__mysql_errno(mysql)); - return -(errno=EBADE); -} - static int mx__mysql_stmt_init(struct mx_mysql_stmt *stmt) { mx_assert_return_minus_errno(stmt, EINVAL); @@ -591,22 +552,6 @@ static int mx__mysql_stmt_field_count(struct mx_mysql_stmt *stmt) return (int)count; } -static int mx__mysql_stmt_num_rows(struct mx_mysql_stmt *stmt, unsigned long long *count) -{ - my_ulonglong c; - - mx_assert_return_minus_errno(stmt, EINVAL); - mx_assert_return_minus_errno(stmt->stmt, EBADF); - - stmt->func = "mysql_stmt_num_rows"; - c = mysql_stmt_num_rows(stmt->stmt); - - *count = (unsigned long long)c; - - /* no mysql errors possible */ - return 0; -} - static int mx__mysql_stmt_affected_rows(struct mx_mysql_stmt *stmt, unsigned long long *count) { my_ulonglong c; @@ -711,42 +656,6 @@ int _mx_mysql_bind_integer(struct mx_mysql_bind *b, unsigned int index, void *va return 0; } -void _mx_mysql_bind_dump_index(struct mx_mysql_bind *b, unsigned int index) -{ - mx_debug_value("%d", index); - mx_debug_value("%d", b->bind[index].buffer_type); - mx_debug_value("%lu", b->bind[index].buffer_length); - mx_debug_value("%p", b->bind[index].buffer); - if (b->bind[index].buffer_type == MYSQL_TYPE_STRING) - mx_debug_value("%s", (char *)b->bind[index].buffer); - mx_debug_value("%d", b->bind[index].is_unsigned); - mx_debug_value("%lu", *b->bind[index].length); - mx_debug_value("%d", *b->bind[index].is_null); - mx_debug_value("%d", *b->bind[index].error); - mx_debug_value("0x%x", b->data[index].flags); -} - -void _mx_mysql_bind_dump(struct mx_mysql_bind *b) -{ - int i; - - mx_log_debug("entered"); - - if (!b) { - mx_log_debug("done"); - return; - } - - mx_debug_value("%d", b->type); - mx_debug_value("%lu", b->count); - - for (i=0; i < b->count; i++) { - _mx_mysql_bind_dump_index(b, i); - } - mx_log_debug("done"); -} - - static int _mx_mysql_bind_string(struct mx_mysql_bind *b, unsigned int index, char **value) { mx_assert_return_minus_errno(b, EINVAL); @@ -857,12 +766,6 @@ int mx_mysql_option_set_default_file(struct mx_mysql *mysql, char *fname) return 0; } -char *mx_mysql_option_get_default_file(struct mx_mysql *mysql) -{ - mx_assert_return_NULL(mysql, EINVAL); - return mysql->default_file; -} - int mx_mysql_option_set_default_group(struct mx_mysql *mysql, char *group) { mx_assert_return_minus_errno(mysql, EINVAL); @@ -875,13 +778,6 @@ int mx_mysql_option_set_default_group(struct mx_mysql *mysql, char *group) return 0; } -char *mx_mysql_option_get_default_group(struct mx_mysql *mysql) -{ - mx_assert_return_NULL(mysql, EINVAL); - - return mysql->default_group; -} - int mx_mysql_option_set_reconnect(struct mx_mysql *mysql, int reconnect) { mx_assert_return_minus_errno(mysql, EINVAL); @@ -890,13 +786,6 @@ int mx_mysql_option_set_reconnect(struct mx_mysql *mysql, int reconnect) return 0; } -int mx_mysql_option_get_reconnect(struct mx_mysql *mysql) -{ - mx_assert_return_minus_errno(mysql, EINVAL); - - return (int)mysql->reconnect; -} - static int mx_mysql_real_connect(struct mx_mysql *mysql, const char *host, const char *user, const char *passwd, const char *db, unsigned int port, const char *unix_socket, unsigned long client_flag) { int res; @@ -1044,32 +933,6 @@ int mx_mysql_ping_forever(struct mx_mysql *mysql) return res; } - -int mx_mysql_queryf(struct mx_mysql *mysql, const char *fmt, ...) -{ - mx_assert_return_minus_errno(mysql, EINVAL); - mx_assert_return_minus_errno(fmt, EINVAL); - mx_assert_return_minus_errno(*fmt, EINVAL); - - mx_assert_return_minus_errno(mysql->mysql, EBADF); - - va_list ap; - _mx_cleanup_free_ char *query = NULL; - int res; - size_t len; - - va_start(ap, fmt); - len = vasprintf(&query, fmt, ap); - va_end(ap); - - if (len == -1) - return 0; - - res = mx__mysql_real_query(mysql, query, len); - - return res; -} - int mx_mysql_statement_init(struct mx_mysql *mysql, struct mx_mysql_stmt **stmt) { struct mx_mysql_stmt *s; @@ -1146,14 +1009,6 @@ int mx_mysql_statement_insert_id(struct mx_mysql_stmt *stmt, unsigned long long return mx__mysql_stmt_insert_id(stmt, id); } -int mx_mysql_statement_affected_rows(struct mx_mysql_stmt *stmt, unsigned long long int *count) { - return mx__mysql_stmt_affected_rows(stmt, count); -} - -int mx_mysql_statement_num_rows(struct mx_mysql_stmt *stmt, unsigned long long int *count) { - return mx__mysql_stmt_num_rows(stmt, count); -} - int mx_mysql_statement_fetch(struct mx_mysql_stmt *stmt) { struct mx_mysql_bind *r; @@ -1240,17 +1095,6 @@ int mx_mysql_stmt_field_count_set(struct mx_mysql_stmt *stmt) return 0; } -int mx_mysql_stmt_field_count_get(struct mx_mysql_stmt *stmt, unsigned long *count) -{ - mx_assert_return_minus_errno(stmt, EINVAL); - mx_assert_return_minus_errno(count, EINVAL); - mx_assert_return_minus_errno(stmt->stmt, EBADF); - - *count = stmt->field_count; - - return 0; -} - int mx_mysql_stmt_param_count_set(struct mx_mysql_stmt *stmt) { mx_assert_return_minus_errno(stmt, EINVAL); @@ -1261,17 +1105,6 @@ int mx_mysql_stmt_param_count_set(struct mx_mysql_stmt *stmt) return 0; } -int mx_mysql_stmt_param_count_get(struct mx_mysql_stmt *stmt, unsigned long *count) -{ - mx_assert_return_minus_errno(stmt, EINVAL); - mx_assert_return_minus_errno(count, EINVAL); - mx_assert_return_minus_errno(stmt->stmt, EBADF); - - *count = stmt->param_count; - - return 0; -} - int mx_mysql_bind_cleanup(struct mx_mysql_bind *bind) { if (!bind) diff --git a/mx_mysql.h b/mx_mysql.h index cfec0040..22817335 100644 --- a/mx_mysql.h +++ b/mx_mysql.h @@ -106,10 +106,6 @@ int mx_mysql_option_set_default_file(struct mx_mysql *mysql, char *fname); int mx_mysql_option_set_default_group(struct mx_mysql *mysql, char *group); int mx_mysql_option_set_reconnect(struct mx_mysql *mysql, int reconnect); -char *mx_mysql_option_get_default_file(struct mx_mysql *mysql); -char *mx_mysql_option_get_default_group(struct mx_mysql *mysql); -int mx_mysql_option_get_reconnect(struct mx_mysql *mysql); - int mx_mysql_connect(struct mx_mysql **mysql); int mx_mysql_connect_forever_sec(struct mx_mysql **mysql, unsigned int seconds); #define mx_mysql_connect_forever(m) mx_mysql_connect_forever_sec((m), MX_MYSQL_FAIL_WAIT_DEFAULT) @@ -139,8 +135,6 @@ struct mx_mysql_stmt *mx_mysql_statement_prepare_with_bindings(struct mx_mysql * int mx_mysql_statement_execute(struct mx_mysql_stmt *stmt, unsigned long long *count); int mx_mysql_statement_insert_id(struct mx_mysql_stmt *stmt, unsigned long long int *id); -int mx_mysql_statement_affected_rows(struct mx_mysql_stmt *stmt, unsigned long long int *count); -int mx_mysql_statement_num_rows(struct mx_mysql_stmt *stmt, unsigned long long int *count); int mx_mysql_statement_fetch(struct mx_mysql_stmt *stmt);