| Bug #4173 | Some aggregate functions used in a prepared query fail on big endian platforms | ||
|---|---|---|---|
| Submitted: | 17 Jun 2004 1:08 | Modified: | 18 Jun 2004 3:29 |
| Reporter: | Nathaniel Blanchard | ||
| Status: | Closed | ||
| Category: | Server | Severity: | S1 (Critical) |
| Version: | 4.1.2 | OS: | IBM AIX (AIX, OSX, Solaris (sparc), HP-UX) |
| Assigned to: | Michael Widenius | Target Version: | |
[18 Jun 2004 3:29]
Michael Widenius
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.
If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information
about accessing the source trees is available at
http://www.mysql.com/doc/en/Installing_source_tree.html
Additional info:
Fix will be in 4.1.3
Regards,
Monty

Description: Using a prepared query, some aggregate functions (tested with SUM and AVG so far) return their results in the wrong byte order when fetched, while on big endian hardware. This sounds very similar to bug 3578. I've confirmed the attached test plan returns incorrect values on the following platforms: AIX 5.2 Solaris 8 (sparc) (x86 works fine since its a lowhigh machine) Mac OS X (Darwin Kernel Version 6.8) How to repeat: MYSQL_STMT *stmt; MYSQL_BIND bind_array[3]; MYSQL *mysql = NULL; int id; /* input and output data of 'id' column */ const char *stmt_text; int rc; /* to save return value of API calls */ int i; /* loop counter */ setup_connection(); stmt= mysql_stmt_init(mysql); stmt_text= "INSERT INTO t1 (id) VALUES (?)"; mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); memset(bind_array, 0, sizeof(bind_array)); bind_array[0].buffer_type= MYSQL_TYPE_LONG; bind_array[0].buffer= (char*) &id; mysql_stmt_bind_param(stmt, bind_array); for (id= 1; id <= 3; ++id) mysql_stmt_execute(stmt); stmt_text= "select sum(id) from t1"; mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); mysql_stmt_execute(stmt); mysql_stmt_bind_result(stmt, bind_array); while ((rc= mysql_stmt_fetch(stmt)) == 0) { printf("result = %d\n", id); } mysql_stmt_close(stmt); cleanup(); return 0;