Hello and have a good time of day! Some time ago I've posted a patch which allowed to compile and use SQLite 3.7.9 under OpenVMS operating system:
http://sqlite.1065341.n5.nabble.com/Port-of-SQLite-3-7-9-to-OpenVMS-td55734.html http://sqlite.1065341.n5.nabble.com/Port-of-SQLite-3-7-9-to-OpenVMS-patch-td55735.html Now I have a somewhat improved version of that patch, which can be used with 3.7.14.1 SQLite amalgamation. I used some tricks from http://www.vmspython.org/ version of SQLite, and invented some new. Database locking still doesn't work (use "unix-none" driver argument of sqlite3_open_v2(), or you will get a "Database is locked" message). I just cannot figure out why does SQLite POSIX advisory locking code fail to work under OpenVMS, and I plan to write a specific question to some VMS programming user group. To compile a patched sqlite3.c, use the following DCL script (mostly taken from http://www.vmspython.org/): xxxxxxxx BEGIN sqlite3vms.com $ vmsver = f$getsyi("VERSION") $ if vmsver .ges. "V8.2" $ then $ cc/opt/define=(NO_GETTOD,RTLD_GLOBAL=0,_USE_STD_STAT=1,- _LARGEFILE,_POSIX_EXIT=1) - /float=ieee/ieee=denorm - sqlite3.c $ else $ cc/opt/define=(NO_GETTOD,RTLD_GLOBAL=0, _LARGEFILE,- __USE_INO64=1,_POSIX_EXIT=1) - /float=ieee/ieee=denorm - sqlite3.c $ endif xxxxxxxx END sqlite3vms.com Best regards, Maxim Zinal P.S. And this is a patch itself: xxxxxxxx BEGIN sqlite-3.7.14.1-vms.patch diff -urb sqlite-3.7.14.1/sqlite3.c sqlite-3.7.14.1-vms/sqlite3.c --- sqlite-3.7.14.1/sqlite3.c 2012-10-04 23:49:28.000000000 +0400 +++ sqlite-3.7.14.1-vms/sqlite3.c 2012-10-31 22:48:37.391310431 +0400 @@ -71,6 +71,15 @@ #endif /* +** Under VMS, dirsync must be disabled + */ +#ifdef __VMS +# ifndef SQLITE_DISABLE_DIRSYNC +# define SQLITE_DISABLE_DIRSYNC 1 +# endif +#endif + +/* ** Include the configuration header output by 'configure' if we're using the ** autoconf-based build */ @@ -316,6 +325,10 @@ #include <inttypes.h> #endif +#ifdef __VMS +#include <unistd.h> +#endif + /* ** The following macros are used to cast pointers to integers and ** integers to pointers. The way you do this varies from one compiler @@ -14888,8 +14901,15 @@ DO_OS_MALLOC_TEST(id); return id->pMethods->xSync(id, flags); } +#ifdef __VMS +SQLITE_PRIVATE int _vms_fsync(sqlite3_file *); +#endif SQLITE_PRIVATE int sqlite3OsFileSize(sqlite3_file *id, i64 *pSize){ DO_OS_MALLOC_TEST(id); +#ifdef __VMS + int rc = _vms_fsync(id); + if ( rc!=0 ) return rc; +#endif return id->pMethods->xFileSize(id, pSize); } SQLITE_PRIVATE int sqlite3OsLock(sqlite3_file *id, int lockType){ @@ -23060,6 +23080,12 @@ #define threadid 0 #endif +#ifdef __VMS +static char *posixGetcwd(char *buf, size_t size) { + return getcwd(buf, size, 0); +} +#endif + /* ** Different Unix systems declare open() in different ways. Same use ** open(const char*,int,mode_t). Others use open(const char*,int,...). @@ -23069,7 +23095,20 @@ ** which always has the same well-defined interface. */ static int posixOpen(const char *zFile, int flags, int mode){ +#ifdef __VMS + if ( (flags & O_NDELAY) == 0 ) { + /* Normal file */ + return open(zFile, flags, mode, + "shr = del, get, put, upd", "ctx = stm", "ctx = bin"); + } else { + /* Temporary file - delete on close */ + flags &= ~O_NDELAY; + return open(zFile, flags, mode, "fop = dlt, tmp", + "shr = del, get, put, upd", "ctx = stm", "ctx = bin"); + } +#else return open(zFile, flags, mode); +#endif } /* @@ -23104,7 +23143,11 @@ { "access", (sqlite3_syscall_ptr)access, 0 }, #define osAccess ((int(*)(const char*,int))aSyscall[2].pCurrent) +#ifdef __VMS + { "getcwd", (sqlite3_syscall_ptr)posixGetcwd,0 }, +#else { "getcwd", (sqlite3_syscall_ptr)getcwd, 0 }, +#endif #define osGetcwd ((char*(*)(char*,size_t))aSyscall[3].pCurrent) { "stat", (sqlite3_syscall_ptr)stat, 0 }, @@ -23390,7 +23433,7 @@ zOpName = "SETLK"; }else{ s = osFcntl(fd, op, p); - sqlite3DebugPrintf("fcntl unknown %d %d %d\n", fd, op, s); + sqlite3DebugPrintf("fcntl unknown FD=%d OP=%d S=%d\n", fd, op, s); return s; } if( p->l_type==F_RDLCK ){ @@ -23405,9 +23448,9 @@ assert( p->l_whence==SEEK_SET ); s = osFcntl(fd, op, p); savedErrno = errno; - sqlite3DebugPrintf("fcntl %d %d %s %s %d %d %d %d\n", + sqlite3DebugPrintf("fcntl T=%d FD=%d %s %s LS=%d LL=%d PID=%d S=%d ERR=%d\n", threadid, fd, zOpName, zType, (int)p->l_start, (int)p->l_len, - (int)p->l_pid, s); + (int)p->l_pid, s, savedErrno); if( s==(-1) && op==F_SETLK && (p->l_type==F_RDLCK || p->l_type==F_WRLCK) ){ struct flock l2; l2 = *p; @@ -23421,7 +23464,7 @@ }else{ assert( 0 ); } - sqlite3DebugPrintf("fcntl-failure-reason: %s %d %d %d\n", + sqlite3DebugPrintf("fcntl-failure-reason: %s LS=%d LL=%d PID=%d\n", zType, (int)l2.l_start, (int)l2.l_len, (int)l2.l_pid); } errno = savedErrno; @@ -23765,6 +23808,16 @@ dev_t dev; /* Device number */ #if OS_VXWORKS struct vxworksFileId *pId; /* Unique file ID for vxworks. */ +#elif defined(__VMS) +# ifdef __USING_STD_STAT + ino_t ino; +# else +# if __USE_INO64 + __ino64_t ino; +# else + __ino32_t ino; +# endif +# endif #else ino_t ino; /* Inode number */ #endif @@ -24575,6 +24628,7 @@ */ static int closeUnixFile(sqlite3_file *id){ unixFile *pFile = (unixFile*)id; + OSTRACE(("CLOSE %-3d\n", pFile->h)); if( pFile->h>=0 ){ robust_close(pFile, pFile->h, __LINE__); pFile->h = -1; @@ -24588,7 +24642,6 @@ pFile->pId = 0; } #endif - OSTRACE(("CLOSE %-3d\n", pFile->h)); OpenCounter(-1); sqlite3_free(pFile->pUnused); memset(pFile, 0, sizeof(unixFile)); @@ -27896,6 +27949,9 @@ if( isCreate ) openFlags |= O_CREAT; if( isExclusive ) openFlags |= (O_EXCL|O_NOFOLLOW); openFlags |= (O_LARGEFILE|O_BINARY); +#ifdef __VMS + if( isDelete ) openFlags |= O_NDELAY; +#endif if( fd<0 ){ mode_t openMode; /* Permissions to create file with */ @@ -27944,7 +28000,7 @@ if( isDelete ){ #if OS_VXWORKS zPath = zName; -#else +#elif !defined(__VMS) osUnlink(zName); #endif } @@ -40791,6 +40847,13 @@ sqlite3PcacheRef(pPg); } +#ifdef __VMS +SQLITE_PRIVATE int _vms_fsync(sqlite3_file *id){ + struct unixFile *pFile = (struct unixFile*)id; + return fsync(pFile->h); +} +#endif + /* ** Sync the journal. In other words, make sure all the pages that have ** been written to the journal have actually reached the surface of the xxxxxxxx END sqlite-3.7.14.1-vms.patch _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users