You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
NpgsqlLogManager.IsParameterLoggingEnabled=true;NpgsqlLogManager.Provider=newConsoleLoggingProvider(NpgsqlLogLevel.Debug);using(varconnection=newNpgsqlConnection("connstring")){connection.Open();using(varcommand=connection.CreateCommand()){command.CommandText="select * from <table>where isDeleted = @isDeleted AND year = @year";command.Parameters.AddWithValue("@year",1991);command.Parameters.AddWithValue("@isDeleted",false);command.ExecuteReader();}}
Console output:
Executing statement(s):
select * from <table> where isDeleted = $1 AND year = $2
Parameters:
$1: 1991 $2: False
When writing log, you assign $index by order of parameters in list. However when you execute you create query index based on order of appearance.
NpgsqlCommand LogCommand method - $ index based on list possition
SqlQueryParser param (goto tag) assigns index based on appearance in query
Thanks for the repro @floatas! The issue was quite simple in the end: we were logging all the parameters from the NpgsqlCommand, in the order in which they were arranged there. The right thing is to log the parameters for each statements separately, from the NpgsqlStatement instance.
@indy-singh we're no longer releasing new patches for 3.2, unless maybe something really critical comes along - I don't think this really qualifies. Any specific reason you can't upgrade to later versions?
Yes, there was #2224 which we got caught up in. Looks like it was fixed #2631 and released as a part of 4.1.0. I'll confirm that before I roll out the upgrade to production.
Great, let me know how it goes! Idle connections are definitely pruned now, although we still have some room for improvement - would be good to get your feedback.
Activity
floatas commentedon Apr 8, 2019
Tested with 4.0.5 same issue
Fix order issue in parameter logic
roji commentedon Apr 10, 2019
Thanks for the repro @floatas! The issue was quite simple in the end: we were logging all the parameters from the NpgsqlCommand, in the order in which they were arranged there. The right thing is to log the parameters for each statements separately, from the NpgsqlStatement instance.
@YohDeadfall @austindrenski would appreciate a quick review on this, we should get the fix into 4.0.6.
Fix order issue in parameter logic
Fix order issue in parameter logic
roji commentedon Aug 21, 2019
Oops, guess I forgot to backport this... Thanks @YohDeadfall!
indy-singh commentedon Apr 30, 2020
Is there any chance of getting this fix into 3.2.7?
Indy
roji commentedon Apr 30, 2020
@indy-singh we're no longer releasing new patches for 3.2, unless maybe something really critical comes along - I don't think this really qualifies. Any specific reason you can't upgrade to later versions?
indy-singh commentedon Apr 30, 2020
Yes, there was #2224 which we got caught up in. Looks like it was fixed #2631 and released as a part of 4.1.0. I'll confirm that before I roll out the upgrade to production.
Thanks @roji
roji commentedon Apr 30, 2020
Great, let me know how it goes! Idle connections are definitely pruned now, although we still have some room for improvement - would be good to get your feedback.