diff --git a/Dockerfile-15 b/Dockerfile-15 index f1b0f4558..f3b506171 100644 --- a/Dockerfile-15 +++ b/Dockerfile-15 @@ -20,6 +20,7 @@ ARG plv8_release=3.1.5 ARG pg_plan_filter_release=5081a7b5cb890876e67d8e7486b6a64c38c9a492 ARG pg_net_release=0.7.1 ARG rum_release=1.3.13 +ARG pg_partman_release=5.2.4 ARG pg_hashids_release=cd0e1b31d52b394a0df64079406a14a4f7387cd6 ARG libsodium_release=1.0.18 ARG pgsodium_release=3.1.6 diff --git a/Dockerfile-17 b/Dockerfile-17 index 7db870ad8..4ed76570d 100644 --- a/Dockerfile-17 +++ b/Dockerfile-17 @@ -21,6 +21,7 @@ ARG plv8_release=3.1.5 ARG pg_plan_filter_release=5081a7b5cb890876e67d8e7486b6a64c38c9a492 ARG pg_net_release=0.7.1 ARG rum_release=1.3.13 +ARG pg_partman_release=5.2.4 ARG pg_hashids_release=cd0e1b31d52b394a0df64079406a14a4f7387cd6 ARG libsodium_release=1.0.18 ARG pgsodium_release=3.1.6 diff --git a/Dockerfile-orioledb-17 b/Dockerfile-orioledb-17 index 0df0b9df0..a65cdab4e 100644 --- a/Dockerfile-orioledb-17 +++ b/Dockerfile-orioledb-17 @@ -27,6 +27,7 @@ ARG pgsodium_release=3.1.6 ARG pg_graphql_release=1.5.11 ARG pg_stat_monitor_release=1.1.1 ARG pg_jsonschema_release=0.1.4 +ARG pg_partman_release=5.2.4 ARG pg_repack_release=1.4.8 ARG vault_release=0.2.8 ARG groonga_release=12.0.8 diff --git a/ansible/files/postgresql_config/postgresql.conf.j2 b/ansible/files/postgresql_config/postgresql.conf.j2 index 5d4237068..772f74b44 100644 --- a/ansible/files/postgresql_config/postgresql.conf.j2 +++ b/ansible/files/postgresql_config/postgresql.conf.j2 @@ -688,7 +688,7 @@ default_text_search_config = 'pg_catalog.english' #local_preload_libraries = '' #session_preload_libraries = '' -shared_preload_libraries = 'pg_stat_statements, pgaudit, plpgsql, plpgsql_check, pg_cron, pg_net, pgsodium, timescaledb, auto_explain, pg_tle, plan_filter, supabase_vault' # (change requires restart) +shared_preload_libraries = 'pg_stat_statements, pgaudit, plpgsql, plpgsql_check, pg_cron, pg_net, pgsodium, timescaledb, auto_explain, pg_tle, plan_filter, supabase_vault, pg_partman_bgw' # (change requires restart) jit_provider = 'llvmjit' # JIT library to use # - Other Defaults - diff --git a/ansible/vars.yml b/ansible/vars.yml index e7e15a78d..00be56df3 100644 --- a/ansible/vars.yml +++ b/ansible/vars.yml @@ -9,9 +9,9 @@ postgres_major: # Full version strings for each major version postgres_release: - postgresorioledb-17: "17.5.1.029" - postgres17: "17.6.1.008" - postgres15: "15.14.1.008" + postgresorioledb-17: "17.5.1.029-pgpartman-test-1" + postgres17: "17.6.1.008-pgpartman-test-1" + postgres15: "15.14.1.008-pgpartman-test-1" # Non Postgres Extensions pgbouncer_release: "1.19.0" diff --git a/migrations/schema-15.sql b/migrations/schema-15.sql index 1f1d98496..65c53004b 100644 --- a/migrations/schema-15.sql +++ b/migrations/schema-15.sql @@ -87,6 +87,9 @@ CREATE EXTENSION IF NOT EXISTS pg_graphql WITH SCHEMA graphql; COMMENT ON EXTENSION pg_graphql IS 'pg_graphql: GraphQL support'; +CREATE SCHEMA partman; +CREATE EXTENSION IF NOT EXISTS pg_partman WITH SCHEMA partman; + -- -- Name: pg_stat_statements; Type: EXTENSION; Schema: -; Owner: - diff --git a/migrations/schema.sql b/migrations/schema.sql index cb031f797..65e720224 100644 --- a/migrations/schema.sql +++ b/migrations/schema.sql @@ -78,6 +78,12 @@ CREATE EXTENSION IF NOT EXISTS pg_graphql WITH SCHEMA graphql; COMMENT ON EXTENSION pg_graphql IS 'pg_graphql: GraphQL support'; +-- +-- Name: pg_partman; Type: EXTENSION; Schema: -; Owner: - +-- + +CREATE SCHEMA partman; +CREATE EXTENSION pg_partman SCHEMA partman; -- -- Name: pg_stat_statements; Type: EXTENSION; Schema: -; Owner: - diff --git a/migrations/tests/extensions/30-pg_partman.sql b/migrations/tests/extensions/30-pg_partman.sql new file mode 100644 index 000000000..ad4ef6d72 --- /dev/null +++ b/migrations/tests/extensions/30-pg_partman.sql @@ -0,0 +1,4 @@ +BEGIN; +create schema if not exists "partman"; +create extension if not exists pg_partman with schema "partman"; +ROLLBACK; diff --git a/migrations/tests/extensions/test.sql b/migrations/tests/extensions/test.sql index 7e0d1f38d..1d7075c13 100644 --- a/migrations/tests/extensions/test.sql +++ b/migrations/tests/extensions/test.sql @@ -28,3 +28,4 @@ \ir 27-pg_repack.sql \ir 28-pgvector.sql \ir 29-pg_tle.sql +\ir 30-pg_partman.sql diff --git a/nix/checks.nix b/nix/checks.nix index d6d3aa59f..c9bbc0340 100644 --- a/nix/checks.nix +++ b/nix/checks.nix @@ -149,7 +149,7 @@ ) filteredSqlTests; sortedTestList = builtins.sort (a: b: a < b) testList; in - pkgs.runCommand "postgres-${pgpkg.version}-check-harness" + pkgs.runCommand "postgres-${pgpkg.version}-ch" { nativeBuildInputs = with pkgs; [ coreutils diff --git a/nix/docs/adding-new-package.md b/nix/docs/adding-new-package.md index 83d546d21..a1f8c662f 100644 --- a/nix/docs/adding-new-package.md +++ b/nix/docs/adding-new-package.md @@ -153,7 +153,7 @@ A few things about `buildPgrxExtension_x`: 2. You may need to add tests to our test.yml gh action workflow as well. 3. You can add the package and name and version to `ansible/vars.yml` it is not necessary to add the sha256 hash here, as the package is already built and cached in our release process before these vars are ever run. 4. to check that all your files will land in the overall build correctly, you can run `nix profile install .#psql_15/bin` on your machine, and check in `~/.nix-profile/bin, ~/.nix-profile/lib, ~/.nix-profile/share/postgresql/*` and you should see your lib, .control and sql files there. -5. You can also run `nix run .#start-server 15` and in a new terminal window run `nix run .#star-client-and-migrate 15` and try to `CREATE EXTENSION ` and work with it there +5. You can also run `nix run .#start-server 15` and in a new terminal window run `nix run .#start-client -- --version15` and try to `CREATE EXTENSION ` and work with it there 6. Check that your extension works with the `pg_upgrade` process (TODO documentation forthcoming) 7. Now you are ready to PR the extension 8. From here, the release process should typically take care of the rest. diff --git a/nix/ext/pg_partman.nix b/nix/ext/pg_partman.nix index 08fc74cee..9348d252b 100644 --- a/nix/ext/pg_partman.nix +++ b/nix/ext/pg_partman.nix @@ -7,15 +7,15 @@ stdenv.mkDerivation rec { pname = "pg_partman"; - version = "5.1.0"; + version = "5.2.4"; buildInputs = [ postgresql ]; src = fetchFromGitHub { owner = "pgpartman"; - repo = pname; + repo = "${pname}"; rev = "refs/tags/v${version}"; - sha256 = "sha256-GrVOJ5ywZMyqyDroYDLdKkXDdIJSDGhDfveO/ZvrmYs="; + hash = "sha256-i/o+JZEXnJRO17kfdTw87aca28+I8pvuFZsPMA/kf+w="; }; installPhase = '' diff --git a/nix/packages/postgres.nix b/nix/packages/postgres.nix index 54c674775..1ccbc555b 100644 --- a/nix/packages/postgres.nix +++ b/nix/packages/postgres.nix @@ -38,6 +38,7 @@ ../ext/pg_hashids.nix ../ext/pgsodium.nix ../ext/pg_graphql.nix + ../ext/pg_partman.nix ../ext/pg_stat_monitor.nix ../ext/pg_jsonschema.nix ../ext/pgvector.nix diff --git a/nix/tests/expected/pg_partman.out b/nix/tests/expected/pg_partman.out new file mode 100644 index 000000000..b32e64bba --- /dev/null +++ b/nix/tests/expected/pg_partman.out @@ -0,0 +1,20 @@ +CREATE SCHEMA IF NOT EXISTS partman_test; +CREATE TABLE partman_test.time_taptest_table + (col1 int, + col2 text default 'stuff', + col3 timestamptz NOT NULL DEFAULT now()) +PARTITION BY RANGE (col3); +CREATE INDEX ON partman_test.time_taptest_table (col3); +CREATE TABLE partman_test.time_taptest_table_template (LIKE partman_test.time_taptest_table); +ALTER TABLE partman_test.time_taptest_table_template ADD PRIMARY KEY (col1); +SELECT partman.create_parent( + p_parent_table := 'partman_test.time_taptest_table' + , p_control := 'col3' + , p_interval := '1 day' + , p_template_table := 'partman_test.time_taptest_table_template' +); + create_parent +--------------- + t +(1 row) + diff --git a/nix/tests/expected/z_15_ext_interface.out b/nix/tests/expected/z_15_ext_interface.out index d3d9f7c4f..c98547058 100644 --- a/nix/tests/expected/z_15_ext_interface.out +++ b/nix/tests/expected/z_15_ext_interface.out @@ -84,6 +84,7 @@ order by pg_hashids | t pg_jsonschema | f pg_net | f + pg_partman | f pg_prewarm | t pg_repack | f pg_stat_monitor | t @@ -128,7 +129,7 @@ order by vector | t wrappers | t xml2 | f -(79 rows) +(80 rows) /* @@ -168,8 +169,8 @@ order by n.nspname, p.proname, md5(pg_catalog.pg_get_function_identity_arguments(p.oid)); - extension_name | schema_name | function_name | argument_types | return_type -------------------------+--------------------------+--------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + extension_name | schema_name | function_name | argument_types | return_type +------------------------+--------------------------+--------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ address_standardizer | public | parse_address | text, OUT num text, OUT street text, OUT street2 text, OUT address1 text, OUT city text, OUT state text, OUT zip text, OUT zipplus text, OUT country text | record address_standardizer | public | standardize_address | lextab text, gaztab text, rultab text, address text | stdaddr address_standardizer | public | standardize_address | lextab text, gaztab text, rultab text, micro text, macro text | stdaddr @@ -1167,6 +1168,47 @@ order by pg_net | net | wait_until_running | | void pg_net | net | wake | | void pg_net | net | worker_restart | | boolean + pg_partman | partman | apply_cluster | p_parent_schema text, p_parent_tablename text, p_child_schema text, p_child_tablename text | void + pg_partman | partman | apply_constraints | p_parent_table text, p_child_table text, p_analyze boolean, p_job_id bigint | void + pg_partman | partman | apply_privileges | p_parent_schema text, p_parent_tablename text, p_child_schema text, p_child_tablename text, p_job_id bigint | void + pg_partman | partman | autovacuum_off | p_parent_schema text, p_parent_tablename text, p_source_schema text, p_source_tablename text | boolean + pg_partman | partman | autovacuum_reset | p_parent_schema text, p_parent_tablename text, p_source_schema text, p_source_tablename text | boolean + pg_partman | partman | calculate_time_partition_info | p_time_interval interval, p_start_time timestamp with time zone, p_date_trunc_interval text, OUT base_timestamp timestamp with time zone, OUT datetime_string text | record + pg_partman | partman | check_automatic_maintenance_value | p_automatic_maintenance text | boolean + pg_partman | partman | check_control_type | p_parent_schema text, p_parent_tablename text, p_control text | TABLE(general_type text, exact_type text) + pg_partman | partman | check_default | p_exact_count boolean | SETOF partman.check_default_table + pg_partman | partman | check_epoch_type | p_type text | boolean + pg_partman | partman | check_name_length | p_object_name text, p_suffix text, p_table_partition boolean | text + pg_partman | partman | check_partition_type | p_type text | boolean + pg_partman | partman | check_subpart_sameconfig | p_parent_table text | TABLE(sub_control text, sub_partition_interval text, sub_partition_type text, sub_premake integer, sub_automatic_maintenance text, sub_template_table text, sub_retention text, sub_retention_schema text, sub_retention_keep_index boolean, sub_retention_keep_table boolean, sub_epoch text, sub_constraint_cols text[], sub_optimize_constraint integer, sub_infinite_time_partitions boolean, sub_jobmon boolean, sub_inherit_privileges boolean, sub_constraint_valid boolean, sub_date_trunc_interval text, sub_ignore_default_data boolean, sub_default_table boolean, sub_maintenance_order integer, sub_retention_keep_publication boolean, sub_control_not_null boolean) + pg_partman | partman | check_subpartition_limits | p_parent_table text, p_type text, OUT sub_min text, OUT sub_max text | record + pg_partman | partman | create_parent | p_parent_table text, p_control text, p_interval text, p_type text, p_epoch text, p_premake integer, p_start_partition text, p_default_table boolean, p_automatic_maintenance text, p_constraint_cols text[], p_template_table text, p_jobmon boolean, p_date_trunc_interval text, p_control_not_null boolean, p_time_encoder text, p_time_decoder text | boolean + pg_partman | partman | create_partition_id | p_parent_table text, p_partition_ids bigint[], p_start_partition text | boolean + pg_partman | partman | create_partition_time | p_parent_table text, p_partition_times timestamp with time zone[], p_start_partition text | boolean + pg_partman | partman | create_sub_parent | p_top_parent text, p_control text, p_interval text, p_type text, p_default_table boolean, p_declarative_check text, p_constraint_cols text[], p_premake integer, p_start_partition text, p_epoch text, p_jobmon boolean, p_date_trunc_interval text, p_control_not_null boolean, p_time_encoder text, p_time_decoder text | boolean + pg_partman | partman | drop_constraints | p_parent_table text, p_child_table text, p_debug boolean | void + pg_partman | partman | drop_partition_id | p_parent_table text, p_retention bigint, p_keep_table boolean, p_keep_index boolean, p_retention_schema text | integer + pg_partman | partman | drop_partition_time | p_parent_table text, p_retention interval, p_keep_table boolean, p_keep_index boolean, p_retention_schema text, p_reference_timestamp timestamp with time zone | integer + pg_partman | partman | dump_partitioned_table_definition | p_parent_table text, p_ignore_template_table boolean | text + pg_partman | partman | inherit_replica_identity | p_parent_schemaname text, p_parent_tablename text, p_child_tablename text | void + pg_partman | partman | inherit_template_properties | p_parent_table text, p_child_schema text, p_child_tablename text | boolean + pg_partman | partman | partition_data_id | p_parent_table text, p_batch_count integer, p_batch_interval bigint, p_lock_wait numeric, p_order text, p_analyze boolean, p_source_table text, p_ignored_columns text[] | bigint + pg_partman | partman | partition_data_proc | IN p_parent_table text, IN p_loop_count integer, IN p_interval text, IN p_lock_wait integer, IN p_lock_wait_tries integer, IN p_wait integer, IN p_order text, IN p_source_table text, IN p_ignored_columns text[], IN p_quiet boolean | + pg_partman | partman | partition_data_time | p_parent_table text, p_batch_count integer, p_batch_interval interval, p_lock_wait numeric, p_order text, p_analyze boolean, p_source_table text, p_ignored_columns text[] | bigint + pg_partman | partman | partition_gap_fill | p_parent_table text | integer + pg_partman | partman | reapply_constraints_proc | IN p_parent_table text, IN p_drop_constraints boolean, IN p_apply_constraints boolean, IN p_wait integer, IN p_dryrun boolean | + pg_partman | partman | reapply_privileges | p_parent_table text | void + pg_partman | partman | run_analyze | IN p_skip_locked boolean, IN p_quiet boolean, IN p_parent_table text | + pg_partman | partman | run_maintenance | p_parent_table text, p_analyze boolean, p_jobmon boolean | void + pg_partman | partman | run_maintenance_proc | IN p_wait integer, IN p_analyze boolean, IN p_jobmon boolean | + pg_partman | partman | show_partition_info | p_child_table text, p_partition_interval text, p_parent_table text, OUT child_start_time timestamp with time zone, OUT child_end_time timestamp with time zone, OUT child_start_id bigint, OUT child_end_id bigint, OUT suffix text | record + pg_partman | partman | show_partition_name | p_parent_table text, p_value text, OUT partition_schema text, OUT partition_table text, OUT suffix_timestamp timestamp with time zone, OUT suffix_id bigint, OUT table_exists boolean | record + pg_partman | partman | show_partitions | p_parent_table text, p_order text, p_include_default boolean | TABLE(partition_schemaname text, partition_tablename text) + pg_partman | partman | stop_sub_partition | p_parent_table text, p_jobmon boolean | boolean + pg_partman | partman | undo_partition | p_parent_table text, p_target_table text, p_loop_count integer, p_batch_interval text, p_keep_table boolean, p_lock_wait numeric, p_ignored_columns text[], p_drop_cascade boolean, OUT partitions_undone integer, OUT rows_undone bigint | record + pg_partman | partman | undo_partition_proc | IN p_parent_table text, IN p_target_table text, IN p_loop_count integer, IN p_interval text, IN p_keep_table boolean, IN p_lock_wait integer, IN p_lock_wait_tries integer, IN p_wait integer, IN p_ignored_columns text[], IN p_drop_cascade boolean, IN p_quiet boolean | + pg_partman | partman | uuid7_time_decoder | uuidv7 text | timestamp with time zone + pg_partman | partman | uuid7_time_encoder | ts timestamp with time zone | uuid pg_prewarm | public | autoprewarm_dump_now | | bigint pg_prewarm | public | autoprewarm_start_worker | | void pg_prewarm | public | pg_prewarm | regclass, mode text, fork text, first_block bigint, last_block bigint | bigint @@ -5229,7 +5271,7 @@ order by xml2 | public | xpath_table | text, text, text, text, text | SETOF record xml2 | public | xslt_process | text, text | text xml2 | public | xslt_process | text, text, text | text -(5059 rows) +(5100 rows) /* @@ -5312,6 +5354,65 @@ order by pg_net | net | http_request_queue | method pg_net | net | http_request_queue | timeout_milliseconds pg_net | net | http_request_queue | url + pg_partman | partman | part_config | automatic_maintenance + pg_partman | partman | part_config | constraint_cols + pg_partman | partman | part_config | constraint_valid + pg_partman | partman | part_config | control + pg_partman | partman | part_config | date_trunc_interval + pg_partman | partman | part_config | datetime_string + pg_partman | partman | part_config | epoch + pg_partman | partman | part_config | ignore_default_data + pg_partman | partman | part_config | infinite_time_partitions + pg_partman | partman | part_config | inherit_privileges + pg_partman | partman | part_config | jobmon + pg_partman | partman | part_config | maintenance_last_run + pg_partman | partman | part_config | maintenance_order + pg_partman | partman | part_config | optimize_constraint + pg_partman | partman | part_config | parent_table + pg_partman | partman | part_config | partition_interval + pg_partman | partman | part_config | partition_type + pg_partman | partman | part_config | premake + pg_partman | partman | part_config | retention + pg_partman | partman | part_config | retention_keep_index + pg_partman | partman | part_config | retention_keep_publication + pg_partman | partman | part_config | retention_keep_table + pg_partman | partman | part_config | retention_schema + pg_partman | partman | part_config | sub_partition_set_full + pg_partman | partman | part_config | template_table + pg_partman | partman | part_config | time_decoder + pg_partman | partman | part_config | time_encoder + pg_partman | partman | part_config | undo_in_progress + pg_partman | partman | part_config_sub | sub_automatic_maintenance + pg_partman | partman | part_config_sub | sub_constraint_cols + pg_partman | partman | part_config_sub | sub_constraint_valid + pg_partman | partman | part_config_sub | sub_control + pg_partman | partman | part_config_sub | sub_control_not_null + pg_partman | partman | part_config_sub | sub_date_trunc_interval + pg_partman | partman | part_config_sub | sub_default_table + pg_partman | partman | part_config_sub | sub_epoch + pg_partman | partman | part_config_sub | sub_ignore_default_data + pg_partman | partman | part_config_sub | sub_infinite_time_partitions + pg_partman | partman | part_config_sub | sub_inherit_privileges + pg_partman | partman | part_config_sub | sub_jobmon + pg_partman | partman | part_config_sub | sub_maintenance_order + pg_partman | partman | part_config_sub | sub_optimize_constraint + pg_partman | partman | part_config_sub | sub_parent + pg_partman | partman | part_config_sub | sub_partition_interval + pg_partman | partman | part_config_sub | sub_partition_type + pg_partman | partman | part_config_sub | sub_premake + pg_partman | partman | part_config_sub | sub_retention + pg_partman | partman | part_config_sub | sub_retention_keep_index + pg_partman | partman | part_config_sub | sub_retention_keep_publication + pg_partman | partman | part_config_sub | sub_retention_keep_table + pg_partman | partman | part_config_sub | sub_retention_schema + pg_partman | partman | part_config_sub | sub_template_table + pg_partman | partman | part_config_sub | sub_time_decoder + pg_partman | partman | part_config_sub | sub_time_encoder + pg_partman | partman | table_privs | grantee + pg_partman | partman | table_privs | grantor + pg_partman | partman | table_privs | privilege_type + pg_partman | partman | table_privs | table_name + pg_partman | partman | table_privs | table_schema pg_repack | repack | primary_keys | indexrelid pg_repack | repack | primary_keys | indrelid pg_repack | repack | tables | alter_col_storage @@ -6369,5 +6470,5 @@ order by wrappers | public | wrappers_fdw_stats | rows_in wrappers | public | wrappers_fdw_stats | rows_out wrappers | public | wrappers_fdw_stats | updated_at -(1106 rows) +(1165 rows) diff --git a/nix/tests/expected/z_15_unhype_timescale_to_partman.out b/nix/tests/expected/z_15_unhype_timescale_to_partman.out new file mode 100644 index 000000000..fa4eb37dc --- /dev/null +++ b/nix/tests/expected/z_15_unhype_timescale_to_partman.out @@ -0,0 +1,77 @@ +/* + +The purpose of this test is to validate the method of moving from Timescale Hypertables to Postgres native partitioned tables +managed by pg_partman + +*/ +CREATE SCHEMA ts; +-- Create a table for time-series data +CREATE TABLE ts.readings ( + time TIMESTAMPTZ NOT NULL, + sensor_id INT NOT NULL, + value DOUBLE PRECISION NOT NULL +); +-- Convert the table into a hypertable +SELECT create_hypertable('ts.readings', by_range('time', INTERVAL '1 day')); + create_hypertable +------------------- + (2,t) +(1 row) + +-- Convert default 7 day chunk interval +SELECT set_chunk_time_interval('ts.readings', INTERVAL '24 hours'); + set_chunk_time_interval +------------------------- + +(1 row) + +-- Insert sample data +INSERT INTO ts.readings (time, sensor_id, value) +SELECT + time_series AS time, + FLOOR(RANDOM() * 10 + 1)::INT AS sensor_id, -- Random sensor_id between 1 and 10 + RANDOM() * 100 AS value -- Random value between 0 and 100 +FROM + generate_series( + '2023-01-19 00:00:00+00'::TIMESTAMPTZ, + '2025-03-26 03:00:00+00'::TIMESTAMPTZ, + INTERVAL '1 second' + ) AS time_series +LIMIT 600000; +-- List hypertables +SELECT * FROM timescaledb_information.hypertables; + hypertable_schema | hypertable_name | owner | num_dimensions | num_chunks | compression_enabled | tablespaces +-------------------+-----------------+----------------+----------------+------------+---------------------+------------- + ts | readings | supabase_admin | 1 | 7 | f | +(1 row) + +-- Rename hypertable +ALTER TABLE ts.readings RENAME TO ht_readings; +-- Create copy of hypertable with original name +CREATE TABLE ts.readings (LIKE ts.ht_readings) PARTITION BY RANGE(time); +-- Configure pg_partman for daily partitions on sensor_data +SELECT partman.create_parent( + p_parent_table := 'ts.readings', + p_control := 'time', + p_type := 'range', + p_interval := '1 day', + p_premake := 7, -- Create partitions for the next 7 days + p_start_partition := '2023-01-19 00:00:00+00' -- Start date for partitioning +); + create_parent +--------------- + t +(1 row) + +INSERT INTO ts.readings SELECT * FROM ts.ht_readings; +DROP SCHEMA ts CASCADE; +NOTICE: drop cascades to 9 other objects +DETAIL: drop cascades to table ts.ht_readings +drop cascades to table _timescaledb_internal._hyper_2_3_chunk +drop cascades to table _timescaledb_internal._hyper_2_4_chunk +drop cascades to table _timescaledb_internal._hyper_2_5_chunk +drop cascades to table _timescaledb_internal._hyper_2_6_chunk +drop cascades to table _timescaledb_internal._hyper_2_7_chunk +drop cascades to table _timescaledb_internal._hyper_2_8_chunk +drop cascades to table _timescaledb_internal._hyper_2_9_chunk +drop cascades to table ts.readings diff --git a/nix/tests/expected/z_17_ext_interface.out b/nix/tests/expected/z_17_ext_interface.out index 46792e48f..96baed46f 100644 --- a/nix/tests/expected/z_17_ext_interface.out +++ b/nix/tests/expected/z_17_ext_interface.out @@ -76,6 +76,7 @@ order by pg_hashids | t pg_jsonschema | f pg_net | f + pg_partman | f pg_prewarm | t pg_repack | f pg_stat_monitor | t @@ -115,7 +116,7 @@ order by vector | t wrappers | t xml2 | f -(72 rows) +(73 rows) /* @@ -155,8 +156,8 @@ order by n.nspname, p.proname, md5(pg_catalog.pg_get_function_identity_arguments(p.oid)); - extension_name | schema_name | function_name | argument_types | return_type -----------------------+----------------+--------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + extension_name | schema_name | function_name | argument_types | return_type +----------------------+----------------+--------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ address_standardizer | public | parse_address | text, OUT num text, OUT street text, OUT street2 text, OUT address1 text, OUT city text, OUT state text, OUT zip text, OUT zipplus text, OUT country text | record address_standardizer | public | standardize_address | lextab text, gaztab text, rultab text, address text | stdaddr address_standardizer | public | standardize_address | lextab text, gaztab text, rultab text, micro text, macro text | stdaddr @@ -1152,6 +1153,47 @@ order by pg_net | net | wait_until_running | | void pg_net | net | wake | | void pg_net | net | worker_restart | | boolean + pg_partman | partman | apply_cluster | p_parent_schema text, p_parent_tablename text, p_child_schema text, p_child_tablename text | void + pg_partman | partman | apply_constraints | p_parent_table text, p_child_table text, p_analyze boolean, p_job_id bigint | void + pg_partman | partman | apply_privileges | p_parent_schema text, p_parent_tablename text, p_child_schema text, p_child_tablename text, p_job_id bigint | void + pg_partman | partman | autovacuum_off | p_parent_schema text, p_parent_tablename text, p_source_schema text, p_source_tablename text | boolean + pg_partman | partman | autovacuum_reset | p_parent_schema text, p_parent_tablename text, p_source_schema text, p_source_tablename text | boolean + pg_partman | partman | calculate_time_partition_info | p_time_interval interval, p_start_time timestamp with time zone, p_date_trunc_interval text, OUT base_timestamp timestamp with time zone, OUT datetime_string text | record + pg_partman | partman | check_automatic_maintenance_value | p_automatic_maintenance text | boolean + pg_partman | partman | check_control_type | p_parent_schema text, p_parent_tablename text, p_control text | TABLE(general_type text, exact_type text) + pg_partman | partman | check_default | p_exact_count boolean | SETOF partman.check_default_table + pg_partman | partman | check_epoch_type | p_type text | boolean + pg_partman | partman | check_name_length | p_object_name text, p_suffix text, p_table_partition boolean | text + pg_partman | partman | check_partition_type | p_type text | boolean + pg_partman | partman | check_subpart_sameconfig | p_parent_table text | TABLE(sub_control text, sub_partition_interval text, sub_partition_type text, sub_premake integer, sub_automatic_maintenance text, sub_template_table text, sub_retention text, sub_retention_schema text, sub_retention_keep_index boolean, sub_retention_keep_table boolean, sub_epoch text, sub_constraint_cols text[], sub_optimize_constraint integer, sub_infinite_time_partitions boolean, sub_jobmon boolean, sub_inherit_privileges boolean, sub_constraint_valid boolean, sub_date_trunc_interval text, sub_ignore_default_data boolean, sub_default_table boolean, sub_maintenance_order integer, sub_retention_keep_publication boolean, sub_control_not_null boolean) + pg_partman | partman | check_subpartition_limits | p_parent_table text, p_type text, OUT sub_min text, OUT sub_max text | record + pg_partman | partman | create_parent | p_parent_table text, p_control text, p_interval text, p_type text, p_epoch text, p_premake integer, p_start_partition text, p_default_table boolean, p_automatic_maintenance text, p_constraint_cols text[], p_template_table text, p_jobmon boolean, p_date_trunc_interval text, p_control_not_null boolean, p_time_encoder text, p_time_decoder text | boolean + pg_partman | partman | create_partition_id | p_parent_table text, p_partition_ids bigint[], p_start_partition text | boolean + pg_partman | partman | create_partition_time | p_parent_table text, p_partition_times timestamp with time zone[], p_start_partition text | boolean + pg_partman | partman | create_sub_parent | p_top_parent text, p_control text, p_interval text, p_type text, p_default_table boolean, p_declarative_check text, p_constraint_cols text[], p_premake integer, p_start_partition text, p_epoch text, p_jobmon boolean, p_date_trunc_interval text, p_control_not_null boolean, p_time_encoder text, p_time_decoder text | boolean + pg_partman | partman | drop_constraints | p_parent_table text, p_child_table text, p_debug boolean | void + pg_partman | partman | drop_partition_id | p_parent_table text, p_retention bigint, p_keep_table boolean, p_keep_index boolean, p_retention_schema text | integer + pg_partman | partman | drop_partition_time | p_parent_table text, p_retention interval, p_keep_table boolean, p_keep_index boolean, p_retention_schema text, p_reference_timestamp timestamp with time zone | integer + pg_partman | partman | dump_partitioned_table_definition | p_parent_table text, p_ignore_template_table boolean | text + pg_partman | partman | inherit_replica_identity | p_parent_schemaname text, p_parent_tablename text, p_child_tablename text | void + pg_partman | partman | inherit_template_properties | p_parent_table text, p_child_schema text, p_child_tablename text | boolean + pg_partman | partman | partition_data_id | p_parent_table text, p_batch_count integer, p_batch_interval bigint, p_lock_wait numeric, p_order text, p_analyze boolean, p_source_table text, p_ignored_columns text[] | bigint + pg_partman | partman | partition_data_proc | IN p_parent_table text, IN p_loop_count integer, IN p_interval text, IN p_lock_wait integer, IN p_lock_wait_tries integer, IN p_wait integer, IN p_order text, IN p_source_table text, IN p_ignored_columns text[], IN p_quiet boolean | + pg_partman | partman | partition_data_time | p_parent_table text, p_batch_count integer, p_batch_interval interval, p_lock_wait numeric, p_order text, p_analyze boolean, p_source_table text, p_ignored_columns text[] | bigint + pg_partman | partman | partition_gap_fill | p_parent_table text | integer + pg_partman | partman | reapply_constraints_proc | IN p_parent_table text, IN p_drop_constraints boolean, IN p_apply_constraints boolean, IN p_wait integer, IN p_dryrun boolean | + pg_partman | partman | reapply_privileges | p_parent_table text | void + pg_partman | partman | run_analyze | IN p_skip_locked boolean, IN p_quiet boolean, IN p_parent_table text | + pg_partman | partman | run_maintenance | p_parent_table text, p_analyze boolean, p_jobmon boolean | void + pg_partman | partman | run_maintenance_proc | IN p_wait integer, IN p_analyze boolean, IN p_jobmon boolean | + pg_partman | partman | show_partition_info | p_child_table text, p_partition_interval text, p_parent_table text, OUT child_start_time timestamp with time zone, OUT child_end_time timestamp with time zone, OUT child_start_id bigint, OUT child_end_id bigint, OUT suffix text | record + pg_partman | partman | show_partition_name | p_parent_table text, p_value text, OUT partition_schema text, OUT partition_table text, OUT suffix_timestamp timestamp with time zone, OUT suffix_id bigint, OUT table_exists boolean | record + pg_partman | partman | show_partitions | p_parent_table text, p_order text, p_include_default boolean | TABLE(partition_schemaname text, partition_tablename text) + pg_partman | partman | stop_sub_partition | p_parent_table text, p_jobmon boolean | boolean + pg_partman | partman | undo_partition | p_parent_table text, p_target_table text, p_loop_count integer, p_batch_interval text, p_keep_table boolean, p_lock_wait numeric, p_ignored_columns text[], p_drop_cascade boolean, OUT partitions_undone integer, OUT rows_undone bigint | record + pg_partman | partman | undo_partition_proc | IN p_parent_table text, IN p_target_table text, IN p_loop_count integer, IN p_interval text, IN p_keep_table boolean, IN p_lock_wait integer, IN p_lock_wait_tries integer, IN p_wait integer, IN p_ignored_columns text[], IN p_drop_cascade boolean, IN p_quiet boolean | + pg_partman | partman | uuid7_time_decoder | uuidv7 text | timestamp with time zone + pg_partman | partman | uuid7_time_encoder | ts timestamp with time zone | uuid pg_prewarm | public | autoprewarm_dump_now | | bigint pg_prewarm | public | autoprewarm_start_worker | | void pg_prewarm | public | pg_prewarm | regclass, mode text, fork text, first_block bigint, last_block bigint | bigint @@ -4873,7 +4915,7 @@ order by xml2 | public | xpath_table | text, text, text, text, text | SETOF record xml2 | public | xslt_process | text, text | text xml2 | public | xslt_process | text, text, text | text -(4716 rows) +(4757 rows) /* @@ -4905,8 +4947,8 @@ order by n.nspname, pc.relname, pa.attname; - extension_name | schema_name | entity_name | attname -------------------------------+-------------+-------------------------+------------------------ + extension_name | schema_name | entity_name | attname +------------------------------+-------------+-------------------------+-------------------------------- address_standardizer_data_us | public | us_gaz | id address_standardizer_data_us | public | us_gaz | is_custom address_standardizer_data_us | public | us_gaz | seq @@ -4956,6 +4998,65 @@ order by pg_net | net | http_request_queue | method pg_net | net | http_request_queue | timeout_milliseconds pg_net | net | http_request_queue | url + pg_partman | partman | part_config | automatic_maintenance + pg_partman | partman | part_config | constraint_cols + pg_partman | partman | part_config | constraint_valid + pg_partman | partman | part_config | control + pg_partman | partman | part_config | date_trunc_interval + pg_partman | partman | part_config | datetime_string + pg_partman | partman | part_config | epoch + pg_partman | partman | part_config | ignore_default_data + pg_partman | partman | part_config | infinite_time_partitions + pg_partman | partman | part_config | inherit_privileges + pg_partman | partman | part_config | jobmon + pg_partman | partman | part_config | maintenance_last_run + pg_partman | partman | part_config | maintenance_order + pg_partman | partman | part_config | optimize_constraint + pg_partman | partman | part_config | parent_table + pg_partman | partman | part_config | partition_interval + pg_partman | partman | part_config | partition_type + pg_partman | partman | part_config | premake + pg_partman | partman | part_config | retention + pg_partman | partman | part_config | retention_keep_index + pg_partman | partman | part_config | retention_keep_publication + pg_partman | partman | part_config | retention_keep_table + pg_partman | partman | part_config | retention_schema + pg_partman | partman | part_config | sub_partition_set_full + pg_partman | partman | part_config | template_table + pg_partman | partman | part_config | time_decoder + pg_partman | partman | part_config | time_encoder + pg_partman | partman | part_config | undo_in_progress + pg_partman | partman | part_config_sub | sub_automatic_maintenance + pg_partman | partman | part_config_sub | sub_constraint_cols + pg_partman | partman | part_config_sub | sub_constraint_valid + pg_partman | partman | part_config_sub | sub_control + pg_partman | partman | part_config_sub | sub_control_not_null + pg_partman | partman | part_config_sub | sub_date_trunc_interval + pg_partman | partman | part_config_sub | sub_default_table + pg_partman | partman | part_config_sub | sub_epoch + pg_partman | partman | part_config_sub | sub_ignore_default_data + pg_partman | partman | part_config_sub | sub_infinite_time_partitions + pg_partman | partman | part_config_sub | sub_inherit_privileges + pg_partman | partman | part_config_sub | sub_jobmon + pg_partman | partman | part_config_sub | sub_maintenance_order + pg_partman | partman | part_config_sub | sub_optimize_constraint + pg_partman | partman | part_config_sub | sub_parent + pg_partman | partman | part_config_sub | sub_partition_interval + pg_partman | partman | part_config_sub | sub_partition_type + pg_partman | partman | part_config_sub | sub_premake + pg_partman | partman | part_config_sub | sub_retention + pg_partman | partman | part_config_sub | sub_retention_keep_index + pg_partman | partman | part_config_sub | sub_retention_keep_publication + pg_partman | partman | part_config_sub | sub_retention_keep_table + pg_partman | partman | part_config_sub | sub_retention_schema + pg_partman | partman | part_config_sub | sub_template_table + pg_partman | partman | part_config_sub | sub_time_decoder + pg_partman | partman | part_config_sub | sub_time_encoder + pg_partman | partman | table_privs | grantee + pg_partman | partman | table_privs | grantor + pg_partman | partman | table_privs | privilege_type + pg_partman | partman | table_privs | table_name + pg_partman | partman | table_privs | table_schema pg_repack | repack | primary_keys | indexrelid pg_repack | repack | primary_keys | indrelid pg_repack | repack | tables | alter_col_storage @@ -5294,5 +5395,5 @@ order by wrappers | public | wrappers_fdw_stats | rows_in wrappers | public | wrappers_fdw_stats | rows_out wrappers | public | wrappers_fdw_stats | updated_at -(387 rows) +(446 rows) diff --git a/nix/tests/expected/z_orioledb-17_ext_interface.out b/nix/tests/expected/z_orioledb-17_ext_interface.out index 46792e48f..fe5d15e8f 100644 --- a/nix/tests/expected/z_orioledb-17_ext_interface.out +++ b/nix/tests/expected/z_orioledb-17_ext_interface.out @@ -76,6 +76,7 @@ order by pg_hashids | t pg_jsonschema | f pg_net | f + pg_partman | f pg_prewarm | t pg_repack | f pg_stat_monitor | t @@ -115,7 +116,7 @@ order by vector | t wrappers | t xml2 | f -(72 rows) +(73 rows) /* @@ -155,8 +156,8 @@ order by n.nspname, p.proname, md5(pg_catalog.pg_get_function_identity_arguments(p.oid)); - extension_name | schema_name | function_name | argument_types | return_type -----------------------+----------------+--------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + extension_name | schema_name | function_name | argument_types | return_type +----------------------+----------------+--------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ address_standardizer | public | parse_address | text, OUT num text, OUT street text, OUT street2 text, OUT address1 text, OUT city text, OUT state text, OUT zip text, OUT zipplus text, OUT country text | record address_standardizer | public | standardize_address | lextab text, gaztab text, rultab text, address text | stdaddr address_standardizer | public | standardize_address | lextab text, gaztab text, rultab text, micro text, macro text | stdaddr @@ -1152,6 +1153,47 @@ order by pg_net | net | wait_until_running | | void pg_net | net | wake | | void pg_net | net | worker_restart | | boolean + pg_partman | public | apply_cluster | p_parent_schema text, p_parent_tablename text, p_child_schema text, p_child_tablename text | void + pg_partman | public | apply_constraints | p_parent_table text, p_child_table text, p_analyze boolean, p_job_id bigint | void + pg_partman | public | apply_privileges | p_parent_schema text, p_parent_tablename text, p_child_schema text, p_child_tablename text, p_job_id bigint | void + pg_partman | public | autovacuum_off | p_parent_schema text, p_parent_tablename text, p_source_schema text, p_source_tablename text | boolean + pg_partman | public | autovacuum_reset | p_parent_schema text, p_parent_tablename text, p_source_schema text, p_source_tablename text | boolean + pg_partman | public | calculate_time_partition_info | p_time_interval interval, p_start_time timestamp with time zone, p_date_trunc_interval text, OUT base_timestamp timestamp with time zone, OUT datetime_string text | record + pg_partman | public | check_automatic_maintenance_value | p_automatic_maintenance text | boolean + pg_partman | public | check_control_type | p_parent_schema text, p_parent_tablename text, p_control text | TABLE(general_type text, exact_type text) + pg_partman | public | check_default | p_exact_count boolean | SETOF check_default_table + pg_partman | public | check_epoch_type | p_type text | boolean + pg_partman | public | check_name_length | p_object_name text, p_suffix text, p_table_partition boolean | text + pg_partman | public | check_partition_type | p_type text | boolean + pg_partman | public | check_subpart_sameconfig | p_parent_table text | TABLE(sub_control text, sub_partition_interval text, sub_partition_type text, sub_premake integer, sub_automatic_maintenance text, sub_template_table text, sub_retention text, sub_retention_schema text, sub_retention_keep_index boolean, sub_retention_keep_table boolean, sub_epoch text, sub_constraint_cols text[], sub_optimize_constraint integer, sub_infinite_time_partitions boolean, sub_jobmon boolean, sub_inherit_privileges boolean, sub_constraint_valid boolean, sub_date_trunc_interval text, sub_ignore_default_data boolean, sub_default_table boolean, sub_maintenance_order integer, sub_retention_keep_publication boolean, sub_control_not_null boolean) + pg_partman | public | check_subpartition_limits | p_parent_table text, p_type text, OUT sub_min text, OUT sub_max text | record + pg_partman | public | create_parent | p_parent_table text, p_control text, p_interval text, p_type text, p_epoch text, p_premake integer, p_start_partition text, p_default_table boolean, p_automatic_maintenance text, p_constraint_cols text[], p_template_table text, p_jobmon boolean, p_date_trunc_interval text, p_control_not_null boolean, p_time_encoder text, p_time_decoder text | boolean + pg_partman | public | create_partition_id | p_parent_table text, p_partition_ids bigint[], p_start_partition text | boolean + pg_partman | public | create_partition_time | p_parent_table text, p_partition_times timestamp with time zone[], p_start_partition text | boolean + pg_partman | public | create_sub_parent | p_top_parent text, p_control text, p_interval text, p_type text, p_default_table boolean, p_declarative_check text, p_constraint_cols text[], p_premake integer, p_start_partition text, p_epoch text, p_jobmon boolean, p_date_trunc_interval text, p_control_not_null boolean, p_time_encoder text, p_time_decoder text | boolean + pg_partman | public | drop_constraints | p_parent_table text, p_child_table text, p_debug boolean | void + pg_partman | public | drop_partition_id | p_parent_table text, p_retention bigint, p_keep_table boolean, p_keep_index boolean, p_retention_schema text | integer + pg_partman | public | drop_partition_time | p_parent_table text, p_retention interval, p_keep_table boolean, p_keep_index boolean, p_retention_schema text, p_reference_timestamp timestamp with time zone | integer + pg_partman | public | dump_partitioned_table_definition | p_parent_table text, p_ignore_template_table boolean | text + pg_partman | public | inherit_replica_identity | p_parent_schemaname text, p_parent_tablename text, p_child_tablename text | void + pg_partman | public | inherit_template_properties | p_parent_table text, p_child_schema text, p_child_tablename text | boolean + pg_partman | public | partition_data_id | p_parent_table text, p_batch_count integer, p_batch_interval bigint, p_lock_wait numeric, p_order text, p_analyze boolean, p_source_table text, p_ignored_columns text[] | bigint + pg_partman | public | partition_data_proc | IN p_parent_table text, IN p_loop_count integer, IN p_interval text, IN p_lock_wait integer, IN p_lock_wait_tries integer, IN p_wait integer, IN p_order text, IN p_source_table text, IN p_ignored_columns text[], IN p_quiet boolean | + pg_partman | public | partition_data_time | p_parent_table text, p_batch_count integer, p_batch_interval interval, p_lock_wait numeric, p_order text, p_analyze boolean, p_source_table text, p_ignored_columns text[] | bigint + pg_partman | public | partition_gap_fill | p_parent_table text | integer + pg_partman | public | reapply_constraints_proc | IN p_parent_table text, IN p_drop_constraints boolean, IN p_apply_constraints boolean, IN p_wait integer, IN p_dryrun boolean | + pg_partman | public | reapply_privileges | p_parent_table text | void + pg_partman | public | run_analyze | IN p_skip_locked boolean, IN p_quiet boolean, IN p_parent_table text | + pg_partman | public | run_maintenance | p_parent_table text, p_analyze boolean, p_jobmon boolean | void + pg_partman | public | run_maintenance_proc | IN p_wait integer, IN p_analyze boolean, IN p_jobmon boolean | + pg_partman | public | show_partition_info | p_child_table text, p_partition_interval text, p_parent_table text, OUT child_start_time timestamp with time zone, OUT child_end_time timestamp with time zone, OUT child_start_id bigint, OUT child_end_id bigint, OUT suffix text | record + pg_partman | public | show_partition_name | p_parent_table text, p_value text, OUT partition_schema text, OUT partition_table text, OUT suffix_timestamp timestamp with time zone, OUT suffix_id bigint, OUT table_exists boolean | record + pg_partman | public | show_partitions | p_parent_table text, p_order text, p_include_default boolean | TABLE(partition_schemaname text, partition_tablename text) + pg_partman | public | stop_sub_partition | p_parent_table text, p_jobmon boolean | boolean + pg_partman | public | undo_partition | p_parent_table text, p_target_table text, p_loop_count integer, p_batch_interval text, p_keep_table boolean, p_lock_wait numeric, p_ignored_columns text[], p_drop_cascade boolean, OUT partitions_undone integer, OUT rows_undone bigint | record + pg_partman | public | undo_partition_proc | IN p_parent_table text, IN p_target_table text, IN p_loop_count integer, IN p_interval text, IN p_keep_table boolean, IN p_lock_wait integer, IN p_lock_wait_tries integer, IN p_wait integer, IN p_ignored_columns text[], IN p_drop_cascade boolean, IN p_quiet boolean | + pg_partman | public | uuid7_time_decoder | uuidv7 text | timestamp with time zone + pg_partman | public | uuid7_time_encoder | ts timestamp with time zone | uuid pg_prewarm | public | autoprewarm_dump_now | | bigint pg_prewarm | public | autoprewarm_start_worker | | void pg_prewarm | public | pg_prewarm | regclass, mode text, fork text, first_block bigint, last_block bigint | bigint @@ -4873,7 +4915,7 @@ order by xml2 | public | xpath_table | text, text, text, text, text | SETOF record xml2 | public | xslt_process | text, text | text xml2 | public | xslt_process | text, text, text | text -(4716 rows) +(4757 rows) /* @@ -4905,8 +4947,8 @@ order by n.nspname, pc.relname, pa.attname; - extension_name | schema_name | entity_name | attname -------------------------------+-------------+-------------------------+------------------------ + extension_name | schema_name | entity_name | attname +------------------------------+-------------+-------------------------+-------------------------------- address_standardizer_data_us | public | us_gaz | id address_standardizer_data_us | public | us_gaz | is_custom address_standardizer_data_us | public | us_gaz | seq @@ -4956,6 +4998,65 @@ order by pg_net | net | http_request_queue | method pg_net | net | http_request_queue | timeout_milliseconds pg_net | net | http_request_queue | url + pg_partman | public | part_config | automatic_maintenance + pg_partman | public | part_config | constraint_cols + pg_partman | public | part_config | constraint_valid + pg_partman | public | part_config | control + pg_partman | public | part_config | date_trunc_interval + pg_partman | public | part_config | datetime_string + pg_partman | public | part_config | epoch + pg_partman | public | part_config | ignore_default_data + pg_partman | public | part_config | infinite_time_partitions + pg_partman | public | part_config | inherit_privileges + pg_partman | public | part_config | jobmon + pg_partman | public | part_config | maintenance_last_run + pg_partman | public | part_config | maintenance_order + pg_partman | public | part_config | optimize_constraint + pg_partman | public | part_config | parent_table + pg_partman | public | part_config | partition_interval + pg_partman | public | part_config | partition_type + pg_partman | public | part_config | premake + pg_partman | public | part_config | retention + pg_partman | public | part_config | retention_keep_index + pg_partman | public | part_config | retention_keep_publication + pg_partman | public | part_config | retention_keep_table + pg_partman | public | part_config | retention_schema + pg_partman | public | part_config | sub_partition_set_full + pg_partman | public | part_config | template_table + pg_partman | public | part_config | time_decoder + pg_partman | public | part_config | time_encoder + pg_partman | public | part_config | undo_in_progress + pg_partman | public | part_config_sub | sub_automatic_maintenance + pg_partman | public | part_config_sub | sub_constraint_cols + pg_partman | public | part_config_sub | sub_constraint_valid + pg_partman | public | part_config_sub | sub_control + pg_partman | public | part_config_sub | sub_control_not_null + pg_partman | public | part_config_sub | sub_date_trunc_interval + pg_partman | public | part_config_sub | sub_default_table + pg_partman | public | part_config_sub | sub_epoch + pg_partman | public | part_config_sub | sub_ignore_default_data + pg_partman | public | part_config_sub | sub_infinite_time_partitions + pg_partman | public | part_config_sub | sub_inherit_privileges + pg_partman | public | part_config_sub | sub_jobmon + pg_partman | public | part_config_sub | sub_maintenance_order + pg_partman | public | part_config_sub | sub_optimize_constraint + pg_partman | public | part_config_sub | sub_parent + pg_partman | public | part_config_sub | sub_partition_interval + pg_partman | public | part_config_sub | sub_partition_type + pg_partman | public | part_config_sub | sub_premake + pg_partman | public | part_config_sub | sub_retention + pg_partman | public | part_config_sub | sub_retention_keep_index + pg_partman | public | part_config_sub | sub_retention_keep_publication + pg_partman | public | part_config_sub | sub_retention_keep_table + pg_partman | public | part_config_sub | sub_retention_schema + pg_partman | public | part_config_sub | sub_template_table + pg_partman | public | part_config_sub | sub_time_decoder + pg_partman | public | part_config_sub | sub_time_encoder + pg_partman | public | table_privs | grantee + pg_partman | public | table_privs | grantor + pg_partman | public | table_privs | privilege_type + pg_partman | public | table_privs | table_name + pg_partman | public | table_privs | table_schema pg_repack | repack | primary_keys | indexrelid pg_repack | repack | primary_keys | indrelid pg_repack | repack | tables | alter_col_storage @@ -5294,5 +5395,5 @@ order by wrappers | public | wrappers_fdw_stats | rows_in wrappers | public | wrappers_fdw_stats | rows_out wrappers | public | wrappers_fdw_stats | updated_at -(387 rows) +(446 rows) diff --git a/nix/tests/postgresql.conf.in b/nix/tests/postgresql.conf.in index e4f844d07..de024ea8f 100644 --- a/nix/tests/postgresql.conf.in +++ b/nix/tests/postgresql.conf.in @@ -718,7 +718,7 @@ default_text_search_config = 'pg_catalog.english' #local_preload_libraries = '' #session_preload_libraries = '' -shared_preload_libraries = 'pg_stat_statements, pgaudit, plpgsql, plpgsql_check, pg_cron, pg_net, pgsodium, timescaledb, auto_explain, pg_tle, plan_filter, supabase_vault' # (change requires restart) +shared_preload_libraries = 'pg_stat_statements, pgaudit, plpgsql, plpgsql_check, pg_cron, pg_net, pgsodium, timescaledb, auto_explain, pg_tle, plan_filter, supabase_vault, pg_partman_bgw' # (change requires restart) jit_provider = 'llvmjit' # JIT library to use diff --git a/nix/tests/prime.sql b/nix/tests/prime.sql index fb724847f..5ae47444e 100644 --- a/nix/tests/prime.sql +++ b/nix/tests/prime.sql @@ -46,6 +46,8 @@ create extension if not exists pg_hashids; create extension if not exists pg_prewarm; create extension if not exists pgmq; create extension if not exists pg_jsonschema; +create schema if not exists partman; +create extension if not exists pg_partman with schema partman; create extension if not exists pg_repack; create extension if not exists pg_stat_monitor; create extension if not exists pg_stat_statements; diff --git a/nix/tests/sql/pg_partman.sql b/nix/tests/sql/pg_partman.sql new file mode 100644 index 000000000..bb018460d --- /dev/null +++ b/nix/tests/sql/pg_partman.sql @@ -0,0 +1,20 @@ +CREATE SCHEMA IF NOT EXISTS partman_test; + +CREATE TABLE partman_test.time_taptest_table + (col1 int, + col2 text default 'stuff', + col3 timestamptz NOT NULL DEFAULT now()) +PARTITION BY RANGE (col3); + +CREATE INDEX ON partman_test.time_taptest_table (col3); + +CREATE TABLE partman_test.time_taptest_table_template (LIKE partman_test.time_taptest_table); + +ALTER TABLE partman_test.time_taptest_table_template ADD PRIMARY KEY (col1); + +SELECT partman.create_parent( + p_parent_table := 'partman_test.time_taptest_table' + , p_control := 'col3' + , p_interval := '1 day' + , p_template_table := 'partman_test.time_taptest_table_template' +); diff --git a/nix/tests/sql/z_15_unhype_timescale_to_partman.sql b/nix/tests/sql/z_15_unhype_timescale_to_partman.sql new file mode 100644 index 000000000..795e3ae54 --- /dev/null +++ b/nix/tests/sql/z_15_unhype_timescale_to_partman.sql @@ -0,0 +1,58 @@ +/* + +The purpose of this test is to validate the method of moving from Timescale Hypertables to Postgres native partitioned tables +managed by pg_partman + +*/ + +CREATE SCHEMA ts; + +-- Create a table for time-series data +CREATE TABLE ts.readings ( + time TIMESTAMPTZ NOT NULL, + sensor_id INT NOT NULL, + value DOUBLE PRECISION NOT NULL +); + +-- Convert the table into a hypertable +SELECT create_hypertable('ts.readings', by_range('time', INTERVAL '1 day')); + +-- Convert default 7 day chunk interval +SELECT set_chunk_time_interval('ts.readings', INTERVAL '24 hours'); + +-- Insert sample data +INSERT INTO ts.readings (time, sensor_id, value) +SELECT + time_series AS time, + FLOOR(RANDOM() * 10 + 1)::INT AS sensor_id, -- Random sensor_id between 1 and 10 + RANDOM() * 100 AS value -- Random value between 0 and 100 +FROM + generate_series( + '2023-01-19 00:00:00+00'::TIMESTAMPTZ, + '2025-03-26 03:00:00+00'::TIMESTAMPTZ, + INTERVAL '1 second' + ) AS time_series +LIMIT 600000; + +-- List hypertables +SELECT * FROM timescaledb_information.hypertables; + +-- Rename hypertable +ALTER TABLE ts.readings RENAME TO ht_readings; + +-- Create copy of hypertable with original name +CREATE TABLE ts.readings (LIKE ts.ht_readings) PARTITION BY RANGE(time); + +-- Configure pg_partman for daily partitions on sensor_data +SELECT partman.create_parent( + p_parent_table := 'ts.readings', + p_control := 'time', + p_type := 'range', + p_interval := '1 day', + p_premake := 7, -- Create partitions for the next 7 days + p_start_partition := '2023-01-19 00:00:00+00' -- Start date for partitioning +); + +INSERT INTO ts.readings SELECT * FROM ts.ht_readings; + +DROP SCHEMA ts CASCADE; \ No newline at end of file diff --git a/nix/tools/sync-exts-versions.sh.in b/nix/tools/sync-exts-versions.sh.in index 1b120e988..39cf43958 100644 --- a/nix/tools/sync-exts-versions.sh.in +++ b/nix/tools/sync-exts-versions.sh.in @@ -175,6 +175,11 @@ for key in $keys; do package_name="pg-safeupdate" run_sync $varname $package_name ;; + "pg_partman_release") + varname="pg_partman_release" + package_name="pg_partman" + run_sync $varname $package_name + ;; "pgsodium_release") varname="pgsodium_release" package_name="pgsodium"