MCPcopy Create free account
hub / github.com/apache/cloudberry / AddUpdResqueueCapabilityEntryInternal

Function AddUpdResqueueCapabilityEntryInternal

src/backend/commands/queue.c:226–273  ·  view source on GitHub ↗

MPP-6923: */ 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. * */

Source from the content-addressed store, hash-verified

224 *
225 */
226static void
227AddUpdResqueueCapabilityEntryInternal(
228 Relation resqueuecap_rel,
229 Oid queueid,
230 int resTypeInt,
231 char *pResSetting,
232 Relation rel,
233 HeapTuple old_tuple)
234{
235 HeapTuple new_tuple;
236 Datum values[Natts_pg_resqueuecapability];
237 bool isnull[Natts_pg_resqueuecapability];
238 bool new_record_repl[Natts_pg_resqueuecapability];
239
240 MemSet(isnull, 0, sizeof(bool) * Natts_pg_resqueuecapability);
241 MemSet(new_record_repl, 0, sizeof(bool) * Natts_pg_resqueuecapability);
242
243 values[Anum_pg_resqueuecapability_resqueueid - 1] =
244 ObjectIdGetDatum(queueid);
245 values[Anum_pg_resqueuecapability_restypid - 1] = resTypeInt;
246
247 Assert(pResSetting);
248
249 values[Anum_pg_resqueuecapability_ressetting - 1] =
250 CStringGetTextDatum(pResSetting);
251 /* set this column to update */
252 new_record_repl[Anum_pg_resqueuecapability_ressetting - 1] = true;
253
254 ValidateResqueueCapabilityEntry(resTypeInt, pResSetting);
255
256 if (HeapTupleIsValid(old_tuple))
257 {
258 new_tuple = heap_modify_tuple(old_tuple,
259 RelationGetDescr(resqueuecap_rel),
260 values, isnull, new_record_repl);
261
262 CatalogTupleUpdate(resqueuecap_rel, &old_tuple->t_self, new_tuple);
263 }
264 else
265 {
266 new_tuple = heap_form_tuple(RelationGetDescr(resqueuecap_rel), values, isnull);
267
268 CatalogTupleInsert(resqueuecap_rel, new_tuple);
269 }
270
271 if (HeapTupleIsValid(old_tuple))
272 heap_freetuple(new_tuple);
273} /* end AddUpdResqueueCapabilityEntryInternal */
274
275/* MPP-6923: */
276static void

Callers 1

Calls 7

ObjectIdGetDatumFunction · 0.85
heap_modify_tupleFunction · 0.85
CatalogTupleUpdateFunction · 0.85
heap_form_tupleFunction · 0.85
CatalogTupleInsertFunction · 0.85
heap_freetupleFunction · 0.85

Tested by

no test coverage detected