static ShareInputScan *make_shareinputscan(PlannerInfo *root, Plan *inputplan) { ShareInputScan *sisc = NULL; Path sipath; Assert(IsA(inputplan, Material) || IsA(inputplan, Sort)); sisc = makeNode(ShareInputScan); incr_plan_nsharer(inputplan); sisc->plan.targetlist = copyObject(inputplan->targetlist); sisc->plan.lefttree = inputplan; sisc->plan.flow = copyObject(inputplan->flow); set_plan_share_type((Plan *) sisc, get_plan_share_type(inputplan)); set_plan_share_id((Plan *) sisc, get_plan_share_id(inputplan)); sisc->driver_slice = -1; sisc->plan.qual = NIL; sisc->plan.righttree = NULL; cost_shareinputscan(&sipath, root, inputplan->total_cost, inputplan->plan_rows, inputplan->plan_width); sisc->plan.startup_cost = sipath.startup_cost; sisc->plan.total_cost = sipath.total_cost; sisc->plan.plan_rows = inputplan->plan_rows; sisc->plan.plan_width = inputplan->plan_width; sisc->plan.extParam = bms_copy(inputplan->extParam); sisc->plan.allParam = bms_copy(inputplan->allParam); return sisc; }
/* * Return permissive policies to be added */ List * test_rls_hooks_permissive(CmdType cmdtype, Relation relation) { List *policies = NIL; RowSecurityPolicy *policy = palloc0(sizeof(RowSecurityPolicy)); Datum role; FuncCall *n; Node *e; ColumnRef *c; ParseState *qual_pstate; RangeTblEntry *rte; if (strcmp(RelationGetRelationName(relation), "rls_test_permissive") && strcmp(RelationGetRelationName(relation), "rls_test_both")) return NIL; qual_pstate = make_parsestate(NULL); rte = addRangeTableEntryForRelation(qual_pstate, relation, NULL, false, false); addRTEtoQuery(qual_pstate, rte, false, true, true); role = ObjectIdGetDatum(ACL_ID_PUBLIC); policy->policy_name = pstrdup("extension policy"); policy->policy_id = InvalidOid; policy->polcmd = '*'; policy->roles = construct_array(&role, 1, OIDOID, sizeof(Oid), true, 'i'); /* * policy->qual = (Expr *) makeConst(BOOLOID, -1, InvalidOid, * sizeof(bool), BoolGetDatum(true), false, true); */ n = makeFuncCall(list_make2(makeString("pg_catalog"), makeString("current_user")), NIL, 0); c = makeNode(ColumnRef); c->fields = list_make1(makeString("username")); c->location = 0; e = (Node *) makeSimpleA_Expr(AEXPR_OP, "=", (Node *) n, (Node *) c, 0); policy->qual = (Expr *) transformWhereClause(qual_pstate, copyObject(e), EXPR_KIND_POLICY, "POLICY"); policy->with_check_qual = copyObject(policy->qual); policy->hassublinks = false; policies = list_make1(policy); return policies; }
/* ---------------- * CopyPlanFields * * This function copies the fields of the Plan node. It is used by * all the copy functions for classes which inherit from Plan. * ---------------- */ static void CopyPlanFields(Plan *from, Plan *newnode) { newnode->cost = from->cost; newnode->plan_size = from->plan_size; newnode->plan_width = from->plan_width; newnode->state = from->state; newnode->targetlist = copyObject(from->targetlist); newnode->qual = copyObject(from->qual); newnode->lefttree = copyObject(from->lefttree); newnode->righttree = copyObject(from->righttree); }
/********************************************************************* ** Member Function: print ** Description: print the resulting array given for the grid object * and use the loop for other loop actions like resetting flags ** Parameters: none ** Pre-Conditions: xMax and yMax must be >= 0 ** Post-Conditions: xMax and yMax remain >= 0 *********************************************************************/ void Grid::print() { int count = 1; // used to count how many objects exist for (int i = 0; i < yMax; i++){ for (int j = 0; j < xMax; j++) { resetIsMoved(j, i); // reset move flags copyObject(j, i); // check to see if a new object should be created deleteObject(j, i); // check to see if an object should be deleted if (gridArray[i][j] == NULL) // prints a background space when NULL //std::cout << " - "; // fill background std::cout << " "; // no background else if (gridArray[i][j]->getType() == 1) { std::cout << " * "; /* Ant object */ count++; } else if (gridArray[i][j]->getType() == 2) { std::cout << ">X<"; /* Doodlebug object */ count++; } } std::cout << std::endl; } std::cout << std::endl; if (count == xMax * yMax) // check to see if the grid is full setIsFull(); }
Query * rewriteTargetSublinkUsingLeftJoin (Query *newTop, Query *query, SublinkInfo *info, Index subList[]) { Query *rewrittenSublink; Index subIndex; /* here we are sure that the sublink is rewritten using MOVE-strategy there say so */ LOGNOTICE("use Move"); addUsedMethod("Move"); /* rewrite Sublink query */ rewrittenSublink = rewriteQueryNode(copyObject(info->sublink->subselect)); info->rewrittenSublinkQuery = rewrittenSublink; /* join query RTEs */ joinQueryRTEs(query); /* add left join for subink */ subIndex = addLeftJoinWithRewrittenSublink (newTop, info); subList[info->sublinkPos] = subIndex; /* create the join condition for the left join with the rewritten sublink */ createJoinCondition (newTop, info, true); return query; }
/* * CreatePhysicalPlan encapsulates the logic needed to transform a particular * query into a physical plan. For modifications, queries immediately enter * the physical planning stage, since they are essentially "routed" to remote * target shards. SELECT queries go through the full logical plan/optimize/ * physical plan process needed to produce distributed query plans. */ MultiPlan * CreatePhysicalPlan(Query *parse) { Query *parseCopy = copyObject(parse); MultiPlan *physicalPlan = MultiRouterPlanCreate(parseCopy, TaskExecutorType); if (physicalPlan == NULL) { /* Create and optimize logical plan */ MultiTreeRoot *logicalPlan = MultiLogicalPlanCreate(parseCopy); MultiLogicalPlanOptimize(logicalPlan); /* * This check is here to make it likely that all node types used in * Citus are dumpable. Explain can dump logical and physical plans * using the extended outfuncs infrastructure, but it's infeasible to * test most plans. MultiQueryContainerNode always serializes the * physical plan, so there's no need to check that separately. */ CheckNodeIsDumpable((Node *) logicalPlan); /* Create the physical plan */ physicalPlan = MultiPhysicalPlanCreate(logicalPlan); } return physicalPlan; }
static Node * generateCsub (SublinkInfo *info) { Node *result; //ReplaceParamsContext *context; SubLink *sublink; //int *increaseSublevelsContext; /* copy sublink */ sublink = copyObject(info->sublink); result = (Node *) sublink; //CHECK that its ok to not increase sublevelup for left join (should be because we are rewritting uncorrelated sublinks anyway, NO because we might be in another sublink) // /* increase varlevelsup in sublink query of Csub */ // increaseSublevelsContext = (int *) palloc(sizeof(int)); // *increaseSublevelsContext = -1; // sublink->subselect = increaseSublevelsUpMutator(sublink->subselect, increaseSublevelsContext); // pfree(increaseSublevelsContext); // /* increase varlevelsup in sublink test expression */ // context = (ReplaceParamsContext *) palloc(sizeof(ReplaceParamsContext)); // context->addVarSublevelsUp = 1; // context->touchParams = false; // context->touchAggs = false; // context->varSublevelsUp = -1; // // ((SubLink *) result)->testexpr = replaceParamsMutator (((SubLink *) result)->testexpr, context); // pfree(context); return result; }
void OperationList::addToPool(BaseObject *object, unsigned op_type) { ObjectType obj_type; //Raises an error if the object to be added is not allocated if(!object) throw Exception(ERR_ASG_NOT_ALOC_OBJECT,__PRETTY_FUNCTION__,__FILE__,__LINE__); obj_type=object->getObjectType(); //Stores a copy of the object if its about to be moved or modified if(op_type==Operation::OBJECT_MODIFIED || op_type==Operation::OBJECT_MOVED) { BaseObject *copy_obj=NULL; if(obj_type!=BASE_OBJECT && obj_type!=OBJ_DATABASE) copyObject(©_obj, object, obj_type); else throw Exception(ERR_ASG_OBJECT_INV_TYPE,__PRETTY_FUNCTION__,__FILE__,__LINE__); //Raises an error if the copy fails (returning a null object) if(!copy_obj) throw Exception(ERR_ASG_NOT_ALOC_OBJECT,__PRETTY_FUNCTION__,__FILE__,__LINE__); else //Inserts the copy on the pool object_pool.push_back(copy_obj); //object=copy_obj; } else //Inserts the original object on the pool (in case of adition or deletion operations) object_pool.push_back(object); }
/* * GetGroupHashIndexExpr * * Returns the function expression used to index the given matrel */ FuncExpr * GetGroupHashIndexExpr(int group_len, ResultRelInfo *ri) { FuncExpr *result = NULL; int i; /* * In order for the hashed group index to be usable, we must use an expression * that is equivalent to the index expression in the group lookup. The best way * to do this is to just copy the actual index expression. */ for (i = 0; i < ri->ri_NumIndices; i++) { IndexInfo *idx = ri->ri_IndexRelationInfo[i]; Node *n; FuncExpr *func; if (!idx->ii_Expressions || list_length(idx->ii_Expressions) != 1) continue; n = linitial(idx->ii_Expressions); if (!IsA(n, FuncExpr)) continue; func = (FuncExpr *) n; if ((func->funcid != HASH_GROUP_OID && func->funcid != LS_HASH_GROUP_OID) || list_length(func->args) != group_len) continue; result = copyObject(func); break; } return result; }
/* * Remember a list of pre-assigned OIDs, to be consumed later in the * transaction, when those system objects are created. */ void AddPreassignedOids(List *l) { ListCell *lc; MemoryContext old_context; if (IsBinaryUpgrade) elog(ERROR, "AddPreassignedOids called during binary upgrade"); /* * In the master, the OID-assignment-list is usually included in the next * command that is dispatched, after an OID was assigned. In almost all * cases, the dispatched command is the same CREATE command for which the * oid was assigned. But I'm not sure if that's true for *all* commands, * and so we don't require it. It is OK if an OID assignment is included * in one dispatched command, but the command that needs the OID is only * dispatched later in the same transaction. Therefore, keep the * 'preassigned_oids' list in TopTransactionContext. */ old_context = MemoryContextSwitchTo(TopTransactionContext); foreach(lc, l) { OidAssignment *p = (OidAssignment *) lfirst(lc); p = copyObject(p); preassigned_oids = lappend(preassigned_oids, p); #ifdef OID_DISPATCH_DEBUG elog(NOTICE, "received OID assignment: catalog %u, namespace: %u, name: \"%s\": %u", p->catalog, p->namespaceOid, p->objname ? p->objname : "", p->oid); #endif }
TEST(CoppyConstructor, ValidData) { Arguments object = initializeObject(); Arguments copyObject(object); ASSERT_EQ(copyObject.appName(), object.appName()); ASSERT_EQ(copyObject[0],object[0]); ASSERT_EQ(copyObject[1],object[1]); }
KeySpace& KeySpace::operator=(const KeySpace &ks) { if (this != &ks) { cleanUp(); copyObject(ks); } return *this; }
Node * replaceParamsMutator (Node *node, ReplaceParamsContext* context) { if (node == NULL) return NULL; // replace Param nodes with Vars if (IsA(node, Param) && context->touchParams) { Param *param; Node *newExpr; TargetEntry *te; param = (Param *) node; /* find target list entry for param and retrieve expr value */ te = (TargetEntry *) list_nth(context->sublink->targetList,param->paramid - 1); /* if the caller provides an varno value create a new var referencing this RTE */ if (context->useVarnoValue) newExpr = (Node *) makeVar(context->useVarnoValue, param->paramid, param->paramtype, param->paramtypmod, 0); /* else use the expr from the original sublink target entry */ else newExpr = (Node *) copyObject(te->expr); return (Node *) newExpr; } // adapt varlevelsup for Var nodes else if (IsA(node, Var)) { Var *var; var = (Var *) node; if (context->addVarSublevelsUp) var->varlevelsup = var->varlevelsup + context->addVarSublevelsUp; if (context->varSublevelsUp != -1) var->varlevelsup = context->varSublevelsUp; return (Node *) var; } // adapt aggregation varlevels up else if (IsA(node, Aggref) && context->touchAggs) { Aggref *aggref; aggref = (Aggref *) node; aggref->agglevelsup = context->aggSublevelsUp; return expression_tree_mutator(node, replaceParamsMutator, (void *) context); } // recurse return expression_tree_mutator(node, replaceParamsMutator, (void *) context); }
void CreateModel(CreateModelStmt *stmt,const char *queryString, DestReceiver *dest, char *completionTag) { List *query_list; List *planned_list; const char *commandTag; Portal portal; DestReceiver *tupledest; // create command Tag commandTag = CreateCommandTag(stmt->algorithmclause->trainingdata); // Rewrite the already analyzed Select query for the training data query_list = pg_rewrite_query((Query *)stmt->algorithmclause->trainingdata); // plan the query planned_list = pg_plan_queries(query_list,0,NULL); // results should be send to the ModelReceiver tupledest = CreateModelDestReceiver(stmt->modelname, (TargetEntry *)stmt->outputcolumn, stmt->timecolumns, ((Query *)stmt->algorithmclause->trainingdata)->jointree->quals, queryString,stmt->algorithmclause->algorithmname, ((AlgorithmClause *)copyObject(stmt->algorithmclause))->algorithmparameter, 0); // Create a new portal to run the query in portal = CreateNewPortal(); //Don't display the portal in pg_cursors, it is for internal use only portal->visible = false; PortalDefineQuery(portal, NULL, queryString, commandTag, planned_list, NULL); // Start the portal. No parameters here. PortalStart(portal, NULL, InvalidSnapshot); (void) PortalRun(portal, FETCH_ALL, false, tupledest, tupledest, completionTag); // Drop portal and receiver (*tupledest->rDestroy) (tupledest); PortalDrop(portal, false); }
TEST(AssignmentOperatorObject, ValidData) { char * args[1] = {(char*)"ceva"}; Arguments object = initializeObject(); Arguments copyObject(1, args); copyObject = object; ASSERT_EQ(copyObject.appName(), object.appName()); ASSERT_EQ(copyObject[0], object[0]); ASSERT_EQ(copyObject[1], object[1]); }
/* ---------------------------------------------------------------- * MJFormSkipQuals * * This takes the mergeclause which is a qualification of the * form ((= expr expr) (= expr expr) ...) and forms new lists * of the forms ((< expr expr) (< expr expr) ...) and * ((> expr expr) (> expr expr) ...). These lists will be used * by ExecMergeJoin() to determine if we should skip tuples. * (We expect there to be suitable operators because the "=" operators * were marked mergejoinable; however, there might be a different * one needed in each qual clause.) * ---------------------------------------------------------------- */ static void MJFormSkipQuals(List *qualList, List **ltQuals, List **gtQuals, PlanState *parent) { List *ltexprs, *gtexprs, *ltcdr, *gtcdr; /* * Make modifiable copies of the qualList. */ ltexprs = (List *) copyObject((Node *) qualList); gtexprs = (List *) copyObject((Node *) qualList); /* * Scan both lists in parallel, so that we can update the operators * with the minimum number of syscache searches. */ ltcdr = ltexprs; foreach(gtcdr, gtexprs) { OpExpr *ltop = (OpExpr *) lfirst(ltcdr); OpExpr *gtop = (OpExpr *) lfirst(gtcdr); /* * The two ops should be identical, so use either one for lookup. */ if (!IsA(ltop, OpExpr)) elog(ERROR, "mergejoin clause is not an OpExpr"); /* * Lookup the operators, and replace the data in the copied * operator nodes. */ op_mergejoin_crossops(ltop->opno, <op->opno, >op->opno, <op->opfuncid, >op->opfuncid); ltcdr = lnext(ltcdr); }
// virtual void LLInventoryItem::copyItem(const LLInventoryItem* other) { copyObject(other); mPermissions = other->mPermissions; mAssetUUID = other->mAssetUUID; mDescription = other->mDescription; mSaleInfo = other->mSaleInfo; mInventoryType = other->mInventoryType; mFlags = other->mFlags; mCreationDate = other->mCreationDate; }
/* * refresh_matview_datafill */ static void refresh_matview_datafill(DestReceiver *dest, Query *query, const char *queryString) { List *rewritten; PlannedStmt *plan; QueryDesc *queryDesc; Query *copied_query; /* Lock and rewrite, using a copy to preserve the original query. */ copied_query = copyObject(query); AcquireRewriteLocks(copied_query, true, false); rewritten = QueryRewrite(copied_query); /* SELECT should never rewrite to more or less than one SELECT query */ if (list_length(rewritten) != 1) elog(ERROR, "unexpected rewrite result for REFRESH MATERIALIZED VIEW"); query = (Query *) linitial(rewritten); /* Check for user-requested abort. */ CHECK_FOR_INTERRUPTS(); /* Plan the query which will generate data for the refresh. */ plan = pg_plan_query(query, 0, NULL); /* * Use a snapshot with an updated command ID to ensure this query sees * results of any previously executed queries. (This could only matter if * the planner executed an allegedly-stable function that changed the * database contents, but let's do it anyway to be safe.) */ PushCopiedSnapshot(GetActiveSnapshot()); UpdateActiveSnapshotCommandId(); /* Create a QueryDesc, redirecting output to our tuple receiver */ queryDesc = CreateQueryDesc(plan, queryString, GetActiveSnapshot(), InvalidSnapshot, dest, NULL, 0); /* call ExecutorStart to prepare the plan for execution */ ExecutorStart(queryDesc, EXEC_FLAG_WITHOUT_OIDS); /* run the plan */ ExecutorRun(queryDesc, ForwardScanDirection, 0L); /* and clean up */ ExecutorFinish(queryDesc); ExecutorEnd(queryDesc); FreeQueryDesc(queryDesc); PopActiveSnapshot(); }
static DLProgram * createWhyGPprogram (DLProgram *p, DLAtom *why) { DLProgram *solvedProgram; // DLProgram *result; solvedProgram = copyObject(p); unifyProgram(solvedProgram, why); solveProgram(solvedProgram, why); return p; }
/* * Prepare a subplan for sharing. This creates a Materialize node, * or marks the existing Materialize or Sort node as shared. After * this, you can call share_prepared_plan() as many times as you * want to share this plan. */ Plan * prepare_plan_for_sharing(PlannerInfo *root, Plan *common) { ShareType stype; Plan *shared = common; bool xslice = false; if (IsA(common, ShareInputScan)) { shared = common->lefttree; } else if(IsA(common, Material)) { Material *m = (Material *) common; Assert(m->share_type == SHARE_NOTSHARED); Assert(m->share_id == SHARE_ID_NOT_SHARED); stype = xslice ? SHARE_MATERIAL_XSLICE : SHARE_MATERIAL; m->share_id = SHARE_ID_NOT_ASSIGNED; m->share_type = stype; } else if (IsA(common, Sort)) { Sort *s = (Sort *) common; Assert(s->share_type == SHARE_NOTSHARED); stype = xslice ? SHARE_SORT_XSLICE : SHARE_SORT; s->share_id = SHARE_ID_NOT_ASSIGNED; s->share_type = stype; } else { Path matpath; Material *m = make_material(common); shared = (Plan *) m; cost_material(&matpath, root, common->total_cost, common->plan_rows, common->plan_width); shared->startup_cost = matpath.startup_cost; shared->total_cost = matpath.total_cost; shared->plan_rows = common->plan_rows; shared->plan_width = common->plan_width; shared->dispatch = common->dispatch; shared->flow = copyObject(common->flow); stype = xslice ? SHARE_MATERIAL_XSLICE : SHARE_MATERIAL; m->share_id = SHARE_ID_NOT_ASSIGNED; m->share_type = stype; } return shared; }
static void createJoinCondition (Query *query, SublinkInfo *info, bool isTargetRewrite) { JoinExpr *join; Node *condition; Node *Csub; Node *CsubPlus; if (info->sublink->subLinkType == ANY_SUBLINK || info->sublink->subLinkType == ALL_SUBLINK) { /* generate Csub and CsubPlus from sublink condition */ if (info->targetVar) { Csub = copyObject(info->targetVar); } else { Csub = generateCsub (info); } CsubPlus = generateCsubPlus (info, list_length(query->rtable) - 1); /* create condition */ if (info->sublink->subLinkType == ANY_SUBLINK) { /* C_sub' OR NOT C_sub */ condition = (Node *) makeBoolExpr(NOT_EXPR, list_make1(Csub)); condition = (Node *) makeBoolExpr(OR_EXPR, list_make2(CsubPlus, condition)); } if (info->sublink->subLinkType == ALL_SUBLINK) { /* C_sub OR NOT C_sub' */ condition = (Node *) makeBoolExpr(NOT_EXPR, list_make1(CsubPlus)); condition = (Node *) makeBoolExpr(OR_EXPR, list_make2(Csub, condition)); } } else { condition = makeBoolConst(true, false); } if (list_length(query->rtable) > 1) { join = (JoinExpr *) linitial(query->jointree->fromlist); join->quals = condition; } else { query->jointree->quals = condition; } }
/* * Generate plan for a UNION or UNION ALL node */ static Plan * generate_union_plan(SetOperationStmt *op, Query *parse, List *refnames_tlist) { List *planlist; List *tlist; Plan *plan; /* * If any of my children are identical UNION nodes (same op, all-flag, * and colTypes) then they can be merged into this node so that we * generate only one Append and Sort for the lot. Recurse to find * such nodes and compute their children's plans. */ planlist = nconc(recurse_union_children(op->larg, parse, op, refnames_tlist), recurse_union_children(op->rarg, parse, op, refnames_tlist)); /* * Generate tlist for Append plan node. * * The tlist for an Append plan isn't important as far as the Append is * concerned, but we must make it look real anyway for the benefit of * the next plan level up. */ tlist = generate_append_tlist(op->colTypes, false, planlist, refnames_tlist); /* * Append the child results together. */ plan = (Plan *) make_append(planlist, false, tlist); /* * For UNION ALL, we just need the Append plan. For UNION, need to * add Sort and Unique nodes to produce unique output. */ if (!op->all) { List *sortList; tlist = copyObject(tlist); sortList = addAllTargetsToSortList(NULL, NIL, tlist, false); plan = (Plan *) make_sort_from_sortclauses(parse, tlist, plan, sortList); plan = (Plan *) make_unique(tlist, plan, sortList); } return plan; }
/* * RebuildQueryStrings deparses the job query for each task to * include execution-time changes such as function evaluation. */ void RebuildQueryStrings(Query *originalQuery, List *taskList) { ListCell *taskCell = NULL; Oid relationId = ((RangeTblEntry *) linitial(originalQuery->rtable))->relid; foreach(taskCell, taskList) { Task *task = (Task *) lfirst(taskCell); StringInfo newQueryString = makeStringInfo(); Query *query = originalQuery; if (task->insertSelectQuery) { /* for INSERT..SELECT, adjust shard names in SELECT part */ RangeTblEntry *copiedInsertRte = NULL; RangeTblEntry *copiedSubqueryRte = NULL; Query *copiedSubquery = NULL; List *relationShardList = task->relationShardList; ShardInterval *shardInterval = LoadShardInterval(task->anchorShardId); query = copyObject(originalQuery); copiedInsertRte = ExtractInsertRangeTableEntry(query); copiedSubqueryRte = ExtractSelectRangeTableEntry(query); copiedSubquery = copiedSubqueryRte->subquery; AddShardIntervalRestrictionToSelect(copiedSubquery, shardInterval); ReorderInsertSelectTargetLists(query, copiedInsertRte, copiedSubqueryRte); /* setting an alias simplifies deparsing of RETURNING */ if (copiedInsertRte->alias == NULL) { Alias *alias = makeAlias(CITUS_TABLE_ALIAS, NIL); copiedInsertRte->alias = alias; } UpdateRelationToShardNames((Node *) copiedSubquery, relationShardList); } deparse_shard_query(query, relationId, task->anchorShardId, newQueryString); ereport(DEBUG4, (errmsg("query before rebuilding: %s", task->queryString))); ereport(DEBUG4, (errmsg("query after rebuilding: %s", newQueryString->data))); task->queryString = newQueryString->data; }
TObject* cloneObject(TObject *p) { TObject *clone; clone = (TObject *) malloc(sizeof(TObject)); if (clone == NULL) { printf("PANIC: object.c: cloneObject(): Run Out of Memory on clone Object\n" ); exit(0); } copyObject(p, clone); return clone; }
void copyObject(Alembic::Abc::IObject & iIn, Alembic::Abc::OObject & iOut) { std::size_t numChildren = iIn.getNumChildren(); Alembic::Abc::ICompoundProperty inProps = iIn.getProperties(); Alembic::Abc::OCompoundProperty outProps = iOut.getProperties(); copyProps(inProps, outProps); for (std::size_t i = 0; i < numChildren; ++i) { Alembic::Abc::IObject childIn(iIn.getChild(i)); Alembic::Abc::OObject childOut(iOut, childIn.getName(), childIn.getMetaData()); copyObject(childIn, childOut); } }
int main(int argc, char **argv) { printf("Testing memcpy/memmove with function pointers for array size "); printf("%d", ARRAY_SIZE); #ifdef NO_TAGS printf(" (no tags)"); #endif #ifdef FAKE_TAGS printf(" (fake tags)"); #endif printf("...\n"); Object *p = createEvilObject(); fillArray(p); printf("Calling function on original object...\n"); #ifndef NO_TAGS printf("Tag on p function pointer is %d\n", (int)load_tag(&(p->fn))); assert(load_tag(&(p->fn)) == __RISCV_TAG_CLEAN_FPTR); #endif p->fn(); Object *q = copyObject(p); checkArray(q); printf("Calling function on memcpy'ed copy of object...\n"); #ifndef NO_TAGS printf("Tag on p function pointer is %d\n", (int)load_tag(&(p->fn))); assert(load_tag(&(p->fn)) == __RISCV_TAG_CLEAN_FPTR); printf("Tag on q function pointer is %d\n", (int)load_tag(&(q->fn))); assert(load_tag(&(q->fn)) == __RISCV_TAG_CLEAN_FPTR); #endif q->fn(); Object *r = moveObject(p); checkArray(r); printf("Calling function on memmove'ed copy of object...\n"); #ifndef NO_TAGS printf("Tag on p function pointer is %d\n", (int)load_tag(&(p->fn))); assert(load_tag(&(p->fn)) == __RISCV_TAG_CLEAN_FPTR); printf("Tag on q function pointer is %d\n", (int)load_tag(&(q->fn))); assert(load_tag(&(q->fn)) == __RISCV_TAG_CLEAN_FPTR); printf("Tag on r function pointer is %d\n", (int)load_tag(&(r->fn))); assert(load_tag(&(r->fn)) == __RISCV_TAG_CLEAN_FPTR); #endif r->fn(); printf("Success!\n"); deleteObject(p); deleteObject(q); deleteObject(r); return 0; }
/* --------------- * _copyAgg * -------------- */ static Agg * _copyAgg(Agg *from) { Agg *newnode = makeNode(Agg); int i; CopyPlanFields((Plan*)from, (Plan*)newnode); CopyTempFields((Temp*)from, (Temp*)newnode); newnode->numAgg = from->numAgg; newnode->aggs = malloc(sizeof(Aggreg *)); for(i=0; i < from->numAgg; i++) { newnode->aggs[i] = copyObject(from->aggs[i]); } Node_Copy(from, newnode, aggstate); return newnode; }
/* * add_vars_to_targetlist * For each variable appearing in the list, add it to the owning * relation's targetlist if not already present, and mark the variable * as being needed for the indicated join (or for final output if * where_needed includes "relation 0"). * * The list may also contain PlaceHolderVars. These don't necessarily * have a single owning relation; we keep their attr_needed info in * root->placeholder_list instead. */ void add_vars_to_targetlist(PlannerInfo *root, List *vars, Relids where_needed) { ListCell *temp; Assert(!bms_is_empty(where_needed)); foreach(temp, vars) { Node *node = (Node *) lfirst(temp); if (IsA(node, Var)) { Var *var = (Var *) node; RelOptInfo *rel = find_base_rel(root, var->varno); int attno = var->varattno; Assert(attno >= rel->min_attr && attno <= rel->max_attr); attno -= rel->min_attr; if (rel->attr_needed[attno] == NULL) { /* Variable not yet requested, so add to reltargetlist */ /* XXX is copyObject necessary here? */ rel->reltargetlist = lappend(rel->reltargetlist, copyObject(var)); } rel->attr_needed[attno] = bms_add_members(rel->attr_needed[attno], where_needed); } else if (IsA(node, PlaceHolderVar)) { PlaceHolderVar *phv = (PlaceHolderVar *) node; PlaceHolderInfo *phinfo = find_placeholder_info(root, phv); phinfo->ph_needed = bms_add_members(phinfo->ph_needed, where_needed); } else elog(ERROR, "unrecognized node type: %d", (int) nodeTag(node)); }
static Node * generateCsubPlus (SublinkInfo *info, Index rtIndex) { Node *result; ReplaceParamsContext *context; context = (ReplaceParamsContext *) palloc(sizeof(ReplaceParamsContext)); context->paramSublevelsUp = 0; context->addVarSublevelsUp = 0;//CHECK thats ok to not add anything to varlevelsup context->varSublevelsUp = -1; context->touchParams = true; context->touchAggs = false; context->sublink = info->rewrittenSublinkQuery; context->useVarnoValue = rtIndex; result = copyObject(info->sublink->testexpr); result = replaceParamsMutator (result, context); pfree(context); return result; }
Query * rewriteSublinkUsingLeftJoin (Query *query, SublinkInfo *info, Index subList[]) { Query *rewrittenSublink; Index subIndex; /* rewrite Sublink query */ rewrittenSublink = rewriteQueryNode(copyObject(info->sublink->subselect)); info->rewrittenSublinkQuery = rewrittenSublink; /* join query RTEs */ joinQueryRTEs(query); /* add left join for subink */ subIndex = addLeftJoinWithRewrittenSublink (query, info); subList[info->sublinkPos] = subIndex; /* create the join condition for the left join with the rewritten sublink */ createJoinCondition (query, info, false); return query; }