Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Initial attempt at defining the sqlite3_initialize() and sqlite3_shutdown() interfaces. (CVS 5198) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
220bfd1f5cef0dfa8b800faa814ad4dc |
User & Date: | drh 2008-06-09 21:57:23.000 |
Context
2008-06-10
| ||
17:30 | Invalidate sqlite3_blob* handles whenever an SQL statement is used to delete or modify the rows containing the open blob. Previously, modifying the table containing the open blob in any way invalidated the handle. This was too restrictive. (CVS 5199) (check-in: e339c91f87 user: danielk1977 tags: trunk) | |
2008-06-09
| ||
21:57 | Initial attempt at defining the sqlite3_initialize() and sqlite3_shutdown() interfaces. (CVS 5198) (check-in: 220bfd1f5c user: drh tags: trunk) | |
19:27 | Moved declaration of int nPage; to top of block to silence picky compilers (MSVC). (CVS 5197) (check-in: 120bffff74 user: shane tags: trunk) | |
Changes
Changes to src/os.h.
︙ | ︙ | |||
13 14 15 16 17 18 19 | ** This header file (together with is companion C source-code file ** "os.c") attempt to abstract the underlying operating system so that ** the SQLite library will work on both POSIX and windows systems. ** ** This header file is #include-ed by sqliteInt.h and thus ends up ** being included by every source file. ** | | | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | ** This header file (together with is companion C source-code file ** "os.c") attempt to abstract the underlying operating system so that ** the SQLite library will work on both POSIX and windows systems. ** ** This header file is #include-ed by sqliteInt.h and thus ends up ** being included by every source file. ** ** $Id: os.h,v 1.103 2008/06/09 21:57:23 drh Exp $ */ #ifndef _SQLITE_OS_H_ #define _SQLITE_OS_H_ /* ** Figure out if we are dealing with Unix, Windows, or some other ** operating system. After the following block of preprocess macros, |
︙ | ︙ | |||
249 250 251 252 253 254 255 | /* ** Functions for accessing sqlite3_vfs methods */ int sqlite3OsOpen(sqlite3_vfs *, const char *, sqlite3_file*, int, int *); int sqlite3OsDelete(sqlite3_vfs *, const char *, int); int sqlite3OsAccess(sqlite3_vfs *, const char *, int, int *pResOut); | < | 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | /* ** Functions for accessing sqlite3_vfs methods */ int sqlite3OsOpen(sqlite3_vfs *, const char *, sqlite3_file*, int, int *); int sqlite3OsDelete(sqlite3_vfs *, const char *, int); int sqlite3OsAccess(sqlite3_vfs *, const char *, int, int *pResOut); int sqlite3OsFullPathname(sqlite3_vfs *, const char *, int, char *); #ifndef SQLITE_OMIT_LOAD_EXTENSION void *sqlite3OsDlOpen(sqlite3_vfs *, const char *); void sqlite3OsDlError(sqlite3_vfs *, int, char *); void *sqlite3OsDlSym(sqlite3_vfs *, void *, const char *); void sqlite3OsDlClose(sqlite3_vfs *, void *); #endif /* SQLITE_OMIT_LOAD_EXTENSION */ |
︙ | ︙ |
Changes to src/sqlite.h.in.
︙ | ︙ | |||
26 27 28 29 30 31 32 | ** on how SQLite interfaces are suppose to operate. ** ** The name of this file under configuration management is "sqlite.h.in". ** The makefile makes some minor changes to this file (such as inserting ** the version number) and changes its name to "sqlite3.h" as ** part of the build process. ** | | | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | ** on how SQLite interfaces are suppose to operate. ** ** The name of this file under configuration management is "sqlite.h.in". ** The makefile makes some minor changes to this file (such as inserting ** the version number) and changes its name to "sqlite3.h" as ** part of the build process. ** ** @(#) $Id: sqlite.h.in,v 1.323 2008/06/09 21:57:23 drh Exp $ */ #ifndef _SQLITE3_H_ #define _SQLITE3_H_ #include <stdarg.h> /* Needed for the definition of va_list */ /* ** Make sure we can call this stuff from C++. |
︙ | ︙ | |||
148 149 150 151 152 153 154 155 156 157 158 159 160 161 | ** INVARIANTS: ** ** {F10101} The [sqlite3_threadsafe()] function returns nonzero if ** SQLite was compiled with its mutexes enabled or zero ** if SQLite was compiled with mutexes disabled. */ int sqlite3_threadsafe(void); /* ** CAPI3REF: Database Connection Handle {F12000} ** KEYWORDS: {database connection} {database connections} ** ** Each open SQLite database is represented by pointer to an instance of the ** opaque structure named "sqlite3". It is useful to think of an sqlite3 | > | 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | ** INVARIANTS: ** ** {F10101} The [sqlite3_threadsafe()] function returns nonzero if ** SQLite was compiled with its mutexes enabled or zero ** if SQLite was compiled with mutexes disabled. */ int sqlite3_threadsafe(void); /* ** CAPI3REF: Database Connection Handle {F12000} ** KEYWORDS: {database connection} {database connections} ** ** Each open SQLite database is represented by pointer to an instance of the ** opaque structure named "sqlite3". It is useful to think of an sqlite3 |
︙ | ︙ | |||
836 837 838 839 840 841 842 843 844 845 846 847 848 849 | ** if the file is both readable and writable. {F11194} With ** SQLITE_ACCESS_READ the xAccess method ** checks to see if the file is readable. */ #define SQLITE_ACCESS_EXISTS 0 #define SQLITE_ACCESS_READWRITE 1 #define SQLITE_ACCESS_READ 2 /* ** CAPI3REF: Enable Or Disable Extended Result Codes {F12200} ** ** The sqlite3_extended_result_codes() routine enables or disables the ** [SQLITE_IOERR_READ | extended result codes] feature of SQLite. ** The extended result codes are disabled by default for historical | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 | ** if the file is both readable and writable. {F11194} With ** SQLITE_ACCESS_READ the xAccess method ** checks to see if the file is readable. */ #define SQLITE_ACCESS_EXISTS 0 #define SQLITE_ACCESS_READWRITE 1 #define SQLITE_ACCESS_READ 2 /* ** CAPI3REF: SQLite Configuration Definition {F10180} ** ** A pointer to an instance of the sqlite3_configuration structure ** may be optionally passed into the [sqlite3_initialize()] interface ** in order to set up a custom configuration for the SQLite library. ** ** The xMemInit() routine is called with pMemClientData as an argument ** at [sqlite3_initialize()]. xMemShutdown is called at ** [sqlite3_shutdown()]. ** ** If the xMemSize pointer may be omitted, ** but if it is, then the following SQLite interfaces will not work ** correctly: ** ** <ul> ** <li> [sqlite3_memory_used()] ** <li> [sqlite3_memory_highwater()] ** <li> [sqlite3_soft_heap_limit()] ** </ul> ** ** If xMemSize is defined, then SQLite will hold the ** [SQLITE_MUTEX_STATIC_MEM] mutex will accessing any of xMemAlloc, ** xMemRealloc, or xMemFree. If xMemSize is NULL then the ** [SQLITE_MUTEX_STATIC_MEM] mutex is never used. ** ** The xPageAlloc and xPageFree functions are alternative memory ** allocators for page cache pages. If undefined ** then xMemAlloc and xMemFree will be used. ** ** The xTempAlloc and xTempFree functions are alternative memory ** allocators for short-lived temporary space. ** If undefined then xMemAlloc and xMemFree above will be used. ** ** None of the mutex subsystem fields are ever accessed ** if SQLite is compiled with -DSQLITE_THREADSAFE=0. ** ** The xMutexInit routine is called by each effective [sqlite3_initialize()] ** and xMutexShutdown is called by each valid [sqlite3_shutdown()]. ** ** If bSerializeConnection is true then SQLite will use one or more ** [SQLITE_MUTEX_RECURSIVE] mutexes to serialize access to ** [database connection] and [prepared statement] objects. If ** bSerializeConnection is false, then it is the application's ** responsibiility to serialize access to these objects. ** ** The xMutexTry interface is an optimization that does not ** come up often and can be omitted. If omitted, xMutexEnter ** will be used in its place. ** ** The xMutexHeld and xMutexNotHeld interfaces are used for testing ** purposes only. It is ok for these functions to report false ** positives. These functions are only used within the argument of ** assert() statements. */ typedef struct sqlite3_configuration sqlite3_configuration; struct sqlite3_configuration { /* Memory allocation subsystem interface */ void *pMemClientData; /* Argument to xMemInit and xMemShutdown */ int (*xMemInit)(void*); /* May be NULL */ int (*xMemShutdown)(void*); /* May be NULL */ void *(*xMemAlloc)(int); void *(*xMemRealloc)(void*, int); void (*xMemFree)(void*); int (*xMemSize)(void*); /* May be NULL */ /* Alternative memory allocators for page cache and transient storage */ void *(*xPageAlloc)(int iSize); /* May be NULL */ void (*xPageFree)(void*, int iSize); /* May be NULL */ void *(*xTempAlloc)(int iSize); /* May be NULL */ void (*xTempFree)(void*); /* May be NULL */ /* Parameters optionally used by some alternative memory allocators. */ sqlite3_int64 nMemHeap; /* Total memory available for allocating */ void *pMemHeap; /* Pointer to memory space to be allocated */ int mnMemAlloc; /* Minimum allocation size */ int mxMemAlloc; /* Maximum allocation size */ int nTemp; /* Maximum temp space available */ int mxTemp; /* Maximum temp space allocation size */ /* Mutex methods */ void *pMutexClientData; /* Arg to xMutexInit and xMutexShutdown */ int (*xMutexInit)(void*); /* May be NULL */ int (*xMutexShutdown)(void*); /* May be NULL */ int bSerializeConnection; sqlite3_mutex *(*xMutexAlloc)(int mutexType); void (*xMutexFree)(sqlite3_mutex*); void (*xMutexEnter)(sqlite3_mutex*); int (*xMutexTry)(sqlite3_mutex*); /* May be NULL */ void (*xMutexLeave)(sqlite3_mutex*); int (*xMutexHeld)(sqlite3_mutex*); /* May be NULL */ int (*xMutexNotHeld)(sqlite3_mutex*); /* May be NULL */ }; /* ** CAPI3REF: Initialize The SQLite Library {F10140} ** ** The sqlite3_initialize() interface is used to initialize the ** SQLite library. The sqlite3_initialize() routine is only effective ** the first time it is called within a process, or the first time it ** is called after a call to sqlite3_shutdown(). Other SQLite APIs ** might invoke sqlite3_initialize() internally, so in order for ** an application to be sure that its call to sqlite3_initialize() ** is first, it should invoke sqlite3_initialize() prior to invoking any ** other SQLite interface (with the possible exception of ** sqlite3_default_configuration() as described below.) ** ** If the parameter to sqlite3_initialize() is NULL then a default ** configuration is used. A copy of the default configuration can ** be obtained using the sqlite3_default_configuration() interface. ** An application that only wants to make slight adjustments to the ** configuration can invoke sqlite3_default_configuration() to populate ** an initially empty [sqlite3_configuration] structure, make whatever ** changes to that structure are desired, then invoke sqlite3_initialize() ** to register the new configuration. ** ** The sqlite3_default_configuration() interface does not invoke ** sqlite3_initialize() so an application can call ** sqlite3_default_configuration() before sqlite3_initialize() and still ** be assured that its call to sqlite3_initialize() is the first. ** The configuration returned by sqlite3_default_configuration() is ** a compiled-in default. Changing the configuration using a call ** to sqlite3_initialize() does not change the value returned by ** sqlite3_default_configuration(). The sqlite3_default_configuration() ** interface is threadsafe. ** ** The second parameter to both sqlite3_initialize() and ** sqlite3_default_configuration() should always be the ** SQLITE_VERSION_NUMBER constant. The content of the ** [sqlite3_configuration] structure may change in future versions of ** SQLite and so the sqlite3_initialize() and ** sqlite3_default_configuration()) functions need to know the ** version of the header file that defined the [sqlite3_configuration] ** structure in order to use the structure correctly. ** ** The sqlite3_default_configuration() interface returns SQLITE_OK on ** success. If the iVersion parameter is such that SQLite is unable ** to fill in the [sqlite3_configuration] structure, then the interface ** will return SQLITE_ERROR. ** ** The application must insure that the initial call to sqlite3_initialize() ** is serialized. This means that multi-threaded applications should invoke ** sqlite3_initialize() in the main thread prior to starting any other ** threads that might use SQLite. In the general case, SQLite depends on ** the application to serialize access to sqlite3_initialize() because SQLite ** cannot create a mutex to do the serialization itself until after ** sqlite3_initialize() has run. In the current unix and win32 ** implementations, SQLite is able to serialize access to sqlite3_initialize() ** on its own, but this is not true for all embedded platforms and might ** not be true for unix and win32 in future releases. ** ** SQLite makes a copy of the content of the [sqlite3_configuration] structure ** that is passed into sqlite3_initialize(). Hence the application is free ** to deallocate or modify the [sqlite3_configuration] structure after ** sqlite3_initialize() returns. ** ** Once sqlite3_initialize() has been successfully invoked once, all ** subsequent calls to sqlite3_initialize() are ignored until ** sqlite3_shutdown() is run. After sqlite3_shutdown() has been invoked, ** the next call to sqlite3_initialize() is effective for a single call ** but after that sqlite3_initialize() again becomes a no-up. In other words, ** a call to sqlite3_initialize() is only effective if it is the first ** invocation for the process or if it is invoked immediately after a ** call to sqlite3_shutdown(). ** ** The sqlite3_initialize() routine returns SQLITE_OK on success. ** If sqlite3_initialize() returns any value other than SQLITE_OK then ** the SQLite library is not safe to use. ** ** The sqlite3_shutdown() interface clears a prior initialization and ** enables SQLite to be reinitialized. The application must insure that ** the sqlite3_shutdown() interface is only called when there are no ** outstanding memory allocations or mutexes, no open database connections, ** and no other SQLite interfaces are being called in different threads. ** If sqlite3_shutdown() is called while there are still outstanding ** memory allocations or mutexes, or open database connections, or while ** another thread is making a call to any SQLite interface, then the ** result is undefined and could be segmentation fault or other ** fatal application error. ** ** As currently implemented, sqlite3_shutdown() always returns SQLITE_OK, ** however this might change in a future release of SQLite. ** ** The sqlite3_on_shutdown() interface registers a callback to be invoked ** the next time sqlite3_shutdown() is called. Each callback is invoked ** only once at the next sqlite3_shutdown() call. Callbacks must be ** reregistered in order to be run on subsequent sqlite3_shutdown() calls. ** Each call to sqlite3_on_shutdown() allocates a little bit of memory ** used to hold the callback function pointer and the corresponding ** application data pointer. The memory is freed after the callback is ** invoked. The callbacks registered by sqlite3_on_callback() are invoked ** in the order in which they were registered. If the same callback is ** registered multiple times, it is invoked multiple times. All callbacks ** are invoked prior to the xMemShutdown() and xMutexShutdown() methods ** of the sqlite3_configuration structure. ** ** The sqlite3_on_shutdown() interface returns SQLITE_OK on success, or ** SQLITE_NOMEM if it is unable to allocate memory to hold the pointer ** to the callback function and corresponding application data pointer. */ int sqlite3_initialize(const sqlite3_configuration*, int iVersion); int sqlite3_default_configuration(sqlite3_configuration*, int iVersion); int sqlite3_on_shutdown(void (*)(void*), void*); int sqlite3_shutdown(void); /* ** CAPI3REF: Enable Or Disable Extended Result Codes {F12200} ** ** The sqlite3_extended_result_codes() routine enables or disables the ** [SQLITE_IOERR_READ | extended result codes] feature of SQLite. ** The extended result codes are disabled by default for historical |
︙ | ︙ |