# pg_stat_plan/Makefile
MODULES = pg_store_plans
-STOREPLANSVER = 1.6.1
+STOREPLANSVER = 1.7
MODULE_big = pg_store_plans
OBJS = pg_store_plans.o pgsp_json.o pgsp_json_text.o pgsp_explain.o
PG_VERSION := $(shell pg_config --version | sed "s/^PostgreSQL //" | sed "s/\.[0-9]*$$//")
-DATA = pg_store_plans--1.6.sql pg_store_plans--1.6--1.6.1.sql
+DATA = pg_store_plans--1.7.sql
REGRESS = convert store
REGRESS_OPTS = --temp-config=regress.conf
include $(top_srcdir)/contrib/contrib-global.mk
endif
-STARBALL14 = pg_store_plans14-$(STOREPLANSVER).tar.gz
-STARBALLS = $(STARBALL14)
+STARBALL15 = pg_store_plans15-$(STOREPLANSVER).tar.gz
+STARBALLS = $(STARBALL15)
TARSOURCES = Makefile *.c *.h \
pg_store_plans--*.sql \
## These entries need running server
DBNAME = postgres
-rpms: rpm14
+rpms: rpm15
$(STARBALLS): $(TARSOURCES)
if [ -h $(subst .tar.gz,,$@) ]; then rm $(subst .tar.gz,,$@); fi
tar -chzf $@ $(addprefix $(subst .tar.gz,,$@)/, $^)
rm $(subst .tar.gz,,$@)
-rpm14: $(STARBALL14)
- MAKE_ROOT=`pwd` rpmbuild -bb SPECS/pg_store_plans14.spec
+rpm15: $(STARBALL15)
+ MAKE_ROOT=`pwd` rpmbuild -bb SPECS/pg_store_plans15.spec
testfiles: convert.out convert.sql
# SPEC file for pg_store_plans
-# Copyright(c) 2021, NIPPON TELEGRAPH AND TELEPHONE CORPORATION
+# Copyright(c) 2022, NIPPON TELEGRAPH AND TELEPHONE CORPORATION
-%define _pgdir /usr/pgsql-14
+%define _pgdir /usr/pgsql-15
%define _bindir %{_pgdir}/bin
%define _libdir %{_pgdir}/lib
%define _datadir %{_pgdir}/share
%endif
## Set general information for pg_store_plans.
-Summary: Record executed plans on PostgreSQL 14
-Name: pg_store_plans14
-Version: 1.6.1
+Summary: Record executed plans on PostgreSQL 15
+Name: pg_store_plans15
+Version: 1.7
Release: 1%{?dist}
License: BSD
Group: Applications/Databases
Vendor: NIPPON TELEGRAPH AND TELEPHONE CORPORATION
## We use postgresql-devel package
-BuildRequires: postgresql14-devel
-Requires: postgresql14-libs
+BuildRequires: postgresql15-devel
+Requires: postgresql15-libs
## Description for "pg_store_plans"
%description
pg_store_plans provides capability to record statistics for every plan
executed on PostgreSQL.
-Note that this package is available for only PostgreSQL 14.
+Note that this package is available for only PostgreSQL 15.
%package llvmjit
-Requires: postgresql14-server, postgresql14-llvmjit
-Requires: pg_store_plans14 = 1.6.1
-Summary: Just-in-time compilation support for pg_store_plans14
+Requires: postgresql15-server, postgresql15-llvmjit
+Requires: pg_store_plans15 = 1.7
+Summary: Just-in-time compilation support for pg_store_plans15
%description llvmjit
-Just-in-time compilation support for pg_store_plans14
+Just-in-time compilation support for pg_store_plans15
## pre work for build pg_store_plans
%prep
-PATH=/usr/pgsql-14/bin:$PATH
+PATH=/usr/pgsql-15/bin:$PATH
if [ "${MAKE_ROOT}" != "" ]; then
pushd ${MAKE_ROOT}
make clean %{name}-%{version}.tar.gz
## Set variables for build environment
%build
-PATH=/usr/pgsql-14/bin:$PATH
+PATH=/usr/pgsql-15/bin:$PATH
pg_config
make USE_PGXS=1 %{?_smp_mflags}
## Set variables for install
%install
rm -rf %{buildroot}
-PATH=/usr/pgsql-14/bin:$PATH
+PATH=/usr/pgsql-15/bin:$PATH
make install DESTDIR=%{buildroot}
%clean
%defattr(0755,root,root)
%{_libdir}/pg_store_plans.so
%defattr(0644,root,root)
-%{_datadir}/extension/pg_store_plans--1.6.sql
-%{_datadir}/extension/pg_store_plans--1.6--1.6.1.sql
+%{_datadir}/extension/pg_store_plans--1.7.sql
%{_datadir}/extension/pg_store_plans.control
%files llvmjit
# History of pg_store_plans.
%changelog
+* Wed Dec 14 2022 Kyotaro Horiguchi
+- Version 1.7. Support PostgreSQL 15.
* Thu Feb 03 2022 Kyotaro Horiguchi
- Version 1.6.1.
* Mon Jan 17 2022 Tatsuro Yamada, Julien Rouhaud, Kyotaro Horiguchi
<TD>Total time the statement using the plan spent writing blocks, in milliseconds (if <A HREF="http://www.postgresql.org/docs/current/static/runtime-config-statistics.html#GUC-TRACK-IO-TIMING">track_io_timing</A> is enabled, otherwise zero)</TD>
</TR>
+<TR><TD><TT CLASS="STRUCTFIELD">temp_blk_read_time</TT></TD>
+ <TD><TT CLASS="TYPE">double precision</TT></TD>
+ <TD> </TD>
+
+ <TD>Total time the statement using the plan spent reading temporary file blocks, in milliseconds (if <A HREF="http://www.postgresql.org/docs/current/static/runtime-config-statistics.html#GUC-TRACK-IO-TIMING">track_io_timing</A> is enabled, otherwise zero)</TD>
+ </TR>
+<TR><TD><TT CLASS="STRUCTFIELD">temp_blk_write_time</TT></TD>
+ <TD><TT CLASS="TYPE">double precision</TT></TD>
+ <TD> </TD>
+
+ <TD>Total time the statement using the plan spent writing temporary file blocks, in milliseconds (if <A HREF="http://www.postgresql.org/docs/current/static/runtime-config-statistics.html#GUC-TRACK-IO-TIMING">track_io_timing</A> is enabled, otherwise zero)</TD>
+ </TR>
<TR><TD><TT CLASS="STRUCTFIELD">first_call</TT></TD>
<TD><TT CLASS="TYPE">timestamp with time zone</TT></TD>
<TD> </TD>
+++ /dev/null
-/* pg_store_plans/pg_store_plans--1.6--1.6.1.sql */
-
--- complain if script is sourced in psql, rather than via CREATE EXTENSION
-\echo Use "CREATE EXTENSION pg_store_plans" to load this file. \quit
-/* pg_store_plans/pg_store_plans--1.6.sql */
+/* pg_store_plans/pg_store_plans--1.7.sql */
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION pg_store_plans" to load this file. \quit
OUT temp_blks_written int8,
OUT blk_read_time float8,
OUT blk_write_time float8,
+ OUT temp_blk_read_time float8,
+ OUT temp_blk_write_time float8,
OUT first_call timestamptz,
OUT last_call timestamptz
)
RETURNS SETOF record
-AS 'MODULE_PATHNAME', 'pg_store_plans_1_6'
+AS 'MODULE_PATHNAME', 'pg_store_plans_1_7'
LANGUAGE C
VOLATILE PARALLEL SAFE;
static const uint32 PGSP_PG_MAJOR_VERSION = PG_VERSION_NUM / 100;
/* This constant defines the magic number in the stats file header */
-static const uint32 PGSP_FILE_HEADER = 0x20211125;
+static const uint32 PGSP_FILE_HEADER = 0x20221214;
static int max_plan_len = 5000;
/* XXX: Should USAGE_EXEC reflect execution time and/or buffer usage? */
typedef enum pgspVersion
{
PGSP_V1_5 = 0,
- PGSP_V1_6
+ PGSP_V1_6,
+ PGSP_V1_7
} pgspVersion;
/*
int64 temp_blks_written; /* # of temp blocks written */
double blk_read_time; /* time spent reading, in msec */
double blk_write_time; /* time spent writing, in msec */
+ double temp_blk_read_time; /* time spent reading temp blocks,
+ in msec */
+ double temp_blk_write_time;/* time spent writing temp blocks,
+ in msec */
TimestampTz first_call; /* timestamp of first call */
TimestampTz last_call; /* timestamp of last call */
double usage; /* usage factor */
PG_FUNCTION_INFO_V1(pg_store_plans_hash_query);
PG_FUNCTION_INFO_V1(pg_store_plans);
PG_FUNCTION_INFO_V1(pg_store_plans_1_6);
+PG_FUNCTION_INFO_V1(pg_store_plans_1_7);
PG_FUNCTION_INFO_V1(pg_store_plans_shorten);
PG_FUNCTION_INFO_V1(pg_store_plans_normalize);
PG_FUNCTION_INFO_V1(pg_store_plans_jsonplan);
*/
if (!process_shared_preload_libraries_in_progress)
return;
-
#if PG_VERSION_NUM >= 140000
/*
* Inform the postmaster that we want to enable query_id calculation if
e->counters.local_blks_written += bufusage->local_blks_written;
e->counters.temp_blks_read += bufusage->temp_blks_read;
e->counters.temp_blks_written += bufusage->temp_blks_written;
+
e->counters.blk_read_time += INSTR_TIME_GET_MILLISEC(bufusage->blk_read_time);
e->counters.blk_write_time += INSTR_TIME_GET_MILLISEC(bufusage->blk_write_time);
+ e->counters.temp_blk_read_time += INSTR_TIME_GET_MILLISEC(bufusage->temp_blk_read_time);
+ e->counters.temp_blk_write_time += INSTR_TIME_GET_MILLISEC(bufusage->temp_blk_write_time);
+
e->counters.last_call = GetCurrentTimestamp();
e->counters.usage += USAGE_EXEC(total_time);
/* Number of output arguments (columns) for various API versions */
#define PG_STORE_PLANS_COLS_V1_5 27
#define PG_STORE_PLANS_COLS_V1_6 26
-#define PG_STORE_PLANS_COLS 27 /* maximum of above */
+#define PG_STORE_PLANS_COLS_V1_7 28
+#define PG_STORE_PLANS_COLS 28 /* maximum of above */
/*
* Retrieve statement statistics.
*/
Datum
+pg_store_plans_1_7(PG_FUNCTION_ARGS)
+{
+ pg_store_plans_internal(fcinfo, PGSP_V1_7);
+
+ return (Datum) 0;
+}
+
+Datum
pg_store_plans_1_6(PG_FUNCTION_ARGS)
{
pg_store_plans_internal(fcinfo, PGSP_V1_6);
values[i++] = Int64GetDatumFast(tmp.temp_blks_written);
values[i++] = Float8GetDatumFast(tmp.blk_read_time);
values[i++] = Float8GetDatumFast(tmp.blk_write_time);
+
+ if (api_version >= PGSP_V1_7)
+ {
+ values[i++] = Float8GetDatumFast(tmp.temp_blk_read_time);
+ values[i++] = Float8GetDatumFast(tmp.temp_blk_write_time);
+ }
+
values[i++] = TimestampTzGetDatum(tmp.first_call);
values[i++] = TimestampTzGetDatum(tmp.last_call);
Assert(i == (api_version == PGSP_V1_5 ? PG_STORE_PLANS_COLS_V1_5 :
api_version == PGSP_V1_6 ? PG_STORE_PLANS_COLS_V1_6 :
+ api_version == PGSP_V1_7 ? PG_STORE_PLANS_COLS_V1_7 :
-1 /* fail if you forget to update this assert */ ));
tuplestore_putvalues(tupstore, tupdesc, values, nulls);
# pg_store_plans extension
comment = 'track plan statistics of all SQL statements executed'
-default_version = '1.6.1'
+default_version = '1.7'
module_pathname = '$libdir/pg_store_plans'
relocatable = true