I'm having some trouble moving a C application from a test machine to production. The program, which uses the small wrapper around mysql_query() shown below, runs flawlessly on the test machine (hours of runtime; tens of thousands if not a million+ queries).
On the production machine, the program will execute exactly 10 queries, then segfault. The 10 queries which are executed before the fault are a mix of INSERT, DELETE, and SELECTs which return both empty and non-empty sets. The last query is a SELECT which returns (well -- is *supposed* to return) an empty set. The problem is twofold: The call to mysql_field_count() returns 1 (should be 0) and upon reaching the mysql_store_result() function call, the program segfaults. I have tried switching around the two statements (as per the examples in the docs), to no avail. Both machines run RH Linux 7.1, and use GCC 2.96-85 Test machine: - MySQL 3.23.39-1 RPM from mysql.com - glibc-2.2-12 - kernel v. 2.2 (as included in RH 7.1) Production machine: - MySQL 3.23.43-1 RPM from mysql.com - glibc-2.2.4-19 - updated kernel (2.4) I've been trying all kinds of up- and downgrades of gcc and the MySQL packages, different levels of compiler optimizations, etc., but can't seem to get around this problem. If anyone has any hint as to what is wrong, I would appreciate hearing from you. [code snippet below] / Carsten MYSQL_RES *mysql_query_e(char *query, char* message, int lineno) { int result; char *errmsg; MYSQL_RES *resultset; // Do the query if (mysql_query(mysql, query)) { printf("----------------------------------------\n" "ERROR: Error when querying database on line %d.\n" "--\n%s\n\nQuery:\n %s\n\nError message:\n%d: %s\n", lineno, message, query, mysql_errno(mysql), mysql_error(mysql)); fflush(stdout); exit(2); } // Check whether we should expect any data if (mysql_field_count(mysql)) { // On the 11th query... // ... this line prints "1" where it should say "0": printf ("%d fields in result\n", mysql_field_count(mysql)); // ... and the following line segfaults: resultset = mysql_store_result(mysql); if (NULL == resultset) { printf("Error: Could not get result for query on line %d\n" "--\nExpected %d columns\n" "%s\n\nQuery:\n %s\n\nError message:\n%d:\n%s\n", lineno, mysql_field_count(mysql), message, query, mysql_errno(mysql), mysql_error(mysql)); fflush(stdout); exit(2); } // yes, there is data. Return the the result to caller return resultset; } // No data, no columns. That's fine return NULL; } --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php