#include #include #include int main (int argc, const char* argv[]) { #define CHECK(cond) if (cond) { printf ("%s\n", mysql_error (& mysql)); return 1; } MYSQL mysql; memset (& mysql, 0, sizeof (mysql)); int status; if (! mysql_init (& mysql)) return 1; if (! mysql_real_connect (& mysql, ?? /*HOST*/, ?? /*USER*/, ?? /*PASSWORD*/, ?? /*SCHEMA*/, ?? /*PORT*/, NULL, 0)) return 1; MYSQL_STMT* stmt = mysql_stmt_init (& mysql); CHECK (! stmt); const unsigned long cursorType = (unsigned long) CURSOR_TYPE_READ_ONLY; status = mysql_stmt_attr_set (stmt, STMT_ATTR_CURSOR_TYPE, & cursorType); CHECK (status); const char* str = "select T.`C` from (select count(*) `C` from `TEST` group by `Col`) T"; status = mysql_stmt_prepare (stmt, str, (unsigned long) strlen (str)); CHECK (status); status = mysql_stmt_execute (stmt); /* Error log: "mysqld got signal 11" */ CHECK (status); mysql_stmt_close (stmt); mysql_close (& mysql); return 0; }