yjhjstz commented on code in PR #725:
URL: https://github.com/apache/cloudberry/pull/725#discussion_r1861544884
##########
src/backend/commands/createas.c:
##########
@@ -1808,3 +1820,38 @@ get_primary_key_attnos_from_query(Query *query, List
**constraintList)
return keys;
}
+
+/*
+ * Create auto-refresh task for Dynamic Tables.
+ */
+static void
+create_dynamic_table_auto_refresh_task(ParseState *pstate, Relation
DynamicTableRel, char *schedule)
+{
+ ObjectAddress refaddr;
+ ObjectAddress address;
+ StringInfoData buf;
+ char *dtname = NULL;
+
+ if (schedule == NULL)
+ schedule = DYNAMIC_TABLE_DEFAULT_REFRESH_INTERVAL;
+
+ /* Create auto refresh task. */
+ CreateTaskStmt *task_stmt = makeNode(CreateTaskStmt);
+
+ initStringInfo(&buf);
+ appendStringInfo(&buf, "gp_dynamic_table_refresh_%u",
RelationGetRelid(DynamicTableRel));
+ task_stmt->taskname = pstrdup(buf.data);
+ task_stmt->schedule = pstrdup(schedule);
+ task_stmt->if_not_exists = false; /* report error if failed. */
+ dtname =
quote_qualified_identifier(get_namespace_name(RelationGetNamespace(DynamicTableRel)),
+
RelationGetRelationName(DynamicTableRel));
+ resetStringInfo(&buf);
+ appendStringInfo(&buf, "REFRESH DYNAMIC TABLE %s", dtname);
Review Comment:
```c++
DropTask(ParseState *pstate, DropTaskStmt *stmt)
{
ObjectAddress address = InvalidObjectAddress;
char *username;
Oid jobid = InvalidOid;
/* current username */
username = GetUserNameFromId(GetUserId(), false);
/* delete from pg_task */
jobid = UnscheduleCronJob(stmt->taskname, username, InvalidOid,
stmt->missing_ok);
/* delete from pg_task_run_history according to the jobid */
if (OidIsValid(jobid))
{
RemoveTaskRunHistoryByJobId(jobid);
ObjectAddressSet(address, TaskRelationId, jobid);
/* Clean up dependencies */
deleteSharedDependencyRecordsFor(TaskRelationId, jobid, 0);
+deleteDependencyRecordsFor(TaskRelationId, jobid, false);
}
return address;
}
```
try remove dependency use `deleteDependencyRecordsFor`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]