|
| 1 | +\set VERBOSITY terse |
| 2 | +SET search_path = 'public'; |
| 3 | +CREATE EXTENSION pg_pathman; |
| 4 | +CREATE SCHEMA test_bgw; |
| 5 | +/* |
| 6 | + * Tests for SpawnPartitionsWorker |
| 7 | + */ |
| 8 | +/* int4, size of Datum == 4 */ |
| 9 | +CREATE TABLE test_bgw.test_1(val INT4 NOT NULL); |
| 10 | +SELECT create_range_partitions('test_bgw.test_1', 'val', 1, 5, 2); |
| 11 | +NOTICE: sequence "test_1_seq" does not exist, skipping |
| 12 | + create_range_partitions |
| 13 | +------------------------- |
| 14 | + 2 |
| 15 | +(1 row) |
| 16 | + |
| 17 | +SELECT set_spawn_using_bgw('test_bgw.test_1', true); |
| 18 | + set_spawn_using_bgw |
| 19 | +--------------------- |
| 20 | + |
| 21 | +(1 row) |
| 22 | + |
| 23 | +INSERT INTO test_bgw.test_1 VALUES (11); |
| 24 | +SELECT * FROM pathman_partition_list ORDER BY partition; /* should contain 3 partitions */ |
| 25 | + parent | partition | parttype | partattr | range_min | range_max |
| 26 | +-----------------+-------------------+----------+----------+-----------+----------- |
| 27 | + test_bgw.test_1 | test_bgw.test_1_1 | 2 | val | 1 | 6 |
| 28 | + test_bgw.test_1 | test_bgw.test_1_2 | 2 | val | 6 | 11 |
| 29 | + test_bgw.test_1 | test_bgw.test_1_3 | 2 | val | 11 | 16 |
| 30 | +(3 rows) |
| 31 | + |
| 32 | +DROP TABLE test_bgw.test_1 CASCADE; |
| 33 | +NOTICE: drop cascades to 3 other objects |
| 34 | +/* int8, size of Datum == 8 */ |
| 35 | +CREATE TABLE test_bgw.test_2(val INT8 NOT NULL); |
| 36 | +SELECT create_range_partitions('test_bgw.test_2', 'val', 1, 5, 2); |
| 37 | +NOTICE: sequence "test_2_seq" does not exist, skipping |
| 38 | + create_range_partitions |
| 39 | +------------------------- |
| 40 | + 2 |
| 41 | +(1 row) |
| 42 | + |
| 43 | +SELECT set_spawn_using_bgw('test_bgw.test_2', true); |
| 44 | + set_spawn_using_bgw |
| 45 | +--------------------- |
| 46 | + |
| 47 | +(1 row) |
| 48 | + |
| 49 | +INSERT INTO test_bgw.test_2 VALUES (11); |
| 50 | +SELECT * FROM pathman_partition_list ORDER BY partition; /* should contain 3 partitions */ |
| 51 | + parent | partition | parttype | partattr | range_min | range_max |
| 52 | +-----------------+-------------------+----------+----------+-----------+----------- |
| 53 | + test_bgw.test_2 | test_bgw.test_2_1 | 2 | val | 1 | 6 |
| 54 | + test_bgw.test_2 | test_bgw.test_2_2 | 2 | val | 6 | 11 |
| 55 | + test_bgw.test_2 | test_bgw.test_2_3 | 2 | val | 11 | 16 |
| 56 | +(3 rows) |
| 57 | + |
| 58 | +DROP TABLE test_bgw.test_2 CASCADE; |
| 59 | +NOTICE: drop cascades to 3 other objects |
| 60 | +/* numeric, size of Datum == var */ |
| 61 | +CREATE TABLE test_bgw.test_3(val NUMERIC NOT NULL); |
| 62 | +SELECT create_range_partitions('test_bgw.test_3', 'val', 1, 5, 2); |
| 63 | +NOTICE: sequence "test_3_seq" does not exist, skipping |
| 64 | + create_range_partitions |
| 65 | +------------------------- |
| 66 | + 2 |
| 67 | +(1 row) |
| 68 | + |
| 69 | +SELECT set_spawn_using_bgw('test_bgw.test_3', true); |
| 70 | + set_spawn_using_bgw |
| 71 | +--------------------- |
| 72 | + |
| 73 | +(1 row) |
| 74 | + |
| 75 | +INSERT INTO test_bgw.test_3 VALUES (11); |
| 76 | +SELECT * FROM pathman_partition_list ORDER BY partition; /* should contain 3 partitions */ |
| 77 | + parent | partition | parttype | partattr | range_min | range_max |
| 78 | +-----------------+-------------------+----------+----------+-----------+----------- |
| 79 | + test_bgw.test_3 | test_bgw.test_3_1 | 2 | val | 1 | 6 |
| 80 | + test_bgw.test_3 | test_bgw.test_3_2 | 2 | val | 6 | 11 |
| 81 | + test_bgw.test_3 | test_bgw.test_3_3 | 2 | val | 11 | 16 |
| 82 | +(3 rows) |
| 83 | + |
| 84 | +DROP TABLE test_bgw.test_3 CASCADE; |
| 85 | +NOTICE: drop cascades to 3 other objects |
| 86 | +/* date, size of Datum == var */ |
| 87 | +CREATE TABLE test_bgw.test_4(val DATE NOT NULL); |
| 88 | +SELECT create_range_partitions('test_bgw.test_4', 'val', '20170213'::date, '1 day'::interval, 2); |
| 89 | +NOTICE: sequence "test_4_seq" does not exist, skipping |
| 90 | + create_range_partitions |
| 91 | +------------------------- |
| 92 | + 2 |
| 93 | +(1 row) |
| 94 | + |
| 95 | +SELECT set_spawn_using_bgw('test_bgw.test_4', true); |
| 96 | + set_spawn_using_bgw |
| 97 | +--------------------- |
| 98 | + |
| 99 | +(1 row) |
| 100 | + |
| 101 | +INSERT INTO test_bgw.test_4 VALUES ('20170215'); |
| 102 | +SELECT * FROM pathman_partition_list ORDER BY partition; /* should contain 3 partitions */ |
| 103 | + parent | partition | parttype | partattr | range_min | range_max |
| 104 | +-----------------+-------------------+----------+----------+------------+------------ |
| 105 | + test_bgw.test_4 | test_bgw.test_4_1 | 2 | val | 02-13-2017 | 02-14-2017 |
| 106 | + test_bgw.test_4 | test_bgw.test_4_2 | 2 | val | 02-14-2017 | 02-15-2017 |
| 107 | + test_bgw.test_4 | test_bgw.test_4_3 | 2 | val | 02-15-2017 | 02-16-2017 |
| 108 | +(3 rows) |
| 109 | + |
| 110 | +DROP TABLE test_bgw.test_4 CASCADE; |
| 111 | +NOTICE: drop cascades to 3 other objects |
| 112 | +DROP SCHEMA test_bgw CASCADE; |
| 113 | +NOTICE: drop cascades to 4 other objects |
| 114 | +DROP EXTENSION pg_pathman; |
0 commit comments