From 878a6c6a3585212c0dfba5e65df80aba1a84b4ac Mon Sep 17 00:00:00 2001 From: tasaba <166795519+tasaba@users.noreply.github.com> Date: Tue, 12 Nov 2024 13:31:09 +0900 Subject: [PATCH] Support PostgreSQL 17. --- agent/bin/collector_sql.h | 6 +- agent/bin/pg_statsrepo.sql | 32 +++------ agent/bin/writer_sql.h | 2 +- agent/lib/last_xact_activity.c | 33 +++++----- agent/lib/libstatsinfo.c | 32 ++++----- reporter/report.c | 4 -- test/expected/function-report.out | 65 ------------------- test/expected/function-snapshot.out | 33 +++++----- test/script/function-snapshot.sh | 6 +- test/script/inputdata/statsrepo-inputdata.sql | 8 +-- 10 files changed, 63 insertions(+), 158 deletions(-) diff --git a/agent/bin/collector_sql.h b/agent/bin/collector_sql.h index bb70005..8243fff 100644 --- a/agent/bin/collector_sql.h +++ b/agent/bin/collector_sql.h @@ -101,8 +101,8 @@ SELECT \ s.local_blks_written, \ s.temp_blks_read, \ s.temp_blks_written, \ - s.blk_read_time, \ - s.blk_write_time, \ + s.shared_blk_read_time, \ + s.shared_blk_write_time, \ s.temp_blk_read_time, \ s.temp_blk_write_time \ FROM \ @@ -199,8 +199,6 @@ WHERE \ SELECT \ buffers_clean, \ maxwritten_clean, \ - buffers_backend, \ - buffers_backend_fsync, \ buffers_alloc \ FROM \ pg_stat_bgwriter" diff --git a/agent/bin/pg_statsrepo.sql b/agent/bin/pg_statsrepo.sql index d0e0aa0..d23720b 100644 --- a/agent/bin/pg_statsrepo.sql +++ b/agent/bin/pg_statsrepo.sql @@ -285,8 +285,8 @@ CREATE TABLE statsrepo.statement local_blks_written bigint, temp_blks_read bigint, temp_blks_written bigint, - blk_read_time double precision, - blk_write_time double precision, + shared_blk_read_time double precision, + shared_blk_write_time double precision, temp_blk_read_time double precision, temp_blk_write_time double precision, FOREIGN KEY (snapid) REFERENCES statsrepo.snapshot (snapid) ON DELETE CASCADE, @@ -560,8 +560,6 @@ CREATE TABLE statsrepo.bgwriter snapid bigint, buffers_clean bigint, maxwritten_clean bigint, - buffers_backend bigint, - buffers_backend_fsync bigint, buffers_alloc bigint, FOREIGN KEY (snapid) REFERENCES statsrepo.snapshot (snapid) ON DELETE CASCADE ); @@ -3106,8 +3104,8 @@ CREATE FUNCTION statsrepo.get_query_activity_statements( OUT calls bigint, OUT total_exec_time numeric, OUT time_per_call numeric, - OUT blk_read_time numeric, - OUT blk_write_time numeric, + OUT shared_blk_read_time numeric, + OUT shared_blk_write_time numeric, OUT tmp_blk_read_time numeric, OUT tmp_blk_write_time numeric, OUT dbid oid, @@ -3128,8 +3126,8 @@ $$ t1.total_exec_time::numeric(30, 3), CASE t1.calls WHEN 0 THEN 0 ELSE (t1.total_exec_time / t1.calls)::numeric(30, 3) END, - t1.blk_read_time::numeric(30, 3), - t1.blk_write_time::numeric(30, 3), + t1.shared_blk_read_time::numeric(30, 3), + t1.shared_blk_write_time::numeric(30, 3), t1.tmp_blk_read_time::numeric(30, 3), t1.tmp_blk_write_time::numeric(30, 3), t1.dbid, @@ -3149,8 +3147,8 @@ $$ statsrepo.sub(st2.total_plan_time, st1.total_plan_time) AS total_plan_time, statsrepo.sub(st2.calls, st1.calls) AS calls, statsrepo.sub(st2.total_exec_time, st1.total_exec_time) AS total_exec_time, - statsrepo.sub(st2.blk_read_time, st1.blk_read_time) AS blk_read_time, - statsrepo.sub(st2.blk_write_time, st1.blk_write_time) AS blk_write_time, + statsrepo.sub(st2.shared_blk_read_time, st1.shared_blk_read_time) AS shared_blk_read_time, + statsrepo.sub(st2.shared_blk_write_time, st1.shared_blk_write_time) AS shared_blk_write_time, statsrepo.sub(st2.temp_blk_read_time, st1.temp_blk_read_time) AS tmp_blk_read_time, statsrepo.sub(st2.temp_blk_write_time, st1.temp_blk_write_time) AS tmp_blk_write_time FROM @@ -3508,8 +3506,6 @@ CREATE FUNCTION statsrepo.get_bgwriter_tendency( IN snapid_end bigint, OUT "timestamp" text, OUT bgwriter_write_tps numeric, - OUT backend_write_tps numeric, - OUT backend_fsync_tps numeric, OUT bgwriter_stopscan_tps numeric, OUT buffer_alloc_tps numeric ) RETURNS SETOF record AS @@ -3517,8 +3513,6 @@ $$ SELECT t.timestamp, statsrepo.tps(t.bgwriter_write, t.duration), - statsrepo.tps(t.backend_write, t.duration), - statsrepo.tps(t.backend_fsync, t.duration), statsrepo.tps(t.bgwriter_stopscan, t.duration), statsrepo.tps(t.buffer_alloc, t.duration) FROM @@ -3527,8 +3521,6 @@ $$ s.snapid, pg_catalog.to_char(s.time, 'YYYY-MM-DD HH24:MI') AS timestamp, b.buffers_clean - pg_catalog.lag(b.buffers_clean) OVER w AS bgwriter_write, - b.buffers_backend - pg_catalog.lag(b.buffers_backend) OVER w AS backend_write, - b.buffers_backend_fsync - pg_catalog.lag(b.buffers_backend_fsync) OVER w AS backend_fsync, b.maxwritten_clean - pg_catalog.lag(b.maxwritten_clean) OVER w AS bgwriter_stopscan, b.buffers_alloc - pg_catalog.lag(b.buffers_alloc) OVER w AS buffer_alloc, s.time - pg_catalog.lag(s.time) OVER w AS duration @@ -3554,10 +3546,6 @@ CREATE OR REPLACE FUNCTION statsrepo.get_bgwriter_stats( IN snapid_end bigint, OUT bgwriter_write_avg numeric, OUT bgwriter_write_max numeric, - OUT backend_write_avg numeric, - OUT backend_write_max numeric, - OUT backend_fsync_avg numeric, - OUT backend_fsync_max numeric, OUT bgwriter_stopscan_avg numeric, OUT buffer_alloc_avg numeric ) RETURNS SETOF record AS @@ -3565,10 +3553,6 @@ $$ SELECT pg_catalog.round(pg_catalog.avg(bgwriter_write_tps), 3), pg_catalog.round(pg_catalog.max(bgwriter_write_tps), 3), - pg_catalog.round(pg_catalog.avg(backend_write_tps), 3), - pg_catalog.round(pg_catalog.max(backend_write_tps), 3), - pg_catalog.round(pg_catalog.avg(backend_fsync_tps), 3), - pg_catalog.round(pg_catalog.max(backend_fsync_tps), 3), pg_catalog.round(pg_catalog.avg(bgwriter_stopscan_tps), 3), pg_catalog.round(pg_catalog.avg(buffer_alloc_tps), 3) FROM diff --git a/agent/bin/writer_sql.h b/agent/bin/writer_sql.h index 907df67..c986a8b 100644 --- a/agent/bin/writer_sql.h +++ b/agent/bin/writer_sql.h @@ -47,7 +47,7 @@ INSERT INTO statsrepo.plan \ INSERT INTO statsrepo.lock VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16)" #define SQL_INSERT_BGWRITER "\ -INSERT INTO statsrepo.bgwriter VALUES ($1, $2, $3, $4, $5, $6)" +INSERT INTO statsrepo.bgwriter VALUES ($1, $2, $3, $4)" #define SQL_INSERT_REPLICATION "\ INSERT INTO statsrepo.replication VALUES \ diff --git a/agent/lib/last_xact_activity.c b/agent/lib/last_xact_activity.c index 3600df1..f160266 100644 --- a/agent/lib/last_xact_activity.c +++ b/agent/lib/last_xact_activity.c @@ -548,7 +548,7 @@ shmem_startup(void) static void backend_shutdown_hook(int code, Datum arg) { - statEntry *entry = get_stat_entry(MyBackendId); + statEntry *entry = get_stat_entry(MyProcNumber); if (entry) entry->pid = 0; } @@ -753,7 +753,7 @@ ru_set_queryid(uint64 queryid) Assert(!IsParallelWorker()); LWLockAcquire(ru_ss->queryids_lock, LW_EXCLUSIVE); - ru_ss->queryids[MyBackendId] = queryid; + ru_ss->queryids[MyProcNumber] = queryid; LWLockRelease(ru_ss->queryids_lock); } @@ -1035,7 +1035,7 @@ myExecutorStart(QueryDesc *queryDesc, int eflags) else standard_ExecutorStart(queryDesc, eflags); - entry = get_stat_entry(MyBackendId); + entry = get_stat_entry(MyProcNumber); entry->change_count++; @@ -1044,7 +1044,7 @@ myExecutorStart(QueryDesc *queryDesc, int eflags) */ if (!entry->inxact) { - init_entry(MyBackendId, GetSessionUserId()); + init_entry(MyProcNumber, GetSessionUserId()); /* * Remember to free activity snapshot on ExecutorEnd when we're out of * transaction here. @@ -1134,7 +1134,7 @@ myExecutorEnd(QueryDesc * queryDesc) if (IsParallelWorker()) { LWLockAcquire(ru_ss->queryids_lock, LW_SHARED); - queryId = ru_ss->queryids[ParallelLeaderBackendId]; + queryId = ru_ss->queryids[ParallelLeaderProcNumber]; LWLockRelease(ru_ss->queryids_lock); } else @@ -1194,7 +1194,7 @@ exit_transaction_if_needed() { if (immediate_exit_xact) { - statEntry *entry = get_stat_entry(MyBackendId); + statEntry *entry = get_stat_entry(MyProcNumber); entry->inxact = false; immediate_exit_xact = false; @@ -1207,14 +1207,14 @@ myProcessUtility0(Node *parsetree, const char *queryString) statEntry *entry; TransactionStmt *stmt; - entry = get_stat_entry(MyBackendId); + entry = get_stat_entry(MyProcNumber); /* * Initialize stat entry if I find that the PID of this backend has changed * unexpectedly. */ if (MyProc->pid != 0 && entry->pid != MyProc->pid) - init_entry(MyBackendId, GetSessionUserId()); + init_entry(MyProcNumber, GetSessionUserId()); switch (nodeTag(parsetree)) { @@ -1227,7 +1227,7 @@ myProcessUtility0(Node *parsetree, const char *queryString) { case TRANS_STMT_BEGIN: entry->change_count++; - init_entry(MyBackendId, GetSessionUserId()); + init_entry(MyProcNumber, GetSessionUserId()); entry->inxact = true; break; case TRANS_STMT_COMMIT: @@ -1265,7 +1265,7 @@ myProcessUtility0(Node *parsetree, const char *queryString) if (!entry->inxact) { immediate_exit_xact = true; - init_entry(MyBackendId, GetSessionUserId()); + init_entry(MyProcNumber, GetSessionUserId()); entry->inxact = true; } @@ -1491,9 +1491,6 @@ statsinfo_rusage_internal(FunctionCallInfo fcinfo) } LWLockRelease(ru_ss->lock); - - /* clean up and return the tuplestore */ - tuplestore_donestoring(tupstore); } #define RUSAGE_STATS_INFO_COLS 2 @@ -1829,14 +1826,14 @@ buffer_size(int nbackends) static char* get_query_entry(int beid) { - if (beid < 1 || beid > stat_buffer->max_id) return NULL; - return query_buffer + buffer_size_per_backend * (beid - 1); + if (beid < 0 || beid >= stat_buffer->max_id) return NULL; + return query_buffer + buffer_size_per_backend * beid; } static statEntry * get_stat_entry(int beid) { - if (beid < 1 || beid > stat_buffer->max_id) return NULL; - return &stat_buffer->entries[beid - 1]; + if (beid < 0 || beid >= stat_buffer->max_id) return NULL; + return &stat_buffer->entries[beid]; } static void @@ -1883,7 +1880,7 @@ attatch_shmem(void) MemSet(stat_buffer, 0, bufsize); query_buffer = (char*)(&stat_buffer->entries[max_backends]); stat_buffer->max_id = max_backends; - for (beid = 1 ; beid <= max_backends ; beid++) + for (beid = 0 ; beid < max_backends ; beid++) init_entry(beid, 0); } } diff --git a/agent/lib/libstatsinfo.c b/agent/lib/libstatsinfo.c index 9cbd7d6..1eb5cb3 100644 --- a/agent/lib/libstatsinfo.c +++ b/agent/lib/libstatsinfo.c @@ -631,6 +631,7 @@ sample_activity(void) int waiting = 0; int running = 0; int i; + int numbackends = 0; if (!long_xacts) { @@ -648,9 +649,11 @@ sample_activity(void) } now = GetCurrentTimestamp(); + numbackends = pgstat_fetch_stat_numbackends(); - for (i = pgstat_fetch_stat_numbackends(); i > 0; i--) + for (i = 1; i <= numbackends; i++) { + LocalPgBackendStatus *local_be; PgBackendStatus *be; long secs; int usecs; @@ -660,7 +663,8 @@ sample_activity(void) LongXactEntry *entry; int procpid; - be = pgstat_get_beentry_by_backend_id(i); + local_be = pgstat_get_local_beentry_by_index(i); + be = &local_be->backendStatus; if (!be) continue; @@ -1060,9 +1064,6 @@ statsinfo_long_xact(PG_FUNCTION_ARGS) } } - /* clean up and return the tuplestore */ - tuplestore_donestoring(tupstore); - return (Datum) 0; } @@ -1156,9 +1157,6 @@ statsinfo_wait_sampling_profile(PG_FUNCTION_ARGS) } } - /* clean up and return the tuplestore */ - tuplestore_donestoring(tupstore); - return (Datum) 0; } @@ -2282,8 +2280,7 @@ statsinfo_devicestats(PG_FUNCTION_ARGS) entry->overflow_dit = 0; } - /* clean up and return the tuplestore */ - tuplestore_donestoring(tupstore); + /* clean up */ SPI_finish(); return (Datum) 0; @@ -2594,9 +2591,6 @@ statsinfo_profile(PG_FUNCTION_ARGS) fclose(fp); - /* clean up and return the tuplestore */ - tuplestore_donestoring(tupstore); - PG_RETURN_VOID(); } @@ -3370,9 +3364,6 @@ statsinfo_tablespaces(PG_FUNCTION_ARGS) tuplestore_putvalues(tupstore, tupdesc, values, nulls); } - /* clean up and return the tuplestore */ - tuplestore_donestoring(tupstore); - return (Datum) 0; } @@ -4604,15 +4595,20 @@ static void probe_waits(void) { int i; + int numbackends = 0; + + numbackends = pgstat_fetch_stat_numbackends(); - for (i = pgstat_fetch_stat_numbackends(); i > 0; i--) + for (i = 1; i <= numbackends; i++) { + LocalPgBackendStatus *local_be; PgBackendStatus *be; wait_samplingEntry item; PGPROC *proc; int procpid; - be = pgstat_get_beentry_by_backend_id(i); + local_be = pgstat_get_local_beentry_by_index(i); + be = &local_be->backendStatus; if (!be) continue; diff --git a/reporter/report.c b/reporter/report.c index c3815d9..560d1ea 100644 --- a/reporter/report.c +++ b/reporter/report.c @@ -667,10 +667,6 @@ report_instance_activity(PGconn *conn, ReportScope *scope, FILE *out) res = pgut_execute(conn, SQL_SELECT_BGWRITER_STATS, lengthof(params), params); fprintf(out, "Written Buffers By BGWriter (Average) : %s buffers/s\n", PQgetvalue(res, 0, 0)); fprintf(out, "Written Buffers By BGWriter (Maximum) : %s buffers/s\n", PQgetvalue(res, 0, 1)); - fprintf(out, "Written Buffers By Backend (Average) : %s buffers/s\n", PQgetvalue(res, 0, 2)); - fprintf(out, "Written Buffers By Backend (Maximum) : %s buffers/s\n", PQgetvalue(res, 0, 3)); - fprintf(out, "Backend Executed fsync (Average) : %s sync/s\n", PQgetvalue(res, 0, 4)); - fprintf(out, "Backend Executed fsync (Maximum) : %s sync/s\n\n", PQgetvalue(res, 0, 5)); PQclear(res); fprintf(out, "/** Transaction Increase Tendency **/\n"); diff --git a/test/expected/function-report.out b/test/expected/function-report.out index f5c884a..005a292 100644 --- a/test/expected/function-report.out +++ b/test/expected/function-report.out @@ -541,11 +541,6 @@ Average 25.5 (36.4 %) 12.8 (18.2 %) ----------------------------------- Written Buffers By BGWriter (Average) : 20.000 buffers/s Written Buffers By BGWriter (Maximum) : 30.000 buffers/s -Written Buffers By Backend (Average) : 200.000 buffers/s -Written Buffers By Backend (Maximum) : 300.000 buffers/s -Backend Executed fsync (Average) : 2.000 sync/s -Backend Executed fsync (Maximum) : 3.000 sync/s - /** Transaction Increase Tendency **/ ----------------------------------- DateTime XID Increase @@ -614,11 +609,6 @@ Average 25.5 (36.4 %) 12.8 (18.2 %) ----------------------------------- Written Buffers By BGWriter (Average) : 20.000 buffers/s Written Buffers By BGWriter (Maximum) : 30.000 buffers/s -Written Buffers By Backend (Average) : 200.000 buffers/s -Written Buffers By Backend (Maximum) : 300.000 buffers/s -Backend Executed fsync (Average) : 2.000 sync/s -Backend Executed fsync (Maximum) : 3.000 sync/s - /** Transaction Increase Tendency **/ ----------------------------------- DateTime XID Increase @@ -687,11 +677,6 @@ Average 25.5 (36.4 %) 12.8 (18.2 %) ----------------------------------- Written Buffers By BGWriter (Average) : 20.000 buffers/s Written Buffers By BGWriter (Maximum) : 30.000 buffers/s -Written Buffers By Backend (Average) : 200.000 buffers/s -Written Buffers By Backend (Maximum) : 300.000 buffers/s -Backend Executed fsync (Average) : 2.000 sync/s -Backend Executed fsync (Maximum) : 3.000 sync/s - /** Transaction Increase Tendency **/ ----------------------------------- DateTime XID Increase @@ -760,11 +745,6 @@ Average 25.5 (36.4 %) 12.8 (18.2 %) ----------------------------------- Written Buffers By BGWriter (Average) : 20.000 buffers/s Written Buffers By BGWriter (Maximum) : 30.000 buffers/s -Written Buffers By Backend (Average) : 200.000 buffers/s -Written Buffers By Backend (Maximum) : 300.000 buffers/s -Backend Executed fsync (Average) : 2.000 sync/s -Backend Executed fsync (Maximum) : 3.000 sync/s - /** Transaction Increase Tendency **/ ----------------------------------- DateTime XID Increase @@ -833,11 +813,6 @@ Average 25.5 (36.4 %) 12.8 (18.2 %) ----------------------------------- Written Buffers By BGWriter (Average) : 20.000 buffers/s Written Buffers By BGWriter (Maximum) : 30.000 buffers/s -Written Buffers By Backend (Average) : 200.000 buffers/s -Written Buffers By Backend (Maximum) : 300.000 buffers/s -Backend Executed fsync (Average) : 2.000 sync/s -Backend Executed fsync (Maximum) : 3.000 sync/s - /** Transaction Increase Tendency **/ ----------------------------------- DateTime XID Increase @@ -906,11 +881,6 @@ Average 25.5 (36.4 %) 12.8 (18.2 %) ----------------------------------- Written Buffers By BGWriter (Average) : 20.000 buffers/s Written Buffers By BGWriter (Maximum) : 30.000 buffers/s -Written Buffers By Backend (Average) : 200.000 buffers/s -Written Buffers By Backend (Maximum) : 300.000 buffers/s -Backend Executed fsync (Average) : 2.000 sync/s -Backend Executed fsync (Maximum) : 3.000 sync/s - /** Transaction Increase Tendency **/ ----------------------------------- DateTime XID Increase @@ -3422,11 +3392,6 @@ Average 25.5 (36.4 %) 12.8 (18.2 %) ----------------------------------- Written Buffers By BGWriter (Average) : 20.000 buffers/s Written Buffers By BGWriter (Maximum) : 30.000 buffers/s -Written Buffers By Backend (Average) : 200.000 buffers/s -Written Buffers By Backend (Maximum) : 300.000 buffers/s -Backend Executed fsync (Average) : 2.000 sync/s -Backend Executed fsync (Maximum) : 3.000 sync/s - /** Transaction Increase Tendency **/ ----------------------------------- DateTime XID Increase @@ -3898,11 +3863,6 @@ Average 25.5 (36.4 %) 12.8 (18.2 %) ----------------------------------- Written Buffers By BGWriter (Average) : 20.000 buffers/s Written Buffers By BGWriter (Maximum) : 30.000 buffers/s -Written Buffers By Backend (Average) : 200.000 buffers/s -Written Buffers By Backend (Maximum) : 300.000 buffers/s -Backend Executed fsync (Average) : 2.000 sync/s -Backend Executed fsync (Maximum) : 3.000 sync/s - /** Transaction Increase Tendency **/ ----------------------------------- DateTime XID Increase @@ -4374,11 +4334,6 @@ Average 25.5 (36.4 %) 12.8 (18.2 %) ----------------------------------- Written Buffers By BGWriter (Average) : 20.000 buffers/s Written Buffers By BGWriter (Maximum) : 30.000 buffers/s -Written Buffers By Backend (Average) : 200.000 buffers/s -Written Buffers By Backend (Maximum) : 300.000 buffers/s -Backend Executed fsync (Average) : 2.000 sync/s -Backend Executed fsync (Maximum) : 3.000 sync/s - /** Transaction Increase Tendency **/ ----------------------------------- DateTime XID Increase @@ -4850,11 +4805,6 @@ Average 25.5 (36.4 %) 12.8 (18.2 %) ----------------------------------- Written Buffers By BGWriter (Average) : 20.000 buffers/s Written Buffers By BGWriter (Maximum) : 30.000 buffers/s -Written Buffers By Backend (Average) : 200.000 buffers/s -Written Buffers By Backend (Maximum) : 300.000 buffers/s -Backend Executed fsync (Average) : 2.000 sync/s -Backend Executed fsync (Maximum) : 3.000 sync/s - /** Transaction Increase Tendency **/ ----------------------------------- DateTime XID Increase @@ -5326,11 +5276,6 @@ Average 25.5 (36.4 %) 12.8 (18.2 %) ----------------------------------- Written Buffers By BGWriter (Average) : 20.000 buffers/s Written Buffers By BGWriter (Maximum) : 30.000 buffers/s -Written Buffers By Backend (Average) : 200.000 buffers/s -Written Buffers By Backend (Maximum) : 300.000 buffers/s -Backend Executed fsync (Average) : 2.000 sync/s -Backend Executed fsync (Maximum) : 3.000 sync/s - /** Transaction Increase Tendency **/ ----------------------------------- DateTime XID Increase @@ -5802,11 +5747,6 @@ Average 25.5 (36.4 %) 12.8 (18.2 %) ----------------------------------- Written Buffers By BGWriter (Average) : 20.000 buffers/s Written Buffers By BGWriter (Maximum) : 30.000 buffers/s -Written Buffers By Backend (Average) : 200.000 buffers/s -Written Buffers By Backend (Maximum) : 300.000 buffers/s -Backend Executed fsync (Average) : 2.000 sync/s -Backend Executed fsync (Maximum) : 3.000 sync/s - /** Transaction Increase Tendency **/ ----------------------------------- DateTime XID Increase @@ -6475,11 +6415,6 @@ Average 300.5 (36.4 %) 150.3 (18.2 %) ----------------------------------- Written Buffers By BGWriter (Average) : 0.000 buffers/s Written Buffers By BGWriter (Maximum) : 0.000 buffers/s -Written Buffers By Backend (Average) : 0.000 buffers/s -Written Buffers By Backend (Maximum) : 0.000 buffers/s -Backend Executed fsync (Average) : 0.000 sync/s -Backend Executed fsync (Maximum) : 0.000 sync/s - /** Transaction Increase Tendency **/ ----------------------------------- DateTime XID Increase diff --git a/test/expected/function-snapshot.out b/test/expected/function-snapshot.out index d191e37..c70e079 100644 --- a/test/expected/function-snapshot.out +++ b/test/expected/function-snapshot.out @@ -41,13 +41,13 @@ vacuumdb: vacuuming database "template1" /**--- Statistics of column ---**/ snapid | database | table | column | attnum | type | stattarget | storage | isnotnull | isdropped | date | avg_width | n_distinct | correlation --------+----------+-------+---------+--------+---------+------------+---------+-----------+-----------+------+-----------+------------+------------- - 1 | db01 | tbl01 | id | 1 | integer | -1 | p | t | f | xxx | xxx | xxx | xxx - 1 | db01 | tbl01 | name | 2 | text | -1 | x | f | f | xxx | xxx | xxx | xxx - 1 | db01 | tbl01 | age | 3 | integer | -1 | p | f | f | xxx | xxx | xxx | xxx - 1 | db01 | tbl02 | id | 1 | integer | -1 | p | t | f | xxx | xxx | xxx | - 1 | db01 | tbl02 | name | 2 | text | -1 | x | f | f | xxx | xxx | xxx | - 1 | db01 | tbl02 | age | 3 | integer | -1 | p | f | f | xxx | xxx | xxx | - 1 | db01 | tbl02 | address | 4 | text | -1 | x | f | f | xxx | xxx | xxx | + 1 | db01 | tbl01 | id | 1 | integer | | p | t | f | xxx | xxx | xxx | xxx + 1 | db01 | tbl01 | name | 2 | text | | x | f | f | xxx | xxx | xxx | xxx + 1 | db01 | tbl01 | age | 3 | integer | | p | f | f | xxx | xxx | xxx | xxx + 1 | db01 | tbl02 | id | 1 | integer | | p | t | f | xxx | xxx | xxx | + 1 | db01 | tbl02 | name | 2 | text | | x | f | f | xxx | xxx | xxx | + 1 | db01 | tbl02 | age | 3 | integer | | p | f | f | xxx | xxx | xxx | + 1 | db01 | tbl02 | address | 4 | text | | x | f | f | xxx | xxx | xxx | (7 rows) /**--- Statistics of index ---**/ @@ -109,6 +109,7 @@ vacuumdb: vacuuming database "template1" 1 | pg_create_subscription | xxx 1 | pg_database_owner | xxx 1 | pg_execute_server_program | xxx + 1 | pg_maintain | xxx 1 | pg_monitor | xxx 1 | pg_read_all_data | xxx 1 | pg_read_all_settings | xxx @@ -121,7 +122,7 @@ vacuumdb: vacuuming database "template1" 1 | pg_write_server_files | xxx 1 | postgres | xxx 1 | user01 | xxx -(16 rows) +(17 rows) /**--- GUC setting ---**/ snapid | name | setting | unit | source @@ -189,21 +190,21 @@ DROP TABLE /**--- Statistics of query ---**/ /***-- pg_stat_statements is not installed --***/ - snapid | dbid | userid | queryid | query | plans | total_plan_time | calls | total_exec_time | rows | shared_blks_hit | shared_blks_read | shared_blks_dirtied | shared_blks_written | local_blks_hit | local_blks_read | local_blks_dirtied | local_blks_written | temp_blks_read | temp_blks_written | blk_read_time | blk_write_time | temp_blk_read_time | temp_blk_write_time ---------+------+--------+---------+-------+-------+-----------------+-------+-----------------+------+-----------------+------------------+---------------------+---------------------+----------------+-----------------+--------------------+--------------------+----------------+-------------------+---------------+----------------+--------------------+--------------------- + snapid | dbid | userid | queryid | query | plans | total_plan_time | calls | total_exec_time | rows | shared_blks_hit | shared_blks_read | shared_blks_dirtied | shared_blks_written | local_blks_hit | local_blks_read | local_blks_dirtied | local_blks_written | temp_blks_read | temp_blks_written | shared_blk_read_time | shared_blk_write_time | temp_blk_read_time | temp_blk_write_time +--------+------+--------+---------+-------+-------+-----------------+-------+-----------------+------+-----------------+------------------+---------------------+---------------------+----------------+-----------------+--------------------+--------------------+----------------+-------------------+----------------------+-----------------------+--------------------+--------------------- (0 rows) /***-- pg_stat_statements is installed --***/ CREATE EXTENSION - snapid | database | role | query | plans | total_plan_time | calls | total_exec_time | rows | shared_blks_hit | shared_blks_read | shared_blks_dirtied | shared_blks_written | local_blks_hit | local_blks_read | local_blks_dirtied | local_blks_written | temp_blks_read | temp_blks_written | blk_read_time | blk_write_time | temp_blk_read_time | temp_blk_write_time ---------+----------+--------+--------------------------------+-------+-----------------+-------+-----------------+------+-----------------+------------------+---------------------+---------------------+----------------+-----------------+--------------------+--------------------+----------------+-------------------+---------------+----------------+--------------------+--------------------- - 8 | db01 | user01 | SELECT schema01.func01($1, $2) | 0 | xxx | 200 | xxx | xxx | xxx | xxx | xxx | xxx | xxx | xxx | xxx | xxx | xxx | xxx | xxx | xxx | xxx | xxx + snapid | database | role | query | plans | total_plan_time | calls | total_exec_time | rows | shared_blks_hit | shared_blks_read | shared_blks_dirtied | shared_blks_written | local_blks_hit | local_blks_read | local_blks_dirtied | local_blks_written | temp_blks_read | temp_blks_written | shared_blk_read_time | shared_blk_write_time | temp_blk_read_time | temp_blk_write_time +--------+----------+--------+--------------------------------+-------+-----------------+-------+-----------------+------+-----------------+------------------+---------------------+---------------------+----------------+-----------------+--------------------+--------------------+----------------+-------------------+----------------------+-----------------------+--------------------+--------------------- + 8 | db01 | user01 | SELECT schema01.func01($1, $2) | 0 | xxx | 200 | xxx | xxx | xxx | xxx | xxx | xxx | xxx | xxx | xxx | xxx | xxx | xxx | xxx | xxx | xxx | xxx (1 row) /**--- Statistics of BGWriter ---**/ - snapid | buffers_clean | maxwritten_clean | buffers_backend | buffers_backend_fsync | buffers_alloc ---------+---------------+------------------+-----------------+-----------------------+--------------- - 8 | xxx | xxx | xxx | xxx | xxx + snapid | buffers_clean | maxwritten_clean | buffers_alloc +--------+---------------+------------------+--------------- + 8 | xxx | xxx | xxx (1 row) /**--- Statistics of rusage ---**/ diff --git a/test/script/function-snapshot.sh b/test/script/function-snapshot.sh index 2e877b2..2d81726 100755 --- a/test/script/function-snapshot.sh +++ b/test/script/function-snapshot.sh @@ -593,8 +593,8 @@ SELECT CASE WHEN s.local_blks_written IS NOT NULL THEN 'xxx' END AS local_blks_written, CASE WHEN s.temp_blks_read IS NOT NULL THEN 'xxx' END AS temp_blks_read, CASE WHEN s.temp_blks_written IS NOT NULL THEN 'xxx' END AS temp_blks_written, - CASE WHEN s.blk_read_time IS NOT NULL THEN 'xxx' END AS blk_read_time, - CASE WHEN s.blk_write_time IS NOT NULL THEN 'xxx' END AS blk_write_time, + CASE WHEN s.shared_blk_read_time IS NOT NULL THEN 'xxx' END AS shared_blk_read_time, + CASE WHEN s.shared_blk_write_time IS NOT NULL THEN 'xxx' END AS shared_blk_write_time, CASE WHEN s.temp_blk_read_time IS NOT NULL THEN 'xxx' END AS temp_blk_read_time, CASE WHEN s.temp_blk_write_time IS NOT NULL THEN 'xxx' END AS temp_blk_write_time FROM @@ -617,8 +617,6 @@ SELECT snapid, CASE WHEN buffers_clean IS NOT NULL THEN 'xxx' END AS buffers_clean, CASE WHEN maxwritten_clean IS NOT NULL THEN 'xxx' END AS maxwritten_clean, - CASE WHEN buffers_backend IS NOT NULL THEN 'xxx' END AS buffers_backend, - CASE WHEN buffers_backend_fsync IS NOT NULL THEN 'xxx' END AS buffers_backend_fsync, CASE WHEN buffers_alloc IS NOT NULL THEN 'xxx' END AS buffers_alloc FROM statsrepo.bgwriter diff --git a/test/script/inputdata/statsrepo-inputdata.sql b/test/script/inputdata/statsrepo-inputdata.sql index 7abf59a..e95f871 100644 --- a/test/script/inputdata/statsrepo-inputdata.sql +++ b/test/script/inputdata/statsrepo-inputdata.sql @@ -81,10 +81,10 @@ $$ -- -- Data for Name: bgwriter; Type: TABLE DATA; Schema: statsrepo; Owner: postgres -- - INSERT INTO statsrepo.bgwriter VALUES ($6, 0, 0, 0, 0, 0); - INSERT INTO statsrepo.bgwriter VALUES ($6 + 1, 600, 6, 6000, 60, 60000); - INSERT INTO statsrepo.bgwriter VALUES ($6 + 2, 2400, 24, 24000, 240, 240000); - INSERT INTO statsrepo.bgwriter VALUES ($6 + 3, 3600, 36, 36000, 360, 360000); + INSERT INTO statsrepo.bgwriter VALUES ($6, 0, 0, 0); + INSERT INTO statsrepo.bgwriter VALUES ($6 + 1, 600, 6, 60000); + INSERT INTO statsrepo.bgwriter VALUES ($6 + 2, 2400, 24, 240000); + INSERT INTO statsrepo.bgwriter VALUES ($6 + 3, 3600, 36, 360000); -- -- Data for Name: autovacuum_cancel; Type: TABLE DATA; Schema: statsrepo; Owner: postgres