/ Check-in [4c7ff4dd]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Invoke the unix open() system call through a wrapper to avoid problems resulting from differing declarations to that function in various systems.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 4c7ff4dd352276e9c01cc536e188cbcd69396952
User & Date: drh 2011-04-25 18:01:27
Context
2011-04-25
18:03
Add the (deliberately undocumented) sqlite_log() SQL function as a built-in. check-in: f7806e03 user: drh tags: trunk
18:01
Invoke the unix open() system call through a wrapper to avoid problems resulting from differing declarations to that function in various systems. check-in: 4c7ff4dd user: drh tags: trunk
2011-04-24
22:56
Disable the transfer optimization if the destination table contains any foreign key constraint and foreign key constraints are enabled. Ticket [6284df89debdf]. check-in: ddeea5ab user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/os_unix.c.

   276    276   ** testing and debugging only.
   277    277   */
   278    278   #if SQLITE_THREADSAFE
   279    279   #define threadid pthread_self()
   280    280   #else
   281    281   #define threadid 0
   282    282   #endif
          283  +
          284  +/*
          285  +** Different Unix systems declare open() in different ways.  Same use
          286  +** open(const char*,int,mode_t).  Others use open(const char*,int,...).
          287  +** The difference is important when using a pointer to the function.
          288  +**
          289  +** The safest way to deal with the problem is to always use this wrapper
          290  +** which always has the same well-defined interface.
          291  +*/
          292  +static int posixOpen(const char *zFile, int flags, int mode){
          293  +  return open(zFile, flags, mode);
          294  +}
   283    295   
   284    296   /*
   285    297   ** Many system calls are accessed through pointer-to-functions so that
   286    298   ** they may be overridden at runtime to facilitate fault injection during
   287    299   ** testing and sandboxing.  The following array holds the names and pointers
   288    300   ** to all overrideable system calls.
   289    301   */
   290    302   static struct unix_syscall {
   291    303     const char *zName;            /* Name of the sytem call */
   292    304     sqlite3_syscall_ptr pCurrent; /* Current value of the system call */
   293    305     sqlite3_syscall_ptr pDefault; /* Default value */
   294    306   } aSyscall[] = {
   295         -  { "open",         (sqlite3_syscall_ptr)open,       0  },
   296         -#define osOpen      ((int(*)(const char*,int,...))aSyscall[0].pCurrent)
          307  +  { "open",         (sqlite3_syscall_ptr)posixOpen,  0  },
          308  +#define osOpen      ((int(*)(const char*,int,int))aSyscall[0].pCurrent)
   297    309   
   298    310     { "close",        (sqlite3_syscall_ptr)close,      0  },
   299    311   #define osClose     ((int(*)(int))aSyscall[1].pCurrent)
   300    312   
   301    313     { "access",       (sqlite3_syscall_ptr)access,     0  },
   302    314   #define osAccess    ((int(*)(const char*,int))aSyscall[2].pCurrent)
   303    315