Skip to content

Commit c05fc14

Browse files
committed
Always unlink first segment for AO/AOCO temp relation.
1 parent 857723b commit c05fc14

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

  • src/backend/access/appendonly

src/backend/access/appendonly/aomd.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ struct truncate_ao_callback_ctx
256256
void
257257
mdunlink_ao(RelFileNodeBackend rnode, ForkNumber forkNumber, bool isRedo)
258258
{
259+
int ret;
259260
const char *path = relpath(rnode, forkNumber);
260261

261262
/*
@@ -294,6 +295,19 @@ mdunlink_ao(RelFileNodeBackend rnode, ForkNumber forkNumber, bool isRedo)
294295
pfree(segPath);
295296
}
296297

298+
/*
299+
* Delete or truncate the first segment. See mdunlinkfork also.
300+
*/
301+
if (RelFileNodeBackendIsTemp(rnode))
302+
{
303+
/* Next unlink the file, unless it was already found to be missing */
304+
ret = unlink(path);
305+
if (ret < 0 && errno != ENOENT)
306+
ereport(WARNING,
307+
(errcode_for_file_access(),
308+
errmsg("could not remove file \"%s\": %m", path)));
309+
}
310+
297311
pfree((void *) path);
298312
}
299313

0 commit comments

Comments
 (0)