From deb9c77083baab69da1ce38552f780e282b2c2e2 Mon Sep 17 00:00:00 2001 From: Constantine Date: Tue, 8 Oct 2024 16:50:22 +0300 Subject: [PATCH] Update range.sql This "if" just disturb create partition for empty table and force you to use "if select count (*) = 0 from tablename then create_range_partition(p_count = 0) else create_range_partition(p_=null, let pathman count how many partition need to) And it wery often create partition of empty table in case of liquibase or other db struct maneger --- range.sql | 8 -------- 1 file changed, 8 deletions(-) diff --git a/range.sql b/range.sql index 5af17014..680f4526 100644 --- a/range.sql +++ b/range.sql @@ -79,10 +79,6 @@ BEGIN EXECUTE pg_catalog.format('SELECT count(*), max(%s) FROM %s', expression, parent_relid) INTO rows_count, max_value; - IF rows_count = 0 THEN - RAISE EXCEPTION 'cannot determine partitions count for empty table'; - END IF; - p_count := 0; WHILE cur_value <= max_value LOOP @@ -172,10 +168,6 @@ BEGIN EXECUTE pg_catalog.format('SELECT count(*), max(%s) FROM %s', expression, parent_relid) INTO rows_count, max_value; - IF rows_count = 0 THEN - RAISE EXCEPTION 'cannot determine partitions count for empty table'; - END IF; - IF max_value IS NULL THEN RAISE EXCEPTION 'expression "%" can return NULL values', expression; END IF;