Skip to content

Commit 4c22dec

Browse files
committed
pathman: cleanup
1 parent 6027775 commit 4c22dec

File tree

7 files changed

+8
-75
lines changed

7 files changed

+8
-75
lines changed

contrib/pg_pathman/expected/pg_pathman.out

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -750,27 +750,8 @@ EXPLAIN (COSTS OFF) SELECT * FROM range_rel WHERE dt > '2010-12-15';
750750
Filter: (dt > 'Wed Dec 15 00:00:00 2010'::timestamp without time zone)
751751
(3 rows)
752752

753-
/* Manual partitions creation */
754-
CREATE TABLE range_rel_archive (CHECK (dt >= '2000-01-01' AND dt < '2005-01-01')) INHERITS (range_rel);
755-
SELECT on_update_partitions('range_rel'::regclass::oid);
756-
on_update_partitions
757-
----------------------
758-
759-
(1 row)
760-
761-
EXPLAIN (COSTS OFF) SELECT * FROM range_rel WHERE dt < '2010-03-01';
762-
QUERY PLAN
763-
-------------------------------------
764-
Append
765-
-> Seq Scan on range_rel_archive
766-
-> Seq Scan on range_rel_15
767-
-> Seq Scan on range_rel_1
768-
-> Seq Scan on range_rel_13
769-
(5 rows)
770-
771753
/* Create range partitions from whole range */
772754
SELECT drop_range_partitions('range_rel');
773-
NOTICE: 0 rows copied from range_rel_archive
774755
NOTICE: 0 rows copied from range_rel_15
775756
NOTICE: 0 rows copied from range_rel_14
776757
NOTICE: 14 rows copied from range_rel_13
@@ -787,7 +768,7 @@ NOTICE: 31 rows copied from range_rel_3
787768
NOTICE: 45 rows copied from range_rel_1
788769
drop_range_partitions
789770
-----------------------
790-
15
771+
14
791772
(1 row)
792773

793774
SELECT create_partitions_from_range('range_rel', 'id', 1, 1000, 100);

contrib/pg_pathman/init.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ init_shmem_config()
4040
shmem_cfg = (ShmemConfig *)
4141
ShmemInitStruct("pathman shmem config", sizeof(ShmemConfig), &found);
4242
shmem_cfg->config_loaded = false;
43-
// *config_loaded = false;
4443
}
4544

4645
/*
@@ -60,7 +59,6 @@ load_config(void)
6059
LWLockAcquire(load_config_lock, LW_EXCLUSIVE);
6160
load_relations_hashtable(new_segment_created);
6261
LWLockRelease(load_config_lock);
63-
// *config_loaded = true;
6462
shmem_cfg->config_loaded = true;
6563
}
6664
}
@@ -342,11 +340,12 @@ load_check_constraints(Oid parent_oid, Snapshot snapshot)
342340
/* Check if some ranges overlap */
343341
for(i=0; i < proc-1; i++)
344342
{
345-
Datum min = PATHMAN_GET_DATUM(ranges[i].max, byVal);
346-
Datum max = PATHMAN_GET_DATUM(ranges[i+1].min, byVal);
343+
Datum cur_upper = PATHMAN_GET_DATUM(ranges[i].max, byVal);
344+
Datum next_lower = PATHMAN_GET_DATUM(ranges[i+1].min, byVal);
345+
bool overlap = FunctionCall2(qsort_type_cmp_func, next_lower, cur_upper) > 0;
347346

348-
// if (FunctionCall2(qsort_type_cmp_func, min, max) > 0)
349-
if (ranges[i].max > ranges[i+1].min)
347+
if (overlap)
348+
// if (ranges[i].max > ranges[i+1].min)
350349
{
351350
RelationKey key;
352351
key.dbid = MyDatabaseId;
@@ -369,7 +368,6 @@ cmp_range_entries(const void *p1, const void *p2)
369368
const RangeEntry *v1 = (const RangeEntry *) p1;
370369
const RangeEntry *v2 = (const RangeEntry *) p2;
371370

372-
// return FunctionCall2(qsort_type_cmp_func, v1->min, v2->min);
373371
return FunctionCall2(qsort_type_cmp_func,
374372
PATHMAN_GET_DATUM(v1->min, globalByVal),
375373
PATHMAN_GET_DATUM(v2->min, globalByVal));

contrib/pg_pathman/pathman.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,5 @@ char *get_extension_schema(void);
172172
FmgrInfo *get_cmp_func(Oid type1, Oid type2);
173173
Oid create_partitions_bg_worker(Oid relid, Datum value, Oid value_type);
174174
Oid create_partitions(Oid relid, Datum value, Oid value_type);
175-
// Datum get_range_min(range, size_t idx, bool byVal);
176-
// Datum get_range_max(range, size_t idx, bool byVal);
177175

178176
#endif /* PATHMAN_H */

contrib/pg_pathman/pg_pathman.c

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -166,24 +166,6 @@ get_cmp_func(Oid type1, Oid type2)
166166
return cmp_func;
167167
}
168168

169-
// Datums
170-
// get_range_min(range, size_t idx, bool byVal)
171-
// {
172-
// if (byVal)
173-
// return (Datum)range[idx].min;
174-
// else
175-
// return PointerGetDatum(&range[idx].min);
176-
// }
177-
178-
// Datum
179-
// get_range_max(range, size_t idx, bool byVal)
180-
// {
181-
// if (byVal)
182-
// return (Datum)range[idx].max;
183-
// else
184-
// return PointerGetDatum(&range[idx].max);
185-
// }
186-
187169
/*
188170
* Planner hook. It disables inheritance for tables that have been partitioned
189171
* by pathman to prevent standart PostgreSQL partitioning mechanism from
@@ -731,8 +713,6 @@ handle_binary_opexpr(const PartRelationInfo *prel, WrapperNode *result,
731713
else
732714
{
733715
/* Corner cases */
734-
// cmp_min = FunctionCall2(&cmp_func, value, ranges[0].min),
735-
// cmp_max = FunctionCall2(&cmp_func, value, ranges[rangerel->ranges.length - 1].max);
736716
cmp_min = FunctionCall2(&cmp_func, value,
737717
PATHMAN_GET_DATUM(ranges[0].min, byVal)),
738718
cmp_max = FunctionCall2(&cmp_func, value,
@@ -776,8 +756,6 @@ handle_binary_opexpr(const PartRelationInfo *prel, WrapperNode *result,
776756
i = startidx + (endidx - startidx) / 2;
777757
Assert(i >= 0 && i < rangerel->ranges.length);
778758
re = &ranges[i];
779-
// cmp_min = FunctionCall2(&cmp_func, value, re->min);
780-
// cmp_max = FunctionCall2(&cmp_func, value, re->max);
781759
cmp_min = FunctionCall2(&cmp_func, value, PATHMAN_GET_DATUM(re->min, byVal));
782760
cmp_max = FunctionCall2(&cmp_func, value, PATHMAN_GET_DATUM(re->max, byVal));
783761

@@ -893,8 +871,6 @@ range_binary_search(const RangeRelation *rangerel, FmgrInfo *cmp_func, Datum val
893871
*foundPtr = false;
894872

895873
/* Check boundaries */
896-
// cmp_min = FunctionCall2(cmp_func, value, ranges[0].min),
897-
// cmp_max = FunctionCall2(cmp_func, value, ranges[rangerel->ranges.length - 1].max);
898874
cmp_min = FunctionCall2(cmp_func, value, PATHMAN_GET_DATUM(ranges[0].min, byVal)),
899875
cmp_max = FunctionCall2(cmp_func, value, PATHMAN_GET_DATUM(ranges[rangerel->ranges.length - 1].max, byVal));
900876

@@ -908,8 +884,6 @@ range_binary_search(const RangeRelation *rangerel, FmgrInfo *cmp_func, Datum val
908884
i = startidx + (endidx - startidx) / 2;
909885
Assert(i >= 0 && i < rangerel->ranges.length);
910886
re = &ranges[i];
911-
// cmp_min = FunctionCall2(cmp_func, value, re->min);
912-
// cmp_max = FunctionCall2(cmp_func, value, re->max);
913887
cmp_min = FunctionCall2(cmp_func, value, PATHMAN_GET_DATUM(re->min, byVal));
914888
cmp_max = FunctionCall2(cmp_func, value, PATHMAN_GET_DATUM(re->max, byVal));
915889

contrib/pg_pathman/range.sql

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,6 @@ BEGIN
4747
END LOOP;
4848
END IF;
4949

50-
/* TODO: think about reusing code */
51-
-- EXECUTE format('SELECT @extschema@.create_partitions_from_range(''%s'', ''%s'', ''%s'', ''%s''::%s, ''%s''::interval)'
52-
-- , p_relation
53-
-- , p_attribute
54-
-- , p_start_value
55-
-- , p_start_value + p_interval*p_count
56-
-- , pg_typeof(p_start_value)
57-
-- , p_interval);
58-
59-
-- RETURN p_count;
60-
6150
/* Check boundaries */
6251
EXECUTE format('SELECT @extschema@.check_boundaries(''%s'', ''%s'', ''%s'', ''%s''::%s)'
6352
, p_relation
@@ -778,8 +767,8 @@ BEGIN
778767

779768
IF @extschema@.is_date(p_atttype::regtype) THEN
780769
v_part_name := @extschema@.create_single_range_partition(p_relation
781-
, p_range[1]
782-
, p_range[1] - p_interval::interval);
770+
, p_range[1] - p_interval::interval
771+
, p_range[1]);
783772
ELSE
784773
EXECUTE format('SELECT @extschema@.create_single_range_partition($1, $2, $2 - $3::%s)', p_atttype)
785774
USING p_relation, p_range[1], p_interval

contrib/pg_pathman/sql/pg_pathman.sql

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,6 @@ SELECT prepend_range_partition('range_rel');
182182
EXPLAIN (COSTS OFF) SELECT * FROM range_rel WHERE dt < '2010-03-01';
183183
EXPLAIN (COSTS OFF) SELECT * FROM range_rel WHERE dt > '2010-12-15';
184184

185-
/* Manual partitions creation */
186-
CREATE TABLE range_rel_archive (CHECK (dt >= '2000-01-01' AND dt < '2005-01-01')) INHERITS (range_rel);
187-
SELECT on_update_partitions('range_rel'::regclass::oid);
188-
EXPLAIN (COSTS OFF) SELECT * FROM range_rel WHERE dt < '2010-03-01';
189-
190185
/* Create range partitions from whole range */
191186
SELECT drop_range_partitions('range_rel');
192187
SELECT create_partitions_from_range('range_rel', 'id', 1, 1000, 100);

contrib/pg_pathman/worker.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
static dsm_segment *segment;
2424

2525
static void bg_worker_main(Datum main_arg);
26-
// static Oid create_partitions(Oid relid, Datum value, Oid value_type);
2726

2827
typedef struct PartitionArgs
2928
{
@@ -34,7 +33,6 @@ typedef struct PartitionArgs
3433
#else
3534
double value;
3635
#endif
37-
//Datum value;
3836
Oid value_type;
3937
bool by_val;
4038
Oid result;

0 commit comments

Comments
 (0)