9 messages in com.mysql.lists.plusplusRE: Mysqlpp 2.2.1 template problem
FromSent OnAttachments
Urscheler, Roger (COM Chantry CA)06 Mar 2007 10:37 
Jim Wallace06 Mar 2007 12:07 
Urscheler, Roger (COM Chantry CA)06 Mar 2007 13:05 
Warren Young06 Mar 2007 15:02 
Urscheler, Roger (COM Chantry CA)06 Mar 2007 15:21 
Warren Young07 Mar 2007 14:20 
Urscheler, Roger (COM Chantry CA)09 Mar 2007 12:47 
Warren Young15 Mar 2007 16:52 
Warren Young16 Mar 2007 20:22 
Subject:RE: Mysqlpp 2.2.1 template problem
From:Urscheler, Roger (COM Chantry CA) (roge@siemens.com)
Date:03/09/2007 12:47:30 PM
List:com.mysql.lists.plusplus

I tried debugging the problem. Here is what I found:

If one parameter is passed to the query, the function 'Query::store(const SQLString& str)' is called twice, instead of only once which causes the final query to be: SELECT bpSerialNo FROM rtsBP WHERE bpSerialNo = 'SELECT bpSerialNo FROM rtsBP WHERE bpSerialNo = \'0000000000001001\' Instead of: SELECT bpSerialNo FROM rtsBP WHERE bpSerialNo = '0000000000001001'

I am not familiar with the code and would not know where the root problem lies. Can anybody that is familiar with the query.cpp code help me find the root cause?

Added debug printf's:

--------------------- Result Query::store(const SQLString& str) { printf("Query::store(const SQLString& str): %s, def.size()=%d, def.processing_=%d\n", str.c_str(),def.size(),def.processing_); if ((def.size() == 1) && !def.processing_) { // Take str to be a lone parameter for a template query. The // auto-reset flag is required because we'll end up back in this // function once the query string is built, but we need to take // the 'else' path to avoid an infinite loop. AutoFlag<> af(def.processing_); return store(SQLQueryParms() << str); } else { // Take str to be the entire query string return store(str.c_str(), str.length()); } }

Example:

-------- string m_serial="0000000000001001"; mysqlpp::Query query1 = con->query(); mysqlpp::Result res1; query1 << "SELECT bpSerialNo FROM rtsBP WHERE bpSerialNo = %0q"; query1.parse(); query1.def[0U] = m_serial; cout << query1.preview() << endl; res1 = query1.store(); cout << res1.num_rows() << endl;

Output:

------ SELECT bpSerialNo FROM rtsBP WHERE bpSerialNo = '0000000000001001' Query::store(SQLQueryParms& p) Query::store(const SQLString& str): SELECT bpSerialNo FROM rtsBP WHERE bpSerialNo = '0000000000001001', def.size()=1, def.processing_=0 Query::store(SQLQueryParms& p) Query::store(const SQLString& str): SELECT bpSerialNo FROM rtsBP WHERE bpSerialNo = 'SELECT bpSerialNo FROM rtsBP WHERE bpSerialNo = \'0000000000001001\'', def.size()=1, def.processing_=1 Query::store(const char* str, size_t len): SELECT bpSerialNo FROM rtsBP WHERE bpSerialNo = 'SELECT bpSerialNo FROM rtsBP WHERE bpSerialNo = \'0000000000001001\'' 0

Working example:

---------------- mysqlpp::Query query3 = con->query(); mysqlpp::Result res3; query3 << "SELECT bpSerialNo FROM rtsBP WHERE bpSerialNo = %1q:serial"; query3.parse(); query3.def["serial"] = m_serial; cout << query3.preview() << endl; res3 = query3.store(); cout << res3.num_rows() << endl;

Output:

------- SELECT bpSerialNo FROM rtsBP WHERE bpSerialNo = '0000000000001001' Query::store(SQLQueryParms& p) Query::store(const SQLString& str): SELECT bpSerialNo FROM rtsBP WHERE bpSerialNo = '0000000000001001', def.size()=2, def.processing_=0 Query::store(const char* str, size_t len): SELECT bpSerialNo FROM rtsBP WHERE bpSerialNo = '0000000000001001' 1

Thanks, Roger

-----Original Message----- From: Warren Young [mailto:mysq@etr-usa.com] Sent: Wednesday, March 07, 2007 5:21 PM To: MySQL++ Mailing List Subject: Re: Mysqlpp 2.2.1 template problem

Urscheler, Roger (COM Chantry CA) wrote:

CALL sp_test(1111111111111111);

And for this its: CALL sp_test('1111111111111111')

It looks like there are two differences here, not just one: there's also a semicolon following the version that doesn't work. The semicolon is only needed by the mysql command line utility. At best, the server ignores such things, and it may confuse it.