Embedded server in MySQL 5.5.4-m3 select failing on information_schema.tables?
Posted by: Rob Clevenger
Date: July 13, 2010 05:16PM

I'm trying this embedded program to do a select against INFORMATION_SCHEMA.TABLES. It fails on next_field and next_mysql_field never being initialized and pointing to garbage.

It looks like this change may have added the code that's not working right: http://lists.mysql.com/commits/85677

I'm not sure what to initialize those fields to for the binary protocol, the text protocol sublcass looks right. Any help would be appreciated.

Thanks!

Rob


Here's a sample app demonstrating the problem on ubunty lucid.
#include <mysql.h>
#include <cstdio>
#include <cstdlib>
#include <iostream>

static char *server_args[] = {
"this_program", /* this string is not used */
"--datadir=.",
"--key_buffer_size=32M"
};

#define CHECK(x) { if (!(x)) { std::cerr << #x << std::endl; exit(1); }}
#define CHECK_STMT(stmt, x) { if (!(x)) { std::cerr << #x << " " << \
mysql_stmt_error(stmt) << std::endl; exit(1); } else { std::cout << "after " \
<< #x << std::endl; } }

int main(void) {
printf("Hello World\n\n");
if (mysql_library_init(sizeof(server_args) / sizeof(char *),
server_args, NULL)) {
std::cerr << "Could not initialize MySQL library!";
return 1;
}

MYSQL* mysql = mysql_init(NULL);
if (!mysql_real_connect(mysql, NULL, NULL, NULL, NULL, 0, NULL, 0)) {
std::cerr << "mysql_real_connect";
return 1;
}

MYSQL_STMT* stmt = mysql_stmt_init(mysql);
CHECK(stmt != NULL);
std::string sql = "select * from information_schema.tables";
CHECK_STMT(stmt, mysql_stmt_prepare(stmt, sql.c_str(), sql.size()) == 0);
CHECK_STMT(stmt, mysql_stmt_execute(stmt)==0);

std::cout << "after mysql_stmt_execute" << std::endl;

mysql_close(mysql);
mysql_library_end();
return 0;
}

Options: ReplyQuote


Subject
Written By
Posted
Embedded server in MySQL 5.5.4-m3 select failing on information_schema.tables?
July 13, 2010 05:16PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.