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

Commit9c2fcd0

Browse files
committed
still broken, although projection works
1 parent87b72e1 commit9c2fcd0

File tree

1 file changed

+50
-30
lines changed

1 file changed

+50
-30
lines changed

‎init.c‎

Lines changed: 50 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
#include"utils/builtins.h"
66
#include"utils/elog.h"
77
#include"utils/lsyscache.h"
8+
89
#include"nodes/print.h"
10+
911
#include"catalog/pg_proc.h"
1012
#include"catalog/pg_operator.h"
1113
#include"commands/explain.h"
@@ -37,12 +39,15 @@ typedef struct
3739
{
3840
CustomScanStatecss;
3941

40-
HeapTupleDatascan_tuple;/* buffer to fetch tuple */
41-
List*dev_tlist;/* tlist to be returned from the device */
42-
List*dev_quals;/* quals to be run on the device */
42+
List*scan_tlist;
43+
44+
Relationouter_rel;
45+
ItemPointerouter_ptr;
46+
HeapTupleouter_tup;
4347

44-
Relationleft;
45-
Relationright;
48+
Relationinner_rel;
49+
ItemPointerinner_ptr;
50+
HeapTupleinner_tup;
4651
}CrossmatchScanState;
4752

4853
staticCustomPathMethodscrossmatch_path_methods;
@@ -232,6 +237,12 @@ create_crossmatch_plan(PlannerInfo *root,
232237
List*otherclauses;
233238
CustomScan*cscan;
234239

240+
Indexlrel=gpath->outer_path->parent->relid;
241+
Indexrrel=gpath->inner_path->parent->relid;
242+
243+
/* relids should not be 0 */
244+
Assert(lrel!=0&&rrel!=0);
245+
235246
if (IS_OUTER_JOIN(gpath->jointype))
236247
{
237248
extract_actual_join_clauses(joinrestrictclauses,
@@ -246,17 +257,16 @@ create_crossmatch_plan(PlannerInfo *root,
246257

247258
cscan=makeNode(CustomScan);
248259
cscan->scan.plan.targetlist=tlist;
260+
cscan->custom_scan_tlist=tlist;/* output of this node */
249261
cscan->scan.plan.qual=NIL;
250262
cscan->scan.scanrelid=0;
251263

252-
cscan->custom_scan_tlist=tlist;/* TODO: recheck target list */
253-
254-
elog(LOG,"tlist:");
255-
pprint(tlist);
256-
257264
cscan->flags=best_path->flags;
258265
cscan->methods=&crossmatch_plan_methods;
259266

267+
cscan->custom_private=list_make2_oid(root->simple_rte_array[lrel]->relid,
268+
root->simple_rte_array[rrel]->relid);
269+
260270
return&cscan->scan.plan;
261271
}
262272

@@ -271,6 +281,12 @@ crossmatch_create_scan_state(CustomScan *node)
271281

272282
scan_state->css.ss.ps.ps_TupFromTlist= false;
273283

284+
scan_state->scan_tlist=node->custom_scan_tlist;
285+
scan_state->outer_rel=heap_open(linitial_oid(node->custom_private),
286+
AccessShareLock);
287+
scan_state->inner_rel=heap_open(lsecond_oid(node->custom_private),
288+
AccessShareLock);
289+
274290
return (Node*)scan_state;
275291
}
276292

@@ -283,49 +299,53 @@ crossmatch_begin(CustomScanState *node, EState *estate, int eflags)
283299
staticTupleTableSlot*
284300
crossmatch_exec(CustomScanState*node)
285301
{
286-
TupleTableSlot*slot=node->ss.ps.ps_ResultTupleSlot;
287-
TupleDesctupdesc=node->ss.ps.ps_ResultTupleSlot->tts_tupleDescriptor;
288-
ExprContext*econtext=node->ss.ps.ps_ProjInfo->pi_exprContext;
302+
TupleTableSlot*slot=node->ss.ss_ScanTupleSlot;
303+
TupleDesctupdesc=node->ss.ss_ScanTupleSlot->tts_tupleDescriptor;
289304
HeapTuplehtup;
290-
291-
HeapTupleDatafetched_tup;
292-
293-
ResetExprContext(econtext);
305+
TupleTableSlot*result;
294306

295307
/* TODO: fill with real data from joined tables */
296-
Datumvalues[4]= {DirectFunctionCall1(spherepoint_in,CStringGetDatum("(0d, 0d)")),
308+
Datumvalues[2]= {DirectFunctionCall1(spherepoint_in,CStringGetDatum("(0d, 0d)")),
297309
DirectFunctionCall1(spherepoint_in,CStringGetDatum("(0d, 0d)")) };
298-
boolnulls[4]= {0,1,1,1};
310+
boolnulls[2]= {0,0};
299311

300312
elog(LOG,"slot.natts: %d",tupdesc->natts);
301313

302314
htup=heap_form_tuple(tupdesc,values,nulls);
303315

304-
if (node->ss.ps.ps_ProjInfo->pi_itemIsDone!=ExprEndResult)
316+
if (node->ss.ps.ps_ProjInfo)
305317
{
306-
TupleTableSlot*result;
307-
ExprDoneCondisDone;
318+
if (*(node->ss.ps.ps_ProjInfo->pi_itemIsDone)!=ExprEndResult)
319+
{
320+
ExprDoneCondisDone;
308321

309-
econtext->ecxt_scantuple=ExecStoreTuple(htup,slot,InvalidBuffer, false);
322+
node->ss.ps.ps_ProjInfo->pi_exprContext->ecxt_scantuple=ExecStoreTuple(htup,slot,InvalidBuffer, false);
310323

311-
result=ExecProject(node->ss.ps.ps_ProjInfo,&isDone);
324+
result=ExecProject(node->ss.ps.ps_ProjInfo,&isDone);
312325

313-
if (isDone!=ExprEndResult)
314-
{
315-
node->ss.ps.ps_TupFromTlist= (isDone==ExprMultipleResult);
316-
returnresult;
326+
if (isDone!=ExprEndResult)
327+
{
328+
node->ss.ps.ps_TupFromTlist= (isDone==ExprMultipleResult);
329+
}
317330
}
331+
else
332+
result=ExecClearTuple(node->ss.ps.ps_ResultTupleSlot);
318333
}
319334
else
320-
ExecClearTuple(slot);
335+
{
336+
result=ExecClearTuple(node->ss.ps.ps_ResultTupleSlot);
337+
}
321338

322-
returnslot;
339+
returnresult;
323340
}
324341

325342
staticvoid
326343
crossmatch_end(CustomScanState*node)
327344
{
345+
CrossmatchScanState*scan_state= (CrossmatchScanState*)node;
328346

347+
heap_close(scan_state->outer_rel,AccessShareLock);
348+
heap_close(scan_state->inner_rel,AccessShareLock);
329349
}
330350

331351
staticvoid

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp