/* AddUpdResqueueCapabilityEntryInternal: * * Internal function to add a new entry to pg_resqueuecapability, or * update an existing one. Key cols are queueid, restypint. If * old_tuple is set (ie not InvalidOid), the update the ressetting column, * else insert a new row. * */ static void AddUpdResqueueCapabilityEntryInternal( Relation resqueuecap_rel, Oid queueid, int resTypeInt, char *pResSetting, Relation rel, HeapTuple old_tuple) { HeapTuple new_tuple; Datum values[Natts_pg_resqueuecapability]; bool isnull[Natts_pg_resqueuecapability]; bool new_record_repl[Natts_pg_resqueuecapability]; MemSet(isnull, 0, sizeof(bool) * Natts_pg_resqueuecapability); MemSet(new_record_repl, 0, sizeof(bool) * Natts_pg_resqueuecapability); values[Anum_pg_resqueuecapability_resqueueid - 1] = ObjectIdGetDatum(queueid); values[Anum_pg_resqueuecapability_restypid - 1] = resTypeInt; Assert(pResSetting); values[Anum_pg_resqueuecapability_ressetting - 1] = CStringGetTextDatum(pResSetting); /* set this column to update */ new_record_repl[Anum_pg_resqueuecapability_ressetting - 1] = true; ValidateResqueueCapabilityEntry(resTypeInt, pResSetting); if (HeapTupleIsValid(old_tuple)) { new_tuple = heap_modify_tuple(old_tuple, RelationGetDescr(resqueuecap_rel), values, isnull, new_record_repl); simple_heap_update(resqueuecap_rel, &old_tuple->t_self, new_tuple); CatalogUpdateIndexes(resqueuecap_rel, new_tuple); } else { new_tuple = heap_form_tuple(RelationGetDescr(resqueuecap_rel), values, isnull); simple_heap_insert(resqueuecap_rel, new_tuple); CatalogUpdateIndexes(resqueuecap_rel, new_tuple); } if (HeapTupleIsValid(old_tuple)) heap_freetuple(new_tuple); } /* end AddUpdResqueueCapabilityEntryInternal */
/* AddUpdResqueueCapabilityEntryInternal: * * Internal function to add a new entry to pg_resqueuecapability, or * update an existing one. Key cols are queueid, restypint. If * old_tuple is set (ie not InvalidOid), the update the ressetting column, * else insert a new row. * */ static List * AddUpdResqueueCapabilityEntryInternal( cqContext *pcqCtx, List *stmtOptIdList, Oid queueid, int resTypeInt, char *pResSetting, Relation rel, HeapTuple old_tuple) { HeapTuple new_tuple; Datum values[Natts_pg_resqueuecapability]; bool isnull[Natts_pg_resqueuecapability]; bool new_record_repl[Natts_pg_resqueuecapability]; MemSet(isnull, 0, sizeof(bool) * Natts_pg_resqueuecapability); MemSet(new_record_repl, 0, sizeof(bool) * Natts_pg_resqueuecapability); values[Anum_pg_resqueuecapability_resqueueid - 1] = ObjectIdGetDatum(queueid); values[Anum_pg_resqueuecapability_restypid - 1] = resTypeInt; Assert(pResSetting); values[Anum_pg_resqueuecapability_ressetting - 1] = CStringGetTextDatum(pResSetting); /* set this column to update */ new_record_repl[Anum_pg_resqueuecapability_ressetting - 1] = true; ValidateResqueueCapabilityEntry(resTypeInt, pResSetting); if (HeapTupleIsValid(old_tuple)) { new_tuple = caql_modify_current(pcqCtx, values, isnull, new_record_repl); caql_update_current(pcqCtx, new_tuple); /* and Update indexes (implicit) */ } else { Oid s1; new_tuple = caql_form_tuple(pcqCtx, values, isnull); /* MPP-11858: synchronize the oids for CREATE/ALTER options... */ if ((Gp_role != GP_ROLE_DISPATCH) && list_length(stmtOptIdList)) { Oid s2 = list_nth_oid(stmtOptIdList, 0); stmtOptIdList = list_delete_first(stmtOptIdList); if (OidIsValid(s2)) HeapTupleSetOid(new_tuple, s2); } s1 = caql_insert(pcqCtx, new_tuple); /* and Update indexes (implicit) */ if (Gp_role == GP_ROLE_DISPATCH) { stmtOptIdList = lappend_oid(stmtOptIdList, s1); } } if (HeapTupleIsValid(old_tuple)) heap_freetuple(new_tuple); return stmtOptIdList; } /* end AddUpdResqueueCapabilityEntryInternal */