mirror of
https://github.com/postgres/postgres.git
synced 2025-06-27 23:21:58 +03:00
Fixing bug in INDEXSCAN_PATCH:
ExecInitIndexScan now works with operands of Param type and (!!!) postquel_execute() now substitutes param values before calling postquel_start().
This commit is contained in:
@ -26,7 +26,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.9 1996/11/13 20:48:28 scrappy Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.10 1997/01/22 05:26:27 vadim Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -170,6 +170,11 @@ ExecutorRun(QueryDesc *queryDesc, EState *estate, int feature, int count)
|
|||||||
dest = queryDesc->dest;
|
dest = queryDesc->dest;
|
||||||
destination = (void (*)()) DestToFunction(dest);
|
destination = (void (*)()) DestToFunction(dest);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/*
|
||||||
|
* It doesn't work in common case (i.g. if function has a aggregate).
|
||||||
|
* Now we store parameter values before ExecutorStart. - vadim 01/22/97
|
||||||
|
*/
|
||||||
#ifdef INDEXSCAN_PATCH
|
#ifdef INDEXSCAN_PATCH
|
||||||
/*
|
/*
|
||||||
* If the plan is an index scan and some of the scan key are
|
* If the plan is an index scan and some of the scan key are
|
||||||
@ -182,6 +187,7 @@ ExecutorRun(QueryDesc *queryDesc, EState *estate, int feature, int count)
|
|||||||
econtext = ((IndexScan *)plan)->scan.scanstate->cstate.cs_ExprContext;
|
econtext = ((IndexScan *)plan)->scan.scanstate->cstate.cs_ExprContext;
|
||||||
ExecIndexReScan((IndexScan *)plan, econtext, plan);
|
ExecIndexReScan((IndexScan *)plan, econtext, plan);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch(feature) {
|
switch(feature) {
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.4 1996/11/06 06:47:36 scrappy Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.5 1997/01/22 05:26:37 vadim Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -281,15 +281,26 @@ postquel_execute(execution_state *es,
|
|||||||
{
|
{
|
||||||
TupleTableSlot *slot;
|
TupleTableSlot *slot;
|
||||||
Datum value;
|
Datum value;
|
||||||
|
|
||||||
|
#ifdef INDEXSCAN_PATCH
|
||||||
|
/*
|
||||||
|
* It's more right place to do it (before postquel_start->ExecutorStart).
|
||||||
|
* Now ExecutorStart->ExecInitIndexScan->ExecEvalParam works ok.
|
||||||
|
* (But note: I HOPE we can do it here). - vadim 01/22/97
|
||||||
|
*/
|
||||||
|
if (fcache->nargs > 0)
|
||||||
|
postquel_sub_params(es, fcache->nargs, args, fcache->nullVect);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (es->status == F_EXEC_START)
|
if (es->status == F_EXEC_START)
|
||||||
{
|
{
|
||||||
(void) postquel_start(es);
|
(void) postquel_start(es);
|
||||||
es->status = F_EXEC_RUN;
|
es->status = F_EXEC_RUN;
|
||||||
}
|
}
|
||||||
|
#ifndef INDEXSCAN_PATCH
|
||||||
if (fcache->nargs > 0)
|
if (fcache->nargs > 0)
|
||||||
postquel_sub_params(es, fcache->nargs, args, fcache->nullVect);
|
postquel_sub_params(es, fcache->nargs, args, fcache->nullVect);
|
||||||
|
#endif
|
||||||
|
|
||||||
slot = postquel_getnext(es);
|
slot = postquel_getnext(es);
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.5 1996/11/08 00:45:57 scrappy Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.6 1997/01/22 05:26:50 vadim Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -609,6 +609,7 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent)
|
|||||||
Oper *op; /* operator used in scan.. */
|
Oper *op; /* operator used in scan.. */
|
||||||
Node *leftop; /* expr on lhs of operator */
|
Node *leftop; /* expr on lhs of operator */
|
||||||
Node *rightop; /* expr on rhs ... */
|
Node *rightop; /* expr on rhs ... */
|
||||||
|
bits16 flags = 0;
|
||||||
|
|
||||||
int scanvar; /* which var identifies varattno */
|
int scanvar; /* which var identifies varattno */
|
||||||
AttrNumber varattno = 0; /* att number used in scan */
|
AttrNumber varattno = 0; /* att number used in scan */
|
||||||
@ -675,6 +676,21 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent)
|
|||||||
*/
|
*/
|
||||||
run_keys[ j ] = NO_OP;
|
run_keys[ j ] = NO_OP;
|
||||||
scanvalue = ((Const*) leftop)->constvalue;
|
scanvalue = ((Const*) leftop)->constvalue;
|
||||||
|
#ifdef INDEXSCAN_PATCH
|
||||||
|
} else if (IsA(leftop,Param)) {
|
||||||
|
bool isnull;
|
||||||
|
/* ----------------
|
||||||
|
* if the leftop is a Param node then it means
|
||||||
|
* it identifies the value to place in our scan key.
|
||||||
|
* ----------------
|
||||||
|
*/
|
||||||
|
run_keys[ j ] = NO_OP;
|
||||||
|
scanvalue = ExecEvalParam((Param*) leftop,
|
||||||
|
scanstate->cstate.cs_ExprContext,
|
||||||
|
&isnull);
|
||||||
|
if ( isnull )
|
||||||
|
flags |= SK_ISNULL;
|
||||||
|
#endif
|
||||||
} else if (leftop != NULL &&
|
} else if (leftop != NULL &&
|
||||||
is_funcclause(leftop) &&
|
is_funcclause(leftop) &&
|
||||||
var_is_rel(lfirst(((Expr*)leftop)->args))) {
|
var_is_rel(lfirst(((Expr*)leftop)->args))) {
|
||||||
@ -733,7 +749,21 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent)
|
|||||||
*/
|
*/
|
||||||
run_keys[ j ] = NO_OP;
|
run_keys[ j ] = NO_OP;
|
||||||
scanvalue = ((Const*) rightop)->constvalue;
|
scanvalue = ((Const*) rightop)->constvalue;
|
||||||
|
#ifdef INDEXSCAN_PATCH
|
||||||
|
} else if (IsA(rightop,Param)) {
|
||||||
|
bool isnull;
|
||||||
|
/* ----------------
|
||||||
|
* if the rightop is a Param node then it means
|
||||||
|
* it identifies the value to place in our scan key.
|
||||||
|
* ----------------
|
||||||
|
*/
|
||||||
|
run_keys[ j ] = NO_OP;
|
||||||
|
scanvalue = ExecEvalParam((Param*) rightop,
|
||||||
|
scanstate->cstate.cs_ExprContext,
|
||||||
|
&isnull);
|
||||||
|
if ( isnull )
|
||||||
|
flags |= SK_ISNULL;
|
||||||
|
#endif
|
||||||
} else if (rightop!=NULL &&
|
} else if (rightop!=NULL &&
|
||||||
is_funcclause(rightop) &&
|
is_funcclause(rightop) &&
|
||||||
var_is_rel(lfirst(((Expr*)rightop)->args))) {
|
var_is_rel(lfirst(((Expr*)rightop)->args))) {
|
||||||
@ -777,7 +807,7 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent)
|
|||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
ScanKeyEntryInitialize(&scan_keys[j],
|
ScanKeyEntryInitialize(&scan_keys[j],
|
||||||
0,
|
flags,
|
||||||
varattno, /* attribute number to scan */
|
varattno, /* attribute number to scan */
|
||||||
(RegProcedure) opid, /* reg proc to use */
|
(RegProcedure) opid, /* reg proc to use */
|
||||||
(Datum) scanvalue); /* constant */
|
(Datum) scanvalue); /* constant */
|
||||||
|
Reference in New Issue
Block a user