-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from Dakotah312/master
Adding host name support
- Loading branch information
Showing
7 changed files
with
73 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"name": "pg_jobmon", | ||
"abstract": "Job logging and monitoring extension", | ||
"version": "1.4.1", | ||
"version": "1.5.0", | ||
"maintainer": [ | ||
"Robert Treat <[email protected]>", | ||
"Keith Fiske <[email protected]>" | ||
|
@@ -19,9 +19,9 @@ | |
}, | ||
"provides": { | ||
"pg_jobmon": { | ||
"file": "sql/pg_jobmon--1.4.1.sql", | ||
"file": "sql/pg_jobmon--1.5.0.sql", | ||
"docfile": "doc/pg_jobmon.md", | ||
"version": "1.4.1", | ||
"version": "1.5.0", | ||
"abstract": "Job logging and monitoring extension" | ||
} | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
default_version = '1.4.1' | ||
default_version = '1.5.0' | ||
comment = 'Extension for logging and monitoring functions in PostgreSQL' | ||
requires = dblink | ||
relocatable = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,12 +11,13 @@ DECLARE | |
v_password text; | ||
v_username text; | ||
v_host text; | ||
v_hostaddr text; | ||
|
||
BEGIN | ||
-- Ensure only one row is returned. No rows is fine, but this was the only way to force one. | ||
-- Trigger on table should enforce it as well, but extra check doesn't hurt. | ||
BEGIN | ||
SELECT host, username, port, pwd INTO STRICT v_host, v_username, v_port, v_password FROM @[email protected]_mapping_jobmon; | ||
SELECT host, hostaddr, username, port, pwd INTO STRICT v_host, v_hostaddr, v_username, v_port, v_password FROM @[email protected]_mapping_jobmon; | ||
EXCEPTION | ||
WHEN NO_DATA_FOUND THEN | ||
-- Do nothing | ||
|
@@ -40,7 +41,11 @@ BEGIN | |
END IF; | ||
|
||
IF v_host IS NOT NULL THEN | ||
v_auth := v_auth || ' hostaddr='||v_host; | ||
v_auth := v_auth || ' host='||v_host; | ||
END IF; | ||
|
||
IF v_hostaddr IS NOT NULL THEN | ||
v_auth := v_auth || ' hostaddr='||v_hostaddr; | ||
END IF; | ||
RETURN v_auth; | ||
END | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
-- Added new configuration column to support host/service names allowing for dynamic ip addresses to be used. | ||
|
||
|
||
ALTER TABLE @[email protected]_mapping_jobmon ADD COLUMN hostaddr text; | ||
UPDATE @[email protected]_mapping_jobmon SET hostaddr = host, host = NULL; | ||
|
||
CREATE OR REPLACE FUNCTION auth() RETURNS text | ||
LANGUAGE plpgsql STABLE | ||
AS $$ | ||
DECLARE | ||
|
||
v_auth text = ''; | ||
v_port text; | ||
v_password text; | ||
v_username text; | ||
v_host text; | ||
v_hostaddr text; | ||
|
||
BEGIN | ||
-- Ensure only one row is returned. No rows is fine, but this was the only way to force one. | ||
-- Trigger on table should enforce it as well, but extra check doesn't hurt. | ||
BEGIN | ||
SELECT host, hostaddr, username, port, pwd INTO STRICT v_host, v_hostaddr, v_username, v_port, v_password FROM @[email protected]_mapping_jobmon; | ||
EXCEPTION | ||
WHEN NO_DATA_FOUND THEN | ||
-- Do nothing | ||
WHEN TOO_MANY_ROWS THEN | ||
RAISE EXCEPTION 'dblink_mapping_jobmon table can only have a single entry'; | ||
END; | ||
|
||
|
||
IF v_port IS NULL THEN | ||
v_auth = 'dbname=' || current_database(); | ||
ELSE | ||
v_auth := 'port='||v_port||' dbname=' || current_database(); | ||
END IF; | ||
|
||
IF v_username IS NOT NULL THEN | ||
v_auth := v_auth || ' user='||v_username; | ||
END IF; | ||
|
||
IF v_password IS NOT NULL THEN | ||
v_auth := v_auth || ' password='||v_password; | ||
END IF; | ||
|
||
IF v_host IS NOT NULL THEN | ||
v_auth := v_auth || ' host='||v_host; | ||
END IF; | ||
|
||
IF v_hostaddr IS NOT NULL THEN | ||
v_auth := v_auth || ' hostaddr='||v_hostaddr; | ||
END IF; | ||
RETURN v_auth; | ||
END | ||
$$; |