Repository navigation
Description
Summary
The fix landed yesterday ("PostgreSQL wire: answer transaction control with CommandComplete only", commits f1754b4 / 0abbffe) states the defect precisely:
A RowDescription in front of the tag, even with zero fields, makes libpq report PGRES_TUPLES_OK instead of PGRES_COMMAND_OK, and a client that checks the status when it opens a transaction gives up ("Failed to begin transaction").
It fixes exactly one of the two paths that produce that byte. queryCommand() (simple 'Q' protocol) got a new transactionControl flag that skips writeRowDescription/writeDataRows. The extended protocol - Parse/Bind/Describe/Execute - got nothing, and it is where libpq's own PQexecParams/PQexecPrepared, psycopg3 and asyncpg send their statements.
The mechanism is setEmptyResultSet(). parseCommand() calls it for BEGIN/COMMIT/ROLLBACK, and it sets isExpectingResult = true with a non-null (empty) columns map. describeCommand()'s second arm then matches - portal.isExpectingResult && portal.columns != null - and calls answerWithColumns(), which calls writeRowDescription() with an EMPTY map. writeRowDescription only returns early on a NULL map, so an empty one still emits a 'T' message carrying a field count of 0. That is the exact byte the simple-query fix exists to stop sending.
SAVEPOINT/RELEASE/SET do NOT have the problem, because they are marked portal.ignoreExecution = true and fall into the third describeCommand arm, which writes NoData. So the file already answers the same class of statement two different ways, and the three transaction-control keywords are on the wrong side.
The fix's own comments assert the opposite of what the code does. describeCommand's third arm now reads "In practice, SAVEPOINT/RELEASE/SET and nothing else ... they are the only portals that carry no statement, never produce a result, and never get columns" - BEGIN/COMMIT/ROLLBACK also never produce a result, they simply do not reach that arm.
Where (HEAD 06b033d)
postgresw/src/main/java/com/arcadedb/postgres/PostgresNetworkExecutor.java:2516-2534 (parseCommand, the "sql" arm) marks them with setEmptyResultSet, not ignoreExecution:
if (isBeginStatement(upperCaseText)) {
explicitTransactionStarted = true;
setEmptyResultSet(portal);postgresw/src/main/java/com/arcadedb/postgres/PostgresNetworkExecutor.java (setEmptyResultSet):
private void setEmptyResultSet(final PostgresPortal portal) {
portal.executed = true;
portal.isExpectingResult = true;
portal.cachedResultSet = Collections.emptyList();
portal.columns = getColumns(portal.cachedResultSet);
}postgresw/src/main/java/com/arcadedb/postgres/PostgresNetworkExecutor.java:459-473 (describeCommand, the arm they land in):
} else if (portal.isExpectingResult && portal.columns != null) {
...
answerWithColumns(portal);
} else
// In practice, SAVEPOINT/RELEASE/SET and nothing else (issue #6930) ...
writeNoData();postgresw/src/main/java/com/arcadedb/postgres/PostgresNetworkExecutor.java (writeRowDescription): if (columns == null) return; - an EMPTY map is written, with channel.writeUnsignedShort((short) columns.size()) = 0.
Contrast the fixed path, queryCommand():
boolean transactionControl = false;
...
if (!transactionControl) {
...
writeRowDescription(columns);
writeDataRows(cachedResultSet, columns);
}
writeCommandComplete(query.query, cachedResultSet.size());Repro
Raw-socket probe against a server booted from the worktree build (engine/network/server/postgresw target/classes, Postgres plugin on, database postgresdb). For each statement it sends Parse('')/Bind('')/Describe('P')/Execute('')/Sync - the exact sequence libpq's PQexecParams sends - and prints the backend message types, the RowDescription field count and the command tag:
$ java -cp <worktree classes + deps> PgExtProbe
EXTENDED [BEGIN] -> 1 2 T C Z RowDescription fields=0 tag=BEGIN
EXTENDED [SAVEPOINT sp1] -> 1 2 n C Z RowDescription fields=-1 tag=SAVEPOINT
EXTENDED [RELEASE sp1] -> 1 2 n C Z RowDescription fields=-1 tag=RELEASE
EXTENDED [COMMIT] -> 1 2 T C Z RowDescription fields=0 tag=COMMIT
EXTENDED [ROLLBACK] -> 1 2 T C Z RowDescription fields=0 tag=ROLLBACK
EXTENDED [SET extra_float_digits = 3] -> 1 2 n C Z RowDescription fields=-1 tag=SET
EXTENDED [SELECT 1 AS one] -> 1 2 T D C Z RowDescription fields=1 tag=SELECT 1
SIMPLE [BEGIN] -> C Z
SIMPLE [COMMIT] -> C Z
(fields=-1 means no 'T' was sent at all.) The simple protocol answers BEGIN with C Z, as the fix intends. The extended protocol answers the same BEGIN with a 'T' of 0 fields - and SAVEPOINT, on the very same connection, correctly answers 'n'. Real PostgreSQL answers NoData for all six.
Suggested fix
Make the extended protocol classify them the same way it already classifies SAVEPOINT/RELEASE/SET. In parseCommand()'s "sql" arm, set portal.ignoreExecution = true for the BEGIN/COMMIT/ROLLBACK branches instead of (or in addition to) setEmptyResultSet(portal): Describe then answers NoData through the third arm, and executeCommand()'s ignoreExecution branch already answers writeCommandComplete(portal.query, 0), which produces the same BEGIN/COMMIT/ROLLBACK tags as today. If the side effects those branches perform (explicitTransactionStarted, database.begin()) need to stay where they are, the smaller change is to leave portal.columns null for them so describeCommand's second arm no longer matches.
Either way TransactionControlNoRowDescriptionIT should grow an extended-protocol case; as written it cannot catch this.
Scope / confidence
Tried to refute it four ways. (1) Maybe no client Describes a transaction-control portal: libpq's PQexecParams/PQexecPrepared always send Describe('P') before Execute, and they are the parameterized entry points of every libpq-based driver - including the Arrow ADBC PostgreSQL driver the fix's own test javadoc names as the reporter. (2) Maybe Execute repairs it: it does not - the trace shows exactly one 'T', sent by Describe, and executeCommand then finds cachedResultSet empty and writes only the tag. (3) Maybe a zero-field RowDescription is harmless: it is the precise claim the fix that landed yesterday is built on, quoted above, and libpq's PQresultStatus keys PGRES_TUPLES_OK off having received a RowDescription at all. (4) Maybe #7846's ROLLBACK TO handling is the same gap: it is not - that one WAS mirrored into parseCommand(), which is what makes the omission here specific to the RowDescription half. Falsified only if the project decides the extended protocol is out of scope for this behaviour, which would leave the two protocols answering the same statement differently.
Activity
fix(#7868,#7905,#7858,#7906,#7895): carry the owner row, answer trans…
Merge pull request #7929 from ArcadeData/fix/issues-7868-7905-7858-79…
lvca commentedon Sep 18, 2026
Fixed in #7929, released in 26.10.1.
BEGIN,COMMITandROLLBACKsent through the extended query protocol (what psycopg3, asyncpg and libpq-based drivers such as the Arrow ADBC driver use) were answered with an empty result-set header. libpq read that as "this returned rows" instead of "this command succeeded", so a client checking the status when it opened a transaction failed withFailed to begin transaction.Both protocols now answer these three the same way, and transactions open normally on those drivers.
❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.