List:MySQL++« Previous MessageNext Message »
From:Martin Gallwey Date:December 3 2009 3:57pm
Subject:Template query change from v2 to v3
View as plain text  
Hi there,

I recently upgraded from version 2 to version 3 and several queries of 
mine stopped working due to the fact that I was using the same templated 
argument more than once in a query, for example:

update help_links set help_status_types_id = 2 where help_status_types_id 
= 3 and (to_help_content_id=%0 or from_help_content_id=%0)

These worked fine in v2, but not so well in v3. I did some digging to try 
and figure out why, and it appears that are two problems.

1) Revision 1446 changed the detection of a templated query to search for 
the magic size of '2' for parse_elems_. This meant that some of my queries 
just fell through to the store/execute methods which just took (const 
char* str, size_t len) with no substitution taking place.

2) Some of my queries take the form of, for example:

pQuery->execute ( "thing", 17 );

Again, mysqlpp assumes I am trying to execute the a query of 'thing' with 
a length of 17, instead of correctly interpreting that I want to do a 
template substitution first and execute the result of that.

I've attached a patch which reverts 1446 back to the version used in 1443 
and adds checks for templated queries to the 'raw' store/use/execute 
methods so that they do substitution when expected to.

I am probably missing some subtleties here, but this patch gets my system 
(which depends heavily on large numbers of templated queries) back up and 
running.

Thanks,

Martin
Attachment: [text/x-diff]  newmysql.patch
Thread
Template query change from v2 to v3Martin Gallwey3 Dec
  • Re: Template query change from v2 to v3Warren Young4 Dec
    • Re: Template query change from v2 to v3Martin Gallwey4 Dec
      • Re: Template query change from v2 to v3Martin Gallwey4 Dec
        • Re: Template query change from v2 to v3Warren Young4 Dec
          • Re: Template query change from v2 to v3Martin Gallwey4 Dec
            • Re: Template query change from v2 to v3Warren Young4 Dec