Skip to content

Error while reusing NpgsqlBatch across different connections with auto preparation #6432

@vonzshik

Description

@vonzshik
[Test]
public async Task Reuse_batch_with_different_connectors()
{
	await using var dataSource = CreateDataSource(csb =>
	{
		csb.MaxAutoPrepare = 10;
		csb.AutoPrepareMinUsages = 2;
	});
	await using var batch = new NpgsqlBatch();
	batch.BatchCommands.Add(new NpgsqlBatchCommand("SELECT 1"));
	await using (var connection = await dataSource.OpenConnectionAsync())
	{
		batch.Connection = connection;

		for (var i = 0; i < 2; i++)
			await batch.ExecuteNonQueryAsync();
	}

	dataSource.Clear();

	await using (var connection = await dataSource.OpenConnectionAsync())
	{
		batch.Connection = connection;
		await batch.ExecuteNonQueryAsync();
	}
}

Repro above throws PostgresException: 26000: prepared statement "_auto0" does not exist.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions