Skip to content

Error while creating nested partition with pg_partman #870

Description

@jakubmalek

With latest 5.4.3 version pg_partman, I'm unable to create range partition for child-partition table.

Here is an example of the initial setup:

CREATE TYPE retention_tier AS ENUM (
  'standard',
  'extended'
);

CREATE TABLE IF NOT EXISTS events (
    id BIGSERIAL NOT NULL,
    retention_tier retention_tier NOT NULL,
    event_time TIMESTAMPTZ NOT NULL,
    data JSONB NOT NULL
) PARTITION BY LIST (retention_tier);

CREATE TABLE events_standard PARTITION OF events
    FOR VALUES IN ('standard')
    PARTITION BY RANGE (event_time);
CREATE TABLE events_extended PARTITION OF events
    FOR VALUES IN ('extended')
    PARTITION BY RANGE (event_time);

Then when I try to create partition for events_standard table:

SELECT create_partition(
    p_parent_table => 'public.events_standard',
    p_control => 'event_time',
    p_interval=> '1 day',
    p_type => 'range',
    p_premake => 3,
    p_constraint_cols => ARRAY['id']);

I get following error:

ERROR:  invalid input syntax for type timestamp with time zone: "'standard'"
CONTEXT: PL/pgSQL function show_partition_info(text,text,text,boolean) line 130 at assignment
SQL statement "SELECT child_start_time::text, child_end_time::text
                                      FROM public.show_partition_info(p_parent_table, v_top_interval, v_top_schema||'.'||v_top_tablename)"
PL/pgSQL function check_subpartition_limits(text,text) line 52 at SQL statement
SQL statement "SELECT sub_min::timestamptz, sub_max::timestamptz                                               FROM public.check_subpartition_limits(p_parent_table, 'time')"
PL/pgSQL function create_partition_time(text,timestamp with time zone[],text) line 105 at SQL statement
PL/pgSQL function create_partition(text,text,text,text,text,integer,text,boolean,text,text[],text,boolean,text,boolean,text,text,bigint) line 383 at assignment
DETAIL:
HINT:
CONTEXT: PL/pgSQL function create_partition_time(text,timestamp with time zone[],text) line 401 at RAISE
PL/pgSQL function create_partition(text,text,text,text,text,integer,text,boolean,text,text[],text,boolean,text,boolean,text,text,bigint) line 383 at assignment
DETAIL:
HINT:
CONTEXT:  PL/pgSQL function create_partition(text,text,text,text,text,integer,text,boolean,text,text[],text,boolean,text,boolean,text,text,bigint) line 638 at RAISE

It looks like partman is trying to parse parent partitioning column as timestamp, which fails.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions