-
Notifications
You must be signed in to change notification settings - Fork 875
Description
Npgsql allows users to change type mappings, either by plugins or manually. Changes can be done at two levels:
- The global type mapper (static
NpgsqlConnection.GlobalTypeMapper). This holds for all connections - The connection-specific type mapper (non-static
NpgsqlConnection.TypeMapper).
Changes to the connection-specific type mapper need to be restricted to the lifetime of the connection. That is, when a connection is returned to the pool, all changes must be reset, otherwise they will leak once the physical connection is returned again.
The current method for handling this checking whether any changes were done, and if so, disposing the entire type mapper and rebuilding mappings from scratch. This is a pretty heavy process that makes connection-based type mapping not very suitable for high-perf scenarios.
Instead, we could setup a sort of "undo list", tracking which mappings were changed and what needs to be done to reset them back.