Skip to content

Commit b215893

Browse files
committed
[pg_dump] Dump SCHEDULE clause of Dynamic Tables.
Dynamic Table's SCHEDULE clause is stored in pg_task jobs. Add it when a Dynamic Table is dumped. Since the SCHEDULE clause is optional, there would be no error if we forget it when dump a Dynamic Table info. And a default SCHEDULE is added with the value of Macro: DYNAMIC_TABLE_DEFAULT_REFRESH_INTERVAL Authored-by: Zhang Mingli [email protected]
1 parent 17c9fed commit b215893

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/bin/pg_dump/pg_dump.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ static bool testAttributeEncodingSupport(Archive *fout);
389389
static char *nextToken(register char **stringp, register const char *delim);
390390
static void addDistributedBy(Archive *fout, PQExpBuffer q, const TableInfo *tbinfo, int actual_atts);
391391
static void addDistributedByOld(Archive *fout, PQExpBuffer q, const TableInfo *tbinfo, int actual_atts);
392+
static void addSchedule(Archive *fout, PQExpBuffer q, const TableInfo *tbinfo);
392393
static bool isGPDB4300OrLater(Archive *fout);
393394
static bool isGPDB(Archive *fout);
394395
static bool isGPDB5000OrLater(Archive *fout);
@@ -18173,6 +18174,7 @@ dumpTableSchema(Archive *fout, const TableInfo *tbinfo)
1817318174
{
1817418175
/* We'r sure there is no UNLOGGED and this is a DYNAMIC TABLE. */
1817518176
appendPQExpBuffer(q, "CREATE DYNAMIC TABLE %s", qualrelname);
18177+
addSchedule(fout, q, tbinfo);
1817618178
}
1817718179
else
1817818180
{
@@ -21459,6 +21461,32 @@ testExtProtocolSupport(Archive *fout)
2145921461
return isSupported;
2146021462
}
2146121463

21464+
/*
21465+
* addSchedule
21466+
*
21467+
* find the SCHEDULE of the job in pg_task with dynamic table
21468+
* and append the SCHEDULE clause to the passed in dump buffer (q).
21469+
*/
21470+
static void
21471+
addSchedule(Archive *fout, PQExpBuffer q, const TableInfo *tbinfo)
21472+
{
21473+
PQExpBuffer query = createPQExpBuffer();
21474+
PGresult *res;
21475+
char *dby;
21476+
21477+
appendPQExpBuffer(query,
21478+
"SELECT pg_catalog.pg_get_dynamic_table_schedule(%u)",
21479+
tbinfo->dobj.catId.oid);
21480+
21481+
res = ExecuteSqlQueryForSingleRow(fout, query->data);
21482+
21483+
dby = PQgetvalue(res, 0, 0);
21484+
if (strcmp(dby, "") != 0)
21485+
appendPQExpBuffer(q, " SCHEDULE \'%s\'", PQgetvalue(res, 0, 0));
21486+
21487+
PQclear(res);
21488+
destroyPQExpBuffer(query);
21489+
}
2146221490

2146321491
/*
2146421492
* addDistributedBy

0 commit comments

Comments
 (0)