Skip to content

Commit 4d37a4c

Browse files
committed
fix function handle_modification_query(), refactoring (+function build_part_tuple_map())
1 parent 8eaba42 commit 4d37a4c

File tree

7 files changed

+263
-97
lines changed

7 files changed

+263
-97
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ REGRESS = pathman_basic \
2525
pathman_cte \
2626
pathman_bgw \
2727
pathman_inserts \
28+
pathman_updates \
2829
pathman_domains \
2930
pathman_interval \
3031
pathman_callbacks \

expected/pathman_updates.out

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
\set VERBOSITY terse
2+
SET search_path = 'public';
3+
CREATE EXTENSION pg_pathman;
4+
CREATE SCHEMA test_updates;
5+
/*
6+
* Test UPDATEs on a partition with different TupleDescriptor.
7+
*/
8+
/* create partitioned table */
9+
CREATE TABLE test_updates.test(a FLOAT4, val INT4 NOT NULL, b FLOAT8);
10+
INSERT INTO test_updates.test SELECT i, i, i FROM generate_series(1, 100) AS i;
11+
SELECT create_range_partitions('test_updates.test', 'val', 1, 10);
12+
NOTICE: sequence "test_seq" does not exist, skipping
13+
create_range_partitions
14+
-------------------------
15+
10
16+
(1 row)
17+
18+
/* drop column 'a' */
19+
ALTER TABLE test_updates.test DROP COLUMN a;
20+
/* append new partition */
21+
SELECT append_range_partition('test_updates.test');
22+
append_range_partition
23+
------------------------
24+
test_updates.test_11
25+
(1 row)
26+
27+
INSERT INTO test_updates.test_11 (val, b) VALUES (101, 10);
28+
/* tuple descs are the same */
29+
EXPLAIN (COSTS OFF) UPDATE test_updates.test SET b = 0 WHERE val = 1;
30+
QUERY PLAN
31+
---------------------------
32+
Update on test_1
33+
-> Seq Scan on test_1
34+
Filter: (val = 1)
35+
(3 rows)
36+
37+
UPDATE test_updates.test SET b = 0 WHERE val = 1 RETURNING *, tableoid::REGCLASS;
38+
val | b | tableoid
39+
-----+---+---------------------
40+
1 | 0 | test_updates.test_1
41+
(1 row)
42+
43+
/* tuple descs are different */
44+
EXPLAIN (COSTS OFF) UPDATE test_updates.test SET b = 0 WHERE val = 101;
45+
QUERY PLAN
46+
-----------------------------
47+
Update on test
48+
Update on test
49+
Update on test_11
50+
-> Seq Scan on test
51+
Filter: (val = 101)
52+
-> Seq Scan on test_11
53+
Filter: (val = 101)
54+
(7 rows)
55+
56+
UPDATE test_updates.test SET b = 0 WHERE val = 101 RETURNING *, tableoid::REGCLASS;
57+
val | b | tableoid
58+
-----+---+----------------------
59+
101 | 0 | test_updates.test_11
60+
(1 row)
61+
62+
DROP SCHEMA test_updates CASCADE;
63+
NOTICE: drop cascades to 13 other objects
64+
DROP EXTENSION pg_pathman;

sql/pathman_updates.sql

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
\set VERBOSITY terse
2+
3+
SET search_path = 'public';
4+
CREATE EXTENSION pg_pathman;
5+
CREATE SCHEMA test_updates;
6+
7+
8+
/*
9+
* Test UPDATEs on a partition with different TupleDescriptor.
10+
*/
11+
12+
/* create partitioned table */
13+
CREATE TABLE test_updates.test(a FLOAT4, val INT4 NOT NULL, b FLOAT8);
14+
INSERT INTO test_updates.test SELECT i, i, i FROM generate_series(1, 100) AS i;
15+
SELECT create_range_partitions('test_updates.test', 'val', 1, 10);
16+
17+
/* drop column 'a' */
18+
ALTER TABLE test_updates.test DROP COLUMN a;
19+
20+
/* append new partition */
21+
SELECT append_range_partition('test_updates.test');
22+
INSERT INTO test_updates.test_11 (val, b) VALUES (101, 10);
23+
24+
25+
/* tuple descs are the same */
26+
EXPLAIN (COSTS OFF) UPDATE test_updates.test SET b = 0 WHERE val = 1;
27+
UPDATE test_updates.test SET b = 0 WHERE val = 1 RETURNING *, tableoid::REGCLASS;
28+
29+
30+
/* tuple descs are different */
31+
EXPLAIN (COSTS OFF) UPDATE test_updates.test SET b = 0 WHERE val = 101;
32+
UPDATE test_updates.test SET b = 0 WHERE val = 101 RETURNING *, tableoid::REGCLASS;
33+
34+
35+
36+
DROP SCHEMA test_updates CASCADE;
37+
DROP EXTENSION pg_pathman;

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