Index: driver/catalog.c =================================================================== --- driver/catalog.c (revision 596) +++ driver/catalog.c (working copy) @@ -662,8 +662,7 @@ if (cbColumn) { to= strmov(to, " LIKE '"); - to+= myodbc_escape_wildcard(mysql, to, sizeof(buff) - (to - buff), - (char *)szColumn, cbColumn); + to+= mysql_real_escape_string(mysql, to, (char *)szColumn, cbColumn); to= strmov(to, "'"); } @@ -687,9 +686,10 @@ return NULL; } - to= strxmov(select, "SELECT `", NullS); + to= strxmov(select, "SELECT ", NullS); while ((row= mysql_fetch_row(result))) { + to= strmov(to, "`"); lengths= mysql_fetch_lengths(result); to+= mysql_real_escape_string(mysql, to, row[0], lengths[0]); to= strmov(to, "`,"); Index: test/my_catalog.c =================================================================== --- test/my_catalog.c (revision 596) +++ test/my_catalog.c (working copy) @@ -1076,6 +1076,28 @@ } +/** + Bug #29888: Crystal wizard throws error on including tables +*/ +DECLARE_TEST(t_bug29888) +{ + ok_sql(hstmt, "DROP TABLE IF EXISTS t_bug29888"); + ok_sql(hstmt, "CREATE TABLE t_bug29888 (a INT, b INT)"); + + ok_stmt(hstmt, SQLColumns(hstmt, mydb, SQL_NTS, NULL, SQL_NTS, + (SQLCHAR *)"t_bug29888", SQL_NTS, + (SQLCHAR *)"%", SQL_NTS)); + + is_num(myrowcount(hstmt), 2); + + ok_stmt(hstmt, SQLFreeStmt(hstmt, SQL_CLOSE)); + + ok_sql(hstmt, "DROP TABLE IF EXISTS t_bug29888"); + + return OK; +} + + BEGIN_TESTS ADD_TEST(my_columns_null) ADD_TEST(my_drop_table) @@ -1096,6 +1118,7 @@ ADD_TEST(t_bug28316) ADD_TEST(bug8860) ADD_TEST(t_bug26934) + ADD_TEST(t_bug29888) END_TESTS Index: ChangeLog =================================================================== --- ChangeLog (revision 596) +++ ChangeLog (working copy) @@ -5,6 +5,8 @@ ODBC logging should be used. Bugs fixed: + * SQLColumns() failed when a catalog was specified due to an + incorrectly-generated query. (Bug #29888) * Tables from the mysql database (catalog) were listed as SYSTEM TABLES by SQLTables() even when a different catalog was being queried. This also introduced errors due to the fix for Bug #26934. (Bug #28662)