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

Function GetTaskJobId

src/backend/catalog/pg_task.c:175–206  ·  view source on GitHub ↗

* GetTaskJobId * Get the jobid of a task. */

Source from the content-addressed store, hash-verified

173 * Get the jobid of a task.
174 */
175Oid
176GetTaskJobId(const char *jobname, const char *username)
177{
178 Relation pg_task;
179 HeapTuple tup;
180 SysScanDesc scanDescriptor = NULL;
181 ScanKeyData scanKey[2];
182 Oid jobid = InvalidOid;
183 Form_pg_task task;
184
185 pg_task = table_open(TaskRelationId, AccessShareLock);
186
187 ScanKeyInit(&scanKey[0], Anum_pg_task_jobname, BTEqualStrategyNumber,
188 F_TEXTEQ, CStringGetTextDatum(jobname));
189 ScanKeyInit(&scanKey[1], Anum_pg_task_username, BTEqualStrategyNumber,
190 F_TEXTEQ, CStringGetTextDatum(username));
191
192 scanDescriptor = systable_beginscan(pg_task, TaskJobNameUserNameIndexId,
193 true, NULL, 2, scanKey);
194 tup = systable_getnext(scanDescriptor);
195
196 if (HeapTupleIsValid(tup))
197 {
198 task = (Form_pg_task) GETSTRUCT(tup);
199 jobid = task->jobid;
200 }
201
202 systable_endscan(scanDescriptor);
203 table_close(pg_task, AccessShareLock);
204
205 return jobid;
206}
207
208/*
209 * GetTaskNameById

Callers 2

DefineTaskFunction · 0.85
AlterTaskFunction · 0.85

Calls 6

table_openFunction · 0.85
ScanKeyInitFunction · 0.85
systable_beginscanFunction · 0.85
systable_getnextFunction · 0.85
systable_endscanFunction · 0.85
table_closeFunction · 0.85

Tested by

no test coverage detected