Vacuum behaviour in plpgsql function

From: "Alain Lavigne" <alavigne(at)zaq(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Vacuum behaviour in plpgsql function
Date: 2002-05-31 17:19:32
Message-ID: C34466F5BBA39949A8F5C180022EC206484668@zaq-msg-03.corp.zaq.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have the following function in PostgreSQL 7.2.1 on i586-pc-linux-gnu, compiled by GCC 2.96:

CREATE FUNCTION "fct_vacuum_db"() RETURNS "int2" AS '

DECLARE
db_table RECORD;
v_overhead float;

BEGIN
FOR db_table IN SELECT relname FROM pg_class WHERE relname like ''tb_%'' AND relkind = ''r'' LOOP

SELECT pgstattuple(db_table.relname)INTO v_overhead;

IF v_overhead >= 0 THEN
RAISE NOTICE ''Vacuuming table (%)'',db_table.relname;
EXECUTE ''vacuum analyze ''|| db_table.relname || '';'';
END IF;
END LOOP;
return 1;

==============================
Using the function pgstatuple I want to use this to control what gets vacuumed. However, whenever the EXECUTE statement runs I get the following message from the backend:

==============================
NOTICE: physical length: 0.00MB live tuples: 0 (0.00MB, 0.00%) dead tuples: 0 (0.00MB, 0.00%) free/reusable space: 0.00MB (0.00%) overhead: 0.00%
NOTICE: Vacuuming table (tb_a)
server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
===============================

What am I doing wrong ??

----------------------------------------------------------------------------------------
Alain Lavigne - Data Administrator - ZAQ Interactive Solutions E-Mail: alavigne(at)zaq(dot)com
297 St-Paul, West - Montreal, Quebec, Canada - H2Y 2A5
Phone: 514-282-7073 ext: 371 - Fax: 514-282-8011

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Curt Sampson 2002-05-31 17:22:59 Re: Row Limit on tables
Previous Message Anders Nielsen 2002-05-31 17:02:09 Re: PostgreSQL search engine (Perl)