Skip to content

Commit 2b374c4

Browse files
committed
Merge branch 'rel_future_beta' into rel_future_expressions
2 parents b556dba + d499bc6 commit 2b374c4

23 files changed

+1206
-421
lines changed

LICENSE

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
Copyright (c) 2015-2016, Postgres Professional
2-
3-
Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
1+
pg_pathman is released under the PostgreSQL License, a liberal Open Source license, similar to the BSD or MIT licenses.
42

3+
Copyright (c) 2015-2017, Postgres Professional
4+
Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
55
Portions Copyright (c) 1994, The Regents of the University of California
66

77
Permission to use, copy, modify, and distribute this software and its documentation for any purpose, without fee, and without a written agreement is hereby granted, provided that the above copyright notice and this paragraph and the following two paragraphs appear in all copies.
88

9-
IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9+
IN NO EVENT SHALL POSTGRES PROFESSIONAL BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF POSTGRES PROFESSIONAL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1010

11-
THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
11+
POSTGRES PROFESSIONAL SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND POSTGRES PROFESSIONAL HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ create_hash_partitions(relation REGCLASS,
9999
attribute TEXT,
100100
partitions_count INTEGER,
101101
partition_data BOOLEAN DEFAULT TRUE,
102-
partition_names TEXT[] DEFAULT NULL,
103-
tablespaces TEXT[] DEFAULT NULL)
102+
partition_names TEXT[] DEFAULT NULL,
103+
tablespaces TEXT[] DEFAULT NULL)
104104
```
105105
Performs HASH partitioning for `relation` by integer key `attribute`. The `partitions_count` parameter specifies the number of partitions to create; it cannot be changed afterwards. If `partition_data` is `true` then all the data will be automatically copied from the parent table to partitions. Note that data migration may took a while to finish and the table will be locked until transaction commits. See `partition_table_concurrently()` for a lock-free way to migrate data. Partition creation callback is invoked for each partition if set beforehand (see `set_init_callback()`).
106106

@@ -665,11 +665,11 @@ SELECT disable_pathman_for('range_rel');
665665
```
666666
All sections and data will remain unchanged and will be handled by the standard PostgreSQL inheritance mechanism.
667667

668-
##Feedback
668+
## Feedback
669669
Do not hesitate to post your issues, questions and new ideas at the [issues](https://github.com/postgrespro/pg_pathman/issues) page.
670670

671671
## Authors
672-
Ildar Musin <i.musin@postgrespro.ru> Postgres Professional Ltd., Russia
673-
Alexander Korotkov <a.korotkov@postgrespro.ru> Postgres Professional Ltd., Russia
674-
Dmitry Ivanov <d.ivanov@postgrespro.ru> Postgres Professional Ltd., Russia
672+
Ildar Musin <i.musin@postgrespro.ru> Postgres Professional Ltd., Russia
673+
Alexander Korotkov <a.korotkov@postgrespro.ru> Postgres Professional Ltd., Russia
674+
Dmitry Ivanov <d.ivanov@postgrespro.ru> Postgres Professional Ltd., Russia
675675

README.rus.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,6 @@ SELECT disable_pathman_for('range_rel');
488488
Если у вас есть вопросы или предложения, а также если вы обнаружили ошибки, напишите нам в разделе [issues](https://github.com/postgrespro/pg_pathman/issues).
489489

490490
## Авторы
491-
Ильдар Мусин <i.musin@postgrespro.ru> Postgres Professional, Россия
492-
Александр Коротков <a.korotkov@postgrespro.ru> Postgres Professional, Россия
493-
Дмитрий Иванов <d.ivanov@postgrespro.ru> Postgres Professional, Россия
491+
Ильдар Мусин <i.musin@postgrespro.ru> Postgres Professional, Россия
492+
Александр Коротков <a.korotkov@postgrespro.ru> Postgres Professional, Россия
493+
Дмитрий Иванов <d.ivanov@postgrespro.ru> Postgres Professional, Россия

expected/pathman_calamity.out

Lines changed: 105 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ SELECT create_hash_partitions('calamity.part_ok', 'val', 4);
510510
CREATE TABLE calamity.wrong_partition (LIKE calamity.part_test) INHERITS (calamity.part_test); /* wrong partition w\o constraints */
511511
NOTICE: merging column "val" with inherited definition
512512
SELECT add_to_pathman_config('calamity.part_test', 'val');
513-
ERROR: constraint "pathman_wrong_partition_1_check" for partition "wrong_partition" does not exist
513+
ERROR: constraint "pathman_wrong_partition_1_check" of partition "wrong_partition" does not exist
514514
EXPLAIN (COSTS OFF) SELECT * FROM calamity.part_ok; /* check that pathman is enabled */
515515
QUERY PLAN
516516
-----------------------------
@@ -522,7 +522,7 @@ EXPLAIN (COSTS OFF) SELECT * FROM calamity.part_ok; /* check that pathman is ena
522522
(5 rows)
523523

524524
SELECT add_to_pathman_config('calamity.part_test', 'val', '10');
525-
ERROR: constraint "pathman_wrong_partition_1_check" for partition "wrong_partition" does not exist
525+
ERROR: constraint "pathman_wrong_partition_1_check" of partition "wrong_partition" does not exist
526526
EXPLAIN (COSTS OFF) SELECT * FROM calamity.part_ok; /* check that pathman is enabled */
527527
QUERY PLAN
528528
-----------------------------
@@ -670,6 +670,109 @@ NOTICE: drop cascades to table calamity.test_range_oid_1
670670
DROP SCHEMA calamity CASCADE;
671671
NOTICE: drop cascades to 18 other objects
672672
DROP EXTENSION pg_pathman;
673+
/*
674+
* -------------------------------------
675+
* Special tests (pathman_cache_stats)
676+
* -------------------------------------
677+
*/
678+
CREATE SCHEMA calamity;
679+
CREATE EXTENSION pg_pathman;
680+
/* Change this setting for code coverage */
681+
SET pg_pathman.enable_bounds_cache = false;
682+
/* check view pathman_cache_stats */
683+
CREATE TABLE calamity.test_pathman_cache_stats(val NUMERIC NOT NULL);
684+
SELECT create_range_partitions('calamity.test_pathman_cache_stats', 'val', 1, 10, 10);
685+
NOTICE: sequence "test_pathman_cache_stats_seq" does not exist, skipping
686+
create_range_partitions
687+
-------------------------
688+
10
689+
(1 row)
690+
691+
SELECT context, entries FROM pathman_cache_stats ORDER BY context; /* OK */
692+
context | entries
693+
--------------------------+---------
694+
maintenance | 0
695+
partition bounds cache | 0
696+
partition dispatch cache | 1
697+
partition parents cache | 10
698+
(4 rows)
699+
700+
SELECT drop_partitions('calamity.test_pathman_cache_stats');
701+
NOTICE: function calamity.test_pathman_cache_stats_upd_trig_func() does not exist, skipping
702+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_1
703+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_2
704+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_3
705+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_4
706+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_5
707+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_6
708+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_7
709+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_8
710+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_9
711+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_10
712+
drop_partitions
713+
-----------------
714+
10
715+
(1 row)
716+
717+
SELECT context, entries FROM pathman_cache_stats ORDER BY context; /* OK */
718+
context | entries
719+
--------------------------+---------
720+
maintenance | 0
721+
partition bounds cache | 0
722+
partition dispatch cache | 0
723+
partition parents cache | 0
724+
(4 rows)
725+
726+
DROP TABLE calamity.test_pathman_cache_stats;
727+
/* Restore this GUC */
728+
SET pg_pathman.enable_bounds_cache = true;
729+
/* check view pathman_cache_stats (one more time) */
730+
CREATE TABLE calamity.test_pathman_cache_stats(val NUMERIC NOT NULL);
731+
SELECT create_range_partitions('calamity.test_pathman_cache_stats', 'val', 1, 10, 10);
732+
create_range_partitions
733+
-------------------------
734+
10
735+
(1 row)
736+
737+
SELECT context, entries FROM pathman_cache_stats ORDER BY context; /* OK */
738+
context | entries
739+
--------------------------+---------
740+
maintenance | 0
741+
partition bounds cache | 10
742+
partition dispatch cache | 1
743+
partition parents cache | 10
744+
(4 rows)
745+
746+
SELECT drop_partitions('calamity.test_pathman_cache_stats');
747+
NOTICE: function calamity.test_pathman_cache_stats_upd_trig_func() does not exist, skipping
748+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_1
749+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_2
750+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_3
751+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_4
752+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_5
753+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_6
754+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_7
755+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_8
756+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_9
757+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_10
758+
drop_partitions
759+
-----------------
760+
10
761+
(1 row)
762+
763+
SELECT context, entries FROM pathman_cache_stats ORDER BY context; /* OK */
764+
context | entries
765+
--------------------------+---------
766+
maintenance | 0
767+
partition bounds cache | 0
768+
partition dispatch cache | 0
769+
partition parents cache | 0
770+
(4 rows)
771+
772+
DROP TABLE calamity.test_pathman_cache_stats;
773+
DROP SCHEMA calamity CASCADE;
774+
NOTICE: drop cascades to sequence calamity.test_pathman_cache_stats_seq
775+
DROP EXTENSION pg_pathman;
673776
/*
674777
* ------------------------------------------
675778
* Special tests (uninitialized pg_pathman)

init.sql

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,12 +250,12 @@ LANGUAGE plpgsql;
250250
*/
251251
CREATE OR REPLACE FUNCTION @extschema@.show_partition_list()
252252
RETURNS TABLE (
253-
parent REGCLASS,
254-
partition REGCLASS,
255-
parttype INT4,
256-
partattr TEXT,
257-
range_min TEXT,
258-
range_max TEXT)
253+
parent REGCLASS,
254+
partition REGCLASS,
255+
parttype INT4,
256+
partattr TEXT,
257+
range_min TEXT,
258+
range_max TEXT)
259259
AS 'pg_pathman', 'show_partition_list_internal'
260260
LANGUAGE C STRICT;
261261

@@ -267,6 +267,24 @@ AS SELECT * FROM @extschema@.show_partition_list();
267267

268268
GRANT SELECT ON @extschema@.pathman_partition_list TO PUBLIC;
269269

270+
/*
271+
* Show memory usage of pg_pathman's caches.
272+
*/
273+
CREATE OR REPLACE FUNCTION @extschema@.show_cache_stats()
274+
RETURNS TABLE (
275+
context TEXT,
276+
size INT8,
277+
used INT8,
278+
entries INT8)
279+
AS 'pg_pathman', 'show_cache_stats_internal'
280+
LANGUAGE C STRICT;
281+
282+
/*
283+
* View for show_cache_stats().
284+
*/
285+
CREATE OR REPLACE VIEW @extschema@.pathman_cache_stats
286+
AS SELECT * FROM @extschema@.show_cache_stats();
287+
270288
/*
271289
* Show all existing concurrent partitioning tasks.
272290
*/

sql/pathman_calamity.sql

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,41 @@ SELECT get_part_range('calamity.test_range_oid_1', NULL::INT4); /* OK */
260260

261261
DROP TABLE calamity.test_range_oid CASCADE;
262262

263+
DROP SCHEMA calamity CASCADE;
264+
DROP EXTENSION pg_pathman;
265+
266+
267+
268+
/*
269+
* -------------------------------------
270+
* Special tests (pathman_cache_stats)
271+
* -------------------------------------
272+
*/
273+
274+
CREATE SCHEMA calamity;
275+
CREATE EXTENSION pg_pathman;
276+
277+
/* Change this setting for code coverage */
278+
SET pg_pathman.enable_bounds_cache = false;
279+
280+
/* check view pathman_cache_stats */
281+
CREATE TABLE calamity.test_pathman_cache_stats(val NUMERIC NOT NULL);
282+
SELECT create_range_partitions('calamity.test_pathman_cache_stats', 'val', 1, 10, 10);
283+
SELECT context, entries FROM pathman_cache_stats ORDER BY context; /* OK */
284+
SELECT drop_partitions('calamity.test_pathman_cache_stats');
285+
SELECT context, entries FROM pathman_cache_stats ORDER BY context; /* OK */
286+
DROP TABLE calamity.test_pathman_cache_stats;
287+
288+
/* Restore this GUC */
289+
SET pg_pathman.enable_bounds_cache = true;
290+
291+
/* check view pathman_cache_stats (one more time) */
292+
CREATE TABLE calamity.test_pathman_cache_stats(val NUMERIC NOT NULL);
293+
SELECT create_range_partitions('calamity.test_pathman_cache_stats', 'val', 1, 10, 10);
294+
SELECT context, entries FROM pathman_cache_stats ORDER BY context; /* OK */
295+
SELECT drop_partitions('calamity.test_pathman_cache_stats');
296+
SELECT context, entries FROM pathman_cache_stats ORDER BY context; /* OK */
297+
DROP TABLE calamity.test_pathman_cache_stats;
263298

264299
DROP SCHEMA calamity CASCADE;
265300
DROP EXTENSION pg_pathman;

src/compat/pg_compat.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,45 @@ create_plain_partial_paths(PlannerInfo *root, RelOptInfo *rel)
268268
add_partial_path(rel, create_seqscan_path(root, rel, NULL, parallel_workers));
269269
}
270270

271+
/*
272+
* Examine contents of MemoryContext.
273+
*/
274+
void
275+
McxtStatsInternal(MemoryContext context, int level,
276+
bool examine_children,
277+
MemoryContextCounters *totals)
278+
{
279+
MemoryContextCounters local_totals;
280+
MemoryContext child;
281+
282+
AssertArg(MemoryContextIsValid(context));
283+
284+
/* Examine the context itself */
285+
(*context->methods->stats) (context, level, false, totals);
286+
287+
memset(&local_totals, 0, sizeof(local_totals));
288+
289+
if (!examine_children)
290+
return;
291+
292+
/* Examine children */
293+
for (child = context->firstchild;
294+
child != NULL;
295+
child = child->nextchild)
296+
{
297+
298+
McxtStatsInternal(child, level + 1,
299+
examine_children,
300+
&local_totals);
301+
}
302+
303+
/* Save children stats */
304+
totals->nblocks += local_totals.nblocks;
305+
totals->freechunks += local_totals.freechunks;
306+
totals->totalspace += local_totals.totalspace;
307+
totals->freespace += local_totals.freespace;
308+
}
309+
271310

272311
#else /* PG_VERSION_NUM >= 90500 */
273312

src/compat/relation_tags.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ rte_attach_tag(const uint32 query_id,
110110

111111
per_table_relation_tags = hash_create("Custom tags for RangeTblEntry",
112112
start_elems, &hashctl,
113-
HASH_ELEM | HASH_BLOBS);
113+
HASH_ELEM | HASH_BLOBS | HASH_CONTEXT);
114114
}
115115

116116
/* Search by 'htab_key' */

0 commit comments

Comments
 (0)