=== Applying patches on top of PostgreSQL commit ID 7d3247ccd15be860b098679e39eff7b6c8040355 === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Wed Sep 2 09:03:25 UTC 2026 On branch cf/7232 nothing to commit, working tree clean === using 'git am' to apply patch ./v1-0001-Add-protocol-compression.patch === Applying: Add protocol compression Using index info to reconstruct a base tree... M doc/src/sgml/libpq.sgml M doc/src/sgml/protocol.sgml M src/backend/commands/copyfromparse.c M src/interfaces/libpq/fe-connect.c M src/interfaces/libpq/fe-protocol3.c M src/interfaces/libpq/libpq-int.h Falling back to patching base and 3-way merge... Auto-merging src/interfaces/libpq/libpq-int.h Auto-merging src/interfaces/libpq/fe-protocol3.c CONFLICT (content): Merge conflict in src/interfaces/libpq/fe-protocol3.c Auto-merging src/interfaces/libpq/fe-connect.c Auto-merging src/backend/commands/copyfromparse.c Auto-merging doc/src/sgml/protocol.sgml Auto-merging doc/src/sgml/libpq.sgml error: Failed to merge in the changes. hint: Use 'git am --show-current-patch=diff' to see the failed patch Patch failed at 0001 Add protocol compression When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort". === using patch(1) to apply patch ./v1-0001-Add-protocol-compression.patch === patching file doc/src/sgml/config.sgml patching file doc/src/sgml/libpq.sgml Hunk #1 succeeded at 2234 (offset -17 lines). Hunk #2 succeeded at 9347 (offset -17 lines). patching file doc/src/sgml/protocol.sgml Hunk #1 succeeded at 335 (offset -11 lines). Hunk #2 succeeded at 4650 (offset -11 lines). patching file meson.build patching file src/backend/commands/copyfromparse.c patching file src/backend/libpq/pqcomm.c patching file src/backend/replication/walsender.c patching file src/backend/tcop/backend_startup.c patching file src/backend/tcop/postgres.c patching file src/backend/utils/misc/guc_parameters.dat patching file src/backend/utils/misc/guc_tables.c patching file src/backend/utils/misc/postgresql.conf.sample patching file src/include/libpq/libpq.h patching file src/include/libpq/protocol.h patching file src/interfaces/libpq/Makefile patching file src/interfaces/libpq/fe-connect.c Hunk #1 succeeded at 346 (offset -1 lines). Hunk #2 succeeded at 2171 (offset 1 line). Hunk #3 succeeded at 5144 (offset -33 lines). Hunk #4 succeeded at 5167 (offset -33 lines). Hunk #5 succeeded at 5343 (offset -33 lines). patching file src/interfaces/libpq/fe-exec.c patching file src/interfaces/libpq/fe-protocol3.c Hunk #7 FAILED at 1916. Hunk #8 FAILED at 1996. Hunk #9 succeeded at 1805 with fuzz 2 (offset -210 lines). Hunk #10 succeeded at 2310 (offset -37 lines). Hunk #11 succeeded at 2350 (offset -37 lines). Hunk #12 succeeded at 2617 (offset -37 lines). Hunk #13 succeeded at 3027 with fuzz 2 (offset -37 lines). 2 out of 13 hunks FAILED -- saving rejects to file src/interfaces/libpq/fe-protocol3.c.rej patching file src/interfaces/libpq/fe-trace.c patching file src/interfaces/libpq/libpq-int.h patching file src/interfaces/libpq/meson.build patching file src/interfaces/libpq/t/007_compression.pl patching file src/interfaces/libpq/test/libpq_testclient.c patching file src/interfaces/libpq/test/meson.build Unstaged changes after reset: M doc/src/sgml/config.sgml M doc/src/sgml/libpq.sgml M doc/src/sgml/protocol.sgml M meson.build M src/backend/commands/copyfromparse.c M src/backend/libpq/pqcomm.c M src/backend/replication/walsender.c M src/backend/tcop/backend_startup.c M src/backend/tcop/postgres.c M src/backend/utils/misc/guc_parameters.dat M src/backend/utils/misc/guc_tables.c M src/backend/utils/misc/postgresql.conf.sample M src/include/libpq/libpq.h M src/include/libpq/protocol.h M src/interfaces/libpq/Makefile M src/interfaces/libpq/fe-connect.c M src/interfaces/libpq/fe-exec.c M src/interfaces/libpq/fe-protocol3.c M src/interfaces/libpq/fe-trace.c M src/interfaces/libpq/libpq-int.h M src/interfaces/libpq/meson.build M src/interfaces/libpq/test/libpq_testclient.c M src/interfaces/libpq/test/meson.build Removing src/interfaces/libpq/fe-protocol3.c.rej Removing src/interfaces/libpq/t/007_compression.pl === using 'git apply' to apply patch ./v1-0001-Add-protocol-compression.patch === Applied patch to 'doc/src/sgml/config.sgml' cleanly. Applied patch to 'doc/src/sgml/libpq.sgml' cleanly. Applied patch to 'doc/src/sgml/protocol.sgml' cleanly. Applied patch to 'meson.build' cleanly. Applied patch to 'src/backend/commands/copyfromparse.c' cleanly. Applied patch to 'src/backend/libpq/pqcomm.c' cleanly. Applied patch to 'src/backend/replication/walsender.c' cleanly. Applied patch to 'src/backend/tcop/backend_startup.c' cleanly. Applied patch to 'src/backend/tcop/postgres.c' cleanly. Applied patch to 'src/backend/utils/misc/guc_parameters.dat' cleanly. Applied patch to 'src/backend/utils/misc/guc_tables.c' cleanly. Applied patch to 'src/backend/utils/misc/postgresql.conf.sample' cleanly. Applied patch to 'src/include/libpq/libpq.h' cleanly. Applied patch to 'src/include/libpq/protocol.h' cleanly. Applied patch to 'src/interfaces/libpq/Makefile' cleanly. Applied patch to 'src/interfaces/libpq/fe-connect.c' cleanly. Applied patch to 'src/interfaces/libpq/fe-exec.c' cleanly. Applied patch to 'src/interfaces/libpq/fe-protocol3.c' with conflicts. Applied patch to 'src/interfaces/libpq/fe-trace.c' cleanly. Applied patch to 'src/interfaces/libpq/libpq-int.h' cleanly. Applied patch to 'src/interfaces/libpq/meson.build' cleanly. Falling back to direct application... Applied patch to 'src/interfaces/libpq/test/libpq_testclient.c' cleanly. Applied patch to 'src/interfaces/libpq/test/meson.build' cleanly. U src/interfaces/libpq/fe-protocol3.c diff --cc src/interfaces/libpq/fe-protocol3.c index 1fd427cb9be,f1f9103fe33..00000000000 --- a/src/interfaces/libpq/fe-protocol3.c +++ b/src/interfaces/libpq/fe-protocol3.c @@@ -1445,6 -1914,16 +1914,19 @@@ pqGetNegotiateProtocolVersion3(PGconn * { int their_version; int num; ++<<<<<<< ours ++======= + bool found_test_protocol_negotiation; + bool expect_test_protocol_negotiation; + bool requested_compression; + + /* + * During 19beta only, if protocol grease is in use, assume that it's the + * cause of any invalid messages encountered below. We'll print extra + * information for the end user in that case. + */ + bool need_grease_info = (conn->max_pversion == PG_PROTOCOL_GREASE); ++>>>>>>> theirs if (pqGetInt(&their_version, 4, conn) != 0) goto eof; @@@ -1512,9 -1992,19 +1994,22 @@@ conn->pversion = their_version; /* - * Check that all expected unsupported parameters are reported by the - * server. + * We don't currently request any protocol extensions, so we don't expect + * the server to reply with any either. */ ++<<<<<<< ours ++======= + found_test_protocol_negotiation = false; + expect_test_protocol_negotiation = (conn->max_pversion == PG_PROTOCOL_GREASE); + #ifdef USE_ZSTD + requested_compression = conn->compression && + (strcmp(conn->compression, "zstd") == 0 || + strcmp(conn->compression, "prefer") == 0); + #else + requested_compression = false; + #endif + ++>>>>>>> theirs for (int i = 0; i < num; i++) { if (pqGets(&conn->workBuffer, conn)) @@@ -1526,8 -2016,43 +2021,48 @@@ libpq_append_conn_error(conn, "received invalid protocol negotiation message: server reported unsupported parameter name without a \"%s\" prefix (\"%s\")", "_pq_.", conn->workBuffer.data); goto failure; } ++<<<<<<< ours + libpq_append_conn_error(conn, "received invalid protocol negotiation message: server reported an unsupported parameter that was not requested (\"%s\")", + conn->workBuffer.data); ++======= + + /* Check if this is the expected test parameter */ + if (expect_test_protocol_negotiation && + strcmp(conn->workBuffer.data, "_pq_.test_protocol_negotiation") == 0) + { + found_test_protocol_negotiation = true; + } + else if (requested_compression && + strcmp(conn->workBuffer.data, "_pq_.compression") == 0) + { + if (strcmp(conn->compression, "prefer") == 0) + conn->compression_rejected = true; + else + { + libpq_append_conn_error(conn, + "server does not support protocol compression method \"zstd\""); + need_grease_info = false; + goto failure; + } + } + else + { + libpq_append_conn_error(conn, "received invalid protocol negotiation message: server reported an unsupported parameter that was not requested (\"%s\")", + conn->workBuffer.data); + goto failure; + } + } + + /* + * If we requested protocol grease, the server must report + * _pq_.test_protocol_negotiation as unsupported. This ensures + * comprehensive NegotiateProtocolVersion implementation. + */ + if (expect_test_protocol_negotiation && !found_test_protocol_negotiation) + { + libpq_append_conn_error(conn, "server did not report the unsupported \"%s\" parameter in its protocol negotiation message", + "_pq_.test_protocol_negotiation"); ++>>>>>>> theirs goto failure; } @@@ -2502,7 -3072,21 +3080,13 @@@ build_startup_packet(const PGconn *conn if (conn->client_encoding_initial && conn->client_encoding_initial[0]) ADD_STARTUP_OPTION("client_encoding", conn->client_encoding_initial); + #ifdef USE_ZSTD + if (conn->compression && + (strcmp(conn->compression, "zstd") == 0 || + strcmp(conn->compression, "prefer") == 0)) + ADD_STARTUP_OPTION("_pq_.compression", "zstd"); + #endif - /* - * Add the test_protocol_negotiation option when greasing, to test that - * servers properly report unsupported protocol options in addition to - * unsupported minor versions. - */ - if (conn->pversion == PG_PROTOCOL_GREASE) - ADD_STARTUP_OPTION("_pq_.test_protocol_negotiation", ""); - /* Add any environment-driven GUC settings needed */ for (next_eo = options; next_eo->envName; next_eo++) {