* GetTaskJobId * Get the jobid of a task. */
| 173 | * Get the jobid of a task. |
| 174 | */ |
| 175 | Oid |
| 176 | GetTaskJobId(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 |
no test coverage detected