Permalink
Browse files

Made simple install script and added installation instructions. Not y…

…et in extension form
  • Loading branch information...
1 parent ba2dd69 commit 59efeb1676efd86abc5cae2fc6a98b060b99bb2d @keithf4 committed Sep 11, 2012
Showing with 26 additions and 48 deletions.
  1. +9 −1 README.md
  2. +17 −0 install.sql
  3. +0 −47 sql/functions/create_next_id_partition.sql
View
@@ -1,5 +1,13 @@
+INSTALLATION
+-----------
+Still in early development, so not actually in extension format yet. Run install.sql located in root directory with psql from the pg_partman top level folder.
+
+ cd pg_partman
+ psql < install.sql
+
+
LICENSE AND COPYRIGHT
----------------------
+-------------------
PG Partition Manager (pg_partman) is released under the PostgreSQL License, a liberal Open Source license, similar to the BSD or MIT licenses.
View
@@ -0,0 +1,17 @@
+-- Run this script from the pg_partman top folder with psql command line tool to install pg_partman.
+
+DROP SCHEMA IF EXISTS part CASCADE;
+CREATE SCHEMA part;
+
+\i sql/types/types.sql
+\i sql/tables/tables.sql
+\i sql/functions/create_id_function.sql
+\i sql/functions/create_id_partition.sql
+\i sql/functions/create_next_time_partition.sql
+\i sql/functions/create_parent.sql
+\i sql/functions/create_time_function.sql
+\i sql/functions/create_time_partition.sql
+\i sql/functions/create_trigger.sql
+--\i sql/functions/
+\i sql/functions/run_maintenance.sql
+
@@ -1,47 +0,0 @@
-CREATE OR REPLACE FUNCTION part.create_next_id_partition (p_parent_table text) RETURNS void
- LANGUAGE plpgsql
- AS $$
-DECLARE
-
-v_control text;
-v_datetime_string text;
-v_last_partition text;
-v_next_partition_timestamp timestamp;
-v_part_interval interval;
-v_tablename text;
-v_type part.partition_type;
-
-
-BEGIN
-
-SELECT type
- , part_interval::interval
- , control
- , datetime_string
- , last_partition
-FROM part.part_config
-WHERE parent_table = p_parent_table
-AND (type = 'time-static' OR type = 'time-dynamic')
-INTO v_type, v_part_interval, v_control, v_datetime_string, v_last_partition;
-IF NOT FOUND THEN
- RAISE EXCEPTION 'ERROR: no config found for %', p_parent_table;
-END IF;
-
--- Double check that last created partition exists
-IF v_last_partition IS NOT NULL THEN
- SELECT tablename INTO v_tablename FROM pg_tables WHERE schemaname || '.' || tablename = p_parent_table;
- IF v_tablename IS NULL THEN
- RAISE EXCEPTION 'ERROR: previous partition missing. Unable to determine proper next partition name';
- END IF;
-END IF;
-
--- pull out datetime portion of last partition's tablename
-v_next_partition_timestamp := to_timestamp(substring(v_last_partition from char_length(p_parent_table||'_p')+1), v_datetime_string) + v_part_interval;
-
-EXECUTE 'SELECT part.create_time_partition('||quote_literal(p_parent_table)||','||quote_literal(v_control)||','||quote_literal(v_part_interval)||','
- ||quote_literal(v_datetime_string)||','||quote_literal(ARRAY[v_next_partition_timestamp])||')' INTO v_last_partition;
-
-UPDATE part.part_config SET last_partition = v_last_partition WHERE parent_table = p_parent_table;
-
-END
-$$;

0 comments on commit 59efeb1

Please sign in to comment.