Tuesday 1 November 2011

function for checking postgres config file parameters

create or replace function pgconfun2() returns void as $$
declare
--tis function will give alert on changes made by postgres.conf file
name1 text;
name2 text;
setting1 text;
setting2 text;
stmt1 text;
stmt2 text;
rec pgmansettings%rowtype;
begin
for rec in select name,setting from pg_settings
loop
name1 :=rec.name;
setting1 :=rec.setting;
stmt1 := 'select name,setting from pgmansettings where name='
|| ''''
||name1
|| ''''
|| ';' ;
execute stmt1 into name2,setting2;
if setting1 != setting2
then
raise notice 'parameter : % standard table value :% pg settings value :%',name2,setting2,setting1;
stmt2 :='update pgmansettings set setting = '
|| ''''
|| setting1
|| ''''
|| ' where name='
|| ''''
|| name2
|| ''''
|| ';' ;
execute stmt2;
raise notice 'updated standard table parameter :%  with value :% ',name2,setting1;
end if;
end loop;
end;
$$language plpgsql;



 

No comments:

Post a Comment