1996-08-28 03:59:28 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* nodes.h
|
1997-09-07 07:04:48 +02:00
|
|
|
* Definitions for tagged nodes.
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
|
|
|
*
|
2015-01-06 17:43:47 +01:00
|
|
|
* Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
2010-09-20 22:08:53 +02:00
|
|
|
* src/include/nodes/nodes.h
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef NODES_H
|
1997-09-07 07:04:48 +02:00
|
|
|
#define NODES_H
|
1996-08-28 03:59:28 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The first field of every node is NodeTag. Each node created (with makeNode)
|
|
|
|
* will have one of the following tags as the value of its first field.
|
|
|
|
*
|
2002-12-05 16:50:39 +01:00
|
|
|
* Note that the numbers of the node tags are not contiguous. We left holes
|
1996-08-28 03:59:28 +02:00
|
|
|
* here so that we can add more tags without changing the existing enum's.
|
2002-12-05 16:50:39 +01:00
|
|
|
* (Since node tag numbers never exist outside backend memory, there's no
|
|
|
|
* real harm in renumbering, it just costs a full rebuild ...)
|
1996-08-28 03:59:28 +02:00
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef enum NodeTag
|
|
|
|
{
|
2001-10-28 07:26:15 +01:00
|
|
|
T_Invalid = 0,
|
1996-08-28 03:59:28 +02:00
|
|
|
|
2002-12-05 16:50:39 +01:00
|
|
|
/*
|
|
|
|
* TAGS FOR EXECUTOR NODES (execnodes.h)
|
|
|
|
*/
|
|
|
|
T_IndexInfo = 10,
|
|
|
|
T_ExprContext,
|
|
|
|
T_ProjectionInfo,
|
|
|
|
T_JunkFilter,
|
2002-12-13 20:46:01 +01:00
|
|
|
T_ResultRelInfo,
|
2002-12-05 16:50:39 +01:00
|
|
|
T_EState,
|
2002-12-13 20:46:01 +01:00
|
|
|
T_TupleTableSlot,
|
2002-12-05 16:50:39 +01:00
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* TAGS FOR PLAN NODES (plannodes.h)
|
|
|
|
*/
|
2002-12-05 16:50:39 +01:00
|
|
|
T_Plan = 100,
|
2001-10-28 07:26:15 +01:00
|
|
|
T_Result,
|
2009-10-10 03:43:50 +02:00
|
|
|
T_ModifyTable,
|
2001-10-28 07:26:15 +01:00
|
|
|
T_Append,
|
2010-10-14 22:56:39 +02:00
|
|
|
T_MergeAppend,
|
2008-10-04 23:56:55 +02:00
|
|
|
T_RecursiveUnion,
|
2005-04-20 00:35:18 +02:00
|
|
|
T_BitmapAnd,
|
|
|
|
T_BitmapOr,
|
2001-10-28 07:26:15 +01:00
|
|
|
T_Scan,
|
|
|
|
T_SeqScan,
|
|
|
|
T_IndexScan,
|
2011-10-11 20:20:06 +02:00
|
|
|
T_IndexOnlyScan,
|
2005-04-20 00:35:18 +02:00
|
|
|
T_BitmapIndexScan,
|
|
|
|
T_BitmapHeapScan,
|
2002-12-05 16:50:39 +01:00
|
|
|
T_TidScan,
|
|
|
|
T_SubqueryScan,
|
|
|
|
T_FunctionScan,
|
2006-08-02 03:59:48 +02:00
|
|
|
T_ValuesScan,
|
2008-10-04 23:56:55 +02:00
|
|
|
T_CteScan,
|
|
|
|
T_WorkTableScan,
|
2011-02-20 06:17:18 +01:00
|
|
|
T_ForeignScan,
|
2014-11-07 23:26:02 +01:00
|
|
|
T_CustomScan,
|
2001-10-28 07:26:15 +01:00
|
|
|
T_Join,
|
|
|
|
T_NestLoop,
|
|
|
|
T_MergeJoin,
|
|
|
|
T_HashJoin,
|
|
|
|
T_Material,
|
|
|
|
T_Sort,
|
2002-12-05 16:50:39 +01:00
|
|
|
T_Group,
|
2001-10-28 07:26:15 +01:00
|
|
|
T_Agg,
|
2008-12-28 19:54:01 +01:00
|
|
|
T_WindowAgg,
|
2001-10-28 07:26:15 +01:00
|
|
|
T_Unique,
|
|
|
|
T_Hash,
|
|
|
|
T_SetOp,
|
2009-10-12 20:10:51 +02:00
|
|
|
T_LockRows,
|
2002-12-05 16:50:39 +01:00
|
|
|
T_Limit,
|
Re-implement EvalPlanQual processing to improve its performance and eliminate
a lot of strange behaviors that occurred in join cases. We now identify the
"current" row for every joined relation in UPDATE, DELETE, and SELECT FOR
UPDATE/SHARE queries. If an EvalPlanQual recheck is necessary, we jam the
appropriate row into each scan node in the rechecking plan, forcing it to emit
only that one row. The former behavior could rescan the whole of each joined
relation for each recheck, which was terrible for performance, and what's much
worse could result in duplicated output tuples.
Also, the original implementation of EvalPlanQual could not re-use the recheck
execution tree --- it had to go through a full executor init and shutdown for
every row to be tested. To avoid this overhead, I've associated a special
runtime Param with each LockRows or ModifyTable plan node, and arranged to
make every scan node below such a node depend on that Param. Thus, by
signaling a change in that Param, the EPQ machinery can just rescan the
already-built test plan.
This patch also adds a prohibition on set-returning functions in the
targetlist of SELECT FOR UPDATE/SHARE. This is needed to avoid the
duplicate-output-tuple problem. It seems fairly reasonable since the
other restrictions on SELECT FOR UPDATE are meant to ensure that there
is a unique correspondence between source tuples and result tuples,
which an output SRF destroys as much as anything else does.
2009-10-26 03:26:45 +01:00
|
|
|
/* these aren't subclasses of Plan: */
|
2010-07-12 19:01:06 +02:00
|
|
|
T_NestLoopParam,
|
Re-implement EvalPlanQual processing to improve its performance and eliminate
a lot of strange behaviors that occurred in join cases. We now identify the
"current" row for every joined relation in UPDATE, DELETE, and SELECT FOR
UPDATE/SHARE queries. If an EvalPlanQual recheck is necessary, we jam the
appropriate row into each scan node in the rechecking plan, forcing it to emit
only that one row. The former behavior could rescan the whole of each joined
relation for each recheck, which was terrible for performance, and what's much
worse could result in duplicated output tuples.
Also, the original implementation of EvalPlanQual could not re-use the recheck
execution tree --- it had to go through a full executor init and shutdown for
every row to be tested. To avoid this overhead, I've associated a special
runtime Param with each LockRows or ModifyTable plan node, and arranged to
make every scan node below such a node depend on that Param. Thus, by
signaling a change in that Param, the EPQ machinery can just rescan the
already-built test plan.
This patch also adds a prohibition on set-returning functions in the
targetlist of SELECT FOR UPDATE/SHARE. This is needed to avoid the
duplicate-output-tuple problem. It seems fairly reasonable since the
other restrictions on SELECT FOR UPDATE are meant to ensure that there
is a unique correspondence between source tuples and result tuples,
which an output SRF destroys as much as anything else does.
2009-10-26 03:26:45 +01:00
|
|
|
T_PlanRowMark,
|
2008-09-09 20:58:09 +02:00
|
|
|
T_PlanInvalItem,
|
2002-12-05 16:50:39 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* TAGS FOR PLAN STATE NODES (execnodes.h)
|
|
|
|
*
|
|
|
|
* These should correspond one-to-one with Plan node types.
|
|
|
|
*/
|
|
|
|
T_PlanState = 200,
|
|
|
|
T_ResultState,
|
2009-10-10 03:43:50 +02:00
|
|
|
T_ModifyTableState,
|
2002-12-05 16:50:39 +01:00
|
|
|
T_AppendState,
|
2010-10-14 22:56:39 +02:00
|
|
|
T_MergeAppendState,
|
2008-10-04 23:56:55 +02:00
|
|
|
T_RecursiveUnionState,
|
2005-04-20 00:35:18 +02:00
|
|
|
T_BitmapAndState,
|
|
|
|
T_BitmapOrState,
|
2002-12-05 16:50:39 +01:00
|
|
|
T_ScanState,
|
|
|
|
T_SeqScanState,
|
|
|
|
T_IndexScanState,
|
2011-10-11 20:20:06 +02:00
|
|
|
T_IndexOnlyScanState,
|
2005-04-20 00:35:18 +02:00
|
|
|
T_BitmapIndexScanState,
|
|
|
|
T_BitmapHeapScanState,
|
2002-12-05 16:50:39 +01:00
|
|
|
T_TidScanState,
|
|
|
|
T_SubqueryScanState,
|
|
|
|
T_FunctionScanState,
|
2006-08-02 03:59:48 +02:00
|
|
|
T_ValuesScanState,
|
2008-10-04 23:56:55 +02:00
|
|
|
T_CteScanState,
|
|
|
|
T_WorkTableScanState,
|
2011-02-20 06:17:18 +01:00
|
|
|
T_ForeignScanState,
|
2014-11-07 23:26:02 +01:00
|
|
|
T_CustomScanState,
|
2002-12-05 16:50:39 +01:00
|
|
|
T_JoinState,
|
|
|
|
T_NestLoopState,
|
|
|
|
T_MergeJoinState,
|
|
|
|
T_HashJoinState,
|
|
|
|
T_MaterialState,
|
|
|
|
T_SortState,
|
|
|
|
T_GroupState,
|
|
|
|
T_AggState,
|
2008-12-28 19:54:01 +01:00
|
|
|
T_WindowAggState,
|
2002-12-05 16:50:39 +01:00
|
|
|
T_UniqueState,
|
|
|
|
T_HashState,
|
|
|
|
T_SetOpState,
|
2009-10-12 20:10:51 +02:00
|
|
|
T_LockRowsState,
|
2002-12-05 16:50:39 +01:00
|
|
|
T_LimitState,
|
1996-08-28 03:59:28 +02:00
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* TAGS FOR PRIMITIVE NODES (primnodes.h)
|
|
|
|
*/
|
2005-04-06 18:34:07 +02:00
|
|
|
T_Alias = 300,
|
2002-12-12 16:49:42 +01:00
|
|
|
T_RangeVar,
|
2001-10-28 07:26:15 +01:00
|
|
|
T_Expr,
|
|
|
|
T_Var,
|
|
|
|
T_Const,
|
|
|
|
T_Param,
|
|
|
|
T_Aggref,
|
2008-12-28 19:54:01 +01:00
|
|
|
T_WindowFunc,
|
2002-12-12 16:49:42 +01:00
|
|
|
T_ArrayRef,
|
|
|
|
T_FuncExpr,
|
2009-10-08 04:39:25 +02:00
|
|
|
T_NamedArgExpr,
|
2002-12-12 16:49:42 +01:00
|
|
|
T_OpExpr,
|
|
|
|
T_DistinctExpr,
|
2011-03-20 01:29:08 +01:00
|
|
|
T_NullIfExpr,
|
2003-06-29 02:33:44 +02:00
|
|
|
T_ScalarArrayOpExpr,
|
2002-12-12 16:49:42 +01:00
|
|
|
T_BoolExpr,
|
2001-10-28 07:26:15 +01:00
|
|
|
T_SubLink,
|
2002-12-14 01:17:59 +01:00
|
|
|
T_SubPlan,
|
2008-08-22 02:16:04 +02:00
|
|
|
T_AlternativeSubPlan,
|
2001-10-28 07:26:15 +01:00
|
|
|
T_FieldSelect,
|
2004-06-09 21:08:20 +02:00
|
|
|
T_FieldStore,
|
2001-10-28 07:26:15 +01:00
|
|
|
T_RelabelType,
|
2007-06-05 23:31:09 +02:00
|
|
|
T_CoerceViaIO,
|
2007-03-28 01:21:12 +02:00
|
|
|
T_ArrayCoerceExpr,
|
2004-12-12 00:26:51 +01:00
|
|
|
T_ConvertRowtypeExpr,
|
2011-03-11 22:27:51 +01:00
|
|
|
T_CollateExpr,
|
2002-12-12 16:49:42 +01:00
|
|
|
T_CaseExpr,
|
|
|
|
T_CaseWhen,
|
2004-03-17 21:48:43 +01:00
|
|
|
T_CaseTestExpr,
|
2003-04-09 01:20:04 +02:00
|
|
|
T_ArrayExpr,
|
2004-05-11 00:44:49 +02:00
|
|
|
T_RowExpr,
|
2005-12-28 02:30:02 +01:00
|
|
|
T_RowCompareExpr,
|
2003-02-16 03:30:39 +01:00
|
|
|
T_CoalesceExpr,
|
2005-06-27 00:05:42 +02:00
|
|
|
T_MinMaxExpr,
|
2006-12-24 01:29:20 +01:00
|
|
|
T_XmlExpr,
|
2002-12-12 16:49:42 +01:00
|
|
|
T_NullTest,
|
|
|
|
T_BooleanTest,
|
2003-02-03 22:15:45 +01:00
|
|
|
T_CoerceToDomain,
|
|
|
|
T_CoerceToDomainValue,
|
2003-07-03 18:34:26 +02:00
|
|
|
T_SetToDefault,
|
2007-06-11 03:16:30 +02:00
|
|
|
T_CurrentOfExpr,
|
2002-12-12 16:49:42 +01:00
|
|
|
T_TargetEntry,
|
2001-10-28 07:26:15 +01:00
|
|
|
T_RangeTblRef,
|
|
|
|
T_JoinExpr,
|
2002-12-12 16:49:42 +01:00
|
|
|
T_FromExpr,
|
2007-02-20 18:32:18 +01:00
|
|
|
T_IntoClause,
|
1996-08-28 03:59:28 +02:00
|
|
|
|
2002-12-13 20:46:01 +01:00
|
|
|
/*
|
|
|
|
* TAGS FOR EXPRESSION STATE NODES (execnodes.h)
|
|
|
|
*
|
2005-11-22 19:17:34 +01:00
|
|
|
* These correspond (not always one-for-one) to primitive nodes derived
|
|
|
|
* from Expr.
|
2002-12-13 20:46:01 +01:00
|
|
|
*/
|
|
|
|
T_ExprState = 400,
|
|
|
|
T_GenericExprState,
|
2012-07-20 19:09:00 +02:00
|
|
|
T_WholeRowVarExprState,
|
2002-12-13 20:46:01 +01:00
|
|
|
T_AggrefExprState,
|
2008-12-28 19:54:01 +01:00
|
|
|
T_WindowFuncExprState,
|
2002-12-13 20:46:01 +01:00
|
|
|
T_ArrayRefExprState,
|
|
|
|
T_FuncExprState,
|
2003-06-29 02:33:44 +02:00
|
|
|
T_ScalarArrayOpExprState,
|
2002-12-13 20:46:01 +01:00
|
|
|
T_BoolExprState,
|
2002-12-14 01:17:59 +01:00
|
|
|
T_SubPlanState,
|
2008-08-22 02:16:04 +02:00
|
|
|
T_AlternativeSubPlanState,
|
2004-04-01 23:28:47 +02:00
|
|
|
T_FieldSelectState,
|
2004-06-09 21:08:20 +02:00
|
|
|
T_FieldStoreState,
|
2007-06-05 23:31:09 +02:00
|
|
|
T_CoerceViaIOState,
|
2007-03-28 01:21:12 +02:00
|
|
|
T_ArrayCoerceExprState,
|
2004-12-12 00:26:51 +01:00
|
|
|
T_ConvertRowtypeExprState,
|
2002-12-13 20:46:01 +01:00
|
|
|
T_CaseExprState,
|
|
|
|
T_CaseWhenState,
|
2003-04-09 01:20:04 +02:00
|
|
|
T_ArrayExprState,
|
2004-05-11 00:44:49 +02:00
|
|
|
T_RowExprState,
|
2005-12-28 02:30:02 +01:00
|
|
|
T_RowCompareExprState,
|
2003-02-16 03:30:39 +01:00
|
|
|
T_CoalesceExprState,
|
2005-06-27 00:05:42 +02:00
|
|
|
T_MinMaxExprState,
|
2006-12-24 01:29:20 +01:00
|
|
|
T_XmlExprState,
|
2006-09-28 22:51:43 +02:00
|
|
|
T_NullTestState,
|
2003-02-03 22:15:45 +01:00
|
|
|
T_CoerceToDomainState,
|
|
|
|
T_DomainConstraintState,
|
2002-12-13 20:46:01 +01:00
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
1999-08-16 04:17:58 +02:00
|
|
|
* TAGS FOR PLANNER NODES (relation.h)
|
1997-09-07 07:04:48 +02:00
|
|
|
*/
|
2005-06-06 00:32:58 +02:00
|
|
|
T_PlannerInfo = 500,
|
2007-02-19 08:03:34 +01:00
|
|
|
T_PlannerGlobal,
|
2005-06-06 00:32:58 +02:00
|
|
|
T_RelOptInfo,
|
2002-11-30 06:21:03 +01:00
|
|
|
T_IndexOptInfo,
|
Revise parameterized-path mechanism to fix assorted issues.
This patch adjusts the treatment of parameterized paths so that all paths
with the same parameterization (same set of required outer rels) for the
same relation will have the same rowcount estimate. We cache the rowcount
estimates to ensure that property, and hopefully save a few cycles too.
Doing this makes it practical for add_path_precheck to operate without
a rowcount estimate: it need only assume that paths with different
parameterizations never dominate each other, which is close enough to
true anyway for coarse filtering, because normally a more-parameterized
path should yield fewer rows thanks to having more join clauses to apply.
In add_path, we do the full nine yards of comparing rowcount estimates
along with everything else, so that we can discard parameterized paths that
don't actually have an advantage. This fixes some issues I'd found with
add_path rejecting parameterized paths on the grounds that they were more
expensive than not-parameterized ones, even though they yielded many fewer
rows and hence would be cheaper once subsequent joining was considered.
To make the same-rowcounts assumption valid, we have to require that any
parameterized path enforce *all* join clauses that could be obtained from
the particular set of outer rels, even if not all of them are useful for
indexing. This is required at both base scans and joins. It's a good
thing anyway since the net impact is that join quals are checked at the
lowest practical level in the join tree. Hence, discard the original
rather ad-hoc mechanism for choosing parameterization joinquals, and build
a better one that has a more principled rule for when clauses can be moved.
The original rule was actually buggy anyway for lack of knowledge about
which relations are part of an outer join's outer side; getting this right
requires adding an outer_relids field to RestrictInfo.
2012-04-19 21:52:46 +02:00
|
|
|
T_ParamPathInfo,
|
2001-10-28 07:26:15 +01:00
|
|
|
T_Path,
|
|
|
|
T_IndexPath,
|
2005-04-20 00:35:18 +02:00
|
|
|
T_BitmapHeapPath,
|
2005-04-21 21:18:13 +02:00
|
|
|
T_BitmapAndPath,
|
|
|
|
T_BitmapOrPath,
|
2001-10-28 07:26:15 +01:00
|
|
|
T_NestPath,
|
|
|
|
T_MergePath,
|
|
|
|
T_HashPath,
|
|
|
|
T_TidPath,
|
2011-02-20 06:17:18 +01:00
|
|
|
T_ForeignPath,
|
2014-11-07 23:26:02 +01:00
|
|
|
T_CustomPath,
|
2001-10-28 07:26:15 +01:00
|
|
|
T_AppendPath,
|
2010-10-14 22:56:39 +02:00
|
|
|
T_MergeAppendPath,
|
2002-11-06 01:00:45 +01:00
|
|
|
T_ResultPath,
|
2002-11-30 06:21:03 +01:00
|
|
|
T_MaterialPath,
|
2003-01-20 19:55:07 +01:00
|
|
|
T_UniquePath,
|
2007-01-20 21:45:41 +01:00
|
|
|
T_EquivalenceClass,
|
|
|
|
T_EquivalenceMember,
|
|
|
|
T_PathKey,
|
2001-10-28 07:26:15 +01:00
|
|
|
T_RestrictInfo,
|
2008-10-21 22:42:53 +02:00
|
|
|
T_PlaceHolderVar,
|
2008-08-14 20:48:00 +02:00
|
|
|
T_SpecialJoinInfo,
|
2012-08-27 04:48:55 +02:00
|
|
|
T_LateralJoinInfo,
|
2006-01-31 22:39:25 +01:00
|
|
|
T_AppendRelInfo,
|
2008-10-21 22:42:53 +02:00
|
|
|
T_PlaceHolderInfo,
|
2010-11-04 17:01:17 +01:00
|
|
|
T_MinMaxAggInfo,
|
2007-02-19 08:03:34 +01:00
|
|
|
T_PlannerParamItem,
|
1996-08-28 03:59:28 +02:00
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* TAGS FOR MEMORY NODES (memnodes.h)
|
|
|
|
*/
|
2002-12-13 20:46:01 +01:00
|
|
|
T_MemoryContext = 600,
|
2001-10-28 07:26:15 +01:00
|
|
|
T_AllocSetContext,
|
1996-08-28 03:59:28 +02:00
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2004-01-07 19:43:36 +01:00
|
|
|
* TAGS FOR VALUE NODES (value.h)
|
1997-09-07 07:04:48 +02:00
|
|
|
*/
|
2002-12-13 20:46:01 +01:00
|
|
|
T_Value = 650,
|
2001-10-28 07:26:15 +01:00
|
|
|
T_Integer,
|
|
|
|
T_Float,
|
|
|
|
T_String,
|
|
|
|
T_BitString,
|
|
|
|
T_Null,
|
1996-08-28 03:59:28 +02:00
|
|
|
|
2004-01-07 19:43:36 +01:00
|
|
|
/*
|
|
|
|
* TAGS FOR LIST NODES (pg_list.h)
|
|
|
|
*/
|
|
|
|
T_List,
|
2004-05-26 06:41:50 +02:00
|
|
|
T_IntList,
|
|
|
|
T_OidList,
|
2004-01-07 19:43:36 +01:00
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2007-02-20 18:32:18 +01:00
|
|
|
* TAGS FOR STATEMENT NODES (mostly in parsenodes.h)
|
1997-09-07 07:04:48 +02:00
|
|
|
*/
|
2002-12-05 16:50:39 +01:00
|
|
|
T_Query = 700,
|
2007-02-20 18:32:18 +01:00
|
|
|
T_PlannedStmt,
|
2001-10-28 07:26:15 +01:00
|
|
|
T_InsertStmt,
|
|
|
|
T_DeleteStmt,
|
|
|
|
T_UpdateStmt,
|
|
|
|
T_SelectStmt,
|
|
|
|
T_AlterTableStmt,
|
2004-05-05 06:48:48 +02:00
|
|
|
T_AlterTableCmd,
|
2002-12-06 06:00:34 +01:00
|
|
|
T_AlterDomainStmt,
|
2001-10-28 07:26:15 +01:00
|
|
|
T_SetOperationStmt,
|
|
|
|
T_GrantStmt,
|
2005-06-28 07:09:14 +02:00
|
|
|
T_GrantRoleStmt,
|
2009-10-05 21:24:49 +02:00
|
|
|
T_AlterDefaultPrivilegesStmt,
|
2001-10-28 07:26:15 +01:00
|
|
|
T_ClosePortalStmt,
|
|
|
|
T_ClusterStmt,
|
|
|
|
T_CopyStmt,
|
|
|
|
T_CreateStmt,
|
|
|
|
T_DefineStmt,
|
|
|
|
T_DropStmt,
|
|
|
|
T_TruncateStmt,
|
|
|
|
T_CommentStmt,
|
|
|
|
T_FetchStmt,
|
|
|
|
T_IndexStmt,
|
2002-05-17 20:32:52 +02:00
|
|
|
T_CreateFunctionStmt,
|
2005-03-14 01:19:37 +01:00
|
|
|
T_AlterFunctionStmt,
|
2009-09-23 01:43:43 +02:00
|
|
|
T_DoStmt,
|
2001-10-28 07:26:15 +01:00
|
|
|
T_RenameStmt,
|
|
|
|
T_RuleStmt,
|
|
|
|
T_NotifyStmt,
|
|
|
|
T_ListenStmt,
|
|
|
|
T_UnlistenStmt,
|
|
|
|
T_TransactionStmt,
|
|
|
|
T_ViewStmt,
|
|
|
|
T_LoadStmt,
|
2002-03-19 03:18:25 +01:00
|
|
|
T_CreateDomainStmt,
|
2001-10-28 07:26:15 +01:00
|
|
|
T_CreatedbStmt,
|
|
|
|
T_DropdbStmt,
|
|
|
|
T_VacuumStmt,
|
|
|
|
T_ExplainStmt,
|
Restructure SELECT INTO's parsetree representation into CreateTableAsStmt.
Making this operation look like a utility statement seems generally a good
idea, and particularly so in light of the desire to provide command
triggers for utility statements. The original choice of representing it as
SELECT with an IntoClause appendage had metastasized into rather a lot of
places, unfortunately, so that this patch is a great deal more complicated
than one might at first expect.
In particular, keeping EXPLAIN working for SELECT INTO and CREATE TABLE AS
subcommands required restructuring some EXPLAIN-related APIs. Add-on code
that calls ExplainOnePlan or ExplainOneUtility, or uses
ExplainOneQuery_hook, will need adjustment.
Also, the cases PREPARE ... SELECT INTO and CREATE RULE ... SELECT INTO,
which formerly were accepted though undocumented, are no longer accepted.
The PREPARE case can be replaced with use of CREATE TABLE AS EXECUTE.
The CREATE RULE case doesn't seem to have much real-world use (since the
rule would work only once before failing with "table already exists"),
so we'll not bother with that one.
Both SELECT INTO and CREATE TABLE AS still return a command tag of
"SELECT nnnn". There was some discussion of returning "CREATE TABLE nnnn",
but for the moment backwards compatibility wins the day.
Andres Freund and Tom Lane
2012-03-20 02:37:19 +01:00
|
|
|
T_CreateTableAsStmt,
|
2001-10-28 07:26:15 +01:00
|
|
|
T_CreateSeqStmt,
|
2003-03-20 08:02:11 +01:00
|
|
|
T_AlterSeqStmt,
|
2001-10-28 07:26:15 +01:00
|
|
|
T_VariableSetStmt,
|
|
|
|
T_VariableShowStmt,
|
2007-04-26 18:13:15 +02:00
|
|
|
T_DiscardStmt,
|
2001-10-28 07:26:15 +01:00
|
|
|
T_CreateTrigStmt,
|
|
|
|
T_CreatePLangStmt,
|
2005-06-28 07:09:14 +02:00
|
|
|
T_CreateRoleStmt,
|
|
|
|
T_AlterRoleStmt,
|
|
|
|
T_DropRoleStmt,
|
2001-10-28 07:26:15 +01:00
|
|
|
T_LockStmt,
|
|
|
|
T_ConstraintsSetStmt,
|
|
|
|
T_ReindexStmt,
|
|
|
|
T_CheckPointStmt,
|
2002-03-21 17:02:16 +01:00
|
|
|
T_CreateSchemaStmt,
|
2005-07-31 19:19:22 +02:00
|
|
|
T_AlterDatabaseStmt,
|
2002-03-01 23:45:19 +01:00
|
|
|
T_AlterDatabaseSetStmt,
|
2005-06-28 07:09:14 +02:00
|
|
|
T_AlterRoleSetStmt,
|
2002-07-11 09:39:28 +02:00
|
|
|
T_CreateConversionStmt,
|
2002-07-19 01:11:32 +02:00
|
|
|
T_CreateCastStmt,
|
2002-07-30 00:14:11 +02:00
|
|
|
T_CreateOpClassStmt,
|
2007-01-23 06:07:18 +01:00
|
|
|
T_CreateOpFamilyStmt,
|
|
|
|
T_AlterOpFamilyStmt,
|
2002-08-27 06:55:12 +02:00
|
|
|
T_PrepareStmt,
|
|
|
|
T_ExecuteStmt,
|
|
|
|
T_DeallocateStmt,
|
2003-03-10 04:53:52 +01:00
|
|
|
T_DeclareCursorStmt,
|
2004-06-18 08:14:31 +02:00
|
|
|
T_CreateTableSpaceStmt,
|
|
|
|
T_DropTableSpaceStmt,
|
2005-08-01 06:03:59 +02:00
|
|
|
T_AlterObjectSchemaStmt,
|
2004-06-25 23:55:59 +02:00
|
|
|
T_AlterOwnerStmt,
|
2005-11-21 13:49:33 +01:00
|
|
|
T_DropOwnedStmt,
|
|
|
|
T_ReassignOwnedStmt,
|
2007-02-20 18:32:18 +01:00
|
|
|
T_CompositeTypeStmt,
|
2007-04-02 05:49:42 +02:00
|
|
|
T_CreateEnumStmt,
|
2011-11-03 12:16:28 +01:00
|
|
|
T_CreateRangeStmt,
|
2010-10-25 05:04:37 +02:00
|
|
|
T_AlterEnumStmt,
|
2007-08-21 03:11:32 +02:00
|
|
|
T_AlterTSDictionaryStmt,
|
|
|
|
T_AlterTSConfigurationStmt,
|
2008-12-19 17:25:19 +01:00
|
|
|
T_CreateFdwStmt,
|
|
|
|
T_AlterFdwStmt,
|
|
|
|
T_CreateForeignServerStmt,
|
|
|
|
T_AlterForeignServerStmt,
|
|
|
|
T_CreateUserMappingStmt,
|
|
|
|
T_AlterUserMappingStmt,
|
|
|
|
T_DropUserMappingStmt,
|
2010-01-05 22:54:00 +01:00
|
|
|
T_AlterTableSpaceOptionsStmt,
|
2014-08-22 01:06:17 +02:00
|
|
|
T_AlterTableMoveAllStmt,
|
2010-09-28 02:55:27 +02:00
|
|
|
T_SecLabelStmt,
|
2011-01-02 05:48:11 +01:00
|
|
|
T_CreateForeignTableStmt,
|
2014-07-10 21:01:31 +02:00
|
|
|
T_ImportForeignSchemaStmt,
|
2011-02-08 22:08:41 +01:00
|
|
|
T_CreateExtensionStmt,
|
2011-02-12 03:25:20 +01:00
|
|
|
T_AlterExtensionStmt,
|
2011-02-10 23:36:44 +01:00
|
|
|
T_AlterExtensionContentsStmt,
|
2012-07-18 16:16:16 +02:00
|
|
|
T_CreateEventTrigStmt,
|
|
|
|
T_AlterEventTrigStmt,
|
2013-03-04 01:23:31 +01:00
|
|
|
T_RefreshMatViewStmt,
|
2013-11-08 18:30:43 +01:00
|
|
|
T_ReplicaIdentityStmt,
|
2013-12-18 15:42:44 +01:00
|
|
|
T_AlterSystemStmt,
|
Row-Level Security Policies (RLS)
Building on the updatable security-barrier views work, add the
ability to define policies on tables to limit the set of rows
which are returned from a query and which are allowed to be added
to a table. Expressions defined by the policy for filtering are
added to the security barrier quals of the query, while expressions
defined to check records being added to a table are added to the
with-check options of the query.
New top-level commands are CREATE/ALTER/DROP POLICY and are
controlled by the table owner. Row Security is able to be enabled
and disabled by the owner on a per-table basis using
ALTER TABLE .. ENABLE/DISABLE ROW SECURITY.
Per discussion, ROW SECURITY is disabled on tables by default and
must be enabled for policies on the table to be used. If no
policies exist on a table with ROW SECURITY enabled, a default-deny
policy is used and no records will be visible.
By default, row security is applied at all times except for the
table owner and the superuser. A new GUC, row_security, is added
which can be set to ON, OFF, or FORCE. When set to FORCE, row
security will be applied even for the table owner and superusers.
When set to OFF, row security will be disabled when allowed and an
error will be thrown if the user does not have rights to bypass row
security.
Per discussion, pg_dump sets row_security = OFF by default to ensure
that exports and backups will have all data in the table or will
error if there are insufficient privileges to bypass row security.
A new option has been added to pg_dump, --enable-row-security, to
ask pg_dump to export with row security enabled.
A new role capability, BYPASSRLS, which can only be set by the
superuser, is added to allow other users to be able to bypass row
security using row_security = OFF.
Many thanks to the various individuals who have helped with the
design, particularly Robert Haas for his feedback.
Authors include Craig Ringer, KaiGai Kohei, Adam Brightwell, Dean
Rasheed, with additional changes and rework by me.
Reviewers have included all of the above, Greg Smith,
Jeff McCormick, and Robert Haas.
2014-09-19 17:18:35 +02:00
|
|
|
T_CreatePolicyStmt,
|
|
|
|
T_AlterPolicyStmt,
|
2015-04-26 16:33:14 +02:00
|
|
|
T_CreateTransformStmt,
|
2001-10-28 07:26:15 +01:00
|
|
|
|
2007-02-20 18:32:18 +01:00
|
|
|
/*
|
|
|
|
* TAGS FOR PARSE TREE NODES (parsenodes.h)
|
|
|
|
*/
|
|
|
|
T_A_Expr = 900,
|
2002-03-21 17:02:16 +01:00
|
|
|
T_ColumnRef,
|
|
|
|
T_ParamRef,
|
|
|
|
T_A_Const,
|
2001-10-28 07:26:15 +01:00
|
|
|
T_FuncCall,
|
2008-08-30 03:39:14 +02:00
|
|
|
T_A_Star,
|
2001-10-28 07:26:15 +01:00
|
|
|
T_A_Indices,
|
2004-06-09 21:08:20 +02:00
|
|
|
T_A_Indirection,
|
2008-03-20 22:42:48 +01:00
|
|
|
T_A_ArrayExpr,
|
2001-10-28 07:26:15 +01:00
|
|
|
T_ResTarget,
|
Implement UPDATE tab SET (col1,col2,...) = (SELECT ...), ...
This SQL-standard feature allows a sub-SELECT yielding multiple columns
(but only one row) to be used to compute the new values of several columns
to be updated. While the same results can be had with an independent
sub-SELECT per column, such a workaround can require a great deal of
duplicated computation.
The standard actually says that the source for a multi-column assignment
could be any row-valued expression. The implementation used here is
tightly tied to our existing sub-SELECT support and can't handle other
cases; the Bison grammar would have some issues with them too. However,
I don't feel too bad about this since other cases can be converted into
sub-SELECTs. For instance, "SET (a,b,c) = row_valued_function(x)" could
be written "SET (a,b,c) = (SELECT * FROM row_valued_function(x))".
2014-06-18 19:22:25 +02:00
|
|
|
T_MultiAssignRef,
|
2001-10-28 07:26:15 +01:00
|
|
|
T_TypeCast,
|
2011-03-11 22:27:51 +01:00
|
|
|
T_CollateClause,
|
2003-08-17 21:58:06 +02:00
|
|
|
T_SortBy,
|
2008-12-28 19:54:01 +01:00
|
|
|
T_WindowDef,
|
2002-03-21 17:02:16 +01:00
|
|
|
T_RangeSubselect,
|
2002-05-12 22:10:05 +02:00
|
|
|
T_RangeFunction,
|
2001-10-28 07:26:15 +01:00
|
|
|
T_TypeName,
|
|
|
|
T_ColumnDef,
|
2002-12-12 16:49:42 +01:00
|
|
|
T_IndexElem,
|
2001-10-28 07:26:15 +01:00
|
|
|
T_Constraint,
|
|
|
|
T_DefElem,
|
|
|
|
T_RangeTblEntry,
|
Support multi-argument UNNEST(), and TABLE() syntax for multiple functions.
This patch adds the ability to write TABLE( function1(), function2(), ...)
as a single FROM-clause entry. The result is the concatenation of the
first row from each function, followed by the second row from each
function, etc; with NULLs inserted if any function produces fewer rows than
others. This is believed to be a much more useful behavior than what
Postgres currently does with multiple SRFs in a SELECT list.
This syntax also provides a reasonable way to combine use of column
definition lists with WITH ORDINALITY: put the column definition list
inside TABLE(), where it's clear that it doesn't control the ordinality
column as well.
Also implement SQL-compliant multiple-argument UNNEST(), by turning
UNNEST(a,b,c) into TABLE(unnest(a), unnest(b), unnest(c)).
The SQL standard specifies TABLE() with only a single function, not
multiple functions, and it seems to require an implicit UNNEST() which is
not what this patch does. There may be something wrong with that reading
of the spec, though, because if it's right then the spec's TABLE() is just
a pointless alternative spelling of UNNEST(). After further review of
that, we might choose to adopt a different syntax for what this patch does,
but in any case this functionality seems clearly worthwhile.
Andrew Gierth, reviewed by Zoltán Böszörményi and Heikki Linnakangas, and
significantly revised by me
2013-11-22 01:37:02 +01:00
|
|
|
T_RangeTblFunction,
|
2013-07-18 23:10:16 +02:00
|
|
|
T_WithCheckOption,
|
2008-08-02 23:32:01 +02:00
|
|
|
T_SortGroupClause,
|
2008-12-28 19:54:01 +01:00
|
|
|
T_WindowClause,
|
2001-10-28 07:26:15 +01:00
|
|
|
T_PrivGrantee,
|
2002-02-19 00:11:58 +01:00
|
|
|
T_FuncWithArgs,
|
2009-01-22 21:16:10 +01:00
|
|
|
T_AccessPriv,
|
2002-07-30 00:14:11 +02:00
|
|
|
T_CreateOpClassItem,
|
2012-01-07 13:58:13 +01:00
|
|
|
T_TableLikeClause,
|
2004-01-07 00:55:19 +01:00
|
|
|
T_FunctionParameter,
|
2005-08-01 22:31:16 +02:00
|
|
|
T_LockingClause,
|
2006-04-30 20:30:40 +02:00
|
|
|
T_RowMarkClause,
|
2007-02-03 15:06:56 +01:00
|
|
|
T_XmlSerialize,
|
2008-10-04 23:56:55 +02:00
|
|
|
T_WithClause,
|
|
|
|
T_CommonTableExpr,
|
Allow CURRENT/SESSION_USER to be used in certain commands
Commands such as ALTER USER, ALTER GROUP, ALTER ROLE, GRANT, and the
various ALTER OBJECT / OWNER TO, as well as ad-hoc clauses related to
roles such as the AUTHORIZATION clause of CREATE SCHEMA, the FOR clause
of CREATE USER MAPPING, and the FOR ROLE clause of ALTER DEFAULT
PRIVILEGES can now take the keywords CURRENT_USER and SESSION_USER as
user specifiers in place of an explicit user name.
This commit also fixes some quite ugly handling of special standards-
mandated syntax in CREATE USER MAPPING, which in particular would fail
to work in presence of a role named "current_user".
The special role specifiers PUBLIC and NONE also have more consistent
handling now.
Also take the opportunity to add location tracking to user specifiers.
Authors: Kyotaro Horiguchi. Heavily reworked by Álvaro Herrera.
Reviewed by: Rushabh Lathia, Adam Brightwell, Marti Raudsepp.
2015-03-09 19:41:54 +01:00
|
|
|
T_RoleSpec,
|
2000-05-29 03:59:17 +02:00
|
|
|
|
2011-08-06 20:53:49 +02:00
|
|
|
/*
|
|
|
|
* TAGS FOR REPLICATION GRAMMAR PARSE NODES (replnodes.h)
|
|
|
|
*/
|
|
|
|
T_IdentifySystemCmd,
|
|
|
|
T_BaseBackupCmd,
|
2014-02-01 04:45:17 +01:00
|
|
|
T_CreateReplicationSlotCmd,
|
|
|
|
T_DropReplicationSlotCmd,
|
2011-08-06 20:53:49 +02:00
|
|
|
T_StartReplicationCmd,
|
Allow a streaming replication standby to follow a timeline switch.
Before this patch, streaming replication would refuse to start replicating
if the timeline in the primary doesn't exactly match the standby. The
situation where it doesn't match is when you have a master, and two
standbys, and you promote one of the standbys to become new master.
Promoting bumps up the timeline ID, and after that bump, the other standby
would refuse to continue.
There's significantly more timeline related logic in streaming replication
now. First of all, when a standby connects to primary, it will ask the
primary for any timeline history files that are missing from the standby.
The missing files are sent using a new replication command TIMELINE_HISTORY,
and stored in standby's pg_xlog directory. Using the timeline history files,
the standby can follow the latest timeline present in the primary
(recovery_target_timeline='latest'), just as it can follow new timelines
appearing in an archive directory.
START_REPLICATION now takes a TIMELINE parameter, to specify exactly which
timeline to stream WAL from. This allows the standby to request the primary
to send over WAL that precedes the promotion. The replication protocol is
changed slightly (in a backwards-compatible way although there's little hope
of streaming replication working across major versions anyway), to allow
replication to stop when the end of timeline reached, putting the walsender
back into accepting a replication command.
Many thanks to Amit Kapila for testing and reviewing various versions of
this patch.
2012-12-13 18:00:00 +01:00
|
|
|
T_TimeLineHistoryCmd,
|
2011-08-06 20:53:49 +02:00
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2005-04-18 00:24:02 +02:00
|
|
|
* TAGS FOR RANDOM OTHER STUFF
|
|
|
|
*
|
|
|
|
* These are objects that aren't part of parse/plan/execute node tree
|
|
|
|
* structures, but we give them NodeTags anyway for identification
|
2005-10-15 04:49:52 +02:00
|
|
|
* purposes (usually because they are involved in APIs where we want to
|
|
|
|
* pass multiple object types through the same pointer).
|
2000-05-29 03:59:17 +02:00
|
|
|
*/
|
2007-02-20 18:32:18 +01:00
|
|
|
T_TriggerData = 950, /* in commands/trigger.h */
|
2012-07-20 17:38:47 +02:00
|
|
|
T_EventTriggerData, /* in commands/event_trigger.h */
|
2005-04-18 00:24:02 +02:00
|
|
|
T_ReturnSetInfo, /* in nodes/execnodes.h */
|
2008-12-28 19:54:01 +01:00
|
|
|
T_WindowObjectData, /* private in nodeWindowAgg.c */
|
2009-09-23 01:43:43 +02:00
|
|
|
T_TIDBitmap, /* in nodes/tidbitmap.h */
|
2011-02-20 06:17:18 +01:00
|
|
|
T_InlineCodeBlock, /* in nodes/parsenodes.h */
|
|
|
|
T_FdwRoutine /* in foreign/fdwapi.h */
|
1997-09-08 23:56:23 +02:00
|
|
|
} NodeTag;
|
1996-08-28 03:59:28 +02:00
|
|
|
|
|
|
|
/*
|
1998-12-04 16:34:49 +01:00
|
|
|
* The first field of a node of any type is guaranteed to be the NodeTag.
|
1996-08-28 03:59:28 +02:00
|
|
|
* Hence the type of any node can be gotten by casting it to Node. Declaring
|
|
|
|
* a variable to be of Node * (instead of void *) can also facilitate
|
|
|
|
* debugging.
|
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef struct Node
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
NodeTag type;
|
1997-09-08 23:56:23 +02:00
|
|
|
} Node;
|
1996-08-28 03:59:28 +02:00
|
|
|
|
2011-12-07 20:46:56 +01:00
|
|
|
#define nodeTag(nodeptr) (((const Node*)(nodeptr))->type)
|
1996-08-28 03:59:28 +02:00
|
|
|
|
2002-11-10 03:17:25 +01:00
|
|
|
/*
|
2002-12-16 17:22:46 +01:00
|
|
|
* newNode -
|
|
|
|
* create a new node of the specified size and tag the node with the
|
|
|
|
* specified tag.
|
|
|
|
*
|
|
|
|
* !WARNING!: Avoid using newNode directly. You should be using the
|
|
|
|
* macro makeNode. eg. to create a Query node, use makeNode(Query)
|
|
|
|
*
|
2008-08-30 00:49:07 +02:00
|
|
|
* Note: the size argument should always be a compile-time constant, so the
|
|
|
|
* apparent risk of multiple evaluation doesn't matter in practice.
|
|
|
|
*/
|
|
|
|
#ifdef __GNUC__
|
|
|
|
|
|
|
|
/* With GCC, we can use a compound statement within an expression */
|
|
|
|
#define newNode(size, tag) \
|
|
|
|
({ Node *_result; \
|
|
|
|
AssertMacro((size) >= sizeof(Node)); /* need the tag, at least */ \
|
|
|
|
_result = (Node *) palloc0fast(size); \
|
|
|
|
_result->type = (tag); \
|
|
|
|
_result; \
|
|
|
|
})
|
|
|
|
#else
|
|
|
|
|
|
|
|
/*
|
2002-11-10 03:17:25 +01:00
|
|
|
* There is no way to dereference the palloc'ed pointer to assign the
|
2002-12-16 17:22:46 +01:00
|
|
|
* tag, and also return the pointer itself, so we need a holder variable.
|
|
|
|
* Fortunately, this macro isn't recursive so we just define
|
2002-11-10 03:17:25 +01:00
|
|
|
* a global variable for this purpose.
|
|
|
|
*/
|
2007-07-25 14:22:54 +02:00
|
|
|
extern PGDLLIMPORT Node *newNodeMacroHolder;
|
2002-11-10 03:17:25 +01:00
|
|
|
|
|
|
|
#define newNode(size, tag) \
|
|
|
|
( \
|
|
|
|
AssertMacro((size) >= sizeof(Node)), /* need the tag, at least */ \
|
2002-12-16 17:22:46 +01:00
|
|
|
newNodeMacroHolder = (Node *) palloc0fast(size), \
|
2002-11-10 03:17:25 +01:00
|
|
|
newNodeMacroHolder->type = (tag), \
|
|
|
|
newNodeMacroHolder \
|
|
|
|
)
|
2008-08-30 00:49:07 +02:00
|
|
|
#endif /* __GNUC__ */
|
|
|
|
|
2002-11-10 03:17:25 +01:00
|
|
|
|
1999-08-16 04:17:58 +02:00
|
|
|
#define makeNode(_type_) ((_type_ *) newNode(sizeof(_type_),T_##_type_))
|
|
|
|
#define NodeSetTag(nodeptr,t) (((Node*)(nodeptr))->type = (t))
|
1996-08-28 03:59:28 +02:00
|
|
|
|
1999-08-16 04:17:58 +02:00
|
|
|
#define IsA(nodeptr,_type_) (nodeTag(nodeptr) == T_##_type_)
|
1996-08-28 03:59:28 +02:00
|
|
|
|
|
|
|
/* ----------------------------------------------------------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* extern declarations follow
|
1996-08-28 03:59:28 +02:00
|
|
|
* ----------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
1999-08-16 04:17:58 +02:00
|
|
|
/*
|
|
|
|
* nodes/{outfuncs.c,print.c}
|
|
|
|
*/
|
2011-12-07 20:46:56 +01:00
|
|
|
extern char *nodeToString(const void *obj);
|
1996-08-28 03:59:28 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* nodes/{readfuncs.c,read.c}
|
|
|
|
*/
|
1997-09-08 04:41:22 +02:00
|
|
|
extern void *stringToNode(char *str);
|
1996-08-28 03:59:28 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* nodes/copyfuncs.c
|
|
|
|
*/
|
2011-12-07 20:46:56 +01:00
|
|
|
extern void *copyObject(const void *obj);
|
1996-08-28 03:59:28 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* nodes/equalfuncs.c
|
|
|
|
*/
|
2011-12-07 20:46:56 +01:00
|
|
|
extern bool equal(const void *a, const void *b);
|
1996-08-28 03:59:28 +02:00
|
|
|
|
|
|
|
|
2000-01-09 01:26:47 +01:00
|
|
|
/*
|
|
|
|
* Typedefs for identifying qualifier selectivities and plan costs as such.
|
|
|
|
* These are just plain "double"s, but declaring a variable as Selectivity
|
|
|
|
* or Cost makes the intent more obvious.
|
|
|
|
*
|
|
|
|
* These could have gone into plannodes.h or some such, but many files
|
|
|
|
* depend on them...
|
1996-08-28 03:59:28 +02:00
|
|
|
*/
|
2005-10-15 04:49:52 +02:00
|
|
|
typedef double Selectivity; /* fraction of tuples a qualifier will pass */
|
2000-01-09 01:26:47 +01:00
|
|
|
typedef double Cost; /* execution cost (in page-access units) */
|
|
|
|
|
1996-08-28 03:59:28 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* CmdType -
|
2007-02-20 18:32:18 +01:00
|
|
|
* enums for type of operation represented by a Query or PlannedStmt
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
2007-02-20 18:32:18 +01:00
|
|
|
* This is needed in both parsenodes.h and plannodes.h, so put it here...
|
1996-08-28 03:59:28 +02:00
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef enum CmdType
|
|
|
|
{
|
2001-10-28 07:26:15 +01:00
|
|
|
CMD_UNKNOWN,
|
2006-01-01 02:41:42 +01:00
|
|
|
CMD_SELECT, /* select stmt */
|
|
|
|
CMD_UPDATE, /* update stmt */
|
|
|
|
CMD_INSERT, /* insert stmt */
|
2001-10-28 07:26:15 +01:00
|
|
|
CMD_DELETE,
|
2005-10-15 04:49:52 +02:00
|
|
|
CMD_UTILITY, /* cmds like create, destroy, copy, vacuum,
|
|
|
|
* etc. */
|
2001-10-28 07:26:15 +01:00
|
|
|
CMD_NOTHING /* dummy command for instead nothing rules
|
1998-09-01 06:40:42 +02:00
|
|
|
* with qual */
|
1997-09-08 23:56:23 +02:00
|
|
|
} CmdType;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1996-08-28 03:59:28 +02:00
|
|
|
|
2000-09-12 23:07:18 +02:00
|
|
|
/*
|
|
|
|
* JoinType -
|
|
|
|
* enums for types of relation joins
|
|
|
|
*
|
|
|
|
* JoinType determines the exact semantics of joining two relations using
|
|
|
|
* a matching qualification. For example, it tells what to do with a tuple
|
|
|
|
* that has no match in the other relation.
|
|
|
|
*
|
|
|
|
* This is needed in both parsenodes.h and plannodes.h, so put it here...
|
|
|
|
*/
|
|
|
|
typedef enum JoinType
|
|
|
|
{
|
|
|
|
/*
|
2009-06-11 16:49:15 +02:00
|
|
|
* The canonical kinds of joins according to the SQL JOIN syntax. Only
|
|
|
|
* these codes can appear in parser output (e.g., JoinExpr nodes).
|
2000-09-12 23:07:18 +02:00
|
|
|
*/
|
2001-10-28 07:26:15 +01:00
|
|
|
JOIN_INNER, /* matching tuple pairs only */
|
2008-08-14 20:48:00 +02:00
|
|
|
JOIN_LEFT, /* pairs + unmatched LHS tuples */
|
|
|
|
JOIN_FULL, /* pairs + unmatched LHS + unmatched RHS */
|
|
|
|
JOIN_RIGHT, /* pairs + unmatched RHS tuples */
|
2001-03-22 05:01:46 +01:00
|
|
|
|
2000-09-12 23:07:18 +02:00
|
|
|
/*
|
2009-06-11 16:49:15 +02:00
|
|
|
* Semijoins and anti-semijoins (as defined in relational theory) do not
|
|
|
|
* appear in the SQL JOIN syntax, but there are standard idioms for
|
2014-05-06 18:12:18 +02:00
|
|
|
* representing them (e.g., using EXISTS). The planner recognizes these
|
2008-08-14 20:48:00 +02:00
|
|
|
* cases and converts them to joins. So the planner and executor must
|
|
|
|
* support these codes. NOTE: in JOIN_SEMI output, it is unspecified
|
2009-06-11 16:49:15 +02:00
|
|
|
* which matching RHS row is joined to. In JOIN_ANTI output, the row is
|
|
|
|
* guaranteed to be null-extended.
|
2003-01-20 19:55:07 +01:00
|
|
|
*/
|
2008-08-14 20:48:00 +02:00
|
|
|
JOIN_SEMI, /* 1 copy of each LHS row that has match(es) */
|
|
|
|
JOIN_ANTI, /* 1 copy of each LHS row that has no match */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* These codes are used internally in the planner, but are not supported
|
|
|
|
* by the executor (nor, indeed, by most of the planner).
|
|
|
|
*/
|
|
|
|
JOIN_UNIQUE_OUTER, /* LHS path must be made unique */
|
|
|
|
JOIN_UNIQUE_INNER /* RHS path must be made unique */
|
2003-01-20 19:55:07 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We might need additional join types someday.
|
2000-09-12 23:07:18 +02:00
|
|
|
*/
|
|
|
|
} JoinType;
|
|
|
|
|
2008-08-14 20:48:00 +02:00
|
|
|
/*
|
|
|
|
* OUTER joins are those for which pushed-down quals must behave differently
|
2008-11-22 23:47:06 +01:00
|
|
|
* from the join's own quals. This is in fact everything except INNER and
|
2014-05-06 18:12:18 +02:00
|
|
|
* SEMI joins. However, this macro must also exclude the JOIN_UNIQUE symbols
|
2008-11-22 23:47:06 +01:00
|
|
|
* since those are temporary proxies for what will eventually be an INNER
|
|
|
|
* join.
|
2008-08-14 20:48:00 +02:00
|
|
|
*
|
2008-11-22 23:47:06 +01:00
|
|
|
* Note: semijoins are a hybrid case, but we choose to treat them as not
|
|
|
|
* being outer joins. This is okay principally because the SQL syntax makes
|
|
|
|
* it impossible to have a pushed-down qual that refers to the inner relation
|
|
|
|
* of a semijoin; so there is no strong need to distinguish join quals from
|
|
|
|
* pushed-down quals. This is convenient because for almost all purposes,
|
|
|
|
* quals attached to a semijoin can be treated the same as innerjoin quals.
|
2008-08-14 20:48:00 +02:00
|
|
|
*/
|
2000-09-12 23:07:18 +02:00
|
|
|
#define IS_OUTER_JOIN(jointype) \
|
2008-11-22 23:47:06 +01:00
|
|
|
(((1 << (jointype)) & \
|
|
|
|
((1 << JOIN_LEFT) | \
|
|
|
|
(1 << JOIN_FULL) | \
|
|
|
|
(1 << JOIN_RIGHT) | \
|
|
|
|
(1 << JOIN_ANTI))) != 0)
|
2001-10-28 07:26:15 +01:00
|
|
|
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* NODES_H */
|