Skip to content

Commit ca1a4ab

Browse files
Ekaterina Sokolovasokolcati
authored andcommitted
Update pg_query_state to PostgreSQL 18
1. Change backend status to text conversion due to possible status set changes 2. Update Travis CI
1 parent c20d892 commit ca1a4ab

File tree

4 files changed

+37
-14
lines changed

4 files changed

+37
-14
lines changed

.travis.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,21 @@ notifications:
2222
on_failure: always
2323

2424
env:
25+
- PG_VERSION=18
2526
- PG_VERSION=17
2627
- PG_VERSION=16 LEVEL=hardcore USE_TPCDS=0
2728
- PG_VERSION=16
2829
- PG_VERSION=15 LEVEL=hardcore USE_TPCDS=0
2930
- PG_VERSION=15
3031
- PG_VERSION=14 LEVEL=hardcore USE_TPCDS=0
3132
- PG_VERSION=14
32-
- PG_VERSION=13 LEVEL=hardcore USE_TPCDS=0
3333
- PG_VERSION=13
34-
- PG_VERSION=12 LEVEL=hardcore USE_TPCDS=0
3534
- PG_VERSION=12
3635
- PG_VERSION=10
3736
- PG_VERSION=9.6
3837

3938
matrix:
4039
allow_failures:
41-
- env: PG_VERSION=13 LEVEL=hardcore USE_TPCDS=1
40+
- env: PG_VERSION=12
4241
- env: PG_VERSION=10
4342
- env: PG_VERSION=9.6

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ PGFILEDESC = "pg_query_state - facility to track progress of plan execution"
1313
EXTRA_CLEAN = ./isolation_output $(EXTENSION)--$(EXTVERSION).sql \
1414
Dockerfile ./tests/*.pyc ./tmp_stress
1515

16+
ISOLATION = corner_cases
1617
ISOLATION_OPTS = --load-extension=pg_query_state
1718

1819
TAP_TESTS = 1

pg_query_state.c

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,7 @@ List *QueryDescStack = NIL;
6767
static ProcSignalReason UserIdPollReason = INVALID_PROCSIGNAL;
6868
static ProcSignalReason QueryStatePollReason = INVALID_PROCSIGNAL;
6969
static ProcSignalReason WorkerPollReason = INVALID_PROCSIGNAL;
70-
static bool module_initialized = false;
71-
static const char *be_state_str[] = { /* BackendState -> string repr */
72-
"undefined", /* STATE_UNDEFINED */
73-
"idle", /* STATE_IDLE */
74-
"active", /* STATE_RUNNING */
75-
"idle in transaction", /* STATE_IDLEINTRANSACTION */
76-
"fastpath function call", /* STATE_FASTPATH */
77-
"idle in transaction (aborted)", /* STATE_IDLEINTRANSACTION_ABORTED */
78-
"disabled", /* STATE_DISABLED */
79-
};
70+
static bool module_initialized = false;
8071
static int reqid = 0;
8172

8273
typedef struct
@@ -352,6 +343,37 @@ qs_ExecutorFinish(QueryDesc *queryDesc)
352343
PG_END_TRY();
353344
}
354345

346+
/*
347+
* Convert BackendState to string description
348+
*/
349+
static const char *
350+
be_state_str(BackendState be_state)
351+
{
352+
switch (be_state)
353+
{
354+
case STATE_UNDEFINED:
355+
return "undefined";
356+
#if PG_VERSION_NUM >= 180000
357+
case STATE_STARTING:
358+
return "starting";
359+
#endif
360+
case STATE_IDLE:
361+
return "idle";
362+
case STATE_RUNNING:
363+
return "active";
364+
case STATE_IDLEINTRANSACTION:
365+
return "idle in transaction";
366+
case STATE_FASTPATH:
367+
return "fastpath function call";
368+
case STATE_IDLEINTRANSACTION_ABORTED:
369+
return "idle in transaction (aborted)";
370+
case STATE_DISABLED:
371+
return "disabled";
372+
default:
373+
return "unknown";
374+
}
375+
}
376+
355377
/*
356378
* Find PgBackendStatus entry
357379
*/
@@ -598,7 +620,7 @@ pg_query_state(PG_FUNCTION_ARGS)
598620

599621
if (be_status)
600622
elog(INFO, "state of backend is %s",
601-
be_state_str[be_status->st_state - STATE_UNDEFINED]);
623+
be_state_str(be_status->st_state));
602624
else
603625
elog(INFO, "backend is not running query");
604626

signal_handler.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include "commands/explain.h"
1414
#if PG_VERSION_NUM >= 180000
15+
#include "commands/explain_state.h"
1516
#include "commands/explain_format.h"
1617
#endif
1718
#include "miscadmin.h"

0 commit comments

Comments
 (0)