Skip to content

Conversation

NinoFloris
Copy link
Member

@NinoFloris NinoFloris commented Feb 26, 2024

Brings our compat with pg-likes back to <= 7.x levels.

These changes also improve object parameter cache re-use when writing db nulls and non-nulls of a constant type via the same parameter instance. This will feed into improvements to binary importer perf in a later pr.

Fixes #5503

improves object parameter resolution cache re-use when writing nulls and non nulls as well
@NinoFloris NinoFloris force-pushed the remove-unknown-pgtype-dependency branch from 7c1d61e to a4526a7 Compare February 26, 2024 17:48
@NinoFloris NinoFloris added this to the 8.0.3 milestone Feb 26, 2024
public void DBNull_reuses_type_info([Values]bool generic)
{
// Bootstrap datasource.
using (var _ = OpenConnection()) {}
Copy link
Member

Choose a reason for hiding this comment

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

nit: move to a fixture initializer ([SetUp])?

using (var _ = OpenConnection()) {}

var param = generic ? new NpgsqlParameter<object> { Value = "value" } : new NpgsqlParameter { Value = "value" };
param.ResolveTypeInfo(DataSource.SerializerOptions);
Copy link
Member

Choose a reason for hiding this comment

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

Ideally we'd test public behavior rather than internal functions, but not super important.

Copy link
Member Author

Choose a reason for hiding this comment

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

I debated whether to add these tests. Given they impact edge-cases in the binary importer I decided it's worth making sure these internal contracts (GetResolutionInfo/SetResolutionInfo) keep working correctly.

public string DisplayName =>
Value.StartsWith("pg_catalog", StringComparison.Ordinal)
Value.StartsWith("pg_catalog", StringComparison.Ordinal) || Value == Unspecified
Copy link
Member

Choose a reason for hiding this comment

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

In which situation will DisplayName actually get called for Unspecified?

Copy link
Member Author

@NinoFloris NinoFloris Mar 5, 2024

Choose a reason for hiding this comment

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

Mostly for completeness. Though you could do NpgsqlParameter() { DataTypeName = "-.-" }, try to write it, resolver won't find a match, and we'll create an error message containing the displayname.

Adding a case for Unspecified means we return "-" (which matches pg) vs "-.-".

@NinoFloris NinoFloris merged commit b9811a2 into main Mar 5, 2024
@NinoFloris NinoFloris deleted the remove-unknown-pgtype-dependency branch March 5, 2024 13:31
NinoFloris added a commit that referenced this pull request Mar 5, 2024
@roji roji removed this from the 8.0.3 milestone Mar 5, 2024
@roji
Copy link
Member

roji commented Mar 5, 2024

@NinoFloris just putting a reminder here to backport in case you forget.

NinoFloris added a commit that referenced this pull request Mar 11, 2024
Fixes #5503

(cherry picked from commit b9811a2)
@NinoFloris
Copy link
Member Author

Backported to 8.0.3 via 6201e1b

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.

A PostgreSQL type with the name 'unknown' was not found in the current database info
2 participants