avamingli commented on code in PR #725:
URL: https://github.com/apache/cloudberry/pull/725#discussion_r1861461636
##########
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:
Good catch!
> if drop task manually
We shouldn't allow that as it's part of DYNAMIC TABLE, I provide a job
prefix `gp_dynamic_table_refresh` prefix to tell the users it's a internal one.
In GPDB, users can't manage `gp` or `pg` prefix objects in principle.
However, a prefix is not enough now.
##########
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:
Good catch!
> if drop task manually
We shouldn't allow that as it's part of DYNAMIC TABLE, I provide a job
prefix `gp_dynamic_table_refresh` to tell the users it's a internal one. In
GPDB, users can't manage `gp` or `pg` prefix objects in principle.
However, a prefix is not enough now.
--
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]