Skip to content

Commit 8ef6541

Browse files
committed
tests added
1 parent 635bfc1 commit 8ef6541

File tree

3 files changed

+66
-3
lines changed

3 files changed

+66
-3
lines changed

contrib/test_partitioning/expected/partition.out

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,53 @@ SELECT * FROM pathman_partition_list;
8585
abc | abc_2 | 1 | id | |
8686
(3 rows)
8787

88+
DROP TABLE abc CASCADE;
89+
NOTICE: drop cascades to 3 other objects
90+
CREATE TABLE abc(id serial);
91+
INSERT INTO abc SELECT generate_series(1, 1000);
92+
ALTER TABLE abc PARTITION BY RANGE (id) START FROM (1) INTERVAL (100);
93+
SELECT * FROM pathman_partition_list;
94+
parent | partition | parttype | partattr | range_min | range_max
95+
--------+-----------+----------+----------+-----------+-----------
96+
abc | abc_11 | 2 | id | NULL | 1
97+
abc | abc_1 | 2 | id | 1 | 101
98+
abc | abc_2 | 2 | id | 101 | 201
99+
abc | abc_3 | 2 | id | 201 | 301
100+
abc | abc_4 | 2 | id | 301 | 401
101+
abc | abc_5 | 2 | id | 401 | 501
102+
abc | abc_6 | 2 | id | 501 | 601
103+
abc | abc_7 | 2 | id | 601 | 701
104+
abc | abc_8 | 2 | id | 701 | 801
105+
abc | abc_9 | 2 | id | 801 | 901
106+
abc | abc_10 | 2 | id | 901 | 1001
107+
(11 rows)
108+
109+
SELECT drop_partitions('abc');
110+
NOTICE: function public.abc_upd_trig_func() does not exist, skipping
111+
NOTICE: 100 rows copied from abc_1
112+
NOTICE: 100 rows copied from abc_2
113+
NOTICE: 100 rows copied from abc_3
114+
NOTICE: 100 rows copied from abc_4
115+
NOTICE: 100 rows copied from abc_5
116+
NOTICE: 100 rows copied from abc_6
117+
NOTICE: 100 rows copied from abc_7
118+
NOTICE: 100 rows copied from abc_8
119+
NOTICE: 100 rows copied from abc_9
120+
NOTICE: 100 rows copied from abc_10
121+
NOTICE: 0 rows copied from abc_11
122+
drop_partitions
123+
-----------------
124+
11
125+
(1 row)
126+
127+
ALTER TABLE abc PARTITION BY HASH (id) PARTITIONS (3);
128+
SELECT * FROM pathman_partition_list;
129+
parent | partition | parttype | partattr | range_min | range_max
130+
--------+-----------+----------+----------+-----------+-----------
131+
abc | abc_0 | 1 | id | |
132+
abc | abc_1 | 1 | id | |
133+
abc | abc_2 | 1 | id | |
134+
(3 rows)
135+
136+
DROP TABLE abc CASCADE;
137+
NOTICE: drop cascades to 3 other objects

contrib/test_partitioning/sql/partition.sql

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,17 @@ CREATE TABLE abc(id serial)
6161
PARTITION BY HASH (id) PARTITIONS (3);
6262

6363
SELECT * FROM pathman_partition_list;
64+
65+
DROP TABLE abc CASCADE;
66+
67+
CREATE TABLE abc(id serial);
68+
INSERT INTO abc SELECT generate_series(1, 1000);
69+
70+
ALTER TABLE abc PARTITION BY RANGE (id) START FROM (1) INTERVAL (100);
71+
SELECT * FROM pathman_partition_list;
72+
SELECT drop_partitions('abc');
73+
74+
ALTER TABLE abc PARTITION BY HASH (id) PARTITIONS (3);
75+
SELECT * FROM pathman_partition_list;
76+
77+
DROP TABLE abc CASCADE;

src/backend/commands/partition.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ create_range_partitions(PartitionInfo *pinfo,
179179
* Start value. It is always non-NULL whenever partition_data = True.
180180
* Otherwise the actual start value doesn't matter
181181
*/
182-
Assert(pinfo->start_value != NULL && partition_data != PDT_NONE);
182+
Assert((pinfo->start_value == NULL) == (partition_data == PDT_NONE));
183183
if (pinfo->start_value)
184184
{
185185
Node *n = cookPartitionKeyValue(relid,
@@ -234,7 +234,6 @@ create_range_partitions(PartitionInfo *pinfo,
234234
*/
235235
if (pinfo->start_value)
236236
{
237-
238237
pm_add_range_partition(relid,
239238
atttype,
240239
NULL,
@@ -248,7 +247,7 @@ create_range_partitions(PartitionInfo *pinfo,
248247

249248

250249
/*
251-
* Converts
250+
* Converts interval from Value
252251
*/
253252
static void
254253
read_interval_value(PartitionInfo *pinfo,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy