| Ticket Hash: | 8075e2d150258d4c9c77c9f7650b7861edc5c8f6 | ||
| Title: | Bug found when execute(...) with template query | ||
| Status: | Closed | Type: | Code Defect |
| Severity: | Important | Priority: | Immediate |
| Subsystem: | Library | Resolution: | Works as Designed |
| Last Modified: |
2020-07-23 06:55:59 5.28 years ago |
Created: |
2018-12-20 09:13:04 6.87 years ago |
| Version Found In: | mysql++-3.2.4 | ||
| User Comments: | ||||
anonymous added on 2018-12-20 09:13:04:
MySQL version: mysql-5.7.23-win32
OS: Windows 10 1809
Visual Studio: vs2015 update 3
I built mysql++-3.2.4 in its vc2005 project and got the x86 lib. I did some modification in the resetdb.cpp and ran the resetdb project, then I found a problem.
```
// Now create empty images table, for testing BLOB and auto-
// increment column features.
cout << "Creating empty images table..." << endl;
query.reset(); // forget template query info
query <<
"CREATE TABLE images (" <<
" id INT UNSIGNED AUTO_INCREMENT, " <<
" data BLOB, " <<
" PRIMARY KEY (id)" <<
")";
query.execute();
query.execute( "insert into images (data) values (\"def\")");
query << "insert into %1:tab (%2:field) values (%0q:val1)";
//query << "insert into %0:table values (\"def\")";
query.parse();
query.template_defaults["tab"] = "images";
query.template_defaults["field"] = "data";
query.template_defaults["val1"] = "abc";
//query.template_defaults["field"] = "data";
cout << query.str() << endl;
query.execute("abc", "images");
query.execute("images");
query.reset();
```
A BadQuery was caught when executing `query.execute("images");`. I debuged and waited in mysql_real_query(...), then I found that the `qstr` is "images".
I think it's something wrong when there're more than one placeholder but pass only one parameter into execute(...).
If it's not a bug, please give me some advice on how to do in this situation.
tangent added on 2020-07-23 06:55:59: The 1-parameter case has always been a mess due to the limitations of C++ overloads. | ||||