Skip to content

Eventuous breaks with npgsql >= 7.0.0 #182

@fbjerggaard

Description

@fbjerggaard

When trying to use the Postgres event store along with npgsql >= 7.0.0 it breaks with the following exception:

Npgsql.PostgresException (0x80004005): 42883: procedure eventuous.read_all_forwards(_from_position => bigint, _count => integer) does not exist

The workaround is to put the following code somewhere (I put it above the services.AddAggregateStore<PostgresStore>();):

AppContext.SetSwitch("Npgsql.EnableStoredProcedureCompatMode", true);

The real solution would probably be something like rewriting this (and other similar methods):

protected override NpgsqlCommand PrepareCommand(NpgsqlConnection connection, long start) {
var cmd = new NpgsqlCommand(Schema.ReadAllForwards, connection);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("_from_position", NpgsqlDbType.Bigint, start + 1);
cmd.Parameters.AddWithValue("_count", NpgsqlDbType.Integer, Options.MaxPageSize);
return cmd;
}

into just using the recommended plain method which is SELECT * FROM function_name($1,$2)

Source: https://www.npgsql.org/doc/release-notes/7.0.html#a-namecommandtypestoredprocedure-commandtypestoredprocedure-now-invokes-procedures-instead-of-functions

Another issue is that connections to the database are not reused/not closed which is probably related to the new DbDataSource way of connecting: https://www.npgsql.org/doc/release-notes/7.0.html#dbdatasource

Metadata

Metadata

Assignees

No one assigned

    Labels

    postgresPostgreSQL-specific issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions