| Bug #6046 | mysql_stmt_execute fails when using NATURAL JOIN | ||
|---|---|---|---|
| Submitted: | 12 Oct 2004 16:47 | Modified: | 22 Oct 2004 11:51 | 
| Reporter: | Georg Richter | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server | Severity: | S1 (Critical) | 
| Version: | >= 4.1 | OS: | Linux (Linux) | 
| Assigned to: | Konstantin Osipov | CPU Architecture: | Any | 
   [22 Oct 2004 11:51]
   Konstantin Osipov        
  Fixed in 4.1.7. The bug can not be repeated any more. It must have been fixed in the fix for Bug#6050. I'm checking the test case in and closing the bug report. Please feel free to reopen it if the problem persists. Subject: bk commit - 4.1 tree (konstantin:1.2126) BUG#6046 ChangeSet 1.2126 04/10/22 15:48:40 konstantin@mysql.com +1 -0 A test case for Bug#6046: no fix is needed (the bug is already fixed in the main tree).

Description: When using a natural join in a prepared statement, mysql_stmt_execute fails with error 'unknown table 'h4zh40' in where clause' How to repeat: #include <stdio.h> #include <mysql.h> int main () { MYSQL *mysql = mysql_init(NULL); MYSQL_STMT *stmt; MYSQL_BIND bind[1]; char query[500]; int b; if (!mysql_real_connect(mysql, "localhost", "root", "", "test", 0, NULL, 0)) { printf("Can't connect! Error: %s\n", mysql_error(mysql)); return 1; } mysql_query(mysql, "DROP TABLE IF EXISTS a1"); mysql_query(mysql, "CREATE TABLE a1 (a int, b int)"); mysql_query(mysql, "INSERT INTO a1 VALUES (1,1),(2,2),(3,1),(4,2)"); stmt = mysql_stmt_init(mysql); strcpy(query, "SELECT a1.a FROM a1 NATURAL JOIN a1 as X1 WHERE a1.b > ? ORDER BY a1.a"); if (mysql_stmt_prepare(stmt, query, strlen(query))) { printf("Error in mysql_stmt_prepare: %s\n", mysql_error(mysql)); return 1; } b = 1; bind[0].buffer = &b; bind[0].is_null = 0; bind[0].buffer_type = MYSQL_TYPE_SHORT; if (mysql_stmt_bind_param(stmt, bind)) { printf("Error in mysql_stmt_bind: %s\n", mysql_stmt_error(stmt)); return 1; } if (mysql_stmt_execute(stmt)) { printf("Error in mysql_stmt_execute: %s\n", mysql_stmt_error(stmt)); return 1; } mysql_stmt_close(stmt); mysql_close(mysql); } Suggested fix: