📄 copyfuncs.c
字号:
}static DeallocateStmt *_copyDeallocateStmt(DeallocateStmt *from){ DeallocateStmt *newnode = makeNode(DeallocateStmt); COPY_STRING_FIELD(name); return newnode;}/* **************************************************************** * pg_list.h copy functions * **************************************************************** *//* * Perform a deep copy of the specified list, using copyObject(). The * list MUST be of type T_List; T_IntList and T_OidList nodes don't * need deep copies, so they should be copied via list_copy() */#define COPY_NODE_CELL(new, old) \ (new) = (ListCell *) palloc(sizeof(ListCell)); \ lfirst(new) = copyObject(lfirst(old));static List *_copyList(List *from){ List *new; ListCell *curr_old; ListCell *prev_new; Assert(list_length(from) >= 1); new = makeNode(List); new->length = from->length; COPY_NODE_CELL(new->head, from->head); prev_new = new->head; curr_old = lnext(from->head); while (curr_old) { COPY_NODE_CELL(prev_new->next, curr_old); prev_new = prev_new->next; curr_old = curr_old->next; } prev_new->next = NULL; new->tail = prev_new; return new;}/* **************************************************************** * value.h copy functions * **************************************************************** */static Value *_copyValue(Value *from){ Value *newnode = makeNode(Value); /* See also _copyAConst when changing this code! */ COPY_SCALAR_FIELD(type); switch (from->type) { case T_Integer: COPY_SCALAR_FIELD(val.ival); break; case T_Float: case T_String: case T_BitString: COPY_STRING_FIELD(val.str); break; case T_Null: /* nothing to do */ break; default: elog(ERROR, "unrecognized node type: %d", (int) from->type); break; } return newnode;}/* * copyObject * * Create a copy of a Node tree or list. This is a "deep" copy: all * substructure is copied too, recursively. */void *copyObject(void *from){ void *retval; if (from == NULL) return NULL; switch (nodeTag(from)) { /* * PLAN NODES */ case T_Plan: retval = _copyPlan(from); break; case T_Result: retval = _copyResult(from); break; case T_Append: retval = _copyAppend(from); break; case T_BitmapAnd: retval = _copyBitmapAnd(from); break; case T_BitmapOr: retval = _copyBitmapOr(from); break; case T_Scan: retval = _copyScan(from); break; case T_SeqScan: retval = _copySeqScan(from); break; case T_IndexScan: retval = _copyIndexScan(from); break; case T_BitmapIndexScan: retval = _copyBitmapIndexScan(from); break; case T_BitmapHeapScan: retval = _copyBitmapHeapScan(from); break; case T_TidScan: retval = _copyTidScan(from); break; case T_SubqueryScan: retval = _copySubqueryScan(from); break; case T_FunctionScan: retval = _copyFunctionScan(from); break; case T_Join: retval = _copyJoin(from); break; case T_NestLoop: retval = _copyNestLoop(from); break; case T_MergeJoin: retval = _copyMergeJoin(from); break; case T_HashJoin: retval = _copyHashJoin(from); break; case T_Material: retval = _copyMaterial(from); break; case T_Sort: retval = _copySort(from); break; case T_Group: retval = _copyGroup(from); break; case T_Agg: retval = _copyAgg(from); break; case T_Unique: retval = _copyUnique(from); break; case T_Hash: retval = _copyHash(from); break; case T_SetOp: retval = _copySetOp(from); break; case T_Limit: retval = _copyLimit(from); break; /* * PRIMITIVE NODES */ case T_Alias: retval = _copyAlias(from); break; case T_RangeVar: retval = _copyRangeVar(from); break; case T_Var: retval = _copyVar(from); break; case T_Const: retval = _copyConst(from); break; case T_Param: retval = _copyParam(from); break; case T_Aggref: retval = _copyAggref(from); break; case T_ArrayRef: retval = _copyArrayRef(from); break; case T_FuncExpr: retval = _copyFuncExpr(from); break; case T_OpExpr: retval = _copyOpExpr(from); break; case T_DistinctExpr: retval = _copyDistinctExpr(from); break; case T_ScalarArrayOpExpr: retval = _copyScalarArrayOpExpr(from); break; case T_BoolExpr: retval = _copyBoolExpr(from); break; case T_SubLink: retval = _copySubLink(from); break; case T_SubPlan: retval = _copySubPlan(from); break; case T_FieldSelect: retval = _copyFieldSelect(from); break; case T_FieldStore: retval = _copyFieldStore(from); break; case T_RelabelType: retval = _copyRelabelType(from); break; case T_ConvertRowtypeExpr: retval = _copyConvertRowtypeExpr(from); break; case T_CaseExpr: retval = _copyCaseExpr(from); break; case T_CaseWhen: retval = _copyCaseWhen(from); break; case T_CaseTestExpr: retval = _copyCaseTestExpr(from); break; case T_ArrayExpr: retval = _copyArrayExpr(from); break; case T_RowExpr: retval = _copyRowExpr(from); break; case T_CoalesceExpr: retval = _copyCoalesceExpr(from); break; case T_MinMaxExpr: retval = _copyMinMaxExpr(from); break; case T_NullIfExpr: retval = _copyNullIfExpr(from); break; case T_NullTest: retval = _copyNullTest(from); break; case T_BooleanTest: retval = _copyBooleanTest(from); break; case T_CoerceToDomain: retval = _copyCoerceToDomain(from); break; case T_CoerceToDomainValue: retval = _copyCoerceToDomainValue(from); break; case T_SetToDefault: retval = _copySetToDefault(from); break; case T_TargetEntry: retval = _copyTargetEntry(from); break; case T_RangeTblRef: retval = _copyRangeTblRef(from); break; case T_JoinExpr: retval = _copyJoinExpr(from); break; case T_FromExpr: retval = _copyFromExpr(from); break; /* * RELATION NODES */ case T_PathKeyItem: retval = _copyPathKeyItem(from); break; case T_RestrictInfo: retval = _copyRestrictInfo(from); break; case T_InClauseInfo: retval = _copyInClauseInfo(from); break; /* * VALUE NODES */ case T_Integer: case T_Float: case T_String: case T_BitString: case T_Null: retval = _copyValue(from); break; /* * LIST NODES */ case T_List: retval = _copyList(from); break; /* * Lists of integers and OIDs don't need to be deep-copied, so we * perform a shallow copy via list_copy() */ case T_IntList: case T_OidList: retval = list_copy(from); break; /* * PARSE NODES */ case T_Query: retval = _copyQuery(from); break; case T_InsertStmt: retval = _copyInsertStmt(from); break; case T_DeleteStmt: retval = _copyDeleteStmt(from); break; case T_UpdateStmt: retval = _copyUpdateStmt(from); break; case T_SelectStmt: retval = _copySelectStmt(from); break; case T_SetOperationStmt: retval = _copySetOperationStmt(from); break; case T_AlterTableStmt: retval = _copyAlterTableStmt(from); break; case T_AlterTableCmd: retval = _copyAlterTableCmd(from); break; case T_AlterDomainStmt: retval = _copyAlterDomainStmt(from); break; case T_GrantStmt: retval = _copyGrantStmt(from); break; case T_GrantRoleStmt: retval = _copyGrantRoleStmt(from); break; case T_DeclareCursorStmt: retval = _copyDeclareCursorStmt(from); break; case T_ClosePortalStmt: retval = _copyClosePortalStmt(from); break; case T_ClusterStmt: retval = _copyClusterStmt(from); break; case T_CopyStmt: retval = _copyCopyStmt(from); break; case T_CreateStmt: retval = _copyCreateStmt(from); break; case T_InhRelation: retval = _copyInhRelation(from); break; case T_DefineStmt: retval = _copyDefineStmt(from); break; case T_DropStmt: retval = _copyDropStmt(from); break; case T_TruncateStmt: retval = _copyTruncateStmt(from); break; case T_CommentStmt: retval = _copyCommentStmt(from); break; case T_FetchStmt: retval = _copyFetchStmt(from); break; case T_IndexStmt: retval = _copyIndexStmt(from); break; case T_CreateFunctionStmt: retval = _copyCreateFunctionStmt(from); break; case T_FunctionParameter: retval = _copyFunctionParameter(from); break; case T_AlterFunctionStmt: retval = _copyAlterFunctionStmt(from); break; case T_RemoveAggrStmt: retval = _copyRemoveAggrStmt(from); break; case T_RemoveFuncStmt: retval = _copyRemoveFuncStmt(from); break; case T_RemoveOperStmt: retval = _copyRemoveOperStmt(from); break; case T_RemoveOpClassStmt: retval = _copyRemoveOpClassStmt(from); break; case T_RenameStmt: retval = _copyRenameStmt(from); break; case T_AlterObjectSchemaStmt: retval = _copyAlterObjectSchemaStmt(from); break; case T_AlterOwnerStmt: retval = _copyAlterOwnerStmt(from); break; case T_RuleStmt: retval = _copyRuleStmt(from); break; case T_NotifyStmt: retval = _copyNotifyStmt(from); break; case T_ListenStmt: retval = _copyListenStmt(from); break; case T_UnlistenStmt: retval = _copyUnlistenStmt(from); break; case T_TransactionStmt: retval = _copyTransactionStmt(from); break; case T_CompositeTypeStmt: retval = _copyCompositeTypeStmt(from); break; case T_ViewStmt: retval = _copyViewStmt(from); break; case T_LoadStmt: retval = _copyLoadStmt(from); break; case T_CreateDomainStmt: retval = _copyCreateDomainStmt(from); break; case T_CreateOpClassStmt: retval = _copyCreateOpClassStmt(from); break; case T_CreateOpClassItem: retval = _copyCreateOpClassItem(from); break; case T_CreatedbStmt: retval = _copyCreatedbStmt(from); break; case T_AlterDatabaseStmt: retval = _copyAlterDatabaseStmt(from); break; case T_AlterDatabaseSetStmt: retval = _copyAlterDatabaseSetStmt(from); break; case T_DropdbStmt: retval = _copyDropdbStmt(from); break; case T_VacuumStmt: retval = _copyVacuumStmt(from); break; case T_ExplainStmt: retval = _copyExplainStmt(from); break; case T_CreateSeqStmt: retval = _copyCreateSeqStmt(from); break; case T_AlterSeqStmt: retval = _copyAlterSeqStmt(from); break; case T_VariableSetStmt: retval = _copyVariableSetStmt(from); break; case T_VariableShowStmt: retval = _copyVariableShowStmt(from); break; case T_VariableResetStmt: retval = _copyVariableResetStmt(from); break; case T_CreateTableSpaceStmt: retval = _copyCreateTableSpaceStmt(from); break; case T_DropTableSpaceStmt: retval = _copyDropTableSpaceStmt(from); break; case T_CreateTrigStmt: retval = _copyCreateTrigStmt(from); break; case T_DropPropertyStmt: retval = _copyDropPropertyStmt(from); break; case T_CreatePLangStmt: retval = _copyCreatePLangStmt(from); break; case T_DropPLangStmt: retval = _copyDropPLangStmt(from); break; case T_CreateRoleStmt: retval = _copyCreateRoleStmt(from); break; case T_AlterRoleStmt: retval = _copyAlterRoleStmt(from); break; case T_AlterRoleSetStmt: retval = _copyAlterRoleSetStmt(from); break; case T_DropRoleStmt: retval = _copyDropRoleStmt(from); break; case T_LockStmt: retval = _copyLockStmt(from); break; case T_ConstraintsSetStmt: retval = _copyConstraintsSetStmt(from); break; case T_ReindexStmt: retval = _copyReindexStmt(from); break; case T_CheckPointStmt: retval = (void *) makeNode(CheckPointStmt); break; case T_CreateSchemaStmt: retval = _copyCreateSchemaStmt(from); break; case T_CreateConversionStmt: retval = _copyCreateConversionStmt(from); break; case T_CreateCastStmt: retval = _copyCreateCastStmt(from); break; case T_DropCastStmt: retval = _copyDropCastStmt(from); break; case T_PrepareStmt: retval = _copyPrepareStmt(from); break; case T_ExecuteStmt: retval = _copyExecuteStmt(from); break; case T_DeallocateStmt: retval = _copyDeallocateStmt(from); break; case T_A_Expr: retval = _copyAExpr(from); break; case T_ColumnRef: retval = _copyColumnRef(from); break; case T_ParamRef: retval = _copyParamRef(from); break; case T_A_Const: retval = _copyAConst(from); break; case T_FuncCall: retval = _copyFuncCall(from); break; case T_A_Indices: retval = _copyAIndices(from); break; case T_A_Indirection: retval = _copyA_Indirection(from); break; case T_ResTarget: retval = _copyResTarget(from); break; case T_TypeCast: retval = _copyTypeCast(from); break; case T_SortBy: retval = _copySortBy(from); break; case T_RangeSubselect: retval = _copyRangeSubselect(from); break; case T_RangeFunction: retval = _copyRangeFunction(from); break; case T_TypeName: retval = _copyTypeName(from); break; case T_IndexElem: retval = _copyIndexElem(from); break; case T_ColumnDef: retval = _copyColumnDef(from); break; case T_Constraint: retval = _copyConstraint(from); break; case T_DefElem: retval = _copyDefElem(from); break; case T_LockingClause: retval = _copyLockingClause(from); break; case T_RangeTblEntry: retval = _copyRangeTblEntry(from); break; case T_SortClause: retval = _copySortClause(from); break; case T_GroupClause: retval = _copyGroupClause(from); break; case T_FkConstraint: retval = _copyFkConstraint(from); break; case T_PrivGrantee: retval = _copyPrivGrantee(from); break; case T_FuncWithArgs: retval = _copyFuncWithArgs(from); break; default: elog(ERROR, "unrecognized node type: %d", (int) nodeTag(from)); retval = from; /* keep compiler quiet */ break; } return retval;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -