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
However because the arg frac=1.0 and there's an default on the options lookup @cursor_tuple_fraction ||= @options.fetch(:fraction) { 1.0 }, I believe the early return return @cursor_tuple_fraction if frac == @cursor_tuple_fraction will always fire unless you set a custom value not equal to 1.0.
This means both that the 1.0 default never gets applied, and also that it's impossible to apply a configuration value of 1.0.
I think the early return probably is an unnecessary optimization in terms of speed, and having any early return will possibly cause bugs since the default config on a given Postgres install might not be 0.1 anyway, so it's not possible to fully fix by changing to only return early if the desired value is 0.1.
Finally, the gem doesn't reset the value after the cursor is done, so it's potentially poisoning the connection settings for any other use not going through the gem.
The text was updated successfully, but these errors were encountered:
Had a quick dig, and can confirm it by just looking at gem's code.
the gem doesn't reset the value after the cursor is done, so it's potentially poisoning the connection settings for any other use not going through the gem.
The good news if you don't explicitly pass :fraction to cursor it won't be set but also it won't poison the connection.
xathien
added a commit
to xathien/postgresql_cursor
that referenced
this issue
Mar 9, 2023
The early return removed the ability to override Postgres' default fraction of `0.1` with `1.0`. A workaround was to use `0.99999` but that's a little bit ugly, so let's just always set the tuple fraction.
Alternatively, we could check the current fraction on the `@connection` and only change it if it's different, which would also allow us to revert the temporary fraction change afterward, but that's an adjustment for another PR.
Partially fixesafair#49
Looking at https://github.com/afair/postgresql_cursor/blob/master/lib/postgresql_cursor/cursor.rb#L298, the comment explains that the gem prefers to override PostgreSQL's default
cursor_tuple_fraction = 0.1
to1.0
.However because the arg
frac=1.0
and there's an default on the options lookup@cursor_tuple_fraction ||= @options.fetch(:fraction) { 1.0 }
, I believe the early returnreturn @cursor_tuple_fraction if frac == @cursor_tuple_fraction
will always fire unless you set a custom value not equal to1.0
.This means both that the
1.0
default never gets applied, and also that it's impossible to apply a configuration value of1.0
.I think the early return probably is an unnecessary optimization in terms of speed, and having any early return will possibly cause bugs since the default config on a given Postgres install might not be
0.1
anyway, so it's not possible to fully fix by changing to only return early if the desired value is0.1
.Finally, the gem doesn't reset the value after the cursor is done, so it's potentially poisoning the connection settings for any other use not going through the gem.
The text was updated successfully, but these errors were encountered: