-- scenario of partition naming causing typname collisions until failure to create partition
CREATE TABLE randomstate_sales_figures_measurements_part_by_days (
    logdate           date not null,
    sales_figures     int
) PARTITION BY RANGE (logdate);

CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m01d01 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-01-01') TO ('2006-01-02');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m01d02 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-01-02') TO ('2006-01-03');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m01d03 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-01-03') TO ('2006-01-04');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m01d04 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-01-04') TO ('2006-01-05');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m01d05 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-01-05') TO ('2006-01-06');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m01d06 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-01-06') TO ('2006-01-07');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m01d07 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-01-07') TO ('2006-01-08');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m01d08 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-01-08') TO ('2006-01-09');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m01d09 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-01-09') TO ('2006-01-10');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m01d10 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-01-10') TO ('2006-01-11');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m01d11 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-01-11') TO ('2006-01-12');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m01d12 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-01-12') TO ('2006-01-13');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m01d13 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-01-13') TO ('2006-01-14');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m01d14 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-01-14') TO ('2006-01-15');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m01d15 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-01-15') TO ('2006-01-16');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m01d16 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-01-16') TO ('2006-01-17');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m01d17 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-01-17') TO ('2006-01-18');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m01d18 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-01-18') TO ('2006-01-19');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m01d19 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-01-19') TO ('2006-01-20');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m01d20 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-01-20') TO ('2006-01-21');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m01d21 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-01-21') TO ('2006-01-22');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m01d22 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-01-22') TO ('2006-01-23');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m01d23 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-01-23') TO ('2006-01-24');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m01d24 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-01-24') TO ('2006-01-25');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m01d25 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-01-25') TO ('2006-01-26');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m01d26 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-01-26') TO ('2006-01-27');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m01d27 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-01-27') TO ('2006-01-28');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m01d28 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-01-28') TO ('2006-01-29');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m01d29 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-01-29') TO ('2006-01-30');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m01d30 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-01-30') TO ('2006-01-31');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m01d31 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-01-31') TO ('2006-02-01');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m02d01 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-02-01') TO ('2006-02-02');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m02d02 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-02-02') TO ('2006-02-03');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m02d03 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-02-03') TO ('2006-02-04');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m02d04 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-02-04') TO ('2006-02-05');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m02d05 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-02-05') TO ('2006-02-06');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m02d06 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-02-06') TO ('2006-02-07');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m02d07 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-02-07') TO ('2006-02-08');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m02d08 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-02-08') TO ('2006-02-09');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m02d09 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-02-09') TO ('2006-02-10');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m02d10 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-02-10') TO ('2006-02-11');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m02d11 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-02-11') TO ('2006-02-12');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m02d12 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-02-12') TO ('2006-02-13');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m02d13 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-02-13') TO ('2006-02-14');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m02d14 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-02-14') TO ('2006-02-15');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m02d15 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-02-15') TO ('2006-02-16');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m02d16 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-02-16') TO ('2006-02-17');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m02d17 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-02-17') TO ('2006-02-18');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m02d18 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-02-18') TO ('2006-02-19');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m02d19 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-02-19') TO ('2006-02-20');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m02d20 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-02-20') TO ('2006-02-21');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m02d21 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-02-21') TO ('2006-02-22');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m02d22 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-02-22') TO ('2006-02-23');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m02d23 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-02-23') TO ('2006-02-24');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m02d24 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-02-24') TO ('2006-02-25');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m02d25 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-02-25') TO ('2006-02-26');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m02d26 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-02-26') TO ('2006-02-27');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m02d27 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-02-27') TO ('2006-02-28');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m02d28 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-02-28') TO ('2006-03-01');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m03d01 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-03-01') TO ('2006-03-02');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m03d02 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-03-02') TO ('2006-03-03');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m03d03 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-03-03') TO ('2006-03-04');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m03d04 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-03-04') TO ('2006-03-05');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m03d05 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-03-05') TO ('2006-03-06');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m03d06 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-03-06') TO ('2006-03-07');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m03d07 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-03-07') TO ('2006-03-08');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m03d08 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-03-08') TO ('2006-03-09');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m03d09 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-03-09') TO ('2006-03-10');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m03d10 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-03-10') TO ('2006-03-11');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m03d11 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-03-11') TO ('2006-03-12');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m03d12 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-03-12') TO ('2006-03-13');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m03d13 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-03-13') TO ('2006-03-14');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m03d14 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-03-14') TO ('2006-03-15');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m03d15 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-03-15') TO ('2006-03-16');

-- These two will not be able to be created because of typname collisions
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m03d16 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-03-16') TO ('2006-03-17');
CREATE TABLE randomstate_sales_figures_measurements_part_by_days_y2006m03d17 PARTITION OF randomstate_sales_figures_measurements_part_by_days
    FOR VALUES FROM ('2006-03-17') TO ('2006-03-18');

-- The array type's typname primarily consists of underscores
select * from pg_type where typelem = (select oid from pg_type where typname = 'randomstate_sales_figures_measurements_part_by_days_y2006m03d14');
select * from pg_type where typelem = (select oid from pg_type where typname = 'randomstate_sales_figures_measurements_part_by_days_y2006m03d15');
