List:MySQL++« Previous MessageNext Message »
From:Rick Gutleber Date:November 19 2008 6:23pm
Subject:Re: Here goes nothing.
View as plain text  
A couple short comments and a question follow.

Rick

Warren Young wrote:
>> Index: test/qssqls.cpp
>> ===================================================================
>> --- test/qssqls.cpp    (revision 2407)
>> +++ test/qssqls.cpp    (working copy)
>> @@ -32,11 +32,8 @@
>> using namespace std;
>>
>>
>> -// Don't use any stringish types here.  That will cause code below to
>> -// eventually try to call DBDriver::escape_string() through the
>> -// Connection object, which we don't really have, so it asplodes.
>
> I'm not sure what's going on here exactly.  Are you saying your patch 
> fixes this, or that you noticed that the warning just isn't true any 
> more?  I would have thought the latter, since without a connection, 
> Query::escape_string() calls the static version of 
> DBDriver::escape_string(), which should always succeed.  It's only the 
> object method version that requires a connection.
>
> Either way, this wants to be a separate patch.  It's not really 
> anything to do with insertfrom().


It's the latter.  I'll submit it as a separate patch later.  Of course, 
the test suite doesn't seem to call this and it's not "silent" like 
tests are supposed to be.  It's more of an example.  Perhaps it should 
be moved into examples and called by dtest.  I think it would be a good 
addition for dtest.  If so, then test/sqlstream.cpp should be moved too.
Let me know what you think if you'd like me to make any changes.


>> +        if (tokenize_line(line, strings) != 6) {
>> +            cerr << "Error parsing input line (doesn't have 6 
>> fields) " <<
>> +                    "in file '" << filename << "'" << endl;
>> +            input.close();
>> +            return false;
>> +        }
>> +       
>> +        row.item = strings[0];
>> +        row.num = strings[1];
>> +        row.weight = strings[2];
>> +        row.price = strings[3];
>> +        row.sdate = strings[4];
>> +        row.description = strings[5];
>
> I don't think a bad line should be fatal.  Also, you should be able to 
> construct and append the row on a single line:
>
>     if (tokenize_line(line, strings) == 6) {
>         stock_vector.push_back(stock(strings[0], strings[1]...);
>     }
>     else {
>         cerr << "Insert angst here";
>     }


I didn't do this because it won't take that line without casts for at 
least some of those arguments, which would have resulted in something 
really long and hard to read.  I would have expected implicit casts to 
kick in since the arguments are of type mysqlpp::String.  Am I missing 
something?


>> +        // this policy means that after the INSERT statement exceeds
>> +        // 1000 characters in length, it will be executed and a new on
>> +        // started
>> +        mysqlpp::SizeThresholdInsertPolicy<> insert_policy(1000);
>> +
>> +        query.insertfrom(stock_vector.begin(), stock_vector.end(),
>> +                insert_policy);
>> +
>> +        query.insertfrom(stock_vector2.begin(), stock_vector2.end(),
>> +                insert_policy );
>
> I'm not seeing enough value in two separate reads and inserts.  It 
> complicates things.  Instead, I'd rather just encourage people to 
> experiment with different policies to see how it changes the 
> insertion.  I'd keep the stock.txt dataset, as it's more diverse.  Or, 
> merge the two.

Originally, I'd planned to show it using two different policies, but 
then decided that was silly.  Why would you ever use more than one 
policy for any given setup?  And yes, you're right... I ran out of ideas 
electronic supplies for making stock2.txt.  ;-)


Thread
Re: Here goes nothing.Warren Young17 Nov
  • Re: Here goes nothing.Rick Gutleber19 Nov
    • Re: Here goes nothing.Warren Young19 Nov
      • Re: Here goes nothing.Rick Gutleber19 Nov
        • Re: Here goes nothing.Jonathan Wakely20 Nov
      • Unexpected results with stock (was Re: Here goes nothing.)Rick Gutleber19 Nov
Re: Here goes nothing.Warren Young17 Nov