Class NpgsqlDataSourceFactory

Assembly: redb.Postgres.dll

Builds the every registration path uses, so the
redb.string_collation and redb.lazy_refs session settings are installed in one
place instead of six.

Why a GUC at all. The Free query path builds its SQL inside the database:
pvt_build_query_sql and the functions below it generate the text, and they take twelve
positional parameters with nowhere to put an option. Threading a thirteenth through five
layers would change every one of those signatures. A run-time setting reaches them without
touching a single signature, and pvt_fold_case() reads it with
current_setting('redb.string_collation', true), which yields NULL when unset. Unset
therefore means byte-for-byte the SQL that was generated before this feature existed. The
lazy-reference flag (V4, Л2) rides the same mechanism into the JSON builders.


Why on every hand-out, not in the physical-connection initializer. A session GUC set
with set_config(..., false) lives for the session - but Npgsql sends DISCARD ALL
when a connection returns to the pool, and RESET ALL inside it puts every session
setting back to its default. The physical-connection initializer runs once per backend, so
only the first scope on each pooled connection saw the settings; every later scope got a
connection with both GUCs empty (review, V4). The settings are therefore registered per data
source here and re-applied by each time it opens its
connection: one round trip per context, the same shape MSSQL and SQLite use.

public static class NpgsqlDataSourceFactory

Inheritance

Object→NpgsqlDataSourceFactory

Methods

ApplySessionSettings(NpgsqlDataSource, NpgsqlConnection)

Synchronous for the thread-pool-free lazy path:

public static void ApplySessionSettings(NpgsqlDataSource dataSource, NpgsqlConnection connection)

ApplySessionSettingsAsync(NpgsqlDataSource, NpgsqlConnection)

Re-applies the session settings registered for dataSource on a

public static Task ApplySessionSettingsAsync(NpgsqlDataSource dataSource, NpgsqlConnection connection)

Create(string, string?, bool)

Creates a data source. With stringCollation null and

public static NpgsqlDataSource Create(string connectionString, string? stringCollation, bool lazyReferences = false)