=== Applying patches on top of PostgreSQL commit ID a75bd485b5ea7a8c9bd00e18aef0f7b0b71236e7 === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Mon Jun 15 21:16:25 UTC 2026 On branch cf/6233 nothing to commit, working tree clean === using 'git am' to apply patch ./v11-0001-postgres_fdw-Rename-cursor_exists-flag-to-scan_i.patch === Applying: postgres_fdw: Rename cursor_exists flag to scan_in_progress === using 'git am' to apply patch ./v11-0002-postgres_fdw-Add-streaming_fetch-option-for-curs.patch === Applying: postgres_fdw:Add streaming_fetch option for cursor-free fetching Using index info to reconstruct a base tree... M contrib/postgres_fdw/postgres_fdw.c Falling back to patching base and 3-way merge... Auto-merging contrib/postgres_fdw/postgres_fdw.c CONFLICT (content): Merge conflict in contrib/postgres_fdw/postgres_fdw.c error: Failed to merge in the changes. hint: Use 'git am --show-current-patch=diff' to see the failed patch Patch failed at 0001 postgres_fdw:Add streaming_fetch option for cursor-free fetching 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 ./v11-0002-postgres_fdw-Add-streaming_fetch-option-for-curs.patch === patching file contrib/postgres_fdw/connection.c patching file contrib/postgres_fdw/expected/postgres_fdw.out patching file contrib/postgres_fdw/option.c patching file contrib/postgres_fdw/postgres_fdw.c Hunk #3 FAILED at 155. Hunk #9 FAILED at 1778. Hunk #12 FAILED at 1851. Hunk #13 FAILED at 1889. Hunk #14 FAILED at 1918. Hunk #16 FAILED at 1986. Hunk #19 FAILED at 4049. Hunk #34 FAILED at 8674. 8 out of 36 hunks FAILED -- saving rejects to file contrib/postgres_fdw/postgres_fdw.c.rej patching file contrib/postgres_fdw/postgres_fdw.h patching file contrib/postgres_fdw/sql/postgres_fdw.sql patching file doc/src/sgml/postgres-fdw.sgml Unstaged changes after reset: M contrib/postgres_fdw/connection.c M contrib/postgres_fdw/expected/postgres_fdw.out M contrib/postgres_fdw/option.c M contrib/postgres_fdw/postgres_fdw.c M contrib/postgres_fdw/postgres_fdw.h M contrib/postgres_fdw/sql/postgres_fdw.sql M doc/src/sgml/postgres-fdw.sgml Removing contrib/postgres_fdw/postgres_fdw.c.rej === using 'git apply' to apply patch ./v11-0002-postgres_fdw-Add-streaming_fetch-option-for-curs.patch === Applied patch to 'contrib/postgres_fdw/connection.c' cleanly. Applied patch to 'contrib/postgres_fdw/expected/postgres_fdw.out' cleanly. Applied patch to 'contrib/postgres_fdw/option.c' cleanly. Applied patch to 'contrib/postgres_fdw/postgres_fdw.c' with conflicts. Applied patch to 'contrib/postgres_fdw/postgres_fdw.h' cleanly. Applied patch to 'contrib/postgres_fdw/sql/postgres_fdw.sql' cleanly. Applied patch to 'doc/src/sgml/postgres-fdw.sgml' cleanly. U contrib/postgres_fdw/postgres_fdw.c diff --cc contrib/postgres_fdw/postgres_fdw.c index f96bbf964a8,1d11873b83d..00000000000 --- a/contrib/postgres_fdw/postgres_fdw.c +++ b/contrib/postgres_fdw/postgres_fdw.c @@@ -1829,7 -1852,12 +1852,16 @@@ postgresIterateForeignScan(ForeignScanS * first call after Begin or ReScan. */ if (!fsstate->scan_in_progress) ++<<<<<<< ours + create_cursor(node); ++======= + { + if (fsstate->streaming_fetch) + init_scan(node); + else + create_cursor(node); + } ++>>>>>>> theirs /* * Get some more tuples, if we've run out. @@@ -1895,20 -1924,31 +1928,43 @@@ postgresReScanForeignScan(ForeignScanSt */ if (node->ss.ps.chgParam != NULL) { ++<<<<<<< ours + fsstate->scan_in_progress = false; + snprintf(sql, sizeof(sql), "CLOSE c%u", + fsstate->cursor_number); ++======= + reinitialize_scan = true; ++>>>>>>> theirs } else if (fsstate->fetch_ct_2 > 1) { if (PQserverVersion(fsstate->conn) < 150000) + { snprintf(sql, sizeof(sql), "MOVE BACKWARD ALL IN c%u", fsstate->cursor_number); + res = pgfdw_exec_query(fsstate->conn, sql, fsstate->conn_state); + if (PQresultStatus(res) != PGRES_COMMAND_OK) + pgfdw_report_error(res, fsstate->conn, sql); + + PQclear(res); + + /* Now force a fresh FETCH. */ + fsstate->tuples = NULL; + fsstate->num_tuples = 0; + fsstate->next_tuple = 0; + fsstate->fetch_ct_2 = 0; + fsstate->eof_reached = false; + return; + } else { ++<<<<<<< ours + fsstate->scan_in_progress = false; + snprintf(sql, sizeof(sql), "CLOSE c%u", + fsstate->cursor_number); ++======= + reinitialize_scan = true; ++>>>>>>> theirs } } else @@@ -1946,9 -2004,26 +2020,31 @@@ postgresEndForeignScan(ForeignScanStat /* Close the cursor if open, to prevent accumulation of cursors */ if (fsstate->scan_in_progress) ++<<<<<<< ours + close_cursor(fsstate->conn, fsstate->cursor_number, + fsstate->conn_state); ++======= + { + if (fsstate->streaming_fetch) + { + /* Remove the pointer from conn_state since ending this scan. */ + if (is_active_scan(fsstate)) + fsstate->conn_state->active_scan = NULL; + if (fsstate->tuplestore) + tuplestore_end(fsstate->tuplestore); ++>>>>>>> theirs + /* + * tuplestore resides in batch_cxt, so we couldn't reset it + * earlier in streaming fetch mode. + */ + MemoryContextReset(fsstate->batch_cxt); + end_scan(fsstate->conn); + } + else + close_cursor(fsstate->conn, fsstate->cursor_number, + fsstate->conn_state); + } /* Release remote connection */ ReleaseConnection(fsstate->conn); fsstate->conn = NULL;