Description:
The C-API call mysql_info() does not support SELECT.
http://dev.mysql.com/doc/refman/6.0/en/mysql-info.html
The MySQL native driver for PHP (mysqlnd) does support SELECT. That makes me believe that its technically possible to support SELECT. Can we get libmysql and mysqlnd in sync by adding support for SELECT?
How to repeat:
Read the manual or, if absolutely needed, write a C program...
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include <my_global.h>
#include <my_sys.h>
#include <mysql.h>
int exit_failure(const char *msg, MYSQL *mysql, MYSQL_RES *res);
/* Connection parameter - change */
const char *con_host = "localhost";
const char *con_user = "root";
const char *con_pass = "root";
const char *con_db = "test";
unsigned int con_port = 3306;
const char *con_socket = "/tmp/mysql.sock";
unsigned long con_flags = 0;
MYSQL *conn;
MYSQL_RES *res;
MYSQL_ROW row;
my_ulonglong insert_id;
int main(void) {
printf("\n");
printf("Connecting...\n");
conn = mysql_init(NULL);
if (conn == NULL)
exit_failure("mysql_init() failed", NULL, NULL);
if (mysql_real_connect(conn, con_host, con_user, con_pass, con_db, con_port, con_socket, con_flags) == NULL)
exit_failure("mysql_real_connect() failed", conn, NULL);
printf("Server: %s\n", mysql_get_server_info(conn));
printf("Protocol: %u\n", mysql_get_proto_info(conn));
printf("Client: %s\n\n", mysql_get_client_info());
printf("Inserting 1 row in an auto_increment column...\n");
if (mysql_query(conn, "DROP TABLE IF EXISTS test") != 0)
exit_failure("DROP TABLE IF EXISTS failed", conn, NULL);
if (mysql_query(conn, "CREATE TABLE test(id INT AUTO_INCREMENT PRIMARY KEY, label CHAR(10))") != 0)
exit_failure("CREATE TABLE test(id INT AUTO_INCREMENT PRIMARY KEY, label CHAR(10)) failed", conn, NULL);
if (mysql_query(conn, "INSERT INTO test(id, label) VALUES (100, 'z')") != 0)
exit_failure("INSERT INTO test(id, label) VALUES (100, 'z') failed", conn, NULL);
if (mysql_query(conn, "SELECT label FROM test") != 0)
exit_failure("SELECT label FROM test", conn, NULL);
res = mysql_store_result(conn);
if (res == NULL)
exit_failure("mysql_store_result() failed", conn, NULL);
if ((row = mysql_fetch_row(res)) == NULL)
exit_failure("mysql_fetch_row() failed", conn, res);
printf("mysql_info: %s\n", mysql_info(conn));
printf("SELECT id returns '%s'...\n", row[0]);
mysql_free_result(res);
mysql_close(conn);
return EXIT_SUCCESS;
}
int exit_failure(const char *msg, MYSQL *mysql, MYSQL_RES *res) {
printf("ERROR: %s\n", msg);
if (mysql) {
printf("[%u] %s\n", mysql_errno(mysql), mysql_error(mysql));
if (res)
mysql_free_result(res);
mysql_close(mysql);
}
printf("\n");
exit(EXIT_FAILURE);
}