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

Function AlterTask

src/backend/commands/taskcmds.c:151–290  ·  view source on GitHub ↗

* AlterTask * Alter an existing cron task. */

Source from the content-addressed store, hash-verified

149 * Alter an existing cron task.
150 */
151ObjectAddress
152AlterTask(ParseState *pstate, AlterTaskStmt * stmt)
153{
154 ObjectAddress address = InvalidObjectAddress;
155 char *current_user;
156 Oid jobid = InvalidOid;
157 DefElem *d_schedule = NULL;
158 DefElem *d_dbname = NULL;
159 DefElem *d_username = NULL;
160 DefElem *d_active = NULL;
161 DefElem *d_sql = NULL;
162 ListCell *option;
163 char *schedule = NULL;
164 char *dbname = NULL;
165 char *username = NULL;
166 bool active;
167 char *sql = NULL;
168
169 current_user = GetUserNameFromId(GetUserId(), false);
170 jobid = GetTaskJobId(stmt->taskname, current_user);
171 if (!OidIsValid(jobid))
172 {
173 if (stmt->missing_ok)
174 {
175 ereport(NOTICE,
176 (errcode(ERRCODE_UNDEFINED_OBJECT),
177 errmsg("task \"%s\" does not exist, skipping",
178 stmt->taskname)));
179 return address;
180 }
181 else
182 ereport(ERROR,
183 (errcode(ERRCODE_UNDEFINED_OBJECT),
184 errmsg("task \"%s\" does not exist", stmt->taskname)));
185 }
186
187 foreach(option, stmt->options)
188 {
189 DefElem *defel = (DefElem *) lfirst(option);
190
191 if (strcmp(defel->defname, "schedule") == 0)
192 {
193 if (d_schedule)
194 ereport(ERROR,
195 (errcode(ERRCODE_SYNTAX_ERROR),
196 errmsg("conflicting or redundant options"),
197 parser_errposition(pstate, defel->location)));
198 d_schedule = defel;
199 }
200 else if (strcmp(defel->defname, "dbname") == 0)
201 {
202 if (d_dbname)
203 ereport(ERROR,
204 (errcode(ERRCODE_SYNTAX_ERROR),
205 errmsg("conflicting or redundant options"),
206 parser_errposition(pstate, defel->location)));
207 d_dbname = defel;
208 }

Callers 1

ProcessUtilitySlowFunction · 0.85

Calls 12

GetUserNameFromIdFunction · 0.85
GetUserIdFunction · 0.85
GetTaskJobIdFunction · 0.85
parser_errpositionFunction · 0.85
defGetStringFunction · 0.85
get_database_oidFunction · 0.85
get_role_oidFunction · 0.85
AlterCronJobFunction · 0.85
changeDependencyOnOwnerFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50
foreachFunction · 0.50

Tested by

no test coverage detected