Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5844c23

Browse files
committed
Merge v1.10 of pg_stat_statements into v1.9
v1.9 is already new in this version of PostgreSQL, so turn it into just one change. Author: Julien Rohaud Discussion: https://postgr.es/m/20210408120505.7zinijtdexbyghvb@nol
1 parent 34399a6 commit 5844c23

File tree

5 files changed

+64
-69
lines changed

5 files changed

+64
-69
lines changed

contrib/pg_stat_statements/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ OBJS = \
66
pg_stat_statements.o
77

88
EXTENSION = pg_stat_statements
9-
DATA = pg_stat_statements--1.4.sql \
10-
pg_stat_statements--1.9--1.10.sql pg_stat_statements--1.8--1.9.sql \
9+
DATA = pg_stat_statements--1.4.sql pg_stat_statements--1.8--1.9.sql \
1110
pg_stat_statements--1.7--1.8.sql pg_stat_statements--1.6--1.7.sql \
1211
pg_stat_statements--1.5--1.6.sql pg_stat_statements--1.4--1.5.sql \
1312
pg_stat_statements--1.3--1.4.sql pg_stat_statements--1.2--1.3.sql \

contrib/pg_stat_statements/pg_stat_statements--1.8--1.9.sql

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,56 @@ CREATE VIEW pg_stat_statements_info AS
1616
SELECT * FROM pg_stat_statements_info();
1717

1818
GRANT SELECT ON pg_stat_statements_info TO PUBLIC;
19+
20+
/* First we have to remove them from the extension */
21+
ALTER EXTENSION pg_stat_statements DROP VIEW pg_stat_statements;
22+
ALTER EXTENSION pg_stat_statements DROP FUNCTION pg_stat_statements(boolean);
23+
24+
/* Then we can drop them */
25+
DROP VIEW pg_stat_statements;
26+
DROP FUNCTION pg_stat_statements(boolean);
27+
28+
/* Now redefine */
29+
CREATE FUNCTION pg_stat_statements(IN showtext boolean,
30+
OUT userid oid,
31+
OUT dbid oid,
32+
OUT toplevel bool,
33+
OUT queryid bigint,
34+
OUT query text,
35+
OUT plans int8,
36+
OUT total_plan_time float8,
37+
OUT min_plan_time float8,
38+
OUT max_plan_time float8,
39+
OUT mean_plan_time float8,
40+
OUT stddev_plan_time float8,
41+
OUT calls int8,
42+
OUT total_exec_time float8,
43+
OUT min_exec_time float8,
44+
OUT max_exec_time float8,
45+
OUT mean_exec_time float8,
46+
OUT stddev_exec_time float8,
47+
OUT rows int8,
48+
OUT shared_blks_hit int8,
49+
OUT shared_blks_read int8,
50+
OUT shared_blks_dirtied int8,
51+
OUT shared_blks_written int8,
52+
OUT local_blks_hit int8,
53+
OUT local_blks_read int8,
54+
OUT local_blks_dirtied int8,
55+
OUT local_blks_written int8,
56+
OUT temp_blks_read int8,
57+
OUT temp_blks_written int8,
58+
OUT blk_read_time float8,
59+
OUT blk_write_time float8,
60+
OUT wal_records int8,
61+
OUT wal_fpi int8,
62+
OUT wal_bytes numeric
63+
)
64+
RETURNS SETOF record
65+
AS 'MODULE_PATHNAME', 'pg_stat_statements_1_9'
66+
LANGUAGE C STRICT VOLATILE PARALLEL SAFE;
67+
68+
CREATE VIEW pg_stat_statements AS
69+
SELECT * FROM pg_stat_statements(true);
70+
71+
GRANT SELECT ON pg_stat_statements TO PUBLIC;

contrib/pg_stat_statements/pg_stat_statements--1.9--1.10.sql

Lines changed: 0 additions & 57 deletions
This file was deleted.

contrib/pg_stat_statements/pg_stat_statements.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ typedef enum pgssVersion
120120
PGSS_V1_2,
121121
PGSS_V1_3,
122122
PGSS_V1_8,
123-
PGSS_V1_10
123+
PGSS_V1_9
124124
} pgssVersion;
125125

126126
typedef enum pgssStoreKind
@@ -299,7 +299,7 @@ PG_FUNCTION_INFO_V1(pg_stat_statements_reset_1_7);
299299
PG_FUNCTION_INFO_V1(pg_stat_statements_1_2);
300300
PG_FUNCTION_INFO_V1(pg_stat_statements_1_3);
301301
PG_FUNCTION_INFO_V1(pg_stat_statements_1_8);
302-
PG_FUNCTION_INFO_V1(pg_stat_statements_1_10);
302+
PG_FUNCTION_INFO_V1(pg_stat_statements_1_9);
303303
PG_FUNCTION_INFO_V1(pg_stat_statements);
304304
PG_FUNCTION_INFO_V1(pg_stat_statements_info);
305305

@@ -1414,7 +1414,7 @@ pg_stat_statements_reset(PG_FUNCTION_ARGS)
14141414
#define PG_STAT_STATEMENTS_COLS_V1_2 19
14151415
#define PG_STAT_STATEMENTS_COLS_V1_3 23
14161416
#define PG_STAT_STATEMENTS_COLS_V1_8 32
1417-
#define PG_STAT_STATEMENTS_COLS_V1_10 33
1417+
#define PG_STAT_STATEMENTS_COLS_V1_9 33
14181418
#define PG_STAT_STATEMENTS_COLS 33 /* maximum of above */
14191419

14201420
/*
@@ -1428,11 +1428,11 @@ pg_stat_statements_reset(PG_FUNCTION_ARGS)
14281428
* function. Unfortunately we weren't bright enough to do that for 1.1.
14291429
*/
14301430
Datum
1431-
pg_stat_statements_1_10(PG_FUNCTION_ARGS)
1431+
pg_stat_statements_1_9(PG_FUNCTION_ARGS)
14321432
{
14331433
bool showtext = PG_GETARG_BOOL(0);
14341434

1435-
pg_stat_statements_internal(fcinfo, PGSS_V1_10, showtext);
1435+
pg_stat_statements_internal(fcinfo, PGSS_V1_9, showtext);
14361436

14371437
return (Datum) 0;
14381438
}
@@ -1556,8 +1556,8 @@ pg_stat_statements_internal(FunctionCallInfo fcinfo,
15561556
if (api_version != PGSS_V1_8)
15571557
elog(ERROR, "incorrect number of output arguments");
15581558
break;
1559-
case PG_STAT_STATEMENTS_COLS_V1_10:
1560-
if (api_version != PGSS_V1_10)
1559+
case PG_STAT_STATEMENTS_COLS_V1_9:
1560+
if (api_version != PGSS_V1_9)
15611561
elog(ERROR, "incorrect number of output arguments");
15621562
break;
15631563
default:
@@ -1651,7 +1651,7 @@ pg_stat_statements_internal(FunctionCallInfo fcinfo,
16511651

16521652
values[i++] = ObjectIdGetDatum(entry->key.userid);
16531653
values[i++] = ObjectIdGetDatum(entry->key.dbid);
1654-
if (api_version >= PGSS_V1_10)
1654+
if (api_version >= PGSS_V1_9)
16551655
values[i++] = BoolGetDatum(entry->key.toplevel);
16561656

16571657
if (is_allowed_role || entry->key.userid == userid)
@@ -1790,7 +1790,7 @@ pg_stat_statements_internal(FunctionCallInfo fcinfo,
17901790
api_version == PGSS_V1_2 ? PG_STAT_STATEMENTS_COLS_V1_2 :
17911791
api_version == PGSS_V1_3 ? PG_STAT_STATEMENTS_COLS_V1_3 :
17921792
api_version == PGSS_V1_8 ? PG_STAT_STATEMENTS_COLS_V1_8 :
1793-
api_version == PGSS_V1_10 ? PG_STAT_STATEMENTS_COLS_V1_10 :
1793+
api_version == PGSS_V1_9 ? PG_STAT_STATEMENTS_COLS_V1_9 :
17941794
-1 /* fail if you forget to update this assert */ ));
17951795

17961796
tuplestore_putvalues(tupstore, tupdesc, values, nulls);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# pg_stat_statements extension
22
comment = 'track planning and execution statistics of all SQL statements executed'
3-
default_version = '1.10'
3+
default_version = '1.9'
44
module_pathname = '$libdir/pg_stat_statements'
55
relocatable = true

0 commit comments

Comments
 (0)