Skip to content

Commit

Permalink
Merge pull request citusdata#2505 from citusdata/fix_stat_statements_…
Browse files Browse the repository at this point in the history
…view

Fix citus_stat_statements view
  • Loading branch information
mtuncer authored Nov 29, 2018
2 parents a378a11 + fd868ec commit cc2422e
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 3 deletions.
2 changes: 1 addition & 1 deletion citus.control
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Citus extension
comment = 'Citus distributed database'
default_version = '8.0-11'
default_version = '8.0-12'
module_pathname = '$libdir/citus'
relocatable = false
schema = pg_catalog
4 changes: 3 additions & 1 deletion src/backend/distributed/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ EXTVERSIONS = 5.0 5.0-1 5.0-2 \
7.3-1 7.3-2 7.3-3 \
7.4-1 7.4-2 7.4-3 \
7.5-1 7.5-2 7.5-3 7.5-4 7.5-5 7.5-6 7.5-7 \
8.0-1 8.0-2 8.0-3 8.0-4 8.0-5 8.0-6 8.0-7 8.0-8 8.0-9 8.0-10 8.0-11
8.0-1 8.0-2 8.0-3 8.0-4 8.0-5 8.0-6 8.0-7 8.0-8 8.0-9 8.0-10 8.0-11 8.0-12

# All citus--*.sql files in the source directory
DATA = $(patsubst $(citus_abs_srcdir)/%.sql,%.sql,$(wildcard $(citus_abs_srcdir)/$(EXTENSION)--*--*.sql))
Expand Down Expand Up @@ -237,6 +237,8 @@ $(EXTENSION)--8.0-10.sql: $(EXTENSION)--8.0-9.sql $(EXTENSION)--8.0-9--8.0-10.sq
cat $^ > $@
$(EXTENSION)--8.0-11.sql: $(EXTENSION)--8.0-10.sql $(EXTENSION)--8.0-10--8.0-11.sql
cat $^ > $@
$(EXTENSION)--8.0-12.sql: $(EXTENSION)--8.0-11.sql $(EXTENSION)--8.0-11--8.0-12.sql
cat $^ > $@

NO_PGXS = 1

Expand Down
31 changes: 31 additions & 0 deletions src/backend/distributed/citus--8.0-11--8.0-12.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* citus--8.0-11--8.0-12 */
SET search_path = 'pg_catalog';

CREATE OR REPLACE FUNCTION pg_catalog.citus_stat_statements(OUT queryid bigint,
OUT userid oid,
OUT dbid oid,
OUT query text,
OUT executor bigint,
OUT partition_key text,
OUT calls bigint)
RETURNS SETOF record
LANGUAGE plpgsql
AS $citus_stat_statements$
BEGIN
IF EXISTS (
SELECT extname FROM pg_extension
WHERE extname = 'pg_stat_statements')
THEN
RETURN QUERY SELECT pss.queryid, pss.userid, pss.dbid, pss.query, cqs.executor,
cqs.partition_key, cqs.calls
FROM pg_stat_statements(true) pss
JOIN citus_query_stats() cqs
USING (queryid, userid, dbid);
ELSE
RAISE EXCEPTION 'pg_stat_statements is not installed'
USING HINT = 'install pg_stat_statements extension and try again';
END IF;
END;
$citus_stat_statements$;

RESET search_path;
2 changes: 1 addition & 1 deletion src/backend/distributed/citus.control
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Citus extension
comment = 'Citus distributed database'
default_version = '8.0-11'
default_version = '8.0-12'
module_pathname = '$libdir/citus'
relocatable = false
schema = pg_catalog
1 change: 1 addition & 0 deletions src/test/regress/expected/multi_extension.out
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ ALTER EXTENSION citus UPDATE TO '8.0-8';
ALTER EXTENSION citus UPDATE TO '8.0-9';
ALTER EXTENSION citus UPDATE TO '8.0-10';
ALTER EXTENSION citus UPDATE TO '8.0-11';
ALTER EXTENSION citus UPDATE TO '8.0-12';
-- show running version
SHOW citus.version;
citus.version
Expand Down
1 change: 1 addition & 0 deletions src/test/regress/sql/multi_extension.sql
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ ALTER EXTENSION citus UPDATE TO '8.0-8';
ALTER EXTENSION citus UPDATE TO '8.0-9';
ALTER EXTENSION citus UPDATE TO '8.0-10';
ALTER EXTENSION citus UPDATE TO '8.0-11';
ALTER EXTENSION citus UPDATE TO '8.0-12';

-- show running version
SHOW citus.version;
Expand Down

0 comments on commit cc2422e

Please sign in to comment.