mirror of
https://github.com/postgres/postgres.git
synced 2025-10-29 22:49:41 +03:00
Revert MERGE patch
This reverts commitsd204ef6377,83454e3c2band a few more commits thereafter (complete list at the end) related to MERGE feature. While the feature was fully functional, with sufficient test coverage and necessary documentation, it was felt that some parts of the executor and parse-analyzer can use a different design and it wasn't possible to do that in the available time. So it was decided to revert the patch for PG11 and retry again in the future. Thanks again to all reviewers and bug reporters. List of commits reverted, in reverse chronological order:f1464c5380Improve parse representation for MERGEddb4158579MERGE syntax diagram correction530e69e59bAllow cpluspluscheck to pass by renaming variable01b88b4df5MERGE minor errata3af7b2b0d4MERGE fix variable warning in non-assert buildsa5d86181ecMERGE INSERT allows only one VALUES clause4b2d44031fMERGE post-commit review4923550c20Tab completion for MERGEaa3faa3c7aWITH support in MERGE83454e3c2bNew files for MERGEd204ef6377MERGE SQL Command following SQL:2016 Author: Pavan Deolasee Reviewed-by: Michael Paquier
This commit is contained in:
@@ -53,34 +53,23 @@ typedef enum LockTupleMode
|
||||
* When heap_update, heap_delete, or heap_lock_tuple fail because the target
|
||||
* tuple is already outdated, they fill in this struct to provide information
|
||||
* to the caller about what happened.
|
||||
*
|
||||
* result is the result of HeapTupleSatisfiesUpdate, leading to the failure.
|
||||
* It's set to HeapTupleMayBeUpdated when there is no failure.
|
||||
*
|
||||
* ctid is the target's ctid link: it is the same as the target's TID if the
|
||||
* target was deleted, or the location of the replacement tuple if the target
|
||||
* was updated.
|
||||
*
|
||||
* xmax is the outdating transaction's XID. If the caller wants to visit the
|
||||
* replacement tuple, it must check that this matches before believing the
|
||||
* replacement is really a match.
|
||||
*
|
||||
* cmax is the outdating command's CID, but only when the failure code is
|
||||
* HeapTupleSelfUpdated (i.e., something in the current transaction outdated
|
||||
* the tuple); otherwise cmax is zero. (We make this restriction because
|
||||
* HeapTupleHeaderGetCmax doesn't work for tuples outdated in other
|
||||
* transactions.)
|
||||
*
|
||||
* lockmode is only relevant for callers of heap_update() and is the mode which
|
||||
* the caller should use in case it needs to lock the updated tuple.
|
||||
*/
|
||||
typedef struct HeapUpdateFailureData
|
||||
{
|
||||
HTSU_Result result;
|
||||
ItemPointerData ctid;
|
||||
TransactionId xmax;
|
||||
CommandId cmax;
|
||||
LockTupleMode lockmode;
|
||||
} HeapUpdateFailureData;
|
||||
|
||||
|
||||
@@ -173,7 +162,7 @@ extern void heap_abort_speculative(Relation relation, HeapTuple tuple);
|
||||
extern HTSU_Result heap_update(Relation relation, ItemPointer otid,
|
||||
HeapTuple newtup,
|
||||
CommandId cid, Snapshot crosscheck, bool wait,
|
||||
HeapUpdateFailureData *hufd);
|
||||
HeapUpdateFailureData *hufd, LockTupleMode *lockmode);
|
||||
extern HTSU_Result heap_lock_tuple(Relation relation, HeapTuple tuple,
|
||||
CommandId cid, LockTupleMode mode, LockWaitPolicy wait_policy,
|
||||
bool follow_update,
|
||||
|
||||
@@ -206,8 +206,7 @@ extern bool ExecBRDeleteTriggers(EState *estate,
|
||||
EPQState *epqstate,
|
||||
ResultRelInfo *relinfo,
|
||||
ItemPointer tupleid,
|
||||
HeapTuple fdw_trigtuple,
|
||||
HeapUpdateFailureData *hufdp);
|
||||
HeapTuple fdw_trigtuple);
|
||||
extern void ExecARDeleteTriggers(EState *estate,
|
||||
ResultRelInfo *relinfo,
|
||||
ItemPointer tupleid,
|
||||
@@ -226,8 +225,7 @@ extern TupleTableSlot *ExecBRUpdateTriggers(EState *estate,
|
||||
ResultRelInfo *relinfo,
|
||||
ItemPointer tupleid,
|
||||
HeapTuple fdw_trigtuple,
|
||||
TupleTableSlot *slot,
|
||||
HeapUpdateFailureData *hufdp);
|
||||
TupleTableSlot *slot);
|
||||
extern void ExecARUpdateTriggers(EState *estate,
|
||||
ResultRelInfo *relinfo,
|
||||
ItemPointer tupleid,
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* execMerge.h
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/executor/execMerge.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef EXECMERGE_H
|
||||
#define EXECMERGE_H
|
||||
|
||||
#include "nodes/execnodes.h"
|
||||
|
||||
/* flags for mt_merge_subcommands */
|
||||
#define MERGE_INSERT 0x01
|
||||
#define MERGE_UPDATE 0x02
|
||||
#define MERGE_DELETE 0x04
|
||||
|
||||
extern void ExecMerge(ModifyTableState *mtstate, EState *estate,
|
||||
TupleTableSlot *slot, JunkFilter *junkfilter,
|
||||
ResultRelInfo *resultRelInfo);
|
||||
|
||||
extern void ExecInitMerge(ModifyTableState *mtstate,
|
||||
EState *estate,
|
||||
ResultRelInfo *resultRelInfo);
|
||||
|
||||
#endif /* NODEMERGE_H */
|
||||
@@ -186,7 +186,6 @@ extern int ExecFindPartition(ResultRelInfo *resultRelInfo,
|
||||
PartitionDispatch *pd,
|
||||
TupleTableSlot *slot,
|
||||
EState *estate);
|
||||
extern int ExecFindPartitionByOid(PartitionTupleRouting *proute, Oid partoid);
|
||||
extern ResultRelInfo *ExecInitPartitionInfo(ModifyTableState *mtstate,
|
||||
ResultRelInfo *resultRelInfo,
|
||||
PartitionTupleRouting *proute,
|
||||
|
||||
@@ -59,11 +59,8 @@ typedef struct Instrumentation
|
||||
double ntuples; /* Total tuples produced */
|
||||
double ntuples2; /* Secondary node-specific tuple counter */
|
||||
double nloops; /* # of run cycles for this node */
|
||||
double nfiltered1; /* # tuples removed by scanqual or joinqual OR
|
||||
* # tuples inserted by MERGE */
|
||||
double nfiltered2; /* # tuples removed by "other" quals OR
|
||||
* # tuples updated by MERGE */
|
||||
double nfiltered3; /* # tuples deleted by MERGE */
|
||||
double nfiltered1; /* # tuples removed by scanqual or joinqual */
|
||||
double nfiltered2; /* # tuples removed by "other" quals */
|
||||
BufferUsage bufusage; /* Total buffer usage */
|
||||
} Instrumentation;
|
||||
|
||||
|
||||
@@ -18,28 +18,5 @@
|
||||
extern ModifyTableState *ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags);
|
||||
extern void ExecEndModifyTable(ModifyTableState *node);
|
||||
extern void ExecReScanModifyTable(ModifyTableState *node);
|
||||
extern TupleTableSlot *ExecPrepareTupleRouting(ModifyTableState *mtstate,
|
||||
EState *estate,
|
||||
struct PartitionTupleRouting *proute,
|
||||
ResultRelInfo *targetRelInfo,
|
||||
TupleTableSlot *slot);
|
||||
extern TupleTableSlot *ExecDelete(ModifyTableState *mtstate,
|
||||
ItemPointer tupleid, HeapTuple oldtuple, TupleTableSlot *planSlot,
|
||||
EPQState *epqstate, EState *estate, bool *tupleDeleted,
|
||||
bool processReturning, HeapUpdateFailureData *hufdp,
|
||||
MergeActionState *actionState, bool canSetTag,
|
||||
bool changingPart);
|
||||
extern TupleTableSlot *ExecUpdate(ModifyTableState *mtstate,
|
||||
ItemPointer tupleid, HeapTuple oldtuple, TupleTableSlot *slot,
|
||||
TupleTableSlot *planSlot, EPQState *epqstate, EState *estate,
|
||||
bool *tuple_updated, HeapUpdateFailureData *hufdp,
|
||||
MergeActionState *actionState, bool canSetTag);
|
||||
extern TupleTableSlot *ExecInsert(ModifyTableState *mtstate,
|
||||
TupleTableSlot *slot,
|
||||
TupleTableSlot *planSlot,
|
||||
EState *estate,
|
||||
MergeActionState *actionState,
|
||||
bool canSetTag);
|
||||
extern void ExecCheckPlanOutput(Relation resultRel, List *targetList);
|
||||
|
||||
#endif /* NODEMODIFYTABLE_H */
|
||||
|
||||
@@ -64,7 +64,6 @@ typedef struct _SPI_plan *SPIPlanPtr;
|
||||
#define SPI_OK_REL_REGISTER 15
|
||||
#define SPI_OK_REL_UNREGISTER 16
|
||||
#define SPI_OK_TD_REGISTER 17
|
||||
#define SPI_OK_MERGE 18
|
||||
|
||||
#define SPI_OPT_NONATOMIC (1 << 0)
|
||||
|
||||
|
||||
@@ -363,17 +363,8 @@ typedef struct JunkFilter
|
||||
AttrNumber *jf_cleanMap;
|
||||
TupleTableSlot *jf_resultSlot;
|
||||
AttrNumber jf_junkAttNo;
|
||||
AttrNumber jf_otherJunkAttNo;
|
||||
} JunkFilter;
|
||||
|
||||
typedef struct MergeState
|
||||
{
|
||||
/* List of MERGE MATCHED action states */
|
||||
List *matchedActionStates;
|
||||
/* List of MERGE NOT MATCHED action states */
|
||||
List *notMatchedActionStates;
|
||||
} MergeState;
|
||||
|
||||
/*
|
||||
* OnConflictSetState
|
||||
*
|
||||
@@ -470,38 +461,8 @@ typedef struct ResultRelInfo
|
||||
|
||||
/* true if ready for tuple routing */
|
||||
bool ri_PartitionReadyForRouting;
|
||||
|
||||
int ri_PartitionLeafIndex;
|
||||
/* for running MERGE on this result relation */
|
||||
MergeState *ri_mergeState;
|
||||
|
||||
/*
|
||||
* While executing MERGE, the target relation is processed twice; once
|
||||
* as a target relation and once to run a join between the target and the
|
||||
* source. We generate two different RTEs for these two purposes, one with
|
||||
* rte->inh set to false and other with rte->inh set to true.
|
||||
*
|
||||
* Since the plan re-evaluated by EvalPlanQual uses the join RTE, we must
|
||||
* install the updated tuple in the scan corresponding to that RTE. The
|
||||
* following member tracks the index of the second RTE for EvalPlanQual
|
||||
* purposes. ri_mergeTargetRTI is non-zero only when MERGE is in-progress.
|
||||
* We use ri_mergeTargetRTI to run EvalPlanQual for MERGE and
|
||||
* ri_RangeTableIndex elsewhere.
|
||||
*/
|
||||
Index ri_mergeTargetRTI;
|
||||
} ResultRelInfo;
|
||||
|
||||
/*
|
||||
* Get the Range table index for EvalPlanQual.
|
||||
*
|
||||
* We use the ri_mergeTargetRTI if set, otherwise use ri_RangeTableIndex.
|
||||
* ri_mergeTargetRTI should really be ever set iff we're running MERGE.
|
||||
*/
|
||||
#define GetEPQRangeTableIndex(r) \
|
||||
(((r)->ri_mergeTargetRTI > 0) \
|
||||
? (r)->ri_mergeTargetRTI \
|
||||
: (r)->ri_RangeTableIndex)
|
||||
|
||||
/* ----------------
|
||||
* EState information
|
||||
*
|
||||
@@ -1019,11 +980,6 @@ typedef struct PlanState
|
||||
if (((PlanState *)(node))->instrument) \
|
||||
((PlanState *)(node))->instrument->nfiltered2 += (delta); \
|
||||
} while(0)
|
||||
#define InstrCountFiltered3(node, delta) \
|
||||
do { \
|
||||
if (((PlanState *)(node))->instrument) \
|
||||
((PlanState *)(node))->instrument->nfiltered3 += (delta); \
|
||||
} while(0)
|
||||
|
||||
/*
|
||||
* EPQState is state for executing an EvalPlanQual recheck on a candidate
|
||||
@@ -1070,20 +1026,6 @@ typedef struct ProjectSetState
|
||||
MemoryContext argcontext; /* context for SRF arguments */
|
||||
} ProjectSetState;
|
||||
|
||||
/* ----------------
|
||||
* MergeActionState information
|
||||
* ----------------
|
||||
*/
|
||||
typedef struct MergeActionState
|
||||
{
|
||||
NodeTag type;
|
||||
bool matched; /* true=MATCHED, false=NOT MATCHED */
|
||||
ExprState *whenqual; /* WHEN AND conditions */
|
||||
CmdType commandType; /* INSERT/UPDATE/DELETE/DO NOTHING */
|
||||
ProjectionInfo *proj; /* tuple projection info */
|
||||
TupleDesc tupDesc; /* tuple descriptor for projection */
|
||||
} MergeActionState;
|
||||
|
||||
/* ----------------
|
||||
* ModifyTableState information
|
||||
* ----------------
|
||||
@@ -1091,7 +1033,7 @@ typedef struct MergeActionState
|
||||
typedef struct ModifyTableState
|
||||
{
|
||||
PlanState ps; /* its first field is NodeTag */
|
||||
CmdType operation; /* INSERT, UPDATE, DELETE or MERGE */
|
||||
CmdType operation; /* INSERT, UPDATE, or DELETE */
|
||||
bool canSetTag; /* do we set the command tag/es_processed? */
|
||||
bool mt_done; /* are we done? */
|
||||
PlanState **mt_plans; /* subplans (one per target rel) */
|
||||
@@ -1107,8 +1049,6 @@ typedef struct ModifyTableState
|
||||
List *mt_excludedtlist; /* the excluded pseudo relation's tlist */
|
||||
TupleTableSlot *mt_conflproj; /* CONFLICT ... SET ... projection target */
|
||||
|
||||
TupleTableSlot *mt_mergeproj; /* MERGE action projection target */
|
||||
|
||||
/* Tuple-routing support info */
|
||||
struct PartitionTupleRouting *mt_partition_tuple_routing;
|
||||
|
||||
@@ -1120,9 +1060,6 @@ typedef struct ModifyTableState
|
||||
|
||||
/* Per plan map for tuple conversion from child to root */
|
||||
TupleConversionMap **mt_per_subplan_tupconv_maps;
|
||||
|
||||
/* Flags showing which subcommands are present INS/UPD/DEL/DO NOTHING */
|
||||
int mt_merge_subcommands;
|
||||
} ModifyTableState;
|
||||
|
||||
/* ----------------
|
||||
|
||||
@@ -97,7 +97,6 @@ typedef enum NodeTag
|
||||
T_PlanState,
|
||||
T_ResultState,
|
||||
T_ProjectSetState,
|
||||
T_MergeActionState,
|
||||
T_ModifyTableState,
|
||||
T_AppendState,
|
||||
T_MergeAppendState,
|
||||
@@ -272,7 +271,6 @@ typedef enum NodeTag
|
||||
T_RollupData,
|
||||
T_GroupingSetData,
|
||||
T_StatisticExtInfo,
|
||||
T_MergeAction,
|
||||
|
||||
/*
|
||||
* TAGS FOR MEMORY NODES (memnodes.h)
|
||||
@@ -313,7 +311,6 @@ typedef enum NodeTag
|
||||
T_InsertStmt,
|
||||
T_DeleteStmt,
|
||||
T_UpdateStmt,
|
||||
T_MergeStmt,
|
||||
T_SelectStmt,
|
||||
T_AlterTableStmt,
|
||||
T_AlterTableCmd,
|
||||
@@ -478,7 +475,6 @@ typedef enum NodeTag
|
||||
T_PartitionRangeDatum,
|
||||
T_PartitionCmd,
|
||||
T_VacuumRelation,
|
||||
T_MergeWhenClause,
|
||||
|
||||
/*
|
||||
* TAGS FOR REPLICATION GRAMMAR PARSE NODES (replnodes.h)
|
||||
@@ -664,8 +660,7 @@ typedef enum CmdType
|
||||
CMD_SELECT, /* select stmt */
|
||||
CMD_UPDATE, /* update stmt */
|
||||
CMD_INSERT, /* insert stmt */
|
||||
CMD_DELETE, /* delete stmt */
|
||||
CMD_MERGE, /* merge stmt */
|
||||
CMD_DELETE,
|
||||
CMD_UTILITY, /* cmds like create, destroy, copy, vacuum,
|
||||
* etc. */
|
||||
CMD_NOTHING /* dummy command for instead nothing rules
|
||||
|
||||
@@ -38,7 +38,7 @@ typedef enum OverridingKind
|
||||
typedef enum QuerySource
|
||||
{
|
||||
QSRC_ORIGINAL, /* original parsetree (explicit query) */
|
||||
QSRC_PARSER, /* added by parse analysis in MERGE */
|
||||
QSRC_PARSER, /* added by parse analysis (now unused) */
|
||||
QSRC_INSTEAD_RULE, /* added by unconditional INSTEAD rule */
|
||||
QSRC_QUAL_INSTEAD_RULE, /* added by conditional INSTEAD rule */
|
||||
QSRC_NON_INSTEAD_RULE /* added by non-INSTEAD rule */
|
||||
@@ -107,7 +107,7 @@ typedef struct Query
|
||||
{
|
||||
NodeTag type;
|
||||
|
||||
CmdType commandType; /* select|insert|update|delete|merge|utility */
|
||||
CmdType commandType; /* select|insert|update|delete|utility */
|
||||
|
||||
QuerySource querySource; /* where did I come from? */
|
||||
|
||||
@@ -118,7 +118,7 @@ typedef struct Query
|
||||
Node *utilityStmt; /* non-null if commandType == CMD_UTILITY */
|
||||
|
||||
int resultRelation; /* rtable index of target relation for
|
||||
* INSERT/UPDATE/DELETE/MERGE; 0 for SELECT */
|
||||
* INSERT/UPDATE/DELETE; 0 for SELECT */
|
||||
|
||||
bool hasAggs; /* has aggregates in tlist or havingQual */
|
||||
bool hasWindowFuncs; /* has window functions in tlist */
|
||||
@@ -169,9 +169,6 @@ typedef struct Query
|
||||
List *withCheckOptions; /* a list of WithCheckOption's, which are
|
||||
* only added during rewrite and therefore
|
||||
* are not written out as part of Query. */
|
||||
int mergeTarget_relation;
|
||||
List *mergeSourceTargetList;
|
||||
List *mergeActionList; /* list of actions for MERGE (only) */
|
||||
|
||||
/*
|
||||
* The following two fields identify the portion of the source text string
|
||||
@@ -1131,9 +1128,7 @@ typedef enum WCOKind
|
||||
WCO_VIEW_CHECK, /* WCO on an auto-updatable view */
|
||||
WCO_RLS_INSERT_CHECK, /* RLS INSERT WITH CHECK policy */
|
||||
WCO_RLS_UPDATE_CHECK, /* RLS UPDATE WITH CHECK policy */
|
||||
WCO_RLS_CONFLICT_CHECK, /* RLS ON CONFLICT DO UPDATE USING policy */
|
||||
WCO_RLS_MERGE_UPDATE_CHECK, /* RLS MERGE UPDATE USING policy */
|
||||
WCO_RLS_MERGE_DELETE_CHECK /* RLS MERGE DELETE USING policy */
|
||||
WCO_RLS_CONFLICT_CHECK /* RLS ON CONFLICT DO UPDATE USING policy */
|
||||
} WCOKind;
|
||||
|
||||
typedef struct WithCheckOption
|
||||
@@ -1508,46 +1503,6 @@ typedef struct UpdateStmt
|
||||
WithClause *withClause; /* WITH clause */
|
||||
} UpdateStmt;
|
||||
|
||||
/* ----------------------
|
||||
* Merge Statement
|
||||
* ----------------------
|
||||
*/
|
||||
typedef struct MergeStmt
|
||||
{
|
||||
NodeTag type;
|
||||
RangeVar *relation; /* target relation to merge into */
|
||||
Node *source_relation; /* source relation */
|
||||
Node *join_condition; /* join condition between source and target */
|
||||
List *mergeWhenClauses; /* list of MergeWhenClause(es) */
|
||||
WithClause *withClause; /* WITH clause */
|
||||
} MergeStmt;
|
||||
|
||||
typedef struct MergeWhenClause
|
||||
{
|
||||
NodeTag type;
|
||||
bool matched; /* true=MATCHED, false=NOT MATCHED */
|
||||
CmdType commandType; /* INSERT/UPDATE/DELETE/DO NOTHING */
|
||||
Node *condition; /* WHEN AND conditions (raw parser) */
|
||||
List *targetList; /* INSERT/UPDATE targetlist */
|
||||
/* the following members are only useful for INSERT action */
|
||||
List *cols; /* optional: names of the target columns */
|
||||
List *values; /* VALUES to INSERT, or NULL */
|
||||
OverridingKind override; /* OVERRIDING clause */
|
||||
} MergeWhenClause;
|
||||
|
||||
/*
|
||||
* WHEN [NOT] MATCHED THEN action info
|
||||
*/
|
||||
typedef struct MergeAction
|
||||
{
|
||||
NodeTag type;
|
||||
bool matched; /* true=MATCHED, false=NOT MATCHED */
|
||||
OverridingKind override; /* OVERRIDING clause */
|
||||
Node *qual; /* transformed WHEN AND conditions */
|
||||
CmdType commandType; /* INSERT/UPDATE/DELETE/DO NOTHING */
|
||||
List *targetList; /* the target list (of ResTarget) */
|
||||
} MergeAction;
|
||||
|
||||
/* ----------------------
|
||||
* Select Statement
|
||||
*
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include "lib/stringinfo.h"
|
||||
#include "nodes/bitmapset.h"
|
||||
#include "nodes/lockoptions.h"
|
||||
#include "nodes/parsenodes.h"
|
||||
#include "nodes/primnodes.h"
|
||||
|
||||
|
||||
@@ -43,7 +42,7 @@ typedef struct PlannedStmt
|
||||
{
|
||||
NodeTag type;
|
||||
|
||||
CmdType commandType; /* select|insert|update|delete|merge|utility */
|
||||
CmdType commandType; /* select|insert|update|delete|utility */
|
||||
|
||||
uint64 queryId; /* query identifier (copied from Query) */
|
||||
|
||||
@@ -217,14 +216,13 @@ typedef struct ProjectSet
|
||||
typedef struct ModifyTable
|
||||
{
|
||||
Plan plan;
|
||||
CmdType operation; /* INSERT, UPDATE, DELETE or MERGE */
|
||||
CmdType operation; /* INSERT, UPDATE, or DELETE */
|
||||
bool canSetTag; /* do we set the command tag/es_processed? */
|
||||
Index nominalRelation; /* Parent RT index for use of EXPLAIN */
|
||||
/* RT indexes of non-leaf tables in a partition tree */
|
||||
List *partitioned_rels;
|
||||
bool partColsUpdated; /* some part key in hierarchy updated */
|
||||
List *resultRelations; /* integer list of RT indexes */
|
||||
Index mergeTargetRelation; /* RT index of the merge target */
|
||||
int resultRelIndex; /* index of first resultRel in plan's list */
|
||||
int rootResultRelIndex; /* index of the partitioned table root */
|
||||
List *plans; /* plan(s) producing source data */
|
||||
@@ -240,8 +238,6 @@ typedef struct ModifyTable
|
||||
Node *onConflictWhere; /* WHERE for ON CONFLICT UPDATE */
|
||||
Index exclRelRTI; /* RTI of the EXCLUDED pseudo relation */
|
||||
List *exclRelTlist; /* tlist of the EXCLUDED pseudo relation */
|
||||
List *mergeSourceTargetList;
|
||||
List *mergeActionList; /* actions for MERGE */
|
||||
} ModifyTable;
|
||||
|
||||
/* ----------------
|
||||
|
||||
@@ -1684,7 +1684,7 @@ typedef struct LockRowsPath
|
||||
} LockRowsPath;
|
||||
|
||||
/*
|
||||
* ModifyTablePath represents performing INSERT/UPDATE/DELETE/MERGE
|
||||
* ModifyTablePath represents performing INSERT/UPDATE/DELETE modifications
|
||||
*
|
||||
* We represent most things that will be in the ModifyTable plan node
|
||||
* literally, except we have child Path(s) not Plan(s). But analysis of the
|
||||
@@ -1693,14 +1693,13 @@ typedef struct LockRowsPath
|
||||
typedef struct ModifyTablePath
|
||||
{
|
||||
Path path;
|
||||
CmdType operation; /* INSERT, UPDATE, DELETE or MERGE */
|
||||
CmdType operation; /* INSERT, UPDATE, or DELETE */
|
||||
bool canSetTag; /* do we set the command tag/es_processed? */
|
||||
Index nominalRelation; /* Parent RT index for use of EXPLAIN */
|
||||
/* RT indexes of non-leaf tables in a partition tree */
|
||||
List *partitioned_rels;
|
||||
bool partColsUpdated; /* some part key in hierarchy updated */
|
||||
List *resultRelations; /* integer list of RT indexes */
|
||||
Index mergeTargetRelation; /* RT index of merge target relation */
|
||||
List *subpaths; /* Path(s) producing source data */
|
||||
List *subroots; /* per-target-table PlannerInfos */
|
||||
List *withCheckOptionLists; /* per-target-table WCO lists */
|
||||
@@ -1708,8 +1707,6 @@ typedef struct ModifyTablePath
|
||||
List *rowMarks; /* PlanRowMarks (non-locking only) */
|
||||
OnConflictExpr *onconflict; /* ON CONFLICT clause, or NULL */
|
||||
int epqParam; /* ID of Param for EvalPlanQual re-eval */
|
||||
List *mergeSourceTargetList;
|
||||
List *mergeActionList; /* actions for MERGE */
|
||||
} ModifyTablePath;
|
||||
|
||||
/*
|
||||
|
||||
@@ -241,14 +241,11 @@ extern ModifyTablePath *create_modifytable_path(PlannerInfo *root,
|
||||
CmdType operation, bool canSetTag,
|
||||
Index nominalRelation, List *partitioned_rels,
|
||||
bool partColsUpdated,
|
||||
List *resultRelations,
|
||||
Index mergeTargetRelation,
|
||||
List *subpaths,
|
||||
List *resultRelations, List *subpaths,
|
||||
List *subroots,
|
||||
List *withCheckOptionLists, List *returningLists,
|
||||
List *rowMarks, OnConflictExpr *onconflict,
|
||||
List *mergeSourceTargetList,
|
||||
List *mergeActionList, int epqParam);
|
||||
int epqParam);
|
||||
extern LimitPath *create_limit_path(PlannerInfo *root, RelOptInfo *rel,
|
||||
Path *subpath,
|
||||
Node *limitOffset, Node *limitCount,
|
||||
|
||||
@@ -32,11 +32,6 @@ extern Query *parse_sub_analyze(Node *parseTree, ParseState *parentParseState,
|
||||
bool locked_from_parent,
|
||||
bool resolve_unknowns);
|
||||
|
||||
extern List *transformInsertRow(ParseState *pstate, List *exprlist,
|
||||
List *stmtcols, List *icolumns, List *attrnos,
|
||||
bool strip_indirection);
|
||||
extern List *transformUpdateTargetList(ParseState *pstate,
|
||||
List *targetList);
|
||||
extern Query *transformTopLevelStmt(ParseState *pstate, RawStmt *parseTree);
|
||||
extern Query *transformStmt(ParseState *pstate, Node *parseTree);
|
||||
|
||||
|
||||
@@ -245,10 +245,8 @@ PG_KEYWORD("locked", LOCKED, UNRESERVED_KEYWORD)
|
||||
PG_KEYWORD("logged", LOGGED, UNRESERVED_KEYWORD)
|
||||
PG_KEYWORD("mapping", MAPPING, UNRESERVED_KEYWORD)
|
||||
PG_KEYWORD("match", MATCH, UNRESERVED_KEYWORD)
|
||||
PG_KEYWORD("matched", MATCHED, UNRESERVED_KEYWORD)
|
||||
PG_KEYWORD("materialized", MATERIALIZED, UNRESERVED_KEYWORD)
|
||||
PG_KEYWORD("maxvalue", MAXVALUE, UNRESERVED_KEYWORD)
|
||||
PG_KEYWORD("merge", MERGE, UNRESERVED_KEYWORD)
|
||||
PG_KEYWORD("method", METHOD, UNRESERVED_KEYWORD)
|
||||
PG_KEYWORD("minute", MINUTE_P, UNRESERVED_KEYWORD)
|
||||
PG_KEYWORD("minvalue", MINVALUE, UNRESERVED_KEYWORD)
|
||||
|
||||
@@ -20,10 +20,7 @@ extern void transformFromClause(ParseState *pstate, List *frmList);
|
||||
extern int setTargetTable(ParseState *pstate, RangeVar *relation,
|
||||
bool inh, bool alsoSource, AclMode requiredPerms);
|
||||
extern bool interpretOidsOption(List *defList, bool allowOids);
|
||||
extern Node *transformFromClauseItem(ParseState *pstate, Node *n,
|
||||
RangeTblEntry **top_rte, int *top_rti,
|
||||
RangeTblEntry **right_rte, int *right_rti,
|
||||
List **fnamespace);
|
||||
|
||||
extern Node *transformWhereClause(ParseState *pstate, Node *clause,
|
||||
ParseExprKind exprKind, const char *constructName);
|
||||
extern Node *transformLimitClause(ParseState *pstate, Node *clause,
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* parse_merge.h
|
||||
* handle merge-stmt in parser
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/parser/parse_merge.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef PARSE_MERGE_H
|
||||
#define PARSE_MERGE_H
|
||||
|
||||
#include "parser/parse_node.h"
|
||||
extern Query *transformMergeStmt(ParseState *pstate, MergeStmt *stmt);
|
||||
#endif
|
||||
@@ -50,7 +50,6 @@ typedef enum ParseExprKind
|
||||
EXPR_KIND_INSERT_TARGET, /* INSERT target list item */
|
||||
EXPR_KIND_UPDATE_SOURCE, /* UPDATE assignment source item */
|
||||
EXPR_KIND_UPDATE_TARGET, /* UPDATE assignment target item */
|
||||
EXPR_KIND_MERGE_WHEN_AND, /* MERGE WHEN ... AND condition */
|
||||
EXPR_KIND_GROUP_BY, /* GROUP BY */
|
||||
EXPR_KIND_ORDER_BY, /* ORDER BY */
|
||||
EXPR_KIND_DISTINCT_ON, /* DISTINCT ON */
|
||||
@@ -128,7 +127,7 @@ typedef Node *(*CoerceParamHook) (ParseState *pstate, Param *param,
|
||||
* p_parent_cte: CommonTableExpr that immediately contains the current query,
|
||||
* if any.
|
||||
*
|
||||
* p_target_relation: target relation, if query is INSERT/UPDATE/DELETE/MERGE
|
||||
* p_target_relation: target relation, if query is INSERT, UPDATE, or DELETE.
|
||||
*
|
||||
* p_target_rangetblentry: target relation's entry in the rtable list.
|
||||
*
|
||||
@@ -182,7 +181,7 @@ struct ParseState
|
||||
List *p_ctenamespace; /* current namespace for common table exprs */
|
||||
List *p_future_ctes; /* common table exprs not yet in namespace */
|
||||
CommonTableExpr *p_parent_cte; /* this query's containing CTE */
|
||||
Relation p_target_relation; /* INSERT/UPDATE/DELETE/MERGE target rel */
|
||||
Relation p_target_relation; /* INSERT/UPDATE/DELETE target rel */
|
||||
RangeTblEntry *p_target_rangetblentry; /* target rel's RTE */
|
||||
bool p_is_insert; /* process assignment like INSERT not UPDATE */
|
||||
List *p_windowdefs; /* raw representations of window clauses */
|
||||
|
||||
@@ -25,7 +25,6 @@ extern void AcquireRewriteLocks(Query *parsetree,
|
||||
extern Node *build_column_default(Relation rel, int attrno);
|
||||
extern void rewriteTargetListUD(Query *parsetree, RangeTblEntry *target_rte,
|
||||
Relation target_relation);
|
||||
extern void rewriteTargetListMerge(Query *parsetree, Relation target_relation);
|
||||
|
||||
extern Query *get_view_query(Relation view);
|
||||
extern const char *view_query_is_auto_updatable(Query *viewquery,
|
||||
|
||||
Reference in New Issue
Block a user