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

Commitd62a542

Browse files
committed
resolve merge conflicts
2 parents1e1c75b +c2ed28a commitd62a542

16 files changed

+1614
-1198
lines changed

‎.travis.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ services:
1010
-docker
1111

1212
install:
13-
-sed -e 's/${CHECK_CODE}/'${CHECK_CODE}/g -e 's/${PG_VERSION}/'${PG_VERSION}/g Dockerfile.tmpl > Dockerfile
13+
-echo "FROM ${DOCKER_IMAGE}" > Dockerfile
1414
-docker-compose build
1515

1616
script:
1717
-docker-compose run $(bash <(curl -s https://codecov.io/env)) tests
1818

1919
env:
20-
-PG_VERSION=10 CHECK_CODE=clang
21-
-PG_VERSION=9.6 CHECK_CODE=clang
22-
-PG_VERSION=9.5 CHECK_CODE=clang
23-
-PG_VERSION=10 CHECK_CODE=cppcheck
24-
-PG_VERSION=9.6 CHECK_CODE=cppcheck
25-
-PG_VERSION=9.5 CHECK_CODE=cppcheck
26-
-PG_VERSION=10 CHECK_CODE=false
27-
-PG_VERSION=9.6 CHECK_CODE=false
28-
-PG_VERSION=9.5 CHECK_CODE=false
20+
-DOCKER_IMAGE=pathman/pg95_clang_check_code
21+
-DOCKER_IMAGE=pathman/pg95_cppcheck
22+
-DOCKER_IMAGE=pathman/pg95_pathman_tests
23+
-DOCKER_IMAGE=pathman/pg96_clang_check_code
24+
-DOCKER_IMAGE=pathman/pg96_cppcheck
25+
-DOCKER_IMAGE=pathman/pg96_pathman_tests
26+
-DOCKER_IMAGE=pathman/pg10_clang_check_code
27+
-DOCKER_IMAGE=pathman/pg10_cppcheck
28+
-DOCKER_IMAGE=pathman/pg10_pathman_tests

‎Dockerfile.tmpl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ RUN if [ "${CHECK_CODE}" = "cppcheck" ] ; then \
1414
RUN if [ "${CHECK_CODE}" = "false" ] ; then \
1515
echo 'http://dl-3.alpinelinux.org/alpine/edge/main' > /etc/apk/repositories; \
1616
apk --no-cache add curl python3 gcc make musl-dev cmocka-dev;\
17-
pip3 installtestgres;\
17+
pip3 installvirtualenv;\
1818
fi
1919

2020
RUN mkdir -p /pg/data && \
@@ -23,8 +23,8 @@ RUN mkdir -p /pg/data && \
2323
chmod a+rwx /usr/local/lib/postgresql && \
2424
chmod a+rwx /usr/local/share/postgresql/extension
2525

26-
ADD . /pg/pg_pathman
27-
WORKDIR /pg/pg_pathman
28-
RUN chmod -R go+rwX /pg/pg_pathman
29-
USER postgres
30-
ENTRYPOINT PGDATA=${PGDATA} CHECK_CODE=${CHECK_CODE} bash run_tests.sh
26+
ONBUILDADD . /pg/pg_pathman
27+
ONBUILDWORKDIR /pg/pg_pathman
28+
ONBUILDRUN chmod -R go+rwX /pg/pg_pathman
29+
ONBUILDUSER postgres
30+
ONBUILDENTRYPOINT PGDATA=${PGDATA} CHECK_CODE=${CHECK_CODE} bash run_tests.sh

‎README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,25 @@ drop_partitions(parent REGCLASS,
251251
```
252252
Drop partitions of the`parent` table (both foreign and local relations). If`delete_data` is`false`, the data is copied to the parent table first. Default is`false`.
253253

254+
To remove partitioned table along with all partitions fully, use conventional
255+
`DROP TABLE relation CASCADE`. However, care should be taken in somewhat rare
256+
case when you are running logical replication and`DROP` was executed by
257+
replication apply worker, e.g. via trigger on replicated table.`pg_pathman`
258+
uses`pathman_ddl_trigger` event trigger to remove the record about dropped
259+
table from`pathman_config`, and this trigger by default won't fire on replica,
260+
leading to inconsistent state when`pg_pathman` thinks that the table still
261+
exists, but in fact it doesn't. If this is the case, configure this trigger to
262+
fire on replica too:
263+
264+
```plpgsql
265+
ALTER EVENT TRIGGER pathman_ddl_trigger ENABLE ALWAYS;
266+
```
267+
268+
Physical replication doesn't have this problem since DDL as well as
269+
`pathman_config` table is replicated too; master and slave PostgreSQL instances
270+
are basically identical, and it is only harmful to keep this trigger in`ALWAYS`
271+
mode.
272+
254273

255274
###Additional parameters
256275

‎expected/pathman_basic.out

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,6 +1346,34 @@ NOTICE: 999 rows copied from test.num_range_rel_6
13461346
DROP TABLE test.num_range_rel CASCADE;
13471347
DROP TABLE test.range_rel CASCADE;
13481348
NOTICE: drop cascades to 10 other objects
1349+
/* Test attributes copying */
1350+
CREATE UNLOGGED TABLE test.range_rel (
1351+
idSERIAL PRIMARY KEY,
1352+
dtDATE NOT NULL)
1353+
WITH (fillfactor = 70);
1354+
INSERT INTO test.range_rel (dt)
1355+
SELECT g FROM generate_series('2015-01-01', '2015-02-15', '1 month'::interval) AS g;
1356+
SELECT pathman.create_range_partitions('test.range_rel', 'dt',
1357+
'2015-01-01'::date, '1 month'::interval);
1358+
create_range_partitions
1359+
-------------------------
1360+
2
1361+
(1 row)
1362+
1363+
SELECT reloptions, relpersistence FROM pg_class WHERE oid='test.range_rel'::REGCLASS;
1364+
reloptions | relpersistence
1365+
-----------------+----------------
1366+
{fillfactor=70} | u
1367+
(1 row)
1368+
1369+
SELECT reloptions, relpersistence FROM pg_class WHERE oid='test.range_rel_1'::REGCLASS;
1370+
reloptions | relpersistence
1371+
-----------------+----------------
1372+
{fillfactor=70} | u
1373+
(1 row)
1374+
1375+
DROP TABLE test.range_rel CASCADE;
1376+
NOTICE: drop cascades to 3 other objects
13491377
/* Test automatic partition creation */
13501378
CREATE TABLE test.range_rel (
13511379
idSERIAL PRIMARY KEY,
@@ -1664,7 +1692,7 @@ EXPLAIN (COSTS OFF) SELECT * FROM test.range_rel WHERE dt > '2010-12-15';
16641692
CREATE TABLE test.tmp (id INTEGER NOT NULL, value INTEGER NOT NULL);
16651693
INSERT INTO test.tmp VALUES (1, 1), (2, 2);
16661694
/* Test UPDATE and DELETE */
1667-
EXPLAIN (COSTS OFF) UPDATE test.range_rel SET value = 111 WHERE dt = '2010-06-15';
1695+
EXPLAIN (COSTS OFF) UPDATE test.range_rel SET value = 111 WHERE dt = '2010-06-15';/* have partitions for this 'dt' */
16681696
QUERY PLAN
16691697
--------------------------------------------------------------------------------
16701698
Update on range_rel_6
@@ -1679,7 +1707,7 @@ SELECT * FROM test.range_rel WHERE dt = '2010-06-15';
16791707
166 | Tue Jun 15 00:00:00 2010 | 111
16801708
(1 row)
16811709

1682-
EXPLAIN (COSTS OFF) DELETE FROM test.range_rel WHERE dt = '2010-06-15';
1710+
EXPLAIN (COSTS OFF) DELETE FROM test.range_rel WHERE dt = '2010-06-15';/* have partitions for this 'dt' */
16831711
QUERY PLAN
16841712
--------------------------------------------------------------------------------
16851713
Delete on range_rel_6
@@ -1693,6 +1721,34 @@ SELECT * FROM test.range_rel WHERE dt = '2010-06-15';
16931721
----+----+-------
16941722
(0 rows)
16951723

1724+
EXPLAIN (COSTS OFF) UPDATE test.range_rel SET value = 222 WHERE dt = '1990-01-01';/* no partitions for this 'dt' */
1725+
QUERY PLAN
1726+
--------------------------------------------------------------------------------
1727+
Update on range_rel
1728+
-> Seq Scan on range_rel
1729+
Filter: (dt = 'Mon Jan 01 00:00:00 1990'::timestamp without time zone)
1730+
(3 rows)
1731+
1732+
UPDATE test.range_rel SET value = 111 WHERE dt = '1990-01-01';
1733+
SELECT * FROM test.range_rel WHERE dt = '1990-01-01';
1734+
id | dt | value
1735+
----+----+-------
1736+
(0 rows)
1737+
1738+
EXPLAIN (COSTS OFF) DELETE FROM test.range_rel WHERE dt < '1990-01-01';/* no partitions for this 'dt' */
1739+
QUERY PLAN
1740+
--------------------------------------------------------------------------------
1741+
Delete on range_rel
1742+
-> Seq Scan on range_rel
1743+
Filter: (dt < 'Mon Jan 01 00:00:00 1990'::timestamp without time zone)
1744+
(3 rows)
1745+
1746+
DELETE FROM test.range_rel WHERE dt < '1990-01-01';
1747+
SELECT * FROM test.range_rel WHERE dt < '1990-01-01';
1748+
id | dt | value
1749+
----+----+-------
1750+
(0 rows)
1751+
16961752
EXPLAIN (COSTS OFF) UPDATE test.range_rel r SET value = t.value FROM test.tmp t WHERE r.dt = '2010-01-01' AND r.id = t.id;
16971753
QUERY PLAN
16981754
--------------------------------------------------------------------------------------------

‎expected/pathman_bgw.out

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,43 @@ SELECT * FROM pathman_partition_list ORDER BY partition; /* should contain 3 par
105105

106106
DROP TABLE test_bgw.test_4 CASCADE;
107107
NOTICE: drop cascades to 4 other objects
108+
/* test error handling in BGW */
109+
CREATE TABLE test_bgw.test_5(val INT4 NOT NULL);
110+
SELECT create_range_partitions('test_bgw.test_5', 'val', 1, 10, 2);
111+
create_range_partitions
112+
-------------------------
113+
2
114+
(1 row)
115+
116+
CREATE OR REPLACE FUNCTION test_bgw.abort_xact(args JSONB)
117+
RETURNS VOID AS $$
118+
BEGIN
119+
RAISE EXCEPTION 'aborting xact!';
120+
END
121+
$$ language plpgsql;
122+
SELECT set_spawn_using_bgw('test_bgw.test_5', true);
123+
set_spawn_using_bgw
124+
---------------------
125+
126+
(1 row)
127+
128+
SELECT set_init_callback('test_bgw.test_5', 'test_bgw.abort_xact(jsonb)');
129+
set_init_callback
130+
-------------------
131+
132+
(1 row)
133+
134+
INSERT INTO test_bgw.test_5 VALUES (-100);
135+
ERROR: Attempt to spawn new partitions of relation "test_5" failed
136+
SELECT * FROM pathman_partition_list ORDER BY partition; /* should contain 3 partitions */
137+
parent | partition | parttype | expr | range_min | range_max
138+
-----------------+-------------------+----------+------+-----------+-----------
139+
test_bgw.test_5 | test_bgw.test_5_1 | 2 | val | 1 | 11
140+
test_bgw.test_5 | test_bgw.test_5_2 | 2 | val | 11 | 21
141+
(2 rows)
142+
143+
DROP FUNCTION test_bgw.abort_xact(args JSONB);
144+
DROP TABLE test_bgw.test_5 CASCADE;
145+
NOTICE: drop cascades to 3 other objects
108146
DROP SCHEMA test_bgw CASCADE;
109147
DROP EXTENSION pg_pathman;

‎expected/pathman_callbacks.out

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
\set VERBOSITY terse
22
CREATE EXTENSION pg_pathman;
33
CREATE SCHEMA callbacks;
4-
/*Check callbacks */
4+
/*callback #1 */
55
CREATE OR REPLACE FUNCTION callbacks.abc_on_part_created_callback(args JSONB)
66
RETURNS VOID AS $$
77
BEGIN
88
RAISE WARNING 'callback arg: %', args::TEXT;
99
END
1010
$$ language plpgsql;
11-
/* callbackis in public namespace, must be schema-qualified */
11+
/* callback#2 */
1212
CREATE OR REPLACE FUNCTION public.dummy_cb(args JSONB)
1313
RETURNS VOID AS $$
1414
BEGIN
@@ -184,15 +184,11 @@ WARNING: callback arg: {"parent": "abc", "parttype": "2", "partition": "abc_2",
184184

185185
INSERT INTO callbacks.abc VALUES (201, 0); /* +1 new partition */
186186
WARNING: callback arg: {"parent": "abc", "parttype": "2", "partition": "abc_3", "range_max": "301", "range_min": "201", "parent_schema": "callbacks", "partition_schema": "callbacks"}
187+
BEGIN;
187188
DROP FUNCTION callbacks.abc_on_part_created_callback(jsonb);
188189
INSERT INTO callbacks.abc VALUES (301, 0); /* +0 new partitions (ERROR) */
189190
ERROR: callback function "callbacks.abc_on_part_created_callback(jsonb)" does not exist
190-
CREATE OR REPLACE FUNCTION callbacks.abc_on_part_created_callback(args JSONB)
191-
RETURNS VOID AS $$
192-
BEGIN
193-
RAISE WARNING 'callback arg: %', args::TEXT;
194-
END
195-
$$ language plpgsql;
191+
ROLLBACK;
196192
INSERT INTO callbacks.abc VALUES (301, 0); /* +1 new partition */
197193
WARNING: callback arg: {"parent": "abc", "parttype": "2", "partition": "abc_5", "range_max": "401", "range_min": "301", "parent_schema": "callbacks", "partition_schema": "callbacks"}
198194
DROP TABLE callbacks.abc CASCADE;
@@ -211,22 +207,22 @@ CREATE OR REPLACE FUNCTION callbacks.rotation_callback(params jsonb)
211207
RETURNS VOID AS
212208
$$
213209
DECLARE
214-
relationregclass;
210+
relationregclass;
215211
parent_relregclass;
216212
BEGIN
217213
parent_rel := concat(params->>'partition_schema', '.', params->>'parent')::regclass;
218214

219-
-- drop "old" partitions
220-
FOR relation IN (SELECT partition FROM
215+
-- drop "old" partitions
216+
FOR relation IN (SELECT partition FROM
221217
(SELECT partition, range_min::INT4 FROM pathman_partition_list
222218
WHERE parent = parent_rel
223219
ORDER BY range_min::INT4 DESC
224220
OFFSET 4) t -- remain 4 last partitions
225221
ORDER BY range_min)
226-
LOOP
227-
RAISE NOTICE 'dropping partition %', relation;
228-
PERFORM drop_range_partition(relation);
229-
END LOOP;
222+
LOOP
223+
RAISE NOTICE 'dropping partition %', relation;
224+
PERFORM drop_range_partition(relation);
225+
END LOOP;
230226
END
231227
$$ LANGUAGE plpgsql;
232228
SELECT * FROM pathman_partition_list

‎make_images.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env python
2+
3+
importsubprocess
4+
importgetpass
5+
6+
DOCKER_ID='pathman'
7+
pg_versions= ['9.5','9.6','10']
8+
9+
image_types= {
10+
'clang_check_code': {
11+
'CHECK_CODE':'clang',
12+
},
13+
'cppcheck': {
14+
'CHECK_CODE':'cppcheck',
15+
},
16+
'pathman_tests': {
17+
'CHECK_CODE':'false',
18+
}
19+
}
20+
21+
user=input("Enter username for `docker login`: ")
22+
password=getpass.getpass()
23+
subprocess.check_output([
24+
'docker',
25+
'login',
26+
'-u',user,
27+
'-p',password])
28+
29+
travis_conf_line='- DOCKER_IMAGE=%s'
30+
travis_conf= []
31+
print("")
32+
33+
forpg_versioninpg_versions:
34+
pgname='pg%s'%pg_version.replace('.','')
35+
forkey,variablesinimage_types.items():
36+
image_name='%s/%s_%s'% (DOCKER_ID,pgname,key)
37+
withopen('Dockerfile','w')asout:
38+
withopen('Dockerfile.tmpl','r')asf:
39+
forlineinf:
40+
line=line.replace('${PG_VERSION}',pg_version)
41+
forkey,valueinvariables.items():
42+
varname='${%s}'%key
43+
line=line.replace(varname,value)
44+
45+
out.write(line)
46+
47+
args= [
48+
'docker',
49+
'build',
50+
'-t',image_name,
51+
'.'
52+
]
53+
subprocess.check_output(args,stderr=subprocess.STDOUT)
54+
print("build ok:",image_name)
55+
subprocess.check_output(['docker','push',image_name],
56+
stderr=subprocess.STDOUT)
57+
print("upload ok:",image_name)
58+
travis_conf.append(travis_conf_line%image_name)
59+
60+
print("\ntravis configuration")
61+
print('\n'.join(travis_conf))

‎run_tests.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ elif [ "$CHECK_CODE" = "cppcheck" ]; then
3535
exit$status
3636
fi
3737

38+
# we need testgres for pathman tests
39+
virtualenv env
40+
export VIRTUAL_ENV_DISABLE_PROMPT=1
41+
source env/bin/activate
42+
pip3 install testgres
43+
pip3 freeze| grep testgres
44+
3845
# don't forget to "make clean"
3946
make USE_PGXS=1 clean
4047

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp