List:MySQL++« Previous MessageNext Message »
From:Roger (COM Chantry CA) Urscheler Date:March 9 2007 8:47pm
Subject:RE: Mysqlpp 2.2.1 template problem
View as plain text  
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:mysqlpp@stripped] 
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.

-- 
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe:
http://lists.mysql.com/plusplus?unsub=1
Thread
Mysqlpp 2.2.1 template problemCOM Chantry CA)6 Mar
RE: Mysqlpp 2.2.1 template problemJim Wallace6 Mar
RE: Mysqlpp 2.2.1 template problemCOM Chantry CA)6 Mar
  • Re: Mysqlpp 2.2.1 template problemWarren Young6 Mar
RE: Mysqlpp 2.2.1 template problemCOM Chantry CA)7 Mar
  • Re: Mysqlpp 2.2.1 template problemWarren Young7 Mar
RE: Mysqlpp 2.2.1 template problemCOM Chantry CA)9 Mar
  • Re: Mysqlpp 2.2.1 template problemWarren Young16 Mar
Re: Mysqlpp 2.2.1 template problemWarren Young17 Mar