Re: vacuumdb for schema only - Mailing list pgsql-admin

From Fabrízio de Royes Mello
Subject Re: vacuumdb for schema only
Date
Msg-id AANLkTi=Prb0rHp-YmKuafuZNrFM4yzvsGftA6uZwH80V@mail.gmail.com
Whole thread Raw
In response to Re: vacuumdb for schema only  (Bèrto ëd Sèra <berto.d.sera@gmail.com>)
Responses Re: vacuumdb for schema only  (Bèrto ëd Sèra <berto.d.sera@gmail.com>)
List pgsql-admin


2010/9/8 Bèrto ëd Sèra <berto.d.sera@gmail.com>
Hi!

I would also expect you to be able to make a Stored Procedure executing the same command, although I never tried it myself.


It is not possible... vacuum cannot be executed inside a function or transaction.

See de sample:

-- Using function
CREATE OR REPLACE FUNCTION fc_vacuum(TEXT) RETURNS VOID AS
$$
BEGIN
  EXECUTE 'VACUUM '||$1;
  RETURN;
END;
$$
LANGUAGE plpgsql;


postgres@bdteste=# select fc_vacuum('foo');
ERROR:  VACUUM cannot be executed from a function
CONTEXT:  SQL statement "VACUUM foo"
PL/pgSQL function "fc_vacuum" line 2 at execute statement


-- Using transaction
postgres@bdteste=# begin;
BEGIN
postgres@bdteste=# VACUUM foo;
ERROR:  VACUUM cannot run inside a transaction block


Best regards,

--
Fabrízio de Royes Mello
>> Blog sobre TI: http://fabriziomello.blogspot.com

pgsql-admin by date:

Previous
From: Thomas Uzunoff
Date:
Subject: PostgreSQL article online - PDF
Next
From: Bèrto ëd Sèra
Date:
Subject: Re: vacuumdb for schema only