List:MySQL++« Previous Message
From:zhuang yan Date:March 22 2017 6:48am
Subject:RE: A bug of "Query::store(const char* , size_t)"
View as plain text  
Sorry for my poor English.

What my mean is , If  the condtions  is  “parse_elems.size() == 3  && …” ,
now ONLY  the query template have TWO placeholders,your demonstrate do thing ok.
Run a template query with ONE OR THREE placeholders , we will catch a exception.

发送自 Windows 10 版邮件<https://go.microsoft.com/fwlink/?LinkId=550986>应用

发件人: zhuang yan<mailto:zhuangyan-stone@hotmail.com>
发送时间: 2017年3月22日 14:39
收件人: Warren Young<mailto:wyoung@stripped>; plusplus@strippedsql.com<mailto:plusplus@stripped>
主题: Re: A bug of "Query::store(const char* , size_t)"


Test 1: (WOULD GOT A EXCEPTION)
-- if ((parse_elems_.size() == 2) && !template_defaults.processing_)
++ if ((parse_elems_.size() == 3) && !template_defaults.processing_)

  CODE:
mysqlpp::Query Q = con.query("SELECT * FROM user WHERE id = %0"); //ONE ONE placeholder
   Q.parse();
cout << Q.str(1) << endl; // SQL : SELECT * FROM user WHERE id = 1 < looks OK.
  mysqlpp: R = Q.store(user.id); //NOW got a  BadQuery exception.

Test 2: (EVERYTHINK OK)
-- if ((parse_elems_.size() == 2) && !template_defaults.processing_)
++ if ((parse_elems_.size() > 1) && !template_defaults.processing_)

mysqlpp::Query Q = con.query("SELECT * FROM user WHERE id = %0"); //ONE ONE placeholder
   Q.parse();
cout << Q.str(1) << endl; // SQL : SELECT * FROM user WHERE id = 1 < looks OK.
  mysqlpp: R = Q.store(user.id); // Everything is OK.


AND I have tested ONE, TWO, THREE, FOUR and more plaeholders. Everything is OK.

===========================

Look at here (query.cpp):

StoreQueryResult
Query::store(const char* str, size_t len)
{
    if ((parse_elems_.size() > 1) && !template_defaults.processing_) {
        // We're a template query and this isn't a recursive call, so
        // take s to be a lone parameter for the query.  We will come
        // back in here with a completed query, but the processing_
        // flag will be set, allowing us to avoid an infinite loop.
        AutoFlag<> af(template_defaults.processing_);
        return execute(SQLQueryParms() << str << len );
    }
…
Does it mean if we have parse_elems,  no matter ONE or MORE, we would call “ SQLQuryParm << str << len “ ?

发送自 Windows 10 版邮件<https://go.microsoft.com/fwlink/?LinkId=550986>应用

⒓奔m<mailto:plusplus@stripped>
主题: Re: A bug of "Query::store(const char* , size_t)"

On Mar 21, 2017, at 8:04 AM, Warren Young <wyoung@stripped> wrote:
>
> How does this not demonstrate that the patch is correct as originally given?

You will convince me more easily if you can modify one of the examples to demonstrate the problem, as I have done in my prior post.
--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe:    http://lists.mysql.com/plusplus

Thread
Re: A bug of "Query::store(const char* , size_t)"Warren Young20 Mar 2017
  • 答复: A bug of "Query::store(const char* , size t)"zhuang yan21 Mar 2017
  • 答复: A bug of "Query::store(const char* , size t)"zhuang yan21 Mar 2017
    • 答复: A bug of "Query::store(const char* , size t)"zhuang yan21 Mar 2017
      • Re: A bug of "Query::store(const char* , size_t)"Warren Young21 Mar 2017
        • Re: A bug of "Query::store(const char* , size_t)"Warren Young21 Mar 2017
          • Re: A bug of "Query::store(const char* , size_t)"zhuang yan22 Mar 2017
            • RE: A bug of "Query::store(const char* , size_t)"zhuang yan22 Mar 2017