Skip to content

Commit

Permalink
Fix declarative test on pg11
Browse files Browse the repository at this point in the history
  • Loading branch information
ildus committed Oct 4, 2018
1 parent 740239f commit e06bbc7
Showing 1 changed file with 100 additions and 0 deletions.
100 changes: 100 additions & 0 deletions expected/pathman_declarative_1.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
\set VERBOSITY terse
SET search_path = 'public';
CREATE SCHEMA pathman;
CREATE EXTENSION pg_pathman SCHEMA pathman;
CREATE SCHEMA test;
CREATE TABLE test.range_rel (
id SERIAL PRIMARY KEY,
dt DATE NOT NULL
);
CREATE TABLE test.r2 (LIKE test.range_rel);
ALTER TABLE test.range_rel ATTACH PARTITION test.r2
FOR VALUES FROM ('2015-05-01') TO ('2015-06-01');
ERROR: table "range_rel" is not partitioned
INSERT INTO test.range_rel (dt)
SELECT g FROM generate_series('2015-01-01', '2015-04-30', '1 day'::interval) AS g;
SELECT pathman.create_range_partitions('test.range_rel', 'dt',
'2015-01-01'::DATE, '1 month'::INTERVAL);
create_range_partitions
-------------------------
4
(1 row)

SELECT * FROM pathman.pathman_partition_list;
parent | partition | parttype | expr | range_min | range_max
----------------+------------------+----------+------+------------+------------
test.range_rel | test.range_rel_1 | 2 | dt | 01-01-2015 | 02-01-2015
test.range_rel | test.range_rel_2 | 2 | dt | 02-01-2015 | 03-01-2015
test.range_rel | test.range_rel_3 | 2 | dt | 03-01-2015 | 04-01-2015
test.range_rel | test.range_rel_4 | 2 | dt | 04-01-2015 | 05-01-2015
(4 rows)

ALTER TABLE test.range_rel ATTACH PARTITION test.r2
FOR VALUES IN ('2015-05-01', '2015-06-01');
ERROR: pg_pathman only supports queries for range partitions
ALTER TABLE test.range_rel ATTACH PARTITION test.r2
FOR VALUES FROM ('2014-05-01') TO ('2015-06-01');
ERROR: specified range [05-01-2014, 06-01-2015) overlaps with existing partitions
ALTER TABLE test.range_rel ATTACH PARTITION test.r2
FOR VALUES FROM ('2015-05-01') TO ('2015-06-01');
SELECT * FROM pathman.pathman_partition_list;
parent | partition | parttype | expr | range_min | range_max
----------------+------------------+----------+------+------------+------------
test.range_rel | test.range_rel_1 | 2 | dt | 01-01-2015 | 02-01-2015
test.range_rel | test.range_rel_2 | 2 | dt | 02-01-2015 | 03-01-2015
test.range_rel | test.range_rel_3 | 2 | dt | 03-01-2015 | 04-01-2015
test.range_rel | test.range_rel_4 | 2 | dt | 04-01-2015 | 05-01-2015
test.range_rel | test.r2 | 2 | dt | 05-01-2015 | 06-01-2015
(5 rows)

\d+ test.r2;
Table "test.r2"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
--------+---------+-----------+----------+---------+---------+--------------+-------------
id | integer | | not null | | plain | |
dt | date | | not null | | plain | |
Check constraints:
"pathman_r2_check" CHECK (dt >= '05-01-2015'::date AND dt < '06-01-2015'::date)
Inherits: test.range_rel

ALTER TABLE test.range_rel DETACH PARTITION test.r2;
SELECT * FROM pathman.pathman_partition_list;
parent | partition | parttype | expr | range_min | range_max
----------------+------------------+----------+------+------------+------------
test.range_rel | test.range_rel_1 | 2 | dt | 01-01-2015 | 02-01-2015
test.range_rel | test.range_rel_2 | 2 | dt | 02-01-2015 | 03-01-2015
test.range_rel | test.range_rel_3 | 2 | dt | 03-01-2015 | 04-01-2015
test.range_rel | test.range_rel_4 | 2 | dt | 04-01-2015 | 05-01-2015
(4 rows)

\d+ test.r2;
Table "test.r2"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
--------+---------+-----------+----------+---------+---------+--------------+-------------
id | integer | | not null | | plain | |
dt | date | | not null | | plain | |

CREATE TABLE test.r4 PARTITION OF test.range_rel
FOR VALUES IN ('2015-05-01', '2015-06-01');
ERROR: pg_pathman only supports queries for range partitions
CREATE TABLE test.r4 PARTITION OF test.range_rel
FOR VALUES FROM ('2014-05-01') TO ('2015-06-01');
ERROR: specified range [05-01-2014, 06-01-2015) overlaps with existing partitions
CREATE TABLE test.r4 PARTITION OF test.range_rel
FOR VALUES FROM ('2015-06-01') TO ('2016-01-01');
\d+ test.r4;
Table "test.r4"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
--------+---------+-----------+----------+--------------------------------------------+---------+--------------+-------------
id | integer | | not null | nextval('test.range_rel_id_seq'::regclass) | plain | |
dt | date | | not null | | plain | |
Indexes:
"r4_pkey" PRIMARY KEY, btree (id)
Check constraints:
"pathman_r4_check" CHECK (dt >= '06-01-2015'::date AND dt < '01-01-2016'::date)
Inherits: test.range_rel

DROP SCHEMA test CASCADE;
NOTICE: drop cascades to 8 other objects
DROP EXTENSION pg_pathman CASCADE;
DROP SCHEMA pathman CASCADE;

0 comments on commit e06bbc7

Please sign in to comment.