|
| 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; |
0 commit comments