Skip to content

Commit 5cdaa7a

Browse files
committed
fix several issues
1 parent 1fab2cd commit 5cdaa7a

File tree

5 files changed

+25
-26
lines changed

5 files changed

+25
-26
lines changed

Diff for: src/hooks.c

+1
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ pathman_join_pathlist_hook(PlannerInfo *root,
167167
if (IS_OUTER_JOIN(extra->sjinfo->jointype))
168168
{
169169
extract_actual_join_clauses(extra->restrictlist,
170+
joinrel->relids,
170171
&joinclauses, &otherclauses);
171172
}
172173
else

Diff for: src/include/relation_info.h

-1
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,6 @@ void invalidate_pathman_status_info(Oid relid);
334334
void invalidate_pathman_status_info_cache(void);
335335

336336
/* Dispatch cache */
337-
void refresh_pathman_relation_info(Oid relid);
338337
void close_pathman_relation_info(PartRelationInfo *prel);
339338
bool has_pathman_relation_info(Oid relid);
340339
PartRelationInfo *get_pathman_relation_info(Oid relid);

Diff for: src/pl_range_funcs.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ get_part_range_by_oid(PG_FUNCTION_ARGS)
432432
shout_if_prel_is_invalid(parent_relid, prel, PT_RANGE);
433433

434434
/* Check type of 'dummy' (for correct output) */
435-
arg_type = get_fn_expr_argtype(fcinfo->flinfo, 2);
435+
arg_type = get_fn_expr_argtype(fcinfo->flinfo, 1);
436436
if (getBaseType(arg_type) != getBaseType(prel->ev_type))
437437
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
438438
errmsg("pg_typeof(dummy) should be %s",

Diff for: src/relation_info.c

+18-19
Original file line numberDiff line numberDiff line change
@@ -205,35 +205,30 @@ invalidate_psin_entry(PartStatusInfo *psin)
205205
psin->relid, MyProcPid);
206206
#endif
207207

208-
/* Mark entry as invalid */
209-
if (psin->prel && PrelReferenceCount(psin->prel) > 0)
210-
{
211-
PrelIsFresh(psin->prel) = false;
212-
}
213-
else
208+
if (psin->prel)
214209
{
215-
if (psin->prel)
210+
if (PrelReferenceCount(psin->prel) > 0)
211+
{
212+
/* Mark entry as outdated and detach it */
213+
PrelIsFresh(psin->prel) = false;
214+
}
215+
else
216+
{
216217
free_pathman_relation_info(psin->prel);
217-
218-
(void) pathman_cache_search_relid(status_cache,
219-
psin->relid,
220-
HASH_REMOVE,
221-
NULL);
218+
}
222219
}
220+
221+
(void) pathman_cache_search_relid(status_cache,
222+
psin->relid,
223+
HASH_REMOVE,
224+
NULL);
223225
}
224226

225227

226228
/*
227229
* Dispatch cache routines.
228230
*/
229231

230-
/* Make changes to PartRelationInfo visible */
231-
void
232-
refresh_pathman_relation_info(Oid relid)
233-
{
234-
235-
}
236-
237232
/* Close PartRelationInfo entry */
238233
void
239234
close_pathman_relation_info(PartRelationInfo *prel)
@@ -242,6 +237,10 @@ close_pathman_relation_info(PartRelationInfo *prel)
242237
Assert(PrelReferenceCount(prel) > 0);
243238

244239
PrelReferenceCount(prel) -= 1;
240+
241+
/* Remove entry is it's outdated and we're the last user */
242+
if (PrelReferenceCount(prel) == 0 && !PrelIsFresh(prel))
243+
free_pathman_relation_info(prel);
245244
}
246245

247246
/* Check if relation is partitioned by pg_pathman */

Diff for: src/utility_stmt_hooking.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ is_pathman_related_alter_column_type(Node *parsetree,
213213
AlterTableStmt *alter_table_stmt = (AlterTableStmt *) parsetree;
214214
ListCell *lc;
215215
Oid parent_relid;
216+
bool result = false;
216217
PartRelationInfo *prel;
217218

218219
Assert(IsPathmanReady());
@@ -235,8 +236,6 @@ is_pathman_related_alter_column_type(Node *parsetree,
235236
/* Return 'parent_relid' and 'prel->parttype' */
236237
if (parent_relid_out) *parent_relid_out = parent_relid;
237238
if (part_type_out) *part_type_out = prel->parttype;
238-
239-
close_pathman_relation_info(prel);
240239
}
241240
else return false;
242241

@@ -264,11 +263,12 @@ is_pathman_related_alter_column_type(Node *parsetree,
264263
if (attr_number_out) *attr_number_out = attnum;
265264

266265
/* Success! */
267-
return true;
266+
result = true;
268267
}
269268

270-
/* Default failure */
271-
return false;
269+
close_pathman_relation_info(prel);
270+
271+
return result;
272272
}
273273

274274

0 commit comments

Comments
 (0)