From 27f7e9ecf6d117f2d94d33c7112786654d36c649 Mon Sep 17 00:00:00 2001 From: Daniel Erat Date: Tue, 19 Jul 2011 22:55:07 +0000 Subject: [PATCH] sqlite: more stubs; test fails instead of crashing Change-Id: I3a9e08d7228c39b8a333469c0ea4f1a6c1cf2b47 --- misc/sqlite/sqlite3_os_go.c | 48 +++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/misc/sqlite/sqlite3_os_go.c b/misc/sqlite/sqlite3_os_go.c index 677a8fdd8..2119c4192 100644 --- a/misc/sqlite/sqlite3_os_go.c +++ b/misc/sqlite/sqlite3_os_go.c @@ -18,7 +18,7 @@ struct GoFile { /* File methods */ static int go_file_close(sqlite3_file* file) { - int fd = ((GoFile*) file)->fd; + const int fd = ((GoFile*) file)->fd; fprintf(stderr, "go_file_close(%d)\n", fd); return GoFileClose(fd == 0 ? SQLITE_OK : SQLITE_ERROR); } @@ -33,21 +33,21 @@ static int go_file_write(sqlite3_file* file, const void* src, int iAmt, sqlite3_ } static int go_file_truncate(sqlite3_file* file, sqlite3_int64 size) { - int fd = ((GoFile*) file)->fd; + const int fd = ((GoFile*) file)->fd; fprintf(stderr, "TODO go_file_truncate(%d)\n", fd); // TODO: implement return SQLITE_OK; } static int go_file_sync(sqlite3_file* file, int flags) { - int fd = ((GoFile*) file)->fd; + const int fd = ((GoFile*) file)->fd; fprintf(stderr, "TODO go_file_sync(%d)\n", fd); // TODO: implement return SQLITE_OK; } static int go_file_file_size(sqlite3_file* file, sqlite3_int64* pSize) { - int fd = ((GoFile*) file)->fd; + const int fd = ((GoFile*) file)->fd; struct GoFileFileSize_return result = GoFileFileSize(fd); fprintf(stderr, "go_file_file_size(%d) = %d, %lld\n", fd, result.r0, result.r1); if (result.r0 != 0) { @@ -59,19 +59,47 @@ static int go_file_file_size(sqlite3_file* file, sqlite3_int64* pSize) { } static int go_file_lock(sqlite3_file* file, int flags) { - int fd = ((GoFile*) file)->fd; + const int fd = ((GoFile*) file)->fd; fprintf(stderr, "TODO go_file_lock(%d)\n", fd); // TODO: implement return SQLITE_OK; } static int go_file_unlock(sqlite3_file* file, int flags) { - int fd = ((GoFile*) file)->fd; + const int fd = ((GoFile*) file)->fd; fprintf(stderr, "TODO go_file_unlock(%d)\n", fd); // TODO: implement return SQLITE_OK; } +static int go_file_check_reserved_lock(sqlite3_file* file, int* pResOut) { + const int fd = ((GoFile*) file)->fd; + fprintf(stderr, "TODO go_file_check_reserved_lock(%d)\n", fd); + // TODO: implement + return SQLITE_OK; +} + +static int go_file_file_control(sqlite3_file* file, int op, void* pArg) { + const int fd = ((GoFile*) file)->fd; + fprintf(stderr, "TODO go_file_file_control(%d, %d)\n", fd, op); + // TODO: implement + return SQLITE_OK; +} + +static int go_file_sector_size(sqlite3_file* file) { + const int fd = ((GoFile*) file)->fd; + fprintf(stderr, "TODO go_file_sector_size(%d)\n", fd); + // TODO: implement + return 512; +} + +static int go_file_device_characteristics(sqlite3_file* file) { + const int fd = ((GoFile*) file)->fd; + fprintf(stderr, "TODO go_file_device_characteristics(%d)\n", fd); + // TODO: implement + return 0; +} + /* VFS methods */ static int go_vfs_open(sqlite3_vfs* vfs, @@ -212,11 +240,11 @@ int sqlite3_os_init(void) { g_file_methods.xFileSize = go_file_file_size; g_file_methods.xLock = go_file_lock; g_file_methods.xUnlock = go_file_unlock; + g_file_methods.xCheckReservedLock = go_file_check_reserved_lock; + g_file_methods.xFileControl = go_file_file_control; + g_file_methods.xSectorSize = go_file_sector_size; + g_file_methods.xDeviceCharacteristics = go_file_device_characteristics; #if 0 - int (*xCheckReservedLock)(sqlite3_file*, int *pResOut); - int (*xFileControl)(sqlite3_file*, int op, void *pArg); - int (*xSectorSize)(sqlite3_file*); - int (*xDeviceCharacteristics)(sqlite3_file*); /* Methods above are valid for version 1 */ int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, void volatile**); int (*xShmLock)(sqlite3_file*, int offset, int n, int flags);