Hey Zoran,
Yep, I confirm, PQcmdTuples returns empty string where the command
does not affect tuples. This behavior in versions < 9.0 as well.
2010/11/3 Zoran Angelov <[email protected]>
> Hi Koen,
>
> I recently found another problem with Postgres connector.
>
> Actualy when i'm executing a query that does not affect rows (for example
> 'alter table') with Wt::Dbo::Session::execute, PostgresStatement::execute
> will try to convert number of affected rows with
> boost::lexical_cast<int>(PQcmdTuples(result_)).
> The problem is that postgres (PQcmdTuples) returns an empty string when
> number of affected rows is 0, and lexical_cast throws bad_lexical_cast even
> the query is correct.
> I'm using libpq from postgresql 9.0, maybe older versions of libpq returns
> correct strings.
>
> I temporary fixed it at src/Wt/Dbo/backend/Postgres.C::line213 like this:
>
> if (PQresultStatus(result_) == PGRES_COMMAND_OK)
> try { affectedRows_ = boost::lexical_cast<int>(PQcmdTuples(result_)); }
> catch(boost::bad_lexical_cast const &) { affectedRows_=0; }
>
> and it works for me.
>
>
> On Tue, Nov 2, 2010 at 8:43 AM, Koen Deforche <[email protected]> wrote:
>
>> Hey Zoran,
>>
>> 2010/11/2 Zoran Angelov <[email protected]>:
>> > Hi,
>> > I think that i found a bug in assignment operator of Wt::Dbo::Query.
>> > I discovered it while using it with QueryModel, after setting query
>> second
>> > time with setQuery().
>> > the original code is at src/Wt/Dbo/Query_impl.h:
>> > template <class Result>
>> > Query<Result, DynamicBinding>&
>> > Query<Result, DynamicBinding>::operator=
>> > (const Query<Result, DynamicBinding>& other)
>> > {
>> > Impl::QueryBase<Result>::operator=(other);
>> > where_ = other.where_;
>> > groupBy_ = other.groupBy_;
>> > orderBy_ = other.orderBy_;
>> > limit_ = other.limit_;
>> > offset_ = other.offset_;
>> > for (unsigned i = 0; i < other.parameters_.size(); ++i)
>> > parameters_.push_back(other.parameters_[i]->clone());
>> > return *this;
>> > }
>> > I think that before adding cloned parameters, current parameters need to
>> be
>> > removed with reset().
>> > Dbo backend throws exception because of extra binded parameters.
>>
>> I can see that! That looks like the right bug and the correct fix.
>>
>> Regards,
>> koen
>>
>>
>> ------------------------------------------------------------------------------
>> Nokia and AT&T present the 2010 Calling All Innovators-North America
>> contest
>> Create new apps & games for the Nokia N8 for consumers in U.S. and Canada
>> $10 million total in prizes - $4M cash, 500 devices, nearly $6M in
>> marketing
>> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
>> http://p.sf.net/sfu/nokia-dev2dev
>> _______________________________________________
>> witty-interest mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/witty-interest
>>
>
>
>
> ------------------------------------------------------------------------------
> Achieve Improved Network Security with IP and DNS Reputation.
> Defend against bad network traffic, including botnets, malware,
> phishing sites, and compromised hosts - saving your company time,
> money, and embarrassment. Learn More!
> http://p.sf.net/sfu/hpdev2dev-nov
> _______________________________________________
> witty-interest mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/witty-interest
>
>
--
// Dmitriy.
------------------------------------------------------------------------------
Achieve Improved Network Security with IP and DNS Reputation.
Defend against bad network traffic, including botnets, malware,
phishing sites, and compromised hosts - saving your company time,
money, and embarrassment. Learn More!
http://p.sf.net/sfu/hpdev2dev-nov
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest