Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit04d5ed2

Browse files
committed
initialize ResultRelInfos for partitions using savedRelInfo
1 parentc63c9a1 commit04d5ed2

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

‎src/partition_filter.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ partition_filter_begin(CustomScanState *node, EState *estate, int eflags)
102102

103103
node->custom_ps=list_make1(ExecInitNode(state->subplan,estate,eflags));
104104
state->prel=get_pathman_relation_info(state->partitioned_table,NULL);
105+
state->savedRelInfo=NULL;
105106

106107
memset(result_rels_table_config,0,sizeof(HASHCTL));
107108
result_rels_table_config->keysize=sizeof(Oid);
@@ -129,6 +130,10 @@ partition_filter_exec(CustomScanState *node)
129130

130131
slot=ExecProcNode(child_ps);
131132

133+
/* Save original ResultRelInfo */
134+
if (!state->savedRelInfo)
135+
state->savedRelInfo=estate->es_result_relation_info;
136+
132137
if (!TupIsNull(slot))
133138
{
134139
WalkerContextwcxt;
@@ -140,9 +145,11 @@ partition_filter_exec(CustomScanState *node)
140145
AttrNumberattnum=state->prel->attnum;
141146
Datumvalue=slot_getattr(slot,attnum,&isnull);
142147

148+
/* Fill const with value ... */
143149
state->temp_const.constvalue=value;
144150
state->temp_const.constisnull=isnull;
145151

152+
/* ... and some other important data */
146153
CopyToTempConst(consttype,atttypid);
147154
CopyToTempConst(consttypmod,atttypmod);
148155
CopyToTempConst(constcollid,attcollation);
@@ -162,6 +169,7 @@ partition_filter_exec(CustomScanState *node)
162169
elseif (nparts==0)
163170
elog(ERROR,"PartitionFilter could not select suitable partition");
164171

172+
/* Replace main table with suitable partition */
165173
estate->es_result_relation_info=getResultRelInfo(parts[0],state);
166174

167175
returnslot;
@@ -209,6 +217,9 @@ partition_filter_explain(CustomScanState *node, List *ancestors, ExplainState *e
209217
staticResultRelInfo*
210218
getResultRelInfo(Oidpartid,PartitionFilterState*state)
211219
{
220+
#defineCopyToResultRelInfo(field_name) \
221+
( resultRelInfo->field_name = state->savedRelInfo->field_name )
222+
212223
ResultRelInfoHandle*resultRelInfoHandle;
213224
boolfound;
214225

@@ -226,6 +237,17 @@ getResultRelInfo(Oid partid, PartitionFilterState *state)
226237

227238
ExecOpenIndices(resultRelInfo,state->onConflictAction!=ONCONFLICT_NONE);
228239

240+
/* Copy necessary fields from saved ResultRelInfo */
241+
CopyToResultRelInfo(ri_WithCheckOptions);
242+
CopyToResultRelInfo(ri_WithCheckOptionExprs);
243+
CopyToResultRelInfo(ri_junkFilter);
244+
CopyToResultRelInfo(ri_projectReturning);
245+
CopyToResultRelInfo(ri_onConflictSetProj);
246+
CopyToResultRelInfo(ri_onConflictSetWhere);
247+
248+
/* ri_ConstraintExprs will be initialized by ExecRelCheck() */
249+
resultRelInfo->ri_ConstraintExprs=NULL;
250+
229251
resultRelInfoHandle->partid=partid;
230252
resultRelInfoHandle->resultRelInfo=resultRelInfo;
231253
}

‎src/partition_filter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ typedef struct
2222
Oidpartitioned_table;
2323
PartRelationInfo*prel;
2424
OnConflictActiononConflictAction;
25+
ResultRelInfo*savedRelInfo;
2526

2627
Plan*subplan;
2728
Consttemp_const;/* temporary const for expr walker */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp