|
| 1 | +-- complain if script is sourced in psql, rather than via CREATE EXTENSION |
| 2 | +\echo Use "CREATE EXTENSION plpgsql_check" to load this file. \quit |
| 3 | + |
| 4 | +CREATE FUNCTION plpgsql_check_function_tb(funcoid regprocedure, |
| 5 | + relid regclass DEFAULT 0, |
| 6 | + fatal_errors boolean DEFAULT true, |
| 7 | + other_warnings boolean DEFAULT true, |
| 8 | + performance_warnings boolean DEFAULT false, |
| 9 | + extra_warnings boolean DEFAULT true, |
| 10 | + security_warnings boolean DEFAULT false, |
| 11 | + oldtable name DEFAULT null, |
| 12 | + newtable name DEFAULT null, |
| 13 | + anyelememttype regtype DEFAULT 'int', |
| 14 | + anyenumtype regtype DEFAULT '-', |
| 15 | + anyrangetype regtype DEFAULT 'int4range', |
| 16 | + anycompatibletype regtype DEFAULT 'int', |
| 17 | + anycompatiblerangetype regtype DEFAULT 'int4range', |
| 18 | + without_warnings boolean DEFAULT false, |
| 19 | + all_warnings boolean DEFAULT false, |
| 20 | + use_incomment_options boolean DEFAULT true, |
| 21 | + incomment_options_usage_warning boolean DEFAULT false) |
| 22 | +RETURNS TABLE(functionid regproc, |
| 23 | + lineno int, |
| 24 | + statement text, |
| 25 | + sqlstate text, |
| 26 | + message text, |
| 27 | + detail text, |
| 28 | + hint text, |
| 29 | + level text, |
| 30 | + "position" int, |
| 31 | + query text, |
| 32 | + context text) |
| 33 | +AS 'MODULE_PATHNAME','plpgsql_check_function_tb' |
| 34 | +LANGUAGE C; |
| 35 | + |
| 36 | +CREATE FUNCTION plpgsql_check_function(funcoid regprocedure, |
| 37 | + relid regclass DEFAULT 0, |
| 38 | + format text DEFAULT 'text', |
| 39 | + fatal_errors boolean DEFAULT true, |
| 40 | + other_warnings boolean DEFAULT true, |
| 41 | + performance_warnings boolean DEFAULT false, |
| 42 | + extra_warnings boolean DEFAULT true, |
| 43 | + security_warnings boolean DEFAULT false, |
| 44 | + oldtable name DEFAULT null, |
| 45 | + newtable name DEFAULT null, |
| 46 | + anyelememttype regtype DEFAULT 'int', |
| 47 | + anyenumtype regtype DEFAULT '-', |
| 48 | + anyrangetype regtype DEFAULT 'int4range', |
| 49 | + anycompatibletype regtype DEFAULT 'int', |
| 50 | + anycompatiblerangetype regtype DEFAULT 'int4range', |
| 51 | + without_warnings boolean DEFAULT false, |
| 52 | + all_warnings boolean DEFAULT false, |
| 53 | + use_incomment_options boolean DEFAULT true, |
| 54 | + incomment_options_usage_warning boolean DEFAULT false) |
| 55 | +RETURNS SETOF text |
| 56 | +AS 'MODULE_PATHNAME','plpgsql_check_function' |
| 57 | +LANGUAGE C; |
| 58 | + |
| 59 | +CREATE FUNCTION plpgsql_check_function_tb(name text, |
| 60 | + relid regclass DEFAULT 0, |
| 61 | + fatal_errors boolean DEFAULT true, |
| 62 | + other_warnings boolean DEFAULT true, |
| 63 | + performance_warnings boolean DEFAULT false, |
| 64 | + extra_warnings boolean DEFAULT true, |
| 65 | + security_warnings boolean DEFAULT false, |
| 66 | + oldtable name DEFAULT null, |
| 67 | + newtable name DEFAULT null, |
| 68 | + anyelememttype regtype DEFAULT 'int', |
| 69 | + anyenumtype regtype DEFAULT '-', |
| 70 | + anyrangetype regtype DEFAULT 'int4range', |
| 71 | + anycompatibletype regtype DEFAULT 'int', |
| 72 | + anycompatiblerangetype regtype DEFAULT 'int4range', |
| 73 | + without_warnings boolean DEFAULT false, |
| 74 | + all_warnings boolean DEFAULT false, |
| 75 | + use_incomment_options boolean DEFAULT true, |
| 76 | + incomment_options_usage_warning boolean DEFAULT false) |
| 77 | +RETURNS TABLE(functionid regproc, |
| 78 | + lineno int, |
| 79 | + statement text, |
| 80 | + sqlstate text, |
| 81 | + message text, |
| 82 | + detail text, |
| 83 | + hint text, |
| 84 | + level text, |
| 85 | + "position" int, |
| 86 | + query text, |
| 87 | + context text) |
| 88 | +AS 'MODULE_PATHNAME','plpgsql_check_function_tb_name' |
| 89 | +LANGUAGE C; |
| 90 | + |
| 91 | +CREATE FUNCTION plpgsql_check_function(name text, |
| 92 | + relid regclass DEFAULT 0, |
| 93 | + format text DEFAULT 'text', |
| 94 | + fatal_errors boolean DEFAULT true, |
| 95 | + other_warnings boolean DEFAULT true, |
| 96 | + performance_warnings boolean DEFAULT false, |
| 97 | + extra_warnings boolean DEFAULT true, |
| 98 | + security_warnings boolean DEFAULT false, |
| 99 | + oldtable name DEFAULT null, |
| 100 | + newtable name DEFAULT null, |
| 101 | + anyelememttype regtype DEFAULT 'int', |
| 102 | + anyenumtype regtype DEFAULT '-', |
| 103 | + anyrangetype regtype DEFAULT 'int4range', |
| 104 | + anycompatibletype regtype DEFAULT 'int', |
| 105 | + anycompatiblerangetype regtype DEFAULT 'int4range', |
| 106 | + without_warnings boolean DEFAULT false, |
| 107 | + all_warnings boolean DEFAULT false, |
| 108 | + use_incomment_options boolean DEFAULT true, |
| 109 | + incomment_options_usage_warning boolean DEFAULT false) |
| 110 | +RETURNS SETOF text |
| 111 | +AS 'MODULE_PATHNAME','plpgsql_check_function_name' |
| 112 | +LANGUAGE C; |
| 113 | + |
| 114 | +CREATE FUNCTION __plpgsql_show_dependency_tb(funcoid regprocedure, relid regclass DEFAULT 0) |
| 115 | +RETURNS TABLE(type text, |
| 116 | + oid oid, |
| 117 | + schema text, |
| 118 | + name text, |
| 119 | + params text) |
| 120 | +AS 'MODULE_PATHNAME','plpgsql_show_dependency_tb' |
| 121 | +LANGUAGE C STRICT; |
| 122 | + |
| 123 | +CREATE FUNCTION __plpgsql_show_dependency_tb(name text, relid regclass DEFAULT 0) |
| 124 | +RETURNS TABLE(type text, |
| 125 | + oid oid, |
| 126 | + schema text, |
| 127 | + name text, |
| 128 | + params text) |
| 129 | +AS 'MODULE_PATHNAME','plpgsql_show_dependency_tb_name' |
| 130 | +LANGUAGE C STRICT; |
| 131 | + |
| 132 | +CREATE FUNCTION plpgsql_show_dependency_tb(funcoid regprocedure, relid regclass DEFAULT 0) |
| 133 | +RETURNS TABLE(type text, |
| 134 | + oid oid, |
| 135 | + schema text, |
| 136 | + name text, |
| 137 | + params text) |
| 138 | +AS $$ |
| 139 | + SELECT * |
| 140 | + FROM @extschema@.__plpgsql_show_dependency_tb($1, $2) |
| 141 | + ORDER BY 1, 3, 4; |
| 142 | +$$ LANGUAGE sql; |
| 143 | + |
| 144 | +CREATE FUNCTION plpgsql_show_dependency_tb(fnname text, relid regclass DEFAULT 0) |
| 145 | +RETURNS TABLE(type text, |
| 146 | + oid oid, |
| 147 | + schema text, |
| 148 | + name text, |
| 149 | + params text) |
| 150 | +AS $$ |
| 151 | + SELECT * |
| 152 | + FROM @extschema@.__plpgsql_show_dependency_tb($1, $2) |
| 153 | + ORDER BY 1, 3, 4; |
| 154 | +$$ LANGUAGE sql; |
| 155 | + |
| 156 | +CREATE FUNCTION plpgsql_profiler_function_tb(funcoid regprocedure) |
| 157 | +RETURNS TABLE(lineno int, |
| 158 | + stmt_lineno int, |
| 159 | + queryids int8[], |
| 160 | + cmds_on_row int, |
| 161 | + exec_stmts int8, |
| 162 | + exec_stmts_err int8, |
| 163 | + total_time double precision, |
| 164 | + avg_time double precision, |
| 165 | + max_time double precision[], |
| 166 | + processed_rows int8[], |
| 167 | + source text) |
| 168 | +AS 'MODULE_PATHNAME','plpgsql_profiler_function_tb' |
| 169 | +LANGUAGE C STRICT; |
| 170 | + |
| 171 | +CREATE FUNCTION plpgsql_profiler_function_tb(name text) |
| 172 | +RETURNS TABLE(lineno int, |
| 173 | + stmt_lineno int, |
| 174 | + queryids int8[], |
| 175 | + cmds_on_row int, |
| 176 | + exec_stmts int8, |
| 177 | + exec_stmts_err int8, |
| 178 | + total_time double precision, |
| 179 | + avg_time double precision, |
| 180 | + max_time double precision[], |
| 181 | + processed_rows int8[], |
| 182 | + source text) |
| 183 | +AS 'MODULE_PATHNAME','plpgsql_profiler_function_tb_name' |
| 184 | +LANGUAGE C STRICT; |
| 185 | + |
| 186 | +CREATE FUNCTION plpgsql_profiler_function_statements_tb(funcoid regprocedure) |
| 187 | +RETURNS TABLE(stmtid int, |
| 188 | + parent_stmtid int, |
| 189 | + parent_note text, |
| 190 | + block_num int, |
| 191 | + lineno int, |
| 192 | + queryid int8, |
| 193 | + exec_stmts int8, |
| 194 | + exec_stmts_err int8, |
| 195 | + total_time double precision, |
| 196 | + avg_time double precision, |
| 197 | + max_time double precision, |
| 198 | + processed_rows int8, |
| 199 | + stmtname text) |
| 200 | +AS 'MODULE_PATHNAME','plpgsql_profiler_function_statements_tb' |
| 201 | +LANGUAGE C STRICT; |
| 202 | + |
| 203 | +CREATE FUNCTION plpgsql_profiler_function_statements_tb(name text) |
| 204 | +RETURNS TABLE(stmtid int, |
| 205 | + parent_stmtid int, |
| 206 | + parent_note text, |
| 207 | + block_num int, |
| 208 | + lineno int, |
| 209 | + queryid int8, |
| 210 | + exec_stmts int8, |
| 211 | + exec_stmts_err int8, |
| 212 | + total_time double precision, |
| 213 | + avg_time double precision, |
| 214 | + max_time double precision, |
| 215 | + processed_rows int8, |
| 216 | + stmtname text) |
| 217 | +AS 'MODULE_PATHNAME','plpgsql_profiler_function_statements_tb_name' |
| 218 | +LANGUAGE C STRICT; |
| 219 | + |
| 220 | +CREATE FUNCTION plpgsql_profiler_install_fake_queryid_hook() |
| 221 | +RETURNS void AS 'MODULE_PATHNAME','plpgsql_profiler_install_fake_queryid_hook' |
| 222 | +LANGUAGE C STRICT; |
| 223 | + |
| 224 | +CREATE FUNCTION plpgsql_profiler_remove_fake_queryid_hook() |
| 225 | +RETURNS void AS 'MODULE_PATHNAME','plpgsql_profiler_remove_fake_queryid_hook' |
| 226 | +LANGUAGE C STRICT; |
| 227 | + |
| 228 | +CREATE FUNCTION plpgsql_profiler_reset_all() |
| 229 | +RETURNS void AS 'MODULE_PATHNAME','plpgsql_profiler_reset_all' |
| 230 | +LANGUAGE C STRICT; |
| 231 | + |
| 232 | +CREATE FUNCTION plpgsql_profiler_reset(funcoid regprocedure) |
| 233 | +RETURNS void AS 'MODULE_PATHNAME','plpgsql_profiler_reset' |
| 234 | +LANGUAGE C STRICT; |
| 235 | + |
| 236 | +CREATE OR REPLACE FUNCTION plpgsql_coverage_statements(funcoid regprocedure) |
| 237 | +RETURNS double precision AS 'MODULE_PATHNAME', 'plpgsql_coverage_statements' |
| 238 | +LANGUAGE C; |
| 239 | + |
| 240 | +CREATE OR REPLACE FUNCTION plpgsql_coverage_statements(name text) |
| 241 | +RETURNS double precision AS 'MODULE_PATHNAME', 'plpgsql_coverage_statements_name' |
| 242 | +LANGUAGE C; |
| 243 | + |
| 244 | +CREATE OR REPLACE FUNCTION plpgsql_coverage_branches(funcoid regprocedure) |
| 245 | +RETURNS double precision AS 'MODULE_PATHNAME', 'plpgsql_coverage_branches' |
| 246 | +LANGUAGE C; |
| 247 | + |
| 248 | +CREATE OR REPLACE FUNCTION plpgsql_coverage_branches(name text) |
| 249 | +RETURNS double precision AS 'MODULE_PATHNAME', 'plpgsql_coverage_branches_name' |
| 250 | +LANGUAGE C; |
| 251 | + |
| 252 | +CREATE OR REPLACE FUNCTION plpgsql_check_pragma(VARIADIC name text[]) |
| 253 | +RETURNS integer AS 'MODULE_PATHNAME', 'plpgsql_check_pragma' |
| 254 | +LANGUAGE C VOLATILE; |
| 255 | + |
| 256 | +CREATE OR REPLACE FUNCTION plpgsql_profiler_functions_all() |
| 257 | +RETURNS TABLE(funcoid regprocedure, |
| 258 | + exec_count int8, |
| 259 | + exec_stmts_err int8, |
| 260 | + total_time double precision, |
| 261 | + avg_time double precision, |
| 262 | + stddev_time double precision, |
| 263 | + min_time double precision, |
| 264 | + max_time double precision) |
| 265 | +AS 'MODULE_PATHNAME','plpgsql_profiler_functions_all_tb' |
| 266 | +LANGUAGE C STRICT; |
0 commit comments