=== Applying patches on top of PostgreSQL commit ID 9018c7d37bb464cd53567c0b553a6f49b50bec78 === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Sun Apr 19 21:16:23 UTC 2026 On branch cf/5873 nothing to commit, working tree clean === using 'git am' to apply patch ./0003-ALTER-TABLE-progress-support.patch === Applying: ALTER TABLE progress support Using index info to reconstruct a base tree... M doc/src/sgml/monitoring.sgml M doc/src/sgml/ref/alter_table.sgml M src/backend/catalog/storage.c M src/backend/catalog/system_views.sql M src/backend/commands/tablecmds.c M src/include/commands/progress.h M src/test/regress/expected/rules.out Falling back to patching base and 3-way merge... Auto-merging src/test/regress/expected/rules.out CONFLICT (content): Merge conflict in src/test/regress/expected/rules.out Auto-merging src/include/commands/progress.h CONFLICT (content): Merge conflict in src/include/commands/progress.h Auto-merging src/backend/commands/tablecmds.c CONFLICT (content): Merge conflict in src/backend/commands/tablecmds.c Auto-merging src/backend/catalog/system_views.sql CONFLICT (content): Merge conflict in src/backend/catalog/system_views.sql Auto-merging src/backend/catalog/storage.c Auto-merging doc/src/sgml/ref/alter_table.sgml Auto-merging doc/src/sgml/monitoring.sgml CONFLICT (content): Merge conflict in doc/src/sgml/monitoring.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 ALTER TABLE progress support 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 ./0003-ALTER-TABLE-progress-support.patch === patching file doc/src/sgml/monitoring.sgml Hunk #1 FAILED at 400. Hunk #2 FAILED at 5494. Hunk #3 FAILED at 5740. Hunk #4 FAILED at 5803. Hunk #5 succeeded at 6541 (offset 655 lines). 4 out of 5 hunks FAILED -- saving rejects to file doc/src/sgml/monitoring.sgml.rej patching file doc/src/sgml/ref/alter_table.sgml Hunk #1 succeeded at 2111 (offset 252 lines). patching file src/backend/catalog/storage.c patching file src/backend/catalog/system_views.sql Hunk #1 FAILED at 1260. Hunk #2 FAILED at 1269. 2 out of 2 hunks FAILED -- saving rejects to file src/backend/catalog/system_views.sql.rej patching file src/backend/commands/tablecmds.c Hunk #1 FAILED at 59. Hunk #2 succeeded at 5907 (offset 69 lines). Hunk #3 succeeded at 6051 (offset 69 lines). Hunk #4 succeeded at 6166 (offset 70 lines). Hunk #5 succeeded at 6184 (offset 70 lines). Hunk #6 succeeded at 6211 with fuzz 2 (offset 70 lines). Hunk #7 succeeded at 6221 (offset 70 lines). Hunk #8 succeeded at 6331 (offset 70 lines). Hunk #9 FAILED at 6361. Hunk #10 succeeded at 6442 (offset 71 lines). Hunk #11 succeeded at 6497 (offset 71 lines). Hunk #12 succeeded at 6620 (offset 71 lines). Hunk #13 succeeded at 13976 (offset 282 lines). Hunk #14 succeeded at 14000 (offset 282 lines). Hunk #15 FAILED at 13739. Hunk #16 succeeded at 14056 (offset 282 lines). Hunk #17 succeeded at 17155 (offset 283 lines). 3 out of 17 hunks FAILED -- saving rejects to file src/backend/commands/tablecmds.c.rej patching file src/include/commands/progress.h Hunk #1 FAILED at 74. 1 out of 1 hunk FAILED -- saving rejects to file src/include/commands/progress.h.rej patching file src/test/regress/expected/rules.out Hunk #1 FAILED at 1986. Hunk #2 FAILED at 1997. 2 out of 2 hunks FAILED -- saving rejects to file src/test/regress/expected/rules.out.rej Unstaged changes after reset: M doc/src/sgml/monitoring.sgml M doc/src/sgml/ref/alter_table.sgml M src/backend/catalog/storage.c M src/backend/commands/tablecmds.c Removing doc/src/sgml/monitoring.sgml.rej Removing src/backend/catalog/system_views.sql.rej Removing src/backend/commands/tablecmds.c.rej Removing src/include/commands/progress.h.rej Removing src/test/regress/expected/rules.out.rej === using 'git apply' to apply patch ./0003-ALTER-TABLE-progress-support.patch === Applied patch to 'doc/src/sgml/monitoring.sgml' with conflicts. Applied patch to 'doc/src/sgml/ref/alter_table.sgml' cleanly. Applied patch to 'src/backend/catalog/storage.c' cleanly. Applied patch to 'src/backend/catalog/system_views.sql' with conflicts. Applied patch to 'src/backend/commands/tablecmds.c' with conflicts. Applied patch to 'src/include/commands/progress.h' with conflicts. Applied patch to 'src/test/regress/expected/rules.out' with conflicts. U doc/src/sgml/monitoring.sgml U src/backend/catalog/system_views.sql U src/backend/commands/tablecmds.c U src/include/commands/progress.h U src/test/regress/expected/rules.out diff --cc doc/src/sgml/monitoring.sgml index 08d5b824552,02d70a86731..00000000000 --- a/doc/src/sgml/monitoring.sgml +++ b/doc/src/sgml/monitoring.sgml @@@ -407,8 -399,8 +407,13 @@@ postgres 27093 0.0 0.0 30096 275 pg_stat_progress_clusterpg_stat_progress_cluster ++<<<<<<< ours + One row for each backend running REPACK, + CLUSTER or VACUUM FULL, showing current progress. ++======= + One row for each backend running + CLUSTER, VACUUM FULL or ALTER TABLE, showing current progress. ++>>>>>>> theirs See . @@@ -6118,9 -5494,9 +6123,15 @@@ FROM pg_stat_get_backend_idset() AS bac PostgreSQL has the ability to report the progress of certain commands during command execution. Currently, the only commands which support progress reporting are ANALYZE, ++<<<<<<< ours + COPY, CREATE INDEX, + REPACK (and its obsolete spelling CLUSTER), + VACUUM, ++======= + CLUSTER, ALTER TABLE, + CREATE INDEX, VACUUM, + COPY, ++>>>>>>> theirs and (i.e., replication command that issues to take a base backup). @@@ -6389,10 -5740,9 +6400,16 @@@ ++<<<<<<< ours + Whenever REPACK, CLUSTER or + VACUUM FULL is running, + the backwards-compatibility pg_stat_progress_cluster + view will ++======= + Whenever CLUSTER, VACUUM FULL + or ALTER TABLE is running, + the pg_stat_progress_cluster view will ++>>>>>>> theirs contain a row for each backend that is currently running either command. The tables below describe the information that will be reported and provide information about how to interpret it. @@@ -6454,11 -5804,7 +6471,15 @@@ command text ++<<<<<<< ours + The command that is running. Either CLUSTER or + VACUUM FULL. + Because this view exists for backwards-compatibility purposes only, + it will translate any REPACK command into one of + these other two. ++======= + The command that is running. Either CLUSTER, VACUUM FULL or ALTER TABLE. ++>>>>>>> theirs diff --cc src/backend/catalog/system_views.sql index 73a1c1c4670,9d68d02ec26..00000000000 --- a/src/backend/catalog/system_views.sql +++ b/src/backend/catalog/system_views.sql @@@ -1353,50 -1259,28 +1353,62 @@@ CREATE VIEW pg_stat_progress_repack A D.datname AS datname, S.relid AS relid, CASE S.param1 WHEN 1 THEN 'CLUSTER' ++<<<<<<< ours + WHEN 2 THEN 'REPACK' + WHEN 3 THEN 'VACUUM FULL' ++======= + WHEN 2 THEN 'VACUUM FULL' + WHEN 3 THEN 'ALTER TABLE' ++>>>>>>> theirs END AS command, CASE S.param2 WHEN 0 THEN 'initializing' WHEN 1 THEN 'seq scanning heap' WHEN 2 THEN 'index scanning heap' WHEN 3 THEN 'sorting tuples' WHEN 4 THEN 'writing new heap' ++<<<<<<< ours + WHEN 5 THEN 'catch-up' + WHEN 6 THEN 'swapping relation files' + WHEN 7 THEN 'rebuilding index' + WHEN 8 THEN 'performing final cleanup' ++======= + WHEN 5 THEN 'swapping relation files' + WHEN 6 THEN 'rebuilding index' + WHEN 7 THEN 'performing final cleanup' + WHEN 8 THEN 'checking foreign key constraints' ++>>>>>>> theirs END AS phase, - CAST(S.param3 AS oid) AS cluster_index_relid, + CAST(S.param3 AS oid) AS repack_index_relid, S.param4 AS heap_tuples_scanned, - S.param5 AS heap_tuples_written, - S.param6 AS heap_blks_total, - S.param7 AS heap_blks_scanned, - S.param8 AS index_rebuild_count - FROM pg_stat_get_progress_info('CLUSTER') AS S + S.param5 AS heap_tuples_inserted, + S.param6 AS heap_tuples_updated, + S.param7 AS heap_tuples_deleted, + S.param8 AS heap_blks_total, + S.param9 AS heap_blks_scanned, + S.param10 AS index_rebuild_count + FROM pg_stat_get_progress_info('REPACK') AS S LEFT JOIN pg_database D ON S.datid = D.oid; +-- This view is as the one above, except for renaming a column and avoiding +-- 'REPACK' as a command name to report. +CREATE VIEW pg_stat_progress_cluster AS + SELECT + pid, + datid, + datname, + relid, + CASE WHEN command IN ('CLUSTER', 'VACUUM FULL') THEN command + WHEN repack_index_relid = 0 THEN 'VACUUM FULL' + ELSE 'CLUSTER' END AS command, + phase, + repack_index_relid AS cluster_index_relid, + heap_tuples_scanned, + heap_tuples_inserted + heap_tuples_updated AS heap_tuples_written, + heap_blks_total, + heap_blks_scanned, + index_rebuild_count + FROM pg_stat_progress_repack; + CREATE VIEW pg_stat_progress_create_index AS SELECT S.pid AS pid, S.datid AS datid, D.datname AS datname, diff --cc src/backend/commands/tablecmds.c index eec09ba1ded,43376539209..00000000000 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@@ -60,7 -58,8 +60,11 @@@ #include "commands/comment.h" #include "commands/defrem.h" #include "commands/event_trigger.h" ++<<<<<<< ours +#include "commands/repack.h" ++======= + #include "commands/progress.h" ++>>>>>>> theirs #include "commands/sequence.h" #include "commands/tablecmds.h" #include "commands/tablespace.h" @@@ -6196,8 -6140,9 +6213,9 @@@ ATRewriteTable(AlteredTableInfo *tab, O EState *estate; CommandId mycid; BulkInsertState bistate; - int ti_options; + uint32 ti_options; ExprState *partqualstate = NULL; + int64 numTuples = 0; /* * Open the relation(s). We have surely already locked the existing @@@ -6412,8 -6361,10 +6434,15 @@@ * checking all the constraints. */ snapshot = RegisterSnapshot(GetLatestSnapshot()); ++<<<<<<< ours + scan = table_beginscan(oldrel, snapshot, 0, NULL, + SO_NONE); ++======= + scan = table_beginscan(oldrel, snapshot, 0, NULL); + heapScan = (HeapScanDesc) scan; + pgstat_progress_update_param(PROGRESS_CLUSTER_TOTAL_HEAP_BLKS, + heapScan->rs_nblocks); ++>>>>>>> theirs /* * Switch to per-tuple memory context and reset it for each tuple @@@ -13984,8 -13742,9 +14031,14 @@@ validateForeignKeyConstraint(char *conn */ snapshot = RegisterSnapshot(GetLatestSnapshot()); slot = table_slot_create(rel, NULL); ++<<<<<<< ours + scan = table_beginscan(rel, snapshot, 0, NULL, + SO_NONE); ++======= + scan = table_beginscan(rel, snapshot, 0, NULL); + heapScan = (HeapScanDesc) scan; + ++>>>>>>> theirs perTupCxt = AllocSetContextCreate(CurrentMemoryContext, "validateForeignKeyConstraint", ALLOCSET_SMALL_SIZES); diff --cc src/include/commands/progress.h index 2a12920c75f,56585742838..00000000000 --- a/src/include/commands/progress.h +++ b/src/include/commands/progress.h @@@ -69,41 -56,30 +69,68 @@@ #define PROGRESS_ANALYZE_PHASE_COMPUTE_EXT_STATS 4 #define PROGRESS_ANALYZE_PHASE_FINALIZE_ANALYZE 5 ++<<<<<<< ours +/* Reasons for analyze (as advertised via PROGRESS_ANALYZE_STARTED_BY) */ +#define PROGRESS_ANALYZE_STARTED_BY_MANUAL 1 +#define PROGRESS_ANALYZE_STARTED_BY_AUTOVACUUM 2 + +/* + * Progress parameters for REPACK. + * + * Values for PROGRESS_REPACK_COMMAND are as in RepackCommand. + * + * Note: Since REPACK shares code with CLUSTER, these values are also + * used by CLUSTER. (CLUSTER being now deprecated, it makes little sense to + * maintain a separate set of constants.) + */ +#define PROGRESS_REPACK_COMMAND 0 +#define PROGRESS_REPACK_PHASE 1 +#define PROGRESS_REPACK_INDEX_RELID 2 +#define PROGRESS_REPACK_HEAP_TUPLES_SCANNED 3 +#define PROGRESS_REPACK_HEAP_TUPLES_INSERTED 4 +#define PROGRESS_REPACK_HEAP_TUPLES_UPDATED 5 +#define PROGRESS_REPACK_HEAP_TUPLES_DELETED 6 +#define PROGRESS_REPACK_TOTAL_HEAP_BLKS 7 +#define PROGRESS_REPACK_HEAP_BLKS_SCANNED 8 +#define PROGRESS_REPACK_INDEX_REBUILD_COUNT 9 + +/* + * Phases of repack (as advertised via PROGRESS_REPACK_PHASE). + */ +#define PROGRESS_REPACK_PHASE_SEQ_SCAN_HEAP 1 +#define PROGRESS_REPACK_PHASE_INDEX_SCAN_HEAP 2 +#define PROGRESS_REPACK_PHASE_SORT_TUPLES 3 +#define PROGRESS_REPACK_PHASE_WRITE_NEW_HEAP 4 +#define PROGRESS_REPACK_PHASE_CATCH_UP 5 +#define PROGRESS_REPACK_PHASE_SWAP_REL_FILES 6 +#define PROGRESS_REPACK_PHASE_REBUILD_INDEX 7 +#define PROGRESS_REPACK_PHASE_FINAL_CLEANUP 8 ++======= + /* Progress parameters for cluster */ + #define PROGRESS_CLUSTER_COMMAND 0 + #define PROGRESS_CLUSTER_PHASE 1 + #define PROGRESS_CLUSTER_INDEX_RELID 2 + #define PROGRESS_CLUSTER_HEAP_TUPLES_SCANNED 3 + #define PROGRESS_CLUSTER_HEAP_TUPLES_WRITTEN 4 + #define PROGRESS_CLUSTER_TOTAL_HEAP_BLKS 5 + #define PROGRESS_CLUSTER_HEAP_BLKS_SCANNED 6 + #define PROGRESS_CLUSTER_INDEX_REBUILD_COUNT 7 + + /* Phases of cluster (as advertised via PROGRESS_CLUSTER_PHASE) */ + #define PROGRESS_CLUSTER_PHASE_SEQ_SCAN_HEAP 1 + #define PROGRESS_CLUSTER_PHASE_INDEX_SCAN_HEAP 2 + #define PROGRESS_CLUSTER_PHASE_SORT_TUPLES 3 + #define PROGRESS_CLUSTER_PHASE_WRITE_NEW_HEAP 4 + #define PROGRESS_CLUSTER_PHASE_SWAP_REL_FILES 5 + #define PROGRESS_CLUSTER_PHASE_REBUILD_INDEX 6 + #define PROGRESS_CLUSTER_PHASE_FINAL_CLEANUP 7 + #define PROGRESS_CLUSTER_PHASE_CHECK_FKEYS 8 + + /* Commands of PROGRESS_CLUSTER */ + #define PROGRESS_CLUSTER_COMMAND_CLUSTER 1 + #define PROGRESS_CLUSTER_COMMAND_VACUUM_FULL 2 + #define PROGRESS_CLUSTER_COMMAND_ALTER_TABLE 3 /* New command type */ ++>>>>>>> theirs /* Progress parameters for CREATE INDEX */ /* 3, 4 and 5 reserved for "waitfor" metrics */ diff --cc src/test/regress/expected/rules.out index a65a5bf0c4f,b0d498d0339..00000000000 --- a/src/test/regress/expected/rules.out +++ b/src/test/regress/expected/rules.out @@@ -2017,30 -1977,38 +2017,66 @@@ pg_stat_progress_basebackup| SELECT pid END AS backup_total, param3 AS backup_streamed, param4 AS tablespaces_total, ++<<<<<<< ours + param5 AS tablespaces_streamed, + CASE param6 + WHEN 1 THEN 'full'::text + WHEN 2 THEN 'incremental'::text ++======= + param5 AS tablespaces_streamed + FROM pg_stat_get_progress_info('BASEBACKUP'::text) s(pid, datid, relid, param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12, param13, param14, param15, param16, param17, param18, param19, param20); + pg_stat_progress_cluster| SELECT s.pid, + s.datid, + d.datname, + s.relid, + CASE s.param1 + WHEN 1 THEN 'CLUSTER'::text + WHEN 2 THEN 'VACUUM FULL'::text + WHEN 3 THEN 'ALTER TABLE'::text ++>>>>>>> theirs ELSE NULL::text + END AS backup_type + FROM pg_stat_get_progress_info('BASEBACKUP'::text) s(pid, datid, relid, param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12, param13, param14, param15, param16, param17, param18, param19, param20); +pg_stat_progress_cluster| SELECT pid, + datid, + datname, + relid, + CASE + WHEN (command = ANY (ARRAY['CLUSTER'::text, 'VACUUM FULL'::text])) THEN command + WHEN (repack_index_relid = (0)::oid) THEN 'VACUUM FULL'::text + ELSE 'CLUSTER'::text END AS command, ++<<<<<<< ours + phase, + repack_index_relid AS cluster_index_relid, + heap_tuples_scanned, + (heap_tuples_inserted + heap_tuples_updated) AS heap_tuples_written, + heap_blks_total, + heap_blks_scanned, + index_rebuild_count + FROM pg_stat_progress_repack; ++======= + CASE s.param2 + WHEN 0 THEN 'initializing'::text + WHEN 1 THEN 'seq scanning heap'::text + WHEN 2 THEN 'index scanning heap'::text + WHEN 3 THEN 'sorting tuples'::text + WHEN 4 THEN 'writing new heap'::text + WHEN 5 THEN 'swapping relation files'::text + WHEN 6 THEN 'rebuilding index'::text + WHEN 7 THEN 'performing final cleanup'::text + WHEN 8 THEN 'checking foreign key constraints'::text + ELSE NULL::text + END AS phase, + (s.param3)::oid AS cluster_index_relid, + s.param4 AS heap_tuples_scanned, + s.param5 AS heap_tuples_written, + s.param6 AS heap_blks_total, + s.param7 AS heap_blks_scanned, + s.param8 AS index_rebuild_count + FROM (pg_stat_get_progress_info('CLUSTER'::text) s(pid, datid, relid, param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12, param13, param14, param15, param16, param17, param18, param19, param20) + LEFT JOIN pg_database d ON ((s.datid = d.oid))); ++>>>>>>> theirs pg_stat_progress_copy| SELECT s.pid, s.datid, d.datname,