refactor(data): pin server output settings and guard busy connections

Pin bytea_output=hex and standard_conforming_strings=on in the startup
packet instead of tracking ParameterStatus values nobody read, so the
legacy bytea escape decoder goes away. A PostgreSQL connection now
refuses a new command while a row stream is still open, and the pool
discards such a connection. Drop unused SQLite declarations.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-02 10:13:09 +00:00
1 parent 49fa8c5214
commit 8d9b04c713
7 files changed
+51 -51

No files matched your search

@@ -61,10 +61,13 @@ public sealed class PgProtocolUnitTests
}
[Test]
public void DecodesByteaInHexAndEscapeFormats()
public void DecodesHexByteaAndRejectsOtherForms()
{
Assert.BytesEqual(new byte[] { 0xDE, 0xAD }, (byte[])PgTypes.Decode(PgTypes.Bytea, "\\xdead"u8));
Assert.BytesEqual(new byte[] { (byte)'a', 0, (byte)'\\', 0xFF }, (byte[])PgTypes.Decode(PgTypes.Bytea, "a\\000\\\\\\377"u8));
Assert.BytesEqual(new byte[] { 0xDE, 0xAD, 0x01 }, (byte[])PgTypes.Decode(PgTypes.Bytea, "\\xdeAD01"u8));
Assert.Equal(0, ((byte[])PgTypes.Decode(PgTypes.Bytea, "\\x"u8)).Length);
Assert.Throws<FormatException>(() => PgTypes.Decode(PgTypes.Bytea, "a\\000"u8));
Assert.Throws<FormatException>(() => PgTypes.Decode(PgTypes.Bytea, "\\xabc"u8));
Assert.Throws<FormatException>(() => PgTypes.Decode(PgTypes.Bytea, "\\xzz"u8));
}
[Theory]
@@ -260,6 +260,17 @@ public sealed class PgWireTests(TestContext context) : DatabaseTest(context)
Assert.Equal("x", second.GetString("b"));
}
[Test]
public async Task ACommandCannotStartWhileARowStreamIsOpen()
{
await using var session = await (await OpenAsync()).OpenAsync(Ct);
var rows = session.QueryAsync("SELECT generate_series(1, 1000)", [], Ct).GetAsyncEnumerator(Ct);
Assert.True(await rows.MoveNextAsync());
await Assert.ThrowsAsync<InvalidOperationException>(() => session.ExecuteAsync("SELECT 1", [], Ct));
await rows.DisposeAsync();
Assert.Equal(1, await session.ScalarAsync<int>("SELECT 1", [], Ct));
}
[Test]
public async Task NoticesAndScriptsDoNotDisturbTheSession()
{