Permalink
Browse files

v0.4.5 Updated show_running() to be compatible with 9.2. Makefile fix…

…. See CHANGELOG for more details.
  • Loading branch information...
1 parent e2cafa7 commit 39ef791e103c20af320723afc797dc15a23f332f @keithf4 keithf4 committed Nov 13, 2012
Showing with 126 additions and 8 deletions.
  1. +56 −0 CHANGELOG
  2. +2 −2 META.json
  3. +1 −0 Makefile
  4. +1 −1 pg_jobmon.control
  5. +22 −5 sql/functions/show_running.sql
  6. +44 −0 updates/pg_jobmon--0.4.4--0.4.5.sql
View
@@ -0,0 +1,56 @@
+0.4.5
+-- Updated show_running() function to be compatible with PostgreSQL 9.2
+-- Updated Makefile to allow setting of grep binary if needed during building.
+-- Created CHANGELOG file.
+
+
+0.4.4
+-- Update monitor function to handle procpid column name change to pid in pg_stat_activity
+
+
+0.4.3
+-- Added port column to dblink_mapping table to allow changing the default port.
+
+
+0.4.2
+-- No code changes to extension itself. Restructured sql file organization and modified Makefile to handle it accordingly.
+-- Did make the cancel_job test a little clearer on what to do in the testjob function.
+
+
+0.4.1
+-- Created job_log_clear() function to clear log data previous to a given interval. Logs it too!
+-- Fixed job_detail table to have ON DELETE CASCADE foreign key to make this function easier to write
+
+
+0.4.0
+-- Adds sql_job() and sql_step() functions for simple query logging.
+
+
+0.3.5
+-- Fixed check_job_status to use the end_time instead of the start_time in job_log to determine the last run of a job. Also more clearly lets you know if a job is blocked by an object lock
+
+
+0.3.4
+-- Make column names in job_status_text table more consistent with the check_job_status() function return column names.
+-- Fix check_job_status() returning extra spaces and ; in the alert_text when a job has failed
+-- Fix check_job_status() to use alert_text value for code 3 instead of hardcoded value 'CRITICAL'
+
+
+0.3.3
+-- See update sql file for important instructions.
+-- Turn off the dump of table data for the log tables. pg_dump isn't handling this properly and will dump all the data out for these tables even in a --schema-only dump.
+-- Data for other tables is minimal, and more critical, so not removing their dump settings.
+-- Data for these tables can be dumped if it's needed by temporarily removing the table from the extention and then adding it back.
+
+
+0.3.2
+-- Fixed bug in check_job_status result when all jobs were ok
+
+
+0.3.0
+IMPORTANT NOTE: Version 0.3.0 introduced backward incompatibilities and a direct upgrade is not possible. Please backup data tables and reinstall extension.
+All constraints were given specific names so future updates can more easily be done using the extension system.
+update_step() parameters have changed.
+close, fail and cancel functions can no longer take a custom config table. Was a nice idea but doesn't work as I'd hoped.
+job_alert_nagios table changed to job_status_text.
+job_detail elapsed_time column data type changed.
View
@@ -1,7 +1,7 @@
{
"name": "pg_jobmon",
"abstract": "Job logging and monitoring extension",
- "version": "0.4.4",
+ "version": "0.4.5",
"maintainer": [
"Keith Fiske <keith@omniti.com>"
],
@@ -20,7 +20,7 @@
"pg_jobmon": {
"file": "sql/pg_jobmon--0.4.4.sql",
"docfile": "doc/pg_jobmon.md",
- "version": "0.4.4",
+ "version": "0.4.5",
"abstract": "Job logging and monitoring extension"
}
},
View
@@ -1,6 +1,7 @@
EXTENSION = pg_jobmon
EXTVERSION = $(shell grep default_version $(EXTENSION).control | \
sed -e "s/default_version[[:space:]]*=[[:space:]]*'\([^']*\)'/\1/")
+GREP ?= grep
DATA = $(filter-out $(wildcard sql/*--*.sql),$(wildcard sql/*.sql))
DOCS = $(wildcard doc/*.md)
View
@@ -1,4 +1,4 @@
-default_version = '0.4.4'
+default_version = '0.4.5'
comment = 'Extension for logging and monitoring jobs in PostgreSQL'
requires = dblink
relocatable = false
@@ -1,22 +1,39 @@
/*
* Show Currently Running Jobs
*/
-CREATE FUNCTION show_running(int default 10) RETURNS SETOF @extschema@.job_log
+CREATE OR REPLACE FUNCTION show_running(int default 10) RETURNS SETOF @extschema@.job_log
LANGUAGE plpgsql
AS $$
DECLARE
v_job_list @extschema@.job_log%ROWTYPE;
+ v_version int;
BEGIN
- FOR v_job_list IN SELECT job_id, owner, job_name, start_time, end_time, status, pid
+
+SELECT current_setting('server_version_num')::int INTO v_version;
+
+IF v_version >= 90200 THEN
+ FOR v_job_list IN SELECT j.job_id, j.owner, j.job_name, j.start_time, j.end_time, j.status, j.pid
+ FROM @extschema@.job_log j
+ JOIN pg_stat_activity p ON j.pid = p.pid
+ WHERE j.status IS NULL
+ ORDER BY j.job_id DESC
+ LIMIT $1
+ LOOP
+ RETURN NEXT v_job_list;
+ END LOOP;
+ELSE
+ FOR v_job_list IN SELECT j.job_id, j.owner, j.job_name, j.start_time, j.end_time, j.status, j.pid
FROM @extschema@.job_log j
JOIN pg_stat_activity p ON j.pid = p.procpid
- WHERE status IS NULL
- ORDER BY job_id DESC
+ WHERE j.status IS NULL
+ ORDER BY j.job_id DESC
LIMIT $1
LOOP
RETURN NEXT v_job_list;
END LOOP;
+END IF;
+
+RETURN;
- RETURN;
END
$$;
@@ -0,0 +1,44 @@
+-- Updated show_running() function to be compatible with PostgreSQL 9.2
+-- Updated Makefile to allow setting of grep binary if needed during building.
+-- Created CHANGELOG file.
+
+
+/*
+ * Show Currently Running Jobs
+ */
+CREATE OR REPLACE FUNCTION show_running(int default 10) RETURNS SETOF @extschema@.job_log
+ LANGUAGE plpgsql
+ AS $$
+DECLARE
+ v_job_list @extschema@.job_log%ROWTYPE;
+ v_version int;
+BEGIN
+
+SELECT current_setting('server_version_num')::int INTO v_version;
+
+IF v_version >= 90200 THEN
+ FOR v_job_list IN SELECT j.job_id, j.owner, j.job_name, j.start_time, j.end_time, j.status, j.pid
+ FROM @extschema@.job_log j
+ JOIN pg_stat_activity p ON j.pid = p.pid
+ WHERE j.status IS NULL
+ ORDER BY j.job_id DESC
+ LIMIT $1
+ LOOP
+ RETURN NEXT v_job_list;
+ END LOOP;
+ELSE
+ FOR v_job_list IN SELECT j.job_id, j.owner, j.job_name, j.start_time, j.end_time, j.status, j.pid
+ FROM @extschema@.job_log j
+ JOIN pg_stat_activity p ON j.pid = p.procpid
+ WHERE j.status IS NULL
+ ORDER BY j.job_id DESC
+ LIMIT $1
+ LOOP
+ RETURN NEXT v_job_list;
+ END LOOP;
+END IF;
+
+RETURN;
+
+END
+$$;

0 comments on commit 39ef791

Please sign in to comment.