From dbb9598a52ed065012feebf1b58a1e18a4a21f78 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Wed, 14 Nov 2012 19:36:00 +0100 Subject: [PATCH] collectd_insert.sql: Let values_update_childs() return table names. The function will now return a set of the names of child tables that have been created. --- contrib/postgresql/collectd_insert.sql | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/contrib/postgresql/collectd_insert.sql b/contrib/postgresql/collectd_insert.sql index 7ccd909a..778de864 100644 --- a/contrib/postgresql/collectd_insert.sql +++ b/contrib/postgresql/collectd_insert.sql @@ -117,7 +117,7 @@ CREATE OR REPLACE VIEW collectd -- the tables for the next couple of days CREATE OR REPLACE FUNCTION values_update_childs( integer - ) RETURNS integer + ) RETURNS SETOF text LANGUAGE plpgsql AS $_$ DECLARE @@ -125,14 +125,12 @@ DECLARE cur_day date; next_day date; i integer; - n integer; BEGIN IF days < 1 THEN RAISE EXCEPTION 'Cannot have negative number of days'; END IF; i := 0; - n := 0; LOOP EXIT WHEN i > days; @@ -150,8 +148,7 @@ BEGIN CONTINUE; END; - RAISE INFO 'Created table "values$%"', cur_day; - n := n + 1; + RETURN NEXT 'values$' || cur_day::text; EXECUTE 'ALTER TABLE ONLY "values$' || cur_day || '" ADD CONSTRAINT "values_' || cur_day || '_pkey" @@ -160,7 +157,7 @@ BEGIN ADD CONSTRAINT "values_' || cur_day || '_id_fkey" FOREIGN KEY (id) REFERENCES identifiers(id)'; END LOOP; - RETURN n; + RETURN; END; $_$; -- 2.30.2