Unregister file from workset even it's not "delete at close"
SharedFileSet files are automatically closed at end of transaction, but
are not automatically deleted on close because they are intended to be
shared between cooperating backends.
By that, unregister file from workset just as unregister from resource
owner there.
@@ -1961,9 +1961,6 @@ FileClose(File file)
else
stat_errno = 0;
- if (vfdP->fdstate & FD_WORKFILE)
- WorkFileDeleted(file, true);
-
/* in any case do the unlink */
if (unlink(vfdP->fileName))
elog(DEBUG1, "could not unlink file \"%s\": %m", vfdP->fileName);
@@ -1982,6 +1979,10 @@ FileClose(File file)
if (vfdP->resowner)
ResourceOwnerForgetFile(vfdP->resowner, file);
+ /* Unregister it from the workfile set */
+ if (vfdP->fdstate & FD_WORKFILE)
+ WorkFileDeleted(file, true);
+
/*
* Return the Vfd slot to the free list
*/
