8000 WIP: now PartitionRouter is able to use both UPDATE & DELETE + INSERT · postgrespro/pg_pathman@d946697 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

10000
Appearance settings

Commit d946697

Browse files
committed
WIP: now PartitionRouter is able to use both UPDATE & DELETE + INSERT
1 parent 47633ba commit d946697

File tree

6 files changed

+250
-148
lines changed

6 files changed

+250
-148
lines changed

src/include/compat/pg_compat.h

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,6 @@ extern void create_plain_partial_paths(PlannerInfo *root,
364364

365365
/*
366366
* ExecEvalExpr()
367-
* NOTE: 'errmsg' specifies error string when ExecEvalExpr returns multiple values.
368367
*/
369368
#if PG_VERSION_NUM >= 100000
370369
#define ExecEvalExprCompat(expr, econtext, isNull) \
@@ -384,6 +383,33 @@ ExecEvalExprCompat(ExprState *expr, ExprContext *econtext, bool *isnull)
384383
#endif
385384

386385

386+
/*
387+
* ExecCheck()
388+
*/
389+
#if PG_VERSION_NUM < 100000
390+
static inline bool
391+
ExecCheck(ExprState *state, ExprContext *econtext)
392+
{
393+
Datum ret;
394+
bool isnull;
395+
MemoryContext old_mcxt;
396+
397+
/* short-circuit (here and in ExecInitCheck) for empty restriction list */
398+
if (state == NULL)
399+
return true;
400+
401+
old_mcxt = MemoryContextSwitchTo(econtext->ecxt_per_tuple_memory);
402+
ret = ExecEvalExprCompat(state, econtext, &isnull);
403+
MemoryContextSwitchTo(old_mcxt);
404+
405+
if (isnull)
406+
return true;
407+
408+
return DatumGetBool(ret);
409+
}
410+
#endif
411+
412+
387413
/*
388414
* extract_actual_join_clauses()
389415
*/
@@ -790,11 +816,15 @@ extern AttrNumber *convert_tuples_by_name_map(TupleDesc indesc,
790816
* heap_delete()
791817
*/
792818
#if PG_VERSION_NUM >= 110000
793-
#define heap_delete_compat(relation, tid, cid, crosscheck, wait, hufd) \
794-
heap_delete((relation), (tid), (cid), (crosscheck), (wait), (hufd), false)
819+
#define heap_delete_compat(relation, tid, cid, crosscheck, \
820+
wait, hufd, changing_part) \
821+
heap_delete((relation), (tid), (cid), (crosscheck), \
822+
(wait), (hufd), (changing_part))
795823
#else
796-
#define heap_delete_compat(relation, tid, cid, crosscheck, wait, hufd) \
797-
heap_delete((relation), (tid), (cid), (crosscheck), (wait), (hufd))
824+
#define heap_delete_compat(relation, tid, cid, crosscheck, \
825+
wait, hufd, changing_part) \
826+
heap_delete((relation), (tid), (cid), (crosscheck), \
827+
(wait), (hufd))
798828
#endif
799829

800830
/*

src/include/partition_router.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,15 @@ typedef struct PartitionRouterState
3030
{
3131
CustomScanState css;
3232

33-
Oid partitioned_table;
34-
Plan *subplan; /* proxy variable to store subplan */
35-
JunkFilter *junkfilter; /* 'ctid' extraction facility */
33+
Plan *subplan; /* proxy variable to store subplan */
34+
JunkFilter *junkfilter; /* 'ctid' extraction facility */
35+
ExprState *constraint; /* should tuple remain in partition? */
3636

3737
EPQState epqstate;
3838
int epqparam;
3939

40+
ModifyTableState *mt_state; /* need this for a GREAT deal of hackery */
41+
4042
ResultRelInfo *current_rri;
4143
} PartitionRouterState;
4244

src/include/relation_info.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ void shout_if_prel_is_invalid(const Oid parent_oid,
367367
const PartType expected_part_type);
368368

369369
/* Bounds cache */
370+
Expr *get_partition_constraint_expr(Oid partition);
370371
void forget_bounds_of_partition(Oid partition);
371372
PartBoundInfo *get_bounds_of_partition(Oid partition, const PartRelationInfo *prel);
372373
void invalidate_bounds_cache(void);

0 commit comments

Comments
 (0)
0