Skip to content

Commit

Permalink
mx_mysql: Remove dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
donald committed Feb 21, 2022
1 parent 2cbc3e8 commit 50a8a3d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 173 deletions.
167 changes: 0 additions & 167 deletions mx_mysql.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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)
Expand Down
6 changes: 0 additions & 6 deletions mx_mysql.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 50a8a3d

Please sign in to comment.