Skip to content

Commit 5078386

Browse files
committed
pathman: fixes after moving to base PGPRO9_5
1 parent 39efd76 commit 5078386

File tree

5 files changed

+215
-215
lines changed

5 files changed

+215
-215
lines changed

contrib/pathman/init.c

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,7 @@ create_part_relations_hashtable()
145145
if (relations != NULL)
146146
hash_destroy(relations);
147147

148-
relations = ShmemInitHash("Partitioning relation info",
149-
1024, 1024,
150-
&ctl, HASH_ELEM);
151-
// &ctl, HASH_ELEM | HASH_BLOBS);
148+
relations = ShmemInitHash("Partitioning relation info", 1024, &ctl, HASH_ELEM);
152149
}
153150

154151
/*
@@ -163,7 +160,6 @@ load_check_constraints(Oid parent_oid)
163160
int ret;
164161
int i;
165162
int proc;
166-
bool arg1_isnull, arg2_isnull;
167163

168164
Datum vals[1];
169165
Oid oids[1] = {INT4OID};
@@ -177,11 +173,6 @@ load_check_constraints(Oid parent_oid)
177173
if (prel->children.length > 0)
178174
return;
179175

180-
// /* if already loaded then quit */
181-
// if (prel->children_count > 0)
182-
// return;
183-
184-
// SPI_connect();
185176
ret = SPI_execute_with_args("select pg_constraint.* "
186177
"from pg_constraint "
187178
"join pg_inherits on inhrelid = conrelid "
@@ -191,14 +182,12 @@ load_check_constraints(Oid parent_oid)
191182

192183
if (ret > 0 && SPI_tuptable != NULL)
193184
{
194-
// TupleDesc tupdesc = SPI_tuptable->tupdesc;
195185
SPITupleTable *tuptable = SPI_tuptable;
196186
Oid *children;
197187
RangeEntry *ranges;
198188
Datum min;
199189
Datum max;
200190
int hash;
201-
HashRelation *hashrel;
202191

203192
alloc_dsm_array(&prel->children, sizeof(Oid), proc);
204193
children = (Oid *) dsm_array_get_pointer(&prel->children);
@@ -292,7 +281,6 @@ static bool
292281
validate_range_constraint(Expr *expr, PartRelationInfo *prel, Datum *min, Datum *max)
293282
{
294283
TypeCacheEntry *tce;
295-
int strategy;
296284
BoolExpr *boolexpr = (BoolExpr *) expr;
297285
OpExpr *opexpr;
298286

@@ -305,7 +293,6 @@ validate_range_constraint(Expr *expr, PartRelationInfo *prel, Datum *min, Datum
305293
return false;
306294

307295
tce = lookup_type_cache(prel->atttype, TYPECACHE_EQ_OPR | TYPECACHE_LT_OPR | TYPECACHE_GT_OPR);
308-
// strategy = get_op_opfamily_strategy(boolexpr->opno, tce->btree_opf);
309296

310297
/* check that left operand is >= operator */
311298
opexpr = (OpExpr *) linitial(boolexpr->args);
@@ -400,8 +387,7 @@ create_range_restrictions_hashtable()
400387
ctl.keysize = sizeof(int);
401388
ctl.entrysize = sizeof(RangeRelation);
402389
range_restrictions = ShmemInitHash("pg_pathman range restrictions",
403-
1024, 1024,
404-
&ctl, HASH_ELEM | HASH_BLOBS);
390+
1024, &ctl, HASH_ELEM | HASH_BLOBS);
405391
}
406392

407393
/*
@@ -411,9 +397,8 @@ void
411397
remove_relation_info(Oid relid)
412398
{
413399
PartRelationInfo *prel;
414-
HashRelationKey key;
400+
// HashRelationKey key;
415401
RangeRelation *rangerel;
416-
int i;
417402

418403
prel = (PartRelationInfo *)
419404
hash_search(relations, (const void *) &relid, HASH_FIND, 0);
@@ -426,11 +411,11 @@ remove_relation_info(Oid relid)
426411
switch (prel->parttype)
427412
{
428413
case PT_HASH:
429-
for (i=0; i<prel->children_count; i++)
430-
{
431-
key.parent_oid = relid;
432-
key.hash = i;
433-
}
414+
// for (i=0; i<prel->children_count; i++)
415+
// {
416+
// key.parent_oid = relid;
417+
// key.hash = i;
418+
// }
434419
free_dsm_array(&prel->children);
435420
break;
436421
case PT_RANGE:

contrib/pathman/pathman.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -309,14 +309,9 @@ append_child_relation(PlannerInfo *root, RelOptInfo *rel, Index rti,
309309
RelOptInfo *childrel;
310310
Index childRTindex;
311311
AppendRelInfo *appinfo;
312-
PartRelationInfo *prel;
313-
314312
Node *node;
315313
ListCell *lc, *lc2;
316314

317-
prel = (PartRelationInfo *)
318-
hash_search(relations, (const void *) &rte->relid, HASH_FIND, 0);
319-
320315
/* Create RangeTblEntry for child relation */
321316
childrte = copyObject(rte);
322317
childrte->relid = childOid;
@@ -960,7 +955,11 @@ set_plain_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
960955
required_outer = rel->lateral_relids;
961956

962957
/* Consider sequential scan */
963-
path = create_seqscan_path(root, rel, required_outer, 0);
958+
path = create_seqscan_path(root, rel, required_outer);
959+
/*
960+
* 9.6 version:
961+
* path = create_seqscan_path(root, rel, required_outer, 0);
962+
*/
964963
add_path(rel, path);
965964
set_pathkeys(root, rel, path);
966965

@@ -1174,11 +1173,11 @@ get_partition_range(PG_FUNCTION_ARGS)
11741173
int child_oid = DatumGetInt32(PG_GETARG_DATUM(1));
11751174
int nelems = 2;
11761175
Datum *elems;
1177-
Oid elemtype = INT4OID;
11781176
PartRelationInfo *prel;
11791177
RangeRelation *rangerel;
11801178
RangeEntry *ranges;
11811179
TypeCacheEntry *tce;
1180+
ArrayType *arr;
11821181
bool found;
11831182
int i;
11841183

@@ -1208,9 +1207,8 @@ get_partition_range(PG_FUNCTION_ARGS)
12081207
elems[0] = ranges[i].min;
12091208
elems[1] = ranges[i].max;
12101209

1211-
ArrayType *arr =
1212-
construct_array(elems, nelems, prel->atttype,
1213-
tce->typlen, tce->typbyval, tce->typalign);
1210+
arr = construct_array(elems, nelems, prel->atttype,
1211+
tce->typlen, tce->typbyval, tce->typalign);
12141212
PG_RETURN_ARRAYTYPE_P(arr);
12151213
}
12161214

contrib/pathman/pathman.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ LWLock *dsm_init_lock;
178178
// void *get_dsm_array(const ArrayPtr* ptr);
179179

180180
void alloc_dsm_table(void);
181-
void create_dsm_segment(size_t block_size);
181+
bool init_dsm_segment(size_t block_size);
182182
void init_dsm_table(Table *tbl, dsm_handle h, size_t block_size);
183183
void alloc_dsm_array(DsmArray *arr, size_t entry_size, size_t length);
184184
void free_dsm_array(DsmArray *arr);

0 commit comments

Comments
 (0)