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

Function DropTask

src/backend/commands/taskcmds.c:296–326  ·  view source on GitHub ↗

* DropTask * Drop an existing cron task. */

Source from the content-addressed store, hash-verified

294 * Drop an existing cron task.
295 */
296ObjectAddress
297DropTask(ParseState *pstate, DropTaskStmt * stmt)
298{
299 ObjectAddress address = InvalidObjectAddress;
300 char *username;
301 Oid jobid = InvalidOid;
302
303 /* current username */
304 username = GetUserNameFromId(GetUserId(), false);
305
306 /* delete from pg_task */
307 jobid = UnscheduleCronJob(stmt->taskname, username, InvalidOid, stmt->missing_ok);
308
309 /* delete from pg_task_run_history according to the jobid */
310 if (OidIsValid(jobid))
311 {
312 if (!allowSystemTableMods && strncmp(stmt->taskname, DYNAMIC_TASK_PREFIX, 25) == 0)
313 {
314 ereport(ERROR,
315 (errcode(ERRCODE_RESERVED_NAME),
316 errmsg("can not drop a internal task \"%s\" paried with dynamic table", stmt->taskname),
317 errdetail("please drop the dynamic table instead")));
318 }
319 RemoveTaskRunHistoryByJobId(jobid);
320 ObjectAddressSet(address, TaskRelationId, jobid);
321 /* Clean up dependencies */
322 deleteSharedDependencyRecordsFor(TaskRelationId, jobid, 0);
323 }
324
325 return address;
326}
327
328/*
329 * RemoveTaskById

Callers 1

ProcessUtilitySlowFunction · 0.85

Calls 8

GetUserNameFromIdFunction · 0.85
GetUserIdFunction · 0.85
UnscheduleCronJobFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50
errdetailFunction · 0.50

Tested by

no test coverage detected