List:MySQL++« Previous MessageNext Message »
From:Jay Sprenkle Date:July 13 2011 8:58pm
Subject:Re: update fails... any suggestions?
View as plain text  
Thanks for the help Warren.

The revised query still seg faults when exceptions are turned on.
I tried quoting just the password, and again quoting all the parameters
(using the 'q').
The blob is random 8 bit binary data (it's an encrypted password).
Is the escaping mechanism intended for text perhaps?
I removed all code using the connection except this update.
Still no joy.

         mysqlpp::Query query = conn.query( "UPDATE customer SET
AccountName=%2q, Active=%3, Password=%1q WHERE CustomerId=%0" );
         query.parse();
         mysqlpp::SimpleResult res = query.execute(
            mysqlpp::sql_int( CustomerId ),
            mysqlpp::sql_blob( data, sizeof(data) ),
            mysqlpp::sql_varchar(
widget.AccountName->text().toAscii().data() ),
            mysqlpp::sql_bool( widget.ActiveCheckBox->checkState() ==
Qt::Checked ? 1 : 0 )
            );



On Wed, Jul 13, 2011 at 3:37 PM, Warren Young <mysqlpp@stripped> wrote:

> On 7/13/2011 2:04 PM, Jay Sprenkle wrote:
>
>>
>>          mysqlpp::Query query = conn.query( "UPDATE customer SET
>> AccountName=%2q, Active=%3, Password=%1 WHERE CustomerId=%0" );
>>          query.parse();
>>          mysqlpp::SQLQueryParms parms;
>>
> >           ....noise noise noise...
>
> Why are you bothering with direct use of SQLQueryParms?  This does the same
> thing, with less code:
>
>
>    mysqlpp::SimpleResult res = query.execute(
>            mysqlpp::sql_int(CustomerId),
>            mysqlpp::sql_blob(data, sizeof(data)),
>            ...etc...);
>
>
>  If I turn off exceptions for the connection it fails silently (the
>> result.info() method returns nothing).
>>
>
> That just gets you "additional information".  To check for errors, test res
> in bool context instead:
>
>    if (res) {
>        // query was successful
>    }
>    else {
>        // FAIL
>
>    }
>
>  if I turn exceptions on it seg faults here when trying to convert to a
>> string:
>>
>
> You need to quote and escape BLOBs.  Your binary password is being inserted
> into the query string raw, as-is.
>
>
>

Thread
update fails... any suggestions?Jay Sprenkle13 Jul
  • Re: update fails... any suggestions?Warren Young13 Jul
    • Re: update fails... any suggestions?Jay Sprenkle13 Jul
      • Re: update fails... any suggestions?Warren Young13 Jul
        • Re: update fails... any suggestions?Warren Young13 Jul
        • Re: update fails... any suggestions?Jay Sprenkle13 Jul
          • Re: update fails... any suggestions?Kemet14 Jul
            • Re: update fails... any suggestions?Warren Young14 Jul
              • Re: update fails... any suggestions?Jay Sprenkle14 Jul
                • Re: update fails... any suggestions?Jay Sprenkle14 Jul
                  • Re: update fails... any suggestions?Jay Sprenkle14 Jul
                    • Re: update fails... any suggestions?Jay Sprenkle14 Jul
                      • Re: update fails... any suggestions?Warren Young15 Jul
                        • Re: update fails... any suggestions?Jay Sprenkle15 Jul