diff --git a/META.json b/META.json index d3608fa..5998820 100644 --- a/META.json +++ b/META.json @@ -2,7 +2,7 @@ "name": "plpgsql_check", "abstract": "Additional tools for plpgsql functions validation", "description": "The plpgsql_check is PostgreSQL extension with functionality for direct or indirect extra validation of functions in plpgsql language. It verifies a validity of SQL identifiers used in plpgsql code. It try to identify a performance issues. Modern versions has integrated profiler. The table and function dependencies can be displayed", - "version": "1.15.0", + "version": "1.15.1", "maintainer": "Pavel STEHULE ", "license": "bsd", "provides": { @@ -10,7 +10,7 @@ "abstract": "Additional tools for plpgsql functions validation", "file": "sql/plpgsql_check_active.sql", "docfile": "README.md", - "version": "1.15.0" + "version": "1.15.1" } }, "prereqs": { diff --git a/plpgsql_check--1.15.sql b/plpgsql_check--1.15.sql new file mode 100644 index 0000000..f0754c5 --- /dev/null +++ b/plpgsql_check--1.15.sql @@ -0,0 +1,242 @@ +-- complain if script is sourced in psql, rather than via CREATE EXTENSION +\echo Use "CREATE EXTENSION plpgsql_check" to load this file. \quit + +CREATE FUNCTION plpgsql_check_function_tb(funcoid regprocedure, + relid regclass DEFAULT 0, + fatal_errors boolean DEFAULT true, + other_warnings boolean DEFAULT true, + performance_warnings boolean DEFAULT false, + extra_warnings boolean DEFAULT true, + security_warnings boolean DEFAULT false, + oldtable name DEFAULT null, + newtable name DEFAULT null, + anyelememttype regtype DEFAULT 'int', + anyenumtype regtype DEFAULT '-', + anyrangetype regtype DEFAULT 'int4range', + anycompatibletype regtype DEFAULT 'int', + anycompatiblerangetype regtype DEFAULT 'int4range', + without_warnings boolean DEFAULT false, + all_warnings boolean DEFAULT false) +RETURNS TABLE(functionid regproc, + lineno int, + statement text, + sqlstate text, + message text, + detail text, + hint text, + level text, + "position" int, + query text, + context text) +AS 'MODULE_PATHNAME','plpgsql_check_function_tb' +LANGUAGE C; + +CREATE FUNCTION plpgsql_check_function(funcoid regprocedure, + relid regclass DEFAULT 0, + format text DEFAULT 'text', + fatal_errors boolean DEFAULT true, + other_warnings boolean DEFAULT true, + performance_warnings boolean DEFAULT false, + extra_warnings boolean DEFAULT true, + security_warnings boolean DEFAULT false, + oldtable name DEFAULT null, + newtable name DEFAULT null, + anyelememttype regtype DEFAULT 'int', + anyenumtype regtype DEFAULT '-', + anyrangetype regtype DEFAULT 'int4range', + anycompatibletype regtype DEFAULT 'int', + anycompatiblerangetype regtype DEFAULT 'int4range', + without_warnings boolean DEFAULT false, + all_warnings boolean DEFAULT false) +RETURNS SETOF text +AS 'MODULE_PATHNAME','plpgsql_check_function' +LANGUAGE C; + +CREATE FUNCTION plpgsql_check_function_tb(name text, + relid regclass DEFAULT 0, + fatal_errors boolean DEFAULT true, + other_warnings boolean DEFAULT true, + performance_warnings boolean DEFAULT false, + extra_warnings boolean DEFAULT true, + security_warnings boolean DEFAULT false, + oldtable name DEFAULT null, + newtable name DEFAULT null, + anyelememttype regtype DEFAULT 'int', + anyenumtype regtype DEFAULT '-', + anyrangetype regtype DEFAULT 'int4range', + anycompatibletype regtype DEFAULT 'int', + anycompatiblerangetype regtype DEFAULT 'int4range', + without_warnings boolean DEFAULT false, + all_warnings boolean DEFAULT false) +RETURNS TABLE(functionid regproc, + lineno int, + statement text, + sqlstate text, + message text, + detail text, + hint text, + level text, + "position" int, + query text, + context text) +AS 'MODULE_PATHNAME','plpgsql_check_function_tb_name' +LANGUAGE C; + +CREATE FUNCTION plpgsql_check_function(name text, + relid regclass DEFAULT 0, + format text DEFAULT 'text', + fatal_errors boolean DEFAULT true, + other_warnings boolean DEFAULT true, + performance_warnings boolean DEFAULT false, + extra_warnings boolean DEFAULT true, + security_warnings boolean DEFAULT false, + oldtable name DEFAULT null, + newtable name DEFAULT null, + anyelememttype regtype DEFAULT 'int', + anyenumtype regtype DEFAULT '-', + anyrangetype regtype DEFAULT 'int4range', + anycompatibletype regtype DEFAULT 'int', + anycompatiblerangetype regtype DEFAULT 'int4range', + without_warnings boolean DEFAULT false, + all_warnings boolean DEFAULT false) +RETURNS SETOF text +AS 'MODULE_PATHNAME','plpgsql_check_function_name' +LANGUAGE C; + +CREATE FUNCTION __plpgsql_show_dependency_tb(funcoid regprocedure, relid regclass DEFAULT 0) +RETURNS TABLE(type text, + oid oid, + schema text, + name text, + params text) +AS 'MODULE_PATHNAME','plpgsql_show_dependency_tb' +LANGUAGE C STRICT; + +CREATE FUNCTION __plpgsql_show_dependency_tb(name text, relid regclass DEFAULT 0) +RETURNS TABLE(type text, + oid oid, + schema text, + name text, + params text) +AS 'MODULE_PATHNAME','plpgsql_show_dependency_tb_name' +LANGUAGE C STRICT; + +CREATE FUNCTION plpgsql_show_dependency_tb(funcoid regprocedure, relid regclass DEFAULT 0) +RETURNS TABLE(type text, + oid oid, + schema text, + name text, + params text) +AS $$ + SELECT * + FROM @extschema@.__plpgsql_show_dependency_tb($1, $2) + ORDER BY 1, 3, 4; +$$ LANGUAGE sql; + +CREATE FUNCTION plpgsql_show_dependency_tb(fnname text, relid regclass DEFAULT 0) +RETURNS TABLE(type text, + oid oid, + schema text, + name text, + params text) +AS $$ + SELECT * + FROM @extschema@.__plpgsql_show_dependency_tb($1, $2) + ORDER BY 1, 3, 4; +$$ LANGUAGE sql; + +CREATE FUNCTION plpgsql_profiler_function_tb(funcoid regprocedure) +RETURNS TABLE(lineno int, + stmt_lineno int, + queryids int8[], + cmds_on_row int, + exec_stmts int8, + total_time double precision, + avg_time double precision, + max_time double precision[], + processed_rows int8[], + source text) +AS 'MODULE_PATHNAME','plpgsql_profiler_function_tb' +LANGUAGE C STRICT; + +CREATE FUNCTION plpgsql_profiler_function_tb(name text) +RETURNS TABLE(lineno int, + stmt_lineno int, + queryids int8[], + cmds_on_row int, + exec_stmts int8, + total_time double precision, + avg_time double precision, + max_time double precision[], + processed_rows int8[], + source text) +AS 'MODULE_PATHNAME','plpgsql_profiler_function_tb_name' +LANGUAGE C STRICT; + +CREATE FUNCTION plpgsql_profiler_function_statements_tb(funcoid regprocedure) +RETURNS TABLE(stmtid int, + parent_stmtid int, + parent_note text, + block_num int, + lineno int, + queryid int8, + exec_stmts int8, + total_time double precision, + avg_time double precision, + max_time double precision, + processed_rows int8, + stmtname text) +AS 'MODULE_PATHNAME','plpgsql_profiler_function_statements_tb' +LANGUAGE C STRICT; + +CREATE FUNCTION plpgsql_profiler_function_statements_tb(name text) +RETURNS TABLE(stmtid int, + parent_stmtid int, + parent_note text, + block_num int, + lineno int, + queryid int8, + exec_stmts int8, + total_time double precision, + avg_time double precision, + max_time double precision, + processed_rows int8, + stmtname text) +AS 'MODULE_PATHNAME','plpgsql_profiler_function_statements_tb_name' +LANGUAGE C STRICT; + +CREATE FUNCTION plpgsql_profiler_install_fake_queryid_hook() +RETURNS void AS 'MODULE_PATHNAME','plpgsql_profiler_install_fake_queryid_hook' +LANGUAGE C STRICT; + +CREATE FUNCTION plpgsql_profiler_remove_fake_queryid_hook() +RETURNS void AS 'MODULE_PATHNAME','plpgsql_profiler_remove_fake_queryid_hook' +LANGUAGE C STRICT; + +CREATE FUNCTION plpgsql_profiler_reset_all() +RETURNS void AS 'MODULE_PATHNAME','plpgsql_profiler_reset_all' +LANGUAGE C STRICT; + +CREATE FUNCTION plpgsql_profiler_reset(funcoid regprocedure) +RETURNS void AS 'MODULE_PATHNAME','plpgsql_profiler_reset' +LANGUAGE C STRICT; + +CREATE OR REPLACE FUNCTION plpgsql_coverage_statements(funcoid regprocedure) +RETURNS double precision AS 'MODULE_PATHNAME', 'plpgsql_coverage_statements' +LANGUAGE C; + +CREATE OR REPLACE FUNCTION plpgsql_coverage_statements(name text) +RETURNS double precision AS 'MODULE_PATHNAME', 'plpgsql_coverage_statements_name' +LANGUAGE C; + +CREATE OR REPLACE FUNCTION plpgsql_coverage_branches(funcoid regprocedure) +RETURNS double precision AS 'MODULE_PATHNAME', 'plpgsql_coverage_branches' +LANGUAGE C; + +CREATE OR REPLACE FUNCTION plpgsql_coverage_branches(name text) +RETURNS double precision AS 'MODULE_PATHNAME', 'plpgsql_coverage_branches_name' +LANGUAGE C; + +CREATE OR REPLACE FUNCTION plpgsql_check_pragma(VARIADIC name text[]) +RETURNS integer AS 'MODULE_PATHNAME', 'plpgsql_check_pragma' +LANGUAGE C VOLATILE; diff --git a/postgresql10-plpgsql_check.spec b/postgresql10-plpgsql_check.spec index ce6a7aa..b3b7d8d 100644 --- a/postgresql10-plpgsql_check.spec +++ b/postgresql10-plpgsql_check.spec @@ -3,7 +3,7 @@ %global sname plpgsql_check Name: %{sname}_%{pgmajorversion} -Version: 1.15.0 +Version: 1.15.1 Release: 1%{?dist} Summary: Additional tools for plpgsql functions validation diff --git a/postgresql11-plpgsql_check.spec b/postgresql11-plpgsql_check.spec index a362d1d..23f5943 100644 --- a/postgresql11-plpgsql_check.spec +++ b/postgresql11-plpgsql_check.spec @@ -3,7 +3,7 @@ %global sname plpgsql_check Name: %{sname}_%{pgmajorversion} -Version: 1.15.0 +Version: 1.15.1 Release: 1%{?dist} Summary: Additional tools for plpgsql functions validation diff --git a/postgresql12-plpgsql_check.spec b/postgresql12-plpgsql_check.spec index b3f65a4..cb405da 100644 --- a/postgresql12-plpgsql_check.spec +++ b/postgresql12-plpgsql_check.spec @@ -3,7 +3,7 @@ %global sname plpgsql_check Name: %{sname}_%{pgmajorversion} -Version: 1.15.0 +Version: 1.15.1 Release: 1%{?dist} Summary: Additional tools for plpgsql functions validation diff --git a/postgresql13-plpgsql_check.spec b/postgresql13-plpgsql_check.spec index 4f45738..6df3d13 100644 --- a/postgresql13-plpgsql_check.spec +++ b/postgresql13-plpgsql_check.spec @@ -3,7 +3,7 @@ %global sname plpgsql_check Name: %{sname}_%{pgmajorversion} -Version: 1.15.0 +Version: 1.15.1 Release: 1%{?dist} Summary: Additional tools for plpgsql functions validation diff --git a/postgresql14-plpgsql_check.spec b/postgresql14-plpgsql_check.spec index 4f45738..6df3d13 100644 --- a/postgresql14-plpgsql_check.spec +++ b/postgresql14-plpgsql_check.spec @@ -3,7 +3,7 @@ %global sname plpgsql_check Name: %{sname}_%{pgmajorversion} -Version: 1.15.0 +Version: 1.15.1 Release: 1%{?dist} Summary: Additional tools for plpgsql functions validation diff --git a/postgresql95-plpgsql_check.spec b/postgresql95-plpgsql_check.spec index 9652da6..1ddca97 100644 --- a/postgresql95-plpgsql_check.spec +++ b/postgresql95-plpgsql_check.spec @@ -3,7 +3,7 @@ %global sname plpgsql_check Name: %{sname}_%{pgmajorversion} -Version: 1.15.0 +Version: 1.15.1 Release: 1%{?dist} Summary: Additional tools for plpgsql functions validation diff --git a/postgresql96-plpgsql_check.spec b/postgresql96-plpgsql_check.spec index 8da6342..7aebb9c 100644 --- a/postgresql96-plpgsql_check.spec +++ b/postgresql96-plpgsql_check.spec @@ -3,7 +3,7 @@ %global sname plpgsql_check Name: %{sname}_%{pgmajorversion} -Version: 1.15.0 +Version: 1.15.1 Release: 1%{?dist} Summary: Additional tools for plpgsql functions validation