MCPcopy Create free account
hub / github.com/WiseLibs/better-sqlite3 / xFileControl

Method xFileControl

src/util/fd-vfs.cpp:639–665  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

637 }
638
639 static int xFileControl(sqlite3_file* f, int op, void* arg) {
640 File* file = reinterpret_cast<File*>(f);
641 switch (op) {
642 case SQLITE_FCNTL_LOCKSTATE:
643 *static_cast<int*>(arg) = file->eFileLock;
644 return SQLITE_OK;
645 case SQLITE_FCNTL_HAS_MOVED:
646 *static_cast<int*>(arg) = !IsLinked(file->fd);
647 return SQLITE_OK;
648 case SQLITE_FCNTL_VFSNAME:
649 *static_cast<char**>(arg) = sqlite3_mprintf("%s", VFS_NAME);
650 return SQLITE_OK;
651 case SQLITE_FCNTL_PRAGMA: {
652 // WAL mode would require creating "-wal" and "-shm" files.
653 char** args = static_cast<char**>(arg);
654 if (args[2] != NULL
655 && sqlite3_stricmp(args[1], "journal_mode") == 0
656 && sqlite3_stricmp(args[2], "wal") == 0) {
657 args[0] = sqlite3_mprintf("journal_mode WAL is not supported for databases opened from file descriptors");
658 return SQLITE_ERROR;
659 }
660 return SQLITE_NOTFOUND;
661 }
662 default:
663 return SQLITE_NOTFOUND;
664 }
665 }
666
667 static constexpr sqlite3_io_methods main_io_methods = {
668 1,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected