8000 Merge branch 'master' into progress_bar · postgrespro/pg_query_state@8ad70f8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8ad70f8

Browse files
authored
Merge branch 'master' into progress_bar
2 parents a71af2e + 35416b6 commit 8ad70f8

18 files changed

+637
-56
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ notifications:
2222
on_failure: always
2323

2424
env:
25+
- PG_VERSION=16 LEVEL=hardcore USE_TPCDS=0
26+
- PG_VERSION=16
27+
- PG_VERSION=15 LEVEL=hardcore USE_TPCDS=0
28+
- PG_VERSION=15
2529
- PG_VERSION=14 LEVEL=hardcore USE_TPCDS=0
2630
- PG_VERSION=14
2731
- PG_VERSION=13 LEVEL=hardcore USE_TPCDS=0

Dockerfile.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ RUN apk add --no-cache \
66
perl perl-ipc-run \
77
make musl-dev gcc bison flex coreutils \
88
zlib-dev libedit-dev \
9-
clang clang-analyzer linux-headers \
9+
icu-dev clang clang-analyzer linux-headers \
1010
python3 python3-dev py3-virtualenv;
1111

1212

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pg_query_state is released under the PostgreSQL License, a liberal Open Source license, similar to the BSD or MIT licenses.
22

3-
Copyright (c) 2016-2019, Postgres Professional
3+
Copyright (c) 2016-2024, Postgres Professional
44
Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
55
Portions Copyright (c) 1994, The Regents of the University of California
66

Makefile

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,26 @@
22
# contrib/pg_query_state/Makefile
33

44
MODULE_big = pg_query_state
5-
OBJS = pg_query_state.o signal_handler.o $(WIN32RES)
5+
OBJS = pg_query_state.o signal_handler.o progress_bar.o $(WIN32RES)
66
EXTENSION = pg_query_state
77
EXTVERSION = 1.1
88
DATA = pg_query_state--1.0--1.1.sql
99
DATA_built = $(EXTENSION)--$(EXTVERSION).sql
1010
PGFILEDESC = "pg_query_state - facility to track progress of plan execution"
11-
EXTRA_REGRESS_OPTS=--temp-config=$(top_srcdir)/$(subdir)/test.conf
11+
1212
EXTRA_CLEAN = ./isolation_output $(EXTENSION)--$(EXTVERSION).sql \
1313
Dockerfile ./tests/*.pyc ./tmp_stress
1414

15+
ISOLATION = corner_cases
16+
#
17+
# PG11 doesn't support ISOLATION_OPTS variable. We have to use
18+
# "CREATE/DROP EXTENTION" command in spec.
19+
#
20+
# One day, when we'll get rid of PG11, it will be possible to uncomment this
21+
# variable and remove "CREATE EXTENTION" from spec.
22+
#
23+
# ISOLATION_OPTS = --load-extension=pg_query_state
24+
1525
ifdef USE_PGXS
1626
PG_CONFIG ?= pg_config
1727
PGXS := $(shell $(PG_CONFIG) --pgxs)
@@ -21,11 +31,17 @@ subdir = contrib/pg_query_state
2131
top_builddir = ../..
2232
include $(top_builddir)/src/Makefile.global
2333
include $(top_srcdir)/contrib/contrib-global.mk
34+
# need this to provide make check in case of "in source" build
35+
EXTRA_REGRESS_OPTS=--temp-config=$(top_srcdir)/$(subdir)/test.conf
2436
endif
2537

2638
$(EXTENSION)--$(EXTVERSION).sql: init.sql
2739
cat $^ > $@
2840

41+
#
42+
# Make conditional targets to save backward compatibility with PG11.
43+
#
44+
ifeq ($(MAJORVERSION),11)
2945
ISOLATIONCHECKS = corner_cases
3046

3147
check: isolationcheck
@@ -46,9 +62,4 @@ submake-isolation:
4662
$(MAKE) -C $(top_builddir)/src/test/isolation all
4763

4864
temp-install: EXTRA_INSTALL=contrib/pg_query_state
49-
50-
submake-progress_bar:
51-
$(MAKE) -C $(top_builddir)/contrib/pg_query_state
52-
53-
check_progress_bar: submake-progress_bar temp-install
54-
$(prove_check)
65+
endif

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,25 @@ Using this module there can help in the following things:
1515
- overwatch the query execution
1616

1717
## Installation
18-
To install `pg_query_state`, please apply corresponding patches `custom_signal_(PG_VERSION).patch` and `runtime_explain_(PG_VERSION).patch` (or `runtime_explain.patch` for PG version <= 10.0) in `patches/` directory to reqired stable version of PostgreSQL and rebuild PostgreSQL.
18+
To install `pg_query_state`, please apply corresponding patches `custom_signal_(PG_VERSION).patch` and `runtime_explain_(PG_VERSION).patch` (or `runtime_explain.patch` for PG version <= 10.0) from the `patches/` directory to reqired stable version of PostgreSQL and rebuild PostgreSQL.
19+
20+
To do this, run the following commands from the postgresql directory:
21+
```
22+
patch -p1 < path_to_pg_query_state_folder/patches/runtime_explain_(PG_VERSION).patch
23+
patch -p1 < path_to_pg_query_state_folder/patches/custom_signal_(PG_VERSION).patch
24+
```
1925

2026
Then execute this in the module's directory:
2127
```
2228
make install USE_PGXS=1
2329
```
30+
To execute the command correctly, make sure you have the PATH or PG_CONFIG variable set.
31+
```
32+
export PATH=path_to_your_bin_folder:$PATH
33+
# or
34+
export PG_CONFIG=path_to_your_bin_folder/pg_config
35+
```
36+
2437
Add module name to the `shared_preload_libraries` parameter in `postgresql.conf`:
2538
```
2639
shared_preload_libraries = 'pg_query_state'

docker-compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
tests:
1+
services:
2+
tests:
23
build: .

patches/custom_signals_15.0.patch

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ diff --git a/src/backend/storage/ipc/procsignal.c b/src/backend/storage/ipc/proc
22
index defb75a..4245d28 100644
33
--- a/src/backend/storage/ipc/procsignal.c
44
+++ b/src/backend/storage/ipc/procsignal.c
5-
@@ -95,6 +95,13 @@ typedef struct
5+
@@ -96,6 +96,13 @@ typedef struct
66
#define BARRIER_CLEAR_BIT(flags, type) \
77
((flags) &= ~(((uint32) 1) << (uint32) (type)))
8-
8+
99
+#define IsCustomProcSignalReason(reason) \
1010
+ ((reason) >= PROCSIG_CUSTOM_1 && (reason) <= PROCSIG_CUSTOM_N)
1111
+
@@ -15,20 +15,20 @@ index defb75a..4245d28 100644
1515
+
1616
static ProcSignalHeader *ProcSignal = NULL;
1717
static ProcSignalSlot *MyProcSignalSlot = NULL;
18-
19-
@@ -103,6 +110,8 @@ static void CleanupProcSignalState(int status, Datum arg);
18+
19+
@@ -103,6 +110,8 @@ static bool CheckProcSignal(ProcSignalReason reason);
20+
static void CleanupProcSignalState(int status, Datum arg);
2021
static void ResetProcSignalBarrierBits(uint32 flags);
21-
static bool ProcessBarrierPlaceholder(void);
22-
22+
2323
+static void CheckAndSetCustomSignalInterrupts(void);
2424
+
2525
/*
2626
* ProcSignalShmemSize
27-
* Compute space needed for procsignal's shared memory
27+
* Compute space needed for ProcSignal's shared memory
2828
@@ -246,6 +255,36 @@ CleanupProcSignalState(int status, Datum arg)
2929
slot->pss_pid = 0;
3030
}
31-
31+
3232
+/*
3333
+ * RegisterCustomProcSignalHandler
3434
+ * Assign specific handler of custom process signal with new
@@ -62,7 +62,7 @@ index defb75a..4245d28 100644
6262
/*
6363
* SendProcSignal
6464
* Send a signal to a Postgres process
65-
@@ -679,7 +718,62 @@ procsignal_sigusr1_handler(SIGNAL_ARGS)
65+
@@ -675,7 +714,72 @@ procsignal_sigusr1_handler(SIGNAL_ARGS)
6666
if (CheckProcSignal(PROCSIG_RECOVERY_CONFLICT_BUFFERPIN))
6767
RecoveryConflictInterrupt(PROCSIG_RECOVERY_CONFLICT_BUFFERPIN);
6868

@@ -135,12 +135,12 @@ index defb75a..4245d28 100644
135135
+
136136
+ RESUME_INTERRUPTS();
137137
+}
138-
\ No newline at end of file
138+
+
139139
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
140140
index 8cea10c..dd77c98 100644
141141
--- a/src/backend/tcop/postgres.c
142142
+++ b/src/backend/tcop/postgres.c
143-
@@ -3364,6 +3364,8 @@ ProcessInterrupts(void)
143+
@@ -3402,6 +3402,8 @@ ProcessInterrupts(void)
144144
if (ParallelMessagePending)
145145
HandleParallelMessages();
146146

@@ -186,16 +186,17 @@ index eec186b..74af186 100644
186186
NUM_PROCSIGNALS /* Must be last! */
187187
} ProcSignalReason;
188188

189-
@@ -56,6 +68,8 @@ typedef enum
190-
*/
191-
PROCSIGNAL_BARRIER_PLACEHOLDER = 0
189+
@@ -51,6 +63,9 @@ typedef enum
190+
{
191+
PROCSIGNAL_BARRIER_SMGRRELEASE /* ask smgr to close files */
192192
} ProcSignalBarrierType;
193+
+
193194
+/* Handler of custom process signal */
194195
+typedef void (*ProcSignalHandler_type) (void);
195196

196197
/*
197198
* prototypes for functions in procsignal.c
198-
@@ -64,12 +78,15 @@ extern Size ProcSignalShmemSize(void);
199+
@@ -59,12 +74,15 @@ extern Size ProcSignalShmemSize(void);
199200
extern void ProcSignalShmemInit(void);
200201

201202
extern void ProcSignalInit(int pss_idx);

0 commit comments

Comments
 (0)
0