Creating temporary tables fails in Cygwin SQLite:

sqlite> CREATE TEMPORARY TABLE foo (bar INT);
Error: unable to open database file

The reason this operation fails is that SQLite cannot create a
temporary file in "C:\Windows", which GetTempPathW reports as the
system temporary directory. GetTempPathW returns the system temporary
directory when none of the environment variables "TMP", "TEMP", and
"USERPROFILE" is set. In a typical Cygwin environment, these
environment variables are unset from the point of view of Windows
APIs: Cygwin maintains an internal, Cygwin-private environment block
and synchronizes it with the Windows environment block lazily. A
normal Cygwin process that uses SQLite has no reason to initialize its
Windows environment block.

Programs run under strace or the debugger, however, do receive a
Windows environment block, so temporary table creation appears to work
in programs run using these tools. A user with administrative rights
can also create temporary tables, since he will be able to write to
the Windows directory.

In a Cygwin environment, SQLite should avoid GetTempPathW and instead
use unixGetTempname to find the temporary directory, translating paths
as appropriate.



Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to