|
2 | 2 | SET search_path = 'public';
|
3 | 3 | CREATE EXTENSION pg_pathman;
|
4 | 4 | CREATE SCHEMA test_column_type;
|
| 5 | +/* |
| 6 | + * RANGE partitioning. |
| 7 | + */ |
5 | 8 | /* create new table (val int) */
|
6 | 9 | CREATE TABLE test_column_type.test(val INT4 NOT NULL);
|
7 | 10 | SELECT create_range_partitions('test_column_type.test', 'val', 1, 10, 10);
|
@@ -51,6 +54,106 @@ SELECT tableoid::regclass, * FROM test_column_type.test;
|
51 | 54 | test_column_type.test_1 | 1
|
52 | 55 | (1 row)
|
53 | 56 |
|
| 57 | +SELECT drop_partitions('test_column_type.test'); |
| 58 | +NOTICE: function test_column_type.test_upd_trig_func() does not exist, skipping |
| 59 | +NOTICE: 1 rows copied from test_column_type.test_1 |
| 60 | +NOTICE: 0 rows copied from test_column_type.test_2 |
| 61 | +NOTICE: 0 rows copied from test_column_type.test_3 |
| 62 | +NOTICE: 0 rows copied from test_column_type.test_4 |
| 63 | +NOTICE: 0 rows copied from test_column_type.test_5 |
| 64 | +NOTICE: 0 rows copied from test_column_type.test_6 |
| 65 | +NOTICE: 0 rows copied from test_column_type.test_7 |
| 66 | +NOTICE: 0 rows copied from test_column_type.test_8 |
| 67 | +NOTICE: 0 rows copied from test_column_type.test_9 |
| 68 | +NOTICE: 0 rows copied from test_column_type.test_10 |
| 69 | + drop_partitions |
| 70 | +----------------- |
| 71 | + 10 |
| 72 | +(1 row) |
| 73 | + |
| 74 | +DROP TABLE test_column_type.test CASCADE; |
| 75 | +/* |
| 76 | + * HASH partitioning. |
| 77 | + */ |
| 78 | +/* create new table (id int, val int) */ |
| 79 | +CREATE TABLE test_column_type.test(id INT4 NOT NULL, val INT4); |
| 80 | +SELECT create_hash_partitions('test_column_type.test', 'id', 5); |
| 81 | + create_hash_partitions |
| 82 | +------------------------ |
| 83 | + 5 |
| 84 | +(1 row) |
| 85 | + |
| 86 | +/* make sure that bounds and dispatch info has been cached */ |
| 87 | +SELECT * FROM test_column_type.test; |
| 88 | + id | val |
| 89 | +----+----- |
| 90 | +(0 rows) |
| 91 | + |
| 92 | +SELECT context, entries FROM pathman_cache_stats ORDER BY context; |
| 93 | + context | entries |
| 94 | +--------------------------+--------- |
| 95 | + maintenance | 0 |
| 96 | + partition bounds cache | 5 |
| 97 | + partition dispatch cache | 1 |
| 98 | + partition parents cache | 5 |
| 99 | +(4 rows) |
| 100 | + |
| 101 | +/* change column's type (should NOT work) */ |
| 102 | +ALTER TABLE test_column_type.test ALTER id TYPE NUMERIC; |
| 103 | +ERROR: cannot change type of column "id" of table "test" partitioned by HASH |
| 104 | +/* make sure that everything works properly */ |
| 105 | +SELECT * FROM test_column_type.test; |
| 106 | + id | val |
| 107 | +----+----- |
| 108 | +(0 rows) |
| 109 | + |
| 110 | +SELECT context, entries FROM pathman_cache_stats ORDER BY context; |
| 111 | + context | entries |
| 112 | +--------------------------+--------- |
| 113 | + maintenance | 0 |
| 114 | + partition bounds cache | 5 |
| 115 | + partition dispatch cache | 1 |
| 116 | + partition parents cache | 5 |
| 117 | +(4 rows) |
| 118 | + |
| 119 | +/* change column's type (should flush caches) */ |
| 120 | +ALTER TABLE test_column_type.test ALTER val TYPE NUMERIC; |
| 121 | +/* make sure that everything works properly */ |
| 122 | +SELECT * FROM test_column_type.test; |
| 123 | + id | val |
| 124 | +----+----- |
| 125 | +(0 rows) |
| 126 | + |
| 127 | +SELECT context, entries FROM pathman_cache_stats ORDER BY context; |
| 128 | + context | entries |
| 129 | +--------------------------+--------- |
| 130 | + maintenance | 0 |
| 131 | + partition bounds cache | 5 |
| 132 | + partition dispatch cache | 1 |
| 133 | + partition parents cache | 5 |
| 134 | +(4 rows) |
| 135 | + |
| 136 | +/* check insert dispatching */ |
| 137 | +INSERT INTO test_column_type.test VALUES (1); |
| 138 | +SELECT tableoid::regclass, * FROM test_column_type.test; |
| 139 | + tableoid | id | val |
| 140 | +-------------------------+----+----- |
| 141 | + test_column_type.test_0 | 1 | |
| 142 | +(1 row) |
| 143 | + |
| 144 | +SELECT drop_partitions('test_column_type.test'); |
| 145 | +NOTICE: function test_column_type.test_upd_trig_func() does not exist, skipping |
| 146 | +NOTICE: 1 rows copied from test_column_type.test_0 |
| 147 | +NOTICE: 0 rows copied from test_column_type.test_1 |
| 148 | +NOTICE: 0 rows copied from test_column_type.test_2 |
| 149 | +NOTICE: 0 rows copied from test_column_type.test_3 |
| 150 | +NOTICE: 0 rows copied from test_column_type.test_4 |
| 151 | + drop_partitions |
| 152 | +----------------- |
| 153 | + 5 |
| 154 | +(1 row) |
| 155 | + |
| 156 | +DROP TABLE test_column_type.test CASCADE; |
54 | 157 | DROP SCHEMA test_column_type CASCADE;
|
55 |
| -NOTICE: drop cascades to12 other objects |
| 158 | +NOTICE: drop cascades tosequence test_column_type.test_seq |
56 | 159 | DROP EXTENSION pg_pathman;
|