Sitelet https://github.com/npgsql/npgsql/pull/6073
Skip to content

Fix adding to hash lookup while renaming an unnamed parameter - #6073

Merged
vonzshik merged 1 commit into
mainfrom
6067-rename-unnamed-parameter-lookup-fix
Mar 26, 2025
Merged

vonzshik merged 1 commit into
mainfrom
6067-rename-unnamed-parameter-lookup-fix

Conversation

@vonzshik

Copy link
Copy Markdown
Contributor

Fixes #6067

@vonzshik
vonzshik requested a review from roji as a code owner March 24, 2025 11:08

@NinoFloris NinoFloris left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

var oldTrimmedName = parameter.TrimmedName;
parameter.ChangeParameterName(value);

if (_caseInsensitiveLookup is null || _caseInsensitiveLookup.Count == 0)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is a strange check, and it's not mirrored in any of the other operations...

Maybe at one point the idea was to allow the lookup to be fully bypassed again until the threshold would be reached once more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was to support cached NpgsqlCommand, as for them we clear lookups, but do not null them. But yeah, since other checks ignore this case, it's better to just remove it from here rather than try to make the lookup completely lazy.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would end up doing the same thing right? We enable the lookup at some point and we never disable it.

I recall that when I made this there was some thought that it would be nice if we would drop back to the fast path until the threshold.

Seeing where we landed in the end - and in all other operations (lookupadd etc) we only check for null - I must have missed this check when I decided it was not worth the complexity.

@vonzshik
vonzshik merged commit ef219b7 into main Mar 26, 2025
@vonzshik
vonzshik deleted the 6067-rename-unnamed-parameter-lookup-fix branch March 26, 2025 11:17
vonzshik added a commit that referenced this pull request Mar 26, 2025
vonzshik added a commit that referenced this pull request Mar 26, 2025
@vonzshik

Copy link
Copy Markdown
Contributor Author

Backported to 9.0.4 via 5cbd025, 8.0.8 via d119175

This was referenced Nov 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PostgresException: 42804 when executing several queries with parameters with one open connection

2 participants