Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit35509c0

Browse files
committed
lots of bugfixes and improvements from internal repository
1 parenta1580d5 commit35509c0

16 files changed

+1680
-374
lines changed

‎Makefile

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# contrib/pg_pathman/Makefile
22

33
MODULE_big = pg_pathman
4-
OBJS = init.o pg_pathman.o dsm_array.o rangeset.o pl_funcs.o$(WIN32RES)
4+
OBJS = init.o pg_pathman.o dsm_array.o rangeset.o pl_funcs.oworker.o$(WIN32RES)
55

66
EXTENSION = pg_pathman
77
EXTVERSION = 0.1
88
DATA_built =$(EXTENSION)--$(EXTVERSION).sql
99
PGFILEDESC = "pg_pathman - partitioning tool"
1010

11-
EXTRA_REGRESS_OPTS=--temp-config=$(top_srcdir)/$(subdir)/conf.add
1211
REGRESS = pg_pathman
13-
EXTRA_CLEAN =$(EXTENSION)--$(EXTVERSION).sql
12+
EXTRA_REGRESS_OPTS=--temp-config=$(top_srcdir)/$(subdir)/conf.add
13+
EXTRA_CLEAN =$(EXTENSION)--$(EXTVERSION).sql ./isolation_output
1414

1515
ifdefUSE_PGXS
1616
PG_CONFIG = pg_config
@@ -25,7 +25,15 @@ endif
2525

2626
$(EXTENSION)--$(EXTVERSION).sql: init.sql hash.sql range.sql
2727
cat$^>$@
28-
EXTRA_REGRESS_OPTS=--temp-config=$(top_srcdir)/$(subdir)/conf.add
2928

30-
# installcheck:
31-
# true
29+
ISOLATIONCHECKS=insert_trigger
30+
31+
submake-isolation:
32+
$(MAKE) -C$(top_builddir)/src/test/isolation all
33+
34+
isolationcheck: | submake-isolation
35+
$(MKDIR_P) isolation_output
36+
$(pg_isolation_regress_check)\
37+
--temp-config=$(top_srcdir)/$(subdir)/conf.add\
38+
--outputdir=./isolation_output\
39+
$(ISOLATIONCHECKS)

‎README.md

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,16 @@ create_range_partitions(
6565
attribute TEXT,
6666
start_value ANYELEMENT,
6767
interval ANYELEMENT,
68-
premake INTEGER)
68+
premake INTEGER DEFAULT NULL)
6969
7070
create_range_partitions(
7171
relation TEXT,
7272
attribute TEXT,
7373
start_value ANYELEMENT,
7474
interval INTERVAL,
75-
premake INTEGER)
75+
premake INTEGER DEFAULT NULL)
7676
```
77-
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,`premake` is the number of premade partitions. All the data will be automatically copied from the parent to partitions.
77+
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,`premake` is the number of premade partitions (if not set then pathman tries to determine it based on attribute values). All the data will be automatically copied from the parent to partitions.
7878

7979
```
8080
create_partitions_from_range(
@@ -93,15 +93,15 @@ create_partitions_from_range(
9393
```
9494
Performs RANGE-partitioning from specified range for`relation` by partitioning key`attribute`. Data will be copied to partitions as well.
9595

96-
###Utilities
96+
###Triggers
9797
```
9898
create_hash_update_trigger(parent TEXT)
9999
```
100100
Creates the trigger on UPDATE for HASH partitions. The UPDATE trigger isn't created by default because of overhead. It is useful in cases when key attribute could be changed.
101101
```
102102
create_range_update_trigger(parent TEXT)
103103
```
104-
Same as above for RANGEsections.
104+
Same as above for RANGEpartitioned table.
105105

106106
###Partitions management
107107
```
@@ -113,13 +113,42 @@ merge_range_partitions(partition1 TEXT, partition2 TEXT)
113113
```
114114
Merge two adjacent RANGE partitions. Data from`partition2` is copied to`partition1`. Then the`partition2` is removed.
115115
```
116-
append_partition(p_relation TEXT)
116+
append_range_partition(p_relation TEXT)
117117
```
118-
Appends new partitionwith the range equal to the range of the previous partition.
118+
Appends newRANGEpartitionand returns
119119
```
120-
prepend_partition(p_relation TEXT)
120+
prepend_range_partition(p_relation TEXT)
121121
```
122-
Prepends new partition with the range equal to the range of the first partition.
122+
Prepends new RANGE partition.
123+
124+
```
125+
add_range_partition(
126+
relation TEXT,
127+
start_value ANYELEMENT,
128+
end_value ANYELEMENT)
129+
```
130+
Creates new RANGE partition for`relation` with specified values range.
131+
132+
```
133+
drop_range_partition(partition TEXT)
134+
```
135+
Drops RANGE partition and all its data.
136+
137+
```
138+
attach_range_partition(
139+
relation TEXT,
140+
partition TEXT,
141+
start_value ANYELEMENT,
142+
end_value ANYELEMENT)
143+
```
144+
Attaches partition to existing RANGE partitioned relation. The table being attached must have exact same structure as the parent one.
145+
146+
```
147+
detach_range_partition(partition TEXT)
148+
```
149+
Detaches partition from existing RANGE partitioned relation.
150+
151+
123152
```
124153
disable_partitioning(relation TEXT)
125154
```

‎README.rus.md

Lines changed: 133 additions & 98 deletions
Large diffs are not rendered by default.

‎dsm_array.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,14 @@ typedef BlockHeader* BlockHeaderPtr;
3232
#defineset_length(header,length) \
3333
((length) | ((*header) & FREE_BIT))
3434

35+
/*
36+
* Initialize dsm config for arrays
37+
*/
3538
void
36-
alloc_dsm_table()
39+
init_dsm_config()
3740
{
3841
boolfound;
39-
dsm_cfg=ShmemInitStruct("dsm config",sizeof(DsmConfig),&found);
42+
dsm_cfg=ShmemInitStruct("pathman dsm_array config",sizeof(DsmConfig),&found);
4043
if (!found)
4144
{
4245
dsm_cfg->segment_handle=0;
@@ -46,6 +49,15 @@ alloc_dsm_table()
4649
}
4750
}
4851

52+
/*
53+
* Attach process to dsm_array segment. This function is used for
54+
* background workers only. Use init_dsm_segment() in backend processes.
55+
*/
56+
void
57+
attach_dsm_array_segment()
58+
{
59+
segment=dsm_attach(dsm_cfg->segment_handle);
60+
}
4961

5062
/*
5163
* Initialize dsm segment. Returns true if new segment was created and

‎expected/insert_trigger.out

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
Parsed test spec with 2 sessions
2+
3+
starting permutation: s1b s1_insert_150 s1r s1_show_partitions s2b s2_insert_150 s2c s2_show_partitions
4+
create_range_partitions
5+
6+
1
7+
step s1b: BEGIN;
8+
step s1_insert_150: INSERT INTO range_rel SELECT generate_series(1, 150);
9+
step s1r: ROLLBACK;
10+
step s1_show_partitions: SELECT c.consrc FROM pg_inherits i LEFT JOIN pg_constraint c ON c.conrelid = i.inhrelid AND c.consrc IS NOT NULL WHERE i.inhparent = 'range_rel'::regclass::oid ORDER BY c.consrc;
11+
consrc
12+
13+
((id >= 1) AND (id < 101))
14+
((id >= 101) AND (id < 201))
15+
step s2b: BEGIN;
16+
step s2_insert_150: INSERT INTO range_rel SELECT generate_series(1, 150);
17+
step s2c: COMMIT;
18+
step s2_show_partitions: SELECT c.consrc FROM pg_inherits i LEFT JOIN pg_constraint c ON c.conrelid = i.inhrelid AND c.consrc IS NOT NULL WHERE i.inhparent = 'range_rel'::regclass::oid ORDER BY c.consrc;
19+
consrc
20+
21+
((id >= 1) AND (id < 101))
22+
((id >= 101) AND (id < 201))
23+
24+
starting permutation: s1b s1_insert_150 s1r s1_show_partitions s2b s2_insert_300 s2c s2_show_partitions
25+
create_range_partitions
26+
27+
1
28+
step s1b: BEGIN;
29+
step s1_insert_150: INSERT INTO range_rel SELECT generate_series(1, 150);
30+
step s1r: ROLLBACK;
31+
step s1_show_partitions: SELECT c.consrc FROM pg_inherits i LEFT JOIN pg_constraint c ON c.conrelid = i.inhrelid AND c.consrc IS NOT NULL WHERE i.inhparent = 'range_rel'::regclass::oid ORDER BY c.consrc;
32+
consrc
33+
34+
((id >= 1) AND (id < 101))
35+
((id >= 101) AND (id < 201))
36+
step s2b: BEGIN;
37+
step s2_insert_300: INSERT INTO range_rel SELECT generate_series(151, 300);
38+
step s2c: COMMIT;
39+
step s2_show_partitions: SELECT c.consrc FROM pg_inherits i LEFT JOIN pg_constraint c ON c.conrelid = i.inhrelid AND c.consrc IS NOT NULL WHERE i.inhparent = 'range_rel'::regclass::oid ORDER BY c.consrc;
40+
consrc
41+
42+
((id >= 1) AND (id < 101))
43+
((id >= 101) AND (id < 201))
44+
((id >= 201) AND (id < 301))
45+
46+
starting permutation: s1b s1_insert_300 s1r s1_show_partitions s2b s2_insert_150 s2c s2_show_partitions
47+
create_range_partitions
48+
49+
1
50+
step s1b: BEGIN;
51+
step s1_insert_300: INSERT INTO range_rel SELECT generate_series(151, 300);
52+
step s1r: ROLLBACK;
53+
step s1_show_partitions: SELECT c.consrc FROM pg_inherits i LEFT JOIN pg_constraint c ON c.conrelid = i.inhrelid AND c.consrc IS NOT NULL WHERE i.inhparent = 'range_rel'::regclass::oid ORDER BY c.consrc;
54+
consrc
55+
56+
((id >= 1) AND (id < 101))
57+
((id >= 101) AND (id < 201))
58+
((id >= 201) AND (id < 301))
59+
step s2b: BEGIN;
60+
step s2_insert_150: INSERT INTO range_rel SELECT generate_series(1, 150);
61+
step s2c: COMMIT;
62+
step s2_show_partitions: SELECT c.consrc FROM pg_inherits i LEFT JOIN pg_constraint c ON c.conrelid = i.inhrelid AND c.consrc IS NOT NULL WHERE i.inhparent = 'range_rel'::regclass::oid ORDER BY c.consrc;
63+
consrc
64+
65+
((id >= 1) AND (id < 101))
66+
((id >= 101) AND (id < 201))
67+
((id >= 201) AND (id < 301))
68+
69+
starting permutation: s1b s1_insert_150 s2b s2_insert_300 s1r s2r s2_show_partitions
70+
create_range_partitions
71+
72+
1
73+
step s1b: BEGIN;
74+
step s1_insert_150: INSERT INTO range_rel SELECT generate_series(1, 150);
75+
step s2b: BEGIN;
76+
step s2_insert_300: INSERT INTO range_rel SELECT generate_series(151, 300);
77+
step s1r: ROLLBACK;
78+
step s2r: ROLLBACK;
79+
step s2_show_partitions: SELECT c.consrc FROM pg_inherits i LEFT JOIN pg_constraint c ON c.conrelid = i.inhrelid AND c.consrc IS NOT NULL WHERE i.inhparent = 'range_rel'::regclass::oid ORDER BY c.consrc;
80+
consrc
81+
82+
((id >= 1) AND (id < 101))
83+
((id >= 101) AND (id < 201))
84+
((id >= 201) AND (id < 301))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp