2009/6/15 Fabrízio de Royes Mello <[email protected]>

>
> Obrigado pelas dicas... amanhã eu posto a PL com as alterações... agora
> estou pregado!!!
>
>
Euler,

Seguindo suas orientações fiz as modificações na PL (em anexo) e já estou
realizando diversos testes...

No próximo final de semana irei colocar o pgbouncer em produção num cliente
juntamente com o PostgreSQL 8.2 e essa PL que implementei. Irei acompanhar o
funcionamento dessa estrutura e postarei aqui na lista os resultados.

Obrigado por enquanto!

-- 
Fabrízio de Royes Mello
>> Blog sobre PostgreSQL: http://fabriziomello.blogspot.com
create or replace function fc_discard_all() returns void as
$$
declare
  rComando record;
  iVersao  integer;
begin

  select cast(setting as integer) 
    into iVersao
    from pg_settings 
   where name ~ 'server_version_num';

  if not found then
    raise exception 'A versão do PostgreSQL deve ser >= 8.2';
  end if;

  if iVersao >= 80300 then
    execute 'discard all';
    return;
  end if;

  set session authorization default;

  reset all;

  if iVersao >= 80200 then
    for rComando in 
      select name 
        from pg_prepared_statements
    loop
      execute 'deallocate '||rComando.name;
    end loop;

    for rComando in
      select name
        from pg_cursors
       where name !~ '^<unnamed' 
    loop
      execute 'close '||rComando.name;
    end loop;
  end if;

  unlisten *;

  if iVersao >= 80200 then
    perform pg_advisory_unlock_all();
  end if;

  for rComando in
    select distinct
           table_schema,
           table_name
      from information_schema.tables 
     where table_type = 'LOCAL TEMPORARY'
  loop
    execute 'drop table if exists '||quote_ident(rComando.table_schema)||'.'||quote_ident(rComando.table_name)||' cascade';
  end loop;

  return;
end;
$$
language plpgsql;

_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral

Responder a