Skip to content

Commit 73e0b26

Browse files
committed
Merge branch 'rel_future_beta' into rel_future_strings
2 parents 3410d7d + 0a0d2cf commit 73e0b26

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+4566
-6074
lines changed

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
pg_pathman*.sql linguist-vendored=true
2+
*.h linguist-language=C
3+
*.c linguist-language=C
4+
*.spec linguist-vendored=true

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ regression.out
88
*.pyc
99
*.gcda
1010
*.gcno
11-
pg_pathman--1.2.sql
11+
*.gcov
12+
pg_pathman--*.sql

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ env:
2020
- PGVERSION=9.5 CHECK_CODE=false
2121

2222
script: bash ./travis/pg-travis-test.sh
23+
24+
after_success:
25+
- bash <(curl -s https://codecov.io/bash)

Makefile

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,45 @@
11
# contrib/pg_pathman/Makefile
22

33
MODULE_big = pg_pathman
4+
45
OBJS = src/init.o src/relation_info.o src/utils.o src/partition_filter.o \
56
src/runtimeappend.o src/runtime_merge_append.o src/pg_pathman.o src/rangeset.o \
67
src/pl_funcs.o src/pl_range_funcs.o src/pl_hash_funcs.o src/pathman_workers.o \
78
src/hooks.o src/nodes_common.o src/xact_handling.o src/utility_stmt_hooking.o \
8-
src/planner_tree_modification.o src/debug_print.o src/pg_compat.o \
9-
src/partition_creation.o $(WIN32RES)
9+
src/planner_tree_modification.o src/debug_print.o src/partition_creation.o \
10+
src/compat/pg_compat.o $(WIN32RES)
11+
12+
PG_CPPFLAGS = -I$(CURDIR)/src/include
1013

1114
EXTENSION = pg_pathman
12-
EXTVERSION = 1.2
15+
16+
EXTVERSION = 1.3
17+
1318
DATA_built = pg_pathman--$(EXTVERSION).sql
14-
DATA = pg_pathman--1.0.sql \
15-
pg_pathman--1.0--1.1.sql \
16-
pg_pathman--1.1.sql \
17-
pg_pathman--1.1--1.2.sql
19+
20+
DATA = pg_pathman--1.0--1.1.sql \
21+
pg_pathman--1.1--1.2.sql \
22+
pg_pathman--1.2--1.3.sql
23+
1824
PGFILEDESC = "pg_pathman - partitioning tool"
1925

2026
REGRESS = pathman_basic \
27+
pathman_cte \
28+
pathman_bgw \
2129
pathman_inserts \
22-
pathman_runtime_nodes \
23-
pathman_callbacks \
30+
pathman_updates \
2431
pathman_domains \
32+
pathman_interval \
33+
pathman_callbacks \
2534
pathman_foreign_keys \
2635
pathman_permissions \
2736
pathman_rowmarks \
37+
pathman_runtime_nodes \
2838
pathman_utility_stmt_hooking \
2939
pathman_calamity
40+
3041
EXTRA_REGRESS_OPTS=--temp-config=$(top_srcdir)/$(subdir)/conf.add
42+
3143
EXTRA_CLEAN = pg_pathman--$(EXTVERSION).sql ./isolation_output
3244

3345
ifdef USE_PGXS

README.md

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[![Build Status](https://travis-ci.org/postgrespro/pg_pathman.svg?branch=master)](https://travis-ci.org/postgrespro/pg_pathman)
22
[![PGXN version](https://badge.fury.io/pg/pg_pathman.svg)](https://badge.fury.io/pg/pg_pathman)
3+
[![codecov](https://codecov.io/gh/postgrespro/pg_pathman/branch/master/graph/badge.svg)](https://codecov.io/gh/postgrespro/pg_pathman)
34

45
# pg_pathman
56

@@ -77,14 +78,29 @@ Done! Now it's time to setup your partitioning schemes.
7778

7879
> **Important:** Don't forget to set the `PG_CONFIG` variable in case you want to test `pg_pathman` on a custom build of PostgreSQL. Read more [here](https://wiki.postgresql.org/wiki/Building_and_Installing_PostgreSQL_Extension_Modules).
7980
81+
## How to update
82+
In order to update pg_pathman:
83+
84+
1. Install the latest _stable_ release of pg_pathman.
85+
2. Restart your PostgreSQL cluster.
86+
3. Execute the following queries:
87+
88+
```plpgsql
89+
/* replace X.Y with the version number, e.g. 1.3 */
90+
ALTER EXTENSION pg_pathman UPDATE TO "X.Y";
91+
SET pg_pathman.enable = t;
92+
```
93+
8094
## Available functions
8195

8296
### Partition creation
8397
```plpgsql
8498
create_hash_partitions(relation REGCLASS,
8599
attribute TEXT,
86100
partitions_count INTEGER,
87-
partition_data BOOLEAN DEFAULT TRUE)
101+
partition_data BOOLEAN DEFAULT TRUE,
102+
partition_names TEXT[] DEFAULT NULL,
103+
tablespaces TEXT[] DEFAULT NULL)
88104
```
89105
Performs HASH partitioning for `relation` by integer key `attribute`. The `partitions_count` parameter specifies the number of partitions to create; it cannot be changed afterwards. If `partition_data` is `true` then all the data will be automatically copied from the parent table to partitions. Note that data migration may took a while to finish and the table will be locked until transaction commits. See `partition_table_concurrently()` for a lock-free way to migrate data. Partition creation callback is invoked for each partition if set beforehand (see `set_init_callback()`).
90106

@@ -103,7 +119,7 @@ create_range_partitions(relation REGCLASS,
103119
p_count INTEGER DEFAULT NULL,
104120
partition_data BOOLEAN DEFAULT TRUE)
105121
```
106-
Performs RANGE partitioning for `relation` by partitioning key `attribute`. `start_value` argument specifies initial value, `interval` sets the range of values in a single partition, `count` is the number of premade partitions (if not set then pathman tries to determine it based on attribute values). Partition creation callback is invoked for each partition if set beforehand.
122+
Performs RANGE partitioning for `relation` by partitioning key `attribute`, `start_value` argument specifies initial value, `p_interval` sets the default range for auto created partitions or partitions created with `append_range_partition()` or `prepend_range_partition()` (if `NULL` then auto partition creation feature won't work), `p_count` is the number of premade partitions (if not set then `pg_pathman` tries to determine it based on attribute values). Partition creation callback is invoked for each partition if set beforehand.
107123

108124
```plpgsql
109125
create_partitions_from_range(relation REGCLASS,
@@ -148,9 +164,9 @@ Same as above, but for a RANGE-partitioned table.
148164

149165
### Post-creation partition management
150166
```plpgsql
151-
replace_hash_partition(old_partition REGCLASS,
152-
new_partition REGCLASS,
153-
lock_parent BOOL DEFAULT TRUE)
167+
replace_hash_partition(old_partition REGCLASS,
168+
new_partition REGCLASS,
169+
lock_parent BOOL DEFAULT TRUE)
154170
```
155171
Replaces specified partition of HASH-partitioned table with another table. The `lock_parent` parameter will prevent any INSERT/UPDATE/ALTER TABLE queries to parent table.
156172

@@ -167,6 +183,11 @@ merge_range_partitions(partition1 REGCLASS, partition2 REGCLASS)
167183
```
168184
Merge two adjacent RANGE partitions. First, data from `partition2` is copied to `partition1`, then `partition2` is removed.
169185

186+
```plpgsql
187+
merge_range_partitions(partitions REGCLASS[])
188+
```
189+
Merge several adjacent RANGE partitions (partitions must be specified in ascending or descending order). All the data will be accumulated in the first partition.
190+
170191
```plpgsql
171192
append_range_partition(parent REGCLASS,
172193
partition_name TEXT DEFAULT NULL,
@@ -188,7 +209,7 @@ add_range_partition(relation REGCLASS,
188209
partition_name TEXT DEFAULT NULL,
189210
tablespace TEXT DEFAULT NULL)
190211
```
191-
Create new RANGE partition for `relation` with specified range bounds.
212+
Create new RANGE partition for `relation` with specified range bounds. If `start_value` or `end_value` are NULL then corresponding range bound will be infinite.
192213

193214
```plpgsql
194215
drop_range_partition(partition TEXT, delete_data BOOLEAN DEFAULT TRUE)
@@ -222,6 +243,12 @@ Drop partitions of the `parent` table (both foreign and local relations). If `de
222243

223244
### Additional parameters
224245

246+
247+
```plpgsql
248+
set_interval(relation REGCLASS, value ANYELEMENT)
249+
```
250+
Update RANGE partitioned table interval. Note that interval must not be negative and it must not be trivial, i.e. its value should be greater than zero for numeric types, at least 1 microsecond for `TIMESTAMP` and at least 1 day for `DATE`.
251+
225252
```plpgsql
226253
set_enable_parent(relation REGCLASS, value BOOLEAN)
227254
```
@@ -240,17 +267,21 @@ Set partition creation callback to be invoked for each attached or created parti
240267
/* RANGE-partitioned table abc (child abc_4) */
241268
{
242269
"parent": "abc",
270+
"parent_schema": "public",
243271
"parttype": "2",
244272
"partition": "abc_4",
273+
"partition_schema": "public",
245274
"range_max": "401",
246275
"range_min": "301"
247276
}
248277

249278
/* HASH-partitioned table abc (child abc_0) */
250279
{
251280
"parent": "abc",
281+
"parent_schema": "public",
252282
"parttype": "1",
253283
"partition": "abc_0"
284+
"partition_schema": "public"
254285
}
255286
```
256287

@@ -641,3 +672,4 @@ Do not hesitate to post your issues, questions and new ideas at the [issues](htt
641672
Ildar Musin <i.musin@postgrespro.ru> Postgres Professional Ltd., Russia
642673
Alexander Korotkov <a.korotkov@postgrespro.ru> Postgres Professional Ltd., Russia
643674
Dmitry Ivanov <d.ivanov@postgrespro.ru> Postgres Professional Ltd., Russia
675+

0 commit comments

Comments
 (0)