Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 9e025db

Browse files
author
Marina Polyakova
committed
Merge remote-tracking branch 'origin/PGPRO-8546'
2 parents c8d2a4c + db938cc commit 9e025db

6 files changed

+61
-48
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ The `pg_pathman` module provides optimized partitioning mechanism and functions
1313

1414
The extension is compatible with:
1515

16-
* PostgreSQL 11, 12, 13;
17-
* PostgreSQL with core-patch: 14, 15;
16+
* PostgreSQL 12, 13;
17+
* PostgreSQL with core-patch: 11, 14, 15;
1818
* Postgres Pro Standard 11, 12, 13, 14, 15;
1919
* Postgres Pro Enterprise;
2020

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
diff --git a/src/backend/jit/llvm/llvmjit_deform.c b/src/backend/jit/llvm/llvmjit_deform.c
2+
index 6384ac940d8..8b4f731e7a8 100644
3+
--- a/src/backend/jit/llvm/llvmjit_deform.c
4+
+++ b/src/backend/jit/llvm/llvmjit_deform.c
5+
@@ -104,6 +104,10 @@ slot_compile_deform(LLVMJitContext *context, TupleDesc desc, int natts)
6+
7+
int attnum;
8+
9+
+ /* don't generate code for tuples without user attributes */
10+
+ if (desc->natts == 0)
11+
+ return NULL;
12+
+
13+
mod = llvm_mutable_module(context);
14+
15+
funcname = llvm_expand_funcname(context, "deform");
16+
diff --git a/src/backend/jit/llvm/llvmjit_expr.c b/src/backend/jit/llvm/llvmjit_expr.c
17+
index 12138e49577..8638ebc4ba1 100644
18+
--- a/src/backend/jit/llvm/llvmjit_expr.c
19+
+++ b/src/backend/jit/llvm/llvmjit_expr.c
20+
@@ -274,6 +274,7 @@ llvm_compile_expr(ExprState *state)
21+
LLVMValueRef v_slot;
22+
LLVMBasicBlockRef b_fetch;
23+
LLVMValueRef v_nvalid;
24+
+ LLVMValueRef l_jit_deform = NULL;
25+
26+
b_fetch = l_bb_before_v(opblocks[i + 1],
27+
"op.%d.fetch", i);
28+
@@ -336,17 +337,20 @@ llvm_compile_expr(ExprState *state)
29+
*/
30+
if (desc && (context->base.flags & PGJIT_DEFORM))
31+
{
32+
- LLVMValueRef params[1];
33+
- LLVMValueRef l_jit_deform;
34+
-
35+
l_jit_deform =
36+
- slot_compile_deform(context, desc,
37+
+ slot_compile_deform(context,
38+
+ desc,
39+
op->d.fetch.last_var);
40+
+ }
41+
+
42+
+ if (l_jit_deform)
43+
+ {
44+
+ LLVMValueRef params[1];
45+
+
46+
params[0] = v_slot;
47+
48+
LLVMBuildCall(b, l_jit_deform,
49+
params, lengthof(params), "");
50+
-
51+
}
52+
else
53+
{

src/include/partition_filter.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,7 @@ TupleConversionMap * build_part_tuple_map_child(Relation child_rel);
181181

182182
void destroy_tuple_map(TupleConversionMap *tuple_map);
183183

184-
List * pfilter_build_tlist(Plan *subplan);
185-
186-
void pfilter_tlist_fix_resjunk(CustomScan *subplan);
184+
List * pfilter_build_tlist(Plan *subplan, Index varno);
187185

188186
/* Find suitable partition using 'value' */
189187
Oid * find_partitions_for_value(Datum value, Oid value_type,

src/partition_filter.c

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -812,12 +812,7 @@ make_partition_filter(Plan *subplan,
812812
cscan->scan.scanrelid = 0;
813813

814814
/* Build an appropriate target list */
815-
cscan->scan.plan.targetlist = pfilter_build_tlist(subplan);
816-
817-
/* Prepare 'custom_scan_tlist' for EXPLAIN (VERBOSE) */
818-
cscan->custom_scan_tlist = copyObject(cscan->scan.plan.targetlist);
819-
ChangeVarNodes((Node *) cscan->custom_scan_tlist, INDEX_VAR, parent_rti, 0);
820-
pfilter_tlist_fix_resjunk(cscan);
815+
cscan->scan.plan.targetlist = pfilter_build_tlist(subplan, parent_rti);
821816

822817
/* Pack partitioned table's Oid and conflict_action */
823818
cscan->custom_private = list_make4(makeInteger(parent_relid),
@@ -1076,7 +1071,7 @@ partition_filter_explain(CustomScanState *node, List *ancestors, ExplainState *e
10761071
* Build partition filter's target list pointing to subplan tuple's elements.
10771072
*/
10781073
List *
1079-
pfilter_build_tlist(Plan *subplan)
1074+
pfilter_build_tlist(Plan *subplan, Index varno)
10801075
{
10811076
List *result_tlist = NIL;
10821077
ListCell *lc;
@@ -1096,7 +1091,7 @@ pfilter_build_tlist(Plan *subplan)
10961091
}
10971092
else
10981093
{
1099-
Var *var = makeVar(INDEX_VAR, /* point to subplan's elements */
1094+
Var *var = makeVar(varno, /* point to subplan's elements */
11001095
tle->resno,
11011096
exprType((Node *) tle->expr),
11021097
exprTypmod((Node *) tle->expr),
@@ -1115,34 +1110,6 @@ pfilter_build_tlist(Plan *subplan)
11151110
return result_tlist;
11161111
}
11171112

1118-
/*
1119-
* resjunk Vars had its varattnos being set on nonexisting relation columns.
1120-
* For future processing service attributes should be indicated correctly.
1121-
*/
1122-
void
1123-
pfilter_tlist_fix_resjunk(CustomScan *css)
1124-
{
1125-
ListCell *lc;
1126-
1127-
foreach(lc, css->custom_scan_tlist)
1128-
{
1129-
TargetEntry *tle = (TargetEntry *) lfirst(lc);
1130-
1131-
if (!IsA(tle->expr, Const))
1132-
{
1133-
Var *var = (Var *) tle->expr;
1134-
1135-
if (tle->resjunk)
1136-
{
1137-
/* To make Var recognizable as service attribute. */
1138-
var->varattno = -1;
1139-
}
1140-
}
1141-
}
1142-
1143-
return;
1144-
}
1145-
11461113
/*
11471114
* ----------------------------------------------
11481115
* Additional init steps for ResultPartsStorage

src/partition_overseer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ make_partition_overseer(Plan *subplan)
4646
cscan->scan.scanrelid = 0;
4747

4848
/* Build an appropriate target list */
49-
cscan->scan.plan.targetlist = pfilter_build_tlist(subplan);
49+
cscan->scan.plan.targetlist = pfilter_build_tlist(subplan, INDEX_VAR);
5050
cscan->custom_scan_tlist = subplan->targetlist;
5151

5252
return &cscan->scan.plan;

src/partition_router.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,7 @@ make_partition_router(Plan *subplan, int epq_param, Index parent_rti)
134134
cscan->scan.scanrelid = 0;
135135

136136
/* Build an appropriate target list */
137-
cscan->scan.plan.targetlist = pfilter_build_tlist(subplan);
138-
139-
/* Fix 'custom_scan_tlist' for EXPLAIN (VERBOSE) */
140-
cscan->custom_scan_tlist = copyObject(cscan->scan.plan.targetlist);
141-
ChangeVarNodes((Node *) cscan->custom_scan_tlist, INDEX_VAR, parent_rti, 0);
142-
pfilter_tlist_fix_resjunk(cscan);
137+
cscan->scan.plan.targetlist = pfilter_build_tlist(subplan, parent_rti);
143138

144139
return &cscan->scan.plan;
145140
}

0 commit comments

Comments
 (0)