else if (info == XLOG_DBASE_DROP)
{
xl_dbase_drop_rec *xlrec = (xl_dbase_drop_rec *) rec;
+ int i;
- appendStringInfo(buf, "dir %u/%u",
- xlrec->tablespace_id, xlrec->db_id);
+ appendStringInfo(buf, "dir");
+ for (i = 0; i < xlrec->ntablespaces; i++)
+ appendStringInfo(buf, " %u/%u",
+ xlrec->tablespace_ids[i], xlrec->db_id);
}
}
xl_dbase_drop_rec xlrec;
xlrec.db_id = db_id;
- xlrec.tablespace_id = src_tblspcoid;
+ xlrec.ntablespaces = 1;
XLogBeginInsert();
XLogRegisterData((char *) &xlrec, sizeof(xl_dbase_drop_rec));
+ XLogRegisterData((char *) &src_tblspcoid, sizeof(Oid));
(void) XLogInsert(RM_DBASE_ID,
XLOG_DBASE_DROP | XLR_SPECIAL_REL_UPDATE);
Relation rel;
TableScanDesc scan;
HeapTuple tuple;
+ List *ltblspc = NIL;
+ ListCell *cell;
+ int ntblspc;
+ int i;
+ Oid *tablespace_ids;
rel = table_open(TableSpaceRelationId, AccessShareLock);
scan = table_beginscan_catalog(rel, 0, NULL);
(errmsg("some useless files may be left behind in old database directory \"%s\"",
dstpath)));
- /* Record the filesystem change in XLOG */
- {
- xl_dbase_drop_rec xlrec;
+ ltblspc = lappend_oid(ltblspc, dsttablespace);
+ pfree(dstpath);
+ }
- xlrec.db_id = db_id;
- xlrec.tablespace_id = dsttablespace;
+ ntblspc = list_length(ltblspc);
+ if (ntblspc == 0)
+ {
+ table_endscan(scan);
+ table_close(rel, AccessShareLock);
+ return;
+ }
- XLogBeginInsert();
- XLogRegisterData((char *) &xlrec, sizeof(xl_dbase_drop_rec));
+ tablespace_ids = (Oid *) palloc(ntblspc * sizeof(Oid));
+ i = 0;
+ foreach(cell, ltblspc)
+ tablespace_ids[i++] = lfirst_oid(cell);
- (void) XLogInsert(RM_DBASE_ID,
- XLOG_DBASE_DROP | XLR_SPECIAL_REL_UPDATE);
- }
+ /* Record the filesystem change in XLOG */
+ {
+ xl_dbase_drop_rec xlrec;
- pfree(dstpath);
+ xlrec.db_id = db_id;
+ xlrec.ntablespaces = ntblspc;
+
+ XLogBeginInsert();
+ XLogRegisterData((char *) &xlrec, MinSizeOfDbaseDropRec);
+ XLogRegisterData((char *) tablespace_ids, ntblspc * sizeof(Oid));
+
+ (void) XLogInsert(RM_DBASE_ID,
+ XLOG_DBASE_DROP | XLR_SPECIAL_REL_UPDATE);
}
+ list_free(ltblspc);
+ pfree(tablespace_ids);
+
table_endscan(scan);
table_close(rel, AccessShareLock);
}
{
xl_dbase_drop_rec *xlrec = (xl_dbase_drop_rec *) XLogRecGetData(record);
char *dst_path;
-
- dst_path = GetDatabasePath(xlrec->db_id, xlrec->tablespace_id);
+ int i;
if (InHotStandby)
{
/* Clean out the xlog relcache too */
XLogDropDatabase(xlrec->db_id);
- /* And remove the physical files */
- if (!rmtree(dst_path, true))
- ereport(WARNING,
- (errmsg("some useless files may be left behind in old database directory \"%s\"",
- dst_path)));
+ for (i = 0; i < xlrec->ntablespaces; i++)
+ {
+ dst_path = GetDatabasePath(xlrec->db_id, xlrec->tablespace_ids[i]);
+
+ /* And remove the physical files */
+ if (!rmtree(dst_path, true))
+ ereport(WARNING,
+ (errmsg("some useless files may be left behind in old database directory \"%s\"",
+ dst_path)));
+ pfree(dst_path);
+ }
if (InHotStandby)
{