1996-07-09 08:22:35 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* execAmi.c
|
1999-09-18 21:08:25 +02:00
|
|
|
* miscellaneous executor access method routines
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
2001-01-24 20:43:33 +01:00
|
|
|
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
Commit to match discussed elog() changes. Only update is that LOG is
now just below FATAL in server_min_messages. Added more text to
highlight ordering difference between it and client_min_messages.
---------------------------------------------------------------------------
REALLYFATAL => PANIC
STOP => PANIC
New INFO level the prints to client by default
New LOG level the prints to server log by default
Cause VACUUM information to print only to the client
NOTICE => INFO where purely information messages are sent
DEBUG => LOG for purely server status messages
DEBUG removed, kept as backward compatible
DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1 added
DebugLvl removed in favor of new DEBUG[1-5] symbols
New server_min_messages GUC parameter with values:
DEBUG[5-1], INFO, NOTICE, ERROR, LOG, FATAL, PANIC
New client_min_messages GUC parameter with values:
DEBUG[5-1], LOG, INFO, NOTICE, ERROR, FATAL, PANIC
Server startup now logged with LOG instead of DEBUG
Remove debug_level GUC parameter
elog() numbers now start at 10
Add test to print error message if older elog() values are passed to elog()
Bootstrap mode now has a -d that requires an argument, like postmaster
2002-03-02 22:39:36 +01:00
|
|
|
* $Id: execAmi.c,v 1.62 2002/03/02 21:39:24 momjian Exp $
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
1996-10-31 11:12:26 +01:00
|
|
|
#include "postgres.h"
|
|
|
|
|
1999-07-16 07:00:38 +02:00
|
|
|
#include "access/genam.h"
|
|
|
|
#include "access/heapam.h"
|
|
|
|
#include "catalog/heap.h"
|
|
|
|
#include "executor/execdebug.h"
|
2001-09-18 03:59:07 +02:00
|
|
|
#include "executor/instrument.h"
|
1999-07-16 07:00:38 +02:00
|
|
|
#include "executor/nodeAgg.h"
|
|
|
|
#include "executor/nodeAppend.h"
|
|
|
|
#include "executor/nodeGroup.h"
|
|
|
|
#include "executor/nodeGroup.h"
|
|
|
|
#include "executor/nodeHash.h"
|
|
|
|
#include "executor/nodeHashjoin.h"
|
1996-07-09 08:22:35 +02:00
|
|
|
#include "executor/nodeIndexscan.h"
|
1999-11-23 21:07:06 +01:00
|
|
|
#include "executor/nodeTidscan.h"
|
2000-10-26 23:38:24 +02:00
|
|
|
#include "executor/nodeLimit.h"
|
1998-02-13 04:26:53 +01:00
|
|
|
#include "executor/nodeMaterial.h"
|
1999-07-16 07:00:38 +02:00
|
|
|
#include "executor/nodeMergejoin.h"
|
1998-02-13 04:26:53 +01:00
|
|
|
#include "executor/nodeNestloop.h"
|
|
|
|
#include "executor/nodeResult.h"
|
1999-07-16 07:00:38 +02:00
|
|
|
#include "executor/nodeSeqscan.h"
|
2000-10-05 21:11:39 +02:00
|
|
|
#include "executor/nodeSetOp.h"
|
1999-07-16 07:00:38 +02:00
|
|
|
#include "executor/nodeSort.h"
|
1998-02-13 04:26:53 +01:00
|
|
|
#include "executor/nodeSubplan.h"
|
2000-09-29 20:21:41 +02:00
|
|
|
#include "executor/nodeSubqueryscan.h"
|
1999-07-16 07:00:38 +02:00
|
|
|
#include "executor/nodeUnique.h"
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/* ----------------------------------------------------------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* ExecReScan
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
1997-09-07 07:04:48 +02:00
|
|
|
* XXX this should be extended to cope with all the node types..
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
1997-09-07 07:04:48 +02:00
|
|
|
* takes the new expression context as an argument, so that
|
|
|
|
* index scans needn't have their scan keys updated separately
|
|
|
|
* - marcel 09/20/94
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
1997-09-08 23:56:23 +02:00
|
|
|
ExecReScan(Plan *node, ExprContext *exprCtxt, Plan *parent)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2001-09-18 03:59:07 +02:00
|
|
|
if (node->instrument)
|
|
|
|
InstrEndLoop(node->instrument);
|
1998-02-13 04:26:53 +01:00
|
|
|
|
1998-02-26 05:46:47 +01:00
|
|
|
if (node->chgParam != NULL) /* Wow! */
|
1998-02-13 04:26:53 +01:00
|
|
|
{
|
1998-02-26 05:46:47 +01:00
|
|
|
List *lst;
|
|
|
|
|
|
|
|
foreach(lst, node->initPlan)
|
1998-02-13 04:26:53 +01:00
|
|
|
{
|
1998-02-26 05:46:47 +01:00
|
|
|
Plan *splan = ((SubPlan *) lfirst(lst))->plan;
|
|
|
|
|
|
|
|
if (splan->extParam != NULL) /* don't care about child
|
|
|
|
* locParam */
|
|
|
|
SetChangedParamList(splan, node->chgParam);
|
|
|
|
if (splan->chgParam != NULL)
|
|
|
|
ExecReScanSetParamPlan((SubPlan *) lfirst(lst), node);
|
1998-02-13 04:26:53 +01:00
|
|
|
}
|
1998-02-26 05:46:47 +01:00
|
|
|
foreach(lst, node->subPlan)
|
1998-02-13 04:26:53 +01:00
|
|
|
{
|
1998-02-26 05:46:47 +01:00
|
|
|
Plan *splan = ((SubPlan *) lfirst(lst))->plan;
|
|
|
|
|
|
|
|
if (splan->extParam != NULL)
|
|
|
|
SetChangedParamList(splan, node->chgParam);
|
1998-02-13 04:26:53 +01:00
|
|
|
}
|
|
|
|
/* Well. Now set chgParam for left/right trees. */
|
1998-02-26 05:46:47 +01:00
|
|
|
if (node->lefttree != NULL)
|
|
|
|
SetChangedParamList(node->lefttree, node->chgParam);
|
|
|
|
if (node->righttree != NULL)
|
|
|
|
SetChangedParamList(node->righttree, node->chgParam);
|
1998-02-13 04:26:53 +01:00
|
|
|
}
|
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
switch (nodeTag(node))
|
|
|
|
{
|
1998-02-13 04:26:53 +01:00
|
|
|
case T_SeqScan:
|
1997-09-08 04:41:22 +02:00
|
|
|
ExecSeqReScan((SeqScan *) node, exprCtxt, parent);
|
1998-02-13 04:26:53 +01:00
|
|
|
break;
|
1997-09-08 04:41:22 +02:00
|
|
|
|
|
|
|
case T_IndexScan:
|
|
|
|
ExecIndexReScan((IndexScan *) node, exprCtxt, parent);
|
1998-02-13 04:26:53 +01:00
|
|
|
break;
|
1997-09-08 04:41:22 +02:00
|
|
|
|
2000-09-29 20:21:41 +02:00
|
|
|
case T_TidScan:
|
|
|
|
ExecTidReScan((TidScan *) node, exprCtxt, parent);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case T_SubqueryScan:
|
|
|
|
ExecSubqueryReScan((SubqueryScan *) node, exprCtxt, parent);
|
|
|
|
break;
|
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
case T_Material:
|
1998-02-26 05:46:47 +01:00
|
|
|
ExecMaterialReScan((Material *) node, exprCtxt, parent);
|
1998-02-13 04:26:53 +01:00
|
|
|
break;
|
1997-09-08 04:41:22 +02:00
|
|
|
|
1998-02-13 04:26:53 +01:00
|
|
|
case T_NestLoop:
|
1998-02-26 05:46:47 +01:00
|
|
|
ExecReScanNestLoop((NestLoop *) node, exprCtxt, parent);
|
1998-02-13 04:26:53 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case T_HashJoin:
|
1998-02-26 05:46:47 +01:00
|
|
|
ExecReScanHashJoin((HashJoin *) node, exprCtxt, parent);
|
1998-02-13 04:26:53 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case T_Hash:
|
1998-02-26 05:46:47 +01:00
|
|
|
ExecReScanHash((Hash *) node, exprCtxt, parent);
|
1998-02-13 04:26:53 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case T_Agg:
|
1998-02-26 05:46:47 +01:00
|
|
|
ExecReScanAgg((Agg *) node, exprCtxt, parent);
|
1998-02-13 04:26:53 +01:00
|
|
|
break;
|
1997-09-08 04:41:22 +02:00
|
|
|
|
1998-07-16 03:49:19 +02:00
|
|
|
case T_Group:
|
|
|
|
ExecReScanGroup((Group *) node, exprCtxt, parent);
|
|
|
|
break;
|
|
|
|
|
1998-02-13 04:26:53 +01:00
|
|
|
case T_Result:
|
1998-02-26 05:46:47 +01:00
|
|
|
ExecReScanResult((Result *) node, exprCtxt, parent);
|
1998-02-13 04:26:53 +01:00
|
|
|
break;
|
|
|
|
|
1998-02-23 07:28:16 +01:00
|
|
|
case T_Unique:
|
1998-02-26 05:46:47 +01:00
|
|
|
ExecReScanUnique((Unique *) node, exprCtxt, parent);
|
1998-02-23 07:28:16 +01:00
|
|
|
break;
|
|
|
|
|
2000-10-05 21:11:39 +02:00
|
|
|
case T_SetOp:
|
|
|
|
ExecReScanSetOp((SetOp *) node, exprCtxt, parent);
|
|
|
|
break;
|
|
|
|
|
2000-10-26 23:38:24 +02:00
|
|
|
case T_Limit:
|
|
|
|
ExecReScanLimit((Limit *) node, exprCtxt, parent);
|
|
|
|
break;
|
|
|
|
|
1998-02-23 07:28:16 +01:00
|
|
|
case T_Sort:
|
1998-02-26 05:46:47 +01:00
|
|
|
ExecReScanSort((Sort *) node, exprCtxt, parent);
|
1998-02-23 07:28:16 +01:00
|
|
|
break;
|
|
|
|
|
1998-02-27 17:11:28 +01:00
|
|
|
case T_MergeJoin:
|
|
|
|
ExecReScanMergeJoin((MergeJoin *) node, exprCtxt, parent);
|
|
|
|
break;
|
|
|
|
|
1998-07-16 00:16:21 +02:00
|
|
|
case T_Append:
|
|
|
|
ExecReScanAppend((Append *) node, exprCtxt, parent);
|
|
|
|
break;
|
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
default:
|
2000-07-26 01:43:38 +02:00
|
|
|
elog(ERROR, "ExecReScan: node type %d not supported",
|
|
|
|
nodeTag(node));
|
1997-09-08 04:41:22 +02:00
|
|
|
return;
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
1998-02-26 05:46:47 +01:00
|
|
|
|
|
|
|
if (node->chgParam != NULL)
|
1998-02-13 04:26:53 +01:00
|
|
|
{
|
1998-02-26 05:46:47 +01:00
|
|
|
freeList(node->chgParam);
|
1998-02-13 04:26:53 +01:00
|
|
|
node->chgParam = NULL;
|
|
|
|
}
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/* ----------------------------------------------------------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* ExecMarkPos
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
1997-09-07 07:04:48 +02:00
|
|
|
* Marks the current scan position.
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
2000-07-26 01:43:38 +02:00
|
|
|
* XXX Needs to be extended to include all the node types,
|
|
|
|
* or at least all the ones that can be directly below a mergejoin.
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
1997-09-08 23:56:23 +02:00
|
|
|
ExecMarkPos(Plan *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-07 07:04:48 +02:00
|
|
|
switch (nodeTag(node))
|
|
|
|
{
|
2001-10-25 07:50:21 +02:00
|
|
|
case T_SeqScan:
|
1997-09-08 04:41:22 +02:00
|
|
|
ExecSeqMarkPos((SeqScan *) node);
|
|
|
|
break;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
case T_IndexScan:
|
|
|
|
ExecIndexMarkPos((IndexScan *) node);
|
|
|
|
break;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2000-06-19 00:44:35 +02:00
|
|
|
case T_Material:
|
|
|
|
ExecMaterialMarkPos((Material *) node);
|
|
|
|
break;
|
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
case T_Sort:
|
|
|
|
ExecSortMarkPos((Sort *) node);
|
|
|
|
break;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1999-11-23 21:07:06 +01:00
|
|
|
case T_TidScan:
|
|
|
|
ExecTidMarkPos((TidScan *) node);
|
|
|
|
break;
|
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
default:
|
2000-07-26 01:43:38 +02:00
|
|
|
/* don't make hard error unless caller asks to restore... */
|
Commit to match discussed elog() changes. Only update is that LOG is
now just below FATAL in server_min_messages. Added more text to
highlight ordering difference between it and client_min_messages.
---------------------------------------------------------------------------
REALLYFATAL => PANIC
STOP => PANIC
New INFO level the prints to client by default
New LOG level the prints to server log by default
Cause VACUUM information to print only to the client
NOTICE => INFO where purely information messages are sent
DEBUG => LOG for purely server status messages
DEBUG removed, kept as backward compatible
DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1 added
DebugLvl removed in favor of new DEBUG[1-5] symbols
New server_min_messages GUC parameter with values:
DEBUG[5-1], INFO, NOTICE, ERROR, LOG, FATAL, PANIC
New client_min_messages GUC parameter with values:
DEBUG[5-1], LOG, INFO, NOTICE, ERROR, FATAL, PANIC
Server startup now logged with LOG instead of DEBUG
Remove debug_level GUC parameter
elog() numbers now start at 10
Add test to print error message if older elog() values are passed to elog()
Bootstrap mode now has a -d that requires an argument, like postmaster
2002-03-02 22:39:36 +01:00
|
|
|
elog(LOG, "ExecMarkPos: node type %d not supported",
|
2000-07-26 01:43:38 +02:00
|
|
|
nodeTag(node));
|
1997-09-08 04:41:22 +02:00
|
|
|
break;
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/* ----------------------------------------------------------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* ExecRestrPos
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
1997-09-07 07:04:48 +02:00
|
|
|
* restores the scan position previously saved with ExecMarkPos()
|
2000-07-26 01:43:38 +02:00
|
|
|
*
|
|
|
|
* XXX Needs to be extended to include all the node types,
|
|
|
|
* or at least all the ones that can be directly below a mergejoin.
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
1997-09-08 23:56:23 +02:00
|
|
|
ExecRestrPos(Plan *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-07 07:04:48 +02:00
|
|
|
switch (nodeTag(node))
|
|
|
|
{
|
2001-10-25 07:50:21 +02:00
|
|
|
case T_SeqScan:
|
1997-09-08 04:41:22 +02:00
|
|
|
ExecSeqRestrPos((SeqScan *) node);
|
2000-07-26 01:43:38 +02:00
|
|
|
break;
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
case T_IndexScan:
|
|
|
|
ExecIndexRestrPos((IndexScan *) node);
|
2000-07-26 01:43:38 +02:00
|
|
|
break;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2000-06-19 00:44:35 +02:00
|
|
|
case T_Material:
|
|
|
|
ExecMaterialRestrPos((Material *) node);
|
2000-07-26 01:43:38 +02:00
|
|
|
break;
|
2000-06-19 00:44:35 +02:00
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
case T_Sort:
|
|
|
|
ExecSortRestrPos((Sort *) node);
|
2000-07-26 01:43:38 +02:00
|
|
|
break;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
default:
|
2000-07-26 01:43:38 +02:00
|
|
|
elog(ERROR, "ExecRestrPos: node type %d not supported",
|
|
|
|
nodeTag(node));
|
|
|
|
break;
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|