| 1 |
<!DOCTYPE html> |
| 2 |
<html><head> |
| 3 |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 4 |
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> |
| 5 |
<link href="../sqlite.css" rel="stylesheet"> |
| 6 |
<title>Initialize The SQLite Library</title> |
| 7 |
<!-- path=../ --> |
| 8 |
</head> |
| 9 |
<body> |
| 10 |
<div class=nosearch> |
| 11 |
<a href="../index.html"> |
| 12 |
<img class="logo" src="../images/sqlite370_banner.svg" alt="SQLite" border="0"> |
| 13 |
</a> |
| 14 |
<div><!-- IE hack to prevent disappearing logo --></div> |
| 15 |
<div class="tagline desktoponly"> |
| 16 |
Small. Fast. Reliable.<br>Choose any three. |
| 17 |
</div> |
| 18 |
<div class="menu mainmenu"> |
| 19 |
<ul> |
| 20 |
<li><a href="../index.html">Home</a> |
| 21 |
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a> |
| 22 |
<li class='wideonly'><a href='../about.html'>About</a> |
| 23 |
<li class='desktoponly'><a href="../docs.html">Documentation</a> |
| 24 |
<li class='desktoponly'><a href="../download.html">Download</a> |
| 25 |
<li class='wideonly'><a href='../copyright.html'>License</a> |
| 26 |
<li class='desktoponly'><a href="../support.html">Support</a> |
| 27 |
<li class='desktoponly'><a href="../prosupport.html">Purchase</a> |
| 28 |
<li class='search' id='search_menubutton'> |
| 29 |
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a> |
| 30 |
</ul> |
| 31 |
</div> |
| 32 |
<div class="menu submenu" id="submenu"> |
| 33 |
<ul> |
| 34 |
<li><a href='../about.html'>About</a> |
| 35 |
<li><a href='../docs.html'>Documentation</a> |
| 36 |
<li><a href='../download.html'>Download</a> |
| 37 |
<li><a href='../support.html'>Support</a> |
| 38 |
<li><a href='../prosupport.html'>Purchase</a> |
| 39 |
</ul> |
| 40 |
</div> |
| 41 |
<div class="searchmenu" id="searchmenu"> |
| 42 |
<form method="GET" action="../search"> |
| 43 |
<select name="s" id="searchtype"> |
| 44 |
<option value="d">Search Documentation</option> |
| 45 |
<option value="c">Search Changelog</option> |
| 46 |
</select> |
| 47 |
<input type="text" name="q" id="searchbox" value=""> |
| 48 |
<input type="submit" value="Go"> |
| 49 |
</form> |
| 50 |
</div> |
| 51 |
</div> |
| 52 |
<script> |
| 53 |
function toggle_div(nm) { |
| 54 |
var w = document.getElementById(nm); |
| 55 |
if( w.style.display=="block" ){ |
| 56 |
w.style.display = "none"; |
| 57 |
}else{ |
| 58 |
w.style.display = "block"; |
| 59 |
} |
| 60 |
} |
| 61 |
function toggle_search() { |
| 62 |
var w = document.getElementById("searchmenu"); |
| 63 |
if( w.style.display=="block" ){ |
| 64 |
w.style.display = "none"; |
| 65 |
} else { |
| 66 |
w.style.display = "block"; |
| 67 |
setTimeout(function(){ |
| 68 |
document.getElementById("searchbox").focus() |
| 69 |
}, 30); |
| 70 |
} |
| 71 |
} |
| 72 |
function div_off(nm){document.getElementById(nm).style.display="none";} |
| 73 |
window.onbeforeunload = function(e){div_off("submenu");} |
| 74 |
/* Disable the Search feature if we are not operating from CGI, since */ |
| 75 |
/* Search is accomplished using CGI and will not work without it. */ |
| 76 |
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){ |
| 77 |
document.getElementById("search_menubutton").style.display = "none"; |
| 78 |
} |
| 79 |
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */ |
| 80 |
function hideorshow(btn,obj){ |
| 81 |
var x = document.getElementById(obj); |
| 82 |
var b = document.getElementById(btn); |
| 83 |
if( x.style.display!='none' ){ |
| 84 |
x.style.display = 'none'; |
| 85 |
b.innerHTML='show'; |
| 86 |
}else{ |
| 87 |
x.style.display = ''; |
| 88 |
b.innerHTML='hide'; |
| 89 |
} |
| 90 |
return false; |
| 91 |
} |
| 92 |
var antiRobot = 0; |
| 93 |
function antiRobotGo(){ |
| 94 |
if( antiRobot!=3 ) return; |
| 95 |
antiRobot = 7; |
| 96 |
var j = document.getElementById("mtimelink"); |
| 97 |
if(j && j.hasAttribute("data-href")) j.href=j.getAttribute("data-href"); |
| 98 |
} |
| 99 |
function antiRobotDefense(){ |
| 100 |
document.body.onmousedown=function(){ |
| 101 |
antiRobot |= 2; |
| 102 |
antiRobotGo(); |
| 103 |
document.body.onmousedown=null; |
| 104 |
} |
| 105 |
document.body.onmousemove=function(){ |
| 106 |
antiRobot |= 2; |
| 107 |
antiRobotGo(); |
| 108 |
document.body.onmousemove=null; |
| 109 |
} |
| 110 |
setTimeout(function(){ |
| 111 |
antiRobot |= 1; |
| 112 |
antiRobotGo(); |
| 113 |
}, 100) |
| 114 |
antiRobotGo(); |
| 115 |
} |
| 116 |
antiRobotDefense(); |
| 117 |
</script> |
| 118 |
<!-- keywords: sqlite3_initialize sqlite3_os_end sqlite3_os_init sqlite3_shutdown --> |
| 119 |
<div class=nosearch> |
| 120 |
<a href="../c3ref/intro.html"><h2>SQLite C Interface</h2></a> |
| 121 |
<h2>Initialize The SQLite Library</h2> |
| 122 |
</div> |
| 123 |
<blockquote><pre> |
| 124 |
int sqlite3_initialize(void); |
| 125 |
int sqlite3_shutdown(void); |
| 126 |
int sqlite3_os_init(void); |
| 127 |
int sqlite3_os_end(void); |
| 128 |
</pre></blockquote> |
| 129 |
<p> |
| 130 |
The sqlite3_initialize() routine initializes the |
| 131 |
SQLite library. The sqlite3_shutdown() routine |
| 132 |
deallocates any resources that were allocated by sqlite3_initialize(). |
| 133 |
These routines are designed to aid in process initialization and |
| 134 |
shutdown on embedded systems. Workstation applications using |
| 135 |
SQLite normally do not need to invoke either of these routines.</p> |
| 136 |
|
| 137 |
<p>A call to sqlite3_initialize() is an "effective" call if it is |
| 138 |
the first time sqlite3_initialize() is invoked during the lifetime of |
| 139 |
the process, or if it is the first time sqlite3_initialize() is invoked |
| 140 |
following a call to sqlite3_shutdown(). Only an effective call |
| 141 |
of sqlite3_initialize() does any initialization. All other calls |
| 142 |
are harmless no-ops.</p> |
| 143 |
|
| 144 |
<p>A call to sqlite3_shutdown() is an "effective" call if it is the first |
| 145 |
call to sqlite3_shutdown() since the last sqlite3_initialize(). Only |
| 146 |
an effective call to sqlite3_shutdown() does any deinitialization. |
| 147 |
All other valid calls to sqlite3_shutdown() are harmless no-ops.</p> |
| 148 |
|
| 149 |
<p>The sqlite3_initialize() interface is threadsafe, but sqlite3_shutdown() |
| 150 |
is not. The sqlite3_shutdown() interface must only be called from a |
| 151 |
single thread. All open <a href="../c3ref/sqlite3.html">database connections</a> must be closed and all |
| 152 |
other SQLite resources must be deallocated prior to invoking |
| 153 |
sqlite3_shutdown().</p> |
| 154 |
|
| 155 |
<p>Among other things, sqlite3_initialize() will invoke |
| 156 |
sqlite3_os_init(). Similarly, sqlite3_shutdown() |
| 157 |
will invoke sqlite3_os_end().</p> |
| 158 |
|
| 159 |
<p>The sqlite3_initialize() routine returns <a href="../rescode.html#ok">SQLITE_OK</a> on success. |
| 160 |
If for some reason, sqlite3_initialize() is unable to initialize |
| 161 |
the library (perhaps it is unable to allocate a needed resource such |
| 162 |
as a mutex) it returns an <a href="../rescode.html">error code</a> other than <a href="../rescode.html#ok">SQLITE_OK</a>.</p> |
| 163 |
|
| 164 |
<p>The sqlite3_initialize() routine is called internally by many other |
| 165 |
SQLite interfaces so that an application usually does not need to |
| 166 |
invoke sqlite3_initialize() directly. For example, <a href="../c3ref/open.html">sqlite3_open()</a> |
| 167 |
calls sqlite3_initialize() so the SQLite library will be automatically |
| 168 |
initialized when <a href="../c3ref/open.html">sqlite3_open()</a> is called if it has not been initialized |
| 169 |
already. However, if SQLite is compiled with the <a href="../compile.html#omit_autoinit">SQLITE_OMIT_AUTOINIT</a> |
| 170 |
compile-time option, then the automatic calls to sqlite3_initialize() |
| 171 |
are omitted and the application must call sqlite3_initialize() directly |
| 172 |
prior to using any other SQLite interface. For maximum portability, |
| 173 |
it is recommended that applications always invoke sqlite3_initialize() |
| 174 |
directly prior to using any other SQLite interface. Future releases |
| 175 |
of SQLite may require this. In other words, the behavior exhibited |
| 176 |
when SQLite is compiled with <a href="../compile.html#omit_autoinit">SQLITE_OMIT_AUTOINIT</a> might become the |
| 177 |
default behavior in some future release of SQLite.</p> |
| 178 |
|
| 179 |
<p>The sqlite3_os_init() routine does operating-system specific |
| 180 |
initialization of the SQLite library. The sqlite3_os_end() |
| 181 |
routine undoes the effect of sqlite3_os_init(). Typical tasks |
| 182 |
performed by these routines include allocation or deallocation |
| 183 |
of static resources, initialization of global variables, |
| 184 |
setting up a default <a href="../c3ref/vfs.html">sqlite3_vfs</a> module, or setting up |
| 185 |
a default configuration using <a href="../c3ref/config.html">sqlite3_config()</a>.</p> |
| 186 |
|
| 187 |
<p>The application should never invoke either sqlite3_os_init() |
| 188 |
or sqlite3_os_end() directly. The application should only invoke |
| 189 |
sqlite3_initialize() and sqlite3_shutdown(). The sqlite3_os_init() |
| 190 |
interface is called automatically by sqlite3_initialize() and |
| 191 |
sqlite3_os_end() is called by sqlite3_shutdown(). Appropriate |
| 192 |
implementations for sqlite3_os_init() and sqlite3_os_end() |
| 193 |
are built into SQLite when it is compiled for Unix, Windows, or OS/2. |
| 194 |
When <a href="../custombuild.html">built for other platforms</a> |
| 195 |
(using the <a href="../compile.html#os_other">SQLITE_OS_OTHER=1</a> compile-time |
| 196 |
option) the application must supply a suitable implementation for |
| 197 |
sqlite3_os_init() and sqlite3_os_end(). An application-supplied |
| 198 |
implementation of sqlite3_os_init() or sqlite3_os_end() |
| 199 |
must return <a href="../rescode.html#ok">SQLITE_OK</a> on success and some other <a href="../rescode.html">error code</a> upon |
| 200 |
failure. |
| 201 |
</p><p>See also lists of |
| 202 |
<a href="../c3ref/objlist.html">Objects</a>, |
| 203 |
<a href="../c3ref/constlist.html">Constants</a>, and |
| 204 |
<a href="../c3ref/funclist.html">Functions</a>.</p> |
| 205 |
|