SQL Server on Linux: How is Delete-On-Close Handled


Moved from: bobsql.com

 

Windows provides an option for CreateFile to delete a file when the file is closed (FILE_FLAG_DELETE_ON_CLOSE.)  

 

Host Extension Handling

Linux does not expose such an option as part of the open syscall.  Instead the host extension remembers that the open request was made with the FILE_FLAG_ON_DELETE option and after closing a file issues the remove syscall on your behalf.

 

Linux does provide a delete-on-close like capability using the unlink or remove syscalls.  Intentionally, the Host Extension does not open the file and then invoke unlink or remove.  Linux allows a file open syscall, followed by a call to unlink or remove, and as long as a