Skip to content

PostgresInstallation

Namespace: Ankus.PgConfig

Assembly: Ankus.PgConfig.dll

Describes one PostgreSQL installation by querying its authoritative pg_config executable.

public sealed class PostgresInstallation

Inheritance: object

Gets the installation directory containing PostgreSQL executables.

public string BinDirectory { get; }

Value: string

Gets the platform-correct path to PostgreSQL’s createdb executable.

public string CreateDbPath { get; }

Value: string

Gets the platform-correct path to PostgreSQL’s dropdb executable.

public string DropDbPath { get; }

Value: string

Gets the public header directory, including dependencies of the server headers.

public string IncludeDirectory { get; }

Value: string

Gets the platform-correct path to PostgreSQL’s initdb executable.

public string InitDbPath { get; }

Value: string

Gets the Ankus version selector for this installation, such as pg18.

public string Label { get; }

Value: string

Gets PostgreSQL’s native extension library directory.

public string LibraryDirectory { get; }

Value: string

Gets the absolute path to pg_config.

public string PgConfigPath { get; }

Value: string

Gets the platform-correct path to PostgreSQL’s pg_ctl executable.

public string PgCtlPath { get; }

Value: string

Gets the preprocessor arguments reported by this installation, split without shell expansion.

public IReadOnlyList<string> PreprocessorArguments { get; }

Value: IReadOnlyList<string>

Gets the preprocessor arguments reported by this installation’s build configuration.

public string PreprocessorFlags { get; }

Value: string

Gets the platform-correct path to PostgreSQL’s psql executable.

public string PsqlPath { get; }

Value: string

Gets the server header directory for compiling native extension boundaries against this installation.

public string ServerIncludeDirectory { get; }

Value: string

Gets PostgreSQL’s architecture-independent shared-data directory.

public string SharedDirectory { get; }

Value: string

Gets the exported information this installation was read from, or null for an installation on this machine.

public PostgresTargetInfo? TargetInfo { get; }

Value: PostgresTargetInfo

Such an installation can supply headers and build values to compile and package an extension, but has no executables or server on this machine.

Gets the PostgreSQL version reported by this installation.

public PostgresVersion Version { get; }

Value: PostgresVersion

Creates an installation descriptor by querying an explicit pg_config executable, or by reading exported target information.

public static Task<PostgresInstallation> CreateAsync(string pgConfigPath, CancellationToken cancellationToken = default)

Parameters:

pgConfigPath — string

Path to pg_config, or to an extracted ManifestFileName.

cancellationToken — CancellationToken

Cancels pg_config queries.

Returns: Task<PostgresInstallation>

The queried PostgreSQL installation.

DiscoverAsync(int, string?, CancellationToken)

Section titled “DiscoverAsync(int, string?, CancellationToken)”

Discovers a specific PostgreSQL major using an explicit Ankus home for registrations and managed installations. An unregistered installation without its server headers, such as one from a client-only package, is skipped.

public static Task<PostgresInstallation> DiscoverAsync(int major, string? homeDirectory, CancellationToken cancellationToken)

Parameters:

major — int

The required PostgreSQL major version.

homeDirectory — string

The selected home, or null to use ANKUS_HOME and the ordinary default.

cancellationToken — CancellationToken

Cancels installation queries.

Returns: Task<PostgresInstallation>

The registered installation or the first matching discovery candidate.

Discovers a specific PostgreSQL major without requiring environment variables. Nonstandard installations can be registered as pgXX paths in the Ankus home’s config.json. ANKUS_HOME selects that home, defaulting to ~/.ankus.

public static Task<PostgresInstallation> DiscoverAsync(int major, CancellationToken cancellationToken = default)

Parameters:

major — int

The required PostgreSQL major version.

cancellationToken — CancellationToken

Cancels installation queries.

Returns: Task<PostgresInstallation>

The first matching installation in discovery order.

Discovers PostgreSQL 18 from persisted configuration, managed installations, PATH, and platform installation locations.

public static Task<PostgresInstallation> DiscoverAsync(CancellationToken cancellationToken = default)

Parameters:

cancellationToken — CancellationToken

Cancels pg_config queries.

Returns: Task<PostgresInstallation>

The discovered PostgreSQL installation.

GetPreprocessorArgumentsAsync(CancellationToken)

Section titled “GetPreprocessorArgumentsAsync(CancellationToken)”

Resolves preprocessor arguments for native compilation on the current platform.

public Task<IReadOnlyList<string>> GetPreprocessorArgumentsAsync(CancellationToken cancellationToken = default)

Parameters:

cancellationToken — CancellationToken

Cancels native SDK discovery.

Returns: Task<IReadOnlyList<string>>

PostgreSQL’s arguments with the active macOS SDK selected when compiling on macOS.

Exceptions:

On macOS, SDKROOT selects an absolute installed SDK path; otherwise the active Apple developer tools select it. Historical SDK roots from PostgreSQL’s build machine are replaced. Other arguments and the recorded properties remain unchanged.

GetRegressionDriverPathAsync(CancellationToken)

Section titled “GetRegressionDriverPathAsync(CancellationToken)”

Locates this installation’s PostgreSQL regression driver in its PGXS tree or Windows executable directory. Ordinary installation discovery does not require the regression tools to be installed.

public Task<string> GetRegressionDriverPathAsync(CancellationToken cancellationToken = default)

Parameters:

cancellationToken — CancellationToken

Cancels the PGXS query.

Returns: Task<string>

The absolute path to the installed pg_regress executable.

Exceptions:

On Windows, include this installation’s BinDirectory in the child process PATH so the driver can load its PostgreSQL DLLs.

GetValgrindSuppressionsPathAsync(CancellationToken)

Section titled “GetValgrindSuppressionsPathAsync(CancellationToken)”

Locates PostgreSQL’s Valgrind suppressions for this installation, which Valgrind startup passes to Memcheck as pgrx does when it keeps the PostgreSQL source tree.

public Task<string?> GetValgrindSuppressionsPathAsync(CancellationToken cancellationToken = default)

Parameters:

cancellationToken — CancellationToken

Cancels the PGXS query.

Returns: Task<string>

The src/tools/valgrind.supp file that ankus init installs in the PGXS tree, else the one in the source tree that PGXS records as abs_top_srcdir when it still exists, else null.