Skip to content

Commit

Permalink
Merge branch 'master' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
ololobus committed Nov 11, 2020
2 parents df7612b + 92becb3 commit 32c389d
Show file tree
Hide file tree
Showing 19 changed files with 172 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
/results
*pg_wait_sampling--1.1.sql
.log
Dockerfile
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,9 @@ env:
- PG_VERSION=10 CHECK_CODE=clang
- PG_VERSION=10 CHECK_CODE=cppcheck
- PG_VERSION=10 CHECK_CODE=false
- PG_VERSION=11 CHECK_CODE=clang
- PG_VERSION=11 CHECK_CODE=false
- PG_VERSION=12 CHECK_CODE=clang
- PG_VERSION=12 CHECK_CODE=false
- PG_VERSION=13 CHECK_CODE=clang
- PG_VERSION=13 CHECK_CODE=false
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build Status](https://travis-ci.org/postgrespro/pg_wait_sampling.svg?branch=master)](https://travis-ci.org/postgrespro/pg_wait_sampling)
[![Build Status](https://travis-ci.com/postgrespro/pg_wait_sampling.svg?branch=master)](https://travis-ci.com/postgrespro/pg_wait_sampling)
[![PGXN version](https://badge.fury.io/pg/pg_wait_sampling.svg)](https://badge.fury.io/pg/pg_wait_sampling)
[![GitHub license](https://img.shields.io/badge/license-PostgreSQL-blue.svg)](https://raw.githubusercontent.com/postgrespro/pg_wait_sampling/master/LICENSE)

Expand Down
9 changes: 6 additions & 3 deletions collector.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
#include "postgres.h"

#include "catalog/pg_type.h"
#if PG_VERSION_NUM >= 130000
#include "common/hashfn.h"
#endif
#include "funcapi.h"
#include "miscadmin.h"
#include "postmaster/bgworker.h"
Expand Down Expand Up @@ -303,11 +306,11 @@ static int64
millisecs_diff(TimestampTz tz1, TimestampTz tz2)
{
long secs;
int millisecs;
int microsecs;

TimestampDifference(tz1, tz2, &secs, &millisecs);
TimestampDifference(tz1, tz2, &secs, &microsecs);

return secs * 1000 + millisecs;
return secs * 1000 + microsecs / 1000;

}

Expand Down
11 changes: 11 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
pg-wait-sampling (1.1.2-1) unstable; urgency=medium

* New upstream version compatible with PG13

-- Adrien Nayrat <[email protected]> Wed, 28 Oct 2020 09:03:03 +0000

pg-wait-sampling (1.1.1-1) unstable; urgency=medium

* Release 1.1.1

-- Adrien Nayrat <[email protected]> Wed, 17 Jun 2020 12:26:59 +0000
1 change: 1 addition & 0 deletions debian/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9
39 changes: 39 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Source: pg-wait-sampling
Section: database
Priority: optional
Maintainer: Adrien Nayrat <[email protected]>
Standards-Version: 4.5.0
Build-Depends: debhelper (>=9~), postgresql-server-dev-all (>= 141~)
Homepage: https://github.com/postgrespro/pg_wait_sampling
Vcs-Browser: https://github.com/postgrespro/pg_wait_sampling
Vcs-Git: https://github.com/postgrespro/pg_wait_sampling.git

Package: postgresql-9.6-pg-wait-sampling
Architecture: any
Depends: ${misc:Depends}, ${shlibs:Depends}, postgresql-9.6,
Description: pg_wait-sampling provides functions for detailed per backend
and per query statistics about PostgreSQL wait events

Package: postgresql-10-pg-wait-sampling
Architecture: any
Depends: ${misc:Depends}, ${shlibs:Depends}, postgresql-10,
Description: pg_wait-sampling provides functions for detailed per backend
and per query statistics about PostgreSQL wait events

Package: postgresql-11-pg-wait-sampling
Architecture: any
Depends: ${misc:Depends}, ${shlibs:Depends}, postgresql-11,
Description: pg_wait-sampling provides functions for detailed per backend
and per query statistics about PostgreSQL wait events

Package: postgresql-12-pg-wait-sampling
Architecture: any
Depends: ${misc:Depends}, ${shlibs:Depends}, postgresql-12,
Description: pg_wait-sampling provides functions for detailed per backend
and per query statistics about PostgreSQL wait events

Package: postgresql-13-pg-wait-sampling
Architecture: any
Depends: ${misc:Depends}, ${shlibs:Depends}, postgresql-13,
Description: pg_wait-sampling provides functions for detailed per backend
and per query statistics about PostgreSQL wait events
15 changes: 15 additions & 0 deletions debian/control.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Source: pg-wait-sampling
Section: database
Priority: optional
Maintainer: Adrien Nayrat <[email protected]>
Standards-Version: 4.5.0
Build-Depends: debhelper (>=9~), postgresql-server-dev-all (>= 141~)
Homepage: https://github.com/postgrespro/pg_wait_sampling
Vcs-Browser: https://github.com/postgrespro/pg_wait_sampling
Vcs-Git: https://github.com/postgrespro/pg_wait_sampling.git

Package: postgresql-PGVERSION-pg-wait-sampling
Architecture: any
Depends: ${misc:Depends}, ${shlibs:Depends}, postgresql-PGVERSION,
Description: pg_wait-sampling provides functions for detailed per backend
and per query statistics about PostgreSQL wait events
11 changes: 11 additions & 0 deletions debian/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
pg_wait_sampling is released under the PostgreSQL License, a liberal Open Source license, similar to the BSD or MIT licenses.

Copyright (c) 2015-2017, Postgres Professional
Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
Portions Copyright (c) 1994, The Regents of the University of California

Permission to use, copy, modify, and distribute this software and its documentation for any purpose, without fee, and without a written agreement is hereby granted, provided that the above copyright notice and this paragraph and the following two paragraphs appear in all copies.

IN NO EVENT SHALL POSTGRES PROFESSIONAL BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF POSTGRES PROFESSIONAL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

POSTGRES PROFESSIONAL SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND POSTGRES PROFESSIONAL HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1 change: 1 addition & 0 deletions debian/pgversions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9.6+
27 changes: 27 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/make -f

PKGVER = $(shell dpkg-parsechangelog | awk -F '[:-]' '/^Version:/ { print substr($$2, 2) }')
EXCLUDE = --exclude-vcs --exclude=debian

include /usr/share/postgresql-common/pgxs_debian_control.mk

override_dh_auto_build:
# do nothing

override_dh_auto_test:
# nothing to do here, upstream tests used, see debian/tests/*

override_dh_auto_install:
# build all supported versions
+pg_buildext loop postgresql-%v-pg-wait-sampling

override_dh_installdocs:
dh_installdocs --all README.md

override_dh_auto_clean:
$(MAKE) clean USE_PGXS=1 PG_CONFIG=/usr/bin/pg_config

orig: debian/control clean
cd .. && tar czf pg-wait-sampling_$(PKGVER).orig.tar.gz $(EXCLUDE) pg_wait_sampling-$(PKGVER)
%:
dh $@
1 change: 1 addition & 0 deletions debian/source/format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0 (quilt)
3 changes: 3 additions & 0 deletions debian/tests/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Depends: @, postgresql-server-dev-all
Tests: installcheck
Restrictions: allow-stderr
5 changes: 5 additions & 0 deletions debian/tests/installcheck
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

set -eu

pg_buildext -o "shared_preload_libraries=pg_wait_sampling" installcheck
3 changes: 3 additions & 0 deletions debian/watch
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
version=3
opts="uversionmangle=s/_/./g" \
https://github.com/postgrespro/pg_wait_sampling/releases .*/archive/v(.*).tar.gz
19 changes: 19 additions & 0 deletions expected/queries.out
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,25 @@ WITH t as (SELECT sum(0) FROM pg_wait_sampling_profile)
0
(1 row)

-- Some dummy checks just to be sure that all our functions work and return something.
SELECT count(*) = 1 as test FROM pg_wait_sampling_get_current(pg_backend_pid());
test
------
t
(1 row)

SELECT count(*) >= 0 as test FROM pg_wait_sampling_get_profile();
test
------
t
(1 row)

SELECT count(*) >= 0 as test FROM pg_wait_sampling_get_history();
test
------
t
(1 row)

SELECT pg_wait_sampling_reset_profile();
pg_wait_sampling_reset_profile
--------------------------------
Expand Down
21 changes: 18 additions & 3 deletions pg_wait_sampling.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ CollectorShmqHeader *collector_hdr = NULL;
static shmem_startup_hook_type prev_shmem_startup_hook = NULL;
static PGPROC * search_proc(int backendPid);
static PlannedStmt *pgws_planner_hook(Query *parse,
#if PG_VERSION_NUM >= 130000
const char *query_string,
#endif
int cursorOptions, ParamListInfo boundParams);
static void pgws_ExecutorEnd(QueryDesc *queryDesc);

Expand Down Expand Up @@ -771,7 +774,11 @@ pg_wait_sampling_get_history(PG_FUNCTION_ARGS)
* planner_hook hook, save queryId for collector
*/
static PlannedStmt *
pgws_planner_hook(Query *parse, int cursorOptions,
pgws_planner_hook(Query *parse,
#if PG_VERSION_NUM >= 130000
const char *query_string,
#endif
int cursorOptions,
ParamListInfo boundParams)
{
if (MyProc)
Expand All @@ -795,9 +802,17 @@ pgws_planner_hook(Query *parse, int cursorOptions,

/* Invoke original hook if needed */
if (planner_hook_next)
return planner_hook_next(parse, cursorOptions, boundParams);
return planner_hook_next(parse,
#if PG_VERSION_NUM >= 130000
query_string,
#endif
cursorOptions, boundParams);

return standard_planner(parse, cursorOptions, boundParams);
return standard_planner(parse,
#if PG_VERSION_NUM >= 130000
query_string,
#endif
cursorOptions, boundParams);
}

/*
Expand Down
4 changes: 2 additions & 2 deletions run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ if [ "$CHECK_CODE" = "clang" ]; then

elif [ "$CHECK_CODE" = "cppcheck" ]; then
cppcheck \
--template "{file} ({line}): {severity} ({id}): {message}" \
--template "{file} ({line}): {severity} ({id}): {message}" \
--enable=warning,portability,performance \
--suppress=redundantAssignment \
--suppress=uselessAssignmentPtrArg \
--suppress=literalWithCharPtrCompare \
--suppress=literalWithCharPtrCompare \
--suppress=incorrectStringBooleanError \
--std=c89 *.c *.h 2> cppcheck.log

Expand Down
4 changes: 4 additions & 0 deletions sql/queries.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ WITH t as (SELECT sum(0) FROM pg_wait_sampling_history)
WITH t as (SELECT sum(0) FROM pg_wait_sampling_profile)
SELECT sum(0) FROM generate_series(1, 2), t;

-- Some dummy checks just to be sure that all our functions work and return something.
SELECT count(*) = 1 as test FROM pg_wait_sampling_get_current(pg_backend_pid());
SELECT count(*) >= 0 as test FROM pg_wait_sampling_get_profile();
SELECT count(*) >= 0 as test FROM pg_wait_sampling_get_history();
SELECT pg_wait_sampling_reset_profile();

DROP EXTENSION pg_wait_sampling;

0 comments on commit 32c389d

Please sign in to comment.