=== Applying patches on top of PostgreSQL commit ID 71ff232a5bc40f36365be985da72b8b6fa275811 === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Fri Apr 10 01:24:26 UTC 2026 On branch cf/6624 nothing to commit, working tree clean === using 'git am' to apply patch ./v2-0001-pg_stat_statements-Add-last_execution_start-colum.patch === Applying: pg_stat_statements: Add last_execution_start column Using index info to reconstruct a base tree... M contrib/pg_stat_statements/pg_stat_statements.c Falling back to patching base and 3-way merge... Auto-merging contrib/pg_stat_statements/pg_stat_statements.c CONFLICT (content): Merge conflict in contrib/pg_stat_statements/pg_stat_statements.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 pg_stat_statements: Add last_execution_start column 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 ./v2-0001-pg_stat_statements-Add-last_execution_start-colum.patch === patching file contrib/pg_stat_statements/Makefile patching file contrib/pg_stat_statements/expected/entry_timestamp.out patching file contrib/pg_stat_statements/meson.build patching file contrib/pg_stat_statements/pg_stat_statements--1.13--1.14.sql patching file contrib/pg_stat_statements/pg_stat_statements.c Hunk #1 succeeded at 49 with fuzz 2. Hunk #2 succeeded at 86 (offset -2 lines). Hunk #3 succeeded at 116 (offset -2 lines). Hunk #4 succeeded at 240 (offset -2 lines). Hunk #5 succeeded at 277 with fuzz 2 (offset 10 lines). Hunk #6 succeeded at 351 (offset 4 lines). Hunk #7 succeeded at 384 with fuzz 1 (offset 2 lines). Hunk #8 succeeded at 685 (offset -10 lines). Hunk #9 succeeded at 898 (offset -10 lines). Hunk #10 succeeded at 981 (offset -10 lines). Hunk #11 succeeded at 1827 with fuzz 2 (offset 775 lines). Hunk #12 FAILED at 1137. Hunk #13 FAILED at 1271. Hunk #14 FAILED at 1335. Hunk #15 FAILED at 1549. Hunk #16 FAILED at 1617. Hunk #17 succeeded at 2065 with fuzz 2 (offset 436 lines). Hunk #18 FAILED at 1811. Hunk #19 FAILED at 1887. Hunk #20 FAILED at 1955. Hunk #21 succeeded at 2580 with fuzz 2 (offset 506 lines). Hunk #22 FAILED at 2089. Hunk #23 FAILED at 2196. 10 out of 23 hunks FAILED -- saving rejects to file contrib/pg_stat_statements/pg_stat_statements.c.rej patching file contrib/pg_stat_statements/pg_stat_statements.control patching file contrib/pg_stat_statements/sql/entry_timestamp.sql patching file doc/src/sgml/pgstatstatements.sgml Unstaged changes after reset: M contrib/pg_stat_statements/Makefile M contrib/pg_stat_statements/expected/entry_timestamp.out M contrib/pg_stat_statements/meson.build M contrib/pg_stat_statements/pg_stat_statements.c M contrib/pg_stat_statements/pg_stat_statements.control M contrib/pg_stat_statements/sql/entry_timestamp.sql M doc/src/sgml/pgstatstatements.sgml Removing contrib/pg_stat_statements/pg_stat_statements--1.13--1.14.sql Removing contrib/pg_stat_statements/pg_stat_statements.c.rej === using 'git apply' to apply patch ./v2-0001-pg_stat_statements-Add-last_execution_start-colum.patch === Applied patch to 'contrib/pg_stat_statements/Makefile' cleanly. Applied patch to 'contrib/pg_stat_statements/expected/entry_timestamp.out' cleanly. Applied patch to 'contrib/pg_stat_statements/meson.build' cleanly. Falling back to direct application... Applied patch to 'contrib/pg_stat_statements/pg_stat_statements.c' with conflicts. Applied patch to 'contrib/pg_stat_statements/pg_stat_statements.control' cleanly. Applied patch to 'contrib/pg_stat_statements/sql/entry_timestamp.sql' cleanly. Applied patch to 'doc/src/sgml/pgstatstatements.sgml' cleanly. U contrib/pg_stat_statements/pg_stat_statements.c diff --cc contrib/pg_stat_statements/pg_stat_statements.c index 95a5411a39d,ed79d9499a6..00000000000 --- a/contrib/pg_stat_statements/pg_stat_statements.c +++ b/contrib/pg_stat_statements/pg_stat_statements.c @@@ -49,7 -49,9 +49,8 @@@ #include "access/htup_details.h" #include "access/parallel.h" + #include "access/xact.h" #include "catalog/pg_authid.h" -#include "common/int.h" #include "executor/instrument.h" #include "funcapi.h" #include "jit/jit.h" @@@ -274,7 -267,25 +277,23 @@@ static const ShmemCallbacks pgss_shmem_ /* Current nesting depth of planner/ExecutorRun/ProcessUtility calls */ static int nesting_level = 0; + /* + * Maximum nesting depth for which we track statement start timestamps. + * Queries nested deeper than this still work, they will fall back to the + * current value of GetCurrentStatementStartTimestamp(). + */ + #define PGSS_MAX_NESTING_LEVEL 64 + + /* + * Per-nesting-level cache of the statement start timestamp captured at + * ExecutorStart time. We need this because ExecutorEnd can be deferred + * in the extended query protocol, when the previous query's ExecutorEnd + * defferred until the next Bind, and GetCurrentStatementStartTimestamp() + * would return the next statement's timestamp at that point. + */ + static TimestampTz pgss_exec_start[PGSS_MAX_NESTING_LEVEL]; + /* Saved hook values */ -static shmem_request_hook_type prev_shmem_request_hook = NULL; -static shmem_startup_hook_type prev_shmem_startup_hook = NULL; static post_parse_analyze_hook_type prev_post_parse_analyze_hook = NULL; static planner_hook_type prev_planner_hook = NULL; static ExecutorStart_hook_type prev_ExecutorStart = NULL; @@@ -361,10 -379,11 +381,11 @@@ static void pgss_store(const char *quer const BufferUsage *bufusage, const WalUsage *walusage, const struct JitInstrumentation *jitusage, - JumbleState *jstate, + const JumbleState *jstate, int parallel_workers_to_launch, int parallel_workers_launched, - PlannedStmtOrigin planOrigin); + PlannedStmtOrigin planOrigin, + TimestampTz exec_start); static void pg_stat_statements_internal(FunctionCallInfo fcinfo, pgssVersion api_version, bool showtext); @@@ -1000,14 -1039,30 +1024,40 @@@ pgss_ExecutorStart(QueryDesc *queryDesc */ if (pgss_enabled(nesting_level) && queryDesc->plannedstmt->queryId != INT64CONST(0)) { ++<<<<<<< ours + /* Request all summary instrumentation, i.e. timing, buffers and WAL */ + queryDesc->query_instr_options |= INSTRUMENT_ALL; ++======= + /* + * Set up to track total elapsed time in ExecutorRun. Make sure the + * space is allocated in the per-query context so it will go away at + * ExecutorEnd. + */ + if (queryDesc->totaltime == NULL) + { + MemoryContext oldcxt; + + oldcxt = MemoryContextSwitchTo(queryDesc->estate->es_query_cxt); + queryDesc->totaltime = InstrAlloc(1, INSTRUMENT_ALL, false); + MemoryContextSwitchTo(oldcxt); + } + + /* + * Capture the statement start timestamp now, while it is still + * correct. We cannot rely on reading it later in ExecutorEnd, + * because ExecutorEnd can be deferred until the next Bind message + * in the extended query protocol. + */ + if (nesting_level < PGSS_MAX_NESTING_LEVEL) + pgss_exec_start[nesting_level] = + GetCurrentStatementStartTimestamp(); ++>>>>>>> theirs } + + if (prev_ExecutorStart) + prev_ExecutorStart(queryDesc, eflags); + else + standard_ExecutorStart(queryDesc, eflags); } /* @@@ -1271,10 -1336,11 +1325,11 @@@ pgss_store(const char *query, int64 que const BufferUsage *bufusage, const WalUsage *walusage, const struct JitInstrumentation *jitusage, - JumbleState *jstate, + const JumbleState *jstate, int parallel_workers_to_launch, int parallel_workers_launched, - PlannedStmtOrigin planOrigin) + PlannedStmtOrigin planOrigin, + TimestampTz exec_start) { pgssHashKey key; pgssEntry *entry;